🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

-isoftdata-svelte-select

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

-isoftdata-svelte-select

## Install

unpublished
latest
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

Svelte Select

Install

npm i @isoftdata/svelte-select

Props

NameTypeDescriptionDefault
classstringAny additional classes to apply to the <select>.""
disabledbooleanWhether the select component is disabled or not.false
emptyTextstringThe label for the empty option.-- Select {label} --
emptyValueT | nullThe value of the empty option.null
hintstringThe hint text to be displayed below the select component.""
hintClassstringThe class name to be applied to the hint text.""
hintClickablebooleanWhether the hint text is clickable or not.false
idstringThe id to be applied to the select component."id" + uuid()
isLoadingbooleanWhether to show the Label's loading icon.false
labelstring | nullThe label text to be displayed above the select component.null
labelClassstringThe class name to be applied to the label text.""
namestringThe name to be applied to the select component.""
optionsArray<T>The options to be displayed in the select component. See "Specifying Options" for details.[]
requiredbooleanWhether the select component is required or not.false
showEmptyOptionbooleanWhether to show an "empty" option.true
showLabelbooleanWhether to show the label text or not.true
size"" | "sm" | "lg"The size of the select component."sm"
textEllipsisbooleanWhether to apply text ellipsis to the select component or not.false
titlestringThe title to be applied to the select component.""
valueT | T[keyof T] | nullThe value of the select component. Svelte allows this to be any type, including an Object.None (Required)

Slots

  • default - Any options you want to apply to the component.
    • If you pass the options prop to the component, this slot will be rendered once per entry of the options array.
    • This slot has a prop, option whose type is T | undefined. It will be T when options is specified, and undefined when it is not.
    • See "Specifying Options" below for more details.
  • append - Any content you want to append to the input.
  • prepend - Any content you want to prepend to the input

Specifying Options

By default, the default slot will just insert its contents into the select's inner HTML.

Options can be specified three ways:

  • Pass any options to the default slot, and do not pass an options prop. (Manual Options in Example)
  • Pass an array to the options prop, and do not pass anything into the default slot. The values of options will be used as both the value and label for each option. (Auto Options in Example)
  • Pass an array to thye options prop, add a let:{option} prop to the Select, and pass a single option in the default slot, which can reference values from option. (Semi Auto Options in Example)

Events

  • change - Fired when the selected value changes

Example

<script lang="ts">
	import Select from "@isoftdata/svelte-select"

	let selectValue: number | null = null
	let selectValue2: string = ""
	let selectValue3: number | null = null
	let selectValue4: { id: number; label: string } | null = null

	const objectOptions = [
		{ id: 1, label: "One" },
		{ id: 2, label: "Two" },
		{ id: 3, label: "Three" },
	]
	const stringOptions = ["One", "Two", "Three"]
</script>

<div class="container">
	<h1>Select</h1>

	<div class="row">
		<div class="col-3">
			<Select
				label="Manual Options"
				bind:value={selectValue}
			>
				{#each objectOptions as option}
					<option value={option.id}>{option.label}</option>
				{/each}
			</Select>
		</div>
		<div class="col-3">
			<Select
				label="Auto Options"
				bind:value={selectValue2}
				options={stringOptions}
				emptyValue=""
			/>
		</div>
		<div class="col-3">
			<Select
				label="Semi Auto Options"
				options={objectOptions}
				bind:value={selectValue3}
				let:option
			>
				<option value={option?.id}>{option?.label}</option>
			</Select>
		</div>
		<div class="col-3">
			<Select
				label="Object Key"
				bind:value={selectValue4}
			>
				{#each objectOptions as option}
					<option value={option}>{option.label}</option>
				{/each}
			</Select>
		</div>
	</div>
</div>

FAQs

Package last updated on 14 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts