x-ui-design 0.7.78 → 0.7.80

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.
@@ -2,7 +2,7 @@ import { ReactElement } from 'react';
2
2
  import { CheckboxProps } from '../../types/checkbox';
3
3
  import './style.css';
4
4
  declare const Checkbox: {
5
- ({ prefixCls, prefixClsV3, className, defaultChecked, checked, style, disabled, onChange, onClick, onMouseEnter, onMouseLeave, onKeyPress, onKeyDown, tabIndex, name, children, id, autoFocus, type, value, required, noStyle, titleClick, ref }: CheckboxProps): ReactElement;
5
+ ({ prefixCls, prefixClsV3, className, defaultChecked, checked, style, disabled, onChange, onClick, onMouseEnter, onMouseLeave, onKeyPress, onKeyDown, tabIndex, name, children, id, autoFocus, type, value, required, noStyle, titleClick, ref, controlled }: CheckboxProps): ReactElement;
6
6
  displayName: string;
7
7
  };
8
8
  export default Checkbox;
@@ -1,4 +1,4 @@
1
- import React, { FC, ReactNode, MouseEvent } from "react";
1
+ import React, { FC, MouseEvent } from "react";
2
2
  import { MenuMode, MenuProps } from "../../types/menu";
3
3
  import MenuItem from "./Item/Item";
4
4
  import SubMenu from "./SubMenu/SubMenu";
@@ -13,14 +13,8 @@ export declare const MenuContext: React.Context<{
13
13
  onItemClick: (key: string, domEvent?: MouseEvent) => void;
14
14
  triggerSubMenuAction?: "hover" | "click";
15
15
  } | null>;
16
- declare const ItemGroup: FC<{
17
- title?: ReactNode;
18
- children?: ReactNode;
19
- prefixCls?: string;
20
- }>;
21
16
  declare const Menu: FC<MenuProps> & {
22
17
  Item: typeof MenuItem;
23
18
  SubMenu: typeof SubMenu;
24
- ItemGroup: typeof ItemGroup;
25
19
  };
26
20
  export default Menu;
@@ -21,4 +21,5 @@ export type CheckboxProps = DefaultProps & {
21
21
  checked?: boolean;
22
22
  titleClick?: boolean;
23
23
  ref?: ForwardedRef<HTMLDivElement>;
24
+ controlled?: boolean;
24
25
  };
package/dist/index.esm.js CHANGED
@@ -1576,21 +1576,32 @@ const Checkbox = ({
1576
1576
  required = false,
1577
1577
  noStyle,
1578
1578
  titleClick,
1579
- ref
1579
+ ref,
1580
+ controlled = false
1580
1581
  }) => {
1581
1582
  const isChecked = checked !== undefined ? checked : defaultChecked || value;
1582
1583
  const [internalChecked, setInternalChecked] = useState(isChecked);
1584
+ const checkboxRef = useRef(null);
1583
1585
  const handleClick = e => {
1584
1586
  if (disabled) {
1585
1587
  e.stopPropagation();
1586
1588
  return;
1587
1589
  }
1588
- setInternalChecked(!internalChecked);
1589
- e.target.value = !internalChecked;
1590
+ if (checkboxRef.current) {
1591
+ if (!controlled) {
1592
+ e.target.value = !internalChecked;
1593
+ setInternalChecked(!internalChecked);
1594
+ checkboxRef.current.checked = !internalChecked;
1595
+ } else {
1596
+ e.target.value = !checked;
1597
+ checkboxRef.current.checked = !checked;
1598
+ }
1599
+ }
1590
1600
  onClick?.(e);
1591
1601
  onChange?.(e);
1592
1602
  };
1593
1603
  useEffect(() => {
1604
+ console.log(checked);
1594
1605
  if (checked !== undefined) {
1595
1606
  setInternalChecked(checked);
1596
1607
  }
@@ -1610,6 +1621,7 @@ const Checkbox = ({
1610
1621
  id: id,
1611
1622
  type: type,
1612
1623
  name: name,
1624
+ ref: checkboxRef,
1613
1625
  disabled: disabled,
1614
1626
  tabIndex: tabIndex,
1615
1627
  required: required,
@@ -4522,19 +4534,6 @@ var css_248z = ".xUi-menu{box-shadow:0 0 4px rgba(0,0,0,.15);font-size:14px;user
4522
4534
  styleInject(css_248z);
4523
4535
 
4524
4536
  const MenuContext = /*#__PURE__*/createContext(null);
4525
- const ItemGroup = ({
4526
- title,
4527
- children,
4528
- prefixCls = prefixClsMenu
4529
- }) => {
4530
- return /*#__PURE__*/React.createElement("li", {
4531
- className: `${prefixCls}-group`
4532
- }, title && /*#__PURE__*/React.createElement("div", {
4533
- className: `${prefixCls}-group-title`
4534
- }, title), /*#__PURE__*/React.createElement("ul", {
4535
- className: `${prefixCls}-group-list`
4536
- }, children));
4537
- };
4538
4537
  const Menu = ({
4539
4538
  prefixCls = prefixClsMenu,
4540
4539
  className = "",
@@ -4700,7 +4699,6 @@ const Menu = ({
4700
4699
  };
4701
4700
  Menu.Item = MenuItem;
4702
4701
  Menu.SubMenu = SubMenu;
4703
- Menu.ItemGroup = ItemGroup;
4704
4702
 
4705
4703
  var Menu$1 = /*#__PURE__*/Object.freeze({
4706
4704
  __proto__: null,