eidos-ui 4.2.0 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/{chunk-TUNG4IDW.cjs → chunk-6Z42NMP4.cjs} +3 -3
  2. package/dist/{chunk-TUNG4IDW.cjs.map → chunk-6Z42NMP4.cjs.map} +1 -1
  3. package/dist/{chunk-STVAB7FD.cjs → chunk-7OWJQHHM.cjs} +12 -12
  4. package/dist/{chunk-STVAB7FD.cjs.map → chunk-7OWJQHHM.cjs.map} +1 -1
  5. package/dist/{chunk-A7K53LDB.js → chunk-BMRZHFDP.js} +79 -42
  6. package/dist/chunk-BMRZHFDP.js.map +1 -0
  7. package/dist/{chunk-YEBWP7FD.cjs → chunk-I36GOOCM.cjs} +11 -11
  8. package/dist/{chunk-YEBWP7FD.cjs.map → chunk-I36GOOCM.cjs.map} +1 -1
  9. package/dist/{chunk-F2FGZFWF.js → chunk-KUP3CP24.js} +2 -2
  10. package/dist/{chunk-J2GJGXGH.cjs → chunk-QKCYXFET.cjs} +80 -43
  11. package/dist/{chunk-J2GJGXGH.cjs.map → chunk-QKCYXFET.cjs.map} +1 -1
  12. package/dist/{chunk-2LSQGDRH.js → chunk-QVUMYDRE.js} +2 -2
  13. package/dist/{chunk-AMVA62UC.js → chunk-YAZSZFLB.js} +2 -2
  14. package/dist/data-grid/index.cjs +4 -4
  15. package/dist/data-grid/index.js +3 -3
  16. package/dist/date-picker/index.cjs +2 -2
  17. package/dist/date-picker/index.d.cts +15 -1
  18. package/dist/date-picker/index.d.ts +15 -1
  19. package/dist/date-picker/index.js +1 -1
  20. package/dist/index.cjs +5 -5
  21. package/dist/index.css +1 -1
  22. package/dist/index.js +4 -4
  23. package/dist/table/index.cjs +4 -4
  24. package/dist/table/index.js +3 -3
  25. package/package.json +1 -1
  26. package/dist/chunk-A7K53LDB.js.map +0 -1
  27. /package/dist/{chunk-F2FGZFWF.js.map → chunk-KUP3CP24.js.map} +0 -0
  28. /package/dist/{chunk-2LSQGDRH.js.map → chunk-QVUMYDRE.js.map} +0 -0
  29. /package/dist/{chunk-AMVA62UC.js.map → chunk-YAZSZFLB.js.map} +0 -0
