@algenium/blocks 1.14.1 → 1.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import * as React7 from 'react';
3
3
  import { createContext, useContext, useState, useCallback, useEffect, useRef, useMemo, useId } from 'react';
4
- import { Loader2, AlertTriangle, Inbox, CheckIcon, CircleIcon, ChevronRightIcon, Monitor, Sun, Moon, Building2, ChevronsUpDown, Check, Plus, Languages, FlaskConical, X, Upload, Move, ZoomOut, ZoomIn, RotateCcw, RotateCw, Grid3X3, RefreshCw, XIcon, User, Pencil, Bell, CheckCheck, XCircle, CheckCircle, Info, Trash2, Clock, MapPin, Link, CalendarDays, ExternalLink, ChevronLeft, ChevronRight, HelpCircle, MessageSquare, Wifi, WifiOff, FileIcon, Download, Paperclip, Send, ArrowLeft, Search, Flag, Hash, Lightbulb, Trophy, Plane, Apple, Leaf, Hand, Smile, Play, AlertCircle, VolumeX, Pause, Volume1, Volume2, Settings, PictureInPicture2, Minimize, Maximize, CreditCard, CheckCircle2, BadgeCheck } from 'lucide-react';
4
+ import { Loader2, AlertTriangle, Inbox, CheckIcon, CircleIcon, ChevronRightIcon, Monitor, Sun, Moon, Building2, ChevronsUpDown, Check, Plus, Languages, FlaskConical, X, Upload, Move, ZoomOut, ZoomIn, RotateCcw, RotateCw, Grid3X3, RefreshCw, XIcon, User, Pencil, Bell, CheckCheck, XCircle, CheckCircle, Info, Trash2, Clock, MapPin, Link, CalendarDays, ExternalLink, ChevronLeft, ChevronRight, HelpCircle, MessageSquare, Wifi, WifiOff, FileIcon, Download, Paperclip, Send, ArrowLeft, Search, Flag, Hash, Lightbulb, Trophy, Plane, Apple, Leaf, Hand, Smile, Play, AlertCircle, VolumeX, Pause, Volume1, Volume2, Settings, PictureInPicture2, Minimize, Maximize, SearchIcon, CreditCard, CheckCircle2, BadgeCheck } from 'lucide-react';
5
5
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
6
6
  import { useTheme } from 'next-themes';
7
7
  import { AnimatePresence, motion } from 'framer-motion';
@@ -16,6 +16,7 @@ import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
16
16
  import * as TooltipPrimitive from '@radix-ui/react-tooltip';
17
17
  import { startOfMonth, endOfMonth, eachDayOfInterval, endOfWeek, startOfWeek, format, isSameDay, subMonths, addMonths } from 'date-fns';
18
18
  import { DayPicker } from 'react-day-picker';
19
+ import { Command as Command$1 } from 'cmdk';
19
20
  import valid from 'card-validator';
20
21
 
21
22
  var CalendarContext = createContext(null);
