UNPKG

@tripetto/block-checkboxes

Version:

Checkboxes block for Tripetto.

3 lines (2 loc) 26.5 kB
/*! Tripetto Checkboxes Block 7.1.1 - Copyright (C) 2023 Tripetto B.V. - All Rights Reserved */ import{Collection as e,markdownifyToString as o,Markdown as t,Slots as i,pgettext as c,Forms as l,insertVariable as s,isString as a,isBoolean as n,definition as b,name as r,alias as u,affects as d,score as h,created as x,reordered as k,renamed as M,refreshed as N,deleted as m,editor as g,collection as p,tripetto as v,ConditionBlock as S,isNumberFinite as A,L10n as w,lookupVariable as L,populateVariables as j,NodeBlock as D,npgettext as I,isNumber as f,each as C,slots as y,conditions as T}from"@tripetto/builder";function z(e,o,t,i){var c,l=arguments.length,s=l<3?o:null===i?i=Object.getOwnPropertyDescriptor(o,t):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,o,t,i);else for(var a=e.length-1;a>=0;a--)(c=e[a])&&(s=(l<3?c(s):l>3?c(o,t,s):c(o,t))||s);return l>3&&s&&Object.defineProperty(o,t,s),s}class E extends e.Item{constructor(){super(...arguments),this.name=""}defineSlot(){const e=this.name&&o(this.name,t.MarkdownFeatures.Formatting|t.MarkdownFeatures.Hyperlinks)||void 0,l=this.ref.slots.dynamic({type:i.Boolean,reference:this.id,label:c("block:checkboxes","Checkbox"),sequence:this.index,name:e,alias:this.value,required:this.ref.required,exportable:"concatenate"!==this.ref.format&&this.ref.exportable,pipeable:{label:c("block:checkboxes","Checkbox"),content:this.name!==e?{string:e||"",markdown:this.name}:"name",alias:this.ref.alias,legacy:"Checkbox"}});l.labelForTrue=this.labelForTrue||this.ref.labelForTrue||c("block:checkboxes","Checked"),l.labelForFalse=this.labelForFalse||this.ref.labelForFalse||c("block:checkboxes","Not checked")}deleteSlot(){this.ref.slots.delete(this.id,"dynamic")}defineEditor(){this.editor.option({name:c("block:checkboxes","Name"),form:{title:c("block:checkboxes","Checkbox name"),controls:[new l.Text("singleline",l.Text.bind(this,"name","")).action("@",s(this)).autoFocus().autoSelect().enter(this.editor.close).escape(this.editor.close)]},locked:!0}),this.editor.option({name:c("block:checkboxes","Description"),form:{title:c("block:checkboxes","Description"),controls:[new l.Text("multiline",l.Text.bind(this,"description",void 0)).action("@",s(this))]},activated:a(this.description)}),this.editor.group(c("block:checkboxes","Options")),this.editor.option({name:c("block:checkboxes","Exclusivity"),form:{title:c("block:checkboxes","Exclusivity"),controls:[new l.Checkbox(c("block:checkboxes","Uncheck all other checkboxes when checked"),l.Checkbox.bind(this,"exclusive",void 0,!0))]},activated:n(this.exclusive)});const e=c("block:checkboxes","Checked"),o=c("block:checkboxes","Not checked");this.editor.option({name:c("block:checkboxes","Labels"),form:{title:c("block:checkboxes","Labels"),controls:[new l.Text("singleline",l.Text.bind(this,"labelForTrue",void 0)).placeholder(e),new l.Text("singleline",l.Text.bind(this,"labelForFalse",void 0)).placeholder(o),new l.Static(c("block:checkboxes","These labels will be used in the dataset and override the default values %1 and %2.",`**${e}**`,`**${o}**`)).markdown()]},activated:a(this.labelForTrue)||a(this.labelForFalse)}),this.editor.option({name:c("block:checkboxes","Identifier"),form:{title:c("block:checkboxes","Identifier"),controls:[new l.Text("singleline",l.Text.bind(this,"value",void 0)),new l.Static(c("block:checkboxes","If a checkbox identifier is set, this identifier will be used instead of the label."))]},activated:a(this.value)});const t=this.ref.slots.select("score","feature");this.editor.option({name:c("block:checkboxes","Score"),form:{title:c("block:checkboxes","Score"),controls:[new l.Numeric(l.Numeric.bind(this,"score",void 0)).precision((null==t?void 0:t.precision)||0).digits((null==t?void 0:t.digits)||0).decimalSign((null==t?void 0:t.decimal)||"").thousands(!!(null==t?void 0:t.separator),(null==t?void 0:t.separator)||"").prefix((null==t?void 0:t.prefix)||"").prefixPlural((null==t?void 0:t.prefixPlural)||void 0).suffix((null==t?void 0:t.suffix)||"").suffixPlural((null==t?void 0:t.suffixPlural)||void 0)]},activated:!0,locked:!!t,disabled:!t})}}z([b("string"),r],E.prototype,"name",void 0),z([b("string","optional")],E.prototype,"description",void 0),z([b("string","optional"),u],E.prototype,"value",void 0),z([b("string","optional"),d("#refresh")],E.prototype,"labelForTrue",void 0),z([b("string","optional"),d("#refresh")],E.prototype,"labelForFalse",void 0),z([b("number","optional"),h],E.prototype,"score",void 0),z([b("boolean","optional"),d("#name")],E.prototype,"exclusive",void 0),z([x,k,M,N],E.prototype,"defineSlot",null),z([m],E.prototype,"deleteSlot",null),z([g],E.prototype,"defineEditor",null);var U="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCI+PHBhdGggZD0iTTE3LjUgMjBoLTE2Qy42NzMgMjAgMCAxOS4zMjcgMCAxOC41di0xNkMwIDEuNjczLjY3MyAxIDEuNSAxaDE2Yy44MjcgMCAxLjUuNjczIDEuNSAxLjV2MTZjMCAuODI3LS42NzMgMS41LTEuNSAxLjV6TTEuNSAyYS41LjUgMCAwIDAtLjUuNXYxNmEuNS41IDAgMCAwIC41LjVoMTZhLjUuNSAwIDAgMCAuNS0uNXYtMTZhLjUuNSAwIDAgMC0uNS0uNWgtMTZ6IiBjbGFzcz0idHJpcGV0dG8tZmlsbCIvPjxwYXRoIGQ9Ik03LjUgMTQuNWEuNTAyLjUwMiAwIDAgMS0uMzU0LS4xNDZsLTMtM2EuNS41IDAgMCAxIC43MDctLjcwN2wyLjY0NiAyLjY0NiA2LjY0Ni02LjY0NmEuNS41IDAgMCAxIC43MDcuNzA3bC03IDdhLjQ5OC40OTggMCAwIDEtLjM1NC4xNDZ6IiBjbGFzcz0idHJpcGV0dG8tZmlsbCIvPjwvc3ZnPg==",Y="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCI+PHBhdGggZD0iTTE3LjUgMjBoLTE2Qy42NzMgMjAgMCAxOS4zMjcgMCAxOC41di0xNkMwIDEuNjczLjY3MyAxIDEuNSAxaDE2Yy44MjcgMCAxLjUuNjczIDEuNSAxLjV2MTZjMCAuODI3LS42NzMgMS41LTEuNSAxLjV6TTEuNSAyYS41LjUgMCAwIDAtLjUuNXYxNmEuNS41IDAgMCAwIC41LjVoMTZhLjUuNSAwIDAgMCAuNS0uNXYtMTZhLjUuNSAwIDAgMC0uNS0uNWgtMTZ6IiBjbGFzcz0idHJpcGV0dG8tZmlsbCIvPjwvc3ZnPg==";let O=class extends S{constructor(){super(...arguments),this.checked=!0}get icon(){return this.checked?U:Y}get name(){var e;return o((null===(e=this.checkbox)||void 0===e?void 0:e.name)||"")||this.type.label}defineEditor(){var e;this.editor.form({controls:[new l.Checkbox(o((null===(e=this.checkbox)||void 0===e?void 0:e.name)||"")||c("block:checkboxes","Checkbox is checked"),l.Checkbox.bind(this,"checked",!0))]})}};z([d("#name"),p("#checkboxes")],O.prototype,"checkbox",void 0),z([d("#icon"),b],O.prototype,"checked",void 0),z([g],O.prototype,"defineEditor",null),O=z([v({type:"condition",legacyBlock:!0,context:"@tripetto/block-checkboxes",identifier:"@tripetto/block-checkboxes",version:"7.1.1",icon:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCI+PHBhdGggZD0iTTE2LjIzIDMuMzA3Yy0uMzk2LS4yNjgtLjk0OS0uNTA0LTEuNjQzLS43MDJDMTMuMjIxIDIuMjE1IDExLjQxNSAyIDkuNSAycy0zLjcyMi4yMTUtNS4wODcuNjA1Yy0uNjk0LjE5OC0xLjI0Ni40MzQtMS42NDMuNzAyLS42MzcuNDMtLjc3Ljg4Ni0uNzcgMS4xOTNWNWMwIC40MjguMzIxIDEuMTMzLjYzOSAxLjYwOWw0Ljg5MSA3LjMzNmMuMjUxLjM3Ni40NzEgMS4xMDMuNDcxIDEuNTU1djNhLjUuNSAwIDAgMCAuNzI0LjQ0N2wyLTFhLjUuNSAwIDAgMCAuMjc2LS40NDd2LTJjMC0uNDUyLjIyLTEuMTc5LjQ3MS0xLjU1NWw0Ljg5MS03LjMzNmMuMzE3LS40NzYuNjM5LTEuMTgyLjYzOS0xLjYwOXYtLjVjMC0uMzA3LS4xMzQtLjc2My0uNzctMS4xOTN6bS0xMS41NDIuMjZDNS45NjcgMy4yMDIgNy42NzYgMyA5LjUgM3MzLjUzNC4yMDEgNC44MTIuNTY3QzE1LjY5IDMuOTYxIDE2IDQuMzgzIDE2IDQuNXMtLjMxLjU0LTEuNjg4LjkzM0MxMy4wMzMgNS43OTggMTEuMzI0IDYgOS41IDZzLTMuNTM0LS4yMDEtNC44MTItLjU2N0MzLjMxIDUuMDM5IDMgNC42MTcgMyA0LjVzLjMxLS41NCAxLjY4OC0uOTMzem01Ljk1MSA5LjgyNGMtLjM1OC41MzctLjYzOSAxLjQ2NC0uNjM5IDIuMTA5djEuNjkxbC0xIC41VjE1LjVjMC0uNjQ2LS4yODEtMS41NzItLjYzOS0yLjEwOWwtNC44OC03LjMyYy4yNzQuMTE3LjU4NS4yMjYuOTMyLjMyNEM1Ljc3OSA2Ljc4NSA3LjU4NSA3IDkuNSA3czMuNzIyLS4yMTUgNS4wODctLjYwNWMuMzQ2LS4wOTkuNjU4LS4yMDcuOTMyLS4zMjVsLTQuODggNy4zMnoiIGNsYXNzPSJ0cmlwZXR0by1maWxsIi8+PC9zdmc+",get label(){return c("block:checkboxes","Checkbox state")}})],O);let Z=class extends S{};Z=z([v({type:"condition",legacyBlock:!0,context:"@tripetto/block-checkboxes",identifier:"@tripetto/block-checkboxes:unchecked",version:"7.1.1",icon:Y,get label(){return c("block:checkboxes","All checkboxes unchecked")}})],Z);var F="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCI+PHBhdGggZD0iTTE4LjUgOEgxM1YzLjVhLjUuNSAwIDAgMC0uNS0uNWgtNmEuNS41IDAgMCAwLS41LjVWNkguNWEuNS41IDAgMCAwLS41LjV2MTBhLjUuNSAwIDAgMCAuNS41aDE4YS41LjUgMCAwIDAgLjUtLjV2LThhLjUuNSAwIDAgMC0uNS0uNXpNNyA0aDV2MTJIN1Y0ek0xIDdoNXY5SDFWN3ptMTcgOWgtNVY5aDV2N3oiIGNsYXNzPSJ0cmlwZXR0by1maWxsIi8+PHBhdGggZD0iTTkuNSAxMGEuNS41IDAgMCAxLS41LS41di00YS41LjUgMCAwIDEgMSAwdjRhLjUuNSAwIDAgMS0uNS41em0tNSAzaC0yYS41LjUgMCAwIDEtLjUtLjV2LTJhLjUuNSAwIDAgMSAuNS0uNUg0VjlIMi41YS41LjUgMCAwIDEgMC0xaDJhLjUuNSAwIDAgMSAuNS41djJhLjUuNSAwIDAgMS0uNS41SDN2MWgxLjVhLjUuNSAwIDAgMSAwIDF6bTEyLTNoLTJhLjUuNSAwIDAgMCAwIDFIMTZ2MWgtMS41YS41LjUgMCAwIDAgMCAxSDE2djFoLTEuNWEuNS41IDAgMCAwIDAgMWgyYS41LjUgMCAwIDAgLjUtLjV2LTRhLjUuNSAwIDAgMC0uNS0uNXoiIGNsYXNzPSJ0cmlwZXR0by1maWxsIi8+PC9zdmc+";let P=class extends S{constructor(){super(...arguments),this.allowMarkdown=!0,this.mode="equal"}get label(){return""}get name(){const e=this.slot;if(e instanceof i.Numeric){const o=this.parse(e,this.value);switch(this.mode){case"between":return`${o} ≤ @${e.id} ≤ ${this.parse(e,this.to)}`;case"not-between":return`@${e.id} < ${o} ${c("block:checkboxes","or")} @${e.id} > ${this.parse(e,this.to)}`;case"defined":return`@${e.id} ${c("block:checkboxes","calculated")}`;case"undefined":return`@${e.id} ${c("block:checkboxes","not calculated")}`;case"not-equal":return`@${e.id} ≠ ${o}`;case"above":case"below":case"equal":return`@${e.id} ${"above"===this.mode?">":"below"===this.mode?"<":"="} ${o}`}}return this.type.label}get title(){var e,o;return(null===(e=this.slot)||void 0===e?void 0:e.label)||(null===(o=this.node)||void 0===o?void 0:o.label)}parse(e,o){var t;return A(o)?e.toString(o,((e,o)=>w.locale.number(e,o,!1))):a(o)&&o&&(null===(t=L(this,o))||void 0===t?void 0:t.label)?`@${o}`:"\\_\\_"}defineEditor(){this.editor.form({title:c("block:checkboxes","Compare mode"),controls:[new l.Radiobutton([{label:c("block:checkboxes","Score is equal to"),value:"equal"},{label:c("block:checkboxes","Score is not equal to"),value:"not-equal"},{label:c("block:checkboxes","Score is lower than"),value:"below"},{label:c("block:checkboxes","Score is higher than"),value:"above"},{label:c("block:checkboxes","Score is between"),value:"between"},{label:c("block:checkboxes","Score is not between"),value:"not-between"},{label:c("block:checkboxes","Score is calculated"),value:"defined"},{label:c("block:checkboxes","Score is not calculated"),value:"undefined"}],l.Radiobutton.bind(this,"mode","equal")).on((e=>{switch(o.visible("defined"!==e.value&&"undefined"!==e.value),t.visible("between"===e.value||"not-between"===e.value),e.value){case"equal":o.title=c("block:checkboxes","If score equals");break;case"not-equal":o.title=c("block:checkboxes","If score not equals");break;case"below":o.title=c("block:checkboxes","If score is lower than");break;case"above":o.title=c("block:checkboxes","If score is higher than");break;case"between":o.title=c("block:checkboxes","If score is between");break;case"not-between":o.title=c("block:checkboxes","If score is not between")}}))]});const e=(e,o,t)=>{var s;const n=this[e],b=this.slot,r=new l.Numeric(A(n)?n:0).label(c("block:checkboxes","Use fixed number")).precision((null==b?void 0:b.precision)||0).digits((null==b?void 0:b.digits)||0).decimalSign((null==b?void 0:b.decimal)||"").thousands(!!(null==b?void 0:b.separator),(null==b?void 0:b.separator)||"").prefix((null==b?void 0:b.prefix)||"").prefixPlural((null==b?void 0:b.prefixPlural)||void 0).suffix((null==b?void 0:b.suffix)||"").suffixPlural((null==b?void 0:b.suffixPlural)||void 0).autoFocus("value"===e).escape(this.editor.close).enter((()=>("between"!==this.mode&&"not-between"!==this.mode||"to"===e)&&this.editor.close())).on((o=>{o.isFormVisible&&o.isObservable&&(this[e]=o.value)})),u=j(this,(e=>e instanceof i.Number||e instanceof i.Numeric),a(n)?n:void 0,!0,null===(s=this.slot)||void 0===s?void 0:s.id),d=new l.Dropdown(u,a(n)?n:"").label(c("block:checkboxes","Use value of")).width("full").on((o=>{o.isFormVisible&&o.isObservable&&(this[e]=o.value||"")}));return this.editor.form({title:o,controls:[new l.Radiobutton([{label:c("block:checkboxes","Number"),value:"number"},{label:c("block:checkboxes","Value"),value:"variable",disabled:0===u.length}],a(n)?"variable":"number").on((e=>{r.visible("number"===e.value),d.visible("variable"===e.value),r.isObservable&&r.focus()})),r,d]}).visible(t)},o=e("value",c("block:checkboxes","If score equals"),"defined"!==this.mode&&"undefined"!==this.mode),t=e("to",c("block:checkboxes","And"),"between"===this.mode||"not-between"===this.mode)}};z([b,d("#name")],P.prototype,"mode",void 0),z([b,d("#name")],P.prototype,"value",void 0),z([b,d("#name")],P.prototype,"to",void 0),z([g],P.prototype,"defineEditor",null),P=z([v({type:"condition",legacyBlock:!0,context:"@tripetto/block-checkboxes",identifier:"@tripetto/block-checkboxes:score",version:"7.1.1",icon:F,get label(){return c("block:checkboxes","Verify score")}})],P);var V="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCI+PHBhdGggZD0iTTIgNmEuNTAyLjUwMiAwIDAgMS0uMzU0LS4xNDZsLTEuNS0xLjVhLjUuNSAwIDAgMSAuNzA3LS43MDdsMS4xNDYgMS4xNDZMNi4xNDUuNjQ3YS41LjUgMCAwIDEgLjcwNy43MDdsLTQuNSA0LjVBLjQ5OC40OTggMCAwIDEgMS45OTggNnptMTcuNS0xaC0xMmEuNS41IDAgMCAxIDAtMWgxMmEuNS41IDAgMCAxIDAgMXpNMiAxM2EuNTAyLjUwMiAwIDAgMS0uMzU0LS4xNDZsLTEuNS0xLjVhLjUuNSAwIDAgMSAuNzA3LS43MDdsMS4xNDYgMS4xNDYgNC4xNDYtNC4xNDZhLjUuNSAwIDAgMSAuNzA3LjcwN2wtNC41IDQuNWEuNDk4LjQ5OCAwIDAgMS0uMzU0LjE0NnptMTcuNS0xaC0xMmEuNS41IDAgMCAxIDAtMWgxMmEuNS41IDAgMCAxIDAgMXpNMiAyMGEuNTAyLjUwMiAwIDAgMS0uMzU0LS4xNDZsLTEuNS0xLjVhLjUuNSAwIDAgMSAuNzA3LS43MDdsMS4xNDYgMS4xNDYgNC4xNDYtNC4xNDZhLjUuNSAwIDAgMSAuNzA3LjcwN2wtNC41IDQuNWEuNDk4LjQ5OCAwIDAgMS0uMzU0LjE0NnptMTcuNS0xaC0xMmEuNS41IDAgMCAxIDAtMWgxMmEuNS41IDAgMCAxIDAgMXoiIGNsYXNzPSJ0cmlwZXR0by1maWxsIi8+PC9zdmc+";let q=class extends S{constructor(){super(...arguments),this.allowMarkdown=!0,this.mode="equal"}get label(){return""}get name(){const e=this.slot;if(e instanceof i.Number){const o=this.parse(e,this.value);switch(this.mode){case"between":return`${o} ≤ @${e.id} ≤ ${this.parse(e,this.to)}`;case"not-between":return`@${e.id} < ${o} ${c("block:checkboxes","or")} @${e.id} > ${this.parse(e,this.to)}`;case"not-equal":return`@${e.id} ≠ ${o}`;case"above":case"below":case"equal":return`@${e.id} ${"above"===this.mode?">":"below"===this.mode?"<":"="} ${o}`}}return this.type.label}get title(){var e,o;return(null===(e=this.slot)||void 0===e?void 0:e.label)||(null===(o=this.node)||void 0===o?void 0:o.label)}parse(e,o){var t;return A(o)?e.toString(o,(e=>w.locale.number(e,0,!1))):a(o)&&o&&(null===(t=L(this,o))||void 0===t?void 0:t.label)?`@${o}`:"\\_\\_"}defineEditor(){this.editor.form({title:c("block:checkboxes","Compare mode"),controls:[new l.Radiobutton([{label:c("block:checkboxes","Counter is equal to"),value:"equal"},{label:c("block:checkboxes","Counter is not equal to"),value:"not-equal"},{label:c("block:checkboxes","Counter is lower than"),value:"below"},{label:c("block:checkboxes","Counter is higher than"),value:"above"},{label:c("block:checkboxes","Counter is between"),value:"between"},{label:c("block:checkboxes","Counter is not between"),value:"not-between"}],l.Radiobutton.bind(this,"mode","equal")).on((e=>{switch(t.visible("between"===e.value||"not-between"===e.value),e.value){case"equal":o.title=c("block:checkboxes","If counter equals");break;case"not-equal":o.title=c("block:checkboxes","If counter not equals");break;case"below":o.title=c("block:checkboxes","If counter is lower than");break;case"above":o.title=c("block:checkboxes","If counter is higher than");break;case"between":o.title=c("block:checkboxes","If counter is between");break;case"not-between":o.title=c("block:checkboxes","If counter is not between")}}))]});const e=(e,o)=>{var t;const s=this[e],n=new l.Numeric(A(s)?s:0).label(c("block:checkboxes","Use fixed number")).autoFocus("value"===e).escape(this.editor.close).enter((()=>("between"!==this.mode&&"not-between"!==this.mode||"to"===e)&&this.editor.close())).on((o=>{o.isFormVisible&&o.isObservable&&(this[e]=o.value)})),b=j(this,(e=>e instanceof i.Number||e instanceof i.Numeric),a(s)?s:void 0,!0,null===(t=this.slot)||void 0===t?void 0:t.id),r=new l.Dropdown(b,a(s)?s:"").label(c("block:checkboxes","Use value of")).width("full").on((o=>{o.isFormVisible&&o.isObservable&&(this[e]=o.value||"")}));return this.editor.form({title:o,controls:[new l.Radiobutton([{label:c("block:checkboxes","Number"),value:"number"},{label:c("block:checkboxes","Value"),value:"variable",disabled:0===b.length}],a(s)?"variable":"number").on((e=>{n.visible("number"===e.value),r.visible("variable"===e.value),n.isObservable&&n.focus()})),n,r]})},o=e("value",c("block:checkboxes","If counter equals")),t=e("to",c("block:checkboxes","And"))}};z([b,d("#name")],q.prototype,"mode",void 0),z([b,d("#name")],q.prototype,"value",void 0),z([b,d("#name")],q.prototype,"to",void 0),z([g],q.prototype,"defineEditor",null),q=z([v({type:"condition",legacyBlock:!0,context:"@tripetto/block-checkboxes",identifier:"@tripetto/block-checkboxes:counter",version:"7.1.1",icon:V,get label(){return c("block:checkboxes","Verify counter")}})],q);let W=class extends D{constructor(){super(...arguments),this.checkboxes=e.of(E,this)}get label(){return I("block:checkboxes","%2 (%1 checkbox)","%2 (%1 checkboxes)",this.checkboxes.count,this.type.label)}defineSlot(){this.slots.meta({type:i.Number,reference:"counter",label:c("block:checkboxes","Counter"),exportable:!1,protected:!0}),"concatenate"===this.format||"both"===this.format?this.slots.feature({type:i.Text,reference:"concatenation",label:c("block:checkboxes","Text value"),exportable:this.exportable,alias:this.alias,protected:!0}):this.slots.delete("concatenation","feature")}defineEditor(){this.editor.name(),this.editor.description(),this.editor.explanation();const e=this.editor.collection({collection:this.checkboxes,title:c("block:checkboxes","Checkboxes"),icon:U,placeholder:c("block:checkboxes","Unnamed checkbox"),sorting:"manual",autoOpen:!0,allowVariables:!0,allowImport:!0,allowExport:!0,allowDedupe:!0,showAliases:!0,markdown:t.MarkdownFeatures.Formatting|t.MarkdownFeatures.Hyperlinks,indicator:e=>e.exclusive&&c("block:checkboxes","Exclusive").toUpperCase()||void 0,emptyMessage:c("block:checkboxes","Click the + button to add a checkbox...")});this.editor.groups.settings();const o=new l.Numeric(l.Numeric.bind(this,"min",void 0)).min(1).max(this.max).visible(f(this.min)).indent(32).width(75).on((()=>{i.min(this.min||1)})),i=new l.Numeric(l.Numeric.bind(this,"max",void 0)).min(this.min||1).visible(f(this.max)).indent(32).width(75).on((()=>{o.max(this.max)}));this.editor.option({name:c("block:checkboxes","Limits"),form:{title:c("block:checkboxes","Limits"),controls:[new l.Checkbox(c("block:checkboxes","Minimum number of selected checkboxes"),f(this.min)).on((e=>{o.visible(e.isChecked)})),o,new l.Checkbox(c("block:checkboxes","Maximum number of selected checkboxes"),f(this.max)).on((e=>{i.visible(e.isChecked)})),i]},activated:f(this.max)||f(this.min)}),this.editor.option({name:c("block:checkboxes","Randomization"),form:{title:c("block:checkboxes","Randomization"),controls:[new l.Checkbox(c("block:checkboxes","Randomize the checkboxes (using [Fisher-Yates shuffle](%1))","https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle"),l.Checkbox.bind(this,"randomize",void 0,!0)).markdown()]},activated:n(this.randomize)}),this.editor.groups.options(),this.editor.required(this),this.editor.visibility();const s=c("block:checkboxes","Checked"),b=c("block:checkboxes","Not checked");this.editor.option({name:c("block:checkboxes","Labels"),form:{title:c("block:checkboxes","Labels"),controls:[new l.Text("singleline",l.Text.bind(this,"labelForTrue",void 0)).placeholder(s),new l.Text("singleline",l.Text.bind(this,"labelForFalse",void 0)).placeholder(b),new l.Static(c("block:checkboxes","These labels will be used in the dataset and override the default values %1 and %2.",`**${s}**`,`**${b}**`)).markdown()]},activated:a(this.labelForTrue)||a(this.labelForFalse)}),this.editor.scores({target:this,collection:e,description:c("block:checkboxes","Generates a score based on the selected checkboxes. Open the settings panel for each checkbox to set the individual score for that checkbox.")});const r=this.editor.alias(this).disabled("concatenate"!==this.format&&"both"!==this.format),u=new l.Text("singleline",l.Text.bind(this,"formatSeparatorCustom",void 0)).visible("custom"===this.formatSeparator).sanitize(!1).width(200).label(c("block:checkboxes","Use this separator:")),d=new l.Group([new l.Dropdown([{label:c("block:checkboxes","Comma separated"),value:"comma"},{label:c("block:checkboxes","Space separated"),value:"space"},{label:c("block:checkboxes","List on multiple lines"),value:"list"},{label:c("block:checkboxes","Bulleted list"),value:"bullets"},{label:c("block:checkboxes","Numbered list"),value:"numbers"},{label:c("block:checkboxes","Language sensitive conjunction (_, _, and _)"),value:"conjunction"},{label:c("block:checkboxes","Language sensitive disjunction (_, _, or _)"),value:"disjunction"},{label:c("block:checkboxes","Custom separator"),value:"custom"}],l.Radiobutton.bind(this,"formatSeparator",void 0,"comma")).label(c("block:checkboxes","How to separate the selected checkboxes:")).on((e=>{u.visible("custom"===e.value)})),u]).visible("concatenate"===this.format||"both"===this.format);this.editor.option({name:c("block:checkboxes","Data format"),form:{title:c("block:checkboxes","Data format"),controls:[new l.Radiobutton([{label:c("block:checkboxes","Every checkbox as a separate field"),description:c("block:checkboxes","Every checkbox is included in the dataset as a separate value."),value:"fields"},{label:c("block:checkboxes","Text field with a list of all selected checkboxes"),description:c("block:checkboxes","All the selected checkboxes are concatenated to a single string of text separated using a configurable separator."),value:"concatenate"},{label:c("block:checkboxes","Both options above"),description:c("block:checkboxes","Includes every checkbox in the dataset together with the concatenated text."),value:"both"}],l.Radiobutton.bind(this,"format",void 0,"fields")).label(c("block:checkboxes","This setting determines how the data is stored in the dataset:")).on((e=>{d.visible("concatenate"===e.value||"both"===e.value),r.disabled("concatenate"!==this.format&&"both"!==this.format)})),d]},activated:a(this.format)}),this.editor.exportable(this)}defineConditions(){this.checkboxes.each((e=>{e.name&&this.conditions.template({condition:O,markdown:e.name,icon:U,burst:!0,props:{slot:this.slots.select(e.id),checkbox:e,checked:!0}})})),this.checkboxes.count>0&&this.conditions.template({condition:Z,separator:!0});const e=this.slots.select("counter","meta");if(e&&e.label){const o=this.conditions.group(e.label,V);C([{mode:"equal",label:c("block:checkboxes","Counter is equal to")},{mode:"not-equal",label:c("block:checkboxes","Counter is not equal to")},{mode:"below",label:c("block:checkboxes","Counter is lower than")},{mode:"above",label:c("block:checkboxes","Counter is higher than")},{mode:"between",label:c("block:checkboxes","Counter is between")},{mode:"not-between",label:c("block:checkboxes","Counter is not between")}],(t=>{o.template({condition:q,label:t.label,autoOpen:!0,props:{slot:e,mode:t.mode,value:0,to:"between"===t.mode||"not-between"===t.mode?0:void 0}})}))}const o=this.slots.select("score","feature");if(o&&o.label){const e=this.conditions.group(o.label,F);C([{mode:"equal",label:c("block:checkboxes","Score is equal to")},{mode:"not-equal",label:c("block:checkboxes","Score is not equal to")},{mode:"below",label:c("block:checkboxes","Score is lower than")},{mode:"above",label:c("block:checkboxes","Score is higher than")},{mode:"between",label:c("block:checkboxes","Score is between")},{mode:"not-between",label:c("block:checkboxes","Score is not between")},{mode:"defined",label:c("block:checkboxes","Score is calculated")},{mode:"undefined",label:c("block:checkboxes","Score is not calculated")}],(t=>{e.template({condition:P,label:t.label,autoOpen:"defined"!==t.mode&&"undefined"!==t.mode,props:{slot:o,mode:t.mode,value:0,to:"between"===t.mode||"not-between"===t.mode?0:void 0}})}))}}};z([b("items"),d("#name")],W.prototype,"checkboxes",void 0),z([b("boolean","optional"),d("#required"),d("#collection","checkboxes")],W.prototype,"required",void 0),z([b("number","optional")],W.prototype,"min",void 0),z([b("number","optional")],W.prototype,"max",void 0),z([b("string","optional"),d("#label"),d("#slots"),d("#collection","checkboxes")],W.prototype,"alias",void 0),z([b("boolean","optional"),d("#slots"),d("#collection","checkboxes")],W.prototype,"exportable",void 0),z([b("string","optional"),d("#collection","checkboxes")],W.prototype,"labelForTrue",void 0),z([b("string","optional"),d("#collection","checkboxes")],W.prototype,"labelForFalse",void 0),z([b("boolean","optional")],W.prototype,"randomize",void 0),z([b("string","optional"),d("#slots"),d("#collection","checkboxes")],W.prototype,"format",void 0),z([b("string","optional")],W.prototype,"formatSeparator",void 0),z([b("string","optional")],W.prototype,"formatSeparatorCustom",void 0),z([y],W.prototype,"defineSlot",null),z([g],W.prototype,"defineEditor",null),z([T],W.prototype,"defineConditions",null),W=z([v({type:"node",legacyBlock:!0,identifier:"@tripetto/block-checkboxes",version:"7.1.1",icon:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCI+PHBhdGggZD0iTTIgNmEuNTAyLjUwMiAwIDAgMS0uMzU0LS4xNDZsLTEuNS0xLjVhLjUuNSAwIDAgMSAuNzA3LS43MDdsMS4xNDYgMS4xNDZMNi4xNDUuNjQ3YS41LjUgMCAwIDEgLjcwNy43MDdsLTQuNSA0LjVBLjQ5OC40OTggMCAwIDEgMS45OTggNnptMTcuNS0xaC0xMmEuNS41IDAgMCAxIDAtMWgxMmEuNS41IDAgMCAxIDAgMXpNMiAxM2EuNTAyLjUwMiAwIDAgMS0uMzU0LS4xNDZsLTEuNS0xLjVhLjUuNSAwIDAgMSAuNzA3LS43MDdsMS4xNDYgMS4xNDYgNC4xNDYtNC4xNDZhLjUuNSAwIDAgMSAuNzA3LjcwN2wtNC41IDQuNWEuNDk4LjQ5OCAwIDAgMS0uMzU0LjE0NnptMTcuNS0xaC0xMmEuNS41IDAgMCAxIDAtMWgxMmEuNS41IDAgMCAxIDAgMXpNMiAyMGEuNTAyLjUwMiAwIDAgMS0uMzU0LS4xNDZsLTEuNS0xLjVhLjUuNSAwIDAgMSAuNzA3LS43MDdsMS4xNDYgMS4xNDYgNC4xNDYtNC4xNDZhLjUuNSAwIDAgMSAuNzA3LjcwN2wtNC41IDQuNWEuNDk4LjQ5OCAwIDAgMS0uMzU0LjE0NnptMTcuNS0xaC0xMmEuNS41IDAgMCAxIDAtMWgxMmEuNS41IDAgMCAxIDAgMXoiIGNsYXNzPSJ0cmlwZXR0by1maWxsIi8+PC9zdmc+",get label(){return c("block:checkboxes","Checkboxes")}})],W);export{W as Checkboxes};