@giro-ds/react 12.4.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 +119 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +33 -6
- package/dist/index.esm.js +119 -28
- package/dist/index.esm.js.map +1 -1
- package/dist/styles.css +2 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -849,15 +849,27 @@ interface MenuProps extends ScalableProps {
|
|
|
849
849
|
align?: 'start' | 'end' | 'center';
|
|
850
850
|
/** Altura máxima do menu */
|
|
851
851
|
maxHeight?: number | string;
|
|
852
|
-
/**
|
|
852
|
+
/**
|
|
853
|
+
* @deprecated Futuramente o carregamento remoto será removido do Menu.
|
|
854
|
+
* Para seleção de dados remotos, utilize o componente recomendado
|
|
855
|
+
* no guia de migração.
|
|
856
|
+
*/
|
|
853
857
|
enableInfiniteScroll?: boolean;
|
|
854
|
-
/**
|
|
858
|
+
/**
|
|
859
|
+
* @deprecated Futuramente será removido do Menu.
|
|
860
|
+
*/
|
|
855
861
|
onScrollEnd?: () => void;
|
|
856
|
-
/**
|
|
862
|
+
/**
|
|
863
|
+
* @deprecated Futuramente será removido do Menu.
|
|
864
|
+
*/
|
|
857
865
|
isLoadingMore?: boolean;
|
|
858
|
-
/**
|
|
866
|
+
/**
|
|
867
|
+
* @deprecated Futuramente a busca remota será removida do Menu.
|
|
868
|
+
*/
|
|
859
869
|
enableApiSearch?: boolean;
|
|
860
|
-
/**
|
|
870
|
+
/**
|
|
871
|
+
* @deprecated Futuramente a busca remota será removida do Menu.
|
|
872
|
+
*/
|
|
861
873
|
onApiSearch?: (searchTerm: string) => void;
|
|
862
874
|
/** Callback executado quando o menu abre/fecha: (open) => void */
|
|
863
875
|
onOpenChange?: (open: boolean) => void;
|
|
@@ -1349,7 +1361,10 @@ interface SelectPropsBase extends ScalableProps {
|
|
|
1349
1361
|
hasMore?: boolean;
|
|
1350
1362
|
/** Estado de carregamento de mais itens */
|
|
1351
1363
|
isLoadingMore?: boolean;
|
|
1352
|
-
/**
|
|
1364
|
+
/**
|
|
1365
|
+
* @deprecated Futuramente a busca remota será identificada pela presença de
|
|
1366
|
+
* `onApiSearch`. Futuramente será removida.
|
|
1367
|
+
*/
|
|
1353
1368
|
enableApiSearch?: boolean;
|
|
1354
1369
|
/** Callback executado na busca via API: (term) => void */
|
|
1355
1370
|
onApiSearch?: (term: string) => void;
|
|
@@ -2092,6 +2107,8 @@ interface ToggleGroupItem {
|
|
|
2092
2107
|
icon?: ReactNode;
|
|
2093
2108
|
/** Exibe somente o ícone, sem label */
|
|
2094
2109
|
iconOnly?: boolean;
|
|
2110
|
+
/** Exibe somente o ícone quando não selecionado; ícone + label quando selecionado */
|
|
2111
|
+
expandOnSelect?: boolean;
|
|
2095
2112
|
/** Desabilita o item, impedindo sua seleção */
|
|
2096
2113
|
disabled?: boolean;
|
|
2097
2114
|
}
|
|
@@ -2131,6 +2148,16 @@ type ToggleGroupMultipleSelectionProps = {
|
|
|
2131
2148
|
type ToggleGroupProps = {
|
|
2132
2149
|
/** Items do grupo de toggles */
|
|
2133
2150
|
items?: ToggleGroupItem[];
|
|
2151
|
+
/**
|
|
2152
|
+
* Exibe somente o ícone dos itens não selecionados; ícone + label no item selecionado.
|
|
2153
|
+
* Aplica-se a todos os itens do grupo. Pode ser sobrescrito individualmente via `item.expandOnSelect`.
|
|
2154
|
+
*/
|
|
2155
|
+
expandOnSelect?: boolean;
|
|
2156
|
+
/**
|
|
2157
|
+
* Impede desmarcar o item ativo ao clicar novamente nele, garantindo que sempre haja uma seleção.
|
|
2158
|
+
* Aplica-se somente quando `selectionType="single"` (ignorado em `"multiple"`).
|
|
2159
|
+
*/
|
|
2160
|
+
requireSelection?: boolean;
|
|
2134
2161
|
} & (ToggleGroupSingleSelectionProps | ToggleGroupMultipleSelectionProps);
|
|
2135
2162
|
/**
|
|
2136
2163
|
* Props do componente ToggleButton
|
package/dist/index.esm.js
CHANGED
|
@@ -3088,6 +3088,29 @@ const SHIFT_TOGGLES = {
|
|
|
3088
3088
|
|
|
3089
3089
|
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"};
|
|
3090
3090
|
|
|
3091
|
+
/**
|
|
3092
|
+
* Atributo usado para marcar raízes de elementos portalizados (ex.: renderizados via
|
|
3093
|
+
* `createPortal` em `document.body`) que devem ser ignorados pela lógica de
|
|
3094
|
+
* "clique/foco fora" de camadas dispensáveis do Radix UI (Dialog, Popover, DropdownMenu etc.).
|
|
3095
|
+
*
|
|
3096
|
+
* Componentes que renderizam conteúdo fora da árvore DOM do elemento pai (como o
|
|
3097
|
+
* `VirtualKeyboard` em modo `native`) devem adicionar este atributo à raiz portalizada
|
|
3098
|
+
* para evitar que o Radix trate cliques nesse conteúdo como "fora" do componente,
|
|
3099
|
+
* o que causaria fechamentos indesejados quando usados dentro de um `Modal` (ou outro
|
|
3100
|
+
* componente baseado em Radix Dialog/Popover).
|
|
3101
|
+
*/
|
|
3102
|
+
const DISMISS_OUTSIDE_IGNORE_ATTRIBUTE = 'data-dismiss-outside-ignore';
|
|
3103
|
+
/**
|
|
3104
|
+
* Verifica se o alvo de um evento de "interação fora" (Radix `onInteractOutside`,
|
|
3105
|
+
* `onPointerDownOutside`, `onFocusOutside`) está dentro de um elemento marcado com
|
|
3106
|
+
* {@link DISMISS_OUTSIDE_IGNORE_ATTRIBUTE}.
|
|
3107
|
+
*/
|
|
3108
|
+
const isDismissOutsideIgnored = (target) => {
|
|
3109
|
+
if (!(target instanceof Element))
|
|
3110
|
+
return false;
|
|
3111
|
+
return target.closest(`[${DISMISS_OUTSIDE_IGNORE_ATTRIBUTE}]`) !== null;
|
|
3112
|
+
};
|
|
3113
|
+
|
|
3091
3114
|
const LONG_PRESS_DELAY_MS = 400;
|
|
3092
3115
|
const ACCENT_OPTIONS = {
|
|
3093
3116
|
a: ['a', 'á', 'à', 'â', 'ã', 'ä', 'å', 'æ', '@', 'ª'],
|
|
@@ -3452,6 +3475,25 @@ const VirtualKeyboard = ({ variant = 'native', type = 'default', value, onChange
|
|
|
3452
3475
|
layoutName,
|
|
3453
3476
|
capsLockOn,
|
|
3454
3477
|
]);
|
|
3478
|
+
// Cobre toda a área do overlay do teclado (inclusive espaços/paddings fora do
|
|
3479
|
+
// `keyboardWrapperRef`, como o preview de tecla e o menu de acento portalizados),
|
|
3480
|
+
// garantindo que `isKeyboardInteractingRef` não seja perdido em cliques que não
|
|
3481
|
+
// caem exatamente sobre um `.hg-button`. Isso evita que o teclado feche sozinho
|
|
3482
|
+
// (via blur do targetRef) ao interagir com áreas adjacentes do próprio teclado.
|
|
3483
|
+
const handleOverlayPointerDown = useCallback((event) => {
|
|
3484
|
+
if (keyboardWrapperRef.current?.contains(event.target))
|
|
3485
|
+
return;
|
|
3486
|
+
isKeyboardInteractingRef.current = true;
|
|
3487
|
+
if (hideTimeoutRef.current !== null) {
|
|
3488
|
+
clearTimeout(hideTimeoutRef.current);
|
|
3489
|
+
}
|
|
3490
|
+
}, []);
|
|
3491
|
+
const handleOverlayPointerUp = useCallback((event) => {
|
|
3492
|
+
if (keyboardWrapperRef.current?.contains(event.target))
|
|
3493
|
+
return;
|
|
3494
|
+
isKeyboardInteractingRef.current = false;
|
|
3495
|
+
scheduleHideIfBlurred();
|
|
3496
|
+
}, [scheduleHideIfBlurred]);
|
|
3455
3497
|
const handleAccentSelect = useCallback((accentedChar) => {
|
|
3456
3498
|
const currentValue = valueRef.current;
|
|
3457
3499
|
const baseLayout = type === 'numeric' ? 'abc' : 'default';
|
|
@@ -3624,7 +3666,7 @@ const VirtualKeyboard = ({ variant = 'native', type = 'default', value, onChange
|
|
|
3624
3666
|
if (instance) {
|
|
3625
3667
|
instance.setInput(valueRef.current);
|
|
3626
3668
|
}
|
|
3627
|
-
}, layoutName: layoutName, layout: activeLayout, theme: 'hg-theme-default', display: keyboardDisplay, onChange: handleChange, onKeyPress: handleKeyPress, preventMouseDownDefault: true }), (() => {
|
|
3669
|
+
}, layoutName: layoutName, layout: activeLayout, theme: 'hg-theme-default', display: keyboardDisplay, onChange: handleChange, onKeyPress: handleKeyPress, preventMouseDownDefault: true, disableButtonHold: true }), (() => {
|
|
3628
3670
|
const shiftCount = { current: 0 };
|
|
3629
3671
|
return iconSlots.map((slot) => {
|
|
3630
3672
|
const key = slot.getAttribute('data-icon-key');
|
|
@@ -3638,14 +3680,14 @@ const VirtualKeyboard = ({ variant = 'native', type = 'default', value, onChange
|
|
|
3638
3680
|
}
|
|
3639
3681
|
return createPortal(createElement(Icon), slot, `icon-${key}`);
|
|
3640
3682
|
});
|
|
3641
|
-
})(), keyPreview && typeof document !== 'undefined' && createPortal(jsx("div", { ref: keyPreviewRef, className: styles$k.keyPreview, style: {
|
|
3683
|
+
})(), keyPreview && typeof document !== 'undefined' && createPortal(jsx("div", { ref: keyPreviewRef, className: clsx(styles$k.keyPreview, className), style: {
|
|
3642
3684
|
top: keyPreview.top,
|
|
3643
3685
|
left: keyPreview.left + keyPreviewOffsetX,
|
|
3644
3686
|
width: portalSizes.preview,
|
|
3645
3687
|
height: portalSizes.preview,
|
|
3646
3688
|
...(portalSizes.fontSize ? { fontSize: portalSizes.fontSize } : {}),
|
|
3647
3689
|
}, "aria-hidden": true, children: keyPreview.char }), document.body), accentMenu && (typeof document !== 'undefined' &&
|
|
3648
|
-
createPortal(jsx("div", { ref: accentMenuRef, className: styles$k.accentMenu, style: {
|
|
3690
|
+
createPortal(jsx("div", { ref: accentMenuRef, className: clsx(styles$k.accentMenu, className), style: {
|
|
3649
3691
|
top: accentMenu.top,
|
|
3650
3692
|
left: accentMenu.left + accentMenuOffsetX,
|
|
3651
3693
|
}, 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) => (jsx("div", { className: styles$k.accentMenuRow, children: rowOptions.map((option) => (jsx("button", { type: "button", className: styles$k.accentOption, style: {
|
|
@@ -3657,7 +3699,7 @@ const VirtualKeyboard = ({ variant = 'native', type = 'default', value, onChange
|
|
|
3657
3699
|
event.stopPropagation();
|
|
3658
3700
|
}, onClick: () => handleAccentSelect(option), children: option }, `${accentMenu.sourceKey}-${option}`))) }, rowIndex))) }), document.body))] })) : null;
|
|
3659
3701
|
if (variant === 'native' && typeof document !== 'undefined') {
|
|
3660
|
-
return createPortal(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);
|
|
3702
|
+
return createPortal(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);
|
|
3661
3703
|
}
|
|
3662
3704
|
return (jsxs("div", { id: id, className: clsx(styles$k.container, styles$k[`mode--${variant}`], styles$k[isNumpadLayout ? 'layout--numeric' : 'layout--default'], className), children: [variant === 'fixed' && (jsx("div", { className: styles$k.textFieldContainer, children: jsx(TextField$1, { 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] }));
|
|
3663
3705
|
};
|
|
@@ -4438,7 +4480,7 @@ const Simple = ({ items, type = 'multiple', selectedIds, onApplyFilter, placehol
|
|
|
4438
4480
|
toggleItem(itemId, item);
|
|
4439
4481
|
}
|
|
4440
4482
|
}, children: [type === 'multiple' && (jsx(Checkbox, { checked: isSelected, disabled: item.disabled, label: "" })), item.icon && (jsx("span", { className: styles$d.itemIcon, children: item.icon })), jsx("span", { className: styles$d.itemText, children: item.text })] }, itemId));
|
|
4441
|
-
})) : (jsx("li", { className: styles$d.noResults, role: "status", "aria-live": "polite", children: "Nenhum
|
|
4483
|
+
})) : (jsx("li", { className: styles$d.noResults, role: "status", "aria-live": "polite", children: "Nenhum resultado encontrado" })) }), jsxs("div", { className: styles$d.footer, children: [jsx(Button, { fullWidth: true, variant: "outlined", onClick: handleClearFilter, children: "Limpar" }), jsx(Button, { fullWidth: true, onClick: handleApplyFilter, children: "Aplicar" })] })] }));
|
|
4442
4484
|
return (jsx("div", { className: filterClass, id: id, ...rest, children: jsx(Popover, { open: isOpen, onOpenChange: handleOpenChange, side: side, align: align, onOpenAutoFocus: (e) => e.preventDefault(), trigger: triggerButton, content: popoverContent }) }));
|
|
4443
4485
|
};
|
|
4444
4486
|
|
|
@@ -4611,7 +4653,7 @@ const ListItem = ({ id, className, variant = 'text', text, subText, disabled = f
|
|
|
4611
4653
|
: children }))] }));
|
|
4612
4654
|
};
|
|
4613
4655
|
|
|
4614
|
-
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","
|
|
4656
|
+
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"};
|
|
4615
4657
|
|
|
4616
4658
|
const MenuItem = memo(({ item, isSelected, onSelect }) => {
|
|
4617
4659
|
const handleSelect = () => {
|
|
@@ -4865,7 +4907,7 @@ const Menu = ({ items, children, onItemSelect, search, enableInfiniteScroll, onS
|
|
|
4865
4907
|
if (search) {
|
|
4866
4908
|
e.stopPropagation();
|
|
4867
4909
|
}
|
|
4868
|
-
}, ...rest, children: [search && (jsx("div", { className: styles$a.searchWrapper, children: jsx(Search, { placeholder: "Buscar", onChange: handleSearchChange, value: searchInput, onKeyDown: handleSearchKeyDown }) })), 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}`))) : (jsx("div", { className: styles$a.
|
|
4910
|
+
}, ...rest, children: [search && (jsx("div", { className: styles$a.searchWrapper, children: jsx(Search, { placeholder: "Buscar", onChange: handleSearchChange, value: searchInput, onKeyDown: handleSearchKeyDown }) })), 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}`))) : (jsx("div", { className: styles$a.noResults, children: "Nenhum resultado encontrado" })), enableInfiniteScroll && isLoadingMore && (jsx("div", { className: styles$a.loadingMore, children: "Carregando mais itens..." })), enableInfiniteScroll && (jsx("div", { ref: sentinelRef, "data-scroll-sentinel": true, style: { height: '1px', visibility: 'hidden' } }))] })] }) })] }));
|
|
4869
4911
|
};
|
|
4870
4912
|
|
|
4871
4913
|
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"};
|
|
@@ -4881,10 +4923,21 @@ const Modal = ({ isOpen = false, onClose, title, children, headerContent, closeO
|
|
|
4881
4923
|
e.preventDefault();
|
|
4882
4924
|
contentRef.current?.focus();
|
|
4883
4925
|
};
|
|
4926
|
+
const handleInteractOutside = (e) => {
|
|
4927
|
+
// Ignora interações em elementos portalizados que se declararam isentos
|
|
4928
|
+
// (ex.: VirtualKeyboard em modo native), evitando fechamentos indesejados.
|
|
4929
|
+
if (isDismissOutsideIgnored(e.target)) {
|
|
4930
|
+
e.preventDefault();
|
|
4931
|
+
return;
|
|
4932
|
+
}
|
|
4933
|
+
if (!closeOnOverlayClick) {
|
|
4934
|
+
e.preventDefault();
|
|
4935
|
+
}
|
|
4936
|
+
};
|
|
4884
4937
|
return (jsx(Dialog$1.Root, { open: isOpen, onOpenChange: handleOpenChange, ...rest, children: jsxs(Dialog$1.Portal, { children: [jsx(Dialog$1.Overlay, { className: styles$9.modalOverlay }), jsxs(Dialog$1.Content, { ref: contentRef, className: clsx(styles$9.modalContent, fullscreen && styles$9['modalContent--fullscreen'], className), id: id, style: {
|
|
4885
4938
|
'--modal-custom-width': customWidth,
|
|
4886
4939
|
'--modal-custom-height': customHeight,
|
|
4887
|
-
}, onInteractOutside:
|
|
4940
|
+
}, onInteractOutside: handleInteractOutside, onOpenAutoFocus: handleOpenAutoFocus, "aria-labelledby": id ? `${id}-title` : 'modal-title', tabIndex: -1, children: [(title || headerContent || closingButton) && (jsxs("header", { className: styles$9.modalHeader, children: [title && (jsx(Dialog$1.Title, { className: styles$9.modalTitle, id: id ? `${id}-title` : 'modal-title', children: title })), headerContent && (jsx("div", { children: headerContent })), closingButton && (jsx("div", { className: styles$9.modalCloseButton, children: jsx(Dialog$1.Close, { asChild: true, children: jsx(Button, { variant: "outlined", iconOnly: true, icon: jsx(Dismiss16Regular, {}), size: "lg", tooltipText: 'Fechar' }) }) }))] })), jsx("section", { className: styles$9.modalBody, children: children }), footer && (jsx("footer", { className: styles$9.modalFooter, children: footer }))] })] }) }));
|
|
4888
4941
|
};
|
|
4889
4942
|
|
|
4890
4943
|
var styles$8 = {"quantity":"Quantity-module__quantity___-vndR","quantityInput":"Quantity-module__quantityInput___xZG-v","disabled":"Quantity-module__disabled___X6p5l"};
|
|
@@ -5402,19 +5455,33 @@ function useSelectLogic({ value, required = false, search = false, onValueChange
|
|
|
5402
5455
|
};
|
|
5403
5456
|
}
|
|
5404
5457
|
|
|
5405
|
-
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
|
|
5458
|
+
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 }) => {
|
|
5406
5459
|
const componentId = useId();
|
|
5407
5460
|
const selectId = `select-${componentId}`;
|
|
5408
5461
|
const viewportRef = useRef(null);
|
|
5409
5462
|
const hasReachedEndRef = useRef(false);
|
|
5410
5463
|
const wasLoadingMoreRef = useRef(false);
|
|
5464
|
+
const isApiSearch = enableApiSearch ?? Boolean(onApiSearch);
|
|
5465
|
+
useEffect(() => {
|
|
5466
|
+
if (process.env.NODE_ENV !== 'production' && enableApiSearch !== undefined) {
|
|
5467
|
+
console.warn('[Giro DS] `enableApiSearch` está depreciado. ' +
|
|
5468
|
+
'A busca remota será ativada pela presença de `onApiSearch`. ' +
|
|
5469
|
+
'Remoção psera feita futuramente.');
|
|
5470
|
+
}
|
|
5471
|
+
}, [enableApiSearch]);
|
|
5472
|
+
useEffect(() => {
|
|
5473
|
+
if (process.env.NODE_ENV !== 'production' && enableApiSearch === false && onApiSearch) {
|
|
5474
|
+
console.warn('[Giro DS] A combinação `enableApiSearch={false}` com `onApiSearch` ' +
|
|
5475
|
+
'futuramente o comportamento ira mudar');
|
|
5476
|
+
}
|
|
5477
|
+
}, [enableApiSearch, onApiSearch]);
|
|
5411
5478
|
const { state, actions, refs, utils, } = useSelectLogic({
|
|
5412
5479
|
value,
|
|
5413
5480
|
required,
|
|
5414
5481
|
search,
|
|
5415
5482
|
onValueChange,
|
|
5416
5483
|
onOpenChange,
|
|
5417
|
-
enableApiSearch,
|
|
5484
|
+
enableApiSearch: isApiSearch,
|
|
5418
5485
|
onApiSearch,
|
|
5419
5486
|
isSearching,
|
|
5420
5487
|
error,
|
|
@@ -5452,9 +5519,9 @@ const Select = ({ items, onValueChange, onOpenChange, variant, required = false,
|
|
|
5452
5519
|
}, [isLoadingMore, enableInfiniteScroll]);
|
|
5453
5520
|
const displayText = useMemo(() => utils.getDisplayText(state.selectedValues, placeholder, variant, items), [state.selectedValues, placeholder, variant, items, utils]);
|
|
5454
5521
|
const filteredItems = useMemo(() => {
|
|
5455
|
-
const termToFilter =
|
|
5522
|
+
const termToFilter = isApiSearch ? state.searchTerm : state.searchInput;
|
|
5456
5523
|
return utils.getFilteredItems(items, termToFilter);
|
|
5457
|
-
}, [items, state.searchTerm, state.searchInput,
|
|
5524
|
+
}, [items, state.searchTerm, state.searchInput, isApiSearch, utils]);
|
|
5458
5525
|
useEffect(() => {
|
|
5459
5526
|
if (!state.isOpen || !enableInfiniteScroll || !onScrollEnd || isLoadingMore)
|
|
5460
5527
|
return;
|
|
@@ -5477,7 +5544,7 @@ const Select = ({ items, onValueChange, onOpenChange, variant, required = false,
|
|
|
5477
5544
|
const handleSearchChange = (e) => {
|
|
5478
5545
|
const value = e.target.value;
|
|
5479
5546
|
actions.setSearchInput(value);
|
|
5480
|
-
if (
|
|
5547
|
+
if (isApiSearch) {
|
|
5481
5548
|
actions.setSearchTerm(value);
|
|
5482
5549
|
}
|
|
5483
5550
|
};
|
|
@@ -5502,7 +5569,7 @@ const Select = ({ items, onValueChange, onOpenChange, variant, required = false,
|
|
|
5502
5569
|
};
|
|
5503
5570
|
const handleClear = () => {
|
|
5504
5571
|
actions.resetSearch();
|
|
5505
|
-
if (
|
|
5572
|
+
if (isApiSearch && onApiSearch) {
|
|
5506
5573
|
onApiSearch('');
|
|
5507
5574
|
}
|
|
5508
5575
|
};
|
|
@@ -5535,9 +5602,9 @@ var styles$5 = {"wrapper":"Table-module__wrapper___KMc04","tableContainer":"Tabl
|
|
|
5535
5602
|
|
|
5536
5603
|
const EmptyState = ({ emptyIcon, emptyTitle, emptyText }) => (jsxs("div", { className: styles$5.tableEmpty, children: [jsx("div", { className: styles$5.tableEmptyContent, children: emptyIcon ?? jsx(SearchInfo20Regular, {}) }), jsxs("div", { className: styles$5.tableEmptyText, children: [jsx("h3", { className: styles$5.tableEmptyTitle, children: emptyTitle ?? 'Nenhum dado encontrado' }), jsx("p", { className: styles$5.tableEmptyCaption, children: emptyText ?? 'Nenhum registro encontrado' })] })] }));
|
|
5537
5604
|
|
|
5538
|
-
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"};
|
|
5605
|
+
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"};
|
|
5539
5606
|
|
|
5540
|
-
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 }) => {
|
|
5607
|
+
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 }) => {
|
|
5541
5608
|
const toggle = (jsx(Toggle$1.Root, { pressed: pressed, defaultPressed: defaultPressed, onPressedChange: onPressedChange, disabled: disabled, className: clsx(styles$4.toggle, styles$4[`toggle-${size}`], {
|
|
5542
5609
|
[styles$4.toggleIconOnly]: iconOnly,
|
|
5543
5610
|
[styles$4.toggleWithIcon]: !!icon && !iconOnly,
|
|
@@ -5548,7 +5615,20 @@ const Toggle = ({ pressed, defaultPressed, onPressedChange, disabled = false, cl
|
|
|
5548
5615
|
return toggle;
|
|
5549
5616
|
};
|
|
5550
5617
|
|
|
5551
|
-
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 }) => {
|
|
5618
|
+
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 }) => {
|
|
5619
|
+
const singleValueProp = value;
|
|
5620
|
+
const singleOnValueChange = onValueChange;
|
|
5621
|
+
const isSingleControlled = singleValueProp !== undefined;
|
|
5622
|
+
const [uncontrolledValue, setUncontrolledValue] = React__default.useState(defaultValue ?? '');
|
|
5623
|
+
const handleSingleValueChange = React__default.useCallback((next) => {
|
|
5624
|
+
if (requireSelection && !next) {
|
|
5625
|
+
return;
|
|
5626
|
+
}
|
|
5627
|
+
if (!isSingleControlled) {
|
|
5628
|
+
setUncontrolledValue(next);
|
|
5629
|
+
}
|
|
5630
|
+
singleOnValueChange?.(next);
|
|
5631
|
+
}, [requireSelection, isSingleControlled, singleOnValueChange]);
|
|
5552
5632
|
const rootProps = selectionType === 'multiple'
|
|
5553
5633
|
? {
|
|
5554
5634
|
type: 'multiple',
|
|
@@ -5556,16 +5636,27 @@ const ToggleGroup = ({ selectionType = 'single', value, defaultValue, onValueCha
|
|
|
5556
5636
|
defaultValue: defaultValue,
|
|
5557
5637
|
onValueChange: onValueChange,
|
|
5558
5638
|
}
|
|
5559
|
-
:
|
|
5560
|
-
|
|
5561
|
-
|
|
5562
|
-
|
|
5563
|
-
|
|
5564
|
-
|
|
5565
|
-
|
|
5566
|
-
|
|
5567
|
-
|
|
5568
|
-
|
|
5639
|
+
: requireSelection
|
|
5640
|
+
? {
|
|
5641
|
+
type: 'single',
|
|
5642
|
+
value: isSingleControlled ? singleValueProp : uncontrolledValue,
|
|
5643
|
+
onValueChange: handleSingleValueChange,
|
|
5644
|
+
}
|
|
5645
|
+
: {
|
|
5646
|
+
type: 'single',
|
|
5647
|
+
value: singleValueProp,
|
|
5648
|
+
defaultValue: defaultValue,
|
|
5649
|
+
onValueChange: singleOnValueChange,
|
|
5650
|
+
};
|
|
5651
|
+
const hasExpandableItems = groupExpandOnSelect || items.some((item) => item.expandOnSelect);
|
|
5652
|
+
const group = (jsx(ToggleGroup$1.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) => {
|
|
5653
|
+
const expandOnSelect = item.expandOnSelect ?? groupExpandOnSelect;
|
|
5654
|
+
return (jsx(ToggleGroup$1.Item, { value: item.value, disabled: item.disabled, className: clsx(styles$4.item, styles$4[`item-${size}`], {
|
|
5655
|
+
[styles$4.toggleIconOnly]: item.iconOnly && !expandOnSelect,
|
|
5656
|
+
[styles$4.toggleWithIcon]: !!item.icon && !item.iconOnly && !expandOnSelect,
|
|
5657
|
+
[styles$4.itemExpandOnSelect]: expandOnSelect,
|
|
5658
|
+
}), style: { '--giro-scale': scale }, children: expandOnSelect ? (jsxs(Fragment, { children: [item.icon && jsx("span", { className: styles$4.toggleIconLeft, "aria-hidden": "true", children: item.icon }), jsx("span", { className: styles$4.toggleLabel, children: item.label })] })) : item.iconOnly ? (jsx("span", { className: styles$4.toggleIconLeft, "aria-hidden": "true", children: item.icon })) : (jsxs(Fragment, { children: [item.icon && jsx("span", { className: styles$4.toggleIconLeft, "aria-hidden": "true", children: item.icon }), item.label] })) }, item.value));
|
|
5659
|
+
}) }));
|
|
5569
5660
|
if (tooltipText) {
|
|
5570
5661
|
return (jsx(Tooltip, { text: tooltipText, side: tooltipSide, align: tooltipAlign, children: group }));
|
|
5571
5662
|
}
|
|
@@ -5718,7 +5809,7 @@ const TableV2 = ({ columns, data, rowSelection: rowSelectionConfig, enableSortin
|
|
|
5718
5809
|
footer?.onPageChange?.(1);
|
|
5719
5810
|
}
|
|
5720
5811
|
header?.onSearchChange?.('');
|
|
5721
|
-
}, placeholder: header.searchPlaceholder ?? 'Pesquisar...', className: styles$5.tableHeaderSearch }) })), header.viewToggle && (jsx(ToggleButton, { mode: "combined", selectionType: "single", value: activeView, onValueChange: (val) => {
|
|
5812
|
+
}, placeholder: header.searchPlaceholder ?? 'Pesquisar...', className: styles$5.tableHeaderSearch }) })), header.viewToggle && (jsx(ToggleButton, { mode: "combined", selectionType: "single", value: activeView, requireSelection: true, onValueChange: (val) => {
|
|
5722
5813
|
if (!val)
|
|
5723
5814
|
return;
|
|
5724
5815
|
setActiveView(val);
|