@budibase/bbui 1.0.50-alpha.5 → 1.0.50-alpha.6

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.50-alpha.5",
4
+ "version": "1.0.50-alpha.6",
5
5
  "license": "MPL-2.0",
6
6
  "svelte": "src/index.js",
7
7
  "module": "dist/bbui.es.js",
@@ -83,5 +83,5 @@
83
83
  "svelte-flatpickr": "^3.2.3",
84
84
  "svelte-portal": "^1.0.0"
85
85
  },
86
- "gitHead": "091100f9351739438a01e32ab71e6bbc6fc9ebb4"
86
+ "gitHead": "a557d325a5be87361fda1b74da6f9a2e8854c61a"
87
87
  }
@@ -5,7 +5,7 @@
5
5
  import { fly } from "svelte/transition"
6
6
  import Icon from "../Icon/Icon.svelte"
7
7
  import Input from "../Form/Input.svelte"
8
- import { capitalise } from "../utils/helpers"
8
+ import { capitalise } from "../helpers"
9
9
 
10
10
  export let value
11
11
  export let size = "M"
@@ -5,7 +5,7 @@
5
5
  import "@spectrum-css/textfield/dist/index-vars.css"
6
6
  import "@spectrum-css/picker/dist/index-vars.css"
7
7
  import { createEventDispatcher } from "svelte"
8
- import { generateID } from "../../utils/helpers"
8
+ import { uuid } from "../../helpers"
9
9
 
10
10
  export let id = null
11
11
  export let disabled = false
@@ -17,7 +17,7 @@
17
17
  export let timeOnly = false
18
18
 
19
19
  const dispatch = createEventDispatcher()
20
- const flatpickrId = `${generateID()}-wrapper`
20
+ const flatpickrId = `${uuid()}-wrapper`
21
21
  let open = false
22
22
  let flatpickr, flatpickrOptions, isTimeOnly
23
23
 
@@ -3,7 +3,7 @@
3
3
  import "@spectrum-css/typography/dist/index-vars.css"
4
4
  import "@spectrum-css/illustratedmessage/dist/index-vars.css"
5
5
  import { createEventDispatcher } from "svelte"
6
- import { generateID } from "../../utils/helpers"
6
+ import { uuid } from "../../helpers"
7
7
  import Icon from "../../Icon/Icon.svelte"
8
8
  import Link from "../../Link/Link.svelte"
9
9
  import Tag from "../../Tags/Tag.svelte"
@@ -37,7 +37,7 @@
37
37
  "jfif",
38
38
  ]
39
39
 
40
- const fieldId = id || generateID()
40
+ const fieldId = id || uuid()
41
41
  let selectedImageIdx = 0
42
42
  let fileDragged = false
43
43
  let selectedUrl
@@ -4,7 +4,7 @@
4
4
  import CellRenderer from "./CellRenderer.svelte"
5
5
  import SelectEditRenderer from "./SelectEditRenderer.svelte"
6
6
  import { cloneDeep } from "lodash"
7
- import { deepGet } from "../utils/helpers"
7
+ import { deepGet } from "../helpers"
8
8
 
9
9
  /**
10
10
  * The expected schema is our normal couch schemas for our tables.
@@ -1,11 +1,45 @@
1
- export const generateID = () => {
2
- const rand = Math.random().toString(32).substring(2)
1
+ /**
2
+ * Generates a DOM safe UUID.
3
+ * Starting with a letter is important to make it DOM safe.
4
+ * @return {string} a random DOM safe UUID
5
+ */
6
+ export function uuid() {
7
+ return "cxxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g, c => {
8
+ const r = (Math.random() * 16) | 0
9
+ const v = c === "x" ? r : (r & 0x3) | 0x8
10
+ return v.toString(16)
11
+ })
12
+ }
3
13
 
4
- // Starts with a letter so that its a valid DOM ID
5
- return `A${rand}`
14
+ /**
15
+ * Capitalises a string
16
+ * @param string the string to capitalise
17
+ * @return {string} the capitalised string
18
+ */
19
+ export const capitalise = string => {
20
+ if (!string) {
21
+ return string
22
+ }
23
+ return string.substring(0, 1).toUpperCase() + string.substring(1)
6
24
  }
7
25
 
8
- export const capitalise = s => s.substring(0, 1).toUpperCase() + s.substring(1)
26
+ /**
27
+ * Computes a short hash of a string
28
+ * @param string the string to compute a hash of
29
+ * @return {string} the hash string
30
+ */
31
+ export const hashString = string => {
32
+ if (!string) {
33
+ return "0"
34
+ }
35
+ let hash = 0
36
+ for (let i = 0; i < string.length; i++) {
37
+ let char = string.charCodeAt(i)
38
+ hash = (hash << 5) - hash + char
39
+ hash = hash & hash // Convert to 32bit integer
40
+ }
41
+ return hash.toString()
42
+ }
9
43
 
10
44
  /**
11
45
  * Gets a key within an object. The key supports dot syntax for retrieving deep
package/src/index.js CHANGED
@@ -85,5 +85,5 @@ export { default as clickOutside } from "./Actions/click_outside"
85
85
  // Stores
86
86
  export { notifications, createNotificationStore } from "./Stores/notifications"
87
87
 
88
- // Utils
89
- export * from "./utils/helpers"
88
+ // Helpers
89
+ export * as Helpers from "./helpers"