@fishbelly/form-morph-arco 0.1.2 → 0.2.0
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/README.md +25 -1
- package/dist/components/ArcoFormItem.vue.d.ts +1 -1
- package/dist/components/ArcoFormShell.vue.d.ts +5 -0
- package/dist/containers/CardContainer.vue.d.ts +1 -1
- package/dist/containers/DividerContainer.vue.d.ts +1 -1
- package/dist/containers/SectionContainer.vue.d.ts +1 -1
- package/dist/fields/CascaderInput.vue.d.ts +1 -1
- package/dist/fields/CheckboxInput.vue.d.ts +1 -1
- package/dist/fields/ColorInput.vue.d.ts +1 -1
- package/dist/fields/DateInput.vue.d.ts +1 -1
- package/dist/fields/NumberInput.vue.d.ts +1 -1
- package/dist/fields/RadioInput.vue.d.ts +1 -1
- package/dist/fields/RateInput.vue.d.ts +1 -1
- package/dist/fields/SelectInput.vue.d.ts +1 -1
- package/dist/fields/SliderInput.vue.d.ts +1 -1
- package/dist/fields/StaticText.vue.d.ts +1 -1
- package/dist/fields/SwitchInput.vue.d.ts +1 -1
- package/dist/fields/TextInput.vue.d.ts +1 -1
- package/dist/fields/TimeInput.vue.d.ts +1 -1
- package/dist/fields/TreeSelectInput.vue.d.ts +1 -1
- package/dist/fields/UploadInput.vue.d.ts +1 -1
- package/dist/fields/treeValue.d.ts +1 -1
- package/dist/i18n.d.ts +12 -0
- package/dist/index.d.ts +15 -6
- package/dist/index.js +743 -584
- package/dist/index.js.map +1 -1
- package/dist/locale.d.ts +14 -0
- package/dist/locales/en-US.d.ts +3 -0
- package/dist/locales/en-US.js +139 -0
- package/dist/locales/en-US.js.map +1 -0
- package/dist/locales/zh-CN.d.ts +34 -0
- package/dist/shell.d.ts +12 -0
- package/dist/style.css +1 -1
- package/package.json +57 -53
- package/dist/__tests__/dateValue.test.d.ts +0 -1
- package/dist/__tests__/fieldConfig.test.d.ts +0 -1
- package/dist/__tests__/formRendererValidation.test.d.ts +0 -1
- package/dist/__tests__/labelWidth.test.d.ts +0 -1
- package/dist/__tests__/optionDisabled.test.d.ts +0 -1
- package/dist/__tests__/treeValue.test.d.ts +0 -1
- package/dist/__tests__/uploadInput.test.d.ts +0 -1
- package/dist/__tests__/uploadValue.test.d.ts +0 -1
package/README.md
CHANGED
|
@@ -46,6 +46,7 @@ import { ref } from 'vue';
|
|
|
46
46
|
import { FormRenderer, type FormSchema } from '@fishbelly/form-morph';
|
|
47
47
|
|
|
48
48
|
const schema: FormSchema = {
|
|
49
|
+
schemaVersion: 3,
|
|
49
50
|
id: 'arco-demo',
|
|
50
51
|
layout: { mode: 'horizontal', labelWidth: 96, gutter: 16 },
|
|
51
52
|
nodes: [
|
|
@@ -207,12 +208,35 @@ const morph = createFormMorph({
|
|
|
207
208
|
console.log(morph.registry.listFields());
|
|
208
209
|
```
|
|
209
210
|
|
|
211
|
+
## 国际化
|
|
212
|
+
|
|
213
|
+
- 引擎默认语言为 `zh-CN`;`createFormMorph({ locale: 'en-US' })` 或运行时 `morph.setLocale('en-US')` 可切换,字段名称、分类、属性面板与校验提示同步切换;切回 `zh-CN` 后完整恢复。
|
|
214
|
+
- 英文资源从子路径按需导入,不会进入本包主产物:
|
|
215
|
+
|
|
216
|
+
```ts
|
|
217
|
+
import { createFormMorph } from '@fishbelly/form-morph';
|
|
218
|
+
import enUS from '@fishbelly/form-morph/locales/en-US';
|
|
219
|
+
import designerEnUS from '@fishbelly/form-morph/designer/locales/en-US';
|
|
220
|
+
import arcoEnUS from '@fishbelly/form-morph-arco/locales/en-US';
|
|
221
|
+
|
|
222
|
+
const morph = createFormMorph({
|
|
223
|
+
locale: 'en-US',
|
|
224
|
+
messages: { 'en-US': { ...enUS, ...designerEnUS } },
|
|
225
|
+
plugins: [createArcoPack({ locales: { 'en-US': arcoEnUS } })]
|
|
226
|
+
});
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
- Arco 组件内置文案(日期面板、空数据等)默认跟随引擎语言,`zh-CN` / `en-US` 已内置映射;追加其他语言用 `uiLocales: { 'zh-TW': arcoZhTW }`,需要交给宿主管理时传 `syncLibraryLocale: false`,由宿主自行用 `ConfigProvider` 包裹。
|
|
230
|
+
- 宿主可传 `translate(key, defaultMessage, context)` 接管翻译,返回 `undefined` 时回退内置资源;`ValidationRule.message` 与 `messageProvider` 优先级更高。
|
|
231
|
+
- Schema 中的用户文案(`label`、`placeholder`、静态选项)不会自动翻译;设计器新建字段时按当前语言写入。
|
|
232
|
+
|
|
210
233
|
## 兼容性
|
|
211
234
|
|
|
212
235
|
- Vue `^3.4.0`
|
|
213
236
|
- `@arco-design/web-vue` `^2.50.0`
|
|
214
|
-
- `@fishbelly/form-morph` `^0.
|
|
237
|
+
- `@fishbelly/form-morph` `^0.2.0`
|
|
215
238
|
- 需同时引入 Arco 样式、`@fishbelly/form-morph/style.css` 与本包 `style.css`
|
|
239
|
+
- 表单外壳默认将引擎语言映射到 Arco 语言包(内置 `zh-CN` / `en-US`),日期面板、空数据等组件内置文案随引擎语言切换;可用 `syncLibraryLocale: false` 交回宿主管理
|
|
216
240
|
|
|
217
241
|
## 文档
|
|
218
242
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ArcoLocale } from '../locale';
|
|
1
2
|
type __VLS_Props = {
|
|
2
3
|
layout?: 'horizontal' | 'vertical';
|
|
3
4
|
labelAlign?: 'left' | 'right';
|
|
@@ -7,6 +8,10 @@ type __VLS_Props = {
|
|
|
7
8
|
model?: Record<string, unknown>;
|
|
8
9
|
rules?: Record<string, unknown>;
|
|
9
10
|
scrollToFirstError?: boolean;
|
|
11
|
+
/** Additional engine-locale → Arco language pack mappings. */
|
|
12
|
+
localeMap?: Record<string, ArcoLocale>;
|
|
13
|
+
/** Set to false to keep the host's UI-library provider and skip syncing. */
|
|
14
|
+
syncLibraryLocale?: boolean;
|
|
10
15
|
};
|
|
11
16
|
declare function validate(): Promise<Record<string, unknown> | undefined> | undefined;
|
|
12
17
|
declare function __VLS_template(): {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FieldWidgetProps } from '
|
|
1
|
+
import { FieldWidgetProps } from '@fishbelly/form-morph';
|
|
2
2
|
declare const _default: import('vue').DefineComponent<FieldWidgetProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<FieldWidgetProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
3
3
|
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldWidgetProps } from '
|
|
1
|
+
import { FieldWidgetProps } from '@fishbelly/form-morph';
|
|
2
2
|
declare const _default: import('vue').DefineComponent<FieldWidgetProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
3
3
|
"update:modelValue": (value: unknown) => any;
|
|
4
4
|
}, string, import('vue').PublicProps, Readonly<FieldWidgetProps> & Readonly<{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldWidgetProps } from '
|
|
1
|
+
import { FieldWidgetProps } from '@fishbelly/form-morph';
|
|
2
2
|
declare const _default: import('vue').DefineComponent<FieldWidgetProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
3
3
|
"update:modelValue": (value: unknown) => any;
|
|
4
4
|
}, string, import('vue').PublicProps, Readonly<FieldWidgetProps> & Readonly<{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldWidgetProps } from '
|
|
1
|
+
import { FieldWidgetProps } from '@fishbelly/form-morph';
|
|
2
2
|
declare const _default: import('vue').DefineComponent<FieldWidgetProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
3
3
|
"update:modelValue": (value: unknown) => any;
|
|
4
4
|
}, string, import('vue').PublicProps, Readonly<FieldWidgetProps> & Readonly<{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldWidgetProps } from '
|
|
1
|
+
import { FieldWidgetProps } from '@fishbelly/form-morph';
|
|
2
2
|
declare const _default: import('vue').DefineComponent<FieldWidgetProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
3
3
|
"update:modelValue": (value: unknown) => any;
|
|
4
4
|
}, string, import('vue').PublicProps, Readonly<FieldWidgetProps> & Readonly<{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldWidgetProps } from '
|
|
1
|
+
import { FieldWidgetProps } from '@fishbelly/form-morph';
|
|
2
2
|
declare const _default: import('vue').DefineComponent<FieldWidgetProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
3
3
|
"update:modelValue": (value: unknown) => any;
|
|
4
4
|
}, string, import('vue').PublicProps, Readonly<FieldWidgetProps> & Readonly<{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldWidgetProps } from '
|
|
1
|
+
import { FieldWidgetProps } from '@fishbelly/form-morph';
|
|
2
2
|
declare const _default: import('vue').DefineComponent<FieldWidgetProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
3
3
|
"update:modelValue": (value: unknown) => any;
|
|
4
4
|
}, string, import('vue').PublicProps, Readonly<FieldWidgetProps> & Readonly<{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldWidgetProps } from '
|
|
1
|
+
import { FieldWidgetProps } from '@fishbelly/form-morph';
|
|
2
2
|
declare const _default: import('vue').DefineComponent<FieldWidgetProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
3
3
|
"update:modelValue": (value: unknown) => any;
|
|
4
4
|
}, string, import('vue').PublicProps, Readonly<FieldWidgetProps> & Readonly<{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldWidgetProps } from '
|
|
1
|
+
import { FieldWidgetProps } from '@fishbelly/form-morph';
|
|
2
2
|
declare const _default: import('vue').DefineComponent<FieldWidgetProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
3
3
|
"update:modelValue": (value: unknown) => any;
|
|
4
4
|
}, string, import('vue').PublicProps, Readonly<FieldWidgetProps> & Readonly<{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldWidgetProps } from '
|
|
1
|
+
import { FieldWidgetProps } from '@fishbelly/form-morph';
|
|
2
2
|
declare const _default: import('vue').DefineComponent<FieldWidgetProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
3
3
|
"update:modelValue": (value: unknown) => any;
|
|
4
4
|
}, string, import('vue').PublicProps, Readonly<FieldWidgetProps> & Readonly<{
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FieldWidgetProps } from '
|
|
1
|
+
import { FieldWidgetProps } from '@fishbelly/form-morph';
|
|
2
2
|
declare const _default: import('vue').DefineComponent<FieldWidgetProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<FieldWidgetProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
3
3
|
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldWidgetProps } from '
|
|
1
|
+
import { FieldWidgetProps } from '@fishbelly/form-morph';
|
|
2
2
|
declare const _default: import('vue').DefineComponent<FieldWidgetProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
3
3
|
"update:modelValue": (value: unknown) => any;
|
|
4
4
|
}, string, import('vue').PublicProps, Readonly<FieldWidgetProps> & Readonly<{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldWidgetProps } from '
|
|
1
|
+
import { FieldWidgetProps } from '@fishbelly/form-morph';
|
|
2
2
|
declare const _default: import('vue').DefineComponent<FieldWidgetProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
3
3
|
"update:modelValue": (value: unknown) => any;
|
|
4
4
|
}, string, import('vue').PublicProps, Readonly<FieldWidgetProps> & Readonly<{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldWidgetProps } from '
|
|
1
|
+
import { FieldWidgetProps } from '@fishbelly/form-morph';
|
|
2
2
|
declare const _default: import('vue').DefineComponent<FieldWidgetProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
3
3
|
"update:modelValue": (value: unknown) => any;
|
|
4
4
|
}, string, import('vue').PublicProps, Readonly<FieldWidgetProps> & Readonly<{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldWidgetProps } from '
|
|
1
|
+
import { FieldWidgetProps } from '@fishbelly/form-morph';
|
|
2
2
|
declare const _default: import('vue').DefineComponent<FieldWidgetProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
3
3
|
"update:modelValue": (value: unknown) => any;
|
|
4
4
|
}, string, import('vue').PublicProps, Readonly<FieldWidgetProps> & Readonly<{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldWidgetProps } from '
|
|
1
|
+
import { FieldWidgetProps } from '@fishbelly/form-morph';
|
|
2
2
|
declare const _default: import('vue').DefineComponent<FieldWidgetProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
3
3
|
"update:modelValue": (value: unknown) => any;
|
|
4
4
|
}, string, import('vue').PublicProps, Readonly<FieldWidgetProps> & Readonly<{
|
package/dist/i18n.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { MessageParams } from '@fishbelly/form-morph';
|
|
2
|
+
import { ArcoMessageKey } from './locales/zh-CN';
|
|
3
|
+
/**
|
|
4
|
+
* Widget-side translation helper.
|
|
5
|
+
*
|
|
6
|
+
* Resolves pack messages through the engine locale context and falls back to
|
|
7
|
+
* the bundled zh-CN copy when no locale resource is registered (for example
|
|
8
|
+
* when a widget is mounted standalone).
|
|
9
|
+
*/
|
|
10
|
+
export declare function useFieldLocale(): {
|
|
11
|
+
tField: (key: ArcoMessageKey, params?: MessageParams) => string;
|
|
12
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { VueFieldTypeDefinition, VueFormMorphPlugin, LocaleMessages } from '@fishbelly/form-morph';
|
|
2
2
|
import { default as TextInput } from './fields/TextInput.vue';
|
|
3
3
|
import { default as NumberInput } from './fields/NumberInput.vue';
|
|
4
4
|
import { default as SelectInput } from './fields/SelectInput.vue';
|
|
@@ -19,10 +19,19 @@ import { default as ArcoFormShell } from './components/ArcoFormShell.vue';
|
|
|
19
19
|
import { default as CardContainer } from './containers/CardContainer.vue';
|
|
20
20
|
import { default as SectionContainer } from './containers/SectionContainer.vue';
|
|
21
21
|
import { default as DividerContainer } from './containers/DividerContainer.vue';
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
import { createArcoFormShell } from './shell';
|
|
23
|
+
import { arcoZhCN } from './locales/zh-CN';
|
|
24
|
+
import { ArcoLocale } from './locale';
|
|
25
|
+
export declare const arcoFieldTypes: VueFieldTypeDefinition[];
|
|
26
|
+
export interface ArcoPackOptions {
|
|
24
27
|
name?: string;
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
locales?: Record<string, LocaleMessages>;
|
|
29
|
+
uiLocales?: Record<string, ArcoLocale>;
|
|
30
|
+
syncLibraryLocale?: boolean;
|
|
31
|
+
}
|
|
32
|
+
export declare function createArcoPack(options?: ArcoPackOptions): VueFormMorphPlugin;
|
|
33
|
+
export declare const arcoPack: VueFormMorphPlugin;
|
|
27
34
|
export default arcoPack;
|
|
28
|
-
export { TextInput, NumberInput, SelectInput, RadioInput, CheckboxInput, SwitchInput, SliderInput, RateInput, DateInput, TimeInput, UploadInput, CascaderInput, TreeSelectInput, ColorInput, StaticText, ArcoFormItem, ArcoFormShell, CardContainer, SectionContainer, DividerContainer };
|
|
35
|
+
export { TextInput, NumberInput, SelectInput, RadioInput, CheckboxInput, SwitchInput, SliderInput, RateInput, DateInput, TimeInput, UploadInput, CascaderInput, TreeSelectInput, ColorInput, StaticText, ArcoFormItem, ArcoFormShell, CardContainer, SectionContainer, DividerContainer, createArcoFormShell, arcoZhCN };
|
|
36
|
+
export type { ArcoLocale } from './locale';
|
|
37
|
+
export type { ArcoShellOptions } from './shell';
|