diff --git a/packages/materialdesign-components/package.json b/packages/materialdesign-components/package.json
index ba2e4dc891..1629b78963 100644
--- a/packages/materialdesign-components/package.json
+++ b/packages/materialdesign-components/package.json
@@ -46,5 +46,8 @@
],
"version": "0.0.24",
"license": "MIT",
- "gitHead": "115189f72a850bfb52b65ec61d932531bf327072"
+ "gitHead": "115189f72a850bfb52b65ec61d932531bf327072",
+ "dependencies": {
+ "@material/select": "4.0.0"
+ }
}
diff --git a/packages/materialdesign-components/src/Button/Button.svelte b/packages/materialdesign-components/src/Button/Button.svelte
index 84e3395987..7c8821547a 100644
--- a/packages/materialdesign-components/src/Button/Button.svelte
+++ b/packages/materialdesign-components/src/Button/Button.svelte
@@ -34,10 +34,6 @@
const clicked = () => _bb.call(onClick)
- $: if (icon) {
- setContext("BBMD:icon:context", "button")
- }
-
$: renderLeadingIcon = !!icon && !trailingIcon
$: renderTrailingIcon = !!icon && trailingIcon
@@ -54,11 +50,11 @@
{disabled}
on:click={clicked}>
{#if renderLeadingIcon}
-
+
{/if}
{text}
{#if renderTrailingIcon}
-
+
{/if}
{/if}
diff --git a/packages/materialdesign-components/src/Common/Icon.svelte b/packages/materialdesign-components/src/Common/Icon.svelte
index e2c309f73e..d4820fcf6c 100644
--- a/packages/materialdesign-components/src/Common/Icon.svelte
+++ b/packages/materialdesign-components/src/Common/Icon.svelte
@@ -2,11 +2,9 @@
import { getContext } from "svelte"
export let icon = ""
+ export let context = ""
- let iconContext = getContext("BBMD:icon:context")
- let cls = iconContext
- ? `material-icons mdc-${iconContext}__icon`
- : "material-icons"
+ let cls = !!context ? `material-icons mdc-${context}__icon` : "material-icons"
{icon}
diff --git a/packages/materialdesign-components/src/List/List.svelte b/packages/materialdesign-components/src/List/List.svelte
index 21cecbeada..eae7018d1b 100644
--- a/packages/materialdesign-components/src/List/List.svelte
+++ b/packages/materialdesign-components/src/List/List.svelte
@@ -17,31 +17,25 @@
export let onSelect = selectedItems => {}
export let singleSelection = false
- export let variant = "two-line"
+ export let variant = "one-line"
export let inputElement = null
let selectedItemsStore
let role = "listbox"
- function createOrAcceptItemStore() {
- let store = _bb.getContext("BBMD:list:selectItemStore")
- if (!!store) {
- selectedItemsStore = store
- } else {
- selectedItemsStore = createItemsStore(() => onSelect($selectedItemsStore))
- _bb.setContext("BBMD:list:selectItemStore", selectedItemsStore)
- }
- }
-
onMount(() => {
- createOrAcceptItemStore()
+ let ctx = getContext("BBMD:list:context")
+
+ selectedItemsStore = createItemsStore(() => onSelect($selectedItemsStore))
+ _bb.setContext("BBMD:list:selectItemStore", selectedItemsStore)
_bb.setContext("BBMD:list:props", {
inputElement,
variant,
singleSelection,
})
+
if (!!list) {
if (!inputElement) {
instance = new MDCList(list)
diff --git a/packages/materialdesign-components/src/List/ListItem.svelte b/packages/materialdesign-components/src/List/ListItem.svelte
index 775d73d2e2..f60396ae4d 100644
--- a/packages/materialdesign-components/src/List/ListItem.svelte
+++ b/packages/materialdesign-components/src/List/ListItem.svelte
@@ -2,13 +2,12 @@
import { onMount, getContext } from "svelte"
import { Radiobutton } from "../Radiobutton"
import { Checkbox } from "../Checkbox"
+ import Icon from "../Common/Icon.svelte"
import ClassBuilder from "../ClassBuilder.js"
import { generate } from "shortid"
const cb = new ClassBuilder("list-item")
- export let onClick = item => {}
-
let _id
let listProps = null
@@ -16,7 +15,7 @@
export let _bb
- export let value = null
+ export let value = ""
export let text = ""
export let secondaryText = ""
@@ -24,6 +23,7 @@
export let trailingIcon = ""
export let selected = false
export let disabled = false
+ export let dividerAfter = false
let role = "option"
@@ -84,7 +84,13 @@
listProps && listProps.variant === "two-line" && !!secondaryText
-
+
{#if leadingIcon}
{leadingIcon}
@@ -104,9 +110,9 @@
{/if}
{:else if trailingIcon}
-
-
- {trailingIcon}
-
+
{/if}
+{#if dividerAfter}
+
+{/if}
diff --git a/packages/materialdesign-components/src/Menu/Menu.svelte b/packages/materialdesign-components/src/Menu/Menu.svelte
index 89c2404f4c..5782652376 100644
--- a/packages/materialdesign-components/src/Menu/Menu.svelte
+++ b/packages/materialdesign-components/src/Menu/Menu.svelte
@@ -2,8 +2,10 @@
import { List } from "../List"
import { MDCMenu } from "@material/menu"
import { onMount, setContext } from "svelte"
- export let items = []
- export let singleSelection = true
+ import createItemsStore from "../Common/ItemStore.js"
+
+ export let onSelect = selectedItems => {}
+
export let width = "400px"
export let open = true
export let useFixedPosition = false
@@ -11,10 +13,20 @@
//{x: number, y: number}
export let absolutePositionCoords = null
+ export let _bb
+
let menu = null
+ let menuList = null
let instance = null
+ let selectedItemsStore
onMount(() => {
+ _bb.setContext("BBMD:list:context", "menu")
+ _bb.setContext("BBMD:list:props", { singleSelection: true })
+
+ selectedItemsStore = createItemsStore(() => onSelect($selectedItemsStore))
+ _bb.setContext("BBMD:list:selectItemStore", selectedItemsStore)
+
if (!!menu) {
instance = new MDCMenu(menu)
instance.open = open
@@ -25,8 +37,9 @@
instance.setAbsolutePosition(x | 0, y | 0)
}
}
- setContext("BBMD:list:context", "menu")
})
+
+ $: menuList && _bb.attachChildren(menuList)
{#if useFixedPosition || useAbsolutePosition}
@@ -34,17 +47,17 @@
bind:this={menu}
class="mdc-menu mdc-menu-surface"
style={`width: ${width}`}>
-
+
{:else}
{/if}
diff --git a/packages/materialdesign-components/src/Menu/_styles.scss b/packages/materialdesign-components/src/Menu/_styles.scss
index 13bd3f1d98..596b6a96da 100644
--- a/packages/materialdesign-components/src/Menu/_styles.scss
+++ b/packages/materialdesign-components/src/Menu/_styles.scss
@@ -1,2 +1,3 @@
+@import "@material/list/mdc-list.scss";
@import "@material/menu-surface/mdc-menu-surface.scss";
@import "@material/menu/mdc-menu.scss";
diff --git a/packages/materialdesign-components/src/Select/HelperText.svelte b/packages/materialdesign-components/src/Select/HelperText.svelte
new file mode 100644
index 0000000000..888f6e5267
--- /dev/null
+++ b/packages/materialdesign-components/src/Select/HelperText.svelte
@@ -0,0 +1,31 @@
+
+
+{text}
diff --git a/packages/materialdesign-components/src/Select/Select.svelte b/packages/materialdesign-components/src/Select/Select.svelte
new file mode 100644
index 0000000000..28cf58697f
--- /dev/null
+++ b/packages/materialdesign-components/src/Select/Select.svelte
@@ -0,0 +1,88 @@
+
+
+
+
+
+
+
+ {#if useNotchedOutline}
+
+
+
+ {:else}
+
+
+ {/if}
+
+
+
+
+
+
diff --git a/packages/materialdesign-components/src/Select/_style.scss b/packages/materialdesign-components/src/Select/_style.scss
new file mode 100644
index 0000000000..e58101303e
--- /dev/null
+++ b/packages/materialdesign-components/src/Select/_style.scss
@@ -0,0 +1,4 @@
+@use "@material/list/mdc-list";
+@use "@material/menu-surface/mdc-menu-surface";
+@use "@material/menu/mdc-menu";
+@use "@material/select/mdc-select";
\ No newline at end of file
diff --git a/packages/materialdesign-components/src/Select/index.js b/packages/materialdesign-components/src/Select/index.js
new file mode 100644
index 0000000000..ee0c361c69
--- /dev/null
+++ b/packages/materialdesign-components/src/Select/index.js
@@ -0,0 +1,3 @@
+import "./_style.scss"
+export { default as HelperText } from "./HelperText.svelte"
+export { default as Select } from "./Select.svelte";
\ No newline at end of file
diff --git a/packages/materialdesign-components/src/Test/TestApp.svelte b/packages/materialdesign-components/src/Test/TestApp.svelte
index 518dc54481..bdea8413ed 100644
--- a/packages/materialdesign-components/src/Test/TestApp.svelte
+++ b/packages/materialdesign-components/src/Test/TestApp.svelte
@@ -14,8 +14,9 @@
Radiobuttongroup,
Datatable,
CustomersIndexTable,
- List,
Icon,
+ List,
+ Select,
} = props
let currentComponent
@@ -36,6 +37,7 @@
Datatable,
CustomersIndexTable,
List,
+ Select,
],
},
}
diff --git a/packages/materialdesign-components/src/Test/props.js b/packages/materialdesign-components/src/Test/props.js
index ec7f4b9bd9..942b031117 100644
--- a/packages/materialdesign-components/src/Test/props.js
+++ b/packages/materialdesign-components/src/Test/props.js
@@ -119,7 +119,7 @@ export const props = {
_component: "@budibase/materialdesign-components/List",
variant: "two-line",
singleSelection: false,
- onSelect: selected => console.log(selected),
+ onSelect: selected => console.log("LIST SELECT", selected),
_children: [
{
_component: "@budibase/materialdesign-components/ListItem",
@@ -144,6 +144,33 @@ export const props = {
secondaryText: "Salmon or Cod",
value: 2,
},
- ]
+ ],
+ },
+ Select: {
+ _component: "@budibase/materialdesign-components/Select",
+ label: "Choose a Milkshake",
+ helperText: "Choose a flavour",
+ persistent: true,
+ onSelect: selectedItem => console.log("SELECT ITEM", selectedItem),
+ _children: [
+ {
+ _component: "@budibase/materialdesign-components/ListItem",
+ _children: [],
+ text: "Orange",
+ value: 0,
+ },
+ {
+ _component: "@budibase/materialdesign-components/ListItem",
+ _children: [],
+ text: "Apple",
+ value: 1,
+ },
+ {
+ _component: "@budibase/materialdesign-components/ListItem",
+ _children: [],
+ text: "Berry",
+ value: 0,
+ },
+ ],
},
}
diff --git a/packages/materialdesign-components/src/Textfield/Textfield.svelte b/packages/materialdesign-components/src/Textfield/Textfield.svelte
index a5d5517df0..7de3141e54 100644
--- a/packages/materialdesign-components/src/Textfield/Textfield.svelte
+++ b/packages/materialdesign-components/src/Textfield/Textfield.svelte
@@ -71,7 +71,6 @@
let useIcon = !!icon && !textarea && !fullwidth
if (useIcon) {
- setContext("BBMD:icon:context", "text-field")
let iconClass = trailingIcon ? "with-trailing-icon" : "with-leading-icon"
modifiers = { ...modifiers, iconClass }
}
@@ -124,7 +123,7 @@ TODO:Needs error handling - this will depend on how Budibase handles errors
on:change={changed} />
{:else}
{#if renderLeadingIcon}
-
+
{/if}
{#if renderTrailingIcon}
-
+
{/if}
{#if variant !== 'outlined'}
diff --git a/packages/materialdesign-components/src/index.js b/packages/materialdesign-components/src/index.js
index 5dac37d7b6..5e1df0081e 100644
--- a/packages/materialdesign-components/src/index.js
+++ b/packages/materialdesign-components/src/index.js
@@ -17,3 +17,5 @@ export {
export { default as indexDatatable } from "./Templates/indexDatatable"
export { default as recordForm } from "./Templates/recordForm"
export { List, ListItem } from "./List"
+export { Menu } from "./Menu"
+export { Select } from "./Select"