@giro-ds/react 12.5.0 → 12.6.0

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
@@ -2138,6 +2138,12 @@ class DateLib {
2138
2138
  * @param overrides Custom overrides for the date library functions.
2139
2139
  */
2140
2140
  constructor(options, overrides) {
2141
+ /**
2142
+ * Reference to the built-in Date constructor.
2143
+ *
2144
+ * @deprecated Use `newDate()` or `today()`.
2145
+ */
2146
+ this.Date = Date;
2141
2147
  /**
2142
2148
  * Creates a new `Date` object representing today's date.
2143
2149
  *
@@ -2151,8 +2157,7 @@ class DateLib {
2151
2157
  if (this.options.timeZone) {
2152
2158
  return TZDate.tz(this.options.timeZone);
2153
2159
  }
2154
- const DateCtor = this.options.Date ?? Date;
2155
- return new DateCtor();
2160
+ return new this.Date();
2156
2161
  };
2157
2162
  /**
2158
2163
  * Creates a new `Date` object with the specified year, month, and day.
@@ -2871,8 +2876,8 @@ const Callout = ({ variant = 'neutral', title, text, icon, onDismiss, dismiss, b
2871
2876
 
2872
2877
  var styles$p = {"card":"Card-module__card___LzN-3","card--hoverable":"Card-module__card--hoverable___orpJZ"};
2873
2878
 
2874
- function Card({ children, className, hoverable }) {
2875
- return (jsxRuntime.jsx("main", { className: clsx(styles$p['card'], hoverable && styles$p['card--hoverable'], className), children: children }));
2879
+ function Card({ children, className, hoverable, borderRadius }) {
2880
+ return (jsxRuntime.jsx("div", { className: clsx(styles$p['card'], hoverable && styles$p['card--hoverable'], className), style: borderRadius !== undefined ? { borderRadius: `var(--border-radius-${borderRadius})` } : undefined, children: children }));
2876
2881
  }
2877
2882
 
2878
2883
  const CheckSmall = ({ className = '', width = 12, height = 10, fill = 'white', ...restProps }) => {
@@ -3107,6 +3112,29 @@ const SHIFT_TOGGLES = {
3107
3112
 
3108
3113
  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
3114
 
3115
+ /**
3116
+ * Atributo usado para marcar raízes de elementos portalizados (ex.: renderizados via
3117
+ * `createPortal` em `document.body`) que devem ser ignorados pela lógica de
3118
+ * "clique/foco fora" de camadas dispensáveis do Radix UI (Dialog, Popover, DropdownMenu etc.).
3119
+ *
3120
+ * Componentes que renderizam conteúdo fora da árvore DOM do elemento pai (como o
3121
+ * `VirtualKeyboard` em modo `native`) devem adicionar este atributo à raiz portalizada
3122
+ * para evitar que o Radix trate cliques nesse conteúdo como "fora" do componente,
3123
+ * o que causaria fechamentos indesejados quando usados dentro de um `Modal` (ou outro
3124
+ * componente baseado em Radix Dialog/Popover).
3125
+ */
3126
+ const DISMISS_OUTSIDE_IGNORE_ATTRIBUTE = 'data-dismiss-outside-ignore';
3127
+ /**
3128
+ * Verifica se o alvo de um evento de "interação fora" (Radix `onInteractOutside`,
3129
+ * `onPointerDownOutside`, `onFocusOutside`) está dentro de um elemento marcado com
3130
+ * {@link DISMISS_OUTSIDE_IGNORE_ATTRIBUTE}.
3131
+ */
3132
+ const isDismissOutsideIgnored = (target) => {
3133
+ if (!(target instanceof Element))
3134
+ return false;
3135
+ return target.closest(`[${DISMISS_OUTSIDE_IGNORE_ATTRIBUTE}]`) !== null;
3136
+ };
3137
+
3110
3138
  const LONG_PRESS_DELAY_MS = 400;
3111
3139
  const ACCENT_OPTIONS = {
3112
3140
  a: ['a', 'á', 'à', 'â', 'ã', 'ä', 'å', 'æ', '@', 'ª'],
@@ -3471,6 +3499,25 @@ const VirtualKeyboard = ({ variant = 'native', type = 'default', value, onChange
3471
3499
  layoutName,
3472
3500
  capsLockOn,
3473
3501
  ]);
3502
+ // Cobre toda a área do overlay do teclado (inclusive espaços/paddings fora do
3503
+ // `keyboardWrapperRef`, como o preview de tecla e o menu de acento portalizados),
3504
+ // garantindo que `isKeyboardInteractingRef` não seja perdido em cliques que não
3505
+ // caem exatamente sobre um `.hg-button`. Isso evita que o teclado feche sozinho
3506
+ // (via blur do targetRef) ao interagir com áreas adjacentes do próprio teclado.
3507
+ const handleOverlayPointerDown = React.useCallback((event) => {
3508
+ if (keyboardWrapperRef.current?.contains(event.target))
3509
+ return;
3510
+ isKeyboardInteractingRef.current = true;
3511
+ if (hideTimeoutRef.current !== null) {
3512
+ clearTimeout(hideTimeoutRef.current);
3513
+ }
3514
+ }, []);
3515
+ const handleOverlayPointerUp = React.useCallback((event) => {
3516
+ if (keyboardWrapperRef.current?.contains(event.target))
3517
+ return;
3518
+ isKeyboardInteractingRef.current = false;
3519
+ scheduleHideIfBlurred();
3520
+ }, [scheduleHideIfBlurred]);
3474
3521
  const handleAccentSelect = React.useCallback((accentedChar) => {
3475
3522
  const currentValue = valueRef.current;
3476
3523
  const baseLayout = type === 'numeric' ? 'abc' : 'default';
@@ -3643,7 +3690,7 @@ const VirtualKeyboard = ({ variant = 'native', type = 'default', value, onChange
3643
3690
  if (instance) {
3644
3691
  instance.setInput(valueRef.current);
3645
3692
  }
3646
- }, layoutName: layoutName, layout: activeLayout, theme: 'hg-theme-default', display: keyboardDisplay, onChange: handleChange, onKeyPress: handleKeyPress, preventMouseDownDefault: true }), (() => {
3693
+ }, layoutName: layoutName, layout: activeLayout, theme: 'hg-theme-default', display: keyboardDisplay, onChange: handleChange, onKeyPress: handleKeyPress, preventMouseDownDefault: true, disableButtonHold: true }), (() => {
3647
3694
  const shiftCount = { current: 0 };
3648
3695
  return iconSlots.map((slot) => {
3649
3696
  const key = slot.getAttribute('data-icon-key');
@@ -3657,14 +3704,14 @@ const VirtualKeyboard = ({ variant = 'native', type = 'default', value, onChange
3657
3704
  }
3658
3705
  return reactDom.createPortal(React.createElement(Icon), slot, `icon-${key}`);
3659
3706
  });
3660
- })(), keyPreview && typeof document !== 'undefined' && reactDom.createPortal(jsxRuntime.jsx("div", { ref: keyPreviewRef, className: styles$k.keyPreview, style: {
3707
+ })(), keyPreview && typeof document !== 'undefined' && reactDom.createPortal(jsxRuntime.jsx("div", { ref: keyPreviewRef, className: clsx(styles$k.keyPreview, className), style: {
3661
3708
  top: keyPreview.top,
3662
3709
  left: keyPreview.left + keyPreviewOffsetX,
3663
3710
  width: portalSizes.preview,
3664
3711
  height: portalSizes.preview,
3665
3712
  ...(portalSizes.fontSize ? { fontSize: portalSizes.fontSize } : {}),
3666
3713
  }, "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: {
3714
+ reactDom.createPortal(jsxRuntime.jsx("div", { ref: accentMenuRef, className: clsx(styles$k.accentMenu, className), style: {
3668
3715
  top: accentMenu.top,
3669
3716
  left: accentMenu.left + accentMenuOffsetX,
3670
3717
  }, 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,9 +3723,9 @@ const VirtualKeyboard = ({ variant = 'native', type = 'default', value, onChange
3676
3723
  event.stopPropagation();
3677
3724
  }, onClick: () => handleAccentSelect(option), children: option }, `${accentMenu.sourceKey}-${option}`))) }, rowIndex))) }), document.body))] })) : null;
