@giro-ds/react 9.0.0 → 10.0.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 +879 -79
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +190 -21
- package/dist/index.esm.js +880 -82
- package/dist/index.esm.js.map +1 -1
- package/dist/styles.css +23 -1
- package/package.json +3 -2
package/dist/index.esm.js
CHANGED
|
@@ -2,26 +2,27 @@ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
import { Avatar as Avatar$1, Tooltip as Tooltip$1, Checkbox as Checkbox$1, Popover as Popover$1, Label, AlertDialog, RadioGroup, DropdownMenu, Dialog as Dialog$1, Select as Select$1, Toast as Toast$1, Switch as Switch$1 } from 'radix-ui';
|
|
4
4
|
import * as React from 'react';
|
|
5
|
-
import React__default, { useId, useMemo, createContext, useState, useContext,
|
|
6
|
-
import { SpinnerIos16Regular, ChevronUp16Regular, ChevronLeft16Regular, ChevronRight16Regular, ChevronDown16Regular, Dismiss24Regular, Info12Regular, Dismiss16Regular, Calendar16Regular, FilterRegular, Search16Regular, ChevronDownRegular, ChevronRight16Filled, Subtract16Regular, Add16Regular, SearchInfo20Regular, ArrowSortUp16Regular, ArrowSortDown16Regular, ArrowSort16Regular, Info20Filled, CheckmarkCircle20Filled, Warning20Filled, Dismiss16Filled } from '@fluentui/react-icons';
|
|
5
|
+
import React__default, { useId, useMemo, createContext, useState, useContext, useRef, useCallback, useEffect, useLayoutEffect, createElement, forwardRef, memo, useReducer, isValidElement } from 'react';
|
|
6
|
+
import { SpinnerIos16Regular, ChevronUp16Regular, ChevronLeft16Regular, ChevronRight16Regular, ChevronDown16Regular, Dismiss24Regular, Emoji20Regular, ChevronDown20Regular, KeyboardShiftUppercase20Regular, KeyboardShift20Filled, KeyboardShift20Regular, Backspace20Regular, Info12Regular, Dismiss16Regular, Calendar16Regular, FilterRegular, Search16Regular, ChevronDownRegular, ChevronRight16Filled, Subtract16Regular, Add16Regular, SearchInfo20Regular, ArrowSortUp16Regular, ArrowSortDown16Regular, ArrowSort16Regular, Info20Filled, CheckmarkCircle20Filled, Warning20Filled, Dismiss16Filled } from '@fluentui/react-icons';
|
|
7
7
|
import { DayPicker } from 'react-day-picker';
|
|
8
8
|
import { format, addDays, addMonths, addWeeks, addYears, differenceInCalendarDays, differenceInCalendarMonths, eachMonthOfInterval, eachYearOfInterval, endOfISOWeek, endOfMonth, endOfWeek, endOfYear, getISOWeek, getMonth, getYear, getWeek, isAfter, isBefore, isDate, isSameDay, isSameMonth, isSameYear, max, min, setMonth, setYear, startOfDay, startOfISOWeek, startOfMonth, startOfWeek, startOfYear } from 'date-fns';
|
|
9
9
|
import { createPortal } from 'react-dom';
|
|
10
|
+
import Keyboard from 'react-simple-keyboard';
|
|
10
11
|
import { useReactTable, getSortedRowModel, getCoreRowModel, flexRender } from '@tanstack/react-table';
|
|
11
12
|
export { createColumnHelper as createTableColumnHelper } from '@tanstack/react-table';
|
|
12
13
|
import Skeleton from 'react-loading-skeleton';
|
|
13
14
|
|
|
14
|
-
var styles$
|
|
15
|
+
var styles$u = {"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"};
|
|
15
16
|
|
|
16
17
|
const Avatar = ({ icon, size = 'lg', src, className, initialLetters, ...rest }) => {
|
|
17
|
-
const AvatarClass = clsx(styles$
|
|
18
|
-
[styles$
|
|
19
|
-
[styles$
|
|
18
|
+
const AvatarClass = clsx(styles$u.AvatarRoot, {
|
|
19
|
+
[styles$u['AvatarRoot--lg']]: size === 'lg',
|
|
20
|
+
[styles$u['AvatarRoot--sm']]: size === 'sm',
|
|
20
21
|
}, className);
|
|
21
|
-
return (jsxs(Avatar$1.Root, { className: AvatarClass, ...rest, children: [src && (jsx(Avatar$1.Image, { className: styles$
|
|
22
|
+
return (jsxs(Avatar$1.Root, { className: AvatarClass, ...rest, children: [src && (jsx(Avatar$1.Image, { className: styles$u.AvatarImage, src: src, alt: "Avatar" })), jsx(Avatar$1.Fallback, { className: styles$u.AvatarFallback, children: icon || initialLetters })] }));
|
|
22
23
|
};
|
|
23
24
|
|
|
24
|
-
var styles$
|
|
25
|
+
var styles$t = {"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"};
|
|
25
26
|
|
|
26
27
|
const getDisplayValue = (value) => {
|
|
27
28
|
if (value === null || value === undefined)
|
|
@@ -43,27 +44,27 @@ const Badge = ({ children, badgeValue = null, className, id, filterVariant = fal
|
|
|
43
44
|
const displayValue = getDisplayValue(badgeValue);
|
|
44
45
|
const isEmpty = displayValue === '';
|
|
45
46
|
if (children) {
|
|
46
|
-
return (jsxs("div", { className: styles$
|
|
47
|
-
[styles$
|
|
48
|
-
[styles$
|
|
47
|
+
return (jsxs("div", { className: styles$t.badgeContainer, ...rest, children: [jsx("div", { "data-testid": "badge-content", children: children }), jsx("div", { id: componentId, className: clsx(styles$t.badge, {
|
|
48
|
+
[styles$t['badge__empty']]: isEmpty,
|
|
49
|
+
[styles$t['badge__flex']]: displayValue.length >= 2,
|
|
49
50
|
}, className), "data-testid": "badge", children: !isEmpty && jsx("span", { "aria-hidden": !!ariaLabel, children: displayValue }) })] }));
|
|
50
51
|
}
|
|
51
|
-
return (jsx("div", { className: styles$
|
|
52
|
-
[styles$
|
|
53
|
-
[styles$
|
|
54
|
-
[styles$
|
|
52
|
+
return (jsx("div", { className: styles$t.badgeContainer, children: jsx("div", { className: clsx(styles$t['badge__status'], {
|
|
53
|
+
[styles$t['badge__status__empty']]: isEmpty,
|
|
54
|
+
[styles$t['badge__status__flex']]: displayValue.length >= 2,
|
|
55
|
+
[styles$t['badge__status__filterBadge']]: filterVariant,
|
|
55
56
|
}, className), "data-testid": "badge", children: !isEmpty && (jsx("span", { "aria-hidden": !!ariaLabel, children: displayValue })) }) }));
|
|
56
57
|
};
|
|
57
58
|
|
|
58
|
-
var styles$
|
|
59
|
+
var styles$s = {"tooltipContent":"Tooltip-module__tooltipContent___xycUg","triggerWrapper":"Tooltip-module__triggerWrapper___x83XR"};
|
|
59
60
|
|
|
60
61
|
const Tooltip = ({ children, text, side = 'bottom', align = 'start', maxWidth, sideOffset = 10, className, ...rest }) => {
|
|
61
|
-
return (jsx(Tooltip$1.Provider, { children: jsxs(Tooltip$1.Root, { children: [jsx(Tooltip$1.Trigger, { asChild: true, children: jsx("span", { className: styles$
|
|
62
|
+
return (jsx(Tooltip$1.Provider, { children: jsxs(Tooltip$1.Root, { children: [jsx(Tooltip$1.Trigger, { asChild: true, children: jsx("span", { className: styles$s.triggerWrapper, children: children }) }), jsx(Tooltip$1.Portal, { children: jsx(Tooltip$1.Content, { className: clsx(styles$s.tooltipContent, className), side: side, align: align, sideOffset: sideOffset, style: { maxWidth: maxWidth ? `${maxWidth}px` : 'auto' }, ...rest, children: text }) })] }) }));
|
|
62
63
|
};
|
|
63
64
|
|
|
64
|
-
var styles$
|
|
65
|
+
var styles$r = {"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"};
|
|
65
66
|
|
|
66
|
-
const Button = React__default.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) => {
|
|
67
|
+
const Button = React__default.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) => {
|
|
67
68
|
const generatedId = useId();
|
|
68
69
|
const componentId = id || generatedId;
|
|
69
70
|
const getComponent = () => {
|
|
@@ -90,14 +91,19 @@ const Button = React__default.forwardRef(({ as, children, variant = 'filled', ic
|
|
|
90
91
|
'Forneça um ícone via `icon={<MeuIcone />}`.');
|
|
91
92
|
}
|
|
92
93
|
const resolvedIcon = icon;
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
[styles$
|
|
100
|
-
[styles$
|
|
94
|
+
const scaleClass = {
|
|
95
|
+
1: 'scale-1-0',
|
|
96
|
+
1.5: 'scale-1-5',
|
|
97
|
+
2: 'scale-2-0',
|
|
98
|
+
}[scale];
|
|
99
|
+
const buttonClasses = clsx(styles$r.button, styles$r[`button-${variant}`], styles$r[`button-${size}`], scaleClass, {
|
|
100
|
+
[styles$r['disabled']]: disabled,
|
|
101
|
+
[styles$r['buttonLoading']]: loading,
|
|
102
|
+
[styles$r['buttonWithIcon']]: resolvedIcon && !iconOnly,
|
|
103
|
+
[styles$r[`buttonIconPosition-${iconPosition}`]]: resolvedIcon && !iconOnly,
|
|
104
|
+
[styles$r['buttonNoContent']]: resolvedIcon && !hasContent && !iconOnly,
|
|
105
|
+
[styles$r['buttonFullWidth']]: fullWidth,
|
|
106
|
+
[styles$r['buttonIconOnly']]: iconOnly,
|
|
101
107
|
}, className);
|
|
102
108
|
const getAriaLabel = () => {
|
|
103
109
|
if (ariaLabel)
|
|
@@ -123,12 +129,12 @@ const Button = React__default.forwardRef(({ as, children, variant = 'filled', ic
|
|
|
123
129
|
};
|
|
124
130
|
const renderContent = () => {
|
|
125
131
|
if (iconOnly && !loading) {
|
|
126
|
-
return (jsx("span", { className: styles$
|
|
132
|
+
return (jsx("span", { className: styles$r.buttonIconOnly, "aria-hidden": "true", children: resolvedIcon }));
|
|
127
133
|
}
|
|
128
134
|
if (loading) {
|
|
129
|
-
return (jsxs(Fragment, { children: [!iconOnly && (jsxs("span", { className: styles$
|
|
135
|
+
return (jsxs(Fragment, { children: [!iconOnly && (jsxs("span", { className: styles$r.buttonContentHidden, "aria-hidden": "true", children: [resolvedIcon && (iconPosition === 'left' || iconPosition === 'both') && (jsx("span", { className: styles$r.buttonIconLeft, children: resolvedIcon })), children, resolvedIcon && (iconPosition === 'right' || iconPosition === 'both') && (jsx("span", { className: styles$r.buttonIconRight, children: resolvedIcon }))] })), jsx("span", { className: styles$r.buttonLoadingSpinner, "aria-hidden": "true", children: jsx(SpinnerIos16Regular, { "aria-hidden": "true" }) })] }));
|
|
130
136
|
}
|
|
131
|
-
return (jsxs(Fragment, { children: [resolvedIcon && (iconPosition === 'left' || iconPosition === 'both') && (jsx("span", { className: styles$
|
|
137
|
+
return (jsxs(Fragment, { children: [resolvedIcon && (iconPosition === 'left' || iconPosition === 'both') && (jsx("span", { className: styles$r.buttonIconLeft, "aria-hidden": "true", children: resolvedIcon })), children, resolvedIcon && (iconPosition === 'right' || iconPosition === 'both') && (jsx("span", { className: styles$r.buttonIconRight, "aria-hidden": "true", children: resolvedIcon }))] }));
|
|
132
138
|
};
|
|
133
139
|
const baseProps = {
|
|
134
140
|
ref,
|
|
@@ -2433,7 +2439,7 @@ const ptBR = {
|
|
|
2433
2439
|
},
|
|
2434
2440
|
};
|
|
2435
2441
|
|
|
2436
|
-
var styles$
|
|
2442
|
+
var styles$q = {"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"};
|
|
2437
2443
|
|
|
2438
2444
|
const FLUENT_CHEVRON_MAP = {
|
|
2439
2445
|
down: ChevronDown16Regular,
|
|
@@ -2452,10 +2458,10 @@ const GridMonthCaption = ({ calendarMonth, displayIndex: _displayIndex, ...divPr
|
|
|
2452
2458
|
const date = calendarMonth.date;
|
|
2453
2459
|
const monthLabel = new Intl.DateTimeFormat(intlLocale, { month: "long" }).format(date);
|
|
2454
2460
|
const yearLabel = String(date.getFullYear());
|
|
2455
|
-
return (jsxs("div", { ...divProps, children: [jsx("span", { className: styles$
|
|
2461
|
+
return (jsxs("div", { ...divProps, children: [jsx("span", { className: styles$q.caption_grid_label, children: monthLabel }), jsxs("button", { type: "button", className: styles$q.caption_grid_btn, "aria-pressed": view === "years", onClick: onYearLabelClick, children: [yearLabel, view !== "days" ? (jsx(ChevronUp16Regular, { className: styles$q.caption_year_chevron, "aria-hidden": true })) : (jsx(ChevronDown16Regular, { className: styles$q.caption_year_chevron, "aria-hidden": true }))] })] }));
|
|
2456
2462
|
};
|
|
2457
2463
|
const YEARS_PER_PAGE = 20;
|
|
2458
|
-
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 }) => {
|
|
2464
|
+
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 }) => {
|
|
2459
2465
|
const animate = true;
|
|
2460
2466
|
const [internalSelected, setInternalSelected] = useState(selected ?? undefined);
|
|
2461
2467
|
const [internalDisplayMonth, setInternalDisplayMonth] = useState(() => currentDate ?? defaultMonth ?? new Date());
|
|
@@ -2520,7 +2526,7 @@ const Calendar = ({ selected, currentDate, defaultMonth, startMonth, endMonth, o
|
|
|
2520
2526
|
onYearLabelClick: handleYearLabelClick,
|
|
2521
2527
|
};
|
|
2522
2528
|
const sharedDayPickerProps = {
|
|
2523
|
-
classNames: styles$
|
|
2529
|
+
classNames: styles$q,
|
|
2524
2530
|
animate,
|
|
2525
2531
|
mode: "single",
|
|
2526
2532
|
selected: resolvedSelected,
|
|
@@ -2532,10 +2538,15 @@ const Calendar = ({ selected, currentDate, defaultMonth, startMonth, endMonth, o
|
|
|
2532
2538
|
autoFocus,
|
|
2533
2539
|
"aria-label": ariaLabel,
|
|
2534
2540
|
};
|
|
2535
|
-
|
|
2541
|
+
const scaleClass = {
|
|
2542
|
+
1: 'scale-1-0',
|
|
2543
|
+
1.5: 'scale-1-5',
|
|
2544
|
+
2: 'scale-2-0',
|
|
2545
|
+
}[scale];
|
|
2546
|
+
return (jsx(GridCtx.Provider, { value: gridCtxValue, children: jsxs("div", { className: clsx(styles$q.calendar_grid_wrapper, scaleClass, className), children: [jsx(DayPicker, { id: id, ...sharedDayPickerProps, ...rest, captionLayout: "label", month: resolvedDisplayMonth, onMonthChange: handleMonthChange, components: { MonthCaption: GridMonthCaption, Chevron: CustomChevron } }), gridView !== "days" && (jsxs("div", { className: `${styles$q.gridOverlay}${gridView === "years" ? ` ${styles$q.gridOverlayYears}` : ""}`, role: "dialog", "aria-modal": "true", "aria-label": gridView === "months" ? "Selecione o mês" : "Selecione o ano", children: [gridView === "months" && (jsxs(Fragment, { children: [jsxs("div", { className: styles$q.gridOverlayCaption, children: [jsx("span", { className: styles$q.caption_grid_label, children: new Intl.DateTimeFormat(intlLocale, { month: "long" }).format(resolvedDisplayMonth) }), jsxs("button", { type: "button", className: styles$q.caption_grid_btn, onClick: () => setGridView("days"), "aria-label": "Fechar sele\u00E7\u00E3o de m\u00EAs", children: [displayedYear, jsx(ChevronUp16Regular, { className: styles$q.caption_year_chevron, "aria-hidden": true })] })] }), jsx("div", { className: styles$q.gridCells, children: monthsGrid.map(({ index, label, disabled: monthDisabled }) => (jsx("button", { type: "button", disabled: monthDisabled, className: `${styles$q.gridCell}${displayedMonthIndex === index ? ` ${styles$q.gridCellActive}` : ""}`, onClick: () => handleGridMonthSelect(index), children: label }, index))) })] })), gridView === "years" && (jsxs(Fragment, { children: [jsxs("div", { className: styles$q.gridOverlayCaption, children: [jsx("span", { className: styles$q.caption_grid_label, children: new Intl.DateTimeFormat(intlLocale, { month: "long" }).format(resolvedDisplayMonth) }), jsxs("button", { type: "button", className: styles$q.caption_grid_btn, onClick: () => setGridView("days"), "aria-label": "Fechar sele\u00E7\u00E3o de ano", children: [displayedYear, jsx(ChevronUp16Regular, { className: styles$q.caption_year_chevron, "aria-hidden": true })] }), jsxs("div", { className: styles$q.gridOverlayYearsNav, children: [jsx("button", { type: "button", className: styles$q.gridNavBtn, disabled: !canGoPrevYears, onClick: () => setYearPageStart((s) => s - YEARS_PER_PAGE), "aria-label": "Anos anteriores", children: jsx(ChevronLeft16Regular, { className: styles$q.chevronNavBtnPrev, "aria-hidden": true }) }), jsx("button", { type: "button", className: styles$q.gridNavBtn, disabled: !canGoNextYears, onClick: () => setYearPageStart((s) => s + YEARS_PER_PAGE), "aria-label": "Pr\u00F3ximos anos", children: jsx(ChevronRight16Regular, { className: styles$q.chevronNavBtnNext, "aria-hidden": true }) })] })] }), jsx("div", { className: `${styles$q.gridCells} ${styles$q.gridCellsYears}`, children: yearsInPage.map((year) => (jsx("button", { type: "button", className: `${styles$q.gridCell}${displayedYear === year ? ` ${styles$q.gridCellActive}` : ""}`, onClick: () => handleGridYearSelect(year), children: year }, year))) })] }))] }))] }) }));
|
|
2536
2547
|
};
|
|
2537
2548
|
|
|
2538
|
-
var styles$
|
|
2549
|
+
var styles$p = {"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"};
|
|
2539
2550
|
|
|
2540
2551
|
const Callout = ({ variant = 'neutral', title, text, icon, onDismiss, dismiss, backgroundColor, textColor, className, id, style, ...rest }) => {
|
|
2541
2552
|
if (process.env.NODE_ENV !== 'production' && (text === '' || (typeof text === 'string' && !text.trim()))) {
|
|
@@ -2545,15 +2556,21 @@ const Callout = ({ variant = 'neutral', title, text, icon, onDismiss, dismiss, b
|
|
|
2545
2556
|
const titleId = `callout-title-${id || generatedId}`;
|
|
2546
2557
|
const componentId = id || generatedId;
|
|
2547
2558
|
const isAlert = variant === 'alert';
|
|
2548
|
-
const containerClass = clsx(styles$
|
|
2559
|
+
const containerClass = clsx(styles$p.container, styles$p[variant], { [styles$p.withTitle]: title }, className);
|
|
2549
2560
|
const customStyle = {
|
|
2550
2561
|
...style,
|
|
2551
2562
|
...(backgroundColor && { '--callout-bg': `var(--${backgroundColor})` }),
|
|
2552
2563
|
...(textColor && { '--callout-text': `var(--${textColor})` }),
|
|
2553
2564
|
};
|
|
2554
|
-
return (jsx("div", { id: componentId, className: containerClass, role: isAlert ? 'alert' : 'status', "aria-live": isAlert ? 'assertive' : 'polite', "aria-labelledby": title ? titleId : undefined, style: customStyle, ...rest, children: jsxs("div", { className: styles$
|
|
2565
|
+
return (jsx("div", { id: componentId, className: containerClass, role: isAlert ? 'alert' : 'status', "aria-live": isAlert ? 'assertive' : 'polite', "aria-labelledby": title ? titleId : undefined, style: customStyle, ...rest, children: jsxs("div", { className: styles$p.content, children: [icon && jsx("span", { className: styles$p.icon, "aria-hidden": "true", children: icon }), jsxs("div", { className: styles$p.subcontent, children: [title && (jsx("span", { id: titleId, className: styles$p.title, children: title })), text && jsx("span", { className: styles$p.text, children: text })] }), dismiss && (jsx("button", { className: styles$p.dismiss, onClick: onDismiss, type: "button", "aria-label": "Fechar", children: jsx(Dismiss24Regular, { "aria-hidden": "true" }) }))] }) }));
|
|
2555
2566
|
};
|
|
2556
2567
|
|
|
2568
|
+
var styles$o = {"card":"Card-module__card___LzN-3","card--hoverable":"Card-module__card--hoverable___orpJZ"};
|
|
2569
|
+
|
|
2570
|
+
function Card({ children, className, hoverable }) {
|
|
2571
|
+
return (jsx("main", { className: clsx(styles$o['card'], hoverable && styles$o['card--hoverable'], className), children: children }));
|
|
2572
|
+
}
|
|
2573
|
+
|
|
2557
2574
|
const CheckSmall = ({ className = '', width = 12, height = 10, fill = 'white', ...restProps }) => {
|
|
2558
2575
|
return (jsx("svg", { width: width, height: height, viewBox: "0 0 12 10", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: className, "aria-hidden": "true", ...restProps, children: jsx("path", { d: "M4 9.4L0 5.4L1.4 4L4 6.6L10.6 0L12 1.4L4 9.4Z", fill: fill }) }));
|
|
2559
2576
|
};
|
|
@@ -2562,22 +2579,32 @@ const CheckHalf = ({ className = '', width = 16, height = 16, fill = 'white', ..
|
|
|
2562
2579
|
return (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: jsx("g", { id: "Icons/check_indeterminate_small", children: jsx("path", { id: "icon", d: "M3 9V7H13V9H3Z", fill: fill }) }) }));
|
|
2563
2580
|
};
|
|
2564
2581
|
|
|
2565
|
-
var styles$
|
|
2582
|
+
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"};
|
|
2566
2583
|
|
|
2567
|
-
const Checkbox = ({ id, label, onCheckedChange, checked, disabled, className, indeterminate = false, ...rest }) => {
|
|
2584
|
+
const Checkbox = ({ id, label, onCheckedChange, checked, disabled, className, scale = 1, indeterminate = false, ...rest }) => {
|
|
2568
2585
|
const componentId = id || React.useId();
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2586
|
+
const scaleClass = {
|
|
2587
|
+
1: 'scale-1-0',
|
|
2588
|
+
1.5: 'scale-1-5',
|
|
2589
|
+
2: 'scale-2-0',
|
|
2590
|
+
}[scale];
|
|
2591
|
+
return (jsxs("div", { className: clsx(styles$n.container, scaleClass, className), children: [jsx("div", { className: clsx(styles$n.wrapperCheckbox, {
|
|
2592
|
+
[styles$n.disabled]: disabled,
|
|
2593
|
+
}), role: "presentation", tabIndex: disabled ? -1 : 0, children: jsx(Checkbox$1.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: jsx(Checkbox$1.Indicator, { className: styles$n.indicator, children: indeterminate ? jsx(CheckHalf, {}) : jsx(CheckSmall, {}) }) }) }), jsx("label", { className: clsx(styles$n.label, { [styles$n.disabled]: disabled }), htmlFor: componentId, children: label })] }));
|
|
2572
2594
|
};
|
|
2573
2595
|
|
|
2574
|
-
var styles$
|
|
2575
|
-
|
|
2576
|
-
const Chips = ({ children, leftIcon, rightIcon, variant = 'neutral', disabled = false, backgroundColor, textColor, className, style, ...rest }) => {
|
|
2577
|
-
const
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2596
|
+
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"};
|
|
2597
|
+
|
|
2598
|
+
const Chips = ({ children, leftIcon, rightIcon, variant = 'neutral', disabled = false, backgroundColor, textColor, scale = 1, className, style, ...rest }) => {
|
|
2599
|
+
const scaleClass = {
|
|
2600
|
+
1: 'scale-1-0',
|
|
2601
|
+
1.5: 'scale-1-5',
|
|
2602
|
+
2: 'scale-2-0',
|
|
2603
|
+
}[scale];
|
|
2604
|
+
const chipsClass = clsx(styles$m.chips, styles$m[variant], scaleClass, {
|
|
2605
|
+
[styles$m.disabled]: disabled,
|
|
2606
|
+
[styles$m.hasLeftIcon]: leftIcon,
|
|
2607
|
+
[styles$m.hasRightIcon]: rightIcon,
|
|
2581
2608
|
}, className);
|
|
2582
2609
|
const colorStyle = {
|
|
2583
2610
|
...(!disabled && backgroundColor && { '--chips-bg': `var(--${backgroundColor})` }),
|
|
@@ -2585,24 +2612,720 @@ const Chips = ({ children, leftIcon, rightIcon, variant = 'neutral', disabled =
|
|
|
2585
2612
|
...style,
|
|
2586
2613
|
};
|
|
2587
2614
|
const isInteractive = typeof rest.onClick === 'function';
|
|
2588
|
-
return (jsxs("div", { className: chipsClass, "aria-disabled": disabled, style: colorStyle, role: isInteractive ? 'button' : undefined, tabIndex: isInteractive ? (disabled ? -1 : 0) : undefined, ...rest, children: [leftIcon && (jsx("span", { className: styles$
|
|
2615
|
+
return (jsxs("div", { className: chipsClass, "aria-disabled": disabled, style: colorStyle, role: isInteractive ? 'button' : undefined, tabIndex: isInteractive ? (disabled ? -1 : 0) : undefined, ...rest, children: [leftIcon && (jsx("span", { className: styles$m.iconLeft, "aria-hidden": "true", children: leftIcon })), jsx("span", { className: styles$m.title, children: children }), rightIcon && (jsx("span", { className: styles$m.iconRight, children: rightIcon }))] }));
|
|
2589
2616
|
};
|
|
2590
2617
|
const MemoizedChips = React__default.memo(Chips);
|
|
2591
2618
|
MemoizedChips.displayName = 'Chips';
|
|
2592
2619
|
|
|
2593
|
-
var styles$
|
|
2620
|
+
var styles$l = {"container":"Container-module__container___exPuE"};
|
|
2594
2621
|
|
|
2595
2622
|
function Container({ children, className }) {
|
|
2596
|
-
return (jsx("main", { className: clsx(styles$
|
|
2623
|
+
return (jsx("main", { className: clsx(styles$l['container'], 'mx-auto', className), children: children }));
|
|
2597
2624
|
}
|
|
2598
2625
|
|
|
2599
|
-
var styles$
|
|
2626
|
+
var styles$k = {"Content":"Popover-module__Content___RIETg"};
|
|
2600
2627
|
|
|
2601
2628
|
const Popover = ({ trigger, content, side = "left", align = "start", sideOffset = 8, open, onOpenChange, asAnchor = false, onOpenAutoFocus, onCloseAutoFocus, showArrow = false, className, ...rest }) => {
|
|
2602
|
-
return (jsxs(Popover$1.Root, { open: open, onOpenChange: onOpenChange, ...rest, children: [asAnchor ? (jsx(Popover$1.Anchor, { asChild: true, children: trigger })) : (jsx(Popover$1.Trigger, { asChild: true, children: trigger })), jsx(Popover$1.Portal, { children: jsxs(Popover$1.Content, { className: clsx(styles$
|
|
2629
|
+
return (jsxs(Popover$1.Root, { open: open, onOpenChange: onOpenChange, ...rest, children: [asAnchor ? (jsx(Popover$1.Anchor, { asChild: true, children: trigger })) : (jsx(Popover$1.Trigger, { asChild: true, children: trigger })), jsx(Popover$1.Portal, { children: jsxs(Popover$1.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 && jsx(Popover$1.Arrow, {})] }) })] }));
|
|
2630
|
+
};
|
|
2631
|
+
|
|
2632
|
+
function useInputKeyboardValue(externalRef) {
|
|
2633
|
+
const internalRef = useRef(null);
|
|
2634
|
+
const setRefs = useCallback((node) => {
|
|
2635
|
+
internalRef.current = node;
|
|
2636
|
+
if (typeof externalRef === 'function') {
|
|
2637
|
+
externalRef(node);
|
|
2638
|
+
return;
|
|
2639
|
+
}
|
|
2640
|
+
if (externalRef) {
|
|
2641
|
+
externalRef.current = node;
|
|
2642
|
+
}
|
|
2643
|
+
}, [externalRef]);
|
|
2644
|
+
return { internalRef, setRefs };
|
|
2645
|
+
}
|
|
2646
|
+
|
|
2647
|
+
const iconSlot = (key) => `<span data-icon-key="${key}"></span>`;
|
|
2648
|
+
const ICON_KEY_MAP = {
|
|
2649
|
+
bksp: Backspace20Regular,
|
|
2650
|
+
shift: KeyboardShift20Regular,
|
|
2651
|
+
shiftactivated: KeyboardShift20Filled,
|
|
2652
|
+
capslock: KeyboardShiftUppercase20Regular,
|
|
2653
|
+
downkeyboard: ChevronDown20Regular,
|
|
2654
|
+
emoji: Emoji20Regular,
|
|
2655
|
+
};
|
|
2656
|
+
const SHARED_DISPLAY = {
|
|
2657
|
+
'{capslock}': iconSlot('capslock'),
|
|
2658
|
+
'{numbers}': '123',
|
|
2659
|
+
'{abc}': 'Abc',
|
|
2660
|
+
'{alt}': '.?!',
|
|
2661
|
+
'{alt2}': '#+=',
|
|
2662
|
+
'{emoticon}': iconSlot('emoji'),
|
|
2663
|
+
'{shift}': iconSlot('shift'),
|
|
2664
|
+
'{shiftactivated}': iconSlot('shiftactivated'),
|
|
2665
|
+
'{enter}': 'Enter',
|
|
2666
|
+
'{bksp}': iconSlot('bksp'),
|
|
2667
|
+
'{altright}': '.?123',
|
|
2668
|
+
'{downkeyboard}': iconSlot('downkeyboard'),
|
|
2669
|
+
'{space}': ' ',
|
|
2670
|
+
'{default}': 'Abc',
|
|
2671
|
+
};
|
|
2672
|
+
const LAYOUT_DISPLAY = {
|
|
2673
|
+
default: SHARED_DISPLAY,
|
|
2674
|
+
numeric: SHARED_DISPLAY,
|
|
2675
|
+
};
|
|
2676
|
+
|
|
2677
|
+
const EMOTICON_KEY = '{emoticon}';
|
|
2678
|
+
const DOWN_KEYBOARD_KEY = '{downkeyboard}';
|
|
2679
|
+
const removeKeyFromLayout = (layout, key) => Object.fromEntries(Object.entries(layout).map(([layoutName, rows]) => [
|
|
2680
|
+
layoutName,
|
|
2681
|
+
rows.map((row) => row.split(key).join(' ').replace(/\s+/g, ' ').trim()),
|
|
2682
|
+
]));
|
|
2683
|
+
const QWERTY_LOWERCASE = [
|
|
2684
|
+
'1 2 3 4 5 6 7 8 9 0',
|
|
2685
|
+
'q w e r t y u i o p',
|
|
2686
|
+
'a s d f g h j k l ç',
|
|
2687
|
+
'{shift} z x c v b n m {bksp}',
|
|
2688
|
+
'{numbers} {alt} {space} . {enter}',
|
|
2689
|
+
];
|
|
2690
|
+
const NUMPAD = ['1 2 3', '4 5 6', '7 8 9', '{bksp} 0 {abc}'];
|
|
2691
|
+
const SHARED_LAYOUTS = {
|
|
2692
|
+
shift: [
|
|
2693
|
+
'1 2 3 4 5 6 7 8 9 0',
|
|
2694
|
+
'Q W E R T Y U I O P',
|
|
2695
|
+
'A S D F G H J K L Ç',
|
|
2696
|
+
'{capslock} Z X C V B N M {bksp}',
|
|
2697
|
+
'{numbers} {alt} {emoticon} {space} . {enter}',
|
|
2698
|
+
],
|
|
2699
|
+
caps: [
|
|
2700
|
+
'1 2 3 4 5 6 7 8 9 0',
|
|
2701
|
+
'Q W E R T Y U I O P',
|
|
2702
|
+
'A S D F G H J K L Ç',
|
|
2703
|
+
'{shiftactivated} Z X C V B N M {bksp}',
|
|
2704
|
+
'{numbers} {alt} {emoticon} {space} . {enter}',
|
|
2705
|
+
],
|
|
2706
|
+
numbers: NUMPAD,
|
|
2707
|
+
alt: [
|
|
2708
|
+
'1 2 3 4 5 6 7 8 9 0',
|
|
2709
|
+
`- / : ; ( ) $ & @ "`,
|
|
2710
|
+
'{alt2} . , ? ! ´ {bksp}',
|
|
2711
|
+
'{default} {emoticon} {space} {enter}',
|
|
2712
|
+
],
|
|
2713
|
+
alt2: [
|
|
2714
|
+
'[ ] { } # % ^ * + =',
|
|
2715
|
+
'_ \\ | ~ < > ¢ £ ¥ •',
|
|
2716
|
+
`{alt} . , ? ! ' {bksp}`,
|
|
2717
|
+
'{default} {emoticon} {space} {enter}',
|
|
2718
|
+
],
|
|
2719
|
+
emoticon: [
|
|
2720
|
+
'😀 😊 😅 😂 🙂 😉 😍 😛 😠 😎 {bksp}',
|
|
2721
|
+
`😏 😬 😭 😓 😱 😪 🙄 😴 😯 {enter}`,
|
|
2722
|
+
'😐 😇 🤣 😘 😚 😆 😡 😥 😓 {shift}',
|
|
2723
|
+
'{default} {alt} {space} {altright} {downkeyboard}',
|
|
2724
|
+
],
|
|
2725
|
+
};
|
|
2726
|
+
const NATIVE_LAYOUTS = {
|
|
2727
|
+
default: {
|
|
2728
|
+
default: QWERTY_LOWERCASE,
|
|
2729
|
+
...SHARED_LAYOUTS,
|
|
2730
|
+
},
|
|
2731
|
+
numeric: {
|
|
2732
|
+
default: NUMPAD,
|
|
2733
|
+
abc: QWERTY_LOWERCASE,
|
|
2734
|
+
...SHARED_LAYOUTS,
|
|
2735
|
+
},
|
|
2736
|
+
};
|
|
2737
|
+
const NATIVE_LAYOUT_KEYS = new Set([
|
|
2738
|
+
'default', 'numeric',
|
|
2739
|
+
]);
|
|
2740
|
+
const getNativeLayout = (type, Emoji = true, showDownKeyboardButton = true, isFixed = false) => {
|
|
2741
|
+
const layout = NATIVE_LAYOUTS[type] ?? NATIVE_LAYOUTS.default ?? null;
|
|
2742
|
+
if (!layout)
|
|
2743
|
+
return null;
|
|
2744
|
+
let computedLayout = layout;
|
|
2745
|
+
if (!Emoji) {
|
|
2746
|
+
computedLayout = removeKeyFromLayout(computedLayout, EMOTICON_KEY);
|
|
2747
|
+
}
|
|
2748
|
+
if (!showDownKeyboardButton) {
|
|
2749
|
+
computedLayout = removeKeyFromLayout(computedLayout, DOWN_KEYBOARD_KEY);
|
|
2750
|
+
}
|
|
2751
|
+
if (isFixed) {
|
|
2752
|
+
computedLayout = Object.fromEntries(Object.entries(computedLayout).map(([layoutName, rows]) => [
|
|
2753
|
+
layoutName,
|
|
2754
|
+
rows.map((row) => {
|
|
2755
|
+
const trimmed = row.trim();
|
|
2756
|
+
if (/^[a-zA-ZçÇ]/.test(trimmed) && trimmed.endsWith('{bksp}')) {
|
|
2757
|
+
return '{//} ' + trimmed.replace(/\s*\{bksp\}$/, '') + ' {//}';
|
|
2758
|
+
}
|
|
2759
|
+
if (/\{(shift|capslock|shiftactivated)\}$/.test(trimmed)) {
|
|
2760
|
+
return trimmed.replace(/\{(shift|capslock|shiftactivated)\}$/, '{bksp}');
|
|
2761
|
+
}
|
|
2762
|
+
return row;
|
|
2763
|
+
}),
|
|
2764
|
+
]));
|
|
2765
|
+
}
|
|
2766
|
+
return computedLayout;
|
|
2767
|
+
};
|
|
2768
|
+
const SHIFT_TOGGLES = {
|
|
2769
|
+
default: 'shift',
|
|
2770
|
+
abc: 'shift',
|
|
2771
|
+
shift: 'default',
|
|
2772
|
+
alt: 'default',
|
|
2773
|
+
alt2: 'alt',
|
|
2774
|
+
};
|
|
2775
|
+
|
|
2776
|
+
var styles$j = {"container":"VirtualKeyboard-module__container___A-e0I","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","keyPreview":"VirtualKeyboard-module__keyPreview___oWaO1","accentMenu":"VirtualKeyboard-module__accentMenu___A6tTy","accentMenuRow":"VirtualKeyboard-module__accentMenuRow___3kbvT","accentOption":"VirtualKeyboard-module__accentOption___ao-Ta"};
|
|
2777
|
+
|
|
2778
|
+
const LONG_PRESS_DELAY_MS = 400;
|
|
2779
|
+
const ACCENT_OPTIONS = {
|
|
2780
|
+
a: ['a', 'á', 'à', 'â', 'ã', 'ä', 'å', 'æ', '@', 'ª'],
|
|
2781
|
+
e: ['e', 'é', 'è', 'ê', 'ë', 'ę', 'ē', 'ė', '€'],
|
|
2782
|
+
i: ['i', 'í', 'ì', 'î', 'ï', 'ī', 'į', 'ı'],
|
|
2783
|
+
o: ['o', 'ó', 'ò', 'ô', 'õ', 'ö', 'ō', 'ø', 'œ', 'º'],
|
|
2784
|
+
u: ['u', 'ú', 'ù', 'û', 'ü', 'ū', 'ů', 'ű'],
|
|
2785
|
+
y: ['y', 'ý', 'ÿ', 'ŷ', 'ȳ'],
|
|
2786
|
+
n: ['n', 'ñ'],
|
|
2787
|
+
c: ['c', 'ç'],
|
|
2788
|
+
'?': ['?', '¿'],
|
|
2789
|
+
'!': ['!', '¡'],
|
|
2790
|
+
};
|
|
2791
|
+
/**
|
|
2792
|
+
* Componente VirtualKeyboard — teclado virtual on-screen para entradas controladas.
|
|
2793
|
+
*
|
|
2794
|
+
* @description Baseado em `react-simple-keyboard`, oferece apenas layouts nativos (QWERTY e numérico)
|
|
2795
|
+
* seguindo o visual padrão da biblioteca.
|
|
2796
|
+
*
|
|
2797
|
+
* Possui dois modos:
|
|
2798
|
+
* - **`native`** (padrão): age como teclado nativo — aparece ao focar no campo referenciado por `targetRef` e some ao perder o foco.
|
|
2799
|
+
* - **`fixed`**: teclado sempre visível com um TextField próprio acima.
|
|
2800
|
+
*
|
|
2801
|
+
* @example
|
|
2802
|
+
* ```tsx
|
|
2803
|
+
* // Modo fixed
|
|
2804
|
+
* <VirtualKeyboard variant="fixed" type="default" onChange={setValue} />
|
|
2805
|
+
* ```
|
|
2806
|
+
*
|
|
2807
|
+
* @example
|
|
2808
|
+
* ```tsx
|
|
2809
|
+
* // Modo native — aparece ao focar no input
|
|
2810
|
+
* const inputRef = useRef<HTMLInputElement>(null);
|
|
2811
|
+
* const [value, setValue] = useState('');
|
|
2812
|
+
* <input ref={inputRef} value={value} readOnly />
|
|
2813
|
+
* <VirtualKeyboard targetRef={inputRef} value={value} onChange={setValue} />
|
|
2814
|
+
* ```
|
|
2815
|
+
*/
|
|
2816
|
+
const VirtualKeyboard = ({ variant = 'native', type = 'default', value = '', onChange, onKeyPress, maxLength, Emoji = false, className, id, textFieldPlaceholder = 'Digite aqui...', helperText, error, errorMessage, targetRef, }) => {
|
|
2817
|
+
const [layoutName, setLayoutName] = useState('default');
|
|
2818
|
+
const [capsLockOn, setCapsLockOn] = useState(false);
|
|
2819
|
+
const [accentMenu, setAccentMenu] = useState(null);
|
|
2820
|
+
const [accentMenuOffsetX, setAccentMenuOffsetX] = useState(0);
|
|
2821
|
+
const [activeLayout, setActiveLayout] = useState(getNativeLayout(type, Emoji, variant === 'native', variant === 'fixed'));
|
|
2822
|
+
const visualType = NATIVE_LAYOUT_KEYS.has(type) ? type : 'default';
|
|
2823
|
+
const [isOpen, setIsOpen] = useState(variant !== 'native');
|
|
2824
|
+
const hideTimeoutRef = useRef(null);
|
|
2825
|
+
const scrollTimeoutRef = useRef(null);
|
|
2826
|
+
const longPressTimeoutRef = useRef(null);
|
|
2827
|
+
const suppressNextInputRef = useRef(null);
|
|
2828
|
+
const heldAccentKeyRef = useRef(null);
|
|
2829
|
+
const longPressTriggeredRef = useRef(false);
|
|
2830
|
+
const isKeyboardInteractingRef = useRef(false);
|
|
2831
|
+
const keyboardWrapperRef = useRef(null);
|
|
2832
|
+
const keyboardInstanceRef = useRef(null);
|
|
2833
|
+
const accentMenuRef = useRef(null);
|
|
2834
|
+
const accentButtonRef = useRef(null);
|
|
2835
|
+
const valueRef = useRef(value);
|
|
2836
|
+
const [iconSlots, setIconSlots] = useState([]);
|
|
2837
|
+
const [keyPreview, setKeyPreview] = useState(null);
|
|
2838
|
+
const [keyPreviewOffsetX, setKeyPreviewOffsetX] = useState(0);
|
|
2839
|
+
const keyPreviewRef = useRef(null);
|
|
2840
|
+
const [containerWidth, setContainerWidth] = useState(Infinity);
|
|
2841
|
+
useEffect(() => {
|
|
2842
|
+
valueRef.current = value;
|
|
2843
|
+
}, [value]);
|
|
2844
|
+
const clearLongPressTimeout = useCallback(() => {
|
|
2845
|
+
if (longPressTimeoutRef.current !== null) {
|
|
2846
|
+
clearTimeout(longPressTimeoutRef.current);
|
|
2847
|
+
longPressTimeoutRef.current = null;
|
|
2848
|
+
}
|
|
2849
|
+
}, []);
|
|
2850
|
+
const closeAccentMenu = useCallback(() => {
|
|
2851
|
+
setAccentMenu(null);
|
|
2852
|
+
accentButtonRef.current = null;
|
|
2853
|
+
}, []);
|
|
2854
|
+
const syncKeyboardInput = useCallback((nextValue) => {
|
|
2855
|
+
keyboardInstanceRef.current?.setInput(nextValue);
|
|
2856
|
+
}, []);
|
|
2857
|
+
useEffect(() => {
|
|
2858
|
+
syncKeyboardInput(value);
|
|
2859
|
+
}, [value, syncKeyboardInput]);
|
|
2860
|
+
const scheduleHideIfBlurred = useCallback(() => {
|
|
2861
|
+
if (variant !== 'native')
|
|
2862
|
+
return;
|
|
2863
|
+
if (hideTimeoutRef.current !== null) {
|
|
2864
|
+
clearTimeout(hideTimeoutRef.current);
|
|
2865
|
+
}
|
|
2866
|
+
hideTimeoutRef.current = setTimeout(() => {
|
|
2867
|
+
const targetEl = targetRef?.current;
|
|
2868
|
+
const isTargetFocused = !!targetEl && document.activeElement === targetEl;
|
|
2869
|
+
if (!isTargetFocused && !isKeyboardInteractingRef.current) {
|
|
2870
|
+
setIsOpen(false);
|
|
2871
|
+
}
|
|
2872
|
+
}, 150);
|
|
2873
|
+
}, [variant, targetRef]);
|
|
2874
|
+
const scrollTargetIntoView = useCallback(() => {
|
|
2875
|
+
const targetEl = targetRef?.current;
|
|
2876
|
+
if (!targetEl)
|
|
2877
|
+
return;
|
|
2878
|
+
const keyboardHeight = keyboardWrapperRef.current?.offsetHeight ?? 0;
|
|
2879
|
+
const rect = targetEl.getBoundingClientRect();
|
|
2880
|
+
const visibleBottom = window.innerHeight - keyboardHeight - 8;
|
|
2881
|
+
if (rect.bottom > visibleBottom) {
|
|
2882
|
+
window.scrollBy({ top: rect.bottom - visibleBottom, behavior: 'smooth' });
|
|
2883
|
+
}
|
|
2884
|
+
}, [targetRef]);
|
|
2885
|
+
useEffect(() => {
|
|
2886
|
+
if (variant !== 'native')
|
|
2887
|
+
return;
|
|
2888
|
+
if (!targetRef?.current) {
|
|
2889
|
+
setIsOpen(true);
|
|
2890
|
+
return;
|
|
2891
|
+
}
|
|
2892
|
+
const el = targetRef.current;
|
|
2893
|
+
const handleFocus = () => {
|
|
2894
|
+
if (hideTimeoutRef.current !== null)
|
|
2895
|
+
clearTimeout(hideTimeoutRef.current);
|
|
2896
|
+
if (scrollTimeoutRef.current !== null)
|
|
2897
|
+
clearTimeout(scrollTimeoutRef.current);
|
|
2898
|
+
setIsOpen(true);
|
|
2899
|
+
scrollTimeoutRef.current = setTimeout(scrollTargetIntoView, 50);
|
|
2900
|
+
};
|
|
2901
|
+
const handleBlur = () => {
|
|
2902
|
+
scheduleHideIfBlurred();
|
|
2903
|
+
};
|
|
2904
|
+
el.addEventListener('focus', handleFocus);
|
|
2905
|
+
el.addEventListener('blur', handleBlur);
|
|
2906
|
+
return () => {
|
|
2907
|
+
el.removeEventListener('focus', handleFocus);
|
|
2908
|
+
el.removeEventListener('blur', handleBlur);
|
|
2909
|
+
if (hideTimeoutRef.current !== null)
|
|
2910
|
+
clearTimeout(hideTimeoutRef.current);
|
|
2911
|
+
if (scrollTimeoutRef.current !== null)
|
|
2912
|
+
clearTimeout(scrollTimeoutRef.current);
|
|
2913
|
+
};
|
|
2914
|
+
}, [variant, targetRef, scheduleHideIfBlurred, scrollTargetIntoView]);
|
|
2915
|
+
useEffect(() => {
|
|
2916
|
+
if (variant !== 'native')
|
|
2917
|
+
return;
|
|
2918
|
+
const wrapper = keyboardWrapperRef.current;
|
|
2919
|
+
if (!wrapper)
|
|
2920
|
+
return;
|
|
2921
|
+
const preventIOSBlur = (event) => {
|
|
2922
|
+
const targetEl = event.target;
|
|
2923
|
+
!!targetEl.closest('.hg-button');
|
|
2924
|
+
event.preventDefault();
|
|
2925
|
+
};
|
|
2926
|
+
wrapper.addEventListener('touchstart', preventIOSBlur, { passive: false });
|
|
2927
|
+
return () => {
|
|
2928
|
+
wrapper.removeEventListener('touchstart', preventIOSBlur);
|
|
2929
|
+
};
|
|
2930
|
+
}, [variant]);
|
|
2931
|
+
useEffect(() => {
|
|
2932
|
+
setLayoutName('default');
|
|
2933
|
+
setCapsLockOn(false);
|
|
2934
|
+
setActiveLayout(getNativeLayout(type, Emoji, variant === 'native', variant === 'fixed'));
|
|
2935
|
+
}, [type, Emoji, variant]);
|
|
2936
|
+
useEffect(() => {
|
|
2937
|
+
if (!Emoji && layoutName === 'emoticon') {
|
|
2938
|
+
setLayoutName(type === 'numeric' ? 'abc' : 'default');
|
|
2939
|
+
}
|
|
2940
|
+
}, [Emoji, layoutName, type]);
|
|
2941
|
+
useEffect(() => {
|
|
2942
|
+
return () => {
|
|
2943
|
+
clearLongPressTimeout();
|
|
2944
|
+
};
|
|
2945
|
+
}, [clearLongPressTimeout]);
|
|
2946
|
+
useEffect(() => {
|
|
2947
|
+
if (!accentMenu)
|
|
2948
|
+
return;
|
|
2949
|
+
const handleOutsidePointerDown = (event) => {
|
|
2950
|
+
if (accentMenuRef.current?.contains(event.target))
|
|
2951
|
+
return;
|
|
2952
|
+
closeAccentMenu();
|
|
2953
|
+
};
|
|
2954
|
+
const handleEscape = (event) => {
|
|
2955
|
+
if (event.key === 'Escape') {
|
|
2956
|
+
closeAccentMenu();
|
|
2957
|
+
}
|
|
2958
|
+
};
|
|
2959
|
+
document.addEventListener('pointerdown', handleOutsidePointerDown, true);
|
|
2960
|
+
document.addEventListener('keydown', handleEscape);
|
|
2961
|
+
return () => {
|
|
2962
|
+
document.removeEventListener('pointerdown', handleOutsidePointerDown, true);
|
|
2963
|
+
document.removeEventListener('keydown', handleEscape);
|
|
2964
|
+
};
|
|
2965
|
+
}, [accentMenu, closeAccentMenu]);
|
|
2966
|
+
useLayoutEffect(() => {
|
|
2967
|
+
if (!keyPreview || !keyPreviewRef.current)
|
|
2968
|
+
return;
|
|
2969
|
+
const margin = 8;
|
|
2970
|
+
const rect = keyPreviewRef.current.getBoundingClientRect();
|
|
2971
|
+
if (rect.width <= 0 || rect.height <= 0)
|
|
2972
|
+
return;
|
|
2973
|
+
const minCenter = margin + rect.width / 2;
|
|
2974
|
+
const maxCenter = window.innerWidth - margin - rect.width / 2;
|
|
2975
|
+
const clampedCenter = Math.min(maxCenter, Math.max(minCenter, keyPreview.left));
|
|
2976
|
+
const nextOffset = clampedCenter - keyPreview.left;
|
|
2977
|
+
if (Math.abs(nextOffset - keyPreviewOffsetX) > 0.5) {
|
|
2978
|
+
setKeyPreviewOffsetX(nextOffset);
|
|
2979
|
+
}
|
|
2980
|
+
}, [keyPreview, keyPreviewOffsetX]);
|
|
2981
|
+
useLayoutEffect(() => {
|
|
2982
|
+
if (!accentMenu || !accentMenuRef.current)
|
|
2983
|
+
return;
|
|
2984
|
+
const margin = 8;
|
|
2985
|
+
const rect = accentMenuRef.current.getBoundingClientRect();
|
|
2986
|
+
if (rect.width <= 0 || rect.height <= 0)
|
|
2987
|
+
return;
|
|
2988
|
+
const minCenter = margin + rect.width / 2;
|
|
2989
|
+
const maxCenter = window.innerWidth - margin - rect.width / 2;
|
|
2990
|
+
const clampedCenter = Math.min(maxCenter, Math.max(minCenter, accentMenu.left));
|
|
2991
|
+
const nextOffset = clampedCenter - accentMenu.left;
|
|
2992
|
+
if (Math.abs(nextOffset - accentMenuOffsetX) > 0.5) {
|
|
2993
|
+
setAccentMenuOffsetX(nextOffset);
|
|
2994
|
+
}
|
|
2995
|
+
}, [accentMenu, accentMenuOffsetX]);
|
|
2996
|
+
useEffect(() => {
|
|
2997
|
+
const wrapper = keyboardWrapperRef.current;
|
|
2998
|
+
if (!wrapper)
|
|
2999
|
+
return;
|
|
3000
|
+
const ro = new ResizeObserver((entries) => {
|
|
3001
|
+
setContainerWidth(entries[0]?.contentRect.width ?? Infinity);
|
|
3002
|
+
});
|
|
3003
|
+
ro.observe(wrapper);
|
|
3004
|
+
return () => ro.disconnect();
|
|
3005
|
+
}, []);
|
|
3006
|
+
useEffect(() => {
|
|
3007
|
+
if (!keyboardWrapperRef.current)
|
|
3008
|
+
return;
|
|
3009
|
+
const container = keyboardWrapperRef.current;
|
|
3010
|
+
const registerNewSlots = () => {
|
|
3011
|
+
const newSlots = Array.from(container.querySelectorAll('[data-icon-key]:not([data-icon-root])'));
|
|
3012
|
+
if (newSlots.length === 0)
|
|
3013
|
+
return;
|
|
3014
|
+
newSlots.forEach((s) => s.setAttribute('data-icon-root', 'true'));
|
|
3015
|
+
setIconSlots((prev) => [...prev, ...newSlots]);
|
|
3016
|
+
};
|
|
3017
|
+
registerNewSlots();
|
|
3018
|
+
const observer = new MutationObserver(() => {
|
|
3019
|
+
setIconSlots((prev) => prev.filter((slot) => container.contains(slot)));
|
|
3020
|
+
registerNewSlots();
|
|
3021
|
+
});
|
|
3022
|
+
observer.observe(container, { childList: true, subtree: true });
|
|
3023
|
+
return () => {
|
|
3024
|
+
observer.disconnect();
|
|
3025
|
+
};
|
|
3026
|
+
}, []);
|
|
3027
|
+
useEffect(() => {
|
|
3028
|
+
closeAccentMenu();
|
|
3029
|
+
setAccentMenuOffsetX(0);
|
|
3030
|
+
suppressNextInputRef.current = null;
|
|
3031
|
+
clearLongPressTimeout();
|
|
3032
|
+
}, [layoutName, type, closeAccentMenu, clearLongPressTimeout]);
|
|
3033
|
+
useEffect(() => {
|
|
3034
|
+
const updateAccentPosition = () => {
|
|
3035
|
+
const btn = accentButtonRef.current;
|
|
3036
|
+
if (!btn)
|
|
3037
|
+
return;
|
|
3038
|
+
const rect = btn.getBoundingClientRect();
|
|
3039
|
+
setAccentMenu((prev) => prev ? { ...prev, top: rect.top - 8, left: rect.left + rect.width / 2 } : null);
|
|
3040
|
+
};
|
|
3041
|
+
window.addEventListener('scroll', updateAccentPosition, { capture: true, passive: true });
|
|
3042
|
+
window.addEventListener('resize', updateAccentPosition);
|
|
3043
|
+
return () => {
|
|
3044
|
+
window.removeEventListener('scroll', updateAccentPosition, true);
|
|
3045
|
+
window.removeEventListener('resize', updateAccentPosition);
|
|
3046
|
+
};
|
|
3047
|
+
}, []);
|
|
3048
|
+
const handleLongPressStart = useCallback((event) => {
|
|
3049
|
+
isKeyboardInteractingRef.current = true;
|
|
3050
|
+
if (hideTimeoutRef.current !== null) {
|
|
3051
|
+
clearTimeout(hideTimeoutRef.current);
|
|
3052
|
+
}
|
|
3053
|
+
const keyboardWrapper = keyboardWrapperRef.current;
|
|
3054
|
+
if (!keyboardWrapper)
|
|
3055
|
+
return;
|
|
3056
|
+
const buttonEl = event.target.closest('.hg-button');
|
|
3057
|
+
if (!buttonEl || !keyboardWrapper.contains(buttonEl))
|
|
3058
|
+
return;
|
|
3059
|
+
event.preventDefault();
|
|
3060
|
+
const sourceKey = buttonEl.getAttribute('data-skbtn') ?? '';
|
|
3061
|
+
heldAccentKeyRef.current = null;
|
|
3062
|
+
longPressTriggeredRef.current = false;
|
|
3063
|
+
if (sourceKey && !sourceKey.startsWith('{') && type !== 'numeric' && containerWidth <= 768) {
|
|
3064
|
+
const buttonRect = buttonEl.getBoundingClientRect();
|
|
3065
|
+
setKeyPreviewOffsetX(0);
|
|
3066
|
+
setKeyPreview({
|
|
3067
|
+
char: sourceKey,
|
|
3068
|
+
top: buttonRect.top - 4,
|
|
3069
|
+
left: buttonRect.left + buttonRect.width / 2,
|
|
3070
|
+
});
|
|
3071
|
+
}
|
|
3072
|
+
if (!sourceKey || sourceKey.startsWith('{'))
|
|
3073
|
+
return;
|
|
3074
|
+
heldAccentKeyRef.current = sourceKey;
|
|
3075
|
+
clearLongPressTimeout();
|
|
3076
|
+
const accentOptions = ACCENT_OPTIONS[sourceKey.toLowerCase()];
|
|
3077
|
+
if (!accentOptions)
|
|
3078
|
+
return;
|
|
3079
|
+
longPressTimeoutRef.current = setTimeout(() => {
|
|
3080
|
+
const buttonRect = buttonEl.getBoundingClientRect();
|
|
3081
|
+
const isUpperCaseKey = sourceKey === sourceKey.toUpperCase();
|
|
3082
|
+
longPressTriggeredRef.current = true;
|
|
3083
|
+
setKeyPreview(null);
|
|
3084
|
+
accentButtonRef.current = buttonEl;
|
|
3085
|
+
setAccentMenu({
|
|
3086
|
+
sourceKey,
|
|
3087
|
+
options: isUpperCaseKey
|
|
3088
|
+
? accentOptions.map((option) => option.toUpperCase())
|
|
3089
|
+
: accentOptions,
|
|
3090
|
+
top: buttonRect.top - 8,
|
|
3091
|
+
left: buttonRect.left + buttonRect.width / 2,
|
|
3092
|
+
});
|
|
3093
|
+
setAccentMenuOffsetX(0);
|
|
3094
|
+
suppressNextInputRef.current = sourceKey;
|
|
3095
|
+
}, LONG_PRESS_DELAY_MS);
|
|
3096
|
+
}, [clearLongPressTimeout, type, containerWidth]);
|
|
3097
|
+
const handleLongPressEnd = useCallback(() => {
|
|
3098
|
+
const heldKey = heldAccentKeyRef.current;
|
|
3099
|
+
const longPressTriggered = longPressTriggeredRef.current;
|
|
3100
|
+
const baseLayout = type === 'numeric' ? 'abc' : 'default';
|
|
3101
|
+
setKeyPreview(null);
|
|
3102
|
+
isKeyboardInteractingRef.current = false;
|
|
3103
|
+
clearLongPressTimeout();
|
|
3104
|
+
if (heldKey && !longPressTriggered) {
|
|
3105
|
+
const currentValue = valueRef.current;
|
|
3106
|
+
if (maxLength === undefined || currentValue.length < maxLength) {
|
|
3107
|
+
const nextValue = `${currentValue}${heldKey}`;
|
|
3108
|
+
onChange?.(nextValue);
|
|
3109
|
+
onKeyPress?.(heldKey);
|
|
3110
|
+
syncKeyboardInput(nextValue);
|
|
3111
|
+
}
|
|
3112
|
+
if (layoutName === 'shift' && !capsLockOn) {
|
|
3113
|
+
setLayoutName(baseLayout);
|
|
3114
|
+
}
|
|
3115
|
+
suppressNextInputRef.current = heldKey;
|
|
3116
|
+
}
|
|
3117
|
+
heldAccentKeyRef.current = null;
|
|
3118
|
+
longPressTriggeredRef.current = false;
|
|
3119
|
+
scheduleHideIfBlurred();
|
|
3120
|
+
}, [
|
|
3121
|
+
clearLongPressTimeout,
|
|
3122
|
+
scheduleHideIfBlurred,
|
|
3123
|
+
maxLength,
|
|
3124
|
+
onChange,
|
|
3125
|
+
onKeyPress,
|
|
3126
|
+
syncKeyboardInput,
|
|
3127
|
+
type,
|
|
3128
|
+
layoutName,
|
|
3129
|
+
capsLockOn,
|
|
3130
|
+
]);
|
|
3131
|
+
const handleAccentSelect = useCallback((accentedChar) => {
|
|
3132
|
+
const currentValue = valueRef.current;
|
|
3133
|
+
const baseLayout = type === 'numeric' ? 'abc' : 'default';
|
|
3134
|
+
if (maxLength !== undefined && currentValue.length >= maxLength) {
|
|
3135
|
+
closeAccentMenu();
|
|
3136
|
+
suppressNextInputRef.current = null;
|
|
3137
|
+
syncKeyboardInput(currentValue);
|
|
3138
|
+
return;
|
|
3139
|
+
}
|
|
3140
|
+
const nextValue = `${currentValue}${accentedChar}`;
|
|
3141
|
+
onChange?.(nextValue);
|
|
3142
|
+
onKeyPress?.(accentedChar);
|
|
3143
|
+
closeAccentMenu();
|
|
3144
|
+
suppressNextInputRef.current = null;
|
|
3145
|
+
heldAccentKeyRef.current = null;
|
|
3146
|
+
longPressTriggeredRef.current = false;
|
|
3147
|
+
if (layoutName === 'shift' && !capsLockOn) {
|
|
3148
|
+
setLayoutName(baseLayout);
|
|
3149
|
+
}
|
|
3150
|
+
syncKeyboardInput(nextValue);
|
|
3151
|
+
}, [maxLength, onChange, onKeyPress, closeAccentMenu, syncKeyboardInput, type, layoutName, capsLockOn]);
|
|
3152
|
+
const handleKeyPress = useCallback((button) => {
|
|
3153
|
+
const baseLayout = type === 'numeric' ? 'abc' : 'default';
|
|
3154
|
+
if (button === '{capslock}') {
|
|
3155
|
+
setCapsLockOn((prev) => {
|
|
3156
|
+
const next = !prev;
|
|
3157
|
+
setLayoutName(next ? 'caps' : baseLayout);
|
|
3158
|
+
return next;
|
|
3159
|
+
});
|
|
3160
|
+
return;
|
|
3161
|
+
}
|
|
3162
|
+
if (button === '{shift}' ||
|
|
3163
|
+
button === '{shiftactivated}') {
|
|
3164
|
+
if (button === '{shiftactivated}') {
|
|
3165
|
+
setCapsLockOn(false);
|
|
3166
|
+
setLayoutName(baseLayout);
|
|
3167
|
+
return;
|
|
3168
|
+
}
|
|
3169
|
+
setLayoutName((prev) => {
|
|
3170
|
+
const next = SHIFT_TOGGLES[prev] ?? 'default';
|
|
3171
|
+
return next === 'default' ? baseLayout : next;
|
|
3172
|
+
});
|
|
3173
|
+
return;
|
|
3174
|
+
}
|
|
3175
|
+
if (button === '{numbers}') {
|
|
3176
|
+
setLayoutName('numbers');
|
|
3177
|
+
return;
|
|
3178
|
+
}
|
|
3179
|
+
if (button === '{abc}') {
|
|
3180
|
+
setLayoutName(baseLayout);
|
|
3181
|
+
return;
|
|
3182
|
+
}
|
|
3183
|
+
if (button === '{alt}' || button === '{altright}') {
|
|
3184
|
+
setLayoutName((prev) => {
|
|
3185
|
+
if (prev === 'alt2')
|
|
3186
|
+
return 'alt';
|
|
3187
|
+
return prev === 'alt' ? baseLayout : 'alt';
|
|
3188
|
+
});
|
|
3189
|
+
return;
|
|
3190
|
+
}
|
|
3191
|
+
if (button === '{alt2}') {
|
|
3192
|
+
setLayoutName((prev) => (prev === 'alt2' ? 'alt' : 'alt2'));
|
|
3193
|
+
return;
|
|
3194
|
+
}
|
|
3195
|
+
if (button === '{emoticon}') {
|
|
3196
|
+
if (!Emoji)
|
|
3197
|
+
return;
|
|
3198
|
+
setLayoutName((prev) => (prev === 'emoticon' ? baseLayout : 'emoticon'));
|
|
3199
|
+
return;
|
|
3200
|
+
}
|
|
3201
|
+
if (button === '{default}') {
|
|
3202
|
+
setLayoutName(baseLayout);
|
|
3203
|
+
return;
|
|
3204
|
+
}
|
|
3205
|
+
if (button === '{downkeyboard}') {
|
|
3206
|
+
setLayoutName(baseLayout);
|
|
3207
|
+
if (variant === 'native') {
|
|
3208
|
+
closeAccentMenu();
|
|
3209
|
+
setIsOpen(false);
|
|
3210
|
+
const targetElement = targetRef?.current;
|
|
3211
|
+
if (targetElement && document.activeElement === targetElement) {
|
|
3212
|
+
targetElement.blur();
|
|
3213
|
+
}
|
|
3214
|
+
}
|
|
3215
|
+
return;
|
|
3216
|
+
}
|
|
3217
|
+
const isHeldAccentKey = heldAccentKeyRef.current === button;
|
|
3218
|
+
if (button !== '{bksp}' && button !== '{enter}' && !isHeldAccentKey) {
|
|
3219
|
+
if (layoutName === 'shift' && !capsLockOn) {
|
|
3220
|
+
setLayoutName(baseLayout);
|
|
3221
|
+
}
|
|
3222
|
+
else if (layoutName === baseLayout && capsLockOn) {
|
|
3223
|
+
setLayoutName('shift');
|
|
3224
|
+
}
|
|
3225
|
+
}
|
|
3226
|
+
if (isHeldAccentKey) {
|
|
3227
|
+
return;
|
|
3228
|
+
}
|
|
3229
|
+
onKeyPress?.(button);
|
|
3230
|
+
}, [
|
|
3231
|
+
type,
|
|
3232
|
+
layoutName,
|
|
3233
|
+
capsLockOn,
|
|
3234
|
+
onKeyPress,
|
|
3235
|
+
Emoji,
|
|
3236
|
+
variant,
|
|
3237
|
+
closeAccentMenu,
|
|
3238
|
+
targetRef,
|
|
3239
|
+
]);
|
|
3240
|
+
const handleChange = useCallback((input) => {
|
|
3241
|
+
const currentValue = valueRef.current;
|
|
3242
|
+
const suppressedKey = suppressNextInputRef.current;
|
|
3243
|
+
const heldKey = heldAccentKeyRef.current;
|
|
3244
|
+
if (heldKey &&
|
|
3245
|
+
input.length >= currentValue.length + 1 &&
|
|
3246
|
+
input.startsWith(currentValue) &&
|
|
3247
|
+
input.slice(currentValue.length).split('').every((char) => char === heldKey)) {
|
|
3248
|
+
syncKeyboardInput(currentValue);
|
|
3249
|
+
return;
|
|
3250
|
+
}
|
|
3251
|
+
if (suppressedKey &&
|
|
3252
|
+
input.length === currentValue.length + 1 &&
|
|
3253
|
+
input.endsWith(suppressedKey)) {
|
|
3254
|
+
suppressNextInputRef.current = null;
|
|
3255
|
+
syncKeyboardInput(currentValue);
|
|
3256
|
+
return;
|
|
3257
|
+
}
|
|
3258
|
+
if (maxLength !== undefined && input.length > maxLength)
|
|
3259
|
+
return;
|
|
3260
|
+
onChange?.(input);
|
|
3261
|
+
}, [maxLength, onChange, syncKeyboardInput]);
|
|
3262
|
+
const portalSizes = useMemo(() => {
|
|
3263
|
+
if (containerWidth <= 360)
|
|
3264
|
+
return { preview: 42, option: 44, fontSize: 'var(--font-size-16)' };
|
|
3265
|
+
if (containerWidth <= 390)
|
|
3266
|
+
return { preview: 44, option: 44, fontSize: 'var(--font-size-18)' };
|
|
3267
|
+
if (containerWidth <= 480)
|
|
3268
|
+
return { preview: 46, option: 46, fontSize: 'var(--font-size-20)' };
|
|
3269
|
+
if (containerWidth <= 768)
|
|
3270
|
+
return { preview: 48, option: 48, fontSize: undefined };
|
|
3271
|
+
return { preview: 50, option: 50, fontSize: undefined };
|
|
3272
|
+
}, [containerWidth]);
|
|
3273
|
+
const keyboardDisplay = useMemo(() => {
|
|
3274
|
+
const baseDisplay = LAYOUT_DISPLAY[visualType];
|
|
3275
|
+
if (!baseDisplay)
|
|
3276
|
+
return baseDisplay;
|
|
3277
|
+
if (variant !== 'fixed') {
|
|
3278
|
+
return baseDisplay;
|
|
3279
|
+
}
|
|
3280
|
+
return {
|
|
3281
|
+
...baseDisplay,
|
|
3282
|
+
'{bksp}': (baseDisplay['{bksp}'] ?? '').replace(/\s*Apagar$/, ''),
|
|
3283
|
+
};
|
|
3284
|
+
}, [visualType, variant]);
|
|
3285
|
+
const keyboardEl = activeLayout ? (jsxs("div", { ref: keyboardWrapperRef, className: styles$j.keyboardWrapper, onPointerDownCapture: handleLongPressStart, onPointerUpCapture: handleLongPressEnd, onPointerLeave: handleLongPressEnd, onPointerCancelCapture: handleLongPressEnd, children: [jsx(Keyboard, { keyboardRef: (instance) => {
|
|
3286
|
+
keyboardInstanceRef.current = instance;
|
|
3287
|
+
if (instance) {
|
|
3288
|
+
instance.setInput(valueRef.current);
|
|
3289
|
+
}
|
|
3290
|
+
}, layoutName: layoutName, layout: activeLayout, theme: 'hg-theme-default', display: keyboardDisplay, onChange: handleChange, onKeyPress: handleKeyPress, preventMouseDownDefault: true }), (() => {
|
|
3291
|
+
const shiftCount = { current: 0 };
|
|
3292
|
+
return iconSlots.map((slot) => {
|
|
3293
|
+
const key = slot.getAttribute('data-icon-key');
|
|
3294
|
+
const Icon = key ? ICON_KEY_MAP[key] : undefined;
|
|
3295
|
+
if (!Icon || !key)
|
|
3296
|
+
return null;
|
|
3297
|
+
if (key === 'shift') {
|
|
3298
|
+
const label = shiftCount.current === 0 ? 'left' : 'right';
|
|
3299
|
+
shiftCount.current += 1;
|
|
3300
|
+
return createPortal(createElement(Icon), slot, `icon-shift-${label}`);
|
|
3301
|
+
}
|
|
3302
|
+
return createPortal(createElement(Icon), slot, `icon-${key}`);
|
|
3303
|
+
});
|
|
3304
|
+
})(), keyPreview && typeof document !== 'undefined' && createPortal(jsx("div", { ref: keyPreviewRef, className: styles$j.keyPreview, style: {
|
|
3305
|
+
top: keyPreview.top,
|
|
3306
|
+
left: keyPreview.left + keyPreviewOffsetX,
|
|
3307
|
+
width: portalSizes.preview,
|
|
3308
|
+
height: portalSizes.preview,
|
|
3309
|
+
...(portalSizes.fontSize ? { fontSize: portalSizes.fontSize } : {}),
|
|
3310
|
+
}, "aria-hidden": true, children: keyPreview.char }), document.body), accentMenu && (typeof document !== 'undefined' &&
|
|
3311
|
+
createPortal(jsx("div", { ref: accentMenuRef, className: styles$j.accentMenu, style: {
|
|
3312
|
+
top: accentMenu.top,
|
|
3313
|
+
left: accentMenu.left + accentMenuOffsetX,
|
|
3314
|
+
}, role: "listbox", "aria-label": `Opcoes de acento para ${accentMenu.sourceKey}`, children: Array.from({ length: Math.ceil(accentMenu.options.length / 5) }, (_, rowIndex) => accentMenu.options.slice(rowIndex * 5, rowIndex * 5 + 5)).map((rowOptions, rowIndex) => (jsx("div", { className: styles$j.accentMenuRow, children: rowOptions.map((option) => (jsx("button", { type: "button", className: styles$j.accentOption, style: {
|
|
3315
|
+
minWidth: portalSizes.option,
|
|
3316
|
+
height: portalSizes.option,
|
|
3317
|
+
...(portalSizes.fontSize ? { fontSize: portalSizes.fontSize } : {}),
|
|
3318
|
+
}, onPointerDown: (event) => {
|
|
3319
|
+
event.preventDefault();
|
|
3320
|
+
event.stopPropagation();
|
|
3321
|
+
}, onClick: () => handleAccentSelect(option), children: option }, `${accentMenu.sourceKey}-${option}`))) }, rowIndex))) }), document.body))] })) : null;
|
|
3322
|
+
if (variant === 'native' && typeof document !== 'undefined') {
|
|
3323
|
+
return createPortal(jsx("div", { id: id, className: clsx(styles$j.overlay, { [styles$j.overlayOpen]: isOpen }, styles$j[`layout--${visualType}`], className), children: keyboardEl }), document.body);
|
|
3324
|
+
}
|
|
3325
|
+
return (jsxs("div", { id: id, className: clsx(styles$j.container, styles$j[`mode--${variant}`], styles$j[`layout--${visualType}`], className), children: [variant === 'fixed' && (jsx("div", { className: styles$j.textFieldContainer, children: jsx(TextField$1, { placeholder: textFieldPlaceholder, value: value, onChange: onChange, helperText: helperText, error: error, errorMessage: errorMessage, readOnly: true, disableAutoComplete: true, maxLength: maxLength, attachedToVirtualKeyboard: true, className: styles$j.textFieldWrapper }) })), keyboardEl] }));
|
|
2603
3326
|
};
|
|
2604
3327
|
|
|
2605
|
-
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"};
|
|
3328
|
+
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"};
|
|
2606
3329
|
|
|
2607
3330
|
const validateInput = ({ value, maxLength, errorMessage, required }) => {
|
|
2608
3331
|
if (required && value.trim() === '') {
|
|
@@ -2625,19 +3348,19 @@ const LabelComponent = ({ children, htmlFor, required = false, tooltip = false,
|
|
|
2625
3348
|
return container;
|
|
2626
3349
|
};
|
|
2627
3350
|
|
|
2628
|
-
const TextField = forwardRef(({ className, value, label, placeholder, type = 'text', onChange, disabled = false, maxLength
|
|
3351
|
+
const TextField = forwardRef(({ className, value, label, placeholder, type = 'text', onChange, disabled = false, maxLength, required = false, helperText, tooltip = false, tooltipText, tooltipSide = 'bottom', tooltipAlign = 'start', errorMessage, error, id, icon, scale = 1, onBlur, onFocus, name, persistIcon = false, virtualKeyboard, attachedToVirtualKeyboard, disableAutoComplete = false, ...rest }, ref) => {
|
|
2629
3352
|
const normalizeValue = (val) => {
|
|
2630
3353
|
return val === undefined || val === null ? '' : String(val);
|
|
2631
3354
|
};
|
|
2632
3355
|
const [inputValue, setInputValue] = useState(normalizeValue(value));
|
|
2633
3356
|
const [inputError, setInputError] = useState('');
|
|
2634
3357
|
const [isFocused, setIsFocused] = useState(false);
|
|
3358
|
+
const { internalRef: inputRef, setRefs: setInputRefs } = useInputKeyboardValue(ref);
|
|
2635
3359
|
const generatedId = useId();
|
|
2636
3360
|
const componentId = id || generatedId;
|
|
2637
3361
|
useEffect(() => {
|
|
2638
3362
|
const newValue = normalizeValue(value);
|
|
2639
3363
|
setInputValue(newValue);
|
|
2640
|
-
// Reavaliar erro quando valor muda externamente (ex: DatePicker atualiza o campo)
|
|
2641
3364
|
if (inputError) {
|
|
2642
3365
|
const validationError = validateInput({
|
|
2643
3366
|
value: newValue,
|
|
@@ -2685,17 +3408,29 @@ const TextField = forwardRef(({ className, value, label, placeholder, type = 'te
|
|
|
2685
3408
|
: helperText
|
|
2686
3409
|
? `${componentId}-helper`
|
|
2687
3410
|
: undefined;
|
|
2688
|
-
const
|
|
3411
|
+
const scaleClass = {
|
|
3412
|
+
1: 'scale-1-0',
|
|
3413
|
+
1.5: 'scale-1-5',
|
|
3414
|
+
2: 'scale-2-0',
|
|
3415
|
+
}[scale];
|
|
3416
|
+
const containerClass = clsx(styles$i.container, scaleClass, {
|
|
2689
3417
|
[styles$i.disabled]: disabled,
|
|
2690
3418
|
[styles$i.error]: hasError && !disabled,
|
|
3419
|
+
[styles$i.errorWithMessage]: Boolean(error) && Boolean(errorMessage) && !disabled,
|
|
3420
|
+
[styles$i.attachedToVirtualKeyboard]: attachedToVirtualKeyboard,
|
|
2691
3421
|
[className]: className,
|
|
2692
3422
|
});
|
|
2693
|
-
return (jsxs("div", { className: containerClass, children: [label && (jsx(LabelComponent, { htmlFor: componentId, required: required, tooltip: tooltip, tooltipText: tooltipText, side:
|
|
3423
|
+
return (jsxs("div", { className: containerClass, children: [label && (jsx(LabelComponent, { htmlFor: componentId, required: required, tooltip: tooltip, tooltipText: tooltipText, side: tooltipSide, align: tooltipAlign, error: hasError, disabled: disabled, children: label })), jsxs("div", { className: styles$i.inputWrapper, children: [jsxs("div", { className: styles$i.inputContainer, children: [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 === 'default' || virtualKeyboard === 'numeric') ? 'none' : rest.inputMode, autoComplete: (disableAutoComplete || virtualKeyboard === 'default' || virtualKeyboard === 'numeric') ? 'off' : rest.autoComplete, className: clsx({
|
|
2694
3424
|
[styles$i.inputWithIcon]: showCustomIcon || showClearIcon,
|
|
2695
3425
|
}) }), showCustomIcon && jsx("span", { className: styles$i.icon, children: icon }), showClearIcon && (jsx("button", { type: "button", className: styles$i.clearButton, onMouseDown: (e) => {
|
|
2696
3426
|
e.preventDefault();
|
|
2697
3427
|
handleClear();
|
|
2698
|
-
}, "aria-label": "Limpar campo", tabIndex: -1, children: jsx(Dismiss16Regular, {}) }))] }), jsx("span", { id: helperId, className: styles$i.helperText, "aria-live": hasError ? 'polite' : undefined, children: displayHelperText })] })
|
|
3428
|
+
}, "aria-label": "Limpar campo", tabIndex: -1, children: jsx(Dismiss16Regular, {}) }))] }), ((error && errorMessage) || inputError || helperText) && (jsx("span", { id: helperId, className: styles$i.helperText, "aria-live": hasError ? 'polite' : undefined, children: displayHelperText }))] }), (virtualKeyboard === 'default' || virtualKeyboard === 'numeric') && (jsx("div", { className: "virtualKeyboardWrapper", children: jsx(VirtualKeyboard, { variant: "native", type: virtualKeyboard, value: inputValue, maxLength: maxLength, targetRef: inputRef, onChange: (val) => {
|
|
3429
|
+
if (!disabled && (!maxLength || val.length <= maxLength)) {
|
|
3430
|
+
setInputValue(val);
|
|
3431
|
+
onChange?.(val);
|
|
3432
|
+
}
|
|
3433
|
+
} }) }))] }));
|
|
2699
3434
|
});
|
|
2700
3435
|
TextField.displayName = 'TextField';
|
|
2701
3436
|
var TextField$1 = React__default.memo(TextField);
|
|
@@ -2792,7 +3527,7 @@ function validatePartialDate(value, locale = 'pt-br') {
|
|
|
2792
3527
|
return 'incomplete';
|
|
2793
3528
|
}
|
|
2794
3529
|
|
|
2795
|
-
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 }) => {
|
|
3530
|
+
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 }) => {
|
|
2796
3531
|
const fieldId = useId();
|
|
2797
3532
|
const calendarId = `${fieldId}-calendar`;
|
|
2798
3533
|
const isControlled = value !== undefined;
|
|
@@ -2809,6 +3544,11 @@ const DatePicker = ({ locale = 'pt-br', calendarSide = 'bottom', calendarAlign =
|
|
|
2809
3544
|
const combinedHelperText = externalError && helperText
|
|
2810
3545
|
? `${helperText} • ${externalError}`
|
|
2811
3546
|
: externalError || helperText || '';
|
|
3547
|
+
const scaleClass = {
|
|
3548
|
+
1: 'scale-1-0',
|
|
3549
|
+
1.5: 'scale-1-5',
|
|
3550
|
+
2: 'scale-2-0',
|
|
3551
|
+
}[datePickerScale];
|
|
2812
3552
|
useEffect(() => {
|
|
2813
3553
|
function handleClickOutside(event) {
|
|
2814
3554
|
const target = event.target;
|
|
@@ -2921,9 +3661,9 @@ const DatePicker = ({ locale = 'pt-br', calendarSide = 'bottom', calendarAlign =
|
|
|
2921
3661
|
}
|
|
2922
3662
|
}
|
|
2923
3663
|
};
|
|
2924
|
-
return (jsx("div", { ref: wrapperRef, className: clsx(styles$g.datePicker, className), ...rest, children: jsx(Popover, { open: showCalendar, onOpenChange: setShowCalendar, asAnchor: true, trigger: jsx(TextField$1, { className: styles$g.textfieldContainer, type: "tel", icon: jsx(Calendar16Regular, { onClick: !disabled ? handleIconClick : undefined, className: clsx(styles$g.datePickerIcon, disabled && styles$g.datePickerIconDisabled) }), onChange: (e) => {
|
|
3664
|
+
return (jsx("div", { ref: wrapperRef, className: clsx(styles$g.datePicker, scaleClass, className), ...rest, children: jsx(Popover, { open: showCalendar, onOpenChange: setShowCalendar, asAnchor: true, trigger: jsx(TextField$1, { className: styles$g.textfieldContainer, type: "tel", icon: jsx(Calendar16Regular, { onClick: !disabled ? handleIconClick : undefined, className: clsx(styles$g.datePickerIcon, disabled && styles$g.datePickerIconDisabled) }), onChange: (e) => {
|
|
2925
3665
|
handleTextFieldChange(String(e));
|
|
2926
|
-
}, 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: 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: () => {
|
|
3666
|
+
}, 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: 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: () => {
|
|
2927
3667
|
handleDateChange(null);
|
|
2928
3668
|
setCurrentDate(new Date());
|
|
2929
3669
|
} }), side: calendarSide, align: calendarAlign, sideOffset: 8 }) }));
|
|
@@ -3017,12 +3757,18 @@ const Combined = ({ buttonText = 'Filtrar', icon, variant = 'outlined', disabled
|
|
|
3017
3757
|
|
|
3018
3758
|
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"};
|
|
3019
3759
|
|
|
3020
|
-
const Search = React__default.forwardRef(({ placeholder = 'Dica do que deve ser buscado', disabled = false, value, onChange, onKeyDown, onFocus, onBlur, onClear, onClick, onMouseDown, searchMode = 'instant', onSearch, id, className, 'data-testid': testId, ...rest }, ref) => {
|
|
3760
|
+
const Search = React__default.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, 'data-testid': testId, ...rest }, ref) => {
|
|
3021
3761
|
const [internalValue, setInternalValue] = useState('');
|
|
3762
|
+
const { internalRef: inputRef, setRefs: setInputRefs } = useInputKeyboardValue(ref);
|
|
3022
3763
|
const isControlled = value !== undefined && onChange !== undefined;
|
|
3023
3764
|
const currentValue = isControlled ? value : internalValue;
|
|
3024
3765
|
const generatedId = useId();
|
|
3025
3766
|
const inputId = id || generatedId;
|
|
3767
|
+
const scaleClass = {
|
|
3768
|
+
1: 'scale-1-0',
|
|
3769
|
+
1.5: 'scale-1-5',
|
|
3770
|
+
2: 'scale-2-0',
|
|
3771
|
+
}[scale];
|
|
3026
3772
|
const handleChange = (e) => {
|
|
3027
3773
|
if (disabled)
|
|
3028
3774
|
return;
|
|
@@ -3069,12 +3815,25 @@ const Search = React__default.forwardRef(({ placeholder = 'Dica do que deve ser
|
|
|
3069
3815
|
}
|
|
3070
3816
|
onKeyDown?.(e);
|
|
3071
3817
|
};
|
|
3072
|
-
return (jsxs("div", { className: clsx(styles$c.search, { [styles$c.disabled]: disabled }, className), onClick: onClick, onMouseDown: onMouseDown, role: onClick || onMouseDown ? "button" : undefined, tabIndex: onClick || onMouseDown ? 0 : undefined, onKeyDown: onClick || onMouseDown ? (e) => {
|
|
3818
|
+
return (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) => {
|
|
3073
3819
|
if (e.key === 'Enter' || e.key === ' ') {
|
|
3074
3820
|
e.preventDefault();
|
|
3075
3821
|
onClick?.(e);
|
|
3076
3822
|
}
|
|
3077
|
-
} : undefined, children: [jsx("span", { className: clsx(styles$c.searchLeftIcon, { [styles$c.disabled]: disabled }), tabIndex: -1, role: "presentation", "aria-hidden": "true", children: jsx(Search16Regular, {}) }), jsx("input", { ref:
|
|
3823
|
+
} : undefined, children: [jsx("span", { className: clsx(styles$c.searchLeftIcon, { [styles$c.disabled]: disabled }), tabIndex: -1, role: "presentation", "aria-hidden": "true", children: jsx(Search16Regular, {}) }), 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 === 'default' || virtualKeyboard === 'numeric') ? 'none' : rest.inputMode, className: clsx({ [styles$c.inputWithClearIcon]: currentValue && currentValue.length > 0 }) }), currentValue && currentValue.length > 0 && (jsx("span", { className: styles$c.searchClearIcon, "aria-hidden": "true", onClick: clearInputSearch, children: jsx(Dismiss16Regular, {}) })), (virtualKeyboard === 'default' || virtualKeyboard === 'numeric') && (jsx("div", { className: "virtualKeyboardWrapper", children: jsx(VirtualKeyboard, { variant: "native", type: virtualKeyboard, value: currentValue || '', targetRef: inputRef, onChange: (val) => {
|
|
3824
|
+
if (disabled)
|
|
3825
|
+
return;
|
|
3826
|
+
if (isControlled) {
|
|
3827
|
+
const syntheticEvent = {
|
|
3828
|
+
target: { value: val },
|
|
3829
|
+
currentTarget: { value: val },
|
|
3830
|
+
};
|
|
3831
|
+
onChange?.(syntheticEvent);
|
|
3832
|
+
}
|
|
3833
|
+
else {
|
|
3834
|
+
setInternalValue(val);
|
|
3835
|
+
}
|
|
3836
|
+
} }) }))] }));
|
|
3078
3837
|
});
|
|
3079
3838
|
Search.displayName = 'Search';
|
|
3080
3839
|
|
|
@@ -3198,9 +3957,15 @@ var styles$b = {"zds-list-item__container":"ListItem-module__zds-list-item__cont
|
|
|
3198
3957
|
|
|
3199
3958
|
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"};
|
|
3200
3959
|
|
|
3201
|
-
const Radio = ({ items, onValueChange, defaultValue, name, id, ariaLabel, orientation = 'vertical', className, ...rest }) => {
|
|
3202
|
-
const
|
|
3203
|
-
|
|
3960
|
+
const Radio = ({ items, onValueChange, defaultValue, name, id, ariaLabel, orientation = 'vertical', scale = 1, className, ...rest }) => {
|
|
3961
|
+
const generatedId = useId();
|
|
3962
|
+
const componentId = id || generatedId;
|
|
3963
|
+
const scaleClass = {
|
|
3964
|
+
1: 'scale-1-0',
|
|
3965
|
+
1.5: 'scale-1-5',
|
|
3966
|
+
2: 'scale-2-0',
|
|
3967
|
+
}[scale];
|
|
3968
|
+
return (jsx(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 }) => {
|
|
3204
3969
|
const itemKey = id ?? value;
|
|
3205
3970
|
const uniqueId = `${componentId}-item-${value}`;
|
|
3206
3971
|
return (jsx("div", { className: clsx(styles$a.wrapper, { [styles$a.disabled]: disabled }), children: jsxs("label", { className: styles$a.labelWrapper, htmlFor: uniqueId, children: [jsx("div", { className: styles$a.itemWrapper, children: jsx(RadioGroup.Item, { disabled: disabled, className: styles$a.item, value: value, id: uniqueId, "data-disabled": disabled, children: jsx(RadioGroup.Indicator, { className: styles$a.indicator }) }) }), jsx("span", { className: styles$a.labelText, children: label })] }) }, itemKey));
|
|
@@ -3421,7 +4186,7 @@ const useSearchLogic = ({ items, searchValue, searchTerm, enableApiSearch, onApi
|
|
|
3421
4186
|
return { filteredItems: filteredItems() };
|
|
3422
4187
|
};
|
|
3423
4188
|
|
|
3424
|
-
const Menu = ({ items, children, onItemSelect, search, enableInfiniteScroll, onScrollEnd, isLoadingMore, onApiSearch, enableApiSearch, selectedItems, onOpenChange, align = 'start', className, maxHeight = 400, ...rest }) => {
|
|
4189
|
+
const Menu = ({ items, children, onItemSelect, search, enableInfiniteScroll, onScrollEnd, isLoadingMore, onApiSearch, enableApiSearch, selectedItems, onOpenChange, align = 'start', dropdownScale = 1, buttonScale, className, maxHeight = 400, ...rest }) => {
|
|
3425
4190
|
const itemsWrapperRef = useRef(null);
|
|
3426
4191
|
const hasReachedEndRef = useRef(false);
|
|
3427
4192
|
const observerRef = useRef(null);
|
|
@@ -3431,6 +4196,16 @@ const Menu = ({ items, children, onItemSelect, search, enableInfiniteScroll, onS
|
|
|
3431
4196
|
const [searchInput, setSearchInput] = useState('');
|
|
3432
4197
|
const [searchTerm, setSearchTerm] = useState('');
|
|
3433
4198
|
const maxHeightStyle = typeof maxHeight === 'number' ? `${maxHeight}px` : maxHeight;
|
|
4199
|
+
const scaleClass = {
|
|
4200
|
+
1: 'scale-1-0',
|
|
4201
|
+
1.5: 'scale-1-5',
|
|
4202
|
+
2: 'scale-2-0',
|
|
4203
|
+
}[dropdownScale];
|
|
4204
|
+
const triggerWithScale = React__default.isValidElement(children) && buttonScale
|
|
4205
|
+
? React__default.cloneElement(children, {
|
|
4206
|
+
scale: children.props?.scale ?? buttonScale,
|
|
4207
|
+
})
|
|
4208
|
+
: children;
|
|
3434
4209
|
const { open, setOpen, handleItemSelect: handleItemSelectLogic, isItemSelected } = useMenuLogic({
|
|
3435
4210
|
selectedItems,
|
|
3436
4211
|
onItemSelect,
|
|
@@ -3533,7 +4308,7 @@ const Menu = ({ items, children, onItemSelect, search, enableInfiniteScroll, onS
|
|
|
3533
4308
|
hasReachedEndRef.current = false;
|
|
3534
4309
|
}
|
|
3535
4310
|
};
|
|
3536
|
-
return (jsxs(DropdownMenu.Root, { open: open, onOpenChange: handleOpenChange, children: [jsx(DropdownMenu.Trigger, { asChild: true, children:
|
|
4311
|
+
return (jsxs(DropdownMenu.Root, { open: open, onOpenChange: handleOpenChange, children: [jsx(DropdownMenu.Trigger, { asChild: true, children: triggerWithScale }), jsx(DropdownMenu.Portal, { children: jsxs(DropdownMenu.Content, { className: clsx(styles$9.content, scaleClass, className), sideOffset: 8, align: align, onPointerDown: () => { closedByPointerRef.current = true; }, onInteractOutside: () => { closedByPointerRef.current = true; }, onCloseAutoFocus: (e) => {
|
|
3537
4312
|
if (closedByPointerRef.current) {
|
|
3538
4313
|
e.preventDefault();
|
|
3539
4314
|
closedByPointerRef.current = false;
|
|
@@ -3565,7 +4340,7 @@ const Modal = ({ isOpen = false, onClose, title, children, headerContent, closeO
|
|
|
3565
4340
|
|
|
3566
4341
|
var styles$7 = {"quantity":"Quantity-module__quantity___-vndR","quantityInput":"Quantity-module__quantityInput___xZG-v","disabled":"Quantity-module__disabled___X6p5l"};
|
|
3567
4342
|
|
|
3568
|
-
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 }) => {
|
|
4343
|
+
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 }) => {
|
|
3569
4344
|
const initialValue = Math.min(Math.max(value, minValue), maxValue);
|
|
3570
4345
|
const [internalValue, setInternalValue] = useState(initialValue);
|
|
3571
4346
|
const [inputValue, setInputValue] = useState(decimal ? initialValue.toFixed(decimalPlaces) : String(initialValue));
|
|
@@ -3744,7 +4519,12 @@ const Quantity = ({ value = 0, onChange, disabled = false, decimal = false, deci
|
|
|
3744
4519
|
const inputSizeValue = inputSize !== undefined ? inputSize : Math.max(1, inputValue.length);
|
|
3745
4520
|
const uniqueId = useId();
|
|
3746
4521
|
const inputId = id || uniqueId;
|
|
3747
|
-
|
|
4522
|
+
const scaleClass = {
|
|
4523
|
+
1: 'scale-1-0',
|
|
4524
|
+
1.5: 'scale-1-5',
|
|
4525
|
+
2: 'scale-2-0',
|
|
4526
|
+
}[scale];
|
|
4527
|
+
return (jsxs("div", { className: clsx(styles$7.quantity, scaleClass, { [styles$7.disabled]: disabled }, className), ...rest, children: [jsx(Button, { variant: 'outlined', size: size, type: 'button', iconOnly: true, icon: jsx(Subtract16Regular, {}), onClick: decrement, disabled: disabled || isMinValue, "aria-label": decrementAriaLabel, tooltipText: 'Diminuir' }), 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 }), jsx(Button, { variant: 'outlined', size: size, type: 'button', iconOnly: true, onClick: increment, disabled: disabled || isMaxValue, "aria-label": incrementAriaLabel, icon: jsx(Add16Regular, {}), tooltipText: 'Aumentar' })] }));
|
|
3748
4528
|
};
|
|
3749
4529
|
const memorizedQuantity = React__default.memo(Quantity);
|
|
3750
4530
|
memorizedQuantity.displayName = 'Quantity';
|
|
@@ -4058,7 +4838,7 @@ function useSelectLogic({ value, required = false, search = false, onValueChange
|
|
|
4058
4838
|
};
|
|
4059
4839
|
}
|
|
4060
4840
|
|
|
4061
|
-
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 }) => {
|
|
4841
|
+
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 }) => {
|
|
4062
4842
|
const componentId = useId();
|
|
4063
4843
|
const selectId = `select-${componentId}`;
|
|
4064
4844
|
const viewportRef = useRef(null);
|
|
@@ -4106,6 +4886,11 @@ const Select = ({ items, onValueChange, onOpenChange, variant, required = false,
|
|
|
4106
4886
|
const containerStyle = useMemo(() => ({
|
|
4107
4887
|
maxWidth: maxWidth ? `${maxWidth}px` : undefined,
|
|
4108
4888
|
}), [maxWidth]);
|
|
4889
|
+
const scaleClass = {
|
|
4890
|
+
1: 'scale-1-0',
|
|
4891
|
+
1.5: 'scale-1-5',
|
|
4892
|
+
2: 'scale-2-0',
|
|
4893
|
+
}[scale];
|
|
4109
4894
|
const handleSearchChange = (e) => {
|
|
4110
4895
|
const value = e.target.value;
|
|
4111
4896
|
actions.setSearchInput(value);
|
|
@@ -4138,7 +4923,7 @@ const Select = ({ items, onValueChange, onOpenChange, variant, required = false,
|
|
|
4138
4923
|
onApiSearch('');
|
|
4139
4924
|
}
|
|
4140
4925
|
};
|
|
4141
|
-
return (jsx(Select$1.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: jsxs("div", { className: clsx(styles$6.container, className), style: containerStyle, "data-testid": testId, children: [jsx("div", { className: styles$6.fieldContainer, children: jsxs("div", { className: styles$6.containerLabel, children: [jsx(LabelComponent, { htmlFor: selectId, required: required, tooltipText: tooltipText, tooltip: tooltip, side: side, align: align, error: state.hasError && state.touched, disabled: disabled, children: label }), jsxs(Select$1.Trigger, { className: clsx(styles$6.trigger, {
|
|
4926
|
+
return (jsx(Select$1.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: jsxs("div", { className: clsx(styles$6.container, scaleClass, className), style: containerStyle, "data-testid": testId, children: [jsx("div", { className: styles$6.fieldContainer, children: jsxs("div", { className: styles$6.containerLabel, children: [jsx(LabelComponent, { htmlFor: selectId, required: required, tooltipText: tooltipText, tooltip: tooltip, side: side, align: align, error: state.hasError && state.touched, disabled: disabled, children: label }), jsxs(Select$1.Trigger, { className: clsx(styles$6.trigger, {
|
|
4142
4927
|
[styles$6.error]: state.hasError && state.touched,
|
|
4143
4928
|
[styles$6.disabled]: disabled,
|
|
4144
4929
|
[styles$6.hasValue]: state.selectedValues.length > 0,
|
|
@@ -4544,7 +5329,7 @@ const TableV2 = ({ columns, data, rowSelection: rowSelectionConfig, enableSortin
|
|
|
4544
5329
|
};
|
|
4545
5330
|
return (jsxs("div", { className: clsx(styles$4.wrapper, className), children: [showBulkActions && (jsxs("div", { className: styles$4.bulkActionsBar, children: [jsxs("div", { className: styles$4.bulkActionsInfo, children: [jsx(Button, { variant: "text", iconOnly: true, icon: jsx(Dismiss16Regular, {}), ariaLabel: "Limpar sele\u00E7\u00E3o", onClick: handleClearSelection, className: styles$4.bulkActionsClearButton }), jsx("span", { className: styles$4.bulkActionsLabel, children: bulkActions.label
|
|
4546
5331
|
? bulkActions.label(selectedCount, selectedRows)
|
|
4547
|
-
: `${selectedCount} ${selectedCount === 1 ? 'item selecionado' : 'itens selecionados'}` })] }), jsx("div", { className: styles$4.bulkActionsButtons, children: bulkActions.actions.map((action, index) => (jsx(Button, { variant: action.variant ?? 'outlined', type: "button", disabled: action.disabled, onClick: action.onClick, size: "sm", children: action.label }, index))) })] })), header && (jsxs("div", { className: styles$4.tableHeader, children: [showSearch && (jsx("div", { className: styles$4.tableHeaderSearchContainer, children: jsx(Search, { value: pendingSearch, searchMode: header?.searchMode ?? "on-enter", onChange: (e) => {
|
|
5332
|
+
: `${selectedCount} ${selectedCount === 1 ? 'item selecionado' : 'itens selecionados'}` })] }), jsx("div", { className: styles$4.bulkActionsButtons, children: bulkActions.actions.map((action, index) => (jsx(Button, { variant: action.variant ?? 'outlined', type: "button", disabled: action.disabled, onClick: action.onClick, size: "sm", children: action.label }, index))) })] })), header && (jsxs("div", { className: styles$4.tableHeader, children: [showSearch && (jsx("div", { className: styles$4.tableHeaderSearchContainer, children: jsx(Search, { value: pendingSearch, virtualKeyboard: header.virtualKeyboard, searchMode: header?.searchMode ?? "on-enter", onChange: (e) => {
|
|
4548
5333
|
setPendingSearch(e.target.value);
|
|
4549
5334
|
}, onSearch: (val) => {
|
|
4550
5335
|
if (footer) {
|
|
@@ -4559,7 +5344,7 @@ const TableV2 = ({ columns, data, rowSelection: rowSelectionConfig, enableSortin
|
|
|
4559
5344
|
footer?.onPageChange?.(1);
|
|
4560
5345
|
}
|
|
4561
5346
|
header?.onSearchChange?.('');
|
|
4562
|
-
}, placeholder: header.searchPlaceholder ?? 'Pesquisar...', className: styles$4.tableHeaderSearch }) })), !!header.filterItems?.length && (jsxs("div", { className: styles$4.tableHeaderFilters, children: [jsx("span", { className: styles$4.tableHeaderFilterLabel, children: "Filtros" }), jsx("div", { className: styles$4.tableHeaderFilterItems, children: header.filterItems.map((filterItem, index) => {
|
|
5347
|
+
}, placeholder: header.searchPlaceholder ?? 'Pesquisar...', className: styles$4.tableHeaderSearch }) })), !!header.filterItems?.length && (jsxs("div", { className: styles$4.tableHeaderFilters, children: [header.filterItems.some((item) => item.type !== 'combined') && (jsx("span", { className: styles$4.tableHeaderFilterLabel, children: "Filtros" })), jsx("div", { className: styles$4.tableHeaderFilterItems, children: header.filterItems.map((filterItem, index) => {
|
|
4563
5348
|
const commonProps = {
|
|
4564
5349
|
buttonText: filterItem.buttonText,
|
|
4565
5350
|
icon: filterItem.icon,
|
|
@@ -4609,12 +5394,13 @@ const TableV2 = ({ columns, data, rowSelection: rowSelectionConfig, enableSortin
|
|
|
4609
5394
|
|
|
4610
5395
|
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"};
|
|
4611
5396
|
|
|
4612
|
-
const TextArea = 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) => {
|
|
5397
|
+
const TextArea = 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, ...rest }, ref) => {
|
|
4613
5398
|
const normalizeValue = (val) => {
|
|
4614
5399
|
return val === undefined || val === null ? '' : String(val);
|
|
4615
5400
|
};
|
|
4616
5401
|
const [textareaValue, setTextareaValue] = useState(normalizeValue(value));
|
|
4617
5402
|
const [textareaError, setTextareaError] = useState('');
|
|
5403
|
+
const { internalRef: textareaRef, setRefs: setTextareaRefs } = useInputKeyboardValue(ref);
|
|
4618
5404
|
const generatedId = useId();
|
|
4619
5405
|
const componentId = id || generatedId;
|
|
4620
5406
|
useEffect(() => {
|
|
@@ -4647,7 +5433,12 @@ const TextArea = forwardRef(({ className, value, label, placeholder, onChange, d
|
|
|
4647
5433
|
? `${componentId}-helper`
|
|
4648
5434
|
: undefined;
|
|
4649
5435
|
const containerClass = clsx(styles$3.container, disabled && styles$3.disabled, hasError && !disabled && styles$3.error, className);
|
|
4650
|
-
return (jsxs("div", { className: containerClass, children: [label && (jsx(LabelComponent, { htmlFor: componentId, required: required, tooltip: tooltip, tooltipText: tooltipText, side: side, align: align, error: hasError, disabled: disabled, children: label })), jsxs("div", { className: styles$3.inputWrapper, children: [jsx("div", { className: styles$3.inputContainer, children: jsx("textarea", { ...rest, ref:
|
|
5436
|
+
return (jsxs("div", { className: containerClass, children: [label && (jsx(LabelComponent, { htmlFor: componentId, required: required, tooltip: tooltip, tooltipText: tooltipText, side: side, align: align, error: hasError, disabled: disabled, children: label })), jsxs("div", { className: styles$3.inputWrapper, children: [jsx("div", { className: styles$3.inputContainer, children: 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 === 'default' || virtualKeyboard === 'numeric') ? 'none' : rest.inputMode }) }), jsxs("div", { className: styles$3.footer, children: [jsx("span", { id: helperId, className: styles$3.helperText, "aria-live": hasError ? 'polite' : undefined, children: displayHelperText }), showCharCount && maxLength && (jsxs("span", { className: styles$3.charCount, children: [textareaValue.length, "/", maxLength] }))] })] }), (virtualKeyboard === 'default' || virtualKeyboard === 'numeric') && (jsx("div", { className: "virtualKeyboardWrapper", children: jsx(VirtualKeyboard, { variant: "native", type: virtualKeyboard, maxLength: maxLength, value: textareaValue, targetRef: textareaRef, onChange: (val) => {
|
|
5437
|
+
if (!disabled && (!maxLength || val.length <= maxLength)) {
|
|
5438
|
+
setTextareaValue(val);
|
|
5439
|
+
onChange?.(val);
|
|
5440
|
+
}
|
|
5441
|
+
} }) }))] }));
|
|
4651
5442
|
});
|
|
4652
5443
|
TextArea.displayName = 'TextArea';
|
|
4653
5444
|
var TextArea_default = React__default.memo(TextArea);
|
|
@@ -4860,7 +5651,14 @@ ToastContainer.displayName = 'ToastContainer';
|
|
|
4860
5651
|
|
|
4861
5652
|
var styles$1 = {"container":"Switch-module__container___BR1OB","switchRoot":"Switch-module__switchRoot___jz2HD","switchThumb":"Switch-module__switchThumb___X3RL7"};
|
|
4862
5653
|
|
|
4863
|
-
const Switch = ({ disabled = false, defaultChecked = false, checked, onCheckedChange,
|
|
5654
|
+
const Switch = ({ disabled = false, defaultChecked = false, checked, onCheckedChange, scale = 1, className, ...rest }) => {
|
|
5655
|
+
const scaleClass = {
|
|
5656
|
+
1: 'scale-1-0',
|
|
5657
|
+
1.5: 'scale-1-5',
|
|
5658
|
+
2: 'scale-2-0',
|
|
5659
|
+
}[scale];
|
|
5660
|
+
return (jsx("div", { className: clsx(styles$1.container, scaleClass, className), children: jsx(Switch$1.Root, { className: styles$1.switchRoot, disabled: disabled, defaultChecked: defaultChecked, checked: checked, onCheckedChange: onCheckedChange, ...rest, children: jsx(Switch$1.Thumb, { className: styles$1.switchThumb }) }) }));
|
|
5661
|
+
};
|
|
4864
5662
|
|
|
4865
5663
|
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"};
|
|
4866
5664
|
|
|
@@ -5276,5 +6074,5 @@ function useInfiniteScroll({ status, page, lastPage, onLoadMore, threshold = 0.1
|
|
|
5276
6074
|
};
|
|
5277
6075
|
}
|
|
5278
6076
|
|
|
5279
|
-
export { Avatar, Badge, Button, Calendar, Callout, Checkbox, MemoizedChips as Chips, Container, DatePicker_default as DatePicker, Dialog, Drawer, Filter, ListItem, Menu, Modal, Popover, memorizedQuantity as Quantity, Radio, Search, Select, Switch, Table, TableHeader, TablePagination, TableV2, TextArea_default as TextArea, TextField$1 as TextField, Toast, ToastContainer, ToastProvider, Tooltip, VerificationCode, normalizeText, useApiSimulation, useInfiniteScroll, useToast };
|
|
6077
|
+
export { Avatar, Badge, Button, Calendar, Callout, Card, Checkbox, MemoizedChips as Chips, Container, DatePicker_default as DatePicker, Dialog, Drawer, Filter, ListItem, Menu, Modal, Popover, memorizedQuantity as Quantity, Radio, Search, Select, Switch, Table, TableHeader, TablePagination, TableV2, TextArea_default as TextArea, TextField$1 as TextField, Toast, ToastContainer, ToastProvider, Tooltip, VerificationCode, VirtualKeyboard, normalizeText, useApiSimulation, useInfiniteScroll, useToast };
|
|
5280
6078
|
//# sourceMappingURL=index.esm.js.map
|