@giro-ds/react 12.5.0 → 12.5.1

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.
package/dist/index.cjs CHANGED
@@ -3107,6 +3107,29 @@ const SHIFT_TOGGLES = {
3107
3107
 
3108
3108
  var styles$k = {"container":"VirtualKeyboard-module__container___A-e0I","layout--numeric":"VirtualKeyboard-module__layout--numeric___zfd7G","mode--fixed":"VirtualKeyboard-module__mode--fixed___1eFY1","layout--default":"VirtualKeyboard-module__layout--default___qyY1b","textFieldContainer":"VirtualKeyboard-module__textFieldContainer___XxGen","keyboardWrapper":"VirtualKeyboard-module__keyboardWrapper___jryTf","keyboardNumpadActive":"VirtualKeyboard-module__keyboardNumpadActive___jPpJD","overlay":"VirtualKeyboard-module__overlay___a5y7i","overlayOpen":"VirtualKeyboard-module__overlayOpen___hREu-","textFieldWrapper":"VirtualKeyboard-module__textFieldWrapper___bmi-z","keyPreview":"VirtualKeyboard-module__keyPreview___oWaO1","accentMenu":"VirtualKeyboard-module__accentMenu___A6tTy","accentMenuRow":"VirtualKeyboard-module__accentMenuRow___3kbvT","accentOption":"VirtualKeyboard-module__accentOption___ao-Ta"};
3109
3109
 
3110
+ /**
3111
+ * Atributo usado para marcar raízes de elementos portalizados (ex.: renderizados via
3112
+ * `createPortal` em `document.body`) que devem ser ignorados pela lógica de
3113
+ * "clique/foco fora" de camadas dispensáveis do Radix UI (Dialog, Popover, DropdownMenu etc.).
3114
+ *
3115
+ * Componentes que renderizam conteúdo fora da árvore DOM do elemento pai (como o
3116
+ * `VirtualKeyboard` em modo `native`) devem adicionar este atributo à raiz portalizada
3117
+ * para evitar que o Radix trate cliques nesse conteúdo como "fora" do componente,
3118
+ * o que causaria fechamentos indesejados quando usados dentro de um `Modal` (ou outro
3119
+ * componente baseado em Radix Dialog/Popover).
3120
+ */
3121
+ const DISMISS_OUTSIDE_IGNORE_ATTRIBUTE = 'data-dismiss-outside-ignore';
3122
+ /**
3123
+ * Verifica se o alvo de um evento de "interação fora" (Radix `onInteractOutside`,
3124
+ * `onPointerDownOutside`, `onFocusOutside`) está dentro de um elemento marcado com
3125
+ * {@link DISMISS_OUTSIDE_IGNORE_ATTRIBUTE}.
3126
+ */
3127
+ const isDismissOutsideIgnored = (target) => {
3128
+ if (!(target instanceof Element))
3129
+ return false;
3130
+ return target.closest(`[${DISMISS_OUTSIDE_IGNORE_ATTRIBUTE}]`) !== null;
3131
+ };
3132
+
3110
3133
  const LONG_PRESS_DELAY_MS = 400;
3111
3134
  const ACCENT_OPTIONS = {
3112
3135
  a: ['a', 'á', 'à', 'â', 'ã', 'ä', 'å', 'æ', '@', 'ª'],
@@ -3471,6 +3494,25 @@ const VirtualKeyboard = ({ variant = 'native', type = 'default', value, onChange
3471
3494
  layoutName,
3472
3495
  capsLockOn,
3473
3496
  ]);
3497
+ // Cobre toda a área do overlay do teclado (inclusive espaços/paddings fora do
3498
+ // `keyboardWrapperRef`, como o preview de tecla e o menu de acento portalizados),
3499
+ // garantindo que `isKeyboardInteractingRef` não seja perdido em cliques que não
3500
+ // caem exatamente sobre um `.hg-button`. Isso evita que o teclado feche sozinho
3501
+ // (via blur do targetRef) ao interagir com áreas adjacentes do próprio teclado.
3502
+ const handleOverlayPointerDown = React.useCallback((event) => {
3503
+ if (keyboardWrapperRef.current?.contains(event.target))
3504
+ return;
3505
+ isKeyboardInteractingRef.current = true;
3506
+ if (hideTimeoutRef.current !== null) {
3507
+ clearTimeout(hideTimeoutRef.current);
3508
+ }
3509
+ }, []);
3510
+ const handleOverlayPointerUp = React.useCallback((event) => {
3511
+ if (keyboardWrapperRef.current?.contains(event.target))
3512
+ return;
3513
+ isKeyboardInteractingRef.current = false;
3514
+ scheduleHideIfBlurred();
3515
+ }, [scheduleHideIfBlurred]);
3474
3516
  const handleAccentSelect = React.useCallback((accentedChar) => {
3475
3517
  const currentValue = valueRef.current;
3476
3518
  const baseLayout = type === 'numeric' ? 'abc' : 'default';
@@ -3643,7 +3685,7 @@ const VirtualKeyboard = ({ variant = 'native', type = 'default', value, onChange
3643
3685
  if (instance) {
3644
3686
  instance.setInput(valueRef.current);
3645
3687
  }
3646
- }, layoutName: layoutName, layout: activeLayout, theme: 'hg-theme-default', display: keyboardDisplay, onChange: handleChange, onKeyPress: handleKeyPress, preventMouseDownDefault: true }), (() => {
3688
+ }, layoutName: layoutName, layout: activeLayout, theme: 'hg-theme-default', display: keyboardDisplay, onChange: handleChange, onKeyPress: handleKeyPress, preventMouseDownDefault: true, disableButtonHold: true }), (() => {
3647
3689
  const shiftCount = { current: 0 };
3648
3690
  return iconSlots.map((slot) => {
3649
3691
  const key = slot.getAttribute('data-icon-key');
@@ -3657,14 +3699,14 @@ const VirtualKeyboard = ({ variant = 'native', type = 'default', value, onChange
3657
3699
  }
3658
3700
  return reactDom.createPortal(React.createElement(Icon), slot, `icon-${key}`);
3659
3701
  });
3660
- })(), keyPreview && typeof document !== 'undefined' && reactDom.createPortal(jsxRuntime.jsx("div", { ref: keyPreviewRef, className: styles$k.keyPreview, style: {
3702
+ })(), keyPreview && typeof document !== 'undefined' && reactDom.createPortal(jsxRuntime.jsx("div", { ref: keyPreviewRef, className: clsx(styles$k.keyPreview, className), style: {
3661
3703
  top: keyPreview.top,
3662
3704
  left: keyPreview.left + keyPreviewOffsetX,
3663
3705
  width: portalSizes.preview,
3664
3706
  height: portalSizes.preview,
3665
3707
  ...(portalSizes.fontSize ? { fontSize: portalSizes.fontSize } : {}),
3666
3708
  }, "aria-hidden": true, children: keyPreview.char }), document.body), accentMenu && (typeof document !== 'undefined' &&
3667
- reactDom.createPortal(jsxRuntime.jsx("div", { ref: accentMenuRef, className: styles$k.accentMenu, style: {
3709
+ reactDom.createPortal(jsxRuntime.jsx("div", { ref: accentMenuRef, className: clsx(styles$k.accentMenu, className), style: {
3668
3710
  top: accentMenu.top,
3669
3711
  left: accentMenu.left + accentMenuOffsetX,
3670
3712
  }, role: "listbox", "aria-label": `Opcoes de acento para ${accentMenu.sourceKey}`, children: Array.from({ length: Math.ceil(accentMenu.options.length / 5) }, (_, rowIndex) => accentMenu.options.slice(rowIndex * 5, rowIndex * 5 + 5)).map((rowOptions, rowIndex) => (jsxRuntime.jsx("div", { className: styles$k.accentMenuRow, children: rowOptions.map((option) => (jsxRuntime.jsx("button", { type: "button", className: styles$k.accentOption, style: {
@@ -3676,7 +3718,7 @@ const VirtualKeyboard = ({ variant = 'native', type = 'default', value, onChange
3676
3718
  event.stopPropagation();
3677
3719
  }, onClick: () => handleAccentSelect(option), children: option }, `${accentMenu.sourceKey}-${option}`))) }, rowIndex))) }), document.body))] })) : null;
3678
3720
  if (variant === 'native' && typeof document !== 'undefined') {
3679
- return reactDom.createPortal(jsxRuntime.jsx("div", { id: id, className: clsx(styles$k.overlay, { [styles$k.overlayOpen]: isOpen }, styles$k[isNumpadLayout ? 'layout--numeric' : 'layout--default'], className), style: nativeHeight ? { '--vkeyboard-native-height': nativeHeight } : undefined, children: keyboardEl }), document.body);
3721
+ return reactDom.createPortal(jsxRuntime.jsx("div", { id: id, className: clsx(styles$k.overlay, { [styles$k.overlayOpen]: isOpen }, styles$k[isNumpadLayout ? 'layout--numeric' : 'layout--default'], className), style: nativeHeight ? { '--vkeyboard-native-height': nativeHeight } : undefined, [DISMISS_OUTSIDE_IGNORE_ATTRIBUTE]: true, onPointerDownCapture: handleOverlayPointerDown, onPointerUpCapture: handleOverlayPointerUp, onPointerCancelCapture: handleOverlayPointerUp, children: keyboardEl }), document.body);
3680
3722
  }
3681
3723
  return (jsxRuntime.jsxs("div", { id: id, className: clsx(styles$k.container, styles$k[`mode--${variant}`], styles$k[isNumpadLayout ? 'layout--numeric' : 'layout--default'], className), children: [variant === 'fixed' && (jsxRuntime.jsx("div", { className: styles$k.textFieldContainer, children: jsxRuntime.jsx(TextField, { placeholder: placeholder, value: effectiveValue, onChange: onChange, helperText: helperText, error: error, errorMessage: errorMessage, readOnly: true, disableAutoComplete: true, maxLength: maxLength, attachedToVirtualKeyboard: true, className: styles$k.textFieldWrapper, scale: textFieldScale }) })), keyboardEl] }));
3682
3724
  };
@@ -4457,7 +4499,7 @@ const Simple = ({ items, type = 'multiple', selectedIds, onApplyFilter, placehol
4457
4499
  toggleItem(itemId, item);
4458
4500
  }
4459
4501
  }, children: [type === 'multiple' && (jsxRuntime.jsx(Checkbox, { checked: isSelected, disabled: item.disabled, label: "" })), item.icon && (jsxRuntime.jsx("span", { className: styles$d.itemIcon, children: item.icon })), jsxRuntime.jsx("span", { className: styles$d.itemText, children: item.text })] }, itemId));
4460
- })) : (jsxRuntime.jsx("li", { className: styles$d.noResults, role: "status", "aria-live": "polite", children: "Nenhum item encontrado" })) }), jsxRuntime.jsxs("div", { className: styles$d.footer, children: [jsxRuntime.jsx(Button, { fullWidth: true, variant: "outlined", onClick: handleClearFilter, children: "Limpar" }), jsxRuntime.jsx(Button, { fullWidth: true, onClick: handleApplyFilter, children: "Aplicar" })] })] }));
4502
+ })) : (jsxRuntime.jsx("li", { className: styles$d.noResults, role: "status", "aria-live": "polite", children: "Nenhum resultado encontrado" })) }), jsxRuntime.jsxs("div", { className: styles$d.footer, children: [jsxRuntime.jsx(Button, { fullWidth: true, variant: "outlined", onClick: handleClearFilter, children: "Limpar" }), jsxRuntime.jsx(Button, { fullWidth: true, onClick: handleApplyFilter, children: "Aplicar" })] })] }));
4461
4503
  return (jsxRuntime.jsx("div", { className: filterClass, id: id, ...rest, children: jsxRuntime.jsx(Popover, { open: isOpen, onOpenChange: handleOpenChange, side: side, align: align, onOpenAutoFocus: (e) => e.preventDefault(), trigger: triggerButton, content: popoverContent }) }));
