@budibase/bbui 2.0.39 → 2.0.40

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": "2.0.39",
4
+ "version": "2.0.40",
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": "^2.0.39",
41
+ "@budibase/string-templates": "^2.0.40",
42
42
  "@spectrum-css/actionbutton": "^1.0.1",
43
43
  "@spectrum-css/actiongroup": "^1.0.1",
44
44
  "@spectrum-css/avatar": "^3.0.2",
@@ -85,5 +85,5 @@
85
85
  "svelte-flatpickr": "^3.2.3",
86
86
  "svelte-portal": "^1.0.0"
87
87
  },
88
- "gitHead": "dce0d52b0ad22c3214c348154a7090f872a82ecf"
88
+ "gitHead": "581ffaea14dfa2b88b55381e56ee1b6eb283a489"
89
89
  }
@@ -1,18 +1,18 @@
1
1
  export default function clickOutside(element, callbackFunction) {
2
2
  function onClick(event) {
3
3
  if (!element.contains(event.target)) {
4
- callbackFunction()
4
+ callbackFunction(event)
5
5
  }
6
6
  }
7
7
 
8
- document.body.addEventListener("mousedown", onClick, true)
8
+ document.body.addEventListener("click", onClick, true)
9
9
 
10
10
  return {
11
11
  update(newCallbackFunction) {
12
12
  callbackFunction = newCallbackFunction
13
13
  },
14
14
  destroy() {
15
- document.body.removeEventListener("mousedown", onClick, true)
15
+ document.body.removeEventListener("click", onClick, true)
16
16
  },
17
17
  }
18
18
  }
@@ -119,6 +119,13 @@
119
119
 
120
120
  return "var(--spectrum-global-color-static-gray-900)"
121
121
  }
122
+
123
+ const handleOutsideClick = event => {
124
+ if (open) {
125
+ event.stopPropagation()
126
+ open = false
127
+ }
128
+ }
122
129
  </script>
123
130
 
124
131
  <div class="container">
@@ -131,7 +138,7 @@
131
138
  </div>
