@gridui/citation-popover 0.0.0-stage → 1.0.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/README.md +7 -2
- package/dist/citation-popover/citation-popover.d.ts +17 -0
- package/dist/citation-popover/style.d.ts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +70 -0
- package/dist/index.js.map +7 -0
- package/dist/styles.css +53 -0
- package/package.json +49 -3
package/README.md
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @gridui/citation-popover
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Dashboard family. Public API: `CitationPopover`, `CitationPopoverProps`.
|
|
4
|
+
|
|
5
|
+
Import components from `@gridui/citation-popover` and load `@gridui/citation-popover/styles.css` after Theme.
|
|
6
|
+
Load styles for any composed dependency used by this family. Applications own routes, labels, state persistence, and branding.
|
|
7
|
+
|
|
8
|
+
See [component ownership](../../docs/component-ownership.md) and [release history](.changeset/history/).
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @package Citation Popover
|
|
4
|
+
* @namespace CitationPopover
|
|
5
|
+
* @description Citation Popover
|
|
6
|
+
*/
|
|
7
|
+
import type { SourceItem } from "@gridui/source-list";
|
|
8
|
+
import { type FC, type ReactNode } from "react";
|
|
9
|
+
export type CitationPopoverProps = {
|
|
10
|
+
readonly source: SourceItem;
|
|
11
|
+
readonly marker: ReactNode;
|
|
12
|
+
readonly label: string;
|
|
13
|
+
readonly openLabel: string;
|
|
14
|
+
readonly quote?: string;
|
|
15
|
+
readonly unmatchedLabel: string;
|
|
16
|
+
};
|
|
17
|
+
export declare const CitationPopover: FC<CitationPopoverProps>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author WMXPY
|
|
3
|
+
* @package Citation Popover
|
|
4
|
+
* @namespace CitationPopover
|
|
5
|
+
* @description Style
|
|
6
|
+
*/
|
|
7
|
+
export declare const citationStyles: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
8
|
+
export declare const citationQuoteStyles: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// src/citation-popover/style.ts
|
|
2
|
+
import { cva } from "class-variance-authority";
|
|
3
|
+
var citationStyles = cva("w-80 max-w-[calc(100vw-32px)] wrap-anywhere [&_a]:text-link");
|
|
4
|
+
var citationQuoteStyles = cva("mx-0 border-s-2 border-border ps-gridui-16 [&_mark]:bg-accent-background [&_mark]:text-accent-foreground");
|
|
5
|
+
|
|
6
|
+
// src/citation-popover/citation-popover.tsx
|
|
7
|
+
import { Popover, PopoverPanel, PopoverTrigger } from "@gridui/popover";
|
|
8
|
+
import { useId } from "react";
|
|
9
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
var CitationPopover = (props) => {
|
|
11
|
+
const { source, marker, label, openLabel, quote, unmatchedLabel } = props;
|
|
12
|
+
const id = useId();
|
|
13
|
+
const excerpt = source.excerpt ?? "";
|
|
14
|
+
const index = quote ? excerpt.indexOf(quote) : -1;
|
|
15
|
+
return /* @__PURE__ */ jsxs(Popover, { children: [
|
|
16
|
+
/* @__PURE__ */ jsx(
|
|
17
|
+
PopoverTrigger,
|
|
18
|
+
{
|
|
19
|
+
"aria-label": label,
|
|
20
|
+
children: marker
|
|
21
|
+
}
|
|
22
|
+
),
|
|
23
|
+
/* @__PURE__ */ jsxs(
|
|
24
|
+
PopoverPanel,
|
|
25
|
+
{
|
|
26
|
+
"aria-labelledby": id,
|
|
27
|
+
className: citationStyles(),
|
|
28
|
+
children: [
|
|
29
|
+
/* @__PURE__ */ jsx(
|
|
30
|
+
"strong",
|
|
31
|
+
{
|
|
32
|
+
id,
|
|
33
|
+
children: source.title
|
|
34
|
+
}
|
|
35
|
+
),
|
|
36
|
+
source.description && /* @__PURE__ */ jsx("p", { children: source.description }),
|
|
37
|
+
excerpt && /* @__PURE__ */ jsx(
|
|
38
|
+
"blockquote",
|
|
39
|
+
{
|
|
40
|
+
className: citationQuoteStyles(),
|
|
41
|
+
children: quote && index >= 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
42
|
+
excerpt.slice(0, index),
|
|
43
|
+
/* @__PURE__ */ jsx("mark", { children: quote }),
|
|
44
|
+
excerpt.slice(index + quote.length)
|
|
45
|
+
] }) : excerpt
|
|
46
|
+
}
|
|
47
|
+
),
|
|
48
|
+
quote && index < 0 && /* @__PURE__ */ jsx(
|
|
49
|
+
"p",
|
|
50
|
+
{
|
|
51
|
+
role: "status",
|
|
52
|
+
children: unmatchedLabel
|
|
53
|
+
}
|
|
54
|
+
),
|
|
55
|
+
/* @__PURE__ */ jsx(
|
|
56
|
+
"a",
|
|
57
|
+
{
|
|
58
|
+
href: source.href,
|
|
59
|
+
children: openLabel
|
|
60
|
+
}
|
|
61
|
+
)
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
)
|
|
65
|
+
] });
|
|
66
|
+
};
|
|
67
|
+
export {
|
|
68
|
+
CitationPopover
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/citation-popover/style.ts", "../src/citation-popover/citation-popover.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * @author WMXPY\n * @package Citation Popover\n * @namespace CitationPopover\n * @description Style\n */\n\nimport { cva } from \"class-variance-authority\";\n\nexport const citationStyles = cva(\"w-80 max-w-[calc(100vw-32px)] wrap-anywhere [&_a]:text-link\");\n\nexport const citationQuoteStyles = cva(\"mx-0 border-s-2 border-border ps-gridui-16 [&_mark]:bg-accent-background [&_mark]:text-accent-foreground\");\n", "/**\n * @author WMXPY\n * @package Citation Popover\n * @namespace CitationPopover\n * @description Citation Popover\n */\n\nimport { citationQuoteStyles, citationStyles } from \"./style\";\nimport { Popover, PopoverPanel, PopoverTrigger } from \"@gridui/popover\";\nimport type { SourceItem } from \"@gridui/source-list\";\nimport { type FC, type ReactNode, useId } from \"react\";\n\nexport type CitationPopoverProps = {\n readonly source: SourceItem;\n readonly marker: ReactNode;\n readonly label: string;\n readonly openLabel: string;\n readonly quote?: string;\n readonly unmatchedLabel: string;\n};\n\nexport const CitationPopover: FC<CitationPopoverProps> = (props: CitationPopoverProps) => {\n const { source, marker, label, openLabel, quote, unmatchedLabel } = props;\n const id = useId();\n const excerpt = source.excerpt ?? \"\";\n const index = quote ? excerpt.indexOf(quote) : -1;\n return (<Popover>\n <PopoverTrigger\n aria-label={label}\n >\n {marker}\n </PopoverTrigger>\n <PopoverPanel\n aria-labelledby={id}\n className={citationStyles()}\n >\n <strong\n id={id}\n >\n {source.title}\n </strong>\n {source.description && (<p>\n {source.description}\n </p>)}\n {excerpt && (<blockquote\n className={citationQuoteStyles()}\n >\n {quote && index >= 0 ? (<>\n {excerpt.slice(0, index)}\n <mark>\n {quote}\n </mark>\n {excerpt.slice(index + quote.length)}\n </>) : excerpt}\n </blockquote>)}\n {quote && index < 0 && (<p\n role=\"status\"\n >\n {unmatchedLabel}\n </p>)}\n <a\n href={source.href}\n >\n {openLabel}\n </a>\n </PopoverPanel>\n </Popover>);\n};\n"],
|
|
5
|
+
"mappings": ";AAOA,SAAS,WAAW;AAEb,IAAM,iBAAiB,IAAI,6DAA6D;AAExF,IAAM,sBAAsB,IAAI,0GAA0G;;;ACHjJ,SAAS,SAAS,cAAc,sBAAsB;AAEtD,SAAkC,aAAa;AAiBvC,SAoBgC,UApBhC,KAoBgC,YApBhC;AAND,IAAM,kBAA4C,CAAC,UAAgC;AACtF,QAAM,EAAE,QAAQ,QAAQ,OAAO,WAAW,OAAO,eAAe,IAAI;AACpE,QAAM,KAAK,MAAM;AACjB,QAAM,UAAU,OAAO,WAAW;AAClC,QAAM,QAAQ,QAAQ,QAAQ,QAAQ,KAAK,IAAI;AAC/C,SAAQ,qBAAC,WACL;AAAA;AAAA,MAAC;AAAA;AAAA,QACG,cAAY;AAAA,QAEX;AAAA;AAAA,IACL;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACG,mBAAiB;AAAA,QACjB,WAAW,eAAe;AAAA,QAE1B;AAAA;AAAA,YAAC;AAAA;AAAA,cACG;AAAA,cAEC,iBAAO;AAAA;AAAA,UACZ;AAAA,UACC,OAAO,eAAgB,oBAAC,OACpB,iBAAO,aACZ;AAAA,UACC,WAAY;AAAA,YAAC;AAAA;AAAA,cACV,WAAW,oBAAoB;AAAA,cAE9B,mBAAS,SAAS,IAAK,iCACnB;AAAA,wBAAQ,MAAM,GAAG,KAAK;AAAA,gBACvB,oBAAC,UACI,iBACL;AAAA,gBACC,QAAQ,MAAM,QAAQ,MAAM,MAAM;AAAA,iBACvC,IAAO;AAAA;AAAA,UACX;AAAA,UACC,SAAS,QAAQ,KAAM;AAAA,YAAC;AAAA;AAAA,cACrB,MAAK;AAAA,cAEJ;AAAA;AAAA,UACL;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACG,MAAM,OAAO;AAAA,cAEZ;AAAA;AAAA,UACL;AAAA;AAAA;AAAA,IACJ;AAAA,KACJ;AACJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/styles.css
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */
|
|
2
|
+
@layer properties;
|
|
3
|
+
@layer theme, base, components, utilities;
|
|
4
|
+
@layer theme {
|
|
5
|
+
:root, :host {
|
|
6
|
+
--spacing: 0.25rem;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
@layer utilities {
|
|
10
|
+
.mx-0 {
|
|
11
|
+
margin-inline: 0px;
|
|
12
|
+
}
|
|
13
|
+
.w-80 {
|
|
14
|
+
width: calc(var(--spacing) * 80);
|
|
15
|
+
}
|
|
16
|
+
.max-w-\[calc\(100vw-32px\)\] {
|
|
17
|
+
max-width: calc(100vw - 32px);
|
|
18
|
+
}
|
|
19
|
+
.border-s-2 {
|
|
20
|
+
border-inline-start-style: var(--tw-border-style);
|
|
21
|
+
border-inline-start-width: 2px;
|
|
22
|
+
}
|
|
23
|
+
.border-border {
|
|
24
|
+
border-color: var(--gridui-border);
|
|
25
|
+
}
|
|
26
|
+
.ps-gridui-16 {
|
|
27
|
+
padding-inline-start: var(--gridui-space-16);
|
|
28
|
+
}
|
|
29
|
+
.wrap-anywhere {
|
|
30
|
+
overflow-wrap: anywhere;
|
|
31
|
+
}
|
|
32
|
+
.\[\&_a\]\:text-link a {
|
|
33
|
+
color: var(--gridui-link);
|
|
34
|
+
}
|
|
35
|
+
.\[\&_mark\]\:bg-accent-background mark {
|
|
36
|
+
background-color: var(--gridui-accent-background);
|
|
37
|
+
}
|
|
38
|
+
.\[\&_mark\]\:text-accent-foreground mark {
|
|
39
|
+
color: var(--gridui-accent-foreground);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
@property --tw-border-style {
|
|
43
|
+
syntax: "*";
|
|
44
|
+
inherits: false;
|
|
45
|
+
initial-value: solid;
|
|
46
|
+
}
|
|
47
|
+
@layer properties {
|
|
48
|
+
@supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))) {
|
|
49
|
+
*, ::before, ::after, ::backdrop {
|
|
50
|
+
--tw-border-style: solid;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gridui/citation-popover",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "GridUI React citation popover",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"README.md"
|
|
10
|
+
],
|
|
11
|
+
"sideEffects": [
|
|
12
|
+
"**/*.css"
|
|
13
|
+
],
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"import": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./styles.css": "./dist/styles.css"
|
|
20
|
+
},
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"react": "^19.2.0",
|
|
26
|
+
"react-dom": "^19.2.0"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@gridui/popover": "^1.0.0",
|
|
30
|
+
"@gridui/source-list": "^1.0.0",
|
|
31
|
+
"@gridui/theme": "^2.1.2",
|
|
32
|
+
"class-variance-authority": "0.7.1"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@gridui-internal/configuration": "0.0.0",
|
|
36
|
+
"@jest/globals": "30.5.2",
|
|
37
|
+
"@types/jest": "30.0.0",
|
|
38
|
+
"@types/node": "26.6.5",
|
|
39
|
+
"@types/react": "19.3.0",
|
|
40
|
+
"@types/react-dom": "19.3.0",
|
|
41
|
+
"jest": "30.5.2",
|
|
42
|
+
"react": "19.3.1",
|
|
43
|
+
"react-dom": "19.3.1",
|
|
44
|
+
"typescript": "6.0.3"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "node ../../scripts/compilation/package.ts",
|
|
48
|
+
"compile": "tsc --project tsconfig.json",
|
|
49
|
+
"test": "jest --passWithNoTests",
|
|
50
|
+
"coverage": "jest --coverage --passWithNoTests"
|
|
51
|
+
}
|
|
6
52
|
}
|