Merge pull request #10819 from Budibase/budi-6945/display_indeterminate
Display indeterminate when few checkbox selected
This commit is contained in:
commit
d9b9d7bda2
|
@ -10,6 +10,7 @@
|
||||||
export let validate = null
|
export let validate = null
|
||||||
export let compress = false
|
export let compress = false
|
||||||
export let lighter = false
|
export let lighter = false
|
||||||
|
export let indeterminate = false
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
|
@ -34,7 +35,7 @@
|
||||||
on:click={onChange}
|
on:click={onChange}
|
||||||
>
|
>
|
||||||
<span>
|
<span>
|
||||||
<Checkbox {disabled} {value} />
|
<Checkbox {disabled} {value} {indeterminate} />
|
||||||
</span>
|
</span>
|
||||||
<div class="text">
|
<div class="text">
|
||||||
{#if text}
|
{#if text}
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
$: updateSelected(selectedBooleans)
|
$: updateSelected(selectedBooleans)
|
||||||
$: dispatch("change", selected)
|
$: dispatch("change", selected)
|
||||||
$: allSelected = selected?.length === options.length
|
$: allSelected = selected?.length === options.length
|
||||||
|
$: noneSelected = !selected?.length
|
||||||
|
|
||||||
function reset() {
|
function reset() {
|
||||||
return Array(options.length).fill(true)
|
return Array(options.length).fill(true)
|
||||||
|
@ -48,6 +49,7 @@
|
||||||
text={selectAllText}
|
text={selectAllText}
|
||||||
compress
|
compress
|
||||||
lighter
|
lighter
|
||||||
|
indeterminate={!allSelected && !noneSelected}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
export let text = null
|
export let text = null
|
||||||
export let disabled = false
|
export let disabled = false
|
||||||
export let size
|
export let size
|
||||||
|
export let indeterminate = false
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
const onChange = event => {
|
const onChange = event => {
|
||||||
|
@ -22,6 +23,7 @@
|
||||||
class="spectrum-Checkbox spectrum-Checkbox--emphasized {sizeClass}"
|
class="spectrum-Checkbox spectrum-Checkbox--emphasized {sizeClass}"
|
||||||
class:is-invalid={!!error}
|
class:is-invalid={!!error}
|
||||||
class:checked={value}
|
class:checked={value}
|
||||||
|
class:is-indeterminate={indeterminate}
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
checked={value}
|
checked={value}
|
||||||
|
|
Loading…
Reference in New Issue