godown 3.13.4 → 3.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (278) hide show
  1. package/build/alert.js +1 -1
  2. package/build/avatar.js +1 -1
  3. package/build/badge.js +1 -1
  4. package/build/breath.js +1 -1
  5. package/build/button.js +1 -1
  6. package/build/card.js +1 -1
  7. package/build/carousel.js +1 -1
  8. package/build/chip.js +1 -1
  9. package/build/details.js +1 -1
  10. package/build/dialog.js +1 -1
  11. package/build/divider.js +1 -1
  12. package/build/dragbox.js +1 -1
  13. package/build/flex.js +1 -1
  14. package/build/form.js +1 -1
  15. package/build/godown.iife.js +16 -16
  16. package/build/godown.iife.js.map +1 -1
  17. package/build/godown.umd.js +16 -16
  18. package/build/godown.umd.js.map +1 -1
  19. package/build/grid.js +1 -1
  20. package/build/heading.js +1 -1
  21. package/build/index.d.ts +1 -1
  22. package/build/index.d.ts.map +1 -1
  23. package/build/index.js +1 -1
  24. package/build/input.js +1 -1
  25. package/build/internal/global-style.d.ts.map +1 -1
  26. package/build/internal/global-style.js +1 -1
  27. package/build/internal/global-style.js.map +1 -1
  28. package/build/internal/icons/caret-down.d.ts.map +1 -1
  29. package/build/internal/icons/caret-down.js +1 -1
  30. package/build/internal/icons/caret-down.js.map +1 -1
  31. package/build/internal/icons/caret-left.d.ts.map +1 -1
  32. package/build/internal/icons/caret-left.js +1 -1
  33. package/build/internal/icons/caret-left.js.map +1 -1
  34. package/build/internal/icons/caret-right.d.ts.map +1 -1
  35. package/build/internal/icons/caret-right.js +1 -1
  36. package/build/internal/icons/caret-right.js.map +1 -1
  37. package/build/internal/icons/eye-slash.d.ts.map +1 -1
  38. package/build/internal/icons/eye-slash.js +1 -1
  39. package/build/internal/icons/eye-slash.js.map +1 -1
  40. package/build/internal/popover.d.ts +1 -1
  41. package/build/internal/popover.d.ts.map +1 -1
  42. package/build/internal/popover.js +1 -1
  43. package/build/internal/popover.js.map +1 -1
  44. package/build/internal/reset-style.d.ts.map +1 -1
  45. package/build/internal/reset-style.js +2 -2
  46. package/build/internal/reset-style.js.map +1 -1
  47. package/build/internal/ring.d.ts.map +1 -1
  48. package/build/internal/ring.js +1 -1
  49. package/build/internal/ring.js.map +1 -1
  50. package/build/internal/super-input.d.ts.map +1 -1
  51. package/build/internal/super-input.js +2 -2
  52. package/build/internal/super-input.js.map +1 -1
  53. package/build/internal/utils.d.ts.map +1 -1
  54. package/build/internal/utils.js +1 -1
  55. package/build/internal/utils.js.map +1 -1
  56. package/build/layout.js +1 -1
  57. package/build/link.js +1 -1
  58. package/build/popover.js +1 -1
  59. package/build/progress.js +1 -1
  60. package/build/range.js +1 -1
  61. package/build/rotate.js +1 -1
  62. package/build/router.js +1 -1
  63. package/build/select.js +1 -1
  64. package/build/skeleton.js +1 -1
  65. package/build/split.js +1 -1
  66. package/build/switch.js +1 -1
  67. package/build/tabs.js +1 -1
  68. package/build/text.js +1 -1
  69. package/build/time.js +1 -1
  70. package/build/tooltip.js +1 -1
  71. package/build/typewriter.js +1 -1
  72. package/build/web-components/alert/component.d.ts.map +1 -1
  73. package/build/web-components/alert/component.js +1 -1
  74. package/build/web-components/alert/component.js.map +1 -1
  75. package/build/web-components/alert/definition.d.ts.map +1 -1
  76. package/build/web-components/alert/definition.js +1 -1
  77. package/build/web-components/alert/definition.js.map +1 -1
  78. package/build/web-components/avatar/component.d.ts.map +1 -1
  79. package/build/web-components/avatar/component.js +1 -1
  80. package/build/web-components/avatar/component.js.map +1 -1
  81. package/build/web-components/avatar/definition.d.ts.map +1 -1
  82. package/build/web-components/avatar/definition.js +1 -1
  83. package/build/web-components/avatar/definition.js.map +1 -1
  84. package/build/web-components/badge/component.d.ts.map +1 -1
  85. package/build/web-components/badge/component.js +2 -2
  86. package/build/web-components/badge/component.js.map +1 -1
  87. package/build/web-components/badge/definition.d.ts.map +1 -1
  88. package/build/web-components/badge/definition.js +1 -1
  89. package/build/web-components/badge/definition.js.map +1 -1
  90. package/build/web-components/breath/component.d.ts.map +1 -1
  91. package/build/web-components/breath/component.js +1 -1
  92. package/build/web-components/breath/component.js.map +1 -1
  93. package/build/web-components/breath/definition.d.ts.map +1 -1
  94. package/build/web-components/breath/definition.js +1 -1
  95. package/build/web-components/breath/definition.js.map +1 -1
  96. package/build/web-components/button/component.d.ts.map +1 -1
  97. package/build/web-components/button/component.js +1 -1
  98. package/build/web-components/button/component.js.map +1 -1
  99. package/build/web-components/button/definition.d.ts.map +1 -1
  100. package/build/web-components/button/definition.js +1 -1
  101. package/build/web-components/button/definition.js.map +1 -1
  102. package/build/web-components/card/component.d.ts.map +1 -1
  103. package/build/web-components/card/component.js +1 -1
  104. package/build/web-components/card/component.js.map +1 -1
  105. package/build/web-components/card/definition.d.ts.map +1 -1
  106. package/build/web-components/card/definition.js +1 -1
  107. package/build/web-components/card/definition.js.map +1 -1
  108. package/build/web-components/carousel/component.d.ts.map +1 -1
  109. package/build/web-components/carousel/component.js +2 -2
  110. package/build/web-components/carousel/component.js.map +1 -1
  111. package/build/web-components/carousel/definition.d.ts.map +1 -1
  112. package/build/web-components/carousel/definition.js +1 -1
  113. package/build/web-components/carousel/definition.js.map +1 -1
  114. package/build/web-components/chip/component.d.ts.map +1 -1
  115. package/build/web-components/chip/component.js +1 -1
  116. package/build/web-components/chip/component.js.map +1 -1
  117. package/build/web-components/chip/definition.d.ts.map +1 -1
  118. package/build/web-components/chip/definition.js +1 -1
  119. package/build/web-components/chip/definition.js.map +1 -1
  120. package/build/web-components/details/component.d.ts.map +1 -1
  121. package/build/web-components/details/component.js +1 -1
  122. package/build/web-components/details/component.js.map +1 -1
  123. package/build/web-components/details/definition.d.ts.map +1 -1
  124. package/build/web-components/details/definition.js +1 -1
  125. package/build/web-components/details/definition.js.map +1 -1
  126. package/build/web-components/dialog/component.d.ts.map +1 -1
  127. package/build/web-components/dialog/component.js +1 -1
  128. package/build/web-components/dialog/component.js.map +1 -1
  129. package/build/web-components/dialog/definition.d.ts.map +1 -1
  130. package/build/web-components/dialog/definition.js +1 -1
  131. package/build/web-components/dialog/definition.js.map +1 -1
  132. package/build/web-components/divider/component.d.ts.map +1 -1
  133. package/build/web-components/divider/component.js +1 -1
  134. package/build/web-components/divider/component.js.map +1 -1
  135. package/build/web-components/divider/definition.d.ts.map +1 -1
  136. package/build/web-components/divider/definition.js +1 -1
  137. package/build/web-components/divider/definition.js.map +1 -1
  138. package/build/web-components/dragbox/component.d.ts.map +1 -1
  139. package/build/web-components/dragbox/component.js +2 -2
  140. package/build/web-components/dragbox/component.js.map +1 -1
  141. package/build/web-components/dragbox/definition.d.ts.map +1 -1
  142. package/build/web-components/dragbox/definition.js +1 -1
  143. package/build/web-components/dragbox/definition.js.map +1 -1
  144. package/build/web-components/flex/component.d.ts.map +1 -1
  145. package/build/web-components/flex/component.js +2 -2
  146. package/build/web-components/flex/component.js.map +1 -1
  147. package/build/web-components/flex/definition.d.ts.map +1 -1
  148. package/build/web-components/flex/definition.js +1 -1
  149. package/build/web-components/flex/definition.js.map +1 -1
  150. package/build/web-components/form/component.d.ts.map +1 -1
  151. package/build/web-components/form/component.js +2 -2
  152. package/build/web-components/form/component.js.map +1 -1
  153. package/build/web-components/form/definition.d.ts.map +1 -1
  154. package/build/web-components/form/definition.js +1 -1
  155. package/build/web-components/form/definition.js.map +1 -1
  156. package/build/web-components/grid/component.d.ts.map +1 -1
  157. package/build/web-components/grid/component.js +2 -2
  158. package/build/web-components/grid/component.js.map +1 -1
  159. package/build/web-components/grid/definition.d.ts.map +1 -1
  160. package/build/web-components/grid/definition.js +1 -1
  161. package/build/web-components/grid/definition.js.map +1 -1
  162. package/build/web-components/heading/component.d.ts.map +1 -1
  163. package/build/web-components/heading/component.js +2 -2
  164. package/build/web-components/heading/component.js.map +1 -1
  165. package/build/web-components/heading/definition.d.ts.map +1 -1
  166. package/build/web-components/heading/definition.js +1 -1
  167. package/build/web-components/heading/definition.js.map +1 -1
  168. package/build/web-components/input/component.d.ts.map +1 -1
  169. package/build/web-components/input/component.js +1 -1
  170. package/build/web-components/input/component.js.map +1 -1
  171. package/build/web-components/input/definition.d.ts.map +1 -1
  172. package/build/web-components/input/definition.js +1 -1
  173. package/build/web-components/input/definition.js.map +1 -1
  174. package/build/web-components/layout/component.d.ts.map +1 -1
  175. package/build/web-components/layout/component.js +2 -2
  176. package/build/web-components/layout/component.js.map +1 -1
  177. package/build/web-components/layout/definition.d.ts.map +1 -1
  178. package/build/web-components/layout/definition.js +1 -1
  179. package/build/web-components/layout/definition.js.map +1 -1
  180. package/build/web-components/link/component.d.ts.map +1 -1
  181. package/build/web-components/link/component.js +2 -2
  182. package/build/web-components/link/component.js.map +1 -1
  183. package/build/web-components/link/definition.d.ts.map +1 -1
  184. package/build/web-components/link/definition.js +1 -1
  185. package/build/web-components/link/definition.js.map +1 -1
  186. package/build/web-components/popover/component.d.ts.map +1 -1
  187. package/build/web-components/popover/component.js +2 -2
  188. package/build/web-components/popover/component.js.map +1 -1
  189. package/build/web-components/popover/definition.d.ts.map +1 -1
  190. package/build/web-components/popover/definition.js +1 -1
  191. package/build/web-components/popover/definition.js.map +1 -1
  192. package/build/web-components/progress/component.d.ts.map +1 -1
  193. package/build/web-components/progress/component.js +1 -1
  194. package/build/web-components/progress/component.js.map +1 -1
  195. package/build/web-components/progress/definition.d.ts.map +1 -1
  196. package/build/web-components/progress/definition.js +1 -1
  197. package/build/web-components/progress/definition.js.map +1 -1
  198. package/build/web-components/range/component.d.ts.map +1 -1
  199. package/build/web-components/range/component.js +1 -1
  200. package/build/web-components/range/component.js.map +1 -1
  201. package/build/web-components/range/definition.d.ts.map +1 -1
  202. package/build/web-components/range/definition.js +1 -1
  203. package/build/web-components/range/definition.js.map +1 -1
  204. package/build/web-components/rotate/component.d.ts.map +1 -1
  205. package/build/web-components/rotate/component.js +1 -1
  206. package/build/web-components/rotate/component.js.map +1 -1
  207. package/build/web-components/rotate/definition.d.ts.map +1 -1
  208. package/build/web-components/rotate/definition.js +1 -1
  209. package/build/web-components/rotate/definition.js.map +1 -1
  210. package/build/web-components/router/component.d.ts.map +1 -1
  211. package/build/web-components/router/component.js +2 -2
  212. package/build/web-components/router/component.js.map +1 -1
  213. package/build/web-components/router/definition.d.ts.map +1 -1
  214. package/build/web-components/router/definition.js +1 -1
  215. package/build/web-components/router/definition.js.map +1 -1
  216. package/build/web-components/select/component.d.ts.map +1 -1
  217. package/build/web-components/select/component.js +2 -2
  218. package/build/web-components/select/component.js.map +1 -1
  219. package/build/web-components/select/definition.d.ts.map +1 -1
  220. package/build/web-components/select/definition.js +1 -1
  221. package/build/web-components/select/definition.js.map +1 -1
  222. package/build/web-components/skeleton/component.d.ts.map +1 -1
  223. package/build/web-components/skeleton/component.js +1 -1
  224. package/build/web-components/skeleton/component.js.map +1 -1
  225. package/build/web-components/skeleton/definition.d.ts.map +1 -1
  226. package/build/web-components/skeleton/definition.js +1 -1
  227. package/build/web-components/skeleton/definition.js.map +1 -1
  228. package/build/web-components/split/component.d.ts.map +1 -1
  229. package/build/web-components/split/component.js +1 -1
  230. package/build/web-components/split/component.js.map +1 -1
  231. package/build/web-components/split/definition.d.ts.map +1 -1
  232. package/build/web-components/split/definition.js +1 -1
  233. package/build/web-components/split/definition.js.map +1 -1
  234. package/build/web-components/switch/component.d.ts.map +1 -1
  235. package/build/web-components/switch/component.js +1 -1
  236. package/build/web-components/switch/component.js.map +1 -1
  237. package/build/web-components/switch/definition.d.ts.map +1 -1
  238. package/build/web-components/switch/definition.js +1 -1
  239. package/build/web-components/switch/definition.js.map +1 -1
  240. package/build/web-components/tabs/component.d.ts +10 -3
  241. package/build/web-components/tabs/component.d.ts.map +1 -1
  242. package/build/web-components/tabs/component.js +1 -1
  243. package/build/web-components/tabs/component.js.map +1 -1
  244. package/build/web-components/tabs/definition.d.ts.map +1 -1
  245. package/build/web-components/tabs/definition.js +1 -1
  246. package/build/web-components/tabs/definition.js.map +1 -1
  247. package/build/web-components/text/component.d.ts.map +1 -1
  248. package/build/web-components/text/component.js +1 -1
  249. package/build/web-components/text/component.js.map +1 -1
  250. package/build/web-components/text/definition.d.ts.map +1 -1
  251. package/build/web-components/text/definition.js +1 -1
  252. package/build/web-components/text/definition.js.map +1 -1
  253. package/build/web-components/time/component.d.ts.map +1 -1
  254. package/build/web-components/time/component.js +1 -1
  255. package/build/web-components/time/component.js.map +1 -1
  256. package/build/web-components/time/definition.d.ts.map +1 -1
  257. package/build/web-components/time/definition.js +1 -1
  258. package/build/web-components/time/definition.js.map +1 -1
  259. package/build/web-components/tooltip/component.d.ts.map +1 -1
  260. package/build/web-components/tooltip/component.js +1 -1
  261. package/build/web-components/tooltip/component.js.map +1 -1
  262. package/build/web-components/tooltip/definition.d.ts.map +1 -1
  263. package/build/web-components/tooltip/definition.js +1 -1
  264. package/build/web-components/tooltip/definition.js.map +1 -1
  265. package/build/web-components/typewriter/component.d.ts.map +1 -1
  266. package/build/web-components/typewriter/component.js +1 -1
  267. package/build/web-components/typewriter/component.js.map +1 -1
  268. package/build/web-components/typewriter/definition.d.ts.map +1 -1
  269. package/build/web-components/typewriter/definition.js +1 -1
  270. package/build/web-components/typewriter/definition.js.map +1 -1
  271. package/custom-elements.json +1 -1
  272. package/package.json +4 -4
  273. package/src/index.ts +1 -1
  274. package/src/internal/popover.ts +8 -12
  275. package/src/internal/ring.ts +3 -1
  276. package/src/web-components/breath/component.ts +3 -1
  277. package/src/web-components/tabs/component.ts +19 -6
  278. package/web-types.json +7 -2
@@ -1,3 +1,3 @@
1
- import{godown,styles,attr,htmlSlot}from"@godown/element";import _default from"../../internal/icons/caret-down.js";import{css,nothing,html}from"lit";import{property,query}from"lit/decorators.js";import Input from"../input/component.js";import{showPopover,hidePopover}from"../../internal/popover.js";import{memoize}from"../../internal/utils.js";import _decorate from"@oxc-project/runtime/helpers/decorate";import"../../internal/icons/eye-slash.js";import"../../internal/global-style.js";import"../../internal/reset-style.js";import"sharekit";import"../../internal/super-input.js";import"../../internal/ring.js";const supportsPositionArea=memoize(()=>CSS.supports(`position-area:top`));function updateSelected(e,g){if(e){let _=`selected`;g?e.setAttribute(_,``):e.removeAttribute(_)}}const protoName=`select`;let Select=class e extends Input{constructor(...e){super(...e),this.multiple=!1,this.noEdit=!1,this.values=[],this.optionsVisible=!1}render(){let e=this.noEdit||this.disabled;return html`<label part="root" ${attr(this.observedRecord)}> ${[this._renderPrefix(),this.noEdit?html`<input style="position: absolute;inset: 0;opacity: 0;"/> `:``,html`<input part="input" .value="${this.text}" ?autofocus="${this.autofocus}" ?disabled="${e}" autocapitalize="${this.autocapitalize||nothing}" autocomplete="${this.autocomplete||nothing}" placeholder="${this.placeholder||nothing}" @input="${e?null:this._handleInput}" @change="${e?null:this._handleChange}"/>`,this._renderSuffix()]} <div part="popover" popover="${supportsPositionArea()?`manual`:nothing}"> ${htmlSlot()} </div> </label>`}_renderSuffix(){return html`<i part="suffix">${htmlSlot(`suffix`,_default())}</i>`}firstUpdated(){this.events.add(this._slot,`click`,e=>{let{target:g}=e;if(g.tagName!==`OPTION`)return;e.preventDefault();let{label:_,value:v}=g,y=this.select(v,_);this.multiple||(updateSelected(this.lastChecked,0),this.hideOptions()),updateSelected(g,y),this.lastChecked=g})}_connectedInit(){this.default=this.value??=``,this.defaultText=this.text??=``,this.events.add(this,`focus`,this.showOptions)}reset(){this.value=this.default,this.text=this.defaultText}select(e,g){g||=e;let _=0,v=this.values.findIndex(g=>g.value===e);return v>-1?this.values.splice(v,1):(this.values.push({value:e,label:g}),_=1),this.checkValues(),this.value=this.values.map(e=>e.value).join(`,`),this.text=this.values.map(e=>e.label).join(`, `),this.dispatchCustomEvent(`select`,this.value),_}checkValues(){!this.multiple&&this.values.length>1&&(this.values.splice(0,this.values.length-1),this.requestUpdate())}showOptions(){if(this.optionsVisible)return;showPopover(this._popover);let e=g=>{this.contains(g.target)||(this.hideOptions(),this.events.remove(document,`click`,e))};this.events.add(document,`click`,e),this.optionsVisible=!0}hideOptions(){this.optionsVisible&&(hidePopover(this._popover),this.optionsVisible=!1)}focus(e){super.focus(),this._input.focus(e),this.showOptions()}blur(){super.blur(),this._input.blur(),hidePopover(this._popover)}};_decorate([property()],Select.prototype,`text`,void 0),_decorate([property({type:Boolean})],Select.prototype,`multiple`,void 0),_decorate([property({type:Boolean})],Select.prototype,`noEdit`,void 0),_decorate([property({type:Array})],Select.prototype,`values`,void 0),_decorate([query(`[part=popover]`)],Select.prototype,`_popover`,void 0),Select=_decorate([godown(protoName),styles(css`[part=root]{position:relative;anchor-name:--select}label{display:contents}[part=popover]{border:0;width:100%;background:0 0;position-anchor:--select;position-area:bottom center;position-try-fallbacks:flip-block}[part=input]{text-overflow:ellipsis}@supports not (position-area:top){[part=popover]{left:0;top:100%;display:none;position:absolute}}
2
- `)],Select);var Select$1=Select;export{Select,Select$1 as default};
1
+ import{godown as e,styles as t,attr as n,htmlSlot as r}from"@godown/element";import i from"../../internal/icons/caret-down.js";import{css as a,nothing as o,html as s}from"lit";import{property as c,query as l}from"lit/decorators.js";import u from"../input/component.js";import{showPopover as d,hidePopover as f}from"../../internal/popover.js";import{memoize as p}from"../../internal/utils.js";import m from"@oxc-project/runtime/helpers/decorate";const h=p(()=>CSS.supports(`position-area:top`));function g(e,t){if(e){let n=`selected`;t?e.setAttribute(n,``):e.removeAttribute(n)}}const _=`select`;let v=class e extends u{constructor(...e){super(...e),this.multiple=!1,this.noEdit=!1,this.values=[],this.optionsVisible=!1}render(){let e=this.noEdit||this.disabled;return s`<label part="root" ${n(this.observedRecord)}> ${[this._renderPrefix(),this.noEdit?s`<input style="position: absolute;inset: 0;opacity: 0;"/> `:``,s`<input part="input" .value="${this.text}" ?autofocus="${this.autofocus}" ?disabled="${e}" autocapitalize="${this.autocapitalize||o}" autocomplete="${this.autocomplete||o}" placeholder="${this.placeholder||o}" @input="${e?null:this._handleInput}" @change="${e?null:this._handleChange}"/>`,this._renderSuffix()]} <div part="popover" popover="${h()?`manual`:o}"> ${r()} </div> </label>`}_renderSuffix(){return s`<i part="suffix">${r(`suffix`,i())}</i>`}firstUpdated(){this.events.add(this._slot,`click`,e=>{let{target:t}=e;if(t.tagName!==`OPTION`)return;e.preventDefault();let{label:n,value:r}=t,i=this.select(r,n);this.multiple||(g(this.lastChecked,0),this.hideOptions()),g(t,i),this.lastChecked=t})}_connectedInit(){this.default=this.value??=``,this.defaultText=this.text??=``,this.events.add(this,`focus`,this.showOptions)}reset(){this.value=this.default,this.text=this.defaultText}select(e,t){t||=e;let n=0,r=this.values.findIndex(t=>t.value===e);return r>-1?this.values.splice(r,1):(this.values.push({value:e,label:t}),n=1),this.checkValues(),this.value=this.values.map(e=>e.value).join(`,`),this.text=this.values.map(e=>e.label).join(`, `),this.dispatchCustomEvent(`select`,this.value),n}checkValues(){!this.multiple&&this.values.length>1&&(this.values.splice(0,this.values.length-1),this.requestUpdate())}showOptions(){if(this.optionsVisible)return;d(this._popover);let e=t=>{this.contains(t.target)||(this.hideOptions(),this.events.remove(document,`click`,e))};this.events.add(document,`click`,e),this.optionsVisible=!0}hideOptions(){this.optionsVisible&&=(f(this._popover),!1)}focus(e){super.focus(),this._input.focus(e),this.showOptions()}blur(){super.blur(),this._input.blur(),f(this._popover)}};m([c()],v.prototype,`text`,void 0),m([c({type:Boolean})],v.prototype,`multiple`,void 0),m([c({type:Boolean})],v.prototype,`noEdit`,void 0),m([c({type:Array})],v.prototype,`values`,void 0),m([l(`[part=popover]`)],v.prototype,`_popover`,void 0),v=m([e(`select`),t(a`[part=root]{position:relative;anchor-name:--select}label{display:contents}[part=popover]{border:0;width:100%;background:0 0;position-anchor:--select;position-area:bottom center;position-try-fallbacks:flip-block}[part=input]{text-overflow:ellipsis}@supports not (position-area:top){[part=popover]{left:0;top:100%;display:none;position:absolute}}
2
+ `)],v);var y=v;export{v as Select,y as default};
3
3
  //# sourceMappingURL=component.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"component.js","sources":["../../../src/web-components/select/component.ts"],"sourcesContent":["import { type HandlerEvent, attr, godown, htmlSlot, styles } from \"@godown/element\";\nimport svgCaretDown from \"../../internal/icons/caret-down.js\";\nimport { type TemplateResult, css, html, nothing } from \"lit\";\nimport { property, query } from \"lit/decorators.js\";\n\nimport Input from \"../input/component.js\";\nimport { hidePopover, showPopover } from \"../../internal/popover.js\";\nimport { memoize } from \"../../internal/utils.js\";\n\nconst supportsPositionArea = memoize(() => CSS.supports(\"position-area:top\"));\n\nfunction updateSelected(element: HTMLElement | null, operation: 0 | 1) {\n if (element) {\n const name = \"selected\";\n if (operation) {\n element.setAttribute(name, \"\");\n } else {\n element.removeAttribute(name);\n }\n }\n}\n\nconst protoName = \"select\";\n\n/**\n * {@linkcode Select} is similar to `<select>`.\n *\n * @fires input - Fires when the input value changes.\n * @fires change - Fires when the input value changes.\n * @fires select - Fires when select an option.\n * @slot - Options.\n * @category input\n */\n@godown(protoName)\n@styles(css`\n [part=\"root\"] {\n position: relative;\n anchor-name: --select;\n }\n\n label {\n display: contents;\n }\n\n [part=\"popover\"] {\n border: 0;\n width: 100%;\n background: none;\n position-anchor: --select;\n position-area: bottom center;\n position-try-fallbacks: flip-block;\n }\n\n [part=\"input\"] {\n text-overflow: ellipsis;\n }\n\n @supports not (position-area: top) {\n [part=\"popover\"] {\n left: 0;\n top: 100%;\n display: none;\n position: absolute;\n }\n }\n`)\nclass Select extends Input {\n @property()\n text: string;\n\n @property({ type: Boolean })\n multiple = false;\n\n @property({ type: Boolean })\n noEdit = false;\n\n @property({ type: Array })\n values: {\n value: string;\n label?: string;\n }[] = [];\n\n @query(\"[part=popover]\")\n _popover: HTMLElement;\n\n protected lastChecked: HTMLElement;\n protected defaultText: string;\n protected optionsVisible = false;\n\n protected render(): TemplateResult<1> {\n const inputNoEdit = this.noEdit || this.disabled;\n return html`\n <label\n part=\"root\"\n ${attr(this.observedRecord)}\n >\n ${[\n this._renderPrefix(),\n this.noEdit\n ? html`\n <input style=\"position: absolute;inset: 0;opacity: 0;\" />\n `\n : \"\",\n html`\n <input\n part=\"input\"\n .value=\"${this.text}\"\n ?autofocus=\"${this.autofocus}\"\n ?disabled=\"${inputNoEdit}\"\n autocapitalize=\"${this.autocapitalize || nothing}\"\n autocomplete=\"${this.autocomplete || nothing}\"\n placeholder=\"${this.placeholder || nothing}\"\n @input=\"${inputNoEdit ? null : this._handleInput}\"\n @change=\"${inputNoEdit ? null : this._handleChange}\"\n />\n `,\n this._renderSuffix(),\n ]}\n <div\n part=\"popover\"\n popover=\"${supportsPositionArea() ? \"manual\" : nothing}\"\n >\n ${htmlSlot()}\n </div>\n </label>\n `;\n }\n\n protected _renderSuffix(): TemplateResult<1> {\n return html`\n <i part=\"suffix\">${htmlSlot(\"suffix\", svgCaretDown())}</i>\n `;\n }\n\n protected firstUpdated(): void {\n this.events.add(this._slot, \"click\", (e: HandlerEvent<HTMLOptionElement>) => {\n const { target } = e;\n if (target.tagName !== \"OPTION\") {\n return;\n }\n e.preventDefault();\n const { label, value } = target;\n const operation = this.select(value, label);\n if (!this.multiple) {\n updateSelected(this.lastChecked, 0);\n this.hideOptions();\n }\n updateSelected(target, operation);\n this.lastChecked = target;\n });\n }\n\n protected _connectedInit(): void {\n this.default = this.value ??= \"\";\n this.defaultText = this.text ??= \"\";\n this.events.add(this, \"focus\", this.showOptions);\n }\n\n reset(): void {\n this.value = this.default;\n this.text = this.defaultText;\n }\n\n select(value: string, label: string): 0 | 1 {\n label ||= value;\n let operation: 0 | 1 = 0;\n const i = this.values.findIndex((s) => s.value === value);\n if (i > -1) {\n this.values.splice(i, 1);\n } else {\n this.values.push({ value, label });\n operation = 1;\n }\n this.checkValues();\n this.value = this.values.map((s) => s.value).join(\",\");\n this.text = this.values.map((s) => s.label).join(\", \");\n this.dispatchCustomEvent(\"select\", this.value);\n return operation;\n }\n\n checkValues(): void {\n if (!this.multiple && this.values.length > 1) {\n this.values.splice(0, this.values.length - 1);\n this.requestUpdate();\n }\n }\n\n showOptions(): void {\n if (this.optionsVisible) {\n return;\n }\n showPopover(this._popover);\n const listener = (e) => {\n if (!this.contains(e.target)) {\n this.hideOptions();\n this.events.remove(document, \"click\", listener);\n }\n };\n this.events.add(document, \"click\", listener);\n this.optionsVisible = true;\n }\n\n hideOptions(): void {\n if (!this.optionsVisible) {\n return;\n }\n hidePopover(this._popover);\n this.optionsVisible = false;\n }\n\n focus(options?: FocusOptions): void {\n super.focus();\n this._input.focus(options);\n this.showOptions();\n }\n\n blur(): void {\n super.blur();\n this._input.blur();\n hidePopover(this._popover);\n }\n}\n\nexport default Select;\nexport { Select };\n"],"names":["element: HTMLElement | null","operation: 0 | 1","element","name","operation","Select","inputNoEdit","svgCaretDown","e: HandlerEvent<HTMLOptionElement>","target","value","label","value: string","label: string","i","s","listener","e","options?: FocusOptions","options"],"mappings":"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"}
1
+ {"version":3,"file":"component.js","sources":["../../../src/web-components/select/component.ts"],"sourcesContent":["import { type HandlerEvent, attr, godown, htmlSlot, styles } from \"@godown/element\";\nimport svgCaretDown from \"../../internal/icons/caret-down.js\";\nimport { type TemplateResult, css, html, nothing } from \"lit\";\nimport { property, query } from \"lit/decorators.js\";\n\nimport Input from \"../input/component.js\";\nimport { hidePopover, showPopover } from \"../../internal/popover.js\";\nimport { memoize } from \"../../internal/utils.js\";\n\nconst supportsPositionArea = memoize(() => CSS.supports(\"position-area:top\"));\n\nfunction updateSelected(element: HTMLElement | null, operation: 0 | 1) {\n if (element) {\n const name = \"selected\";\n if (operation) {\n element.setAttribute(name, \"\");\n } else {\n element.removeAttribute(name);\n }\n }\n}\n\nconst protoName = \"select\";\n\n/**\n * {@linkcode Select} is similar to `<select>`.\n *\n * @fires input - Fires when the input value changes.\n * @fires change - Fires when the input value changes.\n * @fires select - Fires when select an option.\n * @slot - Options.\n * @category input\n */\n@godown(protoName)\n@styles(css`\n [part=\"root\"] {\n position: relative;\n anchor-name: --select;\n }\n\n label {\n display: contents;\n }\n\n [part=\"popover\"] {\n border: 0;\n width: 100%;\n background: none;\n position-anchor: --select;\n position-area: bottom center;\n position-try-fallbacks: flip-block;\n }\n\n [part=\"input\"] {\n text-overflow: ellipsis;\n }\n\n @supports not (position-area: top) {\n [part=\"popover\"] {\n left: 0;\n top: 100%;\n display: none;\n position: absolute;\n }\n }\n`)\nclass Select extends Input {\n @property()\n text: string;\n\n @property({ type: Boolean })\n multiple = false;\n\n @property({ type: Boolean })\n noEdit = false;\n\n @property({ type: Array })\n values: {\n value: string;\n label?: string;\n }[] = [];\n\n @query(\"[part=popover]\")\n _popover: HTMLElement;\n\n protected lastChecked: HTMLElement;\n protected defaultText: string;\n protected optionsVisible = false;\n\n protected render(): TemplateResult<1> {\n const inputNoEdit = this.noEdit || this.disabled;\n return html`\n <label\n part=\"root\"\n ${attr(this.observedRecord)}\n >\n ${[\n this._renderPrefix(),\n this.noEdit\n ? html`\n <input style=\"position: absolute;inset: 0;opacity: 0;\" />\n `\n : \"\",\n html`\n <input\n part=\"input\"\n .value=\"${this.text}\"\n ?autofocus=\"${this.autofocus}\"\n ?disabled=\"${inputNoEdit}\"\n autocapitalize=\"${this.autocapitalize || nothing}\"\n autocomplete=\"${this.autocomplete || nothing}\"\n placeholder=\"${this.placeholder || nothing}\"\n @input=\"${inputNoEdit ? null : this._handleInput}\"\n @change=\"${inputNoEdit ? null : this._handleChange}\"\n />\n `,\n this._renderSuffix(),\n ]}\n <div\n part=\"popover\"\n popover=\"${supportsPositionArea() ? \"manual\" : nothing}\"\n >\n ${htmlSlot()}\n </div>\n </label>\n `;\n }\n\n protected _renderSuffix(): TemplateResult<1> {\n return html`\n <i part=\"suffix\">${htmlSlot(\"suffix\", svgCaretDown())}</i>\n `;\n }\n\n protected firstUpdated(): void {\n this.events.add(this._slot, \"click\", (e: HandlerEvent<HTMLOptionElement>) => {\n const { target } = e;\n if (target.tagName !== \"OPTION\") {\n return;\n }\n e.preventDefault();\n const { label, value } = target;\n const operation = this.select(value, label);\n if (!this.multiple) {\n updateSelected(this.lastChecked, 0);\n this.hideOptions();\n }\n updateSelected(target, operation);\n this.lastChecked = target;\n });\n }\n\n protected _connectedInit(): void {\n this.default = this.value ??= \"\";\n this.defaultText = this.text ??= \"\";\n this.events.add(this, \"focus\", this.showOptions);\n }\n\n reset(): void {\n this.value = this.default;\n this.text = this.defaultText;\n }\n\n select(value: string, label: string): 0 | 1 {\n label ||= value;\n let operation: 0 | 1 = 0;\n const i = this.values.findIndex((s) => s.value === value);\n if (i > -1) {\n this.values.splice(i, 1);\n } else {\n this.values.push({ value, label });\n operation = 1;\n }\n this.checkValues();\n this.value = this.values.map((s) => s.value).join(\",\");\n this.text = this.values.map((s) => s.label).join(\", \");\n this.dispatchCustomEvent(\"select\", this.value);\n return operation;\n }\n\n checkValues(): void {\n if (!this.multiple && this.values.length > 1) {\n this.values.splice(0, this.values.length - 1);\n this.requestUpdate();\n }\n }\n\n showOptions(): void {\n if (this.optionsVisible) {\n return;\n }\n showPopover(this._popover);\n const listener = (e) => {\n if (!this.contains(e.target)) {\n this.hideOptions();\n this.events.remove(document, \"click\", listener);\n }\n };\n this.events.add(document, \"click\", listener);\n this.optionsVisible = true;\n }\n\n hideOptions(): void {\n if (!this.optionsVisible) {\n return;\n }\n hidePopover(this._popover);\n this.optionsVisible = false;\n }\n\n focus(options?: FocusOptions): void {\n super.focus();\n this._input.focus(options);\n this.showOptions();\n }\n\n blur(): void {\n super.blur();\n this._input.blur();\n hidePopover(this._popover);\n }\n}\n\nexport default Select;\nexport { Select };\n"],"names":["supportsPositionArea","memoize","updateSelected","element","name","operation","protoName","Select","Input","inputNoEdit","attr","nothing","htmlSlot","svgCaretDown","target","value","label","operation: 0 | 1","i","s","showPopover","listener","e","hidePopover","options","_decorate","property","query","godown","styles","Select$1"],"mappings":"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"}
@@ -1 +1 @@
1
- {"mappings":"AAAA,OAAO,YAAY,gBAAiB;AAIpC,eAAe;eAEA;WACH,sBAAsB;EAC9B,iBAAiB;CAClB;AACF","names":[],"sources":["../../../../src/web-components/select/definition.ts"],"sourcesContent":["import Select from \"./component.js\";\n\nSelect.define();\n\nexport default Select;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"godown-select\": Select;\n }\n}\n"],"version":3,"file":"definition.d.ts"}
1
+ {"mappings":"AAAA,OAAO,YAAY;AAInB,eAAe;eAEA;WACH,sBAAsB;EAC9B,iBAAiB","names":[],"sources":["../../../../src/web-components/select/definition.ts"],"sourcesContent":["import Select from \"./component.js\";\n\nSelect.define();\n\nexport default Select;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"godown-select\": Select;\n }\n}\n"],"version":3,"file":"definition.d.ts"}
@@ -1,2 +1,2 @@
1
- import Select from"./component.js";import"@godown/element";import"../../internal/icons/caret-down.js";import"lit";import"lit/decorators.js";import"../input/component.js";import"../../internal/icons/eye-slash.js";import"../../internal/global-style.js";import"../../internal/reset-style.js";import"sharekit";import"../../internal/super-input.js";import"../../internal/ring.js";import"@oxc-project/runtime/helpers/decorate";import"../../internal/popover.js";import"../../internal/utils.js";Select.define();export{Select as default};
1
+ import e from"./component.js";e.define();export{e as default};
2
2
  //# sourceMappingURL=definition.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"definition.js","sources":["../../../src/web-components/select/definition.ts"],"sourcesContent":["import Select from \"./component.js\";\n\nSelect.define();\n\nexport default Select;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"godown-select\": Select;\n }\n}\n"],"names":[],"mappings":"ueAEA,OAAO,QAAQ"}
