@mieweb/ui 0.11.0-dev.47 → 0.11.0-dev.48

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.
Files changed (46) hide show
  1. package/agent/skills/mieweb-ui-tailwind4/SKILL.md +1 -0
  2. package/dist/{EncounterMdyEditor-XA7HLLVD.cjs → EncounterMdyEditor-KW52MD2Q.cjs} +6 -6
  3. package/dist/{EncounterMdyEditor-XA7HLLVD.cjs.map → EncounterMdyEditor-KW52MD2Q.cjs.map} +1 -1
  4. package/dist/{EncounterMdyEditor-ATNWXQ72.js → EncounterMdyEditor-OYO3H5GJ.js} +3 -3
  5. package/dist/{EncounterMdyEditor-ATNWXQ72.js.map → EncounterMdyEditor-OYO3H5GJ.js.map} +1 -1
  6. package/dist/{chunk-F6ZTKNAL.cjs → chunk-3XR7BPKD.cjs} +4 -4
  7. package/dist/{chunk-F6ZTKNAL.cjs.map → chunk-3XR7BPKD.cjs.map} +1 -1
  8. package/dist/{chunk-ULKDK6W6.js → chunk-3XVDSLDT.js} +4 -4
  9. package/dist/chunk-3XVDSLDT.js.map +1 -0
  10. package/dist/{chunk-WI35L5TR.js → chunk-DHCSY2JY.js} +3 -3
  11. package/dist/{chunk-WI35L5TR.js.map → chunk-DHCSY2JY.js.map} +1 -1
  12. package/dist/{chunk-IYXZ25E6.js → chunk-ETAYMSCW.js} +4 -4
  13. package/dist/{chunk-IYXZ25E6.js.map → chunk-ETAYMSCW.js.map} +1 -1
  14. package/dist/{chunk-LE3HZ7MM.cjs → chunk-LVUSCBG4.cjs} +11 -11
  15. package/dist/{chunk-LE3HZ7MM.cjs.map → chunk-LVUSCBG4.cjs.map} +1 -1
  16. package/dist/{chunk-BUM72SAI.cjs → chunk-LWAXTZGG.cjs} +7 -7
  17. package/dist/{chunk-BUM72SAI.cjs.map → chunk-LWAXTZGG.cjs.map} +1 -1
  18. package/dist/{chunk-QJ75ZMCG.js → chunk-R4DQRXZY.js} +3 -3
  19. package/dist/{chunk-QJ75ZMCG.js.map → chunk-R4DQRXZY.js.map} +1 -1
  20. package/dist/{chunk-5O54NWAL.cjs → chunk-TA5K5546.cjs} +4 -4
  21. package/dist/chunk-TA5K5546.cjs.map +1 -0
  22. package/dist/{chunk-2D6TFO2Y.js → chunk-XJ37SWVD.js} +3 -3
  23. package/dist/{chunk-2D6TFO2Y.js.map → chunk-XJ37SWVD.js.map} +1 -1
  24. package/dist/{chunk-6I2G26AX.cjs → chunk-YKL66TCM.cjs} +4 -4
  25. package/dist/{chunk-6I2G26AX.cjs.map → chunk-YKL66TCM.cjs.map} +1 -1
  26. package/dist/collabKit-652AGQW6.js +99 -0
  27. package/dist/collabKit-652AGQW6.js.map +1 -0
  28. package/dist/collabKit-DVSTUBN4.cjs +102 -0
  29. package/dist/collabKit-DVSTUBN4.cjs.map +1 -0
  30. package/dist/components/EmailEditor/index.cjs +13 -13
  31. package/dist/components/EmailEditor/index.js +4 -4
  32. package/dist/components/Textarea/index.cjs +6 -6
  33. package/dist/components/Textarea/index.js +3 -3
  34. package/dist/esheet.cjs +18 -18
  35. package/dist/esheet.js +5 -5
  36. package/dist/index.cjs +53 -53
  37. package/dist/index.js +7 -7
  38. package/dist/kerebron.cjs +5 -5
  39. package/dist/kerebron.js +2 -2
  40. package/package.json +1 -1
  41. package/dist/chunk-5O54NWAL.cjs.map +0 -1
  42. package/dist/chunk-ULKDK6W6.js.map +0 -1
  43. package/dist/collabKit-GCRHP25F.cjs +0 -76
  44. package/dist/collabKit-GCRHP25F.cjs.map +0 -1
  45. package/dist/collabKit-SJPDPXU4.js +0 -52
  46. package/dist/collabKit-SJPDPXU4.js.map +0 -1
package/dist/index.cjs CHANGED
@@ -82,7 +82,7 @@ var chunkNGSDBWKA_cjs = require('./chunk-NGSDBWKA.cjs');
82
82
  var chunk56C7K4MV_cjs = require('./chunk-56C7K4MV.cjs');
83
83
  var chunkS6457ZNC_cjs = require('./chunk-S6457ZNC.cjs');
84
84
  var chunkRS5VA6QU_cjs = require('./chunk-RS5VA6QU.cjs');
85
- var chunkBUM72SAI_cjs = require('./chunk-BUM72SAI.cjs');
85
+ var chunkLWAXTZGG_cjs = require('./chunk-LWAXTZGG.cjs');
86
86
  require('./chunk-BXRQ6HEP.cjs');
87
87
  var chunk7K6SW4VB_cjs = require('./chunk-7K6SW4VB.cjs');
88
88
  var chunkPLMXN23Q_cjs = require('./chunk-PLMXN23Q.cjs');
@@ -124,14 +124,14 @@ var chunkGKDHMNUA_cjs = require('./chunk-GKDHMNUA.cjs');
124
124
  var chunk4NCDU5IG_cjs = require('./chunk-4NCDU5IG.cjs');
125
125
  var chunkXXVUHLQN_cjs = require('./chunk-XXVUHLQN.cjs');
126
126
  var chunkRI56YPED_cjs = require('./chunk-RI56YPED.cjs');
127
- var chunkLE3HZ7MM_cjs = require('./chunk-LE3HZ7MM.cjs');
127
+ var chunkLVUSCBG4_cjs = require('./chunk-LVUSCBG4.cjs');
128
128
  var chunkXM3D4KAF_cjs = require('./chunk-XM3D4KAF.cjs');
129
129
  var chunk3SEQVGLH_cjs = require('./chunk-3SEQVGLH.cjs');
130
130
  var chunkSV6YGK4U_cjs = require('./chunk-SV6YGK4U.cjs');
131
131
  var chunkG7EQ3JPX_cjs = require('./chunk-G7EQ3JPX.cjs');
132
132
  var chunkAIJAFPGJ_cjs = require('./chunk-AIJAFPGJ.cjs');
133
133
  var chunkMXIIPFTA_cjs = require('./chunk-MXIIPFTA.cjs');
134
- var chunkF6ZTKNAL_cjs = require('./chunk-F6ZTKNAL.cjs');
134
+ var chunk3XR7BPKD_cjs = require('./chunk-3XR7BPKD.cjs');
135
135
  var chunkUPWIJC6I_cjs = require('./chunk-UPWIJC6I.cjs');
136
136
  var chunkMJWFNV3L_cjs = require('./chunk-MJWFNV3L.cjs');
137
137
  var chunk7AECNMYV_cjs = require('./chunk-7AECNMYV.cjs');
@@ -142,8 +142,8 @@ var chunkNNEFAUHV_cjs = require('./chunk-NNEFAUHV.cjs');
142
142
  var chunkCW75IKA6_cjs = require('./chunk-CW75IKA6.cjs');
143
143
  var chunkSCV7C55E_cjs = require('./chunk-SCV7C55E.cjs');
144
144
  var chunk7E46YDOT_cjs = require('./chunk-7E46YDOT.cjs');
145
- require('./chunk-6I2G26AX.cjs');
146
- require('./chunk-5O54NWAL.cjs');
145
+ require('./chunk-YKL66TCM.cjs');
146
+ require('./chunk-TA5K5546.cjs');
147
147
  var chunkCFT3P5KP_cjs = require('./chunk-CFT3P5KP.cjs');
148
148
  require('./chunk-FSLI5IKP.cjs');
149
149
  var chunkYP5T6NZD_cjs = require('./chunk-YP5T6NZD.cjs');
@@ -18827,7 +18827,7 @@ function CreateInvoiceModal({
18827
18827
  }
18828
18828
  ),
18829
18829
  /* @__PURE__ */ jsxRuntime.jsx(
18830
- chunkF6ZTKNAL_cjs.Textarea,
18830
+ chunk3XR7BPKD_cjs.Textarea,
18831
18831
  {
18832
18832
  label: "Notes (Optional)",
18833
18833
  rows: 3,
@@ -19143,7 +19143,7 @@ function CreateReferralModal({
19143
19143
  )) })
19144
19144
  ] }),
19145
19145
  /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
19146
- chunkF6ZTKNAL_cjs.Textarea,
19146
+ chunk3XR7BPKD_cjs.Textarea,
19147
19147
  {
19148
19148
  label: "Notes (Optional)",
19149
19149
  rows: 2,
@@ -19735,7 +19735,7 @@ function EmployeeForm({
19735
19735
  )
19736
19736
  ] }),
