@radix-ui/react-label
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -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=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; | ||
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; | ||
//# 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,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; | ||
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; | ||
//# sourceMappingURL=index.module.js.map |
{ | ||
"name": "@radix-ui/react-label", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"license": "MIT", | ||
@@ -19,5 +19,5 @@ "source": "src/index.ts", | ||
"dependencies": { | ||
"@radix-ui/react-polymorphic": "0.0.3", | ||
"@radix-ui/react-primitive": "0.0.2", | ||
"@radix-ui/react-utils": "0.0.3", | ||
"@radix-ui/react-polymorphic": "0.0.4", | ||
"@radix-ui/react-primitive": "0.0.3", | ||
"@radix-ui/react-utils": "0.0.4", | ||
"@radix-ui/utils": "0.0.3" | ||
@@ -24,0 +24,0 @@ }, |
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
22088
+ Added@radix-ui/react-polymorphic@0.0.4(transitive)
+ Added@radix-ui/react-primitive@0.0.3(transitive)
+ Added@radix-ui/react-utils@0.0.4(transitive)
- Removed@radix-ui/react-polymorphic@0.0.3(transitive)
- Removed@radix-ui/react-primitive@0.0.2(transitive)
- Removed@radix-ui/react-utils@0.0.3(transitive)
Updated@radix-ui/react-utils@0.0.4