1
+ {"version":3,"file":"definition.js","sources":["../../../src/web-components/select/definition.ts"],"sourcesContent":["import Select from \"./component.js\";\n\nSelect.define();\n\nexport default Select;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"godown-select\": Select;\n }\n}\n"],"names":["Select"],"mappings":"8BAEAA,EAAO"}
@@ -1 +1 @@
1
- {"mappings":"AACA,cAAc,sBAAiC,KAAM;AAGrD,SAAS,mBAA+C,gCAAiC;;;;;;;;AAYzF,cAwCM,iBAAiB,YAAY;;;;CAIjC,AACA;CAEA,UAAU,UAAU,eAAe;AAQpC;AAED,eAAe;AACf,SAAS","names":[],"sources":["../../../../src/web-components/skeleton/component.ts"],"sourcesContent":["import { godown, htmlSlot, styles } from \"@godown/element\";\nimport { type TemplateResult, css, html } from \"lit\";\nimport { state } from \"lit/decorators.js\";\n\nimport { GlobalStyle, cssGlobalVars, scopePrefix } from \"../../internal/global-style.js\";\n\nconst protoName = \"skeleton\";\nconst cssScope = scopePrefix(protoName);\n\n/**\n * {@linkcode Skeleton} renders a skeleton screen.\n *\n * @slot loading - The content if loading is true.\n * @slot - The content if loading is false.\n * @category feedback\n */\n@godown(protoName)\n@styles(css`\n :host {\n ${cssScope}--from: var(${cssGlobalVars.background});\n ${cssScope}--to: var(${cssGlobalVars.passive});\n ${cssScope}--deg: 95deg;\n ${cssScope}--duration: 2s;\n height: 2em;\n width: 100%;\n flex-shrink: 0;\n overflow: hidden;\n background-color: transparent;\n background-size: 200% 100%;\n background-image: linear-gradient(\n var(${cssScope}--deg),\n var(${cssScope}--from) 36%,\n var(${cssScope}--to) 50%,\n var(${cssScope}--from) 64%\n );\n animation: _ var(${cssScope}--duration) ease-in-out infinite none running;\n }\n\n @keyframes _ {\n from {\n background-position: 150% center;\n }\n to {\n background-position: -50% center;\n }\n }\n\n [part=\"root\"] {\n display: contents;\n }\n\n :host,\n :host([contents]) [part=\"root\"] {\n display: block;\n }\n`)\nclass Skeleton extends GlobalStyle {\n /**\n * If false, render slot only.\n */\n @state()\n loading = true;\n\n protected render(): TemplateResult<1> {\n if (!this.loading) {\n return htmlSlot();\n }\n return html`\n <div part=\"root\">${htmlSlot(\"loading\")}</div>\n `;\n }\n}\n\nexport default Skeleton;\nexport { Skeleton };\n"],"version":3,"file":"component.d.ts"}
1
+ {"mappings":"AACA,cAAc,sBAAiC;AAG/C,SAAS,mBAA+C;;;;;;;;AAYxD,cAwCM,iBAAiB,YAAY;;;;CAIjC,AACA;CAEA,UAAU,UAAU,eAAe;;AAUrC,eAAe;AACf,SAAS","names":[],"sources":["../../../../src/web-components/skeleton/component.ts"],"sourcesContent":["import { godown, htmlSlot, styles } from \"@godown/element\";\nimport { type TemplateResult, css, html } from \"lit\";\nimport { state } from \"lit/decorators.js\";\n\nimport { GlobalStyle, cssGlobalVars, scopePrefix } from \"../../internal/global-style.js\";\n\nconst protoName = \"skeleton\";\nconst cssScope = scopePrefix(protoName);\n\n/**\n * {@linkcode Skeleton} renders a skeleton screen.\n *\n * @slot loading - The content if loading is true.\n * @slot - The content if loading is false.\n * @category feedback\n */\n@godown(protoName)\n@styles(css`\n :host {\n ${cssScope}--from: var(${cssGlobalVars.background});\n ${cssScope}--to: var(${cssGlobalVars.passive});\n ${cssScope}--deg: 95deg;\n ${cssScope}--duration: 2s;\n height: 2em;\n width: 100%;\n flex-shrink: 0;\n overflow: hidden;\n background-color: transparent;\n background-size: 200% 100%;\n background-image: linear-gradient(\n var(${cssScope}--deg),\n var(${cssScope}--from) 36%,\n var(${cssScope}--to) 50%,\n var(${cssScope}--from) 64%\n );\n animation: _ var(${cssScope}--duration) ease-in-out infinite none running;\n }\n\n @keyframes _ {\n from {\n background-position: 150% center;\n }\n to {\n background-position: -50% center;\n }\n }\n\n [part=\"root\"] {\n display: contents;\n }\n\n :host,\n :host([contents]) [part=\"root\"] {\n display: block;\n }\n`)\nclass Skeleton extends GlobalStyle {\n /**\n * If false, render slot only.\n */\n @state()\n loading = true;\n\n protected render(): TemplateResult<1> {\n if (!this.loading) {\n return htmlSlot();\n }\n return html`\n <div part=\"root\">${htmlSlot(\"loading\")}</div>\n `;\n }\n}\n\nexport default Skeleton;\nexport { Skeleton };\n"],"version":3,"file":"component.d.ts"}
@@ -1,2 +1,2 @@
1
- import{godown,styles,htmlSlot}from"@godown/element";import{css,html}from"lit";import{state}from"lit/decorators.js";import{scopePrefix,cssGlobalVars,GlobalStyle}from"../../internal/global-style.js";import _decorate from"@oxc-project/runtime/helpers/decorate";import"../../internal/reset-style.js";import"sharekit";const protoName=`skeleton`,cssScope=scopePrefix(protoName);let Skeleton=class e extends GlobalStyle{constructor(...e){super(...e),this.loading=!0}render(){return this.loading?html`<div part="root">${htmlSlot(`loading`)}</div>`:htmlSlot()}};_decorate([state()],Skeleton.prototype,`loading`,void 0),Skeleton=_decorate([godown(protoName),styles(css`:host{${cssScope}--from:var(${cssGlobalVars.background});${cssScope}--to:var(${cssGlobalVars.passive});${cssScope}--deg:95deg;${cssScope}--duration:2s;height:2em;width:100%;flex-shrink:0;overflow:hidden;background-color:transparent;background-size:200% 100%;background-image:linear-gradient(var(${cssScope}--deg),var(${cssScope}--from) 36%,var(${cssScope}--to) 50%,var(${cssScope}--from) 64%);animation:_ var(${cssScope}--duration) ease-in-out infinite none running}@keyframes _{0%{background-position:150%center}to{background-position:-50%center}}[part=root]{display:contents}:host,:host([contents]) [part=root]{display:block}`)],Skeleton);var Skeleton$1=Skeleton;export{Skeleton,Skeleton$1 as default};
1
+ import{godown as e,styles as t,htmlSlot as n}from"@godown/element";import{css as r,html as i}from"lit";import{state as a}from"lit/decorators.js";import{scopePrefix as o,cssGlobalVars as s,GlobalStyle as c}from"../../internal/global-style.js";import l from"@oxc-project/runtime/helpers/decorate";const u=`skeleton`,d=o(u);let f=class e extends c{constructor(...e){super(...e),this.loading=!0}render(){return this.loading?i`<div part="root">${n(`loading`)}</div>`:n()}};l([a()],f.prototype,`loading`,void 0),f=l([e(u),t(r`:host{${d}--from:var(${s.background});${d}--to:var(${s.passive});${d}--deg:95deg;${d}--duration:2s;height:2em;width:100%;flex-shrink:0;overflow:hidden;background-color:transparent;background-size:200% 100%;background-image:linear-gradient(var(${d}--deg),var(${d}--from) 36%,var(${d}--to) 50%,var(${d}--from) 64%);animation:_ var(${d}--duration) ease-in-out infinite none running}@keyframes _{0%{background-position:150%center}to{background-position:-50%center}}[part=root]{display:contents}:host,:host([contents]) [part=root]{display:block}`)],f);var p=f;export{f as Skeleton,p as default};
2
2
  //# sourceMappingURL=component.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"component.js","sources":["../../../src/web-components/skeleton/component.ts"],"sourcesContent":["import { godown, htmlSlot, styles } from \"@godown/element\";\nimport { type TemplateResult, css, html } from \"lit\";\nimport { state } from \"lit/decorators.js\";\n\nimport { GlobalStyle, cssGlobalVars, scopePrefix } from \"../../internal/global-style.js\";\n\nconst protoName = \"skeleton\";\nconst cssScope = scopePrefix(protoName);\n\n/**\n * {@linkcode Skeleton} renders a skeleton screen.\n *\n * @slot loading - The content if loading is true.\n * @slot - The content if loading is false.\n * @category feedback\n */\n@godown(protoName)\n@styles(css`\n :host {\n ${cssScope}--from: var(${cssGlobalVars.background});\n ${cssScope}--to: var(${cssGlobalVars.passive});\n ${cssScope}--deg: 95deg;\n ${cssScope}--duration: 2s;\n height: 2em;\n width: 100%;\n flex-shrink: 0;\n overflow: hidden;\n background-color: transparent;\n background-size: 200% 100%;\n background-image: linear-gradient(\n var(${cssScope}--deg),\n var(${cssScope}--from) 36%,\n var(${cssScope}--to) 50%,\n var(${cssScope}--from) 64%\n );\n animation: _ var(${cssScope}--duration) ease-in-out infinite none running;\n }\n\n @keyframes _ {\n from {\n background-position: 150% center;\n }\n to {\n background-position: -50% center;\n }\n }\n\n [part=\"root\"] {\n display: contents;\n }\n\n :host,\n :host([contents]) [part=\"root\"] {\n display: block;\n }\n`)\nclass Skeleton extends GlobalStyle {\n /**\n * If false, render slot only.\n */\n @state()\n loading = true;\n\n protected render(): TemplateResult<1> {\n if (!this.loading) {\n return htmlSlot();\n }\n return html`\n <div part=\"root\">${htmlSlot(\"loading\")}</div>\n `;\n }\n}\n\nexport default Skeleton;\nexport { Skeleton };\n"],"names":["Skeleton"],"mappings":"yTAMA,MAAM,UAAY,WACZ,SAAW,YAAY,UAAU,CASvC,IAAA,SAAA,MAwCMA,UAAiB,WAAY,oCAKjC,QAAU,GAEA,QAA4B,CAIpC,OAHK,KAAK,QAGH,IAAI,CAAA,iBACQ,EAAE,SAAS,UAAU,CAAC,MACzC,CAAC,CAJQ,UAAU,AAKpB,CACF,aAXE,OAAO,AAAA,EAAA,SAAA,UAAA,UAAA,OAAA,CA5CT,SAAA,UAAA,CAAA,OAAO,UAAU,CACjB,OAAO,GAAG,CAAC,MAER,EAAE,SAAS,WAAY,EAAE,cAAc,WAAW,EAClD,EAAE,SAAS,SAAU,EAAE,cAAc,QAAQ,EAC7C,EAAE,SAAS,YACX,EAAE,SAAS,8JAQL,EAAE,SAAS,WACX,EAAE,SAAS,gBACX,EAAE,SAAS,cACX,EAAE,SAAS,6BAEA,EAAE,SAAS,+MAoBhC,CAAC,CAAC,AAAA,EAAA,SAAA,CAkBF,IAAA,WAAe"}
1
+ {"version":3,"file":"component.js","sources":["../../../src/web-components/skeleton/component.ts"],"sourcesContent":["import { godown, htmlSlot, styles } from \"@godown/element\";\nimport { type TemplateResult, css, html } from \"lit\";\nimport { state } from \"lit/decorators.js\";\n\nimport { GlobalStyle, cssGlobalVars, scopePrefix } from \"../../internal/global-style.js\";\n\nconst protoName = \"skeleton\";\nconst cssScope = scopePrefix(protoName);\n\n/**\n * {@linkcode Skeleton} renders a skeleton screen.\n *\n * @slot loading - The content if loading is true.\n * @slot - The content if loading is false.\n * @category feedback\n */\n@godown(protoName)\n@styles(css`\n :host {\n ${cssScope}--from: var(${cssGlobalVars.background});\n ${cssScope}--to: var(${cssGlobalVars.passive});\n ${cssScope}--deg: 95deg;\n ${cssScope}--duration: 2s;\n height: 2em;\n width: 100%;\n flex-shrink: 0;\n overflow: hidden;\n background-color: transparent;\n background-size: 200% 100%;\n background-image: linear-gradient(\n var(${cssScope}--deg),\n var(${cssScope}--from) 36%,\n var(${cssScope}--to) 50%,\n var(${cssScope}--from) 64%\n );\n animation: _ var(${cssScope}--duration) ease-in-out infinite none running;\n }\n\n @keyframes _ {\n from {\n background-position: 150% center;\n }\n to {\n background-position: -50% center;\n }\n }\n\n [part=\"root\"] {\n display: contents;\n }\n\n :host,\n :host([contents]) [part=\"root\"] {\n display: block;\n }\n`)\nclass Skeleton extends GlobalStyle {\n /**\n * If false, render slot only.\n */\n @state()\n loading = true;\n\n protected render(): TemplateResult<1> {\n if (!this.loading) {\n return htmlSlot();\n }\n return html`\n <div part=\"root\">${htmlSlot(\"loading\")}</div>\n `;\n }\n}\n\nexport default Skeleton;\nexport { Skeleton };\n"],"names":["protoName","cssScope","scopePrefix","Skeleton","GlobalStyle","htmlSlot","_decorate","state","godown","styles","cssGlobalVars","Skeleton$1"],"mappings":"uSAMA,MAAMA,EAAY,WACZC,EAAWC,EAAYF,GAS7B,IAAAG,EAAA,MAwCMA,UAAiBC,CAAY,oCAKjC,QAAU,GAEA,QAA4B,CAIpC,OAHK,KAAK,QAGH,CAAI,oBACUC,EAAS,WAAW,QAHhCA,MALVC,EAAA,CAAAC,KAAAJ,EAAA,UAAA,UAAA,aA5CFK,EAAOR,GACPS,EAAO,CAAG,SAELR,EAAS,aAAcS,EAAc,WAAW,IAChDT,EAAS,WAAYS,EAAc,QAAQ,IAC3CT,EAAS,cACTA,EAAS,gKAQHA,EAAS,aACTA,EAAS,kBACTA,EAAS,gBACTA,EAAS,+BAEEA,EAAS,sNAsChC,IAAAU,EAAeR"}
@@ -1 +1 @@
1
- {"mappings":"AAAA,OAAO,cAAc,gBAAiB;AAItC,eAAe;eAEA;WACH,sBAAsB;EAC9B,mBAAmB;CACpB;AACF","names":[],"sources":["../../../../src/web-components/skeleton/definition.ts"],"sourcesContent":["import Skeleton from \"./component.js\";\n\nSkeleton.define();\n\nexport default Skeleton;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"godown-skeleton\": Skeleton;\n }\n}\n"],"version":3,"file":"definition.d.ts"}
1
+ {"mappings":"AAAA,OAAO,cAAc;AAIrB,eAAe;eAEA;WACH,sBAAsB;EAC9B,mBAAmB","names":[],"sources":["../../../../src/web-components/skeleton/definition.ts"],"sourcesContent":["import Skeleton from \"./component.js\";\n\nSkeleton.define();\n\nexport default Skeleton;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"godown-skeleton\": Skeleton;\n }\n}\n"],"version":3,"file":"definition.d.ts"}
@@ -1,2 +1,2 @@
1
- import Skeleton from"./component.js";import"@godown/element";import"lit";import"lit/decorators.js";import"../../internal/global-style.js";import"../../internal/reset-style.js";import"sharekit";import"@oxc-project/runtime/helpers/decorate";Skeleton.define();export{Skeleton as default};
1
+ import e from"./component.js";e.define();export{e as default};
2
2
  //# sourceMappingURL=definition.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"definition.js","sources":["../../../src/web-components/skeleton/definition.ts"],"sourcesContent":["import Skeleton from \"./component.js\";\n\nSkeleton.define();\n\nexport default Skeleton;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"godown-skeleton\": Skeleton;\n }\n}\n"],"names":[],"mappings":"+OAEA,SAAS,QAAQ"}
