@mw-kit/mw-ui 1.10.7 → 1.10.8

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.
@@ -1,3 +1,3 @@
1
1
  import type { PopupPosition, PopupProps } from '../../types';
2
- declare const useFallbackPlacements: (props: PopupProps) => PopupPosition[];
2
+ declare const useFallbackPlacements: (props: Omit<PopupProps, "enabled">) => PopupPosition[];
3
3
  export default useFallbackPlacements;
@@ -1,3 +1,3 @@
1
1
  import type { PopupProps } from '../../types';
2
- declare const useOpen: (props: PopupProps) => readonly [boolean | undefined, (nextOpen: boolean) => void];
2
+ declare const useOpen: (props: Omit<PopupProps, "enabled">) => readonly [boolean | undefined, (nextOpen: boolean) => void];
3
3
  export default useOpen;
@@ -1,6 +1,4 @@
1
1
  import React from 'react';
2
2
  import type { PopupProps } from './types';
3
- declare const Popup: <T extends React.ElementType = "div">(props: PopupProps<T> & {
4
- enabled?: boolean;
5
- }) => JSX.Element;
3
+ declare const Popup: <T extends React.ElementType = "div", P = {}>(props: PopupProps<T, P>) => JSX.Element;
6
4
  export default Popup;
@@ -1,6 +1,12 @@
1
1
  import type { FloatingPortalProps, OffsetOptions } from '@floating-ui/react';
2
- export type PopupProps<T extends React.ElementType = 'div'> = {
3
- content: React.FunctionComponent;
2
+ type RequiredKeys<T> = {
3
+ [K in keyof T]-?: {} extends Pick<T, K> ? never : K;
4
+ }[keyof T];
5
+ export type PopupContentProps<P = {}> = {
6
+ closePopup: () => void;
7
+ } & P;
8
+ export type PopupProps<T extends React.ElementType = 'div', P = {}> = {
9
+ content: React.FunctionComponent<PopupContentProps<P>>;
4
10
  position: PopupPosition;
5
11
  on?: 'hover' | 'click';
6
12
  triggerType?: T;
@@ -19,5 +25,11 @@ export type PopupProps<T extends React.ElementType = 'div'> = {
19
25
  style?: React.CSSProperties | undefined;
20
26
  dependencies?: React.DependencyList;
21
27
  pinned?: boolean;
22
- };
28
+ enabled?: boolean;
29
+ } & (RequiredKeys<P> extends never ? {
30
+ contentProps?: P;
31
+ } : {
32
+ contentProps: P;
33
+ });
23
34
  export type PopupPosition = 'top' | 'top-start' | 'top-end' | 'right' | 'right-start' | 'right-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end';
35
+ export {};
package/dist/index.d.mts CHANGED
@@ -265,8 +265,14 @@ type AbsoluteContainerProps = CommonProps$4 & {
265
265
  transition?: Partial<Omit<TransitionArguments, 'active'>>;
266
266
  };
267
267
 
268
- type PopupProps<T extends React.ElementType = 'div'> = {
269
- content: React.FunctionComponent;
268
+ type RequiredKeys<T> = {
269
+ [K in keyof T]-?: {} extends Pick<T, K> ? never : K;
270
+ }[keyof T];
271
+ type PopupContentProps<P = {}> = {
272
+ closePopup: () => void;
273
+ } & P;
274
+ type PopupProps<T extends React.ElementType = 'div', P = {}> = {
275
+ content: React.FunctionComponent<PopupContentProps<P>>;
270
276
  position: PopupPosition;
271
277
  on?: 'hover' | 'click';
272
278
  triggerType?: T;
@@ -285,7 +291,12 @@ type PopupProps<T extends React.ElementType = 'div'> = {
285
291
  style?: React.CSSProperties | undefined;
286
292
  dependencies?: React.DependencyList;
287
293
  pinned?: boolean;
288
- };
294
+ enabled?: boolean;
295
+ } & (RequiredKeys<P> extends never ? {
296
+ contentProps?: P;
297
+ } : {
298
+ contentProps: P;
299
+ });
289
300
  type PopupPosition = 'top' | 'top-start' | 'top-end' | 'right' | 'right-start' | 'right-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end';
290
301
 
291
302
  interface LoaderProps extends Omit<react__default.HTMLAttributes<HTMLDivElement>, 'color'> {
@@ -3993,9 +4004,7 @@ interface PlaceholderProps {
3993
4004
 
3994
4005
  declare const Placeholder: (props: PlaceholderProps) => react_jsx_runtime.JSX.Element;
3995
4006
 
3996
- declare const Popup: <T extends react__default.ElementType = "div">(props: PopupProps<T> & {
3997
- enabled?: boolean;
3998
- }) => JSX.Element;
4007
+ declare const Popup: <T extends react__default.ElementType = "div", P = {}>(props: PopupProps<T, P>) => JSX.Element;
3999
4008
 
4000
4009
  interface ProgressBarProps {
4001
4010
  type: 'default' | 'info' | 'danger' | 'success' | 'warning';
package/dist/index.js CHANGED
@@ -10010,6 +10010,7 @@ var defaultDependencies = [];
10010
10010
  var PopupComponent = (props) => {
10011
10011
  const {
10012
10012
  content: Content5,
10013
+ contentProps = {},
10013
10014
  renderTrigger,
10014
10015
  triggerProps,
10015
10016
  on = "hover",
@@ -10095,16 +10096,13 @@ var PopupComponent = (props) => {
10095
10096
  $placement: floating.placement
10096
10097
  }
10097
10098
  ) : null,
10098
- /* @__PURE__ */ (0, import_jsx_runtime294.jsx)(Content5, {})
10099
+ /* @__PURE__ */ (0, import_jsx_runtime294.jsx)(Content5, { closePopup: () => setOpen(false), ...contentProps })
10099
10100
  ]
10100
10101
  }
10101
10102
  ) }) : null
10102
10103
  ] });
