markdown-flow-ui 0.1.100-beta.2 → 0.1.100-beta.21

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 (90) hide show
  1. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-input@1.8.0_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-input/es/BaseInput.cjs.js +1 -1
  2. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-input@1.8.0_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-input/es/BaseInput.es.js +1 -1
  3. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/ResizableTextArea.cjs.js +1 -1
  4. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/ResizableTextArea.es.js +1 -1
  5. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/TextArea.cjs.js +1 -1
  6. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/TextArea.es.js +1 -1
  7. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/index.cjs.js +1 -1
  8. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/index.es.js +1 -1
  9. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-flow@0.1.6/node_modules/remark-flow/dist/remark-custom-variable.cjs.js +1 -1
  10. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-flow@0.1.6/node_modules/remark-flow/dist/remark-custom-variable.es.js +1 -1
  11. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-flow@0.1.6/node_modules/remark-flow/dist/remark-interaction.cjs.js +1 -1
  12. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-flow@0.1.6/node_modules/remark-flow/dist/remark-interaction.es.js +1 -1
  13. package/dist/_virtual/index.cjs3.js +1 -1
  14. package/dist/_virtual/index.cjs4.js +1 -1
  15. package/dist/_virtual/index.es3.js +4 -5
  16. package/dist/_virtual/index.es3.js.map +1 -1
  17. package/dist/_virtual/index.es4.js +5 -4
  18. package/dist/_virtual/index.es4.js.map +1 -1
  19. package/dist/assets/markdown-flow-ui.css +1 -1
  20. package/dist/components/ContentRender/ContentRender.cjs.js +2 -2
  21. package/dist/components/ContentRender/ContentRender.cjs.js.map +1 -1
  22. package/dist/components/ContentRender/ContentRender.d.ts +13 -10
  23. package/dist/components/ContentRender/ContentRender.es.js +175 -158
  24. package/dist/components/ContentRender/ContentRender.es.js.map +1 -1
  25. package/dist/components/ContentRender/IframeSandbox.cjs.js +3 -3
  26. package/dist/components/ContentRender/IframeSandbox.cjs.js.map +1 -1
  27. package/dist/components/ContentRender/IframeSandbox.d.ts +1 -0
  28. package/dist/components/ContentRender/IframeSandbox.es.js +331 -202
  29. package/dist/components/ContentRender/IframeSandbox.es.js.map +1 -1
  30. package/dist/components/ContentRender/SandboxApp.cjs.js +3 -3
  31. package/dist/components/ContentRender/SandboxApp.cjs.js.map +1 -1
  32. package/dist/components/ContentRender/SandboxApp.d.ts +4 -0
  33. package/dist/components/ContentRender/SandboxApp.es.js +144 -111
  34. package/dist/components/ContentRender/SandboxApp.es.js.map +1 -1
  35. package/dist/components/ContentRender/plugins/CustomVariable.cjs.js +1 -1
  36. package/dist/components/ContentRender/plugins/CustomVariable.cjs.js.map +1 -1
  37. package/dist/components/ContentRender/plugins/CustomVariable.es.js +68 -64
  38. package/dist/components/ContentRender/plugins/CustomVariable.es.js.map +1 -1
  39. package/dist/components/MarkdownFlow/MarkdownFlow.cjs.js +1 -1
  40. package/dist/components/MarkdownFlow/MarkdownFlow.cjs.js.map +1 -1
  41. package/dist/components/MarkdownFlow/MarkdownFlow.d.ts +3 -0
  42. package/dist/components/MarkdownFlow/MarkdownFlow.es.js +19 -16
  43. package/dist/components/MarkdownFlow/MarkdownFlow.es.js.map +1 -1
  44. package/dist/components/Slide/Player.cjs.js +1 -1
  45. package/dist/components/Slide/Player.cjs.js.map +1 -1
  46. package/dist/components/Slide/Player.d.ts +1 -0
  47. package/dist/components/Slide/Player.es.js +208 -168
  48. package/dist/components/Slide/Player.es.js.map +1 -1
  49. package/dist/components/Slide/Slide.cjs.js +1 -1
  50. package/dist/components/Slide/Slide.cjs.js.map +1 -1
  51. package/dist/components/Slide/Slide.d.ts +13 -0
  52. package/dist/components/Slide/Slide.es.js +374 -255
  53. package/dist/components/Slide/Slide.es.js.map +1 -1
  54. package/dist/components/Slide/Slide.stories.d.ts +21 -1
  55. package/dist/components/Slide/index.d.ts +3 -3
  56. package/dist/components/Slide/types.d.ts +6 -6
  57. package/dist/components/Slide/useSlide.cjs.js +1 -1
  58. package/dist/components/Slide/useSlide.cjs.js.map +1 -1
  59. package/dist/components/Slide/useSlide.d.ts +4 -1
  60. package/dist/components/Slide/useSlide.es.js +115 -81
  61. package/dist/components/Slide/useSlide.es.js.map +1 -1
  62. package/dist/components/Slide/useWakePlayerFromIframe.cjs.js +2 -0
  63. package/dist/components/Slide/useWakePlayerFromIframe.cjs.js.map +1 -0
  64. package/dist/components/Slide/useWakePlayerFromIframe.d.ts +7 -0
  65. package/dist/components/Slide/useWakePlayerFromIframe.es.js +89 -0
  66. package/dist/components/Slide/useWakePlayerFromIframe.es.js.map +1 -0
  67. package/dist/components/index.d.ts +4 -2
  68. package/dist/components/ui/inputGroup/textarea.cjs.js +1 -1
  69. package/dist/components/ui/inputGroup/textarea.es.js +1 -1
  70. package/dist/index.cjs.js +1 -1
  71. package/dist/index.es.js +24 -22
  72. package/dist/lib/interaction-defaults.cjs.js +2 -0
  73. package/dist/lib/interaction-defaults.cjs.js.map +1 -0
  74. package/dist/lib/interaction-defaults.es.js +106 -0
  75. package/dist/lib/interaction-defaults.es.js.map +1 -0
  76. package/dist/lib/sandboxInteraction.cjs.js +2 -0
  77. package/dist/lib/sandboxInteraction.cjs.js.map +1 -0
  78. package/dist/lib/sandboxInteraction.d.ts +8 -0
  79. package/dist/lib/sandboxInteraction.es.js +12 -0
  80. package/dist/lib/sandboxInteraction.es.js.map +1 -0
  81. package/dist/markdown-flow-ui-lib.css +1 -1
  82. package/dist/renderer.cjs.js +1 -1
  83. package/dist/renderer.d.ts +5 -3
  84. package/dist/renderer.es.js +18 -16
  85. package/package.json +17 -2
  86. package/dist/components/Slide/interaction-defaults.cjs.js +0 -2
  87. package/dist/components/Slide/interaction-defaults.cjs.js.map +0 -1
  88. package/dist/components/Slide/interaction-defaults.es.js +0 -85
  89. package/dist/components/Slide/interaction-defaults.es.js.map +0 -1
  90. /package/dist/{components/Slide → lib}/interaction-defaults.d.ts +0 -0
