@shwfed/nuxt 0.9.0 → 0.9.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.
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shwfed/nuxt",
3
3
  "configKey": "shwfed",
4
- "version": "0.9.0",
4
+ "version": "0.9.1",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -11,7 +11,6 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
11
11
  }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
12
12
  "update:modelValue": (value: Record<string, unknown>) => any;
13
13
  "update:config": (args_0: Readonly<{
14
- orientation: "vertical" | "horizontal" | "floating";
15
14
  fields: readonly ({
16
15
  type: "string";
17
16
  path: string;
@@ -86,6 +85,7 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
86
85
  message: string;
87
86
  }>[] | undefined;
88
87
  })[];
88
+ orientation?: "vertical" | "horizontal" | "floating" | undefined;
89
89
  }>) => any;
90
90
  }, string, import("vue").PublicProps, Readonly<{
91
91
  config?: Effect.Effect<FieldsConfig | undefined>;
@@ -94,7 +94,6 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
94
94
  }> & Readonly<{
95
95
  "onUpdate:modelValue"?: ((value: Record<string, unknown>) => any) | undefined;
96
96
  "onUpdate:config"?: ((args_0: Readonly<{
97
- orientation: "vertical" | "horizontal" | "floating";
98
97
  fields: readonly ({
99
98
  type: "string";
100
99
  path: string;
@@ -169,6 +168,7 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
169
168
  message: string;
170
169
  }>[] | undefined;
171
170
  })[];
171
+ orientation?: "vertical" | "horizontal" | "floating" | undefined;
172
172
  }>) => any) | undefined;
173
173
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
174
174
  [x: string]: ((props: any) => any) | undefined;
@@ -12,7 +12,6 @@ const modelValue = defineModel("modelValue", { type: Object, ...{
12
12
  default: () => ({})
13
13
  } });
14
14
  const defaultConfig = {
15
- orientation: "horizontal",
16
15
  fields: []
17
16
  };
18
17
  const config = props.config ? props.config.pipe(Effect.map((config2) => config2 ?? defaultConfig)) : Effect.succeed(defaultConfig);
@@ -11,7 +11,6 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
11
11
  }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
12
12
  "update:modelValue": (value: Record<string, unknown>) => any;
13
13
  "update:config": (args_0: Readonly<{
14
- orientation: "vertical" | "horizontal" | "floating";
15
14
  fields: readonly ({
16
15
  type: "string";
17
16
  path: string;
@@ -86,6 +85,7 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
86
85
  message: string;
87
86
  }>[] | undefined;
88
87
  })[];
88
+ orientation?: "vertical" | "horizontal" | "floating" | undefined;
89
89
  }>) => any;
90
90
  }, string, import("vue").PublicProps, Readonly<{
91
91
  config?: Effect.Effect<FieldsConfig | undefined>;
@@ -94,7 +94,6 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
94
94
  }> & Readonly<{
95
95
  "onUpdate:modelValue"?: ((value: Record<string, unknown>) => any) | undefined;
96
96
  "onUpdate:config"?: ((args_0: Readonly<{
97
- orientation: "vertical" | "horizontal" | "floating";
98
97
  fields: readonly ({
99
98
  type: "string";
100
99
  path: string;
@@ -169,6 +168,7 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
169
168
  message: string;
170
169
  }>[] | undefined;
171
170
  })[];
171
+ orientation?: "vertical" | "horizontal" | "floating" | undefined;
172
172
  }>) => any) | undefined;
173
173
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
174
174
  [x: string]: ((props: any) => any) | undefined;
@@ -5,7 +5,6 @@ declare const _default: typeof __VLS_export;
5
5
  export default _default;
6
6
  declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
7
7
  config: Effect.Effect<Readonly<{
8
- orientation: "vertical" | "horizontal" | "floating";
9
8
  fields: readonly ({
10
9
  type: "string";
11
10
  path: string;
@@ -80,13 +79,13 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
80
79
  message: string;
81
80
  }>[] | undefined;
82
81
  })[];
83
- }>>;
82
+ orientation?: "vertical" | "horizontal" | "floating" | undefined;
83
+ }> | undefined>;
84
84
  } & {
85
85
  modelValue?: Record<string, unknown>;
86
86
  }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
87
87
  "update:modelValue": (value: Record<string, unknown>) => any;
88
88
  "update:config": (args_0: Readonly<{
89
- orientation: "vertical" | "horizontal" | "floating";
90
89
  fields: readonly ({
91
90
  type: "string";
92
91
  path: string;
@@ -161,10 +160,10 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
161
160
  message: string;
162
161
  }>[] | undefined;
163
162
  })[];
163
+ orientation?: "vertical" | "horizontal" | "floating" | undefined;
164
164
  }>) => any;