1
+ {"version":3,"file":"definition.js","sources":["../../../src/web-components/skeleton/definition.ts"],"sourcesContent":["import Skeleton from \"./component.js\";\n\nSkeleton.define();\n\nexport default Skeleton;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"godown-skeleton\": Skeleton;\n }\n}\n"],"names":["Skeleton"],"mappings":"8BAEAA,EAAS"}
@@ -1 +1 @@
1
- {"mappings":"AAAA,cAAc,oBAA4E,iBAAkB;AAC5G,cAAc,sBAAiC,KAAM;AAIrD,SAAS,kBAAkB,+BAAgC;;;;;;;;;;;;;;AAoB3D,cA2CM,cAAc,WAAW;;;;CAI7B,AACA;;;;CAKA,AACA;CAEA,AACA;CAEA,AACA;CAEA;CAYA,IAAI,kBAAkB;CAItB,UAAU,UAAU,eAAe;CAiCnC;CAKA,UAAU,aAAaA,GAAG,aAAa,kBAAkB;;;;;;;;;;;;;;;;;CA4BzD,UAAU,UAAUC;CA2CpB;CAKA,QAAQC;CAKR;CAMA;AAQD;AAED,eAAe;AACf,SAAS","names":["e: HandlerEvent<HTMLInputElement, InputEvent>","data: string | null","i: number"],"sources":["../../../../src/web-components/split/component.ts"],"sourcesContent":["import { type HandlerEvent, attr, tokenList, godown, styles, loop, StyleController } from \"@godown/element\";\nimport { type TemplateResult, css, html } from \"lit\";\nimport { property, state } from \"lit/decorators.js\";\n\nimport { cssGlobalVars, scopePrefix } from \"../../internal/global-style.js\";\nimport { SuperInput } from \"../../internal/super-input.js\";\nimport { RingBuilder, ringTypeAttribute } from \"../../internal/ring.js\";\nimport { omit } from \"sharekit\";\n\nconst protoName = \"split\";\nconst cssScope = scopePrefix(protoName);\n\n/**\n * {@linkcode Split} renders multiple input boxes.\n *\n * Input: will move the focus box backward until the complete input from start to end.\n *\n * Delete: will move the focus box forward until the first and no inputs for each.\n *\n * @fires input - Fires when the input value changes.\n * @fires change - Fires when the input value changes.\n * @fires focus - Fires when the input is focused.\n * @fires blur - Fires when the input is blurred.\n * @category input\n */\n@godown(protoName)\n@styles(css`\n :host {\n display: block;\n border-radius: 0.1em;\n width: fit-content;\n ${cssScope}--size: 2em;\n ${cssScope}--gap: .25em;\n }\n\n [part=\"root\"] {\n gap: var(${cssScope}--gap);\n position: relative;\n vertical-align: top;\n display: flex;\n justify-content: space-between;\n border-radius: inherit;\n }\n\n [part=\"input-box\"] {\n width: var(${cssScope}--size);\n height: var(${cssScope}--size);\n vertical-align: top;\n border-radius: inherit;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n }\n\n [part=\"input\"] {\n width: 100%;\n height: 100%;\n opacity: 0;\n background: none;\n position: absolute;\n z-index: -1;\n }\n\n .focus,\n [part=\"input-box\"]:active {\n ${cssGlobalVars.ringColor}: var(${cssGlobalVars.active});\n }\n`)\nclass Split extends SuperInput {\n /**\n * The number of input boxes.\n */\n @property({ type: Number })\n len = 6;\n\n /**\n * Focus index.\n */\n @property({ type: Number })\n index = -1;\n\n @state()\n current = -1;\n\n @state()\n currentValue: (string | void)[] = [];\n\n constructor() {\n super();\n new StyleController(\n this,\n () =>\n new RingBuilder({\n selector: \"[part=input-box]\",\n type: this.ringType,\n }).css,\n );\n }\n\n get observedRecord(): Record<string, any> {\n return omit(super.observedRecord, ringTypeAttribute);\n }\n\n protected render(): TemplateResult<1> {\n return html`\n <div\n part=\"root\"\n ${attr(this.observedRecord)}\n >\n ${loop(\n this.len,\n (index: number) => html`\n <span\n part=\"input-box\"\n ring-type=\"${this.ringType}\"\n class=\"${tokenList({ focus: this.current === index })}\"\n @click=\"${this.disabled ? null : () => this.focusAt(index)}\"\n >\n ${this.currentValue[index]}\n </span>\n `,\n )}\n <input\n part=\"input\"\n @blur=${this.blur}\n @input=\"${this._handleInput}\"\n @change=\"${this._handleChange}\"\n .value=\"${\n /* Ensure that input always has a value of length this.len */\n this.value.padStart(this.len, \" \")\n }\"\n />\n </div>\n `;\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n this.reset();\n }\n\n protected _handleInput(e: HandlerEvent<HTMLInputElement, InputEvent>): void {\n e.stopPropagation();\n if (this.compositing) {\n return;\n }\n\n this.fillInput(e.data);\n this.value = this.currentValue.join(\"\");\n\n this.dispatchCustomEvent(\"input\", this.value, { bubbles: true });\n }\n\n /**\n * Fill input with data.\n *\n * If data is null\n * - If current value is null, move to before.\n * - If current value is not null, delete it.\n *\n * If data is not null\n * - If current value is null, input data.\n * - If current value is not null, input data and move to after.\n *\n * If data is multiple characters,\n * Fill input with data[0] and call fillInput with data.slice(1).\n *\n * @param data Input event data.\n */\n protected fillInput(data: string | null): void {\n if (data === null) {\n // delete\n\n if (this.currentValue[this.current] !== null) {\n // delete exist value\n\n this.currentValue[this.current] = null;\n } else {\n // go to before\n\n this.currentValue[this.current - 1] = null;\n const lastNotNull = this.currentValue.findLastIndex((a) => a !== null);\n this.current = this.current - 1 < 0 ? (lastNotNull < 0 ? 0 : lastNotNull) : this.current - 1;\n }\n return;\n }\n\n const multiple = data.length > 1;\n\n // input\n this.currentValue[this.current] = data[0];\n if (this.current + 1 >= this.len) {\n // index overflow\n\n this.current = this.currentValue.indexOf(null);\n if (this.current === -1) {\n this.blur();\n }\n } else {\n // go to after\n\n this.current += 1;\n }\n\n if (multiple) {\n const after = data.slice(1);\n if (after) {\n this.fillInput(after);\n }\n }\n }\n\n focus(): void {\n this.focusAt(this.current);\n super.focus();\n }\n\n focusAt(i: number): void {\n this.current = i;\n this._input.focus();\n }\n\n blur(): void {\n this._input.blur();\n this.current = -1;\n super.blur();\n }\n\n reset(): void {\n this.current = -1;\n this.value = this.default;\n this.currentValue = this.value.split(\"\").concat(Array(this.len - this.value.length).fill(null));\n if (this.index > -1) {\n this.current = this.index;\n }\n }\n}\n\nexport default Split;\nexport { Split };\n"],"version":3,"file":"component.d.ts"}
1
+ {"mappings":"AAAA,cAAc,oBAA4E;AAC1F,cAAc,sBAAiC;AAI/C,SAAS,kBAAkB;;;;;;;;;;;;;;AAoB3B,cA2CM,cAAc,WAAW;;;;CAI7B,AACA;;;;CAKA,AACA;CAEA,AACA;CAEA,AACA;CAEA;CAYA,IAAI,kBAAkB;CAItB,UAAU,UAAU,eAAe;CAiCnC;CAKA,UAAU,aAAa,GAAG,aAAa,kBAAkB;;;;;;;;;;;;;;;;;CA4BzD,UAAU,UAAU;CA2CpB;CAKA,QAAQ;CAKR;CAMA;;AAUF,eAAe;AACf,SAAS","names":[],"sources":["../../../../src/web-components/split/component.ts"],"sourcesContent":["import { type HandlerEvent, attr, tokenList, godown, styles, loop, StyleController } from \"@godown/element\";\nimport { type TemplateResult, css, html } from \"lit\";\nimport { property, state } from \"lit/decorators.js\";\n\nimport { cssGlobalVars, scopePrefix } from \"../../internal/global-style.js\";\nimport { SuperInput } from \"../../internal/super-input.js\";\nimport { RingBuilder, ringTypeAttribute } from \"../../internal/ring.js\";\nimport { omit } from \"sharekit\";\n\nconst protoName = \"split\";\nconst cssScope = scopePrefix(protoName);\n\n/**\n * {@linkcode Split} renders multiple input boxes.\n *\n * Input: will move the focus box backward until the complete input from start to end.\n *\n * Delete: will move the focus box forward until the first and no inputs for each.\n *\n * @fires input - Fires when the input value changes.\n * @fires change - Fires when the input value changes.\n * @fires focus - Fires when the input is focused.\n * @fires blur - Fires when the input is blurred.\n * @category input\n */\n@godown(protoName)\n@styles(css`\n :host {\n display: block;\n border-radius: 0.1em;\n width: fit-content;\n ${cssScope}--size: 2em;\n ${cssScope}--gap: .25em;\n }\n\n [part=\"root\"] {\n gap: var(${cssScope}--gap);\n position: relative;\n vertical-align: top;\n display: flex;\n justify-content: space-between;\n border-radius: inherit;\n }\n\n [part=\"input-box\"] {\n width: var(${cssScope}--size);\n height: var(${cssScope}--size);\n vertical-align: top;\n border-radius: inherit;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n }\n\n [part=\"input\"] {\n width: 100%;\n height: 100%;\n opacity: 0;\n background: none;\n position: absolute;\n z-index: -1;\n }\n\n .focus,\n [part=\"input-box\"]:active {\n ${cssGlobalVars.ringColor}: var(${cssGlobalVars.active});\n }\n`)\nclass Split extends SuperInput {\n /**\n * The number of input boxes.\n */\n @property({ type: Number })\n len = 6;\n\n /**\n * Focus index.\n */\n @property({ type: Number })\n index = -1;\n\n @state()\n current = -1;\n\n @state()\n currentValue: (string | void)[] = [];\n\n constructor() {\n super();\n new StyleController(\n this,\n () =>\n new RingBuilder({\n selector: \"[part=input-box]\",\n type: this.ringType,\n }).css,\n );\n }\n\n get observedRecord(): Record<string, any> {\n return omit(super.observedRecord, ringTypeAttribute);\n }\n\n protected render(): TemplateResult<1> {\n return html`\n <div\n part=\"root\"\n ${attr(this.observedRecord)}\n >\n ${loop(\n this.len,\n (index: number) => html`\n <span\n part=\"input-box\"\n ring-type=\"${this.ringType}\"\n class=\"${tokenList({ focus: this.current === index })}\"\n @click=\"${this.disabled ? null : () => this.focusAt(index)}\"\n >\n ${this.currentValue[index]}\n </span>\n `,\n )}\n <input\n part=\"input\"\n @blur=${this.blur}\n @input=\"${this._handleInput}\"\n @change=\"${this._handleChange}\"\n .value=\"${\n /* Ensure that input always has a value of length this.len */\n this.value.padStart(this.len, \" \")\n }\"\n />\n </div>\n `;\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n this.reset();\n }\n\n protected _handleInput(e: HandlerEvent<HTMLInputElement, InputEvent>): void {\n e.stopPropagation();\n if (this.compositing) {\n return;\n }\n\n this.fillInput(e.data);\n this.value = this.currentValue.join(\"\");\n\n this.dispatchCustomEvent(\"input\", this.value, { bubbles: true });\n }\n\n /**\n * Fill input with data.\n *\n * If data is null\n * - If current value is null, move to before.\n * - If current value is not null, delete it.\n *\n * If data is not null\n * - If current value is null, input data.\n * - If current value is not null, input data and move to after.\n *\n * If data is multiple characters,\n * Fill input with data[0] and call fillInput with data.slice(1).\n *\n * @param data Input event data.\n */\n protected fillInput(data: string | null): void {\n if (data === null) {\n // delete\n\n if (this.currentValue[this.current] !== null) {\n // delete exist value\n\n this.currentValue[this.current] = null;\n } else {\n // go to before\n\n this.currentValue[this.current - 1] = null;\n const lastNotNull = this.currentValue.findLastIndex((a) => a !== null);\n this.current = this.current - 1 < 0 ? (lastNotNull < 0 ? 0 : lastNotNull) : this.current - 1;\n }\n return;\n }\n\n const multiple = data.length > 1;\n\n // input\n this.currentValue[this.current] = data[0];\n if (this.current + 1 >= this.len) {\n // index overflow\n\n this.current = this.currentValue.indexOf(null);\n if (this.current === -1) {\n this.blur();\n }\n } else {\n // go to after\n\n this.current += 1;\n }\n\n if (multiple) {\n const after = data.slice(1);\n if (after) {\n this.fillInput(after);\n }\n }\n }\n\n focus(): void {\n this.focusAt(this.current);\n super.focus();\n }\n\n focusAt(i: number): void {\n this.current = i;\n this._input.focus();\n }\n\n blur(): void {\n this._input.blur();\n this.current = -1;\n super.blur();\n }\n\n reset(): void {\n this.current = -1;\n this.value = this.default;\n this.currentValue = this.value.split(\"\").concat(Array(this.len - this.value.length).fill(null));\n if (this.index > -1) {\n this.current = this.index;\n }\n }\n}\n\nexport default Split;\nexport { Split };\n"],"version":3,"file":"component.d.ts"}
@@ -1,2 +1,2 @@
1
- import{godown,styles,StyleController,attr,loop,tokenList}from"@godown/element";import{css,html}from"lit";import{property,state}from"lit/decorators.js";import{scopePrefix,cssGlobalVars}from"../../internal/global-style.js";import{SuperInput}from"../../internal/super-input.js";import{RingBuilder,ringTypeAttribute}from"../../internal/ring.js";import{omit}from"sharekit";import _decorate from"@oxc-project/runtime/helpers/decorate";import"../../internal/reset-style.js";const protoName=`split`,cssScope=scopePrefix(protoName);let Split=class e extends SuperInput{constructor(){super(),this.len=6,this.index=-1,this.current=-1,this.currentValue=[],new StyleController(this,()=>new RingBuilder({selector:`[part=input-box]`,type:this.ringType}).css)}get observedRecord(){return omit(super.observedRecord,ringTypeAttribute)}render(){return html`<div part="root" ${attr(this.observedRecord)}> ${loop(this.len,e=>html`<span part="input-box" ring-type="${this.ringType}" class="${tokenList({focus:this.current===e})}" @click="${this.disabled?null:()=>this.focusAt(e)}"> ${this.currentValue[e]} </span>`)} <input part="input" @blur=${this.blur} @input="${this._handleInput}" @change="${this._handleChange}" .value="${this.value.padStart(this.len,` `)}"/> </div>`}connectedCallback(){super.connectedCallback(),this.reset()}_handleInput(e){e.stopPropagation(),!this.compositing&&(this.fillInput(e.data),this.value=this.currentValue.join(``),this.dispatchCustomEvent(`input`,this.value,{bubbles:!0}))}fillInput(e){if(e===null){if(this.currentValue[this.current]!==null)this.currentValue[this.current]=null;else{this.currentValue[this.current-1]=null;let e=this.currentValue.findLastIndex(e=>e!==null);this.current=this.current-1<0?e<0?0:e:this.current-1}return}let b=e.length>1;if(this.currentValue[this.current]=e[0],this.current+1>=this.len?(this.current=this.currentValue.indexOf(null),this.current===-1&&this.blur()):this.current+=1,b){let b=e.slice(1);b&&this.fillInput(b)}}focus(){this.focusAt(this.current),super.focus()}focusAt(e){this.current=e,this._input.focus()}blur(){this._input.blur(),this.current=-1,super.blur()}reset(){this.current=-1,this.value=this.default,this.currentValue=this.value.split(``).concat(Array(this.len-this.value.length).fill(null)),this.index>-1&&(this.current=this.index)}};_decorate([property({type:Number})],Split.prototype,`len`,void 0),_decorate([property({type:Number})],Split.prototype,`index`,void 0),_decorate([state()],Split.prototype,`current`,void 0),_decorate([state()],Split.prototype,`currentValue`,void 0),Split=_decorate([godown(protoName),styles(css`:host{display:block;border-radius:.1em;width:-moz-fit-content;width:fit-content;${cssScope}--size:2em;${cssScope}--gap:.25em}[part=root]{gap:var(${cssScope}--gap);position:relative;vertical-align:top;display:flex;justify-content:space-between;border-radius:inherit}[part=input-box]{width:var(${cssScope}--size);height:var(${cssScope}--size);vertical-align:top;border-radius:inherit;display:inline-flex;align-items:center;justify-content:center}[part=input]{width:100%;height:100%;opacity:0;background:0 0;position:absolute;z-index:-1}.focus,[part=input-box]:active{${cssGlobalVars.ringColor}:var(${cssGlobalVars.active})}`)],Split);var Split$1=Split;export{Split,Split$1 as default};
1
+ import{godown as e,styles as t,StyleController as n,attr as r,loop as i,tokenList as a}from"@godown/element";import{css as o,html as s}from"lit";import{property as c,state as l}from"lit/decorators.js";import{scopePrefix as u,cssGlobalVars as d}from"../../internal/global-style.js";import{SuperInput as f}from"../../internal/super-input.js";import{RingBuilder as p,ringTypeAttribute as m}from"../../internal/ring.js";import{omit as h}from"sharekit";import g from"@oxc-project/runtime/helpers/decorate";const _=`split`,v=u(_);let y=class e extends f{constructor(){super(),this.len=6,this.index=-1,this.current=-1,this.currentValue=[],new n(this,()=>new p({selector:`[part=input-box]`,type:this.ringType}).css)}get observedRecord(){return h(super.observedRecord,m)}render(){return s`<div part="root" ${r(this.observedRecord)}> ${i(this.len,e=>s`<span part="input-box" ring-type="${this.ringType}" class="${a({focus:this.current===e})}" @click="${this.disabled?null:()=>this.focusAt(e)}"> ${this.currentValue[e]} </span>`)} <input part="input" @blur=${this.blur} @input="${this._handleInput}" @change="${this._handleChange}" .value="${this.value.padStart(this.len,` `)}"/> </div>`}connectedCallback(){super.connectedCallback(),this.reset()}_handleInput(e){e.stopPropagation(),!this.compositing&&(this.fillInput(e.data),this.value=this.currentValue.join(``),this.dispatchCustomEvent(`input`,this.value,{bubbles:!0}))}fillInput(e){if(e===null){if(this.currentValue[this.current]!==null)this.currentValue[this.current]=null;else{this.currentValue[this.current-1]=null;let e=this.currentValue.findLastIndex(e=>e!==null);this.current=this.current-1<0?e<0?0:e:this.current-1}return}let t=e.length>1;if(this.currentValue[this.current]=e[0],this.current+1>=this.len?(this.current=this.currentValue.indexOf(null),this.current===-1&&this.blur()):this.current+=1,t){let t=e.slice(1);t&&this.fillInput(t)}}focus(){this.focusAt(this.current),super.focus()}focusAt(e){this.current=e,this._input.focus()}blur(){this._input.blur(),this.current=-1,super.blur()}reset(){this.current=-1,this.value=this.default,this.currentValue=this.value.split(``).concat(Array(this.len-this.value.length).fill(null)),this.index>-1&&(this.current=this.index)}};g([c({type:Number})],y.prototype,`len`,void 0),g([c({type:Number})],y.prototype,`index`,void 0),g([l()],y.prototype,`current`,void 0),g([l()],y.prototype,`currentValue`,void 0),y=g([e(_),t(o`:host{display:block;border-radius:.1em;width:-moz-fit-content;width:fit-content;${v}--size:2em;${v}--gap:.25em}[part=root]{gap:var(${v}--gap);position:relative;vertical-align:top;display:flex;justify-content:space-between;border-radius:inherit}[part=input-box]{width:var(${v}--size);height:var(${v}--size);vertical-align:top;border-radius:inherit;display:inline-flex;align-items:center;justify-content:center}[part=input]{width:100%;height:100%;opacity:0;background:0 0;position:absolute;z-index:-1}.focus,[part=input-box]:active{${d.ringColor}:var(${d.active})}`)],y);var b=y;export{y as Split,b as default};
2
2
  //# sourceMappingURL=component.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"component.js","sources":["../../../src/web-components/split/component.ts"],"sourcesContent":["import { type HandlerEvent, attr, tokenList, godown, styles, loop, StyleController } from \"@godown/element\";\nimport { type TemplateResult, css, html } from \"lit\";\nimport { property, state } from \"lit/decorators.js\";\n\nimport { cssGlobalVars, scopePrefix } from \"../../internal/global-style.js\";\nimport { SuperInput } from \"../../internal/super-input.js\";\nimport { RingBuilder, ringTypeAttribute } from \"../../internal/ring.js\";\nimport { omit } from \"sharekit\";\n\nconst protoName = \"split\";\nconst cssScope = scopePrefix(protoName);\n\n/**\n * {@linkcode Split} renders multiple input boxes.\n *\n * Input: will move the focus box backward until the complete input from start to end.\n *\n * Delete: will move the focus box forward until the first and no inputs for each.\n *\n * @fires input - Fires when the input value changes.\n * @fires change - Fires when the input value changes.\n * @fires focus - Fires when the input is focused.\n * @fires blur - Fires when the input is blurred.\n * @category input\n */\n@godown(protoName)\n@styles(css`\n :host {\n display: block;\n border-radius: 0.1em;\n width: fit-content;\n ${cssScope}--size: 2em;\n ${cssScope}--gap: .25em;\n }\n\n [part=\"root\"] {\n gap: var(${cssScope}--gap);\n position: relative;\n vertical-align: top;\n display: flex;\n justify-content: space-between;\n border-radius: inherit;\n }\n\n [part=\"input-box\"] {\n width: var(${cssScope}--size);\n height: var(${cssScope}--size);\n vertical-align: top;\n border-radius: inherit;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n }\n\n [part=\"input\"] {\n width: 100%;\n height: 100%;\n opacity: 0;\n background: none;\n position: absolute;\n z-index: -1;\n }\n\n .focus,\n [part=\"input-box\"]:active {\n ${cssGlobalVars.ringColor}: var(${cssGlobalVars.active});\n }\n`)\nclass Split extends SuperInput {\n /**\n * The number of input boxes.\n */\n @property({ type: Number })\n len = 6;\n\n /**\n * Focus index.\n */\n @property({ type: Number })\n index = -1;\n\n @state()\n current = -1;\n\n @state()\n currentValue: (string | void)[] = [];\n\n constructor() {\n super();\n new StyleController(\n this,\n () =>\n new RingBuilder({\n selector: \"[part=input-box]\",\n type: this.ringType,\n }).css,\n );\n }\n\n get observedRecord(): Record<string, any> {\n return omit(super.observedRecord, ringTypeAttribute);\n }\n\n protected render(): TemplateResult<1> {\n return html`\n <div\n part=\"root\"\n ${attr(this.observedRecord)}\n >\n ${loop(\n this.len,\n (index: number) => html`\n <span\n part=\"input-box\"\n ring-type=\"${this.ringType}\"\n class=\"${tokenList({ focus: this.current === index })}\"\n @click=\"${this.disabled ? null : () => this.focusAt(index)}\"\n >\n ${this.currentValue[index]}\n </span>\n `,\n )}\n <input\n part=\"input\"\n @blur=${this.blur}\n @input=\"${this._handleInput}\"\n @change=\"${this._handleChange}\"\n .value=\"${\n /* Ensure that input always has a value of length this.len */\n this.value.padStart(this.len, \" \")\n }\"\n />\n </div>\n `;\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n this.reset();\n }\n\n protected _handleInput(e: HandlerEvent<HTMLInputElement, InputEvent>): void {\n e.stopPropagation();\n if (this.compositing) {\n return;\n }\n\n this.fillInput(e.data);\n this.value = this.currentValue.join(\"\");\n\n this.dispatchCustomEvent(\"input\", this.value, { bubbles: true });\n }\n\n /**\n * Fill input with data.\n *\n * If data is null\n * - If current value is null, move to before.\n * - If current value is not null, delete it.\n *\n * If data is not null\n * - If current value is null, input data.\n * - If current value is not null, input data and move to after.\n *\n * If data is multiple characters,\n * Fill input with data[0] and call fillInput with data.slice(1).\n *\n * @param data Input event data.\n */\n protected fillInput(data: string | null): void {\n if (data === null) {\n // delete\n\n if (this.currentValue[this.current] !== null) {\n // delete exist value\n\n this.currentValue[this.current] = null;\n } else {\n // go to before\n\n this.currentValue[this.current - 1] = null;\n const lastNotNull = this.currentValue.findLastIndex((a) => a !== null);\n this.current = this.current - 1 < 0 ? (lastNotNull < 0 ? 0 : lastNotNull) : this.current - 1;\n }\n return;\n }\n\n const multiple = data.length > 1;\n\n // input\n this.currentValue[this.current] = data[0];\n if (this.current + 1 >= this.len) {\n // index overflow\n\n this.current = this.currentValue.indexOf(null);\n if (this.current === -1) {\n this.blur();\n }\n } else {\n // go to after\n\n this.current += 1;\n }\n\n if (multiple) {\n const after = data.slice(1);\n if (after) {\n this.fillInput(after);\n }\n }\n }\n\n focus(): void {\n this.focusAt(this.current);\n super.focus();\n }\n\n focusAt(i: number): void {\n this.current = i;\n this._input.focus();\n }\n\n blur(): void {\n this._input.blur();\n this.current = -1;\n super.blur();\n }\n\n reset(): void {\n this.current = -1;\n this.value = this.default;\n this.currentValue = this.value.split(\"\").concat(Array(this.len - this.value.length).fill(null));\n if (this.index > -1) {\n this.current = this.index;\n }\n }\n}\n\nexport default Split;\nexport { Split };\n"],"names":["Split","index: number","index","e: HandlerEvent<HTMLInputElement, InputEvent>","data: string | null","data","lastNotNull","a","multiple","after","i: number","i","Array(this.len - this.value.length)"],"mappings":"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"}