@@ -1,29 +1,31 @@
1
- import { default as l } from "./components/MarkdownFlow/MarkdownFlow.es.js";
1
+ import { default as p } from "./components/MarkdownFlow/MarkdownFlow.es.js";
2
2
  import "./_virtual/jsx-runtime.es.js";
3
3
  import "react";
4
4
  /* empty css */
5
5
  import f from "./components/ContentRender/ContentRender.es.js";
6
- import { default as d } from "./components/ContentRender/IframeSandbox.es.js";
7
- import { splitContentSegments as s } from "./components/ContentRender/utils/split-content.es.js";
6
+ import { default as i } from "./components/ContentRender/IframeSandbox.es.js";
7
+ import { splitContentSegments as d } from "./components/ContentRender/utils/split-content.es.js";
8
8
  import { default as u } from "./components/ContentRender/MarkdownFlowInput.es.js";
9
9
  import { default as D } from "./components/Slide/Slide.es.js";
10
- import { default as y } from "./components/Slide/Player.es.js";
11
- import { applyDiffElement as k, applyUnifiedDiff as F, parseUnifiedDiff as I, splitDiffContent as M } from "./components/Slide/diff-utils.es.js";
12
- import "./components/Slide/interaction-defaults.es.js";
13
- import { default as b } from "./components/Slide/useSlide.es.js";
10
+ import { default as w } from "./components/Slide/Player.es.js";
11
+ import { applyDiffElement as c, applyUnifiedDiff as g, parseUnifiedDiff as y, splitDiffContent as C } from "./components/Slide/diff-utils.es.js";
12
+ import { getInteractionDefaultSelectedValues as F, getInteractionDefaultValues as M } from "./lib/interaction-defaults.es.js";
13
+ import { default as V } from "./components/Slide/useSlide.es.js";
14
14
  export {
15
15
  f as ContentRender,
16
- d as IframeSandbox,
17
- l as MarkdownFlow,
16
+ i as IframeSandbox,
17
+ p as MarkdownFlow,
18
18
  u as MarkdownFlowInput,
19
- y as Player,
19
+ w as Player,
20
20
  D as Slide,
21
- k as applyDiffElement,
22
- F as applyUnifiedDiff,
21
+ c as applyDiffElement,
22
+ g as applyUnifiedDiff,
23
23
  f as default,
24
- I as parseUnifiedDiff,
25
- s as splitContentSegments,
26
- M as splitDiffContent,
27
- b as useSlide
24
+ F as getInteractionDefaultSelectedValues,
25
+ M as getInteractionDefaultValues,
26
+ y as parseUnifiedDiff,
27
+ d as splitContentSegments,
28
+ C as splitDiffContent,
29
+ V as useSlide
28
30
  };
