@revisium/schema-toolkit-ui 0.3.1 → 0.3.3

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/index.cjs CHANGED
@@ -2546,7 +2546,7 @@ function useContentEditable(options) {
2546
2546
  const { value, autoFocus, focusTrigger } = options;
2547
2547
  const elementRef = (0, react.useRef)(null);
2548
2548
  const cursorPosition = (0, react.useRef)(null);
2549
- const isFirstRender = (0, react.useRef)(true);
2549
+ const prevFocusTriggerRef = (0, react.useRef)(focusTrigger);
2550
2550
  const optionsRef = (0, react.useRef)(options);
2551
2551
  optionsRef.current = options;
2552
2552
  const ref = (0, react.useCallback)((node) => {
@@ -2571,10 +2571,8 @@ function useContentEditable(options) {
2571
2571
  }
2572
2572
  });
2573
2573
  (0, react.useEffect)(() => {
2574
- if (isFirstRender.current) {
2575
- isFirstRender.current = false;
2576
- return;
2577
- }
2574
+ if (prevFocusTriggerRef.current === focusTrigger) return;
2575
+ prevFocusTriggerRef.current = focusTrigger;
2578
2576
  elementRef.current?.focus();
2579
2577
  const selection = globalThis.getSelection();
2580
2578
  if (elementRef.current && selection) {
@@ -5785,37 +5783,32 @@ const NumberRendererComponent = (0, mobx_react_lite.observer)(({ node }) => {
5785
5783
  //#endregion
5786
5784
  //#region src/row-editor/ui/editors/FocusPopover.tsx
5787
5785
  const FocusPopover = ({ isOpen, setIsOpen, trigger, children, disabled, width }) => {
5788
- const triggerRef = (0, react.useRef)(null);
5789
- const lastRectRef = (0, react.useRef)(null);
5790
- const getAnchorRect = (0, react.useCallback)(() => {
5791
- const rect = triggerRef.current?.getBoundingClientRect();
5792
- if (rect && rect.width > 0) lastRectRef.current = rect;
5793
- return lastRectRef.current;
5794
- }, []);
5795
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Box, {
5796
- ref: triggerRef,
5797
- onPointerDown: (0, react.useCallback)(() => {
5798
- if (!disabled) setIsOpen(true);
5799
- }, [disabled, setIsOpen]),
5800
- children: trigger
5801
- }), !disabled && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Popover.Root, {
5786
+ const handleClick = (0, react.useCallback)(() => {
5787
+ if (!disabled) setIsOpen(true);
5788
+ }, [disabled, setIsOpen]);
5789
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_chakra_ui_react.Popover.Root, {
5802
5790
  lazyMount: true,
5803
5791
  unmountOnExit: true,
5804
5792
  open: isOpen,
5805
- onOpenChange: ({ open }) => setIsOpen(open),
5793
+ onOpenChange: ({ open }) => {
5794
+ if (!disabled) setIsOpen(open);
5795
+ },
5806
5796
  autoFocus: false,
5807
- closeOnInteractOutside: true,
5797
+ closeOnInteractOutside: !disabled,
5808
5798
  modal: false,
5809
- positioning: {
5810
- placement: "bottom-start",
5811
- getAnchorRect
5812
- },
5813
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Portal, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Popover.Positioner, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Popover.Content, {
5799
+ positioning: { placement: "bottom-start" },
5800
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Popover.Trigger, {
5801
+ asChild: true,
5802
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Box, {
5803
+ onClick: handleClick,
5804
+ children: trigger
5805
+ })
5806
+ }), !disabled && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Portal, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Popover.Positioner, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_chakra_ui_react.Popover.Content, {
5814
5807
  width,
5815
5808
  p: 1,
5816
5809
  children
5817
- }) }) })
5818
- })] });
5810
+ }) }) })]
5811
+ });
5819
5812
  };
5820
5813
 
5821
5814
  //#endregion