@vector-business-services/cristal-ds-web 0.21.0 → 0.22.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 +329 -183
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +120 -87
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +41 -28
- package/dist/index.d.ts +41 -28
- package/dist/index.js +329 -183
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -16,9 +16,9 @@ var checkbox = require('primereact/checkbox');
|
|
|
16
16
|
var chip = require('primereact/chip');
|
|
17
17
|
var contextmenu = require('primereact/contextmenu');
|
|
18
18
|
var menu = require('primereact/menu');
|
|
19
|
-
var overlaypanel = require('primereact/overlaypanel');
|
|
20
19
|
var inputtext = require('primereact/inputtext');
|
|
21
20
|
var radiobutton = require('primereact/radiobutton');
|
|
21
|
+
var overlaypanel = require('primereact/overlaypanel');
|
|
22
22
|
var divider = require('primereact/divider');
|
|
23
23
|
var sidebar = require('primereact/sidebar');
|
|
24
24
|
var menubar = require('primereact/menubar');
|
|
@@ -1112,116 +1112,6 @@ var ContextMenu = react.forwardRef(function ContextMenu2({
|
|
|
1112
1112
|
}
|
|
1113
1113
|
);
|
|
1114
1114
|
});
|
|
1115
|
-
function DatePickerBase({
|
|
1116
|
-
variant = "outline",
|
|
1117
|
-
size = "large",
|
|
1118
|
-
label,
|
|
1119
|
-
hint,
|
|
1120
|
-
error,
|
|
1121
|
-
offDays,
|
|
1122
|
-
locale = LOCALE,
|
|
1123
|
-
placeholder = "dd/mm/aaaa",
|
|
1124
|
-
inputId,
|
|
1125
|
-
required,
|
|
1126
|
-
disabled,
|
|
1127
|
-
className,
|
|
1128
|
-
style,
|
|
1129
|
-
onShow,
|
|
1130
|
-
onHide,
|
|
1131
|
-
...props
|
|
1132
|
-
}, ref) {
|
|
1133
|
-
const autoId = react.useId();
|
|
1134
|
-
const id = inputId ?? autoId;
|
|
1135
|
-
const hintId = `${id}-hint`;
|
|
1136
|
-
const supportText = error ?? hint;
|
|
1137
|
-
const pelaSeta = react.useRef(false);
|
|
1138
|
-
const peloTeclado = react.useRef(false);
|
|
1139
|
-
const calendario = react.useRef(null);
|
|
1140
|
-
react.useImperativeHandle(ref, () => calendario.current, []);
|
|
1141
|
-
const classes2 = [
|
|
1142
|
-
"cr-field",
|
|
1143
|
-
"cr-datepicker",
|
|
1144
|
-
`cr-field--${variant}`,
|
|
1145
|
-
`cr-field--${size}`,
|
|
1146
|
-
error && "cr-field--error",
|
|
1147
|
-
disabled && "cr-field--disabled",
|
|
1148
|
-
className
|
|
1149
|
-
].filter(Boolean).join(" ");
|
|
1150
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classes2, style, children: [
|
|
1151
|
-
label && /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "cr-field__label", htmlFor: id, children: [
|
|
1152
|
-
label,
|
|
1153
|
-
required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "cr-field__required", "aria-hidden": "true", children: "*" })
|
|
1154
|
-
] }),
|
|
1155
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1156
|
-
calendar.Calendar,
|
|
1157
|
-
{
|
|
1158
|
-
...setas,
|
|
1159
|
-
locale,
|
|
1160
|
-
placeholder,
|
|
1161
|
-
...props,
|
|
1162
|
-
ref: calendario,
|
|
1163
|
-
unstyled: true,
|
|
1164
|
-
inputId: id,
|
|
1165
|
-
required,
|
|
1166
|
-
disabled,
|
|
1167
|
-
showIcon: true,
|
|
1168
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(react$1.CalendarDot, { "aria-hidden": "true" }),
|
|
1169
|
-
onShow: () => {
|
|
1170
|
-
if (!pelaSeta.current) document.getElementById(id)?.focus();
|
|
1171
|
-
pelaSeta.current = false;
|
|
1172
|
-
onShow?.();
|
|
1173
|
-
},
|
|
1174
|
-
onHide: () => {
|
|
1175
|
-
const atual = calendario.current;
|
|
1176
|
-
const ativo = document.activeElement;
|
|
1177
|
-
const semFoco = ativo === document.body || atual?.getOverlay()?.contains(ativo);
|
|
1178
|
-
if (peloTeclado.current && semFoco && atual) {
|
|
1179
|
-
atual.focus();
|
|
1180
|
-
atual.hide();
|
|
1181
|
-
}
|
|
1182
|
-
peloTeclado.current = false;
|
|
1183
|
-
pelaSeta.current = false;
|
|
1184
|
-
onHide?.();
|
|
1185
|
-
},
|
|
1186
|
-
pt: {
|
|
1187
|
-
root: { className: "cr-datepicker__root" },
|
|
1188
|
-
input: {
|
|
1189
|
-
root: {
|
|
1190
|
-
className: "cr-field__control cr-datepicker__input",
|
|
1191
|
-
"aria-describedby": supportText ? hintId : void 0,
|
|
1192
|
-
"aria-invalid": error ? true : void 0,
|
|
1193
|
-
onKeyDown: (event) => {
|
|
1194
|
-
if (event.code === "ArrowDown" && !calendario.current?.getOverlay()) {
|
|
1195
|
-
pelaSeta.current = true;
|
|
1196
|
-
}
|
|
1197
|
-
}
|
|
1198
|
-
}
|
|
1199
|
-
},
|
|
1200
|
-
dropdownButton: { root: { className: "cr-datepicker__button" } },
|
|
1201
|
-
panel: {
|
|
1202
|
-
className: "cr-calendar cr-datepicker__panel",
|
|
1203
|
-
onKeyDown: (event) => {
|
|
1204
|
-
if (["Enter", "NumpadEnter", "Space"].includes(event.code))
|
|
1205
|
-
peloTeclado.current = true;
|
|
1206
|
-
}
|
|
1207
|
-
},
|
|
1208
|
-
// Animação de entrada e saída (a do Prime) e o lado do painel, medido logo depois de o
|
|
1209
|
-
// Prime posicionar.
|
|
1210
|
-
transition: transicaoDoPopup(() => {
|
|
1211
|
-
const campo = document.getElementById(id);
|
|
1212
|
-
seguirLado(painelDoCampo(campo, ".cr-datepicker__panel"), campo);
|
|
1213
|
-
}),
|
|
1214
|
-
...ptDoPainel(offDays)
|
|
1215
|
-
}
|
|
1216
|
-
}
|
|
1217
|
-
),
|
|
1218
|
-
supportText && /* @__PURE__ */ jsxRuntime.jsxs("p", { id: hintId, className: `cr-field__hint${error ? " cr-field__hint--error" : ""}`, children: [
|
|
1219
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "cr-field__hint-icon", "aria-hidden": "true", children: error ? /* @__PURE__ */ jsxRuntime.jsx(react$1.WarningCircle, {}) : /* @__PURE__ */ jsxRuntime.jsx(react$1.Info, {}) }),
|
|
1220
|
-
supportText
|
|
1221
|
-
] })
|
|
1222
|
-
] });
|
|
1223
|
-
}
|
|
1224
|
-
var DatePicker = react.forwardRef(DatePickerBase);
|
|
1225
1115
|
var Input = react.forwardRef(function Input2({
|
|
1226
1116
|
variant = "outline",
|
|
1227
1117
|
size = "large",
|
|
@@ -1334,7 +1224,7 @@ var Radio = react.forwardRef(function Radio2({
|
|
|
1334
1224
|
] });
|
|
1335
1225
|
});
|
|
1336
1226
|
|
|
1337
|
-
// src/components/
|
|
1227
|
+
// src/components/Calendar/periodos.ts
|
|
1338
1228
|
var dia = (ano, mes, numero) => new Date(ano, mes, numero);
|
|
1339
1229
|
var semHora = (data) => dia(data.getFullYear(), data.getMonth(), data.getDate());
|
|
1340
1230
|
var menos = (data, dias) => dia(data.getFullYear(), data.getMonth(), data.getDate() - dias);
|
|
@@ -1392,6 +1282,302 @@ function lerData(texto) {
|
|
|
1392
1282
|
const data = dia(a, m - 1, d);
|
|
1393
1283
|
return data.getMonth() === m - 1 && data.getDate() === d ? data : null;
|
|
1394
1284
|
}
|
|
1285
|
+
function ListaDePeriodos({
|
|
1286
|
+
periods,
|
|
1287
|
+
periodo,
|
|
1288
|
+
onEscolher
|
|
1289
|
+
}) {
|
|
1290
|
+
const grupo = react.useId();
|
|
1291
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "cr-data-picker__periods", role: "radiogroup", "aria-label": "Per\xEDodos", children: periods.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1292
|
+
Radio,
|
|
1293
|
+
{
|
|
1294
|
+
className: "cr-data-picker__period",
|
|
1295
|
+
name: grupo,
|
|
1296
|
+
label: item.label,
|
|
1297
|
+
value: item.label,
|
|
1298
|
+
checked: periodo === item,
|
|
1299
|
+
onChange: () => onEscolher(item)
|
|
1300
|
+
},
|
|
1301
|
+
item.label
|
|
1302
|
+
)) });
|
|
1303
|
+
}
|
|
1304
|
+
var mesmoRascunho = (a, b) => (a[0] === b[0] || mesmoDia2(a[0], b[0])) && (a[1] === b[1] || mesmoDia2(a[1], b[1]));
|
|
1305
|
+
function CamposDoPeriodo({
|
|
1306
|
+
value,
|
|
1307
|
+
onChange
|
|
1308
|
+
}) {
|
|
1309
|
+
const [textos, setTextos] = react.useState([
|
|
1310
|
+
dataCurta(value[0]),
|
|
1311
|
+
dataCurta(value[1])
|
|
1312
|
+
]);
|
|
1313
|
+
const [base, setBase] = react.useState(value);
|
|
1314
|
+
if (!mesmoRascunho(base, value)) {
|
|
1315
|
+
setBase(value);
|
|
1316
|
+
setTextos([dataCurta(value[0]), dataCurta(value[1])]);
|
|
1317
|
+
}
|
|
1318
|
+
const digitar = (indice, texto) => {
|
|
1319
|
+
const novosTextos = [...textos];
|
|
1320
|
+
novosTextos[indice] = texto;
|
|
1321
|
+
setTextos(novosTextos);
|
|
1322
|
+
const data = lerData(texto);
|
|
1323
|
+
if (!data) return;
|
|
1324
|
+
const novo = [...value];
|
|
1325
|
+
novo[indice] = data;
|
|
1326
|
+
if (novo[0] && novo[1] && novo[0] > novo[1]) novo[indice === 0 ? 1 : 0] = null;
|
|
1327
|
+
setBase(novo);
|
|
1328
|
+
onChange(novo);
|
|
1329
|
+
};
|
|
1330
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cr-data-picker__inputs", children: [
|
|
1331
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1332
|
+
Input,
|
|
1333
|
+
{
|
|
1334
|
+
size: "medium",
|
|
1335
|
+
"aria-label": "Data inicial",
|
|
1336
|
+
placeholder: "dd / mm / aaaa",
|
|
1337
|
+
value: textos[0],
|
|
1338
|
+
onChange: (event) => digitar(0, event.target.value)
|
|
1339
|
+
}
|
|
1340
|
+
),
|
|
1341
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "cr-data-picker__dash", "aria-hidden": "true", children: "-" }),
|
|
1342
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1343
|
+
Input,
|
|
1344
|
+
{
|
|
1345
|
+
size: "medium",
|
|
1346
|
+
"aria-label": "Data final",
|
|
1347
|
+
placeholder: "dd / mm / aaaa",
|
|
1348
|
+
value: textos[1],
|
|
1349
|
+
onChange: (event) => digitar(1, event.target.value)
|
|
1350
|
+
}
|
|
1351
|
+
)
|
|
1352
|
+
] });
|
|
1353
|
+
}
|
|
1354
|
+
function RodapeDoPeriodo({
|
|
1355
|
+
podeSelecionar,
|
|
1356
|
+
onFechar,
|
|
1357
|
+
onSelecionar
|
|
1358
|
+
}) {
|
|
1359
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cr-data-picker__footer", children: [
|
|
1360
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { variant: "tertiary", size: "medium", onClick: onFechar, children: "Fechar" }),
|
|
1361
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { size: "medium", disabled: !podeSelecionar, onClick: onSelecionar, children: "Selecionar" })
|
|
1362
|
+
] });
|
|
1363
|
+
}
|
|
1364
|
+
function DatePickerBase({
|
|
1365
|
+
variant = "outline",
|
|
1366
|
+
size = "large",
|
|
1367
|
+
label,
|
|
1368
|
+
hint,
|
|
1369
|
+
error,
|
|
1370
|
+
offDays,
|
|
1371
|
+
locale = LOCALE,
|
|
1372
|
+
placeholder = "dd/mm/aaaa",
|
|
1373
|
+
inputId,
|
|
1374
|
+
required,
|
|
1375
|
+
disabled,
|
|
1376
|
+
className,
|
|
1377
|
+
style,
|
|
1378
|
+
onShow,
|
|
1379
|
+
onHide,
|
|
1380
|
+
periods = [],
|
|
1381
|
+
footer = false,
|
|
1382
|
+
today,
|
|
1383
|
+
value,
|
|
1384
|
+
onChange,
|
|
1385
|
+
footerTemplate,
|
|
1386
|
+
...props
|
|
1387
|
+
}, ref) {
|
|
1388
|
+
const autoId = react.useId();
|
|
1389
|
+
const id = inputId ?? autoId;
|
|
1390
|
+
const hintId = `${id}-hint`;
|
|
1391
|
+
const supportText = error ?? hint;
|
|
1392
|
+
const pelaSeta = react.useRef(false);
|
|
1393
|
+
const peloTeclado = react.useRef(false);
|
|
1394
|
+
const calendario = react.useRef(null);
|
|
1395
|
+
react.useImperativeHandle(ref, () => calendario.current, []);
|
|
1396
|
+
const comPeriodos = props.selectionMode === "range" && periods.length > 0;
|
|
1397
|
+
const dataPicker = footer || comPeriodos;
|
|
1398
|
+
const [aberto, setAberto] = react.useState(false);
|
|
1399
|
+
const [rascunho, setRascunho] = react.useState(null);
|
|
1400
|
+
const [periodo, setPeriodo] = react.useState(null);
|
|
1401
|
+
const devolverFoco = react.useRef(false);
|
|
1402
|
+
const ignorarAbertura = react.useRef(false);
|
|
1403
|
+
const valorNaTela = footer && aberto ? rascunho : value;
|
|
1404
|
+
const emitir = (novo) => onChange?.({
|
|
1405
|
+
value: novo,
|
|
1406
|
+
stopPropagation: () => {
|
|
1407
|
+
},
|
|
1408
|
+
preventDefault: () => {
|
|
1409
|
+
},
|
|
1410
|
+
target: { name: props.name, id, value: novo }
|
|
1411
|
+
});
|
|
1412
|
+
const fechar = (pelosBotoes) => {
|
|
1413
|
+
devolverFoco.current = pelosBotoes;
|
|
1414
|
+
setAberto(false);
|
|
1415
|
+
};
|
|
1416
|
+
const mudar = (novo, novoPeriodo) => {
|
|
1417
|
+
setPeriodo(novoPeriodo);
|
|
1418
|
+
if (footer) setRascunho(novo);
|
|
1419
|
+
else emitir(novo);
|
|
1420
|
+
};
|
|
1421
|
+
const classes2 = [
|
|
1422
|
+
"cr-field",
|
|
1423
|
+
"cr-datepicker",
|
|
1424
|
+
`cr-field--${variant}`,
|
|
1425
|
+
`cr-field--${size}`,
|
|
1426
|
+
error && "cr-field--error",
|
|
1427
|
+
disabled && "cr-field--disabled",
|
|
1428
|
+
className
|
|
1429
|
+
].filter(Boolean).join(" ");
|
|
1430
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classes2, style, children: [
|
|
1431
|
+
label && /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "cr-field__label", htmlFor: id, children: [
|
|
1432
|
+
label,
|
|
1433
|
+
required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "cr-field__required", "aria-hidden": "true", children: "*" })
|
|
1434
|
+
] }),
|
|
1435
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1436
|
+
calendar.Calendar,
|
|
1437
|
+
{
|
|
1438
|
+
...setas,
|
|
1439
|
+
locale,
|
|
1440
|
+
placeholder,
|
|
1441
|
+
...props,
|
|
1442
|
+
value: valorNaTela,
|
|
1443
|
+
onChange: footer ? (event) => mudar(event.value, null) : comPeriodos ? (event) => {
|
|
1444
|
+
setPeriodo(null);
|
|
1445
|
+
onChange?.(event);
|
|
1446
|
+
} : onChange,
|
|
1447
|
+
...dataPicker && {
|
|
1448
|
+
visible: aberto,
|
|
1449
|
+
onVisibleChange: (event) => {
|
|
1450
|
+
if (!event.callback) {
|
|
1451
|
+
if (ignorarAbertura.current || aberto) return;
|
|
1452
|
+
const hoje = today ?? /* @__PURE__ */ new Date();
|
|
1453
|
+
setRascunho(value);
|
|
1454
|
+
setPeriodo(periodoDe(periods, value ?? null, hoje) ?? null);
|
|
1455
|
+
setAberto(true);
|
|
1456
|
+
return;
|
|
1457
|
+
}
|
|
1458
|
+
if (footer && event.type === "dateselect") return;
|
|
1459
|
+
fechar(false);
|
|
1460
|
+
event.callback?.();
|
|
1461
|
+
},
|
|
1462
|
+
footerTemplate: () => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1463
|
+
comPeriodos && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1464
|
+
ListaDePeriodos,
|
|
1465
|
+
{
|
|
1466
|
+
periods,
|
|
1467
|
+
periodo,
|
|
1468
|
+
onEscolher: (item) => {
|
|
1469
|
+
mudar(item.range(today ?? /* @__PURE__ */ new Date()), item);
|
|
1470
|
+
if (!footer) fechar(true);
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
),
|
|
1474
|
+
props.selectionMode === "range" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1475
|
+
CamposDoPeriodo,
|
|
1476
|
+
{
|
|
1477
|
+
value: valorNaTela ?? [null, null],
|
|
1478
|
+
onChange: (novo) => mudar(novo, null)
|
|
1479
|
+
}
|
|
1480
|
+
),
|
|
1481
|
+
footer && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1482
|
+
RodapeDoPeriodo,
|
|
1483
|
+
{
|
|
1484
|
+
podeSelecionar: props.selectionMode === "range" ? Boolean(rascunho?.[0] && rascunho[1]) : rascunho != null,
|
|
1485
|
+
onFechar: () => fechar(true),
|
|
1486
|
+
onSelecionar: () => {
|
|
1487
|
+
emitir(rascunho);
|
|
1488
|
+
fechar(true);
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
)
|
|
1492
|
+
] })
|
|
1493
|
+
},
|
|
1494
|
+
...!dataPicker && { footerTemplate },
|
|
1495
|
+
ref: calendario,
|
|
1496
|
+
unstyled: true,
|
|
1497
|
+
inputId: id,
|
|
1498
|
+
required,
|
|
1499
|
+
disabled,
|
|
1500
|
+
showIcon: true,
|
|
1501
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(react$1.CalendarDot, { "aria-hidden": "true" }),
|
|
1502
|
+
onShow: () => {
|
|
1503
|
+
if (!pelaSeta.current) document.getElementById(id)?.focus();
|
|
1504
|
+
pelaSeta.current = false;
|
|
1505
|
+
onShow?.();
|
|
1506
|
+
},
|
|
1507
|
+
onHide: () => {
|
|
1508
|
+
const atual = calendario.current;
|
|
1509
|
+
const ativo = document.activeElement;
|
|
1510
|
+
const semFoco = ativo === document.body || atual?.getOverlay()?.contains(ativo);
|
|
1511
|
+
if ((peloTeclado.current || devolverFoco.current) && semFoco && atual) {
|
|
1512
|
+
if (dataPicker) {
|
|
1513
|
+
ignorarAbertura.current = true;
|
|
1514
|
+
atual.focus();
|
|
1515
|
+
ignorarAbertura.current = false;
|
|
1516
|
+
} else {
|
|
1517
|
+
atual.focus();
|
|
1518
|
+
atual.hide();
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
peloTeclado.current = false;
|
|
1522
|
+
pelaSeta.current = false;
|
|
1523
|
+
devolverFoco.current = false;
|
|
1524
|
+
onHide?.();
|
|
1525
|
+
},
|
|
1526
|
+
pt: {
|
|
1527
|
+
root: { className: "cr-datepicker__root" },
|
|
1528
|
+
input: {
|
|
1529
|
+
root: {
|
|
1530
|
+
className: "cr-field__control cr-datepicker__input",
|
|
1531
|
+
"aria-describedby": supportText ? hintId : void 0,
|
|
1532
|
+
"aria-invalid": error ? true : void 0,
|
|
1533
|
+
onKeyDown: (event) => {
|
|
1534
|
+
if (event.code === "ArrowDown" && !calendario.current?.getOverlay()) {
|
|
1535
|
+
pelaSeta.current = true;
|
|
1536
|
+
}
|
|
1537
|
+
const painel = calendario.current?.getOverlay();
|
|
1538
|
+
if (dataPicker && event.code === "ArrowDown" && painel) {
|
|
1539
|
+
const dia2 = painel.querySelector(".cr-calendar__date--selected") ?? painel.querySelector(
|
|
1540
|
+
".cr-calendar__date:not(.cr-calendar__date--disabled)"
|
|
1541
|
+
);
|
|
1542
|
+
if (dia2) {
|
|
1543
|
+
event.preventDefault();
|
|
1544
|
+
dia2.tabIndex = 0;
|
|
1545
|
+
dia2.focus();
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1550
|
+
},
|
|
1551
|
+
dropdownButton: { root: { className: "cr-datepicker__button" } },
|
|
1552
|
+
panel: {
|
|
1553
|
+
className: `cr-calendar cr-datepicker__panel${dataPicker ? " cr-datepicker__panel--data-picker" : ""}`,
|
|
1554
|
+
onKeyDown: (event) => {
|
|
1555
|
+
if (["Enter", "NumpadEnter", "Space"].includes(event.code))
|
|
1556
|
+
peloTeclado.current = true;
|
|
1557
|
+
if (dataPicker && event.code === "Escape" && aberto) fechar(true);
|
|
1558
|
+
}
|
|
1559
|
+
},
|
|
1560
|
+
// Animação de entrada e saída (a do Prime) e o lado do painel, medido logo depois de o
|
|
1561
|
+
// Prime posicionar.
|
|
1562
|
+
transition: transicaoDoPopup(() => {
|
|
1563
|
+
const campo = document.getElementById(id);
|
|
1564
|
+
seguirLado(painelDoCampo(campo, ".cr-datepicker__panel"), campo);
|
|
1565
|
+
}),
|
|
1566
|
+
...ptDoPainel(offDays),
|
|
1567
|
+
// As partes do Data Picker entram no rodapé do Prime, que some no layout: cada uma ocupa o
|
|
1568
|
+
// seu lugar na grade do painel (DatePicker.css). O Prime aplica o pt do footer, mas não o
|
|
1569
|
+
// declara no tipo.
|
|
1570
|
+
...{ footer: { className: "cr-datepicker__extras" } }
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
),
|
|
1574
|
+
supportText && /* @__PURE__ */ jsxRuntime.jsxs("p", { id: hintId, className: `cr-field__hint${error ? " cr-field__hint--error" : ""}`, children: [
|
|
1575
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "cr-field__hint-icon", "aria-hidden": "true", children: error ? /* @__PURE__ */ jsxRuntime.jsx(react$1.WarningCircle, {}) : /* @__PURE__ */ jsxRuntime.jsx(react$1.Info, {}) }),
|
|
1576
|
+
supportText
|
|
1577
|
+
] })
|
|
1578
|
+
] });
|
|
1579
|
+
}
|
|
1580
|
+
var DatePicker = react.forwardRef(DatePickerBase);
|
|
1395
1581
|
function mesDaTela(range, meses, hoje) {
|
|
1396
1582
|
const base = (meses > 1 ? range[1] : range[0]) ?? range[0] ?? hoje;
|
|
1397
1583
|
return new Date(base.getFullYear(), base.getMonth() - (meses > 1 ? 1 : 0), 1);
|
|
@@ -1409,76 +1595,40 @@ function PainelDePeriodo({
|
|
|
1409
1595
|
onSelect,
|
|
1410
1596
|
onClose
|
|
1411
1597
|
}) {
|
|
1412
|
-
const grupo = react.useId();
|
|
1413
1598
|
const [rascunho, setRascunho] = react.useState(value ?? [null, null]);
|
|
1414
1599
|
const [periodo, setPeriodo] = react.useState(() => periodoDe(periods, value, today) ?? null);
|
|
1415
|
-
const [textos, setTextos] = react.useState([
|
|
1416
|
-
dataCurta(value?.[0]),
|
|
1417
|
-
dataCurta(value?.[1])
|
|
1418
|
-
]);
|
|
1419
1600
|
const [mes, setMes] = react.useState(() => mesDaTela(rascunho, numberOfMonths, today));
|
|
1420
|
-
const mudar = (novo, novoPeriodo
|
|
1601
|
+
const mudar = (novo, novoPeriodo) => {
|
|
1421
1602
|
setRascunho(novo);
|
|
1422
1603
|
setPeriodo(novoPeriodo);
|
|
1423
|
-
if (mudarTextos) setTextos([dataCurta(novo[0]), dataCurta(novo[1])]);
|
|
1424
1604
|
if (!footer && novo[0] && novo[1]) onSelect([novo[0], novo[1]], novoPeriodo);
|
|
1425
1605
|
};
|
|
1426
|
-
const escolherPeriodo = (item) => {
|
|
1427
|
-
const range = item.range(today);
|
|
1428
|
-
setMes(mesDaTela(range, numberOfMonths, today));
|
|
1429
|
-
mudar(range, item);
|
|
1430
|
-
};
|
|
1431
|
-
const digitar = (indice, texto) => {
|
|
1432
|
-
const novosTextos = [...textos];
|
|
1433
|
-
novosTextos[indice] = texto;
|
|
1434
|
-
setTextos(novosTextos);
|
|
1435
|
-
const data = lerData(texto);
|
|
1436
|
-
if (!data) return;
|
|
1437
|
-
const novo = [...rascunho];
|
|
1438
|
-
novo[indice] = data;
|
|
1439
|
-
if (novo[0] && novo[1] && novo[0] > novo[1]) novo[indice === 0 ? 1 : 0] = null;
|
|
1440
|
-
setMes(mesDaTela(novo, numberOfMonths, today));
|
|
1441
|
-
mudar(novo, null, false);
|
|
1442
|
-
};
|
|
1443
1606
|
const [inicio, fim] = rascunho;
|
|
1444
1607
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cr-date-range", children: [
|
|
1445
1608
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cr-date-range__body", children: [
|
|
1446
|
-
periods.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1447
|
-
|
|
1609
|
+
periods.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1610
|
+
ListaDePeriodos,
|
|
1448
1611
|
{
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
)
|
|
1612
|
+
periods,
|
|
1613
|
+
periodo,
|
|
1614
|
+
onEscolher: (item) => {
|
|
1615
|
+
const range = item.range(today);
|
|
1616
|
+
setMes(mesDaTela(range, numberOfMonths, today));
|
|
1617
|
+
mudar(range, item);
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
),
|
|
1458
1621
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cr-date-range__calendars", children: [
|
|
1459
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
value: textos[0],
|
|
1467
|
-
onChange: (event) => digitar(0, event.target.value)
|
|
1468
|
-
}
|
|
1469
|
-
),
|
|
1470
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "cr-date-range__dash", "aria-hidden": "true", children: "-" }),
|
|
1471
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1472
|
-
Input,
|
|
1473
|
-
{
|
|
1474
|
-
size: "medium",
|
|
1475
|
-
"aria-label": "Data final",
|
|
1476
|
-
placeholder: "dd / mm / aaaa",
|
|
1477
|
-
value: textos[1],
|
|
1478
|
-
onChange: (event) => digitar(1, event.target.value)
|
|
1622
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1623
|
+
CamposDoPeriodo,
|
|
1624
|
+
{
|
|
1625
|
+
value: rascunho,
|
|
1626
|
+
onChange: (novo) => {
|
|
1627
|
+
setMes(mesDaTela(novo, numberOfMonths, today));
|
|
1628
|
+
mudar(novo, null);
|
|
1479
1629
|
}
|
|
1480
|
-
|
|
1481
|
-
|
|
1630
|
+
}
|
|
1631
|
+
),
|
|
1482
1632
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1483
1633
|
Calendar,
|
|
1484
1634
|
{
|
|
@@ -1488,8 +1638,8 @@ function PainelDePeriodo({
|
|
|
1488
1638
|
viewDate: mes,
|
|
1489
1639
|
onViewDateChange: (event) => setMes(event.value),
|
|
1490
1640
|
onChange: (event) => {
|
|
1491
|
-
const [
|
|
1492
|
-
mudar([
|
|
1641
|
+
const [novoInicio = null, novoFim = null] = event.value ?? [];
|
|
1642
|
+
mudar([novoInicio, novoFim], null);
|
|
1493
1643
|
},
|
|
1494
1644
|
minDate,
|
|
1495
1645
|
maxDate,
|
|
@@ -1499,18 +1649,14 @@ function PainelDePeriodo({
|
|
|
1499
1649
|
)
|
|
1500
1650
|
] })
|
|
1501
1651
|
] }),
|
|
1502
|
-
footer && /* @__PURE__ */ jsxRuntime.
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
children: "Selecionar"
|
|
1511
|
-
}
|
|
1512
|
-
)
|
|
1513
|
-
] })
|
|
1652
|
+
footer && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1653
|
+
RodapeDoPeriodo,
|
|
1654
|
+
{
|
|
1655
|
+
podeSelecionar: Boolean(inicio && fim),
|
|
1656
|
+
onFechar: onClose,
|
|
1657
|
+
onSelecionar: () => inicio && fim && onSelect([inicio, fim], periodo)
|
|
1658
|
+
}
|
|
1659
|
+
)
|
|
1514
1660
|
] });
|
|
1515
1661
|
}
|
|
1516
1662
|
var DateRangeButton = react.forwardRef(
|