@ostack.tech/ui-kform 0.11.3 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -48,7 +48,7 @@
48
48
  border-bottom-color: transparent;
49
49
  background-color: var(--o-ui-background-color) !important;
50
50
  position: relative;
51
- z-index: 1001;
51
+ z-index: calc(var(--o-ui-layer-z-index, 0) + var(--o-ui-z-index-dropdown) + 1);
52
52
  }
53
53
  .o-ui-kform-annexes__menu {
54
54
  width: 270px;
@@ -157,7 +157,7 @@
157
157
  padding-right: calc(var(--o-ui-space) * 2 * 2 + var(--o-ui-font-size-md) + (32px - var(--o-ui-font-size-md) - 2px) / 2);
158
158
  }
159
159
  .o-ui-kform-annexes__tab-issues-popover-button-container {
160
- z-index: calc(var(--o-ui-z-index-focused) + 1);
160
+ z-index: 2;
161
161
  margin-left: calc(-32px - var(--o-ui-tabs-tab-list-gap-x) - (32px - var(--o-ui-font-size-md) - 2px) / 2 / 2);
162
162
  padding-right: calc(var(--o-ui-tabs-tab-list-gap-x) + (32px - var(--o-ui-font-size-md) - 2px) / 2 / 2);
163
163
  }
@@ -372,7 +372,6 @@
372
372
  .o-ui-kform-form-pages__sidebar {
373
373
  position: sticky;
374
374
  top: calc(var(--o-ui-kform-form-app-base-sticky-top, 0px) + var(--o-ui-kform-top-bar-height));
375
- z-index: calc(var(--o-ui-z-index-sticky) + 1);
376
375
  max-height: calc(100dvh - var(--o-ui-kform-top-bar-height));
377
376
  overflow: auto;
378
377
  }
@@ -417,7 +416,6 @@
417
416
  .o-ui-kform-form-pages__navigation[data-navigation-mode=select] {
418
417
  position: sticky;
419
418
  top: calc(var(--o-ui-kform-form-app-base-sticky-top, 0px) + var(--o-ui-kform-top-bar-height));
420
- z-index: calc(var(--o-ui-z-index-sticky) + 2);
421
419
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
422
420
  }
