@shwfed/nuxt 0.7.9 → 0.7.11

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 (108) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/runtime/components/app.d.vue.ts +7 -56
  3. package/dist/runtime/components/app.vue +17 -404
  4. package/dist/runtime/components/app.vue.d.ts +7 -56
  5. package/dist/runtime/components/fields.d.vue.ts +154 -132
  6. package/dist/runtime/components/fields.vue +30 -295
  7. package/dist/runtime/components/fields.vue.d.ts +154 -132
  8. package/dist/runtime/components/table.d.vue.ts +129 -59
  9. package/dist/runtime/components/table.vue +51 -617
  10. package/dist/runtime/components/table.vue.d.ts +129 -59
  11. package/dist/runtime/components/ui/app/App.d.vue.ts +86 -0
  12. package/dist/runtime/components/ui/app/App.vue +414 -0
  13. package/dist/runtime/components/ui/app/App.vue.d.ts +86 -0
  14. package/dist/runtime/components/ui/checkbox/Checkbox.vue +6 -2
  15. package/dist/runtime/components/ui/dropdown-menu/DropdownMenuItem.vue +1 -1
  16. package/dist/runtime/components/ui/expression-editor/ExpressionEditor.d.vue.ts +30 -0
  17. package/dist/runtime/components/ui/expression-editor/ExpressionEditor.vue +87 -0
  18. package/dist/runtime/components/ui/expression-editor/ExpressionEditor.vue.d.ts +30 -0
  19. package/dist/runtime/components/ui/expression-editor/index.d.ts +1 -0
  20. package/dist/runtime/components/ui/expression-editor/index.js +1 -0
  21. package/dist/runtime/components/ui/field/FieldContent.vue +1 -1
  22. package/dist/runtime/components/ui/field/FieldError.vue +2 -2
  23. package/dist/runtime/components/ui/field/FieldLabel.vue +1 -1
  24. package/dist/runtime/components/ui/fields/Fields.d.vue.ts +376 -0
  25. package/dist/runtime/components/ui/fields/Fields.vue +441 -0
  26. package/dist/runtime/components/ui/fields/Fields.vue.d.ts +376 -0
  27. package/dist/runtime/components/ui/fields-configurator/FieldsConfiguratorDialog.d.vue.ts +163 -0
  28. package/dist/runtime/components/ui/fields-configurator/FieldsConfiguratorDialog.vue +363 -0
  29. package/dist/runtime/components/ui/fields-configurator/FieldsConfiguratorDialog.vue.d.ts +163 -0
  30. package/dist/runtime/components/ui/icon-picker/IconPicker.d.vue.ts +15 -0
  31. package/dist/runtime/components/ui/icon-picker/IconPicker.vue +178 -0
  32. package/dist/runtime/components/ui/icon-picker/IconPicker.vue.d.ts +15 -0
  33. package/dist/runtime/components/ui/icon-picker/index.d.ts +1 -0
  34. package/dist/runtime/components/ui/icon-picker/index.js +1 -0
  35. package/dist/runtime/components/ui/input/Input.d.vue.ts +1 -0
  36. package/dist/runtime/components/ui/input/Input.vue +2 -0
  37. package/dist/runtime/components/ui/input/Input.vue.d.ts +1 -0
  38. package/dist/runtime/components/ui/input-group/InputGroupAddon.vue +4 -1
  39. package/dist/runtime/components/ui/input-group/InputGroupCombobox.d.vue.ts +8 -3
  40. package/dist/runtime/components/ui/input-group/InputGroupCombobox.vue +8 -3
  41. package/dist/runtime/components/ui/input-group/InputGroupCombobox.vue.d.ts +8 -3
  42. package/dist/runtime/components/ui/input-group/InputGroupComboboxInput.d.vue.ts +8 -1
  43. package/dist/runtime/components/ui/input-group/InputGroupComboboxInput.vue +11 -2
  44. package/dist/runtime/components/ui/input-group/InputGroupComboboxInput.vue.d.ts +8 -1
  45. package/dist/runtime/components/ui/input-group/InputGroupInput.vue +1 -1
  46. package/dist/runtime/components/ui/input-group/InputGroupNumberField.d.vue.ts +5 -2
  47. package/dist/runtime/components/ui/input-group/InputGroupNumberField.vue +10 -4
  48. package/dist/runtime/components/ui/input-group/InputGroupNumberField.vue.d.ts +5 -2
  49. package/dist/runtime/components/ui/input-group/InputGroupTextarea.vue +1 -1
  50. package/dist/runtime/components/ui/input-group/index.js +1 -1
  51. package/dist/runtime/components/ui/locale/Locale.d.vue.ts +20 -0
  52. package/dist/runtime/components/ui/locale/Locale.vue +291 -0
  53. package/dist/runtime/components/ui/locale/Locale.vue.d.ts +20 -0
  54. package/dist/runtime/components/ui/locale/index.d.ts +1 -0
  55. package/dist/runtime/components/ui/locale/index.js +1 -0
  56. package/dist/runtime/components/ui/native-select/NativeSelect.d.vue.ts +2 -2
  57. package/dist/runtime/components/ui/native-select/NativeSelect.vue +1 -1
  58. package/dist/runtime/components/ui/native-select/NativeSelect.vue.d.ts +2 -2
  59. package/dist/runtime/components/ui/native-select/NativeSelectOption.d.vue.ts +1 -0
  60. package/dist/runtime/components/ui/native-select/NativeSelectOption.vue +4 -1
  61. package/dist/runtime/components/ui/native-select/NativeSelectOption.vue.d.ts +1 -0
  62. package/dist/runtime/components/ui/number-field/NumberFieldInput.vue +1 -1
  63. package/dist/runtime/components/ui/switch/Switch.vue +2 -2
  64. package/dist/runtime/components/ui/table/Table.d.vue.ts +147 -0
  65. package/dist/runtime/components/ui/table/Table.vue +952 -0
  66. package/dist/runtime/components/ui/table/Table.vue.d.ts +147 -0
  67. package/dist/runtime/components/ui/table/schema.d.ts +151 -0
  68. package/dist/runtime/components/ui/table/schema.js +142 -0
  69. package/dist/runtime/components/ui/table-configurator/TableConfiguratorDialog.d.vue.ts +128 -0
  70. package/dist/runtime/components/ui/table-configurator/TableConfiguratorDialog.vue +2719 -0
  71. package/dist/runtime/components/ui/table-configurator/TableConfiguratorDialog.vue.d.ts +128 -0
  72. package/dist/runtime/components/ui/table-configurator/menu.d.ts +37 -0
  73. package/dist/runtime/components/ui/table-configurator/menu.js +227 -0
  74. package/dist/runtime/components/ui/tabs/Tabs.d.vue.ts +24 -0
  75. package/dist/runtime/components/ui/tabs/Tabs.vue +30 -0
  76. package/dist/runtime/components/ui/tabs/Tabs.vue.d.ts +24 -0
  77. package/dist/runtime/components/ui/tabs/TabsContent.d.vue.ts +18 -0
  78. package/dist/runtime/components/ui/tabs/TabsContent.vue +23 -0
  79. package/dist/runtime/components/ui/tabs/TabsContent.vue.d.ts +18 -0
  80. package/dist/runtime/components/ui/tabs/TabsList.d.vue.ts +18 -0
  81. package/dist/runtime/components/ui/tabs/TabsList.vue +25 -0
  82. package/dist/runtime/components/ui/tabs/TabsList.vue.d.ts +18 -0
  83. package/dist/runtime/components/ui/tabs/TabsTrigger.d.vue.ts +18 -0
  84. package/dist/runtime/components/ui/tabs/TabsTrigger.vue +27 -0
  85. package/dist/runtime/components/ui/tabs/TabsTrigger.vue.d.ts +18 -0
  86. package/dist/runtime/components/ui/tabs/index.d.ts +4 -0
  87. package/dist/runtime/components/ui/tabs/index.js +4 -0
  88. package/dist/runtime/components/ui/textarea/Textarea.d.vue.ts +1 -0
  89. package/dist/runtime/components/ui/textarea/Textarea.vue +4 -2
  90. package/dist/runtime/components/ui/textarea/Textarea.vue.d.ts +1 -0
  91. package/dist/runtime/components/ui/toggle/Toggle.d.vue.ts +34 -0
  92. package/dist/runtime/components/ui/toggle/Toggle.vue +32 -0
  93. package/dist/runtime/components/ui/toggle/Toggle.vue.d.ts +34 -0
  94. package/dist/runtime/components/ui/toggle/index.d.ts +7 -0
  95. package/dist/runtime/components/ui/toggle/index.js +22 -0
  96. package/dist/runtime/composables/useTableRenderers.d.ts +2 -1
  97. package/dist/runtime/composables/useTableRenderers.js +2 -1
  98. package/dist/runtime/plugins/toast/index.d.ts +2 -2
  99. package/dist/runtime/style.css +1 -1
  100. package/dist/runtime/table-renderers/builtins.js +328 -137
  101. package/dist/runtime/table-renderers/registry.d.ts +2 -1
  102. package/dist/runtime/table-renderers/registry.js +3 -0
  103. package/dist/runtime/utils/coders.d.ts +29 -2
  104. package/dist/runtime/utils/coders.js +40 -2
  105. package/package.json +8 -6
  106. /package/dist/runtime/components/{logo.d.vue.ts → ui/logo/Logo.d.vue.ts} +0 -0
  107. /package/dist/runtime/components/{logo.vue → ui/logo/Logo.vue} +0 -0
  108. /package/dist/runtime/components/{logo.vue.d.ts → ui/logo/Logo.vue.d.ts} +0 -0
