@radix-ui/react-label
Advanced tools
Comparing version 0.1.1-rc.1 to 0.1.1-rc.2
@@ -1,2 +0,2 @@ | ||
var e,t,r,n=require("@radix-ui/react-id").useId,i=require("@radix-ui/react-primitive").Primitive,o=require("@radix-ui/react-compose-refs").useComposedRefs,u=(e={},t=require("react"),Object.keys(t).forEach((function(r){"default"!==r&&"__esModule"!==r&&Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[r]}})})),e),s=(r=require("@babel/runtime/helpers/extends"))&&r.__esModule?r.default:r;const l=/*#__PURE__*/u.createContext(void 0),a=/*#__PURE__*/u.forwardRef(((e,t)=>{const{htmlFor:r,id:a,...d}=e,f=u.useRef(null),b=o(t,f),v=n(a);return u.useEffect((()=>{const e=f.current;if(e){const t=e=>{e.detail>1&&e.preventDefault()};return e.addEventListener("mousedown",t),()=>e.removeEventListener("mousedown",t)}}),[f]),u.useEffect((()=>{if(r){const e=document.getElementById(r),t=f.current;if(t&&e){const r=c(t,e),n=()=>e.getAttribute("aria-labelledby"),i=[n(),v].filter(Boolean).join(" ");return e.setAttribute("aria-labelledby",i),()=>{var t;r();const i=null===(t=n())||void 0===t?void 0:t.replace(v,"");""===i?e.removeAttribute("aria-labelledby"):i&&e.setAttribute("aria-labelledby",i)}}}}),[v,r]),/*#__PURE__*/u.createElement(l.Provider,{value:u.useMemo((()=>({id:v,ref:f})),[v])},/*#__PURE__*/u.createElement(i.span,s({role:"label",id:v},d,{ref:b})))}));exports.Label=a;function c(e,t){const r=e=>{const r=t.contains(e.target),n=!0===e.isTrusted;!r&&n&&(t.click(),t.focus())};return e.addEventListener("click",r),()=>e.removeEventListener("click",r)}exports.useLabelContext=e=>{const t=u.useContext(l);return u.useEffect((()=>{const r=null==t?void 0:t.ref.current;if(r&&e)return c(r,e)}),[t,e]),null==t?void 0:t.id};const d=a;exports.Root=d; | ||
var e,r,t,n=require("@radix-ui/react-id").useId,l=require("@radix-ui/react-primitive").Primitive,o=require("@radix-ui/react-compose-refs").useComposedRefs,u=(e={},r=require("react"),Object.keys(r).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return r[t]}})})),e),i=(t=require("@babel/runtime/helpers/extends"))&&t.__esModule?t.default:t;const a=/*#__PURE__*/u.createContext({id:void 0,controlRef:{current:null}}),c=/*#__PURE__*/u.forwardRef(((e,r)=>{const{htmlFor:t,id:c,...s}=e,d=u.useRef(null),f=u.useRef(null),b=o(r,f),v=n(c);return u.useEffect((()=>{if(t){const e=document.getElementById(t);if(f.current&&e){const r=()=>e.getAttribute("aria-labelledby"),t=[r(),v].filter(Boolean).join(" ");return e.setAttribute("aria-labelledby",t),d.current=e,()=>{var t;const n=null===(t=r())||void 0===t?void 0:t.replace(v,"");""===n?e.removeAttribute("aria-labelledby"):n&&e.setAttribute("aria-labelledby",n)}}}}),[v,t]),/*#__PURE__*/u.createElement(a.Provider,{value:u.useMemo((()=>({id:v,controlRef:d})),[v])},/*#__PURE__*/u.createElement(l.span,i({role:"label",id:v},s,{ref:b,onMouseDown:r=>{var t;null===(t=e.onMouseDown)||void 0===t||t.call(e,r),!r.defaultPrevented&&r.detail>1&&r.preventDefault()},onClick:r=>{var t;if(null===(t=e.onClick)||void 0===t||t.call(e,r),!d.current||r.defaultPrevented)return;const n=d.current.contains(r.target),l=!0===r.isTrusted;!n&&l&&(d.current.click(),d.current.focus())}})))}));exports.Label=c;exports.useLabelContext=e=>{const r=u.useContext(a),{controlRef:t}=r;return u.useEffect((()=>{e&&(t.current=e)}),[e,t]),r.id};const s=c;exports.Root=s; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import{useId as e}from"@radix-ui/react-id";import{Primitive as t}from"@radix-ui/react-primitive";import{useComposedRefs as r}from"@radix-ui/react-compose-refs";import*as o from"react";import n from"@babel/runtime/helpers/esm/extends";const i=/*#__PURE__*/o.createContext(void 0);export const Label=/*#__PURE__*/o.forwardRef(((a,s)=>{const{htmlFor:c,id:u,...d}=a,f=o.useRef(null),m=r(s,f),b=e(u);return o.useEffect((()=>{const e=f.current;if(e){const t=e=>{e.detail>1&&e.preventDefault()};return e.addEventListener("mousedown",t),()=>e.removeEventListener("mousedown",t)}}),[f]),o.useEffect((()=>{if(c){const e=document.getElementById(c),t=f.current;if(t&&e){const r=l(t,e),o=()=>e.getAttribute("aria-labelledby"),n=[o(),b].filter(Boolean).join(" ");return e.setAttribute("aria-labelledby",n),()=>{var t;r();const n=null===(t=o())||void 0===t?void 0:t.replace(b,"");""===n?e.removeAttribute("aria-labelledby"):n&&e.setAttribute("aria-labelledby",n)}}}}),[b,c]),/*#__PURE__*/o.createElement(i.Provider,{value:o.useMemo((()=>({id:b,ref:f})),[b])},/*#__PURE__*/o.createElement(t.span,n({role:"label",id:b},d,{ref:m})))}));/*#__PURE__*/export const useLabelContext=e=>{const t=o.useContext(i);return o.useEffect((()=>{const r=null==t?void 0:t.ref.current;if(r&&e)return l(r,e)}),[t,e]),null==t?void 0:t.id};function l(e,t){const r=e=>{const r=t.contains(e.target),o=!0===e.isTrusted;!r&&o&&(t.click(),t.focus())};return e.addEventListener("click",r),()=>e.removeEventListener("click",r)}export const Root=Label; | ||
import{useId as e}from"@radix-ui/react-id";import{Primitive as t}from"@radix-ui/react-primitive";import{useComposedRefs as r}from"@radix-ui/react-compose-refs";import*as o from"react";import l from"@babel/runtime/helpers/esm/extends";const n=/*#__PURE__*/o.createContext({id:void 0,controlRef:{current:null}});export const Label=/*#__PURE__*/o.forwardRef(((i,a)=>{const{htmlFor:u,id:c,...s}=i,d=o.useRef(null),f=o.useRef(null),m=r(a,f),b=e(c);return o.useEffect((()=>{if(u){const e=document.getElementById(u);if(f.current&&e){const t=()=>e.getAttribute("aria-labelledby"),r=[t(),b].filter(Boolean).join(" ");return e.setAttribute("aria-labelledby",r),d.current=e,()=>{var r;const o=null===(r=t())||void 0===r?void 0:r.replace(b,"");""===o?e.removeAttribute("aria-labelledby"):o&&e.setAttribute("aria-labelledby",o)}}}}),[b,u]),/*#__PURE__*/o.createElement(n.Provider,{value:o.useMemo((()=>({id:b,controlRef:d})),[b])},/*#__PURE__*/o.createElement(t.span,l({role:"label",id:b},s,{ref:m,onMouseDown:e=>{var t;null===(t=i.onMouseDown)||void 0===t||t.call(i,e),!e.defaultPrevented&&e.detail>1&&e.preventDefault()},onClick:e=>{var t;if(null===(t=i.onClick)||void 0===t||t.call(i,e),!d.current||e.defaultPrevented)return;const r=d.current.contains(e.target),o=!0===e.isTrusted;!r&&o&&(d.current.click(),d.current.focus())}})))}));/*#__PURE__*/export const useLabelContext=e=>{const t=o.useContext(n),{controlRef:r}=t;return o.useEffect((()=>{e&&(r.current=e)}),[e,r]),t.id};export const Root=Label; | ||
//# sourceMappingURL=index.module.js.map |
{ | ||
"name": "@radix-ui/react-label", | ||
"version": "0.1.1-rc.1", | ||
"version": "0.1.1-rc.2", | ||
"license": "MIT", | ||
@@ -22,3 +22,3 @@ "source": "src/index.ts", | ||
"@radix-ui/react-id": "0.1.0", | ||
"@radix-ui/react-primitive": "0.1.1-rc.1" | ||
"@radix-ui/react-primitive": "0.1.1-rc.2" | ||
}, | ||
@@ -25,0 +25,0 @@ "peerDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
0
19710
+ Added@radix-ui/react-primitive@0.1.1-rc.2(transitive)
- Removed@radix-ui/react-primitive@0.1.1-rc.1(transitive)