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 🙏

© 2024 – Pkg Stats / Ryan Hefner

thai-address-autocomplete-react

v1.1.3

Published

[![NPM](https://img.shields.io/npm/v/thai-address-autocomplete-react)](https://www.npmjs.com/package/thai-address-autocomplete-react) [![NPM](https://img.shields.io/badge/Watsize-Library-289548)](https://www.npmjs.com/package/thai-address-autocomplete-rea

Downloads

489

Readme

thai-address-autocomplete-react

NPM NPM Downloads

🎉 RELEASE v1 🎉

Get back to active!. I hope this library will be useful for all you guy. Welcome all PR as always. Thanks.

📘 About

thai-address-autocomplete-react is an input component for ReactJS that can auto-complete Thai addresses with magic by just typing something. Anyway I hope this component will be a useful thing to you. :D Happy Coding.

⚙ Install

npm install thai-address-autocomplete-react
# or just `yarn add thai-address-autocomplete-react`

📌 Example Usage

import { useState } from "react";
import { Address, CreateInput } from "thai-address-autocomplete-react";

const InputThaiAddress = CreateInput();

const App = () => {
  const [address, setAddress] = useState<Address>({
    district: "", // ตำบล tambol
    amphoe: "", // อำเภอ amphoe
    province: "", // จังหวัด changwat
    zipcode: "", // รหัสไปรษณีย์ postal code
  });

  const handleChange = (scope: string) => (value: string) => {
    setAddress((oldAddr: Address) => ({
      ...oldAddr,
      [scope]: value,
    }));
  };

  const handleSelect = (address: Address) => {
    setAddress(address);
  };

  return (
    <div>
      <label>ตำบล</label>
      <InputThaiAddress.District
        value={address["district"]}
        onChange={handleChange("district")}
        onSelect={handleSelect}
      />
      <label>อำเภอ</label>
      <InputThaiAddress.Amphoe
        value={address["amphoe"]}
        onChange={handleChange("amphoe")}
        onSelect={handleSelect}
      />
      <label>จังหวัด</label>
      <InputThaiAddress.Province
        value={address["province"]}
        onChange={handleChange("province")}
        onSelect={handleSelect}
      />
      <label>รหัสไปรษณีย์</label>
      <InputThaiAddress.Zipcode
        value={address["zipcode"]}
        onChange={handleChange("zipcode")}
        onSelect={handleSelect}
      />
    </div>
  );
};

export default App;

📋 Properties

Label description

| Data label | Data field name | |------------|-----------------| | ตำบล/แขวง | district | | อำเภอ/เขต | amphoe | | จังหวัด | province | | รหัสไปรษณีย์ | zipcode |

Component properties

| Property | Description | Type | Default | |-----------------------|-------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------|-------------| | scope | field name from record. Possible value will be "district", "amphoe", "province", and "zipcode". | string | "province" | | delimiter | delimiter between scope values, which will show inside options in the autocomplete. | string | ", " | | value | value by scope. | string | "" | | filter | array filter function, used for fine grain result of options or fixed something on the result. | (value?: Address, index?: number, array?: Address[]) => boolean | () => true | | onChange | function callback, trigger on input changes. | (value: string) => void | () => null | | onSelect | function callback, trigger on select the option. | (address: Address) => void | () => null | | style | "Fashions fade, style is eternal." — Yves Saint Laurent | CSS.Properties | {} | | className | css class...name. | string | "" | | autoCompleteProps | the override properties of AutoComplete: check out https://ant.design/components/auto-complete#api. | AutoCompleteProps | {} |

Data record (also named Address)

the data record can be found onSelect.

interface Address {
  district: string;
  amphoe: string;
  province: string;
  zipcode: number;
}

📝 Need More Example?

🙋 FAQ?

FAQ 1: Can I use custom database ?

Yes, but to use custom database (in this version). It supports only JSON format file that output from Database Tools by earthchie.

// 1. import json
import customDB from "./database/db.json";

// 2. used by put in the configuration before initialize component
const InputCustom = CreateInput({ database: customDB });

FAQ 2: I want to ask you more.

I provide a simple document on ./docs to describe how to use this library.

But if you're not found what you want to know, please feel free to create an issue on GitHub. I would love to answer all of the questions, and I am also welcome for all the PR. ❤️

𝌡 Changelog

Please see more CHANGELOG.md

License

MIT © buildingwatsize

⚒ Thanks a lot