@threadlabs/looma 0.1.21 → 0.1.23
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-FSGGPFID.js → chunk-GDMQKT5F.js} +63 -31
- package/dist/{chunk-SZJQ3NPX.js → chunk-TL4FIE7X.js} +4 -8
- package/dist/cjs/{index-D07f6BOw.js → index-BHG9Rpil.js} +33 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/looma.cjs.js +2 -2
- package/dist/cjs/{manager-C9j3HZay.js → manager-Ce25WRtl.js} +6 -7
- package/dist/cjs/ui-affordance-scope.cjs.entry.js +1 -1
- package/dist/cjs/ui-avatar-group.cjs.entry.js +1 -1
- package/dist/cjs/ui-avatar.cjs.entry.js +1 -1
- package/dist/cjs/ui-badge.cjs.entry.js +1 -1
- package/dist/cjs/ui-button.cjs.entry.js +16 -5
- package/dist/cjs/ui-checkbox.cjs.entry.js +1 -1
- package/dist/cjs/ui-combobox.cjs.entry.js +541 -0
- package/dist/cjs/ui-context-menu.cjs.entry.js +3 -3
- package/dist/cjs/ui-dialog.cjs.entry.js +3 -3
- package/dist/cjs/ui-disclosure.cjs.entry.js +2 -2
- package/dist/cjs/ui-floating-action-button.cjs.entry.js +2 -2
- package/dist/cjs/ui-form-field.cjs.entry.js +3 -3
- package/dist/cjs/ui-icon-button.cjs.entry.js +2 -2
- package/dist/cjs/ui-input.cjs.entry.js +11 -6
- package/dist/cjs/ui-menu-item.cjs.entry.js +2 -2
- package/dist/cjs/ui-menu.cjs.entry.js +3 -3
- package/dist/cjs/ui-popover.cjs.entry.js +3 -3
- package/dist/cjs/ui-radio-group.cjs.entry.js +2 -2
- package/dist/cjs/ui-radio.cjs.entry.js +3 -3
- package/dist/cjs/ui-search-result-row.cjs.entry.js +2 -2
- package/dist/cjs/ui-search-shell.cjs.entry.js +2 -2
- package/dist/cjs/ui-select.cjs.entry.js +15 -7
- package/dist/cjs/ui-switch.cjs.entry.js +3 -3
- package/dist/cjs/ui-tabs.cjs.entry.js +2 -2
- package/dist/cjs/ui-textarea.cjs.entry.js +10 -6
- package/dist/cjs/ui-toast-region.cjs.entry.js +2 -2
- package/dist/cjs/ui-tooltip.cjs.entry.js +52 -16
- package/dist/cjs/ui-top-bar.cjs.entry.js +2 -2
- package/dist/cjs/ui-tree-item.cjs.entry.js +7 -3
- package/dist/cjs/ui-tree.cjs.entry.js +113 -21
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/ui-button/ui-button.css +36 -26
- package/dist/collection/components/ui-button/ui-button.js +14 -3
- package/dist/collection/components/ui-combobox/ui-combobox.css +24 -0
- package/dist/collection/components/ui-combobox/ui-combobox.js +973 -0
- 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-floating-action-button/ui-floating-action-button.js +1 -1
- package/dist/collection/components/ui-form-field/ui-form-field.css +4 -0
- 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.css +8 -6
- package/dist/collection/components/ui-input/ui-input.js +11 -7
- 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 +2 -2
- 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.css +8 -6
- package/dist/collection/components/ui-select/ui-select.js +17 -11
- 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.css +7 -6
- package/dist/collection/components/ui-textarea/ui-textarea.js +10 -7
- package/dist/collection/components/ui-toast-region/ui-toast-region.js +1 -1
- package/dist/collection/components/ui-tooltip/ui-tooltip.js +102 -15
- package/dist/collection/components/ui-top-bar/ui-top-bar.js +1 -1
- package/dist/collection/components/ui-tree/ui-tree.js +132 -20
- package/dist/collection/components/ui-tree-item/ui-tree-item.js +44 -2
- package/dist/collection/field/combobox.js +4 -0
- package/dist/collection/field/valibot.js +5 -0
- package/dist/collection/field/validation.js +62 -0
- package/dist/collection/overlay/manager.js +6 -7
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +1 -1
- package/dist/components/p-Bh_1GxOD.js +1 -0
- package/dist/components/p-C-0syqXZ.js +1 -0
- package/dist/components/p-CaietZcq.js +1 -0
- package/dist/components/p-DHd18bK7.js +1 -0
- package/dist/components/ui-affordance-scope.js +1 -1
- package/dist/components/ui-avatar-group.js +1 -1
- package/dist/components/ui-avatar.js +1 -1
- package/dist/components/ui-badge.js +1 -1
- package/dist/components/ui-button.js +1 -1
- package/dist/components/ui-checkbox.js +1 -1
- package/dist/components/ui-combobox.d.ts +11 -0
- package/dist/components/ui-combobox.js +1 -0
- 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-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 +2 -2
- package/dist/components/ui-tree.js +1 -1
- package/dist/esm/{index-CEeiinfk.js → index-8BGiMGQ0.js} +33 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/looma.js +3 -3
- package/dist/esm/{manager-PM9a74r7.js → manager-C-0syqXZ.js} +6 -7
- package/dist/esm/ui-affordance-scope.entry.js +1 -1
- package/dist/esm/ui-avatar-group.entry.js +1 -1
- package/dist/esm/ui-avatar.entry.js +1 -1
- package/dist/esm/ui-badge.entry.js +1 -1
- package/dist/esm/ui-button.entry.js +16 -5
- package/dist/esm/ui-checkbox.entry.js +1 -1
- package/dist/esm/ui-combobox.entry.js +539 -0
- package/dist/esm/ui-context-menu.entry.js +3 -3
- package/dist/esm/ui-dialog.entry.js +3 -3
- package/dist/esm/ui-disclosure.entry.js +2 -2
- package/dist/esm/ui-floating-action-button.entry.js +2 -2
- package/dist/esm/ui-form-field.entry.js +3 -3
- package/dist/esm/ui-icon-button.entry.js +2 -2
- package/dist/esm/ui-input.entry.js +11 -6
- package/dist/esm/ui-menu-item.entry.js +2 -2
- package/dist/esm/ui-menu.entry.js +3 -3
- package/dist/esm/ui-popover.entry.js +3 -3
- package/dist/esm/ui-radio-group.entry.js +2 -2
- package/dist/esm/ui-radio.entry.js +3 -3
- package/dist/esm/ui-search-result-row.entry.js +2 -2
- package/dist/esm/ui-search-shell.entry.js +2 -2
- package/dist/esm/ui-select.entry.js +15 -7
- package/dist/esm/ui-switch.entry.js +3 -3
- package/dist/esm/ui-tabs.entry.js +2 -2
- package/dist/esm/ui-textarea.entry.js +10 -6
- package/dist/esm/ui-toast-region.entry.js +2 -2
- package/dist/esm/ui-tooltip.entry.js +52 -16
- package/dist/esm/ui-top-bar.entry.js +2 -2
- package/dist/esm/ui-tree-item.entry.js +7 -3
- package/dist/esm/ui-tree.entry.js +113 -21
- package/dist/index.cjs +911 -135
- package/dist/index.d.cts +104 -1
- package/dist/index.d.ts +104 -1
- package/dist/index.js +62 -8
- package/dist/looma/looma.esm.js +1 -1
- package/dist/looma/{p-0198bb21.entry.js → p-13347631.entry.js} +1 -1
- package/dist/looma/p-14c081cf.entry.js +1 -0
- package/dist/looma/{p-0f45c5f0.entry.js → p-25366205.entry.js} +1 -1
- package/dist/looma/{p-a9f46811.entry.js → p-2e3aa869.entry.js} +1 -1
- package/dist/looma/p-40fe7fee.entry.js +1 -0
- package/dist/looma/p-446cda76.entry.js +1 -0
- package/dist/looma/p-4fc1b005.entry.js +13 -0
- package/dist/looma/p-582973b5.entry.js +1 -0
- package/dist/looma/{p-d273b857.entry.js → p-5a87b59d.entry.js} +1 -1
- package/dist/looma/{p-2ed7e241.entry.js → p-5da09f47.entry.js} +1 -1
- package/dist/looma/{p-7e94d90d.entry.js → p-69a5557b.entry.js} +1 -1
- package/dist/looma/p-6a8a4736.entry.js +1 -0
- package/dist/looma/{p-caa8fc7b.entry.js → p-6bf4038b.entry.js} +1 -1
- package/dist/looma/p-7e0bb7f6.entry.js +1 -0
- package/dist/looma/{p-ed5abf6d.entry.js → p-8204fee6.entry.js} +1 -1
- package/dist/looma/{p-5ba9d496.entry.js → p-8238e0dc.entry.js} +1 -1
- package/dist/looma/p-8BGiMGQ0.js +2 -0
- package/dist/looma/{p-051f578c.entry.js → p-8b8840b8.entry.js} +1 -1
- package/dist/looma/{p-1674cda4.entry.js → p-99d88efb.entry.js} +1 -1
- package/dist/looma/p-C-0syqXZ.js +1 -0
- package/dist/looma/p-a27669b1.entry.js +1 -0
- package/dist/looma/{p-11083743.entry.js → p-a6ee76b7.entry.js} +1 -1
- package/dist/looma/p-a90d2821.entry.js +1 -0
- package/dist/looma/{p-2e6f791e.entry.js → p-add36e74.entry.js} +1 -1
- package/dist/looma/{p-0584a051.entry.js → p-b6398a6b.entry.js} +1 -1
- package/dist/looma/{p-078f9fb8.entry.js → p-d50faaff.entry.js} +1 -1
- package/dist/looma/{p-b7aa4488.entry.js → p-d77278ce.entry.js} +1 -1
- package/dist/looma/p-d9ec13b7.entry.js +1 -0
- package/dist/looma/{p-1681b218.entry.js → p-ecf8005f.entry.js} +1 -1
- package/dist/looma/p-ed368426.entry.js +1 -0
- package/dist/looma/{p-063f5a89.entry.js → p-f0487ff3.entry.js} +1 -1
- package/dist/looma/p-f74e5546.entry.js +1 -0
- package/dist/types/components/ui-combobox/ui-combobox.d.ts +93 -0
- package/dist/types/components/ui-input/ui-input.d.ts +1 -1
- package/dist/types/components/ui-select/ui-select.d.ts +3 -2
- package/dist/types/components/ui-textarea/ui-textarea.d.ts +1 -1
- package/dist/types/components/ui-tooltip/ui-tooltip.d.ts +18 -1
- package/dist/types/components/ui-tree/ui-tree.d.ts +11 -1
- package/dist/types/components/ui-tree-item/ui-tree-item.d.ts +4 -0
- package/dist/types/components.d.ts +260 -28
- package/dist/types/field/combobox.d.ts +46 -0
- package/dist/types/field/valibot.d.ts +7 -0
- package/dist/types/field/validation.d.ts +56 -0
- package/dist/{ui-affordance-scope.entry-Z3H4CM6J.js → ui-affordance-scope.entry-VO4C2MZX.js} +1 -1
- package/dist/{ui-avatar-group.entry-ONGVFRD3.js → ui-avatar-group.entry-TAXJRIIU.js} +1 -1
- package/dist/{ui-avatar.entry-TBA3IEED.js → ui-avatar.entry-T6FU6ZYM.js} +1 -1
- package/dist/{ui-badge.entry-DKBPJ7G7.js → ui-badge.entry-MZFYNBMJ.js} +1 -1
- package/dist/ui-button.entry-7UXMUGHN.js +80 -0
- package/dist/{ui-checkbox.entry-QJTO2U6Z.js → ui-checkbox.entry-DMZJB3RE.js} +1 -1
- package/dist/ui-combobox.entry-ZCTPXEES.js +553 -0
- package/dist/{ui-context-menu.entry-CC4VXCEB.js → ui-context-menu.entry-2WMCBGCP.js} +6 -6
- package/dist/{ui-dialog.entry-GPJWOH5Z.js → ui-dialog.entry-WO23XOSW.js} +6 -6
- package/dist/{ui-disclosure.entry-EGG3HXD4.js → ui-disclosure.entry-USX7OUEW.js} +2 -2
- package/dist/{ui-floating-action-button.entry-XUD44HRX.js → ui-floating-action-button.entry-MXDIN7MV.js} +2 -2
- package/dist/{ui-form-field.entry-UHLNDUXR.js → ui-form-field.entry-7ZCMEHPY.js} +3 -3
- package/dist/{ui-icon-button.entry-6HDCV3E7.js → ui-icon-button.entry-MJUNXHBU.js} +2 -2
- package/dist/{ui-input.entry-73QXAVLL.js → ui-input.entry-AWG63YIG.js} +8 -6
- package/dist/{ui-menu-item.entry-HCZRSY5Y.js → ui-menu-item.entry-HFTWG62N.js} +2 -2
- package/dist/{ui-menu.entry-ASIVAX6M.js → ui-menu.entry-IT3GW5TL.js} +7 -7
- package/dist/{ui-popover.entry-WSQ7AEJN.js → ui-popover.entry-ZQQB4N6E.js} +6 -6
- package/dist/{ui-radio-group.entry-2N7BEBJW.js → ui-radio-group.entry-V7PCTS7I.js} +2 -2
- package/dist/{ui-radio.entry-TOM6HBXP.js → ui-radio.entry-JYH6TQBI.js} +3 -3
- package/dist/{ui-search-result-row.entry-KA3P76WE.js → ui-search-result-row.entry-JBNYXXUN.js} +2 -2
- package/dist/{ui-search-shell.entry-ERMS7TIH.js → ui-search-shell.entry-TEAWE76O.js} +2 -2
- package/dist/{ui-select.entry-KDIM3SWS.js → ui-select.entry-F3A6TE2U.js} +13 -7
- package/dist/{ui-switch.entry-VRTB6X4D.js → ui-switch.entry-MJIICMP2.js} +3 -3
- package/dist/{ui-tabs.entry-GIAO5W3U.js → ui-tabs.entry-6REFIUHV.js} +2 -2
- package/dist/{ui-textarea.entry-T6YH4HVG.js → ui-textarea.entry-OJTXCED7.js} +8 -6
- package/dist/{ui-toast-region.entry-DBQCXOPJ.js → ui-toast-region.entry-NOFXLKPS.js} +5 -5
- package/dist/{ui-tooltip.entry-VS26OECS.js → ui-tooltip.entry-COWTWVHX.js} +57 -21
- package/dist/{ui-top-bar.entry-HGWP6PFQ.js → ui-top-bar.entry-PIAWXJNV.js} +2 -2
- package/dist/{ui-tree-item.entry-ZRXUIZDR.js → ui-tree-item.entry-BSEWNL2O.js} +7 -3
- package/dist/{ui-tree.entry-TC2SCQJF.js → ui-tree.entry-XYI3ZFAZ.js} +105 -20
- package/dist/valibot.d.ts +52 -0
- package/dist/valibot.js +7 -0
- package/package.json +11 -3
- package/styles.css +36 -20
- package/theme-high-contrast.css +12 -0
- package/tokens.css +23 -0
- package/vue/{chunk-5KWCMTXB.js → chunk-JLW23USW.js} +88 -1
- package/vue/editor/index.js +1 -1
- package/vue/index.d.ts +123 -1
- package/vue/index.js +3 -1
- package/dist/components/p-CEYIKqYc.js +0 -1
- package/dist/components/p-CIA4RyEp.js +0 -1
- package/dist/components/p-PM9a74r7.js +0 -1
- package/dist/looma/p-34417499.entry.js +0 -1
- package/dist/looma/p-4b422d40.entry.js +0 -1
- package/dist/looma/p-54722713.entry.js +0 -13
- package/dist/looma/p-54c41576.entry.js +0 -1
- package/dist/looma/p-5d4713a6.entry.js +0 -1
- package/dist/looma/p-624ba086.entry.js +0 -1
- package/dist/looma/p-8d5adb17.entry.js +0 -1
- package/dist/looma/p-9194a99d.entry.js +0 -1
- package/dist/looma/p-CEeiinfk.js +0 -2
- package/dist/looma/p-PM9a74r7.js +0 -1
- package/dist/looma/p-a33522a2.entry.js +0 -1
- package/dist/looma/p-a5127c7d.entry.js +0 -1
- package/dist/looma/p-b0431118.entry.js +0 -1
- package/dist/ui-button.entry-U2MMIHLY.js +0 -71
|
@@ -0,0 +1,539 @@
|
|
|
1
|
+
import { r as registerInstance, c as createEvent, g as getElement, h, H as Host } from './index-8BGiMGQ0.js';
|
|
2
|
+
import { a as createAnchoredSurface } from './positioning-Bu0dmLBE.js';
|
|
3
|
+
import { c as closeOverlay, o as openOverlay } from './manager-C-0syqXZ.js';
|
|
4
|
+
|
|
5
|
+
/** Formatting is additive: every original character must survive in order.
|
|
6
|
+
* Normalization belongs to submitted output, never the visible editing buffer. */
|
|
7
|
+
function formatEditingValue(raw, selection, format) {
|
|
8
|
+
const unchanged = { display: raw, selection };
|
|
9
|
+
if (!format)
|
|
10
|
+
return unchanged;
|
|
11
|
+
let result;
|
|
12
|
+
try {
|
|
13
|
+
result = format(raw, selection);
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return unchanged;
|
|
17
|
+
}
|
|
18
|
+
if (!result)
|
|
19
|
+
return unchanged;
|
|
20
|
+
const characters = Array.from(raw);
|
|
21
|
+
let cursor = 0;
|
|
22
|
+
for (const character of result.display)
|
|
23
|
+
if (character === characters[cursor])
|
|
24
|
+
cursor += 1;
|
|
25
|
+
if (!Number.isInteger(result.selection.start) || !Number.isInteger(result.selection.end) || cursor !== characters.length || result.selection.start < 0 || result.selection.end < result.selection.start
|
|
26
|
+
|| result.selection.end > result.display.length)
|
|
27
|
+
return unchanged;
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
async function validateField(request, config) {
|
|
31
|
+
let output = request.raw;
|
|
32
|
+
let issues = [];
|
|
33
|
+
const check = () => request.signal.throwIfAborted();
|
|
34
|
+
try {
|
|
35
|
+
check();
|
|
36
|
+
if (config.parse)
|
|
37
|
+
output = await config.parse(request.raw, request);
|
|
38
|
+
check();
|
|
39
|
+
if (config.schema) {
|
|
40
|
+
const result = await config.schema['~standard'].validate(output);
|
|
41
|
+
check();
|
|
42
|
+
if (result.issues)
|
|
43
|
+
issues = result.issues;
|
|
44
|
+
else if ('value' in result)
|
|
45
|
+
output = result.value;
|
|
46
|
+
}
|
|
47
|
+
if (!issues.some(issue => issue.severity !== 'warning')) {
|
|
48
|
+
if (config.normalize)
|
|
49
|
+
output = await config.normalize(output, request);
|
|
50
|
+
check();
|
|
51
|
+
if (config.validator) {
|
|
52
|
+
const result = await config.validator(output, request);
|
|
53
|
+
check();
|
|
54
|
+
issues = [...issues, ...(result.issues ?? [])];
|
|
55
|
+
if ('output' in result)
|
|
56
|
+
output = result.output;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
check();
|
|
62
|
+
issues = [{ message: error instanceof Error ? error.message : 'Unable to validate this value.' }];
|
|
63
|
+
}
|
|
64
|
+
issues = [...issues, ...(config.issues ?? [])];
|
|
65
|
+
return { output: issues.some(issue => issue.severity !== 'warning') ? undefined : output, issues };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
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}}`;
|
|
69
|
+
|
|
70
|
+
const UICombobox = class {
|
|
71
|
+
constructor(hostRef) {
|
|
72
|
+
registerInstance(this, hostRef);
|
|
73
|
+
this.queryChange = createEvent(this, "query-change");
|
|
74
|
+
this.valueChange = createEvent(this, "value-change");
|
|
75
|
+
this.freeEntry = createEvent(this, "free-entry");
|
|
76
|
+
this.createEntry = createEvent(this, "create-entry");
|
|
77
|
+
this.dependencyInvalidate = createEvent(this, "dependency-invalidate");
|
|
78
|
+
this.validationChange = createEvent(this, "validation-change");
|
|
79
|
+
this.optionsChange = createEvent(this, "options-change");
|
|
80
|
+
}
|
|
81
|
+
get host() { return getElement(this); }
|
|
82
|
+
/** Accessible visible label, associated with the native text input. */
|
|
83
|
+
label = '';
|
|
84
|
+
placeholder = '';
|
|
85
|
+
name = '';
|
|
86
|
+
/** Controlled canonical value. Undefined selects uncontrolled mode; null means no selection. */
|
|
87
|
+
value;
|
|
88
|
+
defaultValue;
|
|
89
|
+
/** Controlled raw editing text; independent of canonical selection. */
|
|
90
|
+
query;
|
|
91
|
+
defaultQuery = '';
|
|
92
|
+
/** Immutable configuration; replace the object/context when dependencies change. */
|
|
93
|
+
config = {};
|
|
94
|
+
disabled = false;
|
|
95
|
+
readOnly = false;
|
|
96
|
+
required = false;
|
|
97
|
+
size = 'md';
|
|
98
|
+
disclosure = false;
|
|
99
|
+
clearable = false;
|
|
100
|
+
/** Optional description shown by the connected question-mark button. */
|
|
101
|
+
help = '';
|
|
102
|
+
queryChange;
|
|
103
|
+
valueChange;
|
|
104
|
+
freeEntry;
|
|
105
|
+
createEntry;
|
|
106
|
+
dependencyInvalidate;
|
|
107
|
+
validationChange;
|
|
108
|
+
/** Supplies the current result rows for framework-owned rich slots. */
|
|
109
|
+
optionsChange;
|
|
110
|
+
raw = '';
|
|
111
|
+
display = '';
|
|
112
|
+
selected = null;
|
|
113
|
+
expanded = false;
|
|
114
|
+
rows = [];
|
|
115
|
+
active = -1;
|
|
116
|
+
loading = false;
|
|
117
|
+
helpOpen = false;
|
|
118
|
+
lookupError = '';
|
|
119
|
+
validation = { status: 'pristine', touched: false, dirty: false, issues: [] };
|
|
120
|
+
input;
|
|
121
|
+
popup;
|
|
122
|
+
field;
|
|
123
|
+
surface;
|
|
124
|
+
lookup;
|
|
125
|
+
validationRun;
|
|
126
|
+
lookupTimer;
|
|
127
|
+
composing = false;
|
|
128
|
+
initialRaw = '';
|
|
129
|
+
overlayId = `ui-combobox-${Math.random().toString(36).slice(2)}`;
|
|
130
|
+
alive = false;
|
|
131
|
+
fullSet = false;
|
|
132
|
+
knownOptions = new Map();
|
|
133
|
+
awaitingLabel = null;
|
|
134
|
+
proposedChange;
|
|
135
|
+
formattedRaw;
|
|
136
|
+
formattedWith;
|
|
137
|
+
componentWillLoad() {
|
|
138
|
+
this.selected = this.value !== undefined ? this.value : this.defaultValue ?? null;
|
|
139
|
+
this.raw = this.query ?? this.defaultQuery;
|
|
140
|
+
if (this.query === undefined && !this.raw && this.selected !== null) {
|
|
141
|
+
this.raw = this.config.options?.find(row => row.value === this.selected)?.label ?? this.selected;
|
|
142
|
+
}
|
|
143
|
+
if (this.query === undefined && this.selected !== null && this.raw === this.selected)
|
|
144
|
+
this.awaitingLabel = this.selected;
|
|
145
|
+
this.display = this.raw;
|
|
146
|
+
this.initialRaw = this.raw;
|
|
147
|
+
this.applyServerIssues();
|
|
148
|
+
}
|
|
149
|
+
connectedCallback() { this.alive = true; this.setupSurface(); }
|
|
150
|
+
componentDidLoad() { this.setupSurface(); }
|
|
151
|
+
componentDidUpdate() {
|
|
152
|
+
if (this.input && !this.composing && this.input.value !== this.display)
|
|
153
|
+
this.input.value = this.display;
|
|
154
|
+
if (this.expanded)
|
|
155
|
+
this.surface?.refresh();
|
|
156
|
+
}
|
|
157
|
+
disconnectedCallback() {
|
|
158
|
+
this.alive = false;
|
|
159
|
+
this.close();
|
|
160
|
+
this.validationRun?.abort();
|
|
161
|
+
this.surface?.destroy();
|
|
162
|
+
this.surface = undefined;
|
|
163
|
+
}
|
|
164
|
+
setupSurface() {
|
|
165
|
+
if (!this.surface && this.popup && this.field)
|
|
166
|
+
this.surface = createAnchoredSurface(this.popup, { anchor: this.field, placement: 'bottom-start' });
|
|
167
|
+
}
|
|
168
|
+
syncValue() {
|
|
169
|
+
if (this.value === undefined)
|
|
170
|
+
return;
|
|
171
|
+
this.selected = this.value;
|
|
172
|
+
if (this.query === undefined) {
|
|
173
|
+
const proposal = this.proposedChange;
|
|
174
|
+
const option = this.config.options?.find(row => row.value === this.selected)
|
|
175
|
+
?? (this.selected === null ? undefined : this.knownOptions.get(this.selected));
|
|
176
|
+
const nextRaw = proposal?.value === this.selected ? proposal.query : option?.label ?? this.selected ?? '';
|
|
177
|
+
if (proposal?.value !== this.selected || nextRaw !== this.raw) {
|
|
178
|
+
this.raw = nextRaw;
|
|
179
|
+
this.display = this.raw;
|
|
180
|
+
this.formattedRaw = undefined;
|
|
181
|
+
}
|
|
182
|
+
this.awaitingLabel = !option && this.selected !== null ? this.selected : null;
|
|
183
|
+
}
|
|
184
|
+
this.resetValidation();
|
|
185
|
+
}
|
|
186
|
+
syncQuery() {
|
|
187
|
+
if (this.query === undefined || this.query === this.raw)
|
|
188
|
+
return;
|
|
189
|
+
// Only a selection proposal's query echo retains an uncontrolled identity.
|
|
190
|
+
// Other owner text replacements are edits, just like native input.
|
|
191
|
+
if (this.value === undefined && this.proposedChange?.query !== this.query)
|
|
192
|
+
this.selected = null;
|
|
193
|
+
this.awaitingLabel = null;
|
|
194
|
+
this.formattedRaw = undefined;
|
|
195
|
+
this.raw = this.query;
|
|
196
|
+
this.display = this.raw;
|
|
197
|
+
this.resetValidation();
|
|
198
|
+
if (this.expanded)
|
|
199
|
+
this.search('input');
|
|
200
|
+
}
|
|
201
|
+
syncDisabled() {
|
|
202
|
+
if (this.disabled || this.readOnly) {
|
|
203
|
+
this.close();
|
|
204
|
+
this.resetValidation();
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
syncConfig(next, previous) {
|
|
208
|
+
this.validationRun?.abort();
|
|
209
|
+
if (next.provider !== previous?.provider || next.context !== previous?.context)
|
|
210
|
+
this.knownOptions.clear();
|
|
211
|
+
if (next.context !== previous?.context) {
|
|
212
|
+
this.close();
|
|
213
|
+
const policy = next.invalidation ?? 'retain-query';
|
|
214
|
+
const value = policy === 'retain' ? this.selected : null;
|
|
215
|
+
const query = policy === 'clear' ? '' : this.raw;
|
|
216
|
+
this.commit(value, query, null, 'invalidation', 'programmatic');
|
|
217
|
+
this.validation = { status: 'pristine', touched: false, dirty: this.raw !== this.initialRaw, issues: [] };
|
|
218
|
+
}
|
|
219
|
+
this.applyServerIssues();
|
|
220
|
+
if (this.expanded)
|
|
221
|
+
this.search('context');
|
|
222
|
+
}
|
|
223
|
+
applyServerIssues() {
|
|
224
|
+
const issues = this.config.issues ?? [];
|
|
225
|
+
if (issues.length)
|
|
226
|
+
this.setValidation({ issues }, this.validation.touched);
|
|
227
|
+
else
|
|
228
|
+
this.resetValidation();
|
|
229
|
+
}
|
|
230
|
+
resetValidation() {
|
|
231
|
+
this.validationRun?.abort();
|
|
232
|
+
this.validation = { status: 'pristine', touched: this.validation.touched, dirty: this.raw !== this.initialRaw, issues: [] };
|
|
233
|
+
this.validationChange?.emit(this.validation);
|
|
234
|
+
}
|
|
235
|
+
cancelLookup() {
|
|
236
|
+
clearTimeout(this.lookupTimer);
|
|
237
|
+
this.lookup?.abort();
|
|
238
|
+
this.lookup = undefined;
|
|
239
|
+
this.loading = false;
|
|
240
|
+
}
|
|
241
|
+
close() {
|
|
242
|
+
this.expanded = false;
|
|
243
|
+
this.active = -1;
|
|
244
|
+
this.cancelLookup();
|
|
245
|
+
this.surface?.hide();
|
|
246
|
+
closeOverlay(this.overlayId);
|
|
247
|
+
}
|
|
248
|
+
open(reason = 'input') {
|
|
249
|
+
if (this.disabled || this.readOnly)
|
|
250
|
+
return;
|
|
251
|
+
this.expanded = true;
|
|
252
|
+
if (this.popup && this.field)
|
|
253
|
+
this.popup.style.minWidth = `${this.field.getBoundingClientRect().width}px`;
|
|
254
|
+
this.surface?.show();
|
|
255
|
+
openOverlay({ id: this.overlayId, element: this.popup, relatedElements: [this.host], modal: false,
|
|
256
|
+
requestClose: () => this.close() });
|
|
257
|
+
this.search(reason);
|
|
258
|
+
}
|
|
259
|
+
search(reason) {
|
|
260
|
+
this.cancelLookup();
|
|
261
|
+
this.fullSet = reason === 'disclosure';
|
|
262
|
+
this.active = -1;
|
|
263
|
+
this.lookupError = '';
|
|
264
|
+
const config = this.config;
|
|
265
|
+
const query = this.fullSet ? '' : this.raw;
|
|
266
|
+
const controller = new AbortController();
|
|
267
|
+
this.lookup = controller;
|
|
268
|
+
const apply = (options) => {
|
|
269
|
+
if (controller.signal.aborted || !this.alive)
|
|
270
|
+
return;
|
|
271
|
+
for (const option of options)
|
|
272
|
+
this.knownOptions.set(option.value, option);
|
|
273
|
+
const selectedOption = this.selected === null ? undefined : this.knownOptions.get(this.selected);
|
|
274
|
+
if (this.query === undefined && this.awaitingLabel === this.selected && selectedOption) {
|
|
275
|
+
this.raw = selectedOption.label;
|
|
276
|
+
this.display = this.raw;
|
|
277
|
+
this.awaitingLabel = null;
|
|
278
|
+
this.formattedRaw = undefined;
|
|
279
|
+
this.resetValidation();
|
|
280
|
+
}
|
|
281
|
+
const ids = new Set();
|
|
282
|
+
this.rows = options.filter(option => {
|
|
283
|
+
if (ids.has(option.id))
|
|
284
|
+
return false;
|
|
285
|
+
ids.add(option.id);
|
|
286
|
+
return this.fullSet || (config.filter ? config.filter(option, query, config.context)
|
|
287
|
+
: config.provider ? true : option.label.toLocaleLowerCase().includes(query.toLocaleLowerCase()));
|
|
288
|
+
});
|
|
289
|
+
const groups = new Map();
|
|
290
|
+
for (const row of this.rows) {
|
|
291
|
+
const group = row.group ?? '';
|
|
292
|
+
if (!groups.has(group))
|
|
293
|
+
groups.set(group, []);
|
|
294
|
+
groups.get(group).push(row);
|
|
295
|
+
}
|
|
296
|
+
this.rows = [...groups.values()].flat();
|
|
297
|
+
this.loading = false;
|
|
298
|
+
this.optionsChange.emit(this.rows);
|
|
299
|
+
};
|
|
300
|
+
if (!config.provider) {
|
|
301
|
+
apply(config.options ?? []);
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
this.rows = [];
|
|
305
|
+
this.loading = true;
|
|
306
|
+
this.lookupTimer = setTimeout(async () => {
|
|
307
|
+
try {
|
|
308
|
+
apply(await config.provider({ query, context: config.context, signal: controller.signal, reason }));
|
|
309
|
+
}
|
|
310
|
+
catch (error) {
|
|
311
|
+
if (controller.signal.aborted || !this.alive)
|
|
312
|
+
return;
|
|
313
|
+
this.loading = false;
|
|
314
|
+
this.lookupError = error instanceof Error ? error.message : 'Unable to load suggestions.';
|
|
315
|
+
}
|
|
316
|
+
}, reason === 'disclosure' ? 0 : Math.max(0, config.debounce ?? 200));
|
|
317
|
+
}
|
|
318
|
+
get canCreate() {
|
|
319
|
+
return Boolean(this.config.allowCreate && this.raw.trim() && !this.loading && !this.lookupError
|
|
320
|
+
&& !this.rows.some(row => row.label.toLocaleLowerCase() === this.raw.toLocaleLowerCase()));
|
|
321
|
+
}
|
|
322
|
+
format(timing) {
|
|
323
|
+
if ((this.config.formatOn ?? 'blur') !== timing || !this.input)
|
|
324
|
+
return;
|
|
325
|
+
// Selection is now in display coordinates; do not map it as raw a second time.
|
|
326
|
+
if (this.formattedRaw === this.raw && this.formattedWith === this.config.format)
|
|
327
|
+
return;
|
|
328
|
+
const result = formatEditingValue(this.raw, {
|
|
329
|
+
start: this.input.selectionStart ?? this.raw.length, end: this.input.selectionEnd ?? this.raw.length,
|
|
330
|
+
direction: this.input.selectionDirection ?? 'none',
|
|
331
|
+
}, this.config.format);
|
|
332
|
+
this.formattedRaw = this.raw;
|
|
333
|
+
this.formattedWith = this.config.format;
|
|
334
|
+
this.display = result.display;
|
|
335
|
+
if (this.input.value !== result.display) {
|
|
336
|
+
this.input.value = result.display;
|
|
337
|
+
this.input.setSelectionRange(result.selection.start, result.selection.end, result.selection.direction);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
onInput = (event) => {
|
|
341
|
+
// Composition updates remain entirely native until compositionend.
|
|
342
|
+
if (this.composing || event.isComposing)
|
|
343
|
+
return;
|
|
344
|
+
this.awaitingLabel = null;
|
|
345
|
+
this.formattedRaw = undefined;
|
|
346
|
+
this.raw = this.input.value;
|
|
347
|
+
this.display = this.raw;
|
|
348
|
+
this.resetValidation();
|
|
349
|
+
this.format('input');
|
|
350
|
+
this.queryChange.emit({ query: this.raw, display: this.display, trigger: 'keyboard' });
|
|
351
|
+
if (this.selected !== null)
|
|
352
|
+
this.commit(null, this.raw, null, 'clear', 'keyboard');
|
|
353
|
+
this.open();
|
|
354
|
+
if (this.config.validateOn === 'input')
|
|
355
|
+
void this.validate();
|
|
356
|
+
queueMicrotask(() => {
|
|
357
|
+
if (this.query !== undefined && this.query !== this.raw)
|
|
358
|
+
this.syncQuery();
|
|
359
|
+
});
|
|
360
|
+
};
|
|
361
|
+
commit(value, query, option, kind, trigger) {
|
|
362
|
+
this.awaitingLabel = null;
|
|
363
|
+
const queryChanged = query !== this.raw;
|
|
364
|
+
if (this.value === undefined)
|
|
365
|
+
this.selected = value;
|
|
366
|
+
if (this.query === undefined && queryChanged) {
|
|
367
|
+
this.raw = query;
|
|
368
|
+
this.display = query;
|
|
369
|
+
this.formattedRaw = undefined;
|
|
370
|
+
}
|
|
371
|
+
this.resetValidation();
|
|
372
|
+
const detail = { value, query, option, kind, trigger };
|
|
373
|
+
const proposal = { value, query };
|
|
374
|
+
this.proposedChange = proposal;
|
|
375
|
+
this.valueChange.emit(detail);
|
|
376
|
+
if (queryChanged)
|
|
377
|
+
this.queryChange.emit({ query, display: query, trigger });
|
|
378
|
+
if (kind === 'create')
|
|
379
|
+
this.createEntry.emit(detail);
|
|
380
|
+
if (kind === 'free-entry')
|
|
381
|
+
this.freeEntry.emit(detail);
|
|
382
|
+
if (kind === 'invalidation')
|
|
383
|
+
this.dependencyInvalidate.emit(detail);
|
|
384
|
+
// Settle after all owner notifications (including Vue's queued update).
|
|
385
|
+
// A retained prop does not fire a Stencil watcher, so rejection must be
|
|
386
|
+
// reconciled explicitly while the proposal still identifies an edit echo.
|
|
387
|
+
queueMicrotask(() => {
|
|
388
|
+
if (this.proposedChange !== proposal)
|
|
389
|
+
return;
|
|
390
|
+
if (this.value !== undefined && this.value !== proposal.value)
|
|
391
|
+
this.syncValue();
|
|
392
|
+
if (this.query !== undefined && this.query !== proposal.query) {
|
|
393
|
+
if (this.value === undefined) {
|
|
394
|
+
this.selected = null;
|
|
395
|
+
this.resetValidation();
|
|
396
|
+
}
|
|
397
|
+
this.syncQuery();
|
|
398
|
+
}
|
|
399
|
+
this.proposedChange = undefined;
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
choose(index, trigger) {
|
|
403
|
+
const option = this.rows[index];
|
|
404
|
+
if (option?.disabled)
|
|
405
|
+
return;
|
|
406
|
+
if (option)
|
|
407
|
+
this.commit(option.value, option.label, option, 'selection', trigger);
|
|
408
|
+
else if (this.canCreate && index === this.rows.length)
|
|
409
|
+
this.commit(null, this.raw, null, 'create', trigger);
|
|
410
|
+
else
|
|
411
|
+
return;
|
|
412
|
+
this.close();
|
|
413
|
+
this.input?.focus();
|
|
414
|
+
if (this.config.validateOn !== 'submit')
|
|
415
|
+
queueMicrotask(() => void this.validate());
|
|
416
|
+
}
|
|
417
|
+
move(key) {
|
|
418
|
+
const indices = this.rows.flatMap((row, index) => row.disabled ? [] : [index]);
|
|
419
|
+
if (this.canCreate)
|
|
420
|
+
indices.push(this.rows.length);
|
|
421
|
+
if (!indices.length)
|
|
422
|
+
return;
|
|
423
|
+
const current = indices.indexOf(this.active);
|
|
424
|
+
const next = key === 'Home' ? 0 : key === 'End' ? indices.length - 1
|
|
425
|
+
: key === 'ArrowDown' ? Math.min(current + 1, indices.length - 1)
|
|
426
|
+
: current < 0 ? indices.length - 1 : Math.max(0, current - 1);
|
|
427
|
+
this.active = indices[next];
|
|
428
|
+
requestAnimationFrame(() => this.host.shadowRoot?.getElementById(`option-${this.active}`)?.scrollIntoView({ block: 'nearest' }));
|
|
429
|
+
}
|
|
430
|
+
onKeydown = (event) => {
|
|
431
|
+
if (this.composing || event.isComposing || this.disabled || this.readOnly)
|
|
432
|
+
return;
|
|
433
|
+
if (event.key === 'Escape' && this.expanded) {
|
|
434
|
+
event.preventDefault();
|
|
435
|
+
event.stopPropagation();
|
|
436
|
+
this.close();
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
if (event.key === 'Tab') {
|
|
440
|
+
this.close();
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey)
|
|
444
|
+
return;
|
|
445
|
+
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
|
446
|
+
event.preventDefault();
|
|
447
|
+
if (!this.expanded)
|
|
448
|
+
this.open('disclosure');
|
|
449
|
+
this.move(event.key);
|
|
450
|
+
}
|
|
451
|
+
else if ((event.key === 'Home' || event.key === 'End') && this.expanded && this.active >= 0) {
|
|
452
|
+
event.preventDefault();
|
|
453
|
+
this.move(event.key);
|
|
454
|
+
}
|
|
455
|
+
else if (event.key === 'Enter' && this.expanded) {
|
|
456
|
+
if (this.active >= 0) {
|
|
457
|
+
event.preventDefault();
|
|
458
|
+
this.choose(this.active, 'keyboard');
|
|
459
|
+
}
|
|
460
|
+
else if (this.config.allowFreeText) {
|
|
461
|
+
event.preventDefault();
|
|
462
|
+
this.commit(null, this.raw, null, 'free-entry', 'keyboard');
|
|
463
|
+
this.close();
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
};
|
|
467
|
+
onFocusOut = (event) => {
|
|
468
|
+
if (event.relatedTarget instanceof Node && this.host.shadowRoot?.contains(event.relatedTarget))
|
|
469
|
+
return;
|
|
470
|
+
this.close();
|
|
471
|
+
this.format('blur');
|
|
472
|
+
this.validation = { ...this.validation, touched: true };
|
|
473
|
+
if (this.config.allowFreeText && this.selected === null)
|
|
474
|
+
this.commit(null, this.raw, null, 'free-entry', 'keyboard');
|
|
475
|
+
if ((this.config.validateOn ?? 'blur') === 'blur')
|
|
476
|
+
void this.validate();
|
|
477
|
+
};
|
|
478
|
+
setValidation(result, touched = this.validation.touched) {
|
|
479
|
+
const blocking = result.issues.some(issue => issue.severity !== 'warning');
|
|
480
|
+
this.validation = { status: blocking ? 'error' : result.issues.length ? 'warning' : 'valid',
|
|
481
|
+
touched, dirty: this.raw !== this.initialRaw, ...result };
|
|
482
|
+
this.validationChange?.emit(this.validation);
|
|
483
|
+
}
|
|
484
|
+
/** Validate for submission. Caller submits only non-pending, non-error output. */
|
|
485
|
+
async validate() {
|
|
486
|
+
this.validationRun?.abort();
|
|
487
|
+
const run = new AbortController();
|
|
488
|
+
this.validationRun = run;
|
|
489
|
+
this.validation = { ...this.validation, status: 'pending', output: undefined };
|
|
490
|
+
this.validationChange.emit(this.validation);
|
|
491
|
+
try {
|
|
492
|
+
const result = await validateField({ raw: this.raw, value: this.selected, context: this.config.context, signal: run.signal }, this.config);
|
|
493
|
+
if (this.required && !this.raw.trim())
|
|
494
|
+
result.issues = [...result.issues, { message: 'A value is required.' }];
|
|
495
|
+
else if (this.raw && this.selected === null && !this.config.allowFreeText && !this.config.allowCreate)
|
|
496
|
+
result.issues = [...result.issues, { message: 'Choose a suggestion.' }];
|
|
497
|
+
if (result.issues.some(issue => issue.severity !== 'warning'))
|
|
498
|
+
result.output = undefined;
|
|
499
|
+
if (!run.signal.aborted && this.alive)
|
|
500
|
+
this.setValidation(result);
|
|
501
|
+
}
|
|
502
|
+
catch { /* Aborted work never becomes current field state. */ }
|
|
503
|
+
return this.validation;
|
|
504
|
+
}
|
|
505
|
+
render() {
|
|
506
|
+
const description = [this.helpOpen ? 'help-text' : '', this.validation.issues.length ? 'validation' : ''].filter(Boolean).join(' ') || undefined;
|
|
507
|
+
const status = this.loading ? 'Loading suggestions…' : this.lookupError || (this.expanded ? `${this.rows.length} suggestions available.` : '');
|
|
508
|
+
const groups = [...new Set(this.rows.map(row => row.group ?? ''))];
|
|
509
|
+
return h(Host, { key: '2378bfd8473852642fef21898f4a756eb3b092ba', "data-size": this.size, "data-validation": this.validation.status, onFocusout: this.onFocusOut }, h("label", { key: '7aba65aeb336d490ddeaf5db9bba9db8ab8b9dbb', htmlFor: "input", part: "label" }, this.label, this.required ? ' *' : ''), h("div", { key: 'ee87156259d0fe1e2e56c4b36667e8daf5e1e2c1', class: "field", part: "field", ref: element => this.field = element }, h("input", { key: '35c5b85ff9a4bcba9bddaf85ff1f118a94aa077b', 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 && h("button", { key: '74e4f44836b751ab5e9f794a39b480602e0c106d', 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 && h("button", { key: 'c870ced139fb22baa50a1795ab78f14c38647d34', id: "help", type: "button", part: "affordance", "aria-label": `Help for ${this.label}`, disabled: this.disabled }, h("span", { key: 'ba3dc5128c1941b21b53a5ba78a27017b3df5ec8', "aria-hidden": "true" }, "?")), this.disclosure && h("button", { key: 'eced588e3fa7958dd6185173faaef01219c30243', type: "button", part: "affordance", "aria-label": `Suggestions for ${this.label}`, "aria-controls": "listbox", "aria-expanded": String(this.expanded), disabled: this.disabled || this.readOnly, onClick: () => {
|
|
510
|
+
if (this.expanded)
|
|
511
|
+
this.close();
|
|
512
|
+
else
|
|
513
|
+
this.open('disclosure');
|
|
514
|
+
this.input?.focus();
|
|
515
|
+
} }, h("span", { key: '7cb9f7f2bb15246dcdd2348ea0ca656d1d0c8c33', "aria-hidden": "true" }, "\u2304"))), this.help && h("ui-tooltip", { key: 'b1b5d42ca457f9b951758bb5e816c8dbbcd1087d', id: "help-text", for: "help", toggleOnClick: true, onOpen: () => this.helpOpen = true, onClose: () => this.helpOpen = false }, this.help), h("div", { key: '9eca2df66c72917e6bfda21205c2a4ef97dd91d5', class: "popup", part: "popup", hidden: !this.expanded, ref: element => this.popup = element }, h("div", { key: '641e1f137c9cfef5d08ec99f6178e59487a20bf1', id: "listbox", role: "listbox", "aria-label": `${this.label} suggestions`, "aria-busy": String(this.loading) }, groups.map(group => h("div", { role: group ? 'group' : 'presentation', "aria-label": group || undefined }, group && h("div", { class: "group", part: "group" }, group), this.rows.map((row, index) => (row.group ?? '') !== group ? null : h("div", { id: `option-${index}`, role: "option", "aria-selected": String(this.selected === row.value), "aria-disabled": String(Boolean(row.disabled)), "data-active": this.active === index ? '' : undefined, part: "option", class: "option", onPointerDown: event => event.preventDefault(), onClick: () => this.choose(index, 'pointer') }, h("slot", { name: `option-${row.id}` }, h("span", { class: "primary", part: "option-primary" }, row.label), row.description && h("span", { class: "secondary", part: "option-secondary" }, row.description)))))), this.canCreate && h("div", { key: '38a3aa6b2ffae30e6f81e1f89d10c9966dd31b10', 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') }, h("slot", { key: 'dd3e895ef363f6d30a0c25e4b5092a8feacc63e5', name: "create" }, "Create \u201C", this.raw, "\u201D"))), this.loading ? h("div", { class: "message" }, h("slot", { name: "loading" }, "Loading suggestions\u2026"))
|
|
516
|
+
: this.lookupError ? h("div", { class: "message" }, h("slot", { name: "error" }, this.lookupError))
|
|
517
|
+
: !this.rows.length && !this.canCreate ? h("div", { class: "message" }, h("slot", { name: "empty" }, "No suggestions.")) : null), h("div", { key: '9cf12a8fde7d9cfb9e2d2a77669ac4708c7fded6', id: "validation", class: "message", part: "validation", hidden: !this.validation.issues.length }, this.validation.issues.map(issue => h("div", null, issue.message))), h("div", { key: '1c7b1d3f658e500cbf5f5004a76a39511cc79c49', 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(' ')));
|
|
518
|
+
}
|
|
519
|
+
static get watchers() { return {
|
|
520
|
+
"value": [{
|
|
521
|
+
"syncValue": 0
|
|
522
|
+
}],
|
|
523
|
+
"query": [{
|
|
524
|
+
"syncQuery": 0
|
|
525
|
+
}],
|
|
526
|
+
"disabled": [{
|
|
527
|
+
"syncDisabled": 0
|
|
528
|
+
}],
|
|
529
|
+
"readOnly": [{
|
|
530
|
+
"syncDisabled": 0
|
|
531
|
+
}],
|
|
532
|
+
"config": [{
|
|
533
|
+
"syncConfig": 0
|
|
534
|
+
}]
|
|
535
|
+
}; }
|
|
536
|
+
};
|
|
537
|
+
UICombobox.style = uiComboboxCss();
|
|
538
|
+
|
|
539
|
+
export { UICombobox as ui_combobox };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as registerInstance, g as getElement, h, H as Host } from './index-
|
|
2
|
-
import { o as openOverlay, c as closeOverlay, r as requestTopOverlayClose } from './manager-
|
|
1
|
+
import { r as registerInstance, g as getElement, h, H as Host } from './index-8BGiMGQ0.js';
|
|
2
|
+
import { o as openOverlay, c as closeOverlay, r as requestTopOverlayClose } from './manager-C-0syqXZ.js';
|
|
3
3
|
import { d as dispatchDetail } from './events-JwSoedEO.js';
|
|
4
4
|
import { a as createAnchoredSurface } from './positioning-Bu0dmLBE.js';
|
|
5
5
|
|
|
@@ -218,7 +218,7 @@ const UIContextMenu = class {
|
|
|
218
218
|
this.closeMenu('action', 'pointer');
|
|
219
219
|
};
|
|
220
220
|
render() {
|
|
221
|
-
return (h(Host, { key: '
|
|
221
|
+
return (h(Host, { key: '641dd3aba6120cf4187f4503c64029eaf307dc4f', "data-open": this.internalOpen ? '' : undefined, "data-focus-trigger": this.internalOpen ? this.focusTrigger : undefined, onKeyDown: this.onKeydown, onClick: this.onItemClick }, h("slot", { key: '3f550349f9537b951b50a8c291f1951dd5a3b723', name: "trigger" }), h("div", { key: 'a612523f054986122638722340d8135c44a85399', class: "menu", "data-open": this.internalOpen ? '' : undefined }, h("ui-menu", { key: '0711879d09900183e938d8942abb8b9032812a5f', open: this.internalOpen }, h("slot", { key: '8e088dd20a48d8fb81126f2dd020abb886e86e22' })))));
|
|
222
222
|
}
|
|
223
223
|
static get watchers() { return {
|
|
224
224
|
"open": [{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as registerInstance, g as getElement, h, H as Host } from './index-
|
|
2
|
-
import { o as openOverlay, c as closeOverlay, r as requestTopOverlayClose } from './manager-
|
|
1
|
+
import { r as registerInstance, g as getElement, h, H as Host } from './index-8BGiMGQ0.js';
|
|
2
|
+
import { o as openOverlay, c as closeOverlay, r as requestTopOverlayClose } from './manager-C-0syqXZ.js';
|
|
3
3
|
import { d as dispatchDetail } from './events-JwSoedEO.js';
|
|
4
4
|
|
|
5
5
|
const uiDialogCss = () => `:host{display:block}:host:not([data-open]){display:none}:host dialog{--ui-dialog-duration:var(--ui-motion-base);--ui-dialog-viewport-gap:var(--ui-space-4, 1rem);position:fixed;inset:0;inline-size:min( calc(100% - (var(--ui-dialog-viewport-gap) * 2)), var(--ui-dialog-max-width, 440px) );max-inline-size:none;max-block-size:calc(100dvh - (var(--ui-dialog-viewport-gap) * 2));margin:auto;padding:var(--ui-space-4);overflow:auto;background:var(--ui-surface-elevated);border:1px solid var(--ui-border-default);border-radius:var(--ui-radius-dialog);box-shadow:var(--ui-shadow-dialog);visibility:hidden;pointer-events:none;opacity:0;transform:scale(0.96);transition:opacity var(--ui-dialog-duration) var(--ui-motion-ease), transform var(--ui-dialog-duration) var(--ui-motion-ease), visibility var(--ui-dialog-duration), display var(--ui-dialog-duration) var(--ui-motion-ease) allow-discrete, overlay var(--ui-dialog-duration) var(--ui-motion-ease) allow-discrete}:host dialog[open]{visibility:visible;pointer-events:auto;opacity:1;transform:scale(1);animation:ui-dialog-enter var(--ui-dialog-duration) var(--ui-motion-ease)}@keyframes ui-dialog-enter{from{opacity:0;transform:scale(0.96)}}:host dialog::backdrop{background-color:transparent;transition:background-color var(--ui-dialog-duration) var(--ui-motion-ease), display var(--ui-dialog-duration) var(--ui-motion-ease) allow-discrete, overlay var(--ui-dialog-duration) var(--ui-motion-ease) allow-discrete}:host dialog[open]::backdrop{background-color:var(--ui-overlay-backdrop);animation:ui-dialog-backdrop-enter var(--ui-dialog-duration) var(--ui-motion-ease)}@keyframes ui-dialog-backdrop-enter{from{background-color:transparent}}`;
|
|
@@ -77,7 +77,7 @@ const UIDialog = class {
|
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
79
|
render() {
|
|
80
|
-
return (h(Host, { key: '
|
|
80
|
+
return (h(Host, { key: '6e88afd3a595ab0eed3d82a046ffb15e1e167cdb', "data-open": this.internalOpen ? '' : undefined, onKeyDown: this.onKeydown }, h("dialog", { key: '420e4d8de66245a5818a1284adb23a536ebcd907', ref: (el) => (this.dialogRef = el), open: this.internalOpen, "aria-label": this.label }, h("slot", { key: '10604688504f013f79b7a6ed5f9ed36bc9c6b48b' }))));
|
|
81
81
|
}
|
|
82
82
|
static get watchers() { return {
|
|
83
83
|
"open": [{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as registerInstance, g as getElement, h, H as Host } from './index-
|
|
1
|
+
import { r as registerInstance, g as getElement, h, H as Host } from './index-8BGiMGQ0.js';
|
|
2
2
|
import { c as createId } from './id-hgBUJRDa.js';
|
|
3
3
|
import { d as dispatchDetail, e as eventToTrigger, i as isActivationKey } from './events-JwSoedEO.js';
|
|
4
4
|
|
|
@@ -91,7 +91,7 @@ const UIDisclosure = class {
|
|
|
91
91
|
this.setOpen(!this.internalOpen, { reason: 'action', trigger: 'keyboard' });
|
|
92
92
|
};
|
|
93
93
|
render() {
|
|
94
|
-
return (h(Host, { key: '
|
|
94
|
+
return (h(Host, { key: '3905d2d78a2d3d4ef36b582ba0f426be8e5e0f5e' }, h("slot", { key: '18547ff56457b73319264bba981f994fb947dffb' })));
|
|
95
95
|
}
|
|
96
96
|
static get watchers() { return {
|
|
97
97
|
"open": [{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as registerInstance, h, H as Host } from './index-
|
|
1
|
+
import { r as registerInstance, h, H as Host } from './index-8BGiMGQ0.js';
|
|
2
2
|
|
|
3
3
|
const uiFloatingActionButtonCss = () => `:host{position:fixed;inset-block-end:calc( var(--ui-floating-action-button-bottom, var(--ui-space-6, 1.5rem)) + env(safe-area-inset-bottom) );inset-inline-end:max( var(--ui-floating-action-button-inline-end, var(--ui-space-5, 1.25rem)), env(safe-area-inset-right) );inline-size:var(--ui-floating-action-button-size, 56px);block-size:var(--ui-floating-action-button-size, 56px);display:inline-flex;z-index:var(--ui-floating-action-button-z-index, 100)}button{appearance:none;inline-size:100%;block-size:100%;border:none;border-radius:999px;margin:0;padding:0;display:inline-flex;align-items:center;justify-content:center;background:var(--ui-floating-action-button-bg, var(--ui-accent-solid));color:var(--ui-floating-action-button-color, var(--ui-text-on-accent));box-shadow:var( --ui-floating-action-button-shadow, 0 4px 12px color-mix(in srgb, var(--ui-accent-solid) 40%, transparent) );cursor:pointer;transition:background-color var(--ui-motion-fast, 160ms) var(--ui-motion-ease, ease), transform var(--ui-motion-fast, 160ms) var(--ui-motion-ease, ease), box-shadow var(--ui-motion-fast, 160ms) var(--ui-motion-ease, ease)}button:hover:enabled{background:var(--ui-floating-action-button-hover-bg, var(--ui-accent-hover));box-shadow:var( --ui-floating-action-button-hover-shadow, 0 6px 16px color-mix(in srgb, var(--ui-accent-solid) 50%, transparent) )}button:active:enabled{transform:scale(var(--ui-floating-action-button-active-scale, 0.94))}button:focus-visible{outline:2px solid var(--ui-focus-ring);outline-offset:2px}button:disabled,:host([disabled]){opacity:0.6;cursor:not-allowed}::slotted(svg){inline-size:var(--ui-floating-action-button-icon-size, 24px);block-size:var(--ui-floating-action-button-icon-size, 24px);flex-shrink:0}@media (min-width: 768px){:host([mobile-only]){display:none}}`;
|
|
4
4
|
|
|
@@ -10,7 +10,7 @@ const UIFloatingActionButton = class {
|
|
|
10
10
|
mobileOnly = false;
|
|
11
11
|
label = '';
|
|
12
12
|
render() {
|
|
13
|
-
return (h(Host, { key: '
|
|
13
|
+
return (h(Host, { key: 'c9a7d8c9b6d6608566b21621a73d939f372c830d', "data-disabled": this.disabled ? '' : undefined }, h("button", { key: '8eddccaf6be2f028bc02df967038843120045b84', type: "button", "aria-label": this.label || undefined, disabled: this.disabled }, h("slot", { key: '0ea12efb9cb8ecec06238066827a734fb3b01e1e' }))));
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
16
|
UIFloatingActionButton.style = uiFloatingActionButtonCss();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { r as registerInstance, g as getElement, h, H as Host } from './index-
|
|
1
|
+
import { r as registerInstance, g as getElement, h, H as Host } from './index-8BGiMGQ0.js';
|
|
2
2
|
import { c as createId } from './id-hgBUJRDa.js';
|
|
3
3
|
|
|
4
|
-
const uiFormFieldCss = () => `:host{display:grid;gap:var(--ui-space-2);color:var(--ui-text-primary)}::slotted(label){color:var(--ui-text-secondary);font-size:0.95rem}::slotted([data-slot='help']){color:var(--ui-text-muted);font-size:0.875rem}::slotted([data-slot='error']),::slotted([role='alert']){color:var(--ui-accent-active);font-size:0.875rem}`;
|
|
4
|
+
const uiFormFieldCss = () => `:host{display:grid;gap:var(--ui-space-2);min-inline-size:0;align-content:start;color:var(--ui-text-primary)}::slotted(label){color:var(--ui-text-secondary);font-size:0.95rem}::slotted([data-slot='help']){min-block-size:var(--ui-form-field-help-min-block-size, 0);color:var(--ui-text-muted);font-size:0.875rem;line-height:var(--ui-line-height-md)}::slotted([data-slot='error']),::slotted([role='alert']){color:var(--ui-accent-active);font-size:0.875rem}`;
|
|
5
5
|
|
|
6
6
|
const UIFormField = class {
|
|
7
7
|
constructor(hostRef) {
|
|
@@ -49,7 +49,7 @@ const UIFormField = class {
|
|
|
49
49
|
input.setAttribute('aria-invalid', this.invalid ? 'true' : 'false');
|
|
50
50
|
}
|
|
51
51
|
render() {
|
|
52
|
-
return (h(Host, { key: '
|
|
52
|
+
return (h(Host, { key: 'cdd06c6b16ac56f3547e64e7888d8766243392db', "data-invalid": this.invalid ? '' : undefined, "data-disabled": this.disabled ? '' : undefined, "data-required": this.required ? '' : undefined }, h("slot", { key: '7d545673a3485f8beee01b13ab56185b98ba8856' })));
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
55
|
UIFormField.style = uiFormFieldCss();
|