@mieweb/ui 0.6.1-dev.158 → 0.6.1-dev.164
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/MedicationEditor-Bp4NLy7y.d.cts +352 -0
- package/dist/MedicationEditor-Bp4NLy7y.d.ts +352 -0
- package/dist/ag-grid.cjs +5 -5
- package/dist/ag-grid.js +1 -1
- package/dist/{chunk-H4T5T65N.cjs → chunk-2JQBPU3Y.cjs} +3 -3
- package/dist/{chunk-H4T5T65N.cjs.map → chunk-2JQBPU3Y.cjs.map} +1 -1
- package/dist/{chunk-6555OYRU.js → chunk-5BQE6BEL.js} +2 -2
- package/dist/{chunk-6555OYRU.js.map → chunk-5BQE6BEL.js.map} +1 -1
- package/dist/chunk-67CEEDAP.cjs +1605 -0
- package/dist/chunk-67CEEDAP.cjs.map +1 -0
- package/dist/{chunk-ULF4PWHW.cjs → chunk-7BARESXI.cjs} +3 -3
- package/dist/{chunk-ULF4PWHW.cjs.map → chunk-7BARESXI.cjs.map} +1 -1
- package/dist/{chunk-UHPQYBXQ.js → chunk-7QZSJFYT.js} +3 -6
- package/dist/chunk-7QZSJFYT.js.map +1 -0
- package/dist/chunk-7ZVTLTJF.js +109 -0
- package/dist/chunk-7ZVTLTJF.js.map +1 -0
- package/dist/{chunk-2T4JU5RH.cjs → chunk-CB4JX5EJ.cjs} +3 -6
- package/dist/chunk-CB4JX5EJ.cjs.map +1 -0
- package/dist/{chunk-FADQVM4M.cjs → chunk-CDMWZBDD.cjs} +6 -6
- package/dist/{chunk-FADQVM4M.cjs.map → chunk-CDMWZBDD.cjs.map} +1 -1
- package/dist/chunk-DHKYGVP7.js +3 -0
- package/dist/{chunk-LEMY57MI.js.map → chunk-DHKYGVP7.js.map} +1 -1
- package/dist/{chunk-FSBFQBNE.cjs → chunk-DKGUOMBC.cjs} +2 -2
- package/dist/{chunk-FSBFQBNE.cjs.map → chunk-DKGUOMBC.cjs.map} +1 -1
- package/dist/{chunk-4FALCEJI.cjs → chunk-EL2RSQTJ.cjs} +2 -2
- package/dist/{chunk-4FALCEJI.cjs.map → chunk-EL2RSQTJ.cjs.map} +1 -1
- package/dist/{chunk-ASLZUFH4.js → chunk-ETGZ5DSA.js} +4 -4
- package/dist/{chunk-ASLZUFH4.js.map → chunk-ETGZ5DSA.js.map} +1 -1
- package/dist/{chunk-TXYTMU3K.js → chunk-FJG7KUDJ.js} +4 -4
- package/dist/{chunk-TXYTMU3K.js.map → chunk-FJG7KUDJ.js.map} +1 -1
- package/dist/{chunk-6R2ZPDN7.cjs → chunk-GBRPZGSI.cjs} +8 -8
- package/dist/{chunk-6R2ZPDN7.cjs.map → chunk-GBRPZGSI.cjs.map} +1 -1
- package/dist/{chunk-M7BLVBL4.js → chunk-GSOOPTGM.js} +3 -3
- package/dist/{chunk-M7BLVBL4.js.map → chunk-GSOOPTGM.js.map} +1 -1
- package/dist/chunk-HUXOASEB.js +1568 -0
- package/dist/chunk-HUXOASEB.js.map +1 -0
- package/dist/chunk-IQ4KQJAO.js +3 -0
- package/dist/{chunk-4ZU53GNR.cjs.map → chunk-IQ4KQJAO.js.map} +1 -1
- package/dist/{chunk-RXY5SD3O.js → chunk-NBD236EH.js} +50 -2
- package/dist/chunk-NBD236EH.js.map +1 -0
- package/dist/chunk-OF7NTZ2I.js +3 -0
- package/dist/chunk-OF7NTZ2I.js.map +1 -0
- package/dist/chunk-RHNPILZQ.cjs +4 -0
- package/dist/chunk-RHNPILZQ.cjs.map +1 -0
- package/dist/chunk-RI56YPED.cjs +201 -0
- package/dist/chunk-RI56YPED.cjs.map +1 -0
- package/dist/{chunk-DCER2QQB.js → chunk-T42BCIUA.js} +2 -2
- package/dist/{chunk-DCER2QQB.js.map → chunk-T42BCIUA.js.map} +1 -1
- package/dist/{chunk-4ZU53GNR.cjs → chunk-UTYUT5YY.cjs} +62 -2
- package/dist/chunk-UTYUT5YY.cjs.map +1 -0
- package/dist/{chunk-Q7NBJFEB.js → chunk-UVQEHZRF.js} +2 -2
- package/dist/{chunk-Q7NBJFEB.js.map → chunk-UVQEHZRF.js.map} +1 -1
- package/dist/chunk-VBWRH4UW.cjs +4 -0
- package/dist/chunk-VBWRH4UW.cjs.map +1 -0
- package/dist/{chunk-LZPPH5BW.cjs → chunk-VJOVJTFP.cjs} +14 -12
- package/dist/chunk-VJOVJTFP.cjs.map +1 -0
- package/dist/{chunk-OVQKCUTZ.js → chunk-WFS6R2F5.js} +3 -3
- package/dist/{chunk-OVQKCUTZ.js.map → chunk-WFS6R2F5.js.map} +1 -1
- package/dist/chunk-Y5KEFV5O.js +192 -0
- package/dist/chunk-Y5KEFV5O.js.map +1 -0
- package/dist/{chunk-3SSXDWD7.js → chunk-YBLIDESO.js} +14 -12
- package/dist/chunk-YBLIDESO.js.map +1 -0
- package/dist/chunk-YVPC65ZJ.cjs +134 -0
- package/dist/chunk-YVPC65ZJ.cjs.map +1 -0
- package/dist/{chunk-7PA26KBF.cjs → chunk-YYDW3ZZS.cjs} +50 -2
- package/dist/chunk-YYDW3ZZS.cjs.map +1 -0
- package/dist/{chunk-3M4P2KMG.cjs → chunk-ZHBANUBI.cjs} +2 -2
- package/dist/{chunk-3M4P2KMG.cjs.map → chunk-ZHBANUBI.cjs.map} +1 -1
- package/dist/components/Badge/index.cjs +4 -3
- package/dist/components/Badge/index.js +2 -1
- package/dist/components/Card/index.cjs +16 -15
- package/dist/components/Card/index.js +2 -1
- package/dist/components/CountryCodeDropdown/index.cjs +5 -5
- package/dist/components/CountryCodeDropdown/index.js +2 -2
- package/dist/components/Dropdown/index.cjs +8 -8
- package/dist/components/Dropdown/index.js +2 -2
- package/dist/components/RichTextEditor/index.cjs +7 -7
- package/dist/components/RichTextEditor/index.js +4 -4
- package/dist/components/Skeleton/index.d.cts +1 -1
- package/dist/components/Skeleton/index.d.ts +1 -1
- package/dist/components/SuperChat/index.cjs +71 -19
- package/dist/components/SuperChat/index.cjs.map +1 -1
- package/dist/components/SuperChat/index.js +65 -13
- package/dist/components/SuperChat/index.js.map +1 -1
- package/dist/components/SuperChat/plugins/index.cjs +7 -4
- package/dist/components/SuperChat/plugins/index.cjs.map +1 -1
- package/dist/components/SuperChat/plugins/index.js +6 -3
- package/dist/components/SuperChat/plugins/index.js.map +1 -1
- package/dist/datavis.cjs +273 -5
- package/dist/datavis.cjs.map +1 -1
- package/dist/datavis.d.cts +62 -1
- package/dist/datavis.d.ts +62 -1
- package/dist/datavis.js +251 -1
- package/dist/datavis.js.map +1 -1
- package/dist/esheet.cjs +182 -0
- package/dist/esheet.cjs.map +1 -1
- package/dist/esheet.d.cts +117 -0
- package/dist/esheet.d.ts +117 -0
- package/dist/esheet.js +161 -0
- package/dist/esheet.js.map +1 -1
- package/dist/hooks/index.cjs +33 -16
- package/dist/hooks/index.d.cts +62 -1
- package/dist/hooks/index.d.ts +62 -1
- package/dist/hooks/index.js +3 -2
- package/dist/index.cjs +3937 -952
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +981 -2
- package/dist/index.d.ts +981 -2
- package/dist/index.js +3316 -455
- package/dist/index.js.map +1 -1
- package/dist/kerebron.cjs +15 -0
- package/dist/kerebron.cjs.map +1 -1
- package/dist/kerebron.js +15 -0
- package/dist/kerebron.js.map +1 -1
- package/dist/{nitroTableGrid-J7F6D2QA.cjs → nitroTableGrid-3J2GY6CK.cjs} +14 -11
- package/dist/nitroTableGrid-3J2GY6CK.cjs.map +1 -0
- package/dist/nitroTableGrid-SIMT7635.js +25 -0
- package/dist/nitroTableGrid-SIMT7635.js.map +1 -0
- package/dist/orderRows-BUJYgSc7.d.cts +221 -0
- package/dist/orderRows-BUJYgSc7.d.ts +221 -0
- package/dist/styles.css +1 -1
- package/dist/tailwind-preset.cjs +4 -4
- package/dist/tailwind-preset.js +1 -1
- package/package.json +4 -4
- package/dist/chunk-2T4JU5RH.cjs.map +0 -1
- package/dist/chunk-3SSXDWD7.js.map +0 -1
- package/dist/chunk-7PA26KBF.cjs.map +0 -1
- package/dist/chunk-LEMY57MI.js +0 -3
- package/dist/chunk-LZPPH5BW.cjs.map +0 -1
- package/dist/chunk-RXY5SD3O.js.map +0 -1
- package/dist/chunk-UHPQYBXQ.js.map +0 -1
- package/dist/nitroTableGrid-GKJAX3J4.js +0 -22
- package/dist/nitroTableGrid-GKJAX3J4.js.map +0 -1
- package/dist/nitroTableGrid-J7F6D2QA.cjs.map +0 -1
package/dist/kerebron.cjs
CHANGED
|
@@ -67,6 +67,21 @@ var CodeEditor = ({
|
|
|
67
67
|
const editorInstance = react.useRef(null);
|
|
68
68
|
const onChangeRef = react.useRef(onChange);
|
|
69
69
|
onChangeRef.current = onChange;
|
|
70
|
+
react.useEffect(() => {
|
|
71
|
+
const root = editorRef.current;
|
|
72
|
+
if (!root) return;
|
|
73
|
+
const applySelectLabel = () => {
|
|
74
|
+
root.querySelectorAll("select.codejar-select").forEach((element) => {
|
|
75
|
+
if (!element.getAttribute("aria-label")) {
|
|
76
|
+
element.setAttribute("aria-label", "Code editor language");
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
applySelectLabel();
|
|
81
|
+
const observer = new MutationObserver(() => applySelectLabel());
|
|
82
|
+
observer.observe(root, { childList: true, subtree: true });
|
|
83
|
+
return () => observer.disconnect();
|
|
84
|
+
}, []);
|
|
70
85
|
react.useEffect(() => {
|
|
71
86
|
if (!editorRef.current) return;
|
|
72
87
|
const editor$1 = editor.CoreEditor.create({
|
package/dist/kerebron.cjs.map
CHANGED
|
@@ -1 +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,E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C,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"]}
|
|
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,SAAA,CAAU,OAAA;AAAA,MACnB,GAAA,EAAK,qBAAA;AAAA,MACL,SAAA,EAAWC,oBAAgB,gBAAgB,CAAA;AAAA,MAC3C,UAAA,EAAY,CAAC,IAAIC,mCAAA,EAAmB;AAAA,KACrC,CAAA;AAED,IAAA,cAAA,CAAe,OAAA,GAAUH,QAAA;AAGzB,IAAA,MAAM,gBAAgB,YAAY;AAChC,MAAA,IAAI,CAAC,eAAe,OAAA,EAAS;AAE7B,MAAA,IAAI;AACF,QAAA,MAAM,MAAA,GACJ,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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 const root = editorRef.current;\n if (!root) return;\n\n const applySelectLabel = () => {\n root.querySelectorAll('select.codejar-select').forEach((element) => {\n if (!element.getAttribute('aria-label')) {\n element.setAttribute('aria-label', 'Code editor language');\n }\n });\n };\n\n applySelectLabel();\n const observer = new MutationObserver(() => applySelectLabel());\n observer.observe(root, { childList: true, subtree: true });\n return () => observer.disconnect();\n }, []);\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/kerebron.js
CHANGED
|
@@ -65,6 +65,21 @@ var CodeEditor = ({
|
|
|
65
65
|
const editorInstance = useRef(null);
|
|
66
66
|
const onChangeRef = useRef(onChange);
|
|
67
67
|
onChangeRef.current = onChange;
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
const root = editorRef.current;
|
|
70
|
+
if (!root) return;
|
|
71
|
+
const applySelectLabel = () => {
|
|
72
|
+
root.querySelectorAll("select.codejar-select").forEach((element) => {
|
|
73
|
+
if (!element.getAttribute("aria-label")) {
|
|
74
|
+
element.setAttribute("aria-label", "Code editor language");
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
applySelectLabel();
|
|
79
|
+
const observer = new MutationObserver(() => applySelectLabel());
|
|
80
|
+
observer.observe(root, { childList: true, subtree: true });
|
|
81
|
+
return () => observer.disconnect();
|
|
82
|
+
}, []);
|
|
68
83
|
useEffect(() => {
|
|
69
84
|
if (!editorRef.current) return;
|
|
70
85
|
const editor = CoreEditor.create({
|
package/dist/kerebron.js.map
CHANGED
|
@@ -1 +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,GA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AAA,EAAA,EACC,QAAA,kBAAAA,GAAAA,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.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"]}
|
|
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,EAAA,MAAM,cAAA,GAAiB,OAA0B,IAAI,CAAA;AACrD,EAAA,MAAM,WAAA,GAAc,OAAO,QAAQ,CAAA;AACnC,EAAA,WAAA,CAAY,OAAA,GAAU,QAAA;AAEtB,EAAA,MAAM,CAAC,EAAA,EAAI,KAAK,CAAA,GAAI,SAAiB,EAAE,CAAA;AAEvC,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,CAAC,UAAU,OAAA,EAAS;AAGxB,IAAA,MAAM,MAAA,GAAS,WAAW,MAAA,CAAO;AAAA,MAC/B,SAAS,SAAA,CAAU,OAAA;AAAA,MACnB,GAAA,EAAK,qBAAA;AAAA,MACL,SAAA,EAAW,gBAAgB,gBAAgB,CAAA;AAAA,MAC3C,UAAA,EAAY,CAAC,IAAI,iBAAA,EAAmB;AAAA,KACrC,CAAA;AAED,IAAA,cAAA,CAAe,OAAA,GAAU,MAAA;AAGzB,IAAA,MAAM,gBAAgB,YAAY;AAChC,MAAA,IAAI,CAAC,eAAe,OAAA,EAAS;AAE7B,MAAA,IAAI;AACF,QAAA,MAAM,MAAA,GACJ,MAAM,cAAA,C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AAA,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 const root = editorRef.current;\n if (!root) return;\n\n const applySelectLabel = () => {\n root.querySelectorAll('select.codejar-select').forEach((element) => {\n if (!element.getAttribute('aria-label')) {\n element.setAttribute('aria-label', 'Code editor language');\n }\n });\n };\n\n applySelectLabel();\n const observer = new MutationObserver(() => applySelectLabel());\n observer.observe(root, { childList: true, subtree: true });\n return () => observer.disconnect();\n }, []);\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"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkVJOVJTFP_cjs = require('./chunk-VJOVJTFP.cjs');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
|
|
@@ -25,20 +25,23 @@ function _interopNamespace(e) {
|
|
|
25
25
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
26
26
|
|
|
27
27
|
function NitroTableGrid({ headers, rows }) {
|
|
28
|
-
const
|
|
29
|
-
const
|
|
28
|
+
const varName = React__namespace.useMemo(() => {
|
|
29
|
+
const nextVarName = `__superchat_nitro_table_${Math.random().toString(36).slice(2)}`;
|
|
30
|
+
window[nextVarName] = {
|
|
30
31
|
typeInfo: headers.map((field) => ({ field, type: "string" })),
|
|
31
32
|
data: rows
|
|
32
33
|
};
|
|
33
|
-
|
|
34
|
-
type: "application/json"
|
|
35
|
-
});
|
|
36
|
-
return URL.createObjectURL(blob);
|
|
34
|
+
return nextVarName;
|
|
37
35
|
}, [headers, rows]);
|
|
38
|
-
React__namespace.useEffect(
|
|
39
|
-
|
|
36
|
+
React__namespace.useEffect(
|
|
37
|
+
() => () => {
|
|
38
|
+
delete window[varName];
|
|
39
|
+
},
|
|
40
|
+
[varName]
|
|
41
|
+
);
|
|
42
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-slot": "superchat-nitro-table", className: "my-2", children: /* @__PURE__ */ jsxRuntime.jsx(chunkVJOVJTFP_cjs.DataVisNitroSource, { type: "local", varName, children: /* @__PURE__ */ jsxRuntime.jsx(chunkVJOVJTFP_cjs.DataVisNitroGrid, { columns: headers, className: "max-h-80" }) }) });
|
|
40
43
|
}
|
|
41
44
|
|
|
42
45
|
module.exports = NitroTableGrid;
|
|
43
|
-
//# sourceMappingURL=nitroTableGrid-
|
|
44
|
-
//# sourceMappingURL=nitroTableGrid-
|
|
46
|
+
//# sourceMappingURL=nitroTableGrid-3J2GY6CK.cjs.map
|
|
47
|
+
//# sourceMappingURL=nitroTableGrid-3J2GY6CK.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/SuperChat/plugins/nitroTableGrid.tsx"],"names":["React","DataVisNitroSource","DataVisNitroGrid"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAqBe,SAAR,cAAA,CAAgC,EAAE,OAAA,EAAS,IAAA,EAAK,EAAwB;AAC7E,EAAA,MAAM,OAAA,GAAgBA,yBAAQ,MAAM;AAClC,IAAA,MAAM,WAAA,GAAc,CAAA,wBAAA,EAA2B,IAAA,CAAK,MAAA,EAAO,CAAE,SAAS,EAAE,CAAA,CAAE,KAAA,CAAM,CAAC,CAAC,CAAA,CAAA;AAClF,IAAC,MAAA,CAA8C,WAAW,CAAA,GAAI;AAAA,MAC5D,QAAA,EAAU,QAAQ,GAAA,CAAI,CAAC,WAAW,EAAE,KAAA,EAAO,IAAA,EAAM,QAAA,EAAS,CAAE,CAAA;AAAA,MAC5D,IAAA,EAAM;AAAA,KACR;AACA,IAAA,OAAO,WAAA;AAAA,EACT,CAAA,EAAG,CAAC,OAAA,EAAS,IAAI,CAAC,CAAA;AAElB,EAAMA,gBAAA,CAAA,SAAA;AAAA,IACJ,MAAM,MAAM;AACV,MAAA,OAAQ,OAA8C,OAAO,CAAA;AAAA,IAC/D,CAAA;AAAA,IACA,CAAC,OAAO;AAAA,GACV;AAEA,EAAA,sCACG,KAAA,EAAA,EAAI,WAAA,EAAU,yBAAwB,SAAA,EAAU,MAAA,EAC/C,yCAACC,oCAAA,EAAA,EAAmB,IAAA,EAAK,OAAA,EAAQ,OAAA,EAC/B,yCAACC,kCAAA,EAAA,EAAiB,OAAA,EAAS,SAAS,SAAA,EAAU,UAAA,EAAW,GAC3D,CAAA,EACF,CAAA;AAEJ","file":"nitroTableGrid-3J2GY6CK.cjs","sourcesContent":["/**\n * SuperChat NITRO table grid (lazy chunk).\n *\n * Default-exported so it can be pulled in with `React.lazy` only when a GFM\n * table actually renders — this keeps the heavy `datavis` / `datavis-ace`\n * dependencies out of the SuperChat (and Markdown core) bundle.\n *\n * Data is handed to {@link DataVisNitroSource} through a short-lived local\n * source so Storybook never pauses in the intermediate \"Waiting…\" state.\n */\n\nimport * as React from 'react';\nimport { DataVisNitroGrid, DataVisNitroSource } from '../../DataVisNITRO';\n\nexport interface NitroTableGridProps {\n /** Column headers, in order. */\n headers: string[];\n /** Row objects keyed by header. */\n rows: Array<Record<string, string>>;\n}\n\nexport default function NitroTableGrid({ headers, rows }: NitroTableGridProps) {\n const varName = React.useMemo(() => {\n const nextVarName = `__superchat_nitro_table_${Math.random().toString(36).slice(2)}`;\n (window as unknown as Record<string, unknown>)[nextVarName] = {\n typeInfo: headers.map((field) => ({ field, type: 'string' })),\n data: rows,\n };\n return nextVarName;\n }, [headers, rows]);\n\n React.useEffect(\n () => () => {\n delete (window as unknown as Record<string, unknown>)[varName];\n },\n [varName]\n );\n\n return (\n <div data-slot=\"superchat-nitro-table\" className=\"my-2\">\n <DataVisNitroSource type=\"local\" varName={varName}>\n <DataVisNitroGrid columns={headers} className=\"max-h-80\" />\n </DataVisNitroSource>\n </div>\n );\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { DataVisNitroSource, DataVisNitroGrid } from './chunk-YBLIDESO.js';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
function NitroTableGrid({ headers, rows }) {
|
|
6
|
+
const varName = React.useMemo(() => {
|
|
7
|
+
const nextVarName = `__superchat_nitro_table_${Math.random().toString(36).slice(2)}`;
|
|
8
|
+
window[nextVarName] = {
|
|
9
|
+
typeInfo: headers.map((field) => ({ field, type: "string" })),
|
|
10
|
+
data: rows
|
|
11
|
+
};
|
|
12
|
+
return nextVarName;
|
|
13
|
+
}, [headers, rows]);
|
|
14
|
+
React.useEffect(
|
|
15
|
+
() => () => {
|
|
16
|
+
delete window[varName];
|
|
17
|
+
},
|
|
18
|
+
[varName]
|
|
19
|
+
);
|
|
20
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "superchat-nitro-table", className: "my-2", children: /* @__PURE__ */ jsx(DataVisNitroSource, { type: "local", varName, children: /* @__PURE__ */ jsx(DataVisNitroGrid, { columns: headers, className: "max-h-80" }) }) });
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { NitroTableGrid as default };
|
|
24
|
+
//# sourceMappingURL=nitroTableGrid-SIMT7635.js.map
|
|
25
|
+
//# sourceMappingURL=nitroTableGrid-SIMT7635.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/SuperChat/plugins/nitroTableGrid.tsx"],"names":[],"mappings":";;;;AAqBe,SAAR,cAAA,CAAgC,EAAE,OAAA,EAAS,IAAA,EAAK,EAAwB;AAC7E,EAAA,MAAM,OAAA,GAAgB,cAAQ,MAAM;AAClC,IAAA,MAAM,WAAA,GAAc,CAAA,wBAAA,EAA2B,IAAA,CAAK,MAAA,EAAO,CAAE,SAAS,EAAE,CAAA,CAAE,KAAA,CAAM,CAAC,CAAC,CAAA,CAAA;AAClF,IAAC,MAAA,CAA8C,WAAW,CAAA,GAAI;AAAA,MAC5D,QAAA,EAAU,QAAQ,GAAA,CAAI,CAAC,WAAW,EAAE,KAAA,EAAO,IAAA,EAAM,QAAA,EAAS,CAAE,CAAA;AAAA,MAC5D,IAAA,EAAM;AAAA,KACR;AACA,IAAA,OAAO,WAAA;AAAA,EACT,CAAA,EAAG,CAAC,OAAA,EAAS,IAAI,CAAC,CAAA;AAElB,EAAM,KAAA,CAAA,SAAA;AAAA,IACJ,MAAM,MAAM;AACV,MAAA,OAAQ,OAA8C,OAAO,CAAA;AAAA,IAC/D,CAAA;AAAA,IACA,CAAC,OAAO;AAAA,GACV;AAEA,EAAA,2BACG,KAAA,EAAA,EAAI,WAAA,EAAU,yBAAwB,SAAA,EAAU,MAAA,EAC/C,8BAAC,kBAAA,EAAA,EAAmB,IAAA,EAAK,OAAA,EAAQ,OAAA,EAC/B,8BAAC,gBAAA,EAAA,EAAiB,OAAA,EAAS,SAAS,SAAA,EAAU,UAAA,EAAW,GAC3D,CAAA,EACF,CAAA;AAEJ","file":"nitroTableGrid-SIMT7635.js","sourcesContent":["/**\n * SuperChat NITRO table grid (lazy chunk).\n *\n * Default-exported so it can be pulled in with `React.lazy` only when a GFM\n * table actually renders — this keeps the heavy `datavis` / `datavis-ace`\n * dependencies out of the SuperChat (and Markdown core) bundle.\n *\n * Data is handed to {@link DataVisNitroSource} through a short-lived local\n * source so Storybook never pauses in the intermediate \"Waiting…\" state.\n */\n\nimport * as React from 'react';\nimport { DataVisNitroGrid, DataVisNitroSource } from '../../DataVisNITRO';\n\nexport interface NitroTableGridProps {\n /** Column headers, in order. */\n headers: string[];\n /** Row objects keyed by header. */\n rows: Array<Record<string, string>>;\n}\n\nexport default function NitroTableGrid({ headers, rows }: NitroTableGridProps) {\n const varName = React.useMemo(() => {\n const nextVarName = `__superchat_nitro_table_${Math.random().toString(36).slice(2)}`;\n (window as unknown as Record<string, unknown>)[nextVarName] = {\n typeInfo: headers.map((field) => ({ field, type: 'string' })),\n data: rows,\n };\n return nextVarName;\n }, [headers, rows]);\n\n React.useEffect(\n () => () => {\n delete (window as unknown as Record<string, unknown>)[varName];\n },\n [varName]\n );\n\n return (\n <div data-slot=\"superchat-nitro-table\" className=\"my-2\">\n <DataVisNitroSource type=\"local\" varName={varName}>\n <DataVisNitroGrid columns={headers} className=\"max-h-80\" />\n </DataVisNitroSource>\n </div>\n );\n}\n"]}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Patient history — the minimal longitudinal facts the health-surveillance
|
|
3
|
+
* due engine needs: who the patient is (age, sex) and what has been done or
|
|
4
|
+
* is in flight (orders with status, observations, procedures, immunizations),
|
|
5
|
+
* plus problem-list context (conditions) and allergies for display/interop.
|
|
6
|
+
*
|
|
7
|
+
* All clinical entries are keyed by `CODETYPE|FULLCODE` — the same keys used
|
|
8
|
+
* by programs.json order sets and the codify shards — so the due engine can
|
|
9
|
+
* match history against a program's satisfying orders with plain string
|
|
10
|
+
* equality.
|
|
11
|
+
*/
|
|
12
|
+
/** ISO date string (YYYY-MM-DD or full ISO timestamp). */
|
|
13
|
+
type IsoDate = string;
|
|
14
|
+
interface HistoryOrder {
|
|
15
|
+
/** CODETYPE|FULLCODE, e.g. "Quest Order|3058" or "HCPCS|92551" */
|
|
16
|
+
key: string;
|
|
17
|
+
/** Display label (optional; the due list falls back to the key) */
|
|
18
|
+
label?: string;
|
|
19
|
+
status: 'completed' | 'pending';
|
|
20
|
+
/** Completion date for completed orders; order date for pending ones */
|
|
21
|
+
date: IsoDate;
|
|
22
|
+
/** Ordering/performing provider display name (e.g. "Dr. Patel") */
|
|
23
|
+
provider?: string;
|
|
24
|
+
/** Requisition the order was bundled into — the document routing a batch
|
|
25
|
+
* of encounter orders to a provider/referral (e.g. "REQ-2024-0117") */
|
|
26
|
+
requisitionId?: string;
|
|
27
|
+
/** Encounter (visit) the order was placed in (e.g. "ENC-2024-0117") */
|
|
28
|
+
encounterId?: string;
|
|
29
|
+
}
|
|
30
|
+
interface HistoryObservation {
|
|
31
|
+
/** CODETYPE|FULLCODE, e.g. "LOINC|4548-4" (HbA1c) */
|
|
32
|
+
key: string;
|
|
33
|
+
label?: string;
|
|
34
|
+
/** Display value with units, e.g. "7.2 %" or "38 ug/dL" */
|
|
35
|
+
value?: string;
|
|
36
|
+
date: IsoDate;
|
|
37
|
+
}
|
|
38
|
+
interface HistoryProcedure {
|
|
39
|
+
key: string;
|
|
40
|
+
label?: string;
|
|
41
|
+
date: IsoDate;
|
|
42
|
+
}
|
|
43
|
+
interface HistoryImmunization {
|
|
44
|
+
/** CODETYPE|FULLCODE, e.g. "CVX|88" */
|
|
45
|
+
key: string;
|
|
46
|
+
label?: string;
|
|
47
|
+
date: IsoDate;
|
|
48
|
+
}
|
|
49
|
+
interface HistoryCondition {
|
|
50
|
+
key: string;
|
|
51
|
+
label?: string;
|
|
52
|
+
onset?: IsoDate;
|
|
53
|
+
}
|
|
54
|
+
interface HistoryAllergy {
|
|
55
|
+
/** Allergen key when coded (e.g. "RxNORM|7980"), else omit */
|
|
56
|
+
key?: string;
|
|
57
|
+
label: string;
|
|
58
|
+
reaction?: string;
|
|
59
|
+
severity?: 'mild' | 'moderate' | 'severe';
|
|
60
|
+
}
|
|
61
|
+
interface HistoryMedication {
|
|
62
|
+
key?: string;
|
|
63
|
+
label: string;
|
|
64
|
+
/** Sig / dose display, e.g. "10 mg daily" */
|
|
65
|
+
detail?: string;
|
|
66
|
+
}
|
|
67
|
+
interface PatientHistory {
|
|
68
|
+
/** Age in years */
|
|
69
|
+
age: number;
|
|
70
|
+
sex: 'M' | 'F';
|
|
71
|
+
/** Past + in-flight orders (completion drives the due engine) */
|
|
72
|
+
orders: HistoryOrder[];
|
|
73
|
+
observations?: HistoryObservation[];
|
|
74
|
+
procedures?: HistoryProcedure[];
|
|
75
|
+
immunizations?: HistoryImmunization[];
|
|
76
|
+
conditions?: HistoryCondition[];
|
|
77
|
+
allergies?: HistoryAllergy[];
|
|
78
|
+
medications?: HistoryMedication[];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Due-evaluation engine — the "knowledge" layer of health surveillance.
|
|
83
|
+
* Given a patient's history and the program metadata (programs.json from
|
|
84
|
+
* mieweb/codify, or a deployment's own), decides which programs/measures are
|
|
85
|
+
* due, overdue, pending, or satisfied. Pure functions, no I/O — the metadata
|
|
86
|
+
* is small, so this runs on the main thread.
|
|
87
|
+
*/
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* One entry in a program's order set:
|
|
91
|
+
* - `"CODETYPE|FULLCODE"` — a plain required order
|
|
92
|
+
* - `{ alt: [a, b] }` — mutually exclusive alternatives (one-of): a
|
|
93
|
+
* colonoscopy OR a FIT satisfies colorectal screening
|
|
94
|
+
* - `{ key, after: […] }` — depends on completed prerequisites (Gantt edge):
|
|
95
|
+
* the RMO's fitness-for-duty determination needs the panel results first,
|
|
96
|
+
* and a program may carry several determinations (per panel / per SEG)
|
|
97
|
+
*/
|
|
98
|
+
type ProgramOrder = string | {
|
|
99
|
+
key?: string;
|
|
100
|
+
alt?: string[];
|
|
101
|
+
after?: string[];
|
|
102
|
+
};
|
|
103
|
+
/** Program metadata — mirrors programs.json (see mieweb/codify). */
|
|
104
|
+
interface ProgramMeta {
|
|
105
|
+
kind?: 'surveillance' | 'fitness' | 'credential' | 'quality';
|
|
106
|
+
/** Omitted = one-time / event-driven (satisfied forever once done) */
|
|
107
|
+
periodicityMonths?: number;
|
|
108
|
+
ageMin?: number;
|
|
109
|
+
ageMax?: number;
|
|
110
|
+
sex?: 'M' | 'F';
|
|
111
|
+
/** Satisfying orders — plain keys, one-of alternatives, or dependent
|
|
112
|
+
* entries (see ProgramOrder) */
|
|
113
|
+
orders?: ProgramOrder[];
|
|
114
|
+
}
|
|
115
|
+
type ProgramsMap = Record<string, ProgramMeta>;
|
|
116
|
+
type DueStatus = 'due' | 'overdue' | 'pending' | 'satisfied' | 'not-applicable';
|
|
117
|
+
interface DueItem {
|
|
118
|
+
/** Program key, CODETYPE|FULLCODE (e.g. "OSHA|1910.95", "eCQM|CMS125") */
|
|
119
|
+
key: string;
|
|
120
|
+
program: ProgramMeta;
|
|
121
|
+
status: DueStatus;
|
|
122
|
+
/** Most recent completion date of any satisfying order */
|
|
123
|
+
lastCompleted?: string;
|
|
124
|
+
/** When the current/last satisfaction lapses (satisfied/overdue only) */
|
|
125
|
+
dueDate?: string;
|
|
126
|
+
/** Satisfying orders currently pending */
|
|
127
|
+
pendingKeys: string[];
|
|
128
|
+
}
|
|
129
|
+
/** Is the patient inside the program's age/sex gates? */
|
|
130
|
+
declare function isApplicable(history: Pick<PatientHistory, 'age' | 'sex'>, program: ProgramMeta): boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Evaluate one program against the history.
|
|
133
|
+
* `now` defaults to today; injectable for tests.
|
|
134
|
+
*/
|
|
135
|
+
declare function evaluateProgram(key: string, program: ProgramMeta, history: PatientHistory, now?: Date): DueItem;
|
|
136
|
+
/**
|
|
137
|
+
* Evaluate a set of programs against the history, most actionable first
|
|
138
|
+
* (overdue → due → pending → satisfied; not-applicable omitted unless
|
|
139
|
+
* `includeNotApplicable`).
|
|
140
|
+
*
|
|
141
|
+
* `enrolledKeys` restricts occupational programs to the patient's actual
|
|
142
|
+
* enrollments (a clerk isn't due for cadmium surveillance just because the
|
|
143
|
+
* program exists); quality measures apply to everyone passing their gates.
|
|
144
|
+
*/
|
|
145
|
+
declare function evaluateDue(history: PatientHistory, programs: ProgramsMap, options?: {
|
|
146
|
+
enrolledKeys?: string[];
|
|
147
|
+
includeNotApplicable?: boolean;
|
|
148
|
+
now?: Date;
|
|
149
|
+
}): DueItem[];
|
|
150
|
+
/**
|
|
151
|
+
* Ordering-time prompt: is this order key part of a due/overdue program?
|
|
152
|
+
* Returns the matching due items so the UI can badge "due for OSHA 1910.95"
|
|
153
|
+
* or warn "already satisfied" while the clinician is ordering.
|
|
154
|
+
*/
|
|
155
|
+
declare function dueForOrder(orderKey: string, dueItems: DueItem[]): DueItem[];
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Order-row builders — flatten the order history and the due-evaluation
|
|
159
|
+
* output into grid-friendly rows (one row per encounter order) for the
|
|
160
|
+
* NITRO-backed ChartOrdersGrid / EncounterOrdersGrid.
|
|
161
|
+
*
|
|
162
|
+
* Pure functions, no I/O. Every field is a flat string so the DataVis engine
|
|
163
|
+
* can group/filter/aggregate on any of them (reason, provider, requisition,
|
|
164
|
+
* status, kind, date).
|
|
165
|
+
*/
|
|
166
|
+
|
|
167
|
+
/** Per-order status — finer grained than the program-level DueStatus. */
|
|
168
|
+
type OrderRowStatus = 'completed' | 'pending' | 'available' | 'blocked';
|
|
169
|
+
/** One encounter order as a flat grid row. */
|
|
170
|
+
interface OrderRow {
|
|
171
|
+
/** CODETYPE|FULLCODE of the order */
|
|
172
|
+
orderKey: string;
|
|
173
|
+
/** Order display label */
|
|
174
|
+
order: string;
|
|
175
|
+
/** Reason/concern — the surveillance program or quality measure label */
|
|
176
|
+
reason: string;
|
|
177
|
+
/** Program key (CODETYPE|FULLCODE); '' when no program matches */
|
|
178
|
+
reasonKey: string;
|
|
179
|
+
/** Program kind label ('surveillance', 'quality measure', …) */
|
|
180
|
+
kind: string;
|
|
181
|
+
status: OrderRowStatus;
|
|
182
|
+
/** Completion date (completed) or order date (pending); '' otherwise */
|
|
183
|
+
date: string;
|
|
184
|
+
/** Program due date, when known */
|
|
185
|
+
dueDate: string;
|
|
186
|
+
/** Ordering/performing provider; '' when unknown */
|
|
187
|
+
provider: string;
|
|
188
|
+
/** Requisition the order is bundled into; '' = unprocessed */
|
|
189
|
+
requisitionId: string;
|
|
190
|
+
/** Encounter the order was placed in; '' for not-yet-placed rows */
|
|
191
|
+
encounterId: string;
|
|
192
|
+
/** Unmet prerequisite labels, comma-joined ('' when unblocked) */
|
|
193
|
+
blockedBy: string;
|
|
194
|
+
}
|
|
195
|
+
interface OrderRowsOptions {
|
|
196
|
+
/** Occupational enrollments; quality measures apply to everyone in-gate */
|
|
197
|
+
enrolledKeys?: string[];
|
|
198
|
+
/** Evaluation clock (defaults to today; inject for determinism) */
|
|
199
|
+
now?: Date;
|
|
200
|
+
/** Display labels for program keys (falls back to the key) */
|
|
201
|
+
programLabels?: Record<string, string>;
|
|
202
|
+
/** Display labels for order keys (falls back to history labels, then key) */
|
|
203
|
+
orderLabels?: Record<string, string>;
|
|
204
|
+
/** Include not-yet-placed due-list orders as available/blocked rows
|
|
205
|
+
* (default true) */
|
|
206
|
+
includeDue?: boolean;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Chart-wide rows: every past + in-flight order in the history, plus (by
|
|
210
|
+
* default) the actionable due-list orders that haven't been placed yet
|
|
211
|
+
* (`available`, or `blocked` while prerequisites are incomplete).
|
|
212
|
+
*/
|
|
213
|
+
declare function buildChartOrderRows(history: PatientHistory, programs: ProgramsMap, options?: OrderRowsOptions): OrderRow[];
|
|
214
|
+
/**
|
|
215
|
+
* Current-encounter rows: the encounter's own orders (pending unprocessed
|
|
216
|
+
* ones are the mass-operation targets) plus the actionable due-list orders
|
|
217
|
+
* available to place this visit.
|
|
218
|
+
*/
|
|
219
|
+
declare function buildEncounterOrderRows(history: PatientHistory, programs: ProgramsMap, encounterId: string, options?: OrderRowsOptions): OrderRow[];
|
|
220
|
+
|
|
221
|
+
export { type DueItem as D, type HistoryAllergy as H, type IsoDate as I, type OrderRow as O, type PatientHistory as P, type ProgramsMap as a, type DueStatus as b, type HistoryCondition as c, type HistoryImmunization as d, type HistoryMedication as e, type HistoryObservation as f, type HistoryOrder as g, type HistoryProcedure as h, type OrderRowStatus as i, type OrderRowsOptions as j, type ProgramMeta as k, buildChartOrderRows as l, buildEncounterOrderRows as m, dueForOrder as n, evaluateDue as o, evaluateProgram as p, isApplicable as q };
|