yy-forms 1.0.35 → 1.0.37

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
@@ -1936,6 +1936,90 @@ var defaultCommonSettings = {
1936
1936
  }
1937
1937
  }
1938
1938
  };
1939
+ var USdefaultCommonSettings = {
1940
+ "$id": {
1941
+ "title": "ID",
1942
+ "description": "Field Name / English",
1943
+ "type": "string",
1944
+ "widget": "idInput",
1945
+ "require": true,
1946
+ "rules": [{
1947
+ "pattern": "^#/.+$",
1948
+ "message": "ID is required"
1949
+ }]
1950
+ },
1951
+ "title": {
1952
+ "title": "Title",
1953
+ "type": "string",
1954
+ "widget": "htmlInput"
1955
+ },
1956
+ "displayType": {
1957
+ "title": "Title Display Mode",
1958
+ "type": "string",
1959
+ "enum": ["row", "column"],
1960
+ "enumNames": ["Same Line", "Separate Line"],
1961
+ "widget": "radio"
1962
+ },
1963
+ "description": {
1964
+ "title": "Description",
1965
+ "type": "string"
1966
+ },
1967
+ "default": {
1968
+ "title": "Default Value",
1969
+ "type": "string"
1970
+ },
1971
+ "required": {
1972
+ "title": "Required",
1973
+ "type": "boolean"
1974
+ },
1975
+ "placeholder": {
1976
+ "title": "Placeholder",
1977
+ "type": "string"
1978
+ },
1979
+ "bind": {
1980
+ "title": "Bind",
1981
+ "type": "string"
1982
+ },
1983
+ "min": {
1984
+ "title": "Minimum Value",
1985
+ "type": "number"
1986
+ },
1987
+ "max": {
1988
+ "title": "Maximum Value",
1989
+ "type": "number"
1990
+ },
1991
+ "disabled": {
1992
+ "title": "Disabled",
1993
+ "type": "boolean"
1994
+ },
1995
+ "readOnly": {
1996
+ "title": "Read Only",
1997
+ "type": "boolean"
1998
+ },
1999
+ "hidden": {
2000
+ "title": "Hidden",
2001
+ "type": "boolean"
2002
+ },
2003
+ "readOnlyWidget": {
2004
+ "title": "Read Only Widget",
2005
+ "type": "string"
2006
+ },
2007
+ "width": {
2008
+ "title": "Element Width",
2009
+ "type": "string",
2010
+ "widget": "percentSlider"
2011
+ },
2012
+ "labelWidth": {
2013
+ "title": "Label Width",
2014
+ "description": "Default: 120",
2015
+ "type": "number",
2016
+ "widget": "slider",
2017
+ "max": 400,
2018
+ "props": {
2019
+ "hideNumber": true
2020
+ }
2021
+ }
2022
+ };
1939
2023
 
1940
2024
  // widget 用于指定 schema 右侧配置对应的 setting