@@ -1,152 +1,174 @@
1
- import z from 'zod';
2
- import { Effect } from 'effect';
3
- export declare const StringFieldC: z.ZodObject<{
4
- type: z.ZodLiteral<"string">;
5
- path: z.ZodString;
6
- title: z.ZodArray<z.ZodObject<{
7
- locale: z.ZodString;
8
- message: z.ZodString;
9
- }, z.core.$strip>>;
10
- icon: z.ZodOptional<z.ZodString>;
11
- style: z.ZodOptional<z.ZodString>;
12
- discardEmptyString: z.ZodOptional<z.ZodBoolean>;
13
- maxLength: z.ZodOptional<z.ZodString>;
14
- hidden: z.ZodOptional<z.ZodString>;
15
- disabled: z.ZodOptional<z.ZodString>;
16
- }, z.core.$strip>;
17
- export declare const NumberFieldC: z.ZodObject<{
18
- type: z.ZodLiteral<"number">;
19
- path: z.ZodString;
20
- title: z.ZodArray<z.ZodObject<{
21
- locale: z.ZodString;
22
- message: z.ZodString;
23
- }, z.core.$strip>>;
24
- icon: z.ZodOptional<z.ZodString>;
25
- style: z.ZodOptional<z.ZodString>;
26
- min: z.ZodOptional<z.ZodString>;
27
- max: z.ZodOptional<z.ZodString>;
28
- step: z.ZodOptional<z.ZodString>;
29
- hidden: z.ZodOptional<z.ZodString>;
30
- disabled: z.ZodOptional<z.ZodString>;
31
- }, z.core.$strip>;
32
- export declare const SelectFieldC: z.ZodObject<{
33
- type: z.ZodLiteral<"select">;
34
- path: z.ZodString;
35
- title: z.ZodArray<z.ZodObject<{
36
- locale: z.ZodString;
37
- message: z.ZodString;
38
- }, z.core.$strip>>;
39
- icon: z.ZodOptional<z.ZodString>;
40
- options: z.ZodString;
41
- label: z.ZodString;
42
- value: z.ZodString;
43
- key: z.ZodString;
44
- style: z.ZodOptional<z.ZodString>;
45
- hidden: z.ZodOptional<z.ZodString>;
46
- disabled: z.ZodOptional<z.ZodString>;
47
- }, z.core.$strip>;
48
- export declare const CalendarFieldC: z.ZodObject<{
49
- type: z.ZodLiteral<"calendar">;
50
- path: z.ZodString;
51
- title: z.ZodArray<z.ZodObject<{
52
- locale: z.ZodString;
53
- message: z.ZodString;
54
- }, z.core.$strip>>;
55
- icon: z.ZodOptional<z.ZodString>;
56
- style: z.ZodOptional<z.ZodString>;
57
- mode: z.ZodEnum<{
58
- year: "year";
59
- month: "month";
60
- date: "date";
61
- }>;
62
- display: z.ZodOptional<z.ZodString>;
63
- value: z.ZodString;
64
- disableDate: z.ZodOptional<z.ZodString>;
65
- hidden: z.ZodOptional<z.ZodString>;
66
- disabled: z.ZodOptional<z.ZodString>;
67
- }, z.core.$strip>;
68
- export declare const FieldC: z.ZodUnion<readonly [z.ZodObject<{
69
- type: z.ZodLiteral<"string">;
70
- path: z.ZodString;
71
- title: z.ZodArray<z.ZodObject<{
72
- locale: z.ZodString;
73
- message: z.ZodString;
74
- }, z.core.$strip>>;
75
- icon: z.ZodOptional<z.ZodString>;
76
- style: z.ZodOptional<z.ZodString>;
77
- discardEmptyString: z.ZodOptional<z.ZodBoolean>;
78
- maxLength: z.ZodOptional<z.ZodString>;
79
- hidden: z.ZodOptional<z.ZodString>;
80
- disabled: z.ZodOptional<z.ZodString>;
81
- }, z.core.$strip>, z.ZodObject<{
82
- type: z.ZodLiteral<"number">;
83
- path: z.ZodString;
84
- title: z.ZodArray<z.ZodObject<{
85
- locale: z.ZodString;
86
- message: z.ZodString;
87
- }, z.core.$strip>>;
88
- icon: z.ZodOptional<z.ZodString>;
89
- style: z.ZodOptional<z.ZodString>;
90
- min: z.ZodOptional<z.ZodString>;
91
- max: z.ZodOptional<z.ZodString>;
92
- step: z.ZodOptional<z.ZodString>;
93
- hidden: z.ZodOptional<z.ZodString>;
94
- disabled: z.ZodOptional<z.ZodString>;
95
- }, z.core.$strip>, z.ZodObject<{
96
- type: z.ZodLiteral<"select">;
97
- path: z.ZodString;
98
- title: z.ZodArray<z.ZodObject<{
99
- locale: z.ZodString;
100
- message: z.ZodString;
101
- }, z.core.$strip>>;
102
- icon: z.ZodOptional<z.ZodString>;
103
- options: z.ZodString;
104
- label: z.ZodString;
105
- value: z.ZodString;
106
- key: z.ZodString;
107
- style: z.ZodOptional<z.ZodString>;
108
- hidden: z.ZodOptional<z.ZodString>;
109
- disabled: z.ZodOptional<z.ZodString>;
110
- }, z.core.$strip>, z.ZodObject<{
111
- type: z.ZodLiteral<"calendar">;
112
- path: z.ZodString;
113
- title: z.ZodArray<z.ZodObject<{
114
- locale: z.ZodString;
115
- message: z.ZodString;
116
- }, z.core.$strip>>;
117
- icon: z.ZodOptional<z.ZodString>;
118
- style: z.ZodOptional<z.ZodString>;
119
- mode: z.ZodEnum<{
120
- year: "year";
121
- month: "month";
122
- date: "date";
123
- }>;
124
- display: z.ZodOptional<z.ZodString>;
125
- value: z.ZodString;
126
- disableDate: z.ZodOptional<z.ZodString>;
127
- hidden: z.ZodOptional<z.ZodString>;
128
- disabled: z.ZodOptional<z.ZodString>;
129
- }, z.core.$strip>]>;
1
+ import type { Field } from './ui/fields/Fields.vue.js';
2
+ export { CalendarFieldC, FieldC, NumberFieldC, SelectFieldC, StringFieldC, } from './ui/fields/Fields.vue.js';
3
+ export type { Field } from './ui/fields/Fields.vue.js';
130
4
  declare const _default: typeof __VLS_export;
