@infomaximum/ui-kit 0.12.4 → 0.12.5

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,6 +1,6 @@
1
- import { isNumber } from "lodash-es";
1
+ import { isUndefined, isNumber } from "lodash-es";
2
2
  import { getDecimalValue } from "../../InputNumber.utils.js";
3
- import { useState } from "react";
3
+ import { useState, useLayoutEffect } from "react";
4
4
  import { emptyString } from "../../../../utils/const/index.js";
5
5
  import { getMiniDecimal, toFixed } from "../../utils/MiniDecimal.js";
6
6
  const useChangeValue = (options) => {
@@ -32,6 +32,17 @@ const useChangeValue = (options) => {
32
32
  const setInputValue = (newValue, userTyping) => {
33
33
  setInternalInputValue(mergedFormatter(newValue.isInvalidate() ? newValue.toString(false) : newValue.toString(!userTyping), userTyping));
34
34
  };
35
+ useLayoutEffect(() => {
36
+ if (isUndefined(value)) {
37
+ return;
38
+ }
39
+ const newValue = getMiniDecimal(value);
40
+ setDecimalValue(newValue);
41
+ const currentParsedValue = getMiniDecimal(mergedParser(inputValue));
42
+ if (!newValue.equals(currentParsedValue)) {
43
+ setInputValue(newValue, false);
44
+ }
45
+ }, [value]);
35
46
  const setUncontrolledDecimalValue = (newDecimal) => {
36
47
  if (value === void 0) {
37
48
  setDecimalValue(newDecimal);
@@ -1,6 +1,6 @@
1
1
  import { UseDecimalToolsOptions } from './useDecimalTools.types';
2
2
  export declare const useDecimalTools: (options: UseDecimalToolsOptions) => {
3
3
  getPrecision: (numStr: string, userTyping: boolean) => number | undefined;
4
- mergedParser: (num: string | number) => string | number;
4
+ mergedParser: (num: string | number | undefined) => string | number;
5
5
  mergedFormatter: (number: string, userTyping: boolean) => string;
6
6
  };
@@ -10,11 +10,12 @@ const PopoverComponent = memo(({
10
10
  content,
11
11
  children,
12
12
  styles,
13
+ trigger = "hover",
13
14
  ...baseProps
14
15
  }) => {
15
16
  const theme = useTheme();
16
17
  const popoverTokens = getPopoverTokens(theme);
17
- return /* @__PURE__ */ jsx(BaseTooltip, { ...baseProps, floatingElement: /* @__PURE__ */ jsx(PopoverFloatingElement, { title, content, styles }), arrowColor: popoverTokens.popoverBg, children });
18
+ return /* @__PURE__ */ jsx(BaseTooltip, { ...baseProps, floatingElement: /* @__PURE__ */ jsx(PopoverFloatingElement, { title, content, styles }), arrowColor: popoverTokens.popoverBg, trigger: [trigger], children });
18
19
  });
19
20
  const Popover = withThemeProvider(PopoverComponent);
20
21
  export {
@@ -1,10 +1,11 @@
1
1
  import { Interpolation } from '@emotion/react';
2
- import { BaseTooltipProps } from '../BaseTooltip/BaseTooltip.types';
2
+ import { BaseTooltipProps, BaseTooltipTriggerType } from '../BaseTooltip/BaseTooltip.types';
3
3
  import { ReactNode } from 'react';
4
4
  import { Theme } from '../../themes';
5
- export interface PopoverProps extends Omit<BaseTooltipProps, "floatingElement" | "arrowColor"> {
5
+ export interface PopoverProps extends Omit<BaseTooltipProps, "floatingElement" | "arrowColor" | "trigger"> {
6
6
  title?: ReactNode | (() => ReactNode);
7
7
  content?: ReactNode | (() => ReactNode);
8
+ trigger?: Exclude<BaseTooltipTriggerType, "contextMenu">;
8
9
  styles?: {
9
10
  wrapper?: (theme: Theme) => Interpolation;
10
11
  titleWrapper?: (theme: Theme) => Interpolation;
@@ -9,12 +9,12 @@ const TooltipComponent = memo(({
9
9
  title,
10
10
  children,
11
11
  styles,
12
- trigger,
12
+ trigger = "hover",
13
13
  ...baseProps
14
14
  }) => {
15
15
  const theme = useTheme();
16
16
  const tooltipTokens = getTooltipTokens(theme);
17
- return /* @__PURE__ */ jsx(BaseTooltip, { ...baseProps, trigger: trigger ? [trigger] : void 0, floatingElement: /* @__PURE__ */ jsx(TooltipFloatingElement, { title, styles: styles == null ? void 0 : styles.floatingElement }), arrowColor: tooltipTokens.tooltipBg, children });
17
+ return /* @__PURE__ */ jsx(BaseTooltip, { ...baseProps, trigger: [trigger], floatingElement: /* @__PURE__ */ jsx(TooltipFloatingElement, { title, styles: styles == null ? void 0 : styles.floatingElement }), arrowColor: tooltipTokens.tooltipBg, children });
18
18
  });
19
19
  const Tooltip = withThemeProvider(TooltipComponent);
20
20
  export {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@infomaximum/ui-kit",
3
3
  "license": "Apache-2.0",
4
- "version": "0.12.4",
4
+ "version": "0.12.5",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",