yy-forms 1.0.1 → 1.0.3

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/index.esm.js CHANGED
@@ -1834,11 +1834,6 @@ var Canvas = function Canvas(_ref) {
1834
1834
  }))));
1835
1835
  };
1836
1836
 
1837
- // import { useTranslation } from 'react-i18next';
1838
- // const { t } = useTranslation();
1839
- var t = function t(text) {
1840
- return text;
1841
- };
1842
1837
  // 只需写配置,方便可扩展
1843
1838
  var baseCommonSettings = {
1844
1839
  type: {
@@ -2738,42 +2733,46 @@ var defaultSettings = [{
2738
2733
  // widgets: saves,
2739
2734
  // },
2740
2735
  ];
2741
- var defaultGlobalSettings = {
2742
- type: 'object',
2743
- properties: {
2744
- column: {
2745
- title: t('整体布局'),
2746
- type: 'number',
2747
- enum: [1, 2, 3],
2748
- enumNames: [t('一行一列'), t('一行二列'), t('一行三列')],
2749
- props: {
2750
- placeholder: t('默认一行一列')
2751
- }
2752
- },
2753
- labelWidth: {
2754
- title: t('标签宽度'),
2755
- type: 'number',
2756
- widget: 'slider',
2757
- max: 300,
2758
- default: 120,
2759
- props: {
2760
- hideNumber: true
2736
+ var defaultGlobalSettings = function defaultGlobalSettings(t) {
2737
+ return {
2738
+ type: 'object',
2739
+ properties: {
2740
+ column: {
2741
+ title: t('整体布局'),
2742
+ type: 'number',
2743
+ enum: [1, 2, 3],
2744
+ enumNames: [t('一行一列'), t('一行二列'), t('一行三列')],
2745
+ props: {
2746
+ placeholder: t('默认一行一列')
2747
+ }
2748
+ },
2749
+ labelWidth: {
2750
+ title: t('标签宽度'),
2751
+ type: 'number',
2752
+ widget: 'slider',
2753
+ max: 300,
2754
+ default: 120,
2755
+ props: {
2756
+ hideNumber: true
2757
+ }
2758
+ },
2759
+ displayType: {
2760
+ title: t('标签展示模式'),
2761
+ type: 'string',
2762
+ default: 'row',
2763
+ enum: ['row', 'column'],
2764
+ enumNames: [t('同行'), t('单独一行')],
2765
+ widget: 'radio'
2761
2766
  }
2762
- },
2763
- displayType: {
2764
- title: t('标签展示模式'),
2765
- type: 'string',
2766
- default: 'row',
2767
- enum: ['row', 'column'],
2768
- enumNames: [t('同行'), t('单独一行')],
2769
- widget: 'radio'
2770
2767
  }
2771
- }
2768
+ };
2772
2769
  };
2773
2770
 
2774
2771
  function GlobalSettings(_ref) {
2775
2772
  var widgets = _ref.widgets;
2776
2773
  var form = useForm();
2774
+ var _useTranslation = useTranslation(),
2775
+ t = _useTranslation.t;
2777
2776
  var _useState = useState(false),
2778
2777
  _useState2 = _slicedToArray(_useState, 2),
2779
2778
  innerUpdate = _useState2[0],
@@ -2782,10 +2781,10 @@ function GlobalSettings(_ref) {
2782
2781
  globalWidgets = _useStore.widgets,
2783
2782
  frProps = _useStore.frProps,
2784
2783
  _useStore$userProps = _useStore.userProps,
2785
- userProps = _useStore$userProps === void 0 ? {} : _useStore$userProps,
2786
2784
  mapping = _useStore.mapping;
2787
2785
  var setGlobal = useGlobal();
2788
- var globalSettings = userProps.globalSettings || defaultGlobalSettings;
2786
+ // const globalSettings = userProps.globalSettings || defaultGlobalSettings(t);
2787
+
2789
2788
  var onDataChange = function onDataChange(value) {
2790
2789
  setInnerUpdate(!!Object.keys(value).length);
2791
2790
  setGlobal({
@@ -2810,7 +2809,7 @@ function GlobalSettings(_ref) {
2810
2809
  }
2811
2810
  }, /*#__PURE__*/React.createElement(FormRender, {
2812
2811
  form: form,
2813
- schema: globalSettings,
2812
+ schema: defaultGlobalSettings(t),
2814
2813
  watch: {
2815
2814
  '#': function _(v) {
2816
2815
  return onDataChange(v);
package/dist/index.js CHANGED
@@ -1861,11 +1861,6 @@ var Canvas = function Canvas(_ref) {
1861
1861
  }))));
1862
1862
  };
1863
1863
 
1864
- // import { useTranslation } from 'react-i18next';
1865
- // const { t } = useTranslation();
1866
- var t = function t(text) {
1867
- return text;
1868
- };
1869
1864
  // 只需写配置,方便可扩展
1870
1865
  var baseCommonSettings = {
1871
1866
  type: {
@@ -2765,42 +2760,46 @@ var defaultSettings = [{
2765
2760
  // widgets: saves,
2766
2761
  // },
2767
2762
  ];
2768
- var defaultGlobalSettings = {
2769
- type: 'object',
2770
- properties: {
2771
- column: {
2772
- title: t('整体布局'),
2773
- type: 'number',
2774
- enum: [1, 2, 3],
2775
- enumNames: [t('一行一列'), t('一行二列'), t('一行三列')],
2776
- props: {
2777
- placeholder: t('默认一行一列')
2778
- }
2779
- },
2780
- labelWidth: {
2781
- title: t('标签宽度'),
2782
- type: 'number',
2783
- widget: 'slider',
2784
- max: 300,
2785
- default: 120,
2786
- props: {
2787
- hideNumber: true
2763
+ var defaultGlobalSettings = function defaultGlobalSettings(t) {
2764
+ return {
2765
+ type: 'object',
2766
+ properties: {
2767
+ column: {
2768
+ title: t('整体布局'),
2769
+ type: 'number',
2770
+ enum: [1, 2, 3],
2771
+ enumNames: [t('一行一列'), t('一行二列'), t('一行三列')],
2772
+ props: {
2773
+ placeholder: t('默认一行一列')
2774
+ }
2775
+ },
2776
+ labelWidth: {
2777
+ title: t('标签宽度'),
2778
+ type: 'number',
2779
+ widget: 'slider',
2780
+ max: 300,
2781
+ default: 120,
2782
+ props: {
2783
+ hideNumber: true
2784
+ }
2785
+ },
2786
+ displayType: {
2787
+ title: t('标签展示模式'),
2788
+ type: 'string',
2789
+ default: 'row',
2790
+ enum: ['row', 'column'],
2791
+ enumNames: [t('同行'), t('单独一行')],
2792
+ widget: 'radio'
2788
2793
  }
2789
- },
2790
- displayType: {
2791
- title: t('标签展示模式'),
2792
- type: 'string',
2793
- default: 'row',
2794
- enum: ['row', 'column'],
2795
- enumNames: [t('同行'), t('单独一行')],
2796
- widget: 'radio'
2797
2794
  }
2798
- }
2795
+ };
2799
2796
  };
2800
2797
 
2801
2798
  function GlobalSettings(_ref) {
2802
2799
  var widgets = _ref.widgets;
2803
2800
  var form = FormRender.useForm();
2801
+ var _useTranslation = reactI18next.useTranslation(),
2802
+ t = _useTranslation.t;
2804
2803
  var _useState = React.useState(false),
2805
2804
  _useState2 = _slicedToArray(_useState, 2),
2806
2805
  innerUpdate = _useState2[0],
@@ -2809,10 +2808,10 @@ function GlobalSettings(_ref) {
2809
2808
  globalWidgets = _useStore.widgets,
2810
2809
  frProps = _useStore.frProps,
2811
2810
  _useStore$userProps = _useStore.userProps,
2812
- userProps = _useStore$userProps === void 0 ? {} : _useStore$userProps,
2813
2811
  mapping = _useStore.mapping;
2814
2812
  var setGlobal = useGlobal();
2815
- var globalSettings = userProps.globalSettings || defaultGlobalSettings;
2813
+ // const globalSettings = userProps.globalSettings || defaultGlobalSettings(t);
2814
+
2816
2815
  var onDataChange = function onDataChange(value) {
2817
2816
  setInnerUpdate(!!Object.keys(value).length);
2818
2817
  setGlobal({
@@ -2837,7 +2836,7 @@ function GlobalSettings(_ref) {
2837
2836
  }
2838
2837
  }, /*#__PURE__*/React__default['default'].createElement(FormRender__default['default'], {
2839
2838
  form: form,
2840
- schema: globalSettings,
2839
+ schema: defaultGlobalSettings(t),
2841
2840
  watch: {
2842
2841
  '#': function _(v) {
2843
2842
  return onDataChange(v);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yy-forms",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.esm.js",
6
6
  "typings": "dist/index.d.ts",
@@ -2,9 +2,11 @@ import FormRender, { useForm } from 'form-render';
2
2
  import React, { useEffect, useState } from 'react';
3
3
  import { defaultGlobalSettings } from '../../settings';
4
4
  import { useGlobal, useStore } from '../../utils/hooks';
5
+ import { useTranslation } from 'react-i18next';
5
6
 
6
7
  export default function GlobalSettings({ widgets }) {
7
8
  const form = useForm();
9
+ const { t } = useTranslation();
8
10
  const [innerUpdate, setInnerUpdate] = useState(false);
9
11
  const {
10
12
  widgets: globalWidgets,
@@ -13,7 +15,7 @@ export default function GlobalSettings({ widgets }) {
13
15
  mapping,
14
16
  } = useStore();
15
17
  const setGlobal = useGlobal();
16
- const globalSettings = userProps.globalSettings || defaultGlobalSettings;
18
+ // const globalSettings = userProps.globalSettings || defaultGlobalSettings(t);
17
19
 
18
20
  const onDataChange = value => {
19
21
  setInnerUpdate(!!Object.keys(value).length);
@@ -36,7 +38,7 @@ export default function GlobalSettings({ widgets }) {
36
38
  <div style={{ paddingRight: 24 }}>
37
39
  <FormRender
38
40
  form={form}
39
- schema={globalSettings}
41
+ schema={defaultGlobalSettings(t)}
40
42
  watch={{
41
43
  '#': v => onDataChange(v),
42
44
  }}
@@ -1,6 +1,3 @@
1
- // import { useTranslation } from 'react-i18next';
2
- // const { t } = useTranslation();
3
- const t = (text) => text
4
1
  // 只需写配置,方便可扩展
5
2
  export const baseCommonSettings = {
6
3
  type: {
@@ -1025,35 +1022,37 @@ export const defaultSettings = [
1025
1022
  // },
1026
1023
  ];
1027
1024
 
1028
- export const defaultGlobalSettings = {
1029
- type: 'object',
1030
- properties: {
1031
- column: {
1032
- title: t('整体布局'),
1033
- type: 'number',
1034
- enum: [1, 2, 3],
1035
- enumNames: [t('一行一列'), t('一行二列'), t('一行三列')],
1036
- props: {
1037
- placeholder: t('默认一行一列'),
1025
+ export const defaultGlobalSettings = (t) => {
1026
+ return {
1027
+ type: 'object',
1028
+ properties: {
1029
+ column: {
1030
+ title: t('整体布局'),
1031
+ type: 'number',
1032
+ enum: [1, 2, 3],
1033
+ enumNames: [t('一行一列'), t('一行二列'), t('一行三列')],
1034
+ props: {
1035
+ placeholder: t('默认一行一列'),
1036
+ },
1038
1037
  },
1039
- },
1040
- labelWidth: {
1041
- title: t('标签宽度'),
1042
- type: 'number',
1043
- widget: 'slider',
1044
- max: 300,
1045
- default: 120,
1046
- props: {
1047
- hideNumber: true,
1038
+ labelWidth: {
1039
+ title: t('标签宽度'),
1040
+ type: 'number',
1041
+ widget: 'slider',
1042
+ max: 300,
1043
+ default: 120,
1044
+ props: {
1045
+ hideNumber: true,
1046
+ },
1047
+ },
1048
+ displayType: {
1049
+ title: t('标签展示模式'),
1050
+ type: 'string',
1051
+ default: 'row',
1052
+ enum: ['row', 'column'],
1053
+ enumNames: [t('同行'), t('单独一行')],
1054
+ widget: 'radio',
1048
1055
  },
1049
1056
  },
1050
- displayType: {
1051
- title: t('标签展示模式'),
1052
- type: 'string',
1053
- default: 'row',
1054
- enum: ['row', 'column'],
1055
- enumNames: [t('同行'), t('单独一行')],
1056
- widget: 'radio',
1057
- },
1058
- },
1057
+ }
1059
1058
  };