@varlet/ui 2.8.1 → 2.8.2-alpha.1676818330977

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,8 +1,9 @@
1
1
  import Ripple from '../ripple/index.mjs';
2
2
  import VarLoading from '../loading/index.mjs';
3
- import { defineComponent, ref } from 'vue';
3
+ import { computed, defineComponent, ref } from 'vue';
4
4
  import { props } from './props.mjs';
5
5
  import { call, createNamespace } from '../utils/components.mjs';
6
+ import { useButtonGroup } from './provide.mjs';
6
7
  import { isArray } from '@varlet/shared';
7
8
  var {
8
9
  n,
@@ -20,10 +21,11 @@ function __render__(_ctx, _cache) {
20
21
  var _directive_ripple = _resolveDirective("ripple");
21
22
 
22
23
  return _withDirectives((_openBlock(), _createElementBlock("button", {
23
- class: _normalizeClass(_ctx.classes(_ctx.n(), _ctx.n('$--box'), _ctx.n("--" + _ctx.size), [_ctx.block, _ctx.n('$--flex') + " " + _ctx.n('--block'), _ctx.n('$--inline-flex')], [_ctx.disabled, _ctx.n('--disabled')], [_ctx.text, _ctx.n("--text-" + _ctx.type) + " " + _ctx.n('--text'), _ctx.n("--" + _ctx.type) + " " + _ctx.n('$-elevation--2')], [_ctx.text && _ctx.disabled, _ctx.n('--text-disabled')], [_ctx.round, _ctx.n('--round')], [_ctx.outline, _ctx.n('--outline')])),
24
+ ref: "buttonEl",
25
+ class: _normalizeClass(_ctx.classes(_ctx.n(), _ctx.n('$--box'), _ctx.n("--" + _ctx.states.size), [_ctx.block, _ctx.n('$--flex') + " " + _ctx.n('--block'), _ctx.n('$--inline-flex')], [_ctx.disabled, _ctx.n('--disabled')], [_ctx.states.text, _ctx.n("--text-" + _ctx.states.type) + " " + _ctx.n('--text'), _ctx.n("--" + _ctx.states.type) + " " + _ctx.n("$-elevation--" + _ctx.states.elevation)], [_ctx.states.text && _ctx.disabled, _ctx.n('--text-disabled')], [_ctx.round, _ctx.n('--round')], [_ctx.states.outline, _ctx.n('--outline')])),
24
26
  style: _normalizeStyle({
25
- color: _ctx.textColor,
26
- background: _ctx.color
27
+ color: _ctx.states.textColor,
28
+ background: _ctx.states.color
27
29
  }),
28
30
  type: _ctx.nativeType,
29
31
  disabled: _ctx.disabled,
@@ -66,6 +68,39 @@ var __sfc__ = defineComponent({
66
68
 
67
69
  setup(props) {
68
70
  var pending = ref(false);
71
+ var {
72
+ buttonGroup
73
+ } = useButtonGroup();
74
+ var states = computed(() => {
75
+ if (!buttonGroup) {
76
+ return {
77
+ elevation: 2,
78
+ type: props.type != null ? props.type : 'default',
79
+ size: props.size != null ? props.size : 'normal',
80
+ color: props.color,
81
+ text: props.text,
82
+ textColor: props.textColor,
83
+ outline: props.outline
84
+ };
85
+ }
86
+
87
+ var {
88
+ type,
89
+ size,
90
+ color,
91
+ textColor,
92
+ mode
93
+ } = buttonGroup;
94
+ return {
95
+ elevation: 0,
96
+ type: props.type != null ? props.type : type.value,
97
+ size: props.size != null ? props.size : size.value,
98
+ color: props.color != null ? props.color : color.value,
99
+ textColor: props.textColor != null ? props.textColor : textColor.value,
100
+ text: mode.value !== 'normal',
101
+ outline: mode.value === 'outline'
102
+ };
103
+ });
69
104
 
70
105
  var attemptAutoLoading = result => {
71
106
  if (props.autoLoading) {
@@ -111,6 +146,7 @@ var __sfc__ = defineComponent({
111
146
  n,
112
147
  classes,
113
148
  pending,
149
+ states,
114
150
  handleClick,
115
151
  handleTouchstart
116
152
  };
@@ -18,7 +18,6 @@ function nativeTypeValidator(nativeType) {
18
18
  export var props = {
19
19
  type: {
20
20
  type: String,
21
- default: 'default',
22
21
  validator: typeValidator
23
22
  },
24
23
  nativeType: {
@@ -28,7 +27,6 @@ export var props = {
28
27
  },
29
28
  size: {
30
29
  type: String,
31
- default: 'normal',
32
30
  validator: sizeValidator
33
31
  },
34
32
  loading: {
@@ -0,0 +1,16 @@
1
+ import { useAtParentIndex, useParent } from '../utils/components.mjs';
2
+ import { BUTTON_GROUP_BIND_BUTTON_KEY, BUTTON_GROUP_COUNT_BUTTON_KEY } from '../button-group/provide.mjs';
3
+ export function useButtonGroup() {
4
+ var {
5
+ bindParent,
6
+ parentProvider
7
+ } = useParent(BUTTON_GROUP_BIND_BUTTON_KEY);
8
+ var {
9
+ index
10
+ } = useAtParentIndex(BUTTON_GROUP_COUNT_BUTTON_KEY);
11
+ return {
12
+ index,
13
+ buttonGroup: parentProvider,
14
+ bindButtonGroup: bindParent
15
+ };
16
+ }
@@ -0,0 +1,45 @@
1
+ import { computed, defineComponent } from 'vue';
2
+ import { useButtons } from './provide.mjs';
3
+ import { createNamespace } from '../utils/components.mjs';
4
+ import { props } from './props.mjs';
5
+ var {
6
+ n,
7
+ classes
8
+ } = createNamespace('button-group');
9
+ import { renderSlot as _renderSlot, normalizeClass as _normalizeClass, openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue";
10
+
11
+ function __render__(_ctx, _cache) {
12
+ return _openBlock(), _createElementBlock("div", {
13
+ class: _normalizeClass(_ctx.classes(_ctx.n(), _ctx.n('$--box'), [_ctx.mode, "" + _ctx.n("--mode-" + _ctx.mode)], [_ctx.vertical, _ctx.n('--vertical'), _ctx.n('--horizontal')], [_ctx.mode === 'normal', _ctx.n("$-elevation--" + _ctx.elevation)]))
14
+ }, [_renderSlot(_ctx.$slots, "default")], 2
15
+ /* CLASS */
16
+ );
17
+ }
18
+
19
+ var __sfc__ = defineComponent({
20
+ name: 'VarButtonGroup',
21
+ props,
22
+
23
+ setup(props) {
24
+ var {
25
+ bindButtons
26
+ } = useButtons();
27
+ var buttonGroupProvider = {
28
+ elevation: computed(() => props.elevation),
29
+ type: computed(() => props.type),
30
+ size: computed(() => props.size),
31
+ color: computed(() => props.color),
32
+ textColor: computed(() => props.textColor),
33
+ mode: computed(() => props.mode)
34
+ };
35
+ bindButtons(buttonGroupProvider);
36
+ return {
37
+ n,
38
+ classes
39
+ };
40
+ }
41
+
42
+ });
43
+
44
+ __sfc__.render = __render__;
45
+ export default __sfc__;
File without changes
@@ -0,0 +1 @@
1
+ .var-button-group { display: inline-flex; border-radius: var(--button-border-radius); max-width: 100%; overflow: auto;}.var-button-group > .var-button:active { box-shadow: none;}.var-button-group--horizontal > .var-button:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0;}.var-button-group--horizontal > .var-button:last-child { border-top-left-radius: 0; border-bottom-left-radius: 0;}.var-button-group--horizontal > .var-button:not(:first-child):not(:last-child) { border-radius: 0;}.var-button-group--horizontal.var-button-group--mode-text > .var-button { border-right: thin solid currentColor;}.var-button-group--horizontal.var-button-group--mode-text > .var-button:last-child { border: none;}.var-button-group--horizontal.var-button-group--mode-outline > .var-button:not(:first-child) { border-left: none;}.var-button-group--vertical { flex-direction: column;}.var-button-group--vertical > .var-button:first-child { border-bottom-left-radius: 0; border-bottom-right-radius: 0;}.var-button-group--vertical > .var-button:last-child { border-top-left-radius: 0; border-top-right-radius: 0;}.var-button-group--vertical > .var-button:not(:first-child):not(:last-child) { border-radius: 0;}.var-button-group--vertical.var-button-group--mode-text > .var-button { border-bottom: thin solid currentColor;}.var-button-group--vertical.var-button-group--mode-text > .var-button:last-child { border: none;}.var-button-group--vertical.var-button-group--mode-outline > .var-button:not(:first-child) { border-top: none;}
@@ -0,0 +1,9 @@
1
+ // Component entry, the folder where the file exists will be exposed to the user
2
+ import ButtonGroup from './ButtonGroup.mjs';
3
+
4
+ ButtonGroup.install = function (app) {
5
+ app.component(ButtonGroup.name, ButtonGroup);
6
+ };
7
+
8
+ export var _ButtonGroupComponent = ButtonGroup;
9
+ export default ButtonGroup;
@@ -0,0 +1,43 @@
1
+ function typeValidator(type) {
2
+ return ['default', 'primary', 'info', 'success', 'warning', 'danger'].includes(type);
3
+ }
4
+
5
+ function sizeValidator(size) {
6
+ return ['normal', 'mini', 'small', 'large'].includes(size);
7
+ }
8
+
9
+ function modeValidator(mode) {
10
+ return ['normal', 'text', 'outline'].includes(mode);
11
+ }
12
+
13
+ export var props = {
14
+ type: {
15
+ type: String,
16
+ default: 'default',
17
+ validator: typeValidator
18
+ },
19
+ size: {
20
+ type: String,
21
+ default: 'normal',
22
+ validator: sizeValidator
23
+ },
24
+ color: {
25
+ type: String
26
+ },
27
+ textColor: {
28
+ type: String
29
+ },
30
+ mode: {
31
+ type: String,
32
+ default: 'normal',
33
+ validator: modeValidator
34
+ },
35
+ elevation: {
36
+ type: [Number, String],
37
+ default: 2
38
+ },
39
+ vertical: {
40
+ type: Boolean,
41
+ default: false
42
+ }
43
+ };
@@ -0,0 +1,17 @@
1
+ import { useAtChildrenCounter, useChildren } from '../utils/components.mjs';
2
+ export var BUTTON_GROUP_BIND_BUTTON_KEY = Symbol('BUTTON_GROUP_BIND_BUTTON_KEY');
3
+ export var BUTTON_GROUP_COUNT_BUTTON_KEY = Symbol('BUTTON_GROUP_COUNT_BUTTON_KEY');
4
+ export function useButtons() {
5
+ var {
6
+ bindChildren,
7
+ childProviders
8
+ } = useChildren(BUTTON_GROUP_BIND_BUTTON_KEY);
9
+ var {
10
+ length
11
+ } = useAtChildrenCounter(BUTTON_GROUP_COUNT_BUTTON_KEY);
12
+ return {
13
+ length,
14
+ buttons: childProviders,
15
+ bindButtons: bindChildren
16
+ };
17
+ }
@@ -0,0 +1,3 @@
1
+ import '../../styles/common.css'
2
+ import '../buttonGroup.css'
3
+ import '../ButtonGroupSfc.css'
@@ -9,6 +9,7 @@ import BottomNavigationItem from './bottom-navigation-item/index.mjs'
9
9
  import Breadcrumb from './breadcrumb/index.mjs'
10
10
  import Breadcrumbs from './breadcrumbs/index.mjs'
11
11
  import Button from './button/index.mjs'
12
+ import ButtonGroup from './button-group/index.mjs'
12
13
  import Card from './card/index.mjs'
13
14
  import Cell from './cell/index.mjs'
14
15
  import Checkbox from './checkbox/index.mjs'
@@ -86,6 +87,7 @@ export * from './bottom-navigation-item/index.mjs'
86
87
  export * from './breadcrumb/index.mjs'
87
88
  export * from './breadcrumbs/index.mjs'
88
89
  export * from './button/index.mjs'
90
+ export * from './button-group/index.mjs'
89
91
  export * from './card/index.mjs'
90
92
  export * from './cell/index.mjs'
91
93
  export * from './checkbox/index.mjs'
@@ -163,6 +165,7 @@ import './bottom-navigation-item/style/index.mjs'
163
165
  import './breadcrumb/style/index.mjs'
164
166
  import './breadcrumbs/style/index.mjs'
165
167
  import './button/style/index.mjs'
168
+ import './button-group/style/index.mjs'
166
169
  import './card/style/index.mjs'
167
170
  import './cell/style/index.mjs'
168
171
  import './checkbox/style/index.mjs'
@@ -229,7 +232,7 @@ import './time-picker/style/index.mjs'
229
232
  import './tooltip/style/index.mjs'
230
233
  import './uploader/style/index.mjs'
231
234
 
232
- const version = '2.8.1'
235
+ const version = '2.8.2-alpha.1676818330977'
233
236
 
234
237
  function install(app) {
235
238
  ActionSheet.install && app.use(ActionSheet)
@@ -243,6 +246,7 @@ function install(app) {
243
246
  Breadcrumb.install && app.use(Breadcrumb)
244
247
  Breadcrumbs.install && app.use(Breadcrumbs)
245
248
  Button.install && app.use(Button)
249
+ ButtonGroup.install && app.use(ButtonGroup)
246
250
  Card.install && app.use(Card)
247
251
  Cell.install && app.use(Cell)
248
252
  Checkbox.install && app.use(Checkbox)
@@ -324,6 +328,7 @@ export {
324
328
  Breadcrumb,
325
329
  Breadcrumbs,
326
330
  Button,
331
+ ButtonGroup,
327
332
  Card,
328
333
  Cell,
329
334
  Checkbox,
@@ -405,6 +410,7 @@ export default {
405
410
  Breadcrumb,
406
411
  Breadcrumbs,
407
412
  Button,
413
+ ButtonGroup,
408
414
  Card,
409
415
  Cell,
410
416
  Checkbox,
package/es/index.mjs CHANGED
@@ -9,6 +9,7 @@ import BottomNavigationItem from './bottom-navigation-item/index.mjs'
9
9
  import Breadcrumb from './breadcrumb/index.mjs'
10
10
  import Breadcrumbs from './breadcrumbs/index.mjs'
11
11
  import Button from './button/index.mjs'
12
+ import ButtonGroup from './button-group/index.mjs'
12
13
  import Card from './card/index.mjs'
13
14
  import Cell from './cell/index.mjs'
14
15
  import Checkbox from './checkbox/index.mjs'
@@ -86,6 +87,7 @@ export * from './bottom-navigation-item/index.mjs'
86
87
  export * from './breadcrumb/index.mjs'
87
88
  export * from './breadcrumbs/index.mjs'
88
89
  export * from './button/index.mjs'
90
+ export * from './button-group/index.mjs'
89
91
  export * from './card/index.mjs'
90
92
  export * from './cell/index.mjs'
91
93
  export * from './checkbox/index.mjs'
@@ -152,7 +154,7 @@ export * from './time-picker/index.mjs'
152
154
  export * from './tooltip/index.mjs'
153
155
  export * from './uploader/index.mjs'
154
156
 
155
- const version = '2.8.1'
157
+ const version = '2.8.2-alpha.1676818330977'
156
158
 
157
159
  function install(app) {
158
160
  ActionSheet.install && app.use(ActionSheet)
@@ -166,6 +168,7 @@ function install(app) {
166
168
  Breadcrumb.install && app.use(Breadcrumb)
167
169
  Breadcrumbs.install && app.use(Breadcrumbs)
168
170
  Button.install && app.use(Button)
171
+ ButtonGroup.install && app.use(ButtonGroup)
169
172
  Card.install && app.use(Card)
170
173
  Cell.install && app.use(Cell)
171
174
  Checkbox.install && app.use(Checkbox)
@@ -247,6 +250,7 @@ export {
247
250
  Breadcrumb,
248
251
  Breadcrumbs,
249
252
  Button,
253
+ ButtonGroup,
250
254
  Card,
251
255
  Cell,
252
256
  Checkbox,
@@ -328,6 +332,7 @@ export default {
328
332
  Breadcrumb,
329
333
  Breadcrumbs,
330
334
  Button,
335
+ ButtonGroup,
331
336
  Card,
332
337
  Cell,
333
338
  Checkbox,
@@ -13,7 +13,7 @@ function __render__(_ctx, _cache) {
13
13
  var _directive_ripple = _resolveDirective("ripple");
14
14
 
15
15
  return _withDirectives((_openBlock(), _createElementBlock("div", {
16
- class: _normalizeClass(_ctx.classes(_ctx.n(), _ctx.n('$--box'), _ctx.n("$-elevation--" + _ctx.elevation), [_ctx.onClick, _ctx.n('--cursor')], [_ctx.round, _ctx.n('--round')], [_ctx.inline, _ctx.n('$--inline-flex')])),
16
+ class: _normalizeClass(_ctx.classes(_ctx.n(), _ctx.n('$--box'), [_ctx.elevation != null, _ctx.n("$-elevation--" + _ctx.elevation)], [_ctx.onClick, _ctx.n('--cursor')], [_ctx.round, _ctx.n('--round')], [_ctx.inline, _ctx.n('$--inline-flex')])),
17
17
  style: _normalizeStyle({
18
18
  width: _ctx.toSizeUnit(_ctx.width),
19
19
  height: _ctx.toSizeUnit(_ctx.height),