1
+ {"version":3,"file":"component.js","sources":["../../../src/web-components/split/component.ts"],"sourcesContent":["import { type HandlerEvent, attr, tokenList, godown, styles, loop, StyleController } from \"@godown/element\";\nimport { type TemplateResult, css, html } from \"lit\";\nimport { property, state } from \"lit/decorators.js\";\n\nimport { cssGlobalVars, scopePrefix } from \"../../internal/global-style.js\";\nimport { SuperInput } from \"../../internal/super-input.js\";\nimport { RingBuilder, ringTypeAttribute } from \"../../internal/ring.js\";\nimport { omit } from \"sharekit\";\n\nconst protoName = \"split\";\nconst cssScope = scopePrefix(protoName);\n\n/**\n * {@linkcode Split} renders multiple input boxes.\n *\n * Input: will move the focus box backward until the complete input from start to end.\n *\n * Delete: will move the focus box forward until the first and no inputs for each.\n *\n * @fires input - Fires when the input value changes.\n * @fires change - Fires when the input value changes.\n * @fires focus - Fires when the input is focused.\n * @fires blur - Fires when the input is blurred.\n * @category input\n */\n@godown(protoName)\n@styles(css`\n :host {\n display: block;\n border-radius: 0.1em;\n width: fit-content;\n ${cssScope}--size: 2em;\n ${cssScope}--gap: .25em;\n }\n\n [part=\"root\"] {\n gap: var(${cssScope}--gap);\n position: relative;\n vertical-align: top;\n display: flex;\n justify-content: space-between;\n border-radius: inherit;\n }\n\n [part=\"input-box\"] {\n width: var(${cssScope}--size);\n height: var(${cssScope}--size);\n vertical-align: top;\n border-radius: inherit;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n }\n\n [part=\"input\"] {\n width: 100%;\n height: 100%;\n opacity: 0;\n background: none;\n position: absolute;\n z-index: -1;\n }\n\n .focus,\n [part=\"input-box\"]:active {\n ${cssGlobalVars.ringColor}: var(${cssGlobalVars.active});\n }\n`)\nclass Split extends SuperInput {\n /**\n * The number of input boxes.\n */\n @property({ type: Number })\n len = 6;\n\n /**\n * Focus index.\n */\n @property({ type: Number })\n index = -1;\n\n @state()\n current = -1;\n\n @state()\n currentValue: (string | void)[] = [];\n\n constructor() {\n super();\n new StyleController(\n this,\n () =>\n new RingBuilder({\n selector: \"[part=input-box]\",\n type: this.ringType,\n }).css,\n );\n }\n\n get observedRecord(): Record<string, any> {\n return omit(super.observedRecord, ringTypeAttribute);\n }\n\n protected render(): TemplateResult<1> {\n return html`\n <div\n part=\"root\"\n ${attr(this.observedRecord)}\n >\n ${loop(\n this.len,\n (index: number) => html`\n <span\n part=\"input-box\"\n ring-type=\"${this.ringType}\"\n class=\"${tokenList({ focus: this.current === index })}\"\n @click=\"${this.disabled ? null : () => this.focusAt(index)}\"\n >\n ${this.currentValue[index]}\n </span>\n `,\n )}\n <input\n part=\"input\"\n @blur=${this.blur}\n @input=\"${this._handleInput}\"\n @change=\"${this._handleChange}\"\n .value=\"${\n /* Ensure that input always has a value of length this.len */\n this.value.padStart(this.len, \" \")\n }\"\n />\n </div>\n `;\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n this.reset();\n }\n\n protected _handleInput(e: HandlerEvent<HTMLInputElement, InputEvent>): void {\n e.stopPropagation();\n if (this.compositing) {\n return;\n }\n\n this.fillInput(e.data);\n this.value = this.currentValue.join(\"\");\n\n this.dispatchCustomEvent(\"input\", this.value, { bubbles: true });\n }\n\n /**\n * Fill input with data.\n *\n * If data is null\n * - If current value is null, move to before.\n * - If current value is not null, delete it.\n *\n * If data is not null\n * - If current value is null, input data.\n * - If current value is not null, input data and move to after.\n *\n * If data is multiple characters,\n * Fill input with data[0] and call fillInput with data.slice(1).\n *\n * @param data Input event data.\n */\n protected fillInput(data: string | null): void {\n if (data === null) {\n // delete\n\n if (this.currentValue[this.current] !== null) {\n // delete exist value\n\n this.currentValue[this.current] = null;\n } else {\n // go to before\n\n this.currentValue[this.current - 1] = null;\n const lastNotNull = this.currentValue.findLastIndex((a) => a !== null);\n this.current = this.current - 1 < 0 ? (lastNotNull < 0 ? 0 : lastNotNull) : this.current - 1;\n }\n return;\n }\n\n const multiple = data.length > 1;\n\n // input\n this.currentValue[this.current] = data[0];\n if (this.current + 1 >= this.len) {\n // index overflow\n\n this.current = this.currentValue.indexOf(null);\n if (this.current === -1) {\n this.blur();\n }\n } else {\n // go to after\n\n this.current += 1;\n }\n\n if (multiple) {\n const after = data.slice(1);\n if (after) {\n this.fillInput(after);\n }\n }\n }\n\n focus(): void {\n this.focusAt(this.current);\n super.focus();\n }\n\n focusAt(i: number): void {\n this.current = i;\n this._input.focus();\n }\n\n blur(): void {\n this._input.blur();\n this.current = -1;\n super.blur();\n }\n\n reset(): void {\n this.current = -1;\n this.value = this.default;\n this.currentValue = this.value.split(\"\").concat(Array(this.len - this.value.length).fill(null));\n if (this.index > -1) {\n this.current = this.index;\n }\n }\n}\n\nexport default Split;\nexport { Split };\n"],"names":["protoName","cssScope","scopePrefix","Split","SuperInput","StyleController","RingBuilder","omit","ringTypeAttribute","attr","loop","tokenList","index","data","lastNotNull","a","multiple","after","i","_decorate","property","state","godown","styles","cssGlobalVars","Split$1"],"mappings":"qfASA,MAAMA,EAAY,QACZC,EAAWC,EAAYF,GAe7B,IAAAG,EAAA,MA2CMA,UAAcC,CAAW,CAmB7B,aAAc,CACZ,aAfF,IAAM,EAMN,KAAA,MAAQ,GAGR,KAAA,QAAU,QAGV,aAAkC,GAIhC,IAAIC,EACF,SAEE,IAAIC,EAAY,CACd,SAAU,mBACV,KAAM,KAAK,WACV,KAIT,IAAI,gBAAsC,CACxC,OAAOC,EAAK,MAAM,eAAgBC,GAG1B,QAA4B,CACpC,MAAO,EAAI,oBAGLC,EAAK,KAAK,gBAAA,IAEVC,EACA,KAAK,IACJ,GAAkB,CAAI,qCAGN,KAAK,SAAS,WAClBC,EAAU,CAAE,MAAO,KAAK,UAAYC,IAAS,YAC5C,KAAK,SAAW,SAAa,KAAK,QAAQA,GAAO,KAEzD,KAAK,aAAaA,GAAA,WAGxB,6BAGQ,KAAK,KAAA,WACH,KAAK,aAAa,aACjB,KAAK,cAAc,YAG5B,KAAK,MAAM,SAAS,KAAK,IAAK,KAC/B,YAMT,mBAA0B,CACxB,MAAM,oBACN,KAAK,QAGG,aAAa,EAAqD,CAC1E,EAAE,kBACE,MAAK,cAIT,KAAK,UAAU,EAAE,MACjB,KAAK,MAAQ,KAAK,aAAa,KAAK,IAEpC,KAAK,oBAAoB,QAAS,KAAK,MAAO,CAAE,QAAS,MAmBjD,UAAU,EAA2B,CAC7C,GAAIC,IAAS,KAAM,CAGjB,GAAI,KAAK,aAAa,KAAK,WAAa,KAGtC,KAAK,aAAa,KAAK,SAAW,SAC7B,CAGL,KAAK,aAAa,KAAK,QAAU,GAAK,KACtC,IAAMC,EAAc,KAAK,aAAa,cAAe,GAAMC,IAAM,MACjE,KAAK,QAAU,KAAK,QAAU,EAAI,EAAKD,EAAc,EAAI,EAAIA,EAAe,KAAK,QAAU,EAE7F,OAGF,IAAME,EAAWH,EAAK,OAAS,EAiB/B,GAdA,KAAK,aAAa,KAAK,SAAWA,EAAK,GACnC,KAAK,QAAU,GAAK,KAAK,KAG3B,KAAK,QAAU,KAAK,aAAa,QAAQ,MACrC,KAAK,UAAY,IACnB,KAAK,QAKP,KAAK,SAAW,EAGdG,EAAU,CACZ,IAAMC,EAAQJ,EAAK,MAAM,GACrBI,GACF,KAAK,UAAUA,IAKrB,OAAc,CACZ,KAAK,QAAQ,KAAK,SAClB,MAAM,QAGR,QAAQ,EAAiB,CACvB,KAAK,QAAUC,EACf,KAAK,OAAO,QAGd,MAAa,CACX,KAAK,OAAO,OACZ,KAAK,QAAU,GACf,MAAM,OAGR,OAAc,CACZ,KAAK,QAAU,GACf,KAAK,MAAQ,KAAK,QAClB,KAAK,aAAe,KAAK,MAAM,MAAM,IAAI,OAAO,MAAM,KAAK,IAAM,KAAK,MAAM,QAAQ,KAAK,OACrF,KAAK,MAAQ,KACf,KAAK,QAAU,KAAK,SAjKvBC,EAAA,CAAAC,EAAS,CAAE,KAAM,UAAAjB,EAAA,UAAA,MAAA,QAMjBgB,EAAA,CAAAC,EAAS,CAAE,KAAM,UAAAjB,EAAA,UAAA,QAAA,QAGjBgB,EAAA,CAAAE,KAAAlB,EAAA,UAAA,UAAA,QAGAgB,EAAA,CAAAE,KAAAlB,EAAA,UAAA,eAAA,aA3DFmB,EAAOtB,GACPuB,EAAO,CAAG,mFAKLtB,EAAS,aACTA,EAAS,kCAIAA,EAAS,0IASPA,EAAS,qBACRA,EAAS,0OAmBrBuB,EAAc,UAAU,OAAQA,EAAc,OAAO,SA6K3D,IAAAC,EAAetB"}
@@ -1 +1 @@
1
- {"mappings":"AAAA,OAAO,WAAW,gBAAiB;AAInC,eAAe;eAEA;WACH,sBAAsB;EAC9B,gBAAgB;CACjB;AACF","names":[],"sources":["../../../../src/web-components/split/definition.ts"],"sourcesContent":["import Split from \"./component.js\";\n\nSplit.define();\n\nexport default Split;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"godown-split\": Split;\n }\n}\n"],"version":3,"file":"definition.d.ts"}
1
+ {"mappings":"AAAA,OAAO,WAAW;AAIlB,eAAe;eAEA;WACH,sBAAsB;EAC9B,gBAAgB","names":[],"sources":["../../../../src/web-components/split/definition.ts"],"sourcesContent":["import Split from \"./component.js\";\n\nSplit.define();\n\nexport default Split;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"godown-split\": Split;\n }\n}\n"],"version":3,"file":"definition.d.ts"}
@@ -1,2 +1,2 @@
1
- import Split from"./component.js";import"@godown/element";import"lit";import"lit/decorators.js";import"../../internal/global-style.js";import"../../internal/reset-style.js";import"sharekit";import"../../internal/super-input.js";import"../../internal/ring.js";import"@oxc-project/runtime/helpers/decorate";Split.define();export{Split as default};
1
+ import e from"./component.js";e.define();export{e as default};
2
2
  //# sourceMappingURL=definition.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"definition.js","sources":["../../../src/web-components/split/definition.ts"],"sourcesContent":["import Split from \"./component.js\";\n\nSplit.define();\n\nexport default Split;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"godown-split\": Split;\n }\n}\n"],"names":[],"mappings":"iTAEA,MAAM,QAAQ"}
1
+ {"version":3,"file":"definition.js","sources":["../../../src/web-components/split/definition.ts"],"sourcesContent":["import Split from \"./component.js\";\n\nSplit.define();\n\nexport default Split;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"godown-split\": Split;\n }\n}\n"],"names":["Split"],"mappings":"8BAEAA,EAAM"}
@@ -1 +1 @@
1
- {"mappings":"AACA,cAAc,sBAAiC,KAAM;AAIrD,SAAS,kBAAkB,+BAAgC;;;;;;;AAa3D,cA0DM,eAAe,oBAAoB;CACvC,IAAI,QAAQA;CAIZ,IAAI;;;;CAOJ,AACA;;;;CAKA,AACA;CAEA,IAAI,kBAAkB;CAItB,UAAU,UAAU,eAAe;CAmBnC;CAKA,UAAU;CAWV,UAAU;AAKX;AAED,eAAe;AACf,SAAS","names":["v: boolean"],"sources":["../../../../src/web-components/switch/component.ts"],"sourcesContent":["import { attr, godown, styles } from \"@godown/element\";\nimport { type TemplateResult, css, html } from \"lit\";\nimport { property } from \"lit/decorators.js\";\n\nimport { cssGlobalVars, scopePrefix } from \"../../internal/global-style.js\";\nimport { SuperInput } from \"../../internal/super-input.js\";\nimport { ringTypeAttribute } from \"../../internal/ring.js\";\nimport { omit } from \"sharekit\";\n\nconst protoName = \"switch\";\nconst cssScope = scopePrefix(protoName);\n\n/**\n * {@linkcode Switch} renders a switch.\n *\n * @fires change - Fires when the switch is switched.\n * @category input\n */\n@godown(protoName)\n@styles(css`\n :host,\n :host([contents]) [part=\"root\"] {\n display: inline-block;\n }\n\n :host {\n ${cssScope}-width: 3em;\n ${cssScope}-height: calc(var(${cssScope}-width) / 2);\n ${cssScope}-handle-size: 1.25em;\n ${cssScope}-handle-space: calc(var(${cssScope}-width) / 4 - var(${cssScope}-handle-size) / 2);\n width: var(${cssScope}-width);\n height: var(${cssScope}-height);\n border-radius: calc(var(${cssScope}-height) / 2);\n background: var(${cssGlobalVars.passive});\n vertical-align: bottom;\n transition: 0.2s ease-in-out;\n transition-property: background, left;\n }\n\n :host([checked]) {\n background: var(${cssGlobalVars.active});\n }\n\n [part=\"root\"] {\n display: flex;\n align-items: center;\n position: relative;\n transition: inherit;\n }\n\n [part=\"handle\"] {\n display: flex;\n align-items: center;\n justify-content: center;\n position: absolute;\n transition: inherit;\n left: 0;\n top: 50%;\n pointer-events: none;\n border-radius: 100%;\n background: var(${cssGlobalVars.background});\n width: var(${cssScope}-handle-size);\n height: var(${cssScope}-handle-size);\n transform: translateY(-50%) translateX(var(${cssScope}-handle-space));\n }\n\n :host([checked]) [part=\"handle\"] {\n left: 50%;\n }\n\n [part=\"input\"] {\n opacity: 0;\n width: 100%;\n height: 100%;\n }\n`)\nclass Switch extends SuperInput<boolean> {\n set checked(v: boolean) {\n this.value = v;\n }\n\n get checked(): boolean {\n return this.value;\n }\n\n /**\n * Default checked state.\n */\n @property({ type: Boolean })\n default = false;\n\n /**\n * The current value of the switch component. Reflects the \"checked\" attribute.\n */\n @property({ type: Boolean, attribute: \"checked\", reflect: true })\n value = false;\n\n get observedRecord(): Record<string, any> {\n return omit(super.observedRecord, ringTypeAttribute);\n }\n\n protected render(): TemplateResult<1> {\n return html`\n <div\n part=\"root\"\n ${attr(this.observedRecord)}\n class=\"round\"\n >\n <input\n part=\"input\"\n type=\"checkbox\"\n ?disabled=\"${this.disabled}\"\n ?checked=\"${this.value}\"\n @change=\"${this._handleChange}\"\n />\n <span part=\"handle\"></span>\n </div>\n `;\n }\n\n reset(): void {\n this.value = this.default;\n this._input.checked = this.value;\n }\n\n protected _connectedInit(): void {\n if (this.default) {\n this.value = true;\n } else {\n if (this.value) {\n this.value = true;\n this.default = true;\n }\n }\n }\n\n protected _handleChange(): void {\n const { checked } = this._input;\n this.value = checked;\n this.dispatchCustomEvent(\"change\", this.value);\n }\n}\n\nexport default Switch;\nexport { Switch };\n"],"version":3,"file":"component.d.ts"}
1
+ {"mappings":"AACA,cAAc,sBAAiC;AAI/C,SAAS,kBAAkB;;;;;;;AAa3B,cA0DM,eAAe,oBAAoB;CACvC,IAAI,QAAQ;CAIZ,IAAI;;;;CAOJ,AACA;;;;CAKA,AACA;CAEA,IAAI,kBAAkB;CAItB,UAAU,UAAU,eAAe;CAmBnC;CAKA,UAAU;CAWV,UAAU;;AAOZ,eAAe;AACf,SAAS","names":[],"sources":["../../../../src/web-components/switch/component.ts"],"sourcesContent":["import { attr, godown, styles } from \"@godown/element\";\nimport { type TemplateResult, css, html } from \"lit\";\nimport { property } from \"lit/decorators.js\";\n\nimport { cssGlobalVars, scopePrefix } from \"../../internal/global-style.js\";\nimport { SuperInput } from \"../../internal/super-input.js\";\nimport { ringTypeAttribute } from \"../../internal/ring.js\";\nimport { omit } from \"sharekit\";\n\nconst protoName = \"switch\";\nconst cssScope = scopePrefix(protoName);\n\n/**\n * {@linkcode Switch} renders a switch.\n *\n * @fires change - Fires when the switch is switched.\n * @category input\n */\n@godown(protoName)\n@styles(css`\n :host,\n :host([contents]) [part=\"root\"] {\n display: inline-block;\n }\n\n :host {\n ${cssScope}-width: 3em;\n ${cssScope}-height: calc(var(${cssScope}-width) / 2);\n ${cssScope}-handle-size: 1.25em;\n ${cssScope}-handle-space: calc(var(${cssScope}-width) / 4 - var(${cssScope}-handle-size) / 2);\n width: var(${cssScope}-width);\n height: var(${cssScope}-height);\n border-radius: calc(var(${cssScope}-height) / 2);\n background: var(${cssGlobalVars.passive});\n vertical-align: bottom;\n transition: 0.2s ease-in-out;\n transition-property: background, left;\n }\n\n :host([checked]) {\n background: var(${cssGlobalVars.active});\n }\n\n [part=\"root\"] {\n display: flex;\n align-items: center;\n position: relative;\n transition: inherit;\n }\n\n [part=\"handle\"] {\n display: flex;\n align-items: center;\n justify-content: center;\n position: absolute;\n transition: inherit;\n left: 0;\n top: 50%;\n pointer-events: none;\n border-radius: 100%;\n background: var(${cssGlobalVars.background});\n width: var(${cssScope}-handle-size);\n height: var(${cssScope}-handle-size);\n transform: translateY(-50%) translateX(var(${cssScope}-handle-space));\n }\n\n :host([checked]) [part=\"handle\"] {\n left: 50%;\n }\n\n [part=\"input\"] {\n opacity: 0;\n width: 100%;\n height: 100%;\n }\n`)\nclass Switch extends SuperInput<boolean> {\n set checked(v: boolean) {\n this.value = v;\n }\n\n get checked(): boolean {\n return this.value;\n }\n\n /**\n * Default checked state.\n */\n @property({ type: Boolean })\n default = false;\n\n /**\n * The current value of the switch component. Reflects the \"checked\" attribute.\n */\n @property({ type: Boolean, attribute: \"checked\", reflect: true })\n value = false;\n\n get observedRecord(): Record<string, any> {\n return omit(super.observedRecord, ringTypeAttribute);\n }\n\n protected render(): TemplateResult<1> {\n return html`\n <div\n part=\"root\"\n ${attr(this.observedRecord)}\n class=\"round\"\n >\n <input\n part=\"input\"\n type=\"checkbox\"\n ?disabled=\"${this.disabled}\"\n ?checked=\"${this.value}\"\n @change=\"${this._handleChange}\"\n />\n <span part=\"handle\"></span>\n </div>\n `;\n }\n\n reset(): void {\n this.value = this.default;\n this._input.checked = this.value;\n }\n\n protected _connectedInit(): void {\n if (this.default) {\n this.value = true;\n } else {\n if (this.value) {\n this.value = true;\n this.default = true;\n }\n }\n }\n\n protected _handleChange(): void {\n const { checked } = this._input;\n this.value = checked;\n this.dispatchCustomEvent(\"change\", this.value);\n }\n}\n\nexport default Switch;\nexport { Switch };\n"],"version":3,"file":"component.d.ts"}
@@ -1,2 +1,2 @@
1
- import{godown,styles,attr}from"@godown/element";import{css,html}from"lit";import{property}from"lit/decorators.js";import{scopePrefix,cssGlobalVars}from"../../internal/global-style.js";import{SuperInput}from"../../internal/super-input.js";import{ringTypeAttribute}from"../../internal/ring.js";import{omit}from"sharekit";import _decorate from"@oxc-project/runtime/helpers/decorate";import"../../internal/reset-style.js";const protoName=`switch`,cssScope=scopePrefix(protoName);let Switch=class e extends SuperInput{constructor(...e){super(...e),this.default=!1,this.value=!1}set checked(e){this.value=e}get checked(){return this.value}get observedRecord(){return omit(super.observedRecord,ringTypeAttribute)}render(){return html`<div part="root" ${attr(this.observedRecord)} class="round"> <input part="input" type="checkbox" ?disabled="${this.disabled}" ?checked="${this.value}" @change="${this._handleChange}"/> <span part="handle"></span> </div>`}reset(){this.value=this.default,this._input.checked=this.value}_connectedInit(){this.default?this.value=!0:this.value&&(this.value=!0,this.default=!0)}_handleChange(){let{checked:e}=this._input;this.value=e,this.dispatchCustomEvent(`change`,this.value)}};_decorate([property({type:Boolean})],Switch.prototype,`default`,void 0),_decorate([property({type:Boolean,attribute:`checked`,reflect:!0})],Switch.prototype,`value`,void 0),Switch=_decorate([godown(protoName),styles(css`:host,:host([contents]) [part=root]{display:inline-block}:host{${cssScope}-width:3em;${cssScope}-height:calc(var(${cssScope}-width)/2);${cssScope}-handle-size:1.25em;${cssScope}-handle-space:calc(var(${cssScope}-width)/4 - var(${cssScope}-handle-size)/2);width:var(${cssScope}-width);height:var(${cssScope}-height);border-radius:calc(var(${cssScope}-height)/2);background:var(${cssGlobalVars.passive});vertical-align:bottom;transition:.2s ease-in-out;transition-property:background,left}:host([checked]){background:var(${cssGlobalVars.active})}[part=root]{display:flex;align-items:center;position:relative;transition:inherit}[part=handle]{display:flex;align-items:center;justify-content:center;position:absolute;transition:inherit;left:0;top:50%;pointer-events:none;border-radius:100%;background:var(${cssGlobalVars.background});width:var(${cssScope}-handle-size);height:var(${cssScope}-handle-size);transform:translateY(-50%) translateX(var(${cssScope}-handle-space))}:host([checked]) [part=handle]{left:50%}[part=input]{opacity:0;width:100%;height:100%}`)],Switch);var Switch$1=Switch;export{Switch,Switch$1 as default};
1
+ import{godown as e,styles as t,attr as n}from"@godown/element";import{css as r,html as i}from"lit";import{property as a}from"lit/decorators.js";import{scopePrefix as o,cssGlobalVars as s}from"../../internal/global-style.js";import{SuperInput as c}from"../../internal/super-input.js";import{ringTypeAttribute as l}from"../../internal/ring.js";import{omit as u}from"sharekit";import d from"@oxc-project/runtime/helpers/decorate";const f=`switch`,p=o(f);let m=class e extends c{constructor(...e){super(...e),this.default=!1,this.value=!1}set checked(e){this.value=e}get checked(){return this.value}get observedRecord(){return u(super.observedRecord,l)}render(){return i`<div part="root" ${n(this.observedRecord)} class="round"> <input part="input" type="checkbox" ?disabled="${this.disabled}" ?checked="${this.value}" @change="${this._handleChange}"/> <span part="handle"></span> </div>`}reset(){this.value=this.default,this._input.checked=this.value}_connectedInit(){this.default?this.value=!0:this.value&&(this.value=!0,this.default=!0)}_handleChange(){let{checked:e}=this._input;this.value=e,this.dispatchCustomEvent(`change`,this.value)}};d([a({type:Boolean})],m.prototype,`default`,void 0),d([a({type:Boolean,attribute:`checked`,reflect:!0})],m.prototype,`value`,void 0),m=d([e(f),t(r`:host,:host([contents]) [part=root]{display:inline-block}:host{${p}-width:3em;${p}-height:calc(var(${p}-width)/2);${p}-handle-size:1.25em;${p}-handle-space:calc(var(${p}-width)/4 - var(${p}-handle-size)/2);width:var(${p}-width);height:var(${p}-height);border-radius:calc(var(${p}-height)/2);background:var(${s.passive});vertical-align:bottom;transition:.2s ease-in-out;transition-property:background,left}:host([checked]){background:var(${s.active})}[part=root]{display:flex;align-items:center;position:relative;transition:inherit}[part=handle]{display:flex;align-items:center;justify-content:center;position:absolute;transition:inherit;left:0;top:50%;pointer-events:none;border-radius:100%;background:var(${s.background});width:var(${p}-handle-size);height:var(${p}-handle-size);transform:translateY(-50%) translateX(var(${p}-handle-space))}:host([checked]) [part=handle]{left:50%}[part=input]{opacity:0;width:100%;height:100%}`)],m);var h=m;export{m as Switch,h as default};
2
2
  //# sourceMappingURL=component.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"component.js","sources":["../../../src/web-components/switch/component.ts"],"sourcesContent":["import { attr, godown, styles } from \"@godown/element\";\nimport { type TemplateResult, css, html } from \"lit\";\nimport { property } from \"lit/decorators.js\";\n\nimport { cssGlobalVars, scopePrefix } from \"../../internal/global-style.js\";\nimport { SuperInput } from \"../../internal/super-input.js\";\nimport { ringTypeAttribute } from \"../../internal/ring.js\";\nimport { omit } from \"sharekit\";\n\nconst protoName = \"switch\";\nconst cssScope = scopePrefix(protoName);\n\n/**\n * {@linkcode Switch} renders a switch.\n *\n * @fires change - Fires when the switch is switched.\n * @category input\n */\n@godown(protoName)\n@styles(css`\n :host,\n :host([contents]) [part=\"root\"] {\n display: inline-block;\n }\n\n :host {\n ${cssScope}-width: 3em;\n ${cssScope}-height: calc(var(${cssScope}-width) / 2);\n ${cssScope}-handle-size: 1.25em;\n ${cssScope}-handle-space: calc(var(${cssScope}-width) / 4 - var(${cssScope}-handle-size) / 2);\n width: var(${cssScope}-width);\n height: var(${cssScope}-height);\n border-radius: calc(var(${cssScope}-height) / 2);\n background: var(${cssGlobalVars.passive});\n vertical-align: bottom;\n transition: 0.2s ease-in-out;\n transition-property: background, left;\n }\n\n :host([checked]) {\n background: var(${cssGlobalVars.active});\n }\n\n [part=\"root\"] {\n display: flex;\n align-items: center;\n position: relative;\n transition: inherit;\n }\n\n [part=\"handle\"] {\n display: flex;\n align-items: center;\n justify-content: center;\n position: absolute;\n transition: inherit;\n left: 0;\n top: 50%;\n pointer-events: none;\n border-radius: 100%;\n background: var(${cssGlobalVars.background});\n width: var(${cssScope}-handle-size);\n height: var(${cssScope}-handle-size);\n transform: translateY(-50%) translateX(var(${cssScope}-handle-space));\n }\n\n :host([checked]) [part=\"handle\"] {\n left: 50%;\n }\n\n [part=\"input\"] {\n opacity: 0;\n width: 100%;\n height: 100%;\n }\n`)\nclass Switch extends SuperInput<boolean> {\n set checked(v: boolean) {\n this.value = v;\n }\n\n get checked(): boolean {\n return this.value;\n }\n\n /**\n * Default checked state.\n */\n @property({ type: Boolean })\n default = false;\n\n /**\n * The current value of the switch component. Reflects the \"checked\" attribute.\n */\n @property({ type: Boolean, attribute: \"checked\", reflect: true })\n value = false;\n\n get observedRecord(): Record<string, any> {\n return omit(super.observedRecord, ringTypeAttribute);\n }\n\n protected render(): TemplateResult<1> {\n return html`\n <div\n part=\"root\"\n ${attr(this.observedRecord)}\n class=\"round\"\n >\n <input\n part=\"input\"\n type=\"checkbox\"\n ?disabled=\"${this.disabled}\"\n ?checked=\"${this.value}\"\n @change=\"${this._handleChange}\"\n />\n <span part=\"handle\"></span>\n </div>\n `;\n }\n\n reset(): void {\n this.value = this.default;\n this._input.checked = this.value;\n }\n\n protected _connectedInit(): void {\n if (this.default) {\n this.value = true;\n } else {\n if (this.value) {\n this.value = true;\n this.default = true;\n }\n }\n }\n\n protected _handleChange(): void {\n const { checked } = this._input;\n this.value = checked;\n this.dispatchCustomEvent(\"change\", this.value);\n }\n}\n\nexport default Switch;\nexport { Switch };\n"],"names":["Switch","v: boolean","v","checked"],"mappings":"kaASA,MAAM,UAAY,SACZ,SAAW,YAAY,UAAU,CAQvC,IAAA,OAAA,MA0DMA,UAAe,UAAoB,oCAavC,QAAU,QAMV,MAAQ,GAlBR,IAAI,QAAQC,EAAY,CACtB,KAAK,MAAQC,CACd,CAED,IAAI,SAAmB,CACrB,OAAO,KAAK,KACb,CAcD,IAAI,gBAAsC,CACxC,OAAO,KAAK,MAAM,eAAgB,kBAAkB,AACrD,CAES,QAA4B,CACpC,MAAO,KAAI,CAAA,iBAGP,EAAE,KAAK,KAAK,eAAe,CAAA,+DAMd,EAAE,KAAK,SAAS,YACjB,EAAE,KAAK,MAAM,WACd,EAAE,KAAK,cAAc,sCAIpC,CAAC,AACF,CAED,OAAc,CACZ,KAAK,MAAQ,KAAK,QAClB,KAAK,OAAO,QAAU,KAAK,KAC5B,CAES,gBAAuB,CAC3B,KAAK,QACP,KAAK,MAAQ,GAET,KAAK,QACP,KAAK,MAAQ,GACb,KAAK,QAAU,GAGpB,CAES,eAAsB,CAC9B,GAAM,CAAE,UAAS,CAAG,KAAK,OACzB,KAAK,MAAQC,EACb,KAAK,oBAAoB,SAAU,KAAK,MAAM,AAC/C,CACF,aArDE,SAAS,CAAE,KAAM,OAAS,EAAC,AAAA,EAAA,OAAA,UAAA,UAAA,OAAA,YAM3B,SAAS,CAAE,KAAM,QAAS,UAAW,UAAW,QAAS,EAAM,EAAC,AAAA,EAAA,OAAA,UAAA,QAAA,IAAA,GAAA,CA5ElE,OAAA,UAAA,CAAA,OAAO,UAAU,CACjB,OAAO,GAAG,CAAC,+DAOR,EAAE,SAAS,WACX,EAAE,SAAS,iBAAkB,EAAE,SAAS,WACxC,EAAE,SAAS,oBACX,EAAE,SAAS,uBAAwB,EAAE,SAAS,gBAAkB,EAAE,SAAS,2BAChE,EAAE,SAAS,mBACV,EAAE,SAAS,gCACC,EAAE,SAAS,2BACnB,EAAE,cAAc,QAAQ,uHAOxB,EAAE,cAAc,OAAO,kQAoBvB,EAAE,cAAc,WAAW,YAChC,EAAE,SAAS,yBACV,EAAE,SAAS,wDACoB,EAAE,SAAS,sGAY1D,CAAC,CAAC,AAAA,EAAA,OAAA,CAoEF,IAAA,SAAe"}
