@jfrader/ui 0.4.0 → 0.5.1
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/README.md +2 -0
- package/dist/accordion-DLul6vIl.js +205 -0
- package/dist/accordion.js +1 -1
- package/dist/{alert-BBqaKI4k.js → alert-DS_einpy.js} +1 -1
- package/dist/alert.js +1 -1
- package/dist/announcement-bar-Dlbq5-9D.js +382 -0
- package/dist/announcement-bar.js +2 -0
- package/dist/avatar-CaGJHy1N.js +145 -0
- package/dist/avatar-group-M1opAQEG.js +138 -0
- package/dist/avatar-group.js +2 -0
- package/dist/avatar.js +1 -1
- package/dist/badge-CjM5Agqk.js +119 -0
- package/dist/badge.js +1 -1
- package/dist/bottom-sheet-DjZOPq4k.js +674 -0
- package/dist/bottom-sheet.js +2 -0
- package/dist/{breadcrumbs-DVAOxfvL.js → breadcrumbs-BDK_LiwH.js} +11 -4
- package/dist/breadcrumbs.js +1 -1
- package/dist/{button-P2e7_44z.js → button-NLY0h6EJ.js} +8 -8
- package/dist/button.js +1 -1
- package/dist/calendar-BzJdv_SZ.js +449 -0
- package/dist/calendar.js +1 -1
- package/dist/card-Ca4KQKYQ.js +154 -0
- package/dist/card.js +1 -1
- package/dist/carousel-B7OrvD6J.js +474 -0
- package/dist/carousel.js +2 -0
- package/dist/{checkbox-COYG6L7d.js → checkbox-DKSzExj2.js} +17 -16
- package/dist/checkbox.js +1 -1
- package/dist/chip-group-DjQ0_6Y9.js +290 -0
- package/dist/chip-group.js +2 -0
- package/dist/code-block/shiki.js +147 -0
- package/dist/code-block-B5we2lZa.js +293 -0
- package/dist/code-block.js +2 -0
- package/dist/collection-registry-k6JcD3Jr.js +44 -0
- package/dist/combobox-DFFqOBCi.js +339 -0
- package/dist/combobox.js +1 -1
- package/dist/command-palette-BmQu2w4H.js +391 -0
- package/dist/command-palette.js +1 -1
- package/dist/comment-thread-ASaXDcGo.js +1410 -0
- package/dist/comment-thread.js +2 -0
- package/dist/context-menu-__1c2Dk9.js +370 -0
- package/dist/context-menu.js +2 -0
- package/dist/copy-button-DCSLcYS-.js +252 -0
- package/dist/copy-button.js +2 -0
- package/dist/countdown-Dp_TD1VP.js +293 -0
- package/dist/countdown.js +2 -0
- package/dist/date-picker-BiPN7yeK.js +255 -0
- package/dist/date-picker.js +1 -1
- package/dist/date-range-picker-DQpUeKqV.js +570 -0
- package/dist/date-range-picker.js +2 -0
- package/dist/{dialog-xaydbXl2.js → dialog-BX1zYMs-.js} +21 -20
- package/dist/dialog.js +1 -1
- package/dist/{divider-DYoJf0I_.js → divider-Cp7aNbhM.js} +21 -20
- package/dist/divider.js +1 -1
- package/dist/drawer-DsASTiP-.js +553 -0
- package/dist/drawer.js +2 -0
- package/dist/elastic-slider-BG6K019r.js +395 -0
- package/dist/elastic-slider.js +2 -0
- package/dist/empty-state-CDgrjPPf.js +142 -0
- package/dist/empty-state.js +2 -0
- package/dist/expandable-card-rUATve0o.js +347 -0
- package/dist/expandable-card.js +2 -0
- package/dist/expanding-search-BxOwtdwt.js +238 -0
- package/dist/expanding-search.js +2 -0
- package/dist/field-anatomy-COVdNpf5.js +84 -0
- package/dist/file-dropzone-BuXm3Tea.js +457 -0
- package/dist/file-dropzone.js +2 -0
- package/dist/filter-toolbar-Cy5Hqur-.js +314 -0
- package/dist/filter-toolbar.js +2 -0
- package/dist/hold-to-confirm-DjB2EVjM.js +294 -0
- package/dist/hold-to-confirm.js +2 -0
- package/dist/hover-card-CoMJKg1g.js +347 -0
- package/dist/hover-card.js +2 -0
- package/dist/image-compare-BxY8Ykzt.js +415 -0
- package/dist/image-compare.js +2 -0
- package/dist/index.js +84 -38
- package/dist/inline-edit-C0eeml65.js +535 -0
- package/dist/inline-edit.js +2 -0
- package/dist/input-control-DmMuAuPS.js +34 -0
- package/dist/json-viewer-DgWqyU75.js +802 -0
- package/dist/json-viewer.js +2 -0
- package/dist/listbox-style-WX-RASp1.js +59 -0
- package/dist/{media-D_eA_I-e.js → media-8yrN85VT.js} +2 -2
- package/dist/mention-input-sq61si9L.js +600 -0
- package/dist/mention-input.js +2 -0
- package/dist/menu-DDKgmK2F.js +295 -0
- package/dist/menu.js +1 -1
- package/dist/metric-card--lVTz5Wn.js +118 -0
- package/dist/metric-card.js +2 -0
- package/dist/multi-select-DG1BCFX7.js +598 -0
- package/dist/multi-select.js +2 -0
- package/dist/{navigation-DhnKriOp.js → navigation-CC26JDr-.js} +24 -18
- package/dist/navigation.js +1 -1
- package/dist/overlay-layer-qEbpEtb8.js +78 -0
- package/dist/overlay-portal-C4JZFq2M.js +15 -0
- package/dist/{pagination-DYdwsxwe.js → pagination-BfkeWbmP.js} +24 -23
- package/dist/pagination.js +1 -1
- package/dist/password-field-03pWRkuY.js +250 -0
- package/dist/password-field.js +2 -0
- package/dist/pill-BaS-uIbn.js +58 -0
- package/dist/pill.js +1 -1
- package/dist/popover-CErIw2q3.js +125 -0
- package/dist/popover.js +1 -1
- package/dist/{progress-BpJswTG4.js → progress-DAQkfhPd.js} +5 -5
- package/dist/progress.js +1 -1
- package/dist/radio-cards-Cu9cBssN.js +456 -0
- package/dist/radio-cards.js +2 -0
- package/dist/{radio-group-Ce0_IWQr.js → radio-group-TIK0-iPX.js} +22 -19
- package/dist/radio-group.js +1 -1
- package/dist/resizable-panels-DUpQEpwG.js +520 -0
- package/dist/resizable-panels.js +2 -0
- package/dist/scroll-area-CcZyiSOQ.js +371 -0
- package/dist/scroll-area.js +2 -0
- package/dist/search-field-DMvho0KQ.js +274 -0
- package/dist/search-field.js +2 -0
- package/dist/segmented-control-8ZUGnsZm.js +327 -0
- package/dist/segmented-control.js +2 -0
- package/dist/select-D5rhJ8gi.js +293 -0
- package/dist/select.js +1 -1
- package/dist/signature-pad-_bTeguN9.js +645 -0
- package/dist/signature-pad.js +2 -0
- package/dist/{skeleton-OoFlOEXO.js → skeleton-XQQDkCHd.js} +1 -1
- package/dist/skeleton.js +1 -1
- package/dist/slider-DVG6-Awh.js +308 -0
- package/dist/slider.js +2 -0
- package/dist/sortable-data-table-CYKT_Ng7.js +365 -0
- package/dist/sortable-data-table.js +2 -0
- package/dist/{spinner-C2YDoiMn.js → spinner-DtxvDPdM.js} +1 -1
- package/dist/spinner.js +1 -1
- package/dist/split-button-BCw4zZom.js +262 -0
- package/dist/split-button.js +2 -0
- package/dist/stepper-CruHbXxX.js +480 -0
- package/dist/stepper.js +2 -0
- package/dist/swipe-actions-CBuJREU1.js +420 -0
- package/dist/swipe-actions.js +2 -0
- package/dist/switch-C1WrKrf-.js +145 -0
- package/dist/switch.js +1 -1
- package/dist/tabs-XluwRjgg.js +210 -0
- package/dist/tabs.js +1 -1
- package/dist/tag-input-DSRCyrX2.js +418 -0
- package/dist/tag-input.js +2 -0
- package/dist/{text-field-D60ok14S.js → text-field-hU72iSVS.js} +20 -17
- package/dist/text-field.js +1 -1
- package/dist/{textarea-DyfjtP0A.js → textarea-3k4Y0QQ3.js} +23 -20
- package/dist/textarea.js +1 -1
- package/dist/theme-root.js +1 -1
- package/dist/theme-switch-C505TtU8.js +166 -0
- package/dist/theme-switch.js +2 -0
- package/dist/time-picker-CPlhW0tr.js +311 -0
- package/dist/time-picker.js +2 -0
- package/dist/timeline-B0uAAVfT.js +624 -0
- package/dist/timeline.js +2 -0
- package/dist/toast-B7wo3sX1.js +371 -0
- package/dist/toast-stack-B40VpS4M.js +197 -0
- package/dist/toast-stack.js +2 -0
- package/dist/toast.js +1 -1
- package/dist/{toggle-group-CI0e7hFm.js → toggle-group-B2fpFZwV.js} +5 -5
- package/dist/toggle-group.js +1 -1
- package/dist/tooltip-BvgVTCTN.js +120 -0
- package/dist/tooltip.js +1 -1
- package/dist/tree-view-j8qLqkb_.js +364 -0
- package/dist/tree-view.js +2 -0
- package/dist/types/components/announcement-bar/announcement-bar.d.ts +75 -0
- package/dist/types/components/announcement-bar/index.d.ts +2 -0
- package/dist/types/components/avatar-group/avatar-group.d.ts +43 -0
- package/dist/types/components/avatar-group/index.d.ts +2 -0
- package/dist/types/components/bottom-sheet/bottom-sheet.d.ts +60 -0
- package/dist/types/components/bottom-sheet/index.d.ts +2 -0
- package/dist/types/components/calendar/calendar.d.ts +25 -1
- package/dist/types/components/calendar/index.d.ts +1 -1
- package/dist/types/components/carousel/carousel.d.ts +73 -0
- package/dist/types/components/carousel/index.d.ts +2 -0
- package/dist/types/components/checkbox/checkbox.d.ts +1 -1
- package/dist/types/components/chip-group/chip-group.d.ts +54 -0
- package/dist/types/components/chip-group/index.d.ts +1 -0
- package/dist/types/components/code-block/code-block.d.ts +58 -0
- package/dist/types/components/code-block/index.d.ts +1 -0
- package/dist/types/components/code-block/shiki.d.ts +3 -0
- package/dist/types/components/combobox/combobox.d.ts +1 -1
- package/dist/types/components/command-palette/command-palette.d.ts +2 -2
- package/dist/types/components/comment-thread/comment-thread.d.ts +118 -0
- package/dist/types/components/comment-thread/index.d.ts +1 -0
- package/dist/types/components/comment-thread/thread-core.d.ts +96 -0
- package/dist/types/components/comment-thread/thread-parts.d.ts +114 -0
- package/dist/types/components/context-menu/context-menu.d.ts +55 -0
- package/dist/types/components/context-menu/index.d.ts +2 -0
- package/dist/types/components/copy-button/copy-button.d.ts +49 -0
- package/dist/types/components/copy-button/index.d.ts +2 -0
- package/dist/types/components/countdown/countdown.d.ts +37 -0
- package/dist/types/components/countdown/index.d.ts +1 -0
- package/dist/types/components/date-picker/date-picker.d.ts +1 -1
- package/dist/types/components/date-range-picker/date-range-picker.d.ts +103 -0
- package/dist/types/components/date-range-picker/index.d.ts +2 -0
- package/dist/types/components/drawer/drawer.d.ts +59 -0
- package/dist/types/components/drawer/index.d.ts +2 -0
- package/dist/types/components/elastic-slider/elastic-slider.d.ts +53 -0
- package/dist/types/components/elastic-slider/index.d.ts +1 -0
- package/dist/types/components/empty-state/empty-state.d.ts +36 -0
- package/dist/types/components/empty-state/index.d.ts +2 -0
- package/dist/types/components/expandable-card/expandable-card.d.ts +28 -0
- package/dist/types/components/expandable-card/index.d.ts +2 -0
- package/dist/types/components/expanding-search/expanding-search.d.ts +22 -0
- package/dist/types/components/expanding-search/index.d.ts +1 -0
- package/dist/types/components/field/field-anatomy.d.ts +4 -2
- package/dist/types/components/file-dropzone/file-dropzone.d.ts +93 -0
- package/dist/types/components/file-dropzone/index.d.ts +2 -0
- package/dist/types/components/filter-toolbar/filter-toolbar.d.ts +70 -0
- package/dist/types/components/filter-toolbar/index.d.ts +1 -0
- package/dist/types/components/hold-to-confirm/hold-to-confirm.d.ts +32 -0
- package/dist/types/components/hold-to-confirm/index.d.ts +2 -0
- package/dist/types/components/hover-card/hover-card.d.ts +97 -0
- package/dist/types/components/hover-card/index.d.ts +2 -0
- package/dist/types/components/image-compare/image-compare.d.ts +54 -0
- package/dist/types/components/image-compare/index.d.ts +1 -0
- package/dist/types/components/inline-edit/index.d.ts +2 -0
- package/dist/types/components/inline-edit/inline-edit.d.ts +93 -0
- package/dist/types/components/json-viewer/index.d.ts +2 -0
- package/dist/types/components/json-viewer/json-viewer.d.ts +82 -0
- package/dist/types/components/mention-input/index.d.ts +2 -0
- package/dist/types/components/mention-input/mention-input.d.ts +87 -0
- package/dist/types/components/menu/menu.d.ts +68 -7
- package/dist/types/components/metric-card/index.d.ts +1 -0
- package/dist/types/components/metric-card/metric-card.d.ts +37 -0
- package/dist/types/components/multi-select/index.d.ts +2 -0
- package/dist/types/components/multi-select/multi-select.d.ts +73 -0
- package/dist/types/components/pagination/pagination.d.ts +1 -1
- package/dist/types/components/password-field/index.d.ts +2 -0
- package/dist/types/components/password-field/password-field.d.ts +34 -0
- package/dist/types/components/popover/popover.d.ts +1 -1
- package/dist/types/components/radio-cards/index.d.ts +1 -0
- package/dist/types/components/radio-cards/radio-cards.d.ts +42 -0
- package/dist/types/components/radio-group/radio-group.d.ts +1 -1
- package/dist/types/components/resizable-panels/index.d.ts +2 -0
- package/dist/types/components/resizable-panels/resizable-panels.d.ts +42 -0
- package/dist/types/components/scroll-area/index.d.ts +2 -0
- package/dist/types/components/scroll-area/scroll-area.d.ts +34 -0
- package/dist/types/components/search-field/index.d.ts +1 -0
- package/dist/types/components/search-field/search-field.d.ts +31 -0
- package/dist/types/components/segmented-control/index.d.ts +2 -0
- package/dist/types/components/segmented-control/segmented-control.d.ts +32 -0
- package/dist/types/components/select/select.d.ts +1 -1
- package/dist/types/components/signature-pad/index.d.ts +2 -0
- package/dist/types/components/signature-pad/signature-pad.d.ts +104 -0
- package/dist/types/components/slider/index.d.ts +1 -0
- package/dist/types/components/slider/slider-style.d.ts +14 -0
- package/dist/types/components/slider/slider.d.ts +62 -0
- package/dist/types/components/slider/use-slider-interaction.d.ts +79 -0
- package/dist/types/components/sortable-data-table/index.d.ts +1 -0
- package/dist/types/components/sortable-data-table/sortable-data-table.d.ts +76 -0
- package/dist/types/components/split-button/index.d.ts +2 -0
- package/dist/types/components/split-button/split-button.d.ts +55 -0
- package/dist/types/components/stepper/index.d.ts +2 -0
- package/dist/types/components/stepper/stepper.d.ts +85 -0
- package/dist/types/components/swipe-actions/index.d.ts +2 -0
- package/dist/types/components/swipe-actions/swipe-actions.d.ts +44 -0
- package/dist/types/components/tabs/tabs.d.ts +1 -1
- package/dist/types/components/tag-input/index.d.ts +2 -0
- package/dist/types/components/tag-input/tag-input.d.ts +66 -0
- package/dist/types/components/text-field/text-field.d.ts +1 -1
- package/dist/types/components/textarea/textarea.d.ts +1 -1
- package/dist/types/components/theme-switch/index.d.ts +1 -0
- package/dist/types/components/theme-switch/theme-switch.d.ts +33 -0
- package/dist/types/components/time-picker/index.d.ts +2 -0
- package/dist/types/components/time-picker/time-picker.d.ts +48 -0
- package/dist/types/components/timeline/index.d.ts +2 -0
- package/dist/types/components/timeline/timeline.d.ts +66 -0
- package/dist/types/components/toast/toast.d.ts +37 -2
- package/dist/types/components/toast-stack/index.d.ts +2 -0
- package/dist/types/components/toast-stack/toast-stack.d.ts +28 -0
- package/dist/types/components/tooltip/tooltip.d.ts +2 -2
- package/dist/types/components/tree-view/index.d.ts +1 -0
- package/dist/types/components/tree-view/tree-view.d.ts +47 -0
- package/dist/types/components/usage-meter/index.d.ts +2 -0
- package/dist/types/components/usage-meter/usage-meter.d.ts +83 -0
- package/dist/types/index.d.ts +45 -0
- package/dist/types/overlay/overlay-layer.d.ts +53 -0
- package/dist/types/overlay/use-overlay-floating.d.ts +19 -2
- package/dist/types/styling/media.d.ts +1 -0
- package/dist/types/styling/theme.d.ts +12 -0
- package/dist/types/utils/use-controlled-state.d.ts +2 -1
- package/dist/usage-meter-qyQ3rYVv.js +463 -0
- package/dist/usage-meter.js +2 -0
- package/dist/use-controlled-state-DpeVQZNR.js +20 -0
- package/dist/use-latest-callback-cj1OOQL6.js +11 -0
- package/dist/use-overlay-floating-Bx2jBKAA.js +33 -0
- package/dist/use-slider-interaction-ChL-208h.js +234 -0
- package/package.json +195 -3
- package/dist/accordion-Bd-j04hW.js +0 -198
- package/dist/avatar-BahDVO9t.js +0 -132
- package/dist/badge-B_sLygxU.js +0 -108
- package/dist/calendar-C9Yad_-w.js +0 -394
- package/dist/card-D-aI2QHx.js +0 -158
- package/dist/collection-registry-BTYi6zGh.js +0 -98
- package/dist/combobox-DiMC2g_u.js +0 -327
- package/dist/command-palette-V_2pEay7.js +0 -379
- package/dist/date-picker-C29Uo4Tx.js +0 -250
- package/dist/field-anatomy-D2ToMeRa.js +0 -109
- package/dist/menu-CGPTNRnF.js +0 -216
- package/dist/pill-DO2gHzMb.js +0 -56
- package/dist/popover-CdRXjQqI.js +0 -113
- package/dist/select-BgG7WgSh.js +0 -286
- package/dist/switch-Dr-qjmT4.js +0 -142
- package/dist/tabs-CK_g1RKa.js +0 -203
- package/dist/toast-CjmELMZZ.js +0 -283
- package/dist/tooltip-CaL3rKbV.js +0 -108
- package/dist/use-controlled-state-CVXDa-qM.js +0 -21
- package/dist/use-overlay-floating-Bit-f0FU.js +0 -31
- package/dist/{theme-root-BbTBuLMQ.js → theme-root-Bs1U3uPA.js} +2 -2
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { r as e } from "./sx-Dx9JUKp5.js";
|
|
3
|
+
import { vars as t } from "@jfrader/tokens/vars";
|
|
4
|
+
//#region src/styling/listbox-style.ts
|
|
5
|
+
var n = e({
|
|
6
|
+
boxSizing: "border-box",
|
|
7
|
+
display: "flex",
|
|
8
|
+
flexDirection: "column",
|
|
9
|
+
backgroundColor: t.color.surfaceRaised,
|
|
10
|
+
border: `1px solid ${t.color.border}`,
|
|
11
|
+
borderRadius: t.radius.md,
|
|
12
|
+
boxShadow: t.shadow.overlay,
|
|
13
|
+
padding: t.space[1],
|
|
14
|
+
minInlineSize: "180px",
|
|
15
|
+
maxInlineSize: "min(320px, calc(100vw - 32px))",
|
|
16
|
+
color: t.color.text,
|
|
17
|
+
fontFamily: t.font.sans,
|
|
18
|
+
lineHeight: t.lineHeight.base
|
|
19
|
+
}), r = e({
|
|
20
|
+
maxBlockSize: "280px",
|
|
21
|
+
overflow: "auto",
|
|
22
|
+
"&[hidden]": { display: "none" }
|
|
23
|
+
}), i = e({
|
|
24
|
+
boxSizing: "border-box",
|
|
25
|
+
display: "flex",
|
|
26
|
+
alignItems: "center",
|
|
27
|
+
inlineSize: "100%",
|
|
28
|
+
minBlockSize: "32px",
|
|
29
|
+
flexShrink: 0,
|
|
30
|
+
borderRadius: t.radius.sm,
|
|
31
|
+
paddingBlock: t.space[1],
|
|
32
|
+
paddingInline: t.space[2],
|
|
33
|
+
fontSize: t.textSize.sm,
|
|
34
|
+
color: t.color.text,
|
|
35
|
+
cursor: "pointer",
|
|
36
|
+
userSelect: "none",
|
|
37
|
+
transitionProperty: "background-color",
|
|
38
|
+
transitionDuration: t.motion.duration.fast,
|
|
39
|
+
transitionTimingFunction: t.motion.easeStandard,
|
|
40
|
+
"&[data-active]": {
|
|
41
|
+
outline: `2px solid ${t.color.focusRing}`,
|
|
42
|
+
outlineOffset: "-2px"
|
|
43
|
+
},
|
|
44
|
+
"@media (prefers-reduced-motion: reduce)": { transitionDuration: "0s" }
|
|
45
|
+
}), a = e({
|
|
46
|
+
"&:hover:not([aria-disabled=\"true\"]), &[data-active]:not([aria-disabled=\"true\"])": { backgroundColor: t.color.surfaceHover },
|
|
47
|
+
"&[aria-disabled=\"true\"]": {
|
|
48
|
+
opacity: .55,
|
|
49
|
+
cursor: "not-allowed"
|
|
50
|
+
}
|
|
51
|
+
}), o = e({
|
|
52
|
+
gap: t.space[2],
|
|
53
|
+
"&[aria-selected=\"true\"]": { fontWeight: t.fontWeight.medium }
|
|
54
|
+
}), s = e({
|
|
55
|
+
flex: 1,
|
|
56
|
+
minInlineSize: 0
|
|
57
|
+
}), c = e({ color: t.color.accentText });
|
|
58
|
+
//#endregion
|
|
59
|
+
export { s as a, o as i, i as n, r as o, c as r, n as s, a as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
//#region src/styling/media.ts
|
|
3
|
-
var e = "@media (prefers-reduced-motion: reduce)", t = "@media (forced-colors: active)";
|
|
3
|
+
var e = "@media (prefers-reduced-motion: reduce)", t = "@media (forced-colors: active)", n = "@media (pointer: coarse)";
|
|
4
4
|
//#endregion
|
|
5
|
-
export {
|
|
5
|
+
export { t as n, e as r, n as t };
|
|
@@ -0,0 +1,600 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { r as e } from "./sx-Dx9JUKp5.js";
|
|
3
|
+
import { n as t, r as n } from "./media-8yrN85VT.js";
|
|
4
|
+
import { t as r } from "./use-controlled-state-DpeVQZNR.js";
|
|
5
|
+
import { t as i } from "./visually-hidden-BJdvqqvn.js";
|
|
6
|
+
import { t as a } from "./renderable-DzcIj1Lo.js";
|
|
7
|
+
import { n as o, s, t as c } from "./listbox-style-WX-RASp1.js";
|
|
8
|
+
import { t as ee } from "./overlay-portal-C4JZFq2M.js";
|
|
9
|
+
import { t as te } from "./input-control-DmMuAuPS.js";
|
|
10
|
+
import { a as ne, i as re, n as ie, r as ae, t as oe } from "./field-anatomy-COVdNpf5.js";
|
|
11
|
+
import { useId as se, useImperativeHandle as ce, useLayoutEffect as l, useRef as u, useState as d } from "react";
|
|
12
|
+
import { vars as f } from "@jfrader/tokens/vars";
|
|
13
|
+
import { createElement as le } from "@emotion/react";
|
|
14
|
+
import { Fragment as ue, jsx as p, jsxs as m } from "@emotion/react/jsx-runtime";
|
|
15
|
+
import { autoUpdate as de, flip as fe, offset as pe, shift as me, size as he, useDismiss as ge, useFloating as _e, useInteractions as ve, useListNavigation as ye, useMergeRefs as be } from "@floating-ui/react";
|
|
16
|
+
import { flushSync as xe } from "react-dom";
|
|
17
|
+
//#region src/components/mention-input/mention-input.tsx
|
|
18
|
+
var Se = {
|
|
19
|
+
text: "",
|
|
20
|
+
mentions: []
|
|
21
|
+
}, Ce = {
|
|
22
|
+
person: "@",
|
|
23
|
+
channel: "#"
|
|
24
|
+
}, we = 8, Te = 8;
|
|
25
|
+
function Ee(e, t, n) {
|
|
26
|
+
return `${t.format(e)} ${n.select(e) === "one" ? "result" : "results"}`;
|
|
27
|
+
}
|
|
28
|
+
var De = {
|
|
29
|
+
peopleLabel: "People",
|
|
30
|
+
channelsLabel: "Channels",
|
|
31
|
+
results: (e) => Ee(e, new Intl.NumberFormat(), new Intl.PluralRules()),
|
|
32
|
+
empty: () => "No results",
|
|
33
|
+
added: (e) => `Added ${h(e.kind, e.label)}`,
|
|
34
|
+
removed: (e) => `Removed ${h(e.kind, e.label)}`,
|
|
35
|
+
invalidValue: "MentionInput: invalid token ranges were omitted."
|
|
36
|
+
};
|
|
37
|
+
function h(e, t) {
|
|
38
|
+
return `${Ce[e]}${t}`;
|
|
39
|
+
}
|
|
40
|
+
function g(e) {
|
|
41
|
+
let t = 0;
|
|
42
|
+
return e.mentions.filter((n) => {
|
|
43
|
+
let r = Number.isInteger(n.start) && Number.isInteger(n.end) && n.start >= t && n.end > n.start && n.end <= e.text.length && e.text.slice(n.start, n.end) === h(n.kind, n.label);
|
|
44
|
+
return r && (t = n.end), r;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function Oe(e, t = (e) => `<${Ce[e.kind]}${e.id}>`) {
|
|
48
|
+
let n = 0, r = "";
|
|
49
|
+
for (let i of g(e)) r += e.text.slice(n, i.start) + t(i), n = i.end;
|
|
50
|
+
return r + e.text.slice(n);
|
|
51
|
+
}
|
|
52
|
+
function _(e, t) {
|
|
53
|
+
return e.text === t.text && e.mentions.length === t.mentions.length && e.mentions.every((e, n) => {
|
|
54
|
+
let r = t.mentions[n];
|
|
55
|
+
return !!r && e.id === r.id && e.kind === r.kind && e.label === r.label && e.start === r.start && e.end === r.end;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
function v(e, t, n, r) {
|
|
59
|
+
let i = r.length - (n - t);
|
|
60
|
+
return {
|
|
61
|
+
text: e.text.slice(0, t) + r + e.text.slice(n),
|
|
62
|
+
mentions: g(e).flatMap((e) => e.end <= t ? [e] : e.start >= n ? [{
|
|
63
|
+
...e,
|
|
64
|
+
start: e.start + i,
|
|
65
|
+
end: e.end + i
|
|
66
|
+
}] : [])
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function ke(e, t, n) {
|
|
70
|
+
if (n && _(n.value, e) && !n.inputType.startsWith("history")) {
|
|
71
|
+
let { start: r, end: i } = n, a = e.text.length - t.length;
|
|
72
|
+
r === i && a > 0 && (n.inputType.endsWith("Backward") && (r = Math.max(0, r - a)), n.inputType.endsWith("Forward") && (i = Math.min(e.text.length, i + a)));
|
|
73
|
+
let o = t.length - e.text.length + i - r;
|
|
74
|
+
if (o >= 0 && t.startsWith(e.text.slice(0, r)) && t.endsWith(e.text.slice(i))) return v(e, r, i, t.slice(r, r + o));
|
|
75
|
+
}
|
|
76
|
+
let r = 0;
|
|
77
|
+
for (; r < e.text.length && r < t.length && e.text[r] === t[r];) r++;
|
|
78
|
+
let i = e.text.length, a = t.length;
|
|
79
|
+
for (; i > r && a > r && e.text[i - 1] === t[a - 1];) i--, a--;
|
|
80
|
+
return {
|
|
81
|
+
text: t,
|
|
82
|
+
mentions: g(v(e, r, i, t.slice(r, a)))
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function y(e, t, n, r) {
|
|
86
|
+
if (e.mentions.some((e) => t > e.start && t <= e.end)) return null;
|
|
87
|
+
let i = e.text.slice(0, t), a = /(?:^|[\s([{'"“‘])([@#])([\p{L}\p{N}\p{M}_-]*)$/u.exec(i);
|
|
88
|
+
if (!a) return null;
|
|
89
|
+
let o = a[1] === "@" ? "person" : "channel";
|
|
90
|
+
if (!(o === "person" ? n : r)) return null;
|
|
91
|
+
let s = a[2] ?? "", c = t - s.length - 1;
|
|
92
|
+
return e.mentions.some((e) => c < e.end && t > e.start) ? null : {
|
|
93
|
+
kind: o,
|
|
94
|
+
start: c,
|
|
95
|
+
end: t,
|
|
96
|
+
query: s
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function Ae(e, t) {
|
|
100
|
+
return Number.isFinite(e) && e > 0 ? Math.max(1, Math.floor(e)) : t;
|
|
101
|
+
}
|
|
102
|
+
var je = e({
|
|
103
|
+
boxSizing: "border-box",
|
|
104
|
+
inlineSize: "100%",
|
|
105
|
+
minInlineSize: 0,
|
|
106
|
+
fontFamily: f.font.sans,
|
|
107
|
+
lineHeight: f.lineHeight.base,
|
|
108
|
+
paddingBlock: f.space[2],
|
|
109
|
+
whiteSpace: "pre-wrap",
|
|
110
|
+
overflowWrap: "break-word",
|
|
111
|
+
tabSize: 4
|
|
112
|
+
}), Me = e({
|
|
113
|
+
minInlineSize: 0,
|
|
114
|
+
maxInlineSize: "100%",
|
|
115
|
+
overflowWrap: "anywhere"
|
|
116
|
+
}), Ne = {
|
|
117
|
+
sm: e({
|
|
118
|
+
paddingInline: f.space[3],
|
|
119
|
+
fontSize: f.textSize.sm
|
|
120
|
+
}),
|
|
121
|
+
md: e({
|
|
122
|
+
paddingInline: f.space[4],
|
|
123
|
+
fontSize: f.textSize.sm
|
|
124
|
+
}),
|
|
125
|
+
lg: e({
|
|
126
|
+
paddingInline: f.space[4],
|
|
127
|
+
fontSize: f.textSize.md
|
|
128
|
+
})
|
|
129
|
+
}, Pe = e({
|
|
130
|
+
position: "relative",
|
|
131
|
+
minInlineSize: 0,
|
|
132
|
+
borderRadius: f.radius.sm
|
|
133
|
+
}), Fe = e({
|
|
134
|
+
display: "block",
|
|
135
|
+
resize: "none",
|
|
136
|
+
borderRadius: f.radius.sm,
|
|
137
|
+
minBlockSize: f.space[8],
|
|
138
|
+
backgroundColor: "transparent",
|
|
139
|
+
color: "transparent",
|
|
140
|
+
caretColor: f.color.text,
|
|
141
|
+
position: "relative",
|
|
142
|
+
"&::placeholder": { color: f.color.textMuted },
|
|
143
|
+
[t]: {
|
|
144
|
+
color: "CanvasText",
|
|
145
|
+
caretColor: "CanvasText",
|
|
146
|
+
backgroundColor: "Canvas"
|
|
147
|
+
}
|
|
148
|
+
}), Ie = e({
|
|
149
|
+
position: "absolute",
|
|
150
|
+
inset: 0,
|
|
151
|
+
pointerEvents: "none",
|
|
152
|
+
overflow: "hidden",
|
|
153
|
+
border: "1px solid transparent",
|
|
154
|
+
borderRadius: f.radius.sm,
|
|
155
|
+
color: f.color.text,
|
|
156
|
+
backgroundColor: f.color.surface,
|
|
157
|
+
[t]: { visibility: "hidden" }
|
|
158
|
+
}), Le = e({
|
|
159
|
+
color: f.color.accentText,
|
|
160
|
+
backgroundColor: f.color.accentSoft,
|
|
161
|
+
borderRadius: f.radius.sm
|
|
162
|
+
}), Re = e({
|
|
163
|
+
minInlineSize: 0,
|
|
164
|
+
overflow: "auto",
|
|
165
|
+
transitionProperty: "opacity",
|
|
166
|
+
transitionDuration: f.motion.duration.base,
|
|
167
|
+
transitionTimingFunction: f.motion.easeStandard,
|
|
168
|
+
"@starting-style": { opacity: 0 },
|
|
169
|
+
opacity: 1,
|
|
170
|
+
[n]: { transitionDuration: "0s" }
|
|
171
|
+
}), ze = e({
|
|
172
|
+
display: "grid",
|
|
173
|
+
minInlineSize: 0
|
|
174
|
+
}), Be = e({
|
|
175
|
+
overflowWrap: "anywhere",
|
|
176
|
+
flexDirection: "column",
|
|
177
|
+
alignItems: "start",
|
|
178
|
+
[t]: { "&[aria-selected=\"true\"]": { outline: "2px solid Highlight" } }
|
|
179
|
+
}), Ve = e({
|
|
180
|
+
color: f.color.textMuted,
|
|
181
|
+
fontSize: f.textSize.sm
|
|
182
|
+
}), He = e({
|
|
183
|
+
display: "inline-flex",
|
|
184
|
+
alignItems: "center",
|
|
185
|
+
gap: f.space[2]
|
|
186
|
+
}), Ue = e({
|
|
187
|
+
padding: f.space[2],
|
|
188
|
+
color: f.color.textMuted,
|
|
189
|
+
fontSize: f.textSize.sm
|
|
190
|
+
});
|
|
191
|
+
function b({ ref: e, actionsRef: t, value: n, defaultValue: f = Se, onValueChange: Oe, open: b, defaultOpen: We = !1, onOpenChange: Ge, people: x, channels: S, onMentionAdd: Ke, onSubmit: qe, submitOnEnter: Je = !1, label: Ye, description: Xe, error: Ze, size: C = "md", minRows: Qe = 1, maxRows: $e = 8, maxSuggestions: et = 6, placement: tt = "auto", locale: w, messages: nt, renderSuggestion: rt, slotProps: T, className: it, sx: at, id: ot, dir: E, required: st, disabled: D, readOnly: O, onChange: ct, onInput: lt, onKeyDown: ut, onSelect: dt, onFocus: ft, onBlur: pt, onScroll: mt, onCompositionStart: ht, onCompositionEnd: gt, "aria-labelledby": _t, "aria-describedby": vt, "aria-invalid": yt, ...k }) {
|
|
192
|
+
let A = se(), j = ne({
|
|
193
|
+
id: ot,
|
|
194
|
+
description: Xe,
|
|
195
|
+
error: Ze,
|
|
196
|
+
"aria-describedby": vt,
|
|
197
|
+
"aria-invalid": yt
|
|
198
|
+
}), M = u(null), N = u(null), bt = u(null), [P = Se, xt, St] = r(n, f, Oe), F = u(P), Ct = u(P.text);
|
|
199
|
+
F.current = P;
|
|
200
|
+
let I = g(P), L = {
|
|
201
|
+
text: P.text,
|
|
202
|
+
mentions: I
|
|
203
|
+
}, [wt = !1, R] = r(b, We, Ge), [Tt, Et] = d(!1), [Dt, Ot] = d(!1), z = u(!1), [B, kt] = d(0), [At, jt] = d(0), [Mt, Nt] = d(""), V = u(!1), Pt = u(null), H = y(L, B, x !== void 0, S !== void 0), U = wt && Tt && !!H && !D && !O && !Dt, Ft = new Intl.NumberFormat(w), It = new Intl.PluralRules(w), W = {
|
|
204
|
+
...De,
|
|
205
|
+
results: (e) => Ee(e, Ft, It),
|
|
206
|
+
...nt
|
|
207
|
+
}, Lt = new Intl.Collator(w, {
|
|
208
|
+
sensitivity: "base",
|
|
209
|
+
usage: "search"
|
|
210
|
+
}), Rt = new Intl.Segmenter(w, { granularity: "grapheme" }), G = (H?.kind === "person" ? (x ?? []).map((e) => ({
|
|
211
|
+
...e,
|
|
212
|
+
kind: "person"
|
|
213
|
+
})) : (S ?? []).map((e) => ({
|
|
214
|
+
...e,
|
|
215
|
+
kind: "channel"
|
|
216
|
+
}))).filter((e) => !H?.query || Array.from(Rt.segment(e.name)).some(({ index: t }) => Lt.compare(e.name.slice(t, t + H.query.length), H.query) === 0)).sort((e, t) => Lt.compare(e.name, t.name)).slice(0, Ae(et, 6)), K = At !== null && G[At] ? At : G.length ? 0 : null, zt = u([]);
|
|
217
|
+
zt.current.length = G.length;
|
|
218
|
+
let q = _e({
|
|
219
|
+
open: U,
|
|
220
|
+
onOpenChange: R,
|
|
221
|
+
placement: tt === "top" ? "top-start" : "bottom-start",
|
|
222
|
+
middleware: U ? [
|
|
223
|
+
pe(we),
|
|
224
|
+
...tt === "auto" ? [fe({ padding: Te })] : [],
|
|
225
|
+
me({
|
|
226
|
+
padding: Te,
|
|
227
|
+
crossAxis: !0
|
|
228
|
+
}),
|
|
229
|
+
he({
|
|
230
|
+
padding: Te,
|
|
231
|
+
apply: ({ availableWidth: e, availableHeight: t, elements: n }) => {
|
|
232
|
+
let r = M.current?.clientWidth ?? e;
|
|
233
|
+
Object.assign(n.floating.style, {
|
|
234
|
+
maxWidth: `${Math.min(r, Math.max(0, e))}px`,
|
|
235
|
+
width: `${r}px`,
|
|
236
|
+
maxHeight: `${Math.max(0, t)}px`
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
})
|
|
240
|
+
] : [],
|
|
241
|
+
whileElementsMounted: de
|
|
242
|
+
}), Bt = ye(q.context, {
|
|
243
|
+
enabled: U,
|
|
244
|
+
listRef: zt,
|
|
245
|
+
activeIndex: K,
|
|
246
|
+
onNavigate: jt,
|
|
247
|
+
virtual: !0,
|
|
248
|
+
loop: !0,
|
|
249
|
+
focusItemOnOpen: !1
|
|
250
|
+
}), Vt = ge(q.context, {
|
|
251
|
+
enabled: U,
|
|
252
|
+
escapeKey: !1
|
|
253
|
+
}), { getReferenceProps: Ht, getFloatingProps: Ut, getItemProps: Wt } = ve([Bt, Vt]), J = Ht(), Gt = [_t, a(Ye) && `${A}-label`].filter(Boolean).join(" ") || void 0, Kt = be([
|
|
254
|
+
e,
|
|
255
|
+
M,
|
|
256
|
+
q.refs.setReference
|
|
257
|
+
]), Y = Ae(Qe, 1), qt = Math.max(Y, Ae($e, 8)), X = () => {
|
|
258
|
+
let e = M.current;
|
|
259
|
+
e && (kt(e.selectionStart === e.selectionEnd ? e.selectionStart : -1), N.current && (N.current.scrollTop = e.scrollTop, N.current.scrollLeft = e.scrollLeft), q.update());
|
|
260
|
+
}, Jt = (e, t) => {
|
|
261
|
+
if (_(F.current, e)) return !0;
|
|
262
|
+
xe(() => xt(e));
|
|
263
|
+
let n = _(F.current, e), r = M.current;
|
|
264
|
+
if (r) {
|
|
265
|
+
r.value !== F.current.text && (r.value = F.current.text);
|
|
266
|
+
let e = n ? t : Math.min(B < 0 ? r.selectionStart : B, F.current.text.length);
|
|
267
|
+
z.current || r.setSelectionRange(e, e), X();
|
|
268
|
+
}
|
|
269
|
+
return n;
|
|
270
|
+
}, Z = (e, t, n, r) => {
|
|
271
|
+
let i = M.current;
|
|
272
|
+
if (!i || D || O || _(F.current, r)) return;
|
|
273
|
+
let a = i.selectionStart;
|
|
274
|
+
V.current = !0, xe(() => xt(r));
|
|
275
|
+
let o = _(F.current, r);
|
|
276
|
+
if (o) {
|
|
277
|
+
i.setSelectionRange(e, t);
|
|
278
|
+
let a = !1;
|
|
279
|
+
try {
|
|
280
|
+
i.ownerDocument.activeElement === i && (a = i.ownerDocument.execCommand("insertText", !1, n));
|
|
281
|
+
} catch {}
|
|
282
|
+
(!a || i.value !== r.text) && i.setRangeText(n, e, t, "end");
|
|
283
|
+
}
|
|
284
|
+
V.current = !1, i.value !== F.current.text && (i.value = F.current.text);
|
|
285
|
+
let s = o ? e + n.length : Math.min(a, F.current.text.length);
|
|
286
|
+
i.setSelectionRange(s, s), X();
|
|
287
|
+
}, Yt = (e) => {
|
|
288
|
+
let t = M.current;
|
|
289
|
+
if (!t || D || O) return;
|
|
290
|
+
let n = t.selectionStart, r = t.selectionEnd;
|
|
291
|
+
Z(n, r, e, v(L, n, r, e));
|
|
292
|
+
}, Xt = (e) => {
|
|
293
|
+
if (!H || D || O || z.current) return;
|
|
294
|
+
let t = h(e.kind, e.name), n = t + (/^\s/u.test(P.text.slice(H.end)) ? "" : " "), r = {
|
|
295
|
+
kind: e.kind,
|
|
296
|
+
id: e.id,
|
|
297
|
+
label: e.name,
|
|
298
|
+
start: H.start,
|
|
299
|
+
end: H.start + t.length
|
|
300
|
+
}, i = v(L, H.start, H.end, n);
|
|
301
|
+
Z(H.start, H.end, n, {
|
|
302
|
+
text: i.text,
|
|
303
|
+
mentions: [...i.mentions, r].sort((e, t) => e.start - t.start)
|
|
304
|
+
}), Ke?.(r), Nt(W.added(r)), R(!1);
|
|
305
|
+
};
|
|
306
|
+
ce(t, () => ({
|
|
307
|
+
insert: Yt,
|
|
308
|
+
clear: () => {
|
|
309
|
+
D || O || (Z(0, P.text.length, "", Se), R(!1));
|
|
310
|
+
},
|
|
311
|
+
openSuggestions: (e) => {
|
|
312
|
+
D || O || !(e === "person" ? x : S) || (Yt(Ce[e]), R(!0));
|
|
313
|
+
}
|
|
314
|
+
})), l(() => {
|
|
315
|
+
I.length !== P.mentions.length && process.env.NODE_ENV !== "production" && console.warn(W.invalidValue);
|
|
316
|
+
}, [
|
|
317
|
+
P,
|
|
318
|
+
W.invalidValue,
|
|
319
|
+
I.length
|
|
320
|
+
]), l(() => {
|
|
321
|
+
let e = M.current;
|
|
322
|
+
if (!e) return;
|
|
323
|
+
let t = (t) => {
|
|
324
|
+
Pt.current = V.current ? null : {
|
|
325
|
+
value: F.current,
|
|
326
|
+
start: e.selectionStart,
|
|
327
|
+
end: e.selectionEnd,
|
|
328
|
+
inputType: t.inputType
|
|
329
|
+
};
|
|
330
|
+
};
|
|
331
|
+
return e.addEventListener("beforeinput", t), () => e.removeEventListener("beforeinput", t);
|
|
332
|
+
}, []), l(() => {
|
|
333
|
+
let e = M.current, t = N.current;
|
|
334
|
+
if (!e || !t) return;
|
|
335
|
+
let n = () => {
|
|
336
|
+
let n = e.ownerDocument.defaultView.getComputedStyle(e), r = parseFloat(n.lineHeight), i = parseFloat(n.paddingTop) + parseFloat(n.paddingBottom), a = parseFloat(n.borderTopWidth) + parseFloat(n.borderBottomWidth);
|
|
337
|
+
e.style.height = "0px", e.style.height = `${Math.min(Math.max(e.scrollHeight + a, Y * r + i + a), qt * r + i + a)}px`, t.style.width = `${e.clientWidth + a}px`, t.scrollTop = e.scrollTop, t.scrollLeft = e.scrollLeft, q.refs.setPositionReference({
|
|
338
|
+
contextElement: e,
|
|
339
|
+
getBoundingClientRect: () => bt.current?.getBoundingClientRect() ?? e.getBoundingClientRect()
|
|
340
|
+
});
|
|
341
|
+
};
|
|
342
|
+
n();
|
|
343
|
+
let r = new ResizeObserver(n);
|
|
344
|
+
r.observe(e);
|
|
345
|
+
let i = !0;
|
|
346
|
+
return e.ownerDocument.fonts?.ready.then(() => {
|
|
347
|
+
i && n();
|
|
348
|
+
}), () => {
|
|
349
|
+
i = !1, r.disconnect();
|
|
350
|
+
};
|
|
351
|
+
}, [
|
|
352
|
+
P.text,
|
|
353
|
+
B,
|
|
354
|
+
C,
|
|
355
|
+
Y,
|
|
356
|
+
qt,
|
|
357
|
+
q.refs
|
|
358
|
+
]), l(() => {
|
|
359
|
+
let e = M.current, t = e?.form;
|
|
360
|
+
if (!e || !t) return;
|
|
361
|
+
let n = (t) => {
|
|
362
|
+
queueMicrotask(() => {
|
|
363
|
+
t.defaultPrevented || (xe(() => St()), e.value !== F.current.text && (e.value = F.current.text), R(!1), kt(0));
|
|
364
|
+
});
|
|
365
|
+
};
|
|
366
|
+
return t.addEventListener("reset", n), () => t.removeEventListener("reset", n);
|
|
367
|
+
}, [
|
|
368
|
+
St,
|
|
369
|
+
R,
|
|
370
|
+
k.form
|
|
371
|
+
]);
|
|
372
|
+
let Zt = () => {
|
|
373
|
+
let e = M.current;
|
|
374
|
+
if (!e || z.current || V.current) return;
|
|
375
|
+
let t = e.selectionStart, n = e.selectionEnd;
|
|
376
|
+
for (let e of I) t === n && t > e.start && t < e.end ? t = n = t - e.start < e.end - t ? e.start : e.end : (t > e.start && t < e.end && (t = e.start), n > e.start && n < e.end && (n = e.end));
|
|
377
|
+
(t !== e.selectionStart || n !== e.selectionEnd) && e.setSelectionRange(t, n, e.selectionDirection), X();
|
|
378
|
+
}, Q = [], $ = 0;
|
|
379
|
+
l(() => {
|
|
380
|
+
let e = M.current;
|
|
381
|
+
if (!e) return;
|
|
382
|
+
if (!V.current && e.value !== P.text) {
|
|
383
|
+
let { selectionStart: t, selectionEnd: n, selectionDirection: r } = e;
|
|
384
|
+
e.value = P.text, e.setSelectionRange(Math.min(t, P.text.length), Math.min(n, P.text.length), r);
|
|
385
|
+
}
|
|
386
|
+
let t = () => Zt();
|
|
387
|
+
return e.addEventListener("select", t), () => e.removeEventListener("select", t);
|
|
388
|
+
});
|
|
389
|
+
let Qt = (e, t) => {
|
|
390
|
+
if (B >= t && B <= t + e.length) {
|
|
391
|
+
let n = B - t;
|
|
392
|
+
return /* @__PURE__ */ m(ue, { children: [
|
|
393
|
+
e.slice(0, n),
|
|
394
|
+
/* @__PURE__ */ p("span", {
|
|
395
|
+
ref: bt,
|
|
396
|
+
children: ""
|
|
397
|
+
}),
|
|
398
|
+
e.slice(n)
|
|
399
|
+
] });
|
|
400
|
+
}
|
|
401
|
+
return e;
|
|
402
|
+
};
|
|
403
|
+
for (let e of I) Q.push(/* @__PURE__ */ p("span", { children: Qt(P.text.slice($, e.start), $) }, `text-${$}`)), Q.push(/* @__PURE__ */ p("span", {
|
|
404
|
+
"data-ui": "mention-input-token",
|
|
405
|
+
className: T?.token?.className,
|
|
406
|
+
css: [Le, T?.token?.css],
|
|
407
|
+
children: h(e.kind, e.label)
|
|
408
|
+
}, `${e.start}-${e.end}`)), $ = e.end;
|
|
409
|
+
return Q.push(/* @__PURE__ */ m("span", { children: [Qt(P.text.slice($), $), "\n"] }, "tail")), /* @__PURE__ */ m(re, {
|
|
410
|
+
"data-ui": "mention-input",
|
|
411
|
+
dir: E,
|
|
412
|
+
className: it,
|
|
413
|
+
sx: at,
|
|
414
|
+
part: {
|
|
415
|
+
...T?.root,
|
|
416
|
+
css: [Me, T?.root?.css]
|
|
417
|
+
},
|
|
418
|
+
children: [
|
|
419
|
+
/* @__PURE__ */ p(ae, {
|
|
420
|
+
id: `${A}-label`,
|
|
421
|
+
htmlFor: j.id,
|
|
422
|
+
required: st,
|
|
423
|
+
part: T?.label,
|
|
424
|
+
children: Ye
|
|
425
|
+
}),
|
|
426
|
+
/* @__PURE__ */ m("div", {
|
|
427
|
+
role: "combobox",
|
|
428
|
+
"aria-label": k["aria-label"],
|
|
429
|
+
"aria-labelledby": Gt,
|
|
430
|
+
"aria-haspopup": "listbox",
|
|
431
|
+
"aria-expanded": U,
|
|
432
|
+
"aria-controls": U ? `${A}-list` : void 0,
|
|
433
|
+
className: T?.control?.className,
|
|
434
|
+
css: [Pe, T?.control?.css],
|
|
435
|
+
children: [/* @__PURE__ */ p("div", {
|
|
436
|
+
ref: N,
|
|
437
|
+
"aria-hidden": "true",
|
|
438
|
+
dir: E,
|
|
439
|
+
className: T?.mirror?.className,
|
|
440
|
+
css: [
|
|
441
|
+
je,
|
|
442
|
+
Ne[C],
|
|
443
|
+
Ie,
|
|
444
|
+
T?.mirror?.css
|
|
445
|
+
],
|
|
446
|
+
children: Q
|
|
447
|
+
}), /* @__PURE__ */ p("textarea", {
|
|
448
|
+
...J,
|
|
449
|
+
...k,
|
|
450
|
+
onKeyDown: (e) => {
|
|
451
|
+
if (ut?.(e), e.defaultPrevented || D || O || z.current || e.nativeEvent.isComposing || e.keyCode === 229) return;
|
|
452
|
+
let t = !e.ctrlKey && !e.metaKey && !e.altKey;
|
|
453
|
+
if (t && (e.key === "ArrowDown" || e.key === "ArrowUp") && typeof J.onKeyDown == "function" && J.onKeyDown(e), e.key === "Escape" && U) e.preventDefault(), R(!1);
|
|
454
|
+
else if (t && !e.shiftKey && U && K !== null && (e.key === "Enter" || e.key === "Tab")) {
|
|
455
|
+
e.preventDefault();
|
|
456
|
+
let t = G[K];
|
|
457
|
+
!e.repeat && t && Xt(t);
|
|
458
|
+
} else if (e.key === "Tab") R(!1);
|
|
459
|
+
else if (e.key === "Enter" && t && !e.shiftKey && Je) e.preventDefault(), !e.repeat && P.text.trim() && qe?.(P);
|
|
460
|
+
else if (t && !e.shiftKey && e.currentTarget.selectionStart === e.currentTarget.selectionEnd) {
|
|
461
|
+
let t = e.currentTarget.selectionStart, n = e.key === "Backspace" ? I.find((e) => e.end === t) : e.key === "Delete" ? I.find((e) => e.start === t) : void 0;
|
|
462
|
+
n && (e.preventDefault(), Z(n.start, n.end, "", v(L, n.start, n.end, "")), Nt(W.removed(n)));
|
|
463
|
+
let r = e.key === "ArrowLeft" ? I.find((e) => e.end === t) : e.key === "ArrowRight" ? I.find((e) => e.start === t) : void 0;
|
|
464
|
+
if (r) {
|
|
465
|
+
e.preventDefault();
|
|
466
|
+
let t = e.key === "ArrowLeft" ? r.start : r.end;
|
|
467
|
+
e.currentTarget.setSelectionRange(t, t), X();
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
},
|
|
471
|
+
ref: Kt,
|
|
472
|
+
id: j.id,
|
|
473
|
+
dir: E,
|
|
474
|
+
required: st,
|
|
475
|
+
disabled: D,
|
|
476
|
+
readOnly: O,
|
|
477
|
+
rows: Y,
|
|
478
|
+
defaultValue: Ct.current,
|
|
479
|
+
"aria-multiline": "true",
|
|
480
|
+
"aria-autocomplete": "list",
|
|
481
|
+
"aria-haspopup": "listbox",
|
|
482
|
+
"aria-controls": U ? `${A}-list` : void 0,
|
|
483
|
+
"aria-activedescendant": U && K !== null ? `${A}-option-${K}` : void 0,
|
|
484
|
+
"aria-labelledby": Gt,
|
|
485
|
+
"aria-describedby": j.describedBy,
|
|
486
|
+
"aria-invalid": j.ariaInvalid,
|
|
487
|
+
className: T?.input?.className,
|
|
488
|
+
css: [
|
|
489
|
+
te,
|
|
490
|
+
je,
|
|
491
|
+
Ne[C],
|
|
492
|
+
Fe,
|
|
493
|
+
T?.input?.css
|
|
494
|
+
],
|
|
495
|
+
onChange: ct,
|
|
496
|
+
onInput: (e) => {
|
|
497
|
+
lt?.(e);
|
|
498
|
+
let t = Pt.current;
|
|
499
|
+
if (Pt.current = null, V.current) return;
|
|
500
|
+
let n = e.currentTarget.selectionStart, r = ke(L, e.currentTarget.value, t);
|
|
501
|
+
Jt(r, n), z.current || (jt(0), y(r, n, x !== void 0, S !== void 0) && R(!0));
|
|
502
|
+
},
|
|
503
|
+
onSelect: (e) => {
|
|
504
|
+
dt?.(e), Zt();
|
|
505
|
+
},
|
|
506
|
+
onFocus: (e) => {
|
|
507
|
+
ft?.(e), Et(!0), X(), y(L, e.currentTarget.selectionStart, x !== void 0, S !== void 0) && R(!0);
|
|
508
|
+
},
|
|
509
|
+
onBlur: (e) => {
|
|
510
|
+
pt?.(e), Et(!1), R(!1);
|
|
511
|
+
},
|
|
512
|
+
onScroll: (e) => {
|
|
513
|
+
mt?.(e), X();
|
|
514
|
+
},
|
|
515
|
+
onCompositionStart: (e) => {
|
|
516
|
+
ht?.(e), z.current = !0, Ot(!0);
|
|
517
|
+
},
|
|
518
|
+
onCompositionEnd: (e) => {
|
|
519
|
+
gt?.(e), z.current = !1, Ot(!1), X(), y(F.current, e.currentTarget.selectionStart, x !== void 0, S !== void 0) && R(!0);
|
|
520
|
+
}
|
|
521
|
+
})]
|
|
522
|
+
}),
|
|
523
|
+
/* @__PURE__ */ p(oe, {
|
|
524
|
+
id: j.descriptionId,
|
|
525
|
+
part: T?.description,
|
|
526
|
+
children: Xe
|
|
527
|
+
}),
|
|
528
|
+
/* @__PURE__ */ p(ie, {
|
|
529
|
+
id: j.errorId,
|
|
530
|
+
part: T?.error,
|
|
531
|
+
children: Ze
|
|
532
|
+
}),
|
|
533
|
+
/* @__PURE__ */ p("span", {
|
|
534
|
+
role: "status",
|
|
535
|
+
"aria-live": "polite",
|
|
536
|
+
"aria-atomic": "true",
|
|
537
|
+
className: T?.status?.className,
|
|
538
|
+
css: [i, T?.status?.css],
|
|
539
|
+
children: U && H ? G.length ? W.results(G.length, H.kind) : W.empty(H.kind, H.query) : Mt
|
|
540
|
+
}),
|
|
541
|
+
U && H && /* @__PURE__ */ p(ee, { children: /* @__PURE__ */ m("div", {
|
|
542
|
+
ref: q.refs.setFloating,
|
|
543
|
+
style: q.floatingStyles,
|
|
544
|
+
dir: E,
|
|
545
|
+
className: T?.panel?.className,
|
|
546
|
+
css: [
|
|
547
|
+
s,
|
|
548
|
+
Re,
|
|
549
|
+
T?.panel?.css
|
|
550
|
+
],
|
|
551
|
+
children: [/* @__PURE__ */ p("div", {
|
|
552
|
+
...Ut(),
|
|
553
|
+
role: "listbox",
|
|
554
|
+
id: `${A}-list`,
|
|
555
|
+
"aria-label": H.kind === "person" ? W.peopleLabel : W.channelsLabel,
|
|
556
|
+
className: T?.list?.className,
|
|
557
|
+
css: [ze, T?.list?.css],
|
|
558
|
+
children: G.map((e, t) => /* @__PURE__ */ le("div", {
|
|
559
|
+
...Wt({
|
|
560
|
+
onClick: () => Xt(e),
|
|
561
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
562
|
+
onMouseMove: () => jt(t)
|
|
563
|
+
}),
|
|
564
|
+
key: `${e.kind}-${e.id}`,
|
|
565
|
+
ref: (e) => {
|
|
566
|
+
zt.current[t] = e;
|
|
567
|
+
},
|
|
568
|
+
id: `${A}-option-${t}`,
|
|
569
|
+
role: "option",
|
|
570
|
+
"aria-selected": K === t,
|
|
571
|
+
"data-active": K === t ? "" : void 0,
|
|
572
|
+
className: T?.option?.className,
|
|
573
|
+
css: [
|
|
574
|
+
o,
|
|
575
|
+
c,
|
|
576
|
+
Be,
|
|
577
|
+
T?.option?.css
|
|
578
|
+
]
|
|
579
|
+
}, rt ? rt(e, H.query) : /* @__PURE__ */ m(ue, { children: [/* @__PURE__ */ m("span", {
|
|
580
|
+
css: He,
|
|
581
|
+
children: [e.kind === "person" && a(e.avatar) && /* @__PURE__ */ p("span", {
|
|
582
|
+
"aria-hidden": "true",
|
|
583
|
+
children: e.avatar
|
|
584
|
+
}), e.name]
|
|
585
|
+
}), /* @__PURE__ */ p("span", {
|
|
586
|
+
css: Ve,
|
|
587
|
+
children: e.kind === "person" ? e.role : e.description ?? (e.members === void 0 ? null : Ft.format(e.members))
|
|
588
|
+
})] })))
|
|
589
|
+
}), !G.length && /* @__PURE__ */ p("div", {
|
|
590
|
+
className: T?.empty?.className,
|
|
591
|
+
css: [Ue, T?.empty?.css],
|
|
592
|
+
children: W.empty(H.kind, H.query)
|
|
593
|
+
})]
|
|
594
|
+
}) })
|
|
595
|
+
]
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
b.displayName = "MentionInput";
|
|
599
|
+
//#endregion
|
|
600
|
+
export { h as n, Oe as r, b as t };
|