Refactored the approach to builder focus. Extending the behaviour beyond form fields
This commit is contained in:
parent
81bb960491
commit
253642ad1f
|
@ -3,7 +3,7 @@
|
||||||
import "@spectrum-css/popover/dist/index-vars.css"
|
import "@spectrum-css/popover/dist/index-vars.css"
|
||||||
import "@spectrum-css/menu/dist/index-vars.css"
|
import "@spectrum-css/menu/dist/index-vars.css"
|
||||||
import { fly } from "svelte/transition"
|
import { fly } from "svelte/transition"
|
||||||
import { createEventDispatcher, getContext } from "svelte"
|
import { createEventDispatcher } from "svelte"
|
||||||
|
|
||||||
export let value = null
|
export let value = null
|
||||||
export let id = null
|
export let id = null
|
||||||
|
@ -21,11 +21,7 @@
|
||||||
let focus = false
|
let focus = false
|
||||||
let comboInput
|
let comboInput
|
||||||
|
|
||||||
let builderFocus = getContext("field_focus")
|
$: focus = autofocus && comboInput
|
||||||
|
|
||||||
$: if (autofocus && comboInput) {
|
|
||||||
comboInput.focus()
|
|
||||||
}
|
|
||||||
|
|
||||||
const selectOption = value => {
|
const selectOption = value => {
|
||||||
dispatch("change", value)
|
dispatch("change", value)
|
||||||
|
@ -61,12 +57,7 @@
|
||||||
{id}
|
{id}
|
||||||
type="text"
|
type="text"
|
||||||
on:focus={() => (focus = true)}
|
on:focus={() => (focus = true)}
|
||||||
on:blur={() => {
|
on:blur={() => (focus = false)}
|
||||||
if (builderFocus) {
|
|
||||||
builderFocus.clear()
|
|
||||||
}
|
|
||||||
focus = false
|
|
||||||
}}
|
|
||||||
on:change={onType}
|
on:change={onType}
|
||||||
value={value || ""}
|
value={value || ""}
|
||||||
placeholder={placeholder || ""}
|
placeholder={placeholder || ""}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
export let readonly = false
|
export let readonly = false
|
||||||
export let autocomplete = false
|
export let autocomplete = false
|
||||||
export let sort = false
|
export let sort = false
|
||||||
|
export let autofocus = false
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
$: selectedLookupMap = getSelectedLookupMap(value)
|
$: selectedLookupMap = getSelectedLookupMap(value)
|
||||||
|
@ -85,4 +86,5 @@
|
||||||
{getOptionValue}
|
{getOptionValue}
|
||||||
onSelectOption={toggleOption}
|
onSelectOption={toggleOption}
|
||||||
{sort}
|
{sort}
|
||||||
|
{autofocus}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -26,9 +26,14 @@
|
||||||
export let autoWidth = false
|
export let autoWidth = false
|
||||||
export let autocomplete = false
|
export let autocomplete = false
|
||||||
export let sort = false
|
export let sort = false
|
||||||
|
export let autofocus = false
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
let searchTerm = null
|
let searchTerm = null
|
||||||
|
let focus = false
|
||||||
|
let pickerButton
|
||||||
|
|
||||||
|
$: focus = autofocus && pickerButton
|
||||||
|
|
||||||
$: sortedOptions = getSortedOptions(options, getOptionLabel, sort)
|
$: sortedOptions = getSortedOptions(options, getOptionLabel, sort)
|
||||||
$: filteredOptions = getFilteredOptions(
|
$: filteredOptions = getFilteredOptions(
|
||||||
|
@ -80,7 +85,15 @@
|
||||||
class:is-invalid={!!error}
|
class:is-invalid={!!error}
|
||||||
class:is-open={open}
|
class:is-open={open}
|
||||||
aria-haspopup="listbox"
|
aria-haspopup="listbox"
|
||||||
|
class:is-focused={focus}
|
||||||
|
bind:this={pickerButton}
|
||||||
on:mousedown={onClick}
|
on:mousedown={onClick}
|
||||||
|
on:focus={() => {
|
||||||
|
focus = true
|
||||||
|
}}
|
||||||
|
on:blur={() => {
|
||||||
|
focus = false
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{#if fieldIcon}
|
{#if fieldIcon}
|
||||||
<span class="icon-Placeholder-Padding">
|
<span class="icon-Placeholder-Padding">
|
||||||
|
@ -199,6 +212,7 @@
|
||||||
}
|
}
|
||||||
.spectrum-Picker {
|
.spectrum-Picker {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
box-shadow: none;
|
||||||
}
|
}
|
||||||
.spectrum-Picker-label:not(.auto-width) {
|
.spectrum-Picker-label:not(.auto-width) {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
export let autoWidth = false
|
export let autoWidth = false
|
||||||
export let autocomplete = false
|
export let autocomplete = false
|
||||||
export let sort = false
|
export let sort = false
|
||||||
|
export let autofocus = false
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
let open = false
|
let open = false
|
||||||
|
@ -74,6 +75,7 @@
|
||||||
{fieldIcon}
|
{fieldIcon}
|
||||||
{autocomplete}
|
{autocomplete}
|
||||||
{sort}
|
{sort}
|
||||||
|
{autofocus}
|
||||||
isPlaceholder={value == null || value === ""}
|
isPlaceholder={value == null || value === ""}
|
||||||
placeholderOption={placeholder}
|
placeholderOption={placeholder}
|
||||||
isOptionSelected={option => option === value}
|
isOptionSelected={option => option === value}
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
export let getOptionLabel = option => option
|
export let getOptionLabel = option => option
|
||||||
export let getOptionValue = option => option
|
export let getOptionValue = option => option
|
||||||
export let sort = false
|
export let sort = false
|
||||||
|
export let autofocus = false
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
const onChange = e => {
|
const onChange = e => {
|
||||||
|
@ -35,5 +36,6 @@
|
||||||
{getOptionValue}
|
{getOptionValue}
|
||||||
on:change={onChange}
|
on:change={onChange}
|
||||||
on:click
|
on:click
|
||||||
|
{autofocus}
|
||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
export let autoWidth = false
|
export let autoWidth = false
|
||||||
export let sort = false
|
export let sort = false
|
||||||
export let tooltip = ""
|
export let tooltip = ""
|
||||||
|
export let autofocus = false
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
const onChange = e => {
|
const onChange = e => {
|
||||||
|
@ -44,6 +45,7 @@
|
||||||
{placeholder}
|
{placeholder}
|
||||||
{autoWidth}
|
{autoWidth}
|
||||||
{sort}
|
{sort}
|
||||||
|
{autofocus}
|
||||||
{getOptionLabel}
|
{getOptionLabel}
|
||||||
{getOptionValue}
|
{getOptionValue}
|
||||||
{getOptionIcon}
|
{getOptionIcon}
|
||||||
|
|
|
@ -380,21 +380,6 @@ export const getFrontendStore = () => {
|
||||||
const selected = get(selectedComponent)
|
const selected = get(selectedComponent)
|
||||||
const asset = get(currentAsset)
|
const asset = get(currentAsset)
|
||||||
|
|
||||||
const formComponents = [
|
|
||||||
"stringfield",
|
|
||||||
"optionsfield",
|
|
||||||
"numberfield",
|
|
||||||
"datetimefield",
|
|
||||||
"booleanfield",
|
|
||||||
"passwordfield",
|
|
||||||
"longformfield",
|
|
||||||
"attachmentfield",
|
|
||||||
"jsonfield",
|
|
||||||
"relationshipfield",
|
|
||||||
"multifieldselect",
|
|
||||||
"s3upload",
|
|
||||||
]
|
|
||||||
|
|
||||||
// Create new component
|
// Create new component
|
||||||
const componentInstance = store.actions.components.createInstance(
|
const componentInstance = store.actions.components.createInstance(
|
||||||
componentName,
|
componentName,
|
||||||
|
@ -432,16 +417,7 @@ export const getFrontendStore = () => {
|
||||||
}
|
}
|
||||||
parentComponent._children.push(componentInstance)
|
parentComponent._children.push(componentInstance)
|
||||||
|
|
||||||
let isFormComponent = false
|
const definition = store.actions.components.getDefinition(componentName)
|
||||||
let componentPrefix = "@budibase/standard-components/"
|
|
||||||
if (parentComponent._component === componentPrefix + "form") {
|
|
||||||
const mappedComponentTypes = formComponents.map(cmp => {
|
|
||||||
return componentPrefix + cmp
|
|
||||||
})
|
|
||||||
if (mappedComponentTypes.indexOf(componentInstance._component) > -1) {
|
|
||||||
isFormComponent = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save components and update UI
|
// Save components and update UI
|
||||||
await store.actions.preview.saveSelected()
|
await store.actions.preview.saveSelected()
|
||||||
|
@ -449,13 +425,17 @@ export const getFrontendStore = () => {
|
||||||
state.currentView = "component"
|
state.currentView = "component"
|
||||||
state.selectedComponentId = componentInstance._id
|
state.selectedComponentId = componentInstance._id
|
||||||
|
|
||||||
if (isFormComponent) {
|
const focusSetting = definition.settings.filter((setting) => { return setting.required })
|
||||||
//A field component added to a form.
|
const mappedSettings = focusSetting.map((setting) => {
|
||||||
state.builderFocus = {
|
return {
|
||||||
key: "field",
|
key: setting.key,
|
||||||
target: state.selectedComponentId,
|
target: state.selectedComponentId,
|
||||||
location: "component_settings",
|
location: "component_settings",
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if(focusSetting.length){
|
||||||
|
state.builderFocus = mappedSettings
|
||||||
}
|
}
|
||||||
return state
|
return state
|
||||||
})
|
})
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
export let options
|
export let options
|
||||||
export let allowJS = true
|
export let allowJS = true
|
||||||
export let appendBindingsAsOptions = true
|
export let appendBindingsAsOptions = true
|
||||||
|
export let autofocus = false
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
let bindingDrawer
|
let bindingDrawer
|
||||||
|
@ -61,6 +62,7 @@
|
||||||
on:pick={e => onChange(e.detail, true)}
|
on:pick={e => onChange(e.detail, true)}
|
||||||
{placeholder}
|
{placeholder}
|
||||||
options={allOptions}
|
options={allOptions}
|
||||||
|
{autofocus}
|
||||||
/>
|
/>
|
||||||
{#if !disabled}
|
{#if !disabled}
|
||||||
<div
|
<div
|
||||||
|
|
|
@ -148,6 +148,21 @@
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const resolveFocus = (data) => {
|
||||||
|
if($store.builderFocus){
|
||||||
|
const comp = $store.builderFocus.reduce((acc, item)=>{
|
||||||
|
acc = item.target
|
||||||
|
return acc
|
||||||
|
}, "")
|
||||||
|
if(data.id !== comp){
|
||||||
|
store.update(state => {
|
||||||
|
delete state.builderFocus
|
||||||
|
return state
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const handleBudibaseEvent = async event => {
|
const handleBudibaseEvent = async event => {
|
||||||
const { type, data } = event.data || event.detail
|
const { type, data } = event.data || event.detail
|
||||||
if (!type) {
|
if (!type) {
|
||||||
|
@ -157,14 +172,7 @@
|
||||||
try {
|
try {
|
||||||
if (type === "select-component" && data.id) {
|
if (type === "select-component" && data.id) {
|
||||||
store.actions.components.select({ _id: data.id })
|
store.actions.components.select({ _id: data.id })
|
||||||
//Clear focus
|
resolveFocus(data)
|
||||||
if(data.id !== $store.builderFocus?.target){
|
|
||||||
store.update(state => {
|
|
||||||
delete state.builderFocus
|
|
||||||
return state
|
|
||||||
})
|
|
||||||
}
|
|
||||||
//check if the builder-focus matches?
|
|
||||||
} else if (type === "update-prop") {
|
} else if (type === "update-prop") {
|
||||||
await store.actions.components.updateProp(data.prop, data.value)
|
await store.actions.components.updateProp(data.prop, data.value)
|
||||||
} else if (type === "delete-component" && data.id) {
|
} else if (type === "delete-component" && data.id) {
|
||||||
|
@ -202,7 +210,7 @@
|
||||||
store.update(state => ({
|
store.update(state => ({
|
||||||
...state,
|
...state,
|
||||||
builderFocus :
|
builderFocus :
|
||||||
{ ...data }
|
[{...data}]
|
||||||
}))
|
}))
|
||||||
} else {
|
} else {
|
||||||
console.warn(`Client sent unknown event type: ${type}`)
|
console.warn(`Client sent unknown event type: ${type}`)
|
||||||
|
|
|
@ -3,29 +3,16 @@
|
||||||
import { Input, DetailSummary, notifications } from "@budibase/bbui"
|
import { Input, DetailSummary, notifications } from "@budibase/bbui"
|
||||||
import { store } from "builderStore"
|
import { store } from "builderStore"
|
||||||
import PropertyControl from "./PropertyControls/PropertyControl.svelte"
|
import PropertyControl from "./PropertyControls/PropertyControl.svelte"
|
||||||
import LayoutSelect from "./PropertyControls/LayoutSelect.svelte"
|
|
||||||
import RoleSelect from "./PropertyControls/RoleSelect.svelte"
|
|
||||||
import ResetFieldsButton from "./PropertyControls/ResetFieldsButton.svelte"
|
import ResetFieldsButton from "./PropertyControls/ResetFieldsButton.svelte"
|
||||||
import { getComponentForSettingType } from "./PropertyControls/componentSettings"
|
import { getComponentForSettingType } from "./PropertyControls/componentSettings"
|
||||||
import { Utils } from "@budibase/frontend-core"
|
import { Utils } from "@budibase/frontend-core"
|
||||||
|
|
||||||
export let componentDefinition
|
export let componentDefinition
|
||||||
export let componentInstance
|
export let componentInstance
|
||||||
export let assetInstance
|
|
||||||
export let bindings
|
export let bindings
|
||||||
export let componentBindings
|
export let componentBindings
|
||||||
|
|
||||||
const layoutDefinition = []
|
|
||||||
const screenDefinition = [
|
|
||||||
{ key: "description", label: "Description", control: Input },
|
|
||||||
{ key: "routing.route", label: "Route", control: Input },
|
|
||||||
{ key: "routing.roleId", label: "Access", control: RoleSelect },
|
|
||||||
{ key: "layoutId", label: "Layout", control: LayoutSelect },
|
|
||||||
]
|
|
||||||
|
|
||||||
$: sections = getSections(componentDefinition)
|
$: sections = getSections(componentDefinition)
|
||||||
$: isLayout = assetInstance && assetInstance.favicon
|
|
||||||
$: assetDefinition = isLayout ? layoutDefinition : screenDefinition
|
|
||||||
|
|
||||||
const getSections = definition => {
|
const getSections = definition => {
|
||||||
const settings = definition?.settings ?? []
|
const settings = definition?.settings ?? []
|
||||||
|
@ -88,11 +75,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const isFocused = setting => {
|
const isFocused = setting => {
|
||||||
return (
|
if (!$store.builderFocus) {
|
||||||
componentInstance._id === $store.builderFocus?.target &&
|
return false
|
||||||
setting.key === $store.builderFocus?.key &&
|
}
|
||||||
"component_settings" === $store.builderFocus?.location
|
return setting.required === true
|
||||||
)
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
import { createEventDispatcher, onMount } from "svelte"
|
import { createEventDispatcher, onMount } from "svelte"
|
||||||
|
|
||||||
export let value
|
export let value
|
||||||
|
export let autofocus = false
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
const getValue = component => `{{ literal ${makePropSafe(component._id)} }}`
|
const getValue = component => `{{ literal ${makePropSafe(component._id)} }}`
|
||||||
|
@ -24,6 +25,7 @@
|
||||||
|
|
||||||
<Select
|
<Select
|
||||||
{value}
|
{value}
|
||||||
|
{autofocus}
|
||||||
placeholder={null}
|
placeholder={null}
|
||||||
on:change
|
on:change
|
||||||
options={providers}
|
options={providers}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
export let componentInstance = {}
|
export let componentInstance = {}
|
||||||
export let value = ""
|
export let value = ""
|
||||||
export let placeholder
|
export let placeholder
|
||||||
|
export let autofocus = false
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
$: datasource = getDatasourceForProvider($currentAsset, componentInstance)
|
$: datasource = getDatasourceForProvider($currentAsset, componentInstance)
|
||||||
|
@ -37,4 +38,10 @@
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Select {placeholder} value={boundValue} on:change={onChange} {options} />
|
<Select
|
||||||
|
{placeholder}
|
||||||
|
value={boundValue}
|
||||||
|
on:change={onChange}
|
||||||
|
{options}
|
||||||
|
{autofocus}
|
||||||
|
/>
|
||||||
|
|
|
@ -4,19 +4,8 @@
|
||||||
getDatasourceForProvider,
|
getDatasourceForProvider,
|
||||||
getSchemaForDatasource,
|
getSchemaForDatasource,
|
||||||
} from "builderStore/dataBinding"
|
} from "builderStore/dataBinding"
|
||||||
import { currentAsset, store } from "builderStore"
|
import { currentAsset } from "builderStore"
|
||||||
import { findClosestMatchingComponent } from "builderStore/componentUtils"
|
import { findClosestMatchingComponent } from "builderStore/componentUtils"
|
||||||
import { setContext } from "svelte"
|
|
||||||
|
|
||||||
setContext("field_focus", {
|
|
||||||
clear: () => {
|
|
||||||
store.update(state => {
|
|
||||||
delete state.builderFocus
|
|
||||||
return state
|
|
||||||
})
|
|
||||||
},
|
|
||||||
test: $store.builderFocus?.target,
|
|
||||||
})
|
|
||||||
|
|
||||||
export let componentInstance
|
export let componentInstance
|
||||||
export let value
|
export let value
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
export let componentInstance = {}
|
export let componentInstance = {}
|
||||||
export let value = ""
|
export let value = ""
|
||||||
export let placeholder
|
export let placeholder
|
||||||
|
export let autofocus
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
$: datasource = getDatasourceForProvider($currentAsset, componentInstance)
|
$: datasource = getDatasourceForProvider($currentAsset, componentInstance)
|
||||||
|
@ -31,4 +32,10 @@
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Multiselect {placeholder} value={boundValue} on:change={setValue} {options} />
|
<Multiselect
|
||||||
|
{placeholder}
|
||||||
|
value={boundValue}
|
||||||
|
on:change={setValue}
|
||||||
|
{options}
|
||||||
|
{autofocus}
|
||||||
|
/>
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
import DevicePreviewSelect from "components/design/AppPreview/DevicePreviewSelect.svelte"
|
import DevicePreviewSelect from "components/design/AppPreview/DevicePreviewSelect.svelte"
|
||||||
import Logo from "assets/bb-space-man.svg"
|
import Logo from "assets/bb-space-man.svg"
|
||||||
import ScreenWizard from "components/design/NavigationPanel/ScreenWizard.svelte"
|
import ScreenWizard from "components/design/NavigationPanel/ScreenWizard.svelte"
|
||||||
|
import { clickOutside } from "@budibase/bbui"
|
||||||
|
|
||||||
// Cache previous values so we don't update the URL more than necessary
|
// Cache previous values so we don't update the URL more than necessary
|
||||||
let previousType
|
let previousType
|
||||||
|
@ -196,7 +197,28 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if $selectedComponent != null}
|
{#if $selectedComponent != null}
|
||||||
<div class="components-pane">
|
<div
|
||||||
|
class="components-pane"
|
||||||
|
use:clickOutside={() => {
|
||||||
|
if ($store?.builderFocus) {
|
||||||
|
console.log($store?.builderFocus)
|
||||||
|
const otherSettings = $store?.builderFocus?.filter(field => {
|
||||||
|
return field.location !== "component_settings"
|
||||||
|
})
|
||||||
|
if (otherSettings.length) {
|
||||||
|
store.update(state => {
|
||||||
|
state.builderFocus = otherSettings
|
||||||
|
return state
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
store.update(state => {
|
||||||
|
delete state.builderFocus
|
||||||
|
return state
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
<PropertiesPanel />
|
<PropertiesPanel />
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -28,7 +28,23 @@
|
||||||
class="placeholder"
|
class="placeholder"
|
||||||
use:styleable={{ ...$component.styles, empty: true }}
|
use:styleable={{ ...$component.styles, empty: true }}
|
||||||
>
|
>
|
||||||
<Placeholder />
|
<Placeholder>
|
||||||
|
<div slot="content">
|
||||||
|
Add the <mark>URL</mark> and start updating your background image
|
||||||
|
<span
|
||||||
|
class="showMe spectrum-Link"
|
||||||
|
on:click={() => {
|
||||||
|
builderStore.actions.setFocus({
|
||||||
|
location: "component_settings",
|
||||||
|
key: "url",
|
||||||
|
target: $component.id,
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Show me
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</Placeholder>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,23 @@
|
||||||
class="placeholder"
|
class="placeholder"
|
||||||
use:styleable={{ ...$component.styles, empty: true }}
|
use:styleable={{ ...$component.styles, empty: true }}
|
||||||
>
|
>
|
||||||
<Placeholder />
|
<Placeholder>
|
||||||
|
<div slot="content">
|
||||||
|
Add the <mark>URL</mark> and start updating your image
|
||||||
|
<span
|
||||||
|
class="showMe spectrum-Link"
|
||||||
|
on:click={() => {
|
||||||
|
builderStore.actions.setFocus({
|
||||||
|
location: "component_settings",
|
||||||
|
key: "url",
|
||||||
|
target: $component.id,
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Show me
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</Placeholder>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<script>
|
<script>
|
||||||
import { getContext } from "svelte"
|
import { getContext } from "svelte"
|
||||||
|
import Placeholder from "./Placeholder.svelte"
|
||||||
|
|
||||||
const { linkable, styleable, builderStore } = getContext("sdk")
|
const { linkable, styleable, builderStore } = getContext("sdk")
|
||||||
const component = getContext("component")
|
const component = getContext("component")
|
||||||
|
@ -79,7 +80,35 @@
|
||||||
{componentText}
|
{componentText}
|
||||||
</div>
|
</div>
|
||||||
{:else if $builderStore.inBuilder || componentText}
|
{:else if $builderStore.inBuilder || componentText}
|
||||||
{#if externalLink || openInNewTab}
|
{#if !url && !text}
|
||||||
|
<div use:styleable={{ ...$component.styles, empty: true }}>
|
||||||
|
<Placeholder>
|
||||||
|
<div slot="content">
|
||||||
|
Add the <mark>URL</mark> and <mark>Text</mark> settings and start
|
||||||
|
using your link
|
||||||
|
<span
|
||||||
|
class="showMe spectrum-Link"
|
||||||
|
on:click={() => {
|
||||||
|
builderStore.actions.setFocus([
|
||||||
|
{
|
||||||
|
location: "component_settings",
|
||||||
|
key: "url",
|
||||||
|
target: $component.id,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
location: "component_settings",
|
||||||
|
key: "text",
|
||||||
|
target: $component.id,
|
||||||
|
},
|
||||||
|
])
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Show me
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</Placeholder>
|
||||||
|
</div>
|
||||||
|
{:else if externalLink || openInNewTab}
|
||||||
<a
|
<a
|
||||||
{target}
|
{target}
|
||||||
href={sanitizedUrl}
|
href={sanitizedUrl}
|
||||||
|
|
|
@ -14,6 +14,23 @@
|
||||||
{#if value}
|
{#if value}
|
||||||
<MarkdownViewer {value} {height} />
|
<MarkdownViewer {value} {height} />
|
||||||
{:else if $builderStore.inBuilder}
|
{:else if $builderStore.inBuilder}
|
||||||
<Placeholder />
|
<Placeholder>
|
||||||
|
<div slot="content">
|
||||||
|
Add some <mark>Markdown</mark> in the field setting to start using your
|
||||||
|
component
|
||||||
|
<span
|
||||||
|
class="showMe spectrum-Link"
|
||||||
|
on:click={() => {
|
||||||
|
builderStore.actions.setFocus({
|
||||||
|
location: "component_settings",
|
||||||
|
key: "value",
|
||||||
|
target: $component.id,
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Show me
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</Placeholder>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if $builderStore.inBuilder}
|
{#if $builderStore.inBuilder}
|
||||||
<div>
|
<div class="placeholder_wrap">
|
||||||
{#if !$$slots.content}
|
{#if !$$slots.content}
|
||||||
{text || $component.name || "Placeholder"}
|
{text || $component.name || "Placeholder"}
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -20,5 +20,18 @@
|
||||||
div {
|
div {
|
||||||
color: var(--spectrum-global-color-gray-600);
|
color: var(--spectrum-global-color-gray-600);
|
||||||
font-size: var(--font-size-s);
|
font-size: var(--font-size-s);
|
||||||
|
padding: var(--spacing-xs);
|
||||||
|
}
|
||||||
|
:global(div.placeholder_wrap mark) {
|
||||||
|
background-color: var(--spectrum-global-color-gray-400);
|
||||||
|
padding: 0px 2px;
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
|
:global(div.placeholder_wrap .showMe) {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
:global(div.placeholder_wrap .showMe:hover) {
|
||||||
|
text-decoration: underline;
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -13,7 +13,24 @@
|
||||||
<div use:chart={options} use:styleable={$component.styles} />
|
<div use:chart={options} use:styleable={$component.styles} />
|
||||||
{:else if $builderStore.inBuilder}
|
{:else if $builderStore.inBuilder}
|
||||||
<div use:styleable={$component.styles}>
|
<div use:styleable={$component.styles}>
|
||||||
<Placeholder text="Use the settings panel to build your chart" />
|
<Placeholder>
|
||||||
|
<div slot="content">
|
||||||
|
Use the settings panel to select a <mark>Provider</mark> and start
|
||||||
|
building your chart
|
||||||
|
<span
|
||||||
|
class="showMe spectrum-Link"
|
||||||
|
on:click={() => {
|
||||||
|
builderStore.actions.setFocus({
|
||||||
|
location: "component_settings",
|
||||||
|
key: "dataProvider",
|
||||||
|
target: $component.id,
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Show me
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</Placeholder>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,6 @@
|
||||||
palette,
|
palette,
|
||||||
horizontal
|
horizontal
|
||||||
) => {
|
) => {
|
||||||
console.log("new chart")
|
|
||||||
const allCols = [labelColumn, ...(valueColumns || [null])]
|
const allCols = [labelColumn, ...(valueColumns || [null])]
|
||||||
if (
|
if (
|
||||||
!dataProvider ||
|
!dataProvider ||
|
||||||
|
|
|
@ -3,10 +3,6 @@
|
||||||
import FieldGroupFallback from "./FieldGroupFallback.svelte"
|
import FieldGroupFallback from "./FieldGroupFallback.svelte"
|
||||||
import { getContext, onDestroy } from "svelte"
|
import { getContext, onDestroy } from "svelte"
|
||||||
|
|
||||||
const dispatchEvent = (type, data = {}) => {
|
|
||||||
window.parent.postMessage({ type, data })
|
|
||||||
}
|
|
||||||
|
|
||||||
export let label
|
export let label
|
||||||
export let field
|
export let field
|
||||||
export let fieldState
|
export let fieldState
|
||||||
|
@ -81,26 +77,24 @@
|
||||||
<Placeholder text="Form components need to be wrapped in a form" />
|
<Placeholder text="Form components need to be wrapped in a form" />
|
||||||
{:else if !fieldState}
|
{:else if !fieldState}
|
||||||
{#if $builderStore.inBuilder}
|
{#if $builderStore.inBuilder}
|
||||||
<div class="placeholder_wrap">
|
<Placeholder>
|
||||||
<Placeholder>
|
<div slot="content">
|
||||||
<div slot="content">
|
Add the <mark>Field</mark> setting to start using your
|
||||||
Add the <mark>Field</mark> setting to start using your
|
component
|
||||||
component
|
<span
|
||||||
<span
|
class="showMe spectrum-Link"
|
||||||
class="showMe"
|
on:click={() => {
|
||||||
on:click={() => {
|
builderStore.actions.setFocus({
|
||||||
dispatchEvent("builder-focus", {
|
location: "component_settings",
|
||||||
location: "component_settings",
|
key: "field",
|
||||||
key: "field",
|
target: $component.id,
|
||||||
target: $component.id,
|
})
|
||||||
})
|
}}
|
||||||
}}
|
>
|
||||||
>
|
Show me
|
||||||
Show me
|
</span>
|
||||||
</span>
|
</div>
|
||||||
</div>
|
</Placeholder>
|
||||||
</Placeholder>
|
|
||||||
</div>
|
|
||||||
{/if}
|
{/if}
|
||||||
{:else if schemaType && schemaType !== type && type !== "options"}
|
{:else if schemaType && schemaType !== type && type !== "options"}
|
||||||
<Placeholder
|
<Placeholder
|
||||||
|
@ -117,30 +111,16 @@
|
||||||
</FieldGroupFallback>
|
</FieldGroupFallback>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.placeholder_wrap mark {
|
|
||||||
background-color: var(--spectrum-global-color-gray-400);
|
|
||||||
padding: 0px 2px;
|
|
||||||
border-radius: 2px;
|
|
||||||
}
|
|
||||||
div.spectrum-Form-item .placeholder_wrap .showMe {
|
|
||||||
color: black;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
.showMe:hover {
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
label {
|
label {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
label.hidden {
|
label.hidden {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.spectrum-Form-itemField {
|
.spectrum-Form-itemField {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.error {
|
.error {
|
||||||
color: var(
|
color: var(
|
||||||
--spectrum-semantic-negative-color-default,
|
--spectrum-semantic-negative-color-default,
|
||||||
|
@ -149,7 +129,6 @@
|
||||||
font-size: var(--spectrum-global-dimension-font-size-75);
|
font-size: var(--spectrum-global-dimension-font-size-75);
|
||||||
margin-top: var(--spectrum-global-dimension-size-75);
|
margin-top: var(--spectrum-global-dimension-size-75);
|
||||||
}
|
}
|
||||||
|
|
||||||
.spectrum-FieldLabel--right,
|
.spectrum-FieldLabel--right,
|
||||||
.spectrum-FieldLabel--left {
|
.spectrum-FieldLabel--left {
|
||||||
padding-right: var(--spectrum-global-dimension-size-200);
|
padding-right: var(--spectrum-global-dimension-size-200);
|
||||||
|
|
|
@ -76,6 +76,9 @@ const createBuilderStore = () => {
|
||||||
}
|
}
|
||||||
store.update(state => ({ ...state, editMode: enabled }))
|
store.update(state => ({ ...state, editMode: enabled }))
|
||||||
},
|
},
|
||||||
|
setFocus: data => {
|
||||||
|
window.parent.postMessage({ type: "builder-focus", data })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
...store,
|
...store,
|
||||||
|
|
Loading…
Reference in New Issue