-
-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat/input-chip-add-remove-manually (#2347)
- Loading branch information
1 parent
3ff56db
commit 69b6825
Showing
3 changed files
with
125 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@skeletonlabs/skeleton": minor | ||
--- | ||
|
||
feat: InputChip - Implemented function to add/remove chips programatically. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,8 @@ | |
let emails = ['[email protected]', '[email protected]', '[email protected]']; | ||
let musicalGenres = ['rock', 'r&b', 'pop']; | ||
let musicalGenresWhitelist = ['rock', 'pop', 'hip-hop', 'metal', 'techno', 'r&b']; | ||
let manualList: string[] = []; | ||
let manualInputChip: InputChip; | ||
const toastStore = getToastStore(); | ||
function isValidEmail(value: string): boolean { | ||
|
@@ -161,6 +163,50 @@ function onInvalidHandler(event: any): void { | |
</svelte:fragment> | ||
</DocsPreview> | ||
</section> | ||
<!-- Add/Remove Chips Programatically --> | ||
<section class="space-y-4"> | ||
<h2 class="h2">Add / Remove Chips</h2> | ||
<p> | ||
To add or remove chips programatically, use the exported functions <code class="code">addChip</code> and | ||
<code class="code">removeChip</code> after binding the ChipInput. | ||
</p> | ||
<DocsPreview background="neutral"> | ||
<svelte:fragment slot="preview"> | ||
<InputChip | ||
bind:this={manualInputChip} | ||
bind:value={manualList} | ||
name="chips-example-programatic" | ||
placeholder="Enter number..." | ||
chips="variant-filled-tertiary" | ||
/> | ||
</svelte:fragment> | ||
<svelte:fragment slot="footer"> | ||
<div class="text-center"> | ||
<button type="button" class="btn variant-filled" on:click={() => manualInputChip.removeChip(manualList[-1])} | ||
>Remove LastChip</button | ||
> | ||
<button | ||
type="button" | ||
class="btn variant-filled" | ||
on:click={() => manualInputChip.addChip((Math.floor(Math.random() * 10000) + 1).toString())}>Add Random Number</button | ||
> | ||
</div> | ||
</svelte:fragment> | ||
<svelte:fragment slot="source"> | ||
<CodeBlock | ||
language="ts" | ||
code={` | ||
let inputChip: InputChip; | ||
// add chip manually | ||
inputChip.addChip('chipValue'); | ||
// remove chip manually | ||
inputChip.removeChip('chipValue'); | ||
`} | ||
/> | ||
<CodeBlock language="html" code={`<InputChip ... bind:this={inputChip} />`} /> | ||
</svelte:fragment> | ||
</DocsPreview> | ||
</section> | ||
<!-- Additional Settings --> | ||
<section class="space-y-4"> | ||
<h2 class="h2">Additional Settings</h2> | ||
|