3678
3725
  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);
3726
+ 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
3727
  }
3681
- 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] }));
3728
+ 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, disableAutoComplete: true, maxLength: maxLength, attachedToVirtualKeyboard: true, className: styles$k.textFieldWrapper, scale: textFieldScale }) })), keyboardEl] }));
3682
3729
  };
3683
3730
 
3684
3731
  var styles$j = {"container":"TextField-module__container___WJHFR","inputWrapper":"TextField-module__inputWrapper___INjfd","inputContainer":"TextField-module__inputContainer___3EsFJ","icon":"TextField-module__icon___p1vwi","clearButton":"TextField-module__clearButton___kgOot","inputWithIcon":"TextField-module__inputWithIcon___shqkL","helperText":"TextField-module__helperText___d5QGC","error":"TextField-module__error___IGQzp","disabled":"TextField-module__disabled___roIKP","attachedToVirtualKeyboard":"TextField-module__attachedToVirtualKeyboard___fuO2O","errorWithMessage":"TextField-module__errorWithMessage___m-5AA","clearButtonIcon":"TextField-module__clearButtonIcon___Z2iyc"};
@@ -3881,7 +3928,7 @@ function validatePartialDate(value, locale = 'pt-br') {
3881
3928
  return 'incomplete';
3882
3929
  }