1
+ {"version":3,"file":"component.js","sources":["../../../src/web-components/switch/component.ts"],"sourcesContent":["import { attr, godown, styles } from \"@godown/element\";\nimport { type TemplateResult, css, html } from \"lit\";\nimport { property } from \"lit/decorators.js\";\n\nimport { cssGlobalVars, scopePrefix } from \"../../internal/global-style.js\";\nimport { SuperInput } from \"../../internal/super-input.js\";\nimport { ringTypeAttribute } from \"../../internal/ring.js\";\nimport { omit } from \"sharekit\";\n\nconst protoName = \"switch\";\nconst cssScope = scopePrefix(protoName);\n\n/**\n * {@linkcode Switch} renders a switch.\n *\n * @fires change - Fires when the switch is switched.\n * @category input\n */\n@godown(protoName)\n@styles(css`\n :host,\n :host([contents]) [part=\"root\"] {\n display: inline-block;\n }\n\n :host {\n ${cssScope}-width: 3em;\n ${cssScope}-height: calc(var(${cssScope}-width) / 2);\n ${cssScope}-handle-size: 1.25em;\n ${cssScope}-handle-space: calc(var(${cssScope}-width) / 4 - var(${cssScope}-handle-size) / 2);\n width: var(${cssScope}-width);\n height: var(${cssScope}-height);\n border-radius: calc(var(${cssScope}-height) / 2);\n background: var(${cssGlobalVars.passive});\n vertical-align: bottom;\n transition: 0.2s ease-in-out;\n transition-property: background, left;\n }\n\n :host([checked]) {\n background: var(${cssGlobalVars.active});\n }\n\n [part=\"root\"] {\n display: flex;\n align-items: center;\n position: relative;\n transition: inherit;\n }\n\n [part=\"handle\"] {\n display: flex;\n align-items: center;\n justify-content: center;\n position: absolute;\n transition: inherit;\n left: 0;\n top: 50%;\n pointer-events: none;\n border-radius: 100%;\n background: var(${cssGlobalVars.background});\n width: var(${cssScope}-handle-size);\n height: var(${cssScope}-handle-size);\n transform: translateY(-50%) translateX(var(${cssScope}-handle-space));\n }\n\n :host([checked]) [part=\"handle\"] {\n left: 50%;\n }\n\n [part=\"input\"] {\n opacity: 0;\n width: 100%;\n height: 100%;\n }\n`)\nclass Switch extends SuperInput<boolean> {\n set checked(v: boolean) {\n this.value = v;\n }\n\n get checked(): boolean {\n return this.value;\n }\n\n /**\n * Default checked state.\n */\n @property({ type: Boolean })\n default = false;\n\n /**\n * The current value of the switch component. Reflects the \"checked\" attribute.\n */\n @property({ type: Boolean, attribute: \"checked\", reflect: true })\n value = false;\n\n get observedRecord(): Record<string, any> {\n return omit(super.observedRecord, ringTypeAttribute);\n }\n\n protected render(): TemplateResult<1> {\n return html`\n <div\n part=\"root\"\n ${attr(this.observedRecord)}\n class=\"round\"\n >\n <input\n part=\"input\"\n type=\"checkbox\"\n ?disabled=\"${this.disabled}\"\n ?checked=\"${this.value}\"\n @change=\"${this._handleChange}\"\n />\n <span part=\"handle\"></span>\n </div>\n `;\n }\n\n reset(): void {\n this.value = this.default;\n this._input.checked = this.value;\n }\n\n protected _connectedInit(): void {\n if (this.default) {\n this.value = true;\n } else {\n if (this.value) {\n this.value = true;\n this.default = true;\n }\n }\n }\n\n protected _handleChange(): void {\n const { checked } = this._input;\n this.value = checked;\n this.dispatchCustomEvent(\"change\", this.value);\n }\n}\n\nexport default Switch;\nexport { Switch };\n"],"names":["protoName","cssScope","scopePrefix","Switch","SuperInput","v","omit","ringTypeAttribute","attr","checked","_decorate","property","godown","styles","cssGlobalVars","Switch$1"],"mappings":"2aASA,MAAMA,EAAY,SACZC,EAAWC,EAAYF,GAQ7B,IAAAG,EAAA,MA0DMA,UAAeC,CAAoB,oCAavC,QAAU,QAMV,MAAQ,GAlBR,IAAI,QAAQ,EAAY,CACtB,KAAK,MAAQC,EAGf,IAAI,SAAmB,CACrB,OAAO,KAAK,MAed,IAAI,gBAAsC,CACxC,OAAOC,EAAK,MAAM,eAAgBC,GAG1B,QAA4B,CACpC,MAAO,EAAI,oBAGLC,EAAK,KAAK,gBAAA,iEAMG,KAAK,SAAS,cACf,KAAK,MAAM,aACZ,KAAK,cAAc,wCAOtC,OAAc,CACZ,KAAK,MAAQ,KAAK,QAClB,KAAK,OAAO,QAAU,KAAK,MAGnB,gBAAuB,CAC3B,KAAK,QACP,KAAK,MAAQ,GAET,KAAK,QACP,KAAK,MAAQ,GACb,KAAK,QAAU,IAKX,eAAsB,CAC9B,GAAM,CAAE,WAAY,KAAK,OACzB,KAAK,MAAQC,EACb,KAAK,oBAAoB,SAAU,KAAK,SAnDzCC,EAAA,CAAAC,EAAS,CAAE,KAAM,WAAAR,EAAA,UAAA,UAAA,WAMjBQ,EAAS,CAAE,KAAM,QAAS,UAAW,UAAW,QAAS,uCA5E3DC,EAAOZ,GACPa,EAAO,CAAG,kEAOLZ,EAAS,aACTA,EAAS,mBAAoBA,EAAS,aACtCA,EAAS,sBACTA,EAAS,yBAA0BA,EAAS,kBAAoBA,EAAS,6BAC9DA,EAAS,qBACRA,EAAS,kCACGA,EAAS,6BACjBa,EAAc,QAAQ,yHAOtBA,EAAc,OAAO,oQAoBrBA,EAAc,WAAW,cAC9Bb,EAAS,2BACRA,EAAS,0DACsBA,EAAS,6GAgF1D,IAAAc,EAAeZ"}
@@ -1 +1 @@
1
- {"mappings":"AAAA,OAAO,YAAY,gBAAiB;AAIpC,eAAe;eAEA;WACH,sBAAsB;EAC9B,iBAAiB;CAClB;AACF","names":[],"sources":["../../../../src/web-components/switch/definition.ts"],"sourcesContent":["import Switch from \"./component.js\";\n\nSwitch.define();\n\nexport default Switch;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"godown-switch\": Switch;\n }\n}\n"],"version":3,"file":"definition.d.ts"}
1
+ {"mappings":"AAAA,OAAO,YAAY;AAInB,eAAe;eAEA;WACH,sBAAsB;EAC9B,iBAAiB","names":[],"sources":["../../../../src/web-components/switch/definition.ts"],"sourcesContent":["import Switch from \"./component.js\";\n\nSwitch.define();\n\nexport default Switch;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"godown-switch\": Switch;\n }\n}\n"],"version":3,"file":"definition.d.ts"}
@@ -1,2 +1,2 @@
1
- import Switch from"./component.js";import"@godown/element";import"lit";import"lit/decorators.js";import"../../internal/global-style.js";import"../../internal/reset-style.js";import"sharekit";import"../../internal/super-input.js";import"../../internal/ring.js";import"@oxc-project/runtime/helpers/decorate";Switch.define();export{Switch as default};
1
+ import e from"./component.js";e.define();export{e as default};
2
2
  //# sourceMappingURL=definition.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"definition.js","sources":["../../../src/web-components/switch/definition.ts"],"sourcesContent":["import Switch from \"./component.js\";\n\nSwitch.define();\n\nexport default Switch;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"godown-switch\": Switch;\n }\n}\n"],"names":[],"mappings":"kTAEA,OAAO,QAAQ"}
