@imfusion/web-ui 0.6.4-dev.1.g4ec1264f → 0.6.4-dev.7.g1840f300

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.
@@ -0,0 +1,134 @@
1
+ import { t as e } from "./chunk-DmhlhrBa.js";
2
+ import { t } from "./meta-CySnRuVp.js";
3
+ import { Ma as n, Xo as r, r as i } from "./icons-Cy1HAosO.js";
4
+ import { cx as a } from "class-variance-authority";
5
+ import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
6
+ import { useCallback as l, useEffect as u, useRef as d, useState as f } from "react";
7
+ import { mergeProps as p } from "@base-ui/react/merge-props";
8
+ import { useRender as m } from "@base-ui/react/use-render";
9
+ //#region src/hooks/use-clipboard.ts
10
+ function h({ timeout: e = 1500 } = {}) {
11
+ let [t, n] = f(!1), r = d(void 0);
12
+ return u(() => () => clearTimeout(r.current), []), {
13
+ copied: t,
14
+ copy: l((t) => {
15
+ navigator.clipboard.writeText(t).then(() => {
16
+ n(!0), clearTimeout(r.current), r.current = setTimeout(() => n(!1), e);
17
+ });
18
+ }, [e])
19
+ };
20
+ }
21
+ var g = {
22
+ block: "imf-ui-code-module-block",
23
+ copy: "imf-ui-code-module-copy",
24
+ inline: "imf-ui-code-module-inline",
25
+ inlineCopy: "imf-ui-code-module-inlineCopy",
26
+ inlineLink: "imf-ui-code-module-inlineLink",
27
+ language: "imf-ui-code-module-language",
28
+ pre: "imf-ui-code-module-pre",
29
+ separator: "imf-ui-code-module-separator"
30
+ }, _ = /* @__PURE__ */ e({
31
+ Block: () => b,
32
+ Inline: () => v,
33
+ InlineLink: () => y
34
+ });
35
+ function v({ className: e, copyable: t = !1, children: l, render: u, ...f }) {
36
+ let { copied: _, copy: v } = h(), y = d(null), b = _ ? n : r;
37
+ return m({
38
+ defaultTagName: "code",
39
+ render: u,
40
+ props: {
41
+ ...p(f, {
42
+ className: a(g.inline, e),
43
+ children: /* @__PURE__ */ c(o, { children: [
44
+ /* @__PURE__ */ s("span", {
45
+ ref: y,
46
+ children: l
47
+ }),
48
+ t && /* @__PURE__ */ s("span", { className: g.separator }),
49
+ t && /* @__PURE__ */ s("button", {
50
+ type: "button",
51
+ className: g.inlineCopy,
52
+ "data-copied": _ || void 0,
53
+ "aria-label": _ ? "Copied" : "Copy",
54
+ onClick: () => v(y.current?.textContent ?? ""),
55
+ children: /* @__PURE__ */ s(i, {
56
+ glyph: b,
57
+ size: 12,
58
+ strokeWidth: 2,
59
+ "aria-hidden": !0
60
+ })
61
+ })
62
+ ] })
63
+ }),
64
+ "data-imf-ui-component": "Code.Inline"
65
+ }
66
+ });
67
+ }
68
+ v.displayName = "Code.Inline";
69
+ function y({ kind: e = "external", ...t }) {
70
+ let n = e === "external" ? {
71
+ target: "_blank",
72
+ rel: "noreferrer"
73
+ } : {};
74
+ return m({
75
+ defaultTagName: "a",
76
+ render: t.render,
77
+ props: {
78
+ ...p(n, t, {
79
+ className: a(g.inline, g.inlineLink, t.className),
80
+ children: t.children
81
+ }),
82
+ "data-imf-ui-component": "Code.InlineLink",
83
+ "data-kind": e
84
+ }
85
+ });
86
+ }
87
+ y.displayName = "Code.InlineLink";
88
+ function b({ className: e, language: t, hideCopy: o = !1, children: l, ...u }) {
89
+ let { copied: f, copy: p } = h(), m = d(null), _ = f ? n : r;
90
+ return /* @__PURE__ */ c("div", {
91
+ "data-imf-ui-component": "Code.Block",
92
+ className: a(g.block, e),
93
+ children: [
94
+ t != null && /* @__PURE__ */ s("span", {
95
+ className: g.language,
96
+ children: t
97
+ }),
98
+ !o && /* @__PURE__ */ s("button", {
99
+ type: "button",
100
+ className: g.copy,
101
+ "data-copied": f || void 0,
102
+ "aria-label": f ? "Copied" : "Copy",
103
+ onClick: () => p(m.current?.textContent ?? ""),
104
+ children: /* @__PURE__ */ s(i, {
105
+ glyph: _,
106
+ size: 12,
107
+ strokeWidth: 2,
108
+ "aria-hidden": !0
109
+ })
110
+ }),
111
+ /* @__PURE__ */ s("pre", {
112
+ ...u,
113
+ className: g.pre,
114
+ children: /* @__PURE__ */ s("code", {
115
+ ref: m,
116
+ children: l
117
+ })
118
+ })
119
+ ]
120
+ });
121
+ }
122
+ b.displayName = "Code.Block";
123
+ //#endregion
124
+ //#region src/components/code/code.meta.ts
125
+ var x = {
126
+ name: "Code",
127
+ category: t.display,
128
+ status: "stable",
129
+ namespace: !0,
130
+ description: "Displays source code inline or in a block, with optional language labels and copying. Also called a code snippet or code block.",
131
+ origin: "native"
132
+ };
133
+ //#endregion
134
+ export { _ as a, y as i, b as n, h as o, v as r, x as t };
@@ -15,20 +15,18 @@ export declare namespace Inline {
15
15
  var displayName: string;
16
16
  }
