@peng_kai/kit 0.2.17 → 0.2.18

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.
@@ -249,8 +249,7 @@ function resetSetting() {
249
249
  v-bind="settingForm.props"
250
250
  class="ant-cover__col2-form"
251
251
  layout="vertical"
252
- :disabled="settingMutator.isPending.value"
253
- :readonly="props.readonly"
252
+ :disabled="settingMutator.isPending.value || props.readonly"
254
253
  >
255
254
  <template v-for="item of configList" :key="item.key">
256
255
  <FormItem v-bind="settingForm.itemProps[item.key]" :label="item.label" :extra="item.summary">
@@ -1,13 +1,11 @@
1
1
  <script lang="ts">
2
- import { computed, nextTick, watch } from 'vue';
2
+ import { computed, defineModel, watch } from 'vue';
3
3
  import { InputNumber as AInputNumber, Form } from 'ant-design-vue';
4
- import { isNil } from 'lodash-es';
5
4
  </script>
6
5
 
7
6
  <script setup lang="ts">
8
7
  const props = withDefaults(
9
8
  defineProps<{
10
- value: [number | undefined, number | undefined]
11
9
  placeholder?: [string, string]
12
10
  min?: number
13
11
  max?: number
@@ -17,41 +15,38 @@ const props = withDefaults(
17
15
  max: Number.POSITIVE_INFINITY,
18
16
  },
19
17
  );
20
- const emits = defineEmits<{
21
- (e: 'update:value', value: typeof props.value): void
22
- }>();
18
+ const rangeValue = defineModel<[number | undefined, number | undefined]>('value', { default: [] });
23
19
 
24
20
  const formItemContext = Form.useInjectFormItemContext();
25
21
  const minValue = computed({
26
- get: () => props.value[0],
27
- set: v => emits('update:value', [v, props.value[1]]),
22
+ get: () => rangeValue.value[0],
23
+ set: v => rangeValue.value = [v, rangeValue.value[1]],
28
24
  });
29
25
  const maxValue = computed({
30
- get: () => props.value[1],
31
- set: v => emits('update:value', [props.value[0], v]),
26
+ get: () => rangeValue.value[1],
27
+ set: v => rangeValue.value = [rangeValue.value[0], v],
32
28
  });
33
29
 
34
30
  watch([minValue, maxValue], () => formItemContext.onFieldChange());
35
31
 
36
32
  function onBlur() {
37
- const min = props.value[0];
38
- const max = props.value[1];
33
+ const [min, max] = rangeValue.value;
39
34
 
40
- if (!isNil(min) && !isNil(max))
41
- emits('update:value', [min, max].sort() as [number, number]);
35
+ if (typeof min === 'number' && typeof max === 'number')
36
+ rangeValue.value = min > max ? [max, min] : [min, max];
42
37
  }
43
38
  </script>
44
39
 
45
40
  <template>
46
41
  <div class="flex items-center">
47
42
  <AInputNumber
48
- v-model:value="minValue" class="w-full" :min="props.min"
43
+ v-model:value="rangeValue[0]" class="w-full" :min="props.min"
49
44
  :max="props.max" :placeholder="props.placeholder?.[0]"
50
45
  @blur="onBlur"
51
46
  />
52
47
  <span>&nbsp;-&nbsp;</span>
53
48
  <AInputNumber
54
- v-model:value="maxValue" class="w-full" :min="props.min"
49
+ v-model:value="rangeValue[1]" class="w-full" :min="props.min"
55
50
  :max="props.max" :placeholder="props.placeholder?.[1]"
56
51
  @blur="onBlur"
57
52
  />
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@peng_kai/kit",
3
3
  "type": "module",
4
- "version": "0.2.17",
4
+ "version": "0.2.18",
5
5
  "description": "",
6
6
  "author": "",
7
7
  "license": "ISC",