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