minerva-design 1.19.2 → 1.19.3

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.
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Runtime state shared by every copy of this package loaded in the realm
3
+ * (the ESM and CJS builds side by side, duplicated bundles...). Stacks and
4
+ * reference counts kept in plain module variables would split between
5
+ * copies: e.g. two scroll locks on the same body, each believing it is the
6
+ * only one, the first release restoring the styles under the second.
7
+ *
8
+ * The value is stored on `globalThis` under `Symbol.for("minerva.dom.<key>")`,
9
+ * created by the first copy that asks for it. Version the key (`"x.v1"`) and
10
+ * bump it whenever the shape of the state changes, so copies of different
11
+ * versions never read each other's state with the wrong shape.
12
+ */
13
+ export declare function sharedState<T>(key: string, init: () => T): T;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Runtime state shared by every copy of this package loaded in the realm
3
+ * (the ESM and CJS builds side by side, duplicated bundles...). Stacks and
4
+ * reference counts kept in plain module variables would split between
5
+ * copies: e.g. two scroll locks on the same body, each believing it is the
6
+ * only one, the first release restoring the styles under the second.
7
+ *
8
+ * The value is stored on `globalThis` under `Symbol.for("minerva.dom.<key>")`,
9
+ * created by the first copy that asks for it. Version the key (`"x.v1"`) and
10
+ * bump it whenever the shape of the state changes, so copies of different
11
+ * versions never read each other's state with the wrong shape.
12
+ */
13
+ export declare function sharedState<T>(key: string, init: () => T): T;
@@ -912,7 +912,7 @@ function Ie({ value: e, defaultValue: t = "", onChange: n, options: r, onSelect:
912
912
  g?.onFocus?.(e), !P && !F && H(!0);
913
913
  },
914
914
  onConfirm: (e) => {
915
- g?.onConfirm?.(e), E && ie && re(ie);
915
+ g?.onConfirm?.(e), Y && !S && E && ie && re(ie);
916
916
  },
917
917
  onChange: (e) => {
918
918
  L(e), H(!0);
@@ -1,4 +1,4 @@
1
- import { z as e } from "./components-R1m1BIE0.js";
1
+ import { z as e } from "./components-BUS7TwNX.js";
2
2
  import { useMemo as t } from "react";
3
3
  import { Image as n } from "@tarojs/components";
4
4
  import { jsx as r } from "react/jsx-runtime";
@@ -1,4 +1,4 @@
1
- import { A as e, B as t, C as n, D as r, E as i, F as a, H as o, I as s, L as c, M as l, N as u, O as d, P as f, R as p, S as m, T as h, U as g, V as _, _ as v, a as y, b, c as x, d as S, f as C, g as w, h as T, i as E, j as D, k as O, l as k, m as A, n as j, o as M, p as N, r as P, s as F, t as I, u as L, v as R, w as z, x as B, y as ee, z as V } from "./components-R1m1BIE0.js";
1
+ import { A as e, B as t, C as n, D as r, E as i, F as a, H as o, I as s, L as c, M as l, N as u, O as d, P as f, R as p, S as m, T as h, U as g, V as _, _ as v, a as y, b, c as x, d as S, f as C, g as w, h as T, i as E, j as D, k as O, l as k, m as A, n as j, o as M, p as N, r as P, s as F, t as I, u as L, v as R, w as z, x as B, y as ee, z as V } from "./components-BUS7TwNX.js";
2
2
  import { Children as te, Fragment as ne, cloneElement as re, createContext as ie, forwardRef as H, isValidElement as ae, useContext as oe, useEffect as U, useId as se, useImperativeHandle as ce, useMemo as W, useRef as G, useState as le } from "react";
3
3
  import { Canvas as ue, Image as de, Input as fe, Navigator as pe, ScrollView as me, Text as K, Video as he, View as q } from "@tarojs/components";
4
4
  import { DEFAULT_PLAYBACK_RATES as ge, DEFAULT_SKIP_SECONDS as _e, activeCueText as ve, addDays as ye, answerSheetLegend as be, answerSheetSections as xe, answerSheetSummary as Se, applyCodeMarks as Ce, captionsPreference as we, clampMediaTime as Te, clampVolume as Ee, closestSliderThumb as De, cn as J, codeLanguageLabel as Oe, computeFixedColumnLayout as ke, dashboardAccent as Ae, dashboardCardMove as je, dashboardCount as Me, dashboardFind as Ne, dashboardInsertIndex as Pe, dashboardLength as Fe, dayKey as Ie, detectCodeLanguage as Le, formatHasSeconds as Re, formatMediaTime as ze, formatPlaybackRate as Be, formatTime as Ve, getColumnCompare as He, getPaginationItems as Ue, getPaginationVisibleRange as We, getSliderKeyValue as Ge, getSliderMarks as Ke, getTabsTabStop as qe, getVirtualRange as Je, highlightCode as Ye, inferMediaType as Xe, isDashboardNoop as Ze, isSafeUrl as Qe, isSliderMarkActive as $e, loadCaptions as et, matchesAccept as tt, matchesShortcut as nt, mediaProgress as rt, monthStart as it, nextPlaybackRate as at, nextSortState as ot, normalizeShortcuts as st, normalizeSliderValue as ct, parseDayKey as lt, parseTimeInput as ut, pickCaptionsTrack as dt, readCaptionsPreference as ft, resolveCodeMarkBackground as pt, resolveSize as mt, resolveTimeFormat as ht, resolveTokens as gt, secondsOfDay as _t, setSliderThumb as vt, sliderPercent as yt, sliderRatioAt as bt, sliderValueFromRatio as xt, sliderValues as St, sliderValuesEqual as Ct, splitCodeMarkLines as wt, startOfToday as Tt, weekStart as Et, writeCaptionsPreference as Dt } from "../core/index.js";
@@ -1,4 +1,4 @@
1
- import { I as e, L as t, t as n } from "./components-R1m1BIE0.js";
1
+ import { I as e, L as t, t as n } from "./components-BUS7TwNX.js";
2
2
  import { useEffect as r, useId as i, useRef as a, useState as o } from "react";
3
3
  import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
4
4
  //#region src/monaco.tsx
@@ -10,6 +10,7 @@ import {
10
10
  onBeforeUnmount,
11
11
  type CSSProperties,
12
12
  } from "vue";
13
+ import { resolveActiveOptionIndex } from "../core/index.js";
13
14
  import { useNativeId as useId } from "./native-id.js";
14
15
  import { inheritForm } from "./form-context.js";
15
16
  import PopoverContent from "./PopoverContent.vue";
@@ -75,7 +76,8 @@ const readOnly = computed(() => props.inputProps?.readOnly ?? props.readOnly);
75
76
  const locked = computed(() => disabled.value || readOnly.value);
76
77
  const open = ref(false);
77
78
  const composing = ref(false);
78
- const active = ref(-1);
79
+ // Keyboard highlight, by option identity (survives async option updates)
80
+ const focusedValue = ref<string | number | null>(null);
79
81
  let blurTimer: ReturnType<typeof setTimeout> | undefined;
80
82
  const filtered = computed(() => {
81
83
  const result = props.options.filter((o) =>
@@ -102,25 +104,28 @@ const groups = computed(() => {
102
104
  return result;
103
105
  });
104
106
  const ordered = computed(() => groups.value.flatMap((g) => g.options));
105
- const activeOption = computed(
106
- () =>
107
- ordered.value[
108
- active.value >= 0
109
- ? active.value
110
- : props.autoHighlight && open.value
111
- ? ordered.value.findIndex((o) => !o.disabled)
112
- : -1
113
- ],
107
+ // Options the keyboard can reach: none while loading (they are hidden).
108
+ const interactive = computed(() => (props.loading ? [] : ordered.value));
109
+ // With autoHighlight the first enabled option is active until the user
110
+ // moves the highlight; a highlight whose option is gone falls back.
111
+ const activeIndex = computed(() =>
112
+ resolveActiveOptionIndex(
113
+ interactive.value,
114
+ focusedValue.value,
115
+ !!props.autoHighlight && open.value && !locked.value,
116
+ ),
117
+ );
118
+ const activeOption = computed(() => interactive.value[activeIndex.value]);
119
+ /** Option -> its index in display order (ids for aria-activedescendant) */
120
+ const optionIndex = computed(
121
+ () => new Map(ordered.value.map((option, index) => [option, index])),
114
122
  );
115
- watch(filtered, () => {
116
- active.value = -1;
117
- });
118
123
  function setOpen(value: boolean) {
119
124
  if (value && locked.value) return;
120
125
  clearTimeout(blurTimer);
121
126
  if (open.value !== value) emit("dropdownVisibleChange", value);
122
127
  open.value = value;
123
- if (!value) active.value = -1;
128
+ if (!value) focusedValue.value = null;
124
129
  }
125
130
  watch(locked, (value) => {
126
131
  if (value) setOpen(false);
@@ -136,7 +141,7 @@ function change(value: string) {
136
141
  function type(value: string) {
137
142
  if (locked.value) return;
138
143
  change(value);
139
- active.value = -1;
144
+ focusedValue.value = null;
140
145
  setOpen(true);
141
146
  }
142
147
  function choose(option: Option, pointer = false) {
@@ -149,8 +154,7 @@ function choose(option: Option, pointer = false) {
149
154
  }
150
155
  function confirm() {
151
156
  if (locked.value || composing.value) return;
152
- if (open.value && activeOption.value && !props.loading)
153
- choose(activeOption.value);
157
+ if (open.value && activeOption.value) choose(activeOption.value);
154
158
  else if (current.value.trim()) {
155
159
  emit("submit", current.value.trim());
156
160
  setOpen(false);
@@ -174,17 +178,17 @@ function keydown(event: KeyboardEvent) {
174
178
  } else if (event.key === "ArrowDown" || event.key === "ArrowUp") {
175
179
  event.preventDefault();
176
180
  setOpen(true);
177
- const count = ordered.value.length,
181
+ const list = interactive.value,
182
+ count = list.length,
178
183
  step = event.key === "ArrowDown" ? 1 : -1;
179
- let next = activeOption.value
180
- ? ordered.value.indexOf(activeOption.value)
181
- : step === 1
182
- ? -1
183
- : count;
184
+ // from "nothing focused", ArrowDown starts at the first option and
185
+ // ArrowUp at the last one
186
+ let next =
187
+ activeIndex.value >= 0 ? activeIndex.value : step === 1 ? -1 : count;
184
188
  for (let i = 0; i < count; i++) {
185
189
  next = (next + step + count) % count;
186
- if (!ordered.value[next].disabled) {
187
- active.value = next;
190
+ if (!list[next].disabled) {
191
+ focusedValue.value = list[next].value;
188
192
  break;
189
193
  }
190
194
  }
@@ -243,6 +247,9 @@ provide<MiniPopoverContext>("minerva:popover", {
243
247
  :placeholder="placeholder ?? inputProps?.placeholder"
244
248
  role="combobox"
245
249
  :aria-expanded="open"
250
+ :aria-activedescendant="
251
+ open && activeIndex >= 0 ? `${id}-option-${activeIndex}` : undefined
252
+ "
246
253
  @change="type"
247
254
  @focus="setOpen(true)"
248
255
  @tap="setOpen(true)"
@@ -291,6 +298,7 @@ provide<MiniPopoverContext>("minerva:popover", {
291
298
  <button
292
299
  v-for="option in group.options"
293
300
  :key="option.value"
301
+ :id="`${id}-option-${optionIndex.get(option)}`"
294
302
  class="mn-option"
295
303
  :class="{
296
304
  'mn-disabled': option.disabled,