@nucleux/md3-caveat 0.0.0-stage → 0.6.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/LICENSE +21 -0
- package/README.md +35 -2
- package/dist/index.cjs +91 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +25 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +68 -0
- package/dist/index.js.map +1 -0
- package/package.json +59 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nucleux
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,36 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @nucleux/md3-caveat
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Material 3 Caveat — a calm, specific note on what to check about an AI result — Nucleux agentic UI for React.
|
|
4
|
+
|
|
5
|
+
Part of **[Nucleux](https://github.com/intelligaia-open-labs/nucleux)** — agentic UI components for React. Install a single component, or the full kit via [`@nucleux/react`](https://www.npmjs.com/package/@nucleux/react).
|
|
6
|
+
|
|
7
|
+
The Material 3 twin of [`@nucleux/caveat`](https://www.npmjs.com/package/@nucleux/caveat): it shares that package's API — the props types are re-exported from it — so you switch families by changing only the import. Only the look differs: Material 3 colour roles, shape, state layers and motion (with reduced-motion handling).
|
|
8
|
+
|
|
9
|
+
## Exports
|
|
10
|
+
|
|
11
|
+
- **`Md3Caveat`** — a `note`: `variant` below-input / output-footer, `icon`, `actions`
|
|
12
|
+
- **`Md3CaveatTooltip`** — the info-tooltip caveat riding an AI control, linked with `aria-describedby`; `content`, `side`, `showIcon`
|
|
13
|
+
- Types: `Md3CaveatProps`, `Md3CaveatTooltipProps`, `Md3CaveatVariant`
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pnpm add @nucleux/md3-caveat @nucleux/tokens
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`react` / `react-dom` are peer dependencies.
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
import { Md3Caveat } from "@nucleux/md3-caveat";
|
|
27
|
+
|
|
28
|
+
<Md3Caveat variant="output-footer">2 of 8 interviews could not be opened, so this summary reflects 6.</Md3Caveat>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Requires the theme once in your app: `import "@nucleux/tokens/styles.css";`
|
|
32
|
+
and the Tailwind preset from `@nucleux/tokens/preset`.
|
|
33
|
+
|
|
34
|
+
## License
|
|
35
|
+
|
|
36
|
+
MIT © Nucleux
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var lucideReact = require('lucide-react');
|
|
6
|
+
var utils = require('@nucleux/utils');
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
+
|
|
9
|
+
function _interopNamespace(e) {
|
|
10
|
+
if (e && e.__esModule) return e;
|
|
11
|
+
var n = Object.create(null);
|
|
12
|
+
if (e) {
|
|
13
|
+
Object.keys(e).forEach(function (k) {
|
|
14
|
+
if (k !== 'default') {
|
|
15
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
16
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return e[k]; }
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
n.default = e;
|
|
24
|
+
return Object.freeze(n);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
28
|
+
|
|
29
|
+
// src/index.tsx
|
|
30
|
+
var DEFAULT_TEXT = "AI can make mistakes. Verify important information.";
|
|
31
|
+
var Md3Caveat = React__namespace.forwardRef(
|
|
32
|
+
({ variant = "below-input", icon, actions, className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
33
|
+
"p",
|
|
34
|
+
{
|
|
35
|
+
ref,
|
|
36
|
+
role: "note",
|
|
37
|
+
"data-variant": variant,
|
|
38
|
+
className: utils.cn(
|
|
39
|
+
"items-center gap-2 text-xs leading-4 tracking-[0.4px] text-md-on-surface-variant [&_svg]:size-3.5 [&_svg]:shrink-0",
|
|
40
|
+
variant === "output-footer" ? "mt-3.5 flex w-full flex-wrap rounded-md-sm bg-md-surface-container px-3 py-2.5 animate-nx-fade-in motion-reduce:animate-none" : "inline-flex",
|
|
41
|
+
className
|
|
42
|
+
),
|
|
43
|
+
...props,
|
|
44
|
+
children: [
|
|
45
|
+
icon === void 0 ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Info, { "aria-hidden": "true" }) : icon,
|
|
46
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: children ?? DEFAULT_TEXT }),
|
|
47
|
+
actions && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-auto inline-flex flex-wrap items-center gap-1", children: actions })
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
)
|
|
51
|
+
);
|
|
52
|
+
Md3Caveat.displayName = "Md3Caveat";
|
|
53
|
+
var tipSides = {
|
|
54
|
+
top: "bottom-full left-1/2 mb-1 -translate-x-1/2",
|
|
55
|
+
bottom: "top-full left-1/2 mt-1 -translate-x-1/2",
|
|
56
|
+
left: "right-full top-1/2 mr-1 -translate-y-1/2",
|
|
57
|
+
right: "left-full top-1/2 ml-1 -translate-y-1/2"
|
|
58
|
+
};
|
|
59
|
+
var Md3CaveatTooltip = React__namespace.forwardRef(
|
|
60
|
+
({ content = "Output may be inaccurate", side = "top", showIcon = true, children, className, ...props }, ref) => {
|
|
61
|
+
const id = React__namespace.useId();
|
|
62
|
+
const childProps = children.props;
|
|
63
|
+
const trigger = React__namespace.cloneElement(children, {
|
|
64
|
+
"aria-describedby": [childProps["aria-describedby"], id].filter(Boolean).join(" ")
|
|
65
|
+
});
|
|
66
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { ref, className: utils.cn("group/caveat relative inline-flex", className), ...props, children: [
|
|
67
|
+
trigger,
|
|
68
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
69
|
+
"span",
|
|
70
|
+
{
|
|
71
|
+
role: "tooltip",
|
|
72
|
+
className: utils.cn(
|
|
73
|
+
"pointer-events-none invisible absolute z-50 whitespace-nowrap rounded-md-xs bg-md-inverse-surface px-2 py-1 text-xs tracking-[0.4px] text-md-inverse-on-surface opacity-0 transition-opacity duration-150 motion-reduce:transition-none",
|
|
74
|
+
"group-hover/caveat:visible group-hover/caveat:opacity-100 group-focus-within/caveat:visible group-focus-within/caveat:opacity-100",
|
|
75
|
+
tipSides[side]
|
|
76
|
+
),
|
|
77
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("span", { id, className: "inline-flex items-center gap-1.5 [&_svg]:size-3", children: [
|
|
78
|
+
showIcon && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Info, { "aria-hidden": "true" }),
|
|
79
|
+
content
|
|
80
|
+
] })
|
|
81
|
+
}
|
|
82
|
+
)
|
|
83
|
+
] });
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
Md3CaveatTooltip.displayName = "Md3CaveatTooltip";
|
|
87
|
+
|
|
88
|
+
exports.Md3Caveat = Md3Caveat;
|
|
89
|
+
exports.Md3CaveatTooltip = Md3CaveatTooltip;
|
|
90
|
+
//# sourceMappingURL=index.cjs.map
|
|
91
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.tsx"],"names":["React","jsxs","cn","jsx","Info"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,IAAM,YAAA,GAAe,qDAAA;AAUd,IAAM,SAAA,GAAkBA,gBAAA,CAAA,UAAA;AAAA,EAC7B,CAAC,EAAE,OAAA,GAAU,aAAA,EAAe,IAAA,EAAM,OAAA,EAAS,SAAA,EAAW,QAAA,EAAU,GAAG,KAAA,EAAM,EAAG,GAAA,qBAC1EC,eAAA;AAAA,IAAC,GAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,IAAA,EAAK,MAAA;AAAA,MACL,cAAA,EAAc,OAAA;AAAA,MACd,SAAA,EAAWC,QAAA;AAAA,QACT,oHAAA;AAAA,QACA,OAAA,KAAY,kBACR,8HAAA,GACA,aAAA;AAAA,QACJ;AAAA,OACF;AAAA,MACC,GAAG,KAAA;AAAA,MAEH,QAAA,EAAA;AAAA,QAAA,IAAA,KAAS,MAAA,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;AAAA,YACT,yOAAA;AAAA,YACA,mIAAA;AAAA,YACA,SAAS,IAAI;AAAA,WACf;AAAA,UAEA,QAAA,kBAAAD,eAAA,CAAC,MAAA,EAAA,EAAK,EAAA,EAAQ,SAAA,EAAU,iDAAA,EACrB,QAAA,EAAA;AAAA,YAAA,QAAA,oBAAYE,cAAA,CAACC,gBAAA,EAAA,EAAK,aAAA,EAAY,MAAA,EAAO,CAAA;AAAA,YACrC;AAAA,WAAA,EACH;AAAA;AAAA;AACF,KAAA,EACF,CAAA;AAAA,EAEJ;AACF;AACA,gBAAA,CAAiB,WAAA,GAAc,kBAAA","file":"index.cjs","sourcesContent":["import * as React from \"react\";\nimport { Info } from \"lucide-react\";\nimport { cn } from \"@nucleux/utils\";\nimport type { CaveatProps, CaveatTooltipProps, CaveatVariant } from \"@nucleux/caveat\";\n\nexport type Md3CaveatProps = CaveatProps;\nexport type Md3CaveatTooltipProps = CaveatTooltipProps;\nexport type Md3CaveatVariant = CaveatVariant;\n\ntype TipSide = NonNullable<CaveatTooltipProps[\"side\"]>;\n\nconst DEFAULT_TEXT = \"AI can make mistakes. Verify important information.\";\n\n/**\n * A short, calm note on what to check about an AI result — the Material 3\n * twin of `Caveat`, with the same API. Caution, not alarm: an outline info\n * mark in body-small on-surface-variant, never the error role. `below-input`\n * is a caption under the composer; `output-footer` gets a surface-container\n * ground so it separates from the output it qualifies, and can carry the\n * next steps that remove the reason for it. Rendered as a `note`.\n */\nexport const Md3Caveat = React.forwardRef<HTMLParagraphElement, Md3CaveatProps>(\n ({ variant = \"below-input\", icon, actions, className, children, ...props }, ref) => (\n <p\n ref={ref}\n role=\"note\"\n data-variant={variant}\n className={cn(\n \"items-center gap-2 text-xs leading-4 tracking-[0.4px] text-md-on-surface-variant [&_svg]:size-3.5 [&_svg]:shrink-0\",\n variant === \"output-footer\"\n ? \"mt-3.5 flex w-full flex-wrap rounded-md-sm bg-md-surface-container px-3 py-2.5 animate-nx-fade-in motion-reduce:animate-none\"\n : \"inline-flex\",\n className,\n )}\n {...props}\n >\n {icon === undefined ? <Info aria-hidden=\"true\" /> : icon}\n <span>{children ?? DEFAULT_TEXT}</span>\n {actions && <span className=\"ml-auto inline-flex flex-wrap items-center gap-1\">{actions}</span>}\n </p>\n ),\n);\nMd3Caveat.displayName = \"Md3Caveat\";\n\nconst tipSides: Record<TipSide, string> = {\n top: \"bottom-full left-1/2 mb-1 -translate-x-1/2\",\n bottom: \"top-full left-1/2 mt-1 -translate-x-1/2\",\n left: \"right-full top-1/2 mr-1 -translate-y-1/2\",\n right: \"left-full top-1/2 ml-1 -translate-y-1/2\",\n};\n\n/**\n * The `info-tooltip` caveat in Material 3 — the twin of `CaveatTooltip`. The\n * reminder rides the generate control as an M3 plain tooltip\n * (inverse-surface, extra-small corners) shown on hover and keyboard focus,\n * fading in over 150 ms (instantly under reduced motion), and it describes\n * the control through `aria-describedby` so screen readers hear it too.\n */\nexport const Md3CaveatTooltip = React.forwardRef<HTMLSpanElement, Md3CaveatTooltipProps>(\n ({ content = \"Output may be inaccurate\", side = \"top\", showIcon = true, children, className, ...props }, ref) => {\n const id = React.useId();\n const childProps = children.props as { \"aria-describedby\"?: string };\n const trigger = React.cloneElement(children, {\n \"aria-describedby\": [childProps[\"aria-describedby\"], id].filter(Boolean).join(\" \"),\n } as Record<string, unknown>);\n return (\n <span ref={ref} className={cn(\"group/caveat relative inline-flex\", className)} {...props}>\n {trigger}\n <span\n role=\"tooltip\"\n className={cn(\n \"pointer-events-none invisible absolute z-50 whitespace-nowrap rounded-md-xs bg-md-inverse-surface px-2 py-1 text-xs tracking-[0.4px] text-md-inverse-on-surface opacity-0 transition-opacity duration-150 motion-reduce:transition-none\",\n \"group-hover/caveat:visible group-hover/caveat:opacity-100 group-focus-within/caveat:visible group-focus-within/caveat:opacity-100\",\n tipSides[side],\n )}\n >\n <span id={id} className=\"inline-flex items-center gap-1.5 [&_svg]:size-3\">\n {showIcon && <Info aria-hidden=\"true\" />}\n {content}\n </span>\n </span>\n </span>\n );\n },\n);\nMd3CaveatTooltip.displayName = \"Md3CaveatTooltip\";\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { CaveatProps, CaveatTooltipProps, CaveatVariant } from '@nucleux/caveat';
|
|
3
|
+
|
|
4
|
+
type Md3CaveatProps = CaveatProps;
|
|
5
|
+
type Md3CaveatTooltipProps = CaveatTooltipProps;
|
|
6
|
+
type Md3CaveatVariant = CaveatVariant;
|
|
7
|
+
/**
|
|
8
|
+
* A short, calm note on what to check about an AI result — the Material 3
|
|
9
|
+
* twin of `Caveat`, with the same API. Caution, not alarm: an outline info
|
|
10
|
+
* mark in body-small on-surface-variant, never the error role. `below-input`
|
|
11
|
+
* is a caption under the composer; `output-footer` gets a surface-container
|
|
12
|
+
* ground so it separates from the output it qualifies, and can carry the
|
|
13
|
+
* next steps that remove the reason for it. Rendered as a `note`.
|
|
14
|
+
*/
|
|
15
|
+
declare const Md3Caveat: React.ForwardRefExoticComponent<CaveatProps & React.RefAttributes<HTMLParagraphElement>>;
|
|
16
|
+
/**
|
|
17
|
+
* The `info-tooltip` caveat in Material 3 — the twin of `CaveatTooltip`. The
|
|
18
|
+
* reminder rides the generate control as an M3 plain tooltip
|
|
19
|
+
* (inverse-surface, extra-small corners) shown on hover and keyboard focus,
|
|
20
|
+
* fading in over 150 ms (instantly under reduced motion), and it describes
|
|
21
|
+
* the control through `aria-describedby` so screen readers hear it too.
|
|
22
|
+
*/
|
|
23
|
+
declare const Md3CaveatTooltip: React.ForwardRefExoticComponent<CaveatTooltipProps & React.RefAttributes<HTMLSpanElement>>;
|
|
24
|
+
|
|
25
|
+
export { Md3Caveat, type Md3CaveatProps, Md3CaveatTooltip, type Md3CaveatTooltipProps, type Md3CaveatVariant };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { CaveatProps, CaveatTooltipProps, CaveatVariant } from '@nucleux/caveat';
|
|
3
|
+
|
|
4
|
+
type Md3CaveatProps = CaveatProps;
|
|
5
|
+
type Md3CaveatTooltipProps = CaveatTooltipProps;
|
|
6
|
+
type Md3CaveatVariant = CaveatVariant;
|
|
7
|
+
/**
|
|
8
|
+
* A short, calm note on what to check about an AI result — the Material 3
|
|
9
|
+
* twin of `Caveat`, with the same API. Caution, not alarm: an outline info
|
|
10
|
+
* mark in body-small on-surface-variant, never the error role. `below-input`
|
|
11
|
+
* is a caption under the composer; `output-footer` gets a surface-container
|
|
12
|
+
* ground so it separates from the output it qualifies, and can carry the
|
|
13
|
+
* next steps that remove the reason for it. Rendered as a `note`.
|
|
14
|
+
*/
|
|
15
|
+
declare const Md3Caveat: React.ForwardRefExoticComponent<CaveatProps & React.RefAttributes<HTMLParagraphElement>>;
|
|
16
|
+
/**
|
|
17
|
+
* The `info-tooltip` caveat in Material 3 — the twin of `CaveatTooltip`. The
|
|
18
|
+
* reminder rides the generate control as an M3 plain tooltip
|
|
19
|
+
* (inverse-surface, extra-small corners) shown on hover and keyboard focus,
|
|
20
|
+
* fading in over 150 ms (instantly under reduced motion), and it describes
|
|
21
|
+
* the control through `aria-describedby` so screen readers hear it too.
|
|
22
|
+
*/
|
|
23
|
+
declare const Md3CaveatTooltip: React.ForwardRefExoticComponent<CaveatTooltipProps & React.RefAttributes<HTMLSpanElement>>;
|
|
24
|
+
|
|
25
|
+
export { Md3Caveat, type Md3CaveatProps, Md3CaveatTooltip, type Md3CaveatTooltipProps, type Md3CaveatVariant };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { Info } from 'lucide-react';
|
|
4
|
+
import { cn } from '@nucleux/utils';
|
|
5
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
// src/index.tsx
|
|
8
|
+
var DEFAULT_TEXT = "AI can make mistakes. Verify important information.";
|
|
9
|
+
var Md3Caveat = React.forwardRef(
|
|
10
|
+
({ variant = "below-input", icon, actions, className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
11
|
+
"p",
|
|
12
|
+
{
|
|
13
|
+
ref,
|
|
14
|
+
role: "note",
|
|
15
|
+
"data-variant": variant,
|
|
16
|
+
className: cn(
|
|
17
|
+
"items-center gap-2 text-xs leading-4 tracking-[0.4px] text-md-on-surface-variant [&_svg]:size-3.5 [&_svg]:shrink-0",
|
|
18
|
+
variant === "output-footer" ? "mt-3.5 flex w-full flex-wrap rounded-md-sm bg-md-surface-container px-3 py-2.5 animate-nx-fade-in motion-reduce:animate-none" : "inline-flex",
|
|
19
|
+
className
|
|
20
|
+
),
|
|
21
|
+
...props,
|
|
22
|
+
children: [
|
|
23
|
+
icon === void 0 ? /* @__PURE__ */ jsx(Info, { "aria-hidden": "true" }) : icon,
|
|
24
|
+
/* @__PURE__ */ jsx("span", { children: children ?? DEFAULT_TEXT }),
|
|
25
|
+
actions && /* @__PURE__ */ jsx("span", { className: "ml-auto inline-flex flex-wrap items-center gap-1", children: actions })
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
)
|
|
29
|
+
);
|
|
30
|
+
Md3Caveat.displayName = "Md3Caveat";
|
|
31
|
+
var tipSides = {
|
|
32
|
+
top: "bottom-full left-1/2 mb-1 -translate-x-1/2",
|
|
33
|
+
bottom: "top-full left-1/2 mt-1 -translate-x-1/2",
|
|
34
|
+
left: "right-full top-1/2 mr-1 -translate-y-1/2",
|
|
35
|
+
right: "left-full top-1/2 ml-1 -translate-y-1/2"
|
|
36
|
+
};
|
|
37
|
+
var Md3CaveatTooltip = React.forwardRef(
|
|
38
|
+
({ content = "Output may be inaccurate", side = "top", showIcon = true, children, className, ...props }, ref) => {
|
|
39
|
+
const id = React.useId();
|
|
40
|
+
const childProps = children.props;
|
|
41
|
+
const trigger = React.cloneElement(children, {
|
|
42
|
+
"aria-describedby": [childProps["aria-describedby"], id].filter(Boolean).join(" ")
|
|
43
|
+
});
|
|
44
|
+
return /* @__PURE__ */ jsxs("span", { ref, className: cn("group/caveat relative inline-flex", className), ...props, children: [
|
|
45
|
+
trigger,
|
|
46
|
+
/* @__PURE__ */ jsx(
|
|
47
|
+
"span",
|
|
48
|
+
{
|
|
49
|
+
role: "tooltip",
|
|
50
|
+
className: cn(
|
|
51
|
+
"pointer-events-none invisible absolute z-50 whitespace-nowrap rounded-md-xs bg-md-inverse-surface px-2 py-1 text-xs tracking-[0.4px] text-md-inverse-on-surface opacity-0 transition-opacity duration-150 motion-reduce:transition-none",
|
|
52
|
+
"group-hover/caveat:visible group-hover/caveat:opacity-100 group-focus-within/caveat:visible group-focus-within/caveat:opacity-100",
|
|
53
|
+
tipSides[side]
|
|
54
|
+
),
|
|
55
|
+
children: /* @__PURE__ */ jsxs("span", { id, className: "inline-flex items-center gap-1.5 [&_svg]:size-3", children: [
|
|
56
|
+
showIcon && /* @__PURE__ */ jsx(Info, { "aria-hidden": "true" }),
|
|
57
|
+
content
|
|
58
|
+
] })
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
] });
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
Md3CaveatTooltip.displayName = "Md3CaveatTooltip";
|
|
65
|
+
|
|
66
|
+
export { Md3Caveat, Md3CaveatTooltip };
|
|
67
|
+
//# sourceMappingURL=index.js.map
|
|
68
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.tsx"],"names":[],"mappings":";;;;;;AAWA,IAAM,YAAA,GAAe,qDAAA;AAUd,IAAM,SAAA,GAAkB,KAAA,CAAA,UAAA;AAAA,EAC7B,CAAC,EAAE,OAAA,GAAU,aAAA,EAAe,IAAA,EAAM,OAAA,EAAS,SAAA,EAAW,QAAA,EAAU,GAAG,KAAA,EAAM,EAAG,GAAA,qBAC1E,IAAA;AAAA,IAAC,GAAA;AAAA,IAAA;AAAA,MACC,G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,uBACE,IAAA,CAAC,UAAK,GAAA,EAAU,SAAA,EAAW,GAAG,mCAAA,EAAqC,SAAS,CAAA,EAAI,GAAG,KAAA,EAChF,QAAA,EAAA;AAAA,MAAA,OAAA;AAAA,sBACD,GAAA;AAAA,QAAC,MAAA;AAAA,QAAA;AAAA,UACC,IAAA,EAAK,SAAA;AAAA,UACL,SAAA,EAAW,EAAA;AAAA,YACT,yOAAA;AAAA,YACA,mIAAA;AAAA,YACA,SAAS,IAAI;AAAA,WACf;AAAA,UAEA,QAAA,kBAAA,IAAA,CAAC,MAAA,EAAA,EAAK,EAAA,EAAQ,SAAA,EAAU,iDAAA,EACrB,QAAA,EAAA;AAAA,YAAA,QAAA,oBAAY,GAAA,CAAC,IAAA,EAAA,EAAK,aAAA,EAAY,MAAA,EAAO,CAAA;AAAA,YACrC;AAAA,WAAA,EACH;AAAA;AAAA;AACF,KAAA,EACF,CAAA;AAAA,EAEJ;AACF;AACA,gBAAA,CAAiB,WAAA,GAAc,kBAAA","file":"index.js","sourcesContent":["import * as React from \"react\";\nimport { Info } from \"lucide-react\";\nimport { cn } from \"@nucleux/utils\";\nimport type { CaveatProps, CaveatTooltipProps, CaveatVariant } from \"@nucleux/caveat\";\n\nexport type Md3CaveatProps = CaveatProps;\nexport type Md3CaveatTooltipProps = CaveatTooltipProps;\nexport type Md3CaveatVariant = CaveatVariant;\n\ntype TipSide = NonNullable<CaveatTooltipProps[\"side\"]>;\n\nconst DEFAULT_TEXT = \"AI can make mistakes. Verify important information.\";\n\n/**\n * A short, calm note on what to check about an AI result — the Material 3\n * twin of `Caveat`, with the same API. Caution, not alarm: an outline info\n * mark in body-small on-surface-variant, never the error role. `below-input`\n * is a caption under the composer; `output-footer` gets a surface-container\n * ground so it separates from the output it qualifies, and can carry the\n * next steps that remove the reason for it. Rendered as a `note`.\n */\nexport const Md3Caveat = React.forwardRef<HTMLParagraphElement, Md3CaveatProps>(\n ({ variant = \"below-input\", icon, actions, className, children, ...props }, ref) => (\n <p\n ref={ref}\n role=\"note\"\n data-variant={variant}\n className={cn(\n \"items-center gap-2 text-xs leading-4 tracking-[0.4px] text-md-on-surface-variant [&_svg]:size-3.5 [&_svg]:shrink-0\",\n variant === \"output-footer\"\n ? \"mt-3.5 flex w-full flex-wrap rounded-md-sm bg-md-surface-container px-3 py-2.5 animate-nx-fade-in motion-reduce:animate-none\"\n : \"inline-flex\",\n className,\n )}\n {...props}\n >\n {icon === undefined ? <Info aria-hidden=\"true\" /> : icon}\n <span>{children ?? DEFAULT_TEXT}</span>\n {actions && <span className=\"ml-auto inline-flex flex-wrap items-center gap-1\">{actions}</span>}\n </p>\n ),\n);\nMd3Caveat.displayName = \"Md3Caveat\";\n\nconst tipSides: Record<TipSide, string> = {\n top: \"bottom-full left-1/2 mb-1 -translate-x-1/2\",\n bottom: \"top-full left-1/2 mt-1 -translate-x-1/2\",\n left: \"right-full top-1/2 mr-1 -translate-y-1/2\",\n right: \"left-full top-1/2 ml-1 -translate-y-1/2\",\n};\n\n/**\n * The `info-tooltip` caveat in Material 3 — the twin of `CaveatTooltip`. The\n * reminder rides the generate control as an M3 plain tooltip\n * (inverse-surface, extra-small corners) shown on hover and keyboard focus,\n * fading in over 150 ms (instantly under reduced motion), and it describes\n * the control through `aria-describedby` so screen readers hear it too.\n */\nexport const Md3CaveatTooltip = React.forwardRef<HTMLSpanElement, Md3CaveatTooltipProps>(\n ({ content = \"Output may be inaccurate\", side = \"top\", showIcon = true, children, className, ...props }, ref) => {\n const id = React.useId();\n const childProps = children.props as { \"aria-describedby\"?: string };\n const trigger = React.cloneElement(children, {\n \"aria-describedby\": [childProps[\"aria-describedby\"], id].filter(Boolean).join(\" \"),\n } as Record<string, unknown>);\n return (\n <span ref={ref} className={cn(\"group/caveat relative inline-flex\", className)} {...props}>\n {trigger}\n <span\n role=\"tooltip\"\n className={cn(\n \"pointer-events-none invisible absolute z-50 whitespace-nowrap rounded-md-xs bg-md-inverse-surface px-2 py-1 text-xs tracking-[0.4px] text-md-inverse-on-surface opacity-0 transition-opacity duration-150 motion-reduce:transition-none\",\n \"group-hover/caveat:visible group-hover/caveat:opacity-100 group-focus-within/caveat:visible group-focus-within/caveat:opacity-100\",\n tipSides[side],\n )}\n >\n <span id={id} className=\"inline-flex items-center gap-1.5 [&_svg]:size-3\">\n {showIcon && <Info aria-hidden=\"true\" />}\n {content}\n </span>\n </span>\n </span>\n );\n },\n);\nMd3CaveatTooltip.displayName = \"Md3CaveatTooltip\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,62 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nucleux/md3-caveat",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.6.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"sideEffects": false,
|
|
6
|
+
"description": "Material 3 Caveat — a calm, specific note on what to check about an AI result — Nucleux agentic UI for React.",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"nucleux",
|
|
9
|
+
"react",
|
|
10
|
+
"ui",
|
|
11
|
+
"components",
|
|
12
|
+
"agentic",
|
|
13
|
+
"ai",
|
|
14
|
+
"tailwind",
|
|
15
|
+
"md3",
|
|
16
|
+
"material",
|
|
17
|
+
"md3-caveat",
|
|
18
|
+
"caveat"
|
|
19
|
+
],
|
|
20
|
+
"main": "./dist/index.cjs",
|
|
21
|
+
"module": "./dist/index.js",
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"import": "./dist/index.js",
|
|
27
|
+
"require": "./dist/index.cjs"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"README.md"
|
|
33
|
+
],
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"react": ">=18",
|
|
36
|
+
"react-dom": ">=18"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@nucleux/caveat": "0.6.0",
|
|
40
|
+
"@nucleux/utils": "0.6.0",
|
|
41
|
+
"lucide-react": "^0.469.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"tsup": "^8.3.5",
|
|
45
|
+
"typescript": "^5.7.2",
|
|
46
|
+
"@types/react": "^18.3.18",
|
|
47
|
+
"react": "^18.3.1"
|
|
48
|
+
},
|
|
49
|
+
"publishConfig": {
|
|
50
|
+
"access": "public"
|
|
51
|
+
},
|
|
52
|
+
"license": "MIT",
|
|
53
|
+
"repository": {
|
|
54
|
+
"type": "git",
|
|
55
|
+
"url": "git+https://github.com/intelligaia-open-labs/nucleux.git",
|
|
56
|
+
"directory": "packages/md3-caveat"
|
|
57
|
+
},
|
|
58
|
+
"homepage": "https://github.com/intelligaia-open-labs/nucleux#readme",
|
|
59
|
+
"scripts": {
|
|
60
|
+
"build": "tsup"
|
|
61
|
+
}
|
|
6
62
|
}
|