3883
3930
 
3884
- const DatePicker = ({ locale = 'pt-br', calendarSide = 'bottom', calendarAlign = 'start', helperText, required = false, label = 'Data', value, defaultValue, onChange, disabled = false, error: externalError, minDate, maxDate, 'data-testid': testId, scale = 1, id, className, style, ...rest }) => {
3931
+ const DatePicker = ({ locale = 'pt-br', calendarSide = 'bottom', calendarAlign = 'start', helperText, required = false, label, value, defaultValue, onChange, disabled = false, error: externalError, minDate, maxDate, 'data-testid': testId, scale = 1, id, className, style, ...rest }) => {
3885
3932
  const fieldId = React.useId();
3886
3933
  const calendarId = `${fieldId}-calendar`;
3887
3934
  const containerStyle = { '--giro-scale': scale };
@@ -4457,7 +4504,7 @@ const Simple = ({ items, type = 'multiple', selectedIds, onApplyFilter, placehol
4457
4504
  toggleItem(itemId, item);
4458
4505
  }
4459
4506
  }, 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" })] })] }));
4507
+ })) : (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
4508
  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
4509
  };
4463
4510
 
@@ -4630,7 +4677,7 @@ const ListItem = ({ id, className, variant = 'text', text, subText, disabled = f
4630
4677
  : children }))] }));
4631
4678
  };
4632
4679
 
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"};
4680
+ 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
4681
 
