@ostack.tech/ui-kform 0.15.5 → 0.16.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-CaLvO1z0.js → en-CKrk2smU.js} +14 -5
- package/dist/chunks/en-CKrk2smU.js.map +1 -0
- package/dist/locales/en-GB.js +1 -1
- package/dist/locales/en-US.js +1 -1
- package/dist/locales/fr-FR.js +21 -12
- package/dist/locales/fr-FR.js.map +1 -1
- package/dist/locales/pt-PT.js +13 -4
- package/dist/locales/pt-PT.js.map +1 -1
- package/dist/ostack-ui-kform.css +13 -0
- package/dist/ostack-ui-kform.js +1806 -709
- package/dist/ostack-ui-kform.js.map +1 -1
- package/package.json +6 -5
- package/scss/_utils.scss +1 -0
- package/scss/components/FormPages/_FormPages.scss +8 -0
- package/scss/components/SubmitAction/_SubmitAction-variables.scss +3 -0
- package/scss/components/SubmitAction/_SubmitAction.scss +13 -0
- package/scss/index.scss +1 -0
- package/types/components/Annexes/Annex.d.ts +71 -7
- package/types/components/Annexes/Annexes.d.ts +49 -65
- package/types/components/Annexes/AnnexesContext.d.ts +2 -1
- package/types/components/Annexes/AnnexesManager.d.ts +15 -10
- package/types/components/Annexes/AnnexesMenu.d.ts +5 -6
- package/types/components/Annexes/AnnexesTabList.d.ts +3 -4
- package/types/components/CheckboxControl/CheckboxControl.d.ts +38 -9
- package/types/components/CheckboxGroupControl/CheckboxGroupControl.d.ts +64 -22
- package/types/components/CheckboxGroupControl/CheckboxGroupControlItem.d.ts +26 -0
- package/types/components/CheckboxGroupControl/index.d.ts +1 -0
- package/types/components/ControlField/ControlField.d.ts +3 -4
- package/types/components/DateControl/DateControl.d.ts +38 -8
- package/types/components/DateRangeControl/DateRangeControl.d.ts +56 -24
- package/types/components/DebugInfo/DebugInfo.d.ts +26 -0
- package/types/components/DebugInfo/DebugInfoControlAddonTrigger.d.ts +9 -0
- package/types/components/DebugInfo/index.d.ts +2 -0
- package/types/components/FileControl/FileControl.d.ts +37 -8
- package/types/components/FileControl/FileControlDownloadAddon.d.ts +8 -0
- package/types/components/FileControl/FileControlViewAddon.d.ts +10 -0
- package/types/components/FormApp/FormApp.d.ts +60 -139
- package/types/components/FormApp/FormAppContext.d.ts +13 -3
- package/types/components/FormApp/FormAppElement.d.ts +3 -3
- package/types/components/FormApp/index.d.ts +1 -1
- package/types/components/FormPages/FormPage.d.ts +38 -20
- package/types/components/FormPages/FormPageHeader.d.ts +3 -3
- package/types/components/FormPages/FormPages.d.ts +45 -24
- package/types/components/FormPages/FormPagesContext.d.ts +2 -1
- package/types/components/FormPages/FormPagesNavigation.d.ts +11 -8
- package/types/components/FormPages/FormPagesSelect.d.ts +1 -1
- package/types/components/FormPages/FormPagesSidebar.d.ts +3 -3
- package/types/components/FormStepper/FormStep.d.ts +23 -7
- package/types/components/FormStepper/FormStepList.d.ts +3 -4
- package/types/components/FormStepper/FormStepper.d.ts +52 -21
- package/types/components/FormStepper/FormStepperContext.d.ts +2 -1
- package/types/components/FormStepper/FormStepperFinishTrigger.d.ts +4 -1
- package/types/components/FormStepper/FormStepperNextTrigger.d.ts +4 -1
- package/types/components/FormStepper/FormStepperPreviousTrigger.d.ts +4 -1
- package/types/components/FormStepper/FormStepperState.d.ts +3 -1
- package/types/components/IssueMessage/IssueMessage.d.ts +2 -2
- package/types/components/IssueMessages/IssueMessages.d.ts +4 -4
- package/types/components/IssuesAlert/IssuesAlert.d.ts +4 -5
- package/types/components/IssuesPanel/IssuesPanel.d.ts +18 -18
- package/types/components/IssuesPanel/IssuesPanelMessagesCard.d.ts +4 -4
- package/types/components/IssuesPanel/IssuesPanelSummaryCard.d.ts +4 -4
- package/types/components/IssuesPopover/IssuesPopover.d.ts +3 -4
- package/types/components/LoadAction/LoadAction.d.ts +34 -4
- package/types/components/NumericControl/NumericControl.d.ts +56 -8
- package/types/components/PathLink/PathLink.d.ts +2 -2
- package/types/components/PrintAction/PrintAction.d.ts +41 -16
- package/types/components/RadioGroupControl/RadioGroupControl.d.ts +54 -19
- package/types/components/RadioGroupControl/RadioGroupControlItem.d.ts +25 -0
- package/types/components/RadioGroupControl/index.d.ts +1 -0
- package/types/components/SaveAction/SaveAction.d.ts +45 -7
- package/types/components/SelectControl/SelectControl.d.ts +55 -10
- package/types/components/SelectControl/SelectControlItem.d.ts +23 -0
- package/types/components/SelectControl/SelectControlItemGroup.d.ts +23 -0
- package/types/components/SelectControl/index.d.ts +2 -0
- package/types/components/SelectMultipleControl/SelectMultipleControl.d.ts +71 -14
- package/types/components/SelectMultipleControl/SelectMultipleControlItem.d.ts +13 -0
- package/types/components/SelectMultipleControl/SelectMultipleControlItemGroup.d.ts +13 -0
- package/types/components/SelectMultipleControl/index.d.ts +2 -0
- package/types/components/SubmitAction/SubmitAction.d.ts +50 -14
- package/types/components/TableControl/TableControl.d.ts +108 -13
- package/types/components/TableControl/TableControlActionsColumn.d.ts +21 -0
- package/types/components/TableControl/TableControlActionsColumnLabel.d.ts +2 -0
- package/types/components/TableControl/TableControlAddRowTrigger.d.ts +12 -5
- package/types/components/TableControl/TableControlCell.d.ts +3 -4
- package/types/components/TableControl/TableControlColumn.d.ts +24 -56
- package/types/components/TableControl/TableControlColumnFns.d.ts +113 -0
- package/types/components/TableControl/TableControlColumnGroup.d.ts +25 -0
- package/types/components/TableControl/TableControlColumns.d.ts +14 -0
- package/types/components/TableControl/TableControlContent.d.ts +3 -4
- package/types/components/TableControl/TableControlContext.d.ts +2 -1
- package/types/components/TableControl/TableControlIndexColumn.d.ts +10 -0
- package/types/components/TableControl/TableControlIndexColumnLabel.d.ts +2 -0
- package/types/components/TableControl/TableControlPagination.d.ts +4 -1
- package/types/components/TableControl/TableControlRemoveRowTrigger.d.ts +5 -5
- package/types/components/TableControl/TableControlRow.d.ts +11 -4
- package/types/components/TableControl/TableControlRowsPerPage.d.ts +4 -1
- package/types/components/TableControl/index.d.ts +6 -0
- package/types/components/TextControl/TextControl.d.ts +47 -21
- package/types/components/TopBar/TopBar.d.ts +3 -3
- package/types/components/TopBar/TopBarActions.d.ts +3 -4
- package/types/components/ValidateAction/ValidateAction.d.ts +24 -2
- package/types/index.d.ts +1 -0
- package/types/providers/LocalizationProvider/LocalizationObject.d.ts +5 -1
- package/types/utils/__tests__/pathSpecificity.test.d.ts +1 -0
- package/types/utils/options.d.ts +13 -18
- package/types/utils/promiseUtils.d.ts +7 -0
- package/types/utils/selectionTransformations.d.ts +9 -9
- package/types/utils/useControlIssues.d.ts +21 -19
- package/types/utils/useFormLoader.d.ts +7 -1
- package/types/utils/useFormSaver.d.ts +3 -3
- package/dist/chunks/en-CaLvO1z0.js.map +0 -1
package/dist/ostack-ui-kform.js
CHANGED
|
@@ -2,17 +2,18 @@ import { locale } from "./locales/en-GB.js";
|
|
|
2
2
|
import { locale as locale$1 } from "./locales/en-US.js";
|
|
3
3
|
import { locale as locale$2 } from "./locales/fr-FR.js";
|
|
4
4
|
import { locale as locale$3 } from "./locales/pt-PT.js";
|
|
5
|
+
import { Alert, AlertDialog, AlertDialogAction, AlertDialogBody, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, Button, ButtonGroup, Card, CardBody, CardHeader, CardTitle, Checkbox, CheckboxGroup, CloseButton, Code, Container, ControlAddon, DataTable, DataTableCell, DataTableContent, DataTablePagination, DataTableRow, DataTableRowsPerPage, DateInput, DateRangeInput, DescriptionList, DescriptionListItem, Dialog, DialogBody, DialogContent, DialogHeader, DialogTitle, DialogTrigger, DocumentTitle, DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EMPTY_STORE, ErrorBoundary, Feedback, FeedbackList, FeedbackPopover, FeedbackProvider, Field, Icon, IconButton, Input, Layer, Link, LocalizationProvider as LocalizationProvider$1, MenuList, MenuListItem, NATIVE_CONTROLS, NumericInput, Option, OptionsGroup, Popover, PopoverContent, PopoverTrigger, PrefixProvider, PrinterTrigger, Radio, RadioGroup, Root, Select, Slot, Spinner, Stack, Step, StepContent, StepList, Stepper, StepperFinishTrigger, StepperNextTrigger, StepperPreviousTrigger, Tab, TabContent, TabList, Tabs, TextArea, Tooltip, VisuallyHidden, boolDataAttr, combineAriaIds, combineEventHandlers, computed, controlStatusToAccent, cx, parseChildren, setBoolDataAttr, useAlertDialog, useCombinedRef, useConstant, useControllableState, useCssVars, useDataTableApiRef, useDataTableColumnLabel, useDateTransformer, useErrorReporter, useIntersectionObserver, useIsInRoot, useIsInTableCell, useKeyboardShortcut, useLatestRef, useMeasure, useMediaBreakpointUp, useOnLabelChange, usePrefix as usePrefix$1, usePrevious, usePrint, usePrintClassNames, usePrintInProgress, usePrinterDocumentTitle, usePrinting, useResponsiveValues, useScrollPosition, useSpacing, useStartPrintingTask, useToastManager, warnOnce } from "@ostack.tech/ui";
|
|
6
|
+
import { DEV } from "esm-env";
|
|
5
7
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
import { AtPathError, CurrentPath, FormContext, InvalidPathError, equals, formatNumericAsString, formatTemporalAsString, toFileList, useController, useCurrentPath, useFileInput, useForm, useFormContext, useFormController, useFormManager, useFormattedValue, useFormatter, useInput, useIssuesTracker, useListableInput, useNumericInput, useResolvedPath, useTemporalInput } from "@ostack.tech/kform-react";
|
|
7
|
-
import {
|
|
8
|
-
import { Children, Suspense, createContext, forwardRef, isValidElement, memo, startTransition, useCallback, useContext, useDeferredValue, useEffect, useId, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
8
|
+
import { AtPathError, CurrentPath, FormContext, FormattedValue, InvalidPathError, equals, formatNumericAsString, formatTemporalAsString, toFileList, useController, useCurrentPath, useFileInput, useForm, useFormContext, useFormController, useFormManager, useFormattedValue, useFormatter, useInput, useIssuesTracker, useListableInput, useNumericInput, useResolvedPath, useTemporalInput } from "@ostack.tech/kform-react";
|
|
9
|
+
import { Children, Fragment as Fragment$1, Suspense, createContext, isValidElement, startTransition, useCallback, useContext, useDeferredValue, useEffect, useEffectEvent, useId, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
9
10
|
import { createStore, useStore } from "zustand";
|
|
10
11
|
import { useShallow } from "zustand/react/shallow";
|
|
11
|
-
import { AbsolutePath, AbsolutePathFragment, Path, PathMultimap, PromiseCancellationException, ValidationFailure, arrayToTable, compareSchemaPaths,
|
|
12
|
+
import { AbsolutePath, AbsolutePathFragment, Path, PathMultimap, PromiseCancellationException, ValidationFailure, arrayToTable, compareSchemaPaths, isComputedSchema, isKtList, isTable, nullableSchemaInnerSchema, sliceTableRows, tableIdsToArray, tableRowsToArray, tableSize } from "@ostack.tech/kform";
|
|
12
13
|
import { subscribeWithSelector } from "zustand/middleware";
|
|
13
14
|
import { shallow } from "zustand/shallow";
|
|
14
15
|
import { fileOpen, fileSave, supported } from "browser-fs-access";
|
|
15
|
-
import { faAngleLeft, faAngleRight, faAnglesLeft, faAnglesRight, faArrowRight, faArrowsToDot, faCaretDown, faChevronDown, faChevronUp, faCircleCheck, faCircleExclamation, faCircleQuestion, faDownload, faFileLines, faFloppyDisk, faFolderOpen, faPlus, faPrint, faTrash, faTriangleExclamation } from "@fortawesome/free-solid-svg-icons";
|
|
16
|
+
import { faAngleLeft, faAngleRight, faAnglesLeft, faAnglesRight, faArrowRight, faArrowsToDot, faBug, faCaretDown, faChevronDown, faChevronUp, faCircleCheck, faCircleExclamation, faCircleQuestion, faDownload, faFileLines, faFloppyDisk, faFolderOpen, faPlus, faPrint, faTrash, faTriangleExclamation } from "@fortawesome/free-solid-svg-icons";
|
|
16
17
|
import { addDays, format, formatISO, max, min, parseISO } from "date-fns";
|
|
17
18
|
import { faCircleCheck as faCircleCheck$1 } from "@fortawesome/free-regular-svg-icons";
|
|
18
19
|
//#region src/providers/PrefixSuffixProvider/defaultPrefixSuffix.ts
|
|
@@ -175,7 +176,7 @@ function useEqualityFn(selector, equalityFn = Object.is) {
|
|
|
175
176
|
/** Form app context. */
|
|
176
177
|
var FormAppContext = createContext(null);
|
|
177
178
|
/** Hook which creates the form app context. */
|
|
178
|
-
function useCreateFormAppContext({ formTitle, controller, disabled, readOnly, issuesDisplayMode, displayIssueCodes, issueMessagesDataKey, formAppElement, onPathFocus }) {
|
|
179
|
+
function useCreateFormAppContext({ formTitle, controller, disabled, readOnly, issuesDisplayMode, displayIssueCodes, issueMessagesDataKey, formAppElement, onPathFocus, debug }) {
|
|
179
180
|
const latestRef = useLatestRef({
|
|
180
181
|
printing: usePrinting(),
|
|
181
182
|
onPathFocus
|
|
@@ -308,8 +309,13 @@ function useCreateFormAppContext({ formTitle, controller, disabled, readOnly, is
|
|
|
308
309
|
startIssuesNavigation: async ({ validate = true, setTouched = validate } = {}) => {
|
|
309
310
|
const formManager = get().controller.getState().formManager;
|
|
310
311
|
if (setTouched) await formManager.setTouched();
|
|
311
|
-
|
|
312
|
-
|
|
312
|
+
let issues;
|
|
313
|
+
if (validate && formManager.autoValidationStatus === "inactive") issues = await formManager.validate();
|
|
314
|
+
if (get().startIssuesNavigation) get().startIssuesNavigation();
|
|
315
|
+
else {
|
|
316
|
+
const firstIssue = issues ? issues[0] : (await formManager.validate())[0];
|
|
317
|
+
if (firstIssue) get().actions.focus(firstIssue.path);
|
|
318
|
+
}
|
|
313
319
|
}
|
|
314
320
|
}
|
|
315
321
|
}))));
|
|
@@ -324,8 +330,10 @@ function useCreateFormAppContext({ formTitle, controller, disabled, readOnly, is
|
|
|
324
330
|
displayIssueCodes,
|
|
325
331
|
issueMessagesDataKey,
|
|
326
332
|
formAppElement,
|
|
333
|
+
debug,
|
|
327
334
|
store
|
|
328
335
|
}), [
|
|
336
|
+
debug,
|
|
329
337
|
disabled,
|
|
330
338
|
displayIssueCodes,
|
|
331
339
|
formAppElement,
|
|
@@ -369,6 +377,10 @@ function useDisplayIssueCodesInIssueMessages() {
|
|
|
369
377
|
function useFormAppElement() {
|
|
370
378
|
return useFormAppContext().formAppElement;
|
|
371
379
|
}
|
|
380
|
+
/** Returns whether the form is in debug mode. */
|
|
381
|
+
function useFormInDebugMode() {
|
|
382
|
+
return useFormAppContext().debug;
|
|
383
|
+
}
|
|
372
384
|
/**
|
|
373
385
|
* Hook exposing a function that can be used to specify the height of the form
|
|
374
386
|
* app's top bar.
|
|
@@ -498,15 +510,15 @@ function useStartIssuesNavigation() {
|
|
|
498
510
|
* changes.
|
|
499
511
|
*
|
|
500
512
|
* @param cb Function to run when the focused path changes. This function should
|
|
501
|
-
* hopefully not change on every render (i.e
|
|
513
|
+
* hopefully not change on every render (i.e. it should be memoised via
|
|
502
514
|
* `useCallback` or be defined externally).
|
|
503
515
|
* @param options Hook options.
|
|
504
516
|
*/
|
|
505
|
-
function useOnPathFocus(cb, { fireImmediately = true } = {}) {
|
|
517
|
+
function useOnPathFocus(cb, { enabled = true, fireImmediately = true } = {}) {
|
|
506
518
|
const { store } = useFormAppContext();
|
|
507
519
|
const printing = usePrinting();
|
|
508
520
|
useEffect(() => {
|
|
509
|
-
if (!printing) return store.subscribe(({ focusedPath, focusCounter }) => ({
|
|
521
|
+
if (enabled && !printing) return store.subscribe(({ focusedPath, focusCounter }) => ({
|
|
510
522
|
focusedPath,
|
|
511
523
|
focusCounter
|
|
512
524
|
}), ({ focusedPath }) => focusedPath && cb(focusedPath), {
|
|
@@ -515,6 +527,7 @@ function useOnPathFocus(cb, { fireImmediately = true } = {}) {
|
|
|
515
527
|
});
|
|
516
528
|
}, [
|
|
517
529
|
cb,
|
|
530
|
+
enabled,
|
|
518
531
|
fireImmediately,
|
|
519
532
|
printing,
|
|
520
533
|
store
|
|
@@ -699,7 +712,7 @@ function FormAppAutoFocus() {
|
|
|
699
712
|
//#endregion
|
|
700
713
|
//#region src/components/FormApp/FormAppElement.tsx
|
|
701
714
|
/** Form application element. */
|
|
702
|
-
|
|
715
|
+
function FormAppElement({ formAppElement, setFormAppElement, minHeight, className, style, children, ref, ...otherProps }) {
|
|
703
716
|
const prefix = usePrefix();
|
|
704
717
|
const { cssVarName } = useCssVars({ prefix });
|
|
705
718
|
const { responsiveValueToCssVarsAndDataAttrs } = useResponsiveValues({ prefix });
|
|
@@ -721,7 +734,7 @@ var FormAppElement = forwardRef(function FormAppElement({ formAppElement, setFor
|
|
|
721
734
|
store
|
|
722
735
|
]);
|
|
723
736
|
const { cssVars, dataAttrs } = responsiveValueToCssVarsAndDataAttrs("form-app", "min-height", minHeight, (v) => typeof v === "number" ? `${v}px` : v);
|
|
724
|
-
const combinedFormAppRef = useCombinedRef(setFormAppElement,
|
|
737
|
+
const combinedFormAppRef = useCombinedRef(setFormAppElement, ref);
|
|
725
738
|
return /* @__PURE__ */ jsx("form", {
|
|
726
739
|
className: cx(prefix("form-app"), className),
|
|
727
740
|
style: {
|
|
@@ -735,7 +748,7 @@ var FormAppElement = forwardRef(function FormAppElement({ formAppElement, setFor
|
|
|
735
748
|
ref: combinedFormAppRef,
|
|
736
749
|
children
|
|
737
750
|
});
|
|
738
|
-
}
|
|
751
|
+
}
|
|
739
752
|
//#endregion
|
|
740
753
|
//#region src/components/FormApp/FormAppIssueMessages.tsx
|
|
741
754
|
/** Component used to register new issue messages within the form app. */
|
|
@@ -746,15 +759,42 @@ function FormAppIssueMessages({ path, issueMessages, priority, children }) {
|
|
|
746
759
|
//#endregion
|
|
747
760
|
//#region src/components/FormApp/FormApp.tsx
|
|
748
761
|
/**
|
|
749
|
-
* Root component of a form application.
|
|
762
|
+
* Root component of a form application. Built on top of the
|
|
763
|
+
* ostack/KForm-React's `useForm` hook.
|
|
764
|
+
*
|
|
765
|
+
* The `FormApp` component automatically renders the ostack/UI's `Root`
|
|
766
|
+
* component when not rendered within one, in which case all `Root` component
|
|
767
|
+
* properties are supported. The ostack/UI's `locale` is automatically provided
|
|
768
|
+
* to the ostack/UI `Root` component from the provided `FormApp` `locale`.
|
|
769
|
+
*
|
|
770
|
+
* Example usage:
|
|
750
771
|
*
|
|
751
|
-
*
|
|
752
|
-
*
|
|
753
|
-
*
|
|
754
|
-
*
|
|
755
|
-
*
|
|
772
|
+
* ```tsx
|
|
773
|
+
* import { Button, Field, Label, Stack } from "@ostack.tech/ui";
|
|
774
|
+
* import { FormApp, TextControl } from "@ostack.tech/ui-kform";
|
|
775
|
+
*
|
|
776
|
+
* export function SignInForm() {
|
|
777
|
+
* return (
|
|
778
|
+
* <FormApp schema={SignInFormSchema} onSubmit={signIn} minHeight={0}>
|
|
779
|
+
* <Stack>
|
|
780
|
+
* <Field>
|
|
781
|
+
* <Label>Email</Label>
|
|
782
|
+
* <TextControl path="/email" type="email" />
|
|
783
|
+
* </Field>
|
|
784
|
+
* <Field>
|
|
785
|
+
* <Label>Password</Label>
|
|
786
|
+
* <TextControl path="/password" type="password" />
|
|
787
|
+
* </Field>
|
|
788
|
+
* <Button color="primary" type="submit">
|
|
789
|
+
* Sign in
|
|
790
|
+
* </Button>
|
|
791
|
+
* </Stack>
|
|
792
|
+
* </FormApp>
|
|
793
|
+
* );
|
|
794
|
+
* }
|
|
795
|
+
* ```
|
|
756
796
|
*/
|
|
757
|
-
|
|
797
|
+
function FormApp({ enableErrorReporting, reportError, errorReportingUrl, errorReportingMethod, encodeErrorReport, encodedErrorReportMimeType, errorReportingOptions, baseDocumentTitle, documentTitleBaseSeparator, documentTitleBreadcrumbsSeparator, portalsContainer, tooltipsDelayDuration, tooltipsSkipDelayDuration, disableTooltipsHoverableContent, toastsLabel, toastsDuration, toastsSwipeDirection, toastsSwipeThreshold, toastViewportPosition, toastViewportHotkey, toastViewportLabel, toastViewportProps, errorBoundaryProps, schema, initialValue, formTitle, issuesPanelLabel, disabled = false, readOnly = false, prefix: newPrefix, prefixSuffix, defaultLocale, locale: controlledLocale, onLocaleChange, issueMessages, issuesDisplayMode = "inline", displayIssueCodes = false, issueMessagesDataKey = DEFAULT_ISSUE_MESSAGE_DATA_KEY, defaultActivePath, activePath, onActivePathChange, onPathFocus, minHeight, debug = false, apiRef, externalContexts, validationMode = readOnly ? "manual" : "auto", confirmUnloadWhenDirty, confirmUnloadMessage, onSubmit, onInvalidSubmit, onSuccessfulSubmit, onFailedSubmit, validateOnSubmit, setTouchedOnSubmit, setPristineOnSuccessfulSubmit, convertExternalIssuesTableRowIndicesToIds, onReset, onInitialized, onUninitialized, onFormManagerEvent, onValueChange, onValidationStatusChange, onDisplayStatusChange, onDirtyStatusChange, onTouchedStatusChange, ...otherProps }) {
|
|
758
798
|
const isInRoot = useIsInRoot();
|
|
759
799
|
const rootProps = {
|
|
760
800
|
enableErrorReporting,
|
|
@@ -795,7 +835,10 @@ var FormApp = forwardRef(function FormApp({ enableErrorReporting, reportError, e
|
|
|
795
835
|
confirmUnloadWhenDirty,
|
|
796
836
|
confirmUnloadMessage,
|
|
797
837
|
onSubmit,
|
|
798
|
-
onInvalidSubmit,
|
|
838
|
+
onInvalidSubmit: async (issues, event) => {
|
|
839
|
+
await startIssuesNavigation({ validate: false });
|
|
840
|
+
onInvalidSubmit?.(issues, event);
|
|
841
|
+
},
|
|
799
842
|
onSuccessfulSubmit,
|
|
800
843
|
onFailedSubmit,
|
|
801
844
|
validateOnSubmit,
|
|
@@ -831,7 +874,8 @@ var FormApp = forwardRef(function FormApp({ enableErrorReporting, reportError, e
|
|
|
831
874
|
issueMessagesDataKey,
|
|
832
875
|
controller,
|
|
833
876
|
onPathFocus,
|
|
834
|
-
formAppElement
|
|
877
|
+
formAppElement,
|
|
878
|
+
debug
|
|
835
879
|
});
|
|
836
880
|
const { store } = formAppContextValue;
|
|
837
881
|
useEffect(() => store.getState().actions.registerController(AbsolutePath.ROOT, controller), [controller, store]);
|
|
@@ -856,8 +900,7 @@ var FormApp = forwardRef(function FormApp({ enableErrorReporting, reportError, e
|
|
|
856
900
|
formAppElement,
|
|
857
901
|
setFormAppElement,
|
|
858
902
|
...formProps,
|
|
859
|
-
...otherProps
|
|
860
|
-
ref: forwardedRef
|
|
903
|
+
...otherProps
|
|
861
904
|
});
|
|
862
905
|
return /* @__PURE__ */ jsx(PrefixProvider, {
|
|
863
906
|
prefix: newPrefix,
|
|
@@ -893,7 +936,7 @@ var FormApp = forwardRef(function FormApp({ enableErrorReporting, reportError, e
|
|
|
893
936
|
})
|
|
894
937
|
})
|
|
895
938
|
});
|
|
896
|
-
}
|
|
939
|
+
}
|
|
897
940
|
//#endregion
|
|
898
941
|
//#region src/components/FormApp/FormAppStatus.tsx
|
|
899
942
|
/** Component used to apply a different form app status to part of the form. */
|
|
@@ -1084,7 +1127,7 @@ function useCreateAnnexesContext({ formManager, basePath, resolvedAnnexes, defau
|
|
|
1084
1127
|
const isRepetitive = path.lastFragment === AbsolutePathFragment.Wildcard;
|
|
1085
1128
|
const setPromise = formManager.set(isRepetitive ? path.parent().append(AbsolutePathFragment.CollectionEnd) : path, toAdd);
|
|
1086
1129
|
let addedPath;
|
|
1087
|
-
if (isRepetitive) addedPath = await formManager.get(path.parent(), (value) => path.parent().append(new AbsolutePathFragment.Id(
|
|
1130
|
+
if (isRepetitive) addedPath = await formManager.get(path.parent(), (value) => path.parent().append(new AbsolutePathFragment.Id(sliceTableRows(value, tableSize(value) - 1)[0][0])));
|
|
1088
1131
|
else addedPath = path;
|
|
1089
1132
|
set({ nextActiveAnnex: addedPath });
|
|
1090
1133
|
await setPromise;
|
|
@@ -1130,7 +1173,7 @@ function useAnnexState(path, selector) {
|
|
|
1130
1173
|
//#endregion
|
|
1131
1174
|
//#region src/components/Annexes/Annex.tsx
|
|
1132
1175
|
/** Component containing the content of an annex. */
|
|
1133
|
-
|
|
1176
|
+
function Annex({ path, title: _title, subtitle: _subtitle, description: _description, issuesPanelLabel: _issuesPanelLabel, itemTitle: _itemTitle, itemIssuesPanelLabel: _itemIssuesPanelLabel, documentTitle: _documentTitle, maxAnnexes: _maxAnnexes, getValue: _getValue, ref, ...otherProps }) {
|
|
1134
1177
|
const annexPath = useResolvedPath(path);
|
|
1135
1178
|
const store = useAnnexesContext();
|
|
1136
1179
|
const activeAnnex = useStore(store, (state) => state.activeAnnex);
|
|
@@ -1140,12 +1183,12 @@ var Annex = forwardRef(function Annex({ path, title: _title, subtitle: _subtitle
|
|
|
1140
1183
|
path: state.path,
|
|
1141
1184
|
children: /* @__PURE__ */ jsx(AnnexTabContent, {
|
|
1142
1185
|
...otherProps,
|
|
1143
|
-
ref: state.path.equals(activeAnnex) ?
|
|
1186
|
+
ref: state.path.equals(activeAnnex) ? ref : void 0
|
|
1144
1187
|
})
|
|
1145
1188
|
}, pathStr);
|
|
1146
1189
|
});
|
|
1147
|
-
}
|
|
1148
|
-
|
|
1190
|
+
}
|
|
1191
|
+
function AnnexTabContent({ disabled = false, readOnly = false, issueMessages, children, className, containerProps, tabContentLabelProps, errorBoundaryProps, ...otherProps }) {
|
|
1149
1192
|
const prefix = usePrefix();
|
|
1150
1193
|
const printing = usePrinting();
|
|
1151
1194
|
const annexPath = useCurrentPath();
|
|
@@ -1162,7 +1205,6 @@ var AnnexTabContent = forwardRef(function AnnexTabContent({ disabled = false, re
|
|
|
1162
1205
|
className: cx(prefix("annexes__annex-label"), tabContentLabelProps?.className)
|
|
1163
1206
|
},
|
|
1164
1207
|
...otherProps,
|
|
1165
|
-
ref: forwardedRef,
|
|
1166
1208
|
children: /* @__PURE__ */ jsx(ErrorBoundary, {
|
|
1167
1209
|
...errorBoundaryProps,
|
|
1168
1210
|
children: /* @__PURE__ */ jsx(DocumentTitle, {
|
|
@@ -1185,21 +1227,21 @@ var AnnexTabContent = forwardRef(function AnnexTabContent({ disabled = false, re
|
|
|
1185
1227
|
})
|
|
1186
1228
|
})
|
|
1187
1229
|
});
|
|
1188
|
-
}
|
|
1230
|
+
}
|
|
1189
1231
|
//#endregion
|
|
1190
1232
|
//#region src/utils/useFormLoader.tsx
|
|
1191
1233
|
/** Hook exposing a function used to load the form from a file. */
|
|
1192
|
-
function useFormLoader({ decode, path, extensions, mimeTypes, description, startIn, id, setPristineOnLoad, validateOnLoad, successMessage, errorMessage } = {}) {
|
|
1234
|
+
function useFormLoader({ decode, path, extensions, mimeTypes, description, startIn, id, setPristineOnLoad, setTouchedOnLoad, validateOnLoad, successMessage, errorMessage } = {}) {
|
|
1193
1235
|
const [locale] = useLocale();
|
|
1194
1236
|
const formManager = useFormManager();
|
|
1195
1237
|
const { _setState } = useFormController();
|
|
1196
1238
|
const { addToast } = useToastManager();
|
|
1197
1239
|
const startIssuesNavigation = useStartIssuesNavigation();
|
|
1240
|
+
const formTitle = useFormTitle();
|
|
1241
|
+
const defaultId = useMemo(() => formTitle?.replace(/[^a-zA-Z0-9-_]/g, "").substring(0, 32) ?? "", [formTitle]);
|
|
1198
1242
|
return useMemo(() => {
|
|
1199
|
-
async function load({ decode, path = AbsolutePath.ROOT, extensions, mimeTypes, description, startIn, id =
|
|
1243
|
+
async function load({ decode, path = AbsolutePath.ROOT, extensions, mimeTypes, description, startIn, id = defaultId, setPristineOnLoad = true, setTouchedOnLoad = true, validateOnLoad = true, successMessage = locale.LoadAction.successMessage, errorMessage = locale.LoadAction.errorMessage }) {
|
|
1200
1244
|
if (!decode) throw new Error("No `decode` function was provided.");
|
|
1201
|
-
if (successMessage === void 0) successMessage = locale.LoadAction.successMessage;
|
|
1202
|
-
if (errorMessage === void 0) errorMessage = locale.LoadAction.errorMessage;
|
|
1203
1245
|
const validationModeIsAuto = formManager.autoValidationStatus !== "inactive";
|
|
1204
1246
|
let file = null;
|
|
1205
1247
|
try {
|
|
@@ -1214,8 +1256,15 @@ function useFormLoader({ decode, path, extensions, mimeTypes, description, start
|
|
|
1214
1256
|
const formValue = await decode(file);
|
|
1215
1257
|
if (validationModeIsAuto) await formManager.setValidationMode("manual");
|
|
1216
1258
|
await formManager.set(path, formValue);
|
|
1217
|
-
if (setPristineOnLoad
|
|
1218
|
-
|
|
1259
|
+
if (setPristineOnLoad || setTouchedOnLoad) {
|
|
1260
|
+
const pathWithDescendants = (path instanceof AbsolutePath ? path : new AbsolutePath(path)).append(AbsolutePathFragment.RecursiveWildcard);
|
|
1261
|
+
await Promise.all([
|
|
1262
|
+
setPristineOnLoad && formManager.setPristine(path),
|
|
1263
|
+
setTouchedOnLoad && formManager.setTouched(pathWithDescendants),
|
|
1264
|
+
validateOnLoad && formManager.validate(pathWithDescendants)
|
|
1265
|
+
]);
|
|
1266
|
+
}
|
|
1267
|
+
if (validateOnLoad) await startIssuesNavigation({ validate: false });
|
|
1219
1268
|
_setState((state) => ({ latestFileHandles: {
|
|
1220
1269
|
...state.latestFileHandles,
|
|
1221
1270
|
[id]: file.handle ?? null
|
|
@@ -1224,7 +1273,7 @@ function useFormLoader({ decode, path, extensions, mimeTypes, description, start
|
|
|
1224
1273
|
if (message != null) addToast(message, { severity: "success" });
|
|
1225
1274
|
} catch (error) {
|
|
1226
1275
|
if (error instanceof DOMException && error.name === "AbortError") return;
|
|
1227
|
-
if (
|
|
1276
|
+
if (DEV) console.error(error);
|
|
1228
1277
|
const message = typeof errorMessage === "function" ? errorMessage(file, error) : errorMessage;
|
|
1229
1278
|
if (message != null) addToast(message, { severity: "danger" });
|
|
1230
1279
|
} finally {
|
|
@@ -1242,6 +1291,7 @@ function useFormLoader({ decode, path, extensions, mimeTypes, description, start
|
|
|
1242
1291
|
startIn,
|
|
1243
1292
|
id,
|
|
1244
1293
|
setPristineOnLoad,
|
|
1294
|
+
setTouchedOnLoad,
|
|
1245
1295
|
validateOnLoad,
|
|
1246
1296
|
successMessage,
|
|
1247
1297
|
errorMessage,
|
|
@@ -1250,10 +1300,12 @@ function useFormLoader({ decode, path, extensions, mimeTypes, description, start
|
|
|
1250
1300
|
supportsFileSystemAPIs: supported
|
|
1251
1301
|
};
|
|
1252
1302
|
}, [
|
|
1253
|
-
|
|
1303
|
+
defaultId,
|
|
1304
|
+
locale.LoadAction.successMessage,
|
|
1305
|
+
locale.LoadAction.errorMessage,
|
|
1254
1306
|
formManager,
|
|
1307
|
+
_setState,
|
|
1255
1308
|
startIssuesNavigation,
|
|
1256
|
-
locale.LoadAction,
|
|
1257
1309
|
addToast,
|
|
1258
1310
|
decode,
|
|
1259
1311
|
path,
|
|
@@ -1263,6 +1315,7 @@ function useFormLoader({ decode, path, extensions, mimeTypes, description, start
|
|
|
1263
1315
|
startIn,
|
|
1264
1316
|
id,
|
|
1265
1317
|
setPristineOnLoad,
|
|
1318
|
+
setTouchedOnLoad,
|
|
1266
1319
|
validateOnLoad,
|
|
1267
1320
|
successMessage,
|
|
1268
1321
|
errorMessage
|
|
@@ -1279,7 +1332,7 @@ function AnnexRegistrar({ path, title, subtitle, description, issuesPanelLabel,
|
|
|
1279
1332
|
const store = useAnnexesContext();
|
|
1280
1333
|
const printing = usePrinting();
|
|
1281
1334
|
const finishPrintingTask = useStartPrintingTask();
|
|
1282
|
-
const [isNull = true, controller] = useFormattedValue(path.append(AbsolutePathFragment.RecursiveWildcard), {
|
|
1335
|
+
const [isNull = true, controller] = useFormattedValue(typeof itemTitle === "function" || typeof title === "function" || typeof subtitle === "function" || typeof documentTitle === "function" ? path.append(AbsolutePathFragment.RecursiveWildcard) : path, {
|
|
1283
1336
|
enabled: !useFormIsLoading(),
|
|
1284
1337
|
onInitialized: finishPrintingTask,
|
|
1285
1338
|
format: useCallback((value) => value === null, [])
|
|
@@ -1347,7 +1400,7 @@ function RepetitiveAnnexRegistrar({ path, maxAnnexes, ...annexProps }) {
|
|
|
1347
1400
|
const [rowIds, controller] = useFormattedValue(path.parent(), {
|
|
1348
1401
|
enabled: !useFormIsLoading(),
|
|
1349
1402
|
onInitialized: finishPrintingTask,
|
|
1350
|
-
format: useCallback((value) => value
|
|
1403
|
+
format: useCallback((value) => value ? tableIdsToArray(value) : [], [])
|
|
1351
1404
|
});
|
|
1352
1405
|
const schema = controller.useSchema();
|
|
1353
1406
|
const absolutePath = controller.usePath();
|
|
@@ -1387,23 +1440,55 @@ function RepetitiveAnnexRegistrar({ path, maxAnnexes, ...annexProps }) {
|
|
|
1387
1440
|
}
|
|
1388
1441
|
//#endregion
|
|
1389
1442
|
//#region src/components/Annexes/Annexes.tsx
|
|
1390
|
-
/**
|
|
1391
|
-
|
|
1443
|
+
/**
|
|
1444
|
+
* The annexes component can be used to split parts of a form into separate
|
|
1445
|
+
* annexes (tabs), while providing means of managing and navigating between
|
|
1446
|
+
* them. Although not strictly mandatory, each annex (tab) is typically
|
|
1447
|
+
* represented by its own class, with its own schema and distinct path.
|
|
1448
|
+
*
|
|
1449
|
+
* It further supports optional annexes (via
|
|
1450
|
+
* [nullable](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-nullable-schema/index.html)
|
|
1451
|
+
* schemas), as well as repetitive ones (via schemas of type
|
|
1452
|
+
* [`ListSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-list-schema/index.html)
|
|
1453
|
+
* or
|
|
1454
|
+
* [`TableSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-table-schema/index.html)).
|
|
1455
|
+
*
|
|
1456
|
+
* The following built-in KForm validations affect annexes:
|
|
1457
|
+
*
|
|
1458
|
+
* - [`Size`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-size/index.html)/[`MaxSize`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-max-size/index.html):
|
|
1459
|
+
* Sets the `maxAnnexes` property of repetitive annexes.
|
|
1460
|
+
*
|
|
1461
|
+
* It composes the following subcomponents:
|
|
1462
|
+
*
|
|
1463
|
+
* - `AnnexesManager`: Component used to manage and navigate between annexes
|
|
1464
|
+
* (tabs).
|
|
1465
|
+
* - `Annex`: Content of a single annex (tab) of the form.
|
|
1466
|
+
*
|
|
1467
|
+
* Example usage:
|
|
1468
|
+
*
|
|
1469
|
+
* ```tsx
|
|
1470
|
+
* import { Annex, Annexes, AnnexesManager } from "@ostack.tech/ui-kform";
|
|
1471
|
+
*
|
|
1472
|
+
* function TaxDeclarationsAnnexes() {
|
|
1473
|
+
* return (
|
|
1474
|
+
* <Annexes>
|
|
1475
|
+
* <AnnexesManager />
|
|
1476
|
+
* <Annex path="/cover" title="Cover" subtitle="Income sources">
|
|
1477
|
+
* Cover content…
|
|
1478
|
+
* </Annex>
|
|
1479
|
+
* <Annex path="/annexA" title="Annex A" subtitle="Foreign assets">
|
|
1480
|
+
* Annex A content…
|
|
1481
|
+
* </Annex>
|
|
1482
|
+
* </Annexes>
|
|
1483
|
+
* );
|
|
1484
|
+
* }
|
|
1485
|
+
* ```
|
|
1486
|
+
*/
|
|
1487
|
+
function Annexes({ path, annexes, defaultActiveAnnex, activeAnnex, onActiveAnnexChange, onAnnexAdd, onAnnexRemove, variant = "annexes", className, children, ...otherProps }) {
|
|
1392
1488
|
const prefix = usePrefix();
|
|
1393
1489
|
const formManager = useFormManager();
|
|
1394
1490
|
const absolutePath = useResolvedPath(path);
|
|
1395
|
-
annexes ??=
|
|
1396
|
-
path: annex.props.path,
|
|
1397
|
-
title: annex.props.title,
|
|
1398
|
-
subtitle: annex.props.subtitle,
|
|
1399
|
-
description: annex.props.description,
|
|
1400
|
-
issuesPanelLabel: annex.props.issuesPanelLabel,
|
|
1401
|
-
itemTitle: annex.props.itemTitle,
|
|
1402
|
-
itemIssuesPanelLabel: annex.props.itemIssuesPanelLabel,
|
|
1403
|
-
documentTitle: annex.props.documentTitle,
|
|
1404
|
-
maxAnnexes: annex.props.maxAnnexes,
|
|
1405
|
-
getValue: annex.props.getValue
|
|
1406
|
-
}));
|
|
1491
|
+
annexes ??= parseChildren(children, Annex, { renderUnknownComponents: false });
|
|
1407
1492
|
const resolvedAnnexes = useMemo(() => annexes.map((annex) => ({
|
|
1408
1493
|
...annex,
|
|
1409
1494
|
path: absolutePath.resolve(annex.path ?? Path.CURRENT)
|
|
@@ -1438,12 +1523,11 @@ var Annexes = forwardRef(function Annexes({ path, annexes, defaultActiveAnnex, a
|
|
|
1438
1523
|
onValueChange: handleValueChange,
|
|
1439
1524
|
showAllTabsWhilePrinting: true,
|
|
1440
1525
|
...otherProps,
|
|
1441
|
-
ref: forwardedRef,
|
|
1442
1526
|
children
|
|
1443
1527
|
})]
|
|
1444
1528
|
})
|
|
1445
1529
|
});
|
|
1446
|
-
}
|
|
1530
|
+
}
|
|
1447
1531
|
//#endregion
|
|
1448
1532
|
//#region src/utils/useReportValidationFailures.ts
|
|
1449
1533
|
var ValidationFailureError = class extends AtPathError {
|
|
@@ -1533,7 +1617,7 @@ function useRegisterControllerWithinControlField(controller, deferredIssuesToDis
|
|
|
1533
1617
|
* Aria descriptions and error messages are set on the control based on the
|
|
1534
1618
|
* provided helper texts or feedbacks.
|
|
1535
1619
|
*/
|
|
1536
|
-
|
|
1620
|
+
function ControlField({ path = Path.CURRENT, shown = true, resetOnHide = true, setUntouchedOnHide = resetOnHide, setPristineOnHide = resetOnHide, ...otherProps }) {
|
|
1537
1621
|
const formManager = useFormManager();
|
|
1538
1622
|
const store = useCreateControlFieldContext();
|
|
1539
1623
|
const controlStates = useStore(store, (state) => state.controlStates);
|
|
@@ -1559,13 +1643,10 @@ var ControlField = forwardRef(function ControlField({ path = Path.CURRENT, shown
|
|
|
1559
1643
|
path,
|
|
1560
1644
|
children: /* @__PURE__ */ jsx(ControlFieldContext.Provider, {
|
|
1561
1645
|
value: store,
|
|
1562
|
-
children: /* @__PURE__ */ jsx(Field, {
|
|
1563
|
-
...otherProps,
|
|
1564
|
-
ref: forwardedRef
|
|
1565
|
-
})
|
|
1646
|
+
children: /* @__PURE__ */ jsx(Field, { ...otherProps })
|
|
1566
1647
|
})
|
|
1567
1648
|
});
|
|
1568
|
-
}
|
|
1649
|
+
}
|
|
1569
1650
|
//#endregion
|
|
1570
1651
|
//#region src/components/IssueMessages/IssueMessages.tsx
|
|
1571
1652
|
/**
|
|
@@ -1581,7 +1662,7 @@ var ControlField = forwardRef(function ControlField({ path = Path.CURRENT, shown
|
|
|
1581
1662
|
* If `path` contains an issue without an associated issue message, a generic
|
|
1582
1663
|
* message is displayed together with a console warning.
|
|
1583
1664
|
*/
|
|
1584
|
-
|
|
1665
|
+
function IssueMessages({ path, issues, messages, displayIssueCodes, messagesDataKey, visuallyHiddenErrorCodePrefix, visuallyHiddenWarningCodePrefix, unknownErrorMessage, unknownWarningMessage, unwrapped, ...otherProps }) {
|
|
1585
1666
|
const prefix = usePrefix();
|
|
1586
1667
|
const isInControlField = useIsInControlField();
|
|
1587
1668
|
const formManager = useFormManager();
|
|
@@ -1635,39 +1716,36 @@ var IssueMessages = forwardRef(function IssueMessages({ path, issues, messages,
|
|
|
1635
1716
|
issueMessages: messagesToRegister,
|
|
1636
1717
|
children: unwrapped ? feedbackNodes : /* @__PURE__ */ jsx(FeedbackList, {
|
|
1637
1718
|
...otherProps,
|
|
1638
|
-
ref: forwardedRef,
|
|
1639
1719
|
children: feedbackNodes
|
|
1640
1720
|
})
|
|
1641
1721
|
});
|
|
1642
|
-
}
|
|
1722
|
+
}
|
|
1643
1723
|
//#endregion
|
|
1644
1724
|
//#region src/components/IssuesPopover/IssuesPopover.tsx
|
|
1645
1725
|
/** Component used to display issues within a popover. */
|
|
1646
|
-
|
|
1726
|
+
function IssuesPopover({ path, relevantPaths, defaultOpen, open: controlledOpen, onOpenChange, label, ...otherProps }) {
|
|
1647
1727
|
const [locale] = useLocale();
|
|
1648
1728
|
label ??= locale.IssuesPopover.label;
|
|
1649
1729
|
const absolutePath = useResolvedPath(path);
|
|
1650
1730
|
const [open, setOpen] = useControllableState(defaultOpen, controlledOpen);
|
|
1651
1731
|
const isInControlField = useIsInControlField();
|
|
1652
1732
|
useOnPathFocus(useCallback((focusedPath) => {
|
|
1653
|
-
if (
|
|
1733
|
+
if ((relevantPaths ?? [absolutePath]).some((path) => focusedPath.equals(new AbsolutePath(path)))) setOpen(true);
|
|
1654
1734
|
}, [
|
|
1655
|
-
isInControlField,
|
|
1656
1735
|
relevantPaths,
|
|
1657
1736
|
absolutePath,
|
|
1658
1737
|
setOpen
|
|
1659
|
-
]));
|
|
1738
|
+
]), { enabled: !isInControlField });
|
|
1660
1739
|
return /* @__PURE__ */ jsx(CurrentPath, {
|
|
1661
1740
|
path: absolutePath,
|
|
1662
1741
|
children: /* @__PURE__ */ jsx(FeedbackPopover, {
|
|
1663
1742
|
open,
|
|
1664
1743
|
onOpenChange: combineEventHandlers(onOpenChange, setOpen),
|
|
1665
1744
|
label,
|
|
1666
|
-
...otherProps
|
|
1667
|
-
ref: forwardedRef
|
|
1745
|
+
...otherProps
|
|
1668
1746
|
})
|
|
1669
1747
|
});
|
|
1670
|
-
}
|
|
1748
|
+
}
|
|
1671
1749
|
//#endregion
|
|
1672
1750
|
//#region src/utils/displayStatusConversions.ts
|
|
1673
1751
|
/** Transforms ostack/KForm's display status into ostack/UI's control status. */
|
|
@@ -1687,6 +1765,17 @@ function displayStatusToColor(displayStatus) {
|
|
|
1687
1765
|
}
|
|
1688
1766
|
}
|
|
1689
1767
|
//#endregion
|
|
1768
|
+
//#region src/utils/promiseUtils.ts
|
|
1769
|
+
/**
|
|
1770
|
+
* Whether a given value is [promise-like]{@link PromiseLike}.
|
|
1771
|
+
*
|
|
1772
|
+
* @param value Value to check if it is promise-like.
|
|
1773
|
+
* @returns Whether the provided value is like a promise.
|
|
1774
|
+
*/
|
|
1775
|
+
function isPromiseLike(value) {
|
|
1776
|
+
return typeof value?.then === "function";
|
|
1777
|
+
}
|
|
1778
|
+
//#endregion
|
|
1690
1779
|
//#region src/components/TopBar/TopBarContext.tsx
|
|
1691
1780
|
/** Context of the top bar component. */
|
|
1692
1781
|
var TopBarContext = createContext(null);
|
|
@@ -1697,13 +1786,13 @@ function useTopBarElement() {
|
|
|
1697
1786
|
//#endregion
|
|
1698
1787
|
//#region src/components/TopBar/TopBar.tsx
|
|
1699
1788
|
/** Top bar component. */
|
|
1700
|
-
|
|
1789
|
+
function TopBar({ className, ref, ...otherProps }) {
|
|
1701
1790
|
const prefix = usePrefix();
|
|
1702
1791
|
const { printHidden } = usePrintClassNames();
|
|
1703
1792
|
const setTopBarHeight = useSetTopBarHeight();
|
|
1704
1793
|
const [topBarEl, setTopBarEl] = useState(null);
|
|
1705
1794
|
useMeasure(topBarEl, useCallback((measurement) => setTopBarHeight(measurement?.height), [setTopBarHeight]));
|
|
1706
|
-
const combinedTopBarRef = useCombinedRef(setTopBarEl,
|
|
1795
|
+
const combinedTopBarRef = useCombinedRef(setTopBarEl, ref);
|
|
1707
1796
|
return /* @__PURE__ */ jsx(TopBarContext.Provider, {
|
|
1708
1797
|
value: { topBarEl },
|
|
1709
1798
|
children: /* @__PURE__ */ jsx(Layer, {
|
|
@@ -1715,11 +1804,11 @@ var TopBar = forwardRef(function TopBar({ className, ...otherProps }, forwardedR
|
|
|
1715
1804
|
})
|
|
1716
1805
|
})
|
|
1717
1806
|
});
|
|
1718
|
-
}
|
|
1807
|
+
}
|
|
1719
1808
|
//#endregion
|
|
1720
1809
|
//#region src/components/TopBar/TopBarActions.tsx
|
|
1721
1810
|
/** Container used to display actions within the top bar. */
|
|
1722
|
-
|
|
1811
|
+
function TopBarActions({ className, children, ...otherProps }) {
|
|
1723
1812
|
const prefix = usePrefix();
|
|
1724
1813
|
const issuesDisplayMode = useIssuesDisplayMode();
|
|
1725
1814
|
return /* @__PURE__ */ jsxs(Stack, {
|
|
@@ -1728,10 +1817,9 @@ var TopBarActions = forwardRef(function TopBarActions({ className, children, ...
|
|
|
1728
1817
|
gap: 2,
|
|
1729
1818
|
justifyContent: "flex-end",
|
|
1730
1819
|
...otherProps,
|
|
1731
|
-
ref: forwardedRef,
|
|
1732
1820
|
children: [issuesDisplayMode === "inline" && /* @__PURE__ */ jsx(IssuesPopover, { children: /* @__PURE__ */ jsx(IssueMessages, {}) }), children]
|
|
1733
1821
|
});
|
|
1734
|
-
}
|
|
1822
|
+
}
|
|
1735
1823
|
//#endregion
|
|
1736
1824
|
//#region src/components/Annexes/AnnexesMenu.tsx
|
|
1737
1825
|
/** Component that allows to navigate between, add, and remove annexes. */
|
|
@@ -1934,11 +2022,15 @@ function AnnexesMenuNewItem({ annex, addedAnnexPathRef }) {
|
|
|
1934
2022
|
const schema = formManager.schema(annex.path);
|
|
1935
2023
|
const initialValue = schema.typeInfo.nullable ? nullableSchemaInnerSchema(schema).initialValue : schema.initialValue;
|
|
1936
2024
|
let toAdd = initialValue;
|
|
1937
|
-
if (annex.getValue)
|
|
2025
|
+
if (annex.getValue) {
|
|
2026
|
+
const clonedValue = await schema.clone(initialValue);
|
|
1938
2027
|
setGettingValue(true);
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
2028
|
+
try {
|
|
2029
|
+
const getValueResult = annex.getValue(clonedValue);
|
|
2030
|
+
toAdd = isPromiseLike(getValueResult) ? await getValueResult : getValueResult;
|
|
2031
|
+
} finally {
|
|
2032
|
+
setGettingValue(false);
|
|
2033
|
+
}
|
|
1942
2034
|
}
|
|
1943
2035
|
if (toAdd == null) return;
|
|
1944
2036
|
addedAnnexPathRef.current = await store.getState().actions.addAnnex(annex.path, toAdd);
|
|
@@ -2045,7 +2137,7 @@ function AnnexTab({ path }) {
|
|
|
2045
2137
|
//#endregion
|
|
2046
2138
|
//#region src/components/Annexes/AnnexesTabList.tsx
|
|
2047
2139
|
/** List of annex tabs. */
|
|
2048
|
-
|
|
2140
|
+
function AnnexesTabList({ hideNonActiveOnSmallScreens, rootProps, className, ...otherProps }) {
|
|
2049
2141
|
const prefix = usePrefix();
|
|
2050
2142
|
const store = useAnnexesContext();
|
|
2051
2143
|
const activeAnnex = useStore(store, (state) => state.activeAnnex);
|
|
@@ -2053,15 +2145,14 @@ var AnnexesTabList = forwardRef(function AnnexManager({ hideNonActiveOnSmallScre
|
|
|
2053
2145
|
const isLargeScreen = useMediaBreakpointUp("sm");
|
|
2054
2146
|
return /* @__PURE__ */ jsx(TabList, {
|
|
2055
2147
|
className: cx(prefix("annexes__tab-list"), className),
|
|
2056
|
-
...otherProps,
|
|
2057
2148
|
rootProps: {
|
|
2058
2149
|
...rootProps,
|
|
2059
2150
|
className: cx(prefix("annexes__tab-list-root"), rootProps?.className)
|
|
2060
2151
|
},
|
|
2061
|
-
|
|
2152
|
+
...otherProps,
|
|
2062
2153
|
children: tabStates.map((state) => !hideNonActiveOnSmallScreens || isLargeScreen || state.path.equals(activeAnnex) ? /* @__PURE__ */ jsx(AnnexTab, { ...state }, state.path.toString()) : null)
|
|
2063
2154
|
});
|
|
2064
|
-
}
|
|
2155
|
+
}
|
|
2065
2156
|
//#endregion
|
|
2066
2157
|
//#region src/components/Annexes/AnnexesManager.tsx
|
|
2067
2158
|
/**
|
|
@@ -2069,7 +2160,7 @@ var AnnexesTabList = forwardRef(function AnnexManager({ hideNonActiveOnSmallScre
|
|
|
2069
2160
|
* changing, adding, and removing annexes, as well as a list of tabs for each
|
|
2070
2161
|
* existing annex.
|
|
2071
2162
|
*/
|
|
2072
|
-
|
|
2163
|
+
function AnnexesManager({ showMenu, menuButtonText, menuButtonLabel, addAnnexText, removeAnnexButtonLabel, removeAnnexKeyboardHint, removeAnnexConfirmDialogTitle, removeAnnexConfirmDialogMessage, removeAnnexConfirmDialogOkText, removeAnnexConfirmDialogCancelText, className, "aria-label": ariaLabel, menuContainerProps, menuTriggerProps, menuContentProps, menuProps, tabListContainerProps, tabListProps, ref, ...otherProps }) {
|
|
2073
2164
|
const prefix = usePrefix();
|
|
2074
2165
|
const [locale] = useLocale();
|
|
2075
2166
|
ariaLabel ??= locale.AnnexesManager["aria-label"];
|
|
@@ -2091,7 +2182,7 @@ var AnnexesManager = forwardRef(function AnnexManager({ menuButtonText, menuButt
|
|
|
2091
2182
|
const hasIssues = useMemo(() => deferredTablessIssuesToDisplay.some((issues) => issues.length > 0), [deferredTablessIssuesToDisplay]);
|
|
2092
2183
|
const hasErrors = useMemo(() => deferredTablessIssuesToDisplay.some((issues) => issues.some((issue) => issue.severity === "error")), [deferredTablessIssuesToDisplay]);
|
|
2093
2184
|
const formManager = useFormManager();
|
|
2094
|
-
const
|
|
2185
|
+
const shouldShowMenu = useStore(store, (state) => showMenu ?? state.annexes.some((annex) => annex.path.lastFragment === AbsolutePathFragment.Wildcard || formManager.schema(annex.path).typeInfo.nullable));
|
|
2095
2186
|
const generatedId = useId();
|
|
2096
2187
|
const menuContentId = menuContentProps?.id ?? prefix(`annexes-menu-content-${generatedId}`);
|
|
2097
2188
|
const handleAnnexesMenuOpenChange = useCallback((open) => {
|
|
@@ -2126,14 +2217,14 @@ var AnnexesManager = forwardRef(function AnnexManager({ menuButtonText, menuButt
|
|
|
2126
2217
|
unwrapped: true
|
|
2127
2218
|
}, state.path.toString()))
|
|
2128
2219
|
});
|
|
2129
|
-
const combinedManagerRef = useCombinedRef(managerRef,
|
|
2220
|
+
const combinedManagerRef = useCombinedRef(managerRef, ref);
|
|
2130
2221
|
return /* @__PURE__ */ jsxs("nav", {
|
|
2131
2222
|
className: cx(prefix("annexes__manager"), className),
|
|
2132
2223
|
"aria-label": ariaLabel,
|
|
2133
2224
|
...otherProps,
|
|
2134
2225
|
ref: combinedManagerRef,
|
|
2135
2226
|
children: [
|
|
2136
|
-
|
|
2227
|
+
shouldShowMenu && /* @__PURE__ */ jsx("div", {
|
|
2137
2228
|
...menuContainerProps,
|
|
2138
2229
|
className: cx(prefix("annexes__menu-container"), menuContainerProps?.className),
|
|
2139
2230
|
children: /* @__PURE__ */ jsx(AnnexesMenu, {
|
|
@@ -2147,7 +2238,7 @@ var AnnexesManager = forwardRef(function AnnexManager({ menuButtonText, menuButt
|
|
|
2147
2238
|
removeAnnexConfirmDialogOkText,
|
|
2148
2239
|
removeAnnexConfirmDialogCancelText,
|
|
2149
2240
|
...menuProps,
|
|
2150
|
-
onOpenChange: combineEventHandlers(
|
|
2241
|
+
onOpenChange: combineEventHandlers(menuProps?.onOpenChange, handleAnnexesMenuOpenChange),
|
|
2151
2242
|
menuTriggerProps: {
|
|
2152
2243
|
"aria-invalid": hasErrors || void 0,
|
|
2153
2244
|
...menuTriggerProps,
|
|
@@ -2161,8 +2252,8 @@ var AnnexesManager = forwardRef(function AnnexManager({ menuButtonText, menuButt
|
|
|
2161
2252
|
}
|
|
2162
2253
|
})
|
|
2163
2254
|
}),
|
|
2164
|
-
|
|
2165
|
-
|
|
2255
|
+
shouldShowMenu && issuesDisplayMode === "panel" && hasIssues && feedbackList,
|
|
2256
|
+
shouldShowMenu && issuesDisplayMode === "inline" && /* @__PURE__ */ jsx(IssuesPopover, {
|
|
2166
2257
|
open: hasIssues && (menuTriggerFocused || issuesPopoverOpen),
|
|
2167
2258
|
onOpenChange: setIssuesPopoverOpen,
|
|
2168
2259
|
onOpenAutoFocus: handleIssuesPopoverOpenAutoFocus,
|
|
@@ -2175,30 +2266,20 @@ var AnnexesManager = forwardRef(function AnnexManager({ menuButtonText, menuButt
|
|
|
2175
2266
|
...tabListContainerProps,
|
|
2176
2267
|
className: cx(prefix("annexes__tab-list-container"), tabListContainerProps?.className),
|
|
2177
2268
|
children: /* @__PURE__ */ jsx(AnnexesTabList, {
|
|
2178
|
-
hideNonActiveOnSmallScreens:
|
|
2269
|
+
hideNonActiveOnSmallScreens: shouldShowMenu,
|
|
2179
2270
|
...tabListProps
|
|
2180
2271
|
})
|
|
2181
2272
|
})
|
|
2182
2273
|
]
|
|
2183
2274
|
});
|
|
2184
|
-
}
|
|
2275
|
+
}
|
|
2185
2276
|
//#endregion
|
|
2186
2277
|
//#region src/utils/useControlIssues.tsx
|
|
2187
|
-
/**
|
|
2188
|
-
|
|
2189
|
-
*
|
|
2190
|
-
* This hook returns a pair containing two React nodes:
|
|
2191
|
-
*
|
|
2192
|
-
* - The first element of the pair contains the node that should be rendered when
|
|
2193
|
-
* the issues are to appear inline. This will be `null` if the issues should
|
|
2194
|
-
* not appear inline.
|
|
2195
|
-
* - The second element of the pair contains the node that should be rendered when
|
|
2196
|
-
* the issues are to appear within a popover. This will be `null` if the
|
|
2197
|
-
* issues should not appear in a popover.
|
|
2198
|
-
*/
|
|
2199
|
-
function useControlIssues({ issuesToDisplay, issueMessages, displayIssues = true, issueMessagesProps }) {
|
|
2278
|
+
/** Hook which helps a control component render its issues. */
|
|
2279
|
+
function useControlIssues({ issuesToDisplay, issueMessages, displayIssues = true, issueMessagesProps, variant }) {
|
|
2200
2280
|
const issuesDisplayMode = useIssuesDisplayMode();
|
|
2201
2281
|
const isInTableCell = useIsInTableCell();
|
|
2282
|
+
const showInPopover = variant === "cell" || variant === void 0 && isInTableCell;
|
|
2202
2283
|
const { displayIssueCodes, unknownErrorMessage, unknownWarningMessage, ...feedbackListProps } = issueMessagesProps ?? {};
|
|
2203
2284
|
const issuesNode = displayIssues && /* @__PURE__ */ jsx(FeedbackList, {
|
|
2204
2285
|
...feedbackListProps,
|
|
@@ -2213,8 +2294,14 @@ function useControlIssues({ issuesToDisplay, issueMessages, displayIssues = true
|
|
|
2213
2294
|
unwrapped: true
|
|
2214
2295
|
}, i))
|
|
2215
2296
|
});
|
|
2216
|
-
if (issuesDisplayMode === "panel") return
|
|
2217
|
-
|
|
2297
|
+
if (issuesDisplayMode === "panel") return {
|
|
2298
|
+
inlineIssues: issuesNode,
|
|
2299
|
+
popoverIssues: null
|
|
2300
|
+
};
|
|
2301
|
+
return {
|
|
2302
|
+
inlineIssues: showInPopover ? null : issuesNode,
|
|
2303
|
+
popoverIssues: showInPopover ? /* @__PURE__ */ jsx(IssuesPopover, { children: issuesNode }) : null
|
|
2304
|
+
};
|
|
2218
2305
|
}
|
|
2219
2306
|
//#endregion
|
|
2220
2307
|
//#region src/utils/useRegisterControl.tsx
|
|
@@ -2272,19 +2359,163 @@ function useRegisterControl({ controller, issuesPanelLabel, ariaLabel, issuesPan
|
|
|
2272
2359
|
/** Hook used to register a label for all control field's controls. */
|
|
2273
2360
|
function useRegisterFieldLabel(path, issuesPanelLabelSuffix) {
|
|
2274
2361
|
const { store: formAppStore } = useFormAppContext();
|
|
2275
|
-
|
|
2362
|
+
useOnLabelChange(useCallback((label) => formAppStore.getState().actions.registerLabel(path, label && issuesPanelLabelSuffix ? /* @__PURE__ */ jsxs(Fragment, { children: [label, issuesPanelLabelSuffix] }) : label), [
|
|
2276
2363
|
formAppStore,
|
|
2277
2364
|
issuesPanelLabelSuffix,
|
|
2278
2365
|
path
|
|
2279
2366
|
]));
|
|
2280
2367
|
}
|
|
2281
2368
|
//#endregion
|
|
2369
|
+
//#region src/components/DebugInfo/DebugInfo.tsx
|
|
2370
|
+
/** Debug information. */
|
|
2371
|
+
function DebugInfo({ defaultOpen, open, onOpenChange, path = Path.CURRENT_DEEP, format = defaultFormat, children, label, ...otherProps }) {
|
|
2372
|
+
const [locale] = useLocale();
|
|
2373
|
+
label ??= locale.DebugInfo?.label;
|
|
2374
|
+
const spacing = useSpacing();
|
|
2375
|
+
const { cssVar } = useCssVars();
|
|
2376
|
+
const printing = usePrinting();
|
|
2377
|
+
const empty = /* @__PURE__ */ jsx("span", {
|
|
2378
|
+
style: { color: cssVar("neutral-a9") },
|
|
2379
|
+
children: "—"
|
|
2380
|
+
});
|
|
2381
|
+
if (printing) return null;
|
|
2382
|
+
return /* @__PURE__ */ jsxs(Popover, {
|
|
2383
|
+
defaultOpen,
|
|
2384
|
+
open,
|
|
2385
|
+
onOpenChange,
|
|
2386
|
+
children: [/* @__PURE__ */ jsx(PopoverTrigger, { children: children ?? /* @__PURE__ */ jsx(IconButton, {
|
|
2387
|
+
icon: faBug,
|
|
2388
|
+
color: "danger",
|
|
2389
|
+
variant: "ghost",
|
|
2390
|
+
label,
|
|
2391
|
+
...otherProps
|
|
2392
|
+
}) }), /* @__PURE__ */ jsx(PopoverContent, {
|
|
2393
|
+
style: { width: 550 },
|
|
2394
|
+
children: /* @__PURE__ */ jsx(FormattedValue, {
|
|
2395
|
+
path,
|
|
2396
|
+
format,
|
|
2397
|
+
children: ({ schema, path, observingDescendants, initialized, formattedValue, dirty, touched, issues, validationStatus, displayStatus }) => initialized ? /* @__PURE__ */ jsxs(DescriptionList, {
|
|
2398
|
+
gap: 3,
|
|
2399
|
+
style: { margin: spacing(-1, 1, 3) },
|
|
2400
|
+
children: [
|
|
2401
|
+
/* @__PURE__ */ jsx(DescriptionListItem, {
|
|
2402
|
+
xs: 6,
|
|
2403
|
+
term: "Path",
|
|
2404
|
+
children: /* @__PURE__ */ jsx(Code, { children: (observingDescendants ? path.append(AbsolutePathFragment.RecursiveWildcard) : path).toString() })
|
|
2405
|
+
}),
|
|
2406
|
+
/* @__PURE__ */ jsx(DescriptionListItem, {
|
|
2407
|
+
xs: 6,
|
|
2408
|
+
term: "Schema type",
|
|
2409
|
+
children: /* @__PURE__ */ jsx(Code, { children: schema.typeInfo.toString() })
|
|
2410
|
+
}),
|
|
2411
|
+
/* @__PURE__ */ jsx(DescriptionListItem, {
|
|
2412
|
+
xs: 6,
|
|
2413
|
+
term: "Validations",
|
|
2414
|
+
children: schema.validations.length > 0 ? schema.validations.map((validation, i) => /* @__PURE__ */ jsxs(Fragment$1, { children: [i !== 0 && ", ", /* @__PURE__ */ jsx(Code, { children: validation.toString() })] }, i)) : empty
|
|
2415
|
+
}),
|
|
2416
|
+
/* @__PURE__ */ jsx(DescriptionListItem, {
|
|
2417
|
+
xs: 6,
|
|
2418
|
+
term: "Value",
|
|
2419
|
+
children: /* @__PURE__ */ jsx(Code, { children: formattedValue })
|
|
2420
|
+
}),
|
|
2421
|
+
/* @__PURE__ */ jsx(DescriptionListItem, {
|
|
2422
|
+
xs: 6,
|
|
2423
|
+
term: "Dirty",
|
|
2424
|
+
children: /* @__PURE__ */ jsx(Code, { children: JSON.stringify(dirty) })
|
|
2425
|
+
}),
|
|
2426
|
+
/* @__PURE__ */ jsx(DescriptionListItem, {
|
|
2427
|
+
xs: 6,
|
|
2428
|
+
term: "Touched",
|
|
2429
|
+
children: /* @__PURE__ */ jsx(Code, { children: JSON.stringify(touched) })
|
|
2430
|
+
}),
|
|
2431
|
+
/* @__PURE__ */ jsx(DescriptionListItem, {
|
|
2432
|
+
xs: 6,
|
|
2433
|
+
term: "Issues",
|
|
2434
|
+
children: issues && issues.length > 0 ? issues.map((issue, i) => /* @__PURE__ */ jsxs(Fragment$1, { children: [i !== 0 && ", ", /* @__PURE__ */ jsx(Code, {
|
|
2435
|
+
color: issue.severity === "error" ? "danger" : "warning",
|
|
2436
|
+
children: issue.code
|
|
2437
|
+
})] }, i)) : empty
|
|
2438
|
+
}),
|
|
2439
|
+
/* @__PURE__ */ jsx(DescriptionListItem, {
|
|
2440
|
+
xs: 6,
|
|
2441
|
+
term: "Validation status",
|
|
2442
|
+
children: /* @__PURE__ */ jsx(Code, { children: validationStatus })
|
|
2443
|
+
}),
|
|
2444
|
+
/* @__PURE__ */ jsx(DescriptionListItem, {
|
|
2445
|
+
xs: 6,
|
|
2446
|
+
term: "Display status",
|
|
2447
|
+
children: /* @__PURE__ */ jsx(Code, {
|
|
2448
|
+
color: displayStatusToColor(displayStatus),
|
|
2449
|
+
children: displayStatus
|
|
2450
|
+
})
|
|
2451
|
+
})
|
|
2452
|
+
]
|
|
2453
|
+
}) : /* @__PURE__ */ jsx(Spinner, {})
|
|
2454
|
+
})
|
|
2455
|
+
})]
|
|
2456
|
+
});
|
|
2457
|
+
}
|
|
2458
|
+
/** Default format function. */
|
|
2459
|
+
function defaultFormat(value) {
|
|
2460
|
+
if (value === void 0) return "undefined";
|
|
2461
|
+
if (value === null) return "null";
|
|
2462
|
+
if (typeof value === "string") return JSON.stringify(value);
|
|
2463
|
+
if (isKtList(value)) return `[${value.asJsReadonlyArrayView().map(defaultFormat).join(", ")}]`;
|
|
2464
|
+
if (isTable(value)) return `[${tableRowsToArray(value).map(([id, v]) => `${id}=${defaultFormat(v)}`).join(", ")}]`;
|
|
2465
|
+
if (typeof value === "object" && [null, Object.prototype].includes(Object.getPrototypeOf(value))) return `{${Object.entries(value).map(([k, v]) => `${k}: ${defaultFormat(v)}`).join(", ")}}`;
|
|
2466
|
+
return String(value);
|
|
2467
|
+
}
|
|
2468
|
+
//#endregion
|
|
2469
|
+
//#region src/components/DebugInfo/DebugInfoControlAddonTrigger.tsx
|
|
2470
|
+
/** Debug info trigger as a control addon. */
|
|
2471
|
+
function DebugInfoControlAddonTrigger({ label, ...otherProps }) {
|
|
2472
|
+
const [locale] = useLocale();
|
|
2473
|
+
label ??= locale.DebugInfo?.label;
|
|
2474
|
+
return /* @__PURE__ */ jsx(Tooltip, {
|
|
2475
|
+
content: label,
|
|
2476
|
+
children: /* @__PURE__ */ jsx(ControlAddon, {
|
|
2477
|
+
as: "button",
|
|
2478
|
+
...otherProps,
|
|
2479
|
+
"aria-describedby": void 0,
|
|
2480
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
2481
|
+
icon: faBug,
|
|
2482
|
+
label,
|
|
2483
|
+
color: "danger"
|
|
2484
|
+
})
|
|
2485
|
+
})
|
|
2486
|
+
});
|
|
2487
|
+
}
|
|
2488
|
+
//#endregion
|
|
2282
2489
|
//#region src/components/CheckboxControl/CheckboxControl.tsx
|
|
2283
2490
|
/**
|
|
2284
|
-
*
|
|
2285
|
-
*
|
|
2491
|
+
* The checkbox control component is a KForm form control for values with
|
|
2492
|
+
* (possibly
|
|
2493
|
+
* [nullable](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-nullable-schema/index.html))
|
|
2494
|
+
* schemas of type
|
|
2495
|
+
* [`BooleanSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-boolean-schema/index.html).
|
|
2496
|
+
* It is built on top of the [`Checkbox`](/docs/ostack-ui-forms-checkbox--docs)
|
|
2497
|
+
* component.
|
|
2498
|
+
*
|
|
2499
|
+
* The following built-in KForm validation affects this control:
|
|
2500
|
+
*
|
|
2501
|
+
* - [`Required`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-required/index.html):
|
|
2502
|
+
* Sets the `required` property.
|
|
2503
|
+
*
|
|
2504
|
+
* Example usage:
|
|
2505
|
+
*
|
|
2506
|
+
* ```tsx
|
|
2507
|
+
* import { CheckboxControl } from "@ostack.tech/ui-kform";
|
|
2508
|
+
*
|
|
2509
|
+
* function TermsControl() {
|
|
2510
|
+
* return (
|
|
2511
|
+
* <CheckboxControl path="/terms">
|
|
2512
|
+
* Accept terms and conditions
|
|
2513
|
+
* </CheckboxControl>
|
|
2514
|
+
* );
|
|
2515
|
+
* }
|
|
2516
|
+
* ```
|
|
2286
2517
|
*/
|
|
2287
|
-
|
|
2518
|
+
function CheckboxControl({ path, issueMessages, issuesPanelLabel, displayIssues = true, preventAutoFocus, apiRef, issueMessagesProps, formManager, onInitialized, onFormManagerEvent, onValueChange, onValidationStatusChange, onDisplayStatusChange, onDirtyStatusChange, onTouchedStatusChange, required, loading, showSpinner, disabled, readOnly, endAdornment, onFocus, onCheckedChange, onBlurToOutside, debug, ref, ...otherProps }) {
|
|
2288
2519
|
const [formattedValue, setFormattedValue] = useState(false);
|
|
2289
2520
|
const controller = useInput(path, {
|
|
2290
2521
|
enabled: !useFormIsLoading(),
|
|
@@ -2304,6 +2535,7 @@ var CheckboxControl = forwardRef(function CheckboxControl({ path, issueMessages,
|
|
|
2304
2535
|
const schema = useSchema();
|
|
2305
2536
|
const absolutePath = usePath();
|
|
2306
2537
|
const { restrictions } = schema.typeInfo;
|
|
2538
|
+
const showDebugInfo = useFormInDebugMode() || debug;
|
|
2307
2539
|
const { displayLoading, displayDisabled, displayReadOnly, displayStatusToDisplay, displayValidating, issuesToDisplay, autofocusRef, handleFocus } = useRegisterControl({
|
|
2308
2540
|
controller,
|
|
2309
2541
|
issuesPanelLabel,
|
|
@@ -2312,33 +2544,35 @@ var CheckboxControl = forwardRef(function CheckboxControl({ path, issueMessages,
|
|
|
2312
2544
|
apiRef
|
|
2313
2545
|
});
|
|
2314
2546
|
if (schema.typeInfo.name !== "Boolean") throw new InvalidPathError(absolutePath, `Unsupported schema: Expected schema representing (possibly nullable) booleans, but got schema representing values of type '${schema.typeInfo.toString()}'.`);
|
|
2315
|
-
const
|
|
2547
|
+
const { inlineIssues, popoverIssues } = useControlIssues({
|
|
2316
2548
|
issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },
|
|
2317
2549
|
issueMessages: { [absolutePath.toString()]: issueMessages },
|
|
2318
2550
|
displayIssues,
|
|
2319
|
-
issueMessagesProps
|
|
2551
|
+
issueMessagesProps,
|
|
2552
|
+
variant: otherProps.variant
|
|
2320
2553
|
});
|
|
2321
|
-
const combinedCheckboxRef = useCombinedRef(inputProps.ref, autofocusRef,
|
|
2322
|
-
return /* @__PURE__ */ jsxs(
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
});
|
|
2554
|
+
const combinedCheckboxRef = useCombinedRef(inputProps.ref, autofocusRef, ref);
|
|
2555
|
+
return /* @__PURE__ */ jsxs(FeedbackProvider, { children: [/* @__PURE__ */ jsx(Checkbox, {
|
|
2556
|
+
checked: formattedValue,
|
|
2557
|
+
name: inputProps.name,
|
|
2558
|
+
required: required ?? restrictions.required === true,
|
|
2559
|
+
loading: displayLoading || loading,
|
|
2560
|
+
showSpinner: displayValidating || showSpinner,
|
|
2561
|
+
disabled: displayDisabled || disabled || inputProps.disabled,
|
|
2562
|
+
readOnly: displayReadOnly || readOnly || inputProps.readOnly,
|
|
2563
|
+
status: displayStatusToControlStatus(displayStatusToDisplay),
|
|
2564
|
+
endAdornment: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2565
|
+
popoverIssues,
|
|
2566
|
+
endAdornment,
|
|
2567
|
+
(DEV || false) && showDebugInfo && /* @__PURE__ */ jsx(DebugInfo, { path: absolutePath })
|
|
2568
|
+
] }),
|
|
2569
|
+
onCheckedChange: combineEventHandlers(onCheckedChange, combineEventHandlers(inputProps.onChange, setFormattedValue)),
|
|
2570
|
+
onFocus: combineEventHandlers(onFocus, handleFocus),
|
|
2571
|
+
onBlurToOutside: combineEventHandlers(onBlurToOutside, inputProps.onBlur),
|
|
2572
|
+
...otherProps,
|
|
2573
|
+
ref: combinedCheckboxRef
|
|
2574
|
+
}), inlineIssues] });
|
|
2575
|
+
}
|
|
2342
2576
|
/** Parses a checkbox control formatted value. */
|
|
2343
2577
|
function parseCheckboxValue(formattedValue, state) {
|
|
2344
2578
|
return formattedValue === "indeterminate" ? state.schema.typeInfo.nullable ? null : state.schema.initialValue : formattedValue;
|
|
@@ -2388,14 +2622,14 @@ function formatSelectionValuesAsOptionIndices(arrayValue, options, unknownValues
|
|
|
2388
2622
|
}) ?? [];
|
|
2389
2623
|
}
|
|
2390
2624
|
/**
|
|
2391
|
-
* Transforms
|
|
2625
|
+
* Transforms selection item objects into React nodes.
|
|
2392
2626
|
*
|
|
2393
|
-
* @param
|
|
2627
|
+
* @param items Item objects.
|
|
2394
2628
|
* @returns React nodes representing the objects.
|
|
2395
2629
|
*/
|
|
2396
|
-
function
|
|
2630
|
+
function selectionItemObjectsToNodes(items) {
|
|
2397
2631
|
let optionIndex = 0;
|
|
2398
|
-
return
|
|
2632
|
+
return items.map(({ key, ...optionOrGroup }, i) => "options" in optionOrGroup ? /* @__PURE__ */ jsx(OptionsGroup, {
|
|
2399
2633
|
...optionOrGroup,
|
|
2400
2634
|
children: optionOrGroup.options.map(({ key, value, text, ...optionProps }, i) => /* @__PURE__ */ jsx(Option, {
|
|
2401
2635
|
value: optionIndex++,
|
|
@@ -2437,18 +2671,77 @@ function UnknownValue({ value, label }) {
|
|
|
2437
2671
|
] });
|
|
2438
2672
|
}
|
|
2439
2673
|
//#endregion
|
|
2674
|
+
//#region src/components/CheckboxGroupControl/CheckboxGroupControlItem.tsx
|
|
2675
|
+
/**
|
|
2676
|
+
* Definition of a checkbox group control item.
|
|
2677
|
+
*
|
|
2678
|
+
* This component doesn't actually render anything by itself; it is used by the
|
|
2679
|
+
* `CheckboxGroupControl` component to automatically create the `options`
|
|
2680
|
+
* array.
|
|
2681
|
+
*/
|
|
2682
|
+
function CheckboxGroupControlItem(_props) {
|
|
2683
|
+
return null;
|
|
2684
|
+
}
|
|
2685
|
+
//#endregion
|
|
2440
2686
|
//#region src/components/CheckboxGroupControl/CheckboxGroupControl.tsx
|
|
2441
2687
|
/**
|
|
2442
|
-
*
|
|
2443
|
-
*
|
|
2688
|
+
* The checkbox group control component is a KForm form control for values with
|
|
2689
|
+
* (possibly
|
|
2690
|
+
* [nullable](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-nullable-schema/index.html))
|
|
2691
|
+
* schemas of type
|
|
2692
|
+
* [`ListSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-list-schema/index.html)
|
|
2693
|
+
* or
|
|
2694
|
+
* [`TableSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-table-schema/index.html)
|
|
2695
|
+
* and items of any type. It is built on top of the
|
|
2696
|
+
* [`CheckboxGroup`](/docs/ostack-ui-forms-checkbox-group--docs) component.
|
|
2697
|
+
*
|
|
2698
|
+
* It composes the following subcomponent:
|
|
2699
|
+
*
|
|
2700
|
+
* - `CheckboxGroupControlItem`: Component used to define an item of the checkbox
|
|
2701
|
+
* group control.
|
|
2702
|
+
*
|
|
2703
|
+
* The following built-in KForm validations affect this control:
|
|
2704
|
+
*
|
|
2705
|
+
* - [`Required`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-required/index.html):
|
|
2706
|
+
* Sets the `required` property.
|
|
2707
|
+
* - [`Size`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-size/index.html)/[`MinSize`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-min-size/index.html)/[`MaxSize`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-max-size/index.html):
|
|
2708
|
+
* Sets the `minChecked` and/or `maxChecked` properties.
|
|
2444
2709
|
*
|
|
2445
|
-
*
|
|
2446
|
-
*
|
|
2447
|
-
*
|
|
2710
|
+
* Example usage:
|
|
2711
|
+
*
|
|
2712
|
+
* ```tsx
|
|
2713
|
+
* import {
|
|
2714
|
+
* CheckboxGroupControl,
|
|
2715
|
+
* CheckboxGroupControlItem,
|
|
2716
|
+
* } from "@ostack.tech/ui-kform";
|
|
2717
|
+
*
|
|
2718
|
+
* function SpokenLanguagesControl() {
|
|
2719
|
+
* return (
|
|
2720
|
+
* <CheckboxGroupControl path="/spokenLanguages">
|
|
2721
|
+
* <CheckboxGroupControlItem value="en">
|
|
2722
|
+
* English
|
|
2723
|
+
* </CheckboxGroupControlItem>
|
|
2724
|
+
* <CheckboxGroupControlItem value="fr">
|
|
2725
|
+
* French
|
|
2726
|
+
* </CheckboxGroupControlItem>
|
|
2727
|
+
* <CheckboxGroupControlItem value="pt">
|
|
2728
|
+
* Portuguese
|
|
2729
|
+
* </CheckboxGroupControlItem>
|
|
2730
|
+
* <CheckboxGroupControlItem value="es">
|
|
2731
|
+
* Spanish
|
|
2732
|
+
* </CheckboxGroupControlItem>
|
|
2733
|
+
* </CheckboxGroupControl>
|
|
2734
|
+
* );
|
|
2735
|
+
* }
|
|
2736
|
+
* ```
|
|
2448
2737
|
*/
|
|
2449
|
-
|
|
2738
|
+
function CheckboxGroupControl({ path, options, issueMessages, issuesPanelLabel, displayIssues = true, unknownValueLabel, preventAutoFocus, apiRef, issueMessagesProps, formManager, onInitialized, onFormManagerEvent, onValueChange, onValidationStatusChange, onDisplayStatusChange, onDirtyStatusChange, onTouchedStatusChange, required, minChecked, maxChecked, loading, showSpinner, disabled, readOnly, endAdornment, onFocus, onBlurToOutside, children, debug, ref, ...otherProps }) {
|
|
2450
2739
|
const [locale] = useLocale();
|
|
2451
2740
|
unknownValueLabel ??= locale.SelectMultipleControl.unknownValueLabel;
|
|
2741
|
+
options ??= parseChildren(children, CheckboxGroupControlItem, { transformChildObject: ({ children, ...otherProps }) => ({
|
|
2742
|
+
text: children,
|
|
2743
|
+
...otherProps
|
|
2744
|
+
}) });
|
|
2452
2745
|
const [arrayValue, setArrayValue] = useState(null);
|
|
2453
2746
|
const unknownValues = useMemo(() => getUnknownValues(arrayValue, options), [options, arrayValue]);
|
|
2454
2747
|
const formattedValue = useMemo(() => formatSelectionValuesAsOptionIndices(arrayValue, options, unknownValues), [
|
|
@@ -2474,6 +2767,7 @@ var CheckboxGroupControl = forwardRef(function CheckboxGroupControl({ path, opti
|
|
|
2474
2767
|
const schema = useSchema();
|
|
2475
2768
|
const { restrictions } = schema.typeInfo;
|
|
2476
2769
|
const absolutePath = usePath();
|
|
2770
|
+
const showDebugInfo = useFormInDebugMode() || debug;
|
|
2477
2771
|
const { displayLoading, displayDisabled, displayReadOnly, displayStatusToDisplay, displayValidating, issuesToDisplay, autofocusRef, handleFocus } = useRegisterControl({
|
|
2478
2772
|
controller,
|
|
2479
2773
|
issuesPanelLabel,
|
|
@@ -2492,45 +2786,49 @@ var CheckboxGroupControl = forwardRef(function CheckboxGroupControl({ path, opti
|
|
|
2492
2786
|
schema,
|
|
2493
2787
|
unknownValues
|
|
2494
2788
|
]);
|
|
2495
|
-
const
|
|
2789
|
+
const { inlineIssues, popoverIssues } = useControlIssues({
|
|
2496
2790
|
issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },
|
|
2497
2791
|
issueMessages: { [absolutePath.toString()]: issueMessages },
|
|
2498
2792
|
displayIssues,
|
|
2499
|
-
issueMessagesProps
|
|
2793
|
+
issueMessagesProps,
|
|
2794
|
+
variant: otherProps.variant
|
|
2500
2795
|
});
|
|
2501
|
-
const combinedCheckboxGroupRef = useCombinedRef(inputProps.ref, autofocusRef,
|
|
2502
|
-
return /* @__PURE__ */ jsxs(
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2796
|
+
const combinedCheckboxGroupRef = useCombinedRef(inputProps.ref, autofocusRef, ref);
|
|
2797
|
+
return /* @__PURE__ */ jsxs(FeedbackProvider, { children: [/* @__PURE__ */ jsxs(CheckboxGroup, {
|
|
2798
|
+
value: formattedValue,
|
|
2799
|
+
name: inputProps.name,
|
|
2800
|
+
required: required ?? restrictions.required === true,
|
|
2801
|
+
minChecked: minChecked ?? (typeof restrictions.minSize === "number" ? restrictions.minSize : void 0),
|
|
2802
|
+
maxChecked: maxChecked ?? (typeof restrictions.maxSize === "number" ? restrictions.maxSize : void 0),
|
|
2803
|
+
loading: displayLoading || loading,
|
|
2804
|
+
showSpinner: displayValidating || showSpinner,
|
|
2805
|
+
disabled: displayDisabled || disabled || inputProps.disabled,
|
|
2806
|
+
readOnly: displayReadOnly || readOnly || inputProps.readOnly,
|
|
2807
|
+
status: displayStatusToControlStatus(displayStatusToDisplay),
|
|
2808
|
+
endAdornment: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2809
|
+
popoverIssues,
|
|
2810
|
+
endAdornment,
|
|
2811
|
+
(DEV || false) && showDebugInfo && /* @__PURE__ */ jsx(DebugInfo, { path: absolutePath })
|
|
2812
|
+
] }),
|
|
2813
|
+
onValueChange: handleValueChange,
|
|
2814
|
+
onFocus: combineEventHandlers(onFocus, handleFocus),
|
|
2815
|
+
onBlurToOutside: combineEventHandlers(onBlurToOutside, inputProps.onBlur),
|
|
2816
|
+
...otherProps,
|
|
2817
|
+
ref: combinedCheckboxGroupRef,
|
|
2818
|
+
children: [unknownValues.map((v, i) => /* @__PURE__ */ jsx(Checkbox, {
|
|
2819
|
+
value: -i - 1,
|
|
2820
|
+
status: "invalid",
|
|
2821
|
+
children: /* @__PURE__ */ jsx(UnknownValue, {
|
|
2822
|
+
value: v,
|
|
2823
|
+
label: unknownValueLabel
|
|
2824
|
+
})
|
|
2825
|
+
}, i)), options.map(({ value, text, key, ...checkboxProps }, i) => /* @__PURE__ */ jsx(Checkbox, {
|
|
2826
|
+
value: i,
|
|
2827
|
+
...checkboxProps,
|
|
2828
|
+
children: text ?? value?.toString() ?? ""
|
|
2829
|
+
}, key ?? i))]
|
|
2830
|
+
}), inlineIssues] });
|
|
2831
|
+
}
|
|
2534
2832
|
//#endregion
|
|
2535
2833
|
//#region src/utils/dateRestrictions.ts
|
|
2536
2834
|
/** Returns the minimum date allowed based on a temporal schema's restrictions. */
|
|
@@ -2577,8 +2875,33 @@ function useTemporalStringTransformer(dateTransformerOptions) {
|
|
|
2577
2875
|
}
|
|
2578
2876
|
//#endregion
|
|
2579
2877
|
//#region src/components/DateControl/DateControl.tsx
|
|
2580
|
-
/**
|
|
2581
|
-
|
|
2878
|
+
/**
|
|
2879
|
+
* The date control component is a KForm form control for values with (typically
|
|
2880
|
+
* nullable) schemas of type
|
|
2881
|
+
* [`LocalDateSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-local-date-schema/index.html)
|
|
2882
|
+
* or
|
|
2883
|
+
* [`StringSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-string-schema/index.html).
|
|
2884
|
+
* It is built on top of the
|
|
2885
|
+
* [`DateInput`](/docs/ostack-ui-forms-date-input--docs) component.
|
|
2886
|
+
*
|
|
2887
|
+
* The following built-in KForm validations affect this control:
|
|
2888
|
+
*
|
|
2889
|
+
* - [`Required`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-required/index.html):
|
|
2890
|
+
* Sets the `required` property.
|
|
2891
|
+
* - [`Min`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-min/index.html)/[`Max`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-max/index.html)/[`ExclusiveMin`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-exclusive-min/index.html)/[`ExclusiveMax`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-exclusive-max/index.html):
|
|
2892
|
+
* Sets the `minDate`/`maxDate` properties.
|
|
2893
|
+
*
|
|
2894
|
+
* Example usage:
|
|
2895
|
+
*
|
|
2896
|
+
* ```tsx
|
|
2897
|
+
* import { DateControl } from "@ostack.tech/ui-kform";
|
|
2898
|
+
*
|
|
2899
|
+
* function ProjectDueDateControl() {
|
|
2900
|
+
* return <DateControl path="/dueDate" />;
|
|
2901
|
+
* }
|
|
2902
|
+
* ```
|
|
2903
|
+
*/
|
|
2904
|
+
function DateControl({ path, issueMessages, issuesPanelLabel, displayIssues = true, preventAutoFocus, apiRef, issueMessagesProps, formManager, onInitialized, onFormManagerEvent, onValueChange, onValidationStatusChange, onDisplayStatusChange, onDirtyStatusChange, onTouchedStatusChange, format: dateFormat, required, minDate, maxDate, loading, showSpinner, disabled, readOnly, onFocus, onBlurToOutside, endAdornment, debug, ref, ...otherProps }) {
|
|
2582
2905
|
const { format, parse } = useTemporalStringTransformer({ format: dateFormat });
|
|
2583
2906
|
const [formattedValue, setFormattedValue] = useState("");
|
|
2584
2907
|
const controller = useTemporalInput(path, {
|
|
@@ -2599,6 +2922,7 @@ var DateControl = forwardRef(function DateControl({ path, issueMessages, issuesP
|
|
|
2599
2922
|
const schema = useSchema();
|
|
2600
2923
|
const absolutePath = usePath();
|
|
2601
2924
|
const { restrictions } = schema.typeInfo;
|
|
2925
|
+
const showDebugInfo = useFormInDebugMode() || debug;
|
|
2602
2926
|
const { displayLoading, displayDisabled, displayReadOnly, displayStatusToDisplay, displayValidating, issuesToDisplay, autofocusRef, handleFocus } = useRegisterControl({
|
|
2603
2927
|
controller,
|
|
2604
2928
|
issuesPanelLabel,
|
|
@@ -2610,14 +2934,15 @@ var DateControl = forwardRef(function DateControl({ path, issueMessages, issuesP
|
|
|
2610
2934
|
setFormattedValue(formattedValue);
|
|
2611
2935
|
inputProps.onChange(formattedValue);
|
|
2612
2936
|
}, [inputProps]);
|
|
2613
|
-
const
|
|
2937
|
+
const { inlineIssues, popoverIssues } = useControlIssues({
|
|
2614
2938
|
issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },
|
|
2615
2939
|
issueMessages: { [absolutePath.toString()]: issueMessages },
|
|
2616
2940
|
displayIssues,
|
|
2617
|
-
issueMessagesProps
|
|
2941
|
+
issueMessagesProps,
|
|
2942
|
+
variant: otherProps.variant
|
|
2618
2943
|
});
|
|
2619
|
-
const combinedDateInputRef = useCombinedRef(inputProps.ref, autofocusRef,
|
|
2620
|
-
return /* @__PURE__ */ jsxs(
|
|
2944
|
+
const combinedDateInputRef = useCombinedRef(inputProps.ref, autofocusRef, ref);
|
|
2945
|
+
return /* @__PURE__ */ jsxs(FeedbackProvider, { children: [/* @__PURE__ */ jsx(DateInput, {
|
|
2621
2946
|
value: formattedValue,
|
|
2622
2947
|
name: inputProps.name,
|
|
2623
2948
|
format: dateFormat,
|
|
@@ -2629,18 +2954,52 @@ var DateControl = forwardRef(function DateControl({ path, issueMessages, issuesP
|
|
|
2629
2954
|
disabled: displayDisabled || disabled || inputProps.disabled,
|
|
2630
2955
|
readOnly: displayReadOnly || readOnly || inputProps.readOnly,
|
|
2631
2956
|
status: displayStatusToControlStatus(displayStatusToDisplay),
|
|
2632
|
-
endAdornment: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2957
|
+
endAdornment: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2958
|
+
popoverIssues,
|
|
2959
|
+
endAdornment,
|
|
2960
|
+
(DEV || false) && showDebugInfo && /* @__PURE__ */ jsx(DebugInfo, {
|
|
2961
|
+
path: absolutePath,
|
|
2962
|
+
children: /* @__PURE__ */ jsx(DebugInfoControlAddonTrigger, {})
|
|
2963
|
+
})
|
|
2964
|
+
] }),
|
|
2633
2965
|
onValueChange: handleValueChange,
|
|
2634
2966
|
onFocus: combineEventHandlers(onFocus, handleFocus),
|
|
2635
2967
|
onBlurToOutside: combineEventHandlers(onBlurToOutside, inputProps.onBlur),
|
|
2636
2968
|
...otherProps,
|
|
2637
2969
|
ref: combinedDateInputRef
|
|
2638
2970
|
}), inlineIssues] });
|
|
2639
|
-
}
|
|
2971
|
+
}
|
|
2640
2972
|
//#endregion
|
|
2641
2973
|
//#region src/components/DateRangeControl/DateRangeControl.tsx
|
|
2642
|
-
/**
|
|
2643
|
-
|
|
2974
|
+
/**
|
|
2975
|
+
* The date-range control component is a KForm form control for pairs of values
|
|
2976
|
+
* (start and end dates) with (typically nullable) schemas of type
|
|
2977
|
+
* [`LocalDateSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-local-date-schema/index.html)
|
|
2978
|
+
* or
|
|
2979
|
+
* [`StringSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-string-schema/index.html).
|
|
2980
|
+
* It is built on top of the
|
|
2981
|
+
* [`DateRangeInput`](/docs/ostack-ui-forms-date-range-input--docs) component.
|
|
2982
|
+
*
|
|
2983
|
+
* The following built-in KForm validations affect this control:
|
|
2984
|
+
*
|
|
2985
|
+
* - [`Required`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-required/index.html):
|
|
2986
|
+
* Sets the `required` property.
|
|
2987
|
+
* - [`Min`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-min/index.html)/[`Max`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-max/index.html)/[`ExclusiveMin`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-exclusive-min/index.html)/[`ExclusiveMax`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-exclusive-max/index.html):
|
|
2988
|
+
* Sets the `minDate`/`maxDate` properties.
|
|
2989
|
+
*
|
|
2990
|
+
* Example usage:
|
|
2991
|
+
*
|
|
2992
|
+
* ```tsx
|
|
2993
|
+
* import { DateRangeControl } from "@ostack.tech/ui-kform";
|
|
2994
|
+
*
|
|
2995
|
+
* function ReservationDatesControl() {
|
|
2996
|
+
* return (
|
|
2997
|
+
* <DateRangeControl startPath="/checkInDate" endPath="/checkOutDate" />
|
|
2998
|
+
* );
|
|
2999
|
+
* }
|
|
3000
|
+
* ```
|
|
3001
|
+
*/
|
|
3002
|
+
function DateRangeControl({ startPath, endPath, startIssueMessages, endIssueMessages, issuesPanelLabel, issuesPanelStartLabelSuffix, issuesPanelEndLabelSuffix, displayIssues = true, preventAutoFocus, startApiRef, endApiRef, issueMessagesProps, required, minDate, maxDate, loading, showSpinners = loading, showStartSpinner = showSpinners, showEndSpinner = showSpinners, disabled, readOnly, startInputProps, endInputProps, onStartInitialized, onStartFormManagerEvent, onStartValueChange, onStartValidationStatusChange, onStartDisplayStatusChange, onStartDirtyStatusChange, onStartTouchedStatusChange, onEndInitialized, onEndFormManagerEvent, onEndValueChange, onEndValidationStatusChange, onEndDisplayStatusChange, onEndDirtyStatusChange, onEndTouchedStatusChange, onValueChange, format: dateFormat, onBlurToOutside, startMiddleAdornment, endAdornment, debug, ...otherProps }) {
|
|
2644
3003
|
const [locale] = useLocale();
|
|
2645
3004
|
issuesPanelStartLabelSuffix ??= locale.DateRangeControl.issuesPanelStartLabelSuffix;
|
|
2646
3005
|
issuesPanelEndLabelSuffix ??= locale.DateRangeControl.issuesPanelEndLabelSuffix;
|
|
@@ -2692,6 +3051,7 @@ var DateRangeControl = forwardRef(function DateRangeControl({ startPath, endPath
|
|
|
2692
3051
|
const endSchema = endController.useSchema();
|
|
2693
3052
|
const endAbsolutePath = endController.usePath();
|
|
2694
3053
|
const { restrictions: endRestrictions } = endSchema.typeInfo;
|
|
3054
|
+
const showDebugInfo = useFormInDebugMode() || debug;
|
|
2695
3055
|
const { displayLoading: displayStartLoading, displayDisabled: displayStartDisabled, displayReadOnly: displayStartReadOnly, displayStatusToDisplay: startDisplayStatusToDisplay, displayValidating: displayStartValidating, issuesToDisplay: startIssuesToDisplay, autofocusRef: startAutofocusRef, handleFocus: handleStartFocus } = useRegisterControl({
|
|
2696
3056
|
controller: startController,
|
|
2697
3057
|
issuesPanelLabel,
|
|
@@ -2718,7 +3078,7 @@ var DateRangeControl = forwardRef(function DateRangeControl({ startPath, endPath
|
|
|
2718
3078
|
formattedValue.start,
|
|
2719
3079
|
startControllerInputProps
|
|
2720
3080
|
]);
|
|
2721
|
-
const
|
|
3081
|
+
const { inlineIssues, popoverIssues } = useControlIssues({
|
|
2722
3082
|
issuesToDisplay: {
|
|
2723
3083
|
[startAbsolutePath.toString()]: startIssuesToDisplay,
|
|
2724
3084
|
[endAbsolutePath.toString()]: endIssuesToDisplay
|
|
@@ -2728,9 +3088,10 @@ var DateRangeControl = forwardRef(function DateRangeControl({ startPath, endPath
|
|
|
2728
3088
|
[endAbsolutePath.toString()]: endIssueMessages
|
|
2729
3089
|
},
|
|
2730
3090
|
displayIssues,
|
|
2731
|
-
issueMessagesProps
|
|
3091
|
+
issueMessagesProps,
|
|
3092
|
+
variant: otherProps.variant
|
|
2732
3093
|
});
|
|
2733
|
-
return /* @__PURE__ */ jsxs(
|
|
3094
|
+
return /* @__PURE__ */ jsxs(FeedbackProvider, { children: [/* @__PURE__ */ jsx(DateRangeInput, {
|
|
2734
3095
|
value: formattedValue,
|
|
2735
3096
|
format: dateFormat,
|
|
2736
3097
|
required: required ?? (startRestrictions.required === true || endRestrictions.required === true),
|
|
@@ -2760,22 +3121,118 @@ var DateRangeControl = forwardRef(function DateRangeControl({ startPath, endPath
|
|
|
2760
3121
|
onFocus: combineEventHandlers(endInputProps?.onFocus, handleEndFocus),
|
|
2761
3122
|
ref: useCombinedRef(endControllerInputProps?.ref, useCombinedRef(endAutofocusRef, endInputProps?.ref))
|
|
2762
3123
|
},
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
3124
|
+
startMiddleAdornment: /* @__PURE__ */ jsxs(Fragment, { children: [startMiddleAdornment, (DEV || false) && showDebugInfo && /* @__PURE__ */ jsx(DebugInfo, {
|
|
3125
|
+
path: startAbsolutePath,
|
|
3126
|
+
children: /* @__PURE__ */ jsx(DebugInfoControlAddonTrigger, {})
|
|
3127
|
+
})] }),
|
|
3128
|
+
endAdornment: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3129
|
+
popoverIssues,
|
|
3130
|
+
endAdornment,
|
|
3131
|
+
(DEV || false) && showDebugInfo && /* @__PURE__ */ jsx(DebugInfo, {
|
|
3132
|
+
path: endAbsolutePath,
|
|
3133
|
+
children: /* @__PURE__ */ jsx(DebugInfoControlAddonTrigger, {})
|
|
3134
|
+
})
|
|
3135
|
+
] }),
|
|
3136
|
+
...otherProps
|
|
2766
3137
|
}), inlineIssues] });
|
|
2767
|
-
}
|
|
3138
|
+
}
|
|
2768
3139
|
//#endregion
|
|
2769
|
-
//#region src/components/FileControl/
|
|
2770
|
-
/**
|
|
2771
|
-
|
|
3140
|
+
//#region src/components/FileControl/FileControlDownloadAddon.tsx
|
|
3141
|
+
/** Control addon used to download a file. */
|
|
3142
|
+
function FileControlDownloadAddon({ file, label }) {
|
|
3143
|
+
const { printHidden } = usePrintClassNames();
|
|
3144
|
+
const dataURL = useMemo(() => URL.createObjectURL(file), [file]);
|
|
3145
|
+
return /* @__PURE__ */ jsx(Tooltip, {
|
|
3146
|
+
content: label,
|
|
3147
|
+
children: /* @__PURE__ */ jsx(ControlAddon, {
|
|
3148
|
+
as: "a",
|
|
3149
|
+
className: printHidden,
|
|
3150
|
+
href: dataURL,
|
|
3151
|
+
download: file.name,
|
|
3152
|
+
children: /* @__PURE__ */ jsx(Icon, { icon: faDownload })
|
|
3153
|
+
})
|
|
3154
|
+
});
|
|
3155
|
+
}
|
|
3156
|
+
//#endregion
|
|
3157
|
+
//#region src/components/FileControl/FileControlViewAddon.tsx
|
|
3158
|
+
/** Control addon used to view a file. */
|
|
3159
|
+
function FileControlViewAddon({ file, viewLabel, downloadLabel, fallbackText }) {
|
|
2772
3160
|
const prefix = usePrefix();
|
|
3161
|
+
const { printHidden } = usePrintClassNames();
|
|
3162
|
+
const dataURL = useMemo(() => URL.createObjectURL(file), [file]);
|
|
3163
|
+
return /* @__PURE__ */ jsxs(Dialog, { children: [/* @__PURE__ */ jsx(Tooltip, {
|
|
3164
|
+
content: viewLabel,
|
|
3165
|
+
children: /* @__PURE__ */ jsx(DialogTrigger, { children: /* @__PURE__ */ jsx(ControlAddon, {
|
|
3166
|
+
as: "button",
|
|
3167
|
+
className: printHidden,
|
|
3168
|
+
children: /* @__PURE__ */ jsx(Icon, { icon: faFileLines })
|
|
3169
|
+
}) })
|
|
3170
|
+
}), /* @__PURE__ */ jsxs(DialogContent, {
|
|
3171
|
+
variant: "subtle",
|
|
3172
|
+
className: prefix("file-control__viewer-dialog"),
|
|
3173
|
+
"aria-describedby": void 0,
|
|
3174
|
+
children: [/* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsx(DialogTitle, {
|
|
3175
|
+
className: prefix("file-control__viewer-dialog-title"),
|
|
3176
|
+
children: file.name
|
|
3177
|
+
}), /* @__PURE__ */ jsx(IconButton, {
|
|
3178
|
+
variant: "ghost",
|
|
3179
|
+
className: prefix("file-control__viewer-download"),
|
|
3180
|
+
asChild: true,
|
|
3181
|
+
icon: faDownload,
|
|
3182
|
+
label: downloadLabel,
|
|
3183
|
+
children: /* @__PURE__ */ jsx("a", {
|
|
3184
|
+
href: dataURL,
|
|
3185
|
+
download: file.name
|
|
3186
|
+
})
|
|
3187
|
+
})] }), /* @__PURE__ */ jsx(DialogBody, {
|
|
3188
|
+
className: prefix("file-control__viewer-dialog-body"),
|
|
3189
|
+
children: /* @__PURE__ */ jsx("object", {
|
|
3190
|
+
className: prefix("file-control__viewer-object"),
|
|
3191
|
+
type: file.type || void 0,
|
|
3192
|
+
data: dataURL,
|
|
3193
|
+
"aria-label": file.name,
|
|
3194
|
+
children: /* @__PURE__ */ jsx(Alert, {
|
|
3195
|
+
className: prefix("file-control__viewer-fallback"),
|
|
3196
|
+
severity: "warning",
|
|
3197
|
+
children: fallbackText
|
|
3198
|
+
})
|
|
3199
|
+
})
|
|
3200
|
+
})]
|
|
3201
|
+
})] });
|
|
3202
|
+
}
|
|
3203
|
+
//#endregion
|
|
3204
|
+
//#region src/components/FileControl/FileControl.tsx
|
|
3205
|
+
/**
|
|
3206
|
+
* The file control component is a KForm form control for values with (typically
|
|
3207
|
+
* [nullable](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-nullable-schema/index.html))
|
|
3208
|
+
* schemas of type
|
|
3209
|
+
* [`FileSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-file-schema/index.html).
|
|
3210
|
+
* It is built on top of the [`Input`](/docs/ostack-ui-forms-input--docs)
|
|
3211
|
+
* component.
|
|
3212
|
+
*
|
|
3213
|
+
* The following built-in KForm validations affect this control:
|
|
3214
|
+
*
|
|
3215
|
+
* - [`Required`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-required/index.html):
|
|
3216
|
+
* Sets the `required` property.
|
|
3217
|
+
* - [`Accepts`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-accepts/index.html):
|
|
3218
|
+
* Sets the `accept` property.
|
|
3219
|
+
*
|
|
3220
|
+
* Example usage:
|
|
3221
|
+
*
|
|
3222
|
+
* ```tsx
|
|
3223
|
+
* import { FileControl } from "@ostack.tech/ui-kform";
|
|
3224
|
+
*
|
|
3225
|
+
* function IdProofControl() {
|
|
3226
|
+
* return <FileControl path="/idProof" />;
|
|
3227
|
+
* }
|
|
3228
|
+
* ```
|
|
3229
|
+
*/
|
|
3230
|
+
function FileControl({ path, issueMessages, issuesPanelLabel, displayIssues = true, preventAutoFocus, apiRef, issueMessagesProps, fileInteraction = "view", viewFileButtonLabel, downloadFileButtonLabel, fallbackText, formManager, onInitialized, onFormManagerEvent, onValueChange, onValidationStatusChange, onDisplayStatusChange, onDirtyStatusChange, onTouchedStatusChange, required, accept, loading, showSpinner, disabled, readOnly, showClearButton, clearDescription, endAdornment, onChange, onKeyDown, onFocus, onBlurToOutside, debug, clearButtonProps, ref, ...otherProps }) {
|
|
2773
3231
|
const [locale] = useLocale();
|
|
2774
3232
|
clearDescription ??= locale.FileControl.clearDescription;
|
|
2775
3233
|
viewFileButtonLabel ??= locale.FileControl.viewFileButtonLabel;
|
|
2776
3234
|
downloadFileButtonLabel ??= locale.FileControl.downloadFileButtonLabel;
|
|
2777
3235
|
fallbackText ??= locale.FileControl.fallbackText;
|
|
2778
|
-
const { printHidden } = usePrintClassNames();
|
|
2779
3236
|
const latestFile = useRef(null);
|
|
2780
3237
|
const [file, setFile] = useState(null);
|
|
2781
3238
|
const controller = useFileInput(path, {
|
|
@@ -2797,6 +3254,7 @@ var FileControl = forwardRef(function FileControl({ path, issueMessages, issuesP
|
|
|
2797
3254
|
const { useSchema, usePath, inputProps } = controller;
|
|
2798
3255
|
const { nullable, restrictions } = useSchema().typeInfo;
|
|
2799
3256
|
const absolutePath = usePath();
|
|
3257
|
+
const showDebugInfo = useFormInDebugMode() || debug;
|
|
2800
3258
|
const { displayLoading, displayDisabled, displayReadOnly, displayStatusToDisplay, displayValidating, issuesToDisplay, autofocusRef, handleFocus } = useRegisterControl({
|
|
2801
3259
|
controller,
|
|
2802
3260
|
issuesPanelLabel,
|
|
@@ -2804,7 +3262,7 @@ var FileControl = forwardRef(function FileControl({ path, issueMessages, issuesP
|
|
|
2804
3262
|
preventAutoFocus,
|
|
2805
3263
|
apiRef
|
|
2806
3264
|
});
|
|
2807
|
-
showClearButton ??= nullable ?
|
|
3265
|
+
showClearButton ??= nullable ? file !== null : false;
|
|
2808
3266
|
const isClearing = useRef(false);
|
|
2809
3267
|
const handleClearButtonClick = useCallback(() => {
|
|
2810
3268
|
isClearing.current = true;
|
|
@@ -2820,15 +3278,14 @@ var FileControl = forwardRef(function FileControl({ path, issueMessages, issuesP
|
|
|
2820
3278
|
const handleKeyDown = useCallback((evt) => {
|
|
2821
3279
|
if (evt.code === "Delete" || evt.code === "Backspace") clearButtonRef.current?.click();
|
|
2822
3280
|
}, []);
|
|
2823
|
-
const
|
|
2824
|
-
const [inlineIssues, popoverIssues] = useControlIssues({
|
|
3281
|
+
const { inlineIssues, popoverIssues } = useControlIssues({
|
|
2825
3282
|
issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },
|
|
2826
3283
|
issueMessages: { [absolutePath.toString()]: issueMessages },
|
|
2827
3284
|
displayIssues,
|
|
2828
3285
|
issueMessagesProps
|
|
2829
3286
|
});
|
|
2830
|
-
const combinedInputRef = useCombinedRef(inputProps.ref, autofocusRef,
|
|
2831
|
-
return /* @__PURE__ */ jsxs(
|
|
3287
|
+
const combinedInputRef = useCombinedRef(inputProps.ref, autofocusRef, ref);
|
|
3288
|
+
return /* @__PURE__ */ jsxs(FeedbackProvider, { children: [/* @__PURE__ */ jsx(Input, {
|
|
2832
3289
|
type: "file",
|
|
2833
3290
|
name: inputProps.name,
|
|
2834
3291
|
required: required ?? restrictions.required == true,
|
|
@@ -2852,68 +3309,25 @@ var FileControl = forwardRef(function FileControl({ path, issueMessages, issuesP
|
|
|
2852
3309
|
endAdornment: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2853
3310
|
popoverIssues,
|
|
2854
3311
|
endAdornment,
|
|
2855
|
-
fileInteraction === "view" && file && /* @__PURE__ */
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
}), /* @__PURE__ */ jsxs(DialogContent, {
|
|
2869
|
-
variant: "subtle",
|
|
2870
|
-
className: prefix("file-control__viewer-dialog"),
|
|
2871
|
-
"aria-describedby": void 0,
|
|
2872
|
-
children: [/* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsx(DialogTitle, {
|
|
2873
|
-
className: prefix("file-control__viewer-dialog-title"),
|
|
2874
|
-
children: file.name
|
|
2875
|
-
}), /* @__PURE__ */ jsx(IconButton, {
|
|
2876
|
-
variant: "ghost",
|
|
2877
|
-
className: prefix("file-control__viewer-download"),
|
|
2878
|
-
asChild: true,
|
|
2879
|
-
icon: faDownload,
|
|
2880
|
-
label: downloadFileButtonLabel,
|
|
2881
|
-
children: /* @__PURE__ */ jsx("a", {
|
|
2882
|
-
href: dataURL,
|
|
2883
|
-
download: file.name
|
|
2884
|
-
})
|
|
2885
|
-
})] }), /* @__PURE__ */ jsx(DialogBody, {
|
|
2886
|
-
className: prefix("file-control__viewer-dialog-body"),
|
|
2887
|
-
children: /* @__PURE__ */ jsx("object", {
|
|
2888
|
-
className: prefix("file-control__viewer-object"),
|
|
2889
|
-
type: file.type || void 0,
|
|
2890
|
-
data: dataURL,
|
|
2891
|
-
"aria-label": file.name,
|
|
2892
|
-
children: /* @__PURE__ */ jsx(Alert, {
|
|
2893
|
-
className: prefix("file-control__viewer-fallback"),
|
|
2894
|
-
severity: "warning",
|
|
2895
|
-
children: fallbackText
|
|
2896
|
-
})
|
|
2897
|
-
})
|
|
2898
|
-
})]
|
|
2899
|
-
})] }),
|
|
2900
|
-
fileInteraction === "download" && file && /* @__PURE__ */ jsx(Tooltip, {
|
|
2901
|
-
content: downloadFileButtonLabel,
|
|
2902
|
-
children: /* @__PURE__ */ jsx(ControlAddon, {
|
|
2903
|
-
asChild: true,
|
|
2904
|
-
children: /* @__PURE__ */ jsx("a", {
|
|
2905
|
-
className: printHidden,
|
|
2906
|
-
href: dataURL,
|
|
2907
|
-
download: file.name,
|
|
2908
|
-
children: /* @__PURE__ */ jsx(Icon, { icon: faDownload })
|
|
2909
|
-
})
|
|
2910
|
-
})
|
|
3312
|
+
fileInteraction === "view" && file && /* @__PURE__ */ jsx(FileControlViewAddon, {
|
|
3313
|
+
file,
|
|
3314
|
+
viewLabel: viewFileButtonLabel,
|
|
3315
|
+
downloadLabel: downloadFileButtonLabel,
|
|
3316
|
+
fallbackText
|
|
3317
|
+
}),
|
|
3318
|
+
fileInteraction === "download" && file && /* @__PURE__ */ jsx(FileControlDownloadAddon, {
|
|
3319
|
+
file,
|
|
3320
|
+
label: downloadFileButtonLabel
|
|
3321
|
+
}),
|
|
3322
|
+
(DEV || false) && showDebugInfo && /* @__PURE__ */ jsx(DebugInfo, {
|
|
3323
|
+
path: absolutePath,
|
|
3324
|
+
children: /* @__PURE__ */ jsx(DebugInfoControlAddonTrigger, {})
|
|
2911
3325
|
})
|
|
2912
3326
|
] }),
|
|
2913
3327
|
...otherProps,
|
|
2914
3328
|
ref: combinedInputRef
|
|
2915
3329
|
}), inlineIssues] });
|
|
2916
|
-
}
|
|
3330
|
+
}
|
|
2917
3331
|
//#endregion
|
|
2918
3332
|
//#region src/components/FormPages/FormPagesContext.ts
|
|
2919
3333
|
/** Form pages context. */
|
|
@@ -3006,7 +3420,7 @@ function useFormPageState(path, selector) {
|
|
|
3006
3420
|
//#endregion
|
|
3007
3421
|
//#region src/components/FormPages/FormPageHeader.tsx
|
|
3008
3422
|
/** Form page header. */
|
|
3009
|
-
|
|
3423
|
+
function FormPageHeader({ helperText, helperButtonLabel, ownIssueMessages, codeProps, titleProps, headerPopoverContainerProps, issuesPopoverProps, issueMessagesProps, helperButtonProps, helperPopoverProps, helperPopoverContentProps, className, ...otherProps }) {
|
|
3010
3424
|
const prefix = usePrefix();
|
|
3011
3425
|
const [locale] = useLocale();
|
|
3012
3426
|
const printing = usePrinting();
|
|
@@ -3023,7 +3437,6 @@ var FormPageHeader = forwardRef(function FormPageHeader({ helperText, helperButt
|
|
|
3023
3437
|
className: cx(prefix("form-pages__page-header"), className),
|
|
3024
3438
|
...otherProps,
|
|
3025
3439
|
"data-has-popovers": boolDataAttr(helperText != null || deferredIssuesToDisplay.length > 0),
|
|
3026
|
-
ref: forwardedRef,
|
|
3027
3440
|
children: [/* @__PURE__ */ jsxs("h2", {
|
|
3028
3441
|
tabIndex: -1,
|
|
3029
3442
|
...titleProps,
|
|
@@ -3080,11 +3493,11 @@ var FormPageHeader = forwardRef(function FormPageHeader({ helperText, helperButt
|
|
|
3080
3493
|
})]
|
|
3081
3494
|
})
|
|
3082
3495
|
});
|
|
3083
|
-
}
|
|
3496
|
+
}
|
|
3084
3497
|
//#endregion
|
|
3085
3498
|
//#region src/components/FormPages/FormPage.tsx
|
|
3086
|
-
/**
|
|
3087
|
-
|
|
3499
|
+
/** Component representing a single form page. */
|
|
3500
|
+
function FormPage({ path, title: _title, documentTitle: _documentTitle, code: _code, issuesPanelLabel: _issuesPanelLabel, disabled = false, readOnly = false, className, helperText, helperButtonLabel, visuallyHiddenCodePrefix: _visuallyHiddenCodePrefix, issueMessages, ownIssueMessages, headerProps, codeProps, titleProps, headerPopoverContainerProps, issuesPopoverProps, issueMessagesProps, contentProps, containerProps, errorBoundaryProps, helperButtonProps, helperPopoverProps, helperPopoverContentProps, children, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...otherProps }) {
|
|
3088
3501
|
const prefix = usePrefix();
|
|
3089
3502
|
const [locale] = useLocale();
|
|
3090
3503
|
helperButtonLabel ??= locale.FormPage.helperButtonLabel;
|
|
@@ -3113,7 +3526,8 @@ var FormPage = forwardRef(function FormPage({ path, title: _title, documentTitle
|
|
|
3113
3526
|
shouldDisplay
|
|
3114
3527
|
]);
|
|
3115
3528
|
const combinedHeaderRef = useCombinedRef(setHeaderEl, headerProps?.ref);
|
|
3116
|
-
|
|
3529
|
+
if (!shouldDisplay && !printing) return null;
|
|
3530
|
+
return /* @__PURE__ */ jsx(CurrentPath, {
|
|
3117
3531
|
path: pagePath,
|
|
3118
3532
|
children: /* @__PURE__ */ jsx(DocumentTitle, {
|
|
3119
3533
|
title: printing ? void 0 : documentTitle ?? void 0,
|
|
@@ -3122,7 +3536,6 @@ var FormPage = forwardRef(function FormPage({ path, title: _title, documentTitle
|
|
|
3122
3536
|
"aria-label": ariaLabel,
|
|
3123
3537
|
"aria-labelledby": ariaLabelledBy ?? (ariaLabel === void 0 ? titleId : void 0),
|
|
3124
3538
|
...otherProps,
|
|
3125
|
-
ref: forwardedRef,
|
|
3126
3539
|
children: /* @__PURE__ */ jsx(FormAppStatus, {
|
|
3127
3540
|
disabled,
|
|
3128
3541
|
readOnly,
|
|
@@ -3168,8 +3581,8 @@ var FormPage = forwardRef(function FormPage({ path, title: _title, documentTitle
|
|
|
3168
3581
|
})
|
|
3169
3582
|
})
|
|
3170
3583
|
})
|
|
3171
|
-
})
|
|
3172
|
-
}
|
|
3584
|
+
});
|
|
3585
|
+
}
|
|
3173
3586
|
//#endregion
|
|
3174
3587
|
//#region src/components/FormPages/FormPageRegistrar.tsx
|
|
3175
3588
|
/** Component used to register a form page. */
|
|
@@ -3177,7 +3590,7 @@ function FormPageRegistrar({ path, title, documentTitle, code, issuesPanelLabel
|
|
|
3177
3590
|
const store = useFormPagesContext();
|
|
3178
3591
|
const printing = usePrinting();
|
|
3179
3592
|
const finishPrintingTask = useStartPrintingTask();
|
|
3180
|
-
const controller = useController(path.append(AbsolutePathFragment.RecursiveWildcard), {
|
|
3593
|
+
const controller = useController(typeof title === "function" || typeof documentTitle === "function" ? path.append(AbsolutePathFragment.RecursiveWildcard) : path, {
|
|
3181
3594
|
enabled: !useFormIsLoading(),
|
|
3182
3595
|
onInitialized: finishPrintingTask
|
|
3183
3596
|
});
|
|
@@ -3221,21 +3634,52 @@ function FormPageRegistrar({ path, title, documentTitle, code, issuesPanelLabel
|
|
|
3221
3634
|
}
|
|
3222
3635
|
//#endregion
|
|
3223
3636
|
//#region src/components/FormPages/FormPages.tsx
|
|
3224
|
-
/**
|
|
3225
|
-
|
|
3637
|
+
/**
|
|
3638
|
+
* The form pages component can be used to split parts of a form into separate
|
|
3639
|
+
* pages, while providing means of navigating between them. Although not
|
|
3640
|
+
* strictly mandatory, each page is typically represented by its own class, with
|
|
3641
|
+
* its own schema and distinct path.
|
|
3642
|
+
*
|
|
3643
|
+
* It composes the following subcomponents:
|
|
3644
|
+
*
|
|
3645
|
+
* - `FormPagesNavigation`: Component used to navigate between form pages.
|
|
3646
|
+
* - `FormPage`: The content of a single page of the form.
|
|
3647
|
+
*
|
|
3648
|
+
* Example usage:
|
|
3649
|
+
*
|
|
3650
|
+
* ```tsx
|
|
3651
|
+
* import {
|
|
3652
|
+
* FormPage,
|
|
3653
|
+
* FormPages,
|
|
3654
|
+
* FormPagesNavigation,
|
|
3655
|
+
* } from "@ostack.tech/ui-kform";
|
|
3656
|
+
*
|
|
3657
|
+
* function TaxWithholdingPages() {
|
|
3658
|
+
* return (
|
|
3659
|
+
* <FormPages>
|
|
3660
|
+
* <FormPagesNavigation />
|
|
3661
|
+
* <FormPage path="/fillingInfo" title="Filing information" code="0">
|
|
3662
|
+
* Filing information page…
|
|
3663
|
+
* </FormPage>
|
|
3664
|
+
* <FormPage
|
|
3665
|
+
* path="/exemptions"
|
|
3666
|
+
* title="Exemptions & declarations"
|
|
3667
|
+
* code="1"
|
|
3668
|
+
* >
|
|
3669
|
+
* Exemptions & declarations page…
|
|
3670
|
+
* </FormPage>
|
|
3671
|
+
* </FormPages>
|
|
3672
|
+
* );
|
|
3673
|
+
* }
|
|
3674
|
+
* ```
|
|
3675
|
+
*/
|
|
3676
|
+
function FormPages({ path, pages, defaultActivePage, activePage, onActivePageChange, className, children, ref, ...otherProps }) {
|
|
3226
3677
|
const prefix = usePrefix();
|
|
3227
3678
|
const { cssVarName } = useCssVars({ prefix });
|
|
3228
3679
|
const formManager = useFormManager();
|
|
3229
3680
|
const absolutePath = useResolvedPath(path);
|
|
3230
3681
|
const isLargeScreen = useMediaBreakpointUp("sm");
|
|
3231
|
-
pages ??=
|
|
3232
|
-
path: child.props.path,
|
|
3233
|
-
title: child.props.title,
|
|
3234
|
-
documentTitle: child.props.documentTitle,
|
|
3235
|
-
code: child.props.code,
|
|
3236
|
-
visuallyHiddenCodePrefix: child.props.visuallyHiddenCodePrefix,
|
|
3237
|
-
issuesPanelLabel: child.props.issuesPanelLabel
|
|
3238
|
-
}));
|
|
3682
|
+
pages ??= parseChildren(children, FormPage, { renderUnknownComponents: false });
|
|
3239
3683
|
const resolvedPages = useMemo(() => pages.map((page) => ({
|
|
3240
3684
|
...page,
|
|
3241
3685
|
path: absolutePath.resolve(page.path ?? Path.CURRENT)
|
|
@@ -3264,7 +3708,7 @@ var FormPages = forwardRef(function FormPages({ path, pages, defaultActivePage,
|
|
|
3264
3708
|
prefix,
|
|
3265
3709
|
store
|
|
3266
3710
|
]);
|
|
3267
|
-
const combinedFormPagesRef = useCombinedRef(formPagesRef,
|
|
3711
|
+
const combinedFormPagesRef = useCombinedRef(formPagesRef, ref);
|
|
3268
3712
|
return /* @__PURE__ */ jsx(CurrentPath, {
|
|
3269
3713
|
path: absolutePath,
|
|
3270
3714
|
children: /* @__PURE__ */ jsxs(FormPagesContext.Provider, {
|
|
@@ -3278,7 +3722,7 @@ var FormPages = forwardRef(function FormPages({ path, pages, defaultActivePage,
|
|
|
3278
3722
|
})]
|
|
3279
3723
|
})
|
|
3280
3724
|
});
|
|
3281
|
-
}
|
|
3725
|
+
}
|
|
3282
3726
|
//#endregion
|
|
3283
3727
|
//#region src/components/FormPages/FormPagesSelectOption.tsx
|
|
3284
3728
|
function FormPagesSelectOption({ path }) {
|
|
@@ -3310,7 +3754,7 @@ function FormPagesSelectOption({ path }) {
|
|
|
3310
3754
|
//#endregion
|
|
3311
3755
|
//#region src/components/FormPages/FormPagesSelect.tsx
|
|
3312
3756
|
/** Select component allowing the navigation between form pages. */
|
|
3313
|
-
|
|
3757
|
+
function FormPagesSelect({ rootProps, containerProps, valueProps, arrowProps, popoverProps, commandMenuProps, className, ...otherProps }) {
|
|
3314
3758
|
const prefix = usePrefix();
|
|
3315
3759
|
const store = useFormPagesContext();
|
|
3316
3760
|
const activePage = useStore(store, (state) => state.activePage);
|
|
@@ -3350,10 +3794,9 @@ var FormPagesSelect = forwardRef(function FormPagesSelect({ rootProps, container
|
|
|
3350
3794
|
...commandMenuProps
|
|
3351
3795
|
},
|
|
3352
3796
|
...otherProps,
|
|
3353
|
-
ref: forwardedRef,
|
|
3354
3797
|
children: pages.map((page) => /* @__PURE__ */ jsx(FormPagesSelectOption, { path: page.path }, page.path.toString()))
|
|
3355
3798
|
});
|
|
3356
|
-
}
|
|
3799
|
+
}
|
|
3357
3800
|
//#endregion
|
|
3358
3801
|
//#region src/components/FormPages/FormPageSidebarItem.tsx
|
|
3359
3802
|
function FormPageSidebarItem({ path }) {
|
|
@@ -3412,7 +3855,7 @@ function FormPageSidebarItem({ path }) {
|
|
|
3412
3855
|
//#endregion
|
|
3413
3856
|
//#region src/components/FormPages/FormPagesSidebar.tsx
|
|
3414
3857
|
/** Sidebar component allowing the navigation between form pages. */
|
|
3415
|
-
|
|
3858
|
+
function FormPagesSidebar({ className, ref, ...otherProps }) {
|
|
3416
3859
|
const prefix = usePrefix();
|
|
3417
3860
|
const store = useFormPagesContext();
|
|
3418
3861
|
const { currentPath } = useFormContext();
|
|
@@ -3427,18 +3870,21 @@ var FormPagesSidebar = forwardRef(function FormPagesSidebar({ className, ...othe
|
|
|
3427
3870
|
setLeftSidebarWidth
|
|
3428
3871
|
]));
|
|
3429
3872
|
const pages = useStore(store, (state) => state.pages);
|
|
3430
|
-
const combinedSidebarRef = useCombinedRef(setSidebarEl,
|
|
3873
|
+
const combinedSidebarRef = useCombinedRef(setSidebarEl, ref);
|
|
3431
3874
|
return /* @__PURE__ */ jsx("div", {
|
|
3432
3875
|
className: cx(prefix("form-pages__sidebar"), className),
|
|
3433
3876
|
...otherProps,
|
|
3434
3877
|
ref: combinedSidebarRef,
|
|
3435
3878
|
children: /* @__PURE__ */ jsx(MenuList, { children: pages.map((page) => /* @__PURE__ */ jsx(FormPageSidebarItem, { path: page.path }, page.path.toString())) })
|
|
3436
3879
|
});
|
|
3437
|
-
}
|
|
3880
|
+
}
|
|
3438
3881
|
//#endregion
|
|
3439
3882
|
//#region src/components/FormPages/FormPagesNavigation.tsx
|
|
3440
|
-
/**
|
|
3441
|
-
|
|
3883
|
+
/**
|
|
3884
|
+
* Component allowing navigation between form pages. Renders as a sidebar in
|
|
3885
|
+
* large screens and as a select for smaller ones.
|
|
3886
|
+
*/
|
|
3887
|
+
function FormPagesNavigation({ sidebarProps, selectProps, className, "aria-label": ariaLabel, ...otherProps }) {
|
|
3442
3888
|
const prefix = usePrefix();
|
|
3443
3889
|
const [locale] = useLocale();
|
|
3444
3890
|
ariaLabel ??= locale.FormPagesNavigation["aria-label"];
|
|
@@ -3451,14 +3897,13 @@ var FormPagesNavigation = forwardRef(function FormPagesNavigation({ sidebarProps
|
|
|
3451
3897
|
"data-navigation-mode": isLargeScreen ? "sidebar" : "select",
|
|
3452
3898
|
"aria-label": ariaLabel,
|
|
3453
3899
|
...otherProps,
|
|
3454
|
-
ref: forwardedRef,
|
|
3455
3900
|
children: isLargeScreen ? /* @__PURE__ */ jsx(Layer, {
|
|
3456
3901
|
zIndex: "docked",
|
|
3457
3902
|
children: /* @__PURE__ */ jsx(FormPagesSidebar, { ...sidebarProps })
|
|
3458
3903
|
}) : /* @__PURE__ */ jsx(FormPagesSelect, { ...selectProps })
|
|
3459
3904
|
})
|
|
3460
3905
|
});
|
|
3461
|
-
}
|
|
3906
|
+
}
|
|
3462
3907
|
//#endregion
|
|
3463
3908
|
//#region src/components/FormStepper/FormStepperContext.ts
|
|
3464
3909
|
/** Form stepper context. */
|
|
@@ -3575,7 +4020,7 @@ function useFormStepState(path, selector) {
|
|
|
3575
4020
|
//#endregion
|
|
3576
4021
|
//#region src/components/FormStepper/FormStep.tsx
|
|
3577
4022
|
/** Single form step. */
|
|
3578
|
-
|
|
4023
|
+
function FormStep({ path, title: _title, documentTitle: _documentTitle, issuesPanelLabel: _issuesPanelLabel, disabled = false, readOnly = false, issueMessages, errorBoundaryProps, className, children, ...otherProps }) {
|
|
3579
4024
|
const prefix = usePrefix();
|
|
3580
4025
|
const stepPath = useResolvedPath(path);
|
|
3581
4026
|
const index = useFormStepState(stepPath, (controller) => controller?.index);
|
|
@@ -3587,7 +4032,6 @@ var FormStep = forwardRef(function FormStepContent({ path, title: _title, docume
|
|
|
3587
4032
|
index,
|
|
3588
4033
|
className: cx(prefix("form-stepper__step-content"), className),
|
|
3589
4034
|
...otherProps,
|
|
3590
|
-
ref: forwardedRef,
|
|
3591
4035
|
children: /* @__PURE__ */ jsx(DocumentTitle, {
|
|
3592
4036
|
title: documentTitle ?? void 0,
|
|
3593
4037
|
children: /* @__PURE__ */ jsx(FormAppStatus, {
|
|
@@ -3610,7 +4054,7 @@ var FormStep = forwardRef(function FormStepContent({ path, title: _title, docume
|
|
|
3610
4054
|
})
|
|
3611
4055
|
})
|
|
3612
4056
|
});
|
|
3613
|
-
}
|
|
4057
|
+
}
|
|
3614
4058
|
/** @deprecated Use `FormStep` instead. */
|
|
3615
4059
|
var FormStepContent = FormStep;
|
|
3616
4060
|
//#endregion
|
|
@@ -3635,26 +4079,29 @@ function FormStepButton({ path, index }) {
|
|
|
3635
4079
|
//#endregion
|
|
3636
4080
|
//#region src/components/FormStepper/FormStepList.tsx
|
|
3637
4081
|
/** Component displaying all form steps in a list. */
|
|
3638
|
-
|
|
4082
|
+
function FormStepList({ className, ...otherProps }) {
|
|
3639
4083
|
const prefix = usePrefix();
|
|
3640
4084
|
const steps = useStore(useFormStepperContext(), (state) => state.steps);
|
|
3641
4085
|
return /* @__PURE__ */ jsx(StepList, {
|
|
3642
4086
|
className: cx(prefix("form-stepper__step-list"), className),
|
|
3643
4087
|
...otherProps,
|
|
3644
|
-
ref: forwardedRef,
|
|
3645
4088
|
children: steps.map((step) => /* @__PURE__ */ jsx(FormStepButton, {
|
|
3646
4089
|
path: step.path,
|
|
3647
4090
|
index: step.index
|
|
3648
4091
|
}, step.path.toString()))
|
|
3649
4092
|
});
|
|
3650
|
-
}
|
|
4093
|
+
}
|
|
3651
4094
|
//#endregion
|
|
3652
4095
|
//#region src/components/FormStepper/FormStepRegistrar.tsx
|
|
3653
4096
|
/** Component used to register a form step. */
|
|
3654
4097
|
function FormStepRegistrar({ index, path, title, documentTitle, issuesPanelLabel }) {
|
|
3655
4098
|
const store = useFormStepperContext();
|
|
3656
4099
|
const printing = usePrinting();
|
|
3657
|
-
const
|
|
4100
|
+
const finishPrintingTask = useStartPrintingTask();
|
|
4101
|
+
const controller = useController(typeof title === "function" || typeof documentTitle === "function" ? path.append(AbsolutePathFragment.RecursiveWildcard) : path, {
|
|
4102
|
+
enabled: !useFormIsLoading(),
|
|
4103
|
+
onInitialized: finishPrintingTask
|
|
4104
|
+
});
|
|
3658
4105
|
const absolutePath = controller.usePath();
|
|
3659
4106
|
const exists = controller.useState((state) => state.initialized && state.exists);
|
|
3660
4107
|
const value = controller.useValue();
|
|
@@ -3692,17 +4139,59 @@ function FormStepRegistrar({ index, path, title, documentTitle, issuesPanelLabel
|
|
|
3692
4139
|
}
|
|
3693
4140
|
//#endregion
|
|
3694
4141
|
//#region src/components/FormStepper/FormStepper.tsx
|
|
3695
|
-
/**
|
|
3696
|
-
|
|
4142
|
+
/**
|
|
4143
|
+
* The form stepper component can be used to split parts of a form into separate
|
|
4144
|
+
* steps. It is built on top of the
|
|
4145
|
+
* [`Stepper`](/docs/ostack-ui-disclosure-stepper--docs) component. Although not
|
|
4146
|
+
* strictly mandatory, each page is typically represented by its own class, with
|
|
4147
|
+
* its own schema and distinct path.
|
|
4148
|
+
*
|
|
4149
|
+
* It composes the following subcomponents:
|
|
4150
|
+
*
|
|
4151
|
+
* - `FormStepList`: Component used to navigate between form pages.
|
|
4152
|
+
* - `FormStep`: The content of a single step of the form.
|
|
4153
|
+
* - `FormStepperPreviousTrigger`: Trigger to navigate to the previous step.
|
|
4154
|
+
* - `FormStepperNextTrigger`: Trigger to navigate to the next step.
|
|
4155
|
+
* - `FormStepperFinishTrigger`: Trigger to finish the form stepper.
|
|
4156
|
+
*
|
|
4157
|
+
* Example usage:
|
|
4158
|
+
*
|
|
4159
|
+
* ```tsx
|
|
4160
|
+
* import {
|
|
4161
|
+
* FormStep,
|
|
4162
|
+
* FormStepList,
|
|
4163
|
+
* FormStepper,
|
|
4164
|
+
* FormStepperFinishTrigger,
|
|
4165
|
+
* FormStepperNextTrigger,
|
|
4166
|
+
* FormStepperPreviousTrigger,
|
|
4167
|
+
* } from "@ostack.tech/ui-kform";
|
|
4168
|
+
*
|
|
4169
|
+
* function AccountSetupStepper() {
|
|
4170
|
+
* return (
|
|
4171
|
+
* <FormStepper>
|
|
4172
|
+
* <FormStepList />
|
|
4173
|
+
* <FormStep path="/profile" title="Personal profile">
|
|
4174
|
+
* Provide identification…
|
|
4175
|
+
* </FormStep>
|
|
4176
|
+
* <FormStep path="/preferences" title="Preferences">
|
|
4177
|
+
* Select preferences…
|
|
4178
|
+
* </FormStep>
|
|
4179
|
+
* <FormStep path="/terms" title="Terms & authorization">
|
|
4180
|
+
* Accept terms…
|
|
4181
|
+
* </FormStep>
|
|
4182
|
+
* <FormStepperPreviousTrigger />
|
|
4183
|
+
* <FormStepperNextTrigger />
|
|
4184
|
+
* <FormStepperFinishTrigger />
|
|
4185
|
+
* </FormStepper>
|
|
4186
|
+
* );
|
|
4187
|
+
* }
|
|
4188
|
+
* ```
|
|
4189
|
+
*/
|
|
4190
|
+
function FormStepper({ path, steps, defaultActiveStep, activeStep, onActiveStepChange, onStepValidation, skipStepValidationOnForwardNavigation, allowForwardNavigationOnError, preventFocusOnError, className, children, ...otherProps }) {
|
|
3697
4191
|
const prefix = usePrefix();
|
|
3698
4192
|
const formManager = useFormManager();
|
|
3699
4193
|
const absolutePath = useResolvedPath(path);
|
|
3700
|
-
steps ??=
|
|
3701
|
-
path: annex.props.path,
|
|
3702
|
-
title: annex.props.title,
|
|
3703
|
-
documentTitle: annex.props.documentTitle,
|
|
3704
|
-
issuesPanelLabel: annex.props.issuesPanelLabel
|
|
3705
|
-
}));
|
|
4194
|
+
steps ??= parseChildren(children, FormStep, { renderUnknownComponents: false });
|
|
3706
4195
|
const resolvedSteps = useMemo(() => steps.map((step, i) => ({
|
|
3707
4196
|
...step,
|
|
3708
4197
|
index: i,
|
|
@@ -3737,12 +4226,11 @@ var FormStepper = forwardRef(function FormStepper({ path, steps, defaultActiveSt
|
|
|
3737
4226
|
activeStep: activeIndex,
|
|
3738
4227
|
onActiveStepChange: goToStep,
|
|
3739
4228
|
...otherProps,
|
|
3740
|
-
ref: forwardedRef,
|
|
3741
4229
|
children
|
|
3742
4230
|
})]
|
|
3743
4231
|
})
|
|
3744
4232
|
});
|
|
3745
|
-
}
|
|
4233
|
+
}
|
|
3746
4234
|
//#endregion
|
|
3747
4235
|
//#region src/components/FormStepper/FormStepperFinishTrigger.tsx
|
|
3748
4236
|
/** Trigger used to conclude the form stepper. */
|
|
@@ -3758,7 +4246,7 @@ var FormStepperPreviousTrigger = StepperPreviousTrigger;
|
|
|
3758
4246
|
//#endregion
|
|
3759
4247
|
//#region src/components/IssuesAlert/IssuesAlert.tsx
|
|
3760
4248
|
/** Component used to display an issue alert. */
|
|
3761
|
-
|
|
4249
|
+
function IssuesAlert({ variant = "solid", path, issues, messages, displayIssueCodes, messagesDataKey, visuallyHiddenErrorCodePrefix, visuallyHiddenWarningCodePrefix, unknownErrorMessage, unknownWarningMessage, className, ...otherProps }) {
|
|
3762
4250
|
const prefix = usePrefix();
|
|
3763
4251
|
const formManager = useFormManager();
|
|
3764
4252
|
const absolutePath = useResolvedPath(path);
|
|
@@ -3779,7 +4267,6 @@ var IssuesAlert = forwardRef(function IssuesAlert({ variant = "solid", path, iss
|
|
|
3779
4267
|
variant,
|
|
3780
4268
|
...otherProps,
|
|
3781
4269
|
severity: severity ?? prevSeverity,
|
|
3782
|
-
ref: forwardedRef,
|
|
3783
4270
|
children: /* @__PURE__ */ jsx(FormAppIssueMessages, {
|
|
3784
4271
|
issueMessages: messagesToRegister,
|
|
3785
4272
|
children: /* @__PURE__ */ jsx(FeedbackList, { children: deferredIssuesToDisplay.map((issue, i) => /* @__PURE__ */ jsx(Feedback, {
|
|
@@ -3799,7 +4286,7 @@ var IssuesAlert = forwardRef(function IssuesAlert({ variant = "solid", path, iss
|
|
|
3799
4286
|
}, i)) })
|
|
3800
4287
|
})
|
|
3801
4288
|
});
|
|
3802
|
-
}
|
|
4289
|
+
}
|
|
3803
4290
|
//#endregion
|
|
3804
4291
|
//#region src/utils/useFormValidator.ts
|
|
3805
4292
|
/** Hook exposing a function used to validate the form. */
|
|
@@ -3951,7 +4438,7 @@ function IssuesPanelControls({ currentPagePath, nPages, currentPageIndex, curren
|
|
|
3951
4438
|
}
|
|
3952
4439
|
//#endregion
|
|
3953
4440
|
//#region src/components/IssuesPanel/IssuesPanelMessagesCard.tsx
|
|
3954
|
-
|
|
4441
|
+
function IssuesPanelMessagesCard({ currentPagePath, currentPageController, issuesTrackerResult, currentPageIndex, errorsLabel, warningsLabel, noIssuesMessage, resolvedTitle, resolvedMessage, displayIssueCodes, unknownErrorMessage, unknownWarningMessage, renderControls, headerProps, bodyProps, loadingSpinnerProps, titleProps, iconProps, className, ref, ...otherProps }) {
|
|
3955
4442
|
const prefix = usePrefix();
|
|
3956
4443
|
const { initialized, info } = issuesTrackerResult;
|
|
3957
4444
|
const nPages = info?.length ?? 0;
|
|
@@ -3989,7 +4476,7 @@ var IssuesPanelMessagesCard = forwardRef(function IssuesPanelMessagesCard({ curr
|
|
|
3989
4476
|
})
|
|
3990
4477
|
}, i))
|
|
3991
4478
|
})] });
|
|
3992
|
-
const combinedCardRef = useCombinedRef(setCardEl,
|
|
4479
|
+
const combinedCardRef = useCombinedRef(setCardEl, ref);
|
|
3993
4480
|
const combinedHeaderRef = useCombinedRef(headerRef, headerProps?.ref);
|
|
3994
4481
|
return /* @__PURE__ */ jsxs(Card, {
|
|
3995
4482
|
variant: "subtle",
|
|
@@ -4041,7 +4528,7 @@ var IssuesPanelMessagesCard = forwardRef(function IssuesPanelMessagesCard({ curr
|
|
|
4041
4528
|
]
|
|
4042
4529
|
})]
|
|
4043
4530
|
});
|
|
4044
|
-
}
|
|
4531
|
+
}
|
|
4045
4532
|
function Breadcrumb() {
|
|
4046
4533
|
const prefix = usePrefix();
|
|
4047
4534
|
const breadcrumb = useActiveIssuesPanelBreadcrumb();
|
|
@@ -4055,7 +4542,7 @@ function Breadcrumb() {
|
|
|
4055
4542
|
}
|
|
4056
4543
|
//#endregion
|
|
4057
4544
|
//#region src/components/IssuesPanel/IssuesPanelSummaryCard.tsx
|
|
4058
|
-
|
|
4545
|
+
function IssuesPanelSummaryCard({ issuesTrackerResult, errorsLabel, warningsLabel, noIssuesMessage, renderControls, headerProps, loadingSpinnerProps, titleProps, iconProps, className, ...otherProps }) {
|
|
4059
4546
|
const prefix = usePrefix();
|
|
4060
4547
|
const { initialized, info, errors, warnings } = issuesTrackerResult;
|
|
4061
4548
|
const nPages = info?.length ?? 0;
|
|
@@ -4067,7 +4554,6 @@ var IssuesPanelSummaryCard = forwardRef(function IssuesPanelSummaryCard({ issues
|
|
|
4067
4554
|
className: cx(prefix("issues-panel"), prefix("issues-panel--summary"), className),
|
|
4068
4555
|
...otherProps,
|
|
4069
4556
|
color: initialized ? relevantColor : "neutral",
|
|
4070
|
-
ref: forwardedRef,
|
|
4071
4557
|
children: /* @__PURE__ */ jsx(Layer, {
|
|
4072
4558
|
zIndex: "sticky",
|
|
4073
4559
|
children: /* @__PURE__ */ jsxs(CardHeader, {
|
|
@@ -4100,7 +4586,7 @@ var IssuesPanelSummaryCard = forwardRef(function IssuesPanelSummaryCard({ issues
|
|
|
4100
4586
|
})
|
|
4101
4587
|
})
|
|
4102
4588
|
});
|
|
4103
|
-
}
|
|
4589
|
+
}
|
|
4104
4590
|
//#endregion
|
|
4105
4591
|
//#region src/components/IssuesPanel/IssuesPanel.tsx
|
|
4106
4592
|
/** Default “focus” keybinds. */
|
|
@@ -4114,22 +4600,22 @@ var DEFAULT_FIRST_ISSUE_KEYBINDS = "Alt+Shift+Home";
|
|
|
4114
4600
|
/** Default “last issue” keybinds. */
|
|
4115
4601
|
var DEFAULT_LAST_ISSUE_KEYBINDS = "Alt+Shift+End";
|
|
4116
4602
|
/** Component used to navigate through the issues of the form. */
|
|
4117
|
-
|
|
4603
|
+
function IssuesPanel({ defaultOpen = false, open: controlledOpen, onOpenChange, displayIssueCodes, issuesOrderCompareFn, unknownErrorMessage, unknownWarningMessage, errorsLabel, warningsLabel, focusButtonLabel, focusKeybinds: focusKeybindsProp, previousIssueButtonLabel, previousIssueKeybinds: previousIssueKeybindsProp, nextIssueButtonLabel, nextIssueKeybinds: nextIssueKeybindsProp, firstIssueButtonLabel, firstIssueKeybinds: firstIssueKeybindsProp, lastIssueButtonLabel, lastIssueKeybinds: lastIssueKeybindsProp, paginationLabel, noIssuesMessage, resolvedTitle, resolvedMessage, containerProps, headerProps, bodyProps, loadingSpinnerProps, validatingSpinnerProps, paginationProps, focusButtonProps, previousIssueButtonProps, nextIssueButtonProps, firstIssueButtonProps, lastIssueButtonProps, titleProps, iconProps, closeButtonProps, ...otherProps }) {
|
|
4118
4604
|
const prefix = usePrefix();
|
|
4119
4605
|
const printing = usePrinting();
|
|
4120
4606
|
const [locale] = useLocale();
|
|
4121
4607
|
errorsLabel ??= locale.IssuesPanel.errorsLabel;
|
|
4122
4608
|
warningsLabel ??= locale.IssuesPanel.warningsLabel;
|
|
4123
4609
|
focusButtonLabel ??= locale.IssuesPanel.focusButtonLabel;
|
|
4124
|
-
|
|
4610
|
+
const focusKeybinds = focusKeybindsProp === void 0 ? locale.IssuesPanel.focusKeybinds ?? "Alt+Shift+F" : focusKeybindsProp;
|
|
4125
4611
|
previousIssueButtonLabel ??= locale.IssuesPanel.previousIssueButtonLabel;
|
|
4126
|
-
|
|
4612
|
+
const previousIssueKeybinds = previousIssueKeybindsProp === void 0 ? locale.IssuesPanel.previousIssueKeybinds ?? "Alt+Shift+ArrowLeft" : previousIssueKeybindsProp;
|
|
4127
4613
|
nextIssueButtonLabel ??= locale.IssuesPanel.nextIssueButtonLabel;
|
|
4128
|
-
|
|
4614
|
+
const nextIssueKeybinds = nextIssueKeybindsProp === void 0 ? locale.IssuesPanel.nextIssueKeybinds ?? "Alt+Shift+ArrowRight" : nextIssueKeybindsProp;
|
|
4129
4615
|
firstIssueButtonLabel ??= locale.IssuesPanel.firstIssueButtonLabel;
|
|
4130
|
-
|
|
4616
|
+
const firstIssueKeybinds = firstIssueKeybindsProp === void 0 ? locale.IssuesPanel.firstIssueKeybinds ?? "Alt+Shift+Home" : firstIssueKeybindsProp;
|
|
4131
4617
|
lastIssueButtonLabel ??= locale.IssuesPanel.lastIssueButtonLabel;
|
|
4132
|
-
|
|
4618
|
+
const lastIssueKeybinds = lastIssueKeybindsProp === void 0 ? locale.IssuesPanel.lastIssueKeybinds ?? "Alt+Shift+End" : lastIssueKeybindsProp;
|
|
4133
4619
|
paginationLabel ??= locale.IssuesPanel.paginationLabel;
|
|
4134
4620
|
noIssuesMessage ??= locale.IssuesPanel.noIssuesMessage;
|
|
4135
4621
|
resolvedTitle ??= locale.IssuesPanel.resolvedTitle;
|
|
@@ -4147,28 +4633,33 @@ var IssuesPanel = forwardRef(function ValidationPanel({ defaultOpen = false, ope
|
|
|
4147
4633
|
const nPages = info?.length ?? 0;
|
|
4148
4634
|
const [currentPagePath, setCurrentPagePath] = useIssuesPanelPath();
|
|
4149
4635
|
const currentPageController = useController(currentPagePath ?? AbsolutePath.ROOT, { enabled: open && !formIsLoading && currentPagePath !== null });
|
|
4636
|
+
const prevIssuesTrackerResultInfoLength = usePrevious(issuesTrackerResult.info?.length);
|
|
4637
|
+
const handleNewIssues = useEffectEvent(() => {
|
|
4638
|
+
setCurrentPagePath(latestInteraction);
|
|
4639
|
+
});
|
|
4150
4640
|
useEffect(() => {
|
|
4151
|
-
if (
|
|
4641
|
+
if (prevIssuesTrackerResultInfoLength === 0 && issuesTrackerResult.initialized && issuesTrackerResult.info.length > 0) handleNewIssues();
|
|
4152
4642
|
}, [
|
|
4153
|
-
currentPagePath,
|
|
4154
4643
|
issuesTrackerResult.info?.length,
|
|
4155
4644
|
issuesTrackerResult.initialized,
|
|
4156
|
-
|
|
4157
|
-
setCurrentPagePath
|
|
4645
|
+
prevIssuesTrackerResultInfoLength
|
|
4158
4646
|
]);
|
|
4647
|
+
const currentPageIndex = useMemo(() => currentPagePath ? info?.findIndex(({ path }) => currentPagePath.equals(path)) ?? -1 : -1, [currentPagePath, info]);
|
|
4159
4648
|
const lastExistingPageIndex = useRef(null);
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
return idx;
|
|
4164
|
-
}, [currentPagePath, info]);
|
|
4649
|
+
useEffect(() => {
|
|
4650
|
+
if (currentPageIndex !== -1) lastExistingPageIndex.current = currentPageIndex;
|
|
4651
|
+
}, [currentPageIndex]);
|
|
4165
4652
|
const focus = useFocus();
|
|
4166
4653
|
const goToPath = useCallback((path) => {
|
|
4167
4654
|
setCurrentPagePath(path);
|
|
4168
4655
|
if (path) focus(path);
|
|
4169
4656
|
}, [focus, setCurrentPagePath]);
|
|
4170
4657
|
const goToPage = useCallback((page) => {
|
|
4171
|
-
if (nPages > 0)
|
|
4658
|
+
if (nPages > 0) {
|
|
4659
|
+
const clampedPage = Math.max(0, Math.min(page, nPages - 1));
|
|
4660
|
+
const newCurrentPath = info[clampedPage].path ?? null;
|
|
4661
|
+
goToPath(newCurrentPath);
|
|
4662
|
+
}
|
|
4172
4663
|
}, [
|
|
4173
4664
|
goToPath,
|
|
4174
4665
|
info,
|
|
@@ -4186,12 +4677,14 @@ var IssuesPanel = forwardRef(function ValidationPanel({ defaultOpen = false, ope
|
|
|
4186
4677
|
const goToLastPage = useCallback(() => goToPage(nPages - 1), [goToPage, nPages]);
|
|
4187
4678
|
const formManager = useFormManager();
|
|
4188
4679
|
const formSchema = useMemo(() => formManager.schema(), [formManager]);
|
|
4189
|
-
const
|
|
4190
|
-
|
|
4680
|
+
const latestRef = useLatestRef({
|
|
4681
|
+
issuesOrderCompareFn,
|
|
4682
|
+
onOpenChange
|
|
4683
|
+
});
|
|
4191
4684
|
const [starting, setStarting] = useState(false);
|
|
4192
4685
|
useEffect(() => {
|
|
4193
4686
|
if (issuesTrackerResult.initialized && starting) {
|
|
4194
|
-
if (issuesTrackerResult.info.length > 0) goToPath(mostRelevantIssuePath(issuesTrackerResult.info, latestInteraction, formSchema,
|
|
4687
|
+
if (issuesTrackerResult.info.length > 0) goToPath(mostRelevantIssuePath(issuesTrackerResult.info, latestInteraction, formSchema, latestRef.current.issuesOrderCompareFn));
|
|
4195
4688
|
setStarting(false);
|
|
4196
4689
|
}
|
|
4197
4690
|
}, [
|
|
@@ -4200,9 +4693,9 @@ var IssuesPanel = forwardRef(function ValidationPanel({ defaultOpen = false, ope
|
|
|
4200
4693
|
issuesTrackerResult.info,
|
|
4201
4694
|
issuesTrackerResult.initialized,
|
|
4202
4695
|
latestInteraction,
|
|
4696
|
+
latestRef,
|
|
4203
4697
|
starting
|
|
4204
4698
|
]);
|
|
4205
|
-
const latestRef = useLatestRef({ onOpenChange });
|
|
4206
4699
|
useSetStartIssuesNavigation(useCallback(() => {
|
|
4207
4700
|
if (!open) {
|
|
4208
4701
|
setOpen(true);
|
|
@@ -4288,8 +4781,7 @@ var IssuesPanel = forwardRef(function ValidationPanel({ defaultOpen = false, ope
|
|
|
4288
4781
|
loadingSpinnerProps,
|
|
4289
4782
|
titleProps,
|
|
4290
4783
|
iconProps,
|
|
4291
|
-
...otherProps
|
|
4292
|
-
ref: forwardedRef
|
|
4784
|
+
...otherProps
|
|
4293
4785
|
}) : /* @__PURE__ */ jsx(IssuesPanelMessagesCard, {
|
|
4294
4786
|
currentPagePath,
|
|
4295
4787
|
currentPageController,
|
|
@@ -4309,13 +4801,12 @@ var IssuesPanel = forwardRef(function ValidationPanel({ defaultOpen = false, ope
|
|
|
4309
4801
|
loadingSpinnerProps,
|
|
4310
4802
|
titleProps,
|
|
4311
4803
|
iconProps,
|
|
4312
|
-
...otherProps
|
|
4313
|
-
ref: forwardedRef
|
|
4804
|
+
...otherProps
|
|
4314
4805
|
})
|
|
4315
4806
|
})
|
|
4316
4807
|
})
|
|
4317
4808
|
});
|
|
4318
|
-
}
|
|
4809
|
+
}
|
|
4319
4810
|
/**
|
|
4320
4811
|
* Function attempting to return the "most relevant" issue, given the list of
|
|
4321
4812
|
* issue information, the path of the current page, and the path the user last
|
|
@@ -4340,8 +4831,27 @@ function mostRelevantIssuePath(info, latestInteraction, formSchema, issuesOrderC
|
|
|
4340
4831
|
//#region src/components/LoadAction/LoadAction.tsx
|
|
4341
4832
|
/** Default “load” keybinds. */
|
|
4342
4833
|
var DEFAULT_LOAD_KEYBINDS = "$mod+O";
|
|
4343
|
-
/**
|
|
4344
|
-
|
|
4834
|
+
/**
|
|
4835
|
+
* Form action used to load the form from a file. Built on top of the [`Button`
|
|
4836
|
+
* component](/docs/ostack-ui-forms-button--docs) and `useFormLoader` hook.
|
|
4837
|
+
*
|
|
4838
|
+
* Example usage:
|
|
4839
|
+
*
|
|
4840
|
+
* ```tsx
|
|
4841
|
+
* import { LoadAction } from "@ostack.tech/ui-kform";
|
|
4842
|
+
*
|
|
4843
|
+
* function LoadForm() {
|
|
4844
|
+
* return (
|
|
4845
|
+
* <LoadAction
|
|
4846
|
+
* decode={async (file) => decodeFormFromJSON(await file.text())}
|
|
4847
|
+
* mimeTypes={["application/json"]}
|
|
4848
|
+
* extensions={[".json"]}
|
|
4849
|
+
* />
|
|
4850
|
+
* );
|
|
4851
|
+
* }
|
|
4852
|
+
* ```
|
|
4853
|
+
*/
|
|
4854
|
+
function LoadAction({ label, keybinds, showWhenReadOnly, fileSystemId, loading, disabled, onClick, decode, path, extensions, mimeTypes, description, startIn, setPristineOnLoad, validateOnLoad, successMessage, errorMessage, ...otherProps }) {
|
|
4345
4855
|
const [locale] = useLocale();
|
|
4346
4856
|
label ??= locale.LoadAction.label;
|
|
4347
4857
|
if (keybinds === void 0) keybinds = locale.LoadAction.keybinds ?? "$mod+O";
|
|
@@ -4352,28 +4862,32 @@ function LoadAction({ label, keybinds, loading, disabled, onClick, decode, path,
|
|
|
4352
4862
|
mimeTypes,
|
|
4353
4863
|
description,
|
|
4354
4864
|
startIn,
|
|
4355
|
-
id,
|
|
4865
|
+
id: fileSystemId,
|
|
4356
4866
|
setPristineOnLoad,
|
|
4357
4867
|
validateOnLoad,
|
|
4358
4868
|
successMessage,
|
|
4359
4869
|
errorMessage
|
|
4360
4870
|
});
|
|
4361
4871
|
const formIsDisabled = useFormIsDisabled();
|
|
4872
|
+
const formIsReadOnly = useFormIsReadOnly();
|
|
4362
4873
|
const formIsLoading = useFormIsLoading();
|
|
4874
|
+
const showAction = !formIsReadOnly || showWhenReadOnly;
|
|
4875
|
+
const showDisabled = disabled || formIsDisabled;
|
|
4876
|
+
const showLoading = loading || formIsLoading;
|
|
4363
4877
|
const formAppEl = useFormAppElement();
|
|
4364
4878
|
useKeyboardShortcut(keybinds, () => load(), {
|
|
4365
|
-
disabled:
|
|
4879
|
+
disabled: !showAction || showDisabled || showLoading,
|
|
4366
4880
|
target: formAppEl,
|
|
4367
4881
|
preventDefault: true
|
|
4368
4882
|
});
|
|
4369
|
-
return /* @__PURE__ */ jsx(Button, {
|
|
4883
|
+
return showAction && /* @__PURE__ */ jsx(Button, {
|
|
4370
4884
|
vertical: true,
|
|
4371
4885
|
variant: "subtle",
|
|
4372
4886
|
icon: faFolderOpen,
|
|
4373
4887
|
...otherProps,
|
|
4374
4888
|
onClick: combineEventHandlers(() => load(), onClick),
|
|
4375
|
-
disabled:
|
|
4376
|
-
loading:
|
|
4889
|
+
disabled: showDisabled,
|
|
4890
|
+
loading: showLoading,
|
|
4377
4891
|
keybinds,
|
|
4378
4892
|
children: label
|
|
4379
4893
|
});
|
|
@@ -4389,8 +4903,51 @@ var INTEGER_TYPES = [
|
|
|
4389
4903
|
"Long",
|
|
4390
4904
|
"BigInteger"
|
|
4391
4905
|
];
|
|
4392
|
-
/**
|
|
4393
|
-
|
|
4906
|
+
/**
|
|
4907
|
+
* The numeric control component is a KForm form control for values with
|
|
4908
|
+
* (typically nullable) numeric schemas. It is built on top of the
|
|
4909
|
+
* [`NumericInput`](/docs/ostack-ui-forms-numeric-input--docs) component.
|
|
4910
|
+
*
|
|
4911
|
+
* The following (typically
|
|
4912
|
+
* [nullable](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-nullable-schema/index.html))
|
|
4913
|
+
* KForm schemas are supported:
|
|
4914
|
+
* [`ByteSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-byte-schema/index.html),
|
|
4915
|
+
* [`CharSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-char-schema/index.html),
|
|
4916
|
+
* [`ShortSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-short-schema/index.html),
|
|
4917
|
+
* [`IntSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-int-schema/index.html),
|
|
4918
|
+
* [`LongSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-long-schema/index.html),
|
|
4919
|
+
* [`FloatSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-float-schema/index.html),
|
|
4920
|
+
* [`DoubleSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-double-schema/index.html),
|
|
4921
|
+
* [`BigIntegerSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-big-integer-schema/index.html),
|
|
4922
|
+
* [`BigDecimalSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-big-decimal-schema/index.html),
|
|
4923
|
+
* and
|
|
4924
|
+
* [`StringSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-string-schema/index.html).
|
|
4925
|
+
*
|
|
4926
|
+
* The following built-in KForm validations affect this control:
|
|
4927
|
+
*
|
|
4928
|
+
* - [`Required`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-required/index.html):
|
|
4929
|
+
* Sets the `required` property.
|
|
4930
|
+
* - [`Min`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-min/index.html)/[`Max`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-max/index.html)/[`ExclusiveMin`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-exclusive-min/index.html)/[`ExclusiveMax`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-exclusive-max/index.html):
|
|
4931
|
+
* Sets the `min`/`max`/`minExclusive`/`maxExclusive` properties.
|
|
4932
|
+
* - [`Scale`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-scale/index.html)/[`MaxScale`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-max-scale/index.html):
|
|
4933
|
+
* Sets the `scale` property.
|
|
4934
|
+
*
|
|
4935
|
+
* The `valueIsInteger` property is further automatically set for integer
|
|
4936
|
+
* schemas (`Byte`, `Char`, `Short`, `Int`, `Long`, and `BigInteger`).
|
|
4937
|
+
*
|
|
4938
|
+
* Example usage:
|
|
4939
|
+
*
|
|
4940
|
+
* ```tsx
|
|
4941
|
+
* import { NumericControl } from "@ostack.tech/ui-kform";
|
|
4942
|
+
*
|
|
4943
|
+
* function QuantityControl() {
|
|
4944
|
+
* return (
|
|
4945
|
+
* <NumericControl path="/quantity" placeholder="Number of items…" />
|
|
4946
|
+
* );
|
|
4947
|
+
* }
|
|
4948
|
+
* ```
|
|
4949
|
+
*/
|
|
4950
|
+
function NumericControl({ path, issueMessages, issuesPanelLabel, displayIssues = true, preventAutoFocus, apiRef, issueMessagesProps, formManager, onInitialized, onFormManagerEvent, onValueChange, onValidationStatusChange, onDisplayStatusChange, onDirtyStatusChange, onTouchedStatusChange, valueIsInteger, scale, required, min, max, exclusiveMin, exclusiveMax, loading, showSpinner, disabled, readOnly, endAdornment, onFocus, onBlurToOutside, debug, ref, ...otherProps }) {
|
|
4394
4951
|
const [stringValue, setStringValue] = useState("");
|
|
4395
4952
|
const controller = useNumericInput(path, {
|
|
4396
4953
|
enabled: !useFormIsLoading(),
|
|
@@ -4408,6 +4965,7 @@ var NumericControl = forwardRef(function NumericControl({ path, issueMessages, i
|
|
|
4408
4965
|
const schema = useSchema();
|
|
4409
4966
|
const absolutePath = usePath();
|
|
4410
4967
|
const { restrictions } = schema.typeInfo;
|
|
4968
|
+
const showDebugInfo = useFormInDebugMode() || debug;
|
|
4411
4969
|
const { displayLoading, displayDisabled, displayReadOnly, displayStatusToDisplay, displayValidating, issuesToDisplay, autofocusRef, handleFocus } = useRegisterControl({
|
|
4412
4970
|
controller,
|
|
4413
4971
|
issuesPanelLabel,
|
|
@@ -4415,28 +4973,28 @@ var NumericControl = forwardRef(function NumericControl({ path, issueMessages, i
|
|
|
4415
4973
|
preventAutoFocus,
|
|
4416
4974
|
apiRef
|
|
4417
4975
|
});
|
|
4418
|
-
const
|
|
4419
|
-
latestStringValueRef.current = stringValue;
|
|
4976
|
+
const latestRef = useLatestRef({ stringValue });
|
|
4420
4977
|
const handleValueChange = useCallback(({ stringValue }) => {
|
|
4421
|
-
if (stringValue !==
|
|
4978
|
+
if (stringValue !== latestRef.current.stringValue) {
|
|
4422
4979
|
inputProps.onChange(stringValue);
|
|
4423
4980
|
setStringValue(stringValue);
|
|
4424
4981
|
}
|
|
4425
|
-
}, [inputProps]);
|
|
4982
|
+
}, [inputProps, latestRef]);
|
|
4426
4983
|
const schemaIsInteger = INTEGER_TYPES.includes(schema.typeInfo.name);
|
|
4427
4984
|
if (schemaIsInteger && valueIsInteger !== void 0) warnOnce(`NumericControl: At '${absolutePath.toString()}': Property \`valueIsInteger\` has no effect (it will always be \`true\`) when the control's schema is one of the integer types.`);
|
|
4428
|
-
const
|
|
4985
|
+
const { inlineIssues, popoverIssues } = useControlIssues({
|
|
4429
4986
|
issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },
|
|
4430
4987
|
issueMessages: { [absolutePath.toString()]: issueMessages },
|
|
4431
4988
|
displayIssues,
|
|
4432
|
-
issueMessagesProps
|
|
4989
|
+
issueMessagesProps,
|
|
4990
|
+
variant: otherProps.variant
|
|
4433
4991
|
});
|
|
4434
|
-
const combinedNumericInputRef = useCombinedRef(inputProps.ref, autofocusRef,
|
|
4435
|
-
return /* @__PURE__ */ jsxs(
|
|
4992
|
+
const combinedNumericInputRef = useCombinedRef(inputProps.ref, autofocusRef, ref);
|
|
4993
|
+
return /* @__PURE__ */ jsxs(FeedbackProvider, { children: [/* @__PURE__ */ jsx(NumericInput, {
|
|
4436
4994
|
value: stringValue,
|
|
4437
4995
|
valueIsUnformattedString: true,
|
|
4438
4996
|
valueIsInteger: schemaIsInteger || valueIsInteger,
|
|
4439
|
-
scale:
|
|
4997
|
+
scale: scale ?? (restrictions.maxScale == null ? void 0 : restrictions.maxScale),
|
|
4440
4998
|
name: inputProps.name,
|
|
4441
4999
|
required: required ?? restrictions.required === true,
|
|
4442
5000
|
min: min ?? (restrictions.min == null ? void 0 : formatNumericAsString(restrictions.min, schema)),
|
|
@@ -4448,18 +5006,25 @@ var NumericControl = forwardRef(function NumericControl({ path, issueMessages, i
|
|
|
4448
5006
|
disabled: displayDisabled || disabled || inputProps.disabled,
|
|
4449
5007
|
readOnly: displayReadOnly || readOnly || inputProps.readOnly,
|
|
4450
5008
|
status: displayStatusToControlStatus(displayStatusToDisplay),
|
|
4451
|
-
endAdornment: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5009
|
+
endAdornment: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5010
|
+
popoverIssues,
|
|
5011
|
+
endAdornment,
|
|
5012
|
+
(DEV || false) && showDebugInfo && /* @__PURE__ */ jsx(DebugInfo, {
|
|
5013
|
+
path: absolutePath,
|
|
5014
|
+
children: /* @__PURE__ */ jsx(DebugInfoControlAddonTrigger, {})
|
|
5015
|
+
})
|
|
5016
|
+
] }),
|
|
4452
5017
|
onValueChange: handleValueChange,
|
|
4453
5018
|
onFocus: combineEventHandlers(onFocus, handleFocus),
|
|
4454
5019
|
onBlurToOutside: combineEventHandlers(onBlurToOutside, inputProps.onBlur),
|
|
4455
5020
|
...otherProps,
|
|
4456
5021
|
ref: combinedNumericInputRef
|
|
4457
5022
|
}), inlineIssues] });
|
|
4458
|
-
}
|
|
5023
|
+
}
|
|
4459
5024
|
//#endregion
|
|
4460
5025
|
//#region src/components/PathLink/PathLink.tsx
|
|
4461
5026
|
/** Link to a KForm path. */
|
|
4462
|
-
|
|
5027
|
+
function PathLink({ as = "button", to, onClick, ...otherProps }) {
|
|
4463
5028
|
const focus = useFocus();
|
|
4464
5029
|
const path = useResolvedPath(to);
|
|
4465
5030
|
const handleClick = (evt) => {
|
|
@@ -4469,79 +5034,148 @@ var PathLink = forwardRef(function PathLink({ as = "button", to, onClick, ...oth
|
|
|
4469
5034
|
return /* @__PURE__ */ jsx(Link, {
|
|
4470
5035
|
as,
|
|
4471
5036
|
...otherProps,
|
|
4472
|
-
onClick: combineEventHandlers(onClick, handleClick, { checkDefaultPrevented: true })
|
|
4473
|
-
ref: forwardedRef
|
|
5037
|
+
onClick: combineEventHandlers(onClick, handleClick, { checkDefaultPrevented: true })
|
|
4474
5038
|
});
|
|
4475
|
-
}
|
|
5039
|
+
}
|
|
4476
5040
|
//#endregion
|
|
4477
5041
|
//#region src/components/PrintAction/PrintAction.tsx
|
|
4478
5042
|
/** Default “print” keybinds. */
|
|
4479
5043
|
var DEFAULT_PRINT_KEYBINDS = "$mod+P";
|
|
4480
5044
|
/**
|
|
4481
|
-
*
|
|
4482
|
-
*
|
|
4483
|
-
*
|
|
5045
|
+
* Form action used to print the form application. Built on top of the
|
|
5046
|
+
* [`Button`](/docs/ostack-ui-forms-button--docs) and
|
|
5047
|
+
* [`PrinterTrigger`](/docs/ostack-ui-utilities-printer--docs) components.
|
|
4484
5048
|
*
|
|
4485
|
-
*
|
|
5049
|
+
* To print a whole form application, requires the `<FormApp>` component to be
|
|
5050
|
+
* wrapped within a `<Printer>`, and for the `<PrinterContent>` to wrap all
|
|
5051
|
+
* annexes, pages, and form controls.
|
|
5052
|
+
*
|
|
5053
|
+
* Example usage:
|
|
4486
5054
|
*
|
|
4487
5055
|
* ```tsx
|
|
4488
|
-
*
|
|
4489
|
-
*
|
|
4490
|
-
*
|
|
4491
|
-
*
|
|
4492
|
-
*
|
|
4493
|
-
*
|
|
4494
|
-
*
|
|
4495
|
-
*
|
|
4496
|
-
*
|
|
4497
|
-
*
|
|
4498
|
-
*
|
|
5056
|
+
* import { Printer, PrinterContent } from "@ostack.tech/ui";
|
|
5057
|
+
* import {
|
|
5058
|
+
* FormApp,
|
|
5059
|
+
* PrintAction,
|
|
5060
|
+
* TopBar,
|
|
5061
|
+
* TopBarActions,
|
|
5062
|
+
* } from "@ostack.tech/ui-kform";
|
|
5063
|
+
*
|
|
5064
|
+
* export function App() {
|
|
5065
|
+
* return (
|
|
5066
|
+
* <Printer>
|
|
5067
|
+
* <FormApp schema={…}>
|
|
5068
|
+
* <PrinterContent>
|
|
5069
|
+
* <TopBar>
|
|
5070
|
+
* …
|
|
5071
|
+
* <TopBarActions>
|
|
5072
|
+
* …
|
|
5073
|
+
* <PrintAction />
|
|
5074
|
+
* </TopBarActions>
|
|
5075
|
+
* </TopBar>
|
|
5076
|
+
* …
|
|
5077
|
+
* </PrinterContent>
|
|
5078
|
+
* </FormApp>
|
|
5079
|
+
* </Printer>
|
|
5080
|
+
* );
|
|
5081
|
+
* }
|
|
4499
5082
|
* ```
|
|
4500
5083
|
*/
|
|
4501
|
-
function PrintAction({ label, keybinds, disabled, loading, onClick, ...otherProps }) {
|
|
5084
|
+
function PrintAction({ label, keybinds, showWhenReadOnly = true, disabled, loading, onClick, ...otherProps }) {
|
|
4502
5085
|
const [locale] = useLocale();
|
|
4503
5086
|
label ??= locale.PrintAction.label;
|
|
4504
5087
|
if (keybinds === void 0) keybinds = locale.PrintAction.keybinds ?? "$mod+P";
|
|
4505
5088
|
const printInProgress = usePrintInProgress();
|
|
4506
5089
|
const formIsDisabled = useFormIsDisabled();
|
|
5090
|
+
const formIsReadOnly = useFormIsReadOnly();
|
|
4507
5091
|
const formIsLoading = useFormIsLoading();
|
|
5092
|
+
const showAction = !formIsReadOnly || showWhenReadOnly;
|
|
5093
|
+
const showDisabled = disabled || formIsDisabled || formIsLoading;
|
|
5094
|
+
const showLoading = loading || printInProgress;
|
|
4508
5095
|
const formAppEl = useFormAppElement();
|
|
4509
5096
|
const formTitle = useFormTitle();
|
|
4510
5097
|
const print = usePrint();
|
|
4511
5098
|
const printerHasDocumentTitle = Boolean(usePrinterDocumentTitle());
|
|
4512
5099
|
const handlePrint = (evt) => {
|
|
4513
5100
|
evt.preventDefault();
|
|
4514
|
-
print(printerHasDocumentTitle ? void 0 : { documentTitle:
|
|
5101
|
+
print(printerHasDocumentTitle ? void 0 : { documentTitle: formTitle });
|
|
4515
5102
|
};
|
|
4516
5103
|
useKeyboardShortcut(keybinds, handlePrint, {
|
|
4517
|
-
disabled:
|
|
5104
|
+
disabled: !showAction || showDisabled || showLoading,
|
|
4518
5105
|
target: formAppEl,
|
|
4519
5106
|
preventDefault: true
|
|
4520
5107
|
});
|
|
4521
|
-
return /* @__PURE__ */ jsx(PrinterTrigger, {
|
|
5108
|
+
return showAction && /* @__PURE__ */ jsx(PrinterTrigger, {
|
|
4522
5109
|
onClick: combineEventHandlers(onClick, handlePrint, { checkDefaultPrevented: true }),
|
|
4523
5110
|
children: /* @__PURE__ */ jsx(Button, {
|
|
4524
5111
|
vertical: true,
|
|
4525
5112
|
variant: "subtle",
|
|
4526
5113
|
icon: faPrint,
|
|
4527
5114
|
...otherProps,
|
|
4528
|
-
|
|
4529
|
-
|
|
5115
|
+
disabled: showDisabled,
|
|
5116
|
+
loading: showLoading,
|
|
4530
5117
|
keybinds,
|
|
4531
5118
|
children: label
|
|
4532
5119
|
})
|
|
4533
5120
|
});
|
|
4534
5121
|
}
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
5122
|
+
//#endregion
|
|
5123
|
+
//#region src/components/RadioGroupControl/RadioGroupControlItem.tsx
|
|
5124
|
+
/**
|
|
5125
|
+
* Definition of a radio group control item.
|
|
5126
|
+
*
|
|
5127
|
+
* This component doesn't actually render anything by itself; it is used by the
|
|
5128
|
+
* `RadioGroupControl` component to automatically create the `options` array.
|
|
5129
|
+
*/
|
|
5130
|
+
function RadioGroupControlItem(_props) {
|
|
5131
|
+
return null;
|
|
4538
5132
|
}
|
|
4539
5133
|
//#endregion
|
|
4540
5134
|
//#region src/components/RadioGroupControl/RadioGroupControl.tsx
|
|
4541
|
-
/**
|
|
4542
|
-
|
|
5135
|
+
/**
|
|
5136
|
+
* The radio group control component is a KForm form control for values with any
|
|
5137
|
+
* type of (typically
|
|
5138
|
+
* [nullable](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-nullable-schema/index.html))
|
|
5139
|
+
* schema. It is built on top of the
|
|
5140
|
+
* [`RadioGroup`](/docs/ostack-ui-forms-radio-group--docs) component.
|
|
5141
|
+
*
|
|
5142
|
+
* It composes the following subcomponent:
|
|
5143
|
+
*
|
|
5144
|
+
* - `RadioGroupControlItem`: Component used to define an item of the radio group
|
|
5145
|
+
* control.
|
|
5146
|
+
*
|
|
5147
|
+
* The following built-in KForm validation affects this control:
|
|
5148
|
+
*
|
|
5149
|
+
* - [`Required`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-required/index.html):
|
|
5150
|
+
* Sets the `required` property.
|
|
5151
|
+
*
|
|
5152
|
+
* Example usage:
|
|
5153
|
+
*
|
|
5154
|
+
* ```tsx
|
|
5155
|
+
* import {
|
|
5156
|
+
* RadioGroupControl,
|
|
5157
|
+
* RadioGroupControlItem,
|
|
5158
|
+
* } from "@ostack.tech/ui-kform";
|
|
5159
|
+
*
|
|
5160
|
+
* function ShirtSizeControl() {
|
|
5161
|
+
* return (
|
|
5162
|
+
* <RadioGroupControl path="/shirtSize">
|
|
5163
|
+
* <RadioGroupControlItem value="sm">Small</RadioGroupControlItem>
|
|
5164
|
+
* <RadioGroupControlItem value="md">Medium</RadioGroupControlItem>
|
|
5165
|
+
* <RadioGroupControlItem value="lg">Large</RadioGroupControlItem>
|
|
5166
|
+
* <RadioGroupControlItem value="xl">X-Large</RadioGroupControlItem>
|
|
5167
|
+
* </RadioGroupControl>
|
|
5168
|
+
* );
|
|
5169
|
+
* }
|
|
5170
|
+
* ```
|
|
5171
|
+
*/
|
|
5172
|
+
function RadioGroupControl({ path, options, issueMessages, issuesPanelLabel, displayIssues = true, unknownValueLabel, preventAutoFocus, apiRef, issueMessagesProps, formManager, onInitialized, onFormManagerEvent, onValueChange, onValidationStatusChange, onDisplayStatusChange, onDirtyStatusChange, onTouchedStatusChange, required, loading, showSpinner, disabled, readOnly, showClearButton = false, endAdornment, onFocus, onBlurToOutside, children, debug, ref, ...otherProps }) {
|
|
4543
5173
|
const [locale] = useLocale();
|
|
4544
5174
|
unknownValueLabel ??= locale.RadioGroupControl.unknownValueLabel;
|
|
5175
|
+
options ??= parseChildren(children, RadioGroupControlItem, { transformChildObject: ({ children, ...otherProps }) => ({
|
|
5176
|
+
text: children,
|
|
5177
|
+
...otherProps
|
|
5178
|
+
}) });
|
|
4545
5179
|
const [value, setValue] = useState();
|
|
4546
5180
|
const isUnknown = useMemo(() => isUnknownValue(value, options), [options, value]);
|
|
4547
5181
|
const formattedValue = useMemo(() => formatSelectionValueAsOptionIndex(value, options), [options, value]);
|
|
@@ -4561,6 +5195,7 @@ var RadioGroupControl = forwardRef(function RadioGroupControl({ path, options, i
|
|
|
4561
5195
|
const schema = useSchema();
|
|
4562
5196
|
const absolutePath = usePath();
|
|
4563
5197
|
const { nullable, restrictions } = schema.typeInfo;
|
|
5198
|
+
const showDebugInfo = useFormInDebugMode() || debug;
|
|
4564
5199
|
const { displayLoading, displayDisabled, displayReadOnly, displayStatusToDisplay, displayValidating, issuesToDisplay, autofocusRef, handleFocus } = useRegisterControl({
|
|
4565
5200
|
controller,
|
|
4566
5201
|
issuesPanelLabel,
|
|
@@ -4583,46 +5218,48 @@ var RadioGroupControl = forwardRef(function RadioGroupControl({ path, options, i
|
|
|
4583
5218
|
const clearedValue = nullable ? null : schema.initialValue;
|
|
4584
5219
|
const clearedIdx = useMemo(() => options.findIndex((option) => equals(option.value, clearedValue)), [clearedValue, options]);
|
|
4585
5220
|
const clearedFormattedValue = clearedIdx === -1 ? "" : clearedIdx.toString();
|
|
4586
|
-
const
|
|
5221
|
+
const { inlineIssues, popoverIssues } = useControlIssues({
|
|
4587
5222
|
issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },
|
|
4588
5223
|
issueMessages: { [absolutePath.toString()]: issueMessages },
|
|
4589
5224
|
displayIssues,
|
|
4590
|
-
issueMessagesProps
|
|
5225
|
+
issueMessagesProps,
|
|
5226
|
+
variant: otherProps.variant
|
|
4591
5227
|
});
|
|
4592
|
-
const combinedRadioGroupRef = useCombinedRef(inputProps.ref, autofocusRef,
|
|
4593
|
-
return /* @__PURE__ */ jsxs(
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
value
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
});
|
|
5228
|
+
const combinedRadioGroupRef = useCombinedRef(inputProps.ref, autofocusRef, ref);
|
|
5229
|
+
return /* @__PURE__ */ jsxs(FeedbackProvider, { children: [/* @__PURE__ */ jsxs(RadioGroup, {
|
|
5230
|
+
value: formattedValue,
|
|
5231
|
+
name: inputProps.name,
|
|
5232
|
+
required: required ?? restrictions.required === true,
|
|
5233
|
+
loading: displayLoading || loading,
|
|
5234
|
+
showSpinner: displayValidating || showSpinner,
|
|
5235
|
+
disabled: displayDisabled || disabled || inputProps.disabled,
|
|
5236
|
+
readOnly: displayReadOnly || readOnly || inputProps.readOnly,
|
|
5237
|
+
status: displayStatusToControlStatus(displayStatusToDisplay),
|
|
5238
|
+
showClearButton: showClearButton === "auto" ? formattedValue !== clearedFormattedValue : showClearButton,
|
|
5239
|
+
endAdornment: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5240
|
+
popoverIssues,
|
|
5241
|
+
endAdornment,
|
|
5242
|
+
(DEV || false) && showDebugInfo && /* @__PURE__ */ jsx(DebugInfo, { path: absolutePath })
|
|
5243
|
+
] }),
|
|
5244
|
+
onValueChange: handleValueChange,
|
|
5245
|
+
onFocus: combineEventHandlers(onFocus, handleFocus),
|
|
5246
|
+
onBlurToOutside: combineEventHandlers(onBlurToOutside, inputProps.onBlur),
|
|
5247
|
+
...otherProps,
|
|
5248
|
+
ref: combinedRadioGroupRef,
|
|
5249
|
+
children: [isUnknown && /* @__PURE__ */ jsx(Radio, {
|
|
5250
|
+
value: -1,
|
|
5251
|
+
status: "invalid",
|
|
5252
|
+
children: /* @__PURE__ */ jsx(UnknownValue, {
|
|
5253
|
+
value,
|
|
5254
|
+
label: unknownValueLabel
|
|
5255
|
+
})
|
|
5256
|
+
}), options.map(({ value, text, key, ...radioProps }, i) => /* @__PURE__ */ jsx(Radio, {
|
|
5257
|
+
value: i,
|
|
5258
|
+
...radioProps,
|
|
5259
|
+
children: text ?? value?.toString() ?? ""
|
|
5260
|
+
}, key ?? i))]
|
|
5261
|
+
}), inlineIssues] });
|
|
5262
|
+
}
|
|
4626
5263
|
//#endregion
|
|
4627
5264
|
//#region src/utils/useFormSaver.tsx
|
|
4628
5265
|
/** Hook exposing functions used to save the form to a file. */
|
|
@@ -4632,11 +5269,10 @@ function useFormSaver({ overwrite, path, encode, fileName, extensions, descripti
|
|
|
4632
5269
|
const { getState, _setState } = useFormController();
|
|
4633
5270
|
const { addToast } = useToastManager();
|
|
4634
5271
|
const formTitle = useFormTitle();
|
|
5272
|
+
const defaultId = useMemo(() => formTitle?.replace(/[^a-zA-Z0-9-_]/g, "").substring(0, 32) ?? "", [formTitle]);
|
|
4635
5273
|
return useMemo(() => {
|
|
4636
|
-
async function save({ overwrite, path = AbsolutePath.ROOT, encode, fileName, extensions, description, mimeTypes, startIn, excludeAcceptAllOption, id =
|
|
5274
|
+
async function save({ overwrite, path = AbsolutePath.ROOT, encode, fileName, extensions, description, mimeTypes, startIn, excludeAcceptAllOption, id = defaultId, setPristineOnSave = true, successMessage = locale.SaveAction.successMessage, errorMessage = locale.SaveAction.errorMessage }) {
|
|
4637
5275
|
if (!encode) throw new Error("No `encode` function was provided.");
|
|
4638
|
-
if (successMessage === void 0) successMessage = locale.SaveAction.successMessage;
|
|
4639
|
-
if (errorMessage === void 0) errorMessage = locale.SaveAction.errorMessage;
|
|
4640
5276
|
_setState({ saving: true });
|
|
4641
5277
|
let fileHandle = getState().latestFileHandles?.[id] ?? null;
|
|
4642
5278
|
try {
|
|
@@ -4661,7 +5297,7 @@ function useFormSaver({ overwrite, path, encode, fileName, extensions, descripti
|
|
|
4661
5297
|
}
|
|
4662
5298
|
} catch (error) {
|
|
4663
5299
|
if (error instanceof DOMException && error.name === "AbortError") return;
|
|
4664
|
-
if (
|
|
5300
|
+
if (DEV) console.error(error);
|
|
4665
5301
|
const message = typeof errorMessage == "function" ? errorMessage(fileHandle, error) : errorMessage;
|
|
4666
5302
|
if (message != null) addToast(message, { severity: "danger" });
|
|
4667
5303
|
} finally {
|
|
@@ -4690,6 +5326,7 @@ function useFormSaver({ overwrite, path, encode, fileName, extensions, descripti
|
|
|
4690
5326
|
}, [
|
|
4691
5327
|
_setState,
|
|
4692
5328
|
addToast,
|
|
5329
|
+
defaultId,
|
|
4693
5330
|
description,
|
|
4694
5331
|
encode,
|
|
4695
5332
|
errorMessage,
|
|
@@ -4724,8 +5361,33 @@ function defaultFileName(formTitle, extension) {
|
|
|
4724
5361
|
var DEFAULT_SAVE_KEYBINDS = "$mod+S";
|
|
4725
5362
|
/** Default “save as” keybinds. */
|
|
4726
5363
|
var DEFAULT_SAVE_AS_KEYBINDS = "$mod+Shift+S";
|
|
4727
|
-
/**
|
|
4728
|
-
|
|
5364
|
+
/**
|
|
5365
|
+
* Form action used to save the form to a file, supporting both overwriting and
|
|
5366
|
+
* non-overwriting behaviours (i.e. supporting both “save” and “save as”). Built
|
|
5367
|
+
* on top of the [`ButtonGroup`](/docs/ostack-ui-layout-button-group--docs),
|
|
5368
|
+
* [`Button`](/docs/ostack-ui-forms-button--docs), and
|
|
5369
|
+
* [`DropdownMenu`](/docs/ostack-ui-overlay-dropdown-menu--docs) components, as
|
|
5370
|
+
* well as the `useFormSaver` hook.
|
|
5371
|
+
*
|
|
5372
|
+
* Example usage:
|
|
5373
|
+
*
|
|
5374
|
+
* ```tsx
|
|
5375
|
+
* import { SaveAction } from "@ostack.tech/ui-kform";
|
|
5376
|
+
*
|
|
5377
|
+
* function SaveForm() {
|
|
5378
|
+
* return (
|
|
5379
|
+
* <SaveAction
|
|
5380
|
+
* encode={(formValue) =>
|
|
5381
|
+
* encodeFormToJSON(formValue, { pretty: true })
|
|
5382
|
+
* }
|
|
5383
|
+
* mimeTypes={["application/json"]}
|
|
5384
|
+
* extensions={[".json"]}
|
|
5385
|
+
* />
|
|
5386
|
+
* );
|
|
5387
|
+
* }
|
|
5388
|
+
* ```
|
|
5389
|
+
*/
|
|
5390
|
+
function SaveAction({ label, keybinds, showWhenReadOnly = true, fileSystemId, disableOverwrite, saveOptionsLabel, saveAsLabel, saveAsKeybinds, loading, disabled, onClick, variant = "subtle", color, path, encode, fileName, extensions, description, mimeTypes, startIn, excludeAcceptAllOption, successMessage, errorMessage, saveOptionsProps, dropdownMenuProps, ...otherProps }) {
|
|
4729
5391
|
const [locale] = useLocale();
|
|
4730
5392
|
label ??= locale.SaveAction.label;
|
|
4731
5393
|
if (keybinds === void 0) keybinds = locale.SaveAction.keybinds ?? "$mod+S";
|
|
@@ -4741,14 +5403,19 @@ function SaveAction({ label, keybinds, disableOverwrite, saveOptionsLabel, saveA
|
|
|
4741
5403
|
mimeTypes,
|
|
4742
5404
|
startIn,
|
|
4743
5405
|
excludeAcceptAllOption,
|
|
4744
|
-
id,
|
|
5406
|
+
id: fileSystemId,
|
|
4745
5407
|
successMessage,
|
|
4746
5408
|
errorMessage
|
|
4747
5409
|
});
|
|
5410
|
+
const formIsReadOnly = useFormIsReadOnly();
|
|
4748
5411
|
const formIsSaving = useFormIsSaving();
|
|
4749
5412
|
const formIsLoading = useFormIsLoading();
|
|
5413
|
+
const showAction = !formIsReadOnly || showWhenReadOnly;
|
|
5414
|
+
const showDisabled = disabled || formIsLoading;
|
|
5415
|
+
const showLoading = loading || formIsSaving;
|
|
5416
|
+
disableOverwrite ??= formIsReadOnly;
|
|
4750
5417
|
const formAppEl = useFormAppElement();
|
|
4751
|
-
const shortcutsDisabled =
|
|
5418
|
+
const shortcutsDisabled = !showAction || showDisabled || showLoading;
|
|
4752
5419
|
useKeyboardShortcut(keybinds, () => save({ overwrite: !disableOverwrite }), {
|
|
4753
5420
|
disabled: shortcutsDisabled,
|
|
4754
5421
|
target: formAppEl,
|
|
@@ -4766,18 +5433,18 @@ function SaveAction({ label, keybinds, disableOverwrite, saveOptionsLabel, saveA
|
|
|
4766
5433
|
icon: faFloppyDisk,
|
|
4767
5434
|
...otherProps,
|
|
4768
5435
|
onClick: combineEventHandlers(() => save({ overwrite: !disableOverwrite }), onClick),
|
|
4769
|
-
disabled:
|
|
4770
|
-
loading:
|
|
5436
|
+
disabled: showDisabled,
|
|
5437
|
+
loading: showLoading,
|
|
4771
5438
|
keybinds,
|
|
4772
5439
|
children: label
|
|
4773
5440
|
});
|
|
4774
|
-
return supportsFileSystemAPIs && !disableOverwrite ? /* @__PURE__ */ jsxs(ButtonGroup, { children: [saveButton, /* @__PURE__ */ jsxs(DropdownMenu, { children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, { children: /* @__PURE__ */ jsx(IconButton, {
|
|
5441
|
+
return showAction && (supportsFileSystemAPIs && !disableOverwrite ? /* @__PURE__ */ jsxs(ButtonGroup, { children: [saveButton, /* @__PURE__ */ jsxs(DropdownMenu, { children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, { children: /* @__PURE__ */ jsx(IconButton, {
|
|
4775
5442
|
variant,
|
|
4776
5443
|
color,
|
|
4777
5444
|
icon: faCaretDown,
|
|
4778
5445
|
...saveOptionsProps,
|
|
4779
5446
|
label: saveOptionsLabel,
|
|
4780
|
-
disabled:
|
|
5447
|
+
disabled: showDisabled || saveOptionsProps?.disabled,
|
|
4781
5448
|
style: {
|
|
4782
5449
|
minWidth: 20,
|
|
4783
5450
|
...saveOptionsProps?.style
|
|
@@ -4787,19 +5454,87 @@ function SaveAction({ label, keybinds, disableOverwrite, saveOptionsLabel, saveA
|
|
|
4787
5454
|
...dropdownMenuProps,
|
|
4788
5455
|
children: /* @__PURE__ */ jsx(DropdownMenuItem, {
|
|
4789
5456
|
onClick: () => save(),
|
|
4790
|
-
disabled:
|
|
4791
|
-
loading:
|
|
5457
|
+
disabled: showDisabled,
|
|
5458
|
+
loading: showLoading,
|
|
4792
5459
|
keybinds: saveAsKeybinds,
|
|
4793
5460
|
children: saveAsLabel
|
|
4794
5461
|
})
|
|
4795
|
-
})] })] }) : saveButton;
|
|
5462
|
+
})] })] }) : saveButton);
|
|
5463
|
+
}
|
|
5464
|
+
//#endregion
|
|
5465
|
+
//#region src/components/SelectControl/SelectControlItem.tsx
|
|
5466
|
+
/**
|
|
5467
|
+
* Definition of a select control item.
|
|
5468
|
+
*
|
|
5469
|
+
* This component doesn't actually render anything by itself; it is used by the
|
|
5470
|
+
* `SelectControl` component to automatically create the `options` array.
|
|
5471
|
+
*/
|
|
5472
|
+
function SelectControlItem(_props) {
|
|
5473
|
+
return null;
|
|
5474
|
+
}
|
|
5475
|
+
//#endregion
|
|
5476
|
+
//#region src/components/SelectControl/SelectControlItemGroup.tsx
|
|
5477
|
+
/**
|
|
5478
|
+
* Definition of a select control item group.
|
|
5479
|
+
*
|
|
5480
|
+
* This component doesn't actually render anything by itself; it is used by the
|
|
5481
|
+
* `SelectControl` component to automatically create groups of items in the
|
|
5482
|
+
* `options` array.
|
|
5483
|
+
*/
|
|
5484
|
+
function SelectControlItemGroup(_props) {
|
|
5485
|
+
return null;
|
|
4796
5486
|
}
|
|
4797
5487
|
//#endregion
|
|
4798
5488
|
//#region src/components/SelectControl/SelectControl.tsx
|
|
4799
|
-
/**
|
|
4800
|
-
|
|
5489
|
+
/**
|
|
5490
|
+
* The select control component is a KForm form control for values with any type
|
|
5491
|
+
* of (typically
|
|
5492
|
+
* [nullable](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-nullable-schema/index.html))
|
|
5493
|
+
* schema. It is built on top of the
|
|
5494
|
+
* [`Select`](/docs/ostack-ui-forms-select--docs) component.
|
|
5495
|
+
*
|
|
5496
|
+
* It composes the following subcomponents:
|
|
5497
|
+
*
|
|
5498
|
+
* - `SelectControlItem`: Component used to define an item of the select control.
|
|
5499
|
+
* - `SelectControlItemGroup`: Component used to define a group of items of the
|
|
5500
|
+
* select control.
|
|
5501
|
+
*
|
|
5502
|
+
* The following built-in KForm validation affects this control:
|
|
5503
|
+
*
|
|
5504
|
+
* - [`Required`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-required/index.html):
|
|
5505
|
+
* Sets the `required` property.
|
|
5506
|
+
*
|
|
5507
|
+
* Example usage:
|
|
5508
|
+
*
|
|
5509
|
+
* ```tsx
|
|
5510
|
+
* import { SelectControl, SelectControlItem } from "@ostack.tech/ui-kform";
|
|
5511
|
+
*
|
|
5512
|
+
* function ShirtSizeControl() {
|
|
5513
|
+
* return (
|
|
5514
|
+
* <SelectControl
|
|
5515
|
+
* path="/shirtSize"
|
|
5516
|
+
* placeholder="Select your shirt size…"
|
|
5517
|
+
* >
|
|
5518
|
+
* <SelectControlItem value="sm">Small</SelectControlItem>
|
|
5519
|
+
* <SelectControlItem value="md">Medium</SelectControlItem>
|
|
5520
|
+
* <SelectControlItem value="lg">Large</SelectControlItem>
|
|
5521
|
+
* <SelectControlItem value="xl">X-Large</SelectControlItem>
|
|
5522
|
+
* </SelectControl>
|
|
5523
|
+
* );
|
|
5524
|
+
* }
|
|
5525
|
+
* ```
|
|
5526
|
+
*/
|
|
5527
|
+
function SelectControl({ path, options: groupedOptions, issueMessages, issuesPanelLabel, displayIssues = true, unknownValueLabel, preventAutoFocus, apiRef, issueMessagesProps, formManager, onInitialized, onFormManagerEvent, onValueChange, onValidationStatusChange, onDisplayStatusChange, onDirtyStatusChange, onTouchedStatusChange, required, loading, showSpinner, disabled, readOnly, showClearButton, endAdornment, onFocus, onBlurToOutside, children, debug, ref, ...otherProps }) {
|
|
4801
5528
|
const [locale] = useLocale();
|
|
4802
5529
|
unknownValueLabel ??= locale.SelectControl.unknownValueLabel;
|
|
5530
|
+
groupedOptions ??= parseChildren(children, SelectControlItem, {
|
|
5531
|
+
groupType: SelectControlItemGroup,
|
|
5532
|
+
groupProp: "options",
|
|
5533
|
+
transformChildObject: ({ children, ...otherProps }) => ({
|
|
5534
|
+
text: children,
|
|
5535
|
+
...otherProps
|
|
5536
|
+
})
|
|
5537
|
+
});
|
|
4803
5538
|
const options = useMemo(() => groupedOptions.reduce((options, optionOrGroup) => {
|
|
4804
5539
|
if ("options" in optionOrGroup) options.push(...optionOrGroup.options);
|
|
4805
5540
|
else options.push(optionOrGroup);
|
|
@@ -4824,6 +5559,7 @@ var SelectControl = forwardRef(function SelectControl({ path, options: groupedOp
|
|
|
4824
5559
|
const schema = useSchema();
|
|
4825
5560
|
const absolutePath = usePath();
|
|
4826
5561
|
const { nullable, restrictions } = schema.typeInfo;
|
|
5562
|
+
const showDebugInfo = useFormInDebugMode() || debug;
|
|
4827
5563
|
const { displayLoading, displayDisabled, displayReadOnly, displayStatusToDisplay, displayValidating, issuesToDisplay, autofocusRef, handleFocus } = useRegisterControl({
|
|
4828
5564
|
controller,
|
|
4829
5565
|
issuesPanelLabel,
|
|
@@ -4847,15 +5583,16 @@ var SelectControl = forwardRef(function SelectControl({ path, options: groupedOp
|
|
|
4847
5583
|
const clearedValue = nullable ? null : schema.initialValue;
|
|
4848
5584
|
const clearedIdx = useMemo(() => options.findIndex((option) => equals(option.value, clearedValue)), [clearedValue, options]);
|
|
4849
5585
|
const clearedFormattedValue = clearedIdx === -1 ? "" : clearedIdx.toString();
|
|
4850
|
-
const optionNodes = useMemo(() =>
|
|
4851
|
-
const
|
|
5586
|
+
const optionNodes = useMemo(() => selectionItemObjectsToNodes(groupedOptions), [groupedOptions]);
|
|
5587
|
+
const { inlineIssues, popoverIssues } = useControlIssues({
|
|
4852
5588
|
issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },
|
|
4853
5589
|
issueMessages: { [absolutePath.toString()]: issueMessages },
|
|
4854
5590
|
displayIssues,
|
|
4855
|
-
issueMessagesProps
|
|
5591
|
+
issueMessagesProps,
|
|
5592
|
+
variant: otherProps.variant
|
|
4856
5593
|
});
|
|
4857
|
-
const combinedSelectRef = useCombinedRef(inputProps.ref, autofocusRef,
|
|
4858
|
-
return /* @__PURE__ */ jsxs(
|
|
5594
|
+
const combinedSelectRef = useCombinedRef(inputProps.ref, autofocusRef, ref);
|
|
5595
|
+
return /* @__PURE__ */ jsxs(FeedbackProvider, { children: [/* @__PURE__ */ jsxs(Select, {
|
|
4859
5596
|
value: formattedValue,
|
|
4860
5597
|
name: inputProps.name,
|
|
4861
5598
|
required: required ?? restrictions.required === true,
|
|
@@ -4865,7 +5602,14 @@ var SelectControl = forwardRef(function SelectControl({ path, options: groupedOp
|
|
|
4865
5602
|
readOnly: displayReadOnly || readOnly || inputProps.readOnly,
|
|
4866
5603
|
status: displayStatusToControlStatus(displayStatusToDisplay),
|
|
4867
5604
|
showClearButton: showClearButton === "auto" ? formattedValue !== clearedFormattedValue : showClearButton,
|
|
4868
|
-
endAdornment: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5605
|
+
endAdornment: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5606
|
+
popoverIssues,
|
|
5607
|
+
endAdornment,
|
|
5608
|
+
(DEV || false) && showDebugInfo && /* @__PURE__ */ jsx(DebugInfo, {
|
|
5609
|
+
path: absolutePath,
|
|
5610
|
+
children: /* @__PURE__ */ jsx(DebugInfoControlAddonTrigger, {})
|
|
5611
|
+
})
|
|
5612
|
+
] }),
|
|
4869
5613
|
onValueChange: handleValueChange,
|
|
4870
5614
|
onFocus: combineEventHandlers(onFocus, handleFocus),
|
|
4871
5615
|
onBlurToOutside: combineEventHandlers(onBlurToOutside, inputProps.onBlur),
|
|
@@ -4881,20 +5625,101 @@ var SelectControl = forwardRef(function SelectControl({ path, options: groupedOp
|
|
|
4881
5625
|
})
|
|
4882
5626
|
}), optionNodes]
|
|
4883
5627
|
}), inlineIssues] });
|
|
4884
|
-
}
|
|
5628
|
+
}
|
|
5629
|
+
//#endregion
|
|
5630
|
+
//#region src/components/SelectMultipleControl/SelectMultipleControlItem.tsx
|
|
5631
|
+
/**
|
|
5632
|
+
* Definition of a select multiple control item.
|
|
5633
|
+
*
|
|
5634
|
+
* This component doesn't actually render anything by itself; it is used by the
|
|
5635
|
+
* `SelectMultipleControl` component to automatically create the `options`
|
|
5636
|
+
* array.
|
|
5637
|
+
*/
|
|
5638
|
+
function SelectMultipleControlItem(_props) {
|
|
5639
|
+
return null;
|
|
5640
|
+
}
|
|
5641
|
+
//#endregion
|
|
5642
|
+
//#region src/components/SelectMultipleControl/SelectMultipleControlItemGroup.tsx
|
|
5643
|
+
/**
|
|
5644
|
+
* Definition of a select multiple control item group.
|
|
5645
|
+
*
|
|
5646
|
+
* This component doesn't actually render anything by itself; it is used by the
|
|
5647
|
+
* `SelectMultipleControl` component to automatically create groups of items in
|
|
5648
|
+
* the `options` array.
|
|
5649
|
+
*/
|
|
5650
|
+
function SelectMultipleControlItemGroup(_props) {
|
|
5651
|
+
return null;
|
|
5652
|
+
}
|
|
4885
5653
|
//#endregion
|
|
4886
5654
|
//#region src/components/SelectMultipleControl/SelectMultipleControl.tsx
|
|
4887
5655
|
/**
|
|
4888
|
-
*
|
|
4889
|
-
*
|
|
5656
|
+
* The select multiple control component is a KForm form control for values with
|
|
5657
|
+
* (possibly
|
|
5658
|
+
* [nullable](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-nullable-schema/index.html))
|
|
5659
|
+
* schemas of type
|
|
5660
|
+
* [`ListSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-list-schema/index.html)
|
|
5661
|
+
* or
|
|
5662
|
+
* [`TableSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-table-schema/index.html)
|
|
5663
|
+
* and items of any type. It is built on top of the
|
|
5664
|
+
* [`Select`](/docs/ostack-ui-forms-select--docs) component with the `multiple`
|
|
5665
|
+
* property set.
|
|
5666
|
+
*
|
|
5667
|
+
* It composes the following subcomponents:
|
|
5668
|
+
*
|
|
5669
|
+
* - `SelectMultipleControlItem`: Component used to define an item of the select
|
|
5670
|
+
* multiple control.
|
|
5671
|
+
* - `SelectMultipleControlItemGroup`: Component used to define a group of items
|
|
5672
|
+
* of the select multiple control.
|
|
5673
|
+
*
|
|
5674
|
+
* The following built-in KForm validations affect this control:
|
|
5675
|
+
*
|
|
5676
|
+
* - [`Required`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-required/index.html):
|
|
5677
|
+
* Sets the `required` property.
|
|
5678
|
+
* - [`Size`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-size/index.html)/[`MaxSize`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-max-size/index.html):
|
|
5679
|
+
* Sets the `maxSelected` property.
|
|
4890
5680
|
*
|
|
4891
|
-
*
|
|
4892
|
-
*
|
|
4893
|
-
*
|
|
5681
|
+
* Example usage:
|
|
5682
|
+
*
|
|
5683
|
+
* ```tsx
|
|
5684
|
+
* import {
|
|
5685
|
+
* SelectMultipleControl,
|
|
5686
|
+
* SelectMultipleControlItem,
|
|
5687
|
+
* } from "@ostack.tech/ui-kform";
|
|
5688
|
+
*
|
|
5689
|
+
* function SpokenLanguagesControl() {
|
|
5690
|
+
* return (
|
|
5691
|
+
* <SelectMultipleControl
|
|
5692
|
+
* path="/spokenLanguages"
|
|
5693
|
+
* placeholder="Select your spoken languages…"
|
|
5694
|
+
* >
|
|
5695
|
+
* <SelectMultipleControlItem value="en">
|
|
5696
|
+
* English
|
|
5697
|
+
* </SelectMultipleControlItem>
|
|
5698
|
+
* <SelectMultipleControlItem value="fr">
|
|
5699
|
+
* French
|
|
5700
|
+
* </SelectMultipleControlItem>
|
|
5701
|
+
* <SelectMultipleControlItem value="pt">
|
|
5702
|
+
* Portuguese
|
|
5703
|
+
* </SelectMultipleControlItem>
|
|
5704
|
+
* <SelectMultipleControlItem value="es">
|
|
5705
|
+
* Spanish
|
|
5706
|
+
* </SelectMultipleControlItem>
|
|
5707
|
+
* </SelectMultipleControl>
|
|
5708
|
+
* );
|
|
5709
|
+
* }
|
|
5710
|
+
* ```
|
|
4894
5711
|
*/
|
|
4895
|
-
|
|
5712
|
+
function SelectMultipleControl({ path, options: groupedOptions, issueMessages, issuesPanelLabel, displayIssues = true, unknownValueLabel, preventAutoFocus, apiRef, issueMessagesProps, formManager, onInitialized, onFormManagerEvent, onValueChange, onValidationStatusChange, onDisplayStatusChange, onDirtyStatusChange, onTouchedStatusChange, required, maxSelected, loading, showSpinner, disabled, readOnly, endAdornment, onFocus, onBlurToOutside, children, debug, ref, ...otherProps }) {
|
|
4896
5713
|
const [locale] = useLocale();
|
|
4897
5714
|
unknownValueLabel ??= locale.SelectMultipleControl.unknownValueLabel;
|
|
5715
|
+
groupedOptions ??= parseChildren(children, SelectMultipleControlItem, {
|
|
5716
|
+
groupType: SelectMultipleControlItemGroup,
|
|
5717
|
+
groupProp: "options",
|
|
5718
|
+
transformChildObject: ({ children, ...otherProps }) => ({
|
|
5719
|
+
text: children,
|
|
5720
|
+
...otherProps
|
|
5721
|
+
})
|
|
5722
|
+
});
|
|
4898
5723
|
const options = useMemo(() => groupedOptions.reduce((options, optionOrGroup) => {
|
|
4899
5724
|
if ("options" in optionOrGroup) options.push(...optionOrGroup.options);
|
|
4900
5725
|
else options.push(optionOrGroup);
|
|
@@ -4925,6 +5750,7 @@ var SelectMultipleControl = forwardRef(function SelectMultipleControl({ path, op
|
|
|
4925
5750
|
const schema = useSchema();
|
|
4926
5751
|
const { restrictions } = schema.typeInfo;
|
|
4927
5752
|
const absolutePath = usePath();
|
|
5753
|
+
const showDebugInfo = useFormInDebugMode() || debug;
|
|
4928
5754
|
const { displayLoading, displayDisabled, displayReadOnly, displayStatusToDisplay, displayValidating, issuesToDisplay, autofocusRef, handleFocus } = useRegisterControl({
|
|
4929
5755
|
controller,
|
|
4930
5756
|
issuesPanelLabel,
|
|
@@ -4943,25 +5769,34 @@ var SelectMultipleControl = forwardRef(function SelectMultipleControl({ path, op
|
|
|
4943
5769
|
schema,
|
|
4944
5770
|
unknownValues
|
|
4945
5771
|
]);
|
|
4946
|
-
const optionNodes = useMemo(() =>
|
|
4947
|
-
const
|
|
5772
|
+
const optionNodes = useMemo(() => selectionItemObjectsToNodes(groupedOptions), [groupedOptions]);
|
|
5773
|
+
const { inlineIssues, popoverIssues } = useControlIssues({
|
|
4948
5774
|
issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },
|
|
4949
5775
|
issueMessages: { [absolutePath.toString()]: issueMessages },
|
|
4950
5776
|
displayIssues,
|
|
4951
|
-
issueMessagesProps
|
|
5777
|
+
issueMessagesProps,
|
|
5778
|
+
variant: otherProps.variant
|
|
4952
5779
|
});
|
|
4953
|
-
const combinedSelectRef = useCombinedRef(inputProps.ref, autofocusRef,
|
|
4954
|
-
return /* @__PURE__ */ jsxs(
|
|
5780
|
+
const combinedSelectRef = useCombinedRef(inputProps.ref, autofocusRef, ref);
|
|
5781
|
+
return /* @__PURE__ */ jsxs(FeedbackProvider, { children: [/* @__PURE__ */ jsxs(Select, {
|
|
4955
5782
|
multiple: true,
|
|
4956
5783
|
value: formattedValue,
|
|
4957
5784
|
name: inputProps.name,
|
|
4958
5785
|
required: required ?? restrictions.required === true,
|
|
5786
|
+
maxSelected: maxSelected ?? (typeof restrictions.maxSize === "number" ? restrictions.maxSize : void 0),
|
|
4959
5787
|
loading: displayLoading || loading,
|
|
4960
5788
|
showSpinner: displayValidating || showSpinner,
|
|
4961
5789
|
disabled: displayDisabled || disabled || inputProps.disabled,
|
|
4962
5790
|
readOnly: displayReadOnly || readOnly || inputProps.readOnly,
|
|
4963
5791
|
status: displayStatusToControlStatus(displayStatusToDisplay),
|
|
4964
|
-
endAdornment: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5792
|
+
endAdornment: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5793
|
+
popoverIssues,
|
|
5794
|
+
endAdornment,
|
|
5795
|
+
(DEV || false) && showDebugInfo && /* @__PURE__ */ jsx(DebugInfo, {
|
|
5796
|
+
path: absolutePath,
|
|
5797
|
+
children: /* @__PURE__ */ jsx(DebugInfoControlAddonTrigger, {})
|
|
5798
|
+
})
|
|
5799
|
+
] }),
|
|
4965
5800
|
onValueChange: handleValueChange,
|
|
4966
5801
|
onFocus: combineEventHandlers(onFocus, handleFocus),
|
|
4967
5802
|
onBlurToOutside: combineEventHandlers(onBlurToOutside, inputProps.onBlur),
|
|
@@ -4977,13 +5812,43 @@ var SelectMultipleControl = forwardRef(function SelectMultipleControl({ path, op
|
|
|
4977
5812
|
})
|
|
4978
5813
|
}, i)), optionNodes]
|
|
4979
5814
|
}), inlineIssues] });
|
|
4980
|
-
}
|
|
5815
|
+
}
|
|
4981
5816
|
//#endregion
|
|
4982
5817
|
//#region src/components/SubmitAction/SubmitAction.tsx
|
|
4983
5818
|
/** Default “submit” keybinds. */
|
|
4984
5819
|
var DEFAULT_SUBMIT_KEYBINDS = "$mod+Enter";
|
|
4985
|
-
/**
|
|
4986
|
-
|
|
5820
|
+
/**
|
|
5821
|
+
* Form action used to submit a form, supporting all submission-related
|
|
5822
|
+
* properties available in a
|
|
5823
|
+
* [`FormApp`](/docs/ostack-ui-kform-layout-form-app--docs). Built on top of the
|
|
5824
|
+
* [Button](/docs/ostack-ui-forms-button--docs) and
|
|
5825
|
+
* [AlertDialog](/docs/ostack-ui-overlay-alert-dialog--docs) components.
|
|
5826
|
+
*
|
|
5827
|
+
* Example usage:
|
|
5828
|
+
*
|
|
5829
|
+
* ```tsx
|
|
5830
|
+
* import { SubmitAction } from "@ostack.tech/ui-kform";
|
|
5831
|
+
*
|
|
5832
|
+
* function SubmitForm() {
|
|
5833
|
+
* return (
|
|
5834
|
+
* <SubmitAction
|
|
5835
|
+
* onSubmit={async (formValue, warnings) => {
|
|
5836
|
+
* const response = await submitForm(formValue, warnings);
|
|
5837
|
+
* if (response instanceof FormSubmitSuccess) {
|
|
5838
|
+
* return response.redirectTo;
|
|
5839
|
+
* } else if (response instanceof FormSubmitValidationError) {
|
|
5840
|
+
* return response.issues;
|
|
5841
|
+
* } else {
|
|
5842
|
+
* throw new Error(response.errorMessage);
|
|
5843
|
+
* }
|
|
5844
|
+
* }}
|
|
5845
|
+
* onSuccessfulSubmit={(redirectTo) => navigate(redirectTo)}
|
|
5846
|
+
* />
|
|
5847
|
+
* );
|
|
5848
|
+
* }
|
|
5849
|
+
* ```
|
|
5850
|
+
*/
|
|
5851
|
+
function SubmitAction({ onSubmit, onInvalidSubmit, onSuccessfulSubmit, onFailedSubmit, setTouchedOnSubmit, validateOnSubmit, setPristineOnSuccessfulSubmit, convertExternalIssuesTableRowIndicesToIds, label, keybinds, showWhenReadOnly, confirmWarnings = true, loading, disabled, onClick, dialogTitle, dialogDescription, dialogBody, confirmWarningsCheckboxLabel, dialogOkText, dialogCancelText, successMessage: successMessageProp, errorMessage: errorMessageProp, dialogContentProps, dialogHeaderProps, dialogTitleProps, dialogBodyProps, dialogDescriptionProps, dialogFooterProps, dialogOkButtonProps, dialogCancelButtonProps, confirmWarningsAlertProps, confirmWarningsCheckboxProps, ...otherProps }) {
|
|
4987
5852
|
const prefix = usePrefix();
|
|
4988
5853
|
const [locale] = useLocale();
|
|
4989
5854
|
label ??= locale.SubmitAction.label;
|
|
@@ -4994,8 +5859,8 @@ function SubmitAction({ onSubmit, onInvalidSubmit, onSuccessfulSubmit, onFailedS
|
|
|
4994
5859
|
confirmWarningsCheckboxLabel ??= locale.SubmitAction.confirmWarningsCheckboxLabel;
|
|
4995
5860
|
dialogOkText ??= locale.SubmitAction.dialogOkText ?? label;
|
|
4996
5861
|
dialogCancelText ??= locale.SubmitAction.dialogCancelText;
|
|
4997
|
-
|
|
4998
|
-
|
|
5862
|
+
const successMessage = successMessageProp === void 0 ? locale.SubmitAction.successMessage : successMessageProp;
|
|
5863
|
+
const errorMessage = errorMessageProp === void 0 ? locale.SubmitAction.errorMessage : errorMessageProp;
|
|
4999
5864
|
const [confirmingSubmission, setConfirmingSubmission] = useState(false);
|
|
5000
5865
|
const startIssuesNavigation = useStartIssuesNavigation();
|
|
5001
5866
|
const { addToast } = useToastManager();
|
|
@@ -5003,8 +5868,12 @@ function SubmitAction({ onSubmit, onInvalidSubmit, onSuccessfulSubmit, onFailedS
|
|
|
5003
5868
|
const submitting = useSubmitting();
|
|
5004
5869
|
const [runningOnSubmit, setRunningOnSubmit] = useState(false);
|
|
5005
5870
|
const formIsDisabled = useFormIsDisabled();
|
|
5871
|
+
const formIsReadOnly = useFormIsReadOnly();
|
|
5006
5872
|
const formIsLoading = useFormIsLoading();
|
|
5007
5873
|
const formAppEl = useFormAppElement();
|
|
5874
|
+
const showAction = !formIsReadOnly || showWhenReadOnly;
|
|
5875
|
+
const showDisabled = disabled || formIsDisabled || formIsLoading;
|
|
5876
|
+
const showLoading = loading || submitting;
|
|
5008
5877
|
const [submissionInfo, setSubmissionInfo] = useState(null);
|
|
5009
5878
|
const [checkedWarnings, setCheckedWarnings] = useState([]);
|
|
5010
5879
|
const allWarningsChecked = !submissionInfo?.warnings || submissionInfo.warnings.every((warning) => checkedWarnings.some((checkedWarning) => warning.equals(checkedWarning)));
|
|
@@ -5028,12 +5897,10 @@ function SubmitAction({ onSubmit, onInvalidSubmit, onSuccessfulSubmit, onFailedS
|
|
|
5028
5897
|
}
|
|
5029
5898
|
};
|
|
5030
5899
|
const preventCloseAutoFocus = useRef(false);
|
|
5031
|
-
const handleInvalidSubmit = (issues, event) => {
|
|
5900
|
+
const handleInvalidSubmit = async (issues, event) => {
|
|
5032
5901
|
preventCloseAutoFocus.current = true;
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
onInvalidSubmit?.(issues, event);
|
|
5036
|
-
});
|
|
5902
|
+
await startIssuesNavigation({ validate: false });
|
|
5903
|
+
onInvalidSubmit?.(issues, event);
|
|
5037
5904
|
};
|
|
5038
5905
|
const handleCloseAutoFocus = (event) => {
|
|
5039
5906
|
if (preventCloseAutoFocus.current) event.preventDefault();
|
|
@@ -5046,7 +5913,7 @@ function SubmitAction({ onSubmit, onInvalidSubmit, onSuccessfulSubmit, onFailedS
|
|
|
5046
5913
|
};
|
|
5047
5914
|
const handleFailedSubmit = (error, event) => {
|
|
5048
5915
|
if (error instanceof PromiseCancellationException) return;
|
|
5049
|
-
if (
|
|
5916
|
+
if (DEV) console.error(error);
|
|
5050
5917
|
const message = typeof errorMessage === "function" ? errorMessage(error) : errorMessage;
|
|
5051
5918
|
if (message != null) addToast(message, { severity: "danger" });
|
|
5052
5919
|
onFailedSubmit?.(error, event);
|
|
@@ -5079,11 +5946,11 @@ function SubmitAction({ onSubmit, onInvalidSubmit, onSuccessfulSubmit, onFailedS
|
|
|
5079
5946
|
convertExternalIssuesTableRowIndicesToIds
|
|
5080
5947
|
});
|
|
5081
5948
|
useKeyboardShortcut(keybinds, handleAction, {
|
|
5082
|
-
disabled:
|
|
5949
|
+
disabled: !showAction || showDisabled || showLoading,
|
|
5083
5950
|
target: formAppEl,
|
|
5084
5951
|
preventDefault: true
|
|
5085
5952
|
});
|
|
5086
|
-
return /* @__PURE__ */ jsxs(AlertDialog, {
|
|
5953
|
+
return showAction && /* @__PURE__ */ jsxs(AlertDialog, {
|
|
5087
5954
|
open: confirmingSubmission,
|
|
5088
5955
|
onOpenChange: handleOpenChange,
|
|
5089
5956
|
children: [/* @__PURE__ */ jsx(AlertDialogTrigger, { children: /* @__PURE__ */ jsx(Button, {
|
|
@@ -5092,9 +5959,9 @@ function SubmitAction({ onSubmit, onInvalidSubmit, onSuccessfulSubmit, onFailedS
|
|
|
5092
5959
|
icon: faArrowRight,
|
|
5093
5960
|
iconPlacement: "end",
|
|
5094
5961
|
...otherProps,
|
|
5095
|
-
onClick: combineEventHandlers(
|
|
5096
|
-
disabled:
|
|
5097
|
-
loading:
|
|
5962
|
+
onClick: combineEventHandlers(onClick, handleAction),
|
|
5963
|
+
disabled: showDisabled,
|
|
5964
|
+
loading: showLoading,
|
|
5098
5965
|
keybinds,
|
|
5099
5966
|
children: label
|
|
5100
5967
|
}) }), /* @__PURE__ */ jsx(AlertDialogContent, {
|
|
@@ -5113,35 +5980,31 @@ function SubmitAction({ onSubmit, onInvalidSubmit, onSuccessfulSubmit, onFailedS
|
|
|
5113
5980
|
children: typeof dialogTitle === "function" ? dialogTitle(submissionInfo.value, submissionInfo.warnings) : dialogTitle
|
|
5114
5981
|
})
|
|
5115
5982
|
}),
|
|
5116
|
-
/* @__PURE__ */
|
|
5983
|
+
/* @__PURE__ */ jsxs(AlertDialogBody, {
|
|
5117
5984
|
...dialogBodyProps,
|
|
5118
|
-
children:
|
|
5119
|
-
|
|
5120
|
-
|
|
5121
|
-
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
|
|
5129
|
-
|
|
5130
|
-
|
|
5131
|
-
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
|
|
5138
|
-
checked: allWarningsChecked,
|
|
5139
|
-
onCheckedChange: handleOnCheckedChange,
|
|
5140
|
-
children: confirmWarningsCheckboxLabel
|
|
5141
|
-
})
|
|
5985
|
+
children: [
|
|
5986
|
+
dialogDescription && /* @__PURE__ */ jsx(AlertDialogDescription, {
|
|
5987
|
+
...dialogDescriptionProps,
|
|
5988
|
+
className: cx(prefix("submit-action__dialog-description"), dialogDescriptionProps?.className),
|
|
5989
|
+
children: typeof dialogDescription === "function" ? dialogDescription(submissionInfo.value, submissionInfo.warnings) : dialogDescription
|
|
5990
|
+
}),
|
|
5991
|
+
typeof dialogBody === "function" ? dialogBody(submissionInfo.value, submissionInfo.warnings) : dialogBody,
|
|
5992
|
+
confirmWarnings && (submissionInfo.warnings?.length ?? 0) > 0 && /* @__PURE__ */ jsx(Alert, {
|
|
5993
|
+
severity: "warning",
|
|
5994
|
+
...confirmWarningsAlertProps,
|
|
5995
|
+
containerProps: {
|
|
5996
|
+
...confirmWarningsAlertProps?.containerProps,
|
|
5997
|
+
className: cx(prefix("submit-action__confirm-warnings-alert-container"), confirmWarningsAlertProps?.containerProps?.className)
|
|
5998
|
+
},
|
|
5999
|
+
children: /* @__PURE__ */ jsx(Checkbox, {
|
|
6000
|
+
status: "warned",
|
|
6001
|
+
...confirmWarningsCheckboxProps,
|
|
6002
|
+
checked: allWarningsChecked,
|
|
6003
|
+
onCheckedChange: handleOnCheckedChange,
|
|
6004
|
+
children: confirmWarningsCheckboxLabel
|
|
5142
6005
|
})
|
|
5143
|
-
|
|
5144
|
-
|
|
6006
|
+
})
|
|
6007
|
+
]
|
|
5145
6008
|
}),
|
|
5146
6009
|
/* @__PURE__ */ jsxs(AlertDialogFooter, {
|
|
5147
6010
|
...dialogFooterProps,
|
|
@@ -5191,22 +6054,59 @@ function useTableControlRowContext() {
|
|
|
5191
6054
|
//#endregion
|
|
5192
6055
|
//#region src/components/TableControl/TableControlCell.tsx
|
|
5193
6056
|
/** Cell of the table control. */
|
|
5194
|
-
|
|
6057
|
+
function TableControlCell({ variant, ...otherProps }) {
|
|
5195
6058
|
const printing = usePrinting();
|
|
5196
6059
|
const { useDisplayStatus } = useTableControlRowContext();
|
|
5197
6060
|
const deferredDisplayStatus = useDeferredValue(useDisplayStatus());
|
|
5198
6061
|
return /* @__PURE__ */ jsx(DataTableCell, {
|
|
5199
6062
|
variant,
|
|
5200
6063
|
status: !printing && variant === "header" ? displayStatusToControlStatus(deferredDisplayStatus) : void 0,
|
|
5201
|
-
...otherProps
|
|
5202
|
-
ref: forwardedRef
|
|
6064
|
+
...otherProps
|
|
5203
6065
|
});
|
|
5204
|
-
}
|
|
6066
|
+
}
|
|
6067
|
+
//#endregion
|
|
6068
|
+
//#region src/components/TableControl/TableControlColumn.tsx
|
|
6069
|
+
/**
|
|
6070
|
+
* Definition of a table control column.
|
|
6071
|
+
*
|
|
6072
|
+
* This component doesn't actually render anything by itself; it is used by the
|
|
6073
|
+
* `TableControl` component to automatically create the `columns` object.
|
|
6074
|
+
*/
|
|
6075
|
+
function TableControlColumn(_props) {
|
|
6076
|
+
return null;
|
|
6077
|
+
}
|
|
6078
|
+
//#endregion
|
|
6079
|
+
//#region src/components/TableControl/TableControlColumnGroup.tsx
|
|
6080
|
+
/**
|
|
6081
|
+
* Definition of a table control column group.
|
|
6082
|
+
*
|
|
6083
|
+
* This component doesn't actually render anything by itself; it is used by the
|
|
6084
|
+
* `TableControl` component to automatically create the `columns` object.
|
|
6085
|
+
*/
|
|
6086
|
+
function TableControlColumnGroup(_props) {
|
|
6087
|
+
return null;
|
|
6088
|
+
}
|
|
6089
|
+
//#endregion
|
|
6090
|
+
//#region src/components/TableControl/TableControlColumns.tsx
|
|
6091
|
+
/**
|
|
6092
|
+
* Container for the definition of all table control columns. This component
|
|
6093
|
+
* must be a direct child of the `TableControl` component.
|
|
6094
|
+
*
|
|
6095
|
+
* This component doesn't actually render anything by itself; it is used by the
|
|
6096
|
+
* `TableControl` component to automatically create the `columns` object.
|
|
6097
|
+
*/
|
|
6098
|
+
function TableControlColumns(_props) {
|
|
6099
|
+
return null;
|
|
6100
|
+
}
|
|
5205
6101
|
//#endregion
|
|
5206
6102
|
//#region src/components/TableControl/TableControlRow.tsx
|
|
5207
6103
|
/** Row of a table control. */
|
|
5208
|
-
|
|
6104
|
+
function TableControlRow({ row, index, ...otherProps }) {
|
|
5209
6105
|
const controller = useController(row?.toString(), { enabled: !useFormIsLoading() && row != null });
|
|
6106
|
+
const tableControlRowController = useMemo(() => ({
|
|
6107
|
+
index,
|
|
6108
|
+
...controller
|
|
6109
|
+
}), [controller, index]);
|
|
5210
6110
|
const path = controller.usePath();
|
|
5211
6111
|
useRegisterController(controller);
|
|
5212
6112
|
useRegisterLabel(path, row == null ? null : index + 1);
|
|
@@ -5218,30 +6118,93 @@ var TableControlRow = memo(forwardRef(function TableControlRow({ row, index, ...
|
|
|
5218
6118
|
return /* @__PURE__ */ jsx(CurrentPath, {
|
|
5219
6119
|
path,
|
|
5220
6120
|
children: /* @__PURE__ */ jsx(TableControlRowContext.Provider, {
|
|
5221
|
-
value:
|
|
5222
|
-
index,
|
|
5223
|
-
...controller
|
|
5224
|
-
}), [controller, index]),
|
|
6121
|
+
value: tableControlRowController,
|
|
5225
6122
|
children: /* @__PURE__ */ jsx(DataTableRow, {
|
|
5226
6123
|
row,
|
|
5227
6124
|
index,
|
|
5228
|
-
...otherProps
|
|
5229
|
-
ref: forwardedRef
|
|
6125
|
+
...otherProps
|
|
5230
6126
|
})
|
|
5231
6127
|
})
|
|
5232
6128
|
});
|
|
5233
|
-
}
|
|
6129
|
+
}
|
|
5234
6130
|
//#endregion
|
|
5235
6131
|
//#region src/components/TableControl/TableControl.tsx
|
|
5236
|
-
/**
|
|
5237
|
-
|
|
6132
|
+
/**
|
|
6133
|
+
* The table control component is a KForm form control for values with (possibly
|
|
6134
|
+
* [nullable](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-nullable-schema/index.html))
|
|
6135
|
+
* schemas of type
|
|
6136
|
+
* [`TableSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-table-schema/index.html)
|
|
6137
|
+
* and items of any type. It is built on top of the
|
|
6138
|
+
* [`DataTable`](/docs/ostack-ui-data-display-data-table--docs) component.
|
|
6139
|
+
*
|
|
6140
|
+
* It composes the following subcomponents:
|
|
6141
|
+
*
|
|
6142
|
+
* - `TableControlColumns`: Container for the definition of all table control
|
|
6143
|
+
* columns and their groups.
|
|
6144
|
+
* - `TableControlColumn`: Component used to define a column of the table control.
|
|
6145
|
+
* - `TableControlColumnGroup`: Component used to define a column group of the
|
|
6146
|
+
* table control.
|
|
6147
|
+
* - `TableControlContent`: Main content of the table control, containing the
|
|
6148
|
+
* table itself.
|
|
6149
|
+
* - `TableControlAddRowTrigger`: Trigger used to add a new row to the table.
|
|
6150
|
+
* - `TableControlRemoveRowTrigger`: Trigger used to remove a row from the table.
|
|
6151
|
+
* - `DataTablePagination`: Optional pagination component of the table control,
|
|
6152
|
+
* showing the current scroll progress in the default `scrolled` mode and
|
|
6153
|
+
* allowing the selection of the current page in `paged` mode.
|
|
6154
|
+
* - `TableControlRowsPerPage`: Optional component allowing the selection of the
|
|
6155
|
+
* number of rows to display per page.
|
|
6156
|
+
* - `TableControlIndexColumn`: Built-in column displaying the number of each row.
|
|
6157
|
+
* - `TableControlActionsColumn`: Built-in column displaying actions that can be
|
|
6158
|
+
* performed on each row; displays a `TableControlRemoveRowTrigger` by
|
|
6159
|
+
* default.
|
|
6160
|
+
*
|
|
6161
|
+
* The following built-in KForm validations affect this control:
|
|
6162
|
+
*
|
|
6163
|
+
* - [`Required`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-required/index.html):
|
|
6164
|
+
* Sets the `required` property.
|
|
6165
|
+
* - [`Size`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-size/index.html)/[`MaxSize`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-max-size/index.html):
|
|
6166
|
+
* Sets the `maxRows` properties.
|
|
6167
|
+
*
|
|
6168
|
+
* Example usage:
|
|
6169
|
+
*
|
|
6170
|
+
* ```tsx
|
|
6171
|
+
* import {
|
|
6172
|
+
* NumericControl,
|
|
6173
|
+
* TableControl,
|
|
6174
|
+
* TableControlActionsColumn,
|
|
6175
|
+
* TableControlAddRowTrigger,
|
|
6176
|
+
* TableControlColumn,
|
|
6177
|
+
* TableControlContent,
|
|
6178
|
+
* TextControl,
|
|
6179
|
+
* } from "@ostack.tech/ui-kform";
|
|
6180
|
+
*
|
|
6181
|
+
* function InventoryControl() {
|
|
6182
|
+
* return (
|
|
6183
|
+
* <TableControl path="/inventory">
|
|
6184
|
+
* <TableControlColumns>
|
|
6185
|
+
* <TableControlColumn label="Description">
|
|
6186
|
+
* <TextControl path="description" />
|
|
6187
|
+
* </TableControlColumn>
|
|
6188
|
+
* <TableControlColumn label="Quantity">
|
|
6189
|
+
* <NumericControl path="quantity" />
|
|
6190
|
+
* </TableControlColumn>
|
|
6191
|
+
* <TableControlActionsColumn removeRowLabel="Remove item" />
|
|
6192
|
+
* </TableControlColumns>
|
|
6193
|
+
* <TableControlAddRowTrigger label="Add item" />
|
|
6194
|
+
* <TableControlContent caption="Inventory" />
|
|
6195
|
+
* </TableControl>
|
|
6196
|
+
* );
|
|
6197
|
+
* }
|
|
6198
|
+
* ```
|
|
6199
|
+
*/
|
|
6200
|
+
function TableControl({ path, issueMessages, issuesPanelLabel, displayIssues = true, preventAutoFocus, apiRef, issueMessagesProps, onInitialized, onFormManagerEvent, onValueChange, onValidationStatusChange, onDisplayStatusChange, onDirtyStatusChange, onTouchedStatusChange, columns: columnsProp, required, maxRows, getRowValue, disabled = false, readOnly = false, className, debug, children, ...otherProps }) {
|
|
5238
6201
|
const prefix = usePrefix();
|
|
5239
6202
|
const [ids, setIds] = useState(void 0);
|
|
5240
6203
|
const size = ids?.length;
|
|
5241
6204
|
const dataTableApiRef = useDataTableApiRef();
|
|
5242
6205
|
const controller = useFormatter(path, {
|
|
5243
6206
|
enabled: !useFormIsLoading(),
|
|
5244
|
-
format: useCallback((value) => value ?
|
|
6207
|
+
format: useCallback((value) => value ? tableIdsToArray(value) : [], []),
|
|
5245
6208
|
setFormattedValue: setIds,
|
|
5246
6209
|
onInitialized,
|
|
5247
6210
|
onFormManagerEvent,
|
|
@@ -5259,14 +6222,26 @@ var TableControl = forwardRef(function TableControl({ path, issueMessages, issue
|
|
|
5259
6222
|
const { restrictions } = schema.typeInfo;
|
|
5260
6223
|
const maxRowsRestriction = maxRows ?? (typeof restrictions.maxSize === "number" ? restrictions.maxSize : void 0);
|
|
5261
6224
|
const elementsSchema = controller.useState((state) => state.formManager.schema(state.path.append(AbsolutePathFragment.Wildcard)));
|
|
6225
|
+
const showDebugInfo = useFormInDebugMode() || debug;
|
|
5262
6226
|
if (schema.typeInfo.name !== "Table") throw new InvalidPathError(absolutePath, `Unsupported schema: Expected (possibly nullable) table schema, but got schema representing values of type '${schema.typeInfo.toString()}'.`);
|
|
5263
6227
|
const ownController = useMemo(() => ({
|
|
5264
6228
|
addRow: async () => {
|
|
5265
6229
|
const { schema, initialized, exists, touched, dirty } = controller.getState();
|
|
5266
6230
|
if (!initialized || !exists || maxRowsRestriction != null && size >= maxRowsRestriction) return;
|
|
5267
|
-
|
|
5268
|
-
|
|
5269
|
-
|
|
6231
|
+
let toAdd = elementsSchema.initialValue;
|
|
6232
|
+
if (getRowValue) {
|
|
6233
|
+
const clonedValue = await elementsSchema.clone(toAdd);
|
|
6234
|
+
controller._setState({ gettingRowValue: true });
|
|
6235
|
+
try {
|
|
6236
|
+
const getRowValueResult = getRowValue(clonedValue);
|
|
6237
|
+
toAdd = isPromiseLike(getRowValueResult) ? await getRowValueResult : getRowValueResult;
|
|
6238
|
+
} finally {
|
|
6239
|
+
controller._setState({ gettingRowValue: false });
|
|
6240
|
+
}
|
|
6241
|
+
}
|
|
6242
|
+
if (toAdd == null) return;
|
|
6243
|
+
const setPromise = schema.typeInfo.nullable && size === 0 ? controller.set(arrayToTable([toAdd])) : controller.set("-", toAdd);
|
|
6244
|
+
setPromise.then(() => queueMicrotask(() => dataTableApiRef.current?.goTo(size)));
|
|
5270
6245
|
if (!touched) controller.setTouched();
|
|
5271
6246
|
if (!dirty) controller.setDirty();
|
|
5272
6247
|
return setPromise;
|
|
@@ -5280,24 +6255,20 @@ var TableControl = forwardRef(function TableControl({ path, issueMessages, issue
|
|
|
5280
6255
|
return removePromise;
|
|
5281
6256
|
}
|
|
5282
6257
|
}), [
|
|
5283
|
-
maxRowsRestriction,
|
|
5284
6258
|
controller,
|
|
5285
|
-
|
|
5286
|
-
|
|
5287
|
-
|
|
6259
|
+
maxRowsRestriction,
|
|
6260
|
+
size,
|
|
6261
|
+
elementsSchema,
|
|
6262
|
+
getRowValue,
|
|
6263
|
+
dataTableApiRef
|
|
5288
6264
|
]);
|
|
5289
6265
|
const goToIndex = useCallback((index, scrollOptions) => {
|
|
5290
6266
|
dataTableApiRef.current?.goTo(index, scrollOptions);
|
|
5291
6267
|
}, [dataTableApiRef]);
|
|
5292
6268
|
const goToId = useCallback((id, scrollOptions) => {
|
|
5293
|
-
const
|
|
5294
|
-
if (
|
|
5295
|
-
|
|
5296
|
-
const idx = indexOfTableRowId(value, id);
|
|
5297
|
-
if (idx !== -1) dataTableApiRef.current?.goTo(idx, scrollOptions);
|
|
5298
|
-
}
|
|
5299
|
-
});
|
|
5300
|
-
}, [controller, dataTableApiRef]);
|
|
6269
|
+
const idx = ids?.indexOf(id) ?? -1;
|
|
6270
|
+
if (idx !== -1) dataTableApiRef.current?.goTo(idx, scrollOptions);
|
|
6271
|
+
}, [dataTableApiRef, ids]);
|
|
5301
6272
|
const { displayDisabled, displayReadOnly, issuesToDisplay, autofocusRef, handleFocus } = useRegisterControl({
|
|
5302
6273
|
controller,
|
|
5303
6274
|
issuesPanelLabel,
|
|
@@ -5316,34 +6287,38 @@ var TableControl = forwardRef(function TableControl({ path, issueMessages, issue
|
|
|
5316
6287
|
goToIndex
|
|
5317
6288
|
]);
|
|
5318
6289
|
useOnPathFocus(useCallback((focusedPath) => {
|
|
5319
|
-
if (exists && focusedPath && absolutePath.resolve(AbsolutePath.DESCENDANTS).contains(focusedPath)) {
|
|
6290
|
+
if (exists && ids && focusedPath && absolutePath.resolve(AbsolutePath.DESCENDANTS).contains(focusedPath)) {
|
|
5320
6291
|
const rowId = focusedPath.fragments[absolutePath.size];
|
|
5321
|
-
if (rowId instanceof AbsolutePathFragment.Id) goToId(+rowId.id, {
|
|
6292
|
+
if (rowId instanceof AbsolutePathFragment.Id) queueMicrotask(() => goToId(+rowId.id, {
|
|
5322
6293
|
align: "center",
|
|
5323
6294
|
behavior: "smooth"
|
|
5324
|
-
});
|
|
6295
|
+
}));
|
|
5325
6296
|
}
|
|
5326
6297
|
}, [
|
|
5327
6298
|
absolutePath,
|
|
5328
6299
|
exists,
|
|
5329
|
-
goToId
|
|
6300
|
+
goToId,
|
|
6301
|
+
ids
|
|
5330
6302
|
]));
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
6303
|
+
let columns = columnsProp;
|
|
6304
|
+
if (!columns) {
|
|
6305
|
+
const columnsElem = Children.toArray(children).find((child) => isValidElement(child) && child.type === TableControlColumns);
|
|
6306
|
+
columns = parseChildren(columnsElem.props.children, TableControlColumn, {
|
|
6307
|
+
groupType: TableControlColumnGroup,
|
|
6308
|
+
groupProp: "subColumns",
|
|
6309
|
+
allowNestedGroups: true,
|
|
6310
|
+
transformChildObject: ({ children, render, ...otherProps }) => ({
|
|
6311
|
+
render: render ?? children,
|
|
6312
|
+
...otherProps
|
|
6313
|
+
})
|
|
6314
|
+
});
|
|
6315
|
+
}
|
|
6316
|
+
const dataTableColumns = useMemo(() => tableControlToDataTableColumns(columns, controlIsReadOnly), [columns, controlIsReadOnly]);
|
|
5342
6317
|
const tableControlController = useMemo(() => ({
|
|
5343
6318
|
...controller,
|
|
5344
6319
|
...ownController
|
|
5345
6320
|
}), [controller, ownController]);
|
|
5346
|
-
const
|
|
6321
|
+
const { inlineIssues } = useControlIssues({
|
|
5347
6322
|
issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },
|
|
5348
6323
|
issueMessages: { [absolutePath.toString()]: issueMessages },
|
|
5349
6324
|
displayIssues,
|
|
@@ -5352,45 +6327,52 @@ var TableControl = forwardRef(function TableControl({ path, issueMessages, issue
|
|
|
5352
6327
|
return /* @__PURE__ */ jsx(FormAppStatus, {
|
|
5353
6328
|
disabled: controlIsDisabled,
|
|
5354
6329
|
readOnly: controlIsReadOnly,
|
|
5355
|
-
children: /* @__PURE__ */
|
|
6330
|
+
children: /* @__PURE__ */ jsx(TableControlContext.Provider, {
|
|
5356
6331
|
value: {
|
|
5357
6332
|
controller: tableControlController,
|
|
5358
6333
|
autofocusRef,
|
|
5359
6334
|
handleFocus,
|
|
5360
6335
|
size,
|
|
5361
|
-
maxRows: maxRowsRestriction
|
|
6336
|
+
maxRows: maxRowsRestriction,
|
|
6337
|
+
debug: showDebugInfo
|
|
5362
6338
|
},
|
|
5363
|
-
children:
|
|
5364
|
-
|
|
5365
|
-
|
|
5366
|
-
|
|
5367
|
-
|
|
5368
|
-
|
|
5369
|
-
|
|
5370
|
-
|
|
5371
|
-
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
|
|
5375
|
-
|
|
5376
|
-
|
|
5377
|
-
|
|
6339
|
+
children: /* @__PURE__ */ jsx(CurrentPath, {
|
|
6340
|
+
path: absolutePath,
|
|
6341
|
+
children: /* @__PURE__ */ jsxs(FeedbackProvider, { children: [/* @__PURE__ */ jsx(DataTable, {
|
|
6342
|
+
className: cx(prefix("table-control"), className),
|
|
6343
|
+
displayMode: "scrolled",
|
|
6344
|
+
columns: dataTableColumns,
|
|
6345
|
+
rows: ids,
|
|
6346
|
+
rowKey: (id) => id,
|
|
6347
|
+
required: required ?? restrictions.required === true,
|
|
6348
|
+
loading: !initialized,
|
|
6349
|
+
renderRow: (props) => /* @__PURE__ */ jsx(TableControlRow, { ...props }),
|
|
6350
|
+
renderCell: (props) => /* @__PURE__ */ jsx(TableControlCell, { ...props }),
|
|
6351
|
+
showAllRowsWhilePrinting: true,
|
|
6352
|
+
apiRef: dataTableApiRef,
|
|
6353
|
+
...otherProps,
|
|
6354
|
+
children
|
|
6355
|
+
}), inlineIssues] })
|
|
6356
|
+
})
|
|
5378
6357
|
})
|
|
5379
6358
|
});
|
|
5380
|
-
}
|
|
5381
|
-
function tableControlToDataTableColumns(columns,
|
|
5382
|
-
return columns.reduce((
|
|
5383
|
-
const
|
|
5384
|
-
if (
|
|
5385
|
-
|
|
5386
|
-
|
|
5387
|
-
|
|
5388
|
-
|
|
5389
|
-
|
|
5390
|
-
|
|
5391
|
-
|
|
5392
|
-
|
|
5393
|
-
|
|
6359
|
+
}
|
|
6360
|
+
function tableControlToDataTableColumns(columns, readOnly, columnIdPrefix = "col") {
|
|
6361
|
+
return columns.reduce((columns, column, i) => {
|
|
6362
|
+
const { subColumns, render, showWhenReadOnly = true, ...otherColumn } = column;
|
|
6363
|
+
if (readOnly && !showWhenReadOnly) return columns;
|
|
6364
|
+
const columnId = `${columnIdPrefix}-${i}`;
|
|
6365
|
+
if (subColumns) columns[columnId] = {
|
|
6366
|
+
...otherColumn,
|
|
6367
|
+
subColumns: tableControlToDataTableColumns(subColumns, readOnly, columnId)
|
|
6368
|
+
};
|
|
6369
|
+
else columns[columnId] = {
|
|
6370
|
+
...otherColumn,
|
|
6371
|
+
sortable: false,
|
|
6372
|
+
filterable: false,
|
|
6373
|
+
render: typeof render === "function" ? () => /* @__PURE__ */ jsx(TableControlCellRenderer, { render }) : render
|
|
6374
|
+
};
|
|
6375
|
+
return columns;
|
|
5394
6376
|
}, {});
|
|
5395
6377
|
}
|
|
5396
6378
|
/** Renderer of a table control cell. */
|
|
@@ -5398,52 +6380,18 @@ function TableControlCellRenderer({ render }) {
|
|
|
5398
6380
|
return render(useTableControlRowContext());
|
|
5399
6381
|
}
|
|
5400
6382
|
//#endregion
|
|
5401
|
-
//#region src/components/TableControl/
|
|
5402
|
-
/**
|
|
5403
|
-
|
|
5404
|
-
const prefix = usePrefix();
|
|
6383
|
+
//#region src/components/TableControl/TableControlActionsColumnLabel.tsx
|
|
6384
|
+
/** Default label of the table control's actions column. */
|
|
6385
|
+
function TableControlActionsColumnLabel() {
|
|
5405
6386
|
const [locale] = useLocale();
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
const controlIsDisabled = useFormIsDisabled();
|
|
5409
|
-
const controlIsReadOnly = useFormIsReadOnly();
|
|
5410
|
-
const setLatestInteraction = useSetLatestInteraction();
|
|
5411
|
-
const handleClick = async () => {
|
|
5412
|
-
await controller.addRow();
|
|
5413
|
-
setLatestInteraction(controller.getState().path);
|
|
5414
|
-
onRowAdded?.();
|
|
5415
|
-
};
|
|
5416
|
-
const shouldDisable = controller.useState(({ initialized, exists }) => !initialized || !exists || controlIsDisabled || disabled || controlIsReadOnly || maxRows != null && size >= maxRows);
|
|
5417
|
-
if (!showWhenReadOnly && controlIsReadOnly) return null;
|
|
5418
|
-
const commonProps = {
|
|
5419
|
-
className: cx(prefix("table-control__add-row-trigger"), showWhilePrinting || printHidden, className),
|
|
5420
|
-
disabled: shouldDisable,
|
|
5421
|
-
onClick: combineEventHandlers(onClick, handleClick, { checkDefaultPrevented: true }),
|
|
5422
|
-
"data-prefer-right-alignment": boolDataAttr(preferRightAlignment)
|
|
5423
|
-
};
|
|
5424
|
-
if (children === void 0) {
|
|
5425
|
-
const { defaultButtonText, label = defaultButtonText ?? locale.TableControlAddRowTrigger.label, ...buttonProps } = otherProps;
|
|
5426
|
-
return /* @__PURE__ */ jsx(Button, {
|
|
5427
|
-
icon: faPlus,
|
|
5428
|
-
color: "primary",
|
|
5429
|
-
...buttonProps,
|
|
5430
|
-
...commonProps,
|
|
5431
|
-
ref: forwardedRef,
|
|
5432
|
-
children: label
|
|
5433
|
-
});
|
|
5434
|
-
}
|
|
5435
|
-
return /* @__PURE__ */ jsx(Slot, {
|
|
5436
|
-
...otherProps,
|
|
5437
|
-
...commonProps,
|
|
5438
|
-
ref: forwardedRef,
|
|
5439
|
-
children
|
|
5440
|
-
});
|
|
5441
|
-
});
|
|
6387
|
+
return locale.TableControlActionsColumn.label;
|
|
6388
|
+
}
|
|
5442
6389
|
//#endregion
|
|
5443
|
-
//#region src/components/TableControl/
|
|
5444
|
-
/**
|
|
5445
|
-
function
|
|
5446
|
-
|
|
6390
|
+
//#region src/components/TableControl/TableControlIndexColumnLabel.tsx
|
|
6391
|
+
/** Default label of the table control's index column. */
|
|
6392
|
+
function TableControlIndexColumnLabel() {
|
|
6393
|
+
const [locale] = useLocale();
|
|
6394
|
+
return locale.TableControlIndexColumn.label ?? "#";
|
|
5447
6395
|
}
|
|
5448
6396
|
//#endregion
|
|
5449
6397
|
//#region src/components/TableControl/TableControlRemoveRowTrigger.tsx
|
|
@@ -5453,9 +6401,10 @@ function useTableControlApiRef() {
|
|
|
5453
6401
|
* By default, it renders an icon button with label `defaultButtonLabel`,
|
|
5454
6402
|
* however, this can be overriden by providing `children`.
|
|
5455
6403
|
*/
|
|
5456
|
-
|
|
6404
|
+
function TableControlRemoveRowTrigger({ showConfirmation, onConfirmRowRemoval, onRowRemoved, confirmDialogTitle, confirmDialogMessage, confirmDialogOkText, confirmDialogCancelText, showWhenReadOnly, disabled, onClick, children, ...otherProps }) {
|
|
5457
6405
|
const [locale] = useLocale();
|
|
5458
|
-
|
|
6406
|
+
const { defaultButtonLabel, label = defaultButtonLabel ?? locale.TableControlRemoveRowTrigger.label, ...iconButtonProps } = otherProps;
|
|
6407
|
+
confirmDialogTitle ??= locale.TableControlRemoveRowTrigger.confirmDialogTitle ?? label;
|
|
5459
6408
|
confirmDialogMessage ??= locale.TableControlRemoveRowTrigger.confirmDialogMessage;
|
|
5460
6409
|
confirmDialogOkText ??= locale.TableControlRemoveRowTrigger.confirmDialogOkText;
|
|
5461
6410
|
confirmDialogCancelText ??= locale.TableControlRemoveRowTrigger.confirmDialogCancelText;
|
|
@@ -5469,6 +6418,7 @@ var TableControlRemoveRowTrigger = forwardRef(function TableControlRemoveRowTrig
|
|
|
5469
6418
|
const setLatestInteraction = useSetLatestInteraction();
|
|
5470
6419
|
const [removing, setRemoving] = useState(false);
|
|
5471
6420
|
const handleClick = async () => {
|
|
6421
|
+
setLatestInteraction(controller.getState().path);
|
|
5472
6422
|
const { path, dirty } = getState();
|
|
5473
6423
|
if (removing || showConfirmation && dirty && !await confirm(confirmDialogMessage(index), {
|
|
5474
6424
|
title: confirmDialogTitle,
|
|
@@ -5477,60 +6427,59 @@ var TableControlRemoveRowTrigger = forwardRef(function TableControlRemoveRowTrig
|
|
|
5477
6427
|
cancelText: confirmDialogCancelText
|
|
5478
6428
|
})) return;
|
|
5479
6429
|
setRemoving(true);
|
|
5480
|
-
|
|
5481
|
-
|
|
5482
|
-
|
|
5483
|
-
|
|
6430
|
+
try {
|
|
6431
|
+
onConfirmRowRemoval?.();
|
|
6432
|
+
await controller.removeRow(path);
|
|
6433
|
+
onRowRemoved?.();
|
|
6434
|
+
} catch {
|
|
6435
|
+
setRemoving(false);
|
|
6436
|
+
}
|
|
5484
6437
|
};
|
|
5485
6438
|
if (!showWhenReadOnly && controlIsReadOnly) return null;
|
|
5486
6439
|
const commonProps = {
|
|
5487
|
-
disabled: !initialized || !exists || controlIsDisabled || disabled || controlIsReadOnly || removing,
|
|
6440
|
+
disabled: !initialized || !exists || controlIsDisabled || disabled || controlIsReadOnly || removing && children !== void 0,
|
|
5488
6441
|
onClick: combineEventHandlers(onClick, handleClick, { checkDefaultPrevented: true })
|
|
5489
6442
|
};
|
|
5490
|
-
if (children === void 0) {
|
|
5491
|
-
|
|
5492
|
-
|
|
5493
|
-
|
|
5494
|
-
|
|
5495
|
-
|
|
5496
|
-
|
|
5497
|
-
|
|
5498
|
-
|
|
5499
|
-
...commonProps,
|
|
5500
|
-
ref: forwardedRef
|
|
5501
|
-
});
|
|
5502
|
-
}
|
|
6443
|
+
if (children === void 0) return /* @__PURE__ */ jsx(IconButton, {
|
|
6444
|
+
icon: faTrash,
|
|
6445
|
+
label,
|
|
6446
|
+
color: "danger",
|
|
6447
|
+
loading: !initialized || removing,
|
|
6448
|
+
circle: true,
|
|
6449
|
+
...iconButtonProps,
|
|
6450
|
+
...commonProps
|
|
6451
|
+
});
|
|
5503
6452
|
return /* @__PURE__ */ jsx(Slot, {
|
|
5504
6453
|
...otherProps,
|
|
5505
6454
|
...commonProps,
|
|
5506
|
-
ref: forwardedRef,
|
|
5507
6455
|
children
|
|
5508
6456
|
});
|
|
5509
|
-
}
|
|
6457
|
+
}
|
|
5510
6458
|
//#endregion
|
|
5511
|
-
//#region src/components/TableControl/
|
|
6459
|
+
//#region src/components/TableControl/TableControlColumnFns.tsx
|
|
5512
6460
|
/**
|
|
5513
6461
|
* Pre-configured column used to display the index of each row. By default, it
|
|
5514
6462
|
* sticks to left of the table.
|
|
5515
6463
|
*
|
|
5516
|
-
* @param
|
|
6464
|
+
* @param props Column properties to override the defaults.
|
|
5517
6465
|
* @returns Table control column used to display the index of each row.
|
|
5518
6466
|
*/
|
|
5519
|
-
function tableControlIndexColumn(
|
|
6467
|
+
function tableControlIndexColumn({ render, ...otherProps } = {}) {
|
|
5520
6468
|
return {
|
|
5521
|
-
label:
|
|
6469
|
+
label: /* @__PURE__ */ jsx(TableControlIndexColumnLabel, {}),
|
|
5522
6470
|
header: true,
|
|
5523
6471
|
sticky: "left",
|
|
5524
6472
|
width: 65,
|
|
5525
6473
|
fixed: true,
|
|
5526
6474
|
align: "center",
|
|
5527
|
-
render: ({ index }) => index + 1,
|
|
5528
|
-
...
|
|
6475
|
+
render: render ?? (({ index }) => index + 1),
|
|
6476
|
+
...otherProps
|
|
5529
6477
|
};
|
|
5530
6478
|
}
|
|
5531
6479
|
/**
|
|
5532
6480
|
* Pre-configured column used to display row actions. By default, it sticks to
|
|
5533
|
-
* the right of the table and renders the `
|
|
6481
|
+
* the right of the table and renders the `TableControlRemoveRowTrigger`
|
|
6482
|
+
* component.
|
|
5534
6483
|
*
|
|
5535
6484
|
* Its configuration can be overridden to show other actions, for example, an
|
|
5536
6485
|
* edit button:
|
|
@@ -5541,7 +6490,7 @@ function tableControlIndexColumn(overrides) {
|
|
|
5541
6490
|
* render: () => (
|
|
5542
6491
|
* <>
|
|
5543
6492
|
* <IconButton label="Edit row" icon={faPencil} />
|
|
5544
|
-
* <
|
|
6493
|
+
* <TableControlRemoveRowTrigger />
|
|
5545
6494
|
* </>
|
|
5546
6495
|
* ),
|
|
5547
6496
|
* });
|
|
@@ -5550,28 +6499,123 @@ function tableControlIndexColumn(overrides) {
|
|
|
5550
6499
|
* @param overrides Column properties used to display the actions of each row.
|
|
5551
6500
|
* @returns Table control column used to display the actions of each row.
|
|
5552
6501
|
*/
|
|
5553
|
-
function tableControlActionsColumn({ removeRowProps, ...
|
|
5554
|
-
return
|
|
6502
|
+
function tableControlActionsColumn({ removeRowLabel, showRowRemovalConfirmation, onConfirmRowRemoval, onRowRemoved, confirmRowRemovalDialogTitle, confirmRowRemovalDialogMessage, confirmRowRemovalDialogOkText, confirmRowRemovalDialogCancelText, removeRowProps, render, ...otherProps } = {}) {
|
|
6503
|
+
return {
|
|
6504
|
+
label: /* @__PURE__ */ jsx(TableControlActionsColumnLabel, {}),
|
|
5555
6505
|
sticky: "right",
|
|
5556
6506
|
width: 50,
|
|
5557
6507
|
fixed: true,
|
|
5558
6508
|
align: "center",
|
|
5559
|
-
|
|
5560
|
-
|
|
6509
|
+
showWhilePrinting: false,
|
|
6510
|
+
showWhenReadOnly: false,
|
|
6511
|
+
render: render ?? /* @__PURE__ */ jsx(TableControlRemoveRowTrigger, {
|
|
6512
|
+
label: removeRowLabel,
|
|
6513
|
+
showConfirmation: showRowRemovalConfirmation,
|
|
6514
|
+
onConfirmRowRemoval,
|
|
6515
|
+
onRowRemoved,
|
|
6516
|
+
confirmDialogTitle: confirmRowRemovalDialogTitle,
|
|
6517
|
+
confirmDialogMessage: confirmRowRemovalDialogMessage,
|
|
6518
|
+
confirmDialogOkText: confirmRowRemovalDialogOkText,
|
|
6519
|
+
confirmDialogCancelText: confirmRowRemovalDialogCancelText,
|
|
6520
|
+
...removeRowProps
|
|
6521
|
+
}),
|
|
6522
|
+
...otherProps
|
|
5561
6523
|
};
|
|
5562
6524
|
}
|
|
5563
6525
|
//#endregion
|
|
6526
|
+
//#region src/components/TableControl/TableControlActionsColumn.tsx
|
|
6527
|
+
/**
|
|
6528
|
+
* Pre-configured column used to display row actions. By default, it sticks to
|
|
6529
|
+
* the right of the table and renders the `TableControlRemoveRowTrigger`
|
|
6530
|
+
* component.
|
|
6531
|
+
*
|
|
6532
|
+
* Its configuration can be overridden to show other actions, e.g. an edit
|
|
6533
|
+
* button:
|
|
6534
|
+
*
|
|
6535
|
+
* ```tsx
|
|
6536
|
+
* <TableControlActionsColumn width={100}>
|
|
6537
|
+
* <IconButton label="Edit item" icon={faPencil} />
|
|
6538
|
+
* <TableControlRemoveRowTrigger label="Remove item" />
|
|
6539
|
+
* </TableControlActionsColumn>;
|
|
6540
|
+
* ```
|
|
6541
|
+
*/
|
|
6542
|
+
function TableControlActionsColumn({ render, children, ...otherProps }) {
|
|
6543
|
+
return /* @__PURE__ */ jsx(TableControlColumn, { ...tableControlActionsColumn({
|
|
6544
|
+
...otherProps,
|
|
6545
|
+
render: render ?? children
|
|
6546
|
+
}) });
|
|
6547
|
+
}
|
|
6548
|
+
//#endregion
|
|
6549
|
+
//#region src/components/TableControl/TableControlAddRowTrigger.tsx
|
|
6550
|
+
/** Trigger used to add a new row to a table control. */
|
|
6551
|
+
function TableControlAddRowTrigger({ disableWhileAdding, onRowAdded, preferRightAlignment = true, showWhenReadOnly, showWhilePrinting, disabled, onClick, className, children, ...otherProps }) {
|
|
6552
|
+
const prefix = usePrefix();
|
|
6553
|
+
const [locale] = useLocale();
|
|
6554
|
+
const { printHidden } = usePrintClassNames();
|
|
6555
|
+
const { controller, size, maxRows } = useTableControlContext();
|
|
6556
|
+
const controlIsDisabled = useFormIsDisabled();
|
|
6557
|
+
const controlIsReadOnly = useFormIsReadOnly();
|
|
6558
|
+
const setLatestInteraction = useSetLatestInteraction();
|
|
6559
|
+
const gettingRowValue = controller.useState((state) => state.gettingRowValue);
|
|
6560
|
+
const [adding, setAdding] = useState(false);
|
|
6561
|
+
const handleClick = async () => {
|
|
6562
|
+
setLatestInteraction(controller.getState().path);
|
|
6563
|
+
setAdding(true);
|
|
6564
|
+
try {
|
|
6565
|
+
await controller.addRow();
|
|
6566
|
+
onRowAdded?.();
|
|
6567
|
+
} finally {
|
|
6568
|
+
setAdding(false);
|
|
6569
|
+
}
|
|
6570
|
+
};
|
|
6571
|
+
const shouldDisable = controller.useState(({ initialized, exists }) => !initialized || !exists || controlIsDisabled || disabled || controlIsReadOnly || gettingRowValue && children !== void 0 || adding && disableWhileAdding && children !== void 0 || maxRows != null && size >= maxRows);
|
|
6572
|
+
if (!showWhenReadOnly && controlIsReadOnly) return null;
|
|
6573
|
+
const commonProps = {
|
|
6574
|
+
className: cx(prefix("table-control__add-row-trigger"), showWhilePrinting || printHidden, className),
|
|
6575
|
+
disabled: shouldDisable,
|
|
6576
|
+
onClick: combineEventHandlers(onClick, handleClick, { checkDefaultPrevented: true }),
|
|
6577
|
+
"data-prefer-right-alignment": boolDataAttr(preferRightAlignment)
|
|
6578
|
+
};
|
|
6579
|
+
if (children === void 0) {
|
|
6580
|
+
const { defaultButtonText, label = defaultButtonText ?? locale.TableControlAddRowTrigger.label, ...buttonProps } = otherProps;
|
|
6581
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
6582
|
+
icon: faPlus,
|
|
6583
|
+
color: "primary",
|
|
6584
|
+
loading: gettingRowValue || adding && disableWhileAdding,
|
|
6585
|
+
showSpinner: adding && !disableWhileAdding,
|
|
6586
|
+
...buttonProps,
|
|
6587
|
+
...commonProps,
|
|
6588
|
+
children: label
|
|
6589
|
+
});
|
|
6590
|
+
}
|
|
6591
|
+
return /* @__PURE__ */ jsx(Slot, {
|
|
6592
|
+
...otherProps,
|
|
6593
|
+
...commonProps,
|
|
6594
|
+
children
|
|
6595
|
+
});
|
|
6596
|
+
}
|
|
6597
|
+
//#endregion
|
|
6598
|
+
//#region src/components/TableControl/TableControlApi.ts
|
|
6599
|
+
/** Hook used to access the table control API. */
|
|
6600
|
+
function useTableControlApiRef() {
|
|
6601
|
+
return useRef(null);
|
|
6602
|
+
}
|
|
6603
|
+
//#endregion
|
|
5564
6604
|
//#region src/components/TableControl/TableControlContent.tsx
|
|
5565
6605
|
/** Component containing the content of the table control. */
|
|
5566
|
-
|
|
5567
|
-
const { autofocusRef, handleFocus, controller } = useTableControlContext();
|
|
6606
|
+
function TableControlContent({ scrollableProps, ...otherProps }) {
|
|
6607
|
+
const { autofocusRef, handleFocus, controller, debug } = useTableControlContext();
|
|
6608
|
+
const printing = usePrinting();
|
|
6609
|
+
const absolutePath = controller.usePath();
|
|
6610
|
+
const deferredDisplayStatus = useDeferredValue(controller.useDisplayStatus());
|
|
5568
6611
|
const handleContainerOnBlur = useCallback(() => {
|
|
5569
6612
|
const { initialized, exists, touched } = controller.getState();
|
|
5570
|
-
if (initialized && exists && touched) controller.setTouched();
|
|
6613
|
+
if (initialized && exists && !touched) controller.setTouched();
|
|
5571
6614
|
}, [controller]);
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
|
|
6615
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [(DEV || false) && debug && /* @__PURE__ */ jsx(DebugInfo, {
|
|
6616
|
+
path: absolutePath,
|
|
6617
|
+
"data-prefer-right-alignment": ""
|
|
6618
|
+
}), /* @__PURE__ */ jsx(DataTableContent, {
|
|
5575
6619
|
editable: true,
|
|
5576
6620
|
variant: "control",
|
|
5577
6621
|
status: printing ? void 0 : displayStatusToControlStatus(deferredDisplayStatus),
|
|
@@ -5580,10 +6624,21 @@ var TableControlContent = forwardRef(function TableControlContent({ scrollablePr
|
|
|
5580
6624
|
onBlur: combineEventHandlers(scrollableProps?.onBlur, handleContainerOnBlur),
|
|
5581
6625
|
ref: useCombinedRef(autofocusRef, scrollableProps?.ref)
|
|
5582
6626
|
},
|
|
6627
|
+
...otherProps
|
|
6628
|
+
})] });
|
|
6629
|
+
}
|
|
6630
|
+
//#endregion
|
|
6631
|
+
//#region src/components/TableControl/TableControlIndexColumn.tsx
|
|
6632
|
+
/**
|
|
6633
|
+
* Pre-configured column used to display the index of each row. By default, it
|
|
6634
|
+
* sticks to left of the table.
|
|
6635
|
+
*/
|
|
6636
|
+
function TableControlIndexColumn({ render, children, ...otherProps }) {
|
|
6637
|
+
return /* @__PURE__ */ jsx(TableControlColumn, { ...tableControlIndexColumn({
|
|
5583
6638
|
...otherProps,
|
|
5584
|
-
|
|
5585
|
-
});
|
|
5586
|
-
}
|
|
6639
|
+
render: render ?? children
|
|
6640
|
+
}) });
|
|
6641
|
+
}
|
|
5587
6642
|
//#endregion
|
|
5588
6643
|
//#region src/components/TableControl/TableControlPagination.tsx
|
|
5589
6644
|
/** Table control pagination. */
|
|
@@ -5595,17 +6650,35 @@ var TableControlRowsPerPage = DataTableRowsPerPage;
|
|
|
5595
6650
|
//#endregion
|
|
5596
6651
|
//#region src/components/TextControl/TextControl.tsx
|
|
5597
6652
|
/**
|
|
5598
|
-
*
|
|
5599
|
-
*
|
|
6653
|
+
* The text control component is a KForm form control for values with (possibly
|
|
6654
|
+
* [nullable](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-nullable-schema/index.html))
|
|
6655
|
+
* schemas of type
|
|
6656
|
+
* [`StringSchema`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.schemas/-string-schema/index.html).
|
|
6657
|
+
* It supports both single and multiline text editing, being built on top of the
|
|
6658
|
+
* [`Input`](/docs/ostack-ui-forms-input--docs) (for single-line) or
|
|
6659
|
+
* [`TextArea`](/docs/ostack-ui-forms-text-area--docs) (for multiline)
|
|
6660
|
+
* components.
|
|
6661
|
+
*
|
|
6662
|
+
* The following built-in KForm validations affect this control:
|
|
6663
|
+
*
|
|
6664
|
+
* - [`Required`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-required/index.html):
|
|
6665
|
+
* Sets the `required` property.
|
|
6666
|
+
* - [`Length`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-length/index.html)/[`MinLength`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-min-length/index.html)/[`MaxLength`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-max-length/index.html):
|
|
6667
|
+
* Sets the `minLength` and/or `maxLength` properties.
|
|
6668
|
+
* - [`Matches`](https://kform.ostack.tech/api/packages/kform/tech.ostack.kform.validations/-matches/index.html):
|
|
6669
|
+
* Sets the `pattern` property.
|
|
5600
6670
|
*
|
|
5601
|
-
*
|
|
5602
|
-
*
|
|
5603
|
-
*
|
|
6671
|
+
* Example usage:
|
|
6672
|
+
*
|
|
6673
|
+
* ```tsx
|
|
6674
|
+
* import { TextControl } from "@ostack.tech/ui-kform";
|
|
5604
6675
|
*
|
|
5605
|
-
*
|
|
5606
|
-
*
|
|
6676
|
+
* function UsernameControl() {
|
|
6677
|
+
* return <TextControl path="/username" placeholder="Enter username…" />;
|
|
6678
|
+
* }
|
|
6679
|
+
* ```
|
|
5607
6680
|
*/
|
|
5608
|
-
|
|
6681
|
+
function TextControl({ path, issueMessages, issuesPanelLabel, displayIssues = true, preventAutoFocus, multiline = false, apiRef, issueMessagesProps, formManager, onInitialized, onFormManagerEvent, onValueChange, onValidationStatusChange, onDisplayStatusChange, onDirtyStatusChange, onTouchedStatusChange, required, minLength, maxLength, pattern, loading, showSpinner, disabled, readOnly, endAdornment, onChange, onFocus, onBlurToOutside, debug, ref, ...otherProps }) {
|
|
5609
6682
|
const controller = useInput(path, {
|
|
5610
6683
|
enabled: !useFormIsLoading(),
|
|
5611
6684
|
parse: parseText,
|
|
@@ -5622,6 +6695,7 @@ var TextControl = forwardRef(function TextControl({ path, issueMessages, issuesP
|
|
|
5622
6695
|
const schema = useSchema();
|
|
5623
6696
|
const absolutePath = usePath();
|
|
5624
6697
|
const { restrictions } = schema.typeInfo;
|
|
6698
|
+
const showDebugInfo = useFormInDebugMode() || debug;
|
|
5625
6699
|
if (schema.typeInfo.name !== "String") throw new InvalidPathError(absolutePath, `Unsupported schema: Expected schema representing (possibly nullable) strings, but got schema representing values of type '${schema.typeInfo.toString()}'.`);
|
|
5626
6700
|
const { displayLoading, displayDisabled, displayReadOnly, displayStatusToDisplay, displayValidating, issuesToDisplay, autofocusRef, handleFocus } = useRegisterControl({
|
|
5627
6701
|
controller,
|
|
@@ -5630,15 +6704,14 @@ var TextControl = forwardRef(function TextControl({ path, issueMessages, issuesP
|
|
|
5630
6704
|
preventAutoFocus,
|
|
5631
6705
|
apiRef
|
|
5632
6706
|
});
|
|
5633
|
-
const
|
|
5634
|
-
|
|
5635
|
-
|
|
5636
|
-
}, [multiline]);
|
|
5637
|
-
const [inlineIssues, popoverIssues] = useControlIssues({
|
|
6707
|
+
const [wasMultiline] = useState(multiline);
|
|
6708
|
+
if (multiline !== wasMultiline) throw new Error("The `multiline` property cannot not be changed at runtime.");
|
|
6709
|
+
const { inlineIssues, popoverIssues } = useControlIssues({
|
|
5638
6710
|
issuesToDisplay: { [absolutePath.toString()]: issuesToDisplay },
|
|
5639
6711
|
issueMessages: { [absolutePath.toString()]: issueMessages },
|
|
5640
6712
|
displayIssues,
|
|
5641
|
-
issueMessagesProps
|
|
6713
|
+
issueMessagesProps,
|
|
6714
|
+
variant: otherProps.variant
|
|
5642
6715
|
});
|
|
5643
6716
|
const commonProps = {
|
|
5644
6717
|
name: inputProps.name,
|
|
@@ -5651,18 +6724,22 @@ var TextControl = forwardRef(function TextControl({ path, issueMessages, issuesP
|
|
|
5651
6724
|
disabled: displayDisabled || disabled || inputProps.disabled,
|
|
5652
6725
|
readOnly: displayReadOnly || readOnly || inputProps.readOnly,
|
|
5653
6726
|
status: displayStatusToControlStatus(displayStatusToDisplay),
|
|
5654
|
-
endAdornment: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6727
|
+
endAdornment: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6728
|
+
popoverIssues,
|
|
6729
|
+
endAdornment,
|
|
6730
|
+
(DEV || false) && showDebugInfo && /* @__PURE__ */ jsx(DebugInfo, {
|
|
6731
|
+
path: absolutePath,
|
|
6732
|
+
children: /* @__PURE__ */ jsx(DebugInfoControlAddonTrigger, {})
|
|
6733
|
+
})
|
|
6734
|
+
] }),
|
|
5655
6735
|
onChange: combineEventHandlers(onChange, inputProps.onChange),
|
|
5656
6736
|
onFocus: combineEventHandlers(onFocus, handleFocus),
|
|
5657
6737
|
onBlurToOutside: combineEventHandlers(onBlurToOutside, inputProps.onBlur),
|
|
5658
|
-
ref: useCombinedRef(inputProps.ref, useCombinedRef(autofocusRef,
|
|
6738
|
+
ref: useCombinedRef(inputProps.ref, useCombinedRef(autofocusRef, ref)),
|
|
5659
6739
|
...otherProps
|
|
5660
6740
|
};
|
|
5661
|
-
return /* @__PURE__ */ jsxs(
|
|
5662
|
-
|
|
5663
|
-
...commonProps
|
|
5664
|
-
}), inlineIssues] });
|
|
5665
|
-
});
|
|
6741
|
+
return /* @__PURE__ */ jsxs(FeedbackProvider, { children: [multiline ? /* @__PURE__ */ jsx(TextArea, { ...commonProps }) : /* @__PURE__ */ jsx(Input, { ...commonProps }), inlineIssues] });
|
|
6742
|
+
}
|
|
5666
6743
|
/** Parses a text control formatted value. */
|
|
5667
6744
|
function parseText(formattedValue, state) {
|
|
5668
6745
|
return state.schema.typeInfo.nullable ? formattedValue || null : formattedValue;
|
|
@@ -5671,8 +6748,24 @@ function parseText(formattedValue, state) {
|
|
|
5671
6748
|
//#region src/components/ValidateAction/ValidateAction.tsx
|
|
5672
6749
|
/** Default “validate” keybinds. */
|
|
5673
6750
|
var DEFAULT_VALIDATE_KEYBINDS = "Alt+Shift+V";
|
|
5674
|
-
/**
|
|
5675
|
-
|
|
6751
|
+
/**
|
|
6752
|
+
* Form action used to validate the form. Built on top of the [`Button`
|
|
6753
|
+
* component](/docs/ostack-ui-forms-button--docs) and `useFormValidator` hook.
|
|
6754
|
+
*
|
|
6755
|
+
* If the form contains an `IssuesPanel` component, it is shown as a result of
|
|
6756
|
+
* triggering the action.
|
|
6757
|
+
*
|
|
6758
|
+
* Example usage:
|
|
6759
|
+
*
|
|
6760
|
+
* ```tsx
|
|
6761
|
+
* import { ValidateAction } from "@ostack.tech/ui-kform";
|
|
6762
|
+
*
|
|
6763
|
+
* function ValidateForm() {
|
|
6764
|
+
* return <ValidateAction />;
|
|
6765
|
+
* }
|
|
6766
|
+
* ```
|
|
6767
|
+
*/
|
|
6768
|
+
function ValidateAction({ label, keybinds, showWhenReadOnly, loading, disabled, onClick, ...otherProps }) {
|
|
5676
6769
|
const [locale] = useLocale();
|
|
5677
6770
|
label ??= locale.ValidateAction.label;
|
|
5678
6771
|
if (keybinds === void 0) keybinds = locale.ValidateAction.keybinds ?? "Alt+Shift+V";
|
|
@@ -5680,21 +6773,25 @@ function ValidateAction({ label, keybinds, loading, disabled, onClick, ...otherP
|
|
|
5680
6773
|
const { validatingAutomatically, validatingManually } = useFormIsValidating();
|
|
5681
6774
|
const deferredValidatingAutomatically = useDeferredValue(validatingAutomatically);
|
|
5682
6775
|
const formIsDisabled = useFormIsDisabled();
|
|
6776
|
+
const formIsReadOnly = useFormIsReadOnly();
|
|
5683
6777
|
const formIsLoading = useFormIsLoading();
|
|
6778
|
+
const showAction = !formIsReadOnly || showWhenReadOnly;
|
|
6779
|
+
const showDisabled = disabled || formIsDisabled || formIsLoading;
|
|
6780
|
+
const showLoading = loading || validatingManually;
|
|
5684
6781
|
const formAppEl = useFormAppElement();
|
|
5685
6782
|
useKeyboardShortcut(keybinds, validate, {
|
|
5686
|
-
disabled:
|
|
6783
|
+
disabled: !showAction || showDisabled || showLoading,
|
|
5687
6784
|
target: formAppEl,
|
|
5688
6785
|
preventDefault: true
|
|
5689
6786
|
});
|
|
5690
|
-
return /* @__PURE__ */ jsx(Button, {
|
|
6787
|
+
return showAction && /* @__PURE__ */ jsx(Button, {
|
|
5691
6788
|
color: "primary",
|
|
5692
6789
|
icon: faCircleCheck$1,
|
|
5693
6790
|
vertical: true,
|
|
5694
6791
|
...otherProps,
|
|
5695
6792
|
onClick: combineEventHandlers(validate, onClick),
|
|
5696
|
-
|
|
5697
|
-
|
|
6793
|
+
disabled: showDisabled,
|
|
6794
|
+
loading: showLoading,
|
|
5698
6795
|
showSpinner: deferredValidatingAutomatically,
|
|
5699
6796
|
keybinds,
|
|
5700
6797
|
children: label
|
|
@@ -5799,6 +6896,6 @@ async function resetAll(formManager, toReset, setPristine, setUntouched) {
|
|
|
5799
6896
|
]));
|
|
5800
6897
|
}
|
|
5801
6898
|
//#endregion
|
|
5802
|
-
export { ActivePathContext, ActivePathProvider, Annex, AnnexRegistrar, Annexes, AnnexesManager, CheckboxControl, CheckboxGroupControl, ControlField, DEFAULT_FIRST_ISSUE_KEYBINDS, DEFAULT_FOCUS_KEYBINDS, DEFAULT_LAST_ISSUE_KEYBINDS, DEFAULT_LOAD_KEYBINDS, DEFAULT_NEXT_ISSUE_KEYBINDS, DEFAULT_PREVIOUS_ISSUE_KEYBINDS, DEFAULT_PRINT_KEYBINDS, DEFAULT_SAVE_AS_KEYBINDS, DEFAULT_SAVE_KEYBINDS, DEFAULT_SUBMIT_KEYBINDS, DEFAULT_VALIDATE_KEYBINDS, DateControl, DateRangeControl, FileControl, FormApp, FormAppIssueMessages, FormAppStatus, FormPage, FormPageRegistrar, FormPages, FormPagesNavigation, FormStep, FormStepContent, FormStepList, FormStepRegistrar, FormStepper, FormStepperFinishTrigger, FormStepperNextTrigger, FormStepperPreviousTrigger, IssueMessages, IssuesAlert, IssuesPanel, IssuesPopover, LoadAction, LocalizationContext, LocalizationProvider, NumericControl, PathLink, PrefixSuffixContext, PrefixSuffixProvider, PrintAction, RadioGroupControl, RepetitiveAnnexRegistrar, SaveAction, SelectControl, SelectMultipleControl, SubmitAction, TableControl, TableControlAddRowTrigger, TableControlCellRenderer, TableControlContent, TableControlPagination, TableControlRemoveRowTrigger, TableControlRowsPerPage, TextControl, TopBar, TopBarActions, ValidateAction, displayStatusToColor, displayStatusToControlStatus, locale as enGB, locale$1 as enUS, locale$2 as fr, locale$2 as frFR, locale$3 as pt, locale$3 as ptPT, setDefaultPrefixSuffix, tableControlActionsColumn, tableControlIndexColumn, useActiveIssuesPanelBreadcrumb, useActivePathContext, useControlIssues, useDisplayIssueCodesInIssueMessages, useFocus, useFormAppElement, useFormIsDisabled, useFormIsLoading, useFormIsReadOnly, useFormIsSaving, useFormIsValidating, useFormLoader, useFormSaver, useFormTitle, useFormValidator, useIsInControlField, useIsRegistered, useIssuesDisplayMode, useLocale, useOnPathFocus, usePrefix, useRegisterControl, useRegisterController, useRegisterControllerWithinControlField, useRegisterIssueMessages, useRegisterLabel, useRegisteredIssueMessage, useResetOnChange, useSetBottomPanelHeight, useSetLeftSidebarWidth, useSetTopBarHeight, useStartIssuesNavigation, useTableControlApiRef, useTopBarElement };
|
|
6899
|
+
export { ActivePathContext, ActivePathProvider, Annex, AnnexRegistrar, Annexes, AnnexesManager, CheckboxControl, CheckboxGroupControl, CheckboxGroupControlItem, ControlField, DEFAULT_FIRST_ISSUE_KEYBINDS, DEFAULT_FOCUS_KEYBINDS, DEFAULT_LAST_ISSUE_KEYBINDS, DEFAULT_LOAD_KEYBINDS, DEFAULT_NEXT_ISSUE_KEYBINDS, DEFAULT_PREVIOUS_ISSUE_KEYBINDS, DEFAULT_PRINT_KEYBINDS, DEFAULT_SAVE_AS_KEYBINDS, DEFAULT_SAVE_KEYBINDS, DEFAULT_SUBMIT_KEYBINDS, DEFAULT_VALIDATE_KEYBINDS, DateControl, DateRangeControl, DebugInfo, DebugInfoControlAddonTrigger, FileControl, FormApp, FormAppIssueMessages, FormAppStatus, FormPage, FormPageRegistrar, FormPages, FormPagesNavigation, FormStep, FormStepContent, FormStepList, FormStepRegistrar, FormStepper, FormStepperFinishTrigger, FormStepperNextTrigger, FormStepperPreviousTrigger, IssueMessages, IssuesAlert, IssuesPanel, IssuesPopover, LoadAction, LocalizationContext, LocalizationProvider, NumericControl, PathLink, PrefixSuffixContext, PrefixSuffixProvider, PrintAction, RadioGroupControl, RadioGroupControlItem, RepetitiveAnnexRegistrar, SaveAction, SelectControl, SelectControlItem, SelectControlItemGroup, SelectMultipleControl, SelectMultipleControlItem, SelectMultipleControlItemGroup, SubmitAction, TableControl, TableControlActionsColumn, TableControlAddRowTrigger, TableControlCellRenderer, TableControlColumn, TableControlColumnGroup, TableControlColumns, TableControlContent, TableControlIndexColumn, TableControlPagination, TableControlRemoveRowTrigger, TableControlRowsPerPage, TextControl, TopBar, TopBarActions, ValidateAction, displayStatusToColor, displayStatusToControlStatus, locale as enGB, locale$1 as enUS, locale$2 as fr, locale$2 as frFR, locale$3 as pt, locale$3 as ptPT, setDefaultPrefixSuffix, tableControlActionsColumn, tableControlIndexColumn, useActiveIssuesPanelBreadcrumb, useActivePathContext, useControlIssues, useDisplayIssueCodesInIssueMessages, useFocus, useFormAppElement, useFormInDebugMode, useFormIsDisabled, useFormIsLoading, useFormIsReadOnly, useFormIsSaving, useFormIsValidating, useFormLoader, useFormSaver, useFormTitle, useFormValidator, useIsInControlField, useIsRegistered, useIssuesDisplayMode, useLocale, useOnPathFocus, usePrefix, useRegisterControl, useRegisterController, useRegisterControllerWithinControlField, useRegisterIssueMessages, useRegisterLabel, useRegisteredIssueMessage, useResetFocus, useResetOnChange, useSetBottomPanelHeight, useSetLeftSidebarWidth, useSetTopBarHeight, useStartIssuesNavigation, useTableControlApiRef, useTopBarElement };
|
|
5803
6900
|
|
|
5804
6901
|
//# sourceMappingURL=ostack-ui-kform.js.map
|