@varlet/ui 3.3.2 → 3.3.4

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.
@@ -93,60 +93,66 @@ function __render__(_ctx, _cache) {
93
93
  6
94
94
  /* CLASS, STYLE */
95
95
  ),
96
- _createElementVNode(
97
- "div",
98
- {
99
- class: _normalizeClass(_ctx.n("actions"))
100
- },
101
- [
102
- _ctx.cancelButton ? (_openBlock(), _createBlock(_component_var_button, {
103
- key: 0,
104
- class: _normalizeClass(_ctx.classes(_ctx.n("button"), _ctx.n("cancel-button"))),
105
- "var-dialog-cover": "",
106
- text: "",
107
- "text-color": _ctx.cancelButtonTextColor,
108
- color: _ctx.cancelButtonColor,
109
- onClick: _ctx.cancel
110
- }, {
111
- default: _withCtx(() => {
112
- var _a;
113
- return [
114
- _createTextVNode(
115
- _toDisplayString((_a = _ctx.cancelButtonText) != null ? _a : (_ctx.pt ? _ctx.pt : _ctx.t)("dialogCancelButtonText")),
116
- 1
117
- /* TEXT */
118
- )
119
- ];
120
- }),
121
- _: 1
122
- /* STABLE */
123
- }, 8, ["class", "text-color", "color", "onClick"])) : _createCommentVNode("v-if", true),
124
- _ctx.confirmButton ? (_openBlock(), _createBlock(_component_var_button, {
125
- key: 1,
126
- class: _normalizeClass(_ctx.classes(_ctx.n("button"), _ctx.n("confirm-button"))),
127
- "var-dialog-cover": "",
128
- text: "",
129
- "text-color": _ctx.confirmButtonTextColor,
130
- color: _ctx.confirmButtonColor,
131
- onClick: _ctx.confirm
132
- }, {
133
- default: _withCtx(() => {
134
- var _a;
135
- return [
136
- _createTextVNode(
137
- _toDisplayString((_a = _ctx.confirmButtonText) != null ? _a : (_ctx.pt ? _ctx.pt : _ctx.t)("dialogConfirmButtonText")),
138
- 1
139
- /* TEXT */
140
- )
141
- ];
142
- }),
143
- _: 1
144
- /* STABLE */
145
- }, 8, ["class", "text-color", "color", "onClick"])) : _createCommentVNode("v-if", true)
146
- ],
147
- 2
148
- /* CLASS */
149
- )
96
+ _renderSlot(_ctx.$slots, "actions", {
97
+ slotClass: _ctx.n("actions"),
98
+ cancel: _ctx.cancel,
99
+ confirm: _ctx.confirm
100
+ }, () => [
101
+ _createElementVNode(
102
+ "div",
103
+ {
104
+ class: _normalizeClass(_ctx.n("actions"))
105
+ },
106
+ [
107
+ _ctx.cancelButton ? (_openBlock(), _createBlock(_component_var_button, {
108
+ key: 0,
109
+ class: _normalizeClass(_ctx.classes(_ctx.n("button"), _ctx.n("cancel-button"))),
110
+ "var-dialog-cover": "",
111
+ text: "",
112
+ "text-color": _ctx.cancelButtonTextColor,
113
+ color: _ctx.cancelButtonColor,
114
+ onClick: _ctx.cancel
115
+ }, {
116
+ default: _withCtx(() => {
117
+ var _a;
118
+ return [
119
+ _createTextVNode(
120
+ _toDisplayString((_a = _ctx.cancelButtonText) != null ? _a : (_ctx.pt ? _ctx.pt : _ctx.t)("dialogCancelButtonText")),
121
+ 1
122
+ /* TEXT */
123
+ )
124
+ ];
125
+ }),
126
+ _: 1
127
+ /* STABLE */
128
+ }, 8, ["class", "text-color", "color", "onClick"])) : _createCommentVNode("v-if", true),
129
+ _ctx.confirmButton ? (_openBlock(), _createBlock(_component_var_button, {
130
+ key: 1,
131
+ class: _normalizeClass(_ctx.classes(_ctx.n("button"), _ctx.n("confirm-button"))),
132
+ "var-dialog-cover": "",
133
+ text: "",
134
+ "text-color": _ctx.confirmButtonTextColor,
135
+ color: _ctx.confirmButtonColor,
136
+ onClick: _ctx.confirm
137
+ }, {
138
+ default: _withCtx(() => {
139
+ var _a;
140
+ return [
141
+ _createTextVNode(
142
+ _toDisplayString((_a = _ctx.confirmButtonText) != null ? _a : (_ctx.pt ? _ctx.pt : _ctx.t)("dialogConfirmButtonText")),
143
+ 1
144
+ /* TEXT */
145
+ )
146
+ ];
147
+ }),
148
+ _: 1
149
+ /* STABLE */
150
+ }, 8, ["class", "text-color", "color", "onClick"])) : _createCommentVNode("v-if", true)
151
+ ],
152
+ 2
153
+ /* CLASS */
154
+ )
155
+ ])
150
156
  ],
151
157
  16
152
158
  /* FULL_PROPS */
@@ -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.2'
268
+ const version = '3.3.4'
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.2'
179
+ const version = '3.3.4'
180
180
 
181
181
  function install(app) {
182
182
  ActionSheet.install && app.use(ActionSheet)
@@ -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,2 +1,2 @@
1
- import '../ripple.css'
2
1
  import '../../styles/common.css'
2
+ import '../ripple.css'
@@ -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'
@@ -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];