10103
10104
  };
10104
- var Popup = ({
10105
- enabled,
10106
- ...props
10107
- }) => {
10105
+ var Popup = ({ enabled, ...props }) => {
10108
10106
  return enabled !== false ? /* @__PURE__ */ (0, import_jsx_runtime294.jsx)(PopupComponent, { ...props }) : props.renderTrigger(props.triggerProps || {});
10109
10107
  };
10110
10108
  var Popup_default = Popup;
package/dist/index.mjs CHANGED
@@ -9962,6 +9962,7 @@ var defaultDependencies = [];
9962
9962
  var PopupComponent = (props) => {
9963
9963
  const {
9964
9964
  content: Content5,
9965
+ contentProps = {},
9965
9966
  renderTrigger,
9966
9967
  triggerProps,
9967
9968
  on = "hover",
@@ -10047,16 +10048,13 @@ var PopupComponent = (props) => {
10047
10048
  $placement: floating.placement
10048
10049
  }
10049
10050
  ) : null,
10050
- /* @__PURE__ */ jsx294(Content5, {})
10051
+ /* @__PURE__ */ jsx294(Content5, { closePopup: () => setOpen(false), ...contentProps })
10051
10052
  ]
10052
10053
  }
10053
10054
  ) }) : null
10054
10055
  ] });
10055
10056
  };
10056
- var Popup = ({
10057
- enabled,
10058
- ...props
10059
- }) => {
10057
+ var Popup = ({ enabled, ...props }) => {
10060
10058
  return enabled !== false ? /* @__PURE__ */ jsx294(PopupComponent, { ...props }) : props.renderTrigger(props.triggerProps || {});
10061
10059
  };
10062
10060
  var Popup_default = Popup;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mw-kit/mw-ui",
3
- "version": "1.10.7",
3
+ "version": "1.10.8",
4
4
  "description": "Made with create-react-library",
5
5
  "author": "fmgusmao",
6
6
  "license": "MIT",