@qxs-bns/components-wc 0.0.10 → 0.0.11

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.
@@ -1,4 +1,4 @@
1
- "use strict";var t=require("lit"),e=require("../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/property.cjs"),s=require("../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/state.cjs"),i=require("../base/define.cjs"),r=require("./single.cjs"),o=Object.defineProperty,a=Object.getOwnPropertyDescriptor,l=(t,e,s,i)=>{for(var r,l=i>1?void 0:i?a(e,s):e,n=t.length-1;n>=0;n--)(r=t[n])&&(l=(i?r(e,s,l):r(l))||l);return i&&l&&o(e,s,l),l};const n=t.html`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>`,p=t.html`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="5" y1="12" x2="19" y2="12"/></svg>`;exports.QxsScale=class extends t.LitElement{constructor(){super(...arguments),this.orderIndex=0,this.title="",this.customId="",this.isEdit=!1,this.isSave=!1,this.isSet=!1,this.showAction=!0,this.showAnalysis=!0,this.analysis="",this.richTextContent="",this.examAnswerRelationType=0,this.uploadImage=async t=>new Promise((e,s)=>{const i=new FileReader;i.onload=t=>e(t.target?.result),i.onerror=s,i.readAsDataURL(t)}),this._answers=[{title:""},{title:""},{title:""},{title:""},{title:""}],this._scaleQuestions=["问题1"],this._rowTitle="",this._title="",this._analysis="",this._showRichText=!1,this._richText="",this.modelValue="",this.useModel=!1,this.TITLE_MAX=200}get answerList(){return this._answers}set answerList(t){const e=Array.isArray(t)?t:[];this._answers=e.length?e.slice(0,5):[{title:""},{title:""},{title:""},{title:""},{title:""}],this.requestUpdate("answerList")}get scaleQuestions(){return this._scaleQuestions}set scaleQuestions(t){this._scaleQuestions=Array.isArray(t)&&t.length?t:["问题1"],this.requestUpdate("scaleQuestions")}willUpdate(t){t.has("isEdit")&&this.isEdit&&this._syncProps(),t.has("modelValue")&&this.useModel&&(this._title=this.modelValue)}_syncProps(){this._title=this.title||"",this._analysis=this.analysis||"",this._rowTitle=this._scaleQuestions.join("\n"),this.richTextContent&&(this._richText=this.richTextContent,this._showRichText=!0)}async toJSON(){return new Promise((t,e)=>{const s={customId:this.customId||void 0,answerType:"scale",orderIndex:this.orderIndex},i=this.isEdit?this._title:this.title||"",o=this.isEdit?this._answers:this.answerList||[],a=this.isEdit?this._analysis:this.analysis||"",l=this.isEdit?this._rowTitle:this.scaleQuestions?.join("\n")||"",n=this.isEdit?this._showRichText:!!this.richTextContent,p=this.isEdit?this._richText:this.richTextContent||"";if(!i)return void e(new r.SubjectError("题目标题不能为空!","EMPTY_TITLE","title",s));for(let t=0;t<o.length;t++)if(!o[t].title)return void e(new r.SubjectError(`选项${String.fromCharCode(65+t)}未填写。`,"ANSWER_EMPTY","answers",s));if(!l)return void e(new r.SubjectError("行标题不能为空!","EMPTY_ROW_TITLE","rowTitle",s));const d=l.split("\n").filter(t=>t.trim());if(0===d.length)return void e(new r.SubjectError("行标题不能为空!","EMPTY_ROW_TITLE","rowTitle",s));const h={answerType:"scale",title:i,analysis:a,answers:o,scaleQuestionList:d,examRichTextContent:n?p:"",examAnswerRelationType:this.examAnswerRelationType};this.customId&&(h.customId=this.customId),t(h)})}_emit(t,e){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e??null}))}_onTitleInput(t){const e=t.target;e.value.length>this.TITLE_MAX&&(e.value=e.value.slice(0,this.TITLE_MAX)),this._title=e.value,this.useModel&&this.dispatchEvent(new CustomEvent("update:modelValue",{bubbles:!0,composed:!0,detail:this._title}))}async _save(t){t?.stopImmediatePropagation();try{const t=await this.toJSON();this._emit("save",t)}catch(t){!function(t){const e=document.createElement("div");e.textContent=t,Object.assign(e.style,{position:"fixed",top:"20px",left:"50%",transform:"translateX(-50%)",padding:"10px 20px",borderRadius:"4px",fontSize:"13px",color:"#fff",background:"#f56c6c",zIndex:"99999",boxShadow:"0 4px 12px rgba(0,0,0,.15)",transition:"opacity .3s",opacity:"1"}),document.body.appendChild(e),setTimeout(()=>{e.style.opacity="0",setTimeout(()=>e.remove(),300)},2500)}(t.message)}}validate(){const t=[],e={customId:this.customId||void 0,answerType:"scale",orderIndex:this.orderIndex},s=this.isEdit?this._title:this.title||"",i=this.isEdit?this._answers:this.answerList||[],o=this.isEdit?this._rowTitle:this.scaleQuestions?.join("\n")||"";if(s||t.push(new r.SubjectError("题目标题不能为空!","EMPTY_TITLE","title",e)),i.forEach((s,i)=>{s.title||t.push(new r.SubjectError(`选项${String.fromCharCode(65+i)}未填写`,"ANSWER_EMPTY","answers",e))}),o){0===o.split("\n").filter(t=>t.trim()).length&&t.push(new r.SubjectError("行标题不能为空!","EMPTY_ROW_TITLE","rowTitle",e))}else t.push(new r.SubjectError("行标题不能为空!","EMPTY_ROW_TITLE","rowTitle",e));return t}_renderPreview(){const e=Math.floor(100/(this._answers.length+1));return t.html`
1
+ "use strict";var t=require("lit"),e=require("../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/property.cjs"),s=require("../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/state.cjs"),i=require("../base/define.cjs"),r=require("./single.cjs"),o=require("./types.cjs"),a=Object.defineProperty,l=Object.getOwnPropertyDescriptor,n=(t,e,s,i)=>{for(var r,o=i>1?void 0:i?l(e,s):e,n=t.length-1;n>=0;n--)(r=t[n])&&(o=(i?r(e,s,o):r(o))||o);return i&&o&&a(e,s,o),o};const p=t.html`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>`,d=t.html`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="5" y1="12" x2="19" y2="12"/></svg>`;exports.QxsScale=class extends t.LitElement{constructor(){super(...arguments),this.orderIndex=0,this.title="",this.customId="",this.isEdit=!1,this.isSave=!1,this.isSet=!1,this.showAction=!0,this.showAnalysis=!0,this.analysis="",this.richTextContent="",this.examAnswerRelationType=0,this.uploadImage=async t=>new Promise((e,s)=>{const i=new FileReader;i.onload=t=>e(t.target?.result),i.onerror=s,i.readAsDataURL(t)}),this._answers=[{title:""},{title:""},{title:""},{title:""},{title:""}],this._scaleQuestions=["问题1"],this._rowTitle="",this._title="",this._analysis="",this._showRichText=!1,this._richText="",this.modelValue="",this.useModel=!1,this.TITLE_MAX=200}get answerList(){return this._answers}set answerList(t){const e=Array.isArray(t)?t:[];this._answers=e.length?e.slice(0,5):[{title:""},{title:""},{title:""},{title:""},{title:""}],this.requestUpdate("answerList")}get scaleQuestions(){return this._scaleQuestions}set scaleQuestions(t){this._scaleQuestions=Array.isArray(t)&&t.length?t:["问题1"],this.requestUpdate("scaleQuestions")}willUpdate(t){t.has("isEdit")&&this.isEdit&&this._syncProps(),t.has("modelValue")&&this.useModel&&(this._title=this.modelValue)}_syncProps(){this._title=this.title||"",this._analysis=this.analysis||"",this._rowTitle=this._scaleQuestions.join("\n"),this.richTextContent&&(this._richText=this.richTextContent,this._showRichText=!0)}async toJSON(){return new Promise((t,e)=>{const s={customId:this.customId||void 0,answerType:"scale",orderIndex:this.orderIndex},i=this.isEdit?this._title:this.title||"",a=this.isEdit?this._answers:this.answerList||[],l=this.isEdit?this._analysis:this.analysis||"",n=this.isEdit?this._rowTitle:this.scaleQuestions?.join("\n")||"",p=this.isEdit?this._showRichText:!!this.richTextContent,d=this.isEdit?this._richText:this.richTextContent||"";if(!i)return void e(new r.SubjectError("题目标题不能为空!","EMPTY_TITLE","title",s));for(let t=0;t<a.length;t++)if(!a[t].title)return void e(new r.SubjectError(`选项${String.fromCharCode(65+t)}未填写。`,"ANSWER_EMPTY","answers",s));if(!n)return void e(new r.SubjectError("行标题不能为空!","EMPTY_ROW_TITLE","rowTitle",s));const h=n.split("\n").filter(t=>t.trim());if(0===h.length)return void e(new r.SubjectError("行标题不能为空!","EMPTY_ROW_TITLE","rowTitle",s));const c={answerType:o.ExamType.SCALE,title:i,analysis:l,answers:a,scaleQuestionList:h,examRichTextContent:p?d:"",examAnswerRelationType:this.examAnswerRelationType};this.customId&&(c.customId=this.customId),t(c)})}_emit(t,e){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e??null}))}_onTitleInput(t){const e=t.target;e.value.length>this.TITLE_MAX&&(e.value=e.value.slice(0,this.TITLE_MAX)),this._title=e.value,this.useModel&&this.dispatchEvent(new CustomEvent("update:modelValue",{bubbles:!0,composed:!0,detail:this._title}))}async _save(t){t?.stopImmediatePropagation();try{const t=await this.toJSON();this._emit("save",t)}catch(t){!function(t){const e=document.createElement("div");e.textContent=t,Object.assign(e.style,{position:"fixed",top:"20px",left:"50%",transform:"translateX(-50%)",padding:"10px 20px",borderRadius:"4px",fontSize:"13px",color:"#fff",background:"#f56c6c",zIndex:"99999",boxShadow:"0 4px 12px rgba(0,0,0,.15)",transition:"opacity .3s",opacity:"1"}),document.body.appendChild(e),setTimeout(()=>{e.style.opacity="0",setTimeout(()=>e.remove(),300)},2500)}(t.message)}}validate(){const t=[],e={customId:this.customId||void 0,answerType:"scale",orderIndex:this.orderIndex},s=this.isEdit?this._title:this.title||"",i=this.isEdit?this._answers:this.answerList||[],o=this.isEdit?this._rowTitle:this.scaleQuestions?.join("\n")||"";if(s||t.push(new r.SubjectError("题目标题不能为空!","EMPTY_TITLE","title",e)),i.forEach((s,i)=>{s.title||t.push(new r.SubjectError(`选项${String.fromCharCode(65+i)}未填写`,"ANSWER_EMPTY","answers",e))}),o){0===o.split("\n").filter(t=>t.trim()).length&&t.push(new r.SubjectError("行标题不能为空!","EMPTY_ROW_TITLE","rowTitle",e))}else t.push(new r.SubjectError("行标题不能为空!","EMPTY_ROW_TITLE","rowTitle",e));return t}_renderPreview(){const e=Math.floor(100/(this._answers.length+1));return t.html`
2
2
  <div class="preview">
3
3
  <span class="title">${this.orderIndex+1}.${this.title}(量表题)</span>
4
4
  ${this.richTextContent?t.html`<div style="margin-top:8px" .innerHTML=${this.richTextContent}></div>`:""}
@@ -49,8 +49,8 @@
49
49
  placeholder="选项${s+1}" />
50
50
  </div>
51
51
  ${this.isSave?"":t.html`
52
- <span class="icon" @click=${()=>{this._answers.length<5&&(this._answers=[...this._answers,{title:""}])}}>${n}</span>
53
- <span class="icon ${this._answers.length<3?"disabled":""}" @click=${()=>{this._answers.length>3&&(this._answers=this._answers.filter((t,e)=>e!==s))}}>${p}</span>
52
+ <span class="icon" @click=${()=>{this._answers.length<5&&(this._answers=[...this._answers,{title:""}])}}>${p}</span>
53
+ <span class="icon ${this._answers.length<3?"disabled":""}" @click=${()=>{this._answers.length>3&&(this._answers=this._answers.filter((t,e)=>e!==s))}}>${d}</span>
54
54
  `}
55
55
  </div>
56
56
  `)}
@@ -159,5 +159,5 @@
159
159
  .row-title-textarea {
160
160
  height: 200px;
161
161
  }
162
- `,l([e.property({type:Number,attribute:"order-index"})],exports.QxsScale.prototype,"orderIndex",2),l([e.property({type:String})],exports.QxsScale.prototype,"title",2),l([e.property({type:String,attribute:"custom-id"})],exports.QxsScale.prototype,"customId",2),l([e.property({type:Boolean,attribute:"is-edit"})],exports.QxsScale.prototype,"isEdit",2),l([e.property({type:Boolean,attribute:"is-save"})],exports.QxsScale.prototype,"isSave",2),l([e.property({type:Boolean,attribute:"is-set"})],exports.QxsScale.prototype,"isSet",2),l([e.property({type:Boolean,attribute:"show-action"})],exports.QxsScale.prototype,"showAction",2),l([e.property({type:Boolean,attribute:"show-analysis"})],exports.QxsScale.prototype,"showAnalysis",2),l([e.property({type:String})],exports.QxsScale.prototype,"analysis",2),l([e.property({type:String,attribute:"rich-text-content"})],exports.QxsScale.prototype,"richTextContent",2),l([e.property({type:Number,attribute:"exam-answer-relation-type"})],exports.QxsScale.prototype,"examAnswerRelationType",2),l([e.property({type:Object})],exports.QxsScale.prototype,"uploadImage",2),l([e.property({type:Array,attribute:"answer-list"})],exports.QxsScale.prototype,"answerList",1),l([e.property({type:Array,attribute:"scale-questions"})],exports.QxsScale.prototype,"scaleQuestions",1),l([s.state()],exports.QxsScale.prototype,"_answers",2),l([s.state()],exports.QxsScale.prototype,"_scaleQuestions",2),l([s.state()],exports.QxsScale.prototype,"_rowTitle",2),l([s.state()],exports.QxsScale.prototype,"_title",2),l([s.state()],exports.QxsScale.prototype,"_analysis",2),l([s.state()],exports.QxsScale.prototype,"_showRichText",2),l([s.state()],exports.QxsScale.prototype,"_richText",2),l([e.property({type:String,attribute:"model-value"})],exports.QxsScale.prototype,"modelValue",2),l([e.property({type:Boolean,attribute:"use-model"})],exports.QxsScale.prototype,"useModel",2),exports.QxsScale=l([i.safeCustomElement("qxs-scale")],exports.QxsScale);
162
+ `,n([e.property({type:Number,attribute:"order-index"})],exports.QxsScale.prototype,"orderIndex",2),n([e.property({type:String})],exports.QxsScale.prototype,"title",2),n([e.property({type:String,attribute:"custom-id"})],exports.QxsScale.prototype,"customId",2),n([e.property({type:Boolean,attribute:"is-edit"})],exports.QxsScale.prototype,"isEdit",2),n([e.property({type:Boolean,attribute:"is-save"})],exports.QxsScale.prototype,"isSave",2),n([e.property({type:Boolean,attribute:"is-set"})],exports.QxsScale.prototype,"isSet",2),n([e.property({type:Boolean,attribute:"show-action"})],exports.QxsScale.prototype,"showAction",2),n([e.property({type:Boolean,attribute:"show-analysis"})],exports.QxsScale.prototype,"showAnalysis",2),n([e.property({type:String})],exports.QxsScale.prototype,"analysis",2),n([e.property({type:String,attribute:"rich-text-content"})],exports.QxsScale.prototype,"richTextContent",2),n([e.property({type:Number,attribute:"exam-answer-relation-type"})],exports.QxsScale.prototype,"examAnswerRelationType",2),n([e.property({type:Object})],exports.QxsScale.prototype,"uploadImage",2),n([e.property({type:Array,attribute:"answer-list"})],exports.QxsScale.prototype,"answerList",1),n([e.property({type:Array,attribute:"scale-questions"})],exports.QxsScale.prototype,"scaleQuestions",1),n([s.state()],exports.QxsScale.prototype,"_answers",2),n([s.state()],exports.QxsScale.prototype,"_scaleQuestions",2),n([s.state()],exports.QxsScale.prototype,"_rowTitle",2),n([s.state()],exports.QxsScale.prototype,"_title",2),n([s.state()],exports.QxsScale.prototype,"_analysis",2),n([s.state()],exports.QxsScale.prototype,"_showRichText",2),n([s.state()],exports.QxsScale.prototype,"_richText",2),n([e.property({type:String,attribute:"model-value"})],exports.QxsScale.prototype,"modelValue",2),n([e.property({type:Boolean,attribute:"use-model"})],exports.QxsScale.prototype,"useModel",2),exports.QxsScale=n([i.safeCustomElement("qxs-scale")],exports.QxsScale);
163
163
  //# sourceMappingURL=scale.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"scale.cjs","sources":["../../../../packages/components-wc/src/subject/scale.ts"],"sourcesContent":["import { css, html, LitElement } from 'lit'\nimport { property, state } from 'lit/decorators.js'\nimport { safeCustomElement } from '../base/define'\nimport { SubjectError } from './single'\n\nconst iconPlus = html`<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><line x1=\"12\" y1=\"5\" x2=\"12\" y2=\"19\"/><line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"/></svg>`\nconst iconRemove = html`<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"/></svg>`\n\nfunction showToast(msg: string) {\n const el = document.createElement('div')\n el.textContent = msg\n Object.assign(el.style, {\n position: 'fixed', top: '20px', left: '50%', transform: 'translateX(-50%)',\n padding: '10px 20px', borderRadius: '4px', fontSize: '13px', color: '#fff',\n background: '#f56c6c', zIndex: '99999', boxShadow: '0 4px 12px rgba(0,0,0,.15)',\n transition: 'opacity .3s', opacity: '1',\n })\n document.body.appendChild(el)\n setTimeout(() => { el.style.opacity = '0'; setTimeout(() => el.remove(), 300) }, 2500)\n}\n\n@safeCustomElement('qxs-scale')\nexport class QxsScale extends LitElement {\n static styles = css`\n :host { display: block; font-family: system-ui, -apple-system, \"PingFang SC\", \"Microsoft YaHei\", sans-serif; font-size: 12px; color: #5a5a5a; }\n *, ::before, ::after { box-sizing: border-box; }\n\n .preview { padding: 12px 0; }\n .preview .title { font-size: 14px; color: #303133; }\n .scale-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 12px; }\n .scale-table th, .scale-table td { border: 1px solid #e4e7ed; padding: 6px 4px; text-align: center; }\n .scale-table th { background: #f5f7fa; color: #909399; }\n\n .flex { display: flex; }\n .flex-items-center { display: flex; align-items: center; }\n .flex-items-start { display: flex; align-items: flex-start; }\n .flex-justify-end { display: flex; justify-content: flex-end; }\n .label { min-width: 60px; font-size: 13px; color: #606266; }\n\n textarea, input[type=\"text\"] {\n border: 1px solid #dcdfe6; border-radius: 3px; padding: 5px 11px;\n font-size: 13px; font-family: inherit; width: 100%; resize: none; transition: border-color .2s;\n line-height: 1.5; display: block; box-sizing: border-box; white-space: pre-wrap;\n }\n textarea:focus, input[type=\"text\"]:focus { border-color: #3D61E3; outline: none; }\n textarea:disabled, input[type=\"text\"]:disabled { background: #f5f7fa; color: #c0c4cc; cursor: not-allowed; }\n\n .el-input { position: relative; display: block; }\n .el-input textarea { padding-bottom: 24px; }\n .el-input .char-counter {\n position: absolute; right: 12px; bottom: 8px;\n font-size: 12px; color: #909399; line-height: 1; pointer-events: none;\n }\n\n .el-link { color: #3D61E3; cursor: pointer; font-size: 12px; }\n .el-link:hover { color: #2D4CB8; }\n .el-link.danger { color: #f56c6c; }\n\n .answer-item { display: flex; align-items: center; margin-top: 6px; }\n .answer-item .label { min-width: 60px; font-size: 13px; color: #909399; }\n .answer-item .input { flex: 1; max-width: 200px; }\n .answer-item .input input {\n height: 32px; padding: 0 8px;\n font-size: 13px; line-height: 32px;\n border: 1px solid #dcdfe6; border-radius: 3px; width: 100%;\n transition: border-color .2s; box-sizing: border-box;\n }\n .answer-item .input input:focus { border-color: #3D61E3; outline: none; }\n\n .answer-item .icon {\n margin-left: 6px; cursor: pointer; display: inline-flex;\n align-items: center; justify-content: center;\n width: 24px; height: 24px; border-radius: 4px;\n border: 1px solid #dcdfe6; background: #fff; color: #909399;\n transition: all 0.2s;\n }\n .answer-item .icon:hover { color: #3D61E3; border-color: #3D61E3; background: #ecf5ff; }\n .answer-item .icon.disabled { color: #e4e7ed; border-color: #e4e7ed; cursor: not-allowed; }\n\n .row-title-textarea {\n height: 200px;\n }\n `\n\n @property({ type: Number, attribute: 'order-index' }) orderIndex = 0\n @property({ type: String }) title = ''\n @property({ type: String, attribute: 'custom-id' }) customId = ''\n @property({ type: Boolean, attribute: 'is-edit' }) isEdit = false\n @property({ type: Boolean, attribute: 'is-save' }) isSave = false\n @property({ type: Boolean, attribute: 'is-set' }) isSet = false\n @property({ type: Boolean, attribute: 'show-action' }) showAction = true\n @property({ type: Boolean, attribute: 'show-analysis' }) showAnalysis = true\n @property({ type: String }) analysis = ''\n @property({ type: String, attribute: 'rich-text-content' }) richTextContent = ''\n @property({ type: Number, attribute: 'exam-answer-relation-type' }) examAnswerRelationType = 0\n @property({ type: Object })\n uploadImage: (file: File) => Promise<string> = async (file: File) => {\n return new Promise((resolve, reject) => {\n const reader = new FileReader()\n reader.onload = (e) => resolve(e.target?.result as string)\n reader.onerror = reject\n reader.readAsDataURL(file)\n })\n }\n @property({ type: Array, attribute: 'answer-list' })\n get answerList() { return this._answers }\n\n set answerList(v: any) {\n const arr = Array.isArray(v) ? v : []\n this._answers = arr.length ? arr.slice(0, 5) : [{ title: '' }, { title: '' }, { title: '' }, { title: '' }, { title: '' }]\n this.requestUpdate('answerList')\n }\n\n @property({ type: Array, attribute: 'scale-questions' })\n get scaleQuestions() { return this._scaleQuestions }\n\n set scaleQuestions(v: any) {\n this._scaleQuestions = Array.isArray(v) && v.length ? v : ['问题1']\n this.requestUpdate('scaleQuestions')\n }\n\n @state() private _answers: { title: string }[] = [{ title: '' }, { title: '' }, { title: '' }, { title: '' }, { title: '' }]\n @state() private _scaleQuestions: string[] = ['问题1']\n @state() private _rowTitle = ''\n @state() private _title = ''\n @state() private _analysis = ''\n @state() private _showRichText = false\n @state() private _richText = ''\n\n // 双向绑定支持\n @property({ type: String, attribute: 'model-value' }) modelValue = ''\n @property({ type: Boolean, attribute: 'use-model' }) useModel = false\n\n private readonly TITLE_MAX = 200\n\n willUpdate(changed: Map<string, unknown>) {\n if (changed.has('isEdit') && this.isEdit) { this._syncProps() }\n // 当外部 modelValue 变化时同步内部状态\n if (changed.has('modelValue') && this.useModel) {\n this._title = this.modelValue\n }\n }\n\n private _syncProps() {\n this._title = this.title || ''\n this._analysis = this.analysis || ''\n this._rowTitle = this._scaleQuestions.join('\\n')\n if (this.richTextContent) {\n this._richText = this.richTextContent\n this._showRichText = true\n }\n }\n\n async toJSON(): Promise<any> {\n return new Promise((resolve, reject) => {\n const row = { customId: this.customId || undefined, answerType: 'scale', orderIndex: this.orderIndex }\n\n const title = this.isEdit ? this._title : this.title || ''\n const answers = this.isEdit ? this._answers : (this.answerList || [])\n const analysis = this.isEdit ? this._analysis : this.analysis || ''\n const rowTitle = this.isEdit ? this._rowTitle : (this.scaleQuestions?.join('\\n') || '')\n const showRichText = this.isEdit ? this._showRichText : !!this.richTextContent\n const richText = this.isEdit ? this._richText : this.richTextContent || ''\n\n if (!title) {\n reject(new SubjectError('题目标题不能为空!', 'EMPTY_TITLE', 'title', row))\n return\n }\n\n for (let i = 0; i < answers.length; i++) {\n if (!answers[i].title) {\n reject(new SubjectError(`选项${String.fromCharCode(65 + i)}未填写。`, 'ANSWER_EMPTY', 'answers', row))\n return\n }\n }\n\n if (!rowTitle) {\n reject(new SubjectError('行标题不能为空!', 'EMPTY_ROW_TITLE', 'rowTitle', row))\n return\n }\n\n const questions = rowTitle.split('\\n').filter((i: string) => i.trim())\n if (questions.length === 0) {\n reject(new SubjectError('行标题不能为空!', 'EMPTY_ROW_TITLE', 'rowTitle', row))\n return\n }\n\n const result: any = {\n answerType: 'scale',\n title,\n analysis,\n answers,\n scaleQuestionList: questions,\n examRichTextContent: showRichText ? richText : '',\n examAnswerRelationType: this.examAnswerRelationType,\n }\n if (this.customId) { result.customId = this.customId }\n resolve(result)\n })\n }\n\n private _emit(name: string, detail?: unknown) {\n this.dispatchEvent(new CustomEvent(name, { bubbles: true, composed: true, detail: detail ?? null }))\n }\n\n private _onTitleInput(e: Event) {\n const el = e.target as HTMLTextAreaElement\n if (el.value.length > this.TITLE_MAX) { el.value = el.value.slice(0, this.TITLE_MAX) }\n this._title = el.value\n // 双向绑定:通知外部更新\n if (this.useModel) {\n this.dispatchEvent(new CustomEvent('update:modelValue', {\n bubbles: true,\n composed: true,\n detail: this._title,\n }))\n }\n }\n\n private async _save(e?: Event) {\n e?.stopImmediatePropagation()\n try {\n const data = await this.toJSON()\n this._emit('save', data)\n }\n catch (err: any) {\n showToast(err.message)\n }\n }\n\n validate(): SubjectError[] {\n const errors: SubjectError[] = []\n const row = { customId: this.customId || undefined, answerType: 'scale', orderIndex: this.orderIndex }\n\n const title = this.isEdit ? this._title : this.title || ''\n const answers = this.isEdit ? this._answers : (this.answerList || [])\n const rowTitle = this.isEdit ? this._rowTitle : (this.scaleQuestions?.join('\\n') || '')\n\n if (!title) {\n errors.push(new SubjectError('题目标题不能为空!', 'EMPTY_TITLE', 'title', row))\n }\n\n answers.forEach((a: any, i: number) => {\n if (!a.title) {\n errors.push(new SubjectError(`选项${String.fromCharCode(65 + i)}未填写`, 'ANSWER_EMPTY', 'answers', row))\n }\n })\n\n if (!rowTitle) {\n errors.push(new SubjectError('行标题不能为空!', 'EMPTY_ROW_TITLE', 'rowTitle', row))\n }\n else {\n const questions = rowTitle.split('\\n').filter((i: string) => i.trim())\n if (questions.length === 0) {\n errors.push(new SubjectError('行标题不能为空!', 'EMPTY_ROW_TITLE', 'rowTitle', row))\n }\n }\n\n return errors\n }\n\n private _renderPreview() {\n const colWidth = Math.floor(100 / (this._answers.length + 1))\n return html`\n <div class=\"preview\">\n <span class=\"title\">${this.orderIndex + 1}.${this.title}(量表题)</span>\n ${this.richTextContent ? html`<div style=\"margin-top:8px\" .innerHTML=${this.richTextContent}></div>` : ''}\n <table class=\"scale-table\">\n <thead><tr>\n <th style=\"width:${colWidth}%\">问题 \\ 选项</th>\n ${this._answers.map(a => html`<th style=\"width:${colWidth}%\">${a.title}</th>`)}\n </tr></thead>\n <tbody>\n ${this._scaleQuestions.map(q => html`\n <tr><td>${q}</td>${this._answers.map(() => html`<td><input type=\"radio\" disabled /></td>`)}</tr>\n `)}\n </tbody>\n </table>\n ${this.analysis ? html`<div style=\"color:#909399;font-size:12px;margin-top:8px\">解析: ${this.analysis}</div>` : ''}\n </div>\n `\n }\n\n private _renderEdit() {\n return html`\n <div class=\"flex-items-start\">\n <div class=\"label\"><span>题目:</span></div>\n <div style=\"flex:1\">\n <div class=\"el-input\">\n <textarea rows=\"2\" .value=${this._title} ?disabled=${this.isSave}\n maxlength=${this.TITLE_MAX}\n @input=${(e: Event) => this._onTitleInput(e)}\n placeholder=\"【量表题】请输入问题\"></textarea>\n <span class=\"char-counter\">${this._title.length}/${this.TITLE_MAX}</span>\n </div>\n </div>\n </div>\n\n <div class=\"flex-items-start\" style=\"margin-top:12px\">\n <div class=\"label\"><span>行标题:</span></div>\n <div class=\"flex\" style=\"flex:1\">\n <div class=\"el-input\" style=\"width:160px\">\n <textarea class=\"row-title-textarea\" .value=${this._rowTitle} ?disabled=${this.isSave}\n @input=${(e: Event) => { this._rowTitle = (e.target as HTMLTextAreaElement).value }}\n @keydown=${(e: KeyboardEvent) => { e.stopPropagation() }}\n placeholder=\"请输入行标题\"></textarea>\n </div>\n <div style=\"flex:1;margin-left:12px\">\n ${this._answers.map((a, i) => html`\n <div class=\"answer-item\">\n <span class=\"label\">${String.fromCharCode(65 + i)}.</span>\n <div class=\"input\">\n <input type=\"text\" .value=${a.title} ?disabled=${this.isSave}\n maxlength=\"10\"\n @input=${(e: Event) => { this._answers = this._answers.map((x, j) => j === i ? { title: (e.target as HTMLInputElement).value } : x) }}\n placeholder=\"选项${i + 1}\" />\n </div>\n ${!this.isSave\n ? html`\n <span class=\"icon\" @click=${() => {\n if (this._answers.length < 5) { this._answers = [...this._answers, { title: '' }] }\n }}>${iconPlus}</span>\n <span class=\"icon ${this._answers.length < 3 ? 'disabled' : ''}\" @click=${() => {\n if (this._answers.length > 3) { this._answers = this._answers.filter((_, j) => j !== i) }\n }}>${iconRemove}</span>\n `\n : ''}\n </div>\n `)}\n </div>\n </div>\n </div>\n\n <div class=\"flex-items-start\" style=\"margin-top:12px\">\n <div class=\"label\"><span>解析:</span></div>\n <div style=\"flex:1\">\n <div class=\"el-input\">\n <textarea rows=\"2\" .value=${this._analysis} ?disabled=${this.isSave}\n @input=${(e: Event) => { this._analysis = (e.target as HTMLTextAreaElement).value }}\n placeholder=\"请输入题目解析\"></textarea>\n </div>\n </div>\n </div>\n\n ${this._showRichText\n ? html`\n <div class=\"flex-items-start\" style=\"margin-top:12px\">\n <div class=\"label\"><span>富文本:</span></div>\n <div style=\"flex:1\">\n <qxs-blocksuite-editor\n .content=${this._richText}\n .uploadImage=${this.uploadImage}\n ?is-edit=${true}\n ></qxs-blocksuite-editor>\n <div class=\"flex-justify-end\" style=\"margin-top:8px\"><span class=\"el-link danger\" @click=${() => { this._showRichText = false; this._richText = '' }}>删除富文本</span></div>\n </div>\n </div>\n `\n : ''}\n `\n }\n\n render() {\n return html`\n <qxs-subject-layout ?show-edit=${this.isEdit}>\n <div slot=\"preview\">${this._renderPreview()}</div>\n <div slot=\"edit\">${this._renderEdit()}</div>\n ${this.showAction\n ? html`\n <qxs-subject-action\n ?is-edit=${this.isEdit}\n ?is-set=${this.isSet}\n ?show-other-option=${false}\n exam-answer-relation-type=${this.examAnswerRelationType}\n @delete=${() => this._emit('delete')}\n @save=${this._save}\n @edit=${() => this._emit('edit')}\n @add=${(e: CustomEvent) => this._emit('add', e.detail)}\n @on-show-rich-text=${() => { this._showRichText = true }}\n ></qxs-subject-action>\n `\n : ''}\n </qxs-subject-layout>\n `\n }\n}\n\nexport function register() {}\n"],"names":["iconPlus","html","iconRemove","QxsScale","LitElement","constructor","super","arguments","this","orderIndex","title","customId","isEdit","isSave","isSet","showAction","showAnalysis","analysis","richTextContent","examAnswerRelationType","uploadImage","async","Promise","resolve","reject","reader","FileReader","onload","e","target","result","onerror","readAsDataURL","file","_answers","_scaleQuestions","_rowTitle","_title","_analysis","_showRichText","_richText","modelValue","useModel","TITLE_MAX","answerList","v","arr","Array","isArray","length","slice","requestUpdate","scaleQuestions","willUpdate","changed","has","_syncProps","join","toJSON","row","answerType","answers","rowTitle","showRichText","richText","SubjectError","i","String","fromCharCode","questions","split","filter","trim","scaleQuestionList","examRichTextContent","_emit","name","detail","dispatchEvent","CustomEvent","bubbles","composed","_onTitleInput","el","value","_save","stopImmediatePropagation","data","err","msg","document","createElement","textContent","Object","assign","style","position","top","left","transform","padding","borderRadius","fontSize","color","background","zIndex","boxShadow","transition","opacity","body","appendChild","setTimeout","remove","showToast","message","validate","errors","push","forEach","a","_renderPreview","colWidth","Math","floor","map","q","_renderEdit","stopPropagation","x","j","_","render","styles","css","__decorateClass","property","type","Number","attribute","prototype","Boolean","state","safeCustomElement"],"mappings":"ygBAKA,MAAMA,EAAWC,EAAAA,IAAA,2NACXC,EAAaD,EAAAA,IAAA,qLAgBNE,QAAAA,SAAN,cAAuBC,EAAAA,WAAvBC,WAAAA,GAAAC,SAAAC,WA8DiDC,KAAAC,WAAa,EACvCD,KAAAE,MAAQ,GACgBF,KAAAG,SAAW,GACZH,KAAAI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G3BvI,QAAAA,SA6G0CwI,UAAA,WAAA,GA7G1CxI,QAAAA,SAANmI,EAAA,CADNQ,EAAAA,kBAAkB,cACN3I,QAAAA"}
