tembro 4.0.1 → 4.1.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/CHANGELOG.md +15 -0
- package/dist/components/display/chat.cjs +1 -0
- package/dist/components/display/chat.d.ts +94 -0
- package/dist/components/display/chat.js +1 -0
- package/dist/components/display/index.d.ts +1 -0
- package/dist/components/display/kanban.d.ts +33 -1
- package/dist/components/layout/sidebar.d.ts +24 -2
- package/dist/components/modern/rich-text-editor.d.ts +13 -1
- package/dist/components/theme-provider.d.ts +19 -6
- package/dist/components/ui/badge/index.d.ts +8 -2
- package/dist/src/components/display/activity-feed.cjs +1 -1
- package/dist/src/components/display/activity-feed.js +4 -1
- package/dist/src/components/display/chat.cjs +1 -0
- package/dist/src/components/display/chat.js +372 -0
- package/dist/src/components/display/index.cjs +1 -1
- package/dist/src/components/display/index.js +17 -16
- package/dist/src/components/display/kanban.cjs +1 -1
- package/dist/src/components/display/kanban.js +321 -176
- package/dist/src/components/display/timeline.cjs +1 -1
- package/dist/src/components/display/timeline.js +5 -5
- package/dist/src/components/inputs/tag-input.cjs +1 -1
- package/dist/src/components/inputs/tag-input.js +6 -2
- package/dist/src/components/layout/index.cjs +1 -1
- package/dist/src/components/layout/index.js +4 -4
- package/dist/src/components/layout/public.cjs +1 -1
- package/dist/src/components/layout/public.js +4 -4
- package/dist/src/components/layout/sidebar.cjs +1 -1
- package/dist/src/components/layout/sidebar.js +326 -228
- package/dist/src/components/modern/rich-text-editor.cjs +1 -1
- package/dist/src/components/modern/rich-text-editor.js +216 -89
- package/dist/src/components/theme-provider.cjs +1 -1
- package/dist/src/components/theme-provider.js +58 -36
- package/dist/src/components/ui/badge/index.cjs +1 -1
- package/dist/src/components/ui/badge/index.js +59 -47
- package/dist/src/components/ui/input/clearable.cjs +1 -1
- package/dist/src/components/ui/input/clearable.js +5 -2
- package/dist/src/components/ui/input/primitive.cjs +1 -1
- package/dist/src/components/ui/input/primitive.js +1 -1
- package/dist/src/index.cjs +1 -1
- package/dist/src/index.js +87 -86
- package/dist/src/public-component-surface.cjs +1 -1
- package/dist/src/public-component-surface.js +5 -0
- package/package.json +1 -1
- package/packages/cli/dist/index.cjs +3 -3
- package/packages/cli/vendor/src/components/display/activity-feed.tsx +1 -1
- package/packages/cli/vendor/src/components/display/chat.tsx +237 -0
- package/packages/cli/vendor/src/components/display/index.ts +1 -0
- package/packages/cli/vendor/src/components/display/kanban.tsx +219 -72
- package/packages/cli/vendor/src/components/display/timeline.tsx +10 -10
- package/packages/cli/vendor/src/components/inputs/tag-input.tsx +3 -2
- package/packages/cli/vendor/src/components/layout/sidebar.tsx +212 -51
- package/packages/cli/vendor/src/components/modern/rich-text-editor.tsx +115 -32
- package/packages/cli/vendor/src/components/theme-provider.tsx +82 -36
- package/packages/cli/vendor/src/components/ui/badge/index.tsx +29 -8
- package/packages/cli/vendor/src/components/ui/input/clearable.tsx +2 -2
- package/packages/cli/vendor/src/components/ui/input/primitive.tsx +1 -1
- package/packages/cli/vendor/src/public-component-surface.ts +1 -0
- package/packages/cli/vendor/templates/showcase/src/showcase/layout/HeroSection.tsx +2 -2
- package/packages/cli/vendor/templates/showcase/src/showcase/layout/WorkbenchSidebar.tsx +1 -1
- package/packages/cli/vendor/templates/styles/globals.css +91 -10
- package/registry.json +3 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/utils.cjs");let n=require("react");n=e.__toESM(n,1);let r=require("lucide-react"),i=require("react/jsx-runtime"),a=require("@tiptap/react"),o=require("@tiptap/starter-kit");o=e.__toESM(o,1);let s=require("@tiptap/extension-link");s=e.__toESM(s,1);let c=require("@tiptap/extension-placeholder");c=e.__toESM(c,1);function
|
|
1
|
+
"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/utils.cjs");let n=require("react");n=e.__toESM(n,1);let r=require("lucide-react"),i=require("react/jsx-runtime"),a=require("@tiptap/react"),o=require("@tiptap/starter-kit");o=e.__toESM(o,1);let s=require("@tiptap/extension-link");s=e.__toESM(s,1);let c=require("@tiptap/extension-placeholder");c=e.__toESM(c,1);var l=[`history`,`bold`,`italic`,`strike`,`code`,`heading1`,`heading2`,`heading3`,`paragraph`,`bulletList`,`orderedList`,`blockquote`,`codeBlock`,`horizontalRule`,`link`,`clearFormatting`];function u(e){return e.replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`)}function d(e,t){return t===`html`?e:`<p>${u(e)}</p>`}function f({editor:e,onLinkRequest:a,label:o,features:s=l,sticky:c=!1,size:u=`default`}){let[,d]=n.useReducer(e=>e+1,0);n.useEffect(()=>{let t=()=>d();return e.on(`transaction`,t),e.on(`selectionUpdate`,t),()=>{e.off(`transaction`,t),e.off(`selectionUpdate`,t)}},[e]);let f=e.getAttributes(`link`).href,p=[{feature:`history`,group:`history`,label:`Undo`,icon:r.Undo2Icon,disabled:!e.can().undo(),run:()=>e.chain().focus().undo().run()},{feature:`history`,group:`history`,label:`Redo`,icon:r.Redo2Icon,disabled:!e.can().redo(),run:()=>e.chain().focus().redo().run()},{feature:`bold`,group:`marks`,label:`Bold`,icon:r.BoldIcon,active:e.isActive(`bold`),run:()=>e.chain().focus().toggleBold().run()},{feature:`italic`,group:`marks`,label:`Italic`,icon:r.ItalicIcon,active:e.isActive(`italic`),run:()=>e.chain().focus().toggleItalic().run()},{feature:`strike`,group:`marks`,label:`Strike`,icon:r.StrikethroughIcon,active:e.isActive(`strike`),run:()=>e.chain().focus().toggleStrike().run()},{feature:`code`,group:`marks`,label:`Inline code`,icon:r.Code2Icon,active:e.isActive(`code`),run:()=>e.chain().focus().toggleCode().run()},{feature:`paragraph`,group:`blocks`,label:`Paragraph`,icon:r.PilcrowIcon,active:e.isActive(`paragraph`),run:()=>e.chain().focus().setParagraph().run()},{feature:`heading1`,group:`blocks`,label:`Heading 1`,icon:r.Heading1Icon,active:e.isActive(`heading`,{level:1}),run:()=>e.chain().focus().toggleHeading({level:1}).run()},{feature:`heading2`,group:`blocks`,label:`Heading 2`,icon:r.Heading2Icon,active:e.isActive(`heading`,{level:2}),run:()=>e.chain().focus().toggleHeading({level:2}).run()},{feature:`heading3`,group:`blocks`,label:`Heading 3`,icon:r.Heading3Icon,active:e.isActive(`heading`,{level:3}),run:()=>e.chain().focus().toggleHeading({level:3}).run()},{feature:`bulletList`,group:`lists`,label:`Bullet list`,icon:r.ListIcon,active:e.isActive(`bulletList`),run:()=>e.chain().focus().toggleBulletList().run()},{feature:`orderedList`,group:`lists`,label:`Ordered list`,icon:r.ListOrderedIcon,active:e.isActive(`orderedList`),run:()=>e.chain().focus().toggleOrderedList().run()},{feature:`blockquote`,group:`lists`,label:`Blockquote`,icon:r.QuoteIcon,active:e.isActive(`blockquote`),run:()=>e.chain().focus().toggleBlockquote().run()},{feature:`codeBlock`,group:`insert`,label:`Code block`,icon:r.Code2Icon,active:e.isActive(`codeBlock`),run:()=>e.chain().focus().toggleCodeBlock().run()},{feature:`horizontalRule`,group:`insert`,label:`Horizontal rule`,icon:r.MinusIcon,run:()=>e.chain().focus().setHorizontalRule().run()},{feature:`clearFormatting`,group:`clear`,label:`Clear formatting`,icon:r.EraserIcon,run:()=>e.chain().focus().unsetAllMarks().clearNodes().run()}];a&&s.includes(`link`)&&p.push({feature:`link`,group:`link`,label:`Set link`,icon:r.LinkIcon,active:e.isActive(`link`),run:()=>{let t=a(f);t!=null&&(t.trim()?e.chain().focus().extendMarkRange(`link`).setLink({href:t.trim()}).run():e.chain().focus().unsetLink().run())}}),e.isActive(`link`)&&p.push({feature:`link`,group:`link`,label:`Remove link`,icon:r.UnlinkIcon,run:()=>e.chain().focus().unsetLink().run()});let m=p.filter(e=>s.includes(e.feature));return(0,i.jsx)(`div`,{role:`toolbar`,"aria-label":o,"data-size":u,"data-sticky":c||void 0,className:t.cn(`flex flex-wrap items-center gap-1 border-b bg-background/95 p-1.5`,c&&`sticky top-0 z-10 backdrop-blur`,u===`compact`&&`flex-nowrap overflow-x-auto p-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`),children:m.map((e,r)=>{let a=e.icon,o=r>0&&m[r-1]?.group!==e.group;return(0,i.jsxs)(n.Fragment,{children:[o?(0,i.jsx)(`span`,{role:`separator`,"aria-orientation":`vertical`,className:`mx-0.5 h-5 w-px shrink-0 bg-border`}):null,(0,i.jsx)(`button`,{type:`button`,title:e.label,"aria-label":e.label,"aria-pressed":e.active||void 0,disabled:e.disabled,className:t.cn(`grid size-8 shrink-0 place-items-center rounded-md p-0 text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring aria-pressed:bg-accent aria-pressed:text-foreground disabled:pointer-events-none disabled:opacity-40`,u===`compact`&&`size-7`),onClick:e.run,children:(0,i.jsx)(a,{className:`size-4`})})]},e.label)})})}function p({value:e,defaultValue:r=``,onValueChange:u,output:p=`html`,placeholder:m=`Start typing...`,editable:h=!0,autoFocus:g=!1,minHeight:_=144,maxHeight:v,maxLength:y,toolbar:b=!0,stickyToolbar:x=!1,toolbarSize:S=`default`,features:C=l,showCharacterCount:w=!1,showWordCount:T=!1,onLinkRequest:E,labels:D,className:O,...k}){let A=e??r,j=(0,a.useEditor)({immediatelyRender:!0,autofocus:g,editable:h,editorProps:{attributes:{"aria-label":D?.editor??`Rich text editor`,role:`textbox`}},content:d(A,p),extensions:[o.default.configure({link:!1}),s.default.configure({openOnClick:!1,autolink:!0,defaultProtocol:`https`}),c.default.configure({placeholder:m})],onUpdate:({editor:e})=>{u?.(p===`html`?e.getHTML():e.getText())}}),[,M]=n.useReducer(e=>e+1,0);return n.useEffect(()=>{if(!j)return;let e=()=>M();return j.on(`update`,e),()=>{j.off(`update`,e)}},[j]),n.useEffect(()=>{!j||e===void 0||(p===`html`?j.getHTML():j.getText())!==e&&j.commands.setContent(d(e,p),{emitUpdate:!1})},[j,p,e]),n.useEffect(()=>{j?.setEditable(h)},[h,j]),(0,i.jsxs)(`div`,{"data-slot":`rich-text-editor`,"data-disabled":!h||void 0,"data-over-limit":j&&y!==void 0&&j.getText().length>y||void 0,className:t.cn(`overflow-hidden rounded-md border bg-background shadow-sm transition-[border-color,box-shadow] focus-within:border-ring focus-within:ring-2 focus-within:ring-ring/25 data-[disabled]:opacity-60 data-[over-limit=true]:border-destructive`,O),...k,children:[j&&h&&b?(0,i.jsx)(f,{editor:j,onLinkRequest:E,label:D?.toolbar??`Text formatting`,features:C,sticky:x,size:S}):null,(0,i.jsx)(a.EditorContent,{editor:j,"aria-label":D?.editor??`Rich text editor`,className:`overflow-y-auto [&_.tiptap]:min-h-[var(--editor-min-height)] [&_.tiptap]:px-3.5 [&_.tiptap]:py-3 [&_.tiptap]:text-sm [&_.tiptap]:leading-6 [&_.tiptap]:outline-none [&_.tiptap>*+*]:mt-2 [&_.tiptap_a]:text-primary [&_.tiptap_a]:underline [&_.tiptap_blockquote]:border-l-2 [&_.tiptap_blockquote]:border-primary/50 [&_.tiptap_blockquote]:pl-3 [&_.tiptap_code]:rounded [&_.tiptap_code]:bg-muted [&_.tiptap_code]:px-1 [&_.tiptap_code]:py-0.5 [&_.tiptap_h1]:text-2xl [&_.tiptap_h1]:font-semibold [&_.tiptap_h2]:text-xl [&_.tiptap_h2]:font-semibold [&_.tiptap_h3]:text-lg [&_.tiptap_h3]:font-semibold [&_.tiptap_hr]:my-4 [&_.tiptap_hr]:border-border [&_.tiptap_ol]:list-decimal [&_.tiptap_ol]:pl-6 [&_.tiptap_p.is-editor-empty:first-child:before]:pointer-events-none [&_.tiptap_p.is-editor-empty:first-child:before]:float-left [&_.tiptap_p.is-editor-empty:first-child:before]:h-0 [&_.tiptap_p.is-editor-empty:first-child:before]:text-muted-foreground [&_.tiptap_p.is-editor-empty:first-child:before]:content-[attr(data-placeholder)] [&_.tiptap_pre]:overflow-x-auto [&_.tiptap_pre]:rounded-md [&_.tiptap_pre]:bg-muted [&_.tiptap_pre]:p-3 [&_.tiptap_ul]:list-disc [&_.tiptap_ul]:pl-6`,style:{"--editor-min-height":`${_}px`,maxHeight:v}}),j&&(w||T||y!==void 0)?(0,i.jsxs)(`div`,{"data-slot":`rich-text-editor-footer`,className:`flex items-center justify-end gap-3 border-t bg-muted/20 px-3 py-1.5 text-[11px] text-muted-foreground`,children:[T?(0,i.jsxs)(`span`,{children:[j.getText().trim()?j.getText().trim().split(/\s+/).length:0,` words`]}):null,w||y!==void 0?(0,i.jsxs)(`span`,{className:t.cn(y!==void 0&&j.getText().length>y&&`font-medium text-destructive`),children:[j.getText().length,y===void 0?` characters`:`/${y}`]}):null]}):null]})}function m(e){let[r,a]=n.useState(!1);return n.useEffect(()=>{a(!0)},[]),r?(0,i.jsx)(p,{...e}):(0,i.jsx)(`div`,{"data-slot":`rich-text-editor`,"data-state":`loading`,className:t.cn(`overflow-hidden rounded-md border bg-background shadow-sm`,e.className),style:{minHeight:e.minHeight??144},"aria-busy":`true`})}exports.EditorToolbar=f,exports.RichTextEditor=m;
|
|
@@ -1,166 +1,293 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn as e } from "../../lib/utils.js";
|
|
3
3
|
import * as t from "react";
|
|
4
|
-
import { BoldIcon as n,
|
|
5
|
-
import { jsx as
|
|
6
|
-
import { EditorContent as
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
4
|
+
import { BoldIcon as n, Code2Icon as r, EraserIcon as i, Heading1Icon as a, Heading2Icon as o, Heading3Icon as s, ItalicIcon as c, LinkIcon as l, ListIcon as u, ListOrderedIcon as d, MinusIcon as f, PilcrowIcon as p, QuoteIcon as m, Redo2Icon as h, StrikethroughIcon as g, Undo2Icon as _, UnlinkIcon as v } from "lucide-react";
|
|
5
|
+
import { jsx as y, jsxs as b } from "react/jsx-runtime";
|
|
6
|
+
import { EditorContent as x, useEditor as S } from "@tiptap/react";
|
|
7
|
+
import C from "@tiptap/starter-kit";
|
|
8
|
+
import w from "@tiptap/extension-link";
|
|
9
|
+
import T from "@tiptap/extension-placeholder";
|
|
10
10
|
//#region src/components/modern/rich-text-editor.tsx
|
|
11
|
-
|
|
11
|
+
var E = [
|
|
12
|
+
"history",
|
|
13
|
+
"bold",
|
|
14
|
+
"italic",
|
|
15
|
+
"strike",
|
|
16
|
+
"code",
|
|
17
|
+
"heading1",
|
|
18
|
+
"heading2",
|
|
19
|
+
"heading3",
|
|
20
|
+
"paragraph",
|
|
21
|
+
"bulletList",
|
|
22
|
+
"orderedList",
|
|
23
|
+
"blockquote",
|
|
24
|
+
"codeBlock",
|
|
25
|
+
"horizontalRule",
|
|
26
|
+
"link",
|
|
27
|
+
"clearFormatting"
|
|
28
|
+
];
|
|
29
|
+
function D(e) {
|
|
12
30
|
return e.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">");
|
|
13
31
|
}
|
|
14
|
-
function
|
|
15
|
-
return t === "html" ? e : `<p>${
|
|
32
|
+
function O(e, t) {
|
|
33
|
+
return t === "html" ? e : `<p>${D(e)}</p>`;
|
|
16
34
|
}
|
|
17
|
-
function
|
|
18
|
-
let
|
|
35
|
+
function k({ editor: x, onLinkRequest: S, label: C, features: w = E, sticky: T = !1, size: D = "default" }) {
|
|
36
|
+
let [, O] = t.useReducer((e) => e + 1, 0);
|
|
37
|
+
t.useEffect(() => {
|
|
38
|
+
let e = () => O();
|
|
39
|
+
return x.on("transaction", e), x.on("selectionUpdate", e), () => {
|
|
40
|
+
x.off("transaction", e), x.off("selectionUpdate", e);
|
|
41
|
+
};
|
|
42
|
+
}, [x]);
|
|
43
|
+
let k = x.getAttributes("link").href, A = [
|
|
19
44
|
{
|
|
45
|
+
feature: "history",
|
|
46
|
+
group: "history",
|
|
20
47
|
label: "Undo",
|
|
21
|
-
icon:
|
|
22
|
-
disabled: !
|
|
23
|
-
run: () =>
|
|
48
|
+
icon: _,
|
|
49
|
+
disabled: !x.can().undo(),
|
|
50
|
+
run: () => x.chain().focus().undo().run()
|
|
24
51
|
},
|
|
25
52
|
{
|
|
53
|
+
feature: "history",
|
|
54
|
+
group: "history",
|
|
26
55
|
label: "Redo",
|
|
27
|
-
icon:
|
|
28
|
-
disabled: !
|
|
29
|
-
run: () =>
|
|
56
|
+
icon: h,
|
|
57
|
+
disabled: !x.can().redo(),
|
|
58
|
+
run: () => x.chain().focus().redo().run()
|
|
30
59
|
},
|
|
31
60
|
{
|
|
61
|
+
feature: "bold",
|
|
62
|
+
group: "marks",
|
|
32
63
|
label: "Bold",
|
|
33
64
|
icon: n,
|
|
34
|
-
active:
|
|
35
|
-
run: () =>
|
|
65
|
+
active: x.isActive("bold"),
|
|
66
|
+
run: () => x.chain().focus().toggleBold().run()
|
|
36
67
|
},
|
|
37
68
|
{
|
|
69
|
+
feature: "italic",
|
|
70
|
+
group: "marks",
|
|
38
71
|
label: "Italic",
|
|
39
|
-
icon:
|
|
40
|
-
active:
|
|
41
|
-
run: () =>
|
|
72
|
+
icon: c,
|
|
73
|
+
active: x.isActive("italic"),
|
|
74
|
+
run: () => x.chain().focus().toggleItalic().run()
|
|
42
75
|
},
|
|
43
76
|
{
|
|
77
|
+
feature: "strike",
|
|
78
|
+
group: "marks",
|
|
44
79
|
label: "Strike",
|
|
45
|
-
icon:
|
|
46
|
-
active:
|
|
47
|
-
run: () =>
|
|
80
|
+
icon: g,
|
|
81
|
+
active: x.isActive("strike"),
|
|
82
|
+
run: () => x.chain().focus().toggleStrike().run()
|
|
48
83
|
},
|
|
49
84
|
{
|
|
85
|
+
feature: "code",
|
|
86
|
+
group: "marks",
|
|
50
87
|
label: "Inline code",
|
|
51
88
|
icon: r,
|
|
52
|
-
active:
|
|
53
|
-
run: () =>
|
|
89
|
+
active: x.isActive("code"),
|
|
90
|
+
run: () => x.chain().focus().toggleCode().run()
|
|
54
91
|
},
|
|
55
92
|
{
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
93
|
+
feature: "paragraph",
|
|
94
|
+
group: "blocks",
|
|
95
|
+
label: "Paragraph",
|
|
96
|
+
icon: p,
|
|
97
|
+
active: x.isActive("paragraph"),
|
|
98
|
+
run: () => x.chain().focus().setParagraph().run()
|
|
60
99
|
},
|
|
61
100
|
{
|
|
62
|
-
|
|
101
|
+
feature: "heading1",
|
|
102
|
+
group: "blocks",
|
|
103
|
+
label: "Heading 1",
|
|
104
|
+
icon: a,
|
|
105
|
+
active: x.isActive("heading", { level: 1 }),
|
|
106
|
+
run: () => x.chain().focus().toggleHeading({ level: 1 }).run()
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
feature: "heading2",
|
|
110
|
+
group: "blocks",
|
|
111
|
+
label: "Heading 2",
|
|
112
|
+
icon: o,
|
|
113
|
+
active: x.isActive("heading", { level: 2 }),
|
|
114
|
+
run: () => x.chain().focus().toggleHeading({ level: 2 }).run()
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
feature: "heading3",
|
|
118
|
+
group: "blocks",
|
|
119
|
+
label: "Heading 3",
|
|
63
120
|
icon: s,
|
|
64
|
-
active:
|
|
65
|
-
run: () =>
|
|
121
|
+
active: x.isActive("heading", { level: 3 }),
|
|
122
|
+
run: () => x.chain().focus().toggleHeading({ level: 3 }).run()
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
feature: "bulletList",
|
|
126
|
+
group: "lists",
|
|
127
|
+
label: "Bullet list",
|
|
128
|
+
icon: u,
|
|
129
|
+
active: x.isActive("bulletList"),
|
|
130
|
+
run: () => x.chain().focus().toggleBulletList().run()
|
|
66
131
|
},
|
|
67
132
|
{
|
|
133
|
+
feature: "orderedList",
|
|
134
|
+
group: "lists",
|
|
68
135
|
label: "Ordered list",
|
|
69
|
-
icon:
|
|
70
|
-
active:
|
|
71
|
-
run: () =>
|
|
136
|
+
icon: d,
|
|
137
|
+
active: x.isActive("orderedList"),
|
|
138
|
+
run: () => x.chain().focus().toggleOrderedList().run()
|
|
72
139
|
},
|
|
73
140
|
{
|
|
141
|
+
feature: "blockquote",
|
|
142
|
+
group: "lists",
|
|
74
143
|
label: "Blockquote",
|
|
75
|
-
icon:
|
|
76
|
-
active:
|
|
77
|
-
run: () =>
|
|
144
|
+
icon: m,
|
|
145
|
+
active: x.isActive("blockquote"),
|
|
146
|
+
run: () => x.chain().focus().toggleBlockquote().run()
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
feature: "codeBlock",
|
|
150
|
+
group: "insert",
|
|
151
|
+
label: "Code block",
|
|
152
|
+
icon: r,
|
|
153
|
+
active: x.isActive("codeBlock"),
|
|
154
|
+
run: () => x.chain().focus().toggleCodeBlock().run()
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
feature: "horizontalRule",
|
|
158
|
+
group: "insert",
|
|
159
|
+
label: "Horizontal rule",
|
|
160
|
+
icon: f,
|
|
161
|
+
run: () => x.chain().focus().setHorizontalRule().run()
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
feature: "clearFormatting",
|
|
165
|
+
group: "clear",
|
|
166
|
+
label: "Clear formatting",
|
|
167
|
+
icon: i,
|
|
168
|
+
run: () => x.chain().focus().unsetAllMarks().clearNodes().run()
|
|
78
169
|
}
|
|
79
170
|
];
|
|
80
|
-
|
|
171
|
+
S && w.includes("link") && A.push({
|
|
172
|
+
feature: "link",
|
|
173
|
+
group: "link",
|
|
81
174
|
label: "Set link",
|
|
82
|
-
icon:
|
|
83
|
-
active:
|
|
175
|
+
icon: l,
|
|
176
|
+
active: x.isActive("link"),
|
|
84
177
|
run: () => {
|
|
85
|
-
let
|
|
86
|
-
|
|
178
|
+
let e = S(k);
|
|
179
|
+
e != null && (e.trim() ? x.chain().focus().extendMarkRange("link").setLink({ href: e.trim() }).run() : x.chain().focus().unsetLink().run());
|
|
87
180
|
}
|
|
88
|
-
}),
|
|
181
|
+
}), x.isActive("link") && A.push({
|
|
182
|
+
feature: "link",
|
|
183
|
+
group: "link",
|
|
89
184
|
label: "Remove link",
|
|
90
|
-
icon:
|
|
91
|
-
run: () =>
|
|
92
|
-
})
|
|
185
|
+
icon: v,
|
|
186
|
+
run: () => x.chain().focus().unsetLink().run()
|
|
187
|
+
});
|
|
188
|
+
let j = A.filter((e) => w.includes(e.feature));
|
|
189
|
+
return /* @__PURE__ */ y("div", {
|
|
93
190
|
role: "toolbar",
|
|
94
|
-
"aria-label":
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
191
|
+
"aria-label": C,
|
|
192
|
+
"data-size": D,
|
|
193
|
+
"data-sticky": T || void 0,
|
|
194
|
+
className: e("flex flex-wrap items-center gap-1 border-b bg-background/95 p-1.5", T && "sticky top-0 z-10 backdrop-blur", D === "compact" && "flex-nowrap overflow-x-auto p-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden"),
|
|
195
|
+
children: j.map((n, r) => {
|
|
196
|
+
let i = n.icon, a = r > 0 && j[r - 1]?.group !== n.group;
|
|
197
|
+
return /* @__PURE__ */ b(t.Fragment, { children: [a ? /* @__PURE__ */ y("span", {
|
|
198
|
+
role: "separator",
|
|
199
|
+
"aria-orientation": "vertical",
|
|
200
|
+
className: "mx-0.5 h-5 w-px shrink-0 bg-border"
|
|
201
|
+
}) : null, /* @__PURE__ */ y("button", {
|
|
99
202
|
type: "button",
|
|
100
|
-
title:
|
|
101
|
-
"aria-label":
|
|
102
|
-
"aria-pressed":
|
|
103
|
-
disabled:
|
|
104
|
-
className: "
|
|
105
|
-
onClick:
|
|
106
|
-
children: /* @__PURE__ */
|
|
107
|
-
},
|
|
203
|
+
title: n.label,
|
|
204
|
+
"aria-label": n.label,
|
|
205
|
+
"aria-pressed": n.active || void 0,
|
|
206
|
+
disabled: n.disabled,
|
|
207
|
+
className: e("grid size-8 shrink-0 place-items-center rounded-md p-0 text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring aria-pressed:bg-accent aria-pressed:text-foreground disabled:pointer-events-none disabled:opacity-40", D === "compact" && "size-7"),
|
|
208
|
+
onClick: n.run,
|
|
209
|
+
children: /* @__PURE__ */ y(i, { className: "size-4" })
|
|
210
|
+
})] }, n.label);
|
|
108
211
|
})
|
|
109
212
|
});
|
|
110
213
|
}
|
|
111
|
-
function
|
|
112
|
-
let
|
|
214
|
+
function A({ value: n, defaultValue: r = "", onValueChange: i, output: a = "html", placeholder: o = "Start typing...", editable: s = !0, autoFocus: c = !1, minHeight: l = 144, maxHeight: u, maxLength: d, toolbar: f = !0, stickyToolbar: p = !1, toolbarSize: m = "default", features: h = E, showCharacterCount: g = !1, showWordCount: _ = !1, onLinkRequest: v, labels: D, className: A, ...j }) {
|
|
215
|
+
let M = n ?? r, N = S({
|
|
113
216
|
immediatelyRender: !0,
|
|
114
217
|
autofocus: c,
|
|
115
218
|
editable: s,
|
|
116
219
|
editorProps: { attributes: {
|
|
117
|
-
"aria-label":
|
|
220
|
+
"aria-label": D?.editor ?? "Rich text editor",
|
|
118
221
|
role: "textbox"
|
|
119
222
|
} },
|
|
120
|
-
content:
|
|
223
|
+
content: O(M, a),
|
|
121
224
|
extensions: [
|
|
122
|
-
|
|
123
|
-
|
|
225
|
+
C.configure({ link: !1 }),
|
|
226
|
+
w.configure({
|
|
124
227
|
openOnClick: !1,
|
|
125
228
|
autolink: !0,
|
|
126
229
|
defaultProtocol: "https"
|
|
127
230
|
}),
|
|
128
|
-
|
|
231
|
+
T.configure({ placeholder: o })
|
|
129
232
|
],
|
|
130
233
|
onUpdate: ({ editor: e }) => {
|
|
131
234
|
i?.(a === "html" ? e.getHTML() : e.getText());
|
|
132
235
|
}
|
|
133
|
-
});
|
|
236
|
+
}), [, P] = t.useReducer((e) => e + 1, 0);
|
|
134
237
|
return t.useEffect(() => {
|
|
135
|
-
|
|
238
|
+
if (!N) return;
|
|
239
|
+
let e = () => P();
|
|
240
|
+
return N.on("update", e), () => {
|
|
241
|
+
N.off("update", e);
|
|
242
|
+
};
|
|
243
|
+
}, [N]), t.useEffect(() => {
|
|
244
|
+
!N || n === void 0 || (a === "html" ? N.getHTML() : N.getText()) !== n && N.commands.setContent(O(n, a), { emitUpdate: !1 });
|
|
136
245
|
}, [
|
|
137
|
-
|
|
246
|
+
N,
|
|
138
247
|
a,
|
|
139
248
|
n
|
|
140
249
|
]), t.useEffect(() => {
|
|
141
|
-
|
|
142
|
-
}, [s,
|
|
250
|
+
N?.setEditable(s);
|
|
251
|
+
}, [s, N]), /* @__PURE__ */ b("div", {
|
|
143
252
|
"data-slot": "rich-text-editor",
|
|
144
253
|
"data-disabled": !s || void 0,
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
254
|
+
"data-over-limit": N && d !== void 0 && N.getText().length > d || void 0,
|
|
255
|
+
className: e("overflow-hidden rounded-md border bg-background shadow-sm transition-[border-color,box-shadow] focus-within:border-ring focus-within:ring-2 focus-within:ring-ring/25 data-[disabled]:opacity-60 data-[over-limit=true]:border-destructive", A),
|
|
256
|
+
...j,
|
|
257
|
+
children: [
|
|
258
|
+
N && s && f ? /* @__PURE__ */ y(k, {
|
|
259
|
+
editor: N,
|
|
260
|
+
onLinkRequest: v,
|
|
261
|
+
label: D?.toolbar ?? "Text formatting",
|
|
262
|
+
features: h,
|
|
263
|
+
sticky: p,
|
|
264
|
+
size: m
|
|
265
|
+
}) : null,
|
|
266
|
+
/* @__PURE__ */ y(x, {
|
|
267
|
+
editor: N,
|
|
268
|
+
"aria-label": D?.editor ?? "Rich text editor",
|
|
269
|
+
className: "overflow-y-auto [&_.tiptap]:min-h-[var(--editor-min-height)] [&_.tiptap]:px-3.5 [&_.tiptap]:py-3 [&_.tiptap]:text-sm [&_.tiptap]:leading-6 [&_.tiptap]:outline-none [&_.tiptap>*+*]:mt-2 [&_.tiptap_a]:text-primary [&_.tiptap_a]:underline [&_.tiptap_blockquote]:border-l-2 [&_.tiptap_blockquote]:border-primary/50 [&_.tiptap_blockquote]:pl-3 [&_.tiptap_code]:rounded [&_.tiptap_code]:bg-muted [&_.tiptap_code]:px-1 [&_.tiptap_code]:py-0.5 [&_.tiptap_h1]:text-2xl [&_.tiptap_h1]:font-semibold [&_.tiptap_h2]:text-xl [&_.tiptap_h2]:font-semibold [&_.tiptap_h3]:text-lg [&_.tiptap_h3]:font-semibold [&_.tiptap_hr]:my-4 [&_.tiptap_hr]:border-border [&_.tiptap_ol]:list-decimal [&_.tiptap_ol]:pl-6 [&_.tiptap_p.is-editor-empty:first-child:before]:pointer-events-none [&_.tiptap_p.is-editor-empty:first-child:before]:float-left [&_.tiptap_p.is-editor-empty:first-child:before]:h-0 [&_.tiptap_p.is-editor-empty:first-child:before]:text-muted-foreground [&_.tiptap_p.is-editor-empty:first-child:before]:content-[attr(data-placeholder)] [&_.tiptap_pre]:overflow-x-auto [&_.tiptap_pre]:rounded-md [&_.tiptap_pre]:bg-muted [&_.tiptap_pre]:p-3 [&_.tiptap_ul]:list-disc [&_.tiptap_ul]:pl-6",
|
|
270
|
+
style: {
|
|
271
|
+
"--editor-min-height": `${l}px`,
|
|
272
|
+
maxHeight: u
|
|
273
|
+
}
|
|
274
|
+
}),
|
|
275
|
+
N && (g || _ || d !== void 0) ? /* @__PURE__ */ b("div", {
|
|
276
|
+
"data-slot": "rich-text-editor-footer",
|
|
277
|
+
className: "flex items-center justify-end gap-3 border-t bg-muted/20 px-3 py-1.5 text-[11px] text-muted-foreground",
|
|
278
|
+
children: [_ ? /* @__PURE__ */ b("span", { children: [N.getText().trim() ? N.getText().trim().split(/\s+/).length : 0, " words"] }) : null, g || d !== void 0 ? /* @__PURE__ */ b("span", {
|
|
279
|
+
className: e(d !== void 0 && N.getText().length > d && "font-medium text-destructive"),
|
|
280
|
+
children: [N.getText().length, d === void 0 ? " characters" : `/${d}`]
|
|
281
|
+
}) : null]
|
|
282
|
+
}) : null
|
|
283
|
+
]
|
|
157
284
|
});
|
|
158
285
|
}
|
|
159
|
-
function
|
|
286
|
+
function j(n) {
|
|
160
287
|
let [r, i] = t.useState(!1);
|
|
161
288
|
return t.useEffect(() => {
|
|
162
289
|
i(!0);
|
|
163
|
-
}, []), r ? /* @__PURE__ */
|
|
290
|
+
}, []), r ? /* @__PURE__ */ y(A, { ...n }) : /* @__PURE__ */ y("div", {
|
|
164
291
|
"data-slot": "rich-text-editor",
|
|
165
292
|
"data-state": "loading",
|
|
166
293
|
className: e("overflow-hidden rounded-md border bg-background shadow-sm", n.className),
|
|
@@ -169,4 +296,4 @@ function T(n) {
|
|
|
169
296
|
});
|
|
170
297
|
}
|
|
171
298
|
//#endregion
|
|
172
|
-
export {
|
|
299
|
+
export { k as EditorToolbar, j as RichTextEditor };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../_virtual/_rolldown/runtime.cjs");let t=require("react");t=e.__toESM(t,1);let n=require("react/jsx-runtime");var r=`tembro-theme`,i=t.createContext(null);function
|
|
1
|
+
"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../_virtual/_rolldown/runtime.cjs");let t=require("react");t=e.__toESM(t,1);let n=require("react/jsx-runtime");var r=`tembro-theme`,i=[`light`,`dark`],a={light:`light`,dark:`dark`,dim:`dark`},o=t.createContext(null);function s(){return typeof window>`u`?`light`:window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}function c({children:e,themes:c=i,defaultTheme:l=`system`,forcedTheme:u,storageKey:d=r,enableSystem:f=!0,attribute:p=`both`,colorSchemes:m=a,disableTransitionOnChange:h=!0,onThemeChange:g}){let _=t.useMemo(()=>Array.from(new Set(c.length?c:i)),[c]),[v,y]=t.useState(()=>{if(typeof window>`u`)return l;let e=window.localStorage.getItem(d);return e===`system`&&f||e&&_.includes(e)?e:l}),[b,x]=t.useState(!1),[S,C]=t.useState(s),w=t.useRef(void 0),T=u??v,E=T===`system`?_.includes(S)?S:_[0]??`light`:T,D=m[E]??a[E]??(E===`dark`?`dark`:`light`);t.useEffect(()=>{x(!0)},[]),t.useEffect(()=>{if(!f)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=()=>C(e.matches?`dark`:`light`);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[f]),t.useEffect(()=>{let e=window.document.documentElement,t;if(h){let n=document.createElement(`style`);n.textContent=`*,*::before,*::after{transition:none!important}`,document.head.append(n),window.getComputedStyle(e).opacity,t=()=>window.setTimeout(()=>n.remove(),0)}(p===`class`||p===`both`)&&(w.current&&e.classList.remove(w.current),e.classList.remove(`light`,`dark`),e.classList.add(E),D===`dark`&&E!==`dark`&&e.classList.add(`dark`),w.current=E),(p===`data-theme`||p===`both`)&&(e.dataset.theme=E),e.style.colorScheme=D,u||window.localStorage.setItem(d,v),g?.(v,E),t?.()},[p,D,h,u,g,E,d,v]);let O=t.useCallback(e=>{(e===`system`?f:_.includes(e))&&y(e)},[_,f]),k=t.useCallback(()=>{let e=[..._,...f?[`system`]:[]];y(t=>e[(e.indexOf(t)+1)%e.length]??_[0]??`light`)},[_,f]),A=t.useMemo(()=>({theme:v,resolvedTheme:E,systemTheme:S,themes:_,mounted:b,setTheme:O,toggleTheme:k}),[_,b,E,O,S,v,k]);return(0,n.jsx)(o.Provider,{value:A,children:e})}function l(){let e=t.useContext(o);if(!e)throw Error(`useTheme must be used within ThemeProvider`);return e}exports.ThemeProvider=c,exports.useTheme=l;
|
|
@@ -2,52 +2,74 @@
|
|
|
2
2
|
import * as e from "react";
|
|
3
3
|
import { jsx as t } from "react/jsx-runtime";
|
|
4
4
|
//#region src/components/theme-provider.tsx
|
|
5
|
-
var n = "tembro-theme", r =
|
|
6
|
-
|
|
5
|
+
var n = "tembro-theme", r = ["light", "dark"], i = {
|
|
6
|
+
light: "light",
|
|
7
|
+
dark: "dark",
|
|
8
|
+
dim: "dark"
|
|
9
|
+
}, a = e.createContext(null);
|
|
10
|
+
function o() {
|
|
7
11
|
return typeof window > "u" ? "light" : window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
8
12
|
}
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
let [s, c] = e.useState(a), [l, u] = e.useState(!1), [d, f] = e.useState(i), p = s === "system" ? d : s;
|
|
13
|
+
function s({ children: s, themes: c = r, defaultTheme: l = "system", forcedTheme: u, storageKey: d = n, enableSystem: f = !0, attribute: p = "both", colorSchemes: m = i, disableTransitionOnChange: h = !0, onThemeChange: g }) {
|
|
14
|
+
let _ = e.useMemo(() => Array.from(new Set(c.length ? c : r)), [c]), [v, y] = e.useState(() => {
|
|
15
|
+
if (typeof window > "u") return l;
|
|
16
|
+
let e = window.localStorage.getItem(d);
|
|
17
|
+
return e === "system" && f || e && _.includes(e) ? e : l;
|
|
18
|
+
}), [b, x] = e.useState(!1), [S, C] = e.useState(o), w = e.useRef(void 0), T = u ?? v, E = T === "system" ? _.includes(S) ? S : _[0] ?? "light" : T, D = m[E] ?? i[E] ?? (E === "dark" ? "dark" : "light");
|
|
16
19
|
e.useEffect(() => {
|
|
17
|
-
|
|
20
|
+
x(!0);
|
|
18
21
|
}, []), e.useEffect(() => {
|
|
19
|
-
|
|
22
|
+
if (!f) return;
|
|
23
|
+
let e = window.matchMedia("(prefers-color-scheme: dark)"), t = () => C(e.matches ? "dark" : "light");
|
|
20
24
|
return t(), e.addEventListener("change", t), () => e.removeEventListener("change", t);
|
|
21
|
-
}, []), e.useEffect(() => {
|
|
22
|
-
let e = window.document.documentElement;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}, []), g = e.useMemo(() => ({
|
|
30
|
-
theme: s,
|
|
31
|
-
resolvedTheme: p,
|
|
32
|
-
mounted: l,
|
|
33
|
-
setTheme: m,
|
|
34
|
-
toggleTheme: h
|
|
35
|
-
}), [
|
|
36
|
-
l,
|
|
25
|
+
}, [f]), e.useEffect(() => {
|
|
26
|
+
let e = window.document.documentElement, t;
|
|
27
|
+
if (h) {
|
|
28
|
+
let n = document.createElement("style");
|
|
29
|
+
n.textContent = "*,*::before,*::after{transition:none!important}", document.head.append(n), window.getComputedStyle(e).opacity, t = () => window.setTimeout(() => n.remove(), 0);
|
|
30
|
+
}
|
|
31
|
+
(p === "class" || p === "both") && (w.current && e.classList.remove(w.current), e.classList.remove("light", "dark"), e.classList.add(E), D === "dark" && E !== "dark" && e.classList.add("dark"), w.current = E), (p === "data-theme" || p === "both") && (e.dataset.theme = E), e.style.colorScheme = D, u || window.localStorage.setItem(d, v), g?.(v, E), t?.();
|
|
32
|
+
}, [
|
|
37
33
|
p,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
D,
|
|
35
|
+
h,
|
|
36
|
+
u,
|
|
37
|
+
g,
|
|
38
|
+
E,
|
|
39
|
+
d,
|
|
40
|
+
v
|
|
41
|
+
]);
|
|
42
|
+
let O = e.useCallback((e) => {
|
|
43
|
+
(e === "system" ? f : _.includes(e)) && y(e);
|
|
44
|
+
}, [_, f]), k = e.useCallback(() => {
|
|
45
|
+
let e = [..._, ...f ? ["system"] : []];
|
|
46
|
+
y((t) => e[(e.indexOf(t) + 1) % e.length] ?? _[0] ?? "light");
|
|
47
|
+
}, [_, f]), A = e.useMemo(() => ({
|
|
48
|
+
theme: v,
|
|
49
|
+
resolvedTheme: E,
|
|
50
|
+
systemTheme: S,
|
|
51
|
+
themes: _,
|
|
52
|
+
mounted: b,
|
|
53
|
+
setTheme: O,
|
|
54
|
+
toggleTheme: k
|
|
55
|
+
}), [
|
|
56
|
+
_,
|
|
57
|
+
b,
|
|
58
|
+
E,
|
|
59
|
+
O,
|
|
60
|
+
S,
|
|
61
|
+
v,
|
|
62
|
+
k
|
|
41
63
|
]);
|
|
42
|
-
return /* @__PURE__ */ t(
|
|
43
|
-
value:
|
|
44
|
-
children:
|
|
64
|
+
return /* @__PURE__ */ t(a.Provider, {
|
|
65
|
+
value: A,
|
|
66
|
+
children: s
|
|
45
67
|
});
|
|
46
68
|
}
|
|
47
|
-
function
|
|
48
|
-
let t = e.useContext(
|
|
69
|
+
function c() {
|
|
70
|
+
let t = e.useContext(a);
|
|
49
71
|
if (!t) throw Error("useTheme must be used within ThemeProvider");
|
|
50
72
|
return t;
|
|
51
73
|
}
|
|
52
74
|
//#endregion
|
|
53
|
-
export {
|
|
75
|
+
export { s as ThemeProvider, c as useTheme };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../lib/utils.cjs");let n=require("react");n=e.__toESM(n,1);let r=require("lucide-react"),i=require("class-variance-authority"),a=require("react/jsx-runtime"),o=require("@base-ui/react/merge-props"),s=require("@base-ui/react/use-render");var c=(0,i.cva)(`group/badge inline-flex w-fit shrink-0 items-center justify-center whitespace-nowrap outline-none [&>svg]:pointer-events-none`,{variants:{variant:{default:``,secondary:``,destructive:``,soft:``,outline:``,ghost:``,link:``},tone:{neutral:``,info:``,success:``,warning:``,danger:``,muted:``},size:{sm:``,default:``,lg:``},dot:{true:``,false:``}},defaultVariants:{variant:`default`,tone:`neutral`,size:`default`,dot:!1}});function l({className:e,variant:
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../lib/utils.cjs");let n=require("react");n=e.__toESM(n,1);let r=require("lucide-react"),i=require("class-variance-authority"),a=require("react/jsx-runtime"),o=require("@base-ui/react/merge-props"),s=require("@base-ui/react/use-render");var c=(0,i.cva)(`group/badge inline-flex w-fit shrink-0 items-center justify-center whitespace-nowrap outline-none [&>svg]:pointer-events-none`,{variants:{variant:{default:``,secondary:``,destructive:``,soft:``,outline:``,ghost:``,link:``},tone:{neutral:``,info:``,success:``,warning:``,danger:``,muted:``},size:{sm:``,default:``,lg:``},dot:{true:``,false:``}},defaultVariants:{variant:`default`,tone:`neutral`,size:`default`,dot:!1}});function l({className:e,variant:i=`default`,tone:l=`neutral`,size:u=`default`,dot:d=!1,label:f,count:p,status:m,removable:h=!1,selected:g=!1,onRemove:_,removeLabel:v=`Remove badge`,leftIcon:y,rightIcon:b,avatar:x,showDot:S,dotPosition:C=`start`,pulse:w=!1,interactive:T=!1,children:E,render:D,onKeyDown:O,...k}){let A=m??l,j=f??E,M=S??!!(d||m===`success`||m===`warning`||m===`danger`||m===`info`),N=M?(0,a.jsx)(`span`,{"data-slot":`badge-dot`,"data-pulse":w||void 0,children:n.isValidElement(d)?d:null}):null;return(0,s.useRender)({defaultTagName:`span`,props:(0,o.mergeProps)({className:t.cn(c({variant:i,tone:A,size:u,dot:M}),g&&`ring-2 ring-ring/45 ring-offset-1`,T&&`cursor-pointer`,e),tabIndex:h||T?0:void 0,onKeyDown:e=>{h&&(e.key===`Backspace`||e.key===`Delete`)&&(e.preventDefault(),_?.()),O?.(e)},children:(0,a.jsxs)(a.Fragment,{children:[C===`start`?N:null,x?(0,a.jsx)(`span`,{"data-slot":`badge-avatar`,className:`grid shrink-0 place-items-center overflow-hidden rounded-full`,children:x}):null,y?(0,a.jsx)(`span`,{"data-icon":`inline-start`,"data-slot":`badge-icon`,className:`grid shrink-0 place-items-center`,children:y}):null,j?(0,a.jsx)(`span`,{"data-slot":`badge-label`,children:j}):null,p==null?null:(0,a.jsx)(`span`,{"data-slot":`badge-count`,children:p}),b?(0,a.jsx)(`span`,{"data-icon":`inline-end`,"data-slot":`badge-icon`,className:`grid shrink-0 place-items-center`,children:b}):null,C===`end`?N:null,h?(0,a.jsx)(`button`,{type:`button`,"data-slot":`badge-remove`,"aria-label":v,onClick:e=>{e.preventDefault(),e.stopPropagation(),_?.()},children:(0,a.jsx)(r.XIcon,{"data-icon":`remove`})}):null]})},{"data-variant":i??`default`,"data-tone":A??`neutral`,"data-size":u??`default`,"data-removable":h||void 0,"data-selected":g||void 0,"data-interactive":T||void 0,"data-pulse":w||void 0},k),render:D,state:{slot:`badge`,variant:i,tone:A,size:u,dot:M}})}exports.Badge=l,exports.badgeVariants=c;
|