@ecopages/radiant-ui 0.1.0-rc.8 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (196) hide show
  1. package/README.md +9 -1
  2. package/dist/components/ui/autocomplete/autocomplete.css +1 -2
  3. package/dist/components/ui/avatar/avatar.css +10 -8
  4. package/dist/components/ui/avatar/avatar.d.ts +3 -1
  5. package/dist/components/ui/calendar/calendar.css +10 -5
  6. package/dist/components/ui/calendar/calendar.script.d.ts +1 -0
  7. package/dist/components/ui/calendar/index.js +1 -1
  8. package/dist/components/ui/calendar/index.js.map +3 -3
  9. package/dist/components/ui/carousel/carousel-autoplay.d.ts +22 -0
  10. package/dist/components/ui/carousel/carousel-swipe.d.ts +17 -0
  11. package/dist/components/ui/carousel/carousel-window.d.ts +63 -0
  12. package/dist/components/ui/carousel/carousel.css +71 -18
  13. package/dist/components/ui/carousel/carousel.d.ts +1 -1
  14. package/dist/components/ui/carousel/carousel.script.d.ts +49 -21
  15. package/dist/components/ui/carousel/index.js +1 -1
  16. package/dist/components/ui/carousel/index.js.map +4 -4
  17. package/dist/components/ui/checkbox/checkbox.script.d.ts +0 -3
  18. package/dist/components/ui/checkbox/index.js +1 -1
  19. package/dist/components/ui/checkbox/index.js.map +4 -4
  20. package/dist/components/ui/checkbox-group/checkbox-group.d.ts +0 -1
  21. package/dist/components/ui/checkbox-group/checkbox-group.script.d.ts +8 -7
  22. package/dist/components/ui/checkbox-group/index.js +1 -1
  23. package/dist/components/ui/checkbox-group/index.js.map +4 -4
  24. package/dist/components/ui/combobox/combobox.css +2 -2
  25. package/dist/components/ui/combobox/combobox.d.ts +1 -2
  26. package/dist/components/ui/combobox/combobox.script.d.ts +13 -6
  27. package/dist/components/ui/combobox/index.js +1 -1
  28. package/dist/components/ui/combobox/index.js.map +4 -4
  29. package/dist/components/ui/cycle-toggle/index.js +1 -1
  30. package/dist/components/ui/cycle-toggle/index.js.map +3 -3
  31. package/dist/components/ui/date-field/date-field.css +13 -17
  32. package/dist/components/ui/date-field/date-field.d.ts +7 -5
  33. package/dist/components/ui/date-field/date-field.script.d.ts +16 -48
  34. package/dist/components/ui/date-field/index.js +1 -1
  35. package/dist/components/ui/date-field/index.js.map +4 -4
  36. package/dist/components/ui/date-input/date-input-segment-dom.d.ts +24 -0
  37. package/dist/components/ui/date-input/date-input.css +50 -0
  38. package/dist/components/ui/date-input/date-input.d.ts +8 -0
  39. package/dist/components/ui/date-input/date-input.script.d.ts +137 -0
  40. package/dist/components/ui/date-input/index.d.ts +2 -0
  41. package/dist/components/ui/date-input/index.js +2 -0
  42. package/dist/components/ui/date-input/index.js.map +7 -0
  43. package/dist/components/ui/date-range-picker/date-range-picker.css +18 -19
  44. package/dist/components/ui/date-range-picker/date-range-picker.d.ts +8 -6
  45. package/dist/components/ui/date-range-picker/date-range-picker.script.d.ts +24 -47
  46. package/dist/components/ui/date-range-picker/index.js +1 -1
  47. package/dist/components/ui/date-range-picker/index.js.map +4 -4
  48. package/dist/components/ui/dialog/dialog.css +18 -14
  49. package/dist/components/ui/dialog/dialog.script.d.ts +10 -3
  50. package/dist/components/ui/dialog/index.js +1 -1
  51. package/dist/components/ui/dialog/index.js.map +4 -4
  52. package/dist/components/ui/disclosure/disclosure.css +3 -6
  53. package/dist/components/ui/disclosure/disclosure.d.ts +15 -5
  54. package/dist/components/ui/disclosure/disclosure.script.d.ts +2 -2
  55. package/dist/components/ui/disclosure/index.d.ts +1 -1
  56. package/dist/components/ui/disclosure/index.js +1 -1
  57. package/dist/components/ui/disclosure/index.js.map +4 -4
  58. package/dist/components/ui/field/field.d.ts +1 -1
  59. package/dist/components/ui/field/field.script.d.ts +27 -4
  60. package/dist/components/ui/field/index.js +1 -1
  61. package/dist/components/ui/field/index.js.map +4 -4
  62. package/dist/components/ui/form/control-protocol.d.ts +38 -1
  63. package/dist/components/ui/form/form-context.d.ts +3 -0
  64. package/dist/components/ui/form/form.script.d.ts +7 -0
  65. package/dist/components/ui/form/index.d.ts +2 -1
  66. package/dist/components/ui/form/index.js +1 -1
  67. package/dist/components/ui/form/index.js.map +4 -4
  68. package/dist/components/ui/hover-card/hover-card.css +12 -101
  69. package/dist/components/ui/hover-card/hover-card.script.d.ts +7 -0
  70. package/dist/components/ui/hover-card/index.js +1 -1
  71. package/dist/components/ui/hover-card/index.js.map +4 -4
  72. package/dist/components/ui/input/index.js +1 -1
  73. package/dist/components/ui/input/index.js.map +4 -4
  74. package/dist/components/ui/input/input.css +1 -1
  75. package/dist/components/ui/knob/index.js +1 -1
  76. package/dist/components/ui/knob/index.js.map +3 -3
  77. package/dist/components/ui/knob/knob.css +6 -1
  78. package/dist/components/ui/knob/knob.d.ts +1 -1
  79. package/dist/components/ui/knob/knob.script.d.ts +25 -10
  80. package/dist/components/ui/label/index.js +1 -1
  81. package/dist/components/ui/label/index.js.map +4 -4
  82. package/dist/components/ui/listbox/index.js +1 -1
  83. package/dist/components/ui/listbox/index.js.map +4 -4
  84. package/dist/components/ui/listbox/listbox.d.ts +1 -2
  85. package/dist/components/ui/listbox/listbox.script.d.ts +7 -5
  86. package/dist/components/ui/menu-button/index.js +1 -1
  87. package/dist/components/ui/menu-button/index.js.map +4 -4
  88. package/dist/components/ui/menu-button/menu-button.script.d.ts +1 -1
  89. package/dist/components/ui/menubar/index.js +1 -1
  90. package/dist/components/ui/menubar/index.js.map +4 -4
  91. package/dist/components/ui/meter/index.js +1 -1
  92. package/dist/components/ui/meter/index.js.map +3 -3
  93. package/dist/components/ui/meter/meter.css +27 -2
  94. package/dist/components/ui/meter/meter.script.d.ts +14 -4
  95. package/dist/components/ui/navigation-menu/index.d.ts +1 -1
  96. package/dist/components/ui/navigation-menu/index.js +1 -1
  97. package/dist/components/ui/navigation-menu/index.js.map +4 -4
  98. package/dist/components/ui/navigation-menu/navigation-menu.css +32 -34
  99. package/dist/components/ui/navigation-menu/navigation-menu.d.ts +33 -4
  100. package/dist/components/ui/navigation-menu/navigation-menu.script.d.ts +71 -9
  101. package/dist/components/ui/number-field/index.js +1 -1
  102. package/dist/components/ui/number-field/index.js.map +4 -4
  103. package/dist/components/ui/number-field/number-field.css +1 -1
  104. package/dist/components/ui/number-field/number-field.d.ts +1 -1
  105. package/dist/components/ui/number-field/number-field.script.d.ts +7 -9
  106. package/dist/components/ui/pagination/index.d.ts +1 -1
  107. package/dist/components/ui/pagination/index.js +1 -1
  108. package/dist/components/ui/pagination/index.js.map +3 -3
  109. package/dist/components/ui/pagination/pagination.css +50 -13
  110. package/dist/components/ui/pagination/pagination.d.ts +25 -6
  111. package/dist/components/ui/popover/index.js +1 -1
  112. package/dist/components/ui/popover/index.js.map +4 -4
  113. package/dist/components/ui/popover/popover.script.d.ts +5 -0
  114. package/dist/components/ui/radio-group/index.js +1 -1
  115. package/dist/components/ui/radio-group/index.js.map +4 -4
  116. package/dist/components/ui/radio-group/radio-group.script.d.ts +2 -1
  117. package/dist/components/ui/select/index.d.ts +1 -1
  118. package/dist/components/ui/select/index.js +1 -1
  119. package/dist/components/ui/select/index.js.map +4 -4
  120. package/dist/components/ui/select/select.css +4 -3
  121. package/dist/components/ui/select/select.d.ts +7 -5
  122. package/dist/components/ui/select/select.script.d.ts +32 -12
  123. package/dist/components/ui/shared/calendar-popover-behavior.d.ts +27 -0
  124. package/dist/components/ui/shared/listbox-host-controller.d.ts +5 -4
  125. package/dist/components/ui/shared/multi-value.d.ts +18 -8
  126. package/dist/components/ui/shared/numeric-range.d.ts +8 -0
  127. package/dist/components/ui/shared/popover.css +10 -99
  128. package/dist/components/ui/sidebar/index.d.ts +2 -1
  129. package/dist/components/ui/sidebar/index.js +1 -1
  130. package/dist/components/ui/sidebar/index.js.map +4 -4
  131. package/dist/components/ui/sidebar/sidebar-trigger.d.ts +12 -0
  132. package/dist/components/ui/sidebar/sidebar-trigger.script.d.ts +42 -29
  133. package/dist/components/ui/sidebar/sidebar.css +67 -61
  134. package/dist/components/ui/sidebar/sidebar.d.ts +1 -7
  135. package/dist/components/ui/sidebar/sidebar.script.d.ts +12 -7
  136. package/dist/components/ui/slider/index.js +1 -1
  137. package/dist/components/ui/slider/index.js.map +4 -4
  138. package/dist/components/ui/slider/slider.css +5 -5
  139. package/dist/components/ui/slider/slider.d.ts +5 -6
  140. package/dist/components/ui/slider/slider.script.d.ts +72 -29
  141. package/dist/components/ui/switch/index.js +1 -1
  142. package/dist/components/ui/switch/index.js.map +4 -4
  143. package/dist/components/ui/switch/switch.css +28 -22
  144. package/dist/components/ui/switch/switch.script.d.ts +10 -3
  145. package/dist/components/ui/table/index.js +1 -1
  146. package/dist/components/ui/table/index.js.map +4 -4
  147. package/dist/components/ui/table/table.d.ts +5 -3
  148. package/dist/components/ui/table/table.script.d.ts +25 -10
  149. package/dist/components/ui/tabs/tabs.css +18 -12
  150. package/dist/components/ui/tabs/tabs.script.d.ts +7 -0
  151. package/dist/components/ui/tag-group/index.js +1 -1
  152. package/dist/components/ui/tag-group/index.js.map +4 -4
  153. package/dist/components/ui/tag-group/tag-group.d.ts +7 -4
  154. package/dist/components/ui/tag-group/tag-group.script.d.ts +7 -5
  155. package/dist/components/ui/textarea/index.js +1 -1
  156. package/dist/components/ui/textarea/index.js.map +4 -4
  157. package/dist/components/ui/textarea/textarea.css +1 -1
  158. package/dist/components/ui/toast/index.js +1 -1
  159. package/dist/components/ui/toast/index.js.map +3 -3
  160. package/dist/components/ui/toast/toast.css +35 -32
  161. package/dist/components/ui/toast/toast.script.d.ts +2 -1
  162. package/dist/components/ui/toast/toaster.script.d.ts +6 -0
  163. package/dist/components/ui/tooltip/index.js +1 -1
  164. package/dist/components/ui/tooltip/index.js.map +4 -4
  165. package/dist/components/ui/tooltip/tooltip.css +14 -94
  166. package/dist/components/ui/tooltip/tooltip.script.d.ts +9 -1
  167. package/dist/components/ui/window-splitter/index.d.ts +1 -1
  168. package/dist/components/ui/window-splitter/index.js +1 -1
  169. package/dist/components/ui/window-splitter/index.js.map +3 -3
  170. package/dist/components/ui/window-splitter/window-splitter.d.ts +1 -1
  171. package/dist/components/ui/window-splitter/window-splitter.script.d.ts +5 -1
  172. package/dist/index.d.ts +1 -0
  173. package/dist/index.js +1 -1
  174. package/dist/index.js.map +4 -4
  175. package/dist/lib/icons/chevron-down.d.ts +0 -1
  176. package/dist/lib/intl-date/index.d.ts +4 -2
  177. package/dist/lib/intl-date/segment-editing.d.ts +34 -0
  178. package/dist/lib/intl-date/segments.d.ts +26 -4
  179. package/dist/lib/non-empty.d.ts +6 -0
  180. package/dist/lib/unique-id.d.ts +11 -0
  181. package/dist/lib/viewport/breakpoints.d.ts +6 -0
  182. package/dist/lib/viewport/mobile-layout.d.ts +15 -0
  183. package/dist/styles/primitives.css +10 -7
  184. package/dist/styles/radiant-ui-core.css +10 -0
  185. package/dist/styles/radiant-ui.css +40 -3
  186. package/dist/styles/style-dependencies.json +18 -6
  187. package/dist/styles/styles.css +456 -246
  188. package/dist/styles/tailwind.css +40 -93
  189. package/dist/styles/tokens/presets/colors/aurora.css +2 -0
  190. package/dist/styles/tokens/presets/colors/basalt.css +2 -0
  191. package/dist/styles/tokens/presets/colors/ember.css +2 -0
  192. package/dist/styles/tokens/presets/colors/glacier.css +2 -0
  193. package/dist/styles/tokens/semantic.css +1 -0
  194. package/dist/styles/tokens/system.css +11 -3
  195. package/dist/styles/tokens/typography/default.css +8 -0
  196. package/package.json +20 -10
