Merge standard-components into the client library

This commit is contained in:
Andrew Kingston 2021-09-01 11:41:48 +01:00
parent 0fbe0a9a73
commit 9e5805f092
114 changed files with 1454 additions and 920 deletions

View File

@ -11,7 +11,8 @@
"import": "./dist/budibase-client.js", "import": "./dist/budibase-client.js",
"require": "./dist/budibase-client.js" "require": "./dist/budibase-client.js"
}, },
"./package.json": "./package.json" "./package.json": "./package.json",
"./manifest.json": "./manifest.json"
}, },
"scripts": { "scripts": {
"build": "rollup -c", "build": "rollup -c",
@ -19,15 +20,25 @@
}, },
"dependencies": { "dependencies": {
"@budibase/bbui": "^0.9.117-alpha.2", "@budibase/bbui": "^0.9.117-alpha.2",
"@budibase/standard-components": "^0.9.117-alpha.2",
"@budibase/string-templates": "^0.9.117-alpha.2", "@budibase/string-templates": "^0.9.117-alpha.2",
"regexparam": "^1.3.0", "regexparam": "^1.3.0",
"shortid": "^2.2.15", "shortid": "^2.2.15",
"svelte-spa-router": "^3.0.5" "svelte-spa-router": "^3.0.5"
}, },
"devDependencies": { "devDependencies": {
"@budibase/bbui": "^0.9.117-alpha.2",
"@rollup/plugin-alias": "^3.1.5",
"@rollup/plugin-commonjs": "^18.0.0", "@rollup/plugin-commonjs": "^18.0.0",
"@rollup/plugin-node-resolve": "^11.2.1", "@rollup/plugin-node-resolve": "^11.2.1",
"@spectrum-css/button": "^3.0.3",
"@spectrum-css/card": "^3.0.3",
"@spectrum-css/divider": "^1.0.3",
"@spectrum-css/link": "^3.1.3",
"@spectrum-css/page": "^3.0.1",
"@spectrum-css/typography": "^3.0.2",
"@spectrum-css/vars": "^3.0.1",
"apexcharts": "^3.22.1",
"dayjs": "^1.10.5",
"fs-extra": "^8.1.0", "fs-extra": "^8.1.0",
"jsdom": "^16.0.1", "jsdom": "^16.0.1",
"postcss": "^8.2.10", "postcss": "^8.2.10",
@ -39,7 +50,9 @@
"rollup-plugin-svelte": "^7.1.0", "rollup-plugin-svelte": "^7.1.0",
"rollup-plugin-svg": "^2.0.0", "rollup-plugin-svg": "^2.0.0",
"rollup-plugin-terser": "^7.0.2", "rollup-plugin-terser": "^7.0.2",
"svelte": "^3.38.2" "svelte": "^3.38.2",
"svelte-apexcharts": "^1.0.2",
"svelte-flatpickr": "^3.1.0"
}, },
"gitHead": "d1836a898cab3f8ab80ee6d8f42be1a9eed7dcdc" "gitHead": "d1836a898cab3f8ab80ee6d8f42be1a9eed7dcdc"
} }

View File

