@atscript/vue-form 0.1.167 → 0.1.168
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/{as-array-B2axGw3v.mjs → as-array-C9mBBhOv.mjs} +6 -6
- package/dist/{as-array-C97cLzdA.cjs → as-array-ChGQxnvj.cjs} +6 -6
- package/dist/{as-array-clear-btn-BBFccQjO.cjs → as-array-clear-btn-QX7jyfrl.cjs} +2 -2
- package/dist/{as-array-clear-btn-DEH8a3_N.mjs → as-array-clear-btn-oKQHiamf.mjs} +2 -2
- package/dist/as-array.cjs +1 -1
- package/dist/as-array.mjs +1 -1
- package/dist/{as-checkbox-BO8xW0OM.mjs → as-checkbox-BOyH1Yfs.mjs} +3 -3
- package/dist/{as-checkbox-Wn-PmHi-.cjs → as-checkbox-Cbm2qmFH.cjs} +3 -3
- package/dist/as-checkbox.cjs +1 -1
- package/dist/as-checkbox.mjs +1 -1
- package/dist/{as-collapsible-BGeuF2Bn.cjs → as-collapsible-Ck92YufI.cjs} +2 -2
- package/dist/{as-collapsible-Cb9SgJh9.mjs → as-collapsible-DxYCn-ue.mjs} +2 -2
- package/dist/as-collapsible.cjs +1 -1
- package/dist/as-collapsible.mjs +1 -1
- package/dist/{as-date-jQpwe6sr.mjs → as-date-BFiTIWhQ.mjs} +1 -1
- package/dist/{as-date-B2dgUoau.cjs → as-date-Y8DtscL_.cjs} +1 -1
- package/dist/as-date.cjs +1 -1
- package/dist/as-date.mjs +1 -1
- package/dist/{as-datetime-DYn9NndT.mjs → as-datetime-Cx4OKGNY.mjs} +1 -1
- package/dist/{as-datetime-CmBLyjgU.cjs → as-datetime-DRXHIWG7.cjs} +1 -1
- package/dist/as-datetime.cjs +1 -1
- package/dist/as-datetime.mjs +1 -1
- package/dist/{as-decimal-C-OJ8ygU.mjs → as-decimal-BF8UHXiz.mjs} +2 -2
- package/dist/{as-decimal-C0Eqd9nM.cjs → as-decimal-DuTXhLLu.cjs} +2 -2
- package/dist/as-decimal.cjs +1 -1
- package/dist/as-decimal.mjs +1 -1
- package/dist/{as-field-D0HgywQY.cjs → as-field-CHYBYJ07.cjs} +6 -3
- package/dist/{as-field-BZpWLPcM.mjs → as-field-Cem3O5q5.mjs} +6 -3
- package/dist/{as-field-shell-DSj3CqN6.cjs → as-field-shell-ByTLPM99.cjs} +3 -3
- package/dist/{as-field-shell-D7XovzgJ.mjs → as-field-shell-YzKEFdfk.mjs} +3 -3
- package/dist/as-field-shell.cjs +1 -1
- package/dist/as-field-shell.mjs +1 -1
- package/dist/as-field.cjs +1 -1
- package/dist/as-field.mjs +1 -1
- package/dist/{as-form-0VCxVsGo.mjs → as-form-CkLlDHYv.mjs} +11 -7
- package/dist/{as-form-ChyW9bj2.cjs → as-form-wiko7XE-.cjs} +11 -7
- package/dist/as-form.cjs +1 -1
- package/dist/as-form.d.cts +1 -1
- package/dist/as-form.d.mts +1 -1
- package/dist/as-form.mjs +1 -1
- package/dist/{as-form.vue-B_nSx3Ta.d.cts → as-form.vue-B7pD1tRD.d.cts} +6 -0
- package/dist/{as-form.vue-BL-R84j8.d.mts → as-form.vue-CZsZ93hh.d.mts} +6 -0
- package/dist/{as-input-DlLLiAYI.mjs → as-input-DF8S-SVw.mjs} +1 -1
- package/dist/{as-input-Bf94SAOY.cjs → as-input-UmnzPTWe.cjs} +1 -1
- package/dist/as-input.cjs +1 -1
- package/dist/as-input.mjs +1 -1
- package/dist/{as-iterator-Bty6f5Bq.cjs → as-iterator-CQowj0oB.cjs} +2 -2
- package/dist/{as-iterator-Dp1OiwU7.mjs → as-iterator-DWKOlmIo.mjs} +2 -2
- package/dist/as-iterator.cjs +1 -1
- package/dist/as-iterator.mjs +1 -1
- package/dist/{as-multi-select-ZGBYoI48.cjs → as-multi-select-BPhhpk-0.cjs} +2 -2
- package/dist/{as-multi-select-DT0M_1_O.mjs → as-multi-select-DTErr4w0.mjs} +2 -2
- package/dist/as-multi-select.cjs +1 -1
- package/dist/as-multi-select.mjs +1 -1
- package/dist/{as-number-DXQCnc9d.cjs → as-number-CFF3UZuC.cjs} +2 -2
- package/dist/{as-number-DkG5GuGW.mjs → as-number-D3YaZJEv.mjs} +2 -2
- package/dist/as-number.cjs +1 -1
- package/dist/as-number.mjs +1 -1
- package/dist/{as-object-mpRxIKVB.mjs → as-object-CYBKux5h.mjs} +5 -5
- package/dist/{as-object-DLdKOhxb.cjs → as-object-DgVplPOo.cjs} +5 -5
- package/dist/as-object.cjs +1 -1
- package/dist/as-object.mjs +1 -1
- package/dist/{as-radio-CW9YWBnC.mjs → as-radio-B0xhGDGg.mjs} +1 -1
- package/dist/{as-radio-D9sctKpc.cjs → as-radio-ColcrNuU.cjs} +1 -1
- package/dist/as-radio.cjs +1 -1
- package/dist/as-radio.mjs +1 -1
- package/dist/{as-ref-CpHMAAJu.cjs → as-ref-DBfT7RYx.cjs} +3 -3
- package/dist/{as-ref-DaCGfshO.mjs → as-ref-KUaYhUd1.mjs} +3 -3
- package/dist/as-ref.cjs +1 -1
- package/dist/as-ref.mjs +1 -1
- package/dist/{as-select-DAbNosmB.cjs → as-select-C4nXhF3W.cjs} +1 -1
- package/dist/{as-select-CrjlxcgR.mjs → as-select-CYhUQpSa.mjs} +1 -1
- package/dist/as-select.cjs +1 -1
- package/dist/as-select.mjs +1 -1
- package/dist/{as-time-NaICaSIj.cjs → as-time-BfWzx_ja.cjs} +1 -1
- package/dist/{as-time-BmXXgfCZ.mjs → as-time-DnPYtRha.mjs} +1 -1
- package/dist/as-time.cjs +1 -1
- package/dist/as-time.mjs +1 -1
- package/dist/{as-tuple-DkI9fp4G.cjs → as-tuple-BLgljjo3.cjs} +6 -6
- package/dist/{as-tuple-BBx6P6xb.mjs → as-tuple-DB8ZlblB.mjs} +6 -6
- package/dist/as-tuple.cjs +1 -1
- package/dist/as-tuple.mjs +1 -1
- package/dist/{as-union-C3QiGYlE.mjs → as-union-CzYUjXbF.mjs} +2 -2
- package/dist/{as-union-BjmrvD80.cjs → as-union-a17Hv-0j.cjs} +2 -2
- package/dist/as-union.cjs +1 -1
- package/dist/as-union.mjs +1 -1
- package/dist/{as-variant-picker-BUF7Am9t.mjs → as-variant-picker-CDUB7dsS.mjs} +1 -1
- package/dist/{as-variant-picker-BcJx7Zt7.cjs → as-variant-picker-DrI9AF2k.cjs} +1 -1
- package/dist/index.cjs +25 -23
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +24 -24
- package/dist/locale.cjs +5 -1
- package/dist/locale.d.cts +2 -2
- package/dist/locale.d.mts +2 -2
- package/dist/locale.mjs +2 -2
- package/dist/use-as-locale-BxMBUV_j.d.mts +84 -0
- package/dist/use-as-locale-CbpIkjCt.mjs +159 -0
- package/dist/use-as-locale-Dyt3uS60.d.cts +84 -0
- package/dist/use-as-locale-x8f0eN6K.cjs +200 -0
- package/dist/{use-as-value-help-nIpEFMqD.mjs → use-as-value-help-B7Nv5fo6.mjs} +48 -11
- package/dist/{use-as-value-help-BE-fAZRP.cjs → use-as-value-help-DvGkyEPo.cjs} +48 -11
- package/dist/{use-form-context-C3FxL3eF.mjs → use-form-context--9Eqepmq.mjs} +3 -2
- package/dist/{use-form-context-CXsLnG7l.cjs → use-form-context-CtV09wts.cjs} +8 -1
- package/package.json +9 -9
- package/dist/use-as-locale-1k9NBn-G.mjs +0 -56
- package/dist/use-as-locale-BVcC0l75.d.mts +0 -35
- package/dist/use-as-locale-C2tFUenv.cjs +0 -73
- package/dist/use-as-locale-CnGzoVWd.d.cts +0 -35
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { computed, getCurrentScope, hasInjectionContext, inject, onScopeDispose, provide, shallowRef, ssrContextKey, watch } from "vue";
|
|
2
|
+
import { activateUiTexts, createUiTexts, getUiTexts, onUiLocaleChange } from "@atscript/ui";
|
|
3
|
+
//#region src/composables/use-as-locale.ts
|
|
4
|
+
/**
|
|
5
|
+
* The app's locale and UI texts: the BCP-47 locale for form-side `Intl`
|
|
6
|
+
* formatting (decimal separator, thousands, currency symbol) and the
|
|
7
|
+
* language of the built-in texts (buttons, labels, messages) of every
|
|
8
|
+
* `@atscript/vue-*` component. Parallels `provideCellLocale` in
|
|
9
|
+
* `@atscript/vue-table`, which owns the table's `Intl` locale and time zone —
|
|
10
|
+
* the host wires both from a single source (e.g. `useAppPrefs`).
|
|
11
|
+
*
|
|
12
|
+
* One per app, never module-global: a server rendering for many users keeps
|
|
13
|
+
* each app's locale. Interned (`Symbol.for`): one key across module copies.
|
|
14
|
+
*/
|
|
15
|
+
const AS_LOCALE_KEY = Symbol.for("atscript.ui.locale");
|
|
16
|
+
/** The server-rendered texts the browser app starts with (`provideAsServedTexts`). */
|
|
17
|
+
const AS_SERVED_TEXTS_KEY = Symbol.for("atscript.ui.served-texts");
|
|
18
|
+
/** Where a server render's app texts are kept on the Vue SSR context. */
|
|
19
|
+
const SSR_TEXTS = Symbol.for("atscript.ui.ssr-texts");
|
|
20
|
+
/**
|
|
21
|
+
* Provides the app's locale. `getter` returns a BCP-47 locale (or
|
|
22
|
+
* `undefined` for the runtime's); reactive sources work as they are
|
|
23
|
+
* (`() => prefs.value.language`). The built-in texts follow it: the texts the
|
|
24
|
+
* server served for the locale, else English — or your own `translate`
|
|
25
|
+
* first (return `undefined` to fall back).
|
|
26
|
+
*
|
|
27
|
+
* Call it once at the app root. To switch the language of an open page,
|
|
28
|
+
* remount the view (`<RouterView :key="locale" />`). With server rendering,
|
|
29
|
+
* hand the texts the render used to the browser app: {@link getAsServedTexts}
|
|
30
|
+
* and {@link provideAsServedTexts}.
|
|
31
|
+
*/
|
|
32
|
+
function provideAsLocale(getter, translate) {
|
|
33
|
+
const ownTranslate = translate && (() => translate);
|
|
34
|
+
const ssr = typeof window === "undefined" ? inject(ssrContextKey, null) : null;
|
|
35
|
+
const render = ssr ? ssr[SSR_TEXTS] ??= {
|
|
36
|
+
dicts: shallowRef({}),
|
|
37
|
+
unserved: /* @__PURE__ */ new Map()
|
|
38
|
+
} : null;
|
|
39
|
+
let texts = createUiTexts({
|
|
40
|
+
locale: getter,
|
|
41
|
+
translate: ownTranslate,
|
|
42
|
+
dicts: render?.dicts ?? shallowRef({})
|
|
43
|
+
});
|
|
44
|
+
const seed = inject(AS_SERVED_TEXTS_KEY, null);
|
|
45
|
+
if (seed) for (const [locale, dict] of Object.entries(seed)) texts.merge(locale || void 0, dict);
|
|
46
|
+
if (render) texts = pinUnserved(texts, render, ownTranslate);
|
|
47
|
+
provide(AS_LOCALE_KEY, texts);
|
|
48
|
+
if (typeof window !== "undefined") onScopeDispose(activateUiTexts(texts));
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* `texts` for one server render, so the HTML and the hydrating browser agree
|
|
52
|
+
* everywhere: an id looked up before the server served a text for it shows
|
|
53
|
+
* the fallback (`translate`, else English) for the rest of the render — in
|
|
54
|
+
* every provider of the render — and is left out of `getAsServedTexts`.
|
|
55
|
+
*/
|
|
56
|
+
function pinUnserved(texts, render, translate) {
|
|
57
|
+
const fallback = createUiTexts({
|
|
58
|
+
locale: texts.locale,
|
|
59
|
+
translate
|
|
60
|
+
});
|
|
61
|
+
return {
|
|
62
|
+
...texts,
|
|
63
|
+
t: (id, params) => {
|
|
64
|
+
const key = texts.locale() ?? "";
|
|
65
|
+
let pinned = render.unserved.get(key);
|
|
66
|
+
if (pinned?.has(id)) return fallback.t(id, params);
|
|
67
|
+
const dict = render.dicts.value[key];
|
|
68
|
+
if (!dict || !Object.hasOwn(dict, id)) {
|
|
69
|
+
if (!pinned) render.unserved.set(key, pinned = /* @__PURE__ */ new Set());
|
|
70
|
+
pinned.add(id);
|
|
71
|
+
}
|
|
72
|
+
return texts.t(id, params);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Server side: the texts the server served while rendering this app (merged
|
|
78
|
+
* into its `provideAsLocale` texts, e.g. `/meta` `$i18n`) — pass the context
|
|
79
|
+
* object you gave `renderToString(app, ssrContext)`, after it resolves.
|
|
80
|
+
* `undefined` when nothing was served (or the app has no `provideAsLocale`).
|
|
81
|
+
* Put it into the state your server transfers to the browser and give it to
|
|
82
|
+
* {@link provideAsServedTexts} there, so the browser renders the same texts
|
|
83
|
+
* before its own requests come back.
|
|
84
|
+
*
|
|
85
|
+
* A text the render looked up before the server served it shows the fallback
|
|
86
|
+
* everywhere in that render and is left out: the hydrating browser shows the
|
|
87
|
+
* fallback too, and its own request switches it afterwards. Since 0.1.168.
|
|
88
|
+
*/
|
|
89
|
+
function getAsServedTexts(ssrContext) {
|
|
90
|
+
const render = ssrContext[SSR_TEXTS];
|
|
91
|
+
if (!render) return void 0;
|
|
92
|
+
let out;
|
|
93
|
+
for (const [locale, dict] of Object.entries(render.dicts.value)) {
|
|
94
|
+
const skip = render.unserved.get(locale);
|
|
95
|
+
for (const [id, text] of Object.entries(dict)) {
|
|
96
|
+
if (skip?.has(id)) continue;
|
|
97
|
+
((out ??= {})[locale] ??= {})[id] = text;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return out;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Browser side: the texts the server render used ({@link getAsServedTexts}),
|
|
104
|
+
* merged into the app's texts when `provideAsLocale` creates them — call it
|
|
105
|
+
* before `app.mount()`. Nothing to merge (`undefined`) is fine. Since 0.1.168.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```ts
|
|
109
|
+
* const { app } = createApp();
|
|
110
|
+
* provideAsServedTexts(app, window.__SSR_STATE__?.asTexts);
|
|
111
|
+
* app.mount("#app");
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
function provideAsServedTexts(app, served) {
|
|
115
|
+
if (served) app.provide(AS_SERVED_TEXTS_KEY, served);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* The app's UI texts when a `provideAsLocale` is above the caller, else `null`.
|
|
119
|
+
*
|
|
120
|
+
* @internal Shared with `@atscript/vue-table`.
|
|
121
|
+
*/
|
|
122
|
+
function injectAsTexts() {
|
|
123
|
+
return hasInjectionContext() ? inject(AS_LOCALE_KEY, null) : null;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* The app's UI texts (`provideAsLocale`), else the global ones
|
|
127
|
+
* (`setUiLocale`). One `inject` — cheap enough for per-row components.
|
|
128
|
+
*
|
|
129
|
+
* @internal Shared with `@atscript/vue-table` and `@atscript/vue-wf`.
|
|
130
|
+
*/
|
|
131
|
+
function useAsTexts() {
|
|
132
|
+
return injectAsTexts() ?? getUiTexts();
|
|
133
|
+
}
|
|
134
|
+
function useAsLocale() {
|
|
135
|
+
const provided = injectAsTexts();
|
|
136
|
+
const texts = provided ?? getUiTexts();
|
|
137
|
+
return {
|
|
138
|
+
locale: computed(() => provided?.locale()),
|
|
139
|
+
t: texts.t
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* The app's current UI locale as a ref: follows a `provideAsLocale` getter
|
|
144
|
+
* and `setUiLocale` (which is not reactive) — for a `:key` that rebuilds a
|
|
145
|
+
* view, or a watch that re-binds one, when the locale changes.
|
|
146
|
+
*
|
|
147
|
+
* @internal Shared with `@atscript/vue-table`.
|
|
148
|
+
*/
|
|
149
|
+
function useUiLocaleKey(texts) {
|
|
150
|
+
const key = shallowRef(texts.locale());
|
|
151
|
+
const sync = () => {
|
|
152
|
+
key.value = texts.locale();
|
|
153
|
+
};
|
|
154
|
+
watch(() => texts.locale(), sync);
|
|
155
|
+
if (typeof window !== "undefined" && getCurrentScope()) onScopeDispose(onUiLocaleChange(sync));
|
|
156
|
+
return key;
|
|
157
|
+
}
|
|
158
|
+
//#endregion
|
|
159
|
+
export { useAsLocale as a, provideAsServedTexts as i, injectAsTexts as n, useAsTexts as o, provideAsLocale as r, useUiLocaleKey as s, getAsServedTexts as t };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { App, ComputedRef, ShallowRef } from "vue";
|
|
2
|
+
import { UiT, UiTexts, UiTranslate } from "@atscript/ui";
|
|
3
|
+
|
|
4
|
+
//#region src/composables/use-as-locale.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* The texts the server served during a server render (`/meta` `$i18n`, …), per
|
|
7
|
+
* locale (`""` = no locale): what {@link getAsServedTexts} collects and
|
|
8
|
+
* {@link provideAsServedTexts} hands to the browser app. Plain JSON.
|
|
9
|
+
*/
|
|
10
|
+
type AsServedTexts = Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
11
|
+
/**
|
|
12
|
+
* Provides the app's locale. `getter` returns a BCP-47 locale (or
|
|
13
|
+
* `undefined` for the runtime's); reactive sources work as they are
|
|
14
|
+
* (`() => prefs.value.language`). The built-in texts follow it: the texts the
|
|
15
|
+
* server served for the locale, else English — or your own `translate`
|
|
16
|
+
* first (return `undefined` to fall back).
|
|
17
|
+
*
|
|
18
|
+
* Call it once at the app root. To switch the language of an open page,
|
|
19
|
+
* remount the view (`<RouterView :key="locale" />`). With server rendering,
|
|
20
|
+
* hand the texts the render used to the browser app: {@link getAsServedTexts}
|
|
21
|
+
* and {@link provideAsServedTexts}.
|
|
22
|
+
*/
|
|
23
|
+
declare function provideAsLocale(getter: () => string | undefined, translate?: UiTranslate): void;
|
|
24
|
+
/**
|
|
25
|
+
* Server side: the texts the server served while rendering this app (merged
|
|
26
|
+
* into its `provideAsLocale` texts, e.g. `/meta` `$i18n`) — pass the context
|
|
27
|
+
* object you gave `renderToString(app, ssrContext)`, after it resolves.
|
|
28
|
+
* `undefined` when nothing was served (or the app has no `provideAsLocale`).
|
|
29
|
+
* Put it into the state your server transfers to the browser and give it to
|
|
30
|
+
* {@link provideAsServedTexts} there, so the browser renders the same texts
|
|
31
|
+
* before its own requests come back.
|
|
32
|
+
*
|
|
33
|
+
* A text the render looked up before the server served it shows the fallback
|
|
34
|
+
* everywhere in that render and is left out: the hydrating browser shows the
|
|
35
|
+
* fallback too, and its own request switches it afterwards. Since 0.1.168.
|
|
36
|
+
*/
|
|
37
|
+
declare function getAsServedTexts(ssrContext: object): AsServedTexts | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Browser side: the texts the server render used ({@link getAsServedTexts}),
|
|
40
|
+
* merged into the app's texts when `provideAsLocale` creates them — call it
|
|
41
|
+
* before `app.mount()`. Nothing to merge (`undefined`) is fine. Since 0.1.168.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* const { app } = createApp();
|
|
46
|
+
* provideAsServedTexts(app, window.__SSR_STATE__?.asTexts);
|
|
47
|
+
* app.mount("#app");
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
declare function provideAsServedTexts(app: App, served: AsServedTexts | undefined): void;
|
|
51
|
+
interface UseAsLocaleReturn {
|
|
52
|
+
/** Resolved locale; `undefined` when no provider is present (runtime locale). */
|
|
53
|
+
locale: ComputedRef<string | undefined>;
|
|
54
|
+
/**
|
|
55
|
+
* A built-in UI text in the app's locale — `t("UI_CANCEL")`,
|
|
56
|
+
* `t("UI_FORM_ADD", { item: "address" })`. The codes and their English
|
|
57
|
+
* texts are `AS_UI_MESSAGES` (`@atscript/ui/messages`).
|
|
58
|
+
*/
|
|
59
|
+
t: UiT;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The app's UI texts when a `provideAsLocale` is above the caller, else `null`.
|
|
63
|
+
*
|
|
64
|
+
* @internal Shared with `@atscript/vue-table`.
|
|
65
|
+
*/
|
|
66
|
+
declare function injectAsTexts(): UiTexts | null;
|
|
67
|
+
/**
|
|
68
|
+
* The app's UI texts (`provideAsLocale`), else the global ones
|
|
69
|
+
* (`setUiLocale`). One `inject` — cheap enough for per-row components.
|
|
70
|
+
*
|
|
71
|
+
* @internal Shared with `@atscript/vue-table` and `@atscript/vue-wf`.
|
|
72
|
+
*/
|
|
73
|
+
declare function useAsTexts(): UiTexts;
|
|
74
|
+
declare function useAsLocale(): UseAsLocaleReturn;
|
|
75
|
+
/**
|
|
76
|
+
* The app's current UI locale as a ref: follows a `provideAsLocale` getter
|
|
77
|
+
* and `setUiLocale` (which is not reactive) — for a `:key` that rebuilds a
|
|
78
|
+
* view, or a watch that re-binds one, when the locale changes.
|
|
79
|
+
*
|
|
80
|
+
* @internal Shared with `@atscript/vue-table`.
|
|
81
|
+
*/
|
|
82
|
+
declare function useUiLocaleKey(texts: Pick<UiTexts, "locale">): ShallowRef<string | undefined>;
|
|
83
|
+
//#endregion
|
|
84
|
+
export { provideAsLocale as a, useAsTexts as c, injectAsTexts as i, useUiLocaleKey as l, UseAsLocaleReturn as n, provideAsServedTexts as o, getAsServedTexts as r, useAsLocale as s, AsServedTexts as t };
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
let vue = require("vue");
|
|
2
|
+
let _atscript_ui = require("@atscript/ui");
|
|
3
|
+
//#region src/composables/use-as-locale.ts
|
|
4
|
+
/**
|
|
5
|
+
* The app's locale and UI texts: the BCP-47 locale for form-side `Intl`
|
|
6
|
+
* formatting (decimal separator, thousands, currency symbol) and the
|
|
7
|
+
* language of the built-in texts (buttons, labels, messages) of every
|
|
8
|
+
* `@atscript/vue-*` component. Parallels `provideCellLocale` in
|
|
9
|
+
* `@atscript/vue-table`, which owns the table's `Intl` locale and time zone —
|
|
10
|
+
* the host wires both from a single source (e.g. `useAppPrefs`).
|
|
11
|
+
*
|
|
12
|
+
* One per app, never module-global: a server rendering for many users keeps
|
|
13
|
+
* each app's locale. Interned (`Symbol.for`): one key across module copies.
|
|
14
|
+
*/
|
|
15
|
+
const AS_LOCALE_KEY = Symbol.for("atscript.ui.locale");
|
|
16
|
+
/** The server-rendered texts the browser app starts with (`provideAsServedTexts`). */
|
|
17
|
+
const AS_SERVED_TEXTS_KEY = Symbol.for("atscript.ui.served-texts");
|
|
18
|
+
/** Where a server render's app texts are kept on the Vue SSR context. */
|
|
19
|
+
const SSR_TEXTS = Symbol.for("atscript.ui.ssr-texts");
|
|
20
|
+
/**
|
|
21
|
+
* Provides the app's locale. `getter` returns a BCP-47 locale (or
|
|
22
|
+
* `undefined` for the runtime's); reactive sources work as they are
|
|
23
|
+
* (`() => prefs.value.language`). The built-in texts follow it: the texts the
|
|
24
|
+
* server served for the locale, else English — or your own `translate`
|
|
25
|
+
* first (return `undefined` to fall back).
|
|
26
|
+
*
|
|
27
|
+
* Call it once at the app root. To switch the language of an open page,
|
|
28
|
+
* remount the view (`<RouterView :key="locale" />`). With server rendering,
|
|
29
|
+
* hand the texts the render used to the browser app: {@link getAsServedTexts}
|
|
30
|
+
* and {@link provideAsServedTexts}.
|
|
31
|
+
*/
|
|
32
|
+
function provideAsLocale(getter, translate) {
|
|
33
|
+
const ownTranslate = translate && (() => translate);
|
|
34
|
+
const ssr = typeof window === "undefined" ? (0, vue.inject)(vue.ssrContextKey, null) : null;
|
|
35
|
+
const render = ssr ? ssr[SSR_TEXTS] ??= {
|
|
36
|
+
dicts: (0, vue.shallowRef)({}),
|
|
37
|
+
unserved: /* @__PURE__ */ new Map()
|
|
38
|
+
} : null;
|
|
39
|
+
let texts = (0, _atscript_ui.createUiTexts)({
|
|
40
|
+
locale: getter,
|
|
41
|
+
translate: ownTranslate,
|
|
42
|
+
dicts: render?.dicts ?? (0, vue.shallowRef)({})
|
|
43
|
+
});
|
|
44
|
+
const seed = (0, vue.inject)(AS_SERVED_TEXTS_KEY, null);
|
|
45
|
+
if (seed) for (const [locale, dict] of Object.entries(seed)) texts.merge(locale || void 0, dict);
|
|
46
|
+
if (render) texts = pinUnserved(texts, render, ownTranslate);
|
|
47
|
+
(0, vue.provide)(AS_LOCALE_KEY, texts);
|
|
48
|
+
if (typeof window !== "undefined") (0, vue.onScopeDispose)((0, _atscript_ui.activateUiTexts)(texts));
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* `texts` for one server render, so the HTML and the hydrating browser agree
|
|
52
|
+
* everywhere: an id looked up before the server served a text for it shows
|
|
53
|
+
* the fallback (`translate`, else English) for the rest of the render — in
|
|
54
|
+
* every provider of the render — and is left out of `getAsServedTexts`.
|
|
55
|
+
*/
|
|
56
|
+
function pinUnserved(texts, render, translate) {
|
|
57
|
+
const fallback = (0, _atscript_ui.createUiTexts)({
|
|
58
|
+
locale: texts.locale,
|
|
59
|
+
translate
|
|
60
|
+
});
|
|
61
|
+
return {
|
|
62
|
+
...texts,
|
|
63
|
+
t: (id, params) => {
|
|
64
|
+
const key = texts.locale() ?? "";
|
|
65
|
+
let pinned = render.unserved.get(key);
|
|
66
|
+
if (pinned?.has(id)) return fallback.t(id, params);
|
|
67
|
+
const dict = render.dicts.value[key];
|
|
68
|
+
if (!dict || !Object.hasOwn(dict, id)) {
|
|
69
|
+
if (!pinned) render.unserved.set(key, pinned = /* @__PURE__ */ new Set());
|
|
70
|
+
pinned.add(id);
|
|
71
|
+
}
|
|
72
|
+
return texts.t(id, params);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Server side: the texts the server served while rendering this app (merged
|
|
78
|
+
* into its `provideAsLocale` texts, e.g. `/meta` `$i18n`) — pass the context
|
|
79
|
+
* object you gave `renderToString(app, ssrContext)`, after it resolves.
|
|
80
|
+
* `undefined` when nothing was served (or the app has no `provideAsLocale`).
|
|
81
|
+
* Put it into the state your server transfers to the browser and give it to
|
|
82
|
+
* {@link provideAsServedTexts} there, so the browser renders the same texts
|
|
83
|
+
* before its own requests come back.
|
|
84
|
+
*
|
|
85
|
+
* A text the render looked up before the server served it shows the fallback
|
|
86
|
+
* everywhere in that render and is left out: the hydrating browser shows the
|
|
87
|
+
* fallback too, and its own request switches it afterwards. Since 0.1.168.
|
|
88
|
+
*/
|
|
89
|
+
function getAsServedTexts(ssrContext) {
|
|
90
|
+
const render = ssrContext[SSR_TEXTS];
|
|
91
|
+
if (!render) return void 0;
|
|
92
|
+
let out;
|
|
93
|
+
for (const [locale, dict] of Object.entries(render.dicts.value)) {
|
|
94
|
+
const skip = render.unserved.get(locale);
|
|
95
|
+
for (const [id, text] of Object.entries(dict)) {
|
|
96
|
+
if (skip?.has(id)) continue;
|
|
97
|
+
((out ??= {})[locale] ??= {})[id] = text;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return out;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Browser side: the texts the server render used ({@link getAsServedTexts}),
|
|
104
|
+
* merged into the app's texts when `provideAsLocale` creates them — call it
|
|
105
|
+
* before `app.mount()`. Nothing to merge (`undefined`) is fine. Since 0.1.168.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```ts
|
|
109
|
+
* const { app } = createApp();
|
|
110
|
+
* provideAsServedTexts(app, window.__SSR_STATE__?.asTexts);
|
|
111
|
+
* app.mount("#app");
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
function provideAsServedTexts(app, served) {
|
|
115
|
+
if (served) app.provide(AS_SERVED_TEXTS_KEY, served);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* The app's UI texts when a `provideAsLocale` is above the caller, else `null`.
|
|
119
|
+
*
|
|
120
|
+
* @internal Shared with `@atscript/vue-table`.
|
|
121
|
+
*/
|
|
122
|
+
function injectAsTexts() {
|
|
123
|
+
return (0, vue.hasInjectionContext)() ? (0, vue.inject)(AS_LOCALE_KEY, null) : null;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* The app's UI texts (`provideAsLocale`), else the global ones
|
|
127
|
+
* (`setUiLocale`). One `inject` — cheap enough for per-row components.
|
|
128
|
+
*
|
|
129
|
+
* @internal Shared with `@atscript/vue-table` and `@atscript/vue-wf`.
|
|
130
|
+
*/
|
|
131
|
+
function useAsTexts() {
|
|
132
|
+
return injectAsTexts() ?? (0, _atscript_ui.getUiTexts)();
|
|
133
|
+
}
|
|
134
|
+
function useAsLocale() {
|
|
135
|
+
const provided = injectAsTexts();
|
|
136
|
+
const texts = provided ?? (0, _atscript_ui.getUiTexts)();
|
|
137
|
+
return {
|
|
138
|
+
locale: (0, vue.computed)(() => provided?.locale()),
|
|
139
|
+
t: texts.t
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* The app's current UI locale as a ref: follows a `provideAsLocale` getter
|
|
144
|
+
* and `setUiLocale` (which is not reactive) — for a `:key` that rebuilds a
|
|
145
|
+
* view, or a watch that re-binds one, when the locale changes.
|
|
146
|
+
*
|
|
147
|
+
* @internal Shared with `@atscript/vue-table`.
|
|
148
|
+
*/
|
|
149
|
+
function useUiLocaleKey(texts) {
|
|
150
|
+
const key = (0, vue.shallowRef)(texts.locale());
|
|
151
|
+
const sync = () => {
|
|
152
|
+
key.value = texts.locale();
|
|
153
|
+
};
|
|
154
|
+
(0, vue.watch)(() => texts.locale(), sync);
|
|
155
|
+
if (typeof window !== "undefined" && (0, vue.getCurrentScope)()) (0, vue.onScopeDispose)((0, _atscript_ui.onUiLocaleChange)(sync));
|
|
156
|
+
return key;
|
|
157
|
+
}
|
|
158
|
+
//#endregion
|
|
159
|
+
Object.defineProperty(exports, "getAsServedTexts", {
|
|
160
|
+
enumerable: true,
|
|
161
|
+
get: function() {
|
|
162
|
+
return getAsServedTexts;
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
Object.defineProperty(exports, "injectAsTexts", {
|
|
166
|
+
enumerable: true,
|
|
167
|
+
get: function() {
|
|
168
|
+
return injectAsTexts;
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
Object.defineProperty(exports, "provideAsLocale", {
|
|
172
|
+
enumerable: true,
|
|
173
|
+
get: function() {
|
|
174
|
+
return provideAsLocale;
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
Object.defineProperty(exports, "provideAsServedTexts", {
|
|
178
|
+
enumerable: true,
|
|
179
|
+
get: function() {
|
|
180
|
+
return provideAsServedTexts;
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
Object.defineProperty(exports, "useAsLocale", {
|
|
184
|
+
enumerable: true,
|
|
185
|
+
get: function() {
|
|
186
|
+
return useAsLocale;
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
Object.defineProperty(exports, "useAsTexts", {
|
|
190
|
+
enumerable: true,
|
|
191
|
+
get: function() {
|
|
192
|
+
return useAsTexts;
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
Object.defineProperty(exports, "useUiLocaleKey", {
|
|
196
|
+
enumerable: true,
|
|
197
|
+
get: function() {
|
|
198
|
+
return useUiLocaleKey;
|
|
199
|
+
}
|
|
200
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { o as useAsTexts, s as useUiLocaleKey } from "./use-as-locale-CbpIkjCt.mjs";
|
|
2
2
|
import { computed, getCurrentScope, inject, onMounted, onScopeDispose, onUnmounted, ref, shallowRef, watch } from "vue";
|
|
3
3
|
import { ValueHelpClient, getMetaEntry, resolveValueHelp, retainMetaEntry } from "@atscript/ui";
|
|
4
4
|
//#region src/composables/use-as-value-help.ts
|
|
@@ -9,9 +9,23 @@ function useAsValueHelp(options) {
|
|
|
9
9
|
const { info, model, onBlur } = options;
|
|
10
10
|
const injectedFactory = inject(CLIENT_FACTORY_KEY, null) ?? void 0;
|
|
11
11
|
const texts = useAsTexts();
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
const scoped = !!getCurrentScope();
|
|
13
|
+
const browser = typeof window !== "undefined";
|
|
14
|
+
let release;
|
|
15
|
+
let vhClient;
|
|
16
|
+
/**
|
|
17
|
+
* Binds the entry of the app's current locale — held while mounted, so
|
|
18
|
+
* `kickoff`'s `resolveValueHelp` finds it (and its client).
|
|
19
|
+
*/
|
|
20
|
+
function bindEntry() {
|
|
21
|
+
const entry = getMetaEntry(info.url, injectedFactory, { texts });
|
|
22
|
+
const previous = release;
|
|
23
|
+
release = scoped ? retainMetaEntry(entry) : void 0;
|
|
24
|
+
previous?.();
|
|
25
|
+
vhClient = new ValueHelpClient(entry.client);
|
|
26
|
+
}
|
|
27
|
+
if (browser) bindEntry();
|
|
28
|
+
if (scoped) onScopeDispose(() => release?.());
|
|
15
29
|
const resolved = shallowRef(null);
|
|
16
30
|
const status = ref("loading");
|
|
17
31
|
const searchText = ref("");
|
|
@@ -20,20 +34,39 @@ function useAsValueHelp(options) {
|
|
|
20
34
|
const labelIsFkValue = computed(() => !!resolved.value && info.targetField === resolved.value.labelField);
|
|
21
35
|
let debounceTimer;
|
|
22
36
|
let kickoffPromise;
|
|
37
|
+
/** Bumped per kickoff: a superseded one (a previous locale's) never lands. */
|
|
38
|
+
let kickoffSeq = 0;
|
|
23
39
|
let lastSearchedText;
|
|
40
|
+
/** Bumped per search: a superseded one (an older text or locale) never lands. */
|
|
41
|
+
let searchSeq = 0;
|
|
24
42
|
onUnmounted(() => {
|
|
25
43
|
if (debounceTimer !== void 0) clearTimeout(debounceTimer);
|
|
26
44
|
});
|
|
27
45
|
async function kickoff() {
|
|
28
46
|
if (kickoffPromise) return kickoffPromise;
|
|
29
|
-
|
|
47
|
+
const mine = ++kickoffSeq;
|
|
48
|
+
kickoffPromise = resolveValueHelp(info.url, {
|
|
49
|
+
texts,
|
|
50
|
+
clientFactory: injectedFactory
|
|
51
|
+
}).then((r) => {
|
|
52
|
+
if (mine !== kickoffSeq) return;
|
|
30
53
|
resolved.value = r;
|
|
31
54
|
status.value = "ready";
|
|
32
55
|
}).catch(() => {
|
|
33
|
-
status.value = "error";
|
|
56
|
+
if (mine === kickoffSeq) status.value = "error";
|
|
34
57
|
});
|
|
35
58
|
return kickoffPromise;
|
|
36
59
|
}
|
|
60
|
+
function followLocale() {
|
|
61
|
+
if (!browser) return;
|
|
62
|
+
bindEntry();
|
|
63
|
+
lastSearchedText = void 0;
|
|
64
|
+
searchSeq++;
|
|
65
|
+
if (!kickoffPromise) return;
|
|
66
|
+
kickoffPromise = void 0;
|
|
67
|
+
kickoff();
|
|
68
|
+
}
|
|
69
|
+
watch(useUiLocaleKey(texts), followLocale, { flush: "sync" });
|
|
37
70
|
function scheduleSearch(text) {
|
|
38
71
|
if (debounceTimer !== void 0) clearTimeout(debounceTimer);
|
|
39
72
|
debounceTimer = setTimeout(() => {
|
|
@@ -42,22 +75,24 @@ function useAsValueHelp(options) {
|
|
|
42
75
|
}
|
|
43
76
|
async function doSearch(text) {
|
|
44
77
|
const r = resolved.value;
|
|
45
|
-
if (!r) return;
|
|
78
|
+
if (!r || !vhClient) return;
|
|
46
79
|
if (text === lastSearchedText) return;
|
|
47
80
|
lastSearchedText = text;
|
|
81
|
+
const mine = ++searchSeq;
|
|
48
82
|
searching.value = true;
|
|
49
83
|
try {
|
|
50
|
-
|
|
84
|
+
const result = await vhClient.search(r, {
|
|
51
85
|
text: text || void 0,
|
|
52
86
|
mode: "form",
|
|
53
87
|
limit: 20,
|
|
54
88
|
filter: info.filter,
|
|
55
89
|
valueField: info.targetField
|
|
56
|
-
})
|
|
90
|
+
});
|
|
91
|
+
if (mine === searchSeq) results.value = result.items;
|
|
57
92
|
} catch {
|
|
58
|
-
results.value = [];
|
|
93
|
+
if (mine === searchSeq) results.value = [];
|
|
59
94
|
} finally {
|
|
60
|
-
searching.value = false;
|
|
95
|
+
if (mine === searchSeq) searching.value = false;
|
|
61
96
|
}
|
|
62
97
|
}
|
|
63
98
|
watch(searchText, (text) => {
|
|
@@ -77,7 +112,9 @@ function useAsValueHelp(options) {
|
|
|
77
112
|
model.value = void 0;
|
|
78
113
|
searchText.value = "";
|
|
79
114
|
results.value = [];
|
|
115
|
+
searching.value = false;
|
|
80
116
|
lastSearchedText = void 0;
|
|
117
|
+
searchSeq++;
|
|
81
118
|
}
|
|
82
119
|
return {
|
|
83
120
|
resolved,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_use_as_locale = require("./use-as-locale-
|
|
1
|
+
const require_use_as_locale = require("./use-as-locale-x8f0eN6K.cjs");
|
|
2
2
|
let vue = require("vue");
|
|
3
3
|
let _atscript_ui = require("@atscript/ui");
|
|
4
4
|
//#region src/composables/use-as-value-help.ts
|
|
@@ -9,9 +9,23 @@ function useAsValueHelp(options) {
|
|
|
9
9
|
const { info, model, onBlur } = options;
|
|
10
10
|
const injectedFactory = (0, vue.inject)(CLIENT_FACTORY_KEY, null) ?? void 0;
|
|
11
11
|
const texts = require_use_as_locale.useAsTexts();
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
const scoped = !!(0, vue.getCurrentScope)();
|
|
13
|
+
const browser = typeof window !== "undefined";
|
|
14
|
+
let release;
|
|
15
|
+
let vhClient;
|
|
16
|
+
/**
|
|
17
|
+
* Binds the entry of the app's current locale — held while mounted, so
|
|
18
|
+
* `kickoff`'s `resolveValueHelp` finds it (and its client).
|
|
19
|
+
*/
|
|
20
|
+
function bindEntry() {
|
|
21
|
+
const entry = (0, _atscript_ui.getMetaEntry)(info.url, injectedFactory, { texts });
|
|
22
|
+
const previous = release;
|
|
23
|
+
release = scoped ? (0, _atscript_ui.retainMetaEntry)(entry) : void 0;
|
|
24
|
+
previous?.();
|
|
25
|
+
vhClient = new _atscript_ui.ValueHelpClient(entry.client);
|
|
26
|
+
}
|
|
27
|
+
if (browser) bindEntry();
|
|
28
|
+
if (scoped) (0, vue.onScopeDispose)(() => release?.());
|
|
15
29
|
const resolved = (0, vue.shallowRef)(null);
|
|
16
30
|
const status = (0, vue.ref)("loading");
|
|
17
31
|
const searchText = (0, vue.ref)("");
|
|
@@ -20,20 +34,39 @@ function useAsValueHelp(options) {
|
|
|
20
34
|
const labelIsFkValue = (0, vue.computed)(() => !!resolved.value && info.targetField === resolved.value.labelField);
|
|
21
35
|
let debounceTimer;
|
|
22
36
|
let kickoffPromise;
|
|
37
|
+
/** Bumped per kickoff: a superseded one (a previous locale's) never lands. */
|
|
38
|
+
let kickoffSeq = 0;
|
|
23
39
|
let lastSearchedText;
|
|
40
|
+
/** Bumped per search: a superseded one (an older text or locale) never lands. */
|
|
41
|
+
let searchSeq = 0;
|
|
24
42
|
(0, vue.onUnmounted)(() => {
|
|
25
43
|
if (debounceTimer !== void 0) clearTimeout(debounceTimer);
|
|
26
44
|
});
|
|
27
45
|
async function kickoff() {
|
|
28
46
|
if (kickoffPromise) return kickoffPromise;
|
|
29
|
-
|
|
47
|
+
const mine = ++kickoffSeq;
|
|
48
|
+
kickoffPromise = (0, _atscript_ui.resolveValueHelp)(info.url, {
|
|
49
|
+
texts,
|
|
50
|
+
clientFactory: injectedFactory
|
|
51
|
+
}).then((r) => {
|
|
52
|
+
if (mine !== kickoffSeq) return;
|
|
30
53
|
resolved.value = r;
|
|
31
54
|
status.value = "ready";
|
|
32
55
|
}).catch(() => {
|
|
33
|
-
status.value = "error";
|
|
56
|
+
if (mine === kickoffSeq) status.value = "error";
|
|
34
57
|
});
|
|
35
58
|
return kickoffPromise;
|
|
36
59
|
}
|
|
60
|
+
function followLocale() {
|
|
61
|
+
if (!browser) return;
|
|
62
|
+
bindEntry();
|
|
63
|
+
lastSearchedText = void 0;
|
|
64
|
+
searchSeq++;
|
|
65
|
+
if (!kickoffPromise) return;
|
|
66
|
+
kickoffPromise = void 0;
|
|
67
|
+
kickoff();
|
|
68
|
+
}
|
|
69
|
+
(0, vue.watch)(require_use_as_locale.useUiLocaleKey(texts), followLocale, { flush: "sync" });
|
|
37
70
|
function scheduleSearch(text) {
|
|
38
71
|
if (debounceTimer !== void 0) clearTimeout(debounceTimer);
|
|
39
72
|
debounceTimer = setTimeout(() => {
|
|
@@ -42,22 +75,24 @@ function useAsValueHelp(options) {
|
|
|
42
75
|
}
|
|
43
76
|
async function doSearch(text) {
|
|
44
77
|
const r = resolved.value;
|
|
45
|
-
if (!r) return;
|
|
78
|
+
if (!r || !vhClient) return;
|
|
46
79
|
if (text === lastSearchedText) return;
|
|
47
80
|
lastSearchedText = text;
|
|
81
|
+
const mine = ++searchSeq;
|
|
48
82
|
searching.value = true;
|
|
49
83
|
try {
|
|
50
|
-
|
|
84
|
+
const result = await vhClient.search(r, {
|
|
51
85
|
text: text || void 0,
|
|
52
86
|
mode: "form",
|
|
53
87
|
limit: 20,
|
|
54
88
|
filter: info.filter,
|
|
55
89
|
valueField: info.targetField
|
|
56
|
-
})
|
|
90
|
+
});
|
|
91
|
+
if (mine === searchSeq) results.value = result.items;
|
|
57
92
|
} catch {
|
|
58
|
-
results.value = [];
|
|
93
|
+
if (mine === searchSeq) results.value = [];
|
|
59
94
|
} finally {
|
|
60
|
-
searching.value = false;
|
|
95
|
+
if (mine === searchSeq) searching.value = false;
|
|
61
96
|
}
|
|
62
97
|
}
|
|
63
98
|
(0, vue.watch)(searchText, (text) => {
|
|
@@ -77,7 +112,9 @@ function useAsValueHelp(options) {
|
|
|
77
112
|
model.value = void 0;
|
|
78
113
|
searchText.value = "";
|
|
79
114
|
results.value = [];
|
|
115
|
+
searching.value = false;
|
|
80
116
|
lastSearchedText = void 0;
|
|
117
|
+
searchSeq++;
|
|
81
118
|
}
|
|
82
119
|
return {
|
|
83
120
|
resolved,
|