@@ -873,6 +873,7 @@ var DatePicker = ({
873
873
  value,
874
874
  onChange,
875
875
  granularity = "day",
876
+ showActions = false,
876
877
  time = { enabled: false },
877
878
  calendar = { numberOfCalendars: 2 },
878
879
  format = {
@@ -978,13 +979,30 @@ var DatePicker = ({
978
979
  },
979
980
  [time.enabled, pickerTimezone]
980
981
  );
982
+ const [draft, setDraft] = _react.useState.call(void 0, void 0);
983
+ const wasOpen = _react.useRef.call(void 0, false);
984
+ _react.useEffect.call(void 0, () => {
985
+ if (!showActions) return;
986
+ if (isOpen && !wasOpen.current)
987
+ setDraft(value);
988
+ else if (!isOpen && wasOpen.current) setDraft(void 0);
989
+ wasOpen.current = isOpen;
990
+ }, [isOpen, showActions, value]);
991
+ const effectiveValue = showActions ? _nullishCoalesce(draft, () => ( value)) : value;
992
+ const commit = _react.useCallback.call(void 0,
993
+ (newValue) => {
994
+ if (showActions) setDraft(newValue);
995
+ else _optionalChain([onChange, 'optionalCall', _12 => _12(newValue)]);
996
+ },
997
+ [showActions, onChange]
998
+ );
981
999
  const { selectedDates, rangeStart, rangeEnd } = _react.useMemo.call(void 0, () => {
982
- if (!_optionalChain([value, 'optionalAccess', _12 => _12.date])) {
1000
+ if (!_optionalChain([effectiveValue, 'optionalAccess', _13 => _13.date])) {
983
1001
  return { selectedDates: [], rangeStart: null, rangeEnd: null };
984
1002
  }
985
1003
  switch (mode) {
986
1004
  case "single": {
987
- const isoString = value.date;
1005
+ const isoString = effectiveValue.date;
988
1006
  const localDateStr = toLocalDateString(isoString);
989
1007
  return {
990
1008
  selectedDates: localDateStr ? [(0, import_dayjs2.default)(localDateStr)] : [],
@@ -993,7 +1011,7 @@ var DatePicker = ({
993
1011
  };
994
1012
  }
995
1013
  case "multiple": {
996
- const isoStrings = value.date;
1014
+ const isoStrings = effectiveValue.date;
997
1015
  const localDateStrings = isoStrings.map((d) => toLocalDateString(d)).filter(Boolean);
998
1016
  return {
999
1017
  selectedDates: localDateStrings.map((d) => (0, import_dayjs2.default)(d)),
@@ -1002,7 +1020,7 @@ var DatePicker = ({
1002
1020
  };
1003
1021
  }
1004
1022
  case "range": {
1005
- const range = value.date;
1023
+ const range = effectiveValue.date;
1006
1024
  const startStr = toLocalDateString(range.start);
1007
1025
  const endStr = toLocalDateString(range.end);
1008
1026
  return {
@@ -1014,15 +1032,16 @@ var DatePicker = ({
1014
1032
  default:
1015
1033
  return { selectedDates: [], rangeStart: null, rangeEnd: null };
1016
1034
  }
1017
- }, [value, mode, toLocalDateString]);
1035
+ }, [effectiveValue, mode, toLocalDateString]);
1018
1036
  const handleDateSelect = _react.useCallback.call(void 0,
1019
1037
  (selectedDate) => {
1020
1038
  const effectiveDate = granularity === "month" ? selectedDate.endOf("month") : selectedDate;
1039
+ const effectiveRangeStart = granularity === "month" ? selectedDate.startOf("month") : selectedDate;
1021
1040
  const compareUnit = granularity === "month" ? "month" : "day";
1022
1041
  switch (mode) {
1023
1042
  case "single": {
1024
1043
  let dateWithTime;
1025
- const activeTime = _nullishCoalesce(_optionalChain([value, 'optionalAccess', _13 => _13.time]), () => ( defaultStartTime));
1044
+ const activeTime = _nullishCoalesce(_optionalChain([effectiveValue, 'optionalAccess', _14 => _14.time]), () => ( defaultStartTime));
1026
1045
  if (time.enabled) {
1027
1046
  dateWithTime = composeLocalDateTime(effectiveDate, activeTime);
1028
1047
  } else {
@@ -1032,45 +1051,45 @@ var DatePicker = ({
1032
1051
  date: dateWithTime.toISOString(),
1033
1052
  time: time.enabled ? activeTime : void 0
1034
1053
  };
1035
- _optionalChain([onChange, 'optionalCall', _14 => _14(newValue)]);
1036
- setIsOpen(false);
1054
+ commit(newValue);
1055
+ if (!showActions) setIsOpen(false);
1037
1056
  break;
1038
1057
  }
1039
1058
  case "multiple": {
1040
- const currentDates = _optionalChain([value, 'optionalAccess', _15 => _15.date]) || [];
1059
+ const currentDates = _optionalChain([effectiveValue, 'optionalAccess', _15 => _15.date]) || [];
1041
1060
  const currentDayjs = currentDates.map((d) => (0, import_dayjs2.default)(d));
1042
1061
  const existingIndex = currentDayjs.findIndex((d) => d.isSame(effectiveDate, compareUnit));
1043
1062
  let newDates;
1044
1063
  if (existingIndex >= 0) {
1045
1064
  newDates = currentDayjs.filter((_, index) => index !== existingIndex);
1046
1065
  } else {
1047
- const activeTime = _nullishCoalesce(_optionalChain([value, 'optionalAccess', _16 => _16.time]), () => ( defaultStartTime));
1066
+ const activeTime = _nullishCoalesce(_optionalChain([effectiveValue, 'optionalAccess', _16 => _16.time]), () => ( defaultStartTime));
1048
1067
  const dateWithTime = time.enabled ? composeLocalDateTime(effectiveDate, activeTime) : composeDateOnly(effectiveDate, "start");
1049
1068
  newDates = [...currentDayjs, dateWithTime];
1050
1069
  }
1051
1070
  const newValue = {
1052
1071
  date: newDates.map((d) => d.toISOString()),
1053
- time: time.enabled ? _nullishCoalesce(_optionalChain([value, 'optionalAccess', _17 => _17.time]), () => ( defaultStartTime)) : void 0
1072
+ time: time.enabled ? _nullishCoalesce(_optionalChain([effectiveValue, 'optionalAccess', _17 => _17.time]), () => ( defaultStartTime)) : void 0
1054
1073
  };
1055
- _optionalChain([onChange, 'optionalCall', _18 => _18(newValue)]);
1074
+ commit(newValue);
1056
1075
  break;
1057
1076
  }
1058
1077
  case "range": {
1059
- const currentRange = _optionalChain([value, 'optionalAccess', _19 => _19.date]) || {
1078
+ const currentRange = _optionalChain([effectiveValue, 'optionalAccess', _18 => _18.date]) || {
1060
1079
  start: null,
1061
1080
  end: null
1062
1081
  };
1063
- const currentRangeTime = _optionalChain([value, 'optionalAccess', _20 => _20.time]) || {
1082
+ const currentRangeTime = _optionalChain([effectiveValue, 'optionalAccess', _19 => _19.time]) || {
1064
1083
  start: defaultStartTime,
1065
1084
  end: defaultEndTime
1066
1085
  };
1067
1086
  if (!currentRange.start || currentRange.start && currentRange.end) {
1068
- const startWithTime = time.enabled ? composeLocalDateTime(effectiveDate, currentRangeTime.start) : composeDateOnly(effectiveDate, "start");
1087
+ const startWithTime = time.enabled ? composeLocalDateTime(effectiveRangeStart, currentRangeTime.start) : composeDateOnly(effectiveRangeStart, "start");
1069
1088
  const newValue = {
1070
1089
  date: { start: startWithTime.toISOString(), end: null },
1071
1090
  time: time.enabled ? currentRangeTime : void 0
1072
1091
  };
1073
- _optionalChain([onChange, 'optionalCall', _21 => _21(newValue)]);
1092
+ commit(newValue);
1074
1093
  } else {
1075
1094
  const start = time.enabled ? (0, import_dayjs2.default)(currentRange.start) : (0, import_dayjs2.default)(currentRange.start).tz(pickerTimezone);
1076
1095
  let end = effectiveDate;
@@ -1085,8 +1104,8 @@ var DatePicker = ({
1085
1104
  },
1086
1105
  time: time.enabled ? currentRangeTime : void 0
1087
1106
  };
1088
- _optionalChain([onChange, 'optionalCall', _22 => _22(newValue)]);
1089
- setIsOpen(false);
1107
+ commit(newValue);
1108
+ if (!showActions) setIsOpen(false);
1090
1109
  }
1091
1110
  break;
1092
1111
  }
@@ -1095,8 +1114,9 @@ var DatePicker = ({
1095
1114
  [
1096
1115
  mode,
1097
1116
  time,
1098
- value,
1099
- onChange,
1117
+ effectiveValue,
1118
+ commit,
1119
+ showActions,
1100
1120
  defaultStartTime,
1101
1121
  defaultEndTime,
1102
1122
  composeDateOnly,
@@ -1106,7 +1126,7 @@ var DatePicker = ({
1106
1126
  ]
1107
1127
  );
1108
1128
  const displayValue = _react.useMemo.call(void 0, () => {
1109
- if (!_optionalChain([value, 'optionalAccess', _23 => _23.date])) return "";
1129
+ if (!_optionalChain([value, 'optionalAccess', _20 => _20.date])) return "";
1110
1130
  const displayFmt = format.displayFormat || (granularity === "month" ? "MMM YYYY" : "MMM DD, YYYY");
1111
1131
  const parseDateOnlyAware = (iso) => time.enabled ? (0, import_dayjs2.default)(iso) : (0, import_dayjs2.default)(iso).tz(pickerTimezone);
1112
1132
  switch (mode) {
@@ -1187,11 +1207,24 @@ var DatePicker = ({
1187
1207
  };
1188
1208
  }
1189
1209
  })();
1190
- _optionalChain([onChange, 'optionalCall', _24 => _24(clearedValue)]);
1191
- setIsOpen(false);
1210
+ if (showActions && isOpen) {
1211
+ setDraft(clearedValue);
1212
+ } else {
1213
+ _optionalChain([onChange, 'optionalCall', _21 => _21(clearedValue)]);
1214
+ setIsOpen(false);
1215
+ }
1192
1216
  },
1193
- [mode, time, onChange, defaultStartTime, defaultEndTime]
1217
+ [mode, time, onChange, showActions, isOpen, defaultStartTime, defaultEndTime]
1194
1218
  );
1219
+ const applyDraft = _react.useCallback.call(void 0, () => {
1220
+ const next = _nullishCoalesce(draft, () => ( value));
1221
+ if (next !== void 0) _optionalChain([onChange, 'optionalCall', _22 => _22(next)]);
1222
+ setIsOpen(false);
1223
+ }, [onChange, draft, value]);
1224
+ const cancelDraft = _react.useCallback.call(void 0, () => {
1225
+ setIsOpen(false);
1226
+ }, []);
1227
+ const applyDisabled = mode === "range" && !!draft && !!draft.date.start && !draft.date.end;
1195
1228
  const triggerElement = /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1196
1229
  "div",
1197
1230
  {
@@ -1264,15 +1297,15 @@ var DatePicker = ({
1264
1297
  mode === "single" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1265
1298
  TimeInput,
1266
1299
  {
1267
- value: _optionalChain([value, 'optionalAccess', _25 => _25.time]) || defaultStartTime,
1300
+ value: _optionalChain([effectiveValue, 'optionalAccess', _23 => _23.time]) || defaultStartTime,
1268
1301
  onChange: (newTime) => {
1269
- const currentIso = _optionalChain([value, 'optionalAccess', _26 => _26.date]);
1302
+ const currentIso = _optionalChain([effectiveValue, 'optionalAccess', _24 => _24.date]);
1270
1303
  const newValue = {
1271
- ...value,
1304
+ ...effectiveValue,
1272
1305
  date: currentIso ? recomposeIsoWithTime(currentIso, newTime) : currentIso,
1273
1306
  time: newTime
1274
1307
  };
1275
- _optionalChain([onChange, 'optionalCall', _27 => _27(newValue)]);
1308
+ commit(newValue);
1276
1309
  },
1277
1310
  includeSeconds: time.includeSeconds,
1278
1311
  disabled,
@@ -1282,17 +1315,17 @@ var DatePicker = ({
1282
1315
  mode === "multiple" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1283
1316
  TimeInput,
1284
1317
  {
1285
- value: _optionalChain([value, 'optionalAccess', _28 => _28.time]) || defaultStartTime,
1318
+ value: _optionalChain([effectiveValue, 'optionalAccess', _25 => _25.time]) || defaultStartTime,
1286
1319
  onChange: (newTime) => {
1287
- const currentDates = _optionalChain([value, 'optionalAccess', _29 => _29.date]) || [];
1320
+ const currentDates = _optionalChain([effectiveValue, 'optionalAccess', _26 => _26.date]) || [];
1288
1321
  const newValue = {
1289
- ...value,
1322
+ ...effectiveValue,
1290
1323
  date: currentDates.map(
1291
1324
  (d) => recomposeIsoWithTime(d, newTime)
1292
1325
  ),
1293
1326
  time: newTime
1294
1327
  };
1295
- _optionalChain([onChange, 'optionalCall', _30 => _30(newValue)]);
1328
+ commit(newValue);
1296
1329
  },
1297
1330
  includeSeconds: time.includeSeconds,
1298
1331
  disabled,
@@ -1303,18 +1336,18 @@ var DatePicker = ({
1303
1336
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1304
1337
  TimeInput,
1305
1338
  {
1306
- value: _optionalChain([value, 'optionalAccess', _31 => _31.time, 'optionalAccess', _32 => _32.start]) || defaultStartTime,
1339
+ value: _optionalChain([effectiveValue, 'optionalAccess', _27 => _27.time, 'optionalAccess', _28 => _28.start]) || defaultStartTime,
1307
1340
  onChange: (newTime) => {
1308
- const currentRangeTime = _optionalChain([value, 'optionalAccess', _33 => _33.time]) || {
1341
+ const currentRangeTime = _optionalChain([effectiveValue, 'optionalAccess', _29 => _29.time]) || {
1309
1342
  start: defaultStartTime,
1310
1343
  end: defaultEndTime
1311
1344
  };
1312
- const currentRange = _optionalChain([value, 'optionalAccess', _34 => _34.date]) || {
1345
+ const currentRange = _optionalChain([effectiveValue, 'optionalAccess', _30 => _30.date]) || {
1313
1346
  start: null,
1314
1347
  end: null
1315
1348
  };
1316
1349
  const newValue = {
1317
- ...value,
1350
+ ...effectiveValue,
1318
1351
  date: {
1319
1352
  ...currentRange,
1320
1353
  start: currentRange.start ? recomposeIsoWithTime(currentRange.start, newTime) : currentRange.start
@@ -1324,7 +1357,7 @@ var DatePicker = ({
1324
1357
  start: newTime
1325
1358
  }
1326
1359
  };
1327
- _optionalChain([onChange, 'optionalCall', _35 => _35(newValue)]);
1360
+ commit(newValue);
1328
1361
  },
1329
1362
  includeSeconds: time.includeSeconds,
1330
1363
  disabled,
@@ -1334,18 +1367,18 @@ var DatePicker = ({
1334
1367
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1335
1368
  TimeInput,
1336
1369
  {
1337
- value: _optionalChain([value, 'optionalAccess', _36 => _36.time, 'optionalAccess', _37 => _37.end]) || defaultEndTime,
1370
+ value: _optionalChain([effectiveValue, 'optionalAccess', _31 => _31.time, 'optionalAccess', _32 => _32.end]) || defaultEndTime,
1338
1371
  onChange: (newTime) => {
1339
- const currentRangeTime = _optionalChain([value, 'optionalAccess', _38 => _38.time]) || {
1372
+ const currentRangeTime = _optionalChain([effectiveValue, 'optionalAccess', _33 => _33.time]) || {
1340
1373
  start: defaultStartTime,
1341
1374
  end: defaultEndTime
1342
1375
  };
1343
- const currentRange = _optionalChain([value, 'optionalAccess', _39 => _39.date]) || {
1376
+ const currentRange = _optionalChain([effectiveValue, 'optionalAccess', _34 => _34.date]) || {
1344
1377
  start: null,
1345
1378
  end: null
1346
1379
  };
1347
1380
  const newValue = {
1348
- ...value,
1381
+ ...effectiveValue,
1349
1382
  date: {
1350
1383
  ...currentRange,
1351
1384
  end: currentRange.end ? recomposeIsoWithTime(currentRange.end, newTime) : currentRange.end
@@ -1355,7 +1388,7 @@ var DatePicker = ({
1355
1388
  end: newTime
1356
1389
  }
1357
1390
  };
1358
- _optionalChain([onChange, 'optionalCall', _40 => _40(newValue)]);
1391
+ commit(newValue);
1359
1392
  },
1360
1393
  includeSeconds: time.includeSeconds,
1361
1394
  disabled,
@@ -1363,6 +1396,10 @@ var DatePicker = ({
1363
1396
  }
1364
1397
  )
1365
1398
  ] })
1399
+ ] }),
1400
+ showActions && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "eidos-date-picker-actions", children: [
1401
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkNSA7ASZ7cjs.Button, { variant: "text", color: "secondary", onClick: cancelDraft, children: "Cancel" }),
1402
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkNSA7ASZ7cjs.Button, { variant: "filled", color: "primary", disabled: applyDisabled, onClick: applyDraft, children: "Apply" })
1366
1403
  ] })
1367
1404
  ] });
1368
1405
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
@@ -1396,4 +1433,4 @@ DatePicker.displayName = "DatePicker";
1396
1433
 
1397
1434
 
1398
1435
  exports.Calendar = Calendar; exports.TimeInput = TimeInput; exports.DatePicker = DatePicker;
1399
- //# sourceMappingURL=chunk-J2GJGXGH.cjs.map
1436
+ //# sourceMappingURL=chunk-QKCYXFET.cjs.map