@ -1,5 +1,6 @@
import commonjs from "@rollup/plugin-commonjs" import commonjs from "@rollup/plugin-commonjs"
import resolve from "@rollup/plugin-node-resolve" import resolve from "@rollup/plugin-node-resolve"
import alias from "@rollup/plugin-alias"
import svelte from "rollup-plugin-svelte" import svelte from "rollup-plugin-svelte"
import { terser } from "rollup-plugin-terser" import { terser } from "rollup-plugin-terser"
import postcss from "rollup-plugin-postcss" import postcss from "rollup-plugin-postcss"
@ -7,6 +8,7 @@ import svg from "rollup-plugin-svg"
import json from "rollup-plugin-json" import json from "rollup-plugin-json"
import builtins from "rollup-plugin-node-builtins" import builtins from "rollup-plugin-node-builtins"
import globals from "rollup-plugin-node-globals" import globals from "rollup-plugin-node-globals"
import path from "path"
const production = !process.env.ROLLUP_WATCH const production = !process.env.ROLLUP_WATCH
const ignoredWarnings = [ const ignoredWarnings = [
@ -26,6 +28,38 @@ export default {
}, },
], ],
plugins: [ plugins: [
alias({
entries: [
{
find: "manifest.json",
replacement: path.resolve("./manifest.json"),
},
{
find: "api",
replacement: path.resolve("./src/api"),
},
{
find: "components",
replacement: path.resolve("./src/components"),
},
{
find: "stores",
replacement: path.resolve("./src/stores"),
},
{
find: "utils",
replacement: path.resolve("./src/utils"),
},
{
find: "constants",
replacement: path.resolve("./src/constants"),
},
{
find: "sdk",
replacement: path.resolve("./src/sdk"),
},
],
}),
svelte({ svelte({
emitCss: true, emitCss: true,
onwarn: (warning, handler) => { onwarn: (warning, handler) => {

View File

@ -1,5 +1,5 @@
import { notificationStore } from "../store" import { notificationStore } from "stores"
import { ApiVersion } from "../constants" import { ApiVersion } from "constants"
/** /**
* API cache for cached request responses. * API cache for cached request responses.

View File

@ -1,5 +1,6 @@
import { notificationStore } from "../store/notification" import { notificationStore } from "stores/notification"
import API from "./api" import API from "./api"
/** /**
* Executes an automation. Must have "App Action" trigger. * Executes an automation. Must have "App Action" trigger.
*/ */

View File

@ -1,4 +1,4 @@
import { notificationStore, dataSourceStore } from "../store" import { notificationStore, dataSourceStore } from "stores"
import API from "./api" import API from "./api"
/** /**

View File

@ -1,4 +1,4 @@
import { notificationStore, dataSourceStore } from "../store" import { notificationStore, dataSourceStore } from "stores"
import API from "./api" import API from "./api"
import { fetchTableDefinition } from "./tables" import { fetchTableDefinition } from "./tables"

View File

@ -1,11 +1,9 @@
<script> <script>
import { writable } from "svelte/store" import { writable } from "svelte/store"
import { setContext, onMount } from "svelte" import { setContext, onMount } from "svelte"
import { Layout, Heading, Body } from "@budibase/bbui"
import Component from "./Component.svelte" import Component from "./Component.svelte"
import NotificationDisplay from "./NotificationDisplay.svelte" import SDK from "sdk"
import ConfirmationDisplay from "./ConfirmationDisplay.svelte"
import PeekScreenDisplay from "./PeekScreenDisplay.svelte"
import SDK from "../sdk"
import { import {
createContextStore, createContextStore,
initialise, initialise,
@ -14,14 +12,16 @@
routeStore, routeStore,
builderStore, builderStore,
appStore, appStore,
} from "../store" } from "stores"
import SettingsBar from "./preview/SettingsBar.svelte" import NotificationDisplay from "components/overlay/NotificationDisplay.svelte"
import SelectionIndicator from "./preview/SelectionIndicator.svelte" import ConfirmationDisplay from "components/overlay/ConfirmationDisplay.svelte"
import HoverIndicator from "./preview/HoverIndicator.svelte" import PeekScreenDisplay from "components/overlay/PeekScreenDisplay.svelte"
import { Layout, Heading, Body } from "@budibase/bbui" import UserBindingsProvider from "components/context/UserBindingsProvider.svelte"
import DeviceBindingsProvider from "components/context/DeviceBindingsProvider.svelte"
import SettingsBar from "components/preview/SettingsBar.svelte"
import SelectionIndicator from "components/preview/SelectionIndicator.svelte"
import HoverIndicator from "components/preview/HoverIndicator.svelte"
import ErrorSVG from "../../../builder/assets/error.svg" import ErrorSVG from "../../../builder/assets/error.svg"
import UserBindingsProvider from "./UserBindingsProvider.svelte"
import DeviceBindingsProvider from "./DeviceBindingsProvider.svelte"
// Provide contexts // Provide contexts
setContext("sdk", SDK) setContext("sdk", SDK)

View File

@ -1,17 +1,14 @@
<script> <script>
import { getContext, setContext } from "svelte" import { getContext, setContext } from "svelte"
import { writable, get } from "svelte/store" import { writable, get } from "svelte/store"
import * as ComponentLibrary from "@budibase/standard-components" import * as AppComponents from "components/app"
import Router from "./Router.svelte" import Router from "./Router.svelte"
import { enrichProps, propsAreSame } from "../utils/componentProps" import { enrichProps, propsAreSame } from "utils/componentProps"
import { builderStore } from "../store" import { builderStore } from "stores"
import { hashString } from "../utils/hash" import { hashString } from "utils/helpers"
import Manifest from "@budibase/standard-components/manifest.json" import Manifest from "manifest.json"
import { Placeholder } from "@budibase/standard-components" import { getActiveConditions, reduceConditionActions } from "utils/conditions"
import { import Placeholder from "components/app/Placeholder.svelte"
getActiveConditions,
reduceConditionActions,
} from "../utils/conditions"
export let instance = {} export let instance = {}
@ -95,7 +92,7 @@
if (name === "screenslot" && $builderStore.previewType !== "layout") { if (name === "screenslot" && $builderStore.previewType !== "layout") {
return Router return Router
} }
return ComponentLibrary[name] return AppComponents[name]
} }
const getComponentDefinition = component => { const getComponentDefinition = component => {

View File

@ -1,7 +1,7 @@
<script> <script>
import { setContext, getContext } from "svelte" import { setContext, getContext } from "svelte"
import Router, { querystring } from "svelte-spa-router" import Router, { querystring } from "svelte-spa-router"
import { routeStore } from "../store" import { routeStore } from "stores"
import Screen from "./Screen.svelte" import Screen from "./Screen.svelte"
const { styleable } = getContext("sdk") const { styleable } = getContext("sdk")

View File

@ -1,7 +1,7 @@
<script> <script>
import { screenStore, routeStore } from "../store" import { screenStore, routeStore } from "stores"
import Component from "./Component.svelte" import Component from "./Component.svelte"
import Provider from "./Provider.svelte" import Provider from "./context/Provider.svelte"
import { onMount } from "svelte" import { onMount } from "svelte"
// Keep route params up to date // Keep route params up to date

View File

@ -6,7 +6,7 @@
luceneQuery, luceneQuery,
luceneSort, luceneSort,
luceneLimit, luceneLimit,
} from "./lucene" } from "utils/lucene"
import Placeholder from "./Placeholder.svelte" import Placeholder from "./Placeholder.svelte"
export let dataSource export let dataSource

View File

@ -1,9 +1,8 @@
<script> <script>
import { getContext } from "svelte" import { getContext } from "svelte"
import { Heading, Icon } from "@budibase/bbui" import { Heading, Icon } from "@budibase/bbui"
import { routeStore } from "../../client/src/store"
const { styleable, linkable, builderStore } = getContext("sdk") const { routeStore, styleable, linkable, builderStore } = getContext("sdk")
const component = getContext("component") const component = getContext("component")
export let title export let title

View File

@ -2,7 +2,7 @@
import { setContext, getContext } from "svelte" import { setContext, getContext } from "svelte"
import { derived, get, writable } from "svelte/store" import { derived, get, writable } from "svelte/store"
import { createValidatorFromConstraints } from "./validation" import { createValidatorFromConstraints } from "./validation"
import { generateID } from "../helpers" import { generateID } from "utils/helpers"
export let dataSource export let dataSource
export let disabled = false export let disabled = false

View File

@ -7,9 +7,6 @@ import "@spectrum-css/vars/dist/spectrum-dark.css"
import "@spectrum-css/vars/dist/spectrum-darkest.css" import "@spectrum-css/vars/dist/spectrum-darkest.css"
import "@spectrum-css/page/dist/index-vars.css" import "@spectrum-css/page/dist/index-vars.css"
import loadSpectrumIcons from "@budibase/bbui/spectrum-icons-rollup.js"
loadSpectrumIcons()
// Non user-facing components // Non user-facing components
export { default as Placeholder } from "./Placeholder.svelte" export { default as Placeholder } from "./Placeholder.svelte"

View File

@ -1,7 +1,7 @@
<script> <script>
import { getContext, setContext, onMount } from "svelte" import { getContext, setContext, onMount } from "svelte"
import { dataSourceStore, createContextStore } from "../store" import { dataSourceStore, createContextStore } from "stores"
import { ActionTypes } from "../constants" import { ActionTypes } from "constants"
import { generate } from "shortid" import { generate } from "shortid"
export let data export let data

View File

@ -1,7 +1,7 @@
<script> <script>
import Provider from "./Provider.svelte" import Provider from "./Provider.svelte"
import { authStore } from "../store" import { authStore } from "stores"
import { ActionTypes, TableNames } from "../constants" import { ActionTypes, TableNames } from "constants"
// Register this as a refreshable datasource so that user changes cause // Register this as a refreshable datasource so that user changes cause
// the user object to be refreshed // the user object to be refreshed

View File

@ -1,5 +1,5 @@
<script> <script>
import { confirmationStore } from "../store" import { confirmationStore } from "stores"
import { Modal, ModalContent } from "@budibase/bbui" import { Modal, ModalContent } from "@budibase/bbui"
</script> </script>

View File

@ -1,5 +1,5 @@
<script> <script>
import { notificationStore } from "../store" import { notificationStore } from "stores"
import { Notification } from "@budibase/bbui" import { Notification } from "@budibase/bbui"
import { fly } from "svelte/transition" import { fly } from "svelte/transition"
</script> </script>

View File

@ -4,7 +4,7 @@
dataSourceStore, dataSourceStore,
notificationStore, notificationStore,
routeStore, routeStore,
} from "../store" } from "stores"
import { Modal, ModalContent, ActionButton } from "@budibase/bbui" import { Modal, ModalContent, ActionButton } from "@budibase/bbui"
import { onDestroy } from "svelte" import { onDestroy } from "svelte"

View File

@ -1,7 +1,7 @@
<script> <script>
import { onMount, onDestroy } from "svelte" import { onMount, onDestroy } from "svelte"
import IndicatorSet from "./IndicatorSet.svelte" import IndicatorSet from "./IndicatorSet.svelte"
import { builderStore } from "../../store" import { builderStore } from "stores"
let componentId let componentId
$: zIndex = componentId === $builderStore.selectedComponentId ? 900 : 920 $: zIndex = componentId === $builderStore.selectedComponentId ? 900 : 920

View File

@ -1,7 +1,7 @@
<script> <script>
import { onMount, onDestroy } from "svelte" import { onMount, onDestroy } from "svelte"
import Indicator from "./Indicator.svelte" import Indicator from "./Indicator.svelte"
import { domDebounce } from "../../utils/domDebounce" import { domDebounce } from "utils/domDebounce"
export let componentId export let componentId
export let color export let color

View File

@ -1,5 +1,5 @@
<script> <script>
import { builderStore } from "../../store" import { builderStore } from "stores"
import IndicatorSet from "./IndicatorSet.svelte" import IndicatorSet from "./IndicatorSet.svelte"
</script> </script>

View File

@ -3,8 +3,8 @@
import SettingsButton from "./SettingsButton.svelte" import SettingsButton from "./SettingsButton.svelte"
import SettingsColorPicker from "./SettingsColorPicker.svelte" import SettingsColorPicker from "./SettingsColorPicker.svelte"
import SettingsPicker from "./SettingsPicker.svelte" import SettingsPicker from "./SettingsPicker.svelte"
import { builderStore } from "../../store" import { builderStore } from "stores"
import { domDebounce } from "../../utils/domDebounce" import { domDebounce } from "utils/domDebounce"
const verticalOffset = 28 const verticalOffset = 28
const horizontalOffset = 2 const horizontalOffset = 2

View File

@ -1,6 +1,6 @@
<script> <script>
import { Icon } from "@budibase/bbui" import { Icon } from "@budibase/bbui"
import { builderStore } from "../../store" import { builderStore } from "stores"
import { createEventDispatcher } from "svelte" import { createEventDispatcher } from "svelte"
export let prop export let prop

View File

@ -1,6 +1,6 @@
<script> <script>
import { ColorPicker } from "@budibase/bbui" import { ColorPicker } from "@budibase/bbui"
import { builderStore } from "../../store" import { builderStore } from "stores"
export let prop export let prop

View File

@ -1,6 +1,6 @@
<script> <script>
import { Select } from "@budibase/bbui" import { Select } from "@budibase/bbui"
import { builderStore } from "../../store" import { builderStore } from "stores"
export let prop export let prop
export let options export let options

View File

@ -1,5 +1,9 @@
import ClientApp from "./components/ClientApp.svelte" import ClientApp from "./components/ClientApp.svelte"
import { builderStore, appStore } from "./store" import { builderStore, appStore } from "./stores"
import loadSpectrumIcons from "@budibase/bbui/spectrum-icons-rollup.js"
// Initialise spectrum icons
loadSpectrumIcons()
let app let app

View File

@ -5,12 +5,12 @@ import {
routeStore, routeStore,
screenStore, screenStore,
builderStore, builderStore,
} from "./store" } from "stores"
import { styleable } from "./utils/styleable" import { styleable } from "utils/styleable"
import { linkable } from "./utils/linkable" import { linkable } from "utils/linkable"
import { getAction } from "./utils/getAction" import { getAction } from "utils/getAction"
import Provider from "./components/Provider.svelte" import Provider from "components/context/Provider.svelte"
import { ActionTypes } from "./constants" import { ActionTypes } from "constants"
export default { export default {
API, API,

View File

@ -1,5 +1,5 @@
import { writable, derived } from "svelte/store" import { writable, derived } from "svelte/store"
import Manifest from "@budibase/standard-components/manifest.json" import Manifest from "manifest.json"
import { findComponentById, findComponentPathById } from "../utils/components" import { findComponentById, findComponentPathById } from "../utils/components"
const dispatchEvent = (type, data = {}) => { const dispatchEvent = (type, data = {}) => {

View File

@ -5,9 +5,9 @@ import {
confirmationStore, confirmationStore,
authStore, authStore,
peekStore, peekStore,
} from "../store" } from "stores"
import { saveRow, deleteRow, executeQuery, triggerAutomation } from "../api" import { saveRow, deleteRow, executeQuery, triggerAutomation } from "api"
import { ActionTypes } from "../constants" import { ActionTypes } from "constants"
const saveRowHandler = async (action, context) => { const saveRowHandler = async (action, context) => {
const { fields, providerId, tableId } = action.parameters const { fields, providerId, tableId } = action.parameters

View File

@ -1,7 +1,4 @@
import { import { buildLuceneQuery, luceneQuery } from "./lucene"
buildLuceneQuery,
luceneQuery,
} from "../../../standard-components/src/lucene"
export const getActiveConditions = conditions => { export const getActiveConditions = conditions => {
if (!conditions?.length) { if (!conditions?.length) {

View File

@ -1,12 +0,0 @@
export const hashString = str => {
if (!str) {
return 0
}
let hash = 0
for (let i = 0; i < str.length; i++) {
let char = str.charCodeAt(i)
hash = (hash << 5) - hash + char
hash = hash & hash // Convert to 32bit integer
}
return hash
}

View File

@ -39,3 +39,19 @@ export const generateID = (size = 21) => {
} }
return id return id
} }
/**
* Computes a short hash of a string
*/
export const hashString = str => {
if (!str) {
return 0
}
let hash = 0
for (let i = 0; i < str.length; i++) {
let char = str.charCodeAt(i)
hash = (hash << 5) - hash + char
hash = hash & hash // Convert to 32bit integer
}
return hash
}

View File

@ -1,6 +1,6 @@
import { get } from "svelte/store" import { get } from "svelte/store"
import { link } from "svelte-spa-router" import { link } from "svelte-spa-router"
import { builderStore } from "../store" import { builderStore } from "stores"
export const linkable = (node, href) => { export const linkable = (node, href) => {
if (get(builderStore).inBuilder) { if (get(builderStore).inBuilder) {

Some files were not shown because too many files have changed in this diff Show More