sard-uniapp 1.22.2 → 1.23.1

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 (42) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/components/cascader/README.md +22 -15
  3. package/components/cascader/cascader.d.ts +4 -4
  4. package/components/cascader/cascader.vue +81 -70
  5. package/components/cascader/common.d.ts +6 -5
  6. package/components/cascader/common.js +23 -7
  7. package/components/cascader-input/cascader-input.vue +4 -2
  8. package/components/cascader-popout/cascader-popout.vue +5 -3
  9. package/components/config/index.d.ts +1 -1
  10. package/components/crop-image/README.md +15 -14
  11. package/components/crop-image/common.d.ts +1 -0
  12. package/components/crop-image/crop-image.vue +4 -1
  13. package/components/crop-image-agent/crop-image-agent.vue +1 -0
  14. package/components/form/README.md +58 -0
  15. package/components/form/form.d.ts +5 -5
  16. package/components/form/form.vue +6 -115
  17. package/components/form/index.d.ts +1 -0
  18. package/components/form/index.js +1 -0
  19. package/components/form/useForm.d.ts +9 -0
  20. package/components/form/useForm.js +97 -0
  21. package/components/form-item/form-item.d.ts +2 -2
  22. package/components/form-item/form-item.vue +21 -236
  23. package/components/form-item/useFormItem.d.ts +21 -0
  24. package/components/form-item/useFormItem.js +206 -0
  25. package/components/form-item-plain/form-item-plain.d.ts +20 -0
  26. package/components/form-item-plain/form-item-plain.vue +87 -0
  27. package/components/form-plain/common.d.ts +27 -0
  28. package/components/form-plain/common.js +1 -0
  29. package/components/form-plain/form-plain.d.ts +23 -0
  30. package/components/form-plain/form-plain.vue +67 -0
  31. package/components/form-plain/index.d.ts +1 -0
  32. package/components/form-plain/index.js +1 -0
  33. package/components/rate/README.md +21 -21
  34. package/components/rate/rate.vue +4 -1
  35. package/components/status-bar/README.md +1 -1
  36. package/global.d.ts +2 -0
  37. package/index.d.ts +1 -0
  38. package/index.js +1 -0
  39. package/package.json +2 -2
  40. package/utils/dom.d.ts +1 -1
  41. package/utils/dom.js +8 -5
  42. package/utils/is.d.ts +1 -1
