diff --git a/packages/client/src/render/getAppId.js b/packages/client/src/render/getAppId.js
deleted file mode 100644
index c827db8603..0000000000
--- a/packages/client/src/render/getAppId.js
+++ /dev/null
@@ -1,46 +0,0 @@
-const COOKIE_SEPARATOR = ";"
-const APP_PREFIX = "app_"
-const KEY_VALUE_SPLIT = "="
-
-function confirmAppId(possibleAppId) {
- return possibleAppId && possibleAppId.startsWith(APP_PREFIX)
- ? possibleAppId
- : undefined
-}
-
-function tryGetFromCookie({ cookies }) {
- const cookie = cookies
- .split(COOKIE_SEPARATOR)
- .find(cookie => cookie.trim().startsWith("budibase:currentapp"))
- let appId
- if (cookie && cookie.split(KEY_VALUE_SPLIT).length === 2) {
- appId = cookie.split("=")[1]
- }
- return confirmAppId(appId)
-}
-
-function tryGetFromPath() {
- const appId = location.pathname.split("/")[1]
- return confirmAppId(appId)
-}
-
-function tryGetFromSubdomain() {
- const parts = window.location.host.split(".")
- const appId = parts[1] ? parts[0] : undefined
- return confirmAppId(appId)
-}
-
-export const getAppId = cookies => {
- const functions = [tryGetFromSubdomain, tryGetFromPath, tryGetFromCookie]
- // try getting the app Id in order
- let appId
- for (let func of functions) {
- appId = func({ cookies })
- if (appId) {
- break
- }
- }
- return appId
-}
-
-export const getAppIdFromPath = getAppId
diff --git a/packages/standard-components/src/Heading.svelte b/packages/standard-components/src/Heading.svelte
index 5c912a2edd..4242c467eb 100644
--- a/packages/standard-components/src/Heading.svelte
+++ b/packages/standard-components/src/Heading.svelte
@@ -1,5 +1,4 @@
diff --git a/packages/standard-components/src/buildStyle.js b/packages/standard-components/src/buildStyle.js
deleted file mode 100644
index 53c77e062e..0000000000
--- a/packages/standard-components/src/buildStyle.js
+++ /dev/null
@@ -1,9 +0,0 @@
-export const buildStyle = styles => {
- let str = ""
- for (let s in styles) {
- if (styles[s]) {
- str += `${s}: ${styles[s]}; `
- }
- }
- return str
-}
diff --git a/packages/standard-components/src/Chart/ApexChart.svelte b/packages/standard-components/src/charts/ApexChart.svelte
similarity index 100%
rename from packages/standard-components/src/Chart/ApexChart.svelte
rename to packages/standard-components/src/charts/ApexChart.svelte
diff --git a/packages/standard-components/src/Chart/ApexOptionsBuilder.js b/packages/standard-components/src/charts/ApexOptionsBuilder.js
similarity index 100%
rename from packages/standard-components/src/Chart/ApexOptionsBuilder.js
rename to packages/standard-components/src/charts/ApexOptionsBuilder.js
diff --git a/packages/standard-components/src/Chart/AreaChart.svelte b/packages/standard-components/src/charts/AreaChart.svelte
similarity index 100%
rename from packages/standard-components/src/Chart/AreaChart.svelte
rename to packages/standard-components/src/charts/AreaChart.svelte
diff --git a/packages/standard-components/src/Chart/BarChart.svelte b/packages/standard-components/src/charts/BarChart.svelte
similarity index 100%
rename from packages/standard-components/src/Chart/BarChart.svelte
rename to packages/standard-components/src/charts/BarChart.svelte
diff --git a/packages/standard-components/src/Chart/CandleStickChart.svelte b/packages/standard-components/src/charts/CandleStickChart.svelte
similarity index 100%
rename from packages/standard-components/src/Chart/CandleStickChart.svelte
rename to packages/standard-components/src/charts/CandleStickChart.svelte
diff --git a/packages/standard-components/src/Chart/DonutChart.svelte b/packages/standard-components/src/charts/DonutChart.svelte
similarity index 100%
rename from packages/standard-components/src/Chart/DonutChart.svelte
rename to packages/standard-components/src/charts/DonutChart.svelte
diff --git a/packages/standard-components/src/Chart/LineChart.svelte b/packages/standard-components/src/charts/LineChart.svelte
similarity index 100%
rename from packages/standard-components/src/Chart/LineChart.svelte
rename to packages/standard-components/src/charts/LineChart.svelte
diff --git a/packages/standard-components/src/Chart/PieChart.svelte b/packages/standard-components/src/charts/PieChart.svelte
similarity index 100%
rename from packages/standard-components/src/Chart/PieChart.svelte
rename to packages/standard-components/src/charts/PieChart.svelte
diff --git a/packages/standard-components/src/Chart/index.js b/packages/standard-components/src/charts/index.js
similarity index 100%
rename from packages/standard-components/src/Chart/index.js
rename to packages/standard-components/src/charts/index.js
diff --git a/packages/standard-components/src/cssVars.js b/packages/standard-components/src/cssVars.js
deleted file mode 100644
index 7d1371436e..0000000000
--- a/packages/standard-components/src/cssVars.js
+++ /dev/null
@@ -1,31 +0,0 @@
-// https://github.com/kaisermann/svelte-css-vars
-
-export const cssVars = (node, props) => {
- Object.entries(props).forEach(([key, value]) => {
- node.style.setProperty(`--${key}`, value)
- })
-
- return {
- update(new_props) {
- Object.entries(new_props).forEach(([key, value]) => {
- node.style.setProperty(`--${key}`, value)
- delete props[key]
- })
-
- Object.keys(props).forEach(name => node.style.removeProperty(`--${name}`))
- props = new_props
- },
- }
-}
-
-export const createClasses = classes => {
- let all = ""
- for (let cls in classes) {
- if (classes[cls]) {
- all = all + " " + cls
- }
- }
- return all
-}
-
-export default cssVars
diff --git a/packages/standard-components/src/emptyProps.js b/packages/standard-components/src/emptyProps.js
deleted file mode 100644
index 6938c06462..0000000000
--- a/packages/standard-components/src/emptyProps.js
+++ /dev/null
@@ -1 +0,0 @@
-export const emptyProps = () => ({ _component: "" })
diff --git a/packages/standard-components/src/fetchData.js b/packages/standard-components/src/fetchData.js
deleted file mode 100644
index ef1950c5f7..0000000000
--- a/packages/standard-components/src/fetchData.js
+++ /dev/null
@@ -1,87 +0,0 @@
-import api from "./api"
-
-export default async function fetchData(datasource, store) {
- const { type, name } = datasource
-
- if (name) {
- let rows = []
- if (type === "table") {
- rows = await fetchTableData()
- } else if (type === "view") {
- rows = await fetchViewData()
- } else if (type === "link") {
- rows = await fetchLinkedRowsData()
- }
-
- // Fetch table schema so we can check for linked rows
- if (rows && rows.length && datasource.tableId) {
- const schema = await fetchSchema(datasource.tableId)
- const keys = Object.keys(schema)
- rows.forEach(row => {
- for (let key of keys) {
- const type = schema[key].type
- if (type === "link") {
- row[`${key}_count`] = Array.isArray(row[key]) ? row[key].length : 0
- } else if (type === "attachment") {
- let url = null
- if (Array.isArray(row[key]) && row[key][0] != null) {
- url = row[key][0].url
- }
- row[`${key}_first`] = url
- }
- }
- })
- }
-
- return rows
- } else {
- return []
- }
-
- async function fetchTableData() {
- if (!name.startsWith("all_")) {
- throw new Error("Incorrect table convention - must begin with all_")
- }
- const tablesResponse = await api.get(`/api/views/${name}`)
- return await tablesResponse.json()
- }
-
- async function fetchViewData() {
- const { field, groupBy, calculation } = datasource
- const params = new URLSearchParams()
-
- if (calculation) {
- params.set("field", field)
- params.set("calculation", calculation)
- }
-
- if (groupBy) {
- params.set("group", groupBy)
- }
-
- if (groupBy) params.set("group", groupBy)
-
- let QUERY_VIEW_URL = field
- ? `/api/views/${name}?${params}`
- : `/api/views/${name}`
-
- const response = await api.get(QUERY_VIEW_URL)
- return await response.json()
- }
-
- async function fetchLinkedRowsData() {
- if (!store || !store.data || !store.data._id) {
- return []
- }
- const QUERY_URL = `/api/${store.data.tableId}/${store.data._id}/enrich`
- const response = await api.get(QUERY_URL)
- const row = await response.json()
- return row[datasource.fieldName]
- }
-}
-
-export async function fetchSchema(id) {
- const FETCH_TABLE_URL = `/api/tables/${id}`
- const response = await api.get(FETCH_TABLE_URL)
- return (await response.json()).schema
-}
diff --git a/packages/standard-components/src/DataGrid/AttachmentCell/Button.svelte b/packages/standard-components/src/grid/AttachmentCell/Button.svelte
similarity index 100%
rename from packages/standard-components/src/DataGrid/AttachmentCell/Button.svelte
rename to packages/standard-components/src/grid/AttachmentCell/Button.svelte
diff --git a/packages/standard-components/src/DataGrid/AttachmentCell/Modal.svelte b/packages/standard-components/src/grid/AttachmentCell/Modal.svelte
similarity index 100%
rename from packages/standard-components/src/DataGrid/AttachmentCell/Modal.svelte
rename to packages/standard-components/src/grid/AttachmentCell/Modal.svelte
diff --git a/packages/standard-components/src/DataGrid/Component.svelte b/packages/standard-components/src/grid/Component.svelte
similarity index 100%
rename from packages/standard-components/src/DataGrid/Component.svelte
rename to packages/standard-components/src/grid/Component.svelte
diff --git a/packages/standard-components/src/DataGrid/CreateRow/Button.svelte b/packages/standard-components/src/grid/CreateRow/Button.svelte
similarity index 100%
rename from packages/standard-components/src/DataGrid/CreateRow/Button.svelte
rename to packages/standard-components/src/grid/CreateRow/Button.svelte
diff --git a/packages/standard-components/src/DataGrid/CreateRow/Modal.svelte b/packages/standard-components/src/grid/CreateRow/Modal.svelte
similarity index 100%
rename from packages/standard-components/src/DataGrid/CreateRow/Modal.svelte
rename to packages/standard-components/src/grid/CreateRow/Modal.svelte
diff --git a/packages/standard-components/src/DataGrid/DateTime/Wrapper.svelte b/packages/standard-components/src/grid/DateTime/Wrapper.svelte
similarity index 100%
rename from packages/standard-components/src/DataGrid/DateTime/Wrapper.svelte
rename to packages/standard-components/src/grid/DateTime/Wrapper.svelte
diff --git a/packages/standard-components/src/DataGrid/Relationship/RelationshipDisplay.svelte b/packages/standard-components/src/grid/Relationship/RelationshipDisplay.svelte
similarity index 100%
rename from packages/standard-components/src/DataGrid/Relationship/RelationshipDisplay.svelte
rename to packages/standard-components/src/grid/Relationship/RelationshipDisplay.svelte
diff --git a/packages/standard-components/src/DataGrid/Relationship/tableCache.js b/packages/standard-components/src/grid/Relationship/tableCache.js
similarity index 100%
rename from packages/standard-components/src/DataGrid/Relationship/tableCache.js
rename to packages/standard-components/src/grid/Relationship/tableCache.js
diff --git a/packages/standard-components/src/DataGrid/Select/Wrapper.svelte b/packages/standard-components/src/grid/Select/Wrapper.svelte
similarity index 100%
rename from packages/standard-components/src/DataGrid/Select/Wrapper.svelte
rename to packages/standard-components/src/grid/Select/Wrapper.svelte
diff --git a/packages/standard-components/src/DataGrid/ViewDetails/Cell.svelte b/packages/standard-components/src/grid/ViewDetails/Cell.svelte
similarity index 100%
rename from packages/standard-components/src/DataGrid/ViewDetails/Cell.svelte
rename to packages/standard-components/src/grid/ViewDetails/Cell.svelte
diff --git a/packages/standard-components/src/DataGrid/customRenderer.js b/packages/standard-components/src/grid/customRenderer.js
similarity index 100%
rename from packages/standard-components/src/DataGrid/customRenderer.js
rename to packages/standard-components/src/grid/customRenderer.js
diff --git a/packages/standard-components/src/DataGrid/valueSetters.js b/packages/standard-components/src/grid/valueSetters.js
similarity index 100%
rename from packages/standard-components/src/DataGrid/valueSetters.js
rename to packages/standard-components/src/grid/valueSetters.js
diff --git a/packages/standard-components/src/helpers.js b/packages/standard-components/src/helpers.js
index 2989f4d39c..fe160bb836 100644
--- a/packages/standard-components/src/helpers.js
+++ b/packages/standard-components/src/helpers.js
@@ -1 +1,49 @@
-export const capitalise = s => s.substring(0, 1).toUpperCase() + s.substring(1)
+/**
+ * Capitalises a string.
+ *
+ * @param string
+ * @returns {string}
+ */
+export const capitalise = string => {
+ return string.substring(0, 1).toUpperCase() + string.substring(1)
+}
+
+/**
+ * Builds a style string from a style object.
+ *
+ * @param styles
+ * @returns {string}
+ */
+export const buildStyle = styles => {
+ let str = ""
+ Object.entries(styles).forEach(([style, value]) => {
+ if (style && value) {
+ str += `${style}: ${value}; `
+ }
+ })
+ return str
+}
+
+/**
+ * Svelte action to set CSS variables on a DOM node.
+ *
+ * @param node
+ * @param props
+ */
+export const cssVars = (node, props) => {
+ Object.entries(props).forEach(([key, value]) => {
+ node.style.setProperty(`--${key}`, value)
+ })
+
+ return {
+ update(new_props) {
+ Object.entries(new_props).forEach(([key, value]) => {
+ node.style.setProperty(`--${key}`, value)
+ delete props[key]
+ })
+
+ Object.keys(props).forEach(name => node.style.removeProperty(`--${name}`))
+ props = new_props
+ },
+ }
+}
diff --git a/packages/standard-components/src/icons/ArrowDown.svelte b/packages/standard-components/src/icons/ArrowDown.svelte
deleted file mode 100644
index ef7e542ea1..0000000000
--- a/packages/standard-components/src/icons/ArrowDown.svelte
+++ /dev/null
@@ -1,10 +0,0 @@
-
diff --git a/packages/standard-components/src/icons/ArrowUp.svelte b/packages/standard-components/src/icons/ArrowUp.svelte
deleted file mode 100644
index 897c3612d2..0000000000
--- a/packages/standard-components/src/icons/ArrowUp.svelte
+++ /dev/null
@@ -1,10 +0,0 @@
-
diff --git a/packages/standard-components/src/index.js b/packages/standard-components/src/index.js
index 60473bec70..30748aa2bf 100644
--- a/packages/standard-components/src/index.js
+++ b/packages/standard-components/src/index.js
@@ -7,11 +7,10 @@ export { default as input } from "./Input.svelte"
export { default as textfield } from "./Textfield.svelte"
export { default as button } from "./Button.svelte"
export { default as login } from "./Login.svelte"
-export { default as saveRowButton } from "./Templates/saveRowButton"
export { default as link } from "./Link.svelte"
export { default as image } from "./Image.svelte"
export { default as Navigation } from "./Navigation.svelte"
-export { default as datagrid } from "./DataGrid/Component.svelte"
+export { default as datagrid } from "./grid/Component.svelte"
export { default as dataform } from "./DataForm.svelte"
export { default as dataformwide } from "./DataFormWide.svelte"
export { default as datalist } from "./DataList.svelte"
@@ -25,4 +24,4 @@ export { default as rowdetail } from "./RowDetail.svelte"
export { default as newrow } from "./NewRow.svelte"
export { default as datepicker } from "./DatePicker.svelte"
export { default as icon } from "./Icon.svelte"
-export * from "./Chart"
+export * from "./charts"
diff --git a/packages/standard-components/src/Test/TestApp.svelte b/packages/standard-components/src/tests/TestApp.svelte
similarity index 100%
rename from packages/standard-components/src/Test/TestApp.svelte
rename to packages/standard-components/src/tests/TestApp.svelte
diff --git a/packages/standard-components/src/Test/createApp.js b/packages/standard-components/src/tests/createApp.js
similarity index 100%
rename from packages/standard-components/src/Test/createApp.js
rename to packages/standard-components/src/tests/createApp.js
diff --git a/packages/standard-components/src/Test/props.js b/packages/standard-components/src/tests/props.js
similarity index 100%
rename from packages/standard-components/src/Test/props.js
rename to packages/standard-components/src/tests/props.js
diff --git a/packages/standard-components/src/Test/rootComponent.js b/packages/standard-components/src/tests/rootComponent.js
similarity index 100%
rename from packages/standard-components/src/Test/rootComponent.js
rename to packages/standard-components/src/tests/rootComponent.js
diff --git a/packages/standard-components/src/Test/testComponents.js b/packages/standard-components/src/tests/testComponents.js
similarity index 100%
rename from packages/standard-components/src/Test/testComponents.js
rename to packages/standard-components/src/tests/testComponents.js
diff --git a/packages/standard-components/src/Test/testMain.js b/packages/standard-components/src/tests/testMain.js
similarity index 100%
rename from packages/standard-components/src/Test/testMain.js
rename to packages/standard-components/src/tests/testMain.js