Add caret position function to text area and fix issue with design transitions and custom styles
This commit is contained in:
parent
36b1cd75fd
commit
1bc678ad9e
|
@ -7,8 +7,13 @@
|
||||||
export let disabled = false
|
export let disabled = false
|
||||||
export let error = null
|
export let error = null
|
||||||
export let id = null
|
export let id = null
|
||||||
|
export const getCaretPosition = () => ({
|
||||||
|
start: textarea.selectionStart,
|
||||||
|
end: textarea.selectionEnd,
|
||||||
|
})
|
||||||
|
|
||||||
let focus = false
|
let focus = false
|
||||||
|
let textarea
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
const onChange = event => {
|
const onChange = event => {
|
||||||
dispatch("change", event.target.value)
|
dispatch("change", event.target.value)
|
||||||
|
@ -30,6 +35,7 @@
|
||||||
</svg>
|
</svg>
|
||||||
{/if}
|
{/if}
|
||||||
<textarea
|
<textarea
|
||||||
|
bind:this={textarea}
|
||||||
placeholder={placeholder || ''}
|
placeholder={placeholder || ''}
|
||||||
class="spectrum-Textfield-input"
|
class="spectrum-Textfield-input"
|
||||||
{disabled}
|
{disabled}
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
export let placeholder = null
|
export let placeholder = null
|
||||||
export let disabled = false
|
export let disabled = false
|
||||||
export let error = null
|
export let error = null
|
||||||
|
export let getCaretPosition = null
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
const onChange = e => {
|
const onChange = e => {
|
||||||
|
@ -18,5 +19,11 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Field {label} {labelPosition} {disabled} {error}>
|
<Field {label} {labelPosition} {disabled} {error}>
|
||||||
<TextArea {error} {disabled} {value} {placeholder} on:change={onChange} />
|
<TextArea
|
||||||
|
bind:getCaretPosition
|
||||||
|
{error}
|
||||||
|
{disabled}
|
||||||
|
{value}
|
||||||
|
{placeholder}
|
||||||
|
on:change={onChange} />
|
||||||
</Field>
|
</Field>
|
||||||
|
|
|
@ -63,7 +63,7 @@
|
||||||
<div class="custom-styles">
|
<div class="custom-styles">
|
||||||
<TextArea
|
<TextArea
|
||||||
value={componentInstance._styles.custom}
|
value={componentInstance._styles.custom}
|
||||||
on:change={event => onCustomStyleChanged(event.target.value)}
|
on:change={event => onCustomStyleChanged(event.detail)}
|
||||||
placeholder="Enter some CSS..." />
|
placeholder="Enter some CSS..." />
|
||||||
</div>
|
</div>
|
||||||
</DetailSummary>
|
</DetailSummary>
|
||||||
|
@ -79,15 +79,11 @@
|
||||||
<div class="transitions">
|
<div class="transitions">
|
||||||
<Select
|
<Select
|
||||||
value={componentInstance._transition}
|
value={componentInstance._transition}
|
||||||
on:change={event => onUpdateTransition(event.target.value)}
|
on:change={event => onUpdateTransition(event.detail)}
|
||||||
name="transition"
|
name="transition"
|
||||||
label="Transition"
|
label="Transition"
|
||||||
secondary
|
options={transitions}
|
||||||
thin>
|
getOptionLabel={capitalize} />
|
||||||
{#each transitions as transition}
|
|
||||||
<option value={transition}>{capitalize(transition)}</option>
|
|
||||||
{/each}
|
|
||||||
</Select>
|
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue