@budibase/frontend-core 2.6.16-alpha.3 → 2.6.16-alpha.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/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@budibase/frontend-core",
3
- "version": "2.6.16-alpha.3",
3
+ "version": "2.6.16-alpha.5",
4
4
  "description": "Budibase frontend core libraries used in builder and client",
5
5
  "author": "Budibase",
6
6
  "license": "MPL-2.0",
7
7
  "svelte": "src/index.js",
8
8
  "dependencies": {
9
- "@budibase/bbui": "2.6.16-alpha.3",
10
- "@budibase/shared-core": "2.6.16-alpha.3",
9
+ "@budibase/bbui": "2.6.16-alpha.5",
10
+ "@budibase/shared-core": "2.6.16-alpha.5",
11
11
  "dayjs": "^1.11.7",
12
12
  "lodash": "^4.17.21",
13
13
  "socket.io-client": "^4.6.1",
14
14
  "svelte": "^3.46.2"
15
15
  },
16
- "gitHead": "13516a61c7bd197183382add792b04233af97bcf"
16
+ "gitHead": "bbb516f26ae966668b5fa65418d81fbccf3dce37"
17
17
  }
@@ -13,10 +13,10 @@
13
13
  let flatpickr
14
14
  let isOpen
15
15
 
16
- // adding the 0- will turn a string like 00:00:00 into a valid ISO
16
+ // Adding the 0- will turn a string like 00:00:00 into a valid ISO
17
17
  // date, but will make actual ISO dates invalid
18
- $: time = new Date(`0-${value}`)
19
- $: timeOnly = !isNaN(time) || schema?.timeOnly
18
+ $: isTimeValue = !isNaN(new Date(`0-${value}`))
19
+ $: timeOnly = isTimeValue || schema?.timeOnly
20
20
  $: dateOnly = schema?.dateOnly
21
21
  $: format = timeOnly
22
22
  ? "HH:mm:ss"
@@ -24,6 +24,19 @@
24
24
  ? "MMM D YYYY"
25
25
  : "MMM D YYYY, HH:mm"
26
26
  $: editable = focused && !readonly
27
+ $: displayValue = getDisplayValue(value, format, timeOnly, isTimeValue)
28
+
29
+ const getDisplayValue = (value, format, timeOnly, isTimeValue) => {
30
+ if (!value) {
31
+ return ""
32
+ }
33
+ // Parse full date strings
34
+ if (!timeOnly || !isTimeValue) {
35
+ return dayjs(value).format(format)
36
+ }
37
+ // Otherwise must be a time string
38
+ return dayjs(`0-${value}`).format(format)
39
+ }
27
40
 
28
41
  // Ensure we close flatpickr when unselected
29
42
  $: {
@@ -49,7 +62,7 @@
49
62
  <div class="container">
50
63
  <div class="value">
51
64
  {#if value}
52
- {dayjs(timeOnly ? time : value).format(format)}
65
+ {displayValue}
53
66
  {/if}
54
67
  </div>
55
68
  {#if editable}