@budibase/bbui 1.0.105-alpha.2 → 1.0.105-alpha.3

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.105-alpha.2",
4
+ "version": "1.0.105-alpha.3",
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.105-alpha.2",
41
+ "@budibase/string-templates": "^1.0.105-alpha.3",
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": "0a72aa6adb6362bcd2005cc4e985b589f4f59c37"
87
+ "gitHead": "edb7d21a500681d3c9f069e52d3b82b5391b3ef8"
88
88
  }
@@ -19,18 +19,33 @@
19
19
  const dispatch = createEventDispatcher()
20
20
  const flatpickrId = `${uuid()}-wrapper`
21
21
  let open = false
22
- let flatpickr, flatpickrOptions, isTimeOnly
22
+ let flatpickr, flatpickrOptions
23
+
24
+ const resolveTimeStamp = timestamp => {
25
+ let maskedDate = new Date(`0-${timestamp}`)
26
+
27
+ if (maskedDate instanceof Date && !isNaN(maskedDate.getTime())) {
28
+ return maskedDate
29
+ } else {
30
+ return null
31
+ }
32
+ }
23
33
 
24
- $: isTimeOnly = !timeOnly && value ? !isNaN(new Date(`0-${value}`)) : timeOnly
25
34
  $: flatpickrOptions = {
26
35
  element: `#${flatpickrId}`,
27
- enableTime: isTimeOnly || enableTime || false,
28
- noCalendar: isTimeOnly || false,
36
+ enableTime: timeOnly || enableTime || false,
37
+ noCalendar: timeOnly || false,
29
38
  altInput: true,
30
- altFormat: isTimeOnly ? "H:i" : enableTime ? "F j Y, H:i" : "F j, Y",
39
+ altFormat: timeOnly ? "H:i" : enableTime ? "F j Y, H:i" : "F j, Y",
31
40
  wrap: true,
32
41
  appendTo,
33
42
  disableMobile: "true",
43
+ onReady: () => {
44
+ let timestamp = resolveTimeStamp(value)
45
+ if (timeOnly && timestamp) {
46
+ dispatch("change", timestamp.toISOString())
47
+ }
48
+ },
34
49
  }
35
50
 
36
51
  const handleChange = event => {
@@ -39,10 +54,9 @@
39
54
  if (newValue) {
40
55
  newValue = newValue.toISOString()
41
56
  }
42
- // if time only set date component to today
57
+ // if time only set date component to 2000-01-01
43
58
  if (timeOnly) {
44
- const todayDate = new Date().toISOString().split("T")[0]
45
- newValue = `${todayDate}T${newValue.split("T")[1]}`
59
+ newValue = `2000-01-01T${newValue.split("T")[1]}`
46
60
  }
47
61
  dispatch("change", newValue)
48
62
  }
@@ -76,10 +90,13 @@
76
90
  return null
77
91
  }
78
92
  let date
79
- let time = new Date(`0-${val}`)
93
+ let time
94
+
80
95
  // it is a string like 00:00:00, just time
81
- if (timeOnly || (typeof val === "string" && !isNaN(time))) {
82
- date = time
96
+ let ts = resolveTimeStamp(val)
97
+
98
+ if (timeOnly && ts) {
99
+ date = ts
83
100
  } else if (val instanceof Date) {
84
101
  // Use real date obj if already parsed
85
102
  date = val
@@ -101,7 +118,7 @@
101
118
  }
102
119
  </script>
103
120
 
104
- {#key isTimeOnly}
121
+ {#key timeOnly}
105
122
  <Flatpickr
106
123
  bind:flatpickr
107
124
  value={parseDate(value)}