131
5
  export default _default;
132
6
  declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
133
7
  orientation?: "horizontal" | "vertical" | "floating";
134
- fields: Effect.Effect<ReadonlyArray<z.infer<typeof FieldC>>>;
8
+ fields: import("effect").Effect.Effect<ReadonlyArray<Field>>;
135
9
  } & {
136
10
  modelValue?: Record<string, unknown>;
137
11
  }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
138
12
  "update:modelValue": (value: Record<string, unknown>) => any;
13
+ "update:fields": (args_0: readonly ({
14
+ type: "string";
15
+ path: string;
16
+ title: readonly {
17
+ locale: "zh" | "ja" | "en" | "ko";
18
+ message: string;
19
+ }[];
20
+ icon?: string | undefined;
21
+ style?: string | undefined;
22
+ discardEmptyString?: boolean | undefined;
23
+ maxLength?: string | undefined;
24
+ hidden?: string | undefined;
25
+ disabled?: string | undefined;
26
+ validation?: readonly Readonly<{
27
+ expression: string;
28
+ message: string;
29
+ }>[] | undefined;
30
+ } | {
31
+ type: "number";
32
+ path: string;
33
+ title: readonly {
34
+ locale: "zh" | "ja" | "en" | "ko";
35
+ message: string;
36
+ }[];
37
+ icon?: string | undefined;
38
+ style?: string | undefined;
39
+ min?: string | undefined;
40
+ max?: string | undefined;
41
+ step?: string | undefined;
42
+ hidden?: string | undefined;
43
+ disabled?: string | undefined;
44
+ validation?: readonly Readonly<{
45
+ expression: string;
46
+ message: string;
47
+ }>[] | undefined;
48
+ } | {
49
+ type: "select";
50
+ path: string;
51
+ title: readonly {
52
+ locale: "zh" | "ja" | "en" | "ko";
53
+ message: string;
54
+ }[];
55
+ options: string;
56
+ label: string;
57
+ value: string;
58
+ key: string;
59
+ icon?: string | undefined;
60
+ style?: string | undefined;
61
+ hidden?: string | undefined;
62
+ disabled?: string | undefined;
63
+ validation?: readonly Readonly<{
64
+ expression: string;
65
+ message: string;
66
+ }>[] | undefined;
67
+ } | {
68
+ type: "calendar";
69
+ path: string;
70
+ title: readonly {
71
+ locale: "zh" | "ja" | "en" | "ko";
72
+ message: string;
73
+ }[];
74
+ mode: "year" | "month" | "date";
75
+ value: string;
76
+ icon?: string | undefined;
77
+ style?: string | undefined;
78
+ display?: string | undefined;
79
+ disableDate?: string | undefined;
80
+ hidden?: string | undefined;
81
+ disabled?: string | undefined;
82
+ validation?: readonly Readonly<{
83
+ expression: string;
84
+ message: string;
85
+ }>[] | undefined;
86
+ })[]) => any;
139
87
  }, string, import("vue").PublicProps, Readonly<{
140
88
  orientation?: "horizontal" | "vertical" | "floating";
141
- fields: Effect.Effect<ReadonlyArray<z.infer<typeof FieldC>>>;
89
+ fields: import("effect").Effect.Effect<ReadonlyArray<Field>>;
142
90
  } & {
143
91
  modelValue?: Record<string, unknown>;
144
92
  }> & Readonly<{
145
93
  "onUpdate:modelValue"?: ((value: Record<string, unknown>) => any) | undefined;
94
+ "onUpdate:fields"?: ((args_0: readonly ({
95
+ type: "string";
96
+ path: string;
97
+ title: readonly {
98
+ locale: "zh" | "ja" | "en" | "ko";
99
+ message: string;
100
+ }[];
101
+ icon?: string | undefined;
102
+ style?: string | undefined;
103
+ discardEmptyString?: boolean | undefined;
104
+ maxLength?: string | undefined;
105
+ hidden?: string | undefined;
106
+ disabled?: string | undefined;
107
+ validation?: readonly Readonly<{
108
+ expression: string;
109
+ message: string;
110
+ }>[] | undefined;
111
+ } | {
112
+ type: "number";
113
+ path: string;
114
+ title: readonly {
115
+ locale: "zh" | "ja" | "en" | "ko";
116
+ message: string;
117
+ }[];
118
+ icon?: string | undefined;
119
+ style?: string | undefined;
120
+ min?: string | undefined;
121
+ max?: string | undefined;
122
+ step?: string | undefined;
123
+ hidden?: string | undefined;
124
+ disabled?: string | undefined;
125
+ validation?: readonly Readonly<{
126
+ expression: string;
127
+ message: string;
128
+ }>[] | undefined;
129
+ } | {
130
+ type: "select";
131
+ path: string;
132
+ title: readonly {
133
+ locale: "zh" | "ja" | "en" | "ko";
134
+ message: string;
135
+ }[];
136
+ options: string;
137
+ label: string;
138
+ value: string;
139
+ key: string;
140
+ icon?: string | undefined;
141
+ style?: string | undefined;
142
+ hidden?: string | undefined;
143
+ disabled?: string | undefined;
144
+ validation?: readonly Readonly<{
145
+ expression: string;
146
+ message: string;
147
+ }>[] | undefined;
148
+ } | {
149
+ type: "calendar";
150
+ path: string;
151
+ title: readonly {
152
+ locale: "zh" | "ja" | "en" | "ko";
153
+ message: string;
154
+ }[];
155
+ mode: "year" | "month" | "date";
156
+ value: string;
157
+ icon?: string | undefined;
158
+ style?: string | undefined;
159
+ display?: string | undefined;
160
+ disableDate?: string | undefined;
161
+ hidden?: string | undefined;
162
+ disabled?: string | undefined;
163
+ validation?: readonly Readonly<{
164
+ expression: string;
165
+ message: string;
166
+ }>[] | undefined;
167
+ })[]) => any) | undefined;
146
168
  }>, {
147
169
  orientation: "horizontal" | "vertical" | "floating";
148
170
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
149
- default?: (props: {}) => any;
171
+ [x: string]: ((props: any) => any) | undefined;
150
172
  }>;
