@ostack.tech/ui-kform 0.10.5 → 0.11.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.
Files changed (41) hide show
  1. package/dist/chunks/{en-B9UXLueo.js → en-3JcwFYXc.js} +3 -3
  2. package/dist/chunks/{en-B9UXLueo.js.map → en-3JcwFYXc.js.map} +1 -1
  3. package/dist/locales/en-GB.js +1 -1
  4. package/dist/locales/en-US.js +1 -1
  5. package/dist/locales/fr-FR.js +2 -2
  6. package/dist/locales/fr-FR.js.map +1 -1
  7. package/dist/locales/pt-PT.js +2 -2
  8. package/dist/locales/pt-PT.js.map +1 -1
  9. package/dist/ostack-ui-kform.css +15 -36
  10. package/dist/ostack-ui-kform.js +97 -54
  11. package/dist/ostack-ui-kform.js.map +1 -1
  12. package/dist/types/components/Annexes/Annex.d.ts +3 -3
  13. package/dist/types/components/FormApp/FormApp.d.ts +8 -8
  14. package/dist/types/components/FormPages/FormPage.d.ts +3 -3
  15. package/dist/types/components/FormStepper/FormStep.d.ts +43 -6
  16. package/dist/types/components/FormStepper/FormStepButton.d.ts +8 -0
  17. package/dist/types/components/FormStepper/FormStepList.d.ts +1 -1
  18. package/dist/types/components/FormStepper/FormStepper.d.ts +1 -1
  19. package/dist/types/components/FormStepper/FormStepperFinishTrigger.d.ts +2 -0
  20. package/dist/types/components/FormStepper/FormStepperNextTrigger.d.ts +2 -0
  21. package/dist/types/components/FormStepper/FormStepperPreviousTrigger.d.ts +2 -0
  22. package/dist/types/components/FormStepper/FormStepperState.d.ts +3 -0
  23. package/dist/types/components/FormStepper/index.d.ts +4 -1
  24. package/dist/types/components/TableControl/TableControlAddRowTrigger.d.ts +24 -10
  25. package/dist/types/components/TableControl/TableControlRemoveRowTrigger.d.ts +21 -11
  26. package/dist/types/providers/LocalizationProvider/LocalizationObject.d.ts +3 -3
  27. package/package.json +2 -2
  28. package/scss/_utils.scss +1 -0
  29. package/scss/components/Annexes/_Annexes-variables.scss +2 -3
  30. package/scss/components/Annexes/_Annexes.scss +55 -56
  31. package/scss/components/FileControl/_FileControl.scss +7 -10
  32. package/scss/components/FormApp/_FormApp-variables.scss +9 -0
  33. package/scss/components/FormApp/_FormApp.scss +19 -38
  34. package/scss/components/FormPages/_FormPages-variables.scss +18 -22
  35. package/scss/components/FormPages/_FormPages.scss +73 -62
  36. package/scss/components/IssueMessages/_IssueMessages.scss +1 -1
  37. package/scss/components/IssuesPanel/_IssuesPanel-variables.scss +32 -34
  38. package/scss/components/IssuesPanel/_IssuesPanel.scss +9 -10
  39. package/scss/components/TopBar/_TopBar.scss +15 -14
  40. package/scss/scss/_base-variables.scss +2 -2
  41. package/dist/types/components/FormStepper/FormStepContent.d.ts +0 -20
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
- import { usePrefix as usePrefix$1, useControllableState, useLatestValues, combineEventHandlers, LocalizationProvider as LocalizationProvider$1, usePrinting, useConstant, useSpacing, useCssVars, NATIVE_CONTROLS, useResponsiveValues, useCombinedRef, cx, useIsInRoot, warnOnce, usePrintInProgress, PrefixProvider, Root, computed, TabContent, ErrorBoundary, DocumentTitle, Spinner, useToastManager, useStartPrintingTask, Tabs, useErrorReporter, EMPTY_STORE, Field, VisuallyHidden, Feedback, FeedbackList, FeedbackPopover, useMediaBreakpointUp, DropdownMenu, DropdownMenuTrigger, Button, DropdownMenuContent, DropdownMenuRadioGroup, DropdownMenuGroup, DropdownMenuSub, DropdownMenuSubTrigger, DropdownMenuSubContent, DropdownMenuItem, useAlertDialog, DropdownMenuRadioItem, controlStatusToAccent, IconButton, Tab, boolDataAttr, TabList, combineAriaIds, useIsInTableCell, useDataTableColumnLabel, useOnFieldLabelChange, Checkbox, OptionsGroup, Option, CheckboxGroup, useDateTransformer, DateInput, DateRangeInput, usePrintClassNames, Input, Dialog, Tooltip, DialogTrigger, ControlAddon, Icon, DialogContent, DialogHeader, DialogTitle, DialogBody, Alert, Stack, Popover, PopoverTrigger, PopoverContent, useMeasure, Container, Select, MenuListItem, MenuList, StepContent, Step, StepList, Stepper, useKeyboardShortcut, CloseButton, useScrollPosition, setBoolDataAttr, Card, CardHeader, CardTitle, CardBody, useIntersectionObserver, NumericInput, Link, usePrint, usePrinterDocumentTitle, PrinterTrigger, RadioGroup, Radio, ButtonGroup, AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogHeader, AlertDialogTitle, AlertDialogBody, AlertDialogDescription, AlertDialogFooter, AlertDialogCancel, AlertDialogAction, DataTableCell, DataTableRow, useDataTableApiRef, DataTable, Slot, DataTableContent, DataTablePagination, DataTableRowsPerPage, TextArea, PortalContext } from "@ostack.tech/ui";
2
+ import { usePrefix as usePrefix$1, useControllableState, useLatestValues, LocalizationProvider as LocalizationProvider$1, combineEventHandlers, usePrinting, useConstant, useSpacing, useCssVars, NATIVE_CONTROLS, useResponsiveValues, useCombinedRef, cx, useIsInRoot, warnOnce, usePrintInProgress, PrefixProvider, Root, computed, TabContent, ErrorBoundary, DocumentTitle, Spinner, useToastManager, useStartPrintingTask, Tabs, useErrorReporter, EMPTY_STORE, Field, VisuallyHidden, Feedback, FeedbackList, FeedbackPopover, useMediaBreakpointUp, DropdownMenu, DropdownMenuTrigger, Button, DropdownMenuContent, DropdownMenuRadioGroup, DropdownMenuGroup, DropdownMenuSub, DropdownMenuSubTrigger, DropdownMenuSubContent, DropdownMenuItem, useAlertDialog, DropdownMenuRadioItem, IconButton, controlStatusToAccent, Tab, boolDataAttr, TabList, combineAriaIds, useIsInTableCell, useDataTableColumnLabel, useOnFieldLabelChange, Checkbox, OptionsGroup, Option, CheckboxGroup, useDateTransformer, DateInput, DateRangeInput, usePrintClassNames, Input, Dialog, Tooltip, DialogTrigger, ControlAddon, Icon, DialogContent, DialogHeader, DialogTitle, DialogBody, Alert, Stack, Popover, PopoverTrigger, PopoverContent, useMeasure, Container, Select, MenuListItem, MenuList, StepContent, Step, StepList, Stepper, StepperFinishTrigger, StepperNextTrigger, StepperPreviousTrigger, useKeyboardShortcut, CloseButton, useScrollPosition, setBoolDataAttr, Card, CardHeader, CardTitle, CardBody, useIntersectionObserver, NumericInput, Link, usePrint, usePrinterDocumentTitle, PrinterTrigger, RadioGroup, Radio, ButtonGroup, AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogHeader, AlertDialogTitle, AlertDialogBody, AlertDialogDescription, AlertDialogFooter, AlertDialogCancel, AlertDialogAction, DataTableCell, DataTableRow, useDataTableApiRef, DataTable, Slot, DataTableContent, DataTablePagination, DataTableRowsPerPage, TextArea, PortalContext } from "@ostack.tech/ui";
3
3
  import { AbsolutePath, AbsolutePathFragment, PathMultimap, sliceTable, listableSize, Path, ValidationFailure, nullableSchemaInnerSchema, compareSchemaPaths, PromiseCancellationException, arrayToTable, indexOfTableRowId, isComputedSchema } from "@ostack.tech/kform";
