@shwfed/nuxt 0.10.11 → 0.10.13
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
|
@@ -43,7 +43,7 @@ const open = defineModel("open", { type: Boolean, ...{
|
|
|
43
43
|
const { $toast } = useNuxtApp();
|
|
44
44
|
const { t } = useI18n();
|
|
45
45
|
const search = ref("");
|
|
46
|
-
const draftGap = ref(props.config.gap ??
|
|
46
|
+
const draftGap = ref(props.config.gap ?? 4);
|
|
47
47
|
const draftStyle = ref(props.config.style);
|
|
48
48
|
const selectedItemId = ref("general");
|
|
49
49
|
const draftTree = ref(buildButtonConfiguratorTree(props.config.groups));
|
|
@@ -90,7 +90,6 @@ const selectedNode = computed(() => {
|
|
|
90
90
|
const selectedGroup = computed(() => selectedNode.value?.item.type === "group" ? selectedNode.value.item : void 0);
|
|
91
91
|
const selectedButton = computed(() => selectedNode.value?.item.type === "button" ? selectedNode.value.item : void 0);
|
|
92
92
|
const selectedDropdown = computed(() => selectedNode.value?.item.type === "dropdown" ? selectedNode.value.item : void 0);
|
|
93
|
-
const selectedNodeItemId = computed(() => selectedNode.value?.itemId ?? "");
|
|
94
93
|
const selectedParentNodeId = computed(() => {
|
|
95
94
|
const parentItemId = selectedNode.value?.parentItemId;
|
|
96
95
|
if (!parentItemId) {
|
|
@@ -109,13 +108,19 @@ const canAddGroup = computed(() => selectedItemId.value === "general");
|
|
|
109
108
|
const canAddGroupButton = computed(() => selectedNode.value?.item.type === "group");
|
|
110
109
|
const canAddGroupDropdown = computed(() => selectedNode.value?.item.type === "group");
|
|
111
110
|
const canAddDropdownChildButton = computed(() => selectedNode.value?.item.type === "dropdown");
|
|
112
|
-
const flattenedItems = computed(() => flattenButtonConfiguratorTree(draftTree.value).
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
111
|
+
const flattenedItems = computed(() => flattenButtonConfiguratorTree(draftTree.value).flatMap((item) => {
|
|
112
|
+
const node = getButtonConfiguratorNode(draftTree.value, item.itemId);
|
|
113
|
+
if (!node) {
|
|
114
|
+
return [];
|
|
115
|
+
}
|
|
116
|
+
return [{
|
|
117
|
+
itemId: item.itemId,
|
|
118
|
+
depth: item.depth,
|
|
119
|
+
label: getNodeLabel(node),
|
|
120
|
+
type: item.item.type,
|
|
121
|
+
id: item.item.id
|
|
122
|
+
}];
|
|
123
|
+
}));
|
|
119
124
|
const filteredItems = computed(() => {
|
|
120
125
|
if (!normalizedSearch.value) {
|
|
121
126
|
return flattenedItems.value;
|
|
@@ -129,7 +134,7 @@ const selectedItemLabel = computed(() => {
|
|
|
129
134
|
if (!selectedNode.value) {
|
|
130
135
|
return generalItem.value.label;
|
|
131
136
|
}
|
|
132
|
-
return getNodeLabel(selectedNode.value
|
|
137
|
+
return getNodeLabel(selectedNode.value);
|
|
133
138
|
});
|
|
134
139
|
const selectedContainerItemIds = computed(() => {
|
|
135
140
|
if (selectedItemId.value === "general") {
|
|
@@ -159,7 +164,7 @@ const childItems = computed(() => selectedContainerItemIds.value.flatMap((itemId
|
|
|
159
164
|
}
|
|
160
165
|
return [{
|
|
161
166
|
itemId: node.itemId,
|
|
162
|
-
label: getNodeLabel(node
|
|
167
|
+
label: getNodeLabel(node),
|
|
163
168
|
type: node.item.type,
|
|
164
169
|
id: node.item.id
|
|
165
170
|
}];
|
|
@@ -169,7 +174,7 @@ const buttonParentOptions = computed(() => draftTree.value.nodes.flatMap((node)
|
|
|
169
174
|
return [{
|
|
170
175
|
id: node.item.id,
|
|
171
176
|
itemId: node.itemId,
|
|
172
|
-
label: getNodeLabel(node
|
|
177
|
+
label: getNodeLabel(node),
|
|
173
178
|
type: "group"
|
|
174
179
|
}];
|
|
175
180
|
}
|
|
@@ -177,7 +182,7 @@ const buttonParentOptions = computed(() => draftTree.value.nodes.flatMap((node)
|
|
|
177
182
|
return [{
|
|
178
183
|
id: node.item.id,
|
|
179
184
|
itemId: node.itemId,
|
|
180
|
-
label: getNodeLabel(node
|
|
185
|
+
label: getNodeLabel(node),
|
|
181
186
|
type: "dropdown"
|
|
182
187
|
}];
|
|
183
188
|
}
|
|
@@ -186,7 +191,7 @@ const buttonParentOptions = computed(() => draftTree.value.nodes.flatMap((node)
|
|
|
186
191
|
const dropdownParentOptions = computed(() => draftTree.value.nodes.flatMap((node) => node.item.type === "group" ? [{
|
|
187
192
|
id: node.item.id,
|
|
188
193
|
itemId: node.itemId,
|
|
189
|
-
label: getNodeLabel(node
|
|
194
|
+
label: getNodeLabel(node)
|
|
190
195
|
}] : []));
|
|
191
196
|
watch(() => props.config, (config) => {
|
|
192
197
|
applyDraftConfig(config);
|
|
@@ -240,14 +245,24 @@ function isCopyableNode(node) {
|
|
|
240
245
|
}
|
|
241
246
|
return node.item.type === "button" || node.item.type === "dropdown";
|
|
242
247
|
}
|
|
243
|
-
function getNodeLabel(
|
|
244
|
-
if (item.type === "group") {
|
|
248
|
+
function getNodeLabel(node) {
|
|
249
|
+
if (node.item.type === "group") {
|
|
250
|
+
const childLabels = node.childItemIds.flatMap((itemId) => {
|
|
251
|
+
const childNode = getButtonConfiguratorNode(draftTree.value, itemId);
|
|
252
|
+
if (!childNode || childNode.item.type === "group") {
|
|
253
|
+
return [];
|
|
254
|
+
}
|
|
255
|
+
return [getNodeLabel(childNode)];
|
|
256
|
+
});
|
|
257
|
+
if (childLabels.length > 0) {
|
|
258
|
+
return childLabels.join("\u3001");
|
|
259
|
+
}
|
|
245
260
|
return t("group-label");
|
|
246
261
|
}
|
|
247
|
-
return getZhText(item.title) ?? t(item.type === "button" ? "untitled-button" : "untitled-dropdown");
|
|
262
|
+
return getZhText(node.item.title) ?? t(node.item.type === "button" ? "untitled-button" : "untitled-dropdown");
|
|
248
263
|
}
|
|
249
264
|
function applyDraftConfig(config) {
|
|
250
|
-
draftGap.value = config.gap ??
|
|
265
|
+
draftGap.value = config.gap ?? 4;
|
|
251
266
|
draftStyle.value = config.style;
|
|
252
267
|
draftTree.value = buildButtonConfiguratorTree(config.groups);
|
|
253
268
|
validationErrors.value = {};
|
|
@@ -882,18 +897,7 @@ function confirmChanges() {
|
|
|
882
897
|
v-else-if="selectedGroup"
|
|
883
898
|
data-slot="button-configurator-group"
|
|
884
899
|
class="mt-6 grid gap-4"
|
|
885
|
-
|
|
886
|
-
<Button
|
|
887
|
-
type="button"
|
|
888
|
-
variant="ghost"
|
|
889
|
-
data-slot="button-configurator-delete-selected"
|
|
890
|
-
class="justify-start text-red-600 hover:bg-red-50 hover:text-red-700"
|
|
891
|
-
@click="deleteItem(selectedNodeItemId)"
|
|
892
|
-
>
|
|
893
|
-
<Icon icon="fluent:delete-20-regular" />
|
|
894
|
-
{{ t("delete-group") }}
|
|
895
|
-
</Button>
|
|
896
|
-
</section>
|
|
900
|
+
/>
|
|
897
901
|
|
|
898
902
|
<section
|
|
899
903
|
v-else-if="selectedButton"
|
|
@@ -980,17 +984,6 @@ function confirmChanges() {
|
|
|
980
984
|
/>
|
|
981
985
|
<span class="text-sm text-zinc-700">{{ t("button-hide-title") }}</span>
|
|
982
986
|
</label>
|
|
983
|
-
|
|
984
|
-
<Button
|
|
985
|
-
type="button"
|
|
986
|
-
variant="ghost"
|
|
987
|
-
data-slot="button-configurator-delete-selected"
|
|
988
|
-
class="justify-start text-red-600 hover:bg-red-50 hover:text-red-700"
|
|
989
|
-
@click="deleteItem(selectedNodeItemId)"
|
|
990
|
-
>
|
|
991
|
-
<Icon icon="fluent:delete-20-regular" />
|
|
992
|
-
{{ t("delete-button") }}
|
|
993
|
-
</Button>
|
|
994
987
|
</section>
|
|
995
988
|
|
|
996
989
|
<section
|
|
@@ -1032,17 +1025,6 @@ function confirmChanges() {
|
|
|
1032
1025
|
</NativeSelectOption>
|
|
1033
1026
|
</NativeSelect>
|
|
1034
1027
|
</label>
|
|
1035
|
-
|
|
1036
|
-
<Button
|
|
1037
|
-
type="button"
|
|
1038
|
-
variant="ghost"
|
|
1039
|
-
data-slot="button-configurator-delete-selected"
|
|
1040
|
-
class="justify-start text-red-600 hover:bg-red-50 hover:text-red-700"
|
|
1041
|
-
@click="deleteItem(selectedNodeItemId)"
|
|
1042
|
-
>
|
|
1043
|
-
<Icon icon="fluent:delete-20-regular" />
|
|
1044
|
-
{{ t("delete-dropdown") }}
|
|
1045
|
-
</Button>
|
|
1046
1028
|
</section>
|
|
1047
1029
|
|
|
1048
1030
|
<section
|
|
@@ -1099,43 +1081,50 @@ function confirmChanges() {
|
|
|
1099
1081
|
</section>
|
|
1100
1082
|
</div>
|
|
1101
1083
|
|
|
1102
|
-
<DialogFooter class="border-t border-zinc-200 px-6 py-4">
|
|
1103
|
-
<
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
data-slot="button-configurator-copy-markdown"
|
|
1107
|
-
@click="void copyMarkdown()"
|
|
1108
|
-
>
|
|
1109
|
-
<Icon icon="fluent:document-one-page-20-regular" />
|
|
1110
|
-
{{ t("copy-markdown") }}
|
|
1111
|
-
</Button>
|
|
1112
|
-
<Button
|
|
1113
|
-
type="button"
|
|
1114
|
-
variant="ghost"
|
|
1115
|
-
data-slot="button-configurator-copy-config"
|
|
1116
|
-
@click="void copyConfig()"
|
|
1084
|
+
<DialogFooter class="border-t border-zinc-200 px-6 py-4 sm:justify-between">
|
|
1085
|
+
<div
|
|
1086
|
+
data-slot="button-configurator-copy-actions"
|
|
1087
|
+
class="flex items-center gap-2"
|
|
1117
1088
|
>
|
|
1118
|
-
<
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
<
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1089
|
+
<Button
|
|
1090
|
+
type="button"
|
|
1091
|
+
variant="ghost"
|
|
1092
|
+
data-slot="button-configurator-copy-markdown"
|
|
1093
|
+
@click="void copyMarkdown()"
|
|
1094
|
+
>
|
|
1095
|
+
<Icon icon="simple-icons:markdown" />
|
|
1096
|
+
{{ t("copy-markdown") }}
|
|
1097
|
+
</Button>
|
|
1098
|
+
<Button
|
|
1099
|
+
type="button"
|
|
1100
|
+
variant="ghost"
|
|
1101
|
+
data-slot="button-configurator-copy-config"
|
|
1102
|
+
@click="void copyConfig()"
|
|
1103
|
+
>
|
|
1104
|
+
<Icon icon="fluent:copy-20-regular" />
|
|
1105
|
+
{{ t("copy-config") }}
|
|
1106
|
+
</Button>
|
|
1107
|
+
</div>
|
|
1108
|
+
<div class="flex items-center gap-2">
|
|
1109
|
+
<Button
|
|
1110
|
+
type="button"
|
|
1111
|
+
variant="default"
|
|
1112
|
+
data-slot="button-configurator-cancel"
|
|
1113
|
+
@click="open = false"
|
|
1114
|
+
>
|
|
1115
|
+
<Icon icon="fluent:dismiss-20-regular" />
|
|
1116
|
+
{{ t("cancel") }}
|
|
1117
|
+
</Button>
|
|
1118
|
+
<Button
|
|
1119
|
+
type="button"
|
|
1120
|
+
variant="primary"
|
|
1121
|
+
data-slot="button-configurator-confirm"
|
|
1122
|
+
@click="confirmChanges"
|
|
1123
|
+
>
|
|
1124
|
+
<Icon icon="fluent:checkmark-20-regular" />
|
|
1125
|
+
{{ t("confirm") }}
|
|
1126
|
+
</Button>
|
|
1127
|
+
</div>
|
|
1139
1128
|
</DialogFooter>
|
|
1140
1129
|
</DialogContent>
|
|
1141
1130
|
</Dialog>
|
|
@@ -23,7 +23,7 @@ const props = defineProps({
|
|
|
23
23
|
});
|
|
24
24
|
const emit = defineEmits(["update:config"]);
|
|
25
25
|
const defaultConfig = {
|
|
26
|
-
gap:
|
|
26
|
+
gap: 4,
|
|
27
27
|
groups: []
|
|
28
28
|
};
|
|
29
29
|
const uuidPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu;
|
|
@@ -80,7 +80,7 @@ function getConfigStyle(config) {
|
|
|
80
80
|
return style;
|
|
81
81
|
}
|
|
82
82
|
const rootStyle = computed(() => ({
|
|
83
|
-
gap: `calc(${displayConfig.value.gap ?? defaultConfig.gap ??
|
|
83
|
+
gap: `calc(${displayConfig.value.gap ?? defaultConfig.gap ?? 4} * 0.25rem)`,
|
|
84
84
|
...getConfigStyle(displayConfig.value)
|
|
85
85
|
}));
|
|
86
86
|
function getButtonLabel(button) {
|