@autobusal/common 1.27.4 → 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,23 @@
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
+
3
21
  ## 1.27.4
4
22
 
5
23
  ### Fixed
@@ -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.4",
3
+ "version": "1.27.5",
4
4
  "author": "Ferjolt Ozuni",
5
5
  "type": "module",
6
6
  "main": "index.ts"