lecom-ui 5.3.15 → 5.3.17

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.
@@ -2,48 +2,35 @@ import * as React from 'react';
2
2
  import opacity from 'hex-color-opacity';
3
3
  import { Button } from './Button.js';
4
4
 
5
+ const SHADOW_SM_TAILWIND = "0 0 #0000, 0 0 #0000, 0 1px 2px 0 rgb(0, 0, 0, 0.05)";
5
6
  const CustomButton = React.forwardRef(
6
7
  ({ customStyles, isActive, children, ...props }, ref) => {
7
8
  const { normal, hover, focus } = customStyles;
8
- const [backgroundColor, setBackgroundColor] = React.useState(
9
- () => opacity(normal.bgColor, normal.opacity)
10
- );
11
- const [color, setColor] = React.useState(normal.textColor);
9
+ const getStyle = (style) => ({
10
+ backgroundColor: opacity(style.bgColor, style.opacity),
11
+ color: style.textColor
12
+ });
13
+ const [styleState, setStyleState] = React.useState(() => getStyle(normal));
12
14
  React.useEffect(() => {
13
- setBackgroundColor(opacity(normal.bgColor, normal.opacity));
14
- setColor(normal.textColor);
15
- }, [normal.bgColor, normal.opacity, normal.textColor]);
16
- const handleOver = React.useCallback(() => {
17
- setBackgroundColor(opacity(hover.bgColor, hover.opacity));
18
- setColor(hover.textColor);
19
- }, [hover.bgColor, hover.opacity, hover.textColor]);
20
- const handleOut = React.useCallback(() => {
21
- setBackgroundColor(opacity(normal.bgColor, normal.opacity));
22
- setColor(normal.textColor);
23
- }, [normal.bgColor, normal.opacity, normal.textColor]);
24
- const shadowSmTailwind = "0 0 #0000, 0 0 #0000, 0 1px 2px 0 rgb(0, 0, 0, 0.05)";
15
+ setStyleState(getStyle(normal));
16
+ }, [normal]);
17
+ const handleMouseOver = () => setStyleState(getStyle(hover));
18
+ const handleMouseOut = () => setStyleState(getStyle(normal));
25
19
  const mappedCustomStyles = React.useMemo(
26
20
  () => ({
27
- backgroundColor: isActive ? opacity(focus.bgColor, focus.opacity) : backgroundColor,
28
- color: isActive ? focus.textColor : color,
29
- boxShadow: shadowSmTailwind
21
+ backgroundColor: isActive ? opacity(focus.bgColor, focus.opacity) : styleState.backgroundColor,
22
+ color: isActive ? focus.textColor : styleState.color,
23
+ boxShadow: SHADOW_SM_TAILWIND
30
24
  }),
31
- [
32
- isActive,
33
- focus.bgColor,
34
- focus.opacity,
35
- focus.textColor,
36
- backgroundColor,
37
- color
38
- ]
25
+ [isActive, focus, styleState]
39
26
  );
40
27
  return /* @__PURE__ */ React.createElement(
41
28
  Button,
42
29
  {
43
- onMouseOver: handleOver,
44
- onMouseOut: handleOut,
45
- style: mappedCustomStyles,
46
30
  ref,
31
+ style: mappedCustomStyles,
32
+ onMouseOver: handleMouseOver,
33
+ onMouseOut: handleMouseOut,
47
34
  ...props
48
35
  },
49
36
  children
@@ -7,54 +7,25 @@ import { ChevronDown, ChevronUp, Check } from 'lucide-react';
7
7
  const Select = SelectPrimitive.Root;
8
8
  const SelectGroup = SelectPrimitive.Group;
9
9
  const SelectValue = SelectPrimitive.Value;
10
+ const SHADOW_SM_TAILWIND = "0 0 #0000, 0 0 #0000, 0 1px 2px 0 rgb(0, 0, 0, 0.05)";
10
11
  const SelectTrigger = React.forwardRef(({ className, children, customStyles, ...props }, ref) => {
11
- const normal = customStyles?.normal;
12
- const hover = customStyles?.hover;
13
- const focus = customStyles?.focus;
14
- const [state, setState] = React.useState(
15
- "normal"
16
- );
17
- React.useEffect(() => {
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
- };
29
- }
30
- if (state === "focus" && focus) {
31
- return {
32
- backgroundColor: opacity(focus.bgColor, focus.opacity),
33
- color: focus.textColor,
34
- boxShadow: shadowSmTailwind
35
- };
36
- }
37
- if (normal) {
38
- return {
39
- backgroundColor: opacity(normal.bgColor, normal.opacity),
40
- color: normal.textColor,
41
- boxShadow: shadowSmTailwind
42
- };
43
- }
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
- }, []);
12
+ const [state, setState] = React.useState("normal");
13
+ const { normal, hover, focus } = customStyles || {};
14
+ React.useEffect(() => setState("normal"), [customStyles]);
15
+ const currentStyles = React.useMemo(() => {
16
+ const styleByState = customStyles && customStyles[state] || normal;
17
+ if (!styleByState) return {};
18
+ const { bgColor, opacity: bgOpacity, textColor } = styleByState;
19
+ return {
20
+ backgroundColor: opacity(bgColor, bgOpacity),
21
+ color: textColor,
22
+ boxShadow: SHADOW_SM_TAILWIND
23
+ };
24
+ }, [customStyles, state, normal]);
25
+ const handleMouseOver = () => hover && setState("hover");
26
+ const handleMouseOut = () => setState("normal");
27
+ const handleFocus = () => focus && setState("focus");
28
+ const handleBlur = () => setState("normal");
58
29
  return /* @__PURE__ */ React.createElement(
59
30
  SelectPrimitive.Trigger,
60
31
  {
@@ -68,11 +39,11 @@ const SelectTrigger = React.forwardRef(({ className, children, customStyles, ...
68
39
  !customStyles && "border border-grey-400 bg-background",
69
40
  className
70
41
  ),
71
- onMouseOver: handleOver,
72
- onMouseOut: handleOut,
42
+ style: currentStyles,
43
+ onMouseOver: handleMouseOver,
44
+ onMouseOut: handleMouseOut,
73
45
  onFocus: handleFocus,
74
46
  onBlur: handleBlur,
75
- style: getCurrentStyles(),
76
47
  ...props
77
48
  },
78
49
  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<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"> & {
901
+ declare const ResizablePanel: React$1.ForwardRefExoticComponent<Omit<React$1.HTMLAttributes<HTMLElement | HTMLOListElement | HTMLLIElement | HTMLAnchorElement | HTMLSpanElement | HTMLDivElement | HTMLButtonElement | HTMLHeadingElement | HTMLParagraphElement | HTMLInputElement | HTMLLabelElement | 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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lecom-ui",
3
- "version": "5.3.15",
3
+ "version": "5.3.17",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "dist/index.js",