|
@@ -4,8 +4,16 @@
|
|
|
<IconButton
|
|
<IconButton
|
|
|
:icon="minusIcon"
|
|
:icon="minusIcon"
|
|
|
:disabled="disabled || value <= min"
|
|
:disabled="disabled || value <= min"
|
|
|
- :buttonStyle="themeStyles.button.value"
|
|
|
|
|
|
|
+ :buttonStyle="{
|
|
|
|
|
+ ...themeStyles.button.value,
|
|
|
|
|
+ ...selectObjectByType(size, 'medium', {
|
|
|
|
|
+ small: themeStyles.buttonSmall.value,
|
|
|
|
|
+ medium: themeStyles.buttonMedium.value,
|
|
|
|
|
+ large: themeStyles.buttonLarge.value,
|
|
|
|
|
+ })
|
|
|
|
|
+ }"
|
|
|
:padding="5"
|
|
:padding="5"
|
|
|
|
|
+ :size="iconSize"
|
|
|
@click="minus"
|
|
@click="minus"
|
|
|
/>
|
|
/>
|
|
|
</slot>
|
|
</slot>
|
|
@@ -18,7 +26,14 @@
|
|
|
:onBlur="onTextBlur"
|
|
:onBlur="onTextBlur"
|
|
|
:editable="!disabled"
|
|
:editable="!disabled"
|
|
|
>
|
|
>
|
|
|
- <view :style="themeStyles.inputWrapper.value">
|
|
|
|
|
|
|
+ <view :style="{
|
|
|
|
|
+ ...themeStyles.inputWrapper.value,
|
|
|
|
|
+ ...selectObjectByType(size, 'medium', {
|
|
|
|
|
+ small: themeStyles.inputWrapperSmall.value,
|
|
|
|
|
+ medium: themeStyles.inputWrapperMedium.value,
|
|
|
|
|
+ large: themeStyles.inputWrapperLarge.value,
|
|
|
|
|
+ }),
|
|
|
|
|
+ }">
|
|
|
<input
|
|
<input
|
|
|
:style="{
|
|
:style="{
|
|
|
...themeStyles.input.value,
|
|
...themeStyles.input.value,
|
|
@@ -41,8 +56,16 @@
|
|
|
<IconButton
|
|
<IconButton
|
|
|
:icon="addIcon"
|
|
:icon="addIcon"
|
|
|
:disabled="disabled || (max ? value >= max : undefined)"
|
|
:disabled="disabled || (max ? value >= max : undefined)"
|
|
|
- :buttonStyle="themeStyles.button.value"
|
|
|
|
|
|
|
+ :buttonStyle="{
|
|
|
|
|
+ ...themeStyles.button.value,
|
|
|
|
|
+ ...selectObjectByType(size, 'medium', {
|
|
|
|
|
+ small: themeStyles.buttonSmall.value,
|
|
|
|
|
+ medium: themeStyles.buttonMedium.value,
|
|
|
|
|
+ large: themeStyles.buttonLarge.value,
|
|
|
|
|
+ })
|
|
|
|
|
+ }"
|
|
|
:padding="5"
|
|
:padding="5"
|
|
|
|
|
+ :size="iconSize"
|
|
|
@click="add"
|
|
@click="add"
|
|
|
/>
|
|
/>
|
|
|
</slot>
|
|
</slot>
|
|
@@ -50,12 +73,12 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
-import { onMounted, ref, toRef, watch } from 'vue';
|
|
|
|
|
|
|
+import { computed, onMounted, ref, toRef, watch } from 'vue';
|
|
|
import IconButton from '../basic/IconButton.vue';
|
|
import IconButton from '../basic/IconButton.vue';
|
|
|
import FlexRow from '../layout/FlexRow.vue';
|
|
import FlexRow from '../layout/FlexRow.vue';
|
|
|
import { propGetThemeVar, useTheme } from '../theme/ThemeDefine';
|
|
import { propGetThemeVar, useTheme } from '../theme/ThemeDefine';
|
|
|
import { StringUtils } from '@imengyu/imengyu-utils';
|
|
import { StringUtils } from '@imengyu/imengyu-utils';
|
|
|
-import { DynamicColor, DynamicSize } from '../theme/ThemeTools';
|
|
|
|
|
|
|
+import { DynamicColor, DynamicSize, selectObjectByType } from '../theme/ThemeTools';
|
|
|
import { useFieldChildValueInjector } from './FormContext';
|
|
import { useFieldChildValueInjector } from './FormContext';
|
|
|
|
|
|
|
|
export interface StepperProps {
|
|
export interface StepperProps {
|
|
@@ -80,6 +103,11 @@ export interface StepperProps {
|
|
|
*/
|
|
*/
|
|
|
inputWidth?: number;
|
|
inputWidth?: number;
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * 组件大小
|
|
|
|
|
+ * @default 'medium'
|
|
|
|
|
+ */
|
|
|
|
|
+ size?: 'small' | 'medium' | 'large';
|
|
|
|
|
+ /**
|
|
|
* 步长,每次点击时改变的值
|
|
* 步长,每次点击时改变的值
|
|
|
* @default 1
|
|
* @default 1
|
|
|
*/
|
|
*/
|
|
@@ -154,17 +182,57 @@ const themeContext = useTheme();
|
|
|
const themeStyles = themeContext.useThemeStyles({
|
|
const themeStyles = themeContext.useThemeStyles({
|
|
|
button: {
|
|
button: {
|
|
|
borderRadius: DynamicSize('StepperButtonBorderRadius', 0),
|
|
borderRadius: DynamicSize('StepperButtonBorderRadius', 0),
|
|
|
|
|
+ backgroundColor: DynamicColor('StepperButtonBackgroundColor', 'light'),
|
|
|
|
|
+ },
|
|
|
|
|
+ buttonLarge: {
|
|
|
|
|
+ borderRadius: DynamicSize('StepperButtonBorderRadius', 0),
|
|
|
paddingTop: DynamicSize('StepperButtonPaddingVertical', 8),
|
|
paddingTop: DynamicSize('StepperButtonPaddingVertical', 8),
|
|
|
paddingBottom: DynamicSize('StepperButtonPaddingVertical', 8),
|
|
paddingBottom: DynamicSize('StepperButtonPaddingVertical', 8),
|
|
|
paddingLeft: DynamicSize('StepperButtonPaddingHorizontal', 8),
|
|
paddingLeft: DynamicSize('StepperButtonPaddingHorizontal', 8),
|
|
|
paddingRight: DynamicSize('StepperButtonPaddingHorizontal', 8),
|
|
paddingRight: DynamicSize('StepperButtonPaddingHorizontal', 8),
|
|
|
backgroundColor: DynamicColor('StepperButtonBackgroundColor', 'light'),
|
|
backgroundColor: DynamicColor('StepperButtonBackgroundColor', 'light'),
|
|
|
},
|
|
},
|
|
|
|
|
+ buttonMedium: {
|
|
|
|
|
+ paddingTop: DynamicSize('StepperButtonPaddingVertical', 4),
|
|
|
|
|
+ paddingBottom: DynamicSize('StepperButtonPaddingVertical', 4),
|
|
|
|
|
+ paddingLeft: DynamicSize('StepperButtonPaddingHorizontal', 4),
|
|
|
|
|
+ paddingRight: DynamicSize('StepperButtonPaddingHorizontal', 4),
|
|
|
|
|
+ },
|
|
|
|
|
+ buttonSmall: {
|
|
|
|
|
+ borderRadius: DynamicSize('StepperButtonBorderRadius', 0),
|
|
|
|
|
+ paddingTop: DynamicSize('StepperButtonPaddingVertical', 2),
|
|
|
|
|
+ paddingBottom: DynamicSize('StepperButtonPaddingVertical', 2),
|
|
|
|
|
+ paddingLeft: DynamicSize('StepperButtonPaddingHorizontal', 2),
|
|
|
|
|
+ paddingRight: DynamicSize('StepperButtonPaddingHorizontal', 2),
|
|
|
|
|
+ },
|
|
|
inputWrapper: {
|
|
inputWrapper: {
|
|
|
display: 'flex',
|
|
display: 'flex',
|
|
|
justifyContent: 'center',
|
|
justifyContent: 'center',
|
|
|
alignItems: 'center',
|
|
alignItems: 'center',
|
|
|
alignSelf: 'stretch',
|
|
alignSelf: 'stretch',
|
|
|
|
|
+ backgroundColor: DynamicColor('StepperInputBackgroundColor', 'light'),
|
|
|
|
|
+ },
|
|
|
|
|
+ inputWrapperSmall: {
|
|
|
|
|
+ paddingTop: DynamicSize('StepperInputPaddingVertical', 0),
|
|
|
|
|
+ paddingBottom: DynamicSize('StepperInputPaddingVertical', 0),
|
|
|
|
|
+ paddingLeft: DynamicSize('StepperInputPaddingHorizontal', 6),
|
|
|
|
|
+ paddingRight: DynamicSize('StepperInputPaddingHorizontal', 6),
|
|
|
|
|
+ marginLeft: DynamicSize('StepperInputMarginHorizontal', 2),
|
|
|
|
|
+ marginRight: DynamicSize('StepperInputMarginHorizontal', 2),
|
|
|
|
|
+ marginTop: DynamicSize('StepperInputMarginVertical', 0),
|
|
|
|
|
+ marginBottom: DynamicSize('StepperInputMarginVertical', 0),
|
|
|
|
|
+ },
|
|
|
|
|
+ inputWrapperMedium: {
|
|
|
|
|
+ paddingTop: DynamicSize('StepperInputPaddingVertical', 0),
|
|
|
|
|
+ paddingBottom: DynamicSize('StepperInputPaddingVertical', 0),
|
|
|
|
|
+ paddingLeft: DynamicSize('StepperInputPaddingHorizontal', 10),
|
|
|
|
|
+ paddingRight: DynamicSize('StepperInputPaddingHorizontal', 10),
|
|
|
|
|
+ marginLeft: DynamicSize('StepperInputMarginHorizontal', 4),
|
|
|
|
|
+ marginRight: DynamicSize('StepperInputMarginHorizontal', 4),
|
|
|
|
|
+ marginTop: DynamicSize('StepperInputMarginVertical', 0),
|
|
|
|
|
+ marginBottom: DynamicSize('StepperInputMarginVertical', 0),
|
|
|
|
|
+ },
|
|
|
|
|
+ inputWrapperLarge: {
|
|
|
paddingTop: DynamicSize('StepperInputPaddingVertical', 0),
|
|
paddingTop: DynamicSize('StepperInputPaddingVertical', 0),
|
|
|
paddingBottom: DynamicSize('StepperInputPaddingVertical', 0),
|
|
paddingBottom: DynamicSize('StepperInputPaddingVertical', 0),
|
|
|
paddingLeft: DynamicSize('StepperInputPaddingHorizontal', 20),
|
|
paddingLeft: DynamicSize('StepperInputPaddingHorizontal', 20),
|
|
@@ -173,13 +241,24 @@ const themeStyles = themeContext.useThemeStyles({
|
|
|
marginRight: DynamicSize('StepperInputMarginHorizontal', 8),
|
|
marginRight: DynamicSize('StepperInputMarginHorizontal', 8),
|
|
|
marginTop: DynamicSize('StepperInputMarginVertical', 0),
|
|
marginTop: DynamicSize('StepperInputMarginVertical', 0),
|
|
|
marginBottom: DynamicSize('StepperInputMarginVertical', 0),
|
|
marginBottom: DynamicSize('StepperInputMarginVertical', 0),
|
|
|
- backgroundColor: DynamicColor('StepperInputBackgroundColor', 'light'),
|
|
|
|
|
},
|
|
},
|
|
|
input: {
|
|
input: {
|
|
|
textAlign: 'center',
|
|
textAlign: 'center',
|
|
|
color: DynamicColor('StepperInputTextColor', 'text.content'),
|
|
color: DynamicColor('StepperInputTextColor', 'text.content'),
|
|
|
},
|
|
},
|
|
|
-})
|
|
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
|
|
+const iconSize = computed(() => {
|
|
|
|
|
+ switch (props.size) {
|
|
|
|
|
+ case 'small':
|
|
|
|
|
+ return themeContext.resolveThemeSize('StepperIconSizeSmall', 24);
|
|
|
|
|
+ default:
|
|
|
|
|
+ case 'medium':
|
|
|
|
|
+ return themeContext.resolveThemeSize('StepperIconSizeMedium', 36);
|
|
|
|
|
+ case 'large':
|
|
|
|
|
+ return themeContext.resolveThemeSize('StepperIconSizeLarge', 48);
|
|
|
|
|
+ }
|
|
|
|
|
+});
|
|
|
|
|
|
|
|
const {
|
|
const {
|
|
|
value,
|
|
value,
|