165
165
  }, string, import("vue").PublicProps, Readonly<{
166
166
  config: Effect.Effect<Readonly<{
167
- orientation: "vertical" | "horizontal" | "floating";
168
167
  fields: readonly ({
169
168
  type: "string";
170
169
  path: string;
@@ -239,13 +238,13 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
239
238
  message: string;
240
239
  }>[] | undefined;
241
240
  })[];
242
- }>>;
241
+ orientation?: "vertical" | "horizontal" | "floating" | undefined;
242
+ }> | undefined>;
243
243
  } & {
244
244
  modelValue?: Record<string, unknown>;
245
245
  }> & Readonly<{
246
246
  "onUpdate:modelValue"?: ((value: Record<string, unknown>) => any) | undefined;
247
247
  "onUpdate:config"?: ((args_0: Readonly<{
248
- orientation: "vertical" | "horizontal" | "floating";
249
248
  fields: readonly ({
250
249
  type: "string";
251
250
  path: string;
@@ -320,6 +319,7 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
320
319
  message: string;
321
320
  }>[] | undefined;
322
321
  })[];
322
+ orientation?: "vertical" | "horizontal" | "floating" | undefined;
323
323
  }>) => any) | undefined;
324
324
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
325
325
  default?: (props: {}) => any;
@@ -23,14 +23,13 @@ import { getLocalizedText } from "../../../utils/coders";
23
23
  import { FieldsConfigC } from "./schema";
24
24
  const id = useId();
25
25
  const defaultConfig = {
26
- orientation: "horizontal",
27
26
  fields: []
28
27
  };
29
28
  const props = defineProps({
30
29
  config: { type: null, required: true }
31
30
  });
32
31
  const emit = defineEmits(["update:config"]);
33
- const config = computedAsync(async () => FieldsConfigC.parse(await props.config.pipe(Effect.runPromise)));
32
+ const config = computedAsync(async () => FieldsConfigC.parse(await props.config.pipe(Effect.runPromise) ?? defaultConfig));
34
33
  const { t, locale } = useI18n();
35
34
  const { $dsl, $md } = useNuxtApp();
