@varlet/ui 2.15.0-alpha.1693213353380 → 2.15.0

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json",
3
3
  "framework": "vue",
4
- "version": "2.15.0-alpha.1693213353380",
4
+ "version": "2.15.0",
5
5
  "name": "VARLET",
6
6
  "contributions": {
7
7
  "html": {
@@ -2814,7 +2814,16 @@
2814
2814
  }
2815
2815
  }
2816
2816
  ],
2817
- "events": [],
2817
+ "events": [
2818
+ {
2819
+ "name": "submit",
2820
+ "description": "Triggered when the form is submitted"
2821
+ },
2822
+ {
2823
+ "name": "reset",
2824
+ "description": "Fired when the form is reset"
2825
+ }
2826
+ ],
2818
2827
  "slots": [
2819
2828
  {
2820
2829
  "name": "default",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json",
3
3
  "framework": "vue",
4
- "version": "2.15.0-alpha.1693213353380",
4
+ "version": "2.15.0",
5
5
  "name": "VARLET",
6
6
  "contributions": {
7
7
  "html": {
@@ -2973,7 +2973,16 @@
2973
2973
  }
2974
2974
  }
2975
2975
  ],
2976
- "events": [],
2976
+ "events": [
2977
+ {
2978
+ "name": "submit",
2979
+ "description": "表单提交时触发"
2980
+ },
2981
+ {
2982
+ "name": "reset",
2983
+ "description": "表单清空时触发"
2984
+ }
2985
+ ],
2977
2986
  "slots": [
2978
2987
  {
2979
2988
  "name": "default",
package/lib/varlet.cjs.js CHANGED
@@ -637,8 +637,10 @@ function useTouch() {
637
637
  const moveY = vue.ref(0);
638
638
  const direction = vue.ref();
639
639
  const touching = vue.ref(false);
640
+ const dragging = vue.ref(false);
640
641
  const startTime = vue.ref(0);
641
642
  const distance = vue.ref(0);
643
+ let draggingAnimationFrame = null;
642
644
  const resetTouch = () => {
643
645
  startX.value = 0;
644
646
  startY.value = 0;
@@ -652,6 +654,7 @@ function useTouch() {
652
654
  moveY.value = 0;
653
655
  direction.value = void 0;
654
656
  touching.value = false;
657
+ dragging.value = false;
655
658
  startTime.value = 0;
656
659
  distance.value = 0;
657
660
  };
@@ -664,9 +667,14 @@ function useTouch() {
664
667
  prevY.value = y;
665
668
  touching.value = true;
666
669
  startTime.value = performance.now();
670
+ dragging.value = false;
671
+ if (draggingAnimationFrame) {
672
+ window.cancelAnimationFrame(draggingAnimationFrame);
673
+ }
667
674
  };
668
675
  const moveTouch = (event) => {
669
676
  const { clientX: x, clientY: y } = event.touches[0];
677
+ dragging.value = true;
670
678
  deltaX.value = x - startX.value;
671
679
  deltaY.value = y - startY.value;
672
680
  offsetX.value = Math.abs(deltaX.value);
@@ -682,6 +690,9 @@ function useTouch() {
682
690
  };
683
691
  const endTouch = () => {
684
692
  touching.value = false;
693
+ draggingAnimationFrame = window.requestAnimationFrame(() => {
694
+ dragging.value = false;
695
+ });
685
696
  };
686
697
  return {
687
698
  startX,
@@ -696,6 +707,7 @@ function useTouch() {
696
707
  moveY,
697
708
  direction,
698
709
  touching,
710
+ dragging,
699
711
  startTime,
700
712
  distance,
701
713
  resetTouch,
@@ -11041,9 +11053,9 @@ var __sfc__$O = vue.defineComponent({
11041
11053
  });
11042
11054
  var dragged = vue.ref(false);
11043
11055
  var enableTransition = vue.ref(false);
11044
- var dragging = vue.ref(false);
11045
11056
  var {
11046
11057
  touching,
11058
+ dragging,
11047
11059
  moveX,
11048
11060
  moveY,
11049
11061
  startTouch,
@@ -11054,28 +11066,22 @@ var __sfc__$O = vue.defineComponent({
11054
11066
  var {
11055
11067
  disabled: teleportDisabled
11056
11068
  } = useTeleport();
11057
- var draggingRunner = null;
11058
11069
  var handleTouchstart = (event) => {
11059
11070
  if (props2.disabled) {
11060
11071
  return;
11061
11072
  }
11062
- if (draggingRunner) {
11063
- window.clearTimeout(draggingRunner);
11064
- }
11065
- saveXY();
11066
11073
  startTouch(event);
11067
- dragging.value = false;
11074
+ saveXY();
11068
11075
  };
11069
11076
  var handleTouchmove = /* @__PURE__ */ function() {
11070
11077
  var _ref2 = _asyncToGenerator$b(function* (event) {
11071
11078
  if (!touching.value || props2.disabled) {
11072
11079
  return;
11073
11080
  }
11081
+ moveTouch(event);
11074
11082
  event.preventDefault();
11075
11083
  enableTransition.value = false;
11076
11084
  dragged.value = true;
11077
- dragging.value = true;
11078
- moveTouch(event);
11079
11085
  if (props2.direction.includes("x")) {
11080
11086
  x.value += moveX.value;
11081
11087
  }
@@ -11095,9 +11101,6 @@ var __sfc__$O = vue.defineComponent({
11095
11101
  endTouch();
11096
11102
  enableTransition.value = true;
11097
11103
  attract();
11098
- draggingRunner = window.setTimeout(() => {
11099
- dragging.value = false;
11100
- });
11101
11104
  };
11102
11105
  var handleClick = (event) => {
11103
11106
  if (dragging.value) {
@@ -11230,12 +11233,11 @@ var __sfc__$O = vue.defineComponent({
11230
11233
  clampToBoundary();
11231
11234
  };
11232
11235
  var reset = () => {
11236
+ resetTouch();
11233
11237
  enableTransition.value = false;
11234
11238
  dragged.value = false;
11235
- dragging.value = false;
11236
11239
  x.value = 0;
11237
11240
  y.value = 0;
11238
- resetTouch();
11239
11241
  };
11240
11242
  vue.watch(() => props2.boundary, toPxBoundary);
11241
11243
  onWindowResize(resize);
@@ -13377,7 +13379,9 @@ var props$G = {
13377
13379
  scrollToErrorOffsetY: {
13378
13380
  type: [String, Number],
13379
13381
  default: 0
13380
- }
13382
+ },
13383
+ onSubmit: defineListenerProp(),
13384
+ onReset: defineListenerProp()
13381
13385
  };
13382
13386
  function asyncGeneratorStep$9(gen, resolve, reject, _next, _throw, key, arg) {
13383
13387
  try {
@@ -13413,13 +13417,19 @@ var {
13413
13417
  } = createNamespace("form");
13414
13418
  function __render__$K(_ctx, _cache) {
13415
13419
  return vue.openBlock(), vue.createElementBlock(
13416
- "div",
13420
+ "form",
13417
13421
  {
13418
- class: vue.normalizeClass(_ctx.n())
13422
+ class: vue.normalizeClass(_ctx.n()),
13423
+ onSubmit: _cache[0] || (_cache[0] = function() {
13424
+ return _ctx.handleSubmit && _ctx.handleSubmit(...arguments);
13425
+ }),
13426
+ onReset: _cache[1] || (_cache[1] = function() {
13427
+ return _ctx.handleReset && _ctx.handleReset(...arguments);
13428
+ })
13419
13429
  },
13420
13430
  [vue.renderSlot(_ctx.$slots, "default")],
13421
- 2
13422
- /* CLASS */
13431
+ 34
13432
+ /* CLASS, HYDRATE_EVENTS */
13423
13433
  );
13424
13434
  }
13425
13435
  var __sfc__$L = vue.defineComponent({
@@ -13443,12 +13453,27 @@ var __sfc__$L = vue.defineComponent({
13443
13453
  });
13444
13454
  }, 300);
13445
13455
  };
13456
+ var handleSubmit = /* @__PURE__ */ function() {
13457
+ var _ref = _asyncToGenerator$9(function* (event) {
13458
+ event.preventDefault();
13459
+ var valid = yield validate();
13460
+ call(props2.onSubmit, valid);
13461
+ });
13462
+ return function handleSubmit2(_x) {
13463
+ return _ref.apply(this, arguments);
13464
+ };
13465
+ }();
13466
+ var handleReset = (event) => {
13467
+ event.preventDefault();
13468
+ reset();
13469
+ call(props2.onReset);
13470
+ };
13446
13471
  var validate = /* @__PURE__ */ function() {
13447
- var _ref = _asyncToGenerator$9(function* () {
13448
- var res = yield Promise.all(formItems.map((_ref2) => {
13472
+ var _ref2 = _asyncToGenerator$9(function* () {
13473
+ var res = yield Promise.all(formItems.map((_ref3) => {
13449
13474
  var {
13450
13475
  validate: validate2
13451
- } = _ref2;
13476
+ } = _ref3;
13452
13477
  return validate2();
13453
13478
  }));
13454
13479
  if (props2.scrollToError) {
@@ -13464,19 +13489,19 @@ var __sfc__$L = vue.defineComponent({
13464
13489
  return res.every((result2) => result2 === true);
13465
13490
  });
13466
13491
  return function validate2() {
13467
- return _ref.apply(this, arguments);
13492
+ return _ref2.apply(this, arguments);
13468
13493
  };
13469
13494
  }();
13470
- var reset = () => formItems.forEach((_ref3) => {
13495
+ var reset = () => formItems.forEach((_ref4) => {
13471
13496
  var {
13472
13497
  reset: reset2
13473
- } = _ref3;
13498
+ } = _ref4;
13474
13499
  return reset2();
13475
13500
  });
13476
- var resetValidation = () => formItems.forEach((_ref4) => {
13501
+ var resetValidation = () => formItems.forEach((_ref5) => {
13477
13502
  var {
13478
13503
  resetValidation: resetValidation2
13479
- } = _ref4;
13504
+ } = _ref5;
13480
13505
  return resetValidation2();
13481
13506
  });
13482
13507
  var formProvider = {
@@ -13486,6 +13511,8 @@ var __sfc__$L = vue.defineComponent({
13486
13511
  bindFormItems(formProvider);
13487
13512
  return {
13488
13513
  n: n$J,
13514
+ handleSubmit,
13515
+ handleReset,
13489
13516
  validate,
13490
13517
  reset,
13491
13518
  resetValidation
@@ -15538,8 +15565,8 @@ var {
15538
15565
  classes: classes$u
15539
15566
  } = createNamespace("input");
15540
15567
  var _hoisted_1$g = ["placeholder", "enterkeyhint"];
15541
- var _hoisted_2$b = ["id", "disabled", "type", "value", "placeholder", "maxlength", "rows", "enterkeyhint", "inputmode"];
15542
- var _hoisted_3$9 = ["id", "disabled", "type", "value", "placeholder", "maxlength", "enterkeyhint", "inputmode"];
15568
+ var _hoisted_2$b = ["id", "disabled", "readonly", "type", "value", "placeholder", "maxlength", "rows", "enterkeyhint", "inputmode"];
15569
+ var _hoisted_3$9 = ["id", "disabled", "readonly", "type", "value", "placeholder", "maxlength", "enterkeyhint", "inputmode"];
15543
15570
  function __render__$B(_ctx, _cache) {
15544
15571
  var _component_var_field_decorator = vue.resolveComponent("var-field-decorator");
15545
15572
  var _component_var_form_details = vue.resolveComponent("var-form-details");
@@ -15591,7 +15618,8 @@ function __render__$B(_ctx, _cache) {
15591
15618
  ref: "el",
15592
15619
  autocomplete: "new-password",
15593
15620
  id: _ctx.id,
15594
- disabled: _ctx.formDisabled || _ctx.disabled || _ctx.formReadonly || _ctx.readonly,
15621
+ disabled: _ctx.formDisabled || _ctx.disabled,
15622
+ readonly: _ctx.formReadonly || _ctx.readonly,
15595
15623
  type: _ctx.normalizedType,
15596
15624
  value: _ctx.modelValue,
15597
15625
  placeholder: !_ctx.hint ? _ctx.placeholder : void 0,
@@ -15629,7 +15657,8 @@ function __render__$B(_ctx, _cache) {
15629
15657
  ref: "el",
15630
15658
  autocomplete: "new-password",
15631
15659
  id: _ctx.id,
15632
- disabled: _ctx.formDisabled || _ctx.disabled || _ctx.formReadonly || _ctx.readonly,
15660
+ disabled: _ctx.formDisabled || _ctx.disabled,
15661
+ readonly: _ctx.formReadonly || _ctx.readonly,
15633
15662
  type: _ctx.normalizedType,
15634
15663
  value: _ctx.modelValue,
15635
15664
  placeholder: !_ctx.hint ? _ctx.placeholder : void 0,
@@ -17397,9 +17426,9 @@ function __render__$u(_ctx, _cache) {
17397
17426
  return vue.openBlock(), vue.createElementBlock("div", {
17398
17427
  class: vue.normalizeClass(_ctx.n("column")),
17399
17428
  key: c.id,
17400
- onTouchstartPassive: ($event) => _ctx.handleTouchstart(c),
17429
+ onTouchstartPassive: ($event) => _ctx.handleTouchstart($event, c),
17401
17430
  onTouchmove: vue.withModifiers(($event) => _ctx.handleTouchmove($event, c), ["prevent"]),
17402
- onTouchend: ($event) => _ctx.handleTouchend($event, c)
17431
+ onTouchend: ($event) => _ctx.handleTouchend(c)
17403
17432
  }, [vue.createElementVNode("div", {
17404
17433
  class: vue.normalizeClass(_ctx.n("scroller")),
17405
17434
  ref_for: true,
@@ -17489,7 +17518,14 @@ var __sfc__$v = vue.defineComponent({
17489
17518
  var center = vue.computed(() => optionCount.value * optionHeight.value / 2 - optionHeight.value / 2);
17490
17519
  var columnHeight = vue.computed(() => optionCount.value * optionHeight.value);
17491
17520
  var prevIndexes = [];
17492
- var dragging = false;
17521
+ var {
17522
+ prevY,
17523
+ moveY,
17524
+ dragging,
17525
+ startTouch,
17526
+ moveTouch,
17527
+ endTouch
17528
+ } = useTouch();
17493
17529
  var setScrollEl = (el, scrollColumn) => {
17494
17530
  scrollColumn.scrollEl = el;
17495
17531
  };
@@ -17528,30 +17564,27 @@ var __sfc__$v = vue.defineComponent({
17528
17564
  scrollColumn.translate += Math.abs(distance / duration) / 3e-3 * (distance < 0 ? -1 : 1);
17529
17565
  };
17530
17566
  var handleClick = (scrollColumn, index) => {
17531
- if (dragging) {
17567
+ if (dragging.value) {
17532
17568
  return;
17533
17569
  }
17534
17570
  scrollColumn.index = index;
17535
17571
  scrollColumn.scrolling = true;
17536
17572
  scrollTo2(scrollColumn, TRANSITION_DURATION);
17537
17573
  };
17538
- var handleTouchstart = (scrollColumn) => {
17574
+ var handleTouchstart = (event, scrollColumn) => {
17539
17575
  scrollColumn.touching = true;
17540
17576
  scrollColumn.translate = getTranslateY(scrollColumn.scrollEl);
17577
+ startTouch(event);
17541
17578
  };
17542
17579
  var handleTouchmove = (event, scrollColumn) => {
17543
17580
  if (!scrollColumn.touching) {
17544
17581
  return;
17545
17582
  }
17546
- dragging = true;
17583
+ moveTouch(event);
17547
17584
  scrollColumn.scrolling = false;
17548
17585
  scrollColumn.duration = 0;
17549
- var {
17550
- clientY
17551
- } = event.touches[0];
17552
- var deltaY = scrollColumn.prevY !== void 0 ? clientY - scrollColumn.prevY : 0;
17553
- scrollColumn.prevY = clientY;
17554
- scrollColumn.translate += deltaY;
17586
+ scrollColumn.prevY = prevY.value;
17587
+ scrollColumn.translate += moveY.value;
17555
17588
  clampTranslate(scrollColumn);
17556
17589
  var now = performance.now();
17557
17590
  if (now - scrollColumn.momentumTime > MOMENTUM_RECORD_TIME) {
@@ -17559,9 +17592,10 @@ var __sfc__$v = vue.defineComponent({
17559
17592
  scrollColumn.momentumPrevY = scrollColumn.translate;
17560
17593
  }
17561
17594
  };
17562
- var handleTouchend = (event, scrollColumn) => {
17595
+ var handleTouchend = (scrollColumn) => {
17596
+ endTouch();
17563
17597
  scrollColumn.touching = false;
17564
- scrollColumn.prevY = void 0;
17598
+ scrollColumn.prevY = 0;
17565
17599
  var distance = scrollColumn.translate - scrollColumn.momentumPrevY;
17566
17600
  var duration = performance.now() - scrollColumn.momentumTime;
17567
17601
  var shouldMomentum = Math.abs(distance) >= MOMENTUM_ALLOW_DISTANCE && duration <= MOMENTUM_RECORD_TIME;
@@ -17576,9 +17610,6 @@ var __sfc__$v = vue.defineComponent({
17576
17610
  if (!scrollColumn.scrolling) {
17577
17611
  change(scrollColumn);
17578
17612
  }
17579
- requestAnimationFrame(() => {
17580
- dragging = false;
17581
- });
17582
17613
  };
17583
17614
  var handleTransitionend = (scrollColumn) => {
17584
17615
  scrollColumn.scrolling = false;
@@ -17591,8 +17622,8 @@ var __sfc__$v = vue.defineComponent({
17591
17622
  } : column;
17592
17623
  var scrollColumn = {
17593
17624
  id: sid$1++,
17594
- prevY: void 0,
17595
- momentumPrevY: void 0,
17625
+ prevY: 0,
17626
+ momentumPrevY: 0,
17596
17627
  touching: false,
17597
17628
  translate: center.value,
17598
17629
  index: (_normalColumn$initial = normalColumn.initialIndex) != null ? _normalColumn$initial : 0,
@@ -17620,8 +17651,8 @@ var __sfc__$v = vue.defineComponent({
17620
17651
  var index = initial ? (_props$cascadeInitial = props2.cascadeInitialIndexes[scrollColumns2.length]) != null ? _props$cascadeInitial : 0 : 0;
17621
17652
  var scrollColumn = {
17622
17653
  id: sid$1++,
17623
- prevY: void 0,
17624
- momentumPrevY: void 0,
17654
+ prevY: 0,
17655
+ momentumPrevY: 0,
17625
17656
  touching: false,
17626
17657
  translate: center.value,
17627
17658
  index,
@@ -24371,9 +24402,9 @@ const skeleton = "";
24371
24402
  const SkeletonSfc = "";
24372
24403
  const slider = "";
24373
24404
  const SliderSfc = "";
24405
+ const SnackbarSfc = "";
24374
24406
  const snackbar = "";
24375
24407
  const coreSfc = "";
24376
- const SnackbarSfc = "";
24377
24408
  const space = "";
24378
24409
  const step = "";
24379
24410
  const StepSfc = "";
@@ -24400,7 +24431,7 @@ const uploader = "";
24400
24431
  const UploaderSfc = "";
24401
24432
  const watermark = "";
24402
24433
  const WatermarkSfc = "";
24403
- const version = "2.15.0-alpha.1693213353380";
24434
+ const version = "2.15.0";
24404
24435
  function install(app) {
24405
24436
  ActionSheet.install && app.use(ActionSheet);
24406
24437
  AppBar.install && app.use(AppBar);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@varlet/ui",
3
- "version": "2.15.0-alpha.1693213353380",
3
+ "version": "2.15.0",
4
4
  "description": "A material like components library",
5
5
  "main": "lib/varlet.cjs.js",
6
6
  "module": "es/index.mjs",
@@ -46,9 +46,9 @@
46
46
  "@popperjs/core": "^2.11.6",
47
47
  "dayjs": "^1.10.4",
48
48
  "decimal.js": "^10.2.1",
49
- "@varlet/icons": "2.15.0-alpha.1693213353380",
50
- "@varlet/shared": "2.15.0-alpha.1693213353380",
51
- "@varlet/use": "2.15.0-alpha.1693213353380"
49
+ "@varlet/icons": "2.15.0",
50
+ "@varlet/use": "2.15.0",
51
+ "@varlet/shared": "2.15.0"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@vue/runtime-core": "3.3.4",
@@ -64,8 +64,8 @@
64
64
  "typescript": "^5.1.5",
65
65
  "vue": "3.3.4",
66
66
  "vue-router": "4.2.0",
67
- "@varlet/cli": "2.15.0-alpha.1693213353380",
68
- "@varlet/touch-emulator": "2.15.0-alpha.1693213353380"
67
+ "@varlet/touch-emulator": "2.15.0",
68
+ "@varlet/cli": "2.15.0"
69
69
  },
70
70
  "browserslist": [
71
71
  "Chrome >= 54",
package/types/form.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { VarComponent, BasicAttributes } from './varComponent'
1
+ import { VarComponent, BasicAttributes, ListenerProp } from './varComponent'
2
2
  import { ComputedRef, VNode, Ref } from 'vue'
3
3
 
4
4
  export declare const formProps: Record<string, any>
@@ -21,6 +21,8 @@ export interface FormProps extends BasicAttributes {
21
21
  readonly?: boolean
22
22
  scrollToError?: FormScrollToError
23
23
  scrollToErrorOffsetY?: number | string
24
+ onSubmit?: ListenerProp<(valid: boolean) => void>
25
+ onReset?: ListenerProp<() => void>
24
26
  }
25
27
 
26
28
  export class Form extends VarComponent {