@tempots/beatui 1.7.5 → 1.9.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/{ar-Wr6gMs-M.cjs → ar-CEzAem0F.cjs} +1 -1
- package/dist/{ar-fdUqbCvM.js → ar-CQieaqsq.js} +1 -1
- package/dist/auth/index.cjs.js +1 -1
- package/dist/auth/index.es.js +1 -1
- package/dist/auth-divider-B8yr-E_b.cjs +1 -0
- package/dist/{auth-divider-D9KnNeyF.js → auth-divider-Byh5BWLc.js} +91 -88
- package/dist/better-auth/index.cjs.js +1 -1
- package/dist/better-auth/index.es.js +27 -26
- package/dist/card-BkA7Wvbh.cjs +1 -0
- package/dist/card-DX1DwGbL.js +62 -0
- package/dist/{colors-C2sgnzFH.js → colors-CyMhfbJi.js} +64 -58
- package/dist/{colors-DPCHjRMj.cjs → colors-IXZF9U-s.cjs} +1 -1
- package/dist/control-hqEuMzyI.js +343 -0
- package/dist/control-muup9GF1.cjs +1 -0
- package/dist/custom-validation-BA9iJWl_.cjs +1 -0
- package/dist/custom-validation-BOBoUwHY.js +181 -0
- package/dist/{de-C5-k5Eov.js → de-CBIwvkAH.js} +1 -1
- package/dist/{de-DZqdSEta.cjs → de-DdfxrlT3.cjs} +1 -1
- package/dist/deep-merge-8fwp1z4X.js +1346 -0
- package/dist/deep-merge-VDGE_HQD.cjs +1 -0
- package/dist/duration-input-DmsljXl3.cjs +1 -0
- package/dist/{duration-input-D4V_PHIg.js → duration-input-ZQlcqdXU.js} +32 -31
- package/dist/{editor-toolbar-group-FpOHrmtx.js → editor-toolbar-group-BNTBMJCe.js} +2 -2
- package/dist/{editor-toolbar-group-C_ft_T8D.cjs → editor-toolbar-group-DiMzqYgz.cjs} +1 -1
- package/dist/{es-h6jmoF4X.js → es--9HaEj2D.js} +1 -1
- package/dist/{es-CJgYfRap.cjs → es-DSdljxFJ.cjs} +1 -1
- package/dist/{fa-BuxK837l.js → fa-1Z-akcW7.js} +1 -1
- package/dist/{fa-BQ5PzwNY.cjs → fa-BolmeWRT.cjs} +1 -1
- package/dist/flyout-CuKFh_T7.js +151 -0
- package/dist/flyout-DC_tKaTG.cjs +1 -0
- package/dist/{fr-Bv3TG44U.cjs → fr-CODgUuoZ.cjs} +1 -1
- package/dist/{fr-BwILQ9G2.js → fr-DhHM9rou.js} +1 -1
- package/dist/{he-yC9Sc7JD.js → he-CBamXbGJ.js} +1 -1
- package/dist/{he-5LbvgMCC.cjs → he-Juw-dr28.cjs} +1 -1
- package/dist/{hi-Da7rcCpP.js → hi-DvvcX-Ra.js} +1 -1
- package/dist/{hi-YWhWcG_L.cjs → hi-R749jeg-.cjs} +1 -1
- package/dist/{index-CvU9E9wd.js → index-BfQaT5Jy.js} +104 -104
- package/dist/{index-XogEKwdt.cjs → index-Dv7nPuwA.cjs} +1 -1
- package/dist/index.cjs.js +4 -4
- package/dist/index.es.js +6713 -9831
- package/dist/{input-container-CyOgiiQD.cjs → input-container-BaWQLWB6.cjs} +1 -1
- package/dist/{input-container-8JFB11xN.js → input-container-DCS5oJ4S.js} +4 -4
- package/dist/{it-BxOIJE45.cjs → it-DT5oRZDH.cjs} +1 -1
- package/dist/{it-Yeklau78.js → it-aV6i8Qxz.js} +1 -1
- package/dist/{ja-Dxj9Q5Yd.js → ja-CuLhGnJX.js} +1 -1
- package/dist/{ja-CNhjK06P.cjs → ja-CwKaCYLB.cjs} +1 -1
- package/dist/json-schema/index.cjs.js +1 -1
- package/dist/json-schema/index.es.js +83 -79
- package/dist/json-schema-display/index.cjs.js +1 -1
- package/dist/json-schema-display/index.es.js +2 -2
- package/dist/json-structure/index.cjs.js +1 -1
- package/dist/json-structure/index.es.js +74 -72
- package/dist/{ko-DgkqcXTs.cjs → ko-Bucro9ID.cjs} +1 -1
- package/dist/{ko-gn_MsegK.js → ko-D-66BsEX.js} +1 -1
- package/dist/lexical/index.cjs.js +1 -1
- package/dist/lexical/index.es.js +5 -5
- package/dist/menu-BFLFKceF.cjs +1 -0
- package/dist/menu-BO6zqyfq.js +220 -0
- package/dist/modal-6Mq3vS5r.js +309 -0
- package/dist/modal-d77-TMc4.cjs +1 -0
- package/dist/{nl-vHNFtXXb.js → nl-CAny6wvm.js} +1 -1
- package/dist/{nl-Dy9lmbBO.cjs → nl-D7vHpehb.cjs} +1 -1
- package/dist/notice-BNGx86Yg.js +110 -0
- package/dist/notice-iF6zBMq9.cjs +1 -0
- package/dist/{oneof-branch-detection-Q_jxvJIA.js → oneof-branch-detection-Bm17RhC2.js} +27 -26
- package/dist/oneof-branch-detection-DZ4MrfBp.cjs +1 -0
- package/dist/openui/index.cjs.js +9 -0
- package/dist/openui/index.es.js +2174 -0
- package/dist/password-input-Bipt7Wsu.cjs +1 -0
- package/dist/password-input-mkRmrEPq.js +105 -0
- package/dist/{pl-BtYbtsmG.cjs → pl-CSiXoOKT.cjs} +1 -1
- package/dist/{pl-C0UdHla0.js → pl-rmZLgQ_V.js} +1 -1
- package/dist/prosemirror/index.cjs.js +1 -1
- package/dist/prosemirror/index.es.js +4 -4
- package/dist/{pt-CtNmqQ1X.cjs → pt-CJT-iq4y.cjs} +1 -1
- package/dist/{pt-DGKtfN0d.js → pt-DHnajqAi.js} +1 -1
- package/dist/{ru-CpXYLt-v.js → ru-C_E8OZNE.js} +1 -1
- package/dist/{ru-BaL_NPRU.cjs → ru-G3sr_ctV.cjs} +1 -1
- package/dist/slider-input-SLguFA0d.cjs +1 -0
- package/dist/slider-input-VYAMm7pE.js +285 -0
- package/dist/stepper-24p16Zsv.cjs +1 -0
- package/dist/stepper-TlzbfYWa.js +3222 -0
- package/dist/tailwind/preset.cjs.js +1 -1
- package/dist/tailwind/preset.es.js +38 -40
- package/dist/tailwind/vite-plugin.cjs.js +14 -12
- package/dist/tailwind/vite-plugin.es.js +317 -246
- package/dist/text-area-BdemKQ_w.cjs +1 -0
- package/dist/text-area-Br83-_PQ.js +431 -0
- package/dist/{text-input-NJypZSnE.js → text-input-ByuxdX8w.js} +5 -5
- package/dist/{text-input-DS5zlXb2.cjs → text-input-MjlUC_9u.cjs} +1 -1
- package/dist/{toolbar-BF2L6WKC.js → toolbar-CEBTTjHh.js} +1 -1
- package/dist/{toolbar-BBwfe8U9.cjs → toolbar-DWawYFFX.cjs} +1 -1
- package/dist/{tr-DwOd87oB.cjs → tr-DcxLHHTC.cjs} +1 -1
- package/dist/{tr-DIFZDFW_.js → tr-bVXwloKC.js} +1 -1
- package/dist/{translations-EwEmHe3v.cjs → translations-D3xqZUTA.cjs} +1 -1
- package/dist/{translations-BCMP-h52.js → translations-DU9wTV1y.js} +20 -19
- package/dist/{translations-5cXBrENb.js → translations-RT_UN8ny.js} +1 -1
- package/dist/{translations-BqWc0ZHz.cjs → translations-qljG2Chq.cjs} +1 -1
- package/dist/types/components/navigation/stepper.d.ts +4 -4
- package/dist/types/openui/index.d.ts +28 -0
- package/dist/types/openui/library/define-component.d.ts +15 -0
- package/dist/types/openui/library/library.d.ts +7 -0
- package/dist/types/openui/library/prompt-generator.d.ts +5 -0
- package/dist/types/openui/library/types.d.ts +33 -0
- package/dist/types/openui/parser/parser.d.ts +8 -0
- package/dist/types/openui/parser/streaming-parser.d.ts +14 -0
- package/dist/types/openui/parser/tokenizer.d.ts +9 -0
- package/dist/types/openui/parser/types.d.ts +46 -0
- package/dist/types/openui/registry/button.d.ts +148 -0
- package/dist/types/openui/registry/data.d.ts +177 -0
- package/dist/types/openui/registry/form.d.ts +65 -0
- package/dist/types/openui/registry/format.d.ts +67 -0
- package/dist/types/openui/registry/index.d.ts +9 -0
- package/dist/types/openui/registry/layout.d.ts +45 -0
- package/dist/types/openui/registry/navigation.d.ts +149 -0
- package/dist/types/openui/registry/overlay.d.ts +56 -0
- package/dist/types/openui/registry/typography.d.ts +17 -0
- package/dist/types/openui/renderer/action-context.d.ts +24 -0
- package/dist/types/openui/renderer/node-resolver.d.ts +9 -0
- package/dist/types/openui/renderer/openui-renderer.d.ts +32 -0
- package/dist/types/openui/renderer/skeleton.d.ts +2 -0
- package/dist/types/openui/streaming/from-fetch.d.ts +7 -0
- package/dist/types/openui/streaming/from-sse.d.ts +7 -0
- package/dist/types/openui/streaming/from-websocket.d.ts +10 -0
- package/dist/types/openui/streaming/types.d.ts +5 -0
- package/dist/types/tailwind/preset.d.ts +25 -4
- package/dist/types/tailwind/vite-plugin.d.ts +17 -5
- package/dist/types/tokens/colors.d.ts +87 -9
- package/dist/types/tokens/index.d.ts +7 -6
- package/dist/{ur-DBst-TXc.js → ur-Dls2qb4V.js} +1 -1
- package/dist/{ur-D9nLchps.cjs → ur-IRQoHh1E.cjs} +1 -1
- package/dist/use-form-BZ8vDYOv.cjs +2 -0
- package/dist/use-form-DsCzINfm.js +750 -0
- package/dist/utils-D3-NApSw.cjs +1 -0
- package/dist/utils-Nbh7yQ73.js +105 -0
- package/dist/{vi-Dg1aiMr5.cjs → vi-Bi9SvVCP.cjs} +1 -1
- package/dist/{vi-DQOJp32U.js → vi-C3mTzj50.js} +1 -1
- package/dist/widget-customization-BV6XB2v_.cjs +1 -0
- package/dist/widget-customization-Bso45ONQ.js +1198 -0
- package/dist/{zh-DPK4HXl2.js → zh-B4JRJBt2.js} +1 -1
- package/dist/{zh-tbwSTbmn.cjs → zh-BMU5rYu1.cjs} +1 -1
- package/package.json +31 -20
- package/dist/auth-divider-CjcrgXmq.cjs +0 -1
- package/dist/custom-validation-7por5nJN.js +0 -488
- package/dist/custom-validation-CLscGHY4.cjs +0 -1
- package/dist/deep-merge-D90SW1Ci.cjs +0 -1
- package/dist/deep-merge-DT2H9AGq.js +0 -1765
- package/dist/duration-input-4AQnQpyo.cjs +0 -1
- package/dist/menu-B60Q9j3-.cjs +0 -1
- package/dist/menu-BkqFGcXg.js +0 -366
- package/dist/notice-CQGJyZ8o.js +0 -211
- package/dist/notice-p2IqXS5-.cjs +0 -1
- package/dist/oneof-branch-detection-xDDDdYRk.cjs +0 -1
- package/dist/use-form-8NnZ-KHk.js +0 -1090
- package/dist/use-form-Dcra7GeE.cjs +0 -2
- package/dist/utils-DmEuG3Np.cjs +0 -1
- package/dist/utils-vUtP6iPG.js +0 -165
- package/dist/widget-customization-BIBva3f-.js +0 -1458
- package/dist/widget-customization-pqmtsraC.cjs +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=require("@lexical/rich-text"),F=require("@lexical/list"),G=require("@lexical/table"),ee=require("@lexical/link"),ie=require("@lexical/code"),Re=require("@lexical/hashtag"),ne=require("@lexical/mark"),dt=require("@lexical/overflow"),n=require("lexical"),ft=require("@lexical/plain-text"),Fe=require("@lexical/history");require("@lexical/clipboard");const Ae=require("@lexical/markdown"),Be=require("@lexical/html"),B=require("@lexical/selection"),gt=require("@lexical/text"),ge=require("@lexical/utils"),mt=require("@lexical/offset"),pt=require("@lexical/dragon");require("@lexical/file");const ht=require("@lexical/yjs");require("@lexical/headless");const e=require("@tempots/dom"),Le=require("../link-portal-_tiDFZqh.cjs"),Ie=require("../theme-DogY9oT1.cjs"),J=require("../menu-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=require("@lexical/rich-text"),F=require("@lexical/list"),G=require("@lexical/table"),ee=require("@lexical/link"),ie=require("@lexical/code"),Re=require("@lexical/hashtag"),ne=require("@lexical/mark"),dt=require("@lexical/overflow"),n=require("lexical"),ft=require("@lexical/plain-text"),Fe=require("@lexical/history");require("@lexical/clipboard");const Ae=require("@lexical/markdown"),Be=require("@lexical/html"),B=require("@lexical/selection"),gt=require("@lexical/text"),ge=require("@lexical/utils"),mt=require("@lexical/offset"),pt=require("@lexical/dragon");require("@lexical/file");const ht=require("@lexical/yjs");require("@lexical/headless");const e=require("@tempots/dom"),Le=require("../link-portal-_tiDFZqh.cjs"),Ie=require("../theme-DogY9oT1.cjs"),J=require("../menu-BFLFKceF.cjs"),q=require("../translations-D3xqZUTA.cjs"),ve=require("../editor-toolbar-group-DiMzqYgz.cjs"),bt=require("@tempots/std"),je=require("../toolbar-DWawYFFX.cjs"),Ct=require("../input-container-BaWQLWB6.cjs");function ae(t){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const s=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(o,a,s.get?s:{enumerable:!0,get:()=>t[a]})}}return o.default=t,Object.freeze(o)}const fe=ae(G),re=ae(ie),yt=ae(n),Et=ae(mt),ke=ae(pt),Ot={separator:!0};class oe extends n.DecoratorNode{static getType(){return"horizontal-rule"}static clone(o){return new oe(o.__key)}static importJSON(o){return se()}static importDOM(){return{hr:()=>({conversion:Tt,priority:0})}}exportJSON(){return{...super.exportJSON(),type:"horizontal-rule",version:1}}exportDOM(){return{element:document.createElement("hr")}}createDOM(){return document.createElement("hr")}updateDOM(){return!1}getTextContent(){return`
|
|
2
2
|
`}isInline(){return!1}decorate(){return null}}function Tt(){return{node:se()}}function se(){return n.$applyNodeReplacement(new oe)}function Ue(t){return t instanceof oe}function me(t){const o=[j.HeadingNode,j.QuoteNode,F.ListNode,F.ListItemNode,ee.LinkNode,ie.CodeNode,ie.CodeHighlightNode,oe];return t.table&&o.push(G.TableNode,G.TableCellNode,G.TableRowNode),t.autoLink&&o.push(ee.AutoLinkNode),t.hashtag&&o.push(Re.HashtagNode),t.mark&&o.push(ne.MarkNode),t.overflow&&o.push(dt.OverflowNode),[...new Set(o)]}function pe(t){switch(t){case"bare":return{richText:!0,history:!0,clipboard:!0};case"docked":return{richText:!0,history:!0,clipboard:!0,list:!0,link:!0,autoLink:!0,code:!0,table:!0};case"contextual":return{richText:!0,history:!0,clipboard:!0,list:!0,link:!0,autoLink:!0,code:!0,table:!0}}}async function ze(){return yt}async function he(t){return j.registerRichText(t)}async function be(t){return ft.registerPlainText(t)}async function Ce(t,o){const a=Fe.createEmptyHistoryState(),s=o?.delay??300;return Fe.registerHistory(t,a,s)}async function ye(t){return()=>{}}async function Ee(t){return typeof F.registerList=="function"?typeof F.registerCheckList=="function"?ge.mergeRegister(F.registerList(t),F.registerCheckList(t)):F.registerList(t):ge.mergeRegister(t.registerCommand(F.INSERT_ORDERED_LIST_COMMAND,()=>(F.insertList(t,"number"),!0),n.COMMAND_PRIORITY_LOW),t.registerCommand(F.INSERT_UNORDERED_LIST_COMMAND,()=>(F.insertList(t,"bullet"),!0),n.COMMAND_PRIORITY_LOW),t.registerCommand(F.INSERT_CHECK_LIST_COMMAND,()=>(F.insertList(t,"check"),!0),n.COMMAND_PRIORITY_LOW),t.registerCommand(F.REMOVE_LIST_COMMAND,()=>(F.removeList(t),!0),n.COMMAND_PRIORITY_LOW))}async function Oe(t){return t.registerCommand(ee.TOGGLE_LINK_COMMAND,o=>(o===null||typeof o=="string"?ee.toggleLink(o):ee.toggleLink(o.url,o),!0),n.COMMAND_PRIORITY_LOW)}async function Nt(t,o,a){const s=o?.trigger||"/";let i=!1,u=null,h=0;const O=()=>t.getEditorState().read(()=>{const y=n.$getSelection();if(!n.$isRangeSelection(y)||!y.isCollapsed())return!1;const E=y.anchor,M=E.getNode();if(!n.$isTextNode(M))return!1;const _=M.getTextContent(),I=E.offset;if(I===0||_[I-1]!==s)return!1;if(I===1)return!0;const C=_[I-2];return!!/\s/.test(C)}),A=()=>u?t.getEditorState().read(()=>{if(!u)return"";const y=u.getTextContent(),E=y.indexOf(s,h);if(E===-1)return"";const M=n.$getSelection();if(!n.$isRangeSelection(M))return"";const _=M.anchor;if(_.getNode().getKey()!==u.getKey())return"";const N=_.offset;return N<=E?"":y.slice(E+1,N)}):"",R=()=>{t.getEditorState().read(()=>{const y=n.$getSelection();if(n.$isRangeSelection(y)){const E=y.anchor,M=E.getNode();if(n.$isTextNode(M)){u=M,h=E.offset-1,i=!0;const _={isActive:!0,filterText:"",anchorNode:u,anchorOffset:h};a?.onTrigger?.(_,k),a?.onUpdate?.(_,k)}}})},b=()=>{i&&(i=!1,u=null,h=0,a?.onClose?.())},k=()=>{u&&t.update(()=>{if(!u)return;const y=u.getTextContent(),E=y.indexOf(s,h);if(E===-1)return;const M=n.$getSelection();if(!n.$isRangeSelection(M))return;const _=M.anchor;if(_.getNode().getKey()!==u.getKey())return;const N=_.offset,C=y.slice(0,E),v=y.slice(N);u.setTextContent(C+v);const c=n.$getSelection();n.$isRangeSelection(c)&&(c.anchor.set(u.getKey(),E,"text"),c.focus.set(u.getKey(),E,"text"))})},S=()=>{if(!i)return;const E={isActive:!0,filterText:A(),anchorNode:u,anchorOffset:h};a?.onUpdate?.(E,k)},m=t.registerMutationListener(n.TextNode,y=>{if(!i&&O()){R();return}i&&(u&&!y.has(u.getKey())?S():b())}),T=ge.mergeRegister(t.registerUpdateListener(({editorState:y})=>{y.read(()=>{if(!i)return;const E=n.$getSelection();if(!n.$isRangeSelection(E)){b();return}const M=E.anchor,_=M.getNode();if(!u||_.getKey()!==u.getKey()){b();return}const N=u.getTextContent().indexOf(s,h);if(N===-1||M.offset<=N){b();return}})}),t.registerCommand(n.KEY_ARROW_DOWN_COMMAND,y=>i?(y.preventDefault(),!0):!1,n.COMMAND_PRIORITY_LOW),t.registerCommand(n.KEY_ARROW_UP_COMMAND,y=>i?(y.preventDefault(),!0):!1,n.COMMAND_PRIORITY_LOW),t.registerCommand(n.KEY_ENTER_COMMAND,y=>i?(y?.preventDefault(),!0):!1,n.COMMAND_PRIORITY_LOW),t.registerCommand(n.KEY_ESCAPE_COMMAND,y=>i?(y?.preventDefault(),b(),!0):!1,n.COMMAND_PRIORITY_LOW));return()=>{b(),m(),T()}}function St(t,o,a){a(),o.handler(t),t.focus()}const Mt=n.createCommand("TOGGLE_SLASH_COMMAND_PALETTE"),ce=n.createCommand("INSERT_HORIZONTAL_RULE_COMMAND"),xt=n.createCommand("INSERT_IMAGE_COMMAND");function Te(t){return t.registerCommand(ce,()=>{const o=n.$getSelection();if(!n.$isRangeSelection(o))return!1;if(o.focus.getNode()!==null){const s=se();o.insertNodes([s]);const i=n.$createParagraphNode();s.insertAfter(i),i.selectStart()}return!0},n.COMMAND_PRIORITY_LOW)}const Ge={dependencies:[oe],export:t=>Ue(t)?"---":null,regExp:/^(---|\*\*\*|___)\s?$/,replace:(t,o,a,s)=>{const i=se();if(s)t.replace(i);else{t.replace(i);const u=n.$createParagraphNode();i.insertAfter(u),u.selectStart()}},type:"element"},De=[...Ae.TRANSFORMERS,Ge];async function K(t){let o="";return t.getEditorState().read(()=>{o=Ae.$convertToMarkdownString(De)}),o}async function V(t,o){t.update(()=>{Ae.$convertFromMarkdownString(o,De)})}async function kt(){return De}async function Y(t){let o="";return t.getEditorState().read(()=>{o=Be.$generateHtmlFromNodes(t)}),o}async function X(t,o){t.update(()=>{const s=new DOMParser().parseFromString(o,"text/html"),i=Be.$generateNodesFromDOM(t,s);n.$getRoot().clear(),n.$insertNodes(i)})}async function _t(t,o,a){let s,i,u;switch(o){case"markdown":s=await K(t),i="text/markdown",u="md";break;case"html":s=await Y(t),i="text/html",u="html";break;case"json":s=JSON.stringify(t.getEditorState().toJSON(),null,2),i="application/json",u="json";break}const h=new Blob([s],{type:i}),O=URL.createObjectURL(h),A=document.createElement("a");A.href=O,A.download=a??`document.${u}`,A.click(),URL.revokeObjectURL(O)}async function vt(t,o,a){const s=await new Promise((u,h)=>{const O=new FileReader;O.onload=()=>u(O.result),O.onerror=()=>h(O.error),O.readAsText(o)});switch(a??Rt(o.name)){case"markdown":{await V(t,s);break}case"html":{await X(t,s);break}case"json":{const u=t.parseEditorState(s);t.setEditorState(u);break}}}function Rt(t){return t.endsWith(".md")||t.endsWith(".markdown")?"markdown":t.endsWith(".html")||t.endsWith(".htm")?"html":"json"}async function Ne(t,o){return"registerTablePlugin"in fe&&typeof fe.registerTablePlugin=="function"?fe.registerTablePlugin(t):()=>{}}async function At(t,o=3,a=3){t.dispatchCommand(fe.INSERT_TABLE_COMMAND,{rows:String(o),columns:String(a),includeHeaders:!0})}async function Lt(t,o){return"registerCodeHighlighting"in re&&typeof re.registerCodeHighlighting=="function"?re.registerCodeHighlighting(t):()=>{}}async function It(t,o){return"registerCodeHighlighting"in re&&typeof re.registerCodeHighlighting=="function"?re.registerCodeHighlighting(t):()=>{}}const Dt=/#[\w\u0590-\u05ff]+/;function wt(t){return new Re.HashtagNode(t)}async function $t(t,o){const a=[],s=gt.registerLexicalTextEntity(t,i=>{const u=Dt.exec(i);return u?{start:u.index,end:u.index+u[0].length}:null},Re.HashtagNode,wt);if(Array.isArray(s)?a.push(...s):typeof s=="function"&&a.push(s),o?.onHashtagClick){const i=t.registerCommand(n.CLICK_COMMAND,u=>{const h=u.target;if(h.classList.contains("bc-lexical-hashtag")){const O=h.textContent;if(O)return o.onHashtagClick(O.replace("#","")),!0}return!1},n.COMMAND_PRIORITY_LOW);a.push(i)}return()=>{a.forEach(i=>i())}}const Pt=/((https?:\/\/(www\.)?|www\.)[^\s<>]+)/g,Ht=/([a-zA-Z0-9._+-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)/g,Ft=[{pattern:Pt,urlTransformer:t=>t.startsWith("http")?t:`https://${t}`},{pattern:Ht,urlTransformer:t=>`mailto:${t}`}];async function Bt(t,o){const a=o?.matchers??Ft;return t.registerMutationListener(n.TextNode,s=>{t.update(()=>{for(const[i,u]of s){if(u!=="created"&&u!=="updated")continue;const h=n.$getNodeByKey(i);if(!h||!n.$isTextNode(h))continue;const O=h.getTextContent();for(const A of a){const R=new RegExp(A.pattern.source,A.pattern.flags);let b;for(;(b=R.exec(O))!==null;)A.urlTransformer(b[0])}}})})}async function jt(t,o){const a=[];return o?.onMarkClick&&a.push(t.registerCommand(n.CLICK_COMMAND,s=>{const i=s.target;if(i.classList.contains("bc-lexical-mark")){const u=i.dataset.markId;if(u)return o.onMarkClick(u,{id:u,type:i.dataset.markType||"annotation",data:{}}),!0}return!1},n.COMMAND_PRIORITY_LOW)),()=>a.forEach(s=>s())}async function Ut(t,o,a){t.update(()=>{const s=n.$getSelection();n.$isRangeSelection(s)&&ne.$wrapSelectionInMarkNode(s,s.isBackward(),o)})}async function zt(t,o){t.update(()=>{const s=n.$getRoot().getAllTextNodes().filter(i=>{const u=i.getParent();return ne.$isMarkNode(u)?ne.$getMarkIDs(i,0)?.includes(o)??!1:!1});for(const i of s){const u=i.getParent();ne.$isMarkNode(u)&&ne.$unwrapMarkNode(u)}})}async function Gt(t,o){const{maxLength:a,onOverflow:s}=o;return t.registerUpdateListener(({editorState:i})=>{i.read(()=>{const O=n.$getRoot().getTextContent().length,A=O>a;s&&s(A,O)})})}async function Se(t){return"registerDragonSupport"in ke&&typeof ke.registerDragonSupport=="function"?ke.registerDragonSupport(t):()=>{}}async function Me(t,o){const a=o.docMap??new Map,s=o.id??"lexical",i=o.doc.getText(s),u=ht.createBinding(t,o.provider,i,o.doc,a),h=t.registerUpdateListener(()=>{});return()=>{h(),u&&typeof u.destroy=="function"&&u.destroy()}}function qt(t){let o={hasSelection:!1,selectedText:"",anchorOffset:0,focusOffset:0};return t.getEditorState().read(()=>{const a=n.$getSelection();n.$isRangeSelection(a)&&(o={hasSelection:!a.isCollapsed(),selectedText:a.getTextContent(),anchorOffset:a.anchor.offset,focusOffset:a.focus.offset})}),o}function we(t){let o="";return t.getEditorState().read(()=>{o=n.$getRoot().getTextContent()}),o}function Wt(t){return we(t).length}function Kt(t){const o=we(t).trim();return o?o.split(/\s+/).length:0}function Yt(t,o){t.update(()=>{const a=n.$getSelection();n.$isRangeSelection(a)&&a.insertText(o)}),t.focus()}async function Jt(){return Et}function le(t,o,a){const s=new Map;if(t)for(const i of t.split(";")){const u=i.trim();if(!u)continue;const h=u.indexOf(":");if(h===-1)continue;const O=u.slice(0,h).trim(),A=u.slice(h+1).trim();s.set(O,A)}return a?s.set(o,a):s.delete(o),s.size===0?"":Array.from(s.entries()).map(([i,u])=>`${i}: ${u}`).join("; ")}function te(t,o){if(!t)return"";const a=new RegExp(`(?:^|;)\\s*${o.replace(/-/g,"\\-")}:\\s*([^;]+)`),s=t.match(a);return s?s[1].trim():""}function Vt(t,o){const a=t.getElementByKey(o);a&&t.getEditorState().read(()=>{const s=n.$getNodeByKey(o);if(!n.$isElementNode(s)||n.$isRootNode(s))return;const i=s.getStyle(),u=te(i,"background-color");a.style.backgroundColor=u||"";const h=te(i,"line-height");a.style.lineHeight=h||""})}function $e(t){const o=t.registerUpdateListener(({dirtyElements:a})=>{if(a.size!==0)for(const[s]of a)Vt(t,s)});return t.getEditorState().read(()=>{const a=n.$getRoot();for(const s of a.getChildren())if(n.$isElementNode(s)){const i=s.getStyle();if(i){const u=t.getElementByKey(s.getKey());if(u){const h=te(i,"background-color");h&&(u.style.backgroundColor=h);const O=te(i,"line-height");O&&(u.style.lineHeight=O)}}}}),o}function _e(t,o){const a=o.exportDOM(t);if(a.element&&ge.isHTMLElement(a.element)&&n.$isElementNode(o)){const s=o.getStyle(),i=te(s,"background-color");i&&(a.element.style.backgroundColor=i);const u=te(s,"line-height");u&&(a.element.style.lineHeight=u)}return a}function xe(){const t=new Map;return t.set(n.ParagraphNode,_e),t.set(j.HeadingNode,_e),t.set(j.QuoteNode,_e),t}function Xt(){const t=o=>()=>({conversion:a=>{const s=o(a);if(s&&n.$isElementNode(s)){a.style?.textAlign&&s.setFormat(a.style.textAlign);let i="";a.style?.backgroundColor&&(i=le(i,"background-color",a.style.backgroundColor)),a.style?.lineHeight&&(i=le(i,"line-height",a.style.lineHeight)),i&&s.setStyle(i)}return{node:s}},priority:1});return{p:t(()=>n.$createParagraphNode()),h1:t(()=>j.$createHeadingNode("h1")),h2:t(()=>j.$createHeadingNode("h2")),h3:t(()=>j.$createHeadingNode("h3")),h4:t(()=>j.$createHeadingNode("h4")),h5:t(()=>j.$createHeadingNode("h5")),h6:t(()=>j.$createHeadingNode("h6"))}}const qe=["color","font-size","font-family","background-color","line-height"],Zt=new Set(["font-weight","font-style","text-decoration","text-decoration-line","vertical-align"]),Qt={code:"code",em:"italic",i:"italic",mark:"highlight",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"},eo=["span","b","em","i","strong","u","s","sub","sup","code","mark"];function to(t,o,a){if(!n.$isTextNode(o))return;const s=t.fontWeight,i=t.textDecoration.split(" ");(s==="700"||s==="bold")&&!o.hasFormat("bold")&&o.toggleFormat("bold"),t.fontStyle==="italic"&&!o.hasFormat("italic")&&o.toggleFormat("italic"),i.includes("line-through")&&!o.hasFormat("strikethrough")&&o.toggleFormat("strikethrough"),i.includes("underline")&&!o.hasFormat("underline")&&o.toggleFormat("underline"),t.verticalAlign==="sub"&&!o.hasFormat("subscript")&&o.toggleFormat("subscript"),t.verticalAlign==="super"&&!o.hasFormat("superscript")&&o.toggleFormat("superscript"),a&&!o.hasFormat(a)&&o.toggleFormat(a)}function We(t=qe){const o={};for(const a of eo)o[a]=s=>{const i=s.style,u=Qt[a],h=a==="b"?i.fontWeight!=="normal"?"bold":void 0:u;return{conversion:()=>({node:null,forChild:O=>{if(!n.$isTextNode(O))return O;to(i,O,h);let A=O.getStyle();for(const R of t){if(Zt.has(R))continue;const b=i.getPropertyValue(R);b&&(A=le(A,R,b))}return A&&O.setStyle(A),O}}),priority:1}};return o}function ue(t){return{...Xt(),...We(t)}}async function de(t={}){const{nodes:o=[],plugins:a=[],onError:s}=t,u=(await ze()).createEditor({namespace:"BeatUIHeadless",nodes:o,onError:h=>{s?s(h,u):console.error("[BeatUI Headless]",h)},editable:!1,html:{export:xe(),import:ue()}});if(a.length>0)for(const h of a)h.register(u);return u}async function oo(t){const o=await de();return await V(o,t),o.getEditorState().toJSON()}async function no(t){const o=await de(),a=o.parseEditorState(JSON.stringify(t));return o.setEditorState(a),await K(o)}async function ro(t){const o=await de();return await X(o,t),o.getEditorState().toJSON()}async function io(t){const o=await de(),a=o.parseEditorState(JSON.stringify(t));return o.setEditorState(a),await Y(o)}const Ke=t=>{const{value:o,format:a,plugins:s,readOnly:i,placeholder:u,class:h,namespace:O="BeatUILexical",heightMode:A="auto",autoFocus:R=!1,onError:b,onInput:k,onChange:S,onBlur:m,onReady:T}=t;return e.Use(Ie.Theme,({appearance:y})=>e.html.div(e.Task(()=>Promise.resolve().then(()=>require("../styles-url-CkPTI32j.cjs")),({default:E})=>Le.LinkPortal({id:"beatui-lexical-css",href:E})),e.attr.class("bc-lexical-editor-container"),A==="fixed"?e.attr.class("bc-lexical-editor-container--fixed"):null,e.attr.class(h),e.html.div(e.attr.class("bc-lexical-editor"),e.attr.class(`bc-lexical-editor--${A}`),e.attr.contenteditable(i!=null?e.Value.map(i,E=>!E):!0),i!=null?e.attr.class(e.Value.map(i,E=>E?"bc-lexical-editor--readonly":"")):null,e.WithElement(E=>{let M=null;const _=[];return(async()=>{try{const N=s??pe("bare"),C=me(N),v=e.Value.get(a??"markdown"),c=n.createEditor({namespace:O,nodes:C,theme:{heading:{h1:"bc-lexical-h1",h2:"bc-lexical-h2",h3:"bc-lexical-h3",h4:"bc-lexical-h4",h5:"bc-lexical-h5",h6:"bc-lexical-h6"},text:{bold:"bc-lexical-bold",italic:"bc-lexical-italic",underline:"bc-lexical-underline",strikethrough:"bc-lexical-strikethrough",code:"bc-lexical-code"},list:{ul:"bc-lexical-ul",ol:"bc-lexical-ol",listitem:"bc-lexical-li",listitemChecked:"bc-lexical-li-checked",listitemUnchecked:"bc-lexical-li-unchecked"},link:"bc-lexical-link",quote:"bc-lexical-blockquote",code:"bc-lexical-code-block",codeHighlight:{},hashtag:"bc-lexical-hashtag",table:"bc-lexical-table",tableCell:"bc-lexical-table-cell",tableCellHeader:"bc-lexical-table-cell-header",tableRow:"bc-lexical-table-row",mark:"bc-lexical-mark",paragraph:"bc-lexical-paragraph"},onError:f=>{b?b(f,c):console.error("[BeatUI Lexical]",f)},editable:i?!e.Value.get(i):!0,html:{export:xe(),import:ue()}});M=c,c.setRootElement(E);const D=[];if(N.richText?D.push(he(c)):N.plainText&&D.push(be(c)),N.history){const f=typeof N.history=="object"?N.history:void 0;D.push(Ce(c,f))}if(N.clipboard&&D.push(ye(c)),N.list&&D.push(Ee(c)),N.link&&D.push(Oe(c)),N.yjs&&D.push(Me(c,N.yjs)),N.dragon&&D.push(Se(c)),N.table&&D.push(Ne(c)),(await Promise.all(D)).forEach(f=>{f&&_.push(f)}),_.push(Te(c)),_.push($e(c)),o!=null){const f=e.Value.get(o);if(f!=null&&(f!==""||v==="json"&&typeof f=="object")){if(v==="markdown"&&typeof f=="string")await V(c,f);else if(v==="html"&&typeof f=="string")await X(c,f);else if(v==="json"&&typeof f=="object")try{const l=JSON.stringify(f),L=c.parseEditorState(l);c.setEditorState(L)}catch(l){console.error("[BeatUI] Failed to parse JSON editor state:",l),b&&b(l instanceof Error?l:new Error(String(l)),c)}}}if(_.push(c.registerUpdateListener(({editorState:f,dirtyElements:d,dirtyLeaves:l})=>{d.size===0&&l.size===0||k&&f.read(async()=>{if(v==="markdown"){const L=await K(c);k(L,c)}else if(v==="html"){const L=await Y(c);k(L,c)}else v==="json"&&k(f.toJSON(),c)})})),o!=null&&_.push(e.Value.on(o,async f=>{if(f!=null){if(v==="markdown"&&typeof f=="string"){const d=await K(c);f!==d&&await V(c,f)}else if(v==="html"&&typeof f=="string"){const d=await Y(c);f!==d&&await X(c,f)}else if(v==="json"&&typeof f=="object"){const d=JSON.stringify(c.getEditorState().toJSON()),l=JSON.stringify(f);if(d!==l){const L=c.parseEditorState(l);c.setEditorState(L)}}}})),i!=null&&_.push(e.Value.on(i,f=>{c.setEditable(!f)})),_.push(c.registerCommand(n.BLUR_COMMAND,()=>(m&&m(c),S&&c.getEditorState().read(async()=>{if(v==="markdown"){const f=await K(c);S(f,c)}else if(v==="html"){const f=await Y(c);S(f,c)}else v==="json"&&S(c.getEditorState().toJSON(),c)}),!1),n.COMMAND_PRIORITY_LOW)),_.push(y.on(f=>{const d=c.getRootElement();d&&(d.dataset.theme=f)})),R)c.focus();else{const f=c.getRootElement();f&&f===document.activeElement&&f.blur()}T&&T(c)}catch(N){console.error("[BeatUI] Failed to initialize Lexical editor:",N);const C=E;C.textContent="Failed to load Lexical editor."}})(),e.OnDispose(()=>{try{_.forEach(N=>N())}catch{}try{M?.setRootElement(null)}catch{}})}))))};function Ye(t,o,a){const s=(m,T)=>o.map(()=>{const y=t.value;return y?y.getEditorState().read(()=>{const E=n.$getSelection();return n.$isRangeSelection(E)?m(E):T}):T}),i=m=>{const T=m.anchor.getNode();return T.getKey()==="root"?T:T.getTopLevelElementOrThrow()};return{withSelection:s,getAnchorElement:i,textFormatActive:m=>s(T=>T.hasFormat(m),!1),blockTypeActive:m=>s(T=>i(T).getType()===m,!1),listTypeActive:m=>s(T=>{const y=i(T).getParent();return F.$isListNode(y)&&y.getListType()===m},!1),headingActive:m=>o.map(()=>{const T=t.value;return T?T.getEditorState().read(()=>{const y=n.$getSelection();if(n.$isRangeSelection(y)){const E=i(y);if(E.getType()==="heading")return T.getElementByKey(E.getKey())?.tagName===`H${m}`}return!1}):!1}),linkActive:()=>s(m=>{const T=m.anchor.getNode();return T.getParent()?.getType()==="link"||T.getType()==="link"},!1),dispatch:(m,T)=>()=>{const y=t.value;y&&(y.dispatchCommand(m,T),y.focus())},toggleBlock:(m,T)=>()=>{const y=t.value;y&&(y.update(()=>{const E=n.$getSelection();if(n.$isRangeSelection(E)){const M=i(E);B.$setBlocksType(E,()=>M.getType()===m?n.$createParagraphNode():T())}}),y.focus())},toggleLink:()=>{const m=t.value;m&&(m.getEditorState().read(()=>{const T=n.$getSelection();if(n.$isRangeSelection(T)){const y=T.anchor.getNode();if(y.getParent()?.getType()==="link"||y.getType()==="link")m.dispatchCommand(ee.TOGGLE_LINK_COMMAND,null);else{const _=prompt(a?.enterUrlMessage?.()??"Enter URL:");_&&m.dispatchCommand(ee.TOGGLE_LINK_COMMAND,_)}}}),m.focus())}}}function Je(t,o){return a=>s=>ve.EditorToolbarButton({...s,display:a,disabled:t,size:o})}const lo={font:["font-family","font-size","line-height"],color:["font-color","highlight-color","background-color"],"text-formatting":["bold","italic","underline","strikethrough","code"],"clear-formatting":["clear-formatting"],headings:["paragraph","heading-1","heading-2","heading-3","heading-4","heading-5","heading-6"],lists:["bullet-list","ordered-list","check-list"],indent:["indent","outdent"],blocks:["blockquote","code-block","horizontal-rule"],tables:["insert-table"],links:["link"],history:["undo","redo"],clipboard:["cut","copy","paste"]},ao=["font","color","text-formatting","clear-formatting","headings","lists","indent","blocks","tables","links","history","clipboard"];function so(){return ao.map(t=>({group:t}))}function co(t){if(t.layout)return t.layout;const{visibleGroups:o,hiddenGroups:a,customGroups:s}=t;let i=so();if((o||a)&&(i=i.filter(u=>{if("separator"in u||"customGroup"in u)return!0;const h=u.group;return!(a?.includes(h)||o&&!o.includes(h))})),s&&s.length>0)for(const u of s)i.push({customGroup:u.id});return i}const uo=[{value:"Arial",label:"Arial"},{value:"Courier New",label:"Courier New"},{value:"Georgia",label:"Georgia"},{value:"Times New Roman",label:"Times New Roman"},{value:"Trebuchet MS",label:"Trebuchet MS"},{value:"Verdana",label:"Verdana"}],fo=[{value:"10px",label:"10"},{value:"12px",label:"12"},{value:"14px",label:"14"},{value:"16px",label:"16"},{value:"18px",label:"18"},{value:"20px",label:"20"},{value:"24px",label:"24"},{value:"30px",label:"30"},{value:"36px",label:"36"}],go=[{value:"1",label:"1"},{value:"1.15",label:"1.15"},{value:"1.5",label:"1.5"},{value:"2",label:"2"},{value:"2.5",label:"2.5"},{value:"3",label:"3"}];function Ve({editor:t,stateUpdate:o,toolbar:a={},readOnly:s=e.signal(!1),size:i="sm"}){const{maxHeadingLevel:u=3}=a,h=co(a);return e.Use(q.BeatUII18n,O=>e.Ensure(t,A=>{const R=A,b=O.$.lexical,{getAnchorElement:k,textFormatActive:S,blockTypeActive:m,listTypeActive:T,headingActive:y,linkActive:E,dispatch:M,toggleBlock:_,toggleLink:I}=Ye(R,o,{enterUrlMessage:()=>O.value.lexical.enterUrl}),C=Je(s,i)(e.signal(!0)),v=()=>{const r=R.value;r&&(r.update(()=>{const p=n.$getSelection();n.$isRangeSelection(p)&&B.$setBlocksType(p,()=>n.$createParagraphNode())}),r.focus())},c=r=>{const p=R.value;p&&(p.update(()=>{const w=n.$getSelection();if(n.$isRangeSelection(w)){const z=k(w),Z=`h${r}`,Q=p.getElementByKey(z.getKey());z.getType()==="heading"&&Q?.tagName===`H${r}`?B.$setBlocksType(w,()=>n.$createParagraphNode()):B.$setBlocksType(w,()=>j.$createHeadingNode(Z))}}),p.focus())},D=()=>{const r=R.value;if(!r)return;const p=r.getRootElement();p&&(p.focus(),document.execCommand("copy"))},x=()=>{const r=R.value;if(!r)return;const p=r.getRootElement();p&&(p.focus(),document.execCommand("cut"))},f=()=>{const r=R.value;r&&navigator.clipboard.readText().then(p=>{r.update(()=>{const w=n.$getSelection();n.$isRangeSelection(w)&&w.insertText(p)}),r.focus()}).catch(()=>{})},d=()=>{const r=R.value;r&&(r.update(()=>{const p=n.$getSelection();if(n.$isRangeSelection(p))for(const w of p.getNodes())n.$isTextNode(w)&&(w.setFormat(0),w.setStyle(""))}),r.focus())},l=()=>{const r=R.value;r&&(r.dispatchCommand(G.INSERT_TABLE_COMMAND,{rows:"3",columns:"3",includeHeaders:!0}),r.focus())},L={value:"",label:O.value.lexical.defaultOption},W=[L,...a.fontFamilies??uo],g=[L,...a.fontSizes??fo],P=[L,...a.lineHeights??go],H=o.map(()=>{const r=R.value;return r?r.getEditorState().read(()=>{const p=n.$getSelection();return n.$isRangeSelection(p)?B.$getSelectionStyleValueForProperty(p,"font-family",""):""}):""}),U=o.map(()=>{const r=R.value;return r?r.getEditorState().read(()=>{const p=n.$getSelection();return n.$isRangeSelection(p)?B.$getSelectionStyleValueForProperty(p,"font-size",""):""}):""}),tt=r=>{const p=R.value;p&&(p.update(()=>{const w=n.$getSelection();n.$isRangeSelection(w)&&B.$patchStyleText(w,{"font-family":r||null})}),p.focus())},ot=r=>{const p=R.value;p&&(p.update(()=>{const w=n.$getSelection();n.$isRangeSelection(w)&&B.$patchStyleText(w,{"font-size":r||null})}),p.focus())},nt=o.map(()=>{const r=R.value;return r?r.getEditorState().read(()=>{const p=n.$getSelection();return n.$isRangeSelection(p)&&B.$getSelectionStyleValueForProperty(p,"color","")||"#000000"}):"#000000"}),rt=o.map(()=>{const r=R.value;return r?r.getEditorState().read(()=>{const p=n.$getSelection();return n.$isRangeSelection(p)&&B.$getSelectionStyleValueForProperty(p,"background-color","")||"#ffffff"}):"#ffffff"}),it=o.map(()=>{const r=R.value;return r?r.getEditorState().read(()=>{const p=n.$getSelection();if(n.$isRangeSelection(p)){const z=k(p).getStyle();return te(z,"background-color")||"#ffffff"}return"#ffffff"}):"#ffffff"}),lt=o.map(()=>{const r=R.value;return r?r.getEditorState().read(()=>{const p=n.$getSelection();if(n.$isRangeSelection(p)){const z=k(p).getStyle();return te(z,"line-height")||""}return""}):""}),at=r=>{const p=R.value;p&&(p.update(()=>{const w=n.$getSelection();n.$isRangeSelection(w)&&B.$patchStyleText(w,{color:r})}),p.focus())},st=r=>{const p=R.value;p&&(p.update(()=>{const w=n.$getSelection();n.$isRangeSelection(w)&&B.$patchStyleText(w,{"background-color":r})}),p.focus())},ct=r=>{const p=R.value;p&&(p.update(()=>{const w=n.$getSelection();if(n.$isRangeSelection(w)){const z=k(w),Z=z.getStyle(),Q=le(Z,"background-color",r);z.setStyle(Q)}}),p.focus())},ut=r=>{const p=R.value;p&&(p.update(()=>{const w=n.$getSelection();if(n.$isRangeSelection(w)){const z=k(w),Z=z.getStyle(),Q=le(Z,"line-height",r);z.setStyle(Q)}}),p.focus())},$=new Map;$.set("bold",()=>C({active:S("bold"),onClick:M(n.FORMAT_TEXT_COMMAND,"bold"),label:b.map(r=>r.bold),icon:"mdi:format-bold"})),$.set("italic",()=>C({active:S("italic"),onClick:M(n.FORMAT_TEXT_COMMAND,"italic"),label:b.map(r=>r.italic),icon:"mdi:format-italic"})),$.set("underline",()=>C({active:S("underline"),onClick:M(n.FORMAT_TEXT_COMMAND,"underline"),label:b.map(r=>r.underline),icon:"mdi:format-underline"})),$.set("strikethrough",()=>C({active:S("strikethrough"),onClick:M(n.FORMAT_TEXT_COMMAND,"strikethrough"),label:b.map(r=>r.strikethrough),icon:"mdi:format-strikethrough"})),$.set("code",()=>C({active:S("code"),onClick:M(n.FORMAT_TEXT_COMMAND,"code"),label:b.map(r=>r.code),icon:"mdi:code-tags"})),$.set("clear-formatting",()=>C({active:e.signal(!1),onClick:d,label:b.map(r=>r.clearFormatting),icon:"mdi:format-clear"})),$.set("paragraph",()=>C({active:m("paragraph"),onClick:v,label:b.map(r=>r.normal),icon:"mdi:format-paragraph"}));for(let r=1;r<=u;r++)$.set(`heading-${r}`,()=>C({active:y(r),onClick:()=>c(r),label:b.map(p=>p.heading(r)),icon:`mdi:format-header-${r}`}));$.set("bullet-list",()=>C({active:T("bullet"),onClick:M(F.INSERT_UNORDERED_LIST_COMMAND,void 0),label:b.map(r=>r.bulletList),icon:"mdi:format-list-bulleted"})),$.set("ordered-list",()=>C({active:T("number"),onClick:M(F.INSERT_ORDERED_LIST_COMMAND,void 0),label:b.map(r=>r.orderedList),icon:"mdi:format-list-numbered"})),$.set("check-list",()=>C({active:T("check"),onClick:M(F.INSERT_CHECK_LIST_COMMAND,void 0),label:b.map(r=>r.checkList),icon:"mdi:format-list-checks"})),$.set("indent",()=>C({active:e.signal(!1),onClick:M(n.INDENT_CONTENT_COMMAND,void 0),label:b.map(r=>r.indent),icon:"mdi:format-indent-increase"})),$.set("outdent",()=>C({active:e.signal(!1),onClick:M(n.OUTDENT_CONTENT_COMMAND,void 0),label:b.map(r=>r.outdent),icon:"mdi:format-indent-decrease"})),$.set("blockquote",()=>C({active:m("quote"),onClick:_("quote",j.$createQuoteNode),label:b.map(r=>r.blockquote),icon:"mdi:format-quote-close"})),$.set("code-block",()=>C({active:m("code"),onClick:_("code",ie.$createCodeNode),label:b.map(r=>r.codeBlock),icon:"mdi:code-braces"})),$.set("horizontal-rule",()=>C({active:e.signal(!1),onClick:M(ce,void 0),label:b.map(r=>r.horizontalRule),icon:"mdi:minus"})),$.set("insert-table",()=>C({active:e.signal(!1),onClick:l,label:b.map(r=>r.insertTable),icon:"mdi:table-plus"})),$.set("link",()=>C({active:E(),onClick:I,label:b.map(r=>r.link),icon:"mdi:link"})),$.set("undo",()=>C({active:e.signal(!1),onClick:M(n.UNDO_COMMAND,void 0),label:b.map(r=>r.undo),icon:"mdi:undo"})),$.set("redo",()=>C({active:e.signal(!1),onClick:M(n.REDO_COMMAND,void 0),label:b.map(r=>r.redo),icon:"mdi:redo"})),$.set("cut",()=>C({active:e.signal(!1),onClick:x,label:b.map(r=>r.cut),icon:"mdi:content-cut"})),$.set("copy",()=>C({active:e.signal(!1),onClick:D,label:b.map(r=>r.copy),icon:"mdi:content-copy"})),$.set("paste",()=>C({active:e.signal(!1),onClick:f,label:b.map(r=>r.paste),icon:"mdi:content-paste"})),$.set("font-family",()=>e.html.select(e.attr.class("bc-lexical-toolbar-select"),e.attr.title(b.map(r=>r.fontFamily)),e.attr.disabled(s),e.on.change(r=>tt(r.target.value)),...W.map(r=>e.html.option(e.attr.value(r.value),e.attr.selected(H.map(p=>p===r.value)),r.label)))),$.set("font-size",()=>e.html.select(e.attr.class("bc-lexical-toolbar-select"),e.attr.title(b.map(r=>r.fontSize)),e.attr.disabled(s),e.on.change(r=>ot(r.target.value)),...g.map(r=>e.html.option(e.attr.value(r.value),e.attr.selected(U.map(p=>p===r.value)),r.label)))),$.set("line-height",()=>e.html.select(e.attr.class("bc-lexical-toolbar-select"),e.attr.title(b.map(r=>r.lineHeight)),e.attr.disabled(s),e.on.change(r=>ut(r.target.value)),...P.map(r=>e.html.option(e.attr.value(r.value),e.attr.selected(lt.map(p=>p===r.value)),r.label)))),$.set("font-color",()=>e.html.label(e.attr.class("bc-lexical-toolbar-color"),e.attr.title(b.map(r=>r.fontColor)),e.html.input(e.attr.type("color"),e.attr.value(nt),e.attr.disabled(s),e.on.input(r=>at(r.target.value))),e.html.span(e.attr.class("bc-lexical-toolbar-color-icon"),"A"))),$.set("highlight-color",()=>e.html.label(e.attr.class("bc-lexical-toolbar-color"),e.attr.title(b.map(r=>r.highlightColor)),e.html.input(e.attr.type("color"),e.attr.value(rt),e.attr.disabled(s),e.on.input(r=>st(r.target.value))),e.html.span(e.attr.class("bc-lexical-toolbar-color-icon bc-lexical-toolbar-color-icon--highlight"),"A"))),$.set("background-color",()=>e.html.label(e.attr.class("bc-lexical-toolbar-color"),e.attr.title(b.map(r=>r.backgroundColor)),e.html.input(e.attr.type("color"),e.attr.value(it),e.attr.disabled(s),e.on.input(r=>ct(r.target.value))),e.html.span(e.attr.class("bc-lexical-toolbar-color-icon bc-lexical-toolbar-color-icon--bg"),"■")));const Pe={editor:R,stateUpdate:o,readOnly:s,size:i,button:r=>C({active:r.active??e.signal(!1),onClick:r.onClick,label:r.label,icon:r.icon})},He=r=>{if(r.type==="button"){const p=r;$.set(r.id,()=>C({active:p.active?.(Pe)??e.signal(!1),onClick:()=>p.onClick(R.value),label:p.label,icon:p.icon}))}else if(r.type==="select"){const p=r,w=p.resetOnSelect!==!1;$.set(r.id,()=>e.html.select(e.attr.class("bc-lexical-toolbar-select"),e.attr.title(p.label),e.attr.disabled(s),e.on.change(z=>{const Z=z.target,Q=Z.value;Q!==""&&(p.onSelect(Q,R.value),w&&(Z.value=""))}),e.html.option(e.attr.value(""),e.attr.disabled(w),e.attr.selected(!0),p.label),...p.options.map(z=>e.html.option(e.attr.value(z.value),z.label))))}else if(r.type==="custom"){const p=r;$.set(r.id,()=>p.render(Pe))}};if(a.customItems)for(const r of a.customItems)He(r);if(a.customGroups)for(const r of a.customGroups)for(const p of r.items)He(p);return je.Toolbar({},e.attr.class("bc-lexical-toolbar"),...mo(h,$,u,a.customGroups))}))}function mo(t,o,a,s){const i=new Map;if(s)for(const h of s)i.set(h.id,h);const u=[];for(const h of t){if("separator"in h){u.push(je.ToolbarDivider());continue}if("customGroup"in h){const b=i.get(h.customGroup);if(!b)continue;const k=[];for(const m of b.items){const T=o.get(m.id);T&&k.push(T())}if(k.length===0)continue;const S=k.map(()=>e.signal(!0));u.push(ve.EditorToolbarGroup({display:S},...k));continue}let O=h.items??lo[h.group]??[];h.group==="headings"&&!h.items&&(O=O.filter(b=>b.startsWith("heading-")?parseInt(b.split("-")[1],10)<=a:!0));const A=[];for(const b of O){const k=o.get(b);k&&A.push(k())}if(A.length===0)continue;const R=A.map(()=>e.signal(!0));u.push(ve.EditorToolbarGroup({display:R},...A))}return u}function Xe({editor:t,stateUpdate:o,readOnly:a=e.signal(!1)}){const s=e.prop(!1),i=e.prop(0),u=e.prop(0);let h=null;const O=e.prop(!1),A=I=>{let N=null;return I.getEditorState().read(()=>{const C=n.$getSelection();if(!n.$isRangeSelection(C))return;let v=C.anchor.getNode();for(;v;){if(G.$isTableCellNode(v)){N=v;break}if(v=v.getParent(),!v||v.getKey()==="root")break}}),N},R=(I,N)=>{const C=I.getBoundingClientRect(),v=N.closest(".bc-lexical-editor-container"),c=v?v.getBoundingClientRect():N.getBoundingClientRect();return i.value=C.top-c.top+2,u.value=c.right-C.right+2,!0},b=()=>{const I=t.value;if(!I){s.value=!1;return}const N=A(I);if(!N){O.value||(s.value=!1);return}const C=I.getElementByKey(N.getKey()),v=I.getRootElement();C&&v?(R(C,v),s.value=!0):s.value=!1};o.onChange(b);const k=I=>()=>{const N=t.value;N&&(N.update(I),h?.set(!1),N.focus())},S=k(()=>G.$insertTableRowAtSelection(!1)),m=k(()=>G.$insertTableRowAtSelection(!0)),T=k(()=>G.$insertTableColumnAtSelection(!1)),y=k(()=>G.$insertTableColumnAtSelection(!0)),E=k(()=>G.$deleteTableRowAtSelection()),M=k(()=>G.$deleteTableColumnAtSelection()),_=k(()=>{const I=n.$getSelection();if(!n.$isRangeSelection(I))return;const N=I.anchor.getNode(),C=G.$getTableCellNodeFromLexicalNode(N);if(!C)return;G.$getTableNodeFromLexicalNodeOrThrow(C).remove()});return e.Use(q.BeatUII18n,I=>e.Ensure(t,N=>{const C=N,v=I.$.lexical,c=d=>{const l=C.value;if(!l||a.value)return;const L=l.getRootElement();if(!L)return;const g=d.target.closest("td, th");g&&L.contains(g)&&(d.preventDefault(),R(g,L)&&(s.value=!0),bt.delayedAnimationFrame(()=>{h?.set(!0)}))},D=C.value?.getRootElement(),f=D?.closest(".bc-lexical-editor-container")??D??document;return f.addEventListener("contextmenu",c),[e.OnDispose(()=>{f.removeEventListener("contextmenu",c)}),e.When(s,()=>e.html.div(e.attr.class("bc-table-cell-marker"),e.style.position("absolute"),e.style.top(i.map(d=>`${d}px`)),e.style.right(u.map(d=>`${d}px`)),e.style.zIndex("10"),e.WithElement(d=>{d.addEventListener("mousedown",l=>{l.preventDefault()})}),e.html.button(e.attr.class("bc-table-cell-marker__button"),e.attr.type("button"),e.attr.title(v.map(d=>d.tableActions)),e.attr.disabled(a),q.Icon({icon:"lucide:chevron-down",size:"xs"}),e.WithElement(d=>{const l=new MutationObserver(()=>{const L=d.getAttribute("aria-expanded")==="true";O.value=L});return l.observe(d,{attributes:!0,attributeFilter:["aria-expanded"]}),e.OnDispose(()=>l.disconnect())}),J.Menu({items:()=>[J.MenuItem({key:"insert-row-above",content:v.map(d=>d.insertRowAbove),before:q.Icon({icon:"lucide:arrow-up",size:"sm"}),onClick:S,disabled:a}),J.MenuItem({key:"insert-row-below",content:v.map(d=>d.insertRowBelow),before:q.Icon({icon:"lucide:arrow-down",size:"sm"}),onClick:m,disabled:a}),J.MenuItem({key:"insert-column-left",content:v.map(d=>d.insertColumnLeft),before:q.Icon({icon:"lucide:arrow-left",size:"sm"}),onClick:T,disabled:a}),J.MenuItem({key:"insert-column-right",content:v.map(d=>d.insertColumnRight),before:q.Icon({icon:"lucide:arrow-right",size:"sm"}),onClick:y,disabled:a}),J.MenuSeparator(),J.MenuItem({key:"delete-row",content:v.map(d=>d.deleteRow),before:q.Icon({icon:"lucide:trash-2",size:"sm"}),onClick:E,disabled:a}),J.MenuItem({key:"delete-column",content:v.map(d=>d.deleteColumn),before:q.Icon({icon:"lucide:trash-2",size:"sm"}),onClick:M,disabled:a}),J.MenuItem({key:"delete-table",content:v.map(d=>d.deleteTable),before:q.Icon({icon:"lucide:trash-2",size:"sm"}),onClick:_,disabled:a})],placement:"bottom-end",showOn:d=>(h=d,e.on.click(()=>{d.set(!d.value)})),showDelay:0,hideDelay:0,mainAxisOffset:4,onClose:()=>{const d=C.value;d&&d.focus()},ariaLabel:v.map(d=>d.tableActions)}))))]}))}const po=t=>{const{value:o,format:a,plugins:s,readOnly:i,placeholder:u,class:h,namespace:O="BeatUILexical",heightMode:A="fixed",toolbar:R,autoFocus:b=!1,onError:k,onInput:S,onChange:m,onBlur:T,onReady:y}=t,E=e.prop(null),M=e.prop(0),_=N=>typeof N=="object"&&N!==null&&"map"in N&&typeof N.map=="function",I=i!=null?_(i)?i:e.prop(e.Value.get(i)):e.prop(!1);return e.Use(Ie.Theme,({appearance:N})=>e.html.div(e.Task(()=>Promise.resolve().then(()=>require("../styles-url-CkPTI32j.cjs")),({default:C})=>Le.LinkPortal({id:"beatui-lexical-css",href:C})),e.attr.class("bc-lexical-editor-container"),A==="fixed"?e.attr.class("bc-lexical-editor-container--fixed"):null,e.attr.class(h),e.When(I.map(C=>!C),()=>Ve({editor:E,stateUpdate:M,toolbar:R,readOnly:I,size:"sm"})),Xe({editor:E,stateUpdate:M,readOnly:I}),e.html.div(e.attr.class("bc-lexical-editor"),e.attr.class(`bc-lexical-editor--${A}`),e.attr.contenteditable(i!=null?e.Value.map(i,C=>!C):!0),i!=null?e.attr.class(e.Value.map(i,C=>C?"bc-lexical-editor--readonly":"")):null,e.WithElement(C=>{let v=null;const c=[];return(async()=>{try{const x=s??pe("docked"),f=me(x),d=e.Value.get(a??"markdown"),l=n.createEditor({namespace:O,nodes:f,theme:{heading:{h1:"bc-lexical-h1",h2:"bc-lexical-h2",h3:"bc-lexical-h3",h4:"bc-lexical-h4",h5:"bc-lexical-h5",h6:"bc-lexical-h6"},text:{bold:"bc-lexical-bold",italic:"bc-lexical-italic",underline:"bc-lexical-underline",strikethrough:"bc-lexical-strikethrough",code:"bc-lexical-code"},list:{ul:"bc-lexical-ul",ol:"bc-lexical-ol",listitem:"bc-lexical-li",listitemChecked:"bc-lexical-li-checked",listitemUnchecked:"bc-lexical-li-unchecked"},link:"bc-lexical-link",quote:"bc-lexical-blockquote",code:"bc-lexical-code-block",codeHighlight:{},hashtag:"bc-lexical-hashtag",table:"bc-lexical-table",tableCell:"bc-lexical-table-cell",tableCellHeader:"bc-lexical-table-cell-header",tableRow:"bc-lexical-table-row",mark:"bc-lexical-mark",paragraph:"bc-lexical-paragraph"},onError:g=>{k?k(g,l):console.error("[BeatUI Lexical]",g)},editable:i?!e.Value.get(i):!0,html:{export:xe(),import:ue()}});v=l,E.set(l),l.setRootElement(C);const L=[];if(x.richText?L.push(he(l)):x.plainText&&L.push(be(l)),x.history){const g=typeof x.history=="object"?x.history:void 0;L.push(Ce(l,g))}if(x.clipboard&&L.push(ye(l)),x.list&&L.push(Ee(l)),x.link&&L.push(Oe(l)),x.yjs&&L.push(Me(l,x.yjs)),x.dragon&&L.push(Se(l)),x.table&&L.push(Ne(l)),(await Promise.all(L)).forEach(g=>{g&&c.push(g)}),c.push(Te(l)),c.push($e(l)),c.push(l.registerCommand(n.SELECTION_CHANGE_COMMAND,()=>(M.set(M.value+1),!1),n.COMMAND_PRIORITY_LOW)),c.push(l.registerUpdateListener(({editorState:g,dirtyElements:P,dirtyLeaves:H})=>{(P.size>0||H.size>0)&&M.set(M.value+1),S&&(P.size>0||H.size>0)&&g.read(async()=>{if(d==="markdown"){const U=await K(l);S(U,l)}else if(d==="html"){const U=await Y(l);S(U,l)}else d==="json"&&S(g.toJSON(),l)})})),o!=null){const g=e.Value.get(o);if(g!=null&&(g!==""||d==="json"&&typeof g=="object")){if(d==="markdown"&&typeof g=="string")await V(l,g);else if(d==="html"&&typeof g=="string")await X(l,g);else if(d==="json"&&typeof g=="object")try{const H=JSON.stringify(g),U=l.parseEditorState(H);l.setEditorState(U)}catch(H){console.error("[BeatUI] Failed to parse JSON editor state:",H),k&&k(H instanceof Error?H:new Error(String(H)),l)}}}if(o!=null&&c.push(e.Value.on(o,async g=>{if(g!=null){if(d==="markdown"&&typeof g=="string"){const P=await K(l);g!==P&&await V(l,g)}else if(d==="html"&&typeof g=="string"){const P=await Y(l);g!==P&&await X(l,g)}else if(d==="json"&&typeof g=="object"){const P=JSON.stringify(l.getEditorState().toJSON()),H=JSON.stringify(g);if(P!==H){const U=l.parseEditorState(H);l.setEditorState(U)}}}})),i!=null&&c.push(e.Value.on(i,g=>{l.setEditable(!g)})),c.push(l.registerCommand(n.BLUR_COMMAND,()=>(T&&T(l),m&&l.getEditorState().read(async()=>{if(d==="markdown"){const g=await K(l);m(g,l)}else if(d==="html"){const g=await Y(l);m(g,l)}else d==="json"&&m(l.getEditorState().toJSON(),l)}),!1),n.COMMAND_PRIORITY_LOW)),c.push(N.on(g=>{const P=l.getRootElement();P&&(P.dataset.theme=g)})),b)l.focus();else{const g=l.getRootElement();g&&g===document.activeElement&&g.blur()}y&&y(l)}catch(x){console.error("[BeatUI] Failed to initialize Lexical editor:",x);const f=C;f.textContent="Failed to load Lexical editor."}})(),e.OnDispose(()=>{try{c.forEach(x=>x())}catch{}try{v?.setRootElement(null)}catch{}E.set(null)})}))))};function Ze({editor:t,stateUpdate:o,groups:a=["text-formatting"],readOnly:s=e.signal(!1),size:i="sm"}){const u=e.prop(!1),h=e.prop(0),O=e.prop(0);return e.Use(q.BeatUII18n,A=>e.Ensure(t,R=>{const b=R,k=A.$.lexical,S=c=>a.includes(c),{textFormatActive:m,linkActive:T,dispatch:y,toggleLink:E}=Ye(b,o,{enterUrlMessage:()=>A.value.lexical.enterUrl}),_=Je(s,i)(e.signal(!0)),I=()=>{const c=b.value;if(!c){u.value=!1;return}const D=c.getRootElement();if(!D){u.value=!1;return}const x=window.getSelection();if(!x||x.rangeCount===0||x.isCollapsed){u.value=!1;return}const f=x.anchorNode;if(f&&!D.contains(f)){u.value=!1;return}const l=x.getRangeAt(0).getBoundingClientRect();if(l.width===0&&l.height===0){u.value=!1;return}const L=40,W=8;let g=l.top-L-W;const P=l.left+l.width/2;g<0&&(g=l.bottom+W),h.value=g,O.value=P,u.value=!0},N=o.onChange(I),C=()=>{I()};document.addEventListener("selectionchange",C);const v=e.html.div(e.attr.class("bc-floating-toolbar"),e.style.position("fixed"),e.style.top(h.map(c=>`${c}px`)),e.style.left(O.map(c=>`${c}px`)),e.style.transform("translateX(-50%)"),e.WithElement(c=>{const D=f=>{if(f.key==="Escape"&&u.value){u.value=!1;const d=b.value;d&&d.focus()}},x=f=>{if(u.value&&!c.contains(f.target)){const d=b.value;if(d){const l=d.getRootElement();if(l&&l.contains(f.target))return}u.value=!1}};return document.addEventListener("keydown",D),document.addEventListener("mousedown",x),e.OnDispose(()=>{N(),document.removeEventListener("keydown",D),document.removeEventListener("mousedown",x),document.removeEventListener("selectionchange",C)})}),...S("text-formatting")?[_({active:m("bold"),onClick:y(n.FORMAT_TEXT_COMMAND,"bold"),label:k.map(c=>c.bold),icon:"mdi:format-bold"}),_({active:m("italic"),onClick:y(n.FORMAT_TEXT_COMMAND,"italic"),label:k.map(c=>c.italic),icon:"mdi:format-italic"}),_({active:m("underline"),onClick:y(n.FORMAT_TEXT_COMMAND,"underline"),label:k.map(c=>c.underline),icon:"mdi:format-underline"}),_({active:m("strikethrough"),onClick:y(n.FORMAT_TEXT_COMMAND,"strikethrough"),label:k.map(c=>c.strikethrough),icon:"mdi:format-strikethrough"}),_({active:m("code"),onClick:y(n.FORMAT_TEXT_COMMAND,"code"),label:k.map(c=>c.code),icon:"mdi:code-tags"})]:[],...S("links")?[_({active:T(),onClick:E,label:k.map(c=>c.link),icon:"mdi:link"})]:[],...S("clipboard")?[_({active:e.signal(!1),onClick:()=>{const c=b.value;if(!c)return;const D=c.getRootElement();D&&(D.focus(),document.execCommand("cut"))},label:k.map(c=>c.cut),icon:"mdi:content-cut"}),_({active:e.signal(!1),onClick:()=>{const c=b.value;if(!c)return;const D=c.getRootElement();D&&(D.focus(),document.execCommand("copy"))},label:k.map(c=>c.copy),icon:"mdi:content-copy"}),_({active:e.signal(!1),onClick:()=>{const c=b.value;c&&navigator.clipboard.readText().then(D=>{c.update(()=>{const x=n.$getSelection();n.$isRangeSelection(x)&&x.insertText(D)}),c.focus()}).catch(()=>{})},label:k.map(c=>c.paste),icon:"mdi:content-paste"})]:[]);return e.When(u,()=>v)}))}const ho=[{id:"heading1",label:"Heading 1",description:"Large section heading",icon:"mdi:format-header-1",keywords:["h1","heading","title"],category:"Basic blocks",handler:t=>{t.update(()=>{const o=n.$getSelection();n.$isRangeSelection(o)&&B.$setBlocksType(o,()=>j.$createHeadingNode("h1"))})}},{id:"heading2",label:"Heading 2",description:"Medium section heading",icon:"mdi:format-header-2",keywords:["h2","heading"],category:"Basic blocks",handler:t=>{t.update(()=>{const o=n.$getSelection();n.$isRangeSelection(o)&&B.$setBlocksType(o,()=>j.$createHeadingNode("h2"))})}},{id:"heading3",label:"Heading 3",description:"Small section heading",icon:"mdi:format-header-3",keywords:["h3","heading"],category:"Basic blocks",handler:t=>{t.update(()=>{const o=n.$getSelection();n.$isRangeSelection(o)&&B.$setBlocksType(o,()=>j.$createHeadingNode("h3"))})}},{id:"bullet-list",label:"Bullet List",description:"Create a bulleted list",icon:"mdi:format-list-bulleted",keywords:["ul","unordered","bullets"],category:"Lists",handler:t=>{t.dispatchCommand(F.INSERT_UNORDERED_LIST_COMMAND,void 0)}},{id:"ordered-list",label:"Ordered List",description:"Create a numbered list",icon:"mdi:format-list-numbered",keywords:["ol","numbered","1","2","3"],category:"Lists",handler:t=>{t.dispatchCommand(F.INSERT_ORDERED_LIST_COMMAND,void 0)}},{id:"quote",label:"Quote",description:"Insert a blockquote",icon:"mdi:format-quote-close",keywords:["blockquote","citation"],category:"Basic blocks",handler:t=>{t.update(()=>{const o=n.$getSelection();n.$isRangeSelection(o)&&B.$setBlocksType(o,()=>j.$createQuoteNode())})}},{id:"code-block",label:"Code Block",description:"Insert a code block",icon:"mdi:code-braces",keywords:["code","pre","programming"],category:"Basic blocks",handler:t=>{t.update(()=>{const o=n.$getSelection();n.$isRangeSelection(o)&&B.$setBlocksType(o,()=>ie.$createCodeNode())})}},{id:"divider",label:"Divider",description:"Insert a horizontal rule",icon:"mdi:minus",keywords:["hr","horizontal","line","separator"],category:"Basic blocks",handler:t=>{t.dispatchCommand(ce,void 0)}},{id:"table",label:"Table",description:"Insert a table",icon:"mdi:table",keywords:["table","grid","cells","rows","columns"],category:"Advanced",handler:t=>{t.dispatchCommand(G.INSERT_TABLE_COMMAND,{rows:"3",columns:"3",includeHeaders:!0})}}];function bo({commands:t,isVisible:o,filterText:a,position:s,onSelect:i,onClose:u}){const h=e.prop(0),O=a.map(S=>{const m=S.toLowerCase().trim();return m?t.filter(T=>[T.label.toLowerCase(),T.description?.toLowerCase()||"",...T.keywords?.map(E=>E.toLowerCase())||[]].join(" ").includes(m)):t});O.onChange(()=>{h.value=0});const A=S=>{const m=O.value;if(S>=0&&S<m.length){const T=m[S];i(T)}},R=S=>{if(!o.value)return;const T=O.value.length-1;switch(S.key){case"ArrowDown":S.preventDefault(),h.value=Math.min(h.value+1,T);break;case"ArrowUp":S.preventDefault(),h.value=Math.max(h.value-1,0);break;case"Enter":S.preventDefault(),A(h.value);break;case"Escape":S.preventDefault(),u();break}},b=(S,m)=>{const T=h.map(E=>E===m),y=`slash-cmd-${S.id}`;return e.html.div(e.attr.class("bc-slash-command-palette__item"),e.attr.id(y),e.attr.role("option"),e.aria.selected(T),e.WithElement(E=>{const M=()=>{h.value=m},_=()=>{A(m)};return E.addEventListener("mouseenter",M),E.addEventListener("click",_),e.OnDispose(()=>{E.removeEventListener("mouseenter",M),E.removeEventListener("click",_)})}),typeof S.icon=="string"?e.html.div(e.attr.class("bc-slash-command-palette__icon"),q.Icon({icon:S.icon,size:"sm"})):S.icon,e.html.div(e.attr.class("bc-slash-command-palette__content"),e.html.div(e.attr.class("bc-slash-command-palette__label"),S.label),S.description?e.html.div(e.attr.class("bc-slash-command-palette__description"),S.description):void 0),S.category?e.html.div(e.attr.class("bc-slash-command-palette__category"),S.category):void 0)},k=e.Use(q.BeatUII18n,S=>e.html.div(e.attr.class("bc-slash-command-palette"),e.attr.role("listbox"),e.aria.label(S.$.lexical.map(m=>m.slashCommands)),e.style.position("absolute"),e.style.top(s.map(m=>`${m.top}px`)),e.style.left(s.map(m=>`${m.left}px`)),e.WithElement(()=>(document.addEventListener("keydown",R),e.OnDispose(()=>{document.removeEventListener("keydown",R)}))),e.When(O.map(m=>m.length===0),()=>e.html.div(e.attr.class("bc-slash-command-palette__empty"),S.$.lexical.map(m=>m.noCommandsFound))),e.ForEach(O,(m,T)=>{const y=m.value;return b(y,T.index)})));return e.When(o,()=>k)}const Qe=[{id:"paragraph",label:"Paragraph",icon:"mdi:format-paragraph",handler:t=>{t.update(()=>{const o=n.$getSelection();n.$isRangeSelection(o)&&B.$setBlocksType(o,()=>n.$createParagraphNode())})}},{id:"heading1",label:"Heading 1",icon:"mdi:format-header-1",handler:t=>{t.update(()=>{const o=n.$getSelection();n.$isRangeSelection(o)&&B.$setBlocksType(o,()=>j.$createHeadingNode("h1"))})}},{id:"heading2",label:"Heading 2",icon:"mdi:format-header-2",handler:t=>{t.update(()=>{const o=n.$getSelection();n.$isRangeSelection(o)&&B.$setBlocksType(o,()=>j.$createHeadingNode("h2"))})}},{id:"heading3",label:"Heading 3",icon:"mdi:format-header-3",handler:t=>{t.update(()=>{const o=n.$getSelection();n.$isRangeSelection(o)&&B.$setBlocksType(o,()=>j.$createHeadingNode("h3"))})}},{id:"bullet-list",label:"Bullet List",icon:"mdi:format-list-bulleted",handler:t=>{t.dispatchCommand(F.INSERT_UNORDERED_LIST_COMMAND,void 0)}},{id:"ordered-list",label:"Ordered List",icon:"mdi:format-list-numbered",handler:t=>{t.dispatchCommand(F.INSERT_ORDERED_LIST_COMMAND,void 0)}},{id:"quote",label:"Quote",icon:"mdi:format-quote-close",handler:t=>{t.update(()=>{const o=n.$getSelection();n.$isRangeSelection(o)&&B.$setBlocksType(o,()=>j.$createQuoteNode())})}},{id:"code-block",label:"Code Block",icon:"mdi:code-braces",handler:t=>{t.update(()=>{const o=n.$getSelection();n.$isRangeSelection(o)&&B.$setBlocksType(o,()=>ie.$createCodeNode())})}},{id:"divider",label:"Divider",icon:"mdi:minus",handler:t=>{t.dispatchCommand(ce,void 0)}},{id:"table",label:"Table",icon:"mdi:table",handler:t=>{t.dispatchCommand(G.INSERT_TABLE_COMMAND,{rows:"3",columns:"3",includeHeaders:!0})}}];function et({editor:t,stateUpdate:o,readOnly:a=e.signal(!1),commands:s=Qe}){const i=e.prop(!1),u=e.prop(!1),h=e.prop(0),O=e.prop(0);return e.Use(q.BeatUII18n,A=>e.Ensure(t,R=>{const b=R;let k=null,S=!1,m=null;const T=24,y=4,E=200,M=f=>{if(f===k&&i.value)return;k=f;const d=f.getBoundingClientRect();h.value=d.top,O.value=d.left-T-y,i.value=!0},_=()=>{m!=null&&(clearTimeout(m),m=null)},I=()=>{u.value||(_(),m=setTimeout(()=>{m=null,u.value||(i.value=!1,k=null)},E))},N=()=>{const f=b.value;if(!f)return;const d=f.getRootElement();d&&(c(d),f.getEditorState().read(()=>{const l=n.$getSelection();if(n.$isRangeSelection(l))try{const W=l.anchor.getNode().getTopLevelElementOrThrow(),g=f.getElementByKey(W.getKey());g&&M(g)}catch{}}))},C=f=>{if(u.value)return;const d=b.value;if(!d)return;const l=d.getRootElement();if(l)for(const L of Array.from(l.children)){const W=L.getBoundingClientRect();if(f.clientY>=W.top&&f.clientY<=W.bottom){_(),M(L);return}}},v=()=>{I()},c=f=>{S||(S=!0,f.addEventListener("mousemove",C),f.addEventListener("mouseleave",v))},D=o.onChange(N);return[e.OnDispose(()=>{D(),_();const f=b.value;if(f){const d=f.getRootElement();d&&S&&(d.removeEventListener("mousemove",C),d.removeEventListener("mouseleave",v))}}),e.When(i,()=>e.html.div(e.attr.class("bc-block-handle"),e.style.position("fixed"),e.style.top(h.map(f=>`${f}px`)),e.style.left(O.map(f=>`${f}px`)),e.on.mouseenter(_),e.on.mouseleave(()=>I()),e.WithElement(f=>{f.addEventListener("mousedown",d=>{d.preventDefault()})}),e.html.button(e.attr.class("bc-block-handle__button"),e.attr.type("button"),e.attr.title(A.$.lexical.map(f=>f.changeBlockType)),e.attr.disabled(a),q.Icon({icon:"mdi:drag-horizontal-variant",size:"sm"}),e.WithElement(f=>{const d=new MutationObserver(()=>{const l=f.getAttribute("aria-expanded")==="true";u.value=l});return d.observe(f,{attributes:!0,attributeFilter:["aria-expanded"]}),e.OnDispose(()=>d.disconnect())}),J.Menu({items:()=>s.map(f=>J.MenuItem({key:f.id,content:f.label,before:q.Icon({icon:f.icon,size:"sm"}),onClick:()=>{const d=b.value;d&&(f.handler(d),d.focus())}})),placement:"bottom-start",showOn:"click",showDelay:0,hideDelay:0,mainAxisOffset:4,onClose:()=>{const f=b.value;f&&f.focus()},ariaLabel:A.value.lexical.blockTypes}))))]}))}const Co=t=>{const{value:o,format:a,plugins:s,readOnly:i,placeholder:u,class:h,namespace:O="BeatUILexical",heightMode:A="auto",floatingToolbarGroups:R,autoFocus:b=!1,onError:k,onInput:S,onChange:m,onBlur:T,onReady:y}=t,E=e.prop(null),M=e.prop(0),_=N=>typeof N=="object"&&N!==null&&"map"in N&&typeof N.map=="function",I=i!=null?_(i)?i:e.prop(e.Value.get(i)):e.prop(!1);return e.Use(Ie.Theme,({appearance:N})=>e.html.div(e.Task(()=>Promise.resolve().then(()=>require("../styles-url-CkPTI32j.cjs")),({default:C})=>Le.LinkPortal({id:"beatui-lexical-css",href:C})),e.attr.class("bc-lexical-editor-container"),A==="fixed"?e.attr.class("bc-lexical-editor-container--fixed"):null,e.attr.class(h),Ze({editor:E,stateUpdate:M,groups:R??["text-formatting","links"],readOnly:I}),et({editor:E,stateUpdate:M,readOnly:I}),Xe({editor:E,stateUpdate:M,readOnly:I}),e.html.div(e.attr.class("bc-lexical-editor"),e.attr.class(`bc-lexical-editor--${A}`),e.attr.contenteditable(i!=null?e.Value.map(i,C=>!C):!0),i!=null?e.attr.class(e.Value.map(i,C=>C?"bc-lexical-editor--readonly":"")):null,e.WithElement(C=>{let v=null;const c=[];return(async()=>{try{const x=s??pe("contextual"),f=me(x),d=e.Value.get(a??"markdown"),l=n.createEditor({namespace:O,nodes:f,theme:{heading:{h1:"bc-lexical-h1",h2:"bc-lexical-h2",h3:"bc-lexical-h3",h4:"bc-lexical-h4",h5:"bc-lexical-h5",h6:"bc-lexical-h6"},text:{bold:"bc-lexical-bold",italic:"bc-lexical-italic",underline:"bc-lexical-underline",strikethrough:"bc-lexical-strikethrough",code:"bc-lexical-code"},list:{ul:"bc-lexical-ul",ol:"bc-lexical-ol",listitem:"bc-lexical-li",listitemChecked:"bc-lexical-li-checked",listitemUnchecked:"bc-lexical-li-unchecked"},link:"bc-lexical-link",quote:"bc-lexical-blockquote",code:"bc-lexical-code-block",codeHighlight:{},hashtag:"bc-lexical-hashtag",table:"bc-lexical-table",tableCell:"bc-lexical-table-cell",tableCellHeader:"bc-lexical-table-cell-header",tableRow:"bc-lexical-table-row",mark:"bc-lexical-mark",paragraph:"bc-lexical-paragraph"},onError:g=>{k?k(g,l):console.error("[BeatUI Lexical]",g)},editable:i?!e.Value.get(i):!0,html:{export:xe(),import:ue()}});v=l,E.set(l),l.setRootElement(C);const L=[];if(x.richText?L.push(he(l)):x.plainText&&L.push(be(l)),x.history){const g=typeof x.history=="object"?x.history:void 0;L.push(Ce(l,g))}if(x.clipboard&&L.push(ye(l)),x.list&&L.push(Ee(l)),x.link&&L.push(Oe(l)),x.yjs&&L.push(Me(l,x.yjs)),x.dragon&&L.push(Se(l)),x.table&&L.push(Ne(l)),(await Promise.all(L)).forEach(g=>{g&&c.push(g)}),c.push(Te(l)),c.push($e(l)),c.push(l.registerCommand(n.SELECTION_CHANGE_COMMAND,()=>(M.set(M.value+1),!1),n.COMMAND_PRIORITY_LOW)),c.push(l.registerUpdateListener(({editorState:g,dirtyElements:P,dirtyLeaves:H})=>{(P.size>0||H.size>0)&&M.set(M.value+1),S&&(P.size>0||H.size>0)&&g.read(async()=>{if(d==="markdown"){const U=await K(l);S(U,l)}else if(d==="html"){const U=await Y(l);S(U,l)}else d==="json"&&S(g.toJSON(),l)})})),o!=null){const g=e.Value.get(o);if(g!=null&&(g!==""||d==="json"&&typeof g=="object")){if(d==="markdown"&&typeof g=="string")await V(l,g);else if(d==="html"&&typeof g=="string")await X(l,g);else if(d==="json"&&typeof g=="object")try{const H=JSON.stringify(g),U=l.parseEditorState(H);l.setEditorState(U)}catch(H){console.error("[BeatUI] Failed to parse JSON editor state:",H),k&&k(H instanceof Error?H:new Error(String(H)),l)}}}if(o!=null&&c.push(e.Value.on(o,async g=>{if(g!=null){if(d==="markdown"&&typeof g=="string"){const P=await K(l);g!==P&&await V(l,g)}else if(d==="html"&&typeof g=="string"){const P=await Y(l);g!==P&&await X(l,g)}else if(d==="json"&&typeof g=="object"){const P=JSON.stringify(l.getEditorState().toJSON()),H=JSON.stringify(g);if(P!==H){const U=l.parseEditorState(H);l.setEditorState(U)}}}})),i!=null&&c.push(e.Value.on(i,g=>{l.setEditable(!g)})),c.push(l.registerCommand(n.BLUR_COMMAND,()=>(T&&T(l),m&&l.getEditorState().read(async()=>{if(d==="markdown"){const g=await K(l);m(g,l)}else if(d==="html"){const g=await Y(l);m(g,l)}else d==="json"&&m(l.getEditorState().toJSON(),l)}),!1),n.COMMAND_PRIORITY_LOW)),c.push(N.on(g=>{const P=l.getRootElement();P&&(P.dataset.theme=g)})),b)l.focus();else{const g=l.getRootElement();g&&g===document.activeElement&&g.blur()}y&&y(l)}catch(x){console.error("[BeatUI] Failed to initialize Lexical editor:",x);const f=C;f.textContent="Failed to load Lexical editor."}})(),e.OnDispose(()=>{try{c.forEach(x=>x())}catch{}try{v?.setRootElement(null)}catch{}E.set(null)})}))))},yo=t=>{const{value:o,before:a,after:s,onChange:i,onInput:u,onBlur:h,disabled:O,hasError:A,name:R,placeholder:b,id:k,required:S,tabIndex:m,size:T,class:y,namespace:E,format:M,plugins:_,readOnly:I,onError:N,onReady:C,marks:v,autoFocus:c}=t,D=O!=null&&I!=null?e.computedOf(O,I)((x,f)=>(x??!1)||(f??!1)):O??I;return Ct.InputContainer({disabled:O,hasError:A,size:T,baseContainer:!0,growInput:!0,focusableSelector:"[contenteditable]",before:a,after:s,input:e.html.div(e.attr.class("bc-lexical-editor-input"),e.attr.name(R),e.attr.id(k),S!=null?e.aria.required(S):null,m!=null?e.attr.tabindex(m):null,A!=null?e.attr.class(e.Value.map(A,x=>x?"bc-lexical-editor-input--error":"")):null,Ke({value:o,format:M??"markdown",plugins:_,readOnly:D,placeholder:b,namespace:E,class:y,autoFocus:c,onError:N,onReady:C,onInput:u?(x,f)=>{u(x)}:void 0,onChange:i?(x,f)=>{i(x)}:void 0,onBlur:h?x=>{h()}:void 0}))})};Object.defineProperty(exports,"INSERT_CHECK_LIST_COMMAND",{enumerable:!0,get:()=>F.INSERT_CHECK_LIST_COMMAND});Object.defineProperty(exports,"INSERT_ORDERED_LIST_COMMAND",{enumerable:!0,get:()=>F.INSERT_ORDERED_LIST_COMMAND});Object.defineProperty(exports,"INSERT_UNORDERED_LIST_COMMAND",{enumerable:!0,get:()=>F.INSERT_UNORDERED_LIST_COMMAND});Object.defineProperty(exports,"REMOVE_LIST_COMMAND",{enumerable:!0,get:()=>F.REMOVE_LIST_COMMAND});Object.defineProperty(exports,"BLUR_COMMAND",{enumerable:!0,get:()=>n.BLUR_COMMAND});Object.defineProperty(exports,"CLEAR_EDITOR_COMMAND",{enumerable:!0,get:()=>n.CLEAR_EDITOR_COMMAND});Object.defineProperty(exports,"CLICK_COMMAND",{enumerable:!0,get:()=>n.CLICK_COMMAND});Object.defineProperty(exports,"COMMAND_PRIORITY_CRITICAL",{enumerable:!0,get:()=>n.COMMAND_PRIORITY_CRITICAL});Object.defineProperty(exports,"COMMAND_PRIORITY_EDITOR",{enumerable:!0,get:()=>n.COMMAND_PRIORITY_EDITOR});Object.defineProperty(exports,"COMMAND_PRIORITY_HIGH",{enumerable:!0,get:()=>n.COMMAND_PRIORITY_HIGH});Object.defineProperty(exports,"COMMAND_PRIORITY_LOW",{enumerable:!0,get:()=>n.COMMAND_PRIORITY_LOW});Object.defineProperty(exports,"COMMAND_PRIORITY_NORMAL",{enumerable:!0,get:()=>n.COMMAND_PRIORITY_NORMAL});Object.defineProperty(exports,"COPY_COMMAND",{enumerable:!0,get:()=>n.COPY_COMMAND});Object.defineProperty(exports,"CUT_COMMAND",{enumerable:!0,get:()=>n.CUT_COMMAND});Object.defineProperty(exports,"DecoratorNode",{enumerable:!0,get:()=>n.DecoratorNode});Object.defineProperty(exports,"ElementNode",{enumerable:!0,get:()=>n.ElementNode});Object.defineProperty(exports,"FOCUS_COMMAND",{enumerable:!0,get:()=>n.FOCUS_COMMAND});Object.defineProperty(exports,"FORMAT_ELEMENT_COMMAND",{enumerable:!0,get:()=>n.FORMAT_ELEMENT_COMMAND});Object.defineProperty(exports,"FORMAT_TEXT_COMMAND",{enumerable:!0,get:()=>n.FORMAT_TEXT_COMMAND});Object.defineProperty(exports,"INDENT_CONTENT_COMMAND",{enumerable:!0,get:()=>n.INDENT_CONTENT_COMMAND});Object.defineProperty(exports,"INSERT_PARAGRAPH_COMMAND",{enumerable:!0,get:()=>n.INSERT_PARAGRAPH_COMMAND});Object.defineProperty(exports,"KEY_ENTER_COMMAND",{enumerable:!0,get:()=>n.KEY_ENTER_COMMAND});Object.defineProperty(exports,"KEY_ESCAPE_COMMAND",{enumerable:!0,get:()=>n.KEY_ESCAPE_COMMAND});Object.defineProperty(exports,"KEY_TAB_COMMAND",{enumerable:!0,get:()=>n.KEY_TAB_COMMAND});Object.defineProperty(exports,"OUTDENT_CONTENT_COMMAND",{enumerable:!0,get:()=>n.OUTDENT_CONTENT_COMMAND});Object.defineProperty(exports,"PASTE_COMMAND",{enumerable:!0,get:()=>n.PASTE_COMMAND});Object.defineProperty(exports,"REDO_COMMAND",{enumerable:!0,get:()=>n.REDO_COMMAND});Object.defineProperty(exports,"SELECTION_CHANGE_COMMAND",{enumerable:!0,get:()=>n.SELECTION_CHANGE_COMMAND});Object.defineProperty(exports,"TextNode",{enumerable:!0,get:()=>n.TextNode});Object.defineProperty(exports,"UNDO_COMMAND",{enumerable:!0,get:()=>n.UNDO_COMMAND});Object.defineProperty(exports,"createCommand",{enumerable:!0,get:()=>n.createCommand});exports.$createHorizontalRuleNode=se;exports.$isHorizontalRuleNode=Ue;exports.BareEditor=Ke;exports.BlockHandle=et;exports.ContextualEditor=Co;exports.DEFAULT_BLOCK_COMMANDS=Qe;exports.DEFAULT_INLINE_STYLE_PROPERTIES=qe;exports.DEFAULT_SLASH_COMMANDS=ho;exports.DockedEditor=po;exports.FloatingToolbar=Ze;exports.HR_TRANSFORMER=Ge;exports.HorizontalRuleNode=oe;exports.INSERT_HORIZONTAL_RULE_COMMAND=ce;exports.INSERT_IMAGE_COMMAND=xt;exports.LexicalEditorInput=yo;exports.LexicalToolbar=Ve;exports.SlashCommandPalette=bo;exports.TOGGLE_SLASH_COMMAND_PALETTE=Mt;exports.TOOLBAR_SEPARATOR=Ot;exports.applyMark=Ut;exports.buildInlineStyleImportMap=We;exports.buildStyleImportMap=ue;exports.createDefaultPluginConfig=pe;exports.createHeadlessEditor=de;exports.executeSlashCommand=St;exports.exportEditorToFile=_t;exports.exportToHtml=Y;exports.exportToMarkdown=K;exports.getCharacterCount=Wt;exports.getMarkdownTransformers=kt;exports.getNodesForPlugins=me;exports.getSelectionInfo=qt;exports.getTextContent=we;exports.getWordCount=Kt;exports.htmlToLexicalJson=ro;exports.importFileToEditor=vt;exports.importFromHtml=X;exports.importFromMarkdown=V;exports.insertTable=At;exports.insertTextAtCursor=Yt;exports.lexicalJsonToHtml=io;exports.lexicalJsonToMarkdown=no;exports.loadLexicalCore=ze;exports.loadOffsetUtils=Jt;exports.markdownToLexicalJson=oo;exports.registerAutoLinkPlugin=Bt;exports.registerClipboardPlugin=ye;exports.registerCodePlugin=Lt;exports.registerCodeShikiPlugin=It;exports.registerDragonPlugin=Se;exports.registerHashtagPlugin=$t;exports.registerHistoryPlugin=Ce;exports.registerHorizontalRulePlugin=Te;exports.registerLinkPlugin=Oe;exports.registerListPlugin=Ee;exports.registerMarkPlugin=jt;exports.registerOverflowPlugin=Gt;exports.registerPlainTextPlugin=be;exports.registerRichTextPlugin=he;exports.registerSlashCommandsPlugin=Nt;exports.registerTablePlugin=Ne;exports.registerYjsPlugin=Me;exports.removeMark=zt;
|
package/dist/lexical/index.es.js
CHANGED
|
@@ -28,12 +28,12 @@ import "@lexical/headless";
|
|
|
28
28
|
import { Use as ue, html as D, Task as Ke, attr as f, Value as U, WithElement as oe, OnDispose as ne, Ensure as Se, signal as z, on as ee, prop as j, When as pe, style as Y, aria as Pe, ForEach as Io, computedOf as Do } from "@tempots/dom";
|
|
29
29
|
import { L as qe } from "../link-portal-Cr2l9f3k.js";
|
|
30
30
|
import { T as Ye } from "../theme-kQZEeusG.js";
|
|
31
|
-
import { M as Et, a as le, b as Fo } from "../menu-
|
|
32
|
-
import { B as ye, I as Z } from "../translations-
|
|
33
|
-
import { E as Ho, a as gt } from "../editor-toolbar-group-
|
|
31
|
+
import { M as Et, a as le, b as Fo } from "../menu-BO6zqyfq.js";
|
|
32
|
+
import { B as ye, I as Z } from "../translations-DU9wTV1y.js";
|
|
33
|
+
import { E as Ho, a as gt } from "../editor-toolbar-group-BNTBMJCe.js";
|
|
34
34
|
import { delayedAnimationFrame as Po } from "@tempots/std";
|
|
35
|
-
import { b as Bo, c as $o } from "../toolbar-
|
|
36
|
-
import {
|
|
35
|
+
import { b as Bo, c as $o } from "../toolbar-CEBTTjHh.js";
|
|
36
|
+
import { a as Uo } from "../input-container-DCS5oJ4S.js";
|
|
37
37
|
const Vn = { separator: !0 };
|
|
38
38
|
class ge extends co {
|
|
39
39
|
static getType() {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("@tempots/dom"),F=require("./flyout-DC_tKaTG.cjs"),S=require("./session-id-B5lJMzbB.cjs");function x(b){const{items:u,placement:w="bottom-start",showDelay:g=0,hideDelay:y=100,mainAxisOffset:f=4,crossAxisOffset:D=0,showOn:k="click",closable:d=!0,onClose:E,onAction:i,ariaLabel:I,ariaLabelledBy:c}=b,l=S.sessionId("menu"),o=e.prop(-1),v=e.prop([]),m=e.prop(!1);let L=null;return m.onChange(p=>{p||E?.()}),F.Flyout({open:m,content:()=>e.WithElement(p=>{L=document.activeElement;const P=(t,a,s)=>{if(a.length===0)return-1;let n=t+s,A=0;for(;A<a.length;){n>=a.length&&(n=0),n<0&&(n=a.length-1);const r=a[n];if(r&&r.getAttribute("aria-disabled")!=="true")return n;n+=s,A++}return t},M=t=>{const a=v.value,s=o.value;switch(t.key){case"ArrowDown":t.preventDefault(),t.stopPropagation();const n=P(s,a,1);h(n,a);break;case"ArrowUp":t.preventDefault(),t.stopPropagation();const A=P(s,a,-1);h(A,a);break;case"Enter":case" ":if(t.preventDefault(),t.stopPropagation(),s>=0&&a[s]){const r=a[s];if(r.getAttribute("aria-disabled")==="true")return;const O=r.getAttribute("data-key");O&&i&&i(O),r.click(),m.set(!1)}break;case"Escape":m.set(!1);break;case"Home":t.preventDefault(),t.stopPropagation(),a.length>0&&h(0,a);break;case"End":t.preventDefault(),t.stopPropagation(),a.length>0&&h(a.length-1,a);break;case"ArrowRight":if(t.preventDefault(),t.stopPropagation(),s>=0&&a[s]){const r=a[s];r.classList.contains("bc-menu-item--has-submenu")&&r.dispatchEvent(new Event("mouseenter"))}break;case"ArrowLeft":t.preventDefault(),t.stopPropagation(),m.set(!1);break}},h=(t,a)=>{o.value>=0&&a[o.value]&&(a[o.value].classList.remove("bc-menu-item--focused"),a[o.value].removeAttribute("aria-selected")),t>=0&&a[t]&&(a[t].classList.add("bc-menu-item--focused"),a[t].setAttribute("aria-selected","true"),o.set(t),typeof a[t].scrollIntoView=="function"&&a[t].scrollIntoView({block:"nearest"}))},$=()=>{const t=Array.from(p.querySelectorAll('[role="menuitem"]'));if(v.set(t),t.length>0){const a=t.findIndex(s=>s.getAttribute("aria-disabled")!=="true");a>=0&&h(a,t)}},_=new MutationObserver($);return _.observe(p,{childList:!0,subtree:!0}),setTimeout(()=>{$(),p.focus()},0),document.addEventListener("keydown",M,!0),e.Fragment(e.OnDispose(()=>{_.disconnect(),document.removeEventListener("keydown",M,!0),L&&L.focus()}),e.attr.class("bc-menu"),e.attr.id(l),e.attr.role("menu"),e.attr.tabindex(-1),e.aria.orientation("vertical"),I?e.aria.label(I):e.Empty,c?e.aria.labelledby(c):e.Empty,e.aria.activedescendant(o.map(t=>{const a=v.value;return t>=0&&a[t]?a[t].id||`${l}-item-${t}`:""})),e.on.click(t=>{const s=t.target.closest('[role="menuitem"]');if(s&&s.getAttribute("aria-disabled")!=="true"){const n=s.getAttribute("data-key");n&&i&&i(n),m.set(!1)}}),e.html.div(e.attr.class("sr-only"),e.aria.live("polite"),e.aria.atomic(!0),o.map(t=>{const a=v.value;if(t>=0&&a[t]){const s=a[t].textContent||"";return a[t].getAttribute("aria-disabled")==="true"?`${s}, disabled`:`${s}, ${t+1} of ${a.length}`}return""})),...u())}),placement:w,showDelay:g,hideDelay:y,mainAxisOffset:f,crossAxisOffset:D,showOn:k,closable:d,role:"menu"})}function q(b){const{key:u,content:w,before:g,after:y,disabled:f=!1,onClick:D,ariaLabel:k,submenu:d,submenuPlacement:E="right-start"}=b,i=u??S.sessionId("menu-item"),I=`menu-item-${i}`,c=d!=null;return e.html.div(e.attr.class(e.computedOf(f)(l=>`bc-menu-item ${l?"bc-menu-item--disabled":""} ${c?"bc-menu-item--has-submenu":""}`)),e.attr.id(I),e.attr.role("menuitem"),e.attr.tabindex(-1),e.dataAttr("key",i),e.aria.disabled(f),e.aria.selected(!1),c?e.aria.expanded(!1):e.Empty,k?e.aria.label(k):e.Empty,e.on.click(l=>{if(e.Value.get(f)){l.preventDefault(),l.stopPropagation();return}D?.()}),g&&e.html.span(e.attr.class("bc-menu-item__start"),g),e.html.span(e.attr.class("bc-menu-item__content"),w),y&&e.html.span(e.attr.class("bc-menu-item__end"),y),c&&d?F.Flyout({content:()=>e.Fragment(e.attr.class("bc-menu bc-submenu"),e.attr.role("menu"),...d()),placement:E,showOn:"hover",hasPopup:"menu",showDelay:100,hideDelay:300,mainAxisOffset:0,crossAxisOffset:0,role:"menu"}):e.Empty)}function C(b={}){const{label:u}=b;return e.html.div(e.attr.class("bc-menu-separator"),e.attr.role("separator"),e.aria.orientation("horizontal"),u&&e.html.span(e.attr.class("bc-menu-separator__label"),u))}exports.Menu=x;exports.MenuItem=q;exports.MenuSeparator=C;
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { prop as M, WithElement as z, Fragment as V, OnDispose as B, attr as s, aria as o, Empty as k, on as K, html as c, computedOf as H, dataAttr as N, Value as R } from "@tempots/dom";
|
|
2
|
+
import { F as T } from "./flyout-CuKFh_T7.js";
|
|
3
|
+
import { s as q } from "./session-id-3KiilioY.js";
|
|
4
|
+
function G(d) {
|
|
5
|
+
const {
|
|
6
|
+
items: m,
|
|
7
|
+
placement: L = "bottom-start",
|
|
8
|
+
showDelay: v = 0,
|
|
9
|
+
hideDelay: A = 100,
|
|
10
|
+
mainAxisOffset: p = 4,
|
|
11
|
+
crossAxisOffset: O = 0,
|
|
12
|
+
showOn: I = "click",
|
|
13
|
+
closable: h = !0,
|
|
14
|
+
onClose: P,
|
|
15
|
+
onAction: u,
|
|
16
|
+
ariaLabel: w,
|
|
17
|
+
ariaLabelledBy: b
|
|
18
|
+
} = d, i = q("menu"), l = M(-1), D = M([]), f = M(!1);
|
|
19
|
+
let $ = null;
|
|
20
|
+
return f.onChange((g) => {
|
|
21
|
+
g || P?.();
|
|
22
|
+
}), T({
|
|
23
|
+
open: f,
|
|
24
|
+
content: () => z((g) => {
|
|
25
|
+
$ = document.activeElement;
|
|
26
|
+
const x = (e, t, a) => {
|
|
27
|
+
if (t.length === 0) return -1;
|
|
28
|
+
let n = e + a, E = 0;
|
|
29
|
+
for (; E < t.length; ) {
|
|
30
|
+
n >= t.length && (n = 0), n < 0 && (n = t.length - 1);
|
|
31
|
+
const r = t[n];
|
|
32
|
+
if (r && r.getAttribute("aria-disabled") !== "true")
|
|
33
|
+
return n;
|
|
34
|
+
n += a, E++;
|
|
35
|
+
}
|
|
36
|
+
return e;
|
|
37
|
+
}, F = (e) => {
|
|
38
|
+
const t = D.value, a = l.value;
|
|
39
|
+
switch (e.key) {
|
|
40
|
+
case "ArrowDown":
|
|
41
|
+
e.preventDefault(), e.stopPropagation();
|
|
42
|
+
const n = x(a, t, 1);
|
|
43
|
+
y(n, t);
|
|
44
|
+
break;
|
|
45
|
+
case "ArrowUp":
|
|
46
|
+
e.preventDefault(), e.stopPropagation();
|
|
47
|
+
const E = x(a, t, -1);
|
|
48
|
+
y(E, t);
|
|
49
|
+
break;
|
|
50
|
+
case "Enter":
|
|
51
|
+
case " ":
|
|
52
|
+
if (e.preventDefault(), e.stopPropagation(), a >= 0 && t[a]) {
|
|
53
|
+
const r = t[a];
|
|
54
|
+
if (r.getAttribute("aria-disabled") === "true")
|
|
55
|
+
return;
|
|
56
|
+
const _ = r.getAttribute("data-key");
|
|
57
|
+
_ && u && u(_), r.click(), f.set(!1);
|
|
58
|
+
}
|
|
59
|
+
break;
|
|
60
|
+
case "Escape":
|
|
61
|
+
f.set(!1);
|
|
62
|
+
break;
|
|
63
|
+
case "Home":
|
|
64
|
+
e.preventDefault(), e.stopPropagation(), t.length > 0 && y(0, t);
|
|
65
|
+
break;
|
|
66
|
+
case "End":
|
|
67
|
+
e.preventDefault(), e.stopPropagation(), t.length > 0 && y(t.length - 1, t);
|
|
68
|
+
break;
|
|
69
|
+
case "ArrowRight":
|
|
70
|
+
if (e.preventDefault(), e.stopPropagation(), a >= 0 && t[a]) {
|
|
71
|
+
const r = t[a];
|
|
72
|
+
r.classList.contains(
|
|
73
|
+
"bc-menu-item--has-submenu"
|
|
74
|
+
) && r.dispatchEvent(new Event("mouseenter"));
|
|
75
|
+
}
|
|
76
|
+
break;
|
|
77
|
+
case "ArrowLeft":
|
|
78
|
+
e.preventDefault(), e.stopPropagation(), f.set(!1);
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
}, y = (e, t) => {
|
|
82
|
+
l.value >= 0 && t[l.value] && (t[l.value].classList.remove(
|
|
83
|
+
"bc-menu-item--focused"
|
|
84
|
+
), t[l.value].removeAttribute("aria-selected")), e >= 0 && t[e] && (t[e].classList.add("bc-menu-item--focused"), t[e].setAttribute("aria-selected", "true"), l.set(e), typeof t[e].scrollIntoView == "function" && t[e].scrollIntoView({ block: "nearest" }));
|
|
85
|
+
}, S = () => {
|
|
86
|
+
const e = Array.from(
|
|
87
|
+
g.querySelectorAll('[role="menuitem"]')
|
|
88
|
+
);
|
|
89
|
+
if (D.set(e), e.length > 0) {
|
|
90
|
+
const t = e.findIndex(
|
|
91
|
+
(a) => a.getAttribute("aria-disabled") !== "true"
|
|
92
|
+
);
|
|
93
|
+
t >= 0 && y(t, e);
|
|
94
|
+
}
|
|
95
|
+
}, C = new MutationObserver(S);
|
|
96
|
+
return C.observe(g, { childList: !0, subtree: !0 }), setTimeout(() => {
|
|
97
|
+
S(), g.focus();
|
|
98
|
+
}, 0), document.addEventListener("keydown", F, !0), V(
|
|
99
|
+
B(() => {
|
|
100
|
+
C.disconnect(), document.removeEventListener("keydown", F, !0), $ && $.focus();
|
|
101
|
+
}),
|
|
102
|
+
s.class("bc-menu"),
|
|
103
|
+
s.id(i),
|
|
104
|
+
s.role("menu"),
|
|
105
|
+
s.tabindex(-1),
|
|
106
|
+
o.orientation("vertical"),
|
|
107
|
+
w ? o.label(w) : k,
|
|
108
|
+
b ? o.labelledby(b) : k,
|
|
109
|
+
o.activedescendant(
|
|
110
|
+
l.map((e) => {
|
|
111
|
+
const t = D.value;
|
|
112
|
+
return e >= 0 && t[e] ? t[e].id || `${i}-item-${e}` : "";
|
|
113
|
+
})
|
|
114
|
+
),
|
|
115
|
+
K.click((e) => {
|
|
116
|
+
const a = e.target.closest('[role="menuitem"]');
|
|
117
|
+
if (a && a.getAttribute("aria-disabled") !== "true") {
|
|
118
|
+
const n = a.getAttribute("data-key");
|
|
119
|
+
n && u && u(n), f.set(!1);
|
|
120
|
+
}
|
|
121
|
+
}),
|
|
122
|
+
// Live region for screen reader announcements
|
|
123
|
+
c.div(
|
|
124
|
+
s.class("sr-only"),
|
|
125
|
+
o.live("polite"),
|
|
126
|
+
o.atomic(!0),
|
|
127
|
+
l.map((e) => {
|
|
128
|
+
const t = D.value;
|
|
129
|
+
if (e >= 0 && t[e]) {
|
|
130
|
+
const a = t[e].textContent || "";
|
|
131
|
+
return t[e].getAttribute("aria-disabled") === "true" ? `${a}, disabled` : `${a}, ${e + 1} of ${t.length}`;
|
|
132
|
+
}
|
|
133
|
+
return "";
|
|
134
|
+
})
|
|
135
|
+
),
|
|
136
|
+
...m()
|
|
137
|
+
);
|
|
138
|
+
}),
|
|
139
|
+
placement: L,
|
|
140
|
+
showDelay: v,
|
|
141
|
+
hideDelay: A,
|
|
142
|
+
mainAxisOffset: p,
|
|
143
|
+
crossAxisOffset: O,
|
|
144
|
+
showOn: I,
|
|
145
|
+
closable: h,
|
|
146
|
+
role: "menu"
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
function J(d) {
|
|
150
|
+
const {
|
|
151
|
+
key: m,
|
|
152
|
+
content: L,
|
|
153
|
+
before: v,
|
|
154
|
+
after: A,
|
|
155
|
+
disabled: p = !1,
|
|
156
|
+
onClick: O,
|
|
157
|
+
ariaLabel: I,
|
|
158
|
+
submenu: h,
|
|
159
|
+
submenuPlacement: P = "right-start"
|
|
160
|
+
} = d, u = m ?? q("menu-item"), w = `menu-item-${u}`, b = h != null;
|
|
161
|
+
return c.div(
|
|
162
|
+
s.class(
|
|
163
|
+
H(p)(
|
|
164
|
+
(i) => `bc-menu-item ${i ? "bc-menu-item--disabled" : ""} ${b ? "bc-menu-item--has-submenu" : ""}`
|
|
165
|
+
)
|
|
166
|
+
),
|
|
167
|
+
s.id(w),
|
|
168
|
+
s.role("menuitem"),
|
|
169
|
+
s.tabindex(-1),
|
|
170
|
+
N("key", u),
|
|
171
|
+
o.disabled(p),
|
|
172
|
+
o.selected(!1),
|
|
173
|
+
// Will be updated by focus management
|
|
174
|
+
b ? o.expanded(!1) : k,
|
|
175
|
+
I ? o.label(I) : k,
|
|
176
|
+
K.click((i) => {
|
|
177
|
+
if (R.get(p)) {
|
|
178
|
+
i.preventDefault(), i.stopPropagation();
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
O?.();
|
|
182
|
+
}),
|
|
183
|
+
// Before content
|
|
184
|
+
v && c.span(s.class("bc-menu-item__start"), v),
|
|
185
|
+
// Main content
|
|
186
|
+
c.span(s.class("bc-menu-item__content"), L),
|
|
187
|
+
// After content
|
|
188
|
+
A && c.span(s.class("bc-menu-item__end"), A),
|
|
189
|
+
// Submenu (if present)
|
|
190
|
+
b && h ? T({
|
|
191
|
+
content: () => V(
|
|
192
|
+
s.class("bc-menu bc-submenu"),
|
|
193
|
+
s.role("menu"),
|
|
194
|
+
...h()
|
|
195
|
+
),
|
|
196
|
+
placement: P,
|
|
197
|
+
showOn: "hover",
|
|
198
|
+
hasPopup: "menu",
|
|
199
|
+
showDelay: 100,
|
|
200
|
+
hideDelay: 300,
|
|
201
|
+
mainAxisOffset: 0,
|
|
202
|
+
crossAxisOffset: 0,
|
|
203
|
+
role: "menu"
|
|
204
|
+
}) : k
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
function Q(d = {}) {
|
|
208
|
+
const { label: m } = d;
|
|
209
|
+
return c.div(
|
|
210
|
+
s.class("bc-menu-separator"),
|
|
211
|
+
s.role("separator"),
|
|
212
|
+
o.orientation("horizontal"),
|
|
213
|
+
m && c.span(s.class("bc-menu-separator__label"), m)
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
export {
|
|
217
|
+
G as M,
|
|
218
|
+
J as a,
|
|
219
|
+
Q as b
|
|
220
|
+
};
|