@giro-ds/react 11.1.0 → 12.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 +664 -317
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +290 -111
- package/dist/index.esm.js +667 -321
- package/dist/index.esm.js.map +1 -1
- package/dist/styles.css +5 -5
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -31,17 +31,18 @@ function _interopNamespaceDefault(e) {
|
|
|
31
31
|
|
|
32
32
|
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
33
33
|
|
|
34
|
-
var styles$
|
|
34
|
+
var styles$v = {"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"};
|
|
35
35
|
|
|
36
|
-
const Avatar = ({ icon, size = 'lg', src, className,
|
|
37
|
-
const AvatarClass = clsx(styles$
|
|
38
|
-
[styles$
|
|
39
|
-
[styles$
|
|
36
|
+
const Avatar = ({ icon, size = 'lg', src, className, text, ...rest }) => {
|
|
37
|
+
const AvatarClass = clsx(styles$v.AvatarRoot, {
|
|
38
|
+
[styles$v['AvatarRoot--lg']]: size === 'lg',
|
|
39
|
+
[styles$v['AvatarRoot--sm']]: size === 'sm',
|
|
40
40
|
}, className);
|
|
41
|
-
|
|
41
|
+
const truncatedText = text ? text.slice(0, 2) : undefined;
|
|
42
|
+
return (jsxRuntime.jsxs(radixUi.Avatar.Root, { className: AvatarClass, ...rest, children: [src && (jsxRuntime.jsx(radixUi.Avatar.Image, { className: styles$v.AvatarImage, src: src, alt: "Avatar" })), jsxRuntime.jsx(radixUi.Avatar.Fallback, { className: styles$v.AvatarFallback, children: icon || truncatedText })] }));
|
|
42
43
|
};
|
|
43
44
|
|
|
44
|
-
var styles$
|
|
45
|
+
var styles$u = {"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"};
|
|
45
46
|
|
|
46
47
|
const getDisplayValue = (value) => {
|
|
47
48
|
if (value === null || value === undefined)
|
|
@@ -63,27 +64,27 @@ const Badge = ({ children, badgeValue = null, className, id, filterVariant = fal
|
|
|
63
64
|
const displayValue = getDisplayValue(badgeValue);
|
|
64
65
|
const isEmpty = displayValue === '';
|
|
65
66
|
if (children) {
|
|
66
|
-
return (jsxRuntime.jsxs("div", { className: styles$
|
|
67
|
-
[styles$
|
|
68
|
-
[styles$
|
|
67
|
+
return (jsxRuntime.jsxs("div", { className: styles$u.badgeContainer, ...rest, children: [jsxRuntime.jsx("div", { "data-testid": "badge-content", children: children }), jsxRuntime.jsx("div", { id: componentId, className: clsx(styles$u.badge, {
|
|
68
|
+
[styles$u['badge__empty']]: isEmpty,
|
|
69
|
+
[styles$u['badge__flex']]: displayValue.length >= 2,
|
|
69
70
|
}, className), "data-testid": "badge", children: !isEmpty && jsxRuntime.jsx("span", { "aria-hidden": !!ariaLabel, children: displayValue }) })] }));
|
|
70
71
|
}
|
|
71
|
-
return (jsxRuntime.jsx("div", { className: styles$
|
|
72
|
-
[styles$
|
|
73
|
-
[styles$
|
|
74
|
-
[styles$
|
|
72
|
+
return (jsxRuntime.jsx("div", { className: styles$u.badgeContainer, children: jsxRuntime.jsx("div", { className: clsx(styles$u['badge__status'], {
|
|
73
|
+
[styles$u['badge__status__empty']]: isEmpty,
|
|
74
|
+
[styles$u['badge__status__flex']]: displayValue.length >= 2,
|
|
75
|
+
[styles$u['badge__status__filterBadge']]: filterVariant,
|
|
75
76
|
}, className), "data-testid": "badge", children: !isEmpty && (jsxRuntime.jsx("span", { "aria-hidden": !!ariaLabel, children: displayValue })) }) }));
|
|
76
77
|
};
|
|
77
78
|
|
|
78
|
-
var styles$
|
|
79
|
+
var styles$t = {"tooltipContent":"Tooltip-module__tooltipContent___xycUg","triggerWrapper":"Tooltip-module__triggerWrapper___x83XR"};
|
|
79
80
|
|
|
80
81
|
const Tooltip = ({ children, text, side = 'bottom', align = 'start', maxWidth, sideOffset = 10, className, ...rest }) => {
|
|
81
|
-
return (jsxRuntime.jsx(radixUi.Tooltip.Provider, { children: jsxRuntime.jsxs(radixUi.Tooltip.Root, { children: [jsxRuntime.jsx(radixUi.Tooltip.Trigger, { asChild: true, children: jsxRuntime.jsx("span", { className: styles$
|
|
82
|
+
return (jsxRuntime.jsx(radixUi.Tooltip.Provider, { children: jsxRuntime.jsxs(radixUi.Tooltip.Root, { children: [jsxRuntime.jsx(radixUi.Tooltip.Trigger, { asChild: true, children: jsxRuntime.jsx("span", { className: styles$t.triggerWrapper, children: children }) }), jsxRuntime.jsx(radixUi.Tooltip.Portal, { children: jsxRuntime.jsx(radixUi.Tooltip.Content, { className: clsx(styles$t.tooltipContent, className), side: side, align: align, sideOffset: sideOffset, style: { maxWidth: maxWidth ? `${maxWidth}px` : 'auto' }, ...rest, children: text }) })] }) }));
|
|
82
83
|
};
|
|
83
84
|
|
|
84
|
-
var styles$
|
|
85
|
+
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"};
|
|
85
86
|
|
|
86
|
-
const Button =
|
|
87
|
+
const Button = ({ ref, 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 }) => {
|
|
87
88
|
const generatedId = React.useId();
|
|
88
89
|
const componentId = id || generatedId;
|
|
89
90
|
const getComponent = () => {
|
|
@@ -110,14 +111,14 @@ const Button = React.forwardRef(({ as, children, variant = 'filled', iconPositio
|
|
|
110
111
|
'Forneça um ícone via `icon={<MeuIcone />}`.');
|
|
111
112
|
}
|
|
112
113
|
const resolvedIcon = icon;
|
|
113
|
-
const buttonClasses = clsx(styles$
|
|
114
|
-
[styles$
|
|
115
|
-
[styles$
|
|
116
|
-
[styles$
|
|
117
|
-
[styles$
|
|
118
|
-
[styles$
|
|
119
|
-
[styles$
|
|
120
|
-
[styles$
|
|
114
|
+
const buttonClasses = clsx(styles$s.button, styles$s[`button-${variant}`], styles$s[`button-${size}`], {
|
|
115
|
+
[styles$s['disabled']]: disabled,
|
|
116
|
+
[styles$s['buttonLoading']]: loading,
|
|
117
|
+
[styles$s['buttonWithIcon']]: resolvedIcon && !iconOnly,
|
|
118
|
+
[styles$s[`buttonIconPosition-${iconPosition}`]]: resolvedIcon && !iconOnly,
|
|
119
|
+
[styles$s['buttonNoContent']]: resolvedIcon && !hasContent && !iconOnly,
|
|
120
|
+
[styles$s['buttonFullWidth']]: fullWidth,
|
|
121
|
+
[styles$s['buttonIconOnly']]: iconOnly,
|
|
121
122
|
}, className);
|
|
122
123
|
const getAriaLabel = () => {
|
|
123
124
|
if (ariaLabel)
|
|
@@ -143,12 +144,12 @@ const Button = React.forwardRef(({ as, children, variant = 'filled', iconPositio
|
|
|
143
144
|
};
|
|
144
145
|
const renderContent = () => {
|
|
145
146
|
if (iconOnly && !loading) {
|
|
146
|
-
return (jsxRuntime.jsx("span", { className: styles$
|
|
147
|
+
return (jsxRuntime.jsx("span", { className: styles$s.buttonIconOnly, "aria-hidden": "true", children: resolvedIcon }));
|
|
147
148
|
}
|
|
148
149
|
if (loading) {
|
|
149
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [!iconOnly && (jsxRuntime.jsxs("span", { className: styles$
|
|
150
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [!iconOnly && (jsxRuntime.jsxs("span", { className: styles$s.buttonContentHidden, "aria-hidden": "true", children: [resolvedIcon && (iconPosition === 'left' || iconPosition === 'both') && (jsxRuntime.jsx("span", { className: styles$s.buttonIconLeft, children: resolvedIcon })), children, resolvedIcon && (iconPosition === 'right' || iconPosition === 'both') && (jsxRuntime.jsx("span", { className: styles$s.buttonIconRight, children: resolvedIcon }))] })), jsxRuntime.jsx("span", { className: styles$s.buttonLoadingSpinner, "aria-hidden": "true", children: jsxRuntime.jsx(reactIcons.SpinnerIos16Regular, { "aria-hidden": "true" }) })] }));
|
|
150
151
|
}
|
|
151
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [resolvedIcon && (iconPosition === 'left' || iconPosition === 'both') && (jsxRuntime.jsx("span", { className: styles$
|
|
152
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [resolvedIcon && (iconPosition === 'left' || iconPosition === 'both') && (jsxRuntime.jsx("span", { className: styles$s.buttonIconLeft, "aria-hidden": "true", children: resolvedIcon })), children, resolvedIcon && (iconPosition === 'right' || iconPosition === 'both') && (jsxRuntime.jsx("span", { className: styles$s.buttonIconRight, "aria-hidden": "true", children: resolvedIcon }))] }));
|
|
152
153
|
};
|
|
153
154
|
const { style: externalStyle, ...otherRest } = rest;
|
|
154
155
|
const baseProps = {
|
|
@@ -199,7 +200,7 @@ const Button = React.forwardRef(({ as, children, variant = 'filled', iconPositio
|
|
|
199
200
|
return (jsxRuntime.jsx(Tooltip, { text: tooltipText, side: tooltipSide, align: tooltipAlign, children: jsxRuntime.jsx(Component, { ...baseProps, ...getNavigationProps(), children: renderContent() }) }));
|
|
200
201
|
}
|
|
201
202
|
return (jsxRuntime.jsx(Component, { ...baseProps, ...getNavigationProps(), children: renderContent() }));
|
|
202
|
-
}
|
|
203
|
+
};
|
|
203
204
|
Button.displayName = 'Button';
|
|
204
205
|
|
|
205
206
|
function buildFormatLongFn(args) {
|
|
@@ -1376,30 +1377,42 @@ const offsetFormatCache = {};
|
|
|
1376
1377
|
const offsetCache = {};
|
|
1377
1378
|
|
|
1378
1379
|
/**
|
|
1379
|
-
* The function
|
|
1380
|
+
* The function returns UTC offset in minutes for the given date in specified
|
|
1380
1381
|
* time zone.
|
|
1381
1382
|
*
|
|
1382
1383
|
* Unlike `Date.prototype.getTimezoneOffset`, this function returns the value
|
|
1383
1384
|
* mirrored to the sign of the offset in the time zone. For Asia/Singapore
|
|
1384
|
-
* (UTC+8), `tzOffset` returns 480
|
|
1385
|
+
* (UTC+8), `tzOffset` returns `480`, while `getTimezoneOffset` returns `-480`.
|
|
1385
1386
|
*
|
|
1386
|
-
*
|
|
1387
|
-
*
|
|
1387
|
+
* It uses `Intl.DateTimeFormat` internally to access otherwise unavailable
|
|
1388
|
+
* runtime's time zone data, and falls back to basic manual parsing if Intl API
|
|
1389
|
+
* is not supported (e.g., older Node.js versions, React Native's Hermes, etc.).
|
|
1388
1390
|
*
|
|
1389
|
-
* @
|
|
1391
|
+
* @param timeZone - Time zone name (IANA or UTC offset).
|
|
1392
|
+
* @param date - Date to check the offset for.
|
|
1393
|
+
*
|
|
1394
|
+
* @returns UTC offset in minutes (e.g., `480` for date in UTC+8).
|
|
1390
1395
|
*/
|
|
1391
1396
|
function tzOffset(timeZone, date) {
|
|
1392
1397
|
try {
|
|
1398
|
+
// Create `Intl.DateTimeFormat` with `"longOffset"` that gives us consistent
|
|
1399
|
+
// date strings like `"5/19/2026, GMT-08:00"`.
|
|
1393
1400
|
const format = offsetFormatCache[timeZone] ||= new Intl.DateTimeFormat("en-US", {
|
|
1394
1401
|
timeZone,
|
|
1395
1402
|
timeZoneName: "longOffset"
|
|
1396
1403
|
}).format;
|
|
1404
|
+
|
|
1405
|
+
// Get `"-08:00"`.
|
|
1397
1406
|
const offsetStr = format(date).split("GMT")[1];
|
|
1407
|
+
|
|
1408
|
+
// Avoid parsing the same offset string.
|
|
1398
1409
|
if (offsetStr in offsetCache) return offsetCache[offsetStr];
|
|
1410
|
+
|
|
1411
|
+
// Calculate offset from `["-08", "00"]` and cache it.
|
|
1399
1412
|
return calcOffset(offsetStr, offsetStr.split(":"));
|
|
1400
1413
|
} catch {
|
|
1401
|
-
// Fallback to manual parsing if the runtime doesn't support
|
|
1402
|
-
// See: https://github.com/nodejs/node/issues/53419
|
|
1414
|
+
// Fallback to manual parsing if the runtime doesn't support
|
|
1415
|
+
// `±HH:MM/±HHMM/±HH`. See: https://github.com/nodejs/node/issues/53419.
|
|
1403
1416
|
if (timeZone in offsetCache) return offsetCache[timeZone];
|
|
1404
1417
|
const captures = timeZone?.match(offsetRe);
|
|
1405
1418
|
if (captures) return calcOffset(timeZone, captures.slice(1));
|
|
@@ -1415,30 +1428,69 @@ function calcOffset(cacheStr, values) {
|
|
|
1415
1428
|
return offsetCache[cacheStr] = hours * 60 + minutes > 0 ? hours * 60 + minutes + seconds : hours * 60 - minutes - seconds;
|
|
1416
1429
|
}
|
|
1417
1430
|
|
|
1431
|
+
// TZDate stores time in two `Date` objects because native `Date` can only
|
|
1432
|
+
// expose local fields in the system time zone.
|
|
1433
|
+
//
|
|
1434
|
+
// The external date (`this`) stores the real timestamp. It is the value used by
|
|
1435
|
+
// `getTime()`, `valueOf()`, UTC getters/setters, comparisons, and arithmetic.
|
|
1436
|
+
// Its local getters are not used for target-zone fields because they would read
|
|
1437
|
+
// the timestamp through the system time zone.
|
|
1438
|
+
//
|
|
1439
|
+
// The internal date (`this.internal`) stores the target-zone wall-clock fields.
|
|
1440
|
+
// We read and write those fields through UTC getters/setters so the host system
|
|
1441
|
+
// time zone cannot reinterpret them. For example, `getHours()` returns
|
|
1442
|
+
// `internal.getUTCHours()`, and `setHours()` writes `internal.setUTCHours(...)`.
|
|
1443
|
+
//
|
|
1444
|
+
// Syncing moves data between the two representations:
|
|
1445
|
+
//
|
|
1446
|
+
// - `syncToInternal` starts from the external timestamp and rebuilds internal
|
|
1447
|
+
// wall-clock fields using `this.timeZone` offset.
|
|
1448
|
+
//
|
|
1449
|
+
// - `syncFromInternal` starts from internal wall-clock fields, writes them into
|
|
1450
|
+
// the external date, then adjusts that timestamp for the system/target offset
|
|
1451
|
+
// difference and DST edge cases.
|
|
1452
|
+
//
|
|
1453
|
+
// The public TZDate value is the combination of both: external is the instant,
|
|
1454
|
+
// internal is the wall-clock view of that instant in `this.timeZone`.
|
|
1455
|
+
|
|
1418
1456
|
class TZDateMini extends Date {
|
|
1419
1457
|
//#region static
|
|
1420
1458
|
|
|
1421
1459
|
constructor(...args) {
|
|
1422
1460
|
super();
|
|
1461
|
+
|
|
1462
|
+
// Time zone string is always the last string argument unless date string
|
|
1463
|
+
// is passed (as a single argument).
|
|
1423
1464
|
if (args.length > 1 && typeof args[args.length - 1] === "string") {
|
|
1424
1465
|
this.timeZone = args.pop();
|
|
1425
1466
|
}
|
|
1426
1467
|
this.internal = new Date();
|
|
1468
|
+
|
|
1469
|
+
// Validate the time zone by checking its offset.
|
|
1427
1470
|
if (isNaN(tzOffset(this.timeZone, this))) {
|
|
1428
1471
|
this.setTime(NaN);
|
|
1429
1472
|
} else {
|
|
1430
1473
|
if (!args.length) {
|
|
1474
|
+
// No arguments passed: use current time
|
|
1431
1475
|
this.setTime(Date.now());
|
|
1432
1476
|
} else if (typeof args[0] === "number" && (args.length === 1 || args.length === 2 && typeof args[1] !== "number")) {
|
|
1477
|
+
// Timestamp passed: use it as is
|
|
1433
1478
|
this.setTime(args[0]);
|
|
1434
1479
|
} else if (typeof args[0] === "string") {
|
|
1480
|
+
// `Date` string passed: parse it as external date
|
|
1435
1481
|
this.setTime(+new Date(args[0]));
|
|
1436
1482
|
} else if (args[0] instanceof Date) {
|
|
1483
|
+
// `Date` passed: use its timestamp
|
|
1437
1484
|
this.setTime(+args[0]);
|
|
1438
1485
|
} else {
|
|
1486
|
+
// `Date` values passed:
|
|
1487
|
+
|
|
1488
|
+
// Set it as external date.
|
|
1439
1489
|
this.setTime(+new Date(...args));
|
|
1440
|
-
|
|
1441
|
-
|
|
1490
|
+
|
|
1491
|
+
// Adjust internal and external dates considering that we might have
|
|
1492
|
+
// landed on the DST hour.
|
|
1493
|
+
adjustToSystemTZ(this, args);
|
|
1442
1494
|
}
|
|
1443
1495
|
}
|
|
1444
1496
|
}
|
|
@@ -1455,8 +1507,8 @@ class TZDateMini extends Date {
|
|
|
1455
1507
|
}
|
|
1456
1508
|
getTimezoneOffset() {
|
|
1457
1509
|
const offset = -tzOffset(this.timeZone, this);
|
|
1458
|
-
// Remove the seconds offset
|
|
1459
|
-
//
|
|
1510
|
+
// Remove the seconds offset using `Math.floor` for negative UTC time zones
|
|
1511
|
+
// and `Math.ceil` for positive UTC time zones.
|
|
1460
1512
|
return offset > 0 ? Math.floor(offset) : Math.ceil(offset);
|
|
1461
1513
|
}
|
|
1462
1514
|
|
|
@@ -1464,8 +1516,11 @@ class TZDateMini extends Date {
|
|
|
1464
1516
|
|
|
1465
1517
|
//#region time
|
|
1466
1518
|
|
|
1467
|
-
setTime(
|
|
1519
|
+
setTime(_time) {
|
|
1520
|
+
// Use the native `setTime` to the external date time.
|
|
1468
1521
|
Date.prototype.setTime.apply(this, arguments);
|
|
1522
|
+
|
|
1523
|
+
// Then apply it to the internal date adjusting to the timezone offset.
|
|
1469
1524
|
syncToInternal(this);
|
|
1470
1525
|
return +this;
|
|
1471
1526
|
}
|
|
@@ -1511,23 +1566,40 @@ Object.getOwnPropertyNames(Date.prototype).forEach(method => {
|
|
|
1511
1566
|
});
|
|
1512
1567
|
|
|
1513
1568
|
/**
|
|
1514
|
-
*
|
|
1569
|
+
* @internal
|
|
1570
|
+
* Function syncs time to internal date, applying the current time zone offset.
|
|
1515
1571
|
*
|
|
1516
|
-
* @param {Date} date - Date to sync
|
|
1572
|
+
* @param {Date} date - `Date` to sync
|
|
1517
1573
|
*/
|
|
1518
1574
|
function syncToInternal(date) {
|
|
1575
|
+
// Start internal from the same real timestamp as external.
|
|
1519
1576
|
date.internal.setTime(+date);
|
|
1520
|
-
|
|
1577
|
+
|
|
1578
|
+
// Shift internal by the target offset so its UTC fields become the target-zone
|
|
1579
|
+
// wall-clock fields for the external timestamp.
|
|
1580
|
+
//
|
|
1581
|
+
// o internal UTC fields: 2024-02-11 00:00
|
|
1582
|
+
// |
|
|
1583
|
+
// | + Asia/Singapore offset (+08:00)
|
|
1584
|
+
// v
|
|
1585
|
+
// x internal UTC fields: 2024-02-11 08:00
|
|
1586
|
+
//
|
|
1587
|
+
date.internal.setUTCSeconds(date.internal.getUTCSeconds() -
|
|
1588
|
+
// Round after converting minutes to seconds to avoid fractional offset
|
|
1589
|
+
// precision errors from historical offsets.
|
|
1590
|
+
Math.round(-tzOffset(date.timeZone, date) * 60));
|
|
1521
1591
|
}
|
|
1522
1592
|
|
|
1523
1593
|
/**
|
|
1524
|
-
*
|
|
1525
|
-
*
|
|
1594
|
+
* @internal
|
|
1595
|
+
* Function syncs internal wall-clock fields into the external date.
|
|
1526
1596
|
*
|
|
1527
1597
|
* @param {Date} date - The date to sync
|
|
1528
1598
|
*/
|
|
1529
1599
|
function syncFromInternal(date) {
|
|
1530
|
-
//
|
|
1600
|
+
// Copy target-zone wall-clock fields from internal into external using native
|
|
1601
|
+
// local setters. At this point external holds the right field values but they
|
|
1602
|
+
// are interpreted in the system time zone; `adjustToSystemTZ` fixes that.
|
|
1531
1603
|
Date.prototype.setFullYear.call(date, date.internal.getUTCFullYear(), date.internal.getUTCMonth(), date.internal.getUTCDate());
|
|
1532
1604
|
Date.prototype.setHours.call(date, date.internal.getUTCHours(), date.internal.getUTCMinutes(), date.internal.getUTCSeconds(), date.internal.getUTCMilliseconds());
|
|
1533
1605
|
|
|
@@ -1536,115 +1608,271 @@ function syncFromInternal(date) {
|
|
|
1536
1608
|
}
|
|
1537
1609
|
|
|
1538
1610
|
/**
|
|
1611
|
+
* @internal
|
|
1539
1612
|
* Function adjusts the date to the system time zone. It uses the time zone
|
|
1540
1613
|
* differences to calculate the offset and adjust the date.
|
|
1541
1614
|
*
|
|
1542
|
-
*
|
|
1615
|
+
* We use it when constructing `TZDate` and syncing the external date from
|
|
1616
|
+
* the internal one.
|
|
1617
|
+
*
|
|
1618
|
+
* @param {TZDate} date - `TZDate` to adjust.
|
|
1543
1619
|
*/
|
|
1544
|
-
function adjustToSystemTZ(date) {
|
|
1545
|
-
//
|
|
1546
|
-
|
|
1547
|
-
//
|
|
1548
|
-
|
|
1549
|
-
|
|
1620
|
+
function adjustToSystemTZ(date, constructorArgs) {
|
|
1621
|
+
// Keep the intended target-zone wall-clock value before native Date/system
|
|
1622
|
+
// time zone normalization can move it. Later corrections compare against this
|
|
1623
|
+
// value to distinguish intended DST normalization from accidental drift.
|
|
1624
|
+
const expectedInternalTime = Array.isArray(constructorArgs) ? constructorArgsToInternalTime(constructorArgs) : +date.internal;
|
|
1625
|
+
//#region Initial offset calculation
|
|
1626
|
+
|
|
1627
|
+
// Current target time zone offset at the native timestamp. It may include
|
|
1628
|
+
// historical offset seconds, which we preserve for the seconds adjustment.
|
|
1629
|
+
const offsetWithSeconds = tzOffset(date.timeZone, date);
|
|
1630
|
+
|
|
1631
|
+
// Minute-precision target offset used by minute-based timestamp adjustments.
|
|
1632
|
+
// Historical offsets can contain seconds, so we strip the fractional minute
|
|
1633
|
+
// here and handle remaining seconds in the seconds adjustment below.
|
|
1634
|
+
const offset = offsetWithSeconds > 0 ? Math.floor(offsetWithSeconds) : Math.ceil(offsetWithSeconds);
|
|
1635
|
+
|
|
1636
|
+
//#endregion
|
|
1637
|
+
|
|
1550
1638
|
//#region System DST adjustment
|
|
1551
1639
|
|
|
1552
|
-
//
|
|
1553
|
-
//
|
|
1554
|
-
// up on the DST hour:
|
|
1555
|
-
//
|
|
1556
|
-
// $ TZ=America/New_York node
|
|
1557
|
-
// > new Date(2020, 2, 8, 1).toString()
|
|
1558
|
-
// 'Sun Mar 08 2020 01:00:00 GMT-0500 (Eastern Standard Time)'
|
|
1559
|
-
// > new Date(2020, 2, 8, 2).toString()
|
|
1560
|
-
// 'Sun Mar 08 2020 03:00:00 GMT-0400 (Eastern Daylight Time)'
|
|
1561
|
-
// > new Date(2020, 2, 8, 3).toString()
|
|
1562
|
-
// 'Sun Mar 08 2020 03:00:00 GMT-0400 (Eastern Daylight Time)'
|
|
1563
|
-
// > new Date(2020, 2, 8, 4).toString()
|
|
1564
|
-
// 'Sun Mar 08 2020 04:00:00 GMT-0400 (Eastern Daylight Time)'
|
|
1640
|
+
// Native `Date` may normalize the requested wall time when the system time
|
|
1641
|
+
// zone skips that hour for DST.
|
|
1565
1642
|
//
|
|
1566
|
-
//
|
|
1567
|
-
//
|
|
1568
|
-
//
|
|
1569
|
-
//
|
|
1570
|
-
// However we want to adjust only if that's the DST hour the change happenes,
|
|
1571
|
-
// not the hour where DST moves to.
|
|
1643
|
+
// We compare the system wall-clock hour represented by the external date with
|
|
1644
|
+
// the wall-clock hour stored in the internal date. If they differ, the next
|
|
1645
|
+
// offset-diff calculation may need the previous system offset, because the
|
|
1646
|
+
// current external timestamp is already after the system DST jump.
|
|
1572
1647
|
|
|
1573
|
-
//
|
|
1574
|
-
//
|
|
1648
|
+
// Previous-hour reference used to detect whether the system offset changed
|
|
1649
|
+
// immediately before the current native timestamp.
|
|
1575
1650
|
const prevHour = new Date(+date);
|
|
1576
|
-
|
|
1577
|
-
//
|
|
1651
|
+
|
|
1652
|
+
// Use UTC math so subtracting one hour cannot be normalized back into the
|
|
1653
|
+
// same missing local DST hour.
|
|
1578
1654
|
prevHour.setUTCHours(prevHour.getUTCHours() - 1);
|
|
1579
1655
|
|
|
1580
|
-
//
|
|
1656
|
+
// Current system offset at the native timestamp.
|
|
1581
1657
|
const systemOffset = -new Date(+date).getTimezoneOffset();
|
|
1658
|
+
|
|
1659
|
+
// System offset one real hour before the native timestamp.
|
|
1582
1660
|
const prevHourSystemOffset = -new Date(+prevHour).getTimezoneOffset();
|
|
1661
|
+
|
|
1662
|
+
// Non-zero when the system offset changed between `prevHour` and `date`.
|
|
1583
1663
|
const systemDSTChange = systemOffset - prevHourSystemOffset;
|
|
1584
|
-
// Detect the DST shift. System DST change will occur both on
|
|
1585
|
-
const dstShift = Date.prototype.getHours.apply(date) !== date.internal.getUTCHours();
|
|
1586
1664
|
|
|
1587
|
-
//
|
|
1588
|
-
|
|
1665
|
+
// System offset to use in the later system-target offset difference.
|
|
1666
|
+
// Defaults to the current system offset and switches to the previous offset
|
|
1667
|
+
// only when native `Date` normalized a missing system wall time.
|
|
1668
|
+
let systemOffsetForDiff = systemOffset;
|
|
1669
|
+
if (systemDSTChange && systemOffset !== offset) {
|
|
1670
|
+
// System wall-clock hour represented by the current external timestamp.
|
|
1671
|
+
const systemHour = Date.prototype.getHours.apply(date);
|
|
1672
|
+
|
|
1673
|
+
// Target wall-clock hour currently stored in internal fields. Constructors
|
|
1674
|
+
// get it from arguments because internal may have already been synced from
|
|
1675
|
+
// the normalized external timestamp; setters get it directly from internal.
|
|
1676
|
+
const expectedHour = Array.isArray(constructorArgs) ? constructorArgs[3] || 0 : date.internal.getUTCHours();
|
|
1677
|
+
if (systemHour !== expectedHour) {
|
|
1678
|
+
// Check whether using the current system offset would keep the target
|
|
1679
|
+
// offset unchanged. If so, the only DST jump we crossed is the system
|
|
1680
|
+
// one, so the diff should use the pre-DST system offset.
|
|
1681
|
+
const testDate = new Date(+date);
|
|
1682
|
+
|
|
1683
|
+
// Difference that the later offset-diff step would apply with the
|
|
1684
|
+
// current system offset.
|
|
1685
|
+
const testOffsetDiff = systemOffset - offset;
|
|
1686
|
+
if (testOffsetDiff) testDate.setUTCMinutes(testDate.getUTCMinutes() + testOffsetDiff);
|
|
1687
|
+
|
|
1688
|
+
// Target offset after applying the current system offset difference.
|
|
1689
|
+
const testOffsetWithSeconds = tzOffset(date.timeZone, testDate);
|
|
1690
|
+
|
|
1691
|
+
// Target offset without historical seconds, matching `offset`.
|
|
1692
|
+
const testOffset = testOffsetWithSeconds > 0 ? Math.floor(testOffsetWithSeconds) : Math.ceil(testOffsetWithSeconds);
|
|
1693
|
+
if (testOffset === offset) systemOffsetForDiff = prevHourSystemOffset;
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1589
1696
|
|
|
1590
1697
|
//#endregion
|
|
1591
1698
|
|
|
1592
1699
|
//#region System diff adjustment
|
|
1593
1700
|
|
|
1594
|
-
//
|
|
1595
|
-
//
|
|
1596
|
-
//
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1701
|
+
// Move external from the system-zone interpretation of internal fields toward
|
|
1702
|
+
// the timestamp that represents those fields in the target time zone.
|
|
1703
|
+
//
|
|
1704
|
+
// At this point native `Date` has treated the internal wall-clock fields as if
|
|
1705
|
+
// they belonged to the system zone. The system-target offset difference moves
|
|
1706
|
+
// external by the distance between that system interpretation and the target
|
|
1707
|
+
// interpretation.
|
|
1708
|
+
|
|
1709
|
+
// Difference between the system offset selected above and the minute-precision
|
|
1710
|
+
// target offset. Positive values move external forward; negative values move
|
|
1711
|
+
// it backward.
|
|
1712
|
+
const offsetDiff = systemOffsetForDiff - offset;
|
|
1713
|
+
if (offsetDiff)
|
|
1714
|
+
// Apply the system-target minute difference to external. Internal is
|
|
1715
|
+
// rebuilt from the final external timestamp after all adjustments are
|
|
1716
|
+
// complete.
|
|
1717
|
+
//
|
|
1718
|
+
// o external as target: 2023-01-31 23:00
|
|
1719
|
+
// |
|
|
1720
|
+
// | add `offsetDiff`
|
|
1721
|
+
// v
|
|
1722
|
+
// x external as target: 2023-02-01 12:00
|
|
1723
|
+
//
|
|
1724
|
+
Date.prototype.setUTCMinutes.call(date, Date.prototype.getUTCMinutes.call(date) + offsetDiff);
|
|
1600
1725
|
|
|
1601
1726
|
//#endregion
|
|
1602
1727
|
|
|
1603
|
-
//#region Seconds
|
|
1728
|
+
//#region Seconds system diff adjustment
|
|
1604
1729
|
|
|
1730
|
+
// Historical time zone offsets can include seconds, but the minute-based
|
|
1731
|
+
// offset adjustment above intentionally used minute precision.
|
|
1732
|
+
//
|
|
1733
|
+
// This adjustment applies the remaining seconds difference to external. For
|
|
1734
|
+
// example, historical Singapore used UTC+06:55:25, while ISO formatting shows
|
|
1735
|
+
// only `+06:55`; without the seconds correction, setter paths keep the wrong
|
|
1736
|
+
// wall-clock seconds.
|
|
1737
|
+
|
|
1738
|
+
// Clone external as a native `Date` so we can inspect how the system time zone
|
|
1739
|
+
// represents the same timestamp.
|
|
1605
1740
|
const systemDate = new Date(+date);
|
|
1606
|
-
|
|
1741
|
+
|
|
1742
|
+
// Zero UTC seconds before reading system seconds. Any remaining local seconds
|
|
1743
|
+
// then come from the system time zone offset rather than from the timestamp's
|
|
1744
|
+
// own seconds value.
|
|
1607
1745
|
systemDate.setUTCSeconds(0);
|
|
1608
|
-
|
|
1746
|
+
|
|
1747
|
+
// Seconds part contributed by the system time zone offset. Negative offsets
|
|
1748
|
+
// need wrapping because `Date#getSeconds()` returns values in the 0..59 range.
|
|
1609
1749
|
const systemSecondsOffset = systemOffset > 0 ? systemDate.getSeconds() : (systemDate.getSeconds() - 60) % 60;
|
|
1610
1750
|
|
|
1611
|
-
//
|
|
1751
|
+
// Seconds part contributed by the target time zone offset.
|
|
1612
1752
|
const secondsOffset = Math.round(-(tzOffset(date.timeZone, date) * 60)) % 60;
|
|
1613
|
-
if (secondsOffset || systemSecondsOffset)
|
|
1614
|
-
|
|
1753
|
+
if (secondsOffset || systemSecondsOffset)
|
|
1754
|
+
// Apply the remaining second-level system-target difference to external.
|
|
1755
|
+
//
|
|
1756
|
+
// o external as Asia/Singapore: 1900-01-01 00:00:56
|
|
1757
|
+
// |
|
|
1758
|
+
// | + `secondsOffset`
|
|
1759
|
+
// | + `systemSecondsOffset`
|
|
1760
|
+
// v
|
|
1761
|
+
// x external as Asia/Singapore: 1900-01-01 00:00:31
|
|
1762
|
+
//
|
|
1615
1763
|
Date.prototype.setUTCSeconds.call(date, Date.prototype.getUTCSeconds.call(date) + secondsOffset + systemSecondsOffset);
|
|
1616
|
-
}
|
|
1617
1764
|
|
|
1618
1765
|
//#endregion
|
|
1619
1766
|
|
|
1620
1767
|
//#region Post-adjustment DST fix
|
|
1621
1768
|
|
|
1622
|
-
|
|
1623
|
-
//
|
|
1624
|
-
//
|
|
1625
|
-
|
|
1769
|
+
// The first system-target offset move can cross a target-zone DST boundary.
|
|
1770
|
+
//
|
|
1771
|
+
// When that happens, the target offset at the new external timestamp differs
|
|
1772
|
+
// from the target offset used for `offsetDiff`. We compare the original move
|
|
1773
|
+
// with the move that would be calculated at the new timestamp, then apply the
|
|
1774
|
+
// difference to external.
|
|
1775
|
+
|
|
1776
|
+
// Target offset at the current external timestamp, including historical
|
|
1777
|
+
// seconds for the later seconds adjustment.
|
|
1778
|
+
const postOffsetWithSeconds = tzOffset(date.timeZone, date);
|
|
1779
|
+
|
|
1780
|
+
// Minute-precision target offset at the current external timestamp.
|
|
1781
|
+
const postOffset = postOffsetWithSeconds > 0 ? Math.floor(postOffsetWithSeconds) : Math.ceil(postOffsetWithSeconds);
|
|
1782
|
+
|
|
1783
|
+
// System offset at the current external timestamp.
|
|
1626
1784
|
const postSystemOffset = -new Date(+date).getTimezoneOffset();
|
|
1785
|
+
|
|
1786
|
+
// System-target offset difference at the current external timestamp.
|
|
1627
1787
|
const postOffsetDiff = postSystemOffset - postOffset;
|
|
1788
|
+
|
|
1789
|
+
// Whether the target offset changed after the first offset move.
|
|
1628
1790
|
const offsetChanged = postOffset !== offset;
|
|
1791
|
+
|
|
1792
|
+
// Difference between the current offset move and the move already applied.
|
|
1629
1793
|
const postDiff = postOffsetDiff - offsetDiff;
|
|
1630
|
-
|
|
1794
|
+
|
|
1795
|
+
// If the first offset move already normalized a target DST gap forward, the
|
|
1796
|
+
// generic post-DST correction below would undo that valid normalization. This
|
|
1797
|
+
// happens, for example, with America/New_York 02:00 during spring-forward when
|
|
1798
|
+
// the system zone also changes offset around the same instant.
|
|
1799
|
+
const targetDSTShift = postOffset - offset;
|
|
1800
|
+
|
|
1801
|
+
// Candidate timestamp that would represent the requested wall-clock time with
|
|
1802
|
+
// the post-transition target offset. If it still does not round-trip to the
|
|
1803
|
+
// requested wall-clock fields, the requested time is inside a target DST gap.
|
|
1804
|
+
const postOffsetCandidate = expectedInternalTime - postOffset * 60 * 1000;
|
|
1805
|
+
|
|
1806
|
+
// Only positive target offset shifts are spring-forward gaps. Negative shifts
|
|
1807
|
+
// are fall-back overlaps and still need the regular post-adjustment path.
|
|
1808
|
+
const normalizedTargetDSTGap = targetDSTShift > 0 && targetInternalTime(date) - expectedInternalTime === targetDSTShift * 60 * 1000 && targetInternalTime(date, postOffsetCandidate) !== expectedInternalTime;
|
|
1809
|
+
if (offsetChanged && postDiff && !normalizedTargetDSTGap) {
|
|
1810
|
+
// Apply the target-DST correction to external. In the backward-crossing case
|
|
1811
|
+
// shown here, this lands on an intermediate value that needs `offsetChange`
|
|
1812
|
+
// below.
|
|
1813
|
+
//
|
|
1814
|
+
// o external as America/New_York: 2023-03-12 03:00 EDT
|
|
1815
|
+
// |
|
|
1816
|
+
// | + `postDiff`
|
|
1817
|
+
// v
|
|
1818
|
+
// x external as America/New_York: 2023-03-12 01:00 EST
|
|
1819
|
+
//
|
|
1631
1820
|
Date.prototype.setUTCMinutes.call(date, Date.prototype.getUTCMinutes.call(date) + postDiff);
|
|
1632
1821
|
|
|
1633
|
-
//
|
|
1634
|
-
//
|
|
1822
|
+
// Target offset after applying `postDiff`. It may change again if the
|
|
1823
|
+
// correction itself crosses a target-zone DST boundary.
|
|
1824
|
+
const newOffsetWithSeconds = tzOffset(date.timeZone, date);
|
|
1825
|
+
|
|
1826
|
+
// Minute-precision target offset after applying `postDiff`.
|
|
1827
|
+
const newOffset = newOffsetWithSeconds > 0 ? Math.floor(newOffsetWithSeconds) : Math.ceil(newOffsetWithSeconds);
|
|
1635
1828
|
|
|
1636
|
-
|
|
1637
|
-
// Remove the seconds offset
|
|
1638
|
-
// use Math.floor for negative GMT timezones and Math.ceil for positive GMT timezones.
|
|
1639
|
-
const newOffset = newBaseOffset > 0 ? Math.floor(newBaseOffset) : Math.ceil(newBaseOffset);
|
|
1829
|
+
// Offset change caused by the `postDiff` move itself.
|
|
1640
1830
|
const offsetChange = postOffset - newOffset;
|
|
1641
|
-
|
|
1642
|
-
|
|
1831
|
+
|
|
1832
|
+
// If the correction moved external backward across the target DST boundary,
|
|
1833
|
+
// apply the boundary change so external lands on the valid target-zone
|
|
1834
|
+
// timestamp. Forward crossings are already normalized by native Date, and
|
|
1835
|
+
// applying this correction there would undo the valid post-DST result.
|
|
1836
|
+
if (offsetChange && postDiff < 0) {
|
|
1837
|
+
// Apply the second target-DST correction to external.
|
|
1838
|
+
//
|
|
1839
|
+
// o external as America/New_York: 2023-03-12 01:00 EST
|
|
1840
|
+
// |
|
|
1841
|
+
// | + `offsetChange`
|
|
1842
|
+
// v
|
|
1843
|
+
// x external as America/New_York: 2023-03-12 03:00 EDT
|
|
1844
|
+
//
|
|
1643
1845
|
Date.prototype.setUTCMinutes.call(date, Date.prototype.getUTCMinutes.call(date) + offsetChange);
|
|
1644
1846
|
}
|
|
1645
1847
|
}
|
|
1646
1848
|
|
|
1647
1849
|
//#endregion
|
|
1850
|
+
|
|
1851
|
+
// Rebuild internal wall-clock fields from the final external timestamp.
|
|
1852
|
+
syncToInternal(date);
|
|
1853
|
+
|
|
1854
|
+
// Native Date can normalize historical system offsets with minute and second
|
|
1855
|
+
// precision before we adjust to the target time zone. Correct only small
|
|
1856
|
+
// historical drift so DST gap normalization (usually one hour) remains intact.
|
|
1857
|
+
const expectedTime = constructorArgs ? expectedInternalTime : expectedInternalTime + secondsOffset * 1000;
|
|
1858
|
+
const drift = expectedTime - +date.internal;
|
|
1859
|
+
if (drift && Math.abs(drift) < 30 * 60 * 1000) {
|
|
1860
|
+
Date.prototype.setTime.call(date, +date + drift);
|
|
1861
|
+
syncToInternal(date);
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1864
|
+
function constructorArgsToInternalTime(args) {
|
|
1865
|
+
// Mirror Date's date-value constructor defaults while preserving explicit
|
|
1866
|
+
// `undefined` behavior. Missing month/day default, but passed `undefined`
|
|
1867
|
+
// should remain invalid just like `Date.UTC(year, undefined, ...)`.
|
|
1868
|
+
return Date.UTC(args[0], args.length > 1 ? args[1] : 0, args.length > 2 ? args[2] : 1, ...args.slice(3));
|
|
1869
|
+
}
|
|
1870
|
+
function targetInternalTime(date, time) {
|
|
1871
|
+
// Compute the target-zone wall-clock representation for a timestamp without
|
|
1872
|
+
// mutating the TZDate. This mirrors syncToInternal for temporary checks.
|
|
1873
|
+
const internal = new Date(time ?? +date);
|
|
1874
|
+
internal.setUTCSeconds(internal.getUTCSeconds() - Math.round(-tzOffset(date.timeZone, internal) * 60));
|
|
1875
|
+
return +internal;
|
|
1648
1876
|
}
|
|
1649
1877
|
|
|
1650
1878
|
class TZDate extends TZDateMini {
|
|
@@ -2458,7 +2686,7 @@ const ptBR = {
|
|
|
2458
2686
|
},
|
|
2459
2687
|
};
|
|
2460
2688
|
|
|
2461
|
-
var styles$
|
|
2689
|
+
var styles$r = {"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_middle":"Calendar-module__range_middle___Uv4gt","range_start":"Calendar-module__range_start___c1eNH","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","chevron_wrapper":"Calendar-module__chevron_wrapper___BfN9a"};
|
|
2462
2690
|
|
|
2463
2691
|
const FLUENT_CHEVRON_MAP = {
|
|
2464
2692
|
down: reactIcons.ChevronDown16Regular,
|
|
@@ -2468,7 +2696,7 @@ const FLUENT_CHEVRON_MAP = {
|
|
|
2468
2696
|
};
|
|
2469
2697
|
const CustomChevron = ({ orientation = "left", className, }) => {
|
|
2470
2698
|
const Icon = FLUENT_CHEVRON_MAP[orientation];
|
|
2471
|
-
return jsxRuntime.jsx("span", { className: styles$
|
|
2699
|
+
return jsxRuntime.jsx("span", { className: styles$r.chevron_wrapper, children: jsxRuntime.jsx(Icon, { className: className, "aria-hidden": true }) });
|
|
2472
2700
|
};
|
|
2473
2701
|
const GridCtx = React.createContext(null);
|
|
2474
2702
|
const GridMonthCaption = ({ calendarMonth, displayIndex: _displayIndex, ...divProps }) => {
|
|
@@ -2477,18 +2705,22 @@ const GridMonthCaption = ({ calendarMonth, displayIndex: _displayIndex, ...divPr
|
|
|
2477
2705
|
const date = calendarMonth.date;
|
|
2478
2706
|
const monthLabel = new Intl.DateTimeFormat(intlLocale, { month: "long" }).format(date);
|
|
2479
2707
|
const yearLabel = String(date.getFullYear());
|
|
2480
|
-
return (jsxRuntime.jsxs("div", { ...divProps, children: [jsxRuntime.jsx("span", { className: styles$
|
|
2708
|
+
return (jsxRuntime.jsxs("div", { ...divProps, children: [jsxRuntime.jsx("span", { className: styles$r.caption_grid_label, children: monthLabel }), jsxRuntime.jsxs("button", { type: "button", className: styles$r.caption_grid_btn, "aria-pressed": view === "years", onClick: onYearLabelClick, children: [yearLabel, view !== "days" ? (jsxRuntime.jsx("span", { className: styles$r.chevron_wrapper, children: jsxRuntime.jsx(reactIcons.ChevronUp16Regular, { className: styles$r.caption_year_chevron, "aria-hidden": true }) })) : (jsxRuntime.jsx("span", { className: styles$r.chevron_wrapper, children: jsxRuntime.jsx(reactIcons.ChevronDown16Regular, { className: styles$r.caption_year_chevron, "aria-hidden": true }) }))] })] }));
|
|
2481
2709
|
};
|
|
2482
2710
|
const YEARS_PER_PAGE = 20;
|
|
2483
|
-
const Calendar = ({ selected, currentDate, defaultMonth, startMonth, endMonth, onDaySelect, onDateChange, onClear
|
|
2711
|
+
const Calendar = ({ mode = "single", selected, selectedRange, currentDate, defaultMonth, startMonth, endMonth, onDaySelect, onRangeSelect, onDateChange, onClear, minDate, maxDate, disabled, format: _format, locale = "pt-br", autoFocus, numberOfMonths, className, style, scale = 1, id, "aria-label": ariaLabel, ...rest }) => {
|
|
2484
2712
|
const animate = true;
|
|
2485
2713
|
const [internalSelected, setInternalSelected] = React.useState(selected ?? undefined);
|
|
2714
|
+
const [internalRange, setInternalRange] = React.useState(selectedRange ?? undefined);
|
|
2486
2715
|
const [internalDisplayMonth, setInternalDisplayMonth] = React.useState(() => currentDate ?? defaultMonth ?? new Date());
|
|
2487
2716
|
const [gridView, setGridView] = React.useState("days");
|
|
2488
2717
|
const [yearPageStart, setYearPageStart] = React.useState(() => (currentDate ?? defaultMonth ?? new Date()).getFullYear() - 9);
|
|
2489
2718
|
const resolvedSelected = selected !== undefined
|
|
2490
2719
|
? (selected ?? undefined)
|
|
2491
2720
|
: internalSelected;
|
|
2721
|
+
const resolvedRange = selectedRange !== undefined
|
|
2722
|
+
? (selectedRange ?? undefined)
|
|
2723
|
+
: internalRange;
|
|
2492
2724
|
const resolvedLocale = locale === "pt-br" ? ptBR : enUS;
|
|
2493
2725
|
const intlLocale = locale === "pt-br" ? "pt-BR" : "en-US";
|
|
2494
2726
|
const disabledMatchers = [
|
|
@@ -2501,6 +2733,33 @@ const Calendar = ({ selected, currentDate, defaultMonth, startMonth, endMonth, o
|
|
|
2501
2733
|
if (date) {
|
|
2502
2734
|
onDaySelect?.(date);
|
|
2503
2735
|
}
|
|
2736
|
+
else {
|
|
2737
|
+
onClear?.();
|
|
2738
|
+
}
|
|
2739
|
+
};
|
|
2740
|
+
const handleRangeSelect = (range, selectedDay) => {
|
|
2741
|
+
const current = resolvedRange;
|
|
2742
|
+
// Desselecionar: apenas um dia marcado (to ausente ou to = from) e o usuário clicou nele
|
|
2743
|
+
const isSingleDaySelected = current?.from != null &&
|
|
2744
|
+
(current.to == null || current.from.getTime() === current.to.getTime());
|
|
2745
|
+
if (isSingleDaySelected && current?.from?.getTime() === selectedDay.getTime()) {
|
|
2746
|
+
setInternalRange(undefined);
|
|
2747
|
+
onRangeSelect?.(undefined);
|
|
2748
|
+
onClear?.();
|
|
2749
|
+
return;
|
|
2750
|
+
}
|
|
2751
|
+
// Range completo (from ≠ to): reinicia a seleção com o dia clicado
|
|
2752
|
+
const isComplete = current?.from != null &&
|
|
2753
|
+
current?.to != null &&
|
|
2754
|
+
current.from.getTime() !== current.to.getTime();
|
|
2755
|
+
if (isComplete) {
|
|
2756
|
+
const fresh = { from: selectedDay, to: undefined };
|
|
2757
|
+
setInternalRange(fresh);
|
|
2758
|
+
onRangeSelect?.(fresh);
|
|
2759
|
+
return;
|
|
2760
|
+
}
|
|
2761
|
+
setInternalRange(range);
|
|
2762
|
+
onRangeSelect?.(range);
|
|
2504
2763
|
};
|
|
2505
2764
|
const handleMonthChange = (date) => {
|
|
2506
2765
|
setInternalDisplayMonth(date);
|
|
@@ -2545,23 +2804,25 @@ const Calendar = ({ selected, currentDate, defaultMonth, startMonth, endMonth, o
|
|
|
2545
2804
|
onYearLabelClick: handleYearLabelClick,
|
|
2546
2805
|
};
|
|
2547
2806
|
const sharedDayPickerProps = {
|
|
2548
|
-
classNames: styles$
|
|
2807
|
+
classNames: styles$r,
|
|
2549
2808
|
animate,
|
|
2550
|
-
mode: "single",
|
|
2551
|
-
selected: resolvedSelected,
|
|
2552
|
-
onSelect: handleSelect,
|
|
2553
2809
|
startMonth,
|
|
2554
2810
|
endMonth,
|
|
2555
2811
|
disabled: disabledMatchers.length > 0 ? disabledMatchers : undefined,
|
|
2556
2812
|
locale: resolvedLocale,
|
|
2557
2813
|
autoFocus,
|
|
2558
2814
|
"aria-label": ariaLabel,
|
|
2815
|
+
captionLayout: "label",
|
|
2816
|
+
numberOfMonths,
|
|
2817
|
+
month: resolvedDisplayMonth,
|
|
2818
|
+
onMonthChange: handleMonthChange,
|
|
2819
|
+
components: { MonthCaption: GridMonthCaption, Chevron: CustomChevron },
|
|
2559
2820
|
};
|
|
2560
2821
|
const containerStyle = { '--giro-scale': scale };
|
|
2561
|
-
return (jsxRuntime.jsx(GridCtx.Provider, { value: gridCtxValue, children: jsxRuntime.jsxs("div", { className: clsx(styles$
|
|
2822
|
+
return (jsxRuntime.jsx(GridCtx.Provider, { value: gridCtxValue, children: jsxRuntime.jsxs("div", { className: clsx(styles$r.calendar_grid_wrapper, className), style: { ...containerStyle, ...style }, children: [mode === "range" ? (jsxRuntime.jsx(reactDayPicker.DayPicker, { id: id, ...sharedDayPickerProps, ...rest, mode: "range", selected: resolvedRange, onSelect: handleRangeSelect })) : (jsxRuntime.jsx(reactDayPicker.DayPicker, { id: id, ...sharedDayPickerProps, ...rest, mode: "single", selected: resolvedSelected, onSelect: handleSelect })), gridView !== "days" && (jsxRuntime.jsxs("div", { className: `${styles$r.gridOverlay}${gridView === "years" ? ` ${styles$r.gridOverlayYears}` : ""}`, role: "dialog", "aria-modal": "true", "aria-label": gridView === "months" ? "Selecione o mês" : "Selecione o ano", children: [gridView === "months" && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: styles$r.gridOverlayCaption, children: [jsxRuntime.jsx("span", { className: styles$r.caption_grid_label, children: new Intl.DateTimeFormat(intlLocale, { month: "long" }).format(resolvedDisplayMonth) }), jsxRuntime.jsxs("button", { type: "button", className: styles$r.caption_grid_btn, onClick: () => setGridView("days"), "aria-label": "Fechar sele\u00E7\u00E3o de m\u00EAs", children: [displayedYear, jsxRuntime.jsx("span", { className: styles$r.chevron_wrapper, children: jsxRuntime.jsx(reactIcons.ChevronUp16Regular, { className: styles$r.caption_year_chevron, "aria-hidden": true }) })] })] }), jsxRuntime.jsx("div", { className: styles$r.gridCells, children: monthsGrid.map(({ index, label, disabled: monthDisabled }) => (jsxRuntime.jsx("button", { type: "button", disabled: monthDisabled, className: `${styles$r.gridCell}${displayedMonthIndex === index ? ` ${styles$r.gridCellActive}` : ""}`, onClick: () => handleGridMonthSelect(index), children: label }, index))) })] })), gridView === "years" && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: styles$r.gridOverlayCaption, children: [jsxRuntime.jsx("span", { className: styles$r.caption_grid_label, children: new Intl.DateTimeFormat(intlLocale, { month: "long" }).format(resolvedDisplayMonth) }), jsxRuntime.jsxs("button", { type: "button", className: styles$r.caption_grid_btn, onClick: () => setGridView("days"), "aria-label": "Fechar sele\u00E7\u00E3o de ano", children: [displayedYear, jsxRuntime.jsx("span", { className: styles$r.chevron_wrapper, children: jsxRuntime.jsx(reactIcons.ChevronUp16Regular, { className: styles$r.caption_year_chevron, "aria-hidden": true }) })] }), jsxRuntime.jsxs("div", { className: styles$r.gridOverlayYearsNav, children: [jsxRuntime.jsx("button", { type: "button", className: styles$r.gridNavBtn, disabled: !canGoPrevYears, onClick: () => setYearPageStart((s) => s - YEARS_PER_PAGE), "aria-label": "Anos anteriores", children: jsxRuntime.jsx("span", { className: styles$r.chevron_wrapper, children: jsxRuntime.jsx(reactIcons.ChevronLeft16Regular, { className: styles$r.chevronNavBtnPrev, "aria-hidden": true }) }) }), jsxRuntime.jsx("button", { type: "button", className: styles$r.gridNavBtn, disabled: !canGoNextYears, onClick: () => setYearPageStart((s) => s + YEARS_PER_PAGE), "aria-label": "Pr\u00F3ximos anos", children: jsxRuntime.jsx("span", { className: styles$r.chevron_wrapper, children: jsxRuntime.jsx(reactIcons.ChevronRight16Regular, { className: styles$r.chevronNavBtnNext, "aria-hidden": true }) }) })] })] }), jsxRuntime.jsx("div", { className: `${styles$r.gridCells} ${styles$r.gridCellsYears}`, children: yearsInPage.map((year) => (jsxRuntime.jsx("button", { type: "button", className: `${styles$r.gridCell}${displayedYear === year ? ` ${styles$r.gridCellActive}` : ""}`, onClick: () => handleGridYearSelect(year), children: year }, year))) })] }))] }))] }) }));
|
|
2562
2823
|
};
|
|
2563
2824
|
|
|
2564
|
-
var styles$
|
|
2825
|
+
var styles$q = {"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"};
|
|
2565
2826
|
|
|
2566
2827
|
const Callout = ({ variant = 'neutral', title, text, icon, onDismiss, dismiss, backgroundColor, textColor, className, id, style, ...rest }) => {
|
|
2567
2828
|
if (process.env.NODE_ENV !== 'production' && (text === '' || (typeof text === 'string' && !text.trim()))) {
|
|
@@ -2571,19 +2832,19 @@ const Callout = ({ variant = 'neutral', title, text, icon, onDismiss, dismiss, b
|
|
|
2571
2832
|
const titleId = `callout-title-${id || generatedId}`;
|
|
2572
2833
|
const componentId = id || generatedId;
|
|
2573
2834
|
const isAlert = variant === 'alert';
|
|
2574
|
-
const containerClass = clsx(styles$
|
|
2835
|
+
const containerClass = clsx(styles$q.container, styles$q[variant], { [styles$q.withTitle]: title }, className);
|
|
2575
2836
|
const customStyle = {
|
|
2576
2837
|
...style,
|
|
2577
2838
|
...(backgroundColor && { '--callout-bg': `var(--${backgroundColor})` }),
|
|
2578
2839
|
...(textColor && { '--callout-text': `var(--${textColor})` }),
|
|
2579
2840
|
};
|
|
2580
|
-
return (jsxRuntime.jsx("div", { id: componentId, className: containerClass, role: isAlert ? 'alert' : 'status', "aria-live": isAlert ? 'assertive' : 'polite', "aria-labelledby": title ? titleId : undefined, style: customStyle, ...rest, children: jsxRuntime.jsxs("div", { className: styles$
|
|
2841
|
+
return (jsxRuntime.jsx("div", { id: componentId, className: containerClass, role: isAlert ? 'alert' : 'status', "aria-live": isAlert ? 'assertive' : 'polite', "aria-labelledby": title ? titleId : undefined, style: customStyle, ...rest, children: jsxRuntime.jsxs("div", { className: styles$q.content, children: [icon && jsxRuntime.jsx("span", { className: styles$q.icon, "aria-hidden": "true", children: icon }), jsxRuntime.jsxs("div", { className: styles$q.subcontent, children: [title && (jsxRuntime.jsx("span", { id: titleId, className: styles$q.title, children: title })), text && jsxRuntime.jsx("span", { className: styles$q.text, children: text })] }), dismiss && (jsxRuntime.jsx("button", { className: styles$q.dismiss, onClick: onDismiss, type: "button", "aria-label": "Fechar", children: jsxRuntime.jsx(reactIcons.Dismiss24Regular, { "aria-hidden": "true" }) }))] }) }));
|
|
2581
2842
|
};
|
|
2582
2843
|
|
|
2583
|
-
var styles$
|
|
2844
|
+
var styles$p = {"card":"Card-module__card___LzN-3","card--hoverable":"Card-module__card--hoverable___orpJZ"};
|
|
2584
2845
|
|
|
2585
2846
|
function Card({ children, className, hoverable }) {
|
|
2586
|
-
return (jsxRuntime.jsx("main", { className: clsx(styles$
|
|
2847
|
+
return (jsxRuntime.jsx("main", { className: clsx(styles$p['card'], hoverable && styles$p['card--hoverable'], className), children: children }));
|
|
2587
2848
|
}
|
|
2588
2849
|
|
|
2589
2850
|
const CheckSmall = ({ className = '', width = 12, height = 10, fill = 'white', ...restProps }) => {
|
|
@@ -2594,22 +2855,22 @@ const CheckHalf = ({ className = '', width = 16, height = 16, fill = 'white', ..
|
|
|
2594
2855
|
return (jsxRuntime.jsx("svg", { width: width, height: height, viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: className, "aria-hidden": "true", ...restProps, children: jsxRuntime.jsx("g", { id: "Icons/check_indeterminate_small", children: jsxRuntime.jsx("path", { id: "icon", d: "M3 9V7H13V9H3Z", fill: fill }) }) }));
|
|
2595
2856
|
};
|
|
2596
2857
|
|
|
2597
|
-
var styles$
|
|
2858
|
+
var styles$o = {"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"};
|
|
2598
2859
|
|
|
2599
2860
|
const Checkbox = ({ id, label, onCheckedChange, checked, disabled, className, style, scale = 1, indeterminate = false, ...rest }) => {
|
|
2600
2861
|
const componentId = id || React__namespace.useId();
|
|
2601
|
-
return (jsxRuntime.jsxs("div", { className: clsx(styles$
|
|
2602
|
-
[styles$
|
|
2603
|
-
}), role: "presentation", tabIndex: disabled ? -1 : 0, children: jsxRuntime.jsx(radixUi.Checkbox.Root, { className: styles$
|
|
2862
|
+
return (jsxRuntime.jsxs("div", { className: clsx(styles$o.container, className), style: { '--giro-scale': scale, ...style }, children: [jsxRuntime.jsx("div", { className: clsx(styles$o.wrapperCheckbox, {
|
|
2863
|
+
[styles$o.disabled]: disabled,
|
|
2864
|
+
}), role: "presentation", tabIndex: disabled ? -1 : 0, children: jsxRuntime.jsx(radixUi.Checkbox.Root, { className: styles$o.root, checked: indeterminate ? 'indeterminate' : checked, id: componentId, onCheckedChange: onCheckedChange, disabled: disabled, "data-disabled": disabled, "data-indeterminate": indeterminate, "aria-checked": indeterminate ? 'mixed' : checked ? 'true' : 'false', ...rest, children: jsxRuntime.jsx(radixUi.Checkbox.Indicator, { className: styles$o.indicator, children: indeterminate ? jsxRuntime.jsx(CheckHalf, {}) : jsxRuntime.jsx(CheckSmall, {}) }) }) }), jsxRuntime.jsx("label", { className: clsx(styles$o.label, { [styles$o.disabled]: disabled }), htmlFor: componentId, children: label })] }));
|
|
2604
2865
|
};
|
|
2605
2866
|
|
|
2606
|
-
var styles$
|
|
2867
|
+
var styles$n = {"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"};
|
|
2607
2868
|
|
|
2608
2869
|
const Chips = ({ children, leftIcon, rightIcon, variant = 'neutral', disabled = false, backgroundColor, textColor, scale = 1, className, style, ...rest }) => {
|
|
2609
|
-
const chipsClass = clsx(styles$
|
|
2610
|
-
[styles$
|
|
2611
|
-
[styles$
|
|
2612
|
-
[styles$
|
|
2870
|
+
const chipsClass = clsx(styles$n.chips, styles$n[variant], {
|
|
2871
|
+
[styles$n.disabled]: disabled,
|
|
2872
|
+
[styles$n.hasLeftIcon]: leftIcon,
|
|
2873
|
+
[styles$n.hasRightIcon]: rightIcon,
|
|
2613
2874
|
}, className);
|
|
2614
2875
|
const colorStyle = {
|
|
2615
2876
|
'--giro-scale': scale,
|
|
@@ -2618,21 +2879,29 @@ const Chips = ({ children, leftIcon, rightIcon, variant = 'neutral', disabled =
|
|
|
2618
2879
|
...style,
|
|
2619
2880
|
};
|
|
2620
2881
|
const isInteractive = typeof rest.onClick === 'function';
|
|
2621
|
-
|
|
2882
|
+
const { onKeyDown: userOnKeyDown, ...otherRest } = rest;
|
|
2883
|
+
const handleKeyDown = (e) => {
|
|
2884
|
+
userOnKeyDown?.(e);
|
|
2885
|
+
if (!e.defaultPrevented && isInteractive && !disabled && (e.key === 'Enter' || e.key === ' ')) {
|
|
2886
|
+
e.preventDefault();
|
|
2887
|
+
rest.onClick?.(e);
|
|
2888
|
+
}
|
|
2889
|
+
};
|
|
2890
|
+
return (jsxRuntime.jsxs("div", { className: chipsClass, "aria-disabled": disabled, style: colorStyle, role: isInteractive ? 'button' : undefined, tabIndex: isInteractive ? (disabled ? -1 : 0) : undefined, onKeyDown: handleKeyDown, ...otherRest, children: [leftIcon && (jsxRuntime.jsx("span", { className: styles$n.iconLeft, "aria-hidden": "true", children: leftIcon })), jsxRuntime.jsx("span", { className: styles$n.title, children: children }), rightIcon && (jsxRuntime.jsx("span", { className: styles$n.iconRight, "aria-hidden": "true", children: rightIcon }))] }));
|
|
2622
2891
|
};
|
|
2623
2892
|
const MemoizedChips = React.memo(Chips);
|
|
2624
2893
|
MemoizedChips.displayName = 'Chips';
|
|
2625
2894
|
|
|
2626
|
-
var styles$
|
|
2895
|
+
var styles$m = {"container":"Container-module__container___exPuE"};
|
|
2627
2896
|
|
|
2628
2897
|
function Container({ children, className }) {
|
|
2629
|
-
return (jsxRuntime.jsx("main", { className: clsx(styles$
|
|
2898
|
+
return (jsxRuntime.jsx("main", { className: clsx(styles$m['container'], 'mx-auto', className), children: children }));
|
|
2630
2899
|
}
|
|
2631
2900
|
|
|
2632
|
-
var styles$
|
|
2901
|
+
var styles$l = {"Content":"Popover-module__Content___RIETg","Arrow":"Popover-module__Arrow___ue4Mg"};
|
|
2633
2902
|
|
|
2634
2903
|
const Popover = ({ trigger, content, side = "left", align = "start", sideOffset = 8, open, onOpenChange, asAnchor = false, onOpenAutoFocus, onCloseAutoFocus, showArrow = false, className, ...rest }) => {
|
|
2635
|
-
return (jsxRuntime.jsxs(radixUi.Popover.Root, { open: open, onOpenChange: onOpenChange, ...rest, children: [asAnchor ? (jsxRuntime.jsx(radixUi.Popover.Anchor, { asChild: true, children: trigger })) : (jsxRuntime.jsx(radixUi.Popover.Trigger, { asChild: true, children: trigger })), jsxRuntime.jsx(radixUi.Popover.Portal, { children: jsxRuntime.jsxs(radixUi.Popover.Content, { className: clsx(styles$
|
|
2904
|
+
return (jsxRuntime.jsxs(radixUi.Popover.Root, { open: open, onOpenChange: onOpenChange, ...rest, children: [asAnchor ? (jsxRuntime.jsx(radixUi.Popover.Anchor, { asChild: true, children: trigger })) : (jsxRuntime.jsx(radixUi.Popover.Trigger, { asChild: true, children: trigger })), jsxRuntime.jsx(radixUi.Popover.Portal, { children: jsxRuntime.jsxs(radixUi.Popover.Content, { className: clsx(styles$l.Content, className), sideOffset: sideOffset, side: side, align: align, onOpenAutoFocus: asAnchor ? (e) => e.preventDefault() : onOpenAutoFocus, onCloseAutoFocus: asAnchor ? (e) => e.preventDefault() : onCloseAutoFocus, onInteractOutside: asAnchor ? (e) => e.preventDefault() : undefined, children: [content, showArrow && jsxRuntime.jsx(radixUi.Popover.Arrow, { className: styles$l.Arrow })] }) })] }));
|
|
2636
2905
|
};
|
|
2637
2906
|
|
|
2638
2907
|
function useInputKeyboardValue(externalRef) {
|
|
@@ -2687,6 +2956,10 @@ const removeKeyFromLayout = (layout, key) => Object.fromEntries(Object.entries(l
|
|
|
2687
2956
|
layoutName,
|
|
2688
2957
|
rows.map((row) => row.split(key).join(' ').replace(/\s+/g, ' ').trim()),
|
|
2689
2958
|
]));
|
|
2959
|
+
const replaceKeyWithBlank = (layout, key) => Object.fromEntries(Object.entries(layout).map(([layoutName, rows]) => [
|
|
2960
|
+
layoutName,
|
|
2961
|
+
rows.map((row) => row.split(key).join('{//}')),
|
|
2962
|
+
]));
|
|
2690
2963
|
const QWERTY_LOWERCASE = [
|
|
2691
2964
|
'1 2 3 4 5 6 7 8 9 0',
|
|
2692
2965
|
'q w e r t y u i o p',
|
|
@@ -2744,7 +3017,7 @@ const NATIVE_LAYOUTS = {
|
|
|
2744
3017
|
const NATIVE_LAYOUT_KEYS = new Set([
|
|
2745
3018
|
'default', 'numeric',
|
|
2746
3019
|
]);
|
|
2747
|
-
const getNativeLayout = (type, Emoji = true, showDownKeyboardButton = true, isFixed = false, showEnterKey = true) => {
|
|
3020
|
+
const getNativeLayout = (type, Emoji = true, showDownKeyboardButton = true, isFixed = false, showEnterKey = true, showTypeSwitchKey = true) => {
|
|
2748
3021
|
const layout = NATIVE_LAYOUTS[type] ?? NATIVE_LAYOUTS.default ?? null;
|
|
2749
3022
|
if (!layout)
|
|
2750
3023
|
return null;
|
|
@@ -2758,6 +3031,10 @@ const getNativeLayout = (type, Emoji = true, showDownKeyboardButton = true, isFi
|
|
|
2758
3031
|
if (!showEnterKey) {
|
|
2759
3032
|
computedLayout = removeKeyFromLayout(computedLayout, ENTER_KEY);
|
|
2760
3033
|
}
|
|
3034
|
+
if (!showTypeSwitchKey) {
|
|
3035
|
+
computedLayout = removeKeyFromLayout(computedLayout, '{numbers}');
|
|
3036
|
+
computedLayout = replaceKeyWithBlank(computedLayout, '{abc}');
|
|
3037
|
+
}
|
|
2761
3038
|
if (isFixed) {
|
|
2762
3039
|
computedLayout = Object.fromEntries(Object.entries(computedLayout).map(([layoutName, rows]) => [
|
|
2763
3040
|
layoutName,
|
|
@@ -2783,7 +3060,7 @@ const SHIFT_TOGGLES = {
|
|
|
2783
3060
|
alt2: 'alt',
|
|
2784
3061
|
};
|
|
2785
3062
|
|
|
2786
|
-
var styles$
|
|
3063
|
+
var styles$k = {"container":"VirtualKeyboard-module__container___A-e0I","layout--numeric":"VirtualKeyboard-module__layout--numeric___zfd7G","mode--fixed":"VirtualKeyboard-module__mode--fixed___1eFY1","layout--default":"VirtualKeyboard-module__layout--default___qyY1b","textFieldContainer":"VirtualKeyboard-module__textFieldContainer___XxGen","keyboardWrapper":"VirtualKeyboard-module__keyboardWrapper___jryTf","keyboardNumpadActive":"VirtualKeyboard-module__keyboardNumpadActive___jPpJD","overlay":"VirtualKeyboard-module__overlay___a5y7i","overlayOpen":"VirtualKeyboard-module__overlayOpen___hREu-","textFieldWrapper":"VirtualKeyboard-module__textFieldWrapper___bmi-z","keyPreview":"VirtualKeyboard-module__keyPreview___oWaO1","accentMenu":"VirtualKeyboard-module__accentMenu___A6tTy","accentMenuRow":"VirtualKeyboard-module__accentMenuRow___3kbvT","accentOption":"VirtualKeyboard-module__accentOption___ao-Ta"};
|
|
2787
3064
|
|
|
2788
3065
|
const LONG_PRESS_DELAY_MS = 400;
|
|
2789
3066
|
const ACCENT_OPTIONS = {
|
|
@@ -2823,12 +3100,12 @@ const ACCENT_OPTIONS = {
|
|
|
2823
3100
|
* <VirtualKeyboard targetRef={inputRef} value={value} onChange={setValue} />
|
|
2824
3101
|
* ```
|
|
2825
3102
|
*/
|
|
2826
|
-
const VirtualKeyboard = ({ variant = 'native', type = 'default', value = '', onChange, onKeyPress, maxLength, Emoji = false, className, id,
|
|
3103
|
+
const VirtualKeyboard = ({ variant = 'native', type = 'default', value = '', onChange, onKeyPress, onTypeChange, maxLength, Emoji = false, className, id, placeholder = 'Digite aqui...', helperText, error, errorMessage, targetRef, textFieldScale = 1, showEnterKey = true, showTypeSwitchKey = true, }) => {
|
|
2827
3104
|
const [layoutName, setLayoutName] = React.useState('default');
|
|
2828
3105
|
const [capsLockOn, setCapsLockOn] = React.useState(false);
|
|
2829
3106
|
const [accentMenu, setAccentMenu] = React.useState(null);
|
|
2830
3107
|
const [accentMenuOffsetX, setAccentMenuOffsetX] = React.useState(0);
|
|
2831
|
-
const [activeLayout, setActiveLayout] = React.useState(getNativeLayout(type, Emoji, variant === 'native', variant === 'fixed', showEnterKey));
|
|
3108
|
+
const [activeLayout, setActiveLayout] = React.useState(getNativeLayout(type, Emoji, variant === 'native', variant === 'fixed', showEnterKey, showTypeSwitchKey));
|
|
2832
3109
|
const visualType = NATIVE_LAYOUT_KEYS.has(type) ? type : 'default';
|
|
2833
3110
|
const [isOpen, setIsOpen] = React.useState(variant !== 'native');
|
|
2834
3111
|
const hideTimeoutRef = React.useRef(null);
|
|
@@ -2867,6 +3144,9 @@ const VirtualKeyboard = ({ variant = 'native', type = 'default', value = '', onC
|
|
|
2867
3144
|
React.useEffect(() => {
|
|
2868
3145
|
syncKeyboardInput(value);
|
|
2869
3146
|
}, [value, syncKeyboardInput]);
|
|
3147
|
+
React.useEffect(() => {
|
|
3148
|
+
onTypeChange?.(type);
|
|
3149
|
+
}, [type, onTypeChange]);
|
|
2870
3150
|
const scheduleHideIfBlurred = React.useCallback(() => {
|
|
2871
3151
|
if (variant !== 'native')
|
|
2872
3152
|
return;
|
|
@@ -2941,8 +3221,8 @@ const VirtualKeyboard = ({ variant = 'native', type = 'default', value = '', onC
|
|
|
2941
3221
|
React.useEffect(() => {
|
|
2942
3222
|
setLayoutName('default');
|
|
2943
3223
|
setCapsLockOn(false);
|
|
2944
|
-
setActiveLayout(getNativeLayout(type, Emoji, variant === 'native', variant === 'fixed', showEnterKey));
|
|
2945
|
-
}, [type, Emoji, variant, showEnterKey]);
|
|
3224
|
+
setActiveLayout(getNativeLayout(type, Emoji, variant === 'native', variant === 'fixed', showEnterKey, showTypeSwitchKey));
|
|
3225
|
+
}, [type, Emoji, variant, showEnterKey, showTypeSwitchKey]);
|
|
2946
3226
|
React.useEffect(() => {
|
|
2947
3227
|
if (!Emoji && layoutName === 'emoticon') {
|
|
2948
3228
|
setLayoutName(type === 'numeric' ? 'abc' : 'default');
|
|
@@ -3184,10 +3464,12 @@ const VirtualKeyboard = ({ variant = 'native', type = 'default', value = '', onC
|
|
|
3184
3464
|
}
|
|
3185
3465
|
if (button === '{numbers}') {
|
|
3186
3466
|
setLayoutName('numbers');
|
|
3467
|
+
onTypeChange?.('numeric');
|
|
3187
3468
|
return;
|
|
3188
3469
|
}
|
|
3189
3470
|
if (button === '{abc}') {
|
|
3190
3471
|
setLayoutName(baseLayout);
|
|
3472
|
+
onTypeChange?.('default');
|
|
3191
3473
|
return;
|
|
3192
3474
|
}
|
|
3193
3475
|
if (button === '{alt}' || button === '{altright}') {
|
|
@@ -3242,6 +3524,7 @@ const VirtualKeyboard = ({ variant = 'native', type = 'default', value = '', onC
|
|
|
3242
3524
|
layoutName,
|
|
3243
3525
|
capsLockOn,
|
|
3244
3526
|
onKeyPress,
|
|
3527
|
+
onTypeChange,
|
|
3245
3528
|
Emoji,
|
|
3246
3529
|
variant,
|
|
3247
3530
|
closeAccentMenu,
|
|
@@ -3292,7 +3575,7 @@ const VirtualKeyboard = ({ variant = 'native', type = 'default', value = '', onC
|
|
|
3292
3575
|
'{bksp}': (baseDisplay['{bksp}'] ?? '').replace(/\s*Apagar$/, ''),
|
|
3293
3576
|
};
|
|
3294
3577
|
}, [visualType, variant]);
|
|
3295
|
-
const keyboardEl = activeLayout ? (jsxRuntime.jsxs("div", { ref: keyboardWrapperRef, className: clsx(styles$
|
|
3578
|
+
const keyboardEl = activeLayout ? (jsxRuntime.jsxs("div", { ref: keyboardWrapperRef, className: clsx(styles$k.keyboardWrapper, ((type === 'numeric' && layoutName === 'default') || layoutName === 'numbers' || type === 'default') && styles$k.keyboardNumpadActive), onPointerDownCapture: handleLongPressStart, onPointerUpCapture: handleLongPressEnd, onPointerLeave: handleLongPressEnd, onPointerCancelCapture: handleLongPressEnd, children: [jsxRuntime.jsx(Keyboard, { keyboardRef: (instance) => {
|
|
3296
3579
|
keyboardInstanceRef.current = instance;
|
|
3297
3580
|
if (instance) {
|
|
3298
3581
|
instance.setInput(valueRef.current);
|
|
@@ -3311,17 +3594,17 @@ const VirtualKeyboard = ({ variant = 'native', type = 'default', value = '', onC
|
|
|
3311
3594
|
}
|
|
3312
3595
|
return reactDom.createPortal(React.createElement(Icon), slot, `icon-${key}`);
|
|
3313
3596
|
});
|
|
3314
|
-
})(), keyPreview && typeof document !== 'undefined' && reactDom.createPortal(jsxRuntime.jsx("div", { ref: keyPreviewRef, className: styles$
|
|
3597
|
+
})(), keyPreview && typeof document !== 'undefined' && reactDom.createPortal(jsxRuntime.jsx("div", { ref: keyPreviewRef, className: styles$k.keyPreview, style: {
|
|
3315
3598
|
top: keyPreview.top,
|
|
3316
3599
|
left: keyPreview.left + keyPreviewOffsetX,
|
|
3317
3600
|
width: portalSizes.preview,
|
|
3318
3601
|
height: portalSizes.preview,
|
|
3319
3602
|
...(portalSizes.fontSize ? { fontSize: portalSizes.fontSize } : {}),
|
|
3320
3603
|
}, "aria-hidden": true, children: keyPreview.char }), document.body), accentMenu && (typeof document !== 'undefined' &&
|
|
3321
|
-
reactDom.createPortal(jsxRuntime.jsx("div", { ref: accentMenuRef, className: styles$
|
|
3604
|
+
reactDom.createPortal(jsxRuntime.jsx("div", { ref: accentMenuRef, className: styles$k.accentMenu, style: {
|
|
3322
3605
|
top: accentMenu.top,
|
|
3323
3606
|
left: accentMenu.left + accentMenuOffsetX,
|
|
3324
|
-
}, role: "listbox", "aria-label": `Opcoes de acento para ${accentMenu.sourceKey}`, children: Array.from({ length: Math.ceil(accentMenu.options.length / 5) }, (_, rowIndex) => accentMenu.options.slice(rowIndex * 5, rowIndex * 5 + 5)).map((rowOptions, rowIndex) => (jsxRuntime.jsx("div", { className: styles$
|
|
3607
|
+
}, role: "listbox", "aria-label": `Opcoes de acento para ${accentMenu.sourceKey}`, children: Array.from({ length: Math.ceil(accentMenu.options.length / 5) }, (_, rowIndex) => accentMenu.options.slice(rowIndex * 5, rowIndex * 5 + 5)).map((rowOptions, rowIndex) => (jsxRuntime.jsx("div", { className: styles$k.accentMenuRow, children: rowOptions.map((option) => (jsxRuntime.jsx("button", { type: "button", className: styles$k.accentOption, style: {
|
|
3325
3608
|
minWidth: portalSizes.option,
|
|
3326
3609
|
height: portalSizes.option,
|
|
3327
3610
|
...(portalSizes.fontSize ? { fontSize: portalSizes.fontSize } : {}),
|
|
@@ -3330,12 +3613,12 @@ const VirtualKeyboard = ({ variant = 'native', type = 'default', value = '', onC
|
|
|
3330
3613
|
event.stopPropagation();
|
|
3331
3614
|
}, onClick: () => handleAccentSelect(option), children: option }, `${accentMenu.sourceKey}-${option}`))) }, rowIndex))) }), document.body))] })) : null;
|
|
3332
3615
|
if (variant === 'native' && typeof document !== 'undefined') {
|
|
3333
|
-
return reactDom.createPortal(jsxRuntime.jsx("div", { id: id, className: clsx(styles$
|
|
3616
|
+
return reactDom.createPortal(jsxRuntime.jsx("div", { id: id, className: clsx(styles$k.overlay, { [styles$k.overlayOpen]: isOpen }, styles$k[`layout--${visualType}`], className), children: keyboardEl }), document.body);
|
|
3334
3617
|
}
|
|
3335
|
-
return (jsxRuntime.jsxs("div", { id: id, className: clsx(styles$
|
|
3618
|
+
return (jsxRuntime.jsxs("div", { id: id, className: clsx(styles$k.container, styles$k[`mode--${variant}`], styles$k[`layout--${visualType}`], className), children: [variant === 'fixed' && (jsxRuntime.jsx("div", { className: styles$k.textFieldContainer, children: jsxRuntime.jsx(TextField, { placeholder: placeholder, value: value, onChange: onChange, helperText: helperText, error: error, errorMessage: errorMessage, readOnly: true, disableAutoComplete: true, maxLength: maxLength, attachedToVirtualKeyboard: true, className: styles$k.textFieldWrapper, scale: textFieldScale }) })), keyboardEl] }));
|
|
3336
3619
|
};
|
|
3337
3620
|
|
|
3338
|
-
var styles$
|
|
3621
|
+
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"};
|
|
3339
3622
|
|
|
3340
3623
|
const validateInput = ({ value, maxLength, errorMessage, required }) => {
|
|
3341
3624
|
if (required && value.trim() === '') {
|
|
@@ -3347,21 +3630,21 @@ const validateInput = ({ value, maxLength, errorMessage, required }) => {
|
|
|
3347
3630
|
return '';
|
|
3348
3631
|
};
|
|
3349
3632
|
|
|
3350
|
-
var styles$
|
|
3633
|
+
var styles$i = {"labelContainer":"index-module__labelContainer___WGyDF","wrapperLabel":"index-module__wrapperLabel___XJzZO","requiredLabel":"index-module__requiredLabel___7oZkh","infoIcon":"index-module__infoIcon___lClx4","errorIcon":"index-module__errorIcon___yN-lq","disabledIcon":"index-module__disabledIcon___89Os7","errorLabel":"index-module__errorLabel___qa6h6","disabledLabel":"index-module__disabledLabel___U9vL8","disabledContainer":"index-module__disabledContainer___MtOvy"};
|
|
3351
3634
|
|
|
3352
3635
|
const LabelComponent = ({ children, htmlFor, required = false, tooltip = false, tooltipText, side = 'bottom', align = 'start', className, error = false, disabled = false, scale = 1, }) => {
|
|
3353
3636
|
const containerStyle = {
|
|
3354
3637
|
'--giro-scale': scale,
|
|
3355
3638
|
};
|
|
3356
|
-
const container = (jsxRuntime.jsxs("div", { className: clsx(styles$
|
|
3357
|
-
styles$
|
|
3639
|
+
const container = (jsxRuntime.jsxs("div", { className: clsx(styles$i.labelContainer, disabled && styles$i.disabledContainer), style: containerStyle, children: [jsxRuntime.jsxs(radixUi.Label.Root, { className: clsx(styles$i.wrapperLabel, error && !disabled && styles$i.errorLabel, disabled && styles$i.disabledLabel, className), htmlFor: htmlFor, children: [children, required && jsxRuntime.jsx("span", { className: styles$i.requiredLabel, children: "*" })] }), tooltip && (jsxRuntime.jsx("span", { className: disabled ? styles$i.disabledIcon : error ?
|
|
3640
|
+
styles$i.errorIcon : styles$i.infoIcon, children: jsxRuntime.jsx(reactIcons.Info12Regular, {}) }))] }));
|
|
3358
3641
|
if (tooltip) {
|
|
3359
3642
|
return (jsxRuntime.jsx(Tooltip, { side: side, align: align, text: tooltipText || '', children: container }));
|
|
3360
3643
|
}
|
|
3361
3644
|
return container;
|
|
3362
3645
|
};
|
|
3363
3646
|
|
|
3364
|
-
const TextField$1 =
|
|
3647
|
+
const TextField$1 = ({ ref, 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, persistIcon = false, virtualKeyboard, attachedToVirtualKeyboard, disableAutoComplete = false, ...rest }) => {
|
|
3365
3648
|
const normalizeValue = (val) => {
|
|
3366
3649
|
return val === undefined || val === null ? '' : String(val);
|
|
3367
3650
|
};
|
|
@@ -3412,7 +3695,7 @@ const TextField$1 = React.forwardRef(({ className, style, value, label, placehol
|
|
|
3412
3695
|
setIsFocused(true);
|
|
3413
3696
|
onFocus?.(e);
|
|
3414
3697
|
}, [onFocus]);
|
|
3415
|
-
const showCustomIcon = inputValue.trim().length === 0 && icon;
|
|
3698
|
+
const showCustomIcon = (inputValue.trim().length === 0 || persistIcon) && icon;
|
|
3416
3699
|
const showClearIcon = isFocused && inputValue.trim().length > 0;
|
|
3417
3700
|
const hasError = Boolean(inputError) || Boolean(error);
|
|
3418
3701
|
const displayHelperText = (error ? errorMessage : undefined) || inputError || helperText || '\u00A0';
|
|
@@ -3422,29 +3705,28 @@ const TextField$1 = React.forwardRef(({ className, style, value, label, placehol
|
|
|
3422
3705
|
? `${componentId}-helper`
|
|
3423
3706
|
: undefined;
|
|
3424
3707
|
const containerStyle = { '--giro-scale': scale };
|
|
3425
|
-
const containerClass = clsx(styles$
|
|
3426
|
-
[styles$
|
|
3427
|
-
[styles$
|
|
3428
|
-
[styles$
|
|
3429
|
-
[styles$
|
|
3430
|
-
[className]: className,
|
|
3708
|
+
const containerClass = clsx(styles$j.container, className, {
|
|
3709
|
+
[styles$j.attachedToVirtualKeyboard]: attachedToVirtualKeyboard,
|
|
3710
|
+
[styles$j.disabled]: disabled,
|
|
3711
|
+
[styles$j.error]: error,
|
|
3712
|
+
[styles$j.errorWithMessage]: !!errorMessage,
|
|
3431
3713
|
});
|
|
3432
|
-
return (jsxRuntime.jsxs("div", { className: containerClass, style: { ...containerStyle, ...style }, children: [label && (jsxRuntime.jsx(LabelComponent, { scale: scale, htmlFor: componentId, required: required, tooltip:
|
|
3433
|
-
[styles$
|
|
3434
|
-
}) }), showCustomIcon && jsxRuntime.jsx("span", { className: styles$
|
|
3714
|
+
return (jsxRuntime.jsxs("div", { className: containerClass, style: { ...containerStyle, ...style }, children: [label && (jsxRuntime.jsx(LabelComponent, { scale: scale, htmlFor: componentId, required: required, tooltip: !!tooltipText, tooltipText: tooltipText, side: tooltipSide, align: tooltipAlign, error: hasError, disabled: disabled, children: label })), jsxRuntime.jsxs("div", { className: styles$j.inputWrapper, children: [jsxRuntime.jsxs("div", { className: styles$j.inputContainer, children: [jsxRuntime.jsx("input", { ...rest, ref: setInputRefs, id: componentId, name: name, type: type, value: inputValue, placeholder: placeholder, onChange: handleChange, onFocus: handleFocus, onBlur: handleBlur, maxLength: maxLength, disabled: disabled, "aria-invalid": hasError, "aria-required": required, "aria-describedby": helperId, inputMode: (virtualKeyboard === 'default' || virtualKeyboard === 'numeric') ? 'none' : rest.inputMode, autoComplete: (disableAutoComplete || virtualKeyboard === 'default' || virtualKeyboard === 'numeric') ? 'off' : rest.autoComplete, className: clsx({
|
|
3715
|
+
[styles$j.inputWithIcon]: showCustomIcon || showClearIcon,
|
|
3716
|
+
}) }), showCustomIcon && jsxRuntime.jsx("span", { className: styles$j.icon, children: icon }), showClearIcon && (jsxRuntime.jsx("button", { type: "button", className: styles$j.clearButton, onMouseDown: (e) => {
|
|
3435
3717
|
e.preventDefault();
|
|
3436
3718
|
handleClear();
|
|
3437
|
-
}, "aria-label": "Limpar campo", tabIndex: -1, children: jsxRuntime.jsx("span", { className: styles$
|
|
3719
|
+
}, "aria-label": "Limpar campo", tabIndex: -1, children: jsxRuntime.jsx("span", { className: styles$j.clearButtonIcon, children: jsxRuntime.jsx(reactIcons.Dismiss16Regular, {}) }) }))] }), ((error && errorMessage) || inputError || helperText) && (jsxRuntime.jsx("span", { id: helperId, className: styles$j.helperText, "aria-live": hasError ? 'polite' : undefined, children: displayHelperText }))] }), (virtualKeyboard === 'default' || virtualKeyboard === 'numeric') && (jsxRuntime.jsx("div", { className: "virtualKeyboardWrapper", children: jsxRuntime.jsx(VirtualKeyboard, { variant: "native", type: virtualKeyboard, value: inputValue, maxLength: maxLength, targetRef: inputRef, onChange: (val) => {
|
|
3438
3720
|
if (!disabled && (!maxLength || val.length <= maxLength)) {
|
|
3439
3721
|
setInputValue(val);
|
|
3440
3722
|
onChange?.(val);
|
|
3441
3723
|
}
|
|
3442
3724
|
} }) }))] }));
|
|
3443
|
-
}
|
|
3725
|
+
};
|
|
3444
3726
|
TextField$1.displayName = 'TextField';
|
|
3445
3727
|
var TextField = React.memo(TextField$1);
|
|
3446
3728
|
|
|
3447
|
-
var styles$
|
|
3729
|
+
var styles$h = {"datePicker":"DatePicker-module__datePicker___raJYg","textfieldContainer":"DatePicker-module__textfieldContainer___yy8pT","datePickerIcon":"DatePicker-module__datePickerIcon___XCZsn","datePickerIconDisabled":"DatePicker-module__datePickerIconDisabled___BB-Gx"};
|
|
3448
3730
|
|
|
3449
3731
|
function formatDate(date, locale = 'pt-br') {
|
|
3450
3732
|
if (!date || !(date instanceof Date)) {
|
|
@@ -3666,7 +3948,7 @@ const DatePicker = ({ locale = 'pt-br', calendarSide = 'bottom', calendarAlign =
|
|
|
3666
3948
|
}
|
|
3667
3949
|
}
|
|
3668
3950
|
};
|
|
3669
|
-
return (jsxRuntime.jsx("div", { ref: wrapperRef, className: clsx(styles$
|
|
3951
|
+
return (jsxRuntime.jsx("div", { ref: wrapperRef, className: clsx(styles$h.datePicker, className), style: { ...containerStyle, ...style }, ...rest, children: jsxRuntime.jsx(Popover, { open: showCalendar, onOpenChange: setShowCalendar, asAnchor: true, trigger: jsxRuntime.jsx(TextField, { className: styles$h.textfieldContainer, type: "tel", icon: jsxRuntime.jsx(reactIcons.Calendar16Regular, { onClick: !disabled ? handleIconClick : undefined, className: clsx(styles$h.datePickerIcon, disabled && styles$h.datePickerIconDisabled) }), onChange: (e) => {
|
|
3670
3952
|
handleTextFieldChange(String(e));
|
|
3671
3953
|
}, 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, 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: jsxRuntime.jsx(Calendar, { selected: currentSelectedDate, currentDate: currentDate, onDateChange: setCurrentDate, onDaySelect: handleDaySelect, locale: locale, format: locale === 'en-us' ? 'mm/dd/yyyy' : 'dd/mm/yyyy', minDate: minDate, maxDate: maxDate, scale: scale, id: calendarId, onClear: () => {
|
|
3672
3954
|
handleDateChange(null);
|
|
@@ -3675,11 +3957,11 @@ const DatePicker = ({ locale = 'pt-br', calendarSide = 'bottom', calendarAlign =
|
|
|
3675
3957
|
};
|
|
3676
3958
|
var DatePicker_default = React.memo(DatePicker);
|
|
3677
3959
|
|
|
3678
|
-
var styles$
|
|
3960
|
+
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-"};
|
|
3679
3961
|
|
|
3680
|
-
const Dialog = ({ show = false, title, bodyContent, textPrimaryAction, textSecondaryAction, onPrimaryAction, onSecondaryAction, className, ...rest }) => (jsxRuntime.jsx(radixUi.AlertDialog.Root, { open: show, ...rest, children: jsxRuntime.jsxs(radixUi.AlertDialog.Portal, { children: [jsxRuntime.jsx(radixUi.AlertDialog.Overlay, { className: styles$
|
|
3962
|
+
const Dialog = ({ show = false, title, bodyContent, textPrimaryAction, textSecondaryAction, onPrimaryAction, onSecondaryAction, className, ...rest }) => (jsxRuntime.jsx(radixUi.AlertDialog.Root, { open: show, ...rest, children: jsxRuntime.jsxs(radixUi.AlertDialog.Portal, { children: [jsxRuntime.jsx(radixUi.AlertDialog.Overlay, { className: styles$g.DialogOverlay }), jsxRuntime.jsxs(radixUi.AlertDialog.Content, { className: clsx(styles$g.DialogContent, className), children: [jsxRuntime.jsx(radixUi.AlertDialog.Title, { className: styles$g.DialogTitle, children: title }), jsxRuntime.jsx(radixUi.AlertDialog.Description, { className: styles$g.DialogDescription, children: bodyContent }), jsxRuntime.jsxs("div", { className: styles$g.DivButtons, children: [!!(textSecondaryAction && textSecondaryAction.trim()) && (jsxRuntime.jsx(radixUi.AlertDialog.Cancel, { asChild: true, children: jsxRuntime.jsx(Button, { variant: "outlined", ...(onSecondaryAction && { onClick: onSecondaryAction }), children: textSecondaryAction }) })), jsxRuntime.jsx(radixUi.AlertDialog.Action, { asChild: true, children: jsxRuntime.jsx(Button, { variant: "filled", ...(onPrimaryAction && { onClick: onPrimaryAction }), children: textPrimaryAction }) })] })] })] }) }));
|
|
3681
3963
|
|
|
3682
|
-
var styles$
|
|
3964
|
+
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"};
|
|
3683
3965
|
|
|
3684
3966
|
const Drawer = ({ children, headerContent, footer, customWidth = '400px', onClose, title = 'Título', isOpen = false, onOpen, className, id, disabled = false, onOverlayClick, closeOnOverlayClick = true, closeOnEscape = true, ...rest }) => {
|
|
3685
3967
|
const internalClose = React.useCallback(() => {
|
|
@@ -3728,19 +4010,189 @@ const Drawer = ({ children, headerContent, footer, customWidth = '400px', onClos
|
|
|
3728
4010
|
event.stopPropagation();
|
|
3729
4011
|
internalClose();
|
|
3730
4012
|
};
|
|
3731
|
-
return reactDom.createPortal(jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: clsx(styles$
|
|
3732
|
-
[styles$
|
|
3733
|
-
}), onClick: handleOverlayClick, role: "presentation", "aria-hidden": "true", "data-testid": "drawer-overlay" }), jsxRuntime.jsxs("div", { className: clsx(styles$
|
|
3734
|
-
[styles$
|
|
3735
|
-
[styles$
|
|
4013
|
+
return reactDom.createPortal(jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: clsx(styles$f['drawerShadow'], {
|
|
4014
|
+
[styles$f['drawerShadow--visible']]: isOpen,
|
|
4015
|
+
}), onClick: handleOverlayClick, role: "presentation", "aria-hidden": "true", "data-testid": "drawer-overlay" }), jsxRuntime.jsxs("div", { className: clsx(styles$f['drawerSidebar'], {
|
|
4016
|
+
[styles$f['drawerSidebar--open']]: isOpen,
|
|
4017
|
+
[styles$f['drawerSidebar--disabled']]: disabled,
|
|
3736
4018
|
}, className), style: {
|
|
3737
4019
|
'--drawer-custom-width': customWidth,
|
|
3738
|
-
}, onClick: handleDrawerClick, role: "dialog", "aria-modal": "true", "aria-labelledby": id ? `${id}-title` : 'drawer-title', "aria-hidden": !isOpen, "data-testid": "drawer-panel", id: id, ...rest, children: [jsxRuntime.jsxs("div", { className: styles$
|
|
4020
|
+
}, onClick: handleDrawerClick, role: "dialog", "aria-modal": "true", "aria-labelledby": id ? `${id}-title` : 'drawer-title', "aria-hidden": !isOpen, "data-testid": "drawer-panel", id: id, ...rest, children: [jsxRuntime.jsxs("div", { className: styles$f.drawerTitleClose, children: [jsxRuntime.jsx("div", { className: styles$f.drawerTitle, id: id ? `${id}-title` : 'drawer-title', children: title }), headerContent && (jsxRuntime.jsx("div", { className: styles$f.drawerHeaderContent, children: headerContent })), jsxRuntime.jsx(Button, { onClick: handleCloseClick, variant: 'outlined', iconOnly: true, icon: jsxRuntime.jsx(reactIcons.Dismiss16Regular, {}), size: 'lg', tooltipText: 'Fechar' })] }), jsxRuntime.jsx("div", { className: styles$f.drawerChildren, "data-testid": "drawer-content", children: children }), footer] })] }), document.body);
|
|
4021
|
+
};
|
|
4022
|
+
|
|
4023
|
+
var styles$e = {"container":"FileUpload-module__container___hFeKV","dropZone":"FileUpload-module__dropZone___716hF","disabled":"FileUpload-module__disabled___mwePo","alert":"FileUpload-module__alert___Dnzqc","dragging":"FileUpload-module__dragging___XZghy","emptyState":"FileUpload-module__emptyState___6Ll9D","uploadIcon":"FileUpload-module__uploadIcon___MkBLe","uploadText":"FileUpload-module__uploadText___VWc9g","alertIcon":"FileUpload-module__alertIcon___pTaMS","alertText":"FileUpload-module__alertText___sfV4z","fileList":"FileUpload-module__fileList___K6KQD","thumb":"FileUpload-module__thumb___eg59D","removeButton":"FileUpload-module__removeButton___jUFNv","thumbClip":"FileUpload-module__thumbClip___sP9wp","thumbImage":"FileUpload-module__thumbImage___Swxhd","thumbFile":"FileUpload-module__thumbFile___y7lg5","thumbFileName":"FileUpload-module__thumbFileName___LPSCX","helperText":"FileUpload-module__helperText___DzPqP","errorText":"FileUpload-module__errorText___cHd1Z"};
|
|
4024
|
+
|
|
4025
|
+
const truncateFileName = (fileName, maxChars = 18) => {
|
|
4026
|
+
if (fileName.length <= maxChars)
|
|
4027
|
+
return fileName;
|
|
4028
|
+
const lastDot = fileName.lastIndexOf('.');
|
|
4029
|
+
const hasExtension = lastDot > 0 && lastDot < fileName.length - 1;
|
|
4030
|
+
const baseName = hasExtension ? fileName.substring(0, lastDot) : fileName;
|
|
4031
|
+
const extension = hasExtension ? fileName.substring(lastDot) : '';
|
|
4032
|
+
const reserved = 3 + extension.length; // "..."
|
|
4033
|
+
const available = maxChars - reserved;
|
|
4034
|
+
if (available <= 1) {
|
|
4035
|
+
return fileName.substring(0, maxChars - 3) + '...';
|
|
4036
|
+
}
|
|
4037
|
+
return baseName.substring(0, available) + '...' + extension;
|
|
4038
|
+
};
|
|
4039
|
+
const matchesAccept = (file, accept) => {
|
|
4040
|
+
if (!accept)
|
|
4041
|
+
return true;
|
|
4042
|
+
const types = accept.split(',').map((t) => t.trim().toLowerCase());
|
|
4043
|
+
const fileName = file.name.toLowerCase();
|
|
4044
|
+
const fileType = file.type.toLowerCase();
|
|
4045
|
+
return types.some((type) => {
|
|
4046
|
+
if (type.startsWith('.')) {
|
|
4047
|
+
return fileName.endsWith(type);
|
|
4048
|
+
}
|
|
4049
|
+
if (type.endsWith('/*')) {
|
|
4050
|
+
return fileType.startsWith(type.slice(0, -1));
|
|
4051
|
+
}
|
|
4052
|
+
return fileType === type;
|
|
4053
|
+
});
|
|
3739
4054
|
};
|
|
4055
|
+
const FileUpload = ({ ref, value, onChange, helperText, error = false, errorMessage, maxFileSize, maxFilesQuantity, disabled = false, className, id, accept, multiple = true, description = 'Clique ou arraste os arquivos aqui', descriptionErrorMessage = 'Falha ao subir um ou mais arquivos.', ...rest }) => {
|
|
4056
|
+
const generatedId = React.useId();
|
|
4057
|
+
const componentId = id || generatedId;
|
|
4058
|
+
const helperId = `${componentId}-helper`;
|
|
4059
|
+
const listId = `${componentId}-list`;
|
|
4060
|
+
const inputRef = React.useRef(null);
|
|
4061
|
+
const [internalFiles, setInternalFiles] = React.useState([]);
|
|
4062
|
+
const [isDragging, setIsDragging] = React.useState(false);
|
|
4063
|
+
const [objectUrls, setObjectUrls] = React.useState(new Map());
|
|
4064
|
+
const [internalError, setInternalError] = React.useState(null);
|
|
4065
|
+
const isControlled = value !== undefined;
|
|
4066
|
+
const files = isControlled ? value : internalFiles;
|
|
4067
|
+
React.useEffect(() => {
|
|
4068
|
+
return () => {
|
|
4069
|
+
objectUrls.forEach((url) => URL.revokeObjectURL(url));
|
|
4070
|
+
};
|
|
4071
|
+
}, [objectUrls]);
|
|
4072
|
+
const getObjectUrl = React.useCallback((file) => {
|
|
4073
|
+
const key = `${file.name}-${file.size}`;
|
|
4074
|
+
const existing = objectUrls.get(key);
|
|
4075
|
+
if (existing)
|
|
4076
|
+
return existing;
|
|
4077
|
+
const url = URL.createObjectURL(file);
|
|
4078
|
+
setObjectUrls((prev) => new Map(prev).set(key, url));
|
|
4079
|
+
return url;
|
|
4080
|
+
}, [objectUrls]);
|
|
4081
|
+
const revokeUrl = React.useCallback((file) => {
|
|
4082
|
+
const key = `${file.name}-${file.size}`;
|
|
4083
|
+
setObjectUrls((prev) => {
|
|
4084
|
+
const next = new Map(prev);
|
|
4085
|
+
const url = next.get(key);
|
|
4086
|
+
if (url)
|
|
4087
|
+
URL.revokeObjectURL(url);
|
|
4088
|
+
next.delete(key);
|
|
4089
|
+
return next;
|
|
4090
|
+
});
|
|
4091
|
+
}, []);
|
|
4092
|
+
const processFiles = React.useCallback((incoming) => {
|
|
4093
|
+
if (disabled)
|
|
4094
|
+
return;
|
|
4095
|
+
const all = Array.from(incoming);
|
|
4096
|
+
const validFiles = all.filter((file) => {
|
|
4097
|
+
if (maxFileSize && file.size > maxFileSize)
|
|
4098
|
+
return false;
|
|
4099
|
+
if (!matchesAccept(file, accept))
|
|
4100
|
+
return false;
|
|
4101
|
+
return true;
|
|
4102
|
+
});
|
|
4103
|
+
const merged = multiple
|
|
4104
|
+
? [...files, ...validFiles]
|
|
4105
|
+
: validFiles.slice(0, 1);
|
|
4106
|
+
const limited = maxFilesQuantity && multiple ? merged.slice(0, maxFilesQuantity) : merged;
|
|
4107
|
+
// Prioridade de erro: tipo > tamanho > quantidade
|
|
4108
|
+
const hasTypeError = all.some((file) => !matchesAccept(file, accept));
|
|
4109
|
+
const hasSizeError = all.some((file) => maxFileSize && file.size > maxFileSize);
|
|
4110
|
+
const hasQuantityError = maxFilesQuantity && multiple && merged.length > maxFilesQuantity;
|
|
4111
|
+
if (hasTypeError && hasSizeError) {
|
|
4112
|
+
setInternalError('Um ou mais arquivos possuem tipo ou tamanho inválido.');
|
|
4113
|
+
}
|
|
4114
|
+
else if (hasTypeError) {
|
|
4115
|
+
setInternalError('Um ou mais arquivos não são do tipo aceito.');
|
|
4116
|
+
}
|
|
4117
|
+
else if (hasSizeError) {
|
|
4118
|
+
setInternalError('Um ou mais arquivos excedem o tamanho máximo permitido.');
|
|
4119
|
+
}
|
|
4120
|
+
else if (hasQuantityError) {
|
|
4121
|
+
setInternalError(`Não é possível adicionar mais de ${maxFilesQuantity} arquivo(s).`);
|
|
4122
|
+
}
|
|
4123
|
+
else {
|
|
4124
|
+
setInternalError(null);
|
|
4125
|
+
}
|
|
4126
|
+
if (!isControlled)
|
|
4127
|
+
setInternalFiles(limited);
|
|
4128
|
+
onChange?.(limited);
|
|
4129
|
+
}, [disabled, files, isControlled, maxFilesQuantity, maxFileSize, multiple, onChange, accept]);
|
|
4130
|
+
const handleInputChange = React.useCallback((e) => {
|
|
4131
|
+
if (e.target.files) {
|
|
4132
|
+
processFiles(e.target.files);
|
|
4133
|
+
e.target.value = '';
|
|
4134
|
+
}
|
|
4135
|
+
}, [processFiles]);
|
|
4136
|
+
const handleClick = React.useCallback(() => {
|
|
4137
|
+
if (!disabled)
|
|
4138
|
+
inputRef.current?.click();
|
|
4139
|
+
}, [disabled]);
|
|
4140
|
+
const handleKeyDown = React.useCallback((e) => {
|
|
4141
|
+
if (!disabled && (e.key === 'Enter' || e.key === ' ')) {
|
|
4142
|
+
e.preventDefault();
|
|
4143
|
+
inputRef.current?.click();
|
|
4144
|
+
}
|
|
4145
|
+
}, [disabled]);
|
|
4146
|
+
const handleDragOver = React.useCallback((e) => {
|
|
4147
|
+
e.preventDefault();
|
|
4148
|
+
if (!disabled)
|
|
4149
|
+
setIsDragging(true);
|
|
4150
|
+
}, [disabled]);
|
|
4151
|
+
const handleDragLeave = React.useCallback((e) => {
|
|
4152
|
+
e.preventDefault();
|
|
4153
|
+
setIsDragging(false);
|
|
4154
|
+
}, []);
|
|
4155
|
+
const handleDrop = React.useCallback((e) => {
|
|
4156
|
+
e.preventDefault();
|
|
4157
|
+
setIsDragging(false);
|
|
4158
|
+
if (!disabled && e.dataTransfer.files.length > 0) {
|
|
4159
|
+
processFiles(e.dataTransfer.files);
|
|
4160
|
+
}
|
|
4161
|
+
}, [disabled, processFiles]);
|
|
4162
|
+
const handleRemove = React.useCallback((e, index) => {
|
|
4163
|
+
e.stopPropagation();
|
|
4164
|
+
const removed = files[index];
|
|
4165
|
+
revokeUrl(removed);
|
|
4166
|
+
const updated = files.filter((_, i) => i !== index);
|
|
4167
|
+
if (!isControlled)
|
|
4168
|
+
setInternalFiles(updated);
|
|
4169
|
+
onChange?.(updated);
|
|
4170
|
+
}, [files, isControlled, onChange, revokeUrl]);
|
|
4171
|
+
const hasFiles = files.length > 0;
|
|
4172
|
+
const isError = error || !!errorMessage || !!internalError;
|
|
4173
|
+
const displayedHelper = isError ? errorMessage || internalError || helperText : helperText;
|
|
4174
|
+
const setRefs = React.useCallback((node) => {
|
|
4175
|
+
inputRef.current = node;
|
|
4176
|
+
if (typeof ref === 'function')
|
|
4177
|
+
ref(node);
|
|
4178
|
+
else if (ref)
|
|
4179
|
+
ref.current = node;
|
|
4180
|
+
}, [ref]);
|
|
4181
|
+
return (jsxRuntime.jsxs("div", { id: componentId, className: clsx(styles$e.container, className), children: [jsxRuntime.jsx("input", { ref: setRefs, type: "file", accept: accept, multiple: multiple, disabled: disabled, "aria-hidden": "true", tabIndex: -1, style: { display: 'none' }, onChange: handleInputChange, ...rest }), jsxRuntime.jsxs("div", { role: "button", tabIndex: disabled ? -1 : 0, "aria-label": description, "aria-disabled": disabled, "aria-describedby": displayedHelper ? helperId : undefined, "aria-controls": hasFiles ? listId : undefined, "data-invalid": isError || undefined, className: clsx(styles$e.dropZone, isDragging && styles$e.dragging, isError && styles$e.alert, disabled && styles$e.disabled), onClick: handleClick, onKeyDown: handleKeyDown, onDragOver: handleDragOver, onDragLeave: handleDragLeave, onDrop: handleDrop, children: [!hasFiles && !isError && (jsxRuntime.jsxs("div", { className: styles$e.emptyState, "aria-hidden": "true", children: [jsxRuntime.jsx("span", { className: styles$e.uploadIcon, children: jsxRuntime.jsx(reactIcons.DocumentAdd24Regular, {}) }), jsxRuntime.jsx("span", { className: styles$e.uploadText, children: description })] })), !hasFiles && isError && (jsxRuntime.jsxs("div", { className: styles$e.emptyState, "aria-hidden": "true", children: [jsxRuntime.jsx("span", { className: styles$e.alertIcon, children: jsxRuntime.jsx(reactIcons.Warning24Regular, {}) }), descriptionErrorMessage && (jsxRuntime.jsx("span", { className: styles$e.alertText, children: descriptionErrorMessage }))] })), hasFiles && (jsxRuntime.jsx("ul", { id: listId, className: styles$e.fileList, "aria-label": `${files.length} arquivo${files.length !== 1 ? 's' : ''} selecionado${files.length !== 1 ? 's' : ''}`, "aria-live": "polite", children: files.map((file, index) => {
|
|
4182
|
+
const isImage = file.type.startsWith('image/');
|
|
4183
|
+
return (jsxRuntime.jsxs("li", { className: styles$e.thumb, children: [jsxRuntime.jsx("div", { className: styles$e.thumbClip, children: isImage ? (jsxRuntime.jsx("img", { src: getObjectUrl(file), alt: file.name, title: file.name, className: styles$e.thumbImage })) : (jsxRuntime.jsxs("div", { className: styles$e.thumbFile, "aria-hidden": "true", title: file.name, children: [jsxRuntime.jsx(reactIcons.Document24Regular, {}), jsxRuntime.jsx("span", { className: styles$e.thumbFileName, children: truncateFileName(file.name) })] })) }), jsxRuntime.jsx("button", { type: "button", className: styles$e.removeButton, "aria-label": `Remover ${file.name}`, disabled: disabled, onClick: (e) => handleRemove(e, index), onKeyDown: (e) => {
|
|
4184
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
4185
|
+
e.preventDefault();
|
|
4186
|
+
handleRemove(e, index);
|
|
4187
|
+
}
|
|
4188
|
+
}, children: jsxRuntime.jsx(reactIcons.Dismiss16Regular, { "aria-hidden": "true" }) })] }, `${file.name}-${index}`));
|
|
4189
|
+
}) }))] }), displayedHelper && (jsxRuntime.jsx("span", { id: helperId, role: isError ? 'alert' : undefined, className: clsx(styles$e.helperText, isError && styles$e.errorText), children: displayedHelper }))] }));
|
|
4190
|
+
};
|
|
4191
|
+
FileUpload.displayName = 'FileUpload';
|
|
3740
4192
|
|
|
3741
4193
|
var styles$d = {"container":"Filter-module__container___cqntK","panel":"Filter-module__panel___19HqD","search":"Filter-module__search___f0gzj","list":"Filter-module__list___UpBk1","item":"Filter-module__item___oNdeY","itemSelected":"Filter-module__itemSelected___JIpJV","itemText":"Filter-module__itemText___RS--0","itemDisabled":"Filter-module__itemDisabled___X-ktg","itemIcon":"Filter-module__itemIcon___RjJSa","noResults":"Filter-module__noResults___3m6pn","footer":"Filter-module__footer___yYS5j","buttonContent":"Filter-module__buttonContent___28fKe","buttonArrow":"Filter-module__buttonArrow___VJlpc","buttonIcon":"Filter-module__buttonIcon___OOBpZ","triggerWrapper":"Filter-module__triggerWrapper___ptPRL","triggerContent":"Filter-module__triggerContent___LYo9j","body":"Filter-module__body___qsyhk","combinedFooter":"Filter-module__combinedFooter___kTnHP"};
|
|
3742
4194
|
|
|
3743
|
-
const Combined = ({ buttonText = 'Filtrar', icon, variant = 'outlined', disabled = false, className, title = 'Filtrar', drawerWidth = "fit-content",
|
|
4195
|
+
const Combined = ({ buttonText = 'Filtrar', icon, variant = 'outlined', disabled = false, className, title = 'Filtrar', drawerWidth = "fit-content", appliedFilterCount = 0, drawerHeaderContent, children, onApply, onClear, onOpen, onClose, id, ...rest }) => {
|
|
3744
4196
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
3745
4197
|
const handleOpen = React.useCallback(() => {
|
|
3746
4198
|
setIsOpen(true);
|
|
@@ -3757,12 +4209,12 @@ const Combined = ({ buttonText = 'Filtrar', icon, variant = 'outlined', disabled
|
|
|
3757
4209
|
const handleClear = React.useCallback(() => {
|
|
3758
4210
|
onClear?.();
|
|
3759
4211
|
}, [onClear]);
|
|
3760
|
-
return (jsxRuntime.jsxs("div", { className: clsx(styles$d.triggerWrapper, className), id: id, ...rest, children: [jsxRuntime.jsx(Button, { variant: variant, disabled: disabled, icon: icon ?? jsxRuntime.jsx(reactIcons.FilterRegular, {}), iconPosition: "left", onClick: handleOpen, children: jsxRuntime.jsxs("span", { className: styles$d.triggerContent, children: [buttonText,
|
|
4212
|
+
return (jsxRuntime.jsxs("div", { className: clsx(styles$d.triggerWrapper, className), id: id, ...rest, children: [jsxRuntime.jsx(Button, { variant: variant, disabled: disabled, icon: icon ?? jsxRuntime.jsx(reactIcons.FilterRegular, {}), iconPosition: "left", onClick: handleOpen, children: jsxRuntime.jsxs("span", { className: styles$d.triggerContent, children: [buttonText, appliedFilterCount > 0 && (jsxRuntime.jsx(Badge, { badgeValue: appliedFilterCount, filterVariant: true }))] }) }), jsxRuntime.jsx(Drawer, { isOpen: isOpen, onClose: handleClose, title: title, customWidth: drawerWidth, closeOnOverlayClick: true, closeOnEscape: true, headerContent: drawerHeaderContent, footer: jsxRuntime.jsxs("div", { className: styles$d.combinedFooter, children: [jsxRuntime.jsx(Button, { variant: "outlined", onClick: handleClear, children: "Limpar" }), jsxRuntime.jsx(Button, { onClick: handleApply, children: "Aplicar" })] }), children: jsxRuntime.jsx("div", { className: styles$d.body, children: children }) })] }));
|
|
3761
4213
|
};
|
|
3762
4214
|
|
|
3763
4215
|
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"};
|
|
3764
4216
|
|
|
3765
|
-
const Search =
|
|
4217
|
+
const Search = ({ ref, 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 }) => {
|
|
3766
4218
|
const [internalValue, setInternalValue] = React.useState('');
|
|
3767
4219
|
const { internalRef: inputRef, setRefs: setInputRefs } = useInputKeyboardValue(ref);
|
|
3768
4220
|
const isControlled = value !== undefined && onChange !== undefined;
|
|
@@ -3834,7 +4286,7 @@ const Search = React.forwardRef(({ placeholder = 'Dica do que deve ser buscado',
|
|
|
3834
4286
|
setInternalValue(val);
|
|
3835
4287
|
}
|
|
3836
4288
|
} }) }))] }));
|
|
3837
|
-
}
|
|
4289
|
+
};
|
|
3838
4290
|
Search.displayName = 'Search';
|
|
3839
4291
|
|
|
3840
4292
|
const Simple = ({ items, type = 'multiple', selectedIds, onApplyFilter, placeholder = 'Selecionar...', enableSearch = false, buttonText = 'Filter', icon, variant = 'outlined', onOpen, onClose, side = 'bottom', align = 'start', disabled = false, className, selectedDate, onDateSelect, onClearDate, minDate, maxDate, locale = 'pt-br', id, ...rest }) => {
|
|
@@ -4311,9 +4763,9 @@ const Menu = ({ items, children, onItemSelect, search, enableInfiniteScroll, onS
|
|
|
4311
4763
|
}, ...rest, children: [search && (jsxRuntime.jsx("div", { className: styles$9.searchWrapper, children: jsxRuntime.jsx(Search, { placeholder: "Buscar", onChange: handleSearchChange, value: searchInput, onKeyDown: handleSearchKeyDown }) })), jsxRuntime.jsxs("div", { className: styles$9.itemsWrapper, ref: itemsWrapperRef, style: { maxHeight: maxHeightStyle }, children: [filteredItems.length > 0 ? (filteredItems.map((item, index) => renderMenuItem(item, item.value || item.text || `item-${index}`))) : (jsxRuntime.jsx("div", { className: styles$9.emptyState, children: "Nenhum item encontrado" })), enableInfiniteScroll && isLoadingMore && (jsxRuntime.jsx("div", { className: styles$9.loadingMore, children: "Carregando mais itens..." })), enableInfiniteScroll && (jsxRuntime.jsx("div", { ref: sentinelRef, "data-scroll-sentinel": true, style: { height: '1px', visibility: 'hidden' } }))] })] }) })] }));
|
|
4312
4764
|
};
|
|
4313
4765
|
|
|
4314
|
-
var styles$8 = {"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"};
|
|
4766
|
+
var styles$8 = {"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"};
|
|
4315
4767
|
|
|
4316
|
-
const Modal = ({ isOpen = false, onClose, title, children, headerContent, closeOnOverlayClick = true, className, id, footer, customWidth, fullscreen = false, ...rest }) => {
|
|
4768
|
+
const Modal = ({ isOpen = false, onClose, title, children, headerContent, closeOnOverlayClick = true, className, id, footer, customWidth, customHeight, fullscreen = false, ...rest }) => {
|
|
4317
4769
|
const contentRef = React__namespace.useRef(null);
|
|
4318
4770
|
const handleOpenChange = (open) => {
|
|
4319
4771
|
if (!open) {
|
|
@@ -4326,7 +4778,8 @@ const Modal = ({ isOpen = false, onClose, title, children, headerContent, closeO
|
|
|
4326
4778
|
};
|
|
4327
4779
|
return (jsxRuntime.jsx(radixUi.Dialog.Root, { open: isOpen, onOpenChange: handleOpenChange, ...rest, children: jsxRuntime.jsxs(radixUi.Dialog.Portal, { children: [jsxRuntime.jsx(radixUi.Dialog.Overlay, { className: styles$8.modalOverlay }), jsxRuntime.jsxs(radixUi.Dialog.Content, { ref: contentRef, className: clsx(styles$8.modalContent, fullscreen && styles$8['modalContent--fullscreen'], className), id: id, style: {
|
|
4328
4780
|
'--modal-custom-width': customWidth,
|
|
4329
|
-
|
|
4781
|
+
'--modal-custom-height': customHeight,
|
|
4782
|
+
}, onInteractOutside: !closeOnOverlayClick ? (e) => e.preventDefault() : undefined, onOpenAutoFocus: handleOpenAutoFocus, "aria-labelledby": id ? `${id}-title` : 'modal-title', tabIndex: -1, children: [jsxRuntime.jsxs("header", { className: styles$8.modalHeader, children: [title && (jsxRuntime.jsx(radixUi.Dialog.Title, { className: styles$8.modalTitle, id: id ? `${id}-title` : 'modal-title', children: title })), headerContent && (jsxRuntime.jsx("div", { children: headerContent })), jsxRuntime.jsx(radixUi.Dialog.Close, { asChild: true, children: jsxRuntime.jsx(Button, { variant: "outlined", iconOnly: true, icon: jsxRuntime.jsx(reactIcons.Dismiss16Regular, {}), size: "lg", tooltipText: 'Fechar' }) })] }), jsxRuntime.jsx("section", { className: styles$8.modalBody, children: children }), footer && (jsxRuntime.jsx("footer", { className: styles$8.modalFooter, children: footer }))] })] }) }));
|
|
4330
4783
|
};
|
|
4331
4784
|
|
|
4332
4785
|
var styles$7 = {"quantity":"Quantity-module__quantity___-vndR","quantityInput":"Quantity-module__quantityInput___xZG-v","disabled":"Quantity-module__disabled___X6p5l"};
|
|
@@ -4590,13 +5043,13 @@ const ExpandableSelectItem = ({ item, variant, onSelect, selectedValues, level =
|
|
|
4590
5043
|
}, 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 && (jsxRuntime.jsx("span", { className: styles$6.icon, children: item.icon })), jsxRuntime.jsxs("div", { className: styles$6.textContent, children: [jsxRuntime.jsx("div", { className: styles$6.title, children: item.text }), item.subTitle && jsxRuntime.jsx("div", { className: styles$6.subTitle, children: item.subTitle })] }), hasChildren && (jsxRuntime.jsx("span", { className: styles$6.chevron, children: isExpanded ? jsxRuntime.jsx(reactIcons.ChevronDown16Regular, {}) : jsxRuntime.jsx(reactIcons.ChevronRight16Regular, {}) }))] }) }), hasChildren && isExpanded && (jsxRuntime.jsx("div", { className: styles$6.childrenWrapper, children: item.children.map((child) => (jsxRuntime.jsx(ExpandableSelectItem, { item: child, variant: variant, onSelect: onSelect, selectedValues: selectedValues, level: level + 1 }, child.id || child.value))) }))] }));
|
|
4591
5044
|
};
|
|
4592
5045
|
|
|
4593
|
-
const SelectItem =
|
|
5046
|
+
const SelectItem = ({ ref, text, subTitle, icon, disabled, value, variant, disableFocusOnHover, ...restProps }) => {
|
|
4594
5047
|
return (jsxRuntime.jsxs("div", { className: clsx(styles$6.itemWrapper, {
|
|
4595
5048
|
[styles$6.disabled]: disabled,
|
|
4596
5049
|
}), "data-disabled": disabled || undefined, "data-testid": `select-item-${value}`, ref: ref, children: [variant === 'icon' && icon && (jsxRuntime.jsx("span", { className: styles$6.icon, children: icon })), jsxRuntime.jsxs(radixUi.Select.Item, { className: clsx(styles$6.item, {
|
|
4597
5050
|
[styles$6.disabled]: disabled,
|
|
4598
5051
|
}), value: value, disabled: disabled, onPointerMove: disableFocusOnHover ? (e) => e.preventDefault() : undefined, ...restProps, children: [jsxRuntime.jsx(radixUi.Select.ItemText, { className: styles$6.title, children: text }), subTitle && jsxRuntime.jsx("div", { className: styles$6.subTitle, children: subTitle }), jsxRuntime.jsx(radixUi.Select.ItemIndicator, { className: styles$6.itemIndicator })] })] }));
|
|
4599
|
-
}
|
|
5052
|
+
};
|
|
4600
5053
|
SelectItem.displayName = 'SelectItem';
|
|
4601
5054
|
|
|
4602
5055
|
const initialState = {
|
|
@@ -4631,7 +5084,7 @@ function selectReducer(state, action) {
|
|
|
4631
5084
|
return state;
|
|
4632
5085
|
}
|
|
4633
5086
|
}
|
|
4634
|
-
function useSelectLogic({ value, required = false, search = false, onValueChange, onOpenChange, enableApiSearch = false, onApiSearch, isSearching = false, }) {
|
|
5087
|
+
function useSelectLogic({ value, required = false, search = false, onValueChange, onOpenChange, enableApiSearch = false, onApiSearch, isSearching = false, error, }) {
|
|
4635
5088
|
const [state, dispatch] = React.useReducer(selectReducer, {
|
|
4636
5089
|
...initialState,
|
|
4637
5090
|
selectedValues: Array.isArray(value) ? value : value ? [value] : [],
|
|
@@ -4658,6 +5111,14 @@ function useSelectLogic({ value, required = false, search = false, onValueChange
|
|
|
4658
5111
|
const newValues = Array.isArray(value) ? value : value ? [value] : [];
|
|
4659
5112
|
dispatch({ type: 'SET_SELECTED_VALUES', payload: newValues });
|
|
4660
5113
|
}, [value]);
|
|
5114
|
+
React.useEffect(() => {
|
|
5115
|
+
if (error !== undefined) {
|
|
5116
|
+
dispatch({ type: 'SET_ERROR', payload: error });
|
|
5117
|
+
if (error) {
|
|
5118
|
+
dispatch({ type: 'SET_TOUCHED', payload: true });
|
|
5119
|
+
}
|
|
5120
|
+
}
|
|
5121
|
+
}, [error]);
|
|
4661
5122
|
React.useEffect(() => {
|
|
4662
5123
|
if (state.isOpen && search) {
|
|
4663
5124
|
setTimeout(() => {
|
|
@@ -4824,7 +5285,7 @@ function useSelectLogic({ value, required = false, search = false, onValueChange
|
|
|
4824
5285
|
};
|
|
4825
5286
|
}
|
|
4826
5287
|
|
|
4827
|
-
const Select = ({ items, onValueChange, onOpenChange, variant, required = false, value, label, helperText, placeholder = 'Selecione', maxWidth, search = false, errorMessage, disabled = false, className, style, 'aria-label': ariaLabel, 'data-testid': testId,
|
|
5288
|
+
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 }) => {
|
|
4828
5289
|
const componentId = React.useId();
|
|
4829
5290
|
const selectId = `select-${componentId}`;
|
|
4830
5291
|
const viewportRef = React.useRef(null);
|
|
@@ -4838,6 +5299,7 @@ const Select = ({ items, onValueChange, onOpenChange, variant, required = false,
|
|
|
4838
5299
|
enableApiSearch,
|
|
4839
5300
|
onApiSearch,
|
|
4840
5301
|
isSearching,
|
|
5302
|
+
error,
|
|
4841
5303
|
});
|
|
4842
5304
|
React.useEffect(() => {
|
|
4843
5305
|
const viewport = viewportRef.current;
|
|
@@ -4905,7 +5367,7 @@ const Select = ({ items, onValueChange, onOpenChange, variant, required = false,
|
|
|
4905
5367
|
onApiSearch('');
|
|
4906
5368
|
}
|
|
4907
5369
|
};
|
|
4908
|
-
return (jsxRuntime.jsx(radixUi.Select.Root, { value: variant === 'checkbox' || (search && state.isOpen) ? '' : (state.selectedValues[0] || ''), onValueChange: variant === 'checkbox' ? undefined : actions.handleSingleSelect, required: required, open: state.isOpen, onOpenChange: actions.setOpen, disabled: disabled, ...rest, children: jsxRuntime.jsxs("div", { className: clsx(styles$6.container, className), style: { ...containerStyle, ...style }, "data-testid": testId, children: [jsxRuntime.jsx("div", { className: styles$6.fieldContainer, children: jsxRuntime.jsxs("div", { className: styles$6.containerLabel, children: [jsxRuntime.jsx(LabelComponent, { htmlFor: selectId, required: required, tooltipText: tooltipText, tooltip:
|
|
5370
|
+
return (jsxRuntime.jsx(radixUi.Select.Root, { value: variant === 'checkbox' || (search && state.isOpen) ? '' : (state.selectedValues[0] || ''), onValueChange: variant === 'checkbox' ? undefined : actions.handleSingleSelect, required: required, open: state.isOpen, onOpenChange: actions.setOpen, disabled: disabled, ...rest, children: jsxRuntime.jsxs("div", { className: clsx(styles$6.container, className), style: { ...containerStyle, ...style }, "data-testid": testId, children: [jsxRuntime.jsx("div", { className: styles$6.fieldContainer, children: jsxRuntime.jsxs("div", { className: styles$6.containerLabel, children: [jsxRuntime.jsx(LabelComponent, { htmlFor: selectId, required: required, tooltipText: tooltipText, tooltip: !!tooltipText, side: tooltipSide, align: tooltipAlign, error: state.hasError && state.touched, disabled: disabled, scale: scale, children: label }), jsxRuntime.jsxs(radixUi.Select.Trigger, { className: clsx(styles$6.trigger, {
|
|
4909
5371
|
[styles$6.error]: state.hasError && state.touched,
|
|
4910
5372
|
[styles$6.disabled]: disabled,
|
|
4911
5373
|
[styles$6.hasValue]: state.selectedValues.length > 0,
|
|
@@ -4977,15 +5439,11 @@ function __rest(s, e) {
|
|
|
4977
5439
|
return t;
|
|
4978
5440
|
}
|
|
4979
5441
|
|
|
4980
|
-
var uid = (function () {
|
|
4981
|
-
return Math.random()
|
|
4982
|
-
.toString(36)
|
|
4983
|
-
.substring(6);
|
|
4984
|
-
});
|
|
4985
|
-
|
|
4986
5442
|
var SVG = function (_a) {
|
|
4987
5443
|
var _b = _a.animate, animate = _b === void 0 ? true : _b, _c = _a.backgroundColor, backgroundColor = _c === void 0 ? '#f5f6f7' : _c, _d = _a.backgroundOpacity, backgroundOpacity = _d === void 0 ? 1 : _d, _e = _a.baseUrl, baseUrl = _e === void 0 ? '' : _e, children = _a.children, _f = _a.foregroundColor, foregroundColor = _f === void 0 ? '#eee' : _f, _g = _a.foregroundOpacity, foregroundOpacity = _g === void 0 ? 1 : _g, _h = _a.gradientRatio, gradientRatio = _h === void 0 ? 2 : _h, uniqueKey = _a.uniqueKey, _j = _a.rtl, rtl = _j === void 0 ? false : _j, _k = _a.speed, speed = _k === void 0 ? 1.2 : _k, _l = _a.style, style = _l === void 0 ? {} : _l, _m = _a.title, title = _m === void 0 ? 'Loading...' : _m, _o = _a.beforeMask, beforeMask = _o === void 0 ? null : _o, props = __rest(_a, ["animate", "backgroundColor", "backgroundOpacity", "baseUrl", "children", "foregroundColor", "foregroundOpacity", "gradientRatio", "uniqueKey", "rtl", "speed", "style", "title", "beforeMask"]);
|
|
4988
|
-
var fixedId =
|
|
5444
|
+
var fixedId = React.useId();
|
|
5445
|
+
if (uniqueKey)
|
|
5446
|
+
fixedId = uniqueKey;
|
|
4989
5447
|
var idClip = "".concat(fixedId, "-diff");
|
|
4990
5448
|
var idGradient = "".concat(fixedId, "-animated-diff");
|
|
4991
5449
|
var idAria = "".concat(fixedId, "-aria");
|
|
@@ -5338,7 +5796,7 @@ const TableV2 = ({ columns, data, rowSelection: rowSelectionConfig, enableSortin
|
|
|
5338
5796
|
onClose: () => filterItem.onToggle?.(false),
|
|
5339
5797
|
};
|
|
5340
5798
|
if (filterItem.type === 'combined') {
|
|
5341
|
-
return (jsxRuntime.jsx(Filter, { mode: "combined", buttonText: filterItem.buttonText, icon: filterItem.icon, title: filterItem.title, drawerWidth: filterItem.drawerWidth,
|
|
5799
|
+
return (jsxRuntime.jsx(Filter, { mode: "combined", buttonText: filterItem.buttonText, icon: filterItem.icon, title: filterItem.title, drawerWidth: filterItem.drawerWidth, appliedFilterCount: filterItem.activeCount, drawerHeaderContent: filterItem.drawerHeaderContent, onApply: filterItem.onApply, onClear: filterItem.onClear, variant: filterItem.variant ?? 'outlined', disabled: filterItem.disabled, children: filterItem.children }, filterItem.id ?? index));
|
|
5342
5800
|
}
|
|
5343
5801
|
if (filterItem.type === 'calendar') {
|
|
5344
5802
|
return (jsxRuntime.jsx(Filter, { ...commonProps, type: "calendar", selectedDate: filterItem.selectedDate, onDateSelect: filterItem.onDateSelect, onClearDate: filterItem.onClear, minDate: filterItem.minDate, maxDate: filterItem.maxDate, locale: filterItem.locale, placeholder: filterItem.placeholder }, filterItem.id ?? index));
|
|
@@ -5360,7 +5818,7 @@ const TableV2 = ({ columns, data, rowSelection: rowSelectionConfig, enableSortin
|
|
|
5360
5818
|
maxWidth: cell.column.columnDef.maxSize !== Number.MAX_SAFE_INTEGER
|
|
5361
5819
|
? cell.column.columnDef.maxSize
|
|
5362
5820
|
: undefined,
|
|
5363
|
-
}, children:
|
|
5821
|
+
}, children: jsxRuntime.jsx("div", { className: styles$4.tableCellMaxHeight, style: { maxHeight: cell.column.columnDef.meta?.maxHeight ?? '64px' }, children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()) }) }, cell.id))) }, row.id));
|
|
5364
5822
|
})) : (jsxRuntime.jsx("tr", { children: jsxRuntime.jsx("td", { colSpan: table.getVisibleLeafColumns().length, className: styles$4.tableEmptyCell, children: jsxRuntime.jsx(EmptyState, { emptyIcon: emptyIcon, emptyTitle: emptyTitle, emptyText: emptyText }) }) })) })] }) }) }), footer && (jsxRuntime.jsxs("div", { className: styles$4.tablePagination, children: [jsxRuntime.jsxs("div", { className: styles$4.tablePaginationSelect, children: [jsxRuntime.jsx("label", { htmlFor: "tablev2-page-size", className: styles$4.tablePaginationLabel, children: "Itens por p\u00E1gina" }), jsxRuntime.jsx("select", { id: "tablev2-page-size", value: pageSize, onChange: handlePageSizeChange, className: styles$4.tablePaginationSelectInput, children: (footer.pageSizeOptions ?? [10, 25, 50, 100]).map((opt) => (jsxRuntime.jsx("option", { value: opt, children: opt }, opt))) })] }), jsxRuntime.jsx("div", { className: styles$4.tablePaginationInfo, children: jsxRuntime.jsx("span", { children: totalPages > 0
|
|
5365
5823
|
? `${pageIndex + 1} de ${totalPages}`
|
|
5366
5824
|
: '0 páginas' }) }), jsxRuntime.jsxs("div", { className: styles$4.tablePaginationControls, children: [jsxRuntime.jsx("button", { className: styles$4.tablePaginationButton, onClick: () => {
|
|
@@ -5376,7 +5834,7 @@ const TableV2 = ({ columns, data, rowSelection: rowSelectionConfig, enableSortin
|
|
|
5376
5834
|
|
|
5377
5835
|
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"};
|
|
5378
5836
|
|
|
5379
|
-
const TextArea =
|
|
5837
|
+
const TextArea = ({ ref, className, value, label, placeholder, onChange, disabled = false, maxLength, required = false, helperText, tooltipText, tooltipSide = 'bottom', tooltipAlign = 'start', errorMessage, error, id, onBlur, onFocus, name, resize = 'vertical', charCount = false, height, virtualKeyboard, ...rest }) => {
|
|
5380
5838
|
const normalizeValue = (val) => {
|
|
5381
5839
|
return val === undefined || val === null ? '' : String(val);
|
|
5382
5840
|
};
|
|
@@ -5408,20 +5866,20 @@ const TextArea = React.forwardRef(({ className, value, label, placeholder, onCha
|
|
|
5408
5866
|
onFocus?.(e);
|
|
5409
5867
|
}, [onFocus]);
|
|
5410
5868
|
const hasError = Boolean(textareaError) || Boolean(error);
|
|
5411
|
-
const displayHelperText = (error ? errorMessage : undefined) || textareaError || helperText
|
|
5869
|
+
const displayHelperText = (error ? errorMessage : undefined) || textareaError || helperText;
|
|
5412
5870
|
const helperId = (textareaError || error)
|
|
5413
5871
|
? `${componentId}-error`
|
|
5414
5872
|
: helperText
|
|
5415
5873
|
? `${componentId}-helper`
|
|
5416
5874
|
: undefined;
|
|
5417
5875
|
const containerClass = clsx(styles$3.container, disabled && styles$3.disabled, hasError && !disabled && styles$3.error, className);
|
|
5418
|
-
return (jsxRuntime.jsxs("div", { className: containerClass, children: [label && (jsxRuntime.jsx(LabelComponent, { htmlFor: componentId, required: required, tooltip:
|
|
5876
|
+
return (jsxRuntime.jsxs("div", { className: containerClass, children: [label && (jsxRuntime.jsx(LabelComponent, { htmlFor: componentId, required: required, tooltip: !!tooltipText, tooltipText: tooltipText, side: tooltipSide, align: tooltipAlign, error: hasError, disabled: disabled, children: label })), jsxRuntime.jsxs("div", { className: styles$3.inputWrapper, children: [jsxRuntime.jsx("div", { className: styles$3.inputContainer, children: jsxRuntime.jsx("textarea", { ...rest, ref: setTextareaRefs, id: componentId, name: name, value: textareaValue, placeholder: placeholder, onChange: handleChange, onFocus: handleFocus, onBlur: handleBlur, maxLength: maxLength, disabled: disabled, "aria-invalid": hasError, "aria-required": required, "aria-describedby": helperId, style: { resize, height }, inputMode: (virtualKeyboard === 'default' || virtualKeyboard === 'numeric') ? 'none' : rest.inputMode }) }), (((error && errorMessage) || textareaError || helperText) || (charCount && maxLength)) && (jsxRuntime.jsxs("div", { className: styles$3.footer, children: [((error && errorMessage) || textareaError || helperText) && (jsxRuntime.jsx("span", { id: helperId, className: styles$3.helperText, "aria-live": hasError ? 'polite' : undefined, children: displayHelperText })), charCount && maxLength && (jsxRuntime.jsxs("span", { className: styles$3.charCount, children: [textareaValue.length, "/", maxLength] }))] }))] }), (virtualKeyboard === 'default' || virtualKeyboard === 'numeric') && (jsxRuntime.jsx("div", { className: "virtualKeyboardWrapper", children: jsxRuntime.jsx(VirtualKeyboard, { variant: "native", type: virtualKeyboard, maxLength: maxLength, value: textareaValue, targetRef: textareaRef, onChange: (val) => {
|
|
5419
5877
|
if (!disabled && (!maxLength || val.length <= maxLength)) {
|
|
5420
5878
|
setTextareaValue(val);
|
|
5421
5879
|
onChange?.(val);
|
|
5422
5880
|
}
|
|
5423
5881
|
} }) }))] }));
|
|
5424
|
-
}
|
|
5882
|
+
};
|
|
5425
5883
|
TextArea.displayName = 'TextArea';
|
|
5426
5884
|
var TextArea_default = React.memo(TextArea);
|
|
5427
5885
|
|
|
@@ -5637,123 +6095,11 @@ const Switch = ({ disabled = false, defaultChecked = false, checked, onCheckedCh
|
|
|
5637
6095
|
return (jsxRuntime.jsx("div", { className: clsx(styles$1.container, className), style: { '--giro-scale': scale, ...style }, children: jsxRuntime.jsx(radixUi.Switch.Root, { className: styles$1.switchRoot, disabled: disabled, defaultChecked: defaultChecked, checked: checked, onCheckedChange: onCheckedChange, ...rest, children: jsxRuntime.jsx(radixUi.Switch.Thumb, { className: styles$1.switchThumb }) }) }));
|
|
5638
6096
|
};
|
|
5639
6097
|
|
|
5640
|
-
var styles = {"
|
|
6098
|
+
var styles = {"container":"VerificationCode-module__container___5Kxo6","inputGroup":"VerificationCode-module__inputGroup___ose3E","input":"VerificationCode-module__input___Vu-jM","inputError":"VerificationCode-module__inputError___gI-Bl","inputDisabled":"VerificationCode-module__inputDisabled___wUj2Y","errorMessage":"VerificationCode-module__errorMessage___NnYtO"};
|
|
5641
6099
|
|
|
5642
|
-
|
|
5643
|
-
* Mapa de regex para validação dos tipos de entrada
|
|
5644
|
-
*/
|
|
5645
|
-
const REGEX_MAP = {
|
|
5646
|
-
numeric: /^[0-9]$/,
|
|
5647
|
-
alpha: /^[a-zA-Z]$/,
|
|
5648
|
-
alphanumeric: /^[a-zA-Z0-9]$/,
|
|
5649
|
-
};
|
|
5650
|
-
/**
|
|
5651
|
-
* Componente VerificationCode para entrada de códigos de verificação
|
|
5652
|
-
*
|
|
5653
|
-
* @description Permite entrada de códigos com múltiplos dígitos,
|
|
5654
|
-
* suportando diferentes tipos de caracteres e navegação por teclado.
|
|
5655
|
-
*
|
|
5656
|
-
* @example
|
|
5657
|
-
* ```tsx
|
|
5658
|
-
* <VerificationCode
|
|
5659
|
-
* length={6}
|
|
5660
|
-
* inputType="numeric"
|
|
5661
|
-
* onComplete={(code) => console.log('Código:', code)}
|
|
5662
|
-
* hasError={false}
|
|
5663
|
-
* />
|
|
5664
|
-
* ```
|
|
5665
|
-
*/
|
|
5666
|
-
const VerificationCode = ({ length = 6, inputType = 'numeric', onComplete, hasError = false, errorMessage, disabled = false, className, ...rest }) => {
|
|
6100
|
+
const VerificationCode = ({ length = 6, validationType = 'numeric', value, defaultValue, onValueChange, autoSubmit = false, onAutoSubmit, name, form, hasError = false, errorMessage, disabled = false, readOnly = false, className, id, }) => {
|
|
5667
6101
|
const validLength = Math.min(Math.max(length, 1), 100);
|
|
5668
|
-
|
|
5669
|
-
const inputsRef = React.useRef([]);
|
|
5670
|
-
const currentRegex = REGEX_MAP[inputType] || REGEX_MAP.numeric;
|
|
5671
|
-
React.useEffect(() => {
|
|
5672
|
-
setValues(Array(validLength).fill(''));
|
|
5673
|
-
}, [inputType, validLength]);
|
|
5674
|
-
const handleChange = React.useCallback((index, value) => {
|
|
5675
|
-
if (!currentRegex.test(value))
|
|
5676
|
-
return;
|
|
5677
|
-
const newValues = [...values];
|
|
5678
|
-
newValues[index] = value;
|
|
5679
|
-
setValues(newValues);
|
|
5680
|
-
if (value && index < validLength - 1) {
|
|
5681
|
-
inputsRef.current[index + 1]?.focus();
|
|
5682
|
-
}
|
|
5683
|
-
if (newValues.every(v => v !== '')) {
|
|
5684
|
-
onComplete?.(newValues.join(''));
|
|
5685
|
-
}
|
|
5686
|
-
}, [values, currentRegex, onComplete, validLength]);
|
|
5687
|
-
const handlePaste = React.useCallback((e) => {
|
|
5688
|
-
e.preventDefault();
|
|
5689
|
-
const pasteData = e.clipboardData.getData('Text');
|
|
5690
|
-
const valuesToPaste = pasteData.split('').slice(0, validLength);
|
|
5691
|
-
const newValues = [...values];
|
|
5692
|
-
valuesToPaste.forEach((value, index) => {
|
|
5693
|
-
if (currentRegex.test(value)) {
|
|
5694
|
-
newValues[index] = value;
|
|
5695
|
-
}
|
|
5696
|
-
});
|
|
5697
|
-
setValues(newValues);
|
|
5698
|
-
const firstEmptyIndex = newValues.findIndex(v => v === '');
|
|
5699
|
-
const focusIndex = firstEmptyIndex === -1 ? validLength - 1 : firstEmptyIndex;
|
|
5700
|
-
inputsRef.current[focusIndex]?.focus();
|
|
5701
|
-
if (newValues.every(v => v !== '')) {
|
|
5702
|
-
onComplete?.(newValues.join(''));
|
|
5703
|
-
}
|
|
5704
|
-
}, [values, currentRegex, onComplete, validLength]);
|
|
5705
|
-
const handleKeyDown = React.useCallback((index, e) => {
|
|
5706
|
-
if (e.key === 'Backspace') {
|
|
5707
|
-
e.preventDefault();
|
|
5708
|
-
const newValues = [...values];
|
|
5709
|
-
if (values[index]) {
|
|
5710
|
-
newValues[index] = '';
|
|
5711
|
-
setValues(newValues);
|
|
5712
|
-
}
|
|
5713
|
-
else if (index > 0) {
|
|
5714
|
-
inputsRef.current[index - 1]?.focus();
|
|
5715
|
-
newValues[index - 1] = '';
|
|
5716
|
-
setValues(newValues);
|
|
5717
|
-
}
|
|
5718
|
-
}
|
|
5719
|
-
if (e.key === 'Delete') {
|
|
5720
|
-
e.preventDefault();
|
|
5721
|
-
const newValues = [...values];
|
|
5722
|
-
newValues[index] = '';
|
|
5723
|
-
setValues(newValues);
|
|
5724
|
-
if (index < validLength - 1) {
|
|
5725
|
-
inputsRef.current[index + 1]?.focus();
|
|
5726
|
-
}
|
|
5727
|
-
}
|
|
5728
|
-
if (e.key === 'ArrowLeft' && index > 0) {
|
|
5729
|
-
e.preventDefault();
|
|
5730
|
-
inputsRef.current[index - 1]?.focus();
|
|
5731
|
-
}
|
|
5732
|
-
if (e.key === 'ArrowRight' && index < validLength - 1) {
|
|
5733
|
-
e.preventDefault();
|
|
5734
|
-
inputsRef.current[index + 1]?.focus();
|
|
5735
|
-
}
|
|
5736
|
-
}, [values, validLength]);
|
|
5737
|
-
const handleKeyUp = React.useCallback((index, e) => {
|
|
5738
|
-
if (e.key === 'Enter') {
|
|
5739
|
-
e.preventDefault();
|
|
5740
|
-
if (values[index] && index < validLength - 1) {
|
|
5741
|
-
inputsRef.current[index + 1]?.focus();
|
|
5742
|
-
}
|
|
5743
|
-
else if (values[index] && index === validLength - 1) {
|
|
5744
|
-
inputsRef.current[index]?.blur();
|
|
5745
|
-
}
|
|
5746
|
-
}
|
|
5747
|
-
}, [values, validLength]);
|
|
5748
|
-
const handleFocus = React.useCallback((e) => {
|
|
5749
|
-
e.target.select();
|
|
5750
|
-
}, []);
|
|
5751
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: clsx(styles['zds-verification-code__container'], className), ...rest, children: values.map((val, i) => (jsxRuntime.jsx("input", { id: `zds-verification-code__element-${i}`, ref: (el) => {
|
|
5752
|
-
inputsRef.current[i] = el;
|
|
5753
|
-
}, type: "text", inputMode: inputType === 'numeric' ? 'numeric' : 'text', maxLength: 1, value: val, onChange: (e) => handleChange(i, e.target.value), onKeyDown: (e) => handleKeyDown(i, e), onKeyUp: (e) => handleKeyUp(i, e), onPaste: i === 0 ? handlePaste : undefined, onFocus: handleFocus, disabled: disabled, className: clsx(styles['zds-verification-code__input'], {
|
|
5754
|
-
[styles['zds-verification-code__has-error']]: hasError,
|
|
5755
|
-
[styles['zds-verification-code__filled']]: val,
|
|
5756
|
-
}), "aria-invalid": hasError, "aria-label": `Dígito ${i + 1} de ${validLength}`, "aria-describedby": hasError && errorMessage ? 'verification-code-error' : undefined, autoComplete: "one-time-code" }, i))) }), hasError && errorMessage && (jsxRuntime.jsx("div", { id: "verification-code-error", className: styles['zds-verification-code__error'], role: "alert", "aria-live": "assertive", children: errorMessage }))] }));
|
|
6102
|
+
return (jsxRuntime.jsxs("div", { id: id, className: clsx(styles.container, className), children: [jsxRuntime.jsxs(radixUi.unstable_OneTimePasswordField.Root, { className: styles.inputGroup, validationType: validationType, value: value, defaultValue: defaultValue, onValueChange: onValueChange, autoSubmit: autoSubmit, onAutoSubmit: onAutoSubmit, name: name, form: form, disabled: disabled, readOnly: readOnly, "data-error": hasError || undefined, children: [Array.from({ length: validLength }, (_, i) => (jsxRuntime.jsx(radixUi.unstable_OneTimePasswordField.Input, { className: clsx(styles.input, hasError && styles.inputError, disabled && styles.inputDisabled) }, i))), jsxRuntime.jsx(radixUi.unstable_OneTimePasswordField.HiddenInput, {})] }), hasError && errorMessage && (jsxRuntime.jsx("span", { className: styles.errorMessage, children: errorMessage }))] }));
|
|
5757
6103
|
};
|
|
5758
6104
|
|
|
5759
6105
|
function useApiSimulation(config = {}) {
|
|
@@ -6067,6 +6413,7 @@ exports.Container = Container;
|
|
|
6067
6413
|
exports.DatePicker = DatePicker_default;
|
|
6068
6414
|
exports.Dialog = Dialog;
|
|
6069
6415
|
exports.Drawer = Drawer;
|
|
6416
|
+
exports.FileUpload = FileUpload;
|
|
6070
6417
|
exports.Filter = Filter;
|
|
6071
6418
|
exports.ListItem = ListItem;
|
|
6072
6419
|
exports.Menu = Menu;
|