@krak-stack/registry 0.11.7 → 0.11.9

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 (109) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/README.md +39 -0
  3. package/dist/components/app-switcher/html.d.ts +2 -2
  4. package/dist/components/asset-input/html.d.ts +70 -0
  5. package/dist/components/asset-input/html.js +1549 -0
  6. package/dist/components/asset-input/index.d.ts +280 -0
  7. package/dist/components/asset-input/react.d.ts +32 -0
  8. package/dist/components/asset-input/react.js +2269 -0
  9. package/dist/components/asset-input/schema.d.ts +93 -0
  10. package/dist/components/asset-input/upload.d.ts +15 -0
  11. package/dist/components/asset-table/html.d.ts +110 -0
  12. package/dist/components/asset-table/html.js +4934 -0
  13. package/dist/components/asset-table/index.d.ts +225 -0
  14. package/dist/components/asset-table/react.d.ts +21 -0
  15. package/dist/components/asset-table/react.js +8241 -0
  16. package/dist/components/asset-table/schema.d.ts +73 -0
  17. package/dist/components/audit-log-table/html.js +47 -13
  18. package/dist/components/audit-log-table/react.js +36 -12
  19. package/dist/components/copy-button/html.d.ts +2 -2
  20. package/dist/components/danger-confirmation/html.d.ts +2 -2
  21. package/dist/components/data-table/classes.d.ts +2 -0
  22. package/dist/components/data-table/html.d.ts +58 -0
  23. package/dist/components/data-table/html.js +47 -13
  24. package/dist/components/data-table/index.d.ts +51 -1
  25. package/dist/components/data-table/react.d.ts +1 -0
  26. package/dist/components/data-table/react.js +36 -12
  27. package/dist/components/data-table/schema.d.ts +93 -3
  28. package/dist/components/date-input/html.d.ts +2 -2
  29. package/dist/components/docs/html.js +22 -4
  30. package/dist/components/docs/react.js +33 -2
  31. package/dist/components/editable-text/html.d.ts +2 -2
  32. package/dist/components/editing-locale-switcher/html.d.ts +2 -2
  33. package/dist/components/effect-form/react.js +343 -138
  34. package/dist/components/file-input/classes.d.ts +1 -1
  35. package/dist/components/file-input/file-type.d.ts +1 -0
  36. package/dist/components/file-input/html.d.ts +8 -1
  37. package/dist/components/file-input/html.js +170 -12
  38. package/dist/components/file-input/index.d.ts +1 -0
  39. package/dist/components/file-input/react.d.ts +9 -1
  40. package/dist/components/file-input/react.js +277 -127
  41. package/dist/components/file-input/schema.d.ts +1 -0
  42. package/dist/components/form/react.d.ts +5 -5
  43. package/dist/components/form/react.js +343 -138
  44. package/dist/components/icon-input/html.js +19 -5
  45. package/dist/components/icon-input/react.js +70 -13
  46. package/dist/components/locale-switcher/html.d.ts +2 -2
  47. package/dist/components/map-menu/html.d.ts +10 -4
  48. package/dist/components/map-menu/html.js +13 -8
  49. package/dist/components/map-menu/index.d.ts +5 -4
  50. package/dist/components/map-menu/react.d.ts +28 -17
  51. package/dist/components/map-menu/react.js +84 -178
  52. package/dist/components/map-menu/schema.d.ts +6 -0
  53. package/dist/components/map-menu/shared.d.ts +4 -0
  54. package/dist/components/permissions-input/classes.d.ts +8 -0
  55. package/dist/components/permissions-input/html.d.ts +41 -0
  56. package/dist/components/permissions-input/html.js +130 -0
  57. package/dist/components/permissions-input/index.d.ts +80 -0
  58. package/dist/components/permissions-input/react.d.ts +7 -0
  59. package/dist/components/permissions-input/react.js +201 -0
  60. package/dist/components/permissions-input/schema.d.ts +33 -0
  61. package/dist/components/phone-number-input/html.js +48 -14
  62. package/dist/components/phone-number-input/react.js +67 -10
  63. package/dist/components/presence-transition/index.d.ts +2 -2
  64. package/dist/components/search-menu/html.d.ts +2 -2
  65. package/dist/components/sidebar-layout/html.d.ts +3 -2
  66. package/dist/components/sidebar-layout/html.js +20 -2
  67. package/dist/components/sidebar-layout/index.d.ts +1 -0
  68. package/dist/components/sidebar-layout/react.js +33 -2
  69. package/dist/components/time-input/html.d.ts +2 -2
  70. package/dist/components/timezone-input/html.js +48 -14
  71. package/dist/components/timezone-input/react.js +67 -10
  72. package/dist/components/tracking-notice/html.d.ts +4 -4
  73. package/dist/components/tracking-notice/index.d.ts +2 -2
  74. package/dist/components/upload-attachment/classes.d.ts +3 -2
  75. package/dist/components/upload-attachment/html.d.ts +1 -1
  76. package/dist/components/upload-attachment/html.js +7 -5
  77. package/dist/components/upload-attachment/react.d.ts +3 -1
  78. package/dist/components/upload-attachment/react.js +25 -17
  79. package/dist/components/virtualized-combobox/classes.d.ts +12 -0
  80. package/dist/components/virtualized-combobox/html.d.ts +45 -3
  81. package/dist/components/virtualized-combobox/html.js +48 -14
  82. package/dist/components/virtualized-combobox/index.d.ts +55 -4
  83. package/dist/components/virtualized-combobox/react.d.ts +6 -2
  84. package/dist/components/virtualized-combobox/react.js +67 -10
  85. package/dist/components/virtualized-combobox/schema.d.ts +60 -4
  86. package/dist/components/webhook-delivery-table/html.js +47 -13
  87. package/dist/components/webhook-delivery-table/react.js +36 -12
  88. package/dist/lib/access/index.d.ts +61 -0
  89. package/dist/lib/access/index.js +92 -0
  90. package/dist/lib/access/table/classes.d.ts +13 -0
  91. package/dist/lib/access/table/html.d.ts +39 -0
  92. package/dist/lib/access/table/html.js +157 -0
  93. package/dist/lib/access/table/index.d.ts +32 -0
  94. package/dist/lib/access/table/react.d.ts +3 -0
  95. package/dist/lib/access/table/react.js +195 -0
  96. package/dist/lib/access/table/schema.d.ts +43 -0
  97. package/dist/lib/docs.integrations.server.js +23 -1
  98. package/dist/lib/docs.js +33 -2
  99. package/dist/lib/docs.server.js +29 -2
  100. package/dist/lib/documentation-toolkit.js +23 -1
  101. package/dist/lib/effect-ui-adapter/use-model.d.ts +1 -1
  102. package/dist/lib/effect-ui-adapter/use-model.js +19 -11
  103. package/dist/lib/lucide-effect.d.ts +19 -19
  104. package/dist/lib/lucide-effect.js +38 -38
  105. package/dist/services/assets/library.d.ts +221 -0
  106. package/dist/services/assets/schema.d.ts +3 -0
  107. package/dist/services/assets/url.d.ts +12 -0
  108. package/dist/services/assets/use-library.d.ts +20 -0
  109. package/package.json +13 -1
