@qxs-bns/components-wc 0.0.25 → 0.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/es/editor/blocksuite-editor.mjs +312 -43
  2. package/es/editor/blocksuite-editor.mjs.map +1 -1
  3. package/es/entry-subject.mjs +1 -1
  4. package/es/index.mjs +1 -1
  5. package/es/subject/blank-fill.mjs +34 -56
  6. package/es/subject/blank-fill.mjs.map +1 -1
  7. package/es/subject/draft.mjs +2 -0
  8. package/es/subject/draft.mjs.map +1 -0
  9. package/es/subject/list.mjs +57 -99
  10. package/es/subject/list.mjs.map +1 -1
  11. package/es/subject/page-end.mjs +3 -3
  12. package/es/subject/page-end.mjs.map +1 -1
  13. package/es/subject/pagination.mjs +2 -0
  14. package/es/subject/pagination.mjs.map +1 -0
  15. package/es/subject/runtime.mjs +2 -0
  16. package/es/subject/runtime.mjs.map +1 -0
  17. package/es/subject/scale.mjs +101 -152
  18. package/es/subject/scale.mjs.map +1 -1
  19. package/es/subject/single.mjs +89 -88
  20. package/es/subject/single.mjs.map +1 -1
  21. package/es/subject/sort-controller.mjs +2 -0
  22. package/es/subject/sort-controller.mjs.map +1 -0
  23. package/es/subject/sortable.mjs +30 -0
  24. package/es/subject/sortable.mjs.map +1 -0
  25. package/es/subject/sorting-card.mjs +52 -0
  26. package/es/subject/sorting-card.mjs.map +1 -0
  27. package/es/subject/text-fill.mjs +24 -45
  28. package/es/subject/text-fill.mjs.map +1 -1
  29. package/es/subject/types.mjs +1 -1
  30. package/es/subject/types.mjs.map +1 -1
  31. package/lib/editor/blocksuite-editor.cjs +304 -35
  32. package/lib/editor/blocksuite-editor.cjs.map +1 -1
  33. package/lib/entry-subject.cjs +1 -1
  34. package/lib/index.cjs +1 -1
  35. package/lib/subject/blank-fill.cjs +24 -46
  36. package/lib/subject/blank-fill.cjs.map +1 -1
  37. package/lib/subject/draft.cjs +2 -0
  38. package/lib/subject/draft.cjs.map +1 -0
  39. package/lib/subject/list.cjs +16 -58
  40. package/lib/subject/list.cjs.map +1 -1
  41. package/lib/subject/page-end.cjs +3 -3
  42. package/lib/subject/page-end.cjs.map +1 -1
  43. package/lib/subject/pagination.cjs +2 -0
  44. package/lib/subject/pagination.cjs.map +1 -0
  45. package/lib/subject/runtime.cjs +2 -0
  46. package/lib/subject/runtime.cjs.map +1 -0
  47. package/lib/subject/scale.cjs +98 -149
  48. package/lib/subject/scale.cjs.map +1 -1
  49. package/lib/subject/single.cjs +89 -88
  50. package/lib/subject/single.cjs.map +1 -1
  51. package/lib/subject/sort-controller.cjs +2 -0
  52. package/lib/subject/sort-controller.cjs.map +1 -0
  53. package/lib/subject/sortable.cjs +30 -0
  54. package/lib/subject/sortable.cjs.map +1 -0
  55. package/lib/subject/sorting-card.cjs +52 -0
  56. package/lib/subject/sorting-card.cjs.map +1 -0
  57. package/lib/subject/text-fill.cjs +24 -45
  58. package/lib/subject/text-fill.cjs.map +1 -1
  59. package/lib/subject/types.cjs +1 -1
  60. package/lib/subject/types.cjs.map +1 -1
  61. package/package.json +1 -1
