diff --git a/packages/builder/src/builderStore/loadComponentLibraries.js b/packages/builder/src/builderStore/loadComponentLibraries.js index ed720ad6c0..1bd30a5582 100644 --- a/packages/builder/src/builderStore/loadComponentLibraries.js +++ b/packages/builder/src/builderStore/loadComponentLibraries.js @@ -1,6 +1,11 @@ +import { flatten, values, uniq, map } from "lodash/fp" +import { pipe } from "../common/core" + export const loadLibs = async (appName, appPackage) => { const allLibraries = {} - for (let lib of appPackage.pages.componentLibraries) { + + for (let lib of libsFromPages(appPackage.pages)) { + const libModule = await import(makeLibraryUrl(appName, lib)) allLibraries[lib] = libModule } @@ -10,7 +15,7 @@ export const loadLibs = async (appName, appPackage) => { export const loadLibUrls = (appName, appPackage) => { const allLibraries = [] - for (let lib of appPackage.pages.componentLibraries) { + for (let lib of libsFromPages(appPackage.pages)) { const libUrl = makeLibraryUrl(appName, lib) allLibraries.push({ libName: lib, importPath: libUrl }) } @@ -25,3 +30,11 @@ export const loadLib = async (appName, lib, allLibs) => { export const makeLibraryUrl = (appName, lib) => `/_builder/${appName}/componentlibrary?lib=${encodeURI(lib)}` + +export const libsFromPages = pages => pipe(pages, [ + values, + map(p => p.componentLibraries), + flatten, + uniq +]) + diff --git a/packages/builder/src/builderStore/store.js b/packages/builder/src/builderStore/store.js index 70207314ac..9245e2c9b5 100644 --- a/packages/builder/src/builderStore/store.js +++ b/packages/builder/src/builderStore/store.js @@ -140,8 +140,6 @@ const initialise = (store, initial) => async () => { ]) pkg.pages = { - componentLibraries: ["@budibase/standard-components"], - stylesheets: [], main: { ...pkg.pages.main, _screens: Object.values(main_screens), diff --git a/packages/builder/src/userInterface/ComponentsHierarchyChildren.svelte b/packages/builder/src/userInterface/ComponentsHierarchyChildren.svelte index 6e1de3db6f..b15ecc341d 100644 --- a/packages/builder/src/userInterface/ComponentsHierarchyChildren.svelte +++ b/packages/builder/src/userInterface/ComponentsHierarchyChildren.svelte @@ -38,7 +38,7 @@ class="item" class:selected={currentComponent === component} style="padding-left: {level * 20 + 67}px"> - {get_capitalised_name(component._component)} +
{get_capitalised_name(component._component)}
{#if index > 0}

- {#each $store.pages.componentLibraries as lib} + {#each $store.pages[$store.currentPageName].componentLibraries as lib}
{lib} removeLibrary(lib)} /> @@ -79,7 +79,7 @@

- {#each $store.pages.stylesheets as stylesheet} + {#each $store.pages[$store.currentPageName].stylesheets as stylesheet}
{stylesheet} "lib", "node_modules", "@budibase", - "standard-components" + "materialdesign-components" ) const publicUnauth = appName => join( @@ -37,7 +37,7 @@ const publicUnauth = appName => "lib", "node_modules", "@budibase", - "standard-components" + "materialdesign-components" ) const nodeModulesDist = appName => join( @@ -45,11 +45,18 @@ const nodeModulesDist = appName => appName, "node_modules", "@budibase", - "standard-components", + "materialdesign-components", "dist" ) + const nodeModules = appName => - join(appPackages, appName, "node_modules", "@budibase", "standard-components") + join( + appPackages, + appName, + "node_modules", + "@budibase", + "materialdesign-components" + ) ;(async () => { const apps = await readdir(appPackages)