@@ -34,17 +34,26 @@ import { Schema as Schema2 } from "effect";
34
34
  import { Component, UiSchema } from "effect/ui";
35
35
 
36
36
  // ../../src/components/virtualized-combobox/schema.ts
37
- import { Schema, Struct } from "effect";
37
+ import { Predicate, Schema, Struct } from "effect";
38
38
 
39
39
  // ../../src/components/virtualized-combobox/classes.ts
40
40
  var virtualizedComboboxClasses = {
41
- itemLabel: "min-w-0 truncate"
41
+ itemLabel: "min-w-0 truncate",
42
+ groupLabel: "text-muted-foreground px-2 pt-3 pb-1 text-start text-xs",
43
+ itemContent: "flex min-w-0 flex-1 items-center gap-2 text-start",
44
+ itemMedia: "bg-muted grid size-8 shrink-0 place-items-center overflow-hidden rounded-md [&_svg]:size-4",
45
+ itemImage: "size-full object-cover",
46
+ itemDescription: "text-muted-foreground block truncate text-xs"
42
47
  };
43
48
 
44
49
  // ../../src/components/virtualized-combobox/schema.ts
50
+ var Icon = Schema.declare((value) => Predicate.isFunction(value)).annotate({ identifier: "VirtualizedComboboxIcon" });
45
51
  var VirtualizedComboboxOptionSchema = Schema.Struct({
46
52
  value: Schema.String.pipe(Schema.mutableKey),
47
- label: Schema.String.pipe(Schema.mutableKey)
53
+ label: Schema.String.pipe(Schema.mutableKey),
54
+ description: Schema.optionalKey(Schema.String),
55
+ imageSrc: Schema.optionalKey(Schema.String),
56
+ icon: Schema.optionalKey(Icon)
48
57
  }).annotate({ identifier: "VirtualizedComboboxOption" });
