@shwfed/nuxt 0.9.1 → 0.9.2

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.1",
4
+ "version": "0.9.2",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -86,6 +86,7 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
86
86
  }>[] | undefined;
87
87
  })[];
88
88
  orientation?: "vertical" | "horizontal" | "floating" | undefined;
89
+ style?: string | undefined;
89
90
  }>) => any;
90
91
  }, string, import("vue").PublicProps, Readonly<{
91
92
  config?: Effect.Effect<FieldsConfig | undefined>;
@@ -169,6 +170,7 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
169
170
  }>[] | undefined;
170
171
  })[];
171
172
  orientation?: "vertical" | "horizontal" | "floating" | undefined;
173
+ style?: string | undefined;
172
174
  }>) => any) | undefined;
173
175
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
174
176
  [x: string]: ((props: any) => any) | undefined;
@@ -86,6 +86,7 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
86
86
  }>[] | undefined;
87
87
  })[];
88
88
  orientation?: "vertical" | "horizontal" | "floating" | undefined;
89
+ style?: string | undefined;
89
90
  }>) => any;
90
91
  }, string, import("vue").PublicProps, Readonly<{
91
92
  config?: Effect.Effect<FieldsConfig | undefined>;
@@ -169,6 +170,7 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
169
170
  }>[] | undefined;
170
171
  })[];
171
172
  orientation?: "vertical" | "horizontal" | "floating" | undefined;
173
+ style?: string | undefined;
172
174
  }>) => any) | undefined;
173
175
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
174
176
  [x: string]: ((props: any) => any) | undefined;
@@ -80,6 +80,7 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
80
80
  }>[] | undefined;
81
81
  })[];
82
82
  orientation?: "vertical" | "horizontal" | "floating" | undefined;
83
+ style?: string | undefined;
83
84
  }> | undefined>;
84
85
  } & {
85
86
  modelValue?: Record<string, unknown>;
@@ -161,6 +162,7 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
161
162
  }>[] | undefined;
162
163
  })[];
163
164
  orientation?: "vertical" | "horizontal" | "floating" | undefined;
165
+ style?: string | undefined;
164
166
  }>) => any;
165
167
  }, string, import("vue").PublicProps, Readonly<{
166
168
  config: Effect.Effect<Readonly<{
@@ -239,6 +241,7 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
239
241
  }>[] | undefined;
240
242
  })[];
241
243
  orientation?: "vertical" | "horizontal" | "floating" | undefined;
244
+ style?: string | undefined;
242
245
  }> | undefined>;
243
246
  } & {
244
247
  modelValue?: Record<string, unknown>;
@@ -320,6 +323,7 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
320
323
  }>[] | undefined;
321
324
  })[];
322
325
  orientation?: "vertical" | "horizontal" | "floating" | undefined;
326
+ style?: string | undefined;
323
327
  }>) => any) | undefined;
324
328
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
325
329
  default?: (props: {}) => any;
@@ -41,19 +41,33 @@ const displayConfig = ref(defaultConfig);
41
41
  const validationErrors = ref({});
42
42
  const calendarOpen = ref({});
43
43
  function cloneConfig(config2) {
44
- if (config2.orientation) {
45
- return {
46
- orientation: config2.orientation,
47
- fields: config2.fields.slice()
48
- };
49
- }
50
- return {
44
+ const nextConfig = {
51
45
  fields: config2.fields.slice()
52
46
  };
47
+ if (config2.orientation) {
48
+ nextConfig.orientation = config2.orientation;
49
+ }
50
+ if (config2.style) {
51
+ nextConfig.style = config2.style;
52
+ }
53
+ return nextConfig;
53
54
  }
54
55
  function getConfigOrientation(config2) {
55
56
  return config2.orientation ?? "horizontal";
56
57
  }
58
+ function getConfigStyle(config2) {
59
+ const style = {};
60
+ if (!config2.style) {
61
+ return style;
62
+ }
63
+ const styleMap = $dsl.evaluate`${config2.style}`({ form: modelValue.value });
64
+ for (const [key, value] of Object.entries(styleMap)) {
65
+ if (typeof value === "string" || typeof value === "number") {
66
+ Reflect.set(style, key, value);
67
+ }
68
+ }
69
+ return style;
70
+ }
57
71
  function toCalendarDateValue(value, valueFormat) {
58
72
  if (typeof value !== "string") return void 0;
59
73
  const date = parse(value, valueFormat, /* @__PURE__ */ new Date());
@@ -181,6 +195,7 @@ export {
181
195
  'relative p-1 -m-1 border border-dashed',
182
196
  isCheating ? 'border-(--primary)/20 rounded hover:border-(--primary)/40 transition-colors duration-150 group cursor-pointer' : 'border-transparent'
183
197
  ]"
198
+ :style="getConfigStyle(displayConfig)"
184
199
  >
185
200
  <Button
186
201
  v-if="isCheating"
@@ -80,6 +80,7 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
80
80
  }>[] | undefined;
81
81
  })[];