4462
4504
  };
4463
4505
 
@@ -4630,7 +4672,7 @@ const ListItem = ({ id, className, variant = 'text', text, subText, disabled = f
4630
4672
  : children }))] }));
4631
4673
  };
4632
4674
 
4633
- var styles$a = {"content":"Menu-module__content___pnDF6","subContent":"Menu-module__subContent___O9T-y","itemsWrapper":"Menu-module__itemsWrapper___Fcg71","item":"Menu-module__item___S3HKY","subTrigger":"Menu-module__subTrigger___CdnJE","itemSubText":"Menu-module__itemSubText___U1HFP","itemIcon":"Menu-module__itemIcon___iyxmZ","wrapperText":"Menu-module__wrapperText___PomUe","itemText":"Menu-module__itemText___2fd2B","chevronIcon":"Menu-module__chevronIcon___Gda-U","searchWrapper":"Menu-module__searchWrapper___e0knQ","emptyState":"Menu-module__emptyState___3wh-S","loadingMore":"Menu-module__loadingMore___fUCvH"};
4675
+ var styles$a = {"content":"Menu-module__content___pnDF6","subContent":"Menu-module__subContent___O9T-y","itemsWrapper":"Menu-module__itemsWrapper___Fcg71","item":"Menu-module__item___S3HKY","subTrigger":"Menu-module__subTrigger___CdnJE","itemSubText":"Menu-module__itemSubText___U1HFP","itemIcon":"Menu-module__itemIcon___iyxmZ","wrapperText":"Menu-module__wrapperText___PomUe","itemText":"Menu-module__itemText___2fd2B","chevronIcon":"Menu-module__chevronIcon___Gda-U","searchWrapper":"Menu-module__searchWrapper___e0knQ","noResults":"Menu-module__noResults___f-Bi0","loadingMore":"Menu-module__loadingMore___fUCvH"};
4634
4676
 
