@iblai/web-containers 0.0.2 → 0.0.6

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 (51) hide show
  1. package/dist/components/index.d.ts +2 -0
  2. package/dist/components/profile/invite-user.d.ts +2 -1
  3. package/dist/components/top-banner/index.d.ts +3 -0
  4. package/dist/components/top-banner/types.d.ts +10 -0
  5. package/dist/components/top-banner/use-top-banner.d.ts +11 -0
  6. package/dist/index.d.ts +0 -1
  7. package/dist/index.esm.js +231 -70
  8. package/dist/index.esm.js.map +1 -1
  9. package/dist/index.js +231 -69
  10. package/dist/index.js.map +1 -1
  11. package/package.json +7 -7
  12. package/dist/components/ui/accordion.d.ts +0 -6
  13. package/dist/components/ui/alert-dialog.d.ts +0 -19
  14. package/dist/components/ui/alert.d.ts +0 -8
  15. package/dist/components/ui/aspect-ratio.d.ts +0 -2
  16. package/dist/components/ui/breadcrumb.d.ts +0 -19
  17. package/dist/components/ui/calendar.d.ts +0 -8
  18. package/dist/components/ui/card.d.ts +0 -6
  19. package/dist/components/ui/carousel.d.ts +0 -18
  20. package/dist/components/ui/chart.d.ts +0 -55
  21. package/dist/components/ui/collapsible.d.ts +0 -4
  22. package/dist/components/ui/command.d.ts +0 -15
  23. package/dist/components/ui/context-menu.d.ts +0 -20
  24. package/dist/components/ui/date-range-picker.d.ts +0 -2
  25. package/dist/components/ui/drawer.d.ts +0 -22
  26. package/dist/components/ui/dropdown-menu.d.ts +0 -20
  27. package/dist/components/ui/form.d.ts +0 -11
  28. package/dist/components/ui/hover-card.d.ts +0 -5
  29. package/dist/components/ui/input-otp.d.ts +0 -8
  30. package/dist/components/ui/menubar.d.ts +0 -21
  31. package/dist/components/ui/modal.d.ts +0 -13
  32. package/dist/components/ui/navigation-menu.d.ts +0 -11
  33. package/dist/components/ui/popover.d.ts +0 -5
  34. package/dist/components/ui/progress.d.ts +0 -3
  35. package/dist/components/ui/radio-group.d.ts +0 -4
  36. package/dist/components/ui/resizable.d.ts +0 -7
  37. package/dist/components/ui/scroll-area.d.ts +0 -4
  38. package/dist/components/ui/separator.d.ts +0 -3
  39. package/dist/components/ui/sheet.d.ts +0 -25
  40. package/dist/components/ui/sidebar.d.ts +0 -66
  41. package/dist/components/ui/skeleton.d.ts +0 -2
  42. package/dist/components/ui/slider.d.ts +0 -3
  43. package/dist/components/ui/sonner.d.ts +0 -4
  44. package/dist/components/ui/tabs.d.ts +0 -6
  45. package/dist/components/ui/toggle-group.d.ts +0 -4
  46. package/dist/components/ui/toggle.d.ts +0 -7
  47. package/dist/components/ui/tooltip-flowbite.d.ts +0 -10
  48. package/dist/components/ui/tooltip.d.ts +0 -7
  49. package/dist/components/ui/use-mobile.d.ts +0 -1
  50. package/dist/index.css +0 -128
  51. package/dist/index.esm.css +0 -128
@@ -1,3 +1,5 @@
1
1
  export * from "./profile";
2
2
  export * from "./profile/invite-user";
3
3
  export * from "./profile/invited-users";