1941
2025
  var elements = [{
@@ -2839,7 +2923,7 @@ function GlobalSettings(_ref) {
2839
2923
  }
2840
2924
  }, /*#__PURE__*/React.createElement(FormRender, {
2841
2925
  form: form,
2842
- schema: i18n.language === 'zh-CN' ? defaultGlobalSettings : USdefaultGlobalSettings,
2926
+ schema: i18n.language === 'cn' ? defaultGlobalSettings : USdefaultGlobalSettings,
2843
2927
  watch: {
2844
2928
  '#': function _(v) {
2845
2929
  return onDataChange(v);
@@ -3003,6 +3087,8 @@ var frgWidgets = /*#__PURE__*/Object.freeze({
3003
3087
 
3004
3088
  function ItemSettings(_ref) {
3005
3089
  var widgets = _ref.widgets;
3090
+ var _useTranslation = useTranslation(),
3091
+ i18n = _useTranslation.i18n;
3006
3092
  var setGlobal = useGlobal();
3007
3093
  var form = useForm();
3008
3094
  var isReady = useRef(false);
@@ -3067,7 +3153,7 @@ function ItemSettings(_ref) {
3067
3153
  widgets: [].concat(_toConsumableArray(elements), _toConsumableArray(advancedElements), _toConsumableArray(layouts))
3068
3154
  }]) // TODO: 不是最优解
3069
3155
  : defaultSettings;
3070
- var _commonSettings = isObject(commonSettings) ? commonSettings : defaultCommonSettings;
3156
+ var _commonSettings = isObject(commonSettings) ? commonSettings : i18n.language === 'cn' ? defaultCommonSettings : USdefaultCommonSettings;
3071
3157
  var widgetList = getWidgetList(_settings, _commonSettings);
3072
3158
  var widgetName = getWidgetName(item.schema, globalMapping);
3073
3159
  var element = widgetList.find(function (e) {
@@ -3091,7 +3177,7 @@ function ItemSettings(_ref) {
3091
3177
  isReady.current = true;
3092
3178
  console.error(error);
3093
3179
  }
3094
- }, [selected]);
3180
+ }, [selected, i18n.language]);
3095
3181
  useEffect(function () {
3096
3182
  validation && onItemErrorChange(form === null || form === void 0 ? void 0 : form.errorFields);
3097
3183
  }, [validation, form === null || form === void 0 ? void 0 : form.errorFields]);
package/dist/index.js CHANGED
@@ -1963,6 +1963,90 @@ var defaultCommonSettings = {
1963
1963
  }
1964
1964
  }
1965
1965
  };
1966
+ var USdefaultCommonSettings = {
1967
+ "$id": {
1968
+ "title": "ID",
1969
+ "description": "Field Name / English",
1970
+ "type": "string",
1971
+ "widget": "idInput",
1972
+ "require": true,
1973
+ "rules": [{
1974
+ "pattern": "^#/.+$",
1975
+ "message": "ID is required"
1976
+ }]
1977
+ },
1978
+ "title": {
1979
+ "title": "Title",
1980
+ "type": "string",
1981
+ "widget": "htmlInput"
1982
+ },
1983
+ "displayType": {
1984
+ "title": "Title Display Mode",
1985
+ "type": "string",
1986
+ "enum": ["row", "column"],
1987
+ "enumNames": ["Same Line", "Separate Line"],
1988
+ "widget": "radio"
1989
+ },
1990
+ "description": {
1991
+ "title": "Description",
1992
+ "type": "string"
1993
+ },
1994
+ "default": {
1995
+ "title": "Default Value",
1996
+ "type": "string"
1997
+ },
1998
+ "required": {
1999
+ "title": "Required",
2000
+ "type": "boolean"
2001
+ },
2002
+ "placeholder": {
2003
+ "title": "Placeholder",
2004
+ "type": "string"
2005
+ },
2006
+ "bind": {
2007
+ "title": "Bind",
2008
+ "type": "string"
2009
+ },
2010
+ "min": {
2011
+ "title": "Minimum Value",
2012
+ "type": "number"
2013
+ },
2014
+ "max": {
2015
+ "title": "Maximum Value",
2016
+ "type": "number"
2017
+ },
2018
+ "disabled": {
2019
+ "title": "Disabled",
2020
+ "type": "boolean"
2021
+ },
2022
+ "readOnly": {
2023
+ "title": "Read Only",
2024
+ "type": "boolean"
2025
+ },
2026
+ "hidden": {
2027
+ "title": "Hidden",
2028
+ "type": "boolean"
2029
+ },
2030
+ "readOnlyWidget": {
2031
+ "title": "Read Only Widget",
2032
+ "type": "string"
2033
+ },
2034
+ "width": {
2035
+ "title": "Element Width",
2036
+ "type": "string",
2037
+ "widget": "percentSlider"
2038
+ },
2039
+ "labelWidth": {
2040
+ "title": "Label Width",
2041
+ "description": "Default: 120",
2042
+ "type": "number",
2043
+ "widget": "slider",
2044
+ "max": 400,
2045
+ "props": {
2046
+ "hideNumber": true
2047
+ }
2048
+ }
2049
+ };
1966
2050
 
1967
2051
  // widget 用于指定 schema 右侧配置对应的 setting
1968
2052
  var elements = [{
@@ -2866,7 +2950,7 @@ function GlobalSettings(_ref) {
2866
2950
  }
2867
2951
  }, /*#__PURE__*/React__default['default'].createElement(FormRender__default['default'], {
2868
2952
  form: form,
2869
- schema: i18n.language === 'zh-CN' ? defaultGlobalSettings : USdefaultGlobalSettings,
2953
+ schema: i18n.language === 'cn' ? defaultGlobalSettings : USdefaultGlobalSettings,
2870
2954
  watch: {
2871
2955
  '#': function _(v) {
2872
2956
  return onDataChange(v);
@@ -3030,6 +3114,8 @@ var frgWidgets = /*#__PURE__*/Object.freeze({
3030
3114
 
3031
3115
  function ItemSettings(_ref) {
3032
3116
  var widgets = _ref.widgets;
3117
+ var _useTranslation = reactI18next.useTranslation(),
3118
+ i18n = _useTranslation.i18n;
3033
3119
  var setGlobal = useGlobal();
3034
3120
  var form = FormRender.useForm();
3035
3121
  var isReady = React.useRef(false);
@@ -3094,7 +3180,7 @@ function ItemSettings(_ref) {
3094
3180
  widgets: [].concat(_toConsumableArray(elements), _toConsumableArray(advancedElements), _toConsumableArray(layouts))
3095
3181
  }]) // TODO: 不是最优解
3096
3182
  : defaultSettings;
3097
- var _commonSettings = isObject(commonSettings) ? commonSettings : defaultCommonSettings;
3183
+ var _commonSettings = isObject(commonSettings) ? commonSettings : i18n.language === 'cn' ? defaultCommonSettings : USdefaultCommonSettings;
3098
3184
  var widgetList = getWidgetList(_settings, _commonSettings);
3099
3185
  var widgetName = getWidgetName(item.schema, globalMapping);
3100
3186
  var element = widgetList.find(function (e) {
@@ -3118,7 +3204,7 @@ function ItemSettings(_ref) {
3118
3204
  isReady.current = true;
3119
3205
  console.error(error);
3120
3206
  }
3121
- }, [selected]);
3207
+ }, [selected, i18n.language]);
3122
3208
  React.useEffect(function () {
3123
3209
  validation && onItemErrorChange(form === null || form === void 0 ? void 0 : form.errorFields);
3124
3210
  }, [validation, form === null || form === void 0 ? void 0 : form.errorFields]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yy-forms",
3
- "version": "1.0.35",
3
+ "version": "1.0.37",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.esm.js",
6
6
  "typings": "dist/index.d.ts",
@@ -38,7 +38,7 @@ export default function GlobalSettings({ widgets }) {
38
38
  <div style={{ paddingRight: 24 }}>
39
39
  <FormRender
40
40
  form={form}
41
- schema={i18n.language === 'zh-CN' ? defaultGlobalSettings : USdefaultGlobalSettings}
41
+ schema={i18n.language === 'cn' ? defaultGlobalSettings : USdefaultGlobalSettings}
42
42
  watch={{
43
43
  '#': v => onDataChange(v),
44
44
  }}
@@ -4,16 +4,20 @@ import {
4
4
  advancedElements,
5
5
  baseCommonSettings,
6
6
  defaultCommonSettings,
7
+ USdefaultCommonSettings,
7
8
  defaultSettings,
8
9
  elements,
9
10
  layouts,
10
11
  } from '../../settings';
12
+
11
13
  import { isObject, mergeInOrder } from '../../utils';
12
14
  import { useGlobal, useStore } from '../../utils/hooks';
13
15
  import { getWidgetName } from '../../utils/mapping';
14
16
  import * as frgWidgets from '../../widgets';
17
+ import { useTranslation } from 'react-i18next';
15
18
 
16
19
  export default function ItemSettings({ widgets }) {
20
+ const { i18n } = useTranslation();
17
21
  const setGlobal = useGlobal();
18
22
  const form = useForm();
19
23
  const isReady = useRef(false);
@@ -93,7 +97,7 @@ export default function ItemSettings({ widgets }) {
93
97
  : defaultSettings;
94
98
  const _commonSettings = isObject(commonSettings)
95
99
  ? commonSettings
96
- : defaultCommonSettings;
100
+ : i18n.language === 'cn' ?defaultCommonSettings : USdefaultCommonSettings;
97
101
  const widgetList = getWidgetList(_settings, _commonSettings);
98
102
  const widgetName = getWidgetName(item.schema, globalMapping);
99
103
  const element = widgetList.find(e => e.widget === widgetName) || {}; // 有可能会没有找到
@@ -117,7 +121,7 @@ export default function ItemSettings({ widgets }) {
117
121
  isReady.current = true;
118
122
  console.error(error);
119
123
  }
120
- }, [selected]);
124
+ }, [selected,i18n.language]);
121
125
 
122
126
  useEffect(() => {
123
127
  validation && onItemErrorChange(form?.errorFields);
@@ -104,6 +104,93 @@ export const defaultCommonSettings = {
104
104
  },
105
105
  };
106
106
 
107
+ export const USdefaultCommonSettings = {
108
+ "$id": {
109
+ "title": "ID",
110
+ "description": "Field Name / English",
111
+ "type": "string",
112
+ "widget": "idInput",
113
+ "require": true,
114
+ "rules": [
115
+ {
116
+ "pattern": "^#/.+$",
117
+ "message": "ID is required"
118
+ }
119
+ ]
120
+ },
121
+ "title": {
122
+ "title": "Title",
123
+ "type": "string",
124
+ "widget": "htmlInput"
125
+ },
126
+ "displayType": {
127
+ "title": "Title Display Mode",
128
+ "type": "string",
129
+ "enum": ["row", "column"],
130
+ "enumNames": ["Same Line", "Separate Line"],
131
+ "widget": "radio"
132
+ },
133
+ "description": {
134
+ "title": "Description",
135
+ "type": "string"
136
+ },
137
+ "default": {
138
+ "title": "Default Value",
139
+ "type": "string"
140
+ },
141
+ "required": {
142
+ "title": "Required",
143
+ "type": "boolean"
144
+ },
145
+ "placeholder": {
146
+ "title": "Placeholder",
147
+ "type": "string"
148
+ },
149
+ "bind": {
150
+ "title": "Bind",
151
+ "type": "string"
152
+ },
153
+ "min": {
154
+ "title": "Minimum Value",
155
+ "type": "number"
156
+ },
157
+ "max": {
158
+ "title": "Maximum Value",
159
+ "type": "number"
160
+ },
161
+ "disabled": {
162
+ "title": "Disabled",
163
+ "type": "boolean"
164
+ },
165
+ "readOnly": {
166
+ "title": "Read Only",
167
+ "type": "boolean"
168
+ },
169
+ "hidden": {
170
+ "title": "Hidden",
171
+ "type": "boolean"
172
+ },
173
+ "readOnlyWidget": {
174
+ "title": "Read Only Widget",
175
+ "type": "string"
176
+ },
177
+ "width": {
178
+ "title": "Element Width",
179
+ "type": "string",
180
+ "widget": "percentSlider"
181
+ },
182
+ "labelWidth": {
183
+ "title": "Label Width",
184
+ "description": "Default: 120",
185
+ "type": "number",
186
+ "widget": "slider",
187
+ "max": 400,
188
+ "props": {
189
+ "hideNumber": true
190
+ }
191
+ }
192
+ }
193
+
107
194
  // widget 用于指定 schema 右侧配置对应的 setting
108
195
  export const elements = [
109
196
  {
@@ -1022,6 +1109,7 @@ export const defaultSettings = [
1022
1109
  // },
1023
1110
  ];
1024
1111
 
1112
+
1025
1113
  export const defaultGlobalSettings = {
1026
1114
  type: 'object',
1027
1115
  properties: {