@ngrok/mantle 0.76.4 → 0.76.5
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/agent.json +1 -1
- package/dist/code-block.d.ts +76 -1
- package/dist/code-block.js +7 -2
- package/dist/code-block_highlight-utils.js +1 -1
- package/dist/command.d.ts +1 -1
- package/dist/data-table.d.ts +318 -3
- package/dist/data-table.js +1 -1
- package/dist/input.d.ts +3 -3
- package/dist/llms.txt +1 -1
- package/dist/resolve-pre-rendered-props-CF9-Qy2H.js +12 -0
- package/dist/theme.d.ts +3 -3
- package/package.json +1 -1
- package/dist/resolve-pre-rendered-props-D9nlC6xE.js +0 -12
package/dist/agent.json
CHANGED
package/dist/code-block.d.ts
CHANGED
|
@@ -416,6 +416,81 @@ declare const CodeBlock: {
|
|
|
416
416
|
} & import("react").RefAttributes<HTMLHeadingElement>>;
|
|
417
417
|
};
|
|
418
418
|
//#endregion
|
|
419
|
+
//#region src/components/code-block/json-highlight.d.ts
|
|
420
|
+
/**
|
|
421
|
+
* Tokenize a JSON string into the same per-line, CSS-variable-colored span markup
|
|
422
|
+
* that Mantle's server/build-time Shiki highlighter produces — without shipping
|
|
423
|
+
* Shiki (or any grammar/theme/WASM) to the browser.
|
|
424
|
+
*
|
|
425
|
+
* Byte-for-byte parity with `extractHighlightedCodeInnerHtml(shiki.codeToHtml(code, …))`
|
|
426
|
+
* is guaranteed for **canonical `JSON.stringify` output** — the only shape
|
|
427
|
+
* {@link jsonCodeBlockValue} ever feeds it (2-space indent: an opener is always
|
|
428
|
+
* followed by a newline, never inline whitespace; line endings are `\n`). That
|
|
429
|
+
* exact-parity set is locked by the `json-*.fixtures` golden tests. Other valid
|
|
430
|
+
* but non-canonical JSON is highlighted on a best-effort basis and may diverge
|
|
431
|
+
* from Shiki in cosmetic ways: arbitrary inter-token whitespace attaches to the
|
|
432
|
+
* following token rather than the preceding one, and scopes Shiki treats
|
|
433
|
+
* specially (e.g. `invalid.illegal` escapes) are colored as ordinary tokens.
|
|
434
|
+
* CRLF input is normalized to `\n`.
|
|
435
|
+
*
|
|
436
|
+
* Expects well-formed JSON. The result is the inner HTML for a `<code>` element;
|
|
437
|
+
* feed it through `decorateHighlightedHtml` (as `jsonCodeBlockValue` does) for the
|
|
438
|
+
* final `CodeBlock.Code` markup.
|
|
439
|
+
*
|
|
440
|
+
* @example
|
|
441
|
+
* ```ts
|
|
442
|
+
* jsonToShikiHtml('{\n "id": 1\n}');
|
|
443
|
+
* // '<span class="line"><span style="color:var(--shiki-foreground)">{</span></span>\n…'
|
|
444
|
+
* ```
|
|
445
|
+
*/
|
|
446
|
+
declare function jsonToShikiHtml(code: string): string;
|
|
447
|
+
/** Options for {@link jsonCodeBlockValue}. */
|
|
448
|
+
type JsonCodeBlockValueOptions = {
|
|
449
|
+
/**
|
|
450
|
+
* Whether to render line numbers. Defaults to `false` — detail panels usually
|
|
451
|
+
* read better without a gutter.
|
|
452
|
+
*/
|
|
453
|
+
showLineNumbers?: boolean | undefined;
|
|
454
|
+
/**
|
|
455
|
+
* Whether multi-line objects and arrays get collapsible fold toggles, matching
|
|
456
|
+
* every other JSON `CodeBlock`. Uses the same `computeJsonFoldRanges` the
|
|
457
|
+
* server/build pipeline uses, so the fold markup is identical. Defaults to
|
|
458
|
+
* `true`; set `false` for a flat, non-collapsible panel.
|
|
459
|
+
*/
|
|
460
|
+
foldable?: boolean | undefined;
|
|
461
|
+
};
|
|
462
|
+
/**
|
|
463
|
+
* Build a `MantleCodeBlockValue` that renders a value as syntax-highlighted JSON
|
|
464
|
+
* entirely on the client — no Shiki runtime, no build-time plugin, no server
|
|
465
|
+
* roundtrip. The value is `JSON.stringify`'d (2-space indent), tokenized to
|
|
466
|
+
* Shiki-identical markup by {@link jsonToShikiHtml}, and decorated with the same
|
|
467
|
+
* `decorateHighlightedHtml` the server pipeline uses, so it looks identical to a
|
|
468
|
+
* server/build-time highlighted block and adapts to light/dark themes for free.
|
|
469
|
+
*
|
|
470
|
+
* By default, multi-line objects and arrays get collapsible fold toggles (opt
|
|
471
|
+
* out with `foldable: false`) — also identical to server/build-time blocks,
|
|
472
|
+
* since both compute ranges with the same `computeJsonFoldRanges`.
|
|
473
|
+
*
|
|
474
|
+
* Pass the result straight to `CodeBlock.Code`'s `value` prop. Ideal for
|
|
475
|
+
* inspecting a row's underlying object inside a `DataTable.ExpandedRow`.
|
|
476
|
+
*
|
|
477
|
+
* @example
|
|
478
|
+
* ```tsx
|
|
479
|
+
* import { CodeBlock, jsonCodeBlockValue } from "@ngrok/mantle/code-block";
|
|
480
|
+
*
|
|
481
|
+
* <CodeBlock.Root>
|
|
482
|
+
* <CodeBlock.Body>
|
|
483
|
+
* <CodeBlock.CopyButton />
|
|
484
|
+
* <CodeBlock.Code value={jsonCodeBlockValue(row.original)} />
|
|
485
|
+
* </CodeBlock.Body>
|
|
486
|
+
* </CodeBlock.Root>
|
|
487
|
+
* ```
|
|
488
|
+
*/
|
|
489
|
+
declare function jsonCodeBlockValue(value: unknown, {
|
|
490
|
+
showLineNumbers,
|
|
491
|
+
foldable
|
|
492
|
+
}?: JsonCodeBlockValueOptions): MantleCodeBlockValue;
|
|
493
|
+
//#endregion
|
|
419
494
|
//#region src/components/code-block/escape-html.d.ts
|
|
420
495
|
/**
|
|
421
496
|
* Escapes special HTML characters in a string to their corresponding
|
|
@@ -447,4 +522,4 @@ declare function escapeHtml(value: string): string;
|
|
|
447
522
|
*/
|
|
448
523
|
declare function hasMoreThanNLines(value: string, maxLines: number): boolean;
|
|
449
524
|
//#endregion
|
|
450
|
-
export { CodeBlock, type CodeBlockPreElementInput, type ComputeFoldRangesInput, type DefaultMeta, type FoldExplanation, type FoldLine, type FoldScope, type FoldStrategy, type FoldToken, type FoldableRange, type Indentation, type LineRange, type MantleCodeBlockValue, type MantleCodeOptions, type Meta, type MetaInput, type Mode, type ResolvePreRenderedCodeBlockPropsInput, type ResolvePreRenderedCodeBlockPropsResult, type ResolvedPreRenderedCodeBlockProps, type SupportedLanguage, computeFoldRanges, computeJsonFoldRanges, createMantleCodeBlockValue, decorateHighlightedHtml, defaultMeta, escapeHtml, finalizeFoldRanges, foldStrategyFor, hasMoreThanNLines, inferIndentation, isIndentation, isSupportedLanguage, mantleCode, normalizeIndentation, normalizeValue, parseCodeBlockHighlightLines, parseCodeBlockLineNumberStart, parseCodeBlockShowLineNumbers, parseLanguage, parseMetastring, resolvePreRenderedCodeBlockProps, supportedLanguages, tokenizeMetastring };
|
|
525
|
+
export { CodeBlock, type CodeBlockPreElementInput, type ComputeFoldRangesInput, type DefaultMeta, type FoldExplanation, type FoldLine, type FoldScope, type FoldStrategy, type FoldToken, type FoldableRange, type Indentation, type JsonCodeBlockValueOptions, type LineRange, type MantleCodeBlockValue, type MantleCodeOptions, type Meta, type MetaInput, type Mode, type ResolvePreRenderedCodeBlockPropsInput, type ResolvePreRenderedCodeBlockPropsResult, type ResolvedPreRenderedCodeBlockProps, type SupportedLanguage, computeFoldRanges, computeJsonFoldRanges, createMantleCodeBlockValue, decorateHighlightedHtml, defaultMeta, escapeHtml, finalizeFoldRanges, foldStrategyFor, hasMoreThanNLines, inferIndentation, isIndentation, isSupportedLanguage, jsonCodeBlockValue, jsonToShikiHtml, mantleCode, normalizeIndentation, normalizeValue, parseCodeBlockHighlightLines, parseCodeBlockLineNumberStart, parseCodeBlockShowLineNumbers, parseLanguage, parseMetastring, resolvePreRenderedCodeBlockProps, supportedLanguages, tokenizeMetastring };
|
package/dist/code-block.js
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
import{t as e}from"./cx-CBSnSC36.js";import{t}from"./icon-C8bYBIHW.js";import{t as n}from"./slot-CV5fmqFr.js";import{t as r}from"./icon-button-DUNHVWpb.js";import{t as i}from"./compose-refs-Cjf2gfB8.js";import{t as a}from"./use-copy-to-clipboard-BLpquU9d.js";import{t as o}from"./traffic-policy-file-0g5RXFqu.js";import{S as s,_ as c,a as l,b as u,c as d,d as f,f as p,g as m,h,i as g,l as _,m as v,n as y,o as b,p as x,r as S,s as C,t as w,u as T,v as E,y as D}from"./resolve-pre-rendered-props-
|
|
2
|
-
|
|
1
|
+
import{t as e}from"./cx-CBSnSC36.js";import{t}from"./icon-C8bYBIHW.js";import{t as n}from"./slot-CV5fmqFr.js";import{t as r}from"./icon-button-DUNHVWpb.js";import{t as i}from"./compose-refs-Cjf2gfB8.js";import{t as a}from"./use-copy-to-clipboard-BLpquU9d.js";import{t as o}from"./traffic-policy-file-0g5RXFqu.js";import{S as s,_ as c,a as l,b as u,c as d,d as f,f as p,g as m,h,i as g,l as _,m as v,n as y,o as b,p as x,r as S,s as C,t as w,u as T,v as E,y as D}from"./resolve-pre-rendered-props-CF9-Qy2H.js";import{CaretDownIcon as O}from"@phosphor-icons/react/CaretDown";import{createContext as ee,forwardRef as k,useCallback as A,useContext as te,useEffect as j,useId as ne,useLayoutEffect as re,useMemo as M,useRef as N,useState as P}from"react";import F from"tiny-invariant";import{jsx as I,jsxs as ie}from"react/jsx-runtime";import{CheckIcon as ae}from"@phosphor-icons/react/Check";import{CopyIcon as oe}from"@phosphor-icons/react/Copy";import{FileTextIcon as se}from"@phosphor-icons/react/FileText";import{TerminalIcon as ce}from"@phosphor-icons/react/Terminal";import{Content as le,List as ue,Root as de,Trigger as fe}from"@radix-ui/react-tabs";function L(e){let t=-1;for(let n=0;n<e.length;n++){let r=e[n];if(r===`&`||r===`<`||r===`>`||r===`"`||r===`'`){t=n;break}}if(t===-1)return e;let n=e.slice(0,t);for(let r=t;r<e.length;r++){let t=e[r];switch(t){case`&`:n+=`&`;break;case`<`:n+=`<`;break;case`>`:n+=`>`;break;case`"`:n+=`"`;break;case`'`:n+=`'`;break;default:n+=t}}return n}const R=new WeakMap;function z(e){let t=new Set;if(e==null||e===``)return t;for(let n of e.split(` `))n!==``&&t.add(n);return t}function pe(e){let t=R.get(e);if(t!=null&&ge(t))return t;let n=new Map,r=new WeakMap,i=e.querySelectorAll(`[data-fold-regions]`);for(let e=0;e<i.length;e+=1){let t=i[e];if(!(t instanceof HTMLElement))continue;let a=z(t.dataset.foldRegions);if(a.size!==0){r.set(t,a);for(let e of a){let r=n.get(e);r??(r=[],n.set(e,r)),r.push(t)}}}let a={regionToLines:n,lineToRegions:r};return R.set(e,a),a}function me(e){R.delete(e)}function he(e){me(e),e.removeAttribute(`data-folded-regions`)}function ge(e){for(let t of e.regionToLines.values()){if(t.length===0)continue;let e=t[0];if(e!=null)return e.isConnected}return!0}function _e(e,t,n){let r=!1;for(let e of n)if(t.has(e)){r=!0;break}r?e.dataset.foldHidden=`true`:delete e.dataset.foldHidden}function ve(e){let t=e.dataset.foldLine;if(t==null||t===``)return!1;let n=e.closest(`[data-slot='code-block-code']`)?.querySelector(`code`);if(n==null)return!1;let r=z(n.getAttribute(`data-folded-regions`)),i=!r.has(t);i?r.add(t):r.delete(t),r.size===0?n.removeAttribute(`data-folded-regions`):n.setAttribute(`data-folded-regions`,[...r].join(` `)),e.setAttribute(`aria-expanded`,i?`false`:`true`);let{regionToLines:a,lineToRegions:o}=pe(n),s=a.get(t);if(s!=null)for(let e of s){let t=o.get(e);t!=null&&_e(e,r,t)}return!0}function ye(e){let t=e=>{let t=e.target;if(!(t instanceof Element))return;let n=t.closest(`.mantle-code-fold-toggle`);n instanceof HTMLButtonElement&&ve(n)};return e.addEventListener(`click`,t),()=>{e.removeEventListener(`click`,t)}}const B=ee(null);function V(){let e=te(B);return F(e!=null,`CodeBlock subcomponents must be rendered within a <CodeBlock.Root>.`),e}const H=k(({asChild:t=!1,className:r,defaultTab:i,activeTab:a,onActiveTabChange:o,...s},c)=>{let l=N(``),[u,d]=P(!1),[f,p]=P(!1),[m,h]=P(void 0),g=A(e=>{h(t=>(F(t==null,`You can only render a single CodeBlock.Code within a CodeBlock.`),e))},[]),_=A(e=>{h(t=>{F(t===e,`You can only render a single CodeBlock.Code within a CodeBlock.`)})},[]),v=M(()=>({codeId:m,copyTextRef:l,hasCodeExpander:u,isCodeExpanded:f,registerCodeId:g,setHasCodeExpander:d,setIsCodeExpanded:p,unregisterCodeId:_}),[m,u,f,g,_]),y=i!=null||a!=null,b=I(t?n:`div`,{"data-slot":`code-block`,className:e(`text-mono w-full overflow-hidden rounded-md border border-gray-300 bg-card font-mono`,`[&_svg]:shrink-0`,r),ref:c,...s});return I(B.Provider,{value:v,children:y?I(de,{asChild:!0,defaultValue:i,value:a,onValueChange:o,children:b}):b})});H.displayName=`CodeBlock`;const U=k(({asChild:t=!1,className:r,...i},a)=>I(t?n:`div`,{"data-slot":`code-block-body`,className:e(`relative`,r),ref:a,...i}));U.displayName=`CodeBlockBody`;const be=/SHIKI_VAL_(\d+)/g;function xe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}const W=new Map;function Se(e){if(e==null||e.length===0)return be;let t=W.get(e);return t??(W.size>=500&&W.clear(),t=RegExp(`${xe(e)}(\\d+)__`,`g`),W.set(e,t)),t}function G(e,t,n,r){if(n==null){if(!e.includes(`SHIKI_VAL_`))return e}else if(!e.includes(n))return e;return e.replaceAll(Se(n),(e,n)=>{let i=Number.parseInt(n,10);return Number.isNaN(i)||i<0||i>=t.length?e:r(t[i])})}function Ce(e,t,n){return G(e,t,n,e=>L(String(e)))}function we(e,t,n){return G(e,t,n,e=>String(e))}const K=k(({className:t,style:n,value:r,...a},o)=>{let s=ne(),c=N(null),{copyTextRef:l,hasCodeExpander:u,isCodeExpanded:d,registerCodeId:f,unregisterCodeId:p}=V(),{language:m,code:h,"~preValToken":g,"~preVals":_,"~highlightLines":v,"~lineNumberStart":y,"~preHtml":b,"~showLineNumbers":x}=r,S=v,C=y??1,w=x??!1,T=M(()=>_!=null&&_.length>0?we(h,_,g):h,[g,_,h]);re(()=>{l.current=T},[l,T]),j(()=>(f(s),()=>{p(s)}),[s,f,p]);let E=M(()=>{if(b!=null)return _!=null&&_.length>0?Ce(b,_,g):b},[b,g,_]);j(()=>{let e=c.current;if(e==null)return;let t=e.querySelector(`code`);return t!=null&&he(t),ye(e)},[E]);let D=E!=null,O=E??L(T),ee=M(()=>({__html:O}),[O]);return I(`pre`,{"data-slot":`code-block-code`,"aria-expanded":u?d:void 0,className:e(`scrollbar overflow-x-auto overflow-y-hidden py-4`,!D&&`pr-14`,`data-[mantle-line-numbers~='false']:pl-4`,`text-mono m-0 font-mono outline-hidden`,`aria-collapsed:max-h-[13.6rem]`,t),"data-highlighted":D?`true`:`false`,"data-lang":m,"data-mantle-highlight-lines":D&&S!=null&&S.length>0?S.join(`,`):void 0,"data-mantle-line-number-start":D&&w?String(C):`1`,"data-mantle-line-numbers":D&&w?`true`:`false`,id:s,ref:i(c,o),style:{...n,"--mantle-line-number-start":String(C),tabSize:2,MozTabSize:2},...a,children:I(`code`,{className:`text-size-inherit block min-w-full w-max`,dangerouslySetInnerHTML:ee})})});K.displayName=`CodeBlockCode`;const q=k(({asChild:t=!1,className:r,...i},a)=>I(t?n:`div`,{"data-slot":`code-block-header`,className:e(`flex items-center gap-1 border-b border-gray-300 bg-base px-4 py-2 text-gray-700`,r),ref:a,...i}));q.displayName=`CodeBlockHeader`;const J=k(({asChild:t=!1,className:r,...i},a)=>I(t?n:`h3`,{"data-slot":`code-block-title`,ref:a,className:e(`text-mono m-0 font-mono font-normal`,r),...i}));J.displayName=`CodeBlockTitle`;const Y=k(({className:e,label:t=`Copy code`,onCopy:n,onCopyError:i,onClick:o,...s},c)=>{let{copyTextRef:l}=V(),u=a(),[d,f]=P(!1),p=N(void 0);return j(()=>()=>{p.current!=null&&clearTimeout(p.current)},[]),I(`span`,{"data-slot":`code-block-copy-button`,className:`absolute right-3 top-3 z-10 inline-flex size-7 items-center justify-center rounded-[var(--icon-button-border-radius,0.375rem)] bg-card`,children:I(r,{type:`button`,appearance:`ghost`,size:`sm`,label:t,icon:I(d?ae:oe,{}),className:e,ref:c,onClick:async e=>{try{if(o?.(e),e.defaultPrevented){p.current!=null&&clearTimeout(p.current);return}let t=l.current;await u(t),n?.(t),f(!0),p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{f(!1)},2e3)}catch(e){i?.(e)}},...s})})});Y.displayName=`CodeBlockCopyButton`;const X=k(({asChild:r=!1,className:i,onClick:a,...o},s)=>{let{codeId:c,isCodeExpanded:l,setIsCodeExpanded:u,setHasCodeExpander:d}=V();return j(()=>(d(!0),()=>{d(!1)}),[d]),ie(r?n:`button`,{...o,"data-slot":`code-block-expander-button`,"aria-controls":c,"aria-expanded":l,className:e(`flex w-full items-center justify-center gap-0.5 border-t border-gray-300 bg-card px-4 py-2 font-sans text-gray-700 hover:bg-gray-100`,i),ref:s,type:`button`,onClick:e=>{u(e=>!e),a?.(e)},children:[l?`Show less`:`Show more`,` `,I(t,{svg:I(O,{weight:`bold`}),className:e(`size-4`,l&&`rotate-180`,`transition-all duration-150`)})]})});X.displayName=`CodeBlockExpanderButton`;function Z({className:e,preset:n,svg:r,...i}){let a=r;if(n!=null)switch(n){case`file`:a=I(se,{weight:`fill`});break;case`cli`:a=I(ce,{weight:`fill`});break;case`traffic-policy`:a=I(o,{});break}return I(t,{"data-slot":`code-block-icon`,className:e,svg:a,...i})}Z.displayName=`CodeBlockIcon`;const Q=k(({className:t,...n},r)=>I(ue,{"data-slot":`code-block-tab-list`,className:e(`flex items-center gap-1`,t),ref:r,...n}));Q.displayName=`CodeBlockTabList`;const Te=k(({className:t,...n},r)=>I(fe,{"data-slot":`code-block-tab-trigger`,className:e(`cursor-pointer rounded px-1.5 py-0.5 text-xs font-medium`,`text-gray-600 outline-hidden`,`hover:text-gray-900`,`data-[state=active]:bg-neutral-500/15 data-[state=active]:text-strong`,`focus-visible:ring-focus-accent focus-visible:ring-4`,t),ref:r,...n}));Te.displayName=`CodeBlockTabTrigger`;const Ee=k((e,t)=>I(le,{"data-slot":`code-block-tab-content`,ref:t,...e}));Ee.displayName=`CodeBlockTabContent`;const De={Root:H,Body:U,Code:K,CopyButton:Y,ExpanderButton:X,Header:q,Icon:Z,TabContent:Ee,TabList:Q,TabTrigger:Te,Title:J},Oe=`var(--shiki-foreground)`;function ke(e){return e.replace(/[&<]/g,e=>e===`&`?`&`:`<`)}function Ae(e){return e===` `||e===` `||e===`
|
|
2
|
+
`||e===`\r`||e===`{`||e===`}`||e===`[`||e===`]`||e===`:`||e===`,`||e===`"`}function je(e,t,n){let r=e.length,i=[],a=`"`,o=t+1;for(;o<r;){let t=e[o];if(t===`\\`){let t=e[o+1]===`u`&&/^[0-9a-fA-F]{4}$/.test(e.slice(o+2,o+6))?6:2;a!==``&&(i.push({text:a,isEscape:!1}),a=``),i.push({text:e.slice(o,o+t),isEscape:!0}),o+=t;continue}if(t===`"`){a+=`"`,o+=1;break}a+=t,o+=1}a!==``&&i.push({text:a,isEscape:!1});let s=o;for(;s<r;){let t=e[s];if(t===` `||t===` `||t===`
|
|
3
|
+
`||t===`\r`){s+=1;continue}break}let c=e[s]===`:`?`var(--shiki-token-keyword)`:`var(--shiki-token-string-expression)`;for(let e of i)n(e.text,e.isEscape?`var(--shiki-token-escape, var(--shiki-token-constant))`:c);return o}function Me(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n!=null&&n.color==null){let r=Oe;for(let n=t+1;n<e.length;n+=1){let t=e[n];if(t!=null&&t.color!=null){r=t.color;break}}n.color=r}}let t=``,n=``,r=null,i=()=>{r!=null&&(t+=`<span style="color:${r}">${ke(n)}</span>`),n=``,r=null};for(let t of e)t!=null&&(t.color===r?n+=t.text:(i(),n=t.text,r=t.color));return i(),`<span class="line">${t}</span>`}function $(e){let t=[[]],n=t[0]??[],r=e.length,i=0,a=(e,t)=>{n.push({text:e,color:t})};for(;i<r;){let o=e[i];if(o===`
|
|
4
|
+
`||o===`\r`){o===`\r`&&e[i+1]===`
|
|
5
|
+
`&&(i+=1);let r=[];t.push(r),n=r,i+=1;continue}if(o===` `||o===` `){let t=i+1;for(;t<r;){let n=e[t];if(n!==` `&&n!==` `)break;t+=1}a(e.slice(i,t),null),i=t;continue}if(o===`{`||o===`}`||o===`[`||o===`]`){a(o,Oe),i+=1;continue}if(o===`:`||o===`,`){a(o,`var(--shiki-token-punctuation)`),i+=1;continue}if(o===`"`){i=je(e,i,a);continue}let s=i+1;for(;s<r&&!Ae(e[s]??``);)s+=1;a(e.slice(i,s),`var(--shiki-token-constant)`),i=s}return t.map(Me).join(`
|
|
6
|
+
`)}function Ne(e){let t=new WeakSet;try{return JSON.stringify(e,(e,n)=>{if(typeof n==`bigint`)return n.toString();if(typeof n==`object`&&n){if(t.has(n))return`[Circular]`;t.add(n)}return n},2)??``}catch{try{return String(e)}catch{return``}}}function Pe(e,{showLineNumbers:t=!1,foldable:n=!0}={}){let r=Ne(e);return u({language:`json`,code:r,preHtml:c({html:$(r),foldableRanges:n?E(r):void 0,showLineNumbers:t}),showLineNumbers:t})}function Fe(e,t){let n=1;if(n>t)return!0;for(let r=0;r<e.length;r++)if(e[r]===`
|
|
7
|
+
`&&(n+=1,n>t))return!0;return!1}export{De as CodeBlock,h as computeFoldRanges,E as computeJsonFoldRanges,u as createMantleCodeBlockValue,c as decorateHighlightedHtml,w as defaultMeta,L as escapeHtml,D as finalizeFoldRanges,m as foldStrategyFor,Fe as hasMoreThanNLines,x as inferIndentation,v as isIndentation,_ as isSupportedLanguage,Pe as jsonCodeBlockValue,$ as jsonToShikiHtml,s as mantleCode,p as normalizeIndentation,y as normalizeValue,b as parseCodeBlockHighlightLines,C as parseCodeBlockLineNumberStart,d as parseCodeBlockShowLineNumbers,T as parseLanguage,S as parseMetastring,g as resolvePreRenderedCodeBlockProps,f as supportedLanguages,l as tokenizeMetastring};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,l as s,m as c,n as l,o as u,p as d,s as f,u as p,v as m,x as h,y as g}from"./resolve-pre-rendered-props-
|
|
1
|
+
import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,l as s,m as c,n as l,o as u,p as d,s as f,u as p,v as m,x as h,y as g}from"./resolve-pre-rendered-props-CF9-Qy2H.js";export{o as computeFoldRanges,m as computeJsonFoldRanges,e as decorateHighlightedHtml,h as defaultShowLineNumbers,g as finalizeFoldRanges,a as foldStrategyFor,d as inferIndentation,c as isIndentation,s as isSupportedLanguage,i as normalizeIndentation,l as normalizeValue,u as parseCodeBlockHighlightLines,f as parseCodeBlockLineNumberStart,n as parseCodeBlockShowLineNumbers,p as parseLanguage,r as supportedLanguages,t as tokenizeMetastring};
|
package/dist/command.d.ts
CHANGED
|
@@ -243,7 +243,7 @@ declare const Command: {
|
|
|
243
243
|
ref?: React.Ref<HTMLInputElement>;
|
|
244
244
|
} & {
|
|
245
245
|
asChild?: boolean;
|
|
246
|
-
}, "key" | "asChild" | keyof import("react").InputHTMLAttributes<HTMLInputElement>>, "onChange" | "
|
|
246
|
+
}, "key" | "asChild" | keyof import("react").InputHTMLAttributes<HTMLInputElement>>, "onChange" | "type" | "value"> & {
|
|
247
247
|
value?: string;
|
|
248
248
|
onValueChange?: (search: string) => void;
|
|
249
249
|
} & import("react").RefAttributes<HTMLInputElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
package/dist/data-table.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { t as Button } from "./button-mfYak6Rx.js";
|
|
2
|
+
import { t as IconButton } from "./icon-button-D7hs6bX2.js";
|
|
2
3
|
import { s as SortingMode } from "./direction-CcTY0FmA.js";
|
|
3
4
|
import { t as Table$1 } from "./table-BWD9IlIN.js";
|
|
4
5
|
import { ComponentProps, ReactNode } from "react";
|
|
@@ -200,6 +201,18 @@ declare namespace Head {
|
|
|
200
201
|
}
|
|
201
202
|
type DataTableRowProps<TData> = Omit<ComponentProps<typeof Table$1.Row>, "children"> & {
|
|
202
203
|
row: Row<TData>;
|
|
204
|
+
/**
|
|
205
|
+
* Renders an inline detail panel beneath the row. Called only while the row is
|
|
206
|
+
* expanded (`row.getIsExpanded()`), so the panel — and any expensive work it
|
|
207
|
+
* does — stays lazy. Mantle wraps the returned content in a sibling
|
|
208
|
+
* `DataTable.ExpandedRow` spanning every visible column, so return just the
|
|
209
|
+
* panel content (not a `<tr>`). Requires the table to be configured for
|
|
210
|
+
* expansion (`getExpandedRowModel`, plus `getRowCanExpand` for detail panels);
|
|
211
|
+
* pair it with a `DataTable.RowExpandButton` toggle in a leading column. For
|
|
212
|
+
* full control over the detail row (custom `colSpan`, multiple panels), omit
|
|
213
|
+
* this and render `DataTable.ExpandedRow` yourself.
|
|
214
|
+
*/
|
|
215
|
+
renderExpanded?: (row: Row<TData>) => ReactNode;
|
|
203
216
|
};
|
|
204
217
|
/**
|
|
205
218
|
* A single data table body row rendered from a TanStack Table row instance.
|
|
@@ -210,9 +223,15 @@ type DataTableRowProps<TData> = Omit<ComponentProps<typeof Table$1.Row>, "childr
|
|
|
210
223
|
* `cursor-wait`) to override. For keyboard and screen-reader access, also
|
|
211
224
|
* render a `<Link>` inside the primary cell — a `<tr>` is not focusable.
|
|
212
225
|
*
|
|
226
|
+
* Pass `renderExpanded` to give the row an inline detail panel: when the row is
|
|
227
|
+
* expanded the row renders its data `<tr>` plus a sibling `DataTable.ExpandedRow`
|
|
228
|
+
* holding the returned content. Pair it with a `DataTable.RowExpandButton` toggle
|
|
229
|
+
* and configure the table for expansion (`getExpandedRowModel`, `getRowCanExpand`).
|
|
230
|
+
*
|
|
213
231
|
* @see https://mantle.ngrok.com/components/data-table#datatablerow
|
|
214
232
|
*
|
|
215
233
|
* @example
|
|
234
|
+
* Clickable row navigating to a detail page:
|
|
216
235
|
* ```tsx
|
|
217
236
|
* const navigate = useNavigate();
|
|
218
237
|
*
|
|
@@ -224,9 +243,31 @@ type DataTableRowProps<TData> = Omit<ComponentProps<typeof Table$1.Row>, "childr
|
|
|
224
243
|
* />
|
|
225
244
|
* ))}
|
|
226
245
|
* ```
|
|
246
|
+
*
|
|
247
|
+
* @example
|
|
248
|
+
* Expandable row with an inline JSON detail panel (lazy — only built when open):
|
|
249
|
+
* ```tsx
|
|
250
|
+
* import { CodeBlock, jsonCodeBlockValue } from "@ngrok/mantle/code-block";
|
|
251
|
+
*
|
|
252
|
+
* {rows.map((row) => (
|
|
253
|
+
* <DataTable.Row
|
|
254
|
+
* key={row.id}
|
|
255
|
+
* row={row}
|
|
256
|
+
* renderExpanded={(row) => (
|
|
257
|
+
* <CodeBlock.Root>
|
|
258
|
+
* <CodeBlock.Body>
|
|
259
|
+
* <CodeBlock.CopyButton />
|
|
260
|
+
* <CodeBlock.Code value={jsonCodeBlockValue(row.original)} />
|
|
261
|
+
* </CodeBlock.Body>
|
|
262
|
+
* </CodeBlock.Root>
|
|
263
|
+
* )}
|
|
264
|
+
* />
|
|
265
|
+
* ))}
|
|
266
|
+
* ```
|
|
227
267
|
*/
|
|
228
268
|
declare function Row$1<TData>({
|
|
229
269
|
className,
|
|
270
|
+
renderExpanded,
|
|
230
271
|
row,
|
|
231
272
|
...props
|
|
232
273
|
}: DataTableRowProps<TData>): import("react").JSX.Element;
|
|
@@ -355,6 +396,194 @@ declare function ActionHeader({
|
|
|
355
396
|
declare namespace ActionHeader {
|
|
356
397
|
var displayName: string;
|
|
357
398
|
}
|
|
399
|
+
/**
|
|
400
|
+
* Compute the stable DOM `id` for a row's expanded detail row. Shared by
|
|
401
|
+
* `DataTable.RowExpandButton` (as its `aria-controls` target) and
|
|
402
|
+
* `DataTable.ExpandedRow` (as its `id`) so the accessibility association is
|
|
403
|
+
* _derived_ from the row — never synchronized state — and stays correct whether
|
|
404
|
+
* or not the detail panel is currently rendered.
|
|
405
|
+
*
|
|
406
|
+
* REQUIRED: configure the table with a stable `getRowId` so `row.id` (and thus
|
|
407
|
+
* this id) is stable across sorting/filtering/pagination. Any `row.id` value is
|
|
408
|
+
* safe — it is URL-encoded into a valid, whitespace-free HTML id token (and thus
|
|
409
|
+
* a valid `aria-controls` IDREF), so display names with spaces, URLs, and emails
|
|
410
|
+
* all work; `getRowId` controls the value.
|
|
411
|
+
*
|
|
412
|
+
* @example
|
|
413
|
+
* ```tsx
|
|
414
|
+
* <DataTable.RowExpandButton row={row} label={row.original.name} />
|
|
415
|
+
* // ...renders aria-controls={expandedRowId(row)} while expanded, and
|
|
416
|
+
* <DataTable.ExpandedRow row={row}>...</DataTable.ExpandedRow>
|
|
417
|
+
* // ...renders id={expandedRowId(row)} — the same value, so they stay associated.
|
|
418
|
+
* ```
|
|
419
|
+
*/
|
|
420
|
+
declare function expandedRowId<TData>(row: Row<TData>): string;
|
|
421
|
+
type DataTableExpandHeaderProps = Omit<ComponentProps<typeof Table$1.Header>, "children"> & {
|
|
422
|
+
/**
|
|
423
|
+
* Optional header content — e.g. an "expand all" toggle wired to
|
|
424
|
+
* `table.getToggleAllRowsExpandedHandler()`. Defaults to a screen-reader-only
|
|
425
|
+
* label so the column is announced while staying visually empty.
|
|
426
|
+
*/
|
|
427
|
+
children?: ReactNode;
|
|
428
|
+
};
|
|
429
|
+
/**
|
|
430
|
+
* A narrow `<th>` for the leading expand-toggle column, mirroring
|
|
431
|
+
* `DataTable.ActionHeader`. Renders a screen-reader-only label by default so the
|
|
432
|
+
* column is announced to assistive tech while staying visually empty; pass
|
|
433
|
+
* `children` to render an "expand all" control instead.
|
|
434
|
+
*
|
|
435
|
+
* @see https://mantle.ngrok.com/components/data-table#datatableexpandheader
|
|
436
|
+
*
|
|
437
|
+
* @example
|
|
438
|
+
* ```tsx
|
|
439
|
+
* columnHelper.display({
|
|
440
|
+
* id: "expander",
|
|
441
|
+
* header: () => <DataTable.ExpandHeader />,
|
|
442
|
+
* cell: (props) => (
|
|
443
|
+
* <DataTable.Cell className="w-9 px-0 text-center">
|
|
444
|
+
* <DataTable.RowExpandButton row={props.row} label={props.row.original.name} />
|
|
445
|
+
* </DataTable.Cell>
|
|
446
|
+
* ),
|
|
447
|
+
* });
|
|
448
|
+
* ```
|
|
449
|
+
*/
|
|
450
|
+
declare function ExpandHeader({
|
|
451
|
+
children,
|
|
452
|
+
className,
|
|
453
|
+
...props
|
|
454
|
+
}: DataTableExpandHeaderProps): import("react").JSX.Element;
|
|
455
|
+
declare namespace ExpandHeader {
|
|
456
|
+
var displayName: string;
|
|
457
|
+
}
|
|
458
|
+
type DataTableRowExpandButtonProps<TData> = Omit<ComponentProps<typeof IconButton>, "aria-controls" | "aria-expanded" | "icon" | "label"> & {
|
|
459
|
+
/**
|
|
460
|
+
* The TanStack Table row this button toggles. The table must be configured for
|
|
461
|
+
* expansion (`getExpandedRowModel`, plus `getRowCanExpand: () => true` for
|
|
462
|
+
* custom detail panels, which have no sub-rows).
|
|
463
|
+
*/
|
|
464
|
+
row: Row<TData>;
|
|
465
|
+
/**
|
|
466
|
+
* A human-readable name for the row, woven into the accessible label:
|
|
467
|
+
* `Show details for {label}` / `Hide details for {label}`.
|
|
468
|
+
*/
|
|
469
|
+
label: string;
|
|
470
|
+
/**
|
|
471
|
+
* Icon shown while the row is collapsed (activating it expands the row).
|
|
472
|
+
* @default <PlusIcon weight="bold" />
|
|
473
|
+
*/
|
|
474
|
+
expandIcon?: ReactNode;
|
|
475
|
+
/**
|
|
476
|
+
* Icon shown while the row is expanded (activating it collapses the row).
|
|
477
|
+
* @default <MinusIcon weight="bold" />
|
|
478
|
+
*/
|
|
479
|
+
collapseIcon?: ReactNode;
|
|
480
|
+
};
|
|
481
|
+
/**
|
|
482
|
+
* An accessible +/- toggle that expands or collapses a row's detail panel. Drop
|
|
483
|
+
* it inside a `DataTable.Cell` in a leading `columnHelper.display` column and
|
|
484
|
+
* pair it with `DataTable.ExpandedRow`.
|
|
485
|
+
*
|
|
486
|
+
* Renders a real `<button>` (keyboard operable) that sets `aria-expanded` and,
|
|
487
|
+
* while expanded, `aria-controls` pointing at the `DataTable.ExpandedRow`. It
|
|
488
|
+
* stops click propagation so it never triggers a row-level `onClick` (e.g. row
|
|
489
|
+
* navigation), and renders nothing when `row.getCanExpand()` is false so a
|
|
490
|
+
* `getRowCanExpand` predicate cleanly hides it. Forwards `IconButton` props, so
|
|
491
|
+
* pass `onClick` to run side effects before the toggle (call
|
|
492
|
+
* `event.preventDefault()` to veto it).
|
|
493
|
+
*
|
|
494
|
+
* @see https://mantle.ngrok.com/components/data-table#datatablerowexpandbutton
|
|
495
|
+
*
|
|
496
|
+
* @example
|
|
497
|
+
* ```tsx
|
|
498
|
+
* columnHelper.display({
|
|
499
|
+
* id: "expander",
|
|
500
|
+
* header: () => <DataTable.ExpandHeader />,
|
|
501
|
+
* cell: (props) => (
|
|
502
|
+
* <DataTable.Cell className="w-9 px-0 text-center">
|
|
503
|
+
* <DataTable.RowExpandButton row={props.row} label={props.row.original.name} />
|
|
504
|
+
* </DataTable.Cell>
|
|
505
|
+
* ),
|
|
506
|
+
* });
|
|
507
|
+
* ```
|
|
508
|
+
*/
|
|
509
|
+
declare function RowExpandButton<TData>({
|
|
510
|
+
appearance,
|
|
511
|
+
className,
|
|
512
|
+
collapseIcon,
|
|
513
|
+
expandIcon,
|
|
514
|
+
label,
|
|
515
|
+
onClick,
|
|
516
|
+
row,
|
|
517
|
+
size,
|
|
518
|
+
...props
|
|
519
|
+
}: DataTableRowExpandButtonProps<TData>): import("react").JSX.Element | null;
|
|
520
|
+
declare namespace RowExpandButton {
|
|
521
|
+
var displayName: string;
|
|
522
|
+
}
|
|
523
|
+
type DataTableExpandedRowProps<TData> = Omit<ComponentProps<typeof Table$1.Row>, "children"> & {
|
|
524
|
+
/** The row whose detail panel this displays. */row: Row<TData>;
|
|
525
|
+
/**
|
|
526
|
+
* Override the cell's `colSpan`. Defaults to the row's visible-cell count so
|
|
527
|
+
* the panel spans every visible column (visibility- and pinning-aware).
|
|
528
|
+
*/
|
|
529
|
+
colSpan?: number; /** The detail content rendered inside the full-width panel. */
|
|
530
|
+
children: ReactNode;
|
|
531
|
+
};
|
|
532
|
+
/**
|
|
533
|
+
* The sibling `<tr>` that renders a row's expanded detail panel. For the common
|
|
534
|
+
* case, prefer `DataTable.Row`'s `renderExpanded` prop, which renders this for
|
|
535
|
+
* you. Reach for `ExpandedRow` directly when you need full control — a custom
|
|
536
|
+
* `colSpan`, multiple panels, or bespoke markup. Render it directly after the
|
|
537
|
+
* parent `DataTable.Row` — wrapped in a `Fragment`, never a DOM element (a node
|
|
538
|
+
* between `<tbody>` and `<tr>` is invalid HTML) — and only when
|
|
539
|
+
* `row.getIsExpanded()` is true.
|
|
540
|
+
*
|
|
541
|
+
* The single cell spans every visible column (override with `colSpan`), carries
|
|
542
|
+
* the `id` that `DataTable.RowExpandButton` targets via `aria-controls`, and
|
|
543
|
+
* sits on an opaque card surface so horizontally-scrolled content never shows
|
|
544
|
+
* through a sticky action column. Its top divider is suppressed so it reads as
|
|
545
|
+
* one block with its parent row; the panel itself does not change on hover (only
|
|
546
|
+
* the parent data row reacts to hover). Exposes `data-expanded-content` for
|
|
547
|
+
* styling hooks.
|
|
548
|
+
*
|
|
549
|
+
* @see https://mantle.ngrok.com/components/data-table#datatableexpandedrow
|
|
550
|
+
*
|
|
551
|
+
* @example
|
|
552
|
+
* Render the row's underlying object as JSON (a common detail-panel use case).
|
|
553
|
+
* `jsonCodeBlockValue` highlights the JSON entirely on the client — no Shiki
|
|
554
|
+
* runtime, no build-time plugin, no server roundtrip — so it works for runtime
|
|
555
|
+
* data and matches server/build-time highlighting:
|
|
556
|
+
* ```tsx
|
|
557
|
+
* import { CodeBlock, jsonCodeBlockValue } from "@ngrok/mantle/code-block";
|
|
558
|
+
* import { Fragment } from "react";
|
|
559
|
+
*
|
|
560
|
+
* {table.getRowModel().rows.map((row) => (
|
|
561
|
+
* <Fragment key={row.id}>
|
|
562
|
+
* <DataTable.Row row={row} />
|
|
563
|
+
* {row.getIsExpanded() && (
|
|
564
|
+
* <DataTable.ExpandedRow row={row}>
|
|
565
|
+
* <CodeBlock.Root>
|
|
566
|
+
* <CodeBlock.Body>
|
|
567
|
+
* <CodeBlock.CopyButton />
|
|
568
|
+
* <CodeBlock.Code value={jsonCodeBlockValue(row.original)} />
|
|
569
|
+
* </CodeBlock.Body>
|
|
570
|
+
* </CodeBlock.Root>
|
|
571
|
+
* </DataTable.ExpandedRow>
|
|
572
|
+
* )}
|
|
573
|
+
* </Fragment>
|
|
574
|
+
* ))}
|
|
575
|
+
* ```
|
|
576
|
+
*/
|
|
577
|
+
declare function ExpandedRow<TData>({
|
|
578
|
+
children,
|
|
579
|
+
className,
|
|
580
|
+
colSpan,
|
|
581
|
+
row,
|
|
582
|
+
...props
|
|
583
|
+
}: DataTableExpandedRowProps<TData>): import("react").JSX.Element;
|
|
584
|
+
declare namespace ExpandedRow {
|
|
585
|
+
var displayName: string;
|
|
586
|
+
}
|
|
358
587
|
/**
|
|
359
588
|
* Use `DataTable` for INTERACTIVE tabular data — sorting, filtering, pagination,
|
|
360
589
|
* row selection, and server-side or client-side data. Built on TanStack Table;
|
|
@@ -376,13 +605,16 @@ declare namespace ActionHeader {
|
|
|
376
605
|
* DataTable.Root
|
|
377
606
|
* ├── DataTable.Head
|
|
378
607
|
* │ └── DataTable.Row
|
|
608
|
+
* │ ├── DataTable.ExpandHeader
|
|
379
609
|
* │ ├── DataTable.Header
|
|
380
610
|
* │ │ └── DataTable.HeaderSortButton
|
|
381
611
|
* │ └── DataTable.ActionHeader
|
|
382
612
|
* └── DataTable.Body
|
|
383
613
|
* ├── DataTable.Row
|
|
384
614
|
* │ ├── DataTable.Cell
|
|
615
|
+
* │ │ └── DataTable.RowExpandButton
|
|
385
616
|
* │ └── DataTable.ActionCell
|
|
617
|
+
* ├── DataTable.ExpandedRow
|
|
386
618
|
* └── DataTable.EmptyRow
|
|
387
619
|
* ```
|
|
388
620
|
*
|
|
@@ -871,22 +1103,105 @@ declare const DataTable: {
|
|
|
871
1103
|
* Pass a different `cursor-*` class via `className` to override. For keyboard
|
|
872
1104
|
* and screen-reader access, also render a `<Link>` inside the primary cell.
|
|
873
1105
|
*
|
|
1106
|
+
* Pass `renderExpanded` to give the row an inline detail panel — the row then
|
|
1107
|
+
* renders a sibling `DataTable.ExpandedRow` (only while expanded) holding the
|
|
1108
|
+
* returned content. Pair with `DataTable.RowExpandButton`.
|
|
1109
|
+
*
|
|
874
1110
|
* @see https://mantle.ngrok.com/components/data-table#datatablerow
|
|
875
1111
|
*
|
|
876
1112
|
* @example
|
|
877
1113
|
* ```tsx
|
|
878
|
-
*
|
|
1114
|
+
* import { CodeBlock, jsonCodeBlockValue } from "@ngrok/mantle/code-block";
|
|
879
1115
|
*
|
|
880
1116
|
* {rows.map((row) => (
|
|
881
1117
|
* <DataTable.Row
|
|
882
1118
|
* key={row.id}
|
|
883
1119
|
* row={row}
|
|
884
|
-
*
|
|
1120
|
+
* renderExpanded={(row) => (
|
|
1121
|
+
* <CodeBlock.Root>
|
|
1122
|
+
* <CodeBlock.Body>
|
|
1123
|
+
* <CodeBlock.CopyButton />
|
|
1124
|
+
* <CodeBlock.Code value={jsonCodeBlockValue(row.original)} />
|
|
1125
|
+
* </CodeBlock.Body>
|
|
1126
|
+
* </CodeBlock.Root>
|
|
1127
|
+
* )}
|
|
885
1128
|
* />
|
|
886
1129
|
* ))}
|
|
887
1130
|
* ```
|
|
888
1131
|
*/
|
|
889
1132
|
readonly Row: typeof Row$1;
|
|
1133
|
+
/**
|
|
1134
|
+
* A narrow `<th>` for the leading expand-toggle column, mirroring
|
|
1135
|
+
* `DataTable.ActionHeader`. Renders a screen-reader-only label by default so
|
|
1136
|
+
* the column is announced while staying visually empty.
|
|
1137
|
+
*
|
|
1138
|
+
* @see https://mantle.ngrok.com/components/data-table#datatableexpandheader
|
|
1139
|
+
*
|
|
1140
|
+
* @example
|
|
1141
|
+
* ```tsx
|
|
1142
|
+
* columnHelper.display({
|
|
1143
|
+
* id: "expander",
|
|
1144
|
+
* header: () => <DataTable.ExpandHeader />,
|
|
1145
|
+
* cell: (props) => (
|
|
1146
|
+
* <DataTable.Cell className="w-9 px-0 text-center">
|
|
1147
|
+
* <DataTable.RowExpandButton row={props.row} label={props.row.original.name} />
|
|
1148
|
+
* </DataTable.Cell>
|
|
1149
|
+
* ),
|
|
1150
|
+
* });
|
|
1151
|
+
* ```
|
|
1152
|
+
*/
|
|
1153
|
+
readonly ExpandHeader: typeof ExpandHeader;
|
|
1154
|
+
/**
|
|
1155
|
+
* An accessible +/- toggle that expands or collapses a row's detail panel.
|
|
1156
|
+
* Place it inside a `DataTable.Cell` in a leading `columnHelper.display`
|
|
1157
|
+
* column and pair it with `DataTable.ExpandedRow`. Sets `aria-expanded` and
|
|
1158
|
+
* (while expanded) `aria-controls`, stops click propagation so it never fires
|
|
1159
|
+
* a row-level `onClick`, and renders nothing when `row.getCanExpand()` is
|
|
1160
|
+
* false.
|
|
1161
|
+
*
|
|
1162
|
+
* @see https://mantle.ngrok.com/components/data-table#datatablerowexpandbutton
|
|
1163
|
+
*
|
|
1164
|
+
* @example
|
|
1165
|
+
* ```tsx
|
|
1166
|
+
* <DataTable.Cell className="w-9 px-0 text-center">
|
|
1167
|
+
* <DataTable.RowExpandButton row={props.row} label={props.row.original.name} />
|
|
1168
|
+
* </DataTable.Cell>
|
|
1169
|
+
* ```
|
|
1170
|
+
*/
|
|
1171
|
+
readonly RowExpandButton: typeof RowExpandButton;
|
|
1172
|
+
/**
|
|
1173
|
+
* The sibling `<tr>` that renders a row's expanded detail panel. Render it
|
|
1174
|
+
* directly after the parent `DataTable.Row` (wrapped in a `Fragment`, never a
|
|
1175
|
+
* DOM element) and only when `row.getIsExpanded()` is true. Spans every
|
|
1176
|
+
* visible column, carries the `id` that `DataTable.RowExpandButton` targets,
|
|
1177
|
+
* and sits on an opaque card surface so it coexists with a sticky action
|
|
1178
|
+
* column.
|
|
1179
|
+
*
|
|
1180
|
+
* @see https://mantle.ngrok.com/components/data-table#datatableexpandedrow
|
|
1181
|
+
*
|
|
1182
|
+
* @example
|
|
1183
|
+
* ```tsx
|
|
1184
|
+
* import { CodeBlock, jsonCodeBlockValue } from "@ngrok/mantle/code-block";
|
|
1185
|
+
* import { Fragment } from "react";
|
|
1186
|
+
*
|
|
1187
|
+
* {table.getRowModel().rows.map((row) => (
|
|
1188
|
+
* <Fragment key={row.id}>
|
|
1189
|
+
* <DataTable.Row row={row} />
|
|
1190
|
+
* {row.getIsExpanded() && (
|
|
1191
|
+
* <DataTable.ExpandedRow row={row}>
|
|
1192
|
+
* <CodeBlock.Root>
|
|
1193
|
+
* <CodeBlock.Body>
|
|
1194
|
+
* <CodeBlock.CopyButton />
|
|
1195
|
+
* <CodeBlock.Code value={jsonCodeBlockValue(row.original)} />
|
|
1196
|
+
* </CodeBlock.Body>
|
|
1197
|
+
* </CodeBlock.Root>
|
|
1198
|
+
* </DataTable.ExpandedRow>
|
|
1199
|
+
* )}
|
|
1200
|
+
* </Fragment>
|
|
1201
|
+
* ))}
|
|
1202
|
+
* ```
|
|
1203
|
+
*/
|
|
1204
|
+
readonly ExpandedRow: typeof ExpandedRow;
|
|
890
1205
|
};
|
|
891
1206
|
//#endregion
|
|
892
|
-
export { DataTable };
|
|
1207
|
+
export { DataTable, expandedRowId };
|
package/dist/data-table.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./cx-CBSnSC36.js";import{t}from"./button-BfMn3PgP.js";import{i as
|
|
1
|
+
import{t as e}from"./cx-CBSnSC36.js";import{t}from"./icon-button-DUNHVWpb.js";import{t as n}from"./button-BfMn3PgP.js";import{i as r}from"./direction-Wa9W2F61.js";import{t as i}from"./sort-BPX2Fk9t.js";import{t as a}from"./table-DWy_oNta.js";import{Fragment as o,createContext as s,forwardRef as c,useContext as l,useMemo as u}from"react";import d from"tiny-invariant";import{Fragment as f,jsx as p,jsxs as m}from"react/jsx-runtime";import{flexRender as h}from"@tanstack/react-table";import{MinusIcon as g}from"@phosphor-icons/react/Minus";import{PlusIcon as _}from"@phosphor-icons/react/Plus";export*from"@tanstack/react-table";const v=[`unsorted`,`asc`,`desc`],y=[`unsorted`,`desc`,`asc`];function b(e,t){return x(t===`alphanumeric`?v:y,e)??`unsorted`}function x(e,t,n){if(e.length===0)return n;let r=e.findIndex(e=>e===t);if(r===-1)return n;let i=(r+1)%e.length;return e.at(i)??n}const S=s(null);function C(){let e=l(S);return d(e,`useDataTableContext should only be used within a DataTable child component`),e}function w({children:e,table:t,...n}){let r=u(()=>({table:t}),[t]);return p(S.Provider,{value:r,children:p(a.Root,{"data-slot":`data-table`,...n,children:p(a.Element,{children:e})})})}function T({children:t,className:i,column:a,disableSorting:o=!1,iconPlacement:s=`end`,sortingMode:c,sortIcon:l,onClick:u,...d}){let f=a.getIsSorted(),h=!o&&a.getCanSort(),g=h&&typeof f==`string`?f:`unsorted`,_=l?.(g)??p(V,{mode:c,direction:g});return m(n,{appearance:`ghost`,"data-slot":`data-table-header-sort-button`,className:e(`flex justify-start w-full h-full rounded-none not-disabled:active:scale-none text-muted`,i),"data-sort-direction":g,"data-table-header-action":!0,icon:_,iconPlacement:s,onClick:e=>{u?.(e),!e.defaultPrevented&&(!h||o||c===void 0||H(a,c))},priority:`neutral`,type:`button`,...d,children:[h&&g!==`unsorted`&&m(`span`,{className:`sr-only`,children:[`Column sorted in`,` `,c===`alphanumeric`?g===`asc`?`ascending`:`descending`:r(g),` `,`order`]}),t]})}function E({children:t,className:n,...r}){return p(a.Header,{"data-slot":`data-table-header`,className:e(`has-data-table-header-action:px-0`,n),...r,children:t})}const D=c((e,t)=>p(a.Body,{ref:t,"data-slot":`data-table-body`,...e}));D.displayName=`DataTableBody`;function O(e){let{table:t}=C();return p(a.Head,{"data-slot":`data-table-head`,...e,children:t.getHeaderGroups().map(e=>p(a.Row,{children:e.headers.map(e=>p(o,{children:e.isPlaceholder?p(a.Header,{},e.id):h(e.column.columnDef.header,e.getContext())},e.id))},e.id))})}function k({className:t,renderExpanded:n,row:r,...i}){let s=p(a.Row,{"data-slot":`data-table-row`,"data-expanded":r.getIsExpanded()||void 0,className:e(i.onClick&&`cursor-pointer`,t),...i,children:r.getVisibleCells().map(e=>p(o,{children:h(e.column.columnDef.cell,e.getContext())},e.id))});return n==null?s:m(f,{children:[s,r.getIsExpanded()&&p(z,{row:r,children:n(r)})]})}function A({children:e,...t}){let{table:n}=C(),r=n.getAllColumns().length;return p(a.Row,{"data-slot":`data-table-empty-row`,...t,children:p(a.Cell,{colSpan:r,children:e})})}function j(){return p(`span`,{"aria-hidden":!0,className:e(`pointer-events-none absolute -inset-y-px -left-1.5 w-1.5`,`opacity-0 transition-opacity group-data-sticky-active/table:opacity-100`,`shadow-[1px_0_0_0_var(--border-color-card-muted)]`,`bg-linear-to-l to-transparent`,`from-[color-mix(in_oklab,var(--shadow-color)_var(--shadow-second-opacity),transparent)]`)})}function M({children:t,className:n,...r}){return m(a.Cell,{"data-mantle-table-sticky-right":!0,"data-slot":`data-table-action-cell`,className:e(`sticky z-10 right-0 text-end align-middle bg-inherit p-2`,n),...r,children:[p(j,{}),t]})}function N({children:t,className:n,...r}){let{table:i}=C(),o=i.getRowModel().rows.length>0;return m(a.Header,{...o?{"data-mantle-table-sticky-right":!0}:{},"data-slot":`data-table-action-header`,className:e(o&&`sticky z-10 right-0 bg-inherit`,n),...r,children:[o&&p(j,{}),t]})}function P(e){return`data-table-expanded-row-${encodeURIComponent(e.id)}`}function F({children:t,className:n,...r}){return p(a.Header,{"data-slot":`data-table-expand-header`,className:e(`w-9 px-0 text-center`,n),...r,children:t??p(`span`,{className:`sr-only`,children:`Row details`})})}const I=p(_,{weight:`bold`,className:`size-3.5`}),L=p(g,{weight:`bold`,className:`size-3.5`});function R({appearance:n=`ghost`,className:r,collapseIcon:i=L,expandIcon:a=I,label:o,onClick:s,row:c,size:l=`sm`,...u}){if(!c.getCanExpand())return null;let d=c.getIsExpanded(),f=c.getToggleExpandedHandler();return p(t,{type:`button`,"data-slot":`data-table-row-expand-button`,appearance:n,size:l,className:e(`rounded`,r),"aria-expanded":d,"aria-controls":d?P(c):void 0,icon:d?i:a,label:`${d?`Hide`:`Show`} details for ${o}`,onClick:e=>{e.stopPropagation(),s?.(e),!e.defaultPrevented&&f()},...u})}function z({children:t,className:n,colSpan:r,row:i,...o}){return p(a.Row,{"data-slot":`data-table-expanded-row`,"data-expanded-content":!0,className:e(`[&>td]:border-t-0`,n),...o,children:p(a.Cell,{id:P(i),colSpan:r??i.getVisibleCells().length,className:`bg-card font-sans text-body`,children:t})})}w.displayName=`DataTable`,M.displayName=`DataTableActionCell`,N.displayName=`DataTableActionHeader`,D.displayName=`DataTableBody`,A.displayName=`DataTableEmptyRow`,F.displayName=`DataTableExpandHeader`,z.displayName=`DataTableExpandedRow`,O.displayName=`DataTableHead`,E.displayName=`DataTableHeader`,T.displayName=`DataTableHeaderSortButton`,k.displayName=`DataTableRow`,R.displayName=`DataTableRowExpandButton`;const B={Root:w,ActionCell:M,ActionHeader:N,Cell:a.Cell,Body:D,EmptyRow:A,Head:O,Header:E,HeaderSortButton:T,Row:k,ExpandHeader:F,RowExpandButton:R,ExpandedRow:z};function V({direction:e,mode:t,...n}){return e===`unsorted`||!t||!e?p(`svg`,{"aria-hidden":!0,...n}):p(i,{mode:t,direction:e,...n})}function H(e,t){if(!e.getCanSort())return;let n=e.getIsSorted();switch(b(typeof n==`string`?n:`unsorted`,t)){case`unsorted`:e.clearSorting();return;case`asc`:e.toggleSorting(!1);return;case`desc`:e.toggleSorting(!0);return;default:return}}export{B as DataTable,P as expandedRowId};
|
package/dist/input.d.ts
CHANGED
|
@@ -68,7 +68,7 @@ type InputProps = Omit<InputHTMLAttributes<HTMLInputElement>, "autoComplete" | "
|
|
|
68
68
|
* />
|
|
69
69
|
* ```
|
|
70
70
|
*/
|
|
71
|
-
declare const Input: import("react").ForwardRefExoticComponent<Omit<InputHTMLAttributes<HTMLInputElement>, "
|
|
71
|
+
declare const Input: import("react").ForwardRefExoticComponent<Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "autoComplete"> & WithAutoComplete & WithInputType & WithValidation & {
|
|
72
72
|
children?: import("react").ReactNode | undefined;
|
|
73
73
|
} & import("react").RefAttributes<HTMLInputElement>>;
|
|
74
74
|
type InputCaptureProps = Omit<InputHTMLAttributes<HTMLInputElement>, "autoComplete" | "type"> & BaseProps;
|
|
@@ -86,7 +86,7 @@ type InputCaptureProps = Omit<InputHTMLAttributes<HTMLInputElement>, "autoComple
|
|
|
86
86
|
* </Input>
|
|
87
87
|
* ```
|
|
88
88
|
*/
|
|
89
|
-
declare const InputCapture: import("react").ForwardRefExoticComponent<Omit<InputHTMLAttributes<HTMLInputElement>, "
|
|
89
|
+
declare const InputCapture: import("react").ForwardRefExoticComponent<Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "autoComplete"> & WithAutoComplete & WithInputType & WithValidation & import("react").RefAttributes<HTMLInputElement>>;
|
|
90
90
|
//#endregion
|
|
91
91
|
//#region src/components/input/password-input.d.ts
|
|
92
92
|
type PasswordInputProps = Omit<InputHTMLAttributes<HTMLInputElement>, "autoComplete" | "type"> & WithValidation & WithAutoComplete & {
|
|
@@ -158,7 +158,7 @@ type PasswordInputProps = Omit<InputHTMLAttributes<HTMLInputElement>, "autoCompl
|
|
|
158
158
|
* }
|
|
159
159
|
* ```
|
|
160
160
|
*/
|
|
161
|
-
declare const PasswordInput: import("react").ForwardRefExoticComponent<Omit<InputHTMLAttributes<HTMLInputElement>, "
|
|
161
|
+
declare const PasswordInput: import("react").ForwardRefExoticComponent<Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "autoComplete"> & WithValidation & WithAutoComplete & {
|
|
162
162
|
/**
|
|
163
163
|
* Callback for when the visibility of the password value changes.
|
|
164
164
|
*/
|
package/dist/llms.txt
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import{t as e}from"./cx-CBSnSC36.js";import{t}from"./booleanish-BfvnW6vy.js";const n=new Set([`bash`,`sh`,`shell`]);function r(e,t){return!(n.has(e)&&!t.trim().includes(`
|
|
2
|
+
`))}const i=Symbol(`MantleCodeBlockValue`);function a({preHtml:e,preValToken:t,preVals:n,highlightLines:r,lineNumberStart:a,showLineNumbers:o,code:s,language:c}){return{[i]:!0,language:c,code:s,"~preHtml":e,"~preValToken":t,"~preVals":n,"~highlightLines":r,"~lineNumberStart":a,"~showLineNumbers":o}}function o(e,t){let n=``;for(let r=0;r<e.length;r+=1)n+=e[r]??``,r<t.length&&(n+=String(t[r]));return n}function s(e,t={}){let{showLineNumbers:n,highlightLines:i,lineNumberStart:s}=t;return(t,...c)=>{let l=o(t,c);return a({language:e,code:l,preHtml:void 0,preVals:c.length>0?c:void 0,highlightLines:i,lineNumberStart:s,showLineNumbers:n??r(e,l)})}}function c(e){if(e.length<=1)return e;e.sort((e,t)=>e.startLine===t.startLine?t.endLine-e.endLine:e.startLine-t.startLine);let t=[],n=-1;for(let r of e)r.startLine!==n&&(t.push(r),n=r.startLine);return t}function l(e){let t=e.length;if(t===0)return[];let n=[],r=[],i=1,a=0;for(;a<t;){let o=e.charCodeAt(a);if(o===10){i+=1,a+=1;continue}if(o===13){i+=1,a+=1,a<t&&e.charCodeAt(a)===10&&(a+=1);continue}if(o===34){for(a+=1;a<t;){let t=e.charCodeAt(a);if(t===92){a+=2;continue}if(t===34){a+=1;break}if(t===10||t===13)break;a+=1}continue}if(o===123||o===91){n.push({opener:o,line:i}),a+=1;continue}if(o===125||o===93){let e=o===125?123:91,t=n[n.length-1];t?.opener===e?(n.pop(),t.line!==i&&r.push({id:String(t.line),startLine:t.line,endLine:i})):t!=null&&(n.length=0),a+=1;continue}a+=1}return c(r)}function u(...e){let t=new Set;for(let n of e)if(typeof n==`number`){if(!d(n))continue;let e=Math.floor(n);t.add(e)}else{let e=n.indexOf(`-`),r=n.slice(0,e),i=n.slice(e+1),a=Number.parseInt(r,10),o=Number.parseInt(i,10);if(!d(a)||!d(o)||(a>o&&([a,o]=[o,a]),o-a+1>1e3))continue;for(let e=a;e<=o;e++)t.add(e)}return t}const d=e=>e!=null&&!Number.isNaN(e)&&e>0&&Number.isFinite(e);function f(e){let t=e.length;for(;t>0&&(e.charCodeAt(t-1)===10||e.charCodeAt(t-1)===13);)--t;return t===e.length?e:e.slice(0,t)}function p(e){let t=f(e).replaceAll(`\r
|
|
3
|
+
`,`
|
|
4
|
+
`).replaceAll(`\r`,`
|
|
5
|
+
`).split(`
|
|
6
|
+
`);for(let e=0;e<t.length;e++){let n=t[e]??``;n.startsWith(`<span class="line">`)&&n.endsWith(`</span>`)&&(t[e]=n.slice(19,n.length-7))}return t}function m(e){return encodeURIComponent(e)}function h({foldableRanges:t,highlightLines:n,html:r,lineNumberStart:i=1,showLineNumbers:a=!1}){let o=u(...n??[]),s=p(r),c=new Map,l=new Map,d=t!=null&&t.length>0;if(d&&t!=null)for(let e of t){let t=m(e.id);c.set(e.startLine,t);for(let n=e.startLine+1;n<e.endLine;n+=1){let e=l.get(n);e??(e=[],l.set(n,e)),e.push(t)}}let f=``;for(let t=0;t<s.length;t++){let n=s[t]??``,r=t+1,u=i+t,p=d?c.get(r):void 0,m=e(`mantle-code-line`,o.has(u)&&`mantle-code-line-highlighted`,p!=null&&`mantle-code-line-opener`),h=a?`<span class="mantle-code-line-number" data-slot="line-number">${u}</span>`:``,g=``,_=``,v=``;if(d){p!=null&&(g=`<button type="button" class="mantle-code-fold-toggle" data-slot="fold-toggle" data-fold-line="${p}" aria-expanded="true" aria-label="Toggle code folding"><svg class="mantle-code-fold-caret" viewBox="0 0 16 16" aria-hidden="true" focusable="false"><path fill="currentColor" fill-rule="evenodd" d="M3.22 5.97a.75.75 0 0 1 1.06 0L8 9.69l3.72-3.72a.75.75 0 1 1 1.06 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L3.22 7.03a.75.75 0 0 1 0-1.06Z"/></svg></button>`,v=`<span class="mantle-code-fold-ellipsis" data-slot="fold-ellipsis" aria-hidden="true">⋯</span>`);let e=l.get(r);e!=null&&e.length>0&&(_=` data-fold-regions="${e.join(` `)}"`)}let y=`<span class="mantle-code-line-content" data-slot="line-content">${n===``?` `:n}${v}</span>`;f+=`<span class="${m}" data-line-number="${u}"${_}>${h}${g}${y}</span>`}return f}function g(e){switch(e){case`python`:case`py`:case`yaml`:case`yml`:return`indentation`;case`html`:case`xml`:return`tag`;case`bash`:case`sh`:case`shell`:case`plain`:case`plaintext`:case`text`:case`txt`:return`none`;default:return`bracket`}}function _({language:e,tokens:t}){switch(g(e)){case`bracket`:return S(t);case`indentation`:return w(t);case`tag`:return ee(t);case`none`:return[]}}function v(e){if(e.length===0)return!1;let t=e[e.length-1]?.scopeName??``;return t===`string`||t===`comment`||t.startsWith(`string.`)||t.startsWith(`comment.`)||t.startsWith(`constant.character.escape`)}function y(e){return e.explanation!=null&&e.explanation.length>0?e.explanation:[{content:e.content,scopes:[]}]}function b(e){let t=``;for(let n of e){let e=y(n),r=!1;for(let t of e)if(v(t.scopes)){r=!0;break}if(!r){t+=n.content;continue}for(let n of e)v(n.scopes)||(t+=n.content)}return t}function x(e){if(e==null||e.length===0)return-1;let t=0;for(let n of e){let e=n.content;for(let n=0;n<e.length;n+=1){let r=e.charCodeAt(n);if(r===32||r===9){t+=1;continue}return t}}return-1}function S(e){let t=[],n=[];for(let r=0;r<e.length;r+=1){let i=e[r];if(i==null)continue;let a=r+1;for(let e of i)if(C(e.content))for(let r of y(e)){if(v(r.scopes))continue;let e=r.content;for(let r=0;r<e.length;r+=1){let i=e.charCodeAt(r);if(i===123||i===91)t.push(a);else if(i===125||i===93){let e=t.pop();e!=null&&e!==a&&n.push({id:String(e),startLine:e,endLine:a})}}}}return c(n)}function C(e){for(let t=0;t<e.length;t+=1){let n=e.charCodeAt(t);if(n===123||n===125||n===91||n===93)return!0}return!1}function w(e){let t=Array.from({length:e.length});for(let n=0;n<e.length;n+=1)t[n]=x(e[n]);let n=[];for(let e=0;e<t.length;e+=1){let r=t[e]??-1;if(r<0)continue;let i=-1,a=e+1;for(;a<t.length;){let e=t[a]??-1;if(e<0){a+=1;continue}if(e>r){i=a,a+=1;continue}break}i>e&&n.push({id:String(e+1),startLine:e+1,endLine:i+2})}return c(n)}function ee(e){let t=[],n=[];for(let r=0;r<e.length;r+=1){let i=e[r];if(i==null)continue;let a=r+1,o=E(b(i));for(let e of o)if(e.kind===`open`)t.push({name:e.name,line:a});else{let r=t.length>0?t[t.length-1]:void 0;r!=null&&r.name.toLowerCase()===e.name.toLowerCase()&&(t.pop(),r.line!==a&&n.push({id:String(r.line),startLine:r.line,endLine:a}))}}return c(n)}const T=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`]);function E(e){let t=[],n=0;for(;n<e.length;){let r=e.indexOf(`<`,n);if(r===-1)break;let i=O(e,r+1),a=e.charCodeAt(i)===47;if(a&&(i=O(e,i+1)),!k(e.charCodeAt(i))){n=r+1;continue}let o=i;for(i+=1;i<e.length&&A(e.charCodeAt(i));)i+=1;let s=e.slice(o,i),c=j(e,i);if(c===-1){n=r+1;continue}if(a){t.push({name:s,kind:`close`}),n=c+1;continue}if(te(e,c)||T.has(s.toLowerCase())){n=c+1;continue}t.push({name:s,kind:`open`}),n=c+1}return t}function D(e){return e===9||e===10||e===11||e===12||e===13||e===32}function O(e,t){let n=t;for(;n<e.length&&D(e.charCodeAt(n));)n+=1;return n}function k(e){return e>=65&&e<=90||e>=97&&e<=122}function A(e){return k(e)||e>=48&&e<=57||e===45||e===58||e===95}function j(e,t){let n;for(let r=t;r<e.length;r+=1){let t=e.charCodeAt(r);if(n!=null){t===n&&(n=void 0);continue}if(t===34||t===39){n=t;continue}if(t===62)return r}return-1}function te(e,t){let n=t-1;for(;n>=0&&D(e.charCodeAt(n));)--n;return n>=0&&e.charCodeAt(n)===47}const ne=[`tabs`,`spaces`];function M(e){return ne.includes(e)}function re(e,t){return t||(F(e)?`tabs`:(I(e),`spaces`))}const N=new Set([`csharp`,`css`,`go`,`html`,`java`,`javascript`,`js`,`jsx`,`ts`,`tsx`,`typescript`,`xml`]),P=new Set([`python`,`py`,`yaml`,`yml`,`ruby`,`rb`]);function F(e){return N.has(e)}function I(e){return P.has(e)}function L(e,t){let n=t?.indentation??`spaces`,r=e.replace(/\r\n?/g,`
|
|
7
|
+
`),i=r.trim();if(i===``)return``;let a=B(r),o=i.split(`
|
|
8
|
+
`),s=Array.from({length:o.length});for(let e=0;e<o.length;e++){let t=o[e];t!=null&&(s[e]=R(z(t)?t:t.slice(a),n))}return s.join(`
|
|
9
|
+
`)}function R(e,t){let n=0;for(;n<e.length;){let t=e[n];if(t!==` `&&t!==` `)break;n+=1}if(n===0||n===e.length)return e;let r=e.slice(0,n);return(t===`spaces`?r.replace(/\t/g,` `):r.replace(/ {2}/g,` `))+e.slice(n)}function z(e){let t=e[0];return t!=null&&t!==` `&&t!==` `}function B(e){let t=1/0,n=0,r=!0;for(let i=0;i<e.length;i++){let a=e[i];if(r){if(a===` `||a===` `){n+=1;continue}if(a===`
|
|
10
|
+
`||a===`\r`){n=0;continue}if(n<t&&(t=n,t===0))return 0;r=!1;continue}(a===`
|
|
11
|
+
`||a===`\r`)&&(r=!0,n=0)}return t===1/0?0:t}const V=`bash.cs.csharp.css.go.html.java.javascript.js.json.jsx.plain.plaintext.py.python.rb.ruby.rust.sh.shell.text.ts.tsx.txt.typescript.xml.yaml.yml`.split(`.`),H=new Set(V),U=`text`;function W(e){let t=e?.trim()??``;if(!t)return U;let n=t.indexOf(`-`),r=n===-1?t:t.slice(n+1);return G(r)?r:U}const G=e=>typeof e==`string`&&H.has(e);function K(e){if(typeof e==`boolean`)return e;if(typeof e==`string`){if(e===`true`)return!0;if(e===`false`)return!1}}function q(e){if(typeof e==`number`&&Number.isFinite(e)&&e>0)return Math.floor(e);if(typeof e==`string`&&/^\d+$/.test(e)){let t=Number.parseInt(e,10);return t>0?t:void 0}}function J(e){if(typeof e==`number`)return Number.isFinite(e)&&e>0?Math.floor(e):void 0;if(typeof e==`string`){let t=e.trim();if(/^\d+$/.test(t)){let e=Number.parseInt(t,10);return e>0?e:void 0}if(/^\d+-\d+$/.test(t)){let[e,n]=t.split(`-`);return Number.parseInt(e??``,10)>0&&Number.parseInt(n??``,10)>0?t:void 0}}}function Y(e){if(typeof e==`string`){let t=[],n=e.split(`,`);for(let e of n){let n=J(e);n!=null&&t.push(n)}return t.length>0?t:void 0}if(!Array.isArray(e))return;let t=[];for(let n of e){let e=J(n);e!=null&&t.push(e)}return t.length>0?t:void 0}const X={collapsible:!1,disableCopy:!1,indentation:void 0,mode:void 0,title:void 0};function ie(e){let t=e?.trim()??``;if(!t)return X;let n={},r=Q(t);for(let e of r){let t=e.indexOf(`=`),r=t===-1?e:e.slice(0,t),i=t===-1?void 0:e.slice(t+1);r&&(n[r]=Z(i)??!0)}return oe(n)}function Z(e){if(e==null)return;let t=e.trim(),n=t.length-1;return n>=1&&t.charCodeAt(0)===34&&t.charCodeAt(n)===34?t.slice(1,n):t}function Q(e){let t=e?.trim()??``,n=[],r=``,i=!1;for(let e=0;e<t.length;e++){let a=t[e]??``;!i&&ae(a)?r&&=(n.push(r),``):(a===`"`&&(i=!i),r+=a)}return r&&n.push(r),n}function ae(e){return e===` `||e===` `||e===`
|
|
12
|
+
`||e===`\r`}function $(e){return e===`cli`||e===`file`||e===`traffic-policy`}function oe(e){let{collapsible:n=X.collapsible,disableCopy:r=X.disableCopy,indentation:i=X.indentation,mode:a=X.mode,title:o=X.title}=e;return{collapsible:typeof n==`string`||typeof n==`boolean`?t(n):X.collapsible,disableCopy:typeof r==`string`||typeof r==`boolean`?t(r):X.disableCopy,indentation:M(i)?i:X.indentation,mode:$(a)?a:X.mode,title:typeof o==`string`?o.trim():X.title}}function se(e){let{collapsible:n,disableCopy:r,mantleCode:i,mantleCollapsible:a,mantleDisableCopy:o,mantleHighlightLines:s,mantleLanguage:c,mantleLineNumberStart:l,mantleMode:u,mantlePreHtml:d,mantleShowLineNumbers:f,mantleTitle:p,mode:m,title:h,...g}=e;return c!=null||i!=null||d!=null||f!=null||s!=null||l!=null||a!=null||o!=null||u!=null||p!=null?{mantleCode:{code:typeof i==`string`?i:void 0,collapsible:(typeof a==`string`||typeof a==`boolean`?t(a):void 0)??(typeof n==`string`||typeof n==`boolean`?t(n):void 0),disableCopy:typeof o==`string`||typeof o==`boolean`?t(o):typeof r==`string`||typeof r==`boolean`?t(r):void 0,highlightLines:Y(s),language:typeof c==`string`&&G(c)?c:void 0,lineNumberStart:q(l),mode:$(u)?u:$(m)?m:void 0,preHtml:typeof d==`string`?d:void 0,rawLanguage:c,showLineNumbers:K(f),title:typeof p==`string`?p.trim():typeof h==`string`?h.trim():void 0},props:g}:{mantleCode:void 0,props:g}}export{s as S,h as _,Q as a,a as b,K as c,V as d,L as f,g,_ as h,se as i,G as l,M as m,Z as n,Y as o,re as p,ie as r,q as s,X as t,W as u,l as v,r as x,c as y};
|
package/dist/theme.d.ts
CHANGED
|
@@ -201,14 +201,14 @@ declare function useTheme(): ThemeProviderState;
|
|
|
201
201
|
* Read the theme and applied theme from the `<html>` element.
|
|
202
202
|
*/
|
|
203
203
|
declare function readThemeFromHtmlElement(): {
|
|
204
|
-
appliedTheme: "
|
|
205
|
-
theme: "
|
|
204
|
+
appliedTheme: "light" | "dark" | "light-high-contrast" | "dark-high-contrast" | undefined;
|
|
205
|
+
theme: "system" | "light" | "dark" | "light-high-contrast" | "dark-high-contrast" | undefined;
|
|
206
206
|
};
|
|
207
207
|
/**
|
|
208
208
|
* If the theme is "system", it will resolve the theme based on the user's media query preferences, otherwise it will return the theme as is.
|
|
209
209
|
* This will mirror the result that gets applied to the <html> element.
|
|
210
210
|
*/
|
|
211
|
-
declare function useAppliedTheme(): "
|
|
211
|
+
declare function useAppliedTheme(): "light" | "dark" | "light-high-contrast" | "dark-high-contrast";
|
|
212
212
|
/**
|
|
213
213
|
* determineThemeFromMediaQuery returns the theme that should be used based on the user's media query preferences.
|
|
214
214
|
* @private
|
package/package.json
CHANGED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./cx-CBSnSC36.js";import{t}from"./booleanish-BfvnW6vy.js";const n=new Set([`bash`,`sh`,`shell`]);function r(e,t){return!(n.has(e)&&!t.trim().includes(`
|
|
2
|
-
`))}const i=Symbol(`MantleCodeBlockValue`);function a({preHtml:e,preValToken:t,preVals:n,highlightLines:r,lineNumberStart:a,showLineNumbers:o,code:s,language:c}){return{[i]:!0,language:c,code:s,"~preHtml":e,"~preValToken":t,"~preVals":n,"~highlightLines":r,"~lineNumberStart":a,"~showLineNumbers":o}}function o(e,t){let n=``;for(let r=0;r<e.length;r+=1)n+=e[r]??``,r<t.length&&(n+=String(t[r]));return n}function s(e,t={}){let{showLineNumbers:n,highlightLines:i,lineNumberStart:s}=t;return(t,...c)=>{let l=o(t,c);return a({language:e,code:l,preHtml:void 0,preVals:c.length>0?c:void 0,highlightLines:i,lineNumberStart:s,showLineNumbers:n??r(e,l)})}}function c(...e){let t=new Set;for(let n of e)if(typeof n==`number`){if(!l(n))continue;let e=Math.floor(n);t.add(e)}else{let e=n.indexOf(`-`),r=n.slice(0,e),i=n.slice(e+1),a=Number.parseInt(r,10),o=Number.parseInt(i,10);if(!l(a)||!l(o)||(a>o&&([a,o]=[o,a]),o-a+1>1e3))continue;for(let e=a;e<=o;e++)t.add(e)}return t}const l=e=>e!=null&&!Number.isNaN(e)&&e>0&&Number.isFinite(e);function u(e){let t=e.length;for(;t>0&&(e.charCodeAt(t-1)===10||e.charCodeAt(t-1)===13);)--t;return t===e.length?e:e.slice(0,t)}function d(e){let t=u(e).replaceAll(`\r
|
|
3
|
-
`,`
|
|
4
|
-
`).replaceAll(`\r`,`
|
|
5
|
-
`).split(`
|
|
6
|
-
`);for(let e=0;e<t.length;e++){let n=t[e]??``;n.startsWith(`<span class="line">`)&&n.endsWith(`</span>`)&&(t[e]=n.slice(19,n.length-7))}return t}function f(e){return encodeURIComponent(e)}function p({foldableRanges:t,highlightLines:n,html:r,lineNumberStart:i=1,showLineNumbers:a=!1}){let o=c(...n??[]),s=d(r),l=new Map,u=new Map,p=t!=null&&t.length>0;if(p&&t!=null)for(let e of t){let t=f(e.id);l.set(e.startLine,t);for(let n=e.startLine+1;n<e.endLine;n+=1){let e=u.get(n);e??(e=[],u.set(n,e)),e.push(t)}}let m=``;for(let t=0;t<s.length;t++){let n=s[t]??``,r=t+1,c=i+t,d=p?l.get(r):void 0,f=e(`mantle-code-line`,o.has(c)&&`mantle-code-line-highlighted`,d!=null&&`mantle-code-line-opener`),h=a?`<span class="mantle-code-line-number" data-slot="line-number">${c}</span>`:``,g=``,_=``,v=``;if(p){d!=null&&(g=`<button type="button" class="mantle-code-fold-toggle" data-slot="fold-toggle" data-fold-line="${d}" aria-expanded="true" aria-label="Toggle code folding"><svg class="mantle-code-fold-caret" viewBox="0 0 16 16" aria-hidden="true" focusable="false"><path fill="currentColor" fill-rule="evenodd" d="M3.22 5.97a.75.75 0 0 1 1.06 0L8 9.69l3.72-3.72a.75.75 0 1 1 1.06 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L3.22 7.03a.75.75 0 0 1 0-1.06Z"/></svg></button>`,v=`<span class="mantle-code-fold-ellipsis" data-slot="fold-ellipsis" aria-hidden="true">⋯</span>`);let e=u.get(r);e!=null&&e.length>0&&(_=` data-fold-regions="${e.join(` `)}"`)}let y=`<span class="mantle-code-line-content" data-slot="line-content">${n===``?` `:n}${v}</span>`;m+=`<span class="${f}" data-line-number="${c}"${_}>${h}${g}${y}</span>`}return m}function m(e){if(e.length<=1)return e;e.sort((e,t)=>e.startLine===t.startLine?t.endLine-e.endLine:e.startLine-t.startLine);let t=[],n=-1;for(let r of e)r.startLine!==n&&(t.push(r),n=r.startLine);return t}function h(e){let t=e.length;if(t===0)return[];let n=[],r=[],i=1,a=0;for(;a<t;){let o=e.charCodeAt(a);if(o===10){i+=1,a+=1;continue}if(o===13){i+=1,a+=1,a<t&&e.charCodeAt(a)===10&&(a+=1);continue}if(o===34){for(a+=1;a<t;){let t=e.charCodeAt(a);if(t===92){a+=2;continue}if(t===34){a+=1;break}if(t===10||t===13)break;a+=1}continue}if(o===123||o===91){n.push({opener:o,line:i}),a+=1;continue}if(o===125||o===93){let e=o===125?123:91,t=n[n.length-1];t?.opener===e?(n.pop(),t.line!==i&&r.push({id:String(t.line),startLine:t.line,endLine:i})):t!=null&&(n.length=0),a+=1;continue}a+=1}return m(r)}function g(e){switch(e){case`python`:case`py`:case`yaml`:case`yml`:return`indentation`;case`html`:case`xml`:return`tag`;case`bash`:case`sh`:case`shell`:case`plain`:case`plaintext`:case`text`:case`txt`:return`none`;default:return`bracket`}}function _({language:e,tokens:t}){switch(g(e)){case`bracket`:return S(t);case`indentation`:return w(t);case`tag`:return ee(t);case`none`:return[]}}function v(e){if(e.length===0)return!1;let t=e[e.length-1]?.scopeName??``;return t===`string`||t===`comment`||t.startsWith(`string.`)||t.startsWith(`comment.`)||t.startsWith(`constant.character.escape`)}function y(e){return e.explanation!=null&&e.explanation.length>0?e.explanation:[{content:e.content,scopes:[]}]}function b(e){let t=``;for(let n of e){let e=y(n),r=!1;for(let t of e)if(v(t.scopes)){r=!0;break}if(!r){t+=n.content;continue}for(let n of e)v(n.scopes)||(t+=n.content)}return t}function x(e){if(e==null||e.length===0)return-1;let t=0;for(let n of e){let e=n.content;for(let n=0;n<e.length;n+=1){let r=e.charCodeAt(n);if(r===32||r===9){t+=1;continue}return t}}return-1}function S(e){let t=[],n=[];for(let r=0;r<e.length;r+=1){let i=e[r];if(i==null)continue;let a=r+1;for(let e of i)if(C(e.content))for(let r of y(e)){if(v(r.scopes))continue;let e=r.content;for(let r=0;r<e.length;r+=1){let i=e.charCodeAt(r);if(i===123||i===91)t.push(a);else if(i===125||i===93){let e=t.pop();e!=null&&e!==a&&n.push({id:String(e),startLine:e,endLine:a})}}}}return m(n)}function C(e){for(let t=0;t<e.length;t+=1){let n=e.charCodeAt(t);if(n===123||n===125||n===91||n===93)return!0}return!1}function w(e){let t=Array.from({length:e.length});for(let n=0;n<e.length;n+=1)t[n]=x(e[n]);let n=[];for(let e=0;e<t.length;e+=1){let r=t[e]??-1;if(r<0)continue;let i=-1,a=e+1;for(;a<t.length;){let e=t[a]??-1;if(e<0){a+=1;continue}if(e>r){i=a,a+=1;continue}break}i>e&&n.push({id:String(e+1),startLine:e+1,endLine:i+2})}return m(n)}function ee(e){let t=[],n=[];for(let r=0;r<e.length;r+=1){let i=e[r];if(i==null)continue;let a=r+1,o=E(b(i));for(let e of o)if(e.kind===`open`)t.push({name:e.name,line:a});else{let r=t.length>0?t[t.length-1]:void 0;r!=null&&r.name.toLowerCase()===e.name.toLowerCase()&&(t.pop(),r.line!==a&&n.push({id:String(r.line),startLine:r.line,endLine:a}))}}return m(n)}const T=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`]);function E(e){let t=[],n=0;for(;n<e.length;){let r=e.indexOf(`<`,n);if(r===-1)break;let i=O(e,r+1),a=e.charCodeAt(i)===47;if(a&&(i=O(e,i+1)),!k(e.charCodeAt(i))){n=r+1;continue}let o=i;for(i+=1;i<e.length&&A(e.charCodeAt(i));)i+=1;let s=e.slice(o,i),c=j(e,i);if(c===-1){n=r+1;continue}if(a){t.push({name:s,kind:`close`}),n=c+1;continue}if(te(e,c)||T.has(s.toLowerCase())){n=c+1;continue}t.push({name:s,kind:`open`}),n=c+1}return t}function D(e){return e===9||e===10||e===11||e===12||e===13||e===32}function O(e,t){let n=t;for(;n<e.length&&D(e.charCodeAt(n));)n+=1;return n}function k(e){return e>=65&&e<=90||e>=97&&e<=122}function A(e){return k(e)||e>=48&&e<=57||e===45||e===58||e===95}function j(e,t){let n;for(let r=t;r<e.length;r+=1){let t=e.charCodeAt(r);if(n!=null){t===n&&(n=void 0);continue}if(t===34||t===39){n=t;continue}if(t===62)return r}return-1}function te(e,t){let n=t-1;for(;n>=0&&D(e.charCodeAt(n));)--n;return n>=0&&e.charCodeAt(n)===47}const ne=[`tabs`,`spaces`];function M(e){return ne.includes(e)}function re(e,t){return t||(F(e)?`tabs`:(I(e),`spaces`))}const N=new Set([`csharp`,`css`,`go`,`html`,`java`,`javascript`,`js`,`jsx`,`ts`,`tsx`,`typescript`,`xml`]),P=new Set([`python`,`py`,`yaml`,`yml`,`ruby`,`rb`]);function F(e){return N.has(e)}function I(e){return P.has(e)}function L(e,t){let n=t?.indentation??`spaces`,r=e.replace(/\r\n?/g,`
|
|
7
|
-
`),i=r.trim();if(i===``)return``;let a=B(r),o=i.split(`
|
|
8
|
-
`),s=Array.from({length:o.length});for(let e=0;e<o.length;e++){let t=o[e];t!=null&&(s[e]=R(z(t)?t:t.slice(a),n))}return s.join(`
|
|
9
|
-
`)}function R(e,t){let n=0;for(;n<e.length;){let t=e[n];if(t!==` `&&t!==` `)break;n+=1}if(n===0||n===e.length)return e;let r=e.slice(0,n);return(t===`spaces`?r.replace(/\t/g,` `):r.replace(/ {2}/g,` `))+e.slice(n)}function z(e){let t=e[0];return t!=null&&t!==` `&&t!==` `}function B(e){let t=1/0,n=0,r=!0;for(let i=0;i<e.length;i++){let a=e[i];if(r){if(a===` `||a===` `){n+=1;continue}if(a===`
|
|
10
|
-
`||a===`\r`){n=0;continue}if(n<t&&(t=n,t===0))return 0;r=!1;continue}(a===`
|
|
11
|
-
`||a===`\r`)&&(r=!0,n=0)}return t===1/0?0:t}const V=`bash.cs.csharp.css.go.html.java.javascript.js.json.jsx.plain.plaintext.py.python.rb.ruby.rust.sh.shell.text.ts.tsx.txt.typescript.xml.yaml.yml`.split(`.`),H=new Set(V),U=`text`;function W(e){let t=e?.trim()??``;if(!t)return U;let n=t.indexOf(`-`),r=n===-1?t:t.slice(n+1);return G(r)?r:U}const G=e=>typeof e==`string`&&H.has(e);function K(e){if(typeof e==`boolean`)return e;if(typeof e==`string`){if(e===`true`)return!0;if(e===`false`)return!1}}function q(e){if(typeof e==`number`&&Number.isFinite(e)&&e>0)return Math.floor(e);if(typeof e==`string`&&/^\d+$/.test(e)){let t=Number.parseInt(e,10);return t>0?t:void 0}}function J(e){if(typeof e==`number`)return Number.isFinite(e)&&e>0?Math.floor(e):void 0;if(typeof e==`string`){let t=e.trim();if(/^\d+$/.test(t)){let e=Number.parseInt(t,10);return e>0?e:void 0}if(/^\d+-\d+$/.test(t)){let[e,n]=t.split(`-`);return Number.parseInt(e??``,10)>0&&Number.parseInt(n??``,10)>0?t:void 0}}}function Y(e){if(typeof e==`string`){let t=[],n=e.split(`,`);for(let e of n){let n=J(e);n!=null&&t.push(n)}return t.length>0?t:void 0}if(!Array.isArray(e))return;let t=[];for(let n of e){let e=J(n);e!=null&&t.push(e)}return t.length>0?t:void 0}const X={collapsible:!1,disableCopy:!1,indentation:void 0,mode:void 0,title:void 0};function ie(e){let t=e?.trim()??``;if(!t)return X;let n={},r=Q(t);for(let e of r){let t=e.indexOf(`=`),r=t===-1?e:e.slice(0,t),i=t===-1?void 0:e.slice(t+1);r&&(n[r]=Z(i)??!0)}return oe(n)}function Z(e){if(e==null)return;let t=e.trim(),n=t.length-1;return n>=1&&t.charCodeAt(0)===34&&t.charCodeAt(n)===34?t.slice(1,n):t}function Q(e){let t=e?.trim()??``,n=[],r=``,i=!1;for(let e=0;e<t.length;e++){let a=t[e]??``;!i&&ae(a)?r&&=(n.push(r),``):(a===`"`&&(i=!i),r+=a)}return r&&n.push(r),n}function ae(e){return e===` `||e===` `||e===`
|
|
12
|
-
`||e===`\r`}function $(e){return e===`cli`||e===`file`||e===`traffic-policy`}function oe(e){let{collapsible:n=X.collapsible,disableCopy:r=X.disableCopy,indentation:i=X.indentation,mode:a=X.mode,title:o=X.title}=e;return{collapsible:typeof n==`string`||typeof n==`boolean`?t(n):X.collapsible,disableCopy:typeof r==`string`||typeof r==`boolean`?t(r):X.disableCopy,indentation:M(i)?i:X.indentation,mode:$(a)?a:X.mode,title:typeof o==`string`?o.trim():X.title}}function se(e){let{collapsible:n,disableCopy:r,mantleCode:i,mantleCollapsible:a,mantleDisableCopy:o,mantleHighlightLines:s,mantleLanguage:c,mantleLineNumberStart:l,mantleMode:u,mantlePreHtml:d,mantleShowLineNumbers:f,mantleTitle:p,mode:m,title:h,...g}=e;return c!=null||i!=null||d!=null||f!=null||s!=null||l!=null||a!=null||o!=null||u!=null||p!=null?{mantleCode:{code:typeof i==`string`?i:void 0,collapsible:(typeof a==`string`||typeof a==`boolean`?t(a):void 0)??(typeof n==`string`||typeof n==`boolean`?t(n):void 0),disableCopy:typeof o==`string`||typeof o==`boolean`?t(o):typeof r==`string`||typeof r==`boolean`?t(r):void 0,highlightLines:Y(s),language:typeof c==`string`&&G(c)?c:void 0,lineNumberStart:q(l),mode:$(u)?u:$(m)?m:void 0,preHtml:typeof d==`string`?d:void 0,rawLanguage:c,showLineNumbers:K(f),title:typeof p==`string`?p.trim():typeof h==`string`?h.trim():void 0},props:g}:{mantleCode:void 0,props:g}}export{s as S,h as _,Q as a,a as b,K as c,V as d,L as f,g,_ as h,se as i,G as l,M as m,Z as n,Y as o,re as p,ie as r,q as s,X as t,W as u,m as v,r as x,p as y};
|