17
17
  export type CodeInlineLinkKind = "external" | "internal";
18
- type InlineLinkProps = Omit<useRender.ComponentProps<"a">, "children"> & {
19
- /** The link text, as a raw string, rendered as a code fragment. */
20
- children: string;
21
- /** Link target scope. `"external"` (default) opens in a new tab with a diagonal `ArrowUpRight` icon; `"internal"` stays in the current tab with a horizontal `ArrowRight` icon. */
18
+ type InlineLinkProps = useRender.ComponentProps<"a"> & {
19
+ /** Link target scope. `"external"` (default) opens in a new tab; `"internal"` stays in the current tab. */
22
20
  kind?: CodeInlineLinkKind;
23
21
  };
24
22
  /**
25
23
  * Code.InlineLink — the inline-code chip rendered as a link: the same hairline
26
- * box, with a directional arrow behind the separator instead of a copy button.
24
+ * box, with an optional directional arrow behind the separator instead of a copy button.
27
25
  * Sibling of `Code.Inline`, sharing its chip visual (`.inline`) — never both a
28
26
  * copy button and a link on the same chip. Mirrors `ChipLink`'s shape (anchor
29
27
  * is the chip root, trailing icon nudges on hover, `data-kind` picks the icon).
30
28
  */
31
- export declare function InlineLink({ className, kind, children, render, ...props }: InlineLinkProps): import('react').ReactElement<unknown, string | import('react').JSXElementConstructor<any>>;
29
+ export declare function InlineLink({ kind, ...props }: InlineLinkProps): import('react').ReactElement<unknown, string | import('react').JSXElementConstructor<any>>;
32
30
  export declare namespace InlineLink {
33
31
  var displayName: string;
34
32
  }
@@ -20,7 +20,7 @@ type OrderedListProps = useRender.ComponentProps<"ol"> & TypoProps & SpacingProp
20
20
  type UnorderedListProps = useRender.ComponentProps<"ul"> & TypoProps & SpacingProps;
21
21
  export type TypoLinkKind = "external" | "internal";
22
22
  type LinkProps = useRender.ComponentProps<"a"> & TypoProps & {
23
- /** Link target scope. `"external"` (default) opens in a new tab with a diagonal `ArrowUpRight` icon; `"internal"` stays in the current tab with a horizontal `ArrowRight` icon. */
23
+ /** Link target scope. `"external"` (default) opens in a new tab; `"internal"` stays in the current tab. */
24
24
  kind?: TypoLinkKind;
25
25
  };
26
26
  /** Typo.H1 — top-level page heading. */
@@ -83,7 +83,7 @@ export declare function Highlight({ variant, className, render, ...props }: Inli
83
83
  export declare namespace Highlight {
84
84
  var displayName: string;
85
85
  }
86
- /** Typo.Link — inline anchor. Auto-appends a local Web UI directional icon (`ArrowUpRight` for external, `ArrowRight` for internal), mirroring ChipLink's affordance for prose links. */
86
+ /** Typo.Link — inline anchor with an optional local Web UI directional icon. */
87
87
  export declare function Link({ variant, kind, className, render, ...props }: LinkProps): import('react').ReactElement<unknown, string | import('react').JSXElementConstructor<any>>;
88
88
  export declare namespace Link {
89
89
  var displayName: string;