@uvalib/web-components 1.2.0 → 1.3.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.
Files changed (200) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/README.md +808 -46
  3. package/dist/analytics.d.ts +10 -0
  4. package/dist/analytics.js +9 -0
  5. package/dist/analytics.js.map +1 -0
  6. package/dist/base/UvalibElement.js +8 -5
  7. package/dist/base/UvalibElement.js.map +1 -1
  8. package/dist/base/analytics-state.d.ts +7 -0
  9. package/dist/base/analytics-state.js.map +1 -1
  10. package/dist/base/light-dom-styles.d.ts +13 -0
  11. package/dist/base/light-dom-styles.js +26 -0
  12. package/dist/base/light-dom-styles.js.map +1 -1
  13. package/dist/base/search-tracker.d.ts +57 -0
  14. package/dist/base/search-tracker.js +51 -0
  15. package/dist/base/search-tracker.js.map +1 -0
  16. package/dist/base.css +286 -14
  17. package/dist/base.d.ts +2 -0
  18. package/dist/base.js +1 -0
  19. package/dist/base.js.map +1 -1
  20. package/dist/components/site-analytics/SiteAnalytics.d.ts +20 -1
  21. package/dist/components/site-analytics/SiteAnalytics.js +93 -12
  22. package/dist/components/site-analytics/SiteAnalytics.js.map +1 -1
  23. package/dist/components/site-page/SitePage.d.ts +23 -0
  24. package/dist/components/site-page/SitePage.js +77 -0
  25. package/dist/components/site-page/SitePage.js.map +1 -1
  26. package/dist/components/uvalib-back-to-top/UvalibBackToTop.d.ts +58 -0
  27. package/dist/components/uvalib-back-to-top/UvalibBackToTop.js +250 -0
  28. package/dist/components/uvalib-back-to-top/UvalibBackToTop.js.map +1 -0
  29. package/dist/components/uvalib-back-to-top/uvalib-back-to-top.d.ts +1 -0
  30. package/dist/components/uvalib-back-to-top/uvalib-back-to-top.js +4 -0
  31. package/dist/components/uvalib-back-to-top/uvalib-back-to-top.js.map +1 -0
  32. package/dist/components/uvalib-breadcrumbs/UvalibBreadcrumbs.d.ts +14 -0
  33. package/dist/components/uvalib-breadcrumbs/UvalibBreadcrumbs.js +56 -4
  34. package/dist/components/uvalib-breadcrumbs/UvalibBreadcrumbs.js.map +1 -1
  35. package/dist/components/uvalib-chip-group/UvalibChipGroup.d.ts +25 -3
  36. package/dist/components/uvalib-chip-group/UvalibChipGroup.js +80 -10
  37. package/dist/components/uvalib-chip-group/UvalibChipGroup.js.map +1 -1
  38. package/dist/components/uvalib-combobox/UvalibCombobox.d.ts +212 -0
  39. package/dist/components/uvalib-combobox/UvalibCombobox.js +1088 -0
  40. package/dist/components/uvalib-combobox/UvalibCombobox.js.map +1 -0
  41. package/dist/components/uvalib-combobox/uvalib-combobox.d.ts +1 -0
  42. package/dist/components/uvalib-combobox/uvalib-combobox.js +4 -0
  43. package/dist/components/uvalib-combobox/uvalib-combobox.js.map +1 -0
  44. package/dist/components/uvalib-contents/UvalibContents.d.ts +53 -0
  45. package/dist/components/uvalib-contents/UvalibContents.js +202 -3
  46. package/dist/components/uvalib-contents/UvalibContents.js.map +1 -1
  47. package/dist/components/uvalib-date-histogram/UvalibDateHistogram.d.ts +56 -17
  48. package/dist/components/uvalib-date-histogram/UvalibDateHistogram.js +285 -81
  49. package/dist/components/uvalib-date-histogram/UvalibDateHistogram.js.map +1 -1
  50. package/dist/components/uvalib-date-range/UvalibDateRange.d.ts +6 -0
  51. package/dist/components/uvalib-date-range/UvalibDateRange.js +23 -0
  52. package/dist/components/uvalib-date-range/UvalibDateRange.js.map +1 -1
  53. package/dist/components/uvalib-filter-drawer/UvalibFilterDrawer.d.ts +113 -0
  54. package/dist/components/uvalib-filter-drawer/UvalibFilterDrawer.js +589 -0
  55. package/dist/components/uvalib-filter-drawer/UvalibFilterDrawer.js.map +1 -0
  56. package/dist/components/uvalib-filter-drawer/uvalib-filter-drawer.d.ts +1 -0
  57. package/dist/components/uvalib-filter-drawer/uvalib-filter-drawer.js +4 -0
  58. package/dist/components/uvalib-filter-drawer/uvalib-filter-drawer.js.map +1 -0
  59. package/dist/components/uvalib-image-regions/UvalibImageRegions.d.ts +130 -0
  60. package/dist/components/uvalib-image-regions/UvalibImageRegions.js +658 -0
  61. package/dist/components/uvalib-image-regions/UvalibImageRegions.js.map +1 -0
  62. package/dist/components/uvalib-image-regions/regions.d.ts +57 -0
  63. package/dist/components/uvalib-image-regions/regions.js +117 -0
  64. package/dist/components/uvalib-image-regions/regions.js.map +1 -0
  65. package/dist/components/uvalib-image-regions/uvalib-image-regions.d.ts +1 -0
  66. package/dist/components/uvalib-image-regions/uvalib-image-regions.js +4 -0
  67. package/dist/components/uvalib-image-regions/uvalib-image-regions.js.map +1 -0
  68. package/dist/components/uvalib-lightbox/UvalibLightbox.d.ts +40 -0
  69. package/dist/components/uvalib-lightbox/UvalibLightbox.js +144 -16
  70. package/dist/components/uvalib-lightbox/UvalibLightbox.js.map +1 -1
  71. package/dist/components/uvalib-map/UvalibMap.d.ts +182 -0
  72. package/dist/components/uvalib-map/UvalibMap.js +1001 -0
  73. package/dist/components/uvalib-map/UvalibMap.js.map +1 -0
  74. package/dist/components/uvalib-map/uvalib-map.d.ts +1 -0
  75. package/dist/components/uvalib-map/uvalib-map.js +4 -0
  76. package/dist/components/uvalib-map/uvalib-map.js.map +1 -0
  77. package/dist/components/uvalib-metadata/UvalibMetadata.d.ts +39 -2
  78. package/dist/components/uvalib-metadata/UvalibMetadata.js +214 -8
  79. package/dist/components/uvalib-metadata/UvalibMetadata.js.map +1 -1
  80. package/dist/components/uvalib-pager/UvalibPager.d.ts +22 -3
  81. package/dist/components/uvalib-pager/UvalibPager.js +42 -4
  82. package/dist/components/uvalib-pager/UvalibPager.js.map +1 -1
  83. package/dist/custom-elements.json +9253 -3253
  84. package/dist/index.d.ts +8 -0
  85. package/dist/index.js +5 -0
  86. package/dist/index.js.map +1 -1
  87. package/dist/pagefind.css +4 -0
  88. package/dist/styles/base.js +119 -0
  89. package/dist/styles/base.js.map +1 -1
  90. package/dist/styles/color-scheme.js +5 -0
  91. package/dist/styles/color-scheme.js.map +1 -1
  92. package/dist/styles/controls.js +6 -0
  93. package/dist/styles/controls.js.map +1 -1
  94. package/dist/styles/hidden.d.ts +2 -0
  95. package/dist/styles/hidden.js +51 -0
  96. package/dist/styles/hidden.js.map +1 -0
  97. package/dist/styles/message.d.ts +1 -0
  98. package/dist/styles/message.js +82 -0
  99. package/dist/styles/message.js.map +1 -0
  100. package/dist/styles/pagefind.js +4 -0
  101. package/dist/styles/pagefind.js.map +1 -1
  102. package/dist/styles/result-list.d.ts +1 -0
  103. package/dist/styles/result-list.js +111 -0
  104. package/dist/styles/result-list.js.map +1 -0
  105. package/dist/styles/results.js +0 -15
  106. package/dist/styles/results.js.map +1 -1
  107. package/dist/testing/index.d.ts +110 -0
  108. package/dist/testing/index.js +100 -0
  109. package/dist/testing/index.js.map +1 -0
  110. package/dist/testing/lighthouse-rules.d.ts +10 -0
  111. package/dist/testing/lighthouse-rules.js +44 -0
  112. package/dist/testing/lighthouse-rules.js.map +1 -0
  113. package/dist/tokens.css +5 -0
  114. package/dist-cdn/analytics.js +32 -0
  115. package/dist-cdn/analytics.js.map +1 -0
  116. package/dist-cdn/base.css +286 -14
  117. package/dist-cdn/bento-box.js +3 -3
  118. package/dist-cdn/chunks/{SiteAnalytics-Cm-FyhYS.js → SiteAnalytics-B9gu5aGO.js} +59 -30
  119. package/dist-cdn/chunks/SiteAnalytics-B9gu5aGO.js.map +1 -0
  120. package/dist-cdn/chunks/{UvalibElement-BnI-eRRR.js → UvalibElement-pGONDAwB.js} +108 -101
  121. package/dist-cdn/chunks/UvalibElement-pGONDAwB.js.map +1 -0
  122. package/dist-cdn/chunks/{accessible-GqhVn5_H.js → accessible-DJv7YOtS.js} +2 -2
  123. package/dist-cdn/chunks/{accessible-GqhVn5_H.js.map → accessible-DJv7YOtS.js.map} +1 -1
  124. package/dist-cdn/chunks/analytics-state-Ce8DKe4F.js.map +1 -1
  125. package/dist-cdn/chunks/{base-p5pk0vb2.js → base-BI8h0Gf3.js} +121 -2
  126. package/dist-cdn/chunks/base-BI8h0Gf3.js.map +1 -0
  127. package/dist-cdn/chunks/{library-weekly-hours-COE7Vv6V.js → library-weekly-hours-CrV3TlP5.js} +3 -3
  128. package/dist-cdn/chunks/{library-weekly-hours-COE7Vv6V.js.map → library-weekly-hours-CrV3TlP5.js.map} +1 -1
  129. package/dist-cdn/chunks/regions-B8ExwUGP.js +86 -0
  130. package/dist-cdn/chunks/regions-B8ExwUGP.js.map +1 -0
  131. package/dist-cdn/chunks/{repeat-CIFUYkyh.js → repeat-m5Zd_QeP.js} +2 -2
  132. package/dist-cdn/chunks/{repeat-CIFUYkyh.js.map → repeat-m5Zd_QeP.js.map} +1 -1
  133. package/dist-cdn/chunks/{site-header-BlOYvQg1.js → site-header-DYRMpdBj.js} +9 -4
  134. package/dist-cdn/chunks/{site-header-BlOYvQg1.js.map → site-header-DYRMpdBj.js.map} +1 -1
  135. package/dist-cdn/chunks/{site-main-nav-AaxZ9rQf.js → site-main-nav-DURrQMal.js} +3 -3
  136. package/dist-cdn/chunks/{site-main-nav-AaxZ9rQf.js.map → site-main-nav-DURrQMal.js.map} +1 -1
  137. package/dist-cdn/chunks/{static-html-1mTAG6nS.js → static-html-C1rhtCHu.js} +2 -2
  138. package/dist-cdn/chunks/{static-html-1mTAG6nS.js.map → static-html-C1rhtCHu.js.map} +1 -1
  139. package/dist-cdn/custom-elements.json +9253 -3253
  140. package/dist-cdn/events-section.js +3 -3
  141. package/dist-cdn/library-hours-setup.js +2 -2
  142. package/dist-cdn/library-weekly-hours.js +1 -1
  143. package/dist-cdn/manifest.json +10 -2
  144. package/dist-cdn/pagefind.css +4 -0
  145. package/dist-cdn/site-alerts.js +4 -4
  146. package/dist-cdn/site-analytics.js +2 -2
  147. package/dist-cdn/site-footer.js +2 -2
  148. package/dist-cdn/site-header.js +1 -1
  149. package/dist-cdn/site-hours-section.js +4 -4
  150. package/dist-cdn/site-main-nav.js +1 -1
  151. package/dist-cdn/site-page.js +56 -11
  152. package/dist-cdn/site-page.js.map +1 -1
  153. package/dist-cdn/site-style.js +2 -2
  154. package/dist-cdn/skills/uvalib-web-components/SKILL.md +98 -13
  155. package/dist-cdn/skills/uvalib-web-components/reference/accessibility-testing.md +34 -2
  156. package/dist-cdn/skills/uvalib-web-components/reference/components.md +300 -13
  157. package/dist-cdn/skills/uvalib-web-components/reference/snippets.md +1 -1
  158. package/dist-cdn/tokens.css +5 -0
  159. package/dist-cdn/uvalib-analytics.js +2 -2
  160. package/dist-cdn/uvalib-back-to-top.js +156 -0
  161. package/dist-cdn/uvalib-back-to-top.js.map +1 -0
  162. package/dist-cdn/uvalib-breadcrumbs.js +31 -11
  163. package/dist-cdn/uvalib-breadcrumbs.js.map +1 -1
  164. package/dist-cdn/uvalib-card-grid.js +1 -1
  165. package/dist-cdn/uvalib-card.js +3 -3
  166. package/dist-cdn/uvalib-chip-group.js +53 -14
  167. package/dist-cdn/uvalib-chip-group.js.map +1 -1
  168. package/dist-cdn/uvalib-combobox.js +667 -0
  169. package/dist-cdn/uvalib-combobox.js.map +1 -0
  170. package/dist-cdn/uvalib-contents.js +100 -22
  171. package/dist-cdn/uvalib-contents.js.map +1 -1
  172. package/dist-cdn/uvalib-date-histogram.js +237 -127
  173. package/dist-cdn/uvalib-date-histogram.js.map +1 -1
  174. package/dist-cdn/uvalib-date-range.js +14 -2
  175. package/dist-cdn/uvalib-date-range.js.map +1 -1
  176. package/dist-cdn/uvalib-filter-drawer.js +355 -0
  177. package/dist-cdn/uvalib-filter-drawer.js.map +1 -0
  178. package/dist-cdn/uvalib-filter.js +3 -3
  179. package/dist-cdn/uvalib-image-regions.js +447 -0
  180. package/dist-cdn/uvalib-image-regions.js.map +1 -0
  181. package/dist-cdn/uvalib-lightbox.js +144 -55
  182. package/dist-cdn/uvalib-lightbox.js.map +1 -1
  183. package/dist-cdn/uvalib-map.js +471 -0
  184. package/dist-cdn/uvalib-map.js.map +1 -0
  185. package/dist-cdn/uvalib-metadata.js +150 -24
  186. package/dist-cdn/uvalib-metadata.js.map +1 -1
  187. package/dist-cdn/uvalib-pager.js +29 -17
  188. package/dist-cdn/uvalib-pager.js.map +1 -1
  189. package/dist-cdn/uvalib-photo-grid.js +2 -2
  190. package/dist-cdn/uvalib-results-count.js +2 -2
  191. package/dist-cdn/uvalib-tabs.js +2 -2
  192. package/dist-cdn/uvalib-tag-list.js +2 -2
  193. package/package.json +43 -1
  194. package/skills/uvalib-web-components/SKILL.md +98 -13
  195. package/skills/uvalib-web-components/reference/accessibility-testing.md +34 -2
  196. package/skills/uvalib-web-components/reference/components.md +300 -13
  197. package/skills/uvalib-web-components/reference/snippets.md +1 -1
  198. package/dist-cdn/chunks/SiteAnalytics-Cm-FyhYS.js.map +0 -1
  199. package/dist-cdn/chunks/UvalibElement-BnI-eRRR.js.map +0 -1
  200. package/dist-cdn/chunks/base-p5pk0vb2.js.map +0 -1