4635
4677
  const MenuItem = React.memo(({ item, isSelected, onSelect }) => {
4636
4678
  const handleSelect = () => {
@@ -4884,7 +4926,7 @@ const Menu = ({ items, children, onItemSelect, search, enableInfiniteScroll, onS
4884
4926
  if (search) {
4885
4927
  e.stopPropagation();
4886
4928
  }
4887
- }, ...rest, children: [search && (jsxRuntime.jsx("div", { className: styles$a.searchWrapper, children: jsxRuntime.jsx(Search, { placeholder: "Buscar", onChange: handleSearchChange, value: searchInput, onKeyDown: handleSearchKeyDown }) })), jsxRuntime.jsxs("div", { className: styles$a.itemsWrapper, ref: itemsWrapperRef, style: { maxHeight: maxHeightStyle }, children: [filteredItems.length > 0 ? (filteredItems.map((item, index) => renderMenuItem(item, item.value || item.text || `item-${index}`))) : (jsxRuntime.jsx("div", { className: styles$a.emptyState, children: "Nenhum item encontrado" })), enableInfiniteScroll && isLoadingMore && (jsxRuntime.jsx("div", { className: styles$a.loadingMore, children: "Carregando mais itens..." })), enableInfiniteScroll && (jsxRuntime.jsx("div", { ref: sentinelRef, "data-scroll-sentinel": true, style: { height: '1px', visibility: 'hidden' } }))] })] }) })] }));
4929
+ }, ...rest, children: [search && (jsxRuntime.jsx("div", { className: styles$a.searchWrapper, children: jsxRuntime.jsx(Search, { placeholder: "Buscar", onChange: handleSearchChange, value: searchInput, onKeyDown: handleSearchKeyDown }) })), jsxRuntime.jsxs("div", { className: styles$a.itemsWrapper, ref: itemsWrapperRef, style: { maxHeight: maxHeightStyle }, children: [filteredItems.length > 0 ? (filteredItems.map((item, index) => renderMenuItem(item, item.value || item.text || `item-${index}`))) : (jsxRuntime.jsx("div", { className: styles$a.noResults, children: "Nenhum resultado encontrado" })), enableInfiniteScroll && isLoadingMore && (jsxRuntime.jsx("div", { className: styles$a.loadingMore, children: "Carregando mais itens..." })), enableInfiniteScroll && (jsxRuntime.jsx("div", { ref: sentinelRef, "data-scroll-sentinel": true, style: { height: '1px', visibility: 'hidden' } }))] })] }) })] }));
4888
4930
  };
