UNPKG

4.2 kBJavaScriptView Raw
1/*!
2 * The Sutton SignWriting Web Components
3 */
4import{r as t,h as s,H as e,g as i}from"./p-7486a92a.js";import{c as a,H as l,C as h,A as r,a as c,b as n,d as o}from"./p-66ae5418.js";import{i as p,p as f,b as w,h as m}from"./p-79ff7b68.js";const u=class{constructor(s){t(this,s),this.orientation="vertical",this.major=10,this.minor=3,this.total=30,this.size="small",this.alphabet=p,this.group=null,this.base=null,this.more=!1,this.hasMore=!1,this.lower=!1,this.hasLower=!1,this.palette=[]}parseSizeProp(t){switch(t){case"large":this.major=16,this.minor=6;break;case"medium":this.major=10,this.minor=6;break;case"small":default:this.major=10,this.minor=3}this.total=this.major*this.minor}watchGroup(){null==this.group&&null!=this.base?this.base=null:this.setPalette()}watchBase(){this.setPalette()}watchMore(){this.setPalette()}watchLower(){this.setPalette()}getPaletteAll(){let t=Object.keys(this.alphabet);return"large"==this.size&&(t=f(t,10,16)),t=w(t,this.total),this.more=!1,this.hasMore=!1,this.lower=!1,this.hasLower=!1,t}getPaletteGroup(){let t=this.alphabet[this.group];return"large"==this.size&&(t=f(t,10,16)),t=w(t,this.total),t.length>this.total?(this.hasMore=!0,t=this.more?t.slice(this.total,2*this.total):t.slice(0,this.total)):(this.more=!1,this.hasMore=!1),this.lower=!1,this.hasLower=!1,t}getPaletteBase(){const t=this.base.slice(0,4);let s;const e=t+"18",i=t+"30";let l=0,h=16,r=0,c=6;"large"!=this.size&&(this.hasLower=m(a.key2id(t+"08"))||m(a.key2id(e)),this.lower?l=8:h=8),"small"==this.size&&(this.hasMore=m(a.key2id(i)),this.more?r=3:c=3);let n=[];for(var o=r;o<c;o++)for(var p=l;p<h;p++)s=t+o+p.toString(16),n.push(s);return"large"!=this.size&&(n=f(n,8,10)),n}setPalette(){let t;switch(!0){case!this.group:t=this.getPaletteAll();break;case!!this.group&&!!this.base:t=this.getPaletteBase();break;case!!this.group:t=this.getPaletteGroup()}this.palette=[...t]}paletteSymbolClickHandler(t){switch(!0){case!this.group:this.group=t.detail;break;case!!this.group&&!!this.base:break;case!!this.group:this.base=t.detail,this.more=!1}}componentWillLoad(){"string"==typeof this.alphabet&&(this.alphabet=JSON.parse(this.alphabet)),this.parseSizeProp(this.size),this.setPalette()}render(){return s(e,{class:this.orientation+" "+this.size},s("nav",null,s("fsw-button",{svg:l,onClick:()=>{this.group=null}}),this.group?s("fsw-button",{svg:h,onClick:()=>{this.base?(this.base=null,this.more=null):this.group=null}}):s("div",null),this.hasMore?s("fsw-button",{svg:this.more?r:c,onClick:()=>{this.more=!this.more}}):"small"==this.size?s("div",null):null,this.hasLower?s("fsw-button",{svg:this.lower?n:o,onClick:()=>{this.lower=!this.lower}}):"large"!=this.size?s("div",null):null),s("main",null,this.palette.map((t=>s("fsw-palette-symbol",{symbol:t})))))}get el(){return i(this)}static get watchers(){return{size:["parseSizeProp"],group:["watchGroup"],base:["watchBase"],more:["watchMore"],lower:["watchLower"]}}};u.style=".sc-fsw-palette-h{width:100%;height:100%;display:flex}.sc-fsw-palette-h nav.sc-fsw-palette{height:100%;width:100%;flex:0 0 10%;display:flex;align-items:center}.sc-fsw-palette-h nav.sc-fsw-palette fsw-button.sc-fsw-palette,.sc-fsw-palette-h nav.sc-fsw-palette div.sc-fsw-palette{flex:25%;height:100%;width:100%;margin:1%}.sc-fsw-palette-h main.sc-fsw-palette{flex:0 0 90%;width:100%;height:100%;display:grid}.horizontal.sc-fsw-palette-h{flex-direction:row}.horizontal.sc-fsw-palette-h nav.sc-fsw-palette{flex-direction:column}.horizontal.small.sc-fsw-palette-h main.sc-fsw-palette{grid-template-columns:repeat(10,1fr)}.horizontal.medium.sc-fsw-palette-h main.sc-fsw-palette{grid-template-columns:repeat(10,1fr)}.horizontal.large.sc-fsw-palette-h main.sc-fsw-palette{grid-template-columns:repeat(16,1fr)}.vertical.sc-fsw-palette-h{flex-direction:column}.vertical.sc-fsw-palette-h nav.sc-fsw-palette{flex-direction:row}.vertical.sc-fsw-palette-h main.sc-fsw-palette{grid-auto-flow:column}.vertical.small.sc-fsw-palette-h main.sc-fsw-palette{grid-template-rows:repeat(10,1fr)}.vertical.medium.sc-fsw-palette-h main.sc-fsw-palette{grid-template-rows:repeat(10,1fr)}.vertical.large.sc-fsw-palette-h main.sc-fsw-palette{grid-template-rows:repeat(16,1fr)}";export{u as fsw_palette}
\No newline at end of file