82
82
  orientation?: "vertical" | "horizontal" | "floating" | undefined;
83
+ style?: string | undefined;
83
84
  }> | undefined>;
84
85
  } & {
85
86
  modelValue?: Record<string, unknown>;
@@ -161,6 +162,7 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
161
162
  }>[] | undefined;
162
163
  })[];
163
164
  orientation?: "vertical" | "horizontal" | "floating" | undefined;
165
+ style?: string | undefined;
164
166
  }>) => any;
165
167
  }, string, import("vue").PublicProps, Readonly<{
166
168
  config: Effect.Effect<Readonly<{
@@ -239,6 +241,7 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
239
241
  }>[] | undefined;
240
242
  })[];
241
243
  orientation?: "vertical" | "horizontal" | "floating" | undefined;
244
+ style?: string | undefined;
242
245
  }> | undefined>;
243
246
  } & {
244
247
  modelValue?: Record<string, unknown>;
@@ -320,6 +323,7 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
320
323
  }>[] | undefined;
321
324
  })[];
322
325
  orientation?: "vertical" | "horizontal" | "floating" | undefined;
326
+ style?: string | undefined;
323
327
  }>) => any) | undefined;
324
328
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
325
329
  default?: (props: {}) => any;
@@ -211,12 +211,14 @@ export declare const FieldsOrientationC: z.ZodEnum<{
211
211
  horizontal: "horizontal";
212
212
  floating: "floating";
213
213
  }>;
214
+ export declare const FieldsStyleC: z.ZodOptional<z.ZodString>;
214
215
  export declare const FieldsConfigC: z.ZodReadonly<z.ZodObject<{
215
216
  orientation: z.ZodOptional<z.ZodEnum<{
216
217
  vertical: "vertical";
217
218
  horizontal: "horizontal";
218
219
  floating: "floating";
219
220
  }>>;
221
+ style: z.ZodOptional<z.ZodString>;
220
222
  fields: z.ZodReadonly<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
221
223
  type: z.ZodLiteral<"string">;
222
224
  path: z.ZodString;
@@ -65,7 +65,11 @@ export const FieldC = z.discriminatedUnion("type", [
65
65
  CalendarFieldC
66
66
  ]);
67
67
  export const FieldsOrientationC = z.enum(["horizontal", "vertical", "floating"]);
68
+ export const FieldsStyleC = expressionC(/^map/, {
69
+ form: "map<string, dyn>"
70
+ }).optional().describe("\u8FD4\u56DE\u5B57\u6BB5\u96C6\u5408\u5BB9\u5668\u6837\u5F0F\u5BF9\u8C61\u7684 CEL \u8868\u8FBE\u5F0F\uFF0C\u53EF\u4F7F\u7528 form \u53D8\u91CF\u3002");
68
71
  export const FieldsConfigC = z.object({
69
72
  orientation: FieldsOrientationC.optional().describe("\u5B57\u6BB5\u5E03\u5C40\u65B9\u5411\uFF0C\u53EF\u9009 horizontal\u3001vertical \u6216 floating\uFF1B\u7559\u7A7A\u65F6\u9ED8\u8BA4 horizontal"),
73
+ style: FieldsStyleC,
70
74
  fields: z.array(FieldC).readonly().describe("\u5B57\u6BB5\u5217\u8868")
71
75
  }).readonly();
@@ -84,6 +84,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
84
84
  }>[] | undefined;
