@varlet/ui 3.3.3 → 3.3.5-alpha.1720530125141

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 CHANGED
@@ -3,7 +3,7 @@
3
3
  <img src="https://varlet.pages.dev/logo.svg" width="150">
4
4
  </a>
5
5
  <h1>VARLET</h1>
6
- <p>A mobile component library based on Vue3, Material Design 2, Material Design 3, and supports desktop development.</p>
6
+ <p>A Vue3 component library based on Material Design 2 and 3, supporting mobile and desktop.</p>
7
7
  <p>
8
8
  <a href="https://varlet.pages.dev/#/en-US/index">Documentation(Cloudflare)</a> |
9
9
  <a href="https://varlet-varletjs.vercel.app/#/en-US/index">Documentation(Vercel)</a> |
@@ -24,7 +24,7 @@
24
24
 
25
25
  ### Intro
26
26
 
27
- Varlet is a Material design mobile component library developed based on `Vue3`, developed and maintained by `varletjs` community team.
27
+ Varlet is a `Vue3` component library based on Material Design 2 and 3, supporting mobile and desktop, developed and maintained by `varletjs` organization.
28
28
 
29
29
 
30
30
  ### Features
package/README.zh-CN.md CHANGED
@@ -4,7 +4,7 @@
4
4
  <img src="https://varlet.pages.dev/logo.svg" width="150">
5
5
  </a>
6
6
  <h1>VARLET</h1>
7
- <p>一个移动端组件库,基于 Vue3, Material Design 2, Material Design 3,并支持桌面端开发。</p>
7
+ <p>一个 Vue3 组件库,基于 Material Design 2 3,支持移动端、桌面端。</p>
8
8
  <p>
9
9
  <a href="https://varlet.pages.dev">文档(Cloudflare)</a> |
10
10
  <a href="https://varlet-varletjs.vercel.app">文档(Vercel)</a> |
@@ -25,7 +25,7 @@
25
25
 
26
26
  ### 介绍
27
27
 
28
- Varlet 是一个基于 `Vue3` 开发的 Material 风格移动端组件库,全面拥抱 `Vue3` 生态,由 `varletjs` 社区团队进行维护。
28
+ Varlet 是一个 `Vue3` 组件库,基于 Material Design 2 3,支持移动端、桌面端,由 `varletjs` 组织维护。
29
29
 
30
30
  ### 特性
31
31
 
@@ -130,7 +130,7 @@ createApp(App).use(Varlet).mount('#app')
130
130
 
131
131
  ### 反馈和交流
132
132
 