423
421
  .o-ui-kform-form-pages__select-container[data-variant=default] {
@@ -501,7 +499,6 @@
501
499
  .o-ui-kform-form-pages__page-header {
502
500
  position: sticky;
503
501
  top: calc(var(--o-ui-kform-form-app-base-sticky-top, 0px) + var(--o-ui-kform-top-bar-height));
504
- z-index: 1101;
505
502
  display: flex;
506
503
  align-items: center;
507
504
  padding: calc(var(--o-ui-space) * 2) calc(var(--o-ui-space) * 4);
@@ -578,9 +575,6 @@
578
575
  padding: calc(var(--o-ui-space) * 1.5) calc(var(--o-ui-space) * 2);
579
576
  }
580
577
  .o-ui-kform-form-pages__page-content {
581
- position: sticky;
582
- top: calc(var(--o-ui-kform-form-app-base-sticky-top, 0px) + var(--o-ui-kform-top-bar-height) + var(--o-ui-kform-form-pages-page-header-height));
583
- z-index: 1100;
584
578
  padding: calc(var(--o-ui-space) * 4);
585
579
  }
586
580
  @media (min-width: 576px) {
@@ -615,7 +609,6 @@
615
609
  .o-ui-kform-issues-panel__container {
616
610
  position: sticky;
617
611
  bottom: 0;
618
- z-index: 1101;
619
612
  display: flex;
620
613
  justify-content: center;
621
614
  pointer-events: none;
@@ -643,7 +636,6 @@
643
636
  padding: 0 calc(var(--o-ui-space) * 4) calc(var(--o-ui-space) * 2) !important;
644
637
  position: sticky;
645
638
  top: 0;
646
- z-index: 1100;
647
639
  }
648
640
  .o-ui-kform-issues-panel__header[data-stuck]::before {
649
641
  content: "";
@@ -737,9 +729,8 @@
737
729
  justify-content: space-between;
738
730
  position: sticky;
739
731
  top: var(--o-ui-kform-form-app-base-sticky-top, 0px);
740
- z-index: 1103;
741
732
  padding: var(--o-ui-space) var(--o-ui-space) 0;
742
- border-bottom: 2px solid #3e63dd;
733
+ border-bottom: 2px solid var(--o-ui-primary-9);
743
734
  background-color: var(--o-ui-background-color);
744
735
  }
745
736
  .o-ui-kform-top-bar .o-ui-kform-annexes__menu-container, .o-ui-kform-top-bar .o-ui-kform-annexes__tab-list-root {
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
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";
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, usePrintClassNames, useMeasure, Layer, Stack, 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, Input, Dialog, Tooltip, DialogTrigger, ControlAddon, Icon, DialogContent, DialogHeader, DialogTitle, DialogBody, Alert, Popover, PopoverTrigger, PopoverContent, 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 } 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";
@@ -684,7 +684,7 @@ const FormAppElement = forwardRef(function FormAppElement2({
684
684
  const formTitle = useFormTitle();
685
685
  useEffect(
686
686
  () => store.subscribe(
687
- (state) => state.topBarHeight,
687
+ ({ topBarHeight }) => topBarHeight,
688
688
  (height) => formAppElement?.style.setProperty(
689
689
  cssVarName("top-bar-height"),
690
690
  `${height}px`
@@ -695,7 +695,7 @@ const FormAppElement = forwardRef(function FormAppElement2({
695
695
  );
696
696
  useEffect(
697
697
  () => store.subscribe(
698
- (state) => state.leftSidebarWidth,
698
+ ({ leftSidebarWidth }) => leftSidebarWidth,
699
699
  (width) => formAppElement?.style.setProperty(
700
700
  cssVarName("left-sidebar-width"),
701
701
  `${width}px`
@@ -706,7 +706,7 @@ const FormAppElement = forwardRef(function FormAppElement2({
706
706
  );
707
707
  useEffect(
708
708
  () => store.subscribe(
709
- (state) => state.bottomPanelHeight,
709
+ ({ bottomPanelHeight }) => bottomPanelHeight,
710
710
  (height) => formAppElement?.style.setProperty(
711
711
  cssVarName("bottom-panel-height"),
712
712
  `${height}px`
@@ -765,6 +765,7 @@ const FormApp = forwardRef(function FormApp2({
765
765
  toastsDuration,
766
766
  toastsSwipeDirection,
767
767
  toastsSwipeThreshold,
768
+ toastViewportPosition,
768
769
  toastViewportHotkey,
769
770
  toastViewportLabel,
770
771
  toastViewportProps,
@@ -833,6 +834,7 @@ const FormApp = forwardRef(function FormApp2({
833
834
  toastsDuration,
834
835
  toastsSwipeDirection,
835
836
  toastsSwipeThreshold,
837
+ toastViewportPosition,
836
838
  toastViewportHotkey,
837
839
  toastViewportLabel,
838
840
  toastViewportProps,
@@ -2070,6 +2072,48 @@ function displayStatusToColor(displayStatus) {
2070
2072
  return void 0;
2071
2073
  }
2072
2074
  }
2075
+ const TopBarContext = createContext(null);
2076
+ function useTopBarElement() {
2077
+ return useContext(TopBarContext)?.topBarEl ?? null;
2078
+ }
2079
+ const TopBar = forwardRef(
2080
+ function TopBar2({ className, ...otherProps }, forwardedRef) {
2081
+ const prefix = usePrefix();
2082
+ const { printHidden } = usePrintClassNames();
2083
+ const setTopBarHeight = useSetTopBarHeight();
2084
+ const [topBarEl, setTopBarEl] = useState(null);
2085
+ useMeasure(
2086
+ topBarEl,
2087
+ useCallback(
2088
+ (measurement) => setTopBarHeight(measurement?.height),
2089
+ [setTopBarHeight]
2090
+ )
2091
+ );
2092
+ const combinedTopBarRef = useCombinedRef(setTopBarEl, forwardedRef);
2093
+ return /* @__PURE__ */ jsx(TopBarContext.Provider, { value: { topBarEl }, children: /* @__PURE__ */ jsx(Layer, { zIndex: "sticky", children: /* @__PURE__ */ jsx(
2094
+ "div",
2095
+ {
2096
+ className: cx(prefix("top-bar"), printHidden, className),
2097
+ ...otherProps,
2098
+ ref: combinedTopBarRef
2099
+ }
2100
+ ) }) });
2101
+ }
2102
+ );
2103
+ const TopBarActions = forwardRef(function TopBarActions2({ className, ...otherProps }, forwardedRef) {
2104
+ const prefix = usePrefix();
2105
+ return /* @__PURE__ */ jsx(
2106
+ Stack,
2107
+ {
2108
+ className: cx(prefix("top-bar__actions"), className),
2109
+ direction: "row",
2110
+ gap: 2,
2111
+ justifyContent: "flex-end",
2112
+ ...otherProps,
2113
+ ref: forwardedRef
2114
+ }
2115
+ );
2116
+ });
2073
2117
  function AnnexesMenu({
2074
2118
  menuButtonText,
2075
2119
  menuButtonLabel,
@@ -2094,6 +2138,7 @@ function AnnexesMenu({
2094
2138
  const issuesDisplayMode = useIssuesDisplayMode();
2095
2139
  const [open, setOpen] = useControllableState(defaultOpen, controlledOpen);
2096
2140
  const menuTriggerRef = useRef(null);
2141
+ const topBarEl = useTopBarElement();
2097
2142
  const activeAnnex = useStore(store, (state) => state.activeAnnex);
2098
2143
  const handleRadioGroupValueChange = useCallback(
2099
2144
  (value) => store.getState().actions.setActiveAnnex(new AbsolutePath(value)),
@@ -2183,6 +2228,10 @@ function AnnexesMenu({
2183
2228
  // eslint-disable-next-line react-hooks/refs
2184
2229
  handleCloseAutoFocus
2185
2230
  ),
2231
+ portalProps: {
2232
+ container: topBarEl ?? void 0,
2233
+ ...menuContentProps?.portalProps
2234
+ },
2186
2235
  children: [
2187
2236
  /* @__PURE__ */ jsx(
2188
2237
  DropdownMenuRadioGroup,
@@ -3968,7 +4017,7 @@ const FormPageHeader = forwardRef(function FormPageHeader2({
3968
4017
  currentPath,
3969
4018
  (state) => state?.visuallyHiddenCodePrefix ?? locale7.FormPage.visuallyHiddenCodePrefix
3970
4019
  );
3971
- return /* @__PURE__ */ jsxs(
4020
+ return /* @__PURE__ */ jsx(Layer, { zIndex: ["sticky", -1], children: /* @__PURE__ */ jsxs(
3972
4021
  "div",
3973
4022
  {
3974
4023
  className: cx(prefix("form-pages__page-header"), className),
@@ -3983,13 +4032,19 @@ const FormPageHeader = forwardRef(function FormPageHeader2({
3983
4032
  {
3984
4033
  tabIndex: -1,
3985
4034
  ...titleProps,
3986
- className: cx(prefix("form-pages__page-title"), titleProps?.className),
4035
+ className: cx(
4036
+ prefix("form-pages__page-title"),
4037
+ titleProps?.className
4038
+ ),
3987
4039
  children: [
3988
4040
  /* @__PURE__ */ jsx(
3989
4041
  "span",
3990
4042
  {
3991
4043
  ...codeProps,
3992
- className: cx(prefix("form-pages__page-code"), codeProps?.className),
4044
+ className: cx(
4045
+ prefix("form-pages__page-code"),
4046
+ codeProps?.className
4047
+ ),
3993
4048
  "data-status": displayStatusToControlStatus(deferredDisplayStatus),
3994
4049
  "data-accent": controlStatusToAccent(
3995
4050
  displayStatusToControlStatus(deferredDisplayStatus)
@@ -4078,7 +4133,7 @@ const FormPageHeader = forwardRef(function FormPageHeader2({
4078
4133
  )
4079
4134
  ]
4080
4135
  }
4081
- );
4136
+ ) });
4082
4137
  });
4083
4138
  const FormPage = forwardRef(
4084
4139
  function FormPage2({
@@ -4342,7 +4397,7 @@ const FormPages = forwardRef(
4342
4397
  );
4343
4398
  useEffect(
4344
4399
  () => store.subscribe(
4345
- (state) => state.navigationSelectHeight,
4400
+ ({ navigationSelectHeight }) => navigationSelectHeight,
4346
4401
  (height) => formPagesRef.current?.style.setProperty(
4347
4402
  cssVarName("form-pages-navigation-select-height"),
4348
4403
  `${height}px`
@@ -4435,7 +4490,7 @@ const FormPagesSelect = forwardRef(function FormPagesSelect2({
4435
4490
  [store]
4436
4491
  );
4437
4492
  const pages = useStore(store, (state) => state.pages);
4438
- return /* @__PURE__ */ jsx(
4493
+ return /* @__PURE__ */ jsx(Layer, { zIndex: ["sticky", -1], children: /* @__PURE__ */ jsx(
4439
4494
  Select,
4440
4495
  {
4441
4496
  className: cx(prefix("form-pages__select"), className),
@@ -4482,7 +4537,7 @@ const FormPagesSelect = forwardRef(function FormPagesSelect2({
4482
4537
  ref: forwardedRef,
4483
4538
  children: pages.map((page) => /* @__PURE__ */ jsx(FormPagesSelectOption, { path: page.path }, page.path.toString()))
4484
4539
  }
4485
- );
4540
+ ) });
4486
4541
  });
4487
4542
  function FormPageSidebarItem({ path }) {
4488
4543
  const [locale7] = useLocale();
@@ -4577,7 +4632,7 @@ const FormPagesSidebar = forwardRef(function FormPagesSidebar2({ className, ...o
4577
4632
  );
4578
4633
  const pages = useStore(store, (state) => state.pages);
4579
4634
  const combinedSidebarRef = useCombinedRef(setSidebarEl, forwardedRef);
4580
- return /* @__PURE__ */ jsx(
4635
+ return /* @__PURE__ */ jsx(Layer, { zIndex: "docked", children: /* @__PURE__ */ jsx(
4581
4636
  "div",
4582
4637
  {
4583
4638
  className: cx(prefix("form-pages__sidebar"), className),
@@ -4585,7 +4640,7 @@ const FormPagesSidebar = forwardRef(function FormPagesSidebar2({ className, ...o
4585
4640
  ref: combinedSidebarRef,
4586
4641
  children: /* @__PURE__ */ jsx(MenuList, { children: pages.map((page) => /* @__PURE__ */ jsx(FormPageSidebarItem, { path: page.path }, page.path.toString())) })
4587
4642
  }
4588
- );
4643
+ ) });
4589
4644
  });
4590
4645
  const FormPagesNavigation = forwardRef(function FormPagesNavigation2({
4591
4646
  sidebarProps,
@@ -5368,7 +5423,7 @@ const IssuesPanelMessagesCard = forwardRef(function IssuesPanelMessagesCard2({
5368
5423
  color: relevantColor ?? "neutral",
5369
5424
  ref: combinedCardRef,
5370
5425
  children: [
5371
- /* @__PURE__ */ jsxs(
5426
+ /* @__PURE__ */ jsx(Layer, { zIndex: "sticky", children: /* @__PURE__ */ jsxs(
5372
5427
  CardHeader,
5373
5428
  {
5374
5429
  ...headerProps,
@@ -5394,7 +5449,10 @@ const IssuesPanelMessagesCard = forwardRef(function IssuesPanelMessagesCard2({
5394
5449
  color: relevantColor,
5395
5450
  size: "lg",
5396
5451
  ...iconProps,
5397
- className: cx(prefix("issues-panel__icon"), iconProps?.className),
5452
+ className: cx(
5453
+ prefix("issues-panel__icon"),
5454
+ iconProps?.className
5455
+ ),
5398
5456
  icon: relevantIcon
5399
5457
  }
5400
5458
  ),
@@ -5422,7 +5480,7 @@ const IssuesPanelMessagesCard = forwardRef(function IssuesPanelMessagesCard2({
5422
5480
  ] })
5423
5481
  ]
5424
5482
  }
5425
- ),
5483
+ ) }),
5426
5484
  /* @__PURE__ */ jsxs(
5427
5485
  CardBody,
5428
5486
  {
@@ -5477,7 +5535,7 @@ const IssuesPanelSummaryCard = forwardRef(function IssuesPanelSummaryCard2({
5477
5535
  ...otherProps,
5478
5536
  color: initialized ? relevantColor : "neutral",
5479
5537
  ref: forwardedRef,
5480
- children: /* @__PURE__ */ jsxs(
5538
+ children: /* @__PURE__ */ jsx(Layer, { zIndex: "sticky", children: /* @__PURE__ */ jsxs(
5481
5539
  CardHeader,
5482
5540
  {
5483
5541
  ...headerProps,
@@ -5501,7 +5559,10 @@ const IssuesPanelSummaryCard = forwardRef(function IssuesPanelSummaryCard2({
5501
5559
  color: relevantColor,
5502
5560
  size: "lg",
5503
5561
  ...iconProps,
5504
- className: cx(prefix("issues-panel__icon"), iconProps?.className),
5562
+ className: cx(
5563
+ prefix("issues-panel__icon"),
5564
+ iconProps?.className
5565
+ ),
5505
5566
  icon: relevantIcon
5506
5567
  }
5507
5568
  ),
@@ -5528,7 +5589,7 @@ const IssuesPanelSummaryCard = forwardRef(function IssuesPanelSummaryCard2({
5528
5589
  renderControls(relevantColor)
5529
5590
  ]
5530
5591
  }
5531
- )
5592
+ ) })
5532
5593
  }
5533
5594
  );
5534
5595
  });
@@ -5788,7 +5849,7 @@ const IssuesPanel = forwardRef(function ValidationPanel({
5788
5849
  setContainerEl,
5789
5850
  containerProps?.ref
5790
5851
  );
5791
- return open && !printing && /* @__PURE__ */ jsx(
5852
+ return open && !printing && /* @__PURE__ */ jsx(Layer, { zIndex: ["docked", 1], children: /* @__PURE__ */ jsx(
5792
5853
  "div",
5793
5854
  {
5794
5855
  ...containerProps,
@@ -5838,7 +5899,7 @@ const IssuesPanel = forwardRef(function ValidationPanel({
5838
5899
  }
5839
5900
  ) })
5840
5901
  }
5841
- );
5902
+ ) });
5842
5903
  });
5843
5904
  function mostRelevantIssuePath(info, latestInteraction, formSchema, issuesOrderCompareFn) {
5844
5905
  if (issuesOrderCompareFn) {
@@ -7753,44 +7814,6 @@ const TextControl = forwardRef(function TextControl2({
7753
7814
  function parseText(formattedValue, state) {
7754
7815
  return state.schema.typeInfo.nullable ? formattedValue || null : formattedValue;
7755
7816
  }
7756
- const TopBar = forwardRef(
7757
- function TopBar2({ className, ...otherProps }, forwardedRef) {
7758
- const prefix = usePrefix();
7759
- const { printHidden } = usePrintClassNames();
7760
- const setTopBarHeight = useSetTopBarHeight();
7761
- const [topBarEl, setTopBarEl] = useState(null);
7762
- useMeasure(
7763
- topBarEl,
7764
- useCallback(
7765
- (measurement) => setTopBarHeight(measurement?.height),
7766
- [setTopBarHeight]
7767
- )
7768
- );
7769
- const combinedTopBarRef = useCombinedRef(setTopBarEl, forwardedRef);
7770
- return /* @__PURE__ */ jsx(PortalContext.Provider, { value: { container: topBarEl }, children: /* @__PURE__ */ jsx(
7771
- "div",
7772
- {
7773
- className: cx(prefix("top-bar"), printHidden, className),
7774
- ...otherProps,
7775
- ref: combinedTopBarRef
7776
- }
7777
- ) });
7778
- }
7779
- );
7780
- const TopBarActions = forwardRef(function TopBarActions2({ className, ...otherProps }, forwardedRef) {
7781
- const prefix = usePrefix();
7782
- return /* @__PURE__ */ jsx(
7783
- Stack,
7784
- {
7785
- className: cx(prefix("top-bar__actions"), className),
7786
- direction: "row",
7787
- gap: 2,
7788
- justifyContent: "flex-end",
7789
- ...otherProps,
7790
- ref: forwardedRef
7791
- }
7792
- );
7793
- });
7794
7817
  const DEFAULT_VALIDATE_KEYBINDS = "Alt+Shift+V";
7795
7818
  function ValidateAction({
7796
7819
  label,
@@ -7834,6 +7857,66 @@ function ValidateAction({
7834
7857
  }
7835
7858
  );
7836
7859
  }
7860
+ const ALWAYS_RESET = () => true;
7861
+ function useResetOnChange(toReset, {
7862
+ when = ALWAYS_RESET,
7863
+ exclude,
7864
+ confirmation,
7865
+ setUntouched = true,
7866
+ setPristine = true
7867
+ } = {}) {
7868
+ const { confirm } = useAlertDialog();
7869
+ const formManager = useFormManager();
7870
+ const currentPath = useCurrentPath();
7871
+ const resettingValue = useRef(false);
7872
+ return async function handleValueChange(event) {
7873
+ if (!resettingValue.current && when(event)) {
7874
+ let resolvedToReset = (Array.isArray(toReset) ? toReset : [toReset]).map(
7875
+ (path) => currentPath.resolve(path)
7876
+ );
7877
+ if (exclude) {
7878
+ const resolvedExclude = (Array.isArray(exclude) ? exclude : [exclude]).map((path) => currentPath.resolve(path));
7879
+ resolvedToReset = excludePaths(
7880
+ formManager,
7881
+ resolvedToReset,
7882
+ resolvedExclude
7883
+ );
7884
+ }
7885
+ if (confirmation) {
7886
+ const { message, ...confirmOptions } = confirmation;
7887
+ if (await someIsDirty(formManager, resolvedToReset) && !await confirm(message, { color: "warning", ...confirmOptions })) {
7888
+ resettingValue.current = true;
7889
+ setTimeout(
7890
+ () => formManager.set(event.path, event.oldValue).finally(() => resettingValue.current = false)
7891
+ );
7892
+ return;
7893
+ }
7894
+ }
7895
+ void resetAll(formManager, resolvedToReset, setUntouched, setPristine);
7896
+ }
7897
+ };
7898
+ }
7899
+ function excludePaths(formManager, paths, exclude) {
7900
+ return paths.flatMap(
7901
+ (path) => Array.from(formManager.schemaInfo(path)).map((info) => info.path)
7902
+ ).filter((path) => !exclude.some((toIgnore) => path.matches(toIgnore)));
7903
+ }
7904
+ async function someIsDirty(formManager, paths) {
7905
+ const dirtyStatuses = await Promise.all(
7906
+ paths.map((path) => formManager.isDirty(path))
7907
+ );
7908
+ return dirtyStatuses.some((isDirty) => isDirty);
7909
+ }
7910
+ async function resetAll(formManager, toReset, setPristine, setUntouched) {
7911
+ await Promise.all(
7912
+ // eslint-disable-next-line @typescript-eslint/await-thenable
7913
+ toReset.flatMap((path) => [
7914
+ formManager.reset(path),
7915
+ setPristine && formManager.setPristine(path),
7916
+ setUntouched && formManager.setUntouched(path)
7917
+ ])
7918
+ );
7919
+ }
7837
7920
  export {
7838
7921
  ActivePathContext,
7839
7922
  ActivePathProvider,
@@ -7940,10 +8023,12 @@ export {
7940
8023
  useRegisterIssueMessages,
7941
8024
  useRegisterLabel,
7942
8025
  useRegisteredIssueMessage,
8026
+ useResetOnChange,
7943
8027
  useSetBottomPanelHeight,
7944
8028
  useSetLeftSidebarWidth,
7945
8029
  useSetTopBarHeight,
7946
8030
  useStartIssuesNavigation,
7947
- useTableControlApiRef
8031
+ useTableControlApiRef,
8032
+ useTopBarElement
7948
8033
  };
7949
8034
  //# sourceMappingURL=ostack-ui-kform.js.map