@@ -3871,7 +3872,7 @@ function LanguageSwitcher({
3871
3872
  const onLanguageChange = propOnLanguageChange ?? context?.setLanguage;
3872
3873
  const sizes = sizeClasses2[size];
3873
3874
  const shapeClass = shapeClasses2[shape];
3874
- const defaultLabels5 = {
3875
+ const defaultLabels6 = {
3875
3876
  language: labels.language ?? "Language"
3876
3877
  };
3877
3878
  if (variant === "mini") {
@@ -3881,7 +3882,7 @@ function LanguageSwitcher({
3881
3882
  {
3882
3883
  variant: "ghost",
3883
3884
  size: "icon",
3884
- "aria-label": defaultLabels5.language,
3885
+ "aria-label": defaultLabels6.language,
3885
3886
  className: cn(sizes.buttonMini, shapeClass, className),
3886
3887
  children: /* @__PURE__ */ jsx(Languages, { className: sizes.iconMini })
3887
3888
  }
@@ -9161,6 +9162,342 @@ function useDebouncedValueStrict(value, delayMs) {
9161
9162
  }, [value, delayMs]);
9162
9163
  return debounced;
9163
9164
  }
9165
+ function Command({
9166
+ className,
9167
+ ...props
9168
+ }) {
9169
+ return /* @__PURE__ */ jsx(
9170
+ Command$1,
9171
+ {
9172
+ "data-slot": "command",
9173
+ className: cn(
9174
+ "flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
9175
+ className
9176
+ ),
9177
+ ...props
9178
+ }
9179
+ );
9180
+ }
9181
+ function CommandDialog({
9182
+ title = "Command Palette",
9183
+ description = "Search for a command to run...",
9184
+ children,
9185
+ className,
9186
+ showCloseButton = true,
9187
+ commandProps,
9188
+ ...props
9189
+ }) {
9190
+ return /* @__PURE__ */ jsxs(Dialog, { ...props, children: [
9191
+ /* @__PURE__ */ jsxs(DialogHeader, { className: "sr-only", children: [
9192
+ /* @__PURE__ */ jsx(DialogTitle, { children: title }),
9193
+ /* @__PURE__ */ jsx(DialogDescription, { children: description })
9194
+ ] }),
9195
+ /* @__PURE__ */ jsx(
9196
+ DialogContent,
9197
+ {
9198
+ className: cn("overflow-hidden p-0", className),
9199
+ showCloseButton,
9200
+ children: /* @__PURE__ */ jsx(
9201
+ Command,
9202
+ {
9203
+ className: "**:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",
9204
+ ...commandProps,
9205
+ children
9206
+ }
9207
+ )
9208
+ }
9209
+ )
9210
+ ] });
9211
+ }
9212
+ function CommandInput({
9213
+ className,
9214
+ ...props
9215
+ }) {
9216
+ return /* @__PURE__ */ jsxs(
9217
+ "div",
9218
+ {
9219
+ "data-slot": "command-input-wrapper",
9220
+ className: "flex h-9 items-center gap-2 border-b px-3",
9221
+ children: [
9222
+ /* @__PURE__ */ jsx(SearchIcon, { className: "size-4 shrink-0 opacity-50" }),
9223
+ /* @__PURE__ */ jsx(
9224
+ Command$1.Input,
9225
+ {
9226
+ "data-slot": "command-input",
9227
+ className: cn(
9228
+ "flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
9229
+ className
9230
+ ),
9231
+ ...props
9232
+ }
9233
+ )
9234
+ ]
9235
+ }
9236
+ );
9237
+ }
9238
+ function CommandList({
9239
+ className,
9240
+ ...props
9241
+ }) {
9242
+ return /* @__PURE__ */ jsx(
9243
+ Command$1.List,
9244
+ {
9245
+ "data-slot": "command-list",
9246
+ className: cn(
9247
+ "max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",
9248
+ className
9249
+ ),
9250
+ ...props
9251
+ }
9252
+ );
9253
+ }
9254
+ function CommandEmpty({
9255
+ ...props
9256
+ }) {
9257
+ return /* @__PURE__ */ jsx(
9258
+ Command$1.Empty,
9259
+ {
9260
+ "data-slot": "command-empty",
9261
+ className: "py-6 text-center text-sm",
9262
+ ...props
9263
+ }
9264
+ );
9265
+ }
9266
+ function CommandGroup({
9267
+ className,
9268
+ ...props
9269
+ }) {
9270
+ return /* @__PURE__ */ jsx(
9271
+ Command$1.Group,
9272
+ {
9273
+ "data-slot": "command-group",
9274
+ className: cn(
9275
+ "overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
9276
+ className
9277
+ ),
9278
+ ...props
9279
+ }
9280
+ );
9281
+ }
9282
+ function CommandSeparator({
9283
+ className,
9284
+ ...props
9285
+ }) {
9286
+ return /* @__PURE__ */ jsx(
9287
+ Command$1.Separator,
9288
+ {
9289
+ "data-slot": "command-separator",
9290
+ className: cn("-mx-1 h-px bg-border", className),
9291
+ ...props
9292
+ }
9293
+ );
9294
+ }
9295
+ function CommandItem({
9296
+ className,
9297
+ ...props
9298
+ }) {
9299
+ return /* @__PURE__ */ jsx(
9300
+ Command$1.Item,
9301
+ {
9302
+ "data-slot": "command-item",
9303
+ className: cn(
9304
+ "relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground",
9305
+ className
9306
+ ),
9307
+ ...props
9308
+ }
9309
+ );
9310
+ }
9311
+ function CommandShortcut({
9312
+ className,
9313
+ ...props
9314
+ }) {
9315
+ return /* @__PURE__ */ jsx(
9316
+ "span",
9317
+ {
9318
+ "data-slot": "command-shortcut",
9319
+ className: cn(
9320
+ "ml-auto text-xs tracking-widest text-muted-foreground",
9321
+ className
9322
+ ),
9323
+ ...props
9324
+ }
9325
+ );
9326
+ }
9327
+
9328
+ // src/components/search/fuzzy.ts
9329
+ function normalize(value) {
9330
+ return value.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "");
9331
+ }
9332
+ function fuzzyMatch(query, target) {
9333
+ const q = normalize(query.trim());
9334
+ if (!q) return true;
9335
+ const t = normalize(target);
9336
+ if (t.includes(q)) return true;
9337
+ let qi = 0;
9338
+ for (let ti = 0; ti < t.length && qi < q.length; ti++) {
9339
+ if (t[ti] === q[qi]) qi++;
9340
+ }
9341
+ return qi === q.length;
9342
+ }
9343
+ var defaultLabels5 = {
9344
+ placeholder: "Buscar en toda la plataforma\u2026",
9345
+ dialogTitle: "Buscar",
9346
+ dialogDescription: "Busca funcionalidades, eventos, documentos y m\xE1s",
9347
+ loading: "Buscando\u2026",
9348
+ empty: "No se encontraron resultados",
9349
+ error: "No se pudo completar la b\xFAsqueda",
9350
+ featuresGroup: "Funcionalidades",
9351
+ defaultResultsGroup: "Resultados"
9352
+ };
9353
+ function groupHitsByType(hits) {
9354
+ const order = [];
9355
+ const byType = /* @__PURE__ */ new Map();
9356
+ for (const hit of hits) {
9357
+ if (!byType.has(hit.type)) {
9358
+ byType.set(hit.type, []);
9359
+ order.push(hit.type);
9360
+ }
9361
+ byType.get(hit.type)?.push(hit);
9362
+ }
9363
+ return order.map((type) => [type, byType.get(type) ?? []]);
9364
+ }
9365
+ function SearchCommand({
9366
+ open,
9367
+ onOpenChange,
9368
+ fetchResults,
9369
+ onSelect,
9370
+ features = [],
9371
+ typeLabels,
9372
+ labels: userLabels,
9373
+ minQueryLength = 2,
9374
+ debounceMs = 200,
9375
+ className
9376
+ }) {
9377
+ const labels = { ...defaultLabels5, ...userLabels };
9378
+ const [query, setQuery] = useState("");
9379
+ const [hits, setHits] = useState([]);
9380
+ const [isLoading, setIsLoading] = useState(false);
9381
+ const [hasError, setHasError] = useState(false);
9382
+ const debouncedQuery = useDebouncedValue(query, debounceMs);
9383
+ const requestIdRef = useRef(0);
9384
+ useEffect(() => {
9385
+ if (!open) {
9386
+ setQuery("");
9387
+ setHits([]);
9388
+ setHasError(false);
9389
+ }
9390
+ }, [open]);
9391
+ useEffect(() => {
9392
+ const trimmed = debouncedQuery.trim();
9393
+ if (trimmed.length < minQueryLength) {
9394
+ setHits([]);
9395
+ setHasError(false);
9396
+ setIsLoading(false);
9397
+ return;
9398
+ }
9399
+ const requestId = ++requestIdRef.current;
9400
+ setIsLoading(true);
9401
+ setHasError(false);
9402
+ fetchResults(trimmed).then((result) => {
9403
+ if (requestIdRef.current !== requestId) return;
9404
+ setHits(result);
9405
+ }).catch(() => {
9406
+ if (requestIdRef.current !== requestId) return;
9407
+ setHits([]);
9408
+ setHasError(true);
9409
+ }).finally(() => {
9410
+ if (requestIdRef.current !== requestId) return;
9411
+ setIsLoading(false);
9412
+ });
9413
+ }, [debouncedQuery, minQueryLength, fetchResults]);
9414
+ const filteredFeatures = useMemo(() => {
9415
+ if (!query.trim()) return features;
9416
+ return features.filter(
9417
+ (feature) => fuzzyMatch(query, feature.label) || feature.keywords?.some((keyword) => fuzzyMatch(query, keyword))
9418
+ );
9419
+ }, [features, query]);
9420
+ const groupedHits = useMemo(() => groupHitsByType(hits), [hits]);
9421
+ function handleSelect(selection) {
9422
+ onSelect(selection);
9423
+ onOpenChange(false);
9424
+ }
9425
+ const hasAnyResults = filteredFeatures.length > 0 || hits.length > 0;
9426
+ return /* @__PURE__ */ jsxs(
9427
+ CommandDialog,
9428
+ {
9429
+ open,
9430
+ onOpenChange,
9431
+ title: labels.dialogTitle,
9432
+ description: labels.dialogDescription,
9433
+ className,
9434
+ commandProps: { shouldFilter: false },
9435
+ children: [
9436
+ /* @__PURE__ */ jsx(
9437
+ CommandInput,
9438
+ {
9439
+ placeholder: labels.placeholder,
9440
+ value: query,
9441
+ onValueChange: setQuery
9442
+ }
9443
+ ),
9444
+ /* @__PURE__ */ jsxs(CommandList, { children: [
9445
+ isLoading ? /* @__PURE__ */ jsx("div", { className: "py-6 text-center text-sm text-muted-foreground", children: labels.loading }) : null,
9446
+ hasError && !isLoading ? /* @__PURE__ */ jsx("div", { className: "py-6 text-center text-sm text-destructive", children: labels.error }) : null,
9447
+ !isLoading && !hasError && !hasAnyResults ? /* @__PURE__ */ jsx(CommandEmpty, { children: labels.empty }) : null,
9448
+ filteredFeatures.length > 0 ? /* @__PURE__ */ jsx(CommandGroup, { heading: labels.featuresGroup, children: filteredFeatures.map((feature) => /* @__PURE__ */ jsxs(
9449
+ CommandItem,
9450
+ {
9451
+ value: feature.id,
9452
+ onSelect: () => handleSelect({ kind: "feature", feature }),
9453
+ children: [
9454
+ feature.icon,
9455
+ /* @__PURE__ */ jsx("span", { children: feature.label })
9456
+ ]
9457
+ },
9458
+ feature.id
9459
+ )) }) : null,
9460
+ !isLoading && groupedHits.map(([type, typeHits]) => /* @__PURE__ */ jsx(
9461
+ CommandGroup,
9462
+ {
9463
+ heading: typeLabels?.[type] ?? labels.defaultResultsGroup,
9464
+ children: typeHits.map((hit) => /* @__PURE__ */ jsx(
9465
+ CommandItem,
9466
+ {
9467
+ value: hit.id,
9468
+ onSelect: () => handleSelect({ kind: "hit", hit }),
9469
+ children: /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 flex-col", children: [
9470
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: hit.title }),
9471
+ hit.snippet ? /* @__PURE__ */ jsx("span", { className: "truncate text-xs text-muted-foreground", children: hit.snippet }) : null
9472
+ ] })
9473
+ },
9474
+ hit.id
9475
+ ))
9476
+ },
9477
+ type
9478
+ ))
9479
+ ] })
9480
+ ]
9481
+ }
9482
+ );
9483
+ }
9484
+ function useSearchHotkey(options = {}) {
9485
+ const { defaultOpen = false, disabled = false } = options;
9486
+ const [open, setOpen] = useState(defaultOpen);
9487
+ const toggle = useCallback(() => setOpen((prev) => !prev), []);
9488
+ useEffect(() => {
9489
+ if (disabled) return;
9490
+ function handleKeyDown(event) {
9491
+ if (event.key.toLowerCase() !== "k") return;
9492
+ if (!event.metaKey && !event.ctrlKey) return;
9493
+ event.preventDefault();
9494
+ setOpen((prev) => !prev);
9495
+ }
9496
+ window.addEventListener("keydown", handleKeyDown);
9497
+ return () => window.removeEventListener("keydown", handleKeyDown);
9498
+ }, [disabled]);
9499
+ return { open, setOpen, toggle };
9500
+ }
9164
9501
  function onlyDigits(s, max) {
9165
9502
  return s.replace(/\D/g, "").slice(0, max);
9166
9503
  }