@@ -1,132 +1,90 @@
1
- import{css as t,LitElement as e,html as s}from"lit";import{property as i,state as a}from"lit/decorators.js";import r from"sortablejs";import{safeCustomElement as o}from"../base/define.mjs";import{uid as n}from"../base/uid.mjs";import{SubjectError as l}from"./single.mjs";import{SubjectType as h}from"./types.mjs";import"./action.mjs";import"./blank-fill.mjs";import"./layout.mjs";import"./text-fill.mjs";import"./scale.mjs";import"./page-end.mjs";import"./type.mjs";var d=Object.defineProperty,c=Object.getOwnPropertyDescriptor,p=(t,e,s,i)=>{for(var a,r=i>1?void 0:i?c(e,s):e,o=t.length-1;o>=0;o--)(a=t[o])&&(r=(i?a(e,s,r):a(r))||r);return i&&r&&d(e,s,r),r};let u=class extends e{constructor(){super(...arguments),this["is-preview"]=!1,this["use-model"]=null,this._modelValueAttr="",this["upload-image"]=async t=>new Promise((e,s)=>{const i=new FileReader;i.onload=t=>e(t.target?.result),i.onerror=s,i.readAsDataURL(t)}),this["category-list"]=[],this["show-tag"]=!1,this["show-category"]=!1,this["show-ai"]=!1,this["show-resource"]=!1,this["show-jump"]=!1,this["show-add"]=!0,this["show-answer-setting"]=!1,this["show-key"]=!1,this["search-api"]="",this._list=[],this._sortMode=!1,this._sortable=null,this._initialDataProcessed=!1}get"model-value"(){return JSON.stringify(this._list)}set"model-value"(t){if(t&&t!==this._modelValueAttr){this._modelValueAttr=t;try{const e=JSON.parse(t);Array.isArray(e)&&(this._list=this._normalizeIncomingList(e),this.requestUpdate())}catch{}}}get _useModel(){return"true"===this["use-model"]||""===this["use-model"]||this.hasAttribute("use-model")}get"subject-list"(){return this._list}set"subject-list"(t){if(t){if("string"==typeof t)try{t=JSON.parse(t)}catch{return this._list=[],void this.requestUpdate()}if(!Array.isArray(t))return this._list=[],void this.requestUpdate();this._list=this._normalizeIncomingList(t),this.requestUpdate()}else this._list=[]}attributeChangedCallback(t,e,s){if(super.attributeChangedCallback(t,e,s),"subject-list"===t&&s&&!this._list.length){if(s.includes("[object Object]"))return;try{const t=JSON.parse(s);Array.isArray(t)&&(this._list=this._normalizeIncomingList(t),this.requestUpdate())}catch{}}}get _isPreviewValue(){const t=this["is-preview"];return"string"==typeof t?"false"!==t:!!t}connectedCallback(){super.connectedCallback(),this._initialDataProcessed||(this._initialDataProcessed=!0,Promise.resolve().then(()=>{0===this._list.length&&this._processAttributeList()}))}_processAttributeList(){const t=this.getAttribute("subject-list");if(t&&"[]"!==t&&!t.includes("[object Object]"))try{const e=JSON.parse(t);Array.isArray(e)&&e.length>0&&(this._list=this._normalizeIncomingList(e),this.requestUpdate())}catch{}}_normalizeAnswer(t){return{...t,title:String(t?.title??t?.answer??""),answerId:t?.answerId??t?.examAnswerId}}_normalizeItem(t){const e=t?.answerType||(t?.richTextContent?t?.answerType:t?.examTypeEnum),s=Array.isArray(t?.answers)?t.answers.map(t=>this._normalizeAnswer(t)):[];return{...t,customId:t?.customId||n(),...e?{answerType:e}:{},...s.length||Array.isArray(t?.answers)?{answers:s}:{}}}_rebuildPageEndMarkers(t){if(!t.length)return t;if(t.some(t=>"page_end"===t?.answerType))return t;if(!t.some(t=>Number(t?.pageIndex)>1))return t;let e=1;const s=[];return t.forEach(t=>{const i=Number(t?.pageIndex)||1;if(i>e)if(s.length>0)for(;e<i;)s.push({customId:n(),answerType:"page_end"}),e++;else e=i;s.push(t)}),s}_normalizeIncomingList(t){const e=t.map(t=>this._normalizeItem(t));return this._rebuildPageEndMarkers(e)}firstUpdated(){this.updateComplete.then(()=>this._initSortable())}updated(t){t.has("_sortMode")&&(this._sortable?.destroy(),this._sortable=null,this.updateComplete.then(()=>this._initSortable())),t.has("_list")&&this._sortMode&&setTimeout(()=>{this._sortable&&(this._sortable.destroy(),this._sortable=null),this._initSortable()},50)}disconnectedCallback(){super.disconnectedCallback(),this._sortable?.destroy(),this._sortable=null}_initSortable(){if(!this._sortMode)return;this.renderRoot.querySelector(".sort-list")&&(this._sortable&&(this._sortable.destroy(),this._sortable=null),requestAnimationFrame(()=>{const t=this.renderRoot.querySelector(".sort-list");t&&!this._sortable&&(this._sortable=r.create(t,{handle:".sort-handle",animation:200,ghostClass:"sort-ghost",chosenClass:"sort-chosen",onEnd:t=>{const{oldIndex:e,newIndex:s}=t;if(void 0===e||void 0===s||e===s)return;const i=[...this._list],[a]=i.splice(e,1);i.splice(s,0,a),this._list=i,this._emitListChange()}}))}))}_emit(t,e){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e??null}))}_emitListChange(){this._emit("change",this._list),this._useModel&&(this._modelValueAttr=JSON.stringify(this._list),this._emit("list-change",this._list))}_withPageIndex(t){const e=[];let s=1,i=!1;return t.forEach(t=>{t&&("page_end"!==t.answerType?(i&&(s+=1,i=!1),e.push({...t,pageIndex:s})):e.length>0&&(i=!0))}),e}async toJSON(){const t=this.renderRoot.querySelectorAll("qxs-subject-single, qxs-blank-fill, qxs-text-fill, qxs-scale, qxs-page-end, qxs-subject-rich-text");if(!t||0===t.length)return[];const e=[],s=[];for(const i of t)if("function"==typeof i.toJSON)try{const t=await i.toJSON();e.push(t)}catch(t){t instanceof l?s.push(t):s.push(new l(t.message||"未知错误","UNKNOWN","unknown"))}if(s.length>0)throw s;return this._withPageIndex(e)}async validate(){const t=this.renderRoot.querySelectorAll("qxs-subject-single, qxs-blank-fill, qxs-text-fill, qxs-scale, qxs-page-end");if(!t||0===t.length)return{valid:!0,errors:[]};const e=[];for(const s of t)if("function"==typeof s.validate){const t=s.validate();t?.length&&e.push(...t)}return{valid:0===e.length,errors:e}}get currentList(){return this._list}addSubject(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if("page_end"===t){const t={customId:n(),answerType:"page_end"},s=[...this._list];return"number"==typeof e&&e>=0?s.splice(e+1,0,t):s.push(t),this._list=s,this.requestUpdate(),void this._emitListChange()}const i={customId:n(),answerType:t,title:"",answers:[],analysis:"",scaleQuestionList:[],isEdit:!0,isSave:!1,isRealCanDel:!0,hasSet:!1,isKey:!1,answerCheckType:1,examAnswerRelationType:s??0},a=[...this._list];"number"==typeof e&&e>=0?a.splice(e+1,0,i):a.push(i),this._list=a,this.requestUpdate(),this._emitListChange()}addExam(t){const e=this._normalizeIncomingList(t).map(t=>({...t,isEdit:!0,isSave:!1,isRealCanDel:!0,hasSet:!1}));this._list=[...this._list,...e],this._emitListChange()}uploadExcel(t){this._list=[...this._list,...this._normalizeIncomingList(t).map(t=>({...t,isRealCanDel:!0}))],this._emitListChange()}setAnswerRelation(t,e,s){const i=this._list.find(t=>t.customId===e);if(i){const e=i.answers?.find(t=>t.customAnswerId===s);e&&(e.answerRelations=t)}this.requestUpdate(),this._emitListChange()}setTagList(t,e){const s=this._list.find(t=>t.customId===e);if(s)return s.tagInfos=Array.isArray(t)?t:[],s.memberTagInfo=Array.isArray(t)?t:[],this._list=[...this._list],void this._emitListChange();this.requestUpdate()}_orderIndex(t){let e=0,s=0;return this._list.forEach(i=>{e++,i.customId===t&&(s=e)}),s-1}_move(t,e){const s=[...this._list];"up"===e&&t>0?[s[t-1],s[t]]=[s[t],s[t-1]]:"down"===e&&t<s.length-1&&([s[t],s[t+1]]=[s[t+1],s[t]]),this._list=s,this._emitListChange()}_save(t,e){this._list=this._list.map((s,i)=>i===t?{...s,...e.detail,isEdit:!1,isSave:!0}:s),this._emitListChange()}_deleteByCustomId(t){this._list=this._list.filter(e=>e.customId!==t),this._emitListChange()}_delete(t){const e=[...this._list];e.splice(t,1),this._list=e,this._emitListChange()}_setEdit(t,e){this._list=this._list.map((s,i)=>i===t?{...s,isEdit:e}:s)}_pageEndTotal(){return this._list.filter(t=>"page_end"===t.answerType).length+1}_pageEndIndex(t){return this._list.slice(0,t+1).filter(t=>"page_end"===t.answerType).length}_syncRelationAnswer(t,e){const s=this._list[t];if(!s||!Array.isArray(s.answers)||!e?.answer)return;const i=[...s.answers],a=e.answer;let r="number"==typeof e.answerIndex?e.answerIndex:-1;(r<0||r>=i.length)&&(r=i.findIndex((t,e)=>String(t.customAnswerId||"")===String(a.customAnswerId||"")||String(t.answerId||"")===String(a.answerId||"")||String(t.orderIndex||e+1)===String(a.orderIndex||""))),r<0||(i[r]={...i[r],customAnswerId:a.customAnswerId||i[r].customAnswerId||a.answerId},this._list[t]={...s,answers:i},this._list=[...this._list])}_renderItem(t,e){const i=this._orderIndex(t.customId),a=(t.isEdit,t.hasSet,t.isRealCanDel,this._isPreviewValue,t.examAnswerRelationType,t=>this._move(e,t.detail)),r=()=>this._deleteByCustomId(t.customId),o=t=>this._save(e,t),n=()=>this._setEdit(e,!0),l=t=>this.addSubject(t.detail?.type??t.detail,e);return[h.SINGLE,h.MULTIPLE,h.SORT].includes(t.answerType)?s`<qxs-subject-single
2
- .title=${t.title||""}
3
- .answer-list=${t.answers||[]}
4
- .tag-list=${t.tagInfos||t.memberTagInfo||[]}
1
+ import{css as e,LitElement as t,html as s}from"lit";import{property as i,state as r}from"lit/decorators.js";import o from"sortablejs";import{safeCustomElement as a}from"../base/define.mjs";import{uid as n}from"../base/uid.mjs";import{SubjectError as l}from"./single.mjs";import{SubjectType as h}from"./types.mjs";import"./action.mjs";import"./blank-fill.mjs";import"./layout.mjs";import"./text-fill.mjs";import"./scale.mjs";import"./page-end.mjs";import"./type.mjs";var d=Object.defineProperty,c=Object.getOwnPropertyDescriptor,u=(e,t,s,i)=>{for(var r,o=i>1?void 0:i?c(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&&d(t,s,o),o};let p=class extends t{constructor(){super(...arguments),this["is-preview"]=!1,this["use-model"]=null,this._modelValueAttr="",this["upload-image"]=async e=>new Promise((t,s)=>{const i=new FileReader;i.onload=e=>t(e.target?.result),i.onerror=s,i.readAsDataURL(e)}),this["category-list"]=[],this["show-tag"]=!1,this["show-category"]=!1,this["show-ai"]=!1,this["show-resource"]=!1,this["show-jump"]=!1,this["show-add"]=!0,this["show-answer-setting"]=!1,this["show-key"]=!1,this["search-api"]="",this._list=[],this._sortMode=!1,this._sortable=null,this._initialDataProcessed=!1}get"model-value"(){return JSON.stringify(this._list)}set"model-value"(e){if(e&&e!==this._modelValueAttr){this._modelValueAttr=e;try{const t=JSON.parse(e);Array.isArray(t)&&(this._list=this._normalizeIncomingList(t),this.requestUpdate())}catch{}}}get _useModel(){return"true"===this["use-model"]||""===this["use-model"]||this.hasAttribute("use-model")}get"subject-list"(){return this.currentList}set"subject-list"(e){if(e){if("string"==typeof e)try{e=JSON.parse(e)}catch{return this._list=[],void this.requestUpdate()}if(!Array.isArray(e))return this._list=[],void this.requestUpdate();this._list=this._normalizeIncomingList(e),this.requestUpdate()}else this._list=[]}attributeChangedCallback(e,t,s){if(super.attributeChangedCallback(e,t,s),"subject-list"===e&&s&&!this._list.length){if(s.includes("[object Object]"))return;try{const e=JSON.parse(s);Array.isArray(e)&&(this._list=this._normalizeIncomingList(e),this.requestUpdate())}catch{}}}get _isPreviewValue(){const e=this["is-preview"];return"string"==typeof e?"false"!==e:!!e}connectedCallback(){super.connectedCallback(),this._initialDataProcessed||(this._initialDataProcessed=!0,Promise.resolve().then(()=>{0===this._list.length&&this._processAttributeList()}))}_processAttributeList(){const e=this.getAttribute("subject-list");if(e&&"[]"!==e&&!e.includes("[object Object]"))try{const t=JSON.parse(e);Array.isArray(t)&&t.length>0&&(this._list=this._normalizeIncomingList(t),this.requestUpdate())}catch{}}_normalizeAnswer(e){return{...e,title:String(e?.title??e?.answer??""),answerId:e?.answerId??e?.examAnswerId}}_normalizeScaleQuestionList(e){const t=Array.isArray(e?.scaleQuestionList)?e.scaleQuestionList:Array.isArray(e?.scaleQuestions)?e.scaleQuestions:Array.isArray(e?.["scale-question-list"])?e["scale-question-list"]:void 0;if(void 0!==t)return t.map(e=>String(e??"").trim()).filter(Boolean)}_normalizeItem(e){const t=this._stripBusinessFields(e),s=t?.answerType||(t?.richTextContent?t?.answerType:t?.examTypeEnum),i=Array.isArray(t?.answers)?t.answers.map(e=>this._normalizeAnswer(e)):[],r=this._normalizeScaleQuestionList(t);return{...t,customId:t?.customId||n(),...s?{answerType:s}:{},...i.length||Array.isArray(t?.answers)?{answers:i}:{},...void 0!==r?{scaleQuestionList:r}:{}}}_stripBusinessFields(e){if(!e||"object"!=typeof e)return e;const{memberTagInfo:t,tagInfos:s,categoryId:i,category:r,resourceList:o,examResourceBOList:a,aiAnswer:n,...l}=e;return l}_exportQuestionItem(e){return this._stripBusinessFields(e)}_rebuildPageEndMarkers(e){if(!e.length)return e;if(e.some(e=>"page_end"===e?.answerType))return e;if(!e.some(e=>Number(e?.pageIndex)>1))return e;let t=1;const s=[];return e.forEach(e=>{const i=Number(e?.pageIndex)||1;if(i>t)if(s.length>0)for(;t<i;)s.push({customId:n(),answerType:"page_end"}),t++;else t=i;s.push(e)}),s}_normalizeIncomingList(e){const t=e.map(e=>this._normalizeItem(e));return this._rebuildPageEndMarkers(t)}firstUpdated(){this.updateComplete.then(()=>this._initSortable())}updated(e){e.has("_sortMode")&&(this._sortable?.destroy(),this._sortable=null,this.updateComplete.then(()=>this._initSortable())),e.has("_list")&&this._sortMode&&setTimeout(()=>{this._sortable&&(this._sortable.destroy(),this._sortable=null),this._initSortable()},50)}disconnectedCallback(){super.disconnectedCallback(),this._sortable?.destroy(),this._sortable=null}_initSortable(){if(!this._sortMode)return;this.renderRoot.querySelector(".sort-list")&&(this._sortable&&(this._sortable.destroy(),this._sortable=null),requestAnimationFrame(()=>{const e=this.renderRoot.querySelector(".sort-list");e&&!this._sortable&&(this._sortable=o.create(e,{handle:".sort-handle",animation:200,ghostClass:"sort-ghost",chosenClass:"sort-chosen",onEnd:e=>{const{oldIndex:t,newIndex:s}=e;if(void 0===t||void 0===s||t===s)return;const i=[...this._list],[r]=i.splice(t,1);i.splice(s,0,r),this._list=i,this._emitListChange()}}))}))}_emit(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t??null}))}_emitListChange(){const e=this.currentList;this._emit("change",e),this._useModel&&(this._modelValueAttr=JSON.stringify(e),this._emit("list-change",e))}_withPageIndex(e){const t=[];let s=1,i=!1;return e.forEach(e=>{e&&("page_end"!==e.answerType?(i&&(s+=1,i=!1),t.push({...e,pageIndex:s})):t.length>0&&(i=!0))}),t}async toJSON(){const e=this.renderRoot.querySelectorAll("qxs-subject-single, qxs-blank-fill, qxs-text-fill, qxs-scale, qxs-page-end, qxs-subject-rich-text");if(!e||0===e.length)return[];const t=[],s=[];for(const i of e)if("function"==typeof i.toJSON)try{const e=await i.toJSON();t.push(e)}catch(e){e instanceof l?s.push(e):s.push(new l(e.message||"未知错误","UNKNOWN","unknown"))}if(s.length>0)throw s;return this._withPageIndex(t)}async validate(){const e=this.renderRoot.querySelectorAll("qxs-subject-single, qxs-blank-fill, qxs-text-fill, qxs-scale, qxs-page-end");if(!e||0===e.length)return{valid:!0,errors:[]};const t=[];for(const s of e)if("function"==typeof s.validate){const e=s.validate();e?.length&&t.push(...e)}return{valid:0===t.length,errors:t}}get currentList(){return this._list.map(e=>this._exportQuestionItem(e))}addSubject(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if("page_end"===e){const e={customId:n(),answerType:"page_end"},s=[...this._list];return"number"==typeof t&&t>=0?s.splice(t+1,0,e):s.push(e),this._list=s,this.requestUpdate(),void this._emitListChange()}const i={customId:n(),answerType:e,title:"",answers:[],analysis:"",scaleQuestionList:[],isEdit:!0,isSave:!1,isRealCanDel:!0,hasSet:!1};e===h.SCALE&&(i.answers=Array.from({length:5},()=>({title:""}))),null!==s&&(i.examAnswerRelationType=s);const r=[...this._list];"number"==typeof t&&t>=0?r.splice(t+1,0,i):r.push(i),this._list=r,this.requestUpdate(),this._emitListChange()}addExam(e){const t=this._normalizeIncomingList(e).map(e=>({...e,isEdit:!0,isSave:!1,isRealCanDel:!0,hasSet:!1}));this._list=[...this._list,...t],this._emitListChange()}uploadExcel(e){this._list=[...this._list,...this._normalizeIncomingList(e).map(e=>({...e,isRealCanDel:!0}))],this._emitListChange()}setAnswerRelation(e,t,s){const i=this._list.find(e=>e.customId===t);if(i){const t=i.answers?.find(e=>e.customAnswerId===s);t&&(t.answerRelations=e)}this.requestUpdate(),this._emitListChange()}setTagList(e,t){this.requestUpdate()}_orderIndex(e){let t=0,s=0;return this._list.forEach(i=>{t++,i.customId===e&&(s=t)}),s-1}_move(e,t){const s=[...this._list];"up"===t&&e>0?[s[e-1],s[e]]=[s[e],s[e-1]]:"down"===t&&e<s.length-1&&([s[e],s[e+1]]=[s[e+1],s[e]]),this._list=s,this._emitListChange()}_normalizeLeastAnswerCount(e,t){if(![h.MULTIPLE,h.SORT].includes(e))return;if(""===t||null==t)return null;const s=Number(t);return Number.isFinite(s)&&s>0?s:null}_normalizeSavedItem(e){const t={...this._stripBusinessFields(e)},s=this._normalizeLeastAnswerCount(t.answerType,t.leastAnswerCount);return void 0===s?delete t.leastAnswerCount:t.leastAnswerCount=s,t}_save(e,t){this._list=this._list.map((s,i)=>i===e?this._normalizeSavedItem({...s,...t.detail,isEdit:!1,isSave:!0}):s),this._emitListChange()}_deleteByCustomId(e){this._list=this._list.filter(t=>t.customId!==e),this._emitListChange()}_delete(e){const t=[...this._list];t.splice(e,1),this._list=t,this._emitListChange()}_setEdit(e,t){this._list=this._list.map((s,i)=>i===e?{...s,isEdit:t}:s)}_pageEndTotal(){return this._list.filter(e=>"page_end"===e.answerType).length+1}_pageEndIndex(e){return this._list.slice(0,e+1).filter(e=>"page_end"===e.answerType).length}_syncRelationAnswer(e,t){const s=this._list[e];if(!s||!Array.isArray(s.answers)||!t?.answer)return;const i=[...s.answers],r=t.answer;let o="number"==typeof t.answerIndex?t.answerIndex:-1;(o<0||o>=i.length)&&(o=i.findIndex((e,t)=>String(e.customAnswerId||"")===String(r.customAnswerId||"")||String(e.answerId||"")===String(r.answerId||"")||String(e.orderIndex||t+1)===String(r.orderIndex||""))),o<0||(i[o]={...i[o],customAnswerId:r.customAnswerId||i[o].customAnswerId||r.answerId},this._list[e]={...s,answers:i},this._list=[...this._list])}_renderItem(e,t){const i=this._orderIndex(e.customId),r=(e.isEdit,e.hasSet,this._isPreviewValue,e.examAnswerRelationType,e=>this._move(t,e.detail)),o=()=>this._deleteByCustomId(e.customId),a=e=>this._save(t,e),n=()=>this._setEdit(t,!0),l=e=>this.addSubject(e.detail?.type??e.detail,t);if([h.SINGLE,h.MULTIPLE,h.SORT].includes(e.answerType))return s`<qxs-subject-single
2
+ .title=${e.title||""}
3
+ .answer-list=${e.answers||[]}
5
4
  .category-list=${this["category-list"]}
6
- .resource-list=${t.examResourceBOList||t.resourceList||[]}
7
5
  .search-handler=${this["search-handler"]}
8
6
  .upload-image=${this["upload-image"]}
9
7
  order-index=${i}
10
- .is-edit=${!!t.isEdit}
11
- .is-set=${!!t.hasSet}
12
- .is-save=${!t.isRealCanDel}
8
+ .is-edit=${!!e.isEdit}
9
+ .is-set=${!!e.hasSet}
10
+ .lockAnswerKey=${!!(e.lockAnswerKey??e["lock-answer-key"])}
13
11
  .show-action=${!this._isPreviewValue}
14
12
  .show-add=${this["show-add"]}
15
- .show-answer-setting=${this["show-answer-setting"]}
16
- .show-key=${this["show-key"]}
17
- .show-tag=${this["show-tag"]}
18
13
  .show-category=${this["show-category"]}
19
14
  .show-ai=${this["show-ai"]}
20
15
  .show-resource=${this["show-resource"]}
21
16
  .show-jump=${this["show-jump"]}
22
- .is-key=${!!t.isKey}
23
- question-type=${String(t.answerType)}
24
- answer-check-type=${t.answerCheckType??1}
25
- exam-answer-relation-type=${t.examAnswerRelationType??0}
26
- rich-text-content=${t.examRichTextContent||""}
27
- analysis=${t.analysis||""}
28
- .least-answer-count=${Number(t.leastAnswerCount)||0}
29
- exam-expand=${t.examExpand||""}
30
- category-id=${t.categoryId||t.category?.categoryId||""}
31
- ai-answer=${t.aiAnswer||""}
17
+ question-type=${String(e.answerType)}
18
+ rich-text-content=${e.examRichTextContent||""}
19
+ analysis=${e.analysis||""}
20
+ .least-answer-count=${e.leastAnswerCount??null}
21
+ exam-expand=${e.examExpand||""}
32
22
  search-api=${this["search-api"]}
33
- custom-id=${t.customId||""}
34
- exam-id=${t.examId??0}
35
- @move=${a} @delete=${r} @save=${o} @edit=${n} @add=${l}
36
- @set-key=${t=>{this._list[e].isKey=t.detail.value,this.requestUpdate()}}
37
- @title-select=${t=>this._emit("title-select",t.detail)}
38
- @choose-tag=${t=>this._emit("choose-tag",{...t.detail,item:this._list[e]})}
39
- @tag-change=${t=>{this._list[e].tagInfos=t.detail.value,this._list[e].memberTagInfo=t.detail.value,this.requestUpdate()}}
40
- @category-change=${t=>{this._list[e].categoryId=t.detail.value,this.requestUpdate()}}
41
- @jump=${t=>this._emit("jump",{...t.detail,item:this._list[e]})}
42
- @set-relation=${t=>{this._syncRelationAnswer(e,t.detail),this._emit("set-relation",{...t.detail,item:this._list[e]})}}
43
- ></qxs-subject-single>`:t.answerType===h.BLANK_FILL?s`<qxs-blank-fill
44
- .title=${t.title||""}
45
- .answer-list=${t.answers||[]}
46
- .tag-list=${t.tagInfos||t.memberTagInfo||[]}
23
+ custom-id=${e.customId||""}
24
+ exam-id=${e.examId??0}
25
+ @move=${r} @delete=${o} @save=${a} @edit=${n} @add=${l}
26
+ @title-select=${e=>this._emit("title-select",e.detail)}
27
+ @jump=${e=>this._emit("jump",{...e.detail,item:this._list[t]})}
28
+ ></qxs-subject-single>`;if(e.answerType===h.BLANK_FILL)return s`<qxs-blank-fill
29
+ .title=${e.title||""}
30
+ .answer-list=${e.answers||[]}
47
31
  .category-list=${this["category-list"]}
48
- .resource-list=${t.examResourceBOList||t.resourceList||[]}
49
- .exam-answer-setting=${t.examAnswerSettingBO||t.examAnswerSettingVO||{}}
32
+ .exam-answer-setting=${e.examAnswerSettingBO||e.examAnswerSettingVO||{}}
50
33
  .upload-image=${this["upload-image"]}
51
34
  order-index=${i}
52
- .is-edit=${!!t.isEdit} .is-set=${!!t.hasSet} .is-save=${!t.isRealCanDel} .show-action=${!this._isPreviewValue} .show-add=${this["show-add"]}
35
+ .is-edit=${!!e.isEdit} .is-set=${!!e.hasSet} .show-action=${!this._isPreviewValue} .show-add=${this["show-add"]}
53
36
  .show-answer-setting=${this["show-answer-setting"]}
54
- .show-tag=${this["show-tag"]}
55
37
  .show-category=${this["show-category"]}
56
38
  .show-resource=${this["show-resource"]}
57
- exam-answer-relation-type=${t.examAnswerRelationType??0}
58
- exam-expand=${t.examExpand||""}
59
- rich-text-content=${t.examRichTextContent||""}
60
- analysis=${t.analysis||""}
61
- category-id=${t.categoryId||t.category?.categoryId||""}
62
- custom-id=${t.customId||""}
63
- exam-id=${t.examId??0}
64
- @move=${a} @delete=${r} @save=${o} @edit=${n} @add=${l}
65
- @choose-tag=${t=>this._emit("choose-tag",{...t.detail,item:this._list[e]})}
66
- @tag-change=${t=>{this._list[e].tagInfos=t.detail.value,this._list[e].memberTagInfo=t.detail.value,this.requestUpdate()}}
67
- @category-change=${t=>{this._list[e].categoryId=t.detail.value,this.requestUpdate()}}
68
- ></qxs-blank-fill>`:t.answerType===h.TEXT_FILL?s`<qxs-text-fill
69
- .title=${t.title||""}
70
- .answer-list=${t.answers||[]}
71
- .tag-list=${t.tagInfos||t.memberTagInfo||[]}
39
+ exam-answer-relation-type=${e.examAnswerRelationType??0}
40
+ exam-expand=${e.examExpand||""}
41
+ rich-text-content=${e.examRichTextContent||""}
42
+ analysis=${e.analysis||""}
43
+ custom-id=${e.customId||""}
44
+ exam-id=${e.examId??0}
45
+ @move=${r} @delete=${o} @save=${a} @edit=${n} @add=${l}
46
+ ></qxs-blank-fill>`;if(e.answerType===h.TEXT_FILL)return s`<qxs-text-fill
47
+ .title=${e.title||""}
48
+ .answer-list=${e.answers||[]}
72
49
  .category-list=${this["category-list"]}
73
- .resource-list=${t.examResourceBOList||t.resourceList||[]}
74
50
  .search-handler=${this["search-handler"]}
75
- .exam-answer-setting=${t.examAnswerSettingBO||t.examAnswerSettingVO||{}}
51
+ .exam-answer-setting=${e.examAnswerSettingBO||e.examAnswerSettingVO||{}}
76
52
  .upload-image=${this["upload-image"]}
77
53
  order-index=${i}
78
- .is-edit=${!!t.isEdit} .is-set=${!!t.hasSet} .is-save=${!t.isRealCanDel} .show-action=${!this._isPreviewValue} .show-add=${this["show-add"]}
54
+ .is-edit=${!!e.isEdit} .is-set=${!!e.hasSet} .show-action=${!this._isPreviewValue} .show-add=${this["show-add"]}
79
55
  .show-answer-setting=${this["show-answer-setting"]}
80
- .show-tag=${this["show-tag"]}
81
56
  .show-category=${this["show-category"]}
82
57
  .show-resource=${this["show-resource"]}
83
- exam-answer-relation-type=${t.examAnswerRelationType??0}
84
- exam-expand=${t.examExpand||""}
85
- rich-text-content=${t.examRichTextContent||""}
86
- analysis=${t.analysis||""}
87
- category-id=${t.categoryId||t.category?.categoryId||""}
88
- custom-id=${t.customId||""}
89
- exam-id=${t.examId??0}
90
- @move=${a} @delete=${r} @save=${o} @edit=${n} @add=${l}
91
- @choose-tag=${t=>this._emit("choose-tag",{...t.detail,item:this._list[e]})}
92
- @tag-change=${t=>{this._list[e].tagInfos=t.detail.value,this._list[e].memberTagInfo=t.detail.value,this.requestUpdate()}}
93
- @category-change=${t=>{this._list[e].categoryId=t.detail.value,this.requestUpdate()}}
94
- ></qxs-text-fill>`:t.answerType===h.SCALE?s`<qxs-scale
95
- .title=${t.title||""}
96
- .answer-list=${t.answers||[]}
97
- .scale-questions=${t.scaleQuestionList||[]}
98
- .tag-list=${t.tagInfos||t.memberTagInfo||[]}
99
- .category-list=${this["category-list"]}
100
- .resource-list=${t.examResourceBOList||t.resourceList||[]}
58
+ exam-answer-relation-type=${e.examAnswerRelationType??0}
59
+ exam-expand=${e.examExpand||""}
60
+ rich-text-content=${e.examRichTextContent||""}
61
+ analysis=${e.analysis||""}
62
+ custom-id=${e.customId||""}
63
+ exam-id=${e.examId??0}
64
+ @move=${r} @delete=${o} @save=${a} @edit=${n} @add=${l}
65
+ ></qxs-text-fill>`;if(e.answerType===h.SCALE){const t=Array.isArray(e.scaleQuestionList)?e.scaleQuestionList:Array.isArray(e.scaleQuestions)?e.scaleQuestions:[];return s`<qxs-scale
66
+ .title=${e.title||""}
67
+ .answer-list=${e.answers||[]}
68
+ .scale-question-list=${t}
101
69
  .upload-image=${this["upload-image"]}
102
70
  order-index=${i}
103
- .is-edit=${!!t.isEdit} .is-set=${!!t.hasSet} .is-save=${!t.isRealCanDel} .show-action=${!this._isPreviewValue} .show-add=${this["show-add"]}
104
- .show-tag=${this["show-tag"]}
105
- .show-category=${this["show-category"]}
106
- .show-resource=${this["show-resource"]}
107
- exam-answer-relation-type=${t.examAnswerRelationType??0}
108
- rich-text-content=${t.examRichTextContent||""}
109
- analysis=${t.analysis||""}
110
- category-id=${t.categoryId||t.category?.categoryId||""}
111
- custom-id=${t.customId||""}
112
- exam-id=${t.examId??0}
113
- @move=${a} @delete=${r} @save=${o} @edit=${n} @add=${l}
114
- @choose-tag=${t=>this._emit("choose-tag",{...t.detail,item:this._list[e]})}
115
- @tag-change=${t=>{this._list[e].tagInfos=t.detail.value,this._list[e].memberTagInfo=t.detail.value,this.requestUpdate()}}
116
- @category-change=${t=>{this._list[e].categoryId=t.detail.value,this.requestUpdate()}}
117
- ></qxs-scale>`:"page_end"===t.answerType?s`<qxs-page-end
118
- .current-page-index=${t.currentPageIndex||this._pageEndIndex(e)}
119
- .total-page=${t.totalPage||this._pageEndTotal()}
71
+ .is-edit=${!!e.isEdit} .is-set=${!!e.hasSet} .show-action=${!this._isPreviewValue} .show-add=${this["show-add"]}
72
+ rich-text-content=${e.examRichTextContent||""}
73
+ custom-id=${e.customId||""}
74
+ @move=${r} @delete=${o} @save=${a} @edit=${n} @add=${l}
75
+ ></qxs-scale>`}return"page_end"===e.answerType?s`<qxs-page-end
76
+ .current-page-index=${e.currentPageIndex||this._pageEndIndex(t)}
77
+ .total-page=${e.totalPage||this._pageEndTotal()}
120
78
  .show-action=${!this._isPreviewValue}
121
79
  .show-add=${this["show-add"]}
122
- custom-id=${t.customId||""}
123
- @delete=${r}
80
+ custom-id=${e.customId||""}
81
+ @delete=${o}
124
82
  @add=${l}
125
- ></qxs-page-end>`:s`<div style="color:#909399;padding:8px">未知题型: ${t.answerType}</div>`}render(){return s`
83
+ ></qxs-page-end>`:s`<div style="color:#909399;padding:8px">未知题型: ${e.answerType}</div>`}render(){return s`
126
84
  <div class="subject-list">
127
- ${this._list.map((t,e)=>this._renderItem(t,e))}
85
+ ${this._list.map((e,t)=>this._renderItem(e,t))}
128
86
  </div>
129
- `}};u.styles=t`
87
+ `}};p.styles=e`
130
88
  :host { display: block; font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 13px; }
131
89
  *, ::before, ::after { box-sizing: border-box; }
132
90
  .sort-mode-toggle { display: flex; justify-content: flex-end; margin-bottom: 12px; }
@@ -148,5 +106,5 @@ import{css as t,LitElement as e,html as s}from"lit";import{property as i,state a
148
106
  .sort-index { font-size: 13px; color: #606266; font-weight: 500; margin-right: 8px; min-width: 24px; flex-shrink: 0; }
149
107
  .sort-title { flex: 1; font-size: 14px; color: #303133; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
150
108
  .sort-type { font-size: 12px; color: #909399; margin-left: 12px; padding: 2px 8px; background: #f0f0f0; border-radius: 4px; flex-shrink: 0; }
151
- `,p([i({attribute:"is-preview"})],u.prototype,"is-preview",2),p([i({attribute:"use-model"})],u.prototype,"use-model",2),p([i({attribute:"model-value"})],u.prototype,"model-value",1),p([i({type:Object,attribute:"upload-image"})],u.prototype,"upload-image",2),p([i({type:Array,attribute:"category-list"})],u.prototype,"category-list",2),p([i({type:Boolean,attribute:"show-tag"})],u.prototype,"show-tag",2),p([i({type:Boolean,attribute:"show-category"})],u.prototype,"show-category",2),p([i({type:Boolean,attribute:"show-ai"})],u.prototype,"show-ai",2),p([i({type:Boolean,attribute:"show-resource"})],u.prototype,"show-resource",2),p([i({type:Boolean,attribute:"show-jump"})],u.prototype,"show-jump",2),p([i({type:Boolean,attribute:"show-add"})],u.prototype,"show-add",2),p([i({type:Boolean,attribute:"show-answer-setting"})],u.prototype,"show-answer-setting",2),p([i({type:Boolean,attribute:"show-key"})],u.prototype,"show-key",2),p([i({type:String,attribute:"search-api"})],u.prototype,"search-api",2),p([i({type:Object,attribute:"search-handler"})],u.prototype,"search-handler",2),p([i({type:Array,attribute:"subject-list"})],u.prototype,"subject-list",1),p([a()],u.prototype,"_list",2),p([a()],u.prototype,"_sortMode",2),u=p([o("qxs-subject-list")],u);export{u as QxsSubjectList};
109
+ `,u([i({attribute:"is-preview"})],p.prototype,"is-preview",2),u([i({attribute:"use-model"})],p.prototype,"use-model",2),u([i({attribute:"model-value"})],p.prototype,"model-value",1),u([i({type:Object,attribute:"upload-image"})],p.prototype,"upload-image",2),u([i({type:Array,attribute:"category-list"})],p.prototype,"category-list",2),u([i({type:Boolean,attribute:"show-tag"})],p.prototype,"show-tag",2),u([i({type:Boolean,attribute:"show-category"})],p.prototype,"show-category",2),u([i({type:Boolean,attribute:"show-ai"})],p.prototype,"show-ai",2),u([i({type:Boolean,attribute:"show-resource"})],p.prototype,"show-resource",2),u([i({type:Boolean,attribute:"show-jump"})],p.prototype,"show-jump",2),u([i({type:Boolean,attribute:"show-add"})],p.prototype,"show-add",2),u([i({type:Boolean,attribute:"show-answer-setting"})],p.prototype,"show-answer-setting",2),u([i({type:Boolean,attribute:"show-key"})],p.prototype,"show-key",2),u([i({type:String,attribute:"search-api"})],p.prototype,"search-api",2),u([i({type:Object,attribute:"search-handler"})],p.prototype,"search-handler",2),u([i({type:Array,attribute:"subject-list"})],p.prototype,"subject-list",1),u([r()],p.prototype,"_list",2),u([r()],p.prototype,"_sortMode",2),p=u([a("qxs-subject-list")],p);export{p as QxsSubjectList};
152
110
  //# sourceMappingURL=list.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"list.mjs","sources":["../../../../packages/components-wc/src/subject/list.ts"],"sourcesContent":["import { css, html, LitElement } from 'lit'\nimport { property, state } from 'lit/decorators.js'\nimport Sortable from 'sortablejs'\nimport { safeCustomElement } from '../base/define'\nimport { uid } from '../base/uid'\nimport { SubjectError } from './single'\nimport { SubjectType } from './types'\n\n// 导入子组件以确保它们被注册为 Custom Elements\nimport './action'\nimport './blank-fill'\nimport './layout'\nimport './text-fill'\nimport './scale'\nimport './page-end'\nimport './type'\n\n@safeCustomElement('qxs-subject-list')\nexport class QxsSubjectList extends LitElement {\n static styles = css`\n :host { display: block; font-family: system-ui, -apple-system, \"PingFang SC\", \"Microsoft YaHei\", sans-serif; font-size: 13px; }\n *, ::before, ::after { box-sizing: border-box; }\n .sort-mode-toggle { display: flex; justify-content: flex-end; margin-bottom: 12px; }\n .btn { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 12px; font-size: 12px; border: 1px solid #dcdfe6; border-radius: 3px; background: #fff; color: #606266; cursor: pointer; transition: all 0.2s; }\n .btn:hover { color: #3D61E3; border-color: #3D61E3; background: #ecf5ff; }\n .btn.primary { background: #3D61E3; border-color: #3D61E3; color: #fff; }\n .btn.primary:hover { background: #3D61E3; border-color: #3D61E3; }\n .subject-list { display: flex; flex-direction: column; }\n .subject-content { flex: 1; min-width: 0; }\n .ghost { opacity: 0.5; background: #ecf5ff; }\n .chosen { box-shadow: 0 4px 16px rgba(64,158,255,.3); }\n .sort-list { display: flex; flex-direction: column; gap: 8px; }\n .sort-item { display: flex; align-items: center; padding: 12px 16px; background: #f8f9fa; border: 1px solid #e4e7ed; border-radius: 6px; cursor: grab; transition: all 0.3s ease; }\n .sort-item:hover { background: #ecf5ff; border-color: #c6e2ff; }\n .sort-item:active { cursor: grabbing; }\n .sort-item.sort-ghost { opacity: 0.5; background: #ecf5ff; border: 2px dashed #409eff; }\n .sort-item.sort-chosen { background: #ecf5ff; border-color: #409eff; box-shadow: 0 4px 16px rgba(64,158,255,.3); transform: scale(1.02); }\n .sort-handle { display: flex; align-items: center; justify-content: center; width: 20px; height: 20px; margin-right: 12px; color: #909399; flex-shrink: 0; }\n .sort-index { font-size: 13px; color: #606266; font-weight: 500; margin-right: 8px; min-width: 24px; flex-shrink: 0; }\n .sort-title { flex: 1; font-size: 14px; color: #303133; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n .sort-type { font-size: 12px; color: #909399; margin-left: 12px; padding: 2px 8px; background: #f0f0f0; border-radius: 4px; flex-shrink: 0; }\n `\n\n @property({ attribute: 'is-preview' }) 'is-preview' = false\n\n // use-model: enables two-way binding via model-value attribute + list-change event\n @property({ attribute: 'use-model' }) 'use-model': string | null = null\n @property({ attribute: 'model-value' })\n get 'model-value'(): string { return JSON.stringify(this._list) }\n\n set 'model-value'(v: string) {\n if (!v || v === this._modelValueAttr) { return }\n this._modelValueAttr = v\n try {\n const parsed = JSON.parse(v)\n if (Array.isArray(parsed)) {\n this._list = this._normalizeIncomingList(parsed)\n this.requestUpdate()\n }\n }\n catch { /* invalid JSON, ignore */ }\n }\n\n private get _useModel(): boolean {\n return this['use-model'] === 'true' || this['use-model'] === '' || this.hasAttribute('use-model')\n }\n\n private _modelValueAttr = ''\n\n @property({ type: Object, attribute: 'upload-image' })\n 'upload-image': (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\n @property({ type: Array, attribute: 'category-list' }) 'category-list': any[] = []\n @property({ type: Boolean, attribute: 'show-tag' }) 'show-tag' = false\n @property({ type: Boolean, attribute: 'show-category' }) 'show-category' = false\n @property({ type: Boolean, attribute: 'show-ai' }) 'show-ai' = false\n @property({ type: Boolean, attribute: 'show-resource' }) 'show-resource' = false\n @property({ type: Boolean, attribute: 'show-jump' }) 'show-jump' = false\n @property({ type: Boolean, attribute: 'show-add' }) 'show-add' = true\n @property({ type: Boolean, attribute: 'show-answer-setting' }) 'show-answer-setting' = false\n @property({ type: Boolean, attribute: 'show-key' }) 'show-key' = false\n @property({ type: String, attribute: 'search-api' }) 'search-api' = ''\n @property({ type: Object, attribute: 'search-handler' }) 'search-handler'?: (query: string, answerType: number) => Promise<any[]>\n\n @property({ type: Array, attribute: 'subject-list' })\n get 'subject-list'() { return this._list }\n\n set 'subject-list'(v: any) {\n if (!v) {\n this._list = []\n return\n }\n if (typeof v === 'string') {\n try {\n v = JSON.parse(v)\n }\n catch {\n this._list = []\n this.requestUpdate()\n return\n }\n }\n if (!Array.isArray(v)) {\n this._list = []\n this.requestUpdate()\n return\n }\n this._list = this._normalizeIncomingList(v)\n this.requestUpdate()\n }\n\n attributeChangedCallback(name: string, oldVal: string | null, newVal: string | null) {\n super.attributeChangedCallback(name, oldVal, newVal)\n if (name === 'subject-list' && newVal && !this._list.length) {\n if (newVal.includes('[object Object]')) {\n return\n }\n try {\n const parsed = JSON.parse(newVal)\n if (Array.isArray(parsed)) {\n this._list = this._normalizeIncomingList(parsed)\n this.requestUpdate()\n }\n }\n catch {\n // Not valid JSON, ignore\n }\n }\n }\n\n @state() private _list: any[] = []\n @state() private _sortMode = false\n private _sortable: Sortable | null = null\n\n private get _isPreviewValue(): boolean {\n const val = this['is-preview']\n return typeof val === 'string' ? val !== 'false' : !!val\n }\n\n private _initialDataProcessed = false\n\n connectedCallback() {\n super.connectedCallback()\n if (!this._initialDataProcessed) {\n this._initialDataProcessed = true\n Promise.resolve().then(() => {\n if (this._list.length === 0) {\n this._processAttributeList()\n }\n })\n }\n }\n\n private _processAttributeList() {\n const attr = this.getAttribute('subject-list')\n if (!attr || attr === '[]') { return }\n if (attr.includes('[object Object]')) {\n return\n }\n try {\n const parsed = JSON.parse(attr)\n if (Array.isArray(parsed) && parsed.length > 0) {\n this._list = this._normalizeIncomingList(parsed)\n this.requestUpdate()\n }\n }\n catch {\n // Not valid JSON, ignore\n }\n }\n\n private _normalizeAnswer(answer: any) {\n return {\n ...answer,\n title: String(answer?.title ?? answer?.answer ?? ''),\n answerId: answer?.answerId ?? answer?.examAnswerId,\n }\n }\n\n private _normalizeItem(item: any) {\n const answerType = item?.answerType || (!item?.richTextContent ? item?.examTypeEnum : item?.answerType)\n const answers = Array.isArray(item?.answers) ? item.answers.map((answer: any) => this._normalizeAnswer(answer)) : []\n return {\n ...item,\n customId: item?.customId || uid(),\n ...(answerType ? { answerType } : {}),\n ...(answers.length || Array.isArray(item?.answers) ? { answers } : {}),\n }\n }\n\n private _rebuildPageEndMarkers(items: any[]) {\n if (!items.length) { return items }\n if (items.some(item => item?.answerType === 'page_end')) { return items }\n if (!items.some(item => Number(item?.pageIndex) > 1)) { return items }\n\n let currentPageIndex = 1\n const rebuilt: any[] = []\n\n items.forEach((item) => {\n const pageIndex = Number(item?.pageIndex) || 1\n if (pageIndex > currentPageIndex) {\n if (rebuilt.length > 0) {\n while (currentPageIndex < pageIndex) {\n rebuilt.push({ customId: uid(), answerType: 'page_end' })\n currentPageIndex++\n }\n }\n else {\n currentPageIndex = pageIndex\n }\n }\n rebuilt.push(item)\n })\n\n return rebuilt\n }\n\n private _normalizeIncomingList(items: any[]) {\n const normalized = items.map((item: any) => this._normalizeItem(item))\n return this._rebuildPageEndMarkers(normalized)\n }\n\n firstUpdated() {\n this.updateComplete.then(() => this._initSortable())\n }\n\n updated(changed: Map<string, unknown>) {\n if (changed.has('_sortMode')) {\n this._sortable?.destroy()\n this._sortable = null\n this.updateComplete.then(() => this._initSortable())\n }\n // Reinitialize Sortable when list changes in sort mode\n if (changed.has('_list') && this._sortMode) {\n // Small delay to let Lit finish DOM updates\n setTimeout(() => {\n if (this._sortable) {\n this._sortable.destroy()\n this._sortable = null\n }\n this._initSortable()\n }, 50)\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback()\n this._sortable?.destroy()\n this._sortable = null\n }\n\n private _initSortable() {\n if (!this._sortMode) { return }\n const el = this.renderRoot.querySelector<HTMLElement>('.sort-list')\n if (!el) { return }\n\n // Destroy existing instance first\n if (this._sortable) {\n this._sortable.destroy()\n this._sortable = null\n }\n\n // Small delay to ensure DOM is ready after previous destroy\n requestAnimationFrame(() => {\n const currentEl = this.renderRoot.querySelector<HTMLElement>('.sort-list')\n if (!currentEl || this._sortable) { return }\n\n this._sortable = Sortable.create(currentEl, {\n handle: '.sort-handle',\n animation: 200,\n ghostClass: 'sort-ghost',\n chosenClass: 'sort-chosen',\n onEnd: (evt) => {\n const { oldIndex, newIndex } = evt\n if (oldIndex === undefined || newIndex === undefined || oldIndex === newIndex) { return }\n const arr = [...this._list]\n const [item] = arr.splice(oldIndex, 1)\n arr.splice(newIndex, 0, item)\n this._list = arr\n this._emitListChange()\n },\n })\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 _emitListChange() {\n this._emit('change', this._list)\n if (this._useModel) {\n this._modelValueAttr = JSON.stringify(this._list)\n this._emit('list-change', this._list)\n }\n }\n\n private _withPageIndex(items: any[]) {\n const serialized: any[] = []\n let pageIndex = 1\n let pendingBoundary = false\n\n items.forEach((item) => {\n if (!item) { return }\n if (item.answerType === 'page_end') {\n if (serialized.length > 0) {\n pendingBoundary = true\n }\n return\n }\n if (pendingBoundary) {\n pageIndex += 1\n pendingBoundary = false\n }\n serialized.push({\n ...item,\n pageIndex,\n })\n })\n\n return serialized\n }\n\n async toJSON(): Promise<any[]> {\n const subjectEls = this.renderRoot.querySelectorAll<any>(\n 'qxs-subject-single, qxs-blank-fill, qxs-text-fill, qxs-scale, qxs-page-end, qxs-subject-rich-text',\n )\n if (!subjectEls || subjectEls.length === 0) {\n return []\n }\n\n const results: any[] = []\n const errors: SubjectError[] = []\n\n for (const el of subjectEls) {\n if (typeof el.toJSON === 'function') {\n try {\n const data = await el.toJSON()\n results.push(data)\n }\n catch (err: any) {\n if (err instanceof SubjectError) {\n errors.push(err)\n }\n else {\n errors.push(new SubjectError(err.message || '未知错误', 'UNKNOWN', 'unknown'))\n }\n }\n }\n }\n\n if (errors.length > 0) {\n throw errors\n }\n\n return this._withPageIndex(results)\n }\n\n async validate(): Promise<{ valid: boolean, errors: SubjectError[] }> {\n const subjectEls = this.renderRoot.querySelectorAll<any>(\n 'qxs-subject-single, qxs-blank-fill, qxs-text-fill, qxs-scale, qxs-page-end',\n )\n if (!subjectEls || subjectEls.length === 0) {\n return { valid: true, errors: [] }\n }\n\n const errors: SubjectError[] = []\n\n for (const el of subjectEls) {\n if (typeof el.validate === 'function') {\n const errs = el.validate()\n if (errs?.length) {\n errors.push(...errs)\n }\n }\n }\n\n return {\n valid: errors.length === 0,\n errors,\n }\n }\n\n // ── public API ────────────────────────────────────────────────\n get currentList() { return this._list }\n\n addSubject(type: string, index?: number, examAnswerRelationType: number | null = null) {\n // 分页符只需要最少的必要字段\n if (type === 'page_end') {\n const pageEndItem = {\n customId: uid(),\n answerType: 'page_end',\n }\n const arr = [...this._list]\n if (typeof index === 'number' && index >= 0) {\n arr.splice(index + 1, 0, pageEndItem)\n }\n else {\n arr.push(pageEndItem)\n }\n this._list = arr\n this.requestUpdate()\n this._emitListChange()\n return\n }\n\n const item = {\n customId: uid(), answerType: type, title: '',\n answers: [], analysis: '', scaleQuestionList: [],\n isEdit: true, isSave: false, isRealCanDel: true, hasSet: false,\n isKey: false, answerCheckType: 1,\n examAnswerRelationType: examAnswerRelationType ?? 0,\n }\n const arr = [...this._list]\n if (typeof index === 'number' && index >= 0) {\n arr.splice(index + 1, 0, item)\n }\n else { arr.push(item) }\n this._list = arr\n this.requestUpdate()\n this._emitListChange()\n }\n\n addExam(items: any[]) {\n const newItems = this._normalizeIncomingList(items).map((item: any) => ({\n ...item,\n isEdit: true,\n isSave: false,\n isRealCanDel: true,\n hasSet: false,\n }))\n this._list = [...this._list, ...newItems]\n this._emitListChange()\n }\n\n uploadExcel(list: any[]) {\n this._list = [\n ...this._list,\n ...this._normalizeIncomingList(list).map((item: any) => ({ ...item, isRealCanDel: true })),\n ]\n this._emitListChange()\n }\n\n setAnswerRelation(answerRelations: any, customId: string, customAnswerId: string) {\n const item = this._list.find((v: any) => v.customId === customId)\n if (item) {\n const ans = item.answers?.find((c: any) => c.customAnswerId === customAnswerId)\n if (ans) { ans.answerRelations = answerRelations }\n }\n this.requestUpdate()\n this._emitListChange()\n }\n\n setTagList(tagList: any[], customId: string) {\n const item = this._list.find((v: any) => v.customId === customId)\n if (item) {\n item.tagInfos = Array.isArray(tagList) ? tagList : []\n item.memberTagInfo = Array.isArray(tagList) ? tagList : []\n this._list = [...this._list]\n this._emitListChange()\n return\n }\n this.requestUpdate()\n }\n\n // ── private helpers ───────────────────────────────────────────\n private _orderIndex(customId: string) {\n let n = 0; let out = 0\n this._list.forEach((v: any) => {\n n++; if (v.customId === customId) { out = n }\n })\n return out - 1\n }\n\n private _move(index: number, dir: 'up' | 'down') {\n const arr = [...this._list]\n if (dir === 'up' && index > 0) { [arr[index - 1], arr[index]] = [arr[index], arr[index - 1]] }\n else if (dir === 'down' && index < arr.length - 1) { [arr[index], arr[index + 1]] = [arr[index + 1], arr[index]] }\n this._list = arr\n this._emitListChange()\n }\n\n private _save(index: number, e: CustomEvent) {\n this._list = this._list.map((item, i) =>\n i === index ? { ...item, ...e.detail, isEdit: false, isSave: true } : item,\n )\n this._emitListChange()\n }\n\n private _deleteByCustomId(customId: string) {\n this._list = this._list.filter(item => item.customId !== customId)\n this._emitListChange()\n }\n\n private _delete(index: number) {\n const arr = [...this._list]\n arr.splice(index, 1)\n this._list = arr\n this._emitListChange()\n }\n\n private _setEdit(index: number, val: boolean) {\n this._list = this._list.map((item, i) => i === index ? { ...item, isEdit: val } : item)\n }\n\n private _pageEndTotal() {\n return this._list.filter(item => item.answerType === 'page_end').length + 1\n }\n\n private _pageEndIndex(index: number) {\n return this._list.slice(0, index + 1).filter(item => item.answerType === 'page_end').length\n }\n\n private _syncRelationAnswer(index: number, detail: any) {\n const item = this._list[index]\n if (!item || !Array.isArray(item.answers) || !detail?.answer) { return }\n const answers = [...item.answers]\n const currentAnswer = detail.answer\n let answerIndex = typeof detail.answerIndex === 'number' ? detail.answerIndex : -1\n\n if (answerIndex < 0 || answerIndex >= answers.length) {\n answerIndex = answers.findIndex((answer: any, currentIndex: number) => {\n return String(answer.customAnswerId || '') === String(currentAnswer.customAnswerId || '')\n || String(answer.answerId || '') === String(currentAnswer.answerId || '')\n || String(answer.orderIndex || currentIndex + 1) === String(currentAnswer.orderIndex || '')\n })\n }\n\n if (answerIndex < 0) { return }\n answers[answerIndex] = {\n ...answers[answerIndex],\n customAnswerId: currentAnswer.customAnswerId || answers[answerIndex].customAnswerId || currentAnswer.answerId,\n }\n this._list[index] = {\n ...item,\n answers,\n }\n this._list = [...this._list]\n }\n\n private _renderItem(item: any, index: number) {\n const common = {\n 'order-index': this._orderIndex(item.customId),\n '?is-edit': item.isEdit || false,\n '?is-set': item.hasSet || false,\n '?is-save': !item.isRealCanDel,\n '?show-action': !this._isPreviewValue,\n 'exam-answer-relation-type': item.examAnswerRelationType ?? 0,\n }\n const onMove = (e: CustomEvent) => this._move(index, e.detail as 'up' | 'down')\n const onDelete = () => this._deleteByCustomId(item.customId)\n const onSave = (e: CustomEvent) => this._save(index, e)\n const onEdit = () => this._setEdit(index, true)\n const onAdd = (e: CustomEvent) => this.addSubject(e.detail?.type ?? e.detail, index)\n\n if ([SubjectType.SINGLE, SubjectType.MULTIPLE, SubjectType.SORT].includes(item.answerType)) {\n return html`<qxs-subject-single\n .title=${item.title || ''}\n .answer-list=${item.answers || []}\n .tag-list=${item.tagInfos || item.memberTagInfo || []}\n .category-list=${this['category-list']}\n .resource-list=${item.examResourceBOList || item.resourceList || []}\n .search-handler=${this['search-handler']}\n .upload-image=${this['upload-image']}\n order-index=${common['order-index']}\n .is-edit=${!!item.isEdit}\n .is-set=${!!item.hasSet}\n .is-save=${!item.isRealCanDel}\n .show-action=${!this._isPreviewValue}\n .show-add=${this['show-add']}\n .show-answer-setting=${this['show-answer-setting']}\n .show-key=${this['show-key']}\n .show-tag=${this['show-tag']}\n .show-category=${this['show-category']}\n .show-ai=${this['show-ai']}\n .show-resource=${this['show-resource']}\n .show-jump=${this['show-jump']}\n .is-key=${!!item.isKey}\n question-type=${String(item.answerType)}\n answer-check-type=${item.answerCheckType ?? 1}\n exam-answer-relation-type=${item.examAnswerRelationType ?? 0}\n rich-text-content=${item.examRichTextContent || ''}\n analysis=${item.analysis || ''}\n .least-answer-count=${Number(item.leastAnswerCount) || 0}\n exam-expand=${item.examExpand || ''}\n category-id=${item.categoryId || item.category?.categoryId || ''}\n ai-answer=${item.aiAnswer || ''}\n search-api=${this['search-api']}\n custom-id=${item.customId || ''}\n exam-id=${item.examId ?? 0}\n @move=${onMove} @delete=${onDelete} @save=${onSave} @edit=${onEdit} @add=${onAdd}\n @set-key=${(e: CustomEvent) => {\n this._list[index].isKey = e.detail.value\n this.requestUpdate()\n }}\n @title-select=${(e: CustomEvent) => this._emit('title-select', e.detail)}\n @choose-tag=${(e: CustomEvent) => this._emit('choose-tag', { ...e.detail, item: this._list[index] })}\n @tag-change=${(e: CustomEvent) => {\n this._list[index].tagInfos = e.detail.value\n this._list[index].memberTagInfo = e.detail.value\n this.requestUpdate()\n }}\n @category-change=${(e: CustomEvent) => {\n this._list[index].categoryId = e.detail.value\n this.requestUpdate()\n }}\n @jump=${(e: CustomEvent) => this._emit('jump', { ...e.detail, item: this._list[index] })}\n @set-relation=${(e: CustomEvent) => {\n this._syncRelationAnswer(index, e.detail)\n this._emit('set-relation', { ...e.detail, item: this._list[index] })\n }}\n ></qxs-subject-single>`\n }\n if (item.answerType === SubjectType.BLANK_FILL) {\n return html`<qxs-blank-fill\n .title=${item.title || ''}\n .answer-list=${item.answers || []}\n .tag-list=${item.tagInfos || item.memberTagInfo || []}\n .category-list=${this['category-list']}\n .resource-list=${item.examResourceBOList || item.resourceList || []}\n .exam-answer-setting=${item.examAnswerSettingBO || item.examAnswerSettingVO || {}}\n .upload-image=${this['upload-image']}\n order-index=${common['order-index']}\n .is-edit=${!!item.isEdit} .is-set=${!!item.hasSet} .is-save=${!item.isRealCanDel} .show-action=${!this._isPreviewValue} .show-add=${this['show-add']}\n .show-answer-setting=${this['show-answer-setting']}\n .show-tag=${this['show-tag']}\n .show-category=${this['show-category']}\n .show-resource=${this['show-resource']}\n exam-answer-relation-type=${item.examAnswerRelationType ?? 0}\n exam-expand=${item.examExpand || ''}\n rich-text-content=${item.examRichTextContent || ''}\n analysis=${item.analysis || ''}\n category-id=${item.categoryId || item.category?.categoryId || ''}\n custom-id=${item.customId || ''}\n exam-id=${item.examId ?? 0}\n @move=${onMove} @delete=${onDelete} @save=${onSave} @edit=${onEdit} @add=${onAdd}\n @choose-tag=${(e: CustomEvent) => this._emit('choose-tag', { ...e.detail, item: this._list[index] })}\n @tag-change=${(e: CustomEvent) => {\n this._list[index].tagInfos = e.detail.value\n this._list[index].memberTagInfo = e.detail.value\n this.requestUpdate()\n }}\n @category-change=${(e: CustomEvent) => {\n this._list[index].categoryId = e.detail.value\n this.requestUpdate()\n }}\n ></qxs-blank-fill>`\n }\n if (item.answerType === SubjectType.TEXT_FILL) {\n return html`<qxs-text-fill\n .title=${item.title || ''}\n .answer-list=${item.answers || []}\n .tag-list=${item.tagInfos || item.memberTagInfo || []}\n .category-list=${this['category-list']}\n .resource-list=${item.examResourceBOList || item.resourceList || []}\n .search-handler=${this['search-handler']}\n .exam-answer-setting=${item.examAnswerSettingBO || item.examAnswerSettingVO || {}}\n .upload-image=${this['upload-image']}\n order-index=${common['order-index']}\n .is-edit=${!!item.isEdit} .is-set=${!!item.hasSet} .is-save=${!item.isRealCanDel} .show-action=${!this._isPreviewValue} .show-add=${this['show-add']}\n .show-answer-setting=${this['show-answer-setting']}\n .show-tag=${this['show-tag']}\n .show-category=${this['show-category']}\n .show-resource=${this['show-resource']}\n exam-answer-relation-type=${item.examAnswerRelationType ?? 0}\n exam-expand=${item.examExpand || ''}\n rich-text-content=${item.examRichTextContent || ''}\n analysis=${item.analysis || ''}\n category-id=${item.categoryId || item.category?.categoryId || ''}\n custom-id=${item.customId || ''}\n exam-id=${item.examId ?? 0}\n @move=${onMove} @delete=${onDelete} @save=${onSave} @edit=${onEdit} @add=${onAdd}\n @choose-tag=${(e: CustomEvent) => this._emit('choose-tag', { ...e.detail, item: this._list[index] })}\n @tag-change=${(e: CustomEvent) => {\n this._list[index].tagInfos = e.detail.value\n this._list[index].memberTagInfo = e.detail.value\n this.requestUpdate()\n }}\n @category-change=${(e: CustomEvent) => {\n this._list[index].categoryId = e.detail.value\n this.requestUpdate()\n }}\n ></qxs-text-fill>`\n }\n if (item.answerType === SubjectType.SCALE) {\n return html`<qxs-scale\n .title=${item.title || ''}\n .answer-list=${item.answers || []}\n .scale-questions=${item.scaleQuestionList || []}\n .tag-list=${item.tagInfos || item.memberTagInfo || []}\n .category-list=${this['category-list']}\n .resource-list=${item.examResourceBOList || item.resourceList || []}\n .upload-image=${this['upload-image']}\n order-index=${common['order-index']}\n .is-edit=${!!item.isEdit} .is-set=${!!item.hasSet} .is-save=${!item.isRealCanDel} .show-action=${!this._isPreviewValue} .show-add=${this['show-add']}\n .show-tag=${this['show-tag']}\n .show-category=${this['show-category']}\n .show-resource=${this['show-resource']}\n exam-answer-relation-type=${item.examAnswerRelationType ?? 0}\n rich-text-content=${item.examRichTextContent || ''}\n analysis=${item.analysis || ''}\n category-id=${item.categoryId || item.category?.categoryId || ''}\n custom-id=${item.customId || ''}\n exam-id=${item.examId ?? 0}\n @move=${onMove} @delete=${onDelete} @save=${onSave} @edit=${onEdit} @add=${onAdd}\n @choose-tag=${(e: CustomEvent) => this._emit('choose-tag', { ...e.detail, item: this._list[index] })}\n @tag-change=${(e: CustomEvent) => {\n this._list[index].tagInfos = e.detail.value\n this._list[index].memberTagInfo = e.detail.value\n this.requestUpdate()\n }}\n @category-change=${(e: CustomEvent) => {\n this._list[index].categoryId = e.detail.value\n this.requestUpdate()\n }}\n ></qxs-scale>`\n }\n if (item.answerType === 'page_end') {\n return html`<qxs-page-end\n .current-page-index=${item.currentPageIndex || this._pageEndIndex(index)}\n .total-page=${item.totalPage || this._pageEndTotal()}\n .show-action=${!this._isPreviewValue}\n .show-add=${this['show-add']}\n custom-id=${item.customId || ''}\n @delete=${onDelete}\n @add=${onAdd}\n ></qxs-page-end>`\n }\n return html`<div style=\"color:#909399;padding:8px\">未知题型: ${item.answerType}</div>`\n }\n\n render() {\n return html`\n <div class=\"subject-list\">\n ${this._list.map((item, index) => this._renderItem(item, index))}\n </div>\n `\n }\n}\n\nexport function register() {}\n"],"names":["QxsSubjectList","LitElement","constructor","super","arguments","this","_modelValueAttr","async","Promise","resolve","reject","reader","FileReader","onload","e","target","result","onerror","readAsDataURL","file","_list","_sortMode","_sortable","_initialDataProcessed","JSON","stringify","v","parsed","parse","Array","isArray","_normalizeIncomingList","requestUpdate","_useModel","hasAttribute","attributeChangedCallback","name","oldVal","newVal","length","includes","_isPreviewValue","val","connectedCallback","then","_processAttributeList","attr","getAttribute","_normalizeAnswer","answer","title","String","answerId","examAnswerId","_normalizeItem","item","answerType","richTextContent","examTypeEnum","answers","map","customId","uid","_rebuildPageEndMarkers","items","some","Number","pageIndex","currentPageIndex","rebuilt","forEach","push","normalized","firstUpdated","updateComplete","_initSortable","updated","changed","has","destroy","setTimeout","disconnectedCallback","renderRoot","querySelector","requestAnimationFrame","currentEl","Sortable","create","handle","animation","ghostClass","chosenClass","onEnd","evt","oldIndex","newIndex","arr","splice","_emitListChange","_emit","detail","dispatchEvent","CustomEvent","bubbles","composed","_withPageIndex","serialized","pendingBoundary","toJSON","subjectEls","querySelectorAll","results","errors","el","data","err","SubjectError","message","validate","valid","errs","currentList","addSubject","type","index","examAnswerRelationType","undefined","pageEndItem","analysis","scaleQuestionList","isEdit","isSave","isRealCanDel","hasSet","isKey","answerCheckType","addExam","newItems","uploadExcel","list","setAnswerRelation","answerRelations","customAnswerId","find","ans","c","setTagList","tagList","tagInfos","memberTagInfo","_orderIndex","n","out","_move","dir","_save","i","_deleteByCustomId","filter","_delete","_setEdit","_pageEndTotal","_pageEndIndex","slice","_syncRelationAnswer","currentAnswer","answerIndex","findIndex","currentIndex","orderIndex","_renderItem","common","onMove","onDelete","onSave","onEdit","onAdd","SubjectType","SINGLE","MULTIPLE","SORT","html","examResourceBOList","resourceList","examRichTextContent","leastAnswerCount","examExpand","categoryId","category","aiAnswer","examId","value","BLANK_FILL","examAnswerSettingBO","examAnswerSettingVO","TEXT_FILL","SCALE","totalPage","render","styles","css","__decorateClass","property","attribute","prototype","Object","Boolean","state","safeCustomElement"],"mappings":"kpBAkBO,IAAMA,EAAN,cAA6BC,EAA7BC,WAAAA,GAAAC,SAAAC,WAyBkCC,KAAA,eAAe,EAGhBA,KAAA,aAA6B,KAqBnEA,KAAQC,gBAAkB,GAG1BD,KAAA,gBAAkDE,SACzC,IAAIC,QAAQ,CAACC,EAASC,KAC3B,MAAMC,EAAS,IAAIC,WACnBD,EAAOE,OAASC,GAAKL,EAAQK,EAAEC,QAAQC,QACvCL,EAAOM,QAAUP,EACjBC,EAAOO,cAAcC,KAI8Bd,KAAA,iBAAyB,GAC5BA,KAAA,aAAa,EACRA,KAAA,kBAAkB,EACxBA,KAAA,YAAY,EACNA,KAAA,kBA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ts"],"sourcesContent":["import { css, html, LitElement } from 'lit'\nimport { property, state } from 'lit/decorators.js'\nimport Sortable from 'sortablejs'\nimport { safeCustomElement } from '../base/define'\nimport { uid } from '../base/uid'\nimport { SubjectError } from './single'\nimport { SubjectType } from './types'\n\n// 导入子组件以确保它们被注册为 Custom Elements\nimport './action'\nimport './blank-fill'\nimport './layout'\nimport './text-fill'\nimport './scale'\nimport './page-end'\nimport './type'\n\n@safeCustomElement('qxs-subject-list')\nexport class QxsSubjectList extends LitElement {\n static styles = css`\n :host { display: block; font-family: system-ui, -apple-system, \"PingFang SC\", \"Microsoft YaHei\", sans-serif; font-size: 13px; }\n *, ::before, ::after { box-sizing: border-box; }\n .sort-mode-toggle { display: flex; justify-content: flex-end; margin-bottom: 12px; }\n .btn { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 12px; font-size: 12px; border: 1px solid #dcdfe6; border-radius: 3px; background: #fff; color: #606266; cursor: pointer; transition: all 0.2s; }\n .btn:hover { color: #3D61E3; border-color: #3D61E3; background: #ecf5ff; }\n .btn.primary { background: #3D61E3; border-color: #3D61E3; color: #fff; }\n .btn.primary:hover { background: #3D61E3; border-color: #3D61E3; }\n .subject-list { display: flex; flex-direction: column; }\n .subject-content { flex: 1; min-width: 0; }\n .ghost { opacity: 0.5; background: #ecf5ff; }\n .chosen { box-shadow: 0 4px 16px rgba(64,158,255,.3); }\n .sort-list { display: flex; flex-direction: column; gap: 8px; }\n .sort-item { display: flex; align-items: center; padding: 12px 16px; background: #f8f9fa; border: 1px solid #e4e7ed; border-radius: 6px; cursor: grab; transition: all 0.3s ease; }\n .sort-item:hover { background: #ecf5ff; border-color: #c6e2ff; }\n .sort-item:active { cursor: grabbing; }\n .sort-item.sort-ghost { opacity: 0.5; background: #ecf5ff; border: 2px dashed #409eff; }\n .sort-item.sort-chosen { background: #ecf5ff; border-color: #409eff; box-shadow: 0 4px 16px rgba(64,158,255,.3); transform: scale(1.02); }\n .sort-handle { display: flex; align-items: center; justify-content: center; width: 20px; height: 20px; margin-right: 12px; color: #909399; flex-shrink: 0; }\n .sort-index { font-size: 13px; color: #606266; font-weight: 500; margin-right: 8px; min-width: 24px; flex-shrink: 0; }\n .sort-title { flex: 1; font-size: 14px; color: #303133; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n .sort-type { font-size: 12px; color: #909399; margin-left: 12px; padding: 2px 8px; background: #f0f0f0; border-radius: 4px; flex-shrink: 0; }\n `\n\n @property({ attribute: 'is-preview' }) 'is-preview' = false\n\n // use-model: enables two-way binding via model-value attribute + list-change event\n @property({ attribute: 'use-model' }) 'use-model': string | null = null\n @property({ attribute: 'model-value' })\n get 'model-value'(): string { return JSON.stringify(this._list) }\n\n set 'model-value'(v: string) {\n if (!v || v === this._modelValueAttr) { return }\n this._modelValueAttr = v\n try {\n const parsed = JSON.parse(v)\n if (Array.isArray(parsed)) {\n this._list = this._normalizeIncomingList(parsed)\n this.requestUpdate()\n }\n }\n catch { /* invalid JSON, ignore */ }\n }\n\n private get _useModel(): boolean {\n return this['use-model'] === 'true' || this['use-model'] === '' || this.hasAttribute('use-model')\n }\n\n private _modelValueAttr = ''\n\n @property({ type: Object, attribute: 'upload-image' })\n 'upload-image': (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\n @property({ type: Array, attribute: 'category-list' }) 'category-list': any[] = []\n @property({ type: Boolean, attribute: 'show-tag' }) 'show-tag' = false\n @property({ type: Boolean, attribute: 'show-category' }) 'show-category' = false\n @property({ type: Boolean, attribute: 'show-ai' }) 'show-ai' = false\n @property({ type: Boolean, attribute: 'show-resource' }) 'show-resource' = false\n @property({ type: Boolean, attribute: 'show-jump' }) 'show-jump' = false\n @property({ type: Boolean, attribute: 'show-add' }) 'show-add' = true\n @property({ type: Boolean, attribute: 'show-answer-setting' }) 'show-answer-setting' = false\n @property({ type: Boolean, attribute: 'show-key' }) 'show-key' = false\n @property({ type: String, attribute: 'search-api' }) 'search-api' = ''\n @property({ type: Object, attribute: 'search-handler' }) 'search-handler'?: (query: string, answerType: number) => Promise<any[]>\n\n @property({ type: Array, attribute: 'subject-list' })\n get 'subject-list'() { return this.currentList }\n\n set 'subject-list'(v: any) {\n if (!v) {\n this._list = []\n return\n }\n if (typeof v === 'string') {\n try {\n v = JSON.parse(v)\n }\n catch {\n this._list = []\n this.requestUpdate()\n return\n }\n }\n if (!Array.isArray(v)) {\n this._list = []\n this.requestUpdate()\n return\n }\n this._list = this._normalizeIncomingList(v)\n this.requestUpdate()\n }\n\n attributeChangedCallback(name: string, oldVal: string | null, newVal: string | null) {\n super.attributeChangedCallback(name, oldVal, newVal)\n if (name === 'subject-list' && newVal && !this._list.length) {\n if (newVal.includes('[object Object]')) {\n return\n }\n try {\n const parsed = JSON.parse(newVal)\n if (Array.isArray(parsed)) {\n this._list = this._normalizeIncomingList(parsed)\n this.requestUpdate()\n }\n }\n catch {\n // Not valid JSON, ignore\n }\n }\n }\n\n @state() private _list: any[] = []\n @state() private _sortMode = false\n private _sortable: Sortable | null = null\n\n private get _isPreviewValue(): boolean {\n const val = this['is-preview']\n return typeof val === 'string' ? val !== 'false' : !!val\n }\n\n private _initialDataProcessed = false\n\n connectedCallback() {\n super.connectedCallback()\n if (!this._initialDataProcessed) {\n this._initialDataProcessed = true\n Promise.resolve().then(() => {\n if (this._list.length === 0) {\n this._processAttributeList()\n }\n })\n }\n }\n\n private _processAttributeList() {\n const attr = this.getAttribute('subject-list')\n if (!attr || attr === '[]') { return }\n if (attr.includes('[object Object]')) {\n return\n }\n try {\n const parsed = JSON.parse(attr)\n if (Array.isArray(parsed) && parsed.length > 0) {\n this._list = this._normalizeIncomingList(parsed)\n this.requestUpdate()\n }\n }\n catch {\n // Not valid JSON, ignore\n }\n }\n\n private _normalizeAnswer(answer: any) {\n return {\n ...answer,\n title: String(answer?.title ?? answer?.answer ?? ''),\n answerId: answer?.answerId ?? answer?.examAnswerId,\n }\n }\n\n private _normalizeScaleQuestionList(item: any) {\n const raw = Array.isArray(item?.scaleQuestionList)\n ? item.scaleQuestionList\n : Array.isArray(item?.scaleQuestions)\n ? item.scaleQuestions\n : Array.isArray(item?.['scale-question-list'])\n ? item['scale-question-list']\n : undefined\n\n if (raw === undefined) {\n return undefined\n }\n\n return raw\n .map((question: any) => String(question ?? '').trim())\n .filter(Boolean)\n }\n\n private _normalizeItem(item: any) {\n const normalizedItem = this._stripBusinessFields(item)\n const answerType = normalizedItem?.answerType || (!normalizedItem?.richTextContent ? normalizedItem?.examTypeEnum : normalizedItem?.answerType)\n const answers = Array.isArray(normalizedItem?.answers) ? normalizedItem.answers.map((answer: any) => this._normalizeAnswer(answer)) : []\n const scaleQuestionList = this._normalizeScaleQuestionList(normalizedItem)\n return {\n ...normalizedItem,\n customId: normalizedItem?.customId || uid(),\n ...(answerType ? { answerType } : {}),\n ...(answers.length || Array.isArray(normalizedItem?.answers) ? { answers } : {}),\n ...(scaleQuestionList !== undefined ? { scaleQuestionList } : {}),\n }\n }\n\n private _stripBusinessFields(item: any) {\n if (!item || typeof item !== 'object') { return item }\n const {\n memberTagInfo,\n tagInfos,\n categoryId,\n category,\n resourceList,\n examResourceBOList,\n aiAnswer,\n ...rest\n } = item\n return rest\n }\n\n private _exportQuestionItem(item: any) {\n return this._stripBusinessFields(item)\n }\n\n private _rebuildPageEndMarkers(items: any[]) {\n if (!items.length) { return items }\n if (items.some(item => item?.answerType === 'page_end')) { return items }\n if (!items.some(item => Number(item?.pageIndex) > 1)) { return items }\n\n let currentPageIndex = 1\n const rebuilt: any[] = []\n\n items.forEach((item) => {\n const pageIndex = Number(item?.pageIndex) || 1\n if (pageIndex > currentPageIndex) {\n if (rebuilt.length > 0) {\n while (currentPageIndex < pageIndex) {\n rebuilt.push({ customId: uid(), answerType: 'page_end' })\n currentPageIndex++\n }\n }\n else {\n currentPageIndex = pageIndex\n }\n }\n rebuilt.push(item)\n })\n\n return rebuilt\n }\n\n private _normalizeIncomingList(items: any[]) {\n const normalized = items.map((item: any) => this._normalizeItem(item))\n return this._rebuildPageEndMarkers(normalized)\n }\n\n firstUpdated() {\n this.updateComplete.then(() => this._initSortable())\n }\n\n updated(changed: Map<string, unknown>) {\n if (changed.has('_sortMode')) {\n this._sortable?.destroy()\n this._sortable = null\n this.updateComplete.then(() => this._initSortable())\n }\n // Reinitialize Sortable when list changes in sort mode\n if (changed.has('_list') && this._sortMode) {\n // Small delay to let Lit finish DOM updates\n setTimeout(() => {\n if (this._sortable) {\n this._sortable.destroy()\n this._sortable = null\n }\n this._initSortable()\n }, 50)\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback()\n this._sortable?.destroy()\n this._sortable = null\n }\n\n private _initSortable() {\n if (!this._sortMode) { return }\n const el = this.renderRoot.querySelector<HTMLElement>('.sort-list')\n if (!el) { return }\n\n // Destroy existing instance first\n if (this._sortable) {\n this._sortable.destroy()\n this._sortable = null\n }\n\n // Small delay to ensure DOM is ready after previous destroy\n requestAnimationFrame(() => {\n const currentEl = this.renderRoot.querySelector<HTMLElement>('.sort-list')\n if (!currentEl || this._sortable) { return }\n\n this._sortable = Sortable.create(currentEl, {\n handle: '.sort-handle',\n animation: 200,\n ghostClass: 'sort-ghost',\n chosenClass: 'sort-chosen',\n onEnd: (evt) => {\n const { oldIndex, newIndex } = evt\n if (oldIndex === undefined || newIndex === undefined || oldIndex === newIndex) { return }\n const arr = [...this._list]\n const [item] = arr.splice(oldIndex, 1)\n arr.splice(newIndex, 0, item)\n this._list = arr\n this._emitListChange()\n },\n })\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 _emitListChange() {\n const payload = this.currentList\n this._emit('change', payload)\n if (this._useModel) {\n this._modelValueAttr = JSON.stringify(payload)\n this._emit('list-change', payload)\n }\n }\n\n private _withPageIndex(items: any[]) {\n const serialized: any[] = []\n let pageIndex = 1\n let pendingBoundary = false\n\n items.forEach((item) => {\n if (!item) { return }\n if (item.answerType === 'page_end') {\n if (serialized.length > 0) {\n pendingBoundary = true\n }\n return\n }\n if (pendingBoundary) {\n pageIndex += 1\n pendingBoundary = false\n }\n serialized.push({\n ...item,\n pageIndex,\n })\n })\n\n return serialized\n }\n\n async toJSON(): Promise<any[]> {\n const subjectEls = this.renderRoot.querySelectorAll<any>(\n 'qxs-subject-single, qxs-blank-fill, qxs-text-fill, qxs-scale, qxs-page-end, qxs-subject-rich-text',\n )\n if (!subjectEls || subjectEls.length === 0) {\n return []\n }\n\n const results: any[] = []\n const errors: SubjectError[] = []\n\n for (const el of subjectEls) {\n if (typeof el.toJSON === 'function') {\n try {\n const data = await el.toJSON()\n results.push(data)\n }\n catch (err: any) {\n if (err instanceof SubjectError) {\n errors.push(err)\n }\n else {\n errors.push(new SubjectError(err.message || '未知错误', 'UNKNOWN', 'unknown'))\n }\n }\n }\n }\n\n if (errors.length > 0) {\n throw errors\n }\n\n return this._withPageIndex(results)\n }\n\n async validate(): Promise<{ valid: boolean, errors: SubjectError[] }> {\n const subjectEls = this.renderRoot.querySelectorAll<any>(\n 'qxs-subject-single, qxs-blank-fill, qxs-text-fill, qxs-scale, qxs-page-end',\n )\n if (!subjectEls || subjectEls.length === 0) {\n return { valid: true, errors: [] }\n }\n\n const errors: SubjectError[] = []\n\n for (const el of subjectEls) {\n if (typeof el.validate === 'function') {\n const errs = el.validate()\n if (errs?.length) {\n errors.push(...errs)\n }\n }\n }\n\n return {\n valid: errors.length === 0,\n errors,\n }\n }\n\n // ── public API ────────────────────────────────────────────────\n get currentList() { return this._list.map(item => this._exportQuestionItem(item)) }\n\n addSubject(type: string, index?: number, examAnswerRelationType: number | null = null) {\n // 分页符只需要最少的必要字段\n if (type === 'page_end') {\n const pageEndItem = {\n customId: uid(),\n answerType: 'page_end',\n }\n const arr = [...this._list]\n if (typeof index === 'number' && index >= 0) {\n arr.splice(index + 1, 0, pageEndItem)\n }\n else {\n arr.push(pageEndItem)\n }\n this._list = arr\n this.requestUpdate()\n this._emitListChange()\n return\n }\n\n const item: any = {\n customId: uid(), answerType: type, title: '',\n answers: [], analysis: '', scaleQuestionList: [],\n isEdit: true, isSave: false, isRealCanDel: true, hasSet: false,\n }\n if (type === SubjectType.SCALE) {\n item.answers = Array.from({ length: 5 }, () => ({ title: '' }))\n }\n if (examAnswerRelationType !== null) {\n item.examAnswerRelationType = examAnswerRelationType\n }\n const arr = [...this._list]\n if (typeof index === 'number' && index >= 0) {\n arr.splice(index + 1, 0, item)\n }\n else { arr.push(item) }\n this._list = arr\n this.requestUpdate()\n this._emitListChange()\n }\n\n addExam(items: any[]) {\n const newItems = this._normalizeIncomingList(items).map((item: any) => ({\n ...item,\n isEdit: true,\n isSave: false,\n isRealCanDel: true,\n hasSet: false,\n }))\n this._list = [...this._list, ...newItems]\n this._emitListChange()\n }\n\n uploadExcel(list: any[]) {\n this._list = [\n ...this._list,\n ...this._normalizeIncomingList(list).map((item: any) => ({ ...item, isRealCanDel: true })),\n ]\n this._emitListChange()\n }\n\n setAnswerRelation(answerRelations: any, customId: string, customAnswerId: string) {\n const item = this._list.find((v: any) => v.customId === customId)\n if (item) {\n const ans = item.answers?.find((c: any) => c.customAnswerId === customAnswerId)\n if (ans) { ans.answerRelations = answerRelations }\n }\n this.requestUpdate()\n this._emitListChange()\n }\n\n setTagList(tagList: any[], customId: string) {\n void tagList\n void customId\n this.requestUpdate()\n }\n\n // ── private helpers ───────────────────────────────────────────\n private _orderIndex(customId: string) {\n let n = 0; let out = 0\n this._list.forEach((v: any) => {\n n++; if (v.customId === customId) { out = n }\n })\n return out - 1\n }\n\n private _move(index: number, dir: 'up' | 'down') {\n const arr = [...this._list]\n if (dir === 'up' && index > 0) { [arr[index - 1], arr[index]] = [arr[index], arr[index - 1]] }\n else if (dir === 'down' && index < arr.length - 1) { [arr[index], arr[index + 1]] = [arr[index + 1], arr[index]] }\n this._list = arr\n this._emitListChange()\n }\n\n private _normalizeLeastAnswerCount(answerType: string, value: unknown) {\n if (![SubjectType.MULTIPLE, SubjectType.SORT].includes(answerType as SubjectType)) {\n return undefined\n }\n if (value === '' || value === null || value === undefined) {\n return null\n }\n const count = Number(value)\n return Number.isFinite(count) && count > 0 ? count : null\n }\n\n private _normalizeSavedItem(item: any) {\n const next = { ...this._stripBusinessFields(item) }\n const leastAnswerCount = this._normalizeLeastAnswerCount(next.answerType, next.leastAnswerCount)\n if (leastAnswerCount === undefined) {\n delete next.leastAnswerCount\n }\n else {\n next.leastAnswerCount = leastAnswerCount\n }\n return next\n }\n\n private _save(index: number, e: CustomEvent) {\n this._list = this._list.map((item, i) =>\n i === index ? this._normalizeSavedItem({ ...item, ...e.detail, isEdit: false, isSave: true }) : item,\n )\n this._emitListChange()\n }\n\n private _deleteByCustomId(customId: string) {\n this._list = this._list.filter(item => item.customId !== customId)\n this._emitListChange()\n }\n\n private _delete(index: number) {\n const arr = [...this._list]\n arr.splice(index, 1)\n this._list = arr\n this._emitListChange()\n }\n\n private _setEdit(index: number, val: boolean) {\n this._list = this._list.map((item, i) => i === index ? { ...item, isEdit: val } : item)\n }\n\n private _pageEndTotal() {\n return this._list.filter(item => item.answerType === 'page_end').length + 1\n }\n\n private _pageEndIndex(index: number) {\n return this._list.slice(0, index + 1).filter(item => item.answerType === 'page_end').length\n }\n\n private _syncRelationAnswer(index: number, detail: any) {\n const item = this._list[index]\n if (!item || !Array.isArray(item.answers) || !detail?.answer) { return }\n const answers = [...item.answers]\n const currentAnswer = detail.answer\n let answerIndex = typeof detail.answerIndex === 'number' ? detail.answerIndex : -1\n\n if (answerIndex < 0 || answerIndex >= answers.length) {\n answerIndex = answers.findIndex((answer: any, currentIndex: number) => {\n return String(answer.customAnswerId || '') === String(currentAnswer.customAnswerId || '')\n || String(answer.answerId || '') === String(currentAnswer.answerId || '')\n || String(answer.orderIndex || currentIndex + 1) === String(currentAnswer.orderIndex || '')\n })\n }\n\n if (answerIndex < 0) { return }\n answers[answerIndex] = {\n ...answers[answerIndex],\n customAnswerId: currentAnswer.customAnswerId || answers[answerIndex].customAnswerId || currentAnswer.answerId,\n }\n this._list[index] = {\n ...item,\n answers,\n }\n this._list = [...this._list]\n }\n\n private _renderItem(item: any, index: number) {\n const common = {\n 'order-index': this._orderIndex(item.customId),\n '?is-edit': item.isEdit || false,\n '?is-set': item.hasSet || false,\n '?show-action': !this._isPreviewValue,\n 'exam-answer-relation-type': item.examAnswerRelationType ?? 0,\n }\n const onMove = (e: CustomEvent) => this._move(index, e.detail as 'up' | 'down')\n const onDelete = () => this._deleteByCustomId(item.customId)\n const onSave = (e: CustomEvent) => this._save(index, e)\n const onEdit = () => this._setEdit(index, true)\n const onAdd = (e: CustomEvent) => this.addSubject(e.detail?.type ?? e.detail, index)\n\n if ([SubjectType.SINGLE, SubjectType.MULTIPLE, SubjectType.SORT].includes(item.answerType)) {\n return html`<qxs-subject-single\n .title=${item.title || ''}\n .answer-list=${item.answers || []}\n .category-list=${this['category-list']}\n .search-handler=${this['search-handler']}\n .upload-image=${this['upload-image']}\n order-index=${common['order-index']}\n .is-edit=${!!item.isEdit}\n .is-set=${!!item.hasSet}\n .lockAnswerKey=${!!(item.lockAnswerKey ?? item['lock-answer-key'])}\n .show-action=${!this._isPreviewValue}\n .show-add=${this['show-add']}\n .show-category=${this['show-category']}\n .show-ai=${this['show-ai']}\n .show-resource=${this['show-resource']}\n .show-jump=${this['show-jump']}\n question-type=${String(item.answerType)}\n rich-text-content=${item.examRichTextContent || ''}\n analysis=${item.analysis || ''}\n .least-answer-count=${item.leastAnswerCount ?? null}\n exam-expand=${item.examExpand || ''}\n search-api=${this['search-api']}\n custom-id=${item.customId || ''}\n exam-id=${item.examId ?? 0}\n @move=${onMove} @delete=${onDelete} @save=${onSave} @edit=${onEdit} @add=${onAdd}\n @title-select=${(e: CustomEvent) => this._emit('title-select', e.detail)}\n @jump=${(e: CustomEvent) => this._emit('jump', { ...e.detail, item: this._list[index] })}\n ></qxs-subject-single>`\n }\n if (item.answerType === SubjectType.BLANK_FILL) {\n return html`<qxs-blank-fill\n .title=${item.title || ''}\n .answer-list=${item.answers || []}\n .category-list=${this['category-list']}\n .exam-answer-setting=${item.examAnswerSettingBO || item.examAnswerSettingVO || {}}\n .upload-image=${this['upload-image']}\n order-index=${common['order-index']}\n .is-edit=${!!item.isEdit} .is-set=${!!item.hasSet} .show-action=${!this._isPreviewValue} .show-add=${this['show-add']}\n .show-answer-setting=${this['show-answer-setting']}\n .show-category=${this['show-category']}\n .show-resource=${this['show-resource']}\n exam-answer-relation-type=${item.examAnswerRelationType ?? 0}\n exam-expand=${item.examExpand || ''}\n rich-text-content=${item.examRichTextContent || ''}\n analysis=${item.analysis || ''}\n custom-id=${item.customId || ''}\n exam-id=${item.examId ?? 0}\n @move=${onMove} @delete=${onDelete} @save=${onSave} @edit=${onEdit} @add=${onAdd}\n ></qxs-blank-fill>`\n }\n if (item.answerType === SubjectType.TEXT_FILL) {\n return html`<qxs-text-fill\n .title=${item.title || ''}\n .answer-list=${item.answers || []}\n .category-list=${this['category-list']}\n .search-handler=${this['search-handler']}\n .exam-answer-setting=${item.examAnswerSettingBO || item.examAnswerSettingVO || {}}\n .upload-image=${this['upload-image']}\n order-index=${common['order-index']}\n .is-edit=${!!item.isEdit} .is-set=${!!item.hasSet} .show-action=${!this._isPreviewValue} .show-add=${this['show-add']}\n .show-answer-setting=${this['show-answer-setting']}\n .show-category=${this['show-category']}\n .show-resource=${this['show-resource']}\n exam-answer-relation-type=${item.examAnswerRelationType ?? 0}\n exam-expand=${item.examExpand || ''}\n rich-text-content=${item.examRichTextContent || ''}\n analysis=${item.analysis || ''}\n custom-id=${item.customId || ''}\n exam-id=${item.examId ?? 0}\n @move=${onMove} @delete=${onDelete} @save=${onSave} @edit=${onEdit} @add=${onAdd}\n ></qxs-text-fill>`\n }\n if (item.answerType === SubjectType.SCALE) {\n const scaleQuestionList = Array.isArray(item.scaleQuestionList)\n ? item.scaleQuestionList\n : Array.isArray(item.scaleQuestions)\n ? item.scaleQuestions\n : []\n return html`<qxs-scale\n .title=${item.title || ''}\n .answer-list=${item.answers || []}\n .scale-question-list=${scaleQuestionList}\n .upload-image=${this['upload-image']}\n order-index=${common['order-index']}\n .is-edit=${!!item.isEdit} .is-set=${!!item.hasSet} .show-action=${!this._isPreviewValue} .show-add=${this['show-add']}\n rich-text-content=${item.examRichTextContent || ''}\n custom-id=${item.customId || ''}\n @move=${onMove} @delete=${onDelete} @save=${onSave} @edit=${onEdit} @add=${onAdd}\n ></qxs-scale>`\n }\n if (item.answerType === 'page_end') {\n return html`<qxs-page-end\n .current-page-index=${item.currentPageIndex || this._pageEndIndex(index)}\n .total-page=${item.totalPage || this._pageEndTotal()}\n .show-action=${!this._isPreviewValue}\n .show-add=${this['show-add']}\n custom-id=${item.customId || ''}\n @delete=${onDelete}\n @add=${onAdd}\n ></qxs-page-end>`\n }\n return html`<div style=\"color:#909399;padding:8px\">未知题型: ${item.answerType}</div>`\n }\n\n render() {\n return html`\n <div class=\"subject-list\">\n ${this._list.map((item, index) => this._renderItem(item, index))}\n </div>\n `\n }\n}\n\nexport function register() {}\n"],"names":["QxsSubjectList","LitElement","constructor","super","arguments","this","_modelValueAttr","async","Promise","resolve","reject","reader","FileReader","onload","e","target","result","onerror","readAsDataURL","file","_list","_sortMode","_sortable","_initialDataProcessed","JSON","stringify","v","parsed","parse","Array","isArray","_normalizeIncomingList","requestUpdate","_useModel","hasAttribute","currentList","attributeChangedCallback","name","oldVal","newVal","length","includes","_isPreviewValue","val","connectedCallback","then","_processAttributeList","attr","getAttribute","_normalizeAnswer","answer","title","String","answerId","examAnswerId","_normalizeScaleQuestionList","item","raw","scaleQuestionList","scaleQuestions","map","question","trim","filter","Boolean","_normalizeItem","normalizedItem","_stripBusinessFields","answerType","richTextContent","examTypeEnum","answers","customId","uid","memberTagInfo","tagInfos","categoryId","category","resourceList","examResourceBOList","aiAnswer","rest","_exportQuestionItem","_rebuildPageEndMarkers","items","some","Number","pageIndex","currentPageIndex","rebuilt","forEach","push","normalized","firstUpdated","updateComplete","_initSortable","updated","changed","has","destroy","setTimeout","disconnectedCallback","renderRoot","querySelector","requestAnimationFrame","currentEl","Sortable","create","handle","animation","ghostClass","chosenClass","onEnd","evt","oldIndex","newIndex","arr","splice","_emitListChange","_emit","detail","dispatchEvent","CustomEvent","bubbles","composed","payload","_withPageIndex","serialized","pendingBoundary","toJSON","subjectEls","querySelectorAll","results","errors","el","data","err","SubjectError","message","validate","valid","errs","addSubject","type","index","examAnswerRelationType","undefined","pageEndItem","analysis","isEdit","isSave","isRealCanDel","hasSet","SubjectType","SCALE","from","addExam","newItems","uploadExcel","list","setAnswerRelation","answerRelations","customAnswerId","find","ans","c","setTagList","tagList","_orderIndex","n","out","_move","dir","_normalizeLeastAnswerCount","value","MULTIPLE","SORT","count","isFinite","_normalizeSavedItem","next","leastAnswerCount","_save","i","_deleteByCustomId","_delete","_setEdit","_pageEndTotal","_pageEndIndex","slice","_syncRelationAnswer","currentAnswer","answerIndex","findIndex","currentIndex","orderIndex","_renderItem","common","onMove","onDelete","onSave","onEdit","onAdd","SINGLE","html","lockAnswerKey","examRichTextContent","examExpand","examId","BLANK_FILL","examAnswerSettingBO","examAnswerSettingVO","TEXT_FILL","totalPage","render","styles","css","__decorateClass","property","attribute","prototype","Object","state","safeCustomElement"],"mappings":"kpBAkBO,IAAMA,EAAN,cAA6BC,EAA7BC,WAAAA,GAAAC,SAAAC,WAyBkCC,KAAA,eAAe,EAGhBA,KAAA,aAA6B,KAqBnEA,KAAQC,gBAAkB,GAG1BD,KAAA,gBAAkDE,SACzC,IAAIC,QAAQ,CAACC,EAASC,KAC3B,MAAMC,EAAS,IAAIC,WACnBD,EAAOE,OAASC,GAAKL,EAAQK,EAAEC,QAAQC,QACvCL,EAAOM,QAAUP,EACjBC,EAAOO,cAAcC,KAI8Bd,KAAA,iBAAyB,GAC5BA,KAAA,aAAa,EACRA,KAAA,kBAAkB,EACxBA,KAAA,YAAY,EAC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AAA,GACAH,EAAA,CAAhBK,KAxHU9N,EAwHM4N,UAAA,YAAA,GAxHN5N,EAANyN,EAAA,CADNM,EAAkB,qBACN/N"}
@@ -1,4 +1,4 @@
1
- import{css as t,LitElement as e,html as i}from"lit";import{property as s}from"lit/decorators.js";import{safeCustomElement as o}from"../base/define.mjs";var a=Object.defineProperty,r=Object.getOwnPropertyDescriptor,d=(t,e,i,s)=>{for(var o,d=s>1?void 0:s?r(e,i):e,n=t.length-1;n>=0;n--)(o=t[n])&&(d=(s?o(e,i,d):o(d))||d);return s&&d&&a(e,i,d),d};let n=class extends e{constructor(){super(...arguments),this["current-page-index"]=1,this["total-page"]=1,this["show-action"]=!0,this["show-add"]=!0,this["custom-id"]=""}_emit(t,e){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e??null}))}async toJSON(){const t={answerType:"page_end"};return this["custom-id"]&&(t.customId=this["custom-id"]),t}validate(){return[]}render(){return i`
1
+ import{css as t,LitElement as e,html as i}from"lit";import{property as o}from"lit/decorators.js";import{safeCustomElement as s}from"../base/define.mjs";import{sortingCardStyles as r,renderSortingCard as a}from"./sorting-card.mjs";var n=Object.defineProperty,d=Object.getOwnPropertyDescriptor,p=(t,e,i,o)=>{for(var s,r=o>1?void 0:o?d(e,i):e,a=t.length-1;a>=0;a--)(s=t[a])&&(r=(o?s(e,i,r):s(r))||r);return o&&r&&n(e,i,r),r};let c=class extends e{constructor(){super(...arguments),this["current-page-index"]=1,this["total-page"]=1,this["show-action"]=!0,this["show-add"]=!0,this["custom-id"]="",this.sorting=!1}_emit(t,e){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e??null}))}async toJSON(){const t={answerType:"page_end"};return this["custom-id"]&&(t.customId=this["custom-id"]),t}validate(){return[]}render(){return this.sorting?a("分页边界",`第${this["current-page-index"]} / ${this["total-page"]}页`):i`
2
2
  <div class="container">
3
3
  <div class="divider">
4
4
  <div class="line"></div>
@@ -16,11 +16,11 @@ import{css as t,LitElement as e,html as i}from"lit";import{property as s}from"li
16
16
  ></qxs-subject-action>
17
17
  `:""}
18
18
  </div>
19
- `}};n.styles=t`
19
+ `}};c.styles=[r,t`
20
20
  :host { display: block; font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 12px; }
21
21
  .container { width: 100%; }
22
22
  .divider { display: flex; align-items: center; padding: 12px 0; }
23
23
  .line { flex: 1; height: 1px; background-color: #e4e7ed; }
24
24
  .label { padding: 0 12px; font-size: 12px; color: #8c8c8c; }
25
- `,d([s({type:Number,attribute:"current-page-index"})],n.prototype,"current-page-index",2),d([s({type:Number,attribute:"total-page"})],n.prototype,"total-page",2),d([s({type:Boolean,attribute:"show-action"})],n.prototype,"show-action",2),d([s({type:Boolean,attribute:"show-add"})],n.prototype,"show-add",2),d([s({type:String,attribute:"custom-id"})],n.prototype,"custom-id",2),n=d([o("qxs-page-end")],n);export{n as QxsPageEnd};
25
+ `],p([o({type:Number,attribute:"current-page-index"})],c.prototype,"current-page-index",2),p([o({type:Number,attribute:"total-page"})],c.prototype,"total-page",2),p([o({type:Boolean,attribute:"show-action"})],c.prototype,"show-action",2),p([o({type:Boolean,attribute:"show-add"})],c.prototype,"show-add",2),p([o({type:String,attribute:"custom-id"})],c.prototype,"custom-id",2),p([o({type:Boolean,reflect:!0})],c.prototype,"sorting",2),c=p([s("qxs-page-end")],c);export{c as QxsPageEnd};
26
26
  //# sourceMappingURL=page-end.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"page-end.mjs","sources":["../../../../packages/components-wc/src/subject/page-end.ts"],"sourcesContent":["import { css, html, LitElement } from 'lit'\nimport { property } from 'lit/decorators.js'\nimport { safeCustomElement } from '../base/define'\n\n@safeCustomElement('qxs-page-end')\nexport class QxsPageEnd 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; }\n .container { width: 100%; }\n .divider { display: flex; align-items: center; padding: 12px 0; }\n .line { flex: 1; height: 1px; background-color: #e4e7ed; }\n .label { padding: 0 12px; font-size: 12px; color: #8c8c8c; }\n `\n\n @property({ type: Number, attribute: 'current-page-index' }) 'current-page-index' = 1\n @property({ type: Number, attribute: 'total-page' }) 'total-page' = 1\n @property({ type: Boolean, attribute: 'show-action' }) 'show-action' = true\n @property({ type: Boolean, attribute: 'show-add' }) 'show-add' = true\n @property({ type: String, attribute: 'custom-id' }) 'custom-id' = ''\n\n private _emit(name: string, detail?: unknown) {\n this.dispatchEvent(new CustomEvent(name, { bubbles: true, composed: true, detail: detail ?? null }))\n }\n\n async toJSON(): Promise<any> {\n const result: any = {\n answerType: 'page_end',\n }\n if (this['custom-id']) {\n result.customId = this['custom-id']\n }\n return result\n }\n\n validate() {\n return []\n }\n\n render() {\n return html`\n <div class=\"container\">\n <div class=\"divider\">\n <div class=\"line\"></div>\n <span class=\"label\">第${this['current-page-index']} / ${this['total-page']}页</span>\n <div class=\"line\"></div>\n </div>\n ${this['show-action']\n ? html`\n <qxs-subject-action\n .page-end=${true}\n .show-add=${this['show-add']}\n .show-other-option=${false}\n .show-rich-text=${false}\n @delete=${() => this._emit('delete')}\n @add=${(e: CustomEvent) => this._emit('add', e.detail)}\n ></qxs-subject-action>\n `\n : ''}\n </div>\n `\n }\n}\n\nexport function register() {\n // auto-registered via @safeCustomElement\n}\n"],"names":["QxsPageEnd","LitElement","constructor","super","arguments","this","_emit","name","detail","dispatchEvent","CustomEvent","bubbles","composed","toJSON","result","answerType","customId","validate","render","html","e","styles","css","__decorateClass","property","type","Number","attribute","prototype","Boolean","String","safeCustomElement"],"mappings":"wVAKO,IAAMA,EAAN,cAAyBC,EAAzBC,WAAAA,GAAAC,SAAAC,WASwDC,KAAA,sBAAuB,EAC/BA,KAAA,cAAe,EACbA,KAAA,gBAAgB,EACnBA,KAAA,aAAa,EACbA,KAAA,aAAc,EAAA,CAE1DC,KAAAA,CAAMC,EAAcC,GAC1BH,KAAKI,cAAc,IAAIC,YAAYH,EAAM,CAAEI,SAAS,EAAMC,UAAU,EAAMJ,OAAQA,GAAU,OAC9F,CAEA,YAAMK,GACJ,MAAMC,EAAc,CAClBC,WAAY,YAKd,OAHIV,KAAK,eACPS,EAAOE,SAAWX,KAAK,cAElBS,CACT,CAEAG,QAAAA,GACE,MAAO,EACT,CAEAC,MAAAA,GACE,OAAOC,CAAA;;;;iCAIsBd,KAAK,2BAA2BA,KAAK;;;UAG5DA,KAAK,eACHc,CAAA;;yBAEY;wBACAd,KAAK;kCACI;+BACH;sBACR,IAAMA,KAAKC,MAAM;mBACnBc,GAAmBf,KAAKC,MAAM,MAAOc,EAAEZ;;UAG/C;;KAGV,GAvDWR,EACJqB,OAASC,CAAA;;;;;;IAQ6CC,EAAA,CAA5DC,EAAS,CAAEC,KAAMC,OAAQC,UAAW,wBAT1B3B,EASkD4B,UAAA,qBAAA,GACRL,EAAA,CAApDC,EAAS,CAAEC,KAAMC,OAAQC,UAAW,gBAV1B3B,EAU0C4B,UAAA,aAAA,GACEL,EAAA,CAAtDC,EAAS,CAAEC,KAAMI,QAASF,UAAW,iBAX3B3B,EAW4C4B,UAAA,cAAA,GACHL,EAAA,CAAnDC,EAAS,CAAEC,KAAMI,QAASF,UAAW,cAZ3B3B,EAYyC4B,UAAA,WAAA,GACAL,EAAA,CAAnDC,EAAS,CAAEC,KAAMK,OAAQH,UAAW,eAb1B3B,EAayC4B,UAAA,YAAA,GAbzC5B,EAANuB,EAAA,CADNQ,EAAkB,iBACN/B"}
1
+ {"version":3,"file":"page-end.mjs","sources":["../../../../packages/components-wc/src/subject/page-end.ts"],"sourcesContent":["import { css, html, LitElement } from 'lit'\nimport { property } from 'lit/decorators.js'\nimport { safeCustomElement } from '../base/define'\nimport { renderSortingCard, sortingCardStyles } from './sorting-card'\n\n@safeCustomElement('qxs-page-end')\nexport class QxsPageEnd extends LitElement {\n static styles = [sortingCardStyles, css`\n :host { display: block; font-family: system-ui, -apple-system, \"PingFang SC\", \"Microsoft YaHei\", sans-serif; font-size: 12px; }\n .container { width: 100%; }\n .divider { display: flex; align-items: center; padding: 12px 0; }\n .line { flex: 1; height: 1px; background-color: #e4e7ed; }\n .label { padding: 0 12px; font-size: 12px; color: #8c8c8c; }\n `]\n\n @property({ type: Number, attribute: 'current-page-index' }) 'current-page-index' = 1\n @property({ type: Number, attribute: 'total-page' }) 'total-page' = 1\n @property({ type: Boolean, attribute: 'show-action' }) 'show-action' = true\n @property({ type: Boolean, attribute: 'show-add' }) 'show-add' = true\n @property({ type: String, attribute: 'custom-id' }) 'custom-id' = ''\n @property({ type: Boolean, reflect: true }) sorting = false\n\n private _emit(name: string, detail?: unknown) {\n this.dispatchEvent(new CustomEvent(name, { bubbles: true, composed: true, detail: detail ?? null }))\n }\n\n async toJSON(): Promise<any> {\n const result: any = {\n answerType: 'page_end',\n }\n if (this['custom-id']) {\n result.customId = this['custom-id']\n }\n return result\n }\n\n validate() {\n return []\n }\n\n render() {\n if (this.sorting) {\n return renderSortingCard('分页边界', `第${this['current-page-index']} / ${this['total-page']}页`)\n }\n\n return html`\n <div class=\"container\">\n <div class=\"divider\">\n <div class=\"line\"></div>\n <span class=\"label\">第${this['current-page-index']} / ${this['total-page']}页</span>\n <div class=\"line\"></div>\n </div>\n ${this['show-action']\n ? html`\n <qxs-subject-action\n .page-end=${true}\n .show-add=${this['show-add']}\n .show-other-option=${false}\n .show-rich-text=${false}\n @delete=${() => this._emit('delete')}\n @add=${(e: CustomEvent) => this._emit('add', e.detail)}\n ></qxs-subject-action>\n `\n : ''}\n </div>\n `\n }\n}\n\nexport function register() {\n // auto-registered via @safeCustomElement\n}\n"],"names":["QxsPageEnd","LitElement","constructor","super","arguments","this","sorting","_emit","name","detail","dispatchEvent","CustomEvent","bubbles","composed","toJSON","result","answerType","customId","validate","render","renderSortingCard","html","e","styles","sortingCardStyles","css","__decorateClass","property","type","Number","attribute","prototype","Boolean","String","reflect","safeCustomElement"],"mappings":"saAMO,IAAMA,EAAN,cAAyBC,EAA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S,KAdzBlC,EAciC+B,UAAA,UAAA,GAdjC/B,EAAN0B,EAAA,CADNS,EAAkB,iBACNnC"}
@@ -0,0 +1,2 @@
1
+ import{uid as t}from"../base/uid.mjs";import{SubjectType as e}from"./types.mjs";function n(){return{customId:t(),answerType:e.PAGE_END}}function r(t){return!!t&&t.answerType===e.PAGE_END}function u(e){const n=e.map(t=>({...t})),u=[];let o=!1;for(n.forEach(e=>{if(e)if(r(e)){if(!o)return;if(r(u[u.length-1]))return;u.push({...e,customId:e.customId||t()})}else o=!0,u.push(e)});u.length>0&&r(u[u.length-1]);)u.pop();return u}function o(t){const e=t.filter(t=>!r(t)).map(t=>({...t}));if(!e.length)return[];const o=[];let s=1;return e.forEach((t,e)=>{const r=Number(t.pageIndex)>0?Number(t.pageIndex):s;e>0&&r>s&&o.push(n()),o.push(t),s=r}),u(o)}function s(t){const e=[];let n=1,u=0;return t.forEach(t=>{t&&(r(t)?e.length>0&&(u+=1):(u>0&&(n+=u,u=0),e.push({...t,pageIndex:n})))}),e}function c(t,e){const r=[...u(t)];return 0===r.length?r:void 0===e||e<0||e>=r.length-1?(r.push(n()),u(r)):(r.splice(e+1,0,n()),u(r))}function f(t,e){return u(t.filter(t=>!(r(t)&&t.customId===e)))}function i(t){const e=u(t),n=e.filter(t=>r(t)).length+1;let o=1;return e.reduce((t,e,u)=>r(e)?(t.push({customId:e.customId,currentPageIndex:o,totalPage:n,itemIndex:u}),o+=1,t):t,[])}export{i as getPaginationMeta,c as insertPageBreak,r as isPageBreakItem,u as normalizePageBreaks,o as rebuildPageBreaksFromPageIndex,f as removePageBreak,s as serializeSubjectsWithPageIndex};
2
+ //# sourceMappingURL=pagination.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pagination.mjs","sources":["../../../../packages/components-wc/src/subject/pagination.ts"],"sourcesContent":["import { uid } from '../base/uid'\nimport { SubjectType } from './types'\n\nexport interface SubjectLikeItem {\n answerType: string\n customId?: string\n pageIndex?: number\n [key: string]: any\n}\n\nexport interface PageBreakItem extends SubjectLikeItem {\n answerType: 'page_end'\n customId: string\n}\n\nexport interface PaginationMetaItem {\n customId: string\n currentPageIndex: number\n totalPage: number\n itemIndex: number\n}\n\nfunction createPageBreak(): PageBreakItem {\n return {\n customId: uid(),\n answerType: SubjectType.PAGE_END,\n }\n}\n\nexport function isPageBreakItem(item: SubjectLikeItem | null | undefined): item is PageBreakItem {\n return !!item && item.answerType === SubjectType.PAGE_END\n}\n\nexport function normalizePageBreaks(items: SubjectLikeItem[]): SubjectLikeItem[] {\n const normalized = items.map(item => ({ ...item }))\n const compacted: SubjectLikeItem[] = []\n let hasEncounteredQuestion = false\n\n normalized.forEach((item) => {\n if (!item) {\n return\n }\n if (isPageBreakItem(item)) {\n if (!hasEncounteredQuestion) {\n return\n }\n if (isPageBreakItem(compacted[compacted.length - 1])) {\n return\n }\n compacted.push({\n ...item,\n customId: item.customId || uid(),\n })\n return\n }\n hasEncounteredQuestion = true\n compacted.push(item)\n })\n\n while (compacted.length > 0 && isPageBreakItem(compacted[compacted.length - 1])) {\n compacted.pop()\n }\n\n return compacted\n}\n\nexport function rebuildPageBreaksFromPageIndex(items: SubjectLikeItem[]): SubjectLikeItem[] {\n const normalizedItems = items\n .filter(item => !isPageBreakItem(item))\n .map(item => ({ ...item }))\n\n if (!normalizedItems.length) {\n return []\n }\n\n const rebuilt: SubjectLikeItem[] = []\n let lastSourcePageIndex = 1\n\n normalizedItems.forEach((item, index) => {\n const nextPageIndex = Number(item.pageIndex) > 0 ? Number(item.pageIndex) : lastSourcePageIndex\n\n if (index > 0 && nextPageIndex > lastSourcePageIndex) {\n rebuilt.push(createPageBreak())\n }\n\n rebuilt.push(item)\n lastSourcePageIndex = nextPageIndex\n })\n\n return normalizePageBreaks(rebuilt)\n}\n\nexport function serializeSubjectsWithPageIndex(items: SubjectLikeItem[]): SubjectLikeItem[] {\n const serialized: SubjectLikeItem[] = []\n let pageIndex = 1\n let pendingBoundaryCount = 0\n\n items.forEach((item) => {\n if (!item) {\n return\n }\n if (isPageBreakItem(item)) {\n if (serialized.length > 0) {\n pendingBoundaryCount += 1\n }\n return\n }\n if (pendingBoundaryCount > 0) {\n pageIndex += pendingBoundaryCount\n pendingBoundaryCount = 0\n }\n serialized.push({\n ...item,\n pageIndex,\n })\n })\n\n return serialized\n}\n\nexport function insertPageBreak(items: SubjectLikeItem[], index?: number): SubjectLikeItem[] {\n const normalized = normalizePageBreaks(items)\n const next = [...normalized]\n\n if (next.length === 0) {\n return next\n }\n\n if (index === undefined || index < 0 || index >= next.length - 1) {\n next.push(createPageBreak())\n return normalizePageBreaks(next)\n }\n\n next.splice(index + 1, 0, createPageBreak())\n return normalizePageBreaks(next)\n}\n\nexport function removePageBreak(items: SubjectLikeItem[], customId: string): SubjectLikeItem[] {\n return normalizePageBreaks(items.filter(item => !(isPageBreakItem(item) && item.customId === customId)))\n}\n\nexport function getPaginationMeta(items: SubjectLikeItem[]): PaginationMetaItem[] {\n const normalized = normalizePageBreaks(items)\n const totalPage = normalized.filter(item => isPageBreakItem(item)).length + 1\n let currentPageIndex = 1\n\n return normalized.reduce<PaginationMetaItem[]>((result, item, itemIndex) => {\n if (!isPageBreakItem(item)) {\n return result\n }\n result.push({\n customId: item.customId,\n currentPageIndex,\n totalPage,\n itemIndex,\n })\n currentPageIndex += 1\n return result\n }, [])\n}\n"],"names":["createPageBreak","customId","uid","answerType","SubjectType","PAGE_END","isPageBreakItem","item","normalizePageBreaks","items","normalized","map","compacted","hasEncounteredQuestion","forEach","length","push","pop","rebuildPageBreaksFromPageIndex","normalizedItems","filter","rebuilt","lastSourcePageIndex","index","nextPageIndex","Number","pageIndex","serializeSubjectsWithPageIndex","serialized","pendingBoundaryCount","insertPageBreak","next","splice","removePageBreak","getPaginationMeta","totalPage","currentPageIndex","reduce","result","itemIndex"],"mappings":"gFAsBA,SAASA,IACP,MAAO,CACLC,SAAUC,IACVC,WAAYC,EAAYC,SAE5B,CAEO,SAASC,EAAgBC,GAC9B,QAASA,G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AAVR,GAAuBA,EAAQ,GAAKA,GAASQ,EAAKhB,OAAS,GAC7DgB,EAAKf,KAAKhB,KACHQ,EAAoBuB,KAG7BA,EAAKC,OAAOT,EAAQ,EAAG,EAAGvB,KACnBQ,EAAoBuB,GAC7B,CAEO,SAASE,EAAgBxB,EAA0BR,GACxD,OAAOO,EAAoBC,EAAMW,OAAOb,KAAUD,EAAgBC,IAASA,EAAKN,WAAaA,IAC/F,CAEO,SAASiC,EAAkBzB,GAChC,MAAMC,EAAaF,EAAoBC,GACjC0B,EAAYzB,EAAWU,OAAOb,GAAQD,EAAgBC,IAAOQ,OAAS,EAC5E,IAAIqB,EAAmB,EAEvB,OAAO1B,EAAW2B,OAA6B,CAACC,EAAQ/B,EAAMgC,IACvDjC,EAAgBC,IAGrB+B,EAAOtB,KAAK,CACVf,SAAUM,EAAKN,SACfmC,mBACAD,YACAI,cAEFH,GAAoB,EACbE,GATEA,EAUR,GACL"}
@@ -0,0 +1,2 @@
1
+ import{serializeSubjectsWithPageIndex as n}from"./pagination.mjs";import{SubjectError as t}from"./single.mjs";const o=["qxs-subject-single","qxs-blank-fill","qxs-text-fill","qxs-scale","qxs-page-end"].join(", ");function e(n){return Array.from(n.querySelectorAll(o))}function r(n){const t=[];for(const o of n){if("function"!=typeof o.validate)continue;const n=o.validate();Array.isArray(n)&&n.length&&t.push(...n)}return{valid:0===t.length,errors:t}}async function s(o){const e=[],r=[];for(const n of o)if("function"==typeof n.toJSON)try{e.push(await n.toJSON())}catch(n){n instanceof t?r.push(n):r.push(new t(n?.message||"未知错误","UNKNOWN","unknown"))}if(r.length)throw r;return n(e)}export{o as SUBJECT_ELEMENT_SELECTOR,e as collectSubjectElements,s as serializeSubjectElements,r as validateSubjectElements};
2
+ //# sourceMappingURL=runtime.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.mjs","sources":["../../../../packages/components-wc/src/subject/runtime.ts"],"sourcesContent":["import { serializeSubjectsWithPageIndex } from './pagination'\nimport { SubjectError } from './single'\n\nexport const SUBJECT_ELEMENT_SELECTOR = [\n 'qxs-subject-single',\n 'qxs-blank-fill',\n 'qxs-text-fill',\n 'qxs-scale',\n 'qxs-page-end',\n].join(', ')\n\nexport type SubjectElement = HTMLElement & {\n toJSON?: () => Promise<any>\n validate?: () => SubjectError[]\n}\n\nexport function collectSubjectElements(root: ParentNode): SubjectElement[] {\n return Array.from(root.querySelectorAll<SubjectElement>(SUBJECT_ELEMENT_SELECTOR))\n}\n\nexport function validateSubjectElements(elements: Iterable<SubjectElement>): { valid: boolean, errors: SubjectError[] } {\n const errors: SubjectError[] = []\n\n for (const element of elements) {\n if (typeof element.validate !== 'function') {\n continue\n }\n const nextErrors = element.validate()\n if (Array.isArray(nextErrors) && nextErrors.length) {\n errors.push(...nextErrors)\n }\n }\n\n return {\n valid: errors.length === 0,\n errors,\n }\n}\n\nexport async function serializeSubjectElements(elements: Iterable<SubjectElement>): Promise<any[]> {\n const results: any[] = []\n const errors: SubjectError[] = []\n\n for (const element of elements) {\n if (typeof element.toJSON !== 'function') {\n continue\n }\n try {\n results.push(await element.toJSON())\n }\n catch (error: any) {\n if (error instanceof SubjectError) {\n errors.push(error)\n }\n else {\n errors.push(new SubjectError(error?.message || '未知错误', 'UNKNOWN', 'unknown'))\n }\n }\n }\n\n if (errors.length) {\n throw errors\n }\n\n return serializeSubjectsWithPageIndex(results)\n}\n"],"names":["SUBJECT_ELEMENT_SELECTOR","join","collectSubjectElements","root","Array","from","querySelectorAll","validateSubjectElements","elements","errors","element","validate","nextErrors","isArray","length","push","valid","async","serializeSubjectElements","results","toJSON","error","SubjectError","message","serializeSubjectsWithPageIndex"],"mappings":"oHAGaA,EAA2B,CACtC,qBACA,iBACA,gBACA,YACA,gBACAC,KAAK,MAOA,SAASC,EAAuBC,GACrC,OAAOC,MAAMC,KAAKF,EAAKG,iBAAiCN,GAC1D,CAEO,SAASO,EAAwBC,GACtC,MAAMC,EAAyB,GAE/B,IAAA,MAAWC,KAAWF,EAAU,CAC9B,GAAgC,mBAArBE,EAAQC,SACjB,SAEF,MAAMC,EAAaF,EAAQC,WACvBP,MAAMS,QAAQD,IAAeA,EAAWE,QAC1CL,EAAOM,QAAQH,EAEnB,CAEA,MAAO,CACLI,MAAyB,IAAlBP,EAAOK,OACdL,SAEJ,CAEAQ,eAAsBC,EAAyBV,GAC7C,MAAMW,EAAiB,GACjBV,EAAyB,GAE/B,IAAA,MAAWC,KAAWF,EACpB,GAA8B,mBAAnBE,EAAQU,OAGnB,IACED,EAAQJ,WAAWL,EAAQU,SAC7B,OACOC,GACDA,aAAiBC,EACnBb,EAAOM,KAAKM,GAGZZ,EAAOM,KAAK,IAAIO,EAAaD,GAAOE,SAAW,OAAQ,UAAW,WAEtE,CAGF,GAAId,EAAOK,OACT,MAAML,EAGR,OAAOe,EAA+BL,EACxC"}