36
35
  const modelValue = defineModel("modelValue", { type: Object, ...{
@@ -41,6 +40,20 @@ const isConfiguratorOpen = ref(false);
41
40
  const displayConfig = ref(defaultConfig);
42
41
  const validationErrors = ref({});
43
42
  const calendarOpen = ref({});
43
+ function cloneConfig(config2) {
44
+ if (config2.orientation) {
45
+ return {
46
+ orientation: config2.orientation,
47
+ fields: config2.fields.slice()
48
+ };
49
+ }
50
+ return {
51
+ fields: config2.fields.slice()
52
+ };
53
+ }
54
+ function getConfigOrientation(config2) {
55
+ return config2.orientation ?? "horizontal";
56
+ }
44
57
  function toCalendarDateValue(value, valueFormat) {
45
58
  if (typeof value !== "string") return void 0;
46
59
  const date = parse(value, valueFormat, /* @__PURE__ */ new Date());
@@ -120,20 +133,14 @@ function handleCalendarBlur(field) {
120
133
  }, 0);
121
134
  }
122
135
  function handleConfiguratorConfirm(nextConfig) {
123
- displayConfig.value = {
124
- orientation: nextConfig.orientation,
125
- fields: nextConfig.fields.slice()
126
- };
136
+ displayConfig.value = cloneConfig(nextConfig);
127
137
  emit("update:config", nextConfig);
128
138
  }
129
139
  watch(config, (value) => {
130
140
  if (!value) {
131
141
  return;
132
142
  }
133
- displayConfig.value = {
134
- orientation: value.orientation,
135
- fields: value.fields.slice()
136
- };
143
+ displayConfig.value = cloneConfig(value);
137
144
  }, { immediate: true });
138
145
  watchEffect(() => {
139
146
  const activePaths = /* @__PURE__ */ new Set();
@@ -207,7 +214,7 @@ export {
207
214
  v-if="!isFieldHidden(field)"
208
215
  :data-disabled="isFieldDisabled(field) ? 'true' : void 0"
209
216
  :data-invalid="isFieldInvalid(field) ? 'true' : void 0"
210
- :orientation="displayConfig.orientation"
217
+ :orientation="getConfigOrientation(displayConfig)"
211
218
  :style="field.style ? $dsl.evaluate`${field.style}`() : {}"
212
219
  >
213
220
  <FieldLabel :for="['string', 'number'].includes(field.type) ? `${id}:${field.path}` : void 0">
@@ -241,7 +248,7 @@ export {
241
248
  <InputGroupAddon
242
249
  v-if="hasProperty(modelValue, field.path)"
243
250
  align="inline-end"
244
- :class="displayConfig.orientation === 'floating' ? 'group-data-[disabled=true]/input-group:hidden' : void 0"
251
+ :class="getConfigOrientation(displayConfig) === 'floating' ? 'group-data-[disabled=true]/input-group:hidden' : void 0"
245
252
  >
246
253
  <Tooltip :delay-duration="800">
247
254
  <TooltipTrigger>
@@ -346,7 +353,7 @@ export {
346
353
  <InputGroupAddon
347
354
  v-if="hasProperty(modelValue, field.path)"
348
355
  align="inline-end"
349
- :class="displayConfig.orientation === 'floating' ? 'group-data-[disabled=true]/input-group:hidden' : void 0"
356
+ :class="getConfigOrientation(displayConfig) === 'floating' ? 'group-data-[disabled=true]/input-group:hidden' : void 0"
350
357
  >
351
358
  <Tooltip :delay-duration="800">
352
359
  <TooltipTrigger>
@@ -5,7 +5,6 @@ declare const _default: typeof __VLS_export;
5
5
  export default _default;
6
6
  declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
7
7
  config: Effect.Effect<Readonly<{
8
- orientation: "vertical" | "horizontal" | "floating";
9
8
  fields: readonly ({
10
9
  type: "string";
11
10
  path: string;
@@ -80,13 +79,13 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
80
79
  message: string;
81
80
  }>[] | undefined;
82
81
  })[];
83
- }>>;
82
+ orientation?: "vertical" | "horizontal" | "floating" | undefined;
83
+ }> | undefined>;
84
84
  } & {
85
85
  modelValue?: Record<string, unknown>;
86
86
  }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
87
87
  "update:modelValue": (value: Record<string, unknown>) => any;
88
88
  "update:config": (args_0: Readonly<{
89
- orientation: "vertical" | "horizontal" | "floating";
90
89
  fields: readonly ({
91
90
  type: "string";
92
91
  path: string;
@@ -161,10 +160,10 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
161
160
  message: string;
162
161
  }>[] | undefined;
163
162
  })[];
163
+ orientation?: "vertical" | "horizontal" | "floating" | undefined;
164
164
  }>) => any;
165
165
  }, string, import("vue").PublicProps, Readonly<{
166
166
  config: Effect.Effect<Readonly<{
167
- orientation: "vertical" | "horizontal" | "floating";
168
167
  fields: readonly ({
169
168
  type: "string";
170
169
  path: string;
@@ -239,13 +238,13 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
239
238
  message: string;
240
239
  }>[] | undefined;
241
240
  })[];
242
- }>>;
241
+ orientation?: "vertical" | "horizontal" | "floating" | undefined;
242
+ }> | undefined>;
243
243
  } & {
244
244
  modelValue?: Record<string, unknown>;
245
245
  }> & Readonly<{
246
246
  "onUpdate:modelValue"?: ((value: Record<string, unknown>) => any) | undefined;
247
247
  "onUpdate:config"?: ((args_0: Readonly<{
248
- orientation: "vertical" | "horizontal" | "floating";
249
248
  fields: readonly ({
250
249
  type: "string";
251
250
  path: string;
@@ -320,6 +319,7 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
320
319
  message: string;
321
320
  }>[] | undefined;
322
321
  })[];
322
+ orientation?: "vertical" | "horizontal" | "floating" | undefined;
323
323
  }>) => any) | undefined;
324
324
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
325
325
  default?: (props: {}) => any;
@@ -212,11 +212,11 @@ export declare const FieldsOrientationC: z.ZodEnum<{
212
212
  floating: "floating";
213
213
  }>;
