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.2 to 0.0.3

13

dist/index.d.ts
import * as React from "react";
type LabelOwnProps = {
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>, {
htmlFor?: string;
};
export const Label: import("@radix-ui/react-polymorphic").ForwardRefExoticComponentWithAs<"span", LabelOwnProps>;
}>;
type LabelPrimitive = Polymorphic.ForwardRefComponent<typeof DEFAULT_TAG, LabelOwnProps>;
export const Label: LabelPrimitive;
export const useLabelContext: <E extends HTMLElement>(ref?: React.RefObject<E> | undefined) => string | undefined;
export const Root: import("@radix-ui/react-polymorphic").ForwardRefExoticComponentWithAs<"span", LabelOwnProps>;
export const Root: LabelPrimitive;
//# sourceMappingURL=index.d.ts.map

@@ -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.htmlFor,s=e.id,v=e.children,b=c(e,["htmlFor","id","children"]),p=a.useRef(null),m=u(r,p),y="label-".concat(i()),O=s||y;return a.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]),a.useEffect((function(){if(n){var e=document.getElementById(n),r=p.current;if(r&&e){var t=d(r,e),i=function(){return e.getAttribute("aria-labelledby")},u=[i(),O].filter(Boolean).join(" ");return e.setAttribute("aria-labelledby",u),function(){var r;t();var n=null===(r=i())||void 0===r?void 0:r.replace(O,"");""===n?e.removeAttribute("aria-labelledby"):n&&e.setAttribute("aria-labelledby",n)}}}}),[O,n]),a.createElement(t,l({as:"span",selector:o("Label")},b,{ref:m,id:O,role:"label"}),a.createElement(f.Provider,{value:a.useMemo((function(){return{id:O,ref:p}}),[O])},v))}));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-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=e.children,O=c(e,["as","selector","htmlFor","id","children"]),E=a.useRef(null),g=u(r,E),x="label-".concat(i()),h=m||x;return a.useEffect((function(){var e=E.current;if(e){var r=function(e){e.detail>1&&e.preventDefault()};return e.addEventListener("mousedown",r),function(){return e.removeEventListener("mousedown",r)}}}),[E]),a.useEffect((function(){if(p){var e=document.getElementById(p),r=E.current;if(r&&e){var t=d(r,e),n=function(){return e.getAttribute("aria-labelledby")},i=[n(),h].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(h,"");""===i?e.removeAttribute("aria-labelledby"):i&&e.setAttribute("aria-labelledby",i)}}}}),[h,p]),a.createElement(t,l({},O,{as:s,selector:b,ref:g,id:h,role:"label"}),a.createElement(f.Provider,{value:a.useMemo((function(){return{id:h,ref:E}}),[h])},y))}));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;
//# 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=o.createContext(void 0);export const Label=o.forwardRef(((u,s)=>{const{htmlFor:f,id:d,children:b}=u,m=i(u,["htmlFor","id","children"]),v=o.useRef(null),p=r(s,v),y="label-".concat(t()),x=d||y;return o.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]),o.useEffect((()=>{if(f){const e=document.getElementById(f),t=v.current;if(t&&e){const r=c(t,e),n=()=>e.getAttribute("aria-labelledby"),o=[n(),x].filter(Boolean).join(" ");return e.setAttribute("aria-labelledby",o),()=>{var t;r();const o=null===(t=n())||void 0===t?void 0:t.replace(x,"");""===o?e.removeAttribute("aria-labelledby"):o&&e.setAttribute("aria-labelledby",o)}}}}),[x,f]),o.createElement(e,l({as:"span",selector:n("Label")},m,{ref:p,id:x,role:"label"}),o.createElement(a.Provider,{value:o.useMemo((()=>({id:x,ref:v})),[x])},b))}));Label.displayName="Label";export const useLabelContext=e=>{const t=o.useContext(a);return o.useEffect((()=>{const r=null==t?void 0:t.ref.current,n=null==e?void 0:e.current;if(r&&n)return c(r,n)}),[t,e]),null==t?void 0:t.id};function c(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{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,children:y}=f,x=i(f,["as","selector","htmlFor","id","children"]),E=o.useRef(null),O=r(d,E),L="label-".concat(t()),g=p||L;return o.useEffect((()=>{const e=E.current;if(e){const t=e=>{e.detail>1&&e.preventDefault()};return e.addEventListener("mousedown",t),()=>e.removeEventListener("mousedown",t)}}),[E]),o.useEffect((()=>{if(v){const e=document.getElementById(v),t=E.current;if(t&&e){const r=s(t,e),n=()=>e.getAttribute("aria-labelledby"),o=[n(),g].filter(Boolean).join(" ");return e.setAttribute("aria-labelledby",o),()=>{var t;r();const o=null===(t=n())||void 0===t?void 0:t.replace(g,"");""===o?e.removeAttribute("aria-labelledby"):o&&e.setAttribute("aria-labelledby",o)}}}}),[g,v]),o.createElement(e,l({},x,{as:b,selector:m,ref:O,id:g,role:"label"}),o.createElement(u.Provider,{value:o.useMemo((()=>({id:g,ref:E})),[g])},y))}));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;
//# sourceMappingURL=index.module.js.map
{
"name": "@radix-ui/react-label",
"version": "0.0.2",
"version": "0.0.3",
"license": "MIT",

@@ -15,12 +15,10 @@ "source": "src/index.ts",

"scripts": {
"build": "parcel build src/index.ts --no-cache",
"clean": "rm -rf dist",
"version": "yarn version",
"prepublish": "yarn clean && yarn build"
"prepublish": "yarn clean"
},
"dependencies": {
"@radix-ui/react-polymorphic": "0.0.2",
"@radix-ui/react-primitive": "0.0.1",
"@radix-ui/react-utils": "0.0.2",
"@radix-ui/utils": "0.0.2"
"@radix-ui/react-polymorphic": "0.0.3",
"@radix-ui/react-primitive": "0.0.2",
"@radix-ui/react-utils": "0.0.3",
"@radix-ui/utils": "0.0.3"
},

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