29
31
  //# sourceMappingURL=renderer.es.js.map
package/package.json CHANGED
@@ -124,6 +124,7 @@
124
124
  },
125
125
  "main": "dist/index.cjs.js",
126
126
  "module": "dist/index.es.js",
127
+ "types": "dist/index.d.ts",
127
128
  "name": "markdown-flow-ui",
128
129
  "packageManager": "pnpm@10.14.0+sha512.ad27a79641b49c3e481a16a805baa71817a04bbe06a38d17e60e2eaee83f6a146c6a688125f5792e48dd5ba30e7da52a5cda4c3992b9ccf333f9ce223af84748",
129
130
  "peerDependencies": {
@@ -154,9 +155,23 @@
154
155
  "prepublishOnly": "npm run build",
155
156
  "start": "next start",
156
157
  "storybook": "storybook dev -p 6006",
157
- "test": "echo \"No tests specified\" && exit 0"
158
+ "test": "echo \"No tests specified\" && exit 0",
159
+ "typecheck:exports": "pnpm exec tsc -p tsconfig.exports.json --pretty false"
158
160
  },
159
- "version": "0.1.100-beta.2",
161
+ "typesVersions": {
162
+ "*": {
163
+ "editor": [
164
+ "dist/editor.d.ts"
165
+ ],
166
+ "render": [
167
+ "dist/renderer.d.ts"
168
+ ],
169
+ "renderer": [
170
+ "dist/renderer.d.ts"
171
+ ]
172
+ }
173
+ },
174
+ "version": "0.1.100-beta.21",
160
175
  "type": "module",
