@data-slot/toggle 0.2.31 → 0.2.32

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/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));const c=s(require(`@data-slot/core`));function l(e,t={}){let n=t.defaultPressed??(0,c.getDataBool)(e,`defaultPressed`)??!1,r=t.disabled??(0,c.getDataBool)(e,`disabled`)??!1,i=t.onPressedChange,a=n,o=[],s=()=>e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`,l=(t,n=!1)=>{a===t&&!n||(a=t,(0,c.setAria)(e,`pressed`,a),e.dataset.state=a?`on`:`off`,n||((0,c.emit)(e,`toggle:change`,{pressed:a}),i?.(a)))};return r&&(e.tagName===`BUTTON`&&e.setAttribute(`disabled`,``),e.setAttribute(`aria-disabled`,`true`)),e.tagName===`BUTTON`&&!e.hasAttribute(`type`)&&e.setAttribute(`type`,`button`),l(a,!0),o.push((0,c.on)(e,`click`,()=>{s()||l(!a)})),o.push((0,c.on)(e,`toggle:set`,e=>{if(s())return;let t=e.detail,n;typeof t==`boolean`?n=t:t?.value===void 0?t?.pressed!==void 0&&(n=t.pressed):n=t.value,typeof n==`boolean`&&l(n)})),{toggle:()=>l(!a),press:()=>l(!0),release:()=>l(!1),get pressed(){return a},destroy:()=>{o.forEach(e=>e()),o.length=0,u.delete(e)}}}const u=new WeakSet;function d(e=document){let t=[];for(let n of(0,c.getRoots)(e,`toggle`)){if(u.has(n))continue;u.add(n),t.push(l(n))}return t}exports.create=d,exports.createToggle=l;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@data-slot/core`);function t(t,r={}){let i=r.defaultPressed??(0,e.getDataBool)(t,`defaultPressed`)??!1,a=r.disabled??(0,e.getDataBool)(t,`disabled`)??!1,o=r.onPressedChange,s=i,c=[],l=()=>t.hasAttribute(`disabled`)||t.getAttribute(`aria-disabled`)===`true`,u=(n,r=!1)=>{s===n&&!r||(s=n,(0,e.setAria)(t,`pressed`,s),t.dataset.state=s?`on`:`off`,r||((0,e.emit)(t,`toggle:change`,{pressed:s}),o?.(s)))};return a&&(t.tagName===`BUTTON`&&t.setAttribute(`disabled`,``),t.setAttribute(`aria-disabled`,`true`)),t.tagName===`BUTTON`&&!t.hasAttribute(`type`)&&t.setAttribute(`type`,`button`),u(s,!0),c.push((0,e.on)(t,`click`,()=>{l()||u(!s)})),c.push((0,e.on)(t,`toggle:set`,e=>{if(l())return;let t=e.detail,n;typeof t==`boolean`?n=t:t?.value===void 0?t?.pressed!==void 0&&(n=t.pressed):n=t.value,typeof n==`boolean`&&u(n)})),{toggle:()=>u(!s),press:()=>u(!0),release:()=>u(!1),get pressed(){return s},destroy:()=>{c.forEach(e=>e()),c.length=0,n.delete(t)}}}const n=new WeakSet;function r(r=document){let i=[];for(let a of(0,e.getRoots)(r,`toggle`))n.has(a)||(n.add(a),i.push(t(a)));return i}exports.create=r,exports.createToggle=t;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{emit as e,getDataBool as t,getRoots as n,on as r,setAria as i}from"@data-slot/core";function a(n,a={}){let s=a.defaultPressed??t(n,`defaultPressed`)??!1,c=a.disabled??t(n,`disabled`)??!1,l=a.onPressedChange,u=s,d=[],f=()=>n.hasAttribute(`disabled`)||n.getAttribute(`aria-disabled`)===`true`,p=(t,r=!1)=>{u===t&&!r||(u=t,i(n,`pressed`,u),n.dataset.state=u?`on`:`off`,r||(e(n,`toggle:change`,{pressed:u}),l?.(u)))};return c&&(n.tagName===`BUTTON`&&n.setAttribute(`disabled`,``),n.setAttribute(`aria-disabled`,`true`)),n.tagName===`BUTTON`&&!n.hasAttribute(`type`)&&n.setAttribute(`type`,`button`),p(u,!0),d.push(r(n,`click`,()=>{f()||p(!u)})),d.push(r(n,`toggle:set`,e=>{if(f())return;let t=e.detail,n;typeof t==`boolean`?n=t:t?.value===void 0?t?.pressed!==void 0&&(n=t.pressed):n=t.value,typeof n==`boolean`&&p(n)})),{toggle:()=>p(!u),press:()=>p(!0),release:()=>p(!1),get pressed(){return u},destroy:()=>{d.forEach(e=>e()),d.length=0,o.delete(n)}}}const o=new WeakSet;function s(e=document){let t=[];for(let r of n(e,`toggle`)){if(o.has(r))continue;o.add(r),t.push(a(r))}return t}export{s as create,a as createToggle};
1
+ import{emit as e,getDataBool as t,getRoots as n,on as r,setAria as i}from"@data-slot/core";function a(n,a={}){let s=a.defaultPressed??t(n,`defaultPressed`)??!1,c=a.disabled??t(n,`disabled`)??!1,l=a.onPressedChange,u=s,d=[],f=()=>n.hasAttribute(`disabled`)||n.getAttribute(`aria-disabled`)===`true`,p=(t,r=!1)=>{u===t&&!r||(u=t,i(n,`pressed`,u),n.dataset.state=u?`on`:`off`,r||(e(n,`toggle:change`,{pressed:u}),l?.(u)))};return c&&(n.tagName===`BUTTON`&&n.setAttribute(`disabled`,``),n.setAttribute(`aria-disabled`,`true`)),n.tagName===`BUTTON`&&!n.hasAttribute(`type`)&&n.setAttribute(`type`,`button`),p(u,!0),d.push(r(n,`click`,()=>{f()||p(!u)})),d.push(r(n,`toggle:set`,e=>{if(f())return;let t=e.detail,n;typeof t==`boolean`?n=t:t?.value===void 0?t?.pressed!==void 0&&(n=t.pressed):n=t.value,typeof n==`boolean`&&p(n)})),{toggle:()=>p(!u),press:()=>p(!0),release:()=>p(!1),get pressed(){return u},destroy:()=>{d.forEach(e=>e()),d.length=0,o.delete(n)}}}const o=new WeakSet;function s(e=document){let t=[];for(let r of n(e,`toggle`))o.has(r)||(o.add(r),t.push(a(r)));return t}export{s as create,a as createToggle};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@data-slot/toggle",
3
- "version": "0.2.31",
3
+ "version": "0.2.32",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.cjs",
File without changes
File without changes