plain-design 1.0.0-beta.94 → 1.0.0-beta.95
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.
- package/dist/plain-design.commonjs.min.js +2 -2
- package/dist/plain-design.min.css +2 -2
- package/dist/plain-design.min.js +2 -2
- package/dist/report.html +2 -2
- package/package.json +1 -1
- package/src/packages/components/Alert/alert.scss +2 -0
- package/src/packages/components/Alert/index.tsx +4 -4
- package/src/packages/components/Button/button.scss +1 -1
- package/src/packages/components/Form/layout/useFormLayout.tsx +30 -11
- package/src/packages/components/FormItem/index.tsx +3 -3
package/package.json
CHANGED
@@ -37,6 +37,7 @@
|
|
37
37
|
padding-right: $close-width;
|
38
38
|
|
39
39
|
.alert-close {
|
40
|
+
border-radius: inherit;
|
40
41
|
position: absolute;
|
41
42
|
top: 0;
|
42
43
|
right: 0;
|
@@ -112,6 +113,7 @@
|
|
112
113
|
|
113
114
|
&.alert-theme-lite {
|
114
115
|
@include statusMixin(alert) {
|
116
|
+
border:solid 1px $color-3;
|
115
117
|
background-color: $color-light-2;
|
116
118
|
color: $color-6;
|
117
119
|
.alert-close {
|
@@ -17,7 +17,7 @@ export const Alert = designComponent({
|
|
17
17
|
theme: { type: String, default: 'lite' }, // 主题,lite轻色,deep深色
|
18
18
|
noClose: { type: Boolean }, // 禁用关闭
|
19
19
|
icon: { type: String as PropType<string | null | undefined>, default: undefined }, // 显示的图标
|
20
|
-
|
20
|
+
description: { type: String }, // desc内容消息
|
21
21
|
},
|
22
22
|
slots: ['desc', 'close', 'default'],
|
23
23
|
setup({ props, slots, attrs }) {
|
@@ -46,7 +46,7 @@ export const Alert = designComponent({
|
|
46
46
|
`alert-align-${props.align}`,
|
47
47
|
{
|
48
48
|
'alert-has-icon': !!icon.value,
|
49
|
-
'alert-has-desc': !!props.
|
49
|
+
'alert-has-desc': !!props.description || slots.desc.isExist(),
|
50
50
|
'alert-has-close': !props.noClose,
|
51
51
|
}
|
52
52
|
]);
|
@@ -76,9 +76,9 @@ export const Alert = designComponent({
|
|
76
76
|
{slots.default(props.label)}
|
77
77
|
</div>
|
78
78
|
)}
|
79
|
-
{(props.
|
79
|
+
{(props.description || slots.desc.isExist()) && (
|
80
80
|
<div className="alert-desc">
|
81
|
-
{slots.desc(props.
|
81
|
+
{slots.desc(props.description)}
|
82
82
|
</div>
|
83
83
|
)}
|
84
84
|
</div>
|
@@ -3,6 +3,8 @@ import {createEnum} from "plain-utils/utils/createEnum";
|
|
3
3
|
import {unit} from "plain-utils/string/unit";
|
4
4
|
import {removeUnit} from "plain-utils/string/removeUnit";
|
5
5
|
import {InputMode, ThemeSize, tStyleComputed} from "../../../uses/useStyle";
|
6
|
+
import ApplicationConfigurationProvider from "../../ApplicationConfigurationProvider";
|
7
|
+
import {PlainObject} from "plain-utils/utils/event";
|
6
8
|
|
7
9
|
/**
|
8
10
|
* 表单的文本以及内容对齐方式
|
@@ -59,6 +61,7 @@ export type tFormLayoutPropsType = ExtractPropTypes<typeof FormLayoutPropsOption
|
|
59
61
|
* @date 2022.9.4 22:46
|
60
62
|
*/
|
61
63
|
export const FormItemLayoutPropsOption = {
|
64
|
+
hideLabel: { type: Boolean }, // 隐藏label
|
62
65
|
labelWidth: { type: [String, Number] as PropType<string | number> }, // 显示文本宽度
|
63
66
|
column: { type: [String, Number] as PropType<string | number>, default: 1 }, // 多列表单的列数
|
64
67
|
block: { type: Boolean as PropType<boolean> }, // 占用一行
|
@@ -94,8 +97,12 @@ export const DefaultFormLabelWidth = (() => {
|
|
94
97
|
export const useFormLayout = (() => {
|
95
98
|
|
96
99
|
const FORM_LAYOUT_PROVIDER = '@@FORM_LAYOUT_PROVIDER';
|
100
|
+
const FORM_ITEM_LAYOUT_PROVIDER = '@@FORM_ITEM_LAYOUT_PROVIDER';
|
97
101
|
|
98
102
|
const useForm = (props: tFormLayoutPropsType, styleComputed: tStyleComputed) => {
|
103
|
+
|
104
|
+
const configuration = ApplicationConfigurationProvider.inject();
|
105
|
+
|
99
106
|
/*是否为单列*/
|
100
107
|
const isSingleColumn = computed(() => props.column === 1);
|
101
108
|
/*列间距*/
|
@@ -112,7 +119,10 @@ export const useFormLayout = (() => {
|
|
112
119
|
if (props.rowGutter != null) {
|
113
120
|
return removeUnit(props.rowGutter) as any;
|
114
121
|
}
|
115
|
-
return
|
122
|
+
return Math.max(
|
123
|
+
1.25 * ((removeUnit(configuration.value.theme.vars[`margin-${styleComputed.value.size}`]) || 0) as number),
|
124
|
+
14,
|
125
|
+
);
|
116
126
|
});
|
117
127
|
/*校验消息的位置*/
|
118
128
|
const validateMessagePosition = computed(() => {
|
@@ -147,8 +157,11 @@ export const useFormLayout = (() => {
|
|
147
157
|
};
|
148
158
|
|
149
159
|
const useFormItem = (props: tFormItemLayoutPropsType) => {
|
160
|
+
|
150
161
|
const form = inject<ReturnType<typeof useForm>>(FORM_LAYOUT_PROVIDER)!;
|
151
162
|
|
163
|
+
const parentFormItem = inject<PlainObject | null>(FORM_ITEM_LAYOUT_PROVIDER, null);
|
164
|
+
|
152
165
|
/**
|
153
166
|
* 文本宽度
|
154
167
|
* @author 韦胜健
|
@@ -211,7 +224,7 @@ export const useFormLayout = (() => {
|
|
211
224
|
* @author 韦胜健
|
212
225
|
* @date 2022.9.4 23:22
|
213
226
|
*/
|
214
|
-
const contentAlign = computed(() => props.contentAlign || form.props.contentAlign
|
227
|
+
const contentAlign = computed(() => props.contentAlign || form.props.contentAlign);
|
215
228
|
|
216
229
|
const validateMessagePosition = computed(() => props.validateMessagePosition || form.validateMessagePosition.value);
|
217
230
|
/**
|
@@ -229,7 +242,11 @@ export const useFormLayout = (() => {
|
|
229
242
|
return `calc(${Number((itemColumn / totalColumn).toFixed(4)) * 100}%)`;
|
230
243
|
})();
|
231
244
|
styles.padding = `0 ${unit(form.gutter.value / 2)}`;
|
232
|
-
|
245
|
+
if (!parentFormItem) {
|
246
|
+
styles.margin = `${form.rowGutter.value / 2}px 0`;
|
247
|
+
} else {
|
248
|
+
styles.marginTop = `${form.rowGutter.value}px`;
|
249
|
+
}
|
233
250
|
});
|
234
251
|
|
235
252
|
/**
|
@@ -270,7 +287,7 @@ export const useFormLayout = (() => {
|
|
270
287
|
}
|
271
288
|
});
|
272
289
|
|
273
|
-
|
290
|
+
const refer = {
|
274
291
|
colon,
|
275
292
|
labelAlign,
|
276
293
|
contentAlign,
|
@@ -280,11 +297,20 @@ export const useFormLayout = (() => {
|
|
280
297
|
form,
|
281
298
|
validateMessagePosition,
|
282
299
|
};
|
300
|
+
|
301
|
+
provide(FORM_ITEM_LAYOUT_PROVIDER, refer);
|
302
|
+
|
303
|
+
return refer;
|
283
304
|
};
|
284
305
|
|
285
306
|
return { useForm, useFormItem };
|
286
307
|
})();
|
287
308
|
|
309
|
+
/**
|
310
|
+
* 不同尺寸下的默认列间距
|
311
|
+
* @author 韦胜健
|
312
|
+
* @date 2024.7.18 20:52
|
313
|
+
*/
|
288
314
|
const FormSizeGutter: Record<typeof ThemeSize.TYPE, number> = {
|
289
315
|
large: 16,
|
290
316
|
normal: 12,
|
@@ -292,13 +318,6 @@ const FormSizeGutter: Record<typeof ThemeSize.TYPE, number> = {
|
|
292
318
|
mini: 4,
|
293
319
|
};
|
294
320
|
|
295
|
-
const FormSizeRowsGutter: Record<typeof ThemeSize.TYPE, number> = {
|
296
|
-
large: 32,
|
297
|
-
normal: 24,
|
298
|
-
small: 16,
|
299
|
-
mini: 14,
|
300
|
-
};
|
301
|
-
|
302
321
|
export const FormValidateMessagePosition = createEnum([
|
303
322
|
'bottom-left',
|
304
323
|
'bottom-right',
|
@@ -61,10 +61,10 @@ export const FormItem = designComponent({
|
|
61
61
|
|
62
62
|
const classes = useClasses(() => [
|
63
63
|
getComponentCls('form-item'),
|
64
|
-
`form-item-label-align-${formItemLayout.labelAlign.value}`,
|
65
|
-
`form-item-content-align-${formItemLayout.contentAlign.value}`,
|
66
64
|
`form-item-validate-position-${formItemLayout.validateMessagePosition.value}`,
|
67
65
|
{
|
66
|
+
[`form-item-label-align-${formItemLayout.labelAlign.value}`]: !!formItemLayout.labelAlign.value,
|
67
|
+
[`form-item-content-align-${formItemLayout.contentAlign.value}`]: !!formItemLayout.contentAlign.value,
|
68
68
|
'form-item-required': formItemValidation.isRequired.value,
|
69
69
|
'form-item-has-label': !!props.label,
|
70
70
|
'form-item-has-prepend': slots.prepend.isExist(),
|
@@ -97,7 +97,7 @@ export const FormItem = designComponent({
|
|
97
97
|
},
|
98
98
|
render: () => (
|
99
99
|
<div className={classes.value} style={formItemLayout.styles.value} ref={onRef.el}>
|
100
|
-
{props.label !== null && (
|
100
|
+
{props.label !== null && !props.hideLabel && (
|
101
101
|
<div className="form-item-label" style={formItemLayout.labelStyles.value} title={props.label}>
|
102
102
|
{formItemValidation.isRequired.value && <i className="form-item-required-tag">*</i>}
|
103
103
|
{slots.labelPrepend()}
|