85
85
  })[];
86
86
  orientation?: "vertical" | "horizontal" | "floating" | undefined;
87
+ style?: string | undefined;
87
88
  }>) => any;
88
89
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
89
90
  "onUpdate:open"?: ((value: boolean) => any) | undefined;
@@ -163,6 +164,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
163
164
  }>[] | undefined;
164
165
  })[];
165
166
  orientation?: "vertical" | "horizontal" | "floating" | undefined;
167
+ style?: string | undefined;
166
168
  }>) => any) | undefined;
167
169
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
168
170
  declare const _default: typeof __VLS_export;
@@ -7,7 +7,8 @@ import {
7
7
  CalendarFieldC,
8
8
  NumberFieldC,
9
9
  SelectFieldC,
10
- StringFieldC
10
+ StringFieldC,
11
+ FieldsStyleC
11
12
  } from "../fields/schema";
12
13
  import { cn } from "../../../utils/cn";
13
14
  import { Button } from "../button";
@@ -40,6 +41,7 @@ const open = defineModel("open", { type: Boolean, ...{
40
41
  } });
41
42
  const { t } = useI18n();
42
43
  const draftOrientation = ref("horizontal");
44
+ const draftStyle = ref();
43
45
  const selectedItemId = ref("general");
44
46
  const draftFields = ref([]);
45
47
  const sortableListRef = ref(null);
