@varlet/ui 3.16.1 → 3.17.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.
Files changed (49) hide show
  1. package/es/action-sheet/style/index.mjs +1 -1
  2. package/es/card/Card.mjs +35 -6
  3. package/es/card/props.mjs +8 -2
  4. package/es/hover-overlay/HoverOverlay.mjs +5 -4
  5. package/es/hover-overlay/props.mjs +2 -1
  6. package/es/index.bundle.mjs +13 -1
  7. package/es/index.mjs +11 -1
  8. package/es/paper/Paper.mjs +34 -5
  9. package/es/paper/props.mjs +8 -2
  10. package/es/segmented-button/SegmentedButton.mjs +141 -0
  11. package/es/segmented-button/SegmentedButtonSfc.css +0 -0
  12. package/es/segmented-button/index.mjs +12 -0
  13. package/es/segmented-button/props.mjs +17 -0
  14. package/es/segmented-button/provide.mjs +16 -0
  15. package/es/segmented-button/segmentedButton.css +1 -0
  16. package/es/segmented-button/style/index.mjs +5 -0
  17. package/es/segmented-buttons/SegmentedButtons.mjs +218 -0
  18. package/es/segmented-buttons/SegmentedButtonsSfc.css +0 -0
  19. package/es/segmented-buttons/index.mjs +12 -0
  20. package/es/segmented-buttons/props.mjs +38 -0
  21. package/es/segmented-buttons/provide.mjs +16 -0
  22. package/es/segmented-buttons/segmentedButtons.css +1 -0
  23. package/es/segmented-buttons/style/index.mjs +7 -0
  24. package/es/style.mjs +2 -0
  25. package/es/themes/dark/index.mjs +4 -2
  26. package/es/themes/dark/segmentedButton.mjs +22 -0
  27. package/es/themes/dark/segmentedButtons.mjs +11 -0
  28. package/es/themes/md3-dark/index.mjs +4 -2
  29. package/es/themes/md3-dark/segmentedButton.mjs +22 -0
  30. package/es/themes/md3-dark/segmentedButtons.mjs +11 -0
  31. package/es/themes/md3-light/index.mjs +4 -2
  32. package/es/themes/md3-light/segmentedButton.mjs +22 -0
  33. package/es/themes/md3-light/segmentedButtons.mjs +11 -0
  34. package/es/utils/components.mjs +1 -1
  35. package/es/varlet.css +1 -1
  36. package/es/varlet.esm.js +6537 -6071
  37. package/highlight/web-types.en-US.json +164 -9
  38. package/highlight/web-types.zh-CN.json +164 -9
  39. package/lib/varlet.cjs.js +2068 -1505
  40. package/lib/varlet.css +1 -1
  41. package/package.json +7 -7
  42. package/types/card.d.ts +12 -2
  43. package/types/hoverOverlay.d.ts +2 -0
  44. package/types/index.d.ts +4 -0
  45. package/types/paper.d.ts +12 -2
  46. package/types/segmentedButton.d.ts +33 -0
  47. package/types/segmentedButtons.d.ts +58 -0
  48. package/types/styleVars.d.ts +23 -0
  49. package/umd/varlet.js +7 -7
@@ -3,5 +3,5 @@ import '../../icon/icon.css'
3
3
  import '../../ripple/ripple.css'
4
4
  import '../../popup/popup.css'
5
5
  import '../actionSheet.css'
6
- import '../ActionItemSfc.css'
7
6
  import '../ActionSheetSfc.css'
7
+ import '../ActionItemSfc.css'
package/es/card/Card.mjs CHANGED
@@ -18,7 +18,7 @@ var __async = (__this, __arguments, generator) => {
18
18
  step((generator = generator.apply(__this, __arguments)).next());
19
19
  });
20
20
  };
21
- import { call, doubleRaf, getRect } from "@varlet/shared";
21
+ import { call, doubleRaf, getRect, isPlainObject } from "@varlet/shared";
22
22
  import { computed, defineComponent, nextTick, ref, watch } from "vue";
