lecom-ui 5.3.14 → 5.3.15

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.
@@ -10,29 +10,33 @@ const CustomButton = React.forwardRef(
10
10
  );
11
11
  const [color, setColor] = React.useState(normal.textColor);
12
12
  React.useEffect(() => {
13
- setBackgroundColor(
14
- opacity(customStyles.normal.bgColor, customStyles.normal.opacity)
15
- );
16
- setColor(customStyles.normal.textColor);
17
- }, [
18
- customStyles.normal.bgColor,
19
- customStyles.normal.opacity,
20
- customStyles.normal.textColor
21
- ]);
22
- const handleOver = () => {
13
+ setBackgroundColor(opacity(normal.bgColor, normal.opacity));
14
+ setColor(normal.textColor);
15
+ }, [normal.bgColor, normal.opacity, normal.textColor]);
16
+ const handleOver = React.useCallback(() => {
23
17
  setBackgroundColor(opacity(hover.bgColor, hover.opacity));
24
18
  setColor(hover.textColor);
25
- };
26
- const handleOut = () => {
19
+ }, [hover.bgColor, hover.opacity, hover.textColor]);
20
+ const handleOut = React.useCallback(() => {
27
21
  setBackgroundColor(opacity(normal.bgColor, normal.opacity));
28
22
  setColor(normal.textColor);
29
- };
23
+ }, [normal.bgColor, normal.opacity, normal.textColor]);
30
24
  const shadowSmTailwind = "0 0 #0000, 0 0 #0000, 0 1px 2px 0 rgb(0, 0, 0, 0.05)";
