@nexpress/plugin-block-callout 0.1.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Nexpress
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.
@@ -0,0 +1,5 @@
1
+ import * as _nexpress_plugin_sdk from '@nexpress/plugin-sdk';
2
+
3
+ declare const calloutPlugin: _nexpress_plugin_sdk.NpResolvedPlugin<Record<string, unknown>>;
4
+
5
+ export { calloutPlugin, calloutPlugin as default };
package/dist/index.js ADDED
@@ -0,0 +1,147 @@
1
+ // src/index.tsx
2
+ import { definePlugin } from "@nexpress/plugin-sdk";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ var TONE_PALETTES = {
5
+ info: { bg: "#eff6ff", border: "#3b82f6", icon: "\u2139\uFE0F", title: "#1e40af" },
6
+ success: { bg: "#ecfdf5", border: "#10b981", icon: "\u2713", title: "#065f46" },
7
+ warn: { bg: "#fffbeb", border: "#f59e0b", icon: "\u26A0", title: "#92400e" },
8
+ danger: { bg: "#fef2f2", border: "#ef4444", icon: "\u2715", title: "#991b1b" }
9
+ };
10
+ function readString(value, fallback) {
11
+ return typeof value === "string" && value.length > 0 ? value : fallback;
12
+ }
13
+ function readTone(value) {
14
+ return value === "success" || value === "warn" || value === "danger" ? value : "info";
15
+ }
16
+ function readBool(value, fallback) {
17
+ return typeof value === "boolean" ? value : fallback;
18
+ }
19
+ function readColor(value) {
20
+ if (typeof value !== "string") return null;
21
+ const trimmed = value.trim();
22
+ if (trimmed.length === 0) return null;
23
+ return trimmed;
24
+ }
25
+ var calloutBlock = {
26
+ type: "callout",
27
+ label: "Callout",
28
+ description: "Info / warn / danger notice card with a title and body.",
29
+ icon: "\u{1F4A1}",
30
+ defaultProps: {
31
+ tone: "info",
32
+ title: "Heads up",
33
+ body: "Use this block to flag something the reader shouldn't miss.",
34
+ showIcon: true
35
+ },
36
+ propsSchema: [
37
+ {
38
+ name: "tone",
39
+ label: "Tone",
40
+ type: "select",
41
+ defaultValue: "info",
42
+ options: [
43
+ { label: "Info (blue)", value: "info" },
44
+ { label: "Success (green)", value: "success" },
45
+ { label: "Warn (amber)", value: "warn" },
46
+ { label: "Danger (red)", value: "danger" }
47
+ ]
48
+ },
49
+ { name: "title", label: "Title", type: "text", defaultValue: "Heads up" },
50
+ {
51
+ name: "body",
52
+ label: "Body",
53
+ type: "textarea",
54
+ defaultValue: "Use this block to flag something the reader shouldn't miss."
55
+ },
56
+ {
57
+ name: "showIcon",
58
+ label: "Show icon",
59
+ type: "boolean",
60
+ defaultValue: true
61
+ },
62
+ {
63
+ name: "accentColor",
64
+ label: "Accent color (override)",
65
+ type: "color",
66
+ description: "Optional. Overrides the tone's default border + icon color."
67
+ }
68
+ ],
69
+ render: (props) => {
70
+ const tone = readTone(props.tone);
71
+ const palette = TONE_PALETTES[tone];
72
+ const title = readString(props.title, "Heads up");
73
+ const body = readString(props.body, "");
74
+ const showIcon = readBool(props.showIcon, true);
75
+ const accent = readColor(props.accentColor) ?? palette.border;
76
+ const wrapperStyle = {
77
+ display: "flex",
78
+ gap: "0.875rem",
79
+ padding: "1.125rem 1.25rem",
80
+ borderLeft: `4px solid ${accent}`,
81
+ borderRadius: "0.5rem",
82
+ backgroundColor: palette.bg,
83
+ margin: "1.25rem 0"
84
+ };
85
+ const iconStyle = {
86
+ flexShrink: 0,
87
+ width: "1.5rem",
88
+ height: "1.5rem",
89
+ display: "inline-flex",
90
+ alignItems: "center",
91
+ justifyContent: "center",
92
+ fontSize: "1rem",
93
+ color: accent,
94
+ fontWeight: 700
95
+ };
96
+ return /* @__PURE__ */ jsxs("aside", { className: `np-block-callout np-block-callout--${tone}`, style: wrapperStyle, children: [
97
+ showIcon ? /* @__PURE__ */ jsx("span", { "aria-hidden": "true", style: iconStyle, children: palette.icon }) : null,
98
+ /* @__PURE__ */ jsxs("div", { style: { minWidth: 0 }, children: [
99
+ title.length > 0 ? /* @__PURE__ */ jsx(
100
+ "p",
101
+ {
102
+ style: {
103
+ margin: 0,
104
+ fontWeight: 600,
105
+ color: palette.title,
106
+ lineHeight: 1.3
107
+ },
108
+ children: title
109
+ }
110
+ ) : null,
111
+ body.length > 0 ? /* @__PURE__ */ jsx(
112
+ "p",
113
+ {
114
+ style: {
115
+ margin: title.length > 0 ? "0.25rem 0 0" : 0,
116
+ color: "#1f2937",
117
+ lineHeight: 1.55,
118
+ whiteSpace: "pre-wrap"
119
+ },
120
+ children: body
121
+ }
122
+ ) : null
123
+ ] })
124
+ ] });
125
+ }
126
+ };
127
+ var calloutPlugin = definePlugin({
128
+ manifest: {
129
+ id: "block-callout",
130
+ version: "0.1.0",
131
+ name: "Callout block",
132
+ description: "Adds an info / warn / danger callout card to the page-builder block library.",
133
+ author: { name: "NexPress" },
134
+ license: "MIT",
135
+ nexpress: { minVersion: "0.1.0" }
136
+ // capabilities, allowedHosts, provides, agent, usesTokens, styleSlots
137
+ // all default sensibly — `definePlugin` derives `provides.blocks` from
138
+ // the `blocks: [...]` array below, so we don't repeat ourselves.
139
+ },
140
+ blocks: [calloutBlock]
141
+ });
142
+ var index_default = calloutPlugin;
143
+ export {
144
+ calloutPlugin,
145
+ index_default as default
146
+ };
147
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.tsx"],"sourcesContent":["import type { CSSProperties } from \"react\";\n\nimport type { NpBlockDefinition } from \"@nexpress/blocks\";\nimport { definePlugin } from \"@nexpress/plugin-sdk\";\n\nconst TONE_PALETTES = {\n info: { bg: \"#eff6ff\", border: \"#3b82f6\", icon: \"ℹ️\", title: \"#1e40af\" },\n success: { bg: \"#ecfdf5\", border: \"#10b981\", icon: \"✓\", title: \"#065f46\" },\n warn: { bg: \"#fffbeb\", border: \"#f59e0b\", icon: \"⚠\", title: \"#92400e\" },\n danger: { bg: \"#fef2f2\", border: \"#ef4444\", icon: \"✕\", title: \"#991b1b\" },\n} as const;\n\ntype Tone = keyof typeof TONE_PALETTES;\n\nfunction readString(value: unknown, fallback: string): string {\n return typeof value === \"string\" && value.length > 0 ? value : fallback;\n}\n\nfunction readTone(value: unknown): Tone {\n return value === \"success\" || value === \"warn\" || value === \"danger\" ? value : \"info\";\n}\n\nfunction readBool(value: unknown, fallback: boolean): boolean {\n return typeof value === \"boolean\" ? value : fallback;\n}\n\nfunction readColor(value: unknown): string | null {\n if (typeof value !== \"string\") return null;\n const trimmed = value.trim();\n if (trimmed.length === 0) return null;\n return trimmed;\n}\n\nconst calloutBlock: NpBlockDefinition = {\n type: \"callout\",\n label: \"Callout\",\n description: \"Info / warn / danger notice card with a title and body.\",\n icon: \"💡\",\n defaultProps: {\n tone: \"info\",\n title: \"Heads up\",\n body: \"Use this block to flag something the reader shouldn't miss.\",\n showIcon: true,\n },\n propsSchema: [\n {\n name: \"tone\",\n label: \"Tone\",\n type: \"select\",\n defaultValue: \"info\",\n options: [\n { label: \"Info (blue)\", value: \"info\" },\n { label: \"Success (green)\", value: \"success\" },\n { label: \"Warn (amber)\", value: \"warn\" },\n { label: \"Danger (red)\", value: \"danger\" },\n ],\n },\n { name: \"title\", label: \"Title\", type: \"text\", defaultValue: \"Heads up\" },\n {\n name: \"body\",\n label: \"Body\",\n type: \"textarea\",\n defaultValue: \"Use this block to flag something the reader shouldn't miss.\",\n },\n {\n name: \"showIcon\",\n label: \"Show icon\",\n type: \"boolean\",\n defaultValue: true,\n },\n {\n name: \"accentColor\",\n label: \"Accent color (override)\",\n type: \"color\",\n description: \"Optional. Overrides the tone's default border + icon color.\",\n },\n ],\n render: (props) => {\n const tone = readTone(props.tone);\n const palette = TONE_PALETTES[tone];\n const title = readString(props.title, \"Heads up\");\n const body = readString(props.body, \"\");\n const showIcon = readBool(props.showIcon, true);\n const accent = readColor(props.accentColor) ?? palette.border;\n\n const wrapperStyle: CSSProperties = {\n display: \"flex\",\n gap: \"0.875rem\",\n padding: \"1.125rem 1.25rem\",\n borderLeft: `4px solid ${accent}`,\n borderRadius: \"0.5rem\",\n backgroundColor: palette.bg,\n margin: \"1.25rem 0\",\n };\n\n const iconStyle: CSSProperties = {\n flexShrink: 0,\n width: \"1.5rem\",\n height: \"1.5rem\",\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n fontSize: \"1rem\",\n color: accent,\n fontWeight: 700,\n };\n\n return (\n <aside className={`np-block-callout np-block-callout--${tone}`} style={wrapperStyle}>\n {showIcon ? (\n <span aria-hidden=\"true\" style={iconStyle}>\n {palette.icon}\n </span>\n ) : null}\n <div style={{ minWidth: 0 }}>\n {title.length > 0 ? (\n <p\n style={{\n margin: 0,\n fontWeight: 600,\n color: palette.title,\n lineHeight: 1.3,\n }}\n >\n {title}\n </p>\n ) : null}\n {body.length > 0 ? (\n <p\n style={{\n margin: title.length > 0 ? \"0.25rem 0 0\" : 0,\n color: \"#1f2937\",\n lineHeight: 1.55,\n whiteSpace: \"pre-wrap\",\n }}\n >\n {body}\n </p>\n ) : null}\n </div>\n </aside>\n );\n },\n};\n\nexport const calloutPlugin = definePlugin({\n manifest: {\n id: \"block-callout\",\n version: \"0.1.0\",\n name: \"Callout block\",\n description: \"Adds an info / warn / danger callout card to the page-builder block library.\",\n author: { name: \"NexPress\" },\n license: \"MIT\",\n nexpress: { minVersion: \"0.1.0\" },\n // capabilities, allowedHosts, provides, agent, usesTokens, styleSlots\n // all default sensibly — `definePlugin` derives `provides.blocks` from\n // the `blocks: [...]` array below, so we don't repeat ourselves.\n },\n blocks: [calloutBlock],\n});\n\nexport default calloutPlugin;\n"],"mappings":";AAGA,SAAS,oBAAoB;AA2GnB,cAIF,YAJE;AAzGV,IAAM,gBAAgB;AAAA,EACpB,MAAM,EAAE,IAAI,WAAW,QAAQ,WAAW,MAAM,gBAAM,OAAO,UAAU;AAAA,EACvE,SAAS,EAAE,IAAI,WAAW,QAAQ,WAAW,MAAM,UAAK,OAAO,UAAU;AAAA,EACzE,MAAM,EAAE,IAAI,WAAW,QAAQ,WAAW,MAAM,UAAK,OAAO,UAAU;AAAA,EACtE,QAAQ,EAAE,IAAI,WAAW,QAAQ,WAAW,MAAM,UAAK,OAAO,UAAU;AAC1E;AAIA,SAAS,WAAW,OAAgB,UAA0B;AAC5D,SAAO,OAAO,UAAU,YAAY,MAAM,SAAS,IAAI,QAAQ;AACjE;AAEA,SAAS,SAAS,OAAsB;AACtC,SAAO,UAAU,aAAa,UAAU,UAAU,UAAU,WAAW,QAAQ;AACjF;AAEA,SAAS,SAAS,OAAgB,UAA4B;AAC5D,SAAO,OAAO,UAAU,YAAY,QAAQ;AAC9C;AAEA,SAAS,UAAU,OAA+B;AAChD,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,QAAM,UAAU,MAAM,KAAK;AAC3B,MAAI,QAAQ,WAAW,EAAG,QAAO;AACjC,SAAO;AACT;AAEA,IAAM,eAAkC;AAAA,EACtC,MAAM;AAAA,EACN,OAAO;AA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A,IACV;AAEA,UAAM,YAA2B;AAAA,MAC/B,YAAY;AAAA,MACZ,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,YAAY;AAAA,MACZ,gBAAgB;AAAA,MAChB,UAAU;AAAA,MACV,OAAO;AAAA,MACP,YAAY;AAAA,IACd;AAEA,WACE,qBAAC,WAAM,WAAW,sCAAsC,IAAI,IAAI,OAAO,cACpE;AAAA,iBACC,oBAAC,UAAK,eAAY,QAAO,OAAO,WAC7B,kBAAQ,MACX,IACE;AAAA,MACJ,qBAAC,SAAI,OAAO,EAAE,UAAU,EAAE,GACvB;AAAA,cAAM,SAAS,IACd;AAAA,UAAC;AAAA;AAAA,YACC,OAAO;AAAA,cACL,QAAQ;AAAA,cACR,YAAY;AAAA,cACZ,OAAO,QAAQ;AAAA,cACf,YAAY;AAAA,YACd;AAAA,YAEC;AAAA;AAAA,QACH,IACE;AAAA,QACH,KAAK,SAAS,IACb;AAAA,UAAC;AAAA;AAAA,YACC,OAAO;AAAA,cACL,QAAQ,MAAM,SAAS,IAAI,gBAAgB;AAAA,cAC3C,OAAO;AAAA,cACP,YAAY;AAAA,cACZ,YAAY;AAAA,YACd;AAAA,YAEC;AAAA;AAAA,QACH,IACE;AAAA,SACN;AAAA,OACF;AAAA,EAEJ;AACF;AAEO,IAAM,gBAAgB,aAAa;AAAA,EACxC,UAAU;AAAA,IACR,IAAI;AAAA,IACJ,SAAS;AAAA,IACT,MAAM;AAAA,IACN,aAAa;AAAA,IACb,QAAQ,EAAE,MAAM,WAAW;AAAA,IAC3B,SAAS;AAAA,IACT,UAAU,EAAE,YAAY,QAAQ;AAAA;AAAA;AAAA;AAAA,EAIlC;AAAA,EACA,QAAQ,CAAC,YAAY;AACvB,CAAC;AAED,IAAO,gBAAQ;","names":[]}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@nexpress/plugin-block-callout",
3
+ "version": "0.1.0",
4
+ "description": "Callout block — info/warn/danger notice card. Sample plugin showcasing block contribution.",
5
+ "license": "MIT",
6
+ "author": "Nexpress",
7
+ "type": "module",
8
+ "main": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js",
14
+ "default": "./dist/index.js"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "engines": {
21
+ "node": ">=20"
22
+ },
23
+ "peerDependencies": {
24
+ "react": "^19.0.0"
25
+ },
26
+ "dependencies": {
27
+ "@nexpress/plugin-sdk": "0.1.0",
28
+ "@nexpress/blocks": "0.1.0"
29
+ },
30
+ "devDependencies": {
31
+ "@types/node": "^22.0.0",
32
+ "@types/react": "^19.0.0",
33
+ "tsup": "^8.5.0",
34
+ "typescript": "^5.8.0"
35
+ },
36
+ "scripts": {
37
+ "build": "tsup",
38
+ "dev": "tsup --watch --no-clean",
39
+ "clean": "rm -rf dist",
40
+ "typecheck": "tsc --noEmit",
41
+ "lint": "eslint . --cache --cache-location node_modules/.cache/eslint"
42
+ }
43
+ }