151
173
  type __VLS_WithSlots<T, S> = T & {
152
174
  new (): {
@@ -1,312 +1,47 @@
1
- <script>
2
- import { Icon } from "@iconify/vue";
3
- import { useId } from "vue";
4
- import { useNuxtApp } from "#app";
5
- import { Field, FieldLabel } from "./ui/field";
6
- import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupCombobox, InputGroupInput, InputGroupNumberField } from "./ui/input-group";
7
- import { CommandGroup, CommandItem } from "./ui/command";
8
- import { Tooltip, TooltipContent, TooltipTrigger } from "./ui/tooltip";
9
- import { Popover, PopoverAnchor, PopoverContent, PopoverTrigger } from "./ui/popover";
10
- import { Calendar } from "./ui/calendar";
11
- import { useI18n } from "vue-i18n";
12
- import { deleteProperty, getProperty, hasProperty, setProperty } from "dot-prop";
13
- import { useCheating } from "#imports";
14
- import { Skeleton } from "./ui/skeleton";
15
- import z from "zod";
16
- import { Effect } from "effect";
17
- import { computedAsync } from "@vueuse/core";
18
- import { localeC, dotPropC, expressionC } from "../utils/coders";
19
- import { CalendarDate, getLocalTimeZone } from "@internationalized/date";
20
- import { format, parse } from "date-fns";
21
- import { TZDate } from "@date-fns/tz";
22
- export const StringFieldC = z.object({
23
- type: z.literal("string").describe("\u5355\u884C\u6587\u672C\u8F93\u5165\u5B57\u6BB5\uFF0C\u7ED1\u5B9A string \u7C7B\u578B\u7684\u503C"),
24
- path: dotPropC,
25
- title: z.array(localeC).describe("\u5B57\u6BB5\u6807\u7B7E\u7684\u672C\u5730\u5316\u663E\u793A\u6587\u672C"),
26
- icon: z.string().optional().describe("Iconify \u56FE\u6807\u6807\u8BC6\u7B26\uFF0C\u663E\u793A\u5728\u8F93\u5165\u6846\u5185\u4FA7"),
27
- style: z.string().optional().describe("CSS \u6837\u5F0F\u5BF9\u8C61\u8868\u8FBE\u5F0F\uFF0C\u63A7\u5236\u5B57\u6BB5\u7684\u5E03\u5C40\u4E0E\u5916\u89C2"),
28
- discardEmptyString: z.boolean().optional().describe("\u4E3A true \u65F6\uFF0C\u7A7A\u5B57\u7B26\u4E32\u4F5C\u4E3A\u6709\u6548\u503C\u5B58\u50A8\uFF1B\u5426\u5219\u6E05\u7A7A\u8F93\u5165\u5C06\u5220\u9664\u5BF9\u5E94\u5C5E\u6027"),
29
- maxLength: expressionC("int").optional().describe('\u8FD4\u56DE\u6574\u6570\u7684 CEL \u8868\u8FBE\u5F0F\uFF0C\u9650\u5236\u8F93\u5165\u7684\u6700\u5927\u5B57\u7B26\u6570\uFF0C\u5982 "100"'),
30
- hidden: expressionC("bool", { form: "map<string, dyn>" }).optional().describe("\u4E3A true \u65F6\uFF0C\u9690\u85CF\u8FD9\u4E2A\u5B57\u6BB5"),
31
- disabled: expressionC("bool", { form: "map<string, dyn>" }).optional().describe("\u4E3A true \u65F6\uFF0C\u7981\u7528\u8FD9\u4E2A\u5B57\u6BB5")
32
- });
33
- export const NumberFieldC = z.object({
34
- type: z.literal("number").describe("\u6570\u5B57\u8F93\u5165\u5B57\u6BB5\uFF0C\u7ED1\u5B9A number \u7C7B\u578B\u7684\u503C"),
35
- path: dotPropC,
36
- title: z.array(localeC).describe("\u5B57\u6BB5\u6807\u7B7E\u7684\u672C\u5730\u5316\u663E\u793A\u6587\u672C"),
37
- icon: z.string().optional().describe("Iconify \u56FE\u6807\u6807\u8BC6\u7B26\uFF0C\u663E\u793A\u5728\u8F93\u5165\u6846\u5185\u4FA7"),
38
- style: z.string().optional().describe("CSS \u6837\u5F0F\u5BF9\u8C61\u8868\u8FBE\u5F0F\uFF0C\u63A7\u5236\u5B57\u6BB5\u7684\u5E03\u5C40\u4E0E\u5916\u89C2"),
39
- min: expressionC("double").optional().describe('\u8FD4\u56DE\u6D6E\u70B9\u6570\u7684 CEL \u8868\u8FBE\u5F0F\uFF0C\u9650\u5236\u5141\u8BB8\u7684\u6700\u5C0F\u503C\uFF0C\u5982 "0.0"'),
40
- max: expressionC("double").optional().describe('\u8FD4\u56DE\u6D6E\u70B9\u6570\u7684 CEL \u8868\u8FBE\u5F0F\uFF0C\u9650\u5236\u5141\u8BB8\u7684\u6700\u5927\u503C\uFF0C\u5982 "100.0"'),
41
- step: expressionC("double").optional().describe('\u8FD4\u56DE\u6D6E\u70B9\u6570\u7684 CEL \u8868\u8FBE\u5F0F\uFF0C\u63A7\u5236\u6570\u503C\u9012\u589E\u6B65\u957F\uFF0C\u5982 "0.5"'),
42
- hidden: expressionC("bool", { form: "map<string, dyn>" }).optional().describe("\u4E3A true \u65F6\uFF0C\u9690\u85CF\u8FD9\u4E2A\u5B57\u6BB5"),
43
- disabled: expressionC("bool", { form: "map<string, dyn>" }).optional().describe("\u4E3A true \u65F6\uFF0C\u7981\u7528\u8FD9\u4E2A\u5B57\u6BB5")
44
- });
45
- export const SelectFieldC = z.object({
46
- type: z.literal("select").describe("\u4E0B\u62C9\u9009\u62E9\u5B57\u6BB5\uFF0C\u4ECE\u9884\u5B9A\u4E49\u9009\u9879\u4E2D\u9009\u53D6\u4E00\u4E2A\u503C"),
47
- path: dotPropC,
48
- title: z.array(localeC).describe("\u5B57\u6BB5\u6807\u7B7E\u7684\u672C\u5730\u5316\u663E\u793A\u6587\u672C"),
49
- icon: z.string().optional().describe("Iconify \u56FE\u6807\u6807\u8BC6\u7B26\uFF0C\u663E\u793A\u5728\u8F93\u5165\u6846\u5185\u4FA7"),
50
- options: expressionC(/^list/).describe("\u5168\u90E8\u5019\u9009\u9879"),
51
- label: expressionC("string", { option: "dyn" }).describe("\u8FD4\u56DE\u5B57\u7B26\u4E32\u7684 CEL \u8868\u8FBE\u5F0F\uFF0C\u63D0\u4F9B option \u53D8\u91CF\uFF0C\u751F\u6210\u8BE5\u9009\u9879\u7684\u663E\u793A\u6587\u672C"),
52
- value: expressionC(/.+/, { option: "dyn" }).describe("\u8FD4\u56DE\u4EFB\u610F\u503C\u7684 CEL \u8868\u8FBE\u5F0F\uFF0C\u63D0\u4F9B option \u53D8\u91CF\uFF0C\u8FD4\u56DE\u503C\u5C06\u88AB\u5199\u5165\u7ED1\u5B9A\u5B57\u6BB5"),
53
- key: expressionC("string", { option: "dyn" }).describe("\u8FD4\u56DE\u5B57\u7B26\u4E32\u7684 CEL \u8868\u8FBE\u5F0F\uFF0C\u63D0\u4F9B option \u53D8\u91CF\uFF0C\u8FD4\u56DE\u503C\u4E0E\u9009\u9879\u6784\u6210\u5168\u6620\u5C04"),
54
- style: z.string().optional().describe("CSS \u6837\u5F0F\u5BF9\u8C61\u8868\u8FBE\u5F0F\uFF0C\u63A7\u5236\u5B57\u6BB5\u7684\u5E03\u5C40\u4E0E\u5916\u89C2"),
55
- hidden: expressionC("bool", { form: "map<string, dyn>" }).optional().describe("\u4E3A true \u65F6\uFF0C\u9690\u85CF\u8FD9\u4E2A\u5B57\u6BB5"),
56
- disabled: expressionC("bool", { form: "map<string, dyn>" }).optional().describe("\u4E3A true \u65F6\uFF0C\u7981\u7528\u8FD9\u4E2A\u5B57\u6BB5")
57
- });
58
- export const CalendarFieldC = z.object({
59
- type: z.literal("calendar").describe("\u65E5\u671F\u9009\u62E9\u5B57\u6BB5\uFF0C\u901A\u8FC7\u5F39\u51FA\u65E5\u5386\u9762\u677F\u9009\u62E9\u65E5\u671F"),
60
- path: dotPropC,
61
- title: z.array(localeC).describe("\u5B57\u6BB5\u6807\u7B7E\u7684\u672C\u5730\u5316\u663E\u793A\u6587\u672C"),
62
- icon: z.string().optional().describe("Iconify \u56FE\u6807\u6807\u8BC6\u7B26\uFF0C\u663E\u793A\u5728\u8F93\u5165\u6846\u5185\u4FA7"),
63
- style: z.string().optional().describe("CSS \u6837\u5F0F\u5BF9\u8C61\u8868\u8FBE\u5F0F\uFF0C\u63A7\u5236\u5B57\u6BB5\u7684\u5E03\u5C40\u4E0E\u5916\u89C2"),
64
- mode: z.enum(["year", "month", "date"]).describe("\u65E5\u5386\u9009\u62E9\u7CBE\u5EA6\uFF1Ayear \u4EC5\u9009\u5E74\uFF0Cmonth \u9009\u5E74\u6708\uFF0Cdate \u9009\u5E74\u6708\u65E5"),
65
- display: z.string().optional().describe('date-fns \u683C\u5F0F\u5B57\u7B26\u4E32\uFF0C\u63A7\u5236\u8F93\u5165\u6846\u4E2D\u7684\u5C55\u793A\u683C\u5F0F\uFF0C\u5982 "yyyy\u5E74MM\u6708dd\u65E5"\uFF1B\u7559\u7A7A\u5219\u663E\u793A\u539F\u59CB\u5B58\u50A8\u503C'),
66
- value: z.string().describe('date-fns \u683C\u5F0F\u5B57\u7B26\u4E32\uFF0C\u5B9A\u4E49\u65E5\u671F\u5728 model \u4E2D\u7684\u5B58\u50A8\u683C\u5F0F\uFF0C\u5982 "yyyy-MM-dd"'),
67
- disableDate: expressionC("bool", { date: "Date" }).optional().describe("\u8FD4\u56DE\u5E03\u5C14\u503C\u7684 CEL \u8868\u8FBE\u5F0F\uFF0C\u4EE5 date\uFF08Date \u7C7B\u578B\uFF09\u4E3A\u53D8\u91CF\uFF0C\u8FD4\u56DE true \u65F6\u8BE5\u65E5\u671F\u5728\u65E5\u5386\u4E2D\u88AB\u7981\u7528"),
68
- hidden: expressionC("bool", { form: "map<string, dyn>" }).optional().describe("\u4E3A true \u65F6\uFF0C\u9690\u85CF\u8FD9\u4E2A\u5B57\u6BB5"),
69
- disabled: expressionC("bool", { form: "map<string, dyn>" }).optional().describe("\u4E3A true \u65F6\uFF0C\u7981\u7528\u8FD9\u4E2A\u5B57\u6BB5")
70
- });
71
- export const FieldC = z.union([
72
- StringFieldC,
73
- NumberFieldC,
74
- SelectFieldC,
75
- CalendarFieldC
76
- ]);
77
- </script>
78
-
79
1
  <script setup>
80
- const id = useId();
2
+ import UiFields from "./ui/fields/Fields.vue";
3
+ defineOptions({
4
+ inheritAttrs: false
5
+ });
81
6
  const props = defineProps({
82
7
  orientation: { type: String, required: false, default: "horizontal" },
83
8
  fields: { type: null, required: true }
84
9
  });
85
- const fields = computedAsync(async () => z.array(FieldC).readonly().parse(await props.fields.pipe(Effect.runPromise)));
86
- const { t, locale } = useI18n();
87
- const { $dsl } = useNuxtApp();
10
+ const emit = defineEmits(["update:fields"]);
88
11
  const modelValue = defineModel("modelValue", { type: Object, ...{
89
12
  default: () => ({})
90
13
  } });
91
- const isCheating = useCheating();
92
- function toCalendarDateValue(value, valueFormat) {
93
- if (typeof value !== "string") return void 0;
94
- const date = parse(value, valueFormat, /* @__PURE__ */ new Date());
95
- if (Number.isNaN(date.getTime())) return void 0;
96
- return new CalendarDate(date.getFullYear(), date.getMonth() + 1, date.getDate());
97
- }
98
- function displayCalendarValue(stored, displayFormat, valueFormat) {
99
- if (displayFormat) {
100
- const dateVal = toCalendarDateValue(stored, valueFormat);
101
- if (dateVal) return format(dateVal.toDate(getLocalTimeZone()), displayFormat);
102
- }
103
- return stored ?? "";
104
- }
105
- function isFieldHidden(field) {
106
- return $dsl.evaluate`${field.hidden || "false"}`({ form: modelValue.value });
107
- }
108
- function isFieldDisabled(field) {
109
- return $dsl.evaluate`${field.disabled || "false"}`({ form: modelValue.value });
14
+ function handleFieldsUpdate(fields) {
15
+ emit("update:fields", fields);
110
16
  }
111
17
  </script>
112
18
 
19
+ <script>
20
+ export {
21
+ CalendarFieldC,
22
+ FieldC,
23
+ NumberFieldC,
24
+ SelectFieldC,
25
+ StringFieldC
26
+ } from "./ui/fields/Fields.vue";
27
+ </script>
28
+
113
29
  <template>
114
- <div
115
- :class="[
116
- 'relative p-1 border border-dashed',
117
- isCheating ? 'border-(--primary)/20 rounded hover:border-(--primary)/40 transition-colors duration-150 group cursor-pointer' : 'border-transparent'
118
- ]"
30
+ <UiFields
31
+ v-bind="$attrs"
32
+ v-model="modelValue"
33
+ :orientation="props.orientation"
34
+ :fields="props.fields"
35
+ @update:fields="handleFieldsUpdate"
119
36
  >
120
- <Skeleton
121
- v-if="fields === void 0"
122
- class="absolute inset-0 z-10 w-full h-full"
123
- />
124
-
125
37
  <template
126
- v-for="field in fields"
127
- :key="field.path"
38
+ v-for="(_, slotName) in $slots"
39
+ #[slotName]="slotProps"
128
40
  >
129
- <Field
130
- v-if="!isFieldHidden(field)"
131
- :data-disabled="isFieldDisabled(field) ? 'true' : void 0"
132
- :orientation="orientation"
133
- :style="field.style ? $dsl.evaluate`${field.style}`() : {}"
134
- >
135
- <FieldLabel :for="['string', 'number'].includes(field.type) ? `${id}:${field.path}` : void 0">
136
- {{ field.title.find((r) => r.locale === locale)?.message ?? field.title[0]?.message }}
137
- <span v-if="isCheating">
138
- <span class="font-mono">{{ field.path }}</span>
139
- </span>
140
- </FieldLabel>
141
- <Popover v-if="field.type === 'calendar'">
142
- <PopoverAnchor as-child>
143
- <InputGroup :data-disabled="isFieldDisabled(field) ? 'true' : void 0">
144
- <PopoverTrigger as-child>
145
- <InputGroupInput
146
- :model-value="displayCalendarValue(getProperty(modelValue, field.path), field.display, field.value)"
147
- class="text-left"
148
- :disabled="isFieldDisabled(field)"
149
- readonly
150
- />
151
- </PopoverTrigger>
152
- <InputGroupAddon v-if="field.icon">
153
- <Icon
154
- :icon="field.icon"
155
- />
156
- </InputGroupAddon>
157
- <InputGroupAddon
158
- v-if="hasProperty(modelValue, field.path)"
159
- align="inline-end"
160
- :class="orientation === 'floating' ? 'group-data-[disabled=true]/input-group:hidden' : void 0"
161
- >
162
- <Tooltip :delay-duration="800">
163
- <TooltipTrigger>
164
- <InputGroupButton as-child>
165
- <button
166
- type="button"
167
- class="text-zinc-300 hover:text-zinc-500 transition-colors"
168
- :disabled="isFieldDisabled(field)"
169
- @click="deleteProperty(modelValue, field.path)"
170
- >
171
- <Icon
172
- icon="fluent:dismiss-20-regular"
173
- />
174
- </button>
175
- </InputGroupButton>
176
- </TooltipTrigger>
177
- <TooltipContent>
178
- {{ t("clear") }}
179
- </TooltipContent>
180
- </Tooltip>
181
- </InputGroupAddon>
182
- </InputGroup>
183
- </PopoverAnchor>
184
- <PopoverContent class="w-72">
185
- <Calendar
186
- :locale="locale"
187
- :layout="field.mode"
188
- :model-value="toCalendarDateValue(getProperty(modelValue, field.path), field.value)"
189
- :disabled="isFieldDisabled(field)"
190
- :is-date-disabled="field.disableDate ? (date) => !!$dsl.evaluate`${field.disableDate}`({ date: new TZDate(date.toDate(getLocalTimeZone())) }) : void 0"
191
- @update:model-value="(value) => {
192
- if (value === void 0) {
193
- deleteProperty(modelValue, field.path);
194
- } else {
195
- setProperty(modelValue, field.path, format(value.toDate(getLocalTimeZone()), field.value));
196
- }
197
- }"
198
- />
199
- </PopoverContent>
200
- </Popover>
201
- <InputGroup
202
- v-else
203
- :data-disabled="isFieldDisabled(field) ? 'true' : void 0"
204
- >
205
- <InputGroupInput
206
- v-if="field.type === 'string'"
207
- :id="`${id}:${field.path}`"
208
- :treat-empty-as-different-state-from-null="!!field.discardEmptyString"
209
- :model-value="getProperty(modelValue, field.path)"
210
- :maxlength="field.maxLength ? $dsl.evaluate`${field.maxLength}`() : void 0"
211
- :disabled="isFieldDisabled(field)"
212
- @update:model-value="(value) => {
213
- if (!value && !field.discardEmptyString) {
214
- deleteProperty(modelValue, field.path);
215
- } else {
216
- setProperty(modelValue, field.path, value);
217
- }
218
- }"
219
- />
220
- <InputGroupNumberField
221
- v-if="field.type === 'number'"
222
- :id="`${id}:${field.path}`"
223
- :model-value="getProperty(modelValue, field.path) ?? null"
224
- :min="field.min ? $dsl.evaluate`${field.min}`() : void 0"
225
- :max="field.max ? $dsl.evaluate`${field.max}`() : void 0"
226
- :step="field.step ? $dsl.evaluate`${field.step}`() : void 0"
227
- :disabled="isFieldDisabled(field)"
228
- @update:model-value="(value) => {
229
- if (!value && value !== 0) {
230
- deleteProperty(modelValue, field.path);
231
- } else {
232
- setProperty(modelValue, field.path, value);
233
- }
234
- }"
235
- />
236
- <InputGroupCombobox
237
- v-if="field.type === 'select'"
238
- :disabled="isFieldDisabled(field)"
239
- >
240
- <CommandGroup>
241
- <CommandItem
242
- v-for="option in $dsl.evaluate`${field.options}`()"
243
- :key="$dsl.evaluate`${field.key}`({ option })"
244
- :value="$dsl.evaluate`${field.key}`({ option })"
245
- @select="setProperty(modelValue, field.path, $dsl.evaluate`${field.value}`({ option }))"
246
- >
247
- {{ $dsl.evaluate`${field.label}`({ option }) }}
248
- </CommandItem>
249
- </CommandGroup>
250
- </InputGroupCombobox>
251
- <InputGroupAddon v-if="field.icon">
252
- <Icon
253
- :icon="field.icon"
254
- />
255
- </InputGroupAddon>
256
- <InputGroupAddon
257
- v-if="hasProperty(modelValue, field.path)"
258
- align="inline-end"
259
- :class="orientation === 'floating' ? 'group-data-[disabled=true]/input-group:hidden' : void 0"
260
- >
261
- <Tooltip :delay-duration="800">
262
- <TooltipTrigger>
263
- <InputGroupButton as-child>
264
- <button
265
- type="button"
266
- class="text-zinc-300 hover:text-zinc-500 transition-colors"
267
- :disabled="isFieldDisabled(field)"
268
- @click="deleteProperty(modelValue, field.path)"
269
- >
270
- <Icon
271
- icon="fluent:dismiss-20-regular"
272
- />
273
- </button>
274
- </InputGroupButton>
275
- </TooltipTrigger>
276
- <TooltipContent>
277
- {{ t("clear") }}
278
- </TooltipContent>
279
- </Tooltip>
280
- </InputGroupAddon>
281
- <InputGroupAddon
282
- v-if="field.type === 'string' && field.maxLength && getProperty(modelValue, field.path)"
283
- align="inline-end"
284
- >
285
- <span class="text-xs text-zinc-400 font-mono">
286
- <span class="inline-block text-right">{{ String(getProperty(modelValue, field.path) ?? "").length }}</span>/{{ field.maxLength }}
287
- </span>
288
- </InputGroupAddon>
289
- </InputGroup>
290
- </Field>
41
+ <slot
42
+ :name="slotName"
43
+ v-bind="slotProps ?? {}"
44
+ />
291
45
  </template>
292
-
293
- <slot />
294
- </div>
46
+ </UiFields>
295
47
  </template>
296
-
297
- <i18n lang="json">
298
- {
299
- "zh": {
300
- "clear": "清空",
301
- "select-placeholder": "选择…"
302
- },
303
- "ja": {
304
- "clear": "クリア",
305
- "select-placeholder": "選択…"
306
- },
307
- "en": {
308
- "clear": "Clear",
309
- "select-placeholder": "Select…"
310
- }
311
- }
312
- </i18n>