@mieweb/ui 0.6.1-dev.143 → 0.6.1-dev.144
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/brands/index.cjs +12 -12
- package/dist/brands/index.js +3 -3
- package/dist/{chunk-SNEQXSC5.cjs → chunk-26YNFCOC.cjs} +2 -2
- package/dist/{chunk-SNEQXSC5.cjs.map → chunk-26YNFCOC.cjs.map} +1 -1
- package/dist/{chunk-EJUPJGKA.js → chunk-6AHYYWVB.js} +3 -3
- package/dist/{chunk-EJUPJGKA.js.map → chunk-6AHYYWVB.js.map} +1 -1
- package/dist/{chunk-QKAPKIXI.cjs → chunk-6ZYE6JUK.cjs} +6 -6
- package/dist/{chunk-QKAPKIXI.cjs.map → chunk-6ZYE6JUK.cjs.map} +1 -1
- package/dist/{chunk-WTDCNXZO.js → chunk-IUFDGB5O.js} +3 -3
- package/dist/{chunk-WTDCNXZO.js.map → chunk-IUFDGB5O.js.map} +1 -1
- package/dist/{chunk-AWUADXYI.cjs → chunk-KJPOFUF5.cjs} +3 -3
- package/dist/{chunk-AWUADXYI.cjs.map → chunk-KJPOFUF5.cjs.map} +1 -1
- package/dist/{chunk-CYMZ2QS5.js → chunk-TW6DXMSD.js} +2 -2
- package/dist/{chunk-CYMZ2QS5.js.map → chunk-TW6DXMSD.js.map} +1 -1
- package/dist/components/AlertDialog/index.cjs +4 -4
- package/dist/components/AlertDialog/index.js +3 -3
- package/dist/components/Modal/index.cjs +10 -10
- package/dist/components/Modal/index.js +2 -2
- package/dist/components/RichTextEditor/index.cjs +1 -1
- package/dist/components/RichTextEditor/index.js +1 -1
- package/dist/components/Sheet/index.cjs +1 -1
- package/dist/components/Sheet/index.js +1 -1
- package/dist/index.cjs +218 -218
- package/dist/index.js +19 -19
- package/dist/kerebron.cjs +104 -0
- package/dist/kerebron.cjs.map +1 -0
- package/dist/kerebron.css +11 -0
- package/dist/kerebron.d.cts +23 -0
- package/dist/kerebron.d.ts +23 -0
- package/dist/kerebron.js +101 -0
- package/dist/kerebron.js.map +1 -0
- package/dist/utils/index.cjs +5 -5
- package/dist/utils/index.js +1 -1
- package/package.json +29 -2
package/dist/index.js
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
|
+
export { ThemeProvider, ThemeProviderContext, ThemeToggle, themeToggleIconVariants, themeToggleVariants, useThemeContext } from './chunk-I56VBDSC.js';
|
|
1
2
|
export { Toggle, toggleVariants } from './chunk-Y2S6QMKU.js';
|
|
3
|
+
import { Tooltip } from './chunk-FZJBFJJR.js';
|
|
4
|
+
export { Tooltip } from './chunk-FZJBFJJR.js';
|
|
2
5
|
export { VisuallyHidden } from './chunk-H2CIKJQI.js';
|
|
3
|
-
export { brands } from './chunk-
|
|
6
|
+
export { brands } from './chunk-TW6DXMSD.js';
|
|
7
|
+
export { wagglelineBrand } from './chunk-2NTYAALC.js';
|
|
4
8
|
export { webchartBrand } from './chunk-CW66SO5O.js';
|
|
9
|
+
export { ozwellBrand } from './chunk-5YUBQIC7.js';
|
|
5
10
|
export { defaultBrand } from './chunk-PSTGFXQG.js';
|
|
6
11
|
export { enterpriseHealthBrand } from './chunk-MTZPVOP6.js';
|
|
7
12
|
export { miewebBrand } from './chunk-NERS5ZT6.js';
|
|
8
|
-
export { wagglelineBrand } from './chunk-2NTYAALC.js';
|
|
9
13
|
export { createBrandPreset, generateBrandCSS, generateTailwindTheme } from './chunk-WOYUQ4AT.js';
|
|
10
14
|
export { bluehiveBrand } from './chunk-3T7QGLNB.js';
|
|
11
15
|
export { ccmeBrand } from './chunk-SCQRJPSV.js';
|
|
12
|
-
|
|
16
|
+
import { Skeleton } from './chunk-4Z6ZZKIY.js';
|
|
17
|
+
export { Skeleton, SkeletonCard, SkeletonTable, SkeletonText, skeletonVariants } from './chunk-4Z6ZZKIY.js';
|
|
13
18
|
export { Slider, sliderRangeVariants, sliderThumbVariants, sliderTrackVariants } from './chunk-JBB25LFB.js';
|
|
14
19
|
import { Spinner, SpinnerWithLabel } from './chunk-VCO2IZOG.js';
|
|
15
20
|
export { FullPageSpinner, Spinner, SpinnerWithLabel, spinnerVariants } from './chunk-VCO2IZOG.js';
|
|
@@ -23,9 +28,8 @@ import { Text } from './chunk-JLBT76WH.js';
|
|
|
23
28
|
export { SmallMuted, Text, textVariants } from './chunk-JLBT76WH.js';
|
|
24
29
|
import { Textarea } from './chunk-6LFG4JFF.js';
|
|
25
30
|
export { Textarea, textareaVariants } from './chunk-6LFG4JFF.js';
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
export { Tooltip } from './chunk-FZJBFJJR.js';
|
|
31
|
+
import { RadioGroup, Radio } from './chunk-EZKRAW2X.js';
|
|
32
|
+
export { Radio, RadioGroup, radioVariants } from './chunk-EZKRAW2X.js';
|
|
29
33
|
import { RecordButton } from './chunk-QVJBUWJQ.js';
|
|
30
34
|
export { RecordButton, formatDuration, recordButtonVariants } from './chunk-QVJBUWJQ.js';
|
|
31
35
|
export { RichTextEditor, convertAngleBracketsToMustache, processDictation } from './chunk-AEGYWRSL.js';
|
|
@@ -35,8 +39,6 @@ import { Select } from './chunk-R25H4N4Z.js';
|
|
|
35
39
|
export { Select, selectTriggerVariants } from './chunk-R25H4N4Z.js';
|
|
36
40
|
export { Separator, separatorVariants } from './chunk-BX6BTDTR.js';
|
|
37
41
|
export { Sheet, SheetBody, SheetClose, SheetDescription, SheetFooter, SheetHeader, SheetTitle, sheetContentVariants, sheetOverlayVariants } from './chunk-4LVPQ44A.js';
|
|
38
|
-
import { Skeleton } from './chunk-4Z6ZZKIY.js';
|
|
39
|
-
export { Skeleton, SkeletonCard, SkeletonTable, SkeletonText, skeletonVariants } from './chunk-4Z6ZZKIY.js';
|
|
40
42
|
export { Label, labelVariants } from './chunk-DUPR6FEL.js';
|
|
41
43
|
export { CodeBlock, MarkdownRenderer, highlightCode, useMarkdown } from './chunk-NSLR3B7K.js';
|
|
42
44
|
export { CsvBlock } from './chunk-FGIIXD37.js';
|
|
@@ -49,8 +51,6 @@ export { PhoneInput, PhoneInputGroup } from './chunk-OX2RIVN7.js';
|
|
|
49
51
|
import { Progress } from './chunk-IYIYL2SQ.js';
|
|
50
52
|
export { CircularProgress, Progress, circularProgressVariants, progressBarFillVariants, progressBarTrackVariants } from './chunk-IYIYL2SQ.js';
|
|
51
53
|
export { QuickAction, QuickActionGroup, QuickActionIcons, quickActionIconVariants, quickActionVariants } from './chunk-3CJBUAJ4.js';
|
|
52
|
-
import { RadioGroup, Radio } from './chunk-EZKRAW2X.js';
|
|
53
|
-
export { Radio, RadioGroup, radioVariants } from './chunk-EZKRAW2X.js';
|
|
54
54
|
import { Card, CardHeader, CardContent, CardTitle } from './chunk-6555OYRU.js';
|
|
55
55
|
export { Card, CardActions, CardBadge, CardCollapsible, CardContent, CardDescription, CardDivider, CardFooter, CardHeader, CardMedia, CardStat, CardTitle, cardAccentVariants, cardVariants } from './chunk-6555OYRU.js';
|
|
56
56
|
import { Checkbox } from './chunk-XCLQZ4FV.js';
|
|
@@ -62,9 +62,13 @@ export { DateInput } from './chunk-HYEJLKXI.js';
|
|
|
62
62
|
import { Dropdown, DropdownItem, DropdownSeparator } from './chunk-3OHVUXDG.js';
|
|
63
63
|
export { Dropdown, DropdownContent, DropdownHeader, DropdownItem, DropdownLabel, DropdownSeparator } from './chunk-3OHVUXDG.js';
|
|
64
64
|
export { FloatingWindow, MinimizedWindow } from './chunk-C2544GKZ.js';
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
export {
|
|
65
|
+
import { Alert, AlertTitle, AlertDescription } from './chunk-MV3MTHWQ.js';
|
|
66
|
+
export { Alert, AlertDescription, AlertTitle, alertVariants } from './chunk-MV3MTHWQ.js';
|
|
67
|
+
export { AlertDialog } from './chunk-6AHYYWVB.js';
|
|
68
|
+
import { Modal, ModalHeader, ModalTitle, ModalClose, ModalBody, ModalFooter } from './chunk-IUFDGB5O.js';
|
|
69
|
+
export { Modal, ModalBody, ModalClose, ModalFooter, ModalHeader, ModalTitle, modalContentVariants, modalOverlayVariants } from './chunk-IUFDGB5O.js';
|
|
70
|
+
import { Button, buttonVariants } from './chunk-ZVSW2KS6.js';
|
|
71
|
+
export { Button, buttonVariants } from './chunk-ZVSW2KS6.js';
|
|
68
72
|
export { AudioPlayer, ProgressBar, audioPlayerVariants, formatTime as formatAudioTime, playButtonVariants } from './chunk-KAKH2UZA.js';
|
|
69
73
|
export { AudioRecorder, audioRecorderVariants, controlButtonVariants, formatTime, waveformContainerVariants } from './chunk-TRZXK57D.js';
|
|
70
74
|
export { Autocomplete } from './chunk-PI3KOYAT.js';
|
|
@@ -75,8 +79,6 @@ export { Avatar, AvatarGroup, avatarVariants, getInitials } from './chunk-WO5CAO
|
|
|
75
79
|
import { Badge } from './chunk-DCER2QQB.js';
|
|
76
80
|
export { Badge, badgeVariants } from './chunk-DCER2QQB.js';
|
|
77
81
|
export { Breadcrumb, BreadcrumbSlash } from './chunk-HEH3QXOQ.js';
|
|
78
|
-
import { Button, buttonVariants } from './chunk-ZVSW2KS6.js';
|
|
79
|
-
export { Button, buttonVariants } from './chunk-ZVSW2KS6.js';
|
|
80
82
|
import { Clock, FileText, ArrowLeft, Stethoscope, Users, Mail, Phone, Share, ChevronDown, User, Download, ExternalLink, MoreVertical, Pencil, Send, Calendar, Printer, ClipboardPlus, ClipboardCheck, FilePlus, FileCheck, Wheat, Pill, Bell, FileHeart, HeartPulse, AlertCircle as AlertCircle$1, Paperclip, ClipboardList, MoreHorizontal, Trash2, Plus, CheckCircle, Upload as Upload$1, Scan, Camera, ScanLine, RefreshCw as RefreshCw$1, Image, X as X$1, Eye, Check as Check$1 } from './chunk-LEMY57MI.js';
|
|
81
83
|
import { useCommandK, useIsMobile, useMediaQuery, useScrollSpy } from './chunk-Q7NBJFEB.js';
|
|
82
84
|
export { useCommandK, useIsDesktop, useIsLargeDesktop, useIsMobile, useIsMobileOrTablet, useIsSmallTablet, useIsTablet, useKeyboardShortcut, useMediaQuery, useScrollSpy } from './chunk-Q7NBJFEB.js';
|
|
@@ -93,13 +95,11 @@ export { isHtmlEmpty, stripHtmlTags } from './chunk-ERLPVXOV.js';
|
|
|
93
95
|
export { formatPhoneNumber, isPhoneNumberEmpty, isValidPhoneNumber, unformatPhoneNumber } from './chunk-ZVPJ2MH6.js';
|
|
94
96
|
import { dateToDisplayFormat, isValidDate, displayFormatToDateString } from './chunk-RC2YMOMS.js';
|
|
95
97
|
export { calculateAge, dateToDisplayFormat, displayFormatToDateString, formatDateValue, isDateEmpty, isDateInFuture, isDateInPast, isValidDate, isValidDrivingAge, parseDateValue } from './chunk-RC2YMOMS.js';
|
|
98
|
+
import { cn } from './chunk-F3SOEIN2.js';
|
|
99
|
+
export { cn } from './chunk-F3SOEIN2.js';
|
|
96
100
|
import { isStorybookDocsMode } from './chunk-VSQF22GL.js';
|
|
97
101
|
export { isStorybookDocsMode } from './chunk-VSQF22GL.js';
|
|
98
102
|
export { miewebUIPreset, miewebUISafelist } from './chunk-33PO3J4O.js';
|
|
99
|
-
import { Alert, AlertTitle, AlertDescription } from './chunk-MV3MTHWQ.js';
|
|
100
|
-
export { Alert, AlertDescription, AlertTitle, alertVariants } from './chunk-MV3MTHWQ.js';
|
|
101
|
-
import { cn } from './chunk-F3SOEIN2.js';
|
|
102
|
-
export { cn } from './chunk-F3SOEIN2.js';
|
|
103
103
|
import * as React49 from 'react';
|
|
104
104
|
import React49__default, { createContext, useState, useEffect, useCallback, useMemo, useContext, useRef } from 'react';
|
|
105
105
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
var editor = require('@kerebron/editor');
|
|
5
|
+
var AdvancedEditorKit = require('@kerebron/editor-kits/AdvancedEditorKit');
|
|
6
|
+
var web = require('@kerebron/wasm/web');
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
+
var CodeEditorKit = require('@kerebron/editor-kits/CodeEditorKit');
|
|
9
|
+
|
|
10
|
+
// src/components/RichEditor/RichEditor.tsx
|
|
11
|
+
var RichEditor = ({
|
|
12
|
+
value = "",
|
|
13
|
+
onChange,
|
|
14
|
+
showPreview = false
|
|
15
|
+
}) => {
|
|
16
|
+
const editorRef = react.useRef(null);
|
|
17
|
+
const editorInstance = react.useRef(null);
|
|
18
|
+
const onChangeRef = react.useRef(onChange);
|
|
19
|
+
onChangeRef.current = onChange;
|
|
20
|
+
const [md, setMd] = react.useState("");
|
|
21
|
+
react.useEffect(() => {
|
|
22
|
+
if (!editorRef.current) return;
|
|
23
|
+
const editor$1 = editor.CoreEditor.create({
|
|
24
|
+
element: editorRef.current,
|
|
25
|
+
uri: "file:///untitled.md",
|
|
26
|
+
assetLoad: web.createAssetLoad("/kerebron-wasm"),
|
|
27
|
+
editorKits: [new AdvancedEditorKit.AdvancedEditorKit()]
|
|
28
|
+
});
|
|
29
|
+
editorInstance.current = editor$1;
|
|
30
|
+
const onTransaction = async () => {
|
|
31
|
+
if (!editorInstance.current) return;
|
|
32
|
+
try {
|
|
33
|
+
const buffer = await editorInstance.current.saveDocument("text/x-markdown");
|
|
34
|
+
const markdown = new globalThis.TextDecoder().decode(buffer);
|
|
35
|
+
setMd(markdown);
|
|
36
|
+
onChangeRef.current?.(markdown);
|
|
37
|
+
} catch (err) {
|
|
38
|
+
console.error("Failed to save markdown:", err);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
editor$1.addEventListener("transaction", onTransaction);
|
|
42
|
+
if (value) {
|
|
43
|
+
editor$1.loadDocumentText("text/x-markdown", value).then(() => onTransaction()).catch((err) => console.error("Failed to load markdown:", err));
|
|
44
|
+
} else {
|
|
45
|
+
void onTransaction();
|
|
46
|
+
}
|
|
47
|
+
return () => {
|
|
48
|
+
editor$1.removeEventListener("transaction", onTransaction);
|
|
49
|
+
editor$1.destroy();
|
|
50
|
+
};
|
|
51
|
+
}, []);
|
|
52
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
53
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx("div", { ref: editorRef, className: "kb-component" }) }),
|
|
54
|
+
showPreview && /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
55
|
+
/* @__PURE__ */ jsxRuntime.jsx("h5", { children: "Markdown Output" }),
|
|
56
|
+
/* @__PURE__ */ jsxRuntime.jsx("pre", { children: md })
|
|
57
|
+
] }) })
|
|
58
|
+
] });
|
|
59
|
+
};
|
|
60
|
+
RichEditor.displayName = "RichEditor";
|
|
61
|
+
var CodeEditor = ({
|
|
62
|
+
value = "",
|
|
63
|
+
onChange,
|
|
64
|
+
lang = "typescript"
|
|
65
|
+
}) => {
|
|
66
|
+
const editorRef = react.useRef(null);
|
|
67
|
+
const editorInstance = react.useRef(null);
|
|
68
|
+
const onChangeRef = react.useRef(onChange);
|
|
69
|
+
onChangeRef.current = onChange;
|
|
70
|
+
react.useEffect(() => {
|
|
71
|
+
if (!editorRef.current) return;
|
|
72
|
+
const editor$1 = editor.CoreEditor.create({
|
|
73
|
+
element: editorRef.current,
|
|
74
|
+
uri: "file:///untitled.ts",
|
|
75
|
+
assetLoad: web.createAssetLoad("/kerebron-wasm"),
|
|
76
|
+
editorKits: [new CodeEditorKit.CodeEditorKit(lang)]
|
|
77
|
+
});
|
|
78
|
+
editorInstance.current = editor$1;
|
|
79
|
+
const onTransaction = async () => {
|
|
80
|
+
if (!editorInstance.current) return;
|
|
81
|
+
try {
|
|
82
|
+
const buffer = await editorInstance.current.saveDocument("text/plain");
|
|
83
|
+
onChangeRef.current?.(new globalThis.TextDecoder().decode(buffer));
|
|
84
|
+
} catch (err) {
|
|
85
|
+
console.error("Failed to read code:", err);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
editor$1.addEventListener("transaction", onTransaction);
|
|
89
|
+
if (value) {
|
|
90
|
+
editor$1.loadDocumentText("text/plain", value).catch((err) => console.error("Failed to load code:", err));
|
|
91
|
+
}
|
|
92
|
+
return () => {
|
|
93
|
+
editor$1.removeEventListener("transaction", onTransaction);
|
|
94
|
+
editor$1.destroy();
|
|
95
|
+
};
|
|
96
|
+
}, []);
|
|
97
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx("div", { ref: editorRef, className: "kb-component" }) }) });
|
|
98
|
+
};
|
|
99
|
+
CodeEditor.displayName = "CodeEditor";
|
|
100
|
+
|
|
101
|
+
exports.CodeEditor = CodeEditor;
|
|
102
|
+
exports.RichEditor = RichEditor;
|
|
103
|
+
//# sourceMappingURL=kerebron.cjs.map
|
|
104
|
+
//# sourceMappingURL=kerebron.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/RichEditor/RichEditor.tsx","../src/components/RichEditor/CodeEditor.tsx"],"names":["useRef","useState","useEffect","editor","CoreEditor","createAssetLoad","AdvancedEditorKit","jsx","jsxs","CodeEditorKit"],"mappings":";;;;;;;;;;AAeA,IAAM,aAAwC,CAAC;AAAA,EAC7C,KAAA,GAAQ,EAAA;AAAA,EACR,QAAA;AAAA,EACA,WAAA,GAAc;AAChB,CAAA,KAAM;AACJ,EAAA,MAAM,SAAA,GAAYA,aAAuB,IAAI,CAAA;AAC7C,EAAA,MAAM,cAAA,GAAiBA,aAA0B,IAAI,CAAA;AACrD,EAAA,MAAM,WAAA,GAAcA,aAAO,QAAQ,CAAA;AACnC,EAAA,WAAA,CAAY,OAAA,GAAU,QAAA;AAEtB,EAAA,MAAM,CAAC,EAAA,EAAI,KAAK,CAAA,GAAIC,eAAiB,EAAE,CAAA;AAEvC,EAAAC,eAAA,CAAU,MAAM;AACd,IAAA,IAAI,CAAC,UAAU,OAAA,EAAS;AAGxB,IAAA,MAAMC,QAAA,GAASC,kBAAW,MAAA,CAAO;AAAA,MAC/B,SAAS,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AA,MAAM,MAAA,GAAS,MAAM,cAAA,CAAe,OAAA,CAAQ,aAAa,YAAY,CAAA;AACrE,QAAA,WAAA,CAAY,UAAU,IAAI,UAAA,CAAW,aAAY,CAAE,MAAA,CAAO,MAAM,CAAC,CAAA;AAAA,MACnE,SAAS,GAAA,EAAK;AACZ,QAAA,OAAA,CAAQ,KAAA,CAAM,wBAAwB,GAAG,CAAA;AAAA,MAC3C;AAAA,IACF,CAAA;AAEA,IAAAA,QAAA,CAAO,gBAAA,CAAiB,eAAe,aAAa,CAAA;AAGpD,IAAA,IAAI,KAAA,EAAO;AACT,MAAAA,QAAA,CACG,gBAAA,CAAiB,YAAA,EAAc,KAAK,CAAA,CACpC,KAAA,CAAM,CAAC,GAAA,KAAQ,OAAA,CAAQ,KAAA,CAAM,sBAAA,EAAwB,GAAG,CAAC,CAAA;AAAA,IAC9D;AAGA,IAAA,OAAO,MAAM;AACX,MAAAA,QAAA,CAAO,mBAAA,CAAoB,eAAe,aAAa,CAAA;AACvD,MAAAA,QAAA,CAAO,OAAA,EAAQ;AAAA,IACjB,CAAA;AAAA,EAGF,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,uBACEI,cAAAA,CAAC,KAAA,EAAA,EACC,QAAA,kBAAAA,eAAC,KAAA,EAAA,EACC,QAAA,kBAAAA,cAAAA,CAAC,KAAA,EAAA,EAAI,GAAA,EAAK,SAAA,EAAW,SAAA,EAAU,cAAA,EAAe,GAChD,CAAA,EACF,CAAA;AAEJ;AAEA,UAAA,CAAW,WAAA,GAAc,YAAA","file":"kerebron.cjs","sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\n\nimport { CoreEditor } from '@kerebron/editor';\nimport { AdvancedEditorKit } from '@kerebron/editor-kits/AdvancedEditorKit';\nimport { createAssetLoad } from '@kerebron/wasm/web';\n\nexport interface RichEditorProps {\n /** Initial markdown content to load into the editor. */\n value?: string;\n /** Called with the editor's markdown content whenever it changes. */\n onChange?: (value: string) => void;\n /** Whether to render the live markdown output preview. Defaults to `false`. */\n showPreview?: boolean;\n}\n\nconst RichEditor: React.FC<RichEditorProps> = ({\n value = '',\n onChange,\n showPreview = false,\n}) => {\n const editorRef = useRef<HTMLDivElement>(null);\n const editorInstance = useRef<CoreEditor | null>(null);\n const onChangeRef = useRef(onChange);\n onChangeRef.current = onChange;\n\n const [md, setMd] = useState<string>('');\n\n useEffect(() => {\n if (!editorRef.current) return;\n\n // Initialize the editor\n const editor = CoreEditor.create({\n element: editorRef.current,\n uri: 'file:///untitled.md',\n assetLoad: createAssetLoad('/kerebron-wasm'),\n editorKits: [new AdvancedEditorKit()],\n });\n\n editorInstance.current = editor;\n\n // Listen to transactions and update markdown preview\n const onTransaction = async () => {\n if (!editorInstance.current) return;\n\n try {\n const buffer =\n await editorInstance.current.saveDocument('text/x-markdown');\n const markdown = new globalThis.TextDecoder().decode(buffer);\n setMd(markdown);\n onChangeRef.current?.(markdown);\n } catch (err) {\n console.error('Failed to save markdown:', err);\n }\n };\n\n editor.addEventListener('transaction', onTransaction);\n\n // Seed initial content, then populate the preview once on mount.\n if (value) {\n editor\n .loadDocumentText('text/x-markdown', value)\n .then(() => onTransaction())\n .catch((err) => console.error('Failed to load markdown:', err));\n } else {\n void onTransaction();\n }\n\n // Cleanup on unmount\n return () => {\n editor.removeEventListener('transaction', onTransaction);\n editor.destroy();\n };\n // Initial `value` is intentionally only applied on mount (uncontrolled).\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return (\n <div>\n <div>\n <div ref={editorRef} className=\"kb-component\" />\n </div>\n\n {showPreview && (\n <div>\n <div>\n <h5>Markdown Output</h5>\n <pre>{md}</pre>\n </div>\n </div>\n )}\n </div>\n );\n};\n\nRichEditor.displayName = 'RichEditor';\n\nexport { RichEditor };\n","import React, { useEffect, useRef } from 'react';\n\nimport { CoreEditor } from '@kerebron/editor';\nimport { CodeEditorKit } from '@kerebron/editor-kits/CodeEditorKit';\nimport { createAssetLoad } from '@kerebron/wasm/web';\n\nexport interface CodeEditorProps {\n /** Initial source code to load into the editor. */\n value?: string;\n /** Called with the editor's contents whenever they change. */\n onChange?: (value: string) => void;\n /** Language/grammar to use for syntax highlighting. Defaults to `typescript`. */\n lang?: string;\n}\n\nconst CodeEditor: React.FC<CodeEditorProps> = ({\n value = '',\n onChange,\n lang = 'typescript',\n}) => {\n const editorRef = useRef<HTMLDivElement>(null);\n const editorInstance = useRef<CoreEditor | null>(null);\n const onChangeRef = useRef(onChange);\n onChangeRef.current = onChange;\n\n useEffect(() => {\n if (!editorRef.current) return;\n\n // Initialize the editor\n const editor = CoreEditor.create({\n element: editorRef.current,\n uri: 'file:///untitled.ts',\n assetLoad: createAssetLoad('/kerebron-wasm'),\n editorKits: [new CodeEditorKit(lang)],\n });\n\n editorInstance.current = editor;\n\n // Surface edits to callers.\n const onTransaction = async () => {\n if (!editorInstance.current) return;\n\n try {\n const buffer = await editorInstance.current.saveDocument('text/plain');\n onChangeRef.current?.(new globalThis.TextDecoder().decode(buffer));\n } catch (err) {\n console.error('Failed to read code:', err);\n }\n };\n\n editor.addEventListener('transaction', onTransaction);\n\n // Seed initial content on mount.\n if (value) {\n editor\n .loadDocumentText('text/plain', value)\n .catch((err) => console.error('Failed to load code:', err));\n }\n\n // Cleanup on unmount\n return () => {\n editor.removeEventListener('transaction', onTransaction);\n editor.destroy();\n };\n // Initial `value`/`lang` are intentionally only applied on mount.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return (\n <div>\n <div>\n <div ref={editorRef} className=\"kb-component\" />\n </div>\n </div>\n );\n};\n\nCodeEditor.displayName = 'CodeEditor';\n\nexport { CodeEditor };\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kerebron editor styles — opt-in stylesheet for @mieweb/ui/kerebron.
|
|
3
|
+
*
|
|
4
|
+
* Import this only when you use the RichEditor / CodeEditor components:
|
|
5
|
+
* import '@mieweb/ui/kerebron.css';
|
|
6
|
+
*
|
|
7
|
+
* Kept separate from the library's global styles.css so consumers that don't
|
|
8
|
+
* use the Kerebron editor don't ship its CSS.
|
|
9
|
+
*/
|
|
10
|
+
@import '@kerebron/editor/assets/index.css';
|
|
11
|
+
@import '@kerebron/editor-kits/assets/AdvancedEditorKit.css';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
|
|
3
|
+
interface RichEditorProps {
|
|
4
|
+
/** Initial markdown content to load into the editor. */
|
|
5
|
+
value?: string;
|
|
6
|
+
/** Called with the editor's markdown content whenever it changes. */
|
|
7
|
+
onChange?: (value: string) => void;
|
|
8
|
+
/** Whether to render the live markdown output preview. Defaults to `false`. */
|
|
9
|
+
showPreview?: boolean;
|
|
10
|
+
}
|
|
11
|
+
declare const RichEditor: React__default.FC<RichEditorProps>;
|
|
12
|
+
|
|
13
|
+
interface CodeEditorProps {
|
|
14
|
+
/** Initial source code to load into the editor. */
|
|
15
|
+
value?: string;
|
|
16
|
+
/** Called with the editor's contents whenever they change. */
|
|
17
|
+
onChange?: (value: string) => void;
|
|
18
|
+
/** Language/grammar to use for syntax highlighting. Defaults to `typescript`. */
|
|
19
|
+
lang?: string;
|
|
20
|
+
}
|
|
21
|
+
declare const CodeEditor: React__default.FC<CodeEditorProps>;
|
|
22
|
+
|
|
23
|
+
export { CodeEditor, type CodeEditorProps, RichEditor, type RichEditorProps };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
|
|
3
|
+
interface RichEditorProps {
|
|
4
|
+
/** Initial markdown content to load into the editor. */
|
|
5
|
+
value?: string;
|
|
6
|
+
/** Called with the editor's markdown content whenever it changes. */
|
|
7
|
+
onChange?: (value: string) => void;
|
|
8
|
+
/** Whether to render the live markdown output preview. Defaults to `false`. */
|
|
9
|
+
showPreview?: boolean;
|
|
10
|
+
}
|
|
11
|
+
declare const RichEditor: React__default.FC<RichEditorProps>;
|
|
12
|
+
|
|
13
|
+
interface CodeEditorProps {
|
|
14
|
+
/** Initial source code to load into the editor. */
|
|
15
|
+
value?: string;
|
|
16
|
+
/** Called with the editor's contents whenever they change. */
|
|
17
|
+
onChange?: (value: string) => void;
|
|
18
|
+
/** Language/grammar to use for syntax highlighting. Defaults to `typescript`. */
|
|
19
|
+
lang?: string;
|
|
20
|
+
}
|
|
21
|
+
declare const CodeEditor: React__default.FC<CodeEditorProps>;
|
|
22
|
+
|
|
23
|
+
export { CodeEditor, type CodeEditorProps, RichEditor, type RichEditorProps };
|
package/dist/kerebron.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { useRef, useState, useEffect } from 'react';
|
|
2
|
+
import { CoreEditor } from '@kerebron/editor';
|
|
3
|
+
import { AdvancedEditorKit } from '@kerebron/editor-kits/AdvancedEditorKit';
|
|
4
|
+
import { createAssetLoad } from '@kerebron/wasm/web';
|
|
5
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
6
|
+
import { CodeEditorKit } from '@kerebron/editor-kits/CodeEditorKit';
|
|
7
|
+
|
|
8
|
+
// src/components/RichEditor/RichEditor.tsx
|
|
9
|
+
var RichEditor = ({
|
|
10
|
+
value = "",
|
|
11
|
+
onChange,
|
|
12
|
+
showPreview = false
|
|
13
|
+
}) => {
|
|
14
|
+
const editorRef = useRef(null);
|
|
15
|
+
const editorInstance = useRef(null);
|
|
16
|
+
const onChangeRef = useRef(onChange);
|
|
17
|
+
onChangeRef.current = onChange;
|
|
18
|
+
const [md, setMd] = useState("");
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (!editorRef.current) return;
|
|
21
|
+
const editor = CoreEditor.create({
|
|
22
|
+
element: editorRef.current,
|
|
23
|
+
uri: "file:///untitled.md",
|
|
24
|
+
assetLoad: createAssetLoad("/kerebron-wasm"),
|
|
25
|
+
editorKits: [new AdvancedEditorKit()]
|
|
26
|
+
});
|
|
27
|
+
editorInstance.current = editor;
|
|
28
|
+
const onTransaction = async () => {
|
|
29
|
+
if (!editorInstance.current) return;
|
|
30
|
+
try {
|
|
31
|
+
const buffer = await editorInstance.current.saveDocument("text/x-markdown");
|
|
32
|
+
const markdown = new globalThis.TextDecoder().decode(buffer);
|
|
33
|
+
setMd(markdown);
|
|
34
|
+
onChangeRef.current?.(markdown);
|
|
35
|
+
} catch (err) {
|
|
36
|
+
console.error("Failed to save markdown:", err);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
editor.addEventListener("transaction", onTransaction);
|
|
40
|
+
if (value) {
|
|
41
|
+
editor.loadDocumentText("text/x-markdown", value).then(() => onTransaction()).catch((err) => console.error("Failed to load markdown:", err));
|
|
42
|
+
} else {
|
|
43
|
+
void onTransaction();
|
|
44
|
+
}
|
|
45
|
+
return () => {
|
|
46
|
+
editor.removeEventListener("transaction", onTransaction);
|
|
47
|
+
editor.destroy();
|
|
48
|
+
};
|
|
49
|
+
}, []);
|
|
50
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
51
|
+
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("div", { ref: editorRef, className: "kb-component" }) }),
|
|
52
|
+
showPreview && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("div", { children: [
|
|
53
|
+
/* @__PURE__ */ jsx("h5", { children: "Markdown Output" }),
|
|
54
|
+
/* @__PURE__ */ jsx("pre", { children: md })
|
|
55
|
+
] }) })
|
|
56
|
+
] });
|
|
57
|
+
};
|
|
58
|
+
RichEditor.displayName = "RichEditor";
|
|
59
|
+
var CodeEditor = ({
|
|
60
|
+
value = "",
|
|
61
|
+
onChange,
|
|
62
|
+
lang = "typescript"
|
|
63
|
+
}) => {
|
|
64
|
+
const editorRef = useRef(null);
|
|
65
|
+
const editorInstance = useRef(null);
|
|
66
|
+
const onChangeRef = useRef(onChange);
|
|
67
|
+
onChangeRef.current = onChange;
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
if (!editorRef.current) return;
|
|
70
|
+
const editor = CoreEditor.create({
|
|
71
|
+
element: editorRef.current,
|
|
72
|
+
uri: "file:///untitled.ts",
|
|
73
|
+
assetLoad: createAssetLoad("/kerebron-wasm"),
|
|
74
|
+
editorKits: [new CodeEditorKit(lang)]
|
|
75
|
+
});
|
|
76
|
+
editorInstance.current = editor;
|
|
77
|
+
const onTransaction = async () => {
|
|
78
|
+
if (!editorInstance.current) return;
|
|
79
|
+
try {
|
|
80
|
+
const buffer = await editorInstance.current.saveDocument("text/plain");
|
|
81
|
+
onChangeRef.current?.(new globalThis.TextDecoder().decode(buffer));
|
|
82
|
+
} catch (err) {
|
|
83
|
+
console.error("Failed to read code:", err);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
editor.addEventListener("transaction", onTransaction);
|
|
87
|
+
if (value) {
|
|
88
|
+
editor.loadDocumentText("text/plain", value).catch((err) => console.error("Failed to load code:", err));
|
|
89
|
+
}
|
|
90
|
+
return () => {
|
|
91
|
+
editor.removeEventListener("transaction", onTransaction);
|
|
92
|
+
editor.destroy();
|
|
93
|
+
};
|
|
94
|
+
}, []);
|
|
95
|
+
return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("div", { ref: editorRef, className: "kb-component" }) }) });
|
|
96
|
+
};
|
|
97
|
+
CodeEditor.displayName = "CodeEditor";
|
|
98
|
+
|
|
99
|
+
export { CodeEditor, RichEditor };
|
|
100
|
+
//# sourceMappingURL=kerebron.js.map
|
|
101
|
+
//# sourceMappingURL=kerebron.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/RichEditor/RichEditor.tsx","../src/components/RichEditor/CodeEditor.tsx"],"names":["useRef","useEffect","CoreEditor","createAssetLoad","jsx"],"mappings":";;;;;;;;AAeA,IAAM,aAAwC,CAAC;AAAA,EAC7C,KAAA,GAAQ,EAAA;AAAA,EACR,QAAA;AAAA,EACA,WAAA,GAAc;AAChB,CAAA,KAAM;AACJ,EAAA,MAAM,SAAA,GAAY,OAAuB,IAAI,CAAA;AAC7C,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,CAAA;AAEJ;AAEA,UAAA,CAAW,WAAA,GAAc,YAAA","file":"kerebron.js","sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\n\nimport { CoreEditor } from '@kerebron/editor';\nimport { AdvancedEditorKit } from '@kerebron/editor-kits/AdvancedEditorKit';\nimport { createAssetLoad } from '@kerebron/wasm/web';\n\nexport interface RichEditorProps {\n /** Initial markdown content to load into the editor. */\n value?: string;\n /** Called with the editor's markdown content whenever it changes. */\n onChange?: (value: string) => void;\n /** Whether to render the live markdown output preview. Defaults to `false`. */\n showPreview?: boolean;\n}\n\nconst RichEditor: React.FC<RichEditorProps> = ({\n value = '',\n onChange,\n showPreview = false,\n}) => {\n const editorRef = useRef<HTMLDivElement>(null);\n const editorInstance = useRef<CoreEditor | null>(null);\n const onChangeRef = useRef(onChange);\n onChangeRef.current = onChange;\n\n const [md, setMd] = useState<string>('');\n\n useEffect(() => {\n if (!editorRef.current) return;\n\n // Initialize the editor\n const editor = CoreEditor.create({\n element: editorRef.current,\n uri: 'file:///untitled.md',\n assetLoad: createAssetLoad('/kerebron-wasm'),\n editorKits: [new AdvancedEditorKit()],\n });\n\n editorInstance.current = editor;\n\n // Listen to transactions and update markdown preview\n const onTransaction = async () => {\n if (!editorInstance.current) return;\n\n try {\n const buffer =\n await editorInstance.current.saveDocument('text/x-markdown');\n const markdown = new globalThis.TextDecoder().decode(buffer);\n setMd(markdown);\n onChangeRef.current?.(markdown);\n } catch (err) {\n console.error('Failed to save markdown:', err);\n }\n };\n\n editor.addEventListener('transaction', onTransaction);\n\n // Seed initial content, then populate the preview once on mount.\n if (value) {\n editor\n .loadDocumentText('text/x-markdown', value)\n .then(() => onTransaction())\n .catch((err) => console.error('Failed to load markdown:', err));\n } else {\n void onTransaction();\n }\n\n // Cleanup on unmount\n return () => {\n editor.removeEventListener('transaction', onTransaction);\n editor.destroy();\n };\n // Initial `value` is intentionally only applied on mount (uncontrolled).\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return (\n <div>\n <div>\n <div ref={editorRef} className=\"kb-component\" />\n </div>\n\n {showPreview && (\n <div>\n <div>\n <h5>Markdown Output</h5>\n <pre>{md}</pre>\n </div>\n </div>\n )}\n </div>\n );\n};\n\nRichEditor.displayName = 'RichEditor';\n\nexport { RichEditor };\n","import React, { useEffect, useRef } from 'react';\n\nimport { CoreEditor } from '@kerebron/editor';\nimport { CodeEditorKit } from '@kerebron/editor-kits/CodeEditorKit';\nimport { createAssetLoad } from '@kerebron/wasm/web';\n\nexport interface CodeEditorProps {\n /** Initial source code to load into the editor. */\n value?: string;\n /** Called with the editor's contents whenever they change. */\n onChange?: (value: string) => void;\n /** Language/grammar to use for syntax highlighting. Defaults to `typescript`. */\n lang?: string;\n}\n\nconst CodeEditor: React.FC<CodeEditorProps> = ({\n value = '',\n onChange,\n lang = 'typescript',\n}) => {\n const editorRef = useRef<HTMLDivElement>(null);\n const editorInstance = useRef<CoreEditor | null>(null);\n const onChangeRef = useRef(onChange);\n onChangeRef.current = onChange;\n\n useEffect(() => {\n if (!editorRef.current) return;\n\n // Initialize the editor\n const editor = CoreEditor.create({\n element: editorRef.current,\n uri: 'file:///untitled.ts',\n assetLoad: createAssetLoad('/kerebron-wasm'),\n editorKits: [new CodeEditorKit(lang)],\n });\n\n editorInstance.current = editor;\n\n // Surface edits to callers.\n const onTransaction = async () => {\n if (!editorInstance.current) return;\n\n try {\n const buffer = await editorInstance.current.saveDocument('text/plain');\n onChangeRef.current?.(new globalThis.TextDecoder().decode(buffer));\n } catch (err) {\n console.error('Failed to read code:', err);\n }\n };\n\n editor.addEventListener('transaction', onTransaction);\n\n // Seed initial content on mount.\n if (value) {\n editor\n .loadDocumentText('text/plain', value)\n .catch((err) => console.error('Failed to load code:', err));\n }\n\n // Cleanup on unmount\n return () => {\n editor.removeEventListener('transaction', onTransaction);\n editor.destroy();\n };\n // Initial `value`/`lang` are intentionally only applied on mount.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return (\n <div>\n <div>\n <div ref={editorRef} className=\"kb-component\" />\n </div>\n </div>\n );\n};\n\nCodeEditor.displayName = 'CodeEditor';\n\nexport { CodeEditor };\n"]}
|
package/dist/utils/index.cjs
CHANGED
|
@@ -4,8 +4,8 @@ require('../chunk-AT732HC6.cjs');
|
|
|
4
4
|
var chunkC7RVKV25_cjs = require('../chunk-C7RVKV25.cjs');
|
|
5
5
|
var chunkL7YQBSEL_cjs = require('../chunk-L7YQBSEL.cjs');
|
|
6
6
|
var chunkCW75IKA6_cjs = require('../chunk-CW75IKA6.cjs');
|
|
7
|
-
var chunkSCV7C55E_cjs = require('../chunk-SCV7C55E.cjs');
|
|
8
7
|
var chunkOR5DRJCW_cjs = require('../chunk-OR5DRJCW.cjs');
|
|
8
|
+
var chunkSCV7C55E_cjs = require('../chunk-SCV7C55E.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
@@ -73,13 +73,13 @@ Object.defineProperty(exports, "parseDateValue", {
|
|
|
73
73
|
enumerable: true,
|
|
74
74
|
get: function () { return chunkCW75IKA6_cjs.parseDateValue; }
|
|
75
75
|
});
|
|
76
|
-
Object.defineProperty(exports, "isStorybookDocsMode", {
|
|
77
|
-
enumerable: true,
|
|
78
|
-
get: function () { return chunkSCV7C55E_cjs.isStorybookDocsMode; }
|
|
79
|
-
});
|
|
80
76
|
Object.defineProperty(exports, "cn", {
|
|
81
77
|
enumerable: true,
|
|
82
78
|
get: function () { return chunkOR5DRJCW_cjs.cn; }
|
|
83
79
|
});
|
|
80
|
+
Object.defineProperty(exports, "isStorybookDocsMode", {
|
|
81
|
+
enumerable: true,
|
|
82
|
+
get: function () { return chunkSCV7C55E_cjs.isStorybookDocsMode; }
|
|
83
|
+
});
|
|
84
84
|
//# sourceMappingURL=index.cjs.map
|
|
85
85
|
//# sourceMappingURL=index.cjs.map
|
package/dist/utils/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import '../chunk-7XUN3OQT.js';
|
|
|
2
2
|
export { isHtmlEmpty, stripHtmlTags } from '../chunk-ERLPVXOV.js';
|
|
3
3
|
export { formatPhoneNumber, isPhoneNumberEmpty, isValidPhoneNumber, unformatPhoneNumber } from '../chunk-ZVPJ2MH6.js';
|
|
4
4
|
export { calculateAge, dateToDisplayFormat, displayFormatToDateString, formatDateValue, isDateEmpty, isDateInFuture, isDateInPast, isValidDate, isValidDrivingAge, parseDateValue } from '../chunk-RC2YMOMS.js';
|
|
5
|
-
export { isStorybookDocsMode } from '../chunk-VSQF22GL.js';
|
|
6
5
|
export { cn } from '../chunk-F3SOEIN2.js';
|
|
6
|
+
export { isStorybookDocsMode } from '../chunk-VSQF22GL.js';
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mieweb/ui",
|
|
3
|
-
"version": "0.6.1-dev.
|
|
3
|
+
"version": "0.6.1-dev.144",
|
|
4
4
|
"description": "A themeable, accessible React component library built with Tailwind CSS",
|
|
5
5
|
"author": "Medical Informatics Engineering, Inc.",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -139,9 +139,20 @@
|
|
|
139
139
|
"default": "./dist/esheet.cjs"
|
|
140
140
|
}
|
|
141
141
|
},
|
|
142
|
+
"./kerebron": {
|
|
143
|
+
"import": {
|
|
144
|
+
"types": "./dist/kerebron.d.ts",
|
|
145
|
+
"default": "./dist/kerebron.js"
|
|
146
|
+
},
|
|
147
|
+
"require": {
|
|
148
|
+
"types": "./dist/kerebron.d.cts",
|
|
149
|
+
"default": "./dist/kerebron.cjs"
|
|
150
|
+
}
|
|
151
|
+
},
|
|
142
152
|
"./styles.css": "./dist/styles.css",
|
|
143
153
|
"./styles": "./dist/styles.css",
|
|
144
154
|
"./markdown.css": "./dist/components/Markdown/styles.css",
|
|
155
|
+
"./kerebron.css": "./dist/kerebron.css",
|
|
145
156
|
"./init.css": "./dist/styles/init.css"
|
|
146
157
|
},
|
|
147
158
|
"files": [
|
|
@@ -153,12 +164,13 @@
|
|
|
153
164
|
"preinstall": "if [ -d .git ]; then git submodule update --init --recursive; fi",
|
|
154
165
|
"dev": "tsup --watch",
|
|
155
166
|
"prebuild": "npm run build:esheet",
|
|
156
|
-
"build": "node --max-old-space-size=8192 ./node_modules/tsup/dist/cli-default.js && npm run build:css && npm run copy:brand-css && npm run copy:style-css && npm run copy:markdown-css",
|
|
167
|
+
"build": "node --max-old-space-size=8192 ./node_modules/tsup/dist/cli-default.js && npm run build:css && npm run copy:brand-css && npm run copy:style-css && npm run copy:markdown-css && npm run copy:kerebron-css",
|
|
157
168
|
"build:esheet": "if [ ! -f packages/esheet/packages/core/dist/index.d.ts ] || [ ! -f packages/esheet/packages/renderer/src/index.output.css ]; then cd packages/esheet && npm ci && npx nx run-many --target=build --projects=@esheet/core,@esheet/fields,@esheet/adapters,@esheet/builder,@esheet/renderer --parallel; fi",
|
|
158
169
|
"build:css": "npx @tailwindcss/cli -i ./src/styles/base.css -o ./dist/styles.css --minify",
|
|
159
170
|
"copy:brand-css": "cp src/brands/*.css dist/brands/ 2>/dev/null || true",
|
|
160
171
|
"copy:style-css": "mkdir -p dist/styles && cp src/styles/init.css dist/styles/ 2>/dev/null || true",
|
|
161
172
|
"copy:markdown-css": "mkdir -p dist/components/Markdown && cp src/components/Markdown/styles.css dist/components/Markdown/ 2>/dev/null || true",
|
|
173
|
+
"copy:kerebron-css": "cp src/styles/kerebron.css dist/kerebron.css 2>/dev/null || true",
|
|
162
174
|
"typecheck": "tsc --noEmit",
|
|
163
175
|
"lint": "eslint \"src/**/*.{ts,tsx}\"",
|
|
164
176
|
"lint:fix": "eslint \"src/**/*.{ts,tsx}\" --fix",
|
|
@@ -180,6 +192,9 @@
|
|
|
180
192
|
"peerDependencies": {
|
|
181
193
|
"@esheet/builder": ">=0.0.2",
|
|
182
194
|
"@esheet/renderer": ">=0.0.2",
|
|
195
|
+
"@kerebron/editor": ">=0.7.9",
|
|
196
|
+
"@kerebron/editor-kits": ">=0.7.9",
|
|
197
|
+
"@kerebron/wasm": ">=0.7.9",
|
|
183
198
|
"@mieweb/datavis": "=0.0.0-PRE.2",
|
|
184
199
|
"ag-grid-community": ">=32.0.0",
|
|
185
200
|
"ag-grid-react": ">=32.0.0",
|
|
@@ -198,6 +213,15 @@
|
|
|
198
213
|
"@esheet/renderer": {
|
|
199
214
|
"optional": true
|
|
200
215
|
},
|
|
216
|
+
"@kerebron/editor": {
|
|
217
|
+
"optional": true
|
|
218
|
+
},
|
|
219
|
+
"@kerebron/editor-kits": {
|
|
220
|
+
"optional": true
|
|
221
|
+
},
|
|
222
|
+
"@kerebron/wasm": {
|
|
223
|
+
"optional": true
|
|
224
|
+
},
|
|
201
225
|
"@mieweb/datavis": {
|
|
202
226
|
"optional": true
|
|
203
227
|
},
|
|
@@ -253,6 +277,9 @@
|
|
|
253
277
|
"@esheet/fields": "link:./packages/esheet/packages/fields",
|
|
254
278
|
"@esheet/renderer": "link:./packages/esheet/packages/renderer",
|
|
255
279
|
"@eslint/js": "^9.39.3",
|
|
280
|
+
"@kerebron/editor": "0.7.9",
|
|
281
|
+
"@kerebron/editor-kits": "0.7.9",
|
|
282
|
+
"@kerebron/wasm": "0.7.9",
|
|
256
283
|
"@monaco-editor/react": "^4.7.0",
|
|
257
284
|
"@playwright/test": "^1.58.2",
|
|
258
285
|
"@storybook/addon-a11y": "^10.2.11",
|