161
176
  "exports": {
162
177
  ".": {
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("../../_virtual/index.cjs.js"),x=m.distExports.createInteractionParser(),v=e=>{if(!e)return null;try{return x.parseToRemarkFormat(e)}catch(n){return console.warn("Failed to parse interaction block",n),null}},f=(e,n)=>{if(!e)return null;const u=e.trim(),t=n.buttonValues||[],r=n.buttonTexts||[],s=t.indexOf(u);if(s>-1)return{value:t[s],display:r[s]};const l=r.indexOf(u);return l>-1?{value:t[l]||r[l],display:r[l]}:null},I=e=>e.split(/[,,\n]/).map(n=>n.trim()).filter(Boolean),T=(e,n,u,t)=>t?.resolveDefaultValues?.({content:e,rawValue:n,interactionInfo:u})??null,p=(e,n,u)=>{const t=n?.toString().trim();if(!t)return{};const r=v(e),s=T(e,t,r,u);if(s)return s;if(!r)return{buttonText:t,inputText:t};if(r.isMultiSelect){const c=I(t);if(!c.length)return{};const o=[],a=[];return c.forEach(i=>{const d=f(i,r);if(d){o.push(d.value);return}if(r.placeholder){a.push(i);return}o.push(i)}),{selectedValues:o.length?o:void 0,inputText:a.length?a.join(", "):void 0}}const l=f(t,r);return l?{buttonText:l.value||l.display||t}:r.placeholder?{inputText:t}:{buttonText:t,inputText:t}},V=(e,n,u)=>{const t=p(e,n,u);return t.selectedValues?t.selectedValues:n?n.split(",").map(r=>r.trim()).filter(Boolean):void 0};exports.getInteractionDefaultSelectedValues=V;exports.getInteractionDefaultValues=p;
2
- //# sourceMappingURL=interaction-defaults.cjs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interaction-defaults.cjs.js","sources":["../../../src/components/Slide/interaction-defaults.ts"],"sourcesContent":["import { createInteractionParser } from \"remark-flow\";\n\nexport interface InteractionParseResult {\n buttonTexts?: string[];\n buttonValues?: string[];\n placeholder?: string;\n variableName?: string;\n isMultiSelect?: boolean;\n}\n\nexport interface InteractionDefaultValues {\n buttonText?: string;\n inputText?: string;\n selectedValues?: string[];\n}\n\nexport interface InteractionDefaultResolverParams {\n content?: string | null;\n rawValue?: string | null;\n interactionInfo?: InteractionParseResult | null;\n}\n\nexport type InteractionDefaultResolver = (\n params: InteractionDefaultResolverParams\n) => InteractionDefaultValues | null | undefined;\n\nexport interface InteractionDefaultValueOptions {\n resolveDefaultValues?: InteractionDefaultResolver;\n}\n\nconst interactionParser = createInteractionParser();\n\nconst parseInteractionBlock = (\n content?: string | null\n): InteractionParseResult | null => {\n if (!content) {\n return null;\n }\n\n try {\n return interactionParser.parseToRemarkFormat(\n content\n ) as InteractionParseResult;\n } catch (error) {\n console.warn(\"Failed to parse interaction block\", error);\n return null;\n }\n};\n\nconst normalizeButtonValue = (\n token: string,\n info: InteractionParseResult\n): { value: string; display?: string } | null => {\n if (!token) {\n return null;\n }\n\n const cleaned = token.trim();\n const buttonValues = info.buttonValues || [];\n const buttonTexts = info.buttonTexts || [];\n const valueIndex = buttonValues.indexOf(cleaned);\n\n if (valueIndex > -1) {\n return {\n value: buttonValues[valueIndex],\n display: buttonTexts[valueIndex],\n };\n }\n\n const textIndex = buttonTexts.indexOf(cleaned);\n\n if (textIndex > -1) {\n return {\n value: buttonValues[textIndex] || buttonTexts[textIndex],\n display: buttonTexts[textIndex],\n };\n }\n\n return null;\n};\n\nconst splitPresetValues = (raw: string) => {\n return raw\n .split(/[,,\\n]/)\n .map((item) => item.trim())\n .filter(Boolean);\n};\n\nconst resolveCustomInteractionDefaults = (\n content?: string | null,\n rawValue?: string | null,\n interactionInfo?: InteractionParseResult | null,\n options?: InteractionDefaultValueOptions\n) => {\n return (\n options?.resolveDefaultValues?.({\n content,\n rawValue,\n interactionInfo,\n }) ?? null\n );\n};\n\nexport const getInteractionDefaultValues = (\n content?: string | null,\n rawValue?: string | null,\n options?: InteractionDefaultValueOptions\n): InteractionDefaultValues => {\n const normalized = rawValue?.toString().trim();\n\n if (!normalized) {\n return {};\n }\n\n const interactionInfo = parseInteractionBlock(content);\n const customDefaults = resolveCustomInteractionDefaults(\n content,\n normalized,\n interactionInfo,\n options\n );\n\n if (customDefaults) {\n return customDefaults;\n }\n\n if (!interactionInfo) {\n return {\n buttonText: normalized,\n inputText: normalized,\n };\n }\n\n if (interactionInfo.isMultiSelect) {\n const tokens = splitPresetValues(normalized);\n\n if (!tokens.length) {\n return {};\n }\n\n const selectedValues: string[] = [];\n const customInputs: string[] = [];\n\n tokens.forEach((token) => {\n const mapped = normalizeButtonValue(token, interactionInfo);\n\n if (mapped) {\n selectedValues.push(mapped.value);\n return;\n }\n\n if (interactionInfo.placeholder) {\n customInputs.push(token);\n return;\n }\n\n selectedValues.push(token);\n });\n\n return {\n selectedValues: selectedValues.length ? selectedValues : undefined,\n inputText: customInputs.length ? customInputs.join(\", \") : undefined,\n };\n }\n\n const mapped = normalizeButtonValue(normalized, interactionInfo);\n\n if (mapped) {\n return {\n buttonText: mapped.value || mapped.display || normalized,\n };\n }\n\n if (interactionInfo.placeholder) {\n return {\n inputText: normalized,\n };\n }\n\n return {\n buttonText: normalized,\n inputText: normalized,\n };\n};\n\nexport const getInteractionDefaultSelectedValues = (\n content?: string | null,\n rawValue?: string | null,\n options?: InteractionDefaultValueOptions\n) => {\n const defaults = getInteractionDefaultValues(content, rawValue, options);\n\n if (defaults.selectedValues) {\n return defaults.selectedValues;\n }\n\n return rawValue\n ? rawValue\n .split(\",\")\n .map((value) => value.trim())\n .filter(Boolean)\n : undefined;\n};\n"],"names":["interactionParser","createInteractionParser","parseInteractionBlock","content","error","normalizeButtonValue","token","info","cleaned","buttonValues","buttonTexts","valueIndex","textIndex","splitPresetValues","raw","item","resolveCustomInteractionDefaults","rawValue","interactionInfo","options","getInteractionDefaultValues","normalized","customDefaults","tokens","selectedValues","customInputs","mapped","getInteractionDefaultSelectedValues","defaults","value"],"mappings":"+HA8BMA,EAAoBC,EAAAA,YAAAA,wBAAA,EAEpBC,EACJC,GACkC,CAClC,GAAI,CAACA,EACH,OAAO,KAGT,GAAI,CACF,OAAOH,EAAkB,oBACvBG,CAAA,CAEJ,OAASC,EAAO,CACd,eAAQ,KAAK,oCAAqCA,CAAK,EAChD,IACT,CACF,EAEMC,EAAuB,CAC3BC,EACAC,IAC+C,CAC/C,GAAI,CAACD,EACH,OAAO,KAGT,MAAME,EAAUF,EAAM,KAAA,EAChBG,EAAeF,EAAK,cAAgB,CAAA,EACpCG,EAAcH,EAAK,aAAe,CAAA,EAClCI,EAAaF,EAAa,QAAQD,CAAO,EAE/C,GAAIG,EAAa,GACf,MAAO,CACL,MAAOF,EAAaE,CAAU,EAC9B,QAASD,EAAYC,CAAU,CAAA,EAInC,MAAMC,EAAYF,EAAY,QAAQF,CAAO,EAE7C,OAAII,EAAY,GACP,CACL,MAAOH,EAAaG,CAAS,GAAKF,EAAYE,CAAS,EACvD,QAASF,EAAYE,CAAS,CAAA,EAI3B,IACT,EAEMC,EAAqBC,GAClBA,EACJ,MAAM,QAAQ,EACd,IAAKC,GAASA,EAAK,KAAA,CAAM,EACzB,OAAO,OAAO,EAGbC,EAAmC,CACvCb,EACAc,EACAC,EACAC,IAGEA,GAAS,uBAAuB,CAC9B,QAAAhB,EACA,SAAAc,EACA,gBAAAC,CAAA,CACD,GAAK,KAIGE,EAA8B,CACzCjB,EACAc,EACAE,IAC6B,CAC7B,MAAME,EAAaJ,GAAU,SAAA,EAAW,KAAA,EAExC,GAAI,CAACI,EACH,MAAO,CAAA,EAGT,MAAMH,EAAkBhB,EAAsBC,CAAO,EAC/CmB,EAAiBN,EACrBb,EACAkB,EACAH,EACAC,CAAA,EAGF,GAAIG,EACF,OAAOA,EAGT,GAAI,CAACJ,EACH,MAAO,CACL,WAAYG,EACZ,UAAWA,CAAA,EAIf,GAAIH,EAAgB,cAAe,CACjC,MAAMK,EAASV,EAAkBQ,CAAU,EAE3C,GAAI,CAACE,EAAO,OACV,MAAO,CAAA,EAGT,MAAMC,EAA2B,CAAA,EAC3BC,EAAyB,CAAA,EAE/B,OAAAF,EAAO,QAASjB,GAAU,CACxB,MAAMoB,EAASrB,EAAqBC,EAAOY,CAAe,EAE1D,GAAIQ,EAAQ,CACVF,EAAe,KAAKE,EAAO,KAAK,EAChC,MACF,CAEA,GAAIR,EAAgB,YAAa,CAC/BO,EAAa,KAAKnB,CAAK,EACvB,MACF,CAEAkB,EAAe,KAAKlB,CAAK,CAC3B,CAAC,EAEM,CACL,eAAgBkB,EAAe,OAASA,EAAiB,OACzD,UAAWC,EAAa,OAASA,EAAa,KAAK,IAAI,EAAI,MAAA,CAE/D,CAEA,MAAMC,EAASrB,EAAqBgB,EAAYH,CAAe,EAE/D,OAAIQ,EACK,CACL,WAAYA,EAAO,OAASA,EAAO,SAAWL,CAAA,EAI9CH,EAAgB,YACX,CACL,UAAWG,CAAA,EAIR,CACL,WAAYA,EACZ,UAAWA,CAAA,CAEf,EAEaM,EAAsC,CACjDxB,EACAc,EACAE,IACG,CACH,MAAMS,EAAWR,EAA4BjB,EAASc,EAAUE,CAAO,EAEvE,OAAIS,EAAS,eACJA,EAAS,eAGXX,EACHA,EACG,MAAM,GAAG,EACT,IAAKY,GAAUA,EAAM,KAAA,CAAM,EAC3B,OAAO,OAAO,EACjB,MACN"}
@@ -1,85 +0,0 @@
1
- import { d } from "../../_virtual/index.es.js";
2
- const m = d.createInteractionParser(), x = (e) => {
3
- if (!e)
4
- return null;
5
- try {
6
- return m.parseToRemarkFormat(
7
- e
8
- );
9
- } catch (n) {
10
- return console.warn("Failed to parse interaction block", n), null;
11
- }
12
- }, f = (e, n) => {
13
- if (!e)
14
- return null;
15
- const s = e.trim(), t = n.buttonValues || [], r = n.buttonTexts || [], o = t.indexOf(s);
16
- if (o > -1)
17
- return {
18
- value: t[o],
19
- display: r[o]
20
- };
21
- const u = r.indexOf(s);
22
- return u > -1 ? {
23
- value: t[u] || r[u],
24
- display: r[u]
25
- } : null;
26
- }, h = (e) => e.split(/[,,\n]/).map((n) => n.trim()).filter(Boolean), v = (e, n, s, t) => t?.resolveDefaultValues?.({
27
- content: e,
28
- rawValue: n,
29
- interactionInfo: s
30
- }) ?? null, T = (e, n, s) => {
31
- const t = n?.toString().trim();
32
- if (!t)
33
- return {};
34
- const r = x(e), o = v(
35
- e,
36
- t,
37
- r,
38
- s
39
- );
40
- if (o)
41
- return o;
42
- if (!r)
43
- return {
44
- buttonText: t,
45
- inputText: t
46
- };
47
- if (r.isMultiSelect) {
48
- const c = h(t);
49
- if (!c.length)
50
- return {};
51
- const l = [], i = [];
52
- return c.forEach((a) => {
53
- const p = f(a, r);
54
- if (p) {
55
- l.push(p.value);
56
- return;
57
- }
58
- if (r.placeholder) {
59
- i.push(a);
60
- return;
61
- }
62
- l.push(a);
63
- }), {
64
- selectedValues: l.length ? l : void 0,
65
- inputText: i.length ? i.join(", ") : void 0
66
- };
67
- }
68
- const u = f(t, r);
69
- return u ? {
70
- buttonText: u.value || u.display || t
71
- } : r.placeholder ? {
72
- inputText: t
73
- } : {
74
- buttonText: t,
75
- inputText: t
76
- };
77
- }, V = (e, n, s) => {
78
- const t = T(e, n, s);
79
- return t.selectedValues ? t.selectedValues : n ? n.split(",").map((r) => r.trim()).filter(Boolean) : void 0;
80
- };
81
- export {
82
- V as getInteractionDefaultSelectedValues,
83
- T as getInteractionDefaultValues
84
- };
85
- //# sourceMappingURL=interaction-defaults.es.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interaction-defaults.es.js","sources":["../../../src/components/Slide/interaction-defaults.ts"],"sourcesContent":["import { createInteractionParser } from \"remark-flow\";\n\nexport interface InteractionParseResult {\n buttonTexts?: string[];\n buttonValues?: string[];\n placeholder?: string;\n variableName?: string;\n isMultiSelect?: boolean;\n}\n\nexport interface InteractionDefaultValues {\n buttonText?: string;\n inputText?: string;\n selectedValues?: string[];\n}\n\nexport interface InteractionDefaultResolverParams {\n content?: string | null;\n rawValue?: string | null;\n interactionInfo?: InteractionParseResult | null;\n}\n\nexport type InteractionDefaultResolver = (\n params: InteractionDefaultResolverParams\n) => InteractionDefaultValues | null | undefined;\n\nexport interface InteractionDefaultValueOptions {\n resolveDefaultValues?: InteractionDefaultResolver;\n}\n\nconst interactionParser = createInteractionParser();\n\nconst parseInteractionBlock = (\n content?: string | null\n): InteractionParseResult | null => {\n if (!content) {\n return null;\n }\n\n try {\n return interactionParser.parseToRemarkFormat(\n content\n ) as InteractionParseResult;\n } catch (error) {\n console.warn(\"Failed to parse interaction block\", error);\n return null;\n }\n};\n\nconst normalizeButtonValue = (\n token: string,\n info: InteractionParseResult\n): { value: string; display?: string } | null => {\n if (!token) {\n return null;\n }\n\n const cleaned = token.trim();\n const buttonValues = info.buttonValues || [];\n const buttonTexts = info.buttonTexts || [];\n const valueIndex = buttonValues.indexOf(cleaned);\n\n if (valueIndex > -1) {\n return {\n value: buttonValues[valueIndex],\n display: buttonTexts[valueIndex],\n };\n }\n\n const textIndex = buttonTexts.indexOf(cleaned);\n\n if (textIndex > -1) {\n return {\n value: buttonValues[textIndex] || buttonTexts[textIndex],\n display: buttonTexts[textIndex],\n };\n }\n\n return null;\n};\n\nconst splitPresetValues = (raw: string) => {\n return raw\n .split(/[,,\\n]/)\n .map((item) => item.trim())\n .filter(Boolean);\n};\n\nconst resolveCustomInteractionDefaults = (\n content?: string | null,\n rawValue?: string | null,\n interactionInfo?: InteractionParseResult | null,\n options?: InteractionDefaultValueOptions\n) => {\n return (\n options?.resolveDefaultValues?.({\n content,\n rawValue,\n interactionInfo,\n }) ?? null\n );\n};\n\nexport const getInteractionDefaultValues = (\n content?: string | null,\n rawValue?: string | null,\n options?: InteractionDefaultValueOptions\n): InteractionDefaultValues => {\n const normalized = rawValue?.toString().trim();\n\n if (!normalized) {\n return {};\n }\n\n const interactionInfo = parseInteractionBlock(content);\n const customDefaults = resolveCustomInteractionDefaults(\n content,\n normalized,\n interactionInfo,\n options\n );\n\n if (customDefaults) {\n return customDefaults;\n }\n\n if (!interactionInfo) {\n return {\n buttonText: normalized,\n inputText: normalized,\n };\n }\n\n if (interactionInfo.isMultiSelect) {\n const tokens = splitPresetValues(normalized);\n\n if (!tokens.length) {\n return {};\n }\n\n const selectedValues: string[] = [];\n const customInputs: string[] = [];\n\n tokens.forEach((token) => {\n const mapped = normalizeButtonValue(token, interactionInfo);\n\n if (mapped) {\n selectedValues.push(mapped.value);\n return;\n }\n\n if (interactionInfo.placeholder) {\n customInputs.push(token);\n return;\n }\n\n selectedValues.push(token);\n });\n\n return {\n selectedValues: selectedValues.length ? selectedValues : undefined,\n inputText: customInputs.length ? customInputs.join(\", \") : undefined,\n };\n }\n\n const mapped = normalizeButtonValue(normalized, interactionInfo);\n\n if (mapped) {\n return {\n buttonText: mapped.value || mapped.display || normalized,\n };\n }\n\n if (interactionInfo.placeholder) {\n return {\n inputText: normalized,\n };\n }\n\n return {\n buttonText: normalized,\n inputText: normalized,\n };\n};\n\nexport const getInteractionDefaultSelectedValues = (\n content?: string | null,\n rawValue?: string | null,\n options?: InteractionDefaultValueOptions\n) => {\n const defaults = getInteractionDefaultValues(content, rawValue, options);\n\n if (defaults.selectedValues) {\n return defaults.selectedValues;\n }\n\n return rawValue\n ? rawValue\n .split(\",\")\n .map((value) => value.trim())\n .filter(Boolean)\n : undefined;\n};\n"],"names":["interactionParser","createInteractionParser","parseInteractionBlock","content","error","normalizeButtonValue","token","info","cleaned","buttonValues","buttonTexts","valueIndex","textIndex","splitPresetValues","raw","item","resolveCustomInteractionDefaults","rawValue","interactionInfo","options","getInteractionDefaultValues","normalized","customDefaults","tokens","selectedValues","customInputs","mapped","getInteractionDefaultSelectedValues","defaults","value"],"mappings":";AA8BA,MAAMA,IAAoBC,EAAAA,wBAAA,GAEpBC,IAAwB,CAC5BC,MACkC;AAClC,MAAI,CAACA;AACH,WAAO;AAGT,MAAI;AACF,WAAOH,EAAkB;AAAA,MACvBG;AAAA,IAAA;AAAA,EAEJ,SAASC,GAAO;AACd,mBAAQ,KAAK,qCAAqCA,CAAK,GAChD;AAAA,EACT;AACF,GAEMC,IAAuB,CAC3BC,GACAC,MAC+C;AAC/C,MAAI,CAACD;AACH,WAAO;AAGT,QAAME,IAAUF,EAAM,KAAA,GAChBG,IAAeF,EAAK,gBAAgB,CAAA,GACpCG,IAAcH,EAAK,eAAe,CAAA,GAClCI,IAAaF,EAAa,QAAQD,CAAO;AAE/C,MAAIG,IAAa;AACf,WAAO;AAAA,MACL,OAAOF,EAAaE,CAAU;AAAA,MAC9B,SAASD,EAAYC,CAAU;AAAA,IAAA;AAInC,QAAMC,IAAYF,EAAY,QAAQF,CAAO;AAE7C,SAAII,IAAY,KACP;AAAA,IACL,OAAOH,EAAaG,CAAS,KAAKF,EAAYE,CAAS;AAAA,IACvD,SAASF,EAAYE,CAAS;AAAA,EAAA,IAI3B;AACT,GAEMC,IAAoB,CAACC,MAClBA,EACJ,MAAM,QAAQ,EACd,IAAI,CAACC,MAASA,EAAK,KAAA,CAAM,EACzB,OAAO,OAAO,GAGbC,IAAmC,CACvCb,GACAc,GACAC,GACAC,MAGEA,GAAS,uBAAuB;AAAA,EAC9B,SAAAhB;AAAA,EACA,UAAAc;AAAA,EACA,iBAAAC;AAAA,CACD,KAAK,MAIGE,IAA8B,CACzCjB,GACAc,GACAE,MAC6B;AAC7B,QAAME,IAAaJ,GAAU,SAAA,EAAW,KAAA;AAExC,MAAI,CAACI;AACH,WAAO,CAAA;AAGT,QAAMH,IAAkBhB,EAAsBC,CAAO,GAC/CmB,IAAiBN;AAAA,IACrBb;AAAA,IACAkB;AAAA,IACAH;AAAA,IACAC;AAAA,EAAA;AAGF,MAAIG;AACF,WAAOA;AAGT,MAAI,CAACJ;AACH,WAAO;AAAA,MACL,YAAYG;AAAA,MACZ,WAAWA;AAAA,IAAA;AAIf,MAAIH,EAAgB,eAAe;AACjC,UAAMK,IAASV,EAAkBQ,CAAU;AAE3C,QAAI,CAACE,EAAO;AACV,aAAO,CAAA;AAGT,UAAMC,IAA2B,CAAA,GAC3BC,IAAyB,CAAA;AAE/B,WAAAF,EAAO,QAAQ,CAACjB,MAAU;AACxB,YAAMoB,IAASrB,EAAqBC,GAAOY,CAAe;AAE1D,UAAIQ,GAAQ;AACV,QAAAF,EAAe,KAAKE,EAAO,KAAK;AAChC;AAAA,MACF;AAEA,UAAIR,EAAgB,aAAa;AAC/B,QAAAO,EAAa,KAAKnB,CAAK;AACvB;AAAA,MACF;AAEA,MAAAkB,EAAe,KAAKlB,CAAK;AAAA,IAC3B,CAAC,GAEM;AAAA,MACL,gBAAgBkB,EAAe,SAASA,IAAiB;AAAA,MACzD,WAAWC,EAAa,SAASA,EAAa,KAAK,IAAI,IAAI;AAAA,IAAA;AAAA,EAE/D;AAEA,QAAMC,IAASrB,EAAqBgB,GAAYH,CAAe;AAE/D,SAAIQ,IACK;AAAA,IACL,YAAYA,EAAO,SAASA,EAAO,WAAWL;AAAA,EAAA,IAI9CH,EAAgB,cACX;AAAA,IACL,WAAWG;AAAA,EAAA,IAIR;AAAA,IACL,YAAYA;AAAA,IACZ,WAAWA;AAAA,EAAA;AAEf,GAEaM,IAAsC,CACjDxB,GACAc,GACAE,MACG;AACH,QAAMS,IAAWR,EAA4BjB,GAASc,GAAUE,CAAO;AAEvE,SAAIS,EAAS,iBACJA,EAAS,iBAGXX,IACHA,EACG,MAAM,GAAG,EACT,IAAI,CAACY,MAAUA,EAAM,KAAA,CAAM,EAC3B,OAAO,OAAO,IACjB;AACN;"}