@mouseless/baked 1.4.1 → 1.4.3

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": "@mouseless/baked",
3
3
  "configKey": "baked",
4
- "version": "1.4.1",
4
+ "version": "1.4.3",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "unknown"
@@ -2,7 +2,7 @@
2
2
  <div class="flex flex-col gap-8">
3
3
  <PageTitle :schema="title">
4
4
  <template
5
- v-if="inputs.length > 0"
5
+ v-if="sections.length > 0"
6
6
  #actions
7
7
  >
8
8
  <Button
@@ -13,36 +13,107 @@
13
13
  </template>
14
14
  </PageTitle>
15
15
  <div class="flex justify-center">
16
- <Contents>
17
- <Inputs
18
- v-if="inputs"
19
- :inputs="inputs"
20
- :input-class="`w-full lg:col-span-2`"
21
- @ready="onReady"
22
- @changed="onChanged"
23
- />
16
+ <Contents class="gap-6">
17
+ <div
18
+ v-for="section in sections"
19
+ :key="section.key"
20
+ class="w-full col-span-2 grid gap-4"
21
+ >
22
+ <div
23
+ v-if="sections.length > 1"
24
+ class="
25
+ pb-2 border-b-2
26
+ border-zinc-100 dark:border-zinc-900
27
+ "
28
+ >
29
+ <span
30
+ class="
31
+ text-md font-semibold
32
+ text-zinc-800 dark:text-zinc-400
33
+ "
34
+ >
35
+ {{ l(section.label) }}
36
+ </span>
37
+ </div>
38
+ <template
39
+ v-for="(inputGroups, i) in splitByWide(section.inputGroups)"
40
+ :key="`${section.key}_${i}`"
41
+ >
42
+ <div
43
+ v-if="inputGroups.length > 0"
44
+ class="
45
+ grid grid-cols-2 grid-flow-col
46
+ gap-4 items-start
47
+ max-md:flex max-md:flex-col
48
+ "
49
+ :style="{ 'grid-template-rows': `repeat(${Math.ceil(inputGroups.length / 2)}, auto)` }"
50
+ >
51
+ <div
52
+ v-for="inputGroup in inputGroups"
53
+ :key="inputGroup.key"
54
+ class="w-full flex gap-4 max-md:flex-col"
55
+ :class="{
56
+ 'col-span-2': inputGroup.wide,
57
+ 'reset-min-w': inputGroup.inputs.length > 1
58
+ }"
59
+ >
60
+ <Inputs
61
+ :inputs="inputGroup.inputs"
62
+ input-class="w-full"
63
+ @ready="(value) => onReady(`${section.key}_${inputGroup.key}`, value)"
64
+ @changed="onChanged"
65
+ />
66
+ </div>
67
+ </div>
68
+ </template>
69
+ </div>
24
70
  </Contents>
25
71
  </div>
26
72
  </div>
27
73
  </template>
28
74
 
29
75
  <script setup>
30
- import { ref } from "vue";
76
+ import { computed, ref } from "vue";
77
+ import { useLocalization } from "#imports";
31
78
  import { Button, Contents, Inputs, PageTitle } from "#components";
79
+ const { localize: l } = useLocalization();
32
80
  const { schema } = defineProps({
33
81
  schema: { type: null, required: true }
34
82
  });
35
83
  const emit = defineEmits(["submit"]);
36
- const { title, submit, inputs } = schema;
84
+ const { title, submit, sections } = schema;
37
85
  const formData = ref({});
38
- const ready = ref(inputs.length === 0);
39
- function onReady(value) {
40
- ready.value = value;
86
+ const readyData = ref({});
87
+ const ready = computed(() => Object.values(readyData.value).every((v) => v));
88
+ function splitByWide(inputGroups) {
89
+ const result = [];
90
+ let cur = [];
91
+ for (const inputGroup of inputGroups) {
92
+ if (!inputGroup.wide) {
93
+ cur.push(inputGroup);
94
+ continue;
95
+ }
96
+ result.push(cur);
97
+ result.push([inputGroup]);
98
+ cur = [];
99
+ }
100
+ result.push(cur);
101
+ return result;
102
+ }
103
+ function onReady(key, value) {
104
+ Object.assign(readyData.value, { [key]: value });
41
105
  }
42
106
  function onChanged({ values }) {
43
- formData.value = values;
107
+ Object.assign(formData.value, values);
44
108
  }
45
109
  function onSubmit() {
110
+ if (!ready.value) {
111
+ return;
112
+ }
46
113
  emit("submit", formData.value);
47
114
  }
48
115
  </script>
116
+
117
+ <style>
118
+ .b-component--FormPage .reset-min-w *{@apply min-w-0}
119
+ </style>
@@ -9,6 +9,7 @@
9
9
  <InputNumber
10
10
  v-model="model"
11
11
  v-bind="$attrs"
12
+ :use-grouping="!noGrouping"
12
13
  class="min-w-60"
13
14
  @input="onInput"
14
15
  />
@@ -27,7 +28,7 @@ const { schema } = defineProps({
27
28
  schema: { type: null, required: true }
28
29
  });
29
30
  const model = defineModel({ type: null, required: true });
30
- const { label } = schema;
31
+ const { label, noGrouping } = schema;
31
32
  const path = context.injectPath();
32
33
  function onInput(event) {
33
34
  model.value = event.value;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mouseless/baked",
3
- "version": "1.4.1",
3
+ "version": "1.4.3",
4
4
  "description": "Baked is an opinionated framework for .NET and Vue. This is the UI package of Baked project.",
5
5
  "keywords": [
6
6
  "baked",