132
139
  {#if open}
133
140
  <div
134
- use:clickOutside={() => (open = false)}
141
+ use:clickOutside={handleOutsideClick}
135
142
  transition:fly|local={{ y: -20, duration: 200 }}
136
143
  class="spectrum-Popover spectrum-Popover--bottom spectrum-Picker-popover is-open"
137
144
  class:spectrum-Popover--align-right={alignRight}
@@ -17,7 +17,7 @@
17
17
  export let timeOnly = false
18
18
  export let ignoreTimezones = false
19
19
  export let time24hr = false
20
-
20
+ export let range = false
21
21
  const dispatch = createEventDispatcher()
22
22
  const flatpickrId = `${uuid()}-wrapper`
23
23
  let open = false
@@ -41,6 +41,7 @@
41
41
  time_24hr: time24hr || false,
42
42
  altFormat: timeOnly ? "H:i" : enableTime ? "F j Y, H:i" : "F j, Y",
43
43
  wrap: true,
44
+ mode: range ? "range" : null,
44
45
  appendTo,
45
46
  disableMobile: "true",
46
47
  onReady: () => {
@@ -64,7 +65,6 @@
64
65
  if (newValue) {
65
66
  newValue = newValue.toISOString()
66
67
  }
67
-
68
68
  // If time only set date component to 2000-01-01
69
69
  if (timeOnly) {
70
70
  // Classic flackpickr causing issues.
@@ -95,7 +95,11 @@
95
95
  .slice(0, -1)
96
96
  }
97
97
 
98
- dispatch("change", newValue)
98
+ if (range) {
99
+ dispatch("change", event.detail)
100
+ } else {
101
+ dispatch("change", newValue)
102
+ }
99
103
  }
100
104
 
101
105
  const clearDateOnBackspace = event => {
@@ -160,7 +164,7 @@
160
164
  {#key redrawOptions}
161
165
  <Flatpickr
162
166
  bind:flatpickr
163
- value={parseDate(value)}
167
+ value={range ? value : parseDate(value)}
164
168
  on:open={onOpen}
165
169
  on:close={onClose}
166
170
  options={flatpickrOptions}
@@ -102,6 +102,13 @@
102
102
  }
103
103
  return value
104
104
  }
105
+
106
+ const handleOutsideClick = event => {
107
+ if (open) {
108
+ event.stopPropagation()
109
+ open = false
110
+ }
111
+ }
105
112
  </script>
106
113
 
107
114
  <div
@@ -151,7 +158,7 @@
151
158
  {disabled}
152
159
  class:is-open={open}
153
160
  aria-haspopup="listbox"
154
- on:mousedown={onClick}
161
+ on:click={onClick}
155
162
  >
156
163
  <span class="spectrum-Picker-label">
157
164
  <div>
@@ -168,7 +175,7 @@
168
175
  </button>
169
176
  {#if open}
170
177
  <div
171
- use:clickOutside={() => (open = false)}
178
+ use:clickOutside={handleOutsideClick}
172
179
  transition:fly|local={{ y: -20, duration: 200 }}
173
180
  class="spectrum-Popover spectrum-Popover--bottom spectrum-Picker-popover is-open"
174
181
  >
@@ -19,6 +19,7 @@
19
19
  export let placeholderOption = null
20
20
  export let options = []
21
21
  export let isOptionSelected = () => false
22
+ export let isOptionEnabled = () => true
22
23
  export let onSelectOption = () => {}
23
24
  export let getOptionLabel = option => option
24
25
  export let getOptionValue = option => option
@@ -84,7 +85,7 @@
84
85
  class:is-invalid={!!error}
85
86
  class:is-open={open}
86
87
  aria-haspopup="listbox"
87
- on:mousedown={onClick}
88
+ on:click={onClick}
88
89
  >
89
90
  {#if fieldIcon}
90
91
  <span class="option-extra">
@@ -164,6 +165,7 @@
164
165
  aria-selected="true"
165
166
  tabindex="0"
166
167
  on:click={() => onSelectOption(getOptionValue(option, idx))}
168
+ class:is-disabled={!isOptionEnabled(option)}
167
169
  >
168
170
  {#if getOptionIcon(option, idx)}
169
171
  <span class="option-extra">
@@ -256,4 +258,7 @@
256
258
  .spectrum-Popover :global(.spectrum-Search .spectrum-Textfield-icon) {
257
259
  top: 9px;
258
260
  }
261
+ .spectrum-Menu-item.is-disabled {
262
+ pointer-events: none;
263
+ }
259
264
  </style>
@@ -87,6 +87,20 @@
87
87
  updateValue(event.target.value)
88
88
  }
89
89
  }
90
+
91
+ const handlePrimaryOutsideClick = event => {
92
+ if (primaryOpen) {
93
+ event.stopPropagation()
94
+ primaryOpen = false
95
+ }
96
+ }
97
+
98
+ const handleSecondaryOutsideClick = event => {
99
+ if (secondaryOpen) {
100
+ event.stopPropagation()
101
+ secondaryOpen = false
102
+ }
103
+ }
90
104
  </script>
91
105
 
92
106
  <div
@@ -148,7 +162,7 @@
148
162
  </div>
149
163
  {#if primaryOpen}
150
164
  <div
151
- use:clickOutside={() => (primaryOpen = false)}
165
+ use:clickOutside={handlePrimaryOutsideClick}
152
166
  transition:fly|local={{ y: -20, duration: 200 }}
153
167
  class="spectrum-Popover spectrum-Popover--bottom spectrum-Picker-popover is-open"
154
168
  class:auto-width={autoWidth}
@@ -256,7 +270,7 @@
256
270
  {disabled}
257
271
  class:is-open={secondaryOpen}
258
272
  aria-haspopup="listbox"
259
- on:mousedown={onClickSecondary}
273
+ on:click={onClickSecondary}
260
274
  >
261
275
  {#if secondaryFieldIcon}
262
276
  <span class="option-left">
@@ -281,7 +295,7 @@
281
295
  </button>
282
296
  {#if secondaryOpen}
283
297
  <div
284
- use:clickOutside={() => (secondaryOpen = false)}
298
+ use:clickOutside={handleSecondaryOutsideClick}
285
299
  transition:fly|local={{ y: -20, duration: 200 }}
286
300
  class="spectrum-Popover spectrum-Popover--bottom spectrum-Picker-popover is-open"
287
301
  style="width: 30%"
@@ -12,6 +12,7 @@
12
12
  export let getOptionValue = option => option
13
13
  export let getOptionIcon = () => null
14
14
  export let getOptionColour = () => null
15
+ export let isOptionEnabled
15
16
  export let readonly = false
16
17
  export let quiet = false
17
18
  export let autoWidth = false
@@ -66,6 +67,7 @@
66
67
  {getOptionValue}
67
68
  {getOptionIcon}
68
69
  {getOptionColour}
70
+ {isOptionEnabled}
69
71
  {autocomplete}
70
72
  {sort}
71
73
  isPlaceholder={value == null || value === ""}
@@ -14,11 +14,17 @@
14
14
  export let placeholder = null
15
15
  export let appendTo = undefined
16
16
  export let ignoreTimezones = false
17
-
17
+ export let range = false
18
18
  const dispatch = createEventDispatcher()
19
19
 
20
20
  const onChange = e => {
21
- value = e.detail
21
+ if (range) {
22
+ // Flatpickr cant take two dates and work out what to display, needs to be provided a string.
23
+ // Like - "Date1 to Date2". Hence passing in that specifically from the array
24
+ value = e?.detail[1]
25
+ } else {
26
+ value = e.detail
27
+ }
22
28
  dispatch("change", e.detail)
23
29
  }
24
30
  </script>
@@ -34,6 +40,7 @@
34
40
  {time24hr}
35
41
  {appendTo}
36
42
  {ignoreTimezones}
43
+ {range}
37
44
  on:change={onChange}
38
45
  />
39
46
  </Field>
@@ -15,6 +15,7 @@
15
15
  export let getOptionValue = option => extractProperty(option, "value")
16
16
  export let getOptionIcon = option => option?.icon
17
17
  export let getOptionColour = option => option?.colour
18
+ export let isOptionEnabled
18
19
  export let quiet = false
19
20
  export let autoWidth = false
20
21
  export let sort = false
@@ -49,6 +50,7 @@
49
50
  {getOptionValue}
50
51
  {getOptionIcon}
51
52
  {getOptionColour}
53
+ {isOptionEnabled}
52
54
  on:change={onChange}
53
55
  on:click
54
56
  />
@@ -50,6 +50,13 @@
50
50
  dispatch("change", value)
51
51
  open = false
52
52
  }
53
+
54
+ const handleOutsideClick = event => {
55
+ if (open) {
56
+ event.stopPropagation()
57
+ open = false
58
+ }
59
+ }
53
60
  </script>
54
61
 
55
62
  <div class="container">
@@ -64,7 +71,7 @@
64
71
  </div>
65
72
  {#if open}
66
73
  <div
67
- use:clickOutside={() => (open = false)}
74
+ use:clickOutside={handleOutsideClick}
68
75
  transition:fly={{ y: -20, duration: 200 }}
69
76
  class="spectrum-Popover spectrum-Popover--bottom spectrum-Picker-popover is-open"
70
77
  class:spectrum-Popover--align-right={alignRight}
@@ -33,6 +33,13 @@
33
33
  open = false
34
34
  }
35
35
 
36
+ const handleOutsideClick = e => {
37
+ if (open) {
38
+ e.stopPropagation()
39
+ hide()
40
+ }
41
+ }
42
+
36
43
  let open = null
37
44
 
38
45
  function handleEscape(e) {
@@ -47,7 +54,7 @@
47
54
  <div
48
55
  tabindex="0"
49
56
  use:positionDropdown={{ anchor, align, maxWidth }}
50
- use:clickOutside={hide}
57
+ use:clickOutside={handleOutsideClick}
51
58
  on:keydown={handleEscape}
52
59
  class={"spectrum-Popover is-open " + (tooltipClasses || "")}
53
60
  role="presentation"
@@ -56,6 +56,7 @@
56
56
  {schema}
57
57
  value={cellValue}
58
58
  on:clickrelationship
59
+ on:buttonclick
59
60
  >
60
61
  <slot />
61
62
  </svelte:component>
@@ -387,6 +387,7 @@
387
387
  schema={schema[field]}
388
388
  value={deepGet(row, field)}
389
389
  on:clickrelationship
390
+ on:buttonclick
390
391
  >
391
392
  <slot />
392
393
  </CellRenderer>