@ostack.tech/ui-kform 0.1.2 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/en-C1hDoCmB.js +135 -0
- package/dist/chunks/en-C1hDoCmB.js.map +1 -0
- package/dist/locales/en-GB.js +10 -0
- package/dist/locales/en-GB.js.map +1 -0
- package/dist/locales/en-US.js +10 -0
- package/dist/locales/en-US.js.map +1 -0
- package/dist/locales/fr.js +137 -0
- package/dist/locales/fr.js.map +1 -0
- package/dist/locales/pt.js +137 -0
- package/dist/locales/pt.js.map +1 -0
- package/dist/ostack-ui-kform.js +1129 -1472
- package/dist/ostack-ui-kform.js.map +1 -1
- package/dist/types/components/Annexes/Annex.d.ts +5 -5
- package/dist/types/components/Annexes/Annexes.d.ts +10 -10
- package/dist/types/components/Annexes/AnnexesContext.d.ts +5 -5
- package/dist/types/components/Annexes/AnnexesManager.d.ts +15 -15
- package/dist/types/components/Annexes/AnnexesMenu.d.ts +4 -4
- package/dist/types/components/Annexes/AnnexesTabList.d.ts +3 -3
- package/dist/types/components/CheckboxControl/CheckboxControl.d.ts +6 -6
- package/dist/types/components/CheckboxGroupControl/CheckboxGroupControl.d.ts +9 -9
- package/dist/types/components/ControlField/ControlField.d.ts +3 -3
- package/dist/types/components/ControlField/ControlFieldContext.d.ts +1 -2
- package/dist/types/components/DateControl/DateControl.d.ts +6 -6
- package/dist/types/components/DateRangeControl/DateRangeControl.d.ts +9 -9
- package/dist/types/components/FileControl/FileControl.d.ts +9 -9
- package/dist/types/components/FormApp/FormApp.d.ts +23 -15
- package/dist/types/components/FormApp/FormAppAutoFocus.d.ts +2 -0
- package/dist/types/components/FormApp/FormAppContext.d.ts +11 -13
- package/dist/types/components/FormApp/FormAppElement.d.ts +9 -0
- package/dist/types/components/FormApp/FormAppIssueMessages.d.ts +3 -3
- package/dist/types/components/FormApp/FormAppStatus.d.ts +2 -2
- package/dist/types/components/FormPages/FormPage.d.ts +17 -17
- package/dist/types/components/FormPages/FormPageHeader.d.ts +3 -3
- package/dist/types/components/FormPages/FormPages.d.ts +7 -7
- package/dist/types/components/FormPages/FormPagesContext.d.ts +4 -4
- package/dist/types/components/FormPages/FormPagesNavigation.d.ts +5 -5
- package/dist/types/components/FormPages/FormPagesSelect.d.ts +3 -3
- package/dist/types/components/FormPages/FormPagesSidebar.d.ts +3 -3
- package/dist/types/components/FormStepper/FormStepContent.d.ts +5 -5
- package/dist/types/components/FormStepper/FormStepList.d.ts +3 -3
- package/dist/types/components/FormStepper/FormStepper.d.ts +5 -5
- package/dist/types/components/FormStepper/FormStepperContext.d.ts +3 -3
- package/dist/types/components/IssueAlert/IssueAlert.d.ts +4 -4
- package/dist/types/components/IssueMessage/IssueMessage.d.ts +4 -4
- package/dist/types/components/IssueMessages/IssueMessages.d.ts +6 -6
- package/dist/types/components/IssuesPanel/IssuesPanel.d.ts +25 -25
- package/dist/types/components/IssuesPanel/IssuesPanelMessagesCard.d.ts +4 -4
- package/dist/types/components/IssuesPanel/IssuesPanelSummaryCard.d.ts +4 -4
- package/dist/types/components/IssuesPopover/IssuesPopover.d.ts +3 -3
- package/dist/types/components/LoadAction/LoadAction.d.ts +2 -2
- package/dist/types/components/NumericControl/NumericControl.d.ts +6 -6
- package/dist/types/components/PathLink/PathLink.d.ts +2 -2
- package/dist/types/components/RadioGroupControl/RadioGroupControl.d.ts +9 -9
- package/dist/types/components/SaveAction/SaveAction.d.ts +6 -6
- package/dist/types/components/SelectControl/SelectControl.d.ts +6 -6
- package/dist/types/components/SelectMultipleControl/SelectMultipleControl.d.ts +6 -6
- package/dist/types/components/SubmitAction/SubmitAction.d.ts +20 -20
- package/dist/types/components/TableControl/TableControl.d.ts +7 -7
- package/dist/types/components/TableControl/TableControlAddRowTrigger.d.ts +4 -4
- package/dist/types/components/TableControl/TableControlApi.d.ts +2 -2
- package/dist/types/components/TableControl/TableControlCell.d.ts +3 -3
- package/dist/types/components/TableControl/TableControlColumn.d.ts +3 -3
- package/dist/types/components/TableControl/TableControlContent.d.ts +3 -3
- package/dist/types/components/TableControl/TableControlContext.d.ts +4 -4
- package/dist/types/components/TableControl/TableControlRemoveRowTrigger.d.ts +9 -9
- package/dist/types/components/TableControl/TableControlRow.d.ts +3 -3
- package/dist/types/components/TextControl/TextControl.d.ts +8 -8
- package/dist/types/components/TopBar/TopBar.d.ts +3 -3
- package/dist/types/components/TopBar/TopBarActions.d.ts +3 -3
- package/dist/types/components/ValidateAction/ValidateAction.d.ts +2 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/locales/en-GB.d.ts +3 -0
- package/dist/types/locales/en-US.d.ts +3 -0
- package/dist/types/{locale → locales}/en.d.ts +2 -2
- package/dist/types/locales/fr.d.ts +3 -0
- package/dist/types/locales/index.d.ts +4 -0
- package/dist/types/locales/pt.d.ts +3 -0
- package/dist/types/providers/LocalizationProvider/LocalizationContext.d.ts +6 -4
- package/dist/types/{locale → providers/LocalizationProvider}/LocalizationObject.d.ts +14 -15
- package/dist/types/providers/LocalizationProvider/LocalizationProvider.d.ts +17 -6
- package/dist/types/providers/LocalizationProvider/index.d.ts +1 -0
- package/dist/types/providers/LocalizationProvider/useLocale.d.ts +6 -3
- package/dist/types/providers/PrefixSuffixProvider/PrefixSuffixContext.d.ts +1 -4
- package/dist/types/providers/PrefixSuffixProvider/PrefixSuffixProvider.d.ts +3 -3
- package/dist/types/providers/PrefixSuffixProvider/defaultPrefixSuffix.d.ts +12 -0
- package/dist/types/providers/PrefixSuffixProvider/index.d.ts +1 -0
- package/dist/types/utils/options.d.ts +4 -4
- package/dist/types/utils/selectionTransformations.d.ts +2 -1
- package/dist/types/utils/useControlAutofocus.d.ts +2 -2
- package/dist/types/utils/useControlIssues.d.ts +3 -3
- package/dist/types/utils/useFormLoader.d.ts +3 -3
- package/dist/types/utils/useFormSaver.d.ts +3 -3
- package/dist/types/utils/useRegisterControl.d.ts +6 -6
- package/package.json +21 -5
- package/dist/ostack-ui-kform.cjs +0 -7534
- package/dist/ostack-ui-kform.cjs.map +0 -1
- package/dist/types/locale/defaultLocale.d.ts +0 -3
- package/dist/types/locale/en-GB.d.ts +0 -3
- package/dist/types/locale/en-US.d.ts +0 -3
- package/dist/types/locale/fr-FR.d.ts +0 -3
- package/dist/types/locale/index.d.ts +0 -6
- package/dist/types/locale/pt-PT.d.ts +0 -3
package/dist/ostack-ui-kform.js
CHANGED
|
@@ -1,21 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ValidationFailure, Path, AbsolutePathFragment, PathMultimap, AbsolutePath, sliceTable, listableSize, nullableSchemaInnerSchema, compareSchemaPaths, PromiseCancellationException, arrayToTable, indexOfTableRowId, isComputedSchema } from "@ostack.tech/kform";
|
|
2
|
+
import { usePrefix as usePrefix$1, useErrorReporter, useConstant, EMPTY_STORE, Field, Feedback, FeedbackList, useLatestValues, useSpacing, useCssVars, NATIVE_CONTROLS, useResponsiveValues, useCombinedRef, cx, useIsInRoot, warnOnce, PrefixProvider, Root, useToastManager, Tabs, computed, TabContent, ErrorBoundary, DocumentTitle, Spinner, useControllableState, FeedbackPopover, combineEventHandlers, useMediaBreakpointUp, DropdownMenu, DropdownMenuTrigger, Button, DropdownMenuContent, DropdownMenuRadioGroup, DropdownMenuGroup, DropdownMenuSub, DropdownMenuSubTrigger, DropdownMenuSubContent, DropdownMenuItem, useAlertDialog, DropdownMenuRadioItem, controlStatusToAccent, VisuallyHidden, IconButton, Tab, boolDataAttr, TabList, useIsInTableCell, useDataTableColumnLabel, useOnFieldLabelChange, useDateTransformer, DateRangeInput, Input, Dialog, Tooltip, DialogTrigger, ControlAddon, Icon, DialogContent, DialogHeader, DialogTitle, DialogBody, Alert, Stack, Popover, PopoverTrigger, PopoverContent, useMeasure, Container, Option, Select, MenuListItem, MenuList, CloseButton, useScrollPosition, setBoolDataAttr, Card, CardHeader, CardTitle, CardBody, useIntersectionObserver, useKeyboardShortcut, ButtonGroup, AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogHeader, AlertDialogTitle, AlertDialogBody, AlertDialogDescription, Checkbox, AlertDialogFooter, AlertDialogCancel, AlertDialogAction, Slot, DataTableCell, DataTableRow, useDataTableApiRef, DataTable, DataTableContent, DataTablePagination, DataTableRowsPerPage, LocalizationProvider as LocalizationProvider$1, OptionsGroup, CheckboxGroup, DateInput, Stepper, StepContent, Step, StepList, NumericInput, Link, RadioGroup, Radio, TextArea, PortalContext } from "@ostack.tech/ui";
|
|
2
3
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
4
|
-
import { AtPathError, useFormManager, CurrentPath, useResolvedPath, useIssuesTracker, equals, useForm, FormContext,
|
|
5
|
-
import * as React from "react";
|
|
6
|
-
import { Suspense, createElement } from "react";
|
|
4
|
+
import { createContext, useContext, useCallback, useEffect, forwardRef, useMemo, useDeferredValue, useRef, useState, useImperativeHandle, startTransition, Suspense, memo, createElement } from "react";
|
|
5
|
+
import { AtPathError, useFormManager, CurrentPath, useResolvedPath, useIssuesTracker, equals, useFormController, useForm, FormContext, useFormattedValue, InvalidPathError, useCurrentPath, useFormContext, formatTemporalAsString, useTemporalInput, useFileInput, useController, useFormatter, useInput, useListableInput, useNumericInput, formatNumericAsString } from "@ostack.tech/kform-react";
|
|
7
6
|
import { createStore, useStore } from "zustand";
|
|
7
|
+
import { subscribeWithSelector } from "zustand/middleware";
|
|
8
8
|
import { useShallow } from "zustand/react/shallow";
|
|
9
9
|
import { shallow } from "zustand/shallow";
|
|
10
10
|
import { supported, fileOpen, fileSave } from "browser-fs-access";
|
|
11
|
-
import {
|
|
11
|
+
import { enGB } from "./locales/en-GB.js";
|
|
12
|
+
import { enUS } from "./locales/en-US.js";
|
|
13
|
+
import { fr } from "./locales/fr.js";
|
|
14
|
+
import { pt } from "./locales/pt.js";
|
|
12
15
|
import { faChevronUp, faChevronDown, faTrash, faFileLines, faDownload, faCircleQuestion, faArrowsToDot, faAnglesLeft, faAngleLeft, faAngleRight, faAnglesRight, faCircleCheck, faCircleExclamation, faTriangleExclamation, faFolderOpen, faFloppyDisk, faCaretDown, faArrowRight, faPlus } from "@fortawesome/free-solid-svg-icons";
|
|
13
|
-
import { faCircleCheck as faCircleCheck$1 } from "@fortawesome/free-regular-svg-icons";
|
|
14
16
|
import { addDays, min, max, parseISO, format } from "date-fns";
|
|
17
|
+
import { faCircleCheck as faCircleCheck$1 } from "@fortawesome/free-regular-svg-icons";
|
|
15
18
|
const DEFAULT_PREFIX_SUFFIX = "kform-";
|
|
16
|
-
const
|
|
17
|
-
DEFAULT_PREFIX_SUFFIX
|
|
18
|
-
);
|
|
19
|
+
const defaultPrefixSuffixStore = createStore(() => ({
|
|
20
|
+
defaultPrefixSuffix: DEFAULT_PREFIX_SUFFIX
|
|
21
|
+
}));
|
|
22
|
+
function setDefaultPrefixSuffix(defaultPrefixSuffix) {
|
|
23
|
+
defaultPrefixSuffixStore.setState({ defaultPrefixSuffix });
|
|
24
|
+
}
|
|
25
|
+
const PrefixSuffixContext = createContext(null);
|
|
19
26
|
function PrefixSuffixProvider({
|
|
20
27
|
prefixSuffix,
|
|
21
28
|
children
|
|
@@ -24,187 +31,16 @@ function PrefixSuffixProvider({
|
|
|
24
31
|
}
|
|
25
32
|
function usePrefix() {
|
|
26
33
|
const prefix = usePrefix$1();
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
(
|
|
34
|
+
const defaultPrefixSuffix = useStore(
|
|
35
|
+
defaultPrefixSuffixStore,
|
|
36
|
+
({ defaultPrefixSuffix: defaultPrefixSuffix2 }) => defaultPrefixSuffix2
|
|
37
|
+
);
|
|
38
|
+
const prefixSuffix = useContext(PrefixSuffixContext) ?? defaultPrefixSuffix;
|
|
39
|
+
return useCallback(
|
|
40
|
+
(toPrefix = "") => prefix(`${prefixSuffix}${toPrefix}`),
|
|
30
41
|
[prefix, prefixSuffix]
|
|
31
42
|
);
|
|
32
43
|
}
|
|
33
|
-
const ptPT = {
|
|
34
|
-
uiLocale: ptPT$1,
|
|
35
|
-
languageTag: "pt-PT",
|
|
36
|
-
AnnexesManager: {
|
|
37
|
-
"aria-label": "Anexos do formulário",
|
|
38
|
-
menuButtonText: "Anexos",
|
|
39
|
-
addAnnexText: "Adicionar anexo",
|
|
40
|
-
removeAnnexButtonLabel: "Remover anexo",
|
|
41
|
-
removeAnnexKeyboardHint: "Pressione a tecla “Delete” para remover o anexo",
|
|
42
|
-
removeAnnexConfirmDialogTitle: "Remover anexo",
|
|
43
|
-
removeAnnexConfirmDialogMessage: (annexName) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
44
|
-
"Tem a certeza que pretende remover o anexo ",
|
|
45
|
-
annexName,
|
|
46
|
-
"?"
|
|
47
|
-
] }),
|
|
48
|
-
removeAnnexConfirmDialogOkText: "Remover"
|
|
49
|
-
},
|
|
50
|
-
DateRangeControl: {
|
|
51
|
-
issuesPanelStartLabelSuffix: " (data de início)",
|
|
52
|
-
issuesPanelEndLabelSuffix: " (data de fim)"
|
|
53
|
-
},
|
|
54
|
-
FileControl: {
|
|
55
|
-
viewFileButtonLabel: "Visualizar ficheiro",
|
|
56
|
-
downloadFileButtonLabel: "Descarregar ficheiro",
|
|
57
|
-
fallbackText: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
58
|
-
"O ficheiro selecionado não pode ser visualizado neste navegador.",
|
|
59
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
60
|
-
"Por favor use o botão acima para descarregar o ficheiro. Pode depois abri-lo utilizando uma aplicação externa."
|
|
61
|
-
] })
|
|
62
|
-
},
|
|
63
|
-
FormApp: {
|
|
64
|
-
issuesPanelLabel: "Formulário",
|
|
65
|
-
issueMessages: {
|
|
66
|
-
"/**": {
|
|
67
|
-
valueMissing: "Campo de preenchimento obrigatório.",
|
|
68
|
-
valueDisallowed: "Valor indicado não permitido.",
|
|
69
|
-
rangeUnderflow: "Valor inferior ao mínimo permitido.",
|
|
70
|
-
rangeOverflow: "Valor excede o máximo permitido.",
|
|
71
|
-
lengthMismatch: (_data, { typeInfo: { name, restrictions } }) => name === "String" && typeof restrictions.minLength === "number" && restrictions.minLength === restrictions.maxLength ? `Valor deve ter ${restrictions.minLength} ${restrictions.minLength === 1 ? "carácter" : "caracteres"}.` : "Valor tem comprimento inválido.",
|
|
72
|
-
tooShort: (_data, { typeInfo: { name, restrictions } }) => name === "String" && typeof restrictions.minLength === "number" ? `Valor não deve ter menos de ${restrictions.minLength} ${restrictions.minLength === 1 ? "caractér" : "caracteres"}.` : "Valor demasiado curto.",
|
|
73
|
-
tooLong: (_data, { typeInfo: { name, restrictions } }) => name === "String" && typeof restrictions.maxLength === "number" ? `Valor não deve ter mais de ${restrictions.maxLength} ${restrictions.maxLength === 1 ? "caractér" : "caracteres"}.` : "Valor demasiado longo.",
|
|
74
|
-
sizeMismatch: (_data, { typeInfo: { restrictions } }) => typeof restrictions.minSize === "number" && restrictions.minSize === restrictions.maxSize ? `Campo deve ter ${restrictions.minSize} ${restrictions.minSize === 1 ? "item" : "itens"}.` : "Campo tem número inválido de itens.",
|
|
75
|
-
tooSmall: (_data, { typeInfo: { restrictions } }) => typeof restrictions.minLength === "number" ? `Campo não deve ter menos de ${restrictions.minLength} ${restrictions.minLength === 1 ? "item" : "itens"}.` : "Número de itens do campo não é suficiente.",
|
|
76
|
-
tooLarge: (_data, { typeInfo: { restrictions } }) => typeof restrictions.maxLength === "number" ? `Campo não deve ter mais de ${restrictions.maxLength} ${restrictions.maxLength === 1 ? "item" : "itens"}.` : "Número de itens do campo excede o limite permitido.",
|
|
77
|
-
scaleMismatch: (_data, { typeInfo: { restrictions } }) => typeof restrictions.scale === "number" ? `Valor deve ter ${restrictions.scale} ${restrictions.scale === 1 ? "casa decimal" : "casas decimais"}.` : "Valor tem número inválido de casas decimais.",
|
|
78
|
-
patternMismatch: "Valor não segue o padrão permitido.",
|
|
79
|
-
emailPatternMismatch: "Endereço de correio eletrónico inválido.",
|
|
80
|
-
fileTypeMismatch: (_data, { typeInfo: { restrictions } }) => Array.isArray(restrictions.acceptedFileTypes) ? `Apenas os seguintes tipos de ficheiro são permitidos: ${restrictions.acceptedFileTypes.join(", ")}.` : "Tipo do ficheiro indicado não é permitido.",
|
|
81
|
-
itemsRepeated: ({ firstIndex, secondIndex }) => firstIndex != null && secondIndex != null ? `Itens ${+firstIndex + 1} e ${+secondIndex + 1} encontram-se repetidos.` : "Campo contém itens repetidos.",
|
|
82
|
-
computedValueMismatch: "O valor difere do valor calculado.",
|
|
83
|
-
validationFailed: (data) => process.env.NODE_ENV !== "production" ? data.exception : "Algo correu mal ao validar este campo. Por favor volte a tentar mais tarde."
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
confirmUnloadMessage: "Tem a certeza que pretende sair da página? Alterações que fez ao formulário podem não ter sido guardadas."
|
|
87
|
-
},
|
|
88
|
-
FormPagesNavigation: {
|
|
89
|
-
"aria-label": "Páginas do formulário"
|
|
90
|
-
},
|
|
91
|
-
FormPage: {
|
|
92
|
-
helperButtonLabel: "Mostrar ajuda"
|
|
93
|
-
},
|
|
94
|
-
IssueMessages: {
|
|
95
|
-
unknownErrorMessage: "Campo com erro desconhecido.",
|
|
96
|
-
unknownWarningMessage: "Campo com alerta desconhecido."
|
|
97
|
-
},
|
|
98
|
-
IssuesPanel: {
|
|
99
|
-
errorsLabel: (errors) => errors === void 0 ? "Erros" : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
100
|
-
errors,
|
|
101
|
-
" ",
|
|
102
|
-
errors === 1 ? "Erro" : "Erros"
|
|
103
|
-
] }),
|
|
104
|
-
warningsLabel: (warnings) => warnings === void 0 ? "Alertas" : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
105
|
-
warnings,
|
|
106
|
-
" ",
|
|
107
|
-
warnings === 1 ? "Alerta" : "Alertas"
|
|
108
|
-
] }),
|
|
109
|
-
focusButtonLabel: "Focar campo",
|
|
110
|
-
previousIssueButtonLabel: "Campo com problemas anterior",
|
|
111
|
-
nextIssueButtonLabel: "Próximo campo com problemas",
|
|
112
|
-
firstIssueButtonLabel: "Primeiro campo com problemas",
|
|
113
|
-
lastIssueButtonLabel: "Último campo com problemas",
|
|
114
|
-
paginationLabel: (currentPage, totalPages) => `Campo com problemas ${currentPage} de ${totalPages}.`,
|
|
115
|
-
noIssuesMessage: "Nenhum problema a reportar.",
|
|
116
|
-
resolvedTitle: "Resolvido",
|
|
117
|
-
resolvedMessage: "Problemas foram resolvidos. Por favor avance para o próximo campo com problemas."
|
|
118
|
-
},
|
|
119
|
-
IssuesPopover: {
|
|
120
|
-
label: "Mostrar problemas"
|
|
121
|
-
},
|
|
122
|
-
LoadAction: {
|
|
123
|
-
label: "Abrir",
|
|
124
|
-
keybinds: "$mod+O",
|
|
125
|
-
successMessage: (file) => `Ficheiro “${file.name}” carregado com sucesso.`,
|
|
126
|
-
errorMessage: (file) => file ? `Não foi possível carregar o ficheiro “${file.name}”. Por favor confirme que o ficheiro indicado é um ficheiro válido do formulário.` : "Não foi possível abrir o ficheiro indicado. Por favor confirme que tem as permissões devidas para efetuar a operação."
|
|
127
|
-
},
|
|
128
|
-
SaveAction: {
|
|
129
|
-
label: "Gravar",
|
|
130
|
-
keybinds: "$mod+S",
|
|
131
|
-
saveOptionsLabel: "Opções de gravação",
|
|
132
|
-
saveAsLabel: "Gravar como…",
|
|
133
|
-
saveAsKeybinds: "$mod+Shift+S",
|
|
134
|
-
successMessage: (fileHandle) => `Ficheiro “${fileHandle.name}” gravado com sucesso.`,
|
|
135
|
-
errorMessage: (fileHandle) => fileHandle ? `Não foi possível gravar o ficheiro “${fileHandle.name}”. Por favor confirme que tem as permissões devidas para efetuar a operação.` : "Não foi possível gravar o ficheiro indicado. Por favor confirme que tem as permissões devidas para efetuar a operação."
|
|
136
|
-
},
|
|
137
|
-
SubmitAction: {
|
|
138
|
-
label: "Entregar",
|
|
139
|
-
keybinds: "$mod+Enter",
|
|
140
|
-
dialogTitle: "Entregar declaração",
|
|
141
|
-
dialogDescription: "Por favor confirme que pretende continuar com a entrega da declaração.",
|
|
142
|
-
dialogCancelText: "Cancelar",
|
|
143
|
-
confirmWarningsCheckboxLabel: "Declaro que tomei conhecimento dos alertas gerados pelos dados desta declaração e que desejo continuar sem alterar os respetivos dados.",
|
|
144
|
-
successMessage: () => "Declaração entregue com sucesso.",
|
|
145
|
-
errorMessage: () => "Algo correu mal ao entregar a declaração. Por favor volte a tentar mais tarde."
|
|
146
|
-
},
|
|
147
|
-
TableControlAddRowTrigger: {
|
|
148
|
-
defaultButtonText: "Adicionar linha"
|
|
149
|
-
},
|
|
150
|
-
TableControlRemoveRowTrigger: {
|
|
151
|
-
defaultButtonLabel: "Remover linha",
|
|
152
|
-
confirmDialogTitle: "Remover linha",
|
|
153
|
-
confirmDialogMessage: (index) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
154
|
-
"Tem a certeza que pretende remover a linha #",
|
|
155
|
-
index + 1,
|
|
156
|
-
"?"
|
|
157
|
-
] }),
|
|
158
|
-
confirmDialogOkText: "Remover"
|
|
159
|
-
},
|
|
160
|
-
ValidateAction: {
|
|
161
|
-
label: "Validar",
|
|
162
|
-
keybinds: "F7"
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
|
-
const defaultLocale = ptPT;
|
|
166
|
-
const LocalizationContext = React.createContext(defaultLocale);
|
|
167
|
-
function LocalizationProvider({
|
|
168
|
-
locale,
|
|
169
|
-
children
|
|
170
|
-
}) {
|
|
171
|
-
return locale === void 0 ? children : /* @__PURE__ */ jsx(LocalizationContext.Provider, { value: locale, children });
|
|
172
|
-
}
|
|
173
|
-
function useLocale() {
|
|
174
|
-
return React.useContext(LocalizationContext);
|
|
175
|
-
}
|
|
176
|
-
function comparePathsBySpecificity(path1, path2) {
|
|
177
|
-
const [ids1, wildcards1, recursiveWildcards1] = pathSpecificity(path1);
|
|
178
|
-
const [ids2, wildcards2, recursiveWildcards2] = pathSpecificity(path2);
|
|
179
|
-
if (recursiveWildcards1 === 0 && recursiveWildcards2 === 0) {
|
|
180
|
-
return wildcards2 - wildcards1;
|
|
181
|
-
}
|
|
182
|
-
if (recursiveWildcards1 === 0 || recursiveWildcards2 === 0) {
|
|
183
|
-
return recursiveWildcards2 - recursiveWildcards1;
|
|
184
|
-
}
|
|
185
|
-
return ids1 - ids2 || wildcards1 - wildcards2;
|
|
186
|
-
}
|
|
187
|
-
function pathSpecificity(path) {
|
|
188
|
-
const specificity = [0, 0, 0];
|
|
189
|
-
for (const fragment of path.fragments) {
|
|
190
|
-
if (fragment instanceof AbsolutePathFragment.Id) {
|
|
191
|
-
++specificity[0];
|
|
192
|
-
} else if (fragment === AbsolutePathFragment.Wildcard) {
|
|
193
|
-
++specificity[1];
|
|
194
|
-
} else if (fragment === AbsolutePathFragment.RecursiveWildcard) {
|
|
195
|
-
++specificity[2];
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
return specificity;
|
|
199
|
-
}
|
|
200
|
-
const INITIAL = Symbol();
|
|
201
|
-
function useEqualityFn(selector, equalityFn = Object.is) {
|
|
202
|
-
const latest = React.useRef(INITIAL);
|
|
203
|
-
return (state) => {
|
|
204
|
-
const next = selector(state);
|
|
205
|
-
return latest.current !== INITIAL && equalityFn(latest.current, next) ? latest.current : latest.current = next;
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
44
|
class ValidationFailureError extends AtPathError {
|
|
209
45
|
constructor(path, issue) {
|
|
210
46
|
super(path, `Failed to run validation '${issue.validation}'`);
|
|
@@ -215,7 +51,7 @@ Caused by: ${issue.stackTrace}`;
|
|
|
215
51
|
}
|
|
216
52
|
function useReportValidationFailures(info) {
|
|
217
53
|
const reportError = useErrorReporter();
|
|
218
|
-
|
|
54
|
+
useEffect(() => {
|
|
219
55
|
if (info) {
|
|
220
56
|
for (const { path, issues } of info) {
|
|
221
57
|
for (const issue of issues) {
|
|
@@ -227,7 +63,7 @@ function useReportValidationFailures(info) {
|
|
|
227
63
|
}
|
|
228
64
|
}, [info, reportError]);
|
|
229
65
|
}
|
|
230
|
-
const ControlFieldContext =
|
|
66
|
+
const ControlFieldContext = createContext(null);
|
|
231
67
|
function useCreateControlFieldContext() {
|
|
232
68
|
return useConstant(
|
|
233
69
|
() => createStore(() => ({
|
|
@@ -236,7 +72,7 @@ function useCreateControlFieldContext() {
|
|
|
236
72
|
);
|
|
237
73
|
}
|
|
238
74
|
function useControlFieldContext() {
|
|
239
|
-
return
|
|
75
|
+
return useContext(ControlFieldContext);
|
|
240
76
|
}
|
|
241
77
|
function useControlFieldStore(selector) {
|
|
242
78
|
return useStore(useControlFieldContext() ?? EMPTY_STORE, selector);
|
|
@@ -252,7 +88,7 @@ function useRegisterControllerWithinControlField(controller, deferredIssuesToDis
|
|
|
252
88
|
const exists = controller.useState(
|
|
253
89
|
(state) => state.initialized && state.exists
|
|
254
90
|
);
|
|
255
|
-
|
|
91
|
+
useEffect(() => {
|
|
256
92
|
if (store) {
|
|
257
93
|
const pathStr = path.toString();
|
|
258
94
|
store.setState((state) => ({
|
|
@@ -277,7 +113,7 @@ function useRegisterControllerWithinControlField(controller, deferredIssuesToDis
|
|
|
277
113
|
}
|
|
278
114
|
}, [deferredIssuesToDisplay, exists, formManager, path, schema, store]);
|
|
279
115
|
}
|
|
280
|
-
const ControlField =
|
|
116
|
+
const ControlField = forwardRef(function ControlField2({
|
|
281
117
|
path = Path.CURRENT,
|
|
282
118
|
shown = true,
|
|
283
119
|
resetOnHide = true,
|
|
@@ -288,7 +124,7 @@ const ControlField = React.forwardRef(function ControlField2({
|
|
|
288
124
|
const formManager = useFormManager();
|
|
289
125
|
const store = useCreateControlFieldContext();
|
|
290
126
|
const controlStates = useStore(store, (state) => state.controlStates);
|
|
291
|
-
|
|
127
|
+
useEffect(() => {
|
|
292
128
|
if (!shown) {
|
|
293
129
|
for (const controlState of Object.values(controlStates)) {
|
|
294
130
|
const { formManager: formManager2, path: path2, exists } = controlState;
|
|
@@ -325,7 +161,7 @@ function IssueMessage({
|
|
|
325
161
|
unknownWarningMessage,
|
|
326
162
|
issueCodeProps
|
|
327
163
|
}) {
|
|
328
|
-
const locale = useLocale();
|
|
164
|
+
const [locale] = useLocale();
|
|
329
165
|
unknownErrorMessage ??= locale.IssueMessages.unknownErrorMessage;
|
|
330
166
|
unknownWarningMessage ??= locale.IssueMessages.unknownWarningMessage;
|
|
331
167
|
let message = useRegisteredIssueMessage(path, issue.code);
|
|
@@ -344,7 +180,7 @@ function IssueMessage({
|
|
|
344
180
|
] })
|
|
345
181
|
] });
|
|
346
182
|
}
|
|
347
|
-
const IssueMessages =
|
|
183
|
+
const IssueMessages = forwardRef(function IssueMessages2({
|
|
348
184
|
path,
|
|
349
185
|
issues,
|
|
350
186
|
messages,
|
|
@@ -361,17 +197,17 @@ const IssueMessages = React.forwardRef(function IssueMessages2({
|
|
|
361
197
|
const { info } = useIssuesTracker(absolutePath, {
|
|
362
198
|
enabled: !issues && !isInControlField
|
|
363
199
|
});
|
|
364
|
-
const messagesToRegister =
|
|
200
|
+
const messagesToRegister = useMemo(
|
|
365
201
|
() => messages && { [absolutePath.toString()]: messages },
|
|
366
202
|
[absolutePath, messages]
|
|
367
203
|
);
|
|
368
204
|
const relevantControlState = useControlFieldStore(
|
|
369
205
|
(state) => isInControlField ? state.controlStates?.[absolutePath.toString()] : null
|
|
370
206
|
);
|
|
371
|
-
const deferredTrackedIssues =
|
|
372
|
-
|
|
207
|
+
const deferredTrackedIssues = useDeferredValue(
|
|
208
|
+
useMemo(() => info?.flatMap((info2) => info2.issues) ?? [], [info])
|
|
373
209
|
);
|
|
374
|
-
const deferredIssuesToDisplay =
|
|
210
|
+
const deferredIssuesToDisplay = useMemo(
|
|
375
211
|
() => issues ?? (isInControlField ? relevantControlState?.deferredIssuesToDisplay ?? [] : deferredTrackedIssues),
|
|
376
212
|
[
|
|
377
213
|
deferredTrackedIssues,
|
|
@@ -381,16 +217,16 @@ const IssueMessages = React.forwardRef(function IssueMessages2({
|
|
|
381
217
|
]
|
|
382
218
|
);
|
|
383
219
|
useReportValidationFailures(
|
|
384
|
-
|
|
220
|
+
useMemo(
|
|
385
221
|
() => [{ path: absolutePath, issues: deferredIssuesToDisplay }],
|
|
386
222
|
[absolutePath, deferredIssuesToDisplay]
|
|
387
223
|
)
|
|
388
224
|
);
|
|
389
|
-
const schema =
|
|
225
|
+
const schema = useMemo(
|
|
390
226
|
() => relevantControlState?.schema ?? formManager.schema(absolutePath),
|
|
391
227
|
[absolutePath, formManager, relevantControlState?.schema]
|
|
392
228
|
);
|
|
393
|
-
const feedbackNodes =
|
|
229
|
+
const feedbackNodes = useMemo(
|
|
394
230
|
() => deferredIssuesToDisplay.map((issue, i) => /* @__PURE__ */ jsx(Feedback, { type: issue.severity, children: /* @__PURE__ */ jsx(
|
|
395
231
|
IssueMessage,
|
|
396
232
|
{
|
|
@@ -415,9 +251,39 @@ const IssueMessages = React.forwardRef(function IssueMessages2({
|
|
|
415
251
|
);
|
|
416
252
|
return /* @__PURE__ */ jsx(FormAppIssueMessages, { issueMessages: messagesToRegister, children: unwrapped ? feedbackNodes : /* @__PURE__ */ jsx(FeedbackList, { ...otherProps, ref: forwardedRef, children: feedbackNodes }) });
|
|
417
253
|
});
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
);
|
|
254
|
+
function comparePathsBySpecificity(path1, path2) {
|
|
255
|
+
const [ids1, wildcards1, recursiveWildcards1] = pathSpecificity(path1);
|
|
256
|
+
const [ids2, wildcards2, recursiveWildcards2] = pathSpecificity(path2);
|
|
257
|
+
if (recursiveWildcards1 === 0 && recursiveWildcards2 === 0) {
|
|
258
|
+
return wildcards2 - wildcards1;
|
|
259
|
+
}
|
|
260
|
+
if (recursiveWildcards1 === 0 || recursiveWildcards2 === 0) {
|
|
261
|
+
return recursiveWildcards2 - recursiveWildcards1;
|
|
262
|
+
}
|
|
263
|
+
return ids1 - ids2 || wildcards1 - wildcards2;
|
|
264
|
+
}
|
|
265
|
+
function pathSpecificity(path) {
|
|
266
|
+
const specificity = [0, 0, 0];
|
|
267
|
+
for (const fragment of path.fragments) {
|
|
268
|
+
if (fragment instanceof AbsolutePathFragment.Id) {
|
|
269
|
+
++specificity[0];
|
|
270
|
+
} else if (fragment === AbsolutePathFragment.Wildcard) {
|
|
271
|
+
++specificity[1];
|
|
272
|
+
} else if (fragment === AbsolutePathFragment.RecursiveWildcard) {
|
|
273
|
+
++specificity[2];
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
return specificity;
|
|
277
|
+
}
|
|
278
|
+
const INITIAL = Symbol();
|
|
279
|
+
function useEqualityFn(selector, equalityFn = Object.is) {
|
|
280
|
+
const latest = useRef(INITIAL);
|
|
281
|
+
return (state) => {
|
|
282
|
+
const next = selector(state);
|
|
283
|
+
return latest.current !== INITIAL && equalityFn(latest.current, next) ? latest.current : latest.current = next;
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
const FormAppContext = createContext(null);
|
|
421
287
|
function useCreateFormAppContext({
|
|
422
288
|
controller,
|
|
423
289
|
disabled,
|
|
@@ -620,10 +486,10 @@ function useCreateFormAppContext({
|
|
|
620
486
|
}))
|
|
621
487
|
)
|
|
622
488
|
);
|
|
623
|
-
|
|
489
|
+
useEffect(() => {
|
|
624
490
|
store.setState({ controller });
|
|
625
491
|
}, [controller, store]);
|
|
626
|
-
return
|
|
492
|
+
return useMemo(
|
|
627
493
|
() => ({
|
|
628
494
|
disabled,
|
|
629
495
|
readOnly,
|
|
@@ -643,7 +509,7 @@ function useCreateFormAppContext({
|
|
|
643
509
|
);
|
|
644
510
|
}
|
|
645
511
|
function useFormAppContext() {
|
|
646
|
-
const formAppContext =
|
|
512
|
+
const formAppContext = useContext(FormAppContext);
|
|
647
513
|
if (!formAppContext) {
|
|
648
514
|
throw new Error("Form app context not in scope.");
|
|
649
515
|
}
|
|
@@ -666,21 +532,21 @@ function useFormAppElement() {
|
|
|
666
532
|
}
|
|
667
533
|
function useSetTopBarHeight() {
|
|
668
534
|
const { store } = useFormAppContext();
|
|
669
|
-
return
|
|
535
|
+
return useCallback(
|
|
670
536
|
(height) => store.setState({ topBarHeight: height ?? 0 }),
|
|
671
537
|
[store]
|
|
672
538
|
);
|
|
673
539
|
}
|
|
674
540
|
function useSetLeftSidebarWidth() {
|
|
675
541
|
const { store } = useFormAppContext();
|
|
676
|
-
return
|
|
542
|
+
return useCallback(
|
|
677
543
|
(width) => store.setState({ leftSidebarWidth: width ?? 0 }),
|
|
678
544
|
[store]
|
|
679
545
|
);
|
|
680
546
|
}
|
|
681
547
|
function useSetBottomPanelHeight() {
|
|
682
548
|
const { store } = useFormAppContext();
|
|
683
|
-
return
|
|
549
|
+
return useCallback(
|
|
684
550
|
(height) => store.setState({ bottomPanelHeight: height ?? 0 }),
|
|
685
551
|
[store]
|
|
686
552
|
);
|
|
@@ -706,7 +572,7 @@ function useResetFocus() {
|
|
|
706
572
|
function useRegisterController(controller) {
|
|
707
573
|
const store = useFormAppContext().store;
|
|
708
574
|
const path = controller.usePath();
|
|
709
|
-
|
|
575
|
+
useEffect(
|
|
710
576
|
() => store.getState().actions.registerController(path, controller),
|
|
711
577
|
[store, controller, path]
|
|
712
578
|
);
|
|
@@ -728,7 +594,7 @@ function useSetActivePath() {
|
|
|
728
594
|
}
|
|
729
595
|
function useRegisterIssueMessages(path, issueMessages, priority) {
|
|
730
596
|
const store = useFormAppContext().store;
|
|
731
|
-
|
|
597
|
+
useEffect(() => {
|
|
732
598
|
if (path != null) {
|
|
733
599
|
return store.getState().actions.registerIssueMessages(path, issueMessages, priority);
|
|
734
600
|
}
|
|
@@ -742,7 +608,7 @@ function useRegisteredIssueMessage(path, code) {
|
|
|
742
608
|
}
|
|
743
609
|
function useRegisterLabel(path, label, priority = 0) {
|
|
744
610
|
const store = useFormAppContext().store;
|
|
745
|
-
|
|
611
|
+
useEffect(() => {
|
|
746
612
|
if (path != null) {
|
|
747
613
|
return store.getState().actions.registerLabel(path, label, priority);
|
|
748
614
|
}
|
|
@@ -774,7 +640,7 @@ function useStartIssuesNavigation() {
|
|
|
774
640
|
}
|
|
775
641
|
function useOnPathFocus(cb, { fireImmediately = true } = {}) {
|
|
776
642
|
const { store } = useFormAppContext();
|
|
777
|
-
|
|
643
|
+
useEffect(
|
|
778
644
|
() => store.subscribe(
|
|
779
645
|
({ focusedPath, focusCounter }) => ({ focusedPath, focusCounter }),
|
|
780
646
|
({ focusedPath }) => focusedPath && cb(focusedPath),
|
|
@@ -785,21 +651,21 @@ function useOnPathFocus(cb, { fireImmediately = true } = {}) {
|
|
|
785
651
|
}
|
|
786
652
|
function useSetStartIssuesNavigation(fn) {
|
|
787
653
|
const { store } = useFormAppContext();
|
|
788
|
-
|
|
654
|
+
useEffect(() => {
|
|
789
655
|
store.setState({ startIssuesNavigation: fn });
|
|
790
656
|
return () => store.setState({ startIssuesNavigation: void 0 });
|
|
791
657
|
}, [fn, store]);
|
|
792
658
|
}
|
|
793
659
|
const FOCUSABLE_ELEMENTS = ["INPUT", "SELECT", "TEXTAREA"];
|
|
794
660
|
function useControlAutofocus({ usePath, useExists }, enabled = true) {
|
|
795
|
-
const controlRef =
|
|
661
|
+
const controlRef = useRef(null);
|
|
796
662
|
const path = usePath();
|
|
797
663
|
const exists = useExists();
|
|
798
664
|
const resetFocus = useResetFocus();
|
|
799
665
|
const scrollIntoView = useScrollIntoView();
|
|
800
|
-
const timeoutId =
|
|
666
|
+
const timeoutId = useRef(void 0);
|
|
801
667
|
useOnPathFocus(
|
|
802
|
-
|
|
668
|
+
useCallback(
|
|
803
669
|
(focusedPath) => {
|
|
804
670
|
const control = controlRef.current;
|
|
805
671
|
if (enabled && control && exists && path.equals(focusedPath)) {
|
|
@@ -837,7 +703,7 @@ function useScrollIntoView() {
|
|
|
837
703
|
const prefix = usePrefix();
|
|
838
704
|
const spacing = useSpacing();
|
|
839
705
|
const { cssVar } = useCssVars({ prefix });
|
|
840
|
-
return
|
|
706
|
+
return useCallback(
|
|
841
707
|
(el, options) => {
|
|
842
708
|
const scrollableParent = getScrollableParent(el);
|
|
843
709
|
const scrollMarginBlockStart = el.style.scrollMarginBlockStart;
|
|
@@ -872,6 +738,96 @@ function getScrollableParent(el) {
|
|
|
872
738
|
}
|
|
873
739
|
return document.scrollingElement ?? document.documentElement;
|
|
874
740
|
}
|
|
741
|
+
function FormAppAutoFocus() {
|
|
742
|
+
const initialized = useFormController().useInitialized();
|
|
743
|
+
const formAppEl = useFormAppElement();
|
|
744
|
+
const scrollIntoView = useScrollIntoView();
|
|
745
|
+
const issuesDisplayMode = useIssuesDisplayMode();
|
|
746
|
+
const resetFocus = useResetFocus();
|
|
747
|
+
useOnPathFocus(
|
|
748
|
+
useCallback(
|
|
749
|
+
(focusedPath) => {
|
|
750
|
+
if (initialized && focusedPath.isRoot) {
|
|
751
|
+
if (issuesDisplayMode === "panel") {
|
|
752
|
+
scrollIntoView(formAppEl);
|
|
753
|
+
visiblyFocus(formAppEl);
|
|
754
|
+
}
|
|
755
|
+
resetFocus();
|
|
756
|
+
}
|
|
757
|
+
},
|
|
758
|
+
[initialized, issuesDisplayMode, resetFocus, scrollIntoView, formAppEl]
|
|
759
|
+
)
|
|
760
|
+
);
|
|
761
|
+
return null;
|
|
762
|
+
}
|
|
763
|
+
const FormAppElement = forwardRef(function FormAppElement2({
|
|
764
|
+
formAppElement,
|
|
765
|
+
setFormAppElement,
|
|
766
|
+
minHeight,
|
|
767
|
+
className,
|
|
768
|
+
style,
|
|
769
|
+
children,
|
|
770
|
+
...otherProps
|
|
771
|
+
}, forwardedRef) {
|
|
772
|
+
const prefix = usePrefix();
|
|
773
|
+
const { cssVarName } = useCssVars({ prefix });
|
|
774
|
+
const { responsiveValueToCssVarsAndDataAttrs } = useResponsiveValues({
|
|
775
|
+
prefix
|
|
776
|
+
});
|
|
777
|
+
const { store } = useFormAppContext();
|
|
778
|
+
useEffect(
|
|
779
|
+
() => store.subscribe(
|
|
780
|
+
(state) => state.topBarHeight,
|
|
781
|
+
(height) => formAppElement?.style.setProperty(
|
|
782
|
+
cssVarName("top-bar-height"),
|
|
783
|
+
`${height}px`
|
|
784
|
+
),
|
|
785
|
+
{ fireImmediately: true }
|
|
786
|
+
),
|
|
787
|
+
[cssVarName, formAppElement, store]
|
|
788
|
+
);
|
|
789
|
+
useEffect(
|
|
790
|
+
() => store.subscribe(
|
|
791
|
+
(state) => state.leftSidebarWidth,
|
|
792
|
+
(width) => formAppElement?.style.setProperty(
|
|
793
|
+
cssVarName("left-sidebar-width"),
|
|
794
|
+
`${width}px`
|
|
795
|
+
),
|
|
796
|
+
{ fireImmediately: true }
|
|
797
|
+
),
|
|
798
|
+
[cssVarName, formAppElement, store]
|
|
799
|
+
);
|
|
800
|
+
useEffect(
|
|
801
|
+
() => store.subscribe(
|
|
802
|
+
(state) => state.bottomPanelHeight,
|
|
803
|
+
(height) => formAppElement?.style.setProperty(
|
|
804
|
+
cssVarName("bottom-panel-height"),
|
|
805
|
+
`${height}px`
|
|
806
|
+
),
|
|
807
|
+
{ fireImmediately: true }
|
|
808
|
+
),
|
|
809
|
+
[cssVarName, formAppElement, store]
|
|
810
|
+
);
|
|
811
|
+
const { cssVars, dataAttrs } = responsiveValueToCssVarsAndDataAttrs(
|
|
812
|
+
"form-app",
|
|
813
|
+
"min-height",
|
|
814
|
+
minHeight,
|
|
815
|
+
(v) => typeof v === "number" ? `${v}px` : v
|
|
816
|
+
);
|
|
817
|
+
const combinedFormAppRef = useCombinedRef(setFormAppElement, forwardedRef);
|
|
818
|
+
return /* @__PURE__ */ jsx(
|
|
819
|
+
"form",
|
|
820
|
+
{
|
|
821
|
+
className: cx(prefix("form-app"), className),
|
|
822
|
+
style: { ...cssVars, ...style },
|
|
823
|
+
tabIndex: 0,
|
|
824
|
+
...dataAttrs,
|
|
825
|
+
...otherProps,
|
|
826
|
+
ref: combinedFormAppRef,
|
|
827
|
+
children
|
|
828
|
+
}
|
|
829
|
+
);
|
|
830
|
+
});
|
|
875
831
|
function FormAppIssueMessages({
|
|
876
832
|
path,
|
|
877
833
|
issueMessages,
|
|
@@ -882,7 +838,7 @@ function FormAppIssueMessages({
|
|
|
882
838
|
useRegisterIssueMessages(absolutePath, issueMessages, priority);
|
|
883
839
|
return children;
|
|
884
840
|
}
|
|
885
|
-
const FormApp =
|
|
841
|
+
const FormApp = forwardRef(function FormApp2({
|
|
886
842
|
enableErrorReporting,
|
|
887
843
|
reportError,
|
|
888
844
|
errorReportingUrl,
|
|
@@ -912,7 +868,9 @@ const FormApp = React.forwardRef(function FormApp2({
|
|
|
912
868
|
readOnly = false,
|
|
913
869
|
prefix: newPrefix,
|
|
914
870
|
prefixSuffix,
|
|
915
|
-
|
|
871
|
+
defaultLocale,
|
|
872
|
+
locale: controlledLocale,
|
|
873
|
+
onLocaleChange,
|
|
916
874
|
issueMessages,
|
|
917
875
|
issuesDisplayMode = "inline",
|
|
918
876
|
displayIssueCodes = false,
|
|
@@ -940,9 +898,6 @@ const FormApp = React.forwardRef(function FormApp2({
|
|
|
940
898
|
onDisplayStatusChange,
|
|
941
899
|
onDirtyStatusChange,
|
|
942
900
|
onTouchedStatusChange,
|
|
943
|
-
className,
|
|
944
|
-
style,
|
|
945
|
-
children,
|
|
946
901
|
...otherProps
|
|
947
902
|
}, forwardedRef) {
|
|
948
903
|
const isInRoot = useIsInRoot();
|
|
@@ -975,20 +930,13 @@ const FormApp = React.forwardRef(function FormApp2({
|
|
|
975
930
|
`FormApp: Properties ${Object.keys(rootProps).map((prop) => `\`${prop}\``).join(", ")} have no effect when the \`FormApp\` is already inside an ostack/UI's \`Root\` component. Please set any of these properties on the \`Root\` component directly instead.`
|
|
976
931
|
);
|
|
977
932
|
}
|
|
978
|
-
const
|
|
979
|
-
const
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
);
|
|
986
|
-
const { cssVarName } = useCssVars({ prefix });
|
|
987
|
-
const { responsiveValueToCssVarsAndDataAttrs } = useResponsiveValues({
|
|
988
|
-
prefix
|
|
989
|
-
});
|
|
990
|
-
const contextLocale = useLocale();
|
|
991
|
-
const locale = newLocale ?? contextLocale;
|
|
933
|
+
const contextLocale = useContext(LocalizationContext)?.locale;
|
|
934
|
+
const locale = controlledLocale ?? defaultLocale ?? contextLocale;
|
|
935
|
+
if (locale == null) {
|
|
936
|
+
throw new Error(
|
|
937
|
+
"FormApp: No locale has been provided. Either provide a `defaultLocale`/`locale` property or wrap the component in a `LocalizationProvider`."
|
|
938
|
+
);
|
|
939
|
+
}
|
|
992
940
|
issuesPanelLabel ??= locale.FormApp.issuesPanelLabel;
|
|
993
941
|
confirmUnloadMessage ??= locale.FormApp.confirmUnloadMessage;
|
|
994
942
|
const controller = useForm(schema, {
|
|
@@ -1016,11 +964,11 @@ const FormApp = React.forwardRef(function FormApp2({
|
|
|
1016
964
|
onTouchedStatusChange
|
|
1017
965
|
});
|
|
1018
966
|
const { formProps } = controller;
|
|
1019
|
-
const [
|
|
967
|
+
const [formAppElement, setFormAppElement] = useState(
|
|
1020
968
|
null
|
|
1021
969
|
);
|
|
1022
970
|
const formManager = controller.useFormManager();
|
|
1023
|
-
const formContext =
|
|
971
|
+
const formContext = useMemo(
|
|
1024
972
|
() => ({
|
|
1025
973
|
formManager,
|
|
1026
974
|
currentPath: AbsolutePath.ROOT,
|
|
@@ -1036,15 +984,15 @@ const FormApp = React.forwardRef(function FormApp2({
|
|
|
1036
984
|
displayIssueCodes,
|
|
1037
985
|
controller,
|
|
1038
986
|
onPathFocus,
|
|
1039
|
-
formAppElement
|
|
987
|
+
formAppElement
|
|
1040
988
|
});
|
|
1041
989
|
const { store } = formAppContextValue;
|
|
1042
|
-
|
|
990
|
+
useEffect(
|
|
1043
991
|
() => store.getState().actions.registerController(AbsolutePath.ROOT, controller),
|
|
1044
992
|
[controller, store]
|
|
1045
993
|
);
|
|
1046
994
|
const absolutePath = controller.usePath();
|
|
1047
|
-
|
|
995
|
+
useEffect(
|
|
1048
996
|
() => store.getState().actions.registerLabel(absolutePath, issuesPanelLabel),
|
|
1049
997
|
[absolutePath, issuesPanelLabel, store]
|
|
1050
998
|
);
|
|
@@ -1052,7 +1000,7 @@ const FormApp = React.forwardRef(function FormApp2({
|
|
|
1052
1000
|
store,
|
|
1053
1001
|
(state) => state.actions
|
|
1054
1002
|
);
|
|
1055
|
-
|
|
1003
|
+
useImperativeHandle(
|
|
1056
1004
|
apiRef,
|
|
1057
1005
|
() => ({
|
|
1058
1006
|
...controller,
|
|
@@ -1061,93 +1009,37 @@ const FormApp = React.forwardRef(function FormApp2({
|
|
|
1061
1009
|
}),
|
|
1062
1010
|
[focus, controller, startIssuesNavigation]
|
|
1063
1011
|
);
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
(state) => state.topBarHeight,
|
|
1067
|
-
(height) => formAppEl?.style.setProperty(
|
|
1068
|
-
cssVarName("top-bar-height"),
|
|
1069
|
-
`${height}px`
|
|
1070
|
-
),
|
|
1071
|
-
{ fireImmediately: true }
|
|
1072
|
-
),
|
|
1073
|
-
[cssVarName, formAppEl, store]
|
|
1074
|
-
);
|
|
1075
|
-
React.useEffect(
|
|
1076
|
-
() => store.subscribe(
|
|
1077
|
-
(state) => state.leftSidebarWidth,
|
|
1078
|
-
(width) => formAppEl?.style.setProperty(
|
|
1079
|
-
cssVarName("left-sidebar-width"),
|
|
1080
|
-
`${width}px`
|
|
1081
|
-
),
|
|
1082
|
-
{ fireImmediately: true }
|
|
1083
|
-
),
|
|
1084
|
-
[cssVarName, formAppEl, store]
|
|
1085
|
-
);
|
|
1086
|
-
React.useEffect(
|
|
1087
|
-
() => store.subscribe(
|
|
1088
|
-
(state) => state.bottomPanelHeight,
|
|
1089
|
-
(height) => formAppEl?.style.setProperty(
|
|
1090
|
-
cssVarName("bottom-panel-height"),
|
|
1091
|
-
`${height}px`
|
|
1092
|
-
),
|
|
1093
|
-
{ fireImmediately: true }
|
|
1094
|
-
),
|
|
1095
|
-
[cssVarName, formAppEl, store]
|
|
1096
|
-
);
|
|
1097
|
-
const { cssVars, dataAttrs } = responsiveValueToCssVarsAndDataAttrs(
|
|
1098
|
-
"form-app",
|
|
1099
|
-
"min-height",
|
|
1100
|
-
minHeight,
|
|
1101
|
-
(v) => typeof v === "number" ? `${v}px` : v
|
|
1102
|
-
);
|
|
1103
|
-
const combinedFormAppRef = useCombinedRef(setFormAppEl, forwardedRef);
|
|
1104
|
-
const formApp = /* @__PURE__ */ jsx(
|
|
1105
|
-
"form",
|
|
1012
|
+
const formAppEl = /* @__PURE__ */ jsx(
|
|
1013
|
+
FormAppElement,
|
|
1106
1014
|
{
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
...dataAttrs,
|
|
1015
|
+
minHeight,
|
|
1016
|
+
formAppElement,
|
|
1017
|
+
setFormAppElement,
|
|
1111
1018
|
...formProps,
|
|
1112
1019
|
...otherProps,
|
|
1113
|
-
ref:
|
|
1114
|
-
|
|
1020
|
+
ref: forwardedRef
|
|
1021
|
+
}
|
|
1022
|
+
);
|
|
1023
|
+
return /* @__PURE__ */ jsx(PrefixProvider, { prefix: newPrefix, children: /* @__PURE__ */ jsx(PrefixSuffixProvider, { prefixSuffix, children: /* @__PURE__ */ jsx(
|
|
1024
|
+
LocalizationProvider,
|
|
1025
|
+
{
|
|
1026
|
+
defaultLocale,
|
|
1027
|
+
locale: controlledLocale,
|
|
1028
|
+
onLocaleChange,
|
|
1029
|
+
children: /* @__PURE__ */ jsx(FormContext.Provider, { value: formContext, children: /* @__PURE__ */ jsx(FormAppContext.Provider, { value: formAppContextValue, children: /* @__PURE__ */ jsx(
|
|
1115
1030
|
FormAppIssueMessages,
|
|
1116
1031
|
{
|
|
1117
1032
|
issueMessages: locale.FormApp.issueMessages,
|
|
1118
1033
|
priority: -1,
|
|
1119
1034
|
children: /* @__PURE__ */ jsxs(FormAppIssueMessages, { issueMessages, children: [
|
|
1120
1035
|
/* @__PURE__ */ jsx(FormAppAutoFocus, {}),
|
|
1121
|
-
children
|
|
1036
|
+
isInRoot ? formAppEl : /* @__PURE__ */ jsx(Root, { asChild: true, ...rootProps, children: formAppEl })
|
|
1122
1037
|
] })
|
|
1123
1038
|
}
|
|
1124
|
-
) }) })
|
|
1039
|
+
) }) })
|
|
1125
1040
|
}
|
|
1126
|
-
);
|
|
1127
|
-
return isInRoot ? formApp : /* @__PURE__ */ jsx(Root, { asChild: true, ...rootProps, prefix: newPrefix, locale: locale.uiLocale, children: formApp });
|
|
1041
|
+
) }) });
|
|
1128
1042
|
});
|
|
1129
|
-
function FormAppAutoFocus() {
|
|
1130
|
-
const initialized = useFormController().useInitialized();
|
|
1131
|
-
const formAppEl = useFormAppElement();
|
|
1132
|
-
const scrollIntoView = useScrollIntoView();
|
|
1133
|
-
const issuesDisplayMode = useIssuesDisplayMode();
|
|
1134
|
-
const resetFocus = useResetFocus();
|
|
1135
|
-
useOnPathFocus(
|
|
1136
|
-
React.useCallback(
|
|
1137
|
-
(focusedPath) => {
|
|
1138
|
-
if (initialized && focusedPath.isRoot) {
|
|
1139
|
-
if (issuesDisplayMode === "panel") {
|
|
1140
|
-
scrollIntoView(formAppEl);
|
|
1141
|
-
visiblyFocus(formAppEl);
|
|
1142
|
-
}
|
|
1143
|
-
resetFocus();
|
|
1144
|
-
}
|
|
1145
|
-
},
|
|
1146
|
-
[initialized, issuesDisplayMode, resetFocus, scrollIntoView, formAppEl]
|
|
1147
|
-
)
|
|
1148
|
-
);
|
|
1149
|
-
return null;
|
|
1150
|
-
}
|
|
1151
1043
|
function FormAppStatus({
|
|
1152
1044
|
disabled = false,
|
|
1153
1045
|
readOnly = false,
|
|
@@ -1157,7 +1049,7 @@ function FormAppStatus({
|
|
|
1157
1049
|
return /* @__PURE__ */ jsx(
|
|
1158
1050
|
FormAppContext.Provider,
|
|
1159
1051
|
{
|
|
1160
|
-
value:
|
|
1052
|
+
value: useMemo(
|
|
1161
1053
|
() => ({
|
|
1162
1054
|
...formAppContext,
|
|
1163
1055
|
disabled: formAppContext.disabled || disabled,
|
|
@@ -1203,12 +1095,12 @@ function useFormLoader({
|
|
|
1203
1095
|
successMessage,
|
|
1204
1096
|
errorMessage
|
|
1205
1097
|
} = {}) {
|
|
1206
|
-
const locale = useLocale();
|
|
1098
|
+
const [locale] = useLocale();
|
|
1207
1099
|
const formManager = useFormManager();
|
|
1208
1100
|
const { _setState } = useFormController();
|
|
1209
1101
|
const { addToast } = useToastManager();
|
|
1210
1102
|
const startIssuesNavigation = useStartIssuesNavigation();
|
|
1211
|
-
return
|
|
1103
|
+
return useMemo(() => {
|
|
1212
1104
|
async function load({
|
|
1213
1105
|
decode: decode2,
|
|
1214
1106
|
path: path2 = AbsolutePath.ROOT,
|
|
@@ -1316,84 +1208,92 @@ function useFormLoader({
|
|
|
1316
1208
|
function useFormIsLoading() {
|
|
1317
1209
|
return useFormController().useState((state) => state.loading);
|
|
1318
1210
|
}
|
|
1319
|
-
const Annexes =
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
activeAnnex,
|
|
1324
|
-
onActiveAnnexChange,
|
|
1325
|
-
onAnnexAdd,
|
|
1326
|
-
onAnnexRemove,
|
|
1327
|
-
variant = "annexes",
|
|
1328
|
-
className,
|
|
1329
|
-
...otherProps
|
|
1330
|
-
}, forwardedRef) {
|
|
1331
|
-
const prefix = usePrefix();
|
|
1332
|
-
const formManager = useFormManager();
|
|
1333
|
-
const absolutePath = useResolvedPath(path);
|
|
1334
|
-
const resolvedAnnexes = React.useMemo(
|
|
1335
|
-
() => annexes.map((annex) => ({
|
|
1336
|
-
...annex,
|
|
1337
|
-
path: absolutePath.resolve(annex.path)
|
|
1338
|
-
})),
|
|
1339
|
-
[absolutePath, annexes]
|
|
1340
|
-
);
|
|
1341
|
-
if (!formManager.isValidPath(absolutePath)) {
|
|
1342
|
-
throw new Error(`Invalid path: '${absolutePath.toString()}'`);
|
|
1343
|
-
}
|
|
1344
|
-
if (absolutePath.fragments.some(
|
|
1345
|
-
(frag) => !(frag instanceof AbsolutePathFragment.Id)
|
|
1346
|
-
)) {
|
|
1347
|
-
throw new Error("Annexes base path must only contain ids.");
|
|
1348
|
-
}
|
|
1349
|
-
for (const annex of resolvedAnnexes) {
|
|
1350
|
-
if (!formManager.isValidPath(annex.path)) {
|
|
1351
|
-
throw new Error(`Invalid path: '${annex.path.toString()}'`);
|
|
1352
|
-
}
|
|
1353
|
-
if (annex.path.fragments.some(
|
|
1354
|
-
(frag, i, { length }) => !(frag instanceof AbsolutePathFragment.Id) && (frag !== AbsolutePathFragment.Wildcard || i !== length - 1)
|
|
1355
|
-
)) {
|
|
1356
|
-
throw new Error(
|
|
1357
|
-
"Annex path must either only contain ids, or ids followed by a single wildcard at the end."
|
|
1358
|
-
);
|
|
1359
|
-
}
|
|
1360
|
-
}
|
|
1361
|
-
const store = useCreateAnnexesContext({
|
|
1362
|
-
formManager,
|
|
1363
|
-
basePath: absolutePath,
|
|
1364
|
-
resolvedAnnexes,
|
|
1211
|
+
const Annexes = forwardRef(
|
|
1212
|
+
function Annexes2({
|
|
1213
|
+
path,
|
|
1214
|
+
annexes,
|
|
1365
1215
|
defaultActiveAnnex,
|
|
1366
1216
|
activeAnnex,
|
|
1367
1217
|
onActiveAnnexChange,
|
|
1368
1218
|
onAnnexAdd,
|
|
1369
|
-
onAnnexRemove
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
{
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1219
|
+
onAnnexRemove,
|
|
1220
|
+
variant = "annexes",
|
|
1221
|
+
className,
|
|
1222
|
+
...otherProps
|
|
1223
|
+
}, forwardedRef) {
|
|
1224
|
+
const prefix = usePrefix();
|
|
1225
|
+
const formManager = useFormManager();
|
|
1226
|
+
const absolutePath = useResolvedPath(path);
|
|
1227
|
+
const resolvedAnnexes = useMemo(
|
|
1228
|
+
() => annexes.map((annex) => ({
|
|
1229
|
+
...annex,
|
|
1230
|
+
path: absolutePath.resolve(annex.path)
|
|
1231
|
+
})),
|
|
1232
|
+
[absolutePath, annexes]
|
|
1233
|
+
);
|
|
1234
|
+
if (!formManager.isValidPath(absolutePath)) {
|
|
1235
|
+
throw new Error(`Invalid path: '${absolutePath.toString()}'`);
|
|
1236
|
+
}
|
|
1237
|
+
if (absolutePath.fragments.some(
|
|
1238
|
+
(frag) => !(frag instanceof AbsolutePathFragment.Id)
|
|
1239
|
+
)) {
|
|
1240
|
+
throw new Error("Annexes base path must only contain ids.");
|
|
1241
|
+
}
|
|
1242
|
+
for (const annex of resolvedAnnexes) {
|
|
1243
|
+
if (!formManager.isValidPath(annex.path)) {
|
|
1244
|
+
throw new Error(`Invalid path: '${annex.path.toString()}'`);
|
|
1393
1245
|
}
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1246
|
+
if (annex.path.fragments.some(
|
|
1247
|
+
(frag, i, { length }) => !(frag instanceof AbsolutePathFragment.Id) && (frag !== AbsolutePathFragment.Wildcard || i !== length - 1)
|
|
1248
|
+
)) {
|
|
1249
|
+
throw new Error(
|
|
1250
|
+
"Annex path must either only contain ids, or ids followed by a single wildcard at the end."
|
|
1251
|
+
);
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
const store = useCreateAnnexesContext({
|
|
1255
|
+
formManager,
|
|
1256
|
+
basePath: absolutePath,
|
|
1257
|
+
resolvedAnnexes,
|
|
1258
|
+
defaultActiveAnnex,
|
|
1259
|
+
activeAnnex,
|
|
1260
|
+
onActiveAnnexChange,
|
|
1261
|
+
onAnnexAdd,
|
|
1262
|
+
onAnnexRemove
|
|
1263
|
+
});
|
|
1264
|
+
const activeAnnexString = useStore(
|
|
1265
|
+
store,
|
|
1266
|
+
(state) => state.activeAnnex?.toString() ?? ""
|
|
1267
|
+
);
|
|
1268
|
+
const handleValueChange = useCallback(
|
|
1269
|
+
(value) => store.getState().actions.setActiveAnnex(value),
|
|
1270
|
+
[store]
|
|
1271
|
+
);
|
|
1272
|
+
return /* @__PURE__ */ jsx(CurrentPath, { path: absolutePath, children: /* @__PURE__ */ jsxs(AnnexesContext.Provider, { value: store, children: [
|
|
1273
|
+
resolvedAnnexes.map(
|
|
1274
|
+
(annex) => annex.path.lastFragment === AbsolutePathFragment.Wildcard ? /* @__PURE__ */ jsx(
|
|
1275
|
+
RepetitiveAnnexRegistrar,
|
|
1276
|
+
{
|
|
1277
|
+
...annex
|
|
1278
|
+
},
|
|
1279
|
+
annex.path.toString()
|
|
1280
|
+
) : /* @__PURE__ */ jsx(AnnexRegistrar, { ...annex }, annex.path.toString())
|
|
1281
|
+
),
|
|
1282
|
+
/* @__PURE__ */ jsx(
|
|
1283
|
+
Tabs,
|
|
1284
|
+
{
|
|
1285
|
+
className: cx(prefix("annexes"), className),
|
|
1286
|
+
variant,
|
|
1287
|
+
activationMode: "manual",
|
|
1288
|
+
value: activeAnnexString,
|
|
1289
|
+
onValueChange: handleValueChange,
|
|
1290
|
+
...otherProps,
|
|
1291
|
+
ref: forwardedRef
|
|
1292
|
+
}
|
|
1293
|
+
)
|
|
1294
|
+
] }) });
|
|
1295
|
+
}
|
|
1296
|
+
);
|
|
1397
1297
|
function AnnexRegistrar({
|
|
1398
1298
|
path,
|
|
1399
1299
|
title,
|
|
@@ -1410,7 +1310,7 @@ function AnnexRegistrar({
|
|
|
1410
1310
|
path.append(AbsolutePathFragment.RecursiveWildcard),
|
|
1411
1311
|
{
|
|
1412
1312
|
enabled: !useFormIsLoading(),
|
|
1413
|
-
format:
|
|
1313
|
+
format: useCallback((value) => value === null, [])
|
|
1414
1314
|
}
|
|
1415
1315
|
);
|
|
1416
1316
|
const isRepetitive = index != null;
|
|
@@ -1420,19 +1320,17 @@ function AnnexRegistrar({
|
|
|
1420
1320
|
(state) => state.initialized && state.exists
|
|
1421
1321
|
);
|
|
1422
1322
|
const dirty = controller.useDirty();
|
|
1423
|
-
const deferredValue =
|
|
1424
|
-
const deferredIssuesToDisplay =
|
|
1323
|
+
const deferredValue = useDeferredValue(controller.useValue());
|
|
1324
|
+
const deferredIssuesToDisplay = useDeferredValue(
|
|
1425
1325
|
controller.useState((state) => state.touched ? state.issues : [], {
|
|
1426
1326
|
equalityFn: shallow
|
|
1427
1327
|
})
|
|
1428
1328
|
);
|
|
1429
|
-
const deferredDisplayStatus =
|
|
1430
|
-
controller.useDisplayStatus()
|
|
1431
|
-
);
|
|
1329
|
+
const deferredDisplayStatus = useDeferredValue(controller.useDisplayStatus());
|
|
1432
1330
|
const actualTitle = isRepetitive ? typeof itemTitle === "function" ? deferredValue === void 0 ? null : itemTitle(deferredValue, index) : itemTitle === void 0 ? title : itemTitle : typeof title === "function" ? deferredValue === void 0 ? null : title(deferredValue) : title;
|
|
1433
1331
|
const actualSubtitle = typeof subtitle === "function" ? deferredValue === void 0 ? null : subtitle(deferredValue, index) : subtitle;
|
|
1434
1332
|
const actualDocumentTitle = typeof documentTitle === "function" ? deferredValue === void 0 ? null : documentTitle(deferredValue, index) : documentTitle === void 0 ? (actualTitle === null || typeof actualTitle === "string") && (actualSubtitle == null || typeof actualSubtitle === "string") ? [actualTitle, actualSubtitle].filter((s) => s).join(" — ") : void 0 : documentTitle;
|
|
1435
|
-
|
|
1333
|
+
useEffect(() => {
|
|
1436
1334
|
if (exists) {
|
|
1437
1335
|
const { registerAnnexState } = store.getState().actions;
|
|
1438
1336
|
registerAnnexState(absolutePath, {
|
|
@@ -1487,28 +1385,26 @@ function RepetitiveAnnexRegistrar({
|
|
|
1487
1385
|
const store = useAnnexesContext();
|
|
1488
1386
|
const [rowIds, controller] = useFormattedValue(path.parent(), {
|
|
1489
1387
|
enabled: !useFormIsLoading(),
|
|
1490
|
-
format:
|
|
1388
|
+
format: useCallback(
|
|
1491
1389
|
(value) => value == null ? [] : sliceTable(value).map(([id]) => id),
|
|
1492
1390
|
[]
|
|
1493
1391
|
)
|
|
1494
1392
|
});
|
|
1495
1393
|
const schema = controller.useSchema();
|
|
1496
1394
|
const absolutePath = controller.usePath();
|
|
1497
|
-
const deferredIssuesToDisplay =
|
|
1395
|
+
const deferredIssuesToDisplay = useDeferredValue(
|
|
1498
1396
|
controller.useState((state) => state.touched ? state.issues : [], {
|
|
1499
1397
|
equalityFn: shallow
|
|
1500
1398
|
})
|
|
1501
1399
|
);
|
|
1502
|
-
const deferredDisplayStatus =
|
|
1503
|
-
controller.useDisplayStatus()
|
|
1504
|
-
);
|
|
1400
|
+
const deferredDisplayStatus = useDeferredValue(controller.useDisplayStatus());
|
|
1505
1401
|
if (schema.typeInfo.name !== "Table") {
|
|
1506
1402
|
throw new InvalidPathError(
|
|
1507
1403
|
absolutePath,
|
|
1508
1404
|
`Unsupported schema: Expected (possibly nullable) table schema, but got schema representing values of type '${schema.typeInfo.toString()}'.`
|
|
1509
1405
|
);
|
|
1510
1406
|
}
|
|
1511
|
-
|
|
1407
|
+
useEffect(() => {
|
|
1512
1408
|
const { registerRepetitiveAnnexState } = store.getState().actions;
|
|
1513
1409
|
registerRepetitiveAnnexState(absolutePath, {
|
|
1514
1410
|
rowIds,
|
|
@@ -1547,9 +1443,7 @@ function RepetitiveAnnexRegistrar({
|
|
|
1547
1443
|
rowId
|
|
1548
1444
|
));
|
|
1549
1445
|
}
|
|
1550
|
-
const AnnexesContext =
|
|
1551
|
-
null
|
|
1552
|
-
);
|
|
1446
|
+
const AnnexesContext = createContext(null);
|
|
1553
1447
|
function useCreateAnnexesContext({
|
|
1554
1448
|
formManager,
|
|
1555
1449
|
basePath,
|
|
@@ -1707,7 +1601,7 @@ function useCreateAnnexesContext({
|
|
|
1707
1601
|
const newActiveAnnex = path === null || path instanceof AbsolutePath ? path : new AbsolutePath(path);
|
|
1708
1602
|
const oldActiveAnnex = get().activeAnnex;
|
|
1709
1603
|
if (!oldActiveAnnex?.equals(newActiveAnnex)) {
|
|
1710
|
-
|
|
1604
|
+
startTransition(() => {
|
|
1711
1605
|
set({ activeAnnex: newActiveAnnex });
|
|
1712
1606
|
if (newActiveAnnex != null) {
|
|
1713
1607
|
setActivePath(newActiveAnnex);
|
|
@@ -1785,7 +1679,7 @@ function useCreateAnnexesContext({
|
|
|
1785
1679
|
}))
|
|
1786
1680
|
)
|
|
1787
1681
|
);
|
|
1788
|
-
|
|
1682
|
+
useEffect(() => {
|
|
1789
1683
|
store.getState().actions.setAnnexes(resolvedAnnexes);
|
|
1790
1684
|
if (activeAnnex !== void 0) {
|
|
1791
1685
|
const {
|
|
@@ -1802,7 +1696,7 @@ function useCreateAnnexesContext({
|
|
|
1802
1696
|
}
|
|
1803
1697
|
}, [resolvedAnnexes, activeAnnex, basePath, store]);
|
|
1804
1698
|
useOnPathFocus(
|
|
1805
|
-
|
|
1699
|
+
useCallback(
|
|
1806
1700
|
(focusedPath) => {
|
|
1807
1701
|
const { activeAnnex: activeAnnex2, tabStates, waitingRegistration, actions } = store.getState();
|
|
1808
1702
|
actions.setActiveAnnex(
|
|
@@ -1819,7 +1713,7 @@ function useCreateAnnexesContext({
|
|
|
1819
1713
|
return store;
|
|
1820
1714
|
}
|
|
1821
1715
|
function useAnnexesContext() {
|
|
1822
|
-
const annexesContext =
|
|
1716
|
+
const annexesContext = useContext(AnnexesContext);
|
|
1823
1717
|
if (!annexesContext) {
|
|
1824
1718
|
throw new Error("Annexes context not in scope.");
|
|
1825
1719
|
}
|
|
@@ -1831,59 +1725,63 @@ function useAnnexState(path, selector) {
|
|
|
1831
1725
|
(state) => selector(state.actions.getAnnexState(path))
|
|
1832
1726
|
);
|
|
1833
1727
|
}
|
|
1834
|
-
const Annex =
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
(
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1728
|
+
const Annex = forwardRef(
|
|
1729
|
+
function Annex2({ path, ...otherProps }, forwardedRef) {
|
|
1730
|
+
const annexPath = useResolvedPath(path);
|
|
1731
|
+
const store = useAnnexesContext();
|
|
1732
|
+
const activeAnnex = useStore(store, (state) => state.activeAnnex);
|
|
1733
|
+
const tabStates = useStore(
|
|
1734
|
+
store,
|
|
1735
|
+
useShallow(
|
|
1736
|
+
(state) => state.tabStates().filter((state2) => annexPath.contains(state2.path))
|
|
1737
|
+
)
|
|
1738
|
+
);
|
|
1739
|
+
return tabStates.map((state) => {
|
|
1740
|
+
const pathStr = state.path.toString();
|
|
1741
|
+
return /* @__PURE__ */ jsx(CurrentPath, { path: state.path, children: /* @__PURE__ */ jsx(
|
|
1742
|
+
AnnexTabContent,
|
|
1743
|
+
{
|
|
1744
|
+
...otherProps,
|
|
1745
|
+
ref: state.path.equals(activeAnnex) ? forwardedRef : void 0
|
|
1746
|
+
}
|
|
1747
|
+
) }, pathStr);
|
|
1748
|
+
});
|
|
1749
|
+
}
|
|
1750
|
+
);
|
|
1751
|
+
const AnnexTabContent = forwardRef(
|
|
1752
|
+
function AnnexTabContent2({
|
|
1753
|
+
disabled = false,
|
|
1754
|
+
readOnly = false,
|
|
1755
|
+
issueMessages,
|
|
1756
|
+
children,
|
|
1757
|
+
className,
|
|
1758
|
+
errorBoundaryProps,
|
|
1759
|
+
...otherProps
|
|
1760
|
+
}, forwardedRef) {
|
|
1761
|
+
const prefix = usePrefix();
|
|
1762
|
+
const annexPath = useCurrentPath();
|
|
1763
|
+
const documentTitle = useAnnexState(
|
|
1764
|
+
annexPath,
|
|
1765
|
+
(state) => state === null ? null : state.documentTitle
|
|
1766
|
+
);
|
|
1767
|
+
if (documentTitle === void 0) {
|
|
1768
|
+
warnOnce(
|
|
1769
|
+
`Annex: At '${annexPath.toString()}': \`documentTitle\` should be set manually since either \`title\` or \`subtitle\` is not a string.`
|
|
1770
|
+
);
|
|
1771
|
+
}
|
|
1772
|
+
return /* @__PURE__ */ jsx(
|
|
1773
|
+
TabContent,
|
|
1848
1774
|
{
|
|
1775
|
+
className: cx(prefix("annexes__annex"), className),
|
|
1776
|
+
value: annexPath.toString(),
|
|
1849
1777
|
...otherProps,
|
|
1850
|
-
ref:
|
|
1778
|
+
ref: forwardedRef,
|
|
1779
|
+
children: /* @__PURE__ */ jsx(ErrorBoundary, { ...errorBoundaryProps, children: /* @__PURE__ */ jsx(DocumentTitle, { title: documentTitle ?? void 0, children: /* @__PURE__ */ jsx(FormAppStatus, { disabled, readOnly, children: /* @__PURE__ */ jsx(FormAppIssueMessages, { issueMessages, children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Spinner, { size: "xl", color: "primary" }), children }) }) }) }) })
|
|
1851
1780
|
}
|
|
1852
|
-
) }, pathStr);
|
|
1853
|
-
});
|
|
1854
|
-
});
|
|
1855
|
-
const AnnexTabContent = React.forwardRef(function AnnexTabContent2({
|
|
1856
|
-
disabled = false,
|
|
1857
|
-
readOnly = false,
|
|
1858
|
-
issueMessages,
|
|
1859
|
-
children,
|
|
1860
|
-
className,
|
|
1861
|
-
errorBoundaryProps,
|
|
1862
|
-
...otherProps
|
|
1863
|
-
}, forwardedRef) {
|
|
1864
|
-
const prefix = usePrefix();
|
|
1865
|
-
const annexPath = useCurrentPath();
|
|
1866
|
-
const documentTitle = useAnnexState(
|
|
1867
|
-
annexPath,
|
|
1868
|
-
(state) => state === null ? null : state.documentTitle
|
|
1869
|
-
);
|
|
1870
|
-
if (documentTitle === void 0) {
|
|
1871
|
-
warnOnce(
|
|
1872
|
-
`Annex: At '${annexPath.toString()}': \`documentTitle\` should be set manually since either \`title\` or \`subtitle\` is not a string.`
|
|
1873
1781
|
);
|
|
1874
1782
|
}
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
{
|
|
1878
|
-
className: cx(prefix("annexes__annex"), className),
|
|
1879
|
-
value: annexPath.toString(),
|
|
1880
|
-
...otherProps,
|
|
1881
|
-
ref: forwardedRef,
|
|
1882
|
-
children: /* @__PURE__ */ jsx(ErrorBoundary, { ...errorBoundaryProps, children: /* @__PURE__ */ jsx(DocumentTitle, { title: documentTitle ?? void 0, children: /* @__PURE__ */ jsx(FormAppStatus, { disabled, readOnly, children: /* @__PURE__ */ jsx(FormAppIssueMessages, { issueMessages, children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Spinner, { size: "xl", color: "primary" }), children }) }) }) }) })
|
|
1883
|
-
}
|
|
1884
|
-
);
|
|
1885
|
-
});
|
|
1886
|
-
const IssuesPopover = React.forwardRef(function IssuesPopover2({
|
|
1783
|
+
);
|
|
1784
|
+
const IssuesPopover = forwardRef(function IssuesPopover2({
|
|
1887
1785
|
path,
|
|
1888
1786
|
relevantPaths,
|
|
1889
1787
|
defaultOpen,
|
|
@@ -1892,13 +1790,13 @@ const IssuesPopover = React.forwardRef(function IssuesPopover2({
|
|
|
1892
1790
|
label,
|
|
1893
1791
|
...otherProps
|
|
1894
1792
|
}, forwardedRef) {
|
|
1895
|
-
const locale = useLocale();
|
|
1793
|
+
const [locale] = useLocale();
|
|
1896
1794
|
label ??= locale.IssuesPopover.label;
|
|
1897
1795
|
const absolutePath = useResolvedPath(path);
|
|
1898
1796
|
const [open, setOpen] = useControllableState(defaultOpen, controlledOpen);
|
|
1899
1797
|
const isInControlField = useIsInControlField();
|
|
1900
1798
|
useOnPathFocus(
|
|
1901
|
-
|
|
1799
|
+
useCallback(
|
|
1902
1800
|
(focusedPath) => {
|
|
1903
1801
|
if (!isInControlField && (relevantPaths ?? [absolutePath]).some(
|
|
1904
1802
|
(path2) => focusedPath.equals(new AbsolutePath(path2))
|
|
@@ -1962,14 +1860,14 @@ function AnnexesMenu({
|
|
|
1962
1860
|
const isLargeScreen = useMediaBreakpointUp("sm");
|
|
1963
1861
|
const issuesDisplayMode = useIssuesDisplayMode();
|
|
1964
1862
|
const [open, setOpen] = useControllableState(defaultOpen, controlledOpen);
|
|
1965
|
-
const menuTriggerRef =
|
|
1863
|
+
const menuTriggerRef = useRef(null);
|
|
1966
1864
|
const activeAnnex = useStore(store, (state) => state.activeAnnex);
|
|
1967
|
-
const handleRadioGroupValueChange =
|
|
1865
|
+
const handleRadioGroupValueChange = useCallback(
|
|
1968
1866
|
(value) => store.getState().actions.setActiveAnnex(new AbsolutePath(value)),
|
|
1969
1867
|
[store]
|
|
1970
1868
|
);
|
|
1971
1869
|
const annexes = useStore(store, (state) => state.annexes);
|
|
1972
|
-
const newItems =
|
|
1870
|
+
const newItems = useMemo(
|
|
1973
1871
|
() => annexes.map((annex) => /* @__PURE__ */ jsx(AnnexesMenuNewItem, { annex }, annex.path.toString())),
|
|
1974
1872
|
[annexes]
|
|
1975
1873
|
);
|
|
@@ -1979,7 +1877,7 @@ function AnnexesMenu({
|
|
|
1979
1877
|
);
|
|
1980
1878
|
const resetFocus = useResetFocus();
|
|
1981
1879
|
useOnPathFocus(
|
|
1982
|
-
|
|
1880
|
+
useCallback(
|
|
1983
1881
|
(focusedPath) => {
|
|
1984
1882
|
if (issuesDisplayMode === "panel" && menuTriggerRef.current && store.getState().tablessStates().some((state) => state.path.equals(focusedPath))) {
|
|
1985
1883
|
visiblyFocus(menuTriggerRef.current);
|
|
@@ -2216,8 +2114,8 @@ function AnnexesMenuNewItem({ annex }) {
|
|
|
2216
2114
|
}
|
|
2217
2115
|
return canBeAdded2;
|
|
2218
2116
|
});
|
|
2219
|
-
const [gettingValue, setGettingValue] =
|
|
2220
|
-
const handleItemSelect =
|
|
2117
|
+
const [gettingValue, setGettingValue] = useState(false);
|
|
2118
|
+
const handleItemSelect = useCallback(async () => {
|
|
2221
2119
|
const schema = formManager.schema(annex.path);
|
|
2222
2120
|
const initialValue = schema.typeInfo.nullable ? nullableSchemaInnerSchema(schema).initialValue : schema.initialValue;
|
|
2223
2121
|
let toAdd = initialValue;
|
|
@@ -2266,10 +2164,10 @@ function AnnexTab({ path }) {
|
|
|
2266
2164
|
);
|
|
2267
2165
|
const title = useAnnexState(path, (state) => state?.title);
|
|
2268
2166
|
const subtitle = useAnnexState(path, (state) => state?.subtitle);
|
|
2269
|
-
const tabRef =
|
|
2167
|
+
const tabRef = useRef(null);
|
|
2270
2168
|
const resetFocus = useResetFocus();
|
|
2271
2169
|
useOnPathFocus(
|
|
2272
|
-
|
|
2170
|
+
useCallback(
|
|
2273
2171
|
(focusedPath) => {
|
|
2274
2172
|
if (tabRef.current && path.equals(focusedPath)) {
|
|
2275
2173
|
if (issuesDisplayMode === "panel") {
|
|
@@ -2312,7 +2210,7 @@ function AnnexTab({ path }) {
|
|
|
2312
2210
|
)
|
|
2313
2211
|
] });
|
|
2314
2212
|
}
|
|
2315
|
-
const AnnexesTabList =
|
|
2213
|
+
const AnnexesTabList = forwardRef(function AnnexManager({ hideNonActiveOnSmallScreens, rootProps, className, ...otherProps }, forwardedRef) {
|
|
2316
2214
|
const prefix = usePrefix();
|
|
2317
2215
|
const store = useAnnexesContext();
|
|
2318
2216
|
const activeAnnex = useStore(store, (state) => state.activeAnnex);
|
|
@@ -2337,7 +2235,7 @@ const AnnexesTabList = React.forwardRef(function AnnexManager({ hideNonActiveOnS
|
|
|
2337
2235
|
}
|
|
2338
2236
|
);
|
|
2339
2237
|
});
|
|
2340
|
-
const AnnexesManager =
|
|
2238
|
+
const AnnexesManager = forwardRef(function AnnexManager2({
|
|
2341
2239
|
menuButtonText,
|
|
2342
2240
|
addAnnexText,
|
|
2343
2241
|
removeAnnexButtonLabel,
|
|
@@ -2357,7 +2255,7 @@ const AnnexesManager = React.forwardRef(function AnnexManager2({
|
|
|
2357
2255
|
...otherProps
|
|
2358
2256
|
}, forwardedRef) {
|
|
2359
2257
|
const prefix = usePrefix();
|
|
2360
|
-
const locale = useLocale();
|
|
2258
|
+
const [locale] = useLocale();
|
|
2361
2259
|
ariaLabel ??= locale.AnnexesManager["aria-label"];
|
|
2362
2260
|
menuButtonText ??= locale.AnnexesManager.menuButtonText;
|
|
2363
2261
|
addAnnexText ??= locale.AnnexesManager.addAnnexText;
|
|
@@ -2375,11 +2273,11 @@ const AnnexesManager = React.forwardRef(function AnnexManager2({
|
|
|
2375
2273
|
(state) => issuesDisplayMode === "inline" ? state.tablessStates() : []
|
|
2376
2274
|
)
|
|
2377
2275
|
);
|
|
2378
|
-
const tablessPaths =
|
|
2276
|
+
const tablessPaths = useMemo(
|
|
2379
2277
|
() => tablessStates.map((state) => state.path),
|
|
2380
2278
|
[tablessStates]
|
|
2381
2279
|
);
|
|
2382
|
-
const deferredTablessIssuesToDisplay =
|
|
2280
|
+
const deferredTablessIssuesToDisplay = useMemo(
|
|
2383
2281
|
() => tablessStates.map((state) => state.deferredIssuesToDisplay || []),
|
|
2384
2282
|
[tablessStates]
|
|
2385
2283
|
);
|
|
@@ -2529,18 +2427,18 @@ function useRegisterControl({
|
|
|
2529
2427
|
preventAutoFocus,
|
|
2530
2428
|
apiRef
|
|
2531
2429
|
}) {
|
|
2532
|
-
const { useState, usePath, useInitialized, useDisplayStatus } = controller;
|
|
2430
|
+
const { useState: useState2, usePath, useInitialized, useDisplayStatus } = controller;
|
|
2533
2431
|
const path = usePath();
|
|
2534
2432
|
const formIsDisabled = useFormIsDisabled();
|
|
2535
|
-
const displayDisabled =
|
|
2433
|
+
const displayDisabled = useState2((state) => !state.initialized || !state.exists) || formIsDisabled;
|
|
2536
2434
|
const displayReadOnly = useFormIsReadOnly();
|
|
2537
|
-
const deferredIsValidating =
|
|
2538
|
-
|
|
2435
|
+
const deferredIsValidating = useDeferredValue(
|
|
2436
|
+
useState2((state) => state.validationStatus === "validating")
|
|
2539
2437
|
);
|
|
2540
2438
|
const displayLoading = !useInitialized() || deferredIsValidating;
|
|
2541
|
-
const displayStatusToDisplay =
|
|
2542
|
-
const issuesToDisplay =
|
|
2543
|
-
|
|
2439
|
+
const displayStatusToDisplay = useDeferredValue(useDisplayStatus());
|
|
2440
|
+
const issuesToDisplay = useDeferredValue(
|
|
2441
|
+
useState2((state) => state.touched ? state.issues : [], {
|
|
2544
2442
|
equalityFn: shallow
|
|
2545
2443
|
})
|
|
2546
2444
|
);
|
|
@@ -2553,13 +2451,13 @@ function useRegisterControl({
|
|
|
2553
2451
|
useRegisterFieldLabel(path, issuesPanelLabelSuffix);
|
|
2554
2452
|
useRegisterControllerWithinControlField(controller, issuesToDisplay);
|
|
2555
2453
|
useRegisterController(controller);
|
|
2556
|
-
|
|
2454
|
+
useImperativeHandle(apiRef, () => controller, [controller]);
|
|
2557
2455
|
const autofocusRef = useControlAutofocus(
|
|
2558
2456
|
controller,
|
|
2559
2457
|
!preventAutoFocus
|
|
2560
2458
|
);
|
|
2561
2459
|
const setActivePath = useSetActivePath();
|
|
2562
|
-
const handleFocus =
|
|
2460
|
+
const handleFocus = useCallback(
|
|
2563
2461
|
(event) => {
|
|
2564
2462
|
if (event.target === event.currentTarget && !event.defaultPrevented) {
|
|
2565
2463
|
setActivePath(controller.getState().path);
|
|
@@ -2567,7 +2465,7 @@ function useRegisterControl({
|
|
|
2567
2465
|
},
|
|
2568
2466
|
[controller, setActivePath]
|
|
2569
2467
|
);
|
|
2570
|
-
return
|
|
2468
|
+
return useMemo(
|
|
2571
2469
|
() => ({
|
|
2572
2470
|
displayLoading,
|
|
2573
2471
|
displayDisabled,
|
|
@@ -2591,7 +2489,7 @@ function useRegisterControl({
|
|
|
2591
2489
|
function useRegisterFieldLabel(path, issuesPanelLabelSuffix) {
|
|
2592
2490
|
const { store: formAppStore } = useFormAppContext();
|
|
2593
2491
|
useOnFieldLabelChange(
|
|
2594
|
-
|
|
2492
|
+
useCallback(
|
|
2595
2493
|
(label) => formAppStore.getState().actions.registerLabel(
|
|
2596
2494
|
path,
|
|
2597
2495
|
label && issuesPanelLabelSuffix ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -2605,7 +2503,7 @@ function useRegisterFieldLabel(path, issuesPanelLabelSuffix) {
|
|
|
2605
2503
|
}
|
|
2606
2504
|
function useTemporalStringTransformer(dateTransformerOptions) {
|
|
2607
2505
|
const { format: format$1, parse } = useDateTransformer(dateTransformerOptions);
|
|
2608
|
-
return
|
|
2506
|
+
return useMemo(
|
|
2609
2507
|
() => ({
|
|
2610
2508
|
parse: (formattedDate, schema, options) => {
|
|
2611
2509
|
const date = parse(formattedDate, options);
|
|
@@ -2627,7 +2525,7 @@ function useTemporalStringTransformer(dateTransformerOptions) {
|
|
|
2627
2525
|
[format$1, parse]
|
|
2628
2526
|
);
|
|
2629
2527
|
}
|
|
2630
|
-
const DateRangeControl =
|
|
2528
|
+
const DateRangeControl = forwardRef(function DateRangeControl2({
|
|
2631
2529
|
startPath,
|
|
2632
2530
|
endPath,
|
|
2633
2531
|
startIssueMessages,
|
|
@@ -2671,7 +2569,7 @@ const DateRangeControl = React.forwardRef(function DateRangeControl2({
|
|
|
2671
2569
|
endAdornment,
|
|
2672
2570
|
...otherProps
|
|
2673
2571
|
}, forwardedRef) {
|
|
2674
|
-
const locale = useLocale();
|
|
2572
|
+
const [locale] = useLocale();
|
|
2675
2573
|
issuesPanelStartLabelSuffix ??= locale.DateRangeControl.issuesPanelStartLabelSuffix;
|
|
2676
2574
|
issuesPanelEndLabelSuffix ??= locale.DateRangeControl.issuesPanelEndLabelSuffix;
|
|
2677
2575
|
const { format: format2, parse } = useTemporalStringTransformer({
|
|
@@ -2679,15 +2577,15 @@ const DateRangeControl = React.forwardRef(function DateRangeControl2({
|
|
|
2679
2577
|
shortFormat,
|
|
2680
2578
|
fullFormat
|
|
2681
2579
|
});
|
|
2682
|
-
const [formattedValue, setFormattedValue] =
|
|
2580
|
+
const [formattedValue, setFormattedValue] = useState({
|
|
2683
2581
|
start: "",
|
|
2684
2582
|
end: ""
|
|
2685
2583
|
});
|
|
2686
|
-
const parseToString =
|
|
2584
|
+
const parseToString = useCallback(
|
|
2687
2585
|
(formattedValue2, state) => parse(formattedValue2, state.schema),
|
|
2688
2586
|
[parse]
|
|
2689
2587
|
);
|
|
2690
|
-
const formatFromString =
|
|
2588
|
+
const formatFromString = useCallback(
|
|
2691
2589
|
(stringValue, state) => format2(stringValue, state.schema),
|
|
2692
2590
|
[format2]
|
|
2693
2591
|
);
|
|
@@ -2696,7 +2594,7 @@ const DateRangeControl = React.forwardRef(function DateRangeControl2({
|
|
|
2696
2594
|
enabled: !formIsLoading,
|
|
2697
2595
|
parseToString,
|
|
2698
2596
|
formatFromString,
|
|
2699
|
-
setFormattedValue:
|
|
2597
|
+
setFormattedValue: useCallback(
|
|
2700
2598
|
(formattedValue2) => setFormattedValue(({ end }) => ({ start: formattedValue2, end })),
|
|
2701
2599
|
[]
|
|
2702
2600
|
),
|
|
@@ -2714,7 +2612,7 @@ const DateRangeControl = React.forwardRef(function DateRangeControl2({
|
|
|
2714
2612
|
enabled: !formIsLoading,
|
|
2715
2613
|
parseToString,
|
|
2716
2614
|
formatFromString,
|
|
2717
|
-
setFormattedValue:
|
|
2615
|
+
setFormattedValue: useCallback(
|
|
2718
2616
|
(formattedValue2) => setFormattedValue(({ start }) => ({ start, end: formattedValue2 })),
|
|
2719
2617
|
[]
|
|
2720
2618
|
),
|
|
@@ -2767,7 +2665,7 @@ const DateRangeControl = React.forwardRef(function DateRangeControl2({
|
|
|
2767
2665
|
preventAutoFocus,
|
|
2768
2666
|
apiRef: endApiRef
|
|
2769
2667
|
});
|
|
2770
|
-
const handleValueChange =
|
|
2668
|
+
const handleValueChange = useCallback(
|
|
2771
2669
|
({ formattedValue: newFormattedValue }) => {
|
|
2772
2670
|
setFormattedValue(newFormattedValue);
|
|
2773
2671
|
if (newFormattedValue.start !== formattedValue.start) {
|
|
@@ -2856,7 +2754,7 @@ const DateRangeControl = React.forwardRef(function DateRangeControl2({
|
|
|
2856
2754
|
inlineIssues
|
|
2857
2755
|
] });
|
|
2858
2756
|
});
|
|
2859
|
-
const FileControl =
|
|
2757
|
+
const FileControl = forwardRef(function FileControl2({
|
|
2860
2758
|
path,
|
|
2861
2759
|
issueMessages,
|
|
2862
2760
|
issuesPanelLabel,
|
|
@@ -2891,28 +2789,31 @@ const FileControl = React.forwardRef(function FileControl2({
|
|
|
2891
2789
|
...otherProps
|
|
2892
2790
|
}, forwardedRef) {
|
|
2893
2791
|
const prefix = usePrefix();
|
|
2894
|
-
const locale = useLocale();
|
|
2792
|
+
const [locale] = useLocale();
|
|
2895
2793
|
viewFileButtonLabel ??= locale.FileControl.viewFileButtonLabel;
|
|
2896
2794
|
downloadFileButtonLabel ??= locale.FileControl.downloadFileButtonLabel;
|
|
2897
2795
|
fallbackText ??= locale.FileControl.fallbackText;
|
|
2898
|
-
const latestFileList =
|
|
2899
|
-
const [file, setFile] =
|
|
2900
|
-
const controller = useFileInput(
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2796
|
+
const latestFileList = useRef(null);
|
|
2797
|
+
const [file, setFile] = useState(null);
|
|
2798
|
+
const controller = useFileInput(
|
|
2799
|
+
path,
|
|
2800
|
+
{
|
|
2801
|
+
enabled: !useFormIsLoading(),
|
|
2802
|
+
formManager,
|
|
2803
|
+
formatFromFileList: useCallback((fileList) => {
|
|
2804
|
+
setFile(fileList.length === 0 ? null : fileList[0]);
|
|
2805
|
+
latestFileList.current = fileList;
|
|
2806
|
+
return fileList;
|
|
2807
|
+
}, []),
|
|
2808
|
+
onInitialized,
|
|
2809
|
+
onFormManagerEvent,
|
|
2810
|
+
onValueChange,
|
|
2811
|
+
onValidationStatusChange,
|
|
2812
|
+
onDisplayStatusChange,
|
|
2813
|
+
onDirtyStatusChange,
|
|
2814
|
+
onTouchedStatusChange
|
|
2815
|
+
}
|
|
2816
|
+
);
|
|
2916
2817
|
const { useSchema, usePath, inputProps } = controller;
|
|
2917
2818
|
const { nullable, restrictions } = useSchema().typeInfo;
|
|
2918
2819
|
const absolutePath = usePath();
|
|
@@ -2932,11 +2833,11 @@ const FileControl = React.forwardRef(function FileControl2({
|
|
|
2932
2833
|
apiRef
|
|
2933
2834
|
});
|
|
2934
2835
|
showClearButton ??= nullable ? "auto" : false;
|
|
2935
|
-
const isClearing =
|
|
2936
|
-
const handleClearButtonClick =
|
|
2836
|
+
const isClearing = useRef(false);
|
|
2837
|
+
const handleClearButtonClick = useCallback(() => {
|
|
2937
2838
|
isClearing.current = true;
|
|
2938
2839
|
}, []);
|
|
2939
|
-
const handleChange =
|
|
2840
|
+
const handleChange = useCallback(
|
|
2940
2841
|
(evt) => {
|
|
2941
2842
|
if (evt.target.files.length > 0 || isClearing.current) {
|
|
2942
2843
|
isClearing.current = false;
|
|
@@ -2948,13 +2849,13 @@ const FileControl = React.forwardRef(function FileControl2({
|
|
|
2948
2849
|
},
|
|
2949
2850
|
[inputProps, onChange]
|
|
2950
2851
|
);
|
|
2951
|
-
const clearButtonRef =
|
|
2952
|
-
const handleKeyDown =
|
|
2852
|
+
const clearButtonRef = useRef(null);
|
|
2853
|
+
const handleKeyDown = useCallback((evt) => {
|
|
2953
2854
|
if (evt.code === "Delete" || evt.code === "Backspace") {
|
|
2954
2855
|
clearButtonRef.current?.click();
|
|
2955
2856
|
}
|
|
2956
2857
|
}, []);
|
|
2957
|
-
const dataURL =
|
|
2858
|
+
const dataURL = useMemo(
|
|
2958
2859
|
() => fileInteraction !== "none" && file ? URL.createObjectURL(file) : null,
|
|
2959
2860
|
[file, fileInteraction]
|
|
2960
2861
|
);
|
|
@@ -3069,89 +2970,91 @@ const FileControl = React.forwardRef(function FileControl2({
|
|
|
3069
2970
|
inlineIssues
|
|
3070
2971
|
] });
|
|
3071
2972
|
});
|
|
3072
|
-
const FormPages =
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
if (absolutePath.fragments.some(
|
|
3097
|
-
(frag) => !(frag instanceof AbsolutePathFragment.Id)
|
|
3098
|
-
)) {
|
|
3099
|
-
throw new Error("Form pages base path must only contain ids.");
|
|
3100
|
-
}
|
|
3101
|
-
for (const page of resolvedPages) {
|
|
3102
|
-
if (!formManager.isValidPath(page.path)) {
|
|
3103
|
-
throw new Error(`Invalid path: '${page.path.toString()}'`);
|
|
2973
|
+
const FormPages = forwardRef(
|
|
2974
|
+
function FormPages2({
|
|
2975
|
+
path,
|
|
2976
|
+
pages,
|
|
2977
|
+
defaultActivePage,
|
|
2978
|
+
activePage,
|
|
2979
|
+
onActivePageChange,
|
|
2980
|
+
className,
|
|
2981
|
+
...otherProps
|
|
2982
|
+
}, forwardedRef) {
|
|
2983
|
+
const prefix = usePrefix();
|
|
2984
|
+
const { cssVarName } = useCssVars({ prefix });
|
|
2985
|
+
const formManager = useFormManager();
|
|
2986
|
+
const absolutePath = useResolvedPath(path);
|
|
2987
|
+
const isLargeScreen = useMediaBreakpointUp("sm");
|
|
2988
|
+
const resolvedPages = useMemo(
|
|
2989
|
+
() => pages.map((page) => ({
|
|
2990
|
+
...page,
|
|
2991
|
+
path: absolutePath.resolve(page.path ?? Path.CURRENT)
|
|
2992
|
+
})),
|
|
2993
|
+
[absolutePath, pages]
|
|
2994
|
+
);
|
|
2995
|
+
if (!formManager.isValidPath(absolutePath)) {
|
|
2996
|
+
throw new Error(`Invalid path: '${absolutePath.toString()}'`);
|
|
3104
2997
|
}
|
|
3105
|
-
if (
|
|
2998
|
+
if (absolutePath.fragments.some(
|
|
3106
2999
|
(frag) => !(frag instanceof AbsolutePathFragment.Id)
|
|
3107
3000
|
)) {
|
|
3108
|
-
throw new Error("Form
|
|
3001
|
+
throw new Error("Form pages base path must only contain ids.");
|
|
3109
3002
|
}
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3003
|
+
for (const page of resolvedPages) {
|
|
3004
|
+
if (!formManager.isValidPath(page.path)) {
|
|
3005
|
+
throw new Error(`Invalid path: '${page.path.toString()}'`);
|
|
3006
|
+
}
|
|
3007
|
+
if (page.path.fragments.some(
|
|
3008
|
+
(frag) => !(frag instanceof AbsolutePathFragment.Id)
|
|
3009
|
+
)) {
|
|
3010
|
+
throw new Error("Form page path must only contain ids.");
|
|
3011
|
+
}
|
|
3012
|
+
}
|
|
3013
|
+
const store = useCreateFormPagesContext({
|
|
3014
|
+
basePath: absolutePath,
|
|
3015
|
+
resolvedPages,
|
|
3016
|
+
defaultActivePage,
|
|
3017
|
+
activePage,
|
|
3018
|
+
onActivePageChange
|
|
3019
|
+
});
|
|
3020
|
+
const formPagesRef = useRef(null);
|
|
3021
|
+
useEffect(
|
|
3022
|
+
() => store.subscribe(
|
|
3023
|
+
({ activePage: activePage2, pageHeaderHeights: [pageHeaderHeights] }) => (activePage2 && pageHeaderHeights.get(activePage2.toString())) ?? 0,
|
|
3024
|
+
(height) => formPagesRef.current?.style.setProperty(
|
|
3025
|
+
cssVarName("form-pages-page-header-height"),
|
|
3026
|
+
`${height}px`
|
|
3027
|
+
),
|
|
3028
|
+
{ fireImmediately: true }
|
|
3125
3029
|
),
|
|
3126
|
-
|
|
3127
|
-
)
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3030
|
+
[cssVarName, prefix, store]
|
|
3031
|
+
);
|
|
3032
|
+
useEffect(
|
|
3033
|
+
() => store.subscribe(
|
|
3034
|
+
(state) => state.navigationSelectHeight,
|
|
3035
|
+
(height) => formPagesRef.current?.style.setProperty(
|
|
3036
|
+
cssVarName("form-pages-navigation-select-height"),
|
|
3037
|
+
`${height}px`
|
|
3038
|
+
),
|
|
3039
|
+
{ fireImmediately: true }
|
|
3136
3040
|
),
|
|
3137
|
-
|
|
3138
|
-
)
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
});
|
|
3041
|
+
[cssVarName, prefix, store]
|
|
3042
|
+
);
|
|
3043
|
+
const combinedFormPagesRef = useCombinedRef(formPagesRef, forwardedRef);
|
|
3044
|
+
return /* @__PURE__ */ jsx(CurrentPath, { path: absolutePath, children: /* @__PURE__ */ jsxs(FormPagesContext.Provider, { value: store, children: [
|
|
3045
|
+
resolvedPages.map((page) => /* @__PURE__ */ jsx(FormPageRegistrar, { ...page }, page.path.toString())),
|
|
3046
|
+
/* @__PURE__ */ jsx(
|
|
3047
|
+
"div",
|
|
3048
|
+
{
|
|
3049
|
+
className: cx(prefix("form-pages"), className),
|
|
3050
|
+
"data-navigation-mode": isLargeScreen ? "sidebar" : "select",
|
|
3051
|
+
...otherProps,
|
|
3052
|
+
ref: combinedFormPagesRef
|
|
3053
|
+
}
|
|
3054
|
+
)
|
|
3055
|
+
] }) });
|
|
3056
|
+
}
|
|
3057
|
+
);
|
|
3155
3058
|
function FormPageRegistrar({
|
|
3156
3059
|
path,
|
|
3157
3060
|
title,
|
|
@@ -3168,18 +3071,16 @@ function FormPageRegistrar({
|
|
|
3168
3071
|
const exists = controller.useState(
|
|
3169
3072
|
(state) => state.initialized && state.exists
|
|
3170
3073
|
);
|
|
3171
|
-
const deferredValue =
|
|
3172
|
-
const deferredIssuesToDisplay =
|
|
3074
|
+
const deferredValue = useDeferredValue(controller.useValue());
|
|
3075
|
+
const deferredIssuesToDisplay = useDeferredValue(
|
|
3173
3076
|
controller.useState((state) => state.touched ? state.issues : [], {
|
|
3174
3077
|
equalityFn: shallow
|
|
3175
3078
|
})
|
|
3176
3079
|
);
|
|
3177
|
-
const deferredDisplayStatus =
|
|
3178
|
-
controller.useDisplayStatus()
|
|
3179
|
-
);
|
|
3080
|
+
const deferredDisplayStatus = useDeferredValue(controller.useDisplayStatus());
|
|
3180
3081
|
const actualTitle = typeof title === "function" ? deferredValue === void 0 ? null : title(deferredValue) : title;
|
|
3181
3082
|
const actualDocumentTitle = typeof documentTitle === "function" ? deferredValue === void 0 ? null : documentTitle(deferredValue) : documentTitle === void 0 ? actualTitle === null || typeof actualTitle === "string" ? actualTitle : void 0 : documentTitle;
|
|
3182
|
-
|
|
3083
|
+
useEffect(() => {
|
|
3183
3084
|
const { registerPageState } = store.getState().actions;
|
|
3184
3085
|
registerPageState(absolutePath, {
|
|
3185
3086
|
exists,
|
|
@@ -3208,7 +3109,9 @@ function FormPageRegistrar({
|
|
|
3208
3109
|
);
|
|
3209
3110
|
return null;
|
|
3210
3111
|
}
|
|
3211
|
-
const FormPagesContext =
|
|
3112
|
+
const FormPagesContext = createContext(
|
|
3113
|
+
null
|
|
3114
|
+
);
|
|
3212
3115
|
function useCreateFormPagesContext({
|
|
3213
3116
|
basePath,
|
|
3214
3117
|
resolvedPages,
|
|
@@ -3247,7 +3150,7 @@ function useCreateFormPagesContext({
|
|
|
3247
3150
|
const newActivePage = path === null || path instanceof AbsolutePath ? path : new AbsolutePath(path);
|
|
3248
3151
|
const oldActivePage = get().activePage;
|
|
3249
3152
|
if (!oldActivePage?.equals(newActivePage)) {
|
|
3250
|
-
|
|
3153
|
+
startTransition(() => {
|
|
3251
3154
|
set({ activePage: newActivePage });
|
|
3252
3155
|
if (newActivePage != null) {
|
|
3253
3156
|
setActivePath(newActivePage);
|
|
@@ -3289,7 +3192,7 @@ function useCreateFormPagesContext({
|
|
|
3289
3192
|
}))
|
|
3290
3193
|
)
|
|
3291
3194
|
);
|
|
3292
|
-
|
|
3195
|
+
useEffect(() => {
|
|
3293
3196
|
store.getState().actions.setPages(resolvedPages);
|
|
3294
3197
|
if (activePage !== void 0) {
|
|
3295
3198
|
const { pages, activePage: oldActivePage } = store.getState();
|
|
@@ -3303,7 +3206,7 @@ function useCreateFormPagesContext({
|
|
|
3303
3206
|
}
|
|
3304
3207
|
}, [resolvedPages, activePage, basePath, store]);
|
|
3305
3208
|
useOnPathFocus(
|
|
3306
|
-
|
|
3209
|
+
useCallback(
|
|
3307
3210
|
(focusedPath) => {
|
|
3308
3211
|
const { pages, activePage: activePage2, actions } = store.getState();
|
|
3309
3212
|
actions.setActivePage(
|
|
@@ -3320,7 +3223,7 @@ function useCreateFormPagesContext({
|
|
|
3320
3223
|
return store;
|
|
3321
3224
|
}
|
|
3322
3225
|
function useFormPagesContext() {
|
|
3323
|
-
const formPagesContext =
|
|
3226
|
+
const formPagesContext = useContext(FormPagesContext);
|
|
3324
3227
|
if (!formPagesContext) {
|
|
3325
3228
|
throw new Error("Form pages context not in scope.");
|
|
3326
3229
|
}
|
|
@@ -3332,7 +3235,7 @@ function useFormPageState(path, selector) {
|
|
|
3332
3235
|
(state) => selector(state.actions.getPageState(path))
|
|
3333
3236
|
);
|
|
3334
3237
|
}
|
|
3335
|
-
const FormPageHeader =
|
|
3238
|
+
const FormPageHeader = forwardRef(function FormPageHeader2({
|
|
3336
3239
|
helperText,
|
|
3337
3240
|
helperButtonLabel,
|
|
3338
3241
|
ownIssueMessages,
|
|
@@ -3464,111 +3367,119 @@ const FormPageHeader = React.forwardRef(function FormPageHeader2({
|
|
|
3464
3367
|
}
|
|
3465
3368
|
);
|
|
3466
3369
|
});
|
|
3467
|
-
const FormPage =
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
const documentTitle = useFormPageState(
|
|
3502
|
-
pagePath,
|
|
3503
|
-
(state) => state === null ? null : state.documentTitle
|
|
3504
|
-
);
|
|
3505
|
-
if (documentTitle === void 0) {
|
|
3506
|
-
warnOnce(
|
|
3507
|
-
`FormPage: At '${pagePath.toString()}': \`documentTitle\` should be set manually since the form page's \`title\` is not a string.`
|
|
3370
|
+
const FormPage = forwardRef(
|
|
3371
|
+
function FormPage2({
|
|
3372
|
+
path,
|
|
3373
|
+
disabled = false,
|
|
3374
|
+
readOnly = false,
|
|
3375
|
+
className,
|
|
3376
|
+
helperText,
|
|
3377
|
+
helperButtonLabel,
|
|
3378
|
+
issueMessages,
|
|
3379
|
+
ownIssueMessages,
|
|
3380
|
+
headerProps,
|
|
3381
|
+
codeProps,
|
|
3382
|
+
titleProps,
|
|
3383
|
+
headerPopoverContainerProps,
|
|
3384
|
+
issuesPopoverProps,
|
|
3385
|
+
issueMessagesProps,
|
|
3386
|
+
contentProps,
|
|
3387
|
+
containerProps,
|
|
3388
|
+
errorBoundaryProps,
|
|
3389
|
+
helperButtonProps,
|
|
3390
|
+
helperPopoverProps,
|
|
3391
|
+
helperPopoverContentProps,
|
|
3392
|
+
children,
|
|
3393
|
+
...otherProps
|
|
3394
|
+
}, forwardedRef) {
|
|
3395
|
+
const prefix = usePrefix();
|
|
3396
|
+
const [locale] = useLocale();
|
|
3397
|
+
helperButtonLabel ??= locale.FormPage.helperButtonLabel;
|
|
3398
|
+
const store = useFormPagesContext();
|
|
3399
|
+
const pagePath = useResolvedPath(path);
|
|
3400
|
+
const activePage = useStore(store, (state) => state.activePage);
|
|
3401
|
+
const shouldDisplay = useFormPageState(
|
|
3402
|
+
pagePath,
|
|
3403
|
+
(state) => state?.path.equals(activePage)
|
|
3508
3404
|
);
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
(
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
[pagePath, store]
|
|
3518
|
-
)
|
|
3519
|
-
);
|
|
3520
|
-
const formAppEl = useFormAppElement();
|
|
3521
|
-
const isFirstDisplay = React.useRef(true);
|
|
3522
|
-
React.useEffect(() => {
|
|
3523
|
-
if (shouldDisplay && isFirstDisplay.current) {
|
|
3524
|
-
formAppEl.scrollIntoView(true);
|
|
3525
|
-
isFirstDisplay.current = false;
|
|
3526
|
-
return () => {
|
|
3527
|
-
isFirstDisplay.current = true;
|
|
3528
|
-
};
|
|
3405
|
+
const documentTitle = useFormPageState(
|
|
3406
|
+
pagePath,
|
|
3407
|
+
(state) => state === null ? null : state.documentTitle
|
|
3408
|
+
);
|
|
3409
|
+
if (documentTitle === void 0) {
|
|
3410
|
+
warnOnce(
|
|
3411
|
+
`FormPage: At '${pagePath.toString()}': \`documentTitle\` should be set manually since the form page's \`title\` is not a string.`
|
|
3412
|
+
);
|
|
3529
3413
|
}
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3414
|
+
const [headerEl, setHeaderEl] = useState(null);
|
|
3415
|
+
useMeasure(
|
|
3416
|
+
headerEl,
|
|
3417
|
+
useCallback(
|
|
3418
|
+
(measurement) => {
|
|
3419
|
+
store.getState().actions.setPageHeaderHeight(pagePath, measurement?.height ?? null);
|
|
3420
|
+
},
|
|
3421
|
+
[pagePath, store]
|
|
3422
|
+
)
|
|
3423
|
+
);
|
|
3424
|
+
const formAppEl = useFormAppElement();
|
|
3425
|
+
const isFirstDisplay = useRef(true);
|
|
3426
|
+
useEffect(() => {
|
|
3427
|
+
if (shouldDisplay && isFirstDisplay.current) {
|
|
3428
|
+
formAppEl.scrollIntoView(true);
|
|
3429
|
+
isFirstDisplay.current = false;
|
|
3430
|
+
return () => {
|
|
3431
|
+
isFirstDisplay.current = true;
|
|
3432
|
+
};
|
|
3433
|
+
}
|
|
3434
|
+
}, [formAppEl, shouldDisplay]);
|
|
3435
|
+
const combinedHeaderRef = useCombinedRef(setHeaderEl, headerProps?.ref);
|
|
3436
|
+
return shouldDisplay ? /* @__PURE__ */ jsx(CurrentPath, { path: pagePath, children: /* @__PURE__ */ jsx(DocumentTitle, { title: documentTitle ?? void 0, children: /* @__PURE__ */ jsx(
|
|
3437
|
+
"div",
|
|
3438
|
+
{
|
|
3439
|
+
className: cx(prefix("form-pages__page"), className),
|
|
3440
|
+
...otherProps,
|
|
3441
|
+
ref: forwardedRef,
|
|
3442
|
+
children: /* @__PURE__ */ jsx(FormAppStatus, { disabled, readOnly, children: /* @__PURE__ */ jsxs(FormAppIssueMessages, { issueMessages, children: [
|
|
3443
|
+
/* @__PURE__ */ jsx(
|
|
3444
|
+
FormPageHeader,
|
|
3445
|
+
{
|
|
3446
|
+
helperText,
|
|
3447
|
+
helperButtonLabel,
|
|
3448
|
+
ownIssueMessages,
|
|
3449
|
+
codeProps,
|
|
3450
|
+
titleProps,
|
|
3451
|
+
headerPopoverContainerProps,
|
|
3452
|
+
issuesPopoverProps,
|
|
3453
|
+
issueMessagesProps,
|
|
3454
|
+
helperButtonProps,
|
|
3455
|
+
helperPopoverProps,
|
|
3456
|
+
helperPopoverContentProps,
|
|
3457
|
+
...headerProps,
|
|
3458
|
+
ref: combinedHeaderRef
|
|
3459
|
+
}
|
|
3460
|
+
),
|
|
3461
|
+
/* @__PURE__ */ jsx(
|
|
3462
|
+
"div",
|
|
3463
|
+
{
|
|
3464
|
+
...contentProps,
|
|
3465
|
+
className: cx(
|
|
3466
|
+
prefix("form-pages__page-content"),
|
|
3467
|
+
contentProps?.className
|
|
3468
|
+
),
|
|
3469
|
+
children: /* @__PURE__ */ jsx(Container, { fluid: "md", gutter: 0, ...containerProps, children: /* @__PURE__ */ jsx(ErrorBoundary, { ...errorBoundaryProps, children: /* @__PURE__ */ jsx(
|
|
3470
|
+
Suspense,
|
|
3471
|
+
{
|
|
3472
|
+
fallback: /* @__PURE__ */ jsx(Spinner, { size: "xl", color: "primary" }),
|
|
3473
|
+
children
|
|
3474
|
+
}
|
|
3475
|
+
) }) })
|
|
3476
|
+
}
|
|
3477
|
+
)
|
|
3478
|
+
] }) })
|
|
3479
|
+
}
|
|
3480
|
+
) }) }) : null;
|
|
3481
|
+
}
|
|
3482
|
+
);
|
|
3572
3483
|
function FormPagesSelectOption({ path }) {
|
|
3573
3484
|
const prefix = usePrefix();
|
|
3574
3485
|
const disabled = useFormPageState(path, (state) => !state?.exists);
|
|
@@ -3609,7 +3520,7 @@ function FormPagesSelectOption({ path }) {
|
|
|
3609
3520
|
}
|
|
3610
3521
|
) });
|
|
3611
3522
|
}
|
|
3612
|
-
const FormPagesSelect =
|
|
3523
|
+
const FormPagesSelect = forwardRef(function FormPagesSelect2({
|
|
3613
3524
|
rootProps,
|
|
3614
3525
|
containerProps,
|
|
3615
3526
|
valueProps,
|
|
@@ -3622,19 +3533,17 @@ const FormPagesSelect = React.forwardRef(function FormPagesSelect2({
|
|
|
3622
3533
|
const prefix = usePrefix();
|
|
3623
3534
|
const store = useFormPagesContext();
|
|
3624
3535
|
const activePage = useStore(store, (state) => state.activePage);
|
|
3625
|
-
const [selectRootEl, setSelectRootEl] =
|
|
3626
|
-
null
|
|
3627
|
-
);
|
|
3536
|
+
const [selectRootEl, setSelectRootEl] = useState(null);
|
|
3628
3537
|
useMeasure(
|
|
3629
3538
|
selectRootEl,
|
|
3630
|
-
|
|
3539
|
+
useCallback(
|
|
3631
3540
|
(measurement) => {
|
|
3632
3541
|
store.setState({ navigationSelectHeight: measurement?.height ?? 0 });
|
|
3633
3542
|
},
|
|
3634
3543
|
[store]
|
|
3635
3544
|
)
|
|
3636
3545
|
);
|
|
3637
|
-
const handleValueChange =
|
|
3546
|
+
const handleValueChange = useCallback(
|
|
3638
3547
|
(value) => value && store.getState().actions.setActivePage(new AbsolutePath(value)),
|
|
3639
3548
|
[store]
|
|
3640
3549
|
);
|
|
@@ -3701,10 +3610,10 @@ function FormPageSidebarItem({ path }) {
|
|
|
3701
3610
|
const code = useFormPageState(path, (state) => state?.code);
|
|
3702
3611
|
const title = useFormPageState(path, (state) => state?.title);
|
|
3703
3612
|
const issuesDisplayMode = useIssuesDisplayMode();
|
|
3704
|
-
const itemActionRef =
|
|
3613
|
+
const itemActionRef = useRef(null);
|
|
3705
3614
|
const resetFocus = useResetFocus();
|
|
3706
3615
|
useOnPathFocus(
|
|
3707
|
-
|
|
3616
|
+
useCallback(
|
|
3708
3617
|
(focusedPath) => {
|
|
3709
3618
|
if (itemActionRef.current && path.equals(focusedPath)) {
|
|
3710
3619
|
if (issuesDisplayMode === "panel") {
|
|
@@ -3745,16 +3654,16 @@ function FormPageSidebarItem({ path }) {
|
|
|
3745
3654
|
}
|
|
3746
3655
|
);
|
|
3747
3656
|
}
|
|
3748
|
-
const FormPagesSidebar =
|
|
3657
|
+
const FormPagesSidebar = forwardRef(function FormPagesSidebar2({ className, ...otherProps }, forwardedRef) {
|
|
3749
3658
|
const prefix = usePrefix();
|
|
3750
3659
|
const store = useFormPagesContext();
|
|
3751
3660
|
const { currentPath } = useFormContext();
|
|
3752
3661
|
const activePage = useStore(store, (state) => state.activePage);
|
|
3753
3662
|
const setLeftSidebarWidth = useSetLeftSidebarWidth();
|
|
3754
|
-
const [sidebarEl, setSidebarEl] =
|
|
3663
|
+
const [sidebarEl, setSidebarEl] = useState(null);
|
|
3755
3664
|
useMeasure(
|
|
3756
3665
|
sidebarEl,
|
|
3757
|
-
|
|
3666
|
+
useCallback(
|
|
3758
3667
|
(measurement) => {
|
|
3759
3668
|
if (activePage && currentPath.append(AbsolutePathFragment.RecursiveWildcard).contains(activePage)) {
|
|
3760
3669
|
setLeftSidebarWidth(measurement?.width);
|
|
@@ -3775,7 +3684,7 @@ const FormPagesSidebar = React.forwardRef(function FormPagesSidebar2({ className
|
|
|
3775
3684
|
}
|
|
3776
3685
|
);
|
|
3777
3686
|
});
|
|
3778
|
-
const FormPagesNavigation =
|
|
3687
|
+
const FormPagesNavigation = forwardRef(function FormPagesNavigation2({
|
|
3779
3688
|
sidebarProps,
|
|
3780
3689
|
selectProps,
|
|
3781
3690
|
className,
|
|
@@ -3783,7 +3692,7 @@ const FormPagesNavigation = React.forwardRef(function FormPagesNavigation2({
|
|
|
3783
3692
|
...otherProps
|
|
3784
3693
|
}, forwardedRef) {
|
|
3785
3694
|
const prefix = usePrefix();
|
|
3786
|
-
const locale = useLocale();
|
|
3695
|
+
const [locale] = useLocale();
|
|
3787
3696
|
ariaLabel ??= locale.FormPagesNavigation["aria-label"];
|
|
3788
3697
|
const isLargeScreen = useMediaBreakpointUp("sm");
|
|
3789
3698
|
return /* @__PURE__ */ jsx(
|
|
@@ -3801,7 +3710,7 @@ const FormPagesNavigation = React.forwardRef(function FormPagesNavigation2({
|
|
|
3801
3710
|
function useFormValidator() {
|
|
3802
3711
|
const startIssuesNavigation = useStartIssuesNavigation();
|
|
3803
3712
|
const { _setState } = useFormController();
|
|
3804
|
-
const validate =
|
|
3713
|
+
const validate = useCallback(async () => {
|
|
3805
3714
|
_setState({ validating: true });
|
|
3806
3715
|
try {
|
|
3807
3716
|
await startIssuesNavigation();
|
|
@@ -3809,14 +3718,14 @@ function useFormValidator() {
|
|
|
3809
3718
|
_setState({ validating: false });
|
|
3810
3719
|
}
|
|
3811
3720
|
}, [_setState, startIssuesNavigation]);
|
|
3812
|
-
return
|
|
3721
|
+
return useMemo(() => ({ validate }), [validate]);
|
|
3813
3722
|
}
|
|
3814
3723
|
function useFormIsValidating() {
|
|
3815
3724
|
const validatingAutomatically = useFormController().useAutoValidationStatus() === "activeRunning";
|
|
3816
3725
|
const validatingManually = useFormController().useState(
|
|
3817
3726
|
(state) => state.validating
|
|
3818
3727
|
);
|
|
3819
|
-
return
|
|
3728
|
+
return useMemo(
|
|
3820
3729
|
() => ({
|
|
3821
3730
|
validatingAutomatically,
|
|
3822
3731
|
validatingManually,
|
|
@@ -3853,7 +3762,7 @@ function IssuesPanelControls({
|
|
|
3853
3762
|
}) {
|
|
3854
3763
|
const prefix = usePrefix();
|
|
3855
3764
|
const { validating } = useFormIsValidating();
|
|
3856
|
-
const deferredValidating =
|
|
3765
|
+
const deferredValidating = useDeferredValue(validating);
|
|
3857
3766
|
const currentPageInitialized = currentPageController.useInitialized();
|
|
3858
3767
|
const currentPageExists = currentPageController.useExists();
|
|
3859
3768
|
const focus = useFocus();
|
|
@@ -4002,7 +3911,7 @@ function IssuesPanelControls({
|
|
|
4002
3911
|
)
|
|
4003
3912
|
] });
|
|
4004
3913
|
}
|
|
4005
|
-
const IssuesPanelMessagesCard =
|
|
3914
|
+
const IssuesPanelMessagesCard = forwardRef(function IssuesPanelMessagesCard2({
|
|
4006
3915
|
currentPagePath,
|
|
4007
3916
|
currentPageController,
|
|
4008
3917
|
issuesTrackerResult,
|
|
@@ -4034,21 +3943,21 @@ const IssuesPanelMessagesCard = React.forwardRef(function IssuesPanelMessagesCar
|
|
|
4034
3943
|
const hasErrors = currentInfo?.localDisplayStatus === "error";
|
|
4035
3944
|
const hasWarnings = currentInfo?.localDisplayStatus === "warning" || currentInfo?.localDisplayStatus === "error" && currentInfo.issues.some((issue) => issue.severity === "warning");
|
|
4036
3945
|
const formManager = useFormManager();
|
|
4037
|
-
const schema =
|
|
3946
|
+
const schema = useMemo(
|
|
4038
3947
|
() => currentInfo && formManager.schema(currentInfo.path),
|
|
4039
3948
|
[currentInfo, formManager]
|
|
4040
3949
|
);
|
|
4041
3950
|
const isRegistered = useIsRegistered(currentPagePath);
|
|
4042
|
-
const lastRegisteredPath =
|
|
3951
|
+
const lastRegisteredPath = useRef(null);
|
|
4043
3952
|
if (isRegistered) {
|
|
4044
3953
|
lastRegisteredPath.current = currentPagePath;
|
|
4045
3954
|
}
|
|
4046
3955
|
const hasBeenRegistered = isRegistered || lastRegisteredPath?.current?.equals(currentPagePath);
|
|
4047
|
-
const [cardEl, setCardEl] =
|
|
4048
|
-
const headerRef =
|
|
3956
|
+
const [cardEl, setCardEl] = useState(null);
|
|
3957
|
+
const headerRef = useRef(null);
|
|
4049
3958
|
useScrollPosition(
|
|
4050
3959
|
cardEl,
|
|
4051
|
-
|
|
3960
|
+
useCallback(
|
|
4052
3961
|
(scrollPosition) => setBoolDataAttr(
|
|
4053
3962
|
headerRef.current,
|
|
4054
3963
|
"stuck",
|
|
@@ -4178,7 +4087,7 @@ function Breadcrumb() {
|
|
|
4178
4087
|
({ path, label }) => /* @__PURE__ */ jsx(CurrentPath, { path, children: /* @__PURE__ */ jsx("span", { className: prefix("issues-panel__breadcrumb-item"), children: label }) }, path.toString())
|
|
4179
4088
|
);
|
|
4180
4089
|
}
|
|
4181
|
-
const IssuesPanelSummaryCard =
|
|
4090
|
+
const IssuesPanelSummaryCard = forwardRef(function IssuesPanelSummaryCard2({
|
|
4182
4091
|
issuesTrackerResult,
|
|
4183
4092
|
errorsLabel,
|
|
4184
4093
|
warningsLabel,
|
|
@@ -4265,7 +4174,7 @@ const IssuesPanelSummaryCard = React.forwardRef(function IssuesPanelSummaryCard2
|
|
|
4265
4174
|
}
|
|
4266
4175
|
);
|
|
4267
4176
|
});
|
|
4268
|
-
const IssuesPanel =
|
|
4177
|
+
const IssuesPanel = forwardRef(function ValidationPanel({
|
|
4269
4178
|
defaultOpen = false,
|
|
4270
4179
|
open: controlledOpen,
|
|
4271
4180
|
onOpenChange,
|
|
@@ -4301,7 +4210,7 @@ const IssuesPanel = React.forwardRef(function ValidationPanel({
|
|
|
4301
4210
|
...otherProps
|
|
4302
4211
|
}, forwardedRef) {
|
|
4303
4212
|
const prefix = usePrefix();
|
|
4304
|
-
const locale = useLocale();
|
|
4213
|
+
const [locale] = useLocale();
|
|
4305
4214
|
errorsLabel ??= locale.IssuesPanel.errorsLabel;
|
|
4306
4215
|
warningsLabel ??= locale.IssuesPanel.warningsLabel;
|
|
4307
4216
|
focusButtonLabel ??= locale.IssuesPanel.focusButtonLabel;
|
|
@@ -4321,7 +4230,7 @@ const IssuesPanel = React.forwardRef(function ValidationPanel({
|
|
|
4321
4230
|
});
|
|
4322
4231
|
useReportValidationFailures(issuesTrackerResult.info);
|
|
4323
4232
|
const activePath = useActivePath();
|
|
4324
|
-
const deferredIssuesTrackerResult =
|
|
4233
|
+
const deferredIssuesTrackerResult = useDeferredValue(issuesTrackerResult);
|
|
4325
4234
|
const { info } = deferredIssuesTrackerResult;
|
|
4326
4235
|
const nPages = info?.length ?? 0;
|
|
4327
4236
|
const [currentPagePath, setCurrentPagePath] = useIssuesPanelPath();
|
|
@@ -4329,8 +4238,8 @@ const IssuesPanel = React.forwardRef(function ValidationPanel({
|
|
|
4329
4238
|
currentPagePath ?? AbsolutePath.ROOT,
|
|
4330
4239
|
{ enabled: open && !formIsLoading && currentPagePath !== null }
|
|
4331
4240
|
);
|
|
4332
|
-
const lastExistingPageIndex =
|
|
4333
|
-
const currentPageIndex =
|
|
4241
|
+
const lastExistingPageIndex = useRef(null);
|
|
4242
|
+
const currentPageIndex = useMemo(() => {
|
|
4334
4243
|
const idx = currentPagePath ? info?.findIndex(({ path }) => currentPagePath.equals(path)) ?? -1 : -1;
|
|
4335
4244
|
if (idx !== -1) {
|
|
4336
4245
|
lastExistingPageIndex.current = idx;
|
|
@@ -4338,7 +4247,7 @@ const IssuesPanel = React.forwardRef(function ValidationPanel({
|
|
|
4338
4247
|
return idx;
|
|
4339
4248
|
}, [currentPagePath, info]);
|
|
4340
4249
|
const focus = useFocus();
|
|
4341
|
-
const goToPath =
|
|
4250
|
+
const goToPath = useCallback(
|
|
4342
4251
|
(path) => {
|
|
4343
4252
|
setCurrentPagePath(path);
|
|
4344
4253
|
if (path) {
|
|
@@ -4347,7 +4256,7 @@ const IssuesPanel = React.forwardRef(function ValidationPanel({
|
|
|
4347
4256
|
},
|
|
4348
4257
|
[focus, setCurrentPagePath]
|
|
4349
4258
|
);
|
|
4350
|
-
const goToPage =
|
|
4259
|
+
const goToPage = useCallback(
|
|
4351
4260
|
(page) => {
|
|
4352
4261
|
if (nPages > 0) {
|
|
4353
4262
|
const clampedPage = Math.max(0, Math.min(page, nPages - 1));
|
|
@@ -4357,31 +4266,31 @@ const IssuesPanel = React.forwardRef(function ValidationPanel({
|
|
|
4357
4266
|
},
|
|
4358
4267
|
[goToPath, info, nPages]
|
|
4359
4268
|
);
|
|
4360
|
-
const goToPreviousPage =
|
|
4269
|
+
const goToPreviousPage = useCallback(() => {
|
|
4361
4270
|
if (currentPageIndex !== -1) {
|
|
4362
4271
|
goToPage(currentPageIndex - 1);
|
|
4363
4272
|
} else {
|
|
4364
4273
|
goToPage((lastExistingPageIndex.current ?? 1) - 1);
|
|
4365
4274
|
}
|
|
4366
4275
|
}, [currentPageIndex, goToPage]);
|
|
4367
|
-
const goToNextPage =
|
|
4276
|
+
const goToNextPage = useCallback(() => {
|
|
4368
4277
|
if (currentPageIndex !== -1) {
|
|
4369
4278
|
goToPage(currentPageIndex + 1);
|
|
4370
4279
|
} else {
|
|
4371
4280
|
goToPage(lastExistingPageIndex.current ?? 0);
|
|
4372
4281
|
}
|
|
4373
4282
|
}, [currentPageIndex, goToPage]);
|
|
4374
|
-
const goToFirstPage =
|
|
4375
|
-
const goToLastPage =
|
|
4283
|
+
const goToFirstPage = useCallback(() => goToPage(0), [goToPage]);
|
|
4284
|
+
const goToLastPage = useCallback(
|
|
4376
4285
|
() => goToPage(nPages - 1),
|
|
4377
4286
|
[goToPage, nPages]
|
|
4378
4287
|
);
|
|
4379
4288
|
const formManager = useFormManager();
|
|
4380
|
-
const formSchema =
|
|
4381
|
-
const issuesOrderCompareFnRef =
|
|
4289
|
+
const formSchema = useMemo(() => formManager.schema(), [formManager]);
|
|
4290
|
+
const issuesOrderCompareFnRef = useRef(issuesOrderCompareFn);
|
|
4382
4291
|
issuesOrderCompareFnRef.current = issuesOrderCompareFn;
|
|
4383
|
-
const [starting, setStarting] =
|
|
4384
|
-
|
|
4292
|
+
const [starting, setStarting] = useState(false);
|
|
4293
|
+
useEffect(() => {
|
|
4385
4294
|
if (issuesTrackerResult.initialized && starting) {
|
|
4386
4295
|
if (issuesTrackerResult.info.length > 0) {
|
|
4387
4296
|
goToPath(
|
|
@@ -4404,7 +4313,7 @@ const IssuesPanel = React.forwardRef(function ValidationPanel({
|
|
|
4404
4313
|
starting
|
|
4405
4314
|
]);
|
|
4406
4315
|
const listeners = useLatestValues({ onOpenChange });
|
|
4407
|
-
const start =
|
|
4316
|
+
const start = useCallback(() => {
|
|
4408
4317
|
if (!open) {
|
|
4409
4318
|
setOpen(true);
|
|
4410
4319
|
listeners.onOpenChange?.(true);
|
|
@@ -4414,13 +4323,11 @@ const IssuesPanel = React.forwardRef(function ValidationPanel({
|
|
|
4414
4323
|
lastExistingPageIndex.current = null;
|
|
4415
4324
|
}, [listeners, open, setCurrentPagePath, setOpen]);
|
|
4416
4325
|
useSetStartIssuesNavigation(start);
|
|
4417
|
-
const [containerEl, setContainerEl] =
|
|
4418
|
-
null
|
|
4419
|
-
);
|
|
4326
|
+
const [containerEl, setContainerEl] = useState(null);
|
|
4420
4327
|
const setBottomPanelHeight = useSetBottomPanelHeight();
|
|
4421
4328
|
useMeasure(
|
|
4422
4329
|
containerEl,
|
|
4423
|
-
|
|
4330
|
+
useCallback(
|
|
4424
4331
|
(measurement) => setBottomPanelHeight(measurement?.height),
|
|
4425
4332
|
[setBottomPanelHeight]
|
|
4426
4333
|
)
|
|
@@ -4428,11 +4335,11 @@ const IssuesPanel = React.forwardRef(function ValidationPanel({
|
|
|
4428
4335
|
const formAppEl = useFormAppElement();
|
|
4429
4336
|
useIntersectionObserver(
|
|
4430
4337
|
containerEl,
|
|
4431
|
-
|
|
4338
|
+
useCallback(
|
|
4432
4339
|
(e) => setBoolDataAttr(containerEl, "stuck", e.intersectionRatio === 1),
|
|
4433
4340
|
[containerEl]
|
|
4434
4341
|
),
|
|
4435
|
-
|
|
4342
|
+
useMemo(
|
|
4436
4343
|
() => ({
|
|
4437
4344
|
root: formAppEl,
|
|
4438
4345
|
rootMargin: `0px 0px -1px 0px`,
|
|
@@ -4441,7 +4348,7 @@ const IssuesPanel = React.forwardRef(function ValidationPanel({
|
|
|
4441
4348
|
[formAppEl]
|
|
4442
4349
|
)
|
|
4443
4350
|
);
|
|
4444
|
-
const close =
|
|
4351
|
+
const close = useCallback(() => {
|
|
4445
4352
|
if (open) {
|
|
4446
4353
|
setOpen(false);
|
|
4447
4354
|
listeners.onOpenChange?.(false);
|
|
@@ -4585,7 +4492,7 @@ function LoadAction({
|
|
|
4585
4492
|
errorMessage,
|
|
4586
4493
|
...otherProps
|
|
4587
4494
|
}) {
|
|
4588
|
-
const locale = useLocale();
|
|
4495
|
+
const [locale] = useLocale();
|
|
4589
4496
|
label ??= locale.LoadAction.label;
|
|
4590
4497
|
keybinds ??= locale.LoadAction.keybinds;
|
|
4591
4498
|
const { load } = useFormLoader({
|
|
@@ -4637,11 +4544,11 @@ function useFormSaver({
|
|
|
4637
4544
|
successMessage,
|
|
4638
4545
|
errorMessage
|
|
4639
4546
|
} = {}) {
|
|
4640
|
-
const locale = useLocale();
|
|
4547
|
+
const [locale] = useLocale();
|
|
4641
4548
|
const formManager = useFormManager();
|
|
4642
4549
|
const { getState, _setState } = useFormController();
|
|
4643
4550
|
const { addToast } = useToastManager();
|
|
4644
|
-
return
|
|
4551
|
+
return useMemo(() => {
|
|
4645
4552
|
async function save({
|
|
4646
4553
|
overwrite: overwrite2,
|
|
4647
4554
|
path: path2 = AbsolutePath.ROOT,
|
|
@@ -4785,7 +4692,7 @@ function SaveAction({
|
|
|
4785
4692
|
dropdownMenuProps,
|
|
4786
4693
|
...otherProps
|
|
4787
4694
|
}) {
|
|
4788
|
-
const locale = useLocale();
|
|
4695
|
+
const [locale] = useLocale();
|
|
4789
4696
|
label ??= locale.SaveAction.label;
|
|
4790
4697
|
keybinds ??= locale.SaveAction.keybinds;
|
|
4791
4698
|
saveOptionsLabel ??= locale.SaveAction.saveOptionsLabel;
|
|
@@ -4894,7 +4801,7 @@ function SubmitAction({
|
|
|
4894
4801
|
...otherProps
|
|
4895
4802
|
}) {
|
|
4896
4803
|
const prefix = usePrefix();
|
|
4897
|
-
const locale = useLocale();
|
|
4804
|
+
const [locale] = useLocale();
|
|
4898
4805
|
label ??= locale.SubmitAction.label;
|
|
4899
4806
|
keybinds ??= locale.SubmitAction.keybinds;
|
|
4900
4807
|
dialogTitle ??= locale.SubmitAction.dialogTitle;
|
|
@@ -4905,17 +4812,17 @@ function SubmitAction({
|
|
|
4905
4812
|
dialogCancelText ??= locale.SubmitAction.dialogCancelText;
|
|
4906
4813
|
successMessage ??= locale.SubmitAction.successMessage;
|
|
4907
4814
|
errorMessage ??= locale.SubmitAction.errorMessage;
|
|
4908
|
-
const [confirmingSubmission, setConfirmingSubmission] =
|
|
4815
|
+
const [confirmingSubmission, setConfirmingSubmission] = useState(false);
|
|
4909
4816
|
const startIssuesNavigation = useStartIssuesNavigation();
|
|
4910
4817
|
const { addToast } = useToastManager();
|
|
4911
4818
|
const { submit, useSubmitting } = useFormController();
|
|
4912
4819
|
const submitting = useSubmitting();
|
|
4913
|
-
const [runningOnSubmit, setRunningOnSubmit] =
|
|
4820
|
+
const [runningOnSubmit, setRunningOnSubmit] = useState(false);
|
|
4914
4821
|
const formIsLoading = useFormIsLoading();
|
|
4915
4822
|
const formIsDisabled = useFormIsDisabled();
|
|
4916
4823
|
const formAppEl = useFormAppElement();
|
|
4917
|
-
const [submissionInfo, setSubmissionInfo] =
|
|
4918
|
-
const [checkedWarnings, setCheckedWarnings] =
|
|
4824
|
+
const [submissionInfo, setSubmissionInfo] = useState(null);
|
|
4825
|
+
const [checkedWarnings, setCheckedWarnings] = useState([]);
|
|
4919
4826
|
const allWarningsChecked = !submissionInfo?.warnings || submissionInfo.warnings.every(
|
|
4920
4827
|
(warning) => checkedWarnings.some((checkedWarning) => warning.equals(checkedWarning))
|
|
4921
4828
|
);
|
|
@@ -5081,9 +4988,9 @@ function SubmitAction({
|
|
|
5081
4988
|
] });
|
|
5082
4989
|
}
|
|
5083
4990
|
function useTableControlApiRef() {
|
|
5084
|
-
return
|
|
4991
|
+
return useRef(null);
|
|
5085
4992
|
}
|
|
5086
|
-
const TableControlRemoveRowTrigger =
|
|
4993
|
+
const TableControlRemoveRowTrigger = forwardRef(function TableControlRemoveRowTrigger2({
|
|
5087
4994
|
showConfirmation,
|
|
5088
4995
|
onConfirmRowRemoval,
|
|
5089
4996
|
onRowRemoved,
|
|
@@ -5098,7 +5005,7 @@ const TableControlRemoveRowTrigger = React.forwardRef(function TableControlRemov
|
|
|
5098
5005
|
children,
|
|
5099
5006
|
...otherProps
|
|
5100
5007
|
}, forwardedRef) {
|
|
5101
|
-
const locale = useLocale();
|
|
5008
|
+
const [locale] = useLocale();
|
|
5102
5009
|
defaultButtonLabel ??= locale.TableControlRemoveRowTrigger.defaultButtonLabel;
|
|
5103
5010
|
confirmDialogTitle ??= locale.TableControlRemoveRowTrigger.confirmDialogTitle;
|
|
5104
5011
|
confirmDialogMessage ??= locale.TableControlRemoveRowTrigger.confirmDialogMessage;
|
|
@@ -5112,7 +5019,7 @@ const TableControlRemoveRowTrigger = React.forwardRef(function TableControlRemov
|
|
|
5112
5019
|
const initialized = useInitialized();
|
|
5113
5020
|
const exists = useExists();
|
|
5114
5021
|
const setActivePath = useSetActivePath();
|
|
5115
|
-
const [removing, setRemoving] =
|
|
5022
|
+
const [removing, setRemoving] = useState(false);
|
|
5116
5023
|
const handleClick = async () => {
|
|
5117
5024
|
const { path, dirty } = getState();
|
|
5118
5025
|
if (removing || showConfirmation && dirty && !await confirm(confirmDialogMessage(index), {
|
|
@@ -5177,25 +5084,25 @@ function tableControlActionsColumn({
|
|
|
5177
5084
|
...columnOverrides
|
|
5178
5085
|
};
|
|
5179
5086
|
}
|
|
5180
|
-
const TableControlContext =
|
|
5087
|
+
const TableControlContext = createContext(null);
|
|
5181
5088
|
function useTableControlContext() {
|
|
5182
|
-
const tableControlContext =
|
|
5089
|
+
const tableControlContext = useContext(TableControlContext);
|
|
5183
5090
|
if (!tableControlContext) {
|
|
5184
5091
|
throw new Error("Table control context not in scope.");
|
|
5185
5092
|
}
|
|
5186
5093
|
return tableControlContext;
|
|
5187
5094
|
}
|
|
5188
|
-
const TableControlRowContext =
|
|
5095
|
+
const TableControlRowContext = createContext(null);
|
|
5189
5096
|
function useTableControlRowContext() {
|
|
5190
|
-
const tableControlRowContext =
|
|
5097
|
+
const tableControlRowContext = useContext(TableControlRowContext);
|
|
5191
5098
|
if (!tableControlRowContext) {
|
|
5192
5099
|
throw new Error("Table control row context not in scope.");
|
|
5193
5100
|
}
|
|
5194
5101
|
return tableControlRowContext;
|
|
5195
5102
|
}
|
|
5196
|
-
const TableControlCell =
|
|
5103
|
+
const TableControlCell = forwardRef(function TableControlCell2({ variant, ...otherProps }, forwardedRef) {
|
|
5197
5104
|
const { useDisplayStatus } = useTableControlRowContext();
|
|
5198
|
-
const deferredDisplayStatus =
|
|
5105
|
+
const deferredDisplayStatus = useDeferredValue(useDisplayStatus());
|
|
5199
5106
|
return /* @__PURE__ */ jsx(
|
|
5200
5107
|
DataTableCell,
|
|
5201
5108
|
{
|
|
@@ -5206,35 +5113,37 @@ const TableControlCell = React.forwardRef(function TableControlCell2({ variant,
|
|
|
5206
5113
|
}
|
|
5207
5114
|
);
|
|
5208
5115
|
});
|
|
5209
|
-
const TableControlRow =
|
|
5210
|
-
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
|
|
5214
|
-
|
|
5215
|
-
|
|
5216
|
-
|
|
5217
|
-
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5116
|
+
const TableControlRow = memo(
|
|
5117
|
+
forwardRef(
|
|
5118
|
+
function TableControlRow2({ row, index, ...otherProps }, forwardedRef) {
|
|
5119
|
+
const controller = useController(row, {
|
|
5120
|
+
enabled: !useFormIsLoading() && row != null
|
|
5121
|
+
});
|
|
5122
|
+
const path = controller.usePath();
|
|
5123
|
+
useRegisterController(controller);
|
|
5124
|
+
useRegisterLabel(path, row == null ? null : index + 1);
|
|
5125
|
+
return /* @__PURE__ */ jsx(CurrentPath, { path, children: /* @__PURE__ */ jsx(
|
|
5126
|
+
TableControlRowContext.Provider,
|
|
5127
|
+
{
|
|
5128
|
+
value: useMemo(
|
|
5129
|
+
() => ({ index, ...controller }),
|
|
5130
|
+
[controller, index]
|
|
5131
|
+
),
|
|
5132
|
+
children: /* @__PURE__ */ jsx(
|
|
5133
|
+
DataTableRow,
|
|
5134
|
+
{
|
|
5135
|
+
row,
|
|
5136
|
+
index,
|
|
5137
|
+
...otherProps,
|
|
5138
|
+
ref: forwardedRef
|
|
5139
|
+
}
|
|
5140
|
+
)
|
|
5141
|
+
}
|
|
5142
|
+
) });
|
|
5143
|
+
}
|
|
5144
|
+
)
|
|
5236
5145
|
);
|
|
5237
|
-
const TableControl =
|
|
5146
|
+
const TableControl = forwardRef(function TableControl2({
|
|
5238
5147
|
path,
|
|
5239
5148
|
issueMessages,
|
|
5240
5149
|
issuesPanelLabel,
|
|
@@ -5258,12 +5167,12 @@ const TableControl = React.forwardRef(function TableControl2({
|
|
|
5258
5167
|
...otherProps
|
|
5259
5168
|
}, forwardedRef) {
|
|
5260
5169
|
const prefix = usePrefix();
|
|
5261
|
-
const [ids, setIds] =
|
|
5170
|
+
const [ids, setIds] = useState(void 0);
|
|
5262
5171
|
const size = ids?.length;
|
|
5263
5172
|
const dataTableApiRef = useDataTableApiRef();
|
|
5264
5173
|
const controller = useFormatter(path, {
|
|
5265
5174
|
enabled: !useFormIsLoading(),
|
|
5266
|
-
format:
|
|
5175
|
+
format: useCallback(
|
|
5267
5176
|
(value) => value ? sliceTable(value).map(([id]) => id) : [],
|
|
5268
5177
|
[]
|
|
5269
5178
|
),
|
|
@@ -5292,7 +5201,7 @@ const TableControl = React.forwardRef(function TableControl2({
|
|
|
5292
5201
|
`Unsupported schema: Expected (possibly nullable) table schema, but got schema representing values of type '${schema.typeInfo.toString()}'.`
|
|
5293
5202
|
);
|
|
5294
5203
|
}
|
|
5295
|
-
const ownController =
|
|
5204
|
+
const ownController = useMemo(
|
|
5296
5205
|
() => ({
|
|
5297
5206
|
addRow: async () => {
|
|
5298
5207
|
const { schema: schema2, initialized: initialized2, exists: exists2, touched, dirty } = controller.getState();
|
|
@@ -5337,13 +5246,13 @@ const TableControl = React.forwardRef(function TableControl2({
|
|
|
5337
5246
|
size
|
|
5338
5247
|
]
|
|
5339
5248
|
);
|
|
5340
|
-
const goToIndex =
|
|
5249
|
+
const goToIndex = useCallback(
|
|
5341
5250
|
(index, scrollOptions) => {
|
|
5342
5251
|
dataTableApiRef.current?.goTo(index, scrollOptions);
|
|
5343
5252
|
},
|
|
5344
5253
|
[dataTableApiRef]
|
|
5345
5254
|
);
|
|
5346
|
-
const goToId =
|
|
5255
|
+
const goToId = useCallback(
|
|
5347
5256
|
(id, scrollOptions) => {
|
|
5348
5257
|
const { initialized: initialized2, exists: exists2 } = controller.getState();
|
|
5349
5258
|
if (initialized2 && exists2) {
|
|
@@ -5373,7 +5282,7 @@ const TableControl = React.forwardRef(function TableControl2({
|
|
|
5373
5282
|
});
|
|
5374
5283
|
const controlIsDisabled = displayDisabled || disabled;
|
|
5375
5284
|
const controlIsReadOnly = displayReadOnly || readOnly || isComputedSchema(schema);
|
|
5376
|
-
|
|
5285
|
+
useImperativeHandle(
|
|
5377
5286
|
apiRef,
|
|
5378
5287
|
() => ({
|
|
5379
5288
|
...controller,
|
|
@@ -5383,7 +5292,7 @@ const TableControl = React.forwardRef(function TableControl2({
|
|
|
5383
5292
|
[controller, goToId, goToIndex]
|
|
5384
5293
|
);
|
|
5385
5294
|
useOnPathFocus(
|
|
5386
|
-
|
|
5295
|
+
useCallback(
|
|
5387
5296
|
(focusedPath) => {
|
|
5388
5297
|
if (exists && focusedPath && absolutePath.resolve(AbsolutePath.DESCENDANTS).contains(focusedPath)) {
|
|
5389
5298
|
const rowId = focusedPath.fragments[absolutePath.size];
|
|
@@ -5395,14 +5304,14 @@ const TableControl = React.forwardRef(function TableControl2({
|
|
|
5395
5304
|
[absolutePath, exists, goToId]
|
|
5396
5305
|
)
|
|
5397
5306
|
);
|
|
5398
|
-
const dataTableColumns =
|
|
5307
|
+
const dataTableColumns = useMemo(
|
|
5399
5308
|
() => tableControlToDataTableColumns(columns, {
|
|
5400
5309
|
disabled: controlIsDisabled,
|
|
5401
5310
|
readOnly: controlIsReadOnly
|
|
5402
5311
|
}),
|
|
5403
5312
|
[columns, controlIsDisabled, controlIsReadOnly]
|
|
5404
5313
|
);
|
|
5405
|
-
const tableControlController =
|
|
5314
|
+
const tableControlController = useMemo(
|
|
5406
5315
|
() => ({ ...controller, ...ownController }),
|
|
5407
5316
|
[controller, ownController]
|
|
5408
5317
|
);
|
|
@@ -5475,7 +5384,7 @@ function TableControlCellRenderer({
|
|
|
5475
5384
|
const controller = useTableControlRowContext();
|
|
5476
5385
|
return render(controller);
|
|
5477
5386
|
}
|
|
5478
|
-
const TableControlAddRowTrigger =
|
|
5387
|
+
const TableControlAddRowTrigger = forwardRef(function TableControlAddRowTrigger2({
|
|
5479
5388
|
defaultButtonText,
|
|
5480
5389
|
onRowAdded,
|
|
5481
5390
|
showWhenReadOnly,
|
|
@@ -5486,7 +5395,7 @@ const TableControlAddRowTrigger = React.forwardRef(function TableControlAddRowTr
|
|
|
5486
5395
|
...otherProps
|
|
5487
5396
|
}, forwardedRef) {
|
|
5488
5397
|
const prefix = usePrefix();
|
|
5489
|
-
const locale = useLocale();
|
|
5398
|
+
const [locale] = useLocale();
|
|
5490
5399
|
defaultButtonText ??= locale.TableControlAddRowTrigger.defaultButtonText;
|
|
5491
5400
|
const { controller, size, maxRows } = useTableControlContext();
|
|
5492
5401
|
const controlIsDisabled = useFormIsDisabled();
|
|
@@ -5515,18 +5424,16 @@ const TableControlAddRowTrigger = React.forwardRef(function TableControlAddRowTr
|
|
|
5515
5424
|
}
|
|
5516
5425
|
);
|
|
5517
5426
|
});
|
|
5518
|
-
const TableControlContent =
|
|
5427
|
+
const TableControlContent = forwardRef(function TableControlContent2({ containerProps, ...otherProps }, forwardedRef) {
|
|
5519
5428
|
const prefix = usePrefix();
|
|
5520
5429
|
const { autofocusRef, handleFocus, controller } = useTableControlContext();
|
|
5521
|
-
const handleContainerOnBlur =
|
|
5430
|
+
const handleContainerOnBlur = useCallback(() => {
|
|
5522
5431
|
const { initialized, exists, touched } = controller.getState();
|
|
5523
5432
|
if (initialized && exists && touched) {
|
|
5524
5433
|
void controller.setTouched();
|
|
5525
5434
|
}
|
|
5526
5435
|
}, [controller]);
|
|
5527
|
-
const deferredDisplayStatus =
|
|
5528
|
-
controller.useDisplayStatus()
|
|
5529
|
-
);
|
|
5436
|
+
const deferredDisplayStatus = useDeferredValue(controller.useDisplayStatus());
|
|
5530
5437
|
return /* @__PURE__ */ jsx(
|
|
5531
5438
|
DataTableContent,
|
|
5532
5439
|
{
|
|
@@ -5561,12 +5468,12 @@ function ValidateAction({
|
|
|
5561
5468
|
onClick,
|
|
5562
5469
|
...otherProps
|
|
5563
5470
|
}) {
|
|
5564
|
-
const locale = useLocale();
|
|
5471
|
+
const [locale] = useLocale();
|
|
5565
5472
|
label ??= locale.ValidateAction.label;
|
|
5566
5473
|
keybinds ??= locale.ValidateAction.keybinds;
|
|
5567
5474
|
const { validate } = useFormValidator();
|
|
5568
5475
|
const { validatingAutomatically, validating } = useFormIsValidating();
|
|
5569
|
-
const deferredValidating =
|
|
5476
|
+
const deferredValidating = useDeferredValue(validating);
|
|
5570
5477
|
const formIsLoading = useFormIsLoading();
|
|
5571
5478
|
const formAppEl = useFormAppElement();
|
|
5572
5479
|
useKeyboardShortcut(keybinds, validate, {
|
|
@@ -5588,279 +5495,40 @@ function ValidateAction({
|
|
|
5588
5495
|
}
|
|
5589
5496
|
);
|
|
5590
5497
|
}
|
|
5591
|
-
const
|
|
5592
|
-
|
|
5593
|
-
|
|
5594
|
-
|
|
5595
|
-
|
|
5596
|
-
|
|
5597
|
-
|
|
5598
|
-
|
|
5599
|
-
|
|
5600
|
-
|
|
5601
|
-
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
|
|
5613
|
-
|
|
5614
|
-
|
|
5615
|
-
|
|
5616
|
-
|
|
5617
|
-
|
|
5618
|
-
|
|
5619
|
-
|
|
5620
|
-
|
|
5621
|
-
|
|
5622
|
-
|
|
5623
|
-
|
|
5624
|
-
|
|
5625
|
-
rangeUnderflow: "Value is under the minimum allowed.",
|
|
5626
|
-
rangeOverflow: "Value exceeds the maximum allowed.",
|
|
5627
|
-
lengthMismatch: (_data, { typeInfo: { name, restrictions } }) => name === "String" && typeof restrictions.minLength === "number" && restrictions.minLength === restrictions.maxLength ? `Value must have ${restrictions.minLength} character${restrictions.minLength === 1 ? "" : "s"}.` : "Value has an invalid length.",
|
|
5628
|
-
tooShort: (_data, { typeInfo: { name, restrictions } }) => name === "String" && typeof restrictions.minLength === "number" ? `Value must not have under ${restrictions.minLength} character${restrictions.minLength === 1 ? "" : "s"}.` : "Value is too short.",
|
|
5629
|
-
tooLong: (_data, { typeInfo: { name, restrictions } }) => name === "String" && typeof restrictions.maxLength === "number" ? `Value must not have over ${restrictions.maxLength} character${restrictions.maxLength === 1 ? "" : "s"}.` : "Value is too long.",
|
|
5630
|
-
sizeMismatch: (_data, { typeInfo: { restrictions } }) => typeof restrictions.minSize === "number" && restrictions.minSize === restrictions.maxSize ? `Field must have ${restrictions.minSize} item${restrictions.minSize === 1 ? "" : "s"}.` : "Field has an invalid number of items.",
|
|
5631
|
-
tooSmall: (_data, { typeInfo: { restrictions } }) => typeof restrictions.minLength === "number" ? `Field must not have under ${restrictions.minLength} item${restrictions.minLength === 1 ? "" : "s"}.` : "Field does not have enough items.",
|
|
5632
|
-
tooLarge: (_data, { typeInfo: { restrictions } }) => typeof restrictions.maxLength === "number" ? `Field must not have over ${restrictions.maxLength} item${restrictions.maxLength === 1 ? "" : "s"}.` : "Number of items of field exceeds allowed limit.",
|
|
5633
|
-
scaleMismatch: (_data, { typeInfo: { restrictions } }) => typeof restrictions.scale === "number" ? `Value must have ${restrictions.scale} decimal place${restrictions.scale === 1 ? "" : "s"}.` : "Value has invalid number of decimal places.",
|
|
5634
|
-
patternMismatch: "Value does not follow required pattern.",
|
|
5635
|
-
emailPatternMismatch: "Invalid email address.",
|
|
5636
|
-
fileTypeMismatch: (_data, { typeInfo: { restrictions } }) => Array.isArray(restrictions.acceptedFileTypes) ? `Only the following file types are allowed: ${restrictions.acceptedFileTypes.join(", ")}.` : "Indicated file’s type is not allowed.",
|
|
5637
|
-
itemsRepeated: ({ firstIndex, secondIndex }) => firstIndex != null && secondIndex != null ? `Items ${+firstIndex + 1} and ${+secondIndex + 1} are repeated.` : "Field contains repeated items.",
|
|
5638
|
-
computedValueMismatch: "Value differs from the computed value.",
|
|
5639
|
-
validationFailed: (data) => process.env.NODE_ENV !== "production" ? data.exception : "Something went wrong validating this field. Please try again later."
|
|
5640
|
-
}
|
|
5641
|
-
},
|
|
5642
|
-
confirmUnloadMessage: "Are you sure you want to leave the page? Changes you made to the form may not have been saved."
|
|
5643
|
-
},
|
|
5644
|
-
FormPagesNavigation: {
|
|
5645
|
-
"aria-label": "Form pages"
|
|
5646
|
-
},
|
|
5647
|
-
FormPage: {
|
|
5648
|
-
helperButtonLabel: "Show help"
|
|
5649
|
-
},
|
|
5650
|
-
IssueMessages: {
|
|
5651
|
-
unknownErrorMessage: "Field with unknown error.",
|
|
5652
|
-
unknownWarningMessage: "Field with unknown warning."
|
|
5653
|
-
},
|
|
5654
|
-
IssuesPanel: {
|
|
5655
|
-
errorsLabel: (errors) => errors === void 0 ? "Errors" : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5656
|
-
errors,
|
|
5657
|
-
" ",
|
|
5658
|
-
errors === 1 ? "Error" : "Errors"
|
|
5659
|
-
] }),
|
|
5660
|
-
warningsLabel: (warnings) => warnings === void 0 ? "Warnings" : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5661
|
-
warnings,
|
|
5662
|
-
" ",
|
|
5663
|
-
warnings === 1 ? "Warning" : "Warnings"
|
|
5664
|
-
] }),
|
|
5665
|
-
focusButtonLabel: "Focus field",
|
|
5666
|
-
previousIssueButtonLabel: "Previous field with issues",
|
|
5667
|
-
nextIssueButtonLabel: "Next field with issues",
|
|
5668
|
-
firstIssueButtonLabel: "First field with issues",
|
|
5669
|
-
lastIssueButtonLabel: "Last field with issues",
|
|
5670
|
-
paginationLabel: (currentPage, totalPages) => `Field with issues ${currentPage} of ${totalPages}.`,
|
|
5671
|
-
noIssuesMessage: "No issues to report.",
|
|
5672
|
-
resolvedTitle: "Resolved",
|
|
5673
|
-
resolvedMessage: "Issues have been resolved. Please advance to the next field with issues."
|
|
5674
|
-
},
|
|
5675
|
-
IssuesPopover: {
|
|
5676
|
-
label: "Show issues"
|
|
5677
|
-
},
|
|
5678
|
-
LoadAction: {
|
|
5679
|
-
label: "Load",
|
|
5680
|
-
keybinds: "$mod+O",
|
|
5681
|
-
successMessage: (file) => `File “${file.name}” loaded successfully.`,
|
|
5682
|
-
errorMessage: (file) => file ? `Unable to load file “${file.name}”. Please confirm that the indicated file is a valid file of the form.` : "Unable to load the indicated file. Please confirm that you have the appropriate permissions to perform the operation."
|
|
5683
|
-
},
|
|
5684
|
-
SaveAction: {
|
|
5685
|
-
label: "Save",
|
|
5686
|
-
keybinds: "$mod+S",
|
|
5687
|
-
saveOptionsLabel: "Save options",
|
|
5688
|
-
saveAsLabel: "Save as…",
|
|
5689
|
-
saveAsKeybinds: "$mod+Shift+S",
|
|
5690
|
-
successMessage: (fileHandle) => `File “${fileHandle.name}” saved successfully.`,
|
|
5691
|
-
errorMessage: (fileHandle) => fileHandle ? `Unable to save file “${fileHandle.name}”. Please confirm that you have the appropriate permissions to perform the operation.` : "Unable to save the indicated file. Please confirm that you have the appropriate permissions to perform the operation."
|
|
5692
|
-
},
|
|
5693
|
-
SubmitAction: {
|
|
5694
|
-
label: "Submit",
|
|
5695
|
-
keybinds: "$mod+Enter",
|
|
5696
|
-
dialogTitle: "Submit form",
|
|
5697
|
-
dialogDescription: "Please confirm that you wish to proceed with the form submission.",
|
|
5698
|
-
dialogCancelText: "Cancel",
|
|
5699
|
-
confirmWarningsCheckboxLabel: "I declare that I have been informed of the warnings generated by the data in this form and that I wish to proceed without changing said data.",
|
|
5700
|
-
successMessage: () => "Form submitted successfully.",
|
|
5701
|
-
errorMessage: () => "Something went wrong while submitting the form. Please try again later."
|
|
5702
|
-
},
|
|
5703
|
-
TableControlAddRowTrigger: {
|
|
5704
|
-
defaultButtonText: "Add row"
|
|
5705
|
-
},
|
|
5706
|
-
TableControlRemoveRowTrigger: {
|
|
5707
|
-
defaultButtonLabel: "Remove row",
|
|
5708
|
-
confirmDialogTitle: "Remove row",
|
|
5709
|
-
confirmDialogMessage: (index) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5710
|
-
"Are you sure you want to remove line #",
|
|
5711
|
-
index + 1,
|
|
5712
|
-
"?"
|
|
5713
|
-
] }),
|
|
5714
|
-
confirmDialogOkText: "Remove"
|
|
5715
|
-
},
|
|
5716
|
-
ValidateAction: {
|
|
5717
|
-
label: "Validate",
|
|
5718
|
-
keybinds: "F7"
|
|
5719
|
-
}
|
|
5720
|
-
};
|
|
5721
|
-
const enGB = {
|
|
5722
|
-
...en,
|
|
5723
|
-
languageTag: "en-GB",
|
|
5724
|
-
uiLocale: enGB$1
|
|
5725
|
-
};
|
|
5726
|
-
const enUS = {
|
|
5727
|
-
...en,
|
|
5728
|
-
languageTag: "en-US",
|
|
5729
|
-
uiLocale: enUS$1
|
|
5730
|
-
};
|
|
5731
|
-
const frFR = {
|
|
5732
|
-
uiLocale: frFR$1,
|
|
5733
|
-
languageTag: "fr-FR",
|
|
5734
|
-
AnnexesManager: {
|
|
5735
|
-
"aria-label": "Annexes du formulaire",
|
|
5736
|
-
menuButtonText: "Annexes",
|
|
5737
|
-
addAnnexText: "Ajouter une annexe",
|
|
5738
|
-
removeAnnexButtonLabel: "Supprimer une annexe",
|
|
5739
|
-
removeAnnexKeyboardHint: "Appuyez sur la touche « Supprimer » pour supprimer la annexe",
|
|
5740
|
-
removeAnnexConfirmDialogTitle: "Supprimer la annexe",
|
|
5741
|
-
removeAnnexConfirmDialogMessage: (annexName) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5742
|
-
"Êtes-vous sûr de vouloir supprimer la annexe ",
|
|
5743
|
-
annexName,
|
|
5744
|
-
" ?"
|
|
5745
|
-
] }),
|
|
5746
|
-
removeAnnexConfirmDialogOkText: "Supprimer"
|
|
5747
|
-
},
|
|
5748
|
-
DateRangeControl: {
|
|
5749
|
-
issuesPanelStartLabelSuffix: " (date de début)",
|
|
5750
|
-
issuesPanelEndLabelSuffix: " (date de fin)"
|
|
5751
|
-
},
|
|
5752
|
-
FileControl: {
|
|
5753
|
-
viewFileButtonLabel: "Afficher le fichier",
|
|
5754
|
-
downloadFileButtonLabel: "Télécharger le fichier",
|
|
5755
|
-
fallbackText: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5756
|
-
"Le fichier sélectionné ne peut pas être affiché dans ce navigateur.",
|
|
5757
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
5758
|
-
"Veuillez utiliser le bouton ci-dessus pour télécharger le fichier. Vous pourrez ensuite l’ouvrir à l’aide d’une application externe."
|
|
5759
|
-
] })
|
|
5760
|
-
},
|
|
5761
|
-
FormApp: {
|
|
5762
|
-
issuesPanelLabel: "Formulaire",
|
|
5763
|
-
issueMessages: {
|
|
5764
|
-
"/**": {
|
|
5765
|
-
valueMissing: "Champ obligatoire.",
|
|
5766
|
-
valueDisallowed: "Valeur indiquée non autorisée.",
|
|
5767
|
-
rangeUnderflow: "Valeur inférieure au minimum autorisé.",
|
|
5768
|
-
rangeOverflow: "Valeur supérieure au maximum autorisé.",
|
|
5769
|
-
lengthMismatch: (_data, { typeInfo: { name, restrictions } }) => name === "String" && typeof restrictions.minLength === "number" && restrictions.minLength === restrictions.maxLength ? `La valeur doit comporter ${restrictions.minLength} ${restrictions.minLength === 1 ? "caractère" : "caractères"}.` : "La valeur a une longueur invalide.",
|
|
5770
|
-
tooShort: (_data, { typeInfo: { name, restrictions } }) => name === "String" && typeof restrictions.minLength === "number" ? `La valeur ne doit pas être inférieure à ${restrictions.minLength} ${restrictions.minLength === 1 ? "caractère" : "caractères"}.` : "Valeur trop courte.",
|
|
5771
|
-
tooLong: (_data, { typeInfo: { name, restrictions } }) => name === "String" && typeof restrictions.maxLength === "number" ? `La valeur ne doit pas dépasser ${restrictions.maxLength} ${restrictions.maxLength === 1 ? "caractère" : "caractères"}.` : "Valeur trop longue.",
|
|
5772
|
-
sizeMismatch: (_data, { typeInfo: { restrictions } }) => typeof restrictions.minSize === "number" && restrictions.minSize === restrictions.maxSize ? `Le champ doit contenir ${restrictions.minSize} ${restrictions.minSize === 1 ? "élément" : "éléments"}.` : "Le champ contient un nombre d’éléments non valide.",
|
|
5773
|
-
tooSmall: (_data, { typeInfo: { restrictions } }) => typeof restrictions.minLength === "number" ? `Le champ ne doit pas contenir moins de ${restrictions.minLength} ${restrictions.minLength === 1 ? "élément" : "éléments"}.` : "Le nombre d’éléments du champ n’est pas suffisant.",
|
|
5774
|
-
tooLarge: (_data, { typeInfo: { restrictions } }) => typeof restrictions.maxLength === "number" ? `Le champ ne doit pas contenir plus de ${restrictions.maxLength} ${restrictions.maxLength === 1 ? "élément" : "éléments"}.` : "Le nombre d’éléments du champ dépasse la limite autorisée.",
|
|
5775
|
-
scaleMismatch: (_data, { typeInfo: { restrictions } }) => typeof restrictions.scale === "number" ? `La valeur doit comporter ${restrictions.scale} ${restrictions.scale === 1 ? "décimale" : "décimales"}.` : "La valeur comporte un nombre invalide de décimales.",
|
|
5776
|
-
patternMismatch: "La valeur ne respecte pas le modèle requis.",
|
|
5777
|
-
emailPatternMismatch: "Adresse e-mail non valide.",
|
|
5778
|
-
fileTypeMismatch: (_data, { typeInfo: { restrictions } }) => Array.isArray(restrictions.acceptedFileTypes) ? `Seuls les types de fichiers suivants sont autorisés : ${restrictions.acceptedFileTypes.join(", ")}.` : "Le type de fichier indiqué n’est pas autorisé.",
|
|
5779
|
-
itemsRepeated: ({ firstIndex, secondIndex }) => firstIndex != null && secondIndex != null ? `Les éléments ${+firstIndex + 1} et ${+secondIndex + 1} sont répétés.` : "Le champ contient des éléments répétés.",
|
|
5780
|
-
computedValueMismatch: "La valeur diffère de la valeur calculée.",
|
|
5781
|
-
validationFailed: (data) => process.env.NODE_ENV !== "production" ? data.exception : "Une erreur s’est produite lors de la validation de ce champ. Veuillez réessayer plus tard."
|
|
5782
|
-
}
|
|
5783
|
-
},
|
|
5784
|
-
confirmUnloadMessage: "Êtes-tu sûr de vouloir quitter cette page ? Les modifications que tu as apportées au formulaire n’ont peut-être pas été enregistrées."
|
|
5785
|
-
},
|
|
5786
|
-
FormPagesNavigation: {
|
|
5787
|
-
"aria-label": "Pages du formulaire"
|
|
5788
|
-
},
|
|
5789
|
-
FormPage: {
|
|
5790
|
-
helperButtonLabel: "Afficher l’aide"
|
|
5791
|
-
},
|
|
5792
|
-
IssueMessages: {
|
|
5793
|
-
unknownErrorMessage: "Champ avec erreur inconnue.",
|
|
5794
|
-
unknownWarningMessage: "Champ avec alerte inconnue."
|
|
5795
|
-
},
|
|
5796
|
-
IssuesPanel: {
|
|
5797
|
-
errorsLabel: (errors) => errors === void 0 ? "Erreurs" : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5798
|
-
errors,
|
|
5799
|
-
" ",
|
|
5800
|
-
errors === 1 ? "Erreur" : "Erreurs"
|
|
5801
|
-
] }),
|
|
5802
|
-
warningsLabel: (warnings) => warnings === void 0 ? "Alertes" : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5803
|
-
warnings,
|
|
5804
|
-
" ",
|
|
5805
|
-
warnings === 1 ? "Alerte" : "Alertes"
|
|
5806
|
-
] }),
|
|
5807
|
-
focusButtonLabel: "Focaliser le champ",
|
|
5808
|
-
previousIssueButtonLabel: "Champ précédent avec problèmes",
|
|
5809
|
-
nextIssueButtonLabel: "Champ suivant avec problèmes",
|
|
5810
|
-
firstIssueButtonLabel: "Premier champ avec problèmes",
|
|
5811
|
-
lastIssueButtonLabel: "Dernier champ avec problèmes",
|
|
5812
|
-
paginationLabel: (currentPage, totalPages) => `Champ avec problèmes ${currentPage} sur ${totalPages}.`,
|
|
5813
|
-
noIssuesMessage: "Aucun problème à signaler.",
|
|
5814
|
-
resolvedTitle: "Résolu",
|
|
5815
|
-
resolvedMessage: "Les problèmes ont été résolus. Veuillez passer au champ suivant avec des problèmes."
|
|
5816
|
-
},
|
|
5817
|
-
IssuesPopover: {
|
|
5818
|
-
label: "Afficher les problèmes"
|
|
5819
|
-
},
|
|
5820
|
-
LoadAction: {
|
|
5821
|
-
label: "Ouvrir",
|
|
5822
|
-
keybinds: "$mod+O",
|
|
5823
|
-
successMessage: (file) => `Fichier « ${file.name} » chargé avec succès.`,
|
|
5824
|
-
errorMessage: (file) => file ? `Impossible de charger le fichier « ${file.name} ». Veuillez confirmer que le fichier indiqué est un fichier valide du formulaire.` : "Impossible d’ouvrir le fichier indiqué. Veuillez vérifier que vous disposez des autorisations nécessaires pour effectuer cette opération."
|
|
5825
|
-
},
|
|
5826
|
-
SaveAction: {
|
|
5827
|
-
label: "Enregistrer",
|
|
5828
|
-
keybinds: "$mod+S",
|
|
5829
|
-
saveOptionsLabel: "Options d’enregistrement",
|
|
5830
|
-
saveAsLabel: "Enregistrer sous…",
|
|
5831
|
-
saveAsKeybinds: "$mod+Shift+S",
|
|
5832
|
-
successMessage: (fileHandle) => `Fichier « ${fileHandle.name} » enregistré avec succès.`,
|
|
5833
|
-
errorMessage: (fileHandle) => fileHandle ? `Impossible d’enregistrer le fichier « ${fileHandle.name} ». Veuillez vérifier que vous disposez des autorisations nécessaires pour effectuer cette opération.` : "Impossible d’enregistrer le fichier indiqué. Veuillez vérifier que vous disposez des autorisations nécessaires pour effectuer cette opération."
|
|
5834
|
-
},
|
|
5835
|
-
SubmitAction: {
|
|
5836
|
-
label: "Déposer",
|
|
5837
|
-
keybinds: "$mod+Enter",
|
|
5838
|
-
dialogTitle: "Déposer la déclaration",
|
|
5839
|
-
dialogDescription: "Veuillez confirmer que vous souhaitez poursuivre le dépôt de la déclaration.",
|
|
5840
|
-
dialogCancelText: "Annuler",
|
|
5841
|
-
confirmWarningsCheckboxLabel: "Je déclare avoir pris connaissance des alertes générées par les données de cette déclaration et souhaiter continuer sans modifier les données correspondantes.",
|
|
5842
|
-
successMessage: () => "Déclaration déposée avec succès.",
|
|
5843
|
-
errorMessage: () => "Une erreur s’est produite lors du dépôt de la déclaration. Veuillez réessayer plus tard."
|
|
5844
|
-
},
|
|
5845
|
-
TableControlAddRowTrigger: {
|
|
5846
|
-
defaultButtonText: "Ajouter une ligne"
|
|
5847
|
-
},
|
|
5848
|
-
TableControlRemoveRowTrigger: {
|
|
5849
|
-
defaultButtonLabel: "Supprimer une ligne",
|
|
5850
|
-
confirmDialogTitle: "Supprimer une ligne",
|
|
5851
|
-
confirmDialogMessage: (index) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5852
|
-
"Êtes-vous sûr de vouloir supprimer la ligne #",
|
|
5853
|
-
index + 1,
|
|
5854
|
-
" ?"
|
|
5855
|
-
] }),
|
|
5856
|
-
confirmDialogOkText: "Supprimer"
|
|
5857
|
-
},
|
|
5858
|
-
ValidateAction: {
|
|
5859
|
-
label: "Valider",
|
|
5860
|
-
keybinds: "F7"
|
|
5861
|
-
}
|
|
5862
|
-
};
|
|
5863
|
-
const CheckboxControl = React.forwardRef(function CheckboxControl2({
|
|
5498
|
+
const LocalizationContext = createContext(null);
|
|
5499
|
+
function LocalizationProvider({
|
|
5500
|
+
defaultLocale,
|
|
5501
|
+
locale: controlledLocale,
|
|
5502
|
+
onLocaleChange,
|
|
5503
|
+
children
|
|
5504
|
+
}) {
|
|
5505
|
+
const [locale, setLocale] = useControllableState(
|
|
5506
|
+
defaultLocale,
|
|
5507
|
+
controlledLocale
|
|
5508
|
+
);
|
|
5509
|
+
return locale === void 0 ? children : /* @__PURE__ */ jsx(
|
|
5510
|
+
LocalizationContext.Provider,
|
|
5511
|
+
{
|
|
5512
|
+
value: {
|
|
5513
|
+
locale,
|
|
5514
|
+
setLocale: combineEventHandlers(setLocale, onLocaleChange)
|
|
5515
|
+
},
|
|
5516
|
+
children: /* @__PURE__ */ jsx(LocalizationProvider$1, { locale: locale.baseLocale, children })
|
|
5517
|
+
}
|
|
5518
|
+
);
|
|
5519
|
+
}
|
|
5520
|
+
function useLocale() {
|
|
5521
|
+
const localizationContext = useContext(LocalizationContext);
|
|
5522
|
+
if (localizationContext === null)
|
|
5523
|
+
throw new Error(
|
|
5524
|
+
"No locale has been provided. Please provide a locale via the `FormApp` or `LocalizationProvider` components."
|
|
5525
|
+
);
|
|
5526
|
+
return useMemo(
|
|
5527
|
+
() => [localizationContext.locale, localizationContext.setLocale],
|
|
5528
|
+
[localizationContext.locale, localizationContext.setLocale]
|
|
5529
|
+
);
|
|
5530
|
+
}
|
|
5531
|
+
const CheckboxControl = forwardRef(function CheckboxControl2({
|
|
5864
5532
|
path,
|
|
5865
5533
|
issueMessages,
|
|
5866
5534
|
issuesPanelLabel,
|
|
@@ -5885,7 +5553,7 @@ const CheckboxControl = React.forwardRef(function CheckboxControl2({
|
|
|
5885
5553
|
onBlurToOutside,
|
|
5886
5554
|
...otherProps
|
|
5887
5555
|
}, forwardedRef) {
|
|
5888
|
-
const [formattedValue, setFormattedValue] =
|
|
5556
|
+
const [formattedValue, setFormattedValue] = useState(false);
|
|
5889
5557
|
const controller = useInput(path, {
|
|
5890
5558
|
enabled: !useFormIsLoading(),
|
|
5891
5559
|
parse: parseCheckboxValue,
|
|
@@ -6005,16 +5673,60 @@ function optionObjectsToNodes(options) {
|
|
|
6005
5673
|
) }, key ?? i) : /* @__PURE__ */ jsx(Option, { ...optionOrGroup, value: optionIndex++, children: optionOrGroup.text ?? optionOrGroup.value?.toString() ?? "" }, key ?? i)
|
|
6006
5674
|
);
|
|
6007
5675
|
}
|
|
6008
|
-
const CheckboxGroupControl =
|
|
6009
|
-
|
|
6010
|
-
|
|
6011
|
-
|
|
6012
|
-
|
|
6013
|
-
|
|
6014
|
-
|
|
6015
|
-
|
|
6016
|
-
|
|
6017
|
-
|
|
5676
|
+
const CheckboxGroupControl = forwardRef(function CheckboxGroupControl2({
|
|
5677
|
+
path,
|
|
5678
|
+
options,
|
|
5679
|
+
issueMessages,
|
|
5680
|
+
issuesPanelLabel,
|
|
5681
|
+
displayIssues = true,
|
|
5682
|
+
preventAutoFocus,
|
|
5683
|
+
apiRef,
|
|
5684
|
+
issueMessagesProps,
|
|
5685
|
+
formManager,
|
|
5686
|
+
onInitialized,
|
|
5687
|
+
onFormManagerEvent,
|
|
5688
|
+
onValueChange,
|
|
5689
|
+
onValidationStatusChange,
|
|
5690
|
+
onDisplayStatusChange,
|
|
5691
|
+
onDirtyStatusChange,
|
|
5692
|
+
onTouchedStatusChange,
|
|
5693
|
+
required,
|
|
5694
|
+
loading,
|
|
5695
|
+
disabled,
|
|
5696
|
+
readOnly,
|
|
5697
|
+
onFocus,
|
|
5698
|
+
onBlurToOutside,
|
|
5699
|
+
...otherProps
|
|
5700
|
+
}, forwardedRef) {
|
|
5701
|
+
const [arrayValue, setArrayValue] = useState(null);
|
|
5702
|
+
const formattedValue = useMemo(
|
|
5703
|
+
() => formatSelectionValuesAsOptionIndices(arrayValue, options),
|
|
5704
|
+
[options, arrayValue]
|
|
5705
|
+
);
|
|
5706
|
+
const controller = useListableInput(path, {
|
|
5707
|
+
enabled: !useFormIsLoading(),
|
|
5708
|
+
parseToArray: useCallback(
|
|
5709
|
+
(formattedValue2, state) => parseSelectionValuesFromOptionIndices(
|
|
5710
|
+
formattedValue2,
|
|
5711
|
+
state.schema,
|
|
5712
|
+
options
|
|
5713
|
+
),
|
|
5714
|
+
[options]
|
|
5715
|
+
),
|
|
5716
|
+
formatFromArray: useCallback(
|
|
5717
|
+
(arrayValue2) => formatSelectionValuesAsOptionIndices(arrayValue2, options),
|
|
5718
|
+
[options]
|
|
5719
|
+
),
|
|
5720
|
+
setFormattedValue: useCallback(
|
|
5721
|
+
(formattedValue2, state) => setArrayValue(
|
|
5722
|
+
parseSelectionValuesFromOptionIndices(
|
|
5723
|
+
formattedValue2,
|
|
5724
|
+
state.schema,
|
|
5725
|
+
options
|
|
5726
|
+
)
|
|
5727
|
+
),
|
|
5728
|
+
[options]
|
|
5729
|
+
),
|
|
6018
5730
|
formManager,
|
|
6019
5731
|
onInitialized,
|
|
6020
5732
|
onFormManagerEvent,
|
|
@@ -6022,125 +5734,79 @@ const CheckboxGroupControl = React.forwardRef(
|
|
|
6022
5734
|
onValidationStatusChange,
|
|
6023
5735
|
onDisplayStatusChange,
|
|
6024
5736
|
onDirtyStatusChange,
|
|
6025
|
-
onTouchedStatusChange
|
|
6026
|
-
|
|
6027
|
-
|
|
6028
|
-
|
|
6029
|
-
|
|
6030
|
-
|
|
6031
|
-
|
|
6032
|
-
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
|
|
6044
|
-
|
|
6045
|
-
|
|
5737
|
+
onTouchedStatusChange
|
|
5738
|
+
});
|
|
5739
|
+
const { getState, useSchema, usePath, inputProps } = controller;
|
|
5740
|
+
const { restrictions } = useSchema().typeInfo;
|
|
5741
|
+
const absolutePath = usePath();
|
|
5742
|
+
const {
|
|
5743
|
+
displayLoading,
|
|
5744
|
+
displayDisabled,
|
|
5745
|
+
displayReadOnly,
|
|
5746
|
+
displayStatusToDisplay,
|
|
5747
|
+
issuesToDisplay,
|
|
5748
|
+
autofocusRef,
|
|
5749
|
+
handleFocus
|
|
5750
|
+
} = useRegisterControl({
|
|
5751
|
+
controller,
|
|
5752
|
+
issuesPanelLabel,
|
|
5753
|
+
ariaLabel: otherProps["aria-label"],
|
|
5754
|
+
preventAutoFocus,
|
|
5755
|
+
apiRef
|
|
5756
|
+
});
|
|
5757
|
+
const handleValueChange = useCallback(
|
|
5758
|
+
(formattedValue2) => setArrayValue(
|
|
5759
|
+
parseSelectionValuesFromOptionIndices(
|
|
5760
|
+
formattedValue2,
|
|
5761
|
+
getState().schema,
|
|
5762
|
+
options
|
|
5763
|
+
)
|
|
5764
|
+
),
|
|
5765
|
+
[getState, options]
|
|
5766
|
+
);
|
|
5767
|
+
const [inlineIssues, popoverIssues] = useControlIssues({
|
|
5768
|
+
issuesToDisplay: {
|
|
5769
|
+
[absolutePath.toString()]: issuesToDisplay
|
|
5770
|
+
},
|
|
5771
|
+
issueMessages: { [absolutePath.toString()]: issueMessages },
|
|
5772
|
+
displayIssues,
|
|
5773
|
+
issueMessagesProps
|
|
5774
|
+
});
|
|
5775
|
+
const combinedCheckboxGroupRef = useCombinedRef(
|
|
5776
|
+
inputProps.ref,
|
|
5777
|
+
autofocusRef,
|
|
5778
|
+
forwardedRef
|
|
5779
|
+
);
|
|
5780
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5781
|
+
/* @__PURE__ */ jsx(
|
|
5782
|
+
CheckboxGroup,
|
|
5783
|
+
{
|
|
5784
|
+
value: formattedValue,
|
|
5785
|
+
name: inputProps.name,
|
|
5786
|
+
required: required ?? restrictions.required === true,
|
|
5787
|
+
loading: displayLoading || loading,
|
|
5788
|
+
disabled: displayDisabled || disabled,
|
|
5789
|
+
readOnly: displayReadOnly || readOnly || inputProps.readOnly,
|
|
5790
|
+
status: displayStatusToControlStatus(displayStatusToDisplay),
|
|
5791
|
+
onValueChange: combineEventHandlers(
|
|
5792
|
+
inputProps.onChange,
|
|
5793
|
+
handleValueChange
|
|
6046
5794
|
),
|
|
6047
|
-
|
|
6048
|
-
|
|
6049
|
-
|
|
6050
|
-
|
|
6051
|
-
[options]
|
|
6052
|
-
),
|
|
6053
|
-
setFormattedValue: React.useCallback(
|
|
6054
|
-
(formattedValue2, state) => setArrayValue(
|
|
6055
|
-
parseSelectionValuesFromOptionIndices(
|
|
6056
|
-
formattedValue2,
|
|
6057
|
-
state.schema,
|
|
6058
|
-
options
|
|
6059
|
-
)
|
|
5795
|
+
onFocus: combineEventHandlers(onFocus, handleFocus),
|
|
5796
|
+
onBlurToOutside: combineEventHandlers(
|
|
5797
|
+
onBlurToOutside,
|
|
5798
|
+
inputProps.onBlur
|
|
6060
5799
|
),
|
|
6061
|
-
|
|
6062
|
-
|
|
6063
|
-
|
|
6064
|
-
|
|
6065
|
-
|
|
6066
|
-
|
|
6067
|
-
|
|
6068
|
-
|
|
6069
|
-
|
|
6070
|
-
|
|
6071
|
-
});
|
|
6072
|
-
const { getState, useSchema, usePath, inputProps } = controller;
|
|
6073
|
-
const { restrictions } = useSchema().typeInfo;
|
|
6074
|
-
const absolutePath = usePath();
|
|
6075
|
-
const {
|
|
6076
|
-
displayLoading,
|
|
6077
|
-
displayDisabled,
|
|
6078
|
-
displayReadOnly,
|
|
6079
|
-
displayStatusToDisplay,
|
|
6080
|
-
issuesToDisplay,
|
|
6081
|
-
autofocusRef,
|
|
6082
|
-
handleFocus
|
|
6083
|
-
} = useRegisterControl({
|
|
6084
|
-
controller,
|
|
6085
|
-
issuesPanelLabel,
|
|
6086
|
-
ariaLabel: otherProps["aria-label"],
|
|
6087
|
-
preventAutoFocus,
|
|
6088
|
-
apiRef
|
|
6089
|
-
});
|
|
6090
|
-
const handleValueChange = React.useCallback(
|
|
6091
|
-
(formattedValue2) => setArrayValue(
|
|
6092
|
-
parseSelectionValuesFromOptionIndices(
|
|
6093
|
-
formattedValue2,
|
|
6094
|
-
getState().schema,
|
|
6095
|
-
options
|
|
6096
|
-
)
|
|
6097
|
-
),
|
|
6098
|
-
[getState, options]
|
|
6099
|
-
);
|
|
6100
|
-
const [inlineIssues, popoverIssues] = useControlIssues({
|
|
6101
|
-
issuesToDisplay: {
|
|
6102
|
-
[absolutePath.toString()]: issuesToDisplay
|
|
6103
|
-
},
|
|
6104
|
-
issueMessages: { [absolutePath.toString()]: issueMessages },
|
|
6105
|
-
displayIssues,
|
|
6106
|
-
issueMessagesProps
|
|
6107
|
-
});
|
|
6108
|
-
const combinedCheckboxGroupRef = useCombinedRef(
|
|
6109
|
-
inputProps.ref,
|
|
6110
|
-
autofocusRef,
|
|
6111
|
-
forwardedRef
|
|
6112
|
-
);
|
|
6113
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6114
|
-
/* @__PURE__ */ jsx(
|
|
6115
|
-
CheckboxGroup,
|
|
6116
|
-
{
|
|
6117
|
-
value: formattedValue,
|
|
6118
|
-
name: inputProps.name,
|
|
6119
|
-
required: required ?? restrictions.required === true,
|
|
6120
|
-
loading: displayLoading || loading,
|
|
6121
|
-
disabled: displayDisabled || disabled,
|
|
6122
|
-
readOnly: displayReadOnly || readOnly || inputProps.readOnly,
|
|
6123
|
-
status: displayStatusToControlStatus(displayStatusToDisplay),
|
|
6124
|
-
onValueChange: combineEventHandlers(
|
|
6125
|
-
inputProps.onChange,
|
|
6126
|
-
handleValueChange
|
|
6127
|
-
),
|
|
6128
|
-
onFocus: combineEventHandlers(onFocus, handleFocus),
|
|
6129
|
-
onBlurToOutside: combineEventHandlers(
|
|
6130
|
-
onBlurToOutside,
|
|
6131
|
-
inputProps.onBlur
|
|
6132
|
-
),
|
|
6133
|
-
...otherProps,
|
|
6134
|
-
ref: combinedCheckboxGroupRef,
|
|
6135
|
-
children: options.map(({ value, text, key, ...checkboxProps }, i) => /* @__PURE__ */ jsx(Checkbox, { value: i, ...checkboxProps, children: text ?? value?.toString() ?? "" }, key ?? i))
|
|
6136
|
-
}
|
|
6137
|
-
),
|
|
6138
|
-
inlineIssues,
|
|
6139
|
-
popoverIssues
|
|
6140
|
-
] });
|
|
6141
|
-
}
|
|
6142
|
-
);
|
|
6143
|
-
const DateControl = React.forwardRef(function DateControl2({
|
|
5800
|
+
...otherProps,
|
|
5801
|
+
ref: combinedCheckboxGroupRef,
|
|
5802
|
+
children: options.map(({ value, text, key, ...checkboxProps }, i) => /* @__PURE__ */ jsx(Checkbox, { value: i, ...checkboxProps, children: text ?? value?.toString() ?? "" }, key ?? i))
|
|
5803
|
+
}
|
|
5804
|
+
),
|
|
5805
|
+
inlineIssues,
|
|
5806
|
+
popoverIssues
|
|
5807
|
+
] });
|
|
5808
|
+
});
|
|
5809
|
+
const DateControl = forwardRef(function DateControl2({
|
|
6144
5810
|
path,
|
|
6145
5811
|
issueMessages,
|
|
6146
5812
|
issuesPanelLabel,
|
|
@@ -6175,14 +5841,14 @@ const DateControl = React.forwardRef(function DateControl2({
|
|
|
6175
5841
|
shortFormat,
|
|
6176
5842
|
fullFormat
|
|
6177
5843
|
});
|
|
6178
|
-
const [formattedValue, setFormattedValue] =
|
|
5844
|
+
const [formattedValue, setFormattedValue] = useState("");
|
|
6179
5845
|
const controller = useTemporalInput(path, {
|
|
6180
5846
|
enabled: !useFormIsLoading(),
|
|
6181
|
-
parseToString:
|
|
5847
|
+
parseToString: useCallback(
|
|
6182
5848
|
(formattedValue2, state) => parse(formattedValue2, state.schema),
|
|
6183
5849
|
[parse]
|
|
6184
5850
|
),
|
|
6185
|
-
formatFromString:
|
|
5851
|
+
formatFromString: useCallback(
|
|
6186
5852
|
(temporalString, state) => format2(temporalString, state.schema),
|
|
6187
5853
|
[format2]
|
|
6188
5854
|
),
|
|
@@ -6215,7 +5881,7 @@ const DateControl = React.forwardRef(function DateControl2({
|
|
|
6215
5881
|
preventAutoFocus,
|
|
6216
5882
|
apiRef
|
|
6217
5883
|
});
|
|
6218
|
-
const handleValueChange =
|
|
5884
|
+
const handleValueChange = useCallback(
|
|
6219
5885
|
({ formattedValue: formattedValue2 }) => {
|
|
6220
5886
|
setFormattedValue(formattedValue2);
|
|
6221
5887
|
inputProps.onChange(formattedValue2);
|
|
@@ -6268,7 +5934,7 @@ const DateControl = React.forwardRef(function DateControl2({
|
|
|
6268
5934
|
inlineIssues
|
|
6269
5935
|
] });
|
|
6270
5936
|
});
|
|
6271
|
-
const FormStepper =
|
|
5937
|
+
const FormStepper = forwardRef(function FormStepper2({
|
|
6272
5938
|
path,
|
|
6273
5939
|
steps,
|
|
6274
5940
|
defaultActiveStep,
|
|
@@ -6284,7 +5950,7 @@ const FormStepper = React.forwardRef(function FormStepper2({
|
|
|
6284
5950
|
const prefix = usePrefix();
|
|
6285
5951
|
const formManager = useFormManager();
|
|
6286
5952
|
const absolutePath = useResolvedPath(path);
|
|
6287
|
-
const resolvedSteps =
|
|
5953
|
+
const resolvedSteps = useMemo(
|
|
6288
5954
|
() => steps.map((step, i) => ({
|
|
6289
5955
|
...step,
|
|
6290
5956
|
index: i,
|
|
@@ -6351,13 +6017,11 @@ function FormStepRegistrar({
|
|
|
6351
6017
|
const exists = controller.useState(
|
|
6352
6018
|
(state) => state.initialized && state.exists
|
|
6353
6019
|
);
|
|
6354
|
-
const deferredValue =
|
|
6355
|
-
const deferredDisplayStatus =
|
|
6356
|
-
controller.useDisplayStatus()
|
|
6357
|
-
);
|
|
6020
|
+
const deferredValue = useDeferredValue(controller.useValue());
|
|
6021
|
+
const deferredDisplayStatus = useDeferredValue(controller.useDisplayStatus());
|
|
6358
6022
|
const actualTitle = typeof title === "function" ? deferredValue === void 0 ? null : title(deferredValue) : title;
|
|
6359
6023
|
const actualDocumentTitle = typeof documentTitle === "function" ? deferredValue === void 0 ? null : documentTitle(deferredValue) : documentTitle === void 0 ? actualTitle === null || typeof actualTitle === "string" ? actualTitle : void 0 : documentTitle;
|
|
6360
|
-
|
|
6024
|
+
useEffect(() => {
|
|
6361
6025
|
const { registerStepState } = store.getState().actions;
|
|
6362
6026
|
registerStepState(absolutePath, {
|
|
6363
6027
|
exists,
|
|
@@ -6384,7 +6048,9 @@ function FormStepRegistrar({
|
|
|
6384
6048
|
);
|
|
6385
6049
|
return null;
|
|
6386
6050
|
}
|
|
6387
|
-
const FormStepperContext =
|
|
6051
|
+
const FormStepperContext = createContext(
|
|
6052
|
+
null
|
|
6053
|
+
);
|
|
6388
6054
|
function useCreateFormStepperContext({
|
|
6389
6055
|
formManager,
|
|
6390
6056
|
basePath,
|
|
@@ -6435,7 +6101,7 @@ function useCreateFormStepperContext({
|
|
|
6435
6101
|
setActiveStep: (step, callListener = true) => {
|
|
6436
6102
|
const oldActiveStep = get().activeStep;
|
|
6437
6103
|
if (!oldActiveStep?.path.equals(step?.path) || oldActiveStep?.index !== step?.index) {
|
|
6438
|
-
|
|
6104
|
+
startTransition(() => {
|
|
6439
6105
|
set({ activeStep: step });
|
|
6440
6106
|
if (step != null) {
|
|
6441
6107
|
setActivePath(step.path);
|
|
@@ -6513,7 +6179,7 @@ function useCreateFormStepperContext({
|
|
|
6513
6179
|
}))
|
|
6514
6180
|
)
|
|
6515
6181
|
);
|
|
6516
|
-
|
|
6182
|
+
useEffect(() => {
|
|
6517
6183
|
store.getState().actions.setSteps(resolvedSteps);
|
|
6518
6184
|
if (activeStep !== void 0) {
|
|
6519
6185
|
const { steps, activeStep: oldActiveStep } = store.getState();
|
|
@@ -6529,7 +6195,7 @@ function useCreateFormStepperContext({
|
|
|
6529
6195
|
}
|
|
6530
6196
|
}, [resolvedSteps, activeStep, basePath, store]);
|
|
6531
6197
|
useOnPathFocus(
|
|
6532
|
-
|
|
6198
|
+
useCallback(
|
|
6533
6199
|
(focusedPath) => {
|
|
6534
6200
|
const { steps, activeStep: activeStep2, actions } = store.getState();
|
|
6535
6201
|
const specificPath = mostSpecificPath(
|
|
@@ -6547,7 +6213,7 @@ function useCreateFormStepperContext({
|
|
|
6547
6213
|
return store;
|
|
6548
6214
|
}
|
|
6549
6215
|
function useFormStepperContext() {
|
|
6550
|
-
const formStepperContext =
|
|
6216
|
+
const formStepperContext = useContext(FormStepperContext);
|
|
6551
6217
|
if (!formStepperContext) {
|
|
6552
6218
|
throw new Error("Form stepper context not in scope.");
|
|
6553
6219
|
}
|
|
@@ -6559,7 +6225,7 @@ function useFormStepState(path, selector) {
|
|
|
6559
6225
|
(state) => selector(state.actions.getStepState(path))
|
|
6560
6226
|
);
|
|
6561
6227
|
}
|
|
6562
|
-
const FormStepContent =
|
|
6228
|
+
const FormStepContent = forwardRef(function FormStepContent2({
|
|
6563
6229
|
path,
|
|
6564
6230
|
disabled = false,
|
|
6565
6231
|
readOnly = false,
|
|
@@ -6610,7 +6276,7 @@ function FormStep({ path, index }) {
|
|
|
6610
6276
|
}
|
|
6611
6277
|
);
|
|
6612
6278
|
}
|
|
6613
|
-
const FormStepList =
|
|
6279
|
+
const FormStepList = forwardRef(function FormStepperSidebar({ className, ...otherProps }, forwardedRef) {
|
|
6614
6280
|
const prefix = usePrefix();
|
|
6615
6281
|
const steps = useStore(useFormStepperContext(), (state) => state.steps);
|
|
6616
6282
|
return /* @__PURE__ */ jsx(
|
|
@@ -6630,7 +6296,7 @@ const FormStepList = React.forwardRef(function FormStepperSidebar({ className, .
|
|
|
6630
6296
|
}
|
|
6631
6297
|
);
|
|
6632
6298
|
});
|
|
6633
|
-
const IssueAlert =
|
|
6299
|
+
const IssueAlert = forwardRef(function IssueMessage2({ path, code, children, ...otherProps }, forwardedRef) {
|
|
6634
6300
|
const { info } = useIssuesTracker(path);
|
|
6635
6301
|
const relevantIssues = (info?.flatMap((info2) => info2.issues) ?? []).filter(
|
|
6636
6302
|
(issue) => issue.code === code
|
|
@@ -6647,7 +6313,7 @@ const IssueAlert = React.forwardRef(function IssueMessage2({ path, code, childre
|
|
|
6647
6313
|
)) });
|
|
6648
6314
|
});
|
|
6649
6315
|
const INTEGER_TYPES = ["Byte", "Char", "Short", "Int", "Long", "BigInteger"];
|
|
6650
|
-
const NumericControl =
|
|
6316
|
+
const NumericControl = forwardRef(function NumericControl2({
|
|
6651
6317
|
path,
|
|
6652
6318
|
issueMessages,
|
|
6653
6319
|
issuesPanelLabel,
|
|
@@ -6678,7 +6344,7 @@ const NumericControl = React.forwardRef(function NumericControl2({
|
|
|
6678
6344
|
onBlurToOutside,
|
|
6679
6345
|
...otherProps
|
|
6680
6346
|
}, forwardedRef) {
|
|
6681
|
-
const [stringValue, setStringValue] =
|
|
6347
|
+
const [stringValue, setStringValue] = useState("");
|
|
6682
6348
|
const controller = useNumericInput(path, {
|
|
6683
6349
|
enabled: !useFormIsLoading(),
|
|
6684
6350
|
setFormattedValue: setStringValue,
|
|
@@ -6710,9 +6376,9 @@ const NumericControl = React.forwardRef(function NumericControl2({
|
|
|
6710
6376
|
preventAutoFocus,
|
|
6711
6377
|
apiRef
|
|
6712
6378
|
});
|
|
6713
|
-
const latestStringValueRef =
|
|
6379
|
+
const latestStringValueRef = useRef(stringValue);
|
|
6714
6380
|
latestStringValueRef.current = stringValue;
|
|
6715
|
-
const handleValueChange =
|
|
6381
|
+
const handleValueChange = useCallback(
|
|
6716
6382
|
({ stringValue: stringValue2 }) => {
|
|
6717
6383
|
if (stringValue2 !== latestStringValueRef.current) {
|
|
6718
6384
|
inputProps.onChange(stringValue2);
|
|
@@ -6799,7 +6465,7 @@ function PathLink({
|
|
|
6799
6465
|
}
|
|
6800
6466
|
);
|
|
6801
6467
|
}
|
|
6802
|
-
const RadioGroupControl =
|
|
6468
|
+
const RadioGroupControl = forwardRef(function RadioGroupControl2({
|
|
6803
6469
|
path,
|
|
6804
6470
|
options,
|
|
6805
6471
|
issueMessages,
|
|
@@ -6825,8 +6491,8 @@ const RadioGroupControl = React.forwardRef(function RadioGroupControl2({
|
|
|
6825
6491
|
onBlurToOutside,
|
|
6826
6492
|
...otherProps
|
|
6827
6493
|
}, forwardedRef) {
|
|
6828
|
-
const [value, setValue] =
|
|
6829
|
-
const formattedValue =
|
|
6494
|
+
const [value, setValue] = useState();
|
|
6495
|
+
const formattedValue = useMemo(
|
|
6830
6496
|
() => formatSelectionValueAsOptionIndex(value, options),
|
|
6831
6497
|
[options, value]
|
|
6832
6498
|
);
|
|
@@ -6834,7 +6500,7 @@ const RadioGroupControl = React.forwardRef(function RadioGroupControl2({
|
|
|
6834
6500
|
path,
|
|
6835
6501
|
{
|
|
6836
6502
|
enabled: !useFormIsLoading(),
|
|
6837
|
-
parse:
|
|
6503
|
+
parse: useCallback(
|
|
6838
6504
|
(formattedValue2, state) => parseSelectionValueFromOptionIndex(
|
|
6839
6505
|
formattedValue2,
|
|
6840
6506
|
state.schema,
|
|
@@ -6842,11 +6508,11 @@ const RadioGroupControl = React.forwardRef(function RadioGroupControl2({
|
|
|
6842
6508
|
),
|
|
6843
6509
|
[options]
|
|
6844
6510
|
),
|
|
6845
|
-
format:
|
|
6511
|
+
format: useCallback(
|
|
6846
6512
|
(value2) => formatSelectionValueAsOptionIndex(value2, options),
|
|
6847
6513
|
[options]
|
|
6848
6514
|
),
|
|
6849
|
-
setFormattedValue:
|
|
6515
|
+
setFormattedValue: useCallback(
|
|
6850
6516
|
(formattedValue2, state) => setValue(
|
|
6851
6517
|
parseSelectionValueFromOptionIndex(
|
|
6852
6518
|
formattedValue2,
|
|
@@ -6885,14 +6551,14 @@ const RadioGroupControl = React.forwardRef(function RadioGroupControl2({
|
|
|
6885
6551
|
preventAutoFocus,
|
|
6886
6552
|
apiRef
|
|
6887
6553
|
});
|
|
6888
|
-
const handleValueChange =
|
|
6554
|
+
const handleValueChange = useCallback(
|
|
6889
6555
|
(formattedValue2) => setValue(
|
|
6890
6556
|
parseSelectionValueFromOptionIndex(formattedValue2, schema, options)
|
|
6891
6557
|
),
|
|
6892
6558
|
[options, schema]
|
|
6893
6559
|
);
|
|
6894
6560
|
const clearedValue = nullable ? null : schema.initialValue;
|
|
6895
|
-
const clearedIdx =
|
|
6561
|
+
const clearedIdx = useMemo(
|
|
6896
6562
|
() => options.findIndex((option) => equals(option.value, clearedValue)),
|
|
6897
6563
|
[clearedValue, options]
|
|
6898
6564
|
);
|
|
@@ -6940,7 +6606,7 @@ const RadioGroupControl = React.forwardRef(function RadioGroupControl2({
|
|
|
6940
6606
|
popoverIssues
|
|
6941
6607
|
] });
|
|
6942
6608
|
});
|
|
6943
|
-
const SelectControl =
|
|
6609
|
+
const SelectControl = forwardRef(function SelectControl2({
|
|
6944
6610
|
path,
|
|
6945
6611
|
options: groupedOptions,
|
|
6946
6612
|
issueMessages,
|
|
@@ -6967,7 +6633,7 @@ const SelectControl = React.forwardRef(function SelectControl2({
|
|
|
6967
6633
|
onBlurToOutside,
|
|
6968
6634
|
...otherProps
|
|
6969
6635
|
}, forwardedRef) {
|
|
6970
|
-
const options =
|
|
6636
|
+
const options = useMemo(
|
|
6971
6637
|
() => groupedOptions.reduce((options2, optionOrGroup) => {
|
|
6972
6638
|
if ("options" in optionOrGroup) {
|
|
6973
6639
|
options2.push(...optionOrGroup.options);
|
|
@@ -6978,47 +6644,44 @@ const SelectControl = React.forwardRef(function SelectControl2({
|
|
|
6978
6644
|
}, []),
|
|
6979
6645
|
[groupedOptions]
|
|
6980
6646
|
);
|
|
6981
|
-
const [value, setValue] =
|
|
6982
|
-
const formattedValue =
|
|
6647
|
+
const [value, setValue] = useState();
|
|
6648
|
+
const formattedValue = useMemo(
|
|
6983
6649
|
() => formatSelectionValueAsOptionIndex(value, options),
|
|
6984
6650
|
[options, value]
|
|
6985
6651
|
);
|
|
6986
|
-
const controller = useInput(
|
|
6987
|
-
|
|
6988
|
-
|
|
6989
|
-
|
|
6990
|
-
|
|
6991
|
-
|
|
6652
|
+
const controller = useInput(path, {
|
|
6653
|
+
enabled: !useFormIsLoading(),
|
|
6654
|
+
parse: useCallback(
|
|
6655
|
+
(formattedValue2, state) => parseSelectionValueFromOptionIndex(
|
|
6656
|
+
formattedValue2,
|
|
6657
|
+
state.schema,
|
|
6658
|
+
options
|
|
6659
|
+
),
|
|
6660
|
+
[options]
|
|
6661
|
+
),
|
|
6662
|
+
format: useCallback(
|
|
6663
|
+
(value2) => formatSelectionValueAsOptionIndex(value2, options),
|
|
6664
|
+
[options]
|
|
6665
|
+
),
|
|
6666
|
+
setFormattedValue: useCallback(
|
|
6667
|
+
(formattedValue2, state) => setValue(
|
|
6668
|
+
parseSelectionValueFromOptionIndex(
|
|
6992
6669
|
formattedValue2,
|
|
6993
6670
|
state.schema,
|
|
6994
6671
|
options
|
|
6995
|
-
)
|
|
6996
|
-
[options]
|
|
6997
|
-
),
|
|
6998
|
-
format: React.useCallback(
|
|
6999
|
-
(value2) => formatSelectionValueAsOptionIndex(value2, options),
|
|
7000
|
-
[options]
|
|
7001
|
-
),
|
|
7002
|
-
setFormattedValue: React.useCallback(
|
|
7003
|
-
(formattedValue2, state) => setValue(
|
|
7004
|
-
parseSelectionValueFromOptionIndex(
|
|
7005
|
-
formattedValue2,
|
|
7006
|
-
state.schema,
|
|
7007
|
-
options
|
|
7008
|
-
)
|
|
7009
|
-
),
|
|
7010
|
-
[options]
|
|
6672
|
+
)
|
|
7011
6673
|
),
|
|
7012
|
-
|
|
7013
|
-
|
|
7014
|
-
|
|
7015
|
-
|
|
7016
|
-
|
|
7017
|
-
|
|
7018
|
-
|
|
7019
|
-
|
|
7020
|
-
|
|
7021
|
-
|
|
6674
|
+
[options]
|
|
6675
|
+
),
|
|
6676
|
+
formManager,
|
|
6677
|
+
onInitialized,
|
|
6678
|
+
onFormManagerEvent,
|
|
6679
|
+
onValueChange,
|
|
6680
|
+
onValidationStatusChange,
|
|
6681
|
+
onDisplayStatusChange,
|
|
6682
|
+
onDirtyStatusChange,
|
|
6683
|
+
onTouchedStatusChange
|
|
6684
|
+
});
|
|
7022
6685
|
const { getState, useSchema, usePath, inputProps } = controller;
|
|
7023
6686
|
const schema = useSchema();
|
|
7024
6687
|
const absolutePath = usePath();
|
|
@@ -7038,7 +6701,7 @@ const SelectControl = React.forwardRef(function SelectControl2({
|
|
|
7038
6701
|
preventAutoFocus,
|
|
7039
6702
|
apiRef
|
|
7040
6703
|
});
|
|
7041
|
-
const handleValueChange =
|
|
6704
|
+
const handleValueChange = useCallback(
|
|
7042
6705
|
(formattedValue2) => setValue(
|
|
7043
6706
|
parseSelectionValueFromOptionIndex(
|
|
7044
6707
|
formattedValue2,
|
|
@@ -7050,12 +6713,12 @@ const SelectControl = React.forwardRef(function SelectControl2({
|
|
|
7050
6713
|
);
|
|
7051
6714
|
showClearButton ??= nullable ? "auto" : false;
|
|
7052
6715
|
const clearedValue = nullable ? null : schema.initialValue;
|
|
7053
|
-
const clearedIdx =
|
|
6716
|
+
const clearedIdx = useMemo(
|
|
7054
6717
|
() => options.findIndex((option) => equals(option.value, clearedValue)),
|
|
7055
6718
|
[clearedValue, options]
|
|
7056
6719
|
);
|
|
7057
6720
|
const clearedFormattedValue = clearedIdx === -1 ? "" : clearedIdx.toString();
|
|
7058
|
-
const optionNodes =
|
|
6721
|
+
const optionNodes = useMemo(
|
|
7059
6722
|
() => optionObjectsToNodes(groupedOptions),
|
|
7060
6723
|
[groupedOptions]
|
|
7061
6724
|
);
|
|
@@ -7105,16 +6768,72 @@ const SelectControl = React.forwardRef(function SelectControl2({
|
|
|
7105
6768
|
inlineIssues
|
|
7106
6769
|
] });
|
|
7107
6770
|
});
|
|
7108
|
-
const SelectMultipleControl =
|
|
7109
|
-
|
|
7110
|
-
|
|
7111
|
-
|
|
7112
|
-
|
|
7113
|
-
|
|
7114
|
-
|
|
7115
|
-
|
|
7116
|
-
|
|
7117
|
-
|
|
6771
|
+
const SelectMultipleControl = forwardRef(function SelectMultipleControl2({
|
|
6772
|
+
path,
|
|
6773
|
+
issueMessages,
|
|
6774
|
+
issuesPanelLabel,
|
|
6775
|
+
displayIssues = true,
|
|
6776
|
+
options: groupedOptions,
|
|
6777
|
+
preventAutoFocus,
|
|
6778
|
+
apiRef,
|
|
6779
|
+
issueMessagesProps,
|
|
6780
|
+
formManager,
|
|
6781
|
+
onInitialized,
|
|
6782
|
+
onFormManagerEvent,
|
|
6783
|
+
onValueChange,
|
|
6784
|
+
onValidationStatusChange,
|
|
6785
|
+
onDisplayStatusChange,
|
|
6786
|
+
onDirtyStatusChange,
|
|
6787
|
+
onTouchedStatusChange,
|
|
6788
|
+
required,
|
|
6789
|
+
loading,
|
|
6790
|
+
disabled,
|
|
6791
|
+
readOnly,
|
|
6792
|
+
endAdornment,
|
|
6793
|
+
onFocus,
|
|
6794
|
+
onBlurToOutside,
|
|
6795
|
+
...otherProps
|
|
6796
|
+
}, forwardedRef) {
|
|
6797
|
+
const options = useMemo(
|
|
6798
|
+
() => groupedOptions.reduce((options2, optionOrGroup) => {
|
|
6799
|
+
if ("options" in optionOrGroup) {
|
|
6800
|
+
options2.push(...optionOrGroup.options);
|
|
6801
|
+
} else {
|
|
6802
|
+
options2.push(optionOrGroup);
|
|
6803
|
+
}
|
|
6804
|
+
return options2;
|
|
6805
|
+
}, []),
|
|
6806
|
+
[groupedOptions]
|
|
6807
|
+
);
|
|
6808
|
+
const [arrayValue, setArrayValue] = useState(null);
|
|
6809
|
+
const formattedValue = useMemo(
|
|
6810
|
+
() => formatSelectionValuesAsOptionIndices(arrayValue, options),
|
|
6811
|
+
[options, arrayValue]
|
|
6812
|
+
);
|
|
6813
|
+
const controller = useListableInput(path, {
|
|
6814
|
+
enabled: !useFormIsLoading(),
|
|
6815
|
+
parseToArray: useCallback(
|
|
6816
|
+
(formattedValue2, state) => parseSelectionValuesFromOptionIndices(
|
|
6817
|
+
formattedValue2,
|
|
6818
|
+
state.schema,
|
|
6819
|
+
options
|
|
6820
|
+
),
|
|
6821
|
+
[options]
|
|
6822
|
+
),
|
|
6823
|
+
formatFromArray: useCallback(
|
|
6824
|
+
(arrayValue2) => formatSelectionValuesAsOptionIndices(arrayValue2, options),
|
|
6825
|
+
[options]
|
|
6826
|
+
),
|
|
6827
|
+
setFormattedValue: useCallback(
|
|
6828
|
+
(formattedValue2, state) => setArrayValue(
|
|
6829
|
+
parseSelectionValuesFromOptionIndices(
|
|
6830
|
+
formattedValue2,
|
|
6831
|
+
state.schema,
|
|
6832
|
+
options
|
|
6833
|
+
)
|
|
6834
|
+
),
|
|
6835
|
+
[options]
|
|
6836
|
+
),
|
|
7118
6837
|
formManager,
|
|
7119
6838
|
onInitialized,
|
|
7120
6839
|
onFormManagerEvent,
|
|
@@ -7122,145 +6841,87 @@ const SelectMultipleControl = React.forwardRef(
|
|
|
7122
6841
|
onValidationStatusChange,
|
|
7123
6842
|
onDisplayStatusChange,
|
|
7124
6843
|
onDirtyStatusChange,
|
|
7125
|
-
onTouchedStatusChange
|
|
7126
|
-
|
|
7127
|
-
|
|
7128
|
-
|
|
7129
|
-
|
|
7130
|
-
|
|
7131
|
-
|
|
7132
|
-
|
|
7133
|
-
|
|
7134
|
-
|
|
7135
|
-
|
|
7136
|
-
|
|
7137
|
-
|
|
7138
|
-
|
|
7139
|
-
|
|
7140
|
-
|
|
7141
|
-
|
|
7142
|
-
|
|
7143
|
-
|
|
7144
|
-
|
|
7145
|
-
|
|
7146
|
-
|
|
7147
|
-
|
|
7148
|
-
|
|
7149
|
-
|
|
7150
|
-
|
|
7151
|
-
|
|
7152
|
-
|
|
7153
|
-
|
|
7154
|
-
|
|
7155
|
-
|
|
7156
|
-
|
|
7157
|
-
|
|
6844
|
+
onTouchedStatusChange
|
|
6845
|
+
});
|
|
6846
|
+
const { getState, useSchema, usePath, inputProps } = controller;
|
|
6847
|
+
const { restrictions } = useSchema().typeInfo;
|
|
6848
|
+
const absolutePath = usePath();
|
|
6849
|
+
const {
|
|
6850
|
+
displayLoading,
|
|
6851
|
+
displayDisabled,
|
|
6852
|
+
displayReadOnly,
|
|
6853
|
+
displayStatusToDisplay,
|
|
6854
|
+
issuesToDisplay,
|
|
6855
|
+
autofocusRef,
|
|
6856
|
+
handleFocus
|
|
6857
|
+
} = useRegisterControl({
|
|
6858
|
+
controller,
|
|
6859
|
+
issuesPanelLabel,
|
|
6860
|
+
ariaLabel: otherProps["aria-label"],
|
|
6861
|
+
preventAutoFocus,
|
|
6862
|
+
apiRef
|
|
6863
|
+
});
|
|
6864
|
+
const handleValueChange = useCallback(
|
|
6865
|
+
(formattedValue2) => setArrayValue(
|
|
6866
|
+
parseSelectionValuesFromOptionIndices(
|
|
6867
|
+
formattedValue2,
|
|
6868
|
+
getState().schema,
|
|
6869
|
+
options
|
|
6870
|
+
)
|
|
6871
|
+
),
|
|
6872
|
+
[getState, options]
|
|
6873
|
+
);
|
|
6874
|
+
const optionNodes = useMemo(
|
|
6875
|
+
() => optionObjectsToNodes(groupedOptions),
|
|
6876
|
+
[groupedOptions]
|
|
6877
|
+
);
|
|
6878
|
+
const [inlineIssues, popoverIssues] = useControlIssues({
|
|
6879
|
+
issuesToDisplay: {
|
|
6880
|
+
[absolutePath.toString()]: issuesToDisplay
|
|
6881
|
+
},
|
|
6882
|
+
issueMessages: { [absolutePath.toString()]: issueMessages },
|
|
6883
|
+
displayIssues,
|
|
6884
|
+
issueMessagesProps
|
|
6885
|
+
});
|
|
6886
|
+
const combinedSelectRef = useCombinedRef(
|
|
6887
|
+
inputProps.ref,
|
|
6888
|
+
autofocusRef,
|
|
6889
|
+
forwardedRef
|
|
6890
|
+
);
|
|
6891
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6892
|
+
/* @__PURE__ */ jsx(
|
|
6893
|
+
Select,
|
|
6894
|
+
{
|
|
6895
|
+
multiple: true,
|
|
6896
|
+
value: formattedValue,
|
|
6897
|
+
name: inputProps.name,
|
|
6898
|
+
required: required ?? restrictions.required === true,
|
|
6899
|
+
loading: displayLoading || loading,
|
|
6900
|
+
disabled: displayDisabled || disabled,
|
|
6901
|
+
readOnly: displayReadOnly || readOnly || inputProps.readOnly,
|
|
6902
|
+
status: displayStatusToControlStatus(displayStatusToDisplay),
|
|
6903
|
+
endAdornment: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6904
|
+
popoverIssues,
|
|
6905
|
+
endAdornment
|
|
6906
|
+
] }),
|
|
6907
|
+
onValueChange: combineEventHandlers(
|
|
6908
|
+
inputProps.onChange,
|
|
6909
|
+
handleValueChange
|
|
7158
6910
|
),
|
|
7159
|
-
|
|
7160
|
-
|
|
7161
|
-
|
|
7162
|
-
|
|
7163
|
-
[options]
|
|
7164
|
-
),
|
|
7165
|
-
setFormattedValue: React.useCallback(
|
|
7166
|
-
(formattedValue2, state) => setArrayValue(
|
|
7167
|
-
parseSelectionValuesFromOptionIndices(
|
|
7168
|
-
formattedValue2,
|
|
7169
|
-
state.schema,
|
|
7170
|
-
options
|
|
7171
|
-
)
|
|
6911
|
+
onFocus: combineEventHandlers(onFocus, handleFocus),
|
|
6912
|
+
onBlurToOutside: combineEventHandlers(
|
|
6913
|
+
onBlurToOutside,
|
|
6914
|
+
inputProps.onBlur
|
|
7172
6915
|
),
|
|
7173
|
-
|
|
7174
|
-
|
|
7175
|
-
|
|
7176
|
-
|
|
7177
|
-
|
|
7178
|
-
|
|
7179
|
-
|
|
7180
|
-
|
|
7181
|
-
|
|
7182
|
-
onTouchedStatusChange
|
|
7183
|
-
});
|
|
7184
|
-
const { getState, useSchema, usePath, inputProps } = controller;
|
|
7185
|
-
const { restrictions } = useSchema().typeInfo;
|
|
7186
|
-
const absolutePath = usePath();
|
|
7187
|
-
const {
|
|
7188
|
-
displayLoading,
|
|
7189
|
-
displayDisabled,
|
|
7190
|
-
displayReadOnly,
|
|
7191
|
-
displayStatusToDisplay,
|
|
7192
|
-
issuesToDisplay,
|
|
7193
|
-
autofocusRef,
|
|
7194
|
-
handleFocus
|
|
7195
|
-
} = useRegisterControl({
|
|
7196
|
-
controller,
|
|
7197
|
-
issuesPanelLabel,
|
|
7198
|
-
ariaLabel: otherProps["aria-label"],
|
|
7199
|
-
preventAutoFocus,
|
|
7200
|
-
apiRef
|
|
7201
|
-
});
|
|
7202
|
-
const handleValueChange = React.useCallback(
|
|
7203
|
-
(formattedValue2) => setArrayValue(
|
|
7204
|
-
parseSelectionValuesFromOptionIndices(
|
|
7205
|
-
formattedValue2,
|
|
7206
|
-
getState().schema,
|
|
7207
|
-
options
|
|
7208
|
-
)
|
|
7209
|
-
),
|
|
7210
|
-
[getState, options]
|
|
7211
|
-
);
|
|
7212
|
-
const optionNodes = React.useMemo(
|
|
7213
|
-
() => optionObjectsToNodes(groupedOptions),
|
|
7214
|
-
[groupedOptions]
|
|
7215
|
-
);
|
|
7216
|
-
const [inlineIssues, popoverIssues] = useControlIssues({
|
|
7217
|
-
issuesToDisplay: {
|
|
7218
|
-
[absolutePath.toString()]: issuesToDisplay
|
|
7219
|
-
},
|
|
7220
|
-
issueMessages: { [absolutePath.toString()]: issueMessages },
|
|
7221
|
-
displayIssues,
|
|
7222
|
-
issueMessagesProps
|
|
7223
|
-
});
|
|
7224
|
-
const combinedSelectRef = useCombinedRef(
|
|
7225
|
-
inputProps.ref,
|
|
7226
|
-
autofocusRef,
|
|
7227
|
-
forwardedRef
|
|
7228
|
-
);
|
|
7229
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
7230
|
-
/* @__PURE__ */ jsx(
|
|
7231
|
-
Select,
|
|
7232
|
-
{
|
|
7233
|
-
multiple: true,
|
|
7234
|
-
value: formattedValue,
|
|
7235
|
-
name: inputProps.name,
|
|
7236
|
-
required: required ?? restrictions.required === true,
|
|
7237
|
-
loading: displayLoading || loading,
|
|
7238
|
-
disabled: displayDisabled || disabled,
|
|
7239
|
-
readOnly: displayReadOnly || readOnly || inputProps.readOnly,
|
|
7240
|
-
status: displayStatusToControlStatus(displayStatusToDisplay),
|
|
7241
|
-
endAdornment: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
7242
|
-
popoverIssues,
|
|
7243
|
-
endAdornment
|
|
7244
|
-
] }),
|
|
7245
|
-
onValueChange: combineEventHandlers(
|
|
7246
|
-
inputProps.onChange,
|
|
7247
|
-
handleValueChange
|
|
7248
|
-
),
|
|
7249
|
-
onFocus: combineEventHandlers(onFocus, handleFocus),
|
|
7250
|
-
onBlurToOutside: combineEventHandlers(
|
|
7251
|
-
onBlurToOutside,
|
|
7252
|
-
inputProps.onBlur
|
|
7253
|
-
),
|
|
7254
|
-
...otherProps,
|
|
7255
|
-
ref: combinedSelectRef,
|
|
7256
|
-
children: optionNodes
|
|
7257
|
-
}
|
|
7258
|
-
),
|
|
7259
|
-
inlineIssues
|
|
7260
|
-
] });
|
|
7261
|
-
}
|
|
7262
|
-
);
|
|
7263
|
-
const TextControl = React.forwardRef(function TextControl2({
|
|
6916
|
+
...otherProps,
|
|
6917
|
+
ref: combinedSelectRef,
|
|
6918
|
+
children: optionNodes
|
|
6919
|
+
}
|
|
6920
|
+
),
|
|
6921
|
+
inlineIssues
|
|
6922
|
+
] });
|
|
6923
|
+
});
|
|
6924
|
+
const TextControl = forwardRef(function TextControl2({
|
|
7264
6925
|
path,
|
|
7265
6926
|
issueMessages,
|
|
7266
6927
|
issuesPanelLabel,
|
|
@@ -7290,21 +6951,18 @@ const TextControl = React.forwardRef(function TextControl2({
|
|
|
7290
6951
|
onBlurToOutside,
|
|
7291
6952
|
...otherProps
|
|
7292
6953
|
}, forwardedRef) {
|
|
7293
|
-
const controller = useInput(
|
|
7294
|
-
|
|
7295
|
-
|
|
7296
|
-
|
|
7297
|
-
|
|
7298
|
-
|
|
7299
|
-
|
|
7300
|
-
|
|
7301
|
-
|
|
7302
|
-
|
|
7303
|
-
|
|
7304
|
-
|
|
7305
|
-
onTouchedStatusChange
|
|
7306
|
-
}
|
|
7307
|
-
);
|
|
6954
|
+
const controller = useInput(path, {
|
|
6955
|
+
enabled: !useFormIsLoading(),
|
|
6956
|
+
parse: parseText,
|
|
6957
|
+
formManager,
|
|
6958
|
+
onInitialized,
|
|
6959
|
+
onFormManagerEvent,
|
|
6960
|
+
onValueChange,
|
|
6961
|
+
onValidationStatusChange,
|
|
6962
|
+
onDisplayStatusChange,
|
|
6963
|
+
onDirtyStatusChange,
|
|
6964
|
+
onTouchedStatusChange
|
|
6965
|
+
});
|
|
7308
6966
|
const { useSchema, usePath, inputProps } = controller;
|
|
7309
6967
|
const schema = useSchema();
|
|
7310
6968
|
const absolutePath = usePath();
|
|
@@ -7330,8 +6988,8 @@ const TextControl = React.forwardRef(function TextControl2({
|
|
|
7330
6988
|
preventAutoFocus,
|
|
7331
6989
|
apiRef
|
|
7332
6990
|
});
|
|
7333
|
-
const prevMultiline =
|
|
7334
|
-
|
|
6991
|
+
const prevMultiline = useRef(multiline);
|
|
6992
|
+
useEffect(() => {
|
|
7335
6993
|
if (prevMultiline.current !== multiline) {
|
|
7336
6994
|
throw new Error(
|
|
7337
6995
|
"The `multiline` property cannot not be changed at runtime."
|
|
@@ -7391,14 +7049,14 @@ const TextControl = React.forwardRef(function TextControl2({
|
|
|
7391
7049
|
function parseText(formattedValue, state) {
|
|
7392
7050
|
return state.schema.typeInfo.nullable ? formattedValue || null : formattedValue;
|
|
7393
7051
|
}
|
|
7394
|
-
const TopBar =
|
|
7052
|
+
const TopBar = forwardRef(
|
|
7395
7053
|
function TopBar2({ className, ...otherProps }, forwardedRef) {
|
|
7396
7054
|
const prefix = usePrefix();
|
|
7397
7055
|
const setTopBarHeight = useSetTopBarHeight();
|
|
7398
|
-
const [topBarEl, setTopBarEl] =
|
|
7056
|
+
const [topBarEl, setTopBarEl] = useState(null);
|
|
7399
7057
|
useMeasure(
|
|
7400
7058
|
topBarEl,
|
|
7401
|
-
|
|
7059
|
+
useCallback(
|
|
7402
7060
|
(measurement) => setTopBarHeight(measurement?.height),
|
|
7403
7061
|
[setTopBarHeight]
|
|
7404
7062
|
)
|
|
@@ -7414,7 +7072,7 @@ const TopBar = React.forwardRef(
|
|
|
7414
7072
|
) });
|
|
7415
7073
|
}
|
|
7416
7074
|
);
|
|
7417
|
-
const TopBarActions =
|
|
7075
|
+
const TopBarActions = forwardRef(function TopBarActions2({ className, ...otherProps }, forwardedRef) {
|
|
7418
7076
|
const prefix = usePrefix();
|
|
7419
7077
|
return /* @__PURE__ */ jsx(
|
|
7420
7078
|
Stack,
|
|
@@ -7435,7 +7093,6 @@ export {
|
|
|
7435
7093
|
CheckboxControl,
|
|
7436
7094
|
CheckboxGroupControl,
|
|
7437
7095
|
ControlField,
|
|
7438
|
-
DEFAULT_PREFIX_SUFFIX,
|
|
7439
7096
|
DateControl,
|
|
7440
7097
|
DateRangeControl,
|
|
7441
7098
|
FileControl,
|
|
@@ -7475,13 +7132,13 @@ export {
|
|
|
7475
7132
|
TopBar,
|
|
7476
7133
|
TopBarActions,
|
|
7477
7134
|
ValidateAction,
|
|
7478
|
-
defaultLocale,
|
|
7479
7135
|
displayStatusToColor,
|
|
7480
7136
|
displayStatusToControlStatus,
|
|
7481
7137
|
enGB,
|
|
7482
7138
|
enUS,
|
|
7483
|
-
|
|
7484
|
-
|
|
7139
|
+
fr,
|
|
7140
|
+
pt,
|
|
7141
|
+
setDefaultPrefixSuffix,
|
|
7485
7142
|
tableControlActionsColumn,
|
|
7486
7143
|
tableControlIndexColumn,
|
|
7487
7144
|
useActiveIssuesPanelBreadcrumb,
|