4889
4931
 
4890
4932
  var styles$9 = {"modalOverlay":"Modal-module__modalOverlay___rI8Wz","modalContent":"Modal-module__modalContent___6Cgb1","modalContent--fullscreen":"Modal-module__modalContent--fullscreen___QeBlG","modalHeader":"Modal-module__modalHeader___IuHIg","modalCloseButton":"Modal-module__modalCloseButton___VoWHD","modalTitle":"Modal-module__modalTitle___9VDmr","modalBody":"Modal-module__modalBody___ohjQm","modalFooter":"Modal-module__modalFooter___TEqdK"};
@@ -4900,10 +4942,21 @@ const Modal = ({ isOpen = false, onClose, title, children, headerContent, closeO
4900
4942
  e.preventDefault();
4901
4943
  contentRef.current?.focus();
4902
4944
  };
4945
+ const handleInteractOutside = (e) => {
4946
+ // Ignora interações em elementos portalizados que se declararam isentos
4947
+ // (ex.: VirtualKeyboard em modo native), evitando fechamentos indesejados.
4948
+ if (isDismissOutsideIgnored(e.target)) {
4949
+ e.preventDefault();
4950
+ return;
4951
+ }
4952
+ if (!closeOnOverlayClick) {
4953
+ e.preventDefault();
4954
+ }
4955
+ };
4903
4956
  return (jsxRuntime.jsx(radixUi.Dialog.Root, { open: isOpen, onOpenChange: handleOpenChange, ...rest, children: jsxRuntime.jsxs(radixUi.Dialog.Portal, { children: [jsxRuntime.jsx(radixUi.Dialog.Overlay, { className: styles$9.modalOverlay }), jsxRuntime.jsxs(radixUi.Dialog.Content, { ref: contentRef, className: clsx(styles$9.modalContent, fullscreen && styles$9['modalContent--fullscreen'], className), id: id, style: {
4904
4957
  '--modal-custom-width': customWidth,
4905
4958
  '--modal-custom-height': customHeight,
4906
- }, onInteractOutside: !closeOnOverlayClick ? (e) => e.preventDefault() : undefined, onOpenAutoFocus: handleOpenAutoFocus, "aria-labelledby": id ? `${id}-title` : 'modal-title', tabIndex: -1, children: [(title || headerContent || closingButton) && (jsxRuntime.jsxs("header", { className: styles$9.modalHeader, children: [title && (jsxRuntime.jsx(radixUi.Dialog.Title, { className: styles$9.modalTitle, id: id ? `${id}-title` : 'modal-title', children: title })), headerContent && (jsxRuntime.jsx("div", { children: headerContent })), closingButton && (jsxRuntime.jsx("div", { className: styles$9.modalCloseButton, children: jsxRuntime.jsx(radixUi.Dialog.Close, { asChild: true, children: jsxRuntime.jsx(Button, { variant: "outlined", iconOnly: true, icon: jsxRuntime.jsx(reactIcons.Dismiss16Regular, {}), size: "lg", tooltipText: 'Fechar' }) }) }))] })), jsxRuntime.jsx("section", { className: styles$9.modalBody, children: children }), footer && (jsxRuntime.jsx("footer", { className: styles$9.modalFooter, children: footer }))] })] }) }));
4959
+ }, onInteractOutside: handleInteractOutside, onOpenAutoFocus: handleOpenAutoFocus, "aria-labelledby": id ? `${id}-title` : 'modal-title', tabIndex: -1, children: [(title || headerContent || closingButton) && (jsxRuntime.jsxs("header", { className: styles$9.modalHeader, children: [title && (jsxRuntime.jsx(radixUi.Dialog.Title, { className: styles$9.modalTitle, id: id ? `${id}-title` : 'modal-title', children: title })), headerContent && (jsxRuntime.jsx("div", { children: headerContent })), closingButton && (jsxRuntime.jsx("div", { className: styles$9.modalCloseButton, children: jsxRuntime.jsx(radixUi.Dialog.Close, { asChild: true, children: jsxRuntime.jsx(Button, { variant: "outlined", iconOnly: true, icon: jsxRuntime.jsx(reactIcons.Dismiss16Regular, {}), size: "lg", tooltipText: 'Fechar' }) }) }))] })), jsxRuntime.jsx("section", { className: styles$9.modalBody, children: children }), footer && (jsxRuntime.jsx("footer", { className: styles$9.modalFooter, children: footer }))] })] }) }));
4907
4960
  };