4635
4682
  const MenuItem = React.memo(({ item, isSelected, onSelect }) => {
4636
4683
  const handleSelect = () => {
@@ -4884,7 +4931,7 @@ const Menu = ({ items, children, onItemSelect, search, enableInfiniteScroll, onS
4884
4931
  if (search) {
4885
4932
  e.stopPropagation();
4886
4933
  }
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' } }))] })] }) })] }));
4934
+ }, ...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
4935
  };
4889
4936
 
4890
4937
  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 +4947,21 @@ const Modal = ({ isOpen = false, onClose, title, children, headerContent, closeO
4900
4947
  e.preventDefault();
4901
4948
  contentRef.current?.focus();
4902
4949
  };
4950
+ const handleInteractOutside = (e) => {
4951
+ // Ignora interações em elementos portalizados que se declararam isentos
4952
+ // (ex.: VirtualKeyboard em modo native), evitando fechamentos indesejados.
4953
+ if (isDismissOutsideIgnored(e.target)) {
4954
+ e.preventDefault();
4955
+ return;
4956
+ }
4957
+ if (!closeOnOverlayClick) {
4958
+ e.preventDefault();
4959
+ }
4960
+ };
4903
4961
  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
4962
  '--modal-custom-width': customWidth,
4905
4963
  '--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 }))] })] }) }));
4964
+ }, 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
4965
  };
4908
4966
 
4909
4967
  var styles$8 = {"quantity":"Quantity-module__quantity___-vndR","quantityInput":"Quantity-module__quantityInput___xZG-v","disabled":"Quantity-module__disabled___X6p5l"};
@@ -5421,19 +5479,33 @@ function useSelectLogic({ value, required = false, search = false, onValueChange
5421
5479
  };
5422
5480
  }
5423
5481
 
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 }) => {
5482
+ 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
5483
  const componentId = React.useId();
5426
5484
  const selectId = `select-${componentId}`;
5427
5485
  const viewportRef = React.useRef(null);
5428
5486
  const hasReachedEndRef = React.useRef(false);
5429
5487
  const wasLoadingMoreRef = React.useRef(false);
5488
+ const isApiSearch = enableApiSearch ?? Boolean(onApiSearch);
5489
+ React.useEffect(() => {
5490
+ if (process.env.NODE_ENV !== 'production' && enableApiSearch !== undefined) {
5491
+ console.warn('[Giro DS] `enableApiSearch` está depreciado. ' +
5492
+ 'A busca remota será ativada pela presença de `onApiSearch`. ' +
5493
+ 'Remoção psera feita futuramente.');
5494
+ }
5495
+ }, [enableApiSearch]);
5496
+ React.useEffect(() => {
5497
+ if (process.env.NODE_ENV !== 'production' && enableApiSearch === false && onApiSearch) {
5498
+ console.warn('[Giro DS] A combinação `enableApiSearch={false}` com `onApiSearch` ' +
5499
+ 'futuramente o comportamento ira mudar');
5500
+ }
5501
+ }, [enableApiSearch, onApiSearch]);
5430
5502
  const { state, actions, refs, utils, } = useSelectLogic({
5431
5503
  value,
5432
5504
  required,
5433
5505
  search,
5434
5506
  onValueChange,
5435
5507
  onOpenChange,
5436
- enableApiSearch,
5508
+ enableApiSearch: isApiSearch,
5437
5509
  onApiSearch,
5438
5510
  isSearching,
5439
5511
  error,
@@ -5471,9 +5543,9 @@ const Select = ({ items, onValueChange, onOpenChange, variant, required = false,
5471
5543
  }, [isLoadingMore, enableInfiniteScroll]);
5472
5544
  const displayText = React.useMemo(() => utils.getDisplayText(state.selectedValues, placeholder, variant, items), [state.selectedValues, placeholder, variant, items, utils]);
5473
5545
  const filteredItems = React.useMemo(() => {
5474
- const termToFilter = enableApiSearch ? state.searchTerm : state.searchInput;
5546
+ const termToFilter = isApiSearch ? state.searchTerm : state.searchInput;
5475
5547
  return utils.getFilteredItems(items, termToFilter);
5476
- }, [items, state.searchTerm, state.searchInput, enableApiSearch, utils]);
5548
+ }, [items, state.searchTerm, state.searchInput, isApiSearch, utils]);
5477
5549
  React.useEffect(() => {
5478
5550
  if (!state.isOpen || !enableInfiniteScroll || !onScrollEnd || isLoadingMore)
5479
5551
  return;
@@ -5496,7 +5568,7 @@ const Select = ({ items, onValueChange, onOpenChange, variant, required = false,
5496
5568
  const handleSearchChange = (e) => {
5497
5569
  const value = e.target.value;
5498
5570
  actions.setSearchInput(value);
5499
- if (enableApiSearch) {
5571
+ if (isApiSearch) {
5500
5572
  actions.setSearchTerm(value);
5501
5573
  }
5502
5574
  };
@@ -5521,7 +5593,7 @@ const Select = ({ items, onValueChange, onOpenChange, variant, required = false,
5521
5593
  };
5522
5594
  const handleClear = () => {
5523
5595
  actions.resetSearch();
5524
- if (enableApiSearch && onApiSearch) {
5596
+ if (isApiSearch && onApiSearch) {
5525
5597
  onApiSearch('');
5526
5598
  }
5527
5599
  };
@@ -5554,9 +5626,9 @@ var styles$5 = {"wrapper":"Table-module__wrapper___KMc04","tableContainer":"Tabl
5554
5626
 
5555
5627
  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
5628
 
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"};
5629
+ 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
5630
 
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 }) => {
5631
+ 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
5632
  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
5633
  [styles$4.toggleIconOnly]: iconOnly,
5562
5634
  [styles$4.toggleWithIcon]: !!icon && !iconOnly,
@@ -5567,7 +5639,20 @@ const Toggle = ({ pressed, defaultPressed, onPressedChange, disabled = false, cl
5567
5639
  return toggle;
5568
5640
  };
5569
5641
 
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 }) => {
5642
+ 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 }) => {
5643
+ const singleValueProp = value;
5644
+ const singleOnValueChange = onValueChange;
5645
+ const isSingleControlled = singleValueProp !== undefined;
5646
+ const [uncontrolledValue, setUncontrolledValue] = React.useState(defaultValue ?? '');
5647
+ const handleSingleValueChange = React.useCallback((next) => {
5648
+ if (requireSelection && !next) {
5649
+ return;
5650
+ }
5651
+ if (!isSingleControlled) {
5652
+ setUncontrolledValue(next);
5653
+ }
5654
+ singleOnValueChange?.(next);
5655
+ }, [requireSelection, isSingleControlled, singleOnValueChange]);
5571
5656
  const rootProps = selectionType === 'multiple'
5572
5657
  ? {
5573
5658
  type: 'multiple',
@@ -5575,16 +5660,27 @@ const ToggleGroup = ({ selectionType = 'single', value, defaultValue, onValueCha
5575
5660
  defaultValue: defaultValue,
5576
5661
  onValueChange: onValueChange,
5577
5662
  }
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))) }));
5663
+ : requireSelection
5664
+ ? {
5665
+ type: 'single',
5666
+ value: isSingleControlled ? singleValueProp : uncontrolledValue,
5667
+ onValueChange: handleSingleValueChange,
5668
+ }
5669
+ : {
5670
+ type: 'single',
5671
+ value: singleValueProp,
5672
+ defaultValue: defaultValue,
5673
+ onValueChange: singleOnValueChange,
5674
+ };
5675
+ const hasExpandableItems = groupExpandOnSelect || items.some((item) => item.expandOnSelect);
5676
+ 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) => {
5677
+ const expandOnSelect = item.expandOnSelect ?? groupExpandOnSelect;
5678
+ return (jsxRuntime.jsx(radixUi.ToggleGroup.Item, { value: item.value, disabled: item.disabled, className: clsx(styles$4.item, styles$4[`item-${size}`], {
5679
+ [styles$4.toggleIconOnly]: item.iconOnly && !expandOnSelect,
5680
+ [styles$4.toggleWithIcon]: !!item.icon && !item.iconOnly && !expandOnSelect,
5681
+ [styles$4.itemExpandOnSelect]: expandOnSelect,
5682
+ }), 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));
5683
+ }) }));
5588
5684
  if (tooltipText) {
5589
5685
  return (jsxRuntime.jsx(Tooltip, { text: tooltipText, side: tooltipSide, align: tooltipAlign, children: group }));
5590
5686
  }
@@ -5737,7 +5833,7 @@ const TableV2 = ({ columns, data, rowSelection: rowSelectionConfig, enableSortin
5737
5833
  footer?.onPageChange?.(1);
5738
5834
  }
5739
5835
  header?.onSearchChange?.('');
5740
- }, placeholder: header.searchPlaceholder ?? 'Pesquisar...', className: styles$5.tableHeaderSearch }) })), header.viewToggle && (jsxRuntime.jsx(ToggleButton, { mode: "combined", selectionType: "single", value: activeView, onValueChange: (val) => {
5836
+ }, placeholder: header.searchPlaceholder ?? 'Pesquisar...', className: styles$5.tableHeaderSearch }) })), header.viewToggle && (jsxRuntime.jsx(ToggleButton, { mode: "combined", selectionType: "single", value: activeView, requireSelection: true, onValueChange: (val) => {
5741
5837
  if (!val)
5742
5838
  return;
5743
5839
  setActiveView(val);