1
+ {"version":3,"file":"scale.cjs","sources":["../../../../packages/components-wc/src/subject/scale.ts"],"sourcesContent":["import { css, html, LitElement } from 'lit'\nimport { property, state } from 'lit/decorators.js'\nimport { safeCustomElement } from '../base/define'\nimport { SubjectError } from './single'\nimport { ExamType } from './types'\n\nconst iconPlus = html`<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><line x1=\"12\" y1=\"5\" x2=\"12\" y2=\"19\"/><line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"/></svg>`\nconst iconRemove = html`<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"/></svg>`\n\nfunction showToast(msg: string) {\n const el = document.createElement('div')\n el.textContent = msg\n Object.assign(el.style, {\n position: 'fixed', top: '20px', left: '50%', transform: 'translateX(-50%)',\n padding: '10px 20px', borderRadius: '4px', fontSize: '13px', color: '#fff',\n background: '#f56c6c', zIndex: '99999', boxShadow: '0 4px 12px rgba(0,0,0,.15)',\n transition: 'opacity .3s', opacity: '1',\n })\n document.body.appendChild(el)\n setTimeout(() => { el.style.opacity = '0'; setTimeout(() => el.remove(), 300) }, 2500)\n}\n\n@safeCustomElement('qxs-scale')\nexport class QxsScale extends LitElement {\n static styles = css`\n :host { display: block; font-family: system-ui, -apple-system, \"PingFang SC\", \"Microsoft YaHei\", sans-serif; font-size: 12px; color: #5a5a5a; }\n *, ::before, ::after { box-sizing: border-box; }\n\n .preview { padding: 12px 0; }\n .preview .title { font-size: 14px; color: #303133; }\n .scale-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 12px; }\n .scale-table th, .scale-table td { border: 1px solid #e4e7ed; padding: 6px 4px; text-align: center; }\n .scale-table th { background: #f5f7fa; color: #909399; }\n\n .flex { display: flex; }\n .flex-items-center { display: flex; align-items: center; }\n .flex-items-start { display: flex; align-items: flex-start; }\n .flex-justify-end { display: flex; justify-content: flex-end; }\n .label { min-width: 60px; font-size: 13px; color: #606266; }\n\n textarea, input[type=\"text\"] {\n border: 1px solid #dcdfe6; border-radius: 3px; padding: 5px 11px;\n font-size: 13px; font-family: inherit; width: 100%; resize: none; transition: border-color .2s;\n line-height: 1.5; display: block; box-sizing: border-box; white-space: pre-wrap;\n }\n textarea:focus, input[type=\"text\"]:focus { border-color: #3D61E3; outline: none; }\n textarea:disabled, input[type=\"text\"]:disabled { background: #f5f7fa; color: #c0c4cc; cursor: not-allowed; }\n\n .el-input { position: relative; display: block; }\n .el-input textarea { padding-bottom: 24px; }\n .el-input .char-counter {\n position: absolute; right: 12px; bottom: 8px;\n font-size: 12px; color: #909399; line-height: 1; pointer-events: none;\n }\n\n .el-link { color: #3D61E3; cursor: pointer; font-size: 12px; }\n .el-link:hover { color: #2D4CB8; }\n .el-link.danger { color: #f56c6c; }\n\n .answer-item { display: flex; align-items: center; margin-top: 6px; }\n .answer-item .label { min-width: 60px; font-size: 13px; color: #909399; }\n .answer-item .input { flex: 1; max-width: 200px; }\n .answer-item .input input {\n height: 32px; padding: 0 8px;\n font-size: 13px; line-height: 32px;\n border: 1px solid #dcdfe6; border-radius: 3px; width: 100%;\n transition: border-color .2s; box-sizing: border-box;\n }\n .answer-item .input input:focus { border-color: #3D61E3; outline: none; }\n\n .answer-item .icon {\n margin-left: 6px; cursor: pointer; display: inline-flex;\n align-items: center; justify-content: center;\n width: 24px; height: 24px; border-radius: 4px;\n border: 1px solid #dcdfe6; background: #fff; color: #909399;\n transition: all 0.2s;\n }\n .answer-item .icon:hover { color: #3D61E3; border-color: #3D61E3; background: #ecf5ff; }\n .answer-item .icon.disabled { color: #e4e7ed; border-color: #e4e7ed; cursor: not-allowed; }\n\n .row-title-textarea {\n height: 200px;\n }\n `\n\n @property({ type: Number, attribute: 'order-index' }) orderIndex = 0\n @property({ type: String }) title = ''\n @property({ type: String, attribute: 'custom-id' }) customId = ''\n @property({ type: Boolean, attribute: 'is-edit' }) isEdit = false\n @property({ type: Boolean, attribute: 'is-save' }) isSave = false\n @property({ type: Boolean, attribute: 'is-set' }) isSet = false\n @property({ type: Boolean, attribute: 'show-action' }) showAction = true\n @property({ type: Boolean, attribute: 'show-analysis' }) showAnalysis = true\n @property({ type: String }) analysis = ''\n @property({ type: String, attribute: 'rich-text-content' }) richTextContent = ''\n @property({ type: Number, attribute: 'exam-answer-relation-type' }) examAnswerRelationType = 0\n @property({ type: Object })\n uploadImage: (file: File) => Promise<string> = async (file: File) => {\n return new Promise((resolve, reject) => {\n const reader = new FileReader()\n reader.onload = (e) => resolve(e.target?.result as string)\n reader.onerror = reject\n reader.readAsDataURL(file)\n })\n }\n @property({ type: Array, attribute: 'answer-list' })\n get answerList() { return this._answers }\n\n set answerList(v: any) {\n const arr = Array.isArray(v) ? v : []\n this._answers = arr.length ? arr.slice(0, 5) : [{ title: '' }, { title: '' }, { title: '' }, { title: '' }, { title: '' }]\n this.requestUpdate('answerList')\n }\n\n @property({ type: Array, attribute: 'scale-questions' })\n get scaleQuestions() { return this._scaleQuestions }\n\n set scaleQuestions(v: any) {\n this._scaleQuestions = Array.isArray(v) && v.length ? v : ['问题1']\n this.requestUpdate('scaleQuestions')\n }\n\n @state() private _answers: { title: string }[] = [{ title: '' }, { title: '' }, { title: '' }, { title: '' }, { title: '' }]\n @state() private _scaleQuestions: string[] = ['问题1']\n @state() private _rowTitle = ''\n @state() private _title = ''\n @state() private _analysis = ''\n @state() private _showRichText = false\n @state() private _richText = ''\n\n // 双向绑定支持\n @property({ type: String, attribute: 'model-value' }) modelValue = ''\n @property({ type: Boolean, attribute: 'use-model' }) useModel = false\n\n private readonly TITLE_MAX = 200\n\n willUpdate(changed: Map<string, unknown>) {\n if (changed.has('isEdit') && this.isEdit) { this._syncProps() }\n // 当外部 modelValue 变化时同步内部状态\n if (changed.has('modelValue') && this.useModel) {\n this._title = this.modelValue\n }\n }\n\n private _syncProps() {\n this._title = this.title || ''\n this._analysis = this.analysis || ''\n this._rowTitle = this._scaleQuestions.join('\\n')\n if (this.richTextContent) {\n this._richText = this.richTextContent\n this._showRichText = true\n }\n }\n\n async toJSON(): Promise<any> {\n return new Promise((resolve, reject) => {\n const row = { customId: this.customId || undefined, answerType: 'scale', orderIndex: this.orderIndex }\n\n const title = this.isEdit ? this._title : this.title || ''\n const answers = this.isEdit ? this._answers : (this.answerList || [])\n const analysis = this.isEdit ? this._analysis : this.analysis || ''\n const rowTitle = this.isEdit ? this._rowTitle : (this.scaleQuestions?.join('\\n') || '')\n const showRichText = this.isEdit ? this._showRichText : !!this.richTextContent\n const richText = this.isEdit ? this._richText : this.richTextContent || ''\n\n if (!title) {\n reject(new SubjectError('题目标题不能为空!', 'EMPTY_TITLE', 'title', row))\n return\n }\n\n for (let i = 0; i < answers.length; i++) {\n if (!answers[i].title) {\n reject(new SubjectError(`选项${String.fromCharCode(65 + i)}未填写。`, 'ANSWER_EMPTY', 'answers', row))\n return\n }\n }\n\n if (!rowTitle) {\n reject(new SubjectError('行标题不能为空!', 'EMPTY_ROW_TITLE', 'rowTitle', row))\n return\n }\n\n const questions = rowTitle.split('\\n').filter((i: string) => i.trim())\n if (questions.length === 0) {\n reject(new SubjectError('行标题不能为空!', 'EMPTY_ROW_TITLE', 'rowTitle', row))\n return\n }\n\n const result: any = {\n answerType: ExamType.SCALE,\n title,\n analysis,\n answers,\n scaleQuestionList: questions,\n examRichTextContent: showRichText ? richText : '',\n examAnswerRelationType: this.examAnswerRelationType,\n }\n if (this.customId) { result.customId = this.customId }\n resolve(result)\n })\n }\n\n private _emit(name: string, detail?: unknown) {\n this.dispatchEvent(new CustomEvent(name, { bubbles: true, composed: true, detail: detail ?? null }))\n }\n\n private _onTitleInput(e: Event) {\n const el = e.target as HTMLTextAreaElement\n if (el.value.length > this.TITLE_MAX) { el.value = el.value.slice(0, this.TITLE_MAX) }\n this._title = el.value\n // 双向绑定:通知外部更新\n if (this.useModel) {\n this.dispatchEvent(new CustomEvent('update:modelValue', {\n bubbles: true,\n composed: true,\n detail: this._title,\n }))\n }\n }\n\n private async _save(e?: Event) {\n e?.stopImmediatePropagation()\n try {\n const data = await this.toJSON()\n this._emit('save', data)\n }\n catch (err: any) {\n showToast(err.message)\n }\n }\n\n validate(): SubjectError[] {\n const errors: SubjectError[] = []\n const row = { customId: this.customId || undefined, answerType: 'scale', orderIndex: this.orderIndex }\n\n const title = this.isEdit ? this._title : this.title || ''\n const answers = this.isEdit ? this._answers : (this.answerList || [])\n const rowTitle = this.isEdit ? this._rowTitle : (this.scaleQuestions?.join('\\n') || '')\n\n if (!title) {\n errors.push(new SubjectError('题目标题不能为空!', 'EMPTY_TITLE', 'title', row))\n }\n\n answers.forEach((a: any, i: number) => {\n if (!a.title) {\n errors.push(new SubjectError(`选项${String.fromCharCode(65 + i)}未填写`, 'ANSWER_EMPTY', 'answers', row))\n }\n })\n\n if (!rowTitle) {\n errors.push(new SubjectError('行标题不能为空!', 'EMPTY_ROW_TITLE', 'rowTitle', row))\n }\n else {\n const questions = rowTitle.split('\\n').filter((i: string) => i.trim())\n if (questions.length === 0) {\n errors.push(new SubjectError('行标题不能为空!', 'EMPTY_ROW_TITLE', 'rowTitle', row))\n }\n }\n\n return errors\n }\n\n private _renderPreview() {\n const colWidth = Math.floor(100 / (this._answers.length + 1))\n return html`\n <div class=\"preview\">\n <span class=\"title\">${this.orderIndex + 1}.${this.title}(量表题)</span>\n ${this.richTextContent ? html`<div style=\"margin-top:8px\" .innerHTML=${this.richTextContent}></div>` : ''}\n <table class=\"scale-table\">\n <thead><tr>\n <th style=\"width:${colWidth}%\">问题 \\ 选项</th>\n ${this._answers.map(a => html`<th style=\"width:${colWidth}%\">${a.title}</th>`)}\n </tr></thead>\n <tbody>\n ${this._scaleQuestions.map(q => html`\n <tr><td>${q}</td>${this._answers.map(() => html`<td><input type=\"radio\" disabled /></td>`)}</tr>\n `)}\n </tbody>\n </table>\n ${this.analysis ? html`<div style=\"color:#909399;font-size:12px;margin-top:8px\">解析: ${this.analysis}</div>` : ''}\n </div>\n `\n }\n\n private _renderEdit() {\n return html`\n <div class=\"flex-items-start\">\n <div class=\"label\"><span>题目:</span></div>\n <div style=\"flex:1\">\n <div class=\"el-input\">\n <textarea rows=\"2\" .value=${this._title} ?disabled=${this.isSave}\n maxlength=${this.TITLE_MAX}\n @input=${(e: Event) => this._onTitleInput(e)}\n placeholder=\"【量表题】请输入问题\"></textarea>\n <span class=\"char-counter\">${this._title.length}/${this.TITLE_MAX}</span>\n </div>\n </div>\n </div>\n\n <div class=\"flex-items-start\" style=\"margin-top:12px\">\n <div class=\"label\"><span>行标题:</span></div>\n <div class=\"flex\" style=\"flex:1\">\n <div class=\"el-input\" style=\"width:160px\">\n <textarea class=\"row-title-textarea\" .value=${this._rowTitle} ?disabled=${this.isSave}\n @input=${(e: Event) => { this._rowTitle = (e.target as HTMLTextAreaElement).value }}\n @keydown=${(e: KeyboardEvent) => { e.stopPropagation() }}\n placeholder=\"请输入行标题\"></textarea>\n </div>\n <div style=\"flex:1;margin-left:12px\">\n ${this._answers.map((a, i) => html`\n <div class=\"answer-item\">\n <span class=\"label\">${String.fromCharCode(65 + i)}.</span>\n <div class=\"input\">\n <input type=\"text\" .value=${a.title} ?disabled=${this.isSave}\n maxlength=\"10\"\n @input=${(e: Event) => { this._answers = this._answers.map((x, j) => j === i ? { title: (e.target as HTMLInputElement).value } : x) }}\n placeholder=\"选项${i + 1}\" />\n </div>\n ${!this.isSave\n ? html`\n <span class=\"icon\" @click=${() => {\n if (this._answers.length < 5) { this._answers = [...this._answers, { title: '' }] }\n }}>${iconPlus}</span>\n <span class=\"icon ${this._answers.length < 3 ? 'disabled' : ''}\" @click=${() => {\n if (this._answers.length > 3) { this._answers = this._answers.filter((_, j) => j !== i) }\n }}>${iconRemove}</span>\n `\n : ''}\n </div>\n `)}\n </div>\n </div>\n </div>\n\n <div class=\"flex-items-start\" style=\"margin-top:12px\">\n <div class=\"label\"><span>解析:</span></div>\n <div style=\"flex:1\">\n <div class=\"el-input\">\n <textarea rows=\"2\" .value=${this._analysis} ?disabled=${this.isSave}\n @input=${(e: Event) => { this._analysis = (e.target as HTMLTextAreaElement).value }}\n placeholder=\"请输入题目解析\"></textarea>\n </div>\n </div>\n </div>\n\n ${this._showRichText\n ? html`\n <div class=\"flex-items-start\" style=\"margin-top:12px\">\n <div class=\"label\"><span>富文本:</span></div>\n <div style=\"flex:1\">\n <qxs-blocksuite-editor\n .content=${this._richText}\n .uploadImage=${this.uploadImage}\n ?is-edit=${true}\n ></qxs-blocksuite-editor>\n <div class=\"flex-justify-end\" style=\"margin-top:8px\"><span class=\"el-link danger\" @click=${() => { this._showRichText = false; this._richText = '' }}>删除富文本</span></div>\n </div>\n </div>\n `\n : ''}\n `\n }\n\n render() {\n return html`\n <qxs-subject-layout ?show-edit=${this.isEdit}>\n <div slot=\"preview\">${this._renderPreview()}</div>\n <div slot=\"edit\">${this._renderEdit()}</div>\n ${this.showAction\n ? html`\n <qxs-subject-action\n ?is-edit=${this.isEdit}\n ?is-set=${this.isSet}\n ?show-other-option=${false}\n exam-answer-relation-type=${this.examAnswerRelationType}\n @delete=${() => this._emit('delete')}\n @save=${this._save}\n @edit=${() => this._emit('edit')}\n @add=${(e: CustomEvent) => this._emit('add', e.detail)}\n @on-show-rich-text=${() => { this._showRichText = true }}\n ></qxs-subject-action>\n `\n : ''}\n </qxs-subject-layout>\n `\n }\n}\n\nexport function register() {}\n"],"names":["iconPlus","html","iconRemove","QxsScale","LitElement","constructor","super","arguments","this","orderIndex","title","customId","isEdit","isSave","isSet","showAction","showAnalysis","analysis","richTextContent","examAnswerRelationType","uploadImage","async","Promise","resolve","reject","reader","FileReader","onload","e","target","result","onerror","readAsDataURL","file","_answers","_scaleQuestions","_rowTitle","_title","_analysis","_showRichText","_richText","modelValue","useModel","TITLE_MAX","answerList","v","arr","Array","isArray","length","slice","requestUpdate","scaleQuestions","willUpdate","changed","has","_syncProps","join","toJSON","row","answerType","answers","rowTitle","showRichText","richText","SubjectError","i","String","fromCharCode","questions","split","filter","trim","ExamType","SCALE","scaleQuestionList","examRichTextContent","_emit","name","detail","dispatchEvent","CustomEvent","bubbles","composed","_onTitleInput","el","value","_save","stopImmediatePropagation","data","err","msg","document","createElement","textContent","Object","assign","style","position","top","left","transform","padding","borderRadius","fontSize","color","background","zIndex","boxShadow","transition","opacity","body","appendChild","setTimeout","remove","showToast","message","validate","errors","push","forEach","a","_renderPreview","colWidth","Math","floor","map","q","_renderEdit","stopPropagation","x","j","_","render","styles","css","__decorateClass","property","type","Number","attribute","prototype","Boolean","state","safeCustomElement"],"mappings":"kiBAMA,MAAMA,EAAWC,EAAAA,IAAA,2NACXC,EAAaD,EAAAA,IAAA,qLAgBNE,QAAAA,SAAN,cAAuBC,EAAAA,WAAvBC,WAAAA,GAAAC,SAAAC,WA8DiDC,KAAAC,WAAa,EACvCD,KAAAE,MAAQ,GACgBF,KAAAG,SAAW,GACZH,KAAAI,QAAS,EACTJ,KAAAK,QAAS,EACVL,KAAAM,OAAQ,EACHN,KAAAO,YAAa,EACXP,KAAAQ,cAAe,EAC5CR,KAAAS,SAAW,GACqBT,KAAAU,gBAAkB,GACVV,KAAAW,uBAAyB,EAE7FX,KAAAY,YAA+CC,SACtC,IAAIC,QAAQ,CAACC,EAASC,KAC3B,MAAMC,EAAS,IAAIC,WACnBD,EAAOE,OAAUC,GAAML,EAAQK,EAAEC,QAAQC,QACzCL,EAAOM,QAAUP,EACjBC,EAAOO,cAAcC,KAoBhBzB,KAAQ0B,SAAgC,CAAC,CAAExB,MAAO,IAAM,CAAEA,MAAO,IAAM,CAAEA,MAAO,IAAM,CAAEA,MAAO,IAAM,CAAEA,MAAO,KAC9GF,KAAQ2B,gB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zBzI,QAAAA,SAmFP0I,UAAA,aAAA,GASAL,EAAA,CADHC,EAAAA,SAAS,CAAEC,KAAM3F,MAAO6F,UAAW,qBA3FzBzI,QAAAA,SA4FP0I,UAAA,iBAAA,GAOaL,EAAA,CAAhBO,EAAAA,SAnGU5I,QAAAA,SAmGM0I,UAAA,WAAA,GACAL,EAAA,CAAhBO,EAAAA,SApGU5I,QAAAA,SAoGM0I,UAAA,kBAAA,GACAL,EAAA,CAAhBO,EAAAA,SArGU5I,QAAAA,SAqGM0I,UAAA,YAAA,GACAL,EAAA,CAAhBO,EAAAA,SAtGU5I,QAAAA,SAsGM0I,UAAA,SAAA,GACAL,EAAA,CAAhBO,EAAAA,SAvGU5I,QAAAA,SAuGM0I,UAAA,YAAA,GACAL,EAAA,CAAhBO,EAAAA,SAxGU5I,QAAAA,SAwGM0I,UAAA,gBAAA,GACAL,EAAA,CAAhBO,EAAAA,SAzGU5I,QAAAA,SAyGM0I,UAAA,YAAA,GAGqCL,EAAA,CAArDC,EAAAA,SAAS,CAAEC,KAAMvE,OAAQyE,UAAW,iBA5G1BzI,QAAAA,SA4G2C0I,UAAA,aAAA,GACDL,EAAA,CAApDC,EAAAA,SAAS,CAAEC,KAAMI,QAASF,UAAW,eA7G3BzI,QAAAA,SA6G0C0I,UAAA,WAAA,GA7G1C1I,QAAAA,SAANqI,EAAA,CADNQ,EAAAA,kBAAkB,cACN7I,QAAAA"}
@@ -1,4 +1,4 @@
1
- "use strict";var e=require("lit"),t=require("../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/property.cjs"),s=require("../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/state.cjs"),i=require("../base/define.cjs"),r=require("../base/uid.cjs"),o=Object.defineProperty,n=Object.getOwnPropertyDescriptor,l=(e,t,s,i)=>{for(var r,l=i>1?void 0:i?n(t,s):t,a=e.length-1;a>=0;a--)(r=e[a])&&(l=(i?r(t,s,l):r(l))||l);return i&&l&&o(t,s,l),l};class a extends Error{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"VALIDATION_ERROR",s=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0;super(e),this.code=t,this.field=s,this.row=i,this.name="SubjectError"}static from(e){return new a(e.message,e.code,e.field,e.row)}}const p=e.html`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>`,d=e.html`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="5" y1="12" x2="19" y2="12"/></svg>`;e.html`<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>`;const c=e.html`<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"/></svg>`;exports.QxsSubjectSingle=class extends e.LitElement{constructor(){super(...arguments),this.orderIndex=0,this.isEdit=!1,this.isSave=!1,this.isSet=!1,this.isKey=!1,this.showAction=!0,this.showAnalysis=!0,this.type="single",this.answerCheckType=1,this.examAnswerRelationType=0,this.richTextContent="",this.analysis="",this.leastAnswerCount=2,this.examExpand="",this.customId="",this.examId=0,this.uploadImage=async e=>new Promise((t,s)=>{const i=new FileReader;i.onload=e=>t(e.target?.result),i.onerror=s,i.readAsDataURL(e)}),this.modelValue="",this.useModel=!1,this._answers=[{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1}],this._title="",this._analysis="",this._richText="",this._showRichText=!1,this._leastAnswerCount=2,this._answerCheckType=1,this._orderList=[],this._resultDialogOpen=!1,this._resultDialogIndex=0,this._resultDialogValue="",this._sortDropdownOpen=!1,this.TITLE_MAX=200,this.ANSWER_MAX=100,this._handleDocumentClick=e=>{const t=e.composedPath(),s=this.shadowRoot?.querySelector(".multi-select-wrapper");s&&!t.includes(s)&&(this._sortDropdownOpen=!1,this.requestUpdate())}}get answerList(){return this._answers}set answerList(e){const t=Array.isArray(e)?e:[];this._answers=t.length?t.map(e=>({...e})):[{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1}],this.requestUpdate("answerList")}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this._handleDocumentClick)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this._handleDocumentClick)}willUpdate(e){e.has("isEdit")&&this.isEdit&&this._syncProps(),(e.has("examExpand")||e.has("answerList"))&&this._syncExamExpand(),e.has("modelValue")&&this.useModel&&(this._title=this.modelValue)}_syncProps(){this._title=this.title||"",this._analysis=this.analysis||"",this._leastAnswerCount=this.leastAnswerCount||2,this._answerCheckType=this.answerCheckType||1,this.richTextContent&&(this._richText=this.richTextContent,this._showRichText=!0),this.answerList?.length&&(this._answers=this.answerList.map(e=>({...e,title:e.title||"",isCorrect:!!e.isCorrect}))),this._syncExamExpand()}_syncExamExpand(){if(!this.examExpand||!this.answerList?.length)return;const e=this.examExpand.split(",");this._orderList=e.map(e=>{const t=this.answerList.find(t=>t.answerId?.toString()===e);return t?String.fromCharCode(65+t.orderIndex-1):e}).filter(Boolean)}_emit(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t??null}))}_label(e){return String.fromCharCode(65+e)}get _titlePlaceholder(){return"single"===this.type?"单选题":"multiple"===this.type?"多选题":"排序题"}_setCorrect(e,t){"single"===this.type?(this._answers.forEach(e=>{e.isCorrect=!1}),e.isCorrect=t):e.isCorrect=t,this.requestUpdate()}_onTitleInput(e){const t=e.target;t.value.length>this.TITLE_MAX&&(t.value=t.value.slice(0,this.TITLE_MAX)),this._title=t.value,this.useModel&&this.dispatchEvent(new CustomEvent("update:modelValue",{bubbles:!0,composed:!0,detail:this._title}))}_onAnswerInput(e,t){const s=e.target;s.value.length>this.ANSWER_MAX&&(s.value=s.value.slice(0,this.ANSWER_MAX)),this._answers[t].title=s.value,this.requestUpdate()}_addAnswer(){this.isSave||(this._answers=[...this._answers,{title:"",isCorrect:!1,customAnswerId:r.uid()}])}_deleteAnswer(e){this._answers.length<3||this.isSave||(this._answers=this._answers.filter((t,s)=>s!==e))}_toggleSortItem(e){const t=this._orderList.indexOf(e);this._orderList=t>=0?this._orderList.filter(t=>t!==e):[...this._orderList,e],this.requestUpdate()}_removeSortItem(e){this._orderList=this._orderList.filter(t=>t!==e),this.requestUpdate()}_getSortOrder(e){const t=this._orderList.indexOf(this._label(e));return t>=0?t+1:null}async toJSON(){return new Promise((e,t)=>{const s={customId:this.customId||void 0,answerType:this.type,orderIndex:this.orderIndex},i=this.isEdit?this._title:this.title||"",r=this.isEdit?this._answers:this.answerList||[],o=this.isEdit?this._answerCheckType:this.answerCheckType||1,n=this.isEdit?this._leastAnswerCount:this.leastAnswerCount||2,l=this.isEdit?this._analysis:this.analysis||"",p=this.isEdit?this._orderList.map(e=>e.charCodeAt(0)-65+1).join(","):this.examExpand||"",d=this.isEdit?this._showRichText:!!this.richTextContent,c=this.isEdit?this._richText:this.richTextContent||"",h=this.isEdit?this._orderList:(()=>{const e=this.examExpand;return e?e.split(",").map(e=>{const t=this.answerList?.find(t=>t.answerId?.toString()===e);return t?String.fromCharCode(65+t.orderIndex-1):e}).filter(Boolean):[]})();if(!i)return void t(new a("题目标题不能为空!","EMPTY_TITLE","title",s));if(!o)return void t(new a("请选择答题设置","NO_ANSWER_CHECK_TYPE","answerCheckType",s));let u="",x=!1,m=0;if("multiple"===this.type||"single"===this.type)r.forEach((e,t)=>{e.title?.trim()||(u+=`选项${String.fromCharCode(65+t)}未填写。`),e.isCorrect&&(x=!0,m++)});else if("sort"===this.type&&(h.length&&(x=!0),x&&h.length<n))return void t(new a(`排序题至少需要设置${n}项排序答案`,"SORT_COUNT_INVALID","orderList",s));if(u)return void t(new a(u,"ANSWER_EMPTY","answers",s));if(new Set(r.map(e=>e.title)).size!==r.length)return void t(new a("选项不能重复","DUPLICATE_ANSWERS","answers",s));if("multiple"===this.type){if(1===m)return void t(new a("请至少设置两个支持选项","CORRECT_COUNT_INVALID","answers",s));if(x&&m<n)return void t(new a("至少选几项与支持选项数不符","LEAST_ANSWER_COUNT_INVALID","answers",s))}if((2===o||3===o)&&!x)return void t(new a("请设置支持选项","NO_CORRECT_ANSWER","answers",s));const g={answerType:this.type,title:i,answers:r.filter(e=>e.title).map((e,t)=>({...e,orderIndex:t+1})),examExpand:p,analysis:l,isSetCorrectAnswer:x,leastAnswerCount:n,examRichTextContent:d?c:"",examAnswerRelationType:this.examAnswerRelationType,isKey:this.isKey,answerCheckType:o};this.customId&&(g.customId=this.customId),e(g)})}validate(){const e=[],t={customId:this.customId||void 0,answerType:this.type,orderIndex:this.orderIndex},s=this.isEdit?this._title:this.title||"",i=this.isEdit?this._answers:this.answerList||[],r=this.isEdit?this._answerCheckType:this.answerCheckType||1,o=this.isEdit?this._leastAnswerCount:this.leastAnswerCount||2,n=this.isEdit?this._orderList:(()=>{const e=this.examExpand;return e?e.split(",").map(e=>{const t=this.answerList?.find(t=>t.answerId?.toString()===e);return t?String.fromCharCode(65+t.orderIndex-1):e}).filter(Boolean):[]})();s||e.push(new a("题目标题不能为空!","EMPTY_TITLE","title",t)),r||e.push(new a("请选择答题设置","NO_ANSWER_CHECK_TYPE","answerCheckType",t));let l=!1,p=0;"multiple"===this.type||"single"===this.type?i.forEach((s,i)=>{s.title?.trim()||e.push(new a(`选项${String.fromCharCode(65+i)}未填写`,"ANSWER_EMPTY","answers",t)),s.isCorrect&&(l=!0,p++)}):"sort"===this.type&&(n.length&&(l=!0),l&&n.length<o&&e.push(new a(`排序题至少需要设置${o}项排序答案`,"SORT_COUNT_INVALID","orderList",t)));return new Set(i.map(e=>e.title)).size!==i.length&&i.length>0&&e.push(new a("选项不能重复","DUPLICATE_ANSWERS","answers",t)),"multiple"===this.type&&(1===p&&i.length>0&&e.push(new a("请至少设置两个支持选项","CORRECT_COUNT_INVALID","answers",t)),l&&p<o&&e.push(new a("至少选几项与支持选项数不符","LEAST_ANSWER_COUNT_INVALID","answers",t))),2!==r&&3!==r||l||e.push(new a("请设置支持选项","NO_CORRECT_ANSWER","answers",t)),e}_openResultDialog(e){this._resultDialogIndex=e,this._resultDialogValue=this._answers[e].resultItem||"",this._resultDialogOpen=!0}_saveResultDialog(){this._answers[this._resultDialogIndex].resultItem=this._resultDialogValue,this._resultDialogOpen=!1,this.requestUpdate()}_renderResultDialog(){if(!this._resultDialogOpen)return"";const t=this._label(this._resultDialogIndex);return e.html`
1
+ "use strict";var e=require("lit"),t=require("../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/property.cjs"),s=require("../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/state.cjs"),i=require("../base/define.cjs"),r=require("../base/uid.cjs"),o=require("./types.cjs"),n=Object.defineProperty,l=Object.getOwnPropertyDescriptor,a=(e,t,s,i)=>{for(var r,o=i>1?void 0:i?l(t,s):t,a=e.length-1;a>=0;a--)(r=e[a])&&(o=(i?r(t,s,o):r(o))||o);return i&&o&&n(t,s,o),o};class p extends Error{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"VALIDATION_ERROR",s=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0;super(e),this.code=t,this.field=s,this.row=i,this.name="SubjectError"}static from(e){return new p(e.message,e.code,e.field,e.row)}}const d=e.html`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>`,c=e.html`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="5" y1="12" x2="19" y2="12"/></svg>`;e.html`<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>`;const h=e.html`<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"/></svg>`;exports.QxsSubjectSingle=class extends e.LitElement{constructor(){super(...arguments),this.orderIndex=0,this.isEdit=!1,this.isSave=!1,this.isSet=!1,this.isKey=!1,this.showAction=!0,this.showAnalysis=!0,this.type="single",this.answerCheckType=1,this.examAnswerRelationType=0,this.richTextContent="",this.analysis="",this.leastAnswerCount=2,this.examExpand="",this.customId="",this.examId=0,this.uploadImage=async e=>new Promise((t,s)=>{const i=new FileReader;i.onload=e=>t(e.target?.result),i.onerror=s,i.readAsDataURL(e)}),this.modelValue="",this.useModel=!1,this._answers=[{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1}],this._title="",this._analysis="",this._richText="",this._showRichText=!1,this._leastAnswerCount=2,this._answerCheckType=1,this._orderList=[],this._resultDialogOpen=!1,this._resultDialogIndex=0,this._resultDialogValue="",this._sortDropdownOpen=!1,this.TITLE_MAX=200,this.ANSWER_MAX=100,this._handleDocumentClick=e=>{const t=e.composedPath(),s=this.shadowRoot?.querySelector(".multi-select-wrapper");s&&!t.includes(s)&&(this._sortDropdownOpen=!1,this.requestUpdate())}}get answerList(){return this._answers}set answerList(e){const t=Array.isArray(e)?e:[];this._answers=t.length?t.map(e=>({...e})):[{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1}],this.requestUpdate("answerList")}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this._handleDocumentClick)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this._handleDocumentClick)}willUpdate(e){e.has("isEdit")&&this.isEdit&&this._syncProps(),(e.has("examExpand")||e.has("answerList"))&&this._syncExamExpand(),e.has("modelValue")&&this.useModel&&(this._title=this.modelValue)}_syncProps(){this._title=this.title||"",this._analysis=this.analysis||"",this._leastAnswerCount=this.leastAnswerCount||2,this._answerCheckType=this.answerCheckType||1,this.richTextContent&&(this._richText=this.richTextContent,this._showRichText=!0),this.answerList?.length&&(this._answers=this.answerList.map(e=>({...e,title:e.title||"",isCorrect:!!e.isCorrect}))),this._syncExamExpand()}_syncExamExpand(){if(!this.examExpand||!this.answerList?.length)return;const e=this.examExpand.split(",");this._orderList=e.map(e=>{const t=this.answerList.find(t=>t.answerId?.toString()===e);return t?String.fromCharCode(65+t.orderIndex-1):e}).filter(Boolean)}_emit(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t??null}))}_label(e){return String.fromCharCode(65+e)}get _titlePlaceholder(){return"single"===this.type?"单选题":"multiple"===this.type?"多选题":"排序题"}_setCorrect(e,t){"single"===this.type?(this._answers.forEach(e=>{e.isCorrect=!1}),e.isCorrect=t):e.isCorrect=t,this.requestUpdate()}_onTitleInput(e){const t=e.target;t.value.length>this.TITLE_MAX&&(t.value=t.value.slice(0,this.TITLE_MAX)),this._title=t.value,this.useModel&&this.dispatchEvent(new CustomEvent("update:modelValue",{bubbles:!0,composed:!0,detail:this._title}))}_onAnswerInput(e,t){const s=e.target;s.value.length>this.ANSWER_MAX&&(s.value=s.value.slice(0,this.ANSWER_MAX)),this._answers[t].title=s.value,this.requestUpdate()}_addAnswer(){this.isSave||(this._answers=[...this._answers,{title:"",isCorrect:!1,customAnswerId:r.uid()}])}_deleteAnswer(e){this._answers.length<3||this.isSave||(this._answers=this._answers.filter((t,s)=>s!==e))}_toggleSortItem(e){const t=this._orderList.indexOf(e);this._orderList=t>=0?this._orderList.filter(t=>t!==e):[...this._orderList,e],this.requestUpdate()}_removeSortItem(e){this._orderList=this._orderList.filter(t=>t!==e),this.requestUpdate()}_getSortOrder(e){const t=this._orderList.indexOf(this._label(e));return t>=0?t+1:null}async toJSON(){return new Promise((e,t)=>{const s={customId:this.customId||void 0,answerType:this.type,orderIndex:this.orderIndex},i=this.isEdit?this._title:this.title||"",r=this.isEdit?this._answers:this.answerList||[],n=this.isEdit?this._answerCheckType:this.answerCheckType||1,l=this.isEdit?this._leastAnswerCount:this.leastAnswerCount||2,a=this.isEdit?this._analysis:this.analysis||"",d=this.isEdit?this._orderList.map(e=>e.charCodeAt(0)-65+1).join(","):this.examExpand||"",c=this.isEdit?this._showRichText:!!this.richTextContent,h=this.isEdit?this._richText:this.richTextContent||"",u=this.isEdit?this._orderList:(()=>{const e=this.examExpand;return e?e.split(",").map(e=>{const t=this.answerList?.find(t=>t.answerId?.toString()===e);return t?String.fromCharCode(65+t.orderIndex-1):e}).filter(Boolean):[]})();if(!i)return void t(new p("题目标题不能为空!","EMPTY_TITLE","title",s));if(!n)return void t(new p("请选择答题设置","NO_ANSWER_CHECK_TYPE","answerCheckType",s));let x="",m=!1,g=0;if("multiple"===this.type||"single"===this.type)r.forEach((e,t)=>{e.title?.trim()||(x+=`选项${String.fromCharCode(65+t)}未填写。`),e.isCorrect&&(m=!0,g++)});else if("sort"===this.type&&(u.length&&(m=!0),m&&u.length<l))return void t(new p(`排序题至少需要设置${l}项排序答案`,"SORT_COUNT_INVALID","orderList",s));if(x)return void t(new p(x,"ANSWER_EMPTY","answers",s));if(new Set(r.map(e=>e.title)).size!==r.length)return void t(new p("选项不能重复","DUPLICATE_ANSWERS","answers",s));if("multiple"===this.type){if(1===g)return void t(new p("请至少设置两个支持选项","CORRECT_COUNT_INVALID","answers",s));if(m&&g<l)return void t(new p("至少选几项与支持选项数不符","LEAST_ANSWER_COUNT_INVALID","answers",s))}if((2===n||3===n)&&!m)return void t(new p("请设置支持选项","NO_CORRECT_ANSWER","answers",s));const w={answerType:o.getExamType(this.type),title:i,answers:r.filter(e=>e.title).map((e,t)=>({...e,orderIndex:t+1})),examExpand:d,analysis:a,isSetCorrectAnswer:m,leastAnswerCount:l,examRichTextContent:c?h:"",examAnswerRelationType:this.examAnswerRelationType,isKey:this.isKey,answerCheckType:n};this.customId&&(w.customId=this.customId),e(w)})}validate(){const e=[],t={customId:this.customId||void 0,answerType:this.type,orderIndex:this.orderIndex},s=this.isEdit?this._title:this.title||"",i=this.isEdit?this._answers:this.answerList||[],r=this.isEdit?this._answerCheckType:this.answerCheckType||1,o=this.isEdit?this._leastAnswerCount:this.leastAnswerCount||2,n=this.isEdit?this._orderList:(()=>{const e=this.examExpand;return e?e.split(",").map(e=>{const t=this.answerList?.find(t=>t.answerId?.toString()===e);return t?String.fromCharCode(65+t.orderIndex-1):e}).filter(Boolean):[]})();s||e.push(new p("题目标题不能为空!","EMPTY_TITLE","title",t)),r||e.push(new p("请选择答题设置","NO_ANSWER_CHECK_TYPE","answerCheckType",t));let l=!1,a=0;"multiple"===this.type||"single"===this.type?i.forEach((s,i)=>{s.title?.trim()||e.push(new p(`选项${String.fromCharCode(65+i)}未填写`,"ANSWER_EMPTY","answers",t)),s.isCorrect&&(l=!0,a++)}):"sort"===this.type&&(n.length&&(l=!0),l&&n.length<o&&e.push(new p(`排序题至少需要设置${o}项排序答案`,"SORT_COUNT_INVALID","orderList",t)));return new Set(i.map(e=>e.title)).size!==i.length&&i.length>0&&e.push(new p("选项不能重复","DUPLICATE_ANSWERS","answers",t)),"multiple"===this.type&&(1===a&&i.length>0&&e.push(new p("请至少设置两个支持选项","CORRECT_COUNT_INVALID","answers",t)),l&&a<o&&e.push(new p("至少选几项与支持选项数不符","LEAST_ANSWER_COUNT_INVALID","answers",t))),2!==r&&3!==r||l||e.push(new p("请设置支持选项","NO_CORRECT_ANSWER","answers",t)),e}_openResultDialog(e){this._resultDialogIndex=e,this._resultDialogValue=this._answers[e].resultItem||"",this._resultDialogOpen=!0}_saveResultDialog(){this._answers[this._resultDialogIndex].resultItem=this._resultDialogValue,this._resultDialogOpen=!1,this.requestUpdate()}_renderResultDialog(){if(!this._resultDialogOpen)return"";const t=this._label(this._resultDialogIndex);return e.html`
2
2
  <div class="modal-backdrop" @click=${()=>{this._resultDialogOpen=!1}}>
3
3
  <div class="modal" @click=${e=>e.stopPropagation()}>
4
4
  <div class="modal-header">
@@ -82,11 +82,11 @@
82
82
 
83
83
  <span class="icon ${this.isSave?"disabled":""}"
84
84
  @click=${()=>this._addAnswer()}>
85
- ${p}
85
+ ${d}
86
86
  </span>
87
87
  <span class="icon ${this.isSave||this._answers.length<3?"disabled":""}"
88
88
  @click=${()=>this._deleteAnswer(s)}>
89
- ${d}
89
+ ${c}
90
90
  </span>
91
91
 
92
92
  ${1===this.examAnswerRelationType&&"sort"!==this.type?e.html`
@@ -112,7 +112,7 @@
112
112
  <span class="tag-close" @click=${e=>{e.stopPropagation(),this._removeSortItem(t)}}>&#x2715;</span>
113
113
  </span>
114
114
  `):e.html`<span class="placeholder">请按顺序选择排序答案</span>`}
