Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@radix-ui/react-label

Package Overview
Dependencies
Maintainers
5
Versions
171
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@radix-ui/react-label - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

3

dist/index.d.ts
import * as React from "react";
import { Primitive } from "@radix-ui/react-primitive";
import * as Polymorphic from "@radix-ui/react-polymorphic";
import { Merge } from "@radix-ui/utils";
declare const DEFAULT_TAG = "span";
type LabelOwnProps = Merge<Polymorphic.OwnProps<typeof Primitive>, {
type LabelOwnProps = Polymorphic.Merge<Polymorphic.OwnProps<typeof Primitive>, {
htmlFor?: string;

@@ -8,0 +7,0 @@ }>;

@@ -1,2 +0,2 @@

var e,r,t=require("@radix-ui/react-primitive").Primitive,n=require("@radix-ui/react-utils"),i=n.useId,u=n.useComposedRefs,o=require("@radix-ui/utils").getSelector,a=(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);function l(){return(l=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}function c(e,r){if(null==e)return{};var t,n,i=function(e,r){if(null==e)return{};var t,n,i={},u=Object.keys(e);for(n=0;n<u.length;n++)t=u[n],r.indexOf(t)>=0||(i[t]=e[t]);return i}(e,r);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(e);for(n=0;n<u.length;n++)t=u[n],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(i[t]=e[t])}return i}var f=a.createContext(void 0),s=a.forwardRef((function(e,r){var n=e.as,s=void 0===n?"span":n,v=e.selector,b=void 0===v?o("Label"):v,p=e.htmlFor,m=e.id,y=c(e,["as","selector","htmlFor","id"]),O=a.useRef(null),E=u(r,O),g="label-".concat(i()),x=m||g;return a.useEffect((function(){var e=O.current;if(e){var r=function(e){e.detail>1&&e.preventDefault()};return e.addEventListener("mousedown",r),function(){return e.removeEventListener("mousedown",r)}}}),[O]),a.useEffect((function(){if(p){var e=document.getElementById(p),r=O.current;if(r&&e){var t=d(r,e),n=function(){return e.getAttribute("aria-labelledby")},i=[n(),x].filter(Boolean).join(" ");return e.setAttribute("aria-labelledby",i),function(){var r;t();var i=null===(r=n())||void 0===r?void 0:r.replace(x,"");""===i?e.removeAttribute("aria-labelledby"):i&&e.setAttribute("aria-labelledby",i)}}}}),[x,p]),a.createElement(f.Provider,{value:a.useMemo((function(){return{id:x,ref:O}}),[x])},a.createElement(t,l({},y,{as:s,selector:b,ref:E,id:x,role:"label"})))}));exports.Label=s,s.displayName="Label";function d(e,r){var t=function(e){r.contains(e.target)||(r.click(),r.focus())};return e.addEventListener("click",t),function(){return e.removeEventListener("click",t)}}exports.useLabelContext=function(e){var r=a.useContext(f);return a.useEffect((function(){var t=null==r?void 0:r.ref.current,n=null==e?void 0:e.current;if(t&&n)return d(t,n)}),[r,e]),null==r?void 0:r.id};var v=s;exports.Root=v;
var e,r,t=require("@radix-ui/react-id").useId,n=require("@radix-ui/react-primitive").Primitive,i=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);function o(){return(o=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}function a(e,r){if(null==e)return{};var t,n,i=function(e,r){if(null==e)return{};var t,n,i={},u=Object.keys(e);for(n=0;n<u.length;n++)t=u[n],r.indexOf(t)>=0||(i[t]=e[t]);return i}(e,r);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(e);for(n=0;n<u.length;n++)t=u[n],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(i[t]=e[t])}return i}var l=u.createContext(void 0),c=u.forwardRef((function(e,r){var c=e.as,s=void 0===c?"span":c,d=e.htmlFor,v=e.id,b=a(e,["as","htmlFor","id"]),p=u.useRef(null),m=i(r,p),y=t(v);return u.useEffect((function(){var e=p.current;if(e){var r=function(e){e.detail>1&&e.preventDefault()};return e.addEventListener("mousedown",r),function(){return e.removeEventListener("mousedown",r)}}}),[p]),u.useEffect((function(){if(d){var e=document.getElementById(d),r=p.current;if(r&&e){var t=f(r,e),n=function(){return e.getAttribute("aria-labelledby")},i=[n(),y].filter(Boolean).join(" ");return e.setAttribute("aria-labelledby",i),function(){var r;t();var i=null===(r=n())||void 0===r?void 0:r.replace(y,"");""===i?e.removeAttribute("aria-labelledby"):i&&e.setAttribute("aria-labelledby",i)}}}}),[y,d]),u.createElement(l.Provider,{value:u.useMemo((function(){return{id:y,ref:p}}),[y])},u.createElement(n,o({role:"label",id:y},b,{as:s,ref:m})))}));exports.Label=c,c.displayName="Label";function f(e,r){var t=function(e){r.contains(e.target)||(r.click(),r.focus())};return e.addEventListener("click",t),function(){return e.removeEventListener("click",t)}}exports.useLabelContext=function(e){var r=u.useContext(l);return u.useEffect((function(){var t=null==r?void 0:r.ref.current,n=null==e?void 0:e.current;if(t&&n)return f(t,n)}),[r,e]),null==r?void 0:r.id};var s=c;exports.Root=s;
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

