@astryx-vue/core 0.16.5 → 0.17.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 (154) hide show
  1. package/dist/AvatarGroup/index.d.ts +1 -1
  2. package/dist/Banner/index.d.ts +1 -1
  3. package/dist/Button/index.d.ts +1 -1
  4. package/dist/ButtonGroup/index.d.ts +1 -1
  5. package/dist/Calendar/index.d.ts +1 -1
  6. package/dist/Card/index.d.ts +1 -1
  7. package/dist/Carousel/index.d.ts +1 -1
  8. package/dist/Chat/index.d.ts +1 -1
  9. package/dist/Chat/index.js +1 -1
  10. package/dist/CheckboxInput/index.d.ts +1 -1
  11. package/dist/CheckboxList/index.d.ts +1 -1
  12. package/dist/ClickableCard/index.d.ts +1 -1
  13. package/dist/Code/index.js +1 -1
  14. package/dist/Collapsible/index.d.ts +1 -1
  15. package/dist/CommandPalette/index.d.ts +1 -1
  16. package/dist/CommandPalette/index.js +1 -1
  17. package/dist/{CommandPalette-mNR6dV0B.js → CommandPalette-CECjNvGB.js} +1 -1
  18. package/dist/ComplexSelector/index.d.ts +1 -1
  19. package/dist/ComplexSelector/index.js +1 -1
  20. package/dist/{ComplexSelector-CR9XbpTa.js → ComplexSelector-Dmaag1wm.js} +5 -1
  21. package/dist/ContextMenu/index.d.ts +1 -1
  22. package/dist/DateInput/index.d.ts +1 -1
  23. package/dist/DateInput/index.js +1 -1
  24. package/dist/DateRangeInput/index.d.ts +1 -1
  25. package/dist/DateRangeInput/index.js +1 -1
  26. package/dist/DateTimeInput/index.d.ts +1 -1
  27. package/dist/DateTimeInput/index.js +1 -1
  28. package/dist/{DateTimeInput-ChGin5zS.js → DateTimeInput-Cfkuec_h.js} +1 -1
  29. package/dist/Dialog/index.d.ts +1 -1
  30. package/dist/Drawer/index.d.ts +1 -1
  31. package/dist/Field/index.d.ts +1 -1
  32. package/dist/FileInput/index.d.ts +1 -1
  33. package/dist/Heading/index.d.ts +1 -1
  34. package/dist/HoverCard/index.d.ts +1 -1
  35. package/dist/Indicator/index.d.ts +2 -2
  36. package/dist/InfoTip/index.d.ts +1 -1
  37. package/dist/InputGroup/index.d.ts +1 -1
  38. package/dist/InternationalizationProvider/index.d.ts +1 -1
  39. package/dist/InternationalizationProvider/index.js +1 -1
  40. package/dist/{InternationalizationProvider-7rA65NO7.js → InternationalizationProvider-Dr5GE6f0.js} +1 -1
  41. package/dist/Link/index.d.ts +1 -1
  42. package/dist/List/index.d.ts +1 -1
  43. package/dist/Markdown/index.js +1 -1
  44. package/dist/{Markdown-BNVd70jg.js → Markdown-DnnWjJGX.js} +1 -1
  45. package/dist/MoreMenu/index.d.ts +1 -1
  46. package/dist/MultiSelector/index.d.ts +1 -1
  47. package/dist/MultiSelector/index.js +1 -1
  48. package/dist/{MultiSelector-CXX1Hsty.js → MultiSelector-BK6nZweN.js} +26 -14
  49. package/dist/NavItem/index.d.ts +1 -1
  50. package/dist/NumberInput/index.d.ts +1 -1
  51. package/dist/OverflowList/index.d.ts +1 -1
  52. package/dist/Pagination/index.d.ts +1 -1
  53. package/dist/Pagination/index.js +1 -1
  54. package/dist/{Pagination-BvZFvwso.js → Pagination-DFQNX_Mb.js} +1 -1
  55. package/dist/Popover/index.d.ts +1 -1
  56. package/dist/PowerSearch/index.d.ts +1 -1
  57. package/dist/PowerSearch/index.js +1 -1
  58. package/dist/{PowerSearch-BiupstfT.js → PowerSearch-BAOqpQag.js} +10 -10
  59. package/dist/ProgressBar/index.d.ts +1 -1
  60. package/dist/Radio/index.d.ts +1 -1
  61. package/dist/RadioList/index.d.ts +1 -1
  62. package/dist/Resizable/index.d.ts +1 -1
  63. package/dist/ScrollableArea/index.d.ts +1 -1
  64. package/dist/SegmentedControl/index.d.ts +1 -1
  65. package/dist/SelectableCard/index.d.ts +1 -1
  66. package/dist/Selector/index.d.ts +1 -1
  67. package/dist/Selector/index.js +1 -1
  68. package/dist/{Selector-DiSLNzl8.js → Selector-Bo7qkt1P.js} +157 -62
  69. package/dist/SideNav/index.d.ts +1 -1
  70. package/dist/Stepper/index.d.ts +1 -1
  71. package/dist/Switch/index.d.ts +1 -1
  72. package/dist/TabList/index.d.ts +1 -1
  73. package/dist/Table/index.d.ts +1 -1
  74. package/dist/Table/index.js +1 -1
  75. package/dist/{Table-BD8MugZo.js → Table-CRKljXg4.js} +6 -6
  76. package/dist/Text/index.d.ts +1 -1
  77. package/dist/TextArea/index.d.ts +1 -1
  78. package/dist/TextInput/index.d.ts +1 -1
  79. package/dist/Theme/index.d.ts +3 -3
  80. package/dist/Theme/index.js +1 -1
  81. package/dist/{Theme-8bDq2nud.js → Theme-iqi6AvU_.js} +363 -39
  82. package/dist/TimeInput/index.d.ts +1 -1
  83. package/dist/Timestamp/index.d.ts +1 -1
  84. package/dist/ToggleButton/index.d.ts +1 -1
  85. package/dist/Token/index.d.ts +1 -1
  86. package/dist/Tokenizer/index.d.ts +1 -1
  87. package/dist/Tokenizer/index.js +1 -1
  88. package/dist/{Tokenizer-mu0Sak58.js → Tokenizer-CsFiYUJ_.js} +171 -103
  89. package/dist/Toolbar/index.d.ts +1 -1
  90. package/dist/Tooltip/index.d.ts +1 -1
  91. package/dist/TopNav/index.d.ts +1 -1
  92. package/dist/Typeahead/index.d.ts +2 -1
  93. package/dist/Typeahead/index.js +2 -2
  94. package/dist/{Typeahead-Db8Tu27Z.js → Typeahead--kEp21ut.js} +159 -71
  95. package/dist/{useKeyboardHighlight-CGCf1O57.js → assertOptions-CK_gJ0d3.js} +12 -1
  96. package/dist/composables/index.d.ts +3 -3
  97. package/dist/composables/index.js +5 -5
  98. package/dist/composables-BKHcPgN0.js +5730 -0
  99. package/dist/{index-CE74Qsbn.d.ts → index-85RFPeV0.d.ts} +10 -10
  100. package/dist/{index-BFZxzCYu.d.ts → index-9tZJgo0R.d.ts} +2 -2
  101. package/dist/{index-B-Jla56c.d.ts → index-B0iRA00v.d.ts} +3 -3
  102. package/dist/{index-LHvLg1Pv.d.ts → index-B95VIgRl.d.ts} +84 -84
  103. package/dist/{index-DMN_JVEt.d.ts → index-BL4mH8aK.d.ts} +1 -1
  104. package/dist/{index-Bfm6mF-r.d.ts → index-BfoazhEu.d.ts} +1 -1
  105. package/dist/{index-CQ1bsxLC.d.ts → index-C1qJlC65.d.ts} +1 -1
  106. package/dist/{index-ygmRS6Np.d.ts → index-C1zwvxPH.d.ts} +2 -2
  107. package/dist/{index-gmY3A_Iw.d.ts → index-C93nwgTW.d.ts} +1 -1
  108. package/dist/{index-BvWBeoa8.d.ts → index-CEjvYAUZ.d.ts} +1 -1
  109. package/dist/{index-B0yaHi__.d.ts → index-CH-xSiJz.d.ts} +12 -5
  110. package/dist/{index-sXu15K4j.d.ts → index-CO9GW-ik.d.ts} +1 -1
  111. package/dist/{index-Xc3q9f84.d.ts → index-COgrQZIL.d.ts} +3 -3
  112. package/dist/{index-Bgk1Rj2A.d.ts → index-CTjkJP4x.d.ts} +1 -1
  113. package/dist/{index-BQ3cm7mP.d.ts → index-CbA8rR_b.d.ts} +1 -1
  114. package/dist/{index-B0R5CLPF.d.ts → index-CsYDrQ9R.d.ts} +1 -1
  115. package/dist/{index-BWzEt0gT.d.ts → index-CuW4AQ7M.d.ts} +2 -2
  116. package/dist/{index-BPf_jmME.d.ts → index-Cy1rEWC-.d.ts} +2 -2
  117. package/dist/{index-D_xBhUV5.d.ts → index-CyMStZq4.d.ts} +10 -10
  118. package/dist/{index-C2cH8OLC.d.ts → index-D31bgBoy.d.ts} +1 -1
  119. package/dist/index-DGXCnzOL.d.ts +69 -0
  120. package/dist/{index-DBwEz4M9.d.ts → index-DK0Wdo9N.d.ts} +13 -13
  121. package/dist/{index-SWw-WMTO.d.ts → index-DYabo8TI.d.ts} +2 -2
  122. package/dist/{index-CJdOt5Cc.d.ts → index-DofC9Rll.d.ts} +2 -2
  123. package/dist/{index-Byan7Dad.d.ts → index-GmoeIuhl.d.ts} +1 -1
  124. package/dist/{index-unAZVFGz.d.ts → index-Qdbssopn.d.ts} +2 -2
  125. package/dist/{index-DE1genab.d.ts → index-QnlWyUxN.d.ts} +2 -2
  126. package/dist/{index-C5e2rZML.d.ts → index-dWlCpnua.d.ts} +2 -2
  127. package/dist/{index-BPHqOCfp.d.ts → index-lmd9LZKB.d.ts} +4 -4
  128. package/dist/{index-CtYlR9Cu.d.ts → index-rdwI-mcm.d.ts} +1 -1
  129. package/dist/{index-BXDqyk2_.d.ts → index-tuNsmJxw.d.ts} +169 -2
  130. package/dist/{index-BEZ4ezJk.d.ts → index-wY6dKz6c.d.ts} +2 -2
  131. package/dist/{index-C89cIh4E.d.ts → index-waTkqxTz.d.ts} +1 -1
  132. package/dist/index.d.ts +39 -38
  133. package/dist/index.js +26 -26
  134. package/dist/{loadCatalog-DFyDz_4e.d.ts → loadCatalog-BJwcyX8i.d.ts} +2 -0
  135. package/dist/{loadCatalog-C3MSknfx.js → loadCatalog-C1kms5sO.js} +5 -1
  136. package/dist/locale/index.d.ts +2 -2
  137. package/dist/locale/index.js +3 -3
  138. package/dist/{locale-OCGw4bi6.js → locale-CHhsd9Mq.js} +1 -1
  139. package/dist/{typeahead-RkZw0Ktn.js → typeahead-BgfLP7vR.js} +2 -0
  140. package/dist/{index-DbFIQDoa.d.ts → types-C1ydeFiu.d.ts} +43 -65
  141. package/dist/{types-uWxXh1Jm.d.ts → types-fRasDCe4.d.ts} +47 -6
  142. package/dist/{useAsyncSource-Gk0VtE7_.js → useAsyncSource-7GTcK8ep.js} +31 -1
  143. package/dist/{useAsyncSource-aGzrvRkI.d.ts → useAsyncSource-DbG2FSuI.d.ts} +19 -2
  144. package/dist/{useCombobox-D374_pT8.js → useCombobox-DIR9yoEu.js} +150 -3
  145. package/dist/{useTypeaheadAnnouncement-CSikDlpK.js → useTypeaheadMenuConfig--4f7jR6G.js} +264 -20
  146. package/package.json +1 -1
  147. package/styles/motion.css +10 -0
  148. package/styles/selector.css +10 -0
  149. package/dist/composables-CCsHfpCS.js +0 -1256
  150. package/dist/{Chat-PEkZTrQE.js → Chat-Wq7e98zS.js} +1 -1
  151. package/dist/{CodeBlock-9Lfec8C8.js → CodeBlock-CLVXVlB7.js} +1 -1
  152. package/dist/{DateInput-kXAc_r5m.js → DateInput-BitZfGEY.js} +1 -1
  153. package/dist/{DateRangeInput-DW7IzFQM.js → DateRangeInput-kxXBsUTU.js} +1 -1
  154. package/dist/{index-BqhgeAT4.d.ts → index-D8lv2BiD.d.ts} +1 -1
