@peng_kai/kit 0.2.40 → 0.2.41

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.
@@ -5,6 +5,7 @@ import Duration from './src/Duration.vue';
5
5
  import IP from './src/IP.vue';
6
6
 
7
7
  export { createTagGetter } from './src/createTagGetter';
8
+ export { createDateTypeSwitcher } from './src/createDateTypeSwitcher';
8
9
 
9
10
  export const Text = {
10
11
  Hash,
@@ -0,0 +1,41 @@
1
+ import { useCycleList } from '@vueuse/core';
2
+ import { computed, defineComponent } from 'vue';
3
+ import Datetime from './Datetime.vue';
4
+
5
+ export function createDateTypeSwitcher() {
6
+ const cycle = useCycleList(['local', 'utc'] as const);
7
+
8
+ const Switcher = defineComponent({
9
+ props: [],
10
+ setup(props) {
11
+ const title = computed(() => {
12
+ const state = cycle.state.value;
13
+ return ({
14
+ local: '本地',
15
+ utc: 'UTC',
16
+ } satisfies Record<typeof state, string>)[state];
17
+ });
18
+
19
+ return () => (
20
+ <div
21
+ class="flex-inline items-center ml-1 cursor-pointer select-none text-$antd-colorPrimary hover:op-60"
22
+ onClick={() => cycle.next()}
23
+ >
24
+ (
25
+ <span class="min-w-2em inline-block text-center">
26
+ {title.value}
27
+ </span>
28
+ )
29
+ <i class="i-mi:switch text-1.2em" />
30
+ </div>
31
+ );
32
+ },
33
+ });
34
+ const Display = defineComponent({
35
+ setup(props, { attrs }) {
36
+ return () => (<Datetime {...attrs} utc={cycle.state.value === 'utc'} />);
37
+ },
38
+ });
39
+
40
+ return { Switcher, Display };
41
+ }
@@ -6,7 +6,7 @@
6
6
  import type { FormInstance, FormItemProps, RuleObject } from 'ant-design-vue/es/form';
7
7
  import type { FormProps } from 'ant-design-vue';
8
8
  import { type MaybeRefOrGetter, computed, reactive, ref, shallowRef, toRef, watch, watchEffect } from 'vue';
9
- import { mapValues } from 'lodash-es';
9
+ import { cloneDeep, mapValues } from 'lodash-es';
10
10
  import { reactiveComputed } from '@vueuse/core';
11
11
  import { GROUP_SEP, buildGroupField, getGroupIndex } from './useAntdForm.helpers';
12
12
 
@@ -50,15 +50,16 @@ function useAntdForm<S extends Record<string, unknown>, TS = S>(schemas: MaybeRe
50
50
  get scrollToField() {
51
51
  return formRef.value?.scrollToField;
52
52
  },
53
- get validate() {
54
- return formRef.value?.validate;
55
- },
56
53
  get validateFields() {
57
54
  return formRef.value?.validateFields;
58
55
  },
59
56
  get clearValidate() {
60
57
  return formRef.value?.clearValidate;
61
58
  },
59
+ async validate(...args: Parameters<FormInstance['validate']>) {
60
+ const res = await formRef.value?.validate(...args);
61
+ return cloneDeep(reactive(res ?? {}));
62
+ },
62
63
  addGroup(groupName: string, groupSchemas: Record<string, ItemSchema>) {
63
64
  const i = getGroupIndex(groupName, schemasR.value) + 1;
64
65
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@peng_kai/kit",
3
3
  "type": "module",
4
- "version": "0.2.40",
4
+ "version": "0.2.41",
5
5
  "description": "",
6
6
  "author": "",
7
7
  "license": "ISC",