@alfakit/vue 0.1.9 → 0.1.10

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.
Files changed (122) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/app/components.d.ts.map +1 -1
  3. package/dist/app/components.js +1 -0
  4. package/dist/app/components.js.map +1 -1
  5. package/dist/components/dev-tools/DevToolsInspector.js.map +1 -1
  6. package/dist/components/dev-tools/DevToolsInspector.vue.d.ts.map +1 -1
  7. package/dist/components/dev-tools/DevToolsInspector.vue_vue_type_script_setup_true_lang.js +1 -1
  8. package/dist/components/dev-tools/DevToolsInspector.vue_vue_type_script_setup_true_lang.js.map +1 -1
  9. package/dist/components/fields/CheckboxListField.js.map +1 -1
  10. package/dist/components/fields/CheckboxListField.vue.d.ts.map +1 -1
  11. package/dist/components/fields/CheckboxListField.vue_vue_type_script_setup_true_lang.js +2 -2
  12. package/dist/components/fields/CheckboxListField.vue_vue_type_script_setup_true_lang.js.map +1 -1
  13. package/dist/components/fields/DatePickerField.js.map +1 -1
  14. package/dist/components/fields/DatePickerField.vue.d.ts.map +1 -1
  15. package/dist/components/fields/DatePickerField.vue_vue_type_script_setup_true_lang.js +34 -32
  16. package/dist/components/fields/DatePickerField.vue_vue_type_script_setup_true_lang.js.map +1 -1
  17. package/dist/components/fields/RichEditorSuggestions.js.map +1 -1
  18. package/dist/components/fields/RichEditorSuggestions.vue.d.ts +1 -1
  19. package/dist/components/fields/RichEditorSuggestions.vue.d.ts.map +1 -1
  20. package/dist/components/fields/RichEditorSuggestions.vue_vue_type_script_setup_true_lang.js +29 -23
  21. package/dist/components/fields/RichEditorSuggestions.vue_vue_type_script_setup_true_lang.js.map +1 -1
  22. package/dist/components/fields/RichEditorToolbarGroup.js.map +1 -1
  23. package/dist/components/fields/RichEditorToolbarGroup.vue.d.ts.map +1 -1
  24. package/dist/components/fields/RichEditorToolbarGroup.vue_vue_type_script_setup_true_lang.js +9 -4
  25. package/dist/components/fields/RichEditorToolbarGroup.vue_vue_type_script_setup_true_lang.js.map +1 -1
  26. package/dist/components/file-manager/FileManagerView.js.map +1 -1
  27. package/dist/components/file-manager/FileManagerView.vue.d.ts.map +1 -1
  28. package/dist/components/file-manager/FileManagerView.vue_vue_type_script_setup_true_lang.js +5 -1
  29. package/dist/components/file-manager/FileManagerView.vue_vue_type_script_setup_true_lang.js.map +1 -1
  30. package/dist/components/layout/CalloutComponent.js.map +1 -1
  31. package/dist/components/layout/CalloutComponent.vue.d.ts.map +1 -1
  32. package/dist/components/layout/CalloutComponent.vue_vue_type_script_setup_true_lang.js +43 -39
  33. package/dist/components/layout/CalloutComponent.vue_vue_type_script_setup_true_lang.js.map +1 -1
  34. package/dist/components/layout/EmptyStateComponent.js.map +1 -1
  35. package/dist/components/layout/EmptyStateComponent.vue.d.ts.map +1 -1
  36. package/dist/components/layout/EmptyStateComponent.vue_vue_type_script_setup_true_lang.js +29 -26
  37. package/dist/components/layout/EmptyStateComponent.vue_vue_type_script_setup_true_lang.js.map +1 -1
  38. package/dist/components/layout/MixedContent.js.map +1 -1
  39. package/dist/components/layout/MixedContent.vue.d.ts +5 -3
  40. package/dist/components/layout/MixedContent.vue.d.ts.map +1 -1
  41. package/dist/components/layout/MixedContent.vue_vue_type_script_setup_true_lang.js +5 -4
  42. package/dist/components/layout/MixedContent.vue_vue_type_script_setup_true_lang.js.map +1 -1
  43. package/dist/components/layout/SectionComponent.js.map +1 -1
  44. package/dist/components/layout/SectionComponent.vue.d.ts.map +1 -1
  45. package/dist/components/layout/SectionComponent.vue_vue_type_script_setup_true_lang.js +12 -8
  46. package/dist/components/layout/SectionComponent.vue_vue_type_script_setup_true_lang.js.map +1 -1
  47. package/dist/components/notifications/NotificationsMenu.js.map +1 -1
  48. package/dist/components/notifications/NotificationsMenu.vue.d.ts.map +1 -1
  49. package/dist/components/notifications/NotificationsMenu.vue_vue_type_script_setup_true_lang.js +133 -104
  50. package/dist/components/notifications/NotificationsMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
  51. package/dist/components/panel/ShortcutsOverlay.js.map +1 -1
  52. package/dist/components/panel/ShortcutsOverlay.vue.d.ts.map +1 -1
  53. package/dist/components/panel/ShortcutsOverlay.vue_vue_type_script_setup_true_lang.js +20 -19
  54. package/dist/components/panel/ShortcutsOverlay.vue_vue_type_script_setup_true_lang.js.map +1 -1
  55. package/dist/components/table/ColumnManager.js.map +1 -1
  56. package/dist/components/table/ColumnManager.vue.d.ts.map +1 -1
  57. package/dist/components/table/ColumnManager.vue_vue_type_script_setup_true_lang.js +6 -6
  58. package/dist/components/table/ColumnManager.vue_vue_type_script_setup_true_lang.js.map +1 -1
  59. package/dist/components/table/Spreadsheet.js.map +1 -1
  60. package/dist/components/table/Spreadsheet.vue.d.ts.map +1 -1
  61. package/dist/components/table/Spreadsheet.vue_vue_type_script_setup_true_lang.js +37 -33
  62. package/dist/components/table/Spreadsheet.vue_vue_type_script_setup_true_lang.js.map +1 -1
  63. package/dist/components/translation-manager/TranslationManagerView.js.map +1 -1
  64. package/dist/components/translation-manager/TranslationManagerView.vue.d.ts.map +1 -1
  65. package/dist/components/translation-manager/TranslationManagerView.vue_vue_type_script_setup_true_lang.js +1 -1
  66. package/dist/components/translation-manager/TranslationManagerView.vue_vue_type_script_setup_true_lang.js.map +1 -1
  67. package/dist/components/ui/SidebarMenuButton.js.map +1 -1
  68. package/dist/components/ui/SidebarMenuButton.vue.d.ts.map +1 -1
  69. package/dist/components/ui/SidebarMenuButton.vue_vue_type_script_setup_true_lang.js +12 -12
  70. package/dist/components/ui/SidebarMenuButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
  71. package/dist/components/widgets/StatCard.js.map +1 -1
  72. package/dist/components/widgets/StatCard.vue.d.ts.map +1 -1
  73. package/dist/components/widgets/StatCard.vue_vue_type_script_setup_true_lang.js +30 -30
  74. package/dist/components/widgets/StatCard.vue_vue_type_script_setup_true_lang.js.map +1 -1
  75. package/dist/eject-manifest.json +2 -2
  76. package/dist/pages/AlfakitPage.js.map +1 -1
  77. package/dist/pages/AlfakitPage.vue.d.ts.map +1 -1
  78. package/dist/pages/AlfakitPage.vue_vue_type_script_setup_true_lang.js +16 -19
  79. package/dist/pages/AlfakitPage.vue_vue_type_script_setup_true_lang.js.map +1 -1
  80. package/dist/standalone/AlfakitComponent.js.map +1 -1
  81. package/dist/standalone/AlfakitComponent.vue.d.ts.map +1 -1
  82. package/dist/standalone/AlfakitComponent.vue_vue_type_script_setup_true_lang.js +2 -2
  83. package/dist/standalone/AlfakitComponent.vue_vue_type_script_setup_true_lang.js.map +1 -1
  84. package/dist/standalone/runtime.d.ts.map +1 -1
  85. package/dist/standalone/runtime.js +25 -25
  86. package/dist/standalone/runtime.js.map +1 -1
  87. package/dist/standalone.css +2 -1
  88. package/dist/starter-kit/AlfakitStarterKitRoot.js.map +1 -1
  89. package/dist/starter-kit/AlfakitStarterKitRoot.vue.d.ts.map +1 -1
  90. package/dist/starter-kit/AlfakitStarterKitRoot.vue_vue_type_script_setup_true_lang.js +1 -1
  91. package/dist/starter-kit/AlfakitStarterKitRoot.vue_vue_type_script_setup_true_lang.js.map +1 -1
  92. package/dist/starter-kit/navigation.d.ts +6 -1
  93. package/dist/starter-kit/navigation.d.ts.map +1 -1
  94. package/dist/starter-kit/navigation.js +11 -10
  95. package/dist/starter-kit/navigation.js.map +1 -1
  96. package/dist/styles.css +2 -1
  97. package/dist/themes.css +4 -0
  98. package/package.json +2 -2
  99. package/src/app/components.ts +3 -0
  100. package/src/components/dev-tools/DevToolsInspector.vue +1 -1
  101. package/src/components/fields/CheckboxListField.vue +2 -2
  102. package/src/components/fields/DatePickerField.vue +1 -0
  103. package/src/components/fields/RichEditorSuggestions.vue +13 -6
  104. package/src/components/fields/RichEditorToolbarGroup.vue +16 -1
  105. package/src/components/file-manager/FileManagerView.vue +3 -1
  106. package/src/components/layout/CalloutComponent.vue +15 -2
  107. package/src/components/layout/EmptyStateComponent.vue +10 -1
  108. package/src/components/layout/MixedContent.vue +12 -4
  109. package/src/components/layout/SectionComponent.vue +20 -4
  110. package/src/components/notifications/NotificationsMenu.vue +45 -1
  111. package/src/components/panel/ShortcutsOverlay.vue +27 -22
  112. package/src/components/table/ColumnManager.vue +6 -4
  113. package/src/components/table/Spreadsheet.vue +9 -4
  114. package/src/components/translation-manager/TranslationManagerView.vue +1 -1
  115. package/src/components/ui/SidebarMenuButton.vue +6 -0
  116. package/src/components/widgets/StatCard.vue +6 -3
  117. package/src/pages/AlfakitPage.vue +13 -3
  118. package/src/standalone/AlfakitComponent.vue +8 -4
  119. package/src/standalone/runtime.ts +3 -0
  120. package/src/starter-kit/AlfakitStarterKitRoot.vue +3 -2
  121. package/src/starter-kit/navigation.ts +12 -1
  122. package/src/styles.css +2 -1
