@aircall/ds 0.31.4 → 0.34.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/globals.css +1 -1
- package/dist/index.d.ts +462 -194
- package/dist/index.js +1975 -435
- package/dist/theme.css +28 -0
- package/package.json +14 -2
- package/skills/aircall-ds/migrate-tractor/data-table/SKILL.md +62 -2
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { createContext, useCallback, useContext, useSyncExternalStore } from "re
|
|
|
3
3
|
import { Accordion as Accordion$1 } from "@base-ui/react/accordion";
|
|
4
4
|
import { clsx } from "clsx";
|
|
5
5
|
import { extendTailwindMerge } from "tailwind-merge";
|
|
6
|
-
import { ArrowDownToLine, ArrowLeft, ArrowRight, Backward10, CalendarDaysIcon, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, ChevronsUpDownIcon, CircleAlert, CircleAlertIcon, CircleCheck, FLAGS, FastForward, FlagUs, Forward10, Info, Loader2Icon, Minus, MinusIcon, MoreHorizontalIcon, PanelLeftIcon, Pause, Play, Plus, PlusIcon, Rewind, RotateCcw, Search, Smile, TriangleAlertIcon, XIcon } from "@aircall/react-icons";
|
|
6
|
+
import { ArrowDownToLine, ArrowLeft, ArrowRight, Backward10, Bold, CalendarDaysIcon, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, ChevronsUpDownIcon, CircleAlert, CircleAlertIcon, CircleCheck, Code, ExternalLink, FLAGS, FastForward, FlagUs, Forward10, Info, Italic, Link, List as List$1, ListOrdered, Loader2Icon, Minus, MinusIcon, MoreHorizontalIcon, PanelLeftIcon, Pause, Play, Plus, PlusIcon, Rewind, RotateCcw, Search, Smile, Strikethrough, Text, TriangleAlertIcon, Underline, Unlink, XIcon } from "@aircall/react-icons";
|
|
7
7
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
import { Button as Button$1 } from "@base-ui/react/button";
|
|
9
9
|
import { cva } from "class-variance-authority";
|
|
@@ -40,13 +40,30 @@ import { PreviewCard } from "@base-ui/react/preview-card";
|
|
|
40
40
|
import { NumberField } from "@base-ui/react/number-field";
|
|
41
41
|
import { OTPInput, OTPInputContext } from "input-otp";
|
|
42
42
|
import { Progress as Progress$1 } from "@base-ui/react/progress";
|
|
43
|
+
import { BoldRules, CodeRules, ItalicRules, StrikethroughRules } from "@platejs/basic-nodes";
|
|
44
|
+
import { BasicMarksPlugin, BoldPlugin, CodePlugin, ItalicPlugin, StrikethroughPlugin } from "@platejs/basic-nodes/react";
|
|
45
|
+
import { filterWords, withTriggerCombobox } from "@platejs/combobox";
|
|
46
|
+
import { IndentPlugin } from "@platejs/indent/react";
|
|
47
|
+
import { LinkRules, getLinkAttributes, upsertLink, validateUrl } from "@platejs/link";
|
|
48
|
+
import { FloatingLinkUrlInput, LinkPlugin, useFloatingLinkEdit, useFloatingLinkEditState, useFloatingLinkInsert, useFloatingLinkInsertState, useLinkToolbarButton, useLinkToolbarButtonState } from "@platejs/link/react";
|
|
49
|
+
import { ListPlugin, useListToolbarButton, useListToolbarButtonState } from "@platejs/list/react";
|
|
50
|
+
import { MarkdownPlugin } from "@platejs/markdown";
|
|
51
|
+
import { getMentionOnSelectItem } from "@platejs/mention";
|
|
52
|
+
import { MentionInputPlugin, MentionPlugin } from "@platejs/mention/react";
|
|
53
|
+
import { SlashInputPlugin, SlashPlugin } from "@platejs/slash-command/react";
|
|
54
|
+
import { KEYS, createSlatePlugin, createTSlatePlugin } from "platejs";
|
|
55
|
+
import { Plate, PlateContent, PlateElement, createPlatePlugin, toPlatePlugin, useComposedRef, useEditorId, useEditorReadOnly, useEditorRef, useEditorSelection, useEventEditorValue, useFocused, useMarkToolbarButton, useMarkToolbarButtonState, usePlateEditor, usePluginOption, useReadOnly, useSelected } from "platejs/react";
|
|
56
|
+
import remarkGfm from "remark-gfm";
|
|
57
|
+
import { Combobox as Combobox$2, ComboboxGroup as ComboboxGroup$1, ComboboxItem as ComboboxItem$1, ComboboxPopover, ComboboxProvider, Portal, useComboboxContext, useComboboxStore, useStoreState } from "@ariakit/react";
|
|
58
|
+
import { useComboboxInput, useHTMLInputCursorState } from "@platejs/combobox/react";
|
|
59
|
+
import { flip, offset, shift, useFloatingToolbar, useFloatingToolbarState } from "@platejs/floating";
|
|
60
|
+
import { ListStyleType } from "@platejs/list";
|
|
61
|
+
import { Toggle as Toggle$1 } from "@base-ui/react/toggle";
|
|
43
62
|
import { Tooltip as Tooltip$1 } from "@base-ui/react/tooltip";
|
|
44
63
|
import { Toaster as Toaster$1, toast } from "sonner";
|
|
45
64
|
import { Switch as Switch$1 } from "@base-ui/react/switch";
|
|
46
65
|
import { Tabs as Tabs$1 } from "@base-ui/react/tabs";
|
|
47
|
-
import { Toggle as Toggle$1 } from "@base-ui/react/toggle";
|
|
48
66
|
import { ToggleGroup as ToggleGroup$1 } from "@base-ui/react/toggle-group";
|
|
49
|
-
|
|
50
67
|
//#region src/lib/utils.ts
|
|
51
68
|
const DS_COLORS = [
|
|
52
69
|
"background",
|
|
@@ -107,7 +124,6 @@ const twMerge = extendTailwindMerge({ extend: { theme: {
|
|
|
107
124
|
function cn(...inputs) {
|
|
108
125
|
return twMerge(clsx(inputs));
|
|
109
126
|
}
|
|
110
|
-
|
|
111
127
|
//#endregion
|
|
112
128
|
//#region src/components/accordion.tsx
|
|
113
129
|
/**
|
|
@@ -196,7 +212,6 @@ const AccordionContent = React.forwardRef((componentProps, forwardRef) => {
|
|
|
196
212
|
});
|
|
197
213
|
});
|
|
198
214
|
AccordionContent.displayName = "AccordionContent";
|
|
199
|
-
|
|
200
215
|
//#endregion
|
|
201
216
|
//#region src/components/button.tsx
|
|
202
217
|
/** Tailwind class string for link-styled buttons and anchors (primary color, underlined). */
|
|
@@ -253,7 +268,6 @@ const Button = React.forwardRef((componentProps, forwardRef) => {
|
|
|
253
268
|
});
|
|
254
269
|
});
|
|
255
270
|
Button.displayName = "Button";
|
|
256
|
-
|
|
257
271
|
//#endregion
|
|
258
272
|
//#region src/i18n/locales/de.ts
|
|
259
273
|
const de = {
|
|
@@ -285,10 +299,23 @@ const de = {
|
|
|
285
299
|
"datePicker.beforeMin": "Das Datum liegt vor dem frühesten verfügbaren Datum ({{date}})",
|
|
286
300
|
"datePicker.afterMax": "Das Datum liegt nach dem spätesten verfügbaren Datum ({{date}})",
|
|
287
301
|
"datePicker.unavailable": "Dieses Datum ist nicht verfügbar",
|
|
288
|
-
"datePicker.rangeOrder": "Das Startdatum muss vor oder gleich dem Enddatum sein"
|
|
302
|
+
"datePicker.rangeOrder": "Das Startdatum muss vor oder gleich dem Enddatum sein",
|
|
303
|
+
"richTextarea.noResults": "Keine Ergebnisse",
|
|
304
|
+
"richTextarea.slashNoCommands": "Keine Befehle",
|
|
305
|
+
"richTextarea.bold": "Fett",
|
|
306
|
+
"richTextarea.italic": "Kursiv",
|
|
307
|
+
"richTextarea.underline": "Unterstrichen",
|
|
308
|
+
"richTextarea.strikethrough": "Durchgestrichen",
|
|
309
|
+
"richTextarea.inlineCode": "Inline-Code",
|
|
310
|
+
"richTextarea.bulletedList": "Aufzählungsliste",
|
|
311
|
+
"richTextarea.numberedList": "Nummerierte Liste",
|
|
312
|
+
"richTextarea.link": "Link",
|
|
313
|
+
"richTextarea.linkPlaceholder": "Link einfügen",
|
|
314
|
+
"richTextarea.linkText": "Anzuzeigender Text",
|
|
315
|
+
"richTextarea.linkEdit": "Link bearbeiten",
|
|
316
|
+
"richTextarea.linkOpen": "Link in neuem Tab öffnen",
|
|
317
|
+
"richTextarea.linkRemove": "Link entfernen"
|
|
289
318
|
};
|
|
290
|
-
var de_default = de;
|
|
291
|
-
|
|
292
319
|
//#endregion
|
|
293
320
|
//#region src/i18n/locales/en.ts
|
|
294
321
|
const en = {
|
|
@@ -320,10 +347,23 @@ const en = {
|
|
|
320
347
|
"datePicker.beforeMin": "Date is before the earliest available date ({{date}})",
|
|
321
348
|
"datePicker.afterMax": "Date is after the latest available date ({{date}})",
|
|
322
349
|
"datePicker.unavailable": "That date isn't available",
|
|
323
|
-
"datePicker.rangeOrder": "Start date must be on or before the end date"
|
|
350
|
+
"datePicker.rangeOrder": "Start date must be on or before the end date",
|
|
351
|
+
"richTextarea.noResults": "No results",
|
|
352
|
+
"richTextarea.slashNoCommands": "No commands",
|
|
353
|
+
"richTextarea.bold": "Bold",
|
|
354
|
+
"richTextarea.italic": "Italic",
|
|
355
|
+
"richTextarea.underline": "Underline",
|
|
356
|
+
"richTextarea.strikethrough": "Strikethrough",
|
|
357
|
+
"richTextarea.inlineCode": "Inline code",
|
|
358
|
+
"richTextarea.bulletedList": "Bulleted list",
|
|
359
|
+
"richTextarea.numberedList": "Numbered list",
|
|
360
|
+
"richTextarea.link": "Link",
|
|
361
|
+
"richTextarea.linkPlaceholder": "Paste link",
|
|
362
|
+
"richTextarea.linkText": "Text to display",
|
|
363
|
+
"richTextarea.linkEdit": "Edit link",
|
|
364
|
+
"richTextarea.linkOpen": "Open link in a new tab",
|
|
365
|
+
"richTextarea.linkRemove": "Remove link"
|
|
324
366
|
};
|
|
325
|
-
var en_default = en;
|
|
326
|
-
|
|
327
367
|
//#endregion
|
|
328
368
|
//#region src/i18n/locales/es.ts
|
|
329
369
|
const es = {
|
|
@@ -355,10 +395,23 @@ const es = {
|
|
|
355
395
|
"datePicker.beforeMin": "La fecha es anterior a la fecha más antigua disponible ({{date}})",
|
|
356
396
|
"datePicker.afterMax": "La fecha es posterior a la fecha más reciente disponible ({{date}})",
|
|
357
397
|
"datePicker.unavailable": "Esa fecha no está disponible",
|
|
358
|
-
"datePicker.rangeOrder": "La fecha de inicio debe ser anterior o igual a la fecha de fin"
|
|
398
|
+
"datePicker.rangeOrder": "La fecha de inicio debe ser anterior o igual a la fecha de fin",
|
|
399
|
+
"richTextarea.noResults": "Sin resultados",
|
|
400
|
+
"richTextarea.slashNoCommands": "Sin comandos",
|
|
401
|
+
"richTextarea.bold": "Negrita",
|
|
402
|
+
"richTextarea.italic": "Cursiva",
|
|
403
|
+
"richTextarea.underline": "Subrayado",
|
|
404
|
+
"richTextarea.strikethrough": "Tachado",
|
|
405
|
+
"richTextarea.inlineCode": "Código en línea",
|
|
406
|
+
"richTextarea.bulletedList": "Lista con viñetas",
|
|
407
|
+
"richTextarea.numberedList": "Lista numerada",
|
|
408
|
+
"richTextarea.link": "Enlace",
|
|
409
|
+
"richTextarea.linkPlaceholder": "Pegar enlace",
|
|
410
|
+
"richTextarea.linkText": "Texto para mostrar",
|
|
411
|
+
"richTextarea.linkEdit": "Editar enlace",
|
|
412
|
+
"richTextarea.linkOpen": "Abrir enlace en una pestaña nueva",
|
|
413
|
+
"richTextarea.linkRemove": "Eliminar enlace"
|
|
359
414
|
};
|
|
360
|
-
var es_default = es;
|
|
361
|
-
|
|
362
415
|
//#endregion
|
|
363
416
|
//#region src/i18n/locales/fr.ts
|
|
364
417
|
const fr = {
|
|
@@ -390,10 +443,23 @@ const fr = {
|
|
|
390
443
|
"datePicker.beforeMin": "La date est antérieure à la date la plus ancienne disponible ({{date}})",
|
|
391
444
|
"datePicker.afterMax": "La date est postérieure à la date la plus récente disponible ({{date}})",
|
|
392
445
|
"datePicker.unavailable": "Cette date n'est pas disponible",
|
|
393
|
-
"datePicker.rangeOrder": "La date de debut doit etre anterieure ou egale a la date de fin"
|
|
446
|
+
"datePicker.rangeOrder": "La date de debut doit etre anterieure ou egale a la date de fin",
|
|
447
|
+
"richTextarea.noResults": "Aucun résultat",
|
|
448
|
+
"richTextarea.slashNoCommands": "Aucune commande",
|
|
449
|
+
"richTextarea.bold": "Gras",
|
|
450
|
+
"richTextarea.italic": "Italique",
|
|
451
|
+
"richTextarea.underline": "Souligné",
|
|
452
|
+
"richTextarea.strikethrough": "Barré",
|
|
453
|
+
"richTextarea.inlineCode": "Code en ligne",
|
|
454
|
+
"richTextarea.bulletedList": "Liste à puces",
|
|
455
|
+
"richTextarea.numberedList": "Liste numérotée",
|
|
456
|
+
"richTextarea.link": "Lien",
|
|
457
|
+
"richTextarea.linkPlaceholder": "Coller le lien",
|
|
458
|
+
"richTextarea.linkText": "Texte à afficher",
|
|
459
|
+
"richTextarea.linkEdit": "Modifier le lien",
|
|
460
|
+
"richTextarea.linkOpen": "Ouvrir le lien dans un nouvel onglet",
|
|
461
|
+
"richTextarea.linkRemove": "Supprimer le lien"
|
|
394
462
|
};
|
|
395
|
-
var fr_default = fr;
|
|
396
|
-
|
|
397
463
|
//#endregion
|
|
398
464
|
//#region src/i18n/locales/it.ts
|
|
399
465
|
const it = {
|
|
@@ -425,10 +491,23 @@ const it = {
|
|
|
425
491
|
"datePicker.beforeMin": "La data è precedente alla prima data disponibile ({{date}})",
|
|
426
492
|
"datePicker.afterMax": "La data è successiva all'ultima data disponibile ({{date}})",
|
|
427
493
|
"datePicker.unavailable": "Questa data non è disponibile",
|
|
428
|
-
"datePicker.rangeOrder": "La data di inizio deve essere precedente o uguale alla data di fine"
|
|
494
|
+
"datePicker.rangeOrder": "La data di inizio deve essere precedente o uguale alla data di fine",
|
|
495
|
+
"richTextarea.noResults": "Nessun risultato",
|
|
496
|
+
"richTextarea.slashNoCommands": "Nessun comando",
|
|
497
|
+
"richTextarea.bold": "Grassetto",
|
|
498
|
+
"richTextarea.italic": "Corsivo",
|
|
499
|
+
"richTextarea.underline": "Sottolineato",
|
|
500
|
+
"richTextarea.strikethrough": "Barrato",
|
|
501
|
+
"richTextarea.inlineCode": "Codice inline",
|
|
502
|
+
"richTextarea.bulletedList": "Elenco puntato",
|
|
503
|
+
"richTextarea.numberedList": "Elenco numerato",
|
|
504
|
+
"richTextarea.link": "Collegamento",
|
|
505
|
+
"richTextarea.linkPlaceholder": "Incolla il link",
|
|
506
|
+
"richTextarea.linkText": "Testo da visualizzare",
|
|
507
|
+
"richTextarea.linkEdit": "Modifica link",
|
|
508
|
+
"richTextarea.linkOpen": "Apri il link in una nuova scheda",
|
|
509
|
+
"richTextarea.linkRemove": "Rimuovi link"
|
|
429
510
|
};
|
|
430
|
-
var it_default = it;
|
|
431
|
-
|
|
432
511
|
//#endregion
|
|
433
512
|
//#region src/i18n/instance.ts
|
|
434
513
|
const SUPPORTED_LANGUAGES = [
|
|
@@ -455,11 +534,11 @@ dsI18n.init({
|
|
|
455
534
|
ns: ["ds"],
|
|
456
535
|
defaultNS: "ds",
|
|
457
536
|
resources: {
|
|
458
|
-
en: { ds:
|
|
459
|
-
fr: { ds:
|
|
460
|
-
es: { ds:
|
|
461
|
-
de: { ds:
|
|
462
|
-
it: { ds:
|
|
537
|
+
en: { ds: en },
|
|
538
|
+
fr: { ds: fr },
|
|
539
|
+
es: { ds: es },
|
|
540
|
+
de: { ds: de },
|
|
541
|
+
it: { ds: it }
|
|
463
542
|
},
|
|
464
543
|
interpolation: { escapeValue: false },
|
|
465
544
|
keySeparator: false,
|
|
@@ -470,7 +549,6 @@ dsI18n.init({
|
|
|
470
549
|
function registerI18nNamespace(ns, resources) {
|
|
471
550
|
for (const [lng, bundle] of Object.entries(resources)) dsI18n.addResourceBundle(lng, ns, bundle, true, true);
|
|
472
551
|
}
|
|
473
|
-
|
|
474
552
|
//#endregion
|
|
475
553
|
//#region src/i18n/use-ds-translation.ts
|
|
476
554
|
function subscribe(onChange) {
|
|
@@ -486,12 +564,12 @@ function getLanguageSnapshot() {
|
|
|
486
564
|
* Used by @aircall/ds and @aircall/blocks components only — not part of the consumer contract.
|
|
487
565
|
*/
|
|
488
566
|
function useDsTranslation(ns) {
|
|
567
|
+
const language = useSyncExternalStore(subscribe, getLanguageSnapshot, getLanguageSnapshot);
|
|
489
568
|
return useCallback((key, opts) => dsI18n.t(key, {
|
|
490
569
|
ns,
|
|
491
570
|
...opts
|
|
492
|
-
}), [ns,
|
|
571
|
+
}), [ns, language]);
|
|
493
572
|
}
|
|
494
|
-
|
|
495
573
|
//#endregion
|
|
496
574
|
//#region src/components/action-bar.tsx
|
|
497
575
|
/** Fixed height of the ActionBar (px). Single source of truth — the bar uses it
|
|
@@ -541,7 +619,7 @@ const ActionBar = React.forwardRef((componentProps, forwardRef) => {
|
|
|
541
619
|
className: cn("relative flex w-full items-center gap-2 rounded-md border border-border bg-popover px-2 text-popover-foreground shadow-lg", className),
|
|
542
620
|
style: {
|
|
543
621
|
...style,
|
|
544
|
-
height:
|
|
622
|
+
height: 48
|
|
545
623
|
},
|
|
546
624
|
...props,
|
|
547
625
|
children: [
|
|
@@ -563,7 +641,6 @@ const ActionBar = React.forwardRef((componentProps, forwardRef) => {
|
|
|
563
641
|
});
|
|
564
642
|
});
|
|
565
643
|
ActionBar.displayName = "ActionBar";
|
|
566
|
-
|
|
567
644
|
//#endregion
|
|
568
645
|
//#region src/components/spinner.tsx
|
|
569
646
|
/** Class variants for `Spinner`, controlling its `size` (`default`, `sm`, `lg`, `xl`). */
|
|
@@ -598,7 +675,6 @@ const Spinner = React.forwardRef((componentProps, forwardRef) => {
|
|
|
598
675
|
});
|
|
599
676
|
});
|
|
600
677
|
Spinner.displayName = "Spinner";
|
|
601
|
-
|
|
602
678
|
//#endregion
|
|
603
679
|
//#region src/components/audio-player.tsx
|
|
604
680
|
const AudioPlayerContext = React.createContext(null);
|
|
@@ -770,9 +846,9 @@ function Audio({ src, defaultPlaybackRate = 1, preload = "metadata", crossOrigin
|
|
|
770
846
|
} catch {}
|
|
771
847
|
if (item === void 0 || item !== null && item?.src === activeItem?.src) {
|
|
772
848
|
managerRef.current?.register(audio);
|
|
773
|
-
const p
|
|
774
|
-
playPromiseRef.current = p
|
|
775
|
-
return p
|
|
849
|
+
const p = audio.play();
|
|
850
|
+
playPromiseRef.current = p;
|
|
851
|
+
return p;
|
|
776
852
|
}
|
|
777
853
|
swapSrc(item);
|
|
778
854
|
if (item == null) return;
|
|
@@ -805,7 +881,7 @@ function Audio({ src, defaultPlaybackRate = 1, preload = "metadata", crossOrigin
|
|
|
805
881
|
const setPlaybackRate = React.useCallback((rate) => {
|
|
806
882
|
setPlaybackRateState(rate);
|
|
807
883
|
}, []);
|
|
808
|
-
const isItemActive = React.useCallback((src
|
|
884
|
+
const isItemActive = React.useCallback((src) => src != null && activeItem?.src === src, [activeItem]);
|
|
809
885
|
const ctx = React.useMemo(() => ({
|
|
810
886
|
audioRef,
|
|
811
887
|
activeItem,
|
|
@@ -1092,7 +1168,8 @@ const AudioPlayerSpeed = React.forwardRef(function AudioPlayerSpeed({ speeds = D
|
|
|
1092
1168
|
function handleClick(event) {
|
|
1093
1169
|
onClick?.(event);
|
|
1094
1170
|
if (event.defaultPrevented) return;
|
|
1095
|
-
|
|
1171
|
+
const next = speeds[(speeds.indexOf(playbackRate) + 1) % speeds.length] ?? speeds[0];
|
|
1172
|
+
setPlaybackRate(next);
|
|
1096
1173
|
}
|
|
1097
1174
|
const label = `${Number.isInteger(playbackRate) ? playbackRate.toFixed(1) : playbackRate}x`;
|
|
1098
1175
|
const buttonSize = resolvedVariant === "default" ? "default" : "sm";
|
|
@@ -1125,7 +1202,8 @@ const AudioPlayerSkip = React.forwardRef(function AudioPlayerSkip({ offset, rend
|
|
|
1125
1202
|
function handleClick(event) {
|
|
1126
1203
|
onClick?.(event);
|
|
1127
1204
|
if (event.defaultPrevented) return;
|
|
1128
|
-
|
|
1205
|
+
const current = audioRef.current?.currentTime ?? 0;
|
|
1206
|
+
seek(current + offset);
|
|
1129
1207
|
}
|
|
1130
1208
|
return useRender({
|
|
1131
1209
|
defaultTagName: "button",
|
|
@@ -1180,7 +1258,6 @@ function AudioPlayerManager({ children }) {
|
|
|
1180
1258
|
children
|
|
1181
1259
|
});
|
|
1182
1260
|
}
|
|
1183
|
-
|
|
1184
1261
|
//#endregion
|
|
1185
1262
|
//#region src/components/alert-dialog.tsx
|
|
1186
1263
|
/**
|
|
@@ -1378,7 +1455,6 @@ const AlertDialogCancel = React.forwardRef((componentProps, forwardRef) => {
|
|
|
1378
1455
|
});
|
|
1379
1456
|
});
|
|
1380
1457
|
AlertDialogCancel.displayName = "AlertDialogCancel";
|
|
1381
|
-
|
|
1382
1458
|
//#endregion
|
|
1383
1459
|
//#region src/components/alert.tsx
|
|
1384
1460
|
/**
|
|
@@ -1484,7 +1560,6 @@ const AlertAction = React.forwardRef((componentProps, forwardRef) => {
|
|
|
1484
1560
|
});
|
|
1485
1561
|
});
|
|
1486
1562
|
AlertAction.displayName = "AlertAction";
|
|
1487
|
-
|
|
1488
1563
|
//#endregion
|
|
1489
1564
|
//#region src/components/attachment.tsx
|
|
1490
1565
|
const attachmentVariants = cva("group/attachment relative flex w-fit max-w-full min-w-0 shrink-0 flex-wrap rounded-xl border bg-card text-card-foreground transition-colors focus-within:ring-1 focus-within:ring-ring/50 has-[>a,>button]:hover:bg-muted/50 data-[state=error]:border-destructive/30 data-[state=idle]:border-dashed", {
|
|
@@ -1685,7 +1760,6 @@ const AttachmentGroup = React.forwardRef((componentProps, forwardRef) => {
|
|
|
1685
1760
|
});
|
|
1686
1761
|
});
|
|
1687
1762
|
AttachmentGroup.displayName = "AttachmentGroup";
|
|
1688
|
-
|
|
1689
1763
|
//#endregion
|
|
1690
1764
|
//#region src/components/avatar.tsx
|
|
1691
1765
|
/**
|
|
@@ -1791,7 +1865,6 @@ const AvatarGroupCount = React.forwardRef((componentProps, forwardRef) => {
|
|
|
1791
1865
|
});
|
|
1792
1866
|
});
|
|
1793
1867
|
AvatarGroupCount.displayName = "AvatarGroupCount";
|
|
1794
|
-
|
|
1795
1868
|
//#endregion
|
|
1796
1869
|
//#region src/components/counter-badge.tsx
|
|
1797
1870
|
/**
|
|
@@ -1833,7 +1906,6 @@ const CounterBadge = React.forwardRef((componentProps, forwardRef) => {
|
|
|
1833
1906
|
});
|
|
1834
1907
|
});
|
|
1835
1908
|
CounterBadge.displayName = "CounterBadge";
|
|
1836
|
-
|
|
1837
1909
|
//#endregion
|
|
1838
1910
|
//#region src/components/badge.tsx
|
|
1839
1911
|
const OVERLAY_DARK = "bg-[linear-gradient(0deg,var(--badge-film-10)_0%,var(--badge-film-10)_100%)]";
|
|
@@ -1841,7 +1913,7 @@ const OVERLAY_MEDIUM_DARK = "bg-[linear-gradient(0deg,var(--badge-film-40)_0%,va
|
|
|
1841
1913
|
const OVERLAY_MEDIUM_LIGHT = "bg-[linear-gradient(0deg,var(--badge-film-60)_0%,var(--badge-film-60)_100%)]";
|
|
1842
1914
|
const OVERLAY_LIGHT = "bg-[linear-gradient(0deg,var(--badge-film-80)_0%,var(--badge-film-80)_100%)]";
|
|
1843
1915
|
/** `cva` recipe for the Badge/Chip container — drives the `size`, `color`, and `tone` classes. */
|
|
1844
|
-
const badgeVariants = cva("group/badge inline-flex w-fit
|
|
1916
|
+
const badgeVariants = cva("group/badge inline-flex w-fit shrink-0 items-center justify-center gap-1 rounded-md font-medium transition-all focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:shrink-0 [&>svg]:pointer-events-none", {
|
|
1845
1917
|
variants: {
|
|
1846
1918
|
size: {
|
|
1847
1919
|
default: "h-5 px-2 py-0.5 text-xs [&>svg]:size-3!",
|
|
@@ -1861,6 +1933,10 @@ const badgeVariants = cva("group/badge inline-flex w-fit max-w-36 shrink-0 items
|
|
|
1861
1933
|
"medium-dark": "",
|
|
1862
1934
|
"medium-light": "",
|
|
1863
1935
|
light: ""
|
|
1936
|
+
},
|
|
1937
|
+
overflowMode: {
|
|
1938
|
+
none: "",
|
|
1939
|
+
truncate: "max-w-36 overflow-hidden whitespace-nowrap"
|
|
1864
1940
|
}
|
|
1865
1941
|
},
|
|
1866
1942
|
compoundVariants: [
|
|
@@ -2008,7 +2084,8 @@ const badgeVariants = cva("group/badge inline-flex w-fit max-w-36 shrink-0 items
|
|
|
2008
2084
|
defaultVariants: {
|
|
2009
2085
|
size: "default",
|
|
2010
2086
|
color: "charcoal",
|
|
2011
|
-
tone: "dark"
|
|
2087
|
+
tone: "dark",
|
|
2088
|
+
overflowMode: "none"
|
|
2012
2089
|
}
|
|
2013
2090
|
});
|
|
2014
2091
|
/**
|
|
@@ -2019,24 +2096,29 @@ const badgeVariants = cva("group/badge inline-flex w-fit max-w-36 shrink-0 items
|
|
|
2019
2096
|
* Pick a constrained DS `color` + `tone` (no freeform hex) — defaults to
|
|
2020
2097
|
* `charcoal` / `light` — or pass a stored hex via `legacyColor`. Icons are
|
|
2021
2098
|
* composed as children (auto-sized per `size`).
|
|
2099
|
+
*
|
|
2100
|
+
* `overflowMode` controls how content wider than the badge is handled:
|
|
2101
|
+
* `'none'` (default) lets it wrap/grow naturally; `'truncate'` caps the
|
|
2102
|
+
* width at `max-w-36` and ellipsizes text content.
|
|
2022
2103
|
*/
|
|
2023
2104
|
const Badge = React.forwardRef((componentProps, forwardRef) => {
|
|
2024
|
-
const { className, size = "default", color, tone, legacyColor, render, children, ...props } = componentProps;
|
|
2105
|
+
const { className, size = "default", color, tone, overflowMode = "none", legacyColor, render, children, ...props } = componentProps;
|
|
2025
2106
|
const resolved = legacyColor ? resolveTagColor(legacyColor) : {
|
|
2026
2107
|
color,
|
|
2027
2108
|
tone
|
|
2028
2109
|
};
|
|
2029
|
-
const content = React.Children.map(children, (child) => typeof child === "string" || typeof child === "number" ? /* @__PURE__ */ jsx("span", {
|
|
2110
|
+
const content = overflowMode === "truncate" ? React.Children.map(children, (child) => typeof child === "string" || typeof child === "number" ? /* @__PURE__ */ jsx("span", {
|
|
2030
2111
|
className: "min-w-0 truncate",
|
|
2031
2112
|
children: child
|
|
2032
|
-
}) : child);
|
|
2113
|
+
}) : child) : children;
|
|
2033
2114
|
return useRender({
|
|
2034
2115
|
defaultTagName: "span",
|
|
2035
2116
|
props: mergeProps({
|
|
2036
2117
|
className: cn(badgeVariants({
|
|
2037
2118
|
size,
|
|
2038
2119
|
color: resolved.color,
|
|
2039
|
-
tone: resolved.tone
|
|
2120
|
+
tone: resolved.tone,
|
|
2121
|
+
overflowMode
|
|
2040
2122
|
}), className),
|
|
2041
2123
|
ref: forwardRef,
|
|
2042
2124
|
children: content
|
|
@@ -2149,7 +2231,6 @@ const FALLBACK_TAG_COLOR = {
|
|
|
2149
2231
|
function resolveTagColor(hex) {
|
|
2150
2232
|
return LEGACY_TAG_COLOR_MAP[hex.trim().toLowerCase()] ?? FALLBACK_TAG_COLOR;
|
|
2151
2233
|
}
|
|
2152
|
-
|
|
2153
2234
|
//#endregion
|
|
2154
2235
|
//#region src/components/banner.tsx
|
|
2155
2236
|
/**
|
|
@@ -2207,7 +2288,6 @@ const Banner = React.forwardRef((componentProps, forwardRef) => {
|
|
|
2207
2288
|
});
|
|
2208
2289
|
});
|
|
2209
2290
|
Banner.displayName = "Banner";
|
|
2210
|
-
|
|
2211
2291
|
//#endregion
|
|
2212
2292
|
//#region src/components/notification-queue.tsx
|
|
2213
2293
|
const PRIORITY_WEIGHT = {
|
|
@@ -2261,7 +2341,7 @@ function reducer(state, action) {
|
|
|
2261
2341
|
if (state.dismissed.has(key)) return state;
|
|
2262
2342
|
return {
|
|
2263
2343
|
...state,
|
|
2264
|
-
dismissed: new Set([...state.dismissed, key])
|
|
2344
|
+
dismissed: /* @__PURE__ */ new Set([...state.dismissed, key])
|
|
2265
2345
|
};
|
|
2266
2346
|
}
|
|
2267
2347
|
}
|
|
@@ -2405,7 +2485,6 @@ const NotificationSlot = React.forwardRef((componentProps, forwardRef) => {
|
|
|
2405
2485
|
});
|
|
2406
2486
|
});
|
|
2407
2487
|
NotificationSlot.displayName = "NotificationSlot";
|
|
2408
|
-
|
|
2409
2488
|
//#endregion
|
|
2410
2489
|
//#region src/components/separator.tsx
|
|
2411
2490
|
/**
|
|
@@ -2431,7 +2510,6 @@ const Separator = React.forwardRef((componentProps, forwardRef) => {
|
|
|
2431
2510
|
});
|
|
2432
2511
|
});
|
|
2433
2512
|
Separator.displayName = "Separator";
|
|
2434
|
-
|
|
2435
2513
|
//#endregion
|
|
2436
2514
|
//#region src/components/button-group.tsx
|
|
2437
2515
|
/** `cva` variant definitions for {@link ButtonGroup} — resolves `orientation` (horizontal / vertical) into class names. */
|
|
@@ -2498,11 +2576,10 @@ const ButtonGroupSeparator = React.forwardRef((componentProps, forwardRef) => {
|
|
|
2498
2576
|
});
|
|
2499
2577
|
});
|
|
2500
2578
|
ButtonGroupSeparator.displayName = "ButtonGroupSeparator";
|
|
2501
|
-
|
|
2502
2579
|
//#endregion
|
|
2503
2580
|
//#region src/components/select.tsx
|
|
2504
2581
|
/** `class-variance-authority` variants for the select trigger; exposes the `size` variant. */
|
|
2505
|
-
const selectTriggerVariants = cva("flex w-fit items-center justify-between rounded-md border border-input
|
|
2582
|
+
const selectTriggerVariants = cva("flex w-fit items-center justify-between rounded-md border border-input py-2 text-sm whitespace-nowrap transition-colors outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive focus-visible:aria-invalid:ring-3 focus-visible:aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 bg-background dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:focus-visible:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", {
|
|
2506
2583
|
variants: { size: {
|
|
2507
2584
|
default: "h-10 gap-2 px-3",
|
|
2508
2585
|
sm: "h-8 gap-1.5 px-2"
|
|
@@ -2584,7 +2661,8 @@ const SelectContent = React.forwardRef((componentProps, forwardRef) => {
|
|
|
2584
2661
|
align,
|
|
2585
2662
|
alignOffset,
|
|
2586
2663
|
alignItemWithTrigger,
|
|
2587
|
-
|
|
2664
|
+
"data-slot": "select-positioner",
|
|
2665
|
+
className: "isolate z-popup",
|
|
2588
2666
|
children: /* @__PURE__ */ jsxs(Select$1.Popup, {
|
|
2589
2667
|
ref: forwardRef,
|
|
2590
2668
|
"data-slot": "select-content",
|
|
@@ -2680,7 +2758,6 @@ const SelectScrollDownButton = React.forwardRef((componentProps, forwardRef) =>
|
|
|
2680
2758
|
});
|
|
2681
2759
|
});
|
|
2682
2760
|
SelectScrollDownButton.displayName = "SelectScrollDownButton";
|
|
2683
|
-
|
|
2684
2761
|
//#endregion
|
|
2685
2762
|
//#region src/components/calendar.tsx
|
|
2686
2763
|
/**
|
|
@@ -2708,13 +2785,15 @@ SelectScrollDownButton.displayName = "SelectScrollDownButton";
|
|
|
2708
2785
|
* `options` array that react-day-picker passes for month/year values.
|
|
2709
2786
|
*/
|
|
2710
2787
|
function CalendarDropdown({ options, value, onChange, disabled, "aria-label": ariaLabel, className, components: _components, classNames: _classNames }) {
|
|
2788
|
+
const currentValue = value !== void 0 ? String(value) : void 0;
|
|
2789
|
+
const itemsMap = React.useMemo(() => {
|
|
2790
|
+
if (!options) return {};
|
|
2791
|
+
return Object.fromEntries(options.map((o) => [String(o.value), String(o.label)]));
|
|
2792
|
+
}, [options]);
|
|
2711
2793
|
return /* @__PURE__ */ jsxs(Select, {
|
|
2712
|
-
value:
|
|
2794
|
+
value: currentValue,
|
|
2713
2795
|
disabled,
|
|
2714
|
-
items:
|
|
2715
|
-
if (!options) return {};
|
|
2716
|
-
return Object.fromEntries(options.map((o) => [String(o.value), String(o.label)]));
|
|
2717
|
-
}, [options]),
|
|
2796
|
+
items: itemsMap,
|
|
2718
2797
|
modal: false,
|
|
2719
2798
|
onValueChange: (newValue) => {
|
|
2720
2799
|
if (onChange) {
|
|
@@ -2907,7 +2986,6 @@ function CalendarDayButton({ className: dayClassName, day, modifiers, locale, ..
|
|
|
2907
2986
|
...props
|
|
2908
2987
|
});
|
|
2909
2988
|
}
|
|
2910
|
-
|
|
2911
2989
|
//#endregion
|
|
2912
2990
|
//#region src/components/card.tsx
|
|
2913
2991
|
/**
|
|
@@ -3019,7 +3097,6 @@ const CardFooter = React.forwardRef((componentProps, forwardRef) => {
|
|
|
3019
3097
|
});
|
|
3020
3098
|
});
|
|
3021
3099
|
CardFooter.displayName = "CardFooter";
|
|
3022
|
-
|
|
3023
3100
|
//#endregion
|
|
3024
3101
|
//#region src/components/carousel.tsx
|
|
3025
3102
|
const CarouselContext = React.createContext(null);
|
|
@@ -3052,10 +3129,10 @@ const Carousel = React.forwardRef((componentProps, forwardRef) => {
|
|
|
3052
3129
|
}, plugins);
|
|
3053
3130
|
const [canScrollPrev, setCanScrollPrev] = React.useState(false);
|
|
3054
3131
|
const [canScrollNext, setCanScrollNext] = React.useState(false);
|
|
3055
|
-
const onSelect = React.useCallback((api
|
|
3056
|
-
if (!api
|
|
3057
|
-
setCanScrollPrev(api
|
|
3058
|
-
setCanScrollNext(api
|
|
3132
|
+
const onSelect = React.useCallback((api) => {
|
|
3133
|
+
if (!api) return;
|
|
3134
|
+
setCanScrollPrev(api.canScrollPrev());
|
|
3135
|
+
setCanScrollNext(api.canScrollNext());
|
|
3059
3136
|
}, []);
|
|
3060
3137
|
const scrollPrev = React.useCallback(() => {
|
|
3061
3138
|
api?.scrollPrev();
|
|
@@ -3191,7 +3268,6 @@ const CarouselNext = React.forwardRef((componentProps, forwardRef) => {
|
|
|
3191
3268
|
});
|
|
3192
3269
|
});
|
|
3193
3270
|
CarouselNext.displayName = "CarouselNext";
|
|
3194
|
-
|
|
3195
3271
|
//#endregion
|
|
3196
3272
|
//#region src/components/checkbox.tsx
|
|
3197
3273
|
/**
|
|
@@ -3220,7 +3296,6 @@ const Checkbox = React.forwardRef((componentProps, forwardRef) => {
|
|
|
3220
3296
|
});
|
|
3221
3297
|
});
|
|
3222
3298
|
Checkbox.displayName = "Checkbox";
|
|
3223
|
-
|
|
3224
3299
|
//#endregion
|
|
3225
3300
|
//#region src/components/chip.tsx
|
|
3226
3301
|
const chipGlowVariants = cva("", {
|
|
@@ -3306,9 +3381,12 @@ ChipRemove.displayName = "ChipRemove";
|
|
|
3306
3381
|
* fixed 24px size with a forced trailing remove (X) button. The chip body is
|
|
3307
3382
|
* non-interactive — only the X reacts to hover. For combobox-bound chips that
|
|
3308
3383
|
* must drive Base UI's selection state, see `ComboboxChip`.
|
|
3384
|
+
*
|
|
3385
|
+
* Defaults `overflowMode` to `'truncate'` (unlike `Badge`, which defaults to
|
|
3386
|
+
* `'none'`) since chips sit in fixed-width input/combobox rows.
|
|
3309
3387
|
*/
|
|
3310
3388
|
const Chip = React.forwardRef((componentProps, forwardRef) => {
|
|
3311
|
-
const { className, children, color, tone = "medium-light", legacyColor, glow, ...props } = componentProps;
|
|
3389
|
+
const { className, children, color, tone = "medium-light", overflowMode = "truncate", legacyColor, glow, ...props } = componentProps;
|
|
3312
3390
|
const glowColor = legacyColor ? resolveTagColor(legacyColor).color : color;
|
|
3313
3391
|
return /* @__PURE__ */ jsx(Badge, {
|
|
3314
3392
|
ref: forwardRef,
|
|
@@ -3316,6 +3394,7 @@ const Chip = React.forwardRef((componentProps, forwardRef) => {
|
|
|
3316
3394
|
size: "lg",
|
|
3317
3395
|
color,
|
|
3318
3396
|
tone,
|
|
3397
|
+
overflowMode,
|
|
3319
3398
|
legacyColor,
|
|
3320
3399
|
className: cn("has-data-[slot=chip-remove]:pr-0 has-disabled:pointer-events-none has-disabled:opacity-50", chipGlowVariants({
|
|
3321
3400
|
color: glowColor,
|
|
@@ -3326,7 +3405,6 @@ const Chip = React.forwardRef((componentProps, forwardRef) => {
|
|
|
3326
3405
|
});
|
|
3327
3406
|
});
|
|
3328
3407
|
Chip.displayName = "Chip";
|
|
3329
|
-
|
|
3330
3408
|
//#endregion
|
|
3331
3409
|
//#region src/components/collapsible.tsx
|
|
3332
3410
|
/**
|
|
@@ -3376,7 +3454,6 @@ const CollapsibleContent = React.forwardRef((componentProps, forwardRef) => {
|
|
|
3376
3454
|
});
|
|
3377
3455
|
});
|
|
3378
3456
|
CollapsibleContent.displayName = "CollapsibleContent";
|
|
3379
|
-
|
|
3380
3457
|
//#endregion
|
|
3381
3458
|
//#region src/components/input.tsx
|
|
3382
3459
|
const inputVariants = cva("text-foreground file:text-foreground placeholder:text-muted-foreground dark:bg-input/30 border-input flex h-10 w-full min-w-0 rounded-md border bg-background px-3 py-2 text-sm transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 dark:disabled:bg-input/80 md:text-sm focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-3 aria-invalid:border-destructive focus-visible:aria-invalid:ring-destructive/20 focus-visible:aria-invalid:ring-3 dark:focus-visible:aria-invalid:ring-destructive/40", { variants: { block: { true: "w-full" } } });
|
|
@@ -3407,7 +3484,6 @@ const Input = React.forwardRef((componentProps, forwardRef) => {
|
|
|
3407
3484
|
});
|
|
3408
3485
|
});
|
|
3409
3486
|
Input.displayName = "Input";
|
|
3410
|
-
|
|
3411
3487
|
//#endregion
|
|
3412
3488
|
//#region src/components/textarea.tsx
|
|
3413
3489
|
/**
|
|
@@ -3432,7 +3508,6 @@ const Textarea = React.forwardRef((componentProps, forwardRef) => {
|
|
|
3432
3508
|
});
|
|
3433
3509
|
});
|
|
3434
3510
|
Textarea.displayName = "Textarea";
|
|
3435
|
-
|
|
3436
3511
|
//#endregion
|
|
3437
3512
|
//#region src/components/input-group.tsx
|
|
3438
3513
|
/**
|
|
@@ -3441,7 +3516,7 @@ Textarea.displayName = "Textarea";
|
|
|
3441
3516
|
* affix-driven input padding adjustments. Exported so `NumericInput` renders an
|
|
3442
3517
|
* identical container without nesting inside `InputGroup`.
|
|
3443
3518
|
*/
|
|
3444
|
-
const inputGroupShellClassName = cn("group/input-group bg-background border-input dark:bg-input/30 relative flex h-10 w-full items-center rounded-md border transition-[color,box-shadow] outline-none has-[>textarea]:h-auto", "has-[input:disabled]:bg-input/50 has-[textarea:disabled]:bg-input/50 has-[input:disabled]:opacity-50 has-[textarea:disabled]:opacity-50 dark:has-[input:disabled]:bg-input/80 dark:has-[textarea:disabled]:bg-input/80", "has-[>[data-align=inline-start]]:[&>input]:pl-2", "has-[>[data-align=inline-end]]:[&>input]:pr-2", "has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3", "has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3", "has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot=input-group-control]:focus-visible]:ring-3", "has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]:focus-visible]:ring-destructive/20 dark:has-[[data-slot][aria-invalid=true]:focus-visible]:ring-destructive/40", "data-[invalid]:border-destructive has-[input:focus-visible]:data-[invalid]:ring-3 has-[input:focus-visible]:data-[invalid]:ring-destructive/20 dark:has-[input:focus-visible]:data-[invalid]:ring-destructive/40");
|
|
3519
|
+
const inputGroupShellClassName = cn("group/input-group bg-background border-input dark:bg-input/30 relative flex h-10 w-full items-center rounded-md border transition-[color,box-shadow] outline-none has-[>textarea]:h-auto has-[>[data-multiline=true]]:h-auto", "has-[input:disabled]:bg-input/50 has-[textarea:disabled]:bg-input/50 has-[input:disabled]:opacity-50 has-[textarea:disabled]:opacity-50 dark:has-[input:disabled]:bg-input/80 dark:has-[textarea:disabled]:bg-input/80", "has-[[data-slot=input-group-control][aria-disabled=true]]:bg-input/50 has-[[data-slot=input-group-control][aria-disabled=true]]:opacity-50 dark:has-[[data-slot=input-group-control][aria-disabled=true]]:bg-input/80", "has-[>[data-align=inline-start]]:[&>input]:pl-2", "has-[>[data-align=inline-end]]:[&>input]:pr-2", "has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3", "has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3", "has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot=input-group-control]:focus-visible]:ring-3", "has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]:focus-visible]:ring-destructive/20 dark:has-[[data-slot][aria-invalid=true]:focus-visible]:ring-destructive/40", "data-[invalid]:border-destructive has-[input:focus-visible]:data-[invalid]:ring-3 has-[input:focus-visible]:data-[invalid]:ring-destructive/20 dark:has-[input:focus-visible]:data-[invalid]:ring-destructive/40");
|
|
3445
3520
|
/**
|
|
3446
3521
|
* Bordered flex-row container that groups an input with leading/trailing addons
|
|
3447
3522
|
* (icons, buttons, text). Renders a `<div role="group">` and owns the shared
|
|
@@ -3489,7 +3564,7 @@ const InputGroupAddon = React.forwardRef((componentProps, forwardRef) => {
|
|
|
3489
3564
|
className: cn(inputGroupAddonVariants({ align }), className),
|
|
3490
3565
|
onClick: (e) => {
|
|
3491
3566
|
if (e.target.closest("button")) return;
|
|
3492
|
-
e.currentTarget.parentElement?.querySelector("input")?.focus();
|
|
3567
|
+
e.currentTarget.parentElement?.querySelector("input, textarea, [data-slot=\"input-group-control\"]")?.focus();
|
|
3493
3568
|
},
|
|
3494
3569
|
...props
|
|
3495
3570
|
});
|
|
@@ -3536,7 +3611,6 @@ const InputGroupTextarea = React.forwardRef((componentProps, forwardRef) => {
|
|
|
3536
3611
|
});
|
|
3537
3612
|
});
|
|
3538
3613
|
InputGroupTextarea.displayName = "InputGroupTextarea";
|
|
3539
|
-
|
|
3540
3614
|
//#endregion
|
|
3541
3615
|
//#region src/components/combobox.tsx
|
|
3542
3616
|
/**
|
|
@@ -3643,7 +3717,8 @@ const ComboboxContent = React.forwardRef((componentProps, forwardRef) => {
|
|
|
3643
3717
|
align,
|
|
3644
3718
|
alignOffset,
|
|
3645
3719
|
anchor,
|
|
3646
|
-
|
|
3720
|
+
"data-slot": "combobox-positioner",
|
|
3721
|
+
className: "isolate z-popup",
|
|
3647
3722
|
children: /* @__PURE__ */ jsx(Combobox$1.Popup, {
|
|
3648
3723
|
ref: forwardRef,
|
|
3649
3724
|
"data-slot": "combobox-content",
|
|
@@ -3762,7 +3837,7 @@ const ComboboxChips = React.forwardRef((componentProps, forwardRef) => {
|
|
|
3762
3837
|
return /* @__PURE__ */ jsx(Combobox$1.Chips, {
|
|
3763
3838
|
ref: forwardRef,
|
|
3764
3839
|
"data-slot": "combobox-chips",
|
|
3765
|
-
className: cn("flex min-h-10 flex-wrap items-center gap-1 rounded-md border border-input bg-
|
|
3840
|
+
className: cn("flex min-h-10 flex-wrap items-center gap-1 rounded-md border border-input bg-background bg-clip-padding py-2 pl-3 pr-2 text-sm transition-colors focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50 has-aria-invalid:border-destructive has-aria-invalid:ring-3 has-aria-invalid:ring-destructive/20 dark:bg-input/30 dark:has-aria-invalid:border-destructive/50 dark:has-aria-invalid:ring-destructive/40", className),
|
|
3766
3841
|
...props
|
|
3767
3842
|
});
|
|
3768
3843
|
});
|
|
@@ -3806,7 +3881,6 @@ ComboboxChipsInput.displayName = "ComboboxChipsInput";
|
|
|
3806
3881
|
function useComboboxAnchor() {
|
|
3807
3882
|
return React.useRef(null);
|
|
3808
3883
|
}
|
|
3809
|
-
|
|
3810
3884
|
//#endregion
|
|
3811
3885
|
//#region src/components/skeleton.tsx
|
|
3812
3886
|
/**
|
|
@@ -3828,7 +3902,6 @@ const Skeleton = React.forwardRef((componentProps, forwardRef) => {
|
|
|
3828
3902
|
});
|
|
3829
3903
|
});
|
|
3830
3904
|
Skeleton.displayName = "Skeleton";
|
|
3831
|
-
|
|
3832
3905
|
//#endregion
|
|
3833
3906
|
//#region src/lib/use-fetch-more-sentinel.ts
|
|
3834
3907
|
/**
|
|
@@ -3895,7 +3968,6 @@ function useFetchMoreSentinel(onFetchMore, getRoot, resetKey) {
|
|
|
3895
3968
|
observe();
|
|
3896
3969
|
}, [observe]);
|
|
3897
3970
|
}
|
|
3898
|
-
|
|
3899
3971
|
//#endregion
|
|
3900
3972
|
//#region src/components/combobox-rows.tsx
|
|
3901
3973
|
const DEFAULT_SKELETON_COUNT$1 = 5;
|
|
@@ -3994,12 +4066,11 @@ function ComboboxLoadedRows(componentProps) {
|
|
|
3994
4066
|
const { groups, renderRow, virtualRows, isFiltering, isLoadingMore, emptyState, listClassName, listTabIndex, "aria-label": ariaLabel } = componentProps;
|
|
3995
4067
|
const t = useDsTranslation("ds");
|
|
3996
4068
|
const listChildren = virtualRows ?? (groups === null ? renderRow : renderGroupSection(renderRow));
|
|
3997
|
-
const tabIndexProps = listTabIndex === void 0 ? {} : { tabIndex: listTabIndex };
|
|
3998
4069
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3999
4070
|
/* @__PURE__ */ jsx(ComboboxList, {
|
|
4000
4071
|
"aria-label": ariaLabel,
|
|
4001
4072
|
className: listClassName,
|
|
4002
|
-
...
|
|
4073
|
+
...listTabIndex === void 0 ? {} : { tabIndex: listTabIndex },
|
|
4003
4074
|
children: listChildren
|
|
4004
4075
|
}),
|
|
4005
4076
|
isFiltering ? null : /* @__PURE__ */ jsx(ComboboxEmpty, {
|
|
@@ -4117,7 +4188,6 @@ function ComboboxSkeletonRows({ count }) {
|
|
|
4117
4188
|
}, `skeleton-${i}`))
|
|
4118
4189
|
});
|
|
4119
4190
|
}
|
|
4120
|
-
|
|
4121
4191
|
//#endregion
|
|
4122
4192
|
//#region src/lib/use-combobox-item-selection.ts
|
|
4123
4193
|
const EMPTY_KEYS$1 = /* @__PURE__ */ new Set();
|
|
@@ -4131,7 +4201,7 @@ const EMPTY_KEYS$1 = /* @__PURE__ */ new Set();
|
|
|
4131
4201
|
* `escape-key` is deliberately absent: with a popup, Escape CLOSES it rather
|
|
4132
4202
|
* than clearing the query, so forwarding it would refetch on every dismissal.
|
|
4133
4203
|
*/
|
|
4134
|
-
const POPUP_SEARCH_TRIGGER_REASONS = new Set([
|
|
4204
|
+
const POPUP_SEARCH_TRIGGER_REASONS = /* @__PURE__ */ new Set([
|
|
4135
4205
|
"input-change",
|
|
4136
4206
|
"input-clear",
|
|
4137
4207
|
"clear-press"
|
|
@@ -4145,7 +4215,7 @@ const POPUP_SEARCH_TRIGGER_REASONS = new Set([
|
|
|
4145
4215
|
* in step with the reset it just performed — otherwise the component presents
|
|
4146
4216
|
* itself as reset while the caller keeps serving the previous query's page.
|
|
4147
4217
|
*/
|
|
4148
|
-
const INLINE_SEARCH_TRIGGER_REASONS = new Set([
|
|
4218
|
+
const INLINE_SEARCH_TRIGGER_REASONS = /* @__PURE__ */ new Set([
|
|
4149
4219
|
"input-change",
|
|
4150
4220
|
"input-clear",
|
|
4151
4221
|
"clear-press",
|
|
@@ -4199,7 +4269,6 @@ function useComboboxItemSelection(options) {
|
|
|
4199
4269
|
} : void 0
|
|
4200
4270
|
};
|
|
4201
4271
|
}
|
|
4202
|
-
|
|
4203
4272
|
//#endregion
|
|
4204
4273
|
//#region src/components/combobox-body.tsx
|
|
4205
4274
|
const LIST_MAX_HEIGHT = "max-h-63";
|
|
@@ -4269,7 +4338,7 @@ function ComboboxBody(componentProps) {
|
|
|
4269
4338
|
const { items, getItemValue, getItemLabel, renderItem, getGroupKey, getGroupLabel, selectionMode = "single", selectedKeys, defaultSelectedKeys, onSelectionChange, selectedItems, disabledKeys, loadingState = "idle", skeletonCount, onSearch, onFetchMore, hasMore = false, emptyState, estimateRowHeight, searchable = true, placeholder, className, "aria-label": ariaLabel } = componentProps;
|
|
4270
4339
|
const multiple = selectionMode === "multiple";
|
|
4271
4340
|
const autoVirtualizeLatch = React.useRef(false);
|
|
4272
|
-
if (!autoVirtualizeLatch.current) autoVirtualizeLatch.current = !!onFetchMore || items.length >=
|
|
4341
|
+
if (!autoVirtualizeLatch.current) autoVirtualizeLatch.current = !!onFetchMore || items.length >= 100;
|
|
4273
4342
|
const virtualizeRows = (componentProps.virtualizeRows ?? autoVirtualizeLatch.current) && !getGroupKey;
|
|
4274
4343
|
const scrollRowIntoViewRef = React.useRef(null);
|
|
4275
4344
|
const { selectedObjects, commit, handleInputValueChange } = useComboboxItemSelection({
|
|
@@ -4342,7 +4411,6 @@ function ComboboxBody(componentProps) {
|
|
|
4342
4411
|
children: body
|
|
4343
4412
|
}, selectionMode);
|
|
4344
4413
|
}
|
|
4345
|
-
|
|
4346
4414
|
//#endregion
|
|
4347
4415
|
//#region src/components/dialog.tsx
|
|
4348
4416
|
/**
|
|
@@ -4504,7 +4572,6 @@ const DialogDescription = React.forwardRef((componentProps, forwardRef) => {
|
|
|
4504
4572
|
});
|
|
4505
4573
|
});
|
|
4506
4574
|
DialogDescription.displayName = "DialogDescription";
|
|
4507
|
-
|
|
4508
4575
|
//#endregion
|
|
4509
4576
|
//#region src/components/command.tsx
|
|
4510
4577
|
/**
|
|
@@ -4671,7 +4738,6 @@ const CommandShortcut = React.forwardRef((componentProps, forwardRef) => {
|
|
|
4671
4738
|
});
|
|
4672
4739
|
});
|
|
4673
4740
|
CommandShortcut.displayName = "CommandShortcut";
|
|
4674
|
-
|
|
4675
4741
|
//#endregion
|
|
4676
4742
|
//#region src/components/country-flag.tsx
|
|
4677
4743
|
const sizeMap = {
|
|
@@ -4694,14 +4760,14 @@ const sizeMap = {
|
|
|
4694
4760
|
*/
|
|
4695
4761
|
const CountryFlag = React.forwardRef((componentProps, forwardRef) => {
|
|
4696
4762
|
const { countryIsoCode, size = "xl", className, ...otherProps } = componentProps;
|
|
4697
|
-
|
|
4763
|
+
const CurrentFlag = FLAGS[countryIsoCode.toLowerCase()] ?? FlagUs;
|
|
4764
|
+
return /* @__PURE__ */ jsx(CurrentFlag, {
|
|
4698
4765
|
ref: forwardRef,
|
|
4699
4766
|
className: cn("flex-none", sizeMap[size], className),
|
|
4700
4767
|
...otherProps
|
|
4701
4768
|
});
|
|
4702
4769
|
});
|
|
4703
4770
|
CountryFlag.displayName = "CountryFlag";
|
|
4704
|
-
|
|
4705
4771
|
//#endregion
|
|
4706
4772
|
//#region src/components/data-combobox.tsx
|
|
4707
4773
|
/**
|
|
@@ -4802,7 +4868,6 @@ function DataCombobox(componentProps) {
|
|
|
4802
4868
|
})] })
|
|
4803
4869
|
}, selectionMode);
|
|
4804
4870
|
}
|
|
4805
|
-
|
|
4806
4871
|
//#endregion
|
|
4807
4872
|
//#region src/components/table.tsx
|
|
4808
4873
|
/**
|
|
@@ -4906,17 +4971,69 @@ const TableCell = React.forwardRef((componentProps, forwardRef) => {
|
|
|
4906
4971
|
});
|
|
4907
4972
|
});
|
|
4908
4973
|
TableCell.displayName = "TableCell";
|
|
4909
|
-
|
|
4974
|
+
//#endregion
|
|
4975
|
+
//#region src/lib/use-horizontal-scroll-edges.ts
|
|
4976
|
+
/**
|
|
4977
|
+
* Tracks whether a horizontally scrollable container is flush with its left
|
|
4978
|
+
* and/or right content edge. Used by pinned DataTable columns to show an edge
|
|
4979
|
+
* separator only while content is obscured behind the pin.
|
|
4980
|
+
*
|
|
4981
|
+
* @param contentSizeKey - Optional signal that content width may have changed
|
|
4982
|
+
* without the container box resizing (e.g. column sizes / `table.getTotalSize()`).
|
|
4983
|
+
* Re-runs the edge measurement when it changes.
|
|
4984
|
+
*/
|
|
4985
|
+
function useHorizontalScrollEdges(containerRef, enabled, contentSizeKey) {
|
|
4986
|
+
const [atLeftEdge, setAtLeftEdge] = React.useState(true);
|
|
4987
|
+
const [atRightEdge, setAtRightEdge] = React.useState(true);
|
|
4988
|
+
React.useEffect(() => {
|
|
4989
|
+
if (!enabled) {
|
|
4990
|
+
setAtLeftEdge(true);
|
|
4991
|
+
setAtRightEdge(true);
|
|
4992
|
+
return;
|
|
4993
|
+
}
|
|
4994
|
+
const el = containerRef.current;
|
|
4995
|
+
if (!el) return;
|
|
4996
|
+
const update = () => {
|
|
4997
|
+
const { scrollLeft, scrollWidth, clientWidth } = el;
|
|
4998
|
+
setAtLeftEdge(scrollLeft <= 0);
|
|
4999
|
+
setAtRightEdge(scrollLeft + clientWidth >= scrollWidth - 1);
|
|
5000
|
+
};
|
|
5001
|
+
update();
|
|
5002
|
+
el.addEventListener("scroll", update, { passive: true });
|
|
5003
|
+
window.addEventListener("resize", update);
|
|
5004
|
+
const ro = typeof ResizeObserver !== "undefined" ? new ResizeObserver(update) : null;
|
|
5005
|
+
ro?.observe(el);
|
|
5006
|
+
const content = el.querySelector("[data-slot=\"table\"]") ?? el.firstElementChild;
|
|
5007
|
+
if (content instanceof HTMLElement && content !== el) ro?.observe(content);
|
|
5008
|
+
return () => {
|
|
5009
|
+
el.removeEventListener("scroll", update);
|
|
5010
|
+
window.removeEventListener("resize", update);
|
|
5011
|
+
ro?.disconnect();
|
|
5012
|
+
};
|
|
5013
|
+
}, [
|
|
5014
|
+
containerRef,
|
|
5015
|
+
enabled,
|
|
5016
|
+
contentSizeKey
|
|
5017
|
+
]);
|
|
5018
|
+
return {
|
|
5019
|
+
atLeftEdge,
|
|
5020
|
+
atRightEdge
|
|
5021
|
+
};
|
|
5022
|
+
}
|
|
4910
5023
|
//#endregion
|
|
4911
5024
|
//#region src/components/data-table.tsx
|
|
4912
5025
|
const SELECT_COLUMN_ID = "__select";
|
|
4913
5026
|
const DEFAULT_SKELETON_COUNT = 5;
|
|
4914
5027
|
const EMPTY_KEYS = /* @__PURE__ */ new Set();
|
|
5028
|
+
const EMPTY_COLUMN_PINNING = {
|
|
5029
|
+
left: [],
|
|
5030
|
+
right: []
|
|
5031
|
+
};
|
|
4915
5032
|
/**
|
|
4916
5033
|
* Data grid built on TanStack Table. Renders a `<div>` wrapper around a DS
|
|
4917
5034
|
* `<Table>` (`<table>`), driven by `columns` + `data`, with opt-in sorting,
|
|
4918
|
-
* row selection, column resizing,
|
|
4919
|
-
* action bar, and loading/empty states.
|
|
5035
|
+
* row selection, column resizing, column pinning (`meta.pin`), virtualization,
|
|
5036
|
+
* infinite scroll, a floating action bar, and loading/empty states.
|
|
4920
5037
|
*
|
|
4921
5038
|
* @example
|
|
4922
5039
|
* ```tsx
|
|
@@ -4933,14 +5050,19 @@ function DataTable(componentProps) {
|
|
|
4933
5050
|
const selectionEnabled = selectionMode !== "none";
|
|
4934
5051
|
const multiSelect = selectionMode === "multiple";
|
|
4935
5052
|
const disabledKeySet = disabledKeys ?? EMPTY_KEYS;
|
|
5053
|
+
const userColumnPinning = React.useMemo(() => deriveColumnPinning(columns), [columns]);
|
|
5054
|
+
const hasUserPinnedColumns = (userColumnPinning.left?.length ?? 0) > 0 || (userColumnPinning.right?.length ?? 0) > 0;
|
|
4936
5055
|
const finalColumns = React.useMemo(() => {
|
|
4937
5056
|
if (!selectionEnabled) return columns;
|
|
4938
|
-
return [makeSelectColumn(multiSelect), ...columns];
|
|
5057
|
+
return [makeSelectColumn(multiSelect, { pin: hasUserPinnedColumns }), ...columns];
|
|
4939
5058
|
}, [
|
|
4940
5059
|
columns,
|
|
4941
5060
|
selectionEnabled,
|
|
4942
|
-
multiSelect
|
|
5061
|
+
multiSelect,
|
|
5062
|
+
hasUserPinnedColumns
|
|
4943
5063
|
]);
|
|
5064
|
+
const columnPinning = React.useMemo(() => deriveColumnPinning(finalColumns), [finalColumns]);
|
|
5065
|
+
const hasPinnedColumns = (columnPinning.left?.length ?? 0) > 0 || (columnPinning.right?.length ?? 0) > 0;
|
|
4944
5066
|
const [selectionSet, setSelectionSet] = useControllableState({
|
|
4945
5067
|
prop: selectedKeys,
|
|
4946
5068
|
defaultProp: defaultSelectedKeys,
|
|
@@ -4966,12 +5088,14 @@ function DataTable(componentProps) {
|
|
|
4966
5088
|
enableRowSelection: selectionEnabled ? (row) => !disabledKeySet.has(row.id) : false,
|
|
4967
5089
|
enableMultiRowSelection: multiSelect,
|
|
4968
5090
|
enableColumnResizing,
|
|
5091
|
+
enableColumnPinning: hasPinnedColumns,
|
|
4969
5092
|
columnResizeMode: "onChange",
|
|
4970
5093
|
onSortingChange,
|
|
4971
5094
|
onRowSelectionChange: handleRowSelectionChange,
|
|
4972
5095
|
state: {
|
|
4973
5096
|
...sorting !== void 0 && { sorting },
|
|
4974
|
-
rowSelection
|
|
5097
|
+
rowSelection,
|
|
5098
|
+
...hasPinnedColumns && { columnPinning }
|
|
4975
5099
|
}
|
|
4976
5100
|
});
|
|
4977
5101
|
const rows = table.getRowModel().rows;
|
|
@@ -4992,9 +5116,16 @@ function DataTable(componentProps) {
|
|
|
4992
5116
|
} else if (onRowClick) onRowClick(row.original);
|
|
4993
5117
|
};
|
|
4994
5118
|
const virtualizeRows = (componentProps.virtualizeRows ?? false) && fillHeight;
|
|
4995
|
-
const pinWidths = enableColumnResizing || virtualizeRows || fixedLayout;
|
|
4996
|
-
const colWidth = (size) => pinWidths ? { width: size } : void 0;
|
|
5119
|
+
const pinWidths = enableColumnResizing || virtualizeRows || fixedLayout || hasPinnedColumns;
|
|
4997
5120
|
const containerRef = React.useRef(null);
|
|
5121
|
+
const { atLeftEdge, atRightEdge } = useHorizontalScrollEdges(containerRef, hasPinnedColumns, table.getTotalSize());
|
|
5122
|
+
const getCellPinProps = (column, variant) => getPinnedCellProps(column, {
|
|
5123
|
+
pinWidths,
|
|
5124
|
+
variant,
|
|
5125
|
+
fillHeight,
|
|
5126
|
+
showLeftEdgeShadow: !atLeftEdge,
|
|
5127
|
+
showRightEdgeShadow: !atRightEdge
|
|
5128
|
+
});
|
|
4998
5129
|
const rowVirtualizer = useVirtualizer({
|
|
4999
5130
|
count: virtualizeRows ? rows.length : 0,
|
|
5000
5131
|
getScrollElement: () => virtualizeRows ? containerRef.current : null,
|
|
@@ -5006,15 +5137,16 @@ function DataTable(componentProps) {
|
|
|
5006
5137
|
const paddingTop = virtualItems && virtualItems.length > 0 ? virtualItems[0].start : 0;
|
|
5007
5138
|
const paddingBottom = virtualItems && virtualItems.length > 0 ? rowVirtualizer.getTotalSize() - virtualItems[virtualItems.length - 1].end : 0;
|
|
5008
5139
|
const showActionBar = !!actionBar && hasSelection;
|
|
5009
|
-
const reservedBottom = showActionBar ?
|
|
5140
|
+
const reservedBottom = showActionBar ? 64 : void 0;
|
|
5010
5141
|
const sentinelRef = useFetchMoreSentinel(onFetchMore, (node) => fillHeight ? node.closest("[data-slot=\"table-container\"]") : null, data.length);
|
|
5142
|
+
const leafColumnCount = table.getVisibleLeafColumns().length;
|
|
5011
5143
|
return /* @__PURE__ */ jsxs("div", {
|
|
5012
5144
|
className: cn("relative w-full", fillHeight && "flex min-h-0 flex-1 flex-col", className),
|
|
5013
5145
|
"aria-busy": isInitialLoading || isRefreshing || void 0,
|
|
5014
5146
|
children: [
|
|
5015
5147
|
/* @__PURE__ */ jsxs(Table, {
|
|
5016
5148
|
containerRef,
|
|
5017
|
-
className: cn(pinWidths && "table-fixed", fillHeight && "[&_[data-slot=table-head]]:sticky [&_[data-slot=table-head]]:top-0 [&_[data-slot=table-head]]:z-10 [&_[data-slot=table-head]]:bg-background [&_thead_tr]:border-b-0 [&_[data-slot=table-head]]:shadow-[inset_0_-1px_0_0_var(--border)]", fillHeight && showEmptyState && "h-full"),
|
|
5149
|
+
className: cn(pinWidths && "table-fixed", hasPinnedColumns && cn("border-separate border-spacing-0", "[&_[data-slot=table-cell]]:border-b [&_[data-slot=table-cell]]:border-border", "[&_tbody_tr:last-child_[data-slot=table-cell]]:border-b-0", "[&_tfoot_[data-slot=table-cell]]:border-t [&_tfoot_tr:last-child_[data-slot=table-cell]]:border-b-0", !fillHeight && "[&_[data-slot=table-head]]:border-b [&_[data-slot=table-head]]:border-border"), fillHeight && "[&_[data-slot=table-head]]:sticky [&_[data-slot=table-head]]:top-0 [&_[data-slot=table-head]]:z-10 [&_[data-slot=table-head]]:bg-background [&_thead_tr]:border-b-0 [&_[data-slot=table-head]]:shadow-[inset_0_-1px_0_0_var(--border)]", fillHeight && showEmptyState && "h-full"),
|
|
5018
5150
|
containerClassName: fillHeight ? "min-h-0 flex-1 overflow-y-auto" : void 0,
|
|
5019
5151
|
containerStyle: reservedBottom ? {
|
|
5020
5152
|
paddingBottom: reservedBottom,
|
|
@@ -5024,21 +5156,26 @@ function DataTable(componentProps) {
|
|
|
5024
5156
|
children: [
|
|
5025
5157
|
/* @__PURE__ */ jsx(TableHeader, { children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx(TableRow, {
|
|
5026
5158
|
className: enableColumnResizing ? "group/header-row" : void 0,
|
|
5027
|
-
children: headerGroup.headers.map((header) =>
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5159
|
+
children: headerGroup.headers.map((header) => {
|
|
5160
|
+
const pinProps = getCellPinProps(header.column, "header");
|
|
5161
|
+
return /* @__PURE__ */ jsxs(TableHead, {
|
|
5162
|
+
style: pinProps.style,
|
|
5163
|
+
className: cn(enableColumnResizing && "relative", pinProps.className),
|
|
5164
|
+
children: [header.isPlaceholder ? null : header.column.getCanSort() ? /* @__PURE__ */ jsx(SortableHeader, { header }) : flexRender(header.column.columnDef.header, header.getContext()), enableColumnResizing && header.column.getCanResize() ? /* @__PURE__ */ jsx(ResizeHandle, { header }) : null]
|
|
5165
|
+
}, header.id);
|
|
5166
|
+
})
|
|
5032
5167
|
}, headerGroup.id)) }),
|
|
5033
5168
|
/* @__PURE__ */ jsx(TableBody, { children: isInitialLoading ? /* @__PURE__ */ jsx(SkeletonRows, {
|
|
5034
|
-
columns:
|
|
5035
|
-
count: skeletonCount
|
|
5169
|
+
columns: table.getVisibleLeafColumns(),
|
|
5170
|
+
count: skeletonCount,
|
|
5171
|
+
getCellPinProps,
|
|
5172
|
+
groupRows: hasPinnedColumns
|
|
5036
5173
|
}) : rows.length ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5037
5174
|
virtualItems ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5038
5175
|
paddingTop > 0 && /* @__PURE__ */ jsx("tr", {
|
|
5039
5176
|
"aria-hidden": true,
|
|
5040
5177
|
children: /* @__PURE__ */ jsx("td", {
|
|
5041
|
-
colSpan:
|
|
5178
|
+
colSpan: leafColumnCount,
|
|
5042
5179
|
style: { height: paddingTop }
|
|
5043
5180
|
})
|
|
5044
5181
|
}),
|
|
@@ -5052,17 +5189,21 @@ function DataTable(componentProps) {
|
|
|
5052
5189
|
"data-state": row.getIsSelected() ? "selected" : void 0,
|
|
5053
5190
|
"aria-disabled": inert || void 0,
|
|
5054
5191
|
onClick: clickable ? () => handleRowActivate(row) : void 0,
|
|
5055
|
-
className: cn(clickable && "cursor-pointer", inert && "opacity-50"),
|
|
5056
|
-
children: row.getVisibleCells().map((cell) =>
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5192
|
+
className: cn(hasPinnedColumns && "group", clickable && "cursor-pointer", inert && "opacity-50"),
|
|
5193
|
+
children: row.getVisibleCells().map((cell) => {
|
|
5194
|
+
const pinProps = getCellPinProps(cell.column, "body");
|
|
5195
|
+
return /* @__PURE__ */ jsx(TableCell, {
|
|
5196
|
+
style: pinProps.style,
|
|
5197
|
+
className: pinProps.className,
|
|
5198
|
+
children: flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
5199
|
+
}, cell.id);
|
|
5200
|
+
})
|
|
5060
5201
|
}, row.id);
|
|
5061
5202
|
}),
|
|
5062
5203
|
paddingBottom > 0 && /* @__PURE__ */ jsx("tr", {
|
|
5063
5204
|
"aria-hidden": true,
|
|
5064
5205
|
children: /* @__PURE__ */ jsx("td", {
|
|
5065
|
-
colSpan:
|
|
5206
|
+
colSpan: leafColumnCount,
|
|
5066
5207
|
style: { height: paddingBottom }
|
|
5067
5208
|
})
|
|
5068
5209
|
})
|
|
@@ -5073,17 +5214,21 @@ function DataTable(componentProps) {
|
|
|
5073
5214
|
"data-state": row.getIsSelected() ? "selected" : void 0,
|
|
5074
5215
|
"aria-disabled": inert || void 0,
|
|
5075
5216
|
onClick: clickable ? () => handleRowActivate(row) : void 0,
|
|
5076
|
-
className: cn(clickable && "cursor-pointer", inert && "opacity-50"),
|
|
5077
|
-
children: row.getVisibleCells().map((cell) =>
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
5217
|
+
className: cn(hasPinnedColumns && "group", clickable && "cursor-pointer", inert && "opacity-50"),
|
|
5218
|
+
children: row.getVisibleCells().map((cell) => {
|
|
5219
|
+
const pinProps = getCellPinProps(cell.column, "body");
|
|
5220
|
+
return /* @__PURE__ */ jsx(TableCell, {
|
|
5221
|
+
style: pinProps.style,
|
|
5222
|
+
className: pinProps.className,
|
|
5223
|
+
children: flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
5224
|
+
}, cell.id);
|
|
5225
|
+
})
|
|
5081
5226
|
}, row.id);
|
|
5082
5227
|
}),
|
|
5083
5228
|
isLoadingMore ? /* @__PURE__ */ jsx(TableRow, {
|
|
5084
5229
|
className: "hover:bg-transparent",
|
|
5085
5230
|
children: /* @__PURE__ */ jsx(TableCell, {
|
|
5086
|
-
colSpan:
|
|
5231
|
+
colSpan: leafColumnCount,
|
|
5087
5232
|
className: "py-3",
|
|
5088
5233
|
children: /* @__PURE__ */ jsx("div", {
|
|
5089
5234
|
className: "flex items-center justify-center text-muted-foreground",
|
|
@@ -5095,14 +5240,14 @@ function DataTable(componentProps) {
|
|
|
5095
5240
|
"aria-hidden": true,
|
|
5096
5241
|
ref: sentinelRef,
|
|
5097
5242
|
children: /* @__PURE__ */ jsx("td", {
|
|
5098
|
-
colSpan:
|
|
5243
|
+
colSpan: leafColumnCount,
|
|
5099
5244
|
className: "h-px"
|
|
5100
5245
|
})
|
|
5101
5246
|
}) : null
|
|
5102
5247
|
] }) : emptyState ? /* @__PURE__ */ jsx(TableRow, {
|
|
5103
5248
|
className: "hover:bg-transparent",
|
|
5104
5249
|
children: /* @__PURE__ */ jsx(TableCell, {
|
|
5105
|
-
colSpan:
|
|
5250
|
+
colSpan: leafColumnCount,
|
|
5106
5251
|
className: "h-full p-0",
|
|
5107
5252
|
children: /* @__PURE__ */ jsx("div", {
|
|
5108
5253
|
className: cn("flex h-full items-center justify-center", !fillHeight && "min-h-60"),
|
|
@@ -5110,15 +5255,19 @@ function DataTable(componentProps) {
|
|
|
5110
5255
|
})
|
|
5111
5256
|
})
|
|
5112
5257
|
}) : null }),
|
|
5113
|
-
hasFooter && !isInitialLoading ? /* @__PURE__ */ jsx(TableFooter, { children: table.getFooterGroups().map((footerGroup) => /* @__PURE__ */ jsx(TableRow, { children: footerGroup.headers.map((header) =>
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
|
|
5258
|
+
hasFooter && !isInitialLoading ? /* @__PURE__ */ jsx(TableFooter, { children: table.getFooterGroups().map((footerGroup) => /* @__PURE__ */ jsx(TableRow, { children: footerGroup.headers.map((header) => {
|
|
5259
|
+
const pinProps = getCellPinProps(header.column, "footer");
|
|
5260
|
+
return /* @__PURE__ */ jsx(TableCell, {
|
|
5261
|
+
style: pinProps.style,
|
|
5262
|
+
className: pinProps.className,
|
|
5263
|
+
children: header.isPlaceholder ? null : flexRender(header.column.columnDef.footer, header.getContext())
|
|
5264
|
+
}, header.id);
|
|
5265
|
+
}) }, footerGroup.id)) }) : null
|
|
5117
5266
|
]
|
|
5118
5267
|
}),
|
|
5119
5268
|
isRefreshing ? /* @__PURE__ */ jsx("div", {
|
|
5120
5269
|
"data-slot": "table-loading-overlay",
|
|
5121
|
-
className: "bg-background/60 absolute inset-0 z-
|
|
5270
|
+
className: "bg-background/60 absolute inset-0 z-40 flex items-center justify-center",
|
|
5122
5271
|
children: /* @__PURE__ */ jsx(Spinner, {
|
|
5123
5272
|
size: "lg",
|
|
5124
5273
|
className: "text-muted-foreground"
|
|
@@ -5164,7 +5313,7 @@ function SelectRowCell({ row }) {
|
|
|
5164
5313
|
})
|
|
5165
5314
|
});
|
|
5166
5315
|
}
|
|
5167
|
-
function makeSelectColumn(multiSelect) {
|
|
5316
|
+
function makeSelectColumn(multiSelect, options) {
|
|
5168
5317
|
return {
|
|
5169
5318
|
id: SELECT_COLUMN_ID,
|
|
5170
5319
|
header: multiSelect ? ({ table }) => /* @__PURE__ */ jsx(SelectAllHeader, { table }) : () => null,
|
|
@@ -5172,7 +5321,8 @@ function makeSelectColumn(multiSelect) {
|
|
|
5172
5321
|
enableSorting: false,
|
|
5173
5322
|
enableHiding: false,
|
|
5174
5323
|
enableResizing: false,
|
|
5175
|
-
size: 40
|
|
5324
|
+
size: 40,
|
|
5325
|
+
...options?.pin ? { meta: { pin: "left" } } : {}
|
|
5176
5326
|
};
|
|
5177
5327
|
}
|
|
5178
5328
|
function ResizeHandle({ header }) {
|
|
@@ -5199,13 +5349,79 @@ function SortableHeader({ header }) {
|
|
|
5199
5349
|
})]
|
|
5200
5350
|
});
|
|
5201
5351
|
}
|
|
5202
|
-
|
|
5203
|
-
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
|
|
5352
|
+
/**
|
|
5353
|
+
* Resolves a TanStack column id the same way the table does
|
|
5354
|
+
* (`id` → `accessorKey` → string `header`). See `@tanstack/table-core`
|
|
5355
|
+
* `createColumn`.
|
|
5356
|
+
*/
|
|
5357
|
+
function getColumnDefId(col) {
|
|
5358
|
+
if (col.id != null) return col.id;
|
|
5359
|
+
if ("accessorKey" in col && typeof col.accessorKey === "string") return col.accessorKey.replace(/\./g, "_");
|
|
5360
|
+
if (typeof col.header === "string") return col.header;
|
|
5361
|
+
}
|
|
5362
|
+
/** Builds TanStack `columnPinning` state from declarative `meta.pin` on column defs. */
|
|
5363
|
+
function deriveColumnPinning(columns) {
|
|
5364
|
+
const left = [];
|
|
5365
|
+
const right = [];
|
|
5366
|
+
for (const col of columns) {
|
|
5367
|
+
const pin = col.meta?.pin;
|
|
5368
|
+
if (!pin) continue;
|
|
5369
|
+
const id = getColumnDefId(col);
|
|
5370
|
+
if (!id) {
|
|
5371
|
+
console.warn("[DataTable] Column with `meta.pin` has no resolvable id. Set `id`, a string `accessorKey`, or a string `header` so pinning can apply.");
|
|
5372
|
+
continue;
|
|
5373
|
+
}
|
|
5374
|
+
if (pin === "left") left.push(id);
|
|
5375
|
+
else right.push(id);
|
|
5376
|
+
}
|
|
5377
|
+
if (left.length === 0 && right.length === 0) return EMPTY_COLUMN_PINNING;
|
|
5378
|
+
return {
|
|
5379
|
+
left,
|
|
5380
|
+
right
|
|
5381
|
+
};
|
|
5382
|
+
}
|
|
5383
|
+
/**
|
|
5384
|
+
* Position/size/shadow props for a pinned (or width-pinned) cell. Uses CSS
|
|
5385
|
+
* `position: sticky` under the hood (TanStack column-pinning pattern). Edge
|
|
5386
|
+
* inset shadows only render on the outermost pinned column per side, and only
|
|
5387
|
+
* while horizontal scroll has moved away from that edge.
|
|
5388
|
+
*/
|
|
5389
|
+
function getPinnedCellProps(column, options) {
|
|
5390
|
+
const { pinWidths, variant, fillHeight, showLeftEdgeShadow, showRightEdgeShadow } = options;
|
|
5391
|
+
const style = pinWidths ? { width: `${column.getSize()}px` } : {};
|
|
5392
|
+
const isPinned = column.getIsPinned();
|
|
5393
|
+
if (!isPinned) return { style };
|
|
5394
|
+
style.position = "sticky";
|
|
5395
|
+
if (isPinned === "left") style.left = `${column.getStart("left")}px`;
|
|
5396
|
+
else style.right = `${column.getAfter("right")}px`;
|
|
5397
|
+
if (variant === "header" && fillHeight) style.top = 0;
|
|
5398
|
+
style.zIndex = variant === "header" ? 30 : 1;
|
|
5399
|
+
const isEdgeLeft = isPinned === "left" && column.getIsLastColumn("left");
|
|
5400
|
+
const isEdgeRight = isPinned === "right" && column.getIsFirstColumn("right");
|
|
5401
|
+
const shadows = [];
|
|
5402
|
+
if (variant === "header" && fillHeight) shadows.push("inset 0 -1px 0 0 var(--border)");
|
|
5403
|
+
if (isEdgeLeft && showLeftEdgeShadow) shadows.push("inset -1px 0 0 0 var(--border)");
|
|
5404
|
+
if (isEdgeRight && showRightEdgeShadow) shadows.push("inset 1px 0 0 0 var(--border)");
|
|
5405
|
+
if (shadows.length > 0) style.boxShadow = shadows.join(", ");
|
|
5406
|
+
return {
|
|
5407
|
+
style,
|
|
5408
|
+
className: cn(variant === "footer" ? "bg-[color-mix(in_oklch,var(--muted)_50%,var(--background))]" : variant === "body" ? cn("bg-background", "group-hover:bg-[color-mix(in_oklch,var(--accent)_30%,var(--background))]", "group-data-[state=selected]:bg-[color-mix(in_oklch,var(--accent)_50%,var(--background))]", "group-data-[state=selected]:group-hover:bg-[color-mix(in_oklch,var(--accent)_50%,var(--background))]") : "bg-background")
|
|
5409
|
+
};
|
|
5410
|
+
}
|
|
5411
|
+
function SkeletonRows({ columns, count, getCellPinProps, groupRows }) {
|
|
5412
|
+
return /* @__PURE__ */ jsx(Fragment, { children: Array.from({ length: count }, (_, i) => /* @__PURE__ */ jsx(TableRow, {
|
|
5413
|
+
className: groupRows ? "group" : void 0,
|
|
5414
|
+
children: columns.map((col) => {
|
|
5415
|
+
const pinProps = getCellPinProps(col, "body");
|
|
5416
|
+
return /* @__PURE__ */ jsx(TableCell, {
|
|
5417
|
+
"data-test": "loading-cell",
|
|
5418
|
+
style: pinProps.style,
|
|
5419
|
+
className: pinProps.className,
|
|
5420
|
+
children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-full max-w-full" })
|
|
5421
|
+
}, col.id);
|
|
5422
|
+
})
|
|
5423
|
+
}, `skeleton-${i}`)) });
|
|
5207
5424
|
}
|
|
5208
|
-
|
|
5209
5425
|
//#endregion
|
|
5210
5426
|
//#region src/components/tree.tsx
|
|
5211
5427
|
const TreeContext = React.createContext({
|
|
@@ -5257,7 +5473,7 @@ function Tree({ indent = 20, tree, className, ...props }) {
|
|
|
5257
5473
|
})
|
|
5258
5474
|
});
|
|
5259
5475
|
}
|
|
5260
|
-
const ACTIVATION_KEYS = new Set([
|
|
5476
|
+
const ACTIVATION_KEYS = /* @__PURE__ */ new Set([
|
|
5261
5477
|
"Enter",
|
|
5262
5478
|
" ",
|
|
5263
5479
|
"Spacebar"
|
|
@@ -5375,7 +5591,6 @@ function TreeDragLine({ className, ...props }) {
|
|
|
5375
5591
|
...props
|
|
5376
5592
|
});
|
|
5377
5593
|
}
|
|
5378
|
-
|
|
5379
5594
|
//#endregion
|
|
5380
5595
|
//#region src/components/data-tree.tsx
|
|
5381
5596
|
const ROOT_ID = "__data_tree_root__";
|
|
@@ -5476,12 +5691,13 @@ function DataTree(componentProps) {
|
|
|
5476
5691
|
if (!node) return /* @__PURE__ */ jsx(TreeItemLabel, {});
|
|
5477
5692
|
const label = getLabel(node);
|
|
5478
5693
|
if (!getIcon) return /* @__PURE__ */ jsx(TreeItemLabel, { children: label });
|
|
5694
|
+
const icon = getIcon(node, {
|
|
5695
|
+
isFolder: item.isFolder(),
|
|
5696
|
+
isExpanded: item.isExpanded()
|
|
5697
|
+
});
|
|
5479
5698
|
return /* @__PURE__ */ jsx(TreeItemLabel, { children: /* @__PURE__ */ jsxs("span", {
|
|
5480
5699
|
className: "flex items-center gap-2",
|
|
5481
|
-
children: [
|
|
5482
|
-
isFolder: item.isFolder(),
|
|
5483
|
-
isExpanded: item.isExpanded()
|
|
5484
|
-
}) ?? /* @__PURE__ */ jsx("span", {
|
|
5700
|
+
children: [icon ?? /* @__PURE__ */ jsx("span", {
|
|
5485
5701
|
"aria-hidden": "true",
|
|
5486
5702
|
className: "size-4 shrink-0"
|
|
5487
5703
|
}), label]
|
|
@@ -5508,7 +5724,6 @@ function DataTree(componentProps) {
|
|
|
5508
5724
|
})
|
|
5509
5725
|
});
|
|
5510
5726
|
}
|
|
5511
|
-
|
|
5512
5727
|
//#endregion
|
|
5513
5728
|
//#region src/components/label.tsx
|
|
5514
5729
|
/**
|
|
@@ -5531,7 +5746,6 @@ const Label = React.forwardRef((componentProps, forwardRef) => {
|
|
|
5531
5746
|
});
|
|
5532
5747
|
});
|
|
5533
5748
|
Label.displayName = "Label";
|
|
5534
|
-
|
|
5535
5749
|
//#endregion
|
|
5536
5750
|
//#region src/components/popover.tsx
|
|
5537
5751
|
/**
|
|
@@ -5607,7 +5821,8 @@ const PopoverContent = React.forwardRef((componentProps, forwardRef) => {
|
|
|
5607
5821
|
side,
|
|
5608
5822
|
sideOffset,
|
|
5609
5823
|
anchor,
|
|
5610
|
-
|
|
5824
|
+
"data-slot": "popover-positioner",
|
|
5825
|
+
className: "isolate z-popup",
|
|
5611
5826
|
children: /* @__PURE__ */ jsx(Popover$1.Popup, {
|
|
5612
5827
|
ref: forwardRef,
|
|
5613
5828
|
"data-slot": "popover-content",
|
|
@@ -5659,7 +5874,6 @@ const PopoverDescription = React.forwardRef((componentProps, forwardRef) => {
|
|
|
5659
5874
|
});
|
|
5660
5875
|
});
|
|
5661
5876
|
PopoverDescription.displayName = "PopoverDescription";
|
|
5662
|
-
|
|
5663
5877
|
//#endregion
|
|
5664
5878
|
//#region src/components/field.tsx
|
|
5665
5879
|
/**
|
|
@@ -5932,7 +6146,6 @@ const FieldError = React.forwardRef((componentProps, forwardRef) => {
|
|
|
5932
6146
|
});
|
|
5933
6147
|
});
|
|
5934
6148
|
FieldError.displayName = "FieldError";
|
|
5935
|
-
|
|
5936
6149
|
//#endregion
|
|
5937
6150
|
//#region src/i18n/date-mask.ts
|
|
5938
6151
|
/** Module-level cache: one Intl.DisplayNames instance per locale. */
|
|
@@ -6096,7 +6309,6 @@ function deriveDateMask(localeCode) {
|
|
|
6096
6309
|
return fallback;
|
|
6097
6310
|
}
|
|
6098
6311
|
}
|
|
6099
|
-
|
|
6100
6312
|
//#endregion
|
|
6101
6313
|
//#region src/hooks/segmented-date/segment-math.ts
|
|
6102
6314
|
/**
|
|
@@ -6144,7 +6356,6 @@ function clampDayToMonth(day, month, year) {
|
|
|
6144
6356
|
const max = daysInMonth(month, year);
|
|
6145
6357
|
return day > max ? max : day;
|
|
6146
6358
|
}
|
|
6147
|
-
|
|
6148
6359
|
//#endregion
|
|
6149
6360
|
//#region src/hooks/segmented-date/reducer.ts
|
|
6150
6361
|
function toCommitted(d, m, y) {
|
|
@@ -6201,9 +6412,9 @@ function applyDigitToSegment(state, segment, digit) {
|
|
|
6201
6412
|
};
|
|
6202
6413
|
if (segment === "year") {
|
|
6203
6414
|
if (newAcc.length > 4) return state;
|
|
6204
|
-
const num
|
|
6415
|
+
const num = parseInt(newAcc, 10);
|
|
6205
6416
|
if (newAcc.length === 4) {
|
|
6206
|
-
const clamped = clamp(num
|
|
6417
|
+
const clamped = clamp(num, 1e3, 9999);
|
|
6207
6418
|
return {
|
|
6208
6419
|
...state,
|
|
6209
6420
|
year: clamped,
|
|
@@ -6215,8 +6426,8 @@ function applyDigitToSegment(state, segment, digit) {
|
|
|
6215
6426
|
}
|
|
6216
6427
|
return {
|
|
6217
6428
|
...state,
|
|
6218
|
-
year: num
|
|
6219
|
-
day: clampDayToMonth(state.day, state.month, num
|
|
6429
|
+
year: num,
|
|
6430
|
+
day: clampDayToMonth(state.day, state.month, num),
|
|
6220
6431
|
accumulator: newAcc,
|
|
6221
6432
|
announce: null
|
|
6222
6433
|
};
|
|
@@ -6242,12 +6453,13 @@ function processDigitsForSegment(segType, digitsStr, currentValues, yearMin, yea
|
|
|
6242
6453
|
acc += d;
|
|
6243
6454
|
consumed++;
|
|
6244
6455
|
const num = parseInt(acc, 10);
|
|
6245
|
-
if (segType === "year")
|
|
6246
|
-
|
|
6247
|
-
|
|
6248
|
-
|
|
6249
|
-
|
|
6250
|
-
|
|
6456
|
+
if (segType === "year") {
|
|
6457
|
+
if (acc.length === 4) {
|
|
6458
|
+
finalVal = clamp(num, 1e3, 9999);
|
|
6459
|
+
shouldAdvance = true;
|
|
6460
|
+
break;
|
|
6461
|
+
} else finalVal = num;
|
|
6462
|
+
} else {
|
|
6251
6463
|
const autoAdvanceThreshold = segType === "month" ? 1 : 3;
|
|
6252
6464
|
if (acc.length === 1 && num > autoAdvanceThreshold) {
|
|
6253
6465
|
finalVal = clamp(num, segMin, segMax);
|
|
@@ -6441,14 +6653,14 @@ function segmentedDateReducer(state, action) {
|
|
|
6441
6653
|
const candidateMonth = segment === "month" ? next : state.month;
|
|
6442
6654
|
const candidateYear = segment === "year" ? next : state.year;
|
|
6443
6655
|
const newDay = clampDayToMonth(state.day, candidateMonth, candidateYear);
|
|
6444
|
-
let announceText
|
|
6445
|
-
if (next !== cur) announceText
|
|
6656
|
+
let announceText = null;
|
|
6657
|
+
if (next !== cur) announceText = segment === "month" ? monthNames[next - 1] ?? String(next) : String(next);
|
|
6446
6658
|
return {
|
|
6447
6659
|
...state,
|
|
6448
6660
|
[segment]: next,
|
|
6449
6661
|
day: newDay,
|
|
6450
6662
|
accumulator: "",
|
|
6451
|
-
announce: announceText
|
|
6663
|
+
announce: announceText
|
|
6452
6664
|
};
|
|
6453
6665
|
}
|
|
6454
6666
|
const realDay = state.day;
|
|
@@ -6467,14 +6679,14 @@ function segmentedDateReducer(state, action) {
|
|
|
6467
6679
|
accumulator: "",
|
|
6468
6680
|
announce: null
|
|
6469
6681
|
};
|
|
6470
|
-
let announceText
|
|
6471
|
-
if (next !== cur) announceText
|
|
6682
|
+
let announceText = null;
|
|
6683
|
+
if (next !== cur) announceText = segment === "month" ? monthNames[next - 1] ?? String(next) : String(next);
|
|
6472
6684
|
return {
|
|
6473
6685
|
...state,
|
|
6474
6686
|
[segment]: next,
|
|
6475
6687
|
day: newDay,
|
|
6476
6688
|
accumulator: "",
|
|
6477
|
-
announce: announceText
|
|
6689
|
+
announce: announceText
|
|
6478
6690
|
};
|
|
6479
6691
|
}
|
|
6480
6692
|
const landedValue = findFirstAllowed(next, direction, minVal, maxVal, (candidate) => {
|
|
@@ -6691,7 +6903,6 @@ function isComplete(state) {
|
|
|
6691
6903
|
function isAllEmpty(state) {
|
|
6692
6904
|
return state.day === null && state.month === null && state.year === null;
|
|
6693
6905
|
}
|
|
6694
|
-
|
|
6695
6906
|
//#endregion
|
|
6696
6907
|
//#region src/hooks/use-segmented-date.ts
|
|
6697
6908
|
/**
|
|
@@ -7165,7 +7376,6 @@ function useSegmentedDate(options) {
|
|
|
7165
7376
|
groupRef
|
|
7166
7377
|
};
|
|
7167
7378
|
}
|
|
7168
|
-
|
|
7169
7379
|
//#endregion
|
|
7170
7380
|
//#region src/i18n/number-format.ts
|
|
7171
7381
|
/**
|
|
@@ -7199,16 +7409,15 @@ function resolveLocale(localeProp, dsLocale) {
|
|
|
7199
7409
|
* locale); otherwise `undefined`, so an invalid option (e.g. a bad `currency` or
|
|
7200
7410
|
* `unit`) degrades to default number formatting instead of throwing a `RangeError`.
|
|
7201
7411
|
*/
|
|
7202
|
-
function resolveFormat(locale, format
|
|
7203
|
-
if (format
|
|
7412
|
+
function resolveFormat(locale, format) {
|
|
7413
|
+
if (format == null) return;
|
|
7204
7414
|
try {
|
|
7205
|
-
new Intl.NumberFormat(locale, format
|
|
7206
|
-
return format
|
|
7415
|
+
new Intl.NumberFormat(locale, format).format(0);
|
|
7416
|
+
return format;
|
|
7207
7417
|
} catch {
|
|
7208
7418
|
return;
|
|
7209
7419
|
}
|
|
7210
7420
|
}
|
|
7211
|
-
|
|
7212
7421
|
//#endregion
|
|
7213
7422
|
//#region src/i18n/use-ds-locale.ts
|
|
7214
7423
|
function subscribeToLanguage(onChange) {
|
|
@@ -7224,7 +7433,6 @@ function subscribeToLanguage(onChange) {
|
|
|
7224
7433
|
function useDsLocale() {
|
|
7225
7434
|
return useSyncExternalStore(subscribeToLanguage, () => dsI18n.language, () => dsI18n.language);
|
|
7226
7435
|
}
|
|
7227
|
-
|
|
7228
7436
|
//#endregion
|
|
7229
7437
|
//#region src/components/date-picker.tsx
|
|
7230
7438
|
function DateInputSegment({ segmentProps, disabled, id }) {
|
|
@@ -7531,10 +7739,11 @@ const DatePicker = React.forwardRef((componentProps, forwardRef) => {
|
|
|
7531
7739
|
if (fromBlocked || toBlocked) {
|
|
7532
7740
|
const nextFrom = fromBlocked ? void 0 : rangeValue?.from;
|
|
7533
7741
|
const nextTo = toBlocked ? void 0 : rangeValue?.to;
|
|
7534
|
-
|
|
7742
|
+
const next = nextFrom ? {
|
|
7535
7743
|
from: nextFrom,
|
|
7536
7744
|
...nextTo ? { to: nextTo } : {}
|
|
7537
|
-
} : void 0
|
|
7745
|
+
} : void 0;
|
|
7746
|
+
commitRange(next);
|
|
7538
7747
|
}
|
|
7539
7748
|
}
|
|
7540
7749
|
}, [constraintMatchers]);
|
|
@@ -7594,8 +7803,10 @@ const DatePicker = React.forwardRef((componentProps, forwardRef) => {
|
|
|
7594
7803
|
onReject
|
|
7595
7804
|
});
|
|
7596
7805
|
const handleSelectDate = React.useCallback((date) => {
|
|
7597
|
-
if (componentProps.mode !== "range")
|
|
7598
|
-
|
|
7806
|
+
if (componentProps.mode !== "range") {
|
|
7807
|
+
if (date) singleSegmented.onCalendarPick(date);
|
|
7808
|
+
else commitSingleDate(void 0);
|
|
7809
|
+
}
|
|
7599
7810
|
handleSetIsOpen(false);
|
|
7600
7811
|
}, [
|
|
7601
7812
|
componentProps.mode,
|
|
@@ -7618,10 +7829,11 @@ const DatePicker = React.forwardRef((componentProps, forwardRef) => {
|
|
|
7618
7829
|
onCommit: React.useCallback((date) => {
|
|
7619
7830
|
if (date) {
|
|
7620
7831
|
if (!commitRangeEndpoint(date)) return;
|
|
7621
|
-
|
|
7832
|
+
const next = liveToRef.current ? {
|
|
7622
7833
|
from: date,
|
|
7623
7834
|
to: liveToRef.current
|
|
7624
|
-
} : { from: date }
|
|
7835
|
+
} : { from: date };
|
|
7836
|
+
commitRange(next);
|
|
7625
7837
|
setCalendarMonth(date);
|
|
7626
7838
|
const justCompleted = !fromWasCompleteRef.current;
|
|
7627
7839
|
fromWasCompleteRef.current = true;
|
|
@@ -7909,7 +8121,6 @@ const DatePicker = React.forwardRef((componentProps, forwardRef) => {
|
|
|
7909
8121
|
});
|
|
7910
8122
|
});
|
|
7911
8123
|
DatePicker.displayName = "DatePicker";
|
|
7912
|
-
|
|
7913
8124
|
//#endregion
|
|
7914
8125
|
//#region src/components/scroll-area.tsx
|
|
7915
8126
|
/**
|
|
@@ -7962,7 +8173,6 @@ const ScrollBar = React.forwardRef((componentProps, forwardRef) => {
|
|
|
7962
8173
|
});
|
|
7963
8174
|
});
|
|
7964
8175
|
ScrollBar.displayName = "ScrollBar";
|
|
7965
|
-
|
|
7966
8176
|
//#endregion
|
|
7967
8177
|
//#region src/components/drawer.tsx
|
|
7968
8178
|
const DrawerContext = createContext({ position: "bottom" });
|
|
@@ -8126,13 +8336,14 @@ DrawerPopup.displayName = "DrawerPopup";
|
|
|
8126
8336
|
*/
|
|
8127
8337
|
const DrawerHeader = React.forwardRef((componentProps, forwardRef) => {
|
|
8128
8338
|
const { className, allowSelection = false, render, ...props } = componentProps;
|
|
8339
|
+
const defaultProps = {
|
|
8340
|
+
className: cn("flex flex-col gap-2 p-6 in-[[data-slot=drawer-popup]:has([data-slot=drawer-panel])]:pb-3 max-sm:pb-4", !allowSelection && "cursor-default", className),
|
|
8341
|
+
ref: forwardRef,
|
|
8342
|
+
"data-slot": "drawer-header"
|
|
8343
|
+
};
|
|
8129
8344
|
return useRender({
|
|
8130
8345
|
defaultTagName: "div",
|
|
8131
|
-
props: mergeProps(
|
|
8132
|
-
className: cn("flex flex-col gap-2 p-6 in-[[data-slot=drawer-popup]:has([data-slot=drawer-panel])]:pb-3 max-sm:pb-4", !allowSelection && "cursor-default", className),
|
|
8133
|
-
ref: forwardRef,
|
|
8134
|
-
"data-slot": "drawer-header"
|
|
8135
|
-
}, props),
|
|
8346
|
+
props: mergeProps(defaultProps, props),
|
|
8136
8347
|
render: allowSelection ? /* @__PURE__ */ jsx(DrawerContent, { render }) : render
|
|
8137
8348
|
});
|
|
8138
8349
|
});
|
|
@@ -8143,13 +8354,14 @@ DrawerHeader.displayName = "DrawerHeader";
|
|
|
8143
8354
|
*/
|
|
8144
8355
|
const DrawerFooter = React.forwardRef((componentProps, forwardRef) => {
|
|
8145
8356
|
const { className, variant = "default", allowSelection = true, render, ...props } = componentProps;
|
|
8357
|
+
const defaultProps = {
|
|
8358
|
+
className: cn("flex flex-col-reverse gap-2 px-6 pb-(--safe-area-inset-bottom,0px) sm:flex-row sm:justify-end", !allowSelection && "cursor-default", variant === "default" && "border-t bg-muted/72 pt-4 pb-[calc(env(safe-area-inset-bottom,0px)+--spacing(4))]", variant === "bare" && "in-[[data-slot=drawer-popup]:has([data-slot=drawer-panel])]:pt-3 pt-4 pb-[calc(env(safe-area-inset-bottom,0px)+--spacing(6))]", className),
|
|
8359
|
+
ref: forwardRef,
|
|
8360
|
+
"data-slot": "drawer-footer"
|
|
8361
|
+
};
|
|
8146
8362
|
return useRender({
|
|
8147
8363
|
defaultTagName: "div",
|
|
8148
|
-
props: mergeProps(
|
|
8149
|
-
className: cn("flex flex-col-reverse gap-2 px-6 pb-(--safe-area-inset-bottom,0px) sm:flex-row sm:justify-end", !allowSelection && "cursor-default", variant === "default" && "border-t bg-muted/72 pt-4 pb-[calc(env(safe-area-inset-bottom,0px)+--spacing(4))]", variant === "bare" && "in-[[data-slot=drawer-popup]:has([data-slot=drawer-panel])]:pt-3 pt-4 pb-[calc(env(safe-area-inset-bottom,0px)+--spacing(6))]", className),
|
|
8150
|
-
ref: forwardRef,
|
|
8151
|
-
"data-slot": "drawer-footer"
|
|
8152
|
-
}, props),
|
|
8364
|
+
props: mergeProps(defaultProps, props),
|
|
8153
8365
|
render: allowSelection ? /* @__PURE__ */ jsx(DrawerContent, { render }) : render
|
|
8154
8366
|
});
|
|
8155
8367
|
});
|
|
@@ -8188,13 +8400,14 @@ DrawerDescription.displayName = "DrawerDescription";
|
|
|
8188
8400
|
*/
|
|
8189
8401
|
const DrawerPanel = React.forwardRef((componentProps, forwardRef) => {
|
|
8190
8402
|
const { className, scrollFade = true, scrollable = true, allowSelection = true, render, ...props } = componentProps;
|
|
8403
|
+
const defaultProps = {
|
|
8404
|
+
className: cn("p-6 in-[[data-slot=drawer-popup]:has([data-slot=drawer-header])]:pt-1 in-[[data-slot=drawer-popup]:has([data-slot=drawer-footer]:not(.border-t))]:pb-1", !allowSelection && "cursor-default", className),
|
|
8405
|
+
ref: forwardRef,
|
|
8406
|
+
"data-slot": "drawer-panel"
|
|
8407
|
+
};
|
|
8191
8408
|
const content = useRender({
|
|
8192
8409
|
defaultTagName: "div",
|
|
8193
|
-
props: mergeProps(
|
|
8194
|
-
className: cn("p-6 in-[[data-slot=drawer-popup]:has([data-slot=drawer-header])]:pt-1 in-[[data-slot=drawer-popup]:has([data-slot=drawer-footer]:not(.border-t))]:pb-1", !allowSelection && "cursor-default", className),
|
|
8195
|
-
ref: forwardRef,
|
|
8196
|
-
"data-slot": "drawer-panel"
|
|
8197
|
-
}, props),
|
|
8410
|
+
props: mergeProps(defaultProps, props),
|
|
8198
8411
|
render: allowSelection ? /* @__PURE__ */ jsx(DrawerContent, { render }) : render
|
|
8199
8412
|
});
|
|
8200
8413
|
if (scrollable) return /* @__PURE__ */ jsx(ScrollArea, {
|
|
@@ -8213,15 +8426,15 @@ const DrawerBar = React.forwardRef((componentProps, forwardRef) => {
|
|
|
8213
8426
|
const { className, position: positionProp, render, ...props } = componentProps;
|
|
8214
8427
|
const { position: contextPosition } = useContext(DrawerContext);
|
|
8215
8428
|
const position = positionProp ?? contextPosition;
|
|
8216
|
-
const
|
|
8429
|
+
const defaultProps = {
|
|
8430
|
+
"aria-hidden": true,
|
|
8431
|
+
className: cn("absolute flex touch-none items-center justify-center p-3 before:rounded-full before:bg-input", position === "left" || position === "right" ? "inset-y-0 before:h-12 before:w-1" : "inset-x-0 before:h-1 before:w-12", position === "top" && "bottom-0", position === "bottom" && "top-0", position === "left" && "right-0", position === "right" && "left-0", className),
|
|
8432
|
+
ref: forwardRef,
|
|
8433
|
+
"data-slot": "drawer-bar"
|
|
8434
|
+
};
|
|
8217
8435
|
return useRender({
|
|
8218
8436
|
defaultTagName: "div",
|
|
8219
|
-
props: mergeProps(
|
|
8220
|
-
"aria-hidden": true,
|
|
8221
|
-
className: cn("absolute flex touch-none items-center justify-center p-3 before:rounded-full before:bg-input", horizontal ? "inset-y-0 before:h-12 before:w-1" : "inset-x-0 before:h-1 before:w-12", position === "top" && "bottom-0", position === "bottom" && "top-0", position === "left" && "right-0", position === "right" && "left-0", className),
|
|
8222
|
-
ref: forwardRef,
|
|
8223
|
-
"data-slot": "drawer-bar"
|
|
8224
|
-
}, props),
|
|
8437
|
+
props: mergeProps(defaultProps, props),
|
|
8225
8438
|
render
|
|
8226
8439
|
});
|
|
8227
8440
|
});
|
|
@@ -8238,13 +8451,14 @@ const DrawerContent = DrawerPrimitive.Content;
|
|
|
8238
8451
|
*/
|
|
8239
8452
|
const DrawerMenu = React.forwardRef((componentProps, forwardRef) => {
|
|
8240
8453
|
const { className, render, ...props } = componentProps;
|
|
8454
|
+
const defaultProps = {
|
|
8455
|
+
className: cn("-m-2 flex flex-col", className),
|
|
8456
|
+
ref: forwardRef,
|
|
8457
|
+
"data-slot": "drawer-menu"
|
|
8458
|
+
};
|
|
8241
8459
|
return useRender({
|
|
8242
8460
|
defaultTagName: "nav",
|
|
8243
|
-
props: mergeProps(
|
|
8244
|
-
className: cn("-m-2 flex flex-col", className),
|
|
8245
|
-
ref: forwardRef,
|
|
8246
|
-
"data-slot": "drawer-menu"
|
|
8247
|
-
}, props),
|
|
8461
|
+
props: mergeProps(defaultProps, props),
|
|
8248
8462
|
render
|
|
8249
8463
|
});
|
|
8250
8464
|
});
|
|
@@ -8255,16 +8469,17 @@ DrawerMenu.displayName = "DrawerMenu";
|
|
|
8255
8469
|
*/
|
|
8256
8470
|
const DrawerMenuItem = React.forwardRef((componentProps, forwardRef) => {
|
|
8257
8471
|
const { className, variant = "default", render, disabled, ...props } = componentProps;
|
|
8472
|
+
const defaultProps = {
|
|
8473
|
+
className: cn("flex min-h-9 w-full cursor-default select-none items-center gap-2 rounded-sm px-2 py-1 text-base text-foreground outline-none hover:bg-accent hover:text-accent-foreground disabled:pointer-events-none disabled:opacity-64 data-[variant=destructive]:text-destructive-foreground sm:min-h-8 sm:text-sm [&>svg:not([class*='opacity-'])]:opacity-80 [&>svg:not([class*='size-'])]:size-4.5 sm:[&>svg:not([class*='size-'])]:size-4 [&>svg]:pointer-events-none [&>svg]:-mx-0.5 [&>svg]:shrink-0", className),
|
|
8474
|
+
ref: forwardRef,
|
|
8475
|
+
"data-slot": "drawer-menu-item",
|
|
8476
|
+
"data-variant": variant,
|
|
8477
|
+
disabled,
|
|
8478
|
+
type: "button"
|
|
8479
|
+
};
|
|
8258
8480
|
return useRender({
|
|
8259
8481
|
defaultTagName: "button",
|
|
8260
|
-
props: mergeProps(
|
|
8261
|
-
className: cn("flex min-h-9 w-full cursor-default select-none items-center gap-2 rounded-sm px-2 py-1 text-base text-foreground outline-none hover:bg-accent hover:text-accent-foreground disabled:pointer-events-none disabled:opacity-64 data-[variant=destructive]:text-destructive-foreground sm:min-h-8 sm:text-sm [&>svg:not([class*='opacity-'])]:opacity-80 [&>svg:not([class*='size-'])]:size-4.5 sm:[&>svg:not([class*='size-'])]:size-4 [&>svg]:pointer-events-none [&>svg]:-mx-0.5 [&>svg]:shrink-0", className),
|
|
8262
|
-
ref: forwardRef,
|
|
8263
|
-
"data-slot": "drawer-menu-item",
|
|
8264
|
-
"data-variant": variant,
|
|
8265
|
-
disabled,
|
|
8266
|
-
type: "button"
|
|
8267
|
-
}, props),
|
|
8482
|
+
props: mergeProps(defaultProps, props),
|
|
8268
8483
|
render
|
|
8269
8484
|
});
|
|
8270
8485
|
});
|
|
@@ -8275,13 +8490,14 @@ DrawerMenuItem.displayName = "DrawerMenuItem";
|
|
|
8275
8490
|
*/
|
|
8276
8491
|
const DrawerMenuSeparator = React.forwardRef((componentProps, forwardRef) => {
|
|
8277
8492
|
const { className, render, ...props } = componentProps;
|
|
8493
|
+
const defaultProps = {
|
|
8494
|
+
className: cn("mx-2 my-1 h-px bg-border", className),
|
|
8495
|
+
ref: forwardRef,
|
|
8496
|
+
"data-slot": "drawer-menu-separator"
|
|
8497
|
+
};
|
|
8278
8498
|
return useRender({
|
|
8279
8499
|
defaultTagName: "div",
|
|
8280
|
-
props: mergeProps(
|
|
8281
|
-
className: cn("mx-2 my-1 h-px bg-border", className),
|
|
8282
|
-
ref: forwardRef,
|
|
8283
|
-
"data-slot": "drawer-menu-separator"
|
|
8284
|
-
}, props),
|
|
8500
|
+
props: mergeProps(defaultProps, props),
|
|
8285
8501
|
render
|
|
8286
8502
|
});
|
|
8287
8503
|
});
|
|
@@ -8292,13 +8508,14 @@ DrawerMenuSeparator.displayName = "DrawerMenuSeparator";
|
|
|
8292
8508
|
*/
|
|
8293
8509
|
const DrawerMenuGroup = React.forwardRef((componentProps, forwardRef) => {
|
|
8294
8510
|
const { className, render, ...props } = componentProps;
|
|
8511
|
+
const defaultProps = {
|
|
8512
|
+
className: cn("flex flex-col", className),
|
|
8513
|
+
ref: forwardRef,
|
|
8514
|
+
"data-slot": "drawer-menu-group"
|
|
8515
|
+
};
|
|
8295
8516
|
return useRender({
|
|
8296
8517
|
defaultTagName: "div",
|
|
8297
|
-
props: mergeProps(
|
|
8298
|
-
className: cn("flex flex-col", className),
|
|
8299
|
-
ref: forwardRef,
|
|
8300
|
-
"data-slot": "drawer-menu-group"
|
|
8301
|
-
}, props),
|
|
8518
|
+
props: mergeProps(defaultProps, props),
|
|
8302
8519
|
render
|
|
8303
8520
|
});
|
|
8304
8521
|
});
|
|
@@ -8309,13 +8526,14 @@ DrawerMenuGroup.displayName = "DrawerMenuGroup";
|
|
|
8309
8526
|
*/
|
|
8310
8527
|
const DrawerMenuGroupLabel = React.forwardRef((componentProps, forwardRef) => {
|
|
8311
8528
|
const { className, render, ...props } = componentProps;
|
|
8529
|
+
const defaultProps = {
|
|
8530
|
+
className: cn("px-2 py-1.5 font-medium text-muted-foreground text-xs", className),
|
|
8531
|
+
ref: forwardRef,
|
|
8532
|
+
"data-slot": "drawer-menu-group-label"
|
|
8533
|
+
};
|
|
8312
8534
|
return useRender({
|
|
8313
8535
|
defaultTagName: "div",
|
|
8314
|
-
props: mergeProps(
|
|
8315
|
-
className: cn("px-2 py-1.5 font-medium text-muted-foreground text-xs", className),
|
|
8316
|
-
ref: forwardRef,
|
|
8317
|
-
"data-slot": "drawer-menu-group-label"
|
|
8318
|
-
}, props),
|
|
8536
|
+
props: mergeProps(defaultProps, props),
|
|
8319
8537
|
render
|
|
8320
8538
|
});
|
|
8321
8539
|
});
|
|
@@ -8428,7 +8646,6 @@ const DrawerMenuRadioItem = React.forwardRef((componentProps, forwardRef) => {
|
|
|
8428
8646
|
});
|
|
8429
8647
|
});
|
|
8430
8648
|
DrawerMenuRadioItem.displayName = "DrawerMenuRadioItem";
|
|
8431
|
-
|
|
8432
8649
|
//#endregion
|
|
8433
8650
|
//#region src/components/dropdown-menu.tsx
|
|
8434
8651
|
/**
|
|
@@ -8493,7 +8710,8 @@ const DropdownMenuContent = React.forwardRef((componentProps, forwardRef) => {
|
|
|
8493
8710
|
return /* @__PURE__ */ jsx(Menu.Portal, {
|
|
8494
8711
|
container,
|
|
8495
8712
|
children: /* @__PURE__ */ jsx(Menu.Positioner, {
|
|
8496
|
-
|
|
8713
|
+
"data-slot": "dropdown-menu-positioner",
|
|
8714
|
+
className: "isolate z-popup outline-none",
|
|
8497
8715
|
align,
|
|
8498
8716
|
alignOffset,
|
|
8499
8717
|
side,
|
|
@@ -8698,7 +8916,6 @@ const DropdownMenuAddon = React.forwardRef((componentProps, forwardRef) => {
|
|
|
8698
8916
|
});
|
|
8699
8917
|
});
|
|
8700
8918
|
DropdownMenuAddon.displayName = "DropdownMenuAddon";
|
|
8701
|
-
|
|
8702
8919
|
//#endregion
|
|
8703
8920
|
//#region src/components/empty.tsx
|
|
8704
8921
|
/**
|
|
@@ -8808,7 +9025,6 @@ const EmptyContent = React.forwardRef((componentProps, forwardRef) => {
|
|
|
8808
9025
|
});
|
|
8809
9026
|
});
|
|
8810
9027
|
EmptyContent.displayName = "EmptyContent";
|
|
8811
|
-
|
|
8812
9028
|
//#endregion
|
|
8813
9029
|
//#region src/components/dropzone.tsx
|
|
8814
9030
|
const DropzoneContext = React.createContext(null);
|
|
@@ -8825,7 +9041,7 @@ const DEFAULT_ERROR_MESSAGES = {
|
|
|
8825
9041
|
};
|
|
8826
9042
|
function formatBytes(bytes) {
|
|
8827
9043
|
if (bytes < 1024) return `${bytes} B`;
|
|
8828
|
-
if (bytes <
|
|
9044
|
+
if (bytes < 1048576) return `${(bytes / 1024).toFixed(0)} KB`;
|
|
8829
9045
|
return `${(bytes / 1024 / 1024).toFixed(0)} MB`;
|
|
8830
9046
|
}
|
|
8831
9047
|
function parseAccept(accept) {
|
|
@@ -9111,7 +9327,6 @@ const DropzoneTrigger = React.forwardRef((componentProps, forwardRef) => {
|
|
|
9111
9327
|
});
|
|
9112
9328
|
});
|
|
9113
9329
|
DropzoneTrigger.displayName = "DropzoneTrigger";
|
|
9114
|
-
|
|
9115
9330
|
//#endregion
|
|
9116
9331
|
//#region src/components/theme-provider.tsx
|
|
9117
9332
|
/**
|
|
@@ -9137,7 +9352,6 @@ function ThemeProvider(componentProps) {
|
|
|
9137
9352
|
children
|
|
9138
9353
|
});
|
|
9139
9354
|
}
|
|
9140
|
-
|
|
9141
9355
|
//#endregion
|
|
9142
9356
|
//#region src/components/emoji-picker.tsx
|
|
9143
9357
|
/** Emoji category identifiers, for the `categories` prop of `EmojiPickerContent`. */
|
|
@@ -9248,7 +9462,6 @@ function EmojiPickerContent({ className, align = "start", searchPlaceholder, cat
|
|
|
9248
9462
|
})
|
|
9249
9463
|
});
|
|
9250
9464
|
}
|
|
9251
|
-
|
|
9252
9465
|
//#endregion
|
|
9253
9466
|
//#region src/components/fab.tsx
|
|
9254
9467
|
/**
|
|
@@ -9300,7 +9513,6 @@ const FAB = React.forwardRef((componentProps, forwardRef) => {
|
|
|
9300
9513
|
});
|
|
9301
9514
|
});
|
|
9302
9515
|
FAB.displayName = "FAB";
|
|
9303
|
-
|
|
9304
9516
|
//#endregion
|
|
9305
9517
|
//#region src/components/gauge.tsx
|
|
9306
9518
|
const GAUGES = 8;
|
|
@@ -9350,7 +9562,6 @@ const Gauge = React.forwardRef((componentProps, forwardRef) => {
|
|
|
9350
9562
|
});
|
|
9351
9563
|
});
|
|
9352
9564
|
Gauge.displayName = "Gauge";
|
|
9353
|
-
|
|
9354
9565
|
//#endregion
|
|
9355
9566
|
//#region src/components/hover-card.tsx
|
|
9356
9567
|
/**
|
|
@@ -9435,7 +9646,8 @@ const HoverCardContent = React.forwardRef((componentProps, forwardRef) => {
|
|
|
9435
9646
|
sideOffset,
|
|
9436
9647
|
align,
|
|
9437
9648
|
alignOffset,
|
|
9438
|
-
|
|
9649
|
+
"data-slot": "hover-card-positioner",
|
|
9650
|
+
className: "isolate z-popup",
|
|
9439
9651
|
children: /* @__PURE__ */ jsx(PreviewCard.Popup, {
|
|
9440
9652
|
ref: forwardRef,
|
|
9441
9653
|
"data-slot": "hover-card-content",
|
|
@@ -9445,7 +9657,6 @@ const HoverCardContent = React.forwardRef((componentProps, forwardRef) => {
|
|
|
9445
9657
|
}) });
|
|
9446
9658
|
});
|
|
9447
9659
|
HoverCardContent.displayName = "HoverCardContent";
|
|
9448
|
-
|
|
9449
9660
|
//#endregion
|
|
9450
9661
|
//#region src/components/inline-edit.tsx
|
|
9451
9662
|
/** Context shared between InlineEditSelect root and its compound sub-parts. */
|
|
@@ -9530,7 +9741,6 @@ function useInlineEditCommit({ value, defaultValue, onValueChange, onValueCommit
|
|
|
9530
9741
|
}, [isControlled, onValueChange])
|
|
9531
9742
|
};
|
|
9532
9743
|
}
|
|
9533
|
-
|
|
9534
9744
|
//#endregion
|
|
9535
9745
|
//#region src/components/inline-edit-input.tsx
|
|
9536
9746
|
/**
|
|
@@ -9605,7 +9815,6 @@ const InlineEditInput = React.forwardRef((componentProps, forwardRef) => {
|
|
|
9605
9815
|
});
|
|
9606
9816
|
});
|
|
9607
9817
|
InlineEditInput.displayName = "InlineEditInput";
|
|
9608
|
-
|
|
9609
9818
|
//#endregion
|
|
9610
9819
|
//#region src/components/inline-edit-multiselect.tsx
|
|
9611
9820
|
/** Context shared between the `InlineEditMultiselect` root and its compound sub-parts. */
|
|
@@ -9925,7 +10134,6 @@ function InlineEditMultiselect(componentProps) {
|
|
|
9925
10134
|
if ("getItemValue" in componentProps && componentProps.getItemValue !== void 0) return /* @__PURE__ */ jsx(InlineEditMultiselectDataDriven, { ...componentProps });
|
|
9926
10135
|
return /* @__PURE__ */ jsx(InlineEditMultiselectCompound, { ...componentProps });
|
|
9927
10136
|
}
|
|
9928
|
-
|
|
9929
10137
|
//#endregion
|
|
9930
10138
|
//#region src/components/inline-edit-select.tsx
|
|
9931
10139
|
/**
|
|
@@ -10001,7 +10209,8 @@ const InlineEditSelectContent = React.forwardRef((componentProps, forwardRef) =>
|
|
|
10001
10209
|
align,
|
|
10002
10210
|
alignOffset,
|
|
10003
10211
|
alignItemWithTrigger,
|
|
10004
|
-
|
|
10212
|
+
"data-slot": "inline-edit-select-positioner",
|
|
10213
|
+
className: "isolate z-popup",
|
|
10005
10214
|
children: /* @__PURE__ */ jsx(Select$1.Popup, {
|
|
10006
10215
|
ref: forwardRef,
|
|
10007
10216
|
"data-slot": "inline-edit-content",
|
|
@@ -10115,7 +10324,6 @@ function InlineEditSelectCompound(props) {
|
|
|
10115
10324
|
})
|
|
10116
10325
|
});
|
|
10117
10326
|
}
|
|
10118
|
-
|
|
10119
10327
|
//#endregion
|
|
10120
10328
|
//#region src/components/inline-edit-textarea.tsx
|
|
10121
10329
|
/**
|
|
@@ -10217,7 +10425,6 @@ const InlineEditTextarea = React.forwardRef((componentProps, forwardRef) => {
|
|
|
10217
10425
|
});
|
|
10218
10426
|
});
|
|
10219
10427
|
InlineEditTextarea.displayName = "InlineEditTextarea";
|
|
10220
|
-
|
|
10221
10428
|
//#endregion
|
|
10222
10429
|
//#region src/components/numeric-input.tsx
|
|
10223
10430
|
/**
|
|
@@ -10242,9 +10449,9 @@ InlineEditTextarea.displayName = "InlineEditTextarea";
|
|
|
10242
10449
|
* ```
|
|
10243
10450
|
*/
|
|
10244
10451
|
const NumericInput = React.forwardRef((componentProps, forwardRef) => {
|
|
10245
|
-
const { className, children, prefix, suffix, hideStepper = false, locale, format
|
|
10452
|
+
const { className, children, prefix, suffix, hideStepper = false, locale, format, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, "aria-describedby": ariaDescribedby, "aria-invalid": ariaInvalid, ...rootProps } = componentProps;
|
|
10246
10453
|
const resolvedLocale = resolveLocale(locale, useDsLocale());
|
|
10247
|
-
const resolvedFormat = resolveFormat(resolvedLocale, format
|
|
10454
|
+
const resolvedFormat = resolveFormat(resolvedLocale, format);
|
|
10248
10455
|
const ariaForRoot = children != null ? {
|
|
10249
10456
|
"aria-label": ariaLabel,
|
|
10250
10457
|
"aria-labelledby": ariaLabelledby,
|
|
@@ -10354,7 +10561,6 @@ const NumericInputDecrement = React.forwardRef((componentProps, forwardRef) => {
|
|
|
10354
10561
|
});
|
|
10355
10562
|
});
|
|
10356
10563
|
NumericInputDecrement.displayName = "NumericInputDecrement";
|
|
10357
|
-
|
|
10358
10564
|
//#endregion
|
|
10359
10565
|
//#region src/components/input-otp.tsx
|
|
10360
10566
|
/**
|
|
@@ -10432,7 +10638,6 @@ const InputOTPSeparator = React.forwardRef((componentProps, forwardRef) => {
|
|
|
10432
10638
|
});
|
|
10433
10639
|
});
|
|
10434
10640
|
InputOTPSeparator.displayName = "InputOTPSeparator";
|
|
10435
|
-
|
|
10436
10641
|
//#endregion
|
|
10437
10642
|
//#region src/components/item.tsx
|
|
10438
10643
|
/**
|
|
@@ -10470,7 +10675,7 @@ const itemVariants = cva("group/item flex w-full flex-wrap items-center rounded-
|
|
|
10470
10675
|
variants: {
|
|
10471
10676
|
variant: {
|
|
10472
10677
|
default: "border-transparent",
|
|
10473
|
-
outline: "border-border",
|
|
10678
|
+
outline: "border-border bg-background",
|
|
10474
10679
|
muted: "border-transparent bg-muted/50"
|
|
10475
10680
|
},
|
|
10476
10681
|
size: {
|
|
@@ -10624,7 +10829,6 @@ const ItemFooter = React.forwardRef((componentProps, forwardRef) => {
|
|
|
10624
10829
|
});
|
|
10625
10830
|
});
|
|
10626
10831
|
ItemFooter.displayName = "ItemFooter";
|
|
10627
|
-
|
|
10628
10832
|
//#endregion
|
|
10629
10833
|
//#region src/components/anchor.tsx
|
|
10630
10834
|
const anchorVariants = cn(linkStyle, "inline-flex cursor-pointer items-center gap-1.5 font-medium outline-none transition-colors hover:text-primary/80 focus-visible:ring-3 focus-visible:ring-ring/50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-[1em]");
|
|
@@ -10660,7 +10864,6 @@ const Anchor = React.forwardRef((componentProps, forwardRef) => {
|
|
|
10660
10864
|
});
|
|
10661
10865
|
});
|
|
10662
10866
|
Anchor.displayName = "Anchor";
|
|
10663
|
-
|
|
10664
10867
|
//#endregion
|
|
10665
10868
|
//#region src/components/list.tsx
|
|
10666
10869
|
/**
|
|
@@ -10715,7 +10918,6 @@ const ListCol = React.forwardRef((componentProps, forwardRef) => {
|
|
|
10715
10918
|
});
|
|
10716
10919
|
});
|
|
10717
10920
|
ListCol.displayName = "ListCol";
|
|
10718
|
-
|
|
10719
10921
|
//#endregion
|
|
10720
10922
|
//#region src/components/pagination.tsx
|
|
10721
10923
|
/**
|
|
@@ -10862,7 +11064,6 @@ const PaginationEllipsis = React.forwardRef((componentProps, forwardRef) => {
|
|
|
10862
11064
|
});
|
|
10863
11065
|
});
|
|
10864
11066
|
PaginationEllipsis.displayName = "PaginationEllipsis";
|
|
10865
|
-
|
|
10866
11067
|
//#endregion
|
|
10867
11068
|
//#region src/components/progress.tsx
|
|
10868
11069
|
/**
|
|
@@ -10945,7 +11146,6 @@ const ProgressValue = React.forwardRef((componentProps, forwardRef) => {
|
|
|
10945
11146
|
});
|
|
10946
11147
|
});
|
|
10947
11148
|
ProgressValue.displayName = "ProgressValue";
|
|
10948
|
-
|
|
10949
11149
|
//#endregion
|
|
10950
11150
|
//#region src/components/radio-group.tsx
|
|
10951
11151
|
/**
|
|
@@ -10989,124 +11189,1529 @@ const RadioGroupItem = React.forwardRef((componentProps, forwardRef) => {
|
|
|
10989
11189
|
});
|
|
10990
11190
|
});
|
|
10991
11191
|
RadioGroupItem.displayName = "RadioGroupItem";
|
|
10992
|
-
|
|
10993
11192
|
//#endregion
|
|
10994
|
-
//#region src/components/
|
|
11193
|
+
//#region src/components/rich-textarea-combobox.tsx
|
|
11194
|
+
const InlineComboboxContext = React.createContext(null);
|
|
11195
|
+
const defaultFilter = ({ group, keywords = [], label, value }, search) => {
|
|
11196
|
+
const uniqueTerms = new Set([
|
|
11197
|
+
value,
|
|
11198
|
+
...keywords,
|
|
11199
|
+
group,
|
|
11200
|
+
label
|
|
11201
|
+
].filter(Boolean));
|
|
11202
|
+
return Array.from(uniqueTerms).some((keyword) => filterWords(keyword, search));
|
|
11203
|
+
};
|
|
10995
11204
|
/**
|
|
10996
|
-
* Root
|
|
10997
|
-
*
|
|
10998
|
-
*
|
|
10999
|
-
*
|
|
11000
|
-
* @example
|
|
11001
|
-
* ```tsx
|
|
11002
|
-
* <Sheet>
|
|
11003
|
-
* <SheetTrigger render={<Button />}>Open</SheetTrigger>
|
|
11004
|
-
* <SheetContent side="right">
|
|
11005
|
-
* <SheetHeader>
|
|
11006
|
-
* <SheetTitle>Title</SheetTitle>
|
|
11007
|
-
* </SheetHeader>
|
|
11008
|
-
* </SheetContent>
|
|
11009
|
-
* </Sheet>
|
|
11010
|
-
* ```
|
|
11205
|
+
* Root of an inline autocomplete menu bound to a Plate combobox-input node.
|
|
11206
|
+
* Detects the trigger character, tracks the search string, and closes the menu
|
|
11207
|
+
* cleanly (restoring the typed text) when cancelled. Renders no visible DOM of
|
|
11208
|
+
* its own — place `InlineComboboxInput` and `InlineComboboxContent` inside.
|
|
11011
11209
|
*/
|
|
11012
|
-
|
|
11013
|
-
|
|
11014
|
-
|
|
11015
|
-
|
|
11210
|
+
const InlineCombobox = ({ children, element, filter = defaultFilter, hideWhenNoValue = false, initialInputValue, loadingState, onNoMatchEnter, setValue: setValueProp, showTrigger = true, trigger, value: valueProp }) => {
|
|
11211
|
+
const editor = useEditorRef();
|
|
11212
|
+
const inputRef = React.useRef(null);
|
|
11213
|
+
const cursorState = useHTMLInputCursorState(inputRef);
|
|
11214
|
+
const [valueState, setValueState] = React.useState("");
|
|
11215
|
+
const hasValueProp = valueProp !== void 0;
|
|
11216
|
+
const value = hasValueProp ? valueProp : valueState;
|
|
11217
|
+
const setValue = React.useCallback((newValue) => {
|
|
11218
|
+
setValueProp?.(newValue);
|
|
11219
|
+
if (!hasValueProp) setValueState(newValue);
|
|
11220
|
+
}, [setValueProp, hasValueProp]);
|
|
11221
|
+
/**
|
|
11222
|
+
* Track the point just before the input element so we know where to
|
|
11223
|
+
* insertText if the combobox closes due to a selection change.
|
|
11224
|
+
*/
|
|
11225
|
+
const insertPointRef = React.useRef(null);
|
|
11226
|
+
React.useEffect(() => {
|
|
11227
|
+
const path = editor.api.findPath(element);
|
|
11228
|
+
if (!path) return;
|
|
11229
|
+
const point = editor.api.before(path);
|
|
11230
|
+
if (!point) return;
|
|
11231
|
+
const pointRef = editor.api.pointRef(point);
|
|
11232
|
+
insertPointRef.current = pointRef;
|
|
11233
|
+
return () => {
|
|
11234
|
+
if (insertPointRef.current === pointRef) insertPointRef.current = null;
|
|
11235
|
+
pointRef.unref();
|
|
11236
|
+
};
|
|
11237
|
+
}, [editor, element]);
|
|
11238
|
+
const { props: inputProps, removeInput } = useComboboxInput({
|
|
11239
|
+
cancelInputOnBlur: true,
|
|
11240
|
+
cursorState,
|
|
11241
|
+
autoFocus: true,
|
|
11242
|
+
ref: inputRef,
|
|
11243
|
+
onCancelInput: (cause) => {
|
|
11244
|
+
if (cause !== "backspace") editor.tf.insertText(trigger + value, { at: insertPointRef.current?.current ?? void 0 });
|
|
11245
|
+
if (cause === "arrowLeft" || cause === "arrowRight") editor.tf.move({
|
|
11246
|
+
distance: 1,
|
|
11247
|
+
reverse: cause === "arrowLeft"
|
|
11248
|
+
});
|
|
11249
|
+
}
|
|
11250
|
+
});
|
|
11251
|
+
const [hasEmpty, setHasEmpty] = React.useState(false);
|
|
11252
|
+
const isFetching = loadingState === "loading" || loadingState === "filtering" || loadingState === "loadingMore";
|
|
11253
|
+
const handleEmptyEnter = React.useCallback(() => {
|
|
11254
|
+
if (!onNoMatchEnter || isFetching) return false;
|
|
11255
|
+
removeInput(true);
|
|
11256
|
+
editor.tf.insertText(trigger + value, { at: insertPointRef.current?.current ?? void 0 });
|
|
11257
|
+
onNoMatchEnter();
|
|
11258
|
+
return true;
|
|
11259
|
+
}, [
|
|
11260
|
+
onNoMatchEnter,
|
|
11261
|
+
isFetching,
|
|
11262
|
+
removeInput,
|
|
11263
|
+
editor,
|
|
11264
|
+
trigger,
|
|
11265
|
+
value
|
|
11266
|
+
]);
|
|
11267
|
+
const contextValue = React.useMemo(() => ({
|
|
11268
|
+
filter,
|
|
11269
|
+
handleEmptyEnter,
|
|
11270
|
+
inputProps,
|
|
11271
|
+
inputRef,
|
|
11272
|
+
removeInput,
|
|
11273
|
+
setHasEmpty,
|
|
11274
|
+
showTrigger,
|
|
11275
|
+
trigger
|
|
11276
|
+
}), [
|
|
11277
|
+
trigger,
|
|
11278
|
+
showTrigger,
|
|
11279
|
+
filter,
|
|
11280
|
+
inputRef,
|
|
11281
|
+
inputProps,
|
|
11282
|
+
removeInput,
|
|
11283
|
+
setHasEmpty,
|
|
11284
|
+
handleEmptyEnter
|
|
11285
|
+
]);
|
|
11286
|
+
const store = useComboboxStore({
|
|
11287
|
+
setInputValue: setValue,
|
|
11288
|
+
defaultValue: initialInputValue
|
|
11289
|
+
});
|
|
11290
|
+
const items = useStoreState(store, "items");
|
|
11291
|
+
/**
|
|
11292
|
+
* If there is no active ID and the list of items changes, select the first
|
|
11293
|
+
* item.
|
|
11294
|
+
*/
|
|
11295
|
+
React.useEffect(() => {
|
|
11296
|
+
if (!store.getState().activeId) store.setActiveId(store.first());
|
|
11297
|
+
}, [items, store]);
|
|
11298
|
+
return /* @__PURE__ */ jsx("span", {
|
|
11299
|
+
contentEditable: false,
|
|
11300
|
+
children: /* @__PURE__ */ jsx(ComboboxProvider, {
|
|
11301
|
+
open: (items.length > 0 || hasEmpty || loadingState === "loading") && (!hideWhenNoValue || value.length > 0),
|
|
11302
|
+
store,
|
|
11303
|
+
children: /* @__PURE__ */ jsx(InlineComboboxContext.Provider, {
|
|
11304
|
+
value: contextValue,
|
|
11305
|
+
children
|
|
11306
|
+
})
|
|
11307
|
+
})
|
|
11016
11308
|
});
|
|
11309
|
+
};
|
|
11310
|
+
/**
|
|
11311
|
+
* Wraps active-item selection at the list ends (ArrowUp on the first item -> last,
|
|
11312
|
+
* ArrowDown on the last -> first). Ariakit's combobox does not wrap by default. Must be
|
|
11313
|
+
* attached to the focused input in capture phase (not the portaled popover, which never
|
|
11314
|
+
* receives the input's key events) so it runs before Ariakit clamps at the boundary.
|
|
11315
|
+
*/
|
|
11316
|
+
function wrapComboboxAtEnds(event, store) {
|
|
11317
|
+
const { items, activeId } = store.getState();
|
|
11318
|
+
if (!items.length) return;
|
|
11319
|
+
const currentIndex = items.findIndex((item) => item.id === activeId);
|
|
11320
|
+
if (event.key === "ArrowUp" && currentIndex <= 0) {
|
|
11321
|
+
event.preventDefault();
|
|
11322
|
+
store.setActiveId(store.last());
|
|
11323
|
+
} else if (event.key === "ArrowDown" && currentIndex >= items.length - 1) {
|
|
11324
|
+
event.preventDefault();
|
|
11325
|
+
store.setActiveId(store.first());
|
|
11326
|
+
}
|
|
11017
11327
|
}
|
|
11018
11328
|
/**
|
|
11019
|
-
* The
|
|
11020
|
-
*
|
|
11329
|
+
* The auto-resizing text input that captures the query typed after the trigger.
|
|
11330
|
+
* Rendered on top of a visually hidden mirror span so it grows with its value.
|
|
11021
11331
|
*/
|
|
11022
|
-
const
|
|
11023
|
-
const {
|
|
11024
|
-
|
|
11025
|
-
|
|
11026
|
-
|
|
11027
|
-
|
|
11028
|
-
|
|
11029
|
-
|
|
11030
|
-
|
|
11332
|
+
const InlineComboboxInput = ({ className, ref: propRef, ...props }) => {
|
|
11333
|
+
const { handleEmptyEnter, inputProps, inputRef: contextRef, showTrigger, trigger } = React.useContext(InlineComboboxContext);
|
|
11334
|
+
const store = useComboboxContext();
|
|
11335
|
+
const value = useStoreState(store, "inputValue");
|
|
11336
|
+
const open = useStoreState(store, "open");
|
|
11337
|
+
const ref = useComposedRef(propRef, contextRef);
|
|
11338
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [showTrigger && trigger, /* @__PURE__ */ jsxs("span", {
|
|
11339
|
+
className: "relative min-h-[1lh]",
|
|
11340
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
11341
|
+
className: "invisible overflow-hidden text-nowrap",
|
|
11342
|
+
"aria-hidden": "true",
|
|
11343
|
+
children: value || ""
|
|
11344
|
+
}), /* @__PURE__ */ jsx(Combobox$2, {
|
|
11345
|
+
ref,
|
|
11346
|
+
className: cn("absolute top-0 left-0 size-full bg-transparent outline-none", className),
|
|
11347
|
+
value,
|
|
11348
|
+
autoSelect: true,
|
|
11349
|
+
...inputProps,
|
|
11350
|
+
...props,
|
|
11351
|
+
onKeyDownCapture: (event) => {
|
|
11352
|
+
wrapComboboxAtEnds(event, store);
|
|
11353
|
+
if (event.key === "Enter" && !open && handleEmptyEnter()) {
|
|
11354
|
+
event.preventDefault();
|
|
11355
|
+
event.stopPropagation();
|
|
11356
|
+
}
|
|
11357
|
+
props.onKeyDownCapture?.(event);
|
|
11358
|
+
}
|
|
11359
|
+
})]
|
|
11360
|
+
})] });
|
|
11361
|
+
};
|
|
11362
|
+
InlineComboboxInput.displayName = "InlineComboboxInput";
|
|
11031
11363
|
/**
|
|
11032
|
-
*
|
|
11033
|
-
*
|
|
11364
|
+
* Portaled, anchored panel that holds the combobox items. End-of-list wrap navigation is
|
|
11365
|
+
* handled on the input (see wrapComboboxAtEnds) since the input, not this portaled popover,
|
|
11366
|
+
* receives the key events.
|
|
11034
11367
|
*/
|
|
11035
|
-
const
|
|
11036
|
-
|
|
11037
|
-
|
|
11038
|
-
|
|
11039
|
-
"data-slot": "sheet-close",
|
|
11368
|
+
const InlineComboboxContent = ({ className, ...props }) => {
|
|
11369
|
+
return /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(ComboboxPopover, {
|
|
11370
|
+
"data-slot": "inline-combobox-content",
|
|
11371
|
+
className: cn("z-50 max-h-[288px] w-[300px] overflow-y-auto rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md", className),
|
|
11040
11372
|
...props
|
|
11041
|
-
});
|
|
11373
|
+
}) });
|
|
11374
|
+
};
|
|
11375
|
+
const comboboxItemVariants = cva("relative mx-1 flex h-[28px] select-none items-center rounded-sm px-2 text-foreground text-sm outline-none [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0", {
|
|
11376
|
+
defaultVariants: { interactive: true },
|
|
11377
|
+
variants: { interactive: {
|
|
11378
|
+
false: "",
|
|
11379
|
+
true: "cursor-pointer transition-colors hover:bg-accent hover:text-accent-foreground data-[active-item=true]:bg-accent data-[active-item=true]:text-accent-foreground"
|
|
11380
|
+
} }
|
|
11042
11381
|
});
|
|
11043
|
-
|
|
11044
|
-
|
|
11045
|
-
|
|
11046
|
-
|
|
11047
|
-
|
|
11382
|
+
/** A selectable row in the combobox. Hidden automatically when it fails the filter. */
|
|
11383
|
+
const InlineComboboxItem = ({ className, focusEditor = true, group, keywords, label, onClick, ...props }) => {
|
|
11384
|
+
const { value } = props;
|
|
11385
|
+
const { filter, removeInput } = React.useContext(InlineComboboxContext);
|
|
11386
|
+
const store = useComboboxContext();
|
|
11387
|
+
const search = useStoreState(store, "inputValue");
|
|
11388
|
+
if (!(!filter || filter({
|
|
11389
|
+
group,
|
|
11390
|
+
keywords,
|
|
11391
|
+
label,
|
|
11392
|
+
value
|
|
11393
|
+
}, search ?? ""))) return null;
|
|
11394
|
+
return /* @__PURE__ */ jsx(ComboboxItem$1, {
|
|
11395
|
+
className: cn(comboboxItemVariants(), className),
|
|
11396
|
+
onClick: (event) => {
|
|
11397
|
+
removeInput(focusEditor);
|
|
11398
|
+
onClick?.(event);
|
|
11399
|
+
},
|
|
11400
|
+
...props
|
|
11048
11401
|
});
|
|
11049
|
-
}
|
|
11050
|
-
|
|
11051
|
-
|
|
11052
|
-
|
|
11053
|
-
|
|
11054
|
-
|
|
11402
|
+
};
|
|
11403
|
+
/** Placeholder row shown when no items match the current search. */
|
|
11404
|
+
const InlineComboboxEmpty = ({ children, className }) => {
|
|
11405
|
+
const { setHasEmpty } = React.useContext(InlineComboboxContext);
|
|
11406
|
+
const store = useComboboxContext();
|
|
11407
|
+
const items = useStoreState(store, "items");
|
|
11408
|
+
React.useEffect(() => {
|
|
11409
|
+
setHasEmpty(true);
|
|
11410
|
+
return () => {
|
|
11411
|
+
setHasEmpty(false);
|
|
11412
|
+
};
|
|
11413
|
+
}, [setHasEmpty]);
|
|
11414
|
+
if (items.length > 0) return null;
|
|
11415
|
+
return /* @__PURE__ */ jsx("div", {
|
|
11416
|
+
className: cn(comboboxItemVariants({ interactive: false }), className),
|
|
11417
|
+
children
|
|
11418
|
+
});
|
|
11419
|
+
};
|
|
11420
|
+
/** Groups related items under an optional label; hidden when it has no visible options. */
|
|
11421
|
+
function InlineComboboxGroup({ className, ...props }) {
|
|
11422
|
+
return /* @__PURE__ */ jsx(ComboboxGroup$1, {
|
|
11055
11423
|
...props,
|
|
11056
|
-
|
|
11424
|
+
className: cn("hidden not-last:border-b py-1.5 [&:has([role=option])]:block", className)
|
|
11057
11425
|
});
|
|
11058
|
-
}
|
|
11059
|
-
SheetOverlay.displayName = "SheetOverlay";
|
|
11426
|
+
}
|
|
11060
11427
|
/**
|
|
11061
|
-
*
|
|
11062
|
-
*
|
|
11063
|
-
* `<div>` popup fixed to the chosen screen edge, optionally with a close button.
|
|
11428
|
+
* Skeleton rows shown on the first async load (`loadingState="loading"`), before
|
|
11429
|
+
* any items exist. Not selectable and not registered as combobox items.
|
|
11064
11430
|
*/
|
|
11065
|
-
const
|
|
11066
|
-
|
|
11067
|
-
|
|
11068
|
-
|
|
11069
|
-
|
|
11070
|
-
|
|
11071
|
-
|
|
11072
|
-
"data-side": side,
|
|
11073
|
-
className: cn("fixed z-50 flex flex-col gap-4 bg-background bg-clip-padding text-sm shadow-lg transition duration-200 ease-in-out data-ending-style:opacity-0 data-starting-style:opacity-0 data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=bottom]:data-ending-style:translate-y-[2.5rem] data-[side=bottom]:data-starting-style:translate-y-[2.5rem] data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=left]:data-ending-style:translate-x-[-2.5rem] data-[side=left]:data-starting-style:translate-x-[-2.5rem] data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=right]:data-ending-style:translate-x-[2.5rem] data-[side=right]:data-starting-style:translate-x-[2.5rem] data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=top]:data-ending-style:translate-y-[-2.5rem] data-[side=top]:data-starting-style:translate-y-[-2.5rem] data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm", className),
|
|
11074
|
-
...props,
|
|
11075
|
-
children: [children, showCloseButton && /* @__PURE__ */ jsxs(Dialog$1.Close, {
|
|
11076
|
-
"data-slot": "sheet-close",
|
|
11077
|
-
render: /* @__PURE__ */ jsx(Button, {
|
|
11078
|
-
variant: "ghost",
|
|
11079
|
-
className: "absolute top-4 right-4",
|
|
11080
|
-
size: "icon"
|
|
11081
|
-
}),
|
|
11082
|
-
children: [/* @__PURE__ */ jsx(XIcon, {}), /* @__PURE__ */ jsx("span", {
|
|
11083
|
-
className: "sr-only",
|
|
11084
|
-
children: "Close"
|
|
11085
|
-
})]
|
|
11086
|
-
})]
|
|
11087
|
-
})]
|
|
11431
|
+
const InlineComboboxSkeleton = ({ count = 5 }) => {
|
|
11432
|
+
return /* @__PURE__ */ jsx("div", {
|
|
11433
|
+
className: "py-1",
|
|
11434
|
+
children: Array.from({ length: count }).map((_, index) => /* @__PURE__ */ jsx("div", {
|
|
11435
|
+
className: cn(comboboxItemVariants({ interactive: false })),
|
|
11436
|
+
children: /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-full" })
|
|
11437
|
+
}, index))
|
|
11088
11438
|
});
|
|
11089
|
-
}
|
|
11090
|
-
|
|
11439
|
+
};
|
|
11440
|
+
InlineComboboxSkeleton.displayName = "InlineComboboxSkeleton";
|
|
11091
11441
|
/**
|
|
11092
|
-
*
|
|
11093
|
-
*
|
|
11442
|
+
* A centered spinner row appended below the list while the next page is loading
|
|
11443
|
+
* (`loadingState="loadingMore"`), so infinite scroll shows progress in place.
|
|
11094
11444
|
*/
|
|
11095
|
-
const
|
|
11096
|
-
const { className, ...props } = componentProps;
|
|
11445
|
+
const InlineComboboxSpinnerRow = () => {
|
|
11097
11446
|
return /* @__PURE__ */ jsx("div", {
|
|
11098
|
-
|
|
11099
|
-
|
|
11100
|
-
className: cn("flex flex-col gap-1.5 p-4", className),
|
|
11101
|
-
...props
|
|
11447
|
+
className: cn(comboboxItemVariants({ interactive: false }), "justify-center"),
|
|
11448
|
+
children: /* @__PURE__ */ jsx(Spinner, { className: "size-4" })
|
|
11102
11449
|
});
|
|
11103
|
-
}
|
|
11104
|
-
|
|
11105
|
-
/**
|
|
11106
|
-
*
|
|
11107
|
-
*
|
|
11108
|
-
|
|
11109
|
-
|
|
11450
|
+
};
|
|
11451
|
+
InlineComboboxSpinnerRow.displayName = "InlineComboboxSpinnerRow";
|
|
11452
|
+
/**
|
|
11453
|
+
* Invisible sentinel placed at the bottom of the async list. When it scrolls into
|
|
11454
|
+
* view (within 200px) it calls `onFetchMore` once, re-arming whenever the result set's
|
|
11455
|
+
* content changes. Reuses the shared DS infinite-scroll hook so the inline menu paginates
|
|
11456
|
+
* like `DataCombobox`.
|
|
11457
|
+
*
|
|
11458
|
+
* `resetKey` is a CONTENT key (e.g. the joined item ids), not the item count or array
|
|
11459
|
+
* reference. Length alone stalls after a same-size new search; the array reference re-arms on
|
|
11460
|
+
* every render if a consumer rebuilds `items` (e.g. `data ?? []`), which would loop `onFetchMore`.
|
|
11461
|
+
* A content key changes only when the results actually change, and it is converted here into a
|
|
11462
|
+
* stable numeric version for the hook.
|
|
11463
|
+
*/
|
|
11464
|
+
const InlineComboboxFetchSentinel = ({ onFetchMore, resetKey }) => {
|
|
11465
|
+
const versionRef = React.useRef(0);
|
|
11466
|
+
const lastKeyRef = React.useRef(null);
|
|
11467
|
+
if (lastKeyRef.current !== resetKey) {
|
|
11468
|
+
lastKeyRef.current = resetKey;
|
|
11469
|
+
versionRef.current += 1;
|
|
11470
|
+
}
|
|
11471
|
+
const sentinelRef = useFetchMoreSentinel(onFetchMore, (node) => node.closest("[data-slot=\"inline-combobox-content\"]"), versionRef.current);
|
|
11472
|
+
return /* @__PURE__ */ jsx("div", {
|
|
11473
|
+
"aria-hidden": true,
|
|
11474
|
+
ref: sentinelRef
|
|
11475
|
+
});
|
|
11476
|
+
};
|
|
11477
|
+
InlineComboboxFetchSentinel.displayName = "InlineComboboxFetchSentinel";
|
|
11478
|
+
//#endregion
|
|
11479
|
+
//#region src/components/toggle.tsx
|
|
11480
|
+
/**
|
|
11481
|
+
* Class-variance-authority variants for {@link Toggle}: `variant` (`default` | `outline`)
|
|
11482
|
+
* and `size` (`default` | `sm` | `lg`).
|
|
11483
|
+
*/
|
|
11484
|
+
const toggleVariants = cva("group/toggle inline-flex items-center justify-center gap-1 rounded-md text-sm text-foreground font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 data-disabled:pointer-events-none data-disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", {
|
|
11485
|
+
variants: {
|
|
11486
|
+
variant: {
|
|
11487
|
+
default: "bg-transparent",
|
|
11488
|
+
outline: "border border-input bg-background"
|
|
11489
|
+
},
|
|
11490
|
+
size: {
|
|
11491
|
+
default: "h-8 min-w-8 px-2 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5",
|
|
11492
|
+
sm: "h-6 min-w-6 px-1.5 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 [&_svg:not([class*='size-'])]:size-3.5",
|
|
11493
|
+
lg: "h-10 min-w-10 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2"
|
|
11494
|
+
},
|
|
11495
|
+
pressedColor: {
|
|
11496
|
+
highContrast: "data-pressed:bg-secondary data-pressed:text-secondary-foreground data-pressed:hover:bg-secondary data-pressed:hover:text-secondary-foreground",
|
|
11497
|
+
lowContrast: "data-pressed:bg-muted data-pressed:text-muted-foreground data-pressed:hover:bg-muted data-pressed:hover:text-muted-foreground"
|
|
11498
|
+
}
|
|
11499
|
+
},
|
|
11500
|
+
defaultVariants: {
|
|
11501
|
+
variant: "default",
|
|
11502
|
+
size: "default",
|
|
11503
|
+
pressedColor: "highContrast"
|
|
11504
|
+
}
|
|
11505
|
+
});
|
|
11506
|
+
/**
|
|
11507
|
+
* A two-state button that can be pressed on or off, wrapping Base UI's `Toggle`.
|
|
11508
|
+
* Renders a `<button aria-pressed>` styled via {@link toggleVariants}.
|
|
11509
|
+
*
|
|
11510
|
+
* @example
|
|
11511
|
+
* ```tsx
|
|
11512
|
+
* <Toggle aria-label="Bold">B</Toggle>
|
|
11513
|
+
* ```
|
|
11514
|
+
*/
|
|
11515
|
+
const Toggle = React.forwardRef((componentProps, forwardRef) => {
|
|
11516
|
+
const { className, variant = "default", size = "default", pressedColor = "highContrast", ...props } = componentProps;
|
|
11517
|
+
return /* @__PURE__ */ jsx(Toggle$1, {
|
|
11518
|
+
ref: forwardRef,
|
|
11519
|
+
"data-slot": "toggle",
|
|
11520
|
+
className: cn(toggleVariants({
|
|
11521
|
+
variant,
|
|
11522
|
+
size,
|
|
11523
|
+
pressedColor,
|
|
11524
|
+
className
|
|
11525
|
+
})),
|
|
11526
|
+
...props
|
|
11527
|
+
});
|
|
11528
|
+
});
|
|
11529
|
+
Toggle.displayName = "Toggle";
|
|
11530
|
+
//#endregion
|
|
11531
|
+
//#region src/components/rich-textarea-toolbar.tsx
|
|
11532
|
+
/**
|
|
11533
|
+
* Presentational toggle shared by every toolbar control. Owns the read-only gating: a
|
|
11534
|
+
* disabled editor renders the toggle `disabled` and drops its handlers so `editor.tf`
|
|
11535
|
+
* cannot mutate content. `onMouseDown` preventDefault (from the Plate hook props) keeps
|
|
11536
|
+
* the editor selection when the button is clicked.
|
|
11537
|
+
*/
|
|
11538
|
+
function ToolbarToggle({ label, pressed, onMouseDown, onClick, children }) {
|
|
11539
|
+
const readOnly = useEditorReadOnly();
|
|
11540
|
+
return /* @__PURE__ */ jsx(Toggle, {
|
|
11541
|
+
size: "sm",
|
|
11542
|
+
"aria-label": label,
|
|
11543
|
+
disabled: readOnly,
|
|
11544
|
+
pressed,
|
|
11545
|
+
onMouseDown: readOnly ? void 0 : onMouseDown,
|
|
11546
|
+
onClick: readOnly ? void 0 : onClick,
|
|
11547
|
+
children
|
|
11548
|
+
});
|
|
11549
|
+
}
|
|
11550
|
+
/** A single mark toggle (bold/italic/…) wired to the editor via Plate's mark hooks. */
|
|
11551
|
+
function MarkToggle({ nodeType, label, children }) {
|
|
11552
|
+
const { props } = useMarkToolbarButton(useMarkToolbarButtonState({ nodeType }));
|
|
11553
|
+
return /* @__PURE__ */ jsx(ToolbarToggle, {
|
|
11554
|
+
label,
|
|
11555
|
+
pressed: props.pressed,
|
|
11556
|
+
onMouseDown: props.onMouseDown,
|
|
11557
|
+
onClick: props.onClick,
|
|
11558
|
+
children
|
|
11559
|
+
});
|
|
11560
|
+
}
|
|
11561
|
+
/** A list toggle (bulleted/numbered) wired to the editor via Plate's list hooks. */
|
|
11562
|
+
function ListToggle({ listStyleType, label, children }) {
|
|
11563
|
+
const { props } = useListToolbarButton(useListToolbarButtonState({ nodeType: listStyleType }));
|
|
11564
|
+
return /* @__PURE__ */ jsx(ToolbarToggle, {
|
|
11565
|
+
label,
|
|
11566
|
+
pressed: props.pressed,
|
|
11567
|
+
onMouseDown: props.onMouseDown,
|
|
11568
|
+
onClick: props.onClick,
|
|
11569
|
+
children
|
|
11570
|
+
});
|
|
11571
|
+
}
|
|
11572
|
+
/**
|
|
11573
|
+
* Link control. Opens the same floating link card shown on click / Cmd+K (insert form
|
|
11574
|
+
* when the caret is not on a link, edit card when it is) rather than a bespoke popover,
|
|
11575
|
+
* so link editing is consistent everywhere. Wired via Plate's link toolbar hooks.
|
|
11576
|
+
*/
|
|
11577
|
+
function LinkToggle({ label }) {
|
|
11578
|
+
const { props } = useLinkToolbarButton(useLinkToolbarButtonState());
|
|
11579
|
+
return /* @__PURE__ */ jsx(ToolbarToggle, {
|
|
11580
|
+
label,
|
|
11581
|
+
pressed: props.pressed,
|
|
11582
|
+
onMouseDown: props.onMouseDown,
|
|
11583
|
+
onClick: props.onClick,
|
|
11584
|
+
children: /* @__PURE__ */ jsx(Link, {})
|
|
11585
|
+
});
|
|
11586
|
+
}
|
|
11587
|
+
/**
|
|
11588
|
+
* The control row shared by {@link RichTextareaToolbar} (the static, addon-mounted
|
|
11589
|
+
* toolbar) and `RichTextareaFloatingToolbar` (the selection toolbar). Internal to the
|
|
11590
|
+
* package - not exported from `src/index.ts` - so the two toolbars cannot drift apart.
|
|
11591
|
+
* Renders no wrapper: the caller owns the `role="toolbar"` element and its surface.
|
|
11592
|
+
*/
|
|
11593
|
+
function RichTextareaToolbarControls() {
|
|
11594
|
+
const t = useDsTranslation("ds");
|
|
11595
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
11596
|
+
/* @__PURE__ */ jsx(MarkToggle, {
|
|
11597
|
+
nodeType: KEYS.bold,
|
|
11598
|
+
label: t("richTextarea.bold"),
|
|
11599
|
+
children: /* @__PURE__ */ jsx(Bold, {})
|
|
11600
|
+
}),
|
|
11601
|
+
/* @__PURE__ */ jsx(MarkToggle, {
|
|
11602
|
+
nodeType: KEYS.italic,
|
|
11603
|
+
label: t("richTextarea.italic"),
|
|
11604
|
+
children: /* @__PURE__ */ jsx(Italic, {})
|
|
11605
|
+
}),
|
|
11606
|
+
/* @__PURE__ */ jsx(MarkToggle, {
|
|
11607
|
+
nodeType: KEYS.underline,
|
|
11608
|
+
label: t("richTextarea.underline"),
|
|
11609
|
+
children: /* @__PURE__ */ jsx(Underline, {})
|
|
11610
|
+
}),
|
|
11611
|
+
/* @__PURE__ */ jsx(MarkToggle, {
|
|
11612
|
+
nodeType: KEYS.strikethrough,
|
|
11613
|
+
label: t("richTextarea.strikethrough"),
|
|
11614
|
+
children: /* @__PURE__ */ jsx(Strikethrough, {})
|
|
11615
|
+
}),
|
|
11616
|
+
/* @__PURE__ */ jsx(MarkToggle, {
|
|
11617
|
+
nodeType: KEYS.code,
|
|
11618
|
+
label: t("richTextarea.inlineCode"),
|
|
11619
|
+
children: /* @__PURE__ */ jsx(Code, {})
|
|
11620
|
+
}),
|
|
11621
|
+
/* @__PURE__ */ jsx(Separator, {
|
|
11622
|
+
orientation: "vertical",
|
|
11623
|
+
className: "mx-1 h-5"
|
|
11624
|
+
}),
|
|
11625
|
+
/* @__PURE__ */ jsx(ListToggle, {
|
|
11626
|
+
listStyleType: ListStyleType.Disc,
|
|
11627
|
+
label: t("richTextarea.bulletedList"),
|
|
11628
|
+
children: /* @__PURE__ */ jsx(List$1, {})
|
|
11629
|
+
}),
|
|
11630
|
+
/* @__PURE__ */ jsx(ListToggle, {
|
|
11631
|
+
listStyleType: ListStyleType.Decimal,
|
|
11632
|
+
label: t("richTextarea.numberedList"),
|
|
11633
|
+
children: /* @__PURE__ */ jsx(ListOrdered, {})
|
|
11634
|
+
}),
|
|
11635
|
+
/* @__PURE__ */ jsx(Separator, {
|
|
11636
|
+
orientation: "vertical",
|
|
11637
|
+
className: "mx-1 h-5"
|
|
11638
|
+
}),
|
|
11639
|
+
/* @__PURE__ */ jsx(LinkToggle, { label: t("richTextarea.link") })
|
|
11640
|
+
] });
|
|
11641
|
+
}
|
|
11642
|
+
RichTextareaToolbarControls.displayName = "RichTextareaToolbarControls";
|
|
11643
|
+
/**
|
|
11644
|
+
* Formatting toolbar for a {@link RichTextareaRoot} with `formatting`. Renders DS
|
|
11645
|
+
* `Toggle`s wired to the editor: bold / italic / underline / strikethrough / inline
|
|
11646
|
+
* code, bulleted / numbered lists, and a link button that opens the floating link
|
|
11647
|
+
* card (the same card shown on click / Cmd+K). Must render inside a
|
|
11648
|
+
* `RichTextareaRoot` (it reads the editor from the Plate provider) — typically in an
|
|
11649
|
+
* `InputGroupAddon align="block-start"`.
|
|
11650
|
+
*
|
|
11651
|
+
* @example
|
|
11652
|
+
* ```tsx
|
|
11653
|
+
* <RichTextareaRoot formatting>
|
|
11654
|
+
* <InputGroup>
|
|
11655
|
+
* <InputGroupAddon align="block-start"><RichTextareaToolbar /></InputGroupAddon>
|
|
11656
|
+
* <RichTextareaContent bare />
|
|
11657
|
+
* </InputGroup>
|
|
11658
|
+
* </RichTextareaRoot>
|
|
11659
|
+
* ```
|
|
11660
|
+
*/
|
|
11661
|
+
const RichTextareaToolbar = React.forwardRef((componentProps, forwardRef) => {
|
|
11662
|
+
const { className, ...props } = componentProps;
|
|
11663
|
+
return /* @__PURE__ */ jsx("div", {
|
|
11664
|
+
ref: forwardRef,
|
|
11665
|
+
"data-slot": "rich-textarea-toolbar",
|
|
11666
|
+
role: "toolbar",
|
|
11667
|
+
className: cn("flex items-center gap-0.5", className),
|
|
11668
|
+
...props,
|
|
11669
|
+
children: /* @__PURE__ */ jsx(RichTextareaToolbarControls, {})
|
|
11670
|
+
});
|
|
11671
|
+
});
|
|
11672
|
+
RichTextareaToolbar.displayName = "RichTextareaToolbar";
|
|
11673
|
+
//#endregion
|
|
11674
|
+
//#region src/components/rich-textarea-floating-toolbar.tsx
|
|
11675
|
+
const floatingToolbarClassName = "z-50 flex max-w-[80vw] items-center gap-0.5 overflow-x-auto rounded-md bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-none print:hidden";
|
|
11676
|
+
const floatingOptions = {
|
|
11677
|
+
strategy: "fixed",
|
|
11678
|
+
placement: "top",
|
|
11679
|
+
middleware: [
|
|
11680
|
+
offset(8),
|
|
11681
|
+
flip({
|
|
11682
|
+
fallbackPlacements: [
|
|
11683
|
+
"top-start",
|
|
11684
|
+
"top-end",
|
|
11685
|
+
"bottom-start",
|
|
11686
|
+
"bottom-end"
|
|
11687
|
+
],
|
|
11688
|
+
padding: 12
|
|
11689
|
+
}),
|
|
11690
|
+
shift({ padding: 8 })
|
|
11691
|
+
]
|
|
11692
|
+
};
|
|
11693
|
+
/**
|
|
11694
|
+
* Floating formatting toolbar for a {@link RichTextarea} with `formatting` and
|
|
11695
|
+
* `floatingToolbar`. Appears over the current text selection and carries the same
|
|
11696
|
+
* controls as {@link RichTextareaToolbar} (marks, lists, link).
|
|
11697
|
+
*
|
|
11698
|
+
* Mounted by an internal plugin via `render.afterEditable`, so it is never composed
|
|
11699
|
+
* manually and takes no props. It renders nothing when the selection is collapsed or
|
|
11700
|
+
* empty, while the mouse is down, when another editor has focus, when the editor is
|
|
11701
|
+
* read-only (`disabled`), or while the floating link card is open.
|
|
11702
|
+
*/
|
|
11703
|
+
function RichTextareaFloatingToolbar() {
|
|
11704
|
+
const editorId = useEditorId();
|
|
11705
|
+
const focusedEditorId = useEventEditorValue("focus");
|
|
11706
|
+
const isLinkToolbarOpen = usePluginOption(LinkPlugin, "isOpen", editorId);
|
|
11707
|
+
const floatingToolbarState = useFloatingToolbarState({
|
|
11708
|
+
editorId,
|
|
11709
|
+
focusedEditorId,
|
|
11710
|
+
hideToolbar: isLinkToolbarOpen,
|
|
11711
|
+
floatingOptions
|
|
11712
|
+
});
|
|
11713
|
+
const { clickOutsideRef, hidden, props, ref: floatingRef } = useFloatingToolbar(floatingToolbarState);
|
|
11714
|
+
if (hidden) return null;
|
|
11715
|
+
return /* @__PURE__ */ jsx("div", {
|
|
11716
|
+
ref: clickOutsideRef,
|
|
11717
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
11718
|
+
ref: floatingRef,
|
|
11719
|
+
"data-slot": "rich-textarea-floating-toolbar",
|
|
11720
|
+
role: "toolbar",
|
|
11721
|
+
className: floatingToolbarClassName,
|
|
11722
|
+
...props,
|
|
11723
|
+
children: /* @__PURE__ */ jsx(RichTextareaToolbarControls, {})
|
|
11724
|
+
})
|
|
11725
|
+
});
|
|
11726
|
+
}
|
|
11727
|
+
RichTextareaFloatingToolbar.displayName = "RichTextareaFloatingToolbar";
|
|
11728
|
+
//#endregion
|
|
11729
|
+
//#region src/components/rich-textarea-link-toolbar.tsx
|
|
11730
|
+
const floatingCardClassName = "z-50 w-auto rounded-md bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-none";
|
|
11731
|
+
const floatingFieldClassName = "placeholder:text-muted-foreground flex h-8 w-full rounded-md border-none bg-transparent px-1.5 py-1 text-sm outline-none";
|
|
11732
|
+
/** Opens the current link in a new tab; re-reads the href on every selection change. */
|
|
11733
|
+
function LinkOpenButton() {
|
|
11734
|
+
const editor = useEditorRef();
|
|
11735
|
+
const t = useDsTranslation("ds");
|
|
11736
|
+
useEditorSelection();
|
|
11737
|
+
const entry = editor.api.node({ match: { type: editor.getType(KEYS.link) } });
|
|
11738
|
+
const attributes = entry ? getLinkAttributes(editor, entry[0]) : {};
|
|
11739
|
+
return /* @__PURE__ */ jsx("a", {
|
|
11740
|
+
...attributes,
|
|
11741
|
+
className: buttonVariants({
|
|
11742
|
+
size: "sm",
|
|
11743
|
+
variant: "ghost"
|
|
11744
|
+
}),
|
|
11745
|
+
onMouseOver: (event) => event.stopPropagation(),
|
|
11746
|
+
"aria-label": t("richTextarea.linkOpen"),
|
|
11747
|
+
target: "_blank",
|
|
11748
|
+
rel: "noreferrer",
|
|
11749
|
+
children: /* @__PURE__ */ jsx(ExternalLink, { className: "size-4" })
|
|
11750
|
+
});
|
|
11751
|
+
}
|
|
11752
|
+
/**
|
|
11753
|
+
* Floating link UI for a {@link RichTextarea} with `formatting`. Mounted by the
|
|
11754
|
+
* `LinkPlugin` via `render.afterEditable`, so it is not composed manually (it takes no
|
|
11755
|
+
* props). It shows:
|
|
11756
|
+
*
|
|
11757
|
+
* - an insert form (URL + text to display) when creating a link (Cmd/Ctrl+K), and
|
|
11758
|
+
* - an edit card (Edit link / open in new tab / remove) when the caret is on a link,
|
|
11759
|
+
* which swaps to the same URL + text form once "Edit link" is pressed.
|
|
11760
|
+
*
|
|
11761
|
+
* Renders nothing when neither form is active.
|
|
11762
|
+
*/
|
|
11763
|
+
function RichTextareaLinkToolbar() {
|
|
11764
|
+
const t = useDsTranslation("ds");
|
|
11765
|
+
const readOnly = useEditorReadOnly();
|
|
11766
|
+
const floatingOptions = {
|
|
11767
|
+
strategy: "fixed",
|
|
11768
|
+
placement: "bottom-start",
|
|
11769
|
+
middleware: [
|
|
11770
|
+
offset(8),
|
|
11771
|
+
flip({
|
|
11772
|
+
fallbackPlacements: [
|
|
11773
|
+
"bottom-end",
|
|
11774
|
+
"top-start",
|
|
11775
|
+
"top-end"
|
|
11776
|
+
],
|
|
11777
|
+
padding: 12
|
|
11778
|
+
}),
|
|
11779
|
+
shift({ padding: 8 })
|
|
11780
|
+
]
|
|
11781
|
+
};
|
|
11782
|
+
const insertState = useFloatingLinkInsertState({ floatingOptions });
|
|
11783
|
+
const { hidden, props: insertProps, ref: insertRef, textInputProps } = useFloatingLinkInsert(insertState);
|
|
11784
|
+
const editState = useFloatingLinkEditState({ floatingOptions });
|
|
11785
|
+
const { editButtonProps, props: editProps, ref: editRef, unlinkButtonProps } = useFloatingLinkEdit(editState);
|
|
11786
|
+
if (hidden || readOnly) return null;
|
|
11787
|
+
const form = /* @__PURE__ */ jsxs("div", {
|
|
11788
|
+
className: "flex w-[330px] flex-col",
|
|
11789
|
+
children: [
|
|
11790
|
+
/* @__PURE__ */ jsxs("div", {
|
|
11791
|
+
className: "flex items-center",
|
|
11792
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
11793
|
+
className: "text-muted-foreground flex items-center pr-1 pl-2",
|
|
11794
|
+
children: /* @__PURE__ */ jsx(Link, { className: "size-4" })
|
|
11795
|
+
}), /* @__PURE__ */ jsx(FloatingLinkUrlInput, {
|
|
11796
|
+
className: floatingFieldClassName,
|
|
11797
|
+
placeholder: t("richTextarea.linkPlaceholder"),
|
|
11798
|
+
"data-plate-focus": true
|
|
11799
|
+
})]
|
|
11800
|
+
}),
|
|
11801
|
+
/* @__PURE__ */ jsx(Separator, { className: "my-1" }),
|
|
11802
|
+
/* @__PURE__ */ jsxs("div", {
|
|
11803
|
+
className: "flex items-center",
|
|
11804
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
11805
|
+
className: "text-muted-foreground flex items-center pr-1 pl-2",
|
|
11806
|
+
children: /* @__PURE__ */ jsx(Text, { className: "size-4" })
|
|
11807
|
+
}), /* @__PURE__ */ jsx("input", {
|
|
11808
|
+
className: floatingFieldClassName,
|
|
11809
|
+
placeholder: t("richTextarea.linkText"),
|
|
11810
|
+
"data-plate-focus": true,
|
|
11811
|
+
...textInputProps
|
|
11812
|
+
})]
|
|
11813
|
+
})
|
|
11814
|
+
]
|
|
11815
|
+
});
|
|
11816
|
+
const editContent = editState.isEditing ? form : /* @__PURE__ */ jsxs("div", {
|
|
11817
|
+
className: "flex items-center",
|
|
11818
|
+
children: [
|
|
11819
|
+
/* @__PURE__ */ jsx("button", {
|
|
11820
|
+
className: buttonVariants({
|
|
11821
|
+
size: "sm",
|
|
11822
|
+
variant: "ghost"
|
|
11823
|
+
}),
|
|
11824
|
+
type: "button",
|
|
11825
|
+
...editButtonProps,
|
|
11826
|
+
children: t("richTextarea.linkEdit")
|
|
11827
|
+
}),
|
|
11828
|
+
/* @__PURE__ */ jsx(Separator, {
|
|
11829
|
+
orientation: "vertical",
|
|
11830
|
+
className: "mx-1 h-6"
|
|
11831
|
+
}),
|
|
11832
|
+
/* @__PURE__ */ jsx(LinkOpenButton, {}),
|
|
11833
|
+
/* @__PURE__ */ jsx(Separator, {
|
|
11834
|
+
orientation: "vertical",
|
|
11835
|
+
className: "mx-1 h-6"
|
|
11836
|
+
}),
|
|
11837
|
+
/* @__PURE__ */ jsx("button", {
|
|
11838
|
+
className: buttonVariants({
|
|
11839
|
+
size: "sm",
|
|
11840
|
+
variant: "ghost"
|
|
11841
|
+
}),
|
|
11842
|
+
type: "button",
|
|
11843
|
+
"aria-label": t("richTextarea.linkRemove"),
|
|
11844
|
+
...unlinkButtonProps,
|
|
11845
|
+
children: /* @__PURE__ */ jsx(Unlink, { className: "size-4" })
|
|
11846
|
+
})
|
|
11847
|
+
]
|
|
11848
|
+
});
|
|
11849
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
|
|
11850
|
+
ref: insertRef,
|
|
11851
|
+
className: floatingCardClassName,
|
|
11852
|
+
...insertProps,
|
|
11853
|
+
children: form
|
|
11854
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
11855
|
+
ref: editRef,
|
|
11856
|
+
className: floatingCardClassName,
|
|
11857
|
+
...editProps,
|
|
11858
|
+
children: editContent
|
|
11859
|
+
})] });
|
|
11860
|
+
}
|
|
11861
|
+
RichTextareaLinkToolbar.displayName = "RichTextareaLinkToolbar";
|
|
11862
|
+
//#endregion
|
|
11863
|
+
//#region src/components/rich-textarea.tsx
|
|
11864
|
+
const RichTextareaContext = React.createContext({
|
|
11865
|
+
mentions: [],
|
|
11866
|
+
tags: [],
|
|
11867
|
+
slashCommands: [],
|
|
11868
|
+
formatting: false,
|
|
11869
|
+
submitOnEnter: true,
|
|
11870
|
+
disabled: false
|
|
11871
|
+
});
|
|
11872
|
+
/**
|
|
11873
|
+
* Splits a `mentions`/`tags` prop (a static array or an async config) into the current
|
|
11874
|
+
* items list plus the async config (if any). `Array.isArray` is the discriminant.
|
|
11875
|
+
*/
|
|
11876
|
+
function normalizeOptionList(prop) {
|
|
11877
|
+
if (prop === void 0) return { items: [] };
|
|
11878
|
+
if (Array.isArray(prop)) return { items: prop };
|
|
11879
|
+
return {
|
|
11880
|
+
items: prop.items,
|
|
11881
|
+
async: prop
|
|
11882
|
+
};
|
|
11883
|
+
}
|
|
11884
|
+
/**
|
|
11885
|
+
* Reconstructs one line of plain text into inline nodes, turning `#tag` / `@mention` tokens
|
|
11886
|
+
* that match a known option (by label, longest-first, on a word boundary) back into pills.
|
|
11887
|
+
* Mirrors what buildPayload emits (`#value` / `@value`), so a persisted `plainText` note
|
|
11888
|
+
* reloads with its pills intact. Text and pills are interleaved so inline void nodes always
|
|
11889
|
+
* have text siblings (valid Slate structure).
|
|
11890
|
+
*/
|
|
11891
|
+
function parseInlineTokens(line, mentions, tags) {
|
|
11892
|
+
const byTrigger = {
|
|
11893
|
+
"#": [...tags].sort((a, b) => b.label.length - a.label.length),
|
|
11894
|
+
"@": [...mentions].sort((a, b) => b.label.length - a.label.length)
|
|
11895
|
+
};
|
|
11896
|
+
const children = [];
|
|
11897
|
+
let buffer = "";
|
|
11898
|
+
let i = 0;
|
|
11899
|
+
while (i < line.length) {
|
|
11900
|
+
const ch = line[i];
|
|
11901
|
+
const opts = (i === 0 || /\s/.test(line[i - 1])) && (ch === "#" || ch === "@") ? byTrigger[ch] : void 0;
|
|
11902
|
+
const rest = opts ? line.slice(i + 1) : "";
|
|
11903
|
+
const option = opts?.find((o) => {
|
|
11904
|
+
if (!o.label || !rest.startsWith(o.label)) return false;
|
|
11905
|
+
const after = rest[o.label.length];
|
|
11906
|
+
return after === void 0 || !/[A-Za-z0-9]/.test(after);
|
|
11907
|
+
});
|
|
11908
|
+
if (option) {
|
|
11909
|
+
children.push({ text: buffer });
|
|
11910
|
+
buffer = "";
|
|
11911
|
+
children.push({
|
|
11912
|
+
type: ch === "#" ? "tag" : "mention",
|
|
11913
|
+
value: option.label,
|
|
11914
|
+
key: option.id,
|
|
11915
|
+
children: [{ text: "" }]
|
|
11916
|
+
});
|
|
11917
|
+
i += 1 + option.label.length;
|
|
11918
|
+
continue;
|
|
11919
|
+
}
|
|
11920
|
+
buffer += ch;
|
|
11921
|
+
i++;
|
|
11922
|
+
}
|
|
11923
|
+
children.push({ text: buffer });
|
|
11924
|
+
return children;
|
|
11925
|
+
}
|
|
11926
|
+
/**
|
|
11927
|
+
* Builds the initial editor `Value` from the `value` prop. A plain-text string is split on
|
|
11928
|
+
* newlines into paragraph blocks, with `#tag`/`@mention` tokens reparsed into pills (see
|
|
11929
|
+
* parseInlineTokens); a JSON AST is used as-is.
|
|
11930
|
+
*/
|
|
11931
|
+
function toInitialValue(value, mentions, tags) {
|
|
11932
|
+
if (value === void 0) return [{
|
|
11933
|
+
type: "p",
|
|
11934
|
+
children: [{ text: "" }]
|
|
11935
|
+
}];
|
|
11936
|
+
if (typeof value === "string") return value.split("\n").map((line) => ({
|
|
11937
|
+
type: "p",
|
|
11938
|
+
children: parseInlineTokens(line, mentions, tags)
|
|
11939
|
+
}));
|
|
11940
|
+
return value;
|
|
11941
|
+
}
|
|
11942
|
+
/**
|
|
11943
|
+
* Plain-text of one node, including mention/tag labels. `editor.api.string` only walks
|
|
11944
|
+
* text children, but mention and tag nodes are void with empty text and keep their label
|
|
11945
|
+
* on `value`, so it would drop the `@mention`/`#tag` text the user sees.
|
|
11946
|
+
*/
|
|
11947
|
+
function nodeToPlainText(node) {
|
|
11948
|
+
if (typeof node.text === "string") return node.text;
|
|
11949
|
+
if (node.type === "mention") return `@${node.value ?? ""}`;
|
|
11950
|
+
if (node.type === "tag") return `#${node.value ?? ""}`;
|
|
11951
|
+
return (node.children ?? []).map(nodeToPlainText).join("");
|
|
11952
|
+
}
|
|
11953
|
+
/** Serializes the editor to the `{ plainText, json, markdown? }` change/submit payload. */
|
|
11954
|
+
function buildPayload(editor, formatting) {
|
|
11955
|
+
const payload = {
|
|
11956
|
+
plainText: editor.children.map(nodeToPlainText).join("\n"),
|
|
11957
|
+
json: editor.children
|
|
11958
|
+
};
|
|
11959
|
+
if (formatting) {
|
|
11960
|
+
const markdown = editor.api.markdown;
|
|
11961
|
+
if (markdown) try {
|
|
11962
|
+
payload.markdown = markdown.serialize();
|
|
11963
|
+
} catch {
|
|
11964
|
+
payload.markdown = void 0;
|
|
11965
|
+
}
|
|
11966
|
+
}
|
|
11967
|
+
return payload;
|
|
11968
|
+
}
|
|
11969
|
+
/**
|
|
11970
|
+
* Runs the Enter-to-submit pipeline: convert a trailing bare URL to a link (formatting only,
|
|
11971
|
+
* see autolinkTrailingUrl), then emit the payload via `onSubmit`. Shared by the editable's
|
|
11972
|
+
* key handler and the no-match commit path so both submit identically.
|
|
11973
|
+
*/
|
|
11974
|
+
function submitEditor(editor, formatting, onSubmit) {
|
|
11975
|
+
if (formatting) autolinkTrailingUrl(editor);
|
|
11976
|
+
onSubmit?.(buildPayload(editor, formatting));
|
|
11977
|
+
}
|
|
11978
|
+
/**
|
|
11979
|
+
* Links a bare URL sitting at the caret right before submit. The autolink input rules
|
|
11980
|
+
* only fire on space / break / paste, so a URL typed immediately before Enter-to-send
|
|
11981
|
+
* (`https://example.com` with no trailing space) would otherwise submit as plain text
|
|
11982
|
+
* with no link node in `json`. Mirrors Plate's break-variant autolink; best-effort.
|
|
11983
|
+
*/
|
|
11984
|
+
function autolinkTrailingUrl(editor) {
|
|
11985
|
+
try {
|
|
11986
|
+
const { selection } = editor;
|
|
11987
|
+
if (!selection || !editor.api.isCollapsed()) return;
|
|
11988
|
+
if (editor.api.some({
|
|
11989
|
+
at: selection,
|
|
11990
|
+
match: { type: editor.getType(KEYS.link) }
|
|
11991
|
+
})) return;
|
|
11992
|
+
const blockRange = editor.api.range("start", selection);
|
|
11993
|
+
if (!blockRange) return;
|
|
11994
|
+
const token = (editor.api.string(blockRange).split(/\s+/).pop() ?? "").trim();
|
|
11995
|
+
if (!token || !validateUrl(editor, token)) return;
|
|
11996
|
+
const startPoint = editor.api.before(selection, {
|
|
11997
|
+
distance: token.length,
|
|
11998
|
+
unit: "character"
|
|
11999
|
+
});
|
|
12000
|
+
if (!startPoint) return;
|
|
12001
|
+
editor.tf.select({
|
|
12002
|
+
anchor: startPoint,
|
|
12003
|
+
focus: selection.anchor
|
|
12004
|
+
});
|
|
12005
|
+
upsertLink(editor, { url: token });
|
|
12006
|
+
editor.tf.collapse({ edge: "end" });
|
|
12007
|
+
} catch {}
|
|
12008
|
+
}
|
|
12009
|
+
/**
|
|
12010
|
+
* Renders an inserted `@mention` as a non-editable, name-only pill. Slack-style: the
|
|
12011
|
+
* avatar is shown in the menu (to disambiguate people while choosing), but the inserted
|
|
12012
|
+
* pill is just the styled name, so mentions read cleanly inline.
|
|
12013
|
+
*/
|
|
12014
|
+
function MentionElement(props) {
|
|
12015
|
+
const { element } = props;
|
|
12016
|
+
const { mentions } = React.useContext(RichTextareaContext);
|
|
12017
|
+
const selected = useSelected();
|
|
12018
|
+
const focused = useFocused();
|
|
12019
|
+
const readOnly = useReadOnly();
|
|
12020
|
+
const stored = element;
|
|
12021
|
+
const option = mentions.find((m) => m.id === stored.key) ?? mentions.find((m) => m.label === element.value);
|
|
12022
|
+
const color = stored.color ?? option?.color;
|
|
12023
|
+
const label = String(element.value ?? "");
|
|
12024
|
+
return /* @__PURE__ */ jsxs(PlateElement, {
|
|
12025
|
+
...props,
|
|
12026
|
+
as: "span",
|
|
12027
|
+
attributes: {
|
|
12028
|
+
...props.attributes,
|
|
12029
|
+
contentEditable: false,
|
|
12030
|
+
draggable: true
|
|
12031
|
+
},
|
|
12032
|
+
children: [/* @__PURE__ */ jsx(Chip, {
|
|
12033
|
+
color,
|
|
12034
|
+
className: cn("align-middle", !readOnly && "cursor-pointer", selected && focused && "ring-2 ring-ring"),
|
|
12035
|
+
children: `@${label}`
|
|
12036
|
+
}), props.children]
|
|
12037
|
+
});
|
|
12038
|
+
}
|
|
12039
|
+
const onSelectMention = getMentionOnSelectItem();
|
|
12040
|
+
/**
|
|
12041
|
+
* Inserts an async-selected mention node directly. The mention plugin's own
|
|
12042
|
+
* `tf.insert.mention` destructures only `{ key, value }`, so it would drop avatar/color;
|
|
12043
|
+
* inserting the node here persists them so the pill stays self-describing after the
|
|
12044
|
+
* loaded page changes or the note is reloaded from `json`. Mirrors `insertTag` and the
|
|
12045
|
+
* plugin's move + trailing-space (matching `insertSpaceAfterMention`).
|
|
12046
|
+
*/
|
|
12047
|
+
function insertMentionNode(editor, option) {
|
|
12048
|
+
editor.tf.insertNodes({
|
|
12049
|
+
children: [{ text: "" }],
|
|
12050
|
+
type: "mention",
|
|
12051
|
+
value: option.label,
|
|
12052
|
+
key: option.id,
|
|
12053
|
+
...option.avatar ? { avatar: option.avatar } : {},
|
|
12054
|
+
...option.color ? { color: option.color } : {}
|
|
12055
|
+
});
|
|
12056
|
+
editor.tf.move({ unit: "offset" });
|
|
12057
|
+
const path = editor.api.block()?.[1];
|
|
12058
|
+
if (editor.selection && path && editor.api.isEnd(editor.selection.anchor, path)) editor.tf.insertText(" ");
|
|
12059
|
+
}
|
|
12060
|
+
/**
|
|
12061
|
+
* The `@` autocomplete input. With a static `mentions` array it filters client-side;
|
|
12062
|
+
* with a {@link RichTextareaAsyncList} it disables the internal filter, surfaces the
|
|
12063
|
+
* query via `onSearch`, renders the `loadingState` (skeletons / spinner row), paginates
|
|
12064
|
+
* via a scroll sentinel, and silently dismisses on no match (no empty row by default).
|
|
12065
|
+
*/
|
|
12066
|
+
function MentionInputElement(props) {
|
|
12067
|
+
const { editor, element } = props;
|
|
12068
|
+
const { mentions, mentionsAsync, submitOnEnter, formatting, onSubmit } = React.useContext(RichTextareaContext);
|
|
12069
|
+
const initialQuery = element.query ?? "";
|
|
12070
|
+
const [search, setSearch] = React.useState(initialQuery);
|
|
12071
|
+
const t = useDsTranslation("ds");
|
|
12072
|
+
const onSearchRef = React.useRef(mentionsAsync?.onSearch);
|
|
12073
|
+
onSearchRef.current = mentionsAsync?.onSearch;
|
|
12074
|
+
React.useEffect(() => {
|
|
12075
|
+
onSearchRef.current?.(search);
|
|
12076
|
+
}, [search]);
|
|
12077
|
+
const loadingState = mentionsAsync?.loadingState;
|
|
12078
|
+
const noMatch = !!mentionsAsync && !(loadingState === "loading" || loadingState === "filtering" || loadingState === "loadingMore") && search.length > 0 && mentions.length === 0;
|
|
12079
|
+
return /* @__PURE__ */ jsxs(PlateElement, {
|
|
12080
|
+
...props,
|
|
12081
|
+
as: "span",
|
|
12082
|
+
children: [
|
|
12083
|
+
/* @__PURE__ */ jsxs(InlineCombobox, {
|
|
12084
|
+
value: search,
|
|
12085
|
+
element,
|
|
12086
|
+
setValue: setSearch,
|
|
12087
|
+
showTrigger: false,
|
|
12088
|
+
trigger: "@",
|
|
12089
|
+
filter: mentionsAsync ? false : void 0,
|
|
12090
|
+
loadingState,
|
|
12091
|
+
initialInputValue: initialQuery || void 0,
|
|
12092
|
+
onNoMatchEnter: () => submitOnEnter ? submitEditor(editor, formatting, onSubmit) : editor.tf.insertBreak(),
|
|
12093
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
12094
|
+
className: "inline-flex items-center align-middle text-sm",
|
|
12095
|
+
children: ["@", /* @__PURE__ */ jsx(InlineComboboxInput, {})]
|
|
12096
|
+
}), /* @__PURE__ */ jsx(InlineComboboxContent, { children: loadingState === "loading" ? /* @__PURE__ */ jsx(InlineComboboxSkeleton, { count: mentionsAsync?.skeletonCount }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
12097
|
+
/* @__PURE__ */ jsx(InlineComboboxGroup, { children: mentions.map((m) => /* @__PURE__ */ jsxs(InlineComboboxItem, {
|
|
12098
|
+
value: m.label,
|
|
12099
|
+
onClick: () => mentionsAsync ? insertMentionNode(editor, m) : onSelectMention(editor, {
|
|
12100
|
+
key: m.id,
|
|
12101
|
+
text: m.label
|
|
12102
|
+
}, search),
|
|
12103
|
+
children: [m.avatar ? /* @__PURE__ */ jsxs(Avatar, {
|
|
12104
|
+
size: "xs",
|
|
12105
|
+
className: "mr-2 size-5",
|
|
12106
|
+
children: [/* @__PURE__ */ jsx(AvatarImage, {
|
|
12107
|
+
src: m.avatar,
|
|
12108
|
+
alt: m.label
|
|
12109
|
+
}), /* @__PURE__ */ jsx(AvatarFallback, { children: m.label.slice(0, 1) })]
|
|
12110
|
+
}) : null, m.label]
|
|
12111
|
+
}, m.id)) }),
|
|
12112
|
+
loadingState === "loadingMore" ? /* @__PURE__ */ jsx(InlineComboboxSpinnerRow, {}) : null,
|
|
12113
|
+
mentionsAsync?.onFetchMore && mentionsAsync.hasMore ? /* @__PURE__ */ jsx(InlineComboboxFetchSentinel, {
|
|
12114
|
+
onFetchMore: mentionsAsync.onFetchMore,
|
|
12115
|
+
resetKey: mentions.map((m) => m.id).join("|")
|
|
12116
|
+
}) : null
|
|
12117
|
+
] }) })]
|
|
12118
|
+
}),
|
|
12119
|
+
mentionsAsync ? /* @__PURE__ */ jsx("span", {
|
|
12120
|
+
role: "status",
|
|
12121
|
+
"aria-live": "polite",
|
|
12122
|
+
contentEditable: false,
|
|
12123
|
+
className: "sr-only",
|
|
12124
|
+
children: noMatch ? t("richTextarea.noResults") : ""
|
|
12125
|
+
}) : null,
|
|
12126
|
+
props.children
|
|
12127
|
+
]
|
|
12128
|
+
});
|
|
12129
|
+
}
|
|
12130
|
+
const BaseTagInputPlugin = createSlatePlugin({
|
|
12131
|
+
key: "tag_input",
|
|
12132
|
+
node: {
|
|
12133
|
+
isElement: true,
|
|
12134
|
+
isInline: true,
|
|
12135
|
+
isVoid: true,
|
|
12136
|
+
type: "tag_input"
|
|
12137
|
+
}
|
|
12138
|
+
});
|
|
12139
|
+
const BaseTagPlugin = createTSlatePlugin({
|
|
12140
|
+
key: "tag",
|
|
12141
|
+
node: {
|
|
12142
|
+
isElement: true,
|
|
12143
|
+
isInline: true,
|
|
12144
|
+
isMarkableVoid: true,
|
|
12145
|
+
isVoid: true,
|
|
12146
|
+
type: "tag"
|
|
12147
|
+
},
|
|
12148
|
+
options: {
|
|
12149
|
+
trigger: "#",
|
|
12150
|
+
triggerPreviousCharPattern: /^\s?$/,
|
|
12151
|
+
createComboboxInput: (trigger) => ({
|
|
12152
|
+
children: [{ text: "" }],
|
|
12153
|
+
trigger,
|
|
12154
|
+
type: "tag_input"
|
|
12155
|
+
})
|
|
12156
|
+
},
|
|
12157
|
+
plugins: [BaseTagInputPlugin]
|
|
12158
|
+
}).overrideEditor(withTriggerCombobox);
|
|
12159
|
+
const TagPluginBase = toPlatePlugin(BaseTagPlugin);
|
|
12160
|
+
const TagInputPluginBase = toPlatePlugin(BaseTagInputPlugin);
|
|
12161
|
+
/** Renders an inserted `#tag` as a non-editable DS {@link Badge} pill. */
|
|
12162
|
+
function TagElement(props) {
|
|
12163
|
+
const { element } = props;
|
|
12164
|
+
const { tags } = React.useContext(RichTextareaContext);
|
|
12165
|
+
const selected = useSelected();
|
|
12166
|
+
const focused = useFocused();
|
|
12167
|
+
const readOnly = useReadOnly();
|
|
12168
|
+
const stored = element;
|
|
12169
|
+
const option = tags.find((t) => t.id === stored.key) ?? tags.find((t) => t.label === element.value);
|
|
12170
|
+
const appearance = stored.color != null || stored.tone != null || stored.legacyColor != null ? stored : option;
|
|
12171
|
+
return /* @__PURE__ */ jsxs(PlateElement, {
|
|
12172
|
+
...props,
|
|
12173
|
+
as: "span",
|
|
12174
|
+
attributes: {
|
|
12175
|
+
...props.attributes,
|
|
12176
|
+
contentEditable: false,
|
|
12177
|
+
draggable: true
|
|
12178
|
+
},
|
|
12179
|
+
children: [/* @__PURE__ */ jsx(Badge, {
|
|
12180
|
+
color: appearance?.color,
|
|
12181
|
+
tone: appearance?.tone,
|
|
12182
|
+
legacyColor: appearance?.legacyColor,
|
|
12183
|
+
className: cn("align-middle", !readOnly && "cursor-pointer", selected && focused && "ring-2 ring-ring"),
|
|
12184
|
+
children: `#${element.value}`
|
|
12185
|
+
}), props.children]
|
|
12186
|
+
});
|
|
12187
|
+
}
|
|
12188
|
+
/**
|
|
12189
|
+
* The `#` autocomplete input. Tags are select-only (no free-text creation): with a static
|
|
12190
|
+
* `tags` array it filters client-side; with a {@link RichTextareaAsyncList} it disables the
|
|
12191
|
+
* internal filter, surfaces the query via `onSearch`, renders the `loadingState`, and paginates
|
|
12192
|
+
* via a scroll sentinel. Like mentions, an unmatched `#query` stays plain text (Enter commits
|
|
12193
|
+
* and submits it).
|
|
12194
|
+
*/
|
|
12195
|
+
function TagInputElement(props) {
|
|
12196
|
+
const { editor, element } = props;
|
|
12197
|
+
const { tags, tagsAsync, submitOnEnter, formatting, onSubmit } = React.useContext(RichTextareaContext);
|
|
12198
|
+
const initialQuery = element.query ?? "";
|
|
12199
|
+
const [search, setSearch] = React.useState(initialQuery);
|
|
12200
|
+
const t = useDsTranslation("ds");
|
|
12201
|
+
const onSearchRef = React.useRef(tagsAsync?.onSearch);
|
|
12202
|
+
onSearchRef.current = tagsAsync?.onSearch;
|
|
12203
|
+
React.useEffect(() => {
|
|
12204
|
+
onSearchRef.current?.(search);
|
|
12205
|
+
}, [search]);
|
|
12206
|
+
const loadingState = tagsAsync?.loadingState;
|
|
12207
|
+
const noMatch = !!tagsAsync && !(loadingState === "loading" || loadingState === "filtering" || loadingState === "loadingMore") && search.length > 0 && tags.length === 0;
|
|
12208
|
+
const insertTag = (tag) => {
|
|
12209
|
+
editor.tf.insertNodes({
|
|
12210
|
+
children: [{ text: "" }],
|
|
12211
|
+
type: "tag",
|
|
12212
|
+
value: tag.label,
|
|
12213
|
+
key: tag.id,
|
|
12214
|
+
...tag.color ? { color: tag.color } : {},
|
|
12215
|
+
...tag.tone ? { tone: tag.tone } : {},
|
|
12216
|
+
...tag.legacyColor ? { legacyColor: tag.legacyColor } : {}
|
|
12217
|
+
});
|
|
12218
|
+
editor.tf.move({ unit: "offset" });
|
|
12219
|
+
const path = editor.api.block()?.[1];
|
|
12220
|
+
if (editor.selection && path && editor.api.isEnd(editor.selection.anchor, path)) editor.tf.insertText(" ");
|
|
12221
|
+
};
|
|
12222
|
+
return /* @__PURE__ */ jsxs(PlateElement, {
|
|
12223
|
+
...props,
|
|
12224
|
+
as: "span",
|
|
12225
|
+
children: [
|
|
12226
|
+
/* @__PURE__ */ jsxs(InlineCombobox, {
|
|
12227
|
+
value: search,
|
|
12228
|
+
element,
|
|
12229
|
+
setValue: setSearch,
|
|
12230
|
+
showTrigger: false,
|
|
12231
|
+
trigger: "#",
|
|
12232
|
+
filter: tagsAsync ? false : void 0,
|
|
12233
|
+
loadingState,
|
|
12234
|
+
initialInputValue: initialQuery || void 0,
|
|
12235
|
+
onNoMatchEnter: () => submitOnEnter ? submitEditor(editor, formatting, onSubmit) : editor.tf.insertBreak(),
|
|
12236
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
12237
|
+
className: "inline-flex items-center align-middle text-sm",
|
|
12238
|
+
children: ["#", /* @__PURE__ */ jsx(InlineComboboxInput, {})]
|
|
12239
|
+
}), /* @__PURE__ */ jsx(InlineComboboxContent, { children: loadingState === "loading" ? /* @__PURE__ */ jsx(InlineComboboxSkeleton, { count: tagsAsync?.skeletonCount }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
12240
|
+
/* @__PURE__ */ jsx(InlineComboboxGroup, { children: tags.map((tag) => /* @__PURE__ */ jsx(InlineComboboxItem, {
|
|
12241
|
+
value: tag.label,
|
|
12242
|
+
onClick: () => insertTag(tag),
|
|
12243
|
+
children: /* @__PURE__ */ jsx(Badge, {
|
|
12244
|
+
color: tag.color,
|
|
12245
|
+
tone: tag.tone,
|
|
12246
|
+
legacyColor: tag.legacyColor,
|
|
12247
|
+
children: tag.label
|
|
12248
|
+
})
|
|
12249
|
+
}, tag.id)) }),
|
|
12250
|
+
loadingState === "loadingMore" ? /* @__PURE__ */ jsx(InlineComboboxSpinnerRow, {}) : null,
|
|
12251
|
+
tagsAsync?.onFetchMore && tagsAsync.hasMore ? /* @__PURE__ */ jsx(InlineComboboxFetchSentinel, {
|
|
12252
|
+
onFetchMore: tagsAsync.onFetchMore,
|
|
12253
|
+
resetKey: tags.map((t) => t.id).join("|")
|
|
12254
|
+
}) : null
|
|
12255
|
+
] }) })]
|
|
12256
|
+
}),
|
|
12257
|
+
tagsAsync ? /* @__PURE__ */ jsx("span", {
|
|
12258
|
+
role: "status",
|
|
12259
|
+
"aria-live": "polite",
|
|
12260
|
+
contentEditable: false,
|
|
12261
|
+
className: "sr-only",
|
|
12262
|
+
children: noMatch ? t("richTextarea.noResults") : ""
|
|
12263
|
+
}) : null,
|
|
12264
|
+
props.children
|
|
12265
|
+
]
|
|
12266
|
+
});
|
|
12267
|
+
}
|
|
12268
|
+
/** The `/` command menu: lists `slashCommands`; selecting runs `onSelect` (no node inserted). */
|
|
12269
|
+
function SlashInputElement(props) {
|
|
12270
|
+
const { editor, element } = props;
|
|
12271
|
+
const { slashCommands } = React.useContext(RichTextareaContext);
|
|
12272
|
+
const t = useDsTranslation("ds");
|
|
12273
|
+
return /* @__PURE__ */ jsxs(PlateElement, {
|
|
12274
|
+
...props,
|
|
12275
|
+
as: "span",
|
|
12276
|
+
children: [/* @__PURE__ */ jsxs(InlineCombobox, {
|
|
12277
|
+
element,
|
|
12278
|
+
trigger: "/",
|
|
12279
|
+
children: [/* @__PURE__ */ jsx(InlineComboboxInput, {}), /* @__PURE__ */ jsxs(InlineComboboxContent, { children: [/* @__PURE__ */ jsx(InlineComboboxEmpty, { children: t("richTextarea.slashNoCommands") }), /* @__PURE__ */ jsx(InlineComboboxGroup, { children: slashCommands.map((command) => /* @__PURE__ */ jsxs(InlineComboboxItem, {
|
|
12280
|
+
value: command.label,
|
|
12281
|
+
className: "h-auto py-1.5",
|
|
12282
|
+
onClick: () => command.onSelect?.(editor),
|
|
12283
|
+
children: [command.icon ? /* @__PURE__ */ jsx(ItemMedia, { children: command.icon }) : null, /* @__PURE__ */ jsxs(ItemContent, { children: [/* @__PURE__ */ jsx(ItemTitle, { children: command.label }), command.description ? /* @__PURE__ */ jsx(ItemDescription, { children: command.description }) : null] })]
|
|
12284
|
+
}, command.id)) })] })]
|
|
12285
|
+
}), props.children]
|
|
12286
|
+
});
|
|
12287
|
+
}
|
|
12288
|
+
/**
|
|
12289
|
+
* Renders a link node as a styled inline `<a>` (LinkPlugin ships no default component).
|
|
12290
|
+
* Uses `linkStyle` (DS color + underline) rather than `anchorVariants`, which is
|
|
12291
|
+
* `inline-flex` for icon composition and would break the whitespace flow of an inline
|
|
12292
|
+
* text link (collapsing the space before it and doubling it after).
|
|
12293
|
+
*/
|
|
12294
|
+
function LinkElement(props) {
|
|
12295
|
+
const { editor, element } = props;
|
|
12296
|
+
return /* @__PURE__ */ jsx(PlateElement, {
|
|
12297
|
+
...props,
|
|
12298
|
+
as: "a",
|
|
12299
|
+
className: cn(linkStyle, "cursor-pointer font-medium transition-colors hover:text-primary/80"),
|
|
12300
|
+
attributes: {
|
|
12301
|
+
...props.attributes,
|
|
12302
|
+
...getLinkAttributes(editor, element),
|
|
12303
|
+
rel: "noreferrer",
|
|
12304
|
+
target: "_blank"
|
|
12305
|
+
},
|
|
12306
|
+
children: props.children
|
|
12307
|
+
});
|
|
12308
|
+
}
|
|
12309
|
+
/**
|
|
12310
|
+
* Plugins registered when `formatting` is on: basic marks (bold/italic/underline/
|
|
12311
|
+
* strikethrough/code), lists (bulleted/numbered), link, and Markdown serialization.
|
|
12312
|
+
*
|
|
12313
|
+
* `MarkdownPlugin` is configured with `remark-gfm` so strikethrough serializes as
|
|
12314
|
+
* `~~...~~`, and underline is a `plainMark` because Markdown has no underline syntax
|
|
12315
|
+
* (without this it serializes to an MDX `<u>` node the default stringifier throws on,
|
|
12316
|
+
* which previously crashed `onValueChange` for any strikethrough/underline mark).
|
|
12317
|
+
*/
|
|
12318
|
+
const SAFE_LINK_SCHEME = /^(https?|mailto|tel):/i;
|
|
12319
|
+
/**
|
|
12320
|
+
* Normalizes a user-entered link (from the floating link form) Slack-style: keep a value
|
|
12321
|
+
* that already has a safe scheme (`http(s)`/`mailto`/`tel`); otherwise strip any scheme it
|
|
12322
|
+
* has - including dangerous ones like `javascript:` - and prepend `http://`. This makes
|
|
12323
|
+
* the form forgiving (`google.com`, `example` and typo'd schemes all become links) while
|
|
12324
|
+
* never emitting an unsafe href. Empty input stays empty.
|
|
12325
|
+
*/
|
|
12326
|
+
function normalizeLinkInput(url) {
|
|
12327
|
+
const trimmed = (url ?? "").trim();
|
|
12328
|
+
if (!trimmed) return "";
|
|
12329
|
+
if (SAFE_LINK_SCHEME.test(trimmed)) return trimmed;
|
|
12330
|
+
return `http://${trimmed.replace(/^[a-z][a-z0-9+.-]*:\/*/i, "")}`;
|
|
12331
|
+
}
|
|
12332
|
+
const formattingPlugins = [
|
|
12333
|
+
BasicMarksPlugin.configurePlugin(BoldPlugin, { inputRules: [BoldRules.markdown()] }).configurePlugin(ItalicPlugin, { inputRules: [ItalicRules.markdown(), ItalicRules.markdown({ variant: "_" })] }).configurePlugin(StrikethroughPlugin, { inputRules: [StrikethroughRules.markdown()] }).configurePlugin(CodePlugin, { inputRules: [CodeRules.markdown()] }),
|
|
12334
|
+
IndentPlugin,
|
|
12335
|
+
ListPlugin,
|
|
12336
|
+
LinkPlugin.configure({
|
|
12337
|
+
options: {
|
|
12338
|
+
forceSubmit: true,
|
|
12339
|
+
transformInput: normalizeLinkInput
|
|
12340
|
+
},
|
|
12341
|
+
inputRules: [
|
|
12342
|
+
LinkRules.markdown(),
|
|
12343
|
+
LinkRules.autolink({ variant: "paste" }),
|
|
12344
|
+
LinkRules.autolink({ variant: "space" }),
|
|
12345
|
+
LinkRules.autolink({ variant: "break" })
|
|
12346
|
+
],
|
|
12347
|
+
render: {
|
|
12348
|
+
node: LinkElement,
|
|
12349
|
+
afterEditable: () => /* @__PURE__ */ jsx(RichTextareaLinkToolbar, {})
|
|
12350
|
+
}
|
|
12351
|
+
}),
|
|
12352
|
+
MarkdownPlugin.configure({ options: {
|
|
12353
|
+
remarkPlugins: [remarkGfm],
|
|
12354
|
+
plainMarks: [KEYS.underline]
|
|
12355
|
+
} })
|
|
12356
|
+
];
|
|
12357
|
+
/**
|
|
12358
|
+
* Mounts the floating selection toolbar. A plugin rather than a composed child so the
|
|
12359
|
+
* all-in-one `RichTextarea` (which exposes no slot inside the Plate provider) gets it
|
|
12360
|
+
* too. `afterEditable` accumulates across plugins, so this coexists with the floating
|
|
12361
|
+
* link card `LinkPlugin` renders at the same position.
|
|
12362
|
+
*/
|
|
12363
|
+
const FloatingToolbarPlugin = createPlatePlugin({
|
|
12364
|
+
key: "richTextareaFloatingToolbar",
|
|
12365
|
+
render: { afterEditable: () => /* @__PURE__ */ jsx(RichTextareaFloatingToolbar, {}) }
|
|
12366
|
+
});
|
|
12367
|
+
/**
|
|
12368
|
+
* Re-opens the `@`/`#` menu when the user types next to a trigger token that was already
|
|
12369
|
+
* committed to plain text - e.g. after blurring or pressing Escape, which turns the
|
|
12370
|
+
* in-progress `@query` back into text. Plate's `withTriggerCombobox` only opens the menu
|
|
12371
|
+
* when the trigger CHARACTER is typed, so without this, typing beside a bare `@ada` never
|
|
12372
|
+
* reopens it. On a matching keystroke we replace the committed `trigger + query` run with a
|
|
12373
|
+
* fresh combobox input node seeded with the query (plus the just-typed char), so the menu
|
|
12374
|
+
* resumes where it left off.
|
|
12375
|
+
*
|
|
12376
|
+
* Limitations (by design): the query must be a single space-free token (mirrors how you
|
|
12377
|
+
* keep typing a mention); a committed token whose query already contains a space is left as
|
|
12378
|
+
* text. The preceding character must be whitespace or a boundary (so `email@x` is untouched).
|
|
12379
|
+
*/
|
|
12380
|
+
function createRetriggerComboboxPlugin(hasMentions, hasTags) {
|
|
12381
|
+
return createSlatePlugin({ key: "retrigger_combobox" }).overrideEditor(({ editor, tf: { insertText } }) => ({ transforms: { insertText(text, options) {
|
|
12382
|
+
const isEnabled = (trigger) => trigger === "@" && hasMentions || trigger === "#" && hasTags;
|
|
12383
|
+
const { selection } = editor;
|
|
12384
|
+
if (options?.at || !selection || !editor.api.isCollapsed() || text.length !== 1 || /[\s@#]/.test(text)) return insertText(text, options);
|
|
12385
|
+
const { anchor } = selection;
|
|
12386
|
+
const textBefore = editor.api.string({
|
|
12387
|
+
anchor: {
|
|
12388
|
+
path: anchor.path,
|
|
12389
|
+
offset: 0
|
|
12390
|
+
},
|
|
12391
|
+
focus: anchor
|
|
12392
|
+
}) ?? "";
|
|
12393
|
+
const match = /([@#])([^\s@#]*)$/.exec(textBefore);
|
|
12394
|
+
if (!match || !isEnabled(match[1])) return insertText(text, options);
|
|
12395
|
+
const leafText = (editor.api.node(anchor.path)?.[0])?.text ?? "";
|
|
12396
|
+
if (/^[^\s@#]/.test(leafText.slice(anchor.offset))) return insertText(text, options);
|
|
12397
|
+
const [token, trigger, query] = match;
|
|
12398
|
+
const tokenStart = editor.api.before(anchor, {
|
|
12399
|
+
distance: token.length,
|
|
12400
|
+
unit: "character"
|
|
12401
|
+
});
|
|
12402
|
+
if (!tokenStart) return insertText(text, options);
|
|
12403
|
+
const beforeRange = editor.api.range("before", tokenStart);
|
|
12404
|
+
const beforeChar = beforeRange ? editor.api.string(beforeRange) ?? "" : "";
|
|
12405
|
+
if (!/^\s?$/.test(beforeChar)) return insertText(text, options);
|
|
12406
|
+
editor.tf.delete({ at: {
|
|
12407
|
+
anchor: tokenStart,
|
|
12408
|
+
focus: anchor
|
|
12409
|
+
} });
|
|
12410
|
+
editor.tf.insertNodes({
|
|
12411
|
+
children: [{ text: "" }],
|
|
12412
|
+
type: trigger === "@" ? KEYS.mentionInput : "tag_input",
|
|
12413
|
+
trigger,
|
|
12414
|
+
query: query + text
|
|
12415
|
+
}, options);
|
|
12416
|
+
} } }));
|
|
12417
|
+
}
|
|
12418
|
+
/**
|
|
12419
|
+
* Owns the editor and the `<Plate>` provider for a composed RichTextarea. Renders no
|
|
12420
|
+
* DOM of its own — wrap your layout as children so a sibling {@link RichTextareaToolbar}
|
|
12421
|
+
* (which must live inside the Plate provider) can control the editor. For the simple,
|
|
12422
|
+
* all-in-one case use {@link RichTextarea} instead.
|
|
12423
|
+
*
|
|
12424
|
+
* @example
|
|
12425
|
+
* ```tsx
|
|
12426
|
+
* <RichTextareaRoot formatting mentions={mentions} onValueChange={handleChange}>
|
|
12427
|
+
* <InputGroup>
|
|
12428
|
+
* <InputGroupAddon align="block-start"><RichTextareaToolbar /></InputGroupAddon>
|
|
12429
|
+
* <RichTextareaContent bare />
|
|
12430
|
+
* </InputGroup>
|
|
12431
|
+
* </RichTextareaRoot>
|
|
12432
|
+
* ```
|
|
12433
|
+
*/
|
|
12434
|
+
function RichTextareaRoot(componentProps) {
|
|
12435
|
+
const { defaultValue, onValueChange, onSubmit, placeholder, disabled = false, submitOnEnter = true, mentions, slashCommands, tags, formatting = false, floatingToolbar = false, children } = componentProps;
|
|
12436
|
+
const [hasMentions] = React.useState(() => mentions !== void 0);
|
|
12437
|
+
const [hasTags] = React.useState(() => tags !== void 0);
|
|
12438
|
+
const [hasSlashCommands] = React.useState(() => slashCommands !== void 0);
|
|
12439
|
+
const [isFormatting] = React.useState(() => formatting);
|
|
12440
|
+
const [hasFloatingToolbar] = React.useState(() => floatingToolbar);
|
|
12441
|
+
const { items: mentionItems, async: mentionsAsync } = normalizeOptionList(mentions);
|
|
12442
|
+
const { items: tagItems, async: tagsAsync } = normalizeOptionList(tags);
|
|
12443
|
+
const plugins = React.useMemo(() => {
|
|
12444
|
+
const list = [];
|
|
12445
|
+
if (hasMentions) list.push(MentionPlugin.configure({ options: { insertSpaceAfterMention: true } }).withComponent(MentionElement), MentionInputPlugin.withComponent(MentionInputElement));
|
|
12446
|
+
if (hasTags) list.push(TagPluginBase.withComponent(TagElement), TagInputPluginBase.withComponent(TagInputElement));
|
|
12447
|
+
if (hasMentions || hasTags) list.push(toPlatePlugin(createRetriggerComboboxPlugin(hasMentions, hasTags)));
|
|
12448
|
+
if (hasSlashCommands) list.push(SlashPlugin, SlashInputPlugin.withComponent(SlashInputElement));
|
|
12449
|
+
if (isFormatting) {
|
|
12450
|
+
list.push(...formattingPlugins);
|
|
12451
|
+
if (hasFloatingToolbar) list.push(FloatingToolbarPlugin);
|
|
12452
|
+
}
|
|
12453
|
+
return list;
|
|
12454
|
+
}, [
|
|
12455
|
+
hasMentions,
|
|
12456
|
+
hasTags,
|
|
12457
|
+
hasSlashCommands,
|
|
12458
|
+
isFormatting,
|
|
12459
|
+
hasFloatingToolbar
|
|
12460
|
+
]);
|
|
12461
|
+
const editor = usePlateEditor({
|
|
12462
|
+
plugins,
|
|
12463
|
+
value: isFormatting && typeof defaultValue === "string" ? (ed) => ed.api.markdown?.deserialize(defaultValue) ?? toInitialValue(defaultValue, mentionItems, tagItems) : toInitialValue(defaultValue, mentionItems, tagItems)
|
|
12464
|
+
}, [plugins]);
|
|
12465
|
+
const contextValue = React.useMemo(() => ({
|
|
12466
|
+
mentions: mentionItems,
|
|
12467
|
+
tags: tagItems,
|
|
12468
|
+
slashCommands: slashCommands ?? [],
|
|
12469
|
+
mentionsAsync,
|
|
12470
|
+
tagsAsync,
|
|
12471
|
+
formatting: isFormatting,
|
|
12472
|
+
submitOnEnter,
|
|
12473
|
+
disabled,
|
|
12474
|
+
placeholder,
|
|
12475
|
+
onSubmit
|
|
12476
|
+
}), [
|
|
12477
|
+
mentionItems,
|
|
12478
|
+
tagItems,
|
|
12479
|
+
slashCommands,
|
|
12480
|
+
mentionsAsync,
|
|
12481
|
+
tagsAsync,
|
|
12482
|
+
isFormatting,
|
|
12483
|
+
submitOnEnter,
|
|
12484
|
+
disabled,
|
|
12485
|
+
placeholder,
|
|
12486
|
+
onSubmit
|
|
12487
|
+
]);
|
|
12488
|
+
return /* @__PURE__ */ jsx(RichTextareaContext.Provider, {
|
|
12489
|
+
value: contextValue,
|
|
12490
|
+
children: /* @__PURE__ */ jsx(Plate, {
|
|
12491
|
+
editor,
|
|
12492
|
+
readOnly: disabled,
|
|
12493
|
+
onValueChange: () => onValueChange?.(buildPayload(editor, isFormatting)),
|
|
12494
|
+
children
|
|
12495
|
+
})
|
|
12496
|
+
});
|
|
12497
|
+
}
|
|
12498
|
+
RichTextareaRoot.displayName = "RichTextareaRoot";
|
|
12499
|
+
/**
|
|
12500
|
+
* The editable surface of a composed RichTextarea. Must render inside a
|
|
12501
|
+
* {@link RichTextareaRoot}. Use `bare` when placing it inside an `InputGroup`.
|
|
12502
|
+
*/
|
|
12503
|
+
const RichTextareaContent = React.forwardRef((componentProps, forwardRef) => {
|
|
12504
|
+
const { bare = false, className, "aria-label": ariaLabel } = componentProps;
|
|
12505
|
+
const { formatting, submitOnEnter, disabled, placeholder, onSubmit } = React.useContext(RichTextareaContext);
|
|
12506
|
+
const editor = useEditorRef();
|
|
12507
|
+
const handleKeyDown = (event) => {
|
|
12508
|
+
if (disabled) return;
|
|
12509
|
+
if (event.key !== "Enter") return;
|
|
12510
|
+
if (event.nativeEvent.isComposing || event.nativeEvent.keyCode === 229) return;
|
|
12511
|
+
if (editor.api.some({
|
|
12512
|
+
at: [],
|
|
12513
|
+
match: (node) => typeof node.type === "string" && node.type.endsWith("_input")
|
|
12514
|
+
})) return;
|
|
12515
|
+
if (formatting && editor.getOption(LinkPlugin, "isOpen", editor.id)) return;
|
|
12516
|
+
if (event.shiftKey) {
|
|
12517
|
+
event.preventDefault();
|
|
12518
|
+
editor.tf.insertBreak();
|
|
12519
|
+
return;
|
|
12520
|
+
}
|
|
12521
|
+
if (!submitOnEnter) return;
|
|
12522
|
+
event.preventDefault();
|
|
12523
|
+
submitEditor(editor, formatting, onSubmit);
|
|
12524
|
+
};
|
|
12525
|
+
return /* @__PURE__ */ jsx("div", {
|
|
12526
|
+
"data-slot": "rich-textarea",
|
|
12527
|
+
"data-testid": "rich-textarea",
|
|
12528
|
+
"data-multiline": bare ? "true" : void 0,
|
|
12529
|
+
className: cn("flex max-h-60 min-h-20 w-full flex-col overflow-y-auto px-3 py-2 text-base transition-[color,box-shadow] md:text-sm", bare ? "flex-1 border-0 bg-transparent shadow-none" : "border-input focus-within:border-ring focus-within:ring-ring/50 dark:bg-input/30 rounded-md border bg-background shadow-xs focus-within:ring-3", disabled && "cursor-not-allowed", disabled && !bare && "opacity-50 bg-input/50 dark:bg-input/80", className),
|
|
12530
|
+
children: /* @__PURE__ */ jsx(PlateContent, {
|
|
12531
|
+
ref: forwardRef,
|
|
12532
|
+
"data-slot": bare ? "input-group-control" : void 0,
|
|
12533
|
+
"aria-label": ariaLabel,
|
|
12534
|
+
className: "placeholder:text-muted-foreground flex-1 outline-none [&_[data-slate-placeholder]]:text-muted-foreground [&_ol]:!pl-6 [&_ul]:!pl-6 [&_ol]:my-1 [&_ul]:my-1 [&_code]:rounded-sm [&_code]:border [&_code]:border-border [&_code]:bg-muted [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-[0.85em]",
|
|
12535
|
+
placeholder,
|
|
12536
|
+
readOnly: disabled,
|
|
12537
|
+
disabled,
|
|
12538
|
+
"aria-disabled": disabled,
|
|
12539
|
+
onKeyDown: handleKeyDown
|
|
12540
|
+
})
|
|
12541
|
+
});
|
|
12542
|
+
});
|
|
12543
|
+
RichTextareaContent.displayName = "RichTextareaContent";
|
|
12544
|
+
/**
|
|
12545
|
+
* Chat/comment-style rich input built on Plate.js, styled to match the DS
|
|
12546
|
+
* `Textarea`. Supports `@mention` autocomplete, `#tag` colored pills, and
|
|
12547
|
+
* `/slash` command menus. Enter submits (configurable); Shift+Enter adds a newline.
|
|
12548
|
+
*
|
|
12549
|
+
* All-in-one wrapper around {@link RichTextareaRoot} + {@link RichTextareaContent};
|
|
12550
|
+
* for a consumer-composed toolbar, use those directly.
|
|
12551
|
+
*
|
|
12552
|
+
* @example
|
|
12553
|
+
* ```tsx
|
|
12554
|
+
* <RichTextarea
|
|
12555
|
+
* placeholder="Leave a comment…"
|
|
12556
|
+
* mentions={[{ id: '1', label: 'Ada Lovelace' }]}
|
|
12557
|
+
* onSubmit={({ plainText }) => console.log(plainText)}
|
|
12558
|
+
* />
|
|
12559
|
+
* ```
|
|
12560
|
+
*/
|
|
12561
|
+
const RichTextarea = React.forwardRef((componentProps, forwardRef) => {
|
|
12562
|
+
const { bare, className, "aria-label": ariaLabel, ...rootProps } = componentProps;
|
|
12563
|
+
return /* @__PURE__ */ jsx(RichTextareaRoot, {
|
|
12564
|
+
...rootProps,
|
|
12565
|
+
children: /* @__PURE__ */ jsx(RichTextareaContent, {
|
|
12566
|
+
ref: forwardRef,
|
|
12567
|
+
bare,
|
|
12568
|
+
className,
|
|
12569
|
+
"aria-label": ariaLabel
|
|
12570
|
+
})
|
|
12571
|
+
});
|
|
12572
|
+
});
|
|
12573
|
+
RichTextarea.displayName = "RichTextarea";
|
|
12574
|
+
/**
|
|
12575
|
+
* `RichTextarea` pre-configured as the borderless control inside an `InputGroup`
|
|
12576
|
+
* (the `bare` variant). Compose `InputGroupAddon`s around it — e.g. an attachments
|
|
12577
|
+
* row (`align="block-start"`) and a toolbar (`align="block-end"`) — to build a
|
|
12578
|
+
* chat/agent composer. Lives here (not in `input-group.tsx`) so Plate.js stays out
|
|
12579
|
+
* of `InputGroup`'s import graph.
|
|
12580
|
+
*
|
|
12581
|
+
* @example
|
|
12582
|
+
* ```tsx
|
|
12583
|
+
* <InputGroup>
|
|
12584
|
+
* <InputGroupAddon align="block-start">…attachments…</InputGroupAddon>
|
|
12585
|
+
* <InputGroupRichTextarea mentions={mentions} placeholder="Ask anything…" />
|
|
12586
|
+
* <InputGroupAddon align="block-end">…toolbar…</InputGroupAddon>
|
|
12587
|
+
* </InputGroup>
|
|
12588
|
+
* ```
|
|
12589
|
+
*/
|
|
12590
|
+
const InputGroupRichTextarea = React.forwardRef((componentProps, forwardRef) => {
|
|
12591
|
+
return /* @__PURE__ */ jsx(RichTextarea, {
|
|
12592
|
+
ref: forwardRef,
|
|
12593
|
+
bare: true,
|
|
12594
|
+
...componentProps
|
|
12595
|
+
});
|
|
12596
|
+
});
|
|
12597
|
+
InputGroupRichTextarea.displayName = "InputGroupRichTextarea";
|
|
12598
|
+
//#endregion
|
|
12599
|
+
//#region src/components/sheet.tsx
|
|
12600
|
+
/**
|
|
12601
|
+
* Root container for a sheet (a Dialog that slides in from a screen edge),
|
|
12602
|
+
* wrapping Base UI's `Dialog.Root`. Manages open/close state and renders no DOM
|
|
12603
|
+
* element — place `SheetTrigger` and `SheetContent` inside it.
|
|
12604
|
+
*
|
|
12605
|
+
* @example
|
|
12606
|
+
* ```tsx
|
|
12607
|
+
* <Sheet>
|
|
12608
|
+
* <SheetTrigger render={<Button />}>Open</SheetTrigger>
|
|
12609
|
+
* <SheetContent side="right">
|
|
12610
|
+
* <SheetHeader>
|
|
12611
|
+
* <SheetTitle>Title</SheetTitle>
|
|
12612
|
+
* </SheetHeader>
|
|
12613
|
+
* </SheetContent>
|
|
12614
|
+
* </Sheet>
|
|
12615
|
+
* ```
|
|
12616
|
+
*/
|
|
12617
|
+
function Sheet(componentProps) {
|
|
12618
|
+
return /* @__PURE__ */ jsx(Dialog$1.Root, {
|
|
12619
|
+
"data-slot": "sheet",
|
|
12620
|
+
...componentProps
|
|
12621
|
+
});
|
|
12622
|
+
}
|
|
12623
|
+
/**
|
|
12624
|
+
* The element that opens the sheet, wrapping `Dialog.Trigger`.
|
|
12625
|
+
* Renders a `<button>` by default; use `render` to swap the element.
|
|
12626
|
+
*/
|
|
12627
|
+
const SheetTrigger = React.forwardRef((componentProps, forwardRef) => {
|
|
12628
|
+
const { ...props } = componentProps;
|
|
12629
|
+
return /* @__PURE__ */ jsx(Dialog$1.Trigger, {
|
|
12630
|
+
ref: forwardRef,
|
|
12631
|
+
"data-slot": "sheet-trigger",
|
|
12632
|
+
...props
|
|
12633
|
+
});
|
|
12634
|
+
});
|
|
12635
|
+
SheetTrigger.displayName = "SheetTrigger";
|
|
12636
|
+
/**
|
|
12637
|
+
* An element that closes the sheet when activated, wrapping `Dialog.Close`.
|
|
12638
|
+
* Renders a `<button>` by default; use `render` to swap the element.
|
|
12639
|
+
*/
|
|
12640
|
+
const SheetClose = React.forwardRef((componentProps, forwardRef) => {
|
|
12641
|
+
const { ...props } = componentProps;
|
|
12642
|
+
return /* @__PURE__ */ jsx(Dialog$1.Close, {
|
|
12643
|
+
ref: forwardRef,
|
|
12644
|
+
"data-slot": "sheet-close",
|
|
12645
|
+
...props
|
|
12646
|
+
});
|
|
12647
|
+
});
|
|
12648
|
+
SheetClose.displayName = "SheetClose";
|
|
12649
|
+
function SheetPortal(componentProps) {
|
|
12650
|
+
return /* @__PURE__ */ jsx(Dialog$1.Portal, {
|
|
12651
|
+
"data-slot": "sheet-portal",
|
|
12652
|
+
...componentProps
|
|
12653
|
+
});
|
|
12654
|
+
}
|
|
12655
|
+
const SheetOverlay = React.forwardRef((componentProps, forwardRef) => {
|
|
12656
|
+
const { className, ...props } = componentProps;
|
|
12657
|
+
return /* @__PURE__ */ jsx(Dialog$1.Backdrop, {
|
|
12658
|
+
"data-slot": "sheet-overlay",
|
|
12659
|
+
className: cn("fixed inset-0 z-50 bg-black/10 transition-opacity duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0 supports-backdrop-filter:backdrop-blur-xs", className),
|
|
12660
|
+
...props,
|
|
12661
|
+
ref: forwardRef
|
|
12662
|
+
});
|
|
12663
|
+
});
|
|
12664
|
+
SheetOverlay.displayName = "SheetOverlay";
|
|
12665
|
+
/**
|
|
12666
|
+
* The sliding panel shown when the sheet is open. Composes
|
|
12667
|
+
* `Dialog.Portal → Backdrop → Dialog.Popup` into a single part and renders a
|
|
12668
|
+
* `<div>` popup fixed to the chosen screen edge, optionally with a close button.
|
|
12669
|
+
*/
|
|
12670
|
+
const SheetContent = React.forwardRef((componentProps, forwardRef) => {
|
|
12671
|
+
const { className, children, side = "right", showCloseButton = true, container, ...props } = componentProps;
|
|
12672
|
+
return /* @__PURE__ */ jsxs(SheetPortal, {
|
|
12673
|
+
container,
|
|
12674
|
+
children: [/* @__PURE__ */ jsx(SheetOverlay, {}), /* @__PURE__ */ jsxs(Dialog$1.Popup, {
|
|
12675
|
+
ref: forwardRef,
|
|
12676
|
+
"data-slot": "sheet-content",
|
|
12677
|
+
"data-side": side,
|
|
12678
|
+
className: cn("fixed z-50 flex flex-col gap-4 bg-background bg-clip-padding text-sm shadow-lg transition duration-200 ease-in-out data-ending-style:opacity-0 data-starting-style:opacity-0 data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=bottom]:data-ending-style:translate-y-[2.5rem] data-[side=bottom]:data-starting-style:translate-y-[2.5rem] data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=left]:data-ending-style:translate-x-[-2.5rem] data-[side=left]:data-starting-style:translate-x-[-2.5rem] data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=right]:data-ending-style:translate-x-[2.5rem] data-[side=right]:data-starting-style:translate-x-[2.5rem] data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=top]:data-ending-style:translate-y-[-2.5rem] data-[side=top]:data-starting-style:translate-y-[-2.5rem] data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm", className),
|
|
12679
|
+
...props,
|
|
12680
|
+
children: [children, showCloseButton && /* @__PURE__ */ jsxs(Dialog$1.Close, {
|
|
12681
|
+
"data-slot": "sheet-close",
|
|
12682
|
+
render: /* @__PURE__ */ jsx(Button, {
|
|
12683
|
+
variant: "ghost",
|
|
12684
|
+
className: "absolute top-4 right-4",
|
|
12685
|
+
size: "icon"
|
|
12686
|
+
}),
|
|
12687
|
+
children: [/* @__PURE__ */ jsx(XIcon, {}), /* @__PURE__ */ jsx("span", {
|
|
12688
|
+
className: "sr-only",
|
|
12689
|
+
children: "Close"
|
|
12690
|
+
})]
|
|
12691
|
+
})]
|
|
12692
|
+
})]
|
|
12693
|
+
});
|
|
12694
|
+
});
|
|
12695
|
+
SheetContent.displayName = "SheetContent";
|
|
12696
|
+
/**
|
|
12697
|
+
* Header region of the sheet, typically holding the title and description.
|
|
12698
|
+
* Renders a `<div>`.
|
|
12699
|
+
*/
|
|
12700
|
+
const SheetHeader = React.forwardRef((componentProps, forwardRef) => {
|
|
12701
|
+
const { className, ...props } = componentProps;
|
|
12702
|
+
return /* @__PURE__ */ jsx("div", {
|
|
12703
|
+
ref: forwardRef,
|
|
12704
|
+
"data-slot": "sheet-header",
|
|
12705
|
+
className: cn("flex flex-col gap-1.5 p-4", className),
|
|
12706
|
+
...props
|
|
12707
|
+
});
|
|
12708
|
+
});
|
|
12709
|
+
SheetHeader.displayName = "SheetHeader";
|
|
12710
|
+
/**
|
|
12711
|
+
* Footer region of the sheet, typically holding actions; pinned to the bottom.
|
|
12712
|
+
* Renders a `<div>`.
|
|
12713
|
+
*/
|
|
12714
|
+
const SheetFooter = React.forwardRef((componentProps, forwardRef) => {
|
|
11110
12715
|
const { className, ...props } = componentProps;
|
|
11111
12716
|
return /* @__PURE__ */ jsx("div", {
|
|
11112
12717
|
ref: forwardRef,
|
|
@@ -11144,7 +12749,6 @@ const SheetDescription = React.forwardRef((componentProps, forwardRef) => {
|
|
|
11144
12749
|
});
|
|
11145
12750
|
});
|
|
11146
12751
|
SheetDescription.displayName = "SheetDescription";
|
|
11147
|
-
|
|
11148
12752
|
//#endregion
|
|
11149
12753
|
//#region src/components/tooltip.tsx
|
|
11150
12754
|
/**
|
|
@@ -11244,7 +12848,8 @@ const TooltipContent = React.forwardRef((componentProps, forwardRef) => {
|
|
|
11244
12848
|
alignOffset,
|
|
11245
12849
|
side,
|
|
11246
12850
|
sideOffset,
|
|
11247
|
-
|
|
12851
|
+
"data-slot": "tooltip-positioner",
|
|
12852
|
+
className: "isolate z-popup",
|
|
11248
12853
|
children: /* @__PURE__ */ jsxs(Tooltip$1.Popup, {
|
|
11249
12854
|
ref: forwardRef,
|
|
11250
12855
|
"data-slot": "tooltip-content",
|
|
@@ -11256,14 +12861,13 @@ const TooltipContent = React.forwardRef((componentProps, forwardRef) => {
|
|
|
11256
12861
|
});
|
|
11257
12862
|
});
|
|
11258
12863
|
TooltipContent.displayName = "TooltipContent";
|
|
11259
|
-
|
|
11260
12864
|
//#endregion
|
|
11261
12865
|
//#region src/hooks/use-mobile.ts
|
|
11262
12866
|
const MOBILE_BREAKPOINT = 768;
|
|
11263
12867
|
function useIsMobile() {
|
|
11264
12868
|
const [isMobile, setIsMobile] = React.useState(void 0);
|
|
11265
12869
|
React.useEffect(() => {
|
|
11266
|
-
const mql = window.matchMedia(`(max-width:
|
|
12870
|
+
const mql = window.matchMedia(`(max-width: 767px)`);
|
|
11267
12871
|
const onChange = () => {
|
|
11268
12872
|
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
11269
12873
|
};
|
|
@@ -11273,11 +12877,10 @@ function useIsMobile() {
|
|
|
11273
12877
|
}, []);
|
|
11274
12878
|
return !!isMobile;
|
|
11275
12879
|
}
|
|
11276
|
-
|
|
11277
12880
|
//#endregion
|
|
11278
12881
|
//#region src/components/sidebar.tsx
|
|
11279
12882
|
const SIDEBAR_COOKIE_NAME = "sidebar_state";
|
|
11280
|
-
const SIDEBAR_COOKIE_MAX_AGE =
|
|
12883
|
+
const SIDEBAR_COOKIE_MAX_AGE = 604800;
|
|
11281
12884
|
const SIDEBAR_WIDTH = "16rem";
|
|
11282
12885
|
const SIDEBAR_WIDTH_MOBILE = "18rem";
|
|
11283
12886
|
const SIDEBAR_WIDTH_ICON = "3rem";
|
|
@@ -11333,7 +12936,7 @@ const SidebarProvider = React.forwardRef((componentProps, forwardRef) => {
|
|
|
11333
12936
|
document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
|
|
11334
12937
|
}, [setOpenProp, open]);
|
|
11335
12938
|
const toggleSidebar = React.useCallback(() => {
|
|
11336
|
-
return isMobile ? setOpenMobile((open
|
|
12939
|
+
return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open);
|
|
11337
12940
|
}, [
|
|
11338
12941
|
isMobile,
|
|
11339
12942
|
setOpen,
|
|
@@ -11840,7 +13443,6 @@ const SidebarMenuSubButton = React.forwardRef((componentProps, forwardRef) => {
|
|
|
11840
13443
|
});
|
|
11841
13444
|
});
|
|
11842
13445
|
SidebarMenuSubButton.displayName = "SidebarMenuSubButton";
|
|
11843
|
-
|
|
11844
13446
|
//#endregion
|
|
11845
13447
|
//#region src/components/slider.tsx
|
|
11846
13448
|
/**
|
|
@@ -11894,7 +13496,6 @@ const Slider = React.forwardRef((componentProps, forwardRef) => {
|
|
|
11894
13496
|
});
|
|
11895
13497
|
});
|
|
11896
13498
|
Slider.displayName = "Slider";
|
|
11897
|
-
|
|
11898
13499
|
//#endregion
|
|
11899
13500
|
//#region src/components/sonner.tsx
|
|
11900
13501
|
/**
|
|
@@ -11940,7 +13541,6 @@ const Toaster = (componentProps) => {
|
|
|
11940
13541
|
...props
|
|
11941
13542
|
});
|
|
11942
13543
|
};
|
|
11943
|
-
|
|
11944
13544
|
//#endregion
|
|
11945
13545
|
//#region src/components/stepper.tsx
|
|
11946
13546
|
const StepperContext = React.createContext(void 0);
|
|
@@ -12021,10 +13621,9 @@ const StepperProgress = React.forwardRef((componentProps, forwardRef) => {
|
|
|
12021
13621
|
...props,
|
|
12022
13622
|
children: ids.map((id) => {
|
|
12023
13623
|
const idx = getIndex(id);
|
|
12024
|
-
const state = idx < currentIndex ? "completed" : idx === currentIndex ? "active" : "inactive";
|
|
12025
13624
|
return /* @__PURE__ */ jsx("span", {
|
|
12026
13625
|
"data-slot": "stepper-progress-segment",
|
|
12027
|
-
"data-state":
|
|
13626
|
+
"data-state": idx < currentIndex ? "completed" : idx === currentIndex ? "active" : "inactive",
|
|
12028
13627
|
className: "bg-muted h-1.5 flex-1 rounded-full transition-colors duration-300 data-[state=active]:bg-primary data-[state=completed]:bg-primary"
|
|
12029
13628
|
}, id);
|
|
12030
13629
|
})
|
|
@@ -12090,7 +13689,6 @@ const StepperContent = React.forwardRef((componentProps, forwardRef) => {
|
|
|
12090
13689
|
});
|
|
12091
13690
|
});
|
|
12092
13691
|
StepperContent.displayName = "StepperContent";
|
|
12093
|
-
|
|
12094
13692
|
//#endregion
|
|
12095
13693
|
//#region src/components/switch.tsx
|
|
12096
13694
|
/**
|
|
@@ -12116,7 +13714,6 @@ const Switch = React.forwardRef((componentProps, forwardRef) => {
|
|
|
12116
13714
|
});
|
|
12117
13715
|
});
|
|
12118
13716
|
Switch.displayName = "Switch";
|
|
12119
|
-
|
|
12120
13717
|
//#endregion
|
|
12121
13718
|
//#region src/components/tabs.tsx
|
|
12122
13719
|
/**
|
|
@@ -12189,60 +13786,6 @@ const TabsContent = React.forwardRef((componentProps, forwardRef) => {
|
|
|
12189
13786
|
});
|
|
12190
13787
|
});
|
|
12191
13788
|
TabsContent.displayName = "TabsContent";
|
|
12192
|
-
|
|
12193
|
-
//#endregion
|
|
12194
|
-
//#region src/components/toggle.tsx
|
|
12195
|
-
/**
|
|
12196
|
-
* Class-variance-authority variants for {@link Toggle}: `variant` (`default` | `outline`)
|
|
12197
|
-
* and `size` (`default` | `sm` | `lg`).
|
|
12198
|
-
*/
|
|
12199
|
-
const toggleVariants = cva("group/toggle inline-flex items-center justify-center gap-1 rounded-md text-sm text-foreground font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 data-disabled:pointer-events-none data-disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", {
|
|
12200
|
-
variants: {
|
|
12201
|
-
variant: {
|
|
12202
|
-
default: "bg-transparent",
|
|
12203
|
-
outline: "border border-input bg-background"
|
|
12204
|
-
},
|
|
12205
|
-
size: {
|
|
12206
|
-
default: "h-8 min-w-8 px-2 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5",
|
|
12207
|
-
sm: "h-6 min-w-6 px-1.5 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 [&_svg:not([class*='size-'])]:size-3.5",
|
|
12208
|
-
lg: "h-10 min-w-10 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2"
|
|
12209
|
-
},
|
|
12210
|
-
pressedColor: {
|
|
12211
|
-
highContrast: "data-pressed:bg-secondary data-pressed:text-secondary-foreground data-pressed:hover:bg-secondary data-pressed:hover:text-secondary-foreground",
|
|
12212
|
-
lowContrast: "data-pressed:bg-muted data-pressed:text-muted-foreground data-pressed:hover:bg-muted data-pressed:hover:text-muted-foreground"
|
|
12213
|
-
}
|
|
12214
|
-
},
|
|
12215
|
-
defaultVariants: {
|
|
12216
|
-
variant: "default",
|
|
12217
|
-
size: "default",
|
|
12218
|
-
pressedColor: "highContrast"
|
|
12219
|
-
}
|
|
12220
|
-
});
|
|
12221
|
-
/**
|
|
12222
|
-
* A two-state button that can be pressed on or off, wrapping Base UI's `Toggle`.
|
|
12223
|
-
* Renders a `<button aria-pressed>` styled via {@link toggleVariants}.
|
|
12224
|
-
*
|
|
12225
|
-
* @example
|
|
12226
|
-
* ```tsx
|
|
12227
|
-
* <Toggle aria-label="Bold">B</Toggle>
|
|
12228
|
-
* ```
|
|
12229
|
-
*/
|
|
12230
|
-
const Toggle = React.forwardRef((componentProps, forwardRef) => {
|
|
12231
|
-
const { className, variant = "default", size = "default", pressedColor = "highContrast", ...props } = componentProps;
|
|
12232
|
-
return /* @__PURE__ */ jsx(Toggle$1, {
|
|
12233
|
-
ref: forwardRef,
|
|
12234
|
-
"data-slot": "toggle",
|
|
12235
|
-
className: cn(toggleVariants({
|
|
12236
|
-
variant,
|
|
12237
|
-
size,
|
|
12238
|
-
pressedColor,
|
|
12239
|
-
className
|
|
12240
|
-
})),
|
|
12241
|
-
...props
|
|
12242
|
-
});
|
|
12243
|
-
});
|
|
12244
|
-
Toggle.displayName = "Toggle";
|
|
12245
|
-
|
|
12246
13789
|
//#endregion
|
|
12247
13790
|
//#region src/components/toggle-group.tsx
|
|
12248
13791
|
const ToggleGroupContext = React.createContext({
|
|
@@ -12313,7 +13856,6 @@ const ToggleGroupItem = React.forwardRef((componentProps, forwardRef) => {
|
|
|
12313
13856
|
});
|
|
12314
13857
|
});
|
|
12315
13858
|
ToggleGroupItem.displayName = "ToggleGroupItem";
|
|
12316
|
-
|
|
12317
13859
|
//#endregion
|
|
12318
13860
|
//#region src/components/ds-i18n-provider.tsx
|
|
12319
13861
|
/**
|
|
@@ -12354,7 +13896,6 @@ function syncDsLanguage(instance) {
|
|
|
12354
13896
|
instance.on("languageChanged", handler);
|
|
12355
13897
|
return () => instance.off("languageChanged", handler);
|
|
12356
13898
|
}
|
|
12357
|
-
|
|
12358
13899
|
//#endregion
|
|
12359
13900
|
//#region src/hooks/use-audio-gauge.ts
|
|
12360
13901
|
/**
|
|
@@ -12428,6 +13969,5 @@ function useAudioGauge(options = {}) {
|
|
|
12428
13969
|
error
|
|
12429
13970
|
};
|
|
12430
13971
|
}
|
|
12431
|
-
|
|
12432
13972
|
//#endregion
|
|
12433
|
-
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, ActionBar, ActionBarButton, ActionBarContext, ActionBarHeight, Alert, AlertAction, AlertAction as BannerAction, AlertDescription, AlertDescription as BannerDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogMedia, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AlertTitle as BannerTitle, Anchor, Attachment, AttachmentAction, AttachmentActions, AttachmentContent, AttachmentDescription, AttachmentGroup, AttachmentMedia, AttachmentTitle, AttachmentTrigger, Audio, AudioPlayerBar, AudioPlayerButton, AudioPlayerCurrentTime, AudioPlayerDuration, AudioPlayerManager, AudioPlayerRow, AudioPlayerSkip, AudioPlayerSpeed, AudioPlayerTime, Avatar, AvatarBadge, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarImage, Badge, BadgeGroup, BadgeGroupCount, Banner, Button, ButtonGroup, ButtonGroupSeparator, ButtonGroupText, COMBOBOX_AUTO_VIRTUALIZE_THRESHOLD, Calendar, CalendarDayButton, CalendarDropdown, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, Checkbox, Chip, ChipRemove, Collapsible, CollapsibleContent, CollapsibleTrigger, Combobox, ComboboxBody, ComboboxChip, ComboboxChips, ComboboxChipsInput, ComboboxCollection, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxLabel, ComboboxList, ComboboxSeparator, ComboboxTrigger, ComboboxValue, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, CounterBadge, CountryFlag, DataCombobox, DataTable, DataTree, DatePicker, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Drawer, DrawerBackdrop, DrawerBar, DrawerClose, DrawerContent, DrawerCreateHandle, DrawerDescription, DrawerFooter, DrawerHeader, DrawerMenu, DrawerMenuCheckboxItem, DrawerMenuGroup, DrawerMenuGroupLabel, DrawerMenuItem, DrawerMenuRadioGroup, DrawerMenuRadioItem, DrawerMenuSeparator, DrawerMenuTrigger, DrawerPanel, DrawerPopup, DrawerPortal, DrawerPrimitive, DrawerSwipeArea, DrawerTitle, DrawerTrigger, DrawerViewport, DropdownMenu, DropdownMenuAddon, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Dropzone, DropzoneActions, DropzoneContent, DropzoneDescription, DropzoneIcon, DropzoneTitle, DropzoneTrigger, DsI18nProvider, EmojiPicker, EmojiPickerCategories, EmojiPickerContent, EmojiPickerTrigger, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, FAB, Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLabelAside, FieldLabelInfo, FieldLabelRow, FieldLegend, FieldSeparator, FieldSet, FieldTitle, Gauge, HoverCard, HoverCardContent, HoverCardTrigger, InlineEditInput, InlineEditMultiselect, InlineEditMultiselectChip, InlineEditMultiselectChips, InlineEditMultiselectContent, InlineEditMultiselectItem, InlineEditMultiselectTrigger, InlineEditMultiselectValue, InlineEditSelect, InlineEditSelectContent, InlineEditSelectItem, InlineEditSelectTrigger, InlineEditSelectValue, InlineEditTextarea, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, Item, ItemActions, ItemContent, ItemDescription, ItemFooter, ItemGroup, ItemHeader, ItemMedia, ItemSeparator, ItemTitle, Label, List, ListCol, ListRow, NotificationQueueProvider, NotificationSlot, NumericInput, NumericInputControl, NumericInputDecrement, NumericInputIncrement, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, Popover, PopoverClose, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger, Progress, ProgressIndicator, ProgressLabel, ProgressTrack, ProgressValue, RadioGroup, RadioGroupItem, SUPPORTED_LANGUAGES, ScrollArea, ScrollAreaPrimitive, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, Slider, Spinner, Stepper, StepperContent, StepperCounter, StepperPanel, StepperProgress, Switch, Table, TableBody, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, ThemeProvider, Toaster, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, Tree, TreeDragLine, TreeItem, TreeItemLabel, alertVariants, anchorVariants, bannerVariants, buttonGroupVariants, buttonVariants, cn, counterBadgeVariants, detectInitialLanguage, fabVariants, isInsideCalendarDropdown, registerI18nNamespace, selectTriggerVariants, spinnerVariants, syncDsLanguage, toast, toggleVariants, useAudioGauge, useAudioPlayer, useAudioPlayerTime, useComboboxAnchor, useDsLocale, useDsTranslation, useNotification, useNotificationQueue, useSidebar, useStepper, useTheme };
|
|
13973
|
+
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, ActionBar, ActionBarButton, ActionBarContext, ActionBarHeight, Alert, AlertAction, AlertAction as BannerAction, AlertDescription, AlertDescription as BannerDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogMedia, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AlertTitle as BannerTitle, Anchor, Attachment, AttachmentAction, AttachmentActions, AttachmentContent, AttachmentDescription, AttachmentGroup, AttachmentMedia, AttachmentTitle, AttachmentTrigger, Audio, AudioPlayerBar, AudioPlayerButton, AudioPlayerCurrentTime, AudioPlayerDuration, AudioPlayerManager, AudioPlayerRow, AudioPlayerSkip, AudioPlayerSpeed, AudioPlayerTime, Avatar, AvatarBadge, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarImage, Badge, BadgeGroup, BadgeGroupCount, Banner, Button, ButtonGroup, ButtonGroupSeparator, ButtonGroupText, COMBOBOX_AUTO_VIRTUALIZE_THRESHOLD, Calendar, CalendarDayButton, CalendarDropdown, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, Checkbox, Chip, ChipRemove, Collapsible, CollapsibleContent, CollapsibleTrigger, Combobox, ComboboxBody, ComboboxChip, ComboboxChips, ComboboxChipsInput, ComboboxCollection, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxLabel, ComboboxList, ComboboxSeparator, ComboboxTrigger, ComboboxValue, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, CounterBadge, CountryFlag, DataCombobox, DataTable, DataTree, DatePicker, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Drawer, DrawerBackdrop, DrawerBar, DrawerClose, DrawerContent, DrawerCreateHandle, DrawerDescription, DrawerFooter, DrawerHeader, DrawerMenu, DrawerMenuCheckboxItem, DrawerMenuGroup, DrawerMenuGroupLabel, DrawerMenuItem, DrawerMenuRadioGroup, DrawerMenuRadioItem, DrawerMenuSeparator, DrawerMenuTrigger, DrawerPanel, DrawerPopup, DrawerPortal, DrawerPrimitive, DrawerSwipeArea, DrawerTitle, DrawerTrigger, DrawerViewport, DropdownMenu, DropdownMenuAddon, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Dropzone, DropzoneActions, DropzoneContent, DropzoneDescription, DropzoneIcon, DropzoneTitle, DropzoneTrigger, DsI18nProvider, EmojiPicker, EmojiPickerCategories, EmojiPickerContent, EmojiPickerTrigger, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, FAB, Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLabelAside, FieldLabelInfo, FieldLabelRow, FieldLegend, FieldSeparator, FieldSet, FieldTitle, Gauge, HoverCard, HoverCardContent, HoverCardTrigger, InlineEditInput, InlineEditMultiselect, InlineEditMultiselectChip, InlineEditMultiselectChips, InlineEditMultiselectContent, InlineEditMultiselectItem, InlineEditMultiselectTrigger, InlineEditMultiselectValue, InlineEditSelect, InlineEditSelectContent, InlineEditSelectItem, InlineEditSelectTrigger, InlineEditSelectValue, InlineEditTextarea, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupRichTextarea, InputGroupText, InputGroupTextarea, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, Item, ItemActions, ItemContent, ItemDescription, ItemFooter, ItemGroup, ItemHeader, ItemMedia, ItemSeparator, ItemTitle, Label, List, ListCol, ListRow, NotificationQueueProvider, NotificationSlot, NumericInput, NumericInputControl, NumericInputDecrement, NumericInputIncrement, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, Popover, PopoverClose, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger, Progress, ProgressIndicator, ProgressLabel, ProgressTrack, ProgressValue, RadioGroup, RadioGroupItem, RichTextarea, RichTextareaContent, RichTextareaRoot, RichTextareaToolbar, SUPPORTED_LANGUAGES, ScrollArea, ScrollAreaPrimitive, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, Slider, Spinner, Stepper, StepperContent, StepperCounter, StepperPanel, StepperProgress, Switch, Table, TableBody, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, ThemeProvider, Toaster, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, Tree, TreeDragLine, TreeItem, TreeItemLabel, alertVariants, anchorVariants, bannerVariants, buttonGroupVariants, buttonVariants, cn, counterBadgeVariants, detectInitialLanguage, fabVariants, isInsideCalendarDropdown, registerI18nNamespace, selectTriggerVariants, spinnerVariants, syncDsLanguage, toast, toggleVariants, useAudioGauge, useAudioPlayer, useAudioPlayerTime, useComboboxAnchor, useDsLocale, useDsTranslation, useNotification, useNotificationQueue, useSidebar, useStepper, useTheme };
|