@@ -0,0 +1,206 @@
1
+ import { computed, nextTick, onBeforeUnmount, onMounted, provide, reactive, ref, toRef, watch, } from 'vue';
2
+ import { formItemContextSymbol, useFormContext, } from '../form/common';
3
+ import { chainGet, chainSet, deepClone, getBoundingClientRect, getScrollIntoViewValue, getViewportScrollInfo, getWindowInfo, noop, toArray, uniqid, } from '../../utils';
4
+ export function useFormItem(props) {
5
+ // main
6
+ const formContext = useFormContext();
7
+ if (!formContext) {
8
+ throw new Error('FormItem must be included in Form.');
9
+ }
10
+ // 用于阻止验证
11
+ let isResetting = false;
12
+ const fieldValue = computed({
13
+ get() {
14
+ const model = formContext.model;
15
+ if (!model || !props.name) {
16
+ return;
17
+ }
18
+ return chainGet(model, toArray(props.name));
19
+ },
20
+ set(value) {
21
+ const model = formContext.model;
22
+ if (!model || !props.name) {
23
+ return;
24
+ }
25
+ chainSet(model, toArray(props.name), value);
26
+ },
27
+ });
28
+ let initialValue;
29
+ const validateMessage = ref('');
30
+ const validateState = ref('');
31
+ watch(() => props.error, () => {
32
+ validateMessage.value = props.error || '';
33
+ validateState.value = props.error ? 'error' : '';
34
+ });
35
+ watch(() => props.rules, () => {
36
+ if (validateMessage.value) {
37
+ validate().catch(noop);
38
+ }
39
+ }, {
40
+ deep: true,
41
+ flush: 'post',
42
+ });
43
+ const shouldShowError = computed(() => {
44
+ return (!!props.showError && !!formContext.showError && !!validateMessage.value);
45
+ });
46
+ const mergedValidateTrigger = computed(() => {
47
+ const trigger = props.validateTrigger ?? formContext.validateTrigger;
48
+ return trigger ? toArray(trigger) : undefined;
49
+ });
50
+ const mergedRules = computed(() => {
51
+ const rules = [];
52
+ if (props.rules) {
53
+ rules.push(...toArray(props.rules));
54
+ }
55
+ const formRules = formContext.rules;
56
+ if (formRules && props.name) {
57
+ const fRules = chainGet(formRules, toArray(props.name));
58
+ if (fRules) {
59
+ rules.push(...toArray(fRules));
60
+ }
61
+ }
62
+ const required = props.required;
63
+ if (required !== undefined) {
64
+ const requiredRules = rules
65
+ .map((rule, i) => [rule, i])
66
+ .filter(([rule]) => {
67
+ return Object.keys(rule).includes('required');
68
+ });
69
+ if (requiredRules.length > 0) {
70
+ for (const [rule, i] of requiredRules) {
71
+ if (rule.required !== required) {
72
+ rules[i] = { ...rule, required };
73
+ }
74
+ }
75
+ }
76
+ else {
77
+ rules.push({ required });
78
+ }
79
+ }
80
+ const trigger = mergedValidateTrigger.value;
81
+ if (trigger && trigger.length > 0) {
82
+ for (let i = 0, l = rules.length; i < l; i++) {
83
+ const rule = rules[i];
84
+ if (!rule.trigger) {
85
+ rules[i] = { ...rule, trigger: [...trigger] };
86
+ }
87
+ }
88
+ }
89
+ return rules;
90
+ });
91
+ const isRequired = computed(() => {
92
+ return mergedRules.value.some((rule) => rule.required);
93
+ });
94
+ const shouldShowStar = computed(() => {
95
+ return !formContext.hideStar && !props.hideStar && isRequired.value;
96
+ });
97
+ const validate = async (trigger) => {
98
+ if (isResetting || !props.name) {
99
+ return;
100
+ }
101
+ const validRules = formContext.validator.getValidTriggerRules(mergedRules.value, trigger);
102
+ if (validRules.length === 0) {
103
+ return;
104
+ }
105
+ validateState.value = 'validating';
106
+ try {
107
+ await formContext.validator.validate(mergedRules.value, {
108
+ validateFirst: true,
109
+ value: fieldValue.value,
110
+ name: props.name,
111
+ label: props.label,
112
+ trigger,
113
+ });
114
+ validateState.value = 'success';
115
+ validateMessage.value = '';
116
+ }
117
+ catch (messages) {
118
+ validateState.value = 'error';
119
+ validateMessage.value = messages[0];
120
+ const error = {
121
+ name: props.name,
122
+ value: fieldValue.value,
123
+ message: validateMessage.value,
124
+ };
125
+ throw error;
126
+ }
127
+ };
128
+ const clearValidate = () => {
129
+ validateState.value = '';
130
+ validateMessage.value = '';
131
+ isResetting = false;
132
+ };
133
+ const reset = async () => {
134
+ isResetting = true;
135
+ fieldValue.value = deepClone(initialValue);
136
+ await nextTick();
137
+ clearValidate();
138
+ };
139
+ const fieldId = uniqid();
140
+ const scrollToField = async () => {
141
+ const [scrollInfo, fieldRect, windowInfo] = await Promise.all([
142
+ getViewportScrollInfo(),
143
+ getBoundingClientRect(`.${fieldId}`),
144
+ getWindowInfo(),
145
+ ]);
146
+ const scrollTop = getScrollIntoViewValue(windowInfo.windowHeight, scrollInfo.scrollTop, fieldRect.height, fieldRect.top + scrollInfo.scrollTop, formContext.scrollIntoViewOptions);
147
+ uni.pageScrollTo({
148
+ scrollTop,
149
+ duration: formContext.scrollIntoViewOptions?.duration ??
150
+ formContext.scrollDuration,
151
+ });
152
+ };
153
+ const onBlur = () => {
154
+ validate('blur').catch(noop);
155
+ };
156
+ const onChange = () => {
157
+ validate('change').catch(noop);
158
+ };
159
+ const context = reactive({
160
+ name: toRef(() => props.name),
161
+ validateMessage,
162
+ validateState,
163
+ validate,
164
+ clearValidate,
165
+ reset,
166
+ scrollToField,
167
+ onBlur,
168
+ onChange,
169
+ });
170
+ onMounted(() => {
171
+ if (props.name) {
172
+ initialValue = deepClone(fieldValue.value);
173
+ formContext.addField(context);
174
+ }
175
+ });
176
+ onBeforeUnmount(() => {
177
+ formContext.removeField(context);
178
+ });
179
+ const direction = computed(() => props.direction || formContext.direction);
180
+ const labelAlign = computed(() => props.labelAlign || formContext.labelAlign);
181
+ const labelValign = computed(() => props.labelValign || formContext.labelValign);
182
+ const starPosition = computed(() => props.starPosition || formContext.starPosition);
183
+ const labelWidth = computed(() => props.labelWidth || formContext.labelWidth);
184
+ provide(formItemContextSymbol, context);
185
+ const expose = {
186
+ validate,
187
+ reset,
188
+ clearValidate,
189
+ scrollToField,
190
+ validateMessage,
191
+ validateState,
192
+ };
193
+ return {
194
+ expose,
195
+ fieldId,
196
+ validateState,
197
+ shouldShowStar,
198
+ validateMessage,
199
+ shouldShowError,
200
+ direction,
201
+ labelAlign,
202
+ labelValign,
203
+ starPosition,
204
+ labelWidth,
205
+ };
206
+ }
@@ -0,0 +1,20 @@
1
+ import { type FormItemPlainProps, type FormItemPlainSlots } from '../form-plain/common';
2
+ declare function __VLS_template(): Readonly<FormItemPlainSlots> & FormItemPlainSlots;
3
+ declare const __VLS_component: import("vue").DefineComponent<FormItemPlainProps, {
4
+ validate: (trigger?: string | string[]) => Promise<void>;
5
+ reset: () => Promise<void>;
6
+ clearValidate: () => void;
7
+ scrollToField: () => void;
8
+ validateMessage: import("vue").Ref<string>;
9
+ validateState: import("vue").Ref<import("../form/common").ValidateState>;
10
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<FormItemPlainProps> & Readonly<{}>, {
11
+ required: boolean;
12
+ showError: boolean;
13
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
14
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
15
+ export default _default;
16
+ type __VLS_WithTemplateSlots<T, S> = T & {
17
+ new (): {
18
+ $slots: S;
19
+ };
20
+ };
@@ -0,0 +1,87 @@
1
+ <template>
2
+ <view :class="rootClass" :style="rootStyle">
3
+ <slot></slot>
4
+ <slot
5
+ name="custom"
6
+ :field-id="fieldId"
7
+ :validate-state="validateState"
8
+ :should-show-star="shouldShowStar"
9
+ :validate-message="validateMessage"
10
+ :should-show-error="shouldShowError"
11
+ :direction="direction"
12
+ :label-align="labelAlign"
13
+ :label-valign="labelValign"
14
+ :star-position="starPosition"
15
+ :label-width="labelWidth"
16
+ ></slot>
17
+ </view>
18
+ </template>
19
+
20
+ <script>
21
+ import { mergeDefaults as _mergeDefaults, defineComponent as _defineComponent } from "vue";
22
+ import { useFormItem } from "../form-item/useFormItem";
23
+ import { defaultFormItemProps } from "../form/common";
24
+ /**
25
+ * @property {string} rootClass 组件根元素类名,默认值:-。
26
+ * @property {StyleValue} rootStyle 组件根元素样式,默认值:-。
27
+ * @property {'horizontal' | 'vertical'} direction 表单排列方向,默认值:'horizontal'。
28
+ * @property {string} labelWidth 标签宽度,默认值:-。
29
+ * @property {'start' | 'center' | 'end'} labelAlign 标签水平对齐方式,默认值:'start'。
30
+ * @property {'start' | 'center' | 'end'} labelValign 标签垂直对齐方式,默认值:'start'。
31
+ * @property {'left' | 'right'} starPosition 必填星号在标签的左边或右边,默认值:'left'。
32
+ * @property {string} label 标签文本,默认值:-。
33
+ * @property {boolean} required 是否为必填项,如不设置,则会根据校验规则确认,默认值:-。
34
+ * @property {FieldName} name 表单域 `model` 字段,在使用 `validate、reset` 方法的情况下,该属性是必填的。,默认值:-。
35
+ * @property {Rule | Rule[]} rules 表单验证规则,默认值:-。
36
+ * @property {TriggerType} validateTrigger 设置字段校验的时机,默认值:change。
37
+ * @property {string} error 表单域验证错误时的提示信息。设置该值会导致表单验证状态变为 `error`,并显示该错误信息。,默认值:-。
38
+ * @property {boolean} showError 是否显示校验错误信息,默认值:true。
39
+ * @property {boolean} inlaid 去掉边框和内边距,用于嵌入到其他组件中,默认值:false。
40
+ */
41
+ export default _defineComponent({
42
+ ...{
43
+ options: {
44
+ virtualHost: true,
45
+ styleIsolation: "shared"
46
+ }
47
+ },
48
+ __name: "form-item-plain",
49
+ props: _mergeDefaults({
50
+ rootStyle: { type: [Boolean, null, String, Object, Array], required: false, skipCheck: true },
51
+ rootClass: { type: String, required: false },
52
+ direction: { type: String, required: false },
53
+ labelWidth: { type: String, required: false },
54
+ labelAlign: { type: String, required: false },
55
+ labelValign: { type: String, required: false },
56
+ starPosition: { type: String, required: false },
57
+ label: { type: String, required: false },
58
+ hideStar: { type: Boolean, required: false },
59
+ required: { type: Boolean, required: false, skipCheck: true },
60
+ name: { type: [String, Number, Array], required: false },
61
+ rules: { type: [Object, Array], required: false },
62
+ validateTrigger: { type: [String, Array], required: false },
63
+ error: { type: String, required: false },
64
+ showError: { type: Boolean, required: false },
65
+ inlaid: { type: Boolean, required: false }
66
+ }, defaultFormItemProps()),
67
+ setup(__props, { expose: __expose }) {
68
+ const props = __props;
69
+ const {
70
+ expose,
71
+ fieldId,
72
+ validateState,
73
+ shouldShowStar,
74
+ validateMessage,
75
+ shouldShowError,
76
+ direction,
77
+ labelAlign,
78
+ labelValign,
79
+ starPosition,
80
+ labelWidth
81
+ } = useFormItem(props);
82
+ __expose(expose);
83
+ const __returned__ = { props, expose, fieldId, validateState, shouldShowStar, validateMessage, shouldShowError, direction, labelAlign, labelValign, starPosition, labelWidth };
84
+ return __returned__;
85
+ }
86
+ });
87
+ </script>
@@ -0,0 +1,27 @@
1
+ import { type FormExpose, type FormProps, type FormSlots, type FormItemProps, type FormItemExpose, type ValidateState } from '../form/common';
2
+ export interface FormPlainProps extends FormProps {
3
+ }
4
+ export interface FormPlainSlots extends FormSlots {
5
+ }
6
+ export interface FormPlainExpose extends FormExpose {
7
+ }
8
+ export interface FormItemPlainProps extends FormItemProps {
9
+ }
10
+ export interface FormItemPlainSlotsProps {
11
+ fieldId: string;
12
+ validateState: ValidateState;
13
+ shouldShowStar: boolean;
14
+ validateMessage: string;
15
+ shouldShowError: boolean;
16
+ direction: FormProps['direction'];
17
+ labelAlign: FormProps['labelAlign'];
18
+ labelValign: FormProps['labelValign'];
19
+ starPosition: FormProps['starPosition'];
20
+ labelWidth: FormProps['labelWidth'];
21
+ }
22
+ export interface FormItemPlainSlots {
23
+ default?(props: Record<string, never>): any;
24
+ custom?(props: FormItemPlainSlotsProps): any;
25
+ }
26
+ export interface FormItemPlainExpose extends FormItemExpose {
27
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,23 @@
1
+ import { type FormPlainProps, type FormPlainSlots } from './common';
2
+ declare function __VLS_template(): Readonly<FormPlainSlots> & FormPlainSlots;
3
+ declare const __VLS_component: import("vue").DefineComponent<FormPlainProps, {
4
+ validate: (nameList?: import("../form/common").FieldName[]) => Promise<void>;
5
+ reset: (nameList?: import("../form/common").FieldName[]) => Promise<void>;
6
+ clearValidate: (nameList?: import("../form/common").FieldName[]) => Promise<void>;
7
+ scrollToField: (name: import("../form/common").FieldName) => void;
8
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<FormPlainProps> & Readonly<{}>, {
9
+ direction: "horizontal" | "vertical";
10
+ labelAlign: "start" | "center" | "end";
11
+ labelValign: "start" | "center" | "end";
12
+ starPosition: "left" | "right";
13
+ validateOnRuleChange: boolean;
14
+ showError: boolean;
15
+ scrollDuration: number;
16
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
17
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
18
+ export default _default;
19
+ type __VLS_WithTemplateSlots<T, S> = T & {
20
+ new (): {
21
+ $slots: S;
22
+ };
23
+ };
@@ -0,0 +1,67 @@
1
+ <template>
2
+ <view :class="rootClass" :style="rootStyle">
3
+ <slot></slot>
4
+ </view>
5
+ </template>
6
+
7
+ <script>
8
+ import { mergeDefaults as _mergeDefaults, defineComponent as _defineComponent } from "vue";
9
+ import { useForm } from "../form/useForm";
10
+ import { defaultFormProps } from "../form/common";
11
+ /**
12
+ * @property {string} rootClass 组件根元素类名,默认值:-。
13
+ * @property {StyleValue} rootStyle 组件根元素样式,默认值:-。
14
+ * @property {Record\<string, any>} model 表单数据对象,默认值:-。
15
+ * @property {FormRules} rules 表单验证规则,默认值:-。
16
+ * @property {TriggerType} validateTrigger 设置字段校验的时机,默认值:change。
17
+ * @property {boolean} validateOnRuleChange 是否在 `rules` 属性改变后立即触发一次验证,默认值:true。
18
+ * @property {'horizontal' | 'vertical'} direction 表单排列方向,默认值:'horizontal'。
19
+ * @property {string} labelWidth 标签宽度,默认值:-。
20
+ * @property {'start' | 'center' | 'end'} labelAlign 标签水平对齐方式,默认值:'start'。
21
+ * @property {'start' | 'center' | 'end'} labelValign 标签垂直对齐方式,默认值:'start'。
22
+ * @property {'left' | 'right'} starPosition 必填星号在标签的左边或右边,默认值:'left'。
23
+ * @property {boolean} hideStar 是否隐藏必填时的星号,默认值:false。
24
+ * @property {boolean} showError 是否显示校验错误信息,默认值:true。
25
+ * @property {boolean} scrollToFirstError 当校验失败时,滚动到第一个错误表单项,默认值:false。
26
+ * @property {[ScrollIntoViewOptions](../utilities/geometry#ScrollIntoViewOptions)} scrollIntoViewOptions 自定义滚动配置选项,默认值:{position: 'nearest', startOffset: 0, endOffset: 0}。
27
+ * @property {boolean} disabled 是否禁用该表单内的所有组件。 如果设置为 `true`, 它将覆盖内部组件的 `disabled` 属性,默认值:false。
28
+ * @property {boolean} readonly 是否只读该表单内的所有组件。 如果设置为 `true`, 它将覆盖内部组件的 `readonly` 属性,默认值:false。
29
+ */
30
+ export default _defineComponent({
31
+ ...{
32
+ options: {
33
+ virtualHost: true,
34
+ styleIsolation: "shared"
35
+ }
36
+ },
37
+ __name: "form-plain",
38
+ props: _mergeDefaults({
39
+ rootStyle: { type: [Boolean, null, String, Object, Array], required: false, skipCheck: true },
40
+ rootClass: { type: String, required: false },
41
+ model: { type: Object, required: false },
42
+ rules: { type: Object, required: false },
43
+ validateTrigger: { type: [String, Array], required: false },
44
+ validateOnRuleChange: { type: Boolean, required: false },
45
+ direction: { type: String, required: false },
46
+ labelWidth: { type: String, required: false },
47
+ labelAlign: { type: String, required: false },
48
+ labelValign: { type: String, required: false },
49
+ starPosition: { type: String, required: false },
50
+ hideStar: { type: Boolean, required: false },
51
+ showError: { type: Boolean, required: false },
52
+ scrollToFirstError: { type: Boolean, required: false },
53
+ scrollIntoViewOptions: { type: Object, required: false },
54
+ scrollDuration: { type: Number, required: false },
55
+ disabled: { type: Boolean, required: false },
56
+ readonly: { type: Boolean, required: false },
57
+ card: { type: Boolean, required: false }
58
+ }, defaultFormProps),
59
+ setup(__props, { expose: __expose }) {
60
+ const props = __props;
61
+ const { expose } = useForm(props);
62
+ __expose(expose);
63
+ const __returned__ = { props, expose };
64
+ return __returned__;
65
+ }
66
+ });
67
+ </script>
@@ -0,0 +1 @@
1
+ export { type FormPlainProps, type FormPlainSlots, type FormPlainExpose, type FormItemPlainProps, type FormItemPlainSlots, type FormItemPlainExpose, } from './common';
@@ -0,0 +1 @@
1
+ export {};
@@ -57,7 +57,7 @@ import Rate from 'sard-uniapp/components/rate/rate.vue'
57
57
 
58
58
  ### 允许清空
59
59
 
60
- 当 `clearable` 属性设置为 `true`,再次点击相同的值时,可以将值重置为 0。
60
+ 当 `clearable` 属性设置为 `true`,再次点击相同的值,或划到最左边时,可以将值重置为 0。
61
61
 
62
62
  @code('${DEMO_PATH}/rate/demo/Clearable.vue')
63
63
 
@@ -71,26 +71,26 @@ import Rate from 'sard-uniapp/components/rate/rate.vue'
71
71
 
72
72
  ### RateProps
73
73
 
74
- | 属性 | 描述 | 类型 | 默认值 |
75
- | -------------- | ---------------------------- | ---------- | ------ |
76
- | root-class | 组件根元素类名 | string | - |
77
- | root-style | 组件根元素样式 | StyleValue | - |
78
- | model-value | 选中图标数 | number | - |
79
- | allow-half | 是否允许半选 | boolean | false |
80
- | clearable | 是否允许清空,划到最左边清空 | boolean | false |
81
- | count | 图标总数 | number | 5 |
82
- | size | 图标大小 | string | - |
83
- | gap | 图标间距 | string | - |
84
- | icon-family | 图标字体 | string | - |
85
- | icon | 自定义选中时的图标 | string | - |
86
- | void-icon | 自定义未选中时的图标 | string | - |
87
- | text | 自定义选中时的文字 | string | - |
88
- | void-text | 自定义未选中时的文字 | string | - |
89
- | color | 选中时的颜色 | string | - |
90
- | void-color | 未选中时的颜色 | string | - |
91
- | disabled | 禁用状态 | boolean | false |
92
- | readonly | 只读状态 | boolean | false |
93
- | validate-event | 是否触发表单验证 | boolean | true |
74
+ | 属性 | 描述 | 类型 | 默认值 |
75
+ | -------------- | ---------------------------------------------- | ---------- | ------ |
76
+ | root-class | 组件根元素类名 | string | - |
77
+ | root-style | 组件根元素样式 | StyleValue | - |
78
+ | model-value | 选中图标数 | number | - |
79
+ | allow-half | 是否允许半选 | boolean | false |
80
+ | clearable | 在点击相同值,或划到最左边时,是否将值重置为 0 | boolean | false |
81
+ | count | 图标总数 | number | 5 |
82
+ | size | 图标大小 | string | - |
83
+ | gap | 图标间距 | string | - |
84
+ | icon-family | 图标字体 | string | - |
85
+ | icon | 自定义选中时的图标 | string | - |
86
+ | void-icon | 自定义未选中时的图标 | string | - |
87
+ | text | 自定义选中时的文字 | string | - |
88
+ | void-text | 自定义未选中时的文字 | string | - |
89
+ | color | 选中时的颜色 | string | - |
90
+ | void-color | 未选中时的颜色 | string | - |
91
+ | disabled | 禁用状态 | boolean | false |
92
+ | readonly | 只读状态 | boolean | false |
93
+ | validate-event | 是否触发表单验证 | boolean | true |
94
94
 
95
95
  ### RateEmits
96
96
 
@@ -71,7 +71,7 @@ import { useMouseDown } from "../../use";
71
71
  * @property {StyleValue} rootStyle 组件根元素样式,默认值:-。
72
72
  * @property {number} modelValue 选中图标数,默认值:-。
73
73
  * @property {boolean} allowHalf 是否允许半选,默认值:false。
74
- * @property {boolean} clearable 是否允许清空,划到最左边清空,默认值:false。
74
+ * @property {boolean} clearable 在点击相同值,或划到最左边时,是否将值重置为 0,默认值:false。
75
75
  * @property {number} count 图标总数,默认值:5。
76
76
  * @property {string} size 图标大小,默认值:-。
77
77
  * @property {string} gap 图标间距,默认值:-。
@@ -225,6 +225,9 @@ export default _defineComponent({
225
225
  }
226
226
  }
227
227
  }
228
+ if (nextValue === 0 && !props.clearable) {
229
+ nextValue = props.allowHalf ? 0.5 : 1;
230
+ }
228
231
  if (nextValue !== void 0 && nextValue !== innerValue.value) {
229
232
  innerValue.value = nextValue;
230
233
  emit("update:model-value", nextValue);
@@ -31,7 +31,7 @@ setConfig({
31
31
 
32
32
  // 2. 获取状态栏高度
33
33
  // 假设接口如下
34
- const statusBarHeight = window.toggle.getBarHeight()
34
+ const statusBarHeight = window.android.getBarHeight()
35
35
 
36
36
  // 3. 声明到 html 元素上
37
37
  document.documentElement.style.setProperty(
package/global.d.ts CHANGED
@@ -45,6 +45,8 @@ declare module 'vue' {
45
45
  SarFloatingPanel: typeof import('./components/floating-panel/floating-panel').default
46
46
  SarForm: typeof import('./components/form/form').default
47
47
  SarFormItem: typeof import('./components/form-item/form-item').default
48
+ SarFormItemPlain: typeof import('./components/form-item-plain/form-item-plain').default
49
+ SarFormPlain: typeof import('./components/form-plain/form-plain').default
48
50
  SarGrid: typeof import('./components/grid/grid').default
49
51
  SarGridItem: typeof import('./components/grid-item/grid-item').default
50
52
  SarIcon: typeof import('./components/icon/icon').default
package/index.d.ts CHANGED
@@ -39,6 +39,7 @@ export * from './components/fab';
39
39
  export * from './components/floating-bubble';
40
40
  export * from './components/floating-panel';
41
41
  export * from './components/form';
42
+ export * from './components/form-plain';
42
43
  export * from './components/grid';
43
44
  export * from './components/icon';
44
45
  export * from './components/indexes';
package/index.js CHANGED
@@ -39,6 +39,7 @@ export * from './components/fab';
39
39
  export * from './components/floating-bubble';
40
40
  export * from './components/floating-panel';
41
41
  export * from './components/form';
42
+ export * from './components/form-plain';
42
43
  export * from './components/grid';
43
44
  export * from './components/icon';
44
45
  export * from './components/indexes';
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "id": "sard-uniapp",
3
3
  "name": "sard-uniapp",
4
4
  "displayName": "sard-uniapp",
5
- "version": "1.22.2",
5
+ "version": "1.23.1",
6
6
  "description": "sard-uniapp 是一套基于 Uniapp + Vue3 框架开发的兼容多端的 UI 组件库",
7
7
  "main": "index.js",
8
8
  "scripts": {
@@ -123,7 +123,7 @@
123
123
  "lodash-es": "^4.17.21",
124
124
  "prettier": "^3.5.3",
125
125
  "region-data": "^1.2.3",
126
- "sard-cli": "^1.3.6",
126
+ "sard-cli": "^1.3.7",
127
127
  "sass": "^1.69.7",
128
128
  "tailwindcss": "^3.4.17",
129
129
  "tel-area-code": "^1.1.0",
package/utils/dom.d.ts CHANGED
@@ -6,7 +6,7 @@ import { type NodeRect } from './geometry';
6
6
  * @param instance 父组件实例
7
7
  * @returns Promise<NodeRect>
8
8
  */
9
- export declare function getBoundingClientRect(selector: string, instance: ComponentInternalInstance | null): Promise<NodeRect>;
9
+ export declare function getBoundingClientRect(selector: string, instance?: ComponentInternalInstance | null): Promise<NodeRect>;
10
10
  /**
11
11
  * 获取可使用窗口尺寸
12
12
  */
package/utils/dom.js CHANGED
@@ -6,11 +6,14 @@
6
6
  */
7
7
  export function getBoundingClientRect(selector, instance) {
8
8
  return new Promise((resolve) => {
9
- uni
10
- .createSelectorQuery()
11
- // #ifndef MP-ALIPAY
12
- .in(instance?.proxy)
13
- // #endif
9
+ let selectorQuery = uni.createSelectorQuery();
10
+ // #ifndef MP-ALIPAY
11
+ const proxy = instance?.proxy;
12
+ if (proxy) {
13
+ selectorQuery = selectorQuery.in(proxy);
14
+ }
15
+ // #endif
16
+ selectorQuery
14
17
  .select(selector)
15
18
  .boundingClientRect((data) => {
16
19
  resolve(data);
package/utils/is.d.ts CHANGED
@@ -9,7 +9,7 @@ export declare function isPlainObject(target: any): target is Record<PropertyKey
9
9
  * @param {any} target
10
10
  * @return {boolean}
11
11
  */
12
- export declare function isEmptyArray(target: any): boolean;
12
+ export declare function isEmptyArray(target: any): target is [];
13
13
  /**
14
14
  * @description: 判断是否为对象
15
15
  * @param {any} target