lumiverse-spindle-types 0.5.3 → 0.5.5
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/package.json +1 -1
- package/src/components.ts +101 -1
- package/src/index.ts +1 -0
package/package.json
CHANGED
package/src/components.ts
CHANGED
|
@@ -206,6 +206,71 @@ export interface SpindleSwitchHandle extends SpindleMountedComponent<SpindleSwit
|
|
|
206
206
|
// Pickers & selects
|
|
207
207
|
// ──────────────────────────────────────────────────────────────────────────
|
|
208
208
|
|
|
209
|
+
/**
|
|
210
|
+
* Declarative leading-cell content for a select option (avatar, icon, swatch, initial).
|
|
211
|
+
*
|
|
212
|
+
* Rendered by the host in the fixed leading slot of both the dropdown row and
|
|
213
|
+
* the selected-value trigger. Extensions describe what they want declaratively
|
|
214
|
+
* — they do not pass React nodes themselves.
|
|
215
|
+
*
|
|
216
|
+
* Common patterns:
|
|
217
|
+
* - Persona/character avatars with initial fallback: pick `{ type: "image", src, fallback }`.
|
|
218
|
+
* The host shows the image when it loads successfully; if `src` is empty or
|
|
219
|
+
* the image fails to load, the host falls back to the supplied initial.
|
|
220
|
+
* - Provider icons / brand marks: `{ type: "icon-svg" }` or `{ type: "icon-url" }`.
|
|
221
|
+
* - Color tags / category swatches: `{ type: "swatch", color }`.
|
|
222
|
+
* - Plain text bubble (initials, single emoji): `{ type: "initial", text }`.
|
|
223
|
+
*/
|
|
224
|
+
export type SpindleSelectOptionLeading =
|
|
225
|
+
| {
|
|
226
|
+
type: "image";
|
|
227
|
+
/** Image URL. Anything `<img src>` accepts, including data URLs. */
|
|
228
|
+
src: string;
|
|
229
|
+
/** Alt text for accessibility. Defaults to empty (decorative). */
|
|
230
|
+
alt?: string;
|
|
231
|
+
/** Render the image as a circle. Default: `true`. Useful for avatars. */
|
|
232
|
+
rounded?: boolean;
|
|
233
|
+
/**
|
|
234
|
+
* Fallback rendered when `src` is empty or fails to load. Typically a
|
|
235
|
+
* one-character initial. If omitted, the slot collapses on failure.
|
|
236
|
+
*/
|
|
237
|
+
fallback?: {
|
|
238
|
+
/** Fallback text — usually a single character / initial. */
|
|
239
|
+
text: string;
|
|
240
|
+
/** Optional background color for the fallback bubble. */
|
|
241
|
+
background?: string;
|
|
242
|
+
/** Optional text color for the fallback bubble. */
|
|
243
|
+
color?: string;
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
| {
|
|
247
|
+
type: "icon-svg";
|
|
248
|
+
/** Inline SVG string. The host sanitizes and inlines the SVG. */
|
|
249
|
+
svg: string;
|
|
250
|
+
/** Optional foreground color applied via `currentColor`. */
|
|
251
|
+
color?: string;
|
|
252
|
+
}
|
|
253
|
+
| {
|
|
254
|
+
type: "icon-url";
|
|
255
|
+
/** URL to an icon image (PNG / SVG / WebP). */
|
|
256
|
+
url: string;
|
|
257
|
+
alt?: string;
|
|
258
|
+
}
|
|
259
|
+
| {
|
|
260
|
+
type: "swatch";
|
|
261
|
+
/** Any CSS color string. Rendered as a small filled circle. */
|
|
262
|
+
color: string;
|
|
263
|
+
}
|
|
264
|
+
| {
|
|
265
|
+
type: "initial";
|
|
266
|
+
/** Text shown inside the leading bubble — typically one character. */
|
|
267
|
+
text: string;
|
|
268
|
+
/** Background color for the bubble. */
|
|
269
|
+
background?: string;
|
|
270
|
+
/** Text color inside the bubble. */
|
|
271
|
+
color?: string;
|
|
272
|
+
};
|
|
273
|
+
|
|
209
274
|
/** A single option in a select-style picker. */
|
|
210
275
|
export interface SpindleSelectOption {
|
|
211
276
|
/** Stable value emitted to `onChange`. */
|
|
@@ -214,6 +279,13 @@ export interface SpindleSelectOption {
|
|
|
214
279
|
label: string;
|
|
215
280
|
/** Secondary text rendered beneath the label. */
|
|
216
281
|
sublabel?: string;
|
|
282
|
+
/**
|
|
283
|
+
* Optional leading-cell content rendered before the label in both the
|
|
284
|
+
* dropdown row and the selected-value trigger. See {@link SpindleSelectOptionLeading}
|
|
285
|
+
* for the supported variants (avatar image with initial fallback, inline
|
|
286
|
+
* SVG icon, icon URL, color swatch, plain initial bubble).
|
|
287
|
+
*/
|
|
288
|
+
leading?: SpindleSelectOptionLeading;
|
|
217
289
|
/** Group key. Options sharing a group are visually clustered with a header. */
|
|
218
290
|
group?: string;
|
|
219
291
|
/** Render as disabled. */
|
|
@@ -229,8 +301,29 @@ export interface SpindleSelectOptionsBase {
|
|
|
229
301
|
searchPlaceholder?: string;
|
|
230
302
|
/** Minimum option count before the search field is shown. Default: `8`. */
|
|
231
303
|
searchThreshold?: number;
|
|
232
|
-
/**
|
|
304
|
+
/**
|
|
305
|
+
* Message rendered when the option list itself is empty (i.e. no options
|
|
306
|
+
* were supplied). For "no matches against the current search" use
|
|
307
|
+
* {@link noResultsMessage} instead.
|
|
308
|
+
*/
|
|
233
309
|
emptyMessage?: string;
|
|
310
|
+
/** Message rendered when the search query has no matching options. */
|
|
311
|
+
noResultsMessage?: string;
|
|
312
|
+
/**
|
|
313
|
+
* Force a specific trigger label, ignoring whichever option is currently
|
|
314
|
+
* selected. Useful for "+ Add", "Filter…" style triggers.
|
|
315
|
+
*/
|
|
316
|
+
triggerLabel?: string;
|
|
317
|
+
/**
|
|
318
|
+
* Custom trigger icon. Replaces the default chevron. Accepts the same
|
|
319
|
+
* declarative shape as option leading cells — typically `{ type: "icon-svg" }`
|
|
320
|
+
* for a brand mark or chevron alternative.
|
|
321
|
+
*/
|
|
322
|
+
triggerIcon?: SpindleSelectOptionLeading;
|
|
323
|
+
/** Accessible label for the trigger button. Surfaces as `aria-label`. */
|
|
324
|
+
ariaLabel?: string;
|
|
325
|
+
/** Additional CSS class merged onto the trigger button. */
|
|
326
|
+
triggerClassName?: string;
|
|
234
327
|
/**
|
|
235
328
|
* Render the dropdown into a React portal anchored to `document.body` so it
|
|
236
329
|
* escapes containers with `overflow:hidden`. Default: `true`.
|
|
@@ -250,6 +343,13 @@ export interface SpindleSelectOptions extends SpindleSelectOptionsBase {
|
|
|
250
343
|
/** Initial value. */
|
|
251
344
|
value?: string;
|
|
252
345
|
onChange?: (value: string) => void;
|
|
346
|
+
/**
|
|
347
|
+
* Show a "None" / clear option pinned to the top of the dropdown. Selecting
|
|
348
|
+
* it emits `onChange("")`. Single-select only.
|
|
349
|
+
*/
|
|
350
|
+
clearable?: boolean;
|
|
351
|
+
/** Label shown for the clear option. Default: `"None"`. */
|
|
352
|
+
clearLabel?: string;
|
|
253
353
|
}
|
|
254
354
|
|
|
255
355
|
export interface SpindleSelectHandle extends SpindleMountedComponent<SpindleSelectOptions> {
|