@atscript/vue-form 0.1.164 → 0.1.166
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-CqnBh3rv.mjs → as-array-B2axGw3v.mjs} +15 -12
- package/dist/{as-array-CxeMe9Dw.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.mjs +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.mjs +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.mjs +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.mjs +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.mjs +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.mjs +1 -1
- package/dist/{as-field-DQxlwJVM.mjs → as-field-BZpWLPcM.mjs} +16 -13
- package/dist/{as-field-8MDWK_jb.cjs → as-field-D0HgywQY.cjs} +15 -12
- 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.mjs +1 -1
- package/dist/as-field.cjs +1 -1
- package/dist/as-field.mjs +1 -1
- package/dist/{as-form-C-CV5ezE.mjs → as-form-0VCxVsGo.mjs} +18 -10
- package/dist/{as-form-DLSFfuLR.cjs → as-form-ChyW9bj2.cjs} +18 -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-BA70Ib2m.d.cts → as-form.vue-BuRFHSK-.d.cts} +6 -10
- package/dist/{as-form.vue-D2SQ5VeJ.d.mts → as-form.vue-CHEkgO3k.d.mts} +6 -10
- 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.mjs +1 -1
- package/dist/{as-iterator-Bbyxog8g.cjs → as-iterator-Bty6f5Bq.cjs} +2 -2
- package/dist/{as-iterator-CaQ1TkIR.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-B7Nc2brD.mjs → as-multi-select-DT0M_1_O.mjs} +20 -17
- package/dist/{as-multi-select-BiUexFnY.cjs → as-multi-select-ZGBYoI48.cjs} +19 -16
- package/dist/as-multi-select.cjs +1 -1
- package/dist/as-multi-select.mjs +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.mjs +1 -1
- package/dist/{as-object-BjOUiVDG.cjs → as-object-DLdKOhxb.cjs} +14 -8
- package/dist/{as-object-0Qo0bPi5.mjs → as-object-mpRxIKVB.mjs} +14 -8
- package/dist/as-object.cjs +1 -1
- package/dist/as-object.mjs +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.mjs +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.mjs +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.mjs +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.mjs +1 -1
- package/dist/{as-tuple-fwxeV71M.mjs → as-tuple-BBx6P6xb.mjs} +8 -6
- package/dist/{as-tuple-DKBOLriy.cjs → as-tuple-DkI9fp4G.cjs} +8 -6
- package/dist/as-tuple.cjs +1 -1
- package/dist/as-tuple.mjs +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.mjs +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 +25 -25
- package/dist/index.d.cts +2 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.mjs +24 -24
- 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/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 +14 -9
- package/dist/use-as-locale-BrFdAgnU.mjs +0 -23
- package/dist/use-as-locale-C4z5stwD.cjs +0 -34
|
@@ -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.166",
|
|
4
4
|
"description": "Type-driven form rendering for Atscript with Vue 3",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"atscript",
|
|
@@ -154,33 +154,38 @@
|
|
|
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.
|
|
164
|
-
"@atscript/ui-fns": "^0.1.
|
|
168
|
+
"@atscript/ui": "^0.1.166",
|
|
169
|
+
"@atscript/ui-fns": "^0.1.166"
|
|
165
170
|
},
|
|
166
171
|
"devDependencies": {
|
|
167
|
-
"@atscript/core": "^0.2.
|
|
168
|
-
"@atscript/db-client": "^0.1.
|
|
169
|
-
"@atscript/typescript": "^0.2.
|
|
172
|
+
"@atscript/core": "^0.2.7",
|
|
173
|
+
"@atscript/db-client": "^0.1.170",
|
|
174
|
+
"@atscript/typescript": "^0.2.7",
|
|
170
175
|
"@tsdown/css": "^0.21.4",
|
|
171
176
|
"@vitejs/plugin-vue": "^6",
|
|
172
177
|
"@vue/test-utils": "^2",
|
|
173
178
|
"happy-dom": "^18",
|
|
174
179
|
"reka-ui": "^2.9.8",
|
|
175
|
-
"unplugin-atscript": "^0.2.
|
|
180
|
+
"unplugin-atscript": "^0.2.7",
|
|
176
181
|
"vitest": "npm:@voidzero-dev/vite-plus-test@0.1.14",
|
|
177
182
|
"vue": "^3",
|
|
178
183
|
"vue-tsc": "~3.2.9",
|
|
179
184
|
"vunor": "^0.4.0"
|
|
180
185
|
},
|
|
181
186
|
"peerDependencies": {
|
|
182
|
-
"@atscript/db-client": "^0.1.
|
|
183
|
-
"@atscript/typescript": "^0.2.
|
|
187
|
+
"@atscript/db-client": "^0.1.170",
|
|
188
|
+
"@atscript/typescript": "^0.2.7",
|
|
184
189
|
"reka-ui": "^2.9.8",
|
|
185
190
|
"vue": "^3"
|
|
186
191
|
},
|
|
@@ -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
|
-
});
|