tang-ui-x 1.1.2 → 1.1.3

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.
@@ -13,6 +13,9 @@ type Props = Omit<TCheckboxGroupProps, 'modelValue'>
13
13
  const props = withDefaults(defineProps<Props>(), {
14
14
  options: () => [] as CheckboxOption[],
15
15
  direction: 'vertical',
16
+ size: 'medium',
17
+ activeColor: '#00bba7',
18
+ inactiveColor: '#c8c9cc',
16
19
  max: -1,
17
20
  disabled: false,
18
21
  customClass: '',
@@ -56,20 +59,36 @@ const handleChange = (option: CheckboxOption): void => {
56
59
  const isChecked = (option: CheckboxOption): boolean => {
57
60
  return modelValue.value.includes(option.value)
58
61
  }
62
+
63
+ // 尺寸映射
64
+ const sizeMap = {
65
+ small: { icon: 32, fontSize: 20 },
66
+ medium: { icon: 40, fontSize: 24 },
67
+ large: { icon: 48, fontSize: 28 }
68
+ }
69
+
70
+ const currentSize = computed(() => sizeMap[props.size])
71
+
72
+ const cssVars = computed(() => ({
73
+ '--icon-size': `${currentSize.value.icon}rpx`,
74
+ '--checkmark-size': `${currentSize.value.fontSize}rpx`,
75
+ '--active-color': props.activeColor,
76
+ '--inactive-color': props.inactiveColor
77
+ }))
59
78
  </script>
60
79
 
61
80
  <template>
62
81
  <view
63
82
  class="t-checkbox-group"
64
83
  :class="[`t-checkbox-group--${direction}`, customClass]"
65
- :style="customStyle"
84
+ :style="[customStyle, cssVars]"
66
85
  >
67
86
  <view
68
87
  v-for="(option, index) in options"
69
88
  :key="index"
70
89
  class="t-checkbox-group__item"
71
90
  :class="{ 't-checkbox-group__item--disabled': disabled || option.disabled }"
72
- @click="() => handleChange(option)"
91
+ @click="handleChange(option)"
73
92
  >
74
93
  <view class="t-checkbox-group__icon" :class="{ 't-checkbox-group__icon--checked': isChecked(option) }">
75
94
  <text v-if="isChecked(option)" class="t-checkbox-group__check">✓</text>
@@ -95,7 +114,7 @@ const isChecked = (option: CheckboxOption): boolean => {
95
114
 
96
115
  .t-checkbox-group__item {
97
116
  display: flex;
98
- align-items: center;
117
+ flex-direction: row;
99
118
  padding: 12px 0;
100
119
  cursor: pointer;
101
120
 
@@ -110,24 +129,24 @@ const isChecked = (option: CheckboxOption): boolean => {
110
129
  }
111
130
 
112
131
  .t-checkbox-group__icon {
113
- width: 20px;
114
- height: 20px;
115
- border: 2px solid #c8c9cc;
116
- border-radius: 4px;
117
- margin-right: 8px;
132
+ width: var(--icon-size);
133
+ height: var(--icon-size);
134
+ border: 2rpx solid var(--inactive-color);
135
+ border-radius: 8rpx;
136
+ margin-right: 16rpx;
118
137
  display: flex;
119
138
  align-items: center;
120
139
  justify-content: center;
121
140
  transition: all 0.3s;
122
141
 
123
142
  &--checked {
124
- background-color: #1890ff;
125
- border-color: #1890ff;
143
+ background-color: var(--active-color);
144
+ border-color: var(--active-color);
126
145
  }
127
146
  }
128
147
 
129
148
  .t-checkbox-group__check {
130
- font-size: 14px;
149
+ font-size: var(--checkmark-size);
131
150
  color: #fff;
132
151
  font-weight: bold;
133
152
  }
@@ -3,6 +3,7 @@
3
3
  */
4
4
 
5
5
  export type CheckboxDirection = 'horizontal' | 'vertical'
6
+ export type CheckboxSize = 'small' | 'medium' | 'large'
6
7
 
7
8
  export interface CheckboxOption {
8
9
  label: string
@@ -14,8 +15,17 @@ export interface TCheckboxGroupProps {
14
15
  modelValue?: (string | number)[]
15
16
  options?: CheckboxOption[]
16
17
  direction?: CheckboxDirection
18
+ /** 按钮尺寸 */
19
+ size?: CheckboxSize
20
+ /** 激活状态颜色 */
21
+ activeColor?: string
22
+ /** 非激活状态颜色 */
23
+ inactiveColor?: string
24
+ /** 最大可选数量 */
17
25
  max?: number
18
26
  disabled?: boolean
27
+ /** 名称属性(用于表单提交) */
28
+ name?: string
19
29
  customClass?: string
20
30
  customStyle?: string
21
31
  }