4
+ export * from "./top-banner";
5
+ export * from "./top-banner/types";
@@ -1,5 +1,6 @@
1
- export declare function InviteUserDialog({ tenant, onSeeAllInvitedUsersClick, onClose, }: {
1
+ export declare function InviteUserDialog({ tenant, onSeeAllInvitedUsersClick, onClose, isOpen, }: {
2
2
  tenant: string;
3
3
  onSeeAllInvitedUsersClick: () => void;
4
4
  onClose: () => void;
5
+ isOpen: boolean;
5
6
  }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,3 @@
1
+ import { TopBannerProps } from "./types";
2
+ export declare function TopBanner({ parentContainerSelector, bannerText, loading, tooltipText, buttonLabel, buttonHandler, onLoad, onClose, }: TopBannerProps): import("react/jsx-runtime").JSX.Element | null;
3
+ export default TopBanner;
@@ -0,0 +1,10 @@
1
+ export interface TopBannerProps {
2
+ parentContainerSelector: string;
3
+ bannerText?: string;
4
+ loading?: boolean;
5
+ tooltipText?: string;
6
+ buttonHandler?: () => void;
7
+ buttonLabel?: string;
8
+ onLoad?: (bannerRef: HTMLDivElement) => void;
9
+ onClose?: () => void;
10
+ }
@@ -0,0 +1,11 @@
1
+ import { TopBannerProps } from "./types";
2
+ export declare const useTopBanner: ({ parentContainerSelector, loading, onLoad, onClose, }: TopBannerProps) => {
3
+ visible: boolean;
4
+ setVisible: import("react").Dispatch<import("react").SetStateAction<boolean>>;
5
+ showTooltip: boolean;
6
+ setShowTooltip: import("react").Dispatch<import("react").SetStateAction<boolean>>;
7
+ bannerRef: import("react").RefObject<HTMLDivElement | null>;
8
+ parentElRef: import("react").RefObject<HTMLElement | null>;
9
+ isLoading: boolean | undefined;
10
+ setLoading: import("react").Dispatch<import("react").SetStateAction<boolean | undefined>>;
11
+ };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
- import "./global.css";
2
1
  export * from "./hooks";
3
2
  export * from "./components";
package/dist/index.esm.js CHANGED
@@ -3889,7 +3889,7 @@ const oppositeAlignmentMap = {
3889
3889
  function clamp(start, value, end) {
3890
3890
  return max(start, min(value, end));
3891
3891
  }
3892
- function evaluate(value, param) {
3892
+ function evaluate$1(value, param) {
3893
3893
  return typeof value === 'function' ? value(param) : value;
3894
3894
  }
3895
3895
  function getSide(placement) {
@@ -4171,7 +4171,7 @@ async function detectOverflow(state, options) {
4171
4171
  elementContext = 'floating',
4172
4172
  altBoundary = false,
4173
4173
  padding = 0
4174
- } = evaluate(options, state);
4174
+ } = evaluate$1(options, state);
4175
4175
  const paddingObject = getPaddingObject(padding);
4176
4176
  const altContext = elementContext === 'floating' ? 'reference' : 'floating';
4177
4177
  const element = elements[altBoundary ? altContext : elementContext];
@@ -4231,7 +4231,7 @@ const arrow$3 = options => ({
4231
4231
  const {
4232
4232
  element,
4233
4233
  padding = 0
4234
- } = evaluate(options, state) || {};
4234
+ } = evaluate$1(options, state) || {};
4235
4235
  if (element == null) {
4236
4236
  return {};
4237
4237
  }
@@ -4322,7 +4322,7 @@ const flip$2 = function (options) {
4322
4322
  fallbackAxisSideDirection = 'none',
4323
4323
  flipAlignment = true,
4324
4324
  ...detectOverflowOptions
4325
- } = evaluate(options, state);
4325
+ } = evaluate$1(options, state);
4326
4326
 
4327
4327
  // If a reset by the arrow was caused due to an alignment offset being
4328
4328
  // added, we should skip any logic now since `flip()` has already done its
@@ -4452,7 +4452,7 @@ const hide$2 = function (options) {
4452
4452
  const {
4453
4453
  strategy = 'referenceHidden',
4454
4454
  ...detectOverflowOptions
4455
- } = evaluate(options, state);
4455
+ } = evaluate$1(options, state);
4456
4456
  switch (strategy) {
4457
4457
  case 'referenceHidden':
4458
4458
  {
@@ -4506,7 +4506,7 @@ async function convertValueToCoords(state, options) {
4506
4506
  const isVertical = getSideAxis(placement) === 'y';
4507
4507
  const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
4508
4508
  const crossAxisMulti = rtl && isVertical ? -1 : 1;
4509
- const rawValue = evaluate(options, state);
4509
+ const rawValue = evaluate$1(options, state);
4510
4510
 
4511
4511
  // eslint-disable-next-line prefer-const
4512
4512
  let {
@@ -4609,7 +4609,7 @@ const shift$2 = function (options) {
4609
4609
  }
4610
4610
  },
4611
4611
  ...detectOverflowOptions
4612
- } = evaluate(options, state);
4612
+ } = evaluate$1(options, state);
4613
4613
  const coords = {
4614
4614
  x,
4615
4615
  y
@@ -4673,7 +4673,7 @@ const limitShift$2 = function (options) {
4673
4673
  offset = 0,
4674
4674
  mainAxis: checkMainAxis = true,
4675
4675
  crossAxis: checkCrossAxis = true
4676
- } = evaluate(options, state);
4676
+ } = evaluate$1(options, state);
4677
4677
  const coords = {
4678
4678
  x,
4679
4679
  y
@@ -4682,7 +4682,7 @@ const limitShift$2 = function (options) {
4682
4682
  const mainAxis = getOppositeAxis(crossAxis);
4683
4683
  let mainAxisCoord = coords[mainAxis];
4684
4684
  let crossAxisCoord = coords[crossAxis];
4685
- const rawOffset = evaluate(offset, state);
4685
+ const rawOffset = evaluate$1(offset, state);
4686
4686
  const computedOffset = typeof rawOffset === 'number' ? {
4687
4687
  mainAxis: rawOffset,
4688
4688
  crossAxis: 0
@@ -4745,7 +4745,7 @@ const size$2 = function (options) {
4745
4745
  const {
4746
4746
  apply = () => {},
4747
4747
  ...detectOverflowOptions
4748
- } = evaluate(options, state);
4748
+ } = evaluate$1(options, state);
4749
4749
  const overflow = await detectOverflow(state, detectOverflowOptions);
4750
4750
  const side = getSide(placement);
4751
4751
  const alignment = getAlignment(placement);
@@ -6594,8 +6594,9 @@ var hideOthers = function (originalTarget, parentNode, markerName) {
6594
6594
  if (!activeParentNode) {
6595
6595
  return function () { return null; };
6596
6596
  }
6597
- // we should not hide ariaLive elements - https://github.com/theKashey/aria-hidden/issues/10
6598
- targets.push.apply(targets, Array.from(activeParentNode.querySelectorAll('[aria-live]')));
6597
+ // we should not hide aria-live elements - https://github.com/theKashey/aria-hidden/issues/10
6598
+ // and script elements, as they have no impact on accessibility.
6599
+ targets.push.apply(targets, Array.from(activeParentNode.querySelectorAll('[aria-live], script')));
6599
6600
  return applyAttributeToOthers(targets, activeParentNode, markerName, 'aria-hidden');
6600
6601
  };
6601
6602
 
@@ -6874,12 +6875,12 @@ var RemoveScroll = React.forwardRef(function (props, parentRef) {
6874
6875
  onWheelCapture: nothing,
6875
6876
  onTouchMoveCapture: nothing,
6876
6877
  }), callbacks = _a[0], setCallbacks = _a[1];
6877
- var forwardProps = props.forwardProps, children = props.children, className = props.className, removeScrollBar = props.removeScrollBar, enabled = props.enabled, shards = props.shards, sideCar = props.sideCar, noIsolation = props.noIsolation, inert = props.inert, allowPinchZoom = props.allowPinchZoom, _b = props.as, Container = _b === void 0 ? 'div' : _b, gapMode = props.gapMode, rest = __rest(props, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noIsolation", "inert", "allowPinchZoom", "as", "gapMode"]);
6878
+ var forwardProps = props.forwardProps, children = props.children, className = props.className, removeScrollBar = props.removeScrollBar, enabled = props.enabled, shards = props.shards, sideCar = props.sideCar, noRelative = props.noRelative, noIsolation = props.noIsolation, inert = props.inert, allowPinchZoom = props.allowPinchZoom, _b = props.as, Container = _b === void 0 ? 'div' : _b, gapMode = props.gapMode, rest = __rest(props, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noRelative", "noIsolation", "inert", "allowPinchZoom", "as", "gapMode"]);
6878
6879
  var SideCar = sideCar;
6879
6880
  var containerRef = useMergeRefs([ref, parentRef]);
6880
6881
  var containerProps = __assign(__assign({}, rest), callbacks);
6881
6882
  return (React.createElement(React.Fragment, null,
6882
- enabled && (React.createElement(SideCar, { sideCar: effectCar, removeScrollBar: removeScrollBar, shards: shards, noIsolation: noIsolation, inert: inert, setCallbacks: setCallbacks, allowPinchZoom: !!allowPinchZoom, lockRef: ref, gapMode: gapMode })),
6883
+ enabled && (React.createElement(SideCar, { sideCar: effectCar, removeScrollBar: removeScrollBar, shards: shards, noRelative: noRelative, noIsolation: noIsolation, inert: inert, setCallbacks: setCallbacks, allowPinchZoom: !!allowPinchZoom, lockRef: ref, gapMode: gapMode })),
6883
6884
  forwardProps ? (React.cloneElement(React.Children.only(children), __assign(__assign({}, containerProps), { ref: containerRef }))) : (React.createElement(Container, __assign({}, containerProps, { className: className, ref: containerRef }), children))));
6884
6885
  });
6885
6886
  RemoveScroll.defaultProps = {
@@ -7169,12 +7170,9 @@ var handleScroll = function (axis, endTarget, event, sourceDelta, noOverscroll)
7169
7170
  availableScrollTop += position;
7170
7171
  }
7171
7172
  }
7172
- if (target instanceof ShadowRoot) {
7173
- target = target.host;
7174
- }
7175
- else {
7176
- target = target.parentNode;
7177
- }
7173
+ // we will "bubble" from ShadowDom in case we are, or just to the parent in normal case
7174
+ // this is the same logic used in focus-lock
7175
+ target = (target.parentNode.host || target.parentNode);
7178
7176
  } while (
7179
7177
  // portaled content
7180
7178
  (!targetInLock && target !== document.body) ||
@@ -7330,7 +7328,7 @@ function RemoveScrollSideCar(props) {
7330
7328
  var removeScrollBar = props.removeScrollBar, inert = props.inert;
7331
7329
  return (React.createElement(React.Fragment, null,
7332
7330
  inert ? React.createElement(Style, { styles: generateStyle(id) }) : null,
7333
- removeScrollBar ? React.createElement(RemoveScrollBar, { gapMode: props.gapMode }) : null));
7331
+ removeScrollBar ? React.createElement(RemoveScrollBar, { noRelative: props.noRelative, gapMode: props.gapMode }) : null));
7334
7332
  }
7335
7333
  function getOutermostShadowParent(node) {
7336
7334
  var shadowParent = null;
@@ -10112,7 +10110,7 @@ var Close$1 = ToastClose$1;
10112
10110
  const ToastProvider = Provider;
10113
10111
  const ToastViewport = React.forwardRef(({ className, ...props }, ref) => (jsx(Viewport, { ref: ref, className: cn("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]", className), ...props })));
10114
10112
  ToastViewport.displayName = Viewport.displayName;
10115
- const toastVariants = cva("group pointer-events-auto relative flex w-full items-center justify-between space-x-2 overflow-hidden rounded-md border p-4 pr-6 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full", {
10113
+ const toastVariants = cva("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full", {
10116
10114
  variants: {
10117
10115
  variant: {
10118
10116
  default: "border bg-background text-foreground",
@@ -10127,11 +10125,11 @@ const Toast = React.forwardRef(({ className, variant, ...props }, ref) => {
10127
10125
  return (jsx(Root2, { ref: ref, className: cn(toastVariants({ variant }), className), ...props }));
10128
10126
  });
10129
10127
  Toast.displayName = Root2.displayName;
10130
- const ToastAction = React.forwardRef(({ className, ...props }, ref) => (jsx(Action, { ref: ref, className: cn("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium transition-colors hover:bg-secondary focus:outline-none focus:ring-1 focus:ring-ring disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive", className), ...props })));
10128
+ const ToastAction = React.forwardRef(({ className, ...props }, ref) => (jsx(Action, { ref: ref, className: cn("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive", className), ...props })));
10131
10129
  ToastAction.displayName = Action.displayName;
10132
- const ToastClose = React.forwardRef(({ className, ...props }, ref) => (jsx(Close$1, { ref: ref, className: cn("absolute right-1 top-1 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-1 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600", className), "toast-close": "", ...props, children: jsx(X, { className: "h-4 w-4" }) })));
10130
+ const ToastClose = React.forwardRef(({ className, ...props }, ref) => (jsx(Close$1, { ref: ref, className: cn("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600", className), "toast-close": "", ...props, children: jsx(X, { className: "h-4 w-4" }) })));
10133
10131
  ToastClose.displayName = Close$1.displayName;
10134
- const ToastTitle = React.forwardRef(({ className, ...props }, ref) => (jsx(Title$1, { ref: ref, className: cn("text-sm font-semibold [&+div]:text-xs", className), ...props })));
10132
+ const ToastTitle = React.forwardRef(({ className, ...props }, ref) => (jsx(Title$1, { ref: ref, className: cn("text-sm font-semibold", className), ...props })));
10135
10133
  ToastTitle.displayName = Title$1.displayName;
10136
10134
  const ToastDescription = React.forwardRef(({ className, ...props }, ref) => (jsx(Description$1, { ref: ref, className: cn("text-sm opacity-90", className), ...props })));
10137
10135
  ToastDescription.displayName = Description$1.displayName;
@@ -11051,7 +11049,7 @@ function getSyncValidatorArray(cause, options) {
11051
11049
  const isGlobalFormValidationError = (error) => {
11052
11050
  return !!error && typeof error === "object" && "fields" in error;
11053
11051
  };
11054
- function shallow$1(objA, objB) {
11052
+ function evaluate(objA, objB) {
11055
11053
  if (Object.is(objA, objB)) {
11056
11054
  return true;
11057
11055
  }
@@ -11073,11 +11071,12 @@ function shallow$1(objA, objB) {
11073
11071
  return true;
11074
11072
  }
11075
11073
  const keysA = Object.keys(objA);
11076
- if (keysA.length !== Object.keys(objB).length) {
11074
+ const keysB = Object.keys(objB);
11075
+ if (keysA.length !== keysB.length) {
11077
11076
  return false;
11078
11077
  }
11079
- for (let i = 0; i < keysA.length; i++) {
11080
- if (!Object.prototype.hasOwnProperty.call(objB, keysA[i]) || !Object.is(objA[keysA[i]], objB[keysA[i]])) {
11078
+ for (const key of keysA) {
11079
+ if (!keysB.includes(key) || !evaluate(objA[key], objB[key])) {
11081
11080
  return false;
11082
11081
  }
11083
11082
  }
@@ -11164,6 +11163,7 @@ const defaultFieldMeta = {
11164
11163
  isDirty: false,
11165
11164
  isPristine: true,
11166
11165
  isValid: true,
11166
+ isDefaultValue: true,
11167
11167
  errors: [],
11168
11168
  errorMap: {},
11169
11169
  errorSourceMap: {}
@@ -11325,8 +11325,8 @@ class FormApi {
11325
11325
  const shouldUpdateReeval = !!((_b = (_a2 = options.transform) == null ? void 0 : _a2.deps) == null ? void 0 : _b.some(
11326
11326
  (val, i) => val !== this.prevTransformArray[i]
11327
11327
  ));
11328
- const shouldUpdateValues = options.defaultValues && !shallow$1(options.defaultValues, oldOptions.defaultValues) && !this.state.isTouched;
11329
- const shouldUpdateState = !shallow$1(options.defaultState, oldOptions.defaultState) && !this.state.isTouched;
11328
+ const shouldUpdateValues = options.defaultValues && !evaluate(options.defaultValues, oldOptions.defaultValues) && !this.state.isTouched;
11329
+ const shouldUpdateState = !evaluate(options.defaultState, oldOptions.defaultState) && !this.state.isTouched;
11330
11330
  if (!shouldUpdateValues && !shouldUpdateState && !shouldUpdateReeval) return;
11331
11331
  batch(() => {
11332
11332
  this.baseStore.setState(
@@ -11814,10 +11814,7 @@ class FormApi {
11814
11814
  ...prev.fieldMetaBase,
11815
11815
  [field]: defaultFieldMeta
11816
11816
  },
11817
- values: {
11818
- ...prev.values,
11819
- [field]: this.options.defaultValues && this.options.defaultValues[field]
11820
- }
11817
+ values: this.options.defaultValues ? setBy(prev.values, field, getBy(this.options.defaultValues, field)) : prev.values
11821
11818
  };
11822
11819
  });
11823
11820
  };
@@ -11862,7 +11859,7 @@ class FormApi {
11862
11859
  this.fieldMetaDerived = new Derived({
11863
11860
  deps: [this.baseStore],
11864
11861
  fn: ({ prevDepVals, currDepVals, prevVal: _prevVal }) => {
11865
- var _a2;
11862
+ var _a2, _b, _c;
11866
11863
  const prevVal = _prevVal;
11867
11864
  const prevBaseStore = prevDepVals == null ? void 0 : prevDepVals[0];
11868
11865
  const currBaseStore = currDepVals[0];
@@ -11871,12 +11868,13 @@ class FormApi {
11871
11868
  for (const fieldName of Object.keys(
11872
11869
  currBaseStore.fieldMetaBase
11873
11870
  )) {
11874
- const currBaseVal = currBaseStore.fieldMetaBase[fieldName];
11875
- const prevBaseVal = prevBaseStore == null ? void 0 : prevBaseStore.fieldMetaBase[fieldName];
11871
+ const currBaseMeta = currBaseStore.fieldMetaBase[fieldName];
11872
+ const prevBaseMeta = prevBaseStore == null ? void 0 : prevBaseStore.fieldMetaBase[fieldName];
11876
11873
  const prevFieldInfo = prevVal == null ? void 0 : prevVal[fieldName];
11874
+ const curFieldVal = getBy(currBaseStore.values, fieldName);
11877
11875
  let fieldErrors = prevFieldInfo == null ? void 0 : prevFieldInfo.errors;
11878
- if (!prevBaseVal || currBaseVal.errorMap !== prevBaseVal.errorMap) {
11879
- fieldErrors = Object.values(currBaseVal.errorMap ?? {}).filter(
11876
+ if (!prevBaseMeta || currBaseMeta.errorMap !== prevBaseMeta.errorMap) {
11877
+ fieldErrors = Object.values(currBaseMeta.errorMap ?? {}).filter(
11880
11878
  (val) => val !== void 0
11881
11879
  );
11882
11880
  const fieldInstance = (_a2 = this.getFieldInfo(fieldName)) == null ? void 0 : _a2.instance;
@@ -11886,18 +11884,27 @@ class FormApi {
11886
11884
  );
11887
11885
  }
11888
11886
  }
11889
- const isFieldPristine = !currBaseVal.isDirty;
11890
11887
  const isFieldValid = !isNonEmptyArray(fieldErrors ?? []);
11891
- if (prevFieldInfo && prevFieldInfo.isPristine === isFieldPristine && prevFieldInfo.isValid === isFieldValid && prevFieldInfo.errors === fieldErrors && currBaseVal === prevBaseVal) {
11888
+ const isFieldPristine = !currBaseMeta.isDirty;
11889
+ const isDefaultValue = evaluate(
11890
+ curFieldVal,
11891
+ getBy(this.options.defaultValues, fieldName)
11892
+ ) || evaluate(
11893
+ curFieldVal,
11894
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
11895
+ (_c = (_b = this.getFieldInfo(fieldName)) == null ? void 0 : _b.instance) == null ? void 0 : _c.options.defaultValue
11896
+ );
11897
+ if (prevFieldInfo && prevFieldInfo.isPristine === isFieldPristine && prevFieldInfo.isValid === isFieldValid && prevFieldInfo.isDefaultValue === isDefaultValue && prevFieldInfo.errors === fieldErrors && currBaseMeta === prevBaseMeta) {
11892
11898
  fieldMeta[fieldName] = prevFieldInfo;
11893
11899
  originalMetaCount++;
11894
11900
  continue;
11895
11901
  }
11896
11902
  fieldMeta[fieldName] = {
11897
- ...currBaseVal,
11903
+ ...currBaseMeta,
11898
11904
  errors: fieldErrors,
11899
11905
  isPristine: isFieldPristine,
11900
- isValid: isFieldValid
11906
+ isValid: isFieldValid,
11907
+ isDefaultValue
11901
11908
  };
11902
11909
  }
11903
11910
  if (!Object.keys(currBaseStore.fieldMetaBase).length) return fieldMeta;
@@ -11924,6 +11931,9 @@ class FormApi {
11924
11931
  const isFieldsValid = fieldMetaValues.every((field) => field.isValid);
11925
11932
  const isTouched = fieldMetaValues.some((field) => field.isTouched);
11926
11933
  const isBlurred = fieldMetaValues.some((field) => field.isBlurred);
11934
+ const isDefaultValue = fieldMetaValues.every(
11935
+ (field) => field.isDefaultValue
11936
+ );
11927
11937
  const shouldInvalidateOnMount = (
11928
11938
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
11929
11939
  isTouched && ((_a2 = currBaseStore.errorMap) == null ? void 0 : _a2.onMount)
@@ -11962,7 +11972,7 @@ class FormApi {
11962
11972
  );
11963
11973
  errorMap = Object.assign(errorMap, { onMount: void 0 });
11964
11974
  }
11965
- if (prevVal && prevBaseStore && prevVal.errorMap === errorMap && prevVal.fieldMeta === this.fieldMetaDerived.state && prevVal.errors === errors && prevVal.isFieldsValidating === isFieldsValidating && prevVal.isFieldsValid === isFieldsValid && prevVal.isFormValid === isFormValid && prevVal.isValid === isValid && prevVal.canSubmit === canSubmit && prevVal.isTouched === isTouched && prevVal.isBlurred === isBlurred && prevVal.isPristine === isPristine && prevVal.isDirty === isDirty && shallow$1(prevBaseStore, currBaseStore)) {
11975
+ if (prevVal && prevBaseStore && prevVal.errorMap === errorMap && prevVal.fieldMeta === this.fieldMetaDerived.state && prevVal.errors === errors && prevVal.isFieldsValidating === isFieldsValidating && prevVal.isFieldsValid === isFieldsValid && prevVal.isFormValid === isFormValid && prevVal.isValid === isValid && prevVal.canSubmit === canSubmit && prevVal.isTouched === isTouched && prevVal.isBlurred === isBlurred && prevVal.isPristine === isPristine && prevVal.isDefaultValue === isDefaultValue && prevVal.isDirty === isDirty && evaluate(prevBaseStore, currBaseStore)) {
11966
11976
  return prevVal;
11967
11977
  }
11968
11978
  let state = {
@@ -11978,6 +11988,7 @@ class FormApi {
11978
11988
  isTouched,
11979
11989
  isBlurred,
11980
11990
  isPristine,
11991
+ isDefaultValue,
11981
11992
  isDirty
11982
11993
  };
11983
11994
  const transformArray = ((_c = this.options.transform) == null ? void 0 : _c.deps) ?? [];
@@ -12094,13 +12105,46 @@ class FormApi {
12094
12105
  * Updates the form's errorMap
12095
12106
  */
12096
12107
  setErrorMap(errorMap) {
12097
- this.baseStore.setState((prev) => ({
12098
- ...prev,
12099
- errorMap: {
12100
- ...prev.errorMap,
12101
- ...errorMap
12102
- }
12103
- }));
12108
+ batch(() => {
12109
+ Object.entries(errorMap).forEach(([key, value]) => {
12110
+ const errorMapKey = key;
12111
+ if (isGlobalFormValidationError(value)) {
12112
+ const { formError, fieldErrors } = normalizeError$1(value);
12113
+ for (const fieldName of Object.keys(
12114
+ this.fieldInfo
12115
+ )) {
12116
+ const fieldMeta = this.getFieldMeta(fieldName);
12117
+ if (!fieldMeta) continue;
12118
+ this.setFieldMeta(fieldName, (prev) => ({
12119
+ ...prev,
12120
+ errorMap: {
12121
+ ...prev.errorMap,
12122
+ [errorMapKey]: fieldErrors == null ? void 0 : fieldErrors[fieldName]
12123
+ },
12124
+ errorSourceMap: {
12125
+ ...prev.errorSourceMap,
12126
+ [errorMapKey]: "form"
12127
+ }
12128
+ }));
12129
+ }
12130
+ this.baseStore.setState((prev) => ({
12131
+ ...prev,
12132
+ errorMap: {
12133
+ ...prev.errorMap,
12134
+ [errorMapKey]: formError
12135
+ }
12136
+ }));
12137
+ } else {
12138
+ this.baseStore.setState((prev) => ({
12139
+ ...prev,
12140
+ errorMap: {
12141
+ ...prev.errorMap,
12142
+ [errorMapKey]: value
12143
+ }
12144
+ }));
12145
+ }
12146
+ });
12147
+ });
12104
12148
  }
12105
12149
  }
12106
12150
  function normalizeError$1(rawError) {
@@ -14153,26 +14197,47 @@ const getUserName = () => {
14153
14197
  return (_a = JSON.parse(localStorage.getItem("userData"))) === null || _a === void 0 ? void 0 : _a.user_nicename;
14154
14198
  };
14155
14199
 
14156
- function InviteUserDialog({ tenant, onSeeAllInvitedUsersClick, onClose, }) {
14200
+ function InviteUserDialog({ tenant, onSeeAllInvitedUsersClick, onClose, isOpen, }) {
14157
14201
  const [inviteUser] = useInviteUserMutation();
14158
14202
  const [email, setEmail] = useState("");
14159
- const [isOpen, setIsOpen] = useState(true);
14203
+ const containerRef = useRef(null);
14204
+ const { toast } = useToast();
14205
+ useEffect(() => {
14206
+ containerRef.current = document.getElementById("invite-user-dialog-container");
14207
+ }, []);
14160
14208
  const handleInviteUser = async () => {
14161
- await inviteUser([
14162
- {
14163
- email,
14164
- platform_key: tenant,
14165
- redirect_to: window.location.href,
14166
- source: getUserName(),
14167
- },
14168
- ]);
14209
+ try {
14210
+ await inviteUser([
14211
+ {
14212
+ email,
14213
+ platform_key: tenant,
14214
+ redirect_to: window.location.href,
14215
+ source: getUserName(),
14216
+ },
14217
+ ]);
14218
+ setEmail("");
14219
+ toast({
14220
+ title: "Success",
14221
+ description: `Invited user {email} successfully`,
14222
+ });
14223
+ }
14224
+ catch (error) {
14225
+ console.error(error);
14226
+ }
14169
14227
  };
14170
- return (jsx(Fragment, { children: jsx(Dialog, { open: isOpen, onOpenChange: (open) => {
14171
- if (!open) {
14172
- setIsOpen(open);
14173
- onClose();
14174
- }
14175
- }, children: jsx(DialogPortal, { children: jsxs(DialogContent, { className: "max-w-sm rounded-2xl px-6 py-8 pointer-events-auto", children: [jsxs(DialogHeader, { className: "relative flex-row justify-between", children: [jsx(DialogTitle, { className: "text-blue-600 text-xl font-semibold", children: "Invite New User" }), jsx(DialogDescription$1, { children: jsx("span", { onClick: onSeeAllInvitedUsersClick, className: "text-blue-500 text-sm cursor-pointer hover:underline", children: "See All" }) })] }), jsxs("div", { className: "mt-4 space-y-1", children: [jsx("label", { className: "text-gray-700 text-sm font-medium", children: "Email" }), jsx("p", { className: "text-gray-500 text-sm", children: "A confirmation link would be sent" }), jsx(Input, { value: email, onChange: (event) => setEmail(event.target.value), placeholder: "Enter email address", className: "mt-2" })] }), jsx(Button, { onClick: handleInviteUser, className: "bg-[#2563EB] hover:bg-blue-600 text-white mt-6", children: "Submit" })] }) }) }) }));
14228
+ return (jsxs(Fragment, { children: [jsx("div", { id: "invite-user-dialog-container" }), jsx(Dialog, { open: isOpen, onOpenChange: (open) => {
14229
+ if (!open) {
14230
+ onClose();
14231
+ }
14232
+ }, children: jsx(DialogPortal, { container: containerRef.current || undefined, children: jsxs(DialogContent, { onInteractOutside: (e) => {
14233
+ e.preventDefault();
14234
+ e.stopPropagation();
14235
+ }, onEscapeKeyDown: (e) => {
14236
+ // Stop propagation to prevent both dialogs from closing
14237
+ e.preventDefault();
14238
+ e.stopPropagation();
14239
+ onClose();
14240
+ }, className: "max-w-sm rounded-2xl px-6 py-8 pointer-events-auto", children: [jsxs(DialogHeader, { className: "relative flex-row justify-between", children: [jsx(DialogTitle, { className: "text-blue-600 text-xl font-semibold", children: "Invite New User" }), jsx(DialogDescription, { children: jsx("span", { onClick: onSeeAllInvitedUsersClick, className: "text-blue-500 text-sm cursor-pointer hover:underline", children: "See All" }) })] }), jsxs("div", { className: "mt-4 space-y-1", children: [jsx("label", { className: "text-gray-700 text-sm font-medium", children: "Email" }), jsx("p", { className: "text-gray-500 text-sm", children: "A confirmation link would be sent" }), jsx(Input, { value: email, onChange: (event) => setEmail(event.target.value), placeholder: "Enter email address", className: "mt-2" })] }), jsx(Button, { onClick: handleInviteUser, className: "bg-[#2563EB] hover:bg-blue-600 text-white mt-6", children: "Submit" })] }) }) })] }));
14176
14241
  }
14177
14242
 
14178
14243
  function InvitedUsersDialog({ tenant, onClose, }) {
@@ -14194,8 +14259,104 @@ function InvitedUsersDialog({ tenant, onClose, }) {
14194
14259
  setOpen(_open);
14195
14260
  onClose();
14196
14261
  }
14197
- }, children: jsx(DialogPortal, { children: jsxs(DialogContent, { className: "max-w-sm rounded-2xl px-6 py-8 pointer-events-auto", children: [jsx(DialogHeader, { className: "relative flex-row justify-between", children: jsx(DialogTitle, { className: "text-blue-600 text-xl font-semibold", children: "Invited Users" }) }), jsxs("div", { className: "mt-4 space-y-1", children: [jsx("p", { className: "text-gray-500 text-sm", children: "Showing list of invited users pending confirmation" }), jsx("form", { children: jsx(Input, { value: query, onChange: (event) => setQuery(event.target.value), placeholder: "Search Invited Users", className: "mt-2" }) })] }), jsxs("div", { children: [jsx("h2", { className: "text-lg font-semibold", children: "Email" }), invitedUsers === null || invitedUsers === void 0 ? void 0 : invitedUsers.results.map((user) => (jsx("div", { className: "border-b-gray-50 pb-2 mb-4", children: user.email }))), (invitedUsers === null || invitedUsers === void 0 ? void 0 : invitedUsers.results.length) === 0 && (jsx("p", { className: "text-gray", children: "No records found" }))] })] }) }) }));
14262
+ }, children: jsx(DialogPortal, { forceMount: true, children: jsxs(DialogContent, { className: "max-w-sm rounded-2xl px-6 py-8 pointer-events-auto", children: [jsx(DialogHeader, { className: "relative flex-row justify-between", children: jsx(DialogTitle, { className: "text-blue-600 text-xl font-semibold", children: "Invited Users" }) }), jsxs("div", { className: "mt-4 space-y-1", children: [jsx("p", { className: "text-gray-500 text-sm", children: "Showing list of invited users pending confirmation" }), jsx("form", { children: jsx(Input, { value: query, onChange: (event) => setQuery(event.target.value), placeholder: "Search Invited Users", className: "mt-2" }) })] }), jsxs("div", { children: [jsx("h2", { className: "text-lg font-semibold", children: "Email" }), invitedUsers === null || invitedUsers === void 0 ? void 0 : invitedUsers.results.map((user) => (jsx("div", { className: "border-b-gray-50 pb-2 mb-4", children: user.email }))), (invitedUsers === null || invitedUsers === void 0 ? void 0 : invitedUsers.results.length) === 0 && (jsx("p", { className: "text-gray", children: "No records found" }))] })] }) }) }));
14263
+ }
14264
+
14265
+ //import { useDispatch } from "react-redux";
14266
+ const useTopBanner = ({ parentContainerSelector, loading, onLoad = () => { }, onClose = () => { }, }) => {
14267
+ //const dispatch = useDispatch();
14268
+ const [visible, setVisible] = useState(true);
14269
+ const [showTooltip, setShowTooltip] = useState(false);
14270
+ const [isLoading, setLoading] = useState(loading);
14271
+ const bannerRef = useRef(null);
14272
+ const prevParentHeight = useRef(null);
14273
+ const parentElRef = useRef(null);
14274
+ useEffect(() => {
14275
+ setLoading(loading);
14276
+ }, [loading]);
14277
+ useEffect(() => {
14278
+ if (visible && (bannerRef === null || bannerRef === void 0 ? void 0 : bannerRef.current)) {
14279
+ onLoad(bannerRef.current);
14280
+ }
14281
+ return () => {
14282
+ onClose();
14283
+ };
14284
+ }, [visible, bannerRef]);
14285
+ useEffect(() => {
14286
+ if (!visible)
14287
+ return;
14288
+ const parentEl = document.querySelector(parentContainerSelector);
14289
+ if (!parentEl)
14290
+ return;
14291
+ parentElRef.current = parentEl;
14292
+ function updateParentHeight() {
14293
+ if (!bannerRef.current || !parentEl)
14294
+ return;
14295
+ const bannerHeight = bannerRef.current.offsetHeight;
14296
+ parentEl.style.height = `calc(100vh - ${bannerHeight}px)`;
14297
+ }
14298
+ // Save previous height to restore on unmount
14299
+ prevParentHeight.current = parentEl.style.height;
14300
+ updateParentHeight();
14301
+ // Listen for resize
14302
+ const resizeObserver = new window.ResizeObserver(updateParentHeight);
14303
+ if (bannerRef.current) {
14304
+ resizeObserver.observe(bannerRef.current);
14305
+ }
14306
+ window.addEventListener("resize", updateParentHeight);
14307
+ return () => {
14308
+ if (resizeObserver && bannerRef.current) {
14309
+ resizeObserver.unobserve(bannerRef.current);
14310
+ }
14311
+ window.removeEventListener("resize", updateParentHeight);
14312
+ // Restore previous height
14313
+ if (parentElRef.current && prevParentHeight.current !== null) {
14314
+ parentElRef.current.style.height = prevParentHeight.current;
14315
+ }
14316
+ };
14317
+ }, [parentContainerSelector, visible]);
14318
+ return {
14319
+ visible,
14320
+ setVisible,
14321
+ showTooltip,
14322
+ setShowTooltip,
14323
+ bannerRef,
14324
+ parentElRef,
14325
+ isLoading,
14326
+ setLoading,
14327
+ };
14328
+ };
14329
+
14330
+ function TopBanner({ parentContainerSelector, bannerText = "", loading = false, tooltipText = "", buttonLabel = "", buttonHandler = () => { }, onLoad = () => { }, onClose = () => { }, }) {
14331
+ const { visible, setVisible, showTooltip, setShowTooltip, bannerRef, isLoading, } = useTopBanner({
14332
+ parentContainerSelector,
14333
+ loading,
14334
+ onLoad,
14335
+ onClose,
14336
+ });
14337
+ if (!visible)
14338
+ return null;
14339
+ return (jsxs("div", { ref: bannerRef, id: "top-banner-component", className: "relative z-50 flex min-h-[48px] w-full items-center justify-center bg-gradient-to-r from-blue-700 to-blue-400 px-2 py-2 text-sm text-white", children: [jsxs("div", { className: "xs:max-w-[500px] mx-auto flex w-full items-center justify-center gap-2 pr-2 text-center md:pr-12", children: [jsxs("div", { className: "relative flex flex-shrink-0 items-center", onMouseEnter: () => setShowTooltip(true), onMouseLeave: () => setShowTooltip(false), children: [jsxs("svg", { className: "h-5 w-5 cursor-pointer text-white opacity-80", fill: "none", stroke: "currentColor", strokeWidth: "2", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: [jsx("circle", { cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "2" }), jsx("path", { d: "M12 16v-4", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }), jsx("circle", { cx: "12", cy: "8.5", r: "1", fill: "currentColor" })] }), showTooltip && (jsx("div", { className: "absolute top-full left-1/2 z-50 mt-2 -translate-x-1/2 rounded bg-gray-900 px-3 py-1 text-xs whitespace-nowrap text-white shadow-lg", children: tooltipText }))] }), jsx("span", { className: "ml-2 max-w-[250px] font-medium break-words text-white sm:max-w-none", children: bannerText }), buttonLabel && (jsxs(Fragment, { children: [jsx("button", { className: "ml-4 block flex-shrink-0 rounded-full border border-white/70 bg-transparent px-2 py-1 text-sm font-medium whitespace-nowrap text-white transition hover:bg-white/10 sm:hidden", "aria-label": "Upgrade", onClick: isLoading ? () => { } : () => buttonHandler(), disabled: isLoading, style: {
14340
+ position: "relative",
14341
+ minWidth: "40px",
14342
+ minHeight: "32px",
14343
+ }, children: loading ? (jsx("span", { className: "mx-auto flex h-5 w-5 items-center justify-center", children: jsxs("svg", { className: "animate-spin", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsx("circle", { cx: "12", cy: "12", r: "10", stroke: "white", strokeWidth: "4", opacity: "0.2" }), jsx("path", { d: "M12 2a10 10 0 0 1 10 10", stroke: "white", strokeWidth: "4", strokeLinecap: "round" })] }) })) : (jsx("svg", { className: "h-5 w-5", fill: "none", stroke: "currentColor", strokeWidth: "2", viewBox: "0 0 24 24", children: jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M5 12h14M12 5l7 7-7 7" }) })) }), jsx("button", { className: "ml-4 hidden flex-shrink-0 rounded-full border border-white/70 bg-transparent px-4 py-1 text-sm font-medium whitespace-nowrap text-white transition hover:bg-white/10 sm:block", onClick: isLoading ? () => { } : () => buttonHandler(), disabled: isLoading, style: {
14344
+ position: "relative",
14345
+ minWidth: "80px",
14346
+ minHeight: "32px",
14347
+ }, children: loading ? (jsx("span", { className: "mx-auto flex h-5 w-5 items-center justify-center", children: jsxs("svg", { className: "animate-spin", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsx("circle", { cx: "12", cy: "12", r: "10", stroke: "white", strokeWidth: "4", opacity: "0.2" }), jsx("path", { d: "M12 2a10 10 0 0 1 10 10", stroke: "white", strokeWidth: "4", strokeLinecap: "round" })] }) })) : ("Upgrade") })] }))] }), jsx("button", { className: "absolute top-1/2 right-0 rounded-full p-1 transition hover:bg-white/20 md:right-4", "aria-label": "Close banner", onClick: () => {
14348
+ setVisible(false);
14349
+ onClose();
14350
+ }, style: { transform: "translateY(-50%)" }, children: jsx("svg", { className: "h-5 w-5 text-white", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: "2", children: jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" }) }) }), jsx("style", { children: `
14351
+ @keyframes spin {
14352
+ from { transform: rotate(0deg); }
14353
+ to { transform: rotate(360deg); }
14354
+ }
14355
+ .animate-spin {
14356
+ animation: spin 1s linear infinite;
14357
+ }
14358
+ ` })] }));
14198
14359
  }
14199
14360
 
14200
- export { InviteUserDialog, InvitedUsersDialog, Profile, useIframeMessageHandler };
14361
+ export { InviteUserDialog, InvitedUsersDialog, Profile, TopBanner, useIframeMessageHandler };
14201
14362
  //# sourceMappingURL=index.esm.js.map