115
- <span class="arrow">${c}</span>
115
+ <span class="arrow">${h}</span>
116
116
  </div>
117
117
  ${this._sortDropdownOpen?e.html`
118
118
  <div class="multi-select-dropdown">
@@ -315,5 +315,5 @@
315
315
  .modal-footer button:hover { color: #3D61E3; border-color: #a0cfff; }
316
316
  .modal-footer button.primary { background: #3D61E3; border-color: #3D61E3; color: #fff; }
317
317
  .modal-footer button.primary:hover { background: #2D4CB8; border-color: #2D4CB8; }
318
- `,l([t.property({type:Number,attribute:"order-index"})],exports.QxsSubjectSingle.prototype,"orderIndex",2),l([t.property({type:Boolean,attribute:"is-edit"})],exports.QxsSubjectSingle.prototype,"isEdit",2),l([t.property({type:Boolean,attribute:"is-save"})],exports.QxsSubjectSingle.prototype,"isSave",2),l([t.property({type:Boolean,attribute:"is-set"})],exports.QxsSubjectSingle.prototype,"isSet",2),l([t.property({type:Boolean,attribute:"is-key"})],exports.QxsSubjectSingle.prototype,"isKey",2),l([t.property({type:Boolean,attribute:"show-action"})],exports.QxsSubjectSingle.prototype,"showAction",2),l([t.property({type:Boolean,attribute:"show-analysis"})],exports.QxsSubjectSingle.prototype,"showAnalysis",2),l([t.property({type:String})],exports.QxsSubjectSingle.prototype,"type",2),l([t.property({type:Number,attribute:"answer-check-type"})],exports.QxsSubjectSingle.prototype,"answerCheckType",2),l([t.property({type:Number,attribute:"exam-answer-relation-type"})],exports.QxsSubjectSingle.prototype,"examAnswerRelationType",2),l([t.property({type:String,attribute:"rich-text-content"})],exports.QxsSubjectSingle.prototype,"richTextContent",2),l([t.property({type:String})],exports.QxsSubjectSingle.prototype,"analysis",2),l([t.property({type:Number,attribute:"least-answer-count"})],exports.QxsSubjectSingle.prototype,"leastAnswerCount",2),l([t.property({type:String,attribute:"exam-expand"})],exports.QxsSubjectSingle.prototype,"examExpand",2),l([t.property({type:String,attribute:"custom-id"})],exports.QxsSubjectSingle.prototype,"customId",2),l([t.property({type:Number,attribute:"exam-id"})],exports.QxsSubjectSingle.prototype,"examId",2),l([t.property({type:Object})],exports.QxsSubjectSingle.prototype,"uploadImage",2),l([t.property({type:Array,attribute:"answer-list"})],exports.QxsSubjectSingle.prototype,"answerList",1),l([t.property({type:String,attribute:"model-value"})],exports.QxsSubjectSingle.prototype,"modelValue",2),l([t.property({type:Boolean,attribute:"use-model"})],exports.QxsSubjectSingle.prototype,"useModel",2),l([s.state()],exports.QxsSubjectSingle.prototype,"_answers",2),l([s.state()],exports.QxsSubjectSingle.prototype,"_title",2),l([s.state()],exports.QxsSubjectSingle.prototype,"_analysis",2),l([s.state()],exports.QxsSubjectSingle.prototype,"_richText",2),l([s.state()],exports.QxsSubjectSingle.prototype,"_showRichText",2),l([s.state()],exports.QxsSubjectSingle.prototype,"_leastAnswerCount",2),l([s.state()],exports.QxsSubjectSingle.prototype,"_answerCheckType",2),l([s.state()],exports.QxsSubjectSingle.prototype,"_orderList",2),l([s.state()],exports.QxsSubjectSingle.prototype,"_resultDialogOpen",2),l([s.state()],exports.QxsSubjectSingle.prototype,"_resultDialogIndex",2),l([s.state()],exports.QxsSubjectSingle.prototype,"_resultDialogValue",2),l([s.state()],exports.QxsSubjectSingle.prototype,"_sortDropdownOpen",2),exports.QxsSubjectSingle=l([i.safeCustomElement("qxs-subject-single")],exports.QxsSubjectSingle),exports.SubjectError=a;
318
+ `,a([t.property({type:Number,attribute:"order-index"})],exports.QxsSubjectSingle.prototype,"orderIndex",2),a([t.property({type:Boolean,attribute:"is-edit"})],exports.QxsSubjectSingle.prototype,"isEdit",2),a([t.property({type:Boolean,attribute:"is-save"})],exports.QxsSubjectSingle.prototype,"isSave",2),a([t.property({type:Boolean,attribute:"is-set"})],exports.QxsSubjectSingle.prototype,"isSet",2),a([t.property({type:Boolean,attribute:"is-key"})],exports.QxsSubjectSingle.prototype,"isKey",2),a([t.property({type:Boolean,attribute:"show-action"})],exports.QxsSubjectSingle.prototype,"showAction",2),a([t.property({type:Boolean,attribute:"show-analysis"})],exports.QxsSubjectSingle.prototype,"showAnalysis",2),a([t.property({type:String})],exports.QxsSubjectSingle.prototype,"type",2),a([t.property({type:Number,attribute:"answer-check-type"})],exports.QxsSubjectSingle.prototype,"answerCheckType",2),a([t.property({type:Number,attribute:"exam-answer-relation-type"})],exports.QxsSubjectSingle.prototype,"examAnswerRelationType",2),a([t.property({type:String,attribute:"rich-text-content"})],exports.QxsSubjectSingle.prototype,"richTextContent",2),a([t.property({type:String})],exports.QxsSubjectSingle.prototype,"analysis",2),a([t.property({type:Number,attribute:"least-answer-count"})],exports.QxsSubjectSingle.prototype,"leastAnswerCount",2),a([t.property({type:String,attribute:"exam-expand"})],exports.QxsSubjectSingle.prototype,"examExpand",2),a([t.property({type:String,attribute:"custom-id"})],exports.QxsSubjectSingle.prototype,"customId",2),a([t.property({type:Number,attribute:"exam-id"})],exports.QxsSubjectSingle.prototype,"examId",2),a([t.property({type:Object})],exports.QxsSubjectSingle.prototype,"uploadImage",2),a([t.property({type:Array,attribute:"answer-list"})],exports.QxsSubjectSingle.prototype,"answerList",1),a([t.property({type:String,attribute:"model-value"})],exports.QxsSubjectSingle.prototype,"modelValue",2),a([t.property({type:Boolean,attribute:"use-model"})],exports.QxsSubjectSingle.prototype,"useModel",2),a([s.state()],exports.QxsSubjectSingle.prototype,"_answers",2),a([s.state()],exports.QxsSubjectSingle.prototype,"_title",2),a([s.state()],exports.QxsSubjectSingle.prototype,"_analysis",2),a([s.state()],exports.QxsSubjectSingle.prototype,"_richText",2),a([s.state()],exports.QxsSubjectSingle.prototype,"_showRichText",2),a([s.state()],exports.QxsSubjectSingle.prototype,"_leastAnswerCount",2),a([s.state()],exports.QxsSubjectSingle.prototype,"_answerCheckType",2),a([s.state()],exports.QxsSubjectSingle.prototype,"_orderList",2),a([s.state()],exports.QxsSubjectSingle.prototype,"_resultDialogOpen",2),a([s.state()],exports.QxsSubjectSingle.prototype,"_resultDialogIndex",2),a([s.state()],exports.QxsSubjectSingle.prototype,"_resultDialogValue",2),a([s.state()],exports.QxsSubjectSingle.prototype,"_sortDropdownOpen",2),exports.QxsSubjectSingle=a([i.safeCustomElement("qxs-subject-single")],exports.QxsSubjectSingle),exports.SubjectError=p;
319
319
  //# sourceMappingURL=single.cjs.map