@anker-in/campaign-ui 0.5.0 → 0.5.1-beta.2
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/cjs/components/LiveChatWidget/components/MessageContent/FAQList.js +1 -1
- package/dist/cjs/components/LiveChatWidget/components/MessageContent/FAQList.js.map +3 -3
- package/dist/cjs/components/LiveChatWidget/components/MessageContent/PolicyBlock.js +2 -2
- package/dist/cjs/components/LiveChatWidget/components/MessageContent/PolicyBlock.js.map +2 -2
- package/dist/cjs/components/LiveChatWidget/components/MessageContent/TextBlock.js +1 -1
- package/dist/cjs/components/LiveChatWidget/components/MessageContent/TextBlock.js.map +2 -2
- package/dist/cjs/components/credits/context/hooks/useSubscribed.js.map +2 -2
- package/dist/cjs/components/index.d.ts +2 -2
- package/dist/cjs/components/index.js +1 -1
- package/dist/cjs/components/index.js.map +2 -2
- package/dist/cjs/stories/CartCard.stories.d.ts +33 -0
- package/dist/cjs/stories/CartCard.stories.js +21 -0
- package/dist/cjs/stories/CartCard.stories.js.map +7 -0
- package/dist/esm/components/LiveChatWidget/components/MessageContent/FAQList.js +1 -1
- package/dist/esm/components/LiveChatWidget/components/MessageContent/FAQList.js.map +3 -3
- package/dist/esm/components/LiveChatWidget/components/MessageContent/PolicyBlock.js +2 -2
- package/dist/esm/components/LiveChatWidget/components/MessageContent/PolicyBlock.js.map +2 -2
- package/dist/esm/components/LiveChatWidget/components/MessageContent/TextBlock.js +1 -1
- package/dist/esm/components/LiveChatWidget/components/MessageContent/TextBlock.js.map +2 -2
- package/dist/esm/components/credits/context/hooks/useSubscribed.js.map +2 -2
- package/dist/esm/components/index.d.ts +2 -2
- package/dist/esm/components/index.js +1 -1
- package/dist/esm/components/index.js.map +2 -2
- package/dist/esm/stories/CartCard.stories.d.ts +33 -0
- package/dist/esm/stories/CartCard.stories.js +21 -0
- package/dist/esm/stories/CartCard.stories.js.map +7 -0
- package/package.json +20 -19
- package/src/components/LiveChatWidget/components/MessageContent/FAQList.tsx +15 -1
- package/src/components/LiveChatWidget/components/MessageContent/PolicyBlock.tsx +8 -0
- package/src/components/LiveChatWidget/components/MessageContent/TextBlock.tsx +3 -1
- package/src/components/credits/context/hooks/useSubscribed.ts +1 -0
- package/src/components/index.ts +2 -2
- package/src/stories/CartCard.stories.tsx +459 -0
- package/src/styles/livechat.css +15 -3
- package/dist/cjs/components/memberPopup/panels/EarnCredits/CompleteProfileModal.d.ts +0 -10
- package/dist/cjs/components/memberPopup/panels/EarnCredits/CompleteProfileModal.js +0 -2
- package/dist/cjs/components/memberPopup/panels/EarnCredits/CompleteProfileModal.js.map +0 -7
- package/dist/esm/components/memberPopup/panels/EarnCredits/CompleteProfileModal.d.ts +0 -10
- package/dist/esm/components/memberPopup/panels/EarnCredits/CompleteProfileModal.js +0 -2
- package/dist/esm/components/memberPopup/panels/EarnCredits/CompleteProfileModal.js.map +0 -7
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var N=Object.create;var d=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var
|
|
1
|
+
"use strict";var N=Object.create;var d=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var Q=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty;var A=(t,n)=>{for(var a in n)d(t,a,{get:n[a],enumerable:!0})},m=(t,n,a,l)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of h(n))!C.call(t,o)&&o!==a&&d(t,o,{get:()=>n[o],enumerable:!(l=w(n,o))||l.enumerable});return t};var u=(t,n,a)=>(a=t!=null?N(Q(t)):{},m(n||!t||!t.__esModule?d(a,"default",{value:t,enumerable:!0}):a,t)),L=t=>m(d({},"__esModule",{value:!0}),t);var M={};A(M,{FAQList:()=>f,FAQListRenderer:()=>R});module.exports=L(M);var e=require("react/jsx-runtime"),g=require("react"),x=u(require("react-markdown")),v=u(require("remark-gfm"));const R={render:t=>t.type!=="faq_list"?null:(0,e.jsx)(f,{content:t})},f=({content:t,onQuestionClick:n})=>{const{found:a,count:l,total:o,results:p}=t.data,[b,k]=(0,g.useState)(new Set);if(!a||p.length===0)return(0,e.jsx)("div",{className:"rounded-lg border border-gray-200 bg-white p-4",children:(0,e.jsx)("p",{className:"text-sm text-gray-500",children:"\u672A\u627E\u5230\u76F8\u5173\u95EE\u9898"})});const y=s=>{k(i=>{const r=new Set(i);return r.has(s)?r.delete(s):r.add(s),r})},F=s=>{n?.(s)};return(0,e.jsx)("div",{className:"space-y-2",children:(0,e.jsx)("div",{className:"space-y-2",children:p.map(s=>{const i=b.has(s.id);return(0,e.jsxs)("div",{className:"overflow-hidden rounded-2xl bg-[#F5F6F7] transition-all",children:[(0,e.jsxs)("button",{onClick:()=>y(s.id),className:"flex w-full items-center justify-between gap-3 p-4 text-left transition-colors ",children:[(0,e.jsx)("div",{className:"flex-1",children:(0,e.jsx)("div",{className:"flex items-center gap-2",children:(0,e.jsx)("span",{className:"text-base font-bold leading-[1.4] tracking-[-0.02em] text-[#080A0F]",children:s.question})})}),(0,e.jsx)("svg",{className:`size-5 shrink-0 text-[#080A0F] transition-transform ${i?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),i&&(0,e.jsxs)("div",{className:" bg-[#F5F6F7] px-4 py-3 pt-0",children:[(0,e.jsx)("div",{className:"prose prose-sm max-w-none border-t border-gray-100 text-sm font-bold leading-[1.4] tracking-[-0.02em] text-[#4A4C56]",style:{paddingTop:"12px"},children:(0,e.jsx)(x.default,{remarkPlugins:[v.default],components:{a:({node:r,...c})=>(0,e.jsx)("a",{...c,className:"livechat-link livechat-link-bot",target:"_blank",rel:"noopener noreferrer"})},children:s.answer})}),s.relatedQuestions&&s.relatedQuestions.length>0&&(0,e.jsxs)("div",{className:"mt-4 border-t border-gray-200 pt-3",children:[(0,e.jsx)("p",{className:"mb-2 text-xs font-medium text-gray-500",children:"You may also want to know:"}),(0,e.jsx)("div",{className:"space-y-1",children:s.relatedQuestions.map((r,c)=>(0,e.jsx)("button",{onClick:()=>F(r),className:"block w-full text-left text-xs text-blue-600 hover:text-blue-700 hover:underline",children:r},c))})]})]})]},s.id)})})})};
|
|
2
2
|
//# sourceMappingURL=FAQList.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/components/LiveChatWidget/components/MessageContent/FAQList.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * FAQ \u5217\u8868\u7EC4\u4EF6\n * \u663E\u793A\u5E38\u89C1\u95EE\u9898\u5217\u8868\uFF0C\u652F\u6301\u6298\u53E0/\u5C55\u5F00\n */\n\nimport React, { useState } from 'react'\nimport ReactMarkdown from 'react-markdown'\nimport remarkGfm from 'remark-gfm'\nimport type { FAQListContent, FAQItem, MessageRenderer, MessageContent } from '../../types'\n\nexport interface FAQListProps {\n content: FAQListContent\n onQuestionClick?: (question: string) => void\n}\n\n/**\n * FAQ \u5217\u8868\u6E32\u67D3\u5668\n * \u7528\u4E8E\u6CE8\u518C\u5230 MessageRendererRegistry\n */\nexport const FAQListRenderer: MessageRenderer = {\n render: (content: MessageContent) => {\n if (content.type !== 'faq_list') {\n return null\n }\n return <FAQList content={content as FAQListContent} />\n },\n}\n\nexport const FAQList: React.FC<FAQListProps> = ({ content, onQuestionClick }) => {\n const { found, count, total, results } = content.data\n const [expandedIds, setExpandedIds] = useState<Set<string>>(new Set())\n\n // \u5982\u679C\u6CA1\u6709\u627E\u5230\u7ED3\u679C\n if (!found || results.length === 0) {\n return (\n <div className=\"rounded-lg border border-gray-200 bg-white p-4\">\n <p className=\"text-sm text-gray-500\">\u672A\u627E\u5230\u76F8\u5173\u95EE\u9898</p>\n </div>\n )\n }\n\n // \u5207\u6362\u5C55\u5F00/\u6298\u53E0\n const toggleExpand = (id: string) => {\n setExpandedIds(prev => {\n const newSet = new Set(prev)\n if (newSet.has(id)) {\n newSet.delete(id)\n } else {\n newSet.add(id)\n }\n return newSet\n })\n }\n\n // \u5904\u7406\u76F8\u5173\u95EE\u9898\u70B9\u51FB\n const handleRelatedQuestionClick = (question: string) => {\n onQuestionClick?.(question)\n }\n\n return (\n <div className=\"space-y-2\">\n {/* FAQ \u5217\u8868 */}\n <div className=\"space-y-2\">\n {results.map(item => {\n const isExpanded = expandedIds.has(item.id)\n\n return (\n <div key={item.id} className=\"overflow-hidden rounded-2xl bg-[#F5F6F7] transition-all\">\n {/* \u95EE\u9898\u6807\u9898 - \u53EF\u70B9\u51FB\u5C55\u5F00/\u6298\u53E0 */}\n <button\n onClick={() => toggleExpand(item.id)}\n className=\"flex w-full items-center justify-between gap-3 p-4 text-left transition-colors \"\n >\n <div className=\"flex-1\">\n <div className=\"flex items-center gap-2\">\n <span className=\"text-base font-bold leading-[1.4] tracking-[-0.02em] text-[#080A0F]\">\n {item.question}\n </span>\n </div>\n </div>\n\n {/* \u5C55\u5F00/\u6298\u53E0\u56FE\u6807 */}\n <svg\n className={`size-5 shrink-0 text-[#080A0F] transition-transform ${isExpanded ? 'rotate-180' : ''}`}\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M19 9l-7 7-7-7\" />\n </svg>\n </button>\n\n {/* \u7B54\u6848\u5185\u5BB9 - \u5C55\u5F00\u65F6\u663E\u793A */}\n {isExpanded && (\n <div className=\" bg-[#F5F6F7] px-4 py-3 pt-0\">\n <div\n className=\"prose prose-sm max-w-none border-t border-gray-100 text-sm font-bold leading-[1.4] tracking-[-0.02em] text-[#4A4C56]\"\n style={{ paddingTop: '12px' }}\n >\n <ReactMarkdown
|
|
5
|
-
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,oBAAAC,IAAA,eAAAC,EAAAJ,GAwBW,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,EACxF,GACF,EAGCA,MACC,QAAC,OAAI,UAAU,+BACb,oBAAC,OACC,UAAU,wHACV,MAAO,CAAE,WAAY,MAAO,EAE5B,mBAAC,EAAAC,QAAA,
|
|
6
|
-
"names": ["FAQList_exports", "__export", "FAQList", "FAQListRenderer", "__toCommonJS", "import_jsx_runtime", "import_react", "import_react_markdown", "import_remark_gfm", "content", "onQuestionClick", "found", "count", "total", "results", "expandedIds", "setExpandedIds", "toggleExpand", "id", "prev", "newSet", "handleRelatedQuestionClick", "question", "item", "isExpanded", "ReactMarkdown", "remarkGfm", "q", "idx"]
|
|
4
|
+
"sourcesContent": ["/**\n * FAQ \u5217\u8868\u7EC4\u4EF6\n * \u663E\u793A\u5E38\u89C1\u95EE\u9898\u5217\u8868\uFF0C\u652F\u6301\u6298\u53E0/\u5C55\u5F00\n */\n\nimport React, { useState } from 'react'\nimport ReactMarkdown from 'react-markdown'\nimport remarkGfm from 'remark-gfm'\nimport type { FAQListContent, FAQItem, MessageRenderer, MessageContent } from '../../types'\n\nexport interface FAQListProps {\n content: FAQListContent\n onQuestionClick?: (question: string) => void\n}\n\n/**\n * FAQ \u5217\u8868\u6E32\u67D3\u5668\n * \u7528\u4E8E\u6CE8\u518C\u5230 MessageRendererRegistry\n */\nexport const FAQListRenderer: MessageRenderer = {\n render: (content: MessageContent) => {\n if (content.type !== 'faq_list') {\n return null\n }\n return <FAQList content={content as FAQListContent} />\n },\n}\n\nexport const FAQList: React.FC<FAQListProps> = ({ content, onQuestionClick }) => {\n const { found, count, total, results } = content.data\n const [expandedIds, setExpandedIds] = useState<Set<string>>(new Set())\n\n // \u5982\u679C\u6CA1\u6709\u627E\u5230\u7ED3\u679C\n if (!found || results.length === 0) {\n return (\n <div className=\"rounded-lg border border-gray-200 bg-white p-4\">\n <p className=\"text-sm text-gray-500\">\u672A\u627E\u5230\u76F8\u5173\u95EE\u9898</p>\n </div>\n )\n }\n\n // \u5207\u6362\u5C55\u5F00/\u6298\u53E0\n const toggleExpand = (id: string) => {\n setExpandedIds(prev => {\n const newSet = new Set(prev)\n if (newSet.has(id)) {\n newSet.delete(id)\n } else {\n newSet.add(id)\n }\n return newSet\n })\n }\n\n // \u5904\u7406\u76F8\u5173\u95EE\u9898\u70B9\u51FB\n const handleRelatedQuestionClick = (question: string) => {\n onQuestionClick?.(question)\n }\n\n return (\n <div className=\"space-y-2\">\n {/* FAQ \u5217\u8868 */}\n <div className=\"space-y-2\">\n {results.map(item => {\n const isExpanded = expandedIds.has(item.id)\n\n return (\n <div key={item.id} className=\"overflow-hidden rounded-2xl bg-[#F5F6F7] transition-all\">\n {/* \u95EE\u9898\u6807\u9898 - \u53EF\u70B9\u51FB\u5C55\u5F00/\u6298\u53E0 */}\n <button\n onClick={() => toggleExpand(item.id)}\n className=\"flex w-full items-center justify-between gap-3 p-4 text-left transition-colors \"\n >\n <div className=\"flex-1\">\n <div className=\"flex items-center gap-2\">\n <span className=\"text-base font-bold leading-[1.4] tracking-[-0.02em] text-[#080A0F]\">\n {item.question}\n </span>\n </div>\n </div>\n\n {/* \u5C55\u5F00/\u6298\u53E0\u56FE\u6807 */}\n <svg\n className={`size-5 shrink-0 text-[#080A0F] transition-transform ${isExpanded ? 'rotate-180' : ''}`}\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M19 9l-7 7-7-7\" />\n </svg>\n </button>\n\n {/* \u7B54\u6848\u5185\u5BB9 - \u5C55\u5F00\u65F6\u663E\u793A */}\n {isExpanded && (\n <div className=\" bg-[#F5F6F7] px-4 py-3 pt-0\">\n <div\n className=\"prose prose-sm max-w-none border-t border-gray-100 text-sm font-bold leading-[1.4] tracking-[-0.02em] text-[#4A4C56]\"\n style={{ paddingTop: '12px' }}\n >\n <ReactMarkdown\n remarkPlugins={[remarkGfm]}\n components={{\n a: ({ node, ...props }) => (\n <a\n {...props}\n className=\"livechat-link livechat-link-bot\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n />\n ),\n }}\n >\n {item.answer}\n </ReactMarkdown>\n </div>\n\n {/* \u76F8\u5173\u95EE\u9898 */}\n {item.relatedQuestions && item.relatedQuestions.length > 0 && (\n <div className=\"mt-4 border-t border-gray-200 pt-3\">\n <p className=\"mb-2 text-xs font-medium text-gray-500\">You may also want to know:</p>\n <div className=\"space-y-1\">\n {item.relatedQuestions.map((q, idx) => (\n <button\n key={idx}\n onClick={() => handleRelatedQuestionClick(q)}\n className=\"block w-full text-left text-xs text-blue-600 hover:text-blue-700 hover:underline\"\n >\n {q}\n </button>\n ))}\n </div>\n </div>\n )}\n </div>\n )}\n </div>\n )\n })}\n </div>\n </div>\n )\n}\n"],
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,oBAAAC,IAAA,eAAAC,EAAAJ,GAwBW,IAAAK,EAAA,6BAnBXC,EAAgC,iBAChCC,EAA0B,6BAC1BC,EAAsB,yBAYf,MAAML,EAAmC,CAC9C,OAASM,GACHA,EAAQ,OAAS,WACZ,QAEF,OAACP,EAAA,CAAQ,QAASO,EAA2B,CAExD,EAEaP,EAAkC,CAAC,CAAE,QAAAO,EAAS,gBAAAC,CAAgB,IAAM,CAC/E,KAAM,CAAE,MAAAC,EAAO,MAAAC,EAAO,MAAAC,EAAO,QAAAC,CAAQ,EAAIL,EAAQ,KAC3C,CAACM,EAAaC,CAAc,KAAI,YAAsB,IAAI,GAAK,EAGrE,GAAI,CAACL,GAASG,EAAQ,SAAW,EAC/B,SACE,OAAC,OAAI,UAAU,iDACb,mBAAC,KAAE,UAAU,wBAAwB,sDAAO,EAC9C,EAKJ,MAAMG,EAAgBC,GAAe,CACnCF,EAAeG,GAAQ,CACrB,MAAMC,EAAS,IAAI,IAAID,CAAI,EAC3B,OAAIC,EAAO,IAAIF,CAAE,EACfE,EAAO,OAAOF,CAAE,EAEhBE,EAAO,IAAIF,CAAE,EAERE,CACT,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+
"names": ["FAQList_exports", "__export", "FAQList", "FAQListRenderer", "__toCommonJS", "import_jsx_runtime", "import_react", "import_react_markdown", "import_remark_gfm", "content", "onQuestionClick", "found", "count", "total", "results", "expandedIds", "setExpandedIds", "toggleExpand", "id", "prev", "newSet", "handleRelatedQuestionClick", "question", "item", "isExpanded", "ReactMarkdown", "remarkGfm", "node", "props", "q", "idx"]
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";var g=Object.create;var d=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var
|
|
1
|
+
"use strict";var g=Object.create;var d=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var y=Object.getPrototypeOf,h=Object.prototype.hasOwnProperty;var k=(t,o)=>{for(var n in o)d(t,n,{get:o[n],enumerable:!0})},c=(t,o,n,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let l of v(o))!h.call(t,l)&&l!==n&&d(t,l,{get:()=>o[l],enumerable:!(i=x(o,l))||i.enumerable});return t};var m=(t,o,n)=>(n=t!=null?g(y(t)):{},c(o||!t||!t.__esModule?d(n,"default",{value:t,enumerable:!0}):n,t)),f=t=>c(d({},"__esModule",{value:!0}),t);var w={};k(w,{PolicyBlock:()=>N});module.exports=f(w);var e=require("react/jsx-runtime"),p=require("react"),b=m(require("react-markdown")),u=m(require("remark-gfm"));const N={render:(t,o,n)=>{const i=t,{title:l,content:a}=i.data;if(!l||!a)return null;const r=a.length>200;return(0,e.jsx)(C,{title:l,content:a,isLong:r})}},C=({title:t,content:o,isLong:n})=>{const[i,l]=(0,p.useState)(!n);return(0,e.jsxs)("div",{className:"overflow-hidden rounded-lg border border-blue-200 bg-blue-50",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 border-b border-blue-200 bg-blue-100 px-3 py-2",children:[(0,e.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0 text-blue-700",children:[(0,e.jsx)("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),(0,e.jsx)("polyline",{points:"14 2 14 8 20 8"}),(0,e.jsx)("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),(0,e.jsx)("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),(0,e.jsx)("polyline",{points:"10 9 9 9 8 9"})]}),(0,e.jsx)("h3",{className:"text-sm font-semibold text-blue-900",children:t})]}),(0,e.jsxs)("div",{className:"px-3 py-2",children:[(0,e.jsx)("div",{className:`
|
|
2
2
|
text-sm leading-relaxed text-blue-900
|
|
3
3
|
${!i&&n?"line-clamp-3":""}
|
|
4
|
-
`,children:(0,e.jsx)(b.default,{remarkPlugins:[u.default],components:{p:({node:r,...
|
|
4
|
+
`,children:(0,e.jsx)(b.default,{remarkPlugins:[u.default],components:{p:({node:r,...s})=>(0,e.jsx)("p",{...s,className:"mb-2 last:mb-0"}),ul:({node:r,...s})=>(0,e.jsx)("ul",{...s,className:"mb-2 ml-4 list-disc"}),ol:({node:r,...s})=>(0,e.jsx)("ol",{...s,className:"mb-2 ml-4 list-decimal"}),li:({node:r,...s})=>(0,e.jsx)("li",{...s,className:"mb-1"}),strong:({node:r,...s})=>(0,e.jsx)("strong",{...s,className:"font-bold"}),a:({node:r,...s})=>(0,e.jsx)("a",{...s,className:"livechat-link livechat-link-bot",target:"_blank",rel:"noopener noreferrer"})},children:o})}),n&&(0,e.jsxs)("button",{type:"button",onClick:()=>{l(r=>!r)},className:"mt-2 flex items-center gap-1 text-xs font-medium text-blue-700 hover:text-blue-800",children:[(0,e.jsx)("span",{children:i?"\u6536\u8D77":"\u5C55\u5F00"}),(0,e.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:`transition-transform ${i?"rotate-180":""}`,children:(0,e.jsx)("polyline",{points:"6 9 12 15 18 9"})})]})]})]})};
|
|
5
5
|
//# sourceMappingURL=PolicyBlock.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/components/LiveChatWidget/components/MessageContent/PolicyBlock.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * \u653F\u7B56\u8BF4\u660E\u6E32\u67D3\u5668\n * \u663E\u793A\u9000\u8D27\u3001\u4FDD\u4FEE\u7B49\u653F\u7B56\u4FE1\u606F\n * \u57FA\u4E8E specs/livechat-widget/data-model.md \u7684\u653F\u7B56\u6570\u636E\u6A21\u578B\n */\n\nimport React, { useState } from 'react'\nimport ReactMarkdown from 'react-markdown'\nimport remarkGfm from 'remark-gfm'\nimport type { MessageRenderer, PolicyContent } from '../../types'\n\n/**\n * \u653F\u7B56\u8BF4\u660E\u6E32\u67D3\u5668\n *\n * \u529F\u80FD\uFF1A\n * - \u663E\u793A\u653F\u7B56\u6807\u9898\u548C\u5185\u5BB9\n * - \u652F\u6301 Markdown \u683C\u5F0F\n * - \u53EF\u6298\u53E0/\u5C55\u5F00\uFF08\u5185\u5BB9\u8F83\u957F\u65F6\uFF09\n *\n * \u653F\u7B56\u7C7B\u578B\uFF1A\n * - \u9000\u8D27\u653F\u7B56\n * - \u4FDD\u4FEE\u653F\u7B56\n * - \u8FD0\u8D39\u653F\u7B56\n * - \u9690\u79C1\u653F\u7B56\n *\n * \u5E03\u5C40\uFF1A\n * ```\n * \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n * \u2502 \uD83D\uDCCB \u653F\u7B56\u6807\u9898 \u2502\n * \u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n * \u2502 \u653F\u7B56\u5185\u5BB9... \u2502\n * \u2502 (\u652F\u6301 Markdown) \u2502\n * \u2502 \u2502\n * \u2502 [\u5C55\u5F00/\u6536\u8D77] \u2502\n * \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n * ```\n *\n * @example\n * ```tsx\n * const content: PolicyContent = {\n * type: 'policy',\n * data: {\n * title: '\u9000\u8D27\u653F\u7B56',\n * content: '\u6211\u4EEC\u63D0\u4F9B 30 \u5929\u65E0\u7406\u7531\u9000\u8D27...'\n * }\n * }\n * <PolicyBlock.render(content, false, false) />\n * ```\n */\nexport const PolicyBlock: MessageRenderer = {\n render: (content, isUser, isSystem) => {\n const policyContent = content as PolicyContent\n const { title, content: policyText } = policyContent.data\n\n if (!title || !policyText) {\n return null\n }\n\n // \u5224\u65AD\u5185\u5BB9\u662F\u5426\u8F83\u957F\uFF08\u8D85\u8FC7 200 \u5B57\u7B26\uFF09\n const isLongContent = policyText.length > 200\n\n return <PolicyCard title={title} content={policyText} isLong={isLongContent} />\n },\n}\n\n/**\n * \u653F\u7B56\u5361\u7247\u7EC4\u4EF6\uFF08\u652F\u6301\u6298\u53E0\uFF09\n */\nconst PolicyCard: React.FC<{\n title: string\n content: string\n isLong: boolean\n}> = ({ title, content, isLong }) => {\n const [isExpanded, setIsExpanded] = useState(!isLong)\n\n const toggleExpand = () => {\n setIsExpanded(prev => !prev)\n }\n\n return (\n <div className=\"overflow-hidden rounded-lg border border-blue-200 bg-blue-50\">\n {/* \u6807\u9898 */}\n <div className=\"flex items-center gap-2 border-b border-blue-200 bg-blue-100 px-3 py-2\">\n <svg\n width=\"18\"\n height=\"18\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className=\"shrink-0 text-blue-700\"\n >\n <path d=\"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z\" />\n <polyline points=\"14 2 14 8 20 8\" />\n <line x1=\"16\" y1=\"13\" x2=\"8\" y2=\"13\" />\n <line x1=\"16\" y1=\"17\" x2=\"8\" y2=\"17\" />\n <polyline points=\"10 9 9 9 8 9\" />\n </svg>\n <h3 className=\"text-sm font-semibold text-blue-900\">{title}</h3>\n </div>\n\n {/* \u5185\u5BB9 */}\n <div className=\"px-3 py-2\">\n <div\n className={`\n text-sm leading-relaxed text-blue-900\n ${!isExpanded && isLong ? 'line-clamp-3' : ''}\n `}\n >\n <ReactMarkdown\n remarkPlugins={[remarkGfm]}\n components={{\n p: ({ node, ...props }) => <p {...props} className=\"mb-2 last:mb-0\" />,\n ul: ({ node, ...props }) => <ul {...props} className=\"mb-2 ml-4 list-disc\" />,\n ol: ({ node, ...props }) => <ol {...props} className=\"mb-2 ml-4 list-decimal\" />,\n li: ({ node, ...props }) => <li {...props} className=\"mb-1\" />,\n strong: ({ node, ...props }) => <strong {...props} className=\"font-bold\" />,\n }}\n >\n {content}\n </ReactMarkdown>\n </div>\n\n {/* \u5C55\u5F00/\u6536\u8D77\u6309\u94AE\uFF08\u4EC5\u957F\u5185\u5BB9\u663E\u793A\uFF09 */}\n {isLong && (\n <button\n type=\"button\"\n onClick={toggleExpand}\n className=\"mt-2 flex items-center gap-1 text-xs font-medium text-blue-700 hover:text-blue-800\"\n >\n <span>{isExpanded ? '\u6536\u8D77' : '\u5C55\u5F00'}</span>\n <svg\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className={`transition-transform ${isExpanded ? 'rotate-180' : ''}`}\n >\n <polyline points=\"6 9 12 15 18 9\" />\n </svg>\n </button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B,WAAY,CACV,EAAG,CAAC,CAAE,KAAAC,EAAM,GAAGC,CAAM,OAAM,OAAC,KAAG,GAAGA,EAAO,UAAU,iBAAiB,EACpE,GAAI,CAAC,CAAE,KAAAD,EAAM,GAAGC,CAAM,OAAM,OAAC,MAAI,GAAGA,EAAO,UAAU,sBAAsB,EAC3E,GAAI,CAAC,CAAE,KAAAD,EAAM,GAAGC,CAAM,OAAM,OAAC,MAAI,GAAGA,EAAO,UAAU,yBAAyB,EAC9E,GAAI,CAAC,CAAE,KAAAD,EAAM,GAAGC,CAAM,OAAM,OAAC,MAAI,GAAGA,EAAO,UAAU,OAAO,EAC5D,OAAQ,CAAC,CAAE,KAAAD,EAAM,GAAGC,CAAM,OAAM,OAAC,UAAQ,GAAGA,EAAO,UAAU,YAAY,
|
|
4
|
+
"sourcesContent": ["/**\n * \u653F\u7B56\u8BF4\u660E\u6E32\u67D3\u5668\n * \u663E\u793A\u9000\u8D27\u3001\u4FDD\u4FEE\u7B49\u653F\u7B56\u4FE1\u606F\n * \u57FA\u4E8E specs/livechat-widget/data-model.md \u7684\u653F\u7B56\u6570\u636E\u6A21\u578B\n */\n\nimport React, { useState } from 'react'\nimport ReactMarkdown from 'react-markdown'\nimport remarkGfm from 'remark-gfm'\nimport type { MessageRenderer, PolicyContent } from '../../types'\n\n/**\n * \u653F\u7B56\u8BF4\u660E\u6E32\u67D3\u5668\n *\n * \u529F\u80FD\uFF1A\n * - \u663E\u793A\u653F\u7B56\u6807\u9898\u548C\u5185\u5BB9\n * - \u652F\u6301 Markdown \u683C\u5F0F\n * - \u53EF\u6298\u53E0/\u5C55\u5F00\uFF08\u5185\u5BB9\u8F83\u957F\u65F6\uFF09\n *\n * \u653F\u7B56\u7C7B\u578B\uFF1A\n * - \u9000\u8D27\u653F\u7B56\n * - \u4FDD\u4FEE\u653F\u7B56\n * - \u8FD0\u8D39\u653F\u7B56\n * - \u9690\u79C1\u653F\u7B56\n *\n * \u5E03\u5C40\uFF1A\n * ```\n * \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n * \u2502 \uD83D\uDCCB \u653F\u7B56\u6807\u9898 \u2502\n * \u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n * \u2502 \u653F\u7B56\u5185\u5BB9... \u2502\n * \u2502 (\u652F\u6301 Markdown) \u2502\n * \u2502 \u2502\n * \u2502 [\u5C55\u5F00/\u6536\u8D77] \u2502\n * \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n * ```\n *\n * @example\n * ```tsx\n * const content: PolicyContent = {\n * type: 'policy',\n * data: {\n * title: '\u9000\u8D27\u653F\u7B56',\n * content: '\u6211\u4EEC\u63D0\u4F9B 30 \u5929\u65E0\u7406\u7531\u9000\u8D27...'\n * }\n * }\n * <PolicyBlock.render(content, false, false) />\n * ```\n */\nexport const PolicyBlock: MessageRenderer = {\n render: (content, isUser, isSystem) => {\n const policyContent = content as PolicyContent\n const { title, content: policyText } = policyContent.data\n\n if (!title || !policyText) {\n return null\n }\n\n // \u5224\u65AD\u5185\u5BB9\u662F\u5426\u8F83\u957F\uFF08\u8D85\u8FC7 200 \u5B57\u7B26\uFF09\n const isLongContent = policyText.length > 200\n\n return <PolicyCard title={title} content={policyText} isLong={isLongContent} />\n },\n}\n\n/**\n * \u653F\u7B56\u5361\u7247\u7EC4\u4EF6\uFF08\u652F\u6301\u6298\u53E0\uFF09\n */\nconst PolicyCard: React.FC<{\n title: string\n content: string\n isLong: boolean\n}> = ({ title, content, isLong }) => {\n const [isExpanded, setIsExpanded] = useState(!isLong)\n\n const toggleExpand = () => {\n setIsExpanded(prev => !prev)\n }\n\n return (\n <div className=\"overflow-hidden rounded-lg border border-blue-200 bg-blue-50\">\n {/* \u6807\u9898 */}\n <div className=\"flex items-center gap-2 border-b border-blue-200 bg-blue-100 px-3 py-2\">\n <svg\n width=\"18\"\n height=\"18\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className=\"shrink-0 text-blue-700\"\n >\n <path d=\"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z\" />\n <polyline points=\"14 2 14 8 20 8\" />\n <line x1=\"16\" y1=\"13\" x2=\"8\" y2=\"13\" />\n <line x1=\"16\" y1=\"17\" x2=\"8\" y2=\"17\" />\n <polyline points=\"10 9 9 9 8 9\" />\n </svg>\n <h3 className=\"text-sm font-semibold text-blue-900\">{title}</h3>\n </div>\n\n {/* \u5185\u5BB9 */}\n <div className=\"px-3 py-2\">\n <div\n className={`\n text-sm leading-relaxed text-blue-900\n ${!isExpanded && isLong ? 'line-clamp-3' : ''}\n `}\n >\n <ReactMarkdown\n remarkPlugins={[remarkGfm]}\n components={{\n p: ({ node, ...props }) => <p {...props} className=\"mb-2 last:mb-0\" />,\n ul: ({ node, ...props }) => <ul {...props} className=\"mb-2 ml-4 list-disc\" />,\n ol: ({ node, ...props }) => <ol {...props} className=\"mb-2 ml-4 list-decimal\" />,\n li: ({ node, ...props }) => <li {...props} className=\"mb-1\" />,\n strong: ({ node, ...props }) => <strong {...props} className=\"font-bold\" />,\n a: ({ node, ...props }) => (\n <a\n {...props}\n className=\"livechat-link livechat-link-bot\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n />\n ),\n }}\n >\n {content}\n </ReactMarkdown>\n </div>\n\n {/* \u5C55\u5F00/\u6536\u8D77\u6309\u94AE\uFF08\u4EC5\u957F\u5185\u5BB9\u663E\u793A\uFF09 */}\n {isLong && (\n <button\n type=\"button\"\n onClick={toggleExpand}\n className=\"mt-2 flex items-center gap-1 text-xs font-medium text-blue-700 hover:text-blue-800\"\n >\n <span>{isExpanded ? '\u6536\u8D77' : '\u5C55\u5F00'}</span>\n <svg\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className={`transition-transform ${isExpanded ? 'rotate-180' : ''}`}\n >\n <polyline points=\"6 9 12 15 18 9\" />\n </svg>\n </button>\n )}\n </div>\n </div>\n )\n}\n"],
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,IAAA,eAAAC,EAAAH,GA6DW,IAAAI,EAAA,6BAvDXC,EAAgC,iBAChCC,EAA0B,6BAC1BC,EAAsB,yBAyCf,MAAML,EAA+B,CAC1C,OAAQ,CAACM,EAASC,EAAQC,IAAa,CACrC,MAAMC,EAAgBH,EAChB,CAAE,MAAAI,EAAO,QAASC,CAAW,EAAIF,EAAc,KAErD,GAAI,CAACC,GAAS,CAACC,EACb,OAAO,KAIT,MAAMC,EAAgBD,EAAW,OAAS,IAE1C,SAAO,OAACE,EAAA,CAAW,MAAOH,EAAO,QAASC,EAAY,OAAQC,EAAe,CAC/E,CACF,EAKMC,EAID,CAAC,CAAE,MAAAH,EAAO,QAAAJ,EAAS,OAAAQ,CAAO,IAAM,CACnC,KAAM,CAACC,EAAYC,CAAa,KAAI,YAAS,CAACF,CAAM,EAMpD,SACE,QAAC,OAAI,UAAU,+DAEb,qBAAC,OAAI,UAAU,yEACb,qBAAC,OACC,MAAM,KACN,OAAO,KACP,QAAQ,YACR,KAAK,OACL,OAAO,eACP,YAAY,IACZ,cAAc,QACd,eAAe,QACf,UAAU,yBAEV,oBAAC,QAAK,EAAE,6DAA6D,KACrE,OAAC,YAAS,OAAO,iBAAiB,KAClC,OAAC,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AY,IACZ,cAAc,QACd,eAAe,QACf,UAAW,wBAAwBA,EAAa,aAAe,EAAE,GAEjE,mBAAC,YAAS,OAAO,iBAAiB,EACpC,GACF,GAEJ,GACF,CAEJ",
|
|
6
6
|
"names": ["PolicyBlock_exports", "__export", "PolicyBlock", "__toCommonJS", "import_jsx_runtime", "import_react", "import_react_markdown", "import_remark_gfm", "content", "isUser", "isSystem", "policyContent", "title", "policyText", "isLongContent", "PolicyCard", "isLong", "isExpanded", "setIsExpanded", "ReactMarkdown", "remarkGfm", "node", "props", "prev"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var x=Object.create;var n=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var N=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty;var h=(a,r)=>{for(var l in r)n(a,l,{get:r[l],enumerable:!0})},m=(a,r,l,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of y(r))!f.call(a,t)&&t!==l&&n(a,t,{get:()=>r[t],enumerable:!(s=g(r,t))||s.enumerable});return a};var c=(a,r,l)=>(l=a!=null?x(N(a)):{},m(r||!a||!a.__esModule?n(l,"default",{value:a,enumerable:!0}):l,a)),p=a=>m(n({},"__esModule",{value:!0}),a);var k={};h(k,{TextBlock:()=>u});module.exports=p(k);var o=require("react/jsx-runtime"),b=c(require("react-markdown")),i=c(require("remark-gfm"));const u={render:(a,r,l)=>{const s=a;return s.text?(0,o.jsx)("div",{className:"livechat-markdown text-base md:text-sm",children:(0,o.jsx)(b.default,{remarkPlugins:[i.default],components:{a:({node:t,...e})=>(0,o.jsx)("a",{...e,className:`livechat-link underline ${r?"livechat-link-user":"livechat-link-bot"}`,target:"_blank",rel:"noopener noreferrer"}),code:({node:t,className:e,...d})=>/language-/.test(e||"")?(0,o.jsx)("code",{...d,className:`block overflow-x-auto rounded px-3 py-2 font-mono text-xs ${r?"livechat-code-user bg-[#004A6E] text-white":"bg-gray-200 text-gray-800"}`}):(0,o.jsx)("code",{...d,className:`rounded px-1.5 py-0.5 font-mono text-xs ${r?"livechat-code-user bg-[#004A6E] text-white":"bg-gray-200 text-gray-800"}`}),p:({node:t,...e})=>(0,o.jsx)("p",{...e,className:"last:mb-0"}),ul:({node:t,...e})=>(0,o.jsx)("ul",{...e,className:"ml-4 list-disc"}),ol:({node:t,...e})=>(0,o.jsx)("ol",{...e,className:"mb-2 ml-4 list-decimal"}),li:({node:t,...e})=>(0,o.jsx)("li",{...e,className:"mb-1"}),h1:({node:t,...e})=>(0,o.jsx)("h1",{...e,className:"mb-2 font-bold"}),h2:({node:t,...e})=>(0,o.jsx)("h2",{...e,className:"mb-2 font-bold"}),h3:({node:t,...e})=>(0,o.jsx)("h3",{...e,className:"mb-1 font-bold"}),strong:({node:t,...e})=>(0,o.jsx)("strong",{...e,className:"font-bold"}),em:({node:t,...e})=>(0,o.jsx)("em",{...e,className:"italic"}),table:({node:t,...e})=>(0,o.jsx)("div",{className:"my-2 overflow-x-auto",children:(0,o.jsx)("table",{...e,className:"min-w-full border-collapse border border-gray-300 text-base md:text-sm"})}),thead:({node:t,...e})=>(0,o.jsx)("thead",{...e,className:"bg-gray-100"}),tbody:({node:t,...e})=>(0,o.jsx)("tbody",{...e}),tr:({node:t,...e})=>(0,o.jsx)("tr",{...e,className:"border-b border-gray-300"}),th:({node:t,...e})=>(0,o.jsx)("th",{...e,className:"border border-gray-300 px-3 py-2 text-left font-semibold"}),td:({node:t,...e})=>(0,o.jsx)("td",{...e,className:"border border-gray-300 px-3 py-2"})},children:s.text})}):null}};
|
|
2
2
|
//# sourceMappingURL=TextBlock.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/components/LiveChatWidget/components/MessageContent/TextBlock.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * \u6587\u672C\u6D88\u606F\u5185\u5BB9\u6E32\u67D3\u5668\n * \u652F\u6301 Markdown \u683C\u5F0F\n * \u57FA\u4E8E specs/livechat-widget/plan.md \u7684\u6587\u672C\u6D88\u606F\u8BBE\u8BA1\n */\n\nimport React from 'react'\nimport ReactMarkdown from 'react-markdown'\nimport remarkGfm from 'remark-gfm'\nimport type { MessageRenderer, TextContent } from '../../types'\n\n/**\n * \u6587\u672C\u6D88\u606F\u6E32\u67D3\u5668\n *\n * \u529F\u80FD\uFF1A\n * - \u652F\u6301 Markdown \u8BED\u6CD5\uFF08\u7C97\u4F53\u3001\u659C\u4F53\u3001\u94FE\u63A5\u3001\u5217\u8868\u7B49\uFF09\n * - \u5B89\u5168\u6E32\u67D3\uFF08React Markdown \u81EA\u52A8\u9632\u62A4 XSS\uFF09\n * - \u54CD\u5E94\u5F0F\u6587\u672C\u6837\u5F0F\n *\n * Markdown \u652F\u6301\uFF1A\n * - \u7C97\u4F53\uFF1A**text** \u6216 __text__\n * - \u659C\u4F53\uFF1A*text* \u6216 _text_\n * - \u94FE\u63A5\uFF1A[text](url)\n * - \u5217\u8868\uFF1A- item \u6216 1. item\n * - \u4EE3\u7801\uFF1A`code` \u6216 ```code block```\n *\n * @example\n * ```tsx\n * const content: TextContent = {\n * type: 'text',\n * text: '\u60A8\u597D\uFF01**\u8FD9\u662F\u7C97\u4F53**\uFF0C*\u8FD9\u662F\u659C\u4F53*\u3002'\n * }\n * <TextBlock.render(content, false, false) />\n * ```\n */\nexport const TextBlock: MessageRenderer = {\n render: (content, isUser, isSystem) => {\n const textContent = content as TextContent\n\n if (!textContent.text) {\n return null\n }\n\n return (\n <div className=\"livechat-markdown text-base md:text-sm\">\n <ReactMarkdown\n remarkPlugins={[remarkGfm]}\n components={{\n // \u81EA\u5B9A\u4E49\u94FE\u63A5\u6837\u5F0F\n a: ({ node, ...props }) => (\n <a\n {...props}\n className={`underline ${isUser ? '
|
|
5
|
-
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,eAAAE,IAAA,eAAAC,EAAAH,
|
|
4
|
+
"sourcesContent": ["/**\n * \u6587\u672C\u6D88\u606F\u5185\u5BB9\u6E32\u67D3\u5668\n * \u652F\u6301 Markdown \u683C\u5F0F\n * \u57FA\u4E8E specs/livechat-widget/plan.md \u7684\u6587\u672C\u6D88\u606F\u8BBE\u8BA1\n */\n\nimport React from 'react'\nimport ReactMarkdown from 'react-markdown'\nimport remarkGfm from 'remark-gfm'\nimport type { MessageRenderer, TextContent } from '../../types'\n\n/**\n * \u6587\u672C\u6D88\u606F\u6E32\u67D3\u5668\n *\n * \u529F\u80FD\uFF1A\n * - \u652F\u6301 Markdown \u8BED\u6CD5\uFF08\u7C97\u4F53\u3001\u659C\u4F53\u3001\u94FE\u63A5\u3001\u5217\u8868\u7B49\uFF09\n * - \u5B89\u5168\u6E32\u67D3\uFF08React Markdown \u81EA\u52A8\u9632\u62A4 XSS\uFF09\n * - \u54CD\u5E94\u5F0F\u6587\u672C\u6837\u5F0F\n *\n * Markdown \u652F\u6301\uFF1A\n * - \u7C97\u4F53\uFF1A**text** \u6216 __text__\n * - \u659C\u4F53\uFF1A*text* \u6216 _text_\n * - \u94FE\u63A5\uFF1A[text](url)\n * - \u5217\u8868\uFF1A- item \u6216 1. item\n * - \u4EE3\u7801\uFF1A`code` \u6216 ```code block```\n *\n * @example\n * ```tsx\n * const content: TextContent = {\n * type: 'text',\n * text: '\u60A8\u597D\uFF01**\u8FD9\u662F\u7C97\u4F53**\uFF0C*\u8FD9\u662F\u659C\u4F53*\u3002'\n * }\n * <TextBlock.render(content, false, false) />\n * ```\n */\nexport const TextBlock: MessageRenderer = {\n render: (content, isUser, isSystem) => {\n const textContent = content as TextContent\n\n if (!textContent.text) {\n return null\n }\n\n return (\n <div className=\"livechat-markdown text-base md:text-sm\">\n <ReactMarkdown\n remarkPlugins={[remarkGfm]}\n components={{\n // \u81EA\u5B9A\u4E49\u94FE\u63A5\u6837\u5F0F\n // livechat-link-user / livechat-link-bot \u7528\u4E8E\u533A\u5206\u7528\u6237\u8F93\u5165\u94FE\u63A5\u4E0E\u673A\u5668\u4EBA\u56DE\u590D\u94FE\u63A5\u7684\u989C\u8272\uFF0C\n // \u8C03\u7528\u65B9\u53EF\u76F4\u63A5\u8986\u76D6\u8FD9\u4E24\u4E2A\u7C7B\u540D\u81EA\u5B9A\u4E49\u989C\u8272\uFF08\u89C1 styles/livechat.css\uFF09\n a: ({ node, ...props }) => (\n <a\n {...props}\n className={`livechat-link underline ${isUser ? 'livechat-link-user' : 'livechat-link-bot'}`}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n />\n ),\n // \u81EA\u5B9A\u4E49\u4EE3\u7801\u5757\u6837\u5F0F\n code: ({ node, className, ...props }: any) => {\n const isBlock = /language-/.test(className || '')\n return isBlock ? (\n <code\n {...props}\n className={`block overflow-x-auto rounded px-3 py-2 font-mono text-xs ${isUser ? 'livechat-code-user bg-[#004A6E] text-white' : 'bg-gray-200 text-gray-800'}`}\n />\n ) : (\n <code\n {...props}\n className={`rounded px-1.5 py-0.5 font-mono text-xs ${isUser ? 'livechat-code-user bg-[#004A6E] text-white' : 'bg-gray-200 text-gray-800'}`}\n />\n )\n },\n // \u81EA\u5B9A\u4E49\u6BB5\u843D\u6837\u5F0F\n p: ({ node, ...props }) => <p {...props} className=\"last:mb-0\" />,\n // \u81EA\u5B9A\u4E49\u5217\u8868\u6837\u5F0F\n ul: ({ node, ...props }) => <ul {...props} className=\"ml-4 list-disc\" />,\n ol: ({ node, ...props }) => <ol {...props} className=\"mb-2 ml-4 list-decimal\" />,\n li: ({ node, ...props }) => <li {...props} className=\"mb-1\" />,\n // \u81EA\u5B9A\u4E49\u6807\u9898\u6837\u5F0F\n h1: ({ node, ...props }) => <h1 {...props} className=\"mb-2 font-bold\" />,\n h2: ({ node, ...props }) => <h2 {...props} className=\"mb-2 font-bold\" />,\n h3: ({ node, ...props }) => <h3 {...props} className=\"mb-1 font-bold\" />,\n // \u81EA\u5B9A\u4E49\u5F3A\u8C03\u6837\u5F0F\n strong: ({ node, ...props }) => <strong {...props} className=\"font-bold\" />,\n em: ({ node, ...props }) => <em {...props} className=\"italic\" />,\n // \u8868\u683C\u6837\u5F0F\n table: ({ node, ...props }) => (\n <div className=\"my-2 overflow-x-auto\">\n <table {...props} className=\"min-w-full border-collapse border border-gray-300 text-base md:text-sm\" />\n </div>\n ),\n thead: ({ node, ...props }) => (\n <thead {...props} className=\"bg-gray-100\" />\n ),\n tbody: ({ node, ...props }) => <tbody {...props} />,\n tr: ({ node, ...props }) => (\n <tr {...props} className=\"border-b border-gray-300\" />\n ),\n th: ({ node, ...props }) => (\n <th {...props} className=\"border border-gray-300 px-3 py-2 text-left font-semibold\" />\n ),\n td: ({ node, ...props }) => (\n <td {...props} className=\"border border-gray-300 px-3 py-2\" />\n ),\n }}\n >\n {textContent.text}\n </ReactMarkdown>\n </div>\n )\n },\n}\n"],
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,eAAAE,IAAA,eAAAC,EAAAH,GAoDc,IAAAI,EAAA,6BA7CdC,EAA0B,6BAC1BC,EAAsB,yBA2Bf,MAAMJ,EAA6B,CACxC,OAAQ,CAACK,EAASC,EAAQC,IAAa,CACrC,MAAMC,EAAcH,EAEpB,OAAKG,EAAY,QAKf,OAAC,OAAI,UAAU,yCACb,mBAAC,EAAAC,QAAA,CACC,cAAe,CAAC,EAAAC,OAAS,EACzB,WAAY,CAIV,EAAG,CAAC,CAAE,KAAAC,EAAM,GAAGC,CAAM,OACnB,OAAC,KACE,GAAGA,EACJ,UAAW,2BAA2BN,EAAS,qBAAuB,mBAAmB,GACzF,OAAO,SACP,IAAI,sBACN,EAGF,KAAM,CAAC,CAAE,KAAAK,EAAM,UAAAE,EAAW,GAAGD,CAAM,IACjB,YAAY,KAAKC,GAAa,EAAE,KAE9C,OAAC,QACE,GAAGD,EACJ,UAAW,6DAA6DN,EAAS,6CAA+C,2BAA2B,GAC7J,KAEA,OAAC,QACE,GA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,GAAI,CAAC,CAAE,KAAAD,EAAM,GAAGC,CAAM,OACpB,OAAC,MAAI,GAAGA,EAAO,UAAU,2BAA2B,EAEtD,GAAI,CAAC,CAAE,KAAAD,EAAM,GAAGC,CAAM,OACpB,OAAC,MAAI,GAAGA,EAAO,UAAU,2DAA2D,EAEtF,GAAI,CAAC,CAAE,KAAAD,EAAM,GAAGC,CAAM,OACpB,OAAC,MAAI,GAAGA,EAAO,UAAU,mCAAmC,CAEhE,EAEC,SAAAJ,EAAY,KACf,EACF,EAtEO,IAwEX,CACF",
|
|
6
6
|
"names": ["TextBlock_exports", "__export", "TextBlock", "__toCommonJS", "import_jsx_runtime", "import_react_markdown", "import_remark_gfm", "content", "isUser", "isSystem", "textContent", "ReactMarkdown", "remarkGfm", "node", "props", "className"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/components/credits/context/hooks/useSubscribed.ts"],
|
|
4
|
-
"sourcesContent": ["import { useMemo } from 'react'\n\nimport { TaskSubType } from '../const'\nimport useActivities from './useActivities'\nimport { useCreditsContext } from '../provider'\nimport { useHeadlessContext, useSubscriptions } from '@anker-in/lib'\n\nexport const useSubscribed = () => {\n const { profile } = useCreditsContext()\n const { brand } = useHeadlessContext()\n\n const activitiesOptions = useMemo(() => ({ page: 1, pageSize: 50 }), [])\n\n const { activities } = useActivities(activitiesOptions)\n const { data: subscription } = useSubscriptions({ email: profile?.email })\n const subscriptionData = subscription?.data || subscription\n\n const isSubscribed = useMemo(() => {\n if (!subscriptionData?.preference) {\n return false\n }\n\n const subscribeResult = subscriptionData.preference.some((item: any) => {\n return item.brand === brand && item.subscribe\n })\n\n if (subscribeResult) {\n return true\n }\n\n return activities?.some(item => {\n return item.task_sub_type === TaskSubType.Subscription\n })\n }, [subscriptionData?.preference, activities])\n\n return isSubscribed\n}\n"],
|
|
5
|
-
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAwB,iBAExBC,EAA4B,oBAC5BC,EAA0B,8BAC1BC,EAAkC,uBAClCC,EAAqD,yBAE9C,MAAMN,EAAgB,IAAM,CACjC,KAAM,CAAE,QAAAO,CAAQ,KAAI,qBAAkB,EAChC,CAAE,MAAAC,CAAM,KAAI,sBAAmB,EAE/BC,KAAoB,WAAQ,KAAO,CAAE,KAAM,EAAG,SAAU,EAAG,GAAI,CAAC,CAAC,EAEjE,CAAE,WAAAC,CAAW,KAAI,EAAAC,SAAcF,CAAiB,EAChD,CAAE,KAAMG,CAAa,KAAI,oBAAiB,CAAE,MAAOL,GAAS,KAAM,CAAC,
|
|
4
|
+
"sourcesContent": ["import { useMemo } from 'react'\n\nimport { TaskSubType } from '../const'\nimport useActivities from './useActivities'\nimport { useCreditsContext } from '../provider'\nimport { useHeadlessContext, useSubscriptions } from '@anker-in/lib'\n\nexport const useSubscribed = () => {\n const { profile } = useCreditsContext()\n const { brand } = useHeadlessContext()\n\n const activitiesOptions = useMemo(() => ({ page: 1, pageSize: 50 }), [])\n\n const { activities } = useActivities(activitiesOptions)\n const { data: subscription } = useSubscriptions({ email: profile?.email })\n //@ts-ignore\n const subscriptionData = subscription?.data || subscription\n\n const isSubscribed = useMemo(() => {\n if (!subscriptionData?.preference) {\n return false\n }\n\n const subscribeResult = subscriptionData.preference.some((item: any) => {\n return item.brand === brand && item.subscribe\n })\n\n if (subscribeResult) {\n return true\n }\n\n return activities?.some(item => {\n return item.task_sub_type === TaskSubType.Subscription\n })\n }, [subscriptionData?.preference, activities])\n\n return isSubscribed\n}\n"],
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAwB,iBAExBC,EAA4B,oBAC5BC,EAA0B,8BAC1BC,EAAkC,uBAClCC,EAAqD,yBAE9C,MAAMN,EAAgB,IAAM,CACjC,KAAM,CAAE,QAAAO,CAAQ,KAAI,qBAAkB,EAChC,CAAE,MAAAC,CAAM,KAAI,sBAAmB,EAE/BC,KAAoB,WAAQ,KAAO,CAAE,KAAM,EAAG,SAAU,EAAG,GAAI,CAAC,CAAC,EAEjE,CAAE,WAAAC,CAAW,KAAI,EAAAC,SAAcF,CAAiB,EAChD,CAAE,KAAMG,CAAa,KAAI,oBAAiB,CAAE,MAAOL,GAAS,KAAM,CAAC,EAEnEM,EAAmBD,GAAc,MAAQA,EAoB/C,SAlBqB,WAAQ,IACtBC,GAAkB,WAICA,EAAiB,WAAW,KAAMC,GACjDA,EAAK,QAAUN,GAASM,EAAK,SACrC,EAGQ,GAGFJ,GAAY,KAAKI,GACfA,EAAK,gBAAkB,cAAY,YAC3C,EAbQ,GAcR,CAACD,GAAkB,WAAYH,CAAU,CAAC,CAG/C",
|
|
6
6
|
"names": ["useSubscribed_exports", "__export", "useSubscribed", "__toCommonJS", "import_react", "import_const", "import_useActivities", "import_provider", "import_lib", "profile", "brand", "activitiesOptions", "activities", "useActivities", "subscription", "subscriptionData", "item"]
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { default as Chat } from './chat/index';
|
|
2
|
-
export { Role, ActionExecutionMessage, TextMessage, useCopilotChat, useCopilotAction, useCopilotReadable, } from './chat/utils';
|
|
1
|
+
export { default as Chat } from './chat/index.js';
|
|
2
|
+
export { Role, ActionExecutionMessage, TextMessage, useCopilotChat, useCopilotAction, useCopilotReadable, } from './chat/utils.js';
|
|
3
3
|
export * from './credits/index.js';
|
|
4
4
|
export * from './registration/index.js';
|
|
5
5
|
export * from './memberPopup/index.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var l=Object.create;var C=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var M=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty;var f=(e,t)=>{for(var s in t)C(e,s,{get:t[s],enumerable:!0})},i=(e,t,s,p)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of x(t))!c.call(e,a)&&a!==s&&C(e,a,{get:()=>t[a],enumerable:!(p=u(t,a))||p.enumerable});return e},r=(e,t,s)=>(i(e,t,"default"),s&&i(s,t,"default")),m=(e,t,s)=>(s=e!=null?l(M(e)):{},i(t||!e||!e.__esModule?C(s,"default",{value:e,enumerable:!0}):s,e)),h=e=>i(C({},"__esModule",{value:!0}),e);var n={};f(n,{ActionExecutionMessage:()=>o.ActionExecutionMessage,Chat:()=>g.default,LiveChatWidget:()=>d.LiveChatWidget,Role:()=>o.Role,TextMessage:()=>o.TextMessage,useCopilotAction:()=>o.useCopilotAction,useCopilotChat:()=>o.useCopilotChat,useCopilotReadable:()=>o.useCopilotReadable});module.exports=h(n);var g=m(require("./chat/index")),o=require("./chat/utils");r(n,require("./credits/index.js"),module.exports);r(n,require("./registration/index.js"),module.exports);r(n,require("./memberPopup/index.js"),module.exports);var d=require("./LiveChatWidget/index.js");
|
|
1
|
+
"use strict";var l=Object.create;var C=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var M=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty;var f=(e,t)=>{for(var s in t)C(e,s,{get:t[s],enumerable:!0})},i=(e,t,s,p)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of x(t))!c.call(e,a)&&a!==s&&C(e,a,{get:()=>t[a],enumerable:!(p=u(t,a))||p.enumerable});return e},r=(e,t,s)=>(i(e,t,"default"),s&&i(s,t,"default")),m=(e,t,s)=>(s=e!=null?l(M(e)):{},i(t||!e||!e.__esModule?C(s,"default",{value:e,enumerable:!0}):s,e)),h=e=>i(C({},"__esModule",{value:!0}),e);var n={};f(n,{ActionExecutionMessage:()=>o.ActionExecutionMessage,Chat:()=>g.default,LiveChatWidget:()=>d.LiveChatWidget,Role:()=>o.Role,TextMessage:()=>o.TextMessage,useCopilotAction:()=>o.useCopilotAction,useCopilotChat:()=>o.useCopilotChat,useCopilotReadable:()=>o.useCopilotReadable});module.exports=h(n);var g=m(require("./chat/index.js")),o=require("./chat/utils.js");r(n,require("./credits/index.js"),module.exports);r(n,require("./registration/index.js"),module.exports);r(n,require("./memberPopup/index.js"),module.exports);var d=require("./LiveChatWidget/index.js");
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/index.ts"],
|
|
4
|
-
"sourcesContent": ["export { default as Chat } from './chat/index'\n\nexport {\n Role,\n ActionExecutionMessage,\n TextMessage,\n useCopilotChat,\n useCopilotAction,\n useCopilotReadable,\n} from './chat/utils'\n\nexport * from './credits/index.js'\n\nexport * from './registration/index.js'\n\nexport * from './memberPopup/index.js'\n\n\n\n// LiveChatWidget \u5BFC\u51FA\nexport { LiveChatWidget } from './LiveChatWidget/index.js'\nexport type {\n LiveChatWidgetProps,\n Message,\n MessageContent,\n MessageRole,\n MessageContentType,\n MessageMetadata,\n MessageRenderer,\n QuickReply,\n ProductCardContent,\n ProductListContent,\n PolicyContent,\n QuickRepliesContent,\n ThinkingContent,\n ErrorContent,\n SSEEvent,\n ChatStreamRequest,\n} from './LiveChatWidget/index.js'\n"],
|
|
5
|
-
"mappings": "wmBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mSAAAE,EAAAF,GAAA,IAAAG,EAAgC,
|
|
4
|
+
"sourcesContent": ["export { default as Chat } from './chat/index.js'\n\nexport {\n Role,\n ActionExecutionMessage,\n TextMessage,\n useCopilotChat,\n useCopilotAction,\n useCopilotReadable,\n} from './chat/utils.js'\n\nexport * from './credits/index.js'\n\nexport * from './registration/index.js'\n\nexport * from './memberPopup/index.js'\n\n\n\n// LiveChatWidget \u5BFC\u51FA\nexport { LiveChatWidget } from './LiveChatWidget/index.js'\nexport type {\n LiveChatWidgetProps,\n Message,\n MessageContent,\n MessageRole,\n MessageContentType,\n MessageMetadata,\n MessageRenderer,\n QuickReply,\n ProductCardContent,\n ProductListContent,\n PolicyContent,\n QuickRepliesContent,\n ThinkingContent,\n ErrorContent,\n SSEEvent,\n ChatStreamRequest,\n} from './LiveChatWidget/index.js'\n"],
|
|
5
|
+
"mappings": "wmBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mSAAAE,EAAAF,GAAA,IAAAG,EAAgC,8BAEhCC,EAOO,2BAEPC,EAAAL,EAAc,8BAXd,gBAaAK,EAAAL,EAAc,mCAbd,gBAeAK,EAAAL,EAAc,kCAfd,gBAoBA,IAAAM,EAA+B",
|
|
6
6
|
"names": ["components_exports", "__export", "__toCommonJS", "import_chat", "import_utils", "__reExport", "import_LiveChatWidget"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CartCard Storybook Stories
|
|
3
|
+
* 展示购物车卡片组件的各种状态
|
|
4
|
+
*/
|
|
5
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import type { CartContent } from '../components/LiveChatWidget/types';
|
|
8
|
+
declare const CartCardWrapper: React.FC<{
|
|
9
|
+
content: CartContent;
|
|
10
|
+
}>;
|
|
11
|
+
declare const meta: Meta<typeof CartCardWrapper>;
|
|
12
|
+
export default meta;
|
|
13
|
+
type Story = StoryObj<typeof CartCardWrapper>;
|
|
14
|
+
/**
|
|
15
|
+
* 空购物车状态
|
|
16
|
+
*/
|
|
17
|
+
export declare const Empty: Story;
|
|
18
|
+
/**
|
|
19
|
+
* 单件商品
|
|
20
|
+
*/
|
|
21
|
+
export declare const SingleItem: Story;
|
|
22
|
+
/**
|
|
23
|
+
* 多件商品
|
|
24
|
+
*/
|
|
25
|
+
export declare const MultipleItems: Story;
|
|
26
|
+
/**
|
|
27
|
+
* 有折扣码的购物车
|
|
28
|
+
*/
|
|
29
|
+
export declare const WithDiscount: Story;
|
|
30
|
+
/**
|
|
31
|
+
* 多个折扣码(部分失效)
|
|
32
|
+
*/
|
|
33
|
+
export declare const WithMultipleDiscounts: Story;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";var c=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var p=(t,e)=>{for(var a in e)c(t,a,{get:e[a],enumerable:!0})},m=(t,e,a,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of d(e))!s.call(t,o)&&o!==a&&c(t,o,{get:()=>e[o],enumerable:!(n=i(e,o))||n.enumerable});return t};var y=t=>m(c({},"__esModule",{value:!0}),t);var A={};p(A,{Empty:()=>S,MultipleItems:()=>g,SingleItem:()=>f,WithDiscount:()=>U,WithMultipleDiscounts:()=>D,default:()=>C});module.exports=y(A);var r=require("react/jsx-runtime"),u=require("../components/LiveChatWidget/components/MessageContent/CartCard.js");const l=({content:t})=>(0,r.jsx)("div",{className:"flex min-h-screen items-center justify-center bg-gray-100 p-4",children:(0,r.jsx)("div",{className:"w-full max-w-md",children:u.CartCard.render(t,!1,!1)})}),h={title:"Campaign/LiveChatWidget/MessageContent/CartCard",component:l,parameters:{layout:"fullscreen",docs:{description:{component:`
|
|
2
|
+
# \u8D2D\u7269\u8F66\u5361\u7247\u7EC4\u4EF6
|
|
3
|
+
|
|
4
|
+
\u663E\u793A\u7528\u6237\u8D2D\u7269\u8F66\u5185\u5BB9\uFF0C\u5305\u62EC\u5546\u54C1\u5217\u8868\u3001\u4EF7\u683C\u6C47\u603B\u548C\u7ED3\u8D26\u6309\u94AE\u3002
|
|
5
|
+
|
|
6
|
+
## \u529F\u80FD\u7279\u6027
|
|
7
|
+
|
|
8
|
+
- \u{1F4E6} **\u5546\u54C1\u5217\u8868**: \u5C55\u793A\u8D2D\u7269\u8F66\u4E2D\u7684\u6240\u6709\u5546\u54C1
|
|
9
|
+
- \u{1F4B0} **\u4EF7\u683C\u6C47\u603B**: \u663E\u793A\u5C0F\u8BA1\u3001\u6298\u6263\u548C\u603B\u8BA1
|
|
10
|
+
- \u{1F39F}\uFE0F **\u6298\u6263\u7801**: \u663E\u793A\u5DF2\u5E94\u7528\u7684\u6298\u6263\u7801\u53CA\u5176\u72B6\u6001
|
|
11
|
+
- \u{1F6D2} **\u7ED3\u8D26\u6309\u94AE**: \u4E00\u952E\u8DF3\u8F6C\u5230 Shopify \u7ED3\u8D26\u9875\u9762
|
|
12
|
+
- \u{1F233} **\u7A7A\u72B6\u6001**: \u4F18\u96C5\u7684\u7A7A\u8D2D\u7269\u8F66\u63D0\u793A
|
|
13
|
+
|
|
14
|
+
## \u4F7F\u7528\u573A\u666F
|
|
15
|
+
|
|
16
|
+
- \u7528\u6237\u6DFB\u52A0\u5546\u54C1\u5230\u8D2D\u7269\u8F66\u540E (add_to_cart)
|
|
17
|
+
- \u7528\u6237\u67E5\u8BE2\u8D2D\u7269\u8F66\u5185\u5BB9 (get_cart)
|
|
18
|
+
- \u7528\u6237\u4FEE\u6539\u8D2D\u7269\u8F66\u6570\u91CF (update_cart_item)
|
|
19
|
+
- \u7528\u6237\u5E94\u7528\u6298\u6263\u7801 (update_discount_codes)
|
|
20
|
+
`}}},tags:["autodocs"]};var C=h;const S={args:{content:{type:"cart",data:{isEmpty:!0,cartId:"gid://shopify/Cart/empty",totalQuantity:0,lines:[],cost:{totalAmount:{amount:"0.00",currencyCode:"USD"},subtotalAmount:{amount:"0.00",currencyCode:"USD"}}}}}},f={args:{content:{type:"cart",data:{isEmpty:!1,cartId:"gid://shopify/Cart/Z2NwLXVzLWVhc3QxOjAxSkZHRjA4VkFRQkhON1dBMTNLREZEVEZH",totalQuantity:1,lines:[{id:"gid://shopify/CartLine/12345",quantity:1,cost:{totalAmount:{amount:"99.99",currencyCode:"USD"},amountPerQuantity:{amount:"99.99",currencyCode:"USD"},subtotalAmount:{amount:"99.99",currencyCode:"USD"}},merchandise:{id:"gid://shopify/ProductVariant/43234567890",title:"Black",price:{amount:"99.99",currencyCode:"USD"},image:{url:"https://images.unsplash.com/photo-1505740420928-5e560c06d30e?w=400&h=400&fit=crop",altText:"Soundcore Space One"},product:{id:"gid://shopify/Product/8179159826618",title:"Soundcore Space One",handle:"soundcore-space-one"}}}],cost:{totalAmount:{amount:"99.99",currencyCode:"USD"},subtotalAmount:{amount:"99.99",currencyCode:"USD"}},checkoutUrl:"https://checkout.shopify.com/example"}}}},g={args:{content:{type:"cart",data:{isEmpty:!1,cartId:"gid://shopify/Cart/Z2NwLXVzLWVhc3QxOjAxSkZHRjA4VkFRQkhON1dBMTNLREZEVEZH",totalQuantity:5,lines:[{id:"gid://shopify/CartLine/12345",quantity:2,cost:{totalAmount:{amount:"199.98",currencyCode:"USD"},amountPerQuantity:{amount:"99.99",currencyCode:"USD"},subtotalAmount:{amount:"199.98",currencyCode:"USD"}},merchandise:{id:"gid://shopify/ProductVariant/43234567890",title:"Black",price:{amount:"99.99",currencyCode:"USD"},image:{url:"https://images.unsplash.com/photo-1505740420928-5e560c06d30e?w=400&h=400&fit=crop",altText:"Soundcore Space One"},product:{id:"gid://shopify/Product/8179159826618",title:"Soundcore Space One",handle:"soundcore-space-one"}}},{id:"gid://shopify/CartLine/12346",quantity:1,cost:{totalAmount:{amount:"129.99",currencyCode:"USD"},amountPerQuantity:{amount:"129.99",currencyCode:"USD"},subtotalAmount:{amount:"129.99",currencyCode:"USD"}},merchandise:{id:"gid://shopify/ProductVariant/43234567891",title:"White",price:{amount:"129.99",currencyCode:"USD"},image:{url:"https://images.unsplash.com/photo-1484704849700-f032a568e944?w=400&h=400&fit=crop",altText:"eufy Security Camera"},product:{id:"gid://shopify/Product/8179159826619",title:"eufy Security Camera",handle:"eufy-security-camera"}}},{id:"gid://shopify/CartLine/12347",quantity:2,cost:{totalAmount:{amount:"79.98",currencyCode:"USD"},amountPerQuantity:{amount:"39.99",currencyCode:"USD"},subtotalAmount:{amount:"79.98",currencyCode:"USD"}},merchandise:{id:"gid://shopify/ProductVariant/43234567892",title:"USB-C Cable",price:{amount:"39.99",currencyCode:"USD"},image:{url:"https://images.unsplash.com/photo-1583863788434-e58a36330cf0?w=400&h=400&fit=crop",altText:"Anker USB-C Cable"},product:{id:"gid://shopify/Product/8179159826620",title:"Anker USB-C Cable 6ft",handle:"anker-usb-c-cable"}}}],cost:{totalAmount:{amount:"409.95",currencyCode:"USD"},subtotalAmount:{amount:"409.95",currencyCode:"USD"}},checkoutUrl:"https://checkout.shopify.com/example"}}}},U={args:{content:{type:"cart",data:{isEmpty:!1,cartId:"gid://shopify/Cart/Z2NwLXVzLWVhc3QxOjAxSkZHRjA4VkFRQkhON1dBMTNLREZEVEZH",totalQuantity:3,lines:[{id:"gid://shopify/CartLine/12345",quantity:2,cost:{totalAmount:{amount:"199.98",currencyCode:"USD"},amountPerQuantity:{amount:"99.99",currencyCode:"USD"},subtotalAmount:{amount:"199.98",currencyCode:"USD"}},merchandise:{id:"gid://shopify/ProductVariant/43234567890",title:"Black",price:{amount:"99.99",currencyCode:"USD"},image:{url:"https://images.unsplash.com/photo-1505740420928-5e560c06d30e?w=400&h=400&fit=crop",altText:"Soundcore Space One"},product:{id:"gid://shopify/Product/8179159826618",title:"Soundcore Space One",handle:"soundcore-space-one"}}},{id:"gid://shopify/CartLine/12346",quantity:1,cost:{totalAmount:{amount:"129.99",currencyCode:"USD"},amountPerQuantity:{amount:"129.99",currencyCode:"USD"},subtotalAmount:{amount:"129.99",currencyCode:"USD"}},merchandise:{id:"gid://shopify/ProductVariant/43234567891",title:"White",price:{amount:"129.99",currencyCode:"USD"},image:{url:"https://images.unsplash.com/photo-1484704849700-f032a568e944?w=400&h=400&fit=crop",altText:"eufy Security Camera"},product:{id:"gid://shopify/Product/8179159826619",title:"eufy Security Camera",handle:"eufy-security-camera"}}}],cost:{totalAmount:{amount:"296.97",currencyCode:"USD"},subtotalAmount:{amount:"329.97",currencyCode:"USD"}},discountCodes:[{code:"SPRING20",applicable:!0}],checkoutUrl:"https://checkout.shopify.com/example"}}}},D={args:{content:{type:"cart",data:{isEmpty:!1,cartId:"gid://shopify/Cart/Z2NwLXVzLWVhc3QxOjAxSkZHRjA4VkFRQkhON1dBMTNLREZEVEZH",totalQuantity:2,lines:[{id:"gid://shopify/CartLine/12345",quantity:2,cost:{totalAmount:{amount:"199.98",currencyCode:"USD"},amountPerQuantity:{amount:"99.99",currencyCode:"USD"},subtotalAmount:{amount:"199.98",currencyCode:"USD"}},merchandise:{id:"gid://shopify/ProductVariant/43234567890",title:"Black",price:{amount:"99.99",currencyCode:"USD"},image:{url:"https://images.unsplash.com/photo-1505740420928-5e560c06d30e?w=400&h=400&fit=crop",altText:"Soundcore Space One"},product:{id:"gid://shopify/Product/8179159826618",title:"Soundcore Space One",handle:"soundcore-space-one"}}}],cost:{totalAmount:{amount:"179.98",currencyCode:"USD"},subtotalAmount:{amount:"199.98",currencyCode:"USD"}},discountCodes:[{code:"WELCOME10",applicable:!0},{code:"EXPIRED20",applicable:!1}],checkoutUrl:"https://checkout.shopify.com/example"}}}};
|
|
21
|
+
//# sourceMappingURL=CartCard.stories.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/stories/CartCard.stories.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * CartCard Storybook Stories\n * \u5C55\u793A\u8D2D\u7269\u8F66\u5361\u7247\u7EC4\u4EF6\u7684\u5404\u79CD\u72B6\u6001\n */\n\nimport type { Meta, StoryObj } from '@storybook/react'\nimport React from 'react'\nimport { CartCard } from '../components/LiveChatWidget/components/MessageContent/CartCard.js'\nimport type { CartContent } from '../components/LiveChatWidget/types'\n\n// Story \u5305\u88C5\u7EC4\u4EF6\nconst CartCardWrapper: React.FC<{ content: CartContent }> = ({ content }) => {\n return (\n <div className=\"flex min-h-screen items-center justify-center bg-gray-100 p-4\">\n <div className=\"w-full max-w-md\">{CartCard.render(content, false, false)}</div>\n </div>\n )\n}\n\nconst meta: Meta<typeof CartCardWrapper> = {\n title: 'Campaign/LiveChatWidget/MessageContent/CartCard',\n component: CartCardWrapper,\n parameters: {\n layout: 'fullscreen',\n docs: {\n description: {\n component: `\n# \u8D2D\u7269\u8F66\u5361\u7247\u7EC4\u4EF6\n\n\u663E\u793A\u7528\u6237\u8D2D\u7269\u8F66\u5185\u5BB9\uFF0C\u5305\u62EC\u5546\u54C1\u5217\u8868\u3001\u4EF7\u683C\u6C47\u603B\u548C\u7ED3\u8D26\u6309\u94AE\u3002\n\n## \u529F\u80FD\u7279\u6027\n\n- \uD83D\uDCE6 **\u5546\u54C1\u5217\u8868**: \u5C55\u793A\u8D2D\u7269\u8F66\u4E2D\u7684\u6240\u6709\u5546\u54C1\n- \uD83D\uDCB0 **\u4EF7\u683C\u6C47\u603B**: \u663E\u793A\u5C0F\u8BA1\u3001\u6298\u6263\u548C\u603B\u8BA1\n- \uD83C\uDF9F\uFE0F **\u6298\u6263\u7801**: \u663E\u793A\u5DF2\u5E94\u7528\u7684\u6298\u6263\u7801\u53CA\u5176\u72B6\u6001\n- \uD83D\uDED2 **\u7ED3\u8D26\u6309\u94AE**: \u4E00\u952E\u8DF3\u8F6C\u5230 Shopify \u7ED3\u8D26\u9875\u9762\n- \uD83C\uDE33 **\u7A7A\u72B6\u6001**: \u4F18\u96C5\u7684\u7A7A\u8D2D\u7269\u8F66\u63D0\u793A\n\n## \u4F7F\u7528\u573A\u666F\n\n- \u7528\u6237\u6DFB\u52A0\u5546\u54C1\u5230\u8D2D\u7269\u8F66\u540E (add_to_cart)\n- \u7528\u6237\u67E5\u8BE2\u8D2D\u7269\u8F66\u5185\u5BB9 (get_cart)\n- \u7528\u6237\u4FEE\u6539\u8D2D\u7269\u8F66\u6570\u91CF (update_cart_item)\n- \u7528\u6237\u5E94\u7528\u6298\u6263\u7801 (update_discount_codes)\n `,\n },\n },\n },\n tags: ['autodocs'],\n}\n\nexport default meta\n\ntype Story = StoryObj<typeof CartCardWrapper>\n\n/**\n * \u7A7A\u8D2D\u7269\u8F66\u72B6\u6001\n */\nexport const Empty: Story = {\n args: {\n content: {\n type: 'cart',\n data: {\n isEmpty: true,\n cartId: 'gid://shopify/Cart/empty',\n totalQuantity: 0,\n lines: [],\n cost: {\n totalAmount: {\n amount: '0.00',\n currencyCode: 'USD',\n },\n subtotalAmount: {\n amount: '0.00',\n currencyCode: 'USD',\n },\n },\n },\n },\n },\n}\n\n/**\n * \u5355\u4EF6\u5546\u54C1\n */\nexport const SingleItem: Story = {\n args: {\n content: {\n type: 'cart',\n data: {\n isEmpty: false,\n cartId: 'gid://shopify/Cart/Z2NwLXVzLWVhc3QxOjAxSkZHRjA4VkFRQkhON1dBMTNLREZEVEZH',\n totalQuantity: 1,\n lines: [\n {\n id: 'gid://shopify/CartLine/12345',\n quantity: 1,\n cost: {\n totalAmount: {\n amount: '99.99',\n currencyCode: 'USD',\n },\n amountPerQuantity: {\n amount: '99.99',\n currencyCode: 'USD',\n },\n subtotalAmount: {\n amount: '99.99',\n currencyCode: 'USD',\n },\n },\n merchandise: {\n id: 'gid://shopify/ProductVariant/43234567890',\n title: 'Black',\n price: {\n amount: '99.99',\n currencyCode: 'USD',\n },\n image: {\n url: 'https://images.unsplash.com/photo-1505740420928-5e560c06d30e?w=400&h=400&fit=crop',\n altText: 'Soundcore Space One',\n },\n product: {\n id: 'gid://shopify/Product/8179159826618',\n title: 'Soundcore Space One',\n handle: 'soundcore-space-one',\n },\n },\n },\n ],\n cost: {\n totalAmount: {\n amount: '99.99',\n currencyCode: 'USD',\n },\n subtotalAmount: {\n amount: '99.99',\n currencyCode: 'USD',\n },\n },\n checkoutUrl: 'https://checkout.shopify.com/example',\n },\n },\n },\n}\n\n/**\n * \u591A\u4EF6\u5546\u54C1\n */\nexport const MultipleItems: Story = {\n args: {\n content: {\n type: 'cart',\n data: {\n isEmpty: false,\n cartId: 'gid://shopify/Cart/Z2NwLXVzLWVhc3QxOjAxSkZHRjA4VkFRQkhON1dBMTNLREZEVEZH',\n totalQuantity: 5,\n lines: [\n {\n id: 'gid://shopify/CartLine/12345',\n quantity: 2,\n cost: {\n totalAmount: {\n amount: '199.98',\n currencyCode: 'USD',\n },\n amountPerQuantity: {\n amount: '99.99',\n currencyCode: 'USD',\n },\n subtotalAmount: {\n amount: '199.98',\n currencyCode: 'USD',\n },\n },\n merchandise: {\n id: 'gid://shopify/ProductVariant/43234567890',\n title: 'Black',\n price: {\n amount: '99.99',\n currencyCode: 'USD',\n },\n image: {\n url: 'https://images.unsplash.com/photo-1505740420928-5e560c06d30e?w=400&h=400&fit=crop',\n altText: 'Soundcore Space One',\n },\n product: {\n id: 'gid://shopify/Product/8179159826618',\n title: 'Soundcore Space One',\n handle: 'soundcore-space-one',\n },\n },\n },\n {\n id: 'gid://shopify/CartLine/12346',\n quantity: 1,\n cost: {\n totalAmount: {\n amount: '129.99',\n currencyCode: 'USD',\n },\n amountPerQuantity: {\n amount: '129.99',\n currencyCode: 'USD',\n },\n subtotalAmount: {\n amount: '129.99',\n currencyCode: 'USD',\n },\n },\n merchandise: {\n id: 'gid://shopify/ProductVariant/43234567891',\n title: 'White',\n price: {\n amount: '129.99',\n currencyCode: 'USD',\n },\n image: {\n url: 'https://images.unsplash.com/photo-1484704849700-f032a568e944?w=400&h=400&fit=crop',\n altText: 'eufy Security Camera',\n },\n product: {\n id: 'gid://shopify/Product/8179159826619',\n title: 'eufy Security Camera',\n handle: 'eufy-security-camera',\n },\n },\n },\n {\n id: 'gid://shopify/CartLine/12347',\n quantity: 2,\n cost: {\n totalAmount: {\n amount: '79.98',\n currencyCode: 'USD',\n },\n amountPerQuantity: {\n amount: '39.99',\n currencyCode: 'USD',\n },\n subtotalAmount: {\n amount: '79.98',\n currencyCode: 'USD',\n },\n },\n merchandise: {\n id: 'gid://shopify/ProductVariant/43234567892',\n title: 'USB-C Cable',\n price: {\n amount: '39.99',\n currencyCode: 'USD',\n },\n image: {\n url: 'https://images.unsplash.com/photo-1583863788434-e58a36330cf0?w=400&h=400&fit=crop',\n altText: 'Anker USB-C Cable',\n },\n product: {\n id: 'gid://shopify/Product/8179159826620',\n title: 'Anker USB-C Cable 6ft',\n handle: 'anker-usb-c-cable',\n },\n },\n },\n ],\n cost: {\n totalAmount: {\n amount: '409.95',\n currencyCode: 'USD',\n },\n subtotalAmount: {\n amount: '409.95',\n currencyCode: 'USD',\n },\n },\n checkoutUrl: 'https://checkout.shopify.com/example',\n },\n },\n },\n}\n\n/**\n * \u6709\u6298\u6263\u7801\u7684\u8D2D\u7269\u8F66\n */\nexport const WithDiscount: Story = {\n args: {\n content: {\n type: 'cart',\n data: {\n isEmpty: false,\n cartId: 'gid://shopify/Cart/Z2NwLXVzLWVhc3QxOjAxSkZHRjA4VkFRQkhON1dBMTNLREZEVEZH',\n totalQuantity: 3,\n lines: [\n {\n id: 'gid://shopify/CartLine/12345',\n quantity: 2,\n cost: {\n totalAmount: {\n amount: '199.98',\n currencyCode: 'USD',\n },\n amountPerQuantity: {\n amount: '99.99',\n currencyCode: 'USD',\n },\n subtotalAmount: {\n amount: '199.98',\n currencyCode: 'USD',\n },\n },\n merchandise: {\n id: 'gid://shopify/ProductVariant/43234567890',\n title: 'Black',\n price: {\n amount: '99.99',\n currencyCode: 'USD',\n },\n image: {\n url: 'https://images.unsplash.com/photo-1505740420928-5e560c06d30e?w=400&h=400&fit=crop',\n altText: 'Soundcore Space One',\n },\n product: {\n id: 'gid://shopify/Product/8179159826618',\n title: 'Soundcore Space One',\n handle: 'soundcore-space-one',\n },\n },\n },\n {\n id: 'gid://shopify/CartLine/12346',\n quantity: 1,\n cost: {\n totalAmount: {\n amount: '129.99',\n currencyCode: 'USD',\n },\n amountPerQuantity: {\n amount: '129.99',\n currencyCode: 'USD',\n },\n subtotalAmount: {\n amount: '129.99',\n currencyCode: 'USD',\n },\n },\n merchandise: {\n id: 'gid://shopify/ProductVariant/43234567891',\n title: 'White',\n price: {\n amount: '129.99',\n currencyCode: 'USD',\n },\n image: {\n url: 'https://images.unsplash.com/photo-1484704849700-f032a568e944?w=400&h=400&fit=crop',\n altText: 'eufy Security Camera',\n },\n product: {\n id: 'gid://shopify/Product/8179159826619',\n title: 'eufy Security Camera',\n handle: 'eufy-security-camera',\n },\n },\n },\n ],\n cost: {\n totalAmount: {\n amount: '296.97',\n currencyCode: 'USD',\n },\n subtotalAmount: {\n amount: '329.97',\n currencyCode: 'USD',\n },\n },\n discountCodes: [\n {\n code: 'SPRING20',\n applicable: true,\n },\n ],\n checkoutUrl: 'https://checkout.shopify.com/example',\n },\n },\n },\n}\n\n/**\n * \u591A\u4E2A\u6298\u6263\u7801\uFF08\u90E8\u5206\u5931\u6548\uFF09\n */\nexport const WithMultipleDiscounts: Story = {\n args: {\n content: {\n type: 'cart',\n data: {\n isEmpty: false,\n cartId: 'gid://shopify/Cart/Z2NwLXVzLWVhc3QxOjAxSkZHRjA4VkFRQkhON1dBMTNLREZEVEZH',\n totalQuantity: 2,\n lines: [\n {\n id: 'gid://shopify/CartLine/12345',\n quantity: 2,\n cost: {\n totalAmount: {\n amount: '199.98',\n currencyCode: 'USD',\n },\n amountPerQuantity: {\n amount: '99.99',\n currencyCode: 'USD',\n },\n subtotalAmount: {\n amount: '199.98',\n currencyCode: 'USD',\n },\n },\n merchandise: {\n id: 'gid://shopify/ProductVariant/43234567890',\n title: 'Black',\n price: {\n amount: '99.99',\n currencyCode: 'USD',\n },\n image: {\n url: 'https://images.unsplash.com/photo-1505740420928-5e560c06d30e?w=400&h=400&fit=crop',\n altText: 'Soundcore Space One',\n },\n product: {\n id: 'gid://shopify/Product/8179159826618',\n title: 'Soundcore Space One',\n handle: 'soundcore-space-one',\n },\n },\n },\n ],\n cost: {\n totalAmount: {\n amount: '179.98',\n currencyCode: 'USD',\n },\n subtotalAmount: {\n amount: '199.98',\n currencyCode: 'USD',\n },\n },\n discountCodes: [\n {\n code: 'WELCOME10',\n applicable: true,\n },\n {\n code: 'EXPIRED20',\n applicable: false,\n },\n ],\n checkoutUrl: 'https://checkout.shopify.com/example',\n },\n },\n },\n}\n"],
|
|
5
|
+
"mappings":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F,EAKaC,EAA+B,CAC1C,KAAM,CACJ,QAAS,CACP,KAAM,OACN,KAAM,CACJ,QAAS,GACT,OAAQ,0EACR,cAAe,EACf,MAAO,CACL,CACE,GAAI,+BACJ,SAAU,EACV,KAAM,CACJ,YAAa,CACX,OAAQ,SACR,aAAc,KAChB,EACA,kBAAmB,CACjB,OAAQ,QACR,aAAc,KAChB,EACA,eAAgB,CACd,OAAQ,SACR,aAAc,KAChB,CACF,EACA,YAAa,CACX,GAAI,2CACJ,MAAO,QACP,MAAO,CACL,OAAQ,QACR,aAAc,KAChB,EACA,MAAO,CACL,IAAK,oFACL,QAAS,qBACX,EACA,QAAS,CACP,GAAI,sCACJ,MAAO,sBACP,OAAQ,qBACV,CACF,CACF,CACF,EACA,KAAM,CACJ,YAAa,CACX,OAAQ,SACR,aAAc,KAChB,EACA,eAAgB,CACd,OAAQ,SACR,aAAc,KAChB,CACF,EACA,cAAe,CACb,CACE,KAAM,YACN,WAAY,EACd,EACA,CACE,KAAM,YACN,WAAY,EACd,CACF,EACA,YAAa,sCACf,CACF,CACF,CACF",
|
|
6
|
+
"names": ["CartCard_stories_exports", "__export", "Empty", "MultipleItems", "SingleItem", "WithDiscount", "WithMultipleDiscounts", "CartCard_stories_default", "__toCommonJS", "import_jsx_runtime", "import_CartCard", "CartCardWrapper", "content", "meta"]
|
|
7
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as e,jsxs as r}from"react/jsx-runtime";import{useState as g}from"react";import x from"react-markdown";import v from"remark-gfm";const
|
|
1
|
+
import{jsx as e,jsxs as r}from"react/jsx-runtime";import{useState as g}from"react";import x from"react-markdown";import v from"remark-gfm";const h={render:n=>n.type!=="faq_list"?null:e(f,{content:n})},f=({content:n,onQuestionClick:d})=>{const{found:l,count:b,total:k,results:i}=n.data,[c,p]=g(new Set);if(!l||i.length===0)return e("div",{className:"rounded-lg border border-gray-200 bg-white p-4",children:e("p",{className:"text-sm text-gray-500",children:"\u672A\u627E\u5230\u76F8\u5173\u95EE\u9898"})});const m=t=>{p(a=>{const s=new Set(a);return s.has(t)?s.delete(t):s.add(t),s})},u=t=>{d?.(t)};return e("div",{className:"space-y-2",children:e("div",{className:"space-y-2",children:i.map(t=>{const a=c.has(t.id);return r("div",{className:"overflow-hidden rounded-2xl bg-[#F5F6F7] transition-all",children:[r("button",{onClick:()=>m(t.id),className:"flex w-full items-center justify-between gap-3 p-4 text-left transition-colors ",children:[e("div",{className:"flex-1",children:e("div",{className:"flex items-center gap-2",children:e("span",{className:"text-base font-bold leading-[1.4] tracking-[-0.02em] text-[#080A0F]",children:t.question})})}),e("svg",{className:`size-5 shrink-0 text-[#080A0F] transition-transform ${a?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),a&&r("div",{className:" bg-[#F5F6F7] px-4 py-3 pt-0",children:[e("div",{className:"prose prose-sm max-w-none border-t border-gray-100 text-sm font-bold leading-[1.4] tracking-[-0.02em] text-[#4A4C56]",style:{paddingTop:"12px"},children:e(x,{remarkPlugins:[v],components:{a:({node:s,...o})=>e("a",{...o,className:"livechat-link livechat-link-bot",target:"_blank",rel:"noopener noreferrer"})},children:t.answer})}),t.relatedQuestions&&t.relatedQuestions.length>0&&r("div",{className:"mt-4 border-t border-gray-200 pt-3",children:[e("p",{className:"mb-2 text-xs font-medium text-gray-500",children:"You may also want to know:"}),e("div",{className:"space-y-1",children:t.relatedQuestions.map((s,o)=>e("button",{onClick:()=>u(s),className:"block w-full text-left text-xs text-blue-600 hover:text-blue-700 hover:underline",children:s},o))})]})]})]},t.id)})})})};export{f as FAQList,h as FAQListRenderer};
|
|
2
2
|
//# sourceMappingURL=FAQList.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/components/LiveChatWidget/components/MessageContent/FAQList.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * FAQ \u5217\u8868\u7EC4\u4EF6\n * \u663E\u793A\u5E38\u89C1\u95EE\u9898\u5217\u8868\uFF0C\u652F\u6301\u6298\u53E0/\u5C55\u5F00\n */\n\nimport React, { useState } from 'react'\nimport ReactMarkdown from 'react-markdown'\nimport remarkGfm from 'remark-gfm'\nimport type { FAQListContent, FAQItem, MessageRenderer, MessageContent } from '../../types'\n\nexport interface FAQListProps {\n content: FAQListContent\n onQuestionClick?: (question: string) => void\n}\n\n/**\n * FAQ \u5217\u8868\u6E32\u67D3\u5668\n * \u7528\u4E8E\u6CE8\u518C\u5230 MessageRendererRegistry\n */\nexport const FAQListRenderer: MessageRenderer = {\n render: (content: MessageContent) => {\n if (content.type !== 'faq_list') {\n return null\n }\n return <FAQList content={content as FAQListContent} />\n },\n}\n\nexport const FAQList: React.FC<FAQListProps> = ({ content, onQuestionClick }) => {\n const { found, count, total, results } = content.data\n const [expandedIds, setExpandedIds] = useState<Set<string>>(new Set())\n\n // \u5982\u679C\u6CA1\u6709\u627E\u5230\u7ED3\u679C\n if (!found || results.length === 0) {\n return (\n <div className=\"rounded-lg border border-gray-200 bg-white p-4\">\n <p className=\"text-sm text-gray-500\">\u672A\u627E\u5230\u76F8\u5173\u95EE\u9898</p>\n </div>\n )\n }\n\n // \u5207\u6362\u5C55\u5F00/\u6298\u53E0\n const toggleExpand = (id: string) => {\n setExpandedIds(prev => {\n const newSet = new Set(prev)\n if (newSet.has(id)) {\n newSet.delete(id)\n } else {\n newSet.add(id)\n }\n return newSet\n })\n }\n\n // \u5904\u7406\u76F8\u5173\u95EE\u9898\u70B9\u51FB\n const handleRelatedQuestionClick = (question: string) => {\n onQuestionClick?.(question)\n }\n\n return (\n <div className=\"space-y-2\">\n {/* FAQ \u5217\u8868 */}\n <div className=\"space-y-2\">\n {results.map(item => {\n const isExpanded = expandedIds.has(item.id)\n\n return (\n <div key={item.id} className=\"overflow-hidden rounded-2xl bg-[#F5F6F7] transition-all\">\n {/* \u95EE\u9898\u6807\u9898 - \u53EF\u70B9\u51FB\u5C55\u5F00/\u6298\u53E0 */}\n <button\n onClick={() => toggleExpand(item.id)}\n className=\"flex w-full items-center justify-between gap-3 p-4 text-left transition-colors \"\n >\n <div className=\"flex-1\">\n <div className=\"flex items-center gap-2\">\n <span className=\"text-base font-bold leading-[1.4] tracking-[-0.02em] text-[#080A0F]\">\n {item.question}\n </span>\n </div>\n </div>\n\n {/* \u5C55\u5F00/\u6298\u53E0\u56FE\u6807 */}\n <svg\n className={`size-5 shrink-0 text-[#080A0F] transition-transform ${isExpanded ? 'rotate-180' : ''}`}\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M19 9l-7 7-7-7\" />\n </svg>\n </button>\n\n {/* \u7B54\u6848\u5185\u5BB9 - \u5C55\u5F00\u65F6\u663E\u793A */}\n {isExpanded && (\n <div className=\" bg-[#F5F6F7] px-4 py-3 pt-0\">\n <div\n className=\"prose prose-sm max-w-none border-t border-gray-100 text-sm font-bold leading-[1.4] tracking-[-0.02em] text-[#4A4C56]\"\n style={{ paddingTop: '12px' }}\n >\n <ReactMarkdown
|
|
5
|
-
"mappings": "AAwBW,cAAAA,EA6CG,QAAAC,MA7CH,oBAnBX,OAAgB,YAAAC,MAAgB,QAChC,OAAOC,MAAmB,iBAC1B,OAAOC,MAAe,aAYf,MAAMC,EAAmC,CAC9C,OAASC,GACHA,EAAQ,OAAS,WACZ,KAEFN,EAACO,EAAA,CAAQ,QAASD,EAA2B,CAExD,EAEaC,EAAkC,CAAC,CAAE,QAAAD,EAAS,gBAAAE,CAAgB,IAAM,CAC/E,KAAM,CAAE,MAAAC,EAAO,MAAAC,EAAO,MAAAC,EAAO,QAAAC,CAAQ,EAAIN,EAAQ,KAC3C,CAACO,EAAaC,CAAc,EAAIZ,EAAsB,IAAI,GAAK,EAGrE,GAAI,CAACO,GAASG,EAAQ,SAAW,EAC/B,OACEZ,EAAC,OAAI,UAAU,iDACb,SAAAA,EAAC,KAAE,UAAU,wBAAwB,sDAAO,EAC9C,EAKJ,MAAMe,EAAgBC,GAAe,CACnCF,EAAeG,GAAQ,CACrB,MAAMC,EAAS,IAAI,IAAID,CAAI,EAC3B,OAAIC,EAAO,IAAIF,CAAE,EACfE,EAAO,OAAOF,CAAE,EAEhBE,EAAO,IAAIF,CAAE,EAERE,CACT,CAAC,CACH,EAGMC,EAA8BC,GAAqB,CACvDZ,IAAkBY,CAAQ,CAC5B,EAEA,OACEpB,EAAC,OAAI,UAAU,YAEb,SAAAA,EAAC,OAAI,UAAU,YACZ,SAAAY,EAAQ,IAAIS,GAAQ,CACnB,MAAMC,EAAaT,EAAY,IAAIQ,EAAK,EAAE,EAE1C,OACEpB,EAAC,OAAkB,UAAU,2DAE3B,UAAAA,EAAC,UACC,QAAS,IAAMc,EAAaM,EAAK,EAAE,EACnC,UAAU,kFAEV,UAAArB,EAAC,OAAI,UAAU,SACb,SAAAA,EAAC,OAAI,UAAU,0BACb,SAAAA,EAAC,QAAK,UAAU,sEACb,SAAAqB,EAAK,SACR,EACF,EACF,EAGArB,EAAC,OACC,UAAW,uDAAuDsB,EAAa,aAAe,EAAE,GAChG,KAAK,OACL,QAAQ,YACR,OAAO,eAEP,SAAAtB,EAAC,QAAK,cAAc,QAAQ,eAAe,QAAQ,YAAa,EAAG,EAAE,iBAAiB,EACxF,GACF,EAGCsB,GACCrB,EAAC,OAAI,UAAU,+BACb,UAAAD,EAAC,OACC,UAAU,wHACV,MAAO,CAAE,WAAY,MAAO,EAE5B,SAAAA,EAACG,EAAA,
|
|
6
|
-
"names": ["jsx", "jsxs", "useState", "ReactMarkdown", "remarkGfm", "FAQListRenderer", "content", "FAQList", "onQuestionClick", "found", "count", "total", "results", "expandedIds", "setExpandedIds", "toggleExpand", "id", "prev", "newSet", "handleRelatedQuestionClick", "question", "item", "isExpanded", "q", "idx"]
|
|
4
|
+
"sourcesContent": ["/**\n * FAQ \u5217\u8868\u7EC4\u4EF6\n * \u663E\u793A\u5E38\u89C1\u95EE\u9898\u5217\u8868\uFF0C\u652F\u6301\u6298\u53E0/\u5C55\u5F00\n */\n\nimport React, { useState } from 'react'\nimport ReactMarkdown from 'react-markdown'\nimport remarkGfm from 'remark-gfm'\nimport type { FAQListContent, FAQItem, MessageRenderer, MessageContent } from '../../types'\n\nexport interface FAQListProps {\n content: FAQListContent\n onQuestionClick?: (question: string) => void\n}\n\n/**\n * FAQ \u5217\u8868\u6E32\u67D3\u5668\n * \u7528\u4E8E\u6CE8\u518C\u5230 MessageRendererRegistry\n */\nexport const FAQListRenderer: MessageRenderer = {\n render: (content: MessageContent) => {\n if (content.type !== 'faq_list') {\n return null\n }\n return <FAQList content={content as FAQListContent} />\n },\n}\n\nexport const FAQList: React.FC<FAQListProps> = ({ content, onQuestionClick }) => {\n const { found, count, total, results } = content.data\n const [expandedIds, setExpandedIds] = useState<Set<string>>(new Set())\n\n // \u5982\u679C\u6CA1\u6709\u627E\u5230\u7ED3\u679C\n if (!found || results.length === 0) {\n return (\n <div className=\"rounded-lg border border-gray-200 bg-white p-4\">\n <p className=\"text-sm text-gray-500\">\u672A\u627E\u5230\u76F8\u5173\u95EE\u9898</p>\n </div>\n )\n }\n\n // \u5207\u6362\u5C55\u5F00/\u6298\u53E0\n const toggleExpand = (id: string) => {\n setExpandedIds(prev => {\n const newSet = new Set(prev)\n if (newSet.has(id)) {\n newSet.delete(id)\n } else {\n newSet.add(id)\n }\n return newSet\n })\n }\n\n // \u5904\u7406\u76F8\u5173\u95EE\u9898\u70B9\u51FB\n const handleRelatedQuestionClick = (question: string) => {\n onQuestionClick?.(question)\n }\n\n return (\n <div className=\"space-y-2\">\n {/* FAQ \u5217\u8868 */}\n <div className=\"space-y-2\">\n {results.map(item => {\n const isExpanded = expandedIds.has(item.id)\n\n return (\n <div key={item.id} className=\"overflow-hidden rounded-2xl bg-[#F5F6F7] transition-all\">\n {/* \u95EE\u9898\u6807\u9898 - \u53EF\u70B9\u51FB\u5C55\u5F00/\u6298\u53E0 */}\n <button\n onClick={() => toggleExpand(item.id)}\n className=\"flex w-full items-center justify-between gap-3 p-4 text-left transition-colors \"\n >\n <div className=\"flex-1\">\n <div className=\"flex items-center gap-2\">\n <span className=\"text-base font-bold leading-[1.4] tracking-[-0.02em] text-[#080A0F]\">\n {item.question}\n </span>\n </div>\n </div>\n\n {/* \u5C55\u5F00/\u6298\u53E0\u56FE\u6807 */}\n <svg\n className={`size-5 shrink-0 text-[#080A0F] transition-transform ${isExpanded ? 'rotate-180' : ''}`}\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M19 9l-7 7-7-7\" />\n </svg>\n </button>\n\n {/* \u7B54\u6848\u5185\u5BB9 - \u5C55\u5F00\u65F6\u663E\u793A */}\n {isExpanded && (\n <div className=\" bg-[#F5F6F7] px-4 py-3 pt-0\">\n <div\n className=\"prose prose-sm max-w-none border-t border-gray-100 text-sm font-bold leading-[1.4] tracking-[-0.02em] text-[#4A4C56]\"\n style={{ paddingTop: '12px' }}\n >\n <ReactMarkdown\n remarkPlugins={[remarkGfm]}\n components={{\n a: ({ node, ...props }) => (\n <a\n {...props}\n className=\"livechat-link livechat-link-bot\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n />\n ),\n }}\n >\n {item.answer}\n </ReactMarkdown>\n </div>\n\n {/* \u76F8\u5173\u95EE\u9898 */}\n {item.relatedQuestions && item.relatedQuestions.length > 0 && (\n <div className=\"mt-4 border-t border-gray-200 pt-3\">\n <p className=\"mb-2 text-xs font-medium text-gray-500\">You may also want to know:</p>\n <div className=\"space-y-1\">\n {item.relatedQuestions.map((q, idx) => (\n <button\n key={idx}\n onClick={() => handleRelatedQuestionClick(q)}\n className=\"block w-full text-left text-xs text-blue-600 hover:text-blue-700 hover:underline\"\n >\n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AAU,sEACb,SAAAqB,EAAK,SACR,EACF,EACF,EAGArB,EAAC,OACC,UAAW,uDAAuDsB,EAAa,aAAe,EAAE,GAChG,KAAK,OACL,QAAQ,YACR,OAAO,eAEP,SAAAtB,EAAC,QAAK,cAAc,QAAQ,eAAe,QAAQ,YAAa,EAAG,EAAE,iBAAiB,EACxF,GACF,EAGCsB,GACCrB,EAAC,OAAI,UAAU,+BACb,UAAAD,EAAC,OACC,UAAU,wHACV,MAAO,CAAE,WAAY,MAAO,EAE5B,SAAAA,EAACG,EAAA,CACC,cAAe,CAACC,CAAS,EACzB,WAAY,CACV,EAAG,CAAC,CAAE,KAAAmB,EAAM,GAAGC,CAAM,IACnBxB,EAAC,KACE,GAAGwB,EACJ,UAAU,kCACV,OAAO,SACP,IAAI,sBACN,CAEJ,EAEC,SAAAH,EAAK,OACR,EACF,EAGCA,EAAK,kBAAoBA,EAAK,iBAAiB,OAAS,GACvDpB,EAAC,OAAI,UAAU,qCACb,UAAAD,EAAC,KAAE,UAAU,yCAAyC,sCAA0B,EAChFA,EAAC,OAAI,UAAU,YACZ,SAAAqB,EAAK,iBAAiB,IAAI,CAACI,EAAGC,IAC7B1B,EAAC,UAEC,QAAS,IAAMmB,EAA2BM,CAAC,EAC3C,UAAU,mFAET,SAAAA,GAJIC,CAKP,CACD,EACH,GACF,GAEJ,IAlEML,EAAK,EAoEf,CAEJ,CAAC,EACH,EACF,CAEJ",
|
|
6
|
+
"names": ["jsx", "jsxs", "useState", "ReactMarkdown", "remarkGfm", "FAQListRenderer", "content", "FAQList", "onQuestionClick", "found", "count", "total", "results", "expandedIds", "setExpandedIds", "toggleExpand", "id", "prev", "newSet", "handleRelatedQuestionClick", "question", "item", "isExpanded", "node", "props", "q", "idx"]
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{jsx as e,jsxs as s}from"react/jsx-runtime";import{useState as c}from"react";import m from"react-markdown";import p from"remark-gfm";const
|
|
1
|
+
import{jsx as e,jsxs as s}from"react/jsx-runtime";import{useState as c}from"react";import m from"react-markdown";import p from"remark-gfm";const y={render:(a,d,l)=>{const n=a,{title:r,content:i}=n.data;if(!r||!i)return null;const o=i.length>200;return e(b,{title:r,content:i,isLong:o})}},b=({title:a,content:d,isLong:l})=>{const[n,r]=c(!l);return s("div",{className:"overflow-hidden rounded-lg border border-blue-200 bg-blue-50",children:[s("div",{className:"flex items-center gap-2 border-b border-blue-200 bg-blue-100 px-3 py-2",children:[s("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0 text-blue-700",children:[e("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e("polyline",{points:"14 2 14 8 20 8"}),e("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),e("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),e("polyline",{points:"10 9 9 9 8 9"})]}),e("h3",{className:"text-sm font-semibold text-blue-900",children:a})]}),s("div",{className:"px-3 py-2",children:[e("div",{className:`
|
|
2
2
|
text-sm leading-relaxed text-blue-900
|
|
3
3
|
${!n&&l?"line-clamp-3":""}
|
|
4
|
-
`,children:e(m,{remarkPlugins:[p],components:{p:({node:o,...t})=>e("p",{...t,className:"mb-2 last:mb-0"}),ul:({node:o,...t})=>e("ul",{...t,className:"mb-2 ml-4 list-disc"}),ol:({node:o,...t})=>e("ol",{...t,className:"mb-2 ml-4 list-decimal"}),li:({node:o,...t})=>e("li",{...t,className:"mb-1"}),strong:({node:o,...t})=>e("strong",{...t,className:"font-bold"})},children:d})}),l&&s("button",{type:"button",onClick:()=>{
|
|
4
|
+
`,children:e(m,{remarkPlugins:[p],components:{p:({node:o,...t})=>e("p",{...t,className:"mb-2 last:mb-0"}),ul:({node:o,...t})=>e("ul",{...t,className:"mb-2 ml-4 list-disc"}),ol:({node:o,...t})=>e("ol",{...t,className:"mb-2 ml-4 list-decimal"}),li:({node:o,...t})=>e("li",{...t,className:"mb-1"}),strong:({node:o,...t})=>e("strong",{...t,className:"font-bold"}),a:({node:o,...t})=>e("a",{...t,className:"livechat-link livechat-link-bot",target:"_blank",rel:"noopener noreferrer"})},children:d})}),l&&s("button",{type:"button",onClick:()=>{r(o=>!o)},className:"mt-2 flex items-center gap-1 text-xs font-medium text-blue-700 hover:text-blue-800",children:[e("span",{children:n?"\u6536\u8D77":"\u5C55\u5F00"}),e("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:`transition-transform ${n?"rotate-180":""}`,children:e("polyline",{points:"6 9 12 15 18 9"})})]})]})]})};export{y as PolicyBlock};
|
|
5
5
|
//# sourceMappingURL=PolicyBlock.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/components/LiveChatWidget/components/MessageContent/PolicyBlock.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * \u653F\u7B56\u8BF4\u660E\u6E32\u67D3\u5668\n * \u663E\u793A\u9000\u8D27\u3001\u4FDD\u4FEE\u7B49\u653F\u7B56\u4FE1\u606F\n * \u57FA\u4E8E specs/livechat-widget/data-model.md \u7684\u653F\u7B56\u6570\u636E\u6A21\u578B\n */\n\nimport React, { useState } from 'react'\nimport ReactMarkdown from 'react-markdown'\nimport remarkGfm from 'remark-gfm'\nimport type { MessageRenderer, PolicyContent } from '../../types'\n\n/**\n * \u653F\u7B56\u8BF4\u660E\u6E32\u67D3\u5668\n *\n * \u529F\u80FD\uFF1A\n * - \u663E\u793A\u653F\u7B56\u6807\u9898\u548C\u5185\u5BB9\n * - \u652F\u6301 Markdown \u683C\u5F0F\n * - \u53EF\u6298\u53E0/\u5C55\u5F00\uFF08\u5185\u5BB9\u8F83\u957F\u65F6\uFF09\n *\n * \u653F\u7B56\u7C7B\u578B\uFF1A\n * - \u9000\u8D27\u653F\u7B56\n * - \u4FDD\u4FEE\u653F\u7B56\n * - \u8FD0\u8D39\u653F\u7B56\n * - \u9690\u79C1\u653F\u7B56\n *\n * \u5E03\u5C40\uFF1A\n * ```\n * \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n * \u2502 \uD83D\uDCCB \u653F\u7B56\u6807\u9898 \u2502\n * \u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n * \u2502 \u653F\u7B56\u5185\u5BB9... \u2502\n * \u2502 (\u652F\u6301 Markdown) \u2502\n * \u2502 \u2502\n * \u2502 [\u5C55\u5F00/\u6536\u8D77] \u2502\n * \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n * ```\n *\n * @example\n * ```tsx\n * const content: PolicyContent = {\n * type: 'policy',\n * data: {\n * title: '\u9000\u8D27\u653F\u7B56',\n * content: '\u6211\u4EEC\u63D0\u4F9B 30 \u5929\u65E0\u7406\u7531\u9000\u8D27...'\n * }\n * }\n * <PolicyBlock.render(content, false, false) />\n * ```\n */\nexport const PolicyBlock: MessageRenderer = {\n render: (content, isUser, isSystem) => {\n const policyContent = content as PolicyContent\n const { title, content: policyText } = policyContent.data\n\n if (!title || !policyText) {\n return null\n }\n\n // \u5224\u65AD\u5185\u5BB9\u662F\u5426\u8F83\u957F\uFF08\u8D85\u8FC7 200 \u5B57\u7B26\uFF09\n const isLongContent = policyText.length > 200\n\n return <PolicyCard title={title} content={policyText} isLong={isLongContent} />\n },\n}\n\n/**\n * \u653F\u7B56\u5361\u7247\u7EC4\u4EF6\uFF08\u652F\u6301\u6298\u53E0\uFF09\n */\nconst PolicyCard: React.FC<{\n title: string\n content: string\n isLong: boolean\n}> = ({ title, content, isLong }) => {\n const [isExpanded, setIsExpanded] = useState(!isLong)\n\n const toggleExpand = () => {\n setIsExpanded(prev => !prev)\n }\n\n return (\n <div className=\"overflow-hidden rounded-lg border border-blue-200 bg-blue-50\">\n {/* \u6807\u9898 */}\n <div className=\"flex items-center gap-2 border-b border-blue-200 bg-blue-100 px-3 py-2\">\n <svg\n width=\"18\"\n height=\"18\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className=\"shrink-0 text-blue-700\"\n >\n <path d=\"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z\" />\n <polyline points=\"14 2 14 8 20 8\" />\n <line x1=\"16\" y1=\"13\" x2=\"8\" y2=\"13\" />\n <line x1=\"16\" y1=\"17\" x2=\"8\" y2=\"17\" />\n <polyline points=\"10 9 9 9 8 9\" />\n </svg>\n <h3 className=\"text-sm font-semibold text-blue-900\">{title}</h3>\n </div>\n\n {/* \u5185\u5BB9 */}\n <div className=\"px-3 py-2\">\n <div\n className={`\n text-sm leading-relaxed text-blue-900\n ${!isExpanded && isLong ? 'line-clamp-3' : ''}\n `}\n >\n <ReactMarkdown\n remarkPlugins={[remarkGfm]}\n components={{\n p: ({ node, ...props }) => <p {...props} className=\"mb-2 last:mb-0\" />,\n ul: ({ node, ...props }) => <ul {...props} className=\"mb-2 ml-4 list-disc\" />,\n ol: ({ node, ...props }) => <ol {...props} className=\"mb-2 ml-4 list-decimal\" />,\n li: ({ node, ...props }) => <li {...props} className=\"mb-1\" />,\n strong: ({ node, ...props }) => <strong {...props} className=\"font-bold\" />,\n }}\n >\n {content}\n </ReactMarkdown>\n </div>\n\n {/* \u5C55\u5F00/\u6536\u8D77\u6309\u94AE\uFF08\u4EC5\u957F\u5185\u5BB9\u663E\u793A\uFF09 */}\n {isLong && (\n <button\n type=\"button\"\n onClick={toggleExpand}\n className=\"mt-2 flex items-center gap-1 text-xs font-medium text-blue-700 hover:text-blue-800\"\n >\n <span>{isExpanded ? '\u6536\u8D77' : '\u5C55\u5F00'}</span>\n <svg\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className={`transition-transform ${isExpanded ? 'rotate-180' : ''}`}\n >\n <polyline points=\"6 9 12 15 18 9\" />\n </svg>\n </button>\n )}\n </div>\n </div>\n )\n}\n"],
|
|
5
|
-
"mappings": "AA6DW,cAAAA,EAsBH,QAAAC,MAtBG,oBAvDX,OAAgB,YAAAC,MAAgB,QAChC,OAAOC,MAAmB,iBAC1B,OAAOC,MAAe,aAyCf,MAAMC,EAA+B,CAC1C,OAAQ,CAACC,EAASC,EAAQC,IAAa,CACrC,MAAMC,EAAgBH,EAChB,CAAE,MAAAI,EAAO,QAASC,CAAW,EAAIF,EAAc,KAErD,GAAI,CAACC,GAAS,CAACC,EACb,OAAO,KAIT,MAAMC,EAAgBD,EAAW,OAAS,IAE1C,OAAOX,EAACa,EAAA,CAAW,MAAOH,EAAO,QAASC,EAAY,OAAQC,EAAe,CAC/E,CACF,EAKMC,EAID,CAAC,CAAE,MAAAH,EAAO,QAAAJ,EAAS,OAAAQ,CAAO,IAAM,CACnC,KAAM,CAACC,EAAYC,CAAa,EAAId,EAAS,CAACY,CAAM,EAMpD,OACEb,EAAC,OAAI,UAAU,+DAEb,UAAAA,EAAC,OAAI,UAAU,yEACb,UAAAA,EAAC,OACC,MAAM,KACN,OAAO,KACP,QAAQ,YACR,KAAK,OACL,OAAO,eACP,YAAY,IACZ,cAAc,QACd,eAAe,QACf,UAAU,yBAEV,UAAAD,EAAC,QAAK,EAAE,6DAA6D,EACrEA,EAAC,YAAS,OAAO,iBAAiB,EAClCA,EAAC,QAAK,GAAG,KAAK,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,EACrCA,EAAC,QAAK,GAAG,KAAK,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,EACrCA,EAAC,YAAS,OAAO,eAAe,GAClC,EACAA,EAAC,MAAG,UAAU,sCAAuC,SAAAU,EAAM,GAC7D,EAGAT,EAAC,OAAI,UAAU,YACb,UAAAD,EAAC,OACC,UAAW;AAAA;AAAA,cAEP,CAACe,GAAcD,EAAS,eAAiB,EAAE;AAAA,YAG/C,SAAAd,EAACG,EAAA,CACC,cAAe,CAACC,CAAS,EACzB,WAAY,CACV,EAAG,CAAC,CAAE,KAAAa,EAAM,GAAGC,CAAM,IAAMlB,EAAC,KAAG,GAAGkB,EAAO,UAAU,iBAAiB,EACpE,GAAI,CAAC,CAAE,KAAAD,EAAM,GAAGC,CAAM,IAAMlB,EAAC,MAAI,GAAGkB,EAAO,UAAU,sBAAsB,EAC3E,GAAI,CAAC,CAAE,KAAAD,EAAM,GAAGC,CAAM,IAAMlB,EAAC,MAAI,GAAGkB,EAAO,UAAU,yBAAyB,EAC9E,GAAI,CAAC,CAAE,KAAAD,EAAM,GAAGC,CAAM,IAAMlB,EAAC,MAAI,GAAGkB,EAAO,UAAU,OAAO,EAC5D,OAAQ,CAAC,CAAE,KAAAD,EAAM,GAAGC,CAAM,IAAMlB,EAAC,UAAQ,GAAGkB,EAAO,UAAU,YAAY,
|
|
4
|
+
"sourcesContent": ["/**\n * \u653F\u7B56\u8BF4\u660E\u6E32\u67D3\u5668\n * \u663E\u793A\u9000\u8D27\u3001\u4FDD\u4FEE\u7B49\u653F\u7B56\u4FE1\u606F\n * \u57FA\u4E8E specs/livechat-widget/data-model.md \u7684\u653F\u7B56\u6570\u636E\u6A21\u578B\n */\n\nimport React, { useState } from 'react'\nimport ReactMarkdown from 'react-markdown'\nimport remarkGfm from 'remark-gfm'\nimport type { MessageRenderer, PolicyContent } from '../../types'\n\n/**\n * \u653F\u7B56\u8BF4\u660E\u6E32\u67D3\u5668\n *\n * \u529F\u80FD\uFF1A\n * - \u663E\u793A\u653F\u7B56\u6807\u9898\u548C\u5185\u5BB9\n * - \u652F\u6301 Markdown \u683C\u5F0F\n * - \u53EF\u6298\u53E0/\u5C55\u5F00\uFF08\u5185\u5BB9\u8F83\u957F\u65F6\uFF09\n *\n * \u653F\u7B56\u7C7B\u578B\uFF1A\n * - \u9000\u8D27\u653F\u7B56\n * - \u4FDD\u4FEE\u653F\u7B56\n * - \u8FD0\u8D39\u653F\u7B56\n * - \u9690\u79C1\u653F\u7B56\n *\n * \u5E03\u5C40\uFF1A\n * ```\n * \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n * \u2502 \uD83D\uDCCB \u653F\u7B56\u6807\u9898 \u2502\n * \u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n * \u2502 \u653F\u7B56\u5185\u5BB9... \u2502\n * \u2502 (\u652F\u6301 Markdown) \u2502\n * \u2502 \u2502\n * \u2502 [\u5C55\u5F00/\u6536\u8D77] \u2502\n * \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n * ```\n *\n * @example\n * ```tsx\n * const content: PolicyContent = {\n * type: 'policy',\n * data: {\n * title: '\u9000\u8D27\u653F\u7B56',\n * content: '\u6211\u4EEC\u63D0\u4F9B 30 \u5929\u65E0\u7406\u7531\u9000\u8D27...'\n * }\n * }\n * <PolicyBlock.render(content, false, false) />\n * ```\n */\nexport const PolicyBlock: MessageRenderer = {\n render: (content, isUser, isSystem) => {\n const policyContent = content as PolicyContent\n const { title, content: policyText } = policyContent.data\n\n if (!title || !policyText) {\n return null\n }\n\n // \u5224\u65AD\u5185\u5BB9\u662F\u5426\u8F83\u957F\uFF08\u8D85\u8FC7 200 \u5B57\u7B26\uFF09\n const isLongContent = policyText.length > 200\n\n return <PolicyCard title={title} content={policyText} isLong={isLongContent} />\n },\n}\n\n/**\n * \u653F\u7B56\u5361\u7247\u7EC4\u4EF6\uFF08\u652F\u6301\u6298\u53E0\uFF09\n */\nconst PolicyCard: React.FC<{\n title: string\n content: string\n isLong: boolean\n}> = ({ title, content, isLong }) => {\n const [isExpanded, setIsExpanded] = useState(!isLong)\n\n const toggleExpand = () => {\n setIsExpanded(prev => !prev)\n }\n\n return (\n <div className=\"overflow-hidden rounded-lg border border-blue-200 bg-blue-50\">\n {/* \u6807\u9898 */}\n <div className=\"flex items-center gap-2 border-b border-blue-200 bg-blue-100 px-3 py-2\">\n <svg\n width=\"18\"\n height=\"18\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className=\"shrink-0 text-blue-700\"\n >\n <path d=\"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z\" />\n <polyline points=\"14 2 14 8 20 8\" />\n <line x1=\"16\" y1=\"13\" x2=\"8\" y2=\"13\" />\n <line x1=\"16\" y1=\"17\" x2=\"8\" y2=\"17\" />\n <polyline points=\"10 9 9 9 8 9\" />\n </svg>\n <h3 className=\"text-sm font-semibold text-blue-900\">{title}</h3>\n </div>\n\n {/* \u5185\u5BB9 */}\n <div className=\"px-3 py-2\">\n <div\n className={`\n text-sm leading-relaxed text-blue-900\n ${!isExpanded && isLong ? 'line-clamp-3' : ''}\n `}\n >\n <ReactMarkdown\n remarkPlugins={[remarkGfm]}\n components={{\n p: ({ node, ...props }) => <p {...props} className=\"mb-2 last:mb-0\" />,\n ul: ({ node, ...props }) => <ul {...props} className=\"mb-2 ml-4 list-disc\" />,\n ol: ({ node, ...props }) => <ol {...props} className=\"mb-2 ml-4 list-decimal\" />,\n li: ({ node, ...props }) => <li {...props} className=\"mb-1\" />,\n strong: ({ node, ...props }) => <strong {...props} className=\"font-bold\" />,\n a: ({ node, ...props }) => (\n <a\n {...props}\n className=\"livechat-link livechat-link-bot\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n />\n ),\n }}\n >\n {content}\n </ReactMarkdown>\n </div>\n\n {/* \u5C55\u5F00/\u6536\u8D77\u6309\u94AE\uFF08\u4EC5\u957F\u5185\u5BB9\u663E\u793A\uFF09 */}\n {isLong && (\n <button\n type=\"button\"\n onClick={toggleExpand}\n className=\"mt-2 flex items-center gap-1 text-xs font-medium text-blue-700 hover:text-blue-800\"\n >\n <span>{isExpanded ? '\u6536\u8D77' : '\u5C55\u5F00'}</span>\n <svg\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className={`transition-transform ${isExpanded ? 'rotate-180' : ''}`}\n >\n <polyline points=\"6 9 12 15 18 9\" />\n </svg>\n </button>\n )}\n </div>\n </div>\n )\n}\n"],
|
|
5
|
+
"mappings": "AA6DW,cAAAA,EAsBH,QAAAC,MAtBG,oBAvDX,OAAgB,YAAAC,MAAgB,QAChC,OAAOC,MAAmB,iBAC1B,OAAOC,MAAe,aAyCf,MAAMC,EAA+B,CAC1C,OAAQ,CAACC,EAASC,EAAQC,IAAa,CACrC,MAAMC,EAAgBH,EAChB,CAAE,MAAAI,EAAO,QAASC,CAAW,EAAIF,EAAc,KAErD,GAAI,CAACC,GAAS,CAACC,EACb,OAAO,KAIT,MAAMC,EAAgBD,EAAW,OAAS,IAE1C,OAAOX,EAACa,EAAA,CAAW,MAAOH,EAAO,Q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AAC,CAAE,KAAAD,EAAM,GAAGC,CAAM,IAAMlB,EAAC,UAAQ,GAAGkB,EAAO,UAAU,YAAY,EACzE,EAAG,CAAC,CAAE,KAAAD,EAAM,GAAGC,CAAM,IACnBlB,EAAC,KACE,GAAGkB,EACJ,UAAU,kCACV,OAAO,SACP,IAAI,sBACN,CAEJ,EAEC,SAAAZ,EACH,EACF,EAGCQ,GACCb,EAAC,UACC,KAAK,SACL,QA9DW,IAAM,CACzBe,EAAcG,GAAQ,CAACA,CAAI,CAC7B,EA6DU,UAAU,qFAEV,UAAAnB,EAAC,QAAM,SAAAe,EAAa,eAAO,eAAK,EAChCf,EAAC,OACC,MAAM,KACN,OAAO,KACP,QAAQ,YACR,KAAK,OACL,OAAO,eACP,YAAY,IACZ,cAAc,QACd,eAAe,QACf,UAAW,wBAAwBe,EAAa,aAAe,EAAE,GAEjE,SAAAf,EAAC,YAAS,OAAO,iBAAiB,EACpC,GACF,GAEJ,GACF,CAEJ",
|
|
6
6
|
"names": ["jsx", "jsxs", "useState", "ReactMarkdown", "remarkGfm", "PolicyBlock", "content", "isUser", "isSystem", "policyContent", "title", "policyText", "isLongContent", "PolicyCard", "isLong", "isExpanded", "setIsExpanded", "node", "props", "prev"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as t}from"react/jsx-runtime";import
|
|
1
|
+
import{jsx as t}from"react/jsx-runtime";import n from"react-markdown";import d from"remark-gfm";const y={render:(s,a,m)=>{const r=s;return r.text?t("div",{className:"livechat-markdown text-base md:text-sm",children:t(n,{remarkPlugins:[d],components:{a:({node:o,...e})=>t("a",{...e,className:`livechat-link underline ${a?"livechat-link-user":"livechat-link-bot"}`,target:"_blank",rel:"noopener noreferrer"}),code:({node:o,className:e,...l})=>/language-/.test(e||"")?t("code",{...l,className:`block overflow-x-auto rounded px-3 py-2 font-mono text-xs ${a?"livechat-code-user bg-[#004A6E] text-white":"bg-gray-200 text-gray-800"}`}):t("code",{...l,className:`rounded px-1.5 py-0.5 font-mono text-xs ${a?"livechat-code-user bg-[#004A6E] text-white":"bg-gray-200 text-gray-800"}`}),p:({node:o,...e})=>t("p",{...e,className:"last:mb-0"}),ul:({node:o,...e})=>t("ul",{...e,className:"ml-4 list-disc"}),ol:({node:o,...e})=>t("ol",{...e,className:"mb-2 ml-4 list-decimal"}),li:({node:o,...e})=>t("li",{...e,className:"mb-1"}),h1:({node:o,...e})=>t("h1",{...e,className:"mb-2 font-bold"}),h2:({node:o,...e})=>t("h2",{...e,className:"mb-2 font-bold"}),h3:({node:o,...e})=>t("h3",{...e,className:"mb-1 font-bold"}),strong:({node:o,...e})=>t("strong",{...e,className:"font-bold"}),em:({node:o,...e})=>t("em",{...e,className:"italic"}),table:({node:o,...e})=>t("div",{className:"my-2 overflow-x-auto",children:t("table",{...e,className:"min-w-full border-collapse border border-gray-300 text-base md:text-sm"})}),thead:({node:o,...e})=>t("thead",{...e,className:"bg-gray-100"}),tbody:({node:o,...e})=>t("tbody",{...e}),tr:({node:o,...e})=>t("tr",{...e,className:"border-b border-gray-300"}),th:({node:o,...e})=>t("th",{...e,className:"border border-gray-300 px-3 py-2 text-left font-semibold"}),td:({node:o,...e})=>t("td",{...e,className:"border border-gray-300 px-3 py-2"})},children:r.text})}):null}};export{y as TextBlock};
|
|
2
2
|
//# sourceMappingURL=TextBlock.js.map
|