@@ -19,80 +19,80 @@ import { format as O, isValid as k, parse as A } from "date-fns";
19
19
  var ue = {
20
20
  key: 0,
21
21
  class: "border-t p-3"
22
- }, de = ["id"], fe = ["value"], j = () => import("../ui/Calendar.js").then((e) => e.default), M = c("AlfakitCalendar", j, x({
22
+ }, de = ["id"], fe = ["value"], j = () => import("../ui/Calendar.js").then((e) => e.default), pe = c("AlfakitCalendar", j, x({
23
23
  name: "AlfakitCalendarLoading",
24
24
  inheritAttrs: !1,
25
25
  render: () => S("div", {
26
26
  "aria-busy": "true",
27
27
  class: "h-[18.5rem] w-[15.5rem]"
28
28
  })
29
- })), N = /*@__PURE__*/ x({
29
+ })), M = /*@__PURE__*/ x({
30
30
  __name: "DatePickerField",
31
31
  props: { component: {} },
32
32
  setup(c) {
33
- let x = c, { value: S, setValue: N, blur: P, error: F, id: I, disabled: L, readOnly: R, aria: z } = o(() => x.component), B = se(!1), V = g(() => u(x.component.format)), pe = r(), H = e(), U = t(), me = n(), W = g(() => x.component.locale ?? me.value?.tag ?? "en"), he = g(() => x.component.locale ? new f(x.component.locale, U.value.currencyCode, U.value.timeZone) : U.value), G = g(() => x.component.datalist ? `${I}-list` : void 0), ge = (e) => x.component.displayFormat ? re(e, x.component.displayFormat, W.value) : he.value.date(e, {
33
+ let x = c, { value: S, setValue: M, blur: N, error: P, id: F, disabled: I, readOnly: L, aria: R } = o(() => x.component), z = se(!1), B = g(() => u(x.component.format)), V = r(), H = e(), U = t(), me = n(), W = g(() => x.component.locale ?? me.value?.tag ?? "en"), he = g(() => x.component.locale ? new f(x.component.locale, U.value.currencyCode, U.value.timeZone) : U.value), G = g(() => x.component.datalist ? `${F}-list` : void 0), ge = (e) => x.component.displayFormat ? re(e, x.component.displayFormat, W.value) : he.value.date(e, {
34
34
  ...x.component.hasDate ? { dateStyle: "medium" } : {},
35
35
  ...x.component.hasTime ? { timeStyle: "short" } : {},
36
36
  timeZone: void 0
37
- }), K = g(() => x.component.hasDate ? x.component.hasTime ? "datetime-local" : "date" : "time"), q = g(() => K.value === "time" ? x.component.hasSeconds ? "HH:mm:ss" : "HH:mm" : K.value === "datetime-local" ? x.component.hasSeconds ? "yyyy-MM-dd'T'HH:mm:ss" : "yyyy-MM-dd'T'HH:mm" : "yyyy-MM-dd"), J = g(() => S.value ? A(S.value, V.value, /* @__PURE__ */ new Date()) : null), Y = g(() => J.value && k(J.value) ? J.value : void 0), _e = g(() => Y.value ? O(Y.value, q.value) : S.value ?? "");
37
+ }), K = g(() => x.component.hasDate ? x.component.hasTime ? "datetime-local" : "date" : "time"), q = g(() => K.value === "time" ? x.component.hasSeconds ? "HH:mm:ss" : "HH:mm" : K.value === "datetime-local" ? x.component.hasSeconds ? "yyyy-MM-dd'T'HH:mm:ss" : "yyyy-MM-dd'T'HH:mm" : "yyyy-MM-dd"), J = g(() => S.value ? A(S.value, B.value, /* @__PURE__ */ new Date()) : null), Y = g(() => J.value && k(J.value) ? J.value : void 0), _e = g(() => Y.value ? O(Y.value, q.value) : S.value ?? "");
38
38
  function X(e) {
39
- let t = A(e, V.value, /* @__PURE__ */ new Date());
39
+ let t = A(e, B.value, /* @__PURE__ */ new Date());
40
40
  return k(t) ? O(t, q.value) : void 0;
41
41
  }
42
42
  function Z(e) {
43
- return A(e, V.value, /* @__PURE__ */ new Date());
43
+ return A(e, B.value, /* @__PURE__ */ new Date());
44
44
  }
45
45
  let ve = (e) => {
46
46
  if (e === "") {
47
- N(null);
47
+ M(null);
48
48
  return;
49
49
  }
50
50
  let t = A(e, q.value, /* @__PURE__ */ new Date());
51
- N(k(t) ? O(t, V.value) : e);
51
+ M(k(t) ? O(t, B.value) : e);
52
52
  }, Q = (e) => new D(e.getFullYear(), e.getMonth() + 1, e.getDate()), ye = g(() => Y.value ? Q(Y.value) : void 0), be = g(() => x.component.minDate ? Q(Z(x.component.minDate)) : void 0), xe = g(() => x.component.maxDate ? Q(Z(x.component.maxDate)) : void 0), Se = g(() => (x.component.disabledDates ?? []).map((e) => Q(Z(e)).toString())), Ce = (e) => Se.value.includes(e.toString()), we = g(() => {
53
53
  if (!x.component.defaultFocusedDate) return;
54
54
  let e = Z(x.component.defaultFocusedDate);
55
55
  return k(e) ? Q(e) : void 0;
56
56
  }), $ = g(() => p(x.component)), Te = (e) => {
57
57
  if (!e) {
58
- N(null);
58
+ M(null);
59
59
  return;
60
60
  }
61
61
  let t = Y.value, n = new Date(e.year, e.month - 1, e.day, t?.getHours() ?? 0, t?.getMinutes() ?? 0, t?.getSeconds() ?? 0);
62
- N(O(n, V.value)), x.component.closeOnDateSelection && !x.component.hasTime && (B.value = !1, P());
62
+ M(O(n, B.value)), x.component.closeOnDateSelection && !x.component.hasTime && (z.value = !1, N());
63
63
  }, Ee = g(() => Y.value ? O(Y.value, x.component.hasSeconds ? "HH:mm:ss" : "HH:mm") : ""), De = (e) => {
64
64
  let t = Y.value ?? m(x.component.timezone), [n = "0", r = "0", i = "0"] = e.split(":"), a = new Date(t.getFullYear(), t.getMonth(), t.getDate(), Number(n), Number(r), Number(i));
65
- N(O(a, V.value));
65
+ M(O(a, B.value));
66
66
  }, Oe = g(() => x.component.firstDayOfWeek ?? 1);
67
67
  return (e, t) => (C(), _(l, {
68
68
  field: x.component,
69
- "html-for": w(I),
70
- error: w(F)
69
+ "html-for": w(F),
70
+ error: w(P)
71
71
  }, {
72
72
  default: T(() => [b(d, {
73
73
  component: x.component,
74
- error: w(F)
74
+ error: w(P)
75
75
  }, {
76
76
  default: T(() => [x.component.native || !x.component.hasDate ? (C(), _(s, ae({
77
77
  key: 0,
78
- id: w(I),
78
+ id: w(F),
79
79
  type: K.value,
80
80
  name: x.component.name,
81
81
  "model-value": _e.value,
82
82
  step: $.value,
83
83
  min: x.component.minDate ? X(x.component.minDate) : void 0,
84
84
  max: x.component.maxDate ? X(x.component.maxDate) : void 0,
85
- disabled: w(L),
86
- readonly: w(R),
85
+ disabled: w(I),
86
+ readonly: w(L),
87
87
  required: x.component.required,
88
88
  lang: x.component.locale,
89
89
  list: G.value,
90
- "aria-invalid": w(z)["aria-invalid"],
91
- "aria-describedby": w(z)["aria-describedby"],
92
- "aria-required": w(z)["aria-required"]
90
+ "aria-invalid": w(R)["aria-invalid"],
91
+ "aria-describedby": w(R)["aria-describedby"],
92
+ "aria-required": w(R)["aria-required"]
93
93
  }, x.component.extraInputAttributes, {
94
94
  "onUpdate:modelValue": ve,
95
- onBlur: w(P)
95
+ onBlur: w(N)
96
96
  }), null, 16, [
97
97
  "id",
98
98
  "type",
@@ -112,23 +112,23 @@ var ue = {
112
112
  "onBlur"
113
113
  ])) : (C(), _(ee, {
114
114
  key: 1,
115
- open: B.value,
116
- "onUpdate:open": t[1] ||= (e) => B.value = e && !w(R)
115
+ open: z.value,
116
+ "onUpdate:open": t[1] ||= (e) => z.value = e && !w(L)
117
117
  }, {
118
118
  default: T(() => [b(ne, { "as-child": "" }, {
119
119
  default: T(() => [b(a, {
120
- id: w(I),
120
+ id: w(F),
121
121
  type: "button",
122
122
  "data-input": "",
123
123
  variant: "outline",
124
- disabled: w(L),
124
+ disabled: w(I),
125
125
  onPointerenter: j,
126
126
  onFocus: j,
127
- "aria-invalid": w(z)["aria-invalid"],
128
- "aria-describedby": w(z)["aria-describedby"],
129
- class: oe(w(i)("w-full justify-start font-normal", !Y.value && "text-muted-foreground", w(F) && "border-destructive"))
127
+ "aria-invalid": w(R)["aria-invalid"],
128
+ "aria-describedby": w(R)["aria-describedby"],
129
+ class: oe(w(i)("w-full justify-start font-normal", !Y.value && "text-muted-foreground", w(P) && "border-destructive"))
130
130
  }, {
131
- default: T(() => [b(w(E), { class: "size-4" }), ie(" " + le(Y.value ? ge(Y.value) : x.component.placeholder ?? w(pe)("form.pick_date", {}, "Pick a date")), 1)]),
131
+ default: T(() => [b(w(E), { class: "size-4" }), ie(" " + le(Y.value ? ge(Y.value) : x.component.placeholder ?? w(V)("form.pick_date", {}, "Pick a date")), 1)]),
132
132
  _: 1
133
133
  }, 8, [
134
134
  "id",
@@ -142,8 +142,9 @@ var ue = {
142
142
  class: "w-auto p-0",
143
143
  align: "start"
144
144
  }, {
145
- default: T(() => [b(w(M), {
145
+ default: T(() => [b(w(pe), {
146
146
  "model-value": ye.value,
147
+ "calendar-label": x.component.label || w(V)("form.pick_date", {}, "Pick a date"),
147
148
  locale: W.value,
148
149
  dir: w(H),
149
150
  today: Q(w(m)(x.component.timezone)),
@@ -156,6 +157,7 @@ var ue = {
156
157
  "onUpdate:modelValue": t[0] ||= (e) => Te(e)
157
158
  }, null, 8, [
158
159
  "model-value",
160
+ "calendar-label",
159
161
  "locale",
160
162
  "dir",
161
163
  "today",
@@ -168,7 +170,7 @@ var ue = {
168
170
  step: $.value,
169
171
  "model-value": Ee.value,
170
172
  "onUpdate:modelValue": De,
171
- onBlur: w(P)
173
+ onBlur: w(N)
172
174
  }, null, 8, [
173
175
  "step",
174
176
  "model-value",
@@ -195,6 +197,6 @@ var ue = {
195
197
  }
196
198
  });
197
199
  //#endregion
198
- export { N as default };
200
+ export { M as default };
199
201
 
200
202
  //# sourceMappingURL=DatePickerField.vue_vue_type_script_setup_true_lang.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DatePickerField.vue_vue_type_script_setup_true_lang.js","names":["format","formatDate","_openBlock","_createBlock","FieldWrapper","_unref","_withCtx","_createVNode","SelectAffixes","Input","_mergeProps","Popover","PopoverTrigger","Button","_normalizeClass","_createTextVNode","_toDisplayString","PopoverContent","_createElementBlock","_createCommentVNode","_Fragment","_renderList","Button_default","Input_default","Popover_default","PopoverContent_default","PopoverTrigger_default","FieldWrapper_default","SelectAffixes_default","_hoisted_1","_hoisted_2","_hoisted_3","loadCalendar","module","Calendar","lazyComponent","defineComponent","h","DatePickerField_vue_vue_type_script_setup_true_lang_default","props","__props","useField","open","ref","storageFormat","computed","phpToDateFnsFormat","t","useT","direction","useDirection","panelFormat","useFormatter","localization","useLocalization","locale","format$1","LocaleFormatter","listId","id","display","formatPhpDate","date","nativeType","nativeFormat","parsed","value","parse","selectedDate","isValid","nativeValue","format","toNative","raw","parseStored","onNativeInput","toCalendarDate","CalendarDate","calendarValue","minValue","maxValue","disabledDates","isDateDisabled","focusedPlaceholder","step","timeInputStep","onSelect","next","base","withTime","setValue","blur","timeValue","onTimeInput","wallClockNow","hours","minutes","seconds","weekStartsOn","openBlock","createBlock","unref","error","withCtx","createVNode","mergeProps","disabled","readOnly","aria","_cache","$event","normalizeClass","cn","CalendarIcon","createTextVNode","toDisplayString","createElementBlock","createCommentVNode","Fragment","renderList","option"],"sources":["../../../src/components/fields/DatePickerField.vue"],"sourcesContent":["<script lang=\"ts\">\nimport { defineComponent, h } from 'vue'\nimport { lazyComponent } from '../../lib/lazy'\n\n// The month grid (reka-ui) loads the first time a picker opens (or is hovered or focused),\n// not with the form.\nconst loadCalendar = () => import('../ui/Calendar.vue').then((module) => module.default)\nconst Calendar = lazyComponent(\n 'AlfakitCalendar',\n loadCalendar,\n defineComponent({\n name: 'AlfakitCalendarLoading',\n inheritAttrs: false,\n render: () => h('div', { 'aria-busy': 'true', class: 'h-[18.5rem] w-[15.5rem]' }),\n }),\n)\n</script>\n\n<script setup lang=\"ts\">\nimport {\n formatPhpDate,\n LocaleFormatter,\n timeInputStep,\n wallClockNow,\n type DatePickerSchema,\n} from '@alfakit/core'\nimport { CalendarDate, type DateValue } from '@internationalized/date'\nimport { CalendarIcon } from '@lucide/vue'\nimport { format as formatDate, isValid, parse } from 'date-fns'\nimport { computed, ref } from 'vue'\nimport { useDirection, useFormatter, useLocalization, useT } from '../../context'\nimport { cn } from '../../lib/utils'\nimport { useField } from '../form/form-context'\nimport FieldWrapper from '../schema/FieldWrapper.vue'\nimport Button from '../ui/Button.vue'\nimport Input from '../ui/Input.vue'\nimport Popover from '../ui/Popover.vue'\nimport PopoverContent from '../ui/PopoverContent.vue'\nimport PopoverTrigger from '../ui/PopoverTrigger.vue'\nimport { phpToDateFnsFormat } from './date-format'\nimport SelectAffixes from './SelectAffixes.vue'\n\nconst props = defineProps<{ component: DatePickerSchema }>()\nconst { value, setValue, blur, error, id, disabled, readOnly, aria } = useField<string | null>(\n () => props.component,\n)\nconst open = ref(false)\n\nconst storageFormat = computed(() => phpToDateFnsFormat(props.component.format))\nconst t = useT()\nconst direction = useDirection()\nconst panelFormat = useFormatter()\nconst localization = useLocalization()\n// `locale()` overrides the panel's language for this picker only.\nconst locale = computed(() => props.component.locale ?? localization.value?.tag ?? 'en')\nconst format = computed(() =>\n props.component.locale\n ? new LocaleFormatter(\n props.component.locale,\n panelFormat.value.currencyCode,\n panelFormat.value.timeZone,\n )\n : panelFormat.value,\n)\nconst listId = computed(() => (props.component.datalist ? `${id}-list` : undefined))\n\n// Month and weekday names come from Intl, so they follow the user's language.\nconst display = (date: Date): string =>\n props.component.displayFormat\n ? formatPhpDate(date, props.component.displayFormat, locale.value)\n : format.value.date(date, {\n ...(props.component.hasDate ? { dateStyle: 'medium' as const } : {}),\n ...(props.component.hasTime ? { timeStyle: 'short' as const } : {}),\n timeZone: undefined,\n })\n\nconst nativeType = computed(() =>\n !props.component.hasDate ? 'time' : props.component.hasTime ? 'datetime-local' : 'date',\n)\nconst nativeFormat = computed(() =>\n nativeType.value === 'time'\n ? props.component.hasSeconds\n ? 'HH:mm:ss'\n : 'HH:mm'\n : nativeType.value === 'datetime-local'\n ? props.component.hasSeconds\n ? \"yyyy-MM-dd'T'HH:mm:ss\"\n : \"yyyy-MM-dd'T'HH:mm\"\n : 'yyyy-MM-dd',\n)\n\nconst parsed = computed(() =>\n value.value ? parse(value.value, storageFormat.value, new Date()) : null,\n)\nconst selectedDate = computed(() =>\n parsed.value && isValid(parsed.value) ? parsed.value : undefined,\n)\nconst nativeValue = computed(() =>\n selectedDate.value ? formatDate(selectedDate.value, nativeFormat.value) : (value.value ?? ''),\n)\n\nfunction toNative(raw: string): string | undefined {\n const date = parse(raw, storageFormat.value, new Date())\n\n return isValid(date) ? formatDate(date, nativeFormat.value) : undefined\n}\n\nfunction parseStored(raw: string): Date {\n return parse(raw, storageFormat.value, new Date())\n}\n\nconst onNativeInput = (raw: string) => {\n if (raw === '') {\n setValue(null)\n\n return\n }\n\n const date = parse(raw, nativeFormat.value, new Date())\n setValue(isValid(date) ? formatDate(date, storageFormat.value) : raw)\n}\n\n// Calendar (reka-ui) works with @internationalized/date values.\nconst toCalendarDate = (date: Date): CalendarDate =>\n new CalendarDate(date.getFullYear(), date.getMonth() + 1, date.getDate())\nconst calendarValue = computed(() =>\n selectedDate.value ? toCalendarDate(selectedDate.value) : undefined,\n)\nconst minValue = computed(() =>\n props.component.minDate ? toCalendarDate(parseStored(props.component.minDate)) : undefined,\n)\nconst maxValue = computed(() =>\n props.component.maxDate ? toCalendarDate(parseStored(props.component.maxDate)) : undefined,\n)\nconst disabledDates = computed(() =>\n (props.component.disabledDates ?? []).map((date) => toCalendarDate(parseStored(date)).toString()),\n)\nconst isDateDisabled = (date: DateValue) => disabledDates.value.includes(date.toString())\n// `defaultFocusedDate()`: the month the calendar opens on while the field is empty.\nconst focusedPlaceholder = computed(() => {\n if (!props.component.defaultFocusedDate) return undefined\n\n const date = parseStored(props.component.defaultFocusedDate)\n\n return isValid(date) ? toCalendarDate(date) : undefined\n})\nconst step = computed(() => timeInputStep(props.component))\n\nconst onSelect = (next: DateValue | undefined) => {\n if (!next) {\n setValue(null)\n\n return\n }\n\n const base = selectedDate.value\n const withTime = new Date(\n next.year,\n next.month - 1,\n next.day,\n base?.getHours() ?? 0,\n base?.getMinutes() ?? 0,\n base?.getSeconds() ?? 0,\n )\n setValue(formatDate(withTime, storageFormat.value))\n\n if (props.component.closeOnDateSelection && !props.component.hasTime) {\n open.value = false\n blur()\n }\n}\n\nconst timeValue = computed(() =>\n selectedDate.value\n ? formatDate(selectedDate.value, props.component.hasSeconds ? 'HH:mm:ss' : 'HH:mm')\n : '',\n)\n\nconst onTimeInput = (raw: string) => {\n const base = selectedDate.value ?? wallClockNow(props.component.timezone)\n const [hours = '0', minutes = '0', seconds = '0'] = raw.split(':')\n const next = new Date(\n base.getFullYear(),\n base.getMonth(),\n base.getDate(),\n Number(hours),\n Number(minutes),\n Number(seconds),\n )\n setValue(formatDate(next, storageFormat.value))\n}\n\n// Kept out of the template: a `|` union there is parsed as a (removed) Vue 2 filter.\nconst weekStartsOn = computed(\n () => (props.component.firstDayOfWeek ?? 1) as 0 | 1 | 2 | 3 | 4 | 5 | 6,\n)\n</script>\n\n<template>\n <FieldWrapper :field=\"props.component\" :html-for=\"id\" :error=\"error\">\n <SelectAffixes :component=\"props.component\" :error=\"error\">\n <Input\n v-if=\"props.component.native || !props.component.hasDate\"\n :id=\"id\"\n :type=\"nativeType\"\n :name=\"props.component.name\"\n :model-value=\"nativeValue\"\n :step=\"step\"\n :min=\"props.component.minDate ? toNative(props.component.minDate) : undefined\"\n :max=\"props.component.maxDate ? toNative(props.component.maxDate) : undefined\"\n :disabled=\"disabled\"\n :readonly=\"readOnly\"\n :required=\"props.component.required\"\n :lang=\"props.component.locale\"\n :list=\"listId\"\n :aria-invalid=\"aria['aria-invalid']\"\n :aria-describedby=\"aria['aria-describedby']\"\n :aria-required=\"aria['aria-required']\"\n v-bind=\"props.component.extraInputAttributes\"\n @update:model-value=\"onNativeInput\"\n @blur=\"blur\"\n />\n <Popover v-else :open=\"open\" @update:open=\"open = $event && !readOnly\">\n <PopoverTrigger as-child>\n <Button\n :id=\"id\"\n type=\"button\"\n data-input=\"\"\n variant=\"outline\"\n :disabled=\"disabled\"\n @pointerenter=\"loadCalendar\"\n @focus=\"loadCalendar\"\n :aria-invalid=\"aria['aria-invalid']\"\n :aria-describedby=\"aria['aria-describedby']\"\n :class=\"\n cn(\n 'w-full justify-start font-normal',\n !selectedDate && 'text-muted-foreground',\n error && 'border-destructive',\n )\n \"\n >\n <CalendarIcon class=\"size-4\" />\n {{\n selectedDate\n ? display(selectedDate)\n : (props.component.placeholder ?? t('form.pick_date', {}, 'Pick a date'))\n }}\n </Button>\n </PopoverTrigger>\n <PopoverContent class=\"w-auto p-0\" align=\"start\">\n <Calendar\n :model-value=\"calendarValue\"\n :locale=\"locale\"\n :dir=\"direction\"\n :today=\"toCalendarDate(wallClockNow(props.component.timezone))\"\n :week-starts-on=\"weekStartsOn\"\n :min-value=\"minValue\"\n :max-value=\"maxValue\"\n :default-placeholder=\"focusedPlaceholder\"\n :is-date-disabled=\"isDateDisabled\"\n initial-focus\n @update:model-value=\"onSelect($event as DateValue | undefined)\"\n />\n <div v-if=\"props.component.hasTime\" class=\"border-t p-3\">\n <Input\n type=\"time\"\n :step=\"step\"\n :model-value=\"timeValue\"\n @update:model-value=\"onTimeInput\"\n @blur=\"blur\"\n />\n </div>\n </PopoverContent>\n </Popover>\n <datalist\n v-if=\"(props.component.native || !props.component.hasDate) && props.component.datalist\"\n :id=\"listId\"\n >\n <option\n v-for=\"option in props.component.datalist\"\n :key=\"option\"\n :value=\"toNative(option) ?? option\"\n />\n </datalist>\n </SelectAffixes>\n </FieldWrapper>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;gCAMMgC,UAAqB,OAAO,oBAAqB,CAAC,MAAM,MAAWC,EAAO,OAAO,GACjFC,IAAWC,EACf,mBACAH,GACAI,EAAgB;CACd,MAAM;CACN,cAAc;CACd,cAAcC,EAAE,OAAO;EAAE,aAAa;EAAQ,OAAO;CAA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EAAA,EAAA,GAAAgB,EAIEE,GAAA,MAAAC,GAHiBkB,EAAM,UAAU,WAA1B,OADTrC,EAAA,GAAAgB,EAIE,UAAA;KAFC,KAAKsG;KACL,OAAOhD,EAASgD,CAAM,KAAKA"}
1
+ {"version":3,"file":"DatePickerField.vue_vue_type_script_setup_true_lang.js","names":["format","formatDate","_openBlock","_createBlock","FieldWrapper","_unref","_withCtx","_createVNode","SelectAffixes","Input","_mergeProps","Popover","PopoverTrigger","Button","_normalizeClass","_createTextVNode","_toDisplayString","PopoverContent","_createElementBlock","_createCommentVNode","_Fragment","_renderList","Button_default","Input_default","Popover_default","PopoverContent_default","PopoverTrigger_default","FieldWrapper_default","SelectAffixes_default","_hoisted_1","_hoisted_2","_hoisted_3","loadCalendar","module","Calendar","lazyComponent","defineComponent","h","DatePickerField_vue_vue_type_script_setup_true_lang_default","props","__props","useField","open","ref","storageFormat","computed","phpToDateFnsFormat","t","useT","direction","useDirection","panelFormat","useFormatter","localization","useLocalization","locale","format$1","LocaleFormatter","listId","id","display","formatPhpDate","date","nativeType","nativeFormat","parsed","value","parse","selectedDate","isValid","nativeValue","format","toNative","raw","parseStored","onNativeInput","toCalendarDate","CalendarDate","calendarValue","minValue","maxValue","disabledDates","isDateDisabled","focusedPlaceholder","step","timeInputStep","onSelect","next","base","withTime","setValue","blur","timeValue","onTimeInput","wallClockNow","hours","minutes","seconds","weekStartsOn","openBlock","createBlock","unref","error","withCtx","createVNode","mergeProps","disabled","readOnly","aria","_cache","$event","normalizeClass","cn","CalendarIcon","createTextVNode","toDisplayString","createElementBlock","createCommentVNode","Fragment","renderList","option"],"sources":["../../../src/components/fields/DatePickerField.vue"],"sourcesContent":["<script lang=\"ts\">\nimport { defineComponent, h } from 'vue'\nimport { lazyComponent } from '../../lib/lazy'\n\n// The month grid (reka-ui) loads the first time a picker opens (or is hovered or focused),\n// not with the form.\nconst loadCalendar = () => import('../ui/Calendar.vue').then((module) => module.default)\nconst Calendar = lazyComponent(\n 'AlfakitCalendar',\n loadCalendar,\n defineComponent({\n name: 'AlfakitCalendarLoading',\n inheritAttrs: false,\n render: () => h('div', { 'aria-busy': 'true', class: 'h-[18.5rem] w-[15.5rem]' }),\n }),\n)\n</script>\n\n<script setup lang=\"ts\">\nimport {\n formatPhpDate,\n LocaleFormatter,\n timeInputStep,\n wallClockNow,\n type DatePickerSchema,\n} from '@alfakit/core'\nimport { CalendarDate, type DateValue } from '@internationalized/date'\nimport { CalendarIcon } from '@lucide/vue'\nimport { format as formatDate, isValid, parse } from 'date-fns'\nimport { computed, ref } from 'vue'\nimport { useDirection, useFormatter, useLocalization, useT } from '../../context'\nimport { cn } from '../../lib/utils'\nimport { useField } from '../form/form-context'\nimport FieldWrapper from '../schema/FieldWrapper.vue'\nimport Button from '../ui/Button.vue'\nimport Input from '../ui/Input.vue'\nimport Popover from '../ui/Popover.vue'\nimport PopoverContent from '../ui/PopoverContent.vue'\nimport PopoverTrigger from '../ui/PopoverTrigger.vue'\nimport { phpToDateFnsFormat } from './date-format'\nimport SelectAffixes from './SelectAffixes.vue'\n\nconst props = defineProps<{ component: DatePickerSchema }>()\nconst { value, setValue, blur, error, id, disabled, readOnly, aria } = useField<string | null>(\n () => props.component,\n)\nconst open = ref(false)\n\nconst storageFormat = computed(() => phpToDateFnsFormat(props.component.format))\nconst t = useT()\nconst direction = useDirection()\nconst panelFormat = useFormatter()\nconst localization = useLocalization()\n// `locale()` overrides the panel's language for this picker only.\nconst locale = computed(() => props.component.locale ?? localization.value?.tag ?? 'en')\nconst format = computed(() =>\n props.component.locale\n ? new LocaleFormatter(\n props.component.locale,\n panelFormat.value.currencyCode,\n panelFormat.value.timeZone,\n )\n : panelFormat.value,\n)\nconst listId = computed(() => (props.component.datalist ? `${id}-list` : undefined))\n\n// Month and weekday names come from Intl, so they follow the user's language.\nconst display = (date: Date): string =>\n props.component.displayFormat\n ? formatPhpDate(date, props.component.displayFormat, locale.value)\n : format.value.date(date, {\n ...(props.component.hasDate ? { dateStyle: 'medium' as const } : {}),\n ...(props.component.hasTime ? { timeStyle: 'short' as const } : {}),\n timeZone: undefined,\n })\n\nconst nativeType = computed(() =>\n !props.component.hasDate ? 'time' : props.component.hasTime ? 'datetime-local' : 'date',\n)\nconst nativeFormat = computed(() =>\n nativeType.value === 'time'\n ? props.component.hasSeconds\n ? 'HH:mm:ss'\n : 'HH:mm'\n : nativeType.value === 'datetime-local'\n ? props.component.hasSeconds\n ? \"yyyy-MM-dd'T'HH:mm:ss\"\n : \"yyyy-MM-dd'T'HH:mm\"\n : 'yyyy-MM-dd',\n)\n\nconst parsed = computed(() =>\n value.value ? parse(value.value, storageFormat.value, new Date()) : null,\n)\nconst selectedDate = computed(() =>\n parsed.value && isValid(parsed.value) ? parsed.value : undefined,\n)\nconst nativeValue = computed(() =>\n selectedDate.value ? formatDate(selectedDate.value, nativeFormat.value) : (value.value ?? ''),\n)\n\nfunction toNative(raw: string): string | undefined {\n const date = parse(raw, storageFormat.value, new Date())\n\n return isValid(date) ? formatDate(date, nativeFormat.value) : undefined\n}\n\nfunction parseStored(raw: string): Date {\n return parse(raw, storageFormat.value, new Date())\n}\n\nconst onNativeInput = (raw: string) => {\n if (raw === '') {\n setValue(null)\n\n return\n }\n\n const date = parse(raw, nativeFormat.value, new Date())\n setValue(isValid(date) ? formatDate(date, storageFormat.value) : raw)\n}\n\n// Calendar (reka-ui) works with @internationalized/date values.\nconst toCalendarDate = (date: Date): CalendarDate =>\n new CalendarDate(date.getFullYear(), date.getMonth() + 1, date.getDate())\nconst calendarValue = computed(() =>\n selectedDate.value ? toCalendarDate(selectedDate.value) : undefined,\n)\nconst minValue = computed(() =>\n props.component.minDate ? toCalendarDate(parseStored(props.component.minDate)) : undefined,\n)\nconst maxValue = computed(() =>\n props.component.maxDate ? toCalendarDate(parseStored(props.component.maxDate)) : undefined,\n)\nconst disabledDates = computed(() =>\n (props.component.disabledDates ?? []).map((date) => toCalendarDate(parseStored(date)).toString()),\n)\nconst isDateDisabled = (date: DateValue) => disabledDates.value.includes(date.toString())\n// `defaultFocusedDate()`: the month the calendar opens on while the field is empty.\nconst focusedPlaceholder = computed(() => {\n if (!props.component.defaultFocusedDate) return undefined\n\n const date = parseStored(props.component.defaultFocusedDate)\n\n return isValid(date) ? toCalendarDate(date) : undefined\n})\nconst step = computed(() => timeInputStep(props.component))\n\nconst onSelect = (next: DateValue | undefined) => {\n if (!next) {\n setValue(null)\n\n return\n }\n\n const base = selectedDate.value\n const withTime = new Date(\n next.year,\n next.month - 1,\n next.day,\n base?.getHours() ?? 0,\n base?.getMinutes() ?? 0,\n base?.getSeconds() ?? 0,\n )\n setValue(formatDate(withTime, storageFormat.value))\n\n if (props.component.closeOnDateSelection && !props.component.hasTime) {\n open.value = false\n blur()\n }\n}\n\nconst timeValue = computed(() =>\n selectedDate.value\n ? formatDate(selectedDate.value, props.component.hasSeconds ? 'HH:mm:ss' : 'HH:mm')\n : '',\n)\n\nconst onTimeInput = (raw: string) => {\n const base = selectedDate.value ?? wallClockNow(props.component.timezone)\n const [hours = '0', minutes = '0', seconds = '0'] = raw.split(':')\n const next = new Date(\n base.getFullYear(),\n base.getMonth(),\n base.getDate(),\n Number(hours),\n Number(minutes),\n Number(seconds),\n )\n setValue(formatDate(next, storageFormat.value))\n}\n\n// Kept out of the template: a `|` union there is parsed as a (removed) Vue 2 filter.\nconst weekStartsOn = computed(\n () => (props.component.firstDayOfWeek ?? 1) as 0 | 1 | 2 | 3 | 4 | 5 | 6,\n)\n</script>\n\n<template>\n <FieldWrapper :field=\"props.component\" :html-for=\"id\" :error=\"error\">\n <SelectAffixes :component=\"props.component\" :error=\"error\">\n <Input\n v-if=\"props.component.native || !props.component.hasDate\"\n :id=\"id\"\n :type=\"nativeType\"\n :name=\"props.component.name\"\n :model-value=\"nativeValue\"\n :step=\"step\"\n :min=\"props.component.minDate ? toNative(props.component.minDate) : undefined\"\n :max=\"props.component.maxDate ? toNative(props.component.maxDate) : undefined\"\n :disabled=\"disabled\"\n :readonly=\"readOnly\"\n :required=\"props.component.required\"\n :lang=\"props.component.locale\"\n :list=\"listId\"\n :aria-invalid=\"aria['aria-invalid']\"\n :aria-describedby=\"aria['aria-describedby']\"\n :aria-required=\"aria['aria-required']\"\n v-bind=\"props.component.extraInputAttributes\"\n @update:model-value=\"onNativeInput\"\n @blur=\"blur\"\n />\n <Popover v-else :open=\"open\" @update:open=\"open = $event && !readOnly\">\n <PopoverTrigger as-child>\n <Button\n :id=\"id\"\n type=\"button\"\n data-input=\"\"\n variant=\"outline\"\n :disabled=\"disabled\"\n @pointerenter=\"loadCalendar\"\n @focus=\"loadCalendar\"\n :aria-invalid=\"aria['aria-invalid']\"\n :aria-describedby=\"aria['aria-describedby']\"\n :class=\"\n cn(\n 'w-full justify-start font-normal',\n !selectedDate && 'text-muted-foreground',\n error && 'border-destructive',\n )\n \"\n >\n <CalendarIcon class=\"size-4\" />\n {{\n selectedDate\n ? display(selectedDate)\n : (props.component.placeholder ?? t('form.pick_date', {}, 'Pick a date'))\n }}\n </Button>\n </PopoverTrigger>\n <PopoverContent class=\"w-auto p-0\" align=\"start\">\n <Calendar\n :model-value=\"calendarValue\"\n :calendar-label=\"props.component.label || t('form.pick_date', {}, 'Pick a date')\"\n :locale=\"locale\"\n :dir=\"direction\"\n :today=\"toCalendarDate(wallClockNow(props.component.timezone))\"\n :week-starts-on=\"weekStartsOn\"\n :min-value=\"minValue\"\n :max-value=\"maxValue\"\n :default-placeholder=\"focusedPlaceholder\"\n :is-date-disabled=\"isDateDisabled\"\n initial-focus\n @update:model-value=\"onSelect($event as DateValue | undefined)\"\n />\n <div v-if=\"props.component.hasTime\" class=\"border-t p-3\">\n <Input\n type=\"time\"\n :step=\"step\"\n :model-value=\"timeValue\"\n @update:model-value=\"onTimeInput\"\n @blur=\"blur\"\n />\n </div>\n </PopoverContent>\n </Popover>\n <datalist\n v-if=\"(props.component.native || !props.component.hasDate) && props.component.datalist\"\n :id=\"listId\"\n >\n <option\n v-for=\"option in props.component.datalist\"\n :key=\"option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E3B,CAAA,GAAAvE,EAAM,UAAU,WAA3BrC,EAAA,GAAAgB,EAQM,OARNW,IAQM,CAPJtB,EAMEE,GAAA;OALA,MAAK;OACJ,MAAM2E,EAAA;OACN,eAAaQ,GAAA;OACb,uBAAoBC;OACpB,QAAMxF,EAAAsF,CAAA;;;;;;;;;IAMN,GAAA,GAAA,CAAA,MAAA,CAAA,KAAApD,EAAM,UAAU,UAAM,CAAKA,EAAM,UAAU,YAAYA,EAAM,UAAU,YADhFrC,EAAA,GAAAgB,EASW,YAAA;;KAPR,IAAIwC,EAAA;IAELxD,GAAAA,EAAAA,EAAA,EAAA,GAAAgB,EAIEE,GAAA,MAAAC,GAHiBkB,EAAM,UAAU,WAA1B,OADTrC,EAAA,GAAAgB,EAIE,UAAA;KAFC,KAAKsG;KACL,OAAOhD,EAASgD,CAAM,KAAKA"}
@@ -1 +1 @@
1
- {"version":3,"file":"RichEditorSuggestions.js","names":["_sfc_main","RichEditorSuggestions_vue_vue_type_script_setup_true_lang_default","RichEditorSuggestions_default"],"sources":["../../../src/components/fields/RichEditorSuggestions.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { EditorSuggestions } from '@alfakit/core'\nimport type { Editor } from '@tiptap/vue-3'\nimport { useT } from '../../context'\nimport { cn } from '../../lib/utils'\nimport { useStore } from '../../composables/use-store'\n\n/** The mention / merge tag listbox under the trigger. */\nconst props = defineProps<{\n suggestions: EditorSuggestions\n editor: Editor | undefined\n id: string\n}>()\nconst t = useT()\nconst state = useStore(props.suggestions.store)\n</script>\n\n<template>\n <div\n v-if=\"state.open && props.editor\"\n :id=\"props.id\"\n role=\"listbox\"\n :aria-label=\"t('editor.suggestions', {}, 'Suggestions')\"\n data-slot=\"rich-editor-suggestions\"\n class=\"bg-popover text-popover-foreground fixed z-50 min-w-48 overflow-hidden rounded-md border p-1 shadow-md\"\n :style=\"\n state.coords\n ? { left: `${state.coords.left}px`, top: `${state.coords.bottom + 4}px` }\n : undefined\n \"\n >\n <div\n v-if=\"state.loading && state.items.length === 0\"\n class=\"text-muted-foreground px-2 py-1.5 text-sm\"\n >\n {{ t('loading', {}, 'Loading…') }}\n </div>\n <div v-else-if=\"state.items.length === 0\" class=\"text-muted-foreground px-2 py-1.5 text-sm\">\n {{ t('no_results', {}, 'No results.') }}\n </div>\n <template v-else>\n <div\n v-for=\"(item, index) in state.items\"\n :id=\"`${props.id}-${index}`\"\n :key=\"item.id\"\n role=\"option\"\n :aria-selected=\"index === state.index\"\n :class=\"\n cn(\n 'cursor-pointer rounded-sm px-2 py-1.5 text-sm',\n index === state.index && 'bg-accent text-accent-foreground',\n )\n \"\n @mousedown.prevent\n @mouseenter=\"props.suggestions.highlight(index)\"\n @click=\"props.editor && props.suggestions.select(index, props.editor)\"\n >\n {{ state.kind === 'mention' ? `${state.trigger}${item.label}` : item.label }}\n </div>\n </template>\n </div>\n</template>\n"],"mappings":""}
1
+ {"version":3,"file":"RichEditorSuggestions.js","names":["_sfc_main","RichEditorSuggestions_vue_vue_type_script_setup_true_lang_default","RichEditorSuggestions_default"],"sources":["../../../src/components/fields/RichEditorSuggestions.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { fixedContainingBlockOffset, type EditorSuggestions } from '@alfakit/core'\nimport type { Editor } from '@tiptap/vue-3'\nimport { computed } from 'vue'\nimport { useT } from '../../context'\nimport { cn } from '../../lib/utils'\nimport { useStore } from '../../composables/use-store'\n\n/** The mention / merge tag listbox under the trigger. */\nconst props = defineProps<{\n suggestions: EditorSuggestions\n editor: Editor | undefined\n id: string\n}>()\nconst t = useT()\nconst state = useStore(props.suggestions.store)\n// Inside a modal the dialog's transform is the containing block of this fixed list.\nconst position = computed(() => {\n const coords = state.value.coords\n\n if (!coords) return undefined\n\n const offset = fixedContainingBlockOffset(props.editor?.view.dom)\n\n return { left: `${coords.left - offset.x}px`, top: `${coords.bottom + 4 - offset.y}px` }\n})\n</script>\n\n<template>\n <div\n v-if=\"state.open && props.editor\"\n :id=\"props.id\"\n role=\"listbox\"\n :aria-label=\"t('editor.suggestions', {}, 'Suggestions')\"\n data-slot=\"rich-editor-suggestions\"\n class=\"bg-popover text-popover-foreground fixed z-50 min-w-48 overflow-hidden rounded-md border p-1 shadow-md\"\n :style=\"position\"\n >\n <div\n v-if=\"state.loading && state.items.length === 0\"\n class=\"text-muted-foreground px-2 py-1.5 text-sm\"\n >\n {{ t('loading', {}, 'Loading…') }}\n </div>\n <div v-else-if=\"state.items.length === 0\" class=\"text-muted-foreground px-2 py-1.5 text-sm\">\n {{ t('no_results', {}, 'No results.') }}\n </div>\n <template v-else>\n <div\n v-for=\"(item, index) in state.items\"\n :id=\"`${props.id}-${index}`\"\n :key=\"item.id\"\n role=\"option\"\n :aria-selected=\"index === state.index\"\n :class=\"\n cn(\n 'cursor-pointer rounded-sm px-2 py-1.5 text-sm',\n index === state.index && 'bg-accent text-accent-foreground',\n )\n \"\n @mousedown.prevent\n @mouseenter=\"props.suggestions.highlight(index)\"\n @click=\"props.editor && props.suggestions.select(index, props.editor)\"\n >\n {{ state.kind === 'mention' ? `${state.trigger}${item.label}` : item.label }}\n </div>\n </template>\n </div>\n</template>\n"],"mappings":""}
@@ -1,4 +1,4 @@
1
- import type { EditorSuggestions } from '@alfakit/core';
1
+ import { type EditorSuggestions } from '@alfakit/core';
2
2
  import type { Editor } from '@tiptap/vue-3';
3
3
  /** The mention / merge tag listbox under the trigger. */
4
4
  type __VLS_Props = {
@@ -1 +1 @@
1
- {"version":3,"file":"RichEditorSuggestions.vue.d.ts","sourceRoot":"","sources":["../../../src/components/fields/RichEditorSuggestions.vue"],"names":[],"mappings":"AAgEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAK3C,yDAAyD;AACzD,KAAK,WAAW,GAAG;IACjB,WAAW,EAAE,iBAAiB,CAAA;IAC9B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,EAAE,EAAE,MAAM,CAAA;CACX,CAAC;;AA6GF,wBAMG"}
1
+ {"version":3,"file":"RichEditorSuggestions.vue.d.ts","sourceRoot":"","sources":["../../../src/components/fields/RichEditorSuggestions.vue"],"names":[],"mappings":"AAuEA,OAAO,EAA8B,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAClF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAM3C,yDAAyD;AACzD,KAAK,WAAW,GAAG;IACjB,WAAW,EAAE,iBAAiB,CAAA;IAC9B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,EAAE,EAAE,MAAM,CAAA;CACX,CAAC;;AAoHF,wBAMG"}
@@ -1,52 +1,58 @@
1
1
  import { useT as e } from "../../context.js";
2
2
  import { cn as t } from "../../lib/utils.js";
3
3
  import { useStore as n } from "../../composables/use-store.js";
4
- import { Fragment as r, createCommentVNode as i, createElementBlock as a, defineComponent as o, normalizeClass as s, normalizeStyle as c, openBlock as l, renderList as u, toDisplayString as d, unref as f, withModifiers as p } from "vue";
4
+ import { fixedContainingBlockOffset as r } from "@alfakit/core";
5
+ import { Fragment as i, computed as a, createCommentVNode as o, createElementBlock as s, defineComponent as c, normalizeClass as l, normalizeStyle as u, openBlock as d, renderList as f, toDisplayString as p, unref as m, withModifiers as h } from "vue";
5
6
  //#region src/components/fields/RichEditorSuggestions.vue?vue&type=script&setup=true&lang.ts
6
- var m = ["id", "aria-label"], h = {
7
+ var g = ["id", "aria-label"], _ = {
7
8
  key: 0,
8
9
  class: "text-muted-foreground px-2 py-1.5 text-sm"
9
- }, g = {
10
+ }, v = {
10
11
  key: 1,
11
12
  class: "text-muted-foreground px-2 py-1.5 text-sm"
12
- }, _ = [
13
+ }, y = [
13
14
  "id",
14
15
  "aria-selected",
15
16
  "onMouseenter",
16
17
  "onClick"
17
- ], v = /*@__PURE__*/ o({
18
+ ], b = /*@__PURE__*/ c({
18
19
  __name: "RichEditorSuggestions",
19
20
  props: {
20
21
  suggestions: {},
21
22
  editor: {},
22
23
  id: {}
23
24
  },
24
- setup(o) {
25
- let v = o, y = e(), b = n(v.suggestions.store);
26
- return (e, n) => f(b).open && v.editor ? (l(), a("div", {
25
+ setup(c) {
26
+ let b = c, x = e(), S = n(b.suggestions.store), C = a(() => {
27
+ let e = S.value.coords;
28
+ if (!e) return;
29
+ let t = r(b.editor?.view.dom);
30
+ return {
31
+ left: `${e.left - t.x}px`,
32
+ top: `${e.bottom + 4 - t.y}px`
33
+ };
34
+ });
35
+ return (e, n) => m(S).open && b.editor ? (d(), s("div", {
27
36
  key: 0,
28
- id: v.id,
37
+ id: b.id,
29
38
  role: "listbox",
30
- "aria-label": f(y)("editor.suggestions", {}, "Suggestions"),
39
+ "aria-label": m(x)("editor.suggestions", {}, "Suggestions"),
31
40
  "data-slot": "rich-editor-suggestions",
32
41
  class: "bg-popover text-popover-foreground fixed z-50 min-w-48 overflow-hidden rounded-md border p-1 shadow-md",
33
- style: c(f(b).coords ? {
34
- left: `${f(b).coords.left}px`,
35
- top: `${f(b).coords.bottom + 4}px`
36
- } : void 0)
37
- }, [f(b).loading && f(b).items.length === 0 ? (l(), a("div", h, d(f(y)("loading", {}, "Loading…")), 1)) : f(b).items.length === 0 ? (l(), a("div", g, d(f(y)("no_results", {}, "No results.")), 1)) : (l(!0), a(r, { key: 2 }, u(f(b).items, (e, r) => (l(), a("div", {
38
- id: `${v.id}-${r}`,
42
+ style: u(C.value)
43
+ }, [m(S).loading && m(S).items.length === 0 ? (d(), s("div", _, p(m(x)("loading", {}, "Loading…")), 1)) : m(S).items.length === 0 ? (d(), s("div", v, p(m(x)("no_results", {}, "No results.")), 1)) : (d(!0), s(i, { key: 2 }, f(m(S).items, (e, r) => (d(), s("div", {
44
+ id: `${b.id}-${r}`,
39
45
  key: e.id,
40
46
  role: "option",
41
- "aria-selected": r === f(b).index,
42
- class: s(f(t)("cursor-pointer rounded-sm px-2 py-1.5 text-sm", r === f(b).index && "bg-accent text-accent-foreground")),
43
- onMousedown: n[0] ||= p(() => {}, ["prevent"]),
44
- onMouseenter: (e) => v.suggestions.highlight(r),
45
- onClick: (e) => v.editor && v.suggestions.select(r, v.editor)
46
- }, d(f(b).kind === "mention" ? `${f(b).trigger}${e.label}` : e.label), 43, _))), 128))], 12, m)) : i("", !0);
47
+ "aria-selected": r === m(S).index,
48
+ class: l(m(t)("cursor-pointer rounded-sm px-2 py-1.5 text-sm", r === m(S).index && "bg-accent text-accent-foreground")),
49
+ onMousedown: n[0] ||= h(() => {}, ["prevent"]),
50
+ onMouseenter: (e) => b.suggestions.highlight(r),
51
+ onClick: (e) => b.editor && b.suggestions.select(r, b.editor)
52
+ }, p(m(S).kind === "mention" ? `${m(S).trigger}${e.label}` : e.label), 43, y))), 128))], 12, g)) : o("", !0);
47
53
  }
48
54
  });
49
55
  //#endregion
50
- export { v as default };
56
+ export { b as default };
51
57
 
52
58
  //# sourceMappingURL=RichEditorSuggestions.vue_vue_type_script_setup_true_lang.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RichEditorSuggestions.vue_vue_type_script_setup_true_lang.js","names":["_unref","_openBlock","_createElementBlock","_normalizeStyle","_toDisplayString","_Fragment","_renderList","_normalizeClass","_withModifiers","_createCommentVNode","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","RichEditorSuggestions_vue_vue_type_script_setup_true_lang_default","props","__props","t","useT","state","useStore","unref","openBlock","createElementBlock","normalizeStyle","toDisplayString","Fragment","renderList","index","item","normalizeClass","cn","_cache","withModifiers","createCommentVNode"],"sources":["../../../src/components/fields/RichEditorSuggestions.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { EditorSuggestions } from '@alfakit/core'\nimport type { Editor } from '@tiptap/vue-3'\nimport { useT } from '../../context'\nimport { cn } from '../../lib/utils'\nimport { useStore } from '../../composables/use-store'\n\n/** The mention / merge tag listbox under the trigger. */\nconst props = defineProps<{\n suggestions: EditorSuggestions\n editor: Editor | undefined\n id: string\n}>()\nconst t = useT()\nconst state = useStore(props.suggestions.store)\n</script>\n\n<template>\n <div\n v-if=\"state.open && props.editor\"\n :id=\"props.id\"\n role=\"listbox\"\n :aria-label=\"t('editor.suggestions', {}, 'Suggestions')\"\n data-slot=\"rich-editor-suggestions\"\n class=\"bg-popover text-popover-foreground fixed z-50 min-w-48 overflow-hidden rounded-md border p-1 shadow-md\"\n :style=\"\n state.coords\n ? { left: `${state.coords.left}px`, top: `${state.coords.bottom + 4}px` }\n : undefined\n \"\n >\n <div\n v-if=\"state.loading && state.items.length === 0\"\n class=\"text-muted-foreground px-2 py-1.5 text-sm\"\n >\n {{ t('loading', {}, 'Loading…') }}\n </div>\n <div v-else-if=\"state.items.length === 0\" class=\"text-muted-foreground px-2 py-1.5 text-sm\">\n {{ t('no_results', {}, 'No results.') }}\n </div>\n <template v-else>\n <div\n v-for=\"(item, index) in state.items\"\n :id=\"`${props.id}-${index}`\"\n :key=\"item.id\"\n role=\"option\"\n :aria-selected=\"index === state.index\"\n :class=\"\n cn(\n 'cursor-pointer rounded-sm px-2 py-1.5 text-sm',\n index === state.index && 'bg-accent text-accent-foreground',\n )\n \"\n @mousedown.prevent\n @mouseenter=\"props.suggestions.highlight(index)\"\n @click=\"props.editor && props.suggestions.select(index, props.editor)\"\n >\n {{ state.kind === 'mention' ? `${state.trigger}${item.label}` : item.label }}\n </div>\n </template>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;EAQA,IAAMe,IAAQC,GAKRC,IAAIC,EAAK,GACTC,IAAQC,EAASL,EAAM,YAAY,KAAK;mBAKpCf,EAAAmB,CAAA,CAAK,CAAC,QAAQJ,EAAM,UAD5Bd,EAAA,GAAAC,EA0CM,OAAA;;GAxCH,IAAIa,EAAM;GACX,MAAK;GACJ,cAAYf,EAAAiB,CAAA,CAAC,CAAA,sBAAA,CAAA,GAAA,aAAA;GACd,aAAU;GACV,OAAM;GACL,OAAKd,EAASH,EAAAmB,CAAA,CAAK,CAAC,SAA4B;IAAA,MA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AhB,CAAA"}
1
+ {"version":3,"file":"RichEditorSuggestions.vue_vue_type_script_setup_true_lang.js","names":["_unref","_openBlock","_createElementBlock","_normalizeStyle","_toDisplayString","_Fragment","_renderList","_normalizeClass","_withModifiers","_createCommentVNode","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","RichEditorSuggestions_vue_vue_type_script_setup_true_lang_default","props","__props","t","useT","state","useStore","position","computed","coords","offset","fixedContainingBlockOffset","unref","openBlock","createElementBlock","normalizeStyle","toDisplayString","Fragment","renderList","index","item","normalizeClass","cn","_cache","withModifiers","createCommentVNode"],"sources":["../../../src/components/fields/RichEditorSuggestions.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { fixedContainingBlockOffset, type EditorSuggestions } from '@alfakit/core'\nimport type { Editor } from '@tiptap/vue-3'\nimport { computed } from 'vue'\nimport { useT } from '../../context'\nimport { cn } from '../../lib/utils'\nimport { useStore } from '../../composables/use-store'\n\n/** The mention / merge tag listbox under the trigger. */\nconst props = defineProps<{\n suggestions: EditorSuggestions\n editor: Editor | undefined\n id: string\n}>()\nconst t = useT()\nconst state = useStore(props.suggestions.store)\n// Inside a modal the dialog's transform is the containing block of this fixed list.\nconst position = computed(() => {\n const coords = state.value.coords\n\n if (!coords) return undefined\n\n const offset = fixedContainingBlockOffset(props.editor?.view.dom)\n\n return { left: `${coords.left - offset.x}px`, top: `${coords.bottom + 4 - offset.y}px` }\n})\n</script>\n\n<template>\n <div\n v-if=\"state.open && props.editor\"\n :id=\"props.id\"\n role=\"listbox\"\n :aria-label=\"t('editor.suggestions', {}, 'Suggestions')\"\n data-slot=\"rich-editor-suggestions\"\n class=\"bg-popover text-popover-foreground fixed z-50 min-w-48 overflow-hidden rounded-md border p-1 shadow-md\"\n :style=\"position\"\n >\n <div\n v-if=\"state.loading && state.items.length === 0\"\n class=\"text-muted-foreground px-2 py-1.5 text-sm\"\n >\n {{ t('loading', {}, 'Loading…') }}\n </div>\n <div v-else-if=\"state.items.length === 0\" class=\"text-muted-foreground px-2 py-1.5 text-sm\">\n {{ t('no_results', {}, 'No results.') }}\n </div>\n <template v-else>\n <div\n v-for=\"(item, index) in state.items\"\n :id=\"`${props.id}-${index}`\"\n :key=\"item.id\"\n role=\"option\"\n :aria-selected=\"index === state.index\"\n :class=\"\n cn(\n 'cursor-pointer rounded-sm px-2 py-1.5 text-sm',\n index === state.index && 'bg-accent text-accent-foreground',\n )\n \"\n @mousedown.prevent\n @mouseenter=\"props.suggestions.highlight(index)\"\n @click=\"props.editor && props.suggestions.select(index, props.editor)\"\n >\n {{ state.kind === 'mention' ? `${state.trigger}${item.label}` : item.label }}\n </div>\n </template>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;EASA,IAAMe,IAAQC,GAKRC,IAAIC,EAAK,GACTC,IAAQC,EAASL,EAAM,YAAY,KAAK,GAExCM,IAAWC,QAAe;GAC9B,IAAMC,IAASJ,EAAM,MAAM;GAE3B,IAAI,CAACI,GAAQ;GAEb,IAAMC,IAASC,EAA2BV,EAAM,QAAQ,KAAK,GAAG;GAEhE,OAAO;IAAE,MAAM,GAAGQ,EAAO,OAAOC,EAAO,EAAE;IAAK,KAAK,GAAGD,EAAO,SAAS,IAAIC,EAAO,EAAE;GAAI;EACzF,CAAC;mBAKSxB,EAAAmB,CAAA,CAAK,CAAC,QAAQJ,EAAM,UAD5Bd,EAAA,GAAAC,EAsCM,OAAA;;GApCH,IAAIa,EAAM;GACX,MAAK;GACJ,cAAYf,EAAAiB,CAAA,CAAC,CAAA,sBAAA,CAAA,GAAA,aAAA;GACd,aAAU;GACV,OAAM;GACL,OAAKd,EAAEkB,EAAA,KAAQ;EAGRrB,GAAAA,CAAAA,EAAAmB,CAAA,CAAK,CAAC,WAAWnB,EAAAmB,CAAA,CAAK,CAAC,MAAM,WAAM,KAD3ClB,EAAA,GAAAC,EAKM,OALNS,GAKMP,EADDJ,EAAAiB,CAAA,CAAC,CAAA,WAAA,CAAA,GAAA,UAAA,CAAA,GAAA,CAAA,KAEUjB,EAAAmB,CAAA,CAAK,CAAC,MAAM,WAAM,KAAlClB,EAAA,GAAAC,EAEM,OAFNU,GAEMR,EADDJ,EAAAiB,CAAA,CAAC,CAAA,cAAA,CAAA,GAAA,aAAA,CAAA,GAAA,CAAA,MAGJhB,EAAA,EAAA,GAAAC,EAiBMG,GAAA,EAAA,KAAA,EAAA,GAAAC,EAhBoBN,EAAAmB,CAAA,CAAK,CAAC,QAAtB,GAAM,OADhBlB,EAAA,GAAAC,EAiBM,OAAA;GAfH,IAAE,GAAKa,EAAM,GAAE,GAAIkB;GACnB,KAAKC,EAAK;GACX,MAAK;GACJ,iBAAeD,MAAUjC,EAAAmB,CAAA,CAAK,CAAC;GAC/B,OAAKZ,EAAaP,EAAAoC,CAAA,CAAE,CAAA,iDAA2EH,MAAUjC,EAAAmB,CAAA,CAAK,CAAC,SAAK,kCAAA,CAAA;GAMpH,aAAS,AAAAkB,EAAA,OAAA7B,QAAV,CAAA,GAAkB,CAAA,SAAA,CAAA;GACjB,eAAU,MAAEO,EAAM,YAAY,UAAUkB,CAAK;GAC7C,UAAK,MAAElB,EAAM,UAAUA,EAAM,YAAY,OAAOkB,GAAOlB,EAAM,MAAM;EAEjE,GAAAX,EAAAJ,EAAAmB,CAAA,CAAK,CAAC,SAAI,YAAA,GAAoBnB,EAAAmB,CAAA,CAAK,CAAC,UAAUe,EAAK,UAAUA,EAAK,KAAK,GAAA,IAAArB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"RichEditorToolbarGroup.js","names":["_sfc_main","RichEditorToolbarGroup_vue_vue_type_script_setup_true_lang_default","RichEditorToolbarGroup_default"],"sources":["../../../src/components/fields/RichEditorToolbarGroup.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type {\n RichEditorToolbarGroupSchema,\n RichEditorToolSchema,\n ToolbarCommand,\n} from '@alfakit/core'\nimport { commandLabel, groupTriggerButton } from '@alfakit/core'\nimport { ChevronDownIcon } from '@lucide/vue'\nimport type { Editor } from '@tiptap/vue-3'\nimport { computed } from 'vue'\nimport { useT } from '../../context'\nimport { Icon } from '../../lib/icons'\nimport { cn } from '../../lib/utils'\nimport Button from '../ui/Button.vue'\nimport DropdownMenu from '../ui/DropdownMenu.vue'\nimport DropdownMenuContent from '../ui/DropdownMenuContent.vue'\nimport DropdownMenuItem from '../ui/DropdownMenuItem.vue'\nimport DropdownMenuTrigger from '../ui/DropdownMenuTrigger.vue'\nimport RichEditorToolIcon from './RichEditorToolIcon.vue'\n\n/** A `ToolbarButtonGroup`: a dropdown of buttons (icons, or labels with `textualButtons()`). */\nconst props = defineProps<{\n group: RichEditorToolbarGroupSchema\n editor: Editor\n editable: boolean\n commands: Record<string, ToolbarCommand>\n tools?: RichEditorToolSchema[] | null\n /** Bumped on every transaction so active states follow the cursor. */\n tick: number\n}>()\nconst emit = defineEmits<{ run: [name: string] }>()\nconst t = useT()\nconst translate = (key: string, fallback: string) => t(key, {}, fallback)\n\nconst buttons = computed(() => props.group.buttons.filter((name) => props.commands[name]))\nconst trigger = computed(() => {\n void props.tick\n\n return groupTriggerButton(buttons.value, props.editor, props.commands)\n})\nconst active = computed(() => {\n void props.tick\n\n return buttons.value.some((name) => props.commands[name]?.active?.(props.editor))\n})\nconst label = (name: string) => commandLabel(name, props.commands, translate)\nconst pressed = (name: string) => {\n void props.tick\n\n return Boolean(props.commands[name]?.active?.(props.editor))\n}\n</script>\n\n<template>\n <DropdownMenu v-if=\"buttons.length > 0\">\n <DropdownMenuTrigger as-child>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n :aria-label=\"props.group.label\"\n :title=\"props.group.label\"\n :disabled=\"!props.editable\"\n :class=\"cn('h-8 gap-0.5 px-1.5', active && 'bg-accent text-accent-foreground')\"\n @mousedown.prevent\n >\n <Icon v-if=\"props.group.icon\" :name=\"props.group.icon\" />\n <RichEditorToolIcon\n v-else-if=\"trigger\"\n :name=\"trigger\"\n :label=\"label(trigger)\"\n :tools=\"props.tools\"\n />\n <template v-else>{{ props.group.label }}</template>\n <ChevronDownIcon class=\"size-3 opacity-60\" />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent\n align=\"start\"\n :aria-label=\"props.group.label\"\n :class=\"cn(!props.group.textual && 'flex min-w-0 flex-row gap-0.5')\"\n >\n <DropdownMenuItem\n v-for=\"name in buttons\"\n :key=\"name\"\n :aria-label=\"props.group.textual ? undefined : label(name)\"\n :title=\"label(name)\"\n :class=\"cn(pressed(name) && 'bg-accent text-accent-foreground')\"\n @select=\"emit('run', name)\"\n >\n <RichEditorToolIcon :name=\"name\" :label=\"label(name)\" :tools=\"props.tools\" />\n <span v-if=\"props.group.textual\">{{ label(name) }}</span>\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n</template>\n"],"mappings":""}
1
+ {"version":3,"file":"RichEditorToolbarGroup.js","names":["_sfc_main","RichEditorToolbarGroup_vue_vue_type_script_setup_true_lang_default","RichEditorToolbarGroup_default"],"sources":["../../../src/components/fields/RichEditorToolbarGroup.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type {\n RichEditorToolbarGroupSchema,\n RichEditorToolSchema,\n ToolbarCommand,\n} from '@alfakit/core'\nimport { commandLabel, groupTriggerButton } from '@alfakit/core'\nimport { ChevronDownIcon } from '@lucide/vue'\nimport type { Editor } from '@tiptap/vue-3'\nimport { computed } from 'vue'\nimport { useT } from '../../context'\nimport { Icon } from '../../lib/icons'\nimport { cn } from '../../lib/utils'\nimport Button from '../ui/Button.vue'\nimport DropdownMenu from '../ui/DropdownMenu.vue'\nimport DropdownMenuContent from '../ui/DropdownMenuContent.vue'\nimport DropdownMenuItem from '../ui/DropdownMenuItem.vue'\nimport DropdownMenuTrigger from '../ui/DropdownMenuTrigger.vue'\nimport RichEditorToolIcon from './RichEditorToolIcon.vue'\n\n/** A `ToolbarButtonGroup`: a dropdown of buttons (icons, or labels with `textualButtons()`). */\nconst props = defineProps<{\n group: RichEditorToolbarGroupSchema\n editor: Editor\n editable: boolean\n commands: Record<string, ToolbarCommand>\n tools?: RichEditorToolSchema[] | null\n /** Bumped on every transaction so active states follow the cursor. */\n tick: number\n}>()\nconst emit = defineEmits<{ run: [name: string] }>()\nconst t = useT()\nconst translate = (key: string, fallback: string) => t(key, {}, fallback)\n\nconst buttons = computed(() => props.group.buttons.filter((name) => props.commands[name]))\nconst trigger = computed(() => {\n void props.tick\n\n return groupTriggerButton(buttons.value, props.editor, props.commands)\n})\nconst active = computed(() => {\n void props.tick\n\n return buttons.value.some((name) => props.commands[name]?.active?.(props.editor))\n})\nconst label = (name: string) => commandLabel(name, props.commands, translate)\n// After a pick, typing goes on in the editor (the command focused it); the menu would\n// otherwise return focus to its trigger. Closing without a pick (Escape) still does.\nlet picked = false\nconst pick = (name: string) => {\n picked = true\n emit('run', name)\n}\nconst closeAutoFocus = (event: Event) => {\n if (!picked) return\n\n picked = false\n event.preventDefault()\n props.editor.commands.focus()\n}\nconst pressed = (name: string) => {\n void props.tick\n\n return Boolean(props.commands[name]?.active?.(props.editor))\n}\n</script>\n\n<template>\n <DropdownMenu v-if=\"buttons.length > 0\">\n <DropdownMenuTrigger as-child>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n :aria-label=\"props.group.label\"\n :title=\"props.group.label\"\n :disabled=\"!props.editable\"\n :class=\"cn('h-8 gap-0.5 px-1.5', active && 'bg-accent text-accent-foreground')\"\n @mousedown.prevent\n >\n <Icon v-if=\"props.group.icon\" :name=\"props.group.icon\" />\n <RichEditorToolIcon\n v-else-if=\"trigger\"\n :name=\"trigger\"\n :label=\"label(trigger)\"\n :tools=\"props.tools\"\n />\n <template v-else>{{ props.group.label }}</template>\n <ChevronDownIcon class=\"size-3 opacity-60\" />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent\n align=\"start\"\n :aria-label=\"props.group.label\"\n :class=\"cn(!props.group.textual && 'flex min-w-0 flex-row gap-0.5')\"\n @close-auto-focus=\"closeAutoFocus\"\n >\n <DropdownMenuItem\n v-for=\"name in buttons\"\n :key=\"name\"\n :aria-label=\"props.group.textual ? undefined : label(name)\"\n :title=\"label(name)\"\n :class=\"cn(pressed(name) && 'bg-accent text-accent-foreground')\"\n @select=\"pick(name)\"\n >\n <RichEditorToolIcon :name=\"name\" :label=\"label(name)\" :tools=\"props.tools\" />\n <span v-if=\"props.group.textual\">{{ label(name) }}</span>\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n</template>\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"RichEditorToolbarGroup.vue.d.ts","sourceRoot":"","sources":["../../../src/components/fields/RichEditorToolbarGroup.vue"],"names":[],"mappings":"AAkGA,OAAO,KAAK,EACV,4BAA4B,EAC5B,oBAAoB,EACpB,cAAc,EACf,MAAM,eAAe,CAAA;AAGtB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAY3C,gGAAgG;AAChG,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,4BAA4B,CAAA;IACnC,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,OAAO,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IACxC,KAAK,CAAC,EAAE,oBAAoB,EAAE,GAAG,IAAI,CAAA;IACrC,sEAAsE;IACtE,IAAI,EAAE,MAAM,CAAA;CACb,CAAC;;;;;;AAwNF,wBAOG"}
1
+ {"version":3,"file":"RichEditorToolbarGroup.vue.d.ts","sourceRoot":"","sources":["../../../src/components/fields/RichEditorToolbarGroup.vue"],"names":[],"mappings":"AAiHA,OAAO,KAAK,EACV,4BAA4B,EAC5B,oBAAoB,EACpB,cAAc,EACf,MAAM,eAAe,CAAA;AAGtB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAY3C,gGAAgG;AAChG,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,4BAA4B,CAAA;IACnC,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,OAAO,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IACxC,KAAK,CAAC,EAAE,oBAAoB,EAAE,GAAG,IAAI,CAAA;IACrC,sEAAsE;IACtE,IAAI,EAAE,MAAM,CAAA;CACb,CAAC;;;;;;AA8OF,wBAOG"}
@@ -23,7 +23,11 @@ var D = { key: 0 }, O = /*@__PURE__*/ v({
23
23
  },
24
24
  emits: ["run"],
25
25
  setup(v, { emit: O }) {
26
- let k = v, A = O, j = e(), M = (e, t) => j(e, {}, t), N = f(() => k.group.buttons.filter((e) => k.commands[e])), P = f(() => (k.tick, u(N.value, k.editor, k.commands))), F = f(() => (k.tick, N.value.some((e) => k.commands[e]?.active?.(k.editor)))), I = (e) => l(e, k.commands, M), L = (e) => (k.tick, !!k.commands[e]?.active?.(k.editor));
26
+ let k = v, A = O, j = e(), M = (e, t) => j(e, {}, t), N = f(() => k.group.buttons.filter((e) => k.commands[e])), P = f(() => (k.tick, u(N.value, k.editor, k.commands))), F = f(() => (k.tick, N.value.some((e) => k.commands[e]?.active?.(k.editor)))), I = (e) => l(e, k.commands, M), L = !1, R = (e) => {
27
+ L = !0, A("run", e);
28
+ }, z = (e) => {
29
+ L && (L = !1, e.preventDefault(), k.editor.commands.focus());
30
+ }, B = (e) => (k.tick, !!k.commands[e]?.active?.(k.editor));
27
31
  return (e, l) => N.value.length > 0 ? (b(), p(i, { key: 0 }, {
28
32
  default: w(() => [_(s, { "as-child": "" }, {
29
33
  default: w(() => [_(r, {
@@ -60,14 +64,15 @@ var D = { key: 0 }, O = /*@__PURE__*/ v({
60
64
  }), _(a, {
61
65
  align: "start",
62
66
  "aria-label": k.group.label,
63
- class: y(C(t)(!k.group.textual && "flex min-w-0 flex-row gap-0.5"))
67
+ class: y(C(t)(!k.group.textual && "flex min-w-0 flex-row gap-0.5")),
68
+ onCloseAutoFocus: z
64
69
  }, {
65
70
  default: w(() => [(b(!0), h(d, null, x(N.value, (e) => (b(), p(o, {
66
71
  key: e,
67
72
  "aria-label": k.group.textual ? void 0 : I(e),
68
73
  title: I(e),
69
- class: y(C(t)(L(e) && "bg-accent text-accent-foreground")),
70
- onSelect: (t) => A("run", e)
74
+ class: y(C(t)(B(e) && "bg-accent text-accent-foreground")),
75
+ onSelect: (t) => R(e)
71
76
  }, {
72
77
  default: w(() => [_(c, {
73
78
  name: e,
@@ -1 +1 @@
1
- {"version":3,"file":"RichEditorToolbarGroup.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","DropdownMenu","_withCtx","_createVNode","DropdownMenuTrigger","Button","_normalizeClass","_unref","_withModifiers","Icon","RichEditorToolIcon","_createElementBlock","_Fragment","_createTextVNode","_toDisplayString","DropdownMenuContent","_renderList","DropdownMenuItem","_createCommentVNode","Icon_default","Button_default","DropdownMenu_default","DropdownMenuContent_default","DropdownMenuItem_default","DropdownMenuTrigger_default","RichEditorToolIcon_default","_hoisted_1","RichEditorToolbarGroup_vue_vue_type_script_setup_true_lang_default","__emit","props","__props","emit","t","useT","translate","key","fallback","buttons","computed","name","trigger","groupTriggerButton","active","label","commandLabel","pressed","openBlock","createBlock","withCtx","createVNode","normalizeClass","unref","cn","_cache","withModifiers","createElementBlock","Fragment","createTextVNode","toDisplayString","ChevronDownIcon","renderList","createCommentVNode"],"sources":["../../../src/components/fields/RichEditorToolbarGroup.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type {\n RichEditorToolbarGroupSchema,\n RichEditorToolSchema,\n ToolbarCommand,\n} from '@alfakit/core'\nimport { commandLabel, groupTriggerButton } from '@alfakit/core'\nimport { ChevronDownIcon } from '@lucide/vue'\nimport type { Editor } from '@tiptap/vue-3'\nimport { computed } from 'vue'\nimport { useT } from '../../context'\nimport { Icon } from '../../lib/icons'\nimport { cn } from '../../lib/utils'\nimport Button from '../ui/Button.vue'\nimport DropdownMenu from '../ui/DropdownMenu.vue'\nimport DropdownMenuContent from '../ui/DropdownMenuContent.vue'\nimport DropdownMenuItem from '../ui/DropdownMenuItem.vue'\nimport DropdownMenuTrigger from '../ui/DropdownMenuTrigger.vue'\nimport RichEditorToolIcon from './RichEditorToolIcon.vue'\n\n/** A `ToolbarButtonGroup`: a dropdown of buttons (icons, or labels with `textualButtons()`). */\nconst props = defineProps<{\n group: RichEditorToolbarGroupSchema\n editor: Editor\n editable: boolean\n commands: Record<string, ToolbarCommand>\n tools?: RichEditorToolSchema[] | null\n /** Bumped on every transaction so active states follow the cursor. */\n tick: number\n}>()\nconst emit = defineEmits<{ run: [name: string] }>()\nconst t = useT()\nconst translate = (key: string, fallback: string) => t(key, {}, fallback)\n\nconst buttons = computed(() => props.group.buttons.filter((name) => props.commands[name]))\nconst trigger = computed(() => {\n void props.tick\n\n return groupTriggerButton(buttons.value, props.editor, props.commands)\n})\nconst active = computed(() => {\n void props.tick\n\n return buttons.value.some((name) => props.commands[name]?.active?.(props.editor))\n})\nconst label = (name: string) => commandLabel(name, props.commands, translate)\nconst pressed = (name: string) => {\n void props.tick\n\n return Boolean(props.commands[name]?.active?.(props.editor))\n}\n</script>\n\n<template>\n <DropdownMenu v-if=\"buttons.length > 0\">\n <DropdownMenuTrigger as-child>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n :aria-label=\"props.group.label\"\n :title=\"props.group.label\"\n :disabled=\"!props.editable\"\n :class=\"cn('h-8 gap-0.5 px-1.5', active && 'bg-accent text-accent-foreground')\"\n @mousedown.prevent\n >\n <Icon v-if=\"props.group.icon\" :name=\"props.group.icon\" />\n <RichEditorToolIcon\n v-else-if=\"trigger\"\n :name=\"trigger\"\n :label=\"label(trigger)\"\n :tools=\"props.tools\"\n />\n <template v-else>{{ props.group.label }}</template>\n <ChevronDownIcon class=\"size-3 opacity-60\" />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent\n align=\"start\"\n :aria-label=\"props.group.label\"\n :class=\"cn(!props.group.textual && 'flex min-w-0 flex-row gap-0.5')\"\n >\n <DropdownMenuItem\n v-for=\"name in buttons\"\n :key=\"name\"\n :aria-label=\"props.group.textual ? undefined : label(name)\"\n :title=\"label(name)\"\n :class=\"cn(pressed(name) && 'bg-accent text-accent-foreground')\"\n @select=\"emit('run', name)\"\n >\n <RichEditorToolIcon :name=\"name\" :label=\"label(name)\" :tools=\"props.tools\" />\n <span v-if=\"props.group.textual\">{{ label(name) }}</span>\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;EAqBA,IAAM8B,IAAQC,GASRC,IAAOH,GACPI,IAAIC,EAAK,GACTC,KAAa,GAAa,MAAqBF,EAAEG,GAAK,CAAC,GAAGC,CAAQ,GAElEC,IAAUC,QAAeT,EAAM,MAAM,QAAQ,QAAQ,MAASA,EAAM,SAASU,EAAK,CAAC,GACnFC,IAAUF,SACdT,EAAW,MAEJY,EAAmBJ,EAAQ,OAAOR,EAAM,QAAQA,EAAM,QAAQ,EACtE,GACKa,IAASJ,SACbT,EAAW,MAEJQ,EAAQ,MAAM,MAAM,MAASR,EAAM,SAASU,EAAK,EAAE,SAASV,EAAM,MAAM,CAAC,EACjF,GACKc,KAAS,MAAiBC,EAAaL,GAAMV,EAAM,UAAUK,CAAS,GACtEW,KAAW,OACfhB,EAAW,MAEJ,EAAQA,EAAM,SAASU,EAAK,EAAE,SAASV,EAAM,MAAM;mBAKtCQ,EAAA,MAAQ,SAAM,KAAlCtC,EAAA,GAAAC,EAwCeC,GAAA,EAAA,KAAA,EAAA,GAAA;GAvCb,SAAAC,QAqBsB,CArBtBC,EAqBsBC,GAAA,EArBD,YAAA,GAAQ,GAAA;IAC3B,SAAAF,QAmBS,CAnBTC,EAmBSE,GAAA;KAlBP,MAAK;KACL,SAAQ;KACR,MAAK;KACJ,cAAYwB,EAAM,MAAM;KACxB,OAAOA,EAAM,MAAM;KACnB,UAAQ,CAAGA,EAAM;KACjB,OAAKvB,EAAEC,EAAA6C,CAAA,CAA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AAI,OAAOV,EAAM;;;;;KACxD,CAAA,GAAAA,EAAM,MAAM,WAAxB9B,EAAA,GAAAY,EAAyD,QAAAe,GAAAZ,EAArB6B,EAAMJ,CAAI,CAAA,GAAA,CAAA,KAAAsB,EAAA,IAAA,EAAA,CAAA,CAAA"}
1
+ {"version":3,"file":"RichEditorToolbarGroup.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","DropdownMenu","_withCtx","_createVNode","DropdownMenuTrigger","Button","_normalizeClass","_unref","_withModifiers","Icon","RichEditorToolIcon","_createElementBlock","_Fragment","_createTextVNode","_toDisplayString","DropdownMenuContent","_renderList","DropdownMenuItem","_createCommentVNode","Icon_default","Button_default","DropdownMenu_default","DropdownMenuContent_default","DropdownMenuItem_default","DropdownMenuTrigger_default","RichEditorToolIcon_default","_hoisted_1","RichEditorToolbarGroup_vue_vue_type_script_setup_true_lang_default","__emit","props","__props","emit","t","useT","translate","key","fallback","buttons","computed","name","trigger","groupTriggerButton","active","label","commandLabel","picked","pick","closeAutoFocus","event","pressed","openBlock","createBlock","withCtx","createVNode","normalizeClass","unref","cn","_cache","withModifiers","createElementBlock","Fragment","createTextVNode","toDisplayString","ChevronDownIcon","renderList","createCommentVNode"],"sources":["../../../src/components/fields/RichEditorToolbarGroup.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type {\n RichEditorToolbarGroupSchema,\n RichEditorToolSchema,\n ToolbarCommand,\n} from '@alfakit/core'\nimport { commandLabel, groupTriggerButton } from '@alfakit/core'\nimport { ChevronDownIcon } from '@lucide/vue'\nimport type { Editor } from '@tiptap/vue-3'\nimport { computed } from 'vue'\nimport { useT } from '../../context'\nimport { Icon } from '../../lib/icons'\nimport { cn } from '../../lib/utils'\nimport Button from '../ui/Button.vue'\nimport DropdownMenu from '../ui/DropdownMenu.vue'\nimport DropdownMenuContent from '../ui/DropdownMenuContent.vue'\nimport DropdownMenuItem from '../ui/DropdownMenuItem.vue'\nimport DropdownMenuTrigger from '../ui/DropdownMenuTrigger.vue'\nimport RichEditorToolIcon from './RichEditorToolIcon.vue'\n\n/** A `ToolbarButtonGroup`: a dropdown of buttons (icons, or labels with `textualButtons()`). */\nconst props = defineProps<{\n group: RichEditorToolbarGroupSchema\n editor: Editor\n editable: boolean\n commands: Record<string, ToolbarCommand>\n tools?: RichEditorToolSchema[] | null\n /** Bumped on every transaction so active states follow the cursor. */\n tick: number\n}>()\nconst emit = defineEmits<{ run: [name: string] }>()\nconst t = useT()\nconst translate = (key: string, fallback: string) => t(key, {}, fallback)\n\nconst buttons = computed(() => props.group.buttons.filter((name) => props.commands[name]))\nconst trigger = computed(() => {\n void props.tick\n\n return groupTriggerButton(buttons.value, props.editor, props.commands)\n})\nconst active = computed(() => {\n void props.tick\n\n return buttons.value.some((name) => props.commands[name]?.active?.(props.editor))\n})\nconst label = (name: string) => commandLabel(name, props.commands, translate)\n// After a pick, typing goes on in the editor (the command focused it); the menu would\n// otherwise return focus to its trigger. Closing without a pick (Escape) still does.\nlet picked = false\nconst pick = (name: string) => {\n picked = true\n emit('run', name)\n}\nconst closeAutoFocus = (event: Event) => {\n if (!picked) return\n\n picked = false\n event.preventDefault()\n props.editor.commands.focus()\n}\nconst pressed = (name: string) => {\n void props.tick\n\n return Boolean(props.commands[name]?.active?.(props.editor))\n}\n</script>\n\n<template>\n <DropdownMenu v-if=\"buttons.length > 0\">\n <DropdownMenuTrigger as-child>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n :aria-label=\"props.group.label\"\n :title=\"props.group.label\"\n :disabled=\"!props.editable\"\n :class=\"cn('h-8 gap-0.5 px-1.5', active && 'bg-accent text-accent-foreground')\"\n @mousedown.prevent\n >\n <Icon v-if=\"props.group.icon\" :name=\"props.group.icon\" />\n <RichEditorToolIcon\n v-else-if=\"trigger\"\n :name=\"trigger\"\n :label=\"label(trigger)\"\n :tools=\"props.tools\"\n />\n <template v-else>{{ props.group.label }}</template>\n <ChevronDownIcon class=\"size-3 opacity-60\" />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent\n align=\"start\"\n :aria-label=\"props.group.label\"\n :class=\"cn(!props.group.textual && 'flex min-w-0 flex-row gap-0.5')\"\n @close-auto-focus=\"closeAutoFocus\"\n >\n <DropdownMenuItem\n v-for=\"name in buttons\"\n :key=\"name\"\n :aria-label=\"props.group.textual ? undefined : label(name)\"\n :title=\"label(name)\"\n :class=\"cn(pressed(name) && 'bg-accent text-accent-foreground')\"\n @select=\"pick(name)\"\n >\n <RichEditorToolIcon :name=\"name\" :label=\"label(name)\" :tools=\"props.tools\" />\n <span v-if=\"props.group.textual\">{{ label(name) }}</span>\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;EAqBA,IAAM8B,IAAQC,GASRC,IAAOH,GACPI,IAAIC,EAAK,GACTC,KAAa,GAAa,MAAqBF,EAAEG,GAAK,CAAC,GAAGC,CAAQ,GAElEC,IAAUC,QAAeT,EAAM,MAAM,QAAQ,QAAQ,MAASA,EAAM,SAASU,EAAK,CAAC,GACnFC,IAAUF,SACdT,EAAW,MAEJY,EAAmBJ,EAAQ,OAAOR,EAAM,QAAQA,EAAM,QAAQ,EACtE,GACKa,IAASJ,SACbT,EAAW,MAEJQ,EAAQ,MAAM,MAAM,MAASR,EAAM,SAASU,EAAK,EAAE,SAASV,EAAM,MAAM,CAAC,EACjF,GACKc,KAAS,MAAiBC,EAAaL,GAAMV,EAAM,UAAUK,CAAS,GAGxEW,IAAS,IACPC,KAAQ,MAAiB;GAE7B,AADA,IAAS,IACTf,EAAK,OAAOQ,CAAI;EAClB,GACMQ,KAAkB,MAAiB;GACvC,AAAKF,MAEL,IAAS,IACTG,EAAM,eAAe,GACrBnB,EAAM,OAAO,SAAS,MAAM;EAC9B,GACMoB,KAAW,OACfpB,EAAW,MAEJ,EAAQA,EAAM,SAASU,EAAK,EAAE,SAASV,EAAM,MAAM;mBAKtCQ,EAAA,MAAQ,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