4908
4961
 
4909
4962
  var styles$8 = {"quantity":"Quantity-module__quantity___-vndR","quantityInput":"Quantity-module__quantityInput___xZG-v","disabled":"Quantity-module__disabled___X6p5l"};
@@ -5421,19 +5474,33 @@ function useSelectLogic({ value, required = false, search = false, onValueChange
5421
5474
  };
5422
5475
  }
5423
5476
 
5424
- const Select = ({ items, onValueChange, onOpenChange, variant, required = false, value, label, helperText, placeholder = 'Selecione', maxWidth, search = false, error, errorMessage, disabled = false, className, style, 'aria-label': ariaLabel, 'data-testid': testId, tooltipText, tooltipSide = 'bottom', tooltipAlign = 'start', enableInfiniteScroll = false, onScrollEnd, hasMore = true, isLoadingMore = false, enableApiSearch = false, onApiSearch, isSearching = false, scale = 1, ...rest }) => {
5477
+ const Select = ({ items, onValueChange, onOpenChange, variant, required = false, value, label, helperText, placeholder = 'Selecione', maxWidth, search = false, error, errorMessage, disabled = false, className, style, 'aria-label': ariaLabel, 'data-testid': testId, tooltipText, tooltipSide = 'bottom', tooltipAlign = 'start', enableInfiniteScroll = false, onScrollEnd, hasMore = true, isLoadingMore = false, enableApiSearch, onApiSearch, isSearching = false, scale = 1, ...rest }) => {
5425
5478
  const componentId = React.useId();
5426
5479
  const selectId = `select-${componentId}`;
5427
5480
  const viewportRef = React.useRef(null);
5428
5481
  const hasReachedEndRef = React.useRef(false);
5429
5482
  const wasLoadingMoreRef = React.useRef(false);
5483
+ const isApiSearch = enableApiSearch ?? Boolean(onApiSearch);
5484
+ React.useEffect(() => {
5485
+ if (process.env.NODE_ENV !== 'production' && enableApiSearch !== undefined) {
5486
+ console.warn('[Giro DS] `enableApiSearch` está depreciado. ' +
5487
+ 'A busca remota será ativada pela presença de `onApiSearch`. ' +
5488
+ 'Remoção psera feita futuramente.');
5489
+ }
5490
+ }, [enableApiSearch]);
5491
+ React.useEffect(() => {
5492
+ if (process.env.NODE_ENV !== 'production' && enableApiSearch === false && onApiSearch) {
5493
+ console.warn('[Giro DS] A combinação `enableApiSearch={false}` com `onApiSearch` ' +
5494
+ 'futuramente o comportamento ira mudar');
5495
+ }
5496
+ }, [enableApiSearch, onApiSearch]);
5430
5497
  const { state, actions, refs, utils, } = useSelectLogic({
5431
5498
  value,
5432
5499
  required,
5433
5500
  search,
5434
5501
  onValueChange,
5435
5502
  onOpenChange,
5436
- enableApiSearch,
5503
+ enableApiSearch: isApiSearch,
5437
5504
  onApiSearch,
5438
5505
  isSearching,
5439
5506
  error,
@@ -5471,9 +5538,9 @@ const Select = ({ items, onValueChange, onOpenChange, variant, required = false,
5471
5538
  }, [isLoadingMore, enableInfiniteScroll]);
5472
5539
  const displayText = React.useMemo(() => utils.getDisplayText(state.selectedValues, placeholder, variant, items), [state.selectedValues, placeholder, variant, items, utils]);
5473
5540
  const filteredItems = React.useMemo(() => {
5474
- const termToFilter = enableApiSearch ? state.searchTerm : state.searchInput;
5541
+ const termToFilter = isApiSearch ? state.searchTerm : state.searchInput;
5475
5542
  return utils.getFilteredItems(items, termToFilter);
5476
- }, [items, state.searchTerm, state.searchInput, enableApiSearch, utils]);
5543
+ }, [items, state.searchTerm, state.searchInput, isApiSearch, utils]);
5477
5544
  React.useEffect(() => {
5478
5545
  if (!state.isOpen || !enableInfiniteScroll || !onScrollEnd || isLoadingMore)
5479
5546
  return;
@@ -5496,7 +5563,7 @@ const Select = ({ items, onValueChange, onOpenChange, variant, required = false,
5496
5563
  const handleSearchChange = (e) => {
5497
5564
  const value = e.target.value;
5498
5565
  actions.setSearchInput(value);
5499
- if (enableApiSearch) {
5566
+ if (isApiSearch) {
5500
5567
  actions.setSearchTerm(value);
5501
5568
  }
5502
5569
  };
@@ -5521,7 +5588,7 @@ const Select = ({ items, onValueChange, onOpenChange, variant, required = false,
5521
5588
  };
5522
5589
  const handleClear = () => {
5523
5590
  actions.resetSearch();
5524
- if (enableApiSearch && onApiSearch) {
5591
+ if (isApiSearch && onApiSearch) {
5525
5592
  onApiSearch('');
5526
5593
  }
5527
5594
  };
@@ -5554,9 +5621,9 @@ var styles$5 = {"wrapper":"Table-module__wrapper___KMc04","tableContainer":"Tabl
5554
5621
 
5555
5622
  const EmptyState = ({ emptyIcon, emptyTitle, emptyText }) => (jsxRuntime.jsxs("div", { className: styles$5.tableEmpty, children: [jsxRuntime.jsx("div", { className: styles$5.tableEmptyContent, children: emptyIcon ?? jsxRuntime.jsx(reactIcons.SearchInfo20Regular, {}) }), jsxRuntime.jsxs("div", { className: styles$5.tableEmptyText, children: [jsxRuntime.jsx("h3", { className: styles$5.tableEmptyTitle, children: emptyTitle ?? 'Nenhum dado encontrado' }), jsxRuntime.jsx("p", { className: styles$5.tableEmptyCaption, children: emptyText ?? 'Nenhum registro encontrado' })] })] }));
5556
5623
 
5557
- var styles$4 = {"toggle":"ToggleButton-module__toggle___c1Ym-","item":"ToggleButton-module__item___2Qll-","toggle-lg":"ToggleButton-module__toggle-lg___8f3lo","item-lg":"ToggleButton-module__item-lg___479w-","toggle-sm":"ToggleButton-module__toggle-sm___SAGGb","item-sm":"ToggleButton-module__item-sm___4ju--","toggleIconLeft":"ToggleButton-module__toggleIconLeft___VwgKk","toggleWithIcon":"ToggleButton-module__toggleWithIcon___WbCr7","toggleIconOnly":"ToggleButton-module__toggleIconOnly___4iMEp","group":"ToggleButton-module__group___BoR-e"};
5624
+ var styles$4 = {"toggle":"ToggleButton-module__toggle___c1Ym-","item":"ToggleButton-module__item___2Qll-","toggle-lg":"ToggleButton-module__toggle-lg___8f3lo","item-lg":"ToggleButton-module__item-lg___479w-","toggle-sm":"ToggleButton-module__toggle-sm___SAGGb","item-sm":"ToggleButton-module__item-sm___4ju--","toggleIconLeft":"ToggleButton-module__toggleIconLeft___VwgKk","toggleWithIcon":"ToggleButton-module__toggleWithIcon___WbCr7","toggleIconOnly":"ToggleButton-module__toggleIconOnly___4iMEp","toggleLabel":"ToggleButton-module__toggleLabel___nCwcu","itemExpandOnSelect":"ToggleButton-module__itemExpandOnSelect___FVQj3","group":"ToggleButton-module__group___BoR-e","groupExpandable":"ToggleButton-module__groupExpandable___BWYWN"};
5558
5625
 
5559
- const Toggle = ({ pressed, defaultPressed, onPressedChange, disabled = false, className, label, id, size = 'lg', scale = 1, style, tooltipText, tooltipSide = 'top', tooltipAlign = 'center', icon, iconOnly = false, mode: _mode, selectionType: _type, value: _value, defaultValue: _defaultValue, onValueChange: _onValueChange, items: _items, ...rest }) => {
5626
+ const Toggle = ({ pressed, defaultPressed, onPressedChange, disabled = false, className, label, id, size = 'lg', scale = 1, style, tooltipText, tooltipSide = 'top', tooltipAlign = 'center', icon, iconOnly = false, mode: _mode, selectionType: _type, value: _value, defaultValue: _defaultValue, onValueChange: _onValueChange, items: _items, expandOnSelect: _expandOnSelect, requireSelection: _requireSelection, ...rest }) => {
5560
5627
  const toggle = (jsxRuntime.jsx(radixUi.Toggle.Root, { pressed: pressed, defaultPressed: defaultPressed, onPressedChange: onPressedChange, disabled: disabled, className: clsx(styles$4.toggle, styles$4[`toggle-${size}`], {
5561
5628
  [styles$4.toggleIconOnly]: iconOnly,
5562
5629
  [styles$4.toggleWithIcon]: !!icon && !iconOnly,
@@ -5567,7 +5634,20 @@ const Toggle = ({ pressed, defaultPressed, onPressedChange, disabled = false, cl
5567
5634
  return toggle;
5568
5635
  };
5569
5636
 
5570
- const ToggleGroup = ({ selectionType = 'single', value, defaultValue, onValueChange, disabled = false, items = [], className, id, size = 'lg', scale = 1, style, tooltipText, tooltipSide = 'top', tooltipAlign = 'center', mode: _mode, icon: _icon, iconOnly: _iconOnly, pressed: _pressed, defaultPressed: _defaultPressed, onPressedChange: _onPressedChange, ...rest }) => {
5637
+ const ToggleGroup = ({ selectionType = 'single', value, defaultValue, onValueChange, requireSelection = false, disabled = false, items = [], expandOnSelect: groupExpandOnSelect = false, className, id, size = 'lg', scale = 1, style, tooltipText, tooltipSide = 'top', tooltipAlign = 'center', mode: _mode, icon: _icon, iconOnly: _iconOnly, pressed: _pressed, defaultPressed: _defaultPressed, onPressedChange: _onPressedChange, ...rest }) => {
5638
+ const singleValueProp = value;
5639
+ const singleOnValueChange = onValueChange;
5640
+ const isSingleControlled = singleValueProp !== undefined;
5641
+ const [uncontrolledValue, setUncontrolledValue] = React.useState(defaultValue ?? '');
5642
+ const handleSingleValueChange = React.useCallback((next) => {
5643
+ if (requireSelection && !next) {
5644
+ return;
5645
+ }
5646
+ if (!isSingleControlled) {
5647
+ setUncontrolledValue(next);
5648
+ }
5649
+ singleOnValueChange?.(next);
5650
+ }, [requireSelection, isSingleControlled, singleOnValueChange]);
5571
5651
  const rootProps = selectionType === 'multiple'
5572
5652
  ? {
5573
5653
  type: 'multiple',
@@ -5575,16 +5655,27 @@ const ToggleGroup = ({ selectionType = 'single', value, defaultValue, onValueCha
5575
5655
  defaultValue: defaultValue,
5576
5656
  onValueChange: onValueChange,
5577
5657
  }
5578
- : {
5579
- type: 'single',
5580
- value: value,
5581
- defaultValue: defaultValue,
5582
- onValueChange: onValueChange,
5583
- };
5584
- const group = (jsxRuntime.jsx(radixUi.ToggleGroup.Root, { ...rootProps, disabled: disabled, className: clsx(styles$4.group, className), id: id, style: { '--giro-scale': scale, ...style }, ...rest, children: items.map((item) => (jsxRuntime.jsx(radixUi.ToggleGroup.Item, { value: item.value, disabled: item.disabled, className: clsx(styles$4.item, styles$4[`item-${size}`], {
5585
- [styles$4.toggleIconOnly]: item.iconOnly,
5586
- [styles$4.toggleWithIcon]: !!item.icon && !item.iconOnly,
5587
- }), style: { '--giro-scale': scale }, children: item.iconOnly ? (jsxRuntime.jsx("span", { className: styles$4.toggleIconLeft, "aria-hidden": "true", children: item.icon })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [item.icon && jsxRuntime.jsx("span", { className: styles$4.toggleIconLeft, "aria-hidden": "true", children: item.icon }), item.label] })) }, item.value))) }));
5658
+ : requireSelection
5659
+ ? {
5660
+ type: 'single',
5661
+ value: isSingleControlled ? singleValueProp : uncontrolledValue,
5662
+ onValueChange: handleSingleValueChange,
5663
+ }
5664
+ : {
5665
+ type: 'single',
5666
+ value: singleValueProp,
5667
+ defaultValue: defaultValue,
5668
+ onValueChange: singleOnValueChange,
5669
+ };
5670
+ const hasExpandableItems = groupExpandOnSelect || items.some((item) => item.expandOnSelect);
5671
+ const group = (jsxRuntime.jsx(radixUi.ToggleGroup.Root, { ...rootProps, disabled: disabled, className: clsx(styles$4.group, { [styles$4.groupExpandable]: hasExpandableItems }, className), id: id, style: { '--giro-scale': scale, ...style }, ...rest, children: items.map((item) => {
5672
+ const expandOnSelect = item.expandOnSelect ?? groupExpandOnSelect;
5673
+ return (jsxRuntime.jsx(radixUi.ToggleGroup.Item, { value: item.value, disabled: item.disabled, className: clsx(styles$4.item, styles$4[`item-${size}`], {
5674
+ [styles$4.toggleIconOnly]: item.iconOnly && !expandOnSelect,
5675
+ [styles$4.toggleWithIcon]: !!item.icon && !item.iconOnly && !expandOnSelect,
5676
+ [styles$4.itemExpandOnSelect]: expandOnSelect,
5677
+ }), style: { '--giro-scale': scale }, children: expandOnSelect ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [item.icon && jsxRuntime.jsx("span", { className: styles$4.toggleIconLeft, "aria-hidden": "true", children: item.icon }), jsxRuntime.jsx("span", { className: styles$4.toggleLabel, children: item.label })] })) : item.iconOnly ? (jsxRuntime.jsx("span", { className: styles$4.toggleIconLeft, "aria-hidden": "true", children: item.icon })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [item.icon && jsxRuntime.jsx("span", { className: styles$4.toggleIconLeft, "aria-hidden": "true", children: item.icon }), item.label] })) }, item.value));
5678
+ }) }));
5588
5679
  if (tooltipText) {
5589
5680
  return (jsxRuntime.jsx(Tooltip, { text: tooltipText, side: tooltipSide, align: tooltipAlign, children: group }));
5590
5681
  }
@@ -5737,7 +5828,7 @@ const TableV2 = ({ columns, data, rowSelection: rowSelectionConfig, enableSortin
5737
5828
  footer?.onPageChange?.(1);
5738
5829
  }
5739
5830
  header?.onSearchChange?.('');
5740
- }, placeholder: header.searchPlaceholder ?? 'Pesquisar...', className: styles$5.tableHeaderSearch }) })), header.viewToggle && (jsxRuntime.jsx(ToggleButton, { mode: "combined", selectionType: "single", value: activeView, onValueChange: (val) => {
5831
+ }, placeholder: header.searchPlaceholder ?? 'Pesquisar...', className: styles$5.tableHeaderSearch }) })), header.viewToggle && (jsxRuntime.jsx(ToggleButton, { mode: "combined", selectionType: "single", value: activeView, requireSelection: true, onValueChange: (val) => {
5741
5832
  if (!val)
5742
5833
  return;
5743
5834
  setActiveView(val);