133
- 我们推荐使用`issue`列表进行最直接有效的反馈,也可以下面的方式
133
+ 我们推荐使用 [issue](https://github.com/varletjs/varlet/issues) 列表进行最直接有效的反馈,也可以下面的方式
134
134
 
135
135
  * 微信
136
136
 
@@ -265,7 +265,7 @@ import './tooltip/style/index.mjs'
265
265
  import './uploader/style/index.mjs'
266
266
  import './watermark/style/index.mjs'
267
267
 
268
- const version = '3.3.3'
268
+ const version = '3.3.5-alpha.1720530125141'
269
269
 
270
270
  function install(app) {
271
271
  ActionSheet.install && app.use(ActionSheet)
package/es/index.mjs CHANGED
@@ -176,7 +176,7 @@ export * from './tooltip/index.mjs'
176
176
  export * from './uploader/index.mjs'
177
177
  export * from './watermark/index.mjs'
178
178
 
179
- const version = '3.3.3'
179
+ const version = '3.3.5-alpha.1720530125141'
180
180
 
181
181
  function install(app) {
182
182
  ActionSheet.install && app.use(ActionSheet)
@@ -252,7 +252,7 @@ const __sfc__ = defineComponent({
252
252
  if (props2.type === "number") {
253
253
  value = formatNumber(value);
254
254
  }
255
- const targetValue = withMaxlength(withTrim(value));
255
+ const targetValue = withMaxlength(value);
256
256
  if (targetValue === props2.modelValue) {
257
257
  target.value = targetValue;
258
258
  }
@@ -278,7 +278,10 @@ const __sfc__ = defineComponent({
278
278
  validateWithTrigger("onInput");
279
279
  }
280
280
  function handleChange(e) {
281
- const value = updateValue(e);
281
+ const value = withTrim(updateValue(e));
282
+ if (props2.modelModifiers.trim) {
283
+ call(props2["onUpdate:modelValue"], value);
284
+ }
282
285
  call(props2.onChange, value, e);
283
286
  validateWithTrigger("onChange");
284
287
  }
@@ -4,16 +4,17 @@ import Hover from "../hover/index.mjs";
4
4
  import VarHoverOverlay, { useHoverOverlay } from "../hover-overlay/index.mjs";
5
5
  import { defineComponent, computed, ref, watch } from "vue";
6
6
  import { useSelect } from "./provide.mjs";
7
- import { createNamespace } from "../utils/components.mjs";
7
+ import { createNamespace, MaybeVNode } from "../utils/components.mjs";
8
8
  import { props } from "./props.mjs";
9
- import { preventDefault } from "@varlet/shared";
9
+ import { preventDefault, isFunction } from "@varlet/shared";
10
10
  import { useEventListener } from "@varlet/use";
11
11
  const { name, n, classes } = createNamespace("option");
12
- import { normalizeClass as _normalizeClass, normalizeStyle as _normalizeStyle, createElementVNode as _createElementVNode, resolveComponent as _resolveComponent, withModifiers as _withModifiers, openBlock as _openBlock, createBlock as _createBlock, createCommentVNode as _createCommentVNode, renderSlot as _renderSlot, toDisplayString as _toDisplayString, createVNode as _createVNode, resolveDirective as _resolveDirective, createElementBlock as _createElementBlock, withDirectives as _withDirectives, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue";
12
+ import { normalizeClass as _normalizeClass, normalizeStyle as _normalizeStyle, createElementVNode as _createElementVNode, resolveComponent as _resolveComponent, withModifiers as _withModifiers, openBlock as _openBlock, createBlock as _createBlock, createCommentVNode as _createCommentVNode, renderSlot as _renderSlot, createVNode as _createVNode, resolveDirective as _resolveDirective, createElementBlock as _createElementBlock, withDirectives as _withDirectives, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue";
13
13
  const _withScopeId = (n2) => (_pushScopeId(""), n2 = n2(), _popScopeId(), n2);
14
14
  const _hoisted_1 = ["tabindex"];
15
15
  function __render__(_ctx, _cache) {
16
16
  const _component_var_checkbox = _resolveComponent("var-checkbox");
17
+ const _component_maybe_v_node = _resolveComponent("maybe-v-node");
17
18
  const _component_var_hover_overlay = _resolveComponent("var-hover-overlay");
18
19
  const _directive_ripple = _resolveDirective("ripple");
19
20
  const _directive_hover = _resolveDirective("hover");
@@ -57,9 +58,11 @@ function __render__(_ctx, _cache) {
57
58
  {
58
59
  class: _normalizeClass(_ctx.classes(_ctx.n("text"), _ctx.n("$--ellipsis")))
59
60
  },
60
- _toDisplayString(_ctx.label),
61
- 3
62
- /* TEXT, CLASS */
61
+ [
62
+ _createVNode(_component_maybe_v_node, { is: _ctx.labelVNode }, null, 8, ["is"])
63
+ ],
64
+ 2
65
+ /* CLASS */
63
66
  )
64
67
  ]),
65
68
  _createVNode(_component_var_hover_overlay, {
@@ -76,7 +79,8 @@ const __sfc__ = defineComponent({
76
79
  directives: { Ripple, Hover },
77
80
  components: {
78
81
  VarCheckbox,
79
- VarHoverOverlay
82
+ VarHoverOverlay,
83
+ MaybeVNode
80
84
  },
81
85
  props,
82
86
  setup(props2) {
@@ -84,13 +88,25 @@ const __sfc__ = defineComponent({
84
88
  const isFocusing = ref(false);
85
89
  const optionSelected = ref(false);
86
90
  const selected = computed(() => optionSelected.value);
87
- const label = computed(() => props2.label);
91
+ const labelVNode = computed(
92
+ () => {
93
+ var _a;
94
+ return isFunction(props2.label) ? props2.label(
95
+ (_a = props2.option) != null ? _a : {
96
+ label: props2.label,
97
+ value: props2.value,
98
+ disabled: props2.disabled
99
+ },
100
+ optionSelected.value
101
+ ) : props2.label;
102
+ }
103
+ );
88
104
  const value = computed(() => props2.value);
89
105
  const { select, bindSelect } = useSelect();
90
106
  const { multiple, focusColor, onSelect, computeLabel } = select;
91
107
  const { hovering, handleHovering } = useHoverOverlay();
92
108
  const optionProvider = {
93
- label,
109
+ label: labelVNode,
94
110
  value,
95
111
  selected,
96
112
  sync
@@ -141,6 +157,7 @@ const __sfc__ = defineComponent({
141
157
  focusColor,
142
158
  hovering,
143
159
  isFocusing,
160
+ labelVNode,
144
161
  n,
145
162
  classes,
146
163
  handleHovering,
@@ -1,7 +1,9 @@
1
1
  const props = {
2
2
  label: {},
3
3
  value: {},
4
- disabled: Boolean
4
+ disabled: Boolean,
5
+ // internal
6
+ option: Object
5
7
  };
6
8
  export {
7
9
  props
@@ -1,12 +1,13 @@
1
1
  import VarIcon from "../icon/index.mjs";
2
2
  import VarMenu from "../menu/index.mjs";
3
3
  import VarChip from "../chip/index.mjs";
4
+ import VarOption from "../option/index.mjs";
4
5
  import VarFieldDecorator from "../field-decorator/index.mjs";
5
6
  import VarFormDetails from "../form-details/index.mjs";
6
7
  import { computed, defineComponent, ref, watch, nextTick } from "vue";
7
- import { isArray, isEmpty, call, preventDefault, doubleRaf } from "@varlet/shared";
8
+ import { isArray, isEmpty, call, preventDefault, doubleRaf, isFunction } from "@varlet/shared";
8
9
  import { props } from "./props.mjs";
9
- import { useValidation, createNamespace } from "../utils/components.mjs";
10
+ import { useValidation, createNamespace, MaybeVNode } from "../utils/components.mjs";
10
11
  import { useOptions } from "./provide.mjs";
11
12
  import { useForm } from "../form/provide.mjs";
12
13
  import { focusChildElementByKey, toPxNum } from "../utils/elements.mjs";
@@ -14,14 +15,15 @@ import { error } from "../utils/logger.mjs";
14
15
  import { useSelectController } from "./useSelectController.mjs";
15
16
  import { useEventListener } from "@varlet/use";
16
17
  const { name, n, classes } = createNamespace("select");
17
- import { renderSlot as _renderSlot, renderList as _renderList, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, resolveComponent as _resolveComponent, withModifiers as _withModifiers, normalizeClass as _normalizeClass, withCtx as _withCtx, createBlock as _createBlock, createCommentVNode as _createCommentVNode, createElementVNode as _createElementVNode, normalizeStyle as _normalizeStyle, createVNode as _createVNode, normalizeProps as _normalizeProps, guardReactiveProps as _guardReactiveProps, createSlots as _createSlots, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue";
18
+ import { renderSlot as _renderSlot, renderList as _renderList, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock, resolveComponent as _resolveComponent, createVNode as _createVNode, withModifiers as _withModifiers, normalizeClass as _normalizeClass, withCtx as _withCtx, createBlock as _createBlock, createCommentVNode as _createCommentVNode, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, createElementVNode as _createElementVNode, normalizeStyle as _normalizeStyle, normalizeProps as _normalizeProps, guardReactiveProps as _guardReactiveProps, createSlots as _createSlots, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue";
18
19
  const _withScopeId = (n2) => (_pushScopeId(""), n2 = n2(), _popScopeId(), n2);
19
20
  const _hoisted_1 = ["tabindex"];
20
- const _hoisted_2 = { key: 1 };
21
21
  function __render__(_ctx, _cache) {
22
+ const _component_maybe_v_node = _resolveComponent("maybe-v-node");
22
23
  const _component_var_chip = _resolveComponent("var-chip");
23
24
  const _component_var_icon = _resolveComponent("var-icon");
24
25
  const _component_var_field_decorator = _resolveComponent("var-field-decorator");
26
+ const _component_var_option = _resolveComponent("var-option");
25
27
  const _component_var_menu = _resolveComponent("var-menu");
26
28
  const _component_var_form_details = _resolveComponent("var-form-details");
27
29
  return _openBlock(), _createElementBlock("div", {
@@ -54,6 +56,21 @@ function __render__(_ctx, _cache) {
54
56
  class: _normalizeClass(_ctx.classes(_ctx.n("scroller"), _ctx.n("$-elevation--3")))
55
57
  },
56
58
  [
59
+ _ctx.selectOptions.length ? (_openBlock(true), _createElementBlock(
60
+ _Fragment,
61
+ { key: 0 },
62
+ _renderList(_ctx.selectOptions, (option) => {
63
+ return _openBlock(), _createBlock(_component_var_option, {
64
+ key: option[_ctx.valueKey],
65
+ label: option[_ctx.labelKey],
66
+ value: option[_ctx.valueKey],
67
+ option,
68
+ disabled: option.disabled
69
+ }, null, 8, ["label", "value", "option", "disabled"]);
70
+ }),
71
+ 128
72
+ /* KEYED_FRAGMENT */
73
+ )) : _createCommentVNode("v-if", true),
57
74
  _renderSlot(_ctx.$slots, "default")
58
75
  ],
59
76
  2
@@ -134,11 +151,7 @@ function __render__(_ctx, _cache) {
134
151
  onClose: () => _ctx.handleClose(l)
135
152
  }, {
136
153
  default: _withCtx(() => [
137
- _createTextVNode(
138
- _toDisplayString(l),
139
- 1
140
- /* TEXT */
141
- )
154
+ _createVNode(_component_maybe_v_node, { is: l }, null, 8, ["is"])
142
155
  ]),
143
156
  _: 2
144
157
  /* DYNAMIC */
@@ -156,20 +169,40 @@ function __render__(_ctx, _cache) {
156
169
  key: 1,
157
170
  class: _normalizeClass(_ctx.n("values"))
158
171
  },
159
- _toDisplayString(_ctx.labels.join(_ctx.separator)),
160
- 3
161
- /* TEXT, CLASS */
172
+ [
173
+ (_openBlock(true), _createElementBlock(
174
+ _Fragment,
175
+ null,
176
+ _renderList(_ctx.labels, (l, labelIndex) => {
177
+ return _openBlock(), _createElementBlock(
178
+ _Fragment,
179
+ { key: l },
180
+ [
181
+ _createVNode(_component_maybe_v_node, { is: l }, null, 8, ["is"]),
182
+ _createTextVNode(
183
+ _toDisplayString(labelIndex !== _ctx.labels.length - 1 ? _ctx.separator : ""),
184
+ 1
185
+ /* TEXT */
186
+ )
187
+ ],
188
+ 64
189
+ /* STABLE_FRAGMENT */
190
+ );
191
+ }),
192
+ 128
193
+ /* KEYED_FRAGMENT */
194
+ ))
195
+ ],
196
+ 2
197
+ /* CLASS */
162
198
  ))
163
199
  ],
164
200
  64
165
201
  /* STABLE_FRAGMENT */
166
- )) : (_openBlock(), _createElementBlock(
167
- "span",
168
- _hoisted_2,
169
- _toDisplayString(_ctx.label),
170
- 1
171
- /* TEXT */
172
- ))
202
+ )) : (_openBlock(), _createBlock(_component_maybe_v_node, {
203
+ key: 1,
204
+ is: _ctx.label
205
+ }, null, 8, ["is"]))
173
206
  ]) : _createCommentVNode("v-if", true)
174
207
  ],
175
208
  2
@@ -235,8 +268,10 @@ const __sfc__ = defineComponent({
235
268
  VarIcon,
236
269
  VarMenu,
237
270
  VarChip,
271
+ VarOption,
238
272
  VarFieldDecorator,
239
- VarFormDetails
273
+ VarFormDetails,
274
+ MaybeVNode
240
275
  },
241
276
  props,
242
277
  setup(props2) {
@@ -247,6 +282,7 @@ const __sfc__ = defineComponent({
247
282
  const focusColor = computed(() => props2.focusColor);
248
283
  const isEmptyModelValue = computed(() => isEmpty(props2.modelValue));
249
284
  const cursor = computed(() => props2.disabled || props2.readonly ? "" : "pointer");
285
+ const selectOptions = computed(() => isArray(props2.options) ? props2.options : []);
250
286
  const offsetY = ref(0);
251
287
  const { bindForm, form } = useForm();
252
288
  const { length, options, bindOptions } = useOptions();
@@ -462,6 +498,8 @@ const __sfc__ = defineComponent({
462
498
  cursor,
463
499
  placeholderColor,
464
500
  enableCustomPlaceholder,
501
+ selectOptions,
502
+ isFunction,
465
503
  n,
466
504
  classes,
467
505
  handleFocus,
@@ -21,6 +21,15 @@ const props = __spreadValues({
21
21
  type: [String, Number, Boolean, Array],
22
22
  default: void 0
23
23
  },
24
+ options: Array,
25
+ labelKey: {
26
+ type: String,
27
+ default: "label"
28
+ },
29
+ valueKey: {
30
+ type: String,
31
+ default: "value"
32
+ },
24
33
  multiple: Boolean,
25
34
  offsetY: {
26
35
  type: [String, Number],
@@ -5,5 +5,6 @@ import '../../menu/menu.css'
5
5
  import '../../field-decorator/fieldDecorator.css'
6
6
  import '../../form-details/formDetails.css'
7
7
  import '../../chip/chip.css'
8
+ import '../../option/option.css'
8
9
  import '../select.css'
9
10
  import '../SelectSfc.css'
@@ -1,7 +1,7 @@
1
1
  import '../../styles/common.css'
2
+ import '../SnackbarSfc.css'
2
3
  import '../../styles/elevation.css'
3
4
  import '../../loading/loading.css'
4
5
  import '../../icon/icon.css'
5
6
  import '../snackbar.css'
6
7
  import '../coreSfc.css'
7
- import '../SnackbarSfc.css'
@@ -50,7 +50,7 @@ import {
50
50
  } from "vue";
51
51
  import { createNamespaceFn, isArray, isPlainObject, isString } from "@varlet/shared";
52
52
  function pickProps(props, propsKey) {
53
- return Array.isArray(propsKey) ? propsKey.reduce((pickedProps, key) => {
53
+ return isArray(propsKey) ? propsKey.reduce((pickedProps, key) => {
54
54
  pickedProps[key] = props[key];
55
55
  return pickedProps;
56
56
  }, {}) : props[propsKey];