@mw-kit/mw-ui 1.10.5 → 1.10.7

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,4 +1,4 @@
1
- import type { FloatingPortalProps } from '@floating-ui/react';
1
+ import type { FloatingPortalProps, OffsetOptions } from '@floating-ui/react';
2
2
  export type PopupProps<T extends React.ElementType = 'div'> = {
3
3
  content: React.FunctionComponent;
4
4
  position: PopupPosition;
@@ -6,7 +6,7 @@ export type PopupProps<T extends React.ElementType = 'div'> = {
6
6
  triggerType?: T;
7
7
  triggerProps?: React.ComponentPropsWithRef<T>;
8
8
  renderTrigger: (props: React.ComponentPropsWithRef<T>) => React.ReactNode;
9
- offset?: number;
9
+ offset?: OffsetOptions;
10
10
  shift?: number;
11
11
  background?: 'light' | 'dark';
12
12
  arrow?: 'flattened' | 'pointed' | 'none';
@@ -17,5 +17,7 @@ export type PopupProps<T extends React.ElementType = 'div'> = {
17
17
  zIndex?: number;
18
18
  portalRoot?: FloatingPortalProps['root'];
19
19
  style?: React.CSSProperties | undefined;
20
+ dependencies?: React.DependencyList;
21
+ pinned?: boolean;
20
22
  };
21
23
  export type PopupPosition = 'top' | 'top-start' | 'top-end' | 'right' | 'right-start' | 'right-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end';
package/dist/index.d.mts CHANGED
@@ -4,7 +4,7 @@ import * as react from 'react';
4
4
  import react__default, { TextareaHTMLAttributes } from 'react';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
  import * as _fortawesome_fontawesome_common_types from '@fortawesome/fontawesome-common-types';
7
- import { FloatingPortalProps } from '@floating-ui/react';
7
+ import { OffsetOptions, FloatingPortalProps } from '@floating-ui/react';
8
8
  import * as styled_components_dist_types from 'styled-components/dist/types';
9
9
  import { ReactVirtualizerOptions } from '@tanstack/react-virtual';
10
10
  import { Property } from 'csstype';
@@ -272,7 +272,7 @@ type PopupProps<T extends React.ElementType = 'div'> = {
272
272
  triggerType?: T;
273
273
  triggerProps?: React.ComponentPropsWithRef<T>;
274
274
  renderTrigger: (props: React.ComponentPropsWithRef<T>) => React.ReactNode;
275
- offset?: number;
275
+ offset?: OffsetOptions;
276
276
  shift?: number;
277
277
  background?: 'light' | 'dark';
278
278
  arrow?: 'flattened' | 'pointed' | 'none';
@@ -283,6 +283,8 @@ type PopupProps<T extends React.ElementType = 'div'> = {
283
283
  zIndex?: number;
284
284
  portalRoot?: FloatingPortalProps['root'];
285
285
  style?: React.CSSProperties | undefined;
286
+ dependencies?: React.DependencyList;
287
+ pinned?: boolean;
286
288
  };
287
289
  type PopupPosition = 'top' | 'top-start' | 'top-end' | 'right' | 'right-start' | 'right-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end';
288
290
 
package/dist/index.js CHANGED
@@ -10006,6 +10006,7 @@ var mergeRefs = (...refs) => {
10006
10006
  });
10007
10007
  };
10008
10008
  };
