@budibase/bbui 1.0.193 → 1.0.196

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/bbui",
3
3
  "description": "A UI solution used in the different Budibase projects.",
4
- "version": "1.0.193",
4
+ "version": "1.0.196",
5
5
  "license": "MPL-2.0",
6
6
  "svelte": "src/index.js",
7
7
  "module": "dist/bbui.es.js",
@@ -38,7 +38,7 @@
38
38
  ],
39
39
  "dependencies": {
40
40
  "@adobe/spectrum-css-workflow-icons": "^1.2.1",
41
- "@budibase/string-templates": "^1.0.193",
41
+ "@budibase/string-templates": "^1.0.196",
42
42
  "@spectrum-css/actionbutton": "^1.0.1",
43
43
  "@spectrum-css/actiongroup": "^1.0.1",
44
44
  "@spectrum-css/avatar": "^3.0.2",
@@ -84,5 +84,5 @@
84
84
  "svelte-flatpickr": "^3.2.3",
85
85
  "svelte-portal": "^1.0.0"
86
86
  },
87
- "gitHead": "e578ffe12ea6cda078836628b6e69f41a7048301"
87
+ "gitHead": "a7f4959e853eba49c4de3d7d355a98900eaa0591"
88
88
  }
@@ -15,6 +15,7 @@
15
15
  export let placeholder = null
16
16
  export let appendTo = undefined
17
17
  export let timeOnly = false
18
+ export let ignoreTimezones = false
18
19
 
19
20
  const dispatch = createEventDispatcher()
20
21
  const flatpickrId = `${uuid()}-wrapper`
@@ -50,19 +51,35 @@
50
51
 
51
52
  const handleChange = event => {
52
53
  const [dates] = event.detail
54
+ const noTimezone = enableTime && !timeOnly && ignoreTimezones
53
55
  let newValue = dates[0]
54
56
  if (newValue) {
55
57
  newValue = newValue.toISOString()
56
58
  }
57
- // if time only set date component to 2000-01-01
59
+
60
+ // If time only set date component to 2000-01-01
58
61
  if (timeOnly) {
59
62
  newValue = `2000-01-01T${newValue.split("T")[1]}`
60
63
  }
61
- // date only, offset for timezone so always right date
64
+
65
+ // For date-only fields, construct a manual timestamp string without a time
66
+ // or time zone
62
67
  else if (!enableTime) {
68
+ const year = dates[0].getFullYear()
69
+ const month = `${dates[0].getMonth() + 1}`.padStart(2, "0")
70
+ const day = `${dates[0].getDate()}`.padStart(2, "0")
71
+ newValue = `${year}-${month}-${day}T00:00:00.000`
72
+ }
73
+
74
+ // For non-timezone-aware fields, create an ISO 8601 timestamp of the exact
75
+ // time picked, without timezone
76
+ else if (noTimezone) {
63
77
  const offset = dates[0].getTimezoneOffset() * 60000
64
- newValue = new Date(dates[0].getTime() - offset).toISOString()
78
+ newValue = new Date(dates[0].getTime() - offset)
79
+ .toISOString()
80
+ .slice(0, -1)
65
81
  }
82
+
66
83
  dispatch("change", newValue)
67
84
  }
68
85
 
@@ -112,10 +129,12 @@
112
129
  // Treat as numerical timestamp
113
130
  date = new Date(parseInt(val))
114
131
  }
132
+
115
133
  time = date.getTime()
116
134
  if (isNaN(time)) {
117
135
  return null
118
136
  }
137
+
119
138
  // By rounding to the nearest second we avoid locking up in an endless
120
139
  // loop in the builder, caused by potentially enriching {{ now }} to every
121
140
  // millisecond.
@@ -12,6 +12,7 @@
12
12
  export let timeOnly = false
13
13
  export let placeholder = null
14
14
  export let appendTo = undefined
15
+ export let ignoreTimezones = false
15
16
 
16
17
  const dispatch = createEventDispatcher()
17
18
 
@@ -30,6 +31,7 @@
30
31
  {enableTime}
31
32
  {timeOnly}
32
33
  {appendTo}
34
+ {ignoreTimezones}
33
35
  on:change={onChange}
34
36
  />
35
37
  </Field>
@@ -39,7 +39,6 @@
39
39
  position: relative;
40
40
  display: flex;
41
41
  justify-content: center;
42
- margin-top: 1px;
43
42
  margin-left: 5px;
44
43
  margin-right: 5px;
45
44
  }