19737
19737
  /* @__PURE__ */ jsxRuntime.jsx(
19738
- chunkF6ZTKNAL_cjs.Textarea,
19738
+ chunk3XR7BPKD_cjs.Textarea,
19739
19739
  {
19740
19740
  label: additionalInformation,
19741
19741
  value: additionalInfo,
@@ -22754,7 +22754,7 @@ function HelpSupportPanel({
22754
22754
  }
22755
22755
  ),
22756
22756
  /* @__PURE__ */ jsxRuntime.jsx(
22757
- chunkF6ZTKNAL_cjs.Textarea,
22757
+ chunk3XR7BPKD_cjs.Textarea,
22758
22758
  {
22759
22759
  id: "support-message",
22760
22760
  required: true,
@@ -23488,7 +23488,7 @@ function InventoryManager({
23488
23488
  }
23489
23489
  ),
23490
23490
  /* @__PURE__ */ jsxRuntime.jsx(
23491
- chunkF6ZTKNAL_cjs.Textarea,
23491
+ chunk3XR7BPKD_cjs.Textarea,
23492
23492
  {
23493
23493
  label: "Memo",
23494
23494
  value: updateMemo,
@@ -27148,7 +27148,7 @@ var defaultOrderTabs = [
27148
27148
  { id: "rejected", label: "Rejected", statuses: ["rejected", "cancelled"] }
27149
27149
  ];
27150
27150
  function orderToMedication(order) {
27151
- const sig = order.detail ? chunkLE3HZ7MM_cjs.parseSig(order.detail) : void 0;
27151
+ const sig = order.detail ? chunkLVUSCBG4_cjs.parseSig(order.detail) : void 0;
27152
27152
  return {
27153
27153
  id: order.orderId,
27154
27154
  name: order.display,
@@ -27156,7 +27156,7 @@ function orderToMedication(order) {
27156
27156
  status: "unreconciled",
27157
27157
  indication: order.indication,
27158
27158
  pharmacyNotes: order.notes,
27159
- ...chunkLE3HZ7MM_cjs.labelToMedicationFields(order.display),
27159
+ ...chunkLVUSCBG4_cjs.labelToMedicationFields(order.display),
27160
27160
  ...sig && {
27161
27161
  route: sig.route,
27162
27162
  frequency: sig.frequency,
@@ -27227,7 +27227,7 @@ function BaseOrderEditor({
27227
27227
  onSave
27228
27228
  }) {
27229
27229
  const config = TYPE_CONFIG[type];
27230
- const ambientCodeLookup = chunkLE3HZ7MM_cjs.useCodeLookupConfig();
27230
+ const ambientCodeLookup = chunkLVUSCBG4_cjs.useCodeLookupConfig();
27231
27231
  const effectiveCodeLookup = codeLookup === false ? void 0 : codeLookup ?? ambientCodeLookup ?? void 0;
27232
27232
  const [draft, setDraft] = React13__namespace.useState(
27233
27233
  () => order ?? {
@@ -27348,7 +27348,7 @@ function BaseOrderEditor({
27348
27348
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
27349
27349
  /* @__PURE__ */ jsxRuntime.jsx(chunkAIJAFPGJ_cjs.Label, { htmlFor: "ord-detail", children: "Instructions" }),
27350
27350
  /* @__PURE__ */ jsxRuntime.jsx(
27351
- chunkF6ZTKNAL_cjs.Textarea,
27351
+ chunk3XR7BPKD_cjs.Textarea,
27352
27352
  {
27353
27353
  id: "ord-detail",
27354
27354
  value: draft.detail ?? "",
@@ -27371,7 +27371,7 @@ function BaseOrderEditor({
27371
27371
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
27372
27372
  /* @__PURE__ */ jsxRuntime.jsx(chunkAIJAFPGJ_cjs.Label, { htmlFor: "ord-notes", children: type === "referral" ? "Notes to consultant" : "Notes to performer" }),
27373
27373
  /* @__PURE__ */ jsxRuntime.jsx(
27374
- chunkF6ZTKNAL_cjs.Textarea,
27374
+ chunk3XR7BPKD_cjs.Textarea,
27375
27375
  {
27376
27376
  id: "ord-notes",
27377
27377
  value: draft.notes ?? "",
@@ -27426,7 +27426,7 @@ function OrderEditor({
27426
27426
  display: ""
27427
27427
  };
27428
27428
  return /* @__PURE__ */ jsxRuntime.jsx(
27429
- chunkLE3HZ7MM_cjs.MedicationEditor,
27429
+ chunkLVUSCBG4_cjs.MedicationEditor,
27430
27430
  {
27431
27431
  open,
27432
27432
  medication: order ? orderToMedication(order) : void 0,
@@ -33912,7 +33912,7 @@ function ProviderSettings({
33912
33912
  }
33913
33913
  ),
33914
33914
  /* @__PURE__ */ jsxRuntime.jsx(
33915
- chunkF6ZTKNAL_cjs.Textarea,
33915
+ chunk3XR7BPKD_cjs.Textarea,
33916
33916
  {
33917
33917
  id: "provider-description",
33918
33918
  value: settings.general.description || "",
@@ -35910,7 +35910,7 @@ var ResultsEntryForm = React13__namespace.forwardRef(function ResultsEntryForm2(
35910
35910
  }
35911
35911
  ) }),
35912
35912
  /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
35913
- chunkF6ZTKNAL_cjs.Textarea,
35913
+ chunk3XR7BPKD_cjs.Textarea,
35914
35914
  {
35915
35915
  label: providerRecommendations,
35916
35916
  value: recommendations,
@@ -44784,39 +44784,39 @@ Object.defineProperty(exports, "sheetOverlayVariants", {
44784
44784
  });
44785
44785
  Object.defineProperty(exports, "EMAIL_BLOCK_TYPES", {
44786
44786
  enumerable: true,
44787
- get: function () { return chunkBUM72SAI_cjs.EMAIL_BLOCK_TYPES; }
44787
+ get: function () { return chunkLWAXTZGG_cjs.EMAIL_BLOCK_TYPES; }
44788
44788
  });
44789
44789
  Object.defineProperty(exports, "EmailEditor", {
44790
44790
  enumerable: true,
44791
- get: function () { return chunkBUM72SAI_cjs.EmailEditor; }
44791
+ get: function () { return chunkLWAXTZGG_cjs.EmailEditor; }
44792
44792
  });
44793
44793
  Object.defineProperty(exports, "createDefaultDesignSettings", {
44794
44794
  enumerable: true,
44795
- get: function () { return chunkBUM72SAI_cjs.createDefaultDesignSettings; }
44795
+ get: function () { return chunkLWAXTZGG_cjs.createDefaultDesignSettings; }
44796
44796
  });
44797
44797
  Object.defineProperty(exports, "createEmailBlock", {
44798
44798
  enumerable: true,
44799
- get: function () { return chunkBUM72SAI_cjs.createEmailBlock; }
44799
+ get: function () { return chunkLWAXTZGG_cjs.createEmailBlock; }
44800
44800
  });
44801
44801
  Object.defineProperty(exports, "createEmailHtmlSanitizer", {
44802
44802
  enumerable: true,
44803
- get: function () { return chunkBUM72SAI_cjs.createEmailHtmlSanitizer; }
44803
+ get: function () { return chunkLWAXTZGG_cjs.createEmailHtmlSanitizer; }
44804
44804
  });
44805
44805
  Object.defineProperty(exports, "createEmptyEmailContentTree", {
44806
44806
  enumerable: true,
44807
- get: function () { return chunkBUM72SAI_cjs.createEmptyEmailContentTree; }
44807
+ get: function () { return chunkLWAXTZGG_cjs.createEmptyEmailContentTree; }
44808
44808
  });
44809
44809
  Object.defineProperty(exports, "defaultEmailEditorLabels", {
44810
44810
  enumerable: true,
44811
- get: function () { return chunkBUM72SAI_cjs.defaultEmailEditorLabels; }
44811
+ get: function () { return chunkLWAXTZGG_cjs.defaultEmailEditorLabels; }
44812
44812
  });
44813
44813
  Object.defineProperty(exports, "generateEmailBlockId", {
44814
44814
  enumerable: true,
44815
- get: function () { return chunkBUM72SAI_cjs.generateEmailBlockId; }
44815
+ get: function () { return chunkLWAXTZGG_cjs.generateEmailBlockId; }
44816
44816
  });
44817
44817
  Object.defineProperty(exports, "renderEmailMjml", {
44818
44818
  enumerable: true,
44819
- get: function () { return chunkBUM72SAI_cjs.renderEmailMjml; }
44819
+ get: function () { return chunkLWAXTZGG_cjs.renderEmailMjml; }
44820
44820
  });
44821
44821
  Object.defineProperty(exports, "Tabs", {
44822
44822
  enumerable: true,
@@ -45348,87 +45348,87 @@ Object.defineProperty(exports, "isApplicable", {
45348
45348
  });
45349
45349
  Object.defineProperty(exports, "ALLERGY_TYPE_LABELS", {
45350
45350
  enumerable: true,
45351
- get: function () { return chunkLE3HZ7MM_cjs.ALLERGY_TYPE_LABELS; }
45351
+ get: function () { return chunkLVUSCBG4_cjs.ALLERGY_TYPE_LABELS; }
45352
45352
  });
45353
45353
  Object.defineProperty(exports, "AllergyList", {
45354
45354
  enumerable: true,
45355
- get: function () { return chunkLE3HZ7MM_cjs.AllergyList; }
45355
+ get: function () { return chunkLVUSCBG4_cjs.AllergyList; }
45356
45356
  });
45357
45357
  Object.defineProperty(exports, "AllergyManager", {
45358
45358
  enumerable: true,
45359
- get: function () { return chunkLE3HZ7MM_cjs.AllergyManager; }
45359
+ get: function () { return chunkLVUSCBG4_cjs.AllergyManager; }
45360
45360
  });
45361
45361
  Object.defineProperty(exports, "Assessment", {
45362
45362
  enumerable: true,
45363
- get: function () { return chunkLE3HZ7MM_cjs.Assessment; }
45363
+ get: function () { return chunkLVUSCBG4_cjs.Assessment; }
45364
45364
  });
45365
45365
  Object.defineProperty(exports, "CodeLookupProvider", {
45366
45366
  enumerable: true,
45367
- get: function () { return chunkLE3HZ7MM_cjs.CodeLookupProvider; }
45367
+ get: function () { return chunkLVUSCBG4_cjs.CodeLookupProvider; }
45368
45368
  });
45369
45369
  Object.defineProperty(exports, "ConditionEditor", {
45370
45370
  enumerable: true,
45371
- get: function () { return chunkLE3HZ7MM_cjs.ConditionEditor; }
45371
+ get: function () { return chunkLVUSCBG4_cjs.ConditionEditor; }
45372
45372
  });
45373
45373
  Object.defineProperty(exports, "MEDICATION_STATUS_LABELS", {
45374
45374
  enumerable: true,
45375
- get: function () { return chunkLE3HZ7MM_cjs.MEDICATION_STATUS_LABELS; }
45375
+ get: function () { return chunkLVUSCBG4_cjs.MEDICATION_STATUS_LABELS; }
45376
45376
  });
45377
45377
  Object.defineProperty(exports, "MedicationEditor", {
45378
45378
  enumerable: true,
45379
- get: function () { return chunkLE3HZ7MM_cjs.MedicationEditor; }
45379
+ get: function () { return chunkLVUSCBG4_cjs.MedicationEditor; }
45380
45380
  });
45381
45381
  Object.defineProperty(exports, "MedicationList", {
45382
45382
  enumerable: true,
45383
- get: function () { return chunkLE3HZ7MM_cjs.MedicationList; }
45383
+ get: function () { return chunkLVUSCBG4_cjs.MedicationList; }
45384
45384
  });
45385
45385
  Object.defineProperty(exports, "MedicationReconciliation", {
45386
45386
  enumerable: true,
45387
- get: function () { return chunkLE3HZ7MM_cjs.MedicationReconciliation; }
45387
+ get: function () { return chunkLVUSCBG4_cjs.MedicationReconciliation; }
45388
45388
  });
45389
45389
  Object.defineProperty(exports, "ORDER_TYPE_META", {
45390
45390
  enumerable: true,
45391
- get: function () { return chunkLE3HZ7MM_cjs.ORDER_TYPE_META; }
45391
+ get: function () { return chunkLVUSCBG4_cjs.ORDER_TYPE_META; }
45392
45392
  });
45393
45393
  Object.defineProperty(exports, "ORDER_TYPE_SEARCH_DOMAINS", {
45394
45394
  enumerable: true,
45395
- get: function () { return chunkLE3HZ7MM_cjs.ORDER_TYPE_SEARCH_DOMAINS; }
45395
+ get: function () { return chunkLVUSCBG4_cjs.ORDER_TYPE_SEARCH_DOMAINS; }
45396
45396
  });
45397
45397
  Object.defineProperty(exports, "doseFormToQuantityUnit", {
45398
45398
  enumerable: true,
45399
- get: function () { return chunkLE3HZ7MM_cjs.doseFormToQuantityUnit; }
45399
+ get: function () { return chunkLVUSCBG4_cjs.doseFormToQuantityUnit; }
45400
45400
  });
45401
45401
  Object.defineProperty(exports, "isConditionCodetype", {
45402
45402
  enumerable: true,
45403
- get: function () { return chunkLE3HZ7MM_cjs.isConditionCodetype; }
45403
+ get: function () { return chunkLVUSCBG4_cjs.isConditionCodetype; }
45404
45404
  });
45405
45405
  Object.defineProperty(exports, "labelToMedicationFields", {
45406
45406
  enumerable: true,
45407
- get: function () { return chunkLE3HZ7MM_cjs.labelToMedicationFields; }
45407
+ get: function () { return chunkLVUSCBG4_cjs.labelToMedicationFields; }
45408
45408
  });
45409
45409
  Object.defineProperty(exports, "lookupToMedicationFields", {
45410
45410
  enumerable: true,
45411
- get: function () { return chunkLE3HZ7MM_cjs.lookupToMedicationFields; }
45411
+ get: function () { return chunkLVUSCBG4_cjs.lookupToMedicationFields; }
45412
45412
  });
45413
45413
  Object.defineProperty(exports, "normalizeConditionCodingSystem", {
45414
45414
  enumerable: true,
45415
- get: function () { return chunkLE3HZ7MM_cjs.normalizeConditionCodingSystem; }
45415
+ get: function () { return chunkLVUSCBG4_cjs.normalizeConditionCodingSystem; }
45416
45416
  });
45417
45417
  Object.defineProperty(exports, "orderTypeForCodetype", {
45418
45418
  enumerable: true,
45419
- get: function () { return chunkLE3HZ7MM_cjs.orderTypeForCodetype; }
45419
+ get: function () { return chunkLVUSCBG4_cjs.orderTypeForCodetype; }
45420
45420
  });
45421
45421
  Object.defineProperty(exports, "parseMedicationLabel", {
45422
45422
  enumerable: true,
45423
- get: function () { return chunkLE3HZ7MM_cjs.parseMedicationLabel; }
45423
+ get: function () { return chunkLVUSCBG4_cjs.parseMedicationLabel; }
45424
45424
  });
45425
45425
  Object.defineProperty(exports, "parseSig", {
45426
45426
  enumerable: true,
45427
- get: function () { return chunkLE3HZ7MM_cjs.parseSig; }
45427
+ get: function () { return chunkLVUSCBG4_cjs.parseSig; }
45428
45428
  });
45429
45429
  Object.defineProperty(exports, "useCodeLookupConfig", {
45430
45430
  enumerable: true,
45431
- get: function () { return chunkLE3HZ7MM_cjs.useCodeLookupConfig; }
45431
+ get: function () { return chunkLVUSCBG4_cjs.useCodeLookupConfig; }
45432
45432
  });
45433
45433
  Object.defineProperty(exports, "CHANGE_TYPE_LABELS", {
45434
45434
  enumerable: true,
@@ -45508,23 +45508,23 @@ Object.defineProperty(exports, "DateInput", {
45508
45508
  });
45509
45509
  Object.defineProperty(exports, "TextAreaPlain", {
45510
45510
  enumerable: true,
45511
- get: function () { return chunkF6ZTKNAL_cjs.TextAreaPlain; }
45511
+ get: function () { return chunk3XR7BPKD_cjs.TextAreaPlain; }
45512
45512
  });
45513
45513
  Object.defineProperty(exports, "Textarea", {
45514
45514
  enumerable: true,
45515
- get: function () { return chunkF6ZTKNAL_cjs.Textarea; }
45515
+ get: function () { return chunk3XR7BPKD_cjs.Textarea; }
45516
45516
  });
45517
45517
  Object.defineProperty(exports, "htmlToPlain", {
45518
45518
  enumerable: true,
45519
- get: function () { return chunkF6ZTKNAL_cjs.htmlToPlain; }
45519
+ get: function () { return chunk3XR7BPKD_cjs.htmlToPlain; }
45520
45520
  });
45521
45521
  Object.defineProperty(exports, "plainToHtml", {
45522
45522
  enumerable: true,
45523
- get: function () { return chunkF6ZTKNAL_cjs.plainToHtml; }
45523
+ get: function () { return chunk3XR7BPKD_cjs.plainToHtml; }
45524
45524
  });
45525
45525
  Object.defineProperty(exports, "textareaVariants", {
45526
45526
  enumerable: true,
45527
- get: function () { return chunkF6ZTKNAL_cjs.textareaVariants; }
45527
+ get: function () { return chunk3XR7BPKD_cjs.textareaVariants; }
45528
45528
  });
45529
45529
  Object.defineProperty(exports, "Select", {
45530
45530
  enumerable: true,
package/dist/index.js CHANGED
@@ -93,7 +93,7 @@ import { CountryDropdownBase } from './chunk-OTIKWEFZ.js';
93
93
  export { CountryCodeDropdown, formatE164, validatePhoneNumber } from './chunk-OTIKWEFZ.js';
94
94
  export { CustomizableDashboard, DashboardCustomizePanel, consolidateColumns, mergeColumnOrder, moveAcrossColumns, reorderOnDrop, requiredColumns } from './chunk-OWYWRBED.js';
95
95
  export { Sheet, SheetBody, SheetClose, SheetDescription, SheetFooter, SheetHeader, SheetTitle, sheetContentVariants, sheetOverlayVariants } from './chunk-LMBXJZLG.js';
96
- export { EMAIL_BLOCK_TYPES, EmailEditor, createDefaultDesignSettings, createEmailBlock, createEmailHtmlSanitizer, createEmptyEmailContentTree, defaultEmailEditorLabels, generateEmailBlockId, renderEmailMjml } from './chunk-IYXZ25E6.js';
96
+ export { EMAIL_BLOCK_TYPES, EmailEditor, createDefaultDesignSettings, createEmailBlock, createEmailHtmlSanitizer, createEmptyEmailContentTree, defaultEmailEditorLabels, generateEmailBlockId, renderEmailMjml } from './chunk-ETAYMSCW.js';
97
97
  import './chunk-XBAAHOCP.js';
98
98
  import { Tabs, TabsList, TabsTrigger, TabsContent } from './chunk-RYGVILUR.js';
99
99
  export { Tabs, TabsContent, TabsList, TabsTrigger, tabsListVariants, tabsTriggerVariants } from './chunk-RYGVILUR.js';
@@ -147,8 +147,8 @@ import { Spinner, SpinnerWithLabel } from './chunk-UA7E7PDS.js';
147
147
  export { FullPageSpinner, Spinner, SpinnerWithLabel, spinnerVariants } from './chunk-UA7E7PDS.js';
148
148
  import { evaluateDue, completedKeys, normalizeOrders } from './chunk-Y5KEFV5O.js';
149
149
  export { buildChartOrderRows, buildEncounterOrderRows, dueForOrder, evaluateDue, evaluateProgram, isApplicable } from './chunk-Y5KEFV5O.js';
150
- import { parseSig, labelToMedicationFields, MedicationEditor, useCodeLookupConfig } from './chunk-QJ75ZMCG.js';
151
- export { ALLERGY_TYPE_LABELS, AllergyList, AllergyManager, Assessment, CodeLookupProvider, ConditionEditor, MEDICATION_STATUS_LABELS, MedicationEditor, MedicationList, MedicationReconciliation, ORDER_TYPE_META, ORDER_TYPE_SEARCH_DOMAINS, doseFormToQuantityUnit, isConditionCodetype, labelToMedicationFields, lookupToMedicationFields, normalizeConditionCodingSystem, orderTypeForCodetype, parseMedicationLabel, parseSig, useCodeLookupConfig } from './chunk-QJ75ZMCG.js';
150
+ import { parseSig, labelToMedicationFields, MedicationEditor, useCodeLookupConfig } from './chunk-R4DQRXZY.js';
151
+ export { ALLERGY_TYPE_LABELS, AllergyList, AllergyManager, Assessment, CodeLookupProvider, ConditionEditor, MEDICATION_STATUS_LABELS, MedicationEditor, MedicationList, MedicationReconciliation, ORDER_TYPE_META, ORDER_TYPE_SEARCH_DOMAINS, doseFormToQuantityUnit, isConditionCodetype, labelToMedicationFields, lookupToMedicationFields, normalizeConditionCodingSystem, orderTypeForCodetype, parseMedicationLabel, parseSig, useCodeLookupConfig } from './chunk-R4DQRXZY.js';
152
152
  import { currentAssertion, CodingChips, toolbarKeyNav } from './chunk-VQGRMCVT.js';
153
153
  export { CHANGE_TYPE_LABELS, CONCERN_STATUS_LABELS, CodingChips, ProblemList, RowActionToolbar, RowIconButton, UncertaintyBadge, concernGroupKey, concernHistoryContent, currentAssertion, toolbarKeyNav } from './chunk-VQGRMCVT.js';
154
154
  import { Tooltip } from './chunk-AB24H2RM.js';
@@ -161,8 +161,8 @@ import { Label } from './chunk-I3WGZPI6.js';
161
161
  export { Label, labelVariants } from './chunk-I3WGZPI6.js';
162
162
  import { DateInput } from './chunk-ZP4H5HA4.js';
163
163
  export { DateInput } from './chunk-ZP4H5HA4.js';
164
- import { Textarea } from './chunk-2D6TFO2Y.js';
165
- export { TextAreaPlain, Textarea, htmlToPlain, plainToHtml, textareaVariants } from './chunk-2D6TFO2Y.js';
164
+ import { Textarea } from './chunk-XJ37SWVD.js';
165
+ export { TextAreaPlain, Textarea, htmlToPlain, plainToHtml, textareaVariants } from './chunk-XJ37SWVD.js';
166
166
  import { Select } from './chunk-VCI2Y7ST.js';
167
167
  export { Select, selectTriggerVariants } from './chunk-VCI2Y7ST.js';
168
168
  import { Card, CardHeader, CardContent, CardTitle } from './chunk-QYSUYB3S.js';
@@ -183,8 +183,8 @@ import { isStorybookDocsMode } from './chunk-VSQF22GL.js';
183
183
  export { isStorybookDocsMode } from './chunk-VSQF22GL.js';
184
184
  import { Badge } from './chunk-522WJIVI.js';
185
185
  export { Badge, badgeVariants } from './chunk-522WJIVI.js';
186
- import './chunk-WI35L5TR.js';
187
- import './chunk-ULKDK6W6.js';
186
+ import './chunk-DHCSY2JY.js';
187
+ import './chunk-3XVDSLDT.js';
188
188
  import { RichTextEditorBase } from './chunk-N6STVVB6.js';
189
189
  export { MacroLibrary, RichTextEditor, convertAngleBracketsToMustache, processDictation } from './chunk-N6STVVB6.js';
190
190
  import './chunk-5YOT4DVH.js';
package/dist/kerebron.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunk6I2G26AX_cjs = require('./chunk-6I2G26AX.cjs');
4
- var chunk5O54NWAL_cjs = require('./chunk-5O54NWAL.cjs');
3
+ var chunkYKL66TCM_cjs = require('./chunk-YKL66TCM.cjs');
4
+ var chunkTA5K5546_cjs = require('./chunk-TA5K5546.cjs');
5
5
  require('./chunk-CFT3P5KP.cjs');
6
6
  require('./chunk-FSLI5IKP.cjs');
7
7
  require('./chunk-YP5T6NZD.cjs');
@@ -29,15 +29,15 @@ require('./chunk-EUAMEVVI.cjs');
29
29
 
30
30
  Object.defineProperty(exports, "CodeEditor", {
31
31
  enumerable: true,
32
- get: function () { return chunk6I2G26AX_cjs.CodeEditor; }
32
+ get: function () { return chunkYKL66TCM_cjs.CodeEditor; }
33
33
  });
34
34
  Object.defineProperty(exports, "TextAreaRich", {
35
35
  enumerable: true,
36
- get: function () { return chunk6I2G26AX_cjs.TextAreaRichKerebron; }
36
+ get: function () { return chunkYKL66TCM_cjs.TextAreaRichKerebron; }
37
37
  });
38
38
  Object.defineProperty(exports, "RichEditor", {
39
39
  enumerable: true,
40
- get: function () { return chunk5O54NWAL_cjs.RichEditor; }
40
+ get: function () { return chunkTA5K5546_cjs.RichEditor; }
41
41
  });
42
42
  //# sourceMappingURL=kerebron.cjs.map
43
43
  //# sourceMappingURL=kerebron.cjs.map
package/dist/kerebron.js CHANGED
@@ -1,5 +1,5 @@
1
- export { CodeEditor, TextAreaRichKerebron as TextAreaRich } from './chunk-WI35L5TR.js';
2
- export { RichEditor } from './chunk-ULKDK6W6.js';
1
+ export { CodeEditor, TextAreaRichKerebron as TextAreaRich } from './chunk-DHCSY2JY.js';
2
+ export { RichEditor } from './chunk-3XVDSLDT.js';
3
3
  import './chunk-N6STVVB6.js';
4
4
  import './chunk-5YOT4DVH.js';
5
5
  import './chunk-OQWZYKJM.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mieweb/ui",
3
- "version": "0.11.0-dev.47",
3
+ "version": "0.11.0-dev.48",
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",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/RichEditor/mdyTransaction.ts","../src/components/RichEditor/editorKits.ts","../src/components/RichEditor/RichEditor.tsx"],"names":["AdvancedEditorKit","ExtensionCustomMenu","ExtensionMediaUpload","forwardRef","RichEditor","useIsDarkMode","useRef","useState","useReducer","useCallback","useEffect","editor","doc","CoreEditor","createAssetLoad","useImperativeHandle","jsx","jsxs"],"mappings":";;;;;;;;;;;;AACO,IAAM,mBAAA,GAAsB;ACqGnC,IAAM,gBAAA,GAAmB,CAAC,cAAA,EAAgB,OAAO,CAAA;AAoBjD,SAAS,sBAAsB,UAAA,EAA6B;AAC1D,EAAA,KAAA,MAAW,QAAQ,UAAA,EAAY;AAC7B,IAAA,IAAI,CAAC,IAAA,IAAQ,OAAO,IAAA,KAAS,QAAA,EAAU;AACvC,IAAA,MAAM,SAAA,GAAY,IAAA;AAKlB,IAAA,IACE,UAAU,IAAA,KAAS,kBAAA,IACnB,OAAO,SAAA,CAAU,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AAA,EAAA,EACC,QAAA,kBAAAC,eAAA,CAAC,KAAA,EAAA,EACC,QAAA,EAAA;AAAA,wBAAAD,cAAA,CAAC,QAAG,QAAA,EAAA,iBAAA,EAAe,CAAA;AAAA,wBACnBA,cAAA,CAAC,SAAK,QAAA,EAAA,EAAA,EAAG;AAAA,OAAA,EACX,CAAA,EACF;AAAA,KAAA,EAEJ,CAAA;AAAA,EAEJ;AACF;AAEA,UAAA,CAAW,WAAA,GAAc,YAAA","file":"chunk-5O54NWAL.cjs","sourcesContent":["/** Shared metadata for host-created MDY projection updates. */\nexport const MDY_PROJECTION_META = 'mdyProjectionRefresh';\n","/**\n * Editor kit assembly for {@link RichEditor}, for both plain and collaborative\n * (Yjs) mode.\n *\n * Both modes start from {@link AdvancedEditorKit} and drop the extensions that\n * are unsafe for our usage — see {@link unsafeExtensions} — then collaborative\n * mode adds the Yjs pieces on top.\n *\n * The Yjs pieces live in `collabKit.ts` behind a dynamic `import()`, so\n * `@kerebron/extension-yjs`, `yjs` and `y-protocols` remain truly optional\n * peers — plain-mode consumers never load them.\n */\nimport type { EditorKit } from '@kerebron/editor';\nimport type { NodeSpec } from 'prosemirror-model';\nimport { AdvancedEditorKit } from '@kerebron/editor-kits/AdvancedEditorKit';\nimport {\n ExtensionMediaUpload,\n type MediaUploadOptions,\n} from '@kerebron/extension-basic-editor/ExtensionMediaUpload';\nimport {\n ExtensionCustomMenu,\n type MenuElement,\n} from '@kerebron/extension-menu';\n\nexport type { MediaUploadOptions };\nexport type { MenuElement };\n\n/**\n * Reshape the toolbar menu before it renders: receives the stock menu's\n * item groups and returns the groups to render. Append custom\n * {@link MenuElement}s (e.g. a Macros toggle) or drop stock groups.\n */\nexport type ModifyMenu = (menus: MenuElement[][]) => MenuElement[][];\n\nexport interface CollabConfig {\n /** Room id — one shared document per room (e.g. a post id). */\n room: string;\n /**\n * WebSocket base URL for the Yjs relay. Defaults to\n * `<ws|wss>://<location.host>/yjs`. The room id is appended by the provider.\n */\n wsUrl?: string;\n /** Extra query params for the socket (e.g. `{ token }` for auth). */\n params?: Record<string, string>;\n /**\n * Who this editor is, published on awareness (`kerebron:user`) so peers see\n * a named, coloured cursor. Without it remote cursors do not render — the\n * position plugin skips awareness states that carry no user — and the\n * `id` is what the cursor colour is derived from (kerebron's `User` shape).\n */\n user?: { id: string; name: string; color?: string };\n /**\n * Custom WebSocket implementation handed to the Yjs provider — e.g. a\n * loopback socket for demos/tests, or a polyfill outside the browser.\n * Defaults to `globalThis.WebSocket`.\n */\n WebSocketPolyfill?: typeof globalThis.WebSocket;\n /**\n * Called when collaborative editing could not be started at all — the Yjs\n * kit failed to load (see {@link createEditorKits}). The editor mounts\n * anyway, as a local one; this is how the host finds out that edits are no\n * longer shared, so it can say so, or tear its own editor down if unshared\n * editing would be unsafe.\n *\n * Not for connection trouble: a room that is reachable but currently\n * disconnected still has the Yjs kit loaded, and the provider retries on its\n * own. This fires once, before the editor is created.\n */\n onUnavailable?: (error: unknown) => void;\n}\n\n/** What {@link createEditorKits} resolves to. */\nexport interface EditorKits {\n kits: EditorKit[];\n /**\n * Whether the returned kits can actually collaborate. False when `config`\n * asked for a room but the Yjs kit could not be loaded, so callers know not\n * to join one.\n */\n collaborative: boolean;\n}\n\n/**\n * Extensions dropped from {@link AdvancedEditorKit}, and why.\n *\n * `autocomplete` and `hover` debounce their DOM handlers (200ms) and then call\n * `dispatchMeta`, which reads `this.editor.state` with no guard that the editor\n * is still alive. Any teardown or document swap inside that debounce window\n * lands the deferred call on a dead view and throws\n * `null.matchesNode()` inside ProseMirror's `EditorView.updateStateInner`,\n * leaving the view permanently broken. Two ways to hit it:\n * - remount (e.g. a `key` change) while the pointer is over the editor, which\n * fires the debounced `onMouseLeave` after the view is destroyed;\n * - a Yjs remote update replacing the document tree under a pending callback.\n * The first applies to *every* editor, so both extensions come out in both\n * modes. No functional cost — autocomplete popups and node-hover tooltips are\n * compositor conveniences, not required for editing.\n *\n * `history` is collab-only: ExtensionYjs supplies its own CRDT-aware undo/redo\n * and the editor throws `Extension conflict: yjs vs history` if both are\n * present. Plain mode keeps it, so undo/redo still works there.\n */\nconst unsafeExtensions = ['autocomplete', 'hover'] as const;\n\n/**\n * Fix the `shortcode_inline` node's DOM round-trip (mieweb/ui#695).\n *\n * The stock node chips `{{merge_tokens}}` into atomic spans but its `toDOM`\n * drops the braces, so serializing a document back to HTML/text silently\n * corrupts every merge token. Patch the spec on the kit's own instance:\n * serialize the braces, strip them again on parse — the `content` attr stays\n * brace-less, which the input rule and the markdown serializer both rely on.\n *\n * Done here, in the kit we ship, so npm consumers on stock\n * `@kerebron/extension-basic-editor` get the fix too — `@kerebron/*` is\n * externalized (`tsup.config.ts`), so a workspace-level package patch would\n * never reach them. Drop once fixed upstream.\n *\n * The node is nested: `AdvancedEditorKit` → `ExtensionBasicEditor`, whose\n * `requires` carries the `BasicEditorKit` extension *instances* (names and\n * instances mix in `requires`), hence the recursive walk.\n */\nfunction fixShortcodeRoundTrip(extensions: unknown[]): void {\n for (const item of extensions) {\n if (!item || typeof item !== 'object') continue; // name-only requires\n const extension = item as {\n name?: unknown;\n requires?: unknown;\n getNodeSpec?: () => NodeSpec;\n };\n if (\n extension.name === 'shortcode_inline' &&\n typeof extension.getNodeSpec === 'function'\n ) {\n const stockSpec = extension.getNodeSpec.bind(extension);\n extension.getNodeSpec = (): NodeSpec => ({\n ...stockSpec(),\n parseDOM: [\n {\n tag: 'span.kb-shortcode-inline',\n getAttrs: (dom) => {\n const text = dom.textContent ?? '';\n const match = /^\\{\\{([^}]+)\\}\\}$/.exec(text);\n return { content: match ? match[1] : text || null };\n },\n },\n ],\n toDOM: (node) => [\n 'span',\n { class: 'kb-shortcode-inline' },\n node.attrs.content ? `{{${String(node.attrs.content)}}}` : '',\n ],\n });\n return;\n }\n if (Array.isArray(extension.requires)) {\n fixShortcodeRoundTrip(extension.requires);\n }\n }\n}\n\n/**\n * Remove extensions by name, wherever they sit: extensions nest (e.g.\n * `ExtensionBasicEditor.requires` carries the BasicEditorKit node instances),\n * so the walk descends `requires` arrays and filters each level in place.\n * Name-only (string) requires entries are left alone — they declare ordering,\n * not instances.\n */\nfunction dropNamedExtensions(\n extensions: unknown[],\n names: readonly string[]\n): unknown[] {\n const kept = extensions.filter(\n (item) =>\n !(\n item &&\n typeof item === 'object' &&\n 'name' in item &&\n names.includes((item as { name: string }).name)\n )\n );\n for (const item of kept) {\n if (!item || typeof item !== 'object') continue;\n const extension = item as { requires?: unknown };\n if (Array.isArray(extension.requires)) {\n extension.requires = dropNamedExtensions(extension.requires, names);\n }\n }\n return kept;\n}\n\n/**\n * {@link AdvancedEditorKit} minus {@link unsafeExtensions} (and, for collab\n * mode, minus `history`), with `mediaUpload` reconfigured when the host asks.\n *\n * `AdvancedEditorKit` constructs `ExtensionMediaUpload` with no options, and an\n * extension's options are fixed at construction — so the only way to configure\n * it is to drop that instance and append one of our own. `modifyMenu` works\n * the same way: the stock `ExtensionCustomMenu` is constructed with no config,\n * so customizing the toolbar means replacing it with a configured instance.\n */\nclass SafeAdvancedEditorKit implements EditorKit {\n name = 'advanced-editor';\n constructor(\n private readonly forCollab: boolean,\n private readonly mediaUpload?: MediaUploadOptions,\n private readonly modifyMenu?: ModifyMenu,\n private readonly omitExtensions?: readonly string[]\n ) {}\n\n getExtensions() {\n const dropped: string[] = [...unsafeExtensions];\n if (this.forCollab) dropped.push('history');\n if (this.mediaUpload) dropped.push('mediaUpload');\n if (this.modifyMenu) dropped.push('customMenu');\n\n let extensions = new AdvancedEditorKit()\n .getExtensions()\n .filter(\n (extension) =>\n !('name' in extension && dropped.includes(extension.name))\n );\n\n if (this.omitExtensions?.length) {\n extensions = dropNamedExtensions(\n extensions,\n this.omitExtensions\n ) as typeof extensions;\n }\n if (this.modifyMenu) {\n extensions.push(new ExtensionCustomMenu({ modifyMenu: this.modifyMenu }));\n }\n if (this.mediaUpload) {\n extensions.push(new ExtensionMediaUpload(this.mediaUpload));\n }\n fixShortcodeRoundTrip(extensions);\n return extensions;\n }\n}\n\n/** MarkYChange + ExtensionYjs live in `collabKit.ts` (lazy-loaded). */\n\n/**\n * Build the editor kits for a session. Pass `config` to join a collaborative\n * room; omit it for a plain local editor. Pass `mediaUpload` to configure how\n * pasted/dropped files are handled — most importantly `uploadHandler`, without\n * which every image is embedded in the document as a base64 `data:` URL.\n * Pass `omitExtensions` to remove schema extensions by name — the toolbar is\n * schema-driven, so dropping a node removes its menu items, input rules and\n * paste handling in one move (e.g. the email surface drops `task_list`).\n *\n * Async because collaborative mode lazy-loads the Yjs kit (and its optional\n * peer deps) on first use; plain mode resolves immediately.\n *\n * That lazy load is allowed to fail. `@kerebron/extension-yjs`, `yjs` and\n * `y-protocols` are optional peers, so the chunk can be absent (peers never\n * installed), stale (a dev server's dependency hash moved under a running\n * page) or simply unreachable (a partial deploy, an offline client). None of\n * that is a reason to leave the caller without an editor: collaboration is an\n * enhancement, editing is the feature. So a failed load degrades to the local\n * kit and reports itself through {@link CollabConfig.onUnavailable} rather\n * than rejecting.\n */\nexport async function createEditorKits(\n config?: CollabConfig,\n mediaUpload?: MediaUploadOptions,\n modifyMenu?: ModifyMenu,\n omitExtensions?: readonly string[]\n): Promise<EditorKits> {\n if (!config) {\n return {\n kits: [\n new SafeAdvancedEditorKit(\n false,\n mediaUpload,\n modifyMenu,\n omitExtensions\n ),\n ],\n collaborative: false,\n };\n }\n\n try {\n const { HuddleYjsKit, defaultWsUrl } = await import('./collabKit');\n const url = config.wsUrl ?? defaultWsUrl();\n return {\n kits: [\n new SafeAdvancedEditorKit(\n true,\n mediaUpload,\n modifyMenu,\n omitExtensions\n ),\n new HuddleYjsKit(\n url,\n config.params ?? {},\n config.WebSocketPolyfill,\n config.user\n ),\n ],\n collaborative: true,\n };\n } catch (error) {\n console.warn(\n '[RichEditor] Collaborative editing unavailable — the Yjs kit failed to load. Continuing as a local editor.',\n error\n );\n config.onUnavailable?.(error);\n // Degrading to a local editor must not also drop `mediaUpload`: without it\n // the stock extension comes back and pasted files are embedded as base64.\n return {\n kits: [\n new SafeAdvancedEditorKit(\n false,\n mediaUpload,\n modifyMenu,\n omitExtensions\n ),\n ],\n collaborative: false,\n };\n }\n}\n","'use client';\n\nimport {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useReducer,\n useRef,\n useState,\n} from 'react';\n\nimport { CoreEditor, type AssetLoad, type EditorKit } from '@kerebron/editor';\nimport { createAssetLoad } from '@kerebron/wasm/web';\n\nimport { useIsDarkMode } from '../../hooks/useIsDarkMode';\nimport { MDY_PROJECTION_META } from './mdyTransaction';\nimport {\n createEditorKits,\n type CollabConfig,\n type MediaUploadOptions,\n type ModifyMenu,\n} from './editorKits';\n\nexport type {\n CollabConfig,\n MediaUploadOptions,\n MenuElement,\n ModifyMenu,\n} from './editorKits';\n\nconst MARKDOWN_TYPE = 'text/x-markdown';\n\n/**\n * The markdown converter's tree-sitter WASM init is not concurrency-safe, so\n * every editor's *first* load queues behind the previous one. Later loads (a\n * `value` change) are free — by then the grammars are warm.\n */\nlet initialLoadQueue: Promise<unknown> = Promise.resolve();\n\nfunction queueInitialLoad(load: () => Promise<void>): Promise<void> {\n const queued = initialLoadQueue.catch(() => undefined).then(load);\n initialLoadQueue = queued.catch(() => undefined);\n return queued;\n}\n\nexport interface RichEditorProps {\n /** Markdown to load. Changing it reloads the editor unless `collab` is set. */\n value?: string;\n /** Called with the editor's markdown content whenever it changes. */\n onChange?: (value: string) => void;\n /** Called when editor setup or a Markdown load fails. getContent also rejects. */\n onError?: (error: unknown) => void;\n /** Called after the initial Markdown load completes. */\n onReady?: (editor: CoreEditor) => void;\n /** Whether to render the live markdown output preview. Defaults to `false`. */\n showPreview?: boolean;\n /**\n * Enable live collaborative editing (Yjs) for the given room. When set, the\n * editor connects to the `/yjs` websocket relay and every peer in the same\n * `room` co-edits one shared document. Uncontrolled like `value` — remount via\n * `key` to switch rooms.\n *\n * Best-effort: if the Yjs kit cannot be loaded the editor still mounts, as a\n * local one, and `collab.onUnavailable` is called. Pass that callback if\n * unshared editing is something your users need to be told about.\n */\n collab?: CollabConfig;\n /** Read-only surface: no typing, and the content dims. */\n disabled?: boolean;\n /**\n * Lock edits while keeping the surface focusable and selectable, without\n * the dimmed `disabled` styling. Applied from creation, so the document\n * cannot be edited even while the initial load is still in flight.\n */\n readOnly?: boolean;\n /**\n * Id for the editor host element — an `aria-labelledby`/`aria-describedby`\n * anchor. The host is a `div`, not a labelable control, so a\n * `<label htmlFor>` will not associate; name the editor with `aria-label`\n * or `aria-labelledby` instead.\n */\n id?: string;\n /** Extra classes on the editor surface, beside `kb-component`. */\n className?: string;\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n /**\n * Where the tree-sitter WASM grammars load from. Defaults to\n * `createAssetLoad('/kerebron-wasm')`; supply your own when the host serves\n * `@kerebron/wasm`'s `assets/` somewhere else.\n */\n assetLoad?: AssetLoad;\n /**\n * How files pasted or dropped into the editor are handled.\n *\n * **Set `uploadHandler` if your documents are persisted anywhere.** Without\n * it, a pasted image is embedded in the document as a base64 `data:` URL and\n * a video as a blob object URL: a 4 MB screenshot becomes ~5.8 MB of\n * markdown, which most APIs will refuse, and an object URL is dead as soon as\n * the page reloads. `uploadHandler` receives the file and returns the URL to\n * reference it by, so the document carries a link instead of the bytes.\n *\n * ```tsx\n * <RichEditor\n * mediaUpload={{ uploadHandler: (file) => uploadToMyMediaStore(file) }}\n * />\n * ```\n *\n * Read once, when the editor mounts — like {@link collab}, remount via `key`\n * to change it.\n */\n mediaUpload?: MediaUploadOptions;\n /** Additional editor kits, installed once when the editor mounts. */\n editorKits?: EditorKit[];\n /**\n * Reshape the stock toolbar before it renders: receives the menu's item\n * groups and returns the groups to render — append custom controls (a\n * macros toggle, dictation) or drop stock ones. Read once, when the editor\n * mounts — like {@link collab}, remount via `key` to change it.\n */\n modifyMenu?: ModifyMenu;\n /**\n * Schema extensions to remove by name (e.g. `['task_list', 'task_item']`).\n * The toolbar, input rules and paste handling are all schema-driven, so\n * dropping a node here removes the whole feature in one move. Read once,\n * when the editor mounts — like {@link collab}, remount via `key` to\n * change it.\n */\n omitExtensions?: readonly string[];\n /**\n * MIME type of the `value`/`onChange` contract (`'text/x-markdown'` by\n * default; pass `'text/html'` for an HTML-valued surface). Governs both\n * how `value` is parsed and what `onChange`/`getContent()` emit.\n */\n valueType?: string;\n /**\n * Converge the document to `value` on every render, not only when the\n * prop changes — native controlled-input semantics: when a host's\n * `onChange` does not echo an edit back into `value`, the edit reverts.\n * A rejected edit leaves the prop identity unchanged while the document\n * moved on, which a change-gated reload can never see. Off by default,\n * which tolerates read-once hosts that call `getContent()` on submit.\n */\n strictValue?: boolean;\n}\n\nexport interface RichEditorHandle {\n /**\n * The editor's markdown, awaiting the initial load. `onChange` can lag the\n * last keystroke, so read this on submit rather than trusting mirrored state.\n */\n getContent: () => Promise<string>;\n /** Focus the editor, restoring the caret where the writer left it. */\n focus: () => void;\n}\n\n/**\n * Markdown editor over Kerebron's `CoreEditor`.\n *\n * The editor mounts into a **disposable child div**: `CoreEditor.destroy()`\n * replaces its host element with a clone, which would strand React's ref (and,\n * under StrictMode's double-mount, leave the live editor detached behind a\n * dead clone).\n */\nconst RichEditor = forwardRef<RichEditorHandle, RichEditorProps>(\n function RichEditor(\n {\n value = '',\n onChange,\n onError,\n onReady,\n showPreview = false,\n collab,\n disabled = false,\n readOnly = false,\n id,\n className,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n assetLoad,\n mediaUpload,\n editorKits: additionalEditorKits,\n modifyMenu,\n omitExtensions,\n valueType = MARKDOWN_TYPE,\n strictValue = false,\n },\n ref\n ) {\n const isDark = useIsDarkMode();\n const hostRef = useRef<HTMLDivElement>(null);\n const editorInstance = useRef<CoreEditor | null>(null);\n const onChangeRef = useRef(onChange);\n onChangeRef.current = onChange;\n const onErrorRef = useRef(onError);\n onErrorRef.current = onError;\n const onReadyRef = useRef(onReady);\n onReadyRef.current = onReady;\n // Mirrors what the editor last held, so an echo of our own `onChange`\n // doesn't reload the document out from under the caret.\n const valueRef = useRef(value);\n const readyRef = useRef<Promise<void> | null>(null);\n const loadingRef = useRef(false);\n const loadVersionRef = useRef(0);\n // Return the exact source until a writer changes the loaded document.\n // Running the Markdown converter alone can normalize whitespace or links.\n const loadedDocRef = useRef<unknown>(null);\n const disabledRef = useRef(disabled);\n const readOnlyRef = useRef(readOnly);\n\n const [md, setMd] = useState<string>('');\n // A strict surface reconciles in an after-render effect, but publishing\n // an edit only mutates refs — a host whose `onChange` ignores the edit\n // (rejection) triggers no render, so the stale document would stay\n // visible. Each publication schedules one render; an accepted update\n // from the host batches into the same pass, so the effect compares the\n // freshest prop either way.\n const [, scheduleStrictReconcile] = useReducer(\n (tick: number) => tick + 1,\n 0\n );\n const strictValueRef = useRef(strictValue);\n strictValueRef.current = strictValue;\n // Serializing the document is the expensive part of a transaction, so the\n // last doc that was serialized is kept to recognise the transactions that\n // did not change it. ProseMirror documents are immutable, so identity is an\n // exact test.\n const lastSerializedDoc = useRef<unknown>(null);\n // Read inside effects created once on mount.\n const showPreviewRef = useRef(showPreview);\n showPreviewRef.current = showPreview;\n const valueTypeRef = useRef(valueType);\n valueTypeRef.current = valueType;\n\n // The contenteditable surface has no implicit ARIA role, so labeling\n // attributes are only permitted alongside an explicit textbox role — and\n // `aria-readonly` is only valid on such a role, not on the host div.\n const surfaceAttributes = useCallback(\n () =>\n ariaLabel || ariaLabelledBy\n ? {\n role: 'textbox',\n 'aria-multiline': 'true',\n ...(ariaLabel ? { 'aria-label': ariaLabel } : {}),\n ...(ariaLabelledBy ? { 'aria-labelledby': ariaLabelledBy } : {}),\n ...(readOnlyRef.current ? { 'aria-readonly': 'true' } : {}),\n }\n : null,\n [ariaLabel, ariaLabelledBy]\n );\n\n // Applies the read state everywhere it matters: the view's `editable`\n // prop, the surface's ARIA attributes, and the stock toolbar — whose\n // buttons dispatch commands regardless of `editable`, so disabled and\n // readOnly must neutralize it with `inert` (blocks pointer and keyboard\n // access while the document's text stays selectable).\n // ProseMirror drops natural tabbability once `editable` is false, so a\n // read-only (not disabled) surface restores it with a direct tabindex —\n // tracked by ownership so a host-supplied tabindex (the TextAreaRich\n // adapter sets its own through `setProps`) is never touched.\n const ownsTabindexRef = useRef(false);\n const syncReadState = useCallback(() => {\n const editor = editorInstance.current;\n if (editor) {\n const attributes = surfaceAttributes();\n editor.view.setProps({\n editable: () => !disabledRef.current && !readOnlyRef.current,\n ...(attributes ? { attributes } : {}),\n });\n const dom = editor.view.dom as HTMLElement;\n if (readOnlyRef.current && !disabledRef.current) {\n if (!dom.hasAttribute('tabindex')) {\n dom.setAttribute('tabindex', '0');\n ownsTabindexRef.current = true;\n }\n } else if (ownsTabindexRef.current) {\n if (dom.getAttribute('tabindex') === '0')\n dom.removeAttribute('tabindex');\n ownsTabindexRef.current = false;\n }\n }\n const inert = disabledRef.current || readOnlyRef.current;\n for (const toolbar of hostRef.current?.querySelectorAll<HTMLElement>(\n '.kb-custom-menu, .kb-custom-menu__overflow-menu'\n ) ?? []) {\n toolbar.inert = inert;\n }\n }, [surfaceAttributes]);\n\n useEffect(() => {\n disabledRef.current = disabled;\n readOnlyRef.current = readOnly;\n syncReadState();\n }, [disabled, readOnly, syncReadState]);\n\n // Runs after every render (no dependency array): a `strictValue` surface\n // must converge even when the prop identity never changed — a rejected\n // edit keeps `value` as-is while the document moved on. The\n // `value === valueRef` guard keeps the common case free; non-strict\n // hosts additionally require the prop itself to have changed (tracked\n // manually below), preserving tolerance for read-once hosts.\n const lastValuePropRef = useRef(value);\n useEffect(() => {\n const propChanged = lastValuePropRef.current !== value;\n lastValuePropRef.current = value;\n // In collab mode the CRDT owns the content; reloading would fight it.\n if (collab || value === valueRef.current) return;\n if (!strictValue && !propChanged) return;\n valueRef.current = value;\n const editor = editorInstance.current;\n if (!editor) return;\n\n loadingRef.current = true;\n const loadVersion = ++loadVersionRef.current;\n const previousReady = readyRef.current;\n // Serialize reloads behind setup and one another. Saving while a reload\n // is pending awaits that same promise rather than reading stale prose.\n const pending = (previousReady ?? Promise.resolve())\n .catch(() => undefined)\n .then(async () => {\n if (editorInstance.current !== editor) return;\n // Reloading the document must not cost the writer their caret: a\n // host-composed update (macro pick, finding) lands mid-flow and\n // the next keystroke should keep going into the editable.\n const hadFocus = editor.view.hasFocus();\n await editor.loadDocumentText(valueTypeRef.current, value);\n if (editorInstance.current !== editor) return;\n loadedDocRef.current = editor.view.state.doc;\n lastSerializedDoc.current = editor.view.state.doc;\n if (hadFocus) {\n // The load can take long enough for the writer to move on —\n // only reclaim the caret when no other control has taken it.\n const active = document.activeElement;\n if (\n !active ||\n active === document.body ||\n (editor.view.dom as HTMLElement).contains(active)\n ) {\n editor.view.focus();\n }\n }\n if (showPreviewRef.current) setMd(value);\n })\n .finally(() => {\n if (\n editorInstance.current === editor &&\n loadVersion === loadVersionRef.current\n ) {\n loadingRef.current = false;\n }\n });\n readyRef.current = pending;\n void pending.catch((error) => {\n if (editorInstance.current !== editor) return;\n console.error('Failed to load markdown:', error);\n onErrorRef.current?.(error);\n });\n });\n\n useEffect(() => {\n if (!hostRef.current) return;\n const host = hostRef.current;\n\n // Set on cleanup so async continuations (kit loading and the\n // `loadDocumentText` chain) don't touch the editor after `destroy()`.\n let disposed = false;\n let editor: CoreEditor | null = null;\n\n const mount = document.createElement('div');\n host.appendChild(mount);\n\n // Listen to transactions and update markdown preview\n const onTransaction = async (event?: Event) => {\n const transaction = (\n event as\n | globalThis.CustomEvent<{\n transaction?: {\n getMeta: (key: string) => unknown;\n before: unknown;\n };\n }>\n | undefined\n )?.detail?.transaction;\n if (transaction?.getMeta(MDY_PROJECTION_META) === true) {\n const doc = editorInstance.current?.view.state.doc;\n if (transaction.before === loadedDocRef.current) {\n loadedDocRef.current = doc;\n lastSerializedDoc.current = doc;\n } else {\n lastSerializedDoc.current = null;\n // A host projection can overtake a pending user-edit save. That\n // older result is discarded below, so publish the newest composed\n // document even if the writer does not make another transaction.\n // A microtask coalesces a burst of clinical updates into one save.\n void Promise.resolve().then(() => {\n if (!disposed) return onTransaction();\n });\n }\n return;\n }\n // Programmatic loads are not edits — reporting them would echo the\n // caller's own `value` back through `onChange`.\n if (loadingRef.current || !editorInstance.current) return;\n\n // ProseMirror fires a transaction for every selection change too —\n // arrow keys, clicks, a blur. Serializing the whole document to\n // markdown for those costs a full tree-sitter pass and two React\n // renders for a caret move, so only a changed document is re-read.\n const { doc } = editorInstance.current.view.state;\n if (doc === lastSerializedDoc.current) return;\n lastSerializedDoc.current = doc;\n const loadVersion = loadVersionRef.current;\n\n try {\n const buffer = await editorInstance.current.saveDocument(\n valueTypeRef.current\n );\n const markdown = new globalThis.TextDecoder().decode(buffer);\n if (\n disposed ||\n loadingRef.current ||\n loadVersion !== loadVersionRef.current ||\n doc !== editorInstance.current?.view.state.doc\n ) {\n return;\n }\n valueRef.current = markdown;\n // `md` only feeds the preview pane; setting it with the preview off\n // re-renders the editor on every keystroke for nothing.\n if (showPreviewRef.current) setMd(markdown);\n onChangeRef.current?.(markdown);\n if (strictValueRef.current) scheduleStrictReconcile();\n // This source is now published. Future clinical-only projections\n // preserve it without starting another authored-prose write.\n loadedDocRef.current = doc;\n } catch (err) {\n // The document was marked as serialized before the attempt, to keep\n // selection-only transactions arriving mid-save from re-entering.\n // A failure has to undo that, or this document is never retried.\n lastSerializedDoc.current = null;\n console.error('Failed to save markdown:', err);\n }\n };\n\n // Initialize the editor. Both modes drop the teardown-unsafe extensions;\n // collaborative mode additionally swaps `history` for the Yjs CRDT sync\n // and lazy-loads the Yjs kit (see `editorKits.ts` for why).\n const setup = async () => {\n loadingRef.current = true;\n const loadVersion = ++loadVersionRef.current;\n // `collaborative` is false when a room was asked for but the Yjs kit\n // could not be loaded — the editor is still created, just a local one,\n // so there is no room to join below.\n const { kits: editorKits, collaborative } = await createEditorKits(\n collab,\n mediaUpload,\n modifyMenu,\n omitExtensions\n );\n if (disposed) return;\n\n editor = CoreEditor.create({\n element: mount,\n uri: 'file:///untitled.md',\n assetLoad: assetLoad ?? createAssetLoad('/kerebron-wasm'),\n editorKits: [...editorKits, ...(additionalEditorKits ?? [])],\n readOnly: disabledRef.current || readOnlyRef.current,\n });\n\n editorInstance.current = editor;\n syncReadState();\n editor.addEventListener('transaction', onTransaction);\n\n // Seed initial content, then populate the preview once on mount.\n //\n // In collaborative mode we still load the local markdown first, then\n // join the room: the Yjs binding seeds an *empty* shared document from\n // this content on the first join, and overwrites the editor with the\n // shared content when the room already has edits — so the stored\n // markdown is the starting point without ever double-inserting.\n const joinRoom = () => {\n if (collaborative && collab && editor && !disposed) {\n (\n editor.run as Record<string, (...args: unknown[]) => boolean>\n ).changeRoom?.(collab.room);\n reseedWhenRoomStaysEmpty();\n }\n };\n\n // The Yjs binding is supposed to seed an empty room from the local\n // content, but the sync import can land as an overwrite that blanks\n // the just-loaded seed (observed with extension-yjs 0.8.x). Heal it:\n // once the join settles, an empty document with a non-empty seed\n // means nobody's content won — reload the seed, which the binding\n // then pushes into the room. Joiners pass no value, so exactly one\n // participant ever does this.\n const seed = valueRef.current;\n const reseedWhenRoomStaysEmpty = () => {\n if (!seed) return;\n const check = async (attempt: number) => {\n if (disposed || !editorInstance.current) return;\n try {\n const buffer =\n await editorInstance.current.saveDocument(MARKDOWN_TYPE);\n const current = new globalThis.TextDecoder()\n .decode(buffer)\n .trim();\n if (disposed || !editorInstance.current) return;\n if (current) return; // somebody's content arrived — done\n if (attempt >= 2) {\n await editorInstance.current.loadDocumentText(\n valueTypeRef.current,\n seed\n );\n return;\n }\n setTimeout(() => void check(attempt + 1), 300);\n } catch {\n // A failed probe must not break the editor; the room stays as-is.\n }\n };\n setTimeout(() => void check(0), 300);\n };\n\n if (valueRef.current) {\n await queueInitialLoad(() =>\n editor!.loadDocumentText(valueTypeRef.current, valueRef.current)\n );\n }\n if (disposed) return;\n loadedDocRef.current = editor.view.state.doc;\n lastSerializedDoc.current = editor.view.state.doc;\n if (showPreviewRef.current) setMd(valueRef.current);\n if (loadVersion === loadVersionRef.current) loadingRef.current = false;\n onReadyRef.current?.(editor);\n joinRoom();\n };\n\n const pending = setup();\n readyRef.current = pending;\n // Observe the rejection without replacing the readiness promise: callers\n // must be able to detect a failed load instead of saving stale content.\n void pending.catch((error) => {\n if (disposed) return;\n loadingRef.current = false;\n console.error('Failed to set up editor:', error);\n onErrorRef.current?.(error);\n });\n\n // Cleanup on unmount\n return () => {\n disposed = true;\n editorInstance.current = null; // makes onTransaction's guard effective\n editor?.removeEventListener('transaction', onTransaction);\n editor?.destroy();\n readyRef.current = null;\n host.replaceChildren();\n };\n // Initial `value`/`collab` are intentionally only applied on mount\n // (uncontrolled). Remount via `key` to switch rooms.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useImperativeHandle(\n ref,\n () => ({\n getContent: async (): Promise<string> => {\n while (true) {\n await readyRef.current;\n const editor = editorInstance.current;\n if (!editor) return valueRef.current;\n const doc = editor.view.state.doc;\n const loadVersion = loadVersionRef.current;\n if (doc === loadedDocRef.current) return valueRef.current;\n const buffer = await editor.saveDocument(valueTypeRef.current);\n if (\n editorInstance.current !== editor ||\n loadVersion !== loadVersionRef.current ||\n doc !== editor.view.state.doc\n )\n continue;\n const markdown = new globalThis.TextDecoder().decode(buffer);\n valueRef.current = markdown;\n loadedDocRef.current = doc;\n lastSerializedDoc.current = doc;\n return markdown;\n }\n },\n focus: (): void => {\n const apply = (): void => {\n const view = editorInstance.current?.view as\n | { focus?: () => void }\n | undefined;\n if (view?.focus) {\n view.focus();\n return;\n }\n hostRef.current\n ?.querySelector<HTMLElement>('[contenteditable=\"true\"], textarea')\n ?.focus();\n };\n // Callers focus on mount; the editor may still be loading its kits.\n if (editorInstance.current) apply();\n else void readyRef.current?.then(apply, () => undefined);\n },\n }),\n []\n );\n\n return (\n <div>\n <div>\n <div\n ref={hostRef}\n id={id}\n className={[\n 'kb-component',\n isDark ? 'kb-component--dark' : '',\n className ?? '',\n ]\n .filter(Boolean)\n .join(' ')}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-disabled={disabled || undefined}\n style={{\n isolation: 'isolate',\n opacity: disabled ? 0.65 : undefined,\n pointerEvents: disabled ? 'none' : undefined,\n }}\n />\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);\n\nRichEditor.displayName = 'RichEditor';\n\nexport { RichEditor };\n"]}