10009
+ var defaultDependencies = [];
10009
10010
  var PopupComponent = (props) => {
10010
10011
  const {
10011
10012
  content: Content5,
@@ -10017,35 +10018,38 @@ var PopupComponent = (props) => {
10017
10018
  shift: shiftValue = 8,
10018
10019
  background = "dark",
10019
10020
  closeOnClip = false,
10020
- zIndex = 1e3
10021
+ zIndex = 1e3,
10022
+ pinned = false,
10023
+ dependencies = defaultDependencies
10021
10024
  } = props;
10022
10025
  const arrowStyle = props.arrow || (background === "dark" ? "pointed" : "flattened");
10023
10026
  const withArrow = arrowStyle !== "none";
10024
10027
  const [open, setOpen] = open_default(props);
10025
10028
  const arrowRef = (0, import_react11.useRef)(null);
10026
10029
  const fallbackPlacements = fallbackPlacements_default(props);
10030
+ const closeOnClipMiddleware = (0, import_react11.useMemo)(
10031
+ () => ({
10032
+ name: "closeOnClip",
10033
+ fn(state) {
10034
+ if (state.middlewareData.hide?.referenceHidden) {
10035
+ setOpen(false);
10036
+ }
10037
+ return {};
10038
+ }
10039
+ }),
10040
+ dependencies
10041
+ );
10027
10042
  const floating = (0, import_react12.useFloating)({
10028
10043
  open,
10029
10044
  onOpenChange: setOpen,
10030
10045
  placement,
10031
10046
  whileElementsMounted: import_react12.autoUpdate,
10032
10047
  middleware: [
10033
- (0, import_react12.offset)(offsetValue),
10034
- (0, import_react12.flip)({ fallbackPlacements, padding: shiftValue }),
10035
- (0, import_react12.shift)({ padding: shiftValue }),
10036
- ...withArrow ? [(0, import_react12.arrow)({ element: arrowRef })] : [],
10037
- ...closeOnClip ? [
10038
- (0, import_react12.hide)(),
10039
- {
10040
- name: "closeOnClip",
10041
- fn(state) {
10042
- if (state.middlewareData.hide?.referenceHidden) {
10043
- setOpen(false);
10044
- }
10045
- return {};
10046
- }
10047
- }
10048
- ] : []
10048
+ (0, import_react12.offset)(offsetValue, dependencies),
10049
+ ...pinned ? [] : [(0, import_react12.flip)({ fallbackPlacements, padding: shiftValue }, dependencies)],
10050
+ (0, import_react12.shift)({ padding: shiftValue }, dependencies),
10051
+ ...withArrow ? [(0, import_react12.arrow)({ element: arrowRef }, dependencies)] : [],
10052
+ ...closeOnClip ? [(0, import_react12.hide)(void 0, dependencies), closeOnClipMiddleware] : []
10049
10053
  ]
10050
10054
  });
10051
10055
  const hover = (0, import_react12.useHover)(floating.context, {
package/dist/index.mjs CHANGED
@@ -9958,6 +9958,7 @@ var mergeRefs = (...refs) => {
9958
9958
  });
9959
9959
  };
9960
9960
  };
9961
+ var defaultDependencies = [];
9961
9962
  var PopupComponent = (props) => {
9962
9963
  const {
9963
9964
  content: Content5,
@@ -9969,35 +9970,38 @@ var PopupComponent = (props) => {
9969
9970
  shift: shiftValue = 8,
9970
9971
  background = "dark",
9971
9972
  closeOnClip = false,
9972
- zIndex = 1e3
9973
+ zIndex = 1e3,
9974
+ pinned = false,
9975
+ dependencies = defaultDependencies
9973
9976
  } = props;
9974
9977
  const arrowStyle = props.arrow || (background === "dark" ? "pointed" : "flattened");
9975
9978
  const withArrow = arrowStyle !== "none";
9976
9979
  const [open, setOpen] = open_default(props);
9977
9980
  const arrowRef = useRef(null);
9978
9981
  const fallbackPlacements = fallbackPlacements_default(props);
9982
+ const closeOnClipMiddleware = useMemo4(
9983
+ () => ({
9984
+ name: "closeOnClip",
9985
+ fn(state) {
9986
+ if (state.middlewareData.hide?.referenceHidden) {
9987
+ setOpen(false);
9988
+ }
9989
+ return {};
9990
+ }
9991
+ }),
9992
+ dependencies
9993
+ );
9979
9994
  const floating = useFloating({
9980
9995
  open,
9981
9996
  onOpenChange: setOpen,
9982
9997
  placement,
9983
9998
  whileElementsMounted: autoUpdate,
9984
9999
  middleware: [
9985
- offset(offsetValue),
9986
- flip({ fallbackPlacements, padding: shiftValue }),
9987
- shift({ padding: shiftValue }),
9988
- ...withArrow ? [arrow({ element: arrowRef })] : [],
9989
- ...closeOnClip ? [
9990
- hide(),
9991
- {
9992
- name: "closeOnClip",
9993
- fn(state) {
9994
- if (state.middlewareData.hide?.referenceHidden) {
9995
- setOpen(false);
9996
- }
9997
- return {};
9998
- }
9999
- }
10000
- ] : []
10000
+ offset(offsetValue, dependencies),
10001
+ ...pinned ? [] : [flip({ fallbackPlacements, padding: shiftValue }, dependencies)],
10002
+ shift({ padding: shiftValue }, dependencies),
10003
+ ...withArrow ? [arrow({ element: arrowRef }, dependencies)] : [],
10004
+ ...closeOnClip ? [hide(void 0, dependencies), closeOnClipMiddleware] : []
10001
10005
  ]
10002
10006
  });
10003
10007
  const hover = useHover(floating.context, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mw-kit/mw-ui",
3
- "version": "1.10.5",
3
+ "version": "1.10.7",
4
4
  "description": "Made with create-react-library",
5
5
  "author": "fmgusmao",
6
6
  "license": "MIT",