@ecopages/radiant-ui 0.1.0-beta.7 → 0.1.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/components/ui/alert/alert.css +88 -50
- package/dist/components/ui/alert/alert.d.ts +43 -5
- package/dist/components/ui/alert/alert.script.d.ts +51 -4
- package/dist/components/ui/alert/index.d.ts +2 -2
- package/dist/components/ui/alert/index.js +1 -1
- package/dist/components/ui/alert/index.js.map +4 -4
- package/dist/components/ui/autocomplete/autocomplete.css +4 -4
- package/dist/components/ui/autocomplete/autocomplete.d.ts +15 -5
- package/dist/components/ui/autocomplete/autocomplete.script.d.ts +9 -0
- package/dist/components/ui/autocomplete/index.js +1 -1
- package/dist/components/ui/autocomplete/index.js.map +4 -4
- package/dist/components/ui/avatar/avatar.d.ts +15 -1
- package/dist/components/ui/avatar/index.js +1 -1
- package/dist/components/ui/avatar/index.js.map +4 -4
- package/dist/components/ui/breadcrumb/breadcrumb.d.ts +32 -6
- package/dist/components/ui/breadcrumb/index.js +1 -1
- package/dist/components/ui/breadcrumb/index.js.map +4 -4
- package/dist/{styles/components → components/ui/button}/button.css +45 -31
- package/dist/components/ui/button/button.d.ts +21 -4
- package/dist/components/ui/button-group/button-group.d.ts +7 -1
- package/dist/components/ui/button-group/index.js +1 -1
- package/dist/components/ui/button-group/index.js.map +4 -4
- package/dist/components/ui/calendar/calendar.css +7 -7
- package/dist/components/ui/calendar/calendar.d.ts +3 -2
- package/dist/components/ui/calendar/calendar.script.d.ts +39 -1
- package/dist/components/ui/calendar/index.js +1 -1
- package/dist/components/ui/calendar/index.js.map +4 -4
- package/dist/components/ui/carousel/carousel.d.ts +32 -6
- package/dist/components/ui/carousel/carousel.script.d.ts +44 -0
- package/dist/components/ui/carousel/index.js +1 -1
- package/dist/components/ui/carousel/index.js.map +4 -4
- package/dist/components/ui/checkbox/checkbox.css +1 -1
- package/dist/components/ui/checkbox/checkbox.d.ts +3 -2
- package/dist/components/ui/checkbox/checkbox.script.d.ts +4 -0
- package/dist/components/ui/checkbox/index.js +1 -1
- package/dist/components/ui/checkbox/index.js.map +4 -4
- package/dist/components/ui/chip/chip.d.ts +8 -0
- package/dist/components/ui/chip/index.js +1 -1
- package/dist/components/ui/chip/index.js.map +4 -4
- package/dist/components/ui/chip-list/chip-list.d.ts +10 -2
- package/dist/components/ui/chip-list/index.js +1 -1
- package/dist/components/ui/chip-list/index.js.map +4 -4
- package/dist/components/ui/combobox/combobox.css +39 -1
- package/dist/components/ui/combobox/combobox.d.ts +15 -5
- package/dist/components/ui/combobox/combobox.script.d.ts +13 -1
- package/dist/components/ui/combobox/index.js +1 -1
- package/dist/components/ui/combobox/index.js.map +4 -4
- package/dist/components/ui/cycle-toggle/cycle-toggle.css +15 -0
- package/dist/components/ui/cycle-toggle/cycle-toggle.d.ts +29 -0
- package/dist/components/ui/cycle-toggle/cycle-toggle.script.d.ts +61 -0
- package/dist/components/ui/cycle-toggle/index.d.ts +5 -0
- package/dist/components/ui/cycle-toggle/index.js +2 -0
- package/dist/components/ui/cycle-toggle/index.js.map +7 -0
- package/dist/components/ui/cycle-toggle/theme-preference-icons.d.ts +12 -0
- package/dist/components/ui/date-field/date-field.css +37 -0
- package/dist/components/ui/date-field/date-field.d.ts +22 -3
- package/dist/components/ui/date-field/date-field.script.d.ts +29 -5
- package/dist/components/ui/date-field/index.d.ts +1 -1
- package/dist/components/ui/date-field/index.js +1 -1
- package/dist/components/ui/date-field/index.js.map +4 -4
- package/dist/components/ui/date-range-picker/date-range-picker.css +37 -0
- package/dist/components/ui/date-range-picker/date-range-picker.d.ts +37 -4
- package/dist/components/ui/date-range-picker/date-range-picker.script.d.ts +31 -5
- package/dist/components/ui/date-range-picker/index.d.ts +1 -1
- package/dist/components/ui/date-range-picker/index.js +1 -1
- package/dist/components/ui/date-range-picker/index.js.map +4 -4
- package/dist/components/ui/dialog/dialog.css +1 -1
- package/dist/components/ui/dialog/dialog.d.ts +30 -5
- package/dist/components/ui/dialog/dialog.script.d.ts +3 -0
- package/dist/components/ui/dialog/index.js +1 -1
- package/dist/components/ui/dialog/index.js.map +4 -4
- package/dist/components/ui/disclosure/disclosure-group.css +1 -1
- package/dist/components/ui/disclosure/disclosure-group.script.d.ts +6 -0
- package/dist/components/ui/disclosure/disclosure.d.ts +26 -7
- package/dist/components/ui/disclosure/disclosure.script.d.ts +5 -0
- package/dist/components/ui/disclosure/index.js +1 -1
- package/dist/components/ui/disclosure/index.js.map +4 -4
- package/dist/components/ui/feed/feed.d.ts +37 -7
- package/dist/components/ui/feed/index.js +1 -1
- package/dist/components/ui/feed/index.js.map +4 -4
- package/dist/components/ui/field/field-description.d.ts +5 -1
- package/dist/components/ui/field/field-error.d.ts +5 -0
- package/dist/components/ui/field/field.d.ts +8 -1
- package/dist/components/ui/field/field.script.d.ts +35 -0
- package/dist/components/ui/field/index.js +1 -1
- package/dist/components/ui/field/index.js.map +4 -4
- package/dist/components/ui/form/control-protocol.d.ts +6 -0
- package/dist/components/ui/form/form.d.ts +2 -1
- package/dist/components/ui/form/form.script.d.ts +16 -1
- package/dist/components/ui/form/index.d.ts +1 -1
- package/dist/components/ui/form/index.js +1 -1
- package/dist/components/ui/form/index.js.map +4 -4
- package/dist/components/ui/grid/grid.d.ts +12 -2
- package/dist/components/ui/grid/grid.script.d.ts +14 -0
- package/dist/components/ui/grid/index.js +1 -1
- package/dist/components/ui/grid/index.js.map +4 -4
- package/dist/components/ui/heading/heading.d.ts +26 -4
- package/dist/components/ui/heading/index.js +1 -1
- package/dist/components/ui/heading/index.js.map +4 -4
- package/dist/components/ui/headline/headline.d.ts +9 -1
- package/dist/components/ui/headline/index.js +1 -1
- package/dist/components/ui/headline/index.js.map +4 -4
- package/dist/components/ui/input/index.d.ts +1 -1
- package/dist/components/ui/input/index.js +1 -1
- package/dist/components/ui/input/index.js.map +4 -4
- package/dist/components/ui/input/input.css +2 -7
- package/dist/components/ui/input/input.d.ts +7 -2
- package/dist/components/ui/label/index.js +1 -1
- package/dist/components/ui/label/index.js.map +4 -4
- package/dist/components/ui/label/label.d.ts +8 -1
- package/dist/components/ui/listbox/index.js +1 -1
- package/dist/components/ui/listbox/index.js.map +4 -4
- package/dist/components/ui/listbox/listbox.css +2 -5
- package/dist/components/ui/listbox/listbox.d.ts +7 -3
- package/dist/components/ui/listbox/listbox.script.d.ts +14 -1
- package/dist/components/ui/menu-button/index.d.ts +1 -1
- package/dist/components/ui/menu-button/index.js +1 -1
- package/dist/components/ui/menu-button/index.js.map +4 -4
- package/dist/components/ui/menu-button/menu-button.css +2 -2
- package/dist/components/ui/menu-button/menu-button.d.ts +27 -5
- package/dist/components/ui/menu-button/menu-button.script.d.ts +8 -3
- package/dist/components/ui/menubar/index.js +1 -1
- package/dist/components/ui/menubar/index.js.map +4 -4
- package/dist/components/ui/menubar/menubar.css +4 -4
- package/dist/components/ui/menubar/menubar.d.ts +14 -2
- package/dist/components/ui/menubar/menubar.script.d.ts +10 -1
- package/dist/components/ui/meter/index.js +1 -1
- package/dist/components/ui/meter/index.js.map +4 -4
- package/dist/components/ui/meter/meter.css +1 -1
- package/dist/components/ui/meter/meter.d.ts +7 -2
- package/dist/components/ui/meter/meter.script.d.ts +21 -0
- package/dist/components/ui/navigation-menu/index.js +1 -1
- package/dist/components/ui/navigation-menu/index.js.map +4 -4
- package/dist/components/ui/navigation-menu/navigation-menu.css +2 -2
- package/dist/components/ui/navigation-menu/navigation-menu.d.ts +3 -2
- package/dist/components/ui/navigation-menu/navigation-menu.script.d.ts +4 -0
- package/dist/components/ui/number-field/index.d.ts +1 -1
- package/dist/components/ui/number-field/index.js +1 -1
- package/dist/components/ui/number-field/index.js.map +4 -4
- package/dist/components/ui/number-field/number-field.css +18 -3
- package/dist/components/ui/number-field/number-field.d.ts +36 -8
- package/dist/components/ui/number-field/number-field.script.d.ts +28 -1
- package/dist/components/ui/popover/index.js +1 -1
- package/dist/components/ui/popover/index.js.map +4 -4
- package/dist/components/ui/popover/popover.d.ts +5 -4
- package/dist/components/ui/popover/popover.script.d.ts +4 -0
- package/dist/components/ui/radio-group/index.d.ts +1 -1
- package/dist/components/ui/radio-group/index.js +1 -1
- package/dist/components/ui/radio-group/index.js.map +4 -4
- package/dist/components/ui/radio-group/radio-group.d.ts +29 -4
- package/dist/components/ui/radio-group/radio-group.script.d.ts +14 -9
- package/dist/components/ui/select/index.js +1 -1
- package/dist/components/ui/select/index.js.map +4 -4
- package/dist/components/ui/select/select.css +48 -6
- package/dist/components/ui/select/select.d.ts +29 -8
- package/dist/components/ui/select/select.script.d.ts +7 -0
- package/dist/components/ui/sidebar/index.js +1 -1
- package/dist/components/ui/sidebar/index.js.map +4 -4
- package/dist/components/ui/sidebar/sidebar-trigger.script.d.ts +4 -0
- package/dist/components/ui/sidebar/sidebar.css +41 -24
- package/dist/components/ui/sidebar/sidebar.d.ts +68 -14
- package/dist/components/ui/sidebar/sidebar.docs.css +5 -2
- package/dist/components/ui/sidebar/sidebar.script.d.ts +9 -0
- package/dist/components/ui/slider/index.js +1 -1
- package/dist/components/ui/slider/index.js.map +4 -4
- package/dist/components/ui/slider/slider.d.ts +2 -1
- package/dist/components/ui/slider/slider.script.d.ts +29 -1
- package/dist/components/ui/switch/index.js +1 -1
- package/dist/components/ui/switch/index.js.map +4 -4
- package/dist/components/ui/switch/switch.css +3 -3
- package/dist/components/ui/switch/switch.d.ts +11 -2
- package/dist/components/ui/switch/switch.script.d.ts +5 -0
- package/dist/components/ui/tabs/index.js +1 -1
- package/dist/components/ui/tabs/index.js.map +4 -4
- package/dist/components/ui/tabs/tabs.css +9 -10
- package/dist/components/ui/tabs/tabs.d.ts +30 -9
- package/dist/components/ui/tag-group/index.js +1 -1
- package/dist/components/ui/tag-group/index.js.map +4 -4
- package/dist/components/ui/tag-group/tag-group.css +2 -11
- package/dist/components/ui/tag-group/tag-group.d.ts +18 -5
- package/dist/components/ui/tag-group/tag-group.script.d.ts +9 -2
- package/dist/components/ui/textarea/index.d.ts +1 -1
- package/dist/components/ui/textarea/index.js +1 -1
- package/dist/components/ui/textarea/index.js.map +4 -4
- package/dist/components/ui/textarea/textarea.d.ts +7 -2
- package/dist/components/ui/toast/index.d.ts +1 -1
- package/dist/components/ui/toast/index.js +1 -1
- package/dist/components/ui/toast/index.js.map +4 -4
- package/dist/components/ui/toast/stack-layout.d.ts +18 -0
- package/dist/components/ui/toast/toast-context.d.ts +10 -0
- package/dist/components/ui/toast/toast.css +30 -9
- package/dist/components/ui/toast/toast.d.ts +12 -2
- package/dist/components/ui/toast/toast.script.d.ts +60 -4
- package/dist/components/ui/toast/toaster.script.d.ts +71 -2
- package/dist/components/ui/toc/index.js +1 -1
- package/dist/components/ui/toc/index.js.map +4 -4
- package/dist/components/ui/toc/toc.css +3 -0
- package/dist/components/ui/toc/toc.d.ts +2 -1
- package/dist/components/ui/toc/toc.script.d.ts +15 -0
- package/dist/components/ui/toolbar/index.js +1 -1
- package/dist/components/ui/toolbar/index.js.map +4 -4
- package/dist/components/ui/toolbar/toolbar.d.ts +3 -2
- package/dist/components/ui/toolbar/toolbar.script.d.ts +8 -0
- package/dist/components/ui/tooltip/index.js +1 -1
- package/dist/components/ui/tooltip/index.js.map +4 -4
- package/dist/components/ui/tooltip/tooltip.d.ts +3 -2
- package/dist/components/ui/tooltip/tooltip.script.d.ts +3 -0
- package/dist/components/ui/tree/index.js +1 -1
- package/dist/components/ui/tree/index.js.map +4 -4
- package/dist/components/ui/tree/tree.d.ts +12 -2
- package/dist/components/ui/tree/tree.script.d.ts +18 -1
- package/dist/components/ui/treegrid/index.js +1 -1
- package/dist/components/ui/treegrid/index.js.map +4 -4
- package/dist/components/ui/treegrid/treegrid.d.ts +15 -2
- package/dist/components/ui/treegrid/treegrid.script.d.ts +22 -1
- package/dist/components/ui/window-splitter/index.js +1 -1
- package/dist/components/ui/window-splitter/index.js.map +4 -4
- package/dist/components/ui/window-splitter/window-splitter.css +1 -1
- package/dist/components/ui/window-splitter/window-splitter.d.ts +3 -2
- package/dist/components/ui/window-splitter/window-splitter.script.d.ts +22 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/lib/cycle-value.d.ts +8 -0
- package/dist/lib/intl-number/range.d.ts +8 -0
- package/dist/styles/radiant-ui-core.css +110 -341
- package/dist/styles/radiant-ui.css +413 -377
- package/dist/styles/styles.css +839 -2731
- package/dist/styles/tailwind.css +626 -530
- package/dist/styles/tokens/colors/aurora.css +2 -2
- package/dist/styles/tokens/colors/basalt.css +2 -1
- package/dist/styles/tokens/colors/glacier.css +2 -1
- package/dist/styles/tokens/presets/colors/aurora.css +42 -14
- package/dist/styles/tokens/presets/colors/basalt.css +28 -0
- package/dist/styles/tokens/presets/colors/ember.css +28 -0
- package/dist/styles/tokens/presets/colors/glacier.css +28 -0
- package/dist/styles/tokens/semantic.css +22 -2
- package/dist/styles/tokens/spacing/compact.css +12 -12
- package/package.json +21 -8
- package/dist/components/ui/dialog/dialog-registry.test.d.ts +0 -1
- package/dist/components/ui/field/field-ssr-hydration.test.d.ts +0 -1
- package/dist/components/ui/form/form-field.test.d.ts +0 -4
- package/dist/components/ui/form/form-store.test.d.ts +0 -1
- package/dist/components/ui/shared/collection-navigation.test.d.ts +0 -1
- package/dist/components/ui/shared/floating-position.test.d.ts +0 -1
- package/dist/components/ui/shared/listbox-popover-behavior.test.d.ts +0 -1
- package/dist/components/ui/shared/popover-controller.test.d.ts +0 -1
- package/dist/components/ui/shared/portal.test.d.ts +0 -1
- package/dist/components/ui/sidebar/sidebar.ssr.test.d.ts +0 -2
- package/dist/components/ui/sidebar/sidebar.test.d.ts +0 -1
- package/dist/components/ui/toast/toast.test.d.ts +0 -2
- package/dist/components/ui/toc/toc-helpers.test.d.ts +0 -1
- package/dist/components/ui/toc/toc.ssr.test.d.ts +0 -1
- package/dist/components/ui/toc/toc.test.d.ts +0 -1
- package/dist/lib/intl-date/parts.test.d.ts +0 -1
- package/dist/lib/intl-date/segments.test.d.ts +0 -1
- package/dist/lib/intl-date/selection.test.d.ts +0 -1
- package/dist/lib/mask/date-mask.test.d.ts +0 -1
- package/dist/lib/mask/input-mask.test.d.ts +0 -1
- package/dist/lib/radiant-view.d.ts +0 -43
- package/dist/lib/text-filter.test.d.ts +0 -1
- package/dist/styles/tokens/presets/radius.css +0 -45
- package/dist/styles/tokens/presets/spacing.css +0 -57
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{RadiantElement as Te,customElement as ze,event as Ae,onEvent as qe,onUpdated as De,prop as j}from"@ecopages/radiant";function G(e,t){if(e.length===0)throw new RangeError("cycleValue requires at least one value");let n=t===void 0?-1:e.indexOf(t);return n===-1?e[0]:e[(n+1)%e.length]}var ue,de,he,fe,me,ge,be,pe,ye,ve,_e,xe,we,Ee;function Be(e,t,n,o,f,w){var d,a,z,A,V,q,T,Z=Symbol.metadata||Symbol.for("Symbol.metadata"),H=Object.defineProperty,D=Object.create,F=[D(null),D(null)],N=t.length;function k(i,b,m){return function(r,l){b&&(l=r,r=e);for(var p=0;p<i.length;p++)l=i[p].apply(r,m?[l]:[]);return m?l:r}}function _(i,b,m,r){if(typeof i!="function"&&(r||i!==void 0))throw new TypeError(b+" must "+(m||"be")+" a function"+(r?"":" or undefined"));return i}function ee(i,b,m,r,l,p,E,g,y,v,ne){function $(u){if(!ne(u))throw new TypeError("Attempted to access private element on non-instance")}var U=[].concat(b[0]),ie=b[3],P=!E,C=l===1,re=l===3,oe=l===4,R=l===2;function B(u,I,se){return function(O,ce){return I&&(ce=O,O=i),se&&se(O),s[u].call(O,ce)}}if(!P){var s={},K=[],x=re?"get":oe||C?"set":"value";if(y?(v||C?s={get:Ie(function(){return ie(this)},r,"get"),set:function(u){b[4](this,u)}}:s[x]=ie,v||Ie(s[x],r,R?"":x)):v||(s=Object.getOwnPropertyDescriptor(i,r)),!v&&!y){if((a=F[+g][r])&&(a^l)!==7)throw Error("Decorating two elements with the same name ("+s[x].name+") is not supported yet");F[+g][r]=l<3?1:l}}for(var h=i,L=U.length-1;L>=0;L-=m?2:1){var le=_(U[L],"A decorator","be",!0),ae=m?U[L-1]:void 0,W={},S={kind:["field","accessor","method","getter","setter","class"][l],name:r,metadata:d,addInitializer:function(u,I){if(u.v)throw new TypeError("attempted to call addInitializer after decoration was finished");_(I,"An initializer","be",!0),p.push(I)}.bind(null,W)};if(P)a=le.call(ae,h,S),W.v=1,_(a,"class decorators","return")&&(h=a);else if(S.static=g,S.private=y,a=S.access={has:y?ne.bind():function(u){return r in u}},oe||(a.get=y?R?function(u){return $(u),s.value}:B("get",0,$):function(u){return u[r]}),R||re||(a.set=y?B("set",0,$):function(u,I){u[r]=I}),h=le.call(ae,C?{get:s.get,set:s.set}:s[x],S),W.v=1,C){if(typeof h=="object"&&h)(a=_(h.get,"accessor.get"))&&(s.get=a),(a=_(h.set,"accessor.set"))&&(s.set=a),(a=_(h.init,"accessor.init"))&&K.unshift(a);else if(h!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else _(h,(v?"field":"method")+" decorators","return")&&(v?K.unshift(h):s[x]=h)}return l<2&&E.push(k(K,g,1),k(p,g,0)),v||P||(y?C?E.splice(-1,0,B("get",g),B("set",g)):E.push(R?s[x]:_.call.bind(s[x])):H(i,r,s)),h}function te(i){return H(i,Z,{configurable:!0,enumerable:!0,value:d})}return w!==void 0&&(d=w[Z]),d=D(d??null),V=[],q=function(i){i&&V.push(k(i))},T=function(i,b){for(var m=0;m<n.length;m++){var r=n[m],l=r[1],p=7&l;if((8&l)==i&&!p==b){var E=r[2],g=!!r[3],y=16&l;ee(i?e:e.prototype,r,y,g?"#"+E:Le(E),p,p<2?[]:i?A=A||[]:z=z||[],V,!!i,g,b,i&&g?function(v){return Me(v)===e}:f)}}},T(8,0),T(0,0),T(8,1),T(0,1),q(z),q(A),a=V,N||te(e),{e:a,get c(){var i=[];return N&&[te(e=ee(e,[t],o,e.name,5,i)),k(i,1)]}}}function Le(e){var t=Oe(e,"string");return typeof t=="symbol"?t:t+""}function Oe(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var o=n.call(e,t||"default");if(typeof o!="object")return o;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 Me(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 $e="[data-cycle-value]",J="button[data-cycle-toggle-button]",Se,Ce=class extends Te{static{({e:[he,fe,me,ge,be,pe,ye,ve,_e,xe,we,Ee,ue],c:[Se,de]}=Be(this,[ze("rui-cycle-toggle")],[[j({type:String,reflect:!0,defaultValue:""}),0,"value"],[j({type:String,reflect:!0,defaultValue:"filled"}),0,"variant"],[j({type:String,reflect:!0,defaultValue:"md"}),0,"size"],[j({type:String,defaultValue:""}),0,"label"],[j({type:Boolean,reflect:!0,defaultValue:!1}),0,"disabled"],[Ae({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[De(["value","label","disabled","size","variant"]),2,"onPropsUpdated"],[qe({selector:J,type:"click"}),2,"onButtonClick"]],0,void 0,Te))}value=(ue(this),he(this));variant=(fe(this),me(this));size=(ge(this),be(this));label=(pe(this),ye(this));disabled=(ve(this),_e(this));changeEvent=(xe(this),we(this));childObserver=(Ee(this),null);connectedCallback(){super.connectedCallback(),this.childObserver=new MutationObserver(()=>this.resync()),this.childObserver.observe(this,{childList:!0,subtree:!0}),queueMicrotask(()=>this.resync())}disconnectedCallback(){this.childObserver?.disconnect(),this.childObserver=null,super.disconnectedCallback()}onPropsUpdated(){this.resync()}resync(){let t=this.syncSelection(this.value||this.getItemValue(this.getEnabledItems()[0])||"");this.syncButtonPresentation(),this.syncButtonLabel(t)}getItems(){return Array.from(this.querySelectorAll($e))}getEnabledItems(){return this.getItems().filter(t=>t.getAttribute("aria-disabled")!=="true")}getItemValue(t){return t?t.dataset.cycleValue??"":""}syncButtonLabel(t){let n=this.querySelector(J);if(!n)return;let o=t?.querySelector("[aria-label]")?.ariaLabel??t?.textContent?.trim();if(!this.label||!o){n.removeAttribute("aria-label");return}n.setAttribute("aria-label",`${this.label}: ${o}`)}syncButtonPresentation(){let t=this.querySelector(J);if(t){t.disabled=this.disabled;for(let n of Array.from(t.classList))n.startsWith("rui-button--")&&t.classList.remove(n);t.classList.add(`rui-button--${this.variant}`,`rui-button--${this.size}`)}}syncSelection(t){let n=this.getItems();if(!n.length)return;let o=this.getEnabledItems(),f=n.find(d=>this.getItemValue(d)===t&&o.includes(d))??o[0]??n[0],w=this.getItemValue(f);this.value=w;for(let d of n)d.hidden=d!==f;return f}cycle(){if(this.disabled)return;let n=this.getEnabledItems().map(f=>this.getItemValue(f)).filter(Boolean);if(!n.length)return;let o=G(n,this.value||void 0);o!==this.value&&(this.syncSelection(o),this.changeEvent.emit({value:this.value}))}onButtonClick(){this.cycle()}static{de()}};import{jsx as M}from"@ecopages/jsx/jsx-runtime";function Q(...e){return e.filter(Boolean).join(" ")}function Ue({id:e,children:t,class:n,disabled:o,selected:f}){return M("span",{class:Q("rui-cycle-toggle__item",n),"data-cycle-value":e,hidden:f===void 0?void 0:!f,"aria-disabled":o?"true":void 0,children:t})}function je({children:e,variant:t="filled",size:n="md",disabled:o}){return M("button",{type:"button",class:Q("rui-button","rui-cycle-toggle__button",`rui-button--${t}`,`rui-button--${n}`),disabled:o,"data-cycle-toggle-button":!0,children:e})}function Pe({children:e,value:t,variant:n,size:o,label:f,disabled:w,...d}){return M("rui-cycle-toggle",{...d,value:t,variant:n,size:o,label:f,disabled:w,children:M(je,{variant:n,size:o,disabled:w,children:e})})}import{jsx as c,jsxs as Y}from"@ecopages/jsx/jsx-runtime";var Ve={system:"System",light:"Light",dark:"Dark"},X={xmlns:"http://www.w3.org/2000/svg",width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":!0},Ke={system:Y("svg",{...X,children:[c("rect",{width:"20",height:"14",x:"2",y:"3",rx:"2"}),c("line",{x1:"8",x2:"16",y1:"21",y2:"21"}),c("line",{x1:"12",x2:"12",y1:"17",y2:"21"})]}),light:Y("svg",{...X,children:[c("circle",{cx:"12",cy:"12",r:"4"}),c("path",{d:"M12 2v2"}),c("path",{d:"M12 20v2"}),c("path",{d:"m4.93 4.93 1.41 1.41"}),c("path",{d:"m17.66 17.66 1.41 1.41"}),c("path",{d:"M2 12h2"}),c("path",{d:"M20 12h2"}),c("path",{d:"m6.34 17.66-1.41 1.41"}),c("path",{d:"m19.07 4.93-1.41 1.41"})]}),dark:c("svg",{...X,children:c("path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9"})})};function ke({preference:e}){return Ke[e]}function Re({preference:e}){return Ve[e]}function We({preference:e,showLabel:t=!0}){return Y("span",{class:"inline-flex items-center gap-inline","aria-label":t?void 0:Ve[e],children:[c(ke,{preference:e}),t?c(Re,{preference:e}):void 0]})}export{Pe as RuiCycleToggle,je as RuiCycleToggleButton,Se as RuiCycleToggleElement,Ue as RuiCycleToggleItem,Re as ThemeItemLabel,ke as ThemePreferenceIcon,We as ThemePreferenceItemContent,G as cycleValue};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/components/ui/cycle-toggle/cycle-toggle.script.tsx", "../../../../src/lib/cycle-value.ts", "../../../../src/components/ui/cycle-toggle/cycle-toggle.tsx", "../../../../src/lib/cx.ts", "../../../../src/components/ui/cycle-toggle/theme-preference-icons.tsx"],
|
|
4
|
+
"sourcesContent": ["let _initProto, _initClass, _init_value, _init_extra_value, _init_variant, _init_extra_variant, _init_size, _init_extra_size, _init_label, _init_extra_label, _init_disabled, _init_extra_disabled, _init_changeEvent, _init_extra_changeEvent;\nfunction _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for(\"Symbol.metadata\"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if (\"function\" != typeof e && (r || void 0 !== e)) throw new TypeError(t + \" must \" + (n || \"be\") + \" a function\" + (r ? \"\" : \" or undefined\")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError(\"Attempted to access private element on non-instance\"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? \"get\" : j || D ? \"set\" : \"value\"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, \"get\"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? \"\" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error(\"Decorating two elements with the same name (\" + P[F].name + \") is not supported yet\"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], \"A decorator\", \"be\", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: [\"field\", \"accessor\", \"method\", \"getter\", \"setter\", \"class\"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError(\"attempted to call addInitializer after decoration was finished\"); b(t, \"An initializer\", \"be\", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, \"class decorators\", \"return\") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I(\"get\", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I(\"set\", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if (\"object\" == typeof N && N) (c = b(N.get, \"accessor.get\")) && (P.get = c), (c = b(N.set, \"accessor.set\")) && (P.set = c), (c = b(N.init, \"accessor.init\")) && k.unshift(c);else if (void 0 !== N) throw new TypeError(\"accessor decorators must return an object with get, set, or init properties or undefined\"); } else b(N, (l ? \"field\" : \"method\") + \" decorators\", \"return\") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I(\"get\", s), I(\"set\", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? \"#\" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == typeof i ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != typeof i) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\nfunction _setFunctionName(e, t, n) { \"symbol\" == typeof t && (t = (t = t.description) ? \"[\" + t + \"]\" : \"\"); try { Object.defineProperty(e, \"name\", { configurable: !0, value: n ? n + \" \" + t : t }); } catch (e) {} return e; }\nfunction _checkInRHS(e) { if (Object(e) !== e) throw TypeError(\"right-hand side of 'in' should be an object, got \" + (null !== e ? typeof e : \"null\")); return e; }\nimport { RadiantElement, customElement, event, onEvent, onUpdated, prop } from \"@ecopages/radiant\";\nimport { cycleValue } from \"@/lib/cycle-value\";\nconst ITEM_SELECTOR = \"[data-cycle-value]\";\nconst BUTTON_SELECTOR = \"button[data-cycle-toggle-button]\";\nlet _RuiCycleToggle;\nclass RuiCycleToggle extends RadiantElement {\n static {\n ({\n e: [_init_value, _init_extra_value, _init_variant, _init_extra_variant, _init_size, _init_extra_size, _init_label, _init_extra_label, _init_disabled, _init_extra_disabled, _init_changeEvent, _init_extra_changeEvent, _initProto],\n c: [_RuiCycleToggle, _initClass]\n } = _applyDecs(this, [customElement(\"rui-cycle-toggle\")], [[prop({\n type: String,\n reflect: true,\n defaultValue: \"\"\n }), 0, \"value\"], [prop({\n type: String,\n reflect: true,\n defaultValue: \"filled\"\n }), 0, \"variant\"], [prop({\n type: String,\n reflect: true,\n defaultValue: \"md\"\n }), 0, \"size\"], [prop({\n type: String,\n defaultValue: \"\"\n }), 0, \"label\"], [prop({\n type: Boolean,\n reflect: true,\n defaultValue: false\n }), 0, \"disabled\"], [event({\n name: \"rui-change\",\n bubbles: true,\n composed: true\n }), 0, \"changeEvent\"], [onUpdated([\"value\", \"label\", \"disabled\", \"size\", \"variant\"]), 2, \"onPropsUpdated\"], [onEvent({\n selector: BUTTON_SELECTOR,\n type: \"click\"\n }), 2, \"onButtonClick\"]], 0, void 0, RadiantElement));\n }\n value = (_initProto(this), _init_value(this));\n variant = (_init_extra_value(this), _init_variant(this));\n size = (_init_extra_variant(this), _init_size(this));\n label = (_init_extra_size(this), _init_label(this));\n disabled = (_init_extra_label(this), _init_disabled(this));\n changeEvent = (_init_extra_disabled(this), _init_changeEvent(this));\n childObserver = (_init_extra_changeEvent(this), null);\n connectedCallback() {\n super.connectedCallback();\n this.childObserver = new MutationObserver(() => this.resync());\n this.childObserver.observe(this, {\n childList: true,\n subtree: true\n });\n queueMicrotask(() => this.resync());\n }\n disconnectedCallback() {\n this.childObserver?.disconnect();\n this.childObserver = null;\n super.disconnectedCallback();\n }\n onPropsUpdated() {\n this.resync();\n }\n /** Re-applies button labeling and the visible cycle item from the current `value`. */\n resync() {\n const selected = this.syncSelection(this.value || this.getItemValue(this.getEnabledItems()[0]) || \"\");\n this.syncButtonPresentation();\n this.syncButtonLabel(selected);\n }\n getItems() {\n return Array.from(this.querySelectorAll(ITEM_SELECTOR));\n }\n getEnabledItems() {\n return this.getItems().filter(item => item.getAttribute(\"aria-disabled\") !== \"true\");\n }\n getItemValue(item) {\n if (!item) return \"\";\n return item.dataset.cycleValue ?? \"\";\n }\n syncButtonLabel(selected) {\n const button = this.querySelector(BUTTON_SELECTOR);\n if (!button) return;\n const selectedLabel = selected?.querySelector(\"[aria-label]\")?.ariaLabel ?? selected?.textContent?.trim();\n if (!this.label || !selectedLabel) {\n button.removeAttribute(\"aria-label\");\n return;\n }\n button.setAttribute(\"aria-label\", `${this.label}: ${selectedLabel}`);\n }\n syncButtonPresentation() {\n const button = this.querySelector(BUTTON_SELECTOR);\n if (!button) return;\n button.disabled = this.disabled;\n for (const className of Array.from(button.classList)) {\n if (className.startsWith(\"rui-button--\")) button.classList.remove(className);\n }\n button.classList.add(`rui-button--${this.variant}`, `rui-button--${this.size}`);\n }\n syncSelection(nextValue) {\n const items = this.getItems();\n if (!items.length) return void 0;\n const enabled = this.getEnabledItems();\n const selected = items.find(item => this.getItemValue(item) === nextValue && enabled.includes(item)) ?? enabled[0] ?? items[0];\n const selectedValue = this.getItemValue(selected);\n this.value = selectedValue;\n for (const item of items) {\n item.hidden = item !== selected;\n }\n return selected;\n }\n cycle() {\n if (this.disabled) return;\n const enabled = this.getEnabledItems();\n const values = enabled.map(item => this.getItemValue(item)).filter(Boolean);\n if (!values.length) return;\n const next = cycleValue(values, this.value || void 0);\n if (next === this.value) return;\n this.syncSelection(next);\n this.changeEvent.emit({\n value: this.value\n });\n }\n onButtonClick() {\n this.cycle();\n }\n static {\n _initClass();\n }\n}\nexport { _RuiCycleToggle as RuiCycleToggle };", "export function cycleValue(values, current) {\n if (values.length === 0) {\n throw new RangeError(\"cycleValue requires at least one value\");\n }\n const index = current === void 0 ? -1 : values.indexOf(current);\n if (index === -1) {\n return values[0];\n }\n return values[(index + 1) % values.length];\n}", "import { jsx } from \"@ecopages/jsx/jsx-runtime\";\nimport { cx } from \"@/lib/cx\";\nimport \"./cycle-toggle.script\";\nexport function RuiCycleToggleItem({\n id,\n children,\n class: className,\n disabled,\n selected\n}) {\n return /* @__PURE__ */jsx(\"span\", {\n class: cx(\"rui-cycle-toggle__item\", className),\n \"data-cycle-value\": id,\n hidden: selected === void 0 ? void 0 : !selected,\n \"aria-disabled\": disabled ? \"true\" : void 0,\n children\n });\n}\nexport function RuiCycleToggleButton({\n children,\n variant = \"filled\",\n size = \"md\",\n disabled\n}) {\n return /* @__PURE__ */jsx(\"button\", {\n type: \"button\",\n class: cx(\"rui-button\", \"rui-cycle-toggle__button\", `rui-button--${variant}`, `rui-button--${size}`),\n disabled,\n \"data-cycle-toggle-button\": true,\n children\n });\n}\nexport function RuiCycleToggle({\n children,\n value,\n variant,\n size,\n label,\n disabled,\n ...props\n}) {\n return /* @__PURE__ */jsx(\"rui-cycle-toggle\", {\n ...props,\n value,\n variant,\n size,\n label,\n disabled,\n children: /* @__PURE__ */jsx(RuiCycleToggleButton, {\n variant,\n size,\n disabled,\n children\n })\n });\n}", "export function cx(...parts) {\n return parts.filter(Boolean).join(\" \");\n}", "import { jsx, jsxs } from \"@ecopages/jsx/jsx-runtime\";\nconst themeLabels = {\n system: \"System\",\n light: \"Light\",\n dark: \"Dark\"\n};\nconst lucideIconProps = {\n xmlns: \"http://www.w3.org/2000/svg\",\n width: 16,\n height: 16,\n viewBox: \"0 0 24 24\",\n fill: \"none\",\n stroke: \"currentColor\",\n \"stroke-width\": 2,\n \"stroke-linecap\": \"round\",\n \"stroke-linejoin\": \"round\",\n \"aria-hidden\": true\n};\nconst themeIcons = {\n system: /* @__PURE__ */jsxs(\"svg\", {\n ...lucideIconProps,\n children: [/* @__PURE__ */jsx(\"rect\", {\n width: \"20\",\n height: \"14\",\n x: \"2\",\n y: \"3\",\n rx: \"2\"\n }), /* @__PURE__ */jsx(\"line\", {\n x1: \"8\",\n x2: \"16\",\n y1: \"21\",\n y2: \"21\"\n }), /* @__PURE__ */jsx(\"line\", {\n x1: \"12\",\n x2: \"12\",\n y1: \"17\",\n y2: \"21\"\n })]\n }),\n light: /* @__PURE__ */jsxs(\"svg\", {\n ...lucideIconProps,\n children: [/* @__PURE__ */jsx(\"circle\", {\n cx: \"12\",\n cy: \"12\",\n r: \"4\"\n }), /* @__PURE__ */jsx(\"path\", {\n d: \"M12 2v2\"\n }), /* @__PURE__ */jsx(\"path\", {\n d: \"M12 20v2\"\n }), /* @__PURE__ */jsx(\"path\", {\n d: \"m4.93 4.93 1.41 1.41\"\n }), /* @__PURE__ */jsx(\"path\", {\n d: \"m17.66 17.66 1.41 1.41\"\n }), /* @__PURE__ */jsx(\"path\", {\n d: \"M2 12h2\"\n }), /* @__PURE__ */jsx(\"path\", {\n d: \"M20 12h2\"\n }), /* @__PURE__ */jsx(\"path\", {\n d: \"m6.34 17.66-1.41 1.41\"\n }), /* @__PURE__ */jsx(\"path\", {\n d: \"m19.07 4.93-1.41 1.41\"\n })]\n }),\n dark: /* @__PURE__ */jsx(\"svg\", {\n ...lucideIconProps,\n children: /* @__PURE__ */jsx(\"path\", {\n d: \"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9\"\n })\n })\n};\nexport function ThemePreferenceIcon({\n preference\n}) {\n return themeIcons[preference];\n}\nexport function ThemeItemLabel({\n preference\n}) {\n return themeLabels[preference];\n}\nexport function ThemePreferenceItemContent({\n preference,\n showLabel = true\n}) {\n return /* @__PURE__ */jsxs(\"span\", {\n class: \"inline-flex items-center gap-inline\",\n \"aria-label\": showLabel ? void 0 : themeLabels[preference],\n children: [/* @__PURE__ */jsx(ThemePreferenceIcon, {\n preference\n }), showLabel ? /* @__PURE__ */jsx(ThemeItemLabel, {\n preference\n }) : void 0]\n });\n}"],
|
|
5
|
+
"mappings": "AAMA,OAAS,kBAAAA,GAAgB,iBAAAC,GAAe,SAAAC,GAAO,WAAAC,GAAS,aAAAC,GAAW,QAAAC,MAAY,oBCNxE,SAASC,EAAWC,EAAQC,EAAS,CAC1C,GAAID,EAAO,SAAW,EACpB,MAAM,IAAI,WAAW,wCAAwC,EAE/D,IAAME,EAAQD,IAAY,OAAS,GAAKD,EAAO,QAAQC,CAAO,EAC9D,OAAIC,IAAU,GACLF,EAAO,CAAC,EAEVA,GAAQE,EAAQ,GAAKF,EAAO,MAAM,CAC3C,CDTA,IAAIG,GAAYC,GAAYC,GAAaC,GAAmBC,GAAeC,GAAqBC,GAAYC,GAAkBC,GAAaC,GAAmBC,GAAgBC,GAAsBC,GAAmBC,GACvN,SAASC,GAAW,EAAG,EAAG,EAAGC,EAAGC,EAAGC,EAAG,CAAE,IAAIC,EAAGC,EAAGC,EAAGC,EAAGC,EAAGC,EAAGC,EAAGC,EAAI,OAAO,UAAY,OAAO,IAAI,iBAAiB,EAAGC,EAAI,OAAO,eAAgBC,EAAI,OAAO,OAAQC,EAAI,CAACD,EAAE,IAAI,EAAGA,EAAE,IAAI,CAAC,EAAGE,EAAI,EAAE,OAAQ,SAASC,EAAEC,EAAGC,EAAGjB,EAAG,CAAE,OAAO,SAAUC,EAAGC,EAAG,CAAEe,IAAMf,EAAID,EAAGA,EAAI,GAAI,QAASE,EAAI,EAAGA,EAAIa,EAAE,OAAQb,IAAKD,EAAIc,EAAEb,CAAC,EAAE,MAAMF,E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EAAI,OAAQ,CAC7B,EAAG,uBACL,CAAC,EAAkBA,EAAI,OAAQ,CAC7B,EAAG,uBACL,CAAC,CAAC,CACJ,CAAC,EACD,KAAqBA,EAAI,MAAO,CAC9B,GAAGG,EACH,SAAyBH,EAAI,OAAQ,CACnC,EAAG,mCACL,CAAC,CACH,CAAC,CACH,EACO,SAASK,GAAoB,CAClC,WAAAC,CACF,EAAG,CACD,OAAOF,GAAWE,CAAU,CAC9B,CACO,SAASC,GAAe,CAC7B,WAAAD,CACF,EAAG,CACD,OAAOJ,GAAYI,CAAU,CAC/B,CACO,SAASE,GAA2B,CACzC,WAAAF,EACA,UAAAG,EAAY,EACd,EAAG,CACD,OAAsBR,EAAK,OAAQ,CACjC,MAAO,sCACP,aAAcQ,EAAY,OAASP,GAAYI,CAAU,EACzD,SAAU,CAAgBN,EAAIK,GAAqB,CACjD,WAAAC,CACF,CAAC,EAAGG,EAA2BT,EAAIO,GAAgB,CACjD,WAAAD,CACF,CAAC,EAAI,MAAM,CACb,CAAC,CACH",
|
|
6
|
+
"names": ["RadiantElement", "customElement", "event", "onEvent", "onUpdated", "prop", "cycleValue", "values", "current", "index", "_initProto", "_initClass", "_init_value", "_init_extra_value", "_init_variant", "_init_extra_variant", "_init_size", "_init_extra_size", "_init_label", "_init_extra_label", "_init_disabled", "_init_extra_disabled", "_init_changeEvent", "_init_extra_changeEvent", "_applyDecs", "r", "o", "i", "a", "c", "u", "s", "f", "l", "p", "d", "m", "h", "y", "v", "g", "t", "n", "b", "e", "applyDec", "w", "D", "S", "j", "E", "I", "P", "k", "F", "_setFunctionName", "N", "O", "T", "z", "A", "H", "_toPropertyKey", "_checkInRHS", "_toPrimitive", "ITEM_SELECTOR", "BUTTON_SELECTOR", "_RuiCycleToggle", "RuiCycleToggle", "RadiantElement", "customElement", "prop", "event", "onUpdated", "onEvent", "selected", "item", "button", "selectedLabel", "className", "nextValue", "items", "enabled", "selectedValue", "values", "next", "cycleValue", "jsx", "cx", "parts", "RuiCycleToggleItem", "id", "children", "className", "disabled", "selected", "jsx", "cx", "RuiCycleToggleButton", "variant", "size", "RuiCycleToggle", "value", "label", "props", "jsx", "jsxs", "themeLabels", "lucideIconProps", "themeIcons", "ThemePreferenceIcon", "preference", "ThemeItemLabel", "ThemePreferenceItemContent", "showLabel"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { JsxRenderable } from '@ecopages/jsx';
|
|
2
|
+
export type ThemePreference = 'system' | 'light' | 'dark';
|
|
3
|
+
export declare function ThemePreferenceIcon({ preference }: {
|
|
4
|
+
preference: ThemePreference;
|
|
5
|
+
}): JsxRenderable;
|
|
6
|
+
export declare function ThemeItemLabel({ preference }: {
|
|
7
|
+
preference: ThemePreference;
|
|
8
|
+
}): JsxRenderable;
|
|
9
|
+
export declare function ThemePreferenceItemContent({ preference, showLabel, }: {
|
|
10
|
+
preference: ThemePreference;
|
|
11
|
+
showLabel?: boolean;
|
|
12
|
+
}): JsxRenderable;
|
|
@@ -1,6 +1,43 @@
|
|
|
1
1
|
/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */
|
|
2
2
|
@layer properties;
|
|
3
3
|
@layer components {
|
|
4
|
+
.rui-icon {
|
|
5
|
+
width: var(--size-icon-sm);
|
|
6
|
+
height: var(--size-icon-sm);
|
|
7
|
+
flex-shrink: 0;
|
|
8
|
+
}
|
|
9
|
+
.rui-icon--md {
|
|
10
|
+
width: var(--size-icon-md);
|
|
11
|
+
height: var(--size-icon-md);
|
|
12
|
+
}
|
|
13
|
+
.rui-control-toggle {
|
|
14
|
+
display: inline-flex;
|
|
15
|
+
height: var(--spacing-8, var(--space-8));
|
|
16
|
+
width: var(--spacing-8, var(--space-8));
|
|
17
|
+
flex-shrink: 0;
|
|
18
|
+
align-items: center;
|
|
19
|
+
justify-content: center;
|
|
20
|
+
border-radius: var(--radius-control, var(--radius-control));
|
|
21
|
+
border-style: var(--tw-border-style);
|
|
22
|
+
border-width: 0px;
|
|
23
|
+
background-color: transparent;
|
|
24
|
+
color: var(--color-on-surface, var(--on-surface));
|
|
25
|
+
cursor: pointer;
|
|
26
|
+
}
|
|
27
|
+
.rui-control-toggle:hover:not(:disabled) {
|
|
28
|
+
background-color: var(--color-surface-container-low, var(--surface-container-low));
|
|
29
|
+
}
|
|
30
|
+
.rui-control-toggle:focus-visible {
|
|
31
|
+
--tw-ring-shadow: var(--tw-ring-inset,) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color, currentcolor);
|
|
32
|
+
box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
|
|
33
|
+
--tw-ring-color: var(--color-focus-ring, var(--focus-ring));
|
|
34
|
+
--tw-outline-style: none;
|
|
35
|
+
outline-style: none;
|
|
36
|
+
}
|
|
37
|
+
.rui-control-toggle:disabled {
|
|
38
|
+
cursor: not-allowed;
|
|
39
|
+
opacity: var(--opacity-muted, var(--opacity-muted));
|
|
40
|
+
}
|
|
4
41
|
.rui-floating {
|
|
5
42
|
position: fixed;
|
|
6
43
|
visibility: hidden;
|
|
@@ -1,10 +1,29 @@
|
|
|
1
|
-
import type { JsxHtmlPropsWithChildren } from '@ecopages/jsx';
|
|
1
|
+
import type { JsxHtmlProps, JsxHtmlPropsWithChildren } from '@ecopages/jsx';
|
|
2
|
+
import { type RuiCalendarProps } from '../calendar';
|
|
2
3
|
import type { RuiDateFieldProps } from './date-field.script';
|
|
4
|
+
import './date-field.script';
|
|
5
|
+
export type RuiDateFieldControlProps = JsxHtmlPropsWithChildren;
|
|
6
|
+
/** Bordered control row containing the date input and calendar toggle. */
|
|
7
|
+
export declare function RuiDateFieldControl({ children, class: className, ...props }: RuiDateFieldControlProps): import("@ecopages/jsx").JsxRenderable;
|
|
8
|
+
export type RuiDateFieldInputProps = JsxHtmlProps;
|
|
9
|
+
/** Text input controlled by the date-field host. */
|
|
10
|
+
export declare function RuiDateFieldInput({ class: className, ...props }: RuiDateFieldInputProps): import("@ecopages/jsx").JsxRenderable;
|
|
11
|
+
export type RuiDateFieldToggleProps = JsxHtmlPropsWithChildren<{
|
|
12
|
+
'aria-label'?: string;
|
|
13
|
+
}>;
|
|
14
|
+
/** Toggle button for the date calendar. */
|
|
15
|
+
export declare function RuiDateFieldToggle({ children, class: className, 'aria-label': ariaLabel, ...props }: RuiDateFieldToggleProps): import("@ecopages/jsx").JsxRenderable;
|
|
16
|
+
export type RuiDateFieldPopoverProps = JsxHtmlPropsWithChildren;
|
|
17
|
+
/** Floating shell for a `RuiDateFieldCalendar`. */
|
|
18
|
+
export declare function RuiDateFieldPopover({ children, class: className, ...props }: RuiDateFieldPopoverProps): import("@ecopages/jsx").JsxRenderable;
|
|
19
|
+
export type RuiDateFieldCalendarProps = JsxHtmlProps<RuiCalendarProps>;
|
|
20
|
+
/** Calendar whose value and constraints are synchronized by the date-field host. */
|
|
21
|
+
export declare function RuiDateFieldCalendar(props: RuiDateFieldCalendarProps): import("@ecopages/jsx").JsxRenderable;
|
|
3
22
|
/**
|
|
4
23
|
* Locale-aware date field with optional digit masking, flexible parsing, and a calendar popover.
|
|
5
24
|
*
|
|
6
25
|
* Pair with `RuiLabel` / `RuiField` for labeling and validation.
|
|
7
26
|
*/
|
|
8
|
-
export declare
|
|
27
|
+
export declare function RuiDateField({ children, ...props }: JsxHtmlPropsWithChildren<RuiDateFieldProps & {
|
|
9
28
|
slot?: string;
|
|
10
|
-
}
|
|
29
|
+
}>): import("@ecopages/jsx").JsxRenderable;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { RadiantElement } from '@ecopages/radiant';
|
|
2
2
|
import type { EventEmitter } from '@ecopages/radiant/tools/event-emitter';
|
|
3
3
|
import type { DateDisplayStyle } from '@/lib/intl-date';
|
|
4
|
-
import '../calendar/calendar.script';
|
|
5
4
|
export type RuiDateFieldProps = {
|
|
6
5
|
value?: string;
|
|
7
6
|
min?: string;
|
|
@@ -43,11 +42,32 @@ type RuiDateFieldBindings = {
|
|
|
43
42
|
* On blur, values are parsed flexibly (numeric, masked, or month names like "Aug 21, 2002")
|
|
44
43
|
* and displayed with `dateStyle`. Canonical `value` is ISO `YYYY-MM-DD`.
|
|
45
44
|
*
|
|
46
|
-
*
|
|
45
|
+
* Compose the input, toggle, popover, and calendar with the `RuiDateField*`
|
|
46
|
+
* view helpers. `RuiDateField` supplies that composition when it has no children.
|
|
47
47
|
*
|
|
48
48
|
* @see https://react-aria.adobe.com/DatePicker
|
|
49
|
+
*
|
|
49
50
|
* @element rui-date-field
|
|
50
|
-
*
|
|
51
|
+
*
|
|
52
|
+
* @attr {string} value - Canonical ISO `YYYY-MM-DD` value. Default: `''`.
|
|
53
|
+
* @attr {string} min - Earliest selectable ISO date. Default: `''`.
|
|
54
|
+
* @attr {string} max - Latest selectable ISO date. Default: `''`.
|
|
55
|
+
* @attr {boolean} disabled - Disable the field and calendar. Default: `false`.
|
|
56
|
+
* @attr {boolean} read-only - Disable editing while keeping the value visible. Default: `false`.
|
|
57
|
+
* @attr {string} label - Accessible name when there is no associated label. Default: `''`.
|
|
58
|
+
* @attr {string} name - Native `name` for the underlying input. Default: `''`.
|
|
59
|
+
* @attr {string} placeholder - Overrides the locale-derived placeholder. Default: `''`.
|
|
60
|
+
* @attr {string} locale - BCP 47 locale tag, or comma-separated fallback list. Default: `''`.
|
|
61
|
+
* @attr {string} date-style - How the committed value is displayed when not editing. Default: `medium`.
|
|
62
|
+
* @attr {boolean} masked - Guide digits with a locale mask while typing. Default: `true`.
|
|
63
|
+
* @attr {number} visible-months - Month grids shown in the calendar popover. Default: `1`.
|
|
64
|
+
*
|
|
65
|
+
* @fires rui-change - Emitted when a valid date is committed (typing or calendar pick).
|
|
66
|
+
*
|
|
67
|
+
* @cssclass rui-date-field - Root surface.
|
|
68
|
+
* @cssclass rui-date-field__group - Bordered control-height row wrapping input and toggle.
|
|
69
|
+
* @cssclass rui-date-field__input - The masked / formatted text input.
|
|
70
|
+
* @cssclass rui-date-field__popover - Calendar popup shell (`rui-popover` / `rui-floating`).
|
|
51
71
|
*/
|
|
52
72
|
export declare class RuiDateField extends RadiantElement<RuiDateFieldBindings> {
|
|
53
73
|
value: string;
|
|
@@ -69,15 +89,18 @@ export declare class RuiDateField extends RadiantElement<RuiDateFieldBindings> {
|
|
|
69
89
|
private readonly uid;
|
|
70
90
|
private popoverController;
|
|
71
91
|
private suppressPopoverDismiss;
|
|
72
|
-
rootTarget: HTMLElement;
|
|
73
92
|
popoverTarget: HTMLElement;
|
|
74
93
|
private get isoValue();
|
|
75
94
|
private get resolvedLocale();
|
|
76
95
|
private get inputId();
|
|
77
96
|
private get resolvedPlaceholder();
|
|
78
97
|
private getInput;
|
|
98
|
+
private getToggle;
|
|
99
|
+
private getCalendar;
|
|
79
100
|
private syncLabel;
|
|
80
101
|
private syncInput;
|
|
102
|
+
private syncToggle;
|
|
103
|
+
private syncCalendar;
|
|
81
104
|
private formatForDisplay;
|
|
82
105
|
private formatForEditing;
|
|
83
106
|
private syncDisplayValue;
|
|
@@ -87,6 +110,8 @@ export declare class RuiDateField extends RadiantElement<RuiDateFieldBindings> {
|
|
|
87
110
|
private handleMaskedInput;
|
|
88
111
|
private initialize;
|
|
89
112
|
private setOpen;
|
|
113
|
+
/** Focus the calendar's roving day, falling back to its first available day. */
|
|
114
|
+
private focusCalendarDay;
|
|
90
115
|
private ensurePopoverController;
|
|
91
116
|
private syncPopoverPosition;
|
|
92
117
|
connectedCallback(): void;
|
|
@@ -103,6 +128,5 @@ export declare class RuiDateField extends RadiantElement<RuiDateFieldBindings> {
|
|
|
103
128
|
onPopoverMouseDown(event: Event): void;
|
|
104
129
|
onCalendarChange(event: Event): void;
|
|
105
130
|
onRootKeydown(event: KeyboardEvent): void;
|
|
106
|
-
render(): import("@ecopages/jsx").JsxRenderable;
|
|
107
131
|
}
|
|
108
132
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { RuiDateField as RuiDateFieldElement, type RuiDateFieldProps, type RuiDateFieldChangeDetail, } from './date-field.script';
|
|
2
|
-
export { RuiDateField } from './date-field';
|
|
2
|
+
export { RuiDateField, RuiDateFieldCalendar, RuiDateFieldControl, RuiDateFieldInput, RuiDateFieldPopover, RuiDateFieldToggle, } from './date-field';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as N,jsxs as Pe}from"@ecopages/jsx/jsx-runtime";import{RadiantElement as Se,customElement as dn,event as pn,onEvent as k,onUpdated as Ee,prop as b,query as Ce,state as ft}from"@ecopages/radiant";function F(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 T(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 T(t,{dateStyle:n}).format(e)}var Ae={0:"digit",a:"letter","*":"any"},Ne=/\p{L}/u;function je(e,t){let n=t?.[e];if(n instanceof RegExp)return{kind:"any",pattern:n};if(n)return{kind:n};let i=Ae[e];return i?{kind:i}:null}function Tt(e,t,n){return n?n.test(e):t==="digit"?/\d/.test(e):t==="letter"?Ne.test(e):e.length>0}function Pt(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=$e(e,r+1);if(a<0){i.push({type:"literal",value:"["}),r+=1;continue}let l=Pt(e.slice(r+1,a),t,!0);i.push(...l),r=a+1;continue}if(o==="]")break;let s=je(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 $e(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 Pt(e,t)}function at(e,t={}){return e.filter(n=>n.type==="input"&&(!t.requiredOnly||!n.optional)).length}function We(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];Tt(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(!Tt(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 qe(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=We(e,i);return o.length===0&&/\S/.test(e)&&He(i)&&(o=qe(e,i)),o.length>r&&(o=o.slice(0,r)),Be(o,i)}var st=new Date(2001,8,3);function Y(e){return T(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 O(e){let t=T(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 T(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 R(e){return e.replace(/\D/g,"")}function U(e,t){return St(R(e),t)}function A(e){return at(ot(e),{requiredOnly:!0})}function Ye(e){return e>=100?e:e>=69?1900+e:2e3+e}function ut(e,t){let n=Y(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=Ye(l)),r[o]=l,i+=s}return r}function ct(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 Ue=new Date(2001,8,3);function Et(e){return T(e,{year:"numeric",month:"numeric",day:"numeric"}).formatToParts(Ue).filter(n=>n.type==="year"||n.type==="month"||n.type==="day").map(n=>n.type)}function Ct(e){return e>=100?e:e>=69?1900+e:2e3+e}function Ft(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 dt(e,t){let n=(e??"").trim();if(!n)return null;let i=F(n);if(i)return i;let r=Ke(n,t);if(r)return r;let o=Je(n,t);if(o)return o;let s=Et(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=Ct(g)),l[m]=g}return Ft(l)}function Ke(e,t){let n=O(t),i=R(e);return i.length<A(n)?null:ct(ut(i,t)??{})}function ze(e){let t=new Map;for(let n of["short","long"])for(let i=0;i<12;i+=1){let r=T(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 Je(e,t){let n=ze(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=Ct(Number(l)),g=Number(f);return Ft({year:m,month:o,day:g})}return null}import{jsx as K,jsxs as Xe}from"@ecopages/jsx/jsx-runtime";function Ot(...e){return e.filter(Boolean).join(" ")}function pt({class:e,size:t="sm",...n}){return Xe("svg",{...n,class:Ot("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:[K("path",{d:"M8 2v4"}),K("path",{d:"M16 2v4"}),K("rect",{width:"18",height:"18",x:"3",y:"4",rx:"2"}),K("path",{d:"M3 10h18"})]})}function Rt(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 At(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 At(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 Lt(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(At(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),j=Lt(e,t,o,r);Lt(e,t,g,r)>j&&(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 Nt({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 jt(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.hidden=!0;return}let i=this.config.getAnchor();if(!i)return;t.hidden=!1,this.config.portal!==!1?this.portalHandle||(this.portalHandle=jt(t,this.config.portalContainer??document.body)):this.portalHandle&&(this.portalHandle.unmount(),this.portalHandle=null),this.teardownFloating(),this.cleanupFloating=Nt({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], label.rui-label")??null}function Bt(e,t,n){if(!t||t.hasAttribute("data-rui-field-managed"))return;let i=an(e);if(i){i.id||(i.id=n.labelId),i.htmlFor||(i.htmlFor=n.controlId),t.setAttribute("aria-labelledby",i.id),t.removeAttribute("aria-label");return}if(n.label){t.setAttribute("aria-label",n.label),t.removeAttribute("aria-labelledby");return}t.removeAttribute("aria-label"),t.removeAttribute("aria-labelledby")}var Ht,qt,Yt,Ut,Kt,zt,Jt,Xt,Gt,Qt,Zt,te,ee,ne,ie,re,oe,ae,se,le,ue,ce,de,pe,fe,he,me,ge,ye,ve,be,xe,De,_e,we,ke,Ie,Me;function sn(e,t,n,i,r,o){var s,a,l,f,m,g,v,j=Symbol.metadata||Symbol.for("Symbol.metadata"),X=Object.defineProperty,G=Object.create,ht=[G(null),G(null)],mt=t.length;function $(u,_,x){return function(c,d){_&&(d=c,c=e);for(var w=0;w<u.length;w++)d=u[w].apply(c,x?[d]:[]);return x?d:c}}function P(u,_,x,c){if(typeof u!="function"&&(c||u!==void 0))throw new TypeError(_+" must "+(x||"be")+" a function"+(c?"":" or undefined"));return u}function gt(u,_,x,c,d,w,E,D,I,M,vt){function Q(h){if(!vt(h))throw new TypeError("Attempted to access private element on non-instance")}var Z=[].concat(_[0]),bt=_[3],tt=!E,V=d===1,xt=d===3,Dt=d===4,W=d===2;function B(h,C,kt){return function(q,It){return C&&(It=q,q=u),kt&&kt(q),p[h].call(q,It)}}if(!tt){var p={},et=[],S=xt?"get":Dt||V?"set":"value";if(I?(M||V?p={get:Te(function(){return bt(this)},c,"get"),set:function(h){_[4](this,h)}}:p[S]=bt,M||Te(p[S],c,W?"":S)):M||(p=Object.getOwnPropertyDescriptor(u,c)),!M&&!I){if((a=ht[+D][c])&&(a^d)!==7)throw Error("Decorating two elements with the same name ("+p[S].name+") is not supported yet");ht[+D][c]=d<3?1:d}}for(var y=u,H=Z.length-1;H>=0;H-=x?2:1){var _t=P(Z[H],"A decorator","be",!0),wt=x?Z[H-1]:void 0,nt={},L={kind:["field","accessor","method","getter","setter","class"][d],name:c,metadata:s,addInitializer:function(h,C){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");P(C,"An initializer","be",!0),w.push(C)}.bind(null,nt)};if(tt)a=_t.call(wt,y,L),nt.v=1,P(a,"class decorators","return")&&(y=a);else if(L.static=D,L.private=I,a=L.access={has:I?vt.bind():function(h){return c in h}},Dt||(a.get=I?W?function(h){return Q(h),p.value}:B("get",0,Q):function(h){return h[c]}),W||xt||(a.set=I?B("set",0,Q):function(h,C){h[c]=C}),y=_t.call(wt,V?{get:p.get,set:p.set}:p[S],L),nt.v=1,V){if(typeof y=="object"&&y)(a=P(y.get,"accessor.get"))&&(p.get=a),(a=P(y.set,"accessor.set"))&&(p.set=a),(a=P(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 P(y,(M?"field":"method")+" decorators","return")&&(M?et.unshift(y):p[S]=y)}return d<2&&E.push($(et,D,1),$(w,D,0)),M||tt||(I?V?E.splice(-1,0,B("get",D),B("set",D)):E.push(W?p[S]:P.call.bind(p[S])):X(u,c,p)),y}function yt(u){return X(u,j,{configurable:!0,enumerable:!0,value:s})}return o!==void 0&&(s=o[j]),s=G(s??null),m=[],g=function(u){u&&m.push($(u))},v=function(u,_){for(var x=0;x<n.length;x++){var c=n[x],d=c[1],w=7&d;if((8&d)==u&&!w==_){var E=c[2],D=!!c[3],I=16&d;gt(u?e:e.prototype,c,I,D?"#"+E:ln(E),w,w<2?[]:u?f=f||[]:l=l||[],m,!!u,D,_,u&&D?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,mt||yt(e),{e:a,get c(){var u=[];return mt&&[yt(e=gt(e,[t],i,e.name,5,u)),$(u,1)]}}}function ln(e){var t=un(e,"string");return typeof t=="symbol"?t:t+""}function un(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 Te(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 J,Fe=class extends Se{static{({e:[Yt,Ut,Kt,zt,Jt,Xt,Gt,Qt,Zt,te,ee,ne,ie,re,oe,ae,se,le,ue,ce,de,pe,fe,he,me,ge,ye,ve,be,xe,De,_e,we,ke,Ie,Me,Ht],c:[J,qt]}=sn(this,[dn("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"],[pn({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[ft,0,"displayValue"],[ft,0,"editing"],[ft,0,"open"],[Ce({ref:"root"}),0,"rootTarget"],[Ce({ref:"popover"}),0,"popoverTarget"],[Ee(["value","min","max","label","placeholder","disabled","readOnly","locale","dateStyle","masked"]),2,"onPropsUpdated"],[Ee(["open"]),2,"onOpenUpdated"],[k({selector:"[data-date-field-input]",type:"focusin"}),2,"onInputFocus"],[k({selector:"[data-date-field-input]",type:"input"}),2,"onInput"],[k({selector:"[data-date-field-input]",type:"change"}),2,"onInputChange"],[k({selector:"[data-date-field-input]",type:"keydown"}),2,"onInputKeydown"],[k({ref:"root",type:"focusout"}),2,"onRootFocusOut"],[k({ref:"trigger",type:"pointerdown"}),2,"onTriggerPointerDown"],[k({ref:"trigger",type:"click"}),2,"onTriggerClick"],[k({selector:"[data-date-field-popover]",type:"mousedown"}),2,"onPopoverMouseDown"],[k({ref:"root",type:"rui-change"}),2,"onCalendarChange"],[k({ref:"root",type:"keydown"}),2,"onRootKeydown"]],0,void 0,Se))}constructor(...t){super(...t),Me(this)}value=(Ht(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=(ce(this),de(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;rootTarget=we(this);popoverTarget=(ke(this),Ie(this));get isoValue(){return this.value??""}get resolvedLocale(){return Rt(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]")}syncLabel(){let t=this.getInput();Bt(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),this.name&&(t.name=this.name),this.disabled&&(t.disabled=!0);let n=this.resolvedPlaceholder;n&&(t.placeholder=n)}formatForDisplay(t){if(!t)return"";let n=F(t);return n?rt(n,this.resolvedLocale,this.dateStyle):""}formatForEditing(t){if(!t)return"";if(!this.masked)return this.formatForDisplay(t);let n=F(t);if(!n)return"";let i=O(this.resolvedLocale),r=fn(n,this.resolvedLocale);return U(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=dt(n,this.resolvedLocale);if(!i){this.syncDisplayValue();return}this.commitValue(it(i))}handleMaskedInput(t){let n=O(this.resolvedLocale),i=R(t),r=U(i,n);return i.length>=A(n)&&this.parseAndCommit(r),r}initialize(){this.syncLabel(),this.syncInput(),this.syncDisplayValue()}setOpen(t){this.open=t,queueMicrotask(()=>this.syncPopoverPosition())}ensurePopoverController(){return this.popoverController||(this.popoverController=new z({getAnchor:()=>this.rootTarget,getFloating:()=>this.popoverTarget,getOpen:()=>this.open,getPlacement:()=>"bottom-start",gap:4,portal:!1})),this.popoverController}syncPopoverPosition(){let t=this.popoverTarget;if(!t||!this.rootTarget)return;t.hidden=!this.open;let n=this.ensurePopoverController();n.updateConfig({getOpen:()=>this.open}),n.sync()}connectedCallback(){super.connectedCallback(),queueMicrotask(()=>this.initialize())}disconnectedCallback(){this.popoverController?.destroy(),this.popoverController=null,super.disconnectedCallback()}onPropsUpdated(){this.syncLabel(),this.syncInput(),this.syncDisplayValue()}onOpenUpdated(){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;n.matches("[data-date-field-input]")&&n instanceof HTMLInputElement&&queueMicrotask(()=>{this.editing&&(this.editing=!1,this.parseAndCommit(n.value))}),queueMicrotask(()=>{if(this.suppressPopoverDismiss){this.suppressPopoverDismiss=!1;return}if(!this.open)return;let r=i instanceof Node?i:document.activeElement;Wt(this.rootTarget,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.tagName.toLowerCase()!=="rui-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))}render(){let t={"prop:selectionMode":"single","prop:visibleMonths":this.visibleMonths,"prop:value":this.isoValue,"prop:min":this.min,"prop:max":this.max,"prop:locale":this.locale,"prop:disabled":this.disabled};return Pe("div",{class:"rui-date-field","data-ref":"root",children:[Pe("div",{class:"rui-date-field__group",children:[N("input",{type:"text","data-date-field-input":!0,"data-rui-control":!0,"data-rui-control-type":"text",class:"rui-date-field__input",id:this.inputId,autocomplete:"off",inputmode:this.masked?"numeric":"text",disabled:this.$.disabled,readOnly:this.$.readOnly,placeholder:this.$.placeholder||this.resolvedPlaceholder}),N("button",{type:"button",class:"rui-control-toggle","data-ref":"trigger","data-date-field-trigger":!0,"aria-label":"Open calendar","aria-haspopup":"dialog","aria-expanded":this.open?"true":"false",disabled:this.$.disabled||this.$.readOnly,children:N(pt,{})})]}),N("div",{class:"rui-date-field__popover rui-popover rui-floating","data-ref":"popover","data-date-field-popover":!0,hidden:!this.open,role:"dialog",children:this.open?N("rui-calendar",{...t}):null})]})}static{qt()}};function fn(e,t){let n=Y(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{jsx as gn}from"@ecopages/jsx/jsx-runtime";var hn=Symbol.for("@ecopages/storybook-radiant.viewElement"),Oe=Symbol.for("@ecopages/storybook-radiant.scriptModule"),Re=Symbol.for("@ecopages/storybook-radiant.scriptExport");function mn(e,t){e[hn]=t;let n=t[Oe];n&&(e[Oe]=n,e[Re]=t[Re]??t.name)}function Ve(e,t,n){let i=r=>t(r);return mn(i,e),i}var yn=Ve(J,({children:e,...t})=>gn("rui-date-field",{...t,children:e}),{stylesheets:["./date-field.css","../shared/control-toggle.css","../../../lib/icons/icons.css","../calendar/calendar.css"]});export{yn as RuiDateField,J as RuiDateFieldElement};
|
|
1
|
+
import{RadiantElement as Me,customElement as dn,event as cn,onEvent as I,onUpdated as Ce,prop as v,query as pn,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 Ct=new Map;function Ae(e,t){return`${JSON.stringify(e??null)}|${JSON.stringify(t)}`}function T(e,t){let n=Ae(e,t),i=Ct.get(n);if(i)return i;let r=new Intl.DateTimeFormat(e,t);return Ct.set(n,r),r}function rt(e,t,n="medium"){return T(t,{dateStyle:n}).format(e)}var Le={0:"digit",a:"letter","*":"any"},je=/\p{L}/u;function Ne(e,t){let n=t?.[e];if(n instanceof RegExp)return{kind:"any",pattern:n};if(n)return{kind:n};let i=Le[e];return i?{kind:i}:null}function Tt(e,t,n){return n?n.test(e):t==="digit"?/\d/.test(e):t==="letter"?je.test(e):e.length>0}function Ft(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=$e(e,r+1);if(a<0){i.push({type:"literal",value:"["}),r+=1;continue}let l=Ft(e.slice(r+1,a),t,!0);i.push(...l),r=a+1;continue}if(o==="]")break;let s=Ne(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 $e(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 Ft(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];Tt(o,r.kind,r.pattern)&&(n+=o,i+=1)}return n}function We(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(!Tt(o,r.kind,r.pattern)){if(r.optional)continue;break}i+=o,n+=1}return i}function Be(e){return e.every(t=>t.type!=="input"||t.kind==="digit")}function He(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 Pt(e,t,n){let i=ot(t,n),r=at(i),o=qe(e,i);return o.length===0&&/\S/.test(e)&&Be(i)&&(o=He(e,i)),o.length>r&&(o=o.slice(0,r)),We(o,i)}var st=new Date(2001,8,3);function U(e){return T(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=T(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 T(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 Pt(A(e),t)}function N(e){return at(ot(e),{requiredOnly:!0})}function Ye(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=Ye(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 Ue=new Date(2001,8,3);function St(e){return T(e,{year:"numeric",month:"numeric",day:"numeric"}).formatToParts(Ue).filter(n=>n.type==="year"||n.type==="month"||n.type==="day").map(n=>n.type)}function Et(e){return e>=100?e:e>=69?1900+e:2e3+e}function Rt(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=Ke(n,t);if(r)return r;let o=Je(n,t);if(o)return o;let s=St(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=Et(g)),l[m]=g}return Rt(l)}function Ke(e,t){let n=V(t),i=A(e);return i.length<N(n)?null:dt(ut(i,t)??{})}function ze(e){let t=new Map;for(let n of["short","long"])for(let i=0;i<12;i+=1){let r=T(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 Je(e,t){let n=ze(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(b=>b.length===4)??a[a.length-1],f=a.find(b=>b!==l&&Number(b)<=31);if(!f||!l)continue;let m=Et(Number(l)),g=Number(f);return Rt({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"},Xe=8;function Qe(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 Ze(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 tn(e,t){return t==="center"?e:`${e}-${t}`}function en(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 nn(e,t,n,i,r={width:typeof window>"u"?0:window.innerWidth,height:typeof window>"u"?0:window.innerHeight,padding:Xe}){let{side:o,align:s}=Qe(n),a=Vt(e,t,o,s,i),l=Ze(a,t,o,r),f=o,m=a;if(l>0){let g=Ge[o],b=Vt(e,t,g,s,i),$=At(e,t,o,r);At(e,t,g,r)>$&&(f=g,m=b)}return{coords:en(m,t,f,r),placement:tn(f,s)}}function rn(e,t,n,i,r={}){let{coords:o,placement:s}=nn(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||rn(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 qt(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.hidden=!0;return}let i=this.config.getAnchor();if(!i)return;t.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 on(e){let t=e.previousElementSibling;return t?.tagName.toLowerCase()==="label"?t:e.parentElement?.querySelector("[data-rui-field-label], label.rui-label")??null}function Wt(e,t,n){if(!t||t.hasAttribute("data-rui-field-managed"))return;let i=on(e);if(i){i.id||(i.id=n.labelId),i.htmlFor||(i.htmlFor=n.controlId),t.setAttribute("aria-labelledby",i.id),t.removeAttribute("aria-label");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,Gt,Xt,Qt,Zt,te,ee,ne,ie,re,oe,ae,se,le,ue,de,ce,pe,fe,he,me,ge,ye,be,ve,xe,De,_e,we,ke;function an(e,t,n,i,r,o){var s,a,l,f,m,g,b,$=Symbol.metadata||Symbol.for("Symbol.metadata"),G=Object.defineProperty,X=Object.create,mt=[X(null),X(null)],gt=t.length;function q(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 F(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,S,_,M,C,vt){function Q(h){if(!vt(h))throw new TypeError("Attempted to access private element on non-instance")}var Z=[].concat(w[0]),xt=w[3],tt=!S,L=c===1,Dt=c===3,_t=c===4,W=c===2;function B(h,R,It){return function(Y,Mt){return R&&(Mt=Y,Y=u),It&&It(Y),p[h].call(Y,Mt)}}if(!tt){var p={},et=[],P=Dt?"get":_t||L?"set":"value";if(M?(C||L?p={get:Ie(function(){return xt(this)},d,"get"),set:function(h){w[4](this,h)}}:p[P]=xt,C||Ie(p[P],d,W?"":P)):C||(p=Object.getOwnPropertyDescriptor(u,d)),!C&&!M){if((a=mt[+_][d])&&(a^c)!==7)throw Error("Decorating two elements with the same name ("+p[P].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=F(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,R){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");F(R,"An initializer","be",!0),k.push(R)}.bind(null,nt)};if(tt)a=wt.call(kt,y,j),nt.v=1,F(a,"class decorators","return")&&(y=a);else if(j.static=_,j.private=M,a=j.access={has:M?vt.bind():function(h){return d in h}},_t||(a.get=M?W?function(h){return Q(h),p.value}:B("get",0,Q):function(h){return h[d]}),W||Dt||(a.set=M?B("set",0,Q):function(h,R){h[d]=R}),y=wt.call(kt,L?{get:p.get,set:p.set}:p[P],j),nt.v=1,L){if(typeof y=="object"&&y)(a=F(y.get,"accessor.get"))&&(p.get=a),(a=F(y.set,"accessor.set"))&&(p.set=a),(a=F(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 F(y,(C?"field":"method")+" decorators","return")&&(C?et.unshift(y):p[P]=y)}return c<2&&S.push(q(et,_,1),q(k,_,0)),C||tt||(M?L?S.splice(-1,0,B("get",_),B("set",_)):S.push(W?p[P]:F.call.bind(p[P])):G(u,d,p)),y}function bt(u){return G(u,$,{configurable:!0,enumerable:!0,value:s})}return o!==void 0&&(s=o[$]),s=X(s??null),m=[],g=function(u){u&&m.push(q(u))},b=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 S=d[2],_=!!d[3],M=16&c;yt(u?e:e.prototype,d,M,_?"#"+S:sn(S),k,k<2?[]:u?f=f||[]:l=l||[],m,!!u,_,w,u&&_?function(C){return un(C)===e}:r)}}},b(8,0),b(0,0),b(8,1),b(0,1),g(l),g(f),a=m,gt||bt(e),{e:a,get c(){var u=[];return gt&&[bt(e=yt(e,[t],i,e.name,5,u)),q(u,1)]}}}function sn(e){var t=ln(e,"string");return typeof t=="symbol"?t:t+""}function ln(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 un(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 Fe,Te=class extends Me{static{({e:[Yt,Ut,Kt,zt,Jt,Gt,Xt,Qt,Zt,te,ee,ne,ie,re,oe,ae,se,le,ue,de,ce,pe,fe,he,me,ge,ye,be,ve,xe,De,_e,we,ke,Bt],c:[Fe,Ht]}=an(this,[dn("rui-date-field")],[[v({type:String,reflect:!0,defaultValue:""}),0,"value"],[v({type:String,defaultValue:""}),0,"min"],[v({type:String,defaultValue:""}),0,"max"],[v({type:Boolean,reflect:!0,defaultValue:!1}),0,"disabled"],[v({type:Boolean,attribute:"read-only",reflect:!0,defaultValue:!1}),0,"readOnly"],[v({type:String,defaultValue:""}),0,"label"],[v({type:String,defaultValue:""}),0,"name"],[v({type:String,defaultValue:""}),0,"placeholder"],[v({type:String,defaultValue:""}),0,"locale"],[v({type:String,attribute:"date-style",defaultValue:"medium"}),0,"dateStyle"],[v({type:Boolean,reflect:!0,defaultValue:!0}),0,"masked"],[v({type:Number,attribute:"visible-months",defaultValue:1}),0,"visibleMonths"],[cn({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[pt,0,"displayValue"],[pt,0,"editing"],[pt,0,"open"],[pn({ref:"popover"}),0,"popoverTarget"],[Ce(["value","min","max","label","placeholder","disabled","readOnly","locale","dateStyle","masked","visibleMonths"]),2,"onPropsUpdated"],[Ce(["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,Me))}constructor(...t){super(...t),ke(this)}value=(Bt(this),Yt(this));min=(Ut(this),Kt(this));max=(zt(this),Jt(this));disabled=(Gt(this),Xt(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=(be(this),ve(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();Wt(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=fn(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()}connectedCallback(){super.connectedCallback(),queueMicrotask(()=>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;qt(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 fn(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 gn,jsx as x,jsxs as Pe}from"@ecopages/jsx/jsx-runtime";function E(...e){return e.filter(Boolean).join(" ")}import{jsx as J,jsxs as hn}from"@ecopages/jsx/jsx-runtime";function ft({class:e,size:t="sm",...n}){return hn("svg",{...n,class:E("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 mn}from"@ecopages/jsx/jsx-runtime";function ht({children:e,...t}){return mn("rui-calendar",{...t,children:e})}function Se({children:e,class:t,...n}){return x("div",{...n,class:E("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:E("rui-date-field__input",e),autocomplete:"off"})}function Re({children:e,class:t,"aria-label":n="Open calendar",...i}){return x("button",{...i,type:"button","data-ref":"trigger","data-date-field-trigger":!0,class:E("rui-control-toggle",t),"aria-label":n,"aria-haspopup":"dialog",children:e??x(ft,{})})}function Oe({children:e,class:t,...n}){return x("div",{...n,"data-ref":"popover","data-date-field-popover":!0,class:E("rui-date-field__popover rui-popover rui-floating",t),hidden:!0,role:"dialog",children:e})}function Ve(e){return x(ht,{...e,"data-date-field-calendar":!0})}function yn({children:e,...t}){return x("rui-date-field",{...t,children:e??Pe(gn,{children:[Pe(Se,{children:[x(Ee,{}),x(Re,{})]}),x(Oe,{children:x(Ve,{})})]})})}export{yn as RuiDateField,Ve as RuiDateFieldCalendar,Se as RuiDateFieldControl,Fe as RuiDateFieldElement,Ee as RuiDateFieldInput,Oe as RuiDateFieldPopover,Re as RuiDateFieldToggle};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|