trotl-filter 1.0.7 → 1.0.9

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.esm.js CHANGED
@@ -8801,6 +8801,7 @@ function DateTimeInput({
8801
8801
  className = "",
8802
8802
  style = {},
8803
8803
  predefinedRanges = ["today", "yesterday"],
8804
+ startWith = "sunday",
8804
8805
  ...rest
8805
8806
  }) {
8806
8807
  const paramKey = pushUrlParamObj || null;
@@ -8999,8 +9000,12 @@ function DateTimeInput({
8999
9000
  // Build calendar days (6 weeks grid)
9000
9001
  const buildDays = () => {
9001
9002
  const startOfMonth = new Date(monthCursor.getFullYear(), monthCursor.getMonth(), 1);
9002
- const dayOfWeek = startOfMonth.getDay(); // 0 Sun ... 6 Sat
9003
- // We start at Sunday of the week containing the 1st
9003
+ let dayOfWeek = startOfMonth.getDay(); // 0 Sun ... 6 Sat
9004
+ // Adjust for Monday start
9005
+ if (startWith === "monday") {
9006
+ dayOfWeek = dayOfWeek === 0 ? 6 : dayOfWeek - 1;
9007
+ }
9008
+ // We start at the first day of the week containing the 1st
9004
9009
  const firstGridDate = new Date(startOfMonth);
9005
9010
  firstGridDate.setDate(startOfMonth.getDate() - dayOfWeek);
9006
9011
  const days = [];
@@ -9237,7 +9242,7 @@ function DateTimeInput({
9237
9242
  marginBottom: 4,
9238
9243
  opacity: 0.8
9239
9244
  }
9240
- }, ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'].map(d => /*#__PURE__*/React__default.createElement("div", {
9245
+ }, (startWith === "monday" ? ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'] : ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa']).map(d => /*#__PURE__*/React__default.createElement("div", {
9241
9246
  key: d,
9242
9247
  style: {
9243
9248
  textAlign: 'center'
@@ -9349,6 +9354,7 @@ DateTimeInput.propTypes = {
9349
9354
  * onChange: (startDate, endDate) => void
9350
9355
  * time: boolean - if true, show time selectors
9351
9356
  * timeStart, timeEnd: default times for start/end
9357
+ * startWith: "sunday" | "monday" - first day of week
9352
9358
  */
9353
9359
  function CalendarRangePicker({
9354
9360
  startDate,
@@ -9356,7 +9362,8 @@ function CalendarRangePicker({
9356
9362
  onChange,
9357
9363
  time = false,
9358
9364
  timeStart = "00:00",
9359
- timeEnd = "23:59"
9365
+ timeEnd = "23:59",
9366
+ startWith = "sunday"
9360
9367
  }) {
9361
9368
  // Current view months (show 2 months)
9362
9369
  const [leftMonth, setLeftMonth] = useState(() => {
@@ -9434,7 +9441,11 @@ function CalendarRangePicker({
9434
9441
  const monthIdx = month.getMonth();
9435
9442
  const firstDay = new Date(year, monthIdx, 1);
9436
9443
  const lastDay = new Date(year, monthIdx + 1, 0);
9437
- const startWeekday = firstDay.getDay(); // 0 = Sunday
9444
+ let startWeekday = firstDay.getDay(); // 0 = Sunday
9445
+ // Adjust for Monday start
9446
+ if (startWith === "monday") {
9447
+ startWeekday = startWeekday === 0 ? 6 : startWeekday - 1;
9448
+ }
9438
9449
  const daysInMonth = lastDay.getDate();
9439
9450
  const days = [];
9440
9451
  // Padding days from previous month
@@ -9481,7 +9492,7 @@ function CalendarRangePicker({
9481
9492
  gridTemplateColumns: "repeat(7, 1fr)",
9482
9493
  gap: 2
9483
9494
  }
9484
- }, ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"].map(day => /*#__PURE__*/React__default.createElement("div", {
9495
+ }, (startWith === "monday" ? ["Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"] : ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]).map(day => /*#__PURE__*/React__default.createElement("div", {
9485
9496
  key: day,
9486
9497
  style: {
9487
9498
  textAlign: "center",
@@ -9585,7 +9596,8 @@ CalendarRangePicker.propTypes = {
9585
9596
  onChange: PropTypes.func.isRequired,
9586
9597
  time: PropTypes.bool,
9587
9598
  timeStart: PropTypes.string,
9588
- timeEnd: PropTypes.string
9599
+ timeEnd: PropTypes.string,
9600
+ startWith: PropTypes.oneOf(["sunday", "monday"])
9589
9601
  };
9590
9602
 
9591
9603
  /**
@@ -9785,6 +9797,7 @@ function RangePicker({
9785
9797
  min,
9786
9798
  max,
9787
9799
  predefinedRanges = PREDEFINED_RANGES,
9800
+ startWith = "sunday",
9788
9801
  ...rest
9789
9802
  }) {
9790
9803
  const paramKey = pushUrlParamObj || null;
@@ -9940,6 +9953,28 @@ function RangePicker({
9940
9953
  const newUrl = window.location.pathname + (params.toString() ? `?${params.toString()}` : "");
9941
9954
  window.history.replaceState({}, "", newUrl);
9942
9955
  }, [paramKey]);
9956
+
9957
+ // Extract HH:mm part from the current range value
9958
+ const getTimeValue = useCallback(which => {
9959
+ const val = which === 'start' ? range[0] : range[1];
9960
+ if (val && val.includes('T')) {
9961
+ return val.split('T')[1].slice(0, 5);
9962
+ }
9963
+ return which === 'start' ? timeStart || "" : timeEnd || "";
9964
+ }, [range, timeStart, timeEnd]);
9965
+
9966
+ // Update time while keeping the selected date
9967
+ const handleTimeChange = which => e => {
9968
+ const newTime = e.target.value;
9969
+ const currentVal = which === 'start' ? range[0] : range[1];
9970
+ const datePart = currentVal && currentVal.split('T')[0] || formatDate(new Date(), false);
9971
+ const newVal = `${datePart}T${newTime}`;
9972
+ const newRange = which === 'start' ? [newVal, range[1]] : [range[0], newVal];
9973
+ if (!controlledValue) setRange(newRange);
9974
+ setUrlParam(newRange);
9975
+ setSelectedRange("");
9976
+ onChange?.(newRange);
9977
+ };
9943
9978
  const handleClear = () => {
9944
9979
  if (!controlledValue) setRange(["", ""]);
9945
9980
  setUrlParam(["", ""]);
@@ -10118,8 +10153,53 @@ function RangePicker({
10118
10153
  },
10119
10154
  time: time,
10120
10155
  timeStart: timeStart,
10121
- timeEnd: timeEnd
10122
- }), processedRanges && processedRanges.length > 0 && /*#__PURE__*/React__default.createElement("div", {
10156
+ timeEnd: timeEnd,
10157
+ startWith: startWith
10158
+ }), time && /*#__PURE__*/React__default.createElement("div", {
10159
+ style: {
10160
+ display: 'grid',
10161
+ gridTemplateColumns: '1fr 1fr',
10162
+ columnGap: 16,
10163
+ rowGap: 6,
10164
+ marginTop: 16,
10165
+ width: '99%',
10166
+ alignItems: 'center'
10167
+ }
10168
+ }, /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement("div", {
10169
+ style: {
10170
+ fontSize: 12,
10171
+ color: '#555',
10172
+ marginBottom: 6
10173
+ }
10174
+ }, "Start time"), /*#__PURE__*/React__default.createElement("input", {
10175
+ type: "time",
10176
+ value: getTimeValue('start'),
10177
+ onChange: handleTimeChange('start'),
10178
+ style: {
10179
+ width: '100%',
10180
+ padding: '4px 6px',
10181
+ border: '1px solid #d1d5db',
10182
+ borderRadius: 2,
10183
+ fontSize: 12
10184
+ }
10185
+ })), /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement("div", {
10186
+ style: {
10187
+ fontSize: 12,
10188
+ color: '#555',
10189
+ marginBottom: 6
10190
+ }
10191
+ }, "End time"), /*#__PURE__*/React__default.createElement("input", {
10192
+ type: "time",
10193
+ value: getTimeValue('end'),
10194
+ onChange: handleTimeChange('end'),
10195
+ style: {
10196
+ width: '100%',
10197
+ padding: '4px 6px',
10198
+ border: '1px solid #d1d5db',
10199
+ borderRadius: 2,
10200
+ fontSize: 12
10201
+ }
10202
+ }))), processedRanges && processedRanges.length > 0 && /*#__PURE__*/React__default.createElement("div", {
10123
10203
  style: {
10124
10204
  marginTop: 12,
10125
10205
  paddingTop: 12,
@@ -10206,6 +10286,7 @@ RangePicker.propTypes = {
10206
10286
  style: PropTypes.object,
10207
10287
  min: PropTypes.string,
10208
10288
  max: PropTypes.string,
10289
+ startWith: PropTypes.oneOf(["sunday", "monday"]),
10209
10290
  predefinedRanges: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string,
10210
10291
  // e.g., "today", "yesterday", "lastweek"
10211
10292
  PropTypes.number,