lecom-ui 5.4.29 → 5.4.31

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.
@@ -57,7 +57,8 @@ const MultiSelect = React.forwardRef(
57
57
  groupedOptions,
58
58
  classNameContent,
59
59
  size = "medium",
60
- disabled = false
60
+ disabled = false,
61
+ readOnly = false
61
62
  }, ref) => {
62
63
  const { t } = useTranslation();
63
64
  const [selectedValues, setSelectedValues] = React.useState(value);
@@ -169,11 +170,13 @@ const MultiSelect = React.forwardRef(
169
170
  }
170
171
  };
171
172
  const toggleOption = (option) => {
173
+ if (readOnly) return;
172
174
  const newSelectedValues = selectedValues.includes(option) ? selectedValues.filter((value2) => value2 !== option) : [...selectedValues, option];
173
175
  setSelectedValues(newSelectedValues);
174
176
  onValueChange(newSelectedValues);
175
177
  };
176
178
  const handleClear = () => {
179
+ if (readOnly) return;
177
180
  setSelectedValues([]);
178
181
  onValueChange([]);
179
182
  };
@@ -181,6 +184,7 @@ const MultiSelect = React.forwardRef(
181
184
  setIsPopoverOpen((prev) => !prev);
182
185
  };
183
186
  const toggleAll = () => {
187
+ if (readOnly) return;
184
188
  if (treeOptions && treeOptions.length) {
185
189
  const gather = (acc, nodes) => {
186
190
  for (const n of nodes) {
@@ -377,6 +381,7 @@ const MultiSelect = React.forwardRef(
377
381
  }
378
382
  };
379
383
  const toggleTreeNode = (node) => {
384
+ if (readOnly) return;
380
385
  if (treeSelectionStrategy === "all") {
381
386
  const isSelected = selectedValues.includes(node.value);
382
387
  const next = isSelected ? selectedValues.filter((v) => v !== node.value) : [...selectedValues, node.value];
@@ -460,7 +465,8 @@ const MultiSelect = React.forwardRef(
460
465
  {
461
466
  className: cn(
462
467
  "flex items-center gap-2 px-2 py-1 cursor-pointer rounded-sm text-grey-800 hover:bg-grey-100",
463
- (fully || isSelectedLeaf) && "bg-blue-50"
468
+ (fully || isSelectedLeaf) && "bg-blue-50",
469
+ readOnly && "cursor-default hover:bg-transparent"
464
470
  ),
465
471
  style: { paddingLeft: depth * 14 + 8 }
466
472
  },
@@ -473,7 +479,9 @@ const MultiSelect = React.forwardRef(
473
479
  ),
474
480
  onClick: (e) => {
475
481
  e.stopPropagation();
476
- toggleTreeNode(n);
482
+ if (!readOnly) {
483
+ toggleTreeNode(n);
484
+ }
477
485
  }
478
486
  },
479
487
  fully && /* @__PURE__ */ React.createElement(Check, { className: "!h-3 !w-3 !text-white", strokeWidth: 3 }),
@@ -486,7 +494,9 @@ const MultiSelect = React.forwardRef(
486
494
  className: "flex-1 truncate cursor-pointer overflow-hidden",
487
495
  onClick: (e) => {
488
496
  e.stopPropagation();
489
- toggleTreeNode(n);
497
+ if (!readOnly) {
498
+ toggleTreeNode(n);
499
+ }
490
500
  },
491
501
  title: n.label
492
502
  },
@@ -521,9 +531,11 @@ const MultiSelect = React.forwardRef(
521
531
  [&_svg]:pointer-events-auto`,
522
532
  maxCount === void 0 && TRIGGER_HEIGHT_CLASSES[size],
523
533
  disabled && "opacity-50 cursor-not-allowed pointer-events-none",
534
+ readOnly && !disabled && "opacity-50 hover:border-grey-400",
524
535
  className
525
536
  ),
526
537
  "aria-expanded": isPopoverOpen,
538
+ "aria-readonly": readOnly,
527
539
  disabled
528
540
  },
529
541
  selectedValues.length > 0 ? /* @__PURE__ */ React.createElement("div", { className: "flex justify-between items-center w-full" }, /* @__PURE__ */ React.createElement("div", { className: "flex flex-wrap items-center gap-1" }, selectedValues.slice(0, dynamicMaxCount).map((value2) => {
@@ -555,7 +567,7 @@ const MultiSelect = React.forwardRef(
555
567
  },
556
568
  label
557
569
  )),
558
- !disabled && /* @__PURE__ */ React.createElement(
570
+ !disabled && !readOnly && /* @__PURE__ */ React.createElement(
559
571
  X,
560
572
  {
561
573
  className: "h-4 w-4 cursor-pointer flex-shrink-0",
@@ -573,7 +585,7 @@ const MultiSelect = React.forwardRef(
573
585
  className: "text-blue-600"
574
586
  },
575
587
  `+ ${selectedValues.length - dynamicMaxCount}`
576
- ))), /* @__PURE__ */ React.createElement("div", { className: "flex items-center justify-between" }, !disabled && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
588
+ ))), /* @__PURE__ */ React.createElement("div", { className: "flex items-center justify-between" }, !disabled && !readOnly && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
577
589
  X,
578
590
  {
579
591
  className: "h-4 w-4 cursor-pointer text-grey-800",
@@ -621,7 +633,8 @@ const MultiSelect = React.forwardRef(
621
633
  placeholder: treeSearchPlaceholder || t("multiSelect.search"),
622
634
  onKeyDown: handleInputKeyDown,
623
635
  value: query,
624
- onValueChange: (v) => setQuery(v)
636
+ onValueChange: (v) => setQuery(v),
637
+ disabled: readOnly
625
638
  }
626
639
  ),
627
640
  /* @__PURE__ */ React.createElement(CommandList, null, /* @__PURE__ */ React.createElement(CommandGroup, null, (effectiveOptions.length === 0 || query && filteredOptions.length === 0) && /* @__PURE__ */ React.createElement(
@@ -637,8 +650,11 @@ const MultiSelect = React.forwardRef(
637
650
  CommandItem,
638
651
  {
639
652
  key: "all",
640
- onSelect: toggleAll,
641
- className: "cursor-pointer"
653
+ onSelect: readOnly ? void 0 : toggleAll,
654
+ className: cn(
655
+ "cursor-pointer",
656
+ readOnly && "cursor-default pointer-events-none hover:bg-transparent"
657
+ )
642
658
  },
643
659
  /* @__PURE__ */ React.createElement(
644
660
  "div",
@@ -688,8 +704,11 @@ const MultiSelect = React.forwardRef(
688
704
  CommandItem,
689
705
  {
690
706
  key: option.value,
691
- onSelect: () => toggleOption(option.value),
692
- className: "cursor-pointer"
707
+ onSelect: readOnly ? void 0 : () => toggleOption(option.value),
708
+ className: cn(
709
+ "cursor-pointer",
710
+ readOnly && "cursor-default pointer-events-none hover:bg-transparent"
711
+ )
693
712
  },
694
713
  /* @__PURE__ */ React.createElement(
695
714
  "div",
@@ -727,8 +746,11 @@ const MultiSelect = React.forwardRef(
727
746
  CommandItem,
728
747
  {
729
748
  key: option.value,
730
- onSelect: () => toggleOption(option.value),
731
- className: "cursor-pointer"
749
+ onSelect: readOnly ? void 0 : () => toggleOption(option.value),
750
+ className: cn(
751
+ "cursor-pointer",
752
+ readOnly && "cursor-default pointer-events-none hover:bg-transparent"
753
+ )
732
754
  },
733
755
  /* @__PURE__ */ React.createElement(
734
756
  "div",
@@ -782,6 +804,7 @@ const MultiSelect = React.forwardRef(
782
804
  value: treeQuery,
783
805
  onChange: (e) => setTreeQuery(e.target.value),
784
806
  placeholder: treeSearchPlaceholder || t("multiSelect.search"),
807
+ disabled: readOnly,
785
808
  className: cn(
786
809
  "w-full pl-9 pr-3 border-0 focus:outline-none focus:ring-0 bg-transparent placeholder:text-muted-foreground",
787
810
  getFontVariant(size),
@@ -791,8 +814,11 @@ const MultiSelect = React.forwardRef(
791
814
  ))), /* @__PURE__ */ React.createElement("div", { className: "px-2 pb-1 overflow-y-auto overflow-x-hidden [&::-webkit-scrollbar]:w-1.5 [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar-thumb]:bg-grey-300 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb:hover]:bg-grey-400" }, !treeQuery && treeOptions && treeOptions.length > 0 && /* @__PURE__ */ React.createElement(
792
815
  "div",
793
816
  {
794
- className: "flex items-center gap-2 px-2 py-1 cursor-pointer rounded-sm hover:bg-accent",
795
- onClick: toggleAll
817
+ className: cn(
818
+ "flex items-center gap-2 px-2 py-1 cursor-pointer rounded-sm hover:bg-accent",
819
+ readOnly && "cursor-default hover:bg-transparent pointer-events-none"
820
+ ),
821
+ onClick: readOnly ? void 0 : toggleAll
796
822
  },
797
823
  /* @__PURE__ */ React.createElement(
798
824
  "div",
@@ -145,7 +145,8 @@ const PaginationPerPage = ({
145
145
  className,
146
146
  onChangePerPage,
147
147
  perPage,
148
- totalRowsSelected = 0
148
+ totalRowsSelected = 0,
149
+ maxSelection
149
150
  }) => {
150
151
  const { t } = useTranslation();
151
152
  const perPageOptions = [
@@ -165,6 +166,12 @@ const PaginationPerPage = ({
165
166
  if (!onChangePerPage) {
166
167
  return null;
167
168
  }
169
+ const getSelectedText = () => {
170
+ if (maxSelection === 1 && totalRowsSelected === 1) {
171
+ return `${totalRowsSelected} ${t("pagination.selectedItemSingular")}`;
172
+ }
173
+ return `${totalRowsSelected} ${t("pagination.selectedProcess")}`;
174
+ };
168
175
  return /* @__PURE__ */ React.createElement("div", { className: cn("flex items-center gap-4", className) }, /* @__PURE__ */ React.createElement(DropdownMenu, null, /* @__PURE__ */ React.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React.createElement(Button, { size: "small", color: "grey", variant: "outlined" }, /* @__PURE__ */ React.createElement("span", { className: "max-md:hidden" }, t("pagination.show")), " ", perPage, /* @__PURE__ */ React.createElement(ChevronDown, { size: 20 }))), /* @__PURE__ */ React.createElement(DropdownMenuContent, { side: "top", align: "center" }, perPageOptions.map((option) => /* @__PURE__ */ React.createElement(
169
176
  DropdownMenuItem,
170
177
  {
@@ -174,7 +181,7 @@ const PaginationPerPage = ({
174
181
  }
175
182
  },
176
183
  option.value.toString()
177
- )))), totalRowsSelected > 0 && /* @__PURE__ */ React.createElement(Typography, { variant: "heading-xxsmall-600", textColor: "text-grey-800" }, totalRowsSelected, " ", t("pagination.selectedProcess")));
184
+ )))), totalRowsSelected > 0 && /* @__PURE__ */ React.createElement(Typography, { variant: "heading-xxsmall-600", textColor: "text-grey-800" }, getSelectedText()));
178
185
  };
179
186
  PaginationPerPage.displayName = "PaginationPerPage";
180
187
  const Pagination = ({
@@ -185,7 +192,8 @@ const Pagination = ({
185
192
  onChangePerPage,
186
193
  className,
187
194
  activeColor,
188
- showPerPageSelector = true
195
+ showPerPageSelector = true,
196
+ maxSelection
189
197
  }) => {
190
198
  const { t } = useTranslation();
191
199
  const mapPaginationItem = (item) => {
@@ -215,6 +223,12 @@ const Pagination = ({
215
223
  };
216
224
  return React.createElement(mappedComponents[item.type], componentProps);
217
225
  };
226
+ const getSelectedText = () => {
227
+ if (maxSelection === 1 && totalRowsSelected === 1) {
228
+ return `${totalRowsSelected} ${t("pagination.selectedItemSingular")}`;
229
+ }
230
+ return `${totalRowsSelected} ${t("pagination.selectedProcess")}`;
231
+ };
218
232
  return /* @__PURE__ */ React.createElement(
219
233
  "div",
220
234
  {
@@ -225,10 +239,11 @@ const Pagination = ({
225
239
  {
226
240
  onChangePerPage,
227
241
  perPage,
228
- totalRowsSelected
242
+ totalRowsSelected,
243
+ maxSelection
229
244
  }
230
245
  ),
231
- !showPerPageSelector && totalRowsSelected > 0 && /* @__PURE__ */ React.createElement(Typography, { variant: "heading-xxsmall-600", textColor: "text-grey-800" }, totalRowsSelected, " ", t("pagination.selectedProcess")),
246
+ !showPerPageSelector && totalRowsSelected > 0 && /* @__PURE__ */ React.createElement(Typography, { variant: "heading-xxsmall-600", textColor: "text-grey-800" }, getSelectedText()),
232
247
  /* @__PURE__ */ React.createElement("nav", { role: "navigation", "aria-label": "pagination" }, /* @__PURE__ */ React.createElement(PaginationContent, null, itemsPage.map((item) => /* @__PURE__ */ React.createElement(PaginationItem, { key: item.id }, mapPaginationItem(item)))))
233
248
  );
234
249
  };
@@ -9,7 +9,8 @@ const language = {
9
9
  },
10
10
  pagination: {
11
11
  show: "Show:",
12
- selectedProcess: "Item(s) selected"
12
+ selectedProcess: "Item(s) selected",
13
+ selectedItemSingular: "item selected"
13
14
  },
14
15
  upload: {
15
16
  label: "Drag and drop the file here or click to select it.",
@@ -9,7 +9,8 @@ const language = {
9
9
  },
10
10
  pagination: {
11
11
  show: "Mostrar:",
12
- selectedProcess: "Item(s) seleccionado(s)"
12
+ selectedProcess: "Item(s) seleccionado(s)",
13
+ selectedItemSingular: "item seleccionado"
13
14
  },
14
15
  upload: {
15
16
  label: "Arrastre y suelte el archivo aqu\xED o haga clic para seleccionarlo.",
@@ -9,7 +9,8 @@ const language = {
9
9
  },
10
10
  pagination: {
11
11
  show: "Mostrar:",
12
- selectedProcess: "Item(s) selecionado(s)"
12
+ selectedProcess: "Item(s) selecionado(s)",
13
+ selectedItemSingular: "item selecionado"
13
14
  },
14
15
  upload: {
15
16
  label: "Arraste e solte o arquivo aqui ou clique para selecion\xE1-lo.",
package/dist/index.d.ts CHANGED
@@ -306,6 +306,7 @@ interface PaginationProps {
306
306
  className?: string;
307
307
  activeColor?: BgColor$1;
308
308
  showPerPageSelector?: boolean;
309
+ maxSelection?: number;
309
310
  }
310
311
  declare const PaginationContent: React$1.ForwardRefExoticComponent<Omit<React$1.DetailedHTMLProps<React$1.HTMLAttributes<HTMLUListElement>, HTMLUListElement>, "ref"> & React$1.RefAttributes<HTMLUListElement>>;
311
312
  declare const PaginationItem: React$1.ForwardRefExoticComponent<Omit<React$1.DetailedHTMLProps<React$1.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "ref"> & React$1.RefAttributes<HTMLLIElement>>;
@@ -334,7 +335,7 @@ declare const PaginationIndex: {
334
335
  displayName: string;
335
336
  };
336
337
  declare const Pagination: {
337
- ({ currentPage, itemsPage, perPage, totalRowsSelected, onChangePerPage, className, activeColor, showPerPageSelector, }: PaginationProps): React$1.JSX.Element;
338
+ ({ currentPage, itemsPage, perPage, totalRowsSelected, onChangePerPage, className, activeColor, showPerPageSelector, maxSelection, }: PaginationProps): React$1.JSX.Element;
338
339
  displayName: string;
339
340
  };
340
341
 
@@ -862,6 +863,7 @@ interface MultiSelectProps extends React$1.ButtonHTMLAttributes<HTMLButtonElemen
862
863
  };
863
864
  classNameContent?: string;
864
865
  size?: MultiSelectSize;
866
+ readOnly?: boolean;
865
867
  }
866
868
  interface MultiSelectTreeOption {
867
869
  label: string;
@@ -992,7 +994,7 @@ declare const RadioGroup: React$1.ForwardRefExoticComponent<Omit<RadioGroupPrimi
992
994
  declare const RadioGroupItem: React$1.ForwardRefExoticComponent<Omit<RadioGroupPrimitive.RadioGroupItemProps & React$1.RefAttributes<HTMLButtonElement>, "ref"> & React$1.RefAttributes<HTMLButtonElement>>;
993
995
 
994
996
  declare const ResizablePanelGroup: ({ className, ...props }: React$1.ComponentProps<typeof ResizablePrimitive.PanelGroup>) => React$1.JSX.Element;
995
- declare const ResizablePanel: React$1.ForwardRefExoticComponent<Omit<React$1.HTMLAttributes<HTMLDivElement | HTMLElement | HTMLButtonElement | HTMLOListElement | HTMLLIElement | HTMLAnchorElement | HTMLSpanElement | 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"> & {
997
+ declare const ResizablePanel: React$1.ForwardRefExoticComponent<Omit<React$1.HTMLAttributes<HTMLDivElement | HTMLElement | HTMLButtonElement | HTMLOListElement | HTMLLIElement | HTMLAnchorElement | HTMLSpanElement | HTMLHeadingElement | HTMLParagraphElement | HTMLLabelElement | HTMLInputElement | 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 | HTMLUListElement | HTMLVideoElement>, "id" | "onResize"> & {
996
998
  className?: string;
997
999
  collapsedSize?: number | undefined;
998
1000
  collapsible?: boolean | undefined;
@@ -1087,7 +1089,7 @@ declare const TooltipTrigger: React$1.ForwardRefExoticComponent<TooltipPrimitive
1087
1089
  declare const TooltipArrow: React$1.ForwardRefExoticComponent<TooltipPrimitive.TooltipArrowProps & React$1.RefAttributes<SVGSVGElement>>;
1088
1090
  declare const TooltipPortal: React$1.FC<TooltipPrimitive.TooltipPortalProps>;
1089
1091
  declare const tooltipContentVariants: (props?: ({
1090
- color?: "black" | "white" | null | undefined;
1092
+ color?: "white" | "black" | null | undefined;
1091
1093
  arrow?: boolean | null | undefined;
1092
1094
  } & class_variance_authority_types.ClassProp) | undefined) => string;
1093
1095
  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.4.29",
3
+ "version": "5.4.31",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "dist/index.js",