1.0.9 • Published 2 years ago

svelte-indeterminate-checkbox v1.0.9

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Svelte Indeterminable Checkbox

License

Simple checkbox component with "indeterminate" status support.

Installation

You can install this package with npm or yarn

npm install svelte-indeterminate-checkbox
yarn add svelte-indeterminate-checkbox

Usage

<script>
import Checkbox from 'svelte-indeterminate-checkbox';

let checkboxStatus = 'x';

function handleClick(e) {
    switch (checkboxStatus) {
        case 'v':
            checkboxStatus = '-';
        break;
        case '-':
            checkboxStatus = 'x';
            break;
        case 'x':
            checkboxStatus = 'v';
    }
}
</script>

<Checkbox id="myCheckbox" name="myCheckbox" status={checkboxStatus} on:click={handleClick} />

Props

NameValue
idThe checkbox \<input> id
nameThe checkbox input name
statusString, '-' means indeterminate, 'x' means unchecked, 'y' means checked

Events

EventNote
clickClick Event

Note: Should not call e.preventDefault() inside the click handler because it will prevent the checkbox to change its value, this relates to the browser implementation and HTML Spec, (learn more)https://stackoverflow.com/questions/30426523/why-does-preventdefault-on-checkbox-click-event-returns-true-for-the-checked-att

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago