@varlet/ui 2.21.0 → 2.22.0-alpha.1705845515578

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.
@@ -169,8 +169,11 @@ const __sfc__ = defineComponent({
169
169
  function validate() {
170
170
  return v(props2.rules, props2.modelValue);
171
171
  }
172
- function validateWithTrigger() {
173
- return nextTick(() => vt(["onChange"], "onChange", props2.rules, props2.modelValue));
172
+ function validateWithTrigger(trigger) {
173
+ nextTick(() => {
174
+ const { validateTrigger, rules, modelValue } = props2;
175
+ vt(validateTrigger, trigger, rules, modelValue);
176
+ });
174
177
  }
175
178
  function switchActive(event) {
176
179
  const {
@@ -182,16 +185,25 @@ const __sfc__ = defineComponent({
182
185
  modelValue,
183
186
  activeValue,
184
187
  inactiveValue,
185
- "onUpdate:modelValue": updateModelValue
188
+ lazyChange,
189
+ "onUpdate:modelValue": updateModelValue,
190
+ onBeforeChange
186
191
  } = props2;
187
192
  call(onClick, event);
188
193
  if (disabled || loading || readonly || (form == null ? void 0 : form.disabled.value) || (form == null ? void 0 : form.readonly.value)) {
189
194
  return;
190
195
  }
191
196
  const newValue = modelValue === activeValue ? inactiveValue : activeValue;
192
- call(onChange, newValue);
193
- call(updateModelValue, newValue);
194
- validateWithTrigger();
197
+ if (lazyChange) {
198
+ call(onBeforeChange, newValue, (value) => {
199
+ call(updateModelValue, value);
200
+ validateWithTrigger("onLazyChange");
201
+ });
202
+ } else {
203
+ call(onChange, newValue);
204
+ call(updateModelValue, newValue);
205
+ validateWithTrigger("onChange");
206
+ }
195
207
  }
196
208
  function hover(value) {
197
209
  if (props2.disabled || (form == null ? void 0 : form.disabled.value)) {
@@ -9,6 +9,7 @@ const props = {
9
9
  inactiveValue: {
10
10
  default: false
11
11
  },
12
+ lazyChange: Boolean,
12
13
  disabled: Boolean,
13
14
  readonly: Boolean,
14
15
  loading: Boolean,
@@ -21,7 +22,12 @@ const props = {
21
22
  type: Boolean,
22
23
  default: true
23
24
  },
25
+ validateTrigger: {
26
+ type: Array,
27
+ default: () => ["onChange", "onLazyChange"]
28
+ },
24
29
  onClick: defineListenerProp(),
30
+ onBeforeChange: defineListenerProp(),
25
31
  onChange: defineListenerProp(),
26
32
  "onUpdate:modelValue": defineListenerProp()
27
33
  };