@@ -1,2 +1,2 @@
1
- import{RadiantElement as Ce,customElement as pn,event as fn,onEvent as I,onUpdated as Me,prop as b,query as hn,state as pt}from"@ecopages/radiant";function O(e){if(e==null)return null;let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e.trim());if(!t)return null;let n=Number(t[1]),i=Number(t[2])-1,r=Number(t[3]),o=new Date(n,i,r);return o.getFullYear()!==n||o.getMonth()!==i||o.getDate()!==r?null:o}function it(e){let t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0");return`${t}-${n}-${i}`}var Mt=new Map;function Le(e,t){return`${JSON.stringify(e??null)}|${JSON.stringify(t)}`}function F(e,t){let n=Le(e,t),i=Mt.get(n);if(i)return i;let r=new Intl.DateTimeFormat(e,t);return Mt.set(n,r),r}function rt(e,t,n="medium"){return F(t,{dateStyle:n}).format(e)}var je={0:"digit",a:"letter","*":"any"},Ne=/\p{L}/u;function $e(e,t){let n=t?.[e];if(n instanceof RegExp)return{kind:"any",pattern:n};if(n)return{kind:n};let i=je[e];return i?{kind:i}:null}function Ft(e,t,n){return n?n.test(e):t==="digit"?/\d/.test(e):t==="letter"?Ne.test(e):e.length>0}function Tt(e,t,n=!1){let i=[],r=0;for(;r<e.length;){let o=e[r];if(o==="\\"){let a=e[r+1];a&&i.push({type:"literal",value:a}),r+=2;continue}if(o==="{"){let a=e.indexOf("}",r+1);if(a<0){i.push({type:"literal",value:"{"}),r+=1;continue}i.push({type:"fixed",value:e.slice(r+1,a)}),r=a+1;continue}if(o==="["){let a=We(e,r+1);if(a<0){i.push({type:"literal",value:"["}),r+=1;continue}let l=Tt(e.slice(r+1,a),t,!0);i.push(...l),r=a+1;continue}if(o==="]")break;let s=$e(o,t);if(s){i.push({type:"input",definition:o,kind:s.kind,pattern:s.pattern,optional:n}),r+=1;continue}i.push({type:"literal",value:o}),r+=1}return i}function We(e,t){let n=1;for(let i=t;i<e.length;i+=1)if(e[i]==="["&&e[i-1]!=="\\"&&(n+=1),e[i]==="]"&&e[i-1]!=="\\"&&(n-=1,n===0))return i;return-1}function ot(e,t){return Tt(e,t)}function at(e,t={}){return e.filter(n=>n.type==="input"&&(!t.requiredOnly||!n.optional)).length}function qe(e,t){let n="",i=0;for(let r of t){if(r.type==="fixed"||r.type==="literal"){e.slice(i,i+r.value.length)===r.value&&(i+=r.value.length);continue}if(i>=e.length)continue;let o=e[i];Ft(o,r.kind,r.pattern)&&(n+=o,i+=1)}return n}function Be(e,t){if(!e)return"";let n=0,i="";for(let r of t){if(r.type==="fixed"||r.type==="literal"){i+=r.value;continue}if(n>=e.length){if(r.optional)continue;break}let o=e[n];if(!Ft(o,r.kind,r.pattern)){if(r.optional)continue;break}i+=o,n+=1}return i}function He(e){return e.every(t=>t.type!=="input"||t.kind==="digit")}function Ye(e,t){let n=e.replace(/\D/g,""),i=t.filter(r=>r.type==="fixed").map(r=>r.value.replace(/\D/g,"")).join("");return i&&n.startsWith(i)?n.slice(i.length):n}function St(e,t,n){let i=ot(t,n),r=at(i),o=qe(e,i);return o.length===0&&/\S/.test(e)&&He(i)&&(o=Ye(e,i)),o.length>r&&(o=o.slice(0,r)),Be(o,i)}var st=new Date(2001,8,3);function U(e){return F(e,{year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(st).filter(t=>t.type==="year"||t.type==="month"||t.type==="day").map(t=>t.type)}function V(e){let t=F(e,{year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(st),n="";for(let i of t){if(i.type==="literal"){n+=i.value;continue}(i.type==="month"||i.type==="day"||i.type==="year")&&(n+=i.value.replace(/\d/g,"0"))}return n}function lt(e){return F(e,{year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(st).map(n=>n.type==="literal"?n.value:n.type==="year"?"yyyy":n.type==="month"?"mm":n.type==="day"?"dd":"").join("")}function A(e){return e.replace(/\D/g,"")}function K(e,t){return St(A(e),t)}function N(e){return at(ot(e),{requiredOnly:!0})}function Ue(e){return e>=100?e:e>=69?1900+e:2e3+e}function ut(e,t){let n=U(t),i=0,r={};for(let o of n){let s=o==="year"?4:2,a=e.slice(i,i+s);if(a.length<s)return null;let l=Number(a);o==="year"&&(l=Ue(l)),r[o]=l,i+=s}return r}function dt(e){if(e.year==null||e.month==null||e.day==null)return null;let t=new Date(e.year,e.month-1,e.day);return t.getFullYear()!==e.year||t.getMonth()!==e.month-1||t.getDate()!==e.day?null:t}var Ke=new Date(2001,8,3);function Pt(e){return F(e,{year:"numeric",month:"numeric",day:"numeric"}).formatToParts(Ke).filter(n=>n.type==="year"||n.type==="month"||n.type==="day").map(n=>n.type)}function Rt(e){return e>=100?e:e>=69?1900+e:2e3+e}function Et(e){let t=e.year,n=e.month,i=e.day;if(!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(i))return null;let r=new Date(t,n-1,i);return r.getFullYear()!==t||r.getMonth()!==n-1||r.getDate()!==i?null:r}function ct(e,t){let n=(e??"").trim();if(!n)return null;let i=O(n);if(i)return i;let r=ze(n,t);if(r)return r;let o=Xe(n,t);if(o)return o;let s=Pt(t),a=n.match(/\d+/g);if(!a||a.length<3)return null;let l={day:0,month:0,year:0};for(let f=0;f<3;f+=1){let m=s[f];if(!m)return null;let g=Number(a[f]);m==="year"&&(g=Rt(g)),l[m]=g}return Et(l)}function ze(e,t){let n=V(t),i=A(e);return i.length<N(n)?null:dt(ut(i,t)??{})}function Je(e){let t=new Map;for(let n of["short","long"])for(let i=0;i<12;i+=1){let r=F(e,{month:n}).formatToParts(new Date(2020,i,1)).find(o=>o.type==="month")?.value;r&&t.set(r.toLowerCase(),i+1)}return t}function Xe(e,t){let n=Je(t),i=e.toLowerCase();for(let[r,o]of n){if(i.indexOf(r)<0)continue;let a=e.match(/\d+/g);if(!a||a.length<2)continue;let l=a.find(v=>v.length===4)??a[a.length-1],f=a.find(v=>v!==l&&Number(v)<=31);if(!f||!l)continue;let m=Rt(Number(l)),g=Number(f);return Et({year:m,month:o,day:g})}return null}function Ot(e){if(!e)return;let t=e.split(",").map(n=>n.trim()).filter(Boolean);return t.length>1?t:t[0]}var Ge={top:"bottom",bottom:"top",left:"right",right:"left"},Qe=8;function Ze(e){let t=e.indexOf("-");if(t===-1)return{side:e,align:"center"};let n=e.slice(0,t),i=e.slice(t+1);return{side:n,align:i==="start"||i==="end"?i:"center"}}function Lt(e){return e==="top"||e==="bottom"?"y":"x"}function Vt(e,t,n,i,r){let{width:o,height:s}=t,a=0,l=0;switch(n){case"top":l=e.top-s-r;break;case"bottom":l=e.bottom+r;break;case"left":a=e.left-o-r;break;case"right":a=e.right+r;break}return Lt(n)==="y"?i==="start"?a=e.left:i==="end"?a=e.right-o:a=e.left+(e.width-o)/2:i==="start"?l=e.top:i==="end"?l=e.bottom-s:l=e.top+(e.height-s)/2,{x:a,y:l}}function tn(e,t,n,i){let{padding:r,width:o,height:s}=i;return n==="top"?Math.max(0,r-e.y):n==="bottom"?Math.max(0,e.y+t.height-(s-r)):n==="left"?Math.max(0,r-e.x):Math.max(0,e.x+t.width-(o-r))}function At(e,t,n,i){let{padding:r,width:o,height:s}=i;return n==="top"?e.top-r-t.height:n==="bottom"?s-r-t.height-e.bottom:n==="left"?e.left-r-t.width:o-r-t.width-e.right}function en(e,t){return t==="center"?e:`${e}-${t}`}function nn(e,t,n,i){let{padding:r,width:o,height:s}=i;if(Lt(n)==="y"){let l=Math.max(r,o-r-t.width);return{x:Math.min(Math.max(e.x,r),l),y:e.y}}let a=Math.max(r,s-r-t.height);return{x:e.x,y:Math.min(Math.max(e.y,r),a)}}function rn(e,t,n,i,r={width:typeof window>"u"?0:window.innerWidth,height:typeof window>"u"?0:window.innerHeight,padding:Qe}){let{side:o,align:s}=Ze(n),a=Vt(e,t,o,s,i),l=tn(a,t,o,r),f=o,m=a;if(l>0){let g=Ge[o],v=Vt(e,t,g,s,i),$=At(e,t,o,r);At(e,t,g,r)>$&&(f=g,m=v)}return{coords:nn(m,t,f,r),placement:en(f,s)}}function on(e,t,n,i,r={}){let{coords:o,placement:s}=rn(e.getBoundingClientRect(),{width:t.offsetWidth,height:t.offsetHeight},n,i);return Object.assign(t.style,{position:"fixed",left:`${o.x}px`,top:`${o.y}px`,right:"auto",bottom:"auto",visibility:"visible"}),r.matchAnchorWidth&&(t.style.width=`${e.offsetWidth}px`),t.setAttribute("data-placement",s),s}function jt({anchor:e,floating:t,getPlacement:n,gap:i,matchAnchorWidth:r}){let o=()=>{t.hidden||on(e,t,n(),i,{matchAnchorWidth:r})};o(),window.addEventListener("resize",o),window.addEventListener("scroll",o,!0);let s=new ResizeObserver(o);return s.observe(e),s.observe(t),()=>{window.removeEventListener("resize",o),window.removeEventListener("scroll",o,!0),s.disconnect()}}function Nt(e,t=document.body){let n=e.parentNode;if(!n)return{unmount:()=>{}};let i=document.createComment("rui-portal");return n.insertBefore(i,e),t.appendChild(e),{unmount:()=>{let r=i.parentNode;r&&(r.insertBefore(e,i),i.remove())}}}function $t(e,t,n){return n?!!(e?.contains(n)||t?.contains(n)):!1}function Wt(e,t,n){return n instanceof Node?!$t(e,t,n):!0}var z=class{config;cleanupFloating=null;portalHandle=null;floatingElement=null;constructor(t){this.config=t}updateConfig(t){this.config={...this.config,...t}}sync(){let t=this.resolveFloating();if(!t)return;if(!this.config.getOpen()){this.teardown(),t.toggleAttribute("hidden",!0);return}let i=this.config.getAnchor();if(!i)return;t.toggleAttribute("hidden",!1),this.config.portal!==!1?this.portalHandle||(this.portalHandle=Nt(t,this.config.portalContainer??document.body)):this.portalHandle&&(this.portalHandle.unmount(),this.portalHandle=null),this.teardownFloating(),this.cleanupFloating=jt({anchor:i,floating:t,getPlacement:this.config.getPlacement,gap:this.config.gap??8,matchAnchorWidth:this.config.matchAnchorWidth})}contains(t){return $t(this.config.getAnchor(),this.resolveFloating(),t)}getFloatingElement(){return this.resolveFloating()}teardown(){this.teardownFloating(),this.portalHandle&&(this.portalHandle.unmount(),this.portalHandle=null)}destroy(){this.teardown(),this.floatingElement=null}resolveFloating(){let t=this.config.getFloating();return t&&(this.floatingElement=t),t??this.floatingElement}teardownFloating(){this.cleanupFloating?.(),this.cleanupFloating=null}};function an(e){let t=e.previousElementSibling;return t?.tagName.toLowerCase()==="label"?t:e.parentElement?.querySelector("[data-rui-field-label]")??null}function sn(e,t,n){e.id||(e.id=n.labelId),e.htmlFor||(e.htmlFor=n.controlId),t.setAttribute("aria-labelledby",e.id),t.removeAttribute("aria-label")}function qt(e,t,n){if(!t||t.hasAttribute("data-rui-field-managed"))return;let i=an(e);if(i){sn(i,t,n);return}if(n.label){t.setAttribute("aria-label",n.label),t.removeAttribute("aria-labelledby");return}t.removeAttribute("aria-label"),t.removeAttribute("aria-labelledby")}var Bt,Ht,Yt,Ut,Kt,zt,Jt,Xt,Gt,Qt,Zt,te,ee,ne,ie,re,oe,ae,se,le,ue,de,ce,pe,fe,he,me,ge,ye,ve,be,xe,De,_e,we,ke;function ln(e,t,n,i,r,o){var s,a,l,f,m,g,v,$=Symbol.metadata||Symbol.for("Symbol.metadata"),X=Object.defineProperty,G=Object.create,mt=[G(null),G(null)],gt=t.length;function W(u,w,D){return function(d,c){w&&(c=d,d=e);for(var k=0;k<u.length;k++)c=u[k].apply(d,D?[c]:[]);return D?c:d}}function T(u,w,D,d){if(typeof u!="function"&&(d||u!==void 0))throw new TypeError(w+" must "+(D||"be")+" a function"+(d?"":" or undefined"));return u}function yt(u,w,D,d,c,k,P,_,C,M,bt){function Q(h){if(!bt(h))throw new TypeError("Attempted to access private element on non-instance")}var Z=[].concat(w[0]),xt=w[3],tt=!P,L=c===1,Dt=c===3,_t=c===4,q=c===2;function B(h,E,It){return function(Y,Ct){return E&&(Ct=Y,Y=u),It&&It(Y),p[h].call(Y,Ct)}}if(!tt){var p={},et=[],S=Dt?"get":_t||L?"set":"value";if(C?(M||L?p={get:Ie(function(){return xt(this)},d,"get"),set:function(h){w[4](this,h)}}:p[S]=xt,M||Ie(p[S],d,q?"":S)):M||(p=Object.getOwnPropertyDescriptor(u,d)),!M&&!C){if((a=mt[+_][d])&&(a^c)!==7)throw Error("Decorating two elements with the same name ("+p[S].name+") is not supported yet");mt[+_][d]=c<3?1:c}}for(var y=u,H=Z.length-1;H>=0;H-=D?2:1){var wt=T(Z[H],"A decorator","be",!0),kt=D?Z[H-1]:void 0,nt={},j={kind:["field","accessor","method","getter","setter","class"][c],name:d,metadata:s,addInitializer:function(h,E){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");T(E,"An initializer","be",!0),k.push(E)}.bind(null,nt)};if(tt)a=wt.call(kt,y,j),nt.v=1,T(a,"class decorators","return")&&(y=a);else if(j.static=_,j.private=C,a=j.access={has:C?bt.bind():function(h){return d in h}},_t||(a.get=C?q?function(h){return Q(h),p.value}:B("get",0,Q):function(h){return h[d]}),q||Dt||(a.set=C?B("set",0,Q):function(h,E){h[d]=E}),y=wt.call(kt,L?{get:p.get,set:p.set}:p[S],j),nt.v=1,L){if(typeof y=="object"&&y)(a=T(y.get,"accessor.get"))&&(p.get=a),(a=T(y.set,"accessor.set"))&&(p.set=a),(a=T(y.init,"accessor.init"))&&et.unshift(a);else if(y!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else T(y,(M?"field":"method")+" decorators","return")&&(M?et.unshift(y):p[S]=y)}return c<2&&P.push(W(et,_,1),W(k,_,0)),M||tt||(C?L?P.splice(-1,0,B("get",_),B("set",_)):P.push(q?p[S]:T.call.bind(p[S])):X(u,d,p)),y}function vt(u){return X(u,$,{configurable:!0,enumerable:!0,value:s})}return o!==void 0&&(s=o[$]),s=G(s??null),m=[],g=function(u){u&&m.push(W(u))},v=function(u,w){for(var D=0;D<n.length;D++){var d=n[D],c=d[1],k=7&c;if((8&c)==u&&!k==w){var P=d[2],_=!!d[3],C=16&c;yt(u?e:e.prototype,d,C,_?"#"+P:un(P),k,k<2?[]:u?f=f||[]:l=l||[],m,!!u,_,w,u&&_?function(M){return cn(M)===e}:r)}}},v(8,0),v(0,0),v(8,1),v(0,1),g(l),g(f),a=m,gt||vt(e),{e:a,get c(){var u=[];return gt&&[vt(e=yt(e,[t],i,e.name,5,u)),W(u,1)]}}}function un(e){var t=dn(e,"string");return typeof t=="symbol"?t:t+""}function dn(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,t||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Ie(e,t,n){typeof t=="symbol"&&(t=(t=t.description)?"["+t+"]":"");try{Object.defineProperty(e,"name",{configurable:!0,value:n?n+" "+t:t})}catch{}return e}function cn(e){if(Object(e)!==e)throw TypeError("right-hand side of 'in' should be an object, got "+(e!==null?typeof e:"null"));return e}var Te,Fe=class extends Ce{static{({e:[Yt,Ut,Kt,zt,Jt,Xt,Gt,Qt,Zt,te,ee,ne,ie,re,oe,ae,se,le,ue,de,ce,pe,fe,he,me,ge,ye,ve,be,xe,De,_e,we,ke,Bt],c:[Te,Ht]}=ln(this,[pn("rui-date-field")],[[b({type:String,reflect:!0,defaultValue:""}),0,"value"],[b({type:String,defaultValue:""}),0,"min"],[b({type:String,defaultValue:""}),0,"max"],[b({type:Boolean,reflect:!0,defaultValue:!1}),0,"disabled"],[b({type:Boolean,attribute:"read-only",reflect:!0,defaultValue:!1}),0,"readOnly"],[b({type:String,defaultValue:""}),0,"label"],[b({type:String,defaultValue:""}),0,"name"],[b({type:String,defaultValue:""}),0,"placeholder"],[b({type:String,defaultValue:""}),0,"locale"],[b({type:String,attribute:"date-style",defaultValue:"medium"}),0,"dateStyle"],[b({type:Boolean,reflect:!0,defaultValue:!0}),0,"masked"],[b({type:Number,attribute:"visible-months",defaultValue:1}),0,"visibleMonths"],[fn({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[pt,0,"displayValue"],[pt,0,"editing"],[pt,0,"open"],[hn({ref:"popover"}),0,"popoverTarget"],[Me(["value","min","max","label","placeholder","disabled","readOnly","locale","dateStyle","masked","visibleMonths"]),2,"onPropsUpdated"],[Me(["open"]),2,"onOpenUpdated"],[I({selector:"[data-date-field-input]",type:"focusin"}),2,"onInputFocus"],[I({selector:"[data-date-field-input]",type:"input"}),2,"onInput"],[I({selector:"[data-date-field-input]",type:"change"}),2,"onInputChange"],[I({selector:"[data-date-field-input]",type:"keydown"}),2,"onInputKeydown"],[I({selector:"[data-date-field-input], [data-date-field-trigger], [data-date-field-popover]",type:"focusout"}),2,"onRootFocusOut"],[I({ref:"trigger",type:"pointerdown"}),2,"onTriggerPointerDown"],[I({ref:"trigger",type:"click"}),2,"onTriggerClick"],[I({selector:"[data-date-field-popover]",type:"mousedown"}),2,"onPopoverMouseDown"],[I({selector:"[data-date-field-calendar]",type:"rui-change"}),2,"onCalendarChange"],[I({selector:"[data-date-field-input], [data-date-field-trigger], [data-date-field-calendar]",type:"keydown"}),2,"onRootKeydown"]],0,void 0,Ce))}constructor(...t){super(...t),ke(this)}value=(Bt(this),Yt(this));min=(Ut(this),Kt(this));max=(zt(this),Jt(this));disabled=(Xt(this),Gt(this));readOnly=(Qt(this),Zt(this));label=(te(this),ee(this));name=(ne(this),ie(this));placeholder=(re(this),oe(this));locale=(ae(this),se(this));dateStyle=(le(this),ue(this));masked=(de(this),ce(this));visibleMonths=(pe(this),fe(this));changeEvent=(he(this),me(this));displayValue=(ge(this),ye(this,""));editing=(ve(this),be(this,!1));open=(xe(this),De(this,!1));uid=(_e(this),Math.random().toString(36).slice(2,9));popoverController=null;suppressPopoverDismiss=!1;popoverTarget=we(this);get isoValue(){return this.value??""}get resolvedLocale(){return Ot(this.locale)}get inputId(){return`rui-date-field-input-${this.uid}`}get resolvedPlaceholder(){return this.placeholder||lt(this.resolvedLocale)}getInput(){return this.querySelector("[data-date-field-input]")}getToggle(){return this.querySelector("[data-date-field-trigger]")}getCalendar(){return this.querySelector("[data-date-field-calendar]")}syncLabel(){let t=this.getInput();qt(this,t,{controlId:this.inputId,label:this.label,labelId:`rui-date-field-label-${this.uid}`})}syncInput(){let t=this.getInput();if(!t)return;t.id||(t.id=this.inputId),t.name=this.name,t.disabled=this.disabled,t.readOnly=this.readOnly,t.inputMode=this.masked?"numeric":"text";let n=this.resolvedPlaceholder;n&&(t.placeholder=n)}syncToggle(){let t=this.getToggle();t&&(t.disabled=this.disabled||this.readOnly,t.setAttribute("aria-expanded",String(this.open)))}syncCalendar(){let t=this.getCalendar();t&&(t.setAttribute("selection-mode","single"),t.setAttribute("visible-months",String(this.visibleMonths)),t.setAttribute("value",this.isoValue),t.setAttribute("min",this.min),t.setAttribute("max",this.max),t.setAttribute("locale",this.locale),t.toggleAttribute("disabled",this.disabled))}formatForDisplay(t){if(!t)return"";let n=O(t);return n?rt(n,this.resolvedLocale,this.dateStyle):""}formatForEditing(t){if(!t)return"";if(!this.masked)return this.formatForDisplay(t);let n=O(t);if(!n)return"";let i=V(this.resolvedLocale),r=mn(n,this.resolvedLocale);return K(r,i)}syncDisplayValue(){if(this.editing)return;this.displayValue=this.formatForDisplay(this.isoValue);let t=this.getInput();t&&(t.value=this.displayValue)}isIsoAllowed(t){return!(this.min&&t<this.min||this.max&&t>this.max)}commitValue(t){if(t&&!this.isIsoAllowed(t)){this.syncDisplayValue();return}if(t===this.isoValue){this.syncDisplayValue();return}this.value=t,this.changeEvent.emit({value:t}),this.syncDisplayValue()}parseAndCommit(t){let n=(t??"").trim();if(!n){this.commitValue("");return}let i=ct(n,this.resolvedLocale);if(!i){this.syncDisplayValue();return}this.commitValue(it(i))}handleMaskedInput(t){let n=V(this.resolvedLocale),i=A(t),r=K(i,n);return i.length>=N(n)&&this.parseAndCommit(r),r}initialize(){this.syncLabel(),this.syncInput(),this.syncDisplayValue(),this.syncToggle(),this.syncCalendar(),this.setOpen(!1)}setOpen(t){this.open=t,queueMicrotask(()=>{this.syncCalendar(),this.syncPopoverPosition(),t&&this.focusCalendarDay()})}focusCalendarDay(){requestAnimationFrame(()=>{if(!this.open)return;let t=this.getCalendar();((this.isoValue?t?.querySelector(`[data-calendar-day][data-iso="${this.isoValue}"]:not(:disabled)`):null)??t?.querySelector('[data-calendar-day][tabindex="0"]:not(:disabled), [data-calendar-day]:not(:disabled)'))?.focus()})}ensurePopoverController(){return this.popoverController||(this.popoverController=new z({getAnchor:()=>this.getToggle()?.parentElement??this,getFloating:()=>this.popoverTarget,getOpen:()=>this.open,getPlacement:()=>"bottom-start",gap:4,portal:!1})),this.popoverController}syncPopoverPosition(){let t=this.popoverTarget;if(!t)return;t.hidden=!this.open;let n=this.ensurePopoverController();n.updateConfig({getOpen:()=>this.open}),n.sync()}onConnected(){this.initialize()}disconnectedCallback(){this.popoverController?.destroy(),this.popoverController=null,super.disconnectedCallback()}onPropsUpdated(){this.syncLabel(),this.syncInput(),this.syncDisplayValue(),this.syncToggle(),this.syncCalendar()}onOpenUpdated(){this.syncToggle(),this.syncPopoverPosition()}onInputFocus(){this.editing=!0;let t=this.getInput();t&&(t.value=this.isoValue?this.formatForEditing(this.isoValue):"",this.displayValue=t.value)}onInput(t){let n=t.target;if(this.masked){let i=this.handleMaskedInput(n.value);n.value=i,this.displayValue=i;return}this.displayValue=n.value}onInputChange(){let t=this.getInput();t&&this.parseAndCommit(t.value)}onInputKeydown(t){if(t.key==="Escape"){if(this.open){t.preventDefault(),this.setOpen(!1);return}this.editing=!1,this.syncDisplayValue()}}onRootFocusOut(t){let n=t.target,i=t.relatedTarget;if(n.matches("[data-date-field-input]")&&n.localName==="input"){let r=n;queueMicrotask(()=>{this.editing&&(this.editing=!1,this.parseAndCommit(r.value))})}queueMicrotask(()=>{if(this.suppressPopoverDismiss){this.suppressPopoverDismiss=!1;return}if(!this.open)return;let r=i instanceof Node?i:document.activeElement;Wt(this,this.popoverTarget,r)&&this.setOpen(!1)})}onTriggerPointerDown(){this.suppressPopoverDismiss=!0}onTriggerClick(){this.disabled||this.readOnly||this.setOpen(!this.open)}onPopoverMouseDown(t){t.preventDefault()}onCalendarChange(t){let n=t.target;if(!(n instanceof HTMLElement)||!n.matches("[data-date-field-calendar]"))return;let i=t.detail;i?.value&&(this.commitValue(i.value),this.setOpen(!1))}onRootKeydown(t){t.key==="Escape"&&this.open&&(t.preventDefault(),this.setOpen(!1))}static{Ht()}};function mn(e,t){let n=U(t),i={month:String(e.getMonth()+1).padStart(2,"0"),day:String(e.getDate()).padStart(2,"0"),year:String(e.getFullYear())};return n.map(r=>i[r]).join("")}import{Fragment as vn,jsx as x,jsxs as Pe}from"@ecopages/jsx/jsx-runtime";function Se(e,t){return t===void 0||e?.label!==void 0?e:{...e,label:t}}function R(...e){return e.filter(Boolean).join(" ")}import{jsx as J,jsxs as gn}from"@ecopages/jsx/jsx-runtime";function ft({class:e,size:t="sm",...n}){return gn("svg",{...n,class:R("rui-icon",t==="md"&&"rui-icon--md",e),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:[J("path",{d:"M8 2v4"}),J("path",{d:"M16 2v4"}),J("rect",{width:"18",height:"18",x:"3",y:"4",rx:"2"}),J("path",{d:"M3 10h18"})]})}import{jsx as yn}from"@ecopages/jsx/jsx-runtime";function ht({children:e,...t}){return yn("rui-calendar",{...t,children:e})}function Re({children:e,class:t,...n}){return x("div",{...n,class:R("rui-date-field",t),children:x("div",{class:"rui-date-field__group",children:e})})}function Ee({class:e,...t}){return x("input",{...t,type:"text","data-date-field-input":!0,"data-rui-control":!0,"data-rui-control-type":"text",class:R("rui-date-field__input",e),autocomplete:"off"})}function Oe({children:e,class:t,aria:n,...i}){return x("button",{...i,aria:Se(n,"Open calendar"),type:"button","data-ref":"trigger","data-date-field-trigger":!0,class:R("rui-control-toggle",t),"aria-haspopup":"dialog",children:e??x(ft,{})})}function Ve({children:e,class:t,...n}){return x("div",{...n,"data-ref":"popover","data-date-field-popover":!0,class:R("rui-date-field__popover rui-popover rui-floating",t),hidden:!0,role:"dialog",children:e})}function Ae(e){return x(ht,{...e,"data-date-field-calendar":!0})}function bn({children:e,...t}){return x("rui-date-field",{...t,children:e??Pe(vn,{children:[Pe(Re,{children:[x(Ee,{}),x(Oe,{})]}),x(Ve,{children:x(Ae,{})})]})})}export{bn as RuiDateField,Ae as RuiDateFieldCalendar,Re as RuiDateFieldControl,Te as RuiDateFieldElement,Ee as RuiDateFieldInput,Ve as RuiDateFieldPopover,Oe as RuiDateFieldToggle};
1
+ import{RadiantElement as Gt,bindTo as se,customElement as Wr,event as zr,onEvent as le,onUpdated as Wt,prop as U,query as Hr,state as Ur}from"@ecopages/radiant";function Sr(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(`(max-width: ${639}px)`).matches}function it(t){return t<=1||!Sr()?t:1}function at(t){if(typeof window>"u"||typeof window.matchMedia!="function")return null;let e=window.matchMedia(`(max-width: ${639}px)`);return e.addEventListener("change",t),()=>e.removeEventListener("change",t)}var Mr=/^[A-Za-z][A-Za-z0-9_-]*$/;function ot(t){return Mr.test(t)}function Ir(t){let e=t.trim();if(ot(e))return e;let n=`rui-${e}`;return e&&ot(n)?n:"rui"}function De(t){let e=typeof crypto.randomUUID=="function"?crypto.randomUUID().replace(/-/g,""):Array.from(crypto.getRandomValues(new Uint8Array(16)),n=>n.toString(16).padStart(2,"0")).join("");return`${Ir(t)}-${e}`}var Rr={top:"bottom",bottom:"top",left:"right",right:"left"},Fr=8,Le=new WeakMap;function Pr(t){Le.has(t)&&(t.style.width="",t.style.minWidth="",t.style.maxWidth="",t.style.boxSizing="",Le.delete(t))}function Er(t){let e=t.indexOf("-");if(e===-1)return{side:t,align:"center"};let n=t.slice(0,e),r=t.slice(e+1);return{side:n,align:r==="start"||r==="end"?r:"center"}}function ut(t){return t==="top"||t==="bottom"?"y":"x"}function st(t,e,n,r,i){let{width:a,height:s}=e,o=0,f=0;switch(n){case"top":f=t.top-s-i;break;case"bottom":f=t.bottom+i;break;case"left":o=t.left-a-i;break;case"right":o=t.right+i;break}return ut(n)==="y"?r==="start"?o=t.left:r==="end"?o=t.right-a:o=t.left+(t.width-a)/2:r==="start"?f=t.top:r==="end"?f=t.bottom-s:f=t.top+(t.height-s)/2,{x:o,y:f}}function Ar(t,e,n,r){let{padding:i,width:a,height:s}=r;return n==="top"?Math.max(0,i-t.y):n==="bottom"?Math.max(0,t.y+e.height-(s-i)):n==="left"?Math.max(0,i-t.x):Math.max(0,t.x+e.width-(a-i))}function lt(t,e,n,r){let{padding:i,width:a,height:s}=r;return n==="top"?t.top-i-e.height:n==="bottom"?s-i-e.height-t.bottom:n==="left"?t.left-i-e.width:a-i-e.width-t.right}function Tr(t,e){return e==="center"?t:`${t}-${e}`}function kr(t,e,n,r){let{padding:i,width:a,height:s}=r;if(ut(n)==="y"){let f=Math.max(i,a-i-e.width);return{x:Math.min(Math.max(t.x,i),f),y:Math.max(i,t.y)}}let o=Math.max(i,s-i-e.height);return{x:Math.max(i,t.x),y:Math.min(Math.max(t.y,i),o)}}function Lr(t,e,n,r,i={width:typeof window>"u"?0:window.innerWidth,height:typeof window>"u"?0:window.innerHeight,padding:Fr}){let{side:a,align:s}=Er(n),o=st(t,e,a,s,r),f=Ar(o,e,a,i),y=a,x=o;if(f>0){let R=Rr[a],M=st(t,e,R,s,r),O=lt(t,e,a,i);lt(t,e,R,i)>O&&(y=R,x=M)}return{coords:kr(x,e,y,i),placement:Tr(y,s)}}function Cr(t,e,n,r,i={}){let a=i.matchAnchorWidth===!0,s=t.offsetWidth,o=a?{width:s,height:e.offsetHeight}:{width:e.offsetWidth,height:e.offsetHeight};a?(e.style.width=`${s}px`,e.style.minWidth=`${s}px`,e.style.maxWidth=`${s}px`,e.style.boxSizing="border-box",Le.set(e,!0)):Pr(e);let{coords:f,placement:y}=Lr(t.getBoundingClientRect(),o,n,r);return Object.assign(e.style,{position:"fixed",left:`${f.x}px`,top:`${f.y}px`,right:"auto",bottom:"auto",visibility:"visible"}),e.setAttribute("data-placement",y),y}function ct({anchor:t,floating:e,getPlacement:n,gap:r,matchAnchorWidth:i}){let a=()=>{e.hidden||Cr(t,e,n(),r,{matchAnchorWidth:i})};a(),window.addEventListener("resize",a),window.addEventListener("scroll",a,!0);let s=new ResizeObserver(a);return s.observe(t),s.observe(e),()=>{window.removeEventListener("resize",a),window.removeEventListener("scroll",a,!0),s.disconnect()}}function dt(t,e=document.body){let n=t.parentNode;if(!n)return{unmount:()=>{}};let r=document.createComment("rui-portal");return n.insertBefore(r,t),e.appendChild(t),{unmount:()=>{let i=r.parentNode;i&&(i.insertBefore(t,r),r.remove())}}}function ht(t,e,n){return n?!!(t?.contains(n)||e?.contains(n)):!1}function ft(t,e,n){return n instanceof Node?!ht(t,e,n):!0}var Se=class{config;cleanupFloating=null;portalHandle=null;floatingElement=null;constructor(e){this.config=e}updateConfig(e){this.config={...this.config,...e}}sync(){let e=this.resolveFloating();if(!e)return;if(!this.config.getOpen()){this.teardown(),e.toggleAttribute("hidden",!0);return}let r=this.config.getAnchor();if(!r)return;e.toggleAttribute("hidden",!1),this.config.portal!==!1?this.portalHandle||(this.portalHandle=dt(e,this.config.portalContainer??document.body)):this.portalHandle&&(this.portalHandle.unmount(),this.portalHandle=null),this.teardownFloating(),this.cleanupFloating=ct({anchor:r,floating:e,getPlacement:this.config.getPlacement,gap:this.config.gap??8,matchAnchorWidth:this.config.matchAnchorWidth})}contains(e){return ht(this.config.getAnchor(),this.resolveFloating(),e)}getFloatingElement(){return this.resolveFloating()}teardown(){this.teardownFloating(),this.portalHandle&&(this.portalHandle.unmount(),this.portalHandle=null)}destroy(){this.teardown(),this.floatingElement=null}resolveFloating(){let e=this.config.getFloating();return e&&(this.floatingElement=e),e??this.floatingElement}teardownFloating(){this.cleanupFloating?.(),this.cleanupFloating=null}};var Me=class{config;popoverController=null;suppressPopoverDismiss=!1;constructor(e){this.config=e}destroy(){this.popoverController?.destroy(),this.popoverController=null}suppressDismiss(){this.suppressPopoverDismiss=!0}syncPopover(){let e=this.config.getFloating();if(!e)return;e.hidden=!this.config.getOpen();let n=this.ensureController();n.updateConfig({getOpen:()=>this.config.getOpen()}),n.sync()}focusCalendarDay(){Vr(this.config.getCalendar(),this.config.getFocusIso())}handleFocusOut(e,n){let r=e.relatedTarget;queueMicrotask(()=>{if(this.suppressPopoverDismiss){this.suppressPopoverDismiss=!1;return}if(!this.config.getOpen())return;let i=this.config.getFloating();if(!i)return;let a=r instanceof Node?r:document.activeElement;ft(this.config.getHost(),i,a)&&n()})}ensureController(){return this.popoverController||(this.popoverController=new Se({getAnchor:this.config.getAnchor,getFloating:this.config.getFloating,getOpen:this.config.getOpen,getPlacement:()=>"bottom-start",gap:4,portal:!1})),this.popoverController}};function Vr(t,e){requestAnimationFrame(()=>{if(!t)return;((e?t.querySelector(`[data-calendar-day][data-iso="${e}"]:not(:disabled)`):null)??t.querySelector('[data-calendar-day][tabindex="0"]:not(:disabled), [data-calendar-day]:not(:disabled)'))?.focus()})}function Or(t){let e=t.previousElementSibling;return e?.tagName.toLowerCase()==="label"?e:t.parentElement?.querySelector("[data-rui-field-label]")??null}function jr(t,e,n){t.id||(t.id=n.labelId),t.htmlFor||(t.htmlFor=n.controlId),e.setAttribute("aria-labelledby",t.id),e.removeAttribute("aria-label")}function pt(t,e,n){if(!e||e.hasAttribute("data-rui-field-managed"))return;let r=Or(t);if(r){jr(r,e,n);return}if(n.label){e.setAttribute("aria-label",n.label),e.removeAttribute("aria-labelledby");return}e.removeAttribute("aria-label"),e.removeAttribute("aria-labelledby")}var mt,gt,yt,vt,bt,xt,_t,wt,Dt,St,Mt,It,Rt,Ft,Pt,Et,At,Tt,kt,Lt,Ct,Vt,Ot,jt,Yt,Bt;function Yr(t,e,n,r,i,a){var s,o,f,y,x,R,M,O=Symbol.metadata||Symbol.for("Symbol.metadata"),j=Object.defineProperty,A=Object.create,N=[A(null),A(null)],X=e.length;function T(l,v,m){return function(u,c){v&&(c=u,u=t);for(var b=0;b<l.length;b++)c=l[b].apply(u,m?[c]:[]);return m?c:u}}function D(l,v,m,u){if(typeof l!="function"&&(u||l!==void 0))throw new TypeError(v+" must "+(m||"be")+" a function"+(u?"":" or undefined"));return l}function J(l,v,m,u,c,b,I,g,_,w,Q){function $(h){if(!Q(h))throw new TypeError("Attempted to access private element on non-instance")}var G=[].concat(v[0]),ee=v[3],W=!I,P=c===1,te=c===3,ne=c===4,k=c===2;function L(h,F,ae){return function(V,oe){return F&&(oe=V,V=l),ae&&ae(V),d[h].call(V,oe)}}if(!W){var d={},z=[],S=te?"get":ne||P?"set":"value";if(_?(w||P?d={get:$t(function(){return ee(this)},u,"get"),set:function(h){v[4](this,h)}}:d[S]=ee,w||$t(d[S],u,k?"":S)):w||(d=Object.getOwnPropertyDescriptor(l,u)),!w&&!_){if((o=N[+g][u])&&(o^c)!==7)throw Error("Decorating two elements with the same name ("+d[S].name+") is not supported yet");N[+g][u]=c<3?1:c}}for(var p=l,C=G.length-1;C>=0;C-=m?2:1){var re=D(G[C],"A decorator","be",!0),ie=m?G[C-1]:void 0,H={},E={kind:["field","accessor","method","getter","setter","class"][c],name:u,metadata:s,addInitializer:function(h,F){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");D(F,"An initializer","be",!0),b.push(F)}.bind(null,H)};if(W)o=re.call(ie,p,E),H.v=1,D(o,"class decorators","return")&&(p=o);else if(E.static=g,E.private=_,o=E.access={has:_?Q.bind():function(h){return u in h}},ne||(o.get=_?k?function(h){return $(h),d.value}:L("get",0,$):function(h){return h[u]}),k||te||(o.set=_?L("set",0,$):function(h,F){h[u]=F}),p=re.call(ie,P?{get:d.get,set:d.set}:d[S],E),H.v=1,P){if(typeof p=="object"&&p)(o=D(p.get,"accessor.get"))&&(d.get=o),(o=D(p.set,"accessor.set"))&&(d.set=o),(o=D(p.init,"accessor.init"))&&z.unshift(o);else if(p!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else D(p,(w?"field":"method")+" decorators","return")&&(w?z.unshift(p):d[S]=p)}return c<2&&I.push(T(z,g,1),T(b,g,0)),w||W||(_?P?I.splice(-1,0,L("get",g),L("set",g)):I.push(k?d[S]:D.call.bind(d[S])):j(l,u,d)),p}function Z(l){return j(l,O,{configurable:!0,enumerable:!0,value:s})}return a!==void 0&&(s=a[O]),s=A(s??null),x=[],R=function(l){l&&x.push(T(l))},M=function(l,v){for(var m=0;m<n.length;m++){var u=n[m],c=u[1],b=7&c;if((8&c)==l&&!b==v){var I=u[2],g=!!u[3],_=16&c;J(l?t:t.prototype,u,_,g?"#"+I:Br(I),b,b<2?[]:l?y=y||[]:f=f||[],x,!!l,g,v,l&&g?function(w){return Gr(w)===t}:i)}}},M(8,0),M(0,0),M(8,1),M(0,1),R(f),R(y),o=x,X||Z(t),{e:o,get c(){var l=[];return X&&[Z(t=J(t,[e],r,t.name,5,l)),T(l,1)]}}}function Br(t){var e=$r(t,"string");return typeof e=="symbol"?e:e+""}function $r(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function $t(t,e,n){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(t,"name",{configurable:!0,value:n?n+" "+e:e})}catch{}return t}function Gr(t){if(Object(t)!==t)throw TypeError("right-hand side of 'in' should be an object, got "+(t!==null?typeof t:"null"));return t}var Ht,zt=class extends Gt{static{({e:[yt,vt,bt,xt,_t,wt,Dt,St,Mt,It,Rt,Ft,Pt,Et,At,Tt,kt,Lt,Ct,Vt,Ot,jt,Yt,Bt,mt],c:[Ht,gt]}=Yr(this,[Wr("rui-date-field")],[[[U({type:String,reflect:!0,defaultValue:""}),se([{selector:"[data-date-field-input]",attr:"value"},{selector:"[data-date-field-calendar]",attr:"value"}])],0,"value"],[[U({type:String,defaultValue:""}),se([{selector:"[data-date-field-input]",attr:"min"},{selector:"[data-date-field-calendar]",attr:"min"}])],0,"min"],[[U({type:String,defaultValue:""}),se([{selector:"[data-date-field-input]",attr:"max"},{selector:"[data-date-field-calendar]",attr:"max"}])],0,"max"],[[U({type:Boolean,reflect:!0,defaultValue:!1}),se([{selector:"[data-date-field-input]",bool:"disabled"},{selector:"[data-date-field-calendar]",bool:"disabled"}])],0,"disabled"],[[U({type:Boolean,attribute:"read-only",reflect:!0,defaultValue:!1}),se({selector:"[data-date-field-input]",bool:"read-only"})],0,"readOnly"],[U({type:String,defaultValue:""}),0,"label"],[[U({type:String,defaultValue:""}),se({selector:"[data-date-field-input]",attr:"name"})],0,"name"],[[U({type:String,defaultValue:""}),se([{selector:"[data-date-field-input]",attr:"locale"},{selector:"[data-date-field-calendar]",attr:"locale"}])],0,"locale"],[U({type:Number,attribute:"visible-months",defaultValue:1}),0,"visibleMonths"],[zr({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[[Ur,se({selector:"[data-date-field-trigger]",attr:"aria-expanded"})],0,"open"],[Hr({ref:"popover"}),0,"popoverTarget"],[Wt(["value","min","max","label","disabled","readOnly","locale","visibleMonths"]),2,"onPropsUpdated"],[Wt(["open"]),2,"onOpenUpdated"],[le({selector:"[data-date-field-input]",type:"rui-change"}),2,"onDateInputChange"],[le({selector:"[data-date-field-input]",type:"rui-form-reset"}),2,"onDateInputReset"],[le({selector:"[data-date-field-input], [data-date-field-trigger], [data-date-field-popover]",type:"focusout"}),2,"onRootFocusOut"],[le({ref:"trigger",type:"pointerdown"}),2,"onTriggerPointerDown"],[le({ref:"trigger",type:"click"}),2,"onTriggerClick"],[le({selector:"[data-date-field-popover]",type:"mousedown"}),2,"onPopoverMouseDown"],[le({selector:"[data-date-field-calendar]",type:"rui-change"}),2,"onCalendarChange"],[le({selector:"[data-date-field-input], [data-date-field-trigger], [data-date-field-calendar]",type:"keydown"}),2,"onRootKeydown"]],0,void 0,Gt))}value=(mt(this),yt(this));min=(vt(this),bt(this));max=(xt(this),_t(this));disabled=(wt(this),Dt(this));readOnly=(St(this),Mt(this));label=(It(this),Rt(this));name=(Ft(this),Pt(this));locale=(Et(this),At(this));visibleMonths=(Tt(this),kt(this));changeEvent=(Lt(this),Ct(this));open=(Vt(this),Ot(this,!1));uid=(jt(this),De("rui-date-field"));calendarPopover=new Me({getHost:()=>this,getAnchor:()=>this.getToggle()?.parentElement??this,getFloating:()=>this.popoverTarget,getOpen:()=>this.open,getCalendar:()=>this.getCalendar(),getFocusIso:()=>this.isoValue||void 0});disposeMobileLayoutListener=null;popoverTarget=Yt(this);onMediaChange=(Bt(this),()=>{this.syncCalendar(),this.open&&this.calendarPopover.syncPopover()});get isoValue(){return this.value??""}get inputId(){return`${this.uid}-input`}getDateInput(){return this.querySelector("[data-date-field-input]")}getToggle(){return this.querySelector("[data-date-field-trigger]")}getCalendar(){return this.querySelector("[data-date-field-calendar]")}syncLabel(){let e=this.getDateInput();pt(this,e,{controlId:this.inputId,label:this.label,labelId:`${this.uid}-label`})}syncInput(){let e=this.getDateInput();e?.id||e?.setAttribute("id",this.inputId)}syncToggle(){let e=this.getToggle();e&&(e.disabled=this.disabled||this.readOnly)}commitValue(e){e!==this.isoValue&&(this.value=e,this.changeEvent.emit({value:e}))}syncCalendar(){let e=this.getCalendar();e&&(e.setAttribute("selection-mode","single"),e.setAttribute("visible-months",String(it(this.visibleMonths))))}initialize(){this.syncLabel(),this.syncInput(),this.syncToggle(),this.syncCalendar(),this.setOpen(!1)}setOpen(e){this.open=e,queueMicrotask(()=>{this.calendarPopover.syncPopover(),e&&this.calendarPopover.focusCalendarDay()})}onConnected(){this.disposeMobileLayoutListener=at(this.onMediaChange),this.initialize()}disconnectedCallback(){this.disposeMobileLayoutListener?.(),this.disposeMobileLayoutListener=null,this.calendarPopover.destroy(),super.disconnectedCallback()}onPropsUpdated(){this.syncLabel(),this.syncInput(),this.syncToggle(),this.syncCalendar()}onOpenUpdated(){this.syncToggle(),this.calendarPopover.syncPopover()}onDateInputChange(e){let n=e.target;if(!(n instanceof HTMLElement)||!n.matches("[data-date-field-input]"))return;let r=e.detail;this.commitValue(r?.value??"")}onDateInputReset(){let e=this.getDateInput(),n=e&&Reflect.get(e,"value");this.value=typeof n=="string"?n:""}onRootFocusOut(e){this.calendarPopover.handleFocusOut(e,()=>this.setOpen(!1))}onTriggerPointerDown(){this.calendarPopover.suppressDismiss()}onTriggerClick(){this.disabled||this.readOnly||this.setOpen(!this.open)}onPopoverMouseDown(e){e.preventDefault()}onCalendarChange(e){let n=e.target;if(!(n instanceof HTMLElement)||!n.matches("[data-date-field-calendar]"))return;let r=e.detail;r?.value&&(this.commitValue(r.value),this.setOpen(!1))}onRootKeydown(e){e.key==="Escape"&&this.open&&(e.preventDefault(),this.setOpen(!1))}static{gt()}};import{Fragment as Ii,jsx as B,jsxs as yr}from"@ecopages/jsx/jsx-runtime";function Ut(t,e){return e===void 0||t?.label!==void 0?t:{...t,label:e}}function q(...t){return t.filter(Boolean).join(" ")}import{jsx as Ie,jsxs as qr}from"@ecopages/jsx/jsx-runtime";function Ce({class:t,size:e="sm",...n}){return qr("svg",{...n,class:q("rui-icon",e==="md"&&"rui-icon--md",t),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:[Ie("path",{d:"M8 2v4"}),Ie("path",{d:"M16 2v4"}),Ie("rect",{width:"18",height:"18",x:"3",y:"4",rx:"2"}),Ie("path",{d:"M3 10h18"})]})}import{jsx as Y,jsxs as tt}from"@ecopages/jsx/jsx-runtime";import{RadiantElement as $n,customElement as hi,event as fi,onEvent as pe,onUpdated as pi,prop as ue,registerSsrPreparationCallback as mi,state as ce}from"@ecopages/radiant";function Re(t){if(!t)return;let e=t.split(",").map(n=>n.trim()).filter(Boolean);return e.length>1?e:e[0]}function de(t){if(t==null)return null;let e=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t.trim());if(!e)return null;let n=Number(e[1]),r=Number(e[2])-1,i=Number(e[3]),a=new Date(n,r,i);return a.getFullYear()!==n||a.getMonth()!==r||a.getDate()!==i?null:a}function K(t){let e=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${e}-${n}-${r}`}function _e(t,e,n){return!(e&&t<e||n&&t>n)}function he(t,e){return t.localeCompare(e)}function me(t,e){return he(t,e)<=0?{start:t,end:e}:{start:e,end:t}}function ge(t){if(!t)return null;let[e,n]=t.split("/");return!e||!n?null:me(e,n)}function Ve(t){if(!t)return"";let e=me(t.start,t.end);return`${e.start}/${e.end}`}function ye(t){return t?t.split(",").map(e=>e.trim()).filter(Boolean).sort(he):[]}function Oe(t){return[...new Set(t)].sort(he).join(",")}function je(t,e){let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),[...n].sort(he)}function qt(t,e){let n=me(e.start,e.end);return he(t,n.start)>=0&&he(t,n.end)<=0}function Ye(t,e,n){if(e==="single"){let y=n.singleIso===t;return{isSelected:y,isRangeStart:y,isRangeEnd:y,isRangeMiddle:!1}}if(e==="multiple"){let y=n.multipleIsos?.includes(t)??!1;return{isSelected:y,isRangeStart:y,isRangeEnd:y,isRangeMiddle:!1}}let r=n.range;if(!r)return{isSelected:!1,isRangeStart:!1,isRangeEnd:!1,isRangeMiddle:!1};let i=me(r.start,r.end),a=qt(t,i),s=t===i.start,o=t===i.end;return{isSelected:a,isRangeStart:s,isRangeEnd:o,isRangeMiddle:a&&!s&&!o}}function Be(t,e,n){return e.anchor?{committed:me(e.anchor,n),draft:{anchor:null,hover:null}}:{committed:t,draft:{anchor:n,hover:n}}}function Fe(t){let e=Kr(t);try{let r=new Intl.Locale(e).weekInfo;if(r?.firstDay!=null)return r.firstDay===7?0:r.firstDay}catch{}return e.startsWith("en-US")?0:1}function Kr(t){return Array.isArray(t)?t[0]??navigator.language:t??navigator.language}function Nr(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate())}function Xr(t,e){return t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}function Jr(t){let e=t.selectionMode??"single",n=t.value??"";if(e==="multiple")return{mode:e,multipleIsos:ye(n)};if(e==="range"){let r=ge(n);if(t.rangeDraft?.anchor){let i=t.rangeDraft.hover??t.rangeDraft.anchor;return{mode:e,range:Zr(t.rangeDraft.anchor,i)}}return{mode:e,range:r}}return{mode:e,singleIso:n||void 0}}function Zr(t,e){return t.localeCompare(e)<=0?{start:t,end:e}:{start:e,end:t}}function $e(t,e,n){let r=Fe(n.locale),i=Nr(n.today??new Date),a=Jr(n),o=(new Date(t,e,1).getDay()-r+7)%7,f=new Date(t,e,1-o),y=[],x=new Date(f);for(let R=0;R<6;R+=1){let M=[];for(let O=0;O<7;O+=1){let j=K(x),A=Ye(j,a.mode,{singleIso:a.singleIso,multipleIsos:a.multipleIsos,range:a.range});M.push({date:new Date(x),iso:j,inMonth:x.getMonth()===e,isToday:Xr(x,i),isSelected:A.isSelected,isDisabled:!_e(j,n.min,n.max),isRangeStart:A.isRangeStart,isRangeEnd:A.isRangeEnd,isRangeMiddle:A.isRangeMiddle}),x.setDate(x.getDate()+1)}if(y.push(M),R>=4&&x.getMonth()!==e&&x.getDate()>7)break}return y}function Pe(t,e,n){let r=new Date(t,e+n,1);return{year:r.getFullYear(),month:r.getMonth()}}function Ge(t,e,n){let r=Math.max(1,Math.min(n,12));return Array.from({length:r},(i,a)=>{let s=Pe(t,e,a);return{year:s.year,month:s.month,offset:a}})}var Kt=new Map;function Qr(t,e){return`${JSON.stringify(t??null)}|${JSON.stringify(e)}`}function fe(t,e){let n=Qr(t,e),r=Kt.get(n);if(r)return r;let i=new Intl.DateTimeFormat(t,e);return Kt.set(n,i),i}function We(t,e){return fe(e,{month:"long",year:"numeric"}).format(t)}function ze(t,e){let n=fe(t,{weekday:"narrow"}),r=[];for(let i=0;i<7;i+=1){let a=(e+i)%7,s=new Date(2024,0,a===0?7:a);r.push(n.format(s))}return r}function He(t){return new Intl.RelativeTimeFormat(t,{numeric:"auto"}).format(0,"day")}var ei=new Date(2e3,0,1);function ti(t,e){return t==="year"?e==="year":t==="month"?e==="year"||e==="month":!0}function ni(t,e){let r=fe(e,{[t]:t==="year"?"numeric":"2-digit"}).formatToParts(ei).find(i=>i.type===t);return r?r.value.replace(/\d/g,t==="year"?"y":t==="month"?"m":"d"):t==="year"?"yyyy":"mm"}function ri(t,e,n){let r=t==="year"?{year:"numeric"}:{[t]:"2-digit"};return fe(n,r).formatToParts(e).find(i=>i.type===t)?.value??""}function Ee(t,e,n={}){let r=n.granularity??"day",i=t??n.placeholderDate??new Date;return fe(e,{year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(i).filter(s=>s.type!=="era").map(s=>{if(s.type==="literal")return{type:"literal",value:s.value,placeholder:s.value,isPlaceholder:!1,editable:!1};let o=s.type;if(!ti(r,o))return null;let f=t!=null;return{type:o,value:f?ri(o,t,e):"",placeholder:ni(o,e),isPlaceholder:!f,editable:!0}}).filter(s=>s!=null)}function ii(t){if(t.isPlaceholder||t.value==="")return null;let e=Number(t.value);return Number.isFinite(e)?e:null}function ai(t){return t>=100?t:t>=69?1900+t:2e3+t}function Nt(t){let e={};for(let r of t){if(!r.editable)continue;let i=ii(r);if(i==null)return null;e[r.type]=r.type==="year"?ai(i):i}if(e.year==null||e.month==null||e.day==null)return null;let n=new Date(e.year,e.month-1,e.day);return n.getFullYear()!==e.year||n.getMonth()!==e.month-1||n.getDate()!==e.day?null:n}function Xt(t){return t.every(e=>!e.editable||e.isPlaceholder||e.value==="")}function Ue(t,e={}){let n=t.find(a=>a.editable&&a.type==="year");if(n&&!n.isPlaceholder&&n.value!==""&&n.value.replace(/\D/g,"").length<4)return{kind:"partial-year"};if(Xt(t))return{kind:"empty"};let r=Nt(t);if(!r)return{kind:"incomplete"};let i=K(r);return _e(i,e.min,e.max)?{kind:"date",iso:i}:{kind:"out-of-range"}}function qe(t){return t==="year"?4:2}function oi(t,e){return t.findIndex(n=>n.editable&&n.type===e)}function si(t){return t.map(e=>({...e}))}function Ne(t,e,n){let r=si(t),i=oi(r,e);return i<0||(r[i]={...r[i],...n}),r}function Ke(t){if(t==="")return null;let e=Number(t);return Number.isFinite(e)?e:null}function Ae(t,e){return{min:1,max:Zt(t,e)}}function Zt(t,e){if(t==="month")return 12;if(t==="day"){let n=Jt(e,"year"),r=Jt(e,"month");return n!=null&&r!=null?new Date(n,r,0).getDate():31}return 9999}function Jt(t,e){let n=t.find(r=>r.editable&&r.type===e);return!n||n.isPlaceholder||n.value===""?null:Number(n.value)}function Qt(t,e){return t==="year"?String(e).padStart(4,"0"):String(e).padStart(2,"0")}function Xe(t,e){try{let r=new Intl.DisplayNames(e,{type:"dateTimeField"}).of(t);if(r)return r}catch{}return t==="month"?"Month":t==="day"?"Day":"Year"}function we(t){return t.isPlaceholder||t.value===""?t.placeholder:t.value}function Te(t){return t.isPlaceholder||t.value===""?null:Ke(t.value.replace(/\D/g,""))}function en(t,e){return Ne(t,e,{value:"",isPlaceholder:!0})}function tn(t,e,n){return Ne(t,e,{value:Qt(e,n),isPlaceholder:!1})}function Je(t,e,n){let r=t.find(f=>f.editable&&f.type===e);if(!r)return t;let{min:i,max:a}=Ae(e,t),o=(Te(r)??(n>0?i-1:a+1))+n;return e==="month"||e==="day"?o<i?o=a:o>a&&(o=i):o=Math.max(i,o),tn(t,e,o)}function Ze(t,e,n,r){let i=n.replace(/\D/g,"");if(!i)return{segments:t,enteredKeys:r,focusNext:!1};let a=r+i,s=Ke(a);if(s==null)return{segments:t,enteredKeys:r,focusNext:!1};let o=Zt(e,t),f=s;f>o&&(f=Ke(i)??f);let y=qe(e),x=+`${f}0`>o||a.length>=y||String(f).length>=y,R=x?Qt(e,f):String(f);return{segments:Ne(t,e,{value:R,isPlaceholder:!1}),enteredKeys:x?"":a,focusNext:x}}function nn(t){return t.filter(e=>e.editable).map(e=>e.type)}function ve(t,e,n){let r=nn(t),i=r.indexOf(e);if(i<0)return r[0]??null;let a=i+n;return a<0||a>=r.length?null:r[a]??null}function Qe(t){let e=null;for(let n of t){if(!n.editable)continue;let r=n.type;if(e||(e=r),n.isPlaceholder||n.value==="")return r}return e}function et(t,e){let n=t.find(a=>a.editable&&a.type===e);if(!n)return{kind:"focus-previous"};if(n.isPlaceholder||n.value==="")return{kind:"focus-previous"};let r=n.value.replace(/\D/g,"");if(r.length<=1)return{kind:"updated",segments:en(t,e),enteredKeys:""};let i=r.slice(0,-1);return{kind:"updated",segments:t.map(a=>a.editable&&a.type===e?{...a,value:i,isPlaceholder:!1}:a),enteredKeys:i}}var rn,an,on,sn,ln,un,cn,dn,hn,fn,pn,mn,gn,yn,vn,bn,xn,_n,wn,Dn,Sn,Mn,In,Rn,Fn,Pn,En,An,Tn,kn,Ln,Cn,Vn,On,jn,Yn;function li(t,e,n,r,i,a){var s,o,f,y,x,R,M,O=Symbol.metadata||Symbol.for("Symbol.metadata"),j=Object.defineProperty,A=Object.create,N=[A(null),A(null)],X=e.length;function T(l,v,m){return function(u,c){v&&(c=u,u=t);for(var b=0;b<l.length;b++)c=l[b].apply(u,m?[c]:[]);return m?c:u}}function D(l,v,m,u){if(typeof l!="function"&&(u||l!==void 0))throw new TypeError(v+" must "+(m||"be")+" a function"+(u?"":" or undefined"));return l}function J(l,v,m,u,c,b,I,g,_,w,Q){function $(h){if(!Q(h))throw new TypeError("Attempted to access private element on non-instance")}var G=[].concat(v[0]),ee=v[3],W=!I,P=c===1,te=c===3,ne=c===4,k=c===2;function L(h,F,ae){return function(V,oe){return F&&(oe=V,V=l),ae&&ae(V),d[h].call(V,oe)}}if(!W){var d={},z=[],S=te?"get":ne||P?"set":"value";if(_?(w||P?d={get:Bn(function(){return ee(this)},u,"get"),set:function(h){v[4](this,h)}}:d[S]=ee,w||Bn(d[S],u,k?"":S)):w||(d=Object.getOwnPropertyDescriptor(l,u)),!w&&!_){if((o=N[+g][u])&&(o^c)!==7)throw Error("Decorating two elements with the same name ("+d[S].name+") is not supported yet");N[+g][u]=c<3?1:c}}for(var p=l,C=G.length-1;C>=0;C-=m?2:1){var re=D(G[C],"A decorator","be",!0),ie=m?G[C-1]:void 0,H={},E={kind:["field","accessor","method","getter","setter","class"][c],name:u,metadata:s,addInitializer:function(h,F){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");D(F,"An initializer","be",!0),b.push(F)}.bind(null,H)};if(W)o=re.call(ie,p,E),H.v=1,D(o,"class decorators","return")&&(p=o);else if(E.static=g,E.private=_,o=E.access={has:_?Q.bind():function(h){return u in h}},ne||(o.get=_?k?function(h){return $(h),d.value}:L("get",0,$):function(h){return h[u]}),k||te||(o.set=_?L("set",0,$):function(h,F){h[u]=F}),p=re.call(ie,P?{get:d.get,set:d.set}:d[S],E),H.v=1,P){if(typeof p=="object"&&p)(o=D(p.get,"accessor.get"))&&(d.get=o),(o=D(p.set,"accessor.set"))&&(d.set=o),(o=D(p.init,"accessor.init"))&&z.unshift(o);else if(p!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else D(p,(w?"field":"method")+" decorators","return")&&(w?z.unshift(p):d[S]=p)}return c<2&&I.push(T(z,g,1),T(b,g,0)),w||W||(_?P?I.splice(-1,0,L("get",g),L("set",g)):I.push(k?d[S]:D.call.bind(d[S])):j(l,u,d)),p}function Z(l){return j(l,O,{configurable:!0,enumerable:!0,value:s})}return a!==void 0&&(s=a[O]),s=A(s??null),x=[],R=function(l){l&&x.push(T(l))},M=function(l,v){for(var m=0;m<n.length;m++){var u=n[m],c=u[1],b=7&c;if((8&c)==l&&!b==v){var I=u[2],g=!!u[3],_=16&c;J(l?t:t.prototype,u,_,g?"#"+I:ui(I),b,b<2?[]:l?y=y||[]:f=f||[],x,!!l,g,v,l&&g?function(w){return di(w)===t}:i)}}},M(8,0),M(0,0),M(8,1),M(0,1),R(f),R(y),o=x,X||Z(t),{e:o,get c(){var l=[];return X&&[Z(t=J(t,[e],r,t.name,5,l)),T(l,1)]}}}function ui(t){var e=ci(t,"string");return typeof e=="symbol"?e:e+""}function ci(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Bn(t,e,n){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(t,"name",{configurable:!0,value:n?n+" "+e:e})}catch{}return t}function di(t){if(Object(t)!==t)throw TypeError("right-hand side of 'in' should be an object, got "+(t!==null?typeof t:"null"));return t}var Wn,Gn=class extends $n{static{({e:[on,sn,ln,un,cn,dn,hn,fn,pn,mn,gn,yn,vn,bn,xn,_n,wn,Dn,Sn,Mn,In,Rn,Fn,Pn,En,An,Tn,kn,Ln,Cn,Vn,On,jn,Yn,rn],c:[Wn,an]}=li(this,[hi("rui-calendar")],[[ue({type:String,reflect:!0,defaultValue:""}),0,"value"],[ue({type:String,defaultValue:""}),0,"min"],[ue({type:String,defaultValue:""}),0,"max"],[ue({type:Boolean,reflect:!0,defaultValue:!1}),0,"disabled"],[ue({type:String,defaultValue:""}),0,"locale"],[ue({type:String,attribute:"selection-mode",defaultValue:"single"}),0,"selectionMode"],[ue({type:Number,attribute:"visible-months",defaultValue:1}),0,"visibleMonths"],[ue({type:String,attribute:"page-behavior",defaultValue:"visible"}),0,"pageBehavior"],[fi({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[ce,0,"viewYear"],[ce,0,"viewMonth"],[ce,0,"focusedIso"],[ce,0,"weekdayLabels"],[ce,0,"monthPanels"],[ce,0,"todayLabel"],[ce,0,"rangeAnchor"],[ce,0,"rangeHover"],[pi(["value","min","max","disabled","locale","selectionMode","visibleMonths","pageBehavior"]),2,"onPropsUpdated"],[pe({selector:"[data-calendar-prev-month]",type:"click"}),2,"onPrevMonth"],[pe({selector:"[data-calendar-next-month]",type:"click"}),2,"onNextMonth"],[pe({selector:"[data-calendar-today]",type:"click"}),2,"onTodayClick"],[pe({selector:"[data-calendar-day]",type:"click"}),2,"onDayClick"],[pe({selector:"[data-calendar-day]",type:"pointerenter"}),2,"onDayPointerEnter"],[pe({selector:"[data-calendar-grid]",type:"pointerleave"}),2,"onGridPointerLeave"],[pe({selector:"[data-calendar-day]",type:"keydown"}),2,"onDayKeydown"]],0,void 0,$n))}value=(rn(this),on(this));min=(sn(this),ln(this));max=(un(this),cn(this));disabled=(dn(this),hn(this));locale=(fn(this),pn(this));selectionMode=(mn(this),gn(this));visibleMonths=(yn(this),vn(this));pageBehavior=(bn(this),xn(this));changeEvent=(_n(this),wn(this));viewYear=(Dn(this),Sn(this,new Date().getFullYear()));viewMonth=(Mn(this),In(this,new Date().getMonth()));focusedIso=(Rn(this),Fn(this,""));weekdayLabels=(Pn(this),En(this,[]));monthPanels=(An(this),Tn(this,[]));todayLabel=(kn(this),Ln(this,""));rangeAnchor=(Cn(this),Vn(this,null));rangeHover=(On(this),jn(this,null));get resolvedLocale(){return Re(this.locale)}get pageDelta(){return this.pageBehavior==="single"?1:Math.max(1,Math.min(this.visibleMonths,12))}get monthOptions(){return{locale:this.resolvedLocale,selectionMode:this.selectionMode,value:this.value??"",rangeDraft:{anchor:this.rangeAnchor,hover:this.rangeHover},min:this.min||void 0,max:this.max||void 0}}syncViewFromValue(){let e=this.selectionMode==="range"?ge(this.value)?.start??"":this.selectionMode==="multiple"?ye(this.value)[0]??"":this.value,n=de(e);if(n){this.viewYear=n.getFullYear(),this.viewMonth=n.getMonth(),this.focusedIso=e;return}let r=new Date;this.viewYear=r.getFullYear(),this.viewMonth=r.getMonth(),this.focusedIso=K(r)}refreshGrid(){this.weekdayLabels=ze(this.resolvedLocale,Fe(this.resolvedLocale)),this.monthPanels=Ge(this.viewYear,this.viewMonth,this.visibleMonths).map(e=>{let n=new Date(e.year,e.month,1);return{year:e.year,month:e.month,label:We(n,this.resolvedLocale),weeks:$e(e.year,e.month,this.monthOptions)}}),this.todayLabel=He(this.resolvedLocale)}moveMonth(e){let n=Pe(this.viewYear,this.viewMonth,e);this.viewYear=n.year,this.viewMonth=n.month,this.refreshGrid()}getFlatDays(){return this.monthPanels.flatMap(e=>e.weeks.flat())}moveFocusedDay(e){let n=this.getFlatDays().filter(s=>!s.isDisabled);if(!n.length)return;let r=n.findIndex(s=>s.iso===this.focusedIso),i=r<0?Math.max(0,n.findIndex(s=>s.inMonth)):(r+e+n.length)%n.length,a=n[i];if(a){if(!this.isMonthVisible(a.date)){this.viewYear=a.date.getFullYear(),this.viewMonth=a.date.getMonth(),this.focusedIso=a.iso,this.refreshGrid(),this.focusFocusedDay();return}this.focusedIso=a.iso,this.focusDayInCurrentGrid(a.iso)}}isMonthVisible(e){let n=this.viewYear*12+this.viewMonth,r=n+this.visibleMonths-1,i=e.getFullYear()*12+e.getMonth();return i>=n&&i<=r}focusDayInCurrentGrid(e){let n=this.querySelector('[data-calendar-day][tabindex="0"]'),r=Array.from(this.querySelectorAll(`[data-calendar-day][data-iso="${e}"]:not(:disabled)`)),i=r.find(a=>!a.hasAttribute("data-outside"))??r[0];i&&(n&&n!==i&&(n.tabIndex=-1),i.tabIndex=0,i.focus())}focusFocusedDay(){requestAnimationFrame(()=>{this.focusDayInCurrentGrid(this.focusedIso)})}moveFocusedMonth(e){let n=de(this.focusedIso)??new Date(this.viewYear,this.viewMonth,1),r=new Date(n.getFullYear(),n.getMonth()+e,1),i=new Date(r.getFullYear(),r.getMonth()+1,0).getDate(),a=new Date(r.getFullYear(),r.getMonth(),Math.min(n.getDate(),i));this.viewYear=a.getFullYear(),this.viewMonth=a.getMonth(),this.focusedIso=K(a),this.refreshGrid(),this.focusFocusedDay()}isIsoAllowed(e){return!(this.min&&e<this.min||this.max&&e>this.max)}emitChange(e,n={}){this.changeEvent.emit({value:e,...n})}selectSingle(e){!this.isIsoAllowed(e)||e===this.value||(this.value=e,this.emitChange(e),this.refreshGrid())}selectMultiple(e){if(!this.isIsoAllowed(e))return;let n=Oe(je(ye(this.value),e));n!==this.value&&(this.value=n,this.emitChange(n),this.refreshGrid())}selectRange(e){if(!this.isIsoAllowed(e))return;let n=Be(ge(this.value),{anchor:this.rangeAnchor,hover:this.rangeHover},e);if(this.rangeAnchor=n.draft.anchor,this.rangeHover=n.draft.hover,n.committed){let r=Ve(n.committed);r!==this.value&&(this.value=r,this.emitChange(r,{start:n.committed.start,end:n.committed.end}))}this.refreshGrid()}selectIso(e){if(this.selectionMode==="multiple"){this.selectMultiple(e);return}if(this.selectionMode==="range"){this.selectRange(e);return}this.selectSingle(e)}previewRange(e){this.selectionMode!=="range"||!this.rangeAnchor||this.disabled||this.rangeHover!==e&&(this.rangeHover=e,this.refreshGrid())}clearRangePreview(){this.rangeHover&&(this.rangeHover=this.rangeAnchor,this.refreshGrid())}initialize(){this.syncViewFromValue(),this.refreshGrid()}constructor(){super(),Yn(this),mi(this,()=>this.initialize())}onConnected(){this.initialize()}onPropsUpdated(){this.selectionMode!=="range"&&(this.rangeAnchor=null,this.rangeHover=null),this.syncViewFromValue(),this.refreshGrid()}onPrevMonth(e){e.preventDefault(),this.moveMonth(-this.pageDelta)}onNextMonth(e){e.preventDefault(),this.moveMonth(this.pageDelta)}onTodayClick(e){e.preventDefault(),this.selectIso(K(new Date))}onDayClick(e){let n=e.target.closest("[data-calendar-day]"),r=n?.getAttribute("data-iso");!r||n?.disabled||this.disabled||this.selectIso(r)}onDayPointerEnter(e){let n=e.target.closest("[data-calendar-day]"),r=n?.getAttribute("data-iso");!r||n?.disabled||this.previewRange(r)}onGridPointerLeave(){this.clearRangePreview()}onDayKeydown(e){if(this.disabled)return;let n=e.target.getAttribute("data-iso");if(n&&(this.focusedIso=n),e.key==="ArrowLeft"){e.preventDefault(),this.moveFocusedDay(-1);return}if(e.key==="ArrowRight"){e.preventDefault(),this.moveFocusedDay(1);return}if(e.key==="ArrowUp"){e.preventDefault(),this.moveFocusedDay(-7);return}if(e.key==="ArrowDown"){e.preventDefault(),this.moveFocusedDay(7);return}if(e.key==="PageUp"){e.preventDefault(),this.moveFocusedMonth(e.shiftKey?-12:-this.pageDelta);return}if(e.key==="PageDown"){e.preventDefault(),this.moveFocusedMonth(e.shiftKey?12:this.pageDelta);return}if(e.key==="Enter"||e.key===" "){e.preventDefault();let r=e.target,i=r.getAttribute("data-iso");i&&!r.disabled&&this.selectIso(i)}}dayDataAttributes(e){return{"data-range-start":e.isRangeStart?"true":void 0,"data-range-end":e.isRangeEnd?"true":void 0,"data-range-middle":e.isRangeMiddle?"true":void 0}}render(){let e=this.monthPanels.length,n=e>1;return tt("div",{class:`rui-calendar${n?" rui-calendar--multi":""}`,"data-ref":"root",role:"application","aria-label":"Calendar","aria-multiselectable":this.selectionMode==="multiple"?"true":void 0,children:[Y("div",{class:"rui-calendar__months",children:this.monthPanels.map((r,i)=>tt("div",{class:"rui-calendar__month-panel","data-calendar-month-panel":!0,children:[tt("div",{class:"rui-calendar__header",children:[i===0?Y("button",{type:"button",class:"rui-calendar__nav","data-calendar-prev-month":!0,"aria-label":"Previous month",disabled:this.disabled,children:"\u2039"}):Y("span",{class:"rui-calendar__nav-spacer","aria-hidden":"true"}),Y("div",{class:"rui-calendar__month","aria-live":"polite",children:r.label}),i===e-1?Y("button",{type:"button",class:"rui-calendar__nav","data-calendar-next-month":!0,"aria-label":"Next month",disabled:this.disabled,children:"\u203A"}):Y("span",{class:"rui-calendar__nav-spacer","aria-hidden":"true"})]}),i===0?Y("div",{class:"rui-calendar__weekdays",role:"row",children:this.weekdayLabels.map(a=>Y("div",{class:"rui-calendar__weekday",role:"columnheader","aria-hidden":"true",children:a}))}):null,Y("div",{class:"rui-calendar__grid",role:"grid","data-calendar-grid":!0,children:r.weeks.map(a=>Y("div",{class:"rui-calendar__week",role:"row",children:a.map(s=>Y("button",{type:"button",class:"rui-calendar__day","data-calendar-day":!0,"data-iso":s.iso,role:"gridcell",disabled:this.disabled||s.isDisabled,tabIndex:s.iso===this.focusedIso?0:-1,"aria-selected":s.isSelected?"true":"false","aria-current":s.isToday?"date":void 0,"data-outside":s.inMonth?void 0:"true",...this.dayDataAttributes(s),children:s.date.getDate()}))}))})]}))}),Y("div",{class:"rui-calendar__footer",children:Y("button",{type:"button",class:"rui-calendar__today","data-calendar-today":!0,disabled:this.disabled,children:this.todayLabel})})]})}static{an()}};import{jsx as gi}from"@ecopages/jsx/jsx-runtime";function nt({children:t,...e}){return gi("rui-calendar",{...e,children:t})}import{jsx as ke}from"@ecopages/jsx/jsx-runtime";import{customElement as _i,event as wi,onEvent as be,onUpdated as hr,prop as xe,registerSsrPreparationCallback as Di,state as fr}from"@ecopages/radiant";import{FormAssociatedElement as pr}from"@ecopages/radiant/form-associated-element";function zn(t,e){let n=t.type,r=Te(t),i=!e.useTextboxRole,a=i?"spinbutton":"textbox",s=!e.disabled&&!e.readOnly,o=Ae(n,e.segments);return{ariaLabel:Xe(n,e.locale),ariaReadonly:e.readOnly||void 0,ariaRole:a,ariaValuemax:i?o.max:void 0,ariaValuemin:i?o.min:void 0,ariaValuenow:i&&r!=null?r:void 0,ariaValuetext:i?we(t):void 0,className:q("rui-date-input__segment",t.isPlaceholder&&"rui-date-input__segment--placeholder"),contenteditable:s?"true":void 0,inputmode:s?"numeric":void 0,suppresscontenteditablewarning:s?"true":void 0,tabindex:e.disabled?void 0:0}}var Hn,Un,qn,Kn,Nn,Xn,Jn,Zn,Qn,er,tr,nr,rr,ir,ar,or,sr,lr,ur,cr;function yi(t,e,n,r,i,a){var s,o,f,y,x,R,M,O=Symbol.metadata||Symbol.for("Symbol.metadata"),j=Object.defineProperty,A=Object.create,N=[A(null),A(null)],X=e.length;function T(l,v,m){return function(u,c){v&&(c=u,u=t);for(var b=0;b<l.length;b++)c=l[b].apply(u,m?[c]:[]);return m?c:u}}function D(l,v,m,u){if(typeof l!="function"&&(u||l!==void 0))throw new TypeError(v+" must "+(m||"be")+" a function"+(u?"":" or undefined"));return l}function J(l,v,m,u,c,b,I,g,_,w,Q){function $(h){if(!Q(h))throw new TypeError("Attempted to access private element on non-instance")}var G=[].concat(v[0]),ee=v[3],W=!I,P=c===1,te=c===3,ne=c===4,k=c===2;function L(h,F,ae){return function(V,oe){return F&&(oe=V,V=l),ae&&ae(V),d[h].call(V,oe)}}if(!W){var d={},z=[],S=te?"get":ne||P?"set":"value";if(_?(w||P?d={get:dr(function(){return ee(this)},u,"get"),set:function(h){v[4](this,h)}}:d[S]=ee,w||dr(d[S],u,k?"":S)):w||(d=Object.getOwnPropertyDescriptor(l,u)),!w&&!_){if((o=N[+g][u])&&(o^c)!==7)throw Error("Decorating two elements with the same name ("+d[S].name+") is not supported yet");N[+g][u]=c<3?1:c}}for(var p=l,C=G.length-1;C>=0;C-=m?2:1){var re=D(G[C],"A decorator","be",!0),ie=m?G[C-1]:void 0,H={},E={kind:["field","accessor","method","getter","setter","class"][c],name:u,metadata:s,addInitializer:function(h,F){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");D(F,"An initializer","be",!0),b.push(F)}.bind(null,H)};if(W)o=re.call(ie,p,E),H.v=1,D(o,"class decorators","return")&&(p=o);else if(E.static=g,E.private=_,o=E.access={has:_?Q.bind():function(h){return u in h}},ne||(o.get=_?k?function(h){return $(h),d.value}:L("get",0,$):function(h){return h[u]}),k||te||(o.set=_?L("set",0,$):function(h,F){h[u]=F}),p=re.call(ie,P?{get:d.get,set:d.set}:d[S],E),H.v=1,P){if(typeof p=="object"&&p)(o=D(p.get,"accessor.get"))&&(d.get=o),(o=D(p.set,"accessor.set"))&&(d.set=o),(o=D(p.init,"accessor.init"))&&z.unshift(o);else if(p!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else D(p,(w?"field":"method")+" decorators","return")&&(w?z.unshift(p):d[S]=p)}return c<2&&I.push(T(z,g,1),T(b,g,0)),w||W||(_?P?I.splice(-1,0,L("get",g),L("set",g)):I.push(k?d[S]:D.call.bind(d[S])):j(l,u,d)),p}function Z(l){return j(l,O,{configurable:!0,enumerable:!0,value:s})}return a!==void 0&&(s=a[O]),s=A(s??null),x=[],R=function(l){l&&x.push(T(l))},M=function(l,v){for(var m=0;m<n.length;m++){var u=n[m],c=u[1],b=7&c;if((8&c)==l&&!b==v){var I=u[2],g=!!u[3],_=16&c;J(l?t:t.prototype,u,_,g?"#"+I:vi(I),b,b<2?[]:l?y=y||[]:f=f||[],x,!!l,g,v,l&&g?function(w){return xi(w)===t}:i)}}},M(8,0),M(0,0),M(8,1),M(0,1),R(f),R(y),o=x,X||Z(t),{e:o,get c(){var l=[];return X&&[Z(t=J(t,[e],r,t.name,5,l)),T(l,1)]}}}function vi(t){var e=bi(t,"string");return typeof e=="symbol"?e:e+""}function bi(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function dr(t,e,n){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(t,"name",{configurable:!0,value:n?n+" "+e:e})}catch{}return t}function xi(t){if(Object(t)!==t)throw TypeError("right-hand side of 'in' should be an object, got "+(t!==null?typeof t:"null"));return t}function Si(){return typeof navigator>"u"?!1:/iPad|iPhone|iPod/.test(navigator.userAgent)}var gr,mr=class extends pr{static{({e:[qn,Kn,Nn,Xn,Jn,Zn,Qn,er,tr,nr,rr,ir,ar,or,sr,lr,ur,cr,Hn],c:[gr,Un]}=yi(this,[_i("rui-date-input")],[[xe({type:String,reflect:!0,defaultValue:""}),0,"value"],[xe({type:String,defaultValue:""}),0,"min"],[xe({type:String,defaultValue:""}),0,"max"],[xe({type:Boolean,attribute:"read-only",reflect:!0,defaultValue:!1}),0,"readOnly"],[xe({type:String,defaultValue:""}),0,"label"],[xe({type:String,defaultValue:""}),0,"locale"],[wi({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[fr,0,"segments"],[fr,0,"focusedPart"],[hr(["value","locale"]),2,"syncSegmentsFromValue"],[hr("label"),2,"syncGroupLabel"],[be({selector:'[data-ref="root"]',type:"focusin"}),2,"onGroupFocusIn"],[be({selector:"[data-date-segment]",type:"focusin"}),2,"onSegmentFocusIn"],[be({selector:"[data-date-segment]",type:"focusout"}),2,"onSegmentFocusOut"],[be({selector:"[data-date-segment]",type:"keydown"}),2,"onSegmentKeyDown"],[be({selector:"[data-date-segment]",type:"beforeinput"}),2,"onSegmentBeforeInput"],[be({selector:"[data-date-segment]",type:"pointerdown"}),2,"onSegmentPointerDown"]],0,void 0,pr))}value=(Hn(this),qn(this));min=(Kn(this),Nn(this));max=(Xn(this),Jn(this));readOnly=(Zn(this),Qn(this));label=(er(this),tr(this));locale=(nr(this),rr(this));changeEvent=(ir(this),ar(this));segments=(or(this),sr(this,[]));focusedPart=(lr(this),ur(this,null));uid=(cr(this),De("rui-date-input"));buffer="";useTextboxRole=Si();pendingFocus=null;get resolvedLocale(){return Re(this.locale)}get isoValue(){return this.value??""}syncSegmentsFromValue(){this.segments=Ee(de(this.isoValue),this.resolvedLocale),this.buffer=""}get displaySegments(){return this.segments.length>0?this.segments:Ee(de(this.isoValue),this.resolvedLocale)}constructor(){super(),Di(this,()=>this.syncSegmentsFromValue())}getSegmentElement(e){return this.querySelector(`[data-date-segment][data-type="${e}"]`)}setFocusedPart(e,n="leave"){let r=this.focusedPart;e===r&&n==="leave"||(this.buffer="",(r!=null||n==="blur")&&this.commit(n),this.focusedPart=e)}focusPart(e){this.setFocusedPart(e),this.pendingFocus=e}updated(e){super.updated(e),this.pendingFocus=null;let n=this.focusedPart;if(!n||!(e.has("focusedPart")||e.has("segments"))||!this.matches(":focus-within"))return;let r=this.getSegmentElement(n);r&&(document.activeElement!==r&&r.focus(),document.activeElement===r&&window.getSelection()?.collapse(r,0))}commit(e){if(e==="edit"&&this.buffer)return;let n=Ue(this.segments,{min:this.min,max:this.max});switch(n.kind){case"partial-year":e!=="edit"&&this.syncSegmentsFromValue();return;case"incomplete":e==="blur"&&this.syncSegmentsFromValue();return;case"out-of-range":this.syncSegmentsFromValue();return;case"empty":this.publish("");return;case"date":this.publish(n.iso)}}publish(e){if(e===this.isoValue){this.syncSegmentsFromValue();return}this.value=e,this.changeEvent.emit({value:e})}partFromTarget(e){if(!(e instanceof HTMLElement))return null;let r=e.closest("[data-date-segment]")?.getAttribute("data-type");return r==="month"||r==="day"||r==="year"?r:null}handleDigit(e,n){this.setFocusedPart(e);let r=Ze(this.segments,e,n,this.buffer);if(this.segments=r.segments,this.buffer=r.enteredKeys,r.focusNext){this.focusPart(ve(this.segments,e,1));return}this.commit("edit")}handleBackspace(e){this.setFocusedPart(e);let n=et(this.segments,e);if(n.kind==="focus-previous"){this.focusPart(ve(this.segments,e,-1));return}this.segments=n.segments,this.buffer=n.enteredKeys,this.commit("edit")}handleIncrement(e,n){this.setFocusedPart(e),this.buffer="",this.segments=Je(this.segments,e,n),this.commit("edit")}onConnected(){this.syncSegmentsFromValue(),this.syncGroupLabel()}formValue(){return this.name?this.isoValue:null}formState(){return this.value}restoreFormState(e){this.value=typeof e=="string"?e:"",this.syncSegmentsFromValue()}formResetCallback(){super.formResetCallback(),this.dispatchEvent(new Event("rui-form-reset",{bubbles:!0}))}syncGroupLabel(){let e=this.querySelector('[data-ref="root"]');if(!e)return;e.id||(e.id=`${this.uid}-group`);let n=this.label||this.getAttribute("aria-label")||"";n?e.setAttribute("aria-label",n):e.removeAttribute("aria-label")}onGroupFocusIn(e){this.partFromTarget(e.target)||this.focusPart(Qe(this.segments))}onSegmentFocusIn(e){let n=this.partFromTarget(e.target);n&&(this.pendingFocus&&this.pendingFocus!==n||this.setFocusedPart(n))}onSegmentFocusOut(){queueMicrotask(()=>{this.matches(":focus-within")||this.setFocusedPart(null,"blur")})}onSegmentKeyDown(e){let n=this.partFromTarget(e.target);if(!(!n||this.effectiveDisabled||this.readOnly)){if(e.key==="ArrowLeft"){e.preventDefault(),this.focusPart(ve(this.segments,n,-1));return}if(e.key==="ArrowRight"){e.preventDefault(),this.focusPart(ve(this.segments,n,1));return}if(e.key==="ArrowUp"){e.preventDefault(),this.handleIncrement(n,1);return}if(e.key==="ArrowDown"){e.preventDefault(),this.handleIncrement(n,-1);return}(e.key==="Backspace"||e.key==="Delete")&&(e.preventDefault(),e.stopPropagation(),this.handleBackspace(n))}}onSegmentBeforeInput(e){let n=this.partFromTarget(e.target);if(!(!n||this.effectiveDisabled||this.readOnly))switch(e.preventDefault(),e.inputType){case"deleteContentBackward":case"deleteContentForward":this.handleBackspace(n);break;default:e.data!=null&&this.handleDigit(n,e.data);break}}onSegmentPointerDown(e){e.stopPropagation()}renderSegment(e,n){if(!e.editable)return ke("span",{class:"rui-date-input__literal","data-type":"literal","aria-hidden":"true",children:e.value},`literal-${n}`);let r=e.type,i=this.focusedPart===r,a=zn(e,{disabled:this.effectiveDisabled,locale:this.resolvedLocale,readOnly:this.readOnly,segments:this.displaySegments,useTextboxRole:this.useTextboxRole});return ke("span",{class:a.className,"data-date-segment":!0,"data-type":r,"data-placeholder":e.isPlaceholder?"true":void 0,"data-focused":i?"true":void 0,role:a.ariaRole,"aria-label":a.ariaLabel,"aria-valuemin":a.ariaValuemin,"aria-valuemax":a.ariaValuemax,"aria-valuenow":a.ariaValuenow,"aria-valuetext":a.ariaValuetext,"aria-readonly":a.ariaReadonly,contenteditable:a.contenteditable,suppresscontenteditablewarning:a.suppresscontenteditablewarning,spellcheck:"false",inputmode:a.inputmode,tabindex:a.tabindex,children:we(e)},r)}render(){return ke("div",{class:"rui-date-input","data-ref":"root",role:"group",children:ke("div",{class:"rui-date-input__segments",children:this.displaySegments.map((e,n)=>this.renderSegment(e,n))})})}static{Un()}};import{jsx as Mi}from"@ecopages/jsx/jsx-runtime";function rt({children:t,...e}){return Mi("rui-date-input",{"data-rui-control":!0,"data-rui-control-type":"date","data-rui-aria-target":'[data-ref="root"]',...e,children:t})}function vr({children:t,class:e,...n}){return B("div",{...n,class:q("rui-date-field",e),children:B("div",{class:"rui-date-field__group","data-ref":"control",children:t})})}function br({class:t,...e}){return B(rt,{...e,"data-date-field-input":!0,class:q("rui-date-field__input",t)})}function xr({children:t,class:e,aria:n,...r}){return B("button",{...r,aria:Ut(n,"Open calendar"),type:"button","data-ref":"trigger","data-date-field-trigger":!0,class:q("rui-control-toggle",e),"aria-haspopup":"dialog",children:t??B(Ce,{})})}function _r({children:t,class:e,...n}){return B("div",{...n,"data-ref":"popover","data-date-field-popover":!0,class:q("rui-date-field__popover rui-popover rui-floating",e),hidden:!0,role:"dialog",children:t})}function wr(t){return B(nt,{...t,"data-date-field-calendar":!0})}function Ri(t){let{children:e,value:n,min:r,max:i,disabled:a,readOnly:s,label:o,name:f,locale:y}=t;return B("rui-date-field",{"data-rui-aria-target":'[data-date-field-input] [data-ref="root"]',...t,children:e??yr(Ii,{children:[yr(vr,{children:[B(br,{value:n,min:r,max:i,disabled:a,readOnly:s,label:o,name:f,locale:y}),B(xr,{})]}),B(_r,{children:B(wr,{})})]})})}export{Ri as RuiDateField,wr as RuiDateFieldCalendar,vr as RuiDateFieldControl,Ht as RuiDateFieldElement,br as RuiDateFieldInput,_r as RuiDateFieldPopover,xr as RuiDateFieldToggle};
2
2
  //# sourceMappingURL=index.js.map