@liwe3/webcomponents-svelte
v1.1.0
Published
Svelte 5 wrappers for @liwe3/webcomponents
Maintainers
Readme
@liwe3/webcomponents-svelte
Svelte 5 wrappers for @liwe3/webcomponents.
Installation
npm install @liwe3/webcomponents @liwe3/webcomponents-svelte
# or
pnpm add @liwe3/webcomponents @liwe3/webcomponents-svelte
# or
yarn add @liwe3/webcomponents @liwe3/webcomponents-svelteUsage
SmartSelect
<script>
import { SmartSelect } from '@liwe3/webcomponents-svelte';
let selectedValue = $state();
const options = [
{ value: 'js', label: 'JavaScript' },
{ value: 'ts', label: 'TypeScript' },
{ value: 'py', label: 'Python' }
];
const handleChange = (newValue) => {
console.log('Selected:', newValue);
};
</script>
<SmartSelect
bind:value={selectedValue}
{options}
searchable
placeholder="Select a language"
onchange={handleChange}
/>AITextEditor
<script>
import { AITextEditor } from '@liwe3/webcomponents-svelte';
let content = $state('');
let systemPrompt = $state("You are a helpful writing assistant.");
const handleChange = (newValue) => {
console.log('Content changed:', newValue);
};
</script>
<AITextEditor
bind:value={content}
bind:systemPrompt
apiKey="your-api-key"
apiEndpoint="https://api.openai.com/v1/chat/completions"
modelName="gpt-3.5-turbo"
placeholder="Start writing..."
onchange={handleChange}
style="width: 100%; height: 400px;"
/>Features
- Full Svelte 5 Support: Uses Svelte 5 runes (
$state,$bindable,$effect) - TypeScript: Full type safety
- Reactive: All props are reactive and two-way bindable where appropriate
- SSR Safe: Components are loaded dynamically to prevent SSR issues
Components
SmartSelect Props
multiple(boolean): Enable multi-select modesearchable(boolean): Enable search functionalityplaceholder(string): Placeholder textdisabled(boolean): Disable the selectvalue(string | string[], bindable): Selected value(s)options(SelectOption[]): Array of{value, label}objectsonchange(function): Change event handleronopen(function): Open event handleronclose(function): Close event handleronsearch(function): Search event handler
AITextEditor Props
value(string, bindable): Editor contentapiKey(string): API key for AI servicesuggestionDelay(number): Delay before showing suggestions (ms)systemPrompt(string, bindable): System prompt for AIapiEndpoint(string): API endpoint URLmodelName(string): Model name to useplaceholder(string): Placeholder textonbeforesuggestion(function): Called before requesting suggestiononchange(function): Change event handler
License
MIT
