react-better-html 1.1.197 → 1.1.198

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.mjs CHANGED
@@ -5827,7 +5827,7 @@ var DropdownComponent = forwardRef10(function Dropdown({
5827
5827
  filter: isFocused2 ? isDisabled ? "brightness(0.95)" : "brightness(0.9)" : void 0,
5828
5828
  filterHover: focusedOptionIndex === void 0 && !isDisabled ? "brightness(0.9)" : void 0,
5829
5829
  cursor: isDisabled ? "not-allowed" : "pointer",
5830
- padding: `${theme2.styles.space / 2}px ${theme2.styles.space + theme2.styles.gap}px`,
5830
+ padding: `${theme2.styles.gap}px ${theme2.styles.space}px`,
5831
5831
  value: option,
5832
5832
  onClickWithValue: onClickOption,
5833
5833
  onMouseMove: () => setFocusedOptionIndex(void 0),
@@ -6743,6 +6743,13 @@ InputFieldComponent.phoneNumber = forwardRef11(function PhoneNumber({ label, val
6743
6743
  ] }),
6744
6744
  []
6745
6745
  );
6746
+ const onChangeDropdown = useCallback9(
6747
+ (value2) => {
6748
+ setDropdownValue(value2);
6749
+ onChangeValue?.(value2 ? `+${value2}${inputFieldValue}` : inputFieldValue);
6750
+ },
6751
+ [onChangeValue, inputFieldValue]
6752
+ );
6746
6753
  const onChangeValueElement = useCallback9(
6747
6754
  (value2) => {
6748
6755
  const readyValue = value2.replace(/\D/g, "");
@@ -6807,7 +6814,7 @@ InputFieldComponent.phoneNumber = forwardRef11(function PhoneNumber({ label, val
6807
6814
  defaultValue,
6808
6815
  value: dropdownValue,
6809
6816
  disabled: props.disabled,
6810
- onChange: setDropdownValue,
6817
+ onChange: onChangeDropdown,
6811
6818
  withoutClearButton: true,
6812
6819
  withoutRenderingOptionsWhenClosed: true
6813
6820
  }
@@ -8679,11 +8686,11 @@ var tooltipPositionStyle = (props) => ({
8679
8686
  }
8680
8687
  });
8681
8688
  var TooltipContainer = styled13.div.withConfig({
8682
- shouldForwardProp: (prop) => !["theme", "position", "align", "withArrow", "arrowSize", "isOpen", "gap"].includes(prop)
8689
+ shouldForwardProp: (prop) => !["theme", "position", "align", "pointerEvents", "withArrow", "arrowSize", "isOpen", "gap"].includes(prop)
8683
8690
  })`
8684
8691
  position: absolute;
8685
8692
  opacity: ${(props) => props.isOpen ? 1 : 0};
8686
- pointer-events: ${(props) => props.isOpen ? "auto" : "none"};
8693
+ pointer-events: ${(props) => props.isOpen ? props.pointerEvents : "none"};
8687
8694
  transition: ${(props) => props.theme.styles.transition};
8688
8695
  z-index: 1000;
8689
8696
 
@@ -8766,8 +8773,10 @@ var TooltipComponent = forwardRef16(function Tooltip({
8766
8773
  content,
8767
8774
  contentWidth,
8768
8775
  contentMinWidth,
8776
+ contentPointerEvents = "auto",
8769
8777
  childrenWrapperWidth = "fit-content",
8770
8778
  childrenWrapperHeight,
8779
+ disabled,
8771
8780
  withArrow,
8772
8781
  isSmall,
8773
8782
  backgroundColor,
@@ -8789,6 +8798,7 @@ var TooltipComponent = forwardRef16(function Tooltip({
8789
8798
  const outsideScreenGap = theme2.styles.gap / 2;
8790
8799
  const totalGap = arrowSize + gap;
8791
8800
  const openTooltip = useCallback13(() => {
8801
+ if (disabled) return;
8792
8802
  if (closeTimerRef.current) clearTimeout(closeTimerRef.current);
8793
8803
  setIsOpen(true);
8794
8804
  setIsOpenLate(true);
@@ -8811,7 +8821,7 @@ var TooltipComponent = forwardRef16(function Tooltip({
8811
8821
  }
8812
8822
  }, 1);
8813
8823
  onOpen?.();
8814
- }, [onOpen, outsideScreenGap, totalGap]);
8824
+ }, [disabled, onOpen, outsideScreenGap, totalGap]);
8815
8825
  const closeTooltip = useCallback13(() => {
8816
8826
  setIsOpen(false);
8817
8827
  closeTimerRef.current = setTimeout(() => setIsOpenLate(false), 300);
@@ -8887,6 +8897,7 @@ var TooltipComponent = forwardRef16(function Tooltip({
8887
8897
  theme: theme2,
8888
8898
  position,
8889
8899
  align,
8900
+ pointerEvents: contentPointerEvents,
8890
8901
  withArrow,
8891
8902
  arrowSize,
8892
8903
  gap,
@@ -9367,14 +9378,20 @@ var MenuItemComponent = memo27(function MenuItemComponent2({ item, backgroundCol
9367
9378
  const theme2 = useTheme();
9368
9379
  const mediaQuery = useMediaQuery();
9369
9380
  const location = reactRouterDomPluginConfig.useLocation();
9370
- const { colorTheme, components, sideMenuIsCollapsed } = useBetterHtmlContextInternal();
9381
+ const { colorTheme, components, sideMenuIsCollapsed, setSideMenuIsCollapsed } = useBetterHtmlContextInternal();
9371
9382
  const [isOpened, setIsOpened] = useBooleanState();
9383
+ const isCollapsed = sideMenuIsCollapsed && !mediaQuery.size1000;
9372
9384
  const onClickElement = useCallback16(() => {
9373
9385
  if (item.disabled) return;
9374
- if (item.onClickCloseSideMenu !== false) onClick?.();
9375
- item.onClick?.(item);
9376
- }, [onClick, item]);
9377
- const isCollapsed = sideMenuIsCollapsed && !mediaQuery.size1000;
9386
+ if (item.children) {
9387
+ setSideMenuIsCollapsed.setFalse();
9388
+ if (isCollapsed) setTimeout(setIsOpened.setTrue, 0.1 * 1e3);
9389
+ else setIsOpened.toggle();
9390
+ } else {
9391
+ if (item.onClickCloseSideMenu !== false) onClick?.();
9392
+ item.onClick?.(item);
9393
+ }
9394
+ }, [onClick, item, isCollapsed]);
9378
9395
  const isActive = item.href ? location.pathname === "/" ? location.pathname === item.href : location.pathname.startsWith(item.href) && item.href !== "/" : false;
9379
9396
  const readyBackgroundColor = backgroundColor ?? theme2.colors.backgroundContent;
9380
9397
  const iconSize = 16;
@@ -9384,46 +9401,57 @@ var MenuItemComponent = memo27(function MenuItemComponent2({ item, backgroundCol
9384
9401
  const lineHeight = 20;
9385
9402
  const lineWidth = 2;
9386
9403
  const lineEndRadius = iconSize / 2 + iconGap * 2;
9387
- const content = /* @__PURE__ */ jsxs23(
9388
- Div_default.row,
9404
+ const content = /* @__PURE__ */ jsx27(
9405
+ Tooltip_default,
9389
9406
  {
9390
- alignItems: "center",
9391
- gap: iconGap,
9392
- whiteSpace: "nowrap",
9393
- backgroundColor: isActive ? colorTheme === "dark" ? lightenColor(theme2.colors.primary, 0.7) : lightenColor(theme2.colors.primary, 0.85) : readyBackgroundColor,
9394
- borderRadius: theme2.styles.borderRadius,
9395
- paddingBlock,
9396
- paddingLeft: isCollapsed ? theme2.styles.space : paddingLeft,
9397
- paddingRight: theme2.styles.space,
9398
- filterHover: `brightness(${colorTheme === "dark" ? isActive ? 0.8 : 1.3 : isActive ? 0.8 : 0.95})`,
9399
- overflow: isCollapsed ? "hidden" : void 0,
9400
- cursor: item.disabled ? "not-allowed" : "pointer",
9401
- opacity: item.disabled ? 0.6 : void 0,
9402
- onClick: item.children ? setIsOpened.toggle : onClickElement,
9403
- children: [
9404
- /* @__PURE__ */ jsx27(Icon_default, { name: item.iconName, color: theme2.colors.primary, size: iconSize, flexShrink: 0 }),
9405
- /* @__PURE__ */ jsx27(
9406
- Text_default,
9407
- {
9408
- flex: 1,
9409
- lineHeight: `${lineHeight}px`,
9410
- color: isActive ? theme2.colors.primary : theme2.colors.textPrimary,
9411
- opacity: isCollapsed ? 0 : void 0,
9412
- transition: theme2.styles.transition,
9413
- children: item.text
9414
- }
9415
- ),
9416
- item.children && /* @__PURE__ */ jsx27(
9417
- Icon_default,
9418
- {
9419
- name: "chevronDown",
9420
- color: theme2.colors.textSecondary,
9421
- size: 14,
9422
- transform: isOpened ? "rotate(180deg)" : void 0,
9423
- transition: theme2.styles.transition
9424
- }
9425
- )
9426
- ]
9407
+ content: /* @__PURE__ */ jsx27(Text_default, { whiteSpace: "nowrap", children: item.text }),
9408
+ contentPointerEvents: "none",
9409
+ withArrow: true,
9410
+ childrenWrapperWidth: "100%",
9411
+ disabled: !isCollapsed,
9412
+ position: "right",
9413
+ children: /* @__PURE__ */ jsxs23(
9414
+ Div_default.row,
9415
+ {
9416
+ alignItems: "center",
9417
+ gap: iconGap,
9418
+ whiteSpace: "nowrap",
9419
+ backgroundColor: isActive ? colorTheme === "dark" ? lightenColor(theme2.colors.primary, 0.7) : lightenColor(theme2.colors.primary, 0.85) : readyBackgroundColor,
9420
+ borderRadius: theme2.styles.borderRadius,
9421
+ paddingBlock,
9422
+ paddingLeft: isCollapsed ? theme2.styles.space : paddingLeft,
9423
+ paddingRight: theme2.styles.space,
9424
+ filterHover: `brightness(${colorTheme === "dark" ? isActive ? 0.8 : 1.3 : isActive ? 0.8 : 0.95})`,
9425
+ overflow: isCollapsed ? "hidden" : void 0,
9426
+ cursor: item.disabled ? "not-allowed" : "pointer",
9427
+ opacity: item.disabled ? 0.6 : void 0,
9428
+ onClick: onClickElement,
9429
+ children: [
9430
+ /* @__PURE__ */ jsx27(Icon_default, { name: item.iconName, color: theme2.colors.primary, size: iconSize, flexShrink: 0 }),
9431
+ /* @__PURE__ */ jsx27(
9432
+ Text_default,
9433
+ {
9434
+ flex: 1,
9435
+ lineHeight: `${lineHeight}px`,
9436
+ color: isActive ? theme2.colors.primary : theme2.colors.textPrimary,
9437
+ opacity: isCollapsed ? 0 : void 0,
9438
+ transition: theme2.styles.transition,
9439
+ children: item.text
9440
+ }
9441
+ ),
9442
+ item.children && /* @__PURE__ */ jsx27(
9443
+ Icon_default,
9444
+ {
9445
+ name: "chevronDown",
9446
+ color: theme2.colors.textSecondary,
9447
+ size: 14,
9448
+ transform: isOpened ? "rotate(180deg)" : void 0,
9449
+ transition: theme2.styles.transition
9450
+ }
9451
+ )
9452
+ ]
9453
+ }
9454
+ )
9427
9455
  }
9428
9456
  );
9429
9457
  useEffect15(() => {
@@ -9591,7 +9619,7 @@ var SideMenuComponent = function SideMenu({
9591
9619
  {
9592
9620
  width: "100%",
9593
9621
  height: "100%",
9594
- overflowY: "auto",
9622
+ overflowY: !isCollapsed ? "auto" : void 0,
9595
9623
  paddingInline: theme2.styles.space,
9596
9624
  paddingBottom: !isCollapsable && !readyBottomItems ? theme2.styles.space : void 0,
9597
9625
  children: /* @__PURE__ */ jsx27(Div_default.column, { gap: theme2.styles.gap / 2, children: readyItems.map((item) => /* @__PURE__ */ jsx27(