@@ -111,6 +113,9 @@ function getFieldErrorKey(draftId, fieldKey) {
111
113
  function getValidationRuleErrorKey(draftId, index, control) {
112
114
  return `${draftId}:validation:${index}:${control}`;
113
115
  }
116
+ function getGeneralErrorKey(fieldKey) {
117
+ return `general:${fieldKey}`;
118
+ }
114
119
  function clearError(key) {
115
120
  Reflect.deleteProperty(validationErrors.value, key);
116
121
  }
@@ -248,6 +253,7 @@ function createField(type) {
248
253
  }
249
254
  function resetDraftConfig() {
250
255
  draftOrientation.value = props.config.orientation ?? "horizontal";
256
+ draftStyle.value = normalizeOptionalString(props.config.style ?? "");
251
257
  draftFields.value = cloneFields(props.config.fields);
252
258
  selectedItemId.value = "general";
253
259
  validationErrors.value = {};
@@ -338,6 +344,10 @@ function selectItem(itemId) {
338
344
  function updateDraftOrientation(value) {
339
345
  draftOrientation.value = normalizeOrientation(value);
340
346
  }
347
+ function updateDraftStyle(value) {
348
+ clearError(getGeneralErrorKey("style"));
349
+ draftStyle.value = normalizeOptionalString(String(value));
350
+ }
341
351
  function updateDraftField(draftId, updater) {
342
352
  draftFields.value = draftFields.value.map((item) => item.draftId === draftId ? {
343
353
  draftId: item.draftId,
@@ -823,17 +833,26 @@ function confirmChanges() {
823
833
  if (!normalizedFields) {
824
834
  return;
825
835
  }
836
+ const generalStyleResult = FieldsStyleC.safeParse(draftStyle.value);
837
+ if (!generalStyleResult.success) {
838
+ validationErrors.value = {
839
+ ...validationErrors.value,
840
+ [getGeneralErrorKey("style")]: generalStyleResult.error.issues[0]?.message ?? t("general-style-invalid")
841
+ };
842
+ selectedItemId.value = "general";
843
+ return;
844
+ }
826
845
  draftFields.value = normalizedFields.map((item) => createDraftField(item.field));
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
- });
846
+ const nextConfig = {
847
+ fields: normalizedFields.map((item) => item.field)
848
+ };
849
+ if (draftOrientation.value !== "horizontal") {
850
+ nextConfig.orientation = draftOrientation.value;
851
+ }
852
+ if (generalStyleResult.data) {
853
+ nextConfig.style = generalStyleResult.data;
836
854
  }
855
+ emit("confirm", nextConfig);
837
856
  open.value = false;
838
857
  }
839
858
  </script>
@@ -1019,6 +1038,30 @@ function confirmChanges() {
1019
1038
  </NativeSelectOption>
1020
1039
  </NativeSelect>
1021
1040
  </label>
1041
+
1042
+ <label
1043
+ data-slot="fields-configurator-general-style-section"
1044
+ class="flex flex-col gap-2 md:col-span-2"
1045
+ >
1046
+ <span class="text-xs font-medium text-zinc-500">
1047
+ {{ t("general-style") }}
1048
+ </span>
1049
+ <Textarea
1050
+ data-slot="fields-configurator-general-style-input"
1051
+ :model-value="draftStyle ?? ''"
1052
+ :aria-invalid="validationErrors[getGeneralErrorKey('style')] ? 'true' : void 0"
1053
+ :placeholder="t('general-style-placeholder')"
1054
+ class="min-h-20 font-mono text-sm"
1055
+ @update:model-value="updateDraftStyle"
1056
+ />
1057
+ <p
1058
+ v-if="validationErrors[getGeneralErrorKey('style')]"
1059
+ data-slot="fields-configurator-general-style-error"
1060
+ class="text-xs text-red-500"
1061
+ >
1062
+ {{ validationErrors[getGeneralErrorKey("style")] }}
1063
+ </p>
1064
+ </label>
1022
1065
  </section>
1023
1066
 
1024
1067
  <div
@@ -1606,6 +1649,9 @@ function confirmChanges() {
1606
1649
  "field-list": "字段列表",
1607
1650
  "general": "通用",
1608
1651
  "general-description": "在这里配置字段集合级别的公共选项。",
1652
+ "general-style": "通用样式表达式",
1653
+ "general-style-placeholder": "例如返回一个 style map,例如 display: grid",
1654
+ "general-style-invalid": "样式表达式无效",
1609
1655
  "fields-orientation": "布局方向",
1610
1656
  "fields-orientation-horizontal": "水平",
1611
1657
  "fields-orientation-vertical": "垂直",
@@ -1680,6 +1726,9 @@ function confirmChanges() {
1680
1726
  "field-list": "フィールド一覧",
1681
1727
  "general": "共通",
1682
1728
  "general-description": "ここではフィールド群全体に適用される共通設定を編集できます。",
1729
+ "general-style": "共通スタイル式",
1730
+ "general-style-placeholder": "例: style map を返す式。例: display: grid",
1731
+ "general-style-invalid": "スタイル式が無効です",
1683
1732
  "fields-orientation": "レイアウト方向",
1684
1733
  "fields-orientation-horizontal": "横並び",
1685
1734
  "fields-orientation-vertical": "縦並び",
@@ -1754,6 +1803,9 @@ function confirmChanges() {
1754
1803
  "field-list": "Field list",
1755
1804
  "general": "General",
1756
1805
  "general-description": "Edit the shared settings that apply to the whole field group here.",
1806
+ "general-style": "Shared style expression",
1807
+ "general-style-placeholder": "Return a style map, for example display: grid",
1808
+ "general-style-invalid": "The style expression is invalid",
1757
1809
  "fields-orientation": "Layout orientation",
1758
1810
  "fields-orientation-horizontal": "Horizontal",
1759
1811
  "fields-orientation-vertical": "Vertical",
@@ -84,6 +84,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
84
84
  }>[] | undefined;
85
85
  })[];
86
86
  orientation?: "vertical" | "horizontal" | "floating" | undefined;
87
+ style?: string | undefined;
87
88
  }>) => any;
88
89
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
89
90
  "onUpdate:open"?: ((value: boolean) => any) | undefined;
@@ -163,6 +164,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
163
164
  }>[] | undefined;
164
165
  })[];
165
166
  orientation?: "vertical" | "horizontal" | "floating" | undefined;
167
+ style?: string | undefined;
166
168
  }>) => any) | undefined;
167
169
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
168
170
  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.1",
3
+ "version": "0.9.2",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "type": "module",