fanyucomponents
Advanced tools
@@ -16,3 +16,3 @@ import { jsx as _jsx } from "react/jsx-runtime"; | ||
| return null; | ||
| const { direction = "vertical", mainAlign = "center", crossAlign = "center", stopPropagation = true, children, style, ...rest } = props; | ||
| const { direction = "vertical", mainAlign = "center", crossAlign = "center", stopPropagation = true, children, style, clickOutsideToClose = true, onClick, ...rest } = props; | ||
| const Component = (_jsx(StateStylesComponent, { as: "div", style: { | ||
@@ -30,3 +30,8 @@ zIndex: 6987, | ||
| ...style, | ||
| }, onClick: Close, ...rest, children: stopPropagation | ||
| }, onClick: (...args) => { | ||
| if (clickOutsideToClose) | ||
| Close(); | ||
| if (onClick) | ||
| onClick(...args); | ||
| }, ...rest, children: stopPropagation | ||
| ? React.Children.map(children, (child) => React.isValidElement(child) | ||
@@ -33,0 +38,0 @@ ? React.cloneElement(child, { |
@@ -9,4 +9,5 @@ import { AsComponentProps, flexAlignProps, IconProps, OverrideProps, StateStylesProps } from "./UtilProps"; | ||
| }; | ||
| export type ModalContainerProps = OverrideProps<Omit<StateStylesComponentProps<"div">, "onClick">, flexAlignProps & { | ||
| export type ModalContainerProps = OverrideProps<StateStylesComponentProps<"div">, flexAlignProps & { | ||
| stopPropagation?: boolean; | ||
| clickOutsideToClose?: boolean; | ||
| }>; | ||
@@ -13,0 +14,0 @@ export type DownloadButtonProps = OverrideProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, { |
+1
-1
| { | ||
| "$schema": "https://json.schemastore.org/package.json", | ||
| "name": "fanyucomponents", | ||
| "version": "2.10.15", | ||
| "version": "2.10.16", | ||
| "description": "一款以 純邏輯為核心、無樣式綁定 的 React 元件套件", | ||
@@ -6,0 +6,0 @@ "main": "dist/index.js", |
@@ -29,2 +29,4 @@ import React, { useState } from "react"; | ||
| style, | ||
| clickOutsideToClose = true, | ||
| onClick, | ||
| ...rest | ||
@@ -50,3 +52,6 @@ } = props; | ||
| }} | ||
| onClick={Close} | ||
| onClick={(...args) => { | ||
| if (clickOutsideToClose) Close(); | ||
| if (onClick) onClick(...args); | ||
| }} | ||
| {...rest} | ||
@@ -53,0 +58,0 @@ > |
@@ -21,5 +21,6 @@ import { | ||
| export type ModalContainerProps = OverrideProps< | ||
| Omit<StateStylesComponentProps<"div">, "onClick">, | ||
| StateStylesComponentProps<"div">, | ||
| flexAlignProps & { | ||
| stopPropagation?: boolean; | ||
| clickOutsideToClose?: boolean; | ||
| } | ||
@@ -26,0 +27,0 @@ >; |
133968
0.29%1430
0.85%