1
+ {"version":3,"file":"definition.js","sources":["../../../src/web-components/switch/definition.ts"],"sourcesContent":["import Switch from \"./component.js\";\n\nSwitch.define();\n\nexport default Switch;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"godown-switch\": Switch;\n }\n}\n"],"names":["Switch"],"mappings":"8BAEAA,EAAO"}
@@ -10,14 +10,20 @@ import { type RingType } from "../../internal/ring.js";
10
10
  declare class Tabs extends GlobalStyle {
11
11
  ringType: RingType;
12
12
  /**
13
- * If it is "select", the indicator moves from the selected content to the hover position.
13
+ * If "select", the indicator moves from the selected content to the hover position.
14
14
  *
15
- * If it is "previous", the indicator moves from the last moved position to the hover position.
15
+ * If "previous", the indicator moves from the last moved position to the hover position.
16
16
  *
17
- * If "none", the indicator will not move.
17
+ * If "none", the indicator does not move.
18
18
  */
19
19
  beginning: "selected" | "previous" | "none";
20
20
  /**
21
+ * If "remain", the indicator remain on the selected item.
22
+ *
23
+ * If "none", the indicator dose not display.
24
+ */
25
+ ending: "remain" | "none";
26
+ /**
21
27
  * The behavior of the indicator:
22
28
  *
23
29
  * If "background", its size will be consistent with that of a single tab.
@@ -38,6 +44,7 @@ declare class Tabs extends GlobalStyle {
38
44
  protected _indicators: HTMLCollectionOf<HTMLDivElement>;
39
45
  constructor();
40
46
  render(): TemplateResult<1>;
47
+ protected get _finalIndex(): number;
41
48
  connectedCallback(): void;
42
49
  protected _handleMouseLeave(): void;
43
50
  move(sourceIndex: number, targetIndex: number): void;
@@ -1 +1 @@
1
- {"mappings":"AACA,SAAwB,mBAAgC,gCAAiC;AACzF,cAAyB,sBAAsB,KAAM;AAErD,cAA8C,gBAAgB,wBAAyB;;;;;;;AAavF,cAyEM,aAAa,YAAY;CAC7B,AACA,UAAU;;;;;;;;CASV,AACA,WAAW,aAAa,aAAa;;;;;;;;CASrC,AACA,WAAW,eAAe;;;;CAK1B,AACA;;;;CAKA,AACA;CAEA,UAAU;CAEV,UACU,QAAQ,iBAAiB;CAEnC,UACU,aAAa,iBAAiB;CAExC;CAKA,UAAU,eAAe;CA0BzB;CAKA,UAAU;CAQV,KAAKA,qBAAqBC;CAsC1B,OAAOC;AASR;AAED,eAAe;AACf,SAAS","names":["sourceIndex: number","targetIndex: number","selected: number"],"sources":["../../../../src/web-components/tabs/component.ts"],"sourcesContent":["import { attr, godown, htmlSlot, StyleController, styles, tokenList } from \"@godown/element\";\nimport { cssGlobalVars, GlobalStyle, scopePrefix } from \"../../internal/global-style.js\";\nimport { css, html, type TemplateResult } from \"lit\";\nimport { property, queryAll } from \"lit/decorators.js\";\nimport { RingBuilder, ringTypeAttribute, type RingType } from \"../../internal/ring.js\";\n\nconst protoName = \"tabs\";\nconst cssScope = scopePrefix(protoName);\n\nconst hoverToken = \"hover\";\n\n/**\n * {@linkcode Tabs} used to render a set of tabs.\n *\n * @fires select - Fires when the tab index is changed.\n * @category display\n */\n@godown(protoName)\n@styles(css`\n :host {\n ${cssScope}--indicator-background: var(${cssGlobalVars.passive});\n ${cssScope}--selected-background: var(${cssGlobalVars.passive});\n transition: 0.2s ease-in-out;\n display: flex;\n cursor: default;\n }\n\n [part=\"root\"] {\n gap: 0.25em;\n padding: 0.25em;\n position: relative;\n z-index: 1;\n display: flex;\n flex-direction: inherit;\n overflow-x: clip;\n border-radius: inherit;\n transition: inherit;\n transition-property: width, transform, opacity;\n }\n\n [part~=\"item\"] {\n position: relative;\n width: 100%;\n display: block;\n text-align: center;\n position: relative;\n white-space: nowrap;\n transition: inherit;\n border-radius: inherit;\n transition-property: inherit;\n }\n\n [part=\"indicator\"],\n [part~=\"item\"]::after {\n width: 100%;\n height: 100%;\n inset: 0;\n position: absolute;\n transition: inherit;\n border-radius: inherit;\n transition-property: inherit;\n background: var(${cssScope}--indicator-background);\n }\n\n [part=\"indicator\"] {\n opacity: 0;\n z-index: -1;\n }\n\n [part~=\"item\"]::after {\n z-index: -2;\n }\n\n [indicator=\"underline\"] [part=\"indicator\"],\n [indicator=\"underline\"] [part~=\"item\"]::after {\n top: 100%;\n height: 0.15em;\n border-radius: 0.075em;\n margin-top: 0.15em;\n }\n\n [part~=\"selected\"]::after {\n content: \"\";\n background: var(${cssScope}--selected-background);\n }\n\n [part~=\"hover\"] [part=\"indicator\"] {\n opacity: 1;\n }\n`)\nclass Tabs extends GlobalStyle {\n @property({ attribute: ringTypeAttribute })\n ringType: RingType = \"border\";\n\n /**\n * If it is \"select\", the indicator moves from the selected content to the hover position.\n *\n * If it is \"previous\", the indicator moves from the last moved position to the hover position.\n *\n * If \"none\", the indicator will not move.\n */\n @property()\n beginning: \"selected\" | \"previous\" | \"none\" = \"selected\";\n\n /**\n * The behavior of the indicator:\n *\n * If \"background\", its size will be consistent with that of a single tab.\n *\n * If \"underline\", an underline will be displayed at the bottom of the tab.\n */\n @property()\n indicator: \"background\" | \"underline\" = \"background\";\n\n /**\n * Tab list or slot list.\n */\n @property({ type: Array })\n tabs: string[];\n\n /**\n * The index of the currently selected tab.\n */\n @property({ type: Number })\n index = 0;\n\n protected previousIndex: number;\n\n @queryAll(\"[part~=item]\")\n protected _items: HTMLCollectionOf<HTMLLIElement>;\n\n @queryAll(\"[part=indicator]\")\n protected _indicators: HTMLCollectionOf<HTMLDivElement>;\n\n constructor() {\n super();\n new StyleController(this, () => new RingBuilder({ type: this.ringType }).css);\n }\n\n render(): TemplateResult<1> {\n return html`\n <ul\n part=\"root\"\n ${attr(this.observedRecord)}\n @mouseleave=\"${this._handleMouseLeave}\"\n >\n ${this.tabs?.map(\n (tab, index) => html`\n <li\n part=\"${tokenList(\"item\", this.index === index && \"selected\")}\"\n @mouseenter=${() => {\n this.move(this.previousIndex, index);\n this.previousIndex = index;\n }}\n @click=${() => this.select(index)}\n >\n ${htmlSlot(tab, tab)}\n <div part=\"indicator\"></div>\n </li>\n `,\n )}\n </ul>\n `;\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n this.previousIndex = this.beginning === \"selected\" ? this.index : -1;\n }\n\n protected _handleMouseLeave(): void {\n const lastItem = this._items[this.previousIndex];\n if (lastItem) {\n lastItem.part.remove(hoverToken);\n }\n this.previousIndex = this.beginning === \"selected\" ? this.index : -1;\n }\n\n move(sourceIndex: number, targetIndex: number): void {\n if (sourceIndex === targetIndex) {\n return;\n }\n const { _items, _indicators } = this;\n const targetElement = _items[targetIndex];\n if (!targetElement) {\n return;\n }\n targetElement.part.add(hoverToken);\n const fromItem = _items[sourceIndex];\n if (!fromItem) {\n return;\n }\n fromItem.part.remove(hoverToken);\n if (this.beginning === \"none\") {\n return;\n }\n const targetIndicator = _indicators[targetIndex];\n const sourceIndicator = _indicators[sourceIndex];\n if (!targetIndicator || !sourceIndicator) {\n return;\n }\n const { x: sourceX, y: sourceY, width: sourceWidth } = sourceIndicator.getBoundingClientRect();\n const { x, y } = targetIndicator.getBoundingClientRect();\n const transformX = sourceX - x;\n const transformY = sourceY - y;\n\n const { style: targetStyle } = targetIndicator;\n const { style: sourceStyle } = sourceIndicator;\n\n targetStyle.transform = `translate3d(${transformX}px,${transformY}px,0)`;\n targetStyle.width = `${sourceWidth}px`;\n targetStyle.transition = sourceStyle.transition = \"none\";\n targetIndicator.getBoundingClientRect();\n targetStyle.width = targetStyle.transform = targetStyle.transition = sourceStyle.transition = \"\";\n }\n\n select(selected: number): void {\n const { index, previousIndex } = this;\n this.move(previousIndex, selected);\n if (selected !== index) {\n this.previousIndex = selected;\n this.index = selected;\n this.dispatchCustomEvent(\"select\", selected);\n }\n }\n}\n\nexport default Tabs;\nexport { Tabs };\n"],"version":3,"file":"component.d.ts"}
1
+ {"mappings":"AACA,SAAwB,mBAAgC;AACxD,cAAyB,sBAAsB;AAE/C,cAA8C,gBAAgB;;;;;;;AAa9D,cAyEM,aAAa,YAAY;CAC7B,AACA,UAAU;;;;;;;;CASV,AACA,WAAW,aAAa,aAAa;;;;;;CAOrC,AACA,QAAQ,WAAW;;;;;;;;CASnB,AACA,WAAW,eAAe;;;;CAK1B,AACA;;;;CAKA,AACA;CAEA,UAAU;CAEV,UACU,QAAQ,iBAAiB;CAEnC,UACU,aAAa,iBAAiB;CAExC;CAKA,UAAU,eAAe;CA2BzB,cAAc;CAId;CAKA,UAAU;CAQV,KAAK,qBAAqB;CAsC1B,OAAO;;AAWT,eAAe;AACf,SAAS","names":[],"sources":["../../../../src/web-components/tabs/component.ts"],"sourcesContent":["import { attr, godown, htmlSlot, StyleController, styles, tokenList } from \"@godown/element\";\nimport { cssGlobalVars, GlobalStyle, scopePrefix } from \"../../internal/global-style.js\";\nimport { css, html, type TemplateResult } from \"lit\";\nimport { property, queryAll } from \"lit/decorators.js\";\nimport { RingBuilder, ringTypeAttribute, type RingType } from \"../../internal/ring.js\";\n\nconst protoName = \"tabs\";\nconst cssScope = scopePrefix(protoName);\n\nconst hoverToken = \"hover\";\n\n/**\n * {@linkcode Tabs} used to render a set of tabs.\n *\n * @fires select - Fires when the tab index is changed.\n * @category display\n */\n@godown(protoName)\n@styles(css`\n :host {\n ${cssScope}--indicator-background: var(${cssGlobalVars.passive});\n ${cssScope}--selected-background: var(${cssGlobalVars.passive});\n transition: 0.2s ease-in-out;\n display: flex;\n cursor: default;\n }\n\n [part=\"root\"] {\n gap: 0.25em;\n padding: 0.25em;\n position: relative;\n z-index: 1;\n display: flex;\n flex-direction: inherit;\n overflow-x: clip;\n border-radius: inherit;\n transition: inherit;\n transition-property: width, transform, opacity;\n }\n\n [part~=\"item\"] {\n position: relative;\n width: 100%;\n display: block;\n text-align: center;\n position: relative;\n white-space: nowrap;\n transition: inherit;\n border-radius: inherit;\n transition-property: inherit;\n }\n\n [part=\"indicator\"],\n [part~=\"item\"]::after {\n width: 100%;\n height: 100%;\n inset: 0;\n position: absolute;\n transition: inherit;\n border-radius: inherit;\n transition-property: inherit;\n background: var(${cssScope}--indicator-background);\n }\n\n [part=\"indicator\"] {\n opacity: 0;\n z-index: -1;\n }\n\n [part~=\"item\"]::after {\n z-index: -2;\n }\n\n [indicator=\"underline\"] [part=\"indicator\"],\n [indicator=\"underline\"] [part~=\"item\"]::after {\n top: 100%;\n height: 0.15em;\n border-radius: 0.075em;\n margin-top: 0.15em;\n }\n\n [part~=\"selected\"]::after {\n content: \"\";\n background: var(${cssScope}--selected-background);\n }\n\n [part~=\"hover\"] [part=\"indicator\"] {\n opacity: 1;\n }\n`)\nclass Tabs extends GlobalStyle {\n @property({ attribute: ringTypeAttribute })\n ringType: RingType = \"border\";\n\n /**\n * If \"select\", the indicator moves from the selected content to the hover position.\n *\n * If \"previous\", the indicator moves from the last moved position to the hover position.\n *\n * If \"none\", the indicator does not move.\n */\n @property()\n beginning: \"selected\" | \"previous\" | \"none\" = \"selected\";\n\n /**\n * If \"remain\", the indicator remain on the selected item.\n *\n * If \"none\", the indicator dose not display.\n */\n @property()\n ending: \"remain\" | \"none\" = \"remain\";\n\n /**\n * The behavior of the indicator:\n *\n * If \"background\", its size will be consistent with that of a single tab.\n *\n * If \"underline\", an underline will be displayed at the bottom of the tab.\n */\n @property()\n indicator: \"background\" | \"underline\" = \"background\";\n\n /**\n * Tab list or slot list.\n */\n @property({ type: Array })\n tabs: string[];\n\n /**\n * The index of the currently selected tab.\n */\n @property({ type: Number })\n index = 0;\n\n protected previousIndex: number;\n\n @queryAll(\"[part~=item]\")\n protected _items: HTMLCollectionOf<HTMLLIElement>;\n\n @queryAll(\"[part=indicator]\")\n protected _indicators: HTMLCollectionOf<HTMLDivElement>;\n\n constructor() {\n super();\n new StyleController(this, () => new RingBuilder({ type: this.ringType }).css);\n }\n\n render(): TemplateResult<1> {\n const isRemain = this.ending === \"remain\";\n return html`\n <ul\n part=\"root\"\n ${attr(this.observedRecord)}\n @mouseleave=\"${this._handleMouseLeave}\"\n >\n ${this.tabs?.map(\n (tab, index) => html`\n <li\n part=\"${tokenList(\"item\", isRemain && this.index === index && \"selected\")}\"\n @mouseenter=${() => {\n this.move(this.previousIndex, index);\n this.previousIndex = index;\n }}\n @click=${() => this.select(index)}\n >\n ${htmlSlot(tab, tab)}\n <div part=\"indicator\"></div>\n </li>\n `,\n )}\n </ul>\n `;\n }\n\n protected get _finalIndex(): number {\n return this.ending === \"none\" && this.beginning === \"selected\" ? this.index : -1;\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n this.previousIndex = this._finalIndex;\n }\n\n protected _handleMouseLeave(): void {\n const lastItem = this._items[this.previousIndex];\n if (lastItem) {\n lastItem.part.remove(hoverToken);\n }\n this.previousIndex = this._finalIndex;\n }\n\n move(sourceIndex: number, targetIndex: number): void {\n if (sourceIndex === targetIndex) {\n return;\n }\n const { _items, _indicators } = this;\n const targetElement = _items[targetIndex];\n if (!targetElement) {\n return;\n }\n targetElement.part.add(hoverToken);\n const fromItem = _items[sourceIndex];\n if (!fromItem) {\n return;\n }\n fromItem.part.remove(hoverToken);\n if (this.beginning === \"none\") {\n return;\n }\n const targetIndicator = _indicators[targetIndex];\n const sourceIndicator = _indicators[sourceIndex];\n if (!targetIndicator || !sourceIndicator) {\n return;\n }\n const { x: sourceX, y: sourceY, width: sourceWidth } = sourceIndicator.getBoundingClientRect();\n const { x, y } = targetIndicator.getBoundingClientRect();\n const transformX = sourceX - x;\n const transformY = sourceY - y;\n\n const { style: targetStyle } = targetIndicator;\n const { style: sourceStyle } = sourceIndicator;\n\n targetStyle.transform = `translate3d(${transformX}px,${transformY}px,0)`;\n targetStyle.width = `${sourceWidth}px`;\n targetStyle.transition = sourceStyle.transition = \"none\";\n targetIndicator.getBoundingClientRect();\n targetStyle.width = targetStyle.transform = targetStyle.transition = sourceStyle.transition = \"\";\n }\n\n select(selected: number): void {\n const { index, previousIndex } = this;\n this.move(previousIndex, selected);\n if (selected !== index) {\n this.previousIndex = selected;\n this.index = selected;\n this.dispatchCustomEvent(\"select\", selected);\n }\n }\n}\n\nexport default Tabs;\nexport { Tabs };\n"],"version":3,"file":"component.d.ts"}
@@ -1,2 +1,2 @@
1
- import{godown,styles,StyleController,attr,tokenList,htmlSlot}from"@godown/element";import{scopePrefix,cssGlobalVars,GlobalStyle}from"../../internal/global-style.js";import{css,html}from"lit";import{property,queryAll}from"lit/decorators.js";import{ringTypeAttribute,RingBuilder}from"../../internal/ring.js";import _decorate from"@oxc-project/runtime/helpers/decorate";import"../../internal/reset-style.js";import"sharekit";const protoName=`tabs`,cssScope=scopePrefix(protoName),hoverToken=`hover`;let Tabs=class e extends GlobalStyle{constructor(){super(),this.ringType=`border`,this.beginning=`selected`,this.indicator=`background`,this.index=0,new StyleController(this,()=>new RingBuilder({type:this.ringType}).css)}render(){return html`<ul part="root" ${attr(this.observedRecord)} @mouseleave="${this._handleMouseLeave}"> ${this.tabs?.map((e,a)=>html`<li part="${tokenList(`item`,this.index===a&&`selected`)}" @mouseenter=${()=>{this.move(this.previousIndex,a),this.previousIndex=a}} @click=${()=>this.select(a)}> ${htmlSlot(e,e)} <div part="indicator"></div> </li>`)} </ul>`}connectedCallback(){super.connectedCallback(),this.previousIndex=this.beginning===`selected`?this.index:-1}_handleMouseLeave(){let e=this._items[this.previousIndex];e&&e.part.remove(hoverToken),this.previousIndex=this.beginning===`selected`?this.index:-1}move(e,a){if(e===a)return;let{_items:o,_indicators:s}=this,c=o[a];if(!c)return;c.part.add(hoverToken);let l=o[e];if(!l||(l.part.remove(hoverToken),this.beginning===`none`))return;let u=s[a],d=s[e];if(!u||!d)return;let{x:f,y:p,width:m}=d.getBoundingClientRect(),{x:h,y:g}=u.getBoundingClientRect(),_=f-h,v=p-g,{style:y}=u,{style:b}=d;y.transform=`translate3d(${_}px,${v}px,0)`,y.width=`${m}px`,y.transition=b.transition=`none`,u.getBoundingClientRect(),y.width=y.transform=y.transition=b.transition=``}select(e){let{index:a,previousIndex:o}=this;this.move(o,e),e!==a&&(this.previousIndex=e,this.index=e,this.dispatchCustomEvent(`select`,e))}};_decorate([property({attribute:ringTypeAttribute})],Tabs.prototype,`ringType`,void 0),_decorate([property()],Tabs.prototype,`beginning`,void 0),_decorate([property()],Tabs.prototype,`indicator`,void 0),_decorate([property({type:Array})],Tabs.prototype,`tabs`,void 0),_decorate([property({type:Number})],Tabs.prototype,`index`,void 0),_decorate([queryAll(`[part~=item]`)],Tabs.prototype,`_items`,void 0),_decorate([queryAll(`[part=indicator]`)],Tabs.prototype,`_indicators`,void 0),Tabs=_decorate([godown(protoName),styles(css`:host{${cssScope}--indicator-background:var(${cssGlobalVars.passive});${cssScope}--selected-background:var(${cssGlobalVars.passive});transition:.2s ease-in-out;display:flex;cursor:default}[part=root]{gap:.25em;padding:.25em;position:relative;z-index:1;display:flex;flex-direction:inherit;overflow-x:clip;border-radius:inherit;transition:inherit;transition-property:width,transform,opacity}[part~=item]{position:relative;width:100%;display:block;text-align:center;position:relative;white-space:nowrap;transition:inherit;border-radius:inherit;transition-property:inherit}[part=indicator],[part~=item]::after{width:100%;height:100%;inset:0;position:absolute;transition:inherit;border-radius:inherit;transition-property:inherit;background:var(${cssScope}--indicator-background)}[part=indicator]{opacity:0;z-index:-1}[part~=item]::after{z-index:-2}[indicator=underline] [part=indicator],[indicator=underline] [part~=item]::after{top:100%;height:.15em;border-radius:.075em;margin-top:.15em}[part~=selected]::after{content:"";background:var(${cssScope}--selected-background)}[part~=hover] [part=indicator]{opacity:1}`)],Tabs);var Tabs$1=Tabs;export{Tabs,Tabs$1 as default};
1
+ import{godown as e,styles as t,StyleController as n,attr as r,tokenList as i,htmlSlot as a}from"@godown/element";import{scopePrefix as o,cssGlobalVars as s,GlobalStyle as c}from"../../internal/global-style.js";import{css as l,html as u}from"lit";import{property as d,queryAll as f}from"lit/decorators.js";import{ringTypeAttribute as p,RingBuilder as m}from"../../internal/ring.js";import h from"@oxc-project/runtime/helpers/decorate";const g=`tabs`,_=o(g),v=`hover`;let y=class e extends c{constructor(){super(),this.ringType=`border`,this.beginning=`selected`,this.ending=`remain`,this.indicator=`background`,this.index=0,new n(this,()=>new m({type:this.ringType}).css)}render(){let e=this.ending===`remain`;return u`<ul part="root" ${r(this.observedRecord)} @mouseleave="${this._handleMouseLeave}"> ${this.tabs?.map((t,n)=>u`<li part="${i(`item`,e&&this.index===n&&`selected`)}" @mouseenter=${()=>{this.move(this.previousIndex,n),this.previousIndex=n}} @click=${()=>this.select(n)}> ${a(t,t)} <div part="indicator"></div> </li>`)} </ul>`}get _finalIndex(){return this.ending===`none`&&this.beginning===`selected`?this.index:-1}connectedCallback(){super.connectedCallback(),this.previousIndex=this._finalIndex}_handleMouseLeave(){let e=this._items[this.previousIndex];e&&e.part.remove(v),this.previousIndex=this._finalIndex}move(e,t){if(e===t)return;let{_items:n,_indicators:r}=this,i=n[t];if(!i)return;i.part.add(v);let a=n[e];if(!a||(a.part.remove(v),this.beginning===`none`))return;let o=r[t],s=r[e];if(!o||!s)return;let{x:c,y:l,width:u}=s.getBoundingClientRect(),{x:d,y:f}=o.getBoundingClientRect(),p=c-d,m=l-f,{style:h}=o,{style:g}=s;h.transform=`translate3d(${p}px,${m}px,0)`,h.width=`${u}px`,h.transition=g.transition=`none`,o.getBoundingClientRect(),h.width=h.transform=h.transition=g.transition=``}select(e){let{index:t,previousIndex:n}=this;this.move(n,e),e!==t&&(this.previousIndex=e,this.index=e,this.dispatchCustomEvent(`select`,e))}};h([d({attribute:p})],y.prototype,`ringType`,void 0),h([d()],y.prototype,`beginning`,void 0),h([d()],y.prototype,`ending`,void 0),h([d()],y.prototype,`indicator`,void 0),h([d({type:Array})],y.prototype,`tabs`,void 0),h([d({type:Number})],y.prototype,`index`,void 0),h([f(`[part~=item]`)],y.prototype,`_items`,void 0),h([f(`[part=indicator]`)],y.prototype,`_indicators`,void 0),y=h([e(g),t(l`:host{${_}--indicator-background:var(${s.passive});${_}--selected-background:var(${s.passive});transition:.2s ease-in-out;display:flex;cursor:default}[part=root]{gap:.25em;padding:.25em;position:relative;z-index:1;display:flex;flex-direction:inherit;overflow-x:clip;border-radius:inherit;transition:inherit;transition-property:width,transform,opacity}[part~=item]{position:relative;width:100%;display:block;text-align:center;position:relative;white-space:nowrap;transition:inherit;border-radius:inherit;transition-property:inherit}[part=indicator],[part~=item]::after{width:100%;height:100%;inset:0;position:absolute;transition:inherit;border-radius:inherit;transition-property:inherit;background:var(${_}--indicator-background)}[part=indicator]{opacity:0;z-index:-1}[part~=item]::after{z-index:-2}[indicator=underline] [part=indicator],[indicator=underline] [part~=item]::after{top:100%;height:.15em;border-radius:.075em;margin-top:.15em}[part~=selected]::after{content:"";background:var(${_}--selected-background)}[part~=hover] [part=indicator]{opacity:1}`)],y);var b=y;export{y as Tabs,b as default};
2
2
  //# sourceMappingURL=component.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"component.js","sources":["../../../src/web-components/tabs/component.ts"],"sourcesContent":["import { attr, godown, htmlSlot, StyleController, styles, tokenList } from \"@godown/element\";\nimport { cssGlobalVars, GlobalStyle, scopePrefix } from \"../../internal/global-style.js\";\nimport { css, html, type TemplateResult } from \"lit\";\nimport { property, queryAll } from \"lit/decorators.js\";\nimport { RingBuilder, ringTypeAttribute, type RingType } from \"../../internal/ring.js\";\n\nconst protoName = \"tabs\";\nconst cssScope = scopePrefix(protoName);\n\nconst hoverToken = \"hover\";\n\n/**\n * {@linkcode Tabs} used to render a set of tabs.\n *\n * @fires select - Fires when the tab index is changed.\n * @category display\n */\n@godown(protoName)\n@styles(css`\n :host {\n ${cssScope}--indicator-background: var(${cssGlobalVars.passive});\n ${cssScope}--selected-background: var(${cssGlobalVars.passive});\n transition: 0.2s ease-in-out;\n display: flex;\n cursor: default;\n }\n\n [part=\"root\"] {\n gap: 0.25em;\n padding: 0.25em;\n position: relative;\n z-index: 1;\n display: flex;\n flex-direction: inherit;\n overflow-x: clip;\n border-radius: inherit;\n transition: inherit;\n transition-property: width, transform, opacity;\n }\n\n [part~=\"item\"] {\n position: relative;\n width: 100%;\n display: block;\n text-align: center;\n position: relative;\n white-space: nowrap;\n transition: inherit;\n border-radius: inherit;\n transition-property: inherit;\n }\n\n [part=\"indicator\"],\n [part~=\"item\"]::after {\n width: 100%;\n height: 100%;\n inset: 0;\n position: absolute;\n transition: inherit;\n border-radius: inherit;\n transition-property: inherit;\n background: var(${cssScope}--indicator-background);\n }\n\n [part=\"indicator\"] {\n opacity: 0;\n z-index: -1;\n }\n\n [part~=\"item\"]::after {\n z-index: -2;\n }\n\n [indicator=\"underline\"] [part=\"indicator\"],\n [indicator=\"underline\"] [part~=\"item\"]::after {\n top: 100%;\n height: 0.15em;\n border-radius: 0.075em;\n margin-top: 0.15em;\n }\n\n [part~=\"selected\"]::after {\n content: \"\";\n background: var(${cssScope}--selected-background);\n }\n\n [part~=\"hover\"] [part=\"indicator\"] {\n opacity: 1;\n }\n`)\nclass Tabs extends GlobalStyle {\n @property({ attribute: ringTypeAttribute })\n ringType: RingType = \"border\";\n\n /**\n * If it is \"select\", the indicator moves from the selected content to the hover position.\n *\n * If it is \"previous\", the indicator moves from the last moved position to the hover position.\n *\n * If \"none\", the indicator will not move.\n */\n @property()\n beginning: \"selected\" | \"previous\" | \"none\" = \"selected\";\n\n /**\n * The behavior of the indicator:\n *\n * If \"background\", its size will be consistent with that of a single tab.\n *\n * If \"underline\", an underline will be displayed at the bottom of the tab.\n */\n @property()\n indicator: \"background\" | \"underline\" = \"background\";\n\n /**\n * Tab list or slot list.\n */\n @property({ type: Array })\n tabs: string[];\n\n /**\n * The index of the currently selected tab.\n */\n @property({ type: Number })\n index = 0;\n\n protected previousIndex: number;\n\n @queryAll(\"[part~=item]\")\n protected _items: HTMLCollectionOf<HTMLLIElement>;\n\n @queryAll(\"[part=indicator]\")\n protected _indicators: HTMLCollectionOf<HTMLDivElement>;\n\n constructor() {\n super();\n new StyleController(this, () => new RingBuilder({ type: this.ringType }).css);\n }\n\n render(): TemplateResult<1> {\n return html`\n <ul\n part=\"root\"\n ${attr(this.observedRecord)}\n @mouseleave=\"${this._handleMouseLeave}\"\n >\n ${this.tabs?.map(\n (tab, index) => html`\n <li\n part=\"${tokenList(\"item\", this.index === index && \"selected\")}\"\n @mouseenter=${() => {\n this.move(this.previousIndex, index);\n this.previousIndex = index;\n }}\n @click=${() => this.select(index)}\n >\n ${htmlSlot(tab, tab)}\n <div part=\"indicator\"></div>\n </li>\n `,\n )}\n </ul>\n `;\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n this.previousIndex = this.beginning === \"selected\" ? this.index : -1;\n }\n\n protected _handleMouseLeave(): void {\n const lastItem = this._items[this.previousIndex];\n if (lastItem) {\n lastItem.part.remove(hoverToken);\n }\n this.previousIndex = this.beginning === \"selected\" ? this.index : -1;\n }\n\n move(sourceIndex: number, targetIndex: number): void {\n if (sourceIndex === targetIndex) {\n return;\n }\n const { _items, _indicators } = this;\n const targetElement = _items[targetIndex];\n if (!targetElement) {\n return;\n }\n targetElement.part.add(hoverToken);\n const fromItem = _items[sourceIndex];\n if (!fromItem) {\n return;\n }\n fromItem.part.remove(hoverToken);\n if (this.beginning === \"none\") {\n return;\n }\n const targetIndicator = _indicators[targetIndex];\n const sourceIndicator = _indicators[sourceIndex];\n if (!targetIndicator || !sourceIndicator) {\n return;\n }\n const { x: sourceX, y: sourceY, width: sourceWidth } = sourceIndicator.getBoundingClientRect();\n const { x, y } = targetIndicator.getBoundingClientRect();\n const transformX = sourceX - x;\n const transformY = sourceY - y;\n\n const { style: targetStyle } = targetIndicator;\n const { style: sourceStyle } = sourceIndicator;\n\n targetStyle.transform = `translate3d(${transformX}px,${transformY}px,0)`;\n targetStyle.width = `${sourceWidth}px`;\n targetStyle.transition = sourceStyle.transition = \"none\";\n targetIndicator.getBoundingClientRect();\n targetStyle.width = targetStyle.transform = targetStyle.transition = sourceStyle.transition = \"\";\n }\n\n select(selected: number): void {\n const { index, previousIndex } = this;\n this.move(previousIndex, selected);\n if (selected !== index) {\n this.previousIndex = selected;\n this.index = selected;\n this.dispatchCustomEvent(\"select\", selected);\n }\n }\n}\n\nexport default Tabs;\nexport { Tabs };\n"],"names":["Tabs","tab","index","lastItem","sourceIndex: number","targetIndex: number","sourceIndex","targetIndex","targetElement","_items","fromItem","targetIndicator","_indicators","sourceIndicator","sourceX","sourceY","sourceWidth","transformX","x","transformY","y","targetStyle","sourceStyle","selected: number","previousIndex","selected"],"mappings":"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"}
