@giro-ds/react 12.1.1 → 12.3.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 +195 -68
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +17 -10
- package/dist/index.esm.js +163 -69
- package/dist/index.esm.js.map +1 -1
- package/dist/styles.css +2 -2
- package/package.json +4 -3
package/dist/index.esm.js
CHANGED
|
@@ -2,8 +2,8 @@ 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, DropdownMenu, Dialog as Dialog$1, RadioGroup, Select as Select$1, Toggle as Toggle$1, ToggleGroup as ToggleGroup$1, Toast as Toast$1, Switch as Switch$1, unstable_OneTimePasswordField } from 'radix-ui';
|
|
4
4
|
import * as React from 'react';
|
|
5
|
-
import React__default, { useId, useMemo, createContext, useState, useContext, useRef, useCallback, useEffect, useLayoutEffect, createElement,
|
|
6
|
-
import { SpinnerIos16Regular, ChevronUp16Regular, ChevronLeft16Regular, ChevronRight16Regular, ChevronDown16Regular, Dismiss24Regular, Emoji20Regular, ChevronDown20Regular, KeyboardShiftUppercase20Regular, KeyboardShift20Filled, KeyboardShift20Regular, Backspace20Regular, Info12Regular, Dismiss16Regular, Calendar16Regular, DocumentAdd24Regular, Warning24Regular, Document24Regular, FilterRegular, Search16Regular, ChevronDownRegular, ChevronRight16Filled, Subtract16Regular, Add16Regular, SearchInfo20Regular, ArrowSortUp16Regular, ArrowSortDown16Regular, ArrowSort16Regular, Info20Filled, CheckmarkCircle20Filled, Warning20Filled, Dismiss16Filled } from '@fluentui/react-icons';
|
|
5
|
+
import React__default, { useId, version, forwardRef as forwardRef$1, useMemo, createContext, useState, useContext, useRef, useCallback, useEffect, useLayoutEffect, createElement, memo, useReducer } from 'react';
|
|
6
|
+
import { SpinnerIos16Regular, ChevronUp16Regular, ChevronLeft16Regular, ChevronRight16Regular, ChevronDown16Regular, Dismiss24Regular, Spacebar20Regular, ArrowImport20Regular, Emoji20Regular, ChevronDown20Regular, KeyboardShiftUppercase20Regular, KeyboardShift20Filled, KeyboardShift20Regular, Backspace20Regular, Info12Regular, Dismiss16Regular, Calendar16Regular, DocumentAdd24Regular, Warning24Regular, Document24Regular, 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';
|
|
@@ -57,6 +57,39 @@ const Badge = ({ children, badgeValue = null, className, id, filterVariant = fal
|
|
|
57
57
|
}, className), "data-testid": "badge", children: !isEmpty && (jsx("span", { "aria-hidden": !!ariaLabel, children: displayValue })) }) }));
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
+
const REACT_MAJOR = parseInt(version.split('.')[0], 10);
|
|
61
|
+
/**
|
|
62
|
+
* Shim de compatibilidade para `React.forwardRef` que funciona tanto no React 18
|
|
63
|
+
* quanto no React 19.
|
|
64
|
+
*
|
|
65
|
+
* - React 18: `ref` não é uma prop comum — usa `React.forwardRef` internamente.
|
|
66
|
+
* - React 19: `ref` é uma prop normal e `forwardRef` foi depreciado. Este shim
|
|
67
|
+
* cria um componente funcional comum que lê `ref` das props diretamente,
|
|
68
|
+
* evitando o aviso de depreciação.
|
|
69
|
+
*
|
|
70
|
+
* O padrão de autoria dos componentes permanece idêntico para ambas as versões.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* const MyInput = forwardRef<HTMLInputElement, MyInputProps>((props, ref) => {
|
|
74
|
+
* return <input ref={ref} {...props} />;
|
|
75
|
+
* });
|
|
76
|
+
*/
|
|
77
|
+
function forwardRef(render) {
|
|
78
|
+
if (REACT_MAJOR >= 19) {
|
|
79
|
+
const Comp = (props) => {
|
|
80
|
+
const { ref, ...rest } = props;
|
|
81
|
+
return render(rest, ref ?? null);
|
|
82
|
+
};
|
|
83
|
+
const displayName = render.displayName ?? render.name;
|
|
84
|
+
if (displayName) {
|
|
85
|
+
Comp.displayName = displayName;
|
|
86
|
+
}
|
|
87
|
+
return Comp;
|
|
88
|
+
}
|
|
89
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
90
|
+
return forwardRef$1(render);
|
|
91
|
+
}
|
|
92
|
+
|
|
60
93
|
var styles$t = {"tooltipContent":"Tooltip-module__tooltipContent___xycUg","triggerWrapper":"Tooltip-module__triggerWrapper___x83XR"};
|
|
61
94
|
|
|
62
95
|
const Tooltip = ({ children, text, side = 'bottom', align = 'start', maxWidth, sideOffset = 10, className, ...rest }) => {
|
|
@@ -65,7 +98,7 @@ const Tooltip = ({ children, text, side = 'bottom', align = 'start', maxWidth, s
|
|
|
65
98
|
|
|
66
99
|
var styles$s = {"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"};
|
|
67
100
|
|
|
68
|
-
const Button =
|
|
101
|
+
const Button = 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) => {
|
|
69
102
|
const generatedId = useId();
|
|
70
103
|
const componentId = id || generatedId;
|
|
71
104
|
const getComponent = () => {
|
|
@@ -177,7 +210,7 @@ const Button = React__default.forwardRef(({ as, children, variant = 'filled', ic
|
|
|
177
210
|
}
|
|
178
211
|
return {};
|
|
179
212
|
};
|
|
180
|
-
if (
|
|
213
|
+
if (tooltipText && !loading) {
|
|
181
214
|
return (jsx(Tooltip, { text: tooltipText, side: tooltipSide, align: tooltipAlign, children: jsx(Component, { ...baseProps, ...getNavigationProps(), children: renderContent() }) }));
|
|
182
215
|
}
|
|
183
216
|
return (jsx(Component, { ...baseProps, ...getNavigationProps(), children: renderContent() }));
|
|
@@ -2909,6 +2942,8 @@ const ICON_KEY_MAP = {
|
|
|
2909
2942
|
capslock: KeyboardShiftUppercase20Regular,
|
|
2910
2943
|
downkeyboard: ChevronDown20Regular,
|
|
2911
2944
|
emoji: Emoji20Regular,
|
|
2945
|
+
enterNumpad: ArrowImport20Regular,
|
|
2946
|
+
spaceNumpad: Spacebar20Regular,
|
|
2912
2947
|
};
|
|
2913
2948
|
const SHARED_DISPLAY = {
|
|
2914
2949
|
'{capslock}': iconSlot('capslock'),
|
|
@@ -2934,9 +2969,11 @@ const LAYOUT_DISPLAY = {
|
|
|
2934
2969
|
const EMOTICON_KEY = '{emoticon}';
|
|
2935
2970
|
const DOWN_KEYBOARD_KEY = '{downkeyboard}';
|
|
2936
2971
|
const ENTER_KEY = '{enter}';
|
|
2937
|
-
const removeKeyFromLayout = (layout, key) => Object.fromEntries(Object.entries(layout).map(([layoutName, rows]) => [
|
|
2972
|
+
const removeKeyFromLayout = (layout, key, skipLayouts = []) => Object.fromEntries(Object.entries(layout).map(([layoutName, rows]) => [
|
|
2938
2973
|
layoutName,
|
|
2939
|
-
|
|
2974
|
+
skipLayouts.includes(layoutName)
|
|
2975
|
+
? rows
|
|
2976
|
+
: rows.map((row) => row.split(key).join(' ').replace(/\s+/g, ' ').trim()),
|
|
2940
2977
|
]));
|
|
2941
2978
|
const replaceKeyWithBlank = (layout, key) => Object.fromEntries(Object.entries(layout).map(([layoutName, rows]) => [
|
|
2942
2979
|
layoutName,
|
|
@@ -2949,7 +2986,8 @@ const QWERTY_LOWERCASE = [
|
|
|
2949
2986
|
'{shift} z x c v b n m {bksp}',
|
|
2950
2987
|
'{numbers} {alt} {space} . {enter}',
|
|
2951
2988
|
];
|
|
2952
|
-
const NUMPAD = ['1 2 3', '4 5 6', '7 8 9', '{
|
|
2989
|
+
const NUMPAD = ['1 2 3', '4 5 6', '7 8 9', '{abc} 0 {bksp}'];
|
|
2990
|
+
const NUMPAD_WITH_ENTER = ['1 2 3 -', '4 5 6 {space}', '7 8 9 {bksp}', '{abc} 0 . {enter}'];
|
|
2953
2991
|
const SHARED_LAYOUTS = {
|
|
2954
2992
|
shift: [
|
|
2955
2993
|
'1 2 3 4 5 6 7 8 9 0',
|
|
@@ -2999,11 +3037,17 @@ const NATIVE_LAYOUTS = {
|
|
|
2999
3037
|
const NATIVE_LAYOUT_KEYS = new Set([
|
|
3000
3038
|
'default', 'numeric',
|
|
3001
3039
|
]);
|
|
3002
|
-
const getNativeLayout = (type, Emoji = true, showDownKeyboardButton = true, isFixed = false, showEnterKey = true, showTypeSwitchKey = true) => {
|
|
3040
|
+
const getNativeLayout = (type, Emoji = true, showDownKeyboardButton = true, isFixed = false, showEnterKey = true, showTypeSwitchKey = true, numpadWithEnter = false) => {
|
|
3003
3041
|
const layout = NATIVE_LAYOUTS[type] ?? NATIVE_LAYOUTS.default ?? null;
|
|
3004
3042
|
if (!layout)
|
|
3005
3043
|
return null;
|
|
3006
|
-
let computedLayout =
|
|
3044
|
+
let computedLayout = numpadWithEnter
|
|
3045
|
+
? {
|
|
3046
|
+
...layout,
|
|
3047
|
+
...(type === 'numeric' ? { default: NUMPAD_WITH_ENTER } : {}),
|
|
3048
|
+
numbers: NUMPAD_WITH_ENTER,
|
|
3049
|
+
}
|
|
3050
|
+
: layout;
|
|
3007
3051
|
if (!Emoji) {
|
|
3008
3052
|
computedLayout = removeKeyFromLayout(computedLayout, EMOTICON_KEY);
|
|
3009
3053
|
}
|
|
@@ -3011,26 +3055,31 @@ const getNativeLayout = (type, Emoji = true, showDownKeyboardButton = true, isFi
|
|
|
3011
3055
|
computedLayout = removeKeyFromLayout(computedLayout, DOWN_KEYBOARD_KEY);
|
|
3012
3056
|
}
|
|
3013
3057
|
if (!showEnterKey) {
|
|
3014
|
-
|
|
3058
|
+
// Numpad layouts always preserve {enter}; only remove from QWERTY layouts
|
|
3059
|
+
const numpadLayouts = type === 'numeric' ? ['default', 'numbers'] : ['numbers'];
|
|
3060
|
+
computedLayout = removeKeyFromLayout(computedLayout, ENTER_KEY, numpadLayouts);
|
|
3015
3061
|
}
|
|
3016
3062
|
if (!showTypeSwitchKey) {
|
|
3017
3063
|
computedLayout = removeKeyFromLayout(computedLayout, '{numbers}');
|
|
3018
3064
|
computedLayout = replaceKeyWithBlank(computedLayout, '{abc}');
|
|
3019
3065
|
}
|
|
3020
3066
|
if (isFixed) {
|
|
3021
|
-
computedLayout = Object.fromEntries(Object.entries(computedLayout).map(([layoutName, rows]) =>
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3067
|
+
computedLayout = Object.fromEntries(Object.entries(computedLayout).map(([layoutName, rows]) => {
|
|
3068
|
+
const hasBksp = rows.some((r) => r.includes('{bksp}'));
|
|
3069
|
+
return [
|
|
3070
|
+
layoutName,
|
|
3071
|
+
rows.map((row) => {
|
|
3072
|
+
const trimmed = row.trim();
|
|
3073
|
+
if (/^[a-zA-ZçÇ]/.test(trimmed) && trimmed.endsWith('{bksp}')) {
|
|
3074
|
+
return '{//} ' + trimmed.replace(/\s*\{bksp\}$/, '') + ' {//}';
|
|
3075
|
+
}
|
|
3076
|
+
if (!hasBksp && /\{(shift|capslock|shiftactivated)\}$/.test(trimmed)) {
|
|
3077
|
+
return trimmed.replace(/\{(shift|capslock|shiftactivated)\}$/, '{bksp}');
|
|
3078
|
+
}
|
|
3079
|
+
return row;
|
|
3080
|
+
}),
|
|
3081
|
+
];
|
|
3082
|
+
}));
|
|
3034
3083
|
}
|
|
3035
3084
|
return computedLayout;
|
|
3036
3085
|
};
|
|
@@ -3082,13 +3131,16 @@ const ACCENT_OPTIONS = {
|
|
|
3082
3131
|
* <VirtualKeyboard targetRef={inputRef} value={value} onChange={setValue} />
|
|
3083
3132
|
* ```
|
|
3084
3133
|
*/
|
|
3085
|
-
const VirtualKeyboard = ({ variant = 'native', type = 'default', value
|
|
3134
|
+
const VirtualKeyboard = ({ variant = 'native', type = 'default', value, onChange, onKeyPress, onEnterPress, onTypeChange, maxLength, Emoji = false, className, id, placeholder = 'Digite aqui...', helperText, error, errorMessage, targetRef, textFieldScale = 1, showEnterKey = true, showTypeSwitchKey = true, numpadWithEnter = false, }) => {
|
|
3135
|
+
const [internalValue, setInternalValue] = useState(value ?? '');
|
|
3086
3136
|
const [layoutName, setLayoutName] = useState('default');
|
|
3087
3137
|
const [capsLockOn, setCapsLockOn] = useState(false);
|
|
3088
3138
|
const [accentMenu, setAccentMenu] = useState(null);
|
|
3089
3139
|
const [accentMenuOffsetX, setAccentMenuOffsetX] = useState(0);
|
|
3090
|
-
const [activeLayout, setActiveLayout] = useState(getNativeLayout(type, Emoji, variant === 'native', variant === 'fixed', showEnterKey, showTypeSwitchKey));
|
|
3140
|
+
const [activeLayout, setActiveLayout] = useState(getNativeLayout(type, Emoji, variant === 'native', variant === 'fixed', showEnterKey, showTypeSwitchKey, numpadWithEnter));
|
|
3091
3141
|
const visualType = NATIVE_LAYOUT_KEYS.has(type) ? type : 'default';
|
|
3142
|
+
const effectiveValue = onChange !== undefined ? (value ?? '') : internalValue;
|
|
3143
|
+
const isNumpadLayout = (type === 'numeric' && layoutName === 'default') || layoutName === 'numbers';
|
|
3092
3144
|
const [isOpen, setIsOpen] = useState(variant !== 'native');
|
|
3093
3145
|
const hideTimeoutRef = useRef(null);
|
|
3094
3146
|
const scrollTimeoutRef = useRef(null);
|
|
@@ -3101,15 +3153,15 @@ const VirtualKeyboard = ({ variant = 'native', type = 'default', value = '', onC
|
|
|
3101
3153
|
const keyboardInstanceRef = useRef(null);
|
|
3102
3154
|
const accentMenuRef = useRef(null);
|
|
3103
3155
|
const accentButtonRef = useRef(null);
|
|
3104
|
-
const valueRef = useRef(value);
|
|
3156
|
+
const valueRef = useRef(value ?? '');
|
|
3105
3157
|
const [iconSlots, setIconSlots] = useState([]);
|
|
3106
3158
|
const [keyPreview, setKeyPreview] = useState(null);
|
|
3107
3159
|
const [keyPreviewOffsetX, setKeyPreviewOffsetX] = useState(0);
|
|
3108
3160
|
const keyPreviewRef = useRef(null);
|
|
3109
3161
|
const [containerWidth, setContainerWidth] = useState(Infinity);
|
|
3110
3162
|
useEffect(() => {
|
|
3111
|
-
valueRef.current =
|
|
3112
|
-
}, [
|
|
3163
|
+
valueRef.current = effectiveValue;
|
|
3164
|
+
}, [effectiveValue]);
|
|
3113
3165
|
const clearLongPressTimeout = useCallback(() => {
|
|
3114
3166
|
if (longPressTimeoutRef.current !== null) {
|
|
3115
3167
|
clearTimeout(longPressTimeoutRef.current);
|
|
@@ -3124,8 +3176,8 @@ const VirtualKeyboard = ({ variant = 'native', type = 'default', value = '', onC
|
|
|
3124
3176
|
keyboardInstanceRef.current?.setInput(nextValue);
|
|
3125
3177
|
}, []);
|
|
3126
3178
|
useEffect(() => {
|
|
3127
|
-
syncKeyboardInput(
|
|
3128
|
-
}, [
|
|
3179
|
+
syncKeyboardInput(effectiveValue);
|
|
3180
|
+
}, [effectiveValue, syncKeyboardInput]);
|
|
3129
3181
|
useEffect(() => {
|
|
3130
3182
|
onTypeChange?.(type);
|
|
3131
3183
|
}, [type, onTypeChange]);
|
|
@@ -3203,8 +3255,8 @@ const VirtualKeyboard = ({ variant = 'native', type = 'default', value = '', onC
|
|
|
3203
3255
|
useEffect(() => {
|
|
3204
3256
|
setLayoutName('default');
|
|
3205
3257
|
setCapsLockOn(false);
|
|
3206
|
-
setActiveLayout(getNativeLayout(type, Emoji, variant === 'native', variant === 'fixed', showEnterKey, showTypeSwitchKey));
|
|
3207
|
-
}, [type, Emoji, variant, showEnterKey, showTypeSwitchKey]);
|
|
3258
|
+
setActiveLayout(getNativeLayout(type, Emoji, variant === 'native', variant === 'fixed', showEnterKey, showTypeSwitchKey, numpadWithEnter));
|
|
3259
|
+
}, [type, Emoji, variant, showEnterKey, showTypeSwitchKey, numpadWithEnter]);
|
|
3208
3260
|
useEffect(() => {
|
|
3209
3261
|
if (!Emoji && layoutName === 'emoticon') {
|
|
3210
3262
|
setLayoutName(type === 'numeric' ? 'abc' : 'default');
|
|
@@ -3284,7 +3336,10 @@ const VirtualKeyboard = ({ variant = 'native', type = 'default', value = '', onC
|
|
|
3284
3336
|
if (newSlots.length === 0)
|
|
3285
3337
|
return;
|
|
3286
3338
|
newSlots.forEach((s) => s.setAttribute('data-icon-root', 'true'));
|
|
3287
|
-
setIconSlots((prev) => [
|
|
3339
|
+
setIconSlots((prev) => [
|
|
3340
|
+
...prev.filter((slot) => container.contains(slot)),
|
|
3341
|
+
...newSlots,
|
|
3342
|
+
]);
|
|
3288
3343
|
};
|
|
3289
3344
|
registerNewSlots();
|
|
3290
3345
|
const observer = new MutationObserver(() => {
|
|
@@ -3295,7 +3350,7 @@ const VirtualKeyboard = ({ variant = 'native', type = 'default', value = '', onC
|
|
|
3295
3350
|
return () => {
|
|
3296
3351
|
observer.disconnect();
|
|
3297
3352
|
};
|
|
3298
|
-
}, []);
|
|
3353
|
+
}, [variant]);
|
|
3299
3354
|
useEffect(() => {
|
|
3300
3355
|
closeAccentMenu();
|
|
3301
3356
|
setAccentMenuOffsetX(0);
|
|
@@ -3377,6 +3432,8 @@ const VirtualKeyboard = ({ variant = 'native', type = 'default', value = '', onC
|
|
|
3377
3432
|
const currentValue = valueRef.current;
|
|
3378
3433
|
if (maxLength === undefined || currentValue.length < maxLength) {
|
|
3379
3434
|
const nextValue = `${currentValue}${heldKey}`;
|
|
3435
|
+
if (onChange === undefined)
|
|
3436
|
+
setInternalValue(nextValue);
|
|
3380
3437
|
onChange?.(nextValue);
|
|
3381
3438
|
onKeyPress?.(heldKey);
|
|
3382
3439
|
syncKeyboardInput(nextValue);
|
|
@@ -3410,6 +3467,8 @@ const VirtualKeyboard = ({ variant = 'native', type = 'default', value = '', onC
|
|
|
3410
3467
|
return;
|
|
3411
3468
|
}
|
|
3412
3469
|
const nextValue = `${currentValue}${accentedChar}`;
|
|
3470
|
+
if (onChange === undefined)
|
|
3471
|
+
setInternalValue(nextValue);
|
|
3413
3472
|
onChange?.(nextValue);
|
|
3414
3473
|
onKeyPress?.(accentedChar);
|
|
3415
3474
|
closeAccentMenu();
|
|
@@ -3500,12 +3559,16 @@ const VirtualKeyboard = ({ variant = 'native', type = 'default', value = '', onC
|
|
|
3500
3559
|
if (isHeldAccentKey) {
|
|
3501
3560
|
return;
|
|
3502
3561
|
}
|
|
3562
|
+
if (button === '{enter}') {
|
|
3563
|
+
onEnterPress?.();
|
|
3564
|
+
}
|
|
3503
3565
|
onKeyPress?.(button);
|
|
3504
3566
|
}, [
|
|
3505
3567
|
type,
|
|
3506
3568
|
layoutName,
|
|
3507
3569
|
capsLockOn,
|
|
3508
3570
|
onKeyPress,
|
|
3571
|
+
onEnterPress,
|
|
3509
3572
|
onTypeChange,
|
|
3510
3573
|
Emoji,
|
|
3511
3574
|
variant,
|
|
@@ -3519,12 +3582,12 @@ const VirtualKeyboard = ({ variant = 'native', type = 'default', value = '', onC
|
|
|
3519
3582
|
if (heldKey &&
|
|
3520
3583
|
input.length >= currentValue.length + 1 &&
|
|
3521
3584
|
input.startsWith(currentValue) &&
|
|
3522
|
-
input.slice(currentValue.length).
|
|
3585
|
+
[...input.slice(currentValue.length)].every((char) => char === heldKey)) {
|
|
3523
3586
|
syncKeyboardInput(currentValue);
|
|
3524
3587
|
return;
|
|
3525
3588
|
}
|
|
3526
3589
|
if (suppressedKey &&
|
|
3527
|
-
input.length === currentValue.length +
|
|
3590
|
+
input.length === currentValue.length + suppressedKey.length &&
|
|
3528
3591
|
input.endsWith(suppressedKey)) {
|
|
3529
3592
|
suppressNextInputRef.current = null;
|
|
3530
3593
|
syncKeyboardInput(currentValue);
|
|
@@ -3532,8 +3595,10 @@ const VirtualKeyboard = ({ variant = 'native', type = 'default', value = '', onC
|
|
|
3532
3595
|
}
|
|
3533
3596
|
if (maxLength !== undefined && input.length > maxLength)
|
|
3534
3597
|
return;
|
|
3598
|
+
if (onChange === undefined)
|
|
3599
|
+
setInternalValue(input);
|
|
3535
3600
|
onChange?.(input);
|
|
3536
|
-
}, [maxLength, onChange, syncKeyboardInput]);
|
|
3601
|
+
}, [maxLength, onChange, setInternalValue, syncKeyboardInput]);
|
|
3537
3602
|
const portalSizes = useMemo(() => {
|
|
3538
3603
|
if (containerWidth <= 360)
|
|
3539
3604
|
return { preview: 42, option: 44, fontSize: 'var(--font-size-16)' };
|
|
@@ -3549,15 +3614,17 @@ const VirtualKeyboard = ({ variant = 'native', type = 'default', value = '', onC
|
|
|
3549
3614
|
const baseDisplay = LAYOUT_DISPLAY[visualType];
|
|
3550
3615
|
if (!baseDisplay)
|
|
3551
3616
|
return baseDisplay;
|
|
3552
|
-
|
|
3553
|
-
|
|
3617
|
+
const display = { ...baseDisplay };
|
|
3618
|
+
if (numpadWithEnter && isNumpadLayout) {
|
|
3619
|
+
display['{enter}'] = '<span data-icon-key="enterNumpad"></span>';
|
|
3620
|
+
display['{space}'] = '<span data-icon-key="spaceNumpad"></span>';
|
|
3554
3621
|
}
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
}, [visualType, variant]);
|
|
3560
|
-
const keyboardEl = activeLayout ? (jsxs("div", { ref: keyboardWrapperRef, className: clsx(styles$k.keyboardWrapper,
|
|
3622
|
+
if (variant === 'fixed') {
|
|
3623
|
+
display['{bksp}'] = (display['{bksp}'] ?? '').replace(/\s*Apagar$/, '');
|
|
3624
|
+
}
|
|
3625
|
+
return display;
|
|
3626
|
+
}, [visualType, variant, numpadWithEnter, isNumpadLayout]);
|
|
3627
|
+
const keyboardEl = activeLayout ? (jsxs("div", { ref: keyboardWrapperRef, className: clsx(styles$k.keyboardWrapper, isNumpadLayout && styles$k.keyboardNumpadActive), onPointerDownCapture: handleLongPressStart, onPointerUpCapture: handleLongPressEnd, onPointerLeave: handleLongPressEnd, onPointerCancelCapture: handleLongPressEnd, children: [jsx(Keyboard, { keyboardRef: (instance) => {
|
|
3561
3628
|
keyboardInstanceRef.current = instance;
|
|
3562
3629
|
if (instance) {
|
|
3563
3630
|
instance.setInput(valueRef.current);
|
|
@@ -3595,9 +3662,9 @@ const VirtualKeyboard = ({ variant = 'native', type = 'default', value = '', onC
|
|
|
3595
3662
|
event.stopPropagation();
|
|
3596
3663
|
}, onClick: () => handleAccentSelect(option), children: option }, `${accentMenu.sourceKey}-${option}`))) }, rowIndex))) }), document.body))] })) : null;
|
|
3597
3664
|
if (variant === 'native' && typeof document !== 'undefined') {
|
|
3598
|
-
return createPortal(jsx("div", { id: id, className: clsx(styles$k.overlay, { [styles$k.overlayOpen]: isOpen }, styles$k[
|
|
3665
|
+
return createPortal(jsx("div", { id: id, className: clsx(styles$k.overlay, { [styles$k.overlayOpen]: isOpen }, styles$k[isNumpadLayout ? 'layout--numeric' : 'layout--default'], className), children: keyboardEl }), document.body);
|
|
3599
3666
|
}
|
|
3600
|
-
return (jsxs("div", { id: id, className: clsx(styles$k.container, styles$k[`mode--${variant}`], styles$k[
|
|
3667
|
+
return (jsxs("div", { id: id, className: clsx(styles$k.container, styles$k[`mode--${variant}`], styles$k[isNumpadLayout ? 'layout--numeric' : 'layout--default'], className), children: [variant === 'fixed' && (jsx("div", { className: styles$k.textFieldContainer, children: jsx(TextField$1, { placeholder: placeholder, value: effectiveValue, onChange: onChange, helperText: helperText, error: error, errorMessage: errorMessage, readOnly: true, disableAutoComplete: true, maxLength: maxLength, attachedToVirtualKeyboard: true, className: styles$k.textFieldWrapper, scale: textFieldScale }) })), keyboardEl] }));
|
|
3601
3668
|
};
|
|
3602
3669
|
|
|
3603
3670
|
var styles$j = {"container":"TextField-module__container___WJHFR","inputWrapper":"TextField-module__inputWrapper___INjfd","inputContainer":"TextField-module__inputContainer___3EsFJ","icon":"TextField-module__icon___p1vwi","clearButton":"TextField-module__clearButton___kgOot","inputWithIcon":"TextField-module__inputWithIcon___shqkL","helperText":"TextField-module__helperText___d5QGC","error":"TextField-module__error___IGQzp","disabled":"TextField-module__disabled___roIKP","attachedToVirtualKeyboard":"TextField-module__attachedToVirtualKeyboard___fuO2O","errorWithMessage":"TextField-module__errorWithMessage___m-5AA","clearButtonIcon":"TextField-module__clearButtonIcon___Z2iyc"};
|
|
@@ -3626,7 +3693,7 @@ const LabelComponent = ({ children, htmlFor, required = false, tooltip = false,
|
|
|
3626
3693
|
return container;
|
|
3627
3694
|
};
|
|
3628
3695
|
|
|
3629
|
-
const TextField = forwardRef(({ className, style, value, label, placeholder, type = 'text', onChange, disabled = false, maxLength, required = false, helperText, tooltipText, tooltipSide = 'bottom', tooltipAlign = 'start', errorMessage, error, id, icon, scale = 1, onBlur, onFocus, name,
|
|
3696
|
+
const TextField = forwardRef(({ className, style, value, label, placeholder, type = 'text', onChange, disabled = false, maxLength, required = false, helperText, tooltipText, tooltipSide = 'bottom', tooltipAlign = 'start', errorMessage, error, id, icon, scale = 1, onBlur, onFocus, name, virtualKeyboard, attachedToVirtualKeyboard, disableAutoComplete = false, ...rest }, ref) => {
|
|
3630
3697
|
const normalizeValue = (val) => {
|
|
3631
3698
|
return val === undefined || val === null ? '' : String(val);
|
|
3632
3699
|
};
|
|
@@ -3677,7 +3744,7 @@ const TextField = forwardRef(({ className, style, value, label, placeholder, typ
|
|
|
3677
3744
|
setIsFocused(true);
|
|
3678
3745
|
onFocus?.(e);
|
|
3679
3746
|
}, [onFocus]);
|
|
3680
|
-
const showCustomIcon = (inputValue.trim().length === 0 ||
|
|
3747
|
+
const showCustomIcon = (inputValue.trim().length === 0 || !isFocused) && icon;
|
|
3681
3748
|
const showClearIcon = isFocused && inputValue.trim().length > 0;
|
|
3682
3749
|
const hasError = Boolean(inputError) || Boolean(error);
|
|
3683
3750
|
const displayHelperText = (error ? errorMessage : undefined) || inputError || helperText || '\u00A0';
|
|
@@ -3932,7 +3999,7 @@ const DatePicker = ({ locale = 'pt-br', calendarSide = 'bottom', calendarAlign =
|
|
|
3932
3999
|
};
|
|
3933
4000
|
return (jsx("div", { ref: wrapperRef, id: id, className: clsx(styles$h.datePicker, className), style: { ...containerStyle, ...style }, ...rest, children: jsx(Popover, { open: showCalendar, onOpenChange: setShowCalendar, asAnchor: true, trigger: jsx(TextField$1, { className: styles$h.textfieldContainer, type: "tel", icon: jsx(Calendar16Regular, { onClick: !disabled ? handleIconClick : undefined, className: clsx(styles$h.datePickerIcon, disabled && styles$h.datePickerIconDisabled) }), onChange: (e) => {
|
|
3934
4001
|
handleTextFieldChange(String(e));
|
|
3935
|
-
}, onKeyDown: handleKeyDown, onFocus: handleFocus,
|
|
4002
|
+
}, onKeyDown: handleKeyDown, onFocus: handleFocus, 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, scale: scale, 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: scale, id: calendarId, onClear: () => {
|
|
3936
4003
|
handleDateChange(null);
|
|
3937
4004
|
setCurrentDate(new Date());
|
|
3938
4005
|
} }), side: calendarSide, align: calendarAlign, sideOffset: 8 }) }));
|
|
@@ -3941,7 +4008,7 @@ var DatePicker_default = React__default.memo(DatePicker);
|
|
|
3941
4008
|
|
|
3942
4009
|
var styles$g = {"DialogOverlay":"Dialog-module__DialogOverlay___LEX2O","DialogContent":"Dialog-module__DialogContent___ziVXb","DialogTitle":"Dialog-module__DialogTitle___ay1tD","DialogDescription":"Dialog-module__DialogDescription___odslw","DivButtons":"Dialog-module__DivButtons___BiwX-"};
|
|
3943
4010
|
|
|
3944
|
-
const Dialog = ({ show = false, title, bodyContent, textPrimaryAction, textSecondaryAction, onPrimaryAction, onSecondaryAction, className, ...rest }) => (jsx(AlertDialog.Root, { open: show, ...rest, children: jsxs(AlertDialog.Portal, { children: [jsx(AlertDialog.Overlay, { className: styles$g.DialogOverlay }), jsxs(AlertDialog.Content, { className: clsx(styles$g.DialogContent, className), children: [jsx(AlertDialog.Title, { className: styles$g.DialogTitle, children: title }), jsx(AlertDialog.Description, { className: styles$g.DialogDescription, children: bodyContent }), jsxs("div", { className: styles$g.DivButtons, children: [!!(textSecondaryAction && textSecondaryAction.trim()) && (jsx(AlertDialog.Cancel, { asChild: true, children: jsx(Button, { variant: "outlined", ...(onSecondaryAction && { onClick: onSecondaryAction }), children: textSecondaryAction }) })), jsx(AlertDialog.Action, { asChild: true, children: jsx(Button, { variant: "filled", ...(onPrimaryAction && { onClick: onPrimaryAction }), children: textPrimaryAction }) })] })] })] }) }));
|
|
4011
|
+
const Dialog = ({ show = false, title, bodyContent, textPrimaryAction, textSecondaryAction, onPrimaryAction, onSecondaryAction, className, ...rest }) => (jsx(AlertDialog.Root, { open: show, ...rest, children: jsxs(AlertDialog.Portal, { children: [jsx(AlertDialog.Overlay, { className: styles$g.DialogOverlay }), jsxs(AlertDialog.Content, { className: clsx(styles$g.DialogContent, className), children: [jsx(AlertDialog.Title, { className: styles$g.DialogTitle, children: title }), jsx(AlertDialog.Description, { asChild: true, className: styles$g.DialogDescription, children: jsx("div", { children: bodyContent }) }), jsxs("div", { className: styles$g.DivButtons, children: [!!(textSecondaryAction && textSecondaryAction.trim()) && (jsx(AlertDialog.Cancel, { asChild: true, children: jsx(Button, { variant: "outlined", ...(onSecondaryAction && { onClick: onSecondaryAction }), children: textSecondaryAction }) })), jsx(AlertDialog.Action, { asChild: true, children: jsx(Button, { variant: "filled", ...(onPrimaryAction && { onClick: onPrimaryAction }), children: textPrimaryAction }) })] })] })] }) }));
|
|
3945
4012
|
|
|
3946
4013
|
var styles$f = {"drawerShadow":"Drawer-module__drawerShadow___0Z6iL","drawerShadow--visible":"Drawer-module__drawerShadow--visible___FspoH","drawerSidebar":"Drawer-module__drawerSidebar___cdyyb","drawerSidebar--open":"Drawer-module__drawerSidebar--open___ee2-Y","drawerSidebar--disabled":"Drawer-module__drawerSidebar--disabled___MYrBI","drawerTitleClose":"Drawer-module__drawerTitleClose___QzqN-","drawerTitle":"Drawer-module__drawerTitle___naMX0","drawerChildren":"Drawer-module__drawerChildren___xGdg9","drawerHeaderContent":"Drawer-module__drawerHeaderContent___NLSwj"};
|
|
3947
4014
|
|
|
@@ -4196,7 +4263,7 @@ const Combined = ({ buttonText = 'Filtrar', icon, variant = 'outlined', disabled
|
|
|
4196
4263
|
|
|
4197
4264
|
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"};
|
|
4198
4265
|
|
|
4199
|
-
const Search =
|
|
4266
|
+
const Search = 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, style, virtualKeyboard, 'data-testid': testId, ...rest }, ref) => {
|
|
4200
4267
|
const [internalValue, setInternalValue] = useState('');
|
|
4201
4268
|
const { internalRef: inputRef, setRefs: setInputRefs } = useInputKeyboardValue(ref);
|
|
4202
4269
|
const isControlled = value !== undefined && onChange !== undefined;
|
|
@@ -4806,9 +4873,9 @@ const Menu = ({ items, children, onItemSelect, search, enableInfiniteScroll, onS
|
|
|
4806
4873
|
}, ...rest, children: [search && (jsx("div", { className: styles$a.searchWrapper, children: jsx(Search, { placeholder: "Buscar", onChange: handleSearchChange, value: searchInput, onKeyDown: handleSearchKeyDown }) })), jsxs("div", { className: styles$a.itemsWrapper, ref: itemsWrapperRef, style: { maxHeight: maxHeightStyle }, children: [filteredItems.length > 0 ? (filteredItems.map((item, index) => renderMenuItem(item, item.value || item.text || `item-${index}`))) : (jsx("div", { className: styles$a.emptyState, children: "Nenhum item encontrado" })), enableInfiniteScroll && isLoadingMore && (jsx("div", { className: styles$a.loadingMore, children: "Carregando mais itens..." })), enableInfiniteScroll && (jsx("div", { ref: sentinelRef, "data-scroll-sentinel": true, style: { height: '1px', visibility: 'hidden' } }))] })] }) })] }));
|
|
4807
4874
|
};
|
|
4808
4875
|
|
|
4809
|
-
var styles$9 = {"modalOverlay":"Modal-module__modalOverlay___rI8Wz","modalContent":"Modal-module__modalContent___6Cgb1","modalContent--fullscreen":"Modal-module__modalContent--fullscreen___QeBlG","modalHeader":"Modal-module__modalHeader___IuHIg","modalTitle":"Modal-module__modalTitle___9VDmr","modalBody":"Modal-module__modalBody___ohjQm","modalFooter":"Modal-module__modalFooter___TEqdK"};
|
|
4876
|
+
var styles$9 = {"modalOverlay":"Modal-module__modalOverlay___rI8Wz","modalContent":"Modal-module__modalContent___6Cgb1","modalContent--fullscreen":"Modal-module__modalContent--fullscreen___QeBlG","modalHeader":"Modal-module__modalHeader___IuHIg","modalCloseButton":"Modal-module__modalCloseButton___VoWHD","modalTitle":"Modal-module__modalTitle___9VDmr","modalBody":"Modal-module__modalBody___ohjQm","modalFooter":"Modal-module__modalFooter___TEqdK"};
|
|
4810
4877
|
|
|
4811
|
-
const Modal = ({ isOpen = false, onClose, title, children, headerContent, closeOnOverlayClick = true, className, id, footer, customWidth, customHeight, fullscreen = false, ...rest }) => {
|
|
4878
|
+
const Modal = ({ isOpen = false, onClose, title, children, headerContent, closeOnOverlayClick = true, className, id, footer, customWidth, customHeight, closingButton = true, fullscreen = false, ...rest }) => {
|
|
4812
4879
|
const contentRef = React.useRef(null);
|
|
4813
4880
|
const handleOpenChange = (open) => {
|
|
4814
4881
|
if (!open) {
|
|
@@ -4822,7 +4889,7 @@ const Modal = ({ isOpen = false, onClose, title, children, headerContent, closeO
|
|
|
4822
4889
|
return (jsx(Dialog$1.Root, { open: isOpen, onOpenChange: handleOpenChange, ...rest, children: jsxs(Dialog$1.Portal, { children: [jsx(Dialog$1.Overlay, { className: styles$9.modalOverlay }), jsxs(Dialog$1.Content, { ref: contentRef, className: clsx(styles$9.modalContent, fullscreen && styles$9['modalContent--fullscreen'], className), id: id, style: {
|
|
4823
4890
|
'--modal-custom-width': customWidth,
|
|
4824
4891
|
'--modal-custom-height': customHeight,
|
|
4825
|
-
}, onInteractOutside: !closeOnOverlayClick ? (e) => e.preventDefault() : undefined, onOpenAutoFocus: handleOpenAutoFocus, "aria-labelledby": id ? `${id}-title` : 'modal-title', tabIndex: -1, children: [jsxs("header", { className: styles$9.modalHeader, children: [title && (jsx(Dialog$1.Title, { className: styles$9.modalTitle, id: id ? `${id}-title` : 'modal-title', children: title })), headerContent && (jsx("div", { children: headerContent })), jsx(Dialog$1.Close, { asChild: true, children: jsx(Button, { variant: "outlined", iconOnly: true, icon: jsx(Dismiss16Regular, {}), size: "lg", tooltipText: 'Fechar' }) })] }), jsx("section", { className: styles$9.modalBody, children: children }), footer && (jsx("footer", { className: styles$9.modalFooter, children: footer }))] })] }) }));
|
|
4892
|
+
}, onInteractOutside: !closeOnOverlayClick ? (e) => e.preventDefault() : undefined, onOpenAutoFocus: handleOpenAutoFocus, "aria-labelledby": id ? `${id}-title` : 'modal-title', tabIndex: -1, children: [(title || headerContent || closingButton) && (jsxs("header", { className: styles$9.modalHeader, children: [title && (jsx(Dialog$1.Title, { className: styles$9.modalTitle, id: id ? `${id}-title` : 'modal-title', children: title })), headerContent && (jsx("div", { children: headerContent })), closingButton && (jsx("div", { className: styles$9.modalCloseButton, children: jsx(Dialog$1.Close, { asChild: true, children: jsx(Button, { variant: "outlined", iconOnly: true, icon: jsx(Dismiss16Regular, {}), size: "lg", tooltipText: 'Fechar' }) }) }))] })), jsx("section", { className: styles$9.modalBody, children: children }), footer && (jsx("footer", { className: styles$9.modalFooter, children: footer }))] })] }) }));
|
|
4826
4893
|
};
|
|
4827
4894
|
|
|
4828
4895
|
var styles$8 = {"quantity":"Quantity-module__quantity___-vndR","quantityInput":"Quantity-module__quantityInput___xZG-v","disabled":"Quantity-module__disabled___X6p5l"};
|
|
@@ -5098,7 +5165,7 @@ const ExpandableSelectItem = ({ item, variant, onSelect, selectedValues, level =
|
|
|
5098
5165
|
}, role: "button", tabIndex: item.disabled ? -1 : 0, "data-disabled": item.disabled || undefined, "data-selected": isSelected && !hasChildren ? 'true' : undefined, "data-testid": `select-item-${item.value}`, children: [variant === 'icon' && item.icon && (jsx("span", { className: styles$6.icon, children: item.icon })), jsxs("div", { className: styles$6.textContent, children: [jsx("div", { className: styles$6.title, children: item.text }), item.subTitle && jsx("div", { className: styles$6.subTitle, children: item.subTitle })] }), hasChildren && (jsx("span", { className: styles$6.chevron, children: isExpanded ? jsx(ChevronDown16Regular, {}) : jsx(ChevronRight16Regular, {}) }))] }) }), hasChildren && isExpanded && (jsx("div", { className: styles$6.childrenWrapper, children: item.children.map((child) => (jsx(ExpandableSelectItem, { item: child, variant: variant, onSelect: onSelect, selectedValues: selectedValues, level: level + 1 }, child.id || child.value))) }))] }));
|
|
5099
5166
|
};
|
|
5100
5167
|
|
|
5101
|
-
const SelectItem =
|
|
5168
|
+
const SelectItem = forwardRef(({ text, subTitle, icon, disabled, value, variant, disableFocusOnHover, ...restProps }, ref) => {
|
|
5102
5169
|
return (jsxs("div", { className: clsx(styles$6.itemWrapper, {
|
|
5103
5170
|
[styles$6.disabled]: disabled,
|
|
5104
5171
|
}), "data-disabled": disabled || undefined, "data-testid": `select-item-${value}`, ref: ref, children: [variant === 'icon' && icon && (jsx("span", { className: styles$6.icon, children: icon })), jsxs(Select$1.Item, { className: clsx(styles$6.item, {
|
|
@@ -5340,11 +5407,12 @@ function useSelectLogic({ value, required = false, search = false, onValueChange
|
|
|
5340
5407
|
};
|
|
5341
5408
|
}
|
|
5342
5409
|
|
|
5343
|
-
const Select = ({ items, onValueChange, onOpenChange, variant, required = false, value, label, helperText, placeholder = 'Selecione', maxWidth, search = false, error, errorMessage, disabled = false, className, style, 'aria-label': ariaLabel, 'data-testid': testId, tooltipText, tooltipSide = 'bottom', tooltipAlign = 'start', enableInfiniteScroll = false, onScrollEnd, isLoadingMore = false, enableApiSearch = false, onApiSearch, isSearching = false, scale = 1, ...rest }) => {
|
|
5410
|
+
const Select = ({ items, onValueChange, onOpenChange, variant, required = false, value, label, helperText, placeholder = 'Selecione', maxWidth, search = false, error, errorMessage, disabled = false, className, style, 'aria-label': ariaLabel, 'data-testid': testId, tooltipText, tooltipSide = 'bottom', tooltipAlign = 'start', enableInfiniteScroll = false, onScrollEnd, hasMore = true, isLoadingMore = false, enableApiSearch = false, onApiSearch, isSearching = false, scale = 1, ...rest }) => {
|
|
5344
5411
|
const componentId = useId();
|
|
5345
5412
|
const selectId = `select-${componentId}`;
|
|
5346
5413
|
const viewportRef = useRef(null);
|
|
5347
5414
|
const hasReachedEndRef = useRef(false);
|
|
5415
|
+
const wasLoadingMoreRef = useRef(false);
|
|
5348
5416
|
const { state, actions, refs, utils, } = useSelectLogic({
|
|
5349
5417
|
value,
|
|
5350
5418
|
required,
|
|
@@ -5363,7 +5431,7 @@ const Select = ({ items, onValueChange, onOpenChange, variant, required = false,
|
|
|
5363
5431
|
const handleScroll = () => {
|
|
5364
5432
|
const { scrollTop, scrollHeight, clientHeight } = viewport;
|
|
5365
5433
|
const isAtBottom = scrollTop + clientHeight >= scrollHeight - 1;
|
|
5366
|
-
if (isAtBottom && !hasReachedEndRef.current && onScrollEnd && !isLoadingMore) {
|
|
5434
|
+
if (isAtBottom && !hasReachedEndRef.current && onScrollEnd && !isLoadingMore && hasMore) {
|
|
5367
5435
|
hasReachedEndRef.current = true;
|
|
5368
5436
|
onScrollEnd();
|
|
5369
5437
|
}
|
|
@@ -5375,17 +5443,38 @@ const Select = ({ items, onValueChange, onOpenChange, variant, required = false,
|
|
|
5375
5443
|
return () => {
|
|
5376
5444
|
viewport.removeEventListener('scroll', handleScroll);
|
|
5377
5445
|
};
|
|
5378
|
-
}, [state.isOpen, enableInfiniteScroll, onScrollEnd, isLoadingMore]);
|
|
5446
|
+
}, [state.isOpen, enableInfiniteScroll, onScrollEnd, isLoadingMore, hasMore]);
|
|
5379
5447
|
useEffect(() => {
|
|
5380
5448
|
if (state.isOpen && enableInfiniteScroll) {
|
|
5381
5449
|
hasReachedEndRef.current = false;
|
|
5382
5450
|
}
|
|
5383
5451
|
}, [state.isOpen, enableInfiniteScroll]);
|
|
5452
|
+
useEffect(() => {
|
|
5453
|
+
if (wasLoadingMoreRef.current && !isLoadingMore && enableInfiniteScroll) {
|
|
5454
|
+
hasReachedEndRef.current = false;
|
|
5455
|
+
}
|
|
5456
|
+
wasLoadingMoreRef.current = isLoadingMore;
|
|
5457
|
+
}, [isLoadingMore, enableInfiniteScroll]);
|
|
5384
5458
|
const displayText = useMemo(() => utils.getDisplayText(state.selectedValues, placeholder, variant, items), [state.selectedValues, placeholder, variant, items, utils]);
|
|
5385
5459
|
const filteredItems = useMemo(() => {
|
|
5386
5460
|
const termToFilter = enableApiSearch ? state.searchTerm : state.searchInput;
|
|
5387
5461
|
return utils.getFilteredItems(items, termToFilter);
|
|
5388
5462
|
}, [items, state.searchTerm, state.searchInput, enableApiSearch, utils]);
|
|
5463
|
+
useEffect(() => {
|
|
5464
|
+
if (!state.isOpen || !enableInfiniteScroll || !onScrollEnd || isLoadingMore)
|
|
5465
|
+
return;
|
|
5466
|
+
const timer = setTimeout(() => {
|
|
5467
|
+
const viewport = viewportRef.current;
|
|
5468
|
+
if (!viewport)
|
|
5469
|
+
return;
|
|
5470
|
+
const { scrollHeight, clientHeight } = viewport;
|
|
5471
|
+
if (scrollHeight <= clientHeight && !hasReachedEndRef.current && hasMore) {
|
|
5472
|
+
hasReachedEndRef.current = true;
|
|
5473
|
+
onScrollEnd();
|
|
5474
|
+
}
|
|
5475
|
+
}, 150);
|
|
5476
|
+
return () => clearTimeout(timer);
|
|
5477
|
+
}, [state.isOpen, enableInfiniteScroll, onScrollEnd, isLoadingMore, hasMore, filteredItems.length]);
|
|
5389
5478
|
const containerStyle = useMemo(() => ({
|
|
5390
5479
|
maxWidth: maxWidth ? `${maxWidth}px` : undefined,
|
|
5391
5480
|
'--giro-scale': scale,
|
|
@@ -5453,18 +5542,18 @@ const EmptyState = ({ emptyIcon, emptyTitle, emptyText }) => (jsxs("div", { clas
|
|
|
5453
5542
|
|
|
5454
5543
|
var styles$4 = {"toggle":"ToggleButton-module__toggle___c1Ym-","item":"ToggleButton-module__item___2Qll-","toggle-lg":"ToggleButton-module__toggle-lg___8f3lo","item-lg":"ToggleButton-module__item-lg___479w-","toggle-sm":"ToggleButton-module__toggle-sm___SAGGb","item-sm":"ToggleButton-module__item-sm___4ju--","toggleIconLeft":"ToggleButton-module__toggleIconLeft___VwgKk","toggleWithIcon":"ToggleButton-module__toggleWithIcon___WbCr7","toggleIconOnly":"ToggleButton-module__toggleIconOnly___4iMEp","group":"ToggleButton-module__group___BoR-e"};
|
|
5455
5544
|
|
|
5456
|
-
const Toggle = ({ pressed, defaultPressed, onPressedChange, disabled = false, className,
|
|
5545
|
+
const Toggle = ({ pressed, defaultPressed, onPressedChange, disabled = false, className, label, id, size = 'lg', scale = 1, style, tooltipText, tooltipSide = 'top', tooltipAlign = 'center', icon, iconOnly = false, mode: _mode, selectionType: _type, value: _value, defaultValue: _defaultValue, onValueChange: _onValueChange, items: _items, ...rest }) => {
|
|
5457
5546
|
const toggle = (jsx(Toggle$1.Root, { pressed: pressed, defaultPressed: defaultPressed, onPressedChange: onPressedChange, disabled: disabled, className: clsx(styles$4.toggle, styles$4[`toggle-${size}`], {
|
|
5458
5547
|
[styles$4.toggleIconOnly]: iconOnly,
|
|
5459
5548
|
[styles$4.toggleWithIcon]: !!icon && !iconOnly,
|
|
5460
|
-
}, className), id: id, style: { '--giro-scale': scale, ...style }, ...rest, children: iconOnly ? (jsx("span", { className: styles$4.toggleIconLeft, "aria-hidden": "true", children: icon })) : (jsxs(Fragment, { children: [icon && jsx("span", { className: styles$4.toggleIconLeft, "aria-hidden": "true", children: icon }),
|
|
5549
|
+
}, className), id: id, style: { '--giro-scale': scale, ...style }, ...rest, children: iconOnly ? (jsx("span", { className: styles$4.toggleIconLeft, "aria-hidden": "true", children: icon })) : (jsxs(Fragment, { children: [icon && jsx("span", { className: styles$4.toggleIconLeft, "aria-hidden": "true", children: icon }), label] })) }));
|
|
5461
5550
|
if (tooltipText) {
|
|
5462
5551
|
return (jsx(Tooltip, { text: tooltipText, side: tooltipSide, align: tooltipAlign, children: toggle }));
|
|
5463
5552
|
}
|
|
5464
5553
|
return toggle;
|
|
5465
5554
|
};
|
|
5466
5555
|
|
|
5467
|
-
const ToggleGroup = ({ selectionType = 'single', value, defaultValue, onValueChange,
|
|
5556
|
+
const ToggleGroup = ({ selectionType = 'single', value, defaultValue, onValueChange, disabled = false, items = [], className, id, size = 'lg', scale = 1, style, tooltipText, tooltipSide = 'top', tooltipAlign = 'center', mode: _mode, icon: _icon, iconOnly: _iconOnly, pressed: _pressed, defaultPressed: _defaultPressed, onPressedChange: _onPressedChange, ...rest }) => {
|
|
5468
5557
|
const rootProps = selectionType === 'multiple'
|
|
5469
5558
|
? {
|
|
5470
5559
|
type: 'multiple',
|
|
@@ -5478,11 +5567,10 @@ const ToggleGroup = ({ selectionType = 'single', value, defaultValue, onValueCha
|
|
|
5478
5567
|
defaultValue: defaultValue,
|
|
5479
5568
|
onValueChange: onValueChange,
|
|
5480
5569
|
};
|
|
5481
|
-
const group = (jsx(ToggleGroup$1.Root, { ...rootProps,
|
|
5482
|
-
|
|
5483
|
-
|
|
5484
|
-
|
|
5485
|
-
}), style: { '--giro-scale': scale }, children: item.iconOnly ? (jsx("span", { className: styles$4.toggleIconLeft, "aria-hidden": "true", children: item.icon })) : (jsxs(Fragment, { children: [item.icon && jsx("span", { className: styles$4.toggleIconLeft, "aria-hidden": "true", children: item.icon }), item.label] })) }, item.value))) }));
|
|
5570
|
+
const group = (jsx(ToggleGroup$1.Root, { ...rootProps, disabled: disabled, className: clsx(styles$4.group, className), id: id, style: { '--giro-scale': scale, ...style }, ...rest, children: items.map((item) => (jsx(ToggleGroup$1.Item, { value: item.value, disabled: item.disabled, className: clsx(styles$4.item, styles$4[`item-${size}`], {
|
|
5571
|
+
[styles$4.toggleIconOnly]: item.iconOnly,
|
|
5572
|
+
[styles$4.toggleWithIcon]: !!item.icon && !item.iconOnly,
|
|
5573
|
+
}), style: { '--giro-scale': scale }, children: item.iconOnly ? (jsx("span", { className: styles$4.toggleIconLeft, "aria-hidden": "true", children: item.icon })) : (jsxs(Fragment, { children: [item.icon && jsx("span", { className: styles$4.toggleIconLeft, "aria-hidden": "true", children: item.icon }), item.label] })) }, item.value))) }));
|
|
5486
5574
|
if (tooltipText) {
|
|
5487
5575
|
return (jsx(Tooltip, { text: tooltipText, side: tooltipSide, align: tooltipAlign, children: group }));
|
|
5488
5576
|
}
|
|
@@ -5848,13 +5936,19 @@ const useToast = () => {
|
|
|
5848
5936
|
const Toast = ({ id, title, duration = 5000, icon, iconClosed = jsx(Dismiss16Filled, {}), automaticClose = true, iconType = "Info", className, ...rest }) => {
|
|
5849
5937
|
const [open, setOpen] = React.useState(false);
|
|
5850
5938
|
const { dismissToast } = useToastContext();
|
|
5939
|
+
const dismissTimerRef = React.useRef(null);
|
|
5851
5940
|
React.useEffect(() => {
|
|
5852
5941
|
setOpen(true);
|
|
5942
|
+
return () => {
|
|
5943
|
+
if (dismissTimerRef.current !== null) {
|
|
5944
|
+
clearTimeout(dismissTimerRef.current);
|
|
5945
|
+
}
|
|
5946
|
+
};
|
|
5853
5947
|
}, []);
|
|
5854
5948
|
const handleOpenChange = (isOpen) => {
|
|
5855
5949
|
setOpen(isOpen);
|
|
5856
5950
|
if (!isOpen && id) {
|
|
5857
|
-
setTimeout(() => dismissToast(id), 200);
|
|
5951
|
+
dismissTimerRef.current = setTimeout(() => dismissToast(id), 200);
|
|
5858
5952
|
}
|
|
5859
5953
|
};
|
|
5860
5954
|
let displayIcon = icon;
|
|
@@ -6262,5 +6356,5 @@ function useInfiniteScroll({ status, page, lastPage, onLoadMore, threshold = 0.1
|
|
|
6262
6356
|
};
|
|
6263
6357
|
}
|
|
6264
6358
|
|
|
6265
|
-
export { Avatar, Badge, Button, Calendar, Callout, Card, Checkbox, MemoizedChips as Chips, Container, DatePicker_default as DatePicker, Dialog, Drawer, FileUpload, Filter, ListItem, Menu, Modal, Popover, memorizedQuantity as Quantity, Radio, Search, Select, Switch, TableV2, TextArea_default as TextArea, TextField$1 as TextField, Toast, ToastContainer, ToastProvider, ToggleButton, Tooltip, VerificationCode, VirtualKeyboard, normalizeText, useApiSimulation, useInfiniteScroll, useToast };
|
|
6359
|
+
export { Avatar, Badge, Button, Calendar, Callout, Card, Checkbox, MemoizedChips as Chips, Container, DatePicker_default as DatePicker, Dialog, Drawer, FileUpload, Filter, Avatar as G_Avatar, Badge as G_Badge, Button as G_Button, Calendar as G_Calendar, Callout as G_Callout, Card as G_Card, Checkbox as G_Checkbox, MemoizedChips as G_Chips, Container as G_Container, DatePicker_default as G_DatePicker, Dialog as G_Dialog, Drawer as G_Drawer, FileUpload as G_FileUpload, Filter as G_Filter, ListItem as G_ListItem, Menu as G_Menu, Modal as G_Modal, Popover as G_Popover, memorizedQuantity as G_Quantity, Radio as G_Radio, Search as G_Search, Select as G_Select, Switch as G_Switch, TableV2 as G_TableV2, TextArea_default as G_TextArea, TextField$1 as G_TextField, Toast as G_Toast, ToastContainer as G_ToastContainer, ToastProvider as G_ToastProvider, ToggleButton as G_ToggleButton, Tooltip as G_Tooltip, VerificationCode as G_VerificationCode, VirtualKeyboard as G_VirtualKeyboard, ListItem, Menu, Modal, Popover, memorizedQuantity as Quantity, Radio, Search, Select, Switch, TableV2, TextArea_default as TextArea, TextField$1 as TextField, Toast, ToastContainer, ToastProvider, ToggleButton, Tooltip, VerificationCode, VirtualKeyboard, normalizeText, useApiSimulation, useInfiniteScroll, useToast };
|
|
6266
6360
|
//# sourceMappingURL=index.esm.js.map
|