@kopexa/grc 0.0.13 → 0.0.15
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/chunk-C5OUE3C2.mjs +1 -0
- package/dist/chunk-EGK6RMOC.mjs +102 -0
- package/dist/chunk-JHGWV2ID.mjs +30 -0
- package/dist/common/editor/editor-card.d.mts +22 -0
- package/dist/common/editor/editor-card.d.ts +22 -0
- package/dist/common/editor/editor-card.js +150 -0
- package/dist/common/editor/editor-card.mjs +9 -0
- package/dist/common/editor/index.d.mts +3 -0
- package/dist/common/editor/index.d.ts +3 -0
- package/dist/common/editor/index.js +151 -0
- package/dist/common/editor/index.mjs +9 -0
- package/dist/common/editor/messages.d.mts +24 -0
- package/dist/common/editor/messages.d.ts +24 -0
- package/dist/common/editor/messages.js +53 -0
- package/dist/common/editor/messages.mjs +7 -0
- package/dist/common/index.d.mts +2 -0
- package/dist/common/index.d.ts +2 -0
- package/dist/common/index.js +225 -102
- package/dist/common/index.mjs +7 -1
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +300 -177
- package/dist/index.mjs +7 -1
- package/package.json +8 -7
- package/src/common/editor/editor-card.tsx +129 -0
- package/src/common/editor/index.ts +1 -0
- package/src/common/editor/messages.ts +24 -0
- package/src/common/index.ts +1 -0
- /package/dist/{chunk-HJUSN7FD.mjs → chunk-5JULTRFD.mjs} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
messages
|
|
4
|
+
} from "./chunk-JHGWV2ID.mjs";
|
|
5
|
+
|
|
6
|
+
// src/common/editor/editor-card.tsx
|
|
7
|
+
import { useSafeIntl } from "@kopexa/i18n";
|
|
8
|
+
import { EditIcon } from "@kopexa/icons";
|
|
9
|
+
import { Button, Card, Heading } from "@kopexa/sight";
|
|
10
|
+
import { Editor } from "@kopexa/tiptap";
|
|
11
|
+
import { useState } from "react";
|
|
12
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
function EditorCard({
|
|
14
|
+
value,
|
|
15
|
+
onChange,
|
|
16
|
+
title,
|
|
17
|
+
placeholder,
|
|
18
|
+
emptyText,
|
|
19
|
+
readOnly = false,
|
|
20
|
+
cardVariant = "accent"
|
|
21
|
+
}) {
|
|
22
|
+
const intl = useSafeIntl();
|
|
23
|
+
const [isEditing, setIsEditing] = useState(false);
|
|
24
|
+
const [draftContent, setDraftContent] = useState(
|
|
25
|
+
value
|
|
26
|
+
);
|
|
27
|
+
const t = {
|
|
28
|
+
edit: intl.formatMessage(messages.edit),
|
|
29
|
+
cancel: intl.formatMessage(messages.cancel),
|
|
30
|
+
save: intl.formatMessage(messages.save),
|
|
31
|
+
placeholder: placeholder != null ? placeholder : intl.formatMessage(messages.placeholder),
|
|
32
|
+
empty: emptyText != null ? emptyText : intl.formatMessage(messages.empty)
|
|
33
|
+
};
|
|
34
|
+
const handleStartEdit = () => {
|
|
35
|
+
setDraftContent(value);
|
|
36
|
+
setIsEditing(true);
|
|
37
|
+
};
|
|
38
|
+
const handleSave = () => {
|
|
39
|
+
onChange == null ? void 0 : onChange(draftContent);
|
|
40
|
+
setIsEditing(false);
|
|
41
|
+
};
|
|
42
|
+
const handleCancel = () => {
|
|
43
|
+
setDraftContent(value);
|
|
44
|
+
setIsEditing(false);
|
|
45
|
+
};
|
|
46
|
+
return /* @__PURE__ */ jsxs(
|
|
47
|
+
Card.Root,
|
|
48
|
+
{
|
|
49
|
+
variant: cardVariant,
|
|
50
|
+
className: isEditing ? "ring-2 ring-primary overflow-visible" : void 0,
|
|
51
|
+
children: [
|
|
52
|
+
/* @__PURE__ */ jsxs(Card.Header, { className: "flex flex-row items-center justify-between", children: [
|
|
53
|
+
/* @__PURE__ */ jsx(Heading, { level: "h3", className: "text-base", children: title }),
|
|
54
|
+
!readOnly && (isEditing ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
55
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "sm", onClick: handleCancel, children: t.cancel }),
|
|
56
|
+
/* @__PURE__ */ jsx(
|
|
57
|
+
Button,
|
|
58
|
+
{
|
|
59
|
+
variant: "solid",
|
|
60
|
+
color: "primary",
|
|
61
|
+
size: "sm",
|
|
62
|
+
onClick: handleSave,
|
|
63
|
+
children: t.save
|
|
64
|
+
}
|
|
65
|
+
)
|
|
66
|
+
] }) : /* @__PURE__ */ jsx(
|
|
67
|
+
Button,
|
|
68
|
+
{
|
|
69
|
+
variant: "ghost",
|
|
70
|
+
size: "sm",
|
|
71
|
+
isIconOnly: true,
|
|
72
|
+
onClick: handleStartEdit,
|
|
73
|
+
"aria-label": t.edit,
|
|
74
|
+
children: /* @__PURE__ */ jsx(EditIcon, { className: "size-4" })
|
|
75
|
+
}
|
|
76
|
+
))
|
|
77
|
+
] }),
|
|
78
|
+
/* @__PURE__ */ jsx(Card.Body, { className: "p-0", children: isEditing ? /* @__PURE__ */ jsx(
|
|
79
|
+
Editor,
|
|
80
|
+
{
|
|
81
|
+
variant: "field",
|
|
82
|
+
placeholder: t.placeholder,
|
|
83
|
+
content: draftContent,
|
|
84
|
+
onChange: setDraftContent
|
|
85
|
+
}
|
|
86
|
+
) : value ? /* @__PURE__ */ jsx(
|
|
87
|
+
Editor,
|
|
88
|
+
{
|
|
89
|
+
variant: "default",
|
|
90
|
+
bordered: false,
|
|
91
|
+
content: value,
|
|
92
|
+
editable: false
|
|
93
|
+
}
|
|
94
|
+
) : /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground leading-relaxed px-4 py-4", children: t.empty }) })
|
|
95
|
+
]
|
|
96
|
+
}
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export {
|
|
101
|
+
EditorCard
|
|
102
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/common/editor/messages.ts
|
|
4
|
+
import { defineMessages } from "react-intl";
|
|
5
|
+
var messages = defineMessages({
|
|
6
|
+
edit: {
|
|
7
|
+
id: "grc.editor_card.edit",
|
|
8
|
+
defaultMessage: "Edit"
|
|
9
|
+
},
|
|
10
|
+
cancel: {
|
|
11
|
+
id: "grc.editor_card.cancel",
|
|
12
|
+
defaultMessage: "Cancel"
|
|
13
|
+
},
|
|
14
|
+
save: {
|
|
15
|
+
id: "grc.editor_card.save",
|
|
16
|
+
defaultMessage: "Save"
|
|
17
|
+
},
|
|
18
|
+
placeholder: {
|
|
19
|
+
id: "grc.editor_card.placeholder",
|
|
20
|
+
defaultMessage: "Start typing or press '/' for commands..."
|
|
21
|
+
},
|
|
22
|
+
empty: {
|
|
23
|
+
id: "grc.editor_card.empty",
|
|
24
|
+
defaultMessage: "No content yet. Click edit to add content."
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export {
|
|
29
|
+
messages
|
|
30
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { JSONContent } from '@kopexa/tiptap';
|
|
3
|
+
|
|
4
|
+
interface EditorCardProps {
|
|
5
|
+
/** The content as TipTap JSONContent */
|
|
6
|
+
value?: JSONContent;
|
|
7
|
+
/** Callback when the content changes */
|
|
8
|
+
onChange?: (content: JSONContent | undefined) => void;
|
|
9
|
+
/** Title for the card header */
|
|
10
|
+
title: string;
|
|
11
|
+
/** Placeholder text for the editor */
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
/** Text to show when there's no content in view mode */
|
|
14
|
+
emptyText?: string;
|
|
15
|
+
/** Make the component read-only */
|
|
16
|
+
readOnly?: boolean;
|
|
17
|
+
/** Card variant */
|
|
18
|
+
cardVariant?: "default" | "accent";
|
|
19
|
+
}
|
|
20
|
+
declare function EditorCard({ value, onChange, title, placeholder, emptyText, readOnly, cardVariant, }: EditorCardProps): react_jsx_runtime.JSX.Element;
|
|
21
|
+
|
|
22
|
+
export { EditorCard, type EditorCardProps };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { JSONContent } from '@kopexa/tiptap';
|
|
3
|
+
|
|
4
|
+
interface EditorCardProps {
|
|
5
|
+
/** The content as TipTap JSONContent */
|
|
6
|
+
value?: JSONContent;
|
|
7
|
+
/** Callback when the content changes */
|
|
8
|
+
onChange?: (content: JSONContent | undefined) => void;
|
|
9
|
+
/** Title for the card header */
|
|
10
|
+
title: string;
|
|
11
|
+
/** Placeholder text for the editor */
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
/** Text to show when there's no content in view mode */
|
|
14
|
+
emptyText?: string;
|
|
15
|
+
/** Make the component read-only */
|
|
16
|
+
readOnly?: boolean;
|
|
17
|
+
/** Card variant */
|
|
18
|
+
cardVariant?: "default" | "accent";
|
|
19
|
+
}
|
|
20
|
+
declare function EditorCard({ value, onChange, title, placeholder, emptyText, readOnly, cardVariant, }: EditorCardProps): react_jsx_runtime.JSX.Element;
|
|
21
|
+
|
|
22
|
+
export { EditorCard, type EditorCardProps };
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
"use client";
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/common/editor/editor-card.tsx
|
|
23
|
+
var editor_card_exports = {};
|
|
24
|
+
__export(editor_card_exports, {
|
|
25
|
+
EditorCard: () => EditorCard
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(editor_card_exports);
|
|
28
|
+
var import_i18n = require("@kopexa/i18n");
|
|
29
|
+
var import_icons = require("@kopexa/icons");
|
|
30
|
+
var import_sight = require("@kopexa/sight");
|
|
31
|
+
var import_tiptap = require("@kopexa/tiptap");
|
|
32
|
+
var import_react = require("react");
|
|
33
|
+
|
|
34
|
+
// src/common/editor/messages.ts
|
|
35
|
+
var import_react_intl = require("react-intl");
|
|
36
|
+
var messages = (0, import_react_intl.defineMessages)({
|
|
37
|
+
edit: {
|
|
38
|
+
id: "grc.editor_card.edit",
|
|
39
|
+
defaultMessage: "Edit"
|
|
40
|
+
},
|
|
41
|
+
cancel: {
|
|
42
|
+
id: "grc.editor_card.cancel",
|
|
43
|
+
defaultMessage: "Cancel"
|
|
44
|
+
},
|
|
45
|
+
save: {
|
|
46
|
+
id: "grc.editor_card.save",
|
|
47
|
+
defaultMessage: "Save"
|
|
48
|
+
},
|
|
49
|
+
placeholder: {
|
|
50
|
+
id: "grc.editor_card.placeholder",
|
|
51
|
+
defaultMessage: "Start typing or press '/' for commands..."
|
|
52
|
+
},
|
|
53
|
+
empty: {
|
|
54
|
+
id: "grc.editor_card.empty",
|
|
55
|
+
defaultMessage: "No content yet. Click edit to add content."
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// src/common/editor/editor-card.tsx
|
|
60
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
61
|
+
function EditorCard({
|
|
62
|
+
value,
|
|
63
|
+
onChange,
|
|
64
|
+
title,
|
|
65
|
+
placeholder,
|
|
66
|
+
emptyText,
|
|
67
|
+
readOnly = false,
|
|
68
|
+
cardVariant = "accent"
|
|
69
|
+
}) {
|
|
70
|
+
const intl = (0, import_i18n.useSafeIntl)();
|
|
71
|
+
const [isEditing, setIsEditing] = (0, import_react.useState)(false);
|
|
72
|
+
const [draftContent, setDraftContent] = (0, import_react.useState)(
|
|
73
|
+
value
|
|
74
|
+
);
|
|
75
|
+
const t = {
|
|
76
|
+
edit: intl.formatMessage(messages.edit),
|
|
77
|
+
cancel: intl.formatMessage(messages.cancel),
|
|
78
|
+
save: intl.formatMessage(messages.save),
|
|
79
|
+
placeholder: placeholder != null ? placeholder : intl.formatMessage(messages.placeholder),
|
|
80
|
+
empty: emptyText != null ? emptyText : intl.formatMessage(messages.empty)
|
|
81
|
+
};
|
|
82
|
+
const handleStartEdit = () => {
|
|
83
|
+
setDraftContent(value);
|
|
84
|
+
setIsEditing(true);
|
|
85
|
+
};
|
|
86
|
+
const handleSave = () => {
|
|
87
|
+
onChange == null ? void 0 : onChange(draftContent);
|
|
88
|
+
setIsEditing(false);
|
|
89
|
+
};
|
|
90
|
+
const handleCancel = () => {
|
|
91
|
+
setDraftContent(value);
|
|
92
|
+
setIsEditing(false);
|
|
93
|
+
};
|
|
94
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
95
|
+
import_sight.Card.Root,
|
|
96
|
+
{
|
|
97
|
+
variant: cardVariant,
|
|
98
|
+
className: isEditing ? "ring-2 ring-primary overflow-visible" : void 0,
|
|
99
|
+
children: [
|
|
100
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_sight.Card.Header, { className: "flex flex-row items-center justify-between", children: [
|
|
101
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_sight.Heading, { level: "h3", className: "text-base", children: title }),
|
|
102
|
+
!readOnly && (isEditing ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
103
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_sight.Button, { variant: "ghost", size: "sm", onClick: handleCancel, children: t.cancel }),
|
|
104
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
105
|
+
import_sight.Button,
|
|
106
|
+
{
|
|
107
|
+
variant: "solid",
|
|
108
|
+
color: "primary",
|
|
109
|
+
size: "sm",
|
|
110
|
+
onClick: handleSave,
|
|
111
|
+
children: t.save
|
|
112
|
+
}
|
|
113
|
+
)
|
|
114
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
115
|
+
import_sight.Button,
|
|
116
|
+
{
|
|
117
|
+
variant: "ghost",
|
|
118
|
+
size: "sm",
|
|
119
|
+
isIconOnly: true,
|
|
120
|
+
onClick: handleStartEdit,
|
|
121
|
+
"aria-label": t.edit,
|
|
122
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.EditIcon, { className: "size-4" })
|
|
123
|
+
}
|
|
124
|
+
))
|
|
125
|
+
] }),
|
|
126
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_sight.Card.Body, { className: "p-0", children: isEditing ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
127
|
+
import_tiptap.Editor,
|
|
128
|
+
{
|
|
129
|
+
variant: "field",
|
|
130
|
+
placeholder: t.placeholder,
|
|
131
|
+
content: draftContent,
|
|
132
|
+
onChange: setDraftContent
|
|
133
|
+
}
|
|
134
|
+
) : value ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
135
|
+
import_tiptap.Editor,
|
|
136
|
+
{
|
|
137
|
+
variant: "default",
|
|
138
|
+
bordered: false,
|
|
139
|
+
content: value,
|
|
140
|
+
editable: false
|
|
141
|
+
}
|
|
142
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-sm text-muted-foreground leading-relaxed px-4 py-4", children: t.empty }) })
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
148
|
+
0 && (module.exports = {
|
|
149
|
+
EditorCard
|
|
150
|
+
});
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/common/editor/index.ts
|
|
22
|
+
var editor_exports = {};
|
|
23
|
+
__export(editor_exports, {
|
|
24
|
+
EditorCard: () => EditorCard
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(editor_exports);
|
|
27
|
+
|
|
28
|
+
// src/common/editor/editor-card.tsx
|
|
29
|
+
var import_i18n = require("@kopexa/i18n");
|
|
30
|
+
var import_icons = require("@kopexa/icons");
|
|
31
|
+
var import_sight = require("@kopexa/sight");
|
|
32
|
+
var import_tiptap = require("@kopexa/tiptap");
|
|
33
|
+
var import_react = require("react");
|
|
34
|
+
|
|
35
|
+
// src/common/editor/messages.ts
|
|
36
|
+
var import_react_intl = require("react-intl");
|
|
37
|
+
var messages = (0, import_react_intl.defineMessages)({
|
|
38
|
+
edit: {
|
|
39
|
+
id: "grc.editor_card.edit",
|
|
40
|
+
defaultMessage: "Edit"
|
|
41
|
+
},
|
|
42
|
+
cancel: {
|
|
43
|
+
id: "grc.editor_card.cancel",
|
|
44
|
+
defaultMessage: "Cancel"
|
|
45
|
+
},
|
|
46
|
+
save: {
|
|
47
|
+
id: "grc.editor_card.save",
|
|
48
|
+
defaultMessage: "Save"
|
|
49
|
+
},
|
|
50
|
+
placeholder: {
|
|
51
|
+
id: "grc.editor_card.placeholder",
|
|
52
|
+
defaultMessage: "Start typing or press '/' for commands..."
|
|
53
|
+
},
|
|
54
|
+
empty: {
|
|
55
|
+
id: "grc.editor_card.empty",
|
|
56
|
+
defaultMessage: "No content yet. Click edit to add content."
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// src/common/editor/editor-card.tsx
|
|
61
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
62
|
+
function EditorCard({
|
|
63
|
+
value,
|
|
64
|
+
onChange,
|
|
65
|
+
title,
|
|
66
|
+
placeholder,
|
|
67
|
+
emptyText,
|
|
68
|
+
readOnly = false,
|
|
69
|
+
cardVariant = "accent"
|
|
70
|
+
}) {
|
|
71
|
+
const intl = (0, import_i18n.useSafeIntl)();
|
|
72
|
+
const [isEditing, setIsEditing] = (0, import_react.useState)(false);
|
|
73
|
+
const [draftContent, setDraftContent] = (0, import_react.useState)(
|
|
74
|
+
value
|
|
75
|
+
);
|
|
76
|
+
const t = {
|
|
77
|
+
edit: intl.formatMessage(messages.edit),
|
|
78
|
+
cancel: intl.formatMessage(messages.cancel),
|
|
79
|
+
save: intl.formatMessage(messages.save),
|
|
80
|
+
placeholder: placeholder != null ? placeholder : intl.formatMessage(messages.placeholder),
|
|
81
|
+
empty: emptyText != null ? emptyText : intl.formatMessage(messages.empty)
|
|
82
|
+
};
|
|
83
|
+
const handleStartEdit = () => {
|
|
84
|
+
setDraftContent(value);
|
|
85
|
+
setIsEditing(true);
|
|
86
|
+
};
|
|
87
|
+
const handleSave = () => {
|
|
88
|
+
onChange == null ? void 0 : onChange(draftContent);
|
|
89
|
+
setIsEditing(false);
|
|
90
|
+
};
|
|
91
|
+
const handleCancel = () => {
|
|
92
|
+
setDraftContent(value);
|
|
93
|
+
setIsEditing(false);
|
|
94
|
+
};
|
|
95
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
96
|
+
import_sight.Card.Root,
|
|
97
|
+
{
|
|
98
|
+
variant: cardVariant,
|
|
99
|
+
className: isEditing ? "ring-2 ring-primary overflow-visible" : void 0,
|
|
100
|
+
children: [
|
|
101
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_sight.Card.Header, { className: "flex flex-row items-center justify-between", children: [
|
|
102
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_sight.Heading, { level: "h3", className: "text-base", children: title }),
|
|
103
|
+
!readOnly && (isEditing ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
104
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_sight.Button, { variant: "ghost", size: "sm", onClick: handleCancel, children: t.cancel }),
|
|
105
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
106
|
+
import_sight.Button,
|
|
107
|
+
{
|
|
108
|
+
variant: "solid",
|
|
109
|
+
color: "primary",
|
|
110
|
+
size: "sm",
|
|
111
|
+
onClick: handleSave,
|
|
112
|
+
children: t.save
|
|
113
|
+
}
|
|
114
|
+
)
|
|
115
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
116
|
+
import_sight.Button,
|
|
117
|
+
{
|
|
118
|
+
variant: "ghost",
|
|
119
|
+
size: "sm",
|
|
120
|
+
isIconOnly: true,
|
|
121
|
+
onClick: handleStartEdit,
|
|
122
|
+
"aria-label": t.edit,
|
|
123
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.EditIcon, { className: "size-4" })
|
|
124
|
+
}
|
|
125
|
+
))
|
|
126
|
+
] }),
|
|
127
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_sight.Card.Body, { className: "p-0", children: isEditing ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
128
|
+
import_tiptap.Editor,
|
|
129
|
+
{
|
|
130
|
+
variant: "field",
|
|
131
|
+
placeholder: t.placeholder,
|
|
132
|
+
content: draftContent,
|
|
133
|
+
onChange: setDraftContent
|
|
134
|
+
}
|
|
135
|
+
) : value ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
136
|
+
import_tiptap.Editor,
|
|
137
|
+
{
|
|
138
|
+
variant: "default",
|
|
139
|
+
bordered: false,
|
|
140
|
+
content: value,
|
|
141
|
+
editable: false
|
|
142
|
+
}
|
|
143
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-sm text-muted-foreground leading-relaxed px-4 py-4", children: t.empty }) })
|
|
144
|
+
]
|
|
145
|
+
}
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
149
|
+
0 && (module.exports = {
|
|
150
|
+
EditorCard
|
|
151
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
declare const messages: {
|
|
2
|
+
edit: {
|
|
3
|
+
id: string;
|
|
4
|
+
defaultMessage: string;
|
|
5
|
+
};
|
|
6
|
+
cancel: {
|
|
7
|
+
id: string;
|
|
8
|
+
defaultMessage: string;
|
|
9
|
+
};
|
|
10
|
+
save: {
|
|
11
|
+
id: string;
|
|
12
|
+
defaultMessage: string;
|
|
13
|
+
};
|
|
14
|
+
placeholder: {
|
|
15
|
+
id: string;
|
|
16
|
+
defaultMessage: string;
|
|
17
|
+
};
|
|
18
|
+
empty: {
|
|
19
|
+
id: string;
|
|
20
|
+
defaultMessage: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export { messages };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
declare const messages: {
|
|
2
|
+
edit: {
|
|
3
|
+
id: string;
|
|
4
|
+
defaultMessage: string;
|
|
5
|
+
};
|
|
6
|
+
cancel: {
|
|
7
|
+
id: string;
|
|
8
|
+
defaultMessage: string;
|
|
9
|
+
};
|
|
10
|
+
save: {
|
|
11
|
+
id: string;
|
|
12
|
+
defaultMessage: string;
|
|
13
|
+
};
|
|
14
|
+
placeholder: {
|
|
15
|
+
id: string;
|
|
16
|
+
defaultMessage: string;
|
|
17
|
+
};
|
|
18
|
+
empty: {
|
|
19
|
+
id: string;
|
|
20
|
+
defaultMessage: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export { messages };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/common/editor/messages.ts
|
|
22
|
+
var messages_exports = {};
|
|
23
|
+
__export(messages_exports, {
|
|
24
|
+
messages: () => messages
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(messages_exports);
|
|
27
|
+
var import_react_intl = require("react-intl");
|
|
28
|
+
var messages = (0, import_react_intl.defineMessages)({
|
|
29
|
+
edit: {
|
|
30
|
+
id: "grc.editor_card.edit",
|
|
31
|
+
defaultMessage: "Edit"
|
|
32
|
+
},
|
|
33
|
+
cancel: {
|
|
34
|
+
id: "grc.editor_card.cancel",
|
|
35
|
+
defaultMessage: "Cancel"
|
|
36
|
+
},
|
|
37
|
+
save: {
|
|
38
|
+
id: "grc.editor_card.save",
|
|
39
|
+
defaultMessage: "Save"
|
|
40
|
+
},
|
|
41
|
+
placeholder: {
|
|
42
|
+
id: "grc.editor_card.placeholder",
|
|
43
|
+
defaultMessage: "Start typing or press '/' for commands..."
|
|
44
|
+
},
|
|
45
|
+
empty: {
|
|
46
|
+
id: "grc.editor_card.empty",
|
|
47
|
+
defaultMessage: "No content yet. Click edit to add content."
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
+
0 && (module.exports = {
|
|
52
|
+
messages
|
|
53
|
+
});
|
package/dist/common/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { ComplianceBadges, ComplianceBadgesProps, DoraBadge, DoraBadgeProps, Nis2Badge, Nis2BadgeProps } from './compliance/compliance-badge.mjs';
|
|
2
2
|
export { ControlChip, ControlChipProps, MappedControls, MappedControlsProps } from './control/mapped-controls.mjs';
|
|
3
|
+
export { EditorCard, EditorCardProps } from './editor/editor-card.mjs';
|
|
3
4
|
export { ImpactCard, ImpactCardProps, ImpactValue } from './impact/impact-card.mjs';
|
|
4
5
|
export { messages as impactMessages } from './impact/messages.mjs';
|
|
5
6
|
export { ImpactLevel, ImpactLevelConfig, ImpactScaleConfig, ImpactScalePreset, assetScale, getScale, impactLevels, processScale, riskScale } from './impact/scales.mjs';
|
|
@@ -8,4 +9,5 @@ export { RiskRatingDisplay, RiskRatingDisplayProps } from './risk/risk-rating-di
|
|
|
8
9
|
export { RiskLevel, RiskRating, getRiskLevelFromRating, isRatingUnrated, riskLevelConfig } from './risk/types.mjs';
|
|
9
10
|
import 'react/jsx-runtime';
|
|
10
11
|
import 'react';
|
|
12
|
+
import '@kopexa/tiptap';
|
|
11
13
|
import 'react-intl';
|
package/dist/common/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { ComplianceBadges, ComplianceBadgesProps, DoraBadge, DoraBadgeProps, Nis2Badge, Nis2BadgeProps } from './compliance/compliance-badge.js';
|
|
2
2
|
export { ControlChip, ControlChipProps, MappedControls, MappedControlsProps } from './control/mapped-controls.js';
|
|
3
|
+
export { EditorCard, EditorCardProps } from './editor/editor-card.js';
|
|
3
4
|
export { ImpactCard, ImpactCardProps, ImpactValue } from './impact/impact-card.js';
|
|
4
5
|
export { messages as impactMessages } from './impact/messages.js';
|
|
5
6
|
export { ImpactLevel, ImpactLevelConfig, ImpactScaleConfig, ImpactScalePreset, assetScale, getScale, impactLevels, processScale, riskScale } from './impact/scales.js';
|
|
@@ -8,4 +9,5 @@ export { RiskRatingDisplay, RiskRatingDisplayProps } from './risk/risk-rating-di
|
|
|
8
9
|
export { RiskLevel, RiskRating, getRiskLevelFromRating, isRatingUnrated, riskLevelConfig } from './risk/types.js';
|
|
9
10
|
import 'react/jsx-runtime';
|
|
10
11
|
import 'react';
|
|
12
|
+
import '@kopexa/tiptap';
|
|
11
13
|
import 'react-intl';
|