npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

jackui-multi-select

v0.0.991

Published

This project contains an Angular `JackuiMultiSelect` that allows users to select multiple items from a dropdown list. It is designed to be flexible and integrate seamlessly with both template-driven and reactive forms.

Readme

JackuiMultiSelect Component

This project contains an Angular JackuiMultiSelect that allows users to select multiple items from a dropdown list. It is designed to be flexible and integrate seamlessly with both template-driven and reactive forms.

Purpose

The JackuiMultiSelect provides a reusable UI element for scenarios where users need to select one or more options from a predefined list. It handles selection logic, displays selected items, and integrates with Angular's form system.

Installation

This component is part of this Angular project. To use it in your application, ensure it's imported into the module or standalone component where it's being used.

// In your component or module
import { JackuiMultiSelect } from '@jack-ui/jackui-multi-select';

@Component({
  // ...
  standalone: true,
  imports: [JackuiMultiSelect],
  // ...
})
export class YourComponent {
  // ...
}

Dependencies

  • @angular/core
  • @angular/forms
  • clsx (for conditional CSS class names)

Inputs

The JackuiMultiSelect accepts the following inputs:

| Name | Type | Default | Description | | :----------------- | :-------------------- | :---------------- | :----------------------------------------------------------------------- | | items | MultiSelectItem[] \| null \| undefined | undefined | The array of items to display in the dropdown. Each item must have an id (number) and name (string). If null or undefined, the component will be disabled and display "No value". | | placeholder | string | 'Select items...' | The text shown when no items are selected. | | variant | 'default' \| 'outline' \| 'secondary' \| 'destructive' | 'default' | The visual style of the select button. | | position | 'top' \| 'bottom' | 'bottom' | The position of the dropdown relative to the select button. | | closeOnSelect | boolean | true | If true, the dropdown closes after an item is selected or unselected. | | maxDisplaySelected | number | 2 | The maximum number of selected item values to display before showing a summary (e.g., "3 items selected"). |

| disabled | boolean | false | If true, the multi-select component will be disabled. |

MultiSelectItem Interface

export interface MultiSelectItem {
  id: number;
  name: string;
}

Outputs

The component does not have explicit @Output() events. It integrates with Angular forms using ControlValueAccessor to emit changes via ngModel or formControl.

Usage Examples

Template-Driven Forms

<form #multiSelectForm="ngForm">
  <jui-multi-select
    name="myItems"
    [(ngModel)]="selectedItemsTemplate"
    [items]="availableItems"
    placeholder="Choose your items"
    [closeOnSelect]="false"
  ></app-multi-select>
  <p>Selected in Template-Driven: {{ selectedItemsTemplate | json }}</p>
</form>
// In your component.ts
import { Component } from '@angular/core';
import { JackuiMultiSelect, MultiSelectItem } from '@jack-ui/jackui-multi-select';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';

@Component({
  selector: 'app-root',
  standalone: true,
  imports: [CommonModule, FormsModule, JackuiMultiSelect],
  templateUrl: './app.html',
  styleUrls: ['./app.css'],
})
export class AppComponent {
  availableItems: MultiSelectItem[] = [
    { id: 1, name: 'Option A' },
    { id: 2, name: 'Option B' },
    { id: 3, name: 'Option C' },
    { id: 4, name: 'Option D' },
  ];
}

Reactive Forms

<form [formGroup]="multiSelectReactiveForm">
  <jui-multi-select
    formControlName="reactiveItems"
    [items]="availableItems"
    placeholder="Select items (Reactive)"
    variant="filled"
  ></app-multi-select>
  <p>Selected in Reactive Forms: {{ multiSelectReactiveForm.get('reactiveItems')?.value | json }}</p>
</form>
// In your component.ts
import { Component, OnInit } from '@angular/core';
import { JackuiMultiSelect, MultiSelectItem } from '@jack-ui/jackui-multi-select';
import { CommonModule } from '@angular/common';
import { FormGroup, FormControl, ReactiveFormsModule } from '@angular/forms';

@Component({
  selector: 'app-root',
  standalone: true,
  imports: [CommonModule, ReactiveFormsModule, JackuiMultiSelect],
  templateUrl: './app.html',
  styleUrls: ['./app.css'],
})
export class AppComponent implements OnInit {
  availableItems: MultiSelectItem[] = [
    { id: 1, name: 'Option A' },
    { id: 2, name: 'Option B' },
    { id: 3, name: 'Option C' },
    { id: 4, name: 'Option D' },
  ];

  multiSelectReactiveForm!: FormGroup;

  ngOnInit(): void {
    this.multiSelectReactiveForm = new FormGroup({
      reactiveItems: new FormControl<MultiSelectItem[]>([
        { id: 1, name: 'Option A' },
      ]),
    });
  }
}

Handling null or undefined Items

If the items input is null or undefined, the multi-select component will be disabled and will display "No value". This is useful for scenarios where the item list is loaded asynchronously.

<jui-multi-select [items]="null"></app-multi-select>

This will render a disabled select input with the text "No value".

Error State

To indicate an error, you can use the error variant. This will apply a red border to the component.

<jui-multi-select
  [items]="availableItems"
  variant="error"
  placeholder="This field has an error"
></app-multi-select>

Dropdown Position

You can control the dropdown's opening direction using the position input. By default, it opens to the bottom.

<jui-multi-select
  [items]="availableItems"
  position="top"
  placeholder="Dropdown opens upwards"
></app-multi-select>