31
- const mappedCustomStyles = {
32
- backgroundColor: isActive ? opacity(focus.bgColor, focus.opacity) : backgroundColor,
33
- color: isActive ? focus.textColor : color,
34
- boxShadow: shadowSmTailwind
35
- };
25
+ const mappedCustomStyles = React.useMemo(
26
+ () => ({
27
+ backgroundColor: isActive ? opacity(focus.bgColor, focus.opacity) : backgroundColor,
28
+ color: isActive ? focus.textColor : color,
29
+ boxShadow: shadowSmTailwind
30
+ }),
31
+ [
32
+ isActive,
33
+ focus.bgColor,
34
+ focus.opacity,
35
+ focus.textColor,
36
+ backgroundColor,
37
+ color
38
+ ]
39
+ );
36
40
  return /* @__PURE__ */ React.createElement(
37
41
  Button,
38
42
  {
@@ -11,46 +11,50 @@ const SelectTrigger = React.forwardRef(({ className, children, customStyles, ...
11
11
  const normal = customStyles?.normal;
12
12
  const hover = customStyles?.hover;
13
13
  const focus = customStyles?.focus;
14
- const [backgroundColor, setBackgroundColor] = React.useState(
15
- normal ? opacity(normal.bgColor, normal.opacity) : void 0
14
+ const [state, setState] = React.useState(
15
+ "normal"
16
16
  );
17
- const [color, setColor] = React.useState(normal?.textColor ?? void 0);
18
17
  React.useEffect(() => {
19
- if (customStyles?.normal) {
20
- setBackgroundColor(
21
- opacity(customStyles.normal.bgColor, customStyles.normal.opacity)
22
- );
23
- setColor(customStyles.normal.textColor);
18
+ setState("normal");
19
+ }, [customStyles]);
20
+ const getCurrentStyles = React.useCallback(() => {
21
+ const shadowSmTailwind = "0 0 #0000, 0 0 #0000, 0 1px 2px 0 rgb(0, 0, 0, 0.05)";
22
+ if (!customStyles) return {};
23
+ if (state === "hover" && hover) {
24
+ return {
25
+ backgroundColor: opacity(hover.bgColor, hover.opacity),
26
+ color: hover.textColor,
27
+ boxShadow: shadowSmTailwind
28
+ };
24
29
  }
25
- }, [
26
- customStyles?.normal,
27
- customStyles?.normal?.bgColor,
28
- customStyles?.normal?.opacity,
29
- customStyles?.normal?.textColor
30
- ]);
31
- const [isActive, setIsActive] = React.useState(false);
32
- const handleOver = React.useCallback(() => {
33
- if (hover) {
34
- setBackgroundColor(opacity(hover.bgColor, hover.opacity));
35
- setColor(hover.textColor);
30
+ if (state === "focus" && focus) {
31
+ return {
32
+ backgroundColor: opacity(focus.bgColor, focus.opacity),
33
+ color: focus.textColor,
34
+ boxShadow: shadowSmTailwind
35
+ };
36
36
  }
37
- }, [hover]);
38
- const handleOut = React.useCallback(() => {
39
37
  if (normal) {
40
- setBackgroundColor(opacity(normal.bgColor, normal.opacity));
41
- setColor(normal.textColor);
38
+ return {
39
+ backgroundColor: opacity(normal.bgColor, normal.opacity),
40
+ color: normal.textColor,
41
+ boxShadow: shadowSmTailwind
42
+ };
42
43
  }
43
- }, [normal]);
44
- const handleFocus = React.useCallback(() => setIsActive(true), []);
45
- const handleBlur = React.useCallback(() => setIsActive(false), []);
46
- const mappedCustomStyles = React.useMemo(() => {
47
- const shadowSmTailwind = "0 0 #0000, 0 0 #0000, 0 1px 2px 0 rgb(0, 0, 0, 0.05)";
48
- return customStyles ? {
49
- backgroundColor: isActive ? opacity(focus?.bgColor || "", focus?.opacity || 1) : backgroundColor,
50
- color: isActive ? focus?.textColor : color,
51
- boxShadow: shadowSmTailwind
52
- } : {};
53
- }, [customStyles, isActive, focus, backgroundColor, color]);
44
+ return {};
45
+ }, [customStyles, state, normal, hover, focus]);
46
+ const handleOver = React.useCallback(() => {
47
+ if (hover) setState("hover");
48
+ }, [hover]);
49
+ const handleOut = React.useCallback(() => {
50
+ setState("normal");
51
+ }, []);
52
+ const handleFocus = React.useCallback(() => {
53
+ if (focus) setState("focus");
54
+ }, [focus]);
55
+ const handleBlur = React.useCallback(() => {
56
+ setState("normal");
57
+ }, []);
54
58
  return /* @__PURE__ */ React.createElement(
55
59
  SelectPrimitive.Trigger,
56
60
  {
@@ -68,7 +72,7 @@ const SelectTrigger = React.forwardRef(({ className, children, customStyles, ...
68
72
  onMouseOut: handleOut,
69
73
  onFocus: handleFocus,
70
74
  onBlur: handleBlur,
71
- style: mappedCustomStyles,
75
+ style: getCurrentStyles(),
72
76
  ...props
73
77
  },
74
78
  children,
package/dist/index.d.ts CHANGED
@@ -898,7 +898,7 @@ declare const RadioGroup: React$1.ForwardRefExoticComponent<Omit<RadioGroupPrimi
898
898
  declare const RadioGroupItem: React$1.ForwardRefExoticComponent<Omit<RadioGroupPrimitive.RadioGroupItemProps & React$1.RefAttributes<HTMLButtonElement>, "ref"> & React$1.RefAttributes<HTMLButtonElement>>;
899
899
 
900
900
  declare const ResizablePanelGroup: ({ className, ...props }: React$1.ComponentProps<typeof ResizablePrimitive.PanelGroup>) => React$1.JSX.Element;
901
- declare const ResizablePanel: React$1.ForwardRefExoticComponent<Omit<React$1.HTMLAttributes<HTMLDivElement | HTMLElement | HTMLOListElement | HTMLLIElement | HTMLAnchorElement | HTMLSpanElement | HTMLButtonElement | HTMLHeadingElement | HTMLParagraphElement | HTMLLabelElement | HTMLInputElement | HTMLUListElement | HTMLObjectElement | HTMLAreaElement | HTMLAudioElement | HTMLBaseElement | HTMLQuoteElement | HTMLBodyElement | HTMLBRElement | HTMLCanvasElement | HTMLTableCaptionElement | HTMLTableColElement | HTMLDataElement | HTMLDataListElement | HTMLModElement | HTMLDetailsElement | HTMLDialogElement | HTMLDListElement | HTMLEmbedElement | HTMLFieldSetElement | HTMLFormElement | HTMLHeadElement | HTMLHRElement | HTMLHtmlElement | HTMLIFrameElement | HTMLImageElement | HTMLLegendElement | HTMLLinkElement | HTMLMapElement | HTMLMenuElement | HTMLMetaElement | HTMLMeterElement | HTMLOptGroupElement | HTMLOptionElement | HTMLOutputElement | HTMLPictureElement | HTMLPreElement | HTMLProgressElement | HTMLScriptElement | HTMLSelectElement | HTMLSlotElement | HTMLSourceElement | HTMLStyleElement | HTMLTableElement | HTMLTableSectionElement | HTMLTableCellElement | HTMLTemplateElement | HTMLTextAreaElement | HTMLTimeElement | HTMLTitleElement | HTMLTableRowElement | HTMLTrackElement | HTMLVideoElement>, "id" | "onResize"> & {
901
+ declare const ResizablePanel: React$1.ForwardRefExoticComponent<Omit<React$1.HTMLAttributes<HTMLElement | HTMLOListElement | HTMLLIElement | HTMLAnchorElement | HTMLSpanElement | HTMLDivElement | HTMLButtonElement | HTMLLabelElement | HTMLParagraphElement | HTMLHeadingElement | HTMLInputElement | HTMLUListElement | HTMLObjectElement | HTMLAreaElement | HTMLAudioElement | HTMLBaseElement | HTMLQuoteElement | HTMLBodyElement | HTMLBRElement | HTMLCanvasElement | HTMLTableCaptionElement | HTMLTableColElement | HTMLDataElement | HTMLDataListElement | HTMLModElement | HTMLDetailsElement | HTMLDialogElement | HTMLDListElement | HTMLEmbedElement | HTMLFieldSetElement | HTMLFormElement | HTMLHeadElement | HTMLHRElement | HTMLHtmlElement | HTMLIFrameElement | HTMLImageElement | HTMLLegendElement | HTMLLinkElement | HTMLMapElement | HTMLMenuElement | HTMLMetaElement | HTMLMeterElement | HTMLOptGroupElement | HTMLOptionElement | HTMLOutputElement | HTMLPictureElement | HTMLPreElement | HTMLProgressElement | HTMLScriptElement | HTMLSelectElement | HTMLSlotElement | HTMLSourceElement | HTMLStyleElement | HTMLTableElement | HTMLTableSectionElement | HTMLTableCellElement | HTMLTemplateElement | HTMLTextAreaElement | HTMLTimeElement | HTMLTitleElement | HTMLTableRowElement | HTMLTrackElement | HTMLVideoElement>, "id" | "onResize"> & {
902
902
  className?: string;
903
903
  collapsedSize?: number | undefined;
904
904
  collapsible?: boolean | undefined;
@@ -983,7 +983,7 @@ declare const TooltipTrigger: React$1.ForwardRefExoticComponent<TooltipPrimitive
983
983
  declare const TooltipArrow: React$1.ForwardRefExoticComponent<TooltipPrimitive.TooltipArrowProps & React$1.RefAttributes<SVGSVGElement>>;
984
984
  declare const TooltipPortal: React$1.FC<TooltipPrimitive.TooltipPortalProps>;
985
985
  declare const tooltipContentVariants: (props?: ({
986
- color?: "white" | "black" | null | undefined;
986
+ color?: "black" | "white" | null | undefined;
987
987
  arrow?: boolean | null | undefined;
988
988
  } & class_variance_authority_types.ClassProp) | undefined) => string;
989
989
  interface TooltipContentProps extends React$1.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>, VariantProps<typeof tooltipContentVariants> {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lecom-ui",
3
- "version": "5.3.14",
3
+ "version": "5.3.15",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "dist/index.js",