4
4
  import { useResolvedPath, equals, useFormController, useForm, FormContext, CurrentPath, useCurrentPath, useFormManager, useFormattedValue, InvalidPathError, AtPathError, useIssuesTracker, useFormContext, useInput, useListableInput, formatTemporalAsString, useTemporalInput, useFileInput, toFileList, useController, useNumericInput, formatNumericAsString, useFormatter } from "@ostack.tech/kform-react";
5
5
  import { createContext, useContext, useCallback, useMemo, useRef, useEffect, forwardRef, useState, useImperativeHandle, startTransition, Suspense, useDeferredValue, Children, isValidElement, useId, createElement, memo } from "react";
@@ -9,12 +9,12 @@ import { useShallow } from "zustand/react/shallow";
9
9
  import { shallow } from "zustand/shallow";
10
10
  import { supported, fileOpen, fileSave } from "browser-fs-access";
11
11
  import { addDays, min, max, parseISO, format } from "date-fns";
12
+ import { faChevronUp, faChevronDown, faTrash, faFileLines, faDownload, faCircleQuestion, faArrowsToDot, faAnglesLeft, faAngleLeft, faAngleRight, faAnglesRight, faCircleCheck, faCircleExclamation, faTriangleExclamation, faFolderOpen, faPrint, faFloppyDisk, faCaretDown, faArrowRight, faPlus } from "@fortawesome/free-solid-svg-icons";
13
+ import { faCircleCheck as faCircleCheck$1 } from "@fortawesome/free-regular-svg-icons";
12
14
  import { locale } from "./locales/en-GB.js";