23
23
  import VarButton from "../button/index.mjs";
24
24
  import { useLock } from "../context/lock.mjs";
@@ -51,7 +51,7 @@ function __render__(_ctx, _cache) {
51
51
  [_ctx.variant === "outlined" || _ctx.outline, _ctx.n("--outline")],
52
52
  [_ctx.variant === "filled", _ctx.n("--filled")],
53
53
  [_ctx.surfaceLow, _ctx.n("--surface-low")],
54
- [_ctx.hoverable, _ctx.n("--cursor")],
54
+ [!_ctx.normalizedHoverable.disabled, _ctx.n("--cursor")],
55
55
  [_ctx.variant === "standard" || _ctx.outline, _ctx.formatElevation(_ctx.elevation, 1)]
56
56
  )
57
57
  ),
@@ -186,8 +186,9 @@ function __render__(_ctx, _cache) {
186
186
  /* CLASS */
187
187
  ),
188
188
  _createVNode(_component_var_hover_overlay, {
189
- hovering: _ctx.hoverable && !_ctx.floated ? _ctx.hovering : false
190
- }, null, 8, ["hovering"]),
189
+ hovering: !_ctx.normalizedHoverable.disabled && !_ctx.floated ? _ctx.hovering : false,
190
+ color: _ctx.normalizedHoverable.color
191
+ }, null, 8, ["hovering", "color"]),
191
192
  _ctx.showFloatingButtons ? (_openBlock(), _createElementBlock(
192
193
  "div",
193
194
  {
@@ -242,7 +243,7 @@ function __render__(_ctx, _cache) {
242
243
  6
243
244
  /* CLASS, STYLE */
244
245
  )), [
245
- [_directive_ripple, { disabled: !_ctx.ripple || _ctx.floater }],
246
+ [_directive_ripple, { disabled: _ctx.normalizedRipple.disabled || _ctx.floater, color: _ctx.normalizedRipple.color }],
246
247
  [_directive_hover, _ctx.handleHovering, "desktop"]
247
248
  ]);
248
249
  }
@@ -274,6 +275,8 @@ const __sfc__ = defineComponent({
274
275
  const showFloatingButtons = ref(false);
275
276
  const floated = ref(false);
276
277
  const { zIndex } = useZIndex(() => props2.floating, 1);
278
+ const normalizedRipple = computed(() => normalizeRipple(props2.ripple));
279
+ const normalizedHoverable = computed(() => normalizeHoverable(props2.hoverable));
277
280
  let dropdownFloaterTop = "auto";
278
281
  let dropdownFloaterLeft = "auto";
279
282
  let dropper = null;
@@ -327,9 +330,33 @@ const __sfc__ = defineComponent({
327
330
  floaterOverflow.value = "auto";
328
331
  floated.value = true;
329
332
  }),
330
- props2.ripple ? RIPPLE_DELAY : 0
333
+ normalizedRipple.value.disabled ? 0 : RIPPLE_DELAY
331
334
  );
332
335
  }
