@atscript/vue-form 0.1.167 → 0.1.169
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-BL-R84j8.d.mts → as-form.vue-BMDYhMWh.d.mts} +7 -1
- package/dist/{as-form.vue-B_nSx3Ta.d.cts → as-form.vue-CyTLtPvG.d.cts} +7 -1
- 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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { o as useAsTexts } from "./use-as-locale-CbpIkjCt.mjs";
|
|
2
2
|
import { computed, inject, provide } from "vue";
|
|
3
3
|
import { getByPath, joinPath, setByPath } from "@atscript/ui";
|
|
4
4
|
//#region src/composables/internal-keys.ts
|
|
@@ -25,6 +25,7 @@ const CHANGE_HANDLER_KEY = Symbol("atui.change-handler");
|
|
|
25
25
|
const DISMISS_EXTERNAL_AT_KEY = Symbol("atui.dismiss-external-at");
|
|
26
26
|
const UNION_CONTEXT_KEY = Symbol("atui.union-context");
|
|
27
27
|
const FORM_PATCH_KEY = Symbol("atui.form-patch");
|
|
28
|
+
const FORM_NORMALIZED_DATA_KEY = Symbol("atui.form-normalized-data");
|
|
28
29
|
//#endregion
|
|
29
30
|
//#region src/composables/use-form-context.ts
|
|
30
31
|
const EMPTY_PREFIX = computed(() => "");
|
|
@@ -102,4 +103,4 @@ function formatIndexedLabelParts(label, arrayIndex) {
|
|
|
102
103
|
};
|
|
103
104
|
}
|
|
104
105
|
//#endregion
|
|
105
|
-
export {
|
|
106
|
+
export { ROOT_DATA_KEY as _, CHANGE_HANDLER_KEY as a, ERRORS_KEY as c, FORM_NORMALIZED_DATA_KEY as d, FORM_PATCH_KEY as f, PATH_PREFIX_KEY as g, LEVEL_KEY as h, ACTION_HANDLER_KEY as i, FORM_CONTEXT_KEY as l, HIDE_ROOT_TITLE_KEY as m, useAsUnionVariant as n, COMPONENTS_KEY as o, FORM_STATE_KEY as p, useFormContext as r, DISMISS_EXTERNAL_AT_KEY as s, formatIndexedLabelParts as t, FORM_DATA_KEY as u, TYPES_KEY as v, UNION_CONTEXT_KEY as y };
|
|
@@ -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/internal-keys.ts
|
|
@@ -25,6 +25,7 @@ const CHANGE_HANDLER_KEY = Symbol("atui.change-handler");
|
|
|
25
25
|
const DISMISS_EXTERNAL_AT_KEY = Symbol("atui.dismiss-external-at");
|
|
26
26
|
const UNION_CONTEXT_KEY = Symbol("atui.union-context");
|
|
27
27
|
const FORM_PATCH_KEY = Symbol("atui.form-patch");
|
|
28
|
+
const FORM_NORMALIZED_DATA_KEY = Symbol("atui.form-normalized-data");
|
|
28
29
|
//#endregion
|
|
29
30
|
//#region src/composables/use-form-context.ts
|
|
30
31
|
const EMPTY_PREFIX = (0, vue.computed)(() => "");
|
|
@@ -144,6 +145,12 @@ Object.defineProperty(exports, "FORM_DATA_KEY", {
|
|
|
144
145
|
return FORM_DATA_KEY;
|
|
145
146
|
}
|
|
146
147
|
});
|
|
148
|
+
Object.defineProperty(exports, "FORM_NORMALIZED_DATA_KEY", {
|
|
149
|
+
enumerable: true,
|
|
150
|
+
get: function() {
|
|
151
|
+
return FORM_NORMALIZED_DATA_KEY;
|
|
152
|
+
}
|
|
153
|
+
});
|
|
147
154
|
Object.defineProperty(exports, "FORM_PATCH_KEY", {
|
|
148
155
|
enumerable: true,
|
|
149
156
|
get: function() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atscript/vue-form",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.169",
|
|
4
4
|
"description": "Type-driven form rendering for Atscript with Vue 3",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"atscript",
|
|
@@ -165,27 +165,27 @@
|
|
|
165
165
|
"access": "public"
|
|
166
166
|
},
|
|
167
167
|
"dependencies": {
|
|
168
|
-
"@atscript/ui": "^0.1.
|
|
169
|
-
"@atscript/ui-fns": "^0.1.
|
|
168
|
+
"@atscript/ui": "^0.1.169",
|
|
169
|
+
"@atscript/ui-fns": "^0.1.169"
|
|
170
170
|
},
|
|
171
171
|
"devDependencies": {
|
|
172
|
-
"@atscript/core": "^0.2.
|
|
173
|
-
"@atscript/db-client": "^0.1.
|
|
174
|
-
"@atscript/typescript": "^0.2.
|
|
172
|
+
"@atscript/core": "^0.2.9",
|
|
173
|
+
"@atscript/db-client": "^0.1.174",
|
|
174
|
+
"@atscript/typescript": "^0.2.9",
|
|
175
175
|
"@tsdown/css": "^0.21.4",
|
|
176
176
|
"@vitejs/plugin-vue": "^6",
|
|
177
177
|
"@vue/test-utils": "^2",
|
|
178
178
|
"happy-dom": "^18",
|
|
179
179
|
"reka-ui": "^2.9.8",
|
|
180
|
-
"unplugin-atscript": "^0.2.
|
|
180
|
+
"unplugin-atscript": "^0.2.9",
|
|
181
181
|
"vitest": "npm:@voidzero-dev/vite-plus-test@0.1.14",
|
|
182
182
|
"vue": "^3",
|
|
183
183
|
"vue-tsc": "~3.2.9",
|
|
184
184
|
"vunor": "^0.4.1"
|
|
185
185
|
},
|
|
186
186
|
"peerDependencies": {
|
|
187
|
-
"@atscript/db-client": "^0.1.
|
|
188
|
-
"@atscript/typescript": "^0.2.
|
|
187
|
+
"@atscript/db-client": "^0.1.174",
|
|
188
|
+
"@atscript/typescript": "^0.2.9",
|
|
189
189
|
"reka-ui": "^2.9.8",
|
|
190
190
|
"vue": "^3"
|
|
191
191
|
},
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { computed, hasInjectionContext, inject, onScopeDispose, provide, shallowRef } from "vue";
|
|
2
|
-
import { activateUiTexts, createUiTexts, getUiTexts } 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
|
-
/**
|
|
17
|
-
* Provides the app's locale. `getter` returns a BCP-47 locale (or
|
|
18
|
-
* `undefined` for the runtime's); reactive sources work as they are
|
|
19
|
-
* (`() => prefs.value.language`). The built-in texts follow it: the texts the
|
|
20
|
-
* server served for the locale, else English — or your own `translate`
|
|
21
|
-
* first (return `undefined` to fall back).
|
|
22
|
-
*
|
|
23
|
-
* Call it once at the app root. To switch the language of an open page,
|
|
24
|
-
* remount the view (`<RouterView :key="locale" />`).
|
|
25
|
-
*/
|
|
26
|
-
function provideAsLocale(getter, translate) {
|
|
27
|
-
const texts = createUiTexts({
|
|
28
|
-
locale: getter,
|
|
29
|
-
translate: translate && (() => translate),
|
|
30
|
-
dicts: shallowRef({})
|
|
31
|
-
});
|
|
32
|
-
provide(AS_LOCALE_KEY, texts);
|
|
33
|
-
if (typeof window !== "undefined") onScopeDispose(activateUiTexts(texts));
|
|
34
|
-
}
|
|
35
|
-
function injectTexts() {
|
|
36
|
-
return hasInjectionContext() ? inject(AS_LOCALE_KEY, null) : null;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* The app's UI texts (`provideAsLocale`), else the global ones
|
|
40
|
-
* (`setUiLocale`). One `inject` — cheap enough for per-row components.
|
|
41
|
-
*
|
|
42
|
-
* @internal Shared with `@atscript/vue-table` and `@atscript/vue-wf`.
|
|
43
|
-
*/
|
|
44
|
-
function useAsTexts() {
|
|
45
|
-
return injectTexts() ?? getUiTexts();
|
|
46
|
-
}
|
|
47
|
-
function useAsLocale() {
|
|
48
|
-
const provided = injectTexts();
|
|
49
|
-
const texts = provided ?? getUiTexts();
|
|
50
|
-
return {
|
|
51
|
-
locale: computed(() => provided?.locale()),
|
|
52
|
-
t: texts.t
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
//#endregion
|
|
56
|
-
export { useAsLocale as n, useAsTexts as r, provideAsLocale as t };
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { ComputedRef } from "vue";
|
|
2
|
-
import { UiT, UiTexts, UiTranslate } from "@atscript/ui";
|
|
3
|
-
|
|
4
|
-
//#region src/composables/use-as-locale.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* Provides the app's locale. `getter` returns a BCP-47 locale (or
|
|
7
|
-
* `undefined` for the runtime's); reactive sources work as they are
|
|
8
|
-
* (`() => prefs.value.language`). The built-in texts follow it: the texts the
|
|
9
|
-
* server served for the locale, else English — or your own `translate`
|
|
10
|
-
* first (return `undefined` to fall back).
|
|
11
|
-
*
|
|
12
|
-
* Call it once at the app root. To switch the language of an open page,
|
|
13
|
-
* remount the view (`<RouterView :key="locale" />`).
|
|
14
|
-
*/
|
|
15
|
-
declare function provideAsLocale(getter: () => string | undefined, translate?: UiTranslate): void;
|
|
16
|
-
interface UseAsLocaleReturn {
|
|
17
|
-
/** Resolved locale; `undefined` when no provider is present (runtime locale). */
|
|
18
|
-
locale: ComputedRef<string | undefined>;
|
|
19
|
-
/**
|
|
20
|
-
* A built-in UI text in the app's locale — `t("UI_CANCEL")`,
|
|
21
|
-
* `t("UI_FORM_ADD", { item: "address" })`. The codes and their English
|
|
22
|
-
* texts are `AS_UI_MESSAGES` (`@atscript/ui/messages`).
|
|
23
|
-
*/
|
|
24
|
-
t: UiT;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* The app's UI texts (`provideAsLocale`), else the global ones
|
|
28
|
-
* (`setUiLocale`). One `inject` — cheap enough for per-row components.
|
|
29
|
-
*
|
|
30
|
-
* @internal Shared with `@atscript/vue-table` and `@atscript/vue-wf`.
|
|
31
|
-
*/
|
|
32
|
-
declare function useAsTexts(): UiTexts;
|
|
33
|
-
declare function useAsLocale(): UseAsLocaleReturn;
|
|
34
|
-
//#endregion
|
|
35
|
-
export { useAsTexts as i, provideAsLocale as n, useAsLocale as r, UseAsLocaleReturn as t };
|
|
@@ -1,73 +0,0 @@
|
|
|
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
|
-
/**
|
|
17
|
-
* Provides the app's locale. `getter` returns a BCP-47 locale (or
|
|
18
|
-
* `undefined` for the runtime's); reactive sources work as they are
|
|
19
|
-
* (`() => prefs.value.language`). The built-in texts follow it: the texts the
|
|
20
|
-
* server served for the locale, else English — or your own `translate`
|
|
21
|
-
* first (return `undefined` to fall back).
|
|
22
|
-
*
|
|
23
|
-
* Call it once at the app root. To switch the language of an open page,
|
|
24
|
-
* remount the view (`<RouterView :key="locale" />`).
|
|
25
|
-
*/
|
|
26
|
-
function provideAsLocale(getter, translate) {
|
|
27
|
-
const texts = (0, _atscript_ui.createUiTexts)({
|
|
28
|
-
locale: getter,
|
|
29
|
-
translate: translate && (() => translate),
|
|
30
|
-
dicts: (0, vue.shallowRef)({})
|
|
31
|
-
});
|
|
32
|
-
(0, vue.provide)(AS_LOCALE_KEY, texts);
|
|
33
|
-
if (typeof window !== "undefined") (0, vue.onScopeDispose)((0, _atscript_ui.activateUiTexts)(texts));
|
|
34
|
-
}
|
|
35
|
-
function injectTexts() {
|
|
36
|
-
return (0, vue.hasInjectionContext)() ? (0, vue.inject)(AS_LOCALE_KEY, null) : null;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* The app's UI texts (`provideAsLocale`), else the global ones
|
|
40
|
-
* (`setUiLocale`). One `inject` — cheap enough for per-row components.
|
|
41
|
-
*
|
|
42
|
-
* @internal Shared with `@atscript/vue-table` and `@atscript/vue-wf`.
|
|
43
|
-
*/
|
|
44
|
-
function useAsTexts() {
|
|
45
|
-
return injectTexts() ?? (0, _atscript_ui.getUiTexts)();
|
|
46
|
-
}
|
|
47
|
-
function useAsLocale() {
|
|
48
|
-
const provided = injectTexts();
|
|
49
|
-
const texts = provided ?? (0, _atscript_ui.getUiTexts)();
|
|
50
|
-
return {
|
|
51
|
-
locale: (0, vue.computed)(() => provided?.locale()),
|
|
52
|
-
t: texts.t
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
//#endregion
|
|
56
|
-
Object.defineProperty(exports, "provideAsLocale", {
|
|
57
|
-
enumerable: true,
|
|
58
|
-
get: function() {
|
|
59
|
-
return provideAsLocale;
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
Object.defineProperty(exports, "useAsLocale", {
|
|
63
|
-
enumerable: true,
|
|
64
|
-
get: function() {
|
|
65
|
-
return useAsLocale;
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
Object.defineProperty(exports, "useAsTexts", {
|
|
69
|
-
enumerable: true,
|
|
70
|
-
get: function() {
|
|
71
|
-
return useAsTexts;
|
|
72
|
-
}
|
|
73
|
-
});
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { ComputedRef } from "vue";
|
|
2
|
-
import { UiT, UiTexts, UiTranslate } from "@atscript/ui";
|
|
3
|
-
|
|
4
|
-
//#region src/composables/use-as-locale.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* Provides the app's locale. `getter` returns a BCP-47 locale (or
|
|
7
|
-
* `undefined` for the runtime's); reactive sources work as they are
|
|
8
|
-
* (`() => prefs.value.language`). The built-in texts follow it: the texts the
|
|
9
|
-
* server served for the locale, else English — or your own `translate`
|
|
10
|
-
* first (return `undefined` to fall back).
|
|
11
|
-
*
|
|
12
|
-
* Call it once at the app root. To switch the language of an open page,
|
|
13
|
-
* remount the view (`<RouterView :key="locale" />`).
|
|
14
|
-
*/
|
|
15
|
-
declare function provideAsLocale(getter: () => string | undefined, translate?: UiTranslate): void;
|
|
16
|
-
interface UseAsLocaleReturn {
|
|
17
|
-
/** Resolved locale; `undefined` when no provider is present (runtime locale). */
|
|
18
|
-
locale: ComputedRef<string | undefined>;
|
|
19
|
-
/**
|
|
20
|
-
* A built-in UI text in the app's locale — `t("UI_CANCEL")`,
|
|
21
|
-
* `t("UI_FORM_ADD", { item: "address" })`. The codes and their English
|
|
22
|
-
* texts are `AS_UI_MESSAGES` (`@atscript/ui/messages`).
|
|
23
|
-
*/
|
|
24
|
-
t: UiT;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* The app's UI texts (`provideAsLocale`), else the global ones
|
|
28
|
-
* (`setUiLocale`). One `inject` — cheap enough for per-row components.
|
|
29
|
-
*
|
|
30
|
-
* @internal Shared with `@atscript/vue-table` and `@atscript/vue-wf`.
|
|
31
|
-
*/
|
|
32
|
-
declare function useAsTexts(): UiTexts;
|
|
33
|
-
declare function useAsLocale(): UseAsLocaleReturn;
|
|
34
|
-
//#endregion
|
|
35
|
-
export { useAsTexts as i, provideAsLocale as n, useAsLocale as r, UseAsLocaleReturn as t };
|