@budibase/bbui 1.0.49-alpha.1 → 1.0.49-alpha.13

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.49-alpha.1",
4
+ "version": "1.0.49-alpha.13",
5
5
  "license": "MPL-2.0",
6
6
  "svelte": "src/index.js",
7
7
  "module": "dist/bbui.es.js",
@@ -82,5 +82,5 @@
82
82
  "svelte-flatpickr": "^3.2.3",
83
83
  "svelte-portal": "^1.0.0"
84
84
  },
85
- "gitHead": "3f8d81837dd8ba0ebf17dbd8106c3a5d3bec3e46"
85
+ "gitHead": "db3f93e8a964ef589addfc6106337a7bfd7214b0"
86
86
  }
@@ -13,6 +13,7 @@
13
13
  start: textarea.selectionStart,
14
14
  end: textarea.selectionEnd,
15
15
  })
16
+ export let align = null
16
17
 
17
18
  let focus = false
18
19
  let textarea
@@ -46,6 +47,7 @@
46
47
  bind:this={textarea}
47
48
  placeholder={placeholder || ""}
48
49
  class="spectrum-Textfield-input"
50
+ style={align ? `text-align: ${align}` : ""}
49
51
  {disabled}
50
52
  {id}
51
53
  on:focus={() => (focus = true)}
@@ -12,6 +12,7 @@
12
12
  export let updateOnChange = true
13
13
  export let quiet = false
14
14
  export let dataCy
15
+ export let align
15
16
 
16
17
  const dispatch = createEventDispatcher()
17
18
  let focus = false
@@ -92,8 +93,9 @@
92
93
  on:input={onInput}
93
94
  on:keyup={updateValueOnEnter}
94
95
  {type}
95
- inputmode={type === "number" ? "decimal" : "text"}
96
96
  class="spectrum-Textfield-input"
97
+ style={align ? `text-align: ${align};` : ""}
98
+ inputmode={type === "number" ? "decimal" : "text"}
97
99
  />
98
100
  </div>
99
101
 
@@ -8,10 +8,35 @@
8
8
  copyToClipboard(value)
9
9
  }
10
10
 
11
- function copyToClipboard(value) {
12
- navigator.clipboard.writeText(value).then(() => {
13
- notifications.success("Copied")
11
+ const copyToClipboard = value => {
12
+ return new Promise(res => {
13
+ if (navigator.clipboard && window.isSecureContext) {
14
+ // Try using the clipboard API first
15
+ navigator.clipboard.writeText(value).then(res)
16
+ } else {
17
+ // Fall back to the textarea hack
18
+ let textArea = document.createElement("textarea")
19
+ textArea.value = value
20
+ textArea.style.position = "fixed"
21
+ textArea.style.left = "-9999px"
22
+ textArea.style.top = "-9999px"
23
+ document.body.appendChild(textArea)
24
+ textArea.focus()
25
+ textArea.select()
26
+ document.execCommand("copy")
27
+ textArea.remove()
28
+ res()
29
+ }
14
30
  })
31
+ .then(() => {
32
+ notifications.success("Copied to clipboard")
33
+ })
34
+ .catch(() => {
35
+ notifications.error(
36
+ "Failed to copy to clipboard. Check the dev console for the value."
37
+ )
38
+ console.warn("Failed to copy the value", value)
39
+ })
15
40
  }
16
41
  </script>
17
42