forge-select 0.2.0 → 0.4.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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # ForgeSelect
1
+ # Forge Select
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/forge-select.svg)](https://www.npmjs.com/package/forge-select)
4
4
  [![CI](https://github.com/cmm-cmm/ForgeSelect/actions/workflows/ci.yml/badge.svg)](https://github.com/cmm-cmm/ForgeSelect/actions/workflows/ci.yml)
@@ -6,13 +6,13 @@
6
6
 
7
7
  «A modern, lightweight, highly customizable replacement for Select2.»
8
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.
9
+ Forge Select 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
10
 
11
- ## Why ForgeSelect?
11
+ ## Why Forge Select?
12
12
 
13
13
  Select2 has served the community well for many years, but modern web development has evolved.
14
14
 
15
- ForgeSelect is designed to provide:
15
+ Forge Select is designed to provide:
16
16
 
17
17
  - 🚀 High performance
18
18
  - 🎨 Fully customizable UI
@@ -29,13 +29,13 @@ ForgeSelect is designed to provide:
29
29
 
30
30
  ## Documentation
31
31
 
32
- Browse the documentation website at **<https://cmm-cmm.github.io/ForgeSelect/docs/>**, or read the sources in [`docs/`](./docs/README.md):
32
+ Browse the documentation website at **<https://forgeselect.konexforge.com/docs/>**, or read the sources in [`docs/`](./docs/README.md):
33
33
 
34
34
  - [API Reference](./docs/api-reference.md) — constructor, options, methods, events
35
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
36
+ - [Playground](./docs/playground.md) — [live demo](https://forgeselect.konexforge.com/demo/)
37
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)
38
+ - [Benchmarks](./docs/benchmarks.md) — reproducible bundle, initialization, search, and scrolling baseline
39
39
  - [Plugin Development Guide](./docs/plugin-development.md) — write and register your own plugins
40
40
 
41
41
  ## Features
@@ -52,6 +52,7 @@ Browse the documentation website at **<https://cmm-cmm.github.io/ForgeSelect/doc
52
52
  - Disabled Options
53
53
  - Option Groups
54
54
  - Tree Select (nested options with expand/collapse and cascading multi-select)
55
+ - Drag & Drop Tag Ordering (reorder a multi-select's selected tags by mouse/touch/pen, or Alt+Left/Alt+Right on keyboard)
55
56
  - Clear Selection
56
57
  - Placeholder
57
58
  - Custom Themes (CSS variables, dark mode included)
@@ -60,7 +61,7 @@ Browse the documentation website at **<https://cmm-cmm.github.io/ForgeSelect/doc
60
61
  - Internationalization (en/vi built in, custom string tables)
61
62
  - TypeScript Support (written in strict TypeScript, ships `.d.ts`)
62
63
 
63
- > Planned/in-progress capabilities — Drag & Drop Ordering and Angular/Svelte wrappers — are tracked in the [Roadmap](#roadmap) below and intentionally not listed above as shipped features.
64
+ > Planned/in-progress capabilities — Angular/Svelte wrappers — are tracked in the [Roadmap](#roadmap) below and intentionally not listed above as shipped features.
64
65
 
65
66
  ## Installation
66
67
 
@@ -76,9 +77,9 @@ pnpm add forge-select
76
77
 
77
78
  ```html
78
79
  <select id="country">
79
- <option value="vn">Vietnam</option>
80
- <option value="jp">Japan</option>
81
- <option value="us">United States</option>
80
+ <option value="vn">Vietnam</option>
81
+ <option value="jp">Japan</option>
82
+ <option value="us">United States</option>
82
83
  </select>
83
84
  ```
84
85
 
@@ -93,12 +94,12 @@ new ForgeSelect("#country");
93
94
 
94
95
  ```js
95
96
  const select = new ForgeSelect("#country", {
96
- placeholder: "Select a country",
97
- searchable: true,
98
- multiple: false,
99
- clearable: true,
100
- allowCreate: false,
101
- theme: "default"
97
+ placeholder: "Select a country",
98
+ searchable: true,
99
+ multiple: false,
100
+ clearable: true,
101
+ allowCreate: false,
102
+ theme: "default",
102
103
  });
103
104
  ```
104
105
 
@@ -107,24 +108,27 @@ See the [API Reference](./docs/api-reference.md) for all options, including `dat
107
108
  ## Events
108
109
 
109
110
  ```js
110
- select.on("change", value => console.log(value));
111
+ select.on("change", (value) => console.log(value));
111
112
  select.on("open", () => {});
112
113
  select.on("close", () => {});
113
- select.on("search", query => console.log("searching:", query));
114
+ select.on("search", (query) => console.log("searching:", query));
114
115
  select.on("clear", () => {});
116
+ select.on("error", (error) => console.error(error));
115
117
  ```
116
118
 
117
119
  Unsubscribe with `select.off(event, handler)`.
118
120
 
121
+ Use `select.setValue(value, { emitChange: false })` to synchronize external controlled state without emitting `change`.
122
+
119
123
  ## Examples
120
124
 
121
125
  ```js
122
126
  new ForgeSelect("#users", {
123
- ajax: {
124
- url: query => `/api/users?q=${encodeURIComponent(query)}`,
125
- debounce: 300,
126
- transform: response => response.items.map(u => ({ value: u.id, label: u.name }))
127
- }
127
+ ajax: {
128
+ url: (query) => `/api/users?q=${encodeURIComponent(query)}`,
129
+ debounce: 300,
130
+ transform: (response) => response.items.map((u) => ({ value: u.id, label: u.name })),
131
+ },
128
132
  });
129
133
  ```
130
134
 
@@ -132,16 +136,34 @@ More copy-pasteable snippets (multi-select, tags, custom templates, virtual scro
132
136
 
133
137
  ## Playground
134
138
 
135
- 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.
139
+ Write and run Forge Select code in the browser at **<https://forgeselect.konexforge.com/playground/>** — with presets for every major feature. A curated feature showcase also lives at **<https://forgeselect.konexforge.com/demo/>**. See [`docs/playground.md`](./docs/playground.md) for details and local setup.
136
140
 
137
141
  ## API Reference
138
142
 
139
- | Option | Type | Default | Description |
140
- |---|---|---|---|
141
- | `placeholder` | `string` | `""` | Text shown when nothing is selected |
142
- | `searchable` | `boolean` | `true` | Show a search input in the dropdown |
143
- | `multiple` | `boolean` | `false` | Allow selecting more than one option |
144
- | `theme` | `string` | `"default"` | Named theme applied to the control |
143
+ | Option | Type | Default | Description |
144
+ | --------------------- | ---------------------------------- | ----------- | --------------------------------------------------- |
145
+ | `placeholder` | `string` | `""` | Text shown when nothing is selected |
146
+ | `searchable` | `boolean` | `true` | Show a search input in the dropdown |
147
+ | `multiple` | `boolean` | `false` | Allow selecting more than one option |
148
+ | `clearable` | `boolean` | `false` | Show a button to clear the current selection |
149
+ | `allowCreate` | `boolean` | `false` | Let the user create a new option from free text |
150
+ | `sortable` | `boolean` | `false` | Multi-select: let the user reorder selected tags |
151
+ | `closeOnSelect` | `boolean` | `false` | Multi-select: close the dropdown after each pick |
152
+ | `maxSelections` | `number` | `undefined` | Multi-select: caps the number of selected values |
153
+ | `theme` | `string` | `"default"` | Named theme applied to the control |
154
+ | `required` | `boolean` | `false` | Native form validation on a `<select>` mount |
155
+ | `data` | `Array<Option \| OptionGroup>` | `undefined` | Static options, used instead of `<option>` children |
156
+ | `ajax` | `AjaxConfig` | `undefined` | Remote data source config |
157
+ | `filterOption` | `(option, query) => boolean` | `undefined` | Custom match predicate for search filtering |
158
+ | `minSearchLength` | `number` | `0` | Minimum query length before filtering/ajax runs |
159
+ | `minResultsForSearch` | `number` | `0` | Hide local search below an option-count threshold |
160
+ | `isOptionDisabled` | `(option) => boolean` | `undefined` | Dynamically disable an option per render |
161
+ | `virtualScroll` | `boolean` | _(auto)_ | Virtualize the list once it exceeds ~100 rows |
162
+ | `itemHeight` | `number` | `36` | Row height in px used by the virtual scroller |
163
+ | `language` | `string \| Record<string, string>` | `"en"` | Locale code or a custom string table for i18n |
164
+ | `plugins` | `Array<ForgeSelectPlugin>` | `[]` | Plugins to register on this instance |
165
+ | `openOnFocus` | `boolean` | `false` | Open the dropdown on keyboard focus |
166
+ | `dropdownParent` | `HTMLElement \| string` | `undefined` | Portal container for overflow-constrained layouts |
145
167
 
146
168
  Full constructor signature, all options, instance methods, and events are documented in [`docs/api-reference.md`](./docs/api-reference.md).
147
169
 
@@ -155,18 +177,18 @@ new ForgeSelect("#country", { theme: "dark" });
155
177
 
156
178
  ```css
157
179
  .forge-select {
158
- --fs-border-focus: #e11d48;
159
- --fs-radius: 4px;
180
+ --fs-border-focus: #e11d48;
181
+ --fs-radius: 4px;
160
182
  }
161
183
  ```
162
184
 
163
185
  ## Framework Support
164
186
 
165
- ForgeSelect is vanilla TypeScript/JavaScript, so it can be mounted inside any framework today. Official wrapper packages exist for a couple of them:
187
+ Forge Select is vanilla TypeScript/JavaScript, so it can be mounted inside any framework today. Official wrapper packages exist for a couple of them:
166
188
 
167
189
  - Vanilla JavaScript
168
- - React — via [`@forge-select/react`](./packages/react/README.md) (`ForgeSelectReact` component, controlled `value`/`onChange`)
169
- - Vue — via [`@forge-select/vue`](./packages/vue/README.md) (`ForgeSelectVue` component, `v-model` support)
190
+ - React — via [`forge-select-react`](./packages/react/README.md) (`ForgeSelectReact` component, controlled `value`/`onChange`)
191
+ - Vue — via [`forge-select-vue`](./packages/vue/README.md) (`ForgeSelectVue` component, `v-model` support)
170
192
  - Angular — mount manually for now; a dedicated wrapper is on the [Roadmap](#roadmap)
171
193
  - Svelte — mount manually for now; a dedicated wrapper is on the [Roadmap](#roadmap)
172
194
  - Next.js
@@ -183,18 +205,18 @@ ForgeSelect is vanilla TypeScript/JavaScript, so it can be mounted inside any fr
183
205
 
184
206
  ## Migration from Select2
185
207
 
186
- 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).
208
+ Forge Select 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).
187
209
 
188
210
  ## Benchmarks
189
211
 
190
- 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).
212
+ Run `npm run bench` for a reproducible JSON baseline covering bundle size, initialization, 10,000-option search latency, and virtual-scroll performance. The methodology and result fields are documented in [`docs/benchmarks.md`](./docs/benchmarks.md).
191
213
 
192
214
  ## Roadmap
193
215
 
194
216
  - [x] Tree Select
195
217
  - [x] Virtualized List
196
218
  - [x] Async Pagination
197
- - [ ] Drag & Drop Ordering
219
+ - [x] Drag & Drop Ordering
198
220
  - [x] Theme Builder
199
221
  - [x] CSS Variables
200
222
  - [x] React Component
@@ -204,7 +226,7 @@ Performance benchmarking (bundle size, init time, search latency, virtual scroll
204
226
 
205
227
  ## Plugin Development Guide
206
228
 
207
- 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.
229
+ Forge Select 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.
208
230
 
209
231
  ## Development
210
232