336
+ function normalizeRipple(value) {
337
+ if (isPlainObject(value)) {
338
+ return {
339
+ disabled: !!value.disabled,
340
+ color: value.color
341
+ };
342
+ }
343
+ return {
344
+ disabled: !value,
345
+ color: void 0
346
+ };
347
+ }
348
+ function normalizeHoverable(value) {
349
+ if (isPlainObject(value)) {
350
+ return {
351
+ disabled: !!value.disabled,
352
+ color: value.color
353
+ };
354
+ }
355
+ return {
356
+ disabled: !value,
357
+ color: void 0
358
+ };
359
+ }
333
360
  function dropdown() {
334
361
  clearTimeout(dropper);
335
362
  clearTimeout(floater.value);
@@ -378,6 +405,8 @@ const __sfc__ = defineComponent({
378
405
  zIndex,
379
406
  isRow,
380
407
  surfaceLow,
408
+ normalizedRipple,
409
+ normalizedHoverable,
381
410
  hovering,
382
411
  handleHovering,
383
412
  showFloatingButtons,
package/es/card/props.mjs CHANGED
@@ -16,7 +16,10 @@ const props = {
16
16
  default: "column"
17
17
  },
18
18
  surface: String,
19
- hoverable: Boolean,
19
+ hoverable: {
20
+ type: [Boolean, Object],
21
+ default: false
22
+ },
20
23
  floating: Boolean,
21
24
  floatingDuration: {
22
25
  type: Number,
@@ -30,7 +33,10 @@ const props = {
30
33
  type: [Boolean, Number, String],
31
34
  default: true
32
35
  },
33
- ripple: Boolean,
36
+ ripple: {
37
+ type: [Boolean, Object],
38
+ default: false
39
+ },
34
40
  onClick: defineListenerProp(),
35
41
  "onUpdate:floating": defineListenerProp(),
36
42
  /**
@@ -3,16 +3,17 @@ import { defineComponent } from "vue";
3
3
  import { createNamespace } from "../utils/components.mjs";
4
4
  import { props } from "./props.mjs";
5
5
  const { name, n, classes } = createNamespace("hover-overlay");
6
- import { normalizeClass as _normalizeClass, openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue";
6
+ import { normalizeClass as _normalizeClass, normalizeStyle as _normalizeStyle, openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue";
7
7
  function __render__(_ctx, _cache) {
8
8
  return _openBlock(), _createElementBlock(
9
9
  "div",
10
10
  {
11
- class: _normalizeClass(_ctx.classes(_ctx.n(), [_ctx.hovering, _ctx.n("--hovering")], [_ctx.focusing && !_ctx.inMobile(), _ctx.n("--focusing")]))
11
+ class: _normalizeClass(_ctx.classes(_ctx.n(), [_ctx.hovering, _ctx.n("--hovering")], [_ctx.focusing && !_ctx.inMobile(), _ctx.n("--focusing")])),
12
+ style: _normalizeStyle({ color: _ctx.color })
12
13
  },
13
14
  null,
14
- 2
15
- /* CLASS */
15
+ 6
16
+ /* CLASS, STYLE */
16
17
  );
17
18
  }
18
19
  const __sfc__ = defineComponent({
@@ -1,6 +1,7 @@
1
1
  const props = {
2
2
  hovering: Boolean,
3
- focusing: Boolean
3
+ focusing: Boolean,
4
+ color: String
4
5
  };
5
6
  export {
6
7
  props
@@ -70,6 +70,8 @@ import Rate from './rate/index.mjs'
70
70
  import Result from './result/index.mjs'
71
71
  import Ripple from './ripple/index.mjs'
72
72
  import Row from './row/index.mjs'
73
+ import SegmentedButton from './segmented-button/index.mjs'
74
+ import SegmentedButtons from './segmented-buttons/index.mjs'
73
75
  import Select from './select/index.mjs'
74
76
  import Signature from './signature/index.mjs'
75
77
  import Skeleton from './skeleton/index.mjs'
@@ -166,6 +168,8 @@ export * from './rate/index.mjs'
166
168
  export * from './result/index.mjs'
167
169
  export * from './ripple/index.mjs'
168
170
  export * from './row/index.mjs'
171
+ export * from './segmented-button/index.mjs'
172
+ export * from './segmented-buttons/index.mjs'
169
173
  export * from './select/index.mjs'
170
174
  export * from './signature/index.mjs'
171
175
  export * from './skeleton/index.mjs'
@@ -262,6 +266,8 @@ import './rate/style/index.mjs'
262
266
  import './result/style/index.mjs'
263
267
  import './ripple/style/index.mjs'
264
268
  import './row/style/index.mjs'
269
+ import './segmented-button/style/index.mjs'
270
+ import './segmented-buttons/style/index.mjs'
265
271
  import './select/style/index.mjs'
266
272
  import './signature/style/index.mjs'
267
273
  import './skeleton/style/index.mjs'
@@ -286,7 +292,7 @@ import './tooltip/style/index.mjs'
286
292
  import './uploader/style/index.mjs'
287
293
  import './watermark/style/index.mjs'
288
294
 
289
- const version = '3.16.1'
295
+ const version = '3.17.0'
290
296
 
291
297
  function install(app) {
292
298
  ActionSheet.install && app.use(ActionSheet)
@@ -361,6 +367,8 @@ function install(app) {
361
367
  Result.install && app.use(Result)
362
368
  Ripple.install && app.use(Ripple)
363
369
  Row.install && app.use(Row)
370
+ SegmentedButton.install && app.use(SegmentedButton)
371
+ SegmentedButtons.install && app.use(SegmentedButtons)
364
372
  Select.install && app.use(Select)
365
373
  Signature.install && app.use(Signature)
366
374
  Skeleton.install && app.use(Skeleton)
@@ -461,6 +469,8 @@ export {
461
469
  Result,
462
470
  Ripple,
463
471
  Row,
472
+ SegmentedButton,
473
+ SegmentedButtons,
464
474
  Select,
465
475
  Signature,
466
476
  Skeleton,
@@ -561,6 +571,8 @@ export default {
561
571
  Result,
562
572
  Ripple,
563
573
  Row,
574
+ SegmentedButton,
575
+ SegmentedButtons,
564
576
  Select,
565
577
  Signature,
566
578
  Skeleton,
package/es/index.mjs CHANGED
@@ -70,6 +70,8 @@ import Rate from './rate/index.mjs'
70
70
  import Result from './result/index.mjs'
71
71
  import Ripple from './ripple/index.mjs'
72
72
  import Row from './row/index.mjs'
73
+ import SegmentedButton from './segmented-button/index.mjs'
74
+ import SegmentedButtons from './segmented-buttons/index.mjs'
73
75
  import Select from './select/index.mjs'
74
76
  import Signature from './signature/index.mjs'
75
77
  import Skeleton from './skeleton/index.mjs'
@@ -166,6 +168,8 @@ export * from './rate/index.mjs'
166
168
  export * from './result/index.mjs'
167
169
  export * from './ripple/index.mjs'
168
170
  export * from './row/index.mjs'
171
+ export * from './segmented-button/index.mjs'
172
+ export * from './segmented-buttons/index.mjs'
169
173
  export * from './select/index.mjs'
170
174
  export * from './signature/index.mjs'
171
175
  export * from './skeleton/index.mjs'
@@ -190,7 +194,7 @@ export * from './tooltip/index.mjs'
190
194
  export * from './uploader/index.mjs'
191
195
  export * from './watermark/index.mjs'
192
196
 
193
- const version = '3.16.1'
197
+ const version = '3.17.0'
194
198
 
195
199
  function install(app) {
196
200
  ActionSheet.install && app.use(ActionSheet)
@@ -265,6 +269,8 @@ function install(app) {
265
269
  Result.install && app.use(Result)
266
270
  Ripple.install && app.use(Ripple)
267
271
  Row.install && app.use(Row)
272
+ SegmentedButton.install && app.use(SegmentedButton)
273
+ SegmentedButtons.install && app.use(SegmentedButtons)
268
274
  Select.install && app.use(Select)
269
275
  Signature.install && app.use(Signature)
270
276
  Skeleton.install && app.use(Skeleton)
@@ -365,6 +371,8 @@ export {
365
371
  Result,
366
372
  Ripple,
367
373
  Row,
374
+ SegmentedButton,
375
+ SegmentedButtons,
368
376
  Select,
369
377
  Signature,
370
378
  Skeleton,
@@ -465,6 +473,8 @@ export default {
465
473
  Result,
466
474
  Ripple,
467
475
  Row,
476
+ SegmentedButton,
477
+ SegmentedButtons,
468
478
  Select,
469
479
  Signature,
470
480
  Skeleton,
@@ -1,4 +1,4 @@
1
- import { call } from "@varlet/shared";
1
+ import { call, isPlainObject } from "@varlet/shared";
2
2
  import { computed, defineComponent } from "vue";
3
3
  import Hover from "../hover/index.mjs";
4
4
  import VarHoverOverlay, { useHoverOverlay } from "../hover-overlay/index.mjs";
@@ -20,7 +20,7 @@ function __render__(_ctx, _cache) {
20
20
  _ctx.n(),
21
21
  _ctx.n("$--box"),
22
22
  _ctx.formatElevation(_ctx.elevation, 2),
23
- [_ctx.onClick || _ctx.hoverable, _ctx.n("--cursor")],
23
+ [_ctx.onClick || !_ctx.normalizedHoverable.disabled, _ctx.n("--cursor")],
24
24
  [_ctx.round, _ctx.n("--round")],
25
25
  [_ctx.surfaceLow, _ctx.n("--surface-low")],
26
26
  [_ctx.inline, _ctx.n("$--inline-flex")]
@@ -36,13 +36,14 @@ function __render__(_ctx, _cache) {
36
36
  [
37
37
  _renderSlot(_ctx.$slots, "default"),
38
38
  _createVNode(_component_var_hover_overlay, {
39
- hovering: _ctx.hoverable ? _ctx.hovering : false
40
- }, null, 8, ["hovering"])
39
+ hovering: !_ctx.normalizedHoverable.disabled ? _ctx.hovering : false,
40
+ color: _ctx.normalizedHoverable.color
41
+ }, null, 8, ["hovering", "color"])
41
42
  ],
42
43
  6
43
44
  /* CLASS, STYLE */
44
45
  )), [
45
- [_directive_ripple, { disabled: !_ctx.ripple }],
46
+ [_directive_ripple, { disabled: _ctx.normalizedRipple.disabled, color: _ctx.normalizedRipple.color }],
46
47
  [_directive_hover, _ctx.handleHovering, "desktop"]
47
48
  ]);
48
49
  }
@@ -56,6 +57,32 @@ const __sfc__ = defineComponent({
56
57
  setup(props2) {
57
58
  const surfaceLow = computed(() => props2.surface === "low");
58
59
  const { hovering, handleHovering } = useHoverOverlay();
60
+ const normalizedRipple = computed(() => normalizeRipple(props2.ripple));
61
+ const normalizedHoverable = computed(() => normalizeHoverable(props2.hoverable));
62
+ function normalizeRipple(value) {
63
+ if (isPlainObject(value)) {
64
+ return {
65
+ disabled: !!value.disabled,
66
+ color: value.color
67
+ };
68
+ }
69
+ return {
70
+ disabled: !value,
71
+ color: void 0
72
+ };
73
+ }
74
+ function normalizeHoverable(value) {
75
+ if (isPlainObject(value)) {
76
+ return {
77
+ disabled: !!value.disabled,
78
+ color: value.color
79
+ };
80
+ }
81
+ return {
82
+ disabled: !value,
83
+ color: void 0
84
+ };
85
+ }
59
86
  function handleClick(e) {
60
87
  call(props2.onClick, e);
61
88
  }
@@ -64,6 +91,8 @@ const __sfc__ = defineComponent({
64
91
  classes,
65
92
  formatElevation,
66
93
  surfaceLow,
94
+ normalizedRipple,
95
+ normalizedHoverable,
67
96
  hovering,
68
97
  handleHovering,
69
98
  toSizeUnit,
@@ -4,14 +4,20 @@ const props = {
4
4
  type: [Boolean, Number, String],
5
5
  default: false
6
6
  },
7
- ripple: Boolean,
7
+ ripple: {
8
+ type: [Boolean, Object],
9
+ default: false
10
+ },
8
11
  radius: [Number, String],
9
12
  width: [Number, String],
10
13
  height: [Number, String],
11
14
  round: Boolean,
12
15
  inline: Boolean,
13
16
  surface: String,
14
- hoverable: Boolean,
17
+ hoverable: {
18
+ type: [Boolean, Object],
19
+ default: false
20
+ },
15
21
  onClick: defineListenerProp()
16
22
  };
17
23
  export {
@@ -0,0 +1,141 @@
1
+ import { call, isArray } from "@varlet/shared";
2
+ import { computed, defineComponent, ref } from "vue";
3
+ import { useForm } from "../form/provide.mjs";
4
+ import Hover from "../hover/index.mjs";
5
+ import VarHoverOverlay, { useHoverOverlay } from "../hover-overlay/index.mjs";
6
+ import VarIcon from "../icon/index.mjs";
7
+ import Ripple from "../ripple/index.mjs";
8
+ import { createNamespace } from "../utils/components.mjs";
9
+ import { props } from "./props.mjs";
10
+ import { useSegmentedButtons } from "./provide.mjs";
11
+ const { name, n, classes } = createNamespace("segmented-button");
12
+ import { renderSlot as _renderSlot, resolveComponent as _resolveComponent, normalizeClass as _normalizeClass, createVNode as _createVNode, createCommentVNode as _createCommentVNode, createElementVNode as _createElementVNode, resolveDirective as _resolveDirective, openBlock as _openBlock, createElementBlock as _createElementBlock, withDirectives as _withDirectives } from "vue";
13
+ const _hoisted_1 = ["role", "aria-checked", "aria-disabled", "disabled", "tabindex"];
14
+ function __render__(_ctx, _cache) {
15
+ const _component_var_icon = _resolveComponent("var-icon");
16
+ const _component_var_hover_overlay = _resolveComponent("var-hover-overlay");
17
+ const _directive_ripple = _resolveDirective("ripple");
18
+ const _directive_hover = _resolveDirective("hover");
19
+ return _withDirectives((_openBlock(), _createElementBlock("button", {
20
+ ref: "segmentedButton",
21
+ role: _ctx.segmentedButtons.multiple.value ? "checkbox" : "radio",
22
+ "aria-checked": _ctx.checked,
23
+ "aria-disabled": _ctx.formDisabled || _ctx.disabled || _ctx.formReadonly || _ctx.readonly,
24
+ disabled: _ctx.formDisabled || _ctx.disabled,
25
+ tabindex: _ctx.formDisabled || _ctx.disabled ? void 0 : "0",
26
+ class: _normalizeClass(
27
+ _ctx.classes(
28
+ _ctx.n(),
29
+ _ctx.n("$--box"),
30
+ _ctx.n(`--${_ctx.segmentedButtons.size.value}`),
31
+ [_ctx.checked, _ctx.n("--checked"), _ctx.n("--unchecked")],
32
+ [_ctx.formDisabled || _ctx.disabled, _ctx.n("--disabled")]
33
+ )
34
+ ),
35
+ type: "button",
36
+ onClick: _cache[0] || (_cache[0] = (...args) => _ctx.handleClick && _ctx.handleClick(...args)),
37
+ onFocus: _cache[1] || (_cache[1] = ($event) => _ctx.isFocusing = true),
38
+ onBlur: _cache[2] || (_cache[2] = ($event) => _ctx.isFocusing = false)
39
+ }, [
40
+ _createElementVNode(
41
+ "div",
42
+ {
43
+ class: _normalizeClass(_ctx.n("content"))
44
+ },
45
+ [
46
+ _ctx.segmentedButtons.checkmark.value && _ctx.checked ? _renderSlot(_ctx.$slots, "checkmark", {
47
+ key: 0,
48
+ checked: _ctx.checked
49
+ }, () => [
50
+ _createVNode(_component_var_icon, {
51
+ class: _normalizeClass(_ctx.n("icon")),
52
+ "var-segmented-button-cover": "",
53
+ name: "check"
54
+ }, null, 8, ["class"])
55
+ ]) : _createCommentVNode("v-if", true),
56
+ _renderSlot(_ctx.$slots, "default", { checked: _ctx.checked })
57
+ ],
58
+ 2
59
+ /* CLASS */
60
+ ),
61
+ _createVNode(_component_var_hover_overlay, {
62
+ hovering: !_ctx.formDisabled && !_ctx.disabled && _ctx.hovering,
63
+ focusing: !_ctx.formDisabled && !_ctx.disabled && _ctx.isFocusing
64
+ }, null, 8, ["hovering", "focusing"])
65
+ ], 42, _hoisted_1)), [
66
+ [_directive_ripple, { disabled: _ctx.formReadonly || _ctx.readonly || _ctx.formDisabled || _ctx.disabled || !_ctx.ripple }],
67
+ [_directive_hover, _ctx.handleHovering, "desktop"]
68
+ ]);
69
+ }
70
+ const __sfc__ = defineComponent({
71
+ name,
72
+ directives: { Ripple, Hover },
73
+ components: { VarHoverOverlay, VarIcon },
74
+ props,
75
+ setup(props2) {
76
+ const segmentedButton = ref();
77
+ const isFocusing = ref(false);
78
+ const checked = ref(false);
79
+ const { segmentedButtons, bindSegmentedButtons } = useSegmentedButtons();
80
+ const { hovering, handleHovering } = useHoverOverlay();
81
+ const { form } = useForm();
82
+ const segmentedButtonProvider = {
83
+ checked: computed(() => checked.value),
84
+ disabled: computed(() => (form == null ? void 0 : form.disabled.value) || props2.disabled),
85
+ isFocusing: computed(() => isFocusing.value),
86
+ sync,
87
+ toggle,
88
+ move
89
+ };
90
+ bindSegmentedButtons(segmentedButtonProvider);
91
+ function handleClick(event) {
92
+ if ((form == null ? void 0 : form.disabled.value) || props2.disabled) {
93
+ return;
94
+ }
95
+ call(props2.onClick, event);
96
+ toggle();
97
+ }
98
+ function toggle() {
99
+ if ((form == null ? void 0 : form.disabled.value) || props2.disabled) {
100
+ return;
101
+ }
102
+ if ((form == null ? void 0 : form.readonly.value) || props2.readonly) {
103
+ return;
104
+ }
105
+ segmentedButtons.onClick(props2.checkedValue, checked.value);
106
+ }
107
+ function sync(v) {
108
+ const nextChecked = isArray(v) ? v.includes(props2.checkedValue) : v === props2.checkedValue;
109
+ checked.value = nextChecked;
110
+ return nextChecked;
111
+ }
112
+ function move(selectWhenFocused) {
113
+ if ((form == null ? void 0 : form.disabled.value) || props2.disabled) {
114
+ return;
115
+ }
116
+ segmentedButton.value.focus();
117
+ if (selectWhenFocused && !(form == null ? void 0 : form.readonly.value) && !props2.readonly) {
118
+ segmentedButton.value.click();
119
+ }
120
+ }
121
+ return {
122
+ segmentedButton,
123
+ segmentedButtons,
124
+ isFocusing,
125
+ checked,
126
+ formDisabled: form == null ? void 0 : form.disabled,
127
+ formReadonly: form == null ? void 0 : form.readonly,
128
+ hovering,
129
+ n,
130
+ classes,
131
+ handleHovering,
132
+ handleClick,
133
+ toggle
134
+ };
135
+ }
136
+ });
137
+ __sfc__.render = __render__;
138
+ var stdin_default = __sfc__;
139
+ export {
140
+ stdin_default as default
141
+ };
File without changes
@@ -0,0 +1,12 @@
1
+ import { withInstall, withPropsDefaultsSetter } from "../utils/components.mjs";
2
+ import { props as segmentedButtonProps } from "./props.mjs";
3
+ import SegmentedButton from "./SegmentedButton.mjs";
4
+ withInstall(SegmentedButton);
5
+ withPropsDefaultsSetter(SegmentedButton, segmentedButtonProps);
6
+ const _SegmentedButtonComponent = SegmentedButton;
7
+ var stdin_default = SegmentedButton;
8
+ export {
9
+ _SegmentedButtonComponent,
10
+ stdin_default as default,
11
+ segmentedButtonProps
12
+ };
@@ -0,0 +1,17 @@
1
+ import { defineListenerProp } from "../utils/components.mjs";
2
+ const props = {
3
+ checkedValue: {
4
+ type: [String, Number, Boolean, Object, Array],
5
+ default: void 0
6
+ },
7
+ disabled: Boolean,
8
+ readonly: Boolean,
9
+ ripple: {
10
+ type: Boolean,
11
+ default: true
12
+ },
13
+ onClick: defineListenerProp()
14
+ };
15
+ export {
16
+ props
17
+ };
@@ -0,0 +1,16 @@
1
+ import { assert } from "@varlet/shared";
2
+ import { useParent } from "@varlet/use";
3
+ import { SEGMENTED_BUTTONS_BIND_BUTTON_KEY } from "../segmented-buttons/provide.mjs";
4
+ function useSegmentedButtons() {
5
+ const { bindParent, parentProvider } = useParent(
6
+ SEGMENTED_BUTTONS_BIND_BUTTON_KEY
7
+ );
8
+ assert(!!bindParent, "SegmentedButton", "<var-segmented-button/> must in <var-segmented-buttons/>");
9
+ return {
10
+ segmentedButtons: parentProvider,
11
+ bindSegmentedButtons: bindParent
12
+ };
13
+ }
14
+ export {
15
+ useSegmentedButtons
16
+ };
@@ -0,0 +1 @@
1
+ :root { --segmented-button-text-color: var(--color-text); --segmented-button-checked-background: hsla(var(--hsl-primary), 0.2); --segmented-button-checked-text-color: var(--color-primary); --segmented-button-disabled-background: var(--color-disabled); --segmented-button-disabled-color: var(--color-text-disabled); --segmented-button-mini-padding: 0 8px; --segmented-button-small-padding: 0 12px; --segmented-button-normal-padding: 0 16px; --segmented-button-large-padding: 0 22px; --segmented-button-mini-height: 20px; --segmented-button-small-height: 28px; --segmented-button-normal-height: 36px; --segmented-button-large-height: 44px; --segmented-button-mini-font-size: var(--font-size-xs); --segmented-button-small-font-size: var(--font-size-sm); --segmented-button-normal-font-size: var(--font-size-md); --segmented-button-large-font-size: var(--font-size-lg);}.var-segmented-button { position: relative; display: inline-flex; justify-content: center; align-items: center; outline: none; border: none; background-color: transparent; color: var(--segmented-button-text-color); user-select: none; cursor: pointer; font-family: inherit; white-space: nowrap; transition: background-color 0.25s, color 0.25s; -webkit-tap-highlight-color: transparent;}.var-segmented-button__content { display: inline-flex; align-items: center; justify-content: center;}.var-segmented-button__icon[var-segmented-button-cover] { font-size: 18px; margin-right: 6px;}.var-segmented-button--normal { height: var(--segmented-button-normal-height); padding: var(--segmented-button-normal-padding); font-size: var(--segmented-button-normal-font-size);}.var-segmented-button--large { height: var(--segmented-button-large-height); padding: var(--segmented-button-large-padding); font-size: var(--segmented-button-large-font-size);}.var-segmented-button--small { height: var(--segmented-button-small-height); padding: var(--segmented-button-small-padding); font-size: var(--segmented-button-small-font-size);}.var-segmented-button--mini { height: var(--segmented-button-mini-height); padding: var(--segmented-button-mini-padding); font-size: var(--segmented-button-mini-font-size);}.var-segmented-button--checked { background-color: var(--segmented-button-checked-background); color: var(--segmented-button-checked-text-color);}.var-segmented-button--disabled { color: var(--segmented-button-disabled-color); cursor: not-allowed;}.var-segmented-button--checked.var-segmented-button--disabled { background-color: var(--segmented-button-disabled-background);}
@@ -0,0 +1,5 @@
1
+ import '../../styles/common.css'
2
+ import '../../ripple/ripple.css'
3
+ import '../../hover-overlay/hoverOverlay.css'
4
+ import '../segmentedButton.css'
5
+ import '../SegmentedButtonSfc.css'