cosey 0.4.23 → 0.4.25

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.
@@ -118,6 +118,9 @@ var stdin_default = getOverrideStyleHook("OverrideElementPlus", (token) => {
118
118
  ".el-radio": {
119
119
  "--el-radio-font-weight": "normal"
120
120
  },
121
+ ".el-radio-button__inner": {
122
+ fontWeight: "normal"
123
+ },
121
124
  ".el-radio__input.is-checked+.el-radio__label": {
122
125
  color: token.colorText
123
126
  },
@@ -12,7 +12,10 @@ import { reactiveOmit } from '@vueuse/core';
12
12
  import { useToken } from '../theme/util/useToken.js';
13
13
  import { omitUndefined } from '../../utils/object.js';
14
14
  import { useComponentConfig } from '../config-provider/config-provider.js';
15
+ import { useLocale } from '../../hooks/useLocale.js';
15
16
  import { createMergedExpose, defineTemplate } from '../../utils/vue.js';
17
+ import { toArray } from '../../utils/array.js';
18
+ import { isString, isNumber } from '../../utils/is.js';
16
19
 
17
20
  var stdin_default = /* @__PURE__ */defineComponent({
18
21
  ...{
@@ -132,6 +135,9 @@ var stdin_default = /* @__PURE__ */defineComponent({
132
135
  const {
133
136
  hashId
134
137
  } = useToken();
138
+ const {
139
+ t
140
+ } = useLocale();
135
141
  const formItemProps = reactiveOmit(props, "colProps", "width", "fieldType", "fieldProps", "fieldRef", "modelValue", "placeholder", "disabled", "readonly");
136
142
  const attrs = useAttrs();
137
143
  const slots = useSlots();
@@ -155,10 +161,42 @@ var stdin_default = /* @__PURE__ */defineComponent({
155
161
  });
156
162
  });
157
163
  const fixedWidthStyle = useFormItemWidth(props, formContext);
164
+ const mergedRules = computed(() => {
165
+ const {
166
+ required
167
+ } = props;
168
+ const rules = toArray(props.rules || []);
169
+ if (required !== void 0) {
170
+ const requiredRules = rules.map((rule, i) => [rule, i]).filter(([rule]) => Object.keys(rule).includes("required"));
171
+ if (requiredRules.length > 0) {
172
+ for (const [rule, i] of requiredRules) {
173
+ if (rule.required === required) continue;
174
+ rules[i] = {
175
+ ...rule,
176
+ required
177
+ };
178
+ }
179
+ } else {
180
+ rules.push({
181
+ required
182
+ });
183
+ }
184
+ }
185
+ const requiredMsg = isString(props.label) || isNumber(props.label) ? t("co.form.isRequired", {
186
+ label: props.label
187
+ }) : t("co.form.required");
188
+ rules.forEach(rule => {
189
+ if (rule.required && !rule.message) {
190
+ rule.message = requiredMsg;
191
+ }
192
+ });
193
+ return rules;
194
+ });
158
195
  const mergedFormItemProps = computed(() => {
159
196
  return {
160
197
  ...(formContext?.grid ? null : attrs),
161
- ...formItemProps
198
+ ...formItemProps,
199
+ rules: mergedRules.value
162
200
  };
163
201
  });
164
202
  const mergedFieldProps = computed(() => {
@@ -27,6 +27,8 @@ declare const _default: {
27
27
  submit: string;
28
28
  reset: string;
29
29
  search: string;
30
+ required: string;
31
+ isRequired: string;
30
32
  };
31
33
  colorPicker: {
32
34
  preset: string;
package/locale/lang/ar.js CHANGED
@@ -29,7 +29,9 @@ var stdin_default = {
29
29
  weekOfYear: "\u0627\u0644\u0623\u0633\u0628\u0648\u0639 w \u0645\u0646 \u0633\u0646\u0629 YYYY",
30
30
  submit: "\u0625\u0631\u0633\u0627\u0644",
31
31
  reset: "\u0625\u0639\u0627\u062F\u0629 \u062A\u0639\u064A\u064A\u0646",
32
- search: "\u0628\u062D\u062B"
32
+ search: "\u0628\u062D\u062B",
33
+ required: "\u0645\u0637\u0644\u0648\u0628",
34
+ isRequired: "\u0645\u0637\u0644\u0648\u0628"
33
35
  },
34
36
  colorPicker: {
35
37
  preset: "\u0625\u0639\u062F\u0627\u062F\u0627\u062A \u0645\u0633\u0628\u0642\u0629",
@@ -27,6 +27,8 @@ declare const _default: {
27
27
  submit: string;
28
28
  reset: string;
29
29
  search: string;
30
+ required: string;
31
+ isRequired: string;
30
32
  };
31
33
  colorPicker: {
32
34
  preset: string;
package/locale/lang/en.js CHANGED
@@ -29,7 +29,9 @@ var stdin_default = {
29
29
  weekOfYear: "Week w, YYYY",
30
30
  submit: "Submit",
31
31
  reset: "Reset",
32
- search: "Search"
32
+ search: "Search",
33
+ required: "required",
34
+ isRequired: "{label} is required"
33
35
  },
34
36
  colorPicker: {
35
37
  preset: "Preset",
@@ -27,6 +27,8 @@ declare const _default: {
27
27
  submit: string;
28
28
  reset: string;
29
29
  search: string;
30
+ required: string;
31
+ isRequired: string;
30
32
  };
31
33
  colorPicker: {
32
34
  preset: string;
@@ -29,7 +29,9 @@ var stdin_default = {
29
29
  weekOfYear: "YYYY-\u7B2Cw\u5468",
30
30
  submit: "\u63D0\u4EA4",
31
31
  reset: "\u91CD\u7F6E",
32
- search: "\u67E5\u8BE2"
32
+ search: "\u67E5\u8BE2",
33
+ required: "\u5FC5\u586B",
34
+ isRequired: "{label}\u662F\u5FC5\u586B\u9879"
33
35
  },
34
36
  colorPicker: {
35
37
  preset: "\u9884\u8BBE",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cosey",
3
- "version": "0.4.23",
3
+ "version": "0.4.25",
4
4
  "description": "基于 Vue3 + vite 的后台管理系统框架",
5
5
  "type": "module",
6
6
  "main": "index.js",
package/utils/array.d.ts CHANGED
@@ -10,3 +10,7 @@ export declare function toArray(target: unknown): any[];
10
10
  * 判断两数组元素是否一致
11
11
  */
12
12
  export declare function isShallowEqual(arr1: unknown[], arr2: unknown[]): boolean;
13
+ /**
14
+ * 移除数组对象中的唯一键
15
+ */
16
+ export declare function omitUniqueKey<T extends object>(arr: T[], key?: string): Pick<T, Exclude<keyof T, string>>[];
package/utils/array.js CHANGED
@@ -1,3 +1,5 @@
1
+ import { omit } from 'lodash-es';
2
+
1
3
  function arrayMove(arr, fromIndex, toIndex) {
2
4
  if (fromIndex === toIndex) {
3
5
  return arr;
@@ -13,5 +15,10 @@ function toArray(target) {
13
15
  function isShallowEqual(arr1, arr2) {
14
16
  return arr1.length === arr2.length && arr1.every((item, i) => item === arr2[i]);
15
17
  }
18
+ function omitUniqueKey(arr, key = "_uniqid") {
19
+ return arr.map((item) => {
20
+ return omit(item, key);
21
+ });
22
+ }
16
23
 
17
- export { arrayMove, isShallowEqual, toArray };
24
+ export { arrayMove, isShallowEqual, omitUniqueKey, toArray };
package/utils/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { arrayMove, isShallowEqual, toArray } from './array.js';
1
+ export { arrayMove, isShallowEqual, omitUniqueKey, toArray } from './array.js';
2
2
  export { getCssVarProp } from './bem.js';
3
3
  export { getControlKey } from './browser.js';
4
4
  export { getLabelByValue, getTreeLabelByValue } from './collection.js';