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

@libs-ui/components-buttons-sort

v0.2.352-3

Published

## Giới thiệu

Readme

Sort

Giới thiệu

@libs-ui/components-buttons-sort là một component Sort Button cho Angular, hiển thị hai biểu tượng sắp xếp tăng dần và giảm dần, hỗ trợ binding trạng thái và emit event khi thay đổi.

Tính năng

  • Hiển thị icon ascdesc với kích thước tuỳ chỉnh
  • Two-way binding cho chế độ sort (mode)
  • Tuỳ chọn fieldSort để gắn tên trường sắp xếp
  • Hỗ trợ disable toàn bộ sort hoặc riêng asc / desc
  • onlyEmit để chỉ emit sự kiện mà không tự thay đổi chế độ
  • Emit ISort bao gồm mode, modeNumber, fieldSort và hàm reset()

Cài đặt

npm install @libs-ui/components-buttons-sort

hoặc

yarn add @libs-ui/components-buttons-sort

Sử dụng

Inline Template

import { Component } from '@angular/core';
import { LibsUiComponentsButtonsSortComponent } from '@libs-ui/components-buttons-sort';
import { TYPE_SORT_TYPE } from '@libs-ui/components-buttons-sort';

@Component({
  selector: 'app-example',
  standalone: true,
  imports: [LibsUiComponentsButtonsSortComponent],
  template: `
    <libs_ui-components-buttons-sort
      [size]="20"
      [(mode)]="demoMode"
      [fieldSort]="'name'"
      (outChange)="onSort($event)"></libs_ui-components-buttons-sort>
  `,
})
export class ExampleComponent {
  demoMode: TYPE_SORT_TYPE = '';
  onSort(event: any) {
    console.log('Sorted:', event);
  }
}

File HTML riêng

import { Component } from '@angular/core';
import { LibsUiComponentsButtonsSortComponent } from '@libs-ui/components-buttons-sort';
import { TYPE_SORT_TYPE } from '@libs-ui/components-buttons-sort';

@Component({
  selector: 'app-example',
  standalone: true,
  imports: [LibsUiComponentsButtonsSortComponent],
  templateUrl: './example.component.html',
})
export class ExampleComponent {
  demoMode: TYPE_SORT_TYPE = '';
  onSort(event: any) {}
}
<libs_ui-components-buttons-sort
  [size]="20"
  [(mode)]="demoMode"
  [fieldSort]="'name'"
  (outChange)="onSort($event)"></libs_ui-components-buttons-sort>

Công nghệ sử dụng

  • Angular 18 với standalone components và Signals
  • Tailwind CSS 3.x (phong cách demo)

API Reference

Inputs

| Tên | Kiểu | Mặc định | Mô tả | | ----------- | ---------------- | -------- | ----------------------------------------------------- | | size | number | 10 | Độ lớn của icon sắp xếp (px). | | mode | TYPE_SORT_TYPE | '' | Thứ tự hiện tại ('asc', 'desc' hoặc không sắp xếp). | | fieldSort | string | '' | Trường dữ liệu dùng để sắp xếp. | | disable | boolean | false | Nếu true: tắt chức năng sắp xếp. | | disableAsc | boolean | false | Nếu true: vô hiệu hóa chế độ sắp xếp tăng dần. | | disableDesc | boolean | false | Nếu true: vô hiệu hóa chế độ sắp xếp giảm dần. | | onlyEmit | boolean | false | Nếu true: chỉ phát sự kiện, không tự thay đổi chế độ. |

Outputs

| Tên | Kiểu | Mô tả | | --------- | ------------------------ | ------------------------------------------------------- | | outChange | (event: ISort) => void | Trả về đối tượng ISort khi trạng thái sắp xếp thay đổi. |

Interfaces

ISort

export interface ISort {
  mode: TYPE_SORT_TYPE;
  modeNumber: 1 | 2;
  fieldSort: string;
  reset: () => void;
}

Mô tả:

  • mode: 'asc', 'desc' hoặc '' (không sắp xếp).
  • modeNumber: số tương ứng (1 = 'asc', 2 = 'desc').
  • fieldSort: tên trường dữ liệu dùng để sắp xếp.
  • reset(): hàm đặt lại về trạng thái không sắp xếp.

TYPE_SORT_TYPE

export type TYPE_SORT_TYPE = 'asc' | 'desc' | '';

Mô tả:

  • 'asc': sắp xếp tăng dần.
  • 'desc': sắp xếp giảm dần.
  • '': không sắp xếp.