@mw-kit/mw-ui 1.10.7 → 1.10.9

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 {};
@@ -2,9 +2,10 @@ import type { SelectPlacement } from '../../types';
2
2
  type UseFloatingMenuParams = {
3
3
  open: boolean;
4
4
  onOpenChange: (open: boolean) => void;
5
+ minWidth: number;
5
6
  placement?: SelectPlacement;
6
7
  };
7
- declare const useFloatingMenu: ({ open, onOpenChange, placement, }: UseFloatingMenuParams) => {
8
+ declare const useFloatingMenu: ({ open, onOpenChange, minWidth, placement, }: UseFloatingMenuParams) => {
8
9
  floating: {
9
10
  placement: import("@floating-ui/utils").Placement;
10
11
  strategy: import("@floating-ui/utils").Strategy;
@@ -7,6 +7,7 @@ export type UseSelect<Props extends CommonSelectProps<unknown> = CommonSelectPro
7
7
  menuId: string;
8
8
  onClose: () => void;
9
9
  }>;
10
+ minWidth: number;
10
11
  buttonProps: SelectButtonProps;
11
12
  };
12
13
  export * from '../types';
@@ -69,6 +69,7 @@ export type CommonSelectProps<Option> = SelectButtonProps & {
69
69
  */
70
70
  estimateSize?: ReactVirtualizerOptions<Element, Element>['estimateSize'] | number;
71
71
  height?: number;
72
+ minWidth?: number;
72
73
  };
73
74
  export type SelectSingleProps<Option> = CommonSelectProps<Option> & {
74
75
  value: Option | null;
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'> {
@@ -3223,6 +3234,7 @@ type CommonSelectProps<Option> = SelectButtonProps & {
3223
3234
  */
3224
3235
  estimateSize?: ReactVirtualizerOptions<Element, Element>['estimateSize'] | number;
3225
3236
  height?: number;
3237
+ minWidth?: number;
3226
3238
  };
3227
3239
  type SelectSingleProps<Option> = CommonSelectProps<Option> & {
3228
3240
  value: Option | null;
@@ -3993,9 +4005,7 @@ interface PlaceholderProps {
3993
4005
 
3994
4006
  declare const Placeholder: (props: PlaceholderProps) => react_jsx_runtime.JSX.Element;
3995
4007
 
3996
- declare const Popup: <T extends react__default.ElementType = "div">(props: PopupProps<T> & {
3997
- enabled?: boolean;
3998
- }) => JSX.Element;
4008
+ declare const Popup: <T extends react__default.ElementType = "div", P = {}>(props: PopupProps<T, P>) => JSX.Element;
3999
4009
 
4000
4010
  interface ProgressBarProps {
4001
4011
  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;
@@ -19061,6 +19059,7 @@ var import_react71 = require("@floating-ui/react");
19061
19059
  var useFloatingMenu = ({
19062
19060
  open,
19063
19061
  onOpenChange,
19062
+ minWidth,
19064
19063
  placement = "bottom"
19065
19064
  }) => {
19066
19065
  const floating = (0, import_react71.useFloating)({
@@ -19070,13 +19069,16 @@ var useFloatingMenu = ({
19070
19069
  whileElementsMounted: import_react71.autoUpdate,
19071
19070
  middleware: [
19072
19071
  (0, import_react71.flip)(),
19073
- (0, import_react71.size)({
19074
- apply({ rects, elements }) {
19075
- Object.assign(elements.floating.style, {
19076
- minWidth: `${rects.reference.width}px`
19077
- });
19078
- }
19079
- })
19072
+ (0, import_react71.size)(
19073
+ {
19074
+ apply({ rects, elements }) {
19075
+ Object.assign(elements.floating.style, {
19076
+ minWidth: `${Math.max(rects.reference.width, minWidth)}px`
19077
+ });
19078
+ }
19079
+ },
19080
+ [minWidth]
19081
+ )
19080
19082
  ]
19081
19083
  });
19082
19084
  const transition = (0, import_react71.useTransitionStatus)(floating.context, {
@@ -20056,6 +20058,7 @@ var useMultiSelect = ({
20056
20058
  overscan,
20057
20059
  estimateSize,
20058
20060
  height,
20061
+ minWidth = 290,
20059
20062
  value,
20060
20063
  setValue,
20061
20064
  finder,
@@ -20073,6 +20076,7 @@ var useMultiSelect = ({
20073
20076
  placeholder: closedLabel,
20074
20077
  onClear: () => setValue([]),
20075
20078
  Component: SelectMultiOptions,
20079
+ minWidth,
20076
20080
  buttonProps
20077
20081
  };
20078
20082
  };
@@ -20199,6 +20203,7 @@ var useSingleSelect = ({
20199
20203
  overscan,
20200
20204
  estimateSize,
20201
20205
  height,
20206
+ minWidth = 230,
20202
20207
  value,
20203
20208
  setValue,
20204
20209
  ValueComponent,
@@ -20224,6 +20229,7 @@ var useSingleSelect = ({
20224
20229
  placeholder: closedLabel,
20225
20230
  onClear: () => setValue(null),
20226
20231
  Component: SelectSingleOptions,
20232
+ minWidth,
20227
20233
  buttonProps
20228
20234
  };
20229
20235
  };
@@ -20416,9 +20422,11 @@ var Select2 = import_react81.default.forwardRef(
20416
20422
  const required = isRequired() || props.required;
20417
20423
  const disabled = isDisabled() || props.disabled;
20418
20424
  const viewMode = isViewMode() || props.viewMode;
20425
+ const { isEmpty, placeholder, Component: Component5, onClear, minWidth, buttonProps } = instances_default(props);
20419
20426
  const { floating, transition, interactions } = useFloatingMenu_default({
20420
20427
  open,
20421
20428
  onOpenChange: setOpen,
20429
+ minWidth,
20422
20430
  placement
20423
20431
  });
20424
20432
  const height = (0, import_react81.useMemo)(() => {
@@ -20433,7 +20441,6 @@ var Select2 = import_react81.default.forwardRef(
20433
20441
  setOpen(true);
20434
20442
  }
20435
20443
  };
20436
- const { isEmpty, placeholder, Component: Component5, onClear, buttonProps } = instances_default(props);
20437
20444
  const clearEnabled = !isEmpty && props.clearable && !props.disabled && !props.readOnly;
20438
20445
  const setRef = (0, import_react81.useCallback)(
20439
20446
  (node) => {
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;
@@ -19021,6 +19019,7 @@ import {
19021
19019
  var useFloatingMenu = ({
19022
19020
  open,
19023
19021
  onOpenChange,
19022
+ minWidth,
19024
19023
  placement = "bottom"
19025
19024
  }) => {
19026
19025
  const floating = useFloating2({
@@ -19030,13 +19029,16 @@ var useFloatingMenu = ({
19030
19029
  whileElementsMounted: autoUpdate2,
19031
19030
  middleware: [
19032
19031
  flip2(),
19033
- size3({
19034
- apply({ rects, elements }) {
19035
- Object.assign(elements.floating.style, {
19036
- minWidth: `${rects.reference.width}px`
19037
- });
19038
- }
19039
- })
19032
+ size3(
19033
+ {
19034
+ apply({ rects, elements }) {
19035
+ Object.assign(elements.floating.style, {
19036
+ minWidth: `${Math.max(rects.reference.width, minWidth)}px`
19037
+ });
19038
+ }
19039
+ },
19040
+ [minWidth]
19041
+ )
19040
19042
  ]
19041
19043
  });
19042
19044
  const transition = useTransitionStatus(floating.context, {
@@ -20016,6 +20018,7 @@ var useMultiSelect = ({
20016
20018
  overscan,
20017
20019
  estimateSize,
20018
20020
  height,
20021
+ minWidth = 290,
20019
20022
  value,
20020
20023
  setValue,
20021
20024
  finder,
@@ -20033,6 +20036,7 @@ var useMultiSelect = ({
20033
20036
  placeholder: closedLabel,
20034
20037
  onClear: () => setValue([]),
20035
20038
  Component: SelectMultiOptions,
20039
+ minWidth,
20036
20040
  buttonProps
20037
20041
  };
20038
20042
  };
@@ -20159,6 +20163,7 @@ var useSingleSelect = ({
20159
20163
  overscan,
20160
20164
  estimateSize,
20161
20165
  height,
20166
+ minWidth = 230,
20162
20167
  value,
20163
20168
  setValue,
20164
20169
  ValueComponent,
@@ -20184,6 +20189,7 @@ var useSingleSelect = ({
20184
20189
  placeholder: closedLabel,
20185
20190
  onClear: () => setValue(null),
20186
20191
  Component: SelectSingleOptions,
20192
+ minWidth,
20187
20193
  buttonProps
20188
20194
  };
20189
20195
  };
@@ -20376,9 +20382,11 @@ var Select2 = React348.forwardRef(
20376
20382
  const required = isRequired() || props.required;
20377
20383
  const disabled = isDisabled() || props.disabled;
20378
20384
  const viewMode = isViewMode() || props.viewMode;
20385
+ const { isEmpty, placeholder, Component: Component5, onClear, minWidth, buttonProps } = instances_default(props);
20379
20386
  const { floating, transition, interactions } = useFloatingMenu_default({
20380
20387
  open,
20381
20388
  onOpenChange: setOpen,
20389
+ minWidth,
20382
20390
  placement
20383
20391
  });
20384
20392
  const height = useMemo13(() => {
@@ -20393,7 +20401,6 @@ var Select2 = React348.forwardRef(
20393
20401
  setOpen(true);
20394
20402
  }
20395
20403
  };
20396
- const { isEmpty, placeholder, Component: Component5, onClear, buttonProps } = instances_default(props);
20397
20404
  const clearEnabled = !isEmpty && props.clearable && !props.disabled && !props.readOnly;
20398
20405
  const setRef = useCallback12(
20399
20406
  (node) => {
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.9",
4
4
  "description": "Made with create-react-library",
5
5
  "author": "fmgusmao",
6
6
  "license": "MIT",