1
+ {"version":3,"file":"component.js","sources":["../../../src/web-components/tabs/component.ts"],"sourcesContent":["import { attr, godown, htmlSlot, StyleController, styles, tokenList } from \"@godown/element\";\nimport { cssGlobalVars, GlobalStyle, scopePrefix } from \"../../internal/global-style.js\";\nimport { css, html, type TemplateResult } from \"lit\";\nimport { property, queryAll } from \"lit/decorators.js\";\nimport { RingBuilder, ringTypeAttribute, type RingType } from \"../../internal/ring.js\";\n\nconst protoName = \"tabs\";\nconst cssScope = scopePrefix(protoName);\n\nconst hoverToken = \"hover\";\n\n/**\n * {@linkcode Tabs} used to render a set of tabs.\n *\n * @fires select - Fires when the tab index is changed.\n * @category display\n */\n@godown(protoName)\n@styles(css`\n :host {\n ${cssScope}--indicator-background: var(${cssGlobalVars.passive});\n ${cssScope}--selected-background: var(${cssGlobalVars.passive});\n transition: 0.2s ease-in-out;\n display: flex;\n cursor: default;\n }\n\n [part=\"root\"] {\n gap: 0.25em;\n padding: 0.25em;\n position: relative;\n z-index: 1;\n display: flex;\n flex-direction: inherit;\n overflow-x: clip;\n border-radius: inherit;\n transition: inherit;\n transition-property: width, transform, opacity;\n }\n\n [part~=\"item\"] {\n position: relative;\n width: 100%;\n display: block;\n text-align: center;\n position: relative;\n white-space: nowrap;\n transition: inherit;\n border-radius: inherit;\n transition-property: inherit;\n }\n\n [part=\"indicator\"],\n [part~=\"item\"]::after {\n width: 100%;\n height: 100%;\n inset: 0;\n position: absolute;\n transition: inherit;\n border-radius: inherit;\n transition-property: inherit;\n background: var(${cssScope}--indicator-background);\n }\n\n [part=\"indicator\"] {\n opacity: 0;\n z-index: -1;\n }\n\n [part~=\"item\"]::after {\n z-index: -2;\n }\n\n [indicator=\"underline\"] [part=\"indicator\"],\n [indicator=\"underline\"] [part~=\"item\"]::after {\n top: 100%;\n height: 0.15em;\n border-radius: 0.075em;\n margin-top: 0.15em;\n }\n\n [part~=\"selected\"]::after {\n content: \"\";\n background: var(${cssScope}--selected-background);\n }\n\n [part~=\"hover\"] [part=\"indicator\"] {\n opacity: 1;\n }\n`)\nclass Tabs extends GlobalStyle {\n @property({ attribute: ringTypeAttribute })\n ringType: RingType = \"border\";\n\n /**\n * If \"select\", the indicator moves from the selected content to the hover position.\n *\n * If \"previous\", the indicator moves from the last moved position to the hover position.\n *\n * If \"none\", the indicator does not move.\n */\n @property()\n beginning: \"selected\" | \"previous\" | \"none\" = \"selected\";\n\n /**\n * If \"remain\", the indicator remain on the selected item.\n *\n * If \"none\", the indicator dose not display.\n */\n @property()\n ending: \"remain\" | \"none\" = \"remain\";\n\n /**\n * The behavior of the indicator:\n *\n * If \"background\", its size will be consistent with that of a single tab.\n *\n * If \"underline\", an underline will be displayed at the bottom of the tab.\n */\n @property()\n indicator: \"background\" | \"underline\" = \"background\";\n\n /**\n * Tab list or slot list.\n */\n @property({ type: Array })\n tabs: string[];\n\n /**\n * The index of the currently selected tab.\n */\n @property({ type: Number })\n index = 0;\n\n protected previousIndex: number;\n\n @queryAll(\"[part~=item]\")\n protected _items: HTMLCollectionOf<HTMLLIElement>;\n\n @queryAll(\"[part=indicator]\")\n protected _indicators: HTMLCollectionOf<HTMLDivElement>;\n\n constructor() {\n super();\n new StyleController(this, () => new RingBuilder({ type: this.ringType }).css);\n }\n\n render(): TemplateResult<1> {\n const isRemain = this.ending === \"remain\";\n return html`\n <ul\n part=\"root\"\n ${attr(this.observedRecord)}\n @mouseleave=\"${this._handleMouseLeave}\"\n >\n ${this.tabs?.map(\n (tab, index) => html`\n <li\n part=\"${tokenList(\"item\", isRemain && this.index === index && \"selected\")}\"\n @mouseenter=${() => {\n this.move(this.previousIndex, index);\n this.previousIndex = index;\n }}\n @click=${() => this.select(index)}\n >\n ${htmlSlot(tab, tab)}\n <div part=\"indicator\"></div>\n </li>\n `,\n )}\n </ul>\n `;\n }\n\n protected get _finalIndex(): number {\n return this.ending === \"none\" && this.beginning === \"selected\" ? this.index : -1;\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n this.previousIndex = this._finalIndex;\n }\n\n protected _handleMouseLeave(): void {\n const lastItem = this._items[this.previousIndex];\n if (lastItem) {\n lastItem.part.remove(hoverToken);\n }\n this.previousIndex = this._finalIndex;\n }\n\n move(sourceIndex: number, targetIndex: number): void {\n if (sourceIndex === targetIndex) {\n return;\n }\n const { _items, _indicators } = this;\n const targetElement = _items[targetIndex];\n if (!targetElement) {\n return;\n }\n targetElement.part.add(hoverToken);\n const fromItem = _items[sourceIndex];\n if (!fromItem) {\n return;\n }\n fromItem.part.remove(hoverToken);\n if (this.beginning === \"none\") {\n return;\n }\n const targetIndicator = _indicators[targetIndex];\n const sourceIndicator = _indicators[sourceIndex];\n if (!targetIndicator || !sourceIndicator) {\n return;\n }\n const { x: sourceX, y: sourceY, width: sourceWidth } = sourceIndicator.getBoundingClientRect();\n const { x, y } = targetIndicator.getBoundingClientRect();\n const transformX = sourceX - x;\n const transformY = sourceY - y;\n\n const { style: targetStyle } = targetIndicator;\n const { style: sourceStyle } = sourceIndicator;\n\n targetStyle.transform = `translate3d(${transformX}px,${transformY}px,0)`;\n targetStyle.width = `${sourceWidth}px`;\n targetStyle.transition = sourceStyle.transition = \"none\";\n targetIndicator.getBoundingClientRect();\n targetStyle.width = targetStyle.transform = targetStyle.transition = sourceStyle.transition = \"\";\n }\n\n select(selected: number): void {\n const { index, previousIndex } = this;\n this.move(previousIndex, selected);\n if (selected !== index) {\n this.previousIndex = selected;\n this.index = selected;\n this.dispatchCustomEvent(\"select\", selected);\n }\n }\n}\n\nexport default Tabs;\nexport { Tabs };\n"],"names":["protoName","cssScope","scopePrefix","hoverToken","Tabs","GlobalStyle","StyleController","RingBuilder","isRemain","attr","tokenList","index","htmlSlot","tab","lastItem","sourceIndex","targetIndex","targetElement","_items","fromItem","targetIndicator","_indicators","sourceIndicator","sourceX","sourceY","sourceWidth","transformX","x","transformY","y","targetStyle","sourceStyle","previousIndex","selected","_decorate","property","ringTypeAttribute","queryAll","godown","styles","cssGlobalVars","Tabs$1"],"mappings":"kbAMA,MAAMA,EAAY,OACZC,EAAWC,EAAYF,GAEvBG,EAAa,QAQnB,IAAAC,EAAA,MAyEMA,UAAaC,CAAY,CAoD7B,aAAc,CACZ,aAnDF,SAAqB,cAUrB,UAA8C,gBAQ9C,OAA4B,cAU5B,UAAwC,kBAYxC,MAAQ,EAYN,IAAIC,EAAgB,SAAY,IAAIC,EAAY,CAAE,KAAM,KAAK,WAAY,KAG3E,QAA4B,CAC1B,IAAMC,EAAW,KAAK,SAAW,SACjC,MAAO,EAAI,mBAGLC,EAAK,KAAK,gBAAA,gBACG,KAAK,kBAAkB,KAEpC,KAAK,MAAM,KACV,EAAK,IAAU,CAAI,aAERC,EAAU,OAAQF,GAAY,KAAK,QAAUG,GAAS,YAAY,oBACtD,CAClB,KAAK,KAAK,KAAK,cAAeA,GAC9B,KAAK,cAAgBA,GACrB,cACa,KAAK,OAAOA,GAAA,IAEzBC,EAASC,EAAKA,GAAA,sCAIpB,QAKR,IAAc,aAAsB,CAClC,OAAO,KAAK,SAAW,QAAU,KAAK,YAAc,WAAa,KAAK,MAAQ,GAGhF,mBAA0B,CACxB,MAAM,oBACN,KAAK,cAAgB,KAAK,YAGlB,mBAA0B,CAClC,IAAMC,EAAW,KAAK,OAAO,KAAK,eAC9BA,GACFA,EAAS,KAAK,OAAOX,GAEvB,KAAK,cAAgB,KAAK,YAG5B,KAAK,EAAqB,EAA2B,CACnD,GAAIY,IAAgBC,EAClB,OAEF,GAAM,CAAE,SAAQ,eAAgB,KAC1BC,EAAgBC,EAAOF,GAC7B,GAAI,CAACC,EACH,OAEFA,EAAc,KAAK,IAAId,GACvB,IAAMgB,EAAWD,EAAOH,GAKxB,GAJI,CAACI,IAGLA,EAAS,KAAK,OAAOhB,GACjB,KAAK,YAAc,QACrB,OAEF,IAAMiB,EAAkBC,EAAYL,GAC9BM,EAAkBD,EAAYN,GACpC,GAAI,CAACK,GAAmB,CAACE,EACvB,OAEF,GAAM,CAAE,EAAGC,EAAS,EAAGC,EAAS,MAAOC,GAAgBH,EAAgB,wBACjE,CAAE,IAAG,KAAMF,EAAgB,wBAC3BM,EAAaH,EAAUI,EACvBC,EAAaJ,EAAUK,EAEvB,CAAE,MAAOC,GAAgBV,EACzB,CAAE,MAAOW,GAAgBT,EAE/B,EAAY,UAAY,eAAeI,EAAW,KAAKE,EAAW,OAClE,EAAY,MAAQ,GAAGH,EAAY,IACnC,EAAY,WAAa,EAAY,WAAa,OAClDL,EAAgB,wBAChB,EAAY,MAAQ,EAAY,UAAY,EAAY,WAAa,EAAY,WAAa,GAGhG,OAAO,EAAwB,CAC7B,GAAM,CAAE,QAAO,iBAAkB,KACjC,KAAK,KAAKY,EAAeC,GACrBA,IAAatB,IACf,KAAK,cAAgBsB,EACrB,KAAK,MAAQA,EACb,KAAK,oBAAoB,SAAUA,MAhJtCC,EAAA,CAAAC,EAAS,CAAE,UAAWC,KAAAhC,EAAA,UAAA,WAAA,QAUtB8B,EAAA,CAAAC,KAAA/B,EAAA,UAAA,YAAA,QAQA8B,EAAA,CAAAC,KAAA/B,EAAA,UAAA,SAAA,QAUA8B,EAAA,CAAAC,KAAA/B,EAAA,UAAA,YAAA,QAMA8B,EAAA,CAAAC,EAAS,CAAE,KAAM,SAAA/B,EAAA,UAAA,OAAA,QAMjB8B,EAAA,CAAAC,EAAS,CAAE,KAAM,UAAA/B,EAAA,UAAA,QAAA,WAKjBiC,EAAS,iBAAAjC,EAAA,UAAA,SAAA,WAGTiC,EAAS,qBAAAjC,EAAA,UAAA,cAAA,aA1HXkC,EAAOtC,GACPuC,EAAO,CAAG,SAELtC,EAAS,6BAA8BuC,EAAc,QAAQ,IAC7DvC,EAAS,4BAA6BuC,EAAc,QAAQ,kmBAwC5CvC,EAAS,8RAsBTA,EAAS,uEA6J/B,IAAAwC,EAAerC"}
@@ -1 +1 @@
1
- {"mappings":"AAAA,OAAO,UAAU,gBAAiB;AAIlC,eAAe;eAEA;WACH,sBAAsB;EAC9B,eAAe;CAChB;AACF","names":[],"sources":["../../../../src/web-components/tabs/definition.ts"],"sourcesContent":["import Tabs from \"./component.js\";\n\nTabs.define();\n\nexport default Tabs;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"godown-tabs\": Tabs;\n }\n}\n"],"version":3,"file":"definition.d.ts"}
1
+ {"mappings":"AAAA,OAAO,UAAU;AAIjB,eAAe;eAEA;WACH,sBAAsB;EAC9B,eAAe","names":[],"sources":["../../../../src/web-components/tabs/definition.ts"],"sourcesContent":["import Tabs from \"./component.js\";\n\nTabs.define();\n\nexport default Tabs;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"godown-tabs\": Tabs;\n }\n}\n"],"version":3,"file":"definition.d.ts"}
@@ -1,2 +1,2 @@
1
- import Tabs from"./component.js";import"@godown/element";import"../../internal/global-style.js";import"lit";import"../../internal/reset-style.js";import"sharekit";import"lit/decorators.js";import"../../internal/ring.js";import"@oxc-project/runtime/helpers/decorate";Tabs.define();export{Tabs as default};
1
+ import e from"./component.js";e.define();export{e as default};
2
2
  //# sourceMappingURL=definition.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"definition.js","sources":["../../../src/web-components/tabs/definition.ts"],"sourcesContent":["import Tabs from \"./component.js\";\n\nTabs.define();\n\nexport default Tabs;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"godown-tabs\": Tabs;\n }\n}\n"],"names":[],"mappings":"0QAEA,KAAK,QAAQ"}
1
+ {"version":3,"file":"definition.js","sources":["../../../src/web-components/tabs/definition.ts"],"sourcesContent":["import Tabs from \"./component.js\";\n\nTabs.define();\n\nexport default Tabs;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"godown-tabs\": Tabs;\n }\n}\n"],"names":["Tabs"],"mappings":"8BAEAA,EAAK"}