@@ -10101,6 +10438,6 @@ function VerifiedProfessionalBadge({
10101
10438
  );
10102
10439
  }
10103
10440
 
10104
- export { AvatarEditor, AvatarEditorDialog, BLOCKS_DATA_ENVIRONMENTS, Button, CalendarContext, CalendarSubscribeButton, CalendarView, CalendarWidget, CardInput, ChatRoomView, ChatSidebar, ChatSidebarContext, ChatSidebarProvider, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EmojiPicker, EmojiPickerPopover, EmptyState, EnvironmentBanner, EnvironmentContext, EnvironmentDot, EnvironmentMiniBadge, EnvironmentSwitcher, ErrorState, EventDialog, EventRsvpBadge, LanguageContext, LanguageSwitcher, LoadingState, MEXICO_STATES, MEXICO_STATE_PATHS, MexicoMap, MiniCalendar, NotificationsContext, NotificationsWidget, OrgSwitcher, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, ScrollArea, ScrollBar, Slider, ThemeSwitcher, Toggle, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, USAddressInput, UpcomingEvents, VerifiedProfessionalBadge, VideoPlayer, buttonVariants, cn, createLiveHlsConfig, createVodHlsConfig, defaultLanguages, describePlaybackError, getEnvironmentDotClass, getEnvironmentLabel, isBlocksDataEnvironment, normalizeEmojiQuery, shouldRetryLiveEdge404, toggleVariants, useCalendarContext, useChatRoom, useChatSidebar, useDebouncedValue, useDebouncedValueStrict, useEnvironmentContext, useHlsPlayback, useLanguageContext, useNotificationsContext, usePlaybackStats };
10441
+ export { AvatarEditor, AvatarEditorDialog, BLOCKS_DATA_ENVIRONMENTS, Button, CalendarContext, CalendarSubscribeButton, CalendarView, CalendarWidget, CardInput, ChatRoomView, ChatSidebar, ChatSidebarContext, ChatSidebarProvider, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EmojiPicker, EmojiPickerPopover, EmptyState, EnvironmentBanner, EnvironmentContext, EnvironmentDot, EnvironmentMiniBadge, EnvironmentSwitcher, ErrorState, EventDialog, EventRsvpBadge, LanguageContext, LanguageSwitcher, LoadingState, MEXICO_STATES, MEXICO_STATE_PATHS, MexicoMap, MiniCalendar, NotificationsContext, NotificationsWidget, OrgSwitcher, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, ScrollArea, ScrollBar, SearchCommand, Slider, ThemeSwitcher, Toggle, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, USAddressInput, UpcomingEvents, VerifiedProfessionalBadge, VideoPlayer, buttonVariants, cn, createLiveHlsConfig, createVodHlsConfig, defaultLanguages, describePlaybackError, fuzzyMatch, getEnvironmentDotClass, getEnvironmentLabel, isBlocksDataEnvironment, normalizeEmojiQuery, shouldRetryLiveEdge404, toggleVariants, useCalendarContext, useChatRoom, useChatSidebar, useDebouncedValue, useDebouncedValueStrict, useEnvironmentContext, useHlsPlayback, useLanguageContext, useNotificationsContext, usePlaybackStats, useSearchHotkey };
10105
10442
  //# sourceMappingURL=index.js.map
10106
10443
  //# sourceMappingURL=index.js.map