@giro-ds/react 8.0.0 → 9.1.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 +910 -137
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +307 -39
- package/dist/index.esm.js +913 -141
- package/dist/index.esm.js.map +1 -1
- package/dist/styles.css +24 -2
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -8,6 +8,7 @@ var reactIcons = require('@fluentui/react-icons');
|
|
|
8
8
|
var reactDayPicker = require('react-day-picker');
|
|
9
9
|
var dateFns = require('date-fns');
|
|
10
10
|
var reactDom = require('react-dom');
|
|
11
|
+
var Keyboard = require('react-simple-keyboard');
|
|
11
12
|
var reactTable = require('@tanstack/react-table');
|
|
12
13
|
var Skeleton = require('react-loading-skeleton');
|
|
13
14
|
|
|
@@ -30,17 +31,17 @@ function _interopNamespaceDefault(e) {
|
|
|
30
31
|
|
|
31
32
|
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
32
33
|
|
|
33
|
-
var styles$
|
|
34
|
+
var styles$t = {"AvatarRoot":"Avatar-module__AvatarRoot___7eNx7","AvatarRoot--sm":"Avatar-module__AvatarRoot--sm___LVHoe","AvatarRoot--lg":"Avatar-module__AvatarRoot--lg___QWux5","AvatarImage":"Avatar-module__AvatarImage___-H6iH","AvatarFallback":"Avatar-module__AvatarFallback___RDyNV"};
|
|
34
35
|
|
|
35
36
|
const Avatar = ({ icon, size = 'lg', src, className, initialLetters, ...rest }) => {
|
|
36
|
-
const AvatarClass = clsx(styles$
|
|
37
|
-
[styles$
|
|
38
|
-
[styles$
|
|
37
|
+
const AvatarClass = clsx(styles$t.AvatarRoot, {
|
|
38
|
+
[styles$t['AvatarRoot--lg']]: size === 'lg',
|
|
39
|
+
[styles$t['AvatarRoot--sm']]: size === 'sm',
|
|
39
40
|
}, className);
|
|
40
|
-
return (jsxRuntime.jsxs(radixUi.Avatar.Root, { className: AvatarClass, ...rest, children: [src && (jsxRuntime.jsx(radixUi.Avatar.Image, { className: styles$
|
|
41
|
+
return (jsxRuntime.jsxs(radixUi.Avatar.Root, { className: AvatarClass, ...rest, children: [src && (jsxRuntime.jsx(radixUi.Avatar.Image, { className: styles$t.AvatarImage, src: src, alt: "Avatar" })), jsxRuntime.jsx(radixUi.Avatar.Fallback, { className: styles$t.AvatarFallback, children: icon || initialLetters })] }));
|
|
41
42
|
};
|
|
42
43
|
|
|
43
|
-
var styles$
|
|
44
|
+
var styles$s = {"badge__status":"Badge-module__badge__status___-u3xv","badge":"Badge-module__badge___ZbEBU","badgeContainer":"Badge-module__badgeContainer___Guw9Z","badge__empty":"Badge-module__badge__empty___u8ccy","badge__flex":"Badge-module__badge__flex___DSJHW","badge__status__empty":"Badge-module__badge__status__empty___h8L4e","badge__status__flex":"Badge-module__badge__status__flex___703Q6","badge__status__filterBadge":"Badge-module__badge__status__filterBadge___DhjGU"};
|
|
44
45
|
|
|
45
46
|
const getDisplayValue = (value) => {
|
|
46
47
|
if (value === null || value === undefined)
|
|
@@ -62,27 +63,27 @@ const Badge = ({ children, badgeValue = null, className, id, filterVariant = fal
|
|
|
62
63
|
const displayValue = getDisplayValue(badgeValue);
|
|
63
64
|
const isEmpty = displayValue === '';
|
|
64
65
|
if (children) {
|
|
65
|
-
return (jsxRuntime.jsxs("div", { className: styles$
|
|
66
|
-
[styles$
|
|
67
|
-
[styles$
|
|
66
|
+
return (jsxRuntime.jsxs("div", { className: styles$s.badgeContainer, ...rest, children: [jsxRuntime.jsx("div", { "data-testid": "badge-content", children: children }), jsxRuntime.jsx("div", { id: componentId, className: clsx(styles$s.badge, {
|
|
67
|
+
[styles$s['badge__empty']]: isEmpty,
|
|
68
|
+
[styles$s['badge__flex']]: displayValue.length >= 2,
|
|
68
69
|
}, className), "data-testid": "badge", children: !isEmpty && jsxRuntime.jsx("span", { "aria-hidden": !!ariaLabel, children: displayValue }) })] }));
|
|
69
70
|
}
|
|
70
|
-
return (jsxRuntime.jsx("div", { className: styles$
|
|
71
|
-
[styles$
|
|
72
|
-
[styles$
|
|
73
|
-
[styles$
|
|
71
|
+
return (jsxRuntime.jsx("div", { className: styles$s.badgeContainer, children: jsxRuntime.jsx("div", { className: clsx(styles$s['badge__status'], {
|
|
72
|
+
[styles$s['badge__status__empty']]: isEmpty,
|
|
73
|
+
[styles$s['badge__status__flex']]: displayValue.length >= 2,
|
|
74
|
+
[styles$s['badge__status__filterBadge']]: filterVariant,
|
|
74
75
|
}, className), "data-testid": "badge", children: !isEmpty && (jsxRuntime.jsx("span", { "aria-hidden": !!ariaLabel, children: displayValue })) }) }));
|
|
75
76
|
};
|
|
76
77
|
|
|
77
|
-
var styles$
|
|
78
|
+
var styles$r = {"tooltipContent":"Tooltip-module__tooltipContent___xycUg","triggerWrapper":"Tooltip-module__triggerWrapper___x83XR"};
|
|
78
79
|
|
|
79
80
|
const Tooltip = ({ children, text, side = 'bottom', align = 'start', maxWidth, sideOffset = 10, className, ...rest }) => {
|
|
80
|
-
return (jsxRuntime.jsx(radixUi.Tooltip.Provider, { children: jsxRuntime.jsxs(radixUi.Tooltip.Root, { children: [jsxRuntime.jsx(radixUi.Tooltip.Trigger, { asChild: true, children: jsxRuntime.jsx("span", { className: styles$
|
|
81
|
+
return (jsxRuntime.jsx(radixUi.Tooltip.Provider, { children: jsxRuntime.jsxs(radixUi.Tooltip.Root, { children: [jsxRuntime.jsx(radixUi.Tooltip.Trigger, { asChild: true, children: jsxRuntime.jsx("span", { className: styles$r.triggerWrapper, children: children }) }), jsxRuntime.jsx(radixUi.Tooltip.Portal, { children: jsxRuntime.jsx(radixUi.Tooltip.Content, { className: clsx(styles$r.tooltipContent, className), side: side, align: align, sideOffset: sideOffset, style: { maxWidth: maxWidth ? `${maxWidth}px` : 'auto' }, ...rest, children: text }) })] }) }));
|
|
81
82
|
};
|
|
82
83
|
|
|
83
|
-
var styles$
|
|
84
|
+
var styles$q = {"button":"Button-module__button___18Bed","button-lg":"Button-module__button-lg___-A8B9","button-sm":"Button-module__button-sm___L7aT7","button-filled":"Button-module__button-filled___IQx1z","button-outlined":"Button-module__button-outlined___hLkLN","button-text":"Button-module__button-text___8GFeA","buttonWithIcon":"Button-module__buttonWithIcon___8ehK1","buttonIconPosition-left":"Button-module__buttonIconPosition-left___uOY6b","buttonIconPosition-right":"Button-module__buttonIconPosition-right___eswRS","buttonIconPosition-both":"Button-module__buttonIconPosition-both___1Lith","buttonNoContent":"Button-module__buttonNoContent___Tc9jk","buttonIconOnly":"Button-module__buttonIconOnly___aifk4","buttonIconLeft":"Button-module__buttonIconLeft___RICR3","buttonIconRight":"Button-module__buttonIconRight___71lu2","buttonFullWidth":"Button-module__buttonFullWidth___tXuVE","disabled":"Button-module__disabled___UzdWL","buttonLoading":"Button-module__buttonLoading___RGdNw","buttonContentHidden":"Button-module__buttonContentHidden___CoCiN","buttonLoadingSpinner":"Button-module__buttonLoadingSpinner___oZxEU","spin":"Button-module__spin___kQKH9"};
|
|
84
85
|
|
|
85
|
-
const Button = React.forwardRef(({ as, children, variant = 'filled', iconPosition = 'left', href, to, external = false, target, rel, disabled = false, onClick, size = 'lg', className, type = 'button', id, icon, fullWidth = false, ariaLabel, iconOnly = false, loading = false, tooltipText, tooltipSide = 'top', tooltipAlign = 'center', ...rest }, ref) => {
|
|
86
|
+
const Button = React.forwardRef(({ as, children, variant = 'filled', iconPosition = 'left', href, to, external = false, target, rel, disabled = false, onClick, size = 'lg', scale = 1, className, type = 'button', id, icon, fullWidth = false, ariaLabel, iconOnly = false, loading = false, tooltipText, tooltipSide = 'top', tooltipAlign = 'center', ...rest }, ref) => {
|
|
86
87
|
const generatedId = React.useId();
|
|
87
88
|
const componentId = id || generatedId;
|
|
88
89
|
const getComponent = () => {
|
|
@@ -109,14 +110,19 @@ const Button = React.forwardRef(({ as, children, variant = 'filled', iconPositio
|
|
|
109
110
|
'Forneça um ícone via `icon={<MeuIcone />}`.');
|
|
110
111
|
}
|
|
111
112
|
const resolvedIcon = icon;
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
[styles$
|
|
119
|
-
[styles$
|
|
113
|
+
const scaleClass = {
|
|
114
|
+
1: 'scale-1-0',
|
|
115
|
+
1.5: 'scale-1-5',
|
|
116
|
+
2: 'scale-2-0',
|
|
117
|
+
}[scale];
|
|
118
|
+
const buttonClasses = clsx(styles$q.button, styles$q[`button-${variant}`], styles$q[`button-${size}`], scaleClass, {
|
|
119
|
+
[styles$q['disabled']]: disabled,
|
|
120
|
+
[styles$q['buttonLoading']]: loading,
|
|
121
|
+
[styles$q['buttonWithIcon']]: resolvedIcon && !iconOnly,
|
|
122
|
+
[styles$q[`buttonIconPosition-${iconPosition}`]]: resolvedIcon && !iconOnly,
|
|
123
|
+
[styles$q['buttonNoContent']]: resolvedIcon && !hasContent && !iconOnly,
|
|
124
|
+
[styles$q['buttonFullWidth']]: fullWidth,
|
|
125
|
+
[styles$q['buttonIconOnly']]: iconOnly,
|
|
120
126
|
}, className);
|
|
121
127
|
const getAriaLabel = () => {
|
|
122
128
|
if (ariaLabel)
|
|
@@ -142,12 +148,12 @@ const Button = React.forwardRef(({ as, children, variant = 'filled', iconPositio
|
|
|
142
148
|
};
|
|
143
149
|
const renderContent = () => {
|
|
144
150
|
if (iconOnly && !loading) {
|
|
145
|
-
return (jsxRuntime.jsx("span", { className: styles$
|
|
151
|
+
return (jsxRuntime.jsx("span", { className: styles$q.buttonIconOnly, "aria-hidden": "true", children: resolvedIcon }));
|
|
146
152
|
}
|
|
147
153
|
if (loading) {
|
|
148
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [!iconOnly && (jsxRuntime.jsxs("span", { className: styles$
|
|
154
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [!iconOnly && (jsxRuntime.jsxs("span", { className: styles$q.buttonContentHidden, "aria-hidden": "true", children: [resolvedIcon && (iconPosition === 'left' || iconPosition === 'both') && (jsxRuntime.jsx("span", { className: styles$q.buttonIconLeft, children: resolvedIcon })), children, resolvedIcon && (iconPosition === 'right' || iconPosition === 'both') && (jsxRuntime.jsx("span", { className: styles$q.buttonIconRight, children: resolvedIcon }))] })), jsxRuntime.jsx("span", { className: styles$q.buttonLoadingSpinner, "aria-hidden": "true", children: jsxRuntime.jsx(reactIcons.SpinnerIos16Regular, { "aria-hidden": "true" }) })] }));
|
|
149
155
|
}
|
|
150
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [resolvedIcon && (iconPosition === 'left' || iconPosition === 'both') && (jsxRuntime.jsx("span", { className: styles$
|
|
156
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [resolvedIcon && (iconPosition === 'left' || iconPosition === 'both') && (jsxRuntime.jsx("span", { className: styles$q.buttonIconLeft, "aria-hidden": "true", children: resolvedIcon })), children, resolvedIcon && (iconPosition === 'right' || iconPosition === 'both') && (jsxRuntime.jsx("span", { className: styles$q.buttonIconRight, "aria-hidden": "true", children: resolvedIcon }))] }));
|
|
151
157
|
};
|
|
152
158
|
const baseProps = {
|
|
153
159
|
ref,
|
|
@@ -2452,7 +2458,7 @@ const ptBR = {
|
|
|
2452
2458
|
},
|
|
2453
2459
|
};
|
|
2454
2460
|
|
|
2455
|
-
var styles$
|
|
2461
|
+
var styles$p = {"root":"Calendar-module__root___vQEhz","day":"Calendar-module__day___dseUA","day_button":"Calendar-module__day_button___r3WNU","caption_label":"Calendar-module__caption_label___Dhkie","button_next":"Calendar-module__button_next___iRaNz","button_previous":"Calendar-module__button_previous___r7JBs","chevron":"Calendar-module__chevron___NPDg-","nav":"Calendar-module__nav___MT3Dm","dropdowns":"Calendar-module__dropdowns___xBVtv","dropdown":"Calendar-module__dropdown___D7OlW","dropdown_root":"Calendar-module__dropdown_root___v4DlK","month_caption":"Calendar-module__month_caption___P3Hlu","month":"Calendar-module__month___0RA-L","months":"Calendar-module__months___rmJdy","month_grid":"Calendar-module__month_grid___f6YkX","weekday":"Calendar-module__weekday___Spb2f","week_number":"Calendar-module__week_number___EXJD9","today":"Calendar-module__today___U36wP","outside":"Calendar-module__outside___UeJFZ","selected":"Calendar-module__selected___5Nryr","disabled":"Calendar-module__disabled___T3658","hidden":"Calendar-module__hidden___uL3uc","range_start":"Calendar-module__range_start___c1eNH","range_middle":"Calendar-module__range_middle___Uv4gt","range_end":"Calendar-module__range_end___4qDh5","focusable":"Calendar-module__focusable___V7w-Q","weeks_before_enter":"Calendar-module__weeks_before_enter___O1ytQ","slide_in_left":"Calendar-module__slide_in_left___hfrfr","weeks_before_exit":"Calendar-module__weeks_before_exit___v7nDr","slide_out_left":"Calendar-module__slide_out_left___kib4j","weeks_after_enter":"Calendar-module__weeks_after_enter___CEtsD","slide_in_right":"Calendar-module__slide_in_right___ldL0M","weeks_after_exit":"Calendar-module__weeks_after_exit___F8Edz","slide_out_right":"Calendar-module__slide_out_right___X2hxE","caption_after_enter":"Calendar-module__caption_after_enter___0ek1H","fade_in":"Calendar-module__fade_in___YyYoZ","caption_after_exit":"Calendar-module__caption_after_exit___RA1iK","fade_out":"Calendar-module__fade_out___lNcmB","caption_before_enter":"Calendar-module__caption_before_enter___j6sMK","caption_before_exit":"Calendar-module__caption_before_exit___rntl-","calendar_grid_wrapper":"Calendar-module__calendar_grid_wrapper___OX0TR","caption_grid_btn":"Calendar-module__caption_grid_btn___qD0-E","caption_year_chevron":"Calendar-module__caption_year_chevron___4ghQV","caption_grid_label":"Calendar-module__caption_grid_label___93Wx4","gridOverlay":"Calendar-module__gridOverlay___Za-y0","gridOverlayCaption":"Calendar-module__gridOverlayCaption___p4OUO","gridOverlayYearsNav":"Calendar-module__gridOverlayYearsNav___U6S-V","gridCells":"Calendar-module__gridCells___Y8DaG","gridCellsYears":"Calendar-module__gridCellsYears___jEV52","gridCell":"Calendar-module__gridCell___RV1co","gridCellActive":"Calendar-module__gridCellActive___UBi5y","gridNavBtn":"Calendar-module__gridNavBtn___Jligz","chevronNavBtnPrev":"Calendar-module__chevronNavBtnPrev___ifEps","chevronNavBtnNext":"Calendar-module__chevronNavBtnNext___qmghm"};
|
|
2456
2462
|
|
|
2457
2463
|
const FLUENT_CHEVRON_MAP = {
|
|
2458
2464
|
down: reactIcons.ChevronDown16Regular,
|
|
@@ -2471,10 +2477,10 @@ const GridMonthCaption = ({ calendarMonth, displayIndex: _displayIndex, ...divPr
|
|
|
2471
2477
|
const date = calendarMonth.date;
|
|
2472
2478
|
const monthLabel = new Intl.DateTimeFormat(intlLocale, { month: "long" }).format(date);
|
|
2473
2479
|
const yearLabel = String(date.getFullYear());
|
|
2474
|
-
return (jsxRuntime.jsxs("div", { ...divProps, children: [jsxRuntime.jsx("span", { className: styles$
|
|
2480
|
+
return (jsxRuntime.jsxs("div", { ...divProps, children: [jsxRuntime.jsx("span", { className: styles$p.caption_grid_label, children: monthLabel }), jsxRuntime.jsxs("button", { type: "button", className: styles$p.caption_grid_btn, "aria-pressed": view === "years", onClick: onYearLabelClick, children: [yearLabel, view !== "days" ? (jsxRuntime.jsx(reactIcons.ChevronUp16Regular, { className: styles$p.caption_year_chevron, "aria-hidden": true })) : (jsxRuntime.jsx(reactIcons.ChevronDown16Regular, { className: styles$p.caption_year_chevron, "aria-hidden": true }))] })] }));
|
|
2475
2481
|
};
|
|
2476
2482
|
const YEARS_PER_PAGE = 20;
|
|
2477
|
-
const Calendar = ({ selected, currentDate, defaultMonth, startMonth, endMonth, onDaySelect, onDateChange, onClear: _onClear, minDate, maxDate, disabled, format: _format, locale = "pt-br", autoFocus, className, id, "aria-label": ariaLabel, ...rest }) => {
|
|
2483
|
+
const Calendar = ({ selected, currentDate, defaultMonth, startMonth, endMonth, onDaySelect, onDateChange, onClear: _onClear, minDate, maxDate, disabled, format: _format, locale = "pt-br", autoFocus, className, scale = 1, id, "aria-label": ariaLabel, ...rest }) => {
|
|
2478
2484
|
const animate = true;
|
|
2479
2485
|
const [internalSelected, setInternalSelected] = React.useState(selected ?? undefined);
|
|
2480
2486
|
const [internalDisplayMonth, setInternalDisplayMonth] = React.useState(() => currentDate ?? defaultMonth ?? new Date());
|
|
@@ -2539,7 +2545,7 @@ const Calendar = ({ selected, currentDate, defaultMonth, startMonth, endMonth, o
|
|
|
2539
2545
|
onYearLabelClick: handleYearLabelClick,
|
|
2540
2546
|
};
|
|
2541
2547
|
const sharedDayPickerProps = {
|
|
2542
|
-
classNames: styles$
|
|
2548
|
+
classNames: styles$p,
|
|
2543
2549
|
animate,
|
|
2544
2550
|
mode: "single",
|
|
2545
2551
|
selected: resolvedSelected,
|
|
@@ -2551,10 +2557,15 @@ const Calendar = ({ selected, currentDate, defaultMonth, startMonth, endMonth, o
|
|
|
2551
2557
|
autoFocus,
|
|
2552
2558
|
"aria-label": ariaLabel,
|
|
2553
2559
|
};
|
|
2554
|
-
|
|
2560
|
+
const scaleClass = {
|
|
2561
|
+
1: 'scale-1-0',
|
|
2562
|
+
1.5: 'scale-1-5',
|
|
2563
|
+
2: 'scale-2-0',
|
|
2564
|
+
}[scale];
|
|
2565
|
+
return (jsxRuntime.jsx(GridCtx.Provider, { value: gridCtxValue, children: jsxRuntime.jsxs("div", { className: clsx(styles$p.calendar_grid_wrapper, scaleClass, className), children: [jsxRuntime.jsx(reactDayPicker.DayPicker, { id: id, ...sharedDayPickerProps, ...rest, captionLayout: "label", month: resolvedDisplayMonth, onMonthChange: handleMonthChange, components: { MonthCaption: GridMonthCaption, Chevron: CustomChevron } }), gridView !== "days" && (jsxRuntime.jsxs("div", { className: `${styles$p.gridOverlay}${gridView === "years" ? ` ${styles$p.gridOverlayYears}` : ""}`, role: "dialog", "aria-modal": "true", "aria-label": gridView === "months" ? "Selecione o mês" : "Selecione o ano", children: [gridView === "months" && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: styles$p.gridOverlayCaption, children: [jsxRuntime.jsx("span", { className: styles$p.caption_grid_label, children: new Intl.DateTimeFormat(intlLocale, { month: "long" }).format(resolvedDisplayMonth) }), jsxRuntime.jsxs("button", { type: "button", className: styles$p.caption_grid_btn, onClick: () => setGridView("days"), "aria-label": "Fechar sele\u00E7\u00E3o de m\u00EAs", children: [displayedYear, jsxRuntime.jsx(reactIcons.ChevronUp16Regular, { className: styles$p.caption_year_chevron, "aria-hidden": true })] })] }), jsxRuntime.jsx("div", { className: styles$p.gridCells, children: monthsGrid.map(({ index, label, disabled: monthDisabled }) => (jsxRuntime.jsx("button", { type: "button", disabled: monthDisabled, className: `${styles$p.gridCell}${displayedMonthIndex === index ? ` ${styles$p.gridCellActive}` : ""}`, onClick: () => handleGridMonthSelect(index), children: label }, index))) })] })), gridView === "years" && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: styles$p.gridOverlayCaption, children: [jsxRuntime.jsx("span", { className: styles$p.caption_grid_label, children: new Intl.DateTimeFormat(intlLocale, { month: "long" }).format(resolvedDisplayMonth) }), jsxRuntime.jsxs("button", { type: "button", className: styles$p.caption_grid_btn, onClick: () => setGridView("days"), "aria-label": "Fechar sele\u00E7\u00E3o de ano", children: [displayedYear, jsxRuntime.jsx(reactIcons.ChevronUp16Regular, { className: styles$p.caption_year_chevron, "aria-hidden": true })] }), jsxRuntime.jsxs("div", { className: styles$p.gridOverlayYearsNav, children: [jsxRuntime.jsx("button", { type: "button", className: styles$p.gridNavBtn, disabled: !canGoPrevYears, onClick: () => setYearPageStart((s) => s - YEARS_PER_PAGE), "aria-label": "Anos anteriores", children: jsxRuntime.jsx(reactIcons.ChevronLeft16Regular, { className: styles$p.chevronNavBtnPrev, "aria-hidden": true }) }), jsxRuntime.jsx("button", { type: "button", className: styles$p.gridNavBtn, disabled: !canGoNextYears, onClick: () => setYearPageStart((s) => s + YEARS_PER_PAGE), "aria-label": "Pr\u00F3ximos anos", children: jsxRuntime.jsx(reactIcons.ChevronRight16Regular, { className: styles$p.chevronNavBtnNext, "aria-hidden": true }) })] })] }), jsxRuntime.jsx("div", { className: `${styles$p.gridCells} ${styles$p.gridCellsYears}`, children: yearsInPage.map((year) => (jsxRuntime.jsx("button", { type: "button", className: `${styles$p.gridCell}${displayedYear === year ? ` ${styles$p.gridCellActive}` : ""}`, onClick: () => handleGridYearSelect(year), children: year }, year))) })] }))] }))] }) }));
|
|
2555
2566
|
};
|
|
2556
2567
|
|
|
2557
|
-
var styles$
|
|
2568
|
+
var styles$o = {"container":"Callout-module__container___dggFW","withTitle":"Callout-module__withTitle___e-HEg","brand":"Callout-module__brand___YHDPQ","success":"Callout-module__success___RPS0Q","alert":"Callout-module__alert___LVlJM","content":"Callout-module__content___g44Qz","icon":"Callout-module__icon___4CBkz","subcontent":"Callout-module__subcontent___5hz-f","title":"Callout-module__title___IPSdE","text":"Callout-module__text___0Ys48","dismiss":"Callout-module__dismiss___ZaycS"};
|
|
2558
2569
|
|
|
2559
2570
|
const Callout = ({ variant = 'neutral', title, text, icon, onDismiss, dismiss, backgroundColor, textColor, className, id, style, ...rest }) => {
|
|
2560
2571
|
if (process.env.NODE_ENV !== 'production' && (text === '' || (typeof text === 'string' && !text.trim()))) {
|
|
@@ -2564,13 +2575,13 @@ const Callout = ({ variant = 'neutral', title, text, icon, onDismiss, dismiss, b
|
|
|
2564
2575
|
const titleId = `callout-title-${id || generatedId}`;
|
|
2565
2576
|
const componentId = id || generatedId;
|
|
2566
2577
|
const isAlert = variant === 'alert';
|
|
2567
|
-
const containerClass = clsx(styles$
|
|
2578
|
+
const containerClass = clsx(styles$o.container, styles$o[variant], { [styles$o.withTitle]: title }, className);
|
|
2568
2579
|
const customStyle = {
|
|
2569
2580
|
...style,
|
|
2570
2581
|
...(backgroundColor && { '--callout-bg': `var(--${backgroundColor})` }),
|
|
2571
2582
|
...(textColor && { '--callout-text': `var(--${textColor})` }),
|
|
2572
2583
|
};
|
|
2573
|
-
return (jsxRuntime.jsx("div", { id: componentId, className: containerClass, role: isAlert ? 'alert' : 'status', "aria-live": isAlert ? 'assertive' : 'polite', "aria-labelledby": title ? titleId : undefined, style: customStyle, ...rest, children: jsxRuntime.jsxs("div", { className: styles$
|
|
2584
|
+
return (jsxRuntime.jsx("div", { id: componentId, className: containerClass, role: isAlert ? 'alert' : 'status', "aria-live": isAlert ? 'assertive' : 'polite', "aria-labelledby": title ? titleId : undefined, style: customStyle, ...rest, children: jsxRuntime.jsxs("div", { className: styles$o.content, children: [icon && jsxRuntime.jsx("span", { className: styles$o.icon, "aria-hidden": "true", children: icon }), jsxRuntime.jsxs("div", { className: styles$o.subcontent, children: [title && (jsxRuntime.jsx("span", { id: titleId, className: styles$o.title, children: title })), text && jsxRuntime.jsx("span", { className: styles$o.text, children: text })] }), dismiss && (jsxRuntime.jsx("button", { className: styles$o.dismiss, onClick: onDismiss, type: "button", "aria-label": "Fechar", children: jsxRuntime.jsx(reactIcons.Dismiss24Regular, { "aria-hidden": "true" }) }))] }) }));
|
|
2574
2585
|
};
|
|
2575
2586
|
|
|
2576
2587
|
const CheckSmall = ({ className = '', width = 12, height = 10, fill = 'white', ...restProps }) => {
|
|
@@ -2581,22 +2592,32 @@ const CheckHalf = ({ className = '', width = 16, height = 16, fill = 'white', ..
|
|
|
2581
2592
|
return (jsxRuntime.jsx("svg", { width: width, height: height, viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: className, "aria-hidden": "true", ...restProps, children: jsxRuntime.jsx("g", { id: "Icons/check_indeterminate_small", children: jsxRuntime.jsx("path", { id: "icon", d: "M3 9V7H13V9H3Z", fill: fill }) }) }));
|
|
2582
2593
|
};
|
|
2583
2594
|
|
|
2584
|
-
var styles$
|
|
2595
|
+
var styles$n = {"container":"Checkbox-module__container___pUY-s","root":"Checkbox-module__root___BS5dT","disabled":"Checkbox-module__disabled___WagIC","label":"Checkbox-module__label___JBaRm","indicator":"Checkbox-module__indicator___HXLHH","wrapperCheckbox":"Checkbox-module__wrapperCheckbox___m2qIW"};
|
|
2585
2596
|
|
|
2586
|
-
const Checkbox = ({ id, label, onCheckedChange, checked, disabled, className, indeterminate = false, ...rest }) => {
|
|
2597
|
+
const Checkbox = ({ id, label, onCheckedChange, checked, disabled, className, scale = 1, indeterminate = false, ...rest }) => {
|
|
2587
2598
|
const componentId = id || React__namespace.useId();
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2599
|
+
const scaleClass = {
|
|
2600
|
+
1: 'scale-1-0',
|
|
2601
|
+
1.5: 'scale-1-5',
|
|
2602
|
+
2: 'scale-2-0',
|
|
2603
|
+
}[scale];
|
|
2604
|
+
return (jsxRuntime.jsxs("div", { className: clsx(styles$n.container, scaleClass, className), children: [jsxRuntime.jsx("div", { className: clsx(styles$n.wrapperCheckbox, {
|
|
2605
|
+
[styles$n.disabled]: disabled,
|
|
2606
|
+
}), role: "presentation", tabIndex: disabled ? -1 : 0, children: jsxRuntime.jsx(radixUi.Checkbox.Root, { className: styles$n.root, checked: indeterminate ? 'indeterminate' : checked, id: componentId, onCheckedChange: onCheckedChange, disabled: disabled, "data-disabled": disabled, "data-indeterminate": indeterminate, "aria-checked": indeterminate ? 'mixed' : checked ? 'true' : 'false', ...rest, children: jsxRuntime.jsx(radixUi.Checkbox.Indicator, { className: styles$n.indicator, children: indeterminate ? jsxRuntime.jsx(CheckHalf, {}) : jsxRuntime.jsx(CheckSmall, {}) }) }) }), jsxRuntime.jsx("label", { className: clsx(styles$n.label, { [styles$n.disabled]: disabled }), htmlFor: componentId, children: label })] }));
|
|
2591
2607
|
};
|
|
2592
2608
|
|
|
2593
|
-
var styles$
|
|
2594
|
-
|
|
2595
|
-
const Chips = ({ children, leftIcon, rightIcon, variant = 'neutral', disabled = false, backgroundColor, textColor, className, style, ...rest }) => {
|
|
2596
|
-
const
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2609
|
+
var styles$m = {"chips":"Chips-module__chips___SOvBe","title":"Chips-module__title___ZhuQi","iconLeft":"Chips-module__iconLeft___tPhnw","iconRight":"Chips-module__iconRight___-HxL2","hasLeftIcon":"Chips-module__hasLeftIcon___D3quS","hasRightIcon":"Chips-module__hasRightIcon___ZMx2Y","brand":"Chips-module__brand___q1Gsm","success":"Chips-module__success___UhxQa","alert":"Chips-module__alert___nvPnr","disabled":"Chips-module__disabled___ElWLI"};
|
|
2610
|
+
|
|
2611
|
+
const Chips = ({ children, leftIcon, rightIcon, variant = 'neutral', disabled = false, backgroundColor, textColor, scale = 1, className, style, ...rest }) => {
|
|
2612
|
+
const scaleClass = {
|
|
2613
|
+
1: 'scale-1-0',
|
|
2614
|
+
1.5: 'scale-1-5',
|
|
2615
|
+
2: 'scale-2-0',
|
|
2616
|
+
}[scale];
|
|
2617
|
+
const chipsClass = clsx(styles$m.chips, styles$m[variant], scaleClass, {
|
|
2618
|
+
[styles$m.disabled]: disabled,
|
|
2619
|
+
[styles$m.hasLeftIcon]: leftIcon,
|
|
2620
|
+
[styles$m.hasRightIcon]: rightIcon,
|
|
2600
2621
|
}, className);
|
|
2601
2622
|
const colorStyle = {
|
|
2602
2623
|
...(!disabled && backgroundColor && { '--chips-bg': `var(--${backgroundColor})` }),
|
|
@@ -2604,24 +2625,631 @@ const Chips = ({ children, leftIcon, rightIcon, variant = 'neutral', disabled =
|
|
|
2604
2625
|
...style,
|
|
2605
2626
|
};
|
|
2606
2627
|
const isInteractive = typeof rest.onClick === 'function';
|
|
2607
|
-
return (jsxRuntime.jsxs("div", { className: chipsClass, "aria-disabled": disabled, style: colorStyle, role: isInteractive ? 'button' : undefined, tabIndex: isInteractive ? (disabled ? -1 : 0) : undefined, ...rest, children: [leftIcon && (jsxRuntime.jsx("span", { className: styles$
|
|
2628
|
+
return (jsxRuntime.jsxs("div", { className: chipsClass, "aria-disabled": disabled, style: colorStyle, role: isInteractive ? 'button' : undefined, tabIndex: isInteractive ? (disabled ? -1 : 0) : undefined, ...rest, children: [leftIcon && (jsxRuntime.jsx("span", { className: styles$m.iconLeft, "aria-hidden": "true", children: leftIcon })), jsxRuntime.jsx("span", { className: styles$m.title, children: children }), rightIcon && (jsxRuntime.jsx("span", { className: styles$m.iconRight, children: rightIcon }))] }));
|
|
2608
2629
|
};
|
|
2609
2630
|
const MemoizedChips = React.memo(Chips);
|
|
2610
2631
|
MemoizedChips.displayName = 'Chips';
|
|
2611
2632
|
|
|
2612
|
-
var styles$
|
|
2633
|
+
var styles$l = {"container":"Container-module__container___exPuE"};
|
|
2613
2634
|
|
|
2614
2635
|
function Container({ children, className }) {
|
|
2615
|
-
return (jsxRuntime.jsx("main", { className: clsx(styles$
|
|
2636
|
+
return (jsxRuntime.jsx("main", { className: clsx(styles$l['container'], 'mx-auto', className), children: children }));
|
|
2616
2637
|
}
|
|
2617
2638
|
|
|
2618
|
-
var styles$
|
|
2639
|
+
var styles$k = {"Content":"Popover-module__Content___RIETg"};
|
|
2619
2640
|
|
|
2620
2641
|
const Popover = ({ trigger, content, side = "left", align = "start", sideOffset = 8, open, onOpenChange, asAnchor = false, onOpenAutoFocus, onCloseAutoFocus, showArrow = false, className, ...rest }) => {
|
|
2621
|
-
return (jsxRuntime.jsxs(radixUi.Popover.Root, { open: open, onOpenChange: onOpenChange, ...rest, children: [asAnchor ? (jsxRuntime.jsx(radixUi.Popover.Anchor, { asChild: true, children: trigger })) : (jsxRuntime.jsx(radixUi.Popover.Trigger, { asChild: true, children: trigger })), jsxRuntime.jsx(radixUi.Popover.Portal, { children: jsxRuntime.jsxs(radixUi.Popover.Content, { className: clsx(styles$
|
|
2642
|
+
return (jsxRuntime.jsxs(radixUi.Popover.Root, { open: open, onOpenChange: onOpenChange, ...rest, children: [asAnchor ? (jsxRuntime.jsx(radixUi.Popover.Anchor, { asChild: true, children: trigger })) : (jsxRuntime.jsx(radixUi.Popover.Trigger, { asChild: true, children: trigger })), jsxRuntime.jsx(radixUi.Popover.Portal, { children: jsxRuntime.jsxs(radixUi.Popover.Content, { className: clsx(styles$k.Content, className), sideOffset: sideOffset, side: side, align: align, onOpenAutoFocus: asAnchor ? (e) => e.preventDefault() : onOpenAutoFocus, onCloseAutoFocus: asAnchor ? (e) => e.preventDefault() : onCloseAutoFocus, onInteractOutside: asAnchor ? (e) => e.preventDefault() : undefined, children: [content, showArrow && jsxRuntime.jsx(radixUi.Popover.Arrow, {})] }) })] }));
|
|
2622
2643
|
};
|
|
2623
2644
|
|
|
2624
|
-
|
|
2645
|
+
function useInputKeyboardValue(externalRef) {
|
|
2646
|
+
const internalRef = React.useRef(null);
|
|
2647
|
+
const setRefs = React.useCallback((node) => {
|
|
2648
|
+
internalRef.current = node;
|
|
2649
|
+
if (typeof externalRef === 'function') {
|
|
2650
|
+
externalRef(node);
|
|
2651
|
+
return;
|
|
2652
|
+
}
|
|
2653
|
+
if (externalRef) {
|
|
2654
|
+
externalRef.current = node;
|
|
2655
|
+
}
|
|
2656
|
+
}, [externalRef]);
|
|
2657
|
+
return { internalRef, setRefs };
|
|
2658
|
+
}
|
|
2659
|
+
|
|
2660
|
+
const iconSlot = (key) => `<span data-icon-key="${key}"></span>`;
|
|
2661
|
+
const ICON_KEY_MAP = {
|
|
2662
|
+
bksp: reactIcons.Backspace20Regular,
|
|
2663
|
+
shift: reactIcons.KeyboardShift20Regular,
|
|
2664
|
+
shiftactivated: reactIcons.KeyboardShift20Filled,
|
|
2665
|
+
capslock: reactIcons.KeyboardShiftUppercase20Regular,
|
|
2666
|
+
downkeyboard: reactIcons.ChevronDown20Regular,
|
|
2667
|
+
emoji: reactIcons.Emoji20Regular,
|
|
2668
|
+
};
|
|
2669
|
+
const SHARED_DISPLAY = {
|
|
2670
|
+
'{capslock}': iconSlot('capslock'),
|
|
2671
|
+
'{numbers}': '123',
|
|
2672
|
+
'{abc}': 'ABC',
|
|
2673
|
+
'{alt}': '.?!',
|
|
2674
|
+
'{alt2}': '#+=',
|
|
2675
|
+
'{emoticon}': iconSlot('emoji'),
|
|
2676
|
+
'{shift}': iconSlot('shift'),
|
|
2677
|
+
'{shiftactivated}': iconSlot('shiftactivated'),
|
|
2678
|
+
'{enter}': 'Enter',
|
|
2679
|
+
'{bksp}': `${iconSlot('bksp')} Apagar`,
|
|
2680
|
+
'{altright}': '.?123',
|
|
2681
|
+
'{downkeyboard}': iconSlot('downkeyboard'),
|
|
2682
|
+
'{space}': ' ',
|
|
2683
|
+
'{default}': 'ABC',
|
|
2684
|
+
};
|
|
2685
|
+
const LAYOUT_DISPLAY = {
|
|
2686
|
+
default: SHARED_DISPLAY,
|
|
2687
|
+
numeric: SHARED_DISPLAY,
|
|
2688
|
+
};
|
|
2689
|
+
|
|
2690
|
+
const EMOTICON_KEY = '{emoticon}';
|
|
2691
|
+
const DOWN_KEYBOARD_KEY = '{downkeyboard}';
|
|
2692
|
+
const removeKeyFromLayout = (layout, key) => Object.fromEntries(Object.entries(layout).map(([layoutName, rows]) => [
|
|
2693
|
+
layoutName,
|
|
2694
|
+
rows.map((row) => row.split(key).join(' ').replace(/\s+/g, ' ').trim()),
|
|
2695
|
+
]));
|
|
2696
|
+
const QWERTY_LOWERCASE = [
|
|
2697
|
+
'{//} 1 2 3 4 5 6 7 8 9 0 {//}',
|
|
2698
|
+
'{//} q w e r t y u i o p {//}',
|
|
2699
|
+
'a s d f g h j k l ç {bksp}',
|
|
2700
|
+
'{shift} z x c v b n m , . {shift}',
|
|
2701
|
+
'{numbers} {alt} {space} {downkeyboard} {enter}',
|
|
2702
|
+
];
|
|
2703
|
+
const NUMPAD = ['1 2 3', '4 5 6', '7 8 9', '{bksp} 0 {abc}'];
|
|
2704
|
+
const SHARED_LAYOUTS = {
|
|
2705
|
+
shift: [
|
|
2706
|
+
'{//} 1 2 3 4 5 6 7 8 9 0 {//}',
|
|
2707
|
+
'{//} Q W E R T Y U I O P {//}',
|
|
2708
|
+
'A S D F G H J K L Ç {bksp}',
|
|
2709
|
+
'{capslock} Z X C V B N M , . {capslock}',
|
|
2710
|
+
'{numbers} {alt} {emoticon} {space} {downkeyboard} {enter}',
|
|
2711
|
+
],
|
|
2712
|
+
caps: [
|
|
2713
|
+
'{//} 1 2 3 4 5 6 7 8 9 0 {//}',
|
|
2714
|
+
'{//} Q W E R T Y U I O P {//}',
|
|
2715
|
+
'A S D F G H J K L Ç {bksp}',
|
|
2716
|
+
'{shiftactivated} Z X C V B N M , . {shiftactivated}',
|
|
2717
|
+
'{numbers} {alt} {emoticon} {space} {downkeyboard} {enter}',
|
|
2718
|
+
],
|
|
2719
|
+
numbers: NUMPAD,
|
|
2720
|
+
alt: [
|
|
2721
|
+
'1 2 3 4 5 6 7 8 9 0',
|
|
2722
|
+
`- / : ; ( ) $ & @ "`,
|
|
2723
|
+
'{alt2} . , ? ! ´ {bksp}',
|
|
2724
|
+
'{default} {emoticon} {space} {downkeyboard} {enter}',
|
|
2725
|
+
],
|
|
2726
|
+
alt2: [
|
|
2727
|
+
'[ ] { } # % ^ * + =',
|
|
2728
|
+
'_ \\ | ~ < > ¢ £ ¥ •',
|
|
2729
|
+
`{alt} . , ? ! ' {bksp}`,
|
|
2730
|
+
'{default} {emoticon} {space} {downkeyboard} {enter}',
|
|
2731
|
+
],
|
|
2732
|
+
emoticon: [
|
|
2733
|
+
'😀 😊 😅 😂 🙂 😉 😍 😛 😠 😎 {bksp}',
|
|
2734
|
+
`😏 😬 😭 😓 😱 😪 🙄 😴 😯 {enter}`,
|
|
2735
|
+
'😐 😇 🤣 😘 😚 😆 😡 😥 😓 {shift}',
|
|
2736
|
+
'{default} {alt} {space} {altright} {downkeyboard}',
|
|
2737
|
+
],
|
|
2738
|
+
};
|
|
2739
|
+
const NATIVE_LAYOUTS = {
|
|
2740
|
+
default: {
|
|
2741
|
+
default: QWERTY_LOWERCASE,
|
|
2742
|
+
...SHARED_LAYOUTS,
|
|
2743
|
+
},
|
|
2744
|
+
numeric: {
|
|
2745
|
+
default: NUMPAD,
|
|
2746
|
+
abc: QWERTY_LOWERCASE,
|
|
2747
|
+
...SHARED_LAYOUTS,
|
|
2748
|
+
},
|
|
2749
|
+
};
|
|
2750
|
+
const NATIVE_LAYOUT_KEYS = new Set([
|
|
2751
|
+
'default', 'numeric',
|
|
2752
|
+
]);
|
|
2753
|
+
const getNativeLayout = (type, Emoji = true, showDownKeyboardButton = true, isFixed = false) => {
|
|
2754
|
+
const layout = NATIVE_LAYOUTS[type] ?? NATIVE_LAYOUTS.default ?? null;
|
|
2755
|
+
if (!layout)
|
|
2756
|
+
return null;
|
|
2757
|
+
let computedLayout = layout;
|
|
2758
|
+
if (!Emoji) {
|
|
2759
|
+
computedLayout = removeKeyFromLayout(computedLayout, EMOTICON_KEY);
|
|
2760
|
+
}
|
|
2761
|
+
if (!showDownKeyboardButton) {
|
|
2762
|
+
computedLayout = removeKeyFromLayout(computedLayout, DOWN_KEYBOARD_KEY);
|
|
2763
|
+
}
|
|
2764
|
+
if (isFixed) {
|
|
2765
|
+
computedLayout = Object.fromEntries(Object.entries(computedLayout).map(([layoutName, rows]) => [
|
|
2766
|
+
layoutName,
|
|
2767
|
+
rows.map((row) => {
|
|
2768
|
+
const trimmed = row.trim();
|
|
2769
|
+
if (/^[a-zA-ZçÇ]/.test(trimmed) && trimmed.endsWith('{bksp}')) {
|
|
2770
|
+
return '{//} ' + trimmed.replace(/\s*\{bksp\}$/, '') + ' {//}';
|
|
2771
|
+
}
|
|
2772
|
+
if (/\{(shift|capslock|shiftactivated)\}$/.test(trimmed)) {
|
|
2773
|
+
return trimmed.replace(/\{(shift|capslock|shiftactivated)\}$/, '{bksp}');
|
|
2774
|
+
}
|
|
2775
|
+
return row;
|
|
2776
|
+
}),
|
|
2777
|
+
]));
|
|
2778
|
+
}
|
|
2779
|
+
return computedLayout;
|
|
2780
|
+
};
|
|
2781
|
+
const SHIFT_TOGGLES = {
|
|
2782
|
+
default: 'shift',
|
|
2783
|
+
abc: 'shift',
|
|
2784
|
+
shift: 'default',
|
|
2785
|
+
alt: 'default',
|
|
2786
|
+
alt2: 'alt',
|
|
2787
|
+
};
|
|
2788
|
+
|
|
2789
|
+
var styles$j = {"container":"VirtualKeyboard-module__container___A-e0I","disabled":"VirtualKeyboard-module__disabled___HGS2n","layout--numeric":"VirtualKeyboard-module__layout--numeric___zfd7G","layout--default":"VirtualKeyboard-module__layout--default___qyY1b","mode--fixed":"VirtualKeyboard-module__mode--fixed___1eFY1","textFieldContainer":"VirtualKeyboard-module__textFieldContainer___XxGen","keyboardWrapper":"VirtualKeyboard-module__keyboardWrapper___jryTf","overlay":"VirtualKeyboard-module__overlay___a5y7i","overlayOpen":"VirtualKeyboard-module__overlayOpen___hREu-","textFieldWrapper":"VirtualKeyboard-module__textFieldWrapper___bmi-z","accentMenu":"VirtualKeyboard-module__accentMenu___A6tTy","accentOption":"VirtualKeyboard-module__accentOption___ao-Ta"};
|
|
2790
|
+
|
|
2791
|
+
const LONG_PRESS_DELAY_MS = 400;
|
|
2792
|
+
const ACCENT_OPTIONS = {
|
|
2793
|
+
a: ['á', 'à', 'â', 'ã', 'ä', 'å', 'æ'],
|
|
2794
|
+
e: ['é', 'è', 'ê', 'ë'],
|
|
2795
|
+
i: ['í', 'ì', 'î', 'ï'],
|
|
2796
|
+
o: ['ó', 'ò', 'ô', 'õ', 'ö', 'ø', 'œ', 'ð'],
|
|
2797
|
+
u: ['ú', 'ù', 'û', 'ü'],
|
|
2798
|
+
y: ['ý', 'ÿ'],
|
|
2799
|
+
n: ['ñ'],
|
|
2800
|
+
c: ['ç'],
|
|
2801
|
+
'?': ['¿'],
|
|
2802
|
+
'!': ['¡'],
|
|
2803
|
+
};
|
|
2804
|
+
/**
|
|
2805
|
+
* Componente VirtualKeyboard — teclado virtual on-screen para entradas controladas.
|
|
2806
|
+
*
|
|
2807
|
+
* @description Baseado em `react-simple-keyboard`, oferece apenas layouts nativos (QWERTY e numérico)
|
|
2808
|
+
* seguindo o visual padrão da biblioteca.
|
|
2809
|
+
*
|
|
2810
|
+
* Possui dois modos:
|
|
2811
|
+
* - **`native`** (padrão): age como teclado nativo — aparece ao focar no campo referenciado por `targetRef` e some ao perder o foco.
|
|
2812
|
+
* - **`fixed`**: teclado sempre visível com um TextField próprio acima.
|
|
2813
|
+
*
|
|
2814
|
+
* @example
|
|
2815
|
+
* ```tsx
|
|
2816
|
+
* // Modo fixed
|
|
2817
|
+
* <VirtualKeyboard variant="fixed" type="default" onChange={setValue} />
|
|
2818
|
+
* ```
|
|
2819
|
+
*
|
|
2820
|
+
* @example
|
|
2821
|
+
* ```tsx
|
|
2822
|
+
* // Modo native — aparece ao focar no input
|
|
2823
|
+
* const inputRef = useRef<HTMLInputElement>(null);
|
|
2824
|
+
* const [value, setValue] = useState('');
|
|
2825
|
+
* <input ref={inputRef} value={value} readOnly />
|
|
2826
|
+
* <VirtualKeyboard targetRef={inputRef} value={value} onChange={setValue} />
|
|
2827
|
+
* ```
|
|
2828
|
+
*/
|
|
2829
|
+
const VirtualKeyboard = ({ variant = 'native', type = 'default', value = '', onChange, onKeyPress, maxLength, Emoji = false, className, id, textFieldPlaceholder = 'Digite aqui...', helperText, error, errorMessage, targetRef, }) => {
|
|
2830
|
+
const [layoutName, setLayoutName] = React.useState('default');
|
|
2831
|
+
const [capsLockOn, setCapsLockOn] = React.useState(false);
|
|
2832
|
+
const [accentMenu, setAccentMenu] = React.useState(null);
|
|
2833
|
+
const [accentMenuOffsetX, setAccentMenuOffsetX] = React.useState(0);
|
|
2834
|
+
const [activeLayout, setActiveLayout] = React.useState(getNativeLayout(type, Emoji, variant === 'native', variant === 'fixed'));
|
|
2835
|
+
const visualType = NATIVE_LAYOUT_KEYS.has(type) ? type : 'default';
|
|
2836
|
+
const [isOpen, setIsOpen] = React.useState(variant !== 'native');
|
|
2837
|
+
const hideTimeoutRef = React.useRef(null);
|
|
2838
|
+
const longPressTimeoutRef = React.useRef(null);
|
|
2839
|
+
const suppressNextInputRef = React.useRef(null);
|
|
2840
|
+
const heldAccentKeyRef = React.useRef(null);
|
|
2841
|
+
const longPressTriggeredRef = React.useRef(false);
|
|
2842
|
+
const isKeyboardInteractingRef = React.useRef(false);
|
|
2843
|
+
const keyboardWrapperRef = React.useRef(null);
|
|
2844
|
+
const keyboardInstanceRef = React.useRef(null);
|
|
2845
|
+
const accentMenuRef = React.useRef(null);
|
|
2846
|
+
const accentButtonRef = React.useRef(null);
|
|
2847
|
+
const accentMenuOpenRef = React.useRef(false);
|
|
2848
|
+
const valueRef = React.useRef(value);
|
|
2849
|
+
const [iconSlots, setIconSlots] = React.useState([]);
|
|
2850
|
+
React.useEffect(() => {
|
|
2851
|
+
valueRef.current = value;
|
|
2852
|
+
}, [value]);
|
|
2853
|
+
const clearLongPressTimeout = React.useCallback(() => {
|
|
2854
|
+
if (longPressTimeoutRef.current !== null) {
|
|
2855
|
+
clearTimeout(longPressTimeoutRef.current);
|
|
2856
|
+
longPressTimeoutRef.current = null;
|
|
2857
|
+
}
|
|
2858
|
+
}, []);
|
|
2859
|
+
const closeAccentMenu = React.useCallback(() => {
|
|
2860
|
+
setAccentMenu(null);
|
|
2861
|
+
accentButtonRef.current = null;
|
|
2862
|
+
}, []);
|
|
2863
|
+
const syncKeyboardInput = React.useCallback((nextValue) => {
|
|
2864
|
+
keyboardInstanceRef.current?.setInput(nextValue);
|
|
2865
|
+
}, []);
|
|
2866
|
+
React.useEffect(() => {
|
|
2867
|
+
syncKeyboardInput(value);
|
|
2868
|
+
}, [value, syncKeyboardInput]);
|
|
2869
|
+
const scheduleHideIfBlurred = React.useCallback(() => {
|
|
2870
|
+
if (variant !== 'native')
|
|
2871
|
+
return;
|
|
2872
|
+
if (hideTimeoutRef.current !== null) {
|
|
2873
|
+
clearTimeout(hideTimeoutRef.current);
|
|
2874
|
+
}
|
|
2875
|
+
hideTimeoutRef.current = setTimeout(() => {
|
|
2876
|
+
const targetEl = targetRef?.current;
|
|
2877
|
+
const isTargetFocused = !!targetEl && document.activeElement === targetEl;
|
|
2878
|
+
if (!isTargetFocused && !isKeyboardInteractingRef.current) {
|
|
2879
|
+
setIsOpen(false);
|
|
2880
|
+
}
|
|
2881
|
+
}, 150);
|
|
2882
|
+
}, [variant, targetRef]);
|
|
2883
|
+
React.useEffect(() => {
|
|
2884
|
+
if (variant !== 'native')
|
|
2885
|
+
return;
|
|
2886
|
+
if (!targetRef?.current) {
|
|
2887
|
+
setIsOpen(true);
|
|
2888
|
+
return;
|
|
2889
|
+
}
|
|
2890
|
+
const el = targetRef.current;
|
|
2891
|
+
const handleFocus = () => {
|
|
2892
|
+
if (hideTimeoutRef.current !== null)
|
|
2893
|
+
clearTimeout(hideTimeoutRef.current);
|
|
2894
|
+
setIsOpen(true);
|
|
2895
|
+
};
|
|
2896
|
+
const handleBlur = () => {
|
|
2897
|
+
scheduleHideIfBlurred();
|
|
2898
|
+
};
|
|
2899
|
+
el.addEventListener('focus', handleFocus);
|
|
2900
|
+
el.addEventListener('blur', handleBlur);
|
|
2901
|
+
return () => {
|
|
2902
|
+
el.removeEventListener('focus', handleFocus);
|
|
2903
|
+
el.removeEventListener('blur', handleBlur);
|
|
2904
|
+
if (hideTimeoutRef.current !== null)
|
|
2905
|
+
clearTimeout(hideTimeoutRef.current);
|
|
2906
|
+
};
|
|
2907
|
+
}, [variant, targetRef, scheduleHideIfBlurred]);
|
|
2908
|
+
React.useEffect(() => {
|
|
2909
|
+
setLayoutName('default');
|
|
2910
|
+
setCapsLockOn(false);
|
|
2911
|
+
setActiveLayout(getNativeLayout(type, Emoji, variant === 'native', variant === 'fixed'));
|
|
2912
|
+
}, [type, Emoji, variant]);
|
|
2913
|
+
React.useEffect(() => {
|
|
2914
|
+
if (!Emoji && layoutName === 'emoticon') {
|
|
2915
|
+
setLayoutName(type === 'numeric' ? 'abc' : 'default');
|
|
2916
|
+
}
|
|
2917
|
+
}, [Emoji, layoutName, type]);
|
|
2918
|
+
React.useEffect(() => {
|
|
2919
|
+
return () => {
|
|
2920
|
+
clearLongPressTimeout();
|
|
2921
|
+
};
|
|
2922
|
+
}, [clearLongPressTimeout]);
|
|
2923
|
+
React.useEffect(() => {
|
|
2924
|
+
if (!accentMenu)
|
|
2925
|
+
return;
|
|
2926
|
+
const handleOutsidePointerDown = (event) => {
|
|
2927
|
+
if (accentMenuRef.current?.contains(event.target))
|
|
2928
|
+
return;
|
|
2929
|
+
closeAccentMenu();
|
|
2930
|
+
};
|
|
2931
|
+
const handleEscape = (event) => {
|
|
2932
|
+
if (event.key === 'Escape') {
|
|
2933
|
+
closeAccentMenu();
|
|
2934
|
+
}
|
|
2935
|
+
};
|
|
2936
|
+
document.addEventListener('pointerdown', handleOutsidePointerDown, true);
|
|
2937
|
+
document.addEventListener('keydown', handleEscape);
|
|
2938
|
+
return () => {
|
|
2939
|
+
document.removeEventListener('pointerdown', handleOutsidePointerDown, true);
|
|
2940
|
+
document.removeEventListener('keydown', handleEscape);
|
|
2941
|
+
};
|
|
2942
|
+
}, [accentMenu, closeAccentMenu]);
|
|
2943
|
+
React.useLayoutEffect(() => {
|
|
2944
|
+
if (!accentMenu || !accentMenuRef.current)
|
|
2945
|
+
return;
|
|
2946
|
+
const margin = 8;
|
|
2947
|
+
const rect = accentMenuRef.current.getBoundingClientRect();
|
|
2948
|
+
if (rect.width <= 0 || rect.height <= 0)
|
|
2949
|
+
return;
|
|
2950
|
+
const minCenter = margin + rect.width / 2;
|
|
2951
|
+
const maxCenter = window.innerWidth - margin - rect.width / 2;
|
|
2952
|
+
const clampedCenter = Math.min(maxCenter, Math.max(minCenter, accentMenu.left));
|
|
2953
|
+
const nextOffset = clampedCenter - accentMenu.left;
|
|
2954
|
+
if (Math.abs(nextOffset - accentMenuOffsetX) > 0.5) {
|
|
2955
|
+
setAccentMenuOffsetX(nextOffset);
|
|
2956
|
+
}
|
|
2957
|
+
}, [accentMenu, accentMenuOffsetX]);
|
|
2958
|
+
React.useEffect(() => {
|
|
2959
|
+
if (!keyboardWrapperRef.current)
|
|
2960
|
+
return;
|
|
2961
|
+
const container = keyboardWrapperRef.current;
|
|
2962
|
+
const registerNewSlots = () => {
|
|
2963
|
+
const newSlots = Array.from(container.querySelectorAll('[data-icon-key]:not([data-icon-root])'));
|
|
2964
|
+
if (newSlots.length === 0)
|
|
2965
|
+
return;
|
|
2966
|
+
newSlots.forEach((s) => s.setAttribute('data-icon-root', 'true'));
|
|
2967
|
+
setIconSlots((prev) => [...prev, ...newSlots]);
|
|
2968
|
+
};
|
|
2969
|
+
registerNewSlots();
|
|
2970
|
+
const observer = new MutationObserver(() => {
|
|
2971
|
+
setIconSlots((prev) => prev.filter((slot) => container.contains(slot)));
|
|
2972
|
+
registerNewSlots();
|
|
2973
|
+
});
|
|
2974
|
+
observer.observe(container, { childList: true, subtree: true });
|
|
2975
|
+
return () => {
|
|
2976
|
+
observer.disconnect();
|
|
2977
|
+
};
|
|
2978
|
+
}, []);
|
|
2979
|
+
React.useEffect(() => {
|
|
2980
|
+
closeAccentMenu();
|
|
2981
|
+
setAccentMenuOffsetX(0);
|
|
2982
|
+
suppressNextInputRef.current = null;
|
|
2983
|
+
clearLongPressTimeout();
|
|
2984
|
+
}, [layoutName, type, closeAccentMenu, clearLongPressTimeout]);
|
|
2985
|
+
React.useEffect(() => {
|
|
2986
|
+
accentMenuOpenRef.current = !!accentMenu;
|
|
2987
|
+
}, [accentMenu]);
|
|
2988
|
+
React.useEffect(() => {
|
|
2989
|
+
const updateAccentPosition = () => {
|
|
2990
|
+
if (!accentMenuOpenRef.current)
|
|
2991
|
+
return;
|
|
2992
|
+
const btn = accentButtonRef.current;
|
|
2993
|
+
if (!btn)
|
|
2994
|
+
return;
|
|
2995
|
+
const rect = btn.getBoundingClientRect();
|
|
2996
|
+
setAccentMenu((prev) => prev ? { ...prev, top: rect.top - 8, left: rect.left + rect.width / 2 } : null);
|
|
2997
|
+
};
|
|
2998
|
+
window.addEventListener('scroll', updateAccentPosition, { capture: true, passive: true });
|
|
2999
|
+
window.addEventListener('resize', updateAccentPosition);
|
|
3000
|
+
return () => {
|
|
3001
|
+
window.removeEventListener('scroll', updateAccentPosition, true);
|
|
3002
|
+
window.removeEventListener('resize', updateAccentPosition);
|
|
3003
|
+
};
|
|
3004
|
+
}, []);
|
|
3005
|
+
const handleLongPressStart = React.useCallback((event) => {
|
|
3006
|
+
isKeyboardInteractingRef.current = true;
|
|
3007
|
+
if (hideTimeoutRef.current !== null) {
|
|
3008
|
+
clearTimeout(hideTimeoutRef.current);
|
|
3009
|
+
}
|
|
3010
|
+
const keyboardWrapper = keyboardWrapperRef.current;
|
|
3011
|
+
if (!keyboardWrapper)
|
|
3012
|
+
return;
|
|
3013
|
+
const buttonEl = event.target.closest('.hg-button');
|
|
3014
|
+
if (!buttonEl || !keyboardWrapper.contains(buttonEl))
|
|
3015
|
+
return;
|
|
3016
|
+
const sourceKey = buttonEl.getAttribute('data-skbtn') ?? '';
|
|
3017
|
+
heldAccentKeyRef.current = null;
|
|
3018
|
+
longPressTriggeredRef.current = false;
|
|
3019
|
+
if (!sourceKey || sourceKey.startsWith('{'))
|
|
3020
|
+
return;
|
|
3021
|
+
const accentOptions = ACCENT_OPTIONS[sourceKey.toLowerCase()];
|
|
3022
|
+
if (!accentOptions)
|
|
3023
|
+
return;
|
|
3024
|
+
heldAccentKeyRef.current = sourceKey;
|
|
3025
|
+
clearLongPressTimeout();
|
|
3026
|
+
longPressTimeoutRef.current = setTimeout(() => {
|
|
3027
|
+
const buttonRect = buttonEl.getBoundingClientRect();
|
|
3028
|
+
const isUpperCaseKey = sourceKey === sourceKey.toUpperCase();
|
|
3029
|
+
longPressTriggeredRef.current = true;
|
|
3030
|
+
accentButtonRef.current = buttonEl;
|
|
3031
|
+
setAccentMenu({
|
|
3032
|
+
sourceKey,
|
|
3033
|
+
options: isUpperCaseKey
|
|
3034
|
+
? accentOptions.map((option) => option.toUpperCase())
|
|
3035
|
+
: accentOptions,
|
|
3036
|
+
top: buttonRect.top - 8,
|
|
3037
|
+
left: buttonRect.left + buttonRect.width / 2,
|
|
3038
|
+
});
|
|
3039
|
+
setAccentMenuOffsetX(0);
|
|
3040
|
+
suppressNextInputRef.current = sourceKey;
|
|
3041
|
+
}, LONG_PRESS_DELAY_MS);
|
|
3042
|
+
}, [clearLongPressTimeout]);
|
|
3043
|
+
const handleLongPressEnd = React.useCallback(() => {
|
|
3044
|
+
const heldKey = heldAccentKeyRef.current;
|
|
3045
|
+
const longPressTriggered = longPressTriggeredRef.current;
|
|
3046
|
+
const baseLayout = type === 'numeric' ? 'abc' : 'default';
|
|
3047
|
+
isKeyboardInteractingRef.current = false;
|
|
3048
|
+
clearLongPressTimeout();
|
|
3049
|
+
if (heldKey && !longPressTriggered) {
|
|
3050
|
+
const currentValue = valueRef.current;
|
|
3051
|
+
if (maxLength === undefined || currentValue.length < maxLength) {
|
|
3052
|
+
const nextValue = `${currentValue}${heldKey}`;
|
|
3053
|
+
onChange?.(nextValue);
|
|
3054
|
+
onKeyPress?.(heldKey);
|
|
3055
|
+
syncKeyboardInput(nextValue);
|
|
3056
|
+
}
|
|
3057
|
+
if (layoutName === 'shift' && !capsLockOn) {
|
|
3058
|
+
setLayoutName(baseLayout);
|
|
3059
|
+
}
|
|
3060
|
+
suppressNextInputRef.current = heldKey;
|
|
3061
|
+
}
|
|
3062
|
+
heldAccentKeyRef.current = null;
|
|
3063
|
+
longPressTriggeredRef.current = false;
|
|
3064
|
+
scheduleHideIfBlurred();
|
|
3065
|
+
}, [
|
|
3066
|
+
clearLongPressTimeout,
|
|
3067
|
+
scheduleHideIfBlurred,
|
|
3068
|
+
maxLength,
|
|
3069
|
+
onChange,
|
|
3070
|
+
onKeyPress,
|
|
3071
|
+
syncKeyboardInput,
|
|
3072
|
+
type,
|
|
3073
|
+
layoutName,
|
|
3074
|
+
capsLockOn,
|
|
3075
|
+
]);
|
|
3076
|
+
const handleAccentSelect = React.useCallback((accentedChar) => {
|
|
3077
|
+
const currentValue = valueRef.current;
|
|
3078
|
+
const baseLayout = type === 'numeric' ? 'abc' : 'default';
|
|
3079
|
+
if (maxLength !== undefined && currentValue.length >= maxLength) {
|
|
3080
|
+
closeAccentMenu();
|
|
3081
|
+
suppressNextInputRef.current = null;
|
|
3082
|
+
syncKeyboardInput(currentValue);
|
|
3083
|
+
return;
|
|
3084
|
+
}
|
|
3085
|
+
const nextValue = `${currentValue}${accentedChar}`;
|
|
3086
|
+
onChange?.(nextValue);
|
|
3087
|
+
onKeyPress?.(accentedChar);
|
|
3088
|
+
closeAccentMenu();
|
|
3089
|
+
suppressNextInputRef.current = null;
|
|
3090
|
+
heldAccentKeyRef.current = null;
|
|
3091
|
+
longPressTriggeredRef.current = false;
|
|
3092
|
+
if (layoutName === 'shift' && !capsLockOn) {
|
|
3093
|
+
setLayoutName(baseLayout);
|
|
3094
|
+
}
|
|
3095
|
+
syncKeyboardInput(nextValue);
|
|
3096
|
+
}, [maxLength, onChange, onKeyPress, closeAccentMenu, syncKeyboardInput, type, layoutName, capsLockOn]);
|
|
3097
|
+
const handleKeyPress = React.useCallback((button) => {
|
|
3098
|
+
const baseLayout = type === 'numeric' ? 'abc' : 'default';
|
|
3099
|
+
if (button === '{capslock}') {
|
|
3100
|
+
setCapsLockOn((prev) => {
|
|
3101
|
+
const next = !prev;
|
|
3102
|
+
setLayoutName(next ? 'caps' : baseLayout);
|
|
3103
|
+
return next;
|
|
3104
|
+
});
|
|
3105
|
+
return;
|
|
3106
|
+
}
|
|
3107
|
+
if (button === '{shift}' ||
|
|
3108
|
+
button === '{shiftactivated}') {
|
|
3109
|
+
if (button === '{shiftactivated}') {
|
|
3110
|
+
setCapsLockOn(false);
|
|
3111
|
+
setLayoutName(baseLayout);
|
|
3112
|
+
return;
|
|
3113
|
+
}
|
|
3114
|
+
setLayoutName((prev) => {
|
|
3115
|
+
const next = SHIFT_TOGGLES[prev] ?? 'default';
|
|
3116
|
+
return next === 'default' ? baseLayout : next;
|
|
3117
|
+
});
|
|
3118
|
+
return;
|
|
3119
|
+
}
|
|
3120
|
+
if (button === '{numbers}') {
|
|
3121
|
+
setLayoutName('numbers');
|
|
3122
|
+
return;
|
|
3123
|
+
}
|
|
3124
|
+
if (button === '{abc}') {
|
|
3125
|
+
setLayoutName(baseLayout);
|
|
3126
|
+
return;
|
|
3127
|
+
}
|
|
3128
|
+
if (button === '{alt}' || button === '{altright}') {
|
|
3129
|
+
setLayoutName((prev) => {
|
|
3130
|
+
if (prev === 'alt2')
|
|
3131
|
+
return 'alt';
|
|
3132
|
+
return prev === 'alt' ? baseLayout : 'alt';
|
|
3133
|
+
});
|
|
3134
|
+
return;
|
|
3135
|
+
}
|
|
3136
|
+
if (button === '{alt2}') {
|
|
3137
|
+
setLayoutName((prev) => (prev === 'alt2' ? 'alt' : 'alt2'));
|
|
3138
|
+
return;
|
|
3139
|
+
}
|
|
3140
|
+
if (button === '{emoticon}') {
|
|
3141
|
+
if (!Emoji)
|
|
3142
|
+
return;
|
|
3143
|
+
setLayoutName((prev) => (prev === 'emoticon' ? baseLayout : 'emoticon'));
|
|
3144
|
+
return;
|
|
3145
|
+
}
|
|
3146
|
+
if (button === '{default}') {
|
|
3147
|
+
setLayoutName(baseLayout);
|
|
3148
|
+
return;
|
|
3149
|
+
}
|
|
3150
|
+
if (button === '{downkeyboard}') {
|
|
3151
|
+
setLayoutName(baseLayout);
|
|
3152
|
+
if (variant === 'native') {
|
|
3153
|
+
closeAccentMenu();
|
|
3154
|
+
setIsOpen(false);
|
|
3155
|
+
const targetElement = targetRef?.current;
|
|
3156
|
+
if (targetElement && document.activeElement === targetElement) {
|
|
3157
|
+
targetElement.blur();
|
|
3158
|
+
}
|
|
3159
|
+
}
|
|
3160
|
+
return;
|
|
3161
|
+
}
|
|
3162
|
+
const isHeldAccentKey = heldAccentKeyRef.current === button;
|
|
3163
|
+
if (button !== '{bksp}' && button !== '{enter}' && !isHeldAccentKey) {
|
|
3164
|
+
if (layoutName === 'shift' && !capsLockOn) {
|
|
3165
|
+
setLayoutName(baseLayout);
|
|
3166
|
+
}
|
|
3167
|
+
else if (layoutName === baseLayout && capsLockOn) {
|
|
3168
|
+
setLayoutName('shift');
|
|
3169
|
+
}
|
|
3170
|
+
}
|
|
3171
|
+
if (isHeldAccentKey) {
|
|
3172
|
+
return;
|
|
3173
|
+
}
|
|
3174
|
+
onKeyPress?.(button);
|
|
3175
|
+
}, [
|
|
3176
|
+
type,
|
|
3177
|
+
layoutName,
|
|
3178
|
+
capsLockOn,
|
|
3179
|
+
onKeyPress,
|
|
3180
|
+
Emoji,
|
|
3181
|
+
variant,
|
|
3182
|
+
closeAccentMenu,
|
|
3183
|
+
targetRef,
|
|
3184
|
+
]);
|
|
3185
|
+
const handleChange = React.useCallback((input) => {
|
|
3186
|
+
const currentValue = valueRef.current;
|
|
3187
|
+
const suppressedKey = suppressNextInputRef.current;
|
|
3188
|
+
const heldKey = heldAccentKeyRef.current;
|
|
3189
|
+
if (heldKey &&
|
|
3190
|
+
input.length >= currentValue.length + 1 &&
|
|
3191
|
+
input.startsWith(currentValue) &&
|
|
3192
|
+
input.slice(currentValue.length).split('').every((char) => char === heldKey)) {
|
|
3193
|
+
syncKeyboardInput(currentValue);
|
|
3194
|
+
return;
|
|
3195
|
+
}
|
|
3196
|
+
if (suppressedKey &&
|
|
3197
|
+
input.length === currentValue.length + 1 &&
|
|
3198
|
+
input.endsWith(suppressedKey)) {
|
|
3199
|
+
suppressNextInputRef.current = null;
|
|
3200
|
+
syncKeyboardInput(currentValue);
|
|
3201
|
+
return;
|
|
3202
|
+
}
|
|
3203
|
+
if (maxLength !== undefined && input.length > maxLength)
|
|
3204
|
+
return;
|
|
3205
|
+
onChange?.(input);
|
|
3206
|
+
}, [maxLength, onChange, syncKeyboardInput]);
|
|
3207
|
+
const keyboardDisplay = React.useMemo(() => {
|
|
3208
|
+
const baseDisplay = LAYOUT_DISPLAY[visualType];
|
|
3209
|
+
if (!baseDisplay)
|
|
3210
|
+
return baseDisplay;
|
|
3211
|
+
if (variant !== 'fixed') {
|
|
3212
|
+
return baseDisplay;
|
|
3213
|
+
}
|
|
3214
|
+
return {
|
|
3215
|
+
...baseDisplay,
|
|
3216
|
+
'{bksp}': (baseDisplay['{bksp}'] ?? '').replace(/\s*Apagar$/, ''),
|
|
3217
|
+
};
|
|
3218
|
+
}, [visualType, variant]);
|
|
3219
|
+
const keyboardEl = activeLayout ? (jsxRuntime.jsxs("div", { ref: keyboardWrapperRef, className: styles$j.keyboardWrapper, onPointerDownCapture: handleLongPressStart, onPointerUpCapture: handleLongPressEnd, onPointerLeave: handleLongPressEnd, onPointerCancelCapture: handleLongPressEnd, children: [jsxRuntime.jsx(Keyboard, { keyboardRef: (instance) => {
|
|
3220
|
+
keyboardInstanceRef.current = instance;
|
|
3221
|
+
if (instance) {
|
|
3222
|
+
instance.setInput(valueRef.current);
|
|
3223
|
+
}
|
|
3224
|
+
}, layoutName: layoutName, layout: activeLayout, theme: 'hg-theme-default', display: keyboardDisplay, onChange: handleChange, onKeyPress: handleKeyPress, preventMouseDownDefault: true }), (() => {
|
|
3225
|
+
const shiftCount = { current: 0 };
|
|
3226
|
+
return iconSlots.map((slot) => {
|
|
3227
|
+
const key = slot.getAttribute('data-icon-key');
|
|
3228
|
+
const Icon = key ? ICON_KEY_MAP[key] : undefined;
|
|
3229
|
+
if (!Icon || !key)
|
|
3230
|
+
return null;
|
|
3231
|
+
if (key === 'shift') {
|
|
3232
|
+
const label = shiftCount.current === 0 ? 'left' : 'right';
|
|
3233
|
+
shiftCount.current += 1;
|
|
3234
|
+
return reactDom.createPortal(React.createElement(Icon), slot, `icon-shift-${label}`);
|
|
3235
|
+
}
|
|
3236
|
+
return reactDom.createPortal(React.createElement(Icon), slot, `icon-${key}`);
|
|
3237
|
+
});
|
|
3238
|
+
})(), accentMenu && (typeof document !== 'undefined' &&
|
|
3239
|
+
reactDom.createPortal(jsxRuntime.jsx("div", { ref: accentMenuRef, className: styles$j.accentMenu, style: {
|
|
3240
|
+
top: accentMenu.top,
|
|
3241
|
+
left: accentMenu.left + accentMenuOffsetX,
|
|
3242
|
+
}, role: "listbox", "aria-label": `Opcoes de acento para ${accentMenu.sourceKey}`, children: accentMenu.options.map((option) => (jsxRuntime.jsx("button", { type: "button", className: styles$j.accentOption, onPointerDown: (event) => {
|
|
3243
|
+
event.preventDefault();
|
|
3244
|
+
event.stopPropagation();
|
|
3245
|
+
}, onClick: () => handleAccentSelect(option), children: option }, `${accentMenu.sourceKey}-${option}`))) }), document.body))] })) : null;
|
|
3246
|
+
if (variant === 'native' && typeof document !== 'undefined') {
|
|
3247
|
+
return reactDom.createPortal(jsxRuntime.jsx("div", { id: id, className: clsx(styles$j.overlay, { [styles$j.overlayOpen]: isOpen }, styles$j[`layout--${visualType}`], className), children: keyboardEl }), document.body);
|
|
3248
|
+
}
|
|
3249
|
+
return (jsxRuntime.jsxs("div", { id: id, className: clsx(styles$j.container, styles$j[`mode--${variant}`], styles$j[`layout--${visualType}`], className), children: [variant === 'fixed' && (jsxRuntime.jsx("div", { className: styles$j.textFieldContainer, children: jsxRuntime.jsx(TextField, { placeholder: textFieldPlaceholder, value: value, onChange: onChange, helperText: helperText, error: error, errorMessage: errorMessage, readOnly: true, maxLength: maxLength, attachedToVirtualKeyboard: true, className: styles$j.textFieldWrapper }) })), keyboardEl] }));
|
|
3250
|
+
};
|
|
3251
|
+
|
|
3252
|
+
var styles$i = {"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"};
|
|
2625
3253
|
|
|
2626
3254
|
const validateInput = ({ value, maxLength, errorMessage, required }) => {
|
|
2627
3255
|
if (required && value.trim() === '') {
|
|
@@ -2635,22 +3263,28 @@ const validateInput = ({ value, maxLength, errorMessage, required }) => {
|
|
|
2635
3263
|
|
|
2636
3264
|
var styles$h = {"labelContainer":"index-module__labelContainer___WGyDF","wrapperLabel":"index-module__wrapperLabel___XJzZO","requiredLabel":"index-module__requiredLabel___7oZkh","infoIcon":"index-module__infoIcon___lClx4","errorIcon":"index-module__errorIcon___yN-lq","disabledIcon":"index-module__disabledIcon___89Os7","errorLabel":"index-module__errorLabel___qa6h6","disabledLabel":"index-module__disabledLabel___U9vL8","disabledContainer":"index-module__disabledContainer___MtOvy"};
|
|
2637
3265
|
|
|
2638
|
-
const LabelComponent = ({ children, htmlFor, required = false, tooltip = false, tooltipText, side = 'bottom', align = 'start', className, error = false, disabled = false }) =>
|
|
2639
|
-
|
|
3266
|
+
const LabelComponent = ({ children, htmlFor, required = false, tooltip = false, tooltipText, side = 'bottom', align = 'start', className, error = false, disabled = false }) => {
|
|
3267
|
+
const container = (jsxRuntime.jsxs("div", { className: clsx(styles$h.labelContainer, disabled && styles$h.disabledContainer), children: [jsxRuntime.jsxs(radixUi.Label.Root, { className: clsx(styles$h.wrapperLabel, error && !disabled && styles$h.errorLabel, disabled && styles$h.disabledLabel, className), htmlFor: htmlFor, children: [children, required && jsxRuntime.jsx("span", { className: styles$h.requiredLabel, children: "*" })] }), tooltip && (jsxRuntime.jsx("span", { className: disabled ? styles$h.disabledIcon : error ?
|
|
3268
|
+
styles$h.errorIcon : styles$h.infoIcon, children: jsxRuntime.jsx(reactIcons.Info12Regular, {}) }))] }));
|
|
3269
|
+
if (tooltip) {
|
|
3270
|
+
return (jsxRuntime.jsx(Tooltip, { side: side, align: align, text: tooltipText || '', children: container }));
|
|
3271
|
+
}
|
|
3272
|
+
return container;
|
|
3273
|
+
};
|
|
2640
3274
|
|
|
2641
|
-
const TextField$1 = React.forwardRef(({ className, value, label, placeholder, type = 'text', onChange, disabled = false, maxLength = 30, required = false, helperText, tooltip = false, tooltipText, side = 'bottom', align = 'start', errorMessage, error, id, icon, onBlur, onFocus, name, persistIcon = false, ...rest }, ref) => {
|
|
3275
|
+
const TextField$1 = React.forwardRef(({ className, value, label, placeholder, type = 'text', onChange, disabled = false, maxLength = 30, required = false, helperText, tooltip = false, tooltipText, side = 'bottom', align = 'start', errorMessage, error, id, icon, scale = 1, onBlur, onFocus, name, persistIcon = false, virtualKeyboard = false, virtualKeyboardType, virtualKeyboardMaxLength, attachedToVirtualKeyboard = false, ...rest }, ref) => {
|
|
2642
3276
|
const normalizeValue = (val) => {
|
|
2643
3277
|
return val === undefined || val === null ? '' : String(val);
|
|
2644
3278
|
};
|
|
2645
3279
|
const [inputValue, setInputValue] = React.useState(normalizeValue(value));
|
|
2646
3280
|
const [inputError, setInputError] = React.useState('');
|
|
2647
3281
|
const [isFocused, setIsFocused] = React.useState(false);
|
|
3282
|
+
const { internalRef: inputRef, setRefs: setInputRefs } = useInputKeyboardValue(ref);
|
|
2648
3283
|
const generatedId = React.useId();
|
|
2649
3284
|
const componentId = id || generatedId;
|
|
2650
3285
|
React.useEffect(() => {
|
|
2651
3286
|
const newValue = normalizeValue(value);
|
|
2652
3287
|
setInputValue(newValue);
|
|
2653
|
-
// Reavaliar erro quando valor muda externamente (ex: DatePicker atualiza o campo)
|
|
2654
3288
|
if (inputError) {
|
|
2655
3289
|
const validationError = validateInput({
|
|
2656
3290
|
value: newValue,
|
|
@@ -2698,17 +3332,29 @@ const TextField$1 = React.forwardRef(({ className, value, label, placeholder, ty
|
|
|
2698
3332
|
: helperText
|
|
2699
3333
|
? `${componentId}-helper`
|
|
2700
3334
|
: undefined;
|
|
2701
|
-
const
|
|
3335
|
+
const scaleClass = {
|
|
3336
|
+
1: 'scale-1-0',
|
|
3337
|
+
1.5: 'scale-1-5',
|
|
3338
|
+
2: 'scale-2-0',
|
|
3339
|
+
}[scale];
|
|
3340
|
+
const containerClass = clsx(styles$i.container, scaleClass, {
|
|
2702
3341
|
[styles$i.disabled]: disabled,
|
|
2703
3342
|
[styles$i.error]: hasError && !disabled,
|
|
3343
|
+
[styles$i.errorWithMessage]: Boolean(error) && Boolean(errorMessage) && !disabled,
|
|
3344
|
+
[styles$i.attachedToVirtualKeyboard]: attachedToVirtualKeyboard,
|
|
2704
3345
|
[className]: className,
|
|
2705
3346
|
});
|
|
2706
|
-
return (jsxRuntime.jsxs("div", { className: containerClass, children: [label && (jsxRuntime.jsx(LabelComponent, { htmlFor: componentId, required: required, tooltip: tooltip, tooltipText: tooltipText, side: side, align: align, error: hasError, disabled: disabled, children: label })), jsxRuntime.jsxs("div", { className: styles$i.inputWrapper, children: [jsxRuntime.jsxs("div", { className: styles$i.inputContainer, children: [jsxRuntime.jsx("input", { ...rest, ref:
|
|
3347
|
+
return (jsxRuntime.jsxs("div", { className: containerClass, children: [label && (jsxRuntime.jsx(LabelComponent, { htmlFor: componentId, required: required, tooltip: tooltip, tooltipText: tooltipText, side: side, align: align, error: hasError, disabled: disabled, children: label })), jsxRuntime.jsxs("div", { className: styles$i.inputWrapper, children: [jsxRuntime.jsxs("div", { className: styles$i.inputContainer, children: [jsxRuntime.jsx("input", { ...rest, ref: setInputRefs, id: componentId, name: name, type: type, value: inputValue, placeholder: placeholder, onChange: handleChange, onFocus: handleFocus, onBlur: handleBlur, maxLength: maxLength, disabled: disabled, "aria-invalid": hasError, "aria-required": required, "aria-describedby": helperId, inputMode: virtualKeyboard ? 'none' : rest.inputMode, className: clsx({
|
|
2707
3348
|
[styles$i.inputWithIcon]: showCustomIcon || showClearIcon,
|
|
2708
3349
|
}) }), showCustomIcon && jsxRuntime.jsx("span", { className: styles$i.icon, children: icon }), showClearIcon && (jsxRuntime.jsx("button", { type: "button", className: styles$i.clearButton, onMouseDown: (e) => {
|
|
2709
3350
|
e.preventDefault();
|
|
2710
3351
|
handleClear();
|
|
2711
|
-
}, "aria-label": "Limpar campo", tabIndex: -1, children: jsxRuntime.jsx(reactIcons.Dismiss16Regular, {}) }))] }), jsxRuntime.jsx("span", { id: helperId, className: styles$i.helperText, "aria-live": hasError ? 'polite' : undefined, children: displayHelperText })] })
|
|
3352
|
+
}, "aria-label": "Limpar campo", tabIndex: -1, children: jsxRuntime.jsx(reactIcons.Dismiss16Regular, {}) }))] }), (errorMessage || inputError || helperText) && (jsxRuntime.jsx("span", { id: helperId, className: styles$i.helperText, "aria-live": hasError ? 'polite' : undefined, children: displayHelperText }))] }), virtualKeyboard && (jsxRuntime.jsx("div", { className: "virtualKeyboardWrapper", children: jsxRuntime.jsx(VirtualKeyboard, { variant: "native", type: virtualKeyboardType, value: inputValue, maxLength: maxLength ?? virtualKeyboardMaxLength, targetRef: inputRef, onChange: (val) => {
|
|
3353
|
+
if (!disabled && (!maxLength || val.length <= maxLength)) {
|
|
3354
|
+
setInputValue(val);
|
|
3355
|
+
onChange?.(val);
|
|
3356
|
+
}
|
|
3357
|
+
} }) }))] }));
|
|
2712
3358
|
});
|
|
2713
3359
|
TextField$1.displayName = 'TextField';
|
|
2714
3360
|
var TextField = React.memo(TextField$1);
|
|
@@ -2805,7 +3451,7 @@ function validatePartialDate(value, locale = 'pt-br') {
|
|
|
2805
3451
|
return 'incomplete';
|
|
2806
3452
|
}
|
|
2807
3453
|
|
|
2808
|
-
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, className, ...rest }) => {
|
|
3454
|
+
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, datePickerScale = 1, calendarScale = 1, className, ...rest }) => {
|
|
2809
3455
|
const fieldId = React.useId();
|
|
2810
3456
|
const calendarId = `${fieldId}-calendar`;
|
|
2811
3457
|
const isControlled = value !== undefined;
|
|
@@ -2822,6 +3468,11 @@ const DatePicker = ({ locale = 'pt-br', calendarSide = 'bottom', calendarAlign =
|
|
|
2822
3468
|
const combinedHelperText = externalError && helperText
|
|
2823
3469
|
? `${helperText} • ${externalError}`
|
|
2824
3470
|
: externalError || helperText || '';
|
|
3471
|
+
const scaleClass = {
|
|
3472
|
+
1: 'scale-1-0',
|
|
3473
|
+
1.5: 'scale-1-5',
|
|
3474
|
+
2: 'scale-2-0',
|
|
3475
|
+
}[datePickerScale];
|
|
2825
3476
|
React.useEffect(() => {
|
|
2826
3477
|
function handleClickOutside(event) {
|
|
2827
3478
|
const target = event.target;
|
|
@@ -2934,9 +3585,9 @@ const DatePicker = ({ locale = 'pt-br', calendarSide = 'bottom', calendarAlign =
|
|
|
2934
3585
|
}
|
|
2935
3586
|
}
|
|
2936
3587
|
};
|
|
2937
|
-
return (jsxRuntime.jsx("div", { ref: wrapperRef, className: clsx(styles$g.datePicker, className), ...rest, children: jsxRuntime.jsx(Popover, { open: showCalendar, onOpenChange: setShowCalendar, asAnchor: true, trigger: jsxRuntime.jsx(TextField, { className: styles$g.textfieldContainer, type: "tel", icon: jsxRuntime.jsx(reactIcons.Calendar16Regular, { onClick: !disabled ? handleIconClick : undefined, className: clsx(styles$g.datePickerIcon, disabled && styles$g.datePickerIconDisabled) }), onChange: (e) => {
|
|
3588
|
+
return (jsxRuntime.jsx("div", { ref: wrapperRef, className: clsx(styles$g.datePicker, scaleClass, className), ...rest, children: jsxRuntime.jsx(Popover, { open: showCalendar, onOpenChange: setShowCalendar, asAnchor: true, trigger: jsxRuntime.jsx(TextField, { className: styles$g.textfieldContainer, type: "tel", icon: jsxRuntime.jsx(reactIcons.Calendar16Regular, { onClick: !disabled ? handleIconClick : undefined, className: clsx(styles$g.datePickerIcon, disabled && styles$g.datePickerIconDisabled) }), onChange: (e) => {
|
|
2938
3589
|
handleTextFieldChange(String(e));
|
|
2939
|
-
}, onKeyDown: handleKeyDown, onFocus: handleFocus, persistIcon: true, autoComplete: "off", value: displayValue, helperText: !externalError ? (helperText || undefined) : undefined, errorMessage: externalError ? combinedHelperText : undefined, error: hasValidationError ? true : undefined, maxLength: 10, required: required, label: label, disabled: disabled, id: fieldId, "data-testid": testId, placeholder: locale === 'en-us' ? 'MM/DD/YYYY' : 'DD/MM/YYYY', "aria-label": "Open calendar", "aria-expanded": showCalendar, "aria-controls": calendarId, "aria-invalid": hasValidationError, "aria-describedby": externalError ? undefined : (helperText ? `${fieldId}-help` : undefined) }), content: jsxRuntime.jsx(Calendar, { selected: currentSelectedDate, currentDate: currentDate, onDateChange: setCurrentDate, onDaySelect: handleDaySelect, locale: locale, format: locale === 'en-us' ? 'mm/dd/yyyy' : 'dd/mm/yyyy', minDate: minDate, maxDate: maxDate, id: calendarId, onClear: () => {
|
|
3590
|
+
}, onKeyDown: handleKeyDown, onFocus: handleFocus, persistIcon: true, autoComplete: "off", value: displayValue, helperText: !externalError ? (helperText || undefined) : undefined, errorMessage: externalError ? combinedHelperText : undefined, error: hasValidationError ? true : undefined, maxLength: 10, required: required, label: label, disabled: disabled, id: fieldId, "data-testid": testId, placeholder: locale === 'en-us' ? 'MM/DD/YYYY' : 'DD/MM/YYYY', "aria-label": "Open calendar", "aria-expanded": showCalendar, "aria-controls": calendarId, "aria-invalid": hasValidationError, "aria-describedby": externalError ? undefined : (helperText ? `${fieldId}-help` : undefined) }), content: jsxRuntime.jsx(Calendar, { selected: currentSelectedDate, currentDate: currentDate, onDateChange: setCurrentDate, onDaySelect: handleDaySelect, locale: locale, format: locale === 'en-us' ? 'mm/dd/yyyy' : 'dd/mm/yyyy', minDate: minDate, maxDate: maxDate, scale: calendarScale, id: calendarId, onClear: () => {
|
|
2940
3591
|
handleDateChange(null);
|
|
2941
3592
|
setCurrentDate(new Date());
|
|
2942
3593
|
} }), side: calendarSide, align: calendarAlign, sideOffset: 8 }) }));
|
|
@@ -2949,7 +3600,7 @@ const Dialog = ({ show = false, title, bodyContent, textPrimaryAction, textSecon
|
|
|
2949
3600
|
|
|
2950
3601
|
var styles$e = {"drawerShadow":"Drawer-module__drawerShadow___0Z6iL","drawerShadow--visible":"Drawer-module__drawerShadow--visible___FspoH","drawerSidebar":"Drawer-module__drawerSidebar___cdyyb","drawerSidebar--open":"Drawer-module__drawerSidebar--open___ee2-Y","drawerSidebar--disabled":"Drawer-module__drawerSidebar--disabled___MYrBI","drawerTitleClose":"Drawer-module__drawerTitleClose___QzqN-","drawerTitle":"Drawer-module__drawerTitle___naMX0","drawerChildren":"Drawer-module__drawerChildren___xGdg9","drawerHeaderContent":"Drawer-module__drawerHeaderContent___NLSwj"};
|
|
2951
3602
|
|
|
2952
|
-
const Drawer = ({ children, headerContent, customWidth = '400px', onClose, title = 'Título', isOpen = false, onOpen, className, id, disabled = false, onOverlayClick, closeOnOverlayClick = true, closeOnEscape = true, ...rest }) => {
|
|
3603
|
+
const Drawer = ({ children, headerContent, footer, customWidth = '400px', onClose, title = 'Título', isOpen = false, onOpen, className, id, disabled = false, onOverlayClick, closeOnOverlayClick = true, closeOnEscape = true, ...rest }) => {
|
|
2953
3604
|
const internalClose = React.useCallback(() => {
|
|
2954
3605
|
if (disabled)
|
|
2955
3606
|
return;
|
|
@@ -3003,17 +3654,45 @@ const Drawer = ({ children, headerContent, customWidth = '400px', onClose, title
|
|
|
3003
3654
|
[styles$e['drawerSidebar--disabled']]: disabled,
|
|
3004
3655
|
}, className), style: {
|
|
3005
3656
|
'--drawer-custom-width': customWidth,
|
|
3006
|
-
}, onClick: handleDrawerClick, role: "dialog", "aria-modal": "true", "aria-labelledby": id ? `${id}-title` : 'drawer-title', "aria-hidden": !isOpen, "data-testid": "drawer-panel", id: id, ...rest, children: [jsxRuntime.jsxs("div", { className: styles$e.drawerTitleClose, children: [jsxRuntime.jsx("div", { className: styles$e.drawerTitle, id: id ? `${id}-title` : 'drawer-title', children: title }), headerContent && (jsxRuntime.jsx("div", { className: styles$e.drawerHeaderContent, children: headerContent })), jsxRuntime.jsx(Button, { onClick: handleCloseClick, variant: 'outlined', iconOnly: true, icon: jsxRuntime.jsx(reactIcons.Dismiss16Regular, {}), size: 'lg', tooltipText: 'Fechar' })] }), jsxRuntime.jsx("div", { className: styles$e.drawerChildren, "data-testid": "drawer-content", children: children })] })] }), document.body);
|
|
3657
|
+
}, onClick: handleDrawerClick, role: "dialog", "aria-modal": "true", "aria-labelledby": id ? `${id}-title` : 'drawer-title', "aria-hidden": !isOpen, "data-testid": "drawer-panel", id: id, ...rest, children: [jsxRuntime.jsxs("div", { className: styles$e.drawerTitleClose, children: [jsxRuntime.jsx("div", { className: styles$e.drawerTitle, id: id ? `${id}-title` : 'drawer-title', children: title }), headerContent && (jsxRuntime.jsx("div", { className: styles$e.drawerHeaderContent, children: headerContent })), jsxRuntime.jsx(Button, { onClick: handleCloseClick, variant: 'outlined', iconOnly: true, icon: jsxRuntime.jsx(reactIcons.Dismiss16Regular, {}), size: 'lg', tooltipText: 'Fechar' })] }), jsxRuntime.jsx("div", { className: styles$e.drawerChildren, "data-testid": "drawer-content", children: children }), footer] })] }), document.body);
|
|
3007
3658
|
};
|
|
3008
3659
|
|
|
3009
|
-
var styles$d = {"search":"
|
|
3660
|
+
var styles$d = {"container":"Filter-module__container___cqntK","panel":"Filter-module__panel___19HqD","search":"Filter-module__search___f0gzj","list":"Filter-module__list___UpBk1","item":"Filter-module__item___oNdeY","itemSelected":"Filter-module__itemSelected___JIpJV","itemText":"Filter-module__itemText___RS--0","itemDisabled":"Filter-module__itemDisabled___X-ktg","itemIcon":"Filter-module__itemIcon___RjJSa","noResults":"Filter-module__noResults___3m6pn","footer":"Filter-module__footer___yYS5j","buttonContent":"Filter-module__buttonContent___28fKe","buttonArrow":"Filter-module__buttonArrow___VJlpc","buttonIcon":"Filter-module__buttonIcon___OOBpZ","triggerWrapper":"Filter-module__triggerWrapper___ptPRL","triggerContent":"Filter-module__triggerContent___LYo9j","body":"Filter-module__body___qsyhk","combinedFooter":"Filter-module__combinedFooter___kTnHP"};
|
|
3010
3661
|
|
|
3011
|
-
const
|
|
3662
|
+
const Combined = ({ buttonText = 'Filtrar', icon, variant = 'outlined', disabled = false, className, title = 'Filtrar', drawerWidth = "fit-content", activeCount = 0, drawerHeaderContent, children, onApply, onClear, onOpen, onClose, id, ...rest }) => {
|
|
3663
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
3664
|
+
const handleOpen = React.useCallback(() => {
|
|
3665
|
+
setIsOpen(true);
|
|
3666
|
+
onOpen?.();
|
|
3667
|
+
}, [onOpen]);
|
|
3668
|
+
const handleClose = React.useCallback(() => {
|
|
3669
|
+
setIsOpen(false);
|
|
3670
|
+
onClose?.();
|
|
3671
|
+
}, [onClose]);
|
|
3672
|
+
const handleApply = React.useCallback(() => {
|
|
3673
|
+
onApply?.();
|
|
3674
|
+
handleClose();
|
|
3675
|
+
}, [onApply, handleClose]);
|
|
3676
|
+
const handleClear = React.useCallback(() => {
|
|
3677
|
+
onClear?.();
|
|
3678
|
+
}, [onClear]);
|
|
3679
|
+
return (jsxRuntime.jsxs("div", { className: clsx(styles$d.triggerWrapper, className), id: id, ...rest, children: [jsxRuntime.jsx(Button, { variant: variant, disabled: disabled, icon: icon ?? jsxRuntime.jsx(reactIcons.FilterRegular, {}), iconPosition: "left", onClick: handleOpen, children: jsxRuntime.jsxs("span", { className: styles$d.triggerContent, children: [buttonText, activeCount > 0 && (jsxRuntime.jsx(Badge, { badgeValue: activeCount, filterVariant: true }))] }) }), jsxRuntime.jsx(Drawer, { isOpen: isOpen, onClose: handleClose, title: title, customWidth: drawerWidth, closeOnOverlayClick: true, closeOnEscape: true, headerContent: drawerHeaderContent, footer: jsxRuntime.jsxs("div", { className: styles$d.combinedFooter, children: [jsxRuntime.jsx(Button, { variant: "outlined", onClick: handleClear, children: "Limpar" }), jsxRuntime.jsx(Button, { onClick: handleApply, children: "Aplicar" })] }), children: jsxRuntime.jsx("div", { className: styles$d.body, children: children }) })] }));
|
|
3680
|
+
};
|
|
3681
|
+
|
|
3682
|
+
var styles$c = {"search":"Search-module__search___u3QsV","searchLeftIcon":"Search-module__searchLeftIcon___OKOBq","disabled":"Search-module__disabled___adbxO","inputWithClearIcon":"Search-module__inputWithClearIcon___cqvkq","searchClearIcon":"Search-module__searchClearIcon___qX9-h"};
|
|
3683
|
+
|
|
3684
|
+
const Search = React.forwardRef(({ placeholder = 'Dica do que deve ser buscado', disabled = false, value, onChange, onKeyDown, onFocus, onBlur, onClear, onClick, onMouseDown, searchMode = 'instant', onSearch, id, scale = 1, className, virtualKeyboard = false, virtualKeyboardType, virtualKeyboardMaxLength, 'data-testid': testId, ...rest }, ref) => {
|
|
3012
3685
|
const [internalValue, setInternalValue] = React.useState('');
|
|
3686
|
+
const { internalRef: inputRef, setRefs: setInputRefs } = useInputKeyboardValue(ref);
|
|
3013
3687
|
const isControlled = value !== undefined && onChange !== undefined;
|
|
3014
3688
|
const currentValue = isControlled ? value : internalValue;
|
|
3015
3689
|
const generatedId = React.useId();
|
|
3016
3690
|
const inputId = id || generatedId;
|
|
3691
|
+
const scaleClass = {
|
|
3692
|
+
1: 'scale-1-0',
|
|
3693
|
+
1.5: 'scale-1-5',
|
|
3694
|
+
2: 'scale-2-0',
|
|
3695
|
+
}[scale];
|
|
3017
3696
|
const handleChange = (e) => {
|
|
3018
3697
|
if (disabled)
|
|
3019
3698
|
return;
|
|
@@ -3023,6 +3702,9 @@ const Search = React.forwardRef(({ placeholder = 'Dica do que deve ser buscado',
|
|
|
3023
3702
|
else {
|
|
3024
3703
|
setInternalValue(e.target.value);
|
|
3025
3704
|
}
|
|
3705
|
+
if (searchMode === 'instant') {
|
|
3706
|
+
onSearch?.(e.target.value);
|
|
3707
|
+
}
|
|
3026
3708
|
};
|
|
3027
3709
|
const handleFocus = (e) => {
|
|
3028
3710
|
if (disabled)
|
|
@@ -3052,20 +3734,34 @@ const Search = React.forwardRef(({ placeholder = 'Dica do que deve ser buscado',
|
|
|
3052
3734
|
const handleKeyDown = (e) => {
|
|
3053
3735
|
if (disabled)
|
|
3054
3736
|
return;
|
|
3737
|
+
if (searchMode === 'on-enter' && e.key === 'Enter') {
|
|
3738
|
+
onSearch?.(currentValue || '');
|
|
3739
|
+
}
|
|
3055
3740
|
onKeyDown?.(e);
|
|
3056
3741
|
};
|
|
3057
|
-
return (jsxRuntime.jsxs("div", { className: clsx(styles$
|
|
3742
|
+
return (jsxRuntime.jsxs("div", { className: clsx(styles$c.search, scaleClass, { [styles$c.disabled]: disabled }, className), onClick: onClick, onMouseDown: onMouseDown, role: onClick || onMouseDown ? "button" : undefined, tabIndex: onClick || onMouseDown ? 0 : undefined, onKeyDown: onClick || onMouseDown ? (e) => {
|
|
3058
3743
|
if (e.key === 'Enter' || e.key === ' ') {
|
|
3059
3744
|
e.preventDefault();
|
|
3060
3745
|
onClick?.(e);
|
|
3061
3746
|
}
|
|
3062
|
-
} : undefined, children: [jsxRuntime.jsx("span", { className: clsx(styles$
|
|
3747
|
+
} : undefined, children: [jsxRuntime.jsx("span", { className: clsx(styles$c.searchLeftIcon, { [styles$c.disabled]: disabled }), tabIndex: -1, role: "presentation", "aria-hidden": "true", children: jsxRuntime.jsx(reactIcons.Search16Regular, {}) }), jsxRuntime.jsx("input", { ref: setInputRefs, id: inputId, type: "text", placeholder: placeholder, "aria-label": placeholder, value: currentValue || '', onChange: handleChange, onKeyDown: handleKeyDown, disabled: disabled, onFocus: handleFocus, onBlur: handleBlur, "data-testid": testId, ...rest, inputMode: virtualKeyboard ? 'none' : rest.inputMode, className: clsx({ [styles$c.inputWithClearIcon]: currentValue && currentValue.length > 0 }) }), currentValue && currentValue.length > 0 && (jsxRuntime.jsx("span", { className: styles$c.searchClearIcon, "aria-hidden": "true", onClick: clearInputSearch, children: jsxRuntime.jsx(reactIcons.Dismiss16Regular, {}) })), virtualKeyboard && (jsxRuntime.jsx("div", { className: "virtualKeyboardWrapper", children: jsxRuntime.jsx(VirtualKeyboard, { variant: "native", type: virtualKeyboardType, maxLength: virtualKeyboardMaxLength, value: currentValue || '', targetRef: inputRef, onChange: (val) => {
|
|
3748
|
+
if (disabled)
|
|
3749
|
+
return;
|
|
3750
|
+
if (isControlled) {
|
|
3751
|
+
const syntheticEvent = {
|
|
3752
|
+
target: { value: val },
|
|
3753
|
+
currentTarget: { value: val },
|
|
3754
|
+
};
|
|
3755
|
+
onChange?.(syntheticEvent);
|
|
3756
|
+
}
|
|
3757
|
+
else {
|
|
3758
|
+
setInternalValue(val);
|
|
3759
|
+
}
|
|
3760
|
+
} }) }))] }));
|
|
3063
3761
|
});
|
|
3064
3762
|
Search.displayName = 'Search';
|
|
3065
3763
|
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
const Filter = ({ items, type = 'checkbox', selectedIds, onApplyFilter, placeholder = 'Selecionar...', enableSearch = false, buttonText = 'Filter', icon, variant = 'outlined', onOpen, onClose, side = 'bottom', align = 'start', disabled = false, className, selectedDate, onDateSelect, onClearDate, minDate, maxDate, locale = 'pt-br', id, ...rest }) => {
|
|
3764
|
+
const Simple = ({ items, type = 'multiple', selectedIds, onApplyFilter, placeholder = 'Selecionar...', enableSearch = false, buttonText = 'Filter', icon, variant = 'outlined', onOpen, onClose, side = 'bottom', align = 'start', disabled = false, className, selectedDate, onDateSelect, onClearDate, minDate, maxDate, locale = 'pt-br', id, ...rest }) => {
|
|
3069
3765
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
3070
3766
|
const [tempSelectedItems, setTempSelectedItems] = React.useState({});
|
|
3071
3767
|
const [searchQuery, setSearchQuery] = React.useState('');
|
|
@@ -3108,7 +3804,7 @@ const Filter = ({ items, type = 'checkbox', selectedIds, onApplyFilter, placehol
|
|
|
3108
3804
|
if (item.disabled)
|
|
3109
3805
|
return;
|
|
3110
3806
|
setTempSelectedItems((prev) => {
|
|
3111
|
-
if (type === '
|
|
3807
|
+
if (type === 'multiple') {
|
|
3112
3808
|
return { ...prev, [itemId]: !prev[itemId] };
|
|
3113
3809
|
}
|
|
3114
3810
|
return prev[itemId] ? {} : { [itemId]: true };
|
|
@@ -3156,31 +3852,44 @@ const Filter = ({ items, type = 'checkbox', selectedIds, onApplyFilter, placehol
|
|
|
3156
3852
|
return null;
|
|
3157
3853
|
return selectedIds.length - 1;
|
|
3158
3854
|
}, [selectedIds]);
|
|
3159
|
-
const filterClass = clsx(styles$
|
|
3160
|
-
const triggerButton = (jsxRuntime.jsx(Button, { variant: variant, disabled: disabled, icon: type === 'calendar' ? jsxRuntime.jsx(reactIcons.Calendar16Regular, {}) : jsxRuntime.jsx(reactIcons.ChevronDownRegular, {}), iconPosition: "right", size: "lg", children: jsxRuntime.jsxs("div", { className: styles$
|
|
3161
|
-
const popoverContent = type === 'calendar' ? (jsxRuntime.jsx(Calendar, { currentDate: currentCalendarDate, selected: selectedDate, onDaySelect: handleDateSelection, onDateChange: handleCalendarNavigation, minDate: minDate, maxDate: maxDate, locale: locale, onClear: handleClear, id: `filter-calendar-${id || ''}`, "aria-label": "Selecionar data para filtro" })) : (jsxRuntime.jsxs("div", { className: styles$
|
|
3855
|
+
const filterClass = clsx(styles$d.container, className);
|
|
3856
|
+
const triggerButton = (jsxRuntime.jsx(Button, { variant: variant, disabled: disabled, icon: type === 'calendar' ? jsxRuntime.jsx(reactIcons.Calendar16Regular, {}) : jsxRuntime.jsx(reactIcons.ChevronDownRegular, {}), iconPosition: "right", size: "lg", children: jsxRuntime.jsxs("div", { className: styles$d.buttonContent, children: [icon && jsxRuntime.jsx("span", { className: styles$d.buttonIcon, children: icon }), jsxRuntime.jsx("span", { className: styles$d.buttonText, children: buttonDisplayText }), jsxRuntime.jsx("span", { className: clsx(styles$d.buttonArrow, { [styles$d.buttonArrowOpen]: isOpen }), children: getBadgeValue() && (jsxRuntime.jsx(Badge, { badgeValue: `+${getBadgeValue()}`, filterVariant: true })) })] }) }));
|
|
3857
|
+
const popoverContent = type === 'calendar' ? (jsxRuntime.jsx(Calendar, { currentDate: currentCalendarDate, selected: selectedDate, onDaySelect: handleDateSelection, onDateChange: handleCalendarNavigation, minDate: minDate, maxDate: maxDate, locale: locale, onClear: handleClear, id: `filter-calendar-${id || ''}`, "aria-label": "Selecionar data para filtro" })) : (jsxRuntime.jsxs("div", { className: styles$d.panel, children: [searchVisible && (jsxRuntime.jsx("div", { className: styles$d.search, children: jsxRuntime.jsx(Search, { value: searchQuery, placeholder: placeholder, onChange: handleSearchChange, onKeyDown: handleSearchKeyDown, onClear: () => setSearchQuery('') }) })), jsxRuntime.jsx("ul", { className: styles$d.list, role: "listbox", "aria-multiselectable": type === 'multiple', children: filteredItems.length > 0 ? (filteredItems.map((item, index) => {
|
|
3162
3858
|
const itemId = item.id || `filter-item-${index}`;
|
|
3163
3859
|
const isSelected = !!tempSelectedItems[itemId];
|
|
3164
|
-
return (jsxRuntime.jsxs("li", { role: "option", "aria-selected": isSelected, "aria-disabled": item.disabled, className: clsx(styles$
|
|
3165
|
-
[styles$
|
|
3166
|
-
[styles$
|
|
3860
|
+
return (jsxRuntime.jsxs("li", { role: "option", "aria-selected": isSelected, "aria-disabled": item.disabled, className: clsx(styles$d.item, {
|
|
3861
|
+
[styles$d.itemSelected]: isSelected,
|
|
3862
|
+
[styles$d.itemDisabled]: item.disabled,
|
|
3167
3863
|
}), onMouseDown: (e) => e.preventDefault(), onClick: () => toggleItem(itemId, item), onKeyDown: (e) => {
|
|
3168
3864
|
if (e.key === 'Enter' || e.key === ' ') {
|
|
3169
3865
|
e.preventDefault();
|
|
3170
3866
|
toggleItem(itemId, item);
|
|
3171
3867
|
}
|
|
3172
|
-
}, children: [type === '
|
|
3173
|
-
})) : (jsxRuntime.jsx("li", { className: styles$
|
|
3868
|
+
}, 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));
|
|
3869
|
+
})) : (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" })] })] }));
|
|
3174
3870
|
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 }) }));
|
|
3175
3871
|
};
|
|
3176
3872
|
|
|
3873
|
+
const Filter = ({ mode = 'simple', ...props }) => {
|
|
3874
|
+
if (mode === 'combined') {
|
|
3875
|
+
return jsxRuntime.jsx(Combined, { ...props });
|
|
3876
|
+
}
|
|
3877
|
+
return jsxRuntime.jsx(Simple, { ...props });
|
|
3878
|
+
};
|
|
3879
|
+
|
|
3177
3880
|
var styles$b = {"zds-list-item__container":"ListItem-module__zds-list-item__container___mEIUK","zds-list-item--checkbox":"ListItem-module__zds-list-item--checkbox___wfi9-","zds-list-item--icon":"ListItem-module__zds-list-item--icon___h3Ijt","zds-list-item--radio":"ListItem-module__zds-list-item--radio___2l7mK","zds-list-item--text":"ListItem-module__zds-list-item--text___F0PDx","zds-list-item--hovered":"ListItem-module__zds-list-item--hovered___XrDWn","zds-list-item--disabled":"ListItem-module__zds-list-item--disabled___p1xZF","zds-list-item__wrapper-text":"ListItem-module__zds-list-item__wrapper-text___5-TX2","zds-list-item__wrapper-icon":"ListItem-module__zds-list-item__wrapper-icon___S6Fr1","zds-list-item__title":"ListItem-module__zds-list-item__title___AV7nz","zds-list-item__subtext":"ListItem-module__zds-list-item__subtext___nfXky","zds-list-item__text":"ListItem-module__zds-list-item__text___3y0sB"};
|
|
3178
3881
|
|
|
3179
3882
|
var styles$a = {"root":"Radio-module__root___7ElY2","wrapper":"Radio-module__wrapper___NYQ1y","disabled":"Radio-module__disabled___RZ0be","labelText":"Radio-module__labelText___Wkb41","item":"Radio-module__item___3Kvj7","itemWrapper":"Radio-module__itemWrapper___5KbM1","labelWrapper":"Radio-module__labelWrapper___LOHmJ","indicator":"Radio-module__indicator___TJ5hz"};
|
|
3180
3883
|
|
|
3181
|
-
const Radio = ({ items, onValueChange, defaultValue, name, id, ariaLabel, orientation = 'vertical', className, ...rest }) => {
|
|
3182
|
-
const
|
|
3183
|
-
|
|
3884
|
+
const Radio = ({ items, onValueChange, defaultValue, name, id, ariaLabel, orientation = 'vertical', scale = 1, className, ...rest }) => {
|
|
3885
|
+
const generatedId = React.useId();
|
|
3886
|
+
const componentId = id || generatedId;
|
|
3887
|
+
const scaleClass = {
|
|
3888
|
+
1: 'scale-1-0',
|
|
3889
|
+
1.5: 'scale-1-5',
|
|
3890
|
+
2: 'scale-2-0',
|
|
3891
|
+
}[scale];
|
|
3892
|
+
return (jsxRuntime.jsx(radixUi.RadioGroup.Root, { id: componentId, className: clsx(styles$a.root, scaleClass, className), defaultValue: defaultValue, onValueChange: onValueChange, name: name, "aria-label": ariaLabel, "data-orientation": orientation, orientation: orientation, ...rest, children: items.map(({ id, value, disabled, label }) => {
|
|
3184
3893
|
const itemKey = id ?? value;
|
|
3185
3894
|
const uniqueId = `${componentId}-item-${value}`;
|
|
3186
3895
|
return (jsxRuntime.jsx("div", { className: clsx(styles$a.wrapper, { [styles$a.disabled]: disabled }), children: jsxRuntime.jsxs("label", { className: styles$a.labelWrapper, htmlFor: uniqueId, children: [jsxRuntime.jsx("div", { className: styles$a.itemWrapper, children: jsxRuntime.jsx(radixUi.RadioGroup.Item, { disabled: disabled, className: styles$a.item, value: value, id: uniqueId, "data-disabled": disabled, children: jsxRuntime.jsx(radixUi.RadioGroup.Indicator, { className: styles$a.indicator }) }) }), jsxRuntime.jsx("span", { className: styles$a.labelText, children: label })] }) }, itemKey));
|
|
@@ -3401,7 +4110,7 @@ const useSearchLogic = ({ items, searchValue, searchTerm, enableApiSearch, onApi
|
|
|
3401
4110
|
return { filteredItems: filteredItems() };
|
|
3402
4111
|
};
|
|
3403
4112
|
|
|
3404
|
-
const Menu = ({ items, children, onItemSelect, search, enableInfiniteScroll, onScrollEnd, isLoadingMore, onApiSearch, enableApiSearch, selectedItems, onOpenChange, align = 'start', className, maxHeight = 400, ...rest }) => {
|
|
4113
|
+
const Menu = ({ items, children, onItemSelect, search, enableInfiniteScroll, onScrollEnd, isLoadingMore, onApiSearch, enableApiSearch, selectedItems, onOpenChange, align = 'start', dropdownScale = 1, buttonScale, className, maxHeight = 400, ...rest }) => {
|
|
3405
4114
|
const itemsWrapperRef = React.useRef(null);
|
|
3406
4115
|
const hasReachedEndRef = React.useRef(false);
|
|
3407
4116
|
const observerRef = React.useRef(null);
|
|
@@ -3411,6 +4120,16 @@ const Menu = ({ items, children, onItemSelect, search, enableInfiniteScroll, onS
|
|
|
3411
4120
|
const [searchInput, setSearchInput] = React.useState('');
|
|
3412
4121
|
const [searchTerm, setSearchTerm] = React.useState('');
|
|
3413
4122
|
const maxHeightStyle = typeof maxHeight === 'number' ? `${maxHeight}px` : maxHeight;
|
|
4123
|
+
const scaleClass = {
|
|
4124
|
+
1: 'scale-1-0',
|
|
4125
|
+
1.5: 'scale-1-5',
|
|
4126
|
+
2: 'scale-2-0',
|
|
4127
|
+
}[dropdownScale];
|
|
4128
|
+
const triggerWithScale = React.isValidElement(children) && buttonScale
|
|
4129
|
+
? React.cloneElement(children, {
|
|
4130
|
+
scale: children.props?.scale ?? buttonScale,
|
|
4131
|
+
})
|
|
4132
|
+
: children;
|
|
3414
4133
|
const { open, setOpen, handleItemSelect: handleItemSelectLogic, isItemSelected } = useMenuLogic({
|
|
3415
4134
|
selectedItems,
|
|
3416
4135
|
onItemSelect,
|
|
@@ -3513,7 +4232,7 @@ const Menu = ({ items, children, onItemSelect, search, enableInfiniteScroll, onS
|
|
|
3513
4232
|
hasReachedEndRef.current = false;
|
|
3514
4233
|
}
|
|
3515
4234
|
};
|
|
3516
|
-
return (jsxRuntime.jsxs(radixUi.DropdownMenu.Root, { open: open, onOpenChange: handleOpenChange, children: [jsxRuntime.jsx(radixUi.DropdownMenu.Trigger, { asChild: true, children:
|
|
4235
|
+
return (jsxRuntime.jsxs(radixUi.DropdownMenu.Root, { open: open, onOpenChange: handleOpenChange, children: [jsxRuntime.jsx(radixUi.DropdownMenu.Trigger, { asChild: true, children: triggerWithScale }), jsxRuntime.jsx(radixUi.DropdownMenu.Portal, { children: jsxRuntime.jsxs(radixUi.DropdownMenu.Content, { className: clsx(styles$9.content, scaleClass, className), sideOffset: 8, align: align, onPointerDown: () => { closedByPointerRef.current = true; }, onInteractOutside: () => { closedByPointerRef.current = true; }, onCloseAutoFocus: (e) => {
|
|
3517
4236
|
if (closedByPointerRef.current) {
|
|
3518
4237
|
e.preventDefault();
|
|
3519
4238
|
closedByPointerRef.current = false;
|
|
@@ -3545,7 +4264,7 @@ const Modal = ({ isOpen = false, onClose, title, children, headerContent, closeO
|
|
|
3545
4264
|
|
|
3546
4265
|
var styles$7 = {"quantity":"Quantity-module__quantity___-vndR","quantityInput":"Quantity-module__quantityInput___xZG-v","disabled":"Quantity-module__disabled___X6p5l"};
|
|
3547
4266
|
|
|
3548
|
-
const Quantity = ({ value = 0, onChange, disabled = false, decimal = false, decimalPlaces = 2, size = 'lg', id, valueIncrement = 1, className, inputSize, minValue = 0, maxValue = 9999, decrementAriaLabel = 'Decrease quantity', incrementAriaLabel = 'Increase quantity', inputAriaLabel = 'Quantity', ...rest }) => {
|
|
4267
|
+
const Quantity = ({ value = 0, onChange, disabled = false, decimal = false, decimalPlaces = 2, size = 'lg', id, valueIncrement = 1, scale = 1, className, inputSize, minValue = 0, maxValue = 9999, decrementAriaLabel = 'Decrease quantity', incrementAriaLabel = 'Increase quantity', inputAriaLabel = 'Quantity', ...rest }) => {
|
|
3549
4268
|
const initialValue = Math.min(Math.max(value, minValue), maxValue);
|
|
3550
4269
|
const [internalValue, setInternalValue] = React.useState(initialValue);
|
|
3551
4270
|
const [inputValue, setInputValue] = React.useState(decimal ? initialValue.toFixed(decimalPlaces) : String(initialValue));
|
|
@@ -3724,7 +4443,12 @@ const Quantity = ({ value = 0, onChange, disabled = false, decimal = false, deci
|
|
|
3724
4443
|
const inputSizeValue = inputSize !== undefined ? inputSize : Math.max(1, inputValue.length);
|
|
3725
4444
|
const uniqueId = React.useId();
|
|
3726
4445
|
const inputId = id || uniqueId;
|
|
3727
|
-
|
|
4446
|
+
const scaleClass = {
|
|
4447
|
+
1: 'scale-1-0',
|
|
4448
|
+
1.5: 'scale-1-5',
|
|
4449
|
+
2: 'scale-2-0',
|
|
4450
|
+
}[scale];
|
|
4451
|
+
return (jsxRuntime.jsxs("div", { className: clsx(styles$7.quantity, scaleClass, { [styles$7.disabled]: disabled }, className), ...rest, children: [jsxRuntime.jsx(Button, { variant: 'outlined', size: size, type: 'button', iconOnly: true, icon: jsxRuntime.jsx(reactIcons.Subtract16Regular, {}), onClick: decrement, disabled: disabled || isMinValue, "aria-label": decrementAriaLabel, tooltipText: 'Diminuir' }), jsxRuntime.jsx("input", { ref: inputRef, className: clsx(styles$7.quantityInput, { [styles$7.disabled]: disabled }), type: 'text', value: inputValue, onChange: handleInputChange, onBlur: handleBlur, onKeyDown: handleInputKeyDown, id: inputId, step: stepValue, "aria-label": inputAriaLabel, role: 'spinbutton', "aria-valuenow": internalValue, "aria-valuemin": minValue, "aria-valuemax": maxValue, disabled: disabled, inputMode: decimal ? 'decimal' : 'numeric', size: inputSizeValue }), jsxRuntime.jsx(Button, { variant: 'outlined', size: size, type: 'button', iconOnly: true, onClick: increment, disabled: disabled || isMaxValue, "aria-label": incrementAriaLabel, icon: jsxRuntime.jsx(reactIcons.Add16Regular, {}), tooltipText: 'Aumentar' })] }));
|
|
3728
4452
|
};
|
|
3729
4453
|
const memorizedQuantity = React.memo(Quantity);
|
|
3730
4454
|
memorizedQuantity.displayName = 'Quantity';
|
|
@@ -4038,7 +4762,7 @@ function useSelectLogic({ value, required = false, search = false, onValueChange
|
|
|
4038
4762
|
};
|
|
4039
4763
|
}
|
|
4040
4764
|
|
|
4041
|
-
const Select = ({ items, onValueChange, onOpenChange, variant, required = false, value, label, helperText, placeholder = 'Selecione', maxWidth, search = false, errorMessage, disabled = false, className, 'aria-label': ariaLabel, 'data-testid': testId, tooltip = false, tooltipText, side = 'bottom', align = 'start', enableInfiniteScroll = false, onScrollEnd, isLoadingMore = false, enableApiSearch = false, onApiSearch, isSearching = false, ...rest }) => {
|
|
4765
|
+
const Select = ({ items, onValueChange, onOpenChange, variant, required = false, value, label, helperText, placeholder = 'Selecione', maxWidth, search = false, errorMessage, disabled = false, scale = 1, className, 'aria-label': ariaLabel, 'data-testid': testId, tooltip = false, tooltipText, side = 'bottom', align = 'start', enableInfiniteScroll = false, onScrollEnd, isLoadingMore = false, enableApiSearch = false, onApiSearch, isSearching = false, ...rest }) => {
|
|
4042
4766
|
const componentId = React.useId();
|
|
4043
4767
|
const selectId = `select-${componentId}`;
|
|
4044
4768
|
const viewportRef = React.useRef(null);
|
|
@@ -4086,6 +4810,11 @@ const Select = ({ items, onValueChange, onOpenChange, variant, required = false,
|
|
|
4086
4810
|
const containerStyle = React.useMemo(() => ({
|
|
4087
4811
|
maxWidth: maxWidth ? `${maxWidth}px` : undefined,
|
|
4088
4812
|
}), [maxWidth]);
|
|
4813
|
+
const scaleClass = {
|
|
4814
|
+
1: 'scale-1-0',
|
|
4815
|
+
1.5: 'scale-1-5',
|
|
4816
|
+
2: 'scale-2-0',
|
|
4817
|
+
}[scale];
|
|
4089
4818
|
const handleSearchChange = (e) => {
|
|
4090
4819
|
const value = e.target.value;
|
|
4091
4820
|
actions.setSearchInput(value);
|
|
@@ -4118,7 +4847,7 @@ const Select = ({ items, onValueChange, onOpenChange, variant, required = false,
|
|
|
4118
4847
|
onApiSearch('');
|
|
4119
4848
|
}
|
|
4120
4849
|
};
|
|
4121
|
-
return (jsxRuntime.jsx(radixUi.Select.Root, { value: variant === 'checkbox' || (search && state.isOpen) ? '' : (state.selectedValues[0] || ''), onValueChange: variant === 'checkbox' ? undefined : actions.handleSingleSelect, required: required, open: state.isOpen, onOpenChange: actions.setOpen, disabled: disabled, ...rest, children: jsxRuntime.jsxs("div", { className: clsx(styles$6.container, className), style: containerStyle, "data-testid": testId, children: [jsxRuntime.jsx("div", { className: styles$6.fieldContainer, children: jsxRuntime.jsxs("div", { className: styles$6.containerLabel, children: [jsxRuntime.jsx(LabelComponent, { htmlFor: selectId, required: required, tooltipText: tooltipText, tooltip: tooltip, side: side, align: align, error: state.hasError && state.touched, disabled: disabled, children: label }), jsxRuntime.jsxs(radixUi.Select.Trigger, { className: clsx(styles$6.trigger, {
|
|
4850
|
+
return (jsxRuntime.jsx(radixUi.Select.Root, { value: variant === 'checkbox' || (search && state.isOpen) ? '' : (state.selectedValues[0] || ''), onValueChange: variant === 'checkbox' ? undefined : actions.handleSingleSelect, required: required, open: state.isOpen, onOpenChange: actions.setOpen, disabled: disabled, ...rest, children: jsxRuntime.jsxs("div", { className: clsx(styles$6.container, scaleClass, className), style: containerStyle, "data-testid": testId, children: [jsxRuntime.jsx("div", { className: styles$6.fieldContainer, children: jsxRuntime.jsxs("div", { className: styles$6.containerLabel, children: [jsxRuntime.jsx(LabelComponent, { htmlFor: selectId, required: required, tooltipText: tooltipText, tooltip: tooltip, side: side, align: align, error: state.hasError && state.touched, disabled: disabled, children: label }), jsxRuntime.jsxs(radixUi.Select.Trigger, { className: clsx(styles$6.trigger, {
|
|
4122
4851
|
[styles$6.error]: state.hasError && state.touched,
|
|
4123
4852
|
[styles$6.disabled]: disabled,
|
|
4124
4853
|
[styles$6.hasValue]: state.selectedValues.length > 0,
|
|
@@ -4336,7 +5065,7 @@ const isCalendarFilter = (filter) => {
|
|
|
4336
5065
|
return filter.type === 'calendar';
|
|
4337
5066
|
};
|
|
4338
5067
|
const isCheckboxFilter = (filter) => {
|
|
4339
|
-
return filter.type === '
|
|
5068
|
+
return filter.type === 'multiple' || filter.type === 'single';
|
|
4340
5069
|
};
|
|
4341
5070
|
const TableHeader = ({ searchValue = '', onSearchChange, onSearch, searchPlaceholder = 'Pesquisar...', showSearch = true, showFilters = false, filters, filterItems = [], className = '', ...rest }) => {
|
|
4342
5071
|
const [internalSearchValue, setInternalSearchValue] = React.useState(searchValue);
|
|
@@ -4413,12 +5142,24 @@ var styles$4 = {"wrapper":"Table-module__wrapper___KMc04","tableContainer":"Tabl
|
|
|
4413
5142
|
|
|
4414
5143
|
const EmptyState = ({ emptyIcon, emptyTitle, emptyText }) => (jsxRuntime.jsxs("div", { className: styles$4.tableEmpty, children: [jsxRuntime.jsx("div", { className: styles$4.tableEmptyContent, children: emptyIcon ?? jsxRuntime.jsx(reactIcons.SearchInfo20Regular, {}) }), jsxRuntime.jsxs("div", { className: styles$4.tableEmptyText, children: [jsxRuntime.jsx("h3", { className: styles$4.tableEmptyTitle, children: emptyTitle ?? 'Nenhum dado encontrado' }), jsxRuntime.jsx("p", { className: styles$4.tableEmptyCaption, children: emptyText ?? 'Nenhum registro encontrado' })] })] }));
|
|
4415
5144
|
|
|
4416
|
-
const TableV2 = ({ columns, data,
|
|
4417
|
-
const
|
|
4418
|
-
const
|
|
4419
|
-
const [
|
|
5145
|
+
const TableV2 = ({ columns, data, rowSelection: rowSelectionConfig, enableSorting = true, bulkActions, header, footer, loading = false, emptyIcon, emptyTitle, emptyText, onRow, className, }) => {
|
|
5146
|
+
const isRowSelectionEnabled = !!rowSelectionConfig;
|
|
5147
|
+
const isControlled = rowSelectionConfig?.selectedRowKeys !== undefined;
|
|
5148
|
+
const [pendingSearch, setPendingSearch] = React.useState(header?.searchValue ?? '');
|
|
5149
|
+
React.useEffect(() => {
|
|
5150
|
+
if (header?.searchValue !== undefined) {
|
|
5151
|
+
setPendingSearch(header.searchValue);
|
|
5152
|
+
}
|
|
5153
|
+
}, [header?.searchValue]);
|
|
5154
|
+
const [rowSelectionState, setRowSelectionState] = React.useState({});
|
|
4420
5155
|
const rowSelectionRef = React.useRef({});
|
|
4421
|
-
|
|
5156
|
+
const externalSelectionState = React.useMemo(() => {
|
|
5157
|
+
if (!rowSelectionConfig?.selectedRowKeys)
|
|
5158
|
+
return {};
|
|
5159
|
+
return Object.fromEntries(rowSelectionConfig.selectedRowKeys.map((key) => [String(key), true]));
|
|
5160
|
+
}, [rowSelectionConfig?.selectedRowKeys]);
|
|
5161
|
+
const effectiveRowSelection = isControlled ? externalSelectionState : rowSelectionState;
|
|
5162
|
+
rowSelectionRef.current = effectiveRowSelection;
|
|
4422
5163
|
const lastEmittedSelectionKey = React.useRef('{}');
|
|
4423
5164
|
const [sorting, setSorting] = React.useState([]);
|
|
4424
5165
|
const [pagination, setPagination] = React.useState({
|
|
@@ -4431,27 +5172,22 @@ const TableV2 = ({ columns, data, enableFilters = false, enableRowSelection = fa
|
|
|
4431
5172
|
size: 48,
|
|
4432
5173
|
enableSorting: false,
|
|
4433
5174
|
enableColumnFilter: false,
|
|
4434
|
-
header: ({ table: t }) => (jsxRuntime.jsx("div", { className: styles$4.checkboxCell, children: jsxRuntime.jsx(Checkbox, { checked: t.getIsAllPageRowsSelected(), indeterminate: t.getIsSomePageRowsSelected(), onCheckedChange: (checked) => t.toggleAllPageRowsSelected(checked) }) })),
|
|
4435
|
-
cell: ({ row }) => (jsxRuntime.jsx("div", { className: styles$4.checkboxCell, children: jsxRuntime.jsx(Checkbox, { checked: row.getIsSelected(), onCheckedChange: (checked) => row.toggleSelected(checked) }) })),
|
|
4436
|
-
}), []);
|
|
4437
|
-
const resolvedColumns = React.useMemo(() => (
|
|
4438
|
-
const showSearch = !!(header
|
|
5175
|
+
header: ({ table: t }) => (jsxRuntime.jsx("div", { className: styles$4.checkboxCell, children: jsxRuntime.jsx(Checkbox, { checked: t.getIsAllPageRowsSelected(), indeterminate: t.getIsSomePageRowsSelected(), disabled: rowSelectionConfig?.disableSelectAll, onCheckedChange: (checked) => t.toggleAllPageRowsSelected(checked) }) })),
|
|
5176
|
+
cell: ({ row }) => (jsxRuntime.jsx("div", { className: styles$4.checkboxCell, children: jsxRuntime.jsx(Checkbox, { checked: row.getIsSelected(), disabled: !row.getCanSelect(), onCheckedChange: (checked) => row.toggleSelected(checked) }) })),
|
|
5177
|
+
}), [rowSelectionConfig?.disableSelectAll]);
|
|
5178
|
+
const resolvedColumns = React.useMemo(() => (isRowSelectionEnabled ? [selectionColumn, ...columns] : columns), [isRowSelectionEnabled, selectionColumn, columns]);
|
|
5179
|
+
const showSearch = !!(header?.onSearchChange);
|
|
4439
5180
|
const table = reactTable.useReactTable({
|
|
4440
5181
|
data,
|
|
4441
5182
|
columns: resolvedColumns,
|
|
4442
5183
|
defaultColumn: { minSize: 44, size: 0 },
|
|
4443
5184
|
state: {
|
|
4444
|
-
...(
|
|
4445
|
-
...(showSearch ? { globalFilter } : {}),
|
|
4446
|
-
...(footer ? { pagination: { pageIndex, pageSize } } : {}),
|
|
4447
|
-
...(enableRowSelection ? { rowSelection } : {}),
|
|
5185
|
+
...(isRowSelectionEnabled ? { rowSelection: effectiveRowSelection } : {}),
|
|
4448
5186
|
...(enableSorting ? { sorting } : {}),
|
|
4449
5187
|
},
|
|
4450
|
-
onColumnFiltersChange: enableFilters ? setColumnFilters : undefined,
|
|
4451
|
-
onGlobalFilterChange: showSearch ? setGlobalFilter : undefined,
|
|
4452
5188
|
onSortingChange: enableSorting ? setSorting : undefined,
|
|
4453
5189
|
enableSorting,
|
|
4454
|
-
onRowSelectionChange:
|
|
5190
|
+
onRowSelectionChange: isRowSelectionEnabled
|
|
4455
5191
|
? (updater) => {
|
|
4456
5192
|
const prev = rowSelectionRef.current;
|
|
4457
5193
|
const next = typeof updater === 'function' ? updater(prev) : updater;
|
|
@@ -4460,43 +5196,52 @@ const TableV2 = ({ columns, data, enableFilters = false, enableRowSelection = fa
|
|
|
4460
5196
|
return;
|
|
4461
5197
|
lastEmittedSelectionKey.current = selectionKey;
|
|
4462
5198
|
rowSelectionRef.current = next;
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
|
|
5199
|
+
if (!isControlled) {
|
|
5200
|
+
setRowSelectionState(next);
|
|
5201
|
+
}
|
|
5202
|
+
if (rowSelectionConfig?.onRowChange) {
|
|
5203
|
+
const allRows = table.getCoreRowModel().rows;
|
|
5204
|
+
const selectedRows = allRows.filter((r) => next[r.id]).map((r) => r.original);
|
|
5205
|
+
const selectedKeys = allRows.filter((r) => next[r.id]).map((r) => r.index);
|
|
5206
|
+
rowSelectionConfig.onRowChange(selectedRows, selectedKeys);
|
|
4470
5207
|
}
|
|
4471
5208
|
}
|
|
4472
5209
|
: undefined,
|
|
4473
|
-
enableRowSelection
|
|
4474
|
-
|
|
5210
|
+
enableRowSelection: isRowSelectionEnabled
|
|
5211
|
+
? typeof rowSelectionConfig?.disabled === 'function'
|
|
5212
|
+
? (row) => !rowSelectionConfig.disabled(row.original, row.index)
|
|
5213
|
+
: typeof rowSelectionConfig?.disabled === 'boolean'
|
|
5214
|
+
? !rowSelectionConfig.disabled
|
|
5215
|
+
: true
|
|
5216
|
+
: false,
|
|
4475
5217
|
getCoreRowModel: reactTable.getCoreRowModel(),
|
|
4476
|
-
getFilteredRowModel: enableFilters || showSearch ? reactTable.getFilteredRowModel() : undefined,
|
|
4477
|
-
getPaginationRowModel: footer ? reactTable.getPaginationRowModel() : undefined,
|
|
4478
5218
|
getSortedRowModel: enableSorting ? reactTable.getSortedRowModel() : undefined,
|
|
4479
5219
|
});
|
|
4480
|
-
const
|
|
4481
|
-
const effectiveTotalItems = footer
|
|
4482
|
-
? (enableFilters || showSearch) ? filteredRowCount : footer.totalItems
|
|
4483
|
-
: 0;
|
|
5220
|
+
const effectiveTotalItems = footer?.totalItems ?? 0;
|
|
4484
5221
|
const totalPages = footer ? Math.ceil(effectiveTotalItems / pageSize) : 0;
|
|
4485
5222
|
const canGoPrev = pageIndex > 0;
|
|
4486
5223
|
const canGoNext = pageIndex + 1 < totalPages;
|
|
4487
5224
|
const skeletonRowCount = footer ? pageSize : (data.length > 0 ? data.length : pageSize);
|
|
4488
5225
|
const selectedRows = React.useMemo(() => table
|
|
4489
5226
|
.getCoreRowModel()
|
|
4490
|
-
.rows.filter((r) =>
|
|
4491
|
-
.map((r) => r.original), [
|
|
5227
|
+
.rows.filter((r) => effectiveRowSelection[r.id])
|
|
5228
|
+
.map((r) => r.original), [effectiveRowSelection, table]);
|
|
4492
5229
|
const selectedCount = selectedRows.length;
|
|
4493
|
-
const showBulkActions =
|
|
5230
|
+
const showBulkActions = isRowSelectionEnabled && !!bulkActions && selectedCount > 0;
|
|
4494
5231
|
React.useEffect(() => {
|
|
4495
|
-
if (
|
|
5232
|
+
if (isRowSelectionEnabled) {
|
|
4496
5233
|
table.resetRowSelection();
|
|
4497
5234
|
}
|
|
4498
5235
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4499
5236
|
}, [pageIndex]);
|
|
5237
|
+
React.useEffect(() => {
|
|
5238
|
+
if (footer?.currentPage !== undefined) {
|
|
5239
|
+
const targetPageIndex = footer.currentPage - 1;
|
|
5240
|
+
setPagination((prev) => prev.pageIndex !== targetPageIndex
|
|
5241
|
+
? { ...prev, pageIndex: targetPageIndex }
|
|
5242
|
+
: prev);
|
|
5243
|
+
}
|
|
5244
|
+
}, [footer?.currentPage]);
|
|
4500
5245
|
const handleClearSelection = () => {
|
|
4501
5246
|
table.resetRowSelection();
|
|
4502
5247
|
bulkActions?.onClear?.();
|
|
@@ -4508,11 +5253,22 @@ const TableV2 = ({ columns, data, enableFilters = false, enableRowSelection = fa
|
|
|
4508
5253
|
};
|
|
4509
5254
|
return (jsxRuntime.jsxs("div", { className: clsx(styles$4.wrapper, className), children: [showBulkActions && (jsxRuntime.jsxs("div", { className: styles$4.bulkActionsBar, children: [jsxRuntime.jsxs("div", { className: styles$4.bulkActionsInfo, children: [jsxRuntime.jsx(Button, { variant: "text", iconOnly: true, icon: jsxRuntime.jsx(reactIcons.Dismiss16Regular, {}), ariaLabel: "Limpar sele\u00E7\u00E3o", onClick: handleClearSelection, className: styles$4.bulkActionsClearButton }), jsxRuntime.jsx("span", { className: styles$4.bulkActionsLabel, children: bulkActions.label
|
|
4510
5255
|
? bulkActions.label(selectedCount, selectedRows)
|
|
4511
|
-
: `${selectedCount} ${selectedCount === 1 ? 'item selecionado' : 'itens selecionados'}` })] }), jsxRuntime.jsx("div", { className: styles$4.bulkActionsButtons, children: bulkActions.actions.map((action, index) => (jsxRuntime.jsx(Button, { variant: action.variant ?? 'outlined', type: "button", disabled: action.disabled, onClick: action.onClick, size: "sm", children: action.label }, index))) })] })), header && (jsxRuntime.jsxs("div", { className: styles$4.tableHeader, children: [showSearch && (jsxRuntime.jsx("div", { className: styles$4.tableHeaderSearchContainer, children: jsxRuntime.jsx(Search, { value:
|
|
4512
|
-
|
|
4513
|
-
|
|
5256
|
+
: `${selectedCount} ${selectedCount === 1 ? 'item selecionado' : 'itens selecionados'}` })] }), jsxRuntime.jsx("div", { className: styles$4.bulkActionsButtons, children: bulkActions.actions.map((action, index) => (jsxRuntime.jsx(Button, { variant: action.variant ?? 'outlined', type: "button", disabled: action.disabled, onClick: action.onClick, size: "sm", children: action.label }, index))) })] })), header && (jsxRuntime.jsxs("div", { className: styles$4.tableHeader, children: [showSearch && (jsxRuntime.jsx("div", { className: styles$4.tableHeaderSearchContainer, children: jsxRuntime.jsx(Search, { value: pendingSearch, virtualKeyboard: header.virtualKeyboard, virtualKeyboardType: header.virtualKeyboardType, virtualKeyboardMaxLength: header.virtualKeyboardMaxLength, searchMode: header?.searchMode ?? "on-enter", onChange: (e) => {
|
|
5257
|
+
setPendingSearch(e.target.value);
|
|
5258
|
+
}, onSearch: (val) => {
|
|
5259
|
+
if (footer) {
|
|
5260
|
+
setPagination((prev) => ({ ...prev, pageIndex: 0 }));
|
|
5261
|
+
footer?.onPageChange?.(1);
|
|
5262
|
+
}
|
|
5263
|
+
header?.onSearchChange?.(val);
|
|
5264
|
+
}, onClear: () => {
|
|
5265
|
+
setPendingSearch('');
|
|
5266
|
+
if (footer) {
|
|
4514
5267
|
setPagination((prev) => ({ ...prev, pageIndex: 0 }));
|
|
4515
|
-
|
|
5268
|
+
footer?.onPageChange?.(1);
|
|
5269
|
+
}
|
|
5270
|
+
header?.onSearchChange?.('');
|
|
5271
|
+
}, placeholder: header.searchPlaceholder ?? 'Pesquisar...', className: styles$4.tableHeaderSearch }) })), !!header.filterItems?.length && (jsxRuntime.jsxs("div", { className: styles$4.tableHeaderFilters, children: [header.filterItems.some((item) => item.type !== 'combined') && (jsxRuntime.jsx("span", { className: styles$4.tableHeaderFilterLabel, children: "Filtros" })), jsxRuntime.jsx("div", { className: styles$4.tableHeaderFilterItems, children: header.filterItems.map((filterItem, index) => {
|
|
4516
5272
|
const commonProps = {
|
|
4517
5273
|
buttonText: filterItem.buttonText,
|
|
4518
5274
|
icon: filterItem.icon,
|
|
@@ -4523,18 +5279,21 @@ const TableV2 = ({ columns, data, enableFilters = false, enableRowSelection = fa
|
|
|
4523
5279
|
onOpen: () => filterItem.onToggle?.(true),
|
|
4524
5280
|
onClose: () => filterItem.onToggle?.(false),
|
|
4525
5281
|
};
|
|
5282
|
+
if (filterItem.type === 'combined') {
|
|
5283
|
+
return (jsxRuntime.jsx(Filter, { mode: "combined", buttonText: filterItem.buttonText, icon: filterItem.icon, title: filterItem.title, drawerWidth: filterItem.drawerWidth, activeCount: filterItem.activeCount, drawerHeaderContent: filterItem.drawerHeaderContent, onApply: filterItem.onApply, onClear: filterItem.onClear, variant: filterItem.variant ?? 'outlined', disabled: filterItem.disabled, children: filterItem.children }, filterItem.id ?? index));
|
|
5284
|
+
}
|
|
4526
5285
|
if (filterItem.type === 'calendar') {
|
|
4527
5286
|
return (jsxRuntime.jsx(Filter, { ...commonProps, type: "calendar", selectedDate: filterItem.selectedDate, onDateSelect: filterItem.onDateSelect, onClearDate: filterItem.onClear, minDate: filterItem.minDate, maxDate: filterItem.maxDate, locale: filterItem.locale, placeholder: filterItem.placeholder }, filterItem.id ?? index));
|
|
4528
5287
|
}
|
|
4529
5288
|
return (jsxRuntime.jsx(Filter, { ...commonProps, type: filterItem.type, items: filterItem.items, selectedIds: filterItem.selectedIds, onApplyFilter: filterItem.onSelectionChange, placeholder: filterItem.placeholder, enableSearch: filterItem.enableSearch }, filterItem.id ?? index));
|
|
4530
|
-
}) })] }))] })), jsxRuntime.jsx("div", { className: styles$4.tableContainer, children: jsxRuntime.jsx("div", { className: styles$4.tableScrollWrapper, children: jsxRuntime.jsxs("table", { className: styles$4.table, "aria-label": "Tabela de dados", "aria-rowcount":
|
|
5289
|
+
}) })] }))] })), jsxRuntime.jsx("div", { className: styles$4.tableContainer, children: jsxRuntime.jsx("div", { className: styles$4.tableScrollWrapper, children: jsxRuntime.jsxs("table", { className: styles$4.table, "aria-label": "Tabela de dados", "aria-rowcount": data.length + 1, children: [jsxRuntime.jsx("thead", { className: styles$4.tableHead, children: table.getHeaderGroups().map((headerGroup) => (jsxRuntime.jsx("tr", { children: headerGroup.headers.map((col) => (jsxRuntime.jsx("th", { className: styles$4.tableTh, style: {
|
|
4531
5290
|
textAlign: col.column.columnDef.meta?.align,
|
|
4532
5291
|
width: col.column.columnDef.size || undefined,
|
|
4533
5292
|
minWidth: col.column.columnDef.minSize,
|
|
4534
5293
|
maxWidth: col.column.columnDef.maxSize !== Number.MAX_SAFE_INTEGER
|
|
4535
5294
|
? col.column.columnDef.maxSize
|
|
4536
5295
|
: undefined,
|
|
4537
|
-
}, children:
|
|
5296
|
+
}, children: jsxRuntime.jsx("div", { className: styles$4.tableThContent, children: col.isPlaceholder ? null : col.column.getCanSort() ? (jsxRuntime.jsxs("button", { type: "button", className: styles$4.tableSortButton, onClick: col.column.getToggleSortingHandler(), "aria-label": `Ordenar por ${typeof col.column.columnDef.header === 'string' ? col.column.columnDef.header : col.id}`, children: [reactTable.flexRender(col.column.columnDef.header, col.getContext()), col.column.getIsSorted() === 'asc' ? (jsxRuntime.jsx(reactIcons.ArrowSortUp16Regular, { className: styles$4.tableSortIcon })) : col.column.getIsSorted() === 'desc' ? (jsxRuntime.jsx(reactIcons.ArrowSortDown16Regular, { className: styles$4.tableSortIcon })) : (jsxRuntime.jsx(reactIcons.ArrowSort16Regular, { className: clsx(styles$4.tableSortIcon, styles$4.tableSortIconNeutral) }))] })) : (reactTable.flexRender(col.column.columnDef.header, col.getContext())) }) }, col.id))) }, headerGroup.id))) }), jsxRuntime.jsx("tbody", { className: styles$4.tableBody, children: loading ? (Array.from({ length: skeletonRowCount }).map((_, rowIdx) => (jsxRuntime.jsx("tr", { className: styles$4.tableRow, children: table.getVisibleLeafColumns().map((col) => (jsxRuntime.jsx("td", { className: styles$4.tableTd, children: jsxRuntime.jsx(Skeleton, {}) }, col.id))) }, `skeleton-row-${rowIdx}`)))) : table.getRowModel().rows.length > 0 ? (table.getRowModel().rows.map((row, index) => {
|
|
4538
5297
|
const rowProps = onRow?.(row.original, index) ?? {};
|
|
4539
5298
|
return (jsxRuntime.jsx("tr", { className: clsx(styles$4.tableRow, rowProps.className), onClick: rowProps.onClick, onDoubleClick: rowProps.onDoubleClick, children: row.getVisibleCells().map((cell) => (jsxRuntime.jsx("td", { className: styles$4.tableTd, style: {
|
|
4540
5299
|
textAlign: cell.column.columnDef.meta?.align,
|
|
@@ -4559,12 +5318,13 @@ const TableV2 = ({ columns, data, enableFilters = false, enableRowSelection = fa
|
|
|
4559
5318
|
|
|
4560
5319
|
var styles$3 = {"container":"TextArea-module__container___WEBC-","inputWrapper":"TextArea-module__inputWrapper___-omPx","inputContainer":"TextArea-module__inputContainer___0-jKY","footer":"TextArea-module__footer___7XMlj","helperText":"TextArea-module__helperText___709rD","charCount":"TextArea-module__charCount___zdbxM","error":"TextArea-module__error___DWDms","disabled":"TextArea-module__disabled___lHxCa"};
|
|
4561
5320
|
|
|
4562
|
-
const TextArea = React.forwardRef(({ className, value, label, placeholder, onChange, disabled = false, maxLength, required = false, helperText, tooltip = false, tooltipText, side = 'bottom', align = 'start', errorMessage, error, id, onBlur, onFocus, name, resize = 'vertical', showCharCount = false, height, ...rest }, ref) => {
|
|
5321
|
+
const TextArea = React.forwardRef(({ className, value, label, placeholder, onChange, disabled = false, maxLength, required = false, helperText, tooltip = false, tooltipText, side = 'bottom', align = 'start', errorMessage, error, id, onBlur, onFocus, name, resize = 'vertical', showCharCount = false, height, virtualKeyboard = false, virtualKeyboardType, virtualKeyboardMaxLength, ...rest }, ref) => {
|
|
4563
5322
|
const normalizeValue = (val) => {
|
|
4564
5323
|
return val === undefined || val === null ? '' : String(val);
|
|
4565
5324
|
};
|
|
4566
5325
|
const [textareaValue, setTextareaValue] = React.useState(normalizeValue(value));
|
|
4567
5326
|
const [textareaError, setTextareaError] = React.useState('');
|
|
5327
|
+
const { internalRef: textareaRef, setRefs: setTextareaRefs } = useInputKeyboardValue(ref);
|
|
4568
5328
|
const generatedId = React.useId();
|
|
4569
5329
|
const componentId = id || generatedId;
|
|
4570
5330
|
React.useEffect(() => {
|
|
@@ -4597,7 +5357,12 @@ const TextArea = React.forwardRef(({ className, value, label, placeholder, onCha
|
|
|
4597
5357
|
? `${componentId}-helper`
|
|
4598
5358
|
: undefined;
|
|
4599
5359
|
const containerClass = clsx(styles$3.container, disabled && styles$3.disabled, hasError && !disabled && styles$3.error, className);
|
|
4600
|
-
return (jsxRuntime.jsxs("div", { className: containerClass, children: [label && (jsxRuntime.jsx(LabelComponent, { htmlFor: componentId, required: required, tooltip: tooltip, tooltipText: tooltipText, side: side, align: align, error: hasError, disabled: disabled, children: label })), jsxRuntime.jsxs("div", { className: styles$3.inputWrapper, children: [jsxRuntime.jsx("div", { className: styles$3.inputContainer, children: jsxRuntime.jsx("textarea", { ...rest, ref:
|
|
5360
|
+
return (jsxRuntime.jsxs("div", { className: containerClass, children: [label && (jsxRuntime.jsx(LabelComponent, { htmlFor: componentId, required: required, tooltip: tooltip, tooltipText: tooltipText, side: side, align: align, error: hasError, disabled: disabled, children: label })), jsxRuntime.jsxs("div", { className: styles$3.inputWrapper, children: [jsxRuntime.jsx("div", { className: styles$3.inputContainer, children: jsxRuntime.jsx("textarea", { ...rest, ref: setTextareaRefs, id: componentId, name: name, value: textareaValue, placeholder: placeholder, onChange: handleChange, onFocus: handleFocus, onBlur: handleBlur, maxLength: maxLength, disabled: disabled, "aria-invalid": hasError, "aria-required": required, "aria-describedby": helperId, style: { resize, height }, inputMode: virtualKeyboard ? 'none' : rest.inputMode }) }), jsxRuntime.jsxs("div", { className: styles$3.footer, children: [jsxRuntime.jsx("span", { id: helperId, className: styles$3.helperText, "aria-live": hasError ? 'polite' : undefined, children: displayHelperText }), showCharCount && maxLength && (jsxRuntime.jsxs("span", { className: styles$3.charCount, children: [textareaValue.length, "/", maxLength] }))] })] }), virtualKeyboard && (jsxRuntime.jsx("div", { className: "virtualKeyboardWrapper", children: jsxRuntime.jsx(VirtualKeyboard, { variant: "native", type: virtualKeyboardType, maxLength: virtualKeyboardMaxLength, value: textareaValue, targetRef: textareaRef, onChange: (val) => {
|
|
5361
|
+
if (!disabled && (!maxLength || val.length <= maxLength)) {
|
|
5362
|
+
setTextareaValue(val);
|
|
5363
|
+
onChange?.(val);
|
|
5364
|
+
}
|
|
5365
|
+
} }) }))] }));
|
|
4601
5366
|
});
|
|
4602
5367
|
TextArea.displayName = 'TextArea';
|
|
4603
5368
|
var TextArea_default = React.memo(TextArea);
|
|
@@ -4810,7 +5575,14 @@ ToastContainer.displayName = 'ToastContainer';
|
|
|
4810
5575
|
|
|
4811
5576
|
var styles$1 = {"container":"Switch-module__container___BR1OB","switchRoot":"Switch-module__switchRoot___jz2HD","switchThumb":"Switch-module__switchThumb___X3RL7"};
|
|
4812
5577
|
|
|
4813
|
-
const Switch = ({ disabled = false, defaultChecked = false, checked, onCheckedChange,
|
|
5578
|
+
const Switch = ({ disabled = false, defaultChecked = false, checked, onCheckedChange, scale = 1, className, ...rest }) => {
|
|
5579
|
+
const scaleClass = {
|
|
5580
|
+
1: 'scale-1-0',
|
|
5581
|
+
1.5: 'scale-1-5',
|
|
5582
|
+
2: 'scale-2-0',
|
|
5583
|
+
}[scale];
|
|
5584
|
+
return (jsxRuntime.jsx("div", { className: clsx(styles$1.container, scaleClass, className), children: jsxRuntime.jsx(radixUi.Switch.Root, { className: styles$1.switchRoot, disabled: disabled, defaultChecked: defaultChecked, checked: checked, onCheckedChange: onCheckedChange, ...rest, children: jsxRuntime.jsx(radixUi.Switch.Thumb, { className: styles$1.switchThumb }) }) }));
|
|
5585
|
+
};
|
|
4814
5586
|
|
|
4815
5587
|
var styles = {"zds-verification-code__container":"VerificationCode-module__zds-verification-code__container___tUNuJ","zds-verification-code__input":"VerificationCode-module__zds-verification-code__input___wDIQ6","zds-verification-code__filled":"VerificationCode-module__zds-verification-code__filled___-2VVb","zds-verification-code__has-error":"VerificationCode-module__zds-verification-code__has-error___eqKAp","zds-verification-code__error":"VerificationCode-module__zds-verification-code__error___T53i5"};
|
|
4816
5588
|
|
|
@@ -5262,6 +6034,7 @@ exports.ToastContainer = ToastContainer;
|
|
|
5262
6034
|
exports.ToastProvider = ToastProvider;
|
|
5263
6035
|
exports.Tooltip = Tooltip;
|
|
5264
6036
|
exports.VerificationCode = VerificationCode;
|
|
6037
|
+
exports.VirtualKeyboard = VirtualKeyboard;
|
|
5265
6038
|
exports.normalizeText = normalizeText;
|
|
5266
6039
|
exports.useApiSimulation = useApiSimulation;
|
|
5267
6040
|
exports.useInfiniteScroll = useInfiniteScroll;
|