@autobusal/common 1.27.3 → 1.27.5

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/CHANGELOG.md CHANGED
@@ -1,5 +1,44 @@
1
1
  # Changelog
2
2
 
3
+
4
+ ## 1.27.5
5
+
6
+ ### Added
7
+
8
+ - **`placeholder` on a `select`** — a leading empty option, for "nothing
9
+ chosen".
10
+
11
+ A select whose value matches no option silently displays the first one and
12
+ the browser submits it as though it had been picked. That is exactly how
13
+ every profile whose owner never touched the country field was saved as
14
+ **Afghanistan**: it sorts first, and nothing had ever been selected.
15
+ Changing the default from `0` to `''` did not help on its own — neither
16
+ value exists as an option, so the browser fell back either way.
17
+
18
+ Rendered only when placeholder text is supplied, so a select with a real
19
+ default (sex, status, a type) does not grow an empty row it never wanted.
20
+
21
+ ## 1.27.4
22
+
23
+ ### Fixed
24
+
25
+ - **The calendar allowed a different set of days depending on the visitor's
26
+ timezone.** Day cells are built with `createDate`, which is `Date.UTC(...)`;
27
+ the selectable bounds were built with `new Date(y, m, d)` — *local*
28
+ midnight. Those are not the same instant, so the boundary day fell on
29
+ either side of the limit depending on where the visitor was sitting.
30
+
31
+ The consequence on the money path: **same-day departures were not
32
+ selectable west of Greenwich.** A visitor in New York or Los Angeles could
33
+ not pick today, because local midnight there is *after* the cell's UTC
34
+ midnight, so today's cell tested as below the minimum. Same-day selling was
35
+ deliberately enabled — this had been quietly undoing it for those visitors,
36
+ and it is invisible from Europe. Both sides are UTC now, so the comparison
37
+ is exact and identical everywhere.
38
+
39
+ Found while chasing an apparent off-by-one in the birth-date picker, which
40
+ turned out to be this skew wearing a different hat.
41
+
3
42
  ## 1.27.3
4
43
 
5
44
  ### Fixed
@@ -119,9 +119,25 @@ export const getLimits = (type: ('picker' | 'dob' | 'date')): CalendarLimit => {
119
119
  max: limits.max.year
120
120
  },
121
121
 
122
+ /**
123
+ * Edited: Ferjolt Ozuni - Date: 2026-08-06
124
+ * BUILT IN UTC, because the day cells are.
125
+ *
126
+ * Days.tsx gets each cell's date from `createDate`, which is
127
+ * `Date.UTC(...)` - UTC midnight. These bounds were local midnight, and
128
+ * the two are not the same instant. East of Greenwich local midnight is
129
+ * EARLIER, so the boundary day sat just past the maximum and was greyed
130
+ * out; west of it the boundary day was included instead. The same
131
+ * calendar therefore allowed a different set of days depending on where
132
+ * the visitor was sitting, which is exactly the class of bug the
133
+ * departure floor above was already fixed for once.
134
+ *
135
+ * Same basis on both sides makes the comparison exact and the same
136
+ * everywhere.
137
+ */
122
138
  time: {
123
- min: new Date(today.getFullYear() - limits.min.year, limits.min.month, limits.min.day, 0, 0, 0, 0).getTime(),
124
- max: new Date(today.getFullYear() + limits.max.year, limits.max.month, limits.max.day, 0, 0, 0, 0).getTime()
139
+ min: Date.UTC(today.getFullYear() - limits.min.year, limits.min.month, limits.min.day),
140
+ max: Date.UTC(today.getFullYear() + limits.max.year, limits.max.month, limits.max.day)
125
141
  }
126
142
  };
127
143
  };
@@ -30,9 +30,27 @@ const Dropdown = ({ item, refs, t }: Props): (JSX.Element | null) => {
30
30
  { item.name }
31
31
  </option>
32
32
  ));
33
-
33
+
34
+ /**
35
+ * Edited: Ferjolt Ozuni - Date: 2026-08-06
36
+ *
37
+ * A select whose value matches NO option silently shows the first one, and
38
+ * the browser then submits it as though it had been chosen. That is how
39
+ * every profile whose owner did not touch the country field was saved as
40
+ * Afghanistan - it sorts first, and nothing had ever been selected.
41
+ *
42
+ * An empty leading option gives "nothing chosen" somewhere to live, so the
43
+ * field reads as unanswered and a `required` rule can say so. Rendered
44
+ * only when the caller supplies placeholder text: a select with a real
45
+ * default (sex, status, a type) should not grow an empty row it does not
46
+ * want.
47
+ */
34
48
  return (
35
- <select defaultValue={ item?.value } { ...refs(item.name, rules) }>
49
+ <select defaultValue={ item?.value ?? '' } { ...refs(item.name, rules) }>
50
+ { item.placeholder !== undefined && (
51
+ <option value="">{ item.placeholder }</option>
52
+ ) }
53
+
36
54
  { values }
37
55
  </select>
38
56
  );
package/Viewer/types.ts CHANGED
@@ -5,6 +5,14 @@ export interface ViewData {
5
5
  name?: string
6
6
  type?: 'text' | 'select' | 'date' | 'dob' | 'picker' | 'textarea' | 'textarea-html' | 'file' | 'files' | 'email' | 'password' | 'display' | 'component' | 'checkbox' | 'checkbox-list' | 'checkbox-list-all' | 'link' | 'number' | 'float' | 'date-picker'
7
7
  value?: string | number | JSX.Element
8
+ /**
9
+ * Edited: Ferjolt Ozuni - Date: 2026-08-06
10
+ * Leading empty option for a select, for "nothing chosen". Without one a
11
+ * select whose value matches no option silently shows - and submits - the
12
+ * first, which is how profiles were being saved as Afghanistan.
13
+ */
14
+ placeholder?: string
15
+
8
16
  values?: DropdownData[]
9
17
  selected?: any[]
10
18
  rules?: string
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autobusal/common",
3
- "version": "1.27.3",
3
+ "version": "1.27.5",
4
4
  "author": "Ferjolt Ozuni",
5
5
  "type": "module",
6
6
  "main": "index.ts"