@vialiq/web-components 0.19.0 → 0.20.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 +124 -0
- package/base/controllers/floating-controller.d.ts +1 -1
- package/base/controllers/floating-controller.d.ts.map +1 -1
- package/button/vi-button.d.ts +2 -0
- package/button/vi-button.d.ts.map +1 -1
- package/button/vi-button.js +40 -11
- package/index.d.ts +3 -0
- package/index.js +3 -0
- package/keyboard-controller-DqpJtUuK.js +320 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -298,6 +298,130 @@ vi-input {
|
|
|
298
298
|
|
|
299
299
|
---
|
|
300
300
|
|
|
301
|
+
### Select ([vi-select](./src/select/vi-select.ts))
|
|
302
|
+
|
|
303
|
+
> [!NOTE]
|
|
304
|
+
> **Performance Notice:** The `vi-select` component automatically calculates its width to perfectly fit its content by measuring all rendered options. Because it renders all options directly into the DOM without virtualization, it is **not intended for large lists** (e.g., thousands of items). For massive datasets, use a combobox with virtualization and async filtering instead.
|
|
305
|
+
|
|
306
|
+
The [ViSelect](./src/select/vi-select.ts) is a custom listbox component that replaces the native `<select>` element. It supports custom templating, dynamic wrapping, form integration, and floating dropdowns using Floating UI.
|
|
307
|
+
|
|
308
|
+
#### Properties & Attributes
|
|
309
|
+
|
|
310
|
+
| Attribute | Property | Type | Default | Description |
|
|
311
|
+
| :----------------- | :---------------- | :------------------------------ | :---------- | :----------------------------------------------- |
|
|
312
|
+
| `value` | `value` | `string` | `''` | The currently selected option's value. |
|
|
313
|
+
| `placeholder` | `placeholder` | `string` | `'Select...'` | Text shown when no option is selected. |
|
|
314
|
+
| `name` | `name` | `string` | `''` | Form field name. |
|
|
315
|
+
| `disabled` | `disabled` | `boolean` | `false` | Disables the select component entirely. |
|
|
316
|
+
| `required` | `required` | `boolean` | `false` | Makes selecting an option mandatory. |
|
|
317
|
+
| `clearable` | `clearable` | `boolean` | `false` | Shows a clear button ("×") when an option is selected. |
|
|
318
|
+
| `status` | `status` | `'default'\|'valid'\|'invalid'` | `'default'` | Controls validation visual border colors. |
|
|
319
|
+
| `validity-message` | `validityMessage` | `string` | `''` | Custom error message to display in UI. |
|
|
320
|
+
| `wrap-text` | `wrapText` | `boolean` | `false` | Allows text within the dropdown options to wrap instead of truncating. |
|
|
321
|
+
| `match-width` | `matchWidth` | `boolean` | `true` | Forces the listbox dropdown to match the trigger's width. |
|
|
322
|
+
| `placement` | `placement` | `DropdownPlacement` | `'bottom-start'` | Preferred positioning of the listbox dropdown. |
|
|
323
|
+
| `hoist` | `hoist` | `boolean` | `true` | Uses a fixed positioning strategy to escape clipping containers. |
|
|
324
|
+
| `flip-boundary` | `flipBoundary` | `string` | `''` | CSS selector for a boundary element used in collision detection. |
|
|
325
|
+
|
|
326
|
+
#### Slots
|
|
327
|
+
|
|
328
|
+
- **Default Slot**: Used for placing `<vi-select-option>` and `<vi-select-group>` child elements.
|
|
329
|
+
- **`helper` Slot**: Location to insert description text below the select component.
|
|
330
|
+
|
|
331
|
+
#### Child Components (`<vi-select-option>` and `<vi-select-group>`)
|
|
332
|
+
|
|
333
|
+
Options are created using the `<vi-select-option>` tag inside the select.
|
|
334
|
+
- **`value`**: The value to submit when selected.
|
|
335
|
+
- **`label`**: The plain text label used for the trigger and type-ahead filtering.
|
|
336
|
+
- **Default Slot**: You can place any complex HTML template inside the option (e.g., avatars, icons, badges) and it will render inside the listbox!
|
|
337
|
+
|
|
338
|
+
You can group options logically using `<vi-select-group>`:
|
|
339
|
+
- **`label`**: The heading text for the option group.
|
|
340
|
+
|
|
341
|
+
#### CSS Custom Properties
|
|
342
|
+
|
|
343
|
+
- `--vi-select-width`: Controls the width of the select trigger and the dropdown (default: `100%`).
|
|
344
|
+
- `--vi-typeahead-highlight-bg`: Background color of the text match when using keyboard type-ahead (default: `#ebf5ff` / `blue-100`).
|
|
345
|
+
- `--vi-typeahead-highlight-color`: Text color of the type-ahead match (default: `#3676d0` / `primary`).
|
|
346
|
+
|
|
347
|
+
#### Events
|
|
348
|
+
|
|
349
|
+
- `vialiq-change`: Fires when an option is selected. Detail: `{ value: string, label: string }`.
|
|
350
|
+
- `vialiq-clear`: Fires when the clear button is clicked.
|
|
351
|
+
|
|
352
|
+
#### Snippets
|
|
353
|
+
|
|
354
|
+
**Basic Usage:**
|
|
355
|
+
|
|
356
|
+
```html
|
|
357
|
+
<vi-select name="country" placeholder="Select a country...">
|
|
358
|
+
<vi-select-option value="us" label="United States"></vi-select-option>
|
|
359
|
+
<vi-select-option value="uk" label="United Kingdom"></vi-select-option>
|
|
360
|
+
<vi-select-option value="ca" label="Canada"></vi-select-option>
|
|
361
|
+
</vi-select>
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
**Custom Templates & Width:**
|
|
365
|
+
|
|
366
|
+
```html
|
|
367
|
+
<vi-select style="--vi-select-width: 300px;" placeholder="Select a user...">
|
|
368
|
+
<vi-select-option value="user1" label="Jane Doe">
|
|
369
|
+
<div style="display: flex; gap: 8px;">
|
|
370
|
+
<img src="avatar.png" alt="" />
|
|
371
|
+
<span>Jane Doe</span>
|
|
372
|
+
</div>
|
|
373
|
+
</vi-select-option>
|
|
374
|
+
</vi-select>
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
**Option Groups:**
|
|
378
|
+
|
|
379
|
+
```html
|
|
380
|
+
<vi-select name="fruits" placeholder="Select a fruit...">
|
|
381
|
+
<vi-select-group label="Citrus">
|
|
382
|
+
<vi-select-option value="orange" label="Orange"></vi-select-option>
|
|
383
|
+
<vi-select-option value="lemon" label="Lemon"></vi-select-option>
|
|
384
|
+
</vi-select-group>
|
|
385
|
+
<vi-select-group label="Berries">
|
|
386
|
+
<vi-select-option value="strawberry" label="Strawberry"></vi-select-option>
|
|
387
|
+
<vi-select-option value="blueberry" label="Blueberry"></vi-select-option>
|
|
388
|
+
</vi-select-group>
|
|
389
|
+
</vi-select>
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
**Placement & Fit Width (`match-width="false"`):**
|
|
393
|
+
|
|
394
|
+
By default, the dropdown matches the width of the trigger. To allow the dropdown to grow based on its content width, and change the floating direction:
|
|
395
|
+
|
|
396
|
+
```html
|
|
397
|
+
<vi-select placement="top-start" match-width="false" placeholder="Select a user...">
|
|
398
|
+
<vi-select-option value="user1" label="Jane Doe">
|
|
399
|
+
<div style="display: flex; white-space: nowrap;">
|
|
400
|
+
Jane Doe (jane.doe@example.com - Senior Software Engineer)
|
|
401
|
+
</div>
|
|
402
|
+
</vi-select-option>
|
|
403
|
+
</vi-select>
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
**Form Integration & Reset:**
|
|
407
|
+
|
|
408
|
+
The `<vi-select>` responds properly to native form resets and submit interactions.
|
|
409
|
+
|
|
410
|
+
```html
|
|
411
|
+
<form>
|
|
412
|
+
<vi-select name="status" value="pending" required>
|
|
413
|
+
<vi-select-option value="pending" label="Pending"></vi-select-option>
|
|
414
|
+
<vi-select-option value="approved" label="Approved"></vi-select-option>
|
|
415
|
+
</vi-select>
|
|
416
|
+
|
|
417
|
+
<!-- This native reset will restore the select back to "pending" -->
|
|
418
|
+
<vi-button type="reset" variant="ghost">Clear Changes</vi-button>
|
|
419
|
+
<vi-button type="submit" variant="primary">Submit</vi-button>
|
|
420
|
+
</form>
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
---
|
|
424
|
+
|
|
301
425
|
### Checkbox ([vi-checkbox](./src/checkbox/vi-checkbox.ts))
|
|
302
426
|
|
|
303
427
|
The [ViCheckbox](./src/checkbox/vi-checkbox.ts) is a customizable form-associated checkbox control using SVG graphics for checkmarks and supporting the indeterminate (mixed) validation state.
|
|
@@ -24,7 +24,7 @@ export interface FloatingControllerOptions {
|
|
|
24
24
|
/** Element or selector string to constrain flipping. */
|
|
25
25
|
boundary?: () => HTMLElement | string | null;
|
|
26
26
|
/** Whether the floating element should be forced to match the reference element's width. */
|
|
27
|
-
matchWidth?: boolean;
|
|
27
|
+
matchWidth?: boolean | (() => boolean);
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* FloatingController
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"floating-controller.d.ts","sourceRoot":"","sources":["../../../../../libs/web-components/src/base/controllers/floating-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,KAAK,CAAC;AACjE,OAAO,EAAmD,KAAK,SAAS,EAAmB,MAAM,kBAAkB,CAAC;AAGpH;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACxC,qEAAqE;IACrE,SAAS,EAAE,MAAM,WAAW,GAAG,IAAI,CAAC;IACpC,sEAAsE;IACtE,QAAQ,EAAE,MAAM,WAAW,GAAG,IAAI,CAAC;IACnC,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,SAAS,CAAC;IAC5B,kDAAkD;IAClD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,OAAO,CAAC;IACtB,wDAAwD;IACxD,QAAQ,CAAC,EAAE,MAAM,WAAW,GAAG,MAAM,GAAG,IAAI,CAAC;IAC7C,4FAA4F;IAC5F,UAAU,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"floating-controller.d.ts","sourceRoot":"","sources":["../../../../../libs/web-components/src/base/controllers/floating-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,KAAK,CAAC;AACjE,OAAO,EAAmD,KAAK,SAAS,EAAmB,MAAM,kBAAkB,CAAC;AAGpH;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACxC,qEAAqE;IACrE,SAAS,EAAE,MAAM,WAAW,GAAG,IAAI,CAAC;IACpC,sEAAsE;IACtE,QAAQ,EAAE,MAAM,WAAW,GAAG,IAAI,CAAC;IACnC,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,SAAS,CAAC;IAC5B,kDAAkD;IAClD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,OAAO,CAAC;IACtB,wDAAwD;IACxD,QAAQ,CAAC,EAAE,MAAM,WAAW,GAAG,MAAM,GAAG,IAAI,CAAC;IAC7C,4FAA4F;IAC5F,UAAU,CAAC,EAAE,OAAO,GAAG,CAAC,MAAM,OAAO,CAAC,CAAC;CACxC;AAED;;;;;;;;;GASG;AACH,qBAAa,kBAAmB,YAAW,kBAAkB;IAKzD,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,OAAO;IALjB,OAAO,CAAC,QAAQ,CAAC,CAAa;IAC9B,OAAO,CAAC,cAAc,CAAuB;gBAGnC,IAAI,EAAE,sBAAsB,EAC5B,OAAO,EAAE,yBAAyB;IAK5C,gBAAgB;IAIhB;;;;;OAKG;IACH,KAAK;IAyBL;;;;;OAKG;IACH,IAAI;IAgBJ;;;;;;OAMG;IACG,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;CA0DtC"}
|
package/button/vi-button.d.ts
CHANGED
|
@@ -53,6 +53,8 @@ export declare class ViButton extends ViButton_base {
|
|
|
53
53
|
accessor iconOnly: boolean;
|
|
54
54
|
/** Disables the button. */
|
|
55
55
|
accessor disabled: boolean;
|
|
56
|
+
/** The button type — 'button', 'submit', or 'reset'. Forwarded to the inner native button. */
|
|
57
|
+
accessor type: 'button' | 'submit' | 'reset';
|
|
56
58
|
/** Accessible label forwarded to the inner native button. */
|
|
57
59
|
accessor ariaLabel: string | null;
|
|
58
60
|
private accessor _hasIcon;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vi-button.d.ts","sourceRoot":"","sources":["../../../../libs/web-components/src/button/vi-button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiC,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAG9F,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGlD;;;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
|
function _identity(x) {
|
|
381
381
|
return x;
|
|
382
382
|
}
|
|
383
|
-
var _dec, _initClass, _FocusableMixin, _dec1, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, /** Visual variant. */ _init_variant, /** Size scale — controls padding and font-size. */ _init_size, /** Icon placement: 'start' (before label) or 'end' (after label). CSS order handles it — no DOM changes on toggle. */ _init_iconPlacement, /** When true, stretches the button to fill the width of its container. */ _init_fullWidth, /** When true, styles the button for an icon-only layout (typically square with equal padding). */ _init_iconOnly, /** Disables the button. */ _init_disabled, /** Accessible label forwarded to the inner native button. */ _init_ariaLabel, _init__hasIcon, _initProto;
|
|
383
|
+
var _dec, _initClass, _FocusableMixin, _dec1, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, /** Visual variant. */ _init_variant, /** Size scale — controls padding and font-size. */ _init_size, /** Icon placement: 'start' (before label) or 'end' (after label). CSS order handles it — no DOM changes on toggle. */ _init_iconPlacement, /** When true, stretches the button to fill the width of its container. */ _init_fullWidth, /** When true, styles the button for an icon-only layout (typically square with equal padding). */ _init_iconOnly, /** Disables the button. */ _init_disabled, /** The button type — 'button', 'submit', or 'reset'. Forwarded to the inner native button. */ _init_type, /** Accessible label forwarded to the inner native button. */ _init_ariaLabel, _init__hasIcon, _initProto;
|
|
384
384
|
let _ViButton;
|
|
385
385
|
_dec = customElement('vi-button'), _dec1 = property({
|
|
386
386
|
type: String,
|
|
@@ -404,8 +404,11 @@ _dec = customElement('vi-button'), _dec1 = property({
|
|
|
404
404
|
type: Boolean,
|
|
405
405
|
reflect: true
|
|
406
406
|
}), _dec7 = property({
|
|
407
|
+
type: String,
|
|
408
|
+
reflect: true
|
|
409
|
+
}), _dec8 = property({
|
|
407
410
|
attribute: 'aria-label'
|
|
408
|
-
}),
|
|
411
|
+
}), _dec9 = state();
|
|
409
412
|
new class extends _identity {
|
|
410
413
|
constructor(){
|
|
411
414
|
super(_ViButton), _initClass();
|
|
@@ -413,7 +416,7 @@ new class extends _identity {
|
|
|
413
416
|
static{
|
|
414
417
|
class ViButton extends (_FocusableMixin = FocusableMixin(ViElement)) {
|
|
415
418
|
static{
|
|
416
|
-
({ e: [_init_variant, _init_size, _init_iconPlacement, _init_fullWidth, _init_iconOnly, _init_disabled, _init_ariaLabel, _init__hasIcon, _initProto], c: [_ViButton, _initClass] } = _apply_decs_2203_r(this, [
|
|
419
|
+
({ e: [_init_variant, _init_size, _init_iconPlacement, _init_fullWidth, _init_iconOnly, _init_disabled, _init_type, _init_ariaLabel, _init__hasIcon, _initProto], c: [_ViButton, _initClass] } = _apply_decs_2203_r(this, [
|
|
417
420
|
[
|
|
418
421
|
_dec1,
|
|
419
422
|
1,
|
|
@@ -447,11 +450,16 @@ new class extends _identity {
|
|
|
447
450
|
[
|
|
448
451
|
_dec7,
|
|
449
452
|
1,
|
|
450
|
-
"
|
|
453
|
+
"type"
|
|
451
454
|
],
|
|
452
455
|
[
|
|
453
456
|
_dec8,
|
|
454
457
|
1,
|
|
458
|
+
"ariaLabel"
|
|
459
|
+
],
|
|
460
|
+
[
|
|
461
|
+
_dec9,
|
|
462
|
+
1,
|
|
455
463
|
"_hasIcon"
|
|
456
464
|
]
|
|
457
465
|
], [
|
|
@@ -504,19 +512,26 @@ new class extends _identity {
|
|
|
504
512
|
set disabled(_v) {
|
|
505
513
|
this.#___private_disabled_6 = _v;
|
|
506
514
|
}
|
|
507
|
-
#
|
|
515
|
+
#___private_type_7 = _init_type(this, 'button');
|
|
516
|
+
get type() {
|
|
517
|
+
return this.#___private_type_7;
|
|
518
|
+
}
|
|
519
|
+
set type(_v) {
|
|
520
|
+
this.#___private_type_7 = _v;
|
|
521
|
+
}
|
|
522
|
+
#___private_ariaLabel_8 = _init_ariaLabel(this, null);
|
|
508
523
|
get ariaLabel() {
|
|
509
|
-
return this.#
|
|
524
|
+
return this.#___private_ariaLabel_8;
|
|
510
525
|
}
|
|
511
526
|
set ariaLabel(_v) {
|
|
512
|
-
this.#
|
|
527
|
+
this.#___private_ariaLabel_8 = _v;
|
|
513
528
|
}
|
|
514
|
-
#
|
|
529
|
+
#___private__hasIcon_9 = _init__hasIcon(this, false);
|
|
515
530
|
get _hasIcon() {
|
|
516
|
-
return this.#
|
|
531
|
+
return this.#___private__hasIcon_9;
|
|
517
532
|
}
|
|
518
533
|
set _hasIcon(_v) {
|
|
519
|
-
this.#
|
|
534
|
+
this.#___private__hasIcon_9 = _v;
|
|
520
535
|
}
|
|
521
536
|
updated(changed) {
|
|
522
537
|
super.updated(changed);
|
|
@@ -542,6 +557,20 @@ new class extends _identity {
|
|
|
542
557
|
if (this.disabled) {
|
|
543
558
|
event.preventDefault();
|
|
544
559
|
event.stopImmediatePropagation();
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
// Shadow DOM isolation: a <button type="reset|submit"> inside a shadow root
|
|
563
|
+
// cannot natively interact with the parent form. We must do it manually.
|
|
564
|
+
if (this.type === 'reset' || this.type === 'submit') {
|
|
565
|
+
const form = event.composedPath().find((n)=>n instanceof HTMLFormElement);
|
|
566
|
+
if (form) {
|
|
567
|
+
if (this.type === 'reset') {
|
|
568
|
+
form.reset();
|
|
569
|
+
} else {
|
|
570
|
+
const submitter = event.currentTarget instanceof HTMLButtonElement ? event.currentTarget : undefined;
|
|
571
|
+
form.requestSubmit(submitter);
|
|
572
|
+
}
|
|
573
|
+
}
|
|
545
574
|
}
|
|
546
575
|
}
|
|
547
576
|
render() {
|
|
@@ -550,7 +579,7 @@ new class extends _identity {
|
|
|
550
579
|
<button
|
|
551
580
|
class="button"
|
|
552
581
|
part="button"
|
|
553
|
-
type
|
|
582
|
+
type=${this.type}
|
|
554
583
|
tabindex="0"
|
|
555
584
|
?disabled=${disabled}
|
|
556
585
|
aria-label=${this.ariaLabel ?? nothing}
|
package/index.d.ts
CHANGED
|
@@ -38,4 +38,7 @@ export { ViTag } from './tag/vi-tag.js';
|
|
|
38
38
|
export type { TagVariant, TagAppearance, TagSize } from './tag/vi-tag.js';
|
|
39
39
|
export { ViSwitch } from './switch/vi-switch.js';
|
|
40
40
|
export type { SwitchSize, LabelPlacement } from './switch/vi-switch.js';
|
|
41
|
+
export { ViSelect } from './select/vi-select.js';
|
|
42
|
+
export { ViSelectOption } from './select/vi-select-option.js';
|
|
43
|
+
export { ViSelectGroup } from './select/vi-select-group.js';
|
|
41
44
|
//# sourceMappingURL=index.d.ts.map
|
package/index.js
CHANGED
|
@@ -20,3 +20,6 @@ export { ViChipGroup } from './chip/vi-chip-group.js';
|
|
|
20
20
|
export { ViAnimation } from './animation/vi-animation.js';
|
|
21
21
|
export { ViTag } from './tag/vi-tag.js';
|
|
22
22
|
export { ViSwitch } from './switch/vi-switch.js';
|
|
23
|
+
export { ViSelect } from './select/vi-select.js';
|
|
24
|
+
export { ViSelectOption } from './select/vi-select-option.js';
|
|
25
|
+
export { ViSelectGroup } from './select/vi-select-group.js';
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
import { autoUpdate, offset, flip, size, computePosition } from '@floating-ui/dom';
|
|
2
|
+
import { O as OverlayManager } from './overlay-manager-Ch_6fr_D.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* FloatingController
|
|
6
|
+
*
|
|
7
|
+
* A Lit Reactive Controller that manages `@floating-ui/dom` positioning logic.
|
|
8
|
+
* It abstracts away the complex math and event listeners (autoUpdate) required to
|
|
9
|
+
* keep a popup/dropdown anchored to a reference element during scrolling/resizing.
|
|
10
|
+
*
|
|
11
|
+
* It also automatically registers the floating element with the `OverlayManager`
|
|
12
|
+
* to ensure correct z-index stacking when `hoist` is true.
|
|
13
|
+
*/ class FloatingController {
|
|
14
|
+
host;
|
|
15
|
+
options;
|
|
16
|
+
_cleanup;
|
|
17
|
+
_overlayZIndex = null;
|
|
18
|
+
constructor(host, options){
|
|
19
|
+
this.host = host;
|
|
20
|
+
this.options = options;
|
|
21
|
+
this.host.addController(this);
|
|
22
|
+
}
|
|
23
|
+
hostDisconnected() {
|
|
24
|
+
this.stop();
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Starts the floating UI `autoUpdate` listener cycle.
|
|
28
|
+
* This should be called when the popover physically opens (e.g., in `updated()`).
|
|
29
|
+
*
|
|
30
|
+
* If `hoist` is true, it also acquires a high z-index from the `OverlayManager`.
|
|
31
|
+
*/ start() {
|
|
32
|
+
const ref = this.options.reference();
|
|
33
|
+
const floating = this.options.floating();
|
|
34
|
+
if (!ref || !floating) return;
|
|
35
|
+
// autoUpdate automatically cleans up previous listeners if called multiple times,
|
|
36
|
+
// but it's safer to just track and call cleanup manually.
|
|
37
|
+
if (this._cleanup) this.stop();
|
|
38
|
+
const hoist = this.options.hoist?.() ?? false;
|
|
39
|
+
// Register with OverlayManager if hoisted
|
|
40
|
+
if (hoist) {
|
|
41
|
+
this._overlayZIndex = OverlayManager.register(floating, 'dropdown');
|
|
42
|
+
floating.style.zIndex = this._overlayZIndex.toString();
|
|
43
|
+
}
|
|
44
|
+
this._cleanup = autoUpdate(ref, floating, ()=>this.updatePosition(), {
|
|
45
|
+
animationFrame: false
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Stops the floating UI `autoUpdate` listener cycle.
|
|
50
|
+
* This should be called when the popover closes, or when the host component disconnects.
|
|
51
|
+
*
|
|
52
|
+
* It also releases its z-index back to the `OverlayManager`.
|
|
53
|
+
*/ stop() {
|
|
54
|
+
if (this._cleanup) {
|
|
55
|
+
this._cleanup();
|
|
56
|
+
this._cleanup = undefined;
|
|
57
|
+
}
|
|
58
|
+
const floating = this.options.floating();
|
|
59
|
+
if (floating && this._overlayZIndex !== null) {
|
|
60
|
+
OverlayManager.unregister(floating);
|
|
61
|
+
this._overlayZIndex = null;
|
|
62
|
+
// Remove inline z-index only if we managed it
|
|
63
|
+
floating.style.removeProperty('z-index');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Imperatively calculates and applies the new coordinates (`x`, `y`) using Floating UI.
|
|
68
|
+
*
|
|
69
|
+
* This method applies various CSS property resets (`margin`, `bottom`, `right`, `minWidth`)
|
|
70
|
+
* to ensure that the base CSS of the floating element does not distort the absolute coordinates
|
|
71
|
+
* provided by Floating UI.
|
|
72
|
+
*/ async updatePosition() {
|
|
73
|
+
const ref = this.options.reference();
|
|
74
|
+
const floating = this.options.floating();
|
|
75
|
+
if (!ref || !floating) return;
|
|
76
|
+
const placementStr = this.options.placement?.() ?? 'bottom-start';
|
|
77
|
+
const hoist = this.options.hoist?.() ?? false;
|
|
78
|
+
const boundaryOpt = this.options.boundary?.();
|
|
79
|
+
let boundaryElement = 'clippingAncestors';
|
|
80
|
+
if (boundaryOpt instanceof HTMLElement) {
|
|
81
|
+
boundaryElement = boundaryOpt;
|
|
82
|
+
} else if (typeof boundaryOpt === 'string' && boundaryOpt) {
|
|
83
|
+
const customBoundary = document.querySelector(boundaryOpt);
|
|
84
|
+
if (customBoundary) boundaryElement = customBoundary;
|
|
85
|
+
}
|
|
86
|
+
const middlewares = [
|
|
87
|
+
offset(this.options.offset ?? 4),
|
|
88
|
+
flip({
|
|
89
|
+
boundary: boundaryElement,
|
|
90
|
+
fallbackPlacements: [
|
|
91
|
+
'top-start',
|
|
92
|
+
'bottom-start',
|
|
93
|
+
'top-end',
|
|
94
|
+
'bottom-end'
|
|
95
|
+
]
|
|
96
|
+
})
|
|
97
|
+
];
|
|
98
|
+
const matchWidthVal = typeof this.options.matchWidth === 'function' ? this.options.matchWidth() : this.options.matchWidth;
|
|
99
|
+
middlewares.push(size({
|
|
100
|
+
apply: ({ rects })=>{
|
|
101
|
+
if (matchWidthVal !== false) {
|
|
102
|
+
Object.assign(floating.style, {
|
|
103
|
+
width: `${rects.reference.width}px`,
|
|
104
|
+
minWidth: 'auto'
|
|
105
|
+
});
|
|
106
|
+
} else {
|
|
107
|
+
Object.assign(floating.style, {
|
|
108
|
+
width: 'auto',
|
|
109
|
+
minWidth: `${rects.reference.width}px`
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}));
|
|
114
|
+
const { x, y, placement } = await computePosition(ref, floating, {
|
|
115
|
+
placement: placementStr,
|
|
116
|
+
strategy: hoist ? 'fixed' : 'absolute',
|
|
117
|
+
middleware: middlewares
|
|
118
|
+
});
|
|
119
|
+
floating.setAttribute('data-placement', placement);
|
|
120
|
+
Object.assign(floating.style, {
|
|
121
|
+
left: `${x}px`,
|
|
122
|
+
top: `${y}px`,
|
|
123
|
+
right: 'auto',
|
|
124
|
+
bottom: 'auto',
|
|
125
|
+
position: hoist ? 'fixed' : 'absolute',
|
|
126
|
+
margin: '0'
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
class ListboxKeyboardController {
|
|
132
|
+
host;
|
|
133
|
+
config;
|
|
134
|
+
_searchString = '';
|
|
135
|
+
_searchTimeout;
|
|
136
|
+
constructor(host, config){
|
|
137
|
+
this.host = host;
|
|
138
|
+
this.config = config;
|
|
139
|
+
this.host.addController(this);
|
|
140
|
+
}
|
|
141
|
+
hostConnected() {}
|
|
142
|
+
handleKeyDown(e) {
|
|
143
|
+
if (this.host.disabled) return;
|
|
144
|
+
const options = this.config.getFilteredOptions();
|
|
145
|
+
const isSlotted = this.config.getSlottedItems().length > 0;
|
|
146
|
+
const activeIndex = this.config.getActiveIndex();
|
|
147
|
+
switch(e.key){
|
|
148
|
+
case 'ArrowDown':
|
|
149
|
+
e.preventDefault();
|
|
150
|
+
if (!this.host.open) this.config.openDropdown();
|
|
151
|
+
this._navigate(1);
|
|
152
|
+
break;
|
|
153
|
+
case 'ArrowUp':
|
|
154
|
+
e.preventDefault();
|
|
155
|
+
if (!this.host.open) this.config.openDropdown();
|
|
156
|
+
this._navigate(-1);
|
|
157
|
+
break;
|
|
158
|
+
case 'Enter':
|
|
159
|
+
e.preventDefault();
|
|
160
|
+
if (this.host.open) {
|
|
161
|
+
if (isSlotted) {
|
|
162
|
+
const visible = this.config.getVisibleSlottedItems();
|
|
163
|
+
if (activeIndex >= 0 && activeIndex < visible.length) {
|
|
164
|
+
const item = visible[activeIndex];
|
|
165
|
+
this.config.selectOption({
|
|
166
|
+
value: item.value,
|
|
167
|
+
label: item.label || item.value,
|
|
168
|
+
searchText: item.searchText.length > 0 ? item.searchText.join(' ') : undefined,
|
|
169
|
+
group: item.group || undefined,
|
|
170
|
+
disabled: item.disabled,
|
|
171
|
+
icon: item.icon || undefined,
|
|
172
|
+
description: item.description || undefined,
|
|
173
|
+
data: item.data
|
|
174
|
+
});
|
|
175
|
+
} else if (this.host.mode === 'tags' || this.host.mode === 'creatable') {
|
|
176
|
+
this.config.handleCreate();
|
|
177
|
+
}
|
|
178
|
+
} else if (activeIndex >= 0 && activeIndex < options.length) {
|
|
179
|
+
this.config.selectOption(options[activeIndex]);
|
|
180
|
+
} else if (this.host.mode === 'tags' || this.host.mode === 'creatable') {
|
|
181
|
+
this.config.handleCreate();
|
|
182
|
+
}
|
|
183
|
+
} else if (this.host.mode === 'tags' || this.host.mode === 'creatable') {
|
|
184
|
+
this.config.handleCreate();
|
|
185
|
+
} else {
|
|
186
|
+
this.config.openDropdown();
|
|
187
|
+
}
|
|
188
|
+
break;
|
|
189
|
+
case ',':
|
|
190
|
+
if (this.host.mode === 'tags') {
|
|
191
|
+
e.preventDefault();
|
|
192
|
+
this.config.handleCreate();
|
|
193
|
+
}
|
|
194
|
+
break;
|
|
195
|
+
case 'Escape':
|
|
196
|
+
if (this.host.open) {
|
|
197
|
+
e.preventDefault();
|
|
198
|
+
this.config.close();
|
|
199
|
+
}
|
|
200
|
+
break;
|
|
201
|
+
case 'Backspace':
|
|
202
|
+
if (this.host.isSearchable && !this.config.getQuery() && (this.host.mode === 'multi' || this.host.mode === 'tags')) {
|
|
203
|
+
const selected = this.config.getSelectedValues();
|
|
204
|
+
if (selected.length > 0) {
|
|
205
|
+
this.config.removeTag(selected[selected.length - 1]);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
break;
|
|
209
|
+
case 'Home':
|
|
210
|
+
if (this.host.open) {
|
|
211
|
+
e.preventDefault();
|
|
212
|
+
const len = isSlotted ? this.config.getVisibleSlottedItems().length : options.length;
|
|
213
|
+
if (len > 0) this._navigate(1, 0);
|
|
214
|
+
}
|
|
215
|
+
break;
|
|
216
|
+
case 'End':
|
|
217
|
+
if (this.host.open) {
|
|
218
|
+
e.preventDefault();
|
|
219
|
+
const len = isSlotted ? this.config.getVisibleSlottedItems().length : options.length;
|
|
220
|
+
if (len > 0) this._navigate(-1, len - 1);
|
|
221
|
+
}
|
|
222
|
+
break;
|
|
223
|
+
case ' ':
|
|
224
|
+
if (!this.host.isSearchable && !this.host.open) {
|
|
225
|
+
e.preventDefault();
|
|
226
|
+
this.config.openDropdown();
|
|
227
|
+
} else if (!this.host.isSearchable && this.host.open && this._searchString.length > 0) {
|
|
228
|
+
e.preventDefault();
|
|
229
|
+
this._handleTypeAhead(' ');
|
|
230
|
+
}
|
|
231
|
+
break;
|
|
232
|
+
default:
|
|
233
|
+
if (!this.host.isSearchable && e.key.length === 1 && !e.ctrlKey && !e.altKey && !e.metaKey) {
|
|
234
|
+
e.preventDefault();
|
|
235
|
+
this._handleTypeAhead(e.key);
|
|
236
|
+
}
|
|
237
|
+
break;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
_handleTypeAhead(char) {
|
|
241
|
+
if (this._searchTimeout) {
|
|
242
|
+
clearTimeout(this._searchTimeout);
|
|
243
|
+
}
|
|
244
|
+
this._searchTimeout = setTimeout(()=>{
|
|
245
|
+
this._searchString = '';
|
|
246
|
+
this.config.onTypeAheadChange?.(this._searchString);
|
|
247
|
+
}, 1000);
|
|
248
|
+
this._searchString += char.toLowerCase();
|
|
249
|
+
this.config.onTypeAheadChange?.(this._searchString);
|
|
250
|
+
const options = this.config.getFilteredOptions();
|
|
251
|
+
const isSlotted = this.config.getSlottedItems().length > 0;
|
|
252
|
+
const visible = isSlotted ? this.config.getVisibleSlottedItems() : [];
|
|
253
|
+
const len = isSlotted ? visible.length : options.length;
|
|
254
|
+
if (len === 0) return;
|
|
255
|
+
const getLabel = (i)=>{
|
|
256
|
+
if (isSlotted) {
|
|
257
|
+
return (visible[i]?.label || visible[i]?.textContent || '').toLowerCase();
|
|
258
|
+
}
|
|
259
|
+
return (options[i]?.label || options[i]?.value || '').toLowerCase();
|
|
260
|
+
};
|
|
261
|
+
const isDisabled = (i)=>(isSlotted ? visible[i]?.disabled : options[i]?.disabled) ?? false;
|
|
262
|
+
// Start searching from current active index + 1
|
|
263
|
+
const startIdx = Math.max(0, this.config.getActiveIndex());
|
|
264
|
+
let matchIdx = -1;
|
|
265
|
+
// Search after current index
|
|
266
|
+
for(let i = startIdx + 1; i < len; i++){
|
|
267
|
+
if (!isDisabled(i) && getLabel(i).startsWith(this._searchString)) {
|
|
268
|
+
matchIdx = i;
|
|
269
|
+
break;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
// Wrap around to start
|
|
273
|
+
if (matchIdx === -1) {
|
|
274
|
+
for(let i = 0; i <= startIdx; i++){
|
|
275
|
+
if (!isDisabled(i) && getLabel(i).startsWith(this._searchString)) {
|
|
276
|
+
matchIdx = i;
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
if (matchIdx !== -1) {
|
|
282
|
+
this.config.setActiveIndex(matchIdx);
|
|
283
|
+
if (isSlotted) this.config.updateSlottedActiveState(matchIdx);
|
|
284
|
+
this.config.scrollToActiveIndex();
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
_navigate(direction, startFrom) {
|
|
288
|
+
const options = this.config.getFilteredOptions();
|
|
289
|
+
const isSlotted = this.config.getSlottedItems().length > 0;
|
|
290
|
+
const visible = isSlotted ? this.config.getVisibleSlottedItems() : [];
|
|
291
|
+
const len = isSlotted ? visible.length : options.length;
|
|
292
|
+
const isDisabled = (i)=>(isSlotted ? visible[i]?.disabled : options[i]?.disabled) ?? false;
|
|
293
|
+
if (len === 0) {
|
|
294
|
+
this.config.setActiveIndex(-1);
|
|
295
|
+
if (isSlotted) this.config.updateSlottedActiveState(-1);
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
let next = startFrom !== undefined ? startFrom : this.config.getActiveIndex();
|
|
299
|
+
if (startFrom === undefined && next === -1) {
|
|
300
|
+
next = direction === 1 ? -1 : 0;
|
|
301
|
+
} else if (startFrom !== undefined) {
|
|
302
|
+
if (!isDisabled(next)) {
|
|
303
|
+
this.config.setActiveIndex(next);
|
|
304
|
+
if (isSlotted) this.config.updateSlottedActiveState(next);
|
|
305
|
+
this.config.scrollToActiveIndex();
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
for(let step = 0; step < len; step++){
|
|
310
|
+
next = (next + direction + len) % len;
|
|
311
|
+
if (!isDisabled(next)) break;
|
|
312
|
+
}
|
|
313
|
+
if (isDisabled(next)) next = -1;
|
|
314
|
+
this.config.setActiveIndex(next);
|
|
315
|
+
if (isSlotted) this.config.updateSlottedActiveState(next);
|
|
316
|
+
this.config.scrollToActiveIndex();
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
export { FloatingController as F, ListboxKeyboardController as L };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vialiq/web-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
},
|
|
104
104
|
"peerDependencies": {
|
|
105
105
|
"@floating-ui/dom": ">=1.0.0",
|
|
106
|
-
"@vialiq/flux-ui": "^0.
|
|
106
|
+
"@vialiq/flux-ui": "^0.16.0",
|
|
107
107
|
"@vialiq/icons": ">=0.0.3 <0.1.0",
|
|
108
108
|
"lit": "^3.0.0"
|
|
109
109
|
},
|