forge-select 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +227 -0
- package/dist/index.cjs +753 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +132 -0
- package/dist/index.d.ts +132 -0
- package/dist/index.global.js +751 -0
- package/dist/index.global.js.map +1 -0
- package/dist/index.js +726 -0
- package/dist/index.js.map +1 -0
- package/package.json +63 -0
- package/styles/forge-select.css +253 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 KonexForge
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
# ForgeSelect
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/forge-select)
|
|
4
|
+
[](https://github.com/cmm-cmm/ForgeSelect/actions/workflows/ci.yml)
|
|
5
|
+
[](./LICENSE)
|
|
6
|
+
|
|
7
|
+
ยซA modern, lightweight, highly customizable replacement for Select2.ยป
|
|
8
|
+
|
|
9
|
+
ForgeSelect is a next-generation JavaScript select component built for modern web applications. It provides a clean API, powerful customization options, excellent performance, and accessibility while remaining framework-agnostic.
|
|
10
|
+
|
|
11
|
+
## Why ForgeSelect?
|
|
12
|
+
|
|
13
|
+
Select2 has served the community well for many years, but modern web development has evolved.
|
|
14
|
+
|
|
15
|
+
ForgeSelect is designed to provide:
|
|
16
|
+
|
|
17
|
+
- ๐ High performance
|
|
18
|
+
- ๐จ Fully customizable UI
|
|
19
|
+
- ๐ฑ Responsive and mobile-friendly
|
|
20
|
+
- โฟ Accessibility (ARIA) support
|
|
21
|
+
- ๐ Fast searching
|
|
22
|
+
- ๐ณ Nested option groups
|
|
23
|
+
- ๐ท๏ธ Single & multiple selection
|
|
24
|
+
- ๐งฉ Plugin architecture
|
|
25
|
+
- ๐ AJAX & remote data loading
|
|
26
|
+
- ๐ Dark mode support
|
|
27
|
+
- ๐ Internationalization (i18n)
|
|
28
|
+
- ๐ฆ Zero dependency
|
|
29
|
+
|
|
30
|
+
## Documentation
|
|
31
|
+
|
|
32
|
+
Browse the documentation website at **<https://cmm-cmm.github.io/ForgeSelect/docs/>**, or read the sources in [`docs/`](./docs/README.md):
|
|
33
|
+
|
|
34
|
+
- [API Reference](./docs/api-reference.md) โ constructor, options, methods, events
|
|
35
|
+
- [Examples](./docs/examples.md) โ copy-pasteable snippets for every feature and framework
|
|
36
|
+
- [Playground](./docs/playground.md) โ [live demo](https://cmm-cmm.github.io/ForgeSelect/demo/) on GitHub Pages
|
|
37
|
+
- [Migration from Select2](./docs/migration-from-select2.md) โ option/event/method mapping and a migration checklist
|
|
38
|
+
- [Benchmarks](./docs/benchmarks.md) โ performance methodology and results (planned)
|
|
39
|
+
- [Plugin Development Guide](./docs/plugin-development.md) โ write and register your own plugins
|
|
40
|
+
|
|
41
|
+
## Features
|
|
42
|
+
|
|
43
|
+
- Single Select
|
|
44
|
+
- Multiple Select
|
|
45
|
+
- Searchable Dropdown
|
|
46
|
+
- Async Data Source (AJAX with debounce)
|
|
47
|
+
- Rich Item Rendering (avatar + label + description, XSS-safe built-in fields)
|
|
48
|
+
- Virtual Scrolling (automatic for large lists, with per-option render caching)
|
|
49
|
+
- Custom Templates
|
|
50
|
+
- Tags Mode (create options from free text)
|
|
51
|
+
- Keyboard Navigation
|
|
52
|
+
- Disabled Options
|
|
53
|
+
- Option Groups
|
|
54
|
+
- Clear Selection
|
|
55
|
+
- Placeholder
|
|
56
|
+
- Custom Themes (CSS variables, dark mode included)
|
|
57
|
+
- Event System
|
|
58
|
+
- Plugin Architecture
|
|
59
|
+
- Internationalization (en/vi built in, custom string tables)
|
|
60
|
+
- TypeScript Support (written in strict TypeScript, ships `.d.ts`)
|
|
61
|
+
|
|
62
|
+
> Planned/in-progress capabilities โ Tree Select, Async Pagination, Drag & Drop Ordering, and React/Vue/Angular/Svelte wrappers โ are tracked in the [Roadmap](#roadmap) below and intentionally not listed above as shipped features.
|
|
63
|
+
|
|
64
|
+
## Installation
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
npm install forge-select
|
|
68
|
+
# or
|
|
69
|
+
yarn add forge-select
|
|
70
|
+
# or
|
|
71
|
+
pnpm add forge-select
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Quick Start
|
|
75
|
+
|
|
76
|
+
```html
|
|
77
|
+
<select id="country">
|
|
78
|
+
<option value="vn">Vietnam</option>
|
|
79
|
+
<option value="jp">Japan</option>
|
|
80
|
+
<option value="us">United States</option>
|
|
81
|
+
</select>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
```js
|
|
85
|
+
import ForgeSelect from "forge-select";
|
|
86
|
+
import "forge-select/styles.css";
|
|
87
|
+
|
|
88
|
+
new ForgeSelect("#country");
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Configuration
|
|
92
|
+
|
|
93
|
+
```js
|
|
94
|
+
const select = new ForgeSelect("#country", {
|
|
95
|
+
placeholder: "Select a country",
|
|
96
|
+
searchable: true,
|
|
97
|
+
multiple: false,
|
|
98
|
+
clearable: true,
|
|
99
|
+
allowCreate: false,
|
|
100
|
+
theme: "default"
|
|
101
|
+
});
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
See the [API Reference](./docs/api-reference.md) for all options, including `data`, `ajax`, `templateResult`, `templateSelection`, `virtualScroll`, `language`, and `plugins`.
|
|
105
|
+
|
|
106
|
+
## Events
|
|
107
|
+
|
|
108
|
+
```js
|
|
109
|
+
select.on("change", value => console.log(value));
|
|
110
|
+
select.on("open", () => {});
|
|
111
|
+
select.on("close", () => {});
|
|
112
|
+
select.on("search", query => console.log("searching:", query));
|
|
113
|
+
select.on("clear", () => {});
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Unsubscribe with `select.off(event, handler)`.
|
|
117
|
+
|
|
118
|
+
## Examples
|
|
119
|
+
|
|
120
|
+
```js
|
|
121
|
+
new ForgeSelect("#users", {
|
|
122
|
+
ajax: {
|
|
123
|
+
url: query => `/api/users?q=${encodeURIComponent(query)}`,
|
|
124
|
+
debounce: 300,
|
|
125
|
+
transform: response => response.items.map(u => ({ value: u.id, label: u.name }))
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
More copy-pasteable snippets (multi-select, tags, custom templates, virtual scrolling, React/Vue/Svelte) are in [`docs/examples.md`](./docs/examples.md).
|
|
131
|
+
|
|
132
|
+
## Playground
|
|
133
|
+
|
|
134
|
+
Write and run ForgeSelect code in the browser at **<https://cmm-cmm.github.io/ForgeSelect/playground/>** โ with presets for every major feature. A curated feature showcase also lives at **<https://cmm-cmm.github.io/ForgeSelect/demo/>**. See [`docs/playground.md`](./docs/playground.md) for details and local setup.
|
|
135
|
+
|
|
136
|
+
## API Reference
|
|
137
|
+
|
|
138
|
+
| Option | Type | Default | Description |
|
|
139
|
+
|---|---|---|---|
|
|
140
|
+
| `placeholder` | `string` | `""` | Text shown when nothing is selected |
|
|
141
|
+
| `searchable` | `boolean` | `true` | Show a search input in the dropdown |
|
|
142
|
+
| `multiple` | `boolean` | `false` | Allow selecting more than one option |
|
|
143
|
+
| `theme` | `string` | `"default"` | Named theme applied to the control |
|
|
144
|
+
|
|
145
|
+
Full constructor signature, all options, instance methods, and events are documented in [`docs/api-reference.md`](./docs/api-reference.md).
|
|
146
|
+
|
|
147
|
+
## Theming
|
|
148
|
+
|
|
149
|
+
Styling is driven entirely by CSS custom properties, and a dark theme ships out of the box:
|
|
150
|
+
|
|
151
|
+
```js
|
|
152
|
+
new ForgeSelect("#country", { theme: "dark" });
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
```css
|
|
156
|
+
.forge-select {
|
|
157
|
+
--fs-border-focus: #e11d48;
|
|
158
|
+
--fs-radius: 4px;
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Framework Support
|
|
163
|
+
|
|
164
|
+
- Vanilla JavaScript
|
|
165
|
+
- React
|
|
166
|
+
- Vue
|
|
167
|
+
- Angular
|
|
168
|
+
- Svelte
|
|
169
|
+
- Next.js
|
|
170
|
+
- Nuxt
|
|
171
|
+
- Astro
|
|
172
|
+
|
|
173
|
+
## Browser Support
|
|
174
|
+
|
|
175
|
+
- Chrome
|
|
176
|
+
- Edge
|
|
177
|
+
- Firefox
|
|
178
|
+
- Safari
|
|
179
|
+
- Mobile Browsers
|
|
180
|
+
|
|
181
|
+
## Migration from Select2
|
|
182
|
+
|
|
183
|
+
ForgeSelect is designed as a drop-in-concept replacement for Select2: no jQuery dependency, native accessibility, and a smaller API surface. A full option/event/method mapping table and a step-by-step migration checklist are available in [`docs/migration-from-select2.md`](./docs/migration-from-select2.md).
|
|
184
|
+
|
|
185
|
+
## Benchmarks
|
|
186
|
+
|
|
187
|
+
Performance benchmarking (bundle size, init time, search latency, virtual scroll performance) against Select2 is planned once the first release ships. Methodology and the results format are documented in [`docs/benchmarks.md`](./docs/benchmarks.md).
|
|
188
|
+
|
|
189
|
+
## Roadmap
|
|
190
|
+
|
|
191
|
+
- [ ] Tree Select
|
|
192
|
+
- [x] Virtualized List
|
|
193
|
+
- [ ] Async Pagination
|
|
194
|
+
- [ ] Drag & Drop Ordering
|
|
195
|
+
- [x] Theme Builder
|
|
196
|
+
- [x] CSS Variables
|
|
197
|
+
- [ ] React Component
|
|
198
|
+
- [ ] Vue Component
|
|
199
|
+
- [ ] Angular Component
|
|
200
|
+
- [ ] Svelte Component
|
|
201
|
+
|
|
202
|
+
## Plugin Development Guide
|
|
203
|
+
|
|
204
|
+
ForgeSelect uses a small plugin architecture (`onInit`, `onOpen`, `onClose`, `onDestroy` lifecycle hooks) so behavior can be extended without forking the core. See [`docs/plugin-development.md`](./docs/plugin-development.md) for the plugin interface and a complete example plugin.
|
|
205
|
+
|
|
206
|
+
## Development
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
npm install # install dev dependencies
|
|
210
|
+
npm test # run the vitest + jsdom test suite
|
|
211
|
+
npm run typecheck # strict TypeScript check
|
|
212
|
+
npm run build # build ESM + CJS + type declarations into dist/
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Source lives in `src/`, styles in `styles/forge-select.css`, and tests in `tests/`.
|
|
216
|
+
|
|
217
|
+
## Contributing
|
|
218
|
+
|
|
219
|
+
Contributions are welcome! See [CONTRIBUTING.md](./CONTRIBUTING.md) for the development setup, project layout, and PR guidelines. Release history lives in [CHANGELOG.md](./CHANGELOG.md), and security reports should follow [SECURITY.md](./SECURITY.md). This project follows a [Code of Conduct](./CODE_OF_CONDUCT.md); by participating you agree to abide by its terms.
|
|
220
|
+
|
|
221
|
+
## License
|
|
222
|
+
|
|
223
|
+
[MIT License](./LICENSE).
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
Built with โค๏ธ by KonexForge.
|