mokkun 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +283 -0
- package/bin/cli.mjs +155 -0
- package/bin/viewer.html +262 -0
- package/dist/mokkun.css +1 -0
- package/dist/mokkun.esm.js +12496 -0
- package/dist/mokkun.esm.js.map +1 -0
- package/dist/mokkun.js +703 -0
- package/dist/mokkun.js.map +1 -0
- package/package.json +62 -0
package/dist/mokkun.js
ADDED
|
@@ -0,0 +1,703 @@
|
|
|
1
|
+
(function(N,O){typeof exports=="object"&&typeof module<"u"?O(exports):typeof define=="function"&&define.amd?define(["exports"],O):(N=typeof globalThis<"u"?globalThis:N||self,O(N.Mokkun={}))})(this,(function(N){"use strict";var to=Object.defineProperty;var io=(N,O,G)=>O in N?to(N,O,{enumerable:!0,configurable:!0,writable:!0,value:G}):N[O]=G;var h=(N,O,G)=>io(N,typeof O!="symbol"?O+"":O,G);/*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */function O(t){return typeof t>"u"||t===null}function G(t){return typeof t=="object"&&t!==null}function Mi(t){return Array.isArray(t)?t:O(t)?[]:[t]}function Di(t,e){var i,n,s,a;if(e)for(a=Object.keys(e),i=0,n=a.length;i<n;i+=1)s=a[i],t[s]=e[s];return t}function Fi(t,e){var i="",n;for(n=0;n<e;n+=1)i+=t;return i}function Oi(t){return t===0&&Number.NEGATIVE_INFINITY===1/t}var Hi=O,zi=G,Bi=Mi,Ri=Fi,Pi=Oi,Vi=Di,L={isNothing:Hi,isObject:zi,toArray:Bi,repeat:Ri,isNegativeZero:Pi,extend:Vi};function nt(t,e){var i="",n=t.reason||"(unknown reason)";return t.mark?(t.mark.name&&(i+='in "'+t.mark.name+'" '),i+="("+(t.mark.line+1)+":"+(t.mark.column+1)+")",!e&&t.mark.snippet&&(i+=`
|
|
2
|
+
|
|
3
|
+
`+t.mark.snippet),n+" "+i):n}function ie(t,e){Error.call(this),this.name="YAMLException",this.reason=t,this.mark=e,this.message=nt(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}ie.prototype=Object.create(Error.prototype),ie.prototype.constructor=ie,ie.prototype.toString=function(e){return this.name+": "+nt(this,e)};var T=ie;function _e(t,e,i,n,s){var a="",r="",o=Math.floor(s/2)-1;return n-e>o&&(a=" ... ",e=n-o+a.length),i-n>o&&(r=" ...",i=n+o-r.length),{str:a+t.slice(e,i).replace(/\t/g,"→")+r,pos:n-e+a.length}}function Ne(t,e){return L.repeat(" ",e-t.length)+t}function ji(t,e){if(e=Object.create(e||null),!t.buffer)return null;e.maxLength||(e.maxLength=79),typeof e.indent!="number"&&(e.indent=1),typeof e.linesBefore!="number"&&(e.linesBefore=3),typeof e.linesAfter!="number"&&(e.linesAfter=2);for(var i=/\r?\n|\r|\0/g,n=[0],s=[],a,r=-1;a=i.exec(t.buffer);)s.push(a.index),n.push(a.index+a[0].length),t.position<=a.index&&r<0&&(r=n.length-2);r<0&&(r=n.length-1);var o="",l,d,p=Math.min(t.line+e.linesAfter,s.length).toString().length,u=e.maxLength-(e.indent+p+3);for(l=1;l<=e.linesBefore&&!(r-l<0);l++)d=_e(t.buffer,n[r-l],s[r-l],t.position-(n[r]-n[r-l]),u),o=L.repeat(" ",e.indent)+Ne((t.line-l+1).toString(),p)+" | "+d.str+`
|
|
4
|
+
`+o;for(d=_e(t.buffer,n[r],s[r],t.position,u),o+=L.repeat(" ",e.indent)+Ne((t.line+1).toString(),p)+" | "+d.str+`
|
|
5
|
+
`,o+=L.repeat("-",e.indent+p+3+d.pos)+`^
|
|
6
|
+
`,l=1;l<=e.linesAfter&&!(r+l>=s.length);l++)d=_e(t.buffer,n[r+l],s[r+l],t.position-(n[r]-n[r+l]),u),o+=L.repeat(" ",e.indent)+Ne((t.line+l+1).toString(),p)+" | "+d.str+`
|
|
7
|
+
`;return o.replace(/\n$/,"")}var Ui=ji,qi=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],Wi=["scalar","sequence","mapping"];function Yi(t){var e={};return t!==null&&Object.keys(t).forEach(function(i){t[i].forEach(function(n){e[String(n)]=i})}),e}function Gi(t,e){if(e=e||{},Object.keys(e).forEach(function(i){if(qi.indexOf(i)===-1)throw new T('Unknown option "'+i+'" is met in definition of "'+t+'" YAML type.')}),this.options=e,this.tag=t,this.kind=e.kind||null,this.resolve=e.resolve||function(){return!0},this.construct=e.construct||function(i){return i},this.instanceOf=e.instanceOf||null,this.predicate=e.predicate||null,this.represent=e.represent||null,this.representName=e.representName||null,this.defaultStyle=e.defaultStyle||null,this.multi=e.multi||!1,this.styleAliases=Yi(e.styleAliases||null),Wi.indexOf(this.kind)===-1)throw new T('Unknown kind "'+this.kind+'" is specified for "'+t+'" YAML type.')}var $=Gi;function st(t,e){var i=[];return t[e].forEach(function(n){var s=i.length;i.forEach(function(a,r){a.tag===n.tag&&a.kind===n.kind&&a.multi===n.multi&&(s=r)}),i[s]=n}),i}function Zi(){var t={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}},e,i;function n(s){s.multi?(t.multi[s.kind].push(s),t.multi.fallback.push(s)):t[s.kind][s.tag]=t.fallback[s.tag]=s}for(e=0,i=arguments.length;e<i;e+=1)arguments[e].forEach(n);return t}function Te(t){return this.extend(t)}Te.prototype.extend=function(e){var i=[],n=[];if(e instanceof $)n.push(e);else if(Array.isArray(e))n=n.concat(e);else if(e&&(Array.isArray(e.implicit)||Array.isArray(e.explicit)))e.implicit&&(i=i.concat(e.implicit)),e.explicit&&(n=n.concat(e.explicit));else throw new T("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");i.forEach(function(a){if(!(a instanceof $))throw new T("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(a.loadKind&&a.loadKind!=="scalar")throw new T("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(a.multi)throw new T("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),n.forEach(function(a){if(!(a instanceof $))throw new T("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var s=Object.create(Te.prototype);return s.implicit=(this.implicit||[]).concat(i),s.explicit=(this.explicit||[]).concat(n),s.compiledImplicit=st(s,"implicit"),s.compiledExplicit=st(s,"explicit"),s.compiledTypeMap=Zi(s.compiledImplicit,s.compiledExplicit),s};var at=Te,rt=new $("tag:yaml.org,2002:str",{kind:"scalar",construct:function(t){return t!==null?t:""}}),ot=new $("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(t){return t!==null?t:[]}}),lt=new $("tag:yaml.org,2002:map",{kind:"mapping",construct:function(t){return t!==null?t:{}}}),ct=new at({explicit:[rt,ot,lt]});function Ki(t){if(t===null)return!0;var e=t.length;return e===1&&t==="~"||e===4&&(t==="null"||t==="Null"||t==="NULL")}function Qi(){return null}function Ji(t){return t===null}var dt=new $("tag:yaml.org,2002:null",{kind:"scalar",resolve:Ki,construct:Qi,predicate:Ji,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function Xi(t){if(t===null)return!1;var e=t.length;return e===4&&(t==="true"||t==="True"||t==="TRUE")||e===5&&(t==="false"||t==="False"||t==="FALSE")}function en(t){return t==="true"||t==="True"||t==="TRUE"}function tn(t){return Object.prototype.toString.call(t)==="[object Boolean]"}var ht=new $("tag:yaml.org,2002:bool",{kind:"scalar",resolve:Xi,construct:en,predicate:tn,represent:{lowercase:function(t){return t?"true":"false"},uppercase:function(t){return t?"TRUE":"FALSE"},camelcase:function(t){return t?"True":"False"}},defaultStyle:"lowercase"});function nn(t){return 48<=t&&t<=57||65<=t&&t<=70||97<=t&&t<=102}function sn(t){return 48<=t&&t<=55}function an(t){return 48<=t&&t<=57}function rn(t){if(t===null)return!1;var e=t.length,i=0,n=!1,s;if(!e)return!1;if(s=t[i],(s==="-"||s==="+")&&(s=t[++i]),s==="0"){if(i+1===e)return!0;if(s=t[++i],s==="b"){for(i++;i<e;i++)if(s=t[i],s!=="_"){if(s!=="0"&&s!=="1")return!1;n=!0}return n&&s!=="_"}if(s==="x"){for(i++;i<e;i++)if(s=t[i],s!=="_"){if(!nn(t.charCodeAt(i)))return!1;n=!0}return n&&s!=="_"}if(s==="o"){for(i++;i<e;i++)if(s=t[i],s!=="_"){if(!sn(t.charCodeAt(i)))return!1;n=!0}return n&&s!=="_"}}if(s==="_")return!1;for(;i<e;i++)if(s=t[i],s!=="_"){if(!an(t.charCodeAt(i)))return!1;n=!0}return!(!n||s==="_")}function on(t){var e=t,i=1,n;if(e.indexOf("_")!==-1&&(e=e.replace(/_/g,"")),n=e[0],(n==="-"||n==="+")&&(n==="-"&&(i=-1),e=e.slice(1),n=e[0]),e==="0")return 0;if(n==="0"){if(e[1]==="b")return i*parseInt(e.slice(2),2);if(e[1]==="x")return i*parseInt(e.slice(2),16);if(e[1]==="o")return i*parseInt(e.slice(2),8)}return i*parseInt(e,10)}function ln(t){return Object.prototype.toString.call(t)==="[object Number]"&&t%1===0&&!L.isNegativeZero(t)}var ut=new $("tag:yaml.org,2002:int",{kind:"scalar",resolve:rn,construct:on,predicate:ln,represent:{binary:function(t){return t>=0?"0b"+t.toString(2):"-0b"+t.toString(2).slice(1)},octal:function(t){return t>=0?"0o"+t.toString(8):"-0o"+t.toString(8).slice(1)},decimal:function(t){return t.toString(10)},hexadecimal:function(t){return t>=0?"0x"+t.toString(16).toUpperCase():"-0x"+t.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),cn=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function dn(t){return!(t===null||!cn.test(t)||t[t.length-1]==="_")}function hn(t){var e,i;return e=t.replace(/_/g,"").toLowerCase(),i=e[0]==="-"?-1:1,"+-".indexOf(e[0])>=0&&(e=e.slice(1)),e===".inf"?i===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:e===".nan"?NaN:i*parseFloat(e,10)}var un=/^[-+]?[0-9]+e/;function pn(t,e){var i;if(isNaN(t))switch(e){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===t)switch(e){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===t)switch(e){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(L.isNegativeZero(t))return"-0.0";return i=t.toString(10),un.test(i)?i.replace("e",".e"):i}function fn(t){return Object.prototype.toString.call(t)==="[object Number]"&&(t%1!==0||L.isNegativeZero(t))}var pt=new $("tag:yaml.org,2002:float",{kind:"scalar",resolve:dn,construct:hn,predicate:fn,represent:pn,defaultStyle:"lowercase"}),ft=ct.extend({implicit:[dt,ht,ut,pt]}),mt=ft,gt=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),bt=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function mn(t){return t===null?!1:gt.exec(t)!==null||bt.exec(t)!==null}function gn(t){var e,i,n,s,a,r,o,l=0,d=null,p,u,f;if(e=gt.exec(t),e===null&&(e=bt.exec(t)),e===null)throw new Error("Date resolve error");if(i=+e[1],n=+e[2]-1,s=+e[3],!e[4])return new Date(Date.UTC(i,n,s));if(a=+e[4],r=+e[5],o=+e[6],e[7]){for(l=e[7].slice(0,3);l.length<3;)l+="0";l=+l}return e[9]&&(p=+e[10],u=+(e[11]||0),d=(p*60+u)*6e4,e[9]==="-"&&(d=-d)),f=new Date(Date.UTC(i,n,s,a,r,o,l)),d&&f.setTime(f.getTime()-d),f}function bn(t){return t.toISOString()}var vt=new $("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:mn,construct:gn,instanceOf:Date,represent:bn});function vn(t){return t==="<<"||t===null}var xt=new $("tag:yaml.org,2002:merge",{kind:"scalar",resolve:vn}),Me=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
8
|
+
\r`;function xn(t){if(t===null)return!1;var e,i,n=0,s=t.length,a=Me;for(i=0;i<s;i++)if(e=a.indexOf(t.charAt(i)),!(e>64)){if(e<0)return!1;n+=6}return n%8===0}function yn(t){var e,i,n=t.replace(/[\r\n=]/g,""),s=n.length,a=Me,r=0,o=[];for(e=0;e<s;e++)e%4===0&&e&&(o.push(r>>16&255),o.push(r>>8&255),o.push(r&255)),r=r<<6|a.indexOf(n.charAt(e));return i=s%4*6,i===0?(o.push(r>>16&255),o.push(r>>8&255),o.push(r&255)):i===18?(o.push(r>>10&255),o.push(r>>2&255)):i===12&&o.push(r>>4&255),new Uint8Array(o)}function Cn(t){var e="",i=0,n,s,a=t.length,r=Me;for(n=0;n<a;n++)n%3===0&&n&&(e+=r[i>>18&63],e+=r[i>>12&63],e+=r[i>>6&63],e+=r[i&63]),i=(i<<8)+t[n];return s=a%3,s===0?(e+=r[i>>18&63],e+=r[i>>12&63],e+=r[i>>6&63],e+=r[i&63]):s===2?(e+=r[i>>10&63],e+=r[i>>4&63],e+=r[i<<2&63],e+=r[64]):s===1&&(e+=r[i>>2&63],e+=r[i<<4&63],e+=r[64],e+=r[64]),e}function kn(t){return Object.prototype.toString.call(t)==="[object Uint8Array]"}var yt=new $("tag:yaml.org,2002:binary",{kind:"scalar",resolve:xn,construct:yn,predicate:kn,represent:Cn}),wn=Object.prototype.hasOwnProperty,En=Object.prototype.toString;function An(t){if(t===null)return!0;var e=[],i,n,s,a,r,o=t;for(i=0,n=o.length;i<n;i+=1){if(s=o[i],r=!1,En.call(s)!=="[object Object]")return!1;for(a in s)if(wn.call(s,a))if(!r)r=!0;else return!1;if(!r)return!1;if(e.indexOf(a)===-1)e.push(a);else return!1}return!0}function In(t){return t!==null?t:[]}var Ct=new $("tag:yaml.org,2002:omap",{kind:"sequence",resolve:An,construct:In}),Sn=Object.prototype.toString;function Ln(t){if(t===null)return!0;var e,i,n,s,a,r=t;for(a=new Array(r.length),e=0,i=r.length;e<i;e+=1){if(n=r[e],Sn.call(n)!=="[object Object]"||(s=Object.keys(n),s.length!==1))return!1;a[e]=[s[0],n[s[0]]]}return!0}function $n(t){if(t===null)return[];var e,i,n,s,a,r=t;for(a=new Array(r.length),e=0,i=r.length;e<i;e+=1)n=r[e],s=Object.keys(n),a[e]=[s[0],n[s[0]]];return a}var kt=new $("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:Ln,construct:$n}),_n=Object.prototype.hasOwnProperty;function Nn(t){if(t===null)return!0;var e,i=t;for(e in i)if(_n.call(i,e)&&i[e]!==null)return!1;return!0}function Tn(t){return t!==null?t:{}}var wt=new $("tag:yaml.org,2002:set",{kind:"mapping",resolve:Nn,construct:Tn}),De=mt.extend({implicit:[vt,xt],explicit:[yt,Ct,kt,wt]}),q=Object.prototype.hasOwnProperty,pe=1,Et=2,At=3,fe=4,Fe=1,Mn=2,It=3,Dn=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,Fn=/[\x85\u2028\u2029]/,On=/[,\[\]\{\}]/,St=/^(?:!|!!|![a-z\-]+!)$/i,Lt=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function $t(t){return Object.prototype.toString.call(t)}function R(t){return t===10||t===13}function Y(t){return t===9||t===32}function H(t){return t===9||t===32||t===10||t===13}function Z(t){return t===44||t===91||t===93||t===123||t===125}function Hn(t){var e;return 48<=t&&t<=57?t-48:(e=t|32,97<=e&&e<=102?e-97+10:-1)}function zn(t){return t===120?2:t===117?4:t===85?8:0}function Bn(t){return 48<=t&&t<=57?t-48:-1}function _t(t){return t===48?"\0":t===97?"\x07":t===98?"\b":t===116||t===9?" ":t===110?`
|
|
9
|
+
`:t===118?"\v":t===102?"\f":t===114?"\r":t===101?"\x1B":t===32?" ":t===34?'"':t===47?"/":t===92?"\\":t===78?"
":t===95?" ":t===76?"\u2028":t===80?"\u2029":""}function Rn(t){return t<=65535?String.fromCharCode(t):String.fromCharCode((t-65536>>10)+55296,(t-65536&1023)+56320)}function Nt(t,e,i){e==="__proto__"?Object.defineProperty(t,e,{configurable:!0,enumerable:!0,writable:!0,value:i}):t[e]=i}for(var Tt=new Array(256),Mt=new Array(256),K=0;K<256;K++)Tt[K]=_t(K)?1:0,Mt[K]=_t(K);function Pn(t,e){this.input=t,this.filename=e.filename||null,this.schema=e.schema||De,this.onWarning=e.onWarning||null,this.legacy=e.legacy||!1,this.json=e.json||!1,this.listener=e.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=t.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function Dt(t,e){var i={name:t.filename,buffer:t.input.slice(0,-1),position:t.position,line:t.line,column:t.position-t.lineStart};return i.snippet=Ui(i),new T(e,i)}function v(t,e){throw Dt(t,e)}function me(t,e){t.onWarning&&t.onWarning.call(null,Dt(t,e))}var Ft={YAML:function(e,i,n){var s,a,r;e.version!==null&&v(e,"duplication of %YAML directive"),n.length!==1&&v(e,"YAML directive accepts exactly one argument"),s=/^([0-9]+)\.([0-9]+)$/.exec(n[0]),s===null&&v(e,"ill-formed argument of the YAML directive"),a=parseInt(s[1],10),r=parseInt(s[2],10),a!==1&&v(e,"unacceptable YAML version of the document"),e.version=n[0],e.checkLineBreaks=r<2,r!==1&&r!==2&&me(e,"unsupported YAML version of the document")},TAG:function(e,i,n){var s,a;n.length!==2&&v(e,"TAG directive accepts exactly two arguments"),s=n[0],a=n[1],St.test(s)||v(e,"ill-formed tag handle (first argument) of the TAG directive"),q.call(e.tagMap,s)&&v(e,'there is a previously declared suffix for "'+s+'" tag handle'),Lt.test(a)||v(e,"ill-formed tag prefix (second argument) of the TAG directive");try{a=decodeURIComponent(a)}catch{v(e,"tag prefix is malformed: "+a)}e.tagMap[s]=a}};function W(t,e,i,n){var s,a,r,o;if(e<i){if(o=t.input.slice(e,i),n)for(s=0,a=o.length;s<a;s+=1)r=o.charCodeAt(s),r===9||32<=r&&r<=1114111||v(t,"expected valid JSON character");else Dn.test(o)&&v(t,"the stream contains non-printable characters");t.result+=o}}function Ot(t,e,i,n){var s,a,r,o;for(L.isObject(i)||v(t,"cannot merge mappings; the provided source object is unacceptable"),s=Object.keys(i),r=0,o=s.length;r<o;r+=1)a=s[r],q.call(e,a)||(Nt(e,a,i[a]),n[a]=!0)}function Q(t,e,i,n,s,a,r,o,l){var d,p;if(Array.isArray(s))for(s=Array.prototype.slice.call(s),d=0,p=s.length;d<p;d+=1)Array.isArray(s[d])&&v(t,"nested arrays are not supported inside keys"),typeof s=="object"&&$t(s[d])==="[object Object]"&&(s[d]="[object Object]");if(typeof s=="object"&&$t(s)==="[object Object]"&&(s="[object Object]"),s=String(s),e===null&&(e={}),n==="tag:yaml.org,2002:merge")if(Array.isArray(a))for(d=0,p=a.length;d<p;d+=1)Ot(t,e,a[d],i);else Ot(t,e,a,i);else!t.json&&!q.call(i,s)&&q.call(e,s)&&(t.line=r||t.line,t.lineStart=o||t.lineStart,t.position=l||t.position,v(t,"duplicated mapping key")),Nt(e,s,a),delete i[s];return e}function Oe(t){var e;e=t.input.charCodeAt(t.position),e===10?t.position++:e===13?(t.position++,t.input.charCodeAt(t.position)===10&&t.position++):v(t,"a line break is expected"),t.line+=1,t.lineStart=t.position,t.firstTabInLine=-1}function I(t,e,i){for(var n=0,s=t.input.charCodeAt(t.position);s!==0;){for(;Y(s);)s===9&&t.firstTabInLine===-1&&(t.firstTabInLine=t.position),s=t.input.charCodeAt(++t.position);if(e&&s===35)do s=t.input.charCodeAt(++t.position);while(s!==10&&s!==13&&s!==0);if(R(s))for(Oe(t),s=t.input.charCodeAt(t.position),n++,t.lineIndent=0;s===32;)t.lineIndent++,s=t.input.charCodeAt(++t.position);else break}return i!==-1&&n!==0&&t.lineIndent<i&&me(t,"deficient indentation"),n}function ge(t){var e=t.position,i;return i=t.input.charCodeAt(e),!!((i===45||i===46)&&i===t.input.charCodeAt(e+1)&&i===t.input.charCodeAt(e+2)&&(e+=3,i=t.input.charCodeAt(e),i===0||H(i)))}function He(t,e){e===1?t.result+=" ":e>1&&(t.result+=L.repeat(`
|
|
10
|
+
`,e-1))}function Vn(t,e,i){var n,s,a,r,o,l,d,p,u=t.kind,f=t.result,g;if(g=t.input.charCodeAt(t.position),H(g)||Z(g)||g===35||g===38||g===42||g===33||g===124||g===62||g===39||g===34||g===37||g===64||g===96||(g===63||g===45)&&(s=t.input.charCodeAt(t.position+1),H(s)||i&&Z(s)))return!1;for(t.kind="scalar",t.result="",a=r=t.position,o=!1;g!==0;){if(g===58){if(s=t.input.charCodeAt(t.position+1),H(s)||i&&Z(s))break}else if(g===35){if(n=t.input.charCodeAt(t.position-1),H(n))break}else{if(t.position===t.lineStart&&ge(t)||i&&Z(g))break;if(R(g))if(l=t.line,d=t.lineStart,p=t.lineIndent,I(t,!1,-1),t.lineIndent>=e){o=!0,g=t.input.charCodeAt(t.position);continue}else{t.position=r,t.line=l,t.lineStart=d,t.lineIndent=p;break}}o&&(W(t,a,r,!1),He(t,t.line-l),a=r=t.position,o=!1),Y(g)||(r=t.position+1),g=t.input.charCodeAt(++t.position)}return W(t,a,r,!1),t.result?!0:(t.kind=u,t.result=f,!1)}function jn(t,e){var i,n,s;if(i=t.input.charCodeAt(t.position),i!==39)return!1;for(t.kind="scalar",t.result="",t.position++,n=s=t.position;(i=t.input.charCodeAt(t.position))!==0;)if(i===39)if(W(t,n,t.position,!0),i=t.input.charCodeAt(++t.position),i===39)n=t.position,t.position++,s=t.position;else return!0;else R(i)?(W(t,n,s,!0),He(t,I(t,!1,e)),n=s=t.position):t.position===t.lineStart&&ge(t)?v(t,"unexpected end of the document within a single quoted scalar"):(t.position++,s=t.position);v(t,"unexpected end of the stream within a single quoted scalar")}function Un(t,e){var i,n,s,a,r,o;if(o=t.input.charCodeAt(t.position),o!==34)return!1;for(t.kind="scalar",t.result="",t.position++,i=n=t.position;(o=t.input.charCodeAt(t.position))!==0;){if(o===34)return W(t,i,t.position,!0),t.position++,!0;if(o===92){if(W(t,i,t.position,!0),o=t.input.charCodeAt(++t.position),R(o))I(t,!1,e);else if(o<256&&Tt[o])t.result+=Mt[o],t.position++;else if((r=zn(o))>0){for(s=r,a=0;s>0;s--)o=t.input.charCodeAt(++t.position),(r=Hn(o))>=0?a=(a<<4)+r:v(t,"expected hexadecimal character");t.result+=Rn(a),t.position++}else v(t,"unknown escape sequence");i=n=t.position}else R(o)?(W(t,i,n,!0),He(t,I(t,!1,e)),i=n=t.position):t.position===t.lineStart&&ge(t)?v(t,"unexpected end of the document within a double quoted scalar"):(t.position++,n=t.position)}v(t,"unexpected end of the stream within a double quoted scalar")}function qn(t,e){var i=!0,n,s,a,r=t.tag,o,l=t.anchor,d,p,u,f,g,x=Object.create(null),C,w,z,b;if(b=t.input.charCodeAt(t.position),b===91)p=93,g=!1,o=[];else if(b===123)p=125,g=!0,o={};else return!1;for(t.anchor!==null&&(t.anchorMap[t.anchor]=o),b=t.input.charCodeAt(++t.position);b!==0;){if(I(t,!0,e),b=t.input.charCodeAt(t.position),b===p)return t.position++,t.tag=r,t.anchor=l,t.kind=g?"mapping":"sequence",t.result=o,!0;i?b===44&&v(t,"expected the node content, but found ','"):v(t,"missed comma between flow collection entries"),w=C=z=null,u=f=!1,b===63&&(d=t.input.charCodeAt(t.position+1),H(d)&&(u=f=!0,t.position++,I(t,!0,e))),n=t.line,s=t.lineStart,a=t.position,J(t,e,pe,!1,!0),w=t.tag,C=t.result,I(t,!0,e),b=t.input.charCodeAt(t.position),(f||t.line===n)&&b===58&&(u=!0,b=t.input.charCodeAt(++t.position),I(t,!0,e),J(t,e,pe,!1,!0),z=t.result),g?Q(t,o,x,w,C,z,n,s,a):u?o.push(Q(t,null,x,w,C,z,n,s,a)):o.push(C),I(t,!0,e),b=t.input.charCodeAt(t.position),b===44?(i=!0,b=t.input.charCodeAt(++t.position)):i=!1}v(t,"unexpected end of the stream within a flow collection")}function Wn(t,e){var i,n,s=Fe,a=!1,r=!1,o=e,l=0,d=!1,p,u;if(u=t.input.charCodeAt(t.position),u===124)n=!1;else if(u===62)n=!0;else return!1;for(t.kind="scalar",t.result="";u!==0;)if(u=t.input.charCodeAt(++t.position),u===43||u===45)Fe===s?s=u===43?It:Mn:v(t,"repeat of a chomping mode identifier");else if((p=Bn(u))>=0)p===0?v(t,"bad explicit indentation width of a block scalar; it cannot be less than one"):r?v(t,"repeat of an indentation width identifier"):(o=e+p-1,r=!0);else break;if(Y(u)){do u=t.input.charCodeAt(++t.position);while(Y(u));if(u===35)do u=t.input.charCodeAt(++t.position);while(!R(u)&&u!==0)}for(;u!==0;){for(Oe(t),t.lineIndent=0,u=t.input.charCodeAt(t.position);(!r||t.lineIndent<o)&&u===32;)t.lineIndent++,u=t.input.charCodeAt(++t.position);if(!r&&t.lineIndent>o&&(o=t.lineIndent),R(u)){l++;continue}if(t.lineIndent<o){s===It?t.result+=L.repeat(`
|
|
11
|
+
`,a?1+l:l):s===Fe&&a&&(t.result+=`
|
|
12
|
+
`);break}for(n?Y(u)?(d=!0,t.result+=L.repeat(`
|
|
13
|
+
`,a?1+l:l)):d?(d=!1,t.result+=L.repeat(`
|
|
14
|
+
`,l+1)):l===0?a&&(t.result+=" "):t.result+=L.repeat(`
|
|
15
|
+
`,l):t.result+=L.repeat(`
|
|
16
|
+
`,a?1+l:l),a=!0,r=!0,l=0,i=t.position;!R(u)&&u!==0;)u=t.input.charCodeAt(++t.position);W(t,i,t.position,!1)}return!0}function Ht(t,e){var i,n=t.tag,s=t.anchor,a=[],r,o=!1,l;if(t.firstTabInLine!==-1)return!1;for(t.anchor!==null&&(t.anchorMap[t.anchor]=a),l=t.input.charCodeAt(t.position);l!==0&&(t.firstTabInLine!==-1&&(t.position=t.firstTabInLine,v(t,"tab characters must not be used in indentation")),!(l!==45||(r=t.input.charCodeAt(t.position+1),!H(r))));){if(o=!0,t.position++,I(t,!0,-1)&&t.lineIndent<=e){a.push(null),l=t.input.charCodeAt(t.position);continue}if(i=t.line,J(t,e,At,!1,!0),a.push(t.result),I(t,!0,-1),l=t.input.charCodeAt(t.position),(t.line===i||t.lineIndent>e)&&l!==0)v(t,"bad indentation of a sequence entry");else if(t.lineIndent<e)break}return o?(t.tag=n,t.anchor=s,t.kind="sequence",t.result=a,!0):!1}function Yn(t,e,i){var n,s,a,r,o,l,d=t.tag,p=t.anchor,u={},f=Object.create(null),g=null,x=null,C=null,w=!1,z=!1,b;if(t.firstTabInLine!==-1)return!1;for(t.anchor!==null&&(t.anchorMap[t.anchor]=u),b=t.input.charCodeAt(t.position);b!==0;){if(!w&&t.firstTabInLine!==-1&&(t.position=t.firstTabInLine,v(t,"tab characters must not be used in indentation")),n=t.input.charCodeAt(t.position+1),a=t.line,(b===63||b===58)&&H(n))b===63?(w&&(Q(t,u,f,g,x,null,r,o,l),g=x=C=null),z=!0,w=!0,s=!0):w?(w=!1,s=!0):v(t,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),t.position+=1,b=n;else{if(r=t.line,o=t.lineStart,l=t.position,!J(t,i,Et,!1,!0))break;if(t.line===a){for(b=t.input.charCodeAt(t.position);Y(b);)b=t.input.charCodeAt(++t.position);if(b===58)b=t.input.charCodeAt(++t.position),H(b)||v(t,"a whitespace character is expected after the key-value separator within a block mapping"),w&&(Q(t,u,f,g,x,null,r,o,l),g=x=C=null),z=!0,w=!1,s=!1,g=t.tag,x=t.result;else if(z)v(t,"can not read an implicit mapping pair; a colon is missed");else return t.tag=d,t.anchor=p,!0}else if(z)v(t,"can not read a block mapping entry; a multiline key may not be an implicit key");else return t.tag=d,t.anchor=p,!0}if((t.line===a||t.lineIndent>e)&&(w&&(r=t.line,o=t.lineStart,l=t.position),J(t,e,fe,!0,s)&&(w?x=t.result:C=t.result),w||(Q(t,u,f,g,x,C,r,o,l),g=x=C=null),I(t,!0,-1),b=t.input.charCodeAt(t.position)),(t.line===a||t.lineIndent>e)&&b!==0)v(t,"bad indentation of a mapping entry");else if(t.lineIndent<e)break}return w&&Q(t,u,f,g,x,null,r,o,l),z&&(t.tag=d,t.anchor=p,t.kind="mapping",t.result=u),z}function Gn(t){var e,i=!1,n=!1,s,a,r;if(r=t.input.charCodeAt(t.position),r!==33)return!1;if(t.tag!==null&&v(t,"duplication of a tag property"),r=t.input.charCodeAt(++t.position),r===60?(i=!0,r=t.input.charCodeAt(++t.position)):r===33?(n=!0,s="!!",r=t.input.charCodeAt(++t.position)):s="!",e=t.position,i){do r=t.input.charCodeAt(++t.position);while(r!==0&&r!==62);t.position<t.length?(a=t.input.slice(e,t.position),r=t.input.charCodeAt(++t.position)):v(t,"unexpected end of the stream within a verbatim tag")}else{for(;r!==0&&!H(r);)r===33&&(n?v(t,"tag suffix cannot contain exclamation marks"):(s=t.input.slice(e-1,t.position+1),St.test(s)||v(t,"named tag handle cannot contain such characters"),n=!0,e=t.position+1)),r=t.input.charCodeAt(++t.position);a=t.input.slice(e,t.position),On.test(a)&&v(t,"tag suffix cannot contain flow indicator characters")}a&&!Lt.test(a)&&v(t,"tag name cannot contain such characters: "+a);try{a=decodeURIComponent(a)}catch{v(t,"tag name is malformed: "+a)}return i?t.tag=a:q.call(t.tagMap,s)?t.tag=t.tagMap[s]+a:s==="!"?t.tag="!"+a:s==="!!"?t.tag="tag:yaml.org,2002:"+a:v(t,'undeclared tag handle "'+s+'"'),!0}function Zn(t){var e,i;if(i=t.input.charCodeAt(t.position),i!==38)return!1;for(t.anchor!==null&&v(t,"duplication of an anchor property"),i=t.input.charCodeAt(++t.position),e=t.position;i!==0&&!H(i)&&!Z(i);)i=t.input.charCodeAt(++t.position);return t.position===e&&v(t,"name of an anchor node must contain at least one character"),t.anchor=t.input.slice(e,t.position),!0}function Kn(t){var e,i,n;if(n=t.input.charCodeAt(t.position),n!==42)return!1;for(n=t.input.charCodeAt(++t.position),e=t.position;n!==0&&!H(n)&&!Z(n);)n=t.input.charCodeAt(++t.position);return t.position===e&&v(t,"name of an alias node must contain at least one character"),i=t.input.slice(e,t.position),q.call(t.anchorMap,i)||v(t,'unidentified alias "'+i+'"'),t.result=t.anchorMap[i],I(t,!0,-1),!0}function J(t,e,i,n,s){var a,r,o,l=1,d=!1,p=!1,u,f,g,x,C,w;if(t.listener!==null&&t.listener("open",t),t.tag=null,t.anchor=null,t.kind=null,t.result=null,a=r=o=fe===i||At===i,n&&I(t,!0,-1)&&(d=!0,t.lineIndent>e?l=1:t.lineIndent===e?l=0:t.lineIndent<e&&(l=-1)),l===1)for(;Gn(t)||Zn(t);)I(t,!0,-1)?(d=!0,o=a,t.lineIndent>e?l=1:t.lineIndent===e?l=0:t.lineIndent<e&&(l=-1)):o=!1;if(o&&(o=d||s),(l===1||fe===i)&&(pe===i||Et===i?C=e:C=e+1,w=t.position-t.lineStart,l===1?o&&(Ht(t,w)||Yn(t,w,C))||qn(t,C)?p=!0:(r&&Wn(t,C)||jn(t,C)||Un(t,C)?p=!0:Kn(t)?(p=!0,(t.tag!==null||t.anchor!==null)&&v(t,"alias node should not have any properties")):Vn(t,C,pe===i)&&(p=!0,t.tag===null&&(t.tag="?")),t.anchor!==null&&(t.anchorMap[t.anchor]=t.result)):l===0&&(p=o&&Ht(t,w))),t.tag===null)t.anchor!==null&&(t.anchorMap[t.anchor]=t.result);else if(t.tag==="?"){for(t.result!==null&&t.kind!=="scalar"&&v(t,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+t.kind+'"'),u=0,f=t.implicitTypes.length;u<f;u+=1)if(x=t.implicitTypes[u],x.resolve(t.result)){t.result=x.construct(t.result),t.tag=x.tag,t.anchor!==null&&(t.anchorMap[t.anchor]=t.result);break}}else if(t.tag!=="!"){if(q.call(t.typeMap[t.kind||"fallback"],t.tag))x=t.typeMap[t.kind||"fallback"][t.tag];else for(x=null,g=t.typeMap.multi[t.kind||"fallback"],u=0,f=g.length;u<f;u+=1)if(t.tag.slice(0,g[u].tag.length)===g[u].tag){x=g[u];break}x||v(t,"unknown tag !<"+t.tag+">"),t.result!==null&&x.kind!==t.kind&&v(t,"unacceptable node kind for !<"+t.tag+'> tag; it should be "'+x.kind+'", not "'+t.kind+'"'),x.resolve(t.result,t.tag)?(t.result=x.construct(t.result,t.tag),t.anchor!==null&&(t.anchorMap[t.anchor]=t.result)):v(t,"cannot resolve a node with !<"+t.tag+"> explicit tag")}return t.listener!==null&&t.listener("close",t),t.tag!==null||t.anchor!==null||p}function Qn(t){var e=t.position,i,n,s,a=!1,r;for(t.version=null,t.checkLineBreaks=t.legacy,t.tagMap=Object.create(null),t.anchorMap=Object.create(null);(r=t.input.charCodeAt(t.position))!==0&&(I(t,!0,-1),r=t.input.charCodeAt(t.position),!(t.lineIndent>0||r!==37));){for(a=!0,r=t.input.charCodeAt(++t.position),i=t.position;r!==0&&!H(r);)r=t.input.charCodeAt(++t.position);for(n=t.input.slice(i,t.position),s=[],n.length<1&&v(t,"directive name must not be less than one character in length");r!==0;){for(;Y(r);)r=t.input.charCodeAt(++t.position);if(r===35){do r=t.input.charCodeAt(++t.position);while(r!==0&&!R(r));break}if(R(r))break;for(i=t.position;r!==0&&!H(r);)r=t.input.charCodeAt(++t.position);s.push(t.input.slice(i,t.position))}r!==0&&Oe(t),q.call(Ft,n)?Ft[n](t,n,s):me(t,'unknown document directive "'+n+'"')}if(I(t,!0,-1),t.lineIndent===0&&t.input.charCodeAt(t.position)===45&&t.input.charCodeAt(t.position+1)===45&&t.input.charCodeAt(t.position+2)===45?(t.position+=3,I(t,!0,-1)):a&&v(t,"directives end mark is expected"),J(t,t.lineIndent-1,fe,!1,!0),I(t,!0,-1),t.checkLineBreaks&&Fn.test(t.input.slice(e,t.position))&&me(t,"non-ASCII line breaks are interpreted as content"),t.documents.push(t.result),t.position===t.lineStart&&ge(t)){t.input.charCodeAt(t.position)===46&&(t.position+=3,I(t,!0,-1));return}if(t.position<t.length-1)v(t,"end of the stream or a document separator is expected");else return}function zt(t,e){t=String(t),e=e||{},t.length!==0&&(t.charCodeAt(t.length-1)!==10&&t.charCodeAt(t.length-1)!==13&&(t+=`
|
|
17
|
+
`),t.charCodeAt(0)===65279&&(t=t.slice(1)));var i=new Pn(t,e),n=t.indexOf("\0");for(n!==-1&&(i.position=n,v(i,"null byte is not allowed in input")),i.input+="\0";i.input.charCodeAt(i.position)===32;)i.lineIndent+=1,i.position+=1;for(;i.position<i.length-1;)Qn(i);return i.documents}function Jn(t,e,i){e!==null&&typeof e=="object"&&typeof i>"u"&&(i=e,e=null);var n=zt(t,i);if(typeof e!="function")return n;for(var s=0,a=n.length;s<a;s+=1)e(n[s])}function Xn(t,e){var i=zt(t,e);if(i.length!==0){if(i.length===1)return i[0];throw new T("expected a single document in the stream, but found more")}}var es=Jn,ts=Xn,Bt={loadAll:es,load:ts},Rt=Object.prototype.toString,Pt=Object.prototype.hasOwnProperty,ze=65279,is=9,ne=10,ns=13,ss=32,as=33,rs=34,Be=35,os=37,ls=38,cs=39,ds=42,Vt=44,hs=45,be=58,us=61,ps=62,fs=63,ms=64,jt=91,Ut=93,gs=96,qt=123,bs=124,Wt=125,_={};_[0]="\\0",_[7]="\\a",_[8]="\\b",_[9]="\\t",_[10]="\\n",_[11]="\\v",_[12]="\\f",_[13]="\\r",_[27]="\\e",_[34]='\\"',_[92]="\\\\",_[133]="\\N",_[160]="\\_",_[8232]="\\L",_[8233]="\\P";var vs=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],xs=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function ys(t,e){var i,n,s,a,r,o,l;if(e===null)return{};for(i={},n=Object.keys(e),s=0,a=n.length;s<a;s+=1)r=n[s],o=String(e[r]),r.slice(0,2)==="!!"&&(r="tag:yaml.org,2002:"+r.slice(2)),l=t.compiledTypeMap.fallback[r],l&&Pt.call(l.styleAliases,o)&&(o=l.styleAliases[o]),i[r]=o;return i}function Cs(t){var e,i,n;if(e=t.toString(16).toUpperCase(),t<=255)i="x",n=2;else if(t<=65535)i="u",n=4;else if(t<=4294967295)i="U",n=8;else throw new T("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+i+L.repeat("0",n-e.length)+e}var ks=1,se=2;function ws(t){this.schema=t.schema||De,this.indent=Math.max(1,t.indent||2),this.noArrayIndent=t.noArrayIndent||!1,this.skipInvalid=t.skipInvalid||!1,this.flowLevel=L.isNothing(t.flowLevel)?-1:t.flowLevel,this.styleMap=ys(this.schema,t.styles||null),this.sortKeys=t.sortKeys||!1,this.lineWidth=t.lineWidth||80,this.noRefs=t.noRefs||!1,this.noCompatMode=t.noCompatMode||!1,this.condenseFlow=t.condenseFlow||!1,this.quotingType=t.quotingType==='"'?se:ks,this.forceQuotes=t.forceQuotes||!1,this.replacer=typeof t.replacer=="function"?t.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function Yt(t,e){for(var i=L.repeat(" ",e),n=0,s=-1,a="",r,o=t.length;n<o;)s=t.indexOf(`
|
|
18
|
+
`,n),s===-1?(r=t.slice(n),n=o):(r=t.slice(n,s+1),n=s+1),r.length&&r!==`
|
|
19
|
+
`&&(a+=i),a+=r;return a}function Re(t,e){return`
|
|
20
|
+
`+L.repeat(" ",t.indent*e)}function Es(t,e){var i,n,s;for(i=0,n=t.implicitTypes.length;i<n;i+=1)if(s=t.implicitTypes[i],s.resolve(e))return!0;return!1}function ve(t){return t===ss||t===is}function ae(t){return 32<=t&&t<=126||161<=t&&t<=55295&&t!==8232&&t!==8233||57344<=t&&t<=65533&&t!==ze||65536<=t&&t<=1114111}function Gt(t){return ae(t)&&t!==ze&&t!==ns&&t!==ne}function Zt(t,e,i){var n=Gt(t),s=n&&!ve(t);return(i?n:n&&t!==Vt&&t!==jt&&t!==Ut&&t!==qt&&t!==Wt)&&t!==Be&&!(e===be&&!s)||Gt(e)&&!ve(e)&&t===Be||e===be&&s}function As(t){return ae(t)&&t!==ze&&!ve(t)&&t!==hs&&t!==fs&&t!==be&&t!==Vt&&t!==jt&&t!==Ut&&t!==qt&&t!==Wt&&t!==Be&&t!==ls&&t!==ds&&t!==as&&t!==bs&&t!==us&&t!==ps&&t!==cs&&t!==rs&&t!==os&&t!==ms&&t!==gs}function Is(t){return!ve(t)&&t!==be}function re(t,e){var i=t.charCodeAt(e),n;return i>=55296&&i<=56319&&e+1<t.length&&(n=t.charCodeAt(e+1),n>=56320&&n<=57343)?(i-55296)*1024+n-56320+65536:i}function Kt(t){var e=/^\n* /;return e.test(t)}var Qt=1,Pe=2,Jt=3,Xt=4,X=5;function Ss(t,e,i,n,s,a,r,o){var l,d=0,p=null,u=!1,f=!1,g=n!==-1,x=-1,C=As(re(t,0))&&Is(re(t,t.length-1));if(e||r)for(l=0;l<t.length;d>=65536?l+=2:l++){if(d=re(t,l),!ae(d))return X;C=C&&Zt(d,p,o),p=d}else{for(l=0;l<t.length;d>=65536?l+=2:l++){if(d=re(t,l),d===ne)u=!0,g&&(f=f||l-x-1>n&&t[x+1]!==" ",x=l);else if(!ae(d))return X;C=C&&Zt(d,p,o),p=d}f=f||g&&l-x-1>n&&t[x+1]!==" "}return!u&&!f?C&&!r&&!s(t)?Qt:a===se?X:Pe:i>9&&Kt(t)?X:r?a===se?X:Pe:f?Xt:Jt}function Ls(t,e,i,n,s){t.dump=(function(){if(e.length===0)return t.quotingType===se?'""':"''";if(!t.noCompatMode&&(vs.indexOf(e)!==-1||xs.test(e)))return t.quotingType===se?'"'+e+'"':"'"+e+"'";var a=t.indent*Math.max(1,i),r=t.lineWidth===-1?-1:Math.max(Math.min(t.lineWidth,40),t.lineWidth-a),o=n||t.flowLevel>-1&&i>=t.flowLevel;function l(d){return Es(t,d)}switch(Ss(e,o,t.indent,r,l,t.quotingType,t.forceQuotes&&!n,s)){case Qt:return e;case Pe:return"'"+e.replace(/'/g,"''")+"'";case Jt:return"|"+ei(e,t.indent)+ti(Yt(e,a));case Xt:return">"+ei(e,t.indent)+ti(Yt($s(e,r),a));case X:return'"'+_s(e)+'"';default:throw new T("impossible error: invalid scalar style")}})()}function ei(t,e){var i=Kt(t)?String(e):"",n=t[t.length-1]===`
|
|
21
|
+
`,s=n&&(t[t.length-2]===`
|
|
22
|
+
`||t===`
|
|
23
|
+
`),a=s?"+":n?"":"-";return i+a+`
|
|
24
|
+
`}function ti(t){return t[t.length-1]===`
|
|
25
|
+
`?t.slice(0,-1):t}function $s(t,e){for(var i=/(\n+)([^\n]*)/g,n=(function(){var d=t.indexOf(`
|
|
26
|
+
`);return d=d!==-1?d:t.length,i.lastIndex=d,ii(t.slice(0,d),e)})(),s=t[0]===`
|
|
27
|
+
`||t[0]===" ",a,r;r=i.exec(t);){var o=r[1],l=r[2];a=l[0]===" ",n+=o+(!s&&!a&&l!==""?`
|
|
28
|
+
`:"")+ii(l,e),s=a}return n}function ii(t,e){if(t===""||t[0]===" ")return t;for(var i=/ [^ ]/g,n,s=0,a,r=0,o=0,l="";n=i.exec(t);)o=n.index,o-s>e&&(a=r>s?r:o,l+=`
|
|
29
|
+
`+t.slice(s,a),s=a+1),r=o;return l+=`
|
|
30
|
+
`,t.length-s>e&&r>s?l+=t.slice(s,r)+`
|
|
31
|
+
`+t.slice(r+1):l+=t.slice(s),l.slice(1)}function _s(t){for(var e="",i=0,n,s=0;s<t.length;i>=65536?s+=2:s++)i=re(t,s),n=_[i],!n&&ae(i)?(e+=t[s],i>=65536&&(e+=t[s+1])):e+=n||Cs(i);return e}function Ns(t,e,i){var n="",s=t.tag,a,r,o;for(a=0,r=i.length;a<r;a+=1)o=i[a],t.replacer&&(o=t.replacer.call(i,String(a),o)),(V(t,e,o,!1,!1)||typeof o>"u"&&V(t,e,null,!1,!1))&&(n!==""&&(n+=","+(t.condenseFlow?"":" ")),n+=t.dump);t.tag=s,t.dump="["+n+"]"}function ni(t,e,i,n){var s="",a=t.tag,r,o,l;for(r=0,o=i.length;r<o;r+=1)l=i[r],t.replacer&&(l=t.replacer.call(i,String(r),l)),(V(t,e+1,l,!0,!0,!1,!0)||typeof l>"u"&&V(t,e+1,null,!0,!0,!1,!0))&&((!n||s!=="")&&(s+=Re(t,e)),t.dump&&ne===t.dump.charCodeAt(0)?s+="-":s+="- ",s+=t.dump);t.tag=a,t.dump=s||"[]"}function Ts(t,e,i){var n="",s=t.tag,a=Object.keys(i),r,o,l,d,p;for(r=0,o=a.length;r<o;r+=1)p="",n!==""&&(p+=", "),t.condenseFlow&&(p+='"'),l=a[r],d=i[l],t.replacer&&(d=t.replacer.call(i,l,d)),V(t,e,l,!1,!1)&&(t.dump.length>1024&&(p+="? "),p+=t.dump+(t.condenseFlow?'"':"")+":"+(t.condenseFlow?"":" "),V(t,e,d,!1,!1)&&(p+=t.dump,n+=p));t.tag=s,t.dump="{"+n+"}"}function Ms(t,e,i,n){var s="",a=t.tag,r=Object.keys(i),o,l,d,p,u,f;if(t.sortKeys===!0)r.sort();else if(typeof t.sortKeys=="function")r.sort(t.sortKeys);else if(t.sortKeys)throw new T("sortKeys must be a boolean or a function");for(o=0,l=r.length;o<l;o+=1)f="",(!n||s!=="")&&(f+=Re(t,e)),d=r[o],p=i[d],t.replacer&&(p=t.replacer.call(i,d,p)),V(t,e+1,d,!0,!0,!0)&&(u=t.tag!==null&&t.tag!=="?"||t.dump&&t.dump.length>1024,u&&(t.dump&&ne===t.dump.charCodeAt(0)?f+="?":f+="? "),f+=t.dump,u&&(f+=Re(t,e)),V(t,e+1,p,!0,u)&&(t.dump&&ne===t.dump.charCodeAt(0)?f+=":":f+=": ",f+=t.dump,s+=f));t.tag=a,t.dump=s||"{}"}function si(t,e,i){var n,s,a,r,o,l;for(s=i?t.explicitTypes:t.implicitTypes,a=0,r=s.length;a<r;a+=1)if(o=s[a],(o.instanceOf||o.predicate)&&(!o.instanceOf||typeof e=="object"&&e instanceof o.instanceOf)&&(!o.predicate||o.predicate(e))){if(i?o.multi&&o.representName?t.tag=o.representName(e):t.tag=o.tag:t.tag="?",o.represent){if(l=t.styleMap[o.tag]||o.defaultStyle,Rt.call(o.represent)==="[object Function]")n=o.represent(e,l);else if(Pt.call(o.represent,l))n=o.represent[l](e,l);else throw new T("!<"+o.tag+'> tag resolver accepts not "'+l+'" style');t.dump=n}return!0}return!1}function V(t,e,i,n,s,a,r){t.tag=null,t.dump=i,si(t,i,!1)||si(t,i,!0);var o=Rt.call(t.dump),l=n,d;n&&(n=t.flowLevel<0||t.flowLevel>e);var p=o==="[object Object]"||o==="[object Array]",u,f;if(p&&(u=t.duplicates.indexOf(i),f=u!==-1),(t.tag!==null&&t.tag!=="?"||f||t.indent!==2&&e>0)&&(s=!1),f&&t.usedDuplicates[u])t.dump="*ref_"+u;else{if(p&&f&&!t.usedDuplicates[u]&&(t.usedDuplicates[u]=!0),o==="[object Object]")n&&Object.keys(t.dump).length!==0?(Ms(t,e,t.dump,s),f&&(t.dump="&ref_"+u+t.dump)):(Ts(t,e,t.dump),f&&(t.dump="&ref_"+u+" "+t.dump));else if(o==="[object Array]")n&&t.dump.length!==0?(t.noArrayIndent&&!r&&e>0?ni(t,e-1,t.dump,s):ni(t,e,t.dump,s),f&&(t.dump="&ref_"+u+t.dump)):(Ns(t,e,t.dump),f&&(t.dump="&ref_"+u+" "+t.dump));else if(o==="[object String]")t.tag!=="?"&&Ls(t,t.dump,e,a,l);else{if(o==="[object Undefined]")return!1;if(t.skipInvalid)return!1;throw new T("unacceptable kind of an object to dump "+o)}t.tag!==null&&t.tag!=="?"&&(d=encodeURI(t.tag[0]==="!"?t.tag.slice(1):t.tag).replace(/!/g,"%21"),t.tag[0]==="!"?d="!"+d:d.slice(0,18)==="tag:yaml.org,2002:"?d="!!"+d.slice(18):d="!<"+d+">",t.dump=d+" "+t.dump)}return!0}function Ds(t,e){var i=[],n=[],s,a;for(Ve(t,i,n),s=0,a=n.length;s<a;s+=1)e.duplicates.push(i[n[s]]);e.usedDuplicates=new Array(a)}function Ve(t,e,i){var n,s,a;if(t!==null&&typeof t=="object")if(s=e.indexOf(t),s!==-1)i.indexOf(s)===-1&&i.push(s);else if(e.push(t),Array.isArray(t))for(s=0,a=t.length;s<a;s+=1)Ve(t[s],e,i);else for(n=Object.keys(t),s=0,a=n.length;s<a;s+=1)Ve(t[n[s]],e,i)}function Fs(t,e){e=e||{};var i=new ws(e);i.noRefs||Ds(t,i);var n=t;return i.replacer&&(n=i.replacer.call({"":n},"",n)),V(i,0,n,!0,!0)?i.dump+`
|
|
32
|
+
`:""}var Os=Fs,Hs={dump:Os};function je(t,e){return function(){throw new Error("Function yaml."+t+" is removed in js-yaml 4. Use yaml."+e+" instead, which is now safe by default.")}}var zs=$,Bs=at,Rs=ct,Ps=ft,Vs=mt,js=De,ai=Bt.load,Us=Bt.loadAll,qs=Hs.dump,Ws=T,Ys={binary:yt,float:pt,map:lt,null:dt,pairs:kt,set:wt,timestamp:vt,bool:ht,int:ut,merge:xt,omap:Ct,seq:ot,str:rt},Gs=je("safeLoad","load"),Zs=je("safeLoadAll","loadAll"),Ks=je("safeDump","dump"),ri={Type:zs,Schema:Bs,FAILSAFE_SCHEMA:Rs,JSON_SCHEMA:Ps,CORE_SCHEMA:Vs,DEFAULT_SCHEMA:js,load:ai,loadAll:Us,dump:qs,YAMLException:Ws,types:Ys,safeLoad:Gs,safeLoadAll:Zs,safeDump:Ks};const Qs=[],oi=["submit","navigate","custom","reset"],li=["field_group","action_group","layout","template"];function k(t){return t!=null}function M(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function S(t){return Array.isArray(t)}function xe(t){return typeof t=="string"}function ye(t){return t.toLowerCase().replace(/[()()]/g,"").replace(/[・]/g,"_").replace(/\s+/g,"_").replace(/[^a-z0-9_\u3040-\u309f\u30a0-\u30ff\u4e00-\u9faf]/g,"")}function oe(t){var r,o;const e=t.id??t.field_name??"unknown",i=t.label??t.field_name??"Unknown";let n;t.options&&(S(t.options)&&t.options.length>0?xe(t.options[0])?n=t.options.map(l=>({value:l,label:l})):n=t.options:xe(t.options)&&(n=t.options));const s={id:e,label:i,description:t.description,required:t.required,placeholder:t.placeholder,...t.visible_when?{visible_when:t.visible_when}:{}},a=t.type;switch(a){case"text":return{...s,type:"text",input_type:t.input_type};case"number":return{...s,type:"number",min:t.min,max:t.max,unit:t.unit};case"textarea":return{...s,type:"textarea",rows:t.rows};case"select":return{...s,type:"select",options:n??[]};case"multi_select":return{...s,type:"multi_select",options:n??[]};case"radio_group":return{...s,type:"radio_group",options:n??[]};case"checkbox_group":return{...s,type:"checkbox_group",options:n??[]};case"date_picker":return{...s,type:"date_picker"};case"time_picker":return{...s,type:"time_picker"};case"duration_picker":return{...s,type:"duration_picker",units:t.units};case"duration_input":return{...s,type:"duration_input",display_unit:t.unit};case"file_upload":return{...s,type:"file_upload",accept:((r=t.accepted_types)==null?void 0:r.split(",").map(l=>l.trim()))??t.accept,multiple:t.multiple};case"repeater":return{...s,type:"repeater",item_fields:((o=t.item_fields)==null?void 0:o.map(oe))??[]};case"data_table":{const l=t.data,d=l==null?void 0:l.map((p,u)=>p.id===void 0&&p.id!==0?{...p,id:`row-${u}`}:p);return{...s,type:"data_table",columns:t.columns??[],data:d,selection:t.selection,row_actions:t.row_actions,default_sort:t.default_sort,pagination:t.pagination,filters:t.filters,empty_state:t.empty_state,height:t.height,striped:t.striped,hoverable:t.hoverable,bordered:t.bordered,compact:t.compact,responsive:t.responsive}}case"google_map_embed":return{...s,type:"google_map_embed",height:t.height,width:t.width,show_open_link:t.show_open_link,zoom:t.zoom};case"photo_manager":return{...s,type:"photo_manager",photos:t.photos,max_photos:t.max_photos,max_file_size:t.max_file_size,accepted_formats:t.accepted_formats,columns:t.columns};case"image_uploader":return{...s,type:"image_uploader",accepted_formats:t.accepted_formats,max_file_size:t.max_file_size,max_files:t.max_files,min_files:t.min_files};case"browser":return{...s,type:"browser",items:t.items??[],default:t.default,maxColumns:t.max_columns,height:t.height};case"calendar":return{...s,type:"calendar",default:t.default,from:t.from,to:t.to,weekStartsOn:t.week_starts_on,locale:t.locale};case"combobox":return{...s,type:"combobox",mode:t.mode,options:n,searchable:t.searchable,async_loader:t.async_loader,min_search_length:t.min_search_length,debounce_ms:t.debounce_ms,clearable:t.clearable,max_selections:t.max_selections};case"checkbox":return{...s,type:"checkbox",checked_label:t.checked_label,unchecked_label:t.unchecked_label,size:t.size,name:t.name,label_position:t.label_position};case"toggle":return{...s,type:"toggle",checked_label:t.checked_label,unchecked_label:t.unchecked_label,size:t.size,name:t.name,label_position:t.label_position};case"badge":return{...s,type:"badge",color:t.color,size:t.size,dot:t.dot,count:t.count,max_count:t.max_count,text:t.text};case"heading":return{...s,type:"heading",level:t.level??2,text:t.label??t.text??"",size:t.size,align:t.align,color:t.color,icon:t.icon};case"tooltip":return{...s,type:"tooltip",content:t.content??"",position:t.position,delay:t.delay,show_arrow:t.show_arrow,is_html:t.is_html,max_width:t.max_width};case"pagination":return{...s,type:"pagination",total_items:t.total_items??0,current_page:t.current_page,page_size:t.page_size,page_size_options:t.page_size_options,show_page_size_selector:t.show_page_size_selector,show_item_count:t.show_item_count,show_jump_buttons:t.show_jump_buttons,max_page_buttons:t.max_page_buttons,compact:t.compact,align:t.align};case"float_area":return{...s,type:"float_area",position:t.position,show_shadow:t.show_shadow,show_border:t.show_border,z_index:t.z_index,responsive:t.responsive,sticky:t.sticky,align:t.float_align??t.align,padding:t.padding,gap:t.gap,aria_label:t.aria_label};case"loader":return{...s,type:"loader",size:t.loader_size??t.size,loaderType:t.loader_type??t.loaderType,overlay:t.overlay,showProgress:t.show_progress??t.showProgress,initialProgress:t.initial_progress??t.initialProgress};default:return{...s,type:a}}}function Js(t){const e=[];for(const i of t)if(i.input_fields)for(const n of i.input_fields)e.push(oe(n));return e}function Xs(t,e,i){const n=t.map((r,o)=>({id:`col_${o}`,label:r,sortable:!0}));let s;return e&&e.length>0&&(s={enabled:!0,show_search:e.some(r=>r.includes("キーワード")||r.includes("検索")),fields:e.filter(r=>!r.includes("キーワード")&&!r.includes("検索")).map((r,o)=>({id:`filter_${o}`,label:r,column:`col_${o}`,type:"select",options:[]}))}),{id:i?ye(i)+"_table":"data_table",type:"data_table",label:i??"一覧",columns:n,data:[],selection:"single",pagination:{enabled:!0,page_size:10,page_size_options:[10,25,50,100]},filters:s,empty_state:{title:"データがありません",description:"表示するデータが存在しません",icon:"📭"},hoverable:!0,striped:!0}}function ea(t){var e;return{section_name:t.section_name,icon:t.icon,publish_toggle:t.publish_toggle,input_fields:(e=t.input_fields)==null?void 0:e.map(oe)}}function ta(t){var e;if(t)return{logo:t.logo,logoAlt:t.logo_alt,logoHref:t.logo_href,appName:t.app_name??t.appName??"",tenants:t.tenants,currentTenantId:t.current_tenant_id??t.currentTenantId,userInfo:t.user_info?{name:t.user_info.name,email:t.user_info.email,avatarUrl:t.user_info.avatar_url??t.user_info.avatarUrl}:{name:""},navigations:(e=t.navigations)==null?void 0:e.map(i=>{var n;return{id:i.id,label:i.label,href:i.href,active:i.active,disabled:i.disabled,dropdown:(n=i.dropdown)==null?void 0:n.map(s=>({id:s.id,label:s.label,href:s.href,divider:s.divider}))}}),appLauncher:t.app_launcher??t.appLauncher,helpPageUrl:t.help_page_url??t.helpPageUrl,showReleaseNote:t.show_release_note??t.showReleaseNote,releaseNoteText:t.release_note_text??t.releaseNoteText,showDataSync:t.show_data_sync??t.showDataSync}}function ia(t){var i;if(!t)return;const e=((i=t.items)==null?void 0:i.map(n=>{var s;return{id:n.id,label:n.label,type:n.type,icon:n.icon,disabled:n.disabled,current:n.current,href:n.href,target:n.target,dropdownItems:(s=n.dropdown_items??n.dropdownItems)==null?void 0:s.map(a=>({id:a.id,label:a.label,icon:a.icon,disabled:a.disabled,href:a.href}))}}))??[];return{label:t.label,items:e}}function ci(t){const e=t.title??t.name??"Untitled";let i,n;t.sections&&t.sections.length>0?(i=t.sections.map(ea),n=Js(t.sections)):t.fields?n=t.fields.map(oe):t.display_fields&&S(t.display_fields)&&(n=[Xs(t.display_fields,t.filters,t.name)]),!n&&t.input_fields&&S(t.input_fields)&&(n=t.input_fields.map(oe));let s=t.actions;return s&&S(s)&&(s=s.map((a,r)=>xe(a)?{id:`action_${r}`,type:"submit",label:a,style:r===0?"primary":"secondary"}:a)),{title:e,description:t.description??t.purpose,app_header:ta(t.app_header),app_navi:ia(t.app_navi),sections:i,fields:n,actions:s,wizard:t.wizard,layout:t.layout}}function na(t){if(S(t)){const i={};for(const n of t){const s=n.name?ye(n.name):`screen_${Object.keys(i).length}`;i[s]=ci(n)}return i}const e={};for(const[i,n]of Object.entries(t))e[i]=ci(n);return e}function sa(t){if(t){if(S(t)){const e={};for(const i of t){const n=ye(i.component_name);e[n]={name:i.component_name,description:i.description,type:"field_group"}}return e}return t}}function aa(t){if(t){if(S(t)){const e={};for(const i of t){const n=ye(i.field);e[n]={name:i.field,rules:{message:i.rule},message:i.rule}}return e}return t}}function ra(t){return{view:na(t.view),common_components:sa(t.common_components),validations:aa(t.validations)}}function Ce(t,e){const i=[];if(!M(t))return i.push({type:"INVALID_VALUE",message:"Field must be an object",path:e}),i;const n=t.type,s=Qs.includes(n),a=["heading","notification_bar","response_message","timeline","chip","status_label","loader","stepper","section_nav","tabs","disclosure","accordion_panel","information_panel","float_area"].includes(n);return!k(t.id)&&!a&&!s&&i.push({type:"MISSING_REQUIRED_FIELD",message:'Field must have an "id"',path:e}),k(t.type)||i.push({type:"MISSING_REQUIRED_FIELD",message:'Field must have a "type"',path:e}),!k(t.label)&&!s&&i.push({type:"MISSING_REQUIRED_FIELD",message:'Field must have a "label"',path:e}),["select","multi_select","radio_group","checkbox_group"].includes(t.type)&&(k(t.options)?!S(t.options)&&!xe(t.options)?i.push({type:"INVALID_VALUE",message:"Options must be an array or a reference string",path:`${e}.options`}):S(t.options)&&t.options.forEach((o,l)=>{i.push(...oa(o,`${e}.options[${l}]`))}):i.push({type:"MISSING_REQUIRED_FIELD",message:`Field type "${t.type}" requires "options"`,path:e})),t.type==="repeater"&&(k(t.item_fields)?S(t.item_fields)?t.item_fields.forEach((o,l)=>{i.push(...Ce(o,`${e}.item_fields[${l}]`))}):i.push({type:"INVALID_VALUE",message:"item_fields must be an array",path:`${e}.item_fields`}):i.push({type:"MISSING_REQUIRED_FIELD",message:'Repeater field must have "item_fields"',path:e})),i}function oa(t,e){const i=[];return M(t)?(k(t.value)||i.push({type:"MISSING_REQUIRED_FIELD",message:'Option must have a "value"',path:e}),k(t.label)||i.push({type:"MISSING_REQUIRED_FIELD",message:'Option must have a "label"',path:e}),i):(i.push({type:"INVALID_VALUE",message:"Option must be an object",path:e}),i)}function di(t,e){const i=[];return M(t)?(k(t.id)||i.push({type:"MISSING_REQUIRED_FIELD",message:'Action must have an "id"',path:e}),k(t.type)?oi.includes(t.type)||i.push({type:"INVALID_FIELD_TYPE",message:`Invalid action type: "${t.type}". Valid types are: ${oi.join(", ")}`,path:`${e}.type`}):i.push({type:"MISSING_REQUIRED_FIELD",message:'Action must have a "type"',path:e}),k(t.label)||i.push({type:"MISSING_REQUIRED_FIELD",message:'Action must have a "label"',path:e}),t.type==="navigate"&&!k(t.to)&&i.push({type:"MISSING_REQUIRED_FIELD",message:'Navigate action must have a "to" destination',path:e}),i):(i.push({type:"INVALID_VALUE",message:"Action must be an object",path:e}),i)}function la(t,e){const i=[];return M(t)?k(t.steps)?S(t.steps)?(t.steps.forEach((n,s)=>{i.push(...ca(n,`${e}.steps[${s}]`))}),i):(i.push({type:"INVALID_VALUE",message:"Wizard steps must be an array",path:`${e}.steps`}),i):(i.push({type:"MISSING_REQUIRED_FIELD",message:'Wizard must have "steps"',path:e}),i):(i.push({type:"INVALID_VALUE",message:"Wizard must be an object",path:e}),i)}function ca(t,e){const i=[];return M(t)?(k(t.id)||i.push({type:"MISSING_REQUIRED_FIELD",message:'Wizard step must have an "id"',path:e}),k(t.title)||i.push({type:"MISSING_REQUIRED_FIELD",message:'Wizard step must have a "title"',path:e}),k(t.fields)?S(t.fields)?t.fields.forEach((n,s)=>{i.push(...Ce(n,`${e}.fields[${s}]`))}):i.push({type:"INVALID_VALUE",message:"Wizard step fields must be an array",path:`${e}.fields`}):i.push({type:"MISSING_REQUIRED_FIELD",message:'Wizard step must have "fields"',path:e}),i):(i.push({type:"INVALID_VALUE",message:"Wizard step must be an object",path:e}),i)}function da(t,e){const i=[];return M(t)?(k(t.title)||i.push({type:"MISSING_REQUIRED_FIELD",message:'Screen must have a "title"',path:e}),k(t.wizard)&&i.push(...la(t.wizard,`${e}.wizard`)),k(t.fields)&&(S(t.fields)?t.fields.forEach((n,s)=>{i.push(...Ce(n,`${e}.fields[${s}]`))}):i.push({type:"INVALID_VALUE",message:"Screen fields must be an array",path:`${e}.fields`})),k(t.actions)&&(S(t.actions)?t.actions.forEach((n,s)=>{i.push(...di(n,`${e}.actions[${s}]`))}):i.push({type:"INVALID_VALUE",message:"Screen actions must be an array",path:`${e}.actions`})),i):(i.push({type:"INVALID_VALUE",message:"Screen definition must be an object",path:e}),i)}function ha(t,e){const i=[];return M(t)?(k(t.name)||i.push({type:"MISSING_REQUIRED_FIELD",message:'Common component must have a "name"',path:e}),k(t.type)?li.includes(t.type)||i.push({type:"INVALID_FIELD_TYPE",message:`Invalid component type: "${t.type}". Valid types are: ${li.join(", ")}`,path:`${e}.type`}):i.push({type:"MISSING_REQUIRED_FIELD",message:'Common component must have a "type"',path:e}),t.type==="field_group"&&k(t.fields)&&(S(t.fields)?t.fields.forEach((n,s)=>{i.push(...Ce(n,`${e}.fields[${s}]`))}):i.push({type:"INVALID_VALUE",message:"Component fields must be an array",path:`${e}.fields`})),t.type==="action_group"&&k(t.actions)&&(S(t.actions)?t.actions.forEach((n,s)=>{i.push(...di(n,`${e}.actions[${s}]`))}):i.push({type:"INVALID_VALUE",message:"Component actions must be an array",path:`${e}.actions`})),i):(i.push({type:"INVALID_VALUE",message:"Common component must be an object",path:e}),i)}function ua(t,e){const i=[];return M(t)?(k(t.name)||i.push({type:"MISSING_REQUIRED_FIELD",message:'Validation rule must have a "name"',path:e}),k(t.rules)||i.push({type:"MISSING_REQUIRED_FIELD",message:'Validation rule must have "rules"',path:e}),i):(i.push({type:"INVALID_VALUE",message:"Validation rule must be an object",path:e}),i)}function pa(t,e){const i=[];return M(t)?(!k(t.name)&&!k(t.title)&&i.push({type:"MISSING_REQUIRED_FIELD",message:'Screen must have a "name" or "title"',path:e}),k(t.sections)&&(S(t.sections)||i.push({type:"INVALID_VALUE",message:"sections must be an array",path:`${e}.sections`})),i):(i.push({type:"INVALID_VALUE",message:"Screen definition must be an object",path:e}),i)}function fa(t,e){const i=[];return M(t)?(k(t.component_name)||i.push({type:"MISSING_REQUIRED_FIELD",message:'Common component must have a "component_name"',path:e}),i):(i.push({type:"INVALID_VALUE",message:"Common component must be an object",path:e}),i)}function ma(t,e){const i=[];return M(t)?(k(t.field)||i.push({type:"MISSING_REQUIRED_FIELD",message:'Validation rule must have a "field"',path:e}),k(t.rule)||i.push({type:"MISSING_REQUIRED_FIELD",message:'Validation rule must have a "rule"',path:e}),i):(i.push({type:"INVALID_VALUE",message:"Validation rule must be an object",path:e}),i)}function ga(t){const e=[];if(!M(t))return e.push({type:"SCHEMA_VALIDATION_ERROR",message:"Root must be an object",path:""}),e;if(!k(t.view))e.push({type:"MISSING_REQUIRED_FIELD",message:'Schema must have a "view" section',path:""});else if(S(t.view))t.view.forEach((i,n)=>{e.push(...pa(i,`view[${n}]`))});else if(M(t.view))for(const[i,n]of Object.entries(t.view))e.push(...da(n,`view.${i}`));else e.push({type:"INVALID_VALUE",message:'"view" must be an object or array',path:"view"});if(k(t.common_components))if(S(t.common_components))t.common_components.forEach((i,n)=>{e.push(...fa(i,`common_components[${n}]`))});else if(M(t.common_components))for(const[i,n]of Object.entries(t.common_components))e.push(...ha(n,`common_components.${i}`));else e.push({type:"INVALID_VALUE",message:'"common_components" must be an object or array',path:"common_components"});if(k(t.validations))if(S(t.validations))t.validations.forEach((i,n)=>{e.push(...ma(i,`validations[${n}]`))});else if(M(t.validations))for(const[i,n]of Object.entries(t.validations))e.push(...ua(n,`validations.${i}`));else e.push({type:"INVALID_VALUE",message:'"validations" must be an object or array',path:"validations"});return e}function Ue(t){var e,i;try{const n=ri.load(t),s=ga(n);return s.length>0?{success:!1,errors:s}:{success:!0,data:ra(n)}}catch(n){return n instanceof ri.YAMLException?{success:!1,errors:[{type:"YAML_SYNTAX_ERROR",message:n.message,line:(e=n.mark)==null?void 0:e.line,column:(i=n.mark)==null?void 0:i.column}]}:{success:!1,errors:[{type:"YAML_SYNTAX_ERROR",message:n instanceof Error?n.message:"Unknown error"}]}}}function ba(t){return t.map(e=>{let i="";return e.path&&(i=` at "${e.path}"`),e.line!==void 0&&(i+=` (line ${e.line+1}`,e.column!==void 0&&(i+=`, column ${e.column+1}`),i+=")"),`[${e.type}]${i}: ${e.message}`}).join(`
|
|
33
|
+
`)}function qe(t,e){return t.view[e]}function hi(t){return Object.keys(t.view)}function ui(t,e){for(const i of t){if(i.id===e)return i;if(i.type==="repeater"){const n=ui(i.item_fields,e);if(n)return n}}}function c(t,e){const i=document.createElement(t);if(e!=null&&e.className&&(i.className=e.className),e!=null&&e.attributes)for(const[n,s]of Object.entries(e.attributes))i.setAttribute(n,s);if(e!=null&&e.textContent&&(i.textContent=e.textContent),e!=null&&e.children)for(const n of e.children)typeof n=="string"?i.appendChild(document.createTextNode(n)):i.appendChild(n);return i}function B(t){for(;t.firstChild;)t.removeChild(t.firstChild)}function E(t="mokkun"){return`${t}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`}function va(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}function m(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}function y(t,e){const i=t.required?'<span class="required-mark">*</span>':"",n=t.description?`<p class="field-description">${m(t.description)}</p>`:"",s=["form-field",`field-type-${t.type}`];t.class&&s.push(t.class);const a=t.visible_when?` data-visible-when="${m(JSON.stringify(t.visible_when))}"`:"";return`
|
|
34
|
+
<div class="${s.join(" ")}" data-field-id="${m(t.id)}"${a}>
|
|
35
|
+
<label class="field-label" for="${m(t.id)}">
|
|
36
|
+
${m(t.label)}${i}
|
|
37
|
+
</label>
|
|
38
|
+
${e}
|
|
39
|
+
${n}
|
|
40
|
+
</div>
|
|
41
|
+
`}function j(t){const e=[`id="${m(t.id)}"`,`name="${m(t.id)}"`];return t.required&&e.push("required"),t.disabled&&e.push("disabled"),t.readonly&&e.push("readonly"),"placeholder"in t&&t.placeholder&&e.push(`placeholder="${m(t.placeholder)}"`),e.join(" ")}function le(t){return typeof t=="string"?[]:t}function xa(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function ya(t){return{"image/jpeg":"JPEG","image/png":"PNG","image/webp":"WebP","image/gif":"GIF"}[t]??t}function pi(t){return{1:"2xl",2:"xl",3:"lg",4:"md",5:"sm",6:"xs"}[t]}const ke={days:"日",hours:"時間",minutes:"分",seconds:"秒"};class ee{constructor(e,i={},n={}){h(this,"config");h(this,"state");h(this,"callbacks");h(this,"container");h(this,"instanceId");h(this,"inputElement",null);this.config=i,this.container=e,this.callbacks=n,this.instanceId=E("input"),this.state=this.createInitialState()}render(){this.container.innerHTML="";const e=this.config.size??"medium",i=!!this.config.prefix,n=!!this.config.suffix||!!this.config.clearable;this.container.className=`mokkun-input input-${e}`,this.container.setAttribute("data-state",this.getDataState()),this.state.disabled?this.container.setAttribute("data-disabled",""):this.container.removeAttribute("data-disabled"),this.state.readonly?this.container.setAttribute("data-readonly",""):this.container.removeAttribute("data-readonly"),this.state.error?this.container.setAttribute("data-error",""):this.container.removeAttribute("data-error");const s=c("div",{className:"input-wrapper"}),a=this.renderInputGroup(i,n);if(s.appendChild(a),this.state.error&&this.state.errorMessage){const r=this.renderError();s.appendChild(r)}this.container.appendChild(s),this.config.autoFocus&&this.inputElement&&this.inputElement.focus()}setValue(e){var i,n;this.state.value!==e&&(this.state={...this.state,value:e},this.inputElement&&(this.inputElement.value=e),(n=(i=this.callbacks).onChange)==null||n.call(i,e,this.state))}getValue(){return this.state.value}setError(e,i){this.state={...this.state,error:e,errorMessage:i},this.render()}setDisabled(e){this.state.disabled!==e&&(this.state={...this.state,disabled:e},this.render())}setReadonly(e){this.state.readonly!==e&&(this.state={...this.state,readonly:e},this.render())}focus(){this.inputElement&&this.inputElement.focus()}blur(){this.inputElement&&this.inputElement.blur()}clear(){var e,i;this.setValue(""),(i=(e=this.callbacks).onClear)==null||i.call(e,this.state),this.focus()}getState(){return{...this.state}}destroy(){this.container.innerHTML=""}createInitialState(){return{value:this.config.defaultValue??"",disabled:this.config.disabled??!1,readonly:this.config.readonly??!1,error:!!this.config.errorMessage,errorMessage:this.config.errorMessage,focused:!1}}getDataState(){return this.state.error?"error":this.state.focused?"focused":this.state.value?"filled":"empty"}renderInputGroup(e,i){const n=c("div",{className:`input-group ${e?"has-prefix":""} ${i?"has-suffix":""}`});if(e&&this.config.prefix){const a=this.renderAffix(this.config.prefix,"prefix");n.appendChild(a)}const s=this.renderInput();if(n.appendChild(s),i){if(this.config.clearable&&this.state.value&&!this.state.disabled&&!this.state.readonly){const a=this.renderClearButton();n.appendChild(a)}else if(this.config.suffix){const a=this.renderAffix(this.config.suffix,"suffix");n.appendChild(a)}}return n}renderInput(){const e=c("input",{className:"input-field",attributes:{type:this.config.type??"text",id:this.instanceId,...this.config.name&&{name:this.config.name},...this.config.placeholder&&{placeholder:this.config.placeholder},...this.config.required&&{required:"required"},...this.config.autoComplete&&{autocomplete:this.config.autoComplete},...this.config.ariaLabel&&{"aria-label":this.config.ariaLabel},...this.config.ariaDescribedBy&&{"aria-describedby":this.config.ariaDescribedBy},...this.state.disabled&&{disabled:"disabled"},...this.state.readonly&&{readonly:"readonly"},...this.state.error&&{"aria-invalid":"true"}}});return e.value=this.state.value,e.addEventListener("input",this.handleInput.bind(this)),e.addEventListener("focus",this.handleFocus.bind(this)),e.addEventListener("blur",this.handleBlur.bind(this)),e.addEventListener("keydown",this.handleKeyDown.bind(this)),this.inputElement=e,e}renderAffix(e,i){const n=c("span",{className:`input-${i}`});return typeof e=="string"?n.textContent=e:n.appendChild(e),n}renderClearButton(){const e=c("button",{className:"input-clear-button",attributes:{type:"button","aria-label":"Clear input"}}),i=c("span",{className:"clear-icon",textContent:"×"});return e.appendChild(i),e.addEventListener("click",this.handleClear.bind(this)),e}renderError(){return c("div",{className:"input-error-message",attributes:{id:`${this.instanceId}-error`,role:"alert"},textContent:this.state.errorMessage??""})}handleInput(e){var s,a;const n=e.target.value;this.state={...this.state,value:n},(a=(s=this.callbacks).onChange)==null||a.call(s,n,this.state),this.config.clearable&&this.updateClearButton()}updateClearButton(){const e=this.container.querySelector(".input-group");if(!e)return;const i=e.querySelector(".input-clear-button"),n=e.querySelector(".input-suffix"),s=this.state.value&&!this.state.disabled&&!this.state.readonly;if(s&&!i){n&&n.remove();const a=this.renderClearButton();e.appendChild(a)}else if(!s&&i&&(i.remove(),this.config.suffix)){const a=this.renderAffix(this.config.suffix,"suffix");e.appendChild(a)}}handleFocus(){var e,i;this.state={...this.state,focused:!0},this.container.setAttribute("data-state",this.getDataState()),(i=(e=this.callbacks).onFocus)==null||i.call(e,this.state)}handleBlur(){var e,i;this.state={...this.state,focused:!1},this.container.setAttribute("data-state",this.getDataState()),(i=(e=this.callbacks).onBlur)==null||i.call(e,this.state)}handleKeyDown(e){var i,n;e.key==="Enter"&&((n=(i=this.callbacks).onEnter)==null||n.call(i,this.state.value,this.state))}handleClear(){this.clear()}static renderField(e){switch(e.type){case"text":return ee.renderTextField(e);case"number":return ee.renderNumberField(e);case"date_picker":return ee.renderDatePickerField(e);case"time_picker":return ee.renderTimePickerField(e);default:return""}}static renderTextField(e){const i=e.input_type??"text",n=[j(e)];e.min_length!==void 0&&n.push(`minlength="${e.min_length}"`),e.max_length!==void 0&&n.push(`maxlength="${e.max_length}"`),e.pattern&&n.push(`pattern="${m(e.pattern)}"`),e.default!==void 0&&n.push(`value="${m(String(e.default))}"`);const s=`<input type="${i}" class="form-input" ${n.join(" ")} />`;return y(e,s)}static renderNumberField(e){const i=[j(e)];e.min!==void 0&&i.push(`min="${e.min}"`),e.max!==void 0&&i.push(`max="${e.max}"`),e.step!==void 0&&i.push(`step="${e.step}"`),e.default!==void 0&&i.push(`value="${e.default}"`);let n=`<input type="number" class="form-input" ${i.join(" ")} />`;return e.unit&&(n=`
|
|
42
|
+
<div class="input-with-unit">
|
|
43
|
+
${n}
|
|
44
|
+
<span class="input-unit">${m(e.unit)}</span>
|
|
45
|
+
</div>
|
|
46
|
+
`),y(e,n)}static renderDatePickerField(e){const i=e.include_time?"datetime-local":"date",n=[j(e)];e.min_date&&n.push(`min="${m(e.min_date)}"`),e.max_date&&n.push(`max="${m(e.max_date)}"`),e.default!==void 0&&n.push(`value="${m(String(e.default))}"`);const s=`<input type="${i}" class="form-input" ${n.join(" ")} />`;return y(e,s)}static renderTimePickerField(e){const i=[j(e)];e.minute_step&&i.push(`step="${e.minute_step*60}"`),e.default!==void 0&&i.push(`value="${m(String(e.default))}"`);const n=`<input type="time" class="form-input" ${i.join(" ")} />`;return y(e,n)}}class We{constructor(e,i={},n={}){h(this,"config");h(this,"state");h(this,"callbacks");h(this,"container");h(this,"textareaElement");h(this,"instanceId");this.config=i,this.container=e,this.callbacks=n,this.instanceId=i.id??E("textarea"),this.state=this.createInitialState()}render(){this.container.innerHTML="";const e=c("div",{className:"mokkun-textarea-wrapper"});this.state.error&&e.classList.add("has-error"),this.state.disabled&&e.classList.add("is-disabled"),this.state.readonly&&e.classList.add("is-readonly");const i=this.renderTextarea();if(e.appendChild(i),this.config.showCount){const n=this.renderCounter();e.appendChild(n)}if(this.state.error&&this.state.errorMessage){const n=this.renderError();e.appendChild(n)}this.container.appendChild(e)}setValue(e){var i,n;this.state.value!==e&&(this.state={...this.state,value:e,characterCount:e.length},this.textareaElement&&(this.textareaElement.value=e,this.config.autoResize&&this.adjustHeight()),this.render(),(n=(i=this.callbacks).onChange)==null||n.call(i,e,this.state))}getValue(){return this.state.value}setDisabled(e){this.state.disabled!==e&&(this.state={...this.state,disabled:e},this.render())}setReadonly(e){this.state.readonly!==e&&(this.state={...this.state,readonly:e},this.render())}setError(e,i){this.state.error===e&&this.state.errorMessage===i||(this.state={...this.state,error:e,errorMessage:i},this.render())}clear(){this.setValue("")}focus(){var e;(e=this.textareaElement)==null||e.focus()}blur(){var e;(e=this.textareaElement)==null||e.blur()}validate(){const e=this.state.value;return this.config.required&&!e.trim()?(this.setError(!0,"この項目は必須です"),!1):this.config.minLength!==void 0&&e.length<this.config.minLength?(this.setError(!0,`${this.config.minLength}文字以上入力してください`),!1):this.config.maxLength!==void 0&&e.length>this.config.maxLength?(this.setError(!0,`${this.config.maxLength}文字以内で入力してください`),!1):(this.setError(!1),!0)}getState(){return{...this.state}}createInitialState(){const e=this.config.defaultValue??"";return{value:e,disabled:this.config.disabled??!1,readonly:this.config.readonly??!1,error:!1,errorMessage:this.config.errorMessage,characterCount:e.length}}renderTextarea(){const e=this.config.rows??3,i=this.config.resizable===!1?"no-resize":"",n=c("textarea",{className:`mokkun-textarea ${i}`,attributes:{id:this.instanceId,rows:String(e),"aria-label":"Textarea"}});return this.config.name&&n.setAttribute("name",this.config.name),this.config.placeholder&&n.setAttribute("placeholder",this.config.placeholder),this.config.minLength!==void 0&&n.setAttribute("minlength",String(this.config.minLength)),this.config.maxLength!==void 0&&n.setAttribute("maxlength",String(this.config.maxLength)),this.config.required&&(n.setAttribute("required","required"),n.setAttribute("aria-required","true")),this.state.disabled&&(n.setAttribute("disabled","disabled"),n.setAttribute("aria-disabled","true")),this.state.readonly&&(n.setAttribute("readonly","readonly"),n.setAttribute("aria-readonly","true")),this.state.error&&(n.setAttribute("aria-invalid","true"),this.state.errorMessage&&n.setAttribute("aria-describedby",`${this.instanceId}-error`)),n.value=this.state.value,n.addEventListener("input",s=>{var o,l;const r=s.target.value;this.state={...this.state,value:r,characterCount:r.length},this.config.autoResize&&this.adjustHeight(),this.config.showCount&&this.updateCounter(),(l=(o=this.callbacks).onInput)==null||l.call(o,r,this.state)}),n.addEventListener("change",s=>{var o,l;const r=s.target.value;(l=(o=this.callbacks).onChange)==null||l.call(o,r,this.state)}),n.addEventListener("focus",()=>{var s,a;(a=(s=this.callbacks).onFocus)==null||a.call(s,this.state)}),n.addEventListener("blur",()=>{var s,a;(a=(s=this.callbacks).onBlur)==null||a.call(s,this.state),this.validate()}),this.textareaElement=n,this.config.autoResize&&setTimeout(()=>this.adjustHeight(),0),n}renderCounter(){const e=c("div",{className:"mokkun-textarea-counter",attributes:{id:`${this.instanceId}-counter`,"aria-live":"polite"}});return this.updateCounterContent(e),e}updateCounterContent(e){const{characterCount:i}=this.state,{maxLength:n}=this.config;n!==void 0?(e.textContent=`${i} / ${n}`,i>n?e.classList.add("over-limit"):e.classList.remove("over-limit")):e.textContent=`${i}文字`}updateCounter(){const e=this.container.querySelector(`#${this.instanceId}-counter`);e instanceof HTMLElement&&this.updateCounterContent(e)}renderError(){return c("div",{className:"mokkun-textarea-error",textContent:this.state.errorMessage??"",attributes:{id:`${this.instanceId}-error`,role:"alert","aria-live":"polite"}})}adjustHeight(){if(!this.textareaElement)return;this.textareaElement.style.height="auto";const e=this.textareaElement.scrollHeight;this.textareaElement.style.height=`${e}px`}static renderField(e){const i=[j(e)];e.rows&&i.push(`rows="${e.rows}"`),e.min_length!==void 0&&i.push(`minlength="${e.min_length}"`),e.max_length!==void 0&&i.push(`maxlength="${e.max_length}"`);const n=e.resizable===!1?"no-resize":"",s=e.default!==void 0?m(String(e.default)):"",a=`<textarea class="form-textarea ${n}" ${i.join(" ")}>${s}</textarea>`;return y(e,a)}}function Ca(t,e={},i={}){const n=new We(t,e,i);return n.render(),n}function ka(t){return"options"in t&&Array.isArray(t.options)}class we{constructor(e,i,n={}){h(this,"config");h(this,"state");h(this,"callbacks");h(this,"container");h(this,"instanceId");h(this,"selectElement",null);this.config=i,this.container=e,this.callbacks=n,this.instanceId=E("select"),this.state=this.createInitialState()}render(){this.container.innerHTML="";const e=this.config.size??"default";this.container.className=`mokkun-select select-${e}`,this.state.disabled?this.container.setAttribute("data-disabled",""):this.container.removeAttribute("data-disabled"),this.state.error?this.container.setAttribute("data-error",""):this.container.removeAttribute("data-error");const i=this.renderSelect();this.selectElement=i,this.container.appendChild(i)}setValue(e){var n,s;if(this.state.disabled)return;const i=e===null?"":String(e);this.state.value!==e&&(this.state={...this.state,value:e},this.selectElement&&(this.selectElement.value=i),(s=(n=this.callbacks).onChange)==null||s.call(n,e,this.state))}setDisabled(e){this.state.disabled!==e&&(this.state={...this.state,disabled:e},this.render())}setError(e){this.state.error!==e&&(this.state={...this.state,error:e},this.render())}getState(){return{...this.state}}getValue(){return this.state.value}isDisabled(){return this.state.disabled}hasError(){return this.state.error}createInitialState(){return{value:this.config.defaultValue??null,disabled:this.config.disabled??!1,error:this.config.error??!1}}renderSelect(){const e=["field-input","field-select",this.state.error?"error":""].filter(Boolean).join(" "),i=c("select",{className:e,attributes:{id:this.instanceId,"aria-invalid":this.state.error?"true":"false"}});if(this.config.name&&i.setAttribute("name",this.config.name),this.config.width){const n=typeof this.config.width=="number"?`${this.config.width}px`:this.config.width;i.style.width=n}if(this.state.disabled&&(i.setAttribute("disabled","disabled"),i.setAttribute("aria-disabled","true")),this.config.required&&(i.setAttribute("required","required"),i.setAttribute("aria-required","true")),this.config.hasBlank!==!1){const n=c("option",{textContent:this.config.placeholder??this.config.blankLabel??"Select..."});n.value="",(this.state.value===null||this.state.value==="")&&(n.selected=!0),i.appendChild(n)}return this.appendOptions(i,this.config.options),i.addEventListener("change",n=>{const s=n.target,a=s.value===""?null:s.value;this.setValue(a)}),i.addEventListener("keydown",n=>{n.key==="Escape"&&i.blur()}),i}appendOptions(e,i){for(const n of i)if(ka(n)){const s=this.createOptgroup(n);e.appendChild(s)}else{const s=this.createOption(n);e.appendChild(s)}}createOption(e){const i=c("option",{textContent:e.label});return i.value=String(e.value),e.disabled&&(i.disabled=!0),this.state.value!==null&&String(e.value)===String(this.state.value)&&(i.selected=!0),i}createOptgroup(e){const i=document.createElement("optgroup");i.label=e.label,e.disabled&&(i.disabled=!0);for(const n of e.options){const s=this.createOption(n);i.appendChild(s)}return i}static renderField(e){return e.type==="multi_select"?we.renderMultiSelectField(e):we.renderSelectField(e)}static renderSelectField(e){const i=[j(e)],n=e.size?`select-${e.size}`:"select-default",s=le(e.options),a=new Map,r=[];for(const g of s)g.group?(a.has(g.group)||a.set(g.group,[]),a.get(g.group).push(g)):r.push(g);const o=g=>{const x=e.default===g.value?"selected":"",C=g.disabled?"disabled":"";return`<option value="${m(String(g.value))}" ${x} ${C}>${m(g.label)}</option>`},l=r.map(o).join(""),d=Array.from(a.entries()).map(([g,x])=>{const C=x.map(o).join("");return`<optgroup label="${m(g)}">${C}</optgroup>`}).join(""),u=!e.required||e.clearable?`<option value="">${m(e.placeholder??"Select...")}</option>`:"",f=`
|
|
47
|
+
<select class="field-select ${n}" ${i.join(" ")}>
|
|
48
|
+
${u}
|
|
49
|
+
${l}
|
|
50
|
+
${d}
|
|
51
|
+
</select>
|
|
52
|
+
`;return y(e,f)}static renderMultiSelectField(e){const i=[j(e),"multiple"],n=le(e.options),s=Array.isArray(e.default)?e.default:[],a=n.map(o=>{const l=s.includes(o.value)?"selected":"",d=o.disabled?"disabled":"";return`<option value="${m(String(o.value))}" ${l} ${d}>${m(o.label)}</option>`}).join(""),r=`
|
|
53
|
+
<select class="form-select form-multiselect" ${i.join(" ")}>
|
|
54
|
+
${a}
|
|
55
|
+
</select>
|
|
56
|
+
`;return y(e,r)}}class wa{constructor(e,i={},n={}){h(this,"config");h(this,"state");h(this,"callbacks");h(this,"container");h(this,"instanceId");this.config=i,this.container=e,this.callbacks=n,this.instanceId=E("radio"),this.state=this.createInitialState()}render(){this.container.innerHTML="";const e=this.config.size??"medium",i=this.config.labelPosition??"right";this.container.className=`mokkun-radio radio-${e} radio-label-${i}`;const n=this.state.checked?"checked":"unchecked";this.container.setAttribute("data-state",n),this.state.disabled?this.container.setAttribute("data-disabled",""):this.container.removeAttribute("data-disabled");const s=c("div",{className:"radio-wrapper"});if(i==="left"){const r=this.renderLabel();s.appendChild(r)}const a=this.renderRadio();if(s.appendChild(a),i==="right"){const r=this.renderLabel();s.appendChild(r)}this.container.appendChild(s)}setChecked(e){var i,n,s,a;this.state.disabled||this.state.checked!==e&&(this.state={...this.state,checked:e},this.render(),(n=(i=this.callbacks).onChange)==null||n.call(i,e,this.state),(a=(s=this.callbacks).onCheckedChange)==null||a.call(s,e))}setDisabled(e){this.state.disabled!==e&&(this.state={...this.state,disabled:e},this.render())}getState(){return{...this.state}}isChecked(){return this.state.checked}isDisabled(){return this.state.disabled}getValue(){return this.config.value}getName(){return this.config.name}createInitialState(){return{checked:this.config.defaultChecked??!1,disabled:this.config.disabled??!1}}renderRadio(){const e=c("div",{className:"radio-input-container"}),i=c("input",{className:"radio-input",attributes:{type:"radio",id:this.instanceId,role:"radio","aria-checked":String(this.state.checked),"aria-label":this.state.checked?this.config.checkedLabel??"選択済み":this.config.uncheckedLabel??"未選択"}});this.config.name&&i.setAttribute("name",this.config.name),this.config.value&&i.setAttribute("value",this.config.value),this.state.checked&&i.setAttribute("checked","checked"),this.state.disabled&&(i.setAttribute("disabled","disabled"),i.setAttribute("aria-disabled","true")),i.addEventListener("change",l=>{const d=l.target;this.setChecked(d.checked)}),i.addEventListener("keydown",l=>{(l.key===" "||l.key==="Enter")&&(l.preventDefault(),this.state.disabled||this.setChecked(!0))}),e.appendChild(i);const n=this.state.checked?"checked":"unchecked",s=["radio-visual",n,this.state.disabled?"disabled":""].filter(Boolean).join(" "),a=c("label",{className:s,attributes:{for:this.instanceId,"data-state":n}});this.state.disabled&&a.setAttribute("data-disabled","");const r=c("span",{className:"radio-circle"}),o=c("span",{className:"radio-dot",attributes:{"data-state":n}});return r.appendChild(o),a.appendChild(r),e.appendChild(a),e}renderLabel(){const e=this.config.checkedLabel??"",i=this.config.uncheckedLabel??"",n=this.state.checked?"checked":"unchecked",s=["radio-label",n,this.state.disabled?"disabled":""].filter(Boolean).join(" "),a=this.state.checked?e:i,r=c("label",{className:s,textContent:a,attributes:{for:this.instanceId,"aria-live":"polite","data-state":n}});return this.state.disabled&&r.setAttribute("data-disabled",""),r}static renderField(e){const i=le(e.options),n=e.direction??"vertical",s=i.map(r=>{const o=e.default===r.value?"checked":"",l=r.disabled||e.disabled?"disabled":"",d=`${e.id}-${r.value}`,p=r.description?`<span class="radio-option-description">${m(r.description)}</span>`:"";return`
|
|
57
|
+
<label class="radio-option" for="${m(d)}">
|
|
58
|
+
<input
|
|
59
|
+
type="radio"
|
|
60
|
+
id="${m(d)}"
|
|
61
|
+
name="${m(e.id)}"
|
|
62
|
+
value="${m(String(r.value))}"
|
|
63
|
+
${o}
|
|
64
|
+
${l}
|
|
65
|
+
${e.required?"required":""}
|
|
66
|
+
/>
|
|
67
|
+
<span class="radio-label-group">
|
|
68
|
+
<span class="radio-label">${m(r.label)}</span>
|
|
69
|
+
${p}
|
|
70
|
+
</span>
|
|
71
|
+
</label>
|
|
72
|
+
`}).join(""),a=`<div class="radio-group direction-${n}">${s}</div>`;return y(e,a)}}class Ee{constructor(e,i={},n={}){h(this,"config");h(this,"state");h(this,"callbacks");h(this,"container");h(this,"instanceId");this.config=i,this.container=e,this.callbacks=n,this.instanceId=E("checkbox"),this.state=this.createInitialState()}render(){this.container.innerHTML="";const e=this.config.size??"medium",i=this.config.labelPosition??"right";this.container.className=`mokkun-checkbox checkbox-${e} checkbox-label-${i}`;const n=this.state.indeterminate?"indeterminate":this.state.checked?"checked":"unchecked";this.container.setAttribute("data-state",n),this.state.disabled?this.container.setAttribute("data-disabled",""):this.container.removeAttribute("data-disabled");const s=c("div",{className:"checkbox-wrapper"});if(i==="left"){const r=this.renderLabel();s.appendChild(r)}const a=this.renderCheckbox();if(s.appendChild(a),i==="right"){const r=this.renderLabel();s.appendChild(r)}this.container.appendChild(s)}setChecked(e){var i,n,s,a;this.state.disabled||this.state.checked===e&&!this.state.indeterminate||(this.state={...this.state,checked:e,indeterminate:!1},this.render(),(n=(i=this.callbacks).onChange)==null||n.call(i,e,this.state),(a=(s=this.callbacks).onCheckedChange)==null||a.call(s,e))}setIndeterminate(e){this.state.disabled||this.state.indeterminate!==e&&(this.state={...this.state,indeterminate:e},this.render())}toggle(){this.state.indeterminate?this.setChecked(!0):this.setChecked(!this.state.checked)}setDisabled(e){this.state.disabled!==e&&(this.state={...this.state,disabled:e},this.render())}getState(){return{...this.state}}isChecked(){return this.state.checked}isIndeterminate(){return this.state.indeterminate}isDisabled(){return this.state.disabled}createInitialState(){return{checked:this.config.defaultChecked??!1,indeterminate:this.config.defaultIndeterminate??!1,disabled:this.config.disabled??!1}}renderCheckbox(){const e=c("div",{className:"checkbox-input-container"}),i=c("input",{className:"checkbox-input",attributes:{type:"checkbox",id:this.instanceId,role:"checkbox","aria-checked":this.state.indeterminate?"mixed":String(this.state.checked),"aria-label":this.state.checked?this.config.checkedLabel??"チェック済み":this.config.uncheckedLabel??"未チェック"}});this.config.name&&i.setAttribute("name",this.config.name),this.state.checked&&i.setAttribute("checked","checked"),this.state.indeterminate&&(i.indeterminate=!0),this.state.disabled&&(i.setAttribute("disabled","disabled"),i.setAttribute("aria-disabled","true")),i.addEventListener("change",l=>{const d=l.target;this.setChecked(d.checked)}),i.addEventListener("keydown",l=>{(l.key===" "||l.key==="Enter")&&(l.preventDefault(),this.state.disabled||this.toggle())}),e.appendChild(i);const n=this.state.indeterminate?"indeterminate":this.state.checked?"checked":"unchecked",s=["checkbox-visual",n,this.state.disabled?"disabled":""].filter(Boolean).join(" "),a=c("label",{className:s,attributes:{for:this.instanceId,"data-state":n}});this.state.disabled&&a.setAttribute("data-disabled","");const r=c("span",{className:"checkbox-box"}),o=c("span",{className:"checkbox-icon",attributes:{"data-state":n}});return this.state.indeterminate?o.innerHTML=`
|
|
73
|
+
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
74
|
+
<path d="M3 8H13" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
|
|
75
|
+
</svg>
|
|
76
|
+
`:this.state.checked&&(o.innerHTML=`
|
|
77
|
+
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
78
|
+
<path d="M3 8L6.5 11.5L13 4.5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
79
|
+
</svg>
|
|
80
|
+
`),r.appendChild(o),a.appendChild(r),e.appendChild(a),e}renderLabel(){const e=this.config.checkedLabel??"",i=this.config.uncheckedLabel??"",n=this.state.indeterminate?"indeterminate":this.state.checked?"checked":"unchecked",s=["checkbox-label",n,this.state.disabled?"disabled":""].filter(Boolean).join(" "),a=this.state.checked?e:i,r=c("label",{className:s,textContent:a,attributes:{for:this.instanceId,"aria-live":"polite","data-state":n}});return this.state.disabled&&r.setAttribute("data-disabled",""),r}static renderField(e){return e.type==="checkbox"?Ee.renderSingleCheckbox(e):Ee.renderCheckboxGroup(e)}static renderSingleCheckbox(e){const i=e.label_position??"right",n=e.size??"medium",s=e.disabled?"disabled":"",a=`
|
|
81
|
+
<input
|
|
82
|
+
type="checkbox"
|
|
83
|
+
id="${m(e.id)}"
|
|
84
|
+
name="${m(e.name??e.id)}"
|
|
85
|
+
class="checkbox-input checkbox-${n}"
|
|
86
|
+
${e.required?"required":""}
|
|
87
|
+
${s}
|
|
88
|
+
/>
|
|
89
|
+
`,r=e.label?`<span class="checkbox-label-text">${m(e.label)}</span>`:"",o=i==="left"?`<label class="checkbox-single label-left">${r}${a}</label>`:`<label class="checkbox-single label-right">${a}${r}</label>`;return y({...e,label:""},o)}static renderCheckboxGroup(e){const i=le(e.options),n=e.direction??"vertical",s=Array.isArray(e.default)?e.default:[],a=i.map(o=>{const l=s.includes(o.value)?"checked":"",d=o.disabled||e.disabled?"disabled":"",p=`${e.id}-${o.value}`;return`
|
|
90
|
+
<label class="checkbox-option" for="${m(p)}">
|
|
91
|
+
<input
|
|
92
|
+
type="checkbox"
|
|
93
|
+
id="${m(p)}"
|
|
94
|
+
name="${m(e.id)}"
|
|
95
|
+
value="${m(String(o.value))}"
|
|
96
|
+
${l}
|
|
97
|
+
${d}
|
|
98
|
+
/>
|
|
99
|
+
<span class="checkbox-label">${m(o.label)}</span>
|
|
100
|
+
</label>
|
|
101
|
+
`}).join(""),r=`<div class="checkbox-group direction-${n}">${a}</div>`;return y(e,r)}}class fi{constructor(e,i,n={},s=[]){h(this,"config");h(this,"state");h(this,"callbacks");h(this,"container");h(this,"instanceId");h(this,"debounceTimer",null);h(this,"inputRef",null);h(this,"listboxRef",null);h(this,"documentClickHandler",null);h(this,"abortController",null);this.config=i,this.container=e,this.callbacks=n,this.instanceId=E("combobox"),this.state=this.createInitialState(s)}render(){B(this.container),this.container.className=`mokkun-combobox combobox-${this.config.mode}`,this.container.setAttribute("data-state",this.state.isOpen?"open":"closed"),this.config.disabled?this.container.setAttribute("data-disabled",""):this.container.removeAttribute("data-disabled");const e=c("div",{className:"combobox-wrapper"});e.appendChild(this.renderInputArea()),this.state.isOpen&&e.appendChild(this.renderDropdown()),this.container.appendChild(e),this.setupEventListeners()}getValue(){return[...this.state.selectedValues]}setValue(e){this.setState({selectedValues:e})}getSelectedOptions(){const e=this.config.options??[];return this.state.selectedValues.map(i=>e.find(n=>n.value===i)).filter(i=>i!==void 0)}open(){var e,i;this.config.disabled||this.state.isOpen||(this.setState({isOpen:!0,highlightedIndex:-1}),(i=(e=this.callbacks).onOpen)==null||i.call(e,this.state))}close(){var e,i;this.state.isOpen&&(this.setState({isOpen:!1,highlightedIndex:-1}),(i=(e=this.callbacks).onClose)==null||i.call(e,this.state))}toggle(){this.state.isOpen?this.close():this.open()}isOpenState(){return this.state.isOpen}setOptions(e){this.config.options=e,this.updateFilteredOptions()}addOption(e){this.config.options||(this.config.options=[]),this.config.options.push(e),this.updateFilteredOptions()}removeOption(e){this.config.options&&(this.config.options=this.config.options.filter(i=>i.value!==e),this.updateFilteredOptions())}getState(){return{...this.state}}destroy(){this.debounceTimer&&clearTimeout(this.debounceTimer),this.abortController&&this.abortController.abort(),this.documentClickHandler&&document.removeEventListener("click",this.documentClickHandler),B(this.container),this.inputRef=null,this.listboxRef=null}createInitialState(e){const i=this.config.options??[],n=this.filterOptions("",i);return{selectedValues:e,inputValue:"",isOpen:!1,highlightedIndex:-1,filteredOptions:n,groupedOptions:this.groupOptions(n),isLoading:!1,error:null}}setState(e){this.state={...this.state,...e},this.render()}updateFilteredOptions(){const e=this.config.options??[],i=this.filterOptions(this.state.inputValue,e);this.setState({filteredOptions:i,groupedOptions:this.groupOptions(i)})}filterOptions(e,i){if(!e)return i;const n=e.toLowerCase().trim();return i.filter(s=>{var l,d;const a=s.label.toLowerCase().includes(n),r=((l=s.description)==null?void 0:l.toLowerCase().includes(n))??!1,o=((d=s.group)==null?void 0:d.toLowerCase().includes(n))??!1;return a||r||o})}groupOptions(e){const i=new Map,n=[];for(const s of e)s.group?(i.has(s.group)||i.set(s.group,[]),i.get(s.group).push(s)):n.push(s);return n.length>0&&i.set("",n),i}async loadOptionsAsync(e){if(!this.config.loadOptions)return;this.debounceTimer&&clearTimeout(this.debounceTimer);const i=this.config.minSearchLength??0;if(e.length<i){this.setState({filteredOptions:[],groupedOptions:new Map,isLoading:!1,error:null});return}this.abortController&&this.abortController.abort(),this.abortController=new AbortController,this.setState({isLoading:!0,error:null}),this.debounceTimer=setTimeout(async()=>{var n,s;try{const a=await this.config.loadOptions(e),r=this.filterOptions(e,a);this.setState({filteredOptions:r,groupedOptions:this.groupOptions(r),isLoading:!1,error:null})}catch(a){if(a.name==="AbortError")return;this.setState({isLoading:!1,error:a.message}),(s=(n=this.callbacks).onError)==null||s.call(n,a,this.state)}},this.config.debounceMs??300)}renderInputArea(){const e=c("div",{className:`combobox-control ${this.config.disabled?"disabled":""}`}),i=c("div",{className:"combobox-value-container"});if(this.config.mode==="multi"){const a=this.renderTags();a&&i.appendChild(a)}else if(this.state.selectedValues.length>0){const a=this.getSelectedOptions()[0];if(a){const r=c("span",{className:"combobox-single-value"});this.config.renderSelected?r.innerHTML=this.config.renderSelected(a):r.textContent=a.label,i.appendChild(r)}}const n=this.createInputElement();this.inputRef=n,i.appendChild(n),e.appendChild(i);const s=this.renderIndicators();return e.appendChild(s),e}createInputElement(){const e={type:"text",role:"combobox","aria-haspopup":"listbox","aria-expanded":String(this.state.isOpen),"aria-controls":`${this.instanceId}-listbox`,"aria-autocomplete":"list",id:this.config.id,name:this.config.name??this.config.id,placeholder:this.config.placeholder??""};this.config.disabled&&(e.disabled="true"),this.config.required&&(e.required="true");const i=c("input",{className:"combobox-input",attributes:e});return this.state.highlightedIndex>=0&&this.state.filteredOptions[this.state.highlightedIndex]&&i.setAttribute("aria-activedescendant",`${this.instanceId}-option-${this.state.highlightedIndex}`),i}renderTags(){if(this.state.selectedValues.length===0)return null;const e=c("div",{className:"combobox-tags"}),i=this.getSelectedOptions();for(const n of i){const s=c("span",{className:"combobox-tag"}),a=c("span",{className:"combobox-tag-label"});this.config.renderSelected?a.innerHTML=this.config.renderSelected(n):a.textContent=n.label,s.appendChild(a);const r=c("button",{className:"combobox-tag-remove",attributes:{type:"button","aria-label":`Remove ${n.label}`,"data-value":String(n.value)}});r.textContent="×",s.appendChild(r),e.appendChild(s)}return e}renderIndicators(){const e=c("div",{className:"combobox-indicators"});if(this.config.clearable&&this.state.selectedValues.length>0){const n=c("button",{className:"combobox-clear",attributes:{type:"button","aria-label":"Clear selection"}});n.textContent="×",e.appendChild(n);const s=c("span",{className:"combobox-separator"});e.appendChild(s)}const i=c("button",{className:"combobox-dropdown-indicator",attributes:{type:"button","aria-label":this.state.isOpen?"Close options":"Open options"}});return i.textContent="▼",e.appendChild(i),e}renderDropdown(){const e=c("div",{className:"combobox-dropdown",attributes:{role:"listbox",id:`${this.instanceId}-listbox`,"aria-label":"Options"}});if(this.listboxRef=e,this.state.isLoading){const n=c("div",{className:"combobox-loading"});return n.textContent=this.config.loadingMessage??"Loading...",e.appendChild(n),e}if(this.state.error){const n=c("div",{className:"combobox-error"});return n.textContent=this.state.error,e.appendChild(n),e}if(this.state.filteredOptions.length===0){const n=c("div",{className:"combobox-no-options"});return n.textContent=this.config.noOptionsMessage??"No options found",e.appendChild(n),e}let i=0;for(const[n,s]of this.state.groupedOptions.entries()){const a=c("div",{className:"combobox-option-group"});if(n){const r=c("div",{className:"combobox-group-header"});r.textContent=n,a.appendChild(r)}for(const r of s){const o=this.renderOption(r,i);a.appendChild(o),i++}e.appendChild(a)}return e}renderOption(e,i){const n=this.state.selectedValues.includes(e.value),s=this.state.highlightedIndex===i,a=c("div",{className:`combobox-option ${n?"selected":""} ${s?"highlighted":""} ${e.disabled?"disabled":""}`,attributes:{role:"option","aria-selected":String(n),"data-value":String(e.value),"data-index":String(i),id:`${this.instanceId}-option-${i}`}});if(this.config.renderOption)a.innerHTML=this.config.renderOption(e);else{if(e.icon){const o=c("span",{className:"combobox-option-icon"});o.innerHTML=e.icon,a.appendChild(o)}const r=c("span",{className:"combobox-option-label"});if(r.textContent=e.label,a.appendChild(r),e.description){const o=c("span",{className:"combobox-option-description"});o.textContent=e.description,a.appendChild(o)}}return a}setupEventListeners(){if(!this.inputRef)return;this.inputRef.addEventListener("focus",()=>this.handleInputFocus()),this.inputRef.addEventListener("input",s=>this.handleInput(s)),this.inputRef.addEventListener("keydown",s=>this.handleKeyDown(s));const e=this.container.querySelector(".combobox-clear");e&&e.addEventListener("click",()=>this.handleClear());const i=this.container.querySelector(".combobox-dropdown-indicator");i&&i.addEventListener("click",()=>this.toggle()),this.container.querySelectorAll(".combobox-tag-remove").forEach(s=>{s.addEventListener("click",a=>{var o;const r=(o=a.target.closest("[data-value]"))==null?void 0:o.getAttribute("data-value");r!=null&&this.deselectOption(r)})}),this.listboxRef&&(this.listboxRef.addEventListener("click",s=>this.handleOptionClick(s)),this.listboxRef.addEventListener("mouseover",s=>this.handleOptionHover(s))),this.documentClickHandler=s=>{this.container.contains(s.target)||this.close()},document.addEventListener("click",this.documentClickHandler)}handleInputFocus(){this.state.isOpen||this.open()}handleInput(e){var s,a;const n=e.target.value;this.state.inputValue=n,(a=(s=this.callbacks).onInputChange)==null||a.call(s,n,this.state),this.config.loadOptions?this.loadOptionsAsync(n):this.updateFilteredOptions(),this.state.isOpen||this.open()}handleKeyDown(e){switch(e.key){case"ArrowDown":e.preventDefault(),this.state.isOpen?this.highlightNext():this.open();break;case"ArrowUp":e.preventDefault(),this.state.isOpen&&this.highlightPrevious();break;case"Enter":e.preventDefault(),this.state.isOpen&&this.state.highlightedIndex>=0&&this.selectHighlighted();break;case"Escape":e.preventDefault(),this.close();break;case"Tab":this.close();break;case"Backspace":this.config.mode==="multi"&&!this.state.inputValue&&this.removeLastSelected();break}}handleClear(){this.clearSelection()}handleOptionClick(e){const n=e.target.closest(".combobox-option");if(!n)return;const s=n.getAttribute("data-value");if(s===null)return;const a=this.state.filteredOptions.find(r=>String(r.value)===s);!a||a.disabled||this.selectOption(a.value)}handleOptionHover(e){const n=e.target.closest(".combobox-option");if(!n)return;const s=parseInt(n.getAttribute("data-index")??"-1");s>=0&&this.highlightOption(s)}selectOption(e){var i,n;if(this.config.mode==="single")this.setState({selectedValues:[e],inputValue:"",isOpen:!1});else{if(this.state.selectedValues.includes(e)){this.deselectOption(e);return}const s=this.config.maxSelections;if(s&&this.state.selectedValues.length>=s)return;this.setState({selectedValues:[...this.state.selectedValues,e],inputValue:""})}(n=(i=this.callbacks).onChange)==null||n.call(i,this.state.selectedValues,this.state)}deselectOption(e){var i,n;this.setState({selectedValues:this.state.selectedValues.filter(s=>String(s)!==String(e))}),(n=(i=this.callbacks).onChange)==null||n.call(i,this.state.selectedValues,this.state)}clearSelection(){var e,i;this.setState({selectedValues:[],inputValue:""}),(i=(e=this.callbacks).onChange)==null||i.call(e,this.state.selectedValues,this.state)}selectHighlighted(){if(this.state.highlightedIndex<0)return;const e=this.state.filteredOptions[this.state.highlightedIndex];!e||e.disabled||this.selectOption(e.value)}removeLastSelected(){if(this.state.selectedValues.length===0)return;const e=this.state.selectedValues[this.state.selectedValues.length-1];this.deselectOption(e)}highlightNext(){let e=this.state.highlightedIndex+1;for(;e<this.state.filteredOptions.length;){if(!this.state.filteredOptions[e].disabled){this.highlightOption(e);return}e++}}highlightPrevious(){let e=this.state.highlightedIndex-1;for(;e>=0;){if(!this.state.filteredOptions[e].disabled){this.highlightOption(e);return}e--}}highlightOption(e){var s,a;if(e<0||e>=this.state.filteredOptions.length)return;const i=this.state.highlightedIndex;if(this.state.highlightedIndex=e,this.listboxRef){if(i>=0){const o=this.listboxRef.querySelector(`[data-index="${i}"]`);o==null||o.classList.remove("highlighted")}const r=this.listboxRef.querySelector(`[data-index="${e}"]`);r==null||r.classList.add("highlighted"),this.inputRef&&this.inputRef.setAttribute("aria-activedescendant",`${this.instanceId}-option-${e}`),r&&typeof r.scrollIntoView=="function"&&r.scrollIntoView({block:"nearest"})}const n=this.state.filteredOptions[e];(a=(s=this.callbacks).onHighlight)==null||a.call(s,n,this.state)}static renderField(e){const i=[`id="${m(e.id)}"`,`name="${m(e.id)}"`,'role="combobox"','aria-haspopup="listbox"','aria-expanded="false"'];e.required&&i.push("required"),e.disabled&&i.push("disabled"),e.placeholder&&i.push(`placeholder="${m(e.placeholder)}"`);const n=le(e.options??[]),s=`${e.id}-listbox`;i.push(`aria-controls="${s}"`);const a=n.map((o,l)=>{const d=o.disabled?'aria-disabled="true"':"";return`
|
|
102
|
+
<div
|
|
103
|
+
role="option"
|
|
104
|
+
id="${m(e.id)}-option-${l}"
|
|
105
|
+
data-value="${m(String(o.value))}"
|
|
106
|
+
${d}
|
|
107
|
+
>
|
|
108
|
+
${m(o.label)}
|
|
109
|
+
</div>
|
|
110
|
+
`}).join(""),r=`
|
|
111
|
+
<div class="combobox-wrapper" data-state="closed">
|
|
112
|
+
<div class="combobox-control">
|
|
113
|
+
<input type="text" class="combobox-input" ${i.join(" ")} />
|
|
114
|
+
<button type="button" class="combobox-dropdown-indicator" aria-label="Open options">▼</button>
|
|
115
|
+
</div>
|
|
116
|
+
<div role="listbox" id="${s}" class="combobox-dropdown" hidden>
|
|
117
|
+
${a}
|
|
118
|
+
</div>
|
|
119
|
+
</div>
|
|
120
|
+
`;return y(e,r)}}class Ea{constructor(e,i,n={}){h(this,"config");h(this,"state");h(this,"callbacks");h(this,"container");h(this,"instanceId");this.config=i,this.container=e,this.callbacks=n,this.instanceId=i.id??E("heading"),this.state=this.createInitialState()}render(){this.container.innerHTML="";const e=this.state.level,i=this.state.size??this.getDefaultSizeForLevel(e),n=this.state.align??"left",s=this.state.color??"default";this.container.className=["mokkun-heading",`heading-level-${e}`,`heading-size-${i}`,`heading-align-${n}`,`heading-color-${s}`,this.config.className??""].filter(Boolean).join(" ");const a=this.createHeadingElement();this.container.appendChild(a)}setText(e){this.state={...this.state,text:e},this.render()}setLevel(e){this.state={...this.state,level:e},this.render()}setSize(e){this.state={...this.state,size:e},this.render()}setAlign(e){this.state={...this.state,align:e},this.render()}setColor(e){this.state={...this.state,color:e},this.render()}getState(){return{...this.state}}createInitialState(){return{level:this.config.level,text:this.config.text,size:this.config.size,align:this.config.align,color:this.config.color,icon:this.config.icon}}createHeadingElement(){const e=`h${this.state.level}`,i=c(e,{className:"heading-element",attributes:{id:this.instanceId}});if(this.state.icon){const s=c("span",{className:"heading-icon",textContent:this.state.icon});i.appendChild(s)}const n=c("span",{className:"heading-text",textContent:this.state.text});return i.appendChild(n),this.callbacks.onClick&&(i.style.cursor="pointer",i.addEventListener("click",()=>{var s,a;(a=(s=this.callbacks).onClick)==null||a.call(s,this.getState())})),i}getDefaultSizeForLevel(e){return pi(e)}static renderField(e){const i=e.size??pi(e.level),n=e.align??"left",s=e.color??"default",a=`h${e.level}`,r=["heading-field-container",`heading-level-${e.level}`,`heading-size-${i}`,`heading-align-${n}`,`heading-color-${s}`];e.class&&r.push(e.class);const o=e.icon?`<span class="heading-icon">${m(e.icon)}</span>`:"";return`
|
|
121
|
+
<div class="${r.join(" ")}" data-field-id="${m(e.id)}">
|
|
122
|
+
<${a} class="heading-element" id="${m(e.id)}">
|
|
123
|
+
${o}
|
|
124
|
+
<span class="heading-text">${m(e.text)}</span>
|
|
125
|
+
</${a}>
|
|
126
|
+
</div>
|
|
127
|
+
`}}class Aa{constructor(e,i,n={}){h(this,"config");h(this,"state");h(this,"callbacks");h(this,"container");h(this,"instanceId");this.config=i,this.container=e,this.callbacks=n,this.instanceId=i.id??E("duration-picker"),this.state=this.createInitialState()}render(){this.container.innerHTML="";const e=c("div",{className:"mokkun-duration-picker"});this.state.disabled&&e.classList.add("is-disabled");for(const i of this.config.units){const n=this.renderUnitSelector(i);e.appendChild(n)}this.container.appendChild(e)}setValue(e,i){var n,s;this.state.disabled||(this.state={...this.state,values:{...this.state.values,[e]:i}},this.render(),(s=(n=this.callbacks).onChange)==null||s.call(n,this.state.values,this.state))}setValues(e){var i,n;this.state.disabled||(this.state={...this.state,values:{...this.state.values,...e}},this.render(),(n=(i=this.callbacks).onChange)==null||n.call(i,this.state.values,this.state))}getValue(e){return this.state.values[e]}getValues(){return{...this.state.values}}setDisabled(e){this.state.disabled!==e&&(this.state={...this.state,disabled:e},this.render())}getState(){return{...this.state}}createInitialState(){const e=this.config.defaultValues??{};return{values:{days:e.days??0,hours:e.hours??0,minutes:e.minutes??0,seconds:e.seconds??0},disabled:this.config.disabled??!1}}renderUnitSelector(e){const i=c("div",{className:"duration-unit"}),n=`${this.instanceId}-${e}`,s=this.getMaxForUnit(e),a=this.state.values[e],r=c("select",{className:"form-select duration-select",attributes:{id:n,name:this.config.name?`${this.config.name}-${e}`:n}});this.state.disabled&&r.setAttribute("disabled","disabled");for(let l=0;l<=s;l++){const d=c("option",{textContent:String(l)});d.setAttribute("value",String(l)),l===a&&d.setAttribute("selected","selected"),r.appendChild(d)}r.addEventListener("change",l=>{const d=l.target;this.setValue(e,parseInt(d.value,10))}),i.appendChild(r);const o=c("span",{className:"duration-unit-label",textContent:ke[e]??e});return i.appendChild(o),i}getMaxForUnit(e){switch(e){case"days":return 365;case"hours":return 23;case"minutes":case"seconds":return 59;default:return 59}}static renderField(e){const i=e.units??["hours","minutes"],n=e.id,a=`<div class="duration-picker">${i.map(r=>{const o=`${n}-${r}`;let l=59;r==="hours"&&(l=23),r==="days"&&(l=365);const d=Array.from({length:l+1},(p,u)=>`<option value="${u}">${u}</option>`).join("");return`
|
|
128
|
+
<div class="duration-unit">
|
|
129
|
+
<select id="${m(o)}" name="${m(o)}" class="form-select duration-select" ${e.disabled?"disabled":""}>
|
|
130
|
+
${d}
|
|
131
|
+
</select>
|
|
132
|
+
<span class="duration-unit-label">${ke[r]??r}</span>
|
|
133
|
+
</div>
|
|
134
|
+
`}).join("")}</div>`;return y(e,a)}}class Ia{constructor(e,i={},n={}){h(this,"config");h(this,"state");h(this,"callbacks");h(this,"container");h(this,"instanceId");h(this,"inputElement",null);this.config=i,this.container=e,this.callbacks=n,this.instanceId=i.id??E("duration-input"),this.state=this.createInitialState()}render(){this.container.innerHTML="";const e=c("div",{className:"mokkun-duration-input"});this.state.disabled&&e.classList.add("is-disabled"),this.state.readonly&&e.classList.add("is-readonly"),this.state.error&&e.classList.add("has-error");const i=this.renderInputGroup();if(e.appendChild(i),this.state.error&&this.state.errorMessage){const n=this.renderError();e.appendChild(n)}this.container.appendChild(e)}setValue(e){var i,n;this.state.value!==e&&(this.state={...this.state,value:e},this.inputElement&&(this.inputElement.value=String(e)),(n=(i=this.callbacks).onChange)==null||n.call(i,e,this.state))}getValue(){return this.state.value}setError(e,i){this.state={...this.state,error:e,errorMessage:i},this.render()}setDisabled(e){this.state.disabled!==e&&(this.state={...this.state,disabled:e},this.render())}setReadonly(e){this.state.readonly!==e&&(this.state={...this.state,readonly:e},this.render())}focus(){var e;(e=this.inputElement)==null||e.focus()}blur(){var e;(e=this.inputElement)==null||e.blur()}getState(){return{...this.state}}createInitialState(){return{value:this.config.defaultValue??0,disabled:this.config.disabled??!1,readonly:this.config.readonly??!1,error:!1,errorMessage:void 0}}renderInputGroup(){const e=c("div",{className:"input-with-unit"}),i=this.renderInput();e.appendChild(i);const n=this.config.displayUnit??"minutes",s=c("span",{className:"input-unit",textContent:ke[n]??n});return e.appendChild(s),e}renderInput(){const e=c("input",{className:"form-input duration-input-field",attributes:{type:"number",id:this.instanceId,name:this.config.name??this.instanceId,min:String(this.config.min??0),...this.config.max!==void 0&&{max:String(this.config.max)},...this.config.placeholder&&{placeholder:this.config.placeholder},...this.config.required&&{required:"required"},...this.state.disabled&&{disabled:"disabled"},...this.state.readonly&&{readonly:"readonly"},...this.state.error&&{"aria-invalid":"true"}}});return e.value=String(this.state.value),e.addEventListener("input",this.handleInput.bind(this)),e.addEventListener("focus",this.handleFocus.bind(this)),e.addEventListener("blur",this.handleBlur.bind(this)),this.inputElement=e,e}renderError(){return c("div",{className:"duration-input-error",textContent:this.state.errorMessage??"",attributes:{id:`${this.instanceId}-error`,role:"alert"}})}handleInput(e){var s,a;const i=e.target,n=parseInt(i.value,10)||0;this.state={...this.state,value:n},(a=(s=this.callbacks).onChange)==null||a.call(s,n,this.state)}handleFocus(){var e,i;(i=(e=this.callbacks).onFocus)==null||i.call(e,this.state)}handleBlur(){var e,i;(i=(e=this.callbacks).onBlur)==null||i.call(e,this.state)}static renderField(e){const i=[j(e)];i.push('min="0"'),e.default!==void 0&&i.push(`value="${e.default}"`);const n=e.display_unit??"minutes",s=`
|
|
135
|
+
<div class="input-with-unit">
|
|
136
|
+
<input type="number" class="form-input" ${i.join(" ")} />
|
|
137
|
+
<span class="input-unit">${ke[n]??n}</span>
|
|
138
|
+
</div>
|
|
139
|
+
`;return y(e,s)}}class Sa{constructor(e,i,n={}){h(this,"config");h(this,"state");h(this,"callbacks");h(this,"container");h(this,"instanceId");this.config=i,this.container=e,this.callbacks=n,this.instanceId=E("pagination"),this.state=this.createInitialState()}render(){this.container.innerHTML="";const e=this.config.align??"center",i=this.config.compact??!1;this.container.className=`mokkun-pagination pagination-align-${e} ${i?"pagination-compact":""}`;const n=c("div",{className:"pagination-wrapper"});if(this.config.showPageSizeSelector!==!1){const a=this.renderPageSizeSelector();n.appendChild(a)}const s=this.renderNavigation();if(n.appendChild(s),this.config.showItemCount!==!1){const a=this.renderItemCount();n.appendChild(a)}this.container.appendChild(n)}goToPage(e){var n,s;const i=this.clampPage(e);this.state.currentPage!==i&&(this.state={...this.state,currentPage:i},this.render(),(s=(n=this.callbacks).onPageChange)==null||s.call(n,i,this.state))}nextPage(){this.goToPage(this.state.currentPage+1)}previousPage(){this.goToPage(this.state.currentPage-1)}firstPage(){this.goToPage(1)}lastPage(){this.goToPage(this.state.totalPages)}setPageSize(e){var a,r;if(this.state.pageSize===e)return;const i=(this.state.currentPage-1)*this.state.pageSize,n=Math.floor(i/e)+1,s=Math.ceil(this.state.totalItems/e);this.state={...this.state,pageSize:e,totalPages:s,currentPage:this.clampPage(n,s)},this.render(),(r=(a=this.callbacks).onPageSizeChange)==null||r.call(a,e,this.state)}setTotalItems(e){const i=Math.ceil(e/this.state.pageSize);this.state={...this.state,totalItems:e,totalPages:i,currentPage:this.clampPage(this.state.currentPage,i)},this.render()}getState(){return{...this.state}}getCurrentPage(){return this.state.currentPage}getPageSize(){return this.state.pageSize}getItemRange(){const e=(this.state.currentPage-1)*this.state.pageSize+1,i=Math.min(this.state.currentPage*this.state.pageSize,this.state.totalItems);return{start:e,end:i}}createInitialState(){const e=this.config.initialPageSize??10,i=Math.ceil(this.config.totalItems/e);return{currentPage:this.clampPage(this.config.initialPage??1,i),pageSize:e,totalItems:this.config.totalItems,totalPages:i}}clampPage(e,i){const n=i??this.state.totalPages;return Math.max(1,Math.min(e,n))}renderPageSizeSelector(){const e=c("div",{className:"pagination-page-size-selector"}),i=c("label",{className:"page-size-label",textContent:"表示件数:",attributes:{for:`${this.instanceId}-page-size`}}),n=c("select",{className:"page-size-select",attributes:{id:`${this.instanceId}-page-size`,"aria-label":"ページサイズ選択"}});return(this.config.pageSizeOptions??[10,25,50,100]).forEach(a=>{const r=c("option",{textContent:`${a}件`,attributes:{value:String(a)}});a===this.state.pageSize&&(r.selected=!0),n.appendChild(r)}),n.addEventListener("change",a=>{const r=a.target;this.setPageSize(parseInt(r.value,10))}),e.appendChild(i),e.appendChild(n),e}renderNavigation(){const e=c("div",{className:"pagination-navigation"}),{currentPage:i,totalPages:n}=this.state,s=this.config.showJumpButtons!==!1;if(s){const l=this.createButton("最初","first",i===1);l.addEventListener("click",()=>this.firstPage()),e.appendChild(l)}const a=this.createButton("前へ","prev",i===1);a.addEventListener("click",()=>this.previousPage()),e.appendChild(a),this.renderPageButtons().forEach(l=>e.appendChild(l));const o=this.createButton("次へ","next",i===n);if(o.addEventListener("click",()=>this.nextPage()),e.appendChild(o),s){const l=this.createButton("最後","last",i===n);l.addEventListener("click",()=>this.lastPage()),e.appendChild(l)}return e}renderPageButtons(){const{currentPage:e,totalPages:i}=this.state,n=this.config.maxPageButtons??7;if(i===0)return[];const s=[],a=this.calculateVisiblePages(e,i,n);let r=0;return a.forEach(o=>{if(r>0&&o>r+1){const d=c("span",{className:"pagination-ellipsis",textContent:"...",attributes:{"aria-hidden":"true"}});s.push(d)}const l=this.createPageButton(o,o===e);l.addEventListener("click",()=>this.goToPage(o)),s.push(l),r=o}),s}calculateVisiblePages(e,i,n){if(i<=n)return Array.from({length:i},(r,o)=>o+1);const s=[],a=Math.floor((n-3)/2);if(s.push(1),e<=a+2)for(let r=2;r<n-1;r++)s.push(r);else if(e>=i-a-1)for(let r=i-n+2;r<i;r++)s.push(r);else for(let r=e-a;r<=e+a;r++)r>1&&r<i&&s.push(r);return i>1&&!s.includes(i)&&s.push(i),s.sort((r,o)=>r-o)}createButton(e,i,n){const s=c("button",{className:`pagination-button pagination-button-${i}`,textContent:e,attributes:{type:"button","aria-label":e}});return n&&(s.setAttribute("disabled","disabled"),s.setAttribute("aria-disabled","true")),s}createPageButton(e,i){const n=c("button",{className:`pagination-button pagination-page-button ${i?"active":""}`,textContent:String(e),attributes:{type:"button","aria-label":`ページ ${e}`,"aria-current":i?"page":"false"}});return i&&n.setAttribute("data-active",""),n}renderItemCount(){const{start:e,end:i}=this.getItemRange(),{totalItems:n}=this.state,s=c("div",{className:"pagination-item-count"}),a=n>0?`${n}件中 ${e}-${i}件を表示`:"0件",r=c("span",{className:"item-count-text",textContent:a,attributes:{"aria-live":"polite","aria-atomic":"true"}});return s.appendChild(r),s}static renderField(e){const i=e,n=i.totalItems??0,s=i.pageSize??10,a=i.currentPage??1,r=Math.ceil(n/s),o=n>0?(a-1)*s+1:0,l=Math.min(a*s,n),d=`
|
|
140
|
+
<div class="mokkun-pagination pagination-align-center">
|
|
141
|
+
<div class="pagination-wrapper">
|
|
142
|
+
<div class="pagination-page-size-selector">
|
|
143
|
+
<label class="page-size-label">表示件数:</label>
|
|
144
|
+
<select class="page-size-select" aria-label="ページサイズ選択">
|
|
145
|
+
<option value="10" ${s===10?"selected":""}>10件</option>
|
|
146
|
+
<option value="25" ${s===25?"selected":""}>25件</option>
|
|
147
|
+
<option value="50" ${s===50?"selected":""}>50件</option>
|
|
148
|
+
<option value="100" ${s===100?"selected":""}>100件</option>
|
|
149
|
+
</select>
|
|
150
|
+
</div>
|
|
151
|
+
<div class="pagination-navigation">
|
|
152
|
+
<button type="button" class="pagination-button pagination-button-first" ${a===1?"disabled":""} aria-label="最初">最初</button>
|
|
153
|
+
<button type="button" class="pagination-button pagination-button-prev" ${a===1?"disabled":""} aria-label="前へ">前へ</button>
|
|
154
|
+
${Array.from({length:Math.min(r,7)},(p,u)=>{const f=u+1;return`<button type="button" class="pagination-button pagination-page-button ${f===a?"active":""}" aria-label="ページ ${f}" ${f===a?'aria-current="page"':""}>${f}</button>`}).join("")}
|
|
155
|
+
<button type="button" class="pagination-button pagination-button-next" ${a===r||r===0?"disabled":""} aria-label="次へ">次へ</button>
|
|
156
|
+
<button type="button" class="pagination-button pagination-button-last" ${a===r||r===0?"disabled":""} aria-label="最後">最後</button>
|
|
157
|
+
</div>
|
|
158
|
+
<div class="pagination-item-count">
|
|
159
|
+
<span class="item-count-text" aria-live="polite">${n>0?`${n}件中 ${o}-${l}件を表示`:"0件"}</span>
|
|
160
|
+
</div>
|
|
161
|
+
</div>
|
|
162
|
+
</div>
|
|
163
|
+
`;return y(e,d)}}class La{constructor(e,i={},n={}){h(this,"config");h(this,"state");h(this,"callbacks");h(this,"container");h(this,"instanceId");this.config=i,this.container=e,this.callbacks=n,this.instanceId=E("toggle"),this.state=this.createInitialState()}render(){this.container.innerHTML="";const e=this.config.size??"medium",i=this.config.labelPosition??"right";this.container.className=`mokkun-toggle toggle-${e} toggle-label-${i}`,this.container.setAttribute("data-state",this.state.checked?"checked":"unchecked"),this.state.disabled?this.container.setAttribute("data-disabled",""):this.container.removeAttribute("data-disabled");const n=c("div",{className:"toggle-wrapper"});if(i==="left"){const a=this.renderLabel();n.appendChild(a)}const s=this.renderToggle();if(n.appendChild(s),i==="right"){const a=this.renderLabel();n.appendChild(a)}this.container.appendChild(n)}setChecked(e){var i,n,s,a;this.state.disabled||this.state.checked!==e&&(this.state={...this.state,checked:e},this.render(),(n=(i=this.callbacks).onChange)==null||n.call(i,e,this.state),(a=(s=this.callbacks).onCheckedChange)==null||a.call(s,e))}toggle(){this.setChecked(!this.state.checked)}setDisabled(e){this.state.disabled!==e&&(this.state={...this.state,disabled:e},this.render())}getState(){return{...this.state}}isChecked(){return this.state.checked}isDisabled(){return this.state.disabled}createInitialState(){return{checked:this.config.defaultChecked??!1,disabled:this.config.disabled??!1}}renderToggle(){const e=c("div",{className:"toggle-switch-container"}),i=c("input",{className:"toggle-checkbox visually-hidden",attributes:{type:"checkbox",id:this.instanceId,role:"switch","aria-checked":String(this.state.checked),"aria-label":this.state.checked?this.config.checkedLabel??"ON":this.config.uncheckedLabel??"OFF"}});this.config.name&&i.setAttribute("name",this.config.name),this.state.checked&&i.setAttribute("checked","checked"),this.state.disabled&&(i.setAttribute("disabled","disabled"),i.setAttribute("aria-disabled","true")),i.addEventListener("change",l=>{const d=l.target;this.setChecked(d.checked)}),i.addEventListener("keydown",l=>{(l.key===" "||l.key==="Enter")&&(l.preventDefault(),this.state.disabled||this.toggle())}),e.appendChild(i);const n=this.state.checked?"checked":"unchecked",s=["toggle-switch",n,this.state.disabled?"disabled":""].filter(Boolean).join(" "),a=c("label",{className:s,attributes:{for:this.instanceId,"data-state":n}});this.state.disabled&&a.setAttribute("data-disabled","");const r=c("span",{className:"toggle-track"});a.appendChild(r);const o=c("span",{className:"toggle-thumb",attributes:{"data-state":n}});return a.appendChild(o),e.appendChild(a),e}renderLabel(){const e=this.config.checkedLabel??"ON",i=this.config.uncheckedLabel??"OFF",n=this.state.checked?"checked":"unchecked",s=["toggle-label",n,this.state.disabled?"disabled":""].filter(Boolean).join(" "),a=c("span",{className:s,textContent:this.state.checked?e:i,attributes:{"aria-live":"polite","data-state":n}});return this.state.disabled&&a.setAttribute("data-disabled",""),a}static renderField(e){const i=e,n=i.defaultChecked??!1,s=i.checkedLabel??"ON",a=i.uncheckedLabel??"OFF",r=i.size??"medium",o=n?"checked":"unchecked",l=`
|
|
164
|
+
<div class="mokkun-toggle toggle-${r} toggle-label-right" data-state="${o}">
|
|
165
|
+
<div class="toggle-wrapper">
|
|
166
|
+
<div class="toggle-switch-container">
|
|
167
|
+
<input type="checkbox" class="toggle-checkbox visually-hidden" id="${m(e.id)}" role="switch" aria-checked="${n}" ${n?"checked":""}>
|
|
168
|
+
<label class="toggle-switch ${o}" for="${m(e.id)}" data-state="${o}">
|
|
169
|
+
<span class="toggle-track"></span>
|
|
170
|
+
<span class="toggle-thumb" data-state="${o}"></span>
|
|
171
|
+
</label>
|
|
172
|
+
</div>
|
|
173
|
+
<span class="toggle-label ${o}" aria-live="polite" data-state="${o}">${m(n?s:a)}</span>
|
|
174
|
+
</div>
|
|
175
|
+
</div>
|
|
176
|
+
`;return y(e,l)}}class $a{constructor(e,i={},n={}){h(this,"config");h(this,"state");h(this,"callbacks");h(this,"container");h(this,"clickHandler",null);this.config=i,this.container=e,this.callbacks=n,this.state=this.createInitialState()}render(){this.container.innerHTML="";const e=this.config.color??"gray",i=this.config.size??"medium",n=this.config.clickable??!1;if(this.container.className=`mokkun-badge badge-${e} badge-${i}`,n&&this.container.classList.add("badge-clickable"),this.state.dot&&this.container.classList.add("badge-dot"),this.container.setAttribute("data-color",e),this.container.setAttribute("data-size",i),this.state.hidden){this.container.setAttribute("data-hidden",""),this.container.style.display="none";return}else this.container.removeAttribute("data-hidden"),this.container.style.display="";const s=this.renderBadge();this.container.appendChild(s),this.clickHandler&&(this.container.removeEventListener("click",this.clickHandler),this.clickHandler=null),n&&this.callbacks.onClick&&(this.clickHandler=this.handleClick.bind(this),this.container.addEventListener("click",this.clickHandler))}setCount(e){var i,n;e<0&&(e=0),this.state.count!==e&&(this.state={...this.state,count:e,text:null,hidden:this.config.hideOnZero===!0&&e===0},this.render(),(n=(i=this.callbacks).onCountChange)==null||n.call(i,e))}setText(e){this.state.text!==e&&(this.state={...this.state,text:e,count:null,hidden:!1},this.render())}setDot(e){this.state.dot!==e&&(this.state={...this.state,dot:e},this.render())}setHidden(e){this.state.hidden!==e&&(this.state={...this.state,hidden:e},this.render())}getCount(){return this.state.count}getText(){return this.state.text}getState(){return{...this.state}}destroy(){this.clickHandler&&(this.container.removeEventListener("click",this.clickHandler),this.clickHandler=null),this.container.innerHTML=""}createInitialState(){const e=this.config.count??null,i=this.config.text??null,n=this.config.dot??!1,s=this.config.hideOnZero===!0;return{count:e,text:i,dot:n,hidden:s&&e===0}}renderBadge(){const e=c("span",{className:"badge-content"});e.setAttribute("role","status");const i=this.getAriaLabel();if(i&&e.setAttribute("aria-label",i),this.state.dot){const n=c("span",{className:"badge-dot-indicator",attributes:{"aria-hidden":"true"}});return e.appendChild(n),e}if(this.state.text!==null)return e.textContent=this.state.text,e;if(this.state.count!==null){const n=this.formatCount(this.state.count);return e.textContent=n,e}return e}formatCount(e){const i=this.config.maxCount??99;return e>i?`${i}+`:String(e)}getAriaLabel(){if(this.config.label)return this.config.label;if(this.state.dot)return"Status indicator";if(this.state.text!==null)return this.state.text;if(this.state.count!==null){const e=this.state.count,i=this.config.maxCount??99;return e>i?`${i}+ notifications`:`${e} notification${e===1?"":"s"}`}return""}handleClick(e){var i,n;(n=(i=this.callbacks).onClick)==null||n.call(i,e)}static renderField(e){const i=e,n=i.text??e.label,a=`
|
|
177
|
+
<span class="mokkun-badge badge-${i.variant??"default"}">${m(n)}</span>
|
|
178
|
+
`;return y(e,a)}}class _a{constructor(e,i,n={}){h(this,"config");h(this,"state");h(this,"callbacks");h(this,"container");h(this,"instanceId");h(this,"columnsWrapper",null);h(this,"itemsMap",new Map);h(this,"parentMap",new Map);this.config=i,this.container=e,this.callbacks=n,this.instanceId=i.id??E("browser"),this.buildItemsMap(i.items,null);const s=i.defaultValue?this.getPathToValue(i.defaultValue):[];this.state={selectedValue:i.defaultValue??null,selectedPath:s,focusedColumnIndex:0,focusedItemIndexes:new Array(i.maxColumns??3).fill(0)}}render(){this.container.innerHTML="",this.container.className=["mokkun-browser",this.config.className??""].filter(Boolean).join(" "),this.container.id=this.instanceId,this.container.setAttribute("role","application"),this.container.setAttribute("aria-label","階層ブラウザ"),this.config.height&&this.config.height!=="auto"&&(this.container.style.height=this.config.height),this.columnsWrapper=c("div",{className:"browser-columns"}),this.container.addEventListener("keydown",this.handleKeyDown.bind(this)),this.container.appendChild(this.columnsWrapper),this.renderColumns()}selectValue(e){var s,a,r,o;const i=this.itemsMap.get(e);if(!i||i.disabled)return;const n=this.getPathToValue(e);this.state={...this.state,selectedValue:e,selectedPath:n},this.renderColumns(),(a=(s=this.callbacks).onSelect)==null||a.call(s,e,n,i),(o=(r=this.callbacks).onChange)==null||o.call(r,e,n)}clearSelection(){var e,i;this.state={...this.state,selectedValue:null,selectedPath:[]},this.renderColumns(),(i=(e=this.callbacks).onChange)==null||i.call(e,null,[])}getValue(){return this.state.selectedValue}getPath(){return[...this.state.selectedPath]}getState(){return{...this.state}}setItems(e){this.config={...this.config,items:e},this.itemsMap.clear(),this.parentMap.clear(),this.buildItemsMap(e,null),this.state.selectedValue&&!this.itemsMap.has(this.state.selectedValue)&&(this.state={...this.state,selectedValue:null,selectedPath:[]}),this.renderColumns()}destroy(){this.container.innerHTML="",this.columnsWrapper=null,this.itemsMap.clear(),this.parentMap.clear()}buildItemsMap(e,i){for(const n of e)this.itemsMap.set(n.value,n),this.parentMap.set(n.value,i),n.children&&n.children.length>0&&this.buildItemsMap(n.children,n.value)}getPathToValue(e){const i=[];let n=e;for(;n!==null;)i.unshift(n),n=this.parentMap.get(n)??null;return i}getColumnsData(){const e=[],i=this.config.maxColumns??3;e.push({items:this.config.items,parentValue:null});for(let n=0;n<this.state.selectedPath.length&&e.length<i;n++){const s=this.state.selectedPath[n],a=this.itemsMap.get(s);a!=null&&a.children&&a.children.length>0&&e.push({items:a.children,parentValue:s})}return e}renderColumns(){if(!this.columnsWrapper)return;this.columnsWrapper.innerHTML="",this.getColumnsData().forEach((i,n)=>{const s=this.renderColumn(i,n);this.columnsWrapper.appendChild(s)})}renderColumn(e,i){const n=c("div",{className:"browser-column",attributes:{role:"listbox","aria-label":`カラム ${i+1}`,"data-column-index":String(i)}});return e.items.forEach((s,a)=>{const r=this.renderItem(s,i,a);n.appendChild(r)}),n}renderItem(e,i,n){const s=this.state.selectedPath.includes(e.value),a=this.state.selectedValue===e.value,r=e.children&&e.children.length>0,o=this.state.focusedColumnIndex===i&&this.state.focusedItemIndexes[i]===n,l=c("label",{className:["browser-item",s?"is-selected":"",a?"is-leaf-selected":"",e.disabled?"is-disabled":"",o?"is-focused":""].filter(Boolean).join(" "),attributes:{"data-value":e.value,"data-column":String(i),"data-index":String(n)}}),d=document.createElement("input");d.type="radio",d.name=`${this.instanceId}-column-${i}`,d.value=e.value,d.checked=s,d.disabled=e.disabled??!1,d.tabIndex=o?0:-1,d.className="browser-item-radio",d.setAttribute("aria-label",e.label),d.addEventListener("change",()=>{e.disabled||this.handleItemSelect(e,i,n)}),d.addEventListener("focus",()=>{this.state={...this.state,focusedColumnIndex:i,focusedItemIndexes:this.state.focusedItemIndexes.map((f,g)=>g===i?n:f)}}),l.appendChild(d);const p=c("span",{className:"browser-item-content"}),u=c("span",{className:"browser-item-label",textContent:e.label});if(p.appendChild(u),r){const f=this.renderArrowIcon();p.appendChild(f)}return l.appendChild(p),l.addEventListener("click",f=>{if(e.disabled){f.preventDefault();return}this.handleItemSelect(e,i,n)}),l}renderArrowIcon(){const e=c("span",{className:"browser-item-arrow",attributes:{"aria-hidden":"true"}}),i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("width","16"),i.setAttribute("height","16"),i.setAttribute("viewBox","0 0 16 16"),i.setAttribute("fill","currentColor");const n=document.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("d","M6 3l5 5-5 5V3z"),i.appendChild(n),e.appendChild(i),e}handleItemSelect(e,i,n){var r,o,l,d;const s=[...this.state.selectedPath.slice(0,i),e.value],a=e.children&&e.children.length>0;this.state={...this.state,selectedValue:e.value,selectedPath:s,focusedColumnIndex:a?i+1:i,focusedItemIndexes:this.state.focusedItemIndexes.map((p,u)=>u===i?n:u===i+1?0:p)},this.renderColumns(),(o=(r=this.callbacks).onSelect)==null||o.call(r,e.value,s,e),(d=(l=this.callbacks).onChange)==null||d.call(l,e.value,s),a&&setTimeout(()=>{this.focusCurrentItem()},0)}handleKeyDown(e){if(this.getColumnsData()[this.state.focusedColumnIndex])switch(e.key){case"ArrowUp":e.preventDefault(),this.moveFocus(-1,0);break;case"ArrowDown":e.preventDefault(),this.moveFocus(1,0);break;case"ArrowLeft":e.preventDefault(),this.moveFocus(0,-1);break;case"ArrowRight":case"Enter":case" ":e.preventDefault(),this.selectFocusedOrMoveRight();break}}moveFocus(e,i){const n=this.getColumnsData();let s=this.state.focusedColumnIndex+i;s=Math.max(0,Math.min(s,n.length-1));const a=n[s];if(!a)return;let r=this.state.focusedItemIndexes[s]+e;r=Math.max(0,Math.min(r,a.items.length-1)),this.state={...this.state,focusedColumnIndex:s,focusedItemIndexes:this.state.focusedItemIndexes.map((o,l)=>l===s?r:o)},this.renderColumns(),this.focusCurrentItem()}selectFocusedOrMoveRight(){const i=this.getColumnsData()[this.state.focusedColumnIndex];if(!i)return;const n=this.state.focusedItemIndexes[this.state.focusedColumnIndex],s=i.items[n];!s||s.disabled||this.handleItemSelect(s,this.state.focusedColumnIndex,n)}focusCurrentItem(){const e=`.browser-item[data-column="${this.state.focusedColumnIndex}"][data-index="${this.state.focusedItemIndexes[this.state.focusedColumnIndex]}"] .browser-item-radio`,i=this.container.querySelector(e);i==null||i.focus()}static renderField(e){return y(e,`
|
|
179
|
+
<div class="mokkun-browser browser-placeholder">
|
|
180
|
+
<div class="browser-toolbar">
|
|
181
|
+
<div class="browser-controls">
|
|
182
|
+
<span class="browser-dot browser-dot-red"></span>
|
|
183
|
+
<span class="browser-dot browser-dot-yellow"></span>
|
|
184
|
+
<span class="browser-dot browser-dot-green"></span>
|
|
185
|
+
</div>
|
|
186
|
+
<div class="browser-url-bar">
|
|
187
|
+
<span class="browser-url">https://example.com</span>
|
|
188
|
+
</div>
|
|
189
|
+
</div>
|
|
190
|
+
<div class="browser-content">
|
|
191
|
+
<p class="browser-placeholder-text">ブラウザコンテンツ</p>
|
|
192
|
+
</div>
|
|
193
|
+
</div>
|
|
194
|
+
`)}}class Na{constructor(e,i={},n){h(this,"config");h(this,"state");h(this,"callbacks");h(this,"container");h(this,"calendarElement",null);this.config=i,this.container=e,this.callbacks=n,this.state=this.createInitialState()}render(){this.container.innerHTML="",this.container.className="mokkun-calendar",this.state.disabled?this.container.setAttribute("data-disabled",""):this.container.removeAttribute("data-disabled");const e=c("div",{className:"calendar-container",attributes:{role:"application","aria-label":this.config.ariaLabel??"カレンダー"}}),i=this.renderHeader();e.appendChild(i);const n=this.renderGrid();e.appendChild(n),this.container.appendChild(e),this.calendarElement=e,this.setupKeyboardNavigation()}setValue(e){this.state={...this.state,value:e?this.normalizeDate(e):null},e&&(this.state.displayedMonth=this.getFirstDayOfMonth(e)),this.render()}getValue(){return this.state.value}setDisplayedMonth(e){var i,n;this.state={...this.state,displayedMonth:this.getFirstDayOfMonth(e)},this.render(),(n=(i=this.callbacks).onMonthChange)==null||n.call(i,this.state.displayedMonth,this.state)}setDisabled(e){this.state.disabled!==e&&(this.state={...this.state,disabled:e},this.render())}setRange(e,i){this.config={...this.config,from:e?this.normalizeDate(e):void 0,to:i?this.normalizeDate(i):void 0},this.render()}getState(){return{...this.state}}destroy(){this.container.innerHTML="",this.calendarElement=null}createInitialState(){const e=this.config.value?this.normalizeDate(this.config.value):null,i=e?this.getFirstDayOfMonth(e):this.getFirstDayOfMonth(new Date);return{value:e,displayedMonth:i,focusedDate:null,disabled:this.config.disabled??!1}}renderHeader(){const e=c("div",{className:"calendar-header"}),i=c("button",{className:"calendar-nav-button calendar-prev",attributes:{type:"button","aria-label":"前の月",...this.state.disabled&&{disabled:"disabled"}}});i.innerHTML=this.getChevronLeftIcon(),i.addEventListener("click",this.handlePrevMonth.bind(this));const n=c("div",{className:"calendar-month-label",attributes:{"aria-live":"polite"}});n.textContent=this.formatMonthYear(this.state.displayedMonth);const s=c("button",{className:"calendar-nav-button calendar-next",attributes:{type:"button","aria-label":"次の月",...this.state.disabled&&{disabled:"disabled"}}});return s.innerHTML=this.getChevronRightIcon(),s.addEventListener("click",this.handleNextMonth.bind(this)),e.appendChild(i),e.appendChild(n),e.appendChild(s),e}renderGrid(){const e=c("div",{className:"calendar-grid",attributes:{role:"grid","aria-label":this.formatMonthYear(this.state.displayedMonth)}}),i=this.renderWeekdayHeader();e.appendChild(i);const n=this.getCalendarWeeks();for(const s of n){const a=this.renderWeekRow(s);e.appendChild(a)}return e}renderWeekdayHeader(){const e=c("div",{className:"calendar-weekdays",attributes:{role:"row"}}),i=this.getWeekdayLabels();for(const n of i){const s=c("div",{className:"calendar-weekday",attributes:{role:"columnheader","aria-label":n.full},textContent:n.short});e.appendChild(s)}return e}renderWeekRow(e){const i=c("div",{className:"calendar-week",attributes:{role:"row"}});for(const n of e){const s=this.renderDateCell(n);i.appendChild(s)}return i}renderDateCell(e){if(!e)return c("div",{className:"calendar-day calendar-day-empty",attributes:{role:"gridcell"}});const i=this.isToday(e),n=this.isSelected(e),s=this.isDateDisabled(e),a=!this.isDateInRange(e),r=e.getMonth()===this.state.displayedMonth.getMonth(),o=["calendar-day"];i&&o.push("calendar-day-today"),n&&o.push("calendar-day-selected"),(s||a)&&o.push("calendar-day-disabled"),r||o.push("calendar-day-outside");const l=c("button",{className:o.join(" "),attributes:{type:"button",role:"gridcell",tabindex:n?"0":"-1","aria-label":this.formatDateFull(e),"aria-selected":n?"true":"false","aria-disabled":s||a?"true":"false","data-date":e.toISOString().split("T")[0],...i&&{"data-today":""},...(s||a||this.state.disabled)&&{disabled:"disabled"}},textContent:e.getDate().toString()});return!s&&!a&&!this.state.disabled&&l.addEventListener("click",d=>this.handleDateClick(d,e)),l}setupKeyboardNavigation(){this.calendarElement&&this.calendarElement.addEventListener("keydown",e=>{var a;if(this.state.disabled)return;const i=e.key;let n=null;const s=this.state.focusedDate||this.state.value||new Date;switch(i){case"ArrowLeft":e.preventDefault(),n=this.addDays(s,-1);break;case"ArrowRight":e.preventDefault(),n=this.addDays(s,1);break;case"ArrowUp":e.preventDefault(),n=this.addDays(s,-7);break;case"ArrowDown":e.preventDefault(),n=this.addDays(s,7);break;case"Enter":case" ":if(e.preventDefault(),this.state.focusedDate&&this.isDateInRange(this.state.focusedDate)){const r=(a=this.calendarElement)==null?void 0:a.querySelector(`[data-date="${this.state.focusedDate.toISOString().split("T")[0]}"]`);r&&r.click()}break}n&&this.focusDate(n)})}focusDate(e){e.getMonth()!==this.state.displayedMonth.getMonth()||e.getFullYear()!==this.state.displayedMonth.getFullYear()?(this.state.displayedMonth=this.getFirstDayOfMonth(e),this.state.focusedDate=e,this.render()):this.state.focusedDate=e;const i=this.container.querySelector(`[data-date="${e.toISOString().split("T")[0]}"]`);i&&(i.focus(),i.setAttribute("tabindex","0"),this.container.querySelectorAll('.calendar-day:not([data-date="'+e.toISOString().split("T")[0]+'"])').forEach(n=>{n.setAttribute("tabindex","-1")}))}handlePrevMonth(){var i,n;if(this.state.disabled)return;const e=new Date(this.state.displayedMonth);e.setMonth(e.getMonth()-1),this.state.displayedMonth=e,this.render(),(n=(i=this.callbacks).onMonthChange)==null||n.call(i,e,this.state)}handleNextMonth(){var i,n;if(this.state.disabled)return;const e=new Date(this.state.displayedMonth);e.setMonth(e.getMonth()+1),this.state.displayedMonth=e,this.render(),(n=(i=this.callbacks).onMonthChange)==null||n.call(i,e,this.state)}handleDateClick(e,i){this.state.disabled||this.isDateInRange(i)&&(this.state={...this.state,value:i,focusedDate:i},this.render(),this.callbacks.onSelectDate(e,i,this.state))}normalizeDate(e){const i=new Date(e);return i.setHours(0,0,0,0),i}getFirstDayOfMonth(e){return new Date(e.getFullYear(),e.getMonth(),1)}getCalendarWeeks(){const e=[],i=this.getFirstDayOfMonth(this.state.displayedMonth),n=new Date(i.getFullYear(),i.getMonth()+1,0),s=this.config.weekStartsOn??0;let a=new Date(i);const o=(a.getDay()-s+7)%7;a.setDate(a.getDate()-o);for(let l=0;l<6;l++){const d=[];for(let u=0;u<7;u++){const f=new Date(a);f.setDate(a.getDate()+l*7+u),d.push(f)}e.push(d);const p=new Date(a);if(p.setDate(a.getDate()+l*7+6),p>n&&l>=3){const u=new Date(a);if(u.setDate(a.getDate()+(l+1)*7),u.getMonth()!==i.getMonth())break}}return e}getWeekdayLabels(){const e=this.config.locale??"ja-JP",i=this.config.weekStartsOn??0,n=[];for(let s=0;s<7;s++){const a=(s+i)%7,r=new Date(2024,0,7+a);n.push({short:r.toLocaleDateString(e,{weekday:"short"}),full:r.toLocaleDateString(e,{weekday:"long"})})}return n}formatMonthYear(e){const i=this.config.locale??"ja-JP";return e.toLocaleDateString(i,{year:"numeric",month:"long"})}formatDateFull(e){const i=this.config.locale??"ja-JP";return e.toLocaleDateString(i,{year:"numeric",month:"long",day:"numeric",weekday:"long"})}isToday(e){const i=this.normalizeDate(new Date);return e.getTime()===i.getTime()}isSelected(e){return this.state.value?e.getTime()===this.state.value.getTime():!1}isDateDisabled(e){return this.state.disabled}isDateInRange(e){const i=this.normalizeDate(e);if(this.config.from){const n=this.normalizeDate(this.config.from);if(i<n)return!1}if(this.config.to){const n=this.normalizeDate(this.config.to);if(i>n)return!1}return!0}addDays(e,i){const n=new Date(e);return n.setDate(n.getDate()+i),this.normalizeDate(n)}getChevronLeftIcon(){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
195
|
+
<path d="M10 12L6 8L10 4" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
196
|
+
</svg>`}getChevronRightIcon(){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
197
|
+
<path d="M6 12L10 8L6 4" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
198
|
+
</svg>`}static renderField(e){const i=`
|
|
199
|
+
<div class="mokkun-calendar calendar-placeholder">
|
|
200
|
+
<div class="calendar-header">
|
|
201
|
+
<button type="button" class="calendar-nav-btn" aria-label="前月">←</button>
|
|
202
|
+
<span class="calendar-month-year">2024年12月</span>
|
|
203
|
+
<button type="button" class="calendar-nav-btn" aria-label="次月">→</button>
|
|
204
|
+
</div>
|
|
205
|
+
<div class="calendar-grid">
|
|
206
|
+
<div class="calendar-weekdays">
|
|
207
|
+
<span>日</span><span>月</span><span>火</span><span>水</span><span>木</span><span>金</span><span>土</span>
|
|
208
|
+
</div>
|
|
209
|
+
<div class="calendar-days">
|
|
210
|
+
${Array.from({length:35},(n,s)=>{const a=s-5;return a<1||a>31?'<span class="calendar-day calendar-day-empty"></span>':`<span class="calendar-day ${a===15?"calendar-day-selected":""}">${a}</span>`}).join("")}
|
|
211
|
+
</div>
|
|
212
|
+
</div>
|
|
213
|
+
</div>
|
|
214
|
+
`;return y(e,i)}}class mi{constructor(e,i,n={}){h(this,"config");h(this,"state");h(this,"callbacks");h(this,"triggerElement");h(this,"tooltipElement",null);h(this,"instanceId");h(this,"showTimeout",null);h(this,"hideTimeout",null);h(this,"handleMouseEnter",()=>{this.state={...this.state,hovering:!0},this.show()});h(this,"handleMouseLeave",()=>{this.state={...this.state,hovering:!1},this.hide()});h(this,"handleFocus",()=>{this.show()});h(this,"handleBlur",()=>{this.hide()});this.config={position:"top",delay:300,showArrow:!0,isHtml:!1,maxWidth:"200px",disabled:!1,markTrigger:!0,...i},this.triggerElement=e,this.callbacks=n,this.instanceId=E("tooltip"),this.state={visible:!1,hovering:!1},this.initialize()}show(){this.config.disabled||this.state.visible||(this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=null),this.showTimeout=window.setTimeout(()=>{var e,i;this.state={...this.state,visible:!0},this.render(),(i=(e=this.callbacks).onShow)==null||i.call(e)},this.config.delay))}hide(){this.showTimeout&&(clearTimeout(this.showTimeout),this.showTimeout=null),this.state.hovering||(this.hideTimeout=window.setTimeout(()=>{var e,i;this.state={...this.state,visible:!1},this.removeTooltip(),(i=(e=this.callbacks).onHide)==null||i.call(e)},100))}showImmediate(){var e,i;this.config.disabled||(this.showTimeout&&(clearTimeout(this.showTimeout),this.showTimeout=null),this.state={...this.state,visible:!0},this.render(),(i=(e=this.callbacks).onShow)==null||i.call(e))}hideImmediate(){var e,i;this.showTimeout&&(clearTimeout(this.showTimeout),this.showTimeout=null),this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=null),this.state={...this.state,visible:!1},this.removeTooltip(),(i=(e=this.callbacks).onHide)==null||i.call(e)}setContent(e){this.config={...this.config,content:e},this.state.visible&&this.render()}setPosition(e){this.config={...this.config,position:e},this.state.visible&&this.render()}setDisabled(e){this.config={...this.config,disabled:e},e&&this.state.visible&&this.hideImmediate()}destroy(){this.hideImmediate(),this.removeEventListeners(),this.config.markTrigger&&(this.triggerElement.removeAttribute("data-tooltip-trigger"),this.triggerElement.removeAttribute("aria-describedby"))}getState(){return{...this.state}}isVisible(){return this.state.visible}initialize(){this.config.markTrigger&&(this.triggerElement.setAttribute("data-tooltip-trigger",""),this.triggerElement.setAttribute("aria-describedby",this.instanceId)),this.attachEventListeners()}attachEventListeners(){this.triggerElement.addEventListener("mouseenter",this.handleMouseEnter),this.triggerElement.addEventListener("mouseleave",this.handleMouseLeave),this.triggerElement.addEventListener("focus",this.handleFocus),this.triggerElement.addEventListener("blur",this.handleBlur)}removeEventListeners(){this.triggerElement.removeEventListener("mouseenter",this.handleMouseEnter),this.triggerElement.removeEventListener("mouseleave",this.handleMouseLeave),this.triggerElement.removeEventListener("focus",this.handleFocus),this.triggerElement.removeEventListener("blur",this.handleBlur)}render(){if(this.removeTooltipImmediate(),this.tooltipElement=c("div",{className:`mokkun-tooltip tooltip-${this.config.position}`,attributes:{id:this.instanceId,role:"tooltip","data-position":this.config.position??"top"}}),this.tooltipElement.style.maxWidth=this.config.maxWidth??"200px",this.config.showArrow){const i=c("div",{className:"tooltip-arrow",attributes:{"data-position":this.config.position??"top"}});this.tooltipElement.appendChild(i)}const e=c("div",{className:"tooltip-content"});this.config.isHtml?e.innerHTML=this.config.content:e.textContent=this.config.content,this.tooltipElement.appendChild(e),document.body.appendChild(this.tooltipElement),this.positionTooltip(),this.tooltipElement.addEventListener("mouseenter",()=>{this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=null)}),this.tooltipElement.addEventListener("mouseleave",()=>{this.hide()}),requestAnimationFrame(()=>{var i;(i=this.tooltipElement)==null||i.classList.add("tooltip-visible")})}positionTooltip(){if(!this.tooltipElement)return;const e=this.triggerElement.getBoundingClientRect(),i=this.tooltipElement.getBoundingClientRect(),n=this.config.position??"top",s=8;let a=0,r=0;switch(n){case"top":a=e.top+window.scrollY-i.height-s,r=e.left+window.scrollX+(e.width-i.width)/2;break;case"bottom":a=e.bottom+window.scrollY+s,r=e.left+window.scrollX+(e.width-i.width)/2;break;case"left":a=e.top+window.scrollY+(e.height-i.height)/2,r=e.left+window.scrollX-i.width-s;break;case"right":a=e.top+window.scrollY+(e.height-i.height)/2,r=e.right+window.scrollX+s;break}const o=window.innerWidth,l=window.innerHeight;r<0?r=8:r+i.width>o&&(r=o-i.width-8),a<window.scrollY?a=window.scrollY+8:a+i.height>window.scrollY+l&&(a=window.scrollY+l-i.height-8),this.tooltipElement.style.top=`${a}px`,this.tooltipElement.style.left=`${r}px`}removeTooltip(){this.tooltipElement&&(this.tooltipElement.classList.remove("tooltip-visible"),setTimeout(()=>{this.tooltipElement&&this.tooltipElement.parentNode&&this.tooltipElement.parentNode.removeChild(this.tooltipElement),this.tooltipElement=null},200))}removeTooltipImmediate(){this.tooltipElement&&this.tooltipElement.parentNode&&(this.tooltipElement.parentNode.removeChild(this.tooltipElement),this.tooltipElement=null)}static renderField(e){const i=e,n=i.text??"ヘルプ",s=i.content??"ツールチップの内容",a=`
|
|
215
|
+
<div class="mokkun-tooltip-container">
|
|
216
|
+
<span class="tooltip-trigger" tabindex="0" aria-describedby="${m(e.id)}-tooltip">${m(n)}</span>
|
|
217
|
+
<div class="tooltip-content" id="${m(e.id)}-tooltip" role="tooltip">${m(s)}</div>
|
|
218
|
+
</div>
|
|
219
|
+
`;return y(e,a)}}class Ta{constructor(e,i,n={}){h(this,"config");h(this,"state");h(this,"callbacks");h(this,"containerElement");h(this,"floatAreaElement",null);h(this,"instanceId");this.config={zIndex:500,bottom:"24px",maxWidth:"800px",...i},this.containerElement=e,this.callbacks=n,this.instanceId=E("float-area"),this.state={visible:!0,zIndex:this.config.zIndex??500,responseMessage:this.config.responseMessage??null}}render(){this.removeElement(),this.createFloatAreaElement()}show(){var e,i;this.state.visible||(this.state={...this.state,visible:!0},this.updateVisibility(),(i=(e=this.callbacks).onShow)==null||i.call(e))}hide(){var e,i;this.state.visible&&(this.state={...this.state,visible:!1},this.updateVisibility(),(i=(e=this.callbacks).onHide)==null||i.call(e))}toggle(){this.state.visible?this.hide():this.show()}setResponseMessage(e){this.state={...this.state,responseMessage:e},this.render()}showSuccess(e){this.setResponseMessage({text:e,type:"success"})}showError(e){this.setResponseMessage({text:e,type:"error"})}clearMessage(){this.setResponseMessage(null)}updatePrimaryButton(e){this.config={...this.config,primaryButton:{...this.config.primaryButton,...e}},this.render()}setPrimaryDisabled(e){this.updatePrimaryButton({disabled:e})}setZIndex(e){this.state={...this.state,zIndex:e},this.floatAreaElement&&(this.floatAreaElement.style.zIndex=String(e))}destroy(){this.removeElement()}getState(){return{...this.state}}isVisible(){return this.state.visible}createFloatAreaElement(){this.floatAreaElement=c("div",{className:this.buildClassName(),attributes:{id:this.instanceId,role:"region","aria-label":this.config.ariaLabel??"アクション","aria-hidden":String(!this.state.visible)}}),this.floatAreaElement.style.zIndex=String(this.state.zIndex),this.config.bottom&&this.floatAreaElement.style.setProperty("--float-area-bottom",this.config.bottom),this.config.maxWidth&&this.floatAreaElement.style.setProperty("--float-area-max-width",this.config.maxWidth);const e=c("div",{className:"float-area-inner"});if(this.config.tertiaryButton){const s=c("div",{className:"float-area-tertiary"});s.appendChild(this.createButton(this.config.tertiaryButton,"tertiary")),e.appendChild(s)}const i=c("div",{className:"float-area-main"});if(this.state.responseMessage){const s=this.createResponseMessage(this.state.responseMessage);i.appendChild(s)}const n=c("div",{className:"float-area-buttons"});this.config.secondaryButton&&n.appendChild(this.createButton(this.config.secondaryButton,"secondary")),n.appendChild(this.createButton(this.config.primaryButton,"primary")),i.appendChild(n),e.appendChild(i),this.floatAreaElement.appendChild(e),this.containerElement.appendChild(this.floatAreaElement)}createButton(e,i){const n=e.variant??(i==="primary"?"primary":i==="tertiary"?"text":"secondary"),s=document.createElement("button");return s.type="button",s.className=`float-area-btn float-area-btn-${n}`,s.textContent=e.label,s.disabled=e.disabled??!1,e.disabled&&s.setAttribute("aria-disabled","true"),s.addEventListener("click",()=>{var a,r,o,l,d,p,u;e.disabled||((a=e.onClick)==null||a.call(e),i==="primary"?(o=(r=this.callbacks).onPrimaryClick)==null||o.call(r):i==="secondary"?(d=(l=this.callbacks).onSecondaryClick)==null||d.call(l):(u=(p=this.callbacks).onTertiaryClick)==null||u.call(p))}),s}createResponseMessage(e){const i=c("div",{className:`float-area-message float-area-message-${e.type}`,attributes:{role:e.type==="error"?"alert":"status","aria-live":"polite"}}),n=this.getMessageIcon(e.type),s=c("span",{className:"float-area-message-icon"});s.innerHTML=n,i.appendChild(s);const a=c("span",{className:"float-area-message-text"});return a.textContent=e.text,i.appendChild(a),i}getMessageIcon(e){switch(e){case"success":return'<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor"><path d="M8 0a8 8 0 1 0 0 16A8 8 0 0 0 8 0zm3.78 5.22a.75.75 0 0 1 0 1.06l-4.5 4.5a.75.75 0 0 1-1.06 0l-2-2a.75.75 0 0 1 1.06-1.06L6.75 9.19l3.97-3.97a.75.75 0 0 1 1.06 0z"/></svg>';case"error":return'<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor"><path d="M8 0a8 8 0 1 0 0 16A8 8 0 0 0 8 0zm0 3a.75.75 0 0 1 .75.75v4.5a.75.75 0 0 1-1.5 0v-4.5A.75.75 0 0 1 8 3zm0 8a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"/></svg>';case"warning":return'<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor"><path d="M8.22 1.754a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368L8.22 1.754zm-1.763-.707c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575L6.457 1.047zM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm-.25-5.25a.75.75 0 0 0-1.5 0v2.5a.75.75 0 0 0 1.5 0v-2.5z"/></svg>';case"info":return'<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor"><path d="M8 0a8 8 0 1 0 0 16A8 8 0 0 0 8 0zm.75 4.75a.75.75 0 0 1-1.5 0 .75.75 0 0 1 1.5 0zM7 7a.75.75 0 0 1 .75-.75h.5a.75.75 0 0 1 .75.75v3.25h.25a.75.75 0 0 1 0 1.5h-2a.75.75 0 0 1 0-1.5H7V7.75A.75.75 0 0 1 7 7z"/></svg>'}}buildClassName(){const e=["mokkun-float-area"];return this.state.visible||e.push("float-area-hidden"),e.join(" ")}updateVisibility(){this.floatAreaElement&&(this.state.visible?(this.floatAreaElement.classList.remove("float-area-hidden"),this.floatAreaElement.setAttribute("aria-hidden","false")):(this.floatAreaElement.classList.add("float-area-hidden"),this.floatAreaElement.setAttribute("aria-hidden","true")))}removeElement(){this.floatAreaElement&&this.floatAreaElement.parentNode&&this.floatAreaElement.parentNode.removeChild(this.floatAreaElement),this.floatAreaElement=null}static renderField(e){return y(e,`
|
|
220
|
+
<div class="mokkun-float-area">
|
|
221
|
+
<div class="float-area-content">
|
|
222
|
+
<span class="float-area-placeholder">[フロートエリア]</span>
|
|
223
|
+
</div>
|
|
224
|
+
</div>
|
|
225
|
+
`)}}class Ma{constructor(e,i={},n={}){h(this,"config");h(this,"state");h(this,"callbacks");h(this,"container");h(this,"instanceId");h(this,"loaderElement",null);h(this,"overlayElement",null);h(this,"spinnerElement",null);h(this,"textElement",null);h(this,"progressBarContainer",null);h(this,"progressBarFill",null);this.container=e,this.config={size:"medium",type:"primary",overlay:!1,ariaLabel:"Loading",...i},this.callbacks=n,this.instanceId=E("loader"),this.state=this.createInitialState(),this.config.autoShow&&setTimeout(()=>this.show(),0)}show(){var e,i;this.state.isVisible||(this.state={...this.state,isVisible:!0},this.render(),(i=(e=this.callbacks).onShow)==null||i.call(e))}hide(){var e,i;this.state.isVisible&&(this.state={...this.state,isVisible:!1},this.cleanup(),(i=(e=this.callbacks).onHide)==null||i.call(e))}setProgress(e){var n,s;const i=Math.max(0,Math.min(100,e));this.state={...this.state,progress:i},this.state.isVisible&&this.progressBarFill&&this.updateProgressBar(i),(s=(n=this.callbacks).onProgressUpdate)==null||s.call(n,i)}setText(e){this.state={...this.state,text:e},this.state.isVisible&&this.textElement&&(this.textElement.textContent=e)}getState(){return{...this.state}}destroy(){this.cleanup(),this.state={...this.state,isVisible:!1}}render(){this.config.overlay?this.renderOverlay():this.renderInline()}renderInline(){if(!this.container){console.warn("Loader: No container provided for inline mode");return}this.loaderElement=this.createLoaderElement(),this.container.innerHTML="",this.container.appendChild(this.loaderElement)}renderOverlay(){this.overlayElement=c("div",{className:"loader-overlay",attributes:{role:"status","aria-modal":"true","aria-busy":"true","aria-label":this.config.ariaLabel||"Loading"}});const e=c("div",{className:"loader-overlay-content"});this.loaderElement=this.createLoaderElement(),e.appendChild(this.loaderElement),this.overlayElement.appendChild(e),document.body.appendChild(this.overlayElement),document.body.classList.add("loader-open")}createLoaderElement(){const e=c("div",{className:"mokkun-loader",attributes:{id:this.instanceId}});if(this.spinnerElement=this.createSpinner(),e.appendChild(this.spinnerElement),(this.config.text||this.state.text)&&(this.textElement=this.createText(),e.appendChild(this.textElement)),this.config.progress!==void 0||this.state.progress!==void 0){const i=this.createProgressBar();e.appendChild(i)}return this.config.overlay||(e.setAttribute("role","status"),e.setAttribute("aria-label",this.config.ariaLabel||"Loading")),e}createSpinner(){const e=this.config.size||"medium",i=this.config.type||"primary";return c("div",{className:"loader-spinner",attributes:{"data-size":e,"data-type":i,"aria-hidden":"true"}})}createText(){const e=this.state.text||this.config.text||"";return c("div",{className:"loader-text",textContent:e,attributes:{"aria-live":"polite"}})}createProgressBar(){const e=this.state.progress??this.config.progress??0;return this.progressBarContainer=c("div",{className:"loader-progress",attributes:{role:"progressbar","aria-valuemin":"0","aria-valuemax":"100","aria-valuenow":String(e)}}),this.progressBarFill=c("div",{className:"loader-progress-fill"}),this.progressBarFill.style.width=`${e}%`,this.progressBarContainer.appendChild(this.progressBarFill),this.progressBarContainer}updateProgressBar(e){this.progressBarFill&&(this.progressBarFill.style.width=`${e}%`),this.progressBarContainer&&this.progressBarContainer.setAttribute("aria-valuenow",String(e))}createInitialState(){return{isVisible:!1,progress:this.config.progress,text:this.config.text}}cleanup(){this.overlayElement&&(this.overlayElement.remove(),this.overlayElement=null,document.body.classList.remove("loader-open")),this.loaderElement&&!this.config.overlay&&(this.loaderElement.remove(),this.loaderElement=null),this.spinnerElement=null,this.textElement=null,this.progressBarContainer=null,this.progressBarFill=null}static renderField(e){const i=e,n=i.size??"medium",s=i.text,a=`
|
|
226
|
+
<div class="mokkun-loader loader-${n}">
|
|
227
|
+
<div class="loader-spinner"></div>
|
|
228
|
+
${s?`<span class="loader-text">${m(s)}</span>`:""}
|
|
229
|
+
</div>
|
|
230
|
+
`;return y(e,a)}}const Da={info:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M15 8A7 7 0 1 1 1 8a7 7 0 0 1 14 0ZM9 5a1 1 0 1 1-2 0 1 1 0 0 1 2 0ZM6.75 8a.75.75 0 0 0 0 1.5h.75v1.75a.75.75 0 0 0 1.5 0v-2.5A.75.75 0 0 0 8.25 8h-1.5Z" clip-rule="evenodd" /></svg>',success:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M8 15A7 7 0 1 0 8 1a7 7 0 0 0 0 14Zm3.844-8.791a.75.75 0 0 0-1.188-.918l-3.7 4.79-1.649-1.833a.75.75 0 1 0-1.114 1.004l2.25 2.5a.75.75 0 0 0 1.151-.043l4.25-5.5Z" clip-rule="evenodd" /></svg>',warning:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M6.701 2.25c.577-1 2.02-1 2.598 0l5.196 9a1.5 1.5 0 0 1-1.299 2.25H2.804a1.5 1.5 0 0 1-1.3-2.25l5.197-9ZM8 4a.75.75 0 0 1 .75.75v3a.75.75 0 0 1-1.5 0v-3A.75.75 0 0 1 8 4Zm0 8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z" clip-rule="evenodd" /></svg>',error:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M8 15A7 7 0 1 0 8 1a7 7 0 0 0 0 14ZM8 4a.75.75 0 0 1 .75.75v3a.75.75 0 0 1-1.5 0v-3A.75.75 0 0 1 8 4Zm0 8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z" clip-rule="evenodd" /></svg>',sync:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M13.836 2.477a.75.75 0 0 1 .75.75v3.182a.75.75 0 0 1-.75.75h-3.182a.75.75 0 0 1 0-1.5h1.37l-.84-.841a4.5 4.5 0 0 0-7.08.681.75.75 0 0 1-1.264-.808 6 6 0 0 1 9.44-.908l.97.969V3.227a.75.75 0 0 1 .75-.75Zm-1.09 7.595a6 6 0 0 1-9.44.908l-.97-.969v1.637a.75.75 0 0 1-1.5 0V8.466a.75.75 0 0 1 .75-.75h3.182a.75.75 0 0 1 0 1.5h-1.37l.84.841a4.5 4.5 0 0 0 7.08-.681.75.75 0 0 1 1.264.808Z" clip-rule="evenodd" /></svg>'},Fa='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d="M5.28 4.22a.75.75 0 0 0-1.06 1.06L6.94 8l-2.72 2.72a.75.75 0 1 0 1.06 1.06L8 9.06l2.72 2.72a.75.75 0 1 0 1.06-1.06L9.06 8l2.72-2.72a.75.75 0 0 0-1.06-1.06L8 6.94 5.28 4.22Z" /></svg>';class Oa{constructor(e,i,n={}){h(this,"config");h(this,"state");h(this,"callbacks");h(this,"container");h(this,"closeHandler",null);h(this,"actionHandler",null);this.config=i,this.container=e,this.callbacks=n,this.state=this.createInitialState()}render(){this.cleanup(),this.container.innerHTML="";const e=this.config.type??"info",i=this.state.bold,n=this.config.closable??!0;if(this.container.className=["mokkun-notification-bar",`notification-bar-${e}`,i?"notification-bar-bold":"",this.state.visible?"":"notification-bar-hidden"].filter(Boolean).join(" "),this.container.setAttribute("data-type",e),i?this.container.setAttribute("data-bold",""):this.container.removeAttribute("data-bold"),this.state.visible)this.container.removeAttribute("data-hidden");else{this.container.setAttribute("data-hidden","");return}const s=this.config.role??"status";this.container.setAttribute("role",s),this.container.setAttribute("aria-live",s==="alert"?"assertive":"polite");const a=this.config.ariaLabel??this.state.message;this.container.setAttribute("aria-label",a);const r=this.renderContent();if(this.container.appendChild(r),this.config.actionLabel&&this.callbacks.onAction){const o=this.renderActionButton();this.container.appendChild(o)}if(n&&this.callbacks.onClose){const o=this.renderCloseButton();this.container.appendChild(o)}}setMessage(e){this.state.message!==e&&(this.state={...this.state,message:e},this.render())}setVisible(e){this.state.visible!==e&&(this.state={...this.state,visible:e},this.render())}setBold(e){this.state.bold!==e&&(this.state={...this.state,bold:e},this.render())}show(){this.setVisible(!0)}hide(){this.setVisible(!1)}getMessage(){return this.state.message}isVisible(){return this.state.visible}isBold(){return this.state.bold}getState(){return{...this.state}}destroy(){this.cleanup(),this.container.innerHTML="",this.container.className="",this.container.removeAttribute("role"),this.container.removeAttribute("aria-live"),this.container.removeAttribute("aria-label"),this.container.removeAttribute("data-type"),this.container.removeAttribute("data-bold"),this.container.removeAttribute("data-hidden")}createInitialState(){return{message:this.config.message,visible:!0,bold:this.config.bold??!1}}renderContent(){const e=c("div",{className:"notification-bar-content"}),i=this.config.type??"info",n=c("span",{className:"notification-bar-icon",attributes:{"aria-hidden":"true"}});n.innerHTML=Da[i],e.appendChild(n);const s=c("span",{className:"notification-bar-message",textContent:this.state.message});return e.appendChild(s),e}renderActionButton(){const e=c("button",{className:"notification-bar-action",textContent:this.config.actionLabel,attributes:{type:"button"}});return this.actionHandler=this.handleAction.bind(this),e.addEventListener("click",this.actionHandler),e}renderCloseButton(){const e=c("button",{className:"notification-bar-close",attributes:{type:"button","aria-label":"閉じる"}});return e.innerHTML=Fa,this.closeHandler=this.handleClose.bind(this),e.addEventListener("click",this.closeHandler),e}handleAction(e){var i,n;e.stopPropagation(),(n=(i=this.callbacks).onAction)==null||n.call(i)}handleClose(e){var i,n;e.stopPropagation(),(n=(i=this.callbacks).onClose)==null||n.call(i)}cleanup(){if(this.closeHandler){const e=this.container.querySelector(".notification-bar-close");e==null||e.removeEventListener("click",this.closeHandler),this.closeHandler=null}if(this.actionHandler){const e=this.container.querySelector(".notification-bar-action");e==null||e.removeEventListener("click",this.actionHandler),this.actionHandler=null}}static renderField(e){const i=e,n=i.variant??"info",s=i.dismissible??!0,r=`
|
|
231
|
+
<div class="mokkun-notification-bar notification-${n}" role="alert">
|
|
232
|
+
<span class="notification-icon">${{info:"ℹ️",success:"✓",warning:"⚠️",error:"✕"}[n]}</span>
|
|
233
|
+
<div class="notification-content">
|
|
234
|
+
<span class="notification-message">${m(e.description??e.label)}</span>
|
|
235
|
+
</div>
|
|
236
|
+
${s?'<button type="button" class="notification-dismiss" aria-label="閉じる">×</button>':""}
|
|
237
|
+
</div>
|
|
238
|
+
`;return y(e,r)}}const gi={success:'<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z" clip-rule="evenodd" /></svg>',error:'<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z" clip-rule="evenodd" /></svg>',warning:'<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495zM10 5a.75.75 0 01.75.75v3.5a.75.75 0 01-1.5 0v-3.5A.75.75 0 0110 5zm0 9a1 1 0 100-2 1 1 0 000 2z" clip-rule="evenodd" /></svg>',info:'<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z" clip-rule="evenodd" /></svg>'},Ha='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M4.22 6.22a.75.75 0 011.06 0L8 8.94l2.72-2.72a.75.75 0 111.06 1.06l-3.25 3.25a.75.75 0 01-1.06 0L4.22 7.28a.75.75 0 010-1.06z" clip-rule="evenodd" /></svg>',za='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d="M3.72 3.72a.75.75 0 011.06 0L8 6.94l3.22-3.22a.75.75 0 111.06 1.06L9.06 8l3.22 3.22a.75.75 0 11-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 01-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 010-1.06z" /></svg>',bi='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M8 3a5 5 0 104.546 2.914.75.75 0 011.364-.628A6.5 6.5 0 118 1.5v-.75a.75.75 0 011.28-.53l2 2a.75.75 0 010 1.06l-2 2a.75.75 0 01-1.28-.53V3z" clip-rule="evenodd" /></svg>',vi='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true" class="response-message-spinner"><circle cx="8" cy="8" r="6" fill="none" stroke="currentColor" stroke-width="2" opacity="0.25" /><path d="M14 8a6 6 0 00-6-6" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" /></svg>',Ba=200;class Ra{constructor(e,i,n={}){h(this,"config");h(this,"state");h(this,"callbacks");h(this,"container");h(this,"instanceId");h(this,"detailsId");h(this,"detailsToggleHandler",null);h(this,"retryHandler",null);h(this,"closeHandler",null);this.config=i,this.container=e,this.callbacks=n,this.instanceId=i.id??E("response-message"),this.detailsId=`${this.instanceId}-details`,this.state=this.createInitialState()}render(){if(this.cleanupEventListeners(),this.container.innerHTML="",!this.state.visible){this.container.style.display="none";return}this.container.style.display="";const e=this.config.type??"info";if(this.container.className=this.buildClassName(e),this.container.id=this.instanceId,this.container.setAttribute("role",e==="error"?"alert":"status"),this.container.setAttribute("aria-live",e==="error"?"assertive":"polite"),this.config.ariaLabel&&this.container.setAttribute("aria-label",this.config.ariaLabel),!this.config.hideIcon){const n=this.renderIcon(e);this.container.appendChild(n)}const i=this.renderContent();if(this.container.appendChild(i),this.config.showClose){const n=this.renderCloseButton();this.container.appendChild(n)}}show(){this.state.visible||(this.state={...this.state,visible:!0},this.render())}hide(){var e,i;this.state.visible&&(this.state={...this.state,visible:!1},this.render(),(i=(e=this.callbacks).onClose)==null||i.call(e))}expandDetails(){var e,i;this.state.detailsExpanded||!this.hasDetails()||(this.state={...this.state,detailsExpanded:!0},this.updateDetailsState(),(i=(e=this.callbacks).onExpandDetails)==null||i.call(e))}collapseDetails(){var e,i;this.state.detailsExpanded&&(this.state={...this.state,detailsExpanded:!1},this.updateDetailsState(),(i=(e=this.callbacks).onCollapseDetails)==null||i.call(e))}toggleDetails(){this.state.detailsExpanded?this.collapseDetails():this.expandDetails()}setLoading(e){this.state.loading!==e&&(this.state={...this.state,loading:e},this.updateRetryButtonState())}setMessage(e){this.config={...this.config,message:e},this.render()}setDetails(e){this.config={...this.config,details:e},this.render()}setType(e){this.config={...this.config,type:e},this.render()}update(e){this.config={...this.config,...e},this.render()}getState(){return{...this.state}}isVisible(){return this.state.visible}isDetailsExpanded(){return this.state.detailsExpanded}destroy(){this.cleanupEventListeners(),this.container.innerHTML="",this.container.removeAttribute("role"),this.container.removeAttribute("aria-live"),this.container.removeAttribute("aria-label")}createInitialState(){return{visible:!0,detailsExpanded:!1,loading:!1}}cleanupEventListeners(){const e=this.container.querySelector(".response-message-details-toggle"),i=this.container.querySelector(".response-message-retry"),n=this.container.querySelector(".response-message-close");e&&this.detailsToggleHandler&&e.removeEventListener("click",this.detailsToggleHandler),i&&this.retryHandler&&i.removeEventListener("click",this.retryHandler),n&&this.closeHandler&&n.removeEventListener("click",this.closeHandler),this.detailsToggleHandler=null,this.retryHandler=null,this.closeHandler=null}buildClassName(e){const i=["mokkun-response-message",`response-message-${e}`];return this.config.className&&i.push(this.config.className),i.join(" ")}renderIcon(e){const i=c("div",{className:"response-message-icon",attributes:{"aria-hidden":"true"}});return this.config.icon?i.innerHTML=this.sanitizeSvgIcon(this.config.icon)??gi[e]:i.innerHTML=gi[e],i}renderContent(){const e=c("div",{className:"response-message-content"}),i=c("div",{className:"response-message-text",textContent:this.config.message});if(e.appendChild(i),this.hasDetails()||this.config.showRetry){const s=this.renderActions();e.appendChild(s)}if(this.hasDetails()){const s=this.renderDetails();e.appendChild(s)}return e}renderActions(){const e=c("div",{className:"response-message-actions"});if(this.hasDetails()){const i=this.renderDetailsToggle();e.appendChild(i)}if(this.config.showRetry){const i=this.renderRetryButton();e.appendChild(i)}return e}renderDetailsToggle(){const e=this.config.detailsLabel??"詳細",i=c("button",{className:`response-message-details-toggle${this.state.detailsExpanded?" is-expanded":""}`,attributes:{type:"button","aria-expanded":String(this.state.detailsExpanded),"aria-controls":this.detailsId}}),n=c("span",{className:"response-message-details-label",textContent:e});i.appendChild(n);const s=c("span",{className:"response-message-details-chevron"});return s.innerHTML=Ha,i.appendChild(s),this.detailsToggleHandler=()=>{this.toggleDetails()},i.addEventListener("click",this.detailsToggleHandler),i}renderRetryButton(){const e=this.config.retryLabel??"再試行",i=c("button",{className:`response-message-retry${this.state.loading?" is-loading":""}`,attributes:{type:"button","aria-disabled":String(this.state.loading)}});this.state.loading&&(i.disabled=!0);const n=c("span",{className:"response-message-retry-icon"});n.innerHTML=this.state.loading?vi:bi,i.appendChild(n);const s=c("span",{className:"response-message-retry-label",textContent:e});return i.appendChild(s),this.retryHandler=async()=>{if(this.state.loading)return;const a=this.callbacks.onRetry;if(a){this.setLoading(!0);try{await a()}finally{this.setLoading(!1)}}},i.addEventListener("click",this.retryHandler),i}renderDetails(){const e=c("div",{className:`response-message-details-wrapper${this.state.detailsExpanded?" is-expanded":""}`}),i=c("div",{className:"response-message-details",attributes:{id:this.detailsId}});this.state.detailsExpanded||i.setAttribute("hidden","");const n=this.config.details;if(Array.isArray(n)){const s=c("ul",{className:"response-message-details-list"});n.forEach(a=>{const r=c("li",{textContent:a});s.appendChild(r)}),i.appendChild(s)}else if(n){const s=c("div",{className:"response-message-details-text",textContent:n});i.appendChild(s)}return e.appendChild(i),e}renderCloseButton(){const e=c("button",{className:"response-message-close",attributes:{type:"button","aria-label":"閉じる"}});return e.innerHTML=za,this.closeHandler=()=>{this.hide()},e.addEventListener("click",this.closeHandler),e}updateDetailsState(){const e=this.container.querySelector(".response-message-details-toggle"),i=this.container.querySelector(".response-message-details-wrapper"),n=this.container.querySelector(".response-message-details");e&&(e.setAttribute("aria-expanded",String(this.state.detailsExpanded)),this.state.detailsExpanded?e.classList.add("is-expanded"):e.classList.remove("is-expanded")),i&&(this.state.detailsExpanded?i.classList.add("is-expanded"):i.classList.remove("is-expanded")),n&&(this.state.detailsExpanded?n.removeAttribute("hidden"):setTimeout(()=>{this.state.detailsExpanded||n.setAttribute("hidden","")},Ba))}updateRetryButtonState(){const e=this.container.querySelector(".response-message-retry"),i=this.container.querySelector(".response-message-retry-icon");e&&(e.disabled=this.state.loading,e.setAttribute("aria-disabled",String(this.state.loading)),this.state.loading?e.classList.add("is-loading"):e.classList.remove("is-loading")),i&&(i.innerHTML=this.state.loading?vi:bi)}hasDetails(){const e=this.config.details;return Array.isArray(e)?e.length>0:!!e}sanitizeSvgIcon(e){const i=e.trim();if(!i.toLowerCase().startsWith("<svg")||!i.toLowerCase().endsWith("</svg>"))return null;const s=new DOMParser().parseFromString(i,"image/svg+xml");if(s.querySelector("parsererror"))return null;const r=s.querySelector("svg");if(!r)return null;["script","foreignObject","iframe","object","embed","use"].forEach(p=>{r.querySelectorAll(p).forEach(u=>u.remove())});const l=["onload","onerror","onclick","onmouseover","onmouseout","onmousedown","onmouseup","onfocus","onblur","onkeydown","onkeyup","onkeypress","onsubmit","onreset","onchange","oninput","onscroll","onresize","onanimationstart","onanimationend","ontransitionend"];l.forEach(p=>r.removeAttribute(p));const d=r.getAttribute("href")??r.getAttribute("xlink:href");return d&&d.toLowerCase().startsWith("javascript:")&&(r.removeAttribute("href"),r.removeAttribute("xlink:href")),r.querySelectorAll("*").forEach(p=>{l.forEach(f=>p.removeAttribute(f));const u=p.getAttribute("href")??p.getAttribute("xlink:href");u&&u.toLowerCase().startsWith("javascript:")&&(p.removeAttribute("href"),p.removeAttribute("xlink:href"))}),r.outerHTML}static renderField(e){const n=e.variant??"success",a=`
|
|
239
|
+
<div class="mokkun-response-message response-${n}" role="status">
|
|
240
|
+
<span class="response-icon">${{success:"✓",error:"✕",warning:"⚠",info:"ℹ"}[n]}</span>
|
|
241
|
+
<span class="response-text">${m(e.description??e.label)}</span>
|
|
242
|
+
</div>
|
|
243
|
+
`;return y(e,a)}}const Ye={circle:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><circle cx="8" cy="8" r="6" /></svg>',dot:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><circle cx="8" cy="8" r="4" /></svg>',check:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M12.416 3.376a.75.75 0 0 1 .208 1.04l-5 7.5a.75.75 0 0 1-1.154.114l-3-3a.75.75 0 0 1 1.06-1.06l2.353 2.353 4.493-6.739a.75.75 0 0 1 1.04-.208Z" clip-rule="evenodd" /></svg>',warning:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M6.701 2.25c.577-1 2.02-1 2.598 0l5.196 9a1.5 1.5 0 0 1-1.299 2.25H2.804a1.5 1.5 0 0 1-1.3-2.25l5.197-9ZM8 4a.75.75 0 0 1 .75.75v3a.75.75 0 0 1-1.5 0v-3A.75.75 0 0 1 8 4Zm0 8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z" clip-rule="evenodd" /></svg>',error:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M8 15A7 7 0 1 0 8 1a7 7 0 0 0 0 14ZM8 4a.75.75 0 0 1 .75.75v3a.75.75 0 0 1-1.5 0v-3A.75.75 0 0 1 8 4Zm0 8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z" clip-rule="evenodd" /></svg>',info:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M15 8A7 7 0 1 1 1 8a7 7 0 0 1 14 0ZM9 5a1 1 0 1 1-2 0 1 1 0 0 1 2 0ZM6.75 8a.75.75 0 0 0 0 1.5h.75v1.75a.75.75 0 0 0 1.5 0v-2.5A.75.75 0 0 0 8.25 8h-1.5Z" clip-rule="evenodd" /></svg>',clock:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M1 8a7 7 0 1 1 14 0A7 7 0 0 1 1 8Zm7.75-4.25a.75.75 0 0 0-1.5 0V8c0 .414.336.75.75.75h3.25a.75.75 0 0 0 0-1.5h-2.5v-3.5Z" clip-rule="evenodd" /></svg>',star:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M8 1.75a.75.75 0 0 1 .692.462l1.41 3.393 3.664.293a.75.75 0 0 1 .428 1.317l-2.791 2.39.853 3.58a.75.75 0 0 1-1.12.814L8 11.95l-3.136 2.05a.75.75 0 0 1-1.12-.815l.853-3.58-2.79-2.39a.75.75 0 0 1 .427-1.316l3.663-.293 1.41-3.393A.75.75 0 0 1 8 1.75Z" clip-rule="evenodd" /></svg>',user:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d="M8 8a3 3 0 1 0 0-6 3 3 0 0 0 0 6ZM12.735 14c.618 0 1.093-.561.872-1.139a6.002 6.002 0 0 0-11.215 0c-.22.578.254 1.139.872 1.139h9.47Z" /></svg>',message:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M1 8.74c0 .983.713 1.825 1.69 1.943.764.092 1.534.164 2.31.216v2.351a.75.75 0 0 0 1.28.53l2.51-2.51c.182-.181.427-.283.684-.287A23.109 23.109 0 0 0 14 10.67c.7-.123 1-.87 1-1.63v-4.6c0-.76-.3-1.51-1-1.63A23.056 23.056 0 0 0 8 2.25c-2.154 0-4.254.147-6 .56-.7.12-1 .87-1 1.63v4.3Z" clip-rule="evenodd" /></svg>'};function Pa(t){return t instanceof Date?t:new Date(t)}function Va(t){const e=t.getFullYear(),i=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0");return`${e}/${i}/${n}`}function ja(t,e){if(e==="none")return"";const i=String(t.getHours()).padStart(2,"0"),n=String(t.getMinutes()).padStart(2,"0");if(e==="HH:mm")return`${i}:${n}`;const s=String(t.getSeconds()).padStart(2,"0");return`${i}:${n}:${s}`}function Ge(t){const i=new DOMParser().parseFromString(t,"text/html");["script","iframe","object","embed","form","input","button","textarea","select","style","link","meta","base","noscript"].forEach(a=>{i.querySelectorAll(a).forEach(r=>r.remove())});const s=["onload","onerror","onclick","onmouseover","onmouseout","onmousedown","onmouseup","onfocus","onblur","onkeydown","onkeyup","onkeypress","onsubmit","onreset","onchange","oninput","onscroll","onresize","onanimationstart","onanimationend","ontransitionend","oncontextmenu","ondblclick","ondrag","ondragend","ondragenter","ondragleave","ondragover","ondragstart","ondrop","onmouseenter","onmouseleave","onmousemove","onwheel","oncopy","oncut","onpaste","onabort","oncanplay","oncanplaythrough","oncuechange","ondurationchange","onemptied","onended","onloadeddata","onloadedmetadata","onloadstart","onpause","onplay","onplaying","onprogress","onratechange","onseeked","onseeking","onstalled","onsuspend","ontimeupdate","onvolumechange","onwaiting","ontoggle","onpointerdown","onpointerup","onpointermove","onpointerenter","onpointerleave","onpointercancel","ongotpointercapture","onlostpointercapture","ontouchstart","ontouchmove","ontouchend","ontouchcancel"];return i.querySelectorAll("*").forEach(a=>{s.forEach(d=>a.removeAttribute(d));const r=a.getAttribute("href");r&&r.toLowerCase().trim().startsWith("javascript:")&&a.removeAttribute("href");const o=a.getAttribute("src");o&&o.toLowerCase().trim().startsWith("javascript:")&&a.removeAttribute("src"),o&&o.toLowerCase().trim().startsWith("data:")&&a.tagName.toLowerCase()!=="img"&&a.removeAttribute("src");const l=a.getAttribute("style");if(l){const d=l.replace(/javascript:/gi,"").replace(/expression\s*\(/gi,"").replace(/url\s*\(\s*["']?\s*javascript:/gi,"url(");a.setAttribute("style",d)}}),i.body.innerHTML}function Ua(t){const e=t.trim();if(!e.toLowerCase().startsWith("<svg")||!e.toLowerCase().endsWith("</svg>"))return null;const n=new DOMParser().parseFromString(e,"image/svg+xml");if(n.querySelector("parsererror"))return null;const a=n.querySelector("svg");if(!a)return null;["script","foreignObject","iframe","object","embed","use"].forEach(d=>{a.querySelectorAll(d).forEach(p=>p.remove())});const o=["onload","onerror","onclick","onmouseover","onmouseout","onmousedown","onmouseup","onfocus","onblur","onkeydown","onkeyup","onkeypress","onsubmit","onreset","onchange","oninput","onscroll","onresize","onanimationstart","onanimationend","ontransitionend"];o.forEach(d=>a.removeAttribute(d));const l=a.getAttribute("href")??a.getAttribute("xlink:href");return l&&l.toLowerCase().startsWith("javascript:")&&(a.removeAttribute("href"),a.removeAttribute("xlink:href")),a.querySelectorAll("*").forEach(d=>{o.forEach(u=>d.removeAttribute(u));const p=d.getAttribute("href")??d.getAttribute("xlink:href");p&&p.toLowerCase().startsWith("javascript:")&&(d.removeAttribute("href"),d.removeAttribute("xlink:href"))}),a.outerHTML}class qa{constructor(e,i,n={}){h(this,"config");h(this,"container");h(this,"callbacks");h(this,"state");h(this,"itemClickElements",[]);this.container=e,this.config=i,this.callbacks=n,this.state=this.createInitialState()}render(){this.cleanup(),B(this.container),this.container.className="mokkun-timeline",this.container.setAttribute("role","list"),this.container.setAttribute("aria-label","タイムライン");const e=c("ol",{className:"timeline-list"});this.config.items.forEach((i,n)=>{const s=this.renderItem(i,n);e.appendChild(s)}),this.container.appendChild(e)}addItem(e){this.config={...this.config,items:[...this.config.items,e]},this.state=this.createInitialState(),this.render()}removeItem(e){e<0||e>=this.config.items.length||(this.config={...this.config,items:this.config.items.filter((i,n)=>n!==e)},this.state=this.createInitialState(),this.render())}updateItem(e,i){e<0||e>=this.config.items.length||(this.config={...this.config,items:this.config.items.map((n,s)=>s===e?{...n,...i}:n)},this.state=this.createInitialState(),this.render())}getState(){return{...this.state}}getItemCount(){return this.config.items.length}destroy(){this.cleanup(),B(this.container)}createInitialState(){const e=this.config.items.findIndex(i=>i.current);return{itemCount:this.config.items.length,currentIndex:e}}cleanup(){this.itemClickElements.forEach(({element:e,handler:i})=>{e.removeEventListener("click",i)}),this.itemClickElements=[]}renderItem(e,i){const n=i===0,s=i===this.config.items.length-1,a=e.current??!1,r=c("li",{className:["timeline-item",a?"is-current":"",n?"is-first":"",s?"is-last":""].filter(Boolean).join(" ")});r.setAttribute("role","listitem");const o=this.renderMarkerArea(e,s);r.appendChild(o);const l=this.renderContentArea(e,i);return r.appendChild(l),r}renderMarkerArea(e,i){const n=c("div",{className:"timeline-marker-area"}),s=c("span",{className:["timeline-icon",e.current?"is-current":""].filter(Boolean).join(" ")});s.setAttribute("aria-hidden","true"),e.iconColor&&(s.style.color=e.iconColor);const a=this.getIconHtml(e.icon);if(a&&(s.innerHTML=a),n.appendChild(s),!i){const r=c("span",{className:"timeline-line"});n.appendChild(r)}return n}renderContentArea(e,i){const n=c("div",{className:"timeline-content-area"}),s=this.renderHeader(e);if(n.appendChild(s),e.title){const r=c("div",{className:["timeline-title",e.current?"is-current":""].filter(Boolean).join(" "),textContent:e.title});n.appendChild(r)}const a=c("div",{className:"timeline-content"});if(a.innerHTML=Ge(e.content),n.appendChild(a),this.callbacks.onItemClick){n.classList.add("is-clickable");const r=o=>{var l,d;(d=(l=this.callbacks).onItemClick)==null||d.call(l,i,o)};this.itemClickElements.push({element:n,handler:r}),n.addEventListener("click",r)}return n}renderHeader(e){const i=c("div",{className:"timeline-header"}),n=c("div",{className:"timeline-date-area"}),s=Pa(e.datetime),a=e.dateLabel??Va(s),r=c("time",{className:["timeline-date",e.current?"is-current":""].filter(Boolean).join(" "),textContent:a});r.setAttribute("datetime",s.toISOString()),n.appendChild(r);const o=e.timeFormat??"HH:mm";if(o!=="none"){const l=ja(s,o);if(l){const d=c("span",{className:"timeline-time",textContent:l});n.appendChild(d)}}if(e.dateSuffixArea){const l=c("span",{className:"timeline-date-suffix"});l.innerHTML=Ge(e.dateSuffixArea),n.appendChild(l)}if(i.appendChild(n),e.sideActionArea){const l=c("div",{className:"timeline-side-action"});l.innerHTML=Ge(e.sideActionArea),i.appendChild(l)}return i}getIconHtml(e){if(!e)return Ye.dot;const i=Ye[e];return i||(Ua(e)??Ye.dot)}static renderField(e){return y(e,`
|
|
244
|
+
<div class="mokkun-timeline">
|
|
245
|
+
<div class="timeline-item">
|
|
246
|
+
<div class="timeline-marker"></div>
|
|
247
|
+
<div class="timeline-content">
|
|
248
|
+
<div class="timeline-time">10:30</div>
|
|
249
|
+
<div class="timeline-title">アクティビティ1</div>
|
|
250
|
+
</div>
|
|
251
|
+
</div>
|
|
252
|
+
<div class="timeline-item">
|
|
253
|
+
<div class="timeline-marker"></div>
|
|
254
|
+
<div class="timeline-content">
|
|
255
|
+
<div class="timeline-time">09:15</div>
|
|
256
|
+
<div class="timeline-title">アクティビティ2</div>
|
|
257
|
+
</div>
|
|
258
|
+
</div>
|
|
259
|
+
<div class="timeline-item">
|
|
260
|
+
<div class="timeline-marker"></div>
|
|
261
|
+
<div class="timeline-content">
|
|
262
|
+
<div class="timeline-time">08:00</div>
|
|
263
|
+
<div class="timeline-title">アクティビティ3</div>
|
|
264
|
+
</div>
|
|
265
|
+
</div>
|
|
266
|
+
</div>
|
|
267
|
+
`)}}class Wa{constructor(e,i,n={}){h(this,"config");h(this,"state");h(this,"callbacks");h(this,"container");this.container=e,this.config={size:"medium",color:"default",deletable:!1,selected:!1,disabled:!1,...i},this.callbacks=n,this.state=this.createInitialState()}createInitialState(){return{selected:this.config.selected??!1,disabled:this.config.disabled??!1}}render(){this.container.innerHTML="";const e=this.renderChip();this.container.appendChild(e)}renderChip(){const e=c("div",{className:`mokkun-chip chip-${this.config.size} chip-${this.config.color}`,attributes:{role:"button","aria-label":this.config.ariaLabel||this.config.label,"aria-pressed":String(this.state.selected),"aria-disabled":String(this.state.disabled),tabindex:this.state.disabled?"-1":"0","data-selected":String(this.state.selected),"data-disabled":String(this.state.disabled),"data-color":this.config.color||"default"}});this.state.disabled||(e.addEventListener("click",s=>{s.target.closest(".chip-delete-button")||this.handleChipClick()}),e.addEventListener("keydown",s=>{if(s.key==="Enter"||s.key===" "){if(s.preventDefault(),s.target.closest(".chip-delete-button"))return;this.handleChipClick()}}));const i=c("div",{className:"chip-content"});if(this.config.icon){const s=c("span",{className:"chip-icon",attributes:{"aria-hidden":"true"}});this.config.icon.startsWith("<")?s.innerHTML=this.config.icon:s.textContent=this.config.icon,i.appendChild(s)}const n=c("span",{className:"chip-label",textContent:this.config.label});if(i.appendChild(n),e.appendChild(i),this.config.deletable){const s=this.renderDeleteButton();e.appendChild(s)}return e}renderDeleteButton(){const e=c("button",{className:"chip-delete-button",attributes:{type:"button","aria-label":`Delete ${this.config.label}`,tabindex:this.state.disabled?"-1":"0"}}),i=c("span",{className:"chip-delete-icon",attributes:{"aria-hidden":"true"},textContent:"×"});return e.appendChild(i),this.state.disabled||(e.addEventListener("click",n=>{n.stopPropagation(),this.handleDelete()}),e.addEventListener("keydown",n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),n.stopPropagation(),this.handleDelete())})),e}handleChipClick(){if(this.state.disabled)return;const e=!this.state.selected;this.setState({selected:e}),this.callbacks.onClick&&this.callbacks.onClick(e,{...this.state})}handleDelete(){this.state.disabled||this.callbacks.onDelete&&this.callbacks.onDelete({...this.state})}setSelected(e){this.setState({selected:e})}setDisabled(e){this.setState({disabled:e})}setState(e){const i={...this.state,...e};JSON.stringify(i)!==JSON.stringify(this.state)&&(this.state=i,this.render())}getState(){return{...this.state}}updateConfig(e){this.config={...this.config,...e},this.render()}static renderField(e){const i=e,n=i.variant??"default",s=i.removable??!1,a=`
|
|
268
|
+
<span class="mokkun-chip chip-${n}">
|
|
269
|
+
<span class="chip-label">${m(e.label)}</span>
|
|
270
|
+
${s?'<button type="button" class="chip-remove" aria-label="削除">×</button>':""}
|
|
271
|
+
</span>
|
|
272
|
+
`;return y(e,a)}}const Ya={check:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M12.416 3.376a.75.75 0 0 1 .208 1.04l-5 7.5a.75.75 0 0 1-1.154.114l-3-3a.75.75 0 0 1 1.06-1.06l2.353 2.353 4.493-6.739a.75.75 0 0 1 1.04-.208Z" clip-rule="evenodd" /></svg>',warning:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M6.701 2.25c.577-1 2.02-1 2.598 0l5.196 9a1.5 1.5 0 0 1-1.299 2.25H2.804a1.5 1.5 0 0 1-1.3-2.25l5.197-9ZM8 4a.75.75 0 0 1 .75.75v3a.75.75 0 0 1-1.5 0v-3A.75.75 0 0 1 8 4Zm0 8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z" clip-rule="evenodd" /></svg>',error:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M8 15A7 7 0 1 0 8 1a7 7 0 0 0 0 14ZM8 4a.75.75 0 0 1 .75.75v3a.75.75 0 0 1-1.5 0v-3A.75.75 0 0 1 8 4Zm0 8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z" clip-rule="evenodd" /></svg>',info:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M15 8A7 7 0 1 1 1 8a7 7 0 0 1 14 0ZM9 5a1 1 0 1 1-2 0 1 1 0 0 1 2 0ZM6.75 8a.75.75 0 0 0 0 1.5h.75v1.75a.75.75 0 0 0 1.5 0v-2.5A.75.75 0 0 0 8.25 8h-1.5Z" clip-rule="evenodd" /></svg>',clock:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M1 8a7 7 0 1 1 14 0A7 7 0 0 1 1 8Zm7.75-4.25a.75.75 0 0 0-1.5 0V8c0 .414.336.75.75.75h3.25a.75.75 0 0 0 0-1.5h-2.5v-3.5Z" clip-rule="evenodd" /></svg>',circle:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><circle cx="8" cy="8" r="6" /></svg>',dot:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><circle cx="8" cy="8" r="4" /></svg>'};class Ga{constructor(e,i,n={}){h(this,"config");h(this,"state");h(this,"callbacks");h(this,"container");h(this,"clickHandler",null);this.config=i,this.container=e,this.callbacks=n,this.state=this.createInitialState()}render(){this.container.innerHTML="";const e=this.config.type??"grey",i=this.config.size??"medium",n=this.state.bold,s=this.config.clickable??!1;if(this.container.className=`mokkun-status-label status-label-${e} status-label-${i}`,n&&this.container.classList.add("status-label-bold"),s&&this.container.classList.add("status-label-clickable"),this.container.setAttribute("data-type",e),this.container.setAttribute("data-size",i),n?this.container.setAttribute("data-bold",""):this.container.removeAttribute("data-bold"),this.state.hidden){this.container.setAttribute("data-hidden",""),this.container.style.display="none";return}else this.container.removeAttribute("data-hidden"),this.container.style.display="";const a=this.renderLabel();this.container.appendChild(a),this.clickHandler&&(this.container.removeEventListener("click",this.clickHandler),this.clickHandler=null),s&&this.callbacks.onClick&&(this.clickHandler=this.handleClick.bind(this),this.container.addEventListener("click",this.clickHandler))}setText(e){this.state.text!==e&&(this.state={...this.state,text:e},this.render())}setBold(e){this.state.bold!==e&&(this.state={...this.state,bold:e},this.render())}setHidden(e){this.state.hidden!==e&&(this.state={...this.state,hidden:e},this.render())}getText(){return this.state.text}isBold(){return this.state.bold}getState(){return{...this.state}}destroy(){this.clickHandler&&(this.container.removeEventListener("click",this.clickHandler),this.clickHandler=null),this.container.innerHTML=""}createInitialState(){return{text:this.config.text,bold:this.config.bold??!1,hidden:!1}}renderLabel(){const e=c("span",{className:"status-label-content"});e.setAttribute("role","status");const i=this.getAriaLabel();i&&e.setAttribute("aria-label",i);const n=this.config.iconPosition??"left";if(this.config.icon&&n==="left"){const a=this.renderIcon();a&&e.appendChild(a)}const s=c("span",{className:"status-label-text",textContent:this.state.text});if(e.appendChild(s),this.config.icon&&n==="right"){const a=this.renderIcon();a&&e.appendChild(a)}return e}renderIcon(){if(!this.config.icon)return null;const e=c("span",{className:"status-label-icon",attributes:{"aria-hidden":"true"}}),i=Ya[this.config.icon];if(i)e.innerHTML=i;else{const n=this.sanitizeSvgIcon(this.config.icon);n&&(e.innerHTML=n)}return e}sanitizeSvgIcon(e){const i=e.trim();if(!i.toLowerCase().startsWith("<svg")||!i.toLowerCase().endsWith("</svg>"))return null;const s=new DOMParser().parseFromString(i,"image/svg+xml");if(s.querySelector("parsererror"))return null;const r=s.querySelector("svg");if(!r)return null;["script","foreignObject","iframe","object","embed","use"].forEach(p=>{r.querySelectorAll(p).forEach(u=>u.remove())});const l=["onload","onerror","onclick","onmouseover","onmouseout","onmousedown","onmouseup","onfocus","onblur","onkeydown","onkeyup","onkeypress","onsubmit","onreset","onchange","oninput","onscroll","onresize","onanimationstart","onanimationend","ontransitionend"];l.forEach(p=>r.removeAttribute(p));const d=r.getAttribute("href")??r.getAttribute("xlink:href");return d&&d.toLowerCase().startsWith("javascript:")&&(r.removeAttribute("href"),r.removeAttribute("xlink:href")),r.querySelectorAll("*").forEach(p=>{l.forEach(f=>p.removeAttribute(f));const u=p.getAttribute("href")??p.getAttribute("xlink:href");u&&u.toLowerCase().startsWith("javascript:")&&(p.removeAttribute("href"),p.removeAttribute("xlink:href"))}),r.outerHTML}getAriaLabel(){return this.config.label?this.config.label:this.state.text}handleClick(e){var i,n;(n=(i=this.callbacks).onClick)==null||n.call(i,e)}static renderField(e){const s=`
|
|
273
|
+
<span class="mokkun-status-label status-${e.variant??"default"}">
|
|
274
|
+
<span class="status-dot"></span>
|
|
275
|
+
<span class="status-text">${m(e.label)}</span>
|
|
276
|
+
</span>
|
|
277
|
+
`;return y(e,s)}}class Za{constructor(e,i,n={}){h(this,"config");h(this,"state");h(this,"callbacks");h(this,"container");h(this,"optionElements",[]);this.config=i,this.container=e,this.callbacks=n,this.state=this.createInitialState()}render(){this.container.innerHTML="",this.optionElements=[];const e=this.config.size??"default";if(this.container.className=`mokkun-segmented-control segmented-${e==="s"?"small":"medium"}`,this.config.fullWidth&&this.container.classList.add("segmented-full-width"),this.container.setAttribute("role","group"),this.state.disabled?this.container.setAttribute("data-disabled",""):this.container.removeAttribute("data-disabled"),this.config.width){const n=typeof this.config.width=="number"?`${this.config.width}px`:this.config.width;this.container.style.width=n}else this.config.fullWidth?this.container.style.width="100%":this.container.style.width="";const i=c("div",{className:"segmented-options"});this.config.options.forEach((n,s)=>{const a=this.renderOption(n,s);this.optionElements.push(a),i.appendChild(a)}),this.container.appendChild(i)}setValue(e){if(this.state.disabled)return;const i=this.config.options.find(n=>n.value===e);!i||i.disabled||this.state.selectedValue!==e&&(this.state={...this.state,selectedValue:e},this.render())}setDisabled(e){this.state.disabled!==e&&(this.state={...this.state,disabled:e},this.render())}getState(){return{...this.state}}getValue(){return this.state.selectedValue}isDisabled(){return this.state.disabled}createInitialState(){var i,n;const e=this.config.value??((i=this.config.options.find(s=>!s.disabled))==null?void 0:i.value)??((n=this.config.options[0])==null?void 0:n.value)??"";return{selectedValue:e,disabled:this.config.disabled??!1,focusedIndex:this.config.options.findIndex(s=>s.value===e)}}renderOption(e,i){const n=this.state.selectedValue===e.value,s=this.state.disabled||e.disabled||!1,a=n||this.state.focusedIndex===-1&&i===0||this.state.focusedIndex===i,r=c("button",{className:"segmented-button",attributes:{type:"button","aria-pressed":String(n),"aria-disabled":String(s),tabindex:a&&!s?"0":"-1","data-value":e.value}});if(n&&r.classList.add("selected"),s&&(r.classList.add("disabled"),r.setAttribute("disabled","disabled")),e.icon){const l=c("span",{className:"segmented-icon"});l.innerHTML=e.icon,r.appendChild(l)}const o=c("span",{className:"segmented-label",textContent:e.label});return r.appendChild(o),s||(r.addEventListener("click",l=>{l.preventDefault(),this.handleOptionClick(e.value)}),r.addEventListener("keydown",l=>{this.handleKeyboardNavigation(l)})),r}handleOptionClick(e){var s,a,r,o;if(this.state.disabled)return;const i=this.config.options.find(l=>l.value===e);if(!i||i.disabled||this.state.selectedValue===e)return;const n=this.config.options.findIndex(l=>l.value===e);this.state={...this.state,selectedValue:e,focusedIndex:n},this.render(),this.optionElements[n]&&this.optionElements[n].focus(),(a=(s=this.callbacks).onChange)==null||a.call(s,e,this.state),(o=(r=this.callbacks).onClickOption)==null||o.call(r,e)}handleKeyboardNavigation(e){switch(e.key){case"ArrowRight":case"ArrowDown":e.preventDefault(),this.focusNextOption();break;case"ArrowLeft":case"ArrowUp":e.preventDefault(),this.focusPreviousOption();break;case"Home":e.preventDefault(),this.focusFirstOption();break;case"End":e.preventDefault(),this.focusLastOption();break;case" ":case"Enter":e.preventDefault();const n=e.currentTarget.getAttribute("data-value");n&&this.handleOptionClick(n);break}}focusNextOption(){let e=this.state.focusedIndex+1;for(;e<this.config.options.length;){if(!this.config.options[e].disabled){this.focusOption(e);return}e++}this.focusFirstOption()}focusPreviousOption(){let e=this.state.focusedIndex-1;for(;e>=0;){if(!this.config.options[e].disabled){this.focusOption(e);return}e--}this.focusLastOption()}focusFirstOption(){for(let e=0;e<this.config.options.length;e++)if(!this.config.options[e].disabled){this.focusOption(e);return}}focusLastOption(){for(let e=this.config.options.length-1;e>=0;e--)if(!this.config.options[e].disabled){this.focusOption(e);return}}focusOption(e){e<0||e>=this.config.options.length||this.config.options[e].disabled||(this.state={...this.state,focusedIndex:e},this.optionElements[e]&&(this.optionElements.forEach((n,s)=>{n.setAttribute("tabindex",s===e?"0":"-1")}),this.optionElements[e].focus()))}static renderField(e){var r;const i=e,n=i.options??[],s=i.default??((r=n[0])==null?void 0:r.value),a=`
|
|
278
|
+
<div class="mokkun-segmented-control" role="radiogroup" aria-label="${m(e.label)}">
|
|
279
|
+
${n.map(o=>`
|
|
280
|
+
<button type="button" class="segment-button ${o.value===s?"active":""}"
|
|
281
|
+
role="radio" aria-checked="${o.value===s}"
|
|
282
|
+
data-value="${m(o.value)}">
|
|
283
|
+
${m(o.label)}
|
|
284
|
+
</button>
|
|
285
|
+
`).join("")}
|
|
286
|
+
</div>
|
|
287
|
+
`;return y(e,a)}}class Ka{constructor(e,i,n={}){h(this,"config");h(this,"state");h(this,"callbacks");h(this,"container");h(this,"instanceId");h(this,"hashChangeHandler",null);h(this,"lazyLoadCache",new Map);h(this,"loadingTabs",new Set);this.config=e,this.container=i,this.callbacks=n,this.instanceId=E("tabs"),this.state=this.createInitialState()}render(){B(this.container);const e=this.config.position??"top",i=this.config.variant??"default",n=this.config.bordered??!1,s=this.config.scrollable??!1,a=["mokkun-tabs",`tabs-${e}`,`tabs-${i}`,n?"tabs-bordered":"",s?"tabs-scrollable":""].filter(Boolean).join(" ");this.container.className=a;const r=c("div",{className:"tabs-wrapper"});(e==="left"||e==="right")&&(r.style.display="flex",r.style.flexDirection=e==="left"?"row":"row-reverse");const o=this.renderTabList();r.appendChild(o);const l=this.renderPanels();r.appendChild(l),this.container.appendChild(r),this.config.syncWithHash&&!this.hashChangeHandler&&this.setupHashSync(),this.loadLazyContent(this.state.activeTabId)}setActiveTab(e){var n,s;const i=this.state.tabs.find(a=>a.id===e);return!i||i.disabled?!1:(this.state.activeTabId===e||(this.state={...this.state,activeTabId:e},this.render(),(s=(n=this.callbacks).onTabChange)==null||s.call(n,e,this.state),this.config.syncWithHash&&this.updateHash(e)),!0)}nextTab(){const e=this.state.tabs.findIndex(i=>i.id===this.state.activeTabId);for(let i=e+1;i<this.state.tabs.length;i++){const n=this.state.tabs[i];if(!n.disabled)return this.setActiveTab(n.id)}for(let i=0;i<e;i++){const n=this.state.tabs[i];if(!n.disabled)return this.setActiveTab(n.id)}return!1}previousTab(){const e=this.state.tabs.findIndex(i=>i.id===this.state.activeTabId);for(let i=e-1;i>=0;i--){const n=this.state.tabs[i];if(!n.disabled)return this.setActiveTab(n.id)}for(let i=this.state.tabs.length-1;i>e;i--){const n=this.state.tabs[i];if(!n.disabled)return this.setActiveTab(n.id)}return!1}getState(){return{...this.state,tabs:this.state.tabs.map(e=>({...e}))}}getActiveTab(){return this.state.tabs.find(e=>e.id===this.state.activeTabId)}addTab(e,i){const n=[...this.state.tabs];i!==void 0&&i>=0&&i<=n.length?n.splice(i,0,e):n.push(e),this.state={...this.state,tabs:n},this.render()}removeTab(e){if(this.state.tabs.findIndex(a=>a.id===e)===-1)return!1;const n=this.state.tabs.filter(a=>a.id!==e);let s=this.state.activeTabId;if(this.state.activeTabId===e&&n.length>0){const a=n.find(r=>!r.disabled);s=(a==null?void 0:a.id)??n[0].id}return this.state={...this.state,tabs:n,activeTabId:s},this.render(),!0}updateTab(e,i){return this.state.tabs.findIndex(s=>s.id===e)===-1?!1:(this.state={...this.state,tabs:this.state.tabs.map(s=>s.id===e?{...s,...i}:s)},this.render(),!0)}createInitialState(){var n,s;let e;return this.config.syncWithHash&&(e=this.getTabIdFromHash()),{activeTabId:e??this.config.defaultActiveTab??((n=this.config.tabs.find(a=>!a.disabled))==null?void 0:n.id)??((s=this.config.tabs[0])==null?void 0:s.id)??"",tabs:[...this.config.tabs]}}renderTabList(){const e=c("div",{className:"tabs-list",attributes:{role:"tablist"}});for(const i of this.state.tabs){const n=this.renderTabButton(i);e.appendChild(n)}return e.addEventListener("keydown",i=>this.handleKeyDown(i)),e}renderTabButton(e){const i=e.id===this.state.activeTabId,n=["tab-button",i?"active":"",e.disabled?"disabled":""].filter(Boolean).join(" "),s=c("button",{className:n,attributes:{type:"button",role:"tab","aria-selected":String(i),"aria-controls":`${this.instanceId}-panel-${e.id}`,id:`${this.instanceId}-tab-${e.id}`,tabindex:i?"0":"-1"}});if(e.disabled&&s.setAttribute("aria-disabled","true"),e.icon){const r=c("span",{className:"tab-icon",attributes:e.iconLabel?{"aria-label":e.iconLabel,role:"img"}:{}});r.innerHTML=e.icon,s.appendChild(r)}const a=c("span",{className:"tab-label",textContent:e.label});if(s.appendChild(a),e.badge!==void 0){const r=c("span",{className:"tab-badge",textContent:String(e.badge)});s.appendChild(r)}return e.disabled||s.addEventListener("click",()=>this.setActiveTab(e.id)),s}renderPanels(){const e=c("div",{className:"tabs-panels"});for(const i of this.state.tabs){const n=this.renderPanel(i);e.appendChild(n)}return e}renderPanel(e){const i=e.id===this.state.activeTabId,n=c("div",{className:`tab-panel ${i?"active":""}`,attributes:{role:"tabpanel",id:`${this.instanceId}-panel-${e.id}`,"aria-labelledby":`${this.instanceId}-tab-${e.id}`,hidden:i?"":"true"}});if(i&&n.removeAttribute("hidden"),e.fields&&this.callbacks.renderFields)this.callbacks.renderFields(e.fields,n);else if(e.content)n.innerHTML=e.content;else if(e.fields)for(const s of e.fields){const a=c("div",{className:"field-placeholder",textContent:`[${s.type}] ${s.label}`});n.appendChild(a)}return n}handleKeyDown(e){const i=this.config.position??"top",n=i==="left"||i==="right";switch(e.key){case"ArrowLeft":n||(e.preventDefault(),this.previousTab());break;case"ArrowRight":n||(e.preventDefault(),this.nextTab());break;case"ArrowUp":n&&(e.preventDefault(),this.previousTab());break;case"ArrowDown":n&&(e.preventDefault(),this.nextTab());break;case"Home":e.preventDefault();const s=this.state.tabs.find(r=>!r.disabled);s&&this.setActiveTab(s.id);break;case"End":e.preventDefault();const a=[...this.state.tabs].reverse().find(r=>!r.disabled);a&&this.setActiveTab(a.id);break}}setupHashSync(){this.hashChangeHandler=()=>{var i,n;const e=this.getTabIdFromHash();if(e&&e!==this.state.activeTabId){const s=this.state.tabs.find(a=>a.id===e);s&&!s.disabled&&(this.state={...this.state,activeTabId:e},this.render(),(n=(i=this.callbacks).onTabChange)==null||n.call(i,e,this.state))}},window.addEventListener("hashchange",this.hashChangeHandler)}getTabIdFromHash(){const e=window.location.hash.slice(1);if(!e)return;const i=this.config.hashPrefix??"";if(i&&e.startsWith(i)){const s=e.slice(i.length),a=this.state.tabs.find(r=>r.id===s);return a&&!a.disabled?s:void 0}const n=this.config.tabs.find(s=>s.id===e);return n&&!n.disabled?e:void 0}updateHash(e){const i=this.config.hashPrefix??"";window.location.hash=`${i}${e}`}loadLazyContent(e){const i=this.state.tabs.find(s=>s.id===e);if(!(i!=null&&i.lazyLoad)||this.lazyLoadCache.has(e)||this.loadingTabs.has(e))return;this.loadingTabs.add(e);const n=this.container.querySelector(`#${this.instanceId}-panel-${e}`);if(n){const s=c("div",{className:"tab-loading",textContent:"読み込み中..."});B(n),n.appendChild(s)}i.lazyLoad(e).then(s=>{this.lazyLoadCache.set(e,s),this.loadingTabs.delete(e);const a=this.container.querySelector(`#${this.instanceId}-panel-${e}`);a&&(a.innerHTML=s)}).catch(s=>{this.loadingTabs.delete(e);const a=this.container.querySelector(`#${this.instanceId}-panel-${e}`);if(a){const r=c("div",{className:"tab-error",textContent:`読み込みに失敗しました: ${s.message}`});B(a),a.appendChild(r)}})}destroy(){this.hashChangeHandler&&(window.removeEventListener("hashchange",this.hashChangeHandler),this.hashChangeHandler=null),this.lazyLoadCache.clear(),this.loadingTabs.clear(),B(this.container)}async refreshTabContent(e){const i=this.state.tabs.find(n=>n.id===e);i!=null&&i.lazyLoad&&(this.lazyLoadCache.delete(e),this.loadLazyContent(e))}static renderField(e){return y(e,`
|
|
288
|
+
<div class="mokkun-tabs">
|
|
289
|
+
<div class="tabs-list" role="tablist">
|
|
290
|
+
<button type="button" class="tab-button active" role="tab" aria-selected="true">タブ1</button>
|
|
291
|
+
<button type="button" class="tab-button" role="tab" aria-selected="false">タブ2</button>
|
|
292
|
+
<button type="button" class="tab-button" role="tab" aria-selected="false">タブ3</button>
|
|
293
|
+
</div>
|
|
294
|
+
<div class="tab-panel" role="tabpanel">
|
|
295
|
+
<p>タブコンテンツがここに表示されます</p>
|
|
296
|
+
</div>
|
|
297
|
+
</div>
|
|
298
|
+
`)}}function xi(t){const e=["strong","em","b","i","u","a","br","span","p"],i={a:["href","target","rel"],span:["class"]},s=new DOMParser().parseFromString(t,"text/html");function a(l){if(l.nodeType===Node.TEXT_NODE)return l.cloneNode();if(l.nodeType!==Node.ELEMENT_NODE)return null;const d=l,p=d.tagName.toLowerCase();if(!e.includes(p)){const g=document.createDocumentFragment();for(const x of Array.from(d.childNodes)){const C=a(x);C&&g.appendChild(C)}return g}const u=document.createElement(p),f=i[p]??[];for(const g of f){const x=d.getAttribute(g);if(x!==null){if(g==="href"&&x.toLowerCase().startsWith("javascript:"))continue;u.setAttribute(g,x)}}p==="a"&&u.getAttribute("target")==="_blank"&&u.setAttribute("rel","noopener noreferrer");for(const g of Array.from(d.childNodes)){const x=a(g);x&&u.appendChild(x)}return u}const r=document.createDocumentFragment();for(const l of Array.from(s.body.childNodes)){const d=a(l);d&&r.appendChild(d)}const o=document.createElement("div");return o.appendChild(r),o.innerHTML}function Ze(t){return Number.isInteger(t)&&t>=1&&t<=6}class Qa{constructor(e,i,n={}){h(this,"config");h(this,"state");h(this,"callbacks");h(this,"container");h(this,"element",null);h(this,"textElement",null);h(this,"buttonContainer",null);h(this,"expandButton",null);h(this,"collapseButton",null);h(this,"instanceId");h(this,"tooltip",null);h(this,"resizeObserver",null);h(this,"resizeDebounceTimeout",null);h(this,"handleExpand",()=>this.expand());h(this,"handleCollapse",()=>this.collapse());Ze(e.maxLines)||console.warn(`[LineClamp] Invalid maxLines value: ${e.maxLines}. Using default value 2.`),this.config={text:e.text,maxLines:Ze(e.maxLines)?e.maxLines:2,isHtml:e.isHtml??!1,showExpandButton:e.showExpandButton??!1,expandButtonLabel:e.expandButtonLabel??"もっと見る",collapseButtonLabel:e.collapseButtonLabel??"折りたたむ",showTooltip:e.showTooltip??!0,tooltipPosition:e.tooltipPosition??"top",tooltipDelay:e.tooltipDelay??300},this.container=i,this.callbacks=n,this.instanceId=E("line-clamp"),this.state={text:this.config.text,maxLines:this.config.maxLines,expanded:!1,clamped:!1,showExpandButton:this.config.showExpandButton,showTooltip:this.config.showTooltip,tooltipPosition:this.config.tooltipPosition},this.render(),this.setupResizeObserver()}expand(){var e,i,n,s,a,r;this.state.expanded||(this.state={...this.state,expanded:!0},(e=this.element)==null||e.classList.add("expanded"),(i=this.element)==null||i.setAttribute("aria-expanded","true"),this.updateTextStyles(),this.updateExpandButton(),(s=(n=this.callbacks).onExpand)==null||s.call(n),(r=(a=this.callbacks).onToggle)==null||r.call(a,!0))}collapse(){var e,i,n,s,a,r;this.state.expanded&&(this.state={...this.state,expanded:!1},(e=this.element)==null||e.classList.remove("expanded"),(i=this.element)==null||i.setAttribute("aria-expanded","false"),this.updateTextStyles(),this.updateExpandButton(),(s=(n=this.callbacks).onCollapse)==null||s.call(n),(r=(a=this.callbacks).onToggle)==null||r.call(a,!1))}toggle(){this.state.expanded?this.collapse():this.expand()}isExpanded(){return this.state.expanded}setText(e){this.config={...this.config,text:e},this.state={...this.state,text:e},this.updateTextContent(),this.updateClampedState(),this.initializeTooltip()}setMaxLines(e){if(!Ze(e)){console.warn(`[LineClamp] Invalid maxLines value: ${e}. Value must be between 1 and 6.`);return}this.config={...this.config,maxLines:e},this.state={...this.state,maxLines:e},this.updateTextStyles(),this.updateClampedState(),this.initializeTooltip()}getState(){return{...this.state}}setClampedForTesting(e){var i,n;this.state={...this.state,clamped:e},e?(i=this.element)==null||i.classList.add("clamped"):(n=this.element)==null||n.classList.remove("clamped"),this.updateExpandButton(),this.initializeTooltip()}destroy(){this.resizeDebounceTimeout!==null&&(clearTimeout(this.resizeDebounceTimeout),this.resizeDebounceTimeout=null),this.tooltip&&(this.tooltip.destroy(),this.tooltip=null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.cleanupButtonListeners(),this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.element=null,this.textElement=null,this.buttonContainer=null}render(){this.element=c("div",{className:"mokkun-line-clamp",attributes:{id:this.instanceId,"aria-expanded":"false"}}),this.textElement=c("span",{className:"line-clamp-text",attributes:{id:`${this.instanceId}-text`}}),this.updateTextContent(),this.updateTextStyles(),this.element.appendChild(this.textElement),this.buttonContainer=c("div",{className:"line-clamp-button-container"}),this.element.appendChild(this.buttonContainer),this.container.appendChild(this.element),requestAnimationFrame(()=>{this.updateClampedState(),this.updateExpandButton(),this.initializeTooltip()})}updateTextContent(){this.textElement&&(this.config.isHtml?this.textElement.innerHTML=xi(this.config.text):this.textElement.textContent=this.config.text)}updateTextStyles(){this.textElement&&(this.state.expanded?(this.textElement.style.removeProperty("-webkit-line-clamp"),this.textElement.style.removeProperty("display"),this.textElement.style.removeProperty("-webkit-box-orient"),this.textElement.style.removeProperty("overflow")):(this.textElement.style.setProperty("-webkit-line-clamp",String(this.state.maxLines)),this.textElement.style.setProperty("display","-webkit-box"),this.textElement.style.setProperty("-webkit-box-orient","vertical"),this.textElement.style.setProperty("overflow","hidden")))}updateClampedState(){var i,n;const e=this.checkIfClamped();this.state={...this.state,clamped:e},e?(i=this.element)==null||i.classList.add("clamped"):(n=this.element)==null||n.classList.remove("clamped")}checkIfClamped(){return!this.textElement||this.state.expanded?!1:this.textElement.scrollHeight>this.textElement.clientHeight}cleanupButtonListeners(){this.expandButton&&(this.expandButton.removeEventListener("click",this.handleExpand),this.expandButton=null),this.collapseButton&&(this.collapseButton.removeEventListener("click",this.handleCollapse),this.collapseButton=null)}updateExpandButton(){!this.buttonContainer||!this.config.showExpandButton||(this.cleanupButtonListeners(),this.buttonContainer.innerHTML="",!(!this.state.clamped&&!this.state.expanded)&&(this.state.expanded?(this.collapseButton=c("button",{className:"line-clamp-collapse-button",textContent:this.config.collapseButtonLabel,attributes:{type:"button","aria-controls":`${this.instanceId}-text`,"aria-expanded":"true"}}),this.collapseButton.addEventListener("click",this.handleCollapse),this.buttonContainer.appendChild(this.collapseButton)):(this.expandButton=c("button",{className:"line-clamp-expand-button",textContent:this.config.expandButtonLabel,attributes:{type:"button","aria-controls":`${this.instanceId}-text`,"aria-expanded":"false"}}),this.expandButton.addEventListener("click",this.handleExpand),this.buttonContainer.appendChild(this.expandButton))))}initializeTooltip(){this.tooltip&&(this.tooltip.destroy(),this.tooltip=null),!(!this.config.showTooltip||!this.element)&&this.state.clamped&&(this.tooltip=new mi(this.element,{content:this.config.isHtml?xi(this.config.text):va(this.config.text),isHtml:this.config.isHtml,position:this.config.tooltipPosition,delay:this.config.tooltipDelay,maxWidth:"400px",markTrigger:!1}))}setupResizeObserver(){!this.textElement||typeof ResizeObserver>"u"||(this.resizeObserver=new ResizeObserver(()=>{this.resizeDebounceTimeout!==null&&clearTimeout(this.resizeDebounceTimeout),this.resizeDebounceTimeout=window.setTimeout(()=>{this.updateClampedState(),this.updateExpandButton(),this.initializeTooltip()},100)}),this.resizeObserver.observe(this.textElement))}static renderField(e){const s=`
|
|
299
|
+
<div class="mokkun-line-clamp" style="-webkit-line-clamp: ${e.lines??3}; display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden;">
|
|
300
|
+
${m(e.description??"テキストコンテンツがここに表示されます。長いテキストは指定行数で切り詰められます。")}
|
|
301
|
+
</div>
|
|
302
|
+
`;return y(e,s)}}class Ja{constructor(e,i,n={}){h(this,"config");h(this,"state");h(this,"callbacks");h(this,"container");h(this,"instanceId");h(this,"triggerElement",null);h(this,"contentWrapper",null);h(this,"contentElement",null);this.config=i,this.container=e,this.callbacks=n,this.instanceId=i.id??E("disclosure"),this.state={isOpen:i.defaultOpen??!1}}render(){this.container.innerHTML="",this.container.className=["mokkun-disclosure",this.state.isOpen?"is-open":"",this.config.className??""].filter(Boolean).join(" "),this.container.id=this.instanceId,this.triggerElement=this.renderTrigger(),this.container.appendChild(this.triggerElement),this.contentWrapper=this.renderContent(),this.container.appendChild(this.contentWrapper)}open(){var e,i,n,s;this.state.isOpen||(this.state={...this.state,isOpen:!0},this.updateUI(),(i=(e=this.callbacks).onOpen)==null||i.call(e),(s=(n=this.callbacks).onChange)==null||s.call(n,!0))}close(){var e,i,n,s;this.state.isOpen&&(this.state={...this.state,isOpen:!1},this.updateUI(),(i=(e=this.callbacks).onClose)==null||i.call(e),(s=(n=this.callbacks).onChange)==null||s.call(n,!1))}toggle(){this.state.isOpen?this.close():this.open()}isOpen(){return this.state.isOpen}getState(){return{...this.state}}setContent(e){this.config={...this.config,content:e},this.contentElement&&(this.contentElement.innerHTML="",typeof e=="string"?this.contentElement.innerHTML=e:this.contentElement.appendChild(e))}setTriggerLabel(e,i){if(this.config={...this.config,triggerLabel:e,triggerLabelOpen:i},this.triggerElement){const n=this.triggerElement.querySelector(".disclosure-trigger-label");n&&(n.textContent=this.getCurrentLabel())}}destroy(){this.container.innerHTML="",this.triggerElement=null,this.contentWrapper=null,this.contentElement=null}renderTrigger(){const e=`${this.instanceId}-trigger`,i=`${this.instanceId}-content`,n=document.createElement("button");n.type="button",n.className="disclosure-trigger",n.id=e,n.setAttribute("aria-expanded",String(this.state.isOpen)),n.setAttribute("aria-controls",i);const s=this.renderIcon();n.appendChild(s);const a=c("span",{className:"disclosure-trigger-label",textContent:this.getCurrentLabel()});return n.appendChild(a),n.addEventListener("click",()=>{this.toggle()}),n.addEventListener("keydown",r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),this.toggle())}),n}renderIcon(){const e=c("span",{className:`disclosure-icon${this.state.isOpen?" is-open":""}`,attributes:{"aria-hidden":"true"}}),i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("width","16"),i.setAttribute("height","16"),i.setAttribute("viewBox","0 0 16 16"),i.setAttribute("fill","currentColor");const n=document.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("d","M6 3l5 5-5 5V3z"),i.appendChild(n),e.appendChild(i),e}renderContent(){const e=`${this.instanceId}-content`,i=`${this.instanceId}-trigger`,n=c("div",{className:`disclosure-content-wrapper${this.state.isOpen?" is-open":""}`});return this.contentElement=c("div",{className:"disclosure-content",attributes:{id:e,role:"region","aria-labelledby":i}}),this.state.isOpen||(this.config.visuallyHidden?this.contentElement.setAttribute("aria-hidden","true"):this.contentElement.setAttribute("hidden","")),typeof this.config.content=="string"?this.contentElement.innerHTML=this.config.content:this.contentElement.appendChild(this.config.content),n.appendChild(this.contentElement),n}updateUI(){if(this.state.isOpen?this.container.classList.add("is-open"):this.container.classList.remove("is-open"),this.triggerElement){this.triggerElement.setAttribute("aria-expanded",String(this.state.isOpen));const e=this.triggerElement.querySelector(".disclosure-trigger-label");e&&(e.textContent=this.getCurrentLabel());const i=this.triggerElement.querySelector(".disclosure-icon");i&&(this.state.isOpen?i.classList.add("is-open"):i.classList.remove("is-open"))}this.contentWrapper&&(this.state.isOpen?this.contentWrapper.classList.add("is-open"):this.contentWrapper.classList.remove("is-open")),this.contentElement&&(this.state.isOpen?(this.contentElement.removeAttribute("hidden"),this.contentElement.removeAttribute("aria-hidden")):this.config.visuallyHidden?this.contentElement.setAttribute("aria-hidden","true"):setTimeout(()=>{!this.state.isOpen&&this.contentElement&&this.contentElement.setAttribute("hidden","")},200))}getCurrentLabel(){return this.state.isOpen&&this.config.triggerLabelOpen?this.config.triggerLabelOpen:this.config.triggerLabel}static renderField(e){const i=`
|
|
303
|
+
<details class="mokkun-disclosure">
|
|
304
|
+
<summary class="disclosure-trigger">${m(e.label)}</summary>
|
|
305
|
+
<div class="disclosure-content">
|
|
306
|
+
<p>${m(e.description??"詳細コンテンツがここに表示されます")}</p>
|
|
307
|
+
</div>
|
|
308
|
+
</details>
|
|
309
|
+
`;return y(e,i)}}class Xa{constructor(e,i,n={}){h(this,"config");h(this,"state");h(this,"callbacks");h(this,"container");h(this,"instanceId");h(this,"itemElements",new Map);this.config=i,this.container=e,this.callbacks=n,this.instanceId=i.id??E("accordion"),this.state=this.createInitialState()}render(){this.container.innerHTML="",this.itemElements.clear();const e=this.config.iconPosition??"left",i=this.config.headingType??"blockTitle";this.container.className=["mokkun-accordion-panel",`accordion-icon-${e}`,`accordion-heading-${i}`,this.config.className??""].filter(Boolean).join(" "),this.container.setAttribute("role","region"),this.container.id=this.instanceId,this.config.items.forEach((n,s)=>{const a=this.renderItem(n,s);this.container.appendChild(a)}),this.attachKeyboardEvents()}expand(e){var a,r,o,l;const i=this.config.items.find(d=>d.name===e);if(!i||i.disabled||this.state.expandedItems.includes(e))return;const n=this.config.expandableMultiply??!0,s=[...this.state.expandedItems];n?this.state={...this.state,expandedItems:[...this.state.expandedItems,e]}:(this.state={...this.state,expandedItems:[e]},s.forEach(d=>{var p,u;d!==e&&(this.updateItemState(d,!1),(u=(p=this.callbacks).onCollapse)==null||u.call(p,d))})),this.updateItemState(e,!0),(r=(a=this.callbacks).onExpand)==null||r.call(a,e),(l=(o=this.callbacks).onChange)==null||l.call(o,this.state.expandedItems)}collapse(e){var i,n,s,a;this.state.expandedItems.includes(e)&&(this.state={...this.state,expandedItems:this.state.expandedItems.filter(r=>r!==e)},this.updateItemState(e,!1),(n=(i=this.callbacks).onCollapse)==null||n.call(i,e),(a=(s=this.callbacks).onChange)==null||a.call(s,this.state.expandedItems))}toggle(e){this.state.expandedItems.includes(e)?this.collapse(e):this.expand(e)}expandAll(){var i,n;if(!(this.config.expandableMultiply??!0))return;const e=this.config.items.filter(s=>!s.disabled).map(s=>s.name);this.state={...this.state,expandedItems:e},e.forEach(s=>{this.updateItemState(s,!0)}),(n=(i=this.callbacks).onChange)==null||n.call(i,this.state.expandedItems)}collapseAll(){var i,n;const e=[...this.state.expandedItems];this.state={...this.state,expandedItems:[]},e.forEach(s=>{this.updateItemState(s,!1)}),(n=(i=this.callbacks).onChange)==null||n.call(i,this.state.expandedItems)}isExpanded(e){return this.state.expandedItems.includes(e)}getState(){return{...this.state}}setItems(e){this.config={...this.config,items:e};const i=e.map(n=>n.name);this.state={...this.state,expandedItems:this.state.expandedItems.filter(n=>i.includes(n)),focusedIndex:Math.min(this.state.focusedIndex,e.length-1)},this.render()}destroy(){this.container.innerHTML="",this.itemElements.clear()}createInitialState(){const e=this.config.defaultExpanded??[];return{expandedItems:this.config.expandableMultiply??!0?e.filter(s=>{const a=this.config.items.find(r=>r.name===s);return a&&!a.disabled}):e.slice(0,1).filter(s=>{const a=this.config.items.find(r=>r.name===s);return a&&!a.disabled}),focusedIndex:-1}}renderItem(e,i){const n=this.state.expandedItems.includes(e.name),s=`${this.instanceId}-trigger-${e.name}`,a=`${this.instanceId}-content-${e.name}`,r=c("div",{className:`accordion-item${e.disabled?" is-disabled":""}${n?" is-expanded":""}`,attributes:{"data-name":e.name,"data-index":String(i)}}),o=this.renderTrigger(e,n,s,a);r.appendChild(o);const l=this.renderContent(e,n,a,s);return r.appendChild(l),this.itemElements.set(e.name,{trigger:o,content:l}),r}renderTrigger(e,i,n,s){const a=this.config.iconPosition??"left",r=c("button",{className:"accordion-trigger",attributes:{type:"button",id:n,"aria-expanded":String(i),"aria-controls":s,"aria-disabled":e.disabled?"true":"false",tabindex:e.disabled?"-1":"0"}});if(a==="left"){const l=this.renderIcon(i,a);r.appendChild(l)}if(e.icon){const l=c("span",{className:"accordion-trigger-title-icon"});l.innerHTML=e.icon,r.appendChild(l)}const o=c("span",{className:"accordion-trigger-title",textContent:e.title});if(r.appendChild(o),a==="right"){const l=this.renderIcon(i,a);r.appendChild(l)}return e.disabled||r.addEventListener("click",()=>{this.toggle(e.name)}),r}renderIcon(e,i){const n=c("span",{className:`accordion-icon accordion-icon-${i}${e?" is-expanded":""}`,attributes:{"aria-hidden":"true"}}),s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("width","16"),s.setAttribute("height","16"),s.setAttribute("viewBox","0 0 16 16"),s.setAttribute("fill","currentColor");const a=document.createElementNS("http://www.w3.org/2000/svg","path");return i==="left"?a.setAttribute("d","M6 3l5 5-5 5V3z"):a.setAttribute("d","M3 6l5 5 5-5H3z"),s.appendChild(a),n.appendChild(s),n}renderContent(e,i,n,s){const a=c("div",{className:`accordion-content-wrapper${i?" is-expanded":""}`}),r=c("div",{className:"accordion-content",attributes:{id:n,role:"region","aria-labelledby":s}});return i||r.setAttribute("hidden",""),typeof e.content=="string"?r.innerHTML=e.content:r.appendChild(e.content),a.appendChild(r),a}updateItemState(e,i){const n=this.itemElements.get(e);if(!n)return;const{trigger:s,content:a}=n,r=s.parentElement;s.setAttribute("aria-expanded",String(i));const o=s.querySelector(".accordion-icon");o&&(i?o.classList.add("is-expanded"):o.classList.remove("is-expanded")),i?(r==null||r.classList.add("is-expanded"),a.classList.add("is-expanded")):(r==null||r.classList.remove("is-expanded"),a.classList.remove("is-expanded"));const l=a.querySelector(".accordion-content");l&&(i?l.removeAttribute("hidden"):setTimeout(()=>{this.state.expandedItems.includes(e)||l.setAttribute("hidden","")},200))}attachKeyboardEvents(){this.container.addEventListener("keydown",e=>{var s;const i=e.target;if(!i.classList.contains("accordion-trigger"))return;const n=parseInt(((s=i.closest(".accordion-item"))==null?void 0:s.getAttribute("data-index"))??"-1",10);switch(e.key){case"ArrowDown":e.preventDefault(),this.focusNextItem(n);break;case"ArrowUp":e.preventDefault(),this.focusPreviousItem(n);break;case"Home":e.preventDefault(),this.focusFirstItem();break;case"End":e.preventDefault(),this.focusLastItem();break}})}focusNextItem(e){const i=this.config.items.map((r,o)=>({item:r,index:o})).filter(({item:r})=>!r.disabled),s=(i.findIndex(({index:r})=>r===e)+1)%i.length,a=i[s];a&&this.focusItem(a.item.name)}focusPreviousItem(e){const i=this.config.items.map((r,o)=>({item:r,index:o})).filter(({item:r})=>!r.disabled),n=i.findIndex(({index:r})=>r===e),s=n<=0?i.length-1:n-1,a=i[s];a&&this.focusItem(a.item.name)}focusFirstItem(){const e=this.config.items.find(i=>!i.disabled);e&&this.focusItem(e.name)}focusLastItem(){const e=this.config.items.filter(n=>!n.disabled),i=e[e.length-1];i&&this.focusItem(i.name)}focusItem(e){const i=this.itemElements.get(e);i&&i.trigger.focus()}static renderField(e){const i=`
|
|
310
|
+
<div class="mokkun-accordion">
|
|
311
|
+
<div class="accordion-item">
|
|
312
|
+
<button type="button" class="accordion-trigger" aria-expanded="false">
|
|
313
|
+
<span>${m(e.label)}</span>
|
|
314
|
+
<span class="accordion-icon">▼</span>
|
|
315
|
+
</button>
|
|
316
|
+
<div class="accordion-content" hidden>
|
|
317
|
+
<p>${m(e.description??"アコーディオンコンテンツ")}</p>
|
|
318
|
+
</div>
|
|
319
|
+
</div>
|
|
320
|
+
</div>
|
|
321
|
+
`;return y(e,i)}}const er=80,tr=1e3,ir="-20% 0px -60% 0px";class yi{constructor(e,i,n={}){h(this,"config");h(this,"state");h(this,"callbacks");h(this,"container");h(this,"observer",null);h(this,"isScrolling",!1);h(this,"scrollTimeout",null);h(this,"documentClickHandler",null);this.validateConfig(e,i),this.config=e,this.container=i,this.callbacks=n,this.state=this.createInitialState()}render(){B(this.container);const e=this.config.mobileMode??"scroll",i=this.config.stickyTop??"0";this.container.className=`mokkun-section-nav section-nav-${e}`,this.container.style.display="block",this.container.style.position="sticky",this.container.style.top=i,this.container.style.zIndex="100";const n=c("div",{className:"section-nav-wrapper"}),s=this.renderNavList();if(n.appendChild(s),e==="dropdown"){const a=this.renderMobileDropdown();n.appendChild(a)}this.container.appendChild(n),this.setupIntersectionObserver()}scrollToSection(e){var o,l;const i=this.state.sections.find(d=>d.id===e);if(!i||i.disabled)return;const n=document.getElementById(e);if(!n)return;this.isScrolling=!0;const s=this.config.scrollOffset??er,a=this.config.scrollBehavior??"smooth",r=n.getBoundingClientRect().top+window.scrollY-s;window.scrollTo({top:r,behavior:a}),this.state={...this.state,activeSectionId:e},this.updateActiveStyles(),(l=(o=this.callbacks).onSectionChange)==null||l.call(o,e,this.getState()),this.scrollTimeout!==null&&window.clearTimeout(this.scrollTimeout),this.scrollTimeout=window.setTimeout(()=>{this.isScrolling=!1},tr)}setActiveSection(e){const i=this.state.sections.find(n=>n.id===e);!i||i.disabled||(this.state={...this.state,activeSectionId:e},this.updateActiveStyles())}getState(){return{...this.state,sections:this.state.sections.map(e=>({...e}))}}getActiveSection(){return this.state.sections.find(e=>e.id===this.state.activeSectionId)}addSection(e,i){const n=[...this.state.sections];i!==void 0&&i>=0&&i<=n.length?n.splice(i,0,e):n.push(e),this.state={...this.state,sections:n},this.render()}removeSection(e){if(this.state.sections.findIndex(a=>a.id===e)===-1)return!1;const n=this.state.sections.filter(a=>a.id!==e);let s=this.state.activeSectionId;if(this.state.activeSectionId===e&&n.length>0){const a=n.find(r=>!r.disabled);s=(a==null?void 0:a.id)??n[0].id}return this.state={...this.state,sections:n,activeSectionId:s},this.render(),!0}updateSection(e,i){return this.state.sections.findIndex(s=>s.id===e)===-1?!1:(this.state={...this.state,sections:this.state.sections.map(s=>s.id===e?{...s,...i}:s)},this.render(),!0)}destroy(){this.observer&&(this.observer.disconnect(),this.observer=null),this.scrollTimeout!==null&&(window.clearTimeout(this.scrollTimeout),this.scrollTimeout=null),this.documentClickHandler&&(document.removeEventListener("click",this.documentClickHandler),this.documentClickHandler=null)}validateConfig(e,i){if(!(e!=null&&e.sections)||!Array.isArray(e.sections))throw new Error("SectionNav: config.sections must be an array");if(!(i instanceof HTMLElement))throw new Error("SectionNav: container must be an HTMLElement");if(e.sections.length===0)throw new Error("SectionNav: config.sections must not be empty");for(const n of e.sections){if(!n.id||typeof n.id!="string")throw new Error("SectionNav: Each section must have a valid id");if(!n.label||typeof n.label!="string")throw new Error(`SectionNav: Section "${n.id}" must have a valid label`)}}createInitialState(){var i,n;return{activeSectionId:this.config.defaultActiveSection??((i=this.config.sections.find(s=>!s.disabled))==null?void 0:i.id)??((n=this.config.sections[0])==null?void 0:n.id)??"",sections:[...this.config.sections]}}renderNavList(){const e=c("nav",{className:"section-nav-list",attributes:{"aria-label":"セクションナビゲーション",role:"navigation"}}),i=c("ul",{className:"section-nav-items",attributes:{role:"list"}});for(const n of this.state.sections){const s=this.renderNavItem(n);i.appendChild(s)}return e.appendChild(i),e}renderNavItem(e){const i=e.id===this.state.activeSectionId,n=["section-nav-item",i?"active":"",e.disabled?"disabled":""].filter(Boolean).join(" "),s=c("li",{className:n}),a=c("button",{className:"section-nav-button",attributes:{type:"button","aria-current":i?"location":"","data-section-id":e.id}});if(i||a.removeAttribute("aria-current"),e.disabled&&(a.setAttribute("aria-disabled","true"),a.setAttribute("disabled","true")),e.icon){const o=c("span",{className:"section-nav-icon",textContent:e.icon});a.appendChild(o)}const r=c("span",{className:"section-nav-label",textContent:e.label});return a.appendChild(r),e.disabled||a.addEventListener("click",()=>this.scrollToSection(e.id)),s.appendChild(a),s}renderMobileDropdown(){const e=c("div",{className:"section-nav-dropdown"}),i=this.getActiveSection(),n=c("button",{className:"section-nav-dropdown-trigger",attributes:{type:"button","aria-haspopup":"listbox","aria-expanded":"false"}});if(i!=null&&i.icon){const o=c("span",{className:"section-nav-icon",textContent:i.icon});n.appendChild(o)}const s=c("span",{className:"section-nav-label",textContent:(i==null?void 0:i.label)??"セクション選択"});n.appendChild(s);const a=c("span",{className:"section-nav-chevron",textContent:"▼"});n.appendChild(a);const r=c("ul",{className:"section-nav-dropdown-menu",attributes:{role:"listbox",hidden:"true"}});for(const o of this.state.sections){const l=o.id===this.state.activeSectionId,d=c("li",{className:`section-nav-dropdown-item ${l?"active":""} ${o.disabled?"disabled":""}`,attributes:{role:"option","aria-selected":String(l)}});if(o.icon){const u=c("span",{className:"section-nav-icon",textContent:o.icon});d.appendChild(u)}const p=c("span",{className:"section-nav-label",textContent:o.label});d.appendChild(p),o.disabled||d.addEventListener("click",()=>{this.scrollToSection(o.id),r.setAttribute("hidden","true"),n.setAttribute("aria-expanded","false")}),r.appendChild(d)}return n.addEventListener("click",()=>{const o=n.getAttribute("aria-expanded")==="true";n.setAttribute("aria-expanded",String(!o)),o?r.setAttribute("hidden","true"):r.removeAttribute("hidden")}),this.documentClickHandler=o=>{e.contains(o.target)||(r.setAttribute("hidden","true"),n.setAttribute("aria-expanded","false"))},document.addEventListener("click",this.documentClickHandler),e.appendChild(n),e.appendChild(r),e}setupIntersectionObserver(){this.observer&&this.observer.disconnect();const e=this.config.rootMargin??ir,i=this.config.threshold??0;this.observer=new IntersectionObserver(n=>this.handleIntersection(n),{rootMargin:e,threshold:i});for(const n of this.state.sections){const s=document.getElementById(n.id);s&&this.observer.observe(s)}}handleIntersection(e){var i,n;if(!this.isScrolling){for(const s of e)if(s.isIntersecting){const a=s.target.id,r=this.state.sections.find(o=>o.id===a);r&&!r.disabled&&a!==this.state.activeSectionId&&(this.state={...this.state,activeSectionId:a},this.updateActiveStyles(),(n=(i=this.callbacks).onActiveChange)==null||n.call(i,a,this.getState()))}}}updateActiveStyles(){this.container.querySelectorAll(".section-nav-item").forEach(s=>{const a=s.querySelector(".section-nav-button");(a==null?void 0:a.getAttribute("data-section-id"))===this.state.activeSectionId?(s.classList.add("active"),a==null||a.setAttribute("aria-current","location")):(s.classList.remove("active"),a==null||a.removeAttribute("aria-current"))});const i=this.container.querySelector(".section-nav-dropdown-trigger");if(i){const s=this.getActiveSection(),a=i.querySelector(".section-nav-label"),r=i.querySelector(".section-nav-icon");a&&(a.textContent=(s==null?void 0:s.label)??"セクション選択"),r&&(s!=null&&s.icon)&&(r.textContent=s.icon)}this.container.querySelectorAll(".section-nav-dropdown-item").forEach((s,a)=>{const r=this.state.sections[a];(r==null?void 0:r.id)===this.state.activeSectionId?(s.classList.add("active"),s.setAttribute("aria-selected","true")):(s.classList.remove("active"),s.setAttribute("aria-selected","false"))})}static renderField(e){const i=`
|
|
322
|
+
<nav class="mokkun-section-nav" aria-label="${m(e.label)}">
|
|
323
|
+
<ul class="section-nav-list">
|
|
324
|
+
<li class="section-nav-item active">
|
|
325
|
+
<a href="#section1" class="section-nav-link">セクション1</a>
|
|
326
|
+
</li>
|
|
327
|
+
<li class="section-nav-item">
|
|
328
|
+
<a href="#section2" class="section-nav-link">セクション2</a>
|
|
329
|
+
</li>
|
|
330
|
+
<li class="section-nav-item">
|
|
331
|
+
<a href="#section3" class="section-nav-link">セクション3</a>
|
|
332
|
+
</li>
|
|
333
|
+
</ul>
|
|
334
|
+
</nav>
|
|
335
|
+
`;return y(e,i)}}class nr{constructor(e,i={},n={}){h(this,"config");h(this,"state");h(this,"callbacks");h(this,"container");this.config=i,this.container=e,this.callbacks=n,this.state=this.createInitialState()}render(){this.container.innerHTML="";const e=this.config.layout??"horizontal",i=this.config.maxColumns,n=this.config.bordered??!1,s=this.config.striped??!1,a=this.config.compact??!1;this.container.className="mokkun-definition-list",this.container.setAttribute("data-layout",e),i&&this.container.setAttribute("data-columns",String(i)),n&&this.container.classList.add("definition-list-bordered"),s&&this.container.classList.add("definition-list-striped"),a&&this.container.classList.add("definition-list-compact"),this.applyCustomStyles(),this.state.isGrouped&&this.state.groups.length>0?this.renderGroups():this.renderItems(this.state.items)}setItems(e){this.state={...this.state,items:e,groups:[],isGrouped:!1},this.render()}setGroups(e){this.state={...this.state,items:[],groups:e,isGrouped:!0},this.render()}addItem(e){this.state={...this.state,items:[...this.state.items,e]},this.render()}removeItem(e){e<0||e>=this.state.items.length||(this.state={...this.state,items:this.state.items.filter((i,n)=>n!==e)},this.render())}updateItem(e,i){e<0||e>=this.state.items.length||(this.state={...this.state,items:this.state.items.map((n,s)=>s===e?{...n,...i}:n)},this.render())}getState(){return{...this.state}}destroy(){this.container.innerHTML=""}createInitialState(){const e=this.config.items??[],i=this.config.groups??[],n=i.length>0;return{items:n?[]:e,groups:i,isGrouped:n}}applyCustomStyles(){if(this.config.termWidth){const e=typeof this.config.termWidth=="number"?`${this.config.termWidth}px`:this.config.termWidth;this.container.style.setProperty("--definition-term-width",e)}if(this.config.gap){const e=typeof this.config.gap=="number"?`${this.config.gap}px`:this.config.gap;this.container.style.setProperty("--definition-gap",e)}}renderGroups(){this.state.groups.forEach((e,i)=>{const n=this.renderGroup(e,i);this.container.appendChild(n)})}renderGroup(e,i){const n=c("div",{className:"definition-group",attributes:{"data-group-index":String(i)}}),s=c("div",{className:"definition-group-title",textContent:e.title});n.appendChild(s);const a=c("dl",{className:"definition-list-content",attributes:{"aria-label":e.title}});return e.layout&&a.setAttribute("data-layout",e.layout),e.maxColumns&&a.setAttribute("data-columns",String(e.maxColumns)),this.callbacks.onGroupClick&&(n.style.cursor="pointer",n.addEventListener("click",r=>{var o,l;r.target.closest(".definition-item")||(l=(o=this.callbacks).onGroupClick)==null||l.call(o,e,i)})),e.items.forEach((r,o)=>{this.renderItem(r,o).forEach(d=>a.appendChild(d))}),n.appendChild(a),n}renderItems(e){const i=c("dl",{className:"definition-list-content",attributes:{"aria-label":"Definition list"}});e.forEach((n,s)=>{this.renderItem(n,s).forEach(r=>i.appendChild(r))}),this.container.appendChild(i)}renderItem(e,i){const n=[],s=this.config.clickable??!1,a=this.config.emptyText??"-",r=this.config.termStyleType,o=e.className?e.className.replace(/[^a-zA-Z0-9_\-\s]/g,""):"",l=c("div",{className:`definition-item${o?` ${o}`:""}`,attributes:{"data-index":String(i)}});e.fullWidth&&l.setAttribute("data-full-width",""),e.maxColumns&&l.setAttribute("data-columns",String(e.maxColumns));const d=c("dt",{className:`definition-term${r?` term-${r}`:""}`,textContent:e.term}),p=c("dd",{className:"definition-description"});if(e.description===null||e.description===void 0)p.textContent=a,p.classList.add("definition-description-empty");else if(Array.isArray(e.description))if(e.description.length===0)p.textContent=a,p.classList.add("definition-description-empty");else{const u=c("ul",{className:"definition-description-list"});e.description.forEach(f=>{const g=c("li",{textContent:f});u.appendChild(g)}),p.appendChild(u)}else p.textContent=e.description;return s&&this.callbacks.onItemClick&&(l.style.cursor="pointer",l.setAttribute("role","button"),l.setAttribute("tabindex","0"),l.addEventListener("click",()=>{var u,f;(f=(u=this.callbacks).onItemClick)==null||f.call(u,e,i)}),l.addEventListener("keydown",u=>{var f,g;(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),(g=(f=this.callbacks).onItemClick)==null||g.call(f,e,i))})),l.appendChild(d),l.appendChild(p),n.push(l),n}static renderField(e){const n=`
|
|
336
|
+
<dl class="mokkun-definition-list" aria-label="${m(e.label)}">
|
|
337
|
+
<div class="definition-item">
|
|
338
|
+
<dt class="definition-term">項目1</dt>
|
|
339
|
+
<dd class="definition-description">値1</dd>
|
|
340
|
+
</div>
|
|
341
|
+
<div class="definition-item">
|
|
342
|
+
<dt class="definition-term">項目2</dt>
|
|
343
|
+
<dd class="definition-description">値2</dd>
|
|
344
|
+
</div>
|
|
345
|
+
<div class="definition-item">
|
|
346
|
+
<dt class="definition-term">項目3</dt>
|
|
347
|
+
<dd class="definition-description">値3</dd>
|
|
348
|
+
</div>
|
|
349
|
+
</dl>
|
|
350
|
+
`;return y(e,n)}}function Ae(t){if(t)return typeof t=="string"?t:t.type}function sr(t){return t?typeof t=="string"?t==="completed"?"完了":"中断":t.text||(t.type==="completed"?"完了":"中断"):""}function ar(){const t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("viewBox","0 0 512 512"),t.setAttribute("width","1em"),t.setAttribute("height","1em"),t.setAttribute("fill","currentColor"),t.setAttribute("aria-hidden","true"),t.classList.add("stepper-icon","stepper-icon-check");const e=document.createElementNS("http://www.w3.org/2000/svg","path");return e.setAttribute("d","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM369 209L241 337c-9.4 9.4-24.6 9.4-33.9 0l-64-64c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l47 47L335 175c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9z"),t.appendChild(e),t}function rr(){const t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("viewBox","0 0 512 512"),t.setAttribute("width","1em"),t.setAttribute("height","1em"),t.setAttribute("fill","currentColor"),t.setAttribute("aria-hidden","true"),t.classList.add("stepper-icon","stepper-icon-close");const e=document.createElementNS("http://www.w3.org/2000/svg","path");return e.setAttribute("d","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM175 175c9.4-9.4 24.6-9.4 33.9 0l47 47 47-47c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-47 47 47 47c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0l-47-47-47 47c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9l47-47-47-47c-9.4-9.4-9.4-24.6 0-33.9z"),t.appendChild(e),t}class or{constructor(e,i,n={}){h(this,"config");h(this,"container");h(this,"state");this.config=e,this.container=i,this.state=this.createInitialState()}createInitialState(){return{activeIndex:this.config.activeIndex??0,type:this.config.type}}getState(){return{...this.state}}setActiveIndex(e){e>=0&&e<this.config.steps.length&&(this.state={...this.state,activeIndex:e},this.render())}render(){B(this.container),this.container.className=`mokkun-stepper stepper-${this.state.type}`,this.state.type==="horizontal"?this.renderHorizontal():this.renderVertical()}renderHorizontal(){const e=c("ol",{className:"stepper-list stepper-list-horizontal"});e.setAttribute("role","list"),this.config.steps.forEach((n,s)=>{const a=this.renderHorizontalStep(n,s);e.appendChild(a)}),this.container.appendChild(e)}renderHorizontalStep(e,i){const n=i===this.state.activeIndex,s=i<this.state.activeIndex,a=Ae(e.status),r=a==="completed"||s&&!a,o=a==="closed",l=i>0&&(Ae(this.config.steps[i-1].status)==="completed"||i-1<this.state.activeIndex),d=c("li",{className:["stepper-item","stepper-item-horizontal",n?"is-current":"",r?"is-completed":"",o?"is-closed":""].filter(Boolean).join(" ")});n&&d.setAttribute("aria-current","step");const p=c("div",{className:"stepper-label-wrapper"}),u=c("div",{className:"stepper-counter-wrapper"}),f=c("span",{className:["stepper-line","stepper-line-before",l?"is-completed":"",i===0?"is-hidden":""].filter(Boolean).join(" ")});u.appendChild(f);const g=this.renderStepCounter(i,n,e.status);u.appendChild(g);const x=c("span",{className:["stepper-line","stepper-line-after",r?"is-completed":"",i===this.config.steps.length-1?"is-hidden":""].filter(Boolean).join(" ")});u.appendChild(x),p.appendChild(u);const C=c("span",{className:["stepper-label",n?"is-current":"",o?"is-closed":""].filter(Boolean).join(" "),textContent:e.label});return p.appendChild(C),d.appendChild(p),d}renderVertical(){const e=c("ol",{className:"stepper-list stepper-list-vertical"});e.setAttribute("role","list"),this.config.steps.forEach((n,s)=>{const a=this.renderVerticalStep(n,s);e.appendChild(a)}),this.container.appendChild(e)}renderVerticalStep(e,i){const n=i===this.state.activeIndex,s=i<this.state.activeIndex,a=Ae(e.status),r=a==="completed"||s&&!a,o=a==="closed",l=i===this.config.steps.length-1,d=c("li",{className:["stepper-item","stepper-item-vertical",n?"is-current":"",r?"is-completed":"",o?"is-closed":"",l?"is-last":""].filter(Boolean).join(" ")});n&&d.setAttribute("aria-current","step");const p=c("div",{className:"stepper-section"}),u=c("div",{className:"stepper-counter-area"}),f=this.renderStepCounter(i,n,e.status);u.appendChild(f),p.appendChild(u);const g=c("div",{className:"stepper-body"}),x=c("div",{className:["stepper-heading",n?"is-current":"",(r||o)&&!n?"is-inactive":""].filter(Boolean).join(" "),textContent:e.label});if(g.appendChild(x),e.children){const C=c("div",{className:"stepper-inner"});C.innerHTML=e.children,g.appendChild(C)}return p.appendChild(g),d.appendChild(p),d}renderStepCounter(e,i,n){const s=Ae(n),a=s==="completed"||s==="closed",r=c("span",{className:["stepper-counter",i?"is-current":"",s==="completed"?"is-completed":"",s==="closed"?"is-closed":""].filter(Boolean).join(" ")}),o=c("span",{className:"stepper-number",textContent:String(e+1)});if(o.setAttribute("aria-hidden","true"),r.appendChild(o),a){const l=c("span",{className:"stepper-status-icon"});l.setAttribute("role","img"),l.setAttribute("aria-label",sr(n)),s==="completed"?l.appendChild(ar()):s==="closed"&&l.appendChild(rr()),r.appendChild(l)}return r}destroy(){B(this.container)}static renderField(e){return y(e,`
|
|
351
|
+
<div class="mokkun-stepper">
|
|
352
|
+
<div class="stepper-step completed">
|
|
353
|
+
<div class="step-indicator">1</div>
|
|
354
|
+
<div class="step-label">ステップ1</div>
|
|
355
|
+
</div>
|
|
356
|
+
<div class="stepper-connector"></div>
|
|
357
|
+
<div class="stepper-step active">
|
|
358
|
+
<div class="step-indicator">2</div>
|
|
359
|
+
<div class="step-label">ステップ2</div>
|
|
360
|
+
</div>
|
|
361
|
+
<div class="stepper-connector"></div>
|
|
362
|
+
<div class="stepper-step">
|
|
363
|
+
<div class="step-indicator">3</div>
|
|
364
|
+
<div class="step-label">ステップ3</div>
|
|
365
|
+
</div>
|
|
366
|
+
</div>
|
|
367
|
+
`)}}const lr={info:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M15 8A7 7 0 1 1 1 8a7 7 0 0 1 14 0ZM9 5a1 1 0 1 1-2 0 1 1 0 0 1 2 0ZM6.75 8a.75.75 0 0 0 0 1.5h.75v1.75a.75.75 0 0 0 1.5 0v-2.5A.75.75 0 0 0 8.25 8h-1.5Z" clip-rule="evenodd" /></svg>',success:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M8 15A7 7 0 1 0 8 1a7 7 0 0 0 0 14Zm3.844-8.791a.75.75 0 0 0-1.188-.918l-3.7 4.79-1.649-1.833a.75.75 0 1 0-1.114 1.004l2.25 2.5a.75.75 0 0 0 1.151-.043l4.25-5.5Z" clip-rule="evenodd" /></svg>',warning:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M6.701 2.25c.577-1 2.02-1 2.598 0l5.196 9a1.5 1.5 0 0 1-1.299 2.25H2.804a1.5 1.5 0 0 1-1.3-2.25l5.197-9ZM8 4a.75.75 0 0 1 .75.75v3a.75.75 0 0 1-1.5 0v-3A.75.75 0 0 1 8 4Zm0 8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z" clip-rule="evenodd" /></svg>',error:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M8 15A7 7 0 1 0 8 1a7 7 0 0 0 0 14ZM8 4a.75.75 0 0 1 .75.75v3a.75.75 0 0 1-1.5 0v-3A.75.75 0 0 1 8 4Zm0 8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z" clip-rule="evenodd" /></svg>',sync:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M13.836 2.477a.75.75 0 0 1 .75.75v3.182a.75.75 0 0 1-.75.75h-3.182a.75.75 0 0 1 0-1.5h1.37l-.84-.841a4.5 4.5 0 0 0-7.08.681.75.75 0 0 1-1.264-.808 6 6 0 0 1 9.44-.908l.84.84v-1.646a.75.75 0 0 1 .75-.75Zm-1.672 9.046a.75.75 0 0 1 1.264.808 6 6 0 0 1-9.44.908l-.84-.84v1.646a.75.75 0 0 1-1.5 0V10.82a.75.75 0 0 1 .75-.75h3.182a.75.75 0 0 1 0 1.5h-1.37l.84.841a4.5 4.5 0 0 0 7.08-.681Z" clip-rule="evenodd" /></svg>'};class cr{constructor(e,i,n={}){h(this,"config");h(this,"state");h(this,"callbacks");h(this,"container");h(this,"instanceId");h(this,"contentElement",null);this.config=i,this.container=e,this.callbacks=n,this.instanceId=i.id??E("information-panel"),this.state=this.createInitialState()}render(){this.container.innerHTML="",this.contentElement=null;const e=this.config.type??"info",i=this.config.toggleable??!1,n=this.config.bold??!1;if(this.container.className=["mokkun-information-panel",`information-panel-${e}`,i?"information-panel-toggleable":"",n?"information-panel-bold":"",this.state.active?"is-active":"",this.config.className??""].filter(Boolean).join(" "),this.container.id=this.instanceId,this.container.setAttribute("data-type",e),this.state.hidden){this.container.setAttribute("data-hidden",""),this.container.style.display="none";return}else this.container.removeAttribute("data-hidden"),this.container.style.display="";const s=this.renderHeader();this.container.appendChild(s);const a=this.renderContent();this.container.appendChild(a),this.contentElement=a}open(){var e,i;(this.config.toggleable??!1)&&(this.state.active||(this.state={...this.state,active:!0},this.updateActiveState(),(i=(e=this.callbacks).onClickTrigger)==null||i.call(e,!0)))}close(){var e,i;(this.config.toggleable??!1)&&this.state.active&&(this.state={...this.state,active:!1},this.updateActiveState(),(i=(e=this.callbacks).onClickTrigger)==null||i.call(e,!1))}toggle(){this.state.active?this.close():this.open()}isActive(){return this.state.active}hide(){this.state.hidden||(this.state={...this.state,hidden:!0},this.render())}show(){this.state.hidden&&(this.state={...this.state,hidden:!1},this.render())}getState(){return{...this.state}}setTitle(e){this.config={...this.config,title:e},this.render()}setContent(e){this.config={...this.config,content:e},this.render()}setType(e){this.config={...this.config,type:e},this.render()}destroy(){this.container.innerHTML="",this.contentElement=null}createInitialState(){const e=this.config.toggleable??!1,i=this.config.defaultActive??!0;return{active:e?i:!0,hidden:!1}}renderHeader(){const e=c("div",{className:"information-panel-header"}),i=this.renderIcon();e.appendChild(i);const n=this.renderTitle();e.appendChild(n);const s=this.renderActions();return s&&e.appendChild(s),e}renderIcon(){const e=this.config.type??"info",i=c("span",{className:"information-panel-icon",attributes:{"aria-hidden":"true"}});return i.innerHTML=lr[e],i}renderTitle(){const e=this.config.bold??!1,i=this.config.toggleable??!1,n=c("span",{className:`information-panel-title${e?" is-bold":""}`,textContent:this.config.title});return i&&n.setAttribute("id",`${this.instanceId}-title`),n}renderActions(){const e=this.config.toggleable??!1,i=this.config.closable??!1;if(!e&&!i)return null;const n=c("div",{className:"information-panel-actions"});if(e){const s=this.renderToggleButton();n.appendChild(s)}else if(i){const s=this.renderCloseButton();n.appendChild(s)}return n}renderToggleButton(){const e=c("button",{className:"information-panel-toggle",attributes:{type:"button","aria-expanded":String(this.state.active),"aria-controls":`${this.instanceId}-content`}}),i=c("span",{className:"information-panel-toggle-icon",attributes:{"aria-hidden":"true"}}),n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("width","16"),n.setAttribute("height","16"),n.setAttribute("viewBox","0 0 16 16"),n.setAttribute("fill","currentColor");const s=document.createElementNS("http://www.w3.org/2000/svg","path");s.setAttribute("d","M3 6l5 5 5-5H3z"),n.appendChild(s),i.appendChild(n),e.appendChild(i);const a=c("span",{className:"information-panel-toggle-text",textContent:this.state.active?"閉じる":"開く"});return e.appendChild(a),e.addEventListener("click",()=>{this.toggle()}),e}renderCloseButton(){const e=c("button",{className:"information-panel-close",attributes:{type:"button","aria-label":"閉じる"}}),i=c("span",{className:"information-panel-close-icon",attributes:{"aria-hidden":"true"}}),n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("width","16"),n.setAttribute("height","16"),n.setAttribute("viewBox","0 0 16 16"),n.setAttribute("fill","currentColor");const s=document.createElementNS("http://www.w3.org/2000/svg","path");return s.setAttribute("d","M5.28 4.22a.75.75 0 0 0-1.06 1.06L6.94 8l-2.72 2.72a.75.75 0 1 0 1.06 1.06L8 9.06l2.72 2.72a.75.75 0 1 0 1.06-1.06L9.06 8l2.72-2.72a.75.75 0 0 0-1.06-1.06L8 6.94 5.28 4.22Z"),n.appendChild(s),i.appendChild(n),e.appendChild(i),e.addEventListener("click",()=>{var a,r;this.hide(),(r=(a=this.callbacks).onClose)==null||r.call(a)}),e}renderContent(){const e=this.config.toggleable??!1,i=c("div",{className:`information-panel-content-wrapper${this.state.active?" is-active":""}`}),n=c("div",{className:"information-panel-content",attributes:{role:"region"}});return e&&(n.setAttribute("id",`${this.instanceId}-content`),n.setAttribute("aria-labelledby",`${this.instanceId}-title`),this.state.active||n.setAttribute("hidden","")),typeof this.config.content=="string"?n.innerHTML=this.config.content:n.appendChild(this.config.content),i.appendChild(n),i}updateActiveState(){if(!(this.config.toggleable??!1))return;this.state.active?this.container.classList.add("is-active"):this.container.classList.remove("is-active");const i=this.container.querySelector(".information-panel-toggle");if(i){i.setAttribute("aria-expanded",String(this.state.active));const n=i.querySelector(".information-panel-toggle-icon");n&&(this.state.active?n.classList.add("is-active"):n.classList.remove("is-active"));const s=i.querySelector(".information-panel-toggle-text");s&&(s.textContent=this.state.active?"閉じる":"開く")}if(this.contentElement){const n=this.contentElement.querySelector(".information-panel-content");this.state.active?(this.contentElement.classList.add("is-active"),n==null||n.removeAttribute("hidden")):(this.contentElement.classList.remove("is-active"),setTimeout(()=>{this.state.active||n==null||n.setAttribute("hidden","")},200))}}static renderField(e){const s=`
|
|
368
|
+
<div class="mokkun-information-panel panel-${e.variant??"info"}">
|
|
369
|
+
<div class="panel-icon">ℹ️</div>
|
|
370
|
+
<div class="panel-content">
|
|
371
|
+
<div class="panel-title">${m(e.label)}</div>
|
|
372
|
+
${e.description?`<div class="panel-description">${m(e.description)}</div>`:""}
|
|
373
|
+
</div>
|
|
374
|
+
</div>
|
|
375
|
+
`;return y(e,s)}}class dr{constructor(e,i,n={}){h(this,"config");h(this,"state");h(this,"callbacks");h(this,"container");h(this,"instanceId");h(this,"triggerElement",null);h(this,"contentElement",null);h(this,"clickOutsideHandler",null);h(this,"keyboardHandler",null);this.config=i,this.container=e,this.callbacks=n,this.instanceId=E("dropdown"),this.state=this.createInitialState()}render(){this.container.innerHTML="";const e=this.config.variant??"menu",i=this.config.placement??"bottom-start",n=this.config.triggerSize??"default";this.container.className=`mokkun-dropdown dropdown-${e} dropdown-${i} dropdown-trigger-${n}`,this.container.style.overflow="visible",this.state.isOpen?this.container.setAttribute("data-state","open"):this.container.setAttribute("data-state","closed");const s=c("div",{className:"dropdown-wrapper"});this.triggerElement=this.renderTrigger(),s.appendChild(this.triggerElement),this.state.isOpen?(this.contentElement=this.renderContent(),s.appendChild(this.contentElement),this.attachEventListeners(),this.state.focusedIndex===-1&&this.initializeFocus()):(this.contentElement=null,this.detachEventListeners()),this.container.appendChild(s)}toggle(){this.setOpen(!this.state.isOpen)}open(){this.setOpen(!0)}close(){this.setOpen(!1)}setOpen(e){var i,n;this.state.isOpen!==e&&(this.state={...this.state,isOpen:e,focusedIndex:-1},this.render(),(n=(i=this.callbacks).onOpenChange)==null||n.call(i,e))}getState(){return{...this.state}}setItems(e){this.state={...this.state,items:e},this.state.isOpen&&this.render()}destroy(){this.detachEventListeners(),this.container.innerHTML=""}createInitialState(){return{isOpen:this.config.defaultOpen??!1,items:this.config.items,selectedFilters:this.config.variant==="filter"?this.config.items.filter(i=>i.type==="filter"&&i.selected===!0).map(i=>i.value):void 0,currentSort:void 0,focusedIndex:-1}}renderTrigger(){const e=this.config.onlyIconTrigger??!1,i=this.config.triggerSize??"default",n=this.config.isFiltered??!1,s=c("button",{className:`dropdown-trigger dropdown-trigger-${i}${n?" is-filtered":""}`,attributes:{type:"button","aria-haspopup":"true","aria-expanded":String(this.state.isOpen),"aria-controls":`${this.instanceId}-content`,id:`${this.instanceId}-trigger`}});if(this.config.triggerIcon){const r=c("span",{className:"dropdown-trigger-icon"});r.innerHTML=this.config.triggerIcon,s.appendChild(r)}if(!e){const r=c("span",{className:"dropdown-trigger-label",textContent:this.config.triggerLabel});s.appendChild(r)}const a=c("span",{className:"dropdown-trigger-caret",textContent:"▼"});return a.setAttribute("aria-hidden","true"),s.appendChild(a),s.addEventListener("click",()=>{this.toggle()}),s}renderContent(){const e=this.config.variant??"menu",i=this.config.placement??"bottom-start",n=c("div",{className:`dropdown-content dropdown-content-${i}`,attributes:{role:"menu","aria-labelledby":`${this.instanceId}-trigger`,id:`${this.instanceId}-content`}});return e==="filter"?this.renderFilterContent(n):this.renderMenuContent(n),n}renderMenuContent(e){const i=c("div",{className:"dropdown-menu",attributes:{role:"menu"}});this.state.items.forEach((n,s)=>{n.type==="divider"?i.appendChild(this.renderDivider()):i.appendChild(this.renderMenuItem(n,s))}),e.appendChild(i)}renderFilterContent(e){const i=c("div",{className:"dropdown-filter-content"}),n=c("div",{className:"dropdown-menu",attributes:{role:"menu"}});this.state.items.filter(l=>l.type==="filter").forEach((l,d)=>{n.appendChild(this.renderFilterItem(l,d))}),i.appendChild(n);const a=c("div",{className:"dropdown-filter-actions"}),r=c("button",{className:"dropdown-filter-button dropdown-filter-reset",textContent:"クリア",attributes:{type:"button"}});r.addEventListener("click",()=>{this.handleFilterReset()});const o=c("button",{className:"dropdown-filter-button dropdown-filter-apply",textContent:"適用",attributes:{type:"button"}});o.addEventListener("click",()=>{this.handleFilterApply()}),a.appendChild(r),a.appendChild(o),i.appendChild(a),e.appendChild(i)}renderMenuItem(e,i){var a;const n=c("div",{className:`dropdown-menu-item${e.disabled?" is-disabled":""}${this.state.focusedIndex===i?" is-focused":""}`,attributes:{role:"menuitem",tabindex:String(e.disabled?-1:0),"aria-disabled":e.disabled?"true":"false","data-index":String(i)}});if(e.icon){const r=c("span",{className:"dropdown-menu-item-icon"});r.innerHTML=e.icon,n.appendChild(r)}const s=c("span",{className:"dropdown-menu-item-label",textContent:e.label});if(n.appendChild(s),e.type==="sort"&&((a=this.state.currentSort)==null?void 0:a.field)===e.field){const r=c("span",{className:"dropdown-menu-item-sort-indicator",textContent:this.state.currentSort.direction==="asc"?"↑":"↓"});n.appendChild(r)}return e.disabled||n.addEventListener("click",()=>{this.handleItemClick(e)}),n}renderFilterItem(e,i){var o;const n=((o=this.state.selectedFilters)==null?void 0:o.includes(e.value))??!1,s=c("label",{className:`dropdown-menu-item dropdown-filter-item${e.disabled?" is-disabled":""}${n?" is-selected":""}${this.state.focusedIndex===i?" is-focused":""}`,attributes:{tabindex:String(e.disabled?-1:0),"data-index":String(i)}}),a=c("input",{className:"dropdown-filter-checkbox",attributes:{type:"checkbox",value:e.value}});if(n&&(a.checked=!0),e.disabled&&(a.disabled=!0),a.addEventListener("change",()=>{this.handleFilterChange(e.value,a.checked)}),s.appendChild(a),e.icon){const l=c("span",{className:"dropdown-menu-item-icon"});l.innerHTML=e.icon,s.appendChild(l)}const r=c("span",{className:"dropdown-menu-item-label",textContent:e.label});return s.appendChild(r),s}renderDivider(){return c("div",{className:"dropdown-divider",attributes:{role:"separator"}})}handleItemClick(e){var i,n,s,a,r,o;if(e.type!=="divider"){if((n=(i=this.callbacks).onSelect)==null||n.call(i,e),e.type==="action")(s=e.onAction)==null||s.call(e,e.id),this.close();else if(e.type==="sort"){const l=((a=this.state.currentSort)==null?void 0:a.field)===e.field&&this.state.currentSort.direction==="asc"?"desc":"asc";this.state={...this.state,currentSort:{field:e.field,direction:l}},(o=(r=this.callbacks).onSortChange)==null||o.call(r,e.field,l),this.close()}}}handleFilterChange(e,i){const n=this.state.selectedFilters??[];i?this.state={...this.state,selectedFilters:[...n,e]}:this.state={...this.state,selectedFilters:n.filter(s=>s!==e)}}handleFilterApply(){var e,i;(i=(e=this.callbacks).onApply)==null||i.call(e,this.state.selectedFilters??[]),this.close()}handleFilterReset(){var e,i;this.state={...this.state,selectedFilters:[]},this.render(),(i=(e=this.callbacks).onReset)==null||i.call(e)}handleClickOutside(e){const i=e.target;this.container.contains(i)||this.close()}handleKeyboard(e){var n;if(!this.state.isOpen)return;const i=this.state.items.filter(s=>s.type!=="divider"&&!s.disabled);switch(e.key){case"Escape":e.preventDefault(),this.close(),(n=this.triggerElement)==null||n.focus();break;case"ArrowDown":e.preventDefault(),this.focusNextItem(i.length);break;case"ArrowUp":e.preventDefault(),this.focusPreviousItem(i.length);break;case"Home":e.preventDefault(),this.focusFirstItem();break;case"End":e.preventDefault(),this.focusLastItem(i.length);break;case"Enter":case" ":e.preventDefault(),this.selectFocusedItem();break}}initializeFocus(){var s;const e=this.state.items.filter(a=>a.type!=="divider"&&!a.disabled);if(e.length===0)return;const i=this.state.items.indexOf(e[0]);this.state={...this.state,focusedIndex:i};const n=(s=this.contentElement)==null?void 0:s.querySelector(`[data-index="${i}"]`);n==null||n.focus()}focusFirstItem(){const e=this.state.items.filter(n=>n.type!=="divider"&&!n.disabled);if(e.length===0)return;const i=this.state.items.indexOf(e[0]);this.setFocusedIndex(i)}focusLastItem(e){if(e===0)return;const i=this.state.items.filter(s=>s.type!=="divider"&&!s.disabled),n=this.state.items.indexOf(i[i.length-1]);this.setFocusedIndex(n)}focusNextItem(e){if(e===0)return;const i=this.state.items.filter(r=>r.type!=="divider"&&!r.disabled),s=(i.findIndex(r=>this.state.items.indexOf(r)===this.state.focusedIndex)+1)%e,a=this.state.items.indexOf(i[s]);this.setFocusedIndex(a)}focusPreviousItem(e){if(e===0)return;const i=this.state.items.filter(r=>r.type!=="divider"&&!r.disabled),n=i.findIndex(r=>this.state.items.indexOf(r)===this.state.focusedIndex),s=n<=0?e-1:n-1,a=this.state.items.indexOf(i[s]);this.setFocusedIndex(a)}setFocusedIndex(e){var n;this.state={...this.state,focusedIndex:e},this.render();const i=(n=this.contentElement)==null?void 0:n.querySelector(`[data-index="${e}"]`);i==null||i.focus()}selectFocusedItem(){if(this.state.focusedIndex===-1)return;const e=this.state.items[this.state.focusedIndex];e&&e.type!=="divider"&&this.handleItemClick(e)}attachEventListeners(){this.clickOutsideHandler=this.handleClickOutside.bind(this),this.keyboardHandler=this.handleKeyboard.bind(this),setTimeout(()=>{document.addEventListener("click",this.clickOutsideHandler),document.addEventListener("keydown",this.keyboardHandler)},0)}detachEventListeners(){this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null),this.keyboardHandler&&(document.removeEventListener("keydown",this.keyboardHandler),this.keyboardHandler=null)}static renderField(e){const n=e.options??[],s=`
|
|
376
|
+
<div class="mokkun-dropdown">
|
|
377
|
+
<button type="button" class="dropdown-trigger" aria-haspopup="listbox" aria-expanded="false">
|
|
378
|
+
<span>${m(e.label)}</span>
|
|
379
|
+
<span class="dropdown-arrow">▼</span>
|
|
380
|
+
</button>
|
|
381
|
+
<ul class="dropdown-menu" role="listbox" hidden>
|
|
382
|
+
${n.map(a=>`
|
|
383
|
+
<li class="dropdown-item" role="option" data-value="${m(a.value)}">
|
|
384
|
+
${m(a.label)}
|
|
385
|
+
</li>
|
|
386
|
+
`).join("")}
|
|
387
|
+
</ul>
|
|
388
|
+
</div>
|
|
389
|
+
`;return y(e,s)}}class Ci{constructor(e,i={}){h(this,"config");h(this,"callbacks");h(this,"state");h(this,"dialogElement",null);h(this,"overlayElement",null);h(this,"dialogId");h(this,"boundKeydownHandler");this.config=e,this.callbacks=i,this.dialogId=E("delete-dialog"),this.state={isOpen:!1,previouslyFocusedElement:null},this.boundKeydownHandler=this.handleKeydown.bind(this)}open(){this.state.isOpen||(this.state={...this.state,isOpen:!0,previouslyFocusedElement:document.activeElement},this.render(),this.setupEventListeners(),this.trapFocus())}close(){var e,i;this.state.isOpen&&(this.removeEventListeners(),this.destroy(),this.state.previouslyFocusedElement instanceof HTMLElement&&this.state.previouslyFocusedElement.focus(),this.state={...this.state,isOpen:!1,previouslyFocusedElement:null},(i=(e=this.callbacks).onClose)==null||i.call(e))}updateConfig(e){this.config={...this.config,...e},this.state.isOpen&&this.render()}getState(){return{...this.state}}getDialogElement(){return this.dialogElement}render(){this.destroy(),this.overlayElement=c("div",{className:"dialog-overlay",attributes:{"data-dialog-overlay":this.dialogId}});const e=this.config.danger!==!1?"dialog-danger":"";this.dialogElement=c("div",{className:`delete-confirm-dialog ${e}`.trim(),attributes:{role:"alertdialog","aria-modal":"true","aria-labelledby":`${this.dialogId}-title`,"aria-describedby":`${this.dialogId}-description`,"data-dialog-id":this.dialogId}}),this.dialogElement.appendChild(this.renderHeader()),this.dialogElement.appendChild(this.renderBody()),this.dialogElement.appendChild(this.renderFooter()),document.body.appendChild(this.overlayElement),document.body.appendChild(this.dialogElement),document.body.classList.add("dialog-open")}renderHeader(){const e=c("div",{className:"dialog-header"}),i=c("div",{className:"dialog-icon"});i.innerHTML=`
|
|
390
|
+
<svg viewBox="0 0 24 24" width="24" height="24" fill="currentColor" aria-hidden="true">
|
|
391
|
+
<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"/>
|
|
392
|
+
</svg>
|
|
393
|
+
`,e.appendChild(i);const n=c("h2",{className:"dialog-title",textContent:this.config.title,attributes:{id:`${this.dialogId}-title`}});return e.appendChild(n),e}renderBody(){const e=c("div",{className:"dialog-body",attributes:{id:`${this.dialogId}-description`}}),i=c("div",{className:"dialog-target-info"}),n=this.config.targetType??"項目",s=c("p",{className:"dialog-target-text"});if(s.innerHTML=`<strong>${this.escapeHtml(n)}</strong>: ${this.escapeHtml(this.config.targetName)}`,i.appendChild(s),e.appendChild(i),this.config.dependencies&&this.config.dependencies.length>0){const a=this.renderDependencies();e.appendChild(a)}if(this.config.warningMessage){const a=c("div",{className:"dialog-warning",attributes:{role:"alert"}}),r=c("span",{className:"warning-icon"});r.innerHTML=`
|
|
394
|
+
<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor" aria-hidden="true">
|
|
395
|
+
<path d="M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z"/>
|
|
396
|
+
</svg>
|
|
397
|
+
`,a.appendChild(r);const o=c("span",{className:"warning-text",textContent:this.config.warningMessage});a.appendChild(o),e.appendChild(a)}return e}renderDependencies(){var a;const e=c("div",{className:"dialog-dependencies"}),i=c("h3",{className:"dependencies-heading",textContent:"関連データへの影響"});e.appendChild(i);const n=c("ul",{className:"dependencies-list"});for(const r of this.config.dependencies??[]){const o=c("li",{className:"dependency-item"}),l=c("span",{className:"dependency-label",textContent:r.label}),d=c("span",{className:`dependency-count ${r.count>0?"has-data":""}`,textContent:`${r.count}件`});o.appendChild(l),o.appendChild(d),n.appendChild(o)}if(e.appendChild(n),(a=this.config.dependencies)==null?void 0:a.some(r=>r.count>0)){const r=c("p",{className:"dependencies-note",textContent:"これらの関連データも削除されます。この操作は取り消せません。"});e.appendChild(r)}return e}renderFooter(){const e=c("div",{className:"dialog-footer"}),i=c("button",{className:"dialog-btn dialog-btn-cancel",textContent:this.config.cancelLabel??"キャンセル",attributes:{type:"button","data-action":"cancel"}});i.addEventListener("click",()=>this.handleCancel()),e.appendChild(i);const n=c("button",{className:"dialog-btn dialog-btn-confirm dialog-btn-danger",textContent:this.config.confirmLabel??"削除を実行",attributes:{type:"button","data-action":"confirm"}});return n.addEventListener("click",()=>this.handleConfirm()),e.appendChild(n),e}setupEventListeners(){var e;document.addEventListener("keydown",this.boundKeydownHandler),(e=this.overlayElement)==null||e.addEventListener("click",()=>this.handleCancel())}removeEventListeners(){document.removeEventListener("keydown",this.boundKeydownHandler)}handleKeydown(e){if(e.key==="Escape"){e.preventDefault(),this.handleCancel();return}e.key==="Tab"&&this.handleTabKey(e)}handleTabKey(e){if(!this.dialogElement)return;const i=this.getFocusableElements();if(i.length===0)return;const n=i[0],s=i[i.length-1],a=document.activeElement;e.shiftKey?a===n&&(e.preventDefault(),s.focus()):a===s&&(e.preventDefault(),n.focus())}getFocusableElements(){if(!this.dialogElement)return[];const e=["button:not([disabled])","a[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", ");return Array.from(this.dialogElement.querySelectorAll(e))}trapFocus(){const e=this.getFocusableElements();e.length>0&&e[0].focus()}handleConfirm(){var e,i;(i=(e=this.callbacks).onConfirm)==null||i.call(e),this.close()}handleCancel(){var e,i;(i=(e=this.callbacks).onCancel)==null||i.call(e),this.close()}destroy(){this.overlayElement&&(this.overlayElement.remove(),this.overlayElement=null),this.dialogElement&&(this.dialogElement.remove(),this.dialogElement=null),document.body.classList.remove("dialog-open")}escapeHtml(e){const i=document.createElement("div");return i.textContent=e,i.innerHTML}static renderField(e){const i=e,n=i.title??e.label??"削除確認",s=i.message??e.description??"この操作は取り消せません。本当に削除しますか?",a=i.cancelLabel??"キャンセル",r=i.confirmLabel??"削除する",o=i.targetName??"",l=`
|
|
398
|
+
<div class="delete-confirm-dialog-preview">
|
|
399
|
+
<div class="dialog-header">
|
|
400
|
+
<h3>${m(n)}</h3>
|
|
401
|
+
</div>
|
|
402
|
+
<div class="dialog-body">
|
|
403
|
+
${o?`<p class="dialog-target"><strong>対象:</strong> ${m(o)}</p>`:""}
|
|
404
|
+
<p class="dialog-message">${m(s)}</p>
|
|
405
|
+
</div>
|
|
406
|
+
<div class="dialog-footer">
|
|
407
|
+
<button type="button" class="dialog-button dialog-cancel">${m(a)}</button>
|
|
408
|
+
<button type="button" class="dialog-button dialog-confirm dialog-danger">${m(r)}</button>
|
|
409
|
+
</div>
|
|
410
|
+
</div>
|
|
411
|
+
`;return y(e,l)}}function hr(){return typeof window<"u"&&window.faker?window.faker:null}function ur(t,e){const i=hr(),n=t.toLowerCase();if(i){try{i.locale="ja"}catch{}if(n.includes("名前")||n.includes("氏名")||n.includes("name"))return i.person.fullName();if(n.includes("姓")||n.includes("苗字"))return i.person.lastName();if(n.includes("名")&&!n.includes("名前"))return i.person.firstName();if(n.includes("メール")||n.includes("email"))return i.internet.email();if(n.includes("電話")||n.includes("tel")||n.includes("phone"))return i.phone.number();if(n.includes("住所")||n.includes("address"))return i.location.streetAddress();if(n.includes("都道府県")||n.includes("県"))return i.location.state();if(n.includes("市区町村")||n.includes("市"))return i.location.city();if(n.includes("郵便番号")||n.includes("zip"))return i.location.zipCode();if(n.includes("会社")||n.includes("company")||n.includes("施設"))return i.company.name();if(n.includes("部署")||n.includes("department"))return i.commerce.department();if(n.includes("人数")||n.includes("収容"))return i.number.int({min:1,max:100});if(n.includes("金額")||n.includes("価格")||n.includes("price"))return i.number.int({min:1e3,max:1e5});if(n.includes("広さ")||n.includes("面積"))return i.number.int({min:10,max:500});if(n.includes("日付")||n.includes("日時")||n.includes("date"))return i.date.recent().toLocaleDateString("ja-JP");if(n.includes("作成日")||n.includes("登録日"))return i.date.past().toLocaleDateString("ja-JP");if(n.includes("更新日"))return i.date.recent().toLocaleDateString("ja-JP");if(n.includes("ステータス")||n.includes("status")||n.includes("状態")){const s=["有効","無効","保留中","承認済み","公開","非公開","下書き"];return s[e%s.length]}return n.includes("id")||n.includes("番号")?i.string.alphanumeric(8).toUpperCase():n.includes("説明")||n.includes("description")?i.lorem.sentence():n.includes("備考")||n.includes("メモ")||n.includes("note")?i.lorem.words(5):i.lorem.words(2)}return`${t} ${e+1}`}function pr(t,e){const i={id:e+1};for(const n of t)i[n.id]=ur(n.label,e);return i}function fr(t,e=10){const i=[];for(let n=0;n<e;n++)i.push(pr(t,n));return i}function A(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}function mr(t){return`${t}-${Math.random().toString(36).substring(2,11)}`}function gr(t,e){var i,n;if(t==null)return"-";switch(e.format){case"number":return Number(t).toLocaleString("ja-JP");case"currency":{const s=((i=e.currency_format)==null?void 0:i.locale)??"ja-JP",a=((n=e.currency_format)==null?void 0:n.currency)??"JPY";return new Intl.NumberFormat(s,{style:"currency",currency:a}).format(Number(t))}case"date":{const s=new Date(String(t));return isNaN(s.getTime())?String(t):s.toLocaleDateString("ja-JP")}case"datetime":{const s=new Date(String(t));return isNaN(s.getTime())?String(t):s.toLocaleString("ja-JP")}case"status":{const a=(e.status_map??{})[String(t)];return a?a.label:String(t)}case"text":default:return String(t)}}function br(t,e){if(e.format!=="status"||!e.status_map)return"";const i=e.status_map[String(t)];return i?`status-badge status-${i.color}`:"status-badge status-default"}function vr(t){return typeof t.fixed_header=="boolean"?{enabled:t.fixed_header,offset:0}:t.fixed_header?{enabled:t.fixed_header.enabled!==!1,offset:t.fixed_header.offset??0}:{enabled:!1,offset:0}}function xr(t){return typeof t.column_resize=="boolean"?{enabled:t.column_resize,minWidth:50,maxWidth:500}:t.column_resize?{enabled:t.column_resize.enabled!==!1,minWidth:t.column_resize.min_width??50,maxWidth:t.column_resize.max_width??500}:{enabled:!1,minWidth:50,maxWidth:500}}function yr(t,e){return t.map(i=>{const n=i.style?`btn-${i.style}`:"btn-link",s=i.icon?`<span class="action-icon">${A(i.icon)}</span>`:"";return`
|
|
412
|
+
<button
|
|
413
|
+
type="button"
|
|
414
|
+
class="btn btn-sm ${n} row-action-btn"
|
|
415
|
+
data-action-id="${A(i.id)}"
|
|
416
|
+
data-row-id="${A(String(e.id))}"
|
|
417
|
+
${i.confirm?`data-confirm-title="${A(i.confirm.title)}" data-confirm-message="${A(i.confirm.message)}"`:""}
|
|
418
|
+
>
|
|
419
|
+
${s}
|
|
420
|
+
<span class="action-label">${A(i.label)}</span>
|
|
421
|
+
</button>
|
|
422
|
+
`}).join("")}function Cr(t){var w,z;const e=["mokkun-data-table"];t.striped&&e.push("striped"),t.hoverable!==!1&&e.push("hoverable"),t.bordered&&e.push("bordered"),t.compact&&e.push("compact"),t.responsive!==!1&&e.push("responsive");const i=vr(t);i.enabled&&e.push("fixed-header");const n=xr(t);n.enabled&&e.push("resizable-columns"),(w=t.grouping)!=null&&w.enabled&&e.push("grouped"),t.layout==="fixed"&&e.push("layout-fixed");const s=mr("data-table");let a=t.data??[];if(a.length===0&&t.columns.length>0){const b=((z=t.pagination)==null?void 0:z.page_size)??10;a=fr(t.columns,b)}const r=t.height?`max-height: ${t.height};`:"",o=t.columns.map(b=>{const de=b.sortable!==!1?"sortable":"",te=b.align?`align-${b.align}`:"",he=b.fixed?`fixed-${b.fixed}`:"",D=b.width?`width: ${b.width};`:"",Se=n.enabled&&b.resizable!==!1?`<span class="column-resize-handle" data-column-id="${A(b.id)}"></span>`:"",Le=b.colspan&&Number.isInteger(b.colspan)&&b.colspan>0?`colspan="${b.colspan}"`:"",$e=b.rowspan&&Number.isInteger(b.rowspan)&&b.rowspan>0?`rowspan="${b.rowspan}"`:"";return`
|
|
423
|
+
<th class="data-table-th ${de} ${te} ${he}" data-column-id="${A(b.id)}" style="${D}" ${Le} ${$e}>
|
|
424
|
+
<span class="th-content">${A(b.label)}</span>
|
|
425
|
+
${Se}
|
|
426
|
+
</th>
|
|
427
|
+
`}).join(""),l=t.selection==="multiple"?'<th class="data-table-th selection-header"><input type="checkbox" class="select-all-checkbox" /></th>':t.selection==="single"?'<th class="data-table-th selection-header"></th>':"",d=t.row_actions&&t.row_actions.length>0?'<th class="data-table-th actions-header">操作</th>':"";let p;if(a.length===0){const b=t.empty_state??{},de=b.title??"データがありません",te=b.description??"",he=b.icon??"📭";let D=t.columns.length;t.selection&&t.selection!=="none"&&D++,t.row_actions&&t.row_actions.length>0&&D++;const ue=b.action?`<button type="button" class="btn btn-primary empty-state-action" data-handler="${A(b.action.handler)}">${A(b.action.label)}</button>`:"";p=`
|
|
428
|
+
<tr class="empty-state-row">
|
|
429
|
+
<td colspan="${D}" class="empty-state-cell">
|
|
430
|
+
<div class="empty-state">
|
|
431
|
+
<div class="empty-state-icon-wrapper">
|
|
432
|
+
<span class="empty-state-icon">${A(he)}</span>
|
|
433
|
+
</div>
|
|
434
|
+
<div class="empty-state-content">
|
|
435
|
+
<h4 class="empty-state-title">${A(de)}</h4>
|
|
436
|
+
${te?`<p class="empty-state-description">${A(te)}</p>`:""}
|
|
437
|
+
</div>
|
|
438
|
+
${ue?`<div class="empty-state-actions">${ue}</div>`:""}
|
|
439
|
+
</div>
|
|
440
|
+
</td>
|
|
441
|
+
</tr>
|
|
442
|
+
`}else p=a.map(b=>{const de=t.columns.map(D=>{var Ti;const ue=D.field??D.id,Se=b[ue],Le=gr(Se,D),$e=br(Se,D),Kr=D.align?`align-${D.align}`:"",Qr=D.fixed?`fixed-${D.fixed}`:"",F=(Ti=b._cellMerge)==null?void 0:Ti[D.id];if(F!=null&&F.hidden)return"";const Jr=F!=null&&F.colspan&&Number.isInteger(F.colspan)&&F.colspan>0?`colspan="${F.colspan}"`:"",Xr=F!=null&&F.rowspan&&Number.isInteger(F.rowspan)&&F.rowspan>0?`rowspan="${F.rowspan}"`:"",eo=$e?`<span class="${$e}">${A(Le)}</span>`:A(Le);return`<td class="data-table-td ${Kr} ${Qr}" ${Jr} ${Xr}>${eo}</td>`}).join(""),te=t.selection==="multiple"?`<td class="data-table-td selection-cell"><input type="checkbox" class="row-checkbox" data-row-id="${A(String(b.id))}" /></td>`:t.selection==="single"?`<td class="data-table-td selection-cell"><input type="radio" name="${s}-selection" class="row-radio" data-row-id="${A(String(b.id))}" /></td>`:"",he=t.row_actions&&t.row_actions.length>0?`<td class="data-table-td actions-cell">${yr(t.row_actions,b)}</td>`:"";return`
|
|
443
|
+
<tr class="data-table-tr" data-row-id="${A(String(b.id))}">
|
|
444
|
+
${te}
|
|
445
|
+
${de}
|
|
446
|
+
${he}
|
|
447
|
+
</tr>
|
|
448
|
+
`}).join("");const u=t.required?'<span class="required-mark">*</span>':"",f=t.description?`<p class="field-description">${A(t.description)}</p>`:"",g=i.enabled?`top: ${i.offset}px;`:"",x=i.enabled?"data-table-thead sticky-header":"data-table-thead",C=a.length===0?"data-table-tbody data-table-empty-tbody":"data-table-tbody";return`
|
|
449
|
+
<div class="form-field field-type-data_table" data-field-id="${A(t.id)}">
|
|
450
|
+
<label class="field-label">${A(t.label)}${u}</label>
|
|
451
|
+
${f}
|
|
452
|
+
<div class="${e.join(" ")}" data-table-id="${s}">
|
|
453
|
+
<div class="data-table-wrapper" style="${r}">
|
|
454
|
+
<table class="data-table">
|
|
455
|
+
<thead class="${x}" style="${g}">
|
|
456
|
+
<tr>
|
|
457
|
+
${l}
|
|
458
|
+
${o}
|
|
459
|
+
${d}
|
|
460
|
+
</tr>
|
|
461
|
+
</thead>
|
|
462
|
+
<tbody class="${C}">
|
|
463
|
+
${p}
|
|
464
|
+
</tbody>
|
|
465
|
+
</table>
|
|
466
|
+
</div>
|
|
467
|
+
</div>
|
|
468
|
+
</div>
|
|
469
|
+
`}function kr(t){return`${t}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`}function ce(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}function wr(t){const e=kr("photo-manager"),i=t.photos??[],n=t.max_photos??20,s=t.max_file_size??10,a=t.accepted_formats??["JPG","PNG"],r=t.columns??4,o=`
|
|
470
|
+
<div class="photo-upload-area" data-manager-id="${e}">
|
|
471
|
+
<div class="upload-icon">📷</div>
|
|
472
|
+
<div class="upload-text">ここにファイルをドラッグ&ドロップ<br>または</div>
|
|
473
|
+
<button type="button" class="btn btn-primary photo-select-btn">ファイルを選択</button>
|
|
474
|
+
<input type="file" class="photo-file-input" accept="${a.map(u=>`.${u.toLowerCase()}`).join(",")}" multiple hidden />
|
|
475
|
+
<div class="upload-note">対応形式: ${a.join(", ")} / 最大${s}MB/枚 / 最大${n}枚まで</div>
|
|
476
|
+
</div>
|
|
477
|
+
`,l=`
|
|
478
|
+
<div class="photo-count">
|
|
479
|
+
登録済み写真: <strong>${i.length}枚</strong> / 上限${n}枚
|
|
480
|
+
</div>
|
|
481
|
+
`,d=i.length>0?`
|
|
482
|
+
<div class="photo-drag-hint">
|
|
483
|
+
💡 写真をドラッグ&ドロップして表示順序を変更できます
|
|
484
|
+
</div>
|
|
485
|
+
`:"",p=i.length>0?`
|
|
486
|
+
<div class="photo-grid" style="--photo-columns: ${r}" data-manager-id="${e}">
|
|
487
|
+
${i.map((u,f)=>{const g=u.is_main??f===0;return`
|
|
488
|
+
<div class="photo-item" data-photo-id="${ce(u.id)}" data-index="${f}" draggable="true">
|
|
489
|
+
<img src="${ce(u.src)}" alt="${ce(u.alt??`写真${f+1}`)}" loading="lazy" />
|
|
490
|
+
${g?'<span class="photo-main-badge">メイン</span>':""}
|
|
491
|
+
<span class="photo-order-badge">${f+1}</span>
|
|
492
|
+
<div class="photo-overlay">
|
|
493
|
+
<button type="button" class="btn btn-primary btn-sm photo-set-main-btn" ${g?"disabled":""}>メインに設定</button>
|
|
494
|
+
<button type="button" class="btn btn-danger btn-sm photo-delete-btn">削除</button>
|
|
495
|
+
</div>
|
|
496
|
+
</div>
|
|
497
|
+
`}).join("")}
|
|
498
|
+
</div>
|
|
499
|
+
`:`
|
|
500
|
+
<div class="photo-empty">
|
|
501
|
+
<p>写真が登録されていません</p>
|
|
502
|
+
</div>
|
|
503
|
+
`;return`
|
|
504
|
+
<div class="field-wrapper field-type-photo_manager">
|
|
505
|
+
${t.label?`<label class="field-label">${ce(t.label)}</label>`:""}
|
|
506
|
+
${t.description?`<p class="field-description">${ce(t.description)}</p>`:""}
|
|
507
|
+
<div
|
|
508
|
+
class="photo-manager"
|
|
509
|
+
id="${e}"
|
|
510
|
+
data-config='${JSON.stringify({maxPhotos:n,maxFileSize:s,acceptedFormats:a,columns:r})}'
|
|
511
|
+
role="region"
|
|
512
|
+
aria-label="${t.label??"写真管理"}"
|
|
513
|
+
>
|
|
514
|
+
${o}
|
|
515
|
+
${l}
|
|
516
|
+
${d}
|
|
517
|
+
${p}
|
|
518
|
+
</div>
|
|
519
|
+
</div>
|
|
520
|
+
`}function Er(t){const e=[j(t)];t.accept&&t.accept.length>0&&e.push(`accept="${t.accept.join(",")}"`),t.multiple&&e.push("multiple");const i=t.drag_drop?"with-dropzone":"";let n=`<input type="file" class="form-file" ${e.join(" ")} />`;if(t.drag_drop&&(n=`
|
|
521
|
+
<div class="file-dropzone ${i}">
|
|
522
|
+
${n}
|
|
523
|
+
<div class="dropzone-label">
|
|
524
|
+
ファイルをドラッグ&ドロップ または クリックして選択
|
|
525
|
+
</div>
|
|
526
|
+
</div>
|
|
527
|
+
`),t.max_size){const s=(t.max_size/1048576).toFixed(1);n+=`<p class="file-size-hint">最大ファイルサイズ: ${s} MB</p>`}return y(t,n)}function Ar(t){const e=t.height??"300",i=t.width??"100%",n=t.show_open_link!==!1,s=`
|
|
528
|
+
<div class="google-map-embed-container" data-field-id="${m(t.id)}">
|
|
529
|
+
<div class="google-map-embed-input-wrapper">
|
|
530
|
+
<input
|
|
531
|
+
type="text"
|
|
532
|
+
inputmode="url"
|
|
533
|
+
id="${m(t.id)}"
|
|
534
|
+
name="${m(t.id)}"
|
|
535
|
+
class="form-input google-map-embed-input"
|
|
536
|
+
placeholder="${m(t.placeholder??"Google Maps URL を入力してください")}"
|
|
537
|
+
maxlength="2048"
|
|
538
|
+
${t.required?"required":""}
|
|
539
|
+
${t.disabled?"disabled":""}
|
|
540
|
+
${t.readonly?"readonly":""}
|
|
541
|
+
/>
|
|
542
|
+
</div>
|
|
543
|
+
<div class="google-map-embed-error"></div>
|
|
544
|
+
<div class="google-map-embed-preview" data-height="${m(e)}" data-width="${m(i)}">
|
|
545
|
+
<div class="google-map-embed-placeholder">
|
|
546
|
+
Google Maps URL を入力すると、ここにプレビューが表示されます
|
|
547
|
+
</div>
|
|
548
|
+
</div>
|
|
549
|
+
${n?`
|
|
550
|
+
<div class="google-map-embed-link-container">
|
|
551
|
+
<a href="#" class="google-map-embed-open-link disabled" target="_blank" rel="noopener noreferrer" aria-disabled="true">
|
|
552
|
+
Googleマップで開く
|
|
553
|
+
</a>
|
|
554
|
+
</div>
|
|
555
|
+
`:""}
|
|
556
|
+
</div>
|
|
557
|
+
`;return y(t,s)}function Ir(t){const e=t.accepted_formats??["image/jpeg","image/png","image/webp"],i=t.max_file_size??5*1024*1024,n=t.max_files??10,s=e.map(ya).join(", "),a=xa(i),r=`
|
|
558
|
+
<div class="image-uploader-container"
|
|
559
|
+
data-field-id="${m(t.id)}"
|
|
560
|
+
data-accepted-formats="${m(e.join(","))}"
|
|
561
|
+
data-max-file-size="${i}"
|
|
562
|
+
data-max-files="${n}"
|
|
563
|
+
data-min-files="${t.min_files??0}">
|
|
564
|
+
<div class="uploader-wrapper">
|
|
565
|
+
<div class="upload-dropzone">
|
|
566
|
+
<input type="file"
|
|
567
|
+
class="file-input"
|
|
568
|
+
id="${m(t.id)}-input"
|
|
569
|
+
accept="${e.join(",")}"
|
|
570
|
+
multiple
|
|
571
|
+
${t.disabled?"disabled":""} />
|
|
572
|
+
<label class="dropzone-label" for="${m(t.id)}-input">
|
|
573
|
+
<div class="dropzone-icon">
|
|
574
|
+
<svg viewBox="0 0 24 24" width="48" height="48">
|
|
575
|
+
<path fill="currentColor" d="M19.35 10.04A7.49 7.49 0 0012 4C9.11 4 6.6 5.64 5.35 8.04A5.994 5.994 0 000 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM14 13v4h-4v-4H7l5-5 5 5h-3z"/>
|
|
576
|
+
</svg>
|
|
577
|
+
</div>
|
|
578
|
+
<span class="dropzone-text">クリックまたはドラッグ&ドロップで画像を追加</span>
|
|
579
|
+
</label>
|
|
580
|
+
</div>
|
|
581
|
+
<div class="uploader-hints">
|
|
582
|
+
<span class="hint-formats">対応形式: ${s}</span>
|
|
583
|
+
<span class="hint-size">最大サイズ: ${a}/枚</span>
|
|
584
|
+
<span class="hint-count">最大${n}枚</span>
|
|
585
|
+
</div>
|
|
586
|
+
<div class="image-grid"></div>
|
|
587
|
+
</div>
|
|
588
|
+
</div>
|
|
589
|
+
`;return y(t,r)}function Sr(t){const e=t.item_fields??[],i=t.max_items,n=m(t.add_button_label??"Add Item"),s=e.map(l=>ki(l)).join(""),a=i?`1 / ${i}`:"1 items",o=`
|
|
590
|
+
<div class="mokkun-repeater ${t.sortable?"sortable":""}">
|
|
591
|
+
<div class="repeater-wrapper">
|
|
592
|
+
<div class="repeater-header">
|
|
593
|
+
<span class="repeater-counter">${m(a)}</span>
|
|
594
|
+
</div>
|
|
595
|
+
<div class="repeater-items">
|
|
596
|
+
<div class="repeater-item expanded">
|
|
597
|
+
<div class="repeater-item-header">
|
|
598
|
+
${t.sortable?'<div class="repeater-item-handle"></div>':""}
|
|
599
|
+
<span class="repeater-item-number">#1</span>
|
|
600
|
+
<div class="repeater-item-spacer"></div>
|
|
601
|
+
</div>
|
|
602
|
+
<div class="repeater-item-content">
|
|
603
|
+
${s}
|
|
604
|
+
</div>
|
|
605
|
+
</div>
|
|
606
|
+
</div>
|
|
607
|
+
<div class="repeater-footer">
|
|
608
|
+
<button type="button" class="repeater-add-btn">${n}</button>
|
|
609
|
+
</div>
|
|
610
|
+
</div>
|
|
611
|
+
</div>
|
|
612
|
+
`;return y(t,o)}function ki(t){switch(t.type){case"text":case"number":case"date_picker":case"time_picker":return ee.renderField(t);case"textarea":return We.renderField(t);case"select":case"multi_select":return we.renderField(t);case"combobox":return fi.renderField(t);case"radio_group":return wa.renderField(t);case"checkbox":case"checkbox_group":return Ee.renderField(t);case"duration_picker":return Aa.renderField(t);case"duration_input":return Ia.renderField(t);case"file_upload":return Er(t);case"image_uploader":return Ir(t);case"repeater":return Sr(t);case"data_table":return Cr(t);case"google_map_embed":return Ar(t);case"photo_manager":return wr(t);case"heading":return Ea.renderField(t);case"pagination":return Sa.renderField(t);case"toggle":return La.renderField(t);case"badge":return $a.renderField(t);case"browser":return _a.renderField(t);case"calendar":return Na.renderField(t);case"tooltip":return mi.renderField(t);case"float_area":return Ta.renderField(t);case"loader":return Ma.renderField(t);case"notification_bar":return Oa.renderField(t);case"response_message":return Ra.renderField(t);case"timeline":return qa.renderField(t);case"chip":return Wa.renderField(t);case"status_label":return Ga.renderField(t);case"segmented_control":return Za.renderField(t);case"tabs":return Ka.renderField(t);case"line_clamp":return Qa.renderField(t);case"disclosure":return Ja.renderField(t);case"accordion_panel":return Xa.renderField(t);case"section_nav":return yi.renderField(t);case"definition_list":return nr.renderField(t);case"stepper":return or.renderField(t);case"information_panel":return cr.renderField(t);case"dropdown":return dr.renderField(t);case"delete_confirm_dialog":return Ci.renderField(t);default:return y(t,`<div class="unknown-field">不明なフィールドタイプ: ${t.type}</div>`)}}function Ke(t){return t.map(ki).join("")}function P(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}function Lr(t){switch(t){case"primary":return"btn btn-primary";case"secondary":return"btn btn-secondary";case"danger":return"btn btn-danger";case"link":return"btn btn-link";default:return"btn btn-secondary"}}function $r(t){const e=Lr(t.style),i=t.icon?`<span class="btn-icon">${P(t.icon)}</span>`:"",n=[`data-action-id="${P(t.id)}"`,`data-action-type="${P(t.type)}"`];return t.type==="navigate"&&n.push(`data-navigate-to="${P(t.to)}"`),t.type==="custom"&&n.push(`data-handler="${P(t.handler)}"`),t.type==="submit"&&t.url&&(n.push(`data-url="${P(t.url)}"`),t.method&&n.push(`data-method="${P(t.method)}"`)),t.confirm&&(n.push(`data-confirm-title="${P(t.confirm.title)}"`),n.push(`data-confirm-message="${P(t.confirm.message)}"`)),`
|
|
613
|
+
<button
|
|
614
|
+
type="${t.type==="submit"?"submit":t.type==="reset"?"reset":"button"}"
|
|
615
|
+
class="${e}"
|
|
616
|
+
${n.join(" ")}
|
|
617
|
+
>
|
|
618
|
+
${i}
|
|
619
|
+
<span class="btn-label">${P(t.label)}</span>
|
|
620
|
+
</button>
|
|
621
|
+
`}function _r(t){return t.length===0?"":`<div class="actions">${t.map($r).join("")}</div>`}function U(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}function Nr(t){if(!t)return"";const e=[];return t.columns&&t.columns>1&&(e.push("display: grid"),e.push(`grid-template-columns: repeat(${t.columns}, 1fr)`)),t.gap&&e.push(`gap: ${t.gap}`),e.length>0?`style="${e.join("; ")}"`:""}function Qe(t){const e=t.description?`<p class="screen-description">${U(t.description)}</p>`:"";return`
|
|
622
|
+
<header class="screen-header">
|
|
623
|
+
<h1 class="screen-title">${U(t.title)}</h1>
|
|
624
|
+
${e}
|
|
625
|
+
</header>
|
|
626
|
+
`}function Tr(t){if(!t.fields||t.fields.length===0)return"";const e=Nr(t.layout),i=Ke(t.fields);return`
|
|
627
|
+
<div class="fields-section" ${e}>
|
|
628
|
+
${i}
|
|
629
|
+
</div>
|
|
630
|
+
`}function wi(t){return!t.actions||t.actions.length===0?"":`
|
|
631
|
+
<div class="actions-section">
|
|
632
|
+
${_r(t.actions)}
|
|
633
|
+
</div>
|
|
634
|
+
`}function Mr(t,e){return!t.wizard||!t.wizard.show_progress?"":`
|
|
635
|
+
<div class="wizard-progress">
|
|
636
|
+
${t.wizard.steps.map((s,a)=>{const r=["wizard-progress-step"];return a<e?r.push("completed"):a===e&&r.push("current"),`
|
|
637
|
+
<div class="${r.join(" ")}" data-step-index="${a}">
|
|
638
|
+
<span class="step-number">${a+1}</span>
|
|
639
|
+
<span class="step-title">${U(s.title)}</span>
|
|
640
|
+
</div>
|
|
641
|
+
`}).join("")}
|
|
642
|
+
</div>
|
|
643
|
+
`}function Dr(t,e){if(!t.wizard)return"";const i=t.wizard.steps[e];if(!i)return'<div class="error">無効なステップです</div>';const n=e===0,s=e===t.wizard.steps.length-1,a=t.wizard.allow_back??!0,r=i.description?`<p class="wizard-step-description">${U(i.description)}</p>`:"",o=Ke(i.fields),l=!n&&a?`<button type="button" class="btn btn-secondary wizard-back" data-step="${e-1}">戻る</button>`:"",d=s?"":`<button type="button" class="btn btn-primary wizard-next" data-step="${e+1}">次へ</button>`,p=s?'<button type="submit" class="btn btn-primary wizard-submit">送信</button>':"";return`
|
|
644
|
+
<div class="wizard-step" data-step-id="${U(i.id)}" data-step-index="${e}">
|
|
645
|
+
<h2 class="wizard-step-title">${U(i.title)}</h2>
|
|
646
|
+
${r}
|
|
647
|
+
<div class="wizard-step-fields">
|
|
648
|
+
${o}
|
|
649
|
+
</div>
|
|
650
|
+
<div class="wizard-navigation">
|
|
651
|
+
${l}
|
|
652
|
+
${d}
|
|
653
|
+
${p}
|
|
654
|
+
</div>
|
|
655
|
+
</div>
|
|
656
|
+
`}function Ei(t,e=0){if(!t.wizard)return Je(t);const i=Mr(t,e),n=Dr(t,e);return`
|
|
657
|
+
<div class="screen wizard-screen">
|
|
658
|
+
${Qe(t)}
|
|
659
|
+
${i}
|
|
660
|
+
<form class="wizard-form" data-current-step="${e}">
|
|
661
|
+
${n}
|
|
662
|
+
</form>
|
|
663
|
+
</div>
|
|
664
|
+
`}function Ai(t,e){return`section-${t.toLowerCase().replace(/[^a-z0-9\u3040-\u309f\u30a0-\u30ff\u4e00-\u9faf]/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,"")||e}`}function Fr(t){if(!t.sections||t.sections.length===0)return Je(t);const e=Ii(t),i=Qe(t),n=wi(t),s=t.sections.map((a,r)=>{const o=Ai(a.section_name,r),l=a.input_fields,d=l&&l.length>0?Ke(l):"",p=a.publish_toggle?`<div class="section-publish-toggle">
|
|
665
|
+
<label class="checkbox-option">
|
|
666
|
+
<input type="checkbox" name="${o}_publish" />
|
|
667
|
+
<span>このセクションを公開する</span>
|
|
668
|
+
</label>
|
|
669
|
+
</div>`:"";return`
|
|
670
|
+
<section id="${U(o)}" class="form-section">
|
|
671
|
+
<h2 class="section-title">
|
|
672
|
+
${a.icon?`<span class="section-icon">${U(a.icon)}</span>`:""}
|
|
673
|
+
${U(a.section_name)}
|
|
674
|
+
</h2>
|
|
675
|
+
${p}
|
|
676
|
+
<div class="section-fields">
|
|
677
|
+
${d}
|
|
678
|
+
</div>
|
|
679
|
+
</section>
|
|
680
|
+
`}).join("");return`
|
|
681
|
+
<div class="screen screen-with-sections">
|
|
682
|
+
${e}
|
|
683
|
+
${i}
|
|
684
|
+
<div id="section-nav-container" class="section-nav-container"></div>
|
|
685
|
+
<form class="screen-form">
|
|
686
|
+
${s}
|
|
687
|
+
${n}
|
|
688
|
+
</form>
|
|
689
|
+
</div>
|
|
690
|
+
`}function Ii(t){const e=t.app_header?'<div id="app-header-container" class="app-header-container"></div>':"",i=t.app_navi?'<div id="app-navi-container" class="app-navi-container"></div>':"";return e+i}function Je(t){if(t.wizard)return Ei(t,0);if(t.sections&&t.sections.length>0)return Fr(t);const e=Ii(t),i=Qe(t),n=Tr(t),s=wi(t);return`
|
|
691
|
+
<div class="screen">
|
|
692
|
+
${e}
|
|
693
|
+
${i}
|
|
694
|
+
<form class="screen-form">
|
|
695
|
+
${n}
|
|
696
|
+
${s}
|
|
697
|
+
</form>
|
|
698
|
+
</div>
|
|
699
|
+
`}function Or(t,e){if(!e.sections||e.sections.length===0)return null;const i=t.querySelector("#section-nav-container");if(!i)return null;const n=e.sections.map((a,r)=>({id:Ai(a.section_name,r),label:a.section_name,icon:a.icon})),s=new yi({sections:n,scrollOffset:120,mobileMode:"scroll",stickyTop:"60px"},i);return s.render(),{getActiveSection:()=>s.getActiveSection(),scrollToSection:a=>s.scrollToSection(a),destroy:()=>s.destroy()}}function Hr(t,e,i=0){let n=i;function s(){t.innerHTML=Ei(e,n),a()}function a(){t.querySelectorAll(".wizard-next").forEach(r=>{r.addEventListener("click",()=>{e.wizard&&n<e.wizard.steps.length-1&&(n++,s())})}),t.querySelectorAll(".wizard-back").forEach(r=>{r.addEventListener("click",()=>{n>0&&(n--,s())})})}return s(),{getCurrentStep:()=>n,goToStep:r=>{e.wizard&&r>=0&&r<e.wizard.steps.length&&(n=r,s())},nextStep:()=>{e.wizard&&n<e.wizard.steps.length-1&&(n++,s())},prevStep:()=>{n>0&&(n--,s())}}}class zr{constructor(e,i={},n=new Map){h(this,"container");h(this,"callbacks");h(this,"deleteConfirmConfigs");h(this,"boundClickHandler");this.container=e,this.callbacks=i,this.deleteConfirmConfigs=n,this.boundClickHandler=this.handleClick.bind(this)}attach(){this.container.addEventListener("click",this.boundClickHandler)}detach(){this.container.removeEventListener("click",this.boundClickHandler)}registerDeleteConfirmConfig(e,i){this.deleteConfirmConfigs.set(e,i)}handleClick(e){const n=e.target.closest("[data-action-id]");if(!n)return;const s=n.dataset.actionId,a=n.dataset.actionType;if(!s||!a)return;const r=n.dataset.confirmTitle,o=n.dataset.confirmMessage;if(r&&o){e.preventDefault(),this.showConfirmDialog(n,s,a,r,o);return}this.executeAction(n,s,a)}async showConfirmDialog(e,i,n,s,a){const r=this.deleteConfirmConfigs.get(i);let o;if(r!=null&&r.getDependencies){const u=r.getDependencies();o=u instanceof Promise?await u:u}let l=a;r!=null&&r.getTargetName&&(l=r.getTargetName());const d={title:s,targetName:l,targetType:r==null?void 0:r.targetType,dependencies:o,warningMessage:r==null?void 0:r.warningMessage,danger:!0};new Ci(d,{onConfirm:()=>{this.executeAction(e,i,n)},onCancel:()=>{var u,f;(f=(u=this.callbacks).onCancel)==null||f.call(u,i)}}).open()}executeAction(e,i,n){var s,a,r,o,l,d,p,u;switch(n){case"submit":{const f=e.dataset.url,g=e.dataset.method;(a=(s=this.callbacks).onSubmit)==null||a.call(s,i,f,g);break}case"navigate":{const f=e.dataset.navigateTo;f&&((o=(r=this.callbacks).onNavigate)==null||o.call(r,i,f));break}case"custom":{const f=e.dataset.handler;f&&((d=(l=this.callbacks).onCustom)==null||d.call(l,i,f));break}case"reset":{(u=(p=this.callbacks).onReset)==null||u.call(p,i);break}}}}function Br(t,e={},i){const n=new zr(t,e,i);return n.attach(),n}const Si=[".yaml",".yml"],Li=["https:","http:"];function Rr(t){const e=t.toLowerCase();return Si.some(i=>e.endsWith(i))}function Pr(t){return{type:"INVALID_FILE_TYPE",message:`無効なファイル形式: ${t}`,details:`YAMLファイル(${Si.join(", ")})のみ対応しています`}}function Vr(t,e,i){const n=Ue(t);return n.success?{success:!0,schema:n.data,fileName:e,source:i}:{success:!1,error:{type:"YAML_PARSE_ERROR",message:"YAMLのパースに失敗しました",details:ba(n.errors),parseErrors:n.errors}}}async function jr(t){const e=new URL(t,window.location.href),i=e.pathname.split("/"),n=i[i.length-1]||"unknown.yaml";if(!Li.includes(e.protocol))return{success:!1,error:{type:"FETCH_ERROR",message:"無効なURLプロトコル",details:`許可されているプロトコル: ${Li.join(", ")}`}};if(!Rr(n))return{success:!1,error:Pr(n)};try{const s=await fetch(t);if(!s.ok)return{success:!1,error:{type:"FETCH_ERROR",message:`ファイルの取得に失敗しました: ${t}`,details:`HTTPステータス: ${s.status} ${s.statusText}`}};const a=await s.text();return Vr(a,n,"url")}catch(s){const a=s instanceof Error?s.message:String(s);return{success:!1,error:{type:"NETWORK_ERROR",message:`ネットワークエラー: ${t}`,details:a}}}}const Xe="mokkun-theme",$i="data-theme",et="mokkun-theme-change",Ur=[{id:"light",name:"ライト",description:"デフォルトの明るいテーマ",isBuiltIn:!0},{id:"dark",name:"ダーク",description:"目に優しいダークテーマ",isBuiltIn:!0}],tt="light";class qr{constructor(){h(this,"themes");h(this,"currentThemeId");h(this,"config");h(this,"customStyleElement");this.themes=new Map,this.currentThemeId=null,this.config=null,this.customStyleElement=null,Ur.forEach(e=>{this.themes.set(e.id,e)})}initialize(){var n;const e=this.getSavedTheme(),i=e&&this.themes.has(e)?e:((n=this.config)==null?void 0:n.default_theme)??tt;this.applyTheme(i)}loadConfig(e){try{this.config=ai(e),this.config.custom_themes&&this.config.custom_themes.forEach(i=>{const n={id:i.id,name:i.name,description:i.description,isBuiltIn:!1,cssVariables:i.css_variables};this.themes.set(n.id,n)})}catch(i){console.error("Failed to load theme config:",i)}}getAvailableThemes(){return Array.from(this.themes.values())}getCurrentTheme(){return this.currentThemeId}getTheme(e){return this.themes.get(e)}hasTheme(e){return this.themes.has(e)}applyTheme(e){const i=this.themes.get(e);if(!i)return console.warn(`Theme not found: ${e}`),!1;const n=this.currentThemeId;return document.documentElement.setAttribute($i,e),!i.isBuiltIn&&i.cssVariables?this.applyCustomVariables(i.cssVariables):this.removeCustomVariables(),this.currentThemeId=e,this.saveTheme(e),this.dispatchThemeChangeEvent(n,e),!0}applyCustomVariables(e){this.removeCustomVariables();const i=Object.entries(e).map(([s,a])=>` ${s}: ${a};`).join(`
|
|
700
|
+
`),n=`[${$i}] {
|
|
701
|
+
${i}
|
|
702
|
+
}`;this.customStyleElement=document.createElement("style"),this.customStyleElement.id="mokkun-custom-theme",this.customStyleElement.textContent=n,document.head.appendChild(this.customStyleElement)}removeCustomVariables(){this.customStyleElement&&(this.customStyleElement.remove(),this.customStyleElement=null)}registerTheme(e){this.themes.set(e.id,{...e,isBuiltIn:!1})}unregisterTheme(e){const i=this.themes.get(e);return!i||i.isBuiltIn?!1:(this.themes.delete(e),this.currentThemeId===e&&this.applyTheme(tt),!0)}saveTheme(e){try{localStorage.setItem(Xe,e)}catch(i){console.warn("Failed to save theme preference:",i)}}getSavedTheme(){try{return localStorage.getItem(Xe)}catch(e){return console.warn("Failed to read theme preference:",e),null}}clearSavedTheme(){try{localStorage.removeItem(Xe)}catch(e){console.warn("Failed to clear theme preference:",e)}}dispatchThemeChangeEvent(e,i){const n={previousTheme:e,currentTheme:i},s=new CustomEvent(et,{bubbles:!0,detail:n});document.dispatchEvent(s)}onThemeChange(e){const i=n=>{e(n.detail)};return document.addEventListener(et,i),()=>{document.removeEventListener(et,i)}}getDefaultTheme(){var e;return((e=this.config)==null?void 0:e.default_theme)??tt}prefersColorScheme(){return typeof window>"u"||typeof window.matchMedia!="function"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}applySystemPreference(){const e=this.prefersColorScheme();this.applyTheme(e)}watchSystemPreference(e=!1){if(typeof window>"u")return()=>{};const i=window.matchMedia("(prefers-color-scheme: dark)"),n=s=>{e&&this.applyTheme(s.matches?"dark":"light")};return i.addEventListener("change",n),()=>{i.removeEventListener("change",n)}}}const Ie=new qr,Wr=()=>Ie.initialize(),it=t=>Ie.applyTheme(t),Yr=()=>Ie.getAvailableThemes(),_i=()=>Ie.getCurrentTheme();function Gr(t){const e=()=>{if(!t.schema||!t.currentScreenName)return;const n=qe(t.schema,t.currentScreenName);if(!n)return;t.sectionNavController&&(t.sectionNavController.destroy(),t.sectionNavController=null),t.actionHandler&&(t.actionHandler.detach(),t.actionHandler=null),t.wizardController=null,n.wizard?t.wizardController=Hr(t.container,n,0):(t.container.innerHTML=Je(n),n.sections&&n.sections.length>0&&(t.sectionNavController=Or(t.container,n)));const s={onNavigate:(a,r)=>{var l,d;const o=t.currentScreenName;i.showScreen(r),o&&((d=(l=t.options).onNavigate)==null||d.call(l,o,r))},onSubmit:(a,r,o)=>{var d,p;const l=i.getFormData();l&&t.currentScreenName&&((p=(d=t.options).onSubmit)==null||p.call(d,t.currentScreenName,l))},onReset:()=>{const a=t.container.querySelector("form");a==null||a.reset()},onCancel:()=>{},onCustom:()=>{}};t.actionHandler=Br(t.container,s)},i={get schema(){return t.schema},get currentScreen(){return t.currentScreenName},showScreen(n){if(!t.schema)return;if(!qe(t.schema,n)){console.warn(`[Mokkun] Screen not found: ${n}`);return}t.currentScreenName=n,e()},getScreenNames(){return t.schema?hi(t.schema):[]},setTheme(n){it(n)},getTheme(){return _i()},getFormData(){const n=t.container.querySelector("form");if(!n)return null;const s=new FormData(n),a={};return s.forEach((r,o)=>{Object.prototype.hasOwnProperty.call(a,o)?Array.isArray(a[o])?a[o].push(r):a[o]=[a[o],r]:a[o]=r}),a},destroy(){t.sectionNavController&&t.sectionNavController.destroy(),t.actionHandler&&t.actionHandler.detach(),t.container.innerHTML="",t.schema=null,t.currentScreenName=null,t.sectionNavController=null,t.wizardController=null,t.actionHandler=null}};return i}async function Zr(t){var n,s,a;const e=typeof t.container=="string"?document.querySelector(t.container):t.container;if(!e){const r=new Error(`[Mokkun] Container not found: ${t.container}`);throw(n=t.onError)==null||n.call(t,r),r}t.theme?it(t.theme):Wr();const i={container:e,schema:null,currentScreenName:null,sectionNavController:null,wizardController:null,actionHandler:null,options:t};try{if(t.yamlContent){const d=Ue(t.yamlContent);if(!d.success)throw new Error(`[Mokkun] YAML parse error: ${d.errors.map(p=>p.message).join(", ")}`);i.schema=d.data}else if(t.yamlUrl){const d=await jr(t.yamlUrl);if(!d.success)throw new Error(`[Mokkun] Failed to load YAML: ${d.error.message}`);i.schema=d.schema}else throw new Error("[Mokkun] Either yamlUrl or yamlContent must be provided");const r=Gr(i),o=r.getScreenNames(),l=t.initialScreen&&o.includes(t.initialScreen)?t.initialScreen:o[0];return l&&r.showScreen(l),(s=t.onReady)==null||s.call(t,r),r}catch(r){const o=r instanceof Error?r:new Error(String(r));throw(a=t.onError)==null||a.call(t,o),o}}const Ni={init:Zr,VERSION:"0.1.0",utils:{parseYaml:Ue,getScreen:qe,getScreenNames:hi,findFieldById:ui},theme:{apply:it,getCurrent:_i,getAvailable:Yr}};typeof window<"u"&&(window.Mokkun=Ni),N.Combobox=fi,N.Mokkun=Ni,N.Textarea=We,N.createTextarea=Ca,Object.defineProperty(N,Symbol.toStringTag,{value:"Module"})}));
|
|
703
|
+
//# sourceMappingURL=mokkun.js.map
|