13
15
  import { locale as locale2 } from "./locales/en-US.js";
14
16
  import { locale as locale3, locale as locale4 } from "./locales/fr-FR.js";
15
17
  import { locale as locale5, locale as locale6 } from "./locales/pt-PT.js";
16
- import { faChevronUp, faChevronDown, faTrash, faFileLines, faDownload, faCircleQuestion, faArrowsToDot, faAnglesLeft, faAngleLeft, faAngleRight, faAnglesRight, faCircleCheck, faCircleExclamation, faTriangleExclamation, faFolderOpen, faPrint, faFloppyDisk, faCaretDown, faArrowRight, faPlus } from "@fortawesome/free-solid-svg-icons";
17
- import { faCircleCheck as faCircleCheck$1 } from "@fortawesome/free-regular-svg-icons";
18
18
  const DEFAULT_PREFIX_SUFFIX = "kform-";
19
19
  const defaultPrefixSuffixStore = createStore(() => ({
20
20
  defaultPrefixSuffix: DEFAULT_PREFIX_SUFFIX
@@ -2477,6 +2477,7 @@ function AnnexTab({ path }) {
2477
2477
  issuesDisplayMode === "inline" && hasIssues
2478
2478
  ),
2479
2479
  tabInnerProps: { className: prefix("annexes__tab-inner") },
2480
+ tabTextProps: { className: prefix("annexes__tab-text") },
2480
2481
  "aria-describedby": hasIssues ? issueMessagesId : void 0,
2481
2482
  ref: tabRef,
2482
2483
  children: /* @__PURE__ */ jsxs(CurrentPath, { path, children: [
@@ -4195,7 +4196,7 @@ const FormPage = forwardRef(
4195
4196
  prefix("form-pages__page-content"),
4196
4197
  contentProps?.className
4197
4198
  ),
4198
- children: /* @__PURE__ */ jsx(Container, { fluid: "md", gutter: 0, ...containerProps, children: /* @__PURE__ */ jsx(ErrorBoundary, { ...errorBoundaryProps, children: /* @__PURE__ */ jsx(
4199
+ children: /* @__PURE__ */ jsx(Container, { fluid: "xxl", gutter: 0, ...containerProps, children: /* @__PURE__ */ jsx(ErrorBoundary, { ...errorBoundaryProps, children: /* @__PURE__ */ jsx(
4199
4200
  Suspense,
4200
4201
  {
4201
4202
  fallback: /* @__PURE__ */ jsx(Spinner, { size: "xl", color: "primary" }),
@@ -4798,10 +4799,15 @@ function useFormStepState(path, selector) {
4798
4799
  (state) => selector(state.actions.getStepState(path))
4799
4800
  );
4800
4801
  }
4801
- const FormStepContent = forwardRef(function FormStepContent2({
4802
+ const FormStep = forwardRef(function FormStepContent2({
4802
4803
  path,
4804
+ // `FormStepObject` props
4805
+ title: _title,
4806
+ documentTitle: _documentTitle,
4807
+ issuesPanelLabel: _issuesPanelLabel,
4803
4808
  disabled = false,
4804
4809
  readOnly = false,
4810
+ issueMessages,
4805
4811
  errorBoundaryProps,
4806
4812
  className,
4807
4813
  children,
@@ -4826,11 +4832,12 @@ const FormStepContent = forwardRef(function FormStepContent2({
4826
4832
  className: cx(prefix("form-stepper__step-content"), className),
4827
4833
  ...otherProps,
4828
4834
  ref: forwardedRef,
4829
- children: /* @__PURE__ */ jsx(DocumentTitle, { title: documentTitle ?? void 0, children: /* @__PURE__ */ jsx(FormAppStatus, { disabled, readOnly, children: /* @__PURE__ */ jsx(ErrorBoundary, { ...errorBoundaryProps, children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Spinner, { size: "xl", color: "primary" }), children }) }) }) })
4835
+ children: /* @__PURE__ */ jsx(DocumentTitle, { title: documentTitle ?? void 0, children: /* @__PURE__ */ jsx(FormAppStatus, { disabled, readOnly, children: /* @__PURE__ */ jsx(FormAppIssueMessages, { issueMessages, children: /* @__PURE__ */ jsx(ErrorBoundary, { ...errorBoundaryProps, children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Spinner, { size: "xl", color: "primary" }), children }) }) }) }) })
4830
4836
  }
4831
4837
  ) });
4832
4838
  });
4833
- function FormStep({ path, index }) {
4839
+ const FormStepContent = FormStep;
4840
+ function FormStepButton({ path, index }) {
4834
4841
  const prefix = usePrefix();
4835
4842
  const deferredDisplayStatus = useFormStepState(
4836
4843
  path,
@@ -4859,7 +4866,7 @@ const FormStepList = forwardRef(function FormStepperSidebar({ className, ...othe
4859
4866
  ...otherProps,
4860
4867
  ref: forwardedRef,
4861
4868
  children: steps.map((step) => /* @__PURE__ */ jsx(
4862
- FormStep,
4869
+ FormStepButton,
4863
4870
  {
4864
4871
  path: step.path,
4865
4872
  index: step.index
@@ -4927,11 +4934,20 @@ const FormStepper = forwardRef(function FormStepper2({
4927
4934
  allowForwardNavigationOnError,
4928
4935
  preventFocusOnError,
4929
4936
  className,
4937
+ children,
4930
4938
  ...otherProps
4931
4939
  }, forwardedRef) {
4932
4940
  const prefix = usePrefix();
4933
4941
  const formManager = useFormManager();
4934
4942
  const absolutePath = useResolvedPath(path);
4943
+ steps ??= Children.toArray(children).filter(
4944
+ (child) => isValidElement(child) && child.type === FormStep
4945
+ ).map((annex) => ({
4946
+ path: annex.props.path,
4947
+ title: annex.props.title,
4948
+ documentTitle: annex.props.documentTitle,
4949
+ issuesPanelLabel: annex.props.issuesPanelLabel
4950
+ }));
4935
4951
  const resolvedSteps = useMemo(
4936
4952
  () => steps.map((step, i) => ({
4937
4953
  ...step,
@@ -4981,11 +4997,15 @@ const FormStepper = forwardRef(function FormStepper2({
4981
4997
  activeStep: activeIndex,
4982
4998
  onActiveStepChange: goToStep,
4983
4999
  ...otherProps,
4984
- ref: forwardedRef
5000
+ ref: forwardedRef,
5001
+ children
4985
5002
  }
4986
5003
  )
4987
5004
  ] }) });
4988
5005
  });
5006
+ const FormStepperFinishTrigger = StepperFinishTrigger;
5007
+ const FormStepperNextTrigger = StepperNextTrigger;
5008
+ const FormStepperPreviousTrigger = StepperPreviousTrigger;
4989
5009
  const IssueAlert = forwardRef(function IssueMessage2({ path, code, children, ...otherProps }, forwardedRef) {
4990
5010
  const { info } = useIssuesTracker(path);
4991
5011
  const relevantIssues = (info?.flatMap((info2) => info2.issues) ?? []).filter(
@@ -7408,7 +7428,6 @@ function TableControlCellRenderer({
7408
7428
  return render(controller);
7409
7429
  }
7410
7430
  const TableControlAddRowTrigger = forwardRef(function TableControlAddRowTrigger2({
7411
- defaultButtonText,
7412
7431
  onRowAdded,
7413
7432
  preferRightAlignment = true,
7414
7433
  showWhenReadOnly,
@@ -7421,7 +7440,6 @@ const TableControlAddRowTrigger = forwardRef(function TableControlAddRowTrigger2
7421
7440
  }, forwardedRef) {
7422
7441
  const prefix = usePrefix();
7423
7442
  const [locale7] = useLocale();
7424
- defaultButtonText ??= locale7.TableControlAddRowTrigger.defaultButtonText;
7425
7443
  const { printHidden } = usePrintClassNames();
7426
7444
  const { controller, size, maxRows } = useTableControlContext();
7427
7445
  const controlIsDisabled = useFormIsDisabled();
@@ -7435,25 +7453,40 @@ const TableControlAddRowTrigger = forwardRef(function TableControlAddRowTrigger2
7435
7453
  const shouldDisable = controller.useState(
7436
7454
  ({ initialized, exists }) => !initialized || !exists || controlIsDisabled || disabled || controlIsReadOnly || maxRows != null && size >= maxRows
7437
7455
  );
7438
- const As = Slot;
7439
- return (showWhenReadOnly || !controlIsReadOnly) && /* @__PURE__ */ jsx(
7440
- As,
7441
- {
7442
- className: cx(
7443
- prefix("table-control__add-row-trigger"),
7444
- showWhilePrinting || printHidden,
7445
- className
7446
- ),
7447
- disabled: shouldDisable,
7448
- onClick: combineEventHandlers(onClick, handleClick, {
7449
- checkDefaultPrevented: true
7450
- }),
7451
- ...otherProps,
7452
- "data-prefer-right-alignment": boolDataAttr(preferRightAlignment),
7453
- ref: forwardedRef,
7454
- children: children ?? /* @__PURE__ */ jsx(Button, { icon: faPlus, color: "primary", children: defaultButtonText })
7455
- }
7456
- );
7456
+ if (!showWhenReadOnly && controlIsReadOnly) {
7457
+ return null;
7458
+ }
7459
+ const commonProps = {
7460
+ className: cx(
7461
+ prefix("table-control__add-row-trigger"),
7462
+ showWhilePrinting || printHidden,
7463
+ className
7464
+ ),
7465
+ disabled: shouldDisable,
7466
+ onClick: combineEventHandlers(onClick, handleClick, {
7467
+ checkDefaultPrevented: true
7468
+ }),
7469
+ "data-prefer-right-alignment": boolDataAttr(preferRightAlignment)
7470
+ };
7471
+ if (children === void 0) {
7472
+ const {
7473
+ defaultButtonText,
7474
+ label = defaultButtonText ?? locale7.TableControlAddRowTrigger.label,
7475
+ ...buttonProps
7476
+ } = otherProps;
7477
+ return /* @__PURE__ */ jsx(
7478
+ Button,
7479
+ {
7480
+ icon: faPlus,
7481
+ color: "primary",
7482
+ ...buttonProps,
7483
+ ...commonProps,
7484
+ ref: forwardedRef,
7485
+ children: label
7486
+ }
7487
+ );
7488
+ }
7489
+ return /* @__PURE__ */ jsx(Slot, { ...otherProps, ...commonProps, ref: forwardedRef, children });
7457
7490
  });
7458
7491
  function useTableControlApiRef() {
7459
7492
  return useRef(null);
@@ -7462,7 +7495,6 @@ const TableControlRemoveRowTrigger = forwardRef(function TableControlRemoveRowTr
7462
7495
  showConfirmation,
7463
7496
  onConfirmRowRemoval,
7464
7497
  onRowRemoved,
7465
- defaultButtonLabel,
7466
7498
  confirmDialogTitle,
7467
7499
  confirmDialogMessage,
7468
7500
  confirmDialogOkText,
@@ -7474,7 +7506,6 @@ const TableControlRemoveRowTrigger = forwardRef(function TableControlRemoveRowTr
7474
7506
  ...otherProps
7475
7507
  }, forwardedRef) {
7476
7508
  const [locale7] = useLocale();
7477
- defaultButtonLabel ??= locale7.TableControlRemoveRowTrigger.defaultButtonLabel;
7478
7509
  confirmDialogTitle ??= locale7.TableControlRemoveRowTrigger.confirmDialogTitle;
7479
7510
  confirmDialogMessage ??= locale7.TableControlRemoveRowTrigger.confirmDialogMessage;
7480
7511
  confirmDialogOkText ??= locale7.TableControlRemoveRowTrigger.confirmDialogOkText;
@@ -7504,28 +7535,36 @@ const TableControlRemoveRowTrigger = forwardRef(function TableControlRemoveRowTr
7504
7535
  setLatestInteraction(controller.getState().path);
7505
7536
  onRowRemoved?.();
7506
7537
  };
7507
- const As = Slot;
7508
- return (showWhenReadOnly || !controlIsReadOnly) && /* @__PURE__ */ jsx(
7509
- As,
7510
- {
7511
- ...otherProps,
7512
- disabled: !initialized || !exists || controlIsDisabled || disabled || controlIsReadOnly || removing,
7513
- onClick: combineEventHandlers(onClick, handleClick, {
7514
- checkDefaultPrevented: true
7515
- }),
7516
- ref: forwardedRef,
7517
- children: children ?? /* @__PURE__ */ jsx(
7518
- IconButton,
7519
- {
7520
- icon: faTrash,
7521
- label: defaultButtonLabel,
7522
- color: "danger",
7523
- loading: !initialized || removing,
7524
- circle: true
7525
- }
7526
- )
7527
- }
7528
- );
7538
+ if (!showWhenReadOnly && controlIsReadOnly) {
7539
+ return null;
7540
+ }
7541
+ const commonProps = {
7542
+ disabled: !initialized || !exists || controlIsDisabled || disabled || controlIsReadOnly || removing,
7543
+ onClick: combineEventHandlers(onClick, handleClick, {
7544
+ checkDefaultPrevented: true
7545
+ })
7546
+ };
7547
+ if (children === void 0) {
7548
+ const {
7549
+ defaultButtonLabel,
7550
+ label = defaultButtonLabel ?? locale7.TableControlRemoveRowTrigger.label,
7551
+ ...iconButtonProps
7552
+ } = otherProps;
7553
+ return /* @__PURE__ */ jsx(
7554
+ IconButton,
7555
+ {
7556
+ icon: faTrash,
7557
+ label,
7558
+ color: "danger",
7559
+ loading: !initialized || removing,
7560
+ circle: true,
7561
+ ...iconButtonProps,
7562
+ ...commonProps,
7563
+ ref: forwardedRef
7564
+ }
7565
+ );
7566
+ }
7567
+ return /* @__PURE__ */ jsx(Slot, { ...otherProps, ...commonProps, ref: forwardedRef, children });
7529
7568
  });
7530
7569
  function tableControlIndexColumn(overrides) {
7531
7570
  return {
@@ -7826,10 +7865,14 @@ export {
7826
7865
  FormPageRegistrar,
7827
7866
  FormPages,
7828
7867
  FormPagesNavigation,
7868
+ FormStep,
7829
7869
  FormStepContent,
7830
7870
  FormStepList,
7831
7871
  FormStepRegistrar,
7832
7872
  FormStepper,
7873
+ FormStepperFinishTrigger,
7874
+ FormStepperNextTrigger,
7875
+ FormStepperPreviousTrigger,
7833
7876
  IssueAlert,
7834
7877
  IssueMessages,
7835
7878
  IssuesPanel,