@threadlabs/looma 0.1.28 → 0.2.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/dist/{chunk-G5AWV77V.js → chunk-JXSHRMYW.js} +32 -33
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/looma.cjs.js +1 -1
- package/dist/cjs/ui-chip_2.cjs.entry.js +190 -498
- package/dist/cjs/ui-combobox.cjs.entry.js +708 -0
- package/dist/cjs/ui-context-menu.cjs.entry.js +1 -1
- package/dist/cjs/ui-dialog.cjs.entry.js +1 -1
- package/dist/cjs/ui-disclosure.cjs.entry.js +1 -1
- package/dist/cjs/ui-editable.cjs.entry.js +3 -3
- package/dist/cjs/ui-floating-action-button.cjs.entry.js +1 -1
- package/dist/cjs/ui-form-field.cjs.entry.js +1 -1
- package/dist/cjs/ui-icon-button.cjs.entry.js +1 -1
- package/dist/cjs/ui-input.cjs.entry.js +1 -1
- package/dist/cjs/ui-menu-item.cjs.entry.js +1 -1
- package/dist/cjs/ui-menu.cjs.entry.js +1 -1
- package/dist/cjs/ui-popover.cjs.entry.js +1 -1
- package/dist/cjs/ui-radio-group.cjs.entry.js +1 -1
- package/dist/cjs/ui-radio.cjs.entry.js +1 -1
- package/dist/cjs/ui-search-result-row.cjs.entry.js +1 -1
- package/dist/cjs/ui-search-shell.cjs.entry.js +1 -1
- package/dist/cjs/ui-select.cjs.entry.js +1 -1
- package/dist/cjs/ui-switch.cjs.entry.js +2 -2
- package/dist/cjs/ui-tabs.cjs.entry.js +1 -1
- package/dist/cjs/ui-textarea.cjs.entry.js +1 -1
- package/dist/cjs/ui-toast-region.cjs.entry.js +1 -1
- package/dist/cjs/ui-top-bar.cjs.entry.js +1 -1
- package/dist/cjs/ui-tree-item.cjs.entry.js +2 -2
- package/dist/cjs/ui-tree.cjs.entry.js +1 -1
- package/dist/collection/collection-manifest.json +0 -1
- package/dist/collection/components/ui-combobox/ui-combobox.css +23 -0
- package/dist/collection/components/ui-combobox/ui-combobox.js +298 -21
- package/dist/collection/components/ui-context-menu/ui-context-menu.js +1 -1
- package/dist/collection/components/ui-dialog/ui-dialog.js +1 -1
- package/dist/collection/components/ui-disclosure/ui-disclosure.js +1 -1
- package/dist/collection/components/ui-editable/ui-editable.js +3 -3
- package/dist/collection/components/ui-floating-action-button/ui-floating-action-button.js +1 -1
- package/dist/collection/components/ui-form-field/ui-form-field.js +1 -1
- package/dist/collection/components/ui-icon-button/ui-icon-button.js +1 -1
- package/dist/collection/components/ui-input/ui-input.js +1 -1
- package/dist/collection/components/ui-menu/ui-menu.js +1 -1
- package/dist/collection/components/ui-menu-item/ui-menu-item.js +1 -1
- package/dist/collection/components/ui-popover/ui-popover.js +1 -1
- package/dist/collection/components/ui-radio/ui-radio.js +1 -1
- package/dist/collection/components/ui-radio-group/ui-radio-group.js +1 -1
- package/dist/collection/components/ui-search-result-row/ui-search-result-row.js +1 -1
- package/dist/collection/components/ui-search-shell/ui-search-shell.js +1 -1
- package/dist/collection/components/ui-select/ui-select.js +1 -1
- package/dist/collection/components/ui-switch/ui-switch.js +2 -2
- package/dist/collection/components/ui-tabs/ui-tabs.js +1 -1
- package/dist/collection/components/ui-textarea/ui-textarea.js +1 -1
- package/dist/collection/components/ui-toast-region/ui-toast-region.js +1 -1
- package/dist/collection/components/ui-tooltip/ui-tooltip.js +1 -1
- package/dist/collection/components/ui-top-bar/ui-top-bar.js +1 -1
- package/dist/collection/components/ui-tree/ui-tree.js +1 -1
- package/dist/collection/components/ui-tree-item/ui-tree-item.js +2 -2
- package/dist/components/index.d.ts +0 -2
- package/dist/components/index.js +1 -1
- package/dist/components/{p-B1macZOS.js → p-DWN2m6ta.js} +1 -1
- package/dist/components/p-DYiNETk6.js +1 -0
- package/dist/components/ui-combobox.js +1 -1
- package/dist/components/ui-context-menu.js +1 -1
- package/dist/components/ui-dialog.js +1 -1
- package/dist/components/ui-disclosure.js +1 -1
- package/dist/components/ui-editable.js +1 -1
- package/dist/components/ui-floating-action-button.js +1 -1
- package/dist/components/ui-form-field.js +1 -1
- package/dist/components/ui-icon-button.js +1 -1
- package/dist/components/ui-input.js +1 -1
- package/dist/components/ui-menu-item.js +1 -1
- package/dist/components/ui-menu.js +1 -1
- package/dist/components/ui-popover.js +1 -1
- package/dist/components/ui-radio-group.js +1 -1
- package/dist/components/ui-radio.js +1 -1
- package/dist/components/ui-search-result-row.js +1 -1
- package/dist/components/ui-search-shell.js +1 -1
- package/dist/components/ui-select.js +1 -1
- package/dist/components/ui-switch.js +1 -1
- package/dist/components/ui-tabs.js +1 -1
- package/dist/components/ui-textarea.js +1 -1
- package/dist/components/ui-toast-region.js +1 -1
- package/dist/components/ui-tooltip.js +1 -1
- package/dist/components/ui-top-bar.js +1 -1
- package/dist/components/ui-tree-item.js +1 -1
- package/dist/components/ui-tree.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/looma.js +1 -1
- package/dist/esm/ui-chip_2.entry.js +192 -500
- package/dist/esm/ui-combobox.entry.js +706 -0
- package/dist/esm/ui-context-menu.entry.js +1 -1
- package/dist/esm/ui-dialog.entry.js +1 -1
- package/dist/esm/ui-disclosure.entry.js +1 -1
- package/dist/esm/ui-editable.entry.js +3 -3
- package/dist/esm/ui-floating-action-button.entry.js +1 -1
- package/dist/esm/ui-form-field.entry.js +1 -1
- package/dist/esm/ui-icon-button.entry.js +1 -1
- package/dist/esm/ui-input.entry.js +1 -1
- package/dist/esm/ui-menu-item.entry.js +1 -1
- package/dist/esm/ui-menu.entry.js +1 -1
- package/dist/esm/ui-popover.entry.js +1 -1
- package/dist/esm/ui-radio-group.entry.js +1 -1
- package/dist/esm/ui-radio.entry.js +1 -1
- package/dist/esm/ui-search-result-row.entry.js +1 -1
- package/dist/esm/ui-search-shell.entry.js +1 -1
- package/dist/esm/ui-select.entry.js +1 -1
- package/dist/esm/ui-switch.entry.js +2 -2
- package/dist/esm/ui-tabs.entry.js +1 -1
- package/dist/esm/ui-textarea.entry.js +1 -1
- package/dist/esm/ui-toast-region.entry.js +1 -1
- package/dist/esm/ui-top-bar.entry.js +1 -1
- package/dist/esm/ui-tree-item.entry.js +2 -2
- package/dist/esm/ui-tree.entry.js +1 -1
- package/dist/index.cjs +471 -514
- package/dist/index.js +2 -2
- package/dist/looma/looma.esm.js +1 -1
- package/dist/looma/{p-9a82c523.entry.js → p-1249a806.entry.js} +1 -1
- package/dist/looma/p-1c00670f.entry.js +1 -0
- package/dist/looma/p-22842f8c.entry.js +1 -0
- package/dist/looma/{p-1e1de77f.entry.js → p-2915d5c0.entry.js} +1 -1
- package/dist/looma/{p-88e61cab.entry.js → p-37ec2b4b.entry.js} +1 -1
- package/dist/looma/{p-2f3c1b57.entry.js → p-3b2961a6.entry.js} +1 -1
- package/dist/looma/{p-e07e6ac2.entry.js → p-3f60f4c8.entry.js} +1 -1
- package/dist/looma/{p-9551ebf6.entry.js → p-424d6719.entry.js} +1 -1
- package/dist/looma/{p-6cc3180b.entry.js → p-4caccfce.entry.js} +1 -1
- package/dist/looma/p-55e06e2e.entry.js +1 -0
- package/dist/looma/{p-3957f7ef.entry.js → p-56dac38a.entry.js} +1 -1
- package/dist/looma/p-5cbbf7a0.entry.js +1 -0
- package/dist/looma/{p-f431dc13.entry.js → p-6f20d470.entry.js} +1 -1
- package/dist/looma/{p-b68762f2.entry.js → p-7c0b5364.entry.js} +1 -1
- package/dist/looma/{p-e82f104c.entry.js → p-8bdd9495.entry.js} +1 -1
- package/dist/looma/{p-df696cca.entry.js → p-9cfbf722.entry.js} +1 -1
- package/dist/looma/{p-607c3056.entry.js → p-b6ede6bb.entry.js} +1 -1
- package/dist/looma/p-b6fb6ba3.entry.js +1 -0
- package/dist/looma/{p-da6e2d01.entry.js → p-b76e2111.entry.js} +1 -1
- package/dist/looma/{p-1a12eb5c.entry.js → p-d372b0db.entry.js} +1 -1
- package/dist/looma/p-d46317e0.entry.js +1 -0
- package/dist/looma/{p-20387ffa.entry.js → p-d4825822.entry.js} +1 -1
- package/dist/looma/{p-8a5e3fe1.entry.js → p-d5c3954f.entry.js} +1 -1
- package/dist/looma/{p-4f68f939.entry.js → p-e604e906.entry.js} +1 -1
- package/dist/looma/{p-e406656e.entry.js → p-f1f7c5cb.entry.js} +1 -1
- package/dist/types/components/ui-combobox/ui-combobox.d.ts +35 -4
- package/dist/types/components.d.ts +56 -153
- package/dist/{ui-affordance-scope.entry-X5526PRP.js → ui-affordance-scope.entry-VR7FLAWG.js} +1 -1
- package/dist/{ui-avatar-group.entry-U72MPB5K.js → ui-avatar-group.entry-L3UKOY3U.js} +1 -1
- package/dist/{ui-avatar.entry-OC4J3LTV.js → ui-avatar.entry-VM5OHEFQ.js} +1 -1
- package/dist/{ui-badge.entry-4MSUQRQV.js → ui-badge.entry-ZTM4OPUD.js} +1 -1
- package/dist/{ui-button.entry-22DESWN4.js → ui-button.entry-CIPUSV5B.js} +1 -1
- package/dist/{ui-callout.entry-LOGODDM5.js → ui-callout.entry-OBFCI2O7.js} +1 -1
- package/dist/{ui-checkbox.entry-XAGW3BW4.js → ui-checkbox.entry-XT6ET56H.js} +1 -1
- package/dist/{ui-tooltip.entry-AQ6UPBUP.js → ui-chip_2.entry-32SHCLV6.js} +18 -3
- package/dist/{ui-chip_2.entry-JCPHPXAG.js → ui-combobox.entry-ONBBPQ2C.js} +169 -30
- package/dist/{ui-context-menu.entry-24YOHF7L.js → ui-context-menu.entry-RXNUOK24.js} +2 -2
- package/dist/{ui-dialog.entry-XKNYDWOQ.js → ui-dialog.entry-IJXNUARC.js} +2 -2
- package/dist/{ui-disclosure.entry-2AWCGZ4C.js → ui-disclosure.entry-5QS7UDRH.js} +2 -2
- package/dist/{ui-editable.entry-HLEWO7BN.js → ui-editable.entry-D7LOQN2H.js} +3 -3
- package/dist/{ui-floating-action-button.entry-2NJDB4YN.js → ui-floating-action-button.entry-XQZCTZQT.js} +2 -2
- package/dist/{ui-form-field.entry-FJ5HYCTN.js → ui-form-field.entry-A654LJZE.js} +2 -2
- package/dist/{ui-icon-button.entry-YZHJQ5YR.js → ui-icon-button.entry-MJ7F7ZIH.js} +2 -2
- package/dist/{ui-input.entry-JMBLMNP6.js → ui-input.entry-B2XM7JQU.js} +2 -2
- package/dist/{ui-menu-item.entry-VBGXM66D.js → ui-menu-item.entry-JULYSFVW.js} +2 -2
- package/dist/{ui-menu.entry-I2N5H3YC.js → ui-menu.entry-ORRWW7HD.js} +2 -2
- package/dist/{ui-popover.entry-7JRSJM5S.js → ui-popover.entry-W67V4UPA.js} +2 -2
- package/dist/{ui-radio-group.entry-Q2XB7P3B.js → ui-radio-group.entry-KCFOR27M.js} +2 -2
- package/dist/{ui-radio.entry-NJO4NA4M.js → ui-radio.entry-I2P4V5E3.js} +2 -2
- package/dist/{ui-search-result-row.entry-RPMNDSRN.js → ui-search-result-row.entry-GHODLSLR.js} +2 -2
- package/dist/{ui-search-shell.entry-FMIMYD3B.js → ui-search-shell.entry-PDB5UN4B.js} +2 -2
- package/dist/{ui-select.entry-7NDBWNAU.js → ui-select.entry-D3CZHCKB.js} +2 -2
- package/dist/{ui-switch.entry-YUCPIZE4.js → ui-switch.entry-WUDRL4H5.js} +3 -3
- package/dist/{ui-tabs.entry-FXZWV665.js → ui-tabs.entry-MW64GKIJ.js} +2 -2
- package/dist/{ui-textarea.entry-HHLQR5GG.js → ui-textarea.entry-VHRBYY6G.js} +2 -2
- package/dist/{ui-toast-region.entry-PIIBHNYA.js → ui-toast-region.entry-ET75RWYP.js} +2 -2
- package/dist/{ui-top-bar.entry-S2L7ZM4U.js → ui-top-bar.entry-QIYA3LD3.js} +2 -2
- package/dist/{ui-tree-item.entry-UID7IJPA.js → ui-tree-item.entry-BDB7VEUS.js} +3 -3
- package/dist/{ui-tree.entry-UMD3DNG5.js → ui-tree.entry-GSC7BPRN.js} +2 -2
- package/package.json +1 -1
- package/vue/{chunk-2DDIBSFD.js → chunk-ROMBQS2L.js} +32 -89
- package/vue/editor/index.js +1 -1
- package/vue/index.d.ts +30 -107
- package/vue/index.js +1 -3
- package/dist/cjs/ui-multi-combobox.cjs.entry.js +0 -190
- package/dist/cjs/ui-tooltip.cjs.entry.js +0 -241
- package/dist/collection/components/ui-multi-combobox/ui-multi-combobox.css +0 -33
- package/dist/collection/components/ui-multi-combobox/ui-multi-combobox.js +0 -553
- package/dist/components/p-DiyiodGX.js +0 -1
- package/dist/components/p-d5fk1vBI.js +0 -1
- package/dist/components/ui-multi-combobox.d.ts +0 -11
- package/dist/components/ui-multi-combobox.js +0 -1
- package/dist/esm/ui-multi-combobox.entry.js +0 -188
- package/dist/esm/ui-tooltip.entry.js +0 -239
- package/dist/looma/p-071c139c.entry.js +0 -1
- package/dist/looma/p-311e54d4.entry.js +0 -1
- package/dist/looma/p-4a10a875.entry.js +0 -1
- package/dist/looma/p-4fc9917f.entry.js +0 -1
- package/dist/looma/p-63a9159f.entry.js +0 -1
- package/dist/looma/p-82de1112.entry.js +0 -1
- package/dist/looma/p-caa37be2.entry.js +0 -1
- package/dist/types/components/ui-multi-combobox/ui-multi-combobox.d.ts +0 -51
- package/dist/ui-multi-combobox.entry-MEX7MU7P.js +0 -196
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var index = require('./index-BHG9Rpil.js');
|
|
4
|
-
var positioning = require('./positioning-D5q9DM-0.js');
|
|
5
4
|
var manager = require('./manager-Ce25WRtl.js');
|
|
5
|
+
var events = require('./events-TcQIzpNv.js');
|
|
6
|
+
var controlledState = require('./controlled-state-BFya8rAX.js');
|
|
7
|
+
var positioning = require('./positioning-D5q9DM-0.js');
|
|
6
8
|
|
|
7
9
|
const uiChipCss = () => `:host{--ui-chip-surface:var(--ui-surface-subtle);--ui-chip-text:var(--ui-text-secondary);--ui-chip-border:var(--ui-border-default);--ui-chip-font-size:var(--ui-font-size-xs);--ui-chip-font-weight:var(--ui-font-normal);--ui-chip-line-height:var(--ui-line-height-tight);--ui-chip-padding-block:var(--ui-space-0-5);--ui-chip-padding-inline:var(--ui-space-2);--ui-chip-notch:var(--ui-space-1);display:inline-flex;min-width:0;max-width:100%}:host([data-size='sm']){--ui-chip-font-size:var(--ui-font-size-sm)}.chip__surface{display:inline-flex;align-items:center;box-sizing:border-box;min-width:0;max-width:100%;padding:var(--ui-chip-padding-block) var(--ui-chip-padding-inline);border:1px solid var(--ui-chip-border);background:var(--ui-chip-surface);color:var(--ui-chip-text) !important;font-family:var(--ui-font-family-sans) !important;font-size:var(--ui-chip-font-size) !important;font-weight:var(--ui-chip-font-weight) !important;line-height:var(--ui-chip-line-height) !important}.chip__label{min-width:0;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}:host([data-appearance='pill']) .chip__surface{border-radius:var(--ui-radius-round)}:host([data-appearance='tag']) .chip__surface{border:0;padding-inline-end:calc(var(--ui-chip-padding-inline) + var(--ui-chip-notch));clip-path:polygon(0 0, calc(100% - var(--ui-chip-notch)) 0, 100% 50%, calc(100% - var(--ui-chip-notch)) 100%, 0 100%)}`;
|
|
8
10
|
|
|
@@ -20,547 +22,237 @@ const UIChip = class {
|
|
|
20
22
|
};
|
|
21
23
|
UIChip.style = uiChipCss();
|
|
22
24
|
|
|
23
|
-
|
|
24
|
-
* Normalization belongs to submitted output, never the visible editing buffer. */
|
|
25
|
-
function formatEditingValue(raw, selection, format) {
|
|
26
|
-
const unchanged = { display: raw, selection };
|
|
27
|
-
if (!format)
|
|
28
|
-
return unchanged;
|
|
29
|
-
let result;
|
|
30
|
-
try {
|
|
31
|
-
result = format(raw, selection);
|
|
32
|
-
}
|
|
33
|
-
catch {
|
|
34
|
-
return unchanged;
|
|
35
|
-
}
|
|
36
|
-
if (!result)
|
|
37
|
-
return unchanged;
|
|
38
|
-
const characters = Array.from(raw);
|
|
39
|
-
let cursor = 0;
|
|
40
|
-
for (const character of result.display)
|
|
41
|
-
if (character === characters[cursor])
|
|
42
|
-
cursor += 1;
|
|
43
|
-
if (!Number.isInteger(result.selection.start) || !Number.isInteger(result.selection.end) || cursor !== characters.length || result.selection.start < 0 || result.selection.end < result.selection.start
|
|
44
|
-
|| result.selection.end > result.display.length)
|
|
45
|
-
return unchanged;
|
|
46
|
-
return result;
|
|
47
|
-
}
|
|
48
|
-
async function validateField(request, config) {
|
|
49
|
-
let output = request.raw;
|
|
50
|
-
let issues = [];
|
|
51
|
-
const check = () => request.signal.throwIfAborted();
|
|
52
|
-
try {
|
|
53
|
-
check();
|
|
54
|
-
if (config.parse)
|
|
55
|
-
output = await config.parse(request.raw, request);
|
|
56
|
-
check();
|
|
57
|
-
if (config.schema) {
|
|
58
|
-
const result = await config.schema['~standard'].validate(output);
|
|
59
|
-
check();
|
|
60
|
-
if (result.issues)
|
|
61
|
-
issues = result.issues;
|
|
62
|
-
else if ('value' in result)
|
|
63
|
-
output = result.value;
|
|
64
|
-
}
|
|
65
|
-
if (!issues.some(issue => issue.severity !== 'warning')) {
|
|
66
|
-
if (config.normalize)
|
|
67
|
-
output = await config.normalize(output, request);
|
|
68
|
-
check();
|
|
69
|
-
if (config.validator) {
|
|
70
|
-
const result = await config.validator(output, request);
|
|
71
|
-
check();
|
|
72
|
-
issues = [...issues, ...(result.issues ?? [])];
|
|
73
|
-
if ('output' in result)
|
|
74
|
-
output = result.output;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
catch (error) {
|
|
79
|
-
check();
|
|
80
|
-
issues = [{ message: error instanceof Error ? error.message : 'Unable to validate this value.' }];
|
|
81
|
-
}
|
|
82
|
-
issues = [...issues, ...(config.issues ?? [])];
|
|
83
|
-
return { output: issues.some(issue => issue.severity !== 'warning') ? undefined : output, issues };
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const uiComboboxCss = () => `:host{display:grid;gap:var(--ui-space-1);min-inline-size:0;color:var(--ui-text-primary);font:inherit}label{color:var(--ui-field-label-color, var(--ui-text-primary));font-size:var(--ui-field-label-size, 0.875rem);font-weight:var(--ui-field-label-weight, 500)}.field{display:flex;min-inline-size:0;border:1px solid var(--ui-control-border, var(--ui-border-default));border-radius:var(--ui-radius-2);background:var(--ui-control-surface, var(--ui-surface-default))}.field:focus-within{border-color:var(--ui-control-focus, var(--ui-focus-ring));outline:2px solid var(--ui-control-focus, var(--ui-focus-ring));outline-offset:1px}input{appearance:none;width:100%;min-inline-size:0;min-block-size:var(--ui-control-min-block-size, 2.75rem);box-sizing:border-box;border:0;border-radius:inherit;background:transparent;color:inherit;font:inherit;line-height:var(--ui-line-height-md);padding:var(--ui-space-2) var(--ui-space-3);margin:0;outline:none}:host([data-size='sm']) input{min-block-size:var(--ui-field-compact-size, 2rem);padding:var(--ui-space-1) var(--ui-space-2)}button{appearance:none;border:0;border-radius:var(--ui-radius-2);background:transparent;color:var(--ui-field-affordance-color, var(--ui-text-secondary));font:inherit;font-weight:var(--ui-field-affordance-weight, 400);min-inline-size:2rem;padding:var(--ui-space-1);cursor:pointer}button:hover:enabled{background:var(--ui-surface-muted);color:var(--ui-text-primary)}button:focus-visible{outline:2px solid var(--ui-focus-ring);outline-offset:-3px}input:disabled,button:disabled{color:var(--ui-text-muted);cursor:not-allowed}.field:has(input:disabled){background:var(--ui-control-surface-disabled, var(--ui-surface-muted))}:host([data-validation='error']) .field{border-color:var(--ui-danger-solid, var(--ui-accent-active))}.popup{box-sizing:border-box;min-inline-size:12rem;max-inline-size:calc(100vw - 1rem);max-block-size:var(--ui-combobox-max-block-size, 18rem);overflow:auto;margin:0;padding:var(--ui-space-1);border:1px solid var(--ui-border-default);border-radius:var(--ui-radius-2);background:var(--ui-surface-elevated);color:var(--ui-text-primary);box-shadow:var(--ui-shadow-md)}[hidden]{display:none !important}.option{padding:var(--ui-space-2) var(--ui-space-3);border-radius:var(--ui-radius-1);cursor:pointer;overflow-wrap:anywhere}.option:hover,.option[data-active]{background:var(--ui-surface-muted);outline:1px solid var(--ui-focus-ring);outline-offset:-1px}.option[aria-disabled='true']{color:var(--ui-text-muted);cursor:not-allowed}.primary{display:block;color:var(--ui-option-primary-color, var(--ui-text-primary));font-weight:var(--ui-option-primary-weight, 500)}.secondary{display:block;color:var(--ui-option-secondary-color, var(--ui-text-secondary));font-weight:var(--ui-option-secondary-weight, 400);font-size:var(--ui-font-size-sm)}.message,.group{color:var(--ui-field-message-color, var(--ui-text-secondary));font-weight:var(--ui-field-message-weight, 400);font-size:var(--ui-font-size-sm);line-height:var(--ui-line-height-md);overflow-wrap:anywhere}.group,.popup .message{padding:var(--ui-space-2) var(--ui-space-3)}.sr-only{position:absolute;inline-size:1px;block-size:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}@media (pointer: coarse){button{min-inline-size:2.75rem;min-block-size:2.75rem}}@media (forced-colors: active){.field,.popup{border-color:CanvasText}.option[data-active]{outline-color:Highlight}}`;
|
|
25
|
+
const uiTooltipCss = () => `:host{position:fixed;inset:auto;margin:0;display:inline-block;box-sizing:border-box;padding:0;border:0;border-radius:0;background:transparent;opacity:0;transform:translateY(4px);transition:opacity var(--ui-motion-fast) var(--ui-motion-ease), transform var(--ui-motion-fast) var(--ui-motion-ease), display var(--ui-motion-fast) allow-discrete, overlay var(--ui-motion-fast) allow-discrete}.tooltip__surface{box-sizing:border-box;border:1px solid var(--ui-border-default);border-radius:var(--ui-radius-2);background:var(--ui-surface-elevated);color:var(--ui-text-primary);padding:var(--ui-space-2) var(--ui-space-3);font-size:var(--ui-font-size-sm);box-shadow:var(--ui-shadow-md)}:host(:popover-open){opacity:1;transform:translateY(0)}@starting-style{:host(:popover-open){opacity:0;transform:translateY(4px)}}:host([hidden]){display:none !important}@media (prefers-reduced-motion: reduce){:host{transition:none}}`;
|
|
87
26
|
|
|
88
|
-
const
|
|
27
|
+
const UITooltip = class {
|
|
89
28
|
constructor(hostRef) {
|
|
90
29
|
index.registerInstance(this, hostRef);
|
|
91
|
-
this.
|
|
92
|
-
this.
|
|
93
|
-
this.freeEntry = index.createEvent(this, "free-entry");
|
|
94
|
-
this.createEntry = index.createEvent(this, "create-entry");
|
|
95
|
-
this.dependencyInvalidate = index.createEvent(this, "dependency-invalidate");
|
|
96
|
-
this.validationChange = index.createEvent(this, "validation-change");
|
|
97
|
-
this.optionsChange = index.createEvent(this, "options-change");
|
|
30
|
+
this.opened = index.createEvent(this, "open");
|
|
31
|
+
this.closed = index.createEvent(this, "close");
|
|
98
32
|
}
|
|
99
33
|
get host() { return index.getElement(this); }
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
lookupTimer;
|
|
147
|
-
composing = false;
|
|
148
|
-
initialRaw = '';
|
|
149
|
-
overlayId = `ui-combobox-${Math.random().toString(36).slice(2)}`;
|
|
150
|
-
alive = false;
|
|
151
|
-
fullSet = false;
|
|
152
|
-
knownOptions = new Map();
|
|
153
|
-
awaitingLabel = null;
|
|
154
|
-
proposedChange;
|
|
155
|
-
formattedRaw;
|
|
156
|
-
formattedWith;
|
|
157
|
-
componentWillLoad() {
|
|
158
|
-
this.selected = this.value !== undefined ? this.value : this.defaultValue ?? null;
|
|
159
|
-
this.raw = this.query ?? this.defaultQuery;
|
|
160
|
-
if (this.query === undefined && !this.raw && this.selected !== null) {
|
|
161
|
-
this.raw = this.config.options?.find(row => row.value === this.selected)?.label ?? this.selected;
|
|
34
|
+
for = '';
|
|
35
|
+
/** Controlled open state. Omit it to use defaultOpen and local interaction state. */
|
|
36
|
+
open;
|
|
37
|
+
defaultOpen = false;
|
|
38
|
+
placement = 'top-start';
|
|
39
|
+
/** Pointer hover intent delay in milliseconds. Keyboard focus is immediate. */
|
|
40
|
+
showDelay = 500;
|
|
41
|
+
/** Pointer leave grace period in milliseconds. */
|
|
42
|
+
hideDelay = 100;
|
|
43
|
+
/** Click or tap pins the description; activate again to dismiss. */
|
|
44
|
+
toggleOnClick = false;
|
|
45
|
+
pinned = false;
|
|
46
|
+
focused = false;
|
|
47
|
+
opened;
|
|
48
|
+
closed;
|
|
49
|
+
internalOpen = false;
|
|
50
|
+
overlayId = `ui-tooltip-${Math.random().toString(36).slice(2, 11)}`;
|
|
51
|
+
trigger = null;
|
|
52
|
+
surface = null;
|
|
53
|
+
showTimer = null;
|
|
54
|
+
hideTimer = null;
|
|
55
|
+
syncFromProp() {
|
|
56
|
+
this.clearTimers();
|
|
57
|
+
if (controlledState.isControlled(this.open))
|
|
58
|
+
this.internalOpen = this.open;
|
|
59
|
+
}
|
|
60
|
+
resetSurface() {
|
|
61
|
+
this.syncTrigger();
|
|
62
|
+
this.setupSurface();
|
|
63
|
+
this.syncOverlay();
|
|
64
|
+
}
|
|
65
|
+
syncOverlay() {
|
|
66
|
+
if (this.internalOpen) {
|
|
67
|
+
this.surface?.show();
|
|
68
|
+
manager.openOverlay({
|
|
69
|
+
id: this.overlayId,
|
|
70
|
+
modal: false,
|
|
71
|
+
element: this.host,
|
|
72
|
+
relatedElements: this.trigger ? [this.trigger] : undefined,
|
|
73
|
+
dismissible: true,
|
|
74
|
+
requestClose: (reason, trigger) => this.handleRequestClose(reason, trigger),
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
this.surface?.hide();
|
|
79
|
+
manager.closeOverlay(this.overlayId);
|
|
162
80
|
}
|
|
163
|
-
if (this.query === undefined && this.selected !== null && this.raw === this.selected)
|
|
164
|
-
this.awaitingLabel = this.selected;
|
|
165
|
-
this.display = this.raw;
|
|
166
|
-
this.initialRaw = this.raw;
|
|
167
|
-
this.applyServerIssues();
|
|
168
81
|
}
|
|
169
|
-
|
|
170
|
-
|
|
82
|
+
componentDidLoad() {
|
|
83
|
+
if (!this.host.id)
|
|
84
|
+
this.host.id = this.overlayId;
|
|
85
|
+
this.internalOpen = controlledState.controlledOrDefault(this.open, this.defaultOpen);
|
|
86
|
+
this.syncTrigger();
|
|
87
|
+
this.setupSurface();
|
|
88
|
+
this.host.addEventListener('pointerenter', this.onSurfaceEnter);
|
|
89
|
+
this.host.addEventListener('pointerleave', this.onTriggerLeave);
|
|
90
|
+
this.syncOverlay();
|
|
91
|
+
}
|
|
171
92
|
componentDidUpdate() {
|
|
172
|
-
|
|
173
|
-
this.input.value = this.display;
|
|
174
|
-
if (this.expanded)
|
|
175
|
-
this.surface?.refresh();
|
|
93
|
+
this.syncTrigger();
|
|
176
94
|
}
|
|
177
95
|
disconnectedCallback() {
|
|
178
|
-
this.
|
|
179
|
-
this.
|
|
180
|
-
this.validationRun?.abort();
|
|
96
|
+
this.clearTimers();
|
|
97
|
+
this.detachTriggerListeners();
|
|
181
98
|
this.surface?.destroy();
|
|
182
|
-
this.surface =
|
|
99
|
+
this.surface = null;
|
|
100
|
+
this.host.removeEventListener('pointerenter', this.onSurfaceEnter);
|
|
101
|
+
this.host.removeEventListener('pointerleave', this.onTriggerLeave);
|
|
102
|
+
manager.closeOverlay(this.overlayId);
|
|
103
|
+
}
|
|
104
|
+
syncTrigger() {
|
|
105
|
+
const next = this.for
|
|
106
|
+
? this.host.getRootNode().getElementById(this.for)
|
|
107
|
+
: this.host.previousElementSibling;
|
|
108
|
+
if (next === this.trigger)
|
|
109
|
+
return;
|
|
110
|
+
this.detachTriggerListeners();
|
|
111
|
+
this.trigger = next;
|
|
112
|
+
this.attachTriggerListeners();
|
|
113
|
+
this.surface?.setAnchor(next);
|
|
183
114
|
}
|
|
184
115
|
setupSurface() {
|
|
185
|
-
|
|
186
|
-
|
|
116
|
+
this.surface?.destroy();
|
|
117
|
+
this.surface = positioning.createAnchoredSurface(this.host, {
|
|
118
|
+
anchor: this.trigger,
|
|
119
|
+
placement: this.placement,
|
|
120
|
+
});
|
|
187
121
|
}
|
|
188
|
-
|
|
189
|
-
|
|
122
|
+
attachTriggerListeners() {
|
|
123
|
+
this.detachTriggerListeners();
|
|
124
|
+
if (!this.trigger)
|
|
190
125
|
return;
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
this.formattedRaw = undefined;
|
|
201
|
-
}
|
|
202
|
-
this.awaitingLabel = !option && this.selected !== null ? this.selected : null;
|
|
203
|
-
}
|
|
204
|
-
this.resetValidation();
|
|
126
|
+
const ids = new Set((this.trigger.getAttribute('aria-describedby') || '').split(/\s+/).filter(Boolean));
|
|
127
|
+
ids.add(this.host.id);
|
|
128
|
+
this.trigger.setAttribute('aria-describedby', [...ids].join(' '));
|
|
129
|
+
this.trigger.addEventListener('click', this.onTriggerClick);
|
|
130
|
+
this.trigger.addEventListener('keydown', this.onTriggerKeydown);
|
|
131
|
+
this.trigger.addEventListener('pointerenter', this.onTriggerEnter);
|
|
132
|
+
this.trigger.addEventListener('pointerleave', this.onTriggerLeave);
|
|
133
|
+
this.trigger.addEventListener('focusin', this.onTriggerFocusIn);
|
|
134
|
+
this.trigger.addEventListener('focusout', this.onTriggerFocusOut);
|
|
205
135
|
}
|
|
206
|
-
|
|
207
|
-
if (this.
|
|
136
|
+
detachTriggerListeners() {
|
|
137
|
+
if (!this.trigger)
|
|
208
138
|
return;
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
this.selected = null;
|
|
213
|
-
this.awaitingLabel = null;
|
|
214
|
-
this.formattedRaw = undefined;
|
|
215
|
-
this.raw = this.query;
|
|
216
|
-
this.display = this.raw;
|
|
217
|
-
this.resetValidation();
|
|
218
|
-
if (this.expanded)
|
|
219
|
-
this.search('input');
|
|
220
|
-
}
|
|
221
|
-
syncDisabled() {
|
|
222
|
-
if (this.disabled || this.readOnly) {
|
|
223
|
-
this.close();
|
|
224
|
-
this.resetValidation();
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
syncConfig(next, previous) {
|
|
228
|
-
this.validationRun?.abort();
|
|
229
|
-
if (next.provider !== previous?.provider || next.context !== previous?.context)
|
|
230
|
-
this.knownOptions.clear();
|
|
231
|
-
if (next.context !== previous?.context) {
|
|
232
|
-
this.close();
|
|
233
|
-
const policy = next.invalidation ?? 'retain-query';
|
|
234
|
-
const value = policy === 'retain' ? this.selected : null;
|
|
235
|
-
const query = policy === 'clear' ? '' : this.raw;
|
|
236
|
-
this.commit(value, query, null, 'invalidation', 'programmatic');
|
|
237
|
-
this.validation = { status: 'pristine', touched: false, dirty: this.raw !== this.initialRaw, issues: [] };
|
|
238
|
-
}
|
|
239
|
-
this.applyServerIssues();
|
|
240
|
-
if (this.expanded)
|
|
241
|
-
this.search('context');
|
|
242
|
-
}
|
|
243
|
-
applyServerIssues() {
|
|
244
|
-
const issues = this.config.issues ?? [];
|
|
245
|
-
if (issues.length)
|
|
246
|
-
this.setValidation({ issues }, this.validation.touched);
|
|
139
|
+
const ids = (this.trigger.getAttribute('aria-describedby') || '').split(/\s+/).filter(id => id && id !== this.host.id);
|
|
140
|
+
if (ids.length)
|
|
141
|
+
this.trigger.setAttribute('aria-describedby', ids.join(' '));
|
|
247
142
|
else
|
|
248
|
-
this.
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
this.
|
|
252
|
-
this.
|
|
253
|
-
this.
|
|
254
|
-
|
|
255
|
-
cancelLookup() {
|
|
256
|
-
clearTimeout(this.lookupTimer);
|
|
257
|
-
this.lookup?.abort();
|
|
258
|
-
this.lookup = undefined;
|
|
259
|
-
this.loading = false;
|
|
260
|
-
}
|
|
261
|
-
close() {
|
|
262
|
-
this.expanded = false;
|
|
263
|
-
this.active = -1;
|
|
264
|
-
this.cancelLookup();
|
|
265
|
-
this.surface?.hide();
|
|
266
|
-
manager.closeOverlay(this.overlayId);
|
|
143
|
+
this.trigger.removeAttribute('aria-describedby');
|
|
144
|
+
this.trigger.removeEventListener('click', this.onTriggerClick);
|
|
145
|
+
this.trigger.removeEventListener('keydown', this.onTriggerKeydown);
|
|
146
|
+
this.trigger.removeEventListener('pointerenter', this.onTriggerEnter);
|
|
147
|
+
this.trigger.removeEventListener('pointerleave', this.onTriggerLeave);
|
|
148
|
+
this.trigger.removeEventListener('focusin', this.onTriggerFocusIn);
|
|
149
|
+
this.trigger.removeEventListener('focusout', this.onTriggerFocusOut);
|
|
267
150
|
}
|
|
268
|
-
|
|
269
|
-
if (this.
|
|
151
|
+
clearShowTimer() {
|
|
152
|
+
if (this.showTimer === null)
|
|
270
153
|
return;
|
|
271
|
-
this.
|
|
272
|
-
|
|
273
|
-
this.popup.style.minWidth = `${this.field.getBoundingClientRect().width}px`;
|
|
274
|
-
this.surface?.show();
|
|
275
|
-
manager.openOverlay({ id: this.overlayId, element: this.popup, relatedElements: [this.host], modal: false,
|
|
276
|
-
requestClose: () => this.close() });
|
|
277
|
-
this.search(reason);
|
|
154
|
+
clearTimeout(this.showTimer);
|
|
155
|
+
this.showTimer = null;
|
|
278
156
|
}
|
|
279
|
-
|
|
280
|
-
this.
|
|
281
|
-
this.fullSet = reason === 'disclosure';
|
|
282
|
-
this.active = -1;
|
|
283
|
-
this.lookupError = '';
|
|
284
|
-
const config = this.config;
|
|
285
|
-
const query = this.fullSet ? '' : this.raw;
|
|
286
|
-
const controller = new AbortController();
|
|
287
|
-
this.lookup = controller;
|
|
288
|
-
const apply = (options) => {
|
|
289
|
-
if (controller.signal.aborted || !this.alive)
|
|
290
|
-
return;
|
|
291
|
-
for (const option of options)
|
|
292
|
-
this.knownOptions.set(option.value, option);
|
|
293
|
-
const selectedOption = this.selected === null ? undefined : this.knownOptions.get(this.selected);
|
|
294
|
-
if (this.query === undefined && this.awaitingLabel === this.selected && selectedOption) {
|
|
295
|
-
this.raw = selectedOption.label;
|
|
296
|
-
this.display = this.raw;
|
|
297
|
-
this.awaitingLabel = null;
|
|
298
|
-
this.formattedRaw = undefined;
|
|
299
|
-
this.resetValidation();
|
|
300
|
-
}
|
|
301
|
-
const ids = new Set();
|
|
302
|
-
this.rows = options.filter(option => {
|
|
303
|
-
if (ids.has(option.id))
|
|
304
|
-
return false;
|
|
305
|
-
ids.add(option.id);
|
|
306
|
-
return this.fullSet || (config.filter ? config.filter(option, query, config.context)
|
|
307
|
-
: config.provider ? true : option.label.toLocaleLowerCase().includes(query.toLocaleLowerCase()));
|
|
308
|
-
});
|
|
309
|
-
const groups = new Map();
|
|
310
|
-
for (const row of this.rows) {
|
|
311
|
-
const group = row.group ?? '';
|
|
312
|
-
if (!groups.has(group))
|
|
313
|
-
groups.set(group, []);
|
|
314
|
-
groups.get(group).push(row);
|
|
315
|
-
}
|
|
316
|
-
this.rows = [...groups.values()].flat();
|
|
317
|
-
this.loading = false;
|
|
318
|
-
this.optionsChange.emit(this.rows);
|
|
319
|
-
};
|
|
320
|
-
if (!config.provider) {
|
|
321
|
-
apply(config.options ?? []);
|
|
157
|
+
clearHideTimer() {
|
|
158
|
+
if (this.hideTimer === null)
|
|
322
159
|
return;
|
|
323
|
-
|
|
324
|
-
this.
|
|
325
|
-
this.loading = true;
|
|
326
|
-
this.lookupTimer = setTimeout(async () => {
|
|
327
|
-
try {
|
|
328
|
-
apply(await config.provider({ query, context: config.context, signal: controller.signal, reason }));
|
|
329
|
-
}
|
|
330
|
-
catch (error) {
|
|
331
|
-
if (controller.signal.aborted || !this.alive)
|
|
332
|
-
return;
|
|
333
|
-
this.loading = false;
|
|
334
|
-
this.lookupError = error instanceof Error ? error.message : 'Unable to load suggestions.';
|
|
335
|
-
}
|
|
336
|
-
}, reason === 'disclosure' ? 0 : Math.max(0, config.debounce ?? 200));
|
|
337
|
-
}
|
|
338
|
-
get canCreate() {
|
|
339
|
-
const candidates = this.config.options ? [...this.config.options, ...this.rows] : this.rows;
|
|
340
|
-
return Boolean(this.config.allowCreate && this.raw.trim() && !this.loading && !this.lookupError
|
|
341
|
-
&& !candidates.some(row => row.label.toLocaleLowerCase() === this.raw.toLocaleLowerCase()));
|
|
160
|
+
clearTimeout(this.hideTimer);
|
|
161
|
+
this.hideTimer = null;
|
|
342
162
|
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
// Selection is now in display coordinates; do not map it as raw a second time.
|
|
347
|
-
if (this.formattedRaw === this.raw && this.formattedWith === this.config.format)
|
|
348
|
-
return;
|
|
349
|
-
const result = formatEditingValue(this.raw, {
|
|
350
|
-
start: this.input.selectionStart ?? this.raw.length, end: this.input.selectionEnd ?? this.raw.length,
|
|
351
|
-
direction: this.input.selectionDirection ?? 'none',
|
|
352
|
-
}, this.config.format);
|
|
353
|
-
this.formattedRaw = this.raw;
|
|
354
|
-
this.formattedWith = this.config.format;
|
|
355
|
-
this.display = result.display;
|
|
356
|
-
if (this.input.value !== result.display) {
|
|
357
|
-
this.input.value = result.display;
|
|
358
|
-
this.input.setSelectionRange(result.selection.start, result.selection.end, result.selection.direction);
|
|
359
|
-
}
|
|
163
|
+
clearTimers() {
|
|
164
|
+
this.clearShowTimer();
|
|
165
|
+
this.clearHideTimer();
|
|
360
166
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
if (this.composing || event.isComposing)
|
|
167
|
+
setInteractionOpen(nextOpen, trigger) {
|
|
168
|
+
if (this.internalOpen === nextOpen)
|
|
364
169
|
return;
|
|
365
|
-
this.
|
|
366
|
-
|
|
367
|
-
this.
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
this.queryChange.emit({ query: this.raw, display: this.display, trigger: 'keyboard' });
|
|
372
|
-
if (this.selected !== null)
|
|
373
|
-
this.commit(null, this.raw, null, 'clear', 'keyboard');
|
|
374
|
-
this.open();
|
|
375
|
-
if (this.config.validateOn === 'input')
|
|
376
|
-
void this.validate();
|
|
377
|
-
queueMicrotask(() => {
|
|
378
|
-
if (this.query !== undefined && this.query !== this.raw)
|
|
379
|
-
this.syncQuery();
|
|
170
|
+
if (!controlledState.isControlled(this.open))
|
|
171
|
+
this.internalOpen = nextOpen;
|
|
172
|
+
events.dispatchDetail(this.host, nextOpen ? 'open' : 'close', {
|
|
173
|
+
open: nextOpen,
|
|
174
|
+
reason: 'action',
|
|
175
|
+
trigger,
|
|
380
176
|
});
|
|
381
|
-
};
|
|
382
|
-
commit(value, query, option, kind, trigger) {
|
|
383
|
-
this.awaitingLabel = null;
|
|
384
|
-
const queryChanged = query !== this.raw;
|
|
385
|
-
if (this.value === undefined)
|
|
386
|
-
this.selected = value;
|
|
387
|
-
if (this.query === undefined && queryChanged) {
|
|
388
|
-
this.raw = query;
|
|
389
|
-
this.display = query;
|
|
390
|
-
this.formattedRaw = undefined;
|
|
391
|
-
}
|
|
392
|
-
this.resetValidation();
|
|
393
|
-
const detail = { value, query, option, kind, trigger };
|
|
394
|
-
const proposal = { value, query };
|
|
395
|
-
this.proposedChange = proposal;
|
|
396
|
-
this.valueChange.emit(detail);
|
|
397
|
-
if (queryChanged)
|
|
398
|
-
this.queryChange.emit({ query, display: query, trigger });
|
|
399
|
-
if (kind === 'create')
|
|
400
|
-
this.createEntry.emit(detail);
|
|
401
|
-
if (kind === 'free-entry')
|
|
402
|
-
this.freeEntry.emit(detail);
|
|
403
|
-
if (kind === 'invalidation')
|
|
404
|
-
this.dependencyInvalidate.emit(detail);
|
|
405
|
-
// Settle after all owner notifications (including Vue's queued update).
|
|
406
|
-
// A retained prop does not fire a Stencil watcher, so rejection must be
|
|
407
|
-
// reconciled explicitly while the proposal still identifies an edit echo.
|
|
408
|
-
queueMicrotask(() => {
|
|
409
|
-
if (this.proposedChange !== proposal)
|
|
410
|
-
return;
|
|
411
|
-
if (this.value !== undefined && this.value !== proposal.value)
|
|
412
|
-
this.syncValue();
|
|
413
|
-
if (this.query !== undefined && this.query !== proposal.query) {
|
|
414
|
-
if (this.value === undefined) {
|
|
415
|
-
this.selected = null;
|
|
416
|
-
this.resetValidation();
|
|
417
|
-
}
|
|
418
|
-
this.syncQuery();
|
|
419
|
-
}
|
|
420
|
-
this.proposedChange = undefined;
|
|
421
|
-
});
|
|
422
|
-
}
|
|
423
|
-
choose(index, trigger) {
|
|
424
|
-
const option = this.rows[index];
|
|
425
|
-
if (option?.disabled)
|
|
426
|
-
return;
|
|
427
|
-
if (option)
|
|
428
|
-
this.commit(option.value, option.label, option, 'selection', trigger);
|
|
429
|
-
else if (this.canCreate && index === this.rows.length)
|
|
430
|
-
this.commit(null, this.raw, null, 'create', trigger);
|
|
431
|
-
else
|
|
432
|
-
return;
|
|
433
|
-
this.close();
|
|
434
|
-
this.input?.focus();
|
|
435
|
-
if (this.config.validateOn !== 'submit')
|
|
436
|
-
queueMicrotask(() => void this.validate());
|
|
437
177
|
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
if (this.
|
|
441
|
-
indices.push(this.rows.length);
|
|
442
|
-
if (!indices.length)
|
|
178
|
+
onSurfaceEnter = () => this.clearHideTimer();
|
|
179
|
+
onTriggerClick = (event) => {
|
|
180
|
+
if (!this.toggleOnClick)
|
|
443
181
|
return;
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
182
|
+
this.clearTimers();
|
|
183
|
+
this.pinned = !this.pinned;
|
|
184
|
+
this.setInteractionOpen(this.pinned, event.detail === 0 ? 'keyboard' : 'pointer');
|
|
185
|
+
};
|
|
186
|
+
onTriggerKeydown = (event) => {
|
|
187
|
+
if (event.key === 'Escape')
|
|
188
|
+
this.clearTimers();
|
|
189
|
+
};
|
|
190
|
+
onTriggerEnter = (event) => {
|
|
191
|
+
if (event.pointerType === 'touch')
|
|
453
192
|
return;
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
event.stopPropagation();
|
|
457
|
-
this.close();
|
|
193
|
+
this.clearHideTimer();
|
|
194
|
+
if (this.internalOpen || this.showTimer !== null)
|
|
458
195
|
return;
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
this.
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
196
|
+
this.showTimer = setTimeout(() => {
|
|
197
|
+
this.showTimer = null;
|
|
198
|
+
this.setInteractionOpen(true, 'pointer');
|
|
199
|
+
}, Math.max(0, this.showDelay));
|
|
200
|
+
};
|
|
201
|
+
onTriggerLeave = () => {
|
|
202
|
+
this.clearShowTimer();
|
|
203
|
+
if (this.focused || this.pinned || !this.internalOpen || this.hideTimer !== null)
|
|
465
204
|
return;
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
}
|
|
476
|
-
else if (event.key === 'Enter' && this.expanded) {
|
|
477
|
-
if (this.active >= 0) {
|
|
478
|
-
event.preventDefault();
|
|
479
|
-
this.choose(this.active, 'keyboard');
|
|
480
|
-
}
|
|
481
|
-
else if (this.config.allowFreeText) {
|
|
482
|
-
event.preventDefault();
|
|
483
|
-
this.commit(null, this.raw, null, 'free-entry', 'keyboard');
|
|
484
|
-
this.close();
|
|
485
|
-
}
|
|
486
|
-
}
|
|
205
|
+
this.hideTimer = setTimeout(() => {
|
|
206
|
+
this.hideTimer = null;
|
|
207
|
+
this.setInteractionOpen(false, 'pointer');
|
|
208
|
+
}, Math.max(0, this.hideDelay));
|
|
209
|
+
};
|
|
210
|
+
onTriggerFocusIn = () => {
|
|
211
|
+
this.focused = true;
|
|
212
|
+
this.clearTimers();
|
|
213
|
+
this.setInteractionOpen(true, 'keyboard');
|
|
487
214
|
};
|
|
488
|
-
|
|
489
|
-
|
|
215
|
+
onTriggerFocusOut = (e) => {
|
|
216
|
+
const related = e.relatedTarget;
|
|
217
|
+
if (related && this.host.contains(related))
|
|
490
218
|
return;
|
|
491
|
-
this.
|
|
492
|
-
this.
|
|
493
|
-
this.
|
|
494
|
-
|
|
495
|
-
this.commit(null, this.raw, null, 'free-entry', 'keyboard');
|
|
496
|
-
if ((this.config.validateOn ?? 'blur') === 'blur')
|
|
497
|
-
void this.validate();
|
|
219
|
+
this.focused = false;
|
|
220
|
+
this.pinned = false;
|
|
221
|
+
this.clearTimers();
|
|
222
|
+
this.setInteractionOpen(false, 'keyboard');
|
|
498
223
|
};
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
this.validation = { ...this.validation, status: 'pending', output: undefined };
|
|
511
|
-
this.validationChange.emit(this.validation);
|
|
512
|
-
try {
|
|
513
|
-
const result = await validateField({ raw: this.raw, value: this.selected, context: this.config.context, signal: run.signal }, this.config);
|
|
514
|
-
if (this.required && !this.raw.trim())
|
|
515
|
-
result.issues = [...result.issues, { message: 'A value is required.' }];
|
|
516
|
-
else if (this.raw && this.selected === null && !this.config.allowFreeText && !this.config.allowCreate)
|
|
517
|
-
result.issues = [...result.issues, { message: 'Choose a suggestion.' }];
|
|
518
|
-
if (result.issues.some(issue => issue.severity !== 'warning'))
|
|
519
|
-
result.output = undefined;
|
|
520
|
-
if (!run.signal.aborted && this.alive)
|
|
521
|
-
this.setValidation(result);
|
|
224
|
+
handleRequestClose(reason, trigger) {
|
|
225
|
+
if (reason === 'escape' || (reason === 'light-dismiss' && this.toggleOnClick)) {
|
|
226
|
+
this.pinned = false;
|
|
227
|
+
this.clearTimers();
|
|
228
|
+
if (!controlledState.isControlled(this.open))
|
|
229
|
+
this.internalOpen = false;
|
|
230
|
+
events.dispatchDetail(this.host, 'close', {
|
|
231
|
+
open: false,
|
|
232
|
+
reason,
|
|
233
|
+
trigger: trigger,
|
|
234
|
+
});
|
|
522
235
|
}
|
|
523
|
-
catch { /* Aborted work never becomes current field state. */ }
|
|
524
|
-
return this.validation;
|
|
525
236
|
}
|
|
526
|
-
/** Focus the native editing input from a composed control. */
|
|
527
|
-
async focusInput() { this.input?.focus(); }
|
|
528
237
|
render() {
|
|
529
|
-
|
|
530
|
-
const status = this.loading ? 'Loading suggestions…' : this.lookupError || (this.expanded ? `${this.rows.length} suggestions available.` : '');
|
|
531
|
-
const groups = [...new Set(this.rows.map(row => row.group ?? ''))];
|
|
532
|
-
return index.h(index.Host, { key: '1f00d9a83729d9c2147ced7e5006b928d1b5e51d', "data-size": this.size, "data-validation": this.validation.status, onFocusout: this.onFocusOut }, index.h("label", { key: '10353b147cc68ef1d67be0988849af1527fcf9ba', htmlFor: "input", part: "label", class: this.labelVisibility === 'sr-only' ? 'sr-only' : undefined }, this.label, this.required ? ' *' : ''), index.h("div", { key: '74bb53137d9343add37c22f3ac503eccf41807a9', class: "field", part: "field", ref: element => this.field = element, onClick: event => {
|
|
533
|
-
if (!event.composedPath().some(node => node instanceof HTMLButtonElement))
|
|
534
|
-
this.input?.focus();
|
|
535
|
-
} }, index.h("slot", { key: '24c26916365013faa4a78bd4fe0d01f6c129c703', name: "start" }), index.h("input", { key: '835d19e66ec4a24c1a83f43bbc256fa2a9e3332f', id: "input", ref: element => this.input = element, role: "combobox", "aria-autocomplete": "list", "aria-expanded": String(this.expanded), "aria-controls": "listbox", "aria-activedescendant": this.expanded && this.active >= 0 ? `option-${this.active}` : undefined, "aria-describedby": description, "aria-invalid": String(this.validation.status === 'error'), "aria-busy": String(this.validation.status === 'pending'), value: this.display, placeholder: this.placeholder, name: this.name || undefined, disabled: this.disabled, readOnly: this.readOnly, required: this.required, autoComplete: "off", part: "input", onInput: this.onInput, onKeyDown: this.onKeydown, onCompositionstart: () => this.composing = true, onCompositionend: () => { this.composing = false; this.onInput(new InputEvent('input')); } }), this.clearable && index.h("button", { key: '326c1e24d3c417c3a72acd8234a53937b388ba79', type: "button", part: "affordance", "aria-label": `Clear ${this.label}`, disabled: this.disabled || this.readOnly, onClick: () => { this.commit(null, '', null, 'clear', 'pointer'); this.close(); this.input?.focus(); } }, "\u00D7"), this.help && index.h("button", { key: '6aeb62dc2935eb95670caa1d2028c0931dc362b2', id: "help", type: "button", part: "affordance", "aria-label": `Help for ${this.label}`, disabled: this.disabled }, index.h("span", { key: '9317be0fbb0c1bbb91061be69f38037a97a4c36b', "aria-hidden": "true" }, "?")), this.disclosure && index.h("button", { key: '1cd2a0ea92df1144ff2297fcf64df7b3d0f4713a', type: "button", part: "affordance", "aria-label": `Suggestions for ${this.label}`, "aria-controls": "listbox", "aria-expanded": String(this.expanded), disabled: this.disabled || this.readOnly, onClick: () => {
|
|
536
|
-
if (this.expanded)
|
|
537
|
-
this.close();
|
|
538
|
-
else
|
|
539
|
-
this.open('disclosure');
|
|
540
|
-
this.input?.focus();
|
|
541
|
-
} }, index.h("span", { key: '0188b2d0e8cc7b7ff4d1a2175a0ff0b47d9c7d98', "aria-hidden": "true" }, "\u2304"))), this.help && index.h("ui-tooltip", { key: 'e09fd35274c3e1fa6e408850d72f7a07c2bb4baf', id: "help-text", for: "help", toggleOnClick: true, onOpen: () => this.helpOpen = true, onClose: () => this.helpOpen = false }, this.help), index.h("div", { key: 'ddf83a5944dd03fc7eb580b81fcf291e06c03601', class: "popup", part: "popup", hidden: !this.expanded, ref: element => this.popup = element }, index.h("div", { key: '1d73de1dabb6eaa95af12f2af88dac74e3f163ea', id: "listbox", role: "listbox", "aria-label": `${this.label} suggestions`, "aria-busy": String(this.loading) }, groups.map(group => index.h("div", { role: group ? 'group' : 'presentation', "aria-label": group || undefined }, group && index.h("div", { class: "group", part: "group" }, group), this.rows.map((row, index$1) => (row.group ?? '') !== group ? null : index.h("div", { id: `option-${index$1}`, role: "option", "aria-selected": String(this.selected === row.value), "aria-disabled": String(Boolean(row.disabled)), "data-active": this.active === index$1 ? '' : undefined, part: "option", class: "option", onPointerDown: event => event.preventDefault(), onClick: () => this.choose(index$1, 'pointer') }, index.h("slot", { name: `option-${row.id}` }, index.h("span", { class: "primary", part: "option-primary" }, row.label), row.description && index.h("span", { class: "secondary", part: "option-secondary" }, row.description)))))), this.canCreate && index.h("div", { key: 'a0aaafa2f4ff79efa954ed780f3a7bd81d4b2ecd', id: `option-${this.rows.length}`, role: "option", "aria-selected": "false", class: "option", part: "option", "data-active": this.active === this.rows.length ? '' : undefined, onPointerDown: event => event.preventDefault(), onClick: () => this.choose(this.rows.length, 'pointer') }, index.h("slot", { key: '53a6706fc2c26097948b08cf0a7ee6040e37fe57', name: "create" }, "Create \u201C", this.raw, "\u201D"))), this.loading ? index.h("div", { class: "message" }, index.h("slot", { name: "loading" }, "Loading suggestions\u2026"))
|
|
542
|
-
: this.lookupError ? index.h("div", { class: "message" }, index.h("slot", { name: "error" }, this.lookupError))
|
|
543
|
-
: !this.rows.length && !this.canCreate ? index.h("div", { class: "message" }, index.h("slot", { name: "empty" }, "No suggestions.")) : null, index.h("slot", { key: '7997a0233a3c1a560b820c846645405ec4ceec1d', name: "footer" })), index.h("div", { key: '9143eb79141f5f3660a63f7a2471d1eecd8e9332', id: "validation", class: "message", part: "validation", hidden: !this.validation.issues.length }, this.validation.issues.map(issue => index.h("div", null, issue.message))), index.h("div", { key: '21f310613b058f528f8c4df329864fd8a2a94b55', class: "sr-only", role: "status", "aria-live": "polite", "aria-atomic": "true" }, status, " ", this.validation.status === 'pending' ? 'Checking value…' : this.validation.issues.map(issue => issue.message).join(' ')));
|
|
238
|
+
return (index.h(index.Host, { key: 'fd4d81febd147b846aca66e94f25d56f14b171dc', role: "tooltip", hidden: !this.internalOpen, "data-open": this.internalOpen ? '' : undefined }, index.h("div", { key: 'd31ac8c0e087becd7e60459f2cd894a9b15e95fa', class: "tooltip__surface" }, index.h("slot", { key: '06e7aac9b6992a9cf0f92c9d356b97d18fb2da8b' }))));
|
|
544
239
|
}
|
|
545
240
|
static get watchers() { return {
|
|
546
|
-
"
|
|
547
|
-
"
|
|
548
|
-
}],
|
|
549
|
-
"query": [{
|
|
550
|
-
"syncQuery": 0
|
|
241
|
+
"open": [{
|
|
242
|
+
"syncFromProp": 0
|
|
551
243
|
}],
|
|
552
|
-
"
|
|
553
|
-
"
|
|
244
|
+
"for": [{
|
|
245
|
+
"resetSurface": 0
|
|
554
246
|
}],
|
|
555
|
-
"
|
|
556
|
-
"
|
|
247
|
+
"placement": [{
|
|
248
|
+
"resetSurface": 0
|
|
557
249
|
}],
|
|
558
|
-
"
|
|
559
|
-
"
|
|
250
|
+
"internalOpen": [{
|
|
251
|
+
"syncOverlay": 0
|
|
560
252
|
}]
|
|
561
253
|
}; }
|
|
562
254
|
};
|
|
563
|
-
|
|
255
|
+
UITooltip.style = uiTooltipCss();
|
|
564
256
|
|
|
565
257
|
exports.ui_chip = UIChip;
|
|
566
|
-
exports.
|
|
258
|
+
exports.ui_tooltip = UITooltip;
|