@budibase/bbui 1.0.105-alpha.5 → 1.0.107

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