@@ -1,12 +1,14 @@
1
1
  import { t as characterCount } from "./characters-wTnzjkkR.js";
2
- import { t as useAnnounce } from "./announce-GU01Oix2.js";
3
- import { n as useAsyncSource } from "./useAsyncSource-Gk0VtE7_.js";
4
- import { t as useCombobox } from "./useCombobox-D374_pT8.js";
5
2
  import { n as isDevBuild, t as devPropError } from "./devBuild-G249YcdZ.js";
6
- import { t as _sfc_main$2 } from "./Spinner-DEVPDsD0.js";
3
+ import { t as devWarn } from "./useDevWarning-B2fsk2B-.js";
4
+ import { t as useAnnounce } from "./announce-GU01Oix2.js";
5
+ import { n as useAsyncSource } from "./useAsyncSource-7GTcK8ep.js";
6
+ import { t as useCombobox } from "./useCombobox-DIR9yoEu.js";
7
+ import { t as _sfc_main$3 } from "./Spinner-DEVPDsD0.js";
7
8
  import { t as createStillPointerGate } from "./stillPointerGate-0vdn-hSa.js";
8
9
  import { i as isOptionAction, n as searchResultMessage, r as OptionAction, t as useOptionActionGrid } from "./useOptionActionGrid-C7ibYM_A.js";