import{Primitive as e}from"@radix-ui/react-primitive";import{useId as t,useComposedRefs as r}from"@radix-ui/react-utils";import{getSelector as n}from"@radix-ui/utils";import*as o from"react";function l(){return(l=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function i(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},l=Object.keys(e);for(n=0;n<l.length;n++)r=l[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)r=l[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}const a="Label",c="span",u=o.createContext(void 0);export const Label=o.forwardRef(((f,d)=>{const{as:b=c,selector:m=n(a),htmlFor:v,id:p}=f,y=i(f,["as","selector","htmlFor","id"]),x=o.useRef(null),E=r(d,x),O="label-".concat(t()),L=p||O;return o.useEffect((()=>{const e=x.current;if(e){const t=e=>{e.detail>1&&e.preventDefault()};return e.addEventListener("mousedown",t),()=>e.removeEventListener("mousedown",t)}}),[x]),o.useEffect((()=>{if(v){const e=document.getElementById(v),t=x.current;if(t&&e){const r=s(t,e),n=()=>e.getAttribute("aria-labelledby"),o=[n(),L].filter(Boolean).join(" ");return e.setAttribute("aria-labelledby",o),()=>{var t;r();const o=null===(t=n())||void 0===t?void 0:t.replace(L,"");""===o?e.removeAttribute("aria-labelledby"):o&&e.setAttribute("aria-labelledby",o)}}}}),[L,v]),o.createElement(u.Provider,{value:o.useMemo((()=>({id:L,ref:x})),[L])},o.createElement(e,l({},y,{as:b,selector:m,ref:E,id:L,role:"label"})))}));Label.displayName="Label";export const useLabelContext=e=>{const t=o.useContext(u);return o.useEffect((()=>{const r=null==t?void 0:t.ref.current,n=null==e?void 0:e.current;if(r&&n)return s(r,n)}),[t,e]),null==t?void 0:t.id};function s(e,t){const r=e=>{t.contains(e.target)||(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 n from"react";function o(){return(o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}const i="span",a=n.createContext(void 0);export const Label=n.forwardRef(((c,s)=>{const{as:u=i,htmlFor:d,id:f,...m}=c,v=n.useRef(null),b=r(s,v),p=e(f);return n.useEffect((()=>{const e=v.current;if(e){const t=e=>{e.detail>1&&e.preventDefault()};return e.addEventListener("mousedown",t),()=>e.removeEventListener("mousedown",t)}}),[v]),n.useEffect((()=>{if(d){const e=document.getElementById(d),t=v.current;if(t&&e){const r=l(t,e),n=()=>e.getAttribute("aria-labelledby"),o=[n(),p].filter(Boolean).join(" ");return e.setAttribute("aria-labelledby",o),()=>{var t;r();const o=null===(t=n())||void 0===t?void 0:t.replace(p,"");""===o?e.removeAttribute("aria-labelledby"):o&&e.setAttribute("aria-labelledby",o)}}}}),[p,d]),n.createElement(a.Provider,{value:n.useMemo((()=>({id:p,ref:v})),[p])},n.createElement(t,o({role:"label",id:p},m,{as:u,ref:b})))}));Label.displayName="Label";export const useLabelContext=e=>{const t=n.useContext(a);return n.useEffect((()=>{const r=null==t?void 0:t.ref.current,n=null==e?void 0:e.current;if(r&&n)return l(r,n)}),[t,e]),null==t?void 0:t.id};function l(e,t){const r=e=>{t.contains(e.target)||(t.click(),t.focus())};return e.addEventListener("click",r),()=>e.removeEventListener("click",r)}export const Root=Label;
//# sourceMappingURL=index.module.js.map
{
"name": "@radix-ui/react-label",
"version": "0.0.5",
"version": "0.0.6",
"license": "MIT",

@@ -19,6 +19,6 @@ "source": "src/index.ts",

"dependencies": {
"@radix-ui/react-polymorphic": "0.0.5",
"@radix-ui/react-primitive": "0.0.4",
"@radix-ui/react-utils": "0.0.5",
"@radix-ui/utils": "0.0.3"
"@radix-ui/react-compose-refs": "0.0.1",
"@radix-ui/react-id": "0.0.1",
"@radix-ui/react-polymorphic": "0.0.6",
"@radix-ui/react-primitive": "0.0.5"
},

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc