@peng_kai/kit 0.2.7 → 0.2.9

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.
@@ -1,5 +1,4 @@
1
1
  <script lang="ts">
2
- import { reactiveComputed } from '@vueuse/core';
3
2
  import { cloneDeep, mapKeys, mapValues } from 'lodash-es';
4
3
  import { Button, Card, CheckboxGroup, DatePicker, type DatePickerProps, Form, FormItem, Input, InputNumber, RadioGroup, RangePicker, Select, Textarea } from 'ant-design-vue';
5
4
  import { computed, ref, toRef } from 'vue';
@@ -150,11 +149,14 @@ const antdValueResolvers: Record<number, (value: any) => any> = {
150
149
  </script>
151
150
 
152
151
  <script setup lang="ts">
153
- const props = defineProps<{
152
+ const props = withDefaults(defineProps<{
154
153
  categoryApi: Api.Request
155
154
  configApi: Api.Request
156
155
  updateApi: Api.Request
157
- }>();
156
+ readonly?: boolean
157
+ }>(), {
158
+ readonly: false,
159
+ });
158
160
 
159
161
  const queryClient = useQueryClient();
160
162
 
@@ -196,7 +198,7 @@ const settingMutator = useMutation({
196
198
  queryClient.invalidateQueries({ queryKey: [props.configApi.id], exact: false });
197
199
  },
198
200
  });
199
- const formSchema = reactiveComputed(() => {
201
+ const formSchema = computed(() => {
200
202
  const _configList = configList.value ?? [];
201
203
  const entries = _configList.map(config => [
202
204
  config.key,
@@ -248,6 +250,7 @@ function resetSetting() {
248
250
  class="ant-cover__col2-form"
249
251
  layout="vertical"
250
252
  :disabled="settingMutator.isPending.value"
253
+ :readonly="props.readonly"
251
254
  >
252
255
  <template v-for="item of configList" :key="item.key">
253
256
  <FormItem v-bind="settingForm.itemProps[item.key]" :label="item.label" :extra="item.summary">
@@ -314,7 +317,7 @@ function resetSetting() {
314
317
  </template>
315
318
  </Form>
316
319
 
317
- <template #actions>
320
+ <template v-if="!props.readonly" #actions>
318
321
  <Button :disabled="settingMutator.isPending.value" @click="resetSetting()">
319
322
  重置
320
323
  </Button>
@@ -103,7 +103,6 @@ function useAntdForm<S extends Record<string, unknown>, TS = S>(schemas: MaybeRe
103
103
  _state[k] = (k in state.value) ? toRef(state.value, k) : toRef(item, 'value');
104
104
  }
105
105
 
106
- console.log('🤡 / _state:', _state);
107
106
  state.value = _state;
108
107
  }, { immediate: true });
109
108
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@peng_kai/kit",
3
3
  "type": "module",
4
- "version": "0.2.7",
4
+ "version": "0.2.9",
5
5
  "description": "",
6
6
  "author": "",
7
7
  "license": "ISC",
@@ -2,13 +2,13 @@ import { type Component, reactive } from 'vue';
2
2
  import type { ComponentExposed } from 'vue-component-type-helpers';
3
3
  import { makeDestructurable } from '@vueuse/core';
4
4
 
5
- export function useTemplateRefs<T extends Record<string, Component | HTMLElement>>() {
5
+ export function useTemplateRefs<T extends Record<string, Component>>() {
6
6
  type TK = keyof T;
7
- type TI = {
8
- [K in TK]?: T[K] extends Component ? ComponentExposed<T[K]> : T[K]
7
+ type TRs = {
8
+ [K in TK]?: T[K] extends (HTMLElement | SVGElement) ? T[K] : ComponentExposed<T[K]>
9
9
  };
10
10
 
11
- const refs = reactive({} as TI);
11
+ const refs = reactive({} as TRs);
12
12
  const setRefs = new Proxy({} as { [K in TK]: (t: any) => void }, {
13
13
  get(_, p: any) {
14
14
  return (t: any) => {