214
214
  export declare const FieldsConfigC: z.ZodReadonly<z.ZodObject<{
215
- orientation: z.ZodEnum<{
215
+ orientation: z.ZodOptional<z.ZodEnum<{
216
216
  vertical: "vertical";
217
217
  horizontal: "horizontal";
218
218
  floating: "floating";
219
- }>;
219
+ }>>;
220
220
  fields: z.ZodReadonly<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
221
221
  type: z.ZodLiteral<"string">;
222
222
  path: z.ZodString;
@@ -66,6 +66,6 @@ export const FieldC = z.discriminatedUnion("type", [
66
66
  ]);
67
67
  export const FieldsOrientationC = z.enum(["horizontal", "vertical", "floating"]);
68
68
  export const FieldsConfigC = z.object({
69
- orientation: FieldsOrientationC.describe("\u5B57\u6BB5\u5E03\u5C40\u65B9\u5411\uFF0C\u53EF\u9009 horizontal\u3001vertical \u6216 floating"),
69
+ orientation: FieldsOrientationC.optional().describe("\u5B57\u6BB5\u5E03\u5C40\u65B9\u5411\uFF0C\u53EF\u9009 horizontal\u3001vertical \u6216 floating\uFF1B\u7559\u7A7A\u65F6\u9ED8\u8BA4 horizontal"),
70
70
  fields: z.array(FieldC).readonly().describe("\u5B57\u6BB5\u5217\u8868")
71
71
  }).readonly();
@@ -9,7 +9,6 @@ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
9
9
  declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
10
10
  "update:open": (value: boolean) => any;
11
11
  confirm: (args_0: Readonly<{
12
- orientation: "vertical" | "horizontal" | "floating";
13
12
  fields: readonly ({
14
13
  type: "string";
15
14
  path: string;
@@ -84,11 +83,11 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
84
83
  message: string;
85
84
  }>[] | undefined;
86
85
  })[];
86
+ orientation?: "vertical" | "horizontal" | "floating" | undefined;
87
87
  }>) => any;
88
88
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
89
89
  "onUpdate:open"?: ((value: boolean) => any) | undefined;
90
90
  onConfirm?: ((args_0: Readonly<{
91
- orientation: "vertical" | "horizontal" | "floating";
92
91
  fields: readonly ({
93
92
  type: "string";
94
93
  path: string;
@@ -163,6 +162,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
163
162
  message: string;
164
163
  }>[] | undefined;
165
164
  })[];
165
+ orientation?: "vertical" | "horizontal" | "floating" | undefined;
166
166
  }>) => any) | undefined;
167
167
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
168
168
  declare const _default: typeof __VLS_export;
@@ -247,7 +247,7 @@ function createField(type) {
247
247
  }
248
248
  }
249
249
  function resetDraftConfig() {
250
- draftOrientation.value = props.config.orientation;
250
+ draftOrientation.value = props.config.orientation ?? "horizontal";
251
251
  draftFields.value = cloneFields(props.config.fields);
252
252
  selectedItemId.value = "general";
253
253
  validationErrors.value = {};
@@ -824,10 +824,16 @@ function confirmChanges() {
824
824
  return;
825
825
  }
826
826
  draftFields.value = normalizedFields.map((item) => createDraftField(item.field));
827
- emit("confirm", {
828
- orientation: draftOrientation.value,
829
- fields: normalizedFields.map((item) => item.field)
830
- });
827
+ if (draftOrientation.value === "horizontal") {
828
+ emit("confirm", {
829
+ fields: normalizedFields.map((item) => item.field)
830
+ });
831
+ } else {
832
+ emit("confirm", {
833
+ orientation: draftOrientation.value,
834
+ fields: normalizedFields.map((item) => item.field)
835
+ });
836
+ }
831
837
  open.value = false;
832
838
  }
833
839
  </script>
@@ -9,7 +9,6 @@ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
9
9
  declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
10
10
  "update:open": (value: boolean) => any;
11
11
  confirm: (args_0: Readonly<{
12
- orientation: "vertical" | "horizontal" | "floating";
13
12
  fields: readonly ({
14
13
  type: "string";
15
14
  path: string;
@@ -84,11 +83,11 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
84
83
  message: string;
85
84
  }>[] | undefined;
86
85
  })[];
86
+ orientation?: "vertical" | "horizontal" | "floating" | undefined;
87
87
  }>) => any;
88
88
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
89
89
  "onUpdate:open"?: ((value: boolean) => any) | undefined;
90
90
  onConfirm?: ((args_0: Readonly<{
91
- orientation: "vertical" | "horizontal" | "floating";
92
91
  fields: readonly ({
93
92
  type: "string";
94
93
  path: string;
@@ -163,6 +162,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
163
162
  message: string;
164
163
  }>[] | undefined;
165
164
  })[];
165
+ orientation?: "vertical" | "horizontal" | "floating" | undefined;
166
166
  }>) => any) | undefined;
167
167
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
168
168
  declare const _default: typeof __VLS_export;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shwfed/nuxt",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "type": "module",