49
58
  var VirtualizedComboboxLabelsSchema = Schema.Struct({
50
59
  clear: Schema.optionalKey(Schema.String),
@@ -69,6 +78,8 @@ var htmlFields = {
69
78
  emptyLabel: Schema.String,
70
79
  placeholder: Schema.String,
71
80
  triggerLabel: Schema.optionalKey(Schema.String),
81
+ triggerIcon: Schema.optionalKey(Icon),
82
+ itemHeight: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThan(0))),
72
83
  filter: Schema.optionalKey(Schema.Literals(["contains", "none"])),
73
84
  messages: Schema.optionalKey(Schema.Record(Schema.String, Schema.Struct({
74
85
  ...VirtualizedComboboxLabelsSchema.fields,
@@ -129,7 +140,8 @@ var VirtualizedComboboxEvents = UiSchema.TaggedEnum(events).annotate({
129
140
  });
130
141
  var VirtualizedComboboxMessage = UiSchema.TaggedEnum({
131
142
  ...events,
132
- Highlighted: { value: Schema2.String }
143
+ Highlighted: { value: Schema2.String },
144
+ ImageFailed: { src: Schema2.String }
133
145
  }).annotate({ identifier: "VirtualizedComboboxMessage" });
134
146
  var virtualizedComboboxOptions = {
135
147
  name: "VirtualizedCombobox",
@@ -137,6 +149,7 @@ var virtualizedComboboxOptions = {
137
149
  model: Schema2.Struct({
138
150
  open: Schema2.Boolean,
139
151
  searchValue: Schema2.String,
152
+ failedImages: Schema2.Array(Schema2.String),
140
153
  highlight: Schema2.NullOr(Schema2.Struct({ value: Schema2.String, id: Schema2.Int }))
141
154
  }).annotate({ identifier: "VirtualizedComboboxModel" }),
142
155
  message: VirtualizedComboboxMessage,
@@ -156,7 +169,8 @@ var update = Component.define(virtualizedComboboxOptions).update({
156
169
  ValueChanged: ($, { value }) => $.set($.model).emit(VirtualizedComboboxEvents.ValueChanged({ value })),
157
170
  Highlighted: ($, { value }) => $.evolve({
158
171
  highlight: { value, id: ($.model.highlight?.id ?? 0) + 1 }
159
- })
172
+ }),
173
+ ImageFailed: ($, { src }) => $.model.failedImages.includes(src) ? $.model : $.evolve({ failedImages: [...$.model.failedImages, src] })
160
174
  });
161
175
 
162
176
  // ../../src/components/icon-input/schema.ts
@@ -1,6 +1,6 @@
1
1
  // ../../src/components/icon-input/react.tsx
2
2
  import { Component as Component3, View } from "effect/ui";
3
- import { Icon } from "@iconify/react";
3
+ import { Icon as Icon2 } from "@iconify/react";
4
4
  import { ExternalLink, Search } from "lucide-react";
5
5
  import { Button as Button2 } from "@/components/ui/button";
6
6
 
@@ -12,7 +12,8 @@ import {
12
12
  useCallback,
13
13
  useEffect,
14
14
  useImperativeHandle,
15
- useRef
15
+ useRef,
16
+ useState
16
17
  } from "react";
17
18
  import { Button } from "@/components/ui/button";
18
19
  import { InputGroup, InputGroupInput } from "@/components/ui/input-group";
@@ -25,8 +26,15 @@ import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider/reac
25
26
 
26
27
  // ../../src/components/virtualized-combobox/classes.ts
27
28
  var virtualizedComboboxClasses = {
28
- itemLabel: "min-w-0 truncate"
29
+ itemLabel: "min-w-0 truncate",
30
+ groupLabel: "text-muted-foreground px-2 pt-3 pb-1 text-start text-xs",
31
+ itemContent: "flex min-w-0 flex-1 items-center gap-2 text-start",
32
+ itemMedia: "bg-muted grid size-8 shrink-0 place-items-center overflow-hidden rounded-md [&_svg]:size-4",
33
+ itemImage: "size-full object-cover",
34
+ itemDescription: "text-muted-foreground block truncate text-xs"
29
35
  };
36
+ var virtualizedComboboxGroupHeight = 36;
37
+ var virtualizedComboboxDetailHeight = 52;
30
38
  var resolveVirtualizedComboboxClasses = (overrides) => ({
31
39
  ...virtualizedComboboxClasses,
32
40
  ...overrides
@@ -37,10 +45,14 @@ import { Schema as Schema2 } from "effect";
37
45
  import { Component, UiSchema } from "effect/ui";
38
46
 
39
47
  // ../../src/components/virtualized-combobox/schema.ts
40
- import { Schema, Struct } from "effect";
48
+ import { Predicate, Schema, Struct } from "effect";
49
+ var Icon = Schema.declare((value) => Predicate.isFunction(value)).annotate({ identifier: "VirtualizedComboboxIcon" });
41
50
  var VirtualizedComboboxOptionSchema = Schema.Struct({
42
51
  value: Schema.String.pipe(Schema.mutableKey),
43
- label: Schema.String.pipe(Schema.mutableKey)
52
+ label: Schema.String.pipe(Schema.mutableKey),
53
+ description: Schema.optionalKey(Schema.String),
54
+ imageSrc: Schema.optionalKey(Schema.String),
55
+ icon: Schema.optionalKey(Icon)
44
56
  }).annotate({ identifier: "VirtualizedComboboxOption" });
45
57
  var VirtualizedComboboxLabelsSchema = Schema.Struct({
46
58
  clear: Schema.optionalKey(Schema.String),
@@ -65,6 +77,8 @@ var htmlFields = {
65
77
  emptyLabel: Schema.String,
66
78
  placeholder: Schema.String,
67
79
  triggerLabel: Schema.optionalKey(Schema.String),
80
+ triggerIcon: Schema.optionalKey(Icon),
81
+ itemHeight: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThan(0))),
68
82
  filter: Schema.optionalKey(Schema.Literals(["contains", "none"])),
69
83
  messages: Schema.optionalKey(Schema.Record(Schema.String, Schema.Struct({
70
84
  ...VirtualizedComboboxLabelsSchema.fields,
@@ -154,7 +168,8 @@ var VirtualizedComboboxEvents = UiSchema.TaggedEnum(events).annotate({
154
168
  });
155
169
  var VirtualizedComboboxMessage = UiSchema.TaggedEnum({
156
170
  ...events,
157
- Highlighted: { value: Schema2.String }
171
+ Highlighted: { value: Schema2.String },
172
+ ImageFailed: { src: Schema2.String }
158
173
  }).annotate({ identifier: "VirtualizedComboboxMessage" });
159
174
  var virtualizedComboboxOptions = {
160
175
  name: "VirtualizedCombobox",
@@ -162,6 +177,7 @@ var virtualizedComboboxOptions = {
162
177
  model: Schema2.Struct({
163
178
  open: Schema2.Boolean,
164
179
  searchValue: Schema2.String,
180
+ failedImages: Schema2.Array(Schema2.String),
165
181
  highlight: Schema2.NullOr(Schema2.Struct({ value: Schema2.String, id: Schema2.Int }))
166
182
  }).annotate({ identifier: "VirtualizedComboboxModel" }),
167
183
  message: VirtualizedComboboxMessage,
@@ -181,17 +197,24 @@ var update = Component.define(virtualizedComboboxOptions).update({
181
197
  ValueChanged: ($, { value }) => $.set($.model).emit(VirtualizedComboboxEvents.ValueChanged({ value })),
182
198
  Highlighted: ($, { value }) => $.evolve({
183
199
  highlight: { value, id: ($.model.highlight?.id ?? 0) + 1 }
184
- })
200
+ }),
201
+ ImageFailed: ($, { src }) => $.model.failedImages.includes(src) ? $.model : $.evolve({ failedImages: [...$.model.failedImages, src] })
185
202
  });
186
203
 
187
204
  // ../../src/components/virtualized-combobox/react.tsx
188
205
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
189
206
  "use client";
190
207
  var optionEquals = (item, selected) => item.value === selected.value;
208
+ var hasOptionDetails = ({
209
+ description,
210
+ imageSrc,
211
+ icon
212
+ }) => Boolean(description || imageSrc || icon);
191
213
  var VirtualizedComboboxList = ({
192
214
  classes,
193
215
  emptyLabel,
194
216
  groupSelections,
217
+ itemHeight,
195
218
  itemIndexRef,
196
219
  locale = "en",
197
220
  messages: messageOverrides,
@@ -204,6 +227,8 @@ var VirtualizedComboboxList = ({
204
227
  const labels = virtualizedComboboxMessages(locale, messageOverrides);
205
228
  const entries = selectionEntries(filteredItems, selectedValues, groupSelections, labels);
206
229
  const scrollRef = useRef(null);
230
+ const [failedImages, setFailedImages] = useState(() => new Set);
231
+ const rowHeight = itemHeight ?? (filteredItems.some(hasOptionDetails) ? virtualizedComboboxDetailHeight : 36);
207
232
  const virtualizer = useVirtualizer({
208
233
  count: entries.length,
209
234
  getScrollElement: () => scrollRef.current,
@@ -211,7 +236,7 @@ var VirtualizedComboboxList = ({
211
236
  const entry = entries[index];
212
237
  return entry?.kind === "group" ? `group-${entry.key}` : entry?.item.value ?? index;
213
238
  },
214
- estimateSize: () => 36,
239
+ estimateSize: (index) => entries[index]?.kind === "group" ? virtualizedComboboxGroupHeight : rowHeight,
215
240
  overscan: 8
216
241
  });
217
242
  useEffect(() => {
@@ -253,7 +278,7 @@ var VirtualizedComboboxList = ({
253
278
  return /* @__PURE__ */ jsx(ComboboxPrimitive.Group, {
254
279
  className: "contents",
255
280
  children: /* @__PURE__ */ jsx(ComboboxPrimitive.GroupLabel, {
256
- className: "text-muted-foreground absolute top-0 left-0 w-full px-2 pt-3 pb-1 text-xs",
281
+ className: `absolute top-0 left-0 w-full ${virtualizedComboboxClasses.groupLabel}`,
257
282
  "data-index": virtualItem.index,
258
283
  ref: virtualizer.measureElement,
259
284
  style,
@@ -261,6 +286,8 @@ var VirtualizedComboboxList = ({
261
286
  })
262
287
  }, entry.key);
263
288
  }
289
+ const details = entry.item;
290
+ const image = details.imageSrc && !failedImages.has(details.imageSrc) ? details.imageSrc : undefined;
264
291
  return /* @__PURE__ */ jsxs(ComboboxPrimitive.Item, {
265
292
  "aria-posinset": entry.index + 1,
266
293
  "aria-setsize": filteredItems.length,
@@ -271,10 +298,38 @@ var VirtualizedComboboxList = ({
271
298
  style,
272
299
  value: entry.item,
273
300
  children: [
274
- renderItem?.(entry.item) ?? /* @__PURE__ */ jsx("span", {
301
+ renderItem?.(entry.item) ?? (hasOptionDetails(details) ? /* @__PURE__ */ jsxs("span", {
302
+ className: virtualizedComboboxClasses.itemContent,
303
+ children: [
304
+ (image || details.icon) && /* @__PURE__ */ jsx("span", {
305
+ "aria-hidden": "true",
306
+ className: virtualizedComboboxClasses.itemMedia,
307
+ children: image ? /* @__PURE__ */ jsx("img", {
308
+ src: image,
309
+ alt: "",
310
+ loading: "lazy",
311
+ onError: () => setFailedImages((failed) => new Set(failed).add(image)),
312
+ className: virtualizedComboboxClasses.itemImage
313
+ }) : details.icon
314
+ }),
315
+ /* @__PURE__ */ jsxs("span", {
316
+ className: "min-w-0 flex-1",
317
+ children: [
318
+ /* @__PURE__ */ jsx("span", {
319
+ className: cn("block", virtualizedComboboxClasses.itemLabel),
320
+ children: entry.item.label
321
+ }),
322
+ details.description && /* @__PURE__ */ jsx("span", {
323
+ className: virtualizedComboboxClasses.itemDescription,
324
+ children: details.description
325
+ })
326
+ ]
327
+ })
328
+ ]
329
+ }) : /* @__PURE__ */ jsx("span", {
275
330
  className: virtualizedComboboxClasses.itemLabel,
276
331
  children: entry.item.label
277
- }),
332
+ })),
278
333
  /* @__PURE__ */ jsx(ComboboxPrimitive.ItemIndicator, {
279
334
  className: "absolute right-2 flex size-4 items-center justify-center",
280
335
  children: /* @__PURE__ */ jsx(Check, {})
@@ -292,6 +347,7 @@ var VirtualizedComboboxContent = ({
292
347
  contentClassName,
293
348
  emptyLabel,
294
349
  groupSelections,
350
+ itemHeight,
295
351
  itemIndexRef,
296
352
  locale = "en",
297
353
  messages: messageOverrides,
@@ -323,6 +379,7 @@ var VirtualizedComboboxContent = ({
323
379
  classes,
324
380
  emptyLabel,
325
381
  groupSelections,
382
+ itemHeight,
326
383
  itemIndexRef,
327
384
  locale,
328
385
  messages: messageOverrides,
@@ -686,7 +743,7 @@ function IconInput({
686
743
  placeholder: copy.select,
687
744
  renderItem: (item) => /* @__PURE__ */ jsxs2(Fragment2, {
688
745
  children: [
689
- /* @__PURE__ */ jsx2(Icon, {
746
+ /* @__PURE__ */ jsx2(Icon2, {
690
747
  className: "size-5 shrink-0",
691
748
  icon: `${collection}:${item.value}`
692
749
  }),
@@ -709,7 +766,7 @@ function IconInput({
709
766
  title: value,
710
767
  type: "button",
711
768
  variant: "outline",
712
- children: /* @__PURE__ */ jsx2(Icon, {
769
+ children: /* @__PURE__ */ jsx2(Icon2, {
713
770
  className: "size-5",
714
771
  icon: `${collection}:${value}`
715
772
  })
@@ -10,9 +10,9 @@ export declare const LocaleSwitcher: import("effect/ui/Component").Component<"Lo
10
10
  } | undefined;
11
11
  } | undefined;
12
12
  }, boolean, {
13
- readonly _tag: "Opened";
14
- } | {
15
13
  readonly _tag: "Closed";
14
+ } | {
15
+ readonly _tag: "Opened";
16
16
  } | {
17
17
  readonly _tag: "Picked";
18
18
  readonly locale: string;
@@ -7,6 +7,9 @@ export { SaveMapSelection, mapMenuRadiiKm, type MapViewportHost, type MapViewpor
7
7
  export { MapMenuMode, MapMenuPresentation, type MapMenuHtmlProps as MapMenuProps, type MapMenuLocation, type MapMenuMessages, type MapMenuPoint, type MapMenuSelection, } from "./schema.js";
8
8
  /** Uses the browser SDK by default; a host can supply a scoped viewport adapter. */
9
9
  export declare const makeMapMenu: (viewportHost?: MapViewportHost) => import("effect/ui/Component").Component<"MapMenu", {
10
+ readonly showMap?: boolean | undefined;
11
+ readonly confirmation?: "explicit" | "selection" | undefined;
12
+ readonly showCurrentLocation?: boolean | undefined;
10
13
  readonly classes?: {
11
14
  readonly error?: string | undefined;
12
15
  readonly resultDescription?: string | undefined;
@@ -112,9 +115,9 @@ export declare const makeMapMenu: (viewportHost?: MapViewportHost) => import("ef
112
115
  readonly _tag: "ZoomChanged";
113
116
  readonly zoom: number;
114
117
  }, {
115
- readonly _tag: "Cancelled";
116
- } | {
117
118
  readonly _tag: "Confirmed";
119
+ } | {
120
+ readonly _tag: "Cancelled";
118
121
  } | {
119
122
  readonly _tag: "CurrentLocationRequested";
120
123
  } | {
@@ -140,6 +143,9 @@ export declare const makeMapMenu: (viewportHost?: MapViewportHost) => import("ef
140
143
  readonly radiusKm: number;
141
144
  }, import("./index.js").SaveMapSelection, Html.Elements, {}, never>;
142
145
  export declare const MapMenu: import("effect/ui/Component").Component<"MapMenu", {
146
+ readonly showMap?: boolean | undefined;
147
+ readonly confirmation?: "explicit" | "selection" | undefined;
148
+ readonly showCurrentLocation?: boolean | undefined;
143
149
  readonly classes?: {
144
150
  readonly error?: string | undefined;
145
151
  readonly resultDescription?: string | undefined;
@@ -245,9 +251,9 @@ export declare const MapMenu: import("effect/ui/Component").Component<"MapMenu",
245
251
  readonly _tag: "ZoomChanged";
246
252
  readonly zoom: number;
247
253
  }, {
248
- readonly _tag: "Cancelled";
249
- } | {
250
254
  readonly _tag: "Confirmed";
255
+ } | {
256
+ readonly _tag: "Cancelled";
251
257
  } | {
252
258
  readonly _tag: "CurrentLocationRequested";
253
259
  } | {
@@ -330,6 +330,9 @@ var MapMenuLocationSchema = Schema.Struct({
330
330
  }).annotate({ identifier: "MapMenuLocation" });
331
331
  var MapMenuClassesOverridesSchema = Schema.Record(Schema.Literals(Struct.keys(mapMenuClasses)), Schema.optionalKey(Schema.String)).annotate({ identifier: "MapMenuClassesOverrides" });
332
332
  var MapMenuSharedPropsSchema = Schema.Struct({
333
+ showMap: Schema.optional(Schema.Boolean),
334
+ confirmation: Schema.optional(Schema.Literals(["explicit", "selection"])),
335
+ showCurrentLocation: Schema.optional(Schema.Boolean),
333
336
  classes: Schema.optional(MapMenuClassesOverridesSchema),
334
337
  input: Schema.String,
335
338
  selectedLocation: Schema.NullOr(MapMenuLocationSchema),
@@ -368,7 +371,7 @@ var MapMenuSelectionSchema = Schema.Struct({
368
371
  radiusKm: Schema.optionalKey(Schema.Finite)
369
372
  }).annotate({ identifier: "MapMenuSelection" });
370
373
 
371
- // ../../src/components/map-menu/index.ts
374
+ // ../../src/components/map-menu/shared.ts
372
375
  var mapMenuSelectionMatches = ({
373
376
  selectedLocation,
374
377
  input
@@ -435,6 +438,8 @@ var mapMenuMessages = (locale = "en", messages) => {
435
438
  ...messages?.[locale]
436
439
  };
437
440
  };
441
+
442
+ // ../../src/components/map-menu/index.ts
438
443
  var MapMenuEvent = UiSchema.TaggedEnum({
439
444
  InputChanged: { input: Schema2.String },
440
445
  LocationSelected: { location: MapMenuLocationSchema },
@@ -491,7 +496,7 @@ var mapMenuOptions = {
491
496
  };
492
497
  var inline = (props) => props.presentation === "inline" /* Inline */;
493
498
  var visible = (props) => inline(props) || props.open === true;
494
- var mapMenuCanConfirm = (props) => visible(props) && !props.locating && mapMenuSelectionMatches(props) && (props.mode === "point" /* Point */ || props.radiusKm !== undefined);
499
+ var mapMenuCanConfirm = (props) => visible(props) && props.confirmation !== "selection" && !props.locating && mapMenuSelectionMatches(props) && (props.mode === "point" /* Point */ || props.radiusKm !== undefined);
495
500
  var update = Component.define(mapMenuOptions).update({
496
501
  Edited: ($, { input }) => $.model.save === "pending" ? $.model : $.evolve({
497
502
  suggestionsOpen: Boolean(input.trim()),
@@ -506,7 +511,7 @@ var update = Component.define(mapMenuOptions).update({
506
511
  return location ? $.evolve({ suggestionsOpen: false, save: "idle" }).emit(MapMenuEvent.InputChanged({ input: location.label })).emit(MapMenuEvent.LocationSelected({ location })) : $.model;
507
512
  },
508
513
  RadiusPicked: ($, { radiusKm }) => $.model.save === "pending" || $.props.mode === "point" /* Point */ || !($.props.radiusOptions ?? mapMenuRadiiKm).includes(radiusKm) ? $.model : $.emit(MapMenuEvent.RadiusChanged({ radiusKm })),
509
- Locate: ($) => $.model.save !== "pending" && $.props.canUseCurrentLocation && !$.props.locating ? $.evolve({ suggestionsOpen: false }).emit(MapMenuEvent.CurrentLocationRequested()) : $.model,
514
+ Locate: ($) => $.model.save !== "pending" && $.props.showCurrentLocation !== false && $.props.canUseCurrentLocation && !$.props.locating ? $.evolve({ suggestionsOpen: false }).emit(MapMenuEvent.CurrentLocationRequested()) : $.model,
510
515
  Cancel: ($) => $.model.save === "pending" ? $.model : $.evolve({ save: "idle", suggestionsOpen: false }).emit(inline($.props) ? MapMenuEvent.Cancelled() : MapMenuEvent.OpenChanged({ open: false })),
511
516
  Confirm: ($) => {
512
517
  const { selectedLocation, mode, radiusKm } = $.props;
@@ -691,19 +696,19 @@ var makeMapMenu = (viewportHost) => {
691
696
  className: "shrink-0"
692
697
  }), h.span.class("min-w-0").children(h.span.class(mapMenuClasses.resultTitle).children(place?.title ?? label), place?.details && h.span.class(mapMenuClasses.resultDescription).children(place.details)));
693
698
  })), props.loadingSuggestions ? h.p.attr("role", "status").class(mapMenuClasses.status).children(labels.loading) : props.suggestionsError ? h.p.attr("role", "alert").class(mapMenuClasses.error).children(props.suggestionsError) : ComboboxEmpty(h, box).children(labels.noResults))))
694
- })), props.canUseCurrentLocation && Button(h, {
699
+ })), props.showCurrentLocation !== false && props.canUseCurrentLocation && Button(h, {
695
700
  variant: "outline",
696
701
  props: {
697
702
  type: "button",
698
703
  disabled: pending || props.locating
699
704
  },
700
705
  onPress: MapMenuMessage.Locate()
701
- }).attr("data-slot", "map-menu-current").children(LocateIcon(h, { size: 16 }), labels.currentLocation)), notice && h.p.attrs({
706
+ }).attr("data-slot", "map-menu-current").children(LocateIcon(h, { size: 16 }), labels.currentLocation)), (props.showMap !== false || props.provenance) && notice && h.p.attrs({
702
707
  role: "status",
703
708
  "data-slot": "map-menu-provenance"
704
709
  }).class("flex items-start gap-2 text-xs text-muted-foreground").children(Pin(h, { size: 16 }), notice), radiusEnabled && h.label.class("flex items-center gap-3 text-sm font-medium").children(labels.searchWithin, h.select.class(inputVariants({
705
710
  class: "w-auto disabled:opacity-50"
706
- })).disabled(pending).value(String(props.radiusKm ?? "")).on("change", ({ value }) => MapMenuMessage.RadiusPicked({ radiusKm: Number(value) })).children((props.radiusOptions ?? mapMenuRadiiKm).map((option) => h.option.key(String(option)).attr("value", String(option)).children(`${option} Km`))))), showCanvas && h.div.attr("data-slot", "map-menu-map").class(isInline ? "relative h-80 shrink-0 sm:h-96" : "relative min-h-56 flex-1 basis-56").children(h.div.attr("data-slot", "map-menu-renderer").class("relative isolate h-full min-w-0 overflow-hidden rounded-md border bg-muted").children(h.div.attrs({
711
+ })).disabled(pending).value(String(props.radiusKm ?? "")).on("change", ({ value }) => MapMenuMessage.RadiusPicked({ radiusKm: Number(value) })).children((props.radiusOptions ?? mapMenuRadiiKm).map((option) => h.option.key(String(option)).attr("value", String(option)).children(`${option} Km`))))), props.showMap !== false && showCanvas && h.div.attr("data-slot", "map-menu-map").class(isInline ? "relative h-80 shrink-0 sm:h-96" : "relative min-h-56 flex-1 basis-56").children(h.div.attr("data-slot", "map-menu-renderer").class("relative isolate h-full min-w-0 overflow-hidden rounded-md border bg-muted").children(h.div.attrs({
707
712
  "data-slot": "map-menu-canvas",
708
713
  role: "region",
709
714
  "aria-label": mapLabels.map
@@ -715,12 +720,12 @@ var makeMapMenu = (viewportHost) => {
715
720
  overlayColor: color
716
721
  },
717
722
  camera: model.camera
718
- })), model.mapStatus === "ready" && h.div.attr("data-slot", "map-menu-controls").class("absolute top-3 right-3 z-10 grid divide-y overflow-hidden rounded-md border bg-card shadow-md").children(radius !== null && cameraButton("fit", LocateIcon), cameraButton("in", ZoomIn, model.zoom !== null && model.zoom >= mapZoomBounds.max), cameraButton("out", ZoomOut, model.zoom !== null && model.zoom <= mapZoomBounds.min)), model.mapStatus === "loading" && h.div.attr("role", "status").class("absolute inset-0 grid place-items-center bg-background/75 text-sm text-muted-foreground").children(mapLabels.loading), (model.mapStatus === "configuration" || model.mapStatus === "load") && h.div.attr("role", "alert").class("absolute inset-0 grid place-content-center gap-2 bg-background/85 p-6 text-center").children(h.strong.children(mapLabels.unavailable), h.p.class("text-xs text-muted-foreground").children(model.mapStatus === "configuration" ? mapLabels.key : mapLabels.failed)), radius !== null && h.p.class("pointer-events-none absolute bottom-7 left-3 rounded bg-card px-2.5 py-1.5 text-xs text-muted-foreground shadow-sm").children(labels.radiusHint))), h.div.class("flex shrink-0 flex-wrap items-center justify-end gap-2").children((props.error || model.save === "failed") && h.p.attr("role", "alert").class("me-auto text-sm text-destructive").children(props.error ?? labels.confirmError), Button(h, {
723
+ })), model.mapStatus === "ready" && h.div.attr("data-slot", "map-menu-controls").class("absolute top-3 right-3 z-10 grid divide-y overflow-hidden rounded-md border bg-card shadow-md").children(radius !== null && cameraButton("fit", LocateIcon), cameraButton("in", ZoomIn, model.zoom !== null && model.zoom >= mapZoomBounds.max), cameraButton("out", ZoomOut, model.zoom !== null && model.zoom <= mapZoomBounds.min)), model.mapStatus === "loading" && h.div.attr("role", "status").class("absolute inset-0 grid place-items-center bg-background/75 text-sm text-muted-foreground").children(mapLabels.loading), (model.mapStatus === "configuration" || model.mapStatus === "load") && h.div.attr("role", "alert").class("absolute inset-0 grid place-content-center gap-2 bg-background/85 p-6 text-center").children(h.strong.children(mapLabels.unavailable), h.p.class("text-xs text-muted-foreground").children(model.mapStatus === "configuration" ? mapLabels.key : mapLabels.failed)), radius !== null && h.p.class("pointer-events-none absolute bottom-7 left-3 rounded bg-card px-2.5 py-1.5 text-xs text-muted-foreground shadow-sm").children(labels.radiusHint))), h.div.class("flex shrink-0 flex-wrap items-center justify-end gap-2").children((props.error || model.save === "failed") && h.p.attr("role", "alert").class("me-auto text-sm text-destructive").children(props.error ?? labels.confirmError), props.confirmation !== "selection" && Button(h, {
719
724
  variant: "outline",
720
725
  class: "min-h-11",
721
726
  props: { type: "button", disabled: pending },
722
727
  onPress: MapMenuMessage.Cancel()
723
- }).children(labels.cancel), Button(h, {
728
+ }).children(labels.cancel), props.confirmation !== "selection" && Button(h, {
724
729
  class: `min-h-11 ${props.confirmClassName ?? ""}`,
725
730
  loading: pending,
726
731
  props: {
@@ -1,8 +1,7 @@
1
1
  import { Effect, Redacted, Schema, type Scope, type Stream } from "effect";
2
2
  import { Command, Component, UiSchema } from "effect/ui";
3
- import { MapMenuHtmlPropsSchema, MapMenuMode, MapMenuPresentation, MapMenuSelectionSchema, type MapMenuMessages, type MapMenuSharedProps, type MapMenuViewport } from "./schema.js";
4
- export declare const mapMenuSelectionMatches: ({ selectedLocation, input, }: Pick<MapMenuSharedProps, "selectedLocation" | "input">) => boolean;
5
- export declare const mapMenuRadiiKm: readonly [1, 2, 5, 10, 20, 40, 50, 60, 80, 100, 250, 500];
3
+ import { MapMenuHtmlPropsSchema, MapMenuMode, MapMenuPresentation, MapMenuSelectionSchema, type MapMenuViewport } from "./schema.js";
4
+ export * from "./shared.js";
6
5
  /** The HTML renderer acquires this resource against its mounted element. */
7
6
  export interface MapViewportHost {
8
7
  readonly mount: (container: HTMLElement) => Effect.Effect<MapViewport, MapViewportFailure, Scope.Scope>;
@@ -20,7 +19,6 @@ export type MapViewportFailure = {
20
19
  readonly _tag: "MapViewportFailure";
21
20
  readonly reason: "load" | "configuration";
22
21
  };
23
- export declare const mapMenuMessages: (locale?: string, messages?: MapMenuSharedProps["messages"]) => MapMenuMessages;
24
22
  export declare const MapMenuEvent: UiSchema.TaggedEnum<{
25
23
  readonly Cancelled: Schema.TaggedStruct<"Cancelled", {}>;
26
24
  readonly Confirmed: Schema.TaggedStruct<"Confirmed", {}>;
@@ -128,6 +126,9 @@ declare const CameraRequest: Schema.Struct<{
128
126
  export declare const mapMenuOptions: {
129
127
  readonly name: "MapMenu";
130
128
  readonly props: Schema.Struct<{
129
+ readonly showMap: Schema.optional<Schema.Boolean>;
130
+ readonly confirmation: Schema.optional<Schema.Literals<readonly ["explicit", "selection"]>>;
131
+ readonly showCurrentLocation: Schema.optional<Schema.Boolean>;
131
132
  readonly classes: Schema.optional<Schema.$Record<Schema.Literals<("error" | "resultDescription" | "resultTitle" | "status")[]>, Schema.optionalKey<Schema.String>>>;
132
133
  readonly input: Schema.String;
133
134
  readonly selectedLocation: Schema.NullOr<Schema.Struct<{
@@ -1,40 +1,51 @@
1
1
  import { MapMenuMode, MapMenuPresentation, type MapMenuLocation, type MapMenuSharedProps } from "./schema.js";
2
- export { mapMenuRadiiKm } from "./index.js";
2
+ export { mapMenuRadiiKm } from "./shared.js";
3
3
  export { MapMenuMode, MapMenuPresentation } from "./schema.js";
4
4
  export type { MapMenuLocation, MapMenuMessages, MapMenuPoint } from "./schema.js";
5
- type MapMenuCommonProps = MapMenuSharedProps & {
6
- apiKey: string;
5
+ type Suggestion = Pick<MapMenuLocation, "id" | "label" | "title" | "details">;
6
+ type MapMenuCommonProps<T extends Suggestion> = Omit<MapMenuSharedProps, "suggestions"> & {
7
+ suggestions: readonly T[];
8
+ suggestionAttribution?: string;
9
+ apiKey?: string | undefined;
7
10
  onInputChange: (input: string) => void;
8
- onSelectLocation: (location: MapMenuLocation) => void;
11
+ onSelectLocation: (location: T) => void;
9
12
  onUseCurrentLocation?: (() => void) | undefined;
10
13
  };
11
- export type MapMenuProps = MapMenuCommonProps & ({
14
+ type Confirmation<Selection> = {
15
+ onConfirm: (selection: Selection) => void | Promise<void>;
16
+ } | {
17
+ confirmation: "selection";
18
+ onConfirm?: never;
19
+ };
20
+ export type MapMenuProps<T extends Suggestion = MapMenuLocation> = MapMenuCommonProps<T> & ({
12
21
  presentation?: MapMenuPresentation.Dialog | undefined;
13
22
  open: boolean;
14
23
  onOpenChange: (open: boolean) => void;
15
24
  onCancel?: never;
16
- } | {
25
+ } | ({
17
26
  presentation: MapMenuPresentation.Inline;
18
27
  open?: never;
19
28
  onOpenChange?: never;
29
+ } & ({
20
30
  onCancel: () => void;
21
- }) & ({
31
+ } | {
32
+ confirmation: "selection";
33
+ onCancel?: never;
34
+ }))) & (({
22
35
  mode: MapMenuMode.Point;
23
36
  radiusKm?: never;
24
37
  onRadiusChange?: never;
25
38
  radiusOptions?: never;
26
- onConfirm: (selection: {
27
- location: MapMenuLocation;
28
- }) => void | Promise<void>;
29
- } | {
39
+ } & Confirmation<{
40
+ location: MapMenuLocation;
41
+ }>) | ({
30
42
  mode?: MapMenuMode.Radius | undefined;
31
43
  radiusKm: number;
32
44
  onRadiusChange: (radiusKm: number) => void;
33
45
  radiusOptions?: readonly number[] | undefined;
34
- onConfirm: (selection: {
35
- location: MapMenuLocation;
36
- radiusKm: number;
37
- }) => void | Promise<void>;
38
- });
46
+ } & Confirmation<{
47
+ location: MapMenuLocation;
48
+ radiusKm: number;
49
+ }>));
39
50
  /** Controlled picker: the host owns lookup, location acquisition and persisted state. */
40
- export declare const MapMenu: (props: MapMenuProps) => import("react").JSX.Element;
51
+ export declare const MapMenu: <T extends Suggestion = MapMenuLocation>(props: MapMenuProps<T>) => import("react").JSX.Element;