update env dropdown input to remove tags
This commit is contained in:
parent
da2c809a09
commit
8372b50de1
|
@ -3,8 +3,6 @@
|
||||||
import { createEventDispatcher, onMount } from "svelte"
|
import { createEventDispatcher, onMount } from "svelte"
|
||||||
import clickOutside from "../../Actions/click_outside"
|
import clickOutside from "../../Actions/click_outside"
|
||||||
import Divider from "../../Divider/Divider.svelte"
|
import Divider from "../../Divider/Divider.svelte"
|
||||||
import Tag from "../../Tags/Tag.svelte"
|
|
||||||
import Tags from "../../Tags/Tags.svelte"
|
|
||||||
|
|
||||||
export let value = null
|
export let value = null
|
||||||
export let placeholder = null
|
export let placeholder = null
|
||||||
|
@ -31,7 +29,7 @@
|
||||||
const STRIP_NAME_REGEX = /(?<=\.)(.*?)(?=\ })/g
|
const STRIP_NAME_REGEX = /(?<=\.)(.*?)(?=\ })/g
|
||||||
|
|
||||||
// Strips the name out of the value which is {{ env.Variable }} resulting in an array like ["Variable"]
|
// Strips the name out of the value which is {{ env.Variable }} resulting in an array like ["Variable"]
|
||||||
$: tags = String(value)?.match(STRIP_NAME_REGEX) || []
|
$: hbsValue = String(value)?.match(STRIP_NAME_REGEX) || []
|
||||||
|
|
||||||
const updateValue = newValue => {
|
const updateValue = newValue => {
|
||||||
if (readonly) {
|
if (readonly) {
|
||||||
|
@ -87,42 +85,46 @@
|
||||||
focus = autofocus
|
focus = autofocus
|
||||||
if (focus) field.focus()
|
if (focus) field.focus()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function removeVariable() {
|
||||||
|
updateValue("")
|
||||||
|
}
|
||||||
|
|
||||||
|
function openPopover() {
|
||||||
|
open = true
|
||||||
|
focus = true
|
||||||
|
iconFocused = true
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="spectrum-InputGroup">
|
<div class="spectrum-InputGroup">
|
||||||
<div class:is-focused={focus} class="spectrum-Textfield ">
|
<div
|
||||||
|
class:is-disabled={disabled || hbsValue.length}
|
||||||
|
class:is-focused={focus}
|
||||||
|
class="spectrum-Textfield "
|
||||||
|
>
|
||||||
<svg
|
<svg
|
||||||
|
class:close-color={hbsValue.length}
|
||||||
class:focused={iconFocused}
|
class:focused={iconFocused}
|
||||||
class="hoverable icon-position spectrum-Icon spectrum-Icon--sizeM spectrum-Textfield-validationIcon"
|
class="hoverable icon-position spectrum-Icon spectrum-Icon--sizeS spectrum-Textfield-validationIcon"
|
||||||
focusable="false"
|
focusable="false"
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
open = true
|
hbsValue.length ? removeVariable() : openPopover()
|
||||||
focus = true
|
|
||||||
iconFocused = true
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<use xlink:href="#spectrum-icon-18-Key" />
|
<use
|
||||||
|
xlink:href={`#spectrum-icon-18-${!hbsValue.length ? "Key" : "Close"}`}
|
||||||
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
<Tags>
|
|
||||||
<div class="tags">
|
|
||||||
<div class="tag">
|
|
||||||
{#each tags as tag}
|
|
||||||
<Tag closable on:click={() => updateValue("")}>
|
|
||||||
{tag}
|
|
||||||
</Tag>
|
|
||||||
{/each}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Tags>
|
|
||||||
|
|
||||||
<input
|
<input
|
||||||
bind:this={field}
|
bind:this={field}
|
||||||
{disabled}
|
disabled={false}
|
||||||
{readonly}
|
{readonly}
|
||||||
{id}
|
id={"thisOne"}
|
||||||
data-cy={dataCy}
|
data-cy={dataCy}
|
||||||
value={!tags.length ? value : ""}
|
value={hbsValue.length ? `{{ ${hbsValue[0]} }}` : value}
|
||||||
placeholder={placeholder || ""}
|
placeholder={placeholder || ""}
|
||||||
on:click
|
on:click
|
||||||
on:blur
|
on:blur
|
||||||
|
@ -133,8 +135,8 @@
|
||||||
on:focus={onFocus}
|
on:focus={onFocus}
|
||||||
on:input={onInput}
|
on:input={onInput}
|
||||||
{type}
|
{type}
|
||||||
|
style="color: white !important;"
|
||||||
class="spectrum-Textfield-input"
|
class="spectrum-Textfield-input"
|
||||||
style={align ? `text-align: ${align};` : ""}
|
|
||||||
inputmode={type === "number" ? "decimal" : "text"}
|
inputmode={type === "number" ? "decimal" : "text"}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -220,7 +222,7 @@
|
||||||
|
|
||||||
.icon-position {
|
.icon-position {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 20%;
|
top: 25%;
|
||||||
right: 2%;
|
right: 2%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,9 +277,11 @@
|
||||||
background: var(--grey-1);
|
background: var(--grey-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
.tags {
|
.close-color {
|
||||||
position: absolute;
|
color: var(--spectrum-global-color-gray-900) !important;
|
||||||
bottom: 12%;
|
}
|
||||||
left: 1px;
|
|
||||||
|
.close-color:hover {
|
||||||
|
color: var(--spectrum-global-color-blue-400) !important;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -87,7 +87,6 @@
|
||||||
|
|
||||||
function showModal(configKey) {
|
function showModal(configKey) {
|
||||||
selectedKey = configKey
|
selectedKey = configKey
|
||||||
console.log(selectedKey)
|
|
||||||
createVariableModal.show()
|
createVariableModal.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,8 +102,6 @@
|
||||||
await licensing.init()
|
await licensing.init()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
$: console.log(config)
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<form>
|
<form>
|
||||||
|
|
|
@ -122,7 +122,6 @@
|
||||||
|
|
||||||
// Adds a data binding to the expression
|
// Adds a data binding to the expression
|
||||||
const addBinding = (binding, { forceJS } = {}) => {
|
const addBinding = (binding, { forceJS } = {}) => {
|
||||||
console.log(binding)
|
|
||||||
if (usingJS || forceJS) {
|
if (usingJS || forceJS) {
|
||||||
let js = decodeJSBinding(jsValue)
|
let js = decodeJSBinding(jsValue)
|
||||||
js = addJSBinding(js, getCaretPosition(), binding.readableBinding)
|
js = addJSBinding(js, getCaretPosition(), binding.readableBinding)
|
||||||
|
|
Loading…
Reference in New Issue