9
- import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, normalizeClass, openBlock, ref, renderList, renderSlot, toDisplayString, toValue, unref, watch, withModifiers } from "vue";
10
+ import { Fragment, Teleport, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createTextVNode, createVNode, defineComponent, guardReactiveProps, h, mergeProps, nextTick, normalizeClass, normalizeProps, normalizeStyle, openBlock, ref, renderList, renderSlot, toDisplayString, toValue, unref, useSlots, useTemplateRef, vShow, watch, withCtx, withDirectives, withModifiers } from "vue";
11
+ import "../styles/layer.css";
10
12
  import "../styles/typeahead.css";
11
13
  //#region src/Typeahead/queryLength.ts
12
14
  /**
@@ -49,6 +51,11 @@ function useTypeaheadMenu(options) {
49
51
  if (source === previous || asyncSource.status.value !== "loading") return;
50
52
  asyncSource.status.value = "idle";
51
53
  }, { flush: "sync" });
54
+ const isSettled = computed(() => asyncSource.status.value !== "loading" && asyncSource.searchedQuery.value === query.value);
55
+ const menuStatus = computed(() => {
56
+ const status = asyncSource.status.value;
57
+ return status === "empty" && asyncSource.searchedQuery.value !== query.value ? "idle" : status;
58
+ });
52
59
  const matchCount = computed(() => {
53
60
  if (belowMinQueryLength.value) return 0;
54
61
  const excluded = new Set(toValue(options.excludeIds) ?? []);
@@ -106,6 +113,14 @@ function useTypeaheadMenu(options) {
106
113
  const current = list[combobox.activeIndex.value];
107
114
  if (!current || current.disabled) combobox.highlightFirst();
108
115
  });
116
+ watch([
117
+ isSettled,
118
+ () => asyncSource.status.value,
119
+ () => entries.value.length
120
+ ], () => {
121
+ if (!combobox.isOpen.value || !isSettled.value || query.value.trim() !== "") return;
122
+ if ((asyncSource.status.value === "empty" || asyncSource.status.value === "error") && entries.value.length === 0) close();
123
+ });
109
124
  /**
110
125
  * 太短的查询没东西可展示,此时不让下拉打开。
111
126
  * 只有从文字自己派生的条目(比如「创建 xxx」)还值得看一眼。
@@ -134,14 +149,27 @@ function useTypeaheadMenu(options) {
134
149
  if (value.length > 0 || toValue(options.showOnFocus)) open();
135
150
  else close();
136
151
  }
152
+ function resetQuery() {
153
+ const changed = query.value !== "";
154
+ query.value = "";
155
+ if (changed) options.onQueryChange?.("");
156
+ }
137
157
  function selectHighlighted() {
138
158
  const entry = entries.value[combobox.activeIndex.value];
139
159
  if (entry && !entry.disabled) options.onSelect(entry);
140
160
  }
141
161
  function onKeyDown(event) {
142
162
  if (event.isComposing || event.key === "Process") return;
143
- if (toValue(options.disabled)) return;
144
163
  const openNow = combobox.isOpen.value;
164
+ if (toValue(options.disabled)) {
165
+ if (openNow && event.key === "Enter") event.preventDefault();
166
+ if (openNow && event.key === "Escape") {
167
+ event.preventDefault();
168
+ close();
169
+ }
170
+ if (openNow && event.key === "Tab") close();
171
+ return;
172
+ }
145
173
  const list = entries.value;
146
174
  switch (event.key) {
147
175
  case "ArrowDown":
@@ -193,7 +221,6 @@ function useTypeaheadMenu(options) {
193
221
  if (openNow) {
194
222
  event.preventDefault();
195
223
  close();
196
- options.onEscape?.();
197
224
  }
198
225
  break;
199
226
  case "Tab": if (openNow) close();
@@ -211,8 +238,11 @@ function useTypeaheadMenu(options) {
211
238
  error: asyncSource.error,
212
239
  activeId,
213
240
  belowMinQueryLength,
241
+ isSettled,
242
+ menuStatus,
214
243
  matchCount,
215
244
  setQuery,
245
+ resetQuery,
216
246
  open,
217
247
  close,
218
248
  onKeyDown
@@ -254,7 +284,7 @@ function useLatchedOptionGrid(options) {
254
284
  }
255
285
  //#endregion
256
286
  //#region src/Typeahead/TypeaheadItem.vue
257
- const _hoisted_1$1 = ["data-disabled"];
287
+ const _hoisted_1$2 = ["data-disabled"];
258
288
  const _hoisted_2$1 = {
259
289
  key: 0,
260
290
  class: "astryx-typeahead-item-icon",
@@ -266,7 +296,7 @@ const _hoisted_5$1 = {
266
296
  key: 0,
267
297
  class: "astryx-typeahead-option-description"
268
298
  };
269
- const _sfc_main$1 = /*@__PURE__*/ defineComponent({
299
+ const _sfc_main$2 = /*@__PURE__*/ defineComponent({
270
300
  name: "AstryxTypeaheadItem",
271
301
  __name: "TypeaheadItem",
272
302
  props: {
@@ -282,16 +312,16 @@ const _sfc_main$1 = /*@__PURE__*/ defineComponent({
282
312
  return openBlock(), createElementBlock("span", {
283
313
  class: "astryx-typeahead-item",
284
314
  "data-disabled": props.isDisabled || props.item.disabled || void 0
285
- }, [_ctx.$slots.icon ? (openBlock(), createElementBlock("span", _hoisted_2$1, [renderSlot(_ctx.$slots, "icon")])) : createCommentVNode("v-if", true), createElementVNode("span", _hoisted_3$1, [createElementVNode("span", _hoisted_4$1, toDisplayString(props.item.label), 1), props.description ?? props.item.description ? (openBlock(), createElementBlock("span", _hoisted_5$1, toDisplayString(props.description ?? props.item.description), 1)) : createCommentVNode("v-if", true)])], 8, _hoisted_1$1);
315
+ }, [_ctx.$slots.icon ? (openBlock(), createElementBlock("span", _hoisted_2$1, [renderSlot(_ctx.$slots, "icon")])) : createCommentVNode("v-if", true), createElementVNode("span", _hoisted_3$1, [createElementVNode("span", _hoisted_4$1, toDisplayString(props.item.label), 1), props.description ?? props.item.description ? (openBlock(), createElementBlock("span", _hoisted_5$1, toDisplayString(props.description ?? props.item.description), 1)) : createCommentVNode("v-if", true)])], 8, _hoisted_1$2);
286
316
  };
287
317
  }
288
318
  });
289
319
  //#endregion
290
320
  //#region src/Typeahead/TypeaheadMenu.vue
291
- const _hoisted_1 = {
321
+ const _hoisted_1$1 = {
292
322
  key: 0,
293
323
  class: "astryx-typeahead-state",
294
- role: "status"
324
+ "aria-hidden": "true"
295
325
  };
296
326
  const _hoisted_2 = {
297
327
  key: 1,
@@ -316,6 +346,9 @@ const _hoisted_7 = [
316
346
  "aria-selected",
317
347
  "aria-disabled",
318
348
  "data-option-id",
349
+ "data-highlighted",
350
+ "data-selected",
351
+ "data-disabled",
319
352
  "onMouseenter",
320
353
  "onClick"
321
354
  ];
@@ -344,7 +377,7 @@ const _hoisted_13 = {
344
377
  fill: "none",
345
378
  "aria-hidden": "true"
346
379
  };
347
- const _sfc_main = /*@__PURE__*/ defineComponent({
380
+ const _sfc_main$1 = /*@__PURE__*/ defineComponent({
348
381
  name: "AstryxTypeaheadMenu",
349
382
  __name: "TypeaheadMenu",
350
383
  props: {
@@ -404,10 +437,10 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
404
437
  class: "astryx-typeahead-menu",
405
438
  role: "presentation",
406
439
  onMousemove: _cache[3] || (_cache[3] = (...args) => unref(pointerGate).track && unref(pointerGate).track(...args))
407
- }, [props.status === "loading" && props.entries.length === 0 ? (openBlock(), createElementBlock("div", _hoisted_1, [createVNode(_sfc_main$2, {
440
+ }, [props.status === "loading" && props.entries.length === 0 ? (openBlock(), createElementBlock("div", _hoisted_1$1, [createVNode(_sfc_main$3, {
408
441
  size: "sm",
409
442
  label: props.loadingText
410
- }, null, 8, ["label"])])) : props.status === "error" ? (openBlock(), createElementBlock("div", _hoisted_2, toDisplayString(props.errorText), 1)) : props.entries.length === 0 ? (openBlock(), createElementBlock("div", {
443
+ }, null, 8, ["label"])])) : props.status === "error" ? (openBlock(), createElementBlock("div", _hoisted_2, toDisplayString(props.errorText), 1)) : props.entries.length === 0 && props.status !== "idle" ? (openBlock(), createElementBlock("div", {
411
444
  key: 2,
412
445
  class: "astryx-typeahead-state",
413
446
  role: props.grid ? "presentation" : "option",
@@ -435,6 +468,9 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
435
468
  "aria-selected": row.entry.selected ? "true" : "false",
436
469
  "aria-disabled": row.entry.disabled || void 0,
437
470
  "data-option-id": row.entry.id,
471
+ "data-highlighted": row.index === props.activeIndex ? "highlighted" : void 0,
472
+ "data-selected": row.entry.selected ? "selected" : void 0,
473
+ "data-disabled": row.entry.disabled ? "disabled" : void 0,
438
474
  tabindex: "-1",
439
475
  onMousedown: _cache[2] || (_cache[2] = withModifiers(() => {}, ["prevent"])),
440
476
  onMouseenter: ($event) => onRowEnter($event, row.index),
@@ -452,7 +488,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
452
488
  entry: row.entry,
453
489
  isActive: row.index === props.activeIndex,
454
490
  isSelected: Boolean(row.entry.selected)
455
- }, () => [createVNode(_sfc_main$1, {
491
+ }, () => [createVNode(_sfc_main$2, {
456
492
  item: {
457
493
  id: row.entry.id,
458
494
  label: row.entry.label,
@@ -483,7 +519,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
483
519
  entry: row.entry,
484
520
  isActive: row.index === props.activeIndex,
485
521
  isSelected: Boolean(row.entry.selected)
486
- }, () => [createVNode(_sfc_main$1, {
522
+ }, () => [createVNode(_sfc_main$2, {
487
523
  item: {
488
524
  id: row.entry.id,
489
525
  label: row.entry.label,
@@ -507,6 +543,117 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
507
543
  }
508
544
  });
509
545
  //#endregion
546
+ //#region src/Typeahead/TypeaheadPopup.vue
547
+ const _hoisted_1 = [
548
+ "id",
549
+ "role",
550
+ "aria-label",
551
+ "data-placement"
552
+ ];
553
+ const _sfc_main = /*@__PURE__*/ defineComponent({
554
+ name: "AstryxTypeaheadPopup",
555
+ inheritAttrs: false,
556
+ __name: "TypeaheadPopup",
557
+ props: {
558
+ id: {},
559
+ isOpen: { type: Boolean },
560
+ config: {},
561
+ label: {},
562
+ grid: { type: Boolean },
563
+ placement: {},
564
+ popupStyle: {},
565
+ popupClass: {},
566
+ entries: {},
567
+ activeIndex: {},
568
+ actionIndex: {},
569
+ status: {},
570
+ emptyText: {},
571
+ loadingText: {},
572
+ errorText: {},
573
+ query: {},
574
+ isSettled: { type: Boolean }
575
+ },
576
+ emits: [
577
+ "select",
578
+ "highlight",
579
+ "close",
580
+ "keydown"
581
+ ],
582
+ setup(__props, { expose: __expose, emit: __emit }) {
583
+ const props = __props;
584
+ const emit = __emit;
585
+ const slots = useSlots();
586
+ const root = useTemplateRef("root");
587
+ __expose({ el: root });
588
+ const isDialog = computed(() => props.config?.role === "dialog");
589
+ const dialogLabel = computed(() => props.config?.role === "dialog" ? props.config.label : void 0);
590
+ /** listbox 角色带 `menu` 插槽:浮层本身不是列表,列表由插槽里的 `listbox` 放在想放的位置。 */
591
+ const wrapsList = computed(() => !isDialog.value && slots.menu != null);
592
+ const listRole = computed(() => props.grid ? "grid" : "listbox");
593
+ const isBusy = computed(() => props.status === "loading");
594
+ const isEmptySearch = computed(() => props.status === "empty" && props.isSettled && props.query.trim() !== "");
595
+ const menuProps = computed(() => ({
596
+ entries: props.entries,
597
+ activeIndex: props.activeIndex,
598
+ grid: props.grid,
599
+ actionIndex: props.actionIndex,
600
+ status: props.status,
601
+ listboxId: props.id,
602
+ emptyText: props.emptyText,
603
+ loadingText: props.loadingText,
604
+ errorText: props.errorText,
605
+ onSelect: (id) => emit("select", id),
606
+ onHighlight: (index) => emit("highlight", index)
607
+ }));
608
+ function menuSlots() {
609
+ return {
610
+ ...slots.item ? { item: slots.item } : {},
611
+ ...slots.empty ? { empty: slots.empty } : {}
612
+ };
613
+ }
614
+ /** 结果列表:唯一带 listbox 角色的元素,菜单插槽围着它放别的信息。 */
615
+ const Listbox = defineComponent({
616
+ name: "AstryxTypeaheadListbox",
617
+ setup: () => () => h("div", {
618
+ "id": props.id,
619
+ "role": listRole.value,
620
+ "aria-label": props.label
621
+ }, [h(_sfc_main$1, menuProps.value, menuSlots())])
622
+ });
623
+ return (_ctx, _cache) => {
624
+ return openBlock(), createBlock(Teleport, { to: "body" }, [createCommentVNode(" eslint-disable-next-line vue-a11y/no-static-element-interactions -- Escape 关 dialog 菜单:焦点在菜单里的任何地方按下都要接到。 "), withDirectives(createElementVNode("div", {
625
+ id: isDialog.value || !wrapsList.value ? __props.id : void 0,
626
+ ref_key: "root",
627
+ ref: root,
628
+ class: normalizeClass(["astryx-typeahead-listbox astryx-layer", __props.popupClass]),
629
+ role: isDialog.value ? "dialog" : wrapsList.value ? void 0 : listRole.value,
630
+ "aria-label": isDialog.value ? dialogLabel.value : wrapsList.value ? void 0 : __props.label,
631
+ "data-placement": __props.placement,
632
+ style: normalizeStyle(__props.popupStyle),
633
+ tabindex: "-1",
634
+ onKeydown: _cache[0] || (_cache[0] = ($event) => emit("keydown", $event))
635
+ }, [isDialog.value ? renderSlot(_ctx.$slots, "menu", {
636
+ query: __props.query,
637
+ close: () => emit("close")
638
+ }, void 0, void 0, 0) : wrapsList.value ? renderSlot(_ctx.$slots, "menu", {
639
+ listbox: unref(Listbox),
640
+ query: __props.query,
641
+ isBusy: isBusy.value,
642
+ isEmptySearch: isEmptySearch.value,
643
+ close: () => emit("close")
644
+ }, void 0, void 0, 1) : (openBlock(), createBlock(_sfc_main$1, normalizeProps(mergeProps({ key: 2 }, menuProps.value)), createSlots({ _: 2 }, [_ctx.$slots.item ? {
645
+ name: "item",
646
+ fn: withCtx((slotProps) => [renderSlot(_ctx.$slots, "item", normalizeProps(guardReactiveProps(slotProps)))]),
647
+ key: "0"
648
+ } : void 0, _ctx.$slots.empty ? {
649
+ name: "empty",
650
+ fn: withCtx(() => [renderSlot(_ctx.$slots, "empty")]),
651
+ key: "1"
652
+ } : void 0]), 1040))], 46, _hoisted_1), [[vShow, __props.isOpen]])]);
653
+ };
654
+ }
655
+ });
656
+ //#endregion
510
657
  //#region src/Typeahead/useTypeaheadAnnouncement.ts
511
658
  /**
512
659
  * 输入了文字、搜索落定之后,念一句结果数(点名每一条匹配,包括超出 `maxMenuItems`
@@ -519,7 +666,7 @@ function useTypeaheadAnnouncement(options) {
519
666
  const createRows = menu.entries.value.filter((entry) => entry.create).length;
520
667
  return searchResultMessage({
521
668
  isOpen: menu.combobox.isOpen.value,
522
- isLoading: menu.status.value === "loading",
669
+ isLoading: !menu.isSettled.value,
523
670
  query: menu.query.value,
524
671
  matchCount: menu.matchCount.value,
525
672
  hasCreateRow: createRows > 0,
@@ -529,9 +676,106 @@ function useTypeaheadAnnouncement(options) {
529
676
  });
530
677
  });
531
678
  watch(message, (next) => {
532
- if (next) announce(next);
679
+ if (!next) return;
680
+ options.settleBusy?.();
681
+ announce(next);
533
682
  });
534
683
  return message;
535
684
  }
536
685
  //#endregion
537
- export { useTypeaheadMenu as a, useLatchedOptionGrid as i, _sfc_main as n, _sfc_main$1 as r, useTypeaheadAnnouncement as t };
686
+ //#region src/Typeahead/useTypeaheadMenuConfig.ts
687
+ const FOCUSABLE = "a[href], button:not([disabled]), input:not([disabled]):not([type=\"hidden\"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])";
688
+ /**
689
+ * 菜单的角色:结果列表(listbox)或会拿走焦点的内容(dialog),以及用 `open()` 打开它的方法。
690
+ *
691
+ * - dialog 只能由 `open()` 打开,输入、聚焦、方向键都不会;打开后焦点进到里面,
692
+ * Escape 或 `close()` 关掉后焦点回到打开它时的元素,那个元素没了就回到输入框。
693
+ * - listbox 的 `open()` 显示结果,需要时先加载。
694
+ * - 在 `change` 里调用 `open()`:这次选择之后菜单保持打开,换成 dialog 时挂在同一个锚点上不闪。
695
+ */
696
+ function useTypeaheadMenuConfig(options) {
697
+ const isDialog = computed(() => options.config()?.role === "dialog");
698
+ const dialogOpen = ref(false);
699
+ const popupOpen = computed(() => isDialog.value ? dialogOpen.value : options.listbox.isOpen.value);
700
+ let opener = null;
701
+ let requestedInPick = false;
702
+ function popupHolds(element) {
703
+ return element != null && options.popupEl()?.contains(element) === true;
704
+ }
705
+ /** 焦点掉在菜单里、或没处可去时,才送回打开它的元素。点到别处的焦点不抢。 */
706
+ function restoreFocus() {
707
+ const active = document.activeElement;
708
+ if (active != null && active !== document.body && !popupHolds(active)) return;
709
+ const target = opener?.isConnected ? opener : options.returnTarget?.() ?? options.inputEl();
710
+ opener = null;
711
+ target?.focus();
712
+ }
713
+ function focusInside() {
714
+ const popup = options.popupEl();
715
+ (popup?.querySelector(FOCUSABLE) ?? popup)?.focus();
716
+ }
717
+ function open() {
718
+ if (options.isDisabled()) return;
719
+ const active = document.activeElement;
720
+ opener = active instanceof HTMLElement && !popupHolds(active) ? active : null;
721
+ requestedInPick = true;
722
+ nextTick(() => {
723
+ if (options.isDisabled()) return;
724
+ if (isDialog.value) {
725
+ options.listbox.close();
726
+ dialogOpen.value = true;
727
+ nextTick(focusInside);
728
+ } else if (options.canOpenList()) options.listbox.open();
729
+ });
730
+ }
731
+ function close() {
732
+ if (dialogOpen.value) {
733
+ dialogOpen.value = false;
734
+ nextTick(restoreFocus);
735
+ } else options.listbox.close();
736
+ }
737
+ function dismiss() {
738
+ dialogOpen.value = false;
739
+ opener = null;
740
+ }
741
+ watch(isDialog, (dialog) => {
742
+ if (!dialog) dialogOpen.value = false;
743
+ });
744
+ watch(() => options.isDisabled(), (disabled) => {
745
+ if (disabled) dialogOpen.value = false;
746
+ });
747
+ watch(popupOpen, (isOpen) => {
748
+ if (!isOpen || isDialog.value) return;
749
+ nextTick(() => {
750
+ const popup = options.popupEl();
751
+ const list = popup?.querySelector("[role=\"listbox\"], [role=\"grid\"]");
752
+ if (!popup || !list) return;
753
+ if ([...popup.querySelectorAll(FOCUSABLE)].some((control) => !list.contains(control) && control !== popup)) devWarn("Typeahead", "a control sits outside the result list in the menu. Anything a person acts on belongs in the list as a result, so the arrow keys reach it.");
754
+ });
755
+ });
756
+ function closeOnEscape(event) {
757
+ if (event.key !== "Escape" || !isDialog.value || !popupOpen.value) return false;
758
+ event.preventDefault();
759
+ event.stopPropagation();
760
+ close();
761
+ return true;
762
+ }
763
+ return {
764
+ isDialog,
765
+ popupOpen,
766
+ open,
767
+ close,
768
+ closeOnEscape,
769
+ dismiss,
770
+ beginPick: () => {
771
+ requestedInPick = false;
772
+ },
773
+ endPick: () => {
774
+ const requested = requestedInPick;
775
+ requestedInPick = false;
776
+ return requested;
777
+ }
778
+ };
779
+ }
780
+ //#endregion
781
+ export { useLatchedOptionGrid as a, _sfc_main$2 as i, useTypeaheadAnnouncement as n, useTypeaheadMenu as o, _sfc_main as r, useTypeaheadMenuConfig as t };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@astryx-vue/core",
3
3
  "type": "module",
4
- "version": "0.16.5",
4
+ "version": "0.17.0",
5
5
  "description": "Vue 3 components for the unofficial astryx-vue port of Astryx. Not affiliated with Meta.",
6
6
  "author": "ShenQingchuan",
7
7
  "license": "MIT",
package/styles/motion.css CHANGED
@@ -5,11 +5,21 @@
5
5
  * their own animations; these names are for later use and for the theme docs.
6
6
  * prefers-reduced-motion collapses the distance, scale, and opacity delta to
7
7
  * nothing, without rewriting component duration tokens.
8
+ *
9
+ * Reduce Motion splits by pointer, as UIKit does: under
10
+ * `@media (prefers-reduced-motion: reduce) and (pointer: coarse)` a change
11
+ * cross-fades over `--_astryx-reduced-motion-fade-duration` on
12
+ * `--_astryx-reduced-motion-fade-easing`; under
13
+ * `@media (prefers-reduced-motion: reduce) and (not (pointer: coarse))` it
14
+ * lands at once. The fade is a constant, not a theme token (no theme
15
+ * lengthens it); src/motion/reducedMotionCss.ts holds the same values.
8
16
  */
9
17
  @layer astryx.reset, astryx.tokens, astryx.base, astryx.components, astryx.overrides;
10
18
 
11
19
  @layer astryx.tokens {
12
20
  :root {
21
+ --_astryx-reduced-motion-fade-duration: 200ms;
22
+ --_astryx-reduced-motion-fade-easing: cubic-bezier(0.42, 0, 0.58, 1);
13
23
  --astryx-motion-enter-opacity: 0;
14
24
  --astryx-motion-exit-opacity: 1;
15
25
  --astryx-motion-scale-from: 0.95;
@@ -535,6 +535,16 @@
535
535
  outline: none;
536
536
  }
537
537
 
538
+ /*
539
+ * 幽灵和次要触发器的外框没有边框和聚焦底纹,焦点环画在真正拿到键盘焦点的那一个上:
540
+ * 触发器聚焦时环画在外框,清除按钮聚焦时环画在它自己身上,不会两个一起圈。
541
+ */
542
+ .astryx-selector-field:is(.is-ghost, [data-variant='secondary']):has(.astryx-selector-trigger:focus-visible),
543
+ .astryx-selector-field:is(.is-ghost, [data-variant='secondary']) .astryx-selector-clear:focus-visible {
544
+ outline: var(--astryx-focus-outline-width, 2px) var(--astryx-focus-outline-style, solid) var(--astryx-focus-outline-color, currentcolor);
545
+ outline-offset: 2px;
546
+ }
547
+
538
548
  /* 强制颜色下焦点只剩边框能表达:聚焦(含可聚焦的禁用字段)的边框取系统 Highlight 色。 */
539
549
  @layer astryx.components {
540
550
  @media (forced-colors: active) {