@smilodon/react 1.11.0 → 1.12.1
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/COMPLETE-GUIDE.md +67 -0
- package/README.md +142 -0
- package/dist/index.cjs +274 -265
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +274 -265
- package/dist/index.js.map +1 -1
- package/dist/types/Select.d.ts +19 -4
- package/dist/types/Select.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +2 -2
package/COMPLETE-GUIDE.md
CHANGED
|
@@ -679,6 +679,41 @@ function EventHandling() {
|
|
|
679
679
|
|
|
680
680
|
## Styling & Theming
|
|
681
681
|
|
|
682
|
+
### Active class mapping for custom-rendered options (Core #82)
|
|
683
|
+
|
|
684
|
+
Use `classMap.active` to supply application-specific active styles when using `customRenderer`. Core removes stale built-in aliases and old mapped classes when active focus changes:
|
|
685
|
+
|
|
686
|
+
```tsx
|
|
687
|
+
<Select
|
|
688
|
+
items={items}
|
|
689
|
+
customRenderer={(item) => <span>{item.label}</span>}
|
|
690
|
+
classMap={{ active: "my-active-option", selected: "my-selected-option" }}
|
|
691
|
+
/>
|
|
692
|
+
```
|
|
693
|
+
|
|
694
|
+
Active and selected are distinct states; use `data-sm-state` or the mapped classes when styling. The correction is in Core. See the [Core rendering contract](../core/README.md#active-state-on-custom-option-roots).
|
|
695
|
+
|
|
696
|
+
### Dropdown enter and exit animations (Core 1.12.0)
|
|
697
|
+
|
|
698
|
+
The shared Core supports independent animations controlled through inherited CSS variables:
|
|
699
|
+
|
|
700
|
+
```css
|
|
701
|
+
enhanced-select {
|
|
702
|
+
--select-dropdown-animation: dropdownEnter 220ms ease-out forwards;
|
|
703
|
+
--select-dropdown-exit-animation: dropdownExit 160ms ease-in forwards;
|
|
704
|
+
--select-dropdown-exit-to-transform: translateY(-8px) scale(0.98);
|
|
705
|
+
--select-dropdown-top-exit-to-transform: translateY(8px) scale(0.98);
|
|
706
|
+
}
|
|
707
|
+
```
|
|
708
|
+
|
|
709
|
+
Exit updates `aria-expanded` and `close` synchronously while an inert visual panel finishes animating. Set `--select-dropdown-exit-animation: none` to disable exit. Reduced-motion preferences are honored. Core `1.12.0` is available from npm.
|
|
710
|
+
|
|
711
|
+
### Acknowledged pagination and rerender ownership (#85 — pending React release)
|
|
712
|
+
|
|
713
|
+
The locally prepared React fix synchronizes `items`/`groupedItems` only for actual input identity changes; presentation config changes must not overwrite accepted cumulative pages. Keep initial item references stable and use `completeDataRequest()` for acknowledged page results with the request ID and query generation. That fix is **not merged or released**; the public React 1.11.0 package cannot be assumed to contain it.
|
|
714
|
+
|
|
715
|
+
|
|
716
|
+
|
|
682
717
|
### Inline Styles with CSS Variables
|
|
683
718
|
|
|
684
719
|
```tsx
|
|
@@ -1242,6 +1277,38 @@ function AsyncSelect() {
|
|
|
1242
1277
|
}
|
|
1243
1278
|
```
|
|
1244
1279
|
|
|
1280
|
+
### Customizing the Core busy bucket
|
|
1281
|
+
|
|
1282
|
+
`loadingIcon` and `loadingContent` provide React nodes to Core's native `loading-icon` and `loading-content` slots. The adapter keeps these nodes in the custom element's light DOM and React owns their lifecycle; Core controls when the slot projection is visible.
|
|
1283
|
+
|
|
1284
|
+
```tsx
|
|
1285
|
+
<Select
|
|
1286
|
+
items={items}
|
|
1287
|
+
infiniteScroll
|
|
1288
|
+
config={{
|
|
1289
|
+
busyBucket: {
|
|
1290
|
+
enabled: true,
|
|
1291
|
+
showSpinner: false,
|
|
1292
|
+
showMessage: true,
|
|
1293
|
+
message: 'Loading…',
|
|
1294
|
+
minDisplayTime: 200,
|
|
1295
|
+
contentMode: 'replace',
|
|
1296
|
+
},
|
|
1297
|
+
}}
|
|
1298
|
+
loadingIcon={<MyLoadingIcon />}
|
|
1299
|
+
loadingContent={(
|
|
1300
|
+
<div>
|
|
1301
|
+
<strong>Loading more options…</strong>
|
|
1302
|
+
<span>Additional results will appear shortly.</span>
|
|
1303
|
+
</div>
|
|
1304
|
+
)}
|
|
1305
|
+
/>
|
|
1306
|
+
```
|
|
1307
|
+
|
|
1308
|
+
`append` is the default `contentMode` and shows the built-in UI alongside custom content. `replace` shows only accessible custom content and hides the icon and message regions; otherwise Core retains its “Loading…” fallback. Keep meaningful text in replacement content so assistive technology has a status to announce. In append mode, the icon is decorative and separate from `arrowIcon`.
|
|
1309
|
+
|
|
1310
|
+
The busy bucket is presentation only. `minDisplayTime` may keep it visible briefly after completion, but never delays the data coordinator, page advancement, or `aria-busy`. Custom nodes remain mounted while the bucket is hidden; gate animation or expensive work through application state. The existing `Searching...` state has its own rendering path.
|
|
1311
|
+
|
|
1245
1312
|
### With React Hook Form
|
|
1246
1313
|
|
|
1247
1314
|
```tsx
|
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Select component for React applications. The shared core has scoped automated Phase 4 browser coverage; complete React integration parity and manual assistive-technology certification remain unverified.
|
|
4
4
|
|
|
5
|
+
> **Web release:** React `1.12.0` and Core `1.17.0` are available from npm. This release adds the React remove-button node API and horizontal latest-chip auto-scroll; see the [web release record](../../docs/releases/WEB-1.17.0-RELEASE.md).
|
|
6
|
+
|
|
5
7
|
> Large-list status: the public `virtualized` prop enables legacy chunked rendering for large flat lists; it does not window rows to the viewport, and all results may eventually be mounted. True viewport virtualization remains guarded by a private test seam and is not a supported production mode. The shared core passed its scoped Phase 4 automated browser matrix in Chromium, Firefox, and WebKit; this does not certify every React integration, minimum browser versions, or WCAG conformance. Manual assistive-technology assessment remains pending. See the [current limitation record](../../docs/KNOWN-LIMITATIONS.md#viewport-virtualization-status).
|
|
6
8
|
|
|
7
9
|
## 📖 Documentation
|
|
@@ -174,8 +176,17 @@ export function RemoteSelect() {
|
|
|
174
176
|
|
|
175
177
|
The coordinator rejects stale responses by request ID and query generation; the host should still abort cancelled network work to save resources. An accepted response does not mean projection is finished: observe `onDataProjection` for the projection result. A failed request remains failed until a new explicit request is made; the sample deliberately does not retry automatically.
|
|
176
178
|
|
|
179
|
+
### React item synchronization and acknowledged pagination
|
|
180
|
+
|
|
181
|
+
The adapter treats React props as the source snapshot and the Core data coordinator as the owner of accepted acknowledged responses. Rerendering with a newly allocated array of equivalent plain-object records does not call `setItems()` and cannot reset pages accepted by Core. Meaningful changes to an item's enumerable fields, nested plain-object metadata, array metadata, or group structure synchronize as source updates; an empty array is also an intentional update.
|
|
182
|
+
|
|
183
|
+
Use immutable plain-object item records. Functions and non-plain metadata values such as `Date`, `Map`, and class instances compare by identity, so memoize them if they are part of item metadata. Enumerable symbol keys and accessor identity are included in comparison. When data is semantically unchanged, React cannot infer that the application intends to restart pagination; initiate a new acknowledged search/generation for that intent instead of relying on a render or a fresh array.
|
|
184
|
+
|
|
185
|
+
The adapter applies configuration, source data, and controlled selection through separate lifecycle paths. Fresh equivalent configuration objects and inline React `removeButtonIcon` nodes do not reapply Core configuration. Actual selection, layout, styling, disabled-state, and data-loading configuration changes remain active. See the [React data synchronization ownership record](../../docs/architecture/REACT-DATA-SYNC-OWNERSHIP-107.md).
|
|
186
|
+
|
|
177
187
|
### Other useful scenarios
|
|
178
188
|
|
|
189
|
+
- **Terminal empty remote search (#92):** When the host completes the matching acknowledged request with `status: 'exhausted'`, `items: []`, and `hasMore: false`, Core displays the query-specific no-results message after successful projection. React consumers do not need a manual rerender, popup toggle, or `setItems([])` workaround. Wait for `onDataProjection` with `status: 'complete'` before relying on the projected DOM; `completeDataRequest()` returning `accepted` reports response acceptance, not DOM settlement. An empty page with `status: 'empty'` and `hasMore: true` is nonterminal. This guidance does not include the separate React #85 fix.
|
|
179
190
|
- **Empty query:** clearing search still invokes `onSearch` with `request.query === ''`. `URLSearchParams` serializes it as an explicit empty `q` parameter; do not omit it if the endpoint treats an empty query specially.
|
|
180
191
|
- **Page-based pagination:** change `paginationMode` to `'page'`; the request's `position.page` is the page to request. Keep the API's page numbering consistent with `firstPage`.
|
|
181
192
|
- **Hybrid search:** use `searchMode: 'hybrid'` only when the host intends the runtime's hybrid search behavior; the host still answers the remote request with its identity and generation.
|
|
@@ -184,6 +195,75 @@ The coordinator rejects stale responses by request ID and query generation; the
|
|
|
184
195
|
- **Legacy compatibility:** omit `config.dataLoading` to retain the legacy protocol. Existing `onSearch(query, results, count)` and `onLoadMore(page)` calls remain usable; the new request argument is optional in those callback signatures.
|
|
185
196
|
- **Controlled selection:** keep `value` in application state and update it through `onChange`. Replacing remote result pages does not transfer ownership of the selected value from the application to the transport layer.
|
|
186
197
|
|
|
198
|
+
### Custom busy bucket (React 1.12.0; requires Core 1.13.0)
|
|
199
|
+
|
|
200
|
+
Introduced in `@smilodon/react@1.12.0`, `loadingIcon` and `loadingContent` expose Core's native loading slots. Use `@smilodon/core@^1.13.0`. These are React-owned light-DOM children; Core projects them into its Shadow DOM busy bucket without creating another React root.
|
|
201
|
+
|
|
202
|
+
```tsx
|
|
203
|
+
<Select
|
|
204
|
+
items={items}
|
|
205
|
+
infiniteScroll
|
|
206
|
+
config={{
|
|
207
|
+
busyBucket: {
|
|
208
|
+
enabled: true,
|
|
209
|
+
showSpinner: false,
|
|
210
|
+
showMessage: true,
|
|
211
|
+
message: 'Loading…',
|
|
212
|
+
minDisplayTime: 200,
|
|
213
|
+
contentMode: 'append',
|
|
214
|
+
},
|
|
215
|
+
}}
|
|
216
|
+
loadingIcon={<MyLoadingIcon />}
|
|
217
|
+
loadingContent={(
|
|
218
|
+
<div>
|
|
219
|
+
<strong>Loading more products…</strong>
|
|
220
|
+
<span>Please wait.</span>
|
|
221
|
+
</div>
|
|
222
|
+
)}
|
|
223
|
+
/>
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Use `contentMode: 'replace'` when accessible `loadingContent` should be the only visible bucket content; Core hides the icon and message regions. If no accessible replacement is supplied, Core retains a “Loading…” fallback. In append mode, `loadingIcon` is decorative and does not affect `arrowIcon`; `loadingContent` is independent of `items`. React keeps both custom nodes mounted in the light DOM while busy UI is hidden, so start expensive work only from the request callback or explicit application state.
|
|
227
|
+
|
|
228
|
+
`minDisplayTime` is a presentation policy for the busy bucket, not a request delay. Request acceptance, pagination state, and `aria-busy` update as soon as the request completes. The dedicated `Searching...` view remains unchanged and is not replaced by these props.
|
|
229
|
+
|
|
230
|
+
### Latest-chip auto-scroll (React 1.12.0; Issue #100)
|
|
231
|
+
|
|
232
|
+
In horizontal multi-select mode, `multiSelectDisplay.scrollToLatestChip` reveals a newly selected chip. It is opt-in and respects reduced-motion preferences. It is available with Core `1.17.0`.
|
|
233
|
+
|
|
234
|
+
```tsx
|
|
235
|
+
<Select
|
|
236
|
+
items={items}
|
|
237
|
+
multiple
|
|
238
|
+
multiSelectDisplay={{
|
|
239
|
+
mode: 'horizontal',
|
|
240
|
+
overflowX: 'auto',
|
|
241
|
+
scrollToLatestChip: true,
|
|
242
|
+
scrollToLatestChipBehavior: 'smooth',
|
|
243
|
+
}}
|
|
244
|
+
/>
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### Custom empty-state renderer (React 1.12.0; Issue #93)
|
|
248
|
+
|
|
249
|
+
`emptyStateRenderer` receives Core's readonly `{ query, reason }` context only while a terminal empty state is active. React renders its result in Core's native `empty-state` slot; omit the prop to keep the built-in fallback. `onEmptyStateChange` receives the new context and receives `null` when the empty state clears. The imperative handle also exposes `getEmptyStateContext()`.
|
|
250
|
+
|
|
251
|
+
```tsx
|
|
252
|
+
<Select
|
|
253
|
+
items={items}
|
|
254
|
+
searchable
|
|
255
|
+
emptyStateRenderer={({ query, reason }) => (
|
|
256
|
+
<div role="status">
|
|
257
|
+
<EmptyResultsIcon aria-hidden="true" />
|
|
258
|
+
<span>{reason === 'no-options' ? 'No options yet' : `No results for “${query}”`}</span>
|
|
259
|
+
</div>
|
|
260
|
+
)}
|
|
261
|
+
onEmptyStateChange={(context) => console.log('Empty state:', context)}
|
|
262
|
+
/>
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
This is a presentation API; it does not change the behavior of `items`, acknowledged request completion, or selection.
|
|
266
|
+
|
|
187
267
|
## Infinite Render Loop: Root-Cause Review (No External Dependencies)
|
|
188
268
|
|
|
189
269
|
If you see `Maximum update depth exceeded`, follow this checklist before shipping:
|
|
@@ -1537,6 +1617,28 @@ You can replace the default chip remove icon with the `removeButtonIcon` prop:
|
|
|
1537
1617
|
|
|
1538
1618
|
Markup strings are supported too, so inline SVG icons work.
|
|
1539
1619
|
|
|
1620
|
+
React components are also supported, including generated icon components:
|
|
1621
|
+
|
|
1622
|
+
```tsx
|
|
1623
|
+
import TrashIcon from '@/generated/icons/Trash.icon';
|
|
1624
|
+
|
|
1625
|
+
<Select
|
|
1626
|
+
items={items}
|
|
1627
|
+
multiple
|
|
1628
|
+
defaultValue={['one']}
|
|
1629
|
+
removeButtonIcon={<TrashIcon />}
|
|
1630
|
+
/>
|
|
1631
|
+
```
|
|
1632
|
+
|
|
1633
|
+
The React node is displayed inside Core's existing remove buttons in selected
|
|
1634
|
+
chips and selected dropdown options. Remove behavior, accessibility labels, and
|
|
1635
|
+
`chip-remove` / `chip-remove-icon` parts remain Core-owned. Strings still
|
|
1636
|
+
render as the legacy text or inline SVG markup. The prop supports React nodes,
|
|
1637
|
+
**not** a component function passed directly: use `<TrashIcon />`, not
|
|
1638
|
+
`TrashIcon`. When `config.selection.removeButtonIcon` is explicitly
|
|
1639
|
+
supplied, that Core string configuration takes precedence. React nodes are
|
|
1640
|
+
supported by the React adapter only, not Core or other framework adapters.
|
|
1641
|
+
|
|
1540
1642
|
To style the icon separately from the round remove button, use the host `style` prop with these tokens:
|
|
1541
1643
|
|
|
1542
1644
|
- `--select-badge-remove-icon-size`
|
|
@@ -1753,6 +1855,46 @@ interface SelectHandle {
|
|
|
1753
1855
|
}
|
|
1754
1856
|
```
|
|
1755
1857
|
|
|
1858
|
+
## Dropdown animation controls (Core 1.12.0)
|
|
1859
|
+
|
|
1860
|
+
React consumers can customize entry and exit animations through inherited Core CSS variables, without a new React prop:
|
|
1861
|
+
|
|
1862
|
+
```tsx
|
|
1863
|
+
<Select items={items} className="animated-select" />
|
|
1864
|
+
```
|
|
1865
|
+
|
|
1866
|
+
```css
|
|
1867
|
+
enhanced-select.animated-select {
|
|
1868
|
+
--select-dropdown-animation: dropdownEnter 250ms ease-out forwards;
|
|
1869
|
+
--select-dropdown-exit-animation: dropdownExit 180ms ease-in forwards;
|
|
1870
|
+
--select-dropdown-exit-to-opacity: 0;
|
|
1871
|
+
--select-dropdown-exit-to-transform: translateY(-8px) scale(0.98);
|
|
1872
|
+
--select-dropdown-top-exit-to-transform: translateY(8px) scale(0.98);
|
|
1873
|
+
}
|
|
1874
|
+
```
|
|
1875
|
+
|
|
1876
|
+
Set either animation to `none` to disable it. The close event and ARIA close immediately, while the visual dropdown becomes inert and exits. Reopening cancels an unfinished exit; reduced-motion preferences are respected. Core `1.12.0` is available on npm, and React `1.11.0` declares `@smilodon/core: ^1.11.0`, which accepts it. See [engineering notes](../../docs/architecture/DROPDOWN-EXIT-ANIMATION.md).
|
|
1877
|
+
|
|
1878
|
+
### Custom active classes — Issue #82 (Core)
|
|
1879
|
+
|
|
1880
|
+
When rendering custom option content, set `classMap.active` to the class names used by your application's active-state styles. Core now removes both legacy `active`/`sm-active` aliases and previously configured active classes as focus moves; an inactive option no longer matches `.option.active` accidentally.
|
|
1881
|
+
|
|
1882
|
+
```tsx
|
|
1883
|
+
<Select
|
|
1884
|
+
items={items}
|
|
1885
|
+
customRenderer={(item) => <span>{item.label}</span>}
|
|
1886
|
+
classMap={{ active: "my-option-active", selected: "my-option-selected" }}
|
|
1887
|
+
/>
|
|
1888
|
+
```
|
|
1889
|
+
|
|
1890
|
+
The option's `data-sm-state`, `aria-selected`, and classes reflect independent active/selected semantics. The fix is in Core, not in React's renderer. See [Issue #82](https://github.com/navidrezadoost/Smilodon/issues/82) and the [Core rendering guide](../core/README.md#active-state-on-custom-option-roots).
|
|
1891
|
+
|
|
1892
|
+
### Acknowledged data synchronization on React rerenders — Issue #107
|
|
1893
|
+
|
|
1894
|
+
In acknowledged loading, Core owns the cumulative accepted result pages, while React owns the source records and configuration passed by the application. React `1.12.1` compares incoming source/configuration values with the last values it successfully synchronized. Equivalent newly allocated arrays and plain configuration objects do not reset accepted pages during an incidental rerender; changed item fields, grouping, and an explicit empty source still synchronize.
|
|
1895
|
+
|
|
1896
|
+
Controlled selection remains synchronized separately. Core's acknowledged request protocol and imperative `setItems()` behavior are unchanged. Functions and non-plain metadata values compare by identity; keep them stable when they have not changed. Consumers should replace records immutably when changing their contents. See [Issue #107](https://github.com/navidrezadoost/Smilodon/issues/107), the [implementation and qualification record](../../docs/architecture/REACT-DATA-SYNC-OWNERSHIP-107.md), and the [React 1.12.1 release record](../../docs/releases/REACT-1.12.1-RELEASE.md).
|
|
1897
|
+
|
|
1756
1898
|
## Styling
|
|
1757
1899
|
|
|
1758
1900
|
The component uses Shadow DOM for style encapsulation. You can customize it using CSS custom properties:
|