@@ -0,0 +1,667 @@
1
+ import { a as e, d as t, f as n, i as r, l as i, m as a, n as o, o as s, p as c, r as l, t as u } from "./chunks/UvalibElement-pGONDAwB.js";
2
+ import { a as d, i as f } from "./chunks/analytics-DTTihuBD.js";
3
+ import { n as p, t as m } from "./chunks/source-children-BHsDwCvL.js";
4
+ import { t as h } from "./chunks/accessible-DJv7YOtS.js";
5
+ // src/components/uvalib-combobox/UvalibCombobox.ts
6
+ var g = {
7
+ debounce: 250,
8
+ announce: 500
9
+ }, _ = "uvalib-combobox", v = 5e3, y = 30, b = 0, x = /\p{M}/gu, S = (e) => e.normalize("NFD").replace(x, "").toLowerCase();
10
+ function C(e) {
11
+ let t = "", n = [], r = 0;
12
+ for (let i of e) {
13
+ let e = S(i);
14
+ for (let t = 0; t < e.length; t++) n.push(r);
15
+ t += e, r += i.length;
16
+ }
17
+ return n.push(r), {
18
+ text: t,
19
+ map: n
20
+ };
21
+ }
22
+ var w = /[\p{L}\p{N}]/u;
23
+ function T(e) {
24
+ if (typeof e == "string" || typeof e == "number") {
25
+ let t = p(e);
26
+ return t ? {
27
+ value: t,
28
+ label: t,
29
+ disabled: !1,
30
+ fold: S(t),
31
+ raw: {
32
+ value: t,
33
+ label: t
34
+ }
35
+ } : null;
36
+ }
37
+ if (!e || typeof e != "object") return null;
38
+ let t = e, n = p(t.label ?? t.value);
39
+ if (!n) return null;
40
+ let r = {
41
+ value: String(t.value ?? n),
42
+ label: n,
43
+ disabled: !!t.disabled,
44
+ fold: S(n),
45
+ raw: t
46
+ }, i = p(t.description);
47
+ return i && (r.description = i), r;
48
+ }
49
+ var E = (e) => Array.isArray(e) ? e.map(T).filter((e) => e !== null) : [], D = (e) => e.toLocaleString("en-US"), O = (e) => `
50
+ ${e} { display: block; max-width: 100%; line-height: 1.5; }
51
+ ${e} .label { display: block; margin-block-end: 0.25rem; }
52
+ ${e} .field { position: relative; }
53
+ ${e} .input {
54
+ display: block;
55
+ box-sizing: border-box;
56
+ inline-size: 100%;
57
+ min-block-size: 44px;
58
+ margin: 0;
59
+ padding-inline-end: 44px;
60
+ font: inherit;
61
+ line-height: 1.2;
62
+ }
63
+ ${e} .clear {
64
+ position: absolute;
65
+ inset-block-start: 0;
66
+ inset-inline-end: 0;
67
+ display: inline-flex;
68
+ align-items: center;
69
+ justify-content: center;
70
+ box-sizing: border-box;
71
+ inline-size: 44px;
72
+ block-size: 44px;
73
+ margin: 0;
74
+ padding: 0;
75
+ cursor: pointer;
76
+ }
77
+ ${e} .popup {
78
+ position: absolute;
79
+ inset-inline: 0;
80
+ inset-block-start: calc(100% + 2px);
81
+ z-index: 20;
82
+ box-sizing: border-box;
83
+ max-block-size: min(18rem, 60vh);
84
+ margin: 0;
85
+ overflow-y: auto;
86
+ overscroll-behavior: contain;
87
+ }
88
+ ${e} .listbox { margin: 0; padding: 0; list-style: none; }
89
+ ${e} .option {
90
+ display: flex;
91
+ flex-direction: column;
92
+ justify-content: center;
93
+ box-sizing: border-box;
94
+ min-block-size: 44px;
95
+ overflow-wrap: anywhere;
96
+ cursor: pointer;
97
+ }
98
+ ${e} .option[aria-disabled='true'] { cursor: not-allowed; }
99
+ ${e} .message { box-sizing: border-box; min-block-size: 44px; margin: 0; }
100
+ ${e} .description { margin: 0.25rem 0 0; }
101
+ ${e} .visually-hidden {
102
+ position: absolute;
103
+ width: 1px;
104
+ height: 1px;
105
+ margin: -1px;
106
+ padding: 0;
107
+ overflow: hidden;
108
+ clip: rect(0, 0, 0, 0);
109
+ white-space: nowrap;
110
+ border: 0;
111
+ }
112
+ ${e}[hidden], ${e} [hidden] { display: none !important; }
113
+ `, k = c(O(":host")), A = c("var(--uva-color-control-border, var(--uva-grey, #808080))"), j = c("var(--uva-color-accent-bg, var(--uva-brand-blue, #232d4b))"), M = c("var(--uva-color-text-muted, var(--uva-grey-A, #4f4f4f))"), N = c("var(--uva-color-input-text, var(--uva-grey-darkest, #2b2b2b))"), P = c("var(--uva-color-surface-raised, #ffffff)"), F = t`<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true" focusable="false"><path d="M4 4l8 8M12 4l-8 8" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>`, I = class extends u {
114
+ static {
115
+ this.formAssociated = !0;
116
+ }
117
+ static {
118
+ this.shadowRootOptions = {
119
+ ...u.shadowRootOptions,
120
+ delegatesFocus: !0
121
+ };
122
+ }
123
+ static {
124
+ this.styles = [
125
+ h,
126
+ k,
127
+ n`
128
+ .label {
129
+ font-weight: 600;
130
+ }
131
+ .input {
132
+ padding-block: 0.5rem;
133
+ padding-inline-start: 0.75rem;
134
+ border: 1px solid ${A};
135
+ border-radius: 5px;
136
+ background: ${P};
137
+ color: ${N};
138
+ }
139
+ .input::placeholder {
140
+ color: ${M};
141
+ opacity: 1;
142
+ }
143
+ .input:disabled {
144
+ background: var(--uva-color-track, var(--uva-grey-200, #f1f1f1));
145
+ color: ${M};
146
+ cursor: not-allowed;
147
+ }
148
+ .input[aria-invalid='true'] {
149
+ border-width: 2px;
150
+ }
151
+ .clear {
152
+ border: 0;
153
+ border-radius: 5px;
154
+ background: none;
155
+ color: ${M};
156
+ }
157
+ .clear:hover {
158
+ color: ${N};
159
+ }
160
+ .clear:focus-visible {
161
+ outline-offset: -4px;
162
+ }
163
+ .popup {
164
+ padding-block: 0.25rem;
165
+ border: 1px solid ${A};
166
+ border-radius: 5px;
167
+ background: ${P};
168
+ color: ${N};
169
+ box-shadow: 0 4px 12px var(--uva-color-shadow, rgba(0, 0, 0, 0.2));
170
+ }
171
+ .option {
172
+ padding: 0.375rem 0.75rem;
173
+ border-inline-start: 4px solid transparent;
174
+ }
175
+ .option:hover {
176
+ background: var(--uva-color-track, var(--uva-grey-200, #f1f1f1));
177
+ }
178
+ /* The active suggestion: a fill, a bar at the start and an outline, never colour alone. */
179
+ .option[aria-selected='true'] {
180
+ border-inline-start-color: ${j};
181
+ background: var(--uva-color-surface-hover, var(--uva-grey-100, #dadada));
182
+ outline: 2px solid ${j};
183
+ outline-offset: -2px;
184
+ }
185
+ .option[aria-disabled='true'] {
186
+ color: ${M};
187
+ font-style: italic;
188
+ }
189
+ .option-description {
190
+ color: ${M};
191
+ font-size: 0.875em;
192
+ }
193
+ mark {
194
+ background: none;
195
+ color: inherit;
196
+ font-weight: 700;
197
+ text-decoration: underline;
198
+ text-underline-offset: 0.15em;
199
+ }
200
+ .message {
201
+ padding: 0.625rem 0.75rem;
202
+ color: ${M};
203
+ }
204
+ .description {
205
+ color: ${M};
206
+ }
207
+ @media (forced-colors: active) {
208
+ .input,
209
+ .popup {
210
+ border-color: CanvasText;
211
+ }
212
+ .clear {
213
+ color: ButtonText;
214
+ }
215
+ .option[aria-selected='true'] {
216
+ forced-color-adjust: none;
217
+ border-inline-start-color: HighlightText;
218
+ background: Highlight;
219
+ color: HighlightText;
220
+ outline-color: HighlightText;
221
+ }
222
+ .option[aria-selected='true'] .option-description {
223
+ color: HighlightText;
224
+ }
225
+ .option[aria-disabled='true'] {
226
+ color: GrayText;
227
+ }
228
+ }
229
+ `
230
+ ];
231
+ }
232
+ constructor() {
233
+ super(), this.label = "", this.description = "", this.placeholder = "", this.name = "", this.value = "", this.selected = null, this.src = "", this.minLength = 1, this.maxResults = 50, this.mustChoose = !1, this.required = !1, this.disabled = !1, this.open = !1, this.active = -1, this.shown = [], this.total = 0, this.loading = "idle", this.announcement = "", this.formDisabled = !1, this.invalidShown = !1, this.childEntries = [], this.uid = `${_}-${++b}`, this.warned = /* @__PURE__ */ new Set(), this.committed = {
234
+ value: "",
235
+ item: null
236
+ }, this.remote = [], this.cache = /* @__PURE__ */ new Map(), this.lastAnnounced = "", this.adopted = /* @__PURE__ */ new WeakSet(), this.started = !1, this.internals = this.attachInternals(), new m(this, () => this.lightDom, (e) => this.read(e));
237
+ }
238
+ createRenderRoot() {
239
+ let e = super.createRenderRoot();
240
+ if (e instanceof ShadowRoot && this.noStyle) {
241
+ let t = k.styleSheet;
242
+ t && (e.adoptedStyleSheets = [t]);
243
+ }
244
+ return e;
245
+ }
246
+ connectedCallback() {
247
+ if (super.connectedCallback(), this.lightDom && this.noStyle) {
248
+ let e = this.getRootNode();
249
+ l(`${this.localName}::structure`, c(O(this.localName)), {
250
+ root: e instanceof ShadowRoot || e instanceof Document ? e : void 0,
251
+ scope: !1
252
+ });
253
+ }
254
+ }
255
+ disconnectedCallback() {
256
+ super.disconnectedCallback(), this.cancelFetch(), clearTimeout(this.announceTimer), clearTimeout(this.clearTimer), this.open = !1;
257
+ }
258
+ get form() {
259
+ return this.internals.form;
260
+ }
261
+ get validity() {
262
+ return this.internals.validity;
263
+ }
264
+ get validationMessage() {
265
+ return this.internals.validationMessage;
266
+ }
267
+ get willValidate() {
268
+ return this.internals.willValidate;
269
+ }
270
+ checkValidity() {
271
+ return this.internals.checkValidity();
272
+ }
273
+ reportValidity() {
274
+ return this.internals.reportValidity();
275
+ }
276
+ formResetCallback() {
277
+ this.cancelFetch(), this.open = !1, this.active = -1, this.invalidShown = !1, this.setOwn(this.getAttribute("value") ?? "", null), this.committed = {
278
+ value: this.value,
279
+ item: null
280
+ };
281
+ }
282
+ formDisabledCallback(e) {
283
+ this.formDisabled = e;
284
+ }
285
+ formStateRestoreCallback(e) {
286
+ typeof e == "string" && (this.setOwn(e, null), this.committed = {
287
+ value: e,
288
+ item: null
289
+ });
290
+ }
291
+ get input() {
292
+ return this.renderRoot.querySelector(`#${this.uid}-input`);
293
+ }
294
+ focus(e) {
295
+ let t = this.input;
296
+ t ? t.focus(e) : super.focus(e);
297
+ }
298
+ updateForm() {
299
+ let e = this.selected ? String(this.selected.value) : this.value;
300
+ this.internals.setFormValue(e, this.value);
301
+ let t = this.input ?? void 0;
302
+ this.required && !this.value.trim() ? this.internals.setValidity({ valueMissing: !0 }, "Fill in this field.", t) : this.mustChoose && this.value.trim() && !this.selected ? this.internals.setValidity({ customError: !0 }, "Choose one of the suggestions.", t) : this.internals.setValidity({});
303
+ }
304
+ warnOnce(e, t) {
305
+ this.warned.has(e) || (this.warned.add(e), console.warn(`${this.localName}: ${t}`));
306
+ }
307
+ read(e) {
308
+ let t = [];
309
+ for (let n of e) n instanceof HTMLOptionElement ? t.push(n) : n instanceof HTMLDataListElement ? t.push(...n.options) : n instanceof HTMLInputElement && (this.adopt(n), n.list && !e.includes(n.list) && t.push(...n.list.options));
310
+ let n = E(t.map((e) => {
311
+ let t = p(e.getAttribute("label") ?? e.textContent) || e.value, n = {
312
+ value: e.value || t,
313
+ label: t
314
+ }, r = e.getAttribute("data-description");
315
+ return r && (n.description = r), e.disabled && (n.disabled = !0), n;
316
+ })), r = (e) => e.map((e) => `${e.value}\u0001${e.label}\u0001${e.description ?? ""}\u0001${+e.disabled}`).join("\0");
317
+ r(n) !== r(this.childEntries) && (this.childEntries = n);
318
+ }
319
+ adopt(e) {
320
+ this.adopted.has(e) || (this.adopted.add(e), !this.name && e.name && (this.name = e.name), !this.placeholder && e.placeholder && (this.placeholder = e.placeholder), !this.value && e.value && this.setOwn(e.value, null), e.disabled = !0);
321
+ }
322
+ get local() {
323
+ return this.items ? (this.items !== this.itemsSource && (this.itemsSource = this.items, this.itemEntries = E(this.items)), this.itemEntries) : this.childEntries;
324
+ }
325
+ get query() {
326
+ let e = p(this.value);
327
+ return {
328
+ text: e,
329
+ folded: S(e)
330
+ };
331
+ }
332
+ get max() {
333
+ let e = Math.trunc(Number(this.maxResults));
334
+ return Number.isFinite(e) && e > 0 ? e : Infinity;
335
+ }
336
+ filter(e) {
337
+ let t = this.local, n = this.max;
338
+ if (!e) {
339
+ this.shown = t.slice(0, n), this.total = t.length;
340
+ return;
341
+ }
342
+ let r = [
343
+ [],
344
+ [],
345
+ []
346
+ ], i = 0;
347
+ for (let a of t) {
348
+ let t = a.fold.indexOf(e);
349
+ if (t < 0) continue;
350
+ i++;
351
+ let o = t === 0 ? 0 : w.test(a.fold[t - 1]) ? 2 : 1;
352
+ r[o].length < n && r[o].push(a);
353
+ }
354
+ this.shown = r.flat().slice(0, n), this.total = i;
355
+ }
356
+ cancelFetch() {
357
+ clearTimeout(this.fetchTimer), this.fetchTimer = void 0, this.abort?.abort(), this.abort = void 0;
358
+ }
359
+ showRemote(e, t) {
360
+ this.remote = t, this.remoteQuery = e, this.loading = "idle", this.shown = t.slice(0, this.max), this.total = t.length;
361
+ }
362
+ request(e) {
363
+ this.cancelFetch();
364
+ let t = this.cache.get(e);
365
+ t ? this.showRemote(e, t) : (this.loading = "loading", this.fetchTimer = setTimeout(() => void this.load(e), g.debounce));
366
+ }
367
+ async load(e) {
368
+ let t = new AbortController();
369
+ this.abort = t;
370
+ let n = this.src.replaceAll("{q}", encodeURIComponent(e));
371
+ try {
372
+ let r = await fetch(new URL(n, this.ownerDocument.baseURI), {
373
+ signal: t.signal,
374
+ headers: { Accept: "application/json" }
375
+ });
376
+ if (!r.ok) throw Error(`HTTP ${r.status}`);
377
+ let i = await r.json(), a = this.transform ? this.transform(i, e) : i;
378
+ if (!Array.isArray(a)) throw Error("the response is not an array");
379
+ if (t.signal.aborted) return;
380
+ let o = E(a);
381
+ if (this.cache.set(e, o), this.cache.size > y && this.cache.delete(this.cache.keys().next().value), this.query.text !== e) return;
382
+ this.showRemote(e, o), this.active = -1;
383
+ } catch (e) {
384
+ if (t.signal.aborted) return;
385
+ this.loading = "error", this.shown = [], this.total = 0, this.remoteQuery = void 0, this.warnOnce("load", `couldn't load suggestions (${e.message}).`), f(this, _, "load");
386
+ } finally {
387
+ this.abort === t && (this.abort = void 0);
388
+ }
389
+ }
390
+ refresh() {
391
+ let e = this.query;
392
+ if (this.src) {
393
+ if (e.text.length < this.minLength) {
394
+ this.cancelFetch(), this.loading = "idle", this.shown = [], this.total = 0;
395
+ return;
396
+ }
397
+ if (e.text === this.remoteQuery && this.loading !== "error") {
398
+ this.shown = this.remote.slice(0, this.max), this.total = this.remote.length;
399
+ return;
400
+ }
401
+ this.request(e.text);
402
+ } else this.filter(e.folded);
403
+ }
404
+ setOwn(e, t) {
405
+ this.value = this.ownValue = e, this.selected = this.ownSelected = t;
406
+ }
407
+ emit(e, t) {
408
+ this.dispatchEvent(new CustomEvent(e, {
409
+ detail: t,
410
+ bubbles: !0,
411
+ composed: !0
412
+ }));
413
+ }
414
+ exact() {
415
+ let e = this.query.folded;
416
+ if (!e) return;
417
+ let t = (this.src ? this.remote : this.local).filter((t) => !t.disabled && t.fold === e);
418
+ return t.length === 1 ? t[0] : void 0;
419
+ }
420
+ commit() {
421
+ if (!this.selected) {
422
+ let e = this.exact();
423
+ e && this.setOwn(e.label, e.raw);
424
+ }
425
+ let { value: e, selected: t } = this;
426
+ this.invalidShown = this.mustChoose && !!e.trim() && !t, (e !== this.committed.value || t !== this.committed.item) && (this.committed = {
427
+ value: e,
428
+ item: t
429
+ }, this.emit("change", {
430
+ value: e,
431
+ item: t
432
+ }));
433
+ }
434
+ close() {
435
+ this.open = !1, this.active = -1;
436
+ }
437
+ openList(e) {
438
+ this.src && this.query.text.length < this.minLength || (this.refresh(), this.open = !0, this.active = e === "none" ? -1 : this.step(e === "first" ? -1 : this.shown.length, e === "first" ? 1 : -1));
439
+ }
440
+ step(e, t) {
441
+ let n = this.shown.length;
442
+ for (let r = 1; r <= n; r++) {
443
+ let i = ((e + t * r) % n + n) % n;
444
+ if (!this.shown[i].disabled) return i;
445
+ }
446
+ return -1;
447
+ }
448
+ choose(e) {
449
+ let t = this.shown[e];
450
+ t && !t.disabled && (this.cancelFetch(), this.setOwn(t.label, t.raw), this.close(), this.invalidShown = !1, this.emit("select", { item: t.raw }), d(this, [
451
+ _,
452
+ "select",
453
+ this.label.trim(),
454
+ e + 1
455
+ ]), this.commit());
456
+ }
457
+ clear() {
458
+ this.cancelFetch(), this.loading = "idle", this.setOwn("", null), this.close(), d(this, [
459
+ _,
460
+ "clear",
461
+ this.label.trim()
462
+ ]), this.commit(), this.focus();
463
+ }
464
+ onInput(e) {
465
+ let t = e.target.value, n = this.selected && t === p(this.selected.label ?? this.selected.value);
466
+ this.setOwn(t, n ? this.selected : null), this.invalidShown = !1, this.active = -1, this.query.text.length < this.minLength ? (this.cancelFetch(), this.loading = "idle", this.close()) : (this.refresh(), this.open = !0);
467
+ }
468
+ onKeydown(e) {
469
+ if (!e.isComposing) switch (e.key) {
470
+ case "ArrowDown":
471
+ e.preventDefault(), e.altKey ? this.open || this.openList("none") : this.open ? this.active = this.step(this.active, 1) : this.openList("first");
472
+ return;
473
+ case "ArrowUp":
474
+ e.preventDefault(), e.altKey ? this.close() : this.open ? this.active = this.step(this.active < 0 ? this.shown.length : this.active, -1) : this.openList("last");
475
+ return;
476
+ case "Enter":
477
+ if (this.open && this.active >= 0) {
478
+ e.preventDefault(), this.choose(this.active);
479
+ return;
480
+ }
481
+ this.close(), this.commit(), this.updateForm(), !this.lightDom && this.form && (e.preventDefault(), this.submit(this.form));
482
+ return;
483
+ case "Escape":
484
+ this.open ? (e.preventDefault(), e.stopPropagation(), this.cancelFetch(), this.loading === "loading" && (this.loading = "idle"), this.close()) : this.value && (e.preventDefault(), e.stopPropagation(), this.clear());
485
+ return;
486
+ case "Home":
487
+ case "End":
488
+ case "ArrowLeft":
489
+ case "ArrowRight":
490
+ this.active = -1;
491
+ return;
492
+ }
493
+ }
494
+ submit(e) {
495
+ let t = [...e.elements].find((e) => (e instanceof HTMLButtonElement || e instanceof HTMLInputElement) && (e.type === "submit" || e.type === "image"));
496
+ t ? t.disabled || t.click() : e.requestSubmit();
497
+ }
498
+ onBlur() {
499
+ this.cancelFetch(), this.loading === "loading" && (this.loading = "idle"), this.close(), this.commit();
500
+ }
501
+ onOptionClick(e) {
502
+ let t = e.target.closest("[role=\"option\"]");
503
+ t && this.choose(Number(t.dataset.index));
504
+ }
505
+ get note() {
506
+ if (this.loading === "loading" && !this.shown.length) return {
507
+ visible: "Loading suggestions…",
508
+ spoken: "Loading suggestions"
509
+ };
510
+ if (this.loading === "error") return {
511
+ visible: "Couldn't load suggestions",
512
+ spoken: "Couldn't load suggestions"
513
+ };
514
+ let e = this.shown.length;
515
+ return e ? this.total > e ? {
516
+ visible: `Showing ${D(e)} of ${D(this.total)}. Type more to narrow them.`,
517
+ spoken: `${D(e)} of ${D(this.total)} suggestions`
518
+ } : {
519
+ visible: "",
520
+ spoken: `${D(e)} suggestion${e === 1 ? "" : "s"}`
521
+ } : {
522
+ visible: "No suggestions",
523
+ spoken: "No suggestions"
524
+ };
525
+ }
526
+ scheduleAnnouncement() {
527
+ clearTimeout(this.announceTimer);
528
+ let e = this.open ? this.note.spoken : "";
529
+ e ? e !== this.lastAnnounced && (this.announceTimer = setTimeout(() => {
530
+ let e = this.open ? this.note.spoken : "";
531
+ e && e !== this.lastAnnounced && (this.lastAnnounced = e, this.announcement = e, clearTimeout(this.clearTimer), this.clearTimer = setTimeout(() => this.announcement = "", v));
532
+ }, g.announce)) : this.lastAnnounced = "";
533
+ }
534
+ willUpdate(e) {
535
+ if (this.label.trim() || this.warnOnce("label", "set label: the field needs a visible label."), e.has("selected") && this.selected !== this.ownSelected) {
536
+ let e = this.selected, t = e == null ? null : T(e);
537
+ this.selected = this.ownSelected = t ? t.raw : null, t && (this.value = this.ownValue = t.label), this.committed = {
538
+ value: this.value,
539
+ item: this.selected
540
+ };
541
+ } else e.has("value") && this.value !== this.ownValue && (this.value = this.ownValue = String(this.value ?? ""), this.selected && this.value !== p(this.selected.label ?? this.selected.value) && (this.selected = this.ownSelected = null), this.committed = {
542
+ value: this.value,
543
+ item: this.selected
544
+ });
545
+ (e.has("src") || e.has("transform")) && (this.cache.clear(), this.remoteQuery = void 0), this.open && (e.has("items") || e.has("childEntries") || e.has("maxResults")) && this.refresh(), this.open && this.active >= this.shown.length && (this.active = -1);
546
+ }
547
+ updated(e) {
548
+ super.updated(e);
549
+ let t = this.input;
550
+ t && t.value !== this.value && (t.value = this.value), this.started ? ((e.has("value") || e.has("selected") || e.has("required") || e.has("mustChoose")) && this.updateForm(), (e.has("open") || e.has("shown") || e.has("total") || e.has("loading")) && this.scheduleAnnouncement(), e.has("active") && this.active >= 0 && this.reveal()) : (this.started = !0, this.updateForm());
551
+ }
552
+ reveal() {
553
+ let e = this.renderRoot.querySelector(".popup"), t = this.renderRoot.querySelector(`#${this.uid}-opt-${this.active}`);
554
+ if (!e || !t) return;
555
+ let n = t.offsetTop, r = n + t.offsetHeight;
556
+ n < e.scrollTop ? e.scrollTop = n : r > e.scrollTop + e.clientHeight && (e.scrollTop = r - e.clientHeight);
557
+ }
558
+ marked(e, t) {
559
+ if (!t) return e;
560
+ let { text: n, map: r } = C(e), a = [], o = 0, s = 0;
561
+ for (let c = n.indexOf(t); c !== -1; c = n.indexOf(t, s)) {
562
+ let n = r[c], l = r[c + t.length];
563
+ n > o && a.push(e.slice(o, n)), a.push(i`<mark>${e.slice(n, l)}</mark>`), o = l, s = c + t.length;
564
+ }
565
+ return a.push(e.slice(o)), a;
566
+ }
567
+ render() {
568
+ let e = this.uid, t = this.label.trim(), n = this.disabled || this.formDisabled, r = this.open && this.shown.length > 0, a = this.open ? this.note.visible : "", o = this.query.folded;
569
+ return i`<label class="label" part="label" id="${e}-label" for="${e}-input"
570
+ >${t}</label
571
+ >
572
+ <div class="field">
573
+ <input
574
+ id="${e}-input"
575
+ class="input"
576
+ part="input"
577
+ type="text"
578
+ role="combobox"
579
+ aria-autocomplete="list"
580
+ aria-expanded=${r ? "true" : "false"}
581
+ aria-controls="${e}-listbox"
582
+ aria-activedescendant=${r && this.active >= 0 ? `${e}-opt-${this.active}` : s}
583
+ aria-describedby=${this.description ? `${e}-description` : s}
584
+ aria-required=${this.required ? "true" : s}
585
+ aria-invalid=${this.invalidShown ? "true" : s}
586
+ autocomplete="off"
587
+ autocapitalize="off"
588
+ spellcheck="false"
589
+ placeholder=${this.placeholder || s}
590
+ .value=${this.value}
591
+ ?disabled=${n}
592
+ @input=${this.onInput}
593
+ @keydown=${this.onKeydown}
594
+ @blur=${this.onBlur}
595
+ @change=${(e) => e.stopPropagation()}
596
+ @select=${(e) => e.stopPropagation()}
597
+ /><button
598
+ type="button"
599
+ class="clear"
600
+ part="clear"
601
+ aria-label="Clear ${t}"
602
+ ?hidden=${!this.value || n}
603
+ @mousedown=${(e) => e.preventDefault()}
604
+ @click=${this.clear}
605
+ >
606
+ ${F}
607
+ </button>
608
+ <div
609
+ class="popup"
610
+ part="popup"
611
+ ?hidden=${!this.open || !this.shown.length && !a}
612
+ @mousedown=${(e) => e.preventDefault()}
613
+ >
614
+ <ul
615
+ id="${e}-listbox"
616
+ class="listbox"
617
+ role="listbox"
618
+ aria-labelledby="${e}-label"
619
+ tabindex="-1"
620
+ ?hidden=${!r}
621
+ @click=${this.onOptionClick}
622
+ >
623
+ ${r ? this.shown.map((t, n) => i`<li
624
+ id="${e}-opt-${n}"
625
+ class="option"
626
+ part="option"
627
+ role="option"
628
+ data-index=${n}
629
+ aria-selected=${n === this.active ? "true" : "false"}
630
+ aria-disabled=${t.disabled ? "true" : s}
631
+ >
632
+ <span class="option-label">${this.marked(t.label, o)}</span>${t.description ? i`<span class="option-description">${t.description}</span>` : s}
633
+ </li>`) : s}
634
+ </ul>
635
+ <p class="message" ?hidden=${!a}>${a}</p>
636
+ </div>
637
+ </div>
638
+ <p class="description" part="description" id="${e}-description" ?hidden=${!this.description}>
639
+ ${this.description}
640
+ </p>
641
+ <span class="visually-hidden" role="status" aria-live="polite" aria-atomic="true"
642
+ >${this.announcement}</span
643
+ >`;
644
+ }
645
+ };
646
+ // src/components/uvalib-combobox/uvalib-combobox.ts
647
+ o([e({ type: String })], I.prototype, "label", void 0), o([e({ type: String })], I.prototype, "description", void 0), o([e({ type: String })], I.prototype, "placeholder", void 0), o([e({
648
+ type: String,
649
+ reflect: !0
650
+ })], I.prototype, "name", void 0), o([e({ type: String })], I.prototype, "value", void 0), o([e({ attribute: !1 })], I.prototype, "selected", void 0), o([e({ attribute: !1 })], I.prototype, "items", void 0), o([e({ type: String })], I.prototype, "src", void 0), o([e({ attribute: !1 })], I.prototype, "transform", void 0), o([e({
651
+ type: Number,
652
+ attribute: "min-length"
653
+ })], I.prototype, "minLength", void 0), o([e({
654
+ type: Number,
655
+ attribute: "max-results"
656
+ })], I.prototype, "maxResults", void 0), o([e({
657
+ type: Boolean,
658
+ attribute: "must-choose"
659
+ })], I.prototype, "mustChoose", void 0), o([e({
660
+ type: Boolean,
661
+ reflect: !0
662
+ })], I.prototype, "required", void 0), o([e({
663
+ type: Boolean,
664
+ reflect: !0
665
+ })], I.prototype, "disabled", void 0), o([r()], I.prototype, "open", void 0), o([r()], I.prototype, "active", void 0), o([r()], I.prototype, "shown", void 0), o([r()], I.prototype, "total", void 0), o([r()], I.prototype, "loading", void 0), o([r()], I.prototype, "announcement", void 0), o([r()], I.prototype, "formDisabled", void 0), o([r()], I.prototype, "invalidShown", void 0), o([r()], I.prototype, "childEntries", void 0), a("uvalib-combobox", I);
666
+
667
+ //# sourceMappingURL=uvalib-combobox.js.map