@shwfed/nuxt 0.11.49 → 0.11.50

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.11.49",
4
+ "version": "0.11.50",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -23,6 +23,8 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
23
23
  message: string;
24
24
  }[] | undefined;
25
25
  icon?: string | undefined;
26
+ hidden?: string | undefined;
27
+ disabled?: string | undefined;
26
28
  variant?: "default" | "destructive" | "primary" | "ghost" | undefined;
27
29
  size?: "default" | "sm" | "xs" | undefined;
28
30
  hideTitle?: boolean | undefined;
@@ -56,6 +58,8 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
56
58
  message: string;
57
59
  }[] | undefined;
58
60
  icon?: string | undefined;
61
+ hidden?: string | undefined;
62
+ disabled?: string | undefined;
59
63
  variant?: "default" | "destructive" | "primary" | "ghost" | undefined;
60
64
  modal?: Readonly<{
61
65
  title?: readonly {
@@ -98,6 +102,8 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
98
102
  message: string;
99
103
  }[] | undefined;
100
104
  icon?: string | undefined;
105
+ hidden?: string | undefined;
106
+ disabled?: string | undefined;
101
107
  variant?: "default" | "destructive" | "primary" | "ghost" | undefined;
102
108
  size?: "default" | "sm" | "xs" | undefined;
103
109
  hideTitle?: boolean | undefined;
@@ -131,6 +137,8 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
131
137
  message: string;
132
138
  }[] | undefined;
133
139
  icon?: string | undefined;
140
+ hidden?: string | undefined;
141
+ disabled?: string | undefined;
134
142
  variant?: "default" | "destructive" | "primary" | "ghost" | undefined;
135
143
  modal?: Readonly<{
136
144
  title?: readonly {
@@ -23,6 +23,8 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
23
23
  message: string;
24
24
  }[] | undefined;
25
25
  icon?: string | undefined;
26
+ hidden?: string | undefined;
27
+ disabled?: string | undefined;
26
28
  variant?: "default" | "destructive" | "primary" | "ghost" | undefined;
27
29
  size?: "default" | "sm" | "xs" | undefined;
28
30
  hideTitle?: boolean | undefined;
@@ -56,6 +58,8 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
56
58
  message: string;
57
59
  }[] | undefined;
58
60
  icon?: string | undefined;
61
+ hidden?: string | undefined;
62
+ disabled?: string | undefined;
59
63
  variant?: "default" | "destructive" | "primary" | "ghost" | undefined;
60
64
  modal?: Readonly<{
61
65
  title?: readonly {
@@ -98,6 +102,8 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
98
102
  message: string;
99
103
  }[] | undefined;
100
104
  icon?: string | undefined;
105
+ hidden?: string | undefined;
106
+ disabled?: string | undefined;
101
107
  variant?: "default" | "destructive" | "primary" | "ghost" | undefined;
102
108
  size?: "default" | "sm" | "xs" | undefined;
103
109
  hideTitle?: boolean | undefined;
@@ -131,6 +137,8 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
131
137
  message: string;
132
138
  }[] | undefined;
133
139
  icon?: string | undefined;
140
+ hidden?: string | undefined;
141
+ disabled?: string | undefined;
134
142
  variant?: "default" | "destructive" | "primary" | "ghost" | undefined;
135
143
  modal?: Readonly<{
136
144
  title?: readonly {
@@ -22,6 +22,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
22
22
  message: string;
23
23
  }[] | undefined;
24
24
  icon?: string | undefined;
25
+ hidden?: string | undefined;
26
+ disabled?: string | undefined;
25
27
  variant?: "default" | "destructive" | "primary" | "ghost" | undefined;
26
28
  size?: "default" | "sm" | "xs" | undefined;
27
29
  hideTitle?: boolean | undefined;
@@ -55,6 +57,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
55
57
  message: string;
56
58
  }[] | undefined;
57
59
  icon?: string | undefined;
60
+ hidden?: string | undefined;
61
+ disabled?: string | undefined;
58
62
  variant?: "default" | "destructive" | "primary" | "ghost" | undefined;
59
63
  modal?: Readonly<{
60
64
  title?: readonly {
@@ -96,6 +100,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
96
100
  message: string;
97
101
  }[] | undefined;
98
102
  icon?: string | undefined;
103
+ hidden?: string | undefined;
104
+ disabled?: string | undefined;
99
105
  variant?: "default" | "destructive" | "primary" | "ghost" | undefined;
100
106
  size?: "default" | "sm" | "xs" | undefined;
101
107
  hideTitle?: boolean | undefined;
@@ -129,6 +135,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
129
135
  message: string;
130
136
  }[] | undefined;
131
137
  icon?: string | undefined;
138
+ hidden?: string | undefined;
139
+ disabled?: string | undefined;
132
140
  variant?: "default" | "destructive" | "primary" | "ghost" | undefined;
133
141
  modal?: Readonly<{
134
142
  title?: readonly {
@@ -6,6 +6,7 @@ import z from "zod";
6
6
  import { computed, nextTick, ref, watch } from "vue";
7
7
  import { useI18n } from "vue-i18n";
8
8
  import { cn } from "../../../utils/cn";
9
+ import { expressionC } from "../../../utils/coders";
9
10
  import { Button } from "../button";
10
11
  import {
11
12
  ButtonBodyC,
@@ -54,6 +55,7 @@ const draftTree = ref(buildButtonConfiguratorTree(props.config.groups));
54
55
  const sortableListRef = ref(null);
55
56
  const sortableItemIds = ref([]);
56
57
  const validationErrors = ref({});
58
+ const buttonStateExpressionC = expressionC("bool").optional();
57
59
  const sortable = useSortable(sortableListRef, sortableItemIds);
58
60
  function handleSortableUpdate(event) {
59
61
  if (event.oldIndex === void 0 || event.newIndex === void 0 || event.oldIndex === event.newIndex) {
@@ -382,6 +384,38 @@ function updateSelectedTooltip(value) {
382
384
  };
383
385
  });
384
386
  }
387
+ function updateSelectedHidden(value) {
388
+ const node = selectedNode.value;
389
+ if (!node || node.item.type !== "button") {
390
+ return;
391
+ }
392
+ clearNodeError(node.itemId, "hidden");
393
+ draftTree.value = updateButtonConfiguratorNode(draftTree.value, node.itemId, (item) => {
394
+ if (item.type !== "button") {
395
+ return item;
396
+ }
397
+ return {
398
+ ...item,
399
+ hidden: normalizeOptionalString(String(value))
400
+ };
401
+ });
402
+ }
403
+ function updateSelectedDisabled(value) {
404
+ const node = selectedNode.value;
405
+ if (!node || node.item.type !== "button") {
406
+ return;
407
+ }
408
+ clearNodeError(node.itemId, "disabled");
409
+ draftTree.value = updateButtonConfiguratorNode(draftTree.value, node.itemId, (item) => {
410
+ if (item.type !== "button") {
411
+ return item;
412
+ }
413
+ return {
414
+ ...item,
415
+ disabled: normalizeOptionalString(String(value))
416
+ };
417
+ });
418
+ }
385
419
  function updateSelectedIcon(value) {
386
420
  const node = selectedNode.value;
387
421
  if (!node) {
@@ -409,6 +443,12 @@ function updateSelectedIcon(value) {
409
443
  if (item.tooltip) {
410
444
  nextItem2.tooltip = item.tooltip;
411
445
  }
446
+ if (item.hidden) {
447
+ nextItem2.hidden = item.hidden;
448
+ }
449
+ if (item.disabled) {
450
+ nextItem2.disabled = item.disabled;
451
+ }
412
452
  if (value) {
413
453
  nextItem2.icon = value;
414
454
  }
@@ -501,6 +541,8 @@ function updateSelectedHideTitle(value) {
501
541
  title: item.title,
502
542
  tooltip: item.tooltip,
503
543
  icon: item.icon,
544
+ hidden: item.hidden,
545
+ disabled: item.disabled,
504
546
  variant: item.variant,
505
547
  size: item.size
506
548
  };
@@ -623,6 +665,36 @@ function validateEditableNodeIds() {
623
665
  }
624
666
  return false;
625
667
  }
668
+ function validateButtonExpressions() {
669
+ const errors = {};
670
+ let firstInvalidItemId;
671
+ for (const node of draftTree.value.nodes) {
672
+ if (node.item.type !== "button") {
673
+ continue;
674
+ }
675
+ const hiddenResult = buttonStateExpressionC.safeParse(node.item.hidden);
676
+ if (!hiddenResult.success) {
677
+ errors[getNodeErrorKey(node.itemId, "hidden")] = hiddenResult.error.issues[0]?.message ?? t("button-hidden-invalid");
678
+ firstInvalidItemId = firstInvalidItemId ?? node.itemId;
679
+ }
680
+ const disabledResult = buttonStateExpressionC.safeParse(node.item.disabled);
681
+ if (!disabledResult.success) {
682
+ errors[getNodeErrorKey(node.itemId, "disabled")] = disabledResult.error.issues[0]?.message ?? t("button-disabled-invalid");
683
+ firstInvalidItemId = firstInvalidItemId ?? node.itemId;
684
+ }
685
+ }
686
+ if (Object.keys(errors).length === 0) {
687
+ return true;
688
+ }
689
+ validationErrors.value = {
690
+ ...validationErrors.value,
691
+ ...errors
692
+ };
693
+ if (firstInvalidItemId) {
694
+ selectedItemId.value = firstInvalidItemId;
695
+ }
696
+ return false;
697
+ }
626
698
  function buildDraftConfig() {
627
699
  const generalStyleResult = ButtonsStyleC.safeParse(draftStyle.value);
628
700
  if (!generalStyleResult.success) {
@@ -636,6 +708,9 @@ function buildDraftConfig() {
636
708
  if (!validateEditableNodeIds()) {
637
709
  return;
638
710
  }
711
+ if (!validateButtonExpressions()) {
712
+ return;
713
+ }
639
714
  const bodyResult = ButtonBodyC.safeParse({
640
715
  gap: draftGap.value,
641
716
  style: generalStyleResult.data,
@@ -1147,6 +1222,44 @@ function confirmChanges() {
1147
1222
  />
1148
1223
  </label>
1149
1224
 
1225
+ <label class="flex flex-col gap-2">
1226
+ <span class="text-xs font-medium text-zinc-500">{{ t("button-hidden") }}</span>
1227
+ <Textarea
1228
+ data-slot="button-configurator-button-hidden"
1229
+ :model-value="selectedButton.hidden ?? ''"
1230
+ :aria-invalid="validationErrors[getNodeErrorKey(selectedItemId, 'hidden')] ? 'true' : void 0"
1231
+ :placeholder="t('button-hidden-placeholder')"
1232
+ class="min-h-20 font-mono text-sm"
1233
+ @update:model-value="updateSelectedHidden"
1234
+ />
1235
+ <p
1236
+ v-if="validationErrors[getNodeErrorKey(selectedItemId, 'hidden')]"
1237
+ data-slot="button-configurator-button-hidden-error"
1238
+ class="text-xs text-red-500"
1239
+ >
1240
+ {{ validationErrors[getNodeErrorKey(selectedItemId, "hidden")] }}
1241
+ </p>
1242
+ </label>
1243
+
1244
+ <label class="flex flex-col gap-2">
1245
+ <span class="text-xs font-medium text-zinc-500">{{ t("button-disabled") }}</span>
1246
+ <Textarea
1247
+ data-slot="button-configurator-button-disabled"
1248
+ :model-value="selectedButton.disabled ?? ''"
1249
+ :aria-invalid="validationErrors[getNodeErrorKey(selectedItemId, 'disabled')] ? 'true' : void 0"
1250
+ :placeholder="t('button-disabled-placeholder')"
1251
+ class="min-h-20 font-mono text-sm"
1252
+ @update:model-value="updateSelectedDisabled"
1253
+ />
1254
+ <p
1255
+ v-if="validationErrors[getNodeErrorKey(selectedItemId, 'disabled')]"
1256
+ data-slot="button-configurator-button-disabled-error"
1257
+ class="text-xs text-red-500"
1258
+ >
1259
+ {{ validationErrors[getNodeErrorKey(selectedItemId, "disabled")] }}
1260
+ </p>
1261
+ </label>
1262
+
1150
1263
  <label
1151
1264
  v-if="selectedButtonIsInGroup"
1152
1265
  class="flex flex-col gap-2"
@@ -1443,6 +1556,12 @@ function confirmChanges() {
1443
1556
  "button-size-sm": "小",
1444
1557
  "button-size-xs": "超小",
1445
1558
  "button-parent": "所属容器",
1559
+ "button-hidden": "隐藏条件",
1560
+ "button-hidden-placeholder": "返回 true 时隐藏按钮",
1561
+ "button-hidden-invalid": "隐藏条件无效",
1562
+ "button-disabled": "禁用条件",
1563
+ "button-disabled-placeholder": "返回 true 时禁用按钮",
1564
+ "button-disabled-invalid": "禁用条件无效",
1446
1565
  "button-hide-title": "隐藏文字,仅显示图标",
1447
1566
  "dropdown-title": "下拉名称",
1448
1567
  "dropdown-icon": "下拉图标",
@@ -1509,6 +1628,12 @@ function confirmChanges() {
1509
1628
  "button-size-sm": "Small",
1510
1629
  "button-size-xs": "Extra small",
1511
1630
  "button-parent": "Parent container",
1631
+ "button-hidden": "Hidden condition",
1632
+ "button-hidden-placeholder": "Hide the button when the expression returns true",
1633
+ "button-hidden-invalid": "The hidden condition is invalid",
1634
+ "button-disabled": "Disabled condition",
1635
+ "button-disabled-placeholder": "Disable the button when the expression returns true",
1636
+ "button-disabled-invalid": "The disabled condition is invalid",
1512
1637
  "button-hide-title": "Hide text and show icon only",
1513
1638
  "dropdown-title": "Dropdown title",
1514
1639
  "dropdown-icon": "Dropdown icon",
@@ -1575,6 +1700,12 @@ function confirmChanges() {
1575
1700
  "button-size-sm": "小",
1576
1701
  "button-size-xs": "極小",
1577
1702
  "button-parent": "親コンテナ",
1703
+ "button-hidden": "非表示条件",
1704
+ "button-hidden-placeholder": "true を返すとボタンを非表示にします",
1705
+ "button-hidden-invalid": "非表示条件が無効です",
1706
+ "button-disabled": "無効化条件",
1707
+ "button-disabled-placeholder": "true を返すとボタンを無効化します",
1708
+ "button-disabled-invalid": "無効化条件が無効です",
1578
1709
  "button-hide-title": "テキストを隠してアイコンのみ表示",
1579
1710
  "dropdown-title": "ドロップダウン名",
1580
1711
  "dropdown-icon": "ドロップダウンアイコン",
@@ -1641,6 +1772,12 @@ function confirmChanges() {
1641
1772
  "button-size-sm": "작게",
1642
1773
  "button-size-xs": "매우 작게",
1643
1774
  "button-parent": "부모 컨테이너",
1775
+ "button-hidden": "숨김 조건",
1776
+ "button-hidden-placeholder": "true 를 반환하면 버튼을 숨깁니다",
1777
+ "button-hidden-invalid": "숨김 조건이 올바르지 않습니다",
1778
+ "button-disabled": "비활성화 조건",
1779
+ "button-disabled-placeholder": "true 를 반환하면 버튼을 비활성화합니다",
1780
+ "button-disabled-invalid": "비활성화 조건이 올바르지 않습니다",
1644
1781
  "button-hide-title": "텍스트를 숨기고 아이콘만 표시",
1645
1782
  "dropdown-title": "드롭다운 이름",
1646
1783
  "dropdown-icon": "드롭다운 아이콘",
@@ -22,6 +22,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
22
22
  message: string;
23
23
  }[] | undefined;
24
24
  icon?: string | undefined;
25
+ hidden?: string | undefined;
26
+ disabled?: string | undefined;
25
27
  variant?: "default" | "destructive" | "primary" | "ghost" | undefined;
26
28
  size?: "default" | "sm" | "xs" | undefined;
27
29
  hideTitle?: boolean | undefined;
@@ -55,6 +57,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
55
57
  message: string;
56
58
  }[] | undefined;
57
59
  icon?: string | undefined;
60
+ hidden?: string | undefined;
61
+ disabled?: string | undefined;
58
62
  variant?: "default" | "destructive" | "primary" | "ghost" | undefined;
59
63
  modal?: Readonly<{
60
64
  title?: readonly {
@@ -96,6 +100,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
96
100
  message: string;
97
101
  }[] | undefined;
98
102
  icon?: string | undefined;
103
+ hidden?: string | undefined;
104
+ disabled?: string | undefined;
99
105
  variant?: "default" | "destructive" | "primary" | "ghost" | undefined;
100
106
  size?: "default" | "sm" | "xs" | undefined;
101
107
  hideTitle?: boolean | undefined;
@@ -129,6 +135,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
129
135
  message: string;
130
136
  }[] | undefined;
131
137
  icon?: string | undefined;
138
+ hidden?: string | undefined;
139
+ disabled?: string | undefined;
132
140
  variant?: "default" | "destructive" | "primary" | "ghost" | undefined;
133
141
  modal?: Readonly<{
134
142
  title?: readonly {
@@ -11,6 +11,8 @@ export type ButtonConfiguratorDraftNodeData = Readonly<{
11
11
  title: LocaleValue;
12
12
  tooltip?: LocaleValue;
13
13
  icon?: string;
14
+ hidden?: string;
15
+ disabled?: string;
14
16
  variant?: ButtonAction['variant'];
15
17
  size?: ButtonAction['size'];
16
18
  hideTitle?: boolean;
@@ -47,6 +47,12 @@ function stripButton(button) {
47
47
  if (button.icon) {
48
48
  nextItem.icon = button.icon;
49
49
  }
50
+ if (button.hidden) {
51
+ nextItem.hidden = button.hidden;
52
+ }
53
+ if (button.disabled) {
54
+ nextItem.disabled = button.disabled;
55
+ }
50
56
  if (button.variant) {
51
57
  nextItem.variant = button.variant;
52
58
  }
@@ -325,6 +331,12 @@ export function materializeButtonConfiguratorTree(tree) {
325
331
  if (node.item.tooltip) {
326
332
  nextButton.tooltip = node.item.tooltip;
327
333
  }
334
+ if (node.item.hidden) {
335
+ nextButton.hidden = node.item.hidden;
336
+ }
337
+ if (node.item.disabled) {
338
+ nextButton.disabled = node.item.disabled;
339
+ }
328
340
  const parentNode = node.parentItemId ? getButtonConfiguratorNode(tree, node.parentItemId) : void 0;
329
341
  if (parentNode?.item.type === "group") {
330
342
  if (node.item.hideTitle) {
@@ -350,6 +362,8 @@ export function materializeButtonConfiguratorTree(tree) {
350
362
  title: button.title,
351
363
  tooltip: button.tooltip,
352
364
  icon: button.icon,
365
+ hidden: button.hidden,
366
+ disabled: button.disabled,
353
367
  variant: button.variant
354
368
  }] : [];
355
369
  })
@@ -24,6 +24,8 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
24
24
  message: string;
25
25
  }[] | undefined;
26
26
  icon?: string | undefined;
27
+ hidden?: string | undefined;
28
+ disabled?: string | undefined;
27
29
  variant?: "default" | "destructive" | "primary" | "ghost" | undefined;
28
30
  size?: "default" | "sm" | "xs" | undefined;
29
31
  hideTitle?: boolean | undefined;
@@ -57,6 +59,8 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
57
59
  message: string;
58
60
  }[] | undefined;
59
61
  icon?: string | undefined;
62
+ hidden?: string | undefined;
63
+ disabled?: string | undefined;
60
64
  variant?: "default" | "destructive" | "primary" | "ghost" | undefined;
61
65
  modal?: Readonly<{
62
66
  title?: readonly {
@@ -99,6 +103,8 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
99
103
  message: string;
100
104
  }[] | undefined;
101
105
  icon?: string | undefined;
106
+ hidden?: string | undefined;
107
+ disabled?: string | undefined;
102
108
  variant?: "default" | "destructive" | "primary" | "ghost" | undefined;
103
109
  size?: "default" | "sm" | "xs" | undefined;
104
110
  hideTitle?: boolean | undefined;
@@ -132,6 +138,8 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
132
138
  message: string;
133
139
  }[] | undefined;
134
140
  icon?: string | undefined;
141
+ hidden?: string | undefined;
142
+ disabled?: string | undefined;
135
143
  variant?: "default" | "destructive" | "primary" | "ghost" | undefined;
136
144
  modal?: Readonly<{
137
145
  title?: readonly {
@@ -13,7 +13,7 @@ import {
13
13
  provideOverlay,
14
14
  useOverlay
15
15
  } from "../../../composables/useOverlay";
16
- import { useCELContext } from "../../../plugins/cel/context";
16
+ import { mergeDslContexts, useCELContext } from "../../../plugins/cel/context";
17
17
  import { getLocalizedText, hasVisibleLocaleValue } from "../../../utils/coders";
18
18
  import { cn } from "../../../utils/cn";
19
19
  import ButtonConfiguratorDialog from "../button-configurator/ButtonConfiguratorDialog.vue";
@@ -174,7 +174,7 @@ function getConfigStyle(config) {
174
174
  if (!config.style) {
175
175
  return style;
176
176
  }
177
- const styleMap = $dsl.evaluate`${config.style}`();
177
+ const styleMap = evaluateExpression(config.style, void 0, {});
178
178
  if (!styleMap || typeof styleMap !== "object" || Array.isArray(styleMap)) {
179
179
  return style;
180
180
  }
@@ -222,11 +222,37 @@ function isEffectFactory(value) {
222
222
  function isPending(buttonId) {
223
223
  return pendingIds.value.includes(buttonId);
224
224
  }
225
- function isButtonDisabled(buttonId) {
226
- return isPending(buttonId) || !(isEffectValue(getButtonEffect(buttonId)) || isEffectFactory(getButtonEffect(buttonId)));
225
+ function tryEvaluateExpression(source, context) {
226
+ try {
227
+ return {
228
+ ok: true,
229
+ value: $dsl.evaluate`${source}`(mergeDslContexts(context, celContext))
230
+ };
231
+ } catch {
232
+ return {
233
+ ok: false
234
+ };
235
+ }
236
+ }
237
+ function evaluateExpression(source, context, fallback) {
238
+ const result = tryEvaluateExpression(source, context);
239
+ if (!result.ok) {
240
+ return fallback;
241
+ }
242
+ return result.value;
243
+ }
244
+ function isButtonHidden(button) {
245
+ return evaluateExpression(button.hidden ?? "false", void 0, false);
246
+ }
247
+ function isButtonDisabled(button) {
248
+ const effect = getButtonEffect(button.id);
249
+ return evaluateExpression(button.disabled ?? "false", void 0, false) || isPending(button.id) || !(isEffectValue(effect) || isEffectFactory(effect));
227
250
  }
228
251
  function isDropdownPending(dropdown) {
229
- return dropdown.items.some((item) => isPending(item.id));
252
+ return dropdown.items.some((item) => !isButtonHidden(item) && isPending(item.id));
253
+ }
254
+ function hasVisibleDropdownItems(dropdown) {
255
+ return dropdown.items.some((item) => !isButtonHidden(item));
230
256
  }
231
257
  function hasButtonTooltip(button) {
232
258
  return hasVisibleLocaleValue(button.tooltip);
@@ -383,11 +409,11 @@ export { ButtonActionService, currentButtonAction } from "../../../composables/u
383
409
  :key="item.id"
384
410
  >
385
411
  <Button
386
- v-if="!isDropdownItem(item) && !hasButtonTooltip(item)"
412
+ v-if="!isDropdownItem(item) && !isButtonHidden(item) && !hasButtonTooltip(item)"
387
413
  data-slot="buttons-item"
388
414
  :variant="getResolvedButtonVariant(group, item)"
389
415
  :size="getResolvedButtonSize(group, item)"
390
- :disabled="isButtonDisabled(item.id)"
416
+ :disabled="isButtonDisabled(item)"
391
417
  :class="hasLeadingPrimaryGap(group, itemIndex) ? 'ml-px' : void 0"
392
418
  :title="item.hideTitle ? getButtonLabel(item) : void 0"
393
419
  @click="void runButton(item.id)"
@@ -404,7 +430,7 @@ export { ButtonActionService, currentButtonAction } from "../../../composables/u
404
430
  </Button>
405
431
 
406
432
  <Tooltip
407
- v-else-if="!isDropdownItem(item)"
433
+ v-else-if="!isDropdownItem(item) && !isButtonHidden(item)"
408
434
  :delay-duration="180"
409
435
  >
410
436
  <TooltipTrigger as-child>
@@ -412,7 +438,7 @@ export { ButtonActionService, currentButtonAction } from "../../../composables/u
412
438
  data-slot="buttons-item"
413
439
  :variant="getResolvedButtonVariant(group, item)"
414
440
  :size="getResolvedButtonSize(group, item)"
415
- :disabled="isButtonDisabled(item.id)"
441
+ :disabled="isButtonDisabled(item)"
416
442
  :class="hasLeadingPrimaryGap(group, itemIndex) ? 'ml-px' : void 0"
417
443
  :title="item.hideTitle ? getButtonLabel(item) : void 0"
418
444
  @click="void runButton(item.id)"
@@ -437,7 +463,9 @@ export { ButtonActionService, currentButtonAction } from "../../../composables/u
437
463
  </TooltipContent>
438
464
  </Tooltip>
439
465
 
440
- <DropdownMenu v-else>
466
+ <DropdownMenu
467
+ v-else-if="isDropdownItem(item) && hasVisibleDropdownItems(item)"
468
+ >
441
469
  <DropdownMenuTrigger as-child>
442
470
  <Button
443
471
  data-slot="buttons-dropdown-trigger"
@@ -463,9 +491,9 @@ export { ButtonActionService, currentButtonAction } from "../../../composables/u
463
491
  :key="child.id"
464
492
  >
465
493
  <DropdownMenuItem
466
- v-if="!hasButtonTooltip(child)"
494
+ v-if="!isButtonHidden(child) && !hasButtonTooltip(child)"
467
495
  data-slot="buttons-dropdown-item"
468
- :disabled="isButtonDisabled(child.id)"
496
+ :disabled="isButtonDisabled(child)"
469
497
  @select="void runButton(child.id)"
470
498
  >
471
499
  <Icon
@@ -480,13 +508,13 @@ export { ButtonActionService, currentButtonAction } from "../../../composables/u
480
508
  </DropdownMenuItem>
481
509
 
482
510
  <Tooltip
483
- v-else
511
+ v-else-if="!isButtonHidden(child)"
484
512
  :delay-duration="180"
485
513
  >
486
514
  <TooltipTrigger as-child>
487
515
  <DropdownMenuItem
488
516
  data-slot="buttons-dropdown-item"
489
- :disabled="isButtonDisabled(child.id)"
517
+ :disabled="isButtonDisabled(child)"
490
518
  @select="void runButton(child.id)"
491
519
  >
492
520
  <Icon
@@ -24,6 +24,8 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
24
24
  message: string;
25
25
  }[] | undefined;
26
26
  icon?: string | undefined;
27
+ hidden?: string | undefined;
28
+ disabled?: string | undefined;
27
29
  variant?: "default" | "destructive" | "primary" | "ghost" | undefined;
28
30
  size?: "default" | "sm" | "xs" | undefined;
29
31
  hideTitle?: boolean | undefined;
@@ -57,6 +59,8 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
57
59
  message: string;
58
60
  }[] | undefined;
59
61
  icon?: string | undefined;
62
+ hidden?: string | undefined;
63
+ disabled?: string | undefined;
60
64
  variant?: "default" | "destructive" | "primary" | "ghost" | undefined;
61
65
  modal?: Readonly<{
62
66
  title?: readonly {
@@ -99,6 +103,8 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
99
103
  message: string;
100
104
  }[] | undefined;
101
105
  icon?: string | undefined;
106
+ hidden?: string | undefined;
107
+ disabled?: string | undefined;
102
108
  variant?: "default" | "destructive" | "primary" | "ghost" | undefined;
103
109
  size?: "default" | "sm" | "xs" | undefined;
104
110
  hideTitle?: boolean | undefined;
@@ -132,6 +138,8 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
132
138
  message: string;
133
139
  }[] | undefined;
134
140
  icon?: string | undefined;
141
+ hidden?: string | undefined;
142
+ disabled?: string | undefined;
135
143
  variant?: "default" | "destructive" | "primary" | "ghost" | undefined;
136
144
  modal?: Readonly<{
137
145
  title?: readonly {
@@ -48,6 +48,8 @@ export declare const ButtonActionC: z.ZodReadonly<z.ZodObject<{
48
48
  message: z.ZodString;
49
49
  }, z.core.$strip>>>>;
50
50
  icon: z.ZodOptional<z.ZodString>;
51
+ hidden: z.ZodOptional<z.ZodString>;
52
+ disabled: z.ZodOptional<z.ZodString>;
51
53
  variant: z.ZodOptional<z.ZodEnum<{
52
54
  default: "default";
53
55
  destructive: "destructive";
@@ -105,6 +107,8 @@ declare const DropdownButtonActionC: z.ZodReadonly<z.ZodObject<{
105
107
  message: z.ZodString;
106
108
  }, z.core.$strip>>>>;
107
109
  icon: z.ZodOptional<z.ZodString>;
110
+ hidden: z.ZodOptional<z.ZodString>;
111
+ disabled: z.ZodOptional<z.ZodString>;
108
112
  variant: z.ZodOptional<z.ZodEnum<{
109
113
  default: "default";
110
114
  destructive: "destructive";
@@ -168,6 +172,8 @@ export declare const ButtonDropdownC: z.ZodReadonly<z.ZodObject<{
168
172
  message: z.ZodString;
169
173
  }, z.core.$strip>>>>;
170
174
  icon: z.ZodOptional<z.ZodString>;
175
+ hidden: z.ZodOptional<z.ZodString>;
176
+ disabled: z.ZodOptional<z.ZodString>;
171
177
  variant: z.ZodOptional<z.ZodEnum<{
172
178
  default: "default";
173
179
  destructive: "destructive";
@@ -220,6 +226,8 @@ export declare const ButtonGroupItemC: z.ZodUnion<readonly [z.ZodReadonly<z.ZodO
220
226
  message: z.ZodString;
221
227
  }, z.core.$strip>>>>;
222
228
  icon: z.ZodOptional<z.ZodString>;
229
+ hidden: z.ZodOptional<z.ZodString>;
230
+ disabled: z.ZodOptional<z.ZodString>;
223
231
  variant: z.ZodOptional<z.ZodEnum<{
224
232
  default: "default";
225
233
  destructive: "destructive";
@@ -288,6 +296,8 @@ export declare const ButtonGroupItemC: z.ZodUnion<readonly [z.ZodReadonly<z.ZodO
288
296
  message: z.ZodString;
289
297
  }, z.core.$strip>>>>;
290
298
  icon: z.ZodOptional<z.ZodString>;
299
+ hidden: z.ZodOptional<z.ZodString>;
300
+ disabled: z.ZodOptional<z.ZodString>;
291
301
  variant: z.ZodOptional<z.ZodEnum<{
292
302
  default: "default";
293
303
  destructive: "destructive";
@@ -353,6 +363,8 @@ export declare const ButtonGroupC: z.ZodReadonly<z.ZodObject<{
353
363
  message: z.ZodString;
354
364
  }, z.core.$strip>>>>;
355
365
  icon: z.ZodOptional<z.ZodString>;
366
+ hidden: z.ZodOptional<z.ZodString>;
367
+ disabled: z.ZodOptional<z.ZodString>;
356
368
  variant: z.ZodOptional<z.ZodEnum<{
357
369
  default: "default";
358
370
  destructive: "destructive";
@@ -421,6 +433,8 @@ export declare const ButtonGroupC: z.ZodReadonly<z.ZodObject<{
421
433
  message: z.ZodString;
422
434
  }, z.core.$strip>>>>;
423
435
  icon: z.ZodOptional<z.ZodString>;
436
+ hidden: z.ZodOptional<z.ZodString>;
437
+ disabled: z.ZodOptional<z.ZodString>;
424
438
  variant: z.ZodOptional<z.ZodEnum<{
425
439
  default: "default";
426
440
  destructive: "destructive";
@@ -490,6 +504,8 @@ export declare const ButtonBodyC: z.ZodReadonly<z.ZodObject<{
490
504
  message: z.ZodString;
491
505
  }, z.core.$strip>>>>;
492
506
  icon: z.ZodOptional<z.ZodString>;
507
+ hidden: z.ZodOptional<z.ZodString>;
508
+ disabled: z.ZodOptional<z.ZodString>;
493
509
  variant: z.ZodOptional<z.ZodEnum<{
494
510
  default: "default";
495
511
  destructive: "destructive";
@@ -558,6 +574,8 @@ export declare const ButtonBodyC: z.ZodReadonly<z.ZodObject<{
558
574
  message: z.ZodString;
559
575
  }, z.core.$strip>>>>;
560
576
  icon: z.ZodOptional<z.ZodString>;
577
+ hidden: z.ZodOptional<z.ZodString>;
578
+ disabled: z.ZodOptional<z.ZodString>;
561
579
  variant: z.ZodOptional<z.ZodEnum<{
562
580
  default: "default";
563
581
  destructive: "destructive";
@@ -628,6 +646,8 @@ export declare const ButtonBodyInputC: z.ZodReadonly<z.ZodObject<{
628
646
  message: z.ZodString;
629
647
  }, z.core.$strip>>>>;
630
648
  icon: z.ZodOptional<z.ZodString>;
649
+ hidden: z.ZodOptional<z.ZodString>;
650
+ disabled: z.ZodOptional<z.ZodString>;
631
651
  variant: z.ZodOptional<z.ZodEnum<{
632
652
  default: "default";
633
653
  destructive: "destructive";
@@ -696,6 +716,8 @@ export declare const ButtonBodyInputC: z.ZodReadonly<z.ZodObject<{
696
716
  message: z.ZodString;
697
717
  }, z.core.$strip>>>>;
698
718
  icon: z.ZodOptional<z.ZodString>;
719
+ hidden: z.ZodOptional<z.ZodString>;
720
+ disabled: z.ZodOptional<z.ZodString>;
699
721
  variant: z.ZodOptional<z.ZodEnum<{
700
722
  default: "default";
701
723
  destructive: "destructive";
@@ -766,6 +788,8 @@ export declare const ButtonConfigC: z.ZodReadonly<z.ZodObject<{
766
788
  message: z.ZodString;
767
789
  }, z.core.$strip>>>>;
768
790
  icon: z.ZodOptional<z.ZodString>;
791
+ hidden: z.ZodOptional<z.ZodString>;
792
+ disabled: z.ZodOptional<z.ZodString>;
769
793
  variant: z.ZodOptional<z.ZodEnum<{
770
794
  default: "default";
771
795
  destructive: "destructive";
@@ -834,6 +858,8 @@ export declare const ButtonConfigC: z.ZodReadonly<z.ZodObject<{
834
858
  message: z.ZodString;
835
859
  }, z.core.$strip>>>>;
836
860
  icon: z.ZodOptional<z.ZodString>;
861
+ hidden: z.ZodOptional<z.ZodString>;
862
+ disabled: z.ZodOptional<z.ZodString>;
837
863
  variant: z.ZodOptional<z.ZodEnum<{
838
864
  default: "default";
839
865
  destructive: "destructive";
@@ -906,6 +932,8 @@ export declare const ButtonConfigInputC: z.ZodReadonly<z.ZodObject<{
906
932
  message: z.ZodString;
907
933
  }, z.core.$strip>>>>;
908
934
  icon: z.ZodOptional<z.ZodString>;
935
+ hidden: z.ZodOptional<z.ZodString>;
936
+ disabled: z.ZodOptional<z.ZodString>;
909
937
  variant: z.ZodOptional<z.ZodEnum<{
910
938
  default: "default";
911
939
  destructive: "destructive";
@@ -974,6 +1002,8 @@ export declare const ButtonConfigInputC: z.ZodReadonly<z.ZodObject<{
974
1002
  message: z.ZodString;
975
1003
  }, z.core.$strip>>>>;
976
1004
  icon: z.ZodOptional<z.ZodString>;
1005
+ hidden: z.ZodOptional<z.ZodString>;
1006
+ disabled: z.ZodOptional<z.ZodString>;
977
1007
  variant: z.ZodOptional<z.ZodEnum<{
978
1008
  default: "default";
979
1009
  destructive: "destructive";
@@ -9,6 +9,7 @@ export const SUPPORTED_COMPATIBILITY_DATES = [CURRENT_COMPATIBILITY_DATE];
9
9
  const buttonVariantC = z.enum(["default", "primary", "destructive", "ghost"]).optional().describe("\u6309\u94AE\u53D8\u4F53");
10
10
  const buttonSizeC = z.enum(["default", "sm", "xs"]).optional().describe("\u6309\u94AE\u5927\u5C0F");
11
11
  export const ButtonsStyleC = expressionC(/^map/).optional().describe("\u8FD4\u56DE\u6309\u94AE\u5BB9\u5668\u6837\u5F0F\u5BF9\u8C61\u7684 CEL \u8868\u8FBE\u5F0F");
12
+ const buttonStateExpressionC = expressionC("bool").optional();
12
13
  export const ButtonModalC = z.strictObject({
13
14
  title: localeC.optional().describe("Modal \u6807\u9898\u7684\u672C\u5730\u5316\u663E\u793A\u6587\u672C"),
14
15
  description: localeC.optional().describe("Modal \u63CF\u8FF0\u7684\u672C\u5730\u5316\u663E\u793A\u6587\u672C"),
@@ -21,6 +22,8 @@ export const ButtonActionC = z.strictObject({
21
22
  title: localeC.describe("\u6309\u94AE\u540D\u79F0\u7684\u672C\u5730\u5316\u663E\u793A\u6587\u672C"),
22
23
  tooltip: localeC.optional().describe("\u6309\u94AE\u63D0\u793A\u7684\u672C\u5730\u5316\u663E\u793A\u6587\u672C"),
23
24
  icon: z.string().optional().describe("Iconify \u56FE\u6807\u6807\u8BC6\u7B26"),
25
+ hidden: buttonStateExpressionC.describe("\u8FD4\u56DE true \u65F6\u9690\u85CF\u6309\u94AE\u7684 CEL \u8868\u8FBE\u5F0F"),
26
+ disabled: buttonStateExpressionC.describe("\u8FD4\u56DE true \u65F6\u7981\u7528\u6309\u94AE\u7684 CEL \u8868\u8FBE\u5F0F"),
24
27
  variant: buttonVariantC,
25
28
  size: buttonSizeC,
26
29
  hideTitle: z.boolean().optional().describe("\u4EC5\u5BF9\u975E\u4E0B\u62C9\u6309\u94AE\u751F\u6548\uFF1B\u4E3A true \u65F6\u9690\u85CF\u6309\u94AE\u6587\u5B57\uFF0C\u4EC5\u663E\u793A\u56FE\u6807"),
@@ -31,6 +34,8 @@ const DropdownButtonActionC = z.strictObject({
31
34
  title: localeC.describe("\u4E0B\u62C9\u9879\u6309\u94AE\u540D\u79F0\u7684\u672C\u5730\u5316\u663E\u793A\u6587\u672C"),
32
35
  tooltip: localeC.optional().describe("\u4E0B\u62C9\u9879\u6309\u94AE\u63D0\u793A\u7684\u672C\u5730\u5316\u663E\u793A\u6587\u672C"),
33
36
  icon: z.string().optional().describe("Iconify \u56FE\u6807\u6807\u8BC6\u7B26"),
37
+ hidden: buttonStateExpressionC.describe("\u8FD4\u56DE true \u65F6\u9690\u85CF\u4E0B\u62C9\u9879\u6309\u94AE\u7684 CEL \u8868\u8FBE\u5F0F"),
38
+ disabled: buttonStateExpressionC.describe("\u8FD4\u56DE true \u65F6\u7981\u7528\u4E0B\u62C9\u9879\u6309\u94AE\u7684 CEL \u8868\u8FBE\u5F0F"),
34
39
  variant: buttonVariantC,
35
40
  modal: ButtonModalC.optional().describe("\u4F9B\u5F53\u524D action \u7684 overlay \u58F0\u660E\u4F7F\u7528\u7684\u9ED8\u8BA4 Modal \u58F3\u914D\u7F6E")
36
41
  }).readonly();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shwfed/nuxt",
3
- "version": "0.11.49",
3
+ "version": "0.11.50",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "type": "module",