@varlet/ui 3.3.16 → 3.5.0-alpha.1726249557629

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.
Files changed (56) hide show
  1. package/es/auto-complete/AutoComplete.mjs +361 -0
  2. package/es/auto-complete/AutoCompleteSfc.css +0 -0
  3. package/es/auto-complete/autoComplete.css +1 -0
  4. package/es/auto-complete/index.mjs +11 -0
  5. package/es/auto-complete/props.mjs +63 -0
  6. package/es/auto-complete/provide.mjs +0 -0
  7. package/es/auto-complete/style/index.mjs +11 -0
  8. package/es/checkbox/props.mjs +1 -1
  9. package/es/checkbox-group/CheckboxGroup.mjs +3 -5
  10. package/es/checkbox-group/props.mjs +5 -2
  11. package/es/counter/props.mjs +1 -1
  12. package/es/field-decorator/FieldDecorator.mjs +8 -8
  13. package/es/field-decorator/props.mjs +1 -1
  14. package/es/index.bundle.mjs +7 -1
  15. package/es/index.mjs +6 -1
  16. package/es/input/Input.mjs +12 -13
  17. package/es/input/props.mjs +22 -3
  18. package/es/menu-option/MenuOption.mjs +5 -2
  19. package/es/menu-option/menuOption.css +1 -1
  20. package/es/menu-select/MenuSelect.mjs +4 -5
  21. package/es/menu-select/props.mjs +13 -3
  22. package/es/radio/props.mjs +1 -1
  23. package/es/radio-group/RadioGroup.mjs +4 -6
  24. package/es/radio-group/props.mjs +5 -2
  25. package/es/select/Select.mjs +3 -5
  26. package/es/select/props.mjs +5 -2
  27. package/es/slider/props.mjs +1 -1
  28. package/es/style.css +1 -1
  29. package/es/style.mjs +1 -0
  30. package/es/switch/props.mjs +1 -1
  31. package/es/tooltip/Tooltip.mjs +5 -1
  32. package/es/tooltip/props.mjs +1 -0
  33. package/es/uploader/props.mjs +1 -1
  34. package/es/utils/components.mjs +30 -9
  35. package/es/varlet.esm.js +14219 -13843
  36. package/highlight/web-types.en-US.json +268 -30
  37. package/highlight/web-types.zh-CN.json +270 -32
  38. package/lib/style.css +1 -1
  39. package/lib/varlet.cjs.js +15305 -14844
  40. package/package.json +9 -8
  41. package/types/autoComplete.d.ts +84 -0
  42. package/types/checkbox.d.ts +3 -3
  43. package/types/checkboxGroup.d.ts +1 -1
  44. package/types/counter.d.ts +1 -1
  45. package/types/index.d.ts +2 -0
  46. package/types/input.d.ts +2 -1
  47. package/types/radio.d.ts +1 -1
  48. package/types/radioGroup.d.ts +1 -1
  49. package/types/rate.d.ts +1 -1
  50. package/types/select.d.ts +1 -1
  51. package/types/slider.d.ts +1 -1
  52. package/types/styleVars.d.ts +1 -0
  53. package/types/switch.d.ts +1 -1
  54. package/types/tooltip.d.ts +1 -0
  55. package/types/uploader.d.ts +1 -1
  56. package/umd/varlet.js +8 -8
package/es/style.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import './action-sheet/style/index.mjs'
2
2
  import './app-bar/style/index.mjs'
3
+ import './auto-complete/style/index.mjs'
3
4
  import './avatar/style/index.mjs'
4
5
  import './avatar-group/style/index.mjs'
5
6
  import './back-top/style/index.mjs'
@@ -18,7 +18,7 @@ const props = {
18
18
  closeColor: String,
19
19
  size: [String, Number],
20
20
  variant: Boolean,
21
- rules: Array,
21
+ rules: [Array, Function, Object],
22
22
  ripple: {
23
23
  type: Boolean,
24
24
  default: true
@@ -43,7 +43,11 @@ function __render__(_ctx, _cache) {
43
43
  _createElementVNode(
44
44
  "div",
45
45
  {
46
- style: _normalizeStyle({ background: _ctx.color, width: _ctx.sameWidth ? _ctx.toSizeUnit(Math.ceil(_ctx.hostSize.width)) : void 0 }),
46
+ style: _normalizeStyle({
47
+ background: _ctx.color,
48
+ color: _ctx.textColor,
49
+ width: _ctx.sameWidth ? _ctx.toSizeUnit(Math.ceil(_ctx.hostSize.width)) : void 0
50
+ }),
47
51
  class: _normalizeClass(_ctx.classes(_ctx.n("content-container"), _ctx.n(`--${_ctx.type}`))),
48
52
  role: "tooltip"
49
53
  },
@@ -5,6 +5,7 @@ const props = {
5
5
  default: "default"
6
6
  },
7
7
  color: String,
8
+ textColor: String,
8
9
  content: String,
9
10
  show: Boolean,
10
11
  disabled: Boolean,
@@ -41,7 +41,7 @@ const props = {
41
41
  type: Array,
42
42
  default: () => ["onChange", "onRemove"]
43
43
  },
44
- rules: Array,
44
+ rules: [Array, Function, Object],
45
45
  hideList: Boolean,
46
46
  preventDefaultPreview: Boolean,
47
47
  onClickAction: defineListenerProp(),
@@ -48,7 +48,15 @@ import {
48
48
  Fragment,
49
49
  defineComponent
50
50
  } from "vue";
51
- import { createNamespaceFn, isArray, isPlainObject, isString } from "@varlet/shared";
51
+ import {
52
+ createNamespaceFn,
53
+ hasOwn,
54
+ isArray,
55
+ isFunction,
56
+ isPlainObject,
57
+ isString,
58
+ normalizeToArray
59
+ } from "@varlet/shared";
52
60
  function pickProps(props, propsKey) {
53
61
  return isArray(propsKey) ? propsKey.reduce((pickedProps, key) => {
54
62
  pickedProps[key] = props[key];
@@ -124,17 +132,28 @@ function flatFragment(vNodes) {
124
132
  });
125
133
  return result;
126
134
  }
135
+ function isZodRule(rule) {
136
+ return isPlainObject(rule) && isFunction(rule.safeParseAsync);
137
+ }
138
+ function isZodResult(result) {
139
+ return isPlainObject(result) && hasOwn(result, "success");
140
+ }
127
141
  function useValidation() {
128
142
  const errorMessage = ref("");
129
- const validate = (rules, value, apis) => __async(this, null, function* () {
130
- if (!isArray(rules) || !rules.length) {
131
- return true;
132
- }
133
- const resArr = yield Promise.all(rules.map((rule) => rule(value, apis)));
143
+ const validate = (ruleOrRules, value, apis) => __async(this, null, function* () {
144
+ const rules = normalizeToArray(ruleOrRules).filter((rule) => isZodRule(rule) || isFunction(rule));
145
+ const results = yield Promise.all(
146
+ rules.map((rule) => isZodRule(rule) ? rule.safeParseAsync(value) : rule(value, apis))
147
+ );
134
148
  resetValidation();
135
- return !resArr.some((res) => {
136
- if (res !== true) {
137
- errorMessage.value = String(res);
149
+ return !results.some((result) => {
150
+ if (isZodResult(result)) {
151
+ if (result.success === false) {
152
+ errorMessage.value = result.error.issues[0].message;
153
+ return true;
154
+ }
155
+ } else if (result !== true) {
156
+ errorMessage.value = String(result);
138
157
  return true;
139
158
  }
140
159
  return false;
@@ -208,6 +227,8 @@ export {
208
227
  defineListenerProp,
209
228
  flatFragment,
210
229
  formatElevation,
230
+ isZodResult,
231
+ isZodRule,
211
232
  mount,
212
233
  mountInstance,
213
234
  pickProps,