@atscript/vue-form 0.1.163 → 0.1.165
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-action.d.cts +1 -1
- package/dist/as-action.d.mts +1 -1
- package/dist/{as-action.vue-wcB6Dkpu.d.cts → as-action.vue-CYGG4gUQ.d.mts} +1 -1
- package/dist/{as-action.vue-yDKx8hC0.d.mts → as-action.vue-Cp9Q8a-6.d.cts} +1 -1
- package/dist/{as-array-CD_Z7lZV.mjs → as-array-B2axGw3v.mjs} +15 -12
- package/dist/{as-array-CX52_z_L.cjs → as-array-C97cLzdA.cjs} +16 -13
- package/dist/{as-array-clear-btn-COfRUzeb.cjs → as-array-clear-btn-BBFccQjO.cjs} +5 -3
- package/dist/{as-array-clear-btn-BY1IBwBP.mjs → as-array-clear-btn-DEH8a3_N.mjs} +6 -4
- package/dist/as-array.cjs +1 -1
- package/dist/as-array.d.cts +1 -1
- package/dist/as-array.d.mts +1 -1
- package/dist/as-array.mjs +1 -1
- package/dist/{as-array.vue-BoKbyO1a.d.cts → as-array.vue-Cgfjz2I-.d.cts} +1 -1
- package/dist/{as-array.vue-DKcxkmjP.d.mts → as-array.vue-Wj9giGdu.d.mts} +1 -1
- package/dist/{as-checkbox-DosdhEuS.mjs → as-checkbox-BO8xW0OM.mjs} +36 -12
- package/dist/{as-checkbox-QO5Oh13K.cjs → as-checkbox-Wn-PmHi-.cjs} +35 -11
- package/dist/as-checkbox.cjs +1 -1
- package/dist/as-checkbox.d.cts +1 -1
- package/dist/as-checkbox.d.mts +1 -1
- package/dist/as-checkbox.mjs +1 -1
- package/dist/{as-checkbox.vue-BXS5v6Ru.d.mts → as-checkbox.vue-CWe73b3Z.d.mts} +1 -1
- package/dist/{as-checkbox.vue-DdttMJAS.d.cts → as-checkbox.vue-CXiUHIZj.d.cts} +1 -1
- package/dist/{as-collapsible-CQyuXwj9.cjs → as-collapsible-BGeuF2Bn.cjs} +4 -2
- package/dist/{as-collapsible-DHSlSMfY.mjs → as-collapsible-Cb9SgJh9.mjs} +5 -3
- package/dist/as-collapsible.cjs +1 -1
- package/dist/as-collapsible.d.cts +1 -1
- package/dist/as-collapsible.d.mts +1 -1
- package/dist/as-collapsible.mjs +1 -1
- package/dist/{as-collapsible.vue-1JSWgRMg.d.cts → as-collapsible.vue-BXwe24OV.d.cts} +1 -1
- package/dist/{as-collapsible.vue-DowxhNde.d.mts → as-collapsible.vue-hfAqxx1w.d.mts} +1 -1
- package/dist/{as-date-DTUQP2Dc.cjs → as-date-B2dgUoau.cjs} +1 -1
- package/dist/{as-date-DyQsn7Mu.mjs → as-date-jQpwe6sr.mjs} +1 -1
- package/dist/as-date.cjs +1 -1
- package/dist/as-date.d.cts +1 -1
- package/dist/as-date.d.mts +1 -1
- package/dist/as-date.mjs +1 -1
- package/dist/{as-date.vue-BVvALvZ_.d.mts → as-date.vue-BTm9X4fW.d.mts} +1 -1
- package/dist/{as-date.vue-BiUgcOwZ.d.cts → as-date.vue-axahL_Zv.d.cts} +1 -1
- package/dist/{as-datetime-BDJtlZLz.cjs → as-datetime-CmBLyjgU.cjs} +1 -1
- package/dist/{as-datetime-CrstxtPJ.mjs → as-datetime-DYn9NndT.mjs} +1 -1
- package/dist/as-datetime.cjs +1 -1
- package/dist/as-datetime.d.cts +1 -1
- package/dist/as-datetime.d.mts +1 -1
- package/dist/as-datetime.mjs +1 -1
- package/dist/{as-datetime.vue-BVc6jcUI.d.cts → as-datetime.vue-C6ILTI-7.d.cts} +1 -1
- package/dist/{as-datetime.vue-CCQqZsKA.d.mts → as-datetime.vue-vysHc3Ug.d.mts} +1 -1
- package/dist/{as-decimal-Bimpnzo2.mjs → as-decimal-C-OJ8ygU.mjs} +4 -3
- package/dist/{as-decimal-BZWqiKXZ.cjs → as-decimal-C0Eqd9nM.cjs} +4 -3
- package/dist/as-decimal.cjs +1 -1
- package/dist/as-decimal.d.cts +1 -1
- package/dist/as-decimal.d.mts +1 -1
- package/dist/as-decimal.mjs +1 -1
- package/dist/{as-decimal.vue-BDfM2ICc.d.mts → as-decimal.vue-CAq25zbX.d.mts} +1 -1
- package/dist/{as-decimal.vue-Cc9pNTqj.d.cts → as-decimal.vue-Dgfz9UDJ.d.cts} +1 -1
- package/dist/{as-field-DqK4Yiev.mjs → as-field-BZpWLPcM.mjs} +32 -16
- package/dist/{as-field-C_DB6Lbi.cjs → as-field-D0HgywQY.cjs} +31 -15
- package/dist/{as-field-shell-Bxqa_ZsU.mjs → as-field-shell-D7XovzgJ.mjs} +14 -7
- package/dist/{as-field-shell-BrJpCzIA.cjs → as-field-shell-DSj3CqN6.cjs} +14 -7
- package/dist/as-field-shell.cjs +1 -1
- package/dist/as-field-shell.d.cts +1 -1
- package/dist/as-field-shell.d.mts +1 -1
- package/dist/as-field-shell.mjs +1 -1
- package/dist/{as-field-shell.vue-B1ep312_.d.cts → as-field-shell.vue-BU0_8-uI.d.mts} +1 -1
- package/dist/{as-field-shell.vue-DisEXQI1.d.mts → as-field-shell.vue-DAcRqi7G.d.cts} +1 -1
- package/dist/as-field.cjs +1 -1
- package/dist/as-field.mjs +1 -1
- package/dist/{as-form-DLYEF8Ez.mjs → as-form-0VCxVsGo.mjs} +20 -11
- package/dist/{as-form-DgbRGqD8.cjs → as-form-ChyW9bj2.cjs} +19 -10
- 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-BmKBCn6P.d.cts → as-form.vue-CjNW1L-x.d.cts} +55 -326
- package/dist/{as-form.vue-hHJm_Rxq.d.mts → as-form.vue-NCTvXZUy.d.mts} +55 -326
- package/dist/{as-input-UkZxRSD4.cjs → as-input-Bf94SAOY.cjs} +1 -1
- package/dist/{as-input-65rtLZt3.mjs → as-input-DlLLiAYI.mjs} +1 -1
- package/dist/as-input.cjs +1 -1
- package/dist/as-input.d.cts +1 -1
- package/dist/as-input.d.mts +1 -1
- package/dist/as-input.mjs +1 -1
- package/dist/{as-input.vue-CL-Om6Ed.d.mts → as-input.vue-CyLveDWK.d.mts} +1 -1
- package/dist/{as-input.vue-D-RM35Rp.d.cts → as-input.vue-mZ0h1Q2J.d.cts} +1 -1
- package/dist/{as-iterator-DHNJwo-R.cjs → as-iterator-Bty6f5Bq.cjs} +2 -2
- package/dist/{as-iterator-mOyaYJiN.mjs → as-iterator-Dp1OiwU7.mjs} +2 -2
- package/dist/as-iterator.cjs +1 -1
- package/dist/as-iterator.mjs +1 -1
- package/dist/{as-multi-select-AC05uVzY.mjs → as-multi-select-DT0M_1_O.mjs} +97 -26
- package/dist/{as-multi-select-BedSzod1.cjs → as-multi-select-ZGBYoI48.cjs} +95 -24
- package/dist/as-multi-select.cjs +1 -1
- package/dist/as-multi-select.d.cts +1 -1
- package/dist/as-multi-select.d.mts +1 -1
- package/dist/as-multi-select.mjs +1 -1
- package/dist/{as-multi-select.vue-5GHWrbim.d.mts → as-multi-select.vue-BS9bNhCB.d.mts} +1 -1
- package/dist/{as-multi-select.vue-D1OnCH-x.d.cts → as-multi-select.vue-DAFz9hZR.d.cts} +1 -1
- package/dist/{as-number-BMsgxGQw.cjs → as-number-DXQCnc9d.cjs} +2 -2
- package/dist/{as-number-6DTZnVfg.mjs → as-number-DkG5GuGW.mjs} +2 -2
- package/dist/as-number.cjs +1 -1
- package/dist/as-number.d.cts +1 -1
- package/dist/as-number.d.mts +1 -1
- package/dist/as-number.mjs +1 -1
- package/dist/{as-number.vue-BiZ2B2iJ.d.mts → as-number.vue-BsJdJS36.d.cts} +1 -1
- package/dist/{as-number.vue-DE33Giq3.d.cts → as-number.vue-DSP2S_xP.d.mts} +1 -1
- package/dist/{as-object-YYxV2y77.cjs → as-object-DLdKOhxb.cjs} +14 -8
- package/dist/{as-object-B_x-yycI.mjs → as-object-mpRxIKVB.mjs} +14 -8
- package/dist/as-object.cjs +1 -1
- package/dist/as-object.d.cts +1 -1
- package/dist/as-object.d.mts +1 -1
- package/dist/as-object.mjs +1 -1
- package/dist/{as-object.vue-Dg4IT2JT.d.mts → as-object.vue-CpDhlJ_D.d.mts} +1 -1
- package/dist/{as-object.vue-PUhmGqhY.d.cts → as-object.vue-DduGoHKD.d.cts} +1 -1
- package/dist/as-paragraph.d.cts +1 -1
- package/dist/as-paragraph.d.mts +1 -1
- package/dist/{as-paragraph.vue-BUfbXaiy.d.cts → as-paragraph.vue-BJSA27kd.d.cts} +1 -1
- package/dist/{as-paragraph.vue-Bp-MUDcH.d.mts → as-paragraph.vue-CMUaF6WV.d.mts} +1 -1
- package/dist/{as-radio-Dg9c4dGh.mjs → as-radio-CW9YWBnC.mjs} +3 -3
- package/dist/{as-radio-C06SIAFY.cjs → as-radio-D9sctKpc.cjs} +2 -2
- package/dist/as-radio.cjs +1 -1
- package/dist/as-radio.d.cts +1 -1
- package/dist/as-radio.d.mts +1 -1
- package/dist/as-radio.mjs +1 -1
- package/dist/{as-radio.vue-NmjJm8Pj.d.mts → as-radio.vue-BR2ThEbi.d.mts} +1 -1
- package/dist/{as-radio.vue-h4XkpaW0.d.cts → as-radio.vue-Dw1QaJoY.d.cts} +1 -1
- package/dist/{as-ref-BEhS_vo9.cjs → as-ref-CpHMAAJu.cjs} +5 -3
- package/dist/{as-ref-BWJlIf5G.mjs → as-ref-DaCGfshO.mjs} +5 -3
- package/dist/as-ref.cjs +1 -1
- package/dist/as-ref.d.cts +1 -1
- package/dist/as-ref.d.mts +1 -1
- package/dist/as-ref.mjs +1 -1
- package/dist/{as-ref.vue-ec447Bmx.d.cts → as-ref.vue-CZzOVBz1.d.mts} +1 -1
- package/dist/{as-ref.vue-vP2P1ePF.d.mts → as-ref.vue-CvY88H7p.d.cts} +1 -1
- package/dist/{as-select-CrTKlmhd.mjs → as-select-CrjlxcgR.mjs} +3 -3
- package/dist/{as-select-DzEUs8Od.cjs → as-select-DAbNosmB.cjs} +2 -2
- package/dist/as-select.cjs +1 -1
- package/dist/as-select.d.cts +1 -1
- package/dist/as-select.d.mts +1 -1
- package/dist/as-select.mjs +1 -1
- package/dist/{as-select.vue-9mQ6cjW7.d.mts → as-select.vue-7xiuC9JG.d.cts} +1 -1
- package/dist/{as-select.vue-DV0C1MsH.d.cts → as-select.vue-BPPctxZT.d.mts} +1 -1
- package/dist/{as-time-BQ6KXMyV.mjs → as-time-BmXXgfCZ.mjs} +1 -1
- package/dist/{as-time-Cu-8mKpR.cjs → as-time-NaICaSIj.cjs} +1 -1
- package/dist/as-time.cjs +1 -1
- package/dist/as-time.d.cts +1 -1
- package/dist/as-time.d.mts +1 -1
- package/dist/as-time.mjs +1 -1
- package/dist/{as-time.vue-CmvsgHJd.d.cts → as-time.vue-CQhIKAs0.d.cts} +1 -1
- package/dist/{as-time.vue-DGfZPnWK.d.mts → as-time.vue-CjzRrsFg.d.mts} +1 -1
- package/dist/{as-tuple-Dny4Ov_j.mjs → as-tuple-BBx6P6xb.mjs} +8 -6
- package/dist/{as-tuple-CfgSnsT9.cjs → as-tuple-DkI9fp4G.cjs} +8 -6
- package/dist/as-tuple.cjs +1 -1
- package/dist/as-tuple.d.cts +1 -1
- package/dist/as-tuple.d.mts +1 -1
- package/dist/as-tuple.mjs +1 -1
- package/dist/{as-tuple.vue-CInEbMRo.d.mts → as-tuple.vue-BSh2-1uv.d.cts} +1 -1
- package/dist/{as-tuple.vue-zZkuYxet.d.cts → as-tuple.vue-DvHHrn-6.d.mts} +1 -1
- package/dist/{as-union-DT8XDZSt.cjs → as-union-BjmrvD80.cjs} +8 -6
- package/dist/{as-union-Gz8gEjmn.mjs → as-union-C3QiGYlE.mjs} +7 -5
- package/dist/as-union.cjs +1 -1
- package/dist/as-union.d.cts +1 -1
- package/dist/as-union.d.mts +1 -1
- package/dist/as-union.mjs +1 -1
- package/dist/{as-union.vue-Bz3EO0Gg.d.mts → as-union.vue-BJ8xFYYb.d.mts} +1 -1
- package/dist/{as-union.vue-K9ZSRg0G.d.cts → as-union.vue-CnF4bNex.d.cts} +1 -1
- package/dist/{as-variant-picker-B3GLhKyt.mjs → as-variant-picker-BUF7Am9t.mjs} +13 -8
- package/dist/{as-variant-picker-JlEhh7YO.cjs → as-variant-picker-BcJx7Zt7.cjs} +14 -9
- package/dist/index.cjs +30 -27
- package/dist/index.d.cts +23 -22
- package/dist/index.d.mts +23 -22
- package/dist/index.mjs +29 -26
- package/dist/locale.cjs +5 -0
- package/dist/locale.d.cts +2 -0
- package/dist/locale.d.mts +2 -0
- package/dist/locale.mjs +2 -0
- package/dist/{types-BLoV3zIo.d.mts → types-BoguW89D.d.mts} +24 -19
- package/dist/{types-Crwu2D-w.d.cts → types-DoLxVJhd.d.cts} +24 -19
- package/dist/use-as-locale-1k9NBn-G.mjs +56 -0
- package/dist/use-as-locale-BVcC0l75.d.mts +35 -0
- package/dist/use-as-locale-C2tFUenv.cjs +73 -0
- package/dist/use-as-locale-CnGzoVWd.d.cts +35 -0
- package/dist/{use-as-value-help-CDmkz6A7.cjs → use-as-value-help-BE-fAZRP.cjs} +4 -2
- package/dist/{use-as-value-help-CYMlEubv.mjs → use-as-value-help-nIpEFMqD.mjs} +4 -2
- package/dist/{use-form-context-cDW2GW4-.mjs → use-form-context-C3FxL3eF.mjs} +4 -1
- package/dist/{use-form-context-B6ZnzfxG.cjs → use-form-context-CXsLnG7l.cjs} +4 -1
- package/dist/{use-as-dropdown-B2Shb7wn.mjs → variant-label-B065kts3.mjs} +13 -1
- package/dist/{use-as-dropdown-Bj9toVdw.cjs → variant-label-C-rLK7Z3.cjs} +18 -0
- package/package.json +16 -11
- package/dist/use-as-locale-BrFdAgnU.mjs +0 -23
- package/dist/use-as-locale-C4z5stwD.cjs +0 -34
|
@@ -0,0 +1,56 @@
|
|
|
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 };
|
|
@@ -0,0 +1,35 @@
|
|
|
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 };
|
|
@@ -0,0 +1,73 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
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,3 +1,4 @@
|
|
|
1
|
+
const require_use_as_locale = require("./use-as-locale-C2tFUenv.cjs");
|
|
1
2
|
let vue = require("vue");
|
|
2
3
|
let _atscript_ui = require("@atscript/ui");
|
|
3
4
|
//#region src/composables/use-as-value-help.ts
|
|
@@ -7,7 +8,8 @@ const DEBOUNCE_MS = 300;
|
|
|
7
8
|
function useAsValueHelp(options) {
|
|
8
9
|
const { info, model, onBlur } = options;
|
|
9
10
|
const injectedFactory = (0, vue.inject)(CLIENT_FACTORY_KEY, null) ?? void 0;
|
|
10
|
-
const
|
|
11
|
+
const texts = require_use_as_locale.useAsTexts();
|
|
12
|
+
const entry = (0, _atscript_ui.getMetaEntry)(info.url, injectedFactory, { texts });
|
|
11
13
|
if ((0, vue.getCurrentScope)()) (0, vue.onScopeDispose)((0, _atscript_ui.retainMetaEntry)(entry));
|
|
12
14
|
const vhClient = new _atscript_ui.ValueHelpClient(entry.client);
|
|
13
15
|
const resolved = (0, vue.shallowRef)(null);
|
|
@@ -24,7 +26,7 @@ function useAsValueHelp(options) {
|
|
|
24
26
|
});
|
|
25
27
|
async function kickoff() {
|
|
26
28
|
if (kickoffPromise) return kickoffPromise;
|
|
27
|
-
kickoffPromise = (0, _atscript_ui.resolveValueHelp)(info.url).then((r) => {
|
|
29
|
+
kickoffPromise = (0, _atscript_ui.resolveValueHelp)(info.url, { texts }).then((r) => {
|
|
28
30
|
resolved.value = r;
|
|
29
31
|
status.value = "ready";
|
|
30
32
|
}).catch(() => {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { r as useAsTexts } from "./use-as-locale-1k9NBn-G.mjs";
|
|
1
2
|
import { computed, getCurrentScope, inject, onMounted, onScopeDispose, onUnmounted, ref, shallowRef, watch } from "vue";
|
|
2
3
|
import { ValueHelpClient, getMetaEntry, resolveValueHelp, retainMetaEntry } from "@atscript/ui";
|
|
3
4
|
//#region src/composables/use-as-value-help.ts
|
|
@@ -7,7 +8,8 @@ const DEBOUNCE_MS = 300;
|
|
|
7
8
|
function useAsValueHelp(options) {
|
|
8
9
|
const { info, model, onBlur } = options;
|
|
9
10
|
const injectedFactory = inject(CLIENT_FACTORY_KEY, null) ?? void 0;
|
|
10
|
-
const
|
|
11
|
+
const texts = useAsTexts();
|
|
12
|
+
const entry = getMetaEntry(info.url, injectedFactory, { texts });
|
|
11
13
|
if (getCurrentScope()) onScopeDispose(retainMetaEntry(entry));
|
|
12
14
|
const vhClient = new ValueHelpClient(entry.client);
|
|
13
15
|
const resolved = shallowRef(null);
|
|
@@ -24,7 +26,7 @@ function useAsValueHelp(options) {
|
|
|
24
26
|
});
|
|
25
27
|
async function kickoff() {
|
|
26
28
|
if (kickoffPromise) return kickoffPromise;
|
|
27
|
-
kickoffPromise = resolveValueHelp(info.url).then((r) => {
|
|
29
|
+
kickoffPromise = resolveValueHelp(info.url, { texts }).then((r) => {
|
|
28
30
|
resolved.value = r;
|
|
29
31
|
status.value = "ready";
|
|
30
32
|
}).catch(() => {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { r as useAsTexts } from "./use-as-locale-1k9NBn-G.mjs";
|
|
1
2
|
import { computed, inject, provide } from "vue";
|
|
2
3
|
import { getByPath, joinPath, setByPath } from "@atscript/ui";
|
|
3
4
|
//#region src/composables/internal-keys.ts
|
|
@@ -54,12 +55,14 @@ function useFormContext(componentName) {
|
|
|
54
55
|
function setByPath$1(path, value) {
|
|
55
56
|
setByPath(rootFormData(), path, value);
|
|
56
57
|
}
|
|
58
|
+
const { t } = useAsTexts();
|
|
57
59
|
function buildScope(v, entry) {
|
|
58
60
|
return {
|
|
59
61
|
v,
|
|
60
62
|
data: rootFormData().value,
|
|
61
63
|
context: formContext.value,
|
|
62
|
-
entry
|
|
64
|
+
entry,
|
|
65
|
+
t
|
|
63
66
|
};
|
|
64
67
|
}
|
|
65
68
|
return {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const require_use_as_locale = require("./use-as-locale-C2tFUenv.cjs");
|
|
1
2
|
let vue = require("vue");
|
|
2
3
|
let _atscript_ui = require("@atscript/ui");
|
|
3
4
|
//#region src/composables/internal-keys.ts
|
|
@@ -54,12 +55,14 @@ function useFormContext(componentName) {
|
|
|
54
55
|
function setByPath(path, value) {
|
|
55
56
|
(0, _atscript_ui.setByPath)(rootFormData(), path, value);
|
|
56
57
|
}
|
|
58
|
+
const { t } = require_use_as_locale.useAsTexts();
|
|
57
59
|
function buildScope(v, entry) {
|
|
58
60
|
return {
|
|
59
61
|
v,
|
|
60
62
|
data: rootFormData().value,
|
|
61
63
|
context: formContext.value,
|
|
62
|
-
entry
|
|
64
|
+
entry,
|
|
65
|
+
t
|
|
63
66
|
};
|
|
64
67
|
}
|
|
65
68
|
return {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { onBeforeUnmount, ref, watch } from "vue";
|
|
2
|
+
import { AS_UI_MESSAGES } from "@atscript/ui/messages";
|
|
2
3
|
//#region src/composables/use-as-dropdown.ts
|
|
3
4
|
function useAsDropdown(containerRef) {
|
|
4
5
|
const isOpen = ref(false);
|
|
@@ -28,4 +29,15 @@ function useAsDropdown(containerRef) {
|
|
|
28
29
|
};
|
|
29
30
|
}
|
|
30
31
|
//#endregion
|
|
31
|
-
|
|
32
|
+
//#region src/composables/variant-label.ts
|
|
33
|
+
/**
|
|
34
|
+
* A union variant's label in the UI locale: a generated type name
|
|
35
|
+
* (`labelCode`, e.g. "1. String") is worded with `t` at render time —
|
|
36
|
+
* a definition is built once for every locale (and on a server).
|
|
37
|
+
*/
|
|
38
|
+
function variantLabel(variant, t) {
|
|
39
|
+
const code = variant.labelCode;
|
|
40
|
+
return code ? variant.label.slice(0, -AS_UI_MESSAGES[code].length) + t(code) : variant.label;
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
export { useAsDropdown as n, variantLabel as t };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
let vue = require("vue");
|
|
2
|
+
let _atscript_ui_messages = require("@atscript/ui/messages");
|
|
2
3
|
//#region src/composables/use-as-dropdown.ts
|
|
3
4
|
function useAsDropdown(containerRef) {
|
|
4
5
|
const isOpen = (0, vue.ref)(false);
|
|
@@ -28,9 +29,26 @@ function useAsDropdown(containerRef) {
|
|
|
28
29
|
};
|
|
29
30
|
}
|
|
30
31
|
//#endregion
|
|
32
|
+
//#region src/composables/variant-label.ts
|
|
33
|
+
/**
|
|
34
|
+
* A union variant's label in the UI locale: a generated type name
|
|
35
|
+
* (`labelCode`, e.g. "1. String") is worded with `t` at render time —
|
|
36
|
+
* a definition is built once for every locale (and on a server).
|
|
37
|
+
*/
|
|
38
|
+
function variantLabel(variant, t) {
|
|
39
|
+
const code = variant.labelCode;
|
|
40
|
+
return code ? variant.label.slice(0, -_atscript_ui_messages.AS_UI_MESSAGES[code].length) + t(code) : variant.label;
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
31
43
|
Object.defineProperty(exports, "useAsDropdown", {
|
|
32
44
|
enumerable: true,
|
|
33
45
|
get: function() {
|
|
34
46
|
return useAsDropdown;
|
|
35
47
|
}
|
|
36
48
|
});
|
|
49
|
+
Object.defineProperty(exports, "variantLabel", {
|
|
50
|
+
enumerable: true,
|
|
51
|
+
get: function() {
|
|
52
|
+
return variantLabel;
|
|
53
|
+
}
|
|
54
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atscript/vue-form",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.165",
|
|
4
4
|
"description": "Type-driven form rendering for Atscript with Vue 3",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"atscript",
|
|
@@ -154,35 +154,40 @@
|
|
|
154
154
|
"types": "./styles.d.ts",
|
|
155
155
|
"default": "./dist/style.css"
|
|
156
156
|
},
|
|
157
|
+
"./locale": {
|
|
158
|
+
"types": "./dist/locale.d.mts",
|
|
159
|
+
"import": "./dist/locale.mjs",
|
|
160
|
+
"require": "./dist/locale.cjs"
|
|
161
|
+
},
|
|
157
162
|
"./package.json": "./package.json"
|
|
158
163
|
},
|
|
159
164
|
"publishConfig": {
|
|
160
165
|
"access": "public"
|
|
161
166
|
},
|
|
162
167
|
"dependencies": {
|
|
163
|
-
"@atscript/ui": "^0.1.
|
|
168
|
+
"@atscript/ui": "^0.1.165",
|
|
169
|
+
"@atscript/ui-fns": "^0.1.165"
|
|
164
170
|
},
|
|
165
171
|
"devDependencies": {
|
|
166
|
-
"@atscript/core": "^0.2.
|
|
167
|
-
"@atscript/db-client": "^0.1.
|
|
168
|
-
"@atscript/typescript": "^0.2.
|
|
172
|
+
"@atscript/core": "^0.2.7",
|
|
173
|
+
"@atscript/db-client": "^0.1.170",
|
|
174
|
+
"@atscript/typescript": "^0.2.7",
|
|
169
175
|
"@tsdown/css": "^0.21.4",
|
|
170
176
|
"@vitejs/plugin-vue": "^6",
|
|
171
177
|
"@vue/test-utils": "^2",
|
|
172
178
|
"happy-dom": "^18",
|
|
173
179
|
"reka-ui": "^2.9.8",
|
|
174
|
-
"unplugin-atscript": "^0.2.
|
|
180
|
+
"unplugin-atscript": "^0.2.7",
|
|
175
181
|
"vitest": "npm:@voidzero-dev/vite-plus-test@0.1.14",
|
|
176
182
|
"vue": "^3",
|
|
177
183
|
"vue-tsc": "~3.2.9",
|
|
178
|
-
"vunor": "^0.4.0"
|
|
179
|
-
"@atscript/ui-fns": "^0.1.163"
|
|
184
|
+
"vunor": "^0.4.0"
|
|
180
185
|
},
|
|
181
186
|
"peerDependencies": {
|
|
182
|
-
"@atscript/db-client": "^0.1.
|
|
187
|
+
"@atscript/db-client": "^0.1.170",
|
|
188
|
+
"@atscript/typescript": "^0.2.7",
|
|
183
189
|
"reka-ui": "^2.9.8",
|
|
184
|
-
"vue": "^3"
|
|
185
|
-
"@atscript/ui-fns": "^0.1.163"
|
|
190
|
+
"vue": "^3"
|
|
186
191
|
},
|
|
187
192
|
"scripts": {
|
|
188
193
|
"build": "node ../../scripts/gen-exports.mjs && vp pack",
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { computed, inject, provide } from "vue";
|
|
2
|
-
//#region src/composables/use-as-locale.ts
|
|
3
|
-
/**
|
|
4
|
-
* BCP-47 locale for form-side decimal formatting (separator, thousands,
|
|
5
|
-
* currency symbol). Parallels `provideCellLocale` in `@atscript/vue-table`
|
|
6
|
-
* but lives in vue-form so the form package stays free of cross-package
|
|
7
|
-
* coupling — the host wires both providers from a single source (e.g.
|
|
8
|
-
* `useAppPrefs` in vue-table).
|
|
9
|
-
*
|
|
10
|
-
* The injected value is a getter so reactive sources (e.g.
|
|
11
|
-
* `prefs.value?.language`) can be passed without forcing the caller to
|
|
12
|
-
* wrap them in a computed.
|
|
13
|
-
*/
|
|
14
|
-
const AS_LOCALE_KEY = Symbol("as-locale");
|
|
15
|
-
function provideAsLocale(getter) {
|
|
16
|
-
provide(AS_LOCALE_KEY, getter);
|
|
17
|
-
}
|
|
18
|
-
function useAsLocale() {
|
|
19
|
-
const getter = inject(AS_LOCALE_KEY, () => void 0);
|
|
20
|
-
return { locale: computed(() => getter()) };
|
|
21
|
-
}
|
|
22
|
-
//#endregion
|
|
23
|
-
export { useAsLocale as n, provideAsLocale as t };
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
let vue = require("vue");
|
|
2
|
-
//#region src/composables/use-as-locale.ts
|
|
3
|
-
/**
|
|
4
|
-
* BCP-47 locale for form-side decimal formatting (separator, thousands,
|
|
5
|
-
* currency symbol). Parallels `provideCellLocale` in `@atscript/vue-table`
|
|
6
|
-
* but lives in vue-form so the form package stays free of cross-package
|
|
7
|
-
* coupling — the host wires both providers from a single source (e.g.
|
|
8
|
-
* `useAppPrefs` in vue-table).
|
|
9
|
-
*
|
|
10
|
-
* The injected value is a getter so reactive sources (e.g.
|
|
11
|
-
* `prefs.value?.language`) can be passed without forcing the caller to
|
|
12
|
-
* wrap them in a computed.
|
|
13
|
-
*/
|
|
14
|
-
const AS_LOCALE_KEY = Symbol("as-locale");
|
|
15
|
-
function provideAsLocale(getter) {
|
|
16
|
-
(0, vue.provide)(AS_LOCALE_KEY, getter);
|
|
17
|
-
}
|
|
18
|
-
function useAsLocale() {
|
|
19
|
-
const getter = (0, vue.inject)(AS_LOCALE_KEY, () => void 0);
|
|
20
|
-
return { locale: (0, vue.computed)(() => getter()) };
|
|
21
|
-
}
|
|
22
|
-
//#endregion
|
|
23
|
-
Object.defineProperty(exports, "provideAsLocale", {
|
|
24
|
-
enumerable: true,
|
|
25
|
-
get: function() {
|
|
26
|
-
return provideAsLocale;
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
Object.defineProperty(exports, "useAsLocale", {
|
|
30
|
-
enumerable: true,
|
|
31
|
-
get: function() {
|
|
32
|
-
return useAsLocale;
|
|
33
|
-
}
|
|
34
|
-
});
|