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

react-floating-label-wrapper

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-floating-label-wrapper - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

dist/utils/judgeHasValue.d.ts

2

dist/floating-label-wrapper.d.ts

@@ -20,5 +20,5 @@ import React, { ElementType } from 'react';

};
valueGetter?: () => any;
judgeHasValue?: () => boolean;
};
declare const FloatingLabelWrapper: (props: FloatingLabelWrapperProps) => JSX.Element;
export { FloatingLabelWrapper };

@@ -29,2 +29,20 @@ 'use strict';

function judgeHasValue(value) {
var hasValue = false;
if (value === undefined || value === null) {
return hasValue;
}
if (Array.isArray(value)) {
hasValue = value.length > 0;
} else if (typeof value === 'object') {
hasValue = Object.keys(value).length > 0;
} else {
hasValue = value !== undefined && value !== null && value !== '';
}
return hasValue;
}
var defaultVariables = {

@@ -72,3 +90,4 @@ '--input-padding-y': '1em',

component = props.component,
valueGetter = props.valueGetter,
_props$judgeHasValue = props.judgeHasValue,
judgeHasValue$1 = _props$judgeHasValue === void 0 ? judgeHasValue : _props$judgeHasValue,
_props$cssVariables = props.cssVariables,

@@ -91,4 +110,5 @@ cssVariables = _props$cssVariables === void 0 ? {} : _props$cssVariables,

var value = valueGetter && typeof valueGetter === 'function' ? valueGetter() : childrenOriginProps[(_inputPropsName$value = inputPropsName.value) != null ? _inputPropsName$value : defaultInputPropsName.value];
if (!value) return isFocused;
var value = childrenOriginProps[(_inputPropsName$value = inputPropsName.value) != null ? _inputPropsName$value : defaultInputPropsName.value];
var hasValue = judgeHasValue$1(value);
if (!hasValue) return isFocused;
return true;

@@ -102,4 +122,4 @@ }, [isFocused, inputPropsName.value, childrenOriginProps]);

if (!childrenOriginProps.hasOwnProperty(inputPropsName.value) && !props.valueGetter) {
warning("children props error, children be must have correct value prop (for controlled component) or valueGetter (for uncontrolled component), current value prop is '" + inputPropsName.value + "'") ;
if (!childrenOriginProps.hasOwnProperty(inputPropsName.value)) {
warning("children props error, children be must be controlled component and have correct value prop , current value prop is '" + inputPropsName.value + "'") ;
return children;

@@ -106,0 +126,0 @@ }

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

"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var n=e(require("classnames")),l=require("react"),t=e(l);function r(){return(r=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var l=arguments[n];for(var t in l)Object.prototype.hasOwnProperty.call(l,t)&&(e[t]=l[t])}return e}).apply(this,arguments)}var a={"--input-padding-y":"1em","--input-padding-x":"0.6em","--floating-label-padding-left":"0.3em","--floating-label-padding-right":"0.5em","--floating-label-font-size":"0.9em","--floating-label-font-size--floating":"0.75em","--floating-label-color":"rgba(0, 0, 0, 0.5)","--active-color":"rgb(43, 116, 226)"},o=function(e){var o,u,i,c,s=e.children,f=e.className,p=void 0===f?"":f,v=e.style,d=void 0===v?{}:v,g=e.label,b=e.component,m=e.valueGetter,y=e.cssVariables,h=void 0===y?{}:y,B=e.inputPropsName,F=void 0===B?{value:"value",onFocus:"onFocus",onBlur:"onBlur"}:B,O=s.props,w=l.useState(!1),j=w[0],x=w[1],E=l.useMemo((function(){var e;return!!(m&&"function"==typeof m?m():O[null!=(e=F.value)?e:"value"])||j}),[j,F.value,O]);if(!function(e){try{var n=t.Children.only(e);return t.isValidElement(n)}catch(e){return!1}}(s))return s;if(!O.hasOwnProperty(F.value)&&!e.valueGetter)return s;var N=r({},O,((i={})[null!=(o=F.onFocus)?o:"onFocus"]=function(e){var n,l;x(!0),null==(n=O[null!=(l=F.onFocus)?l:"onFocus"])||n.call(O,e)},i[null!=(u=F.onBlur)?u:"onBlur"]=function(e){var n,l;x(!1),null==(n=O[null!=(l=F.onBlur)?l:"onBlur"])||n.call(O,e)},i));return t.createElement(b||"div",{className:n("floating-label-wrapper",(c={},c[p]=p,c["float-label-wrapper--focus"]=j,c)),style:r({},a,h,d)},t.createElement("label",{className:n("floating-label",{"floating-label--float":E})},g),t.cloneElement(s,N))};function u(e){var n=new Map;return function(){for(var l=arguments.length,t=new Array(l),r=0;r<l;r++)t[r]=arguments[r];var a=JSON.stringify(t);if(n.has(a))return n.get(a);var o=e.apply(Function,t);return n.set(a,o),o}}exports.Bind=u((function(e){return function(n){var l=r({},e,n);return t.createElement(o,Object.assign({},l))}})),exports.default=o,exports.defaultVariables=a;
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var n=e(require("classnames")),l=require("react"),r=e(l);function t(){return(t=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var l=arguments[n];for(var r in l)Object.prototype.hasOwnProperty.call(l,r)&&(e[r]=l[r])}return e}).apply(this,arguments)}function a(e){var n=!1;return null==e?n:n=Array.isArray(e)?e.length>0:"object"==typeof e?Object.keys(e).length>0:null!=e&&""!==e}var o={"--input-padding-y":"1em","--input-padding-x":"0.6em","--floating-label-padding-left":"0.3em","--floating-label-padding-right":"0.5em","--floating-label-font-size":"0.9em","--floating-label-font-size--floating":"0.75em","--floating-label-color":"rgba(0, 0, 0, 0.5)","--active-color":"rgb(43, 116, 226)"},u=function(e){var u,i,c,s,f=e.children,p=e.className,v=void 0===p?"":p,d=e.style,g=void 0===d?{}:d,b=e.label,m=e.component,y=e.judgeHasValue,h=void 0===y?a:y,j=e.cssVariables,O=void 0===j?{}:j,B=e.inputPropsName,F=void 0===B?{value:"value",onFocus:"onFocus",onBlur:"onBlur"}:B,w=f.props,x=l.useState(!1),E=x[0],N=x[1],P=l.useMemo((function(){var e,n=w[null!=(e=F.value)?e:"value"];return!!h(n)||E}),[E,F.value,w]);if(!function(e){try{var n=r.Children.only(e);return r.isValidElement(n)}catch(e){return!1}}(f))return f;if(!w.hasOwnProperty(F.value))return f;var V=t({},w,((c={})[null!=(u=F.onFocus)?u:"onFocus"]=function(e){var n,l;N(!0),null==(n=w[null!=(l=F.onFocus)?l:"onFocus"])||n.call(w,e)},c[null!=(i=F.onBlur)?i:"onBlur"]=function(e){var n,l;N(!1),null==(n=w[null!=(l=F.onBlur)?l:"onBlur"])||n.call(w,e)},c));return r.createElement(m||"div",{className:n("floating-label-wrapper",(s={},s[v]=v,s["float-label-wrapper--focus"]=E,s)),style:t({},o,O,g)},r.createElement("label",{className:n("floating-label",{"floating-label--float":P})},b),r.cloneElement(f,V))};function i(e){var n=new Map;return function(){for(var l=arguments.length,r=new Array(l),t=0;t<l;t++)r[t]=arguments[t];var a=JSON.stringify(r);if(n.has(a))return n.get(a);var o=e.apply(Function,r);return n.set(a,o),o}}exports.Bind=i((function(e){return function(n){var l=t({},e,n);return r.createElement(u,Object.assign({},l))}})),exports.default=u,exports.defaultVariables=o;
//# sourceMappingURL=react-floating-label-wrapper.cjs.production.min.js.map

@@ -22,2 +22,20 @@ import classNames from 'classnames';

function judgeHasValue(value) {
var hasValue = false;
if (value === undefined || value === null) {
return hasValue;
}
if (Array.isArray(value)) {
hasValue = value.length > 0;
} else if (typeof value === 'object') {
hasValue = Object.keys(value).length > 0;
} else {
hasValue = value !== undefined && value !== null && value !== '';
}
return hasValue;
}
var defaultVariables = {

@@ -67,3 +85,4 @@ '--input-padding-y': '1em',

component = props.component,
valueGetter = props.valueGetter,
_props$judgeHasValue = props.judgeHasValue,
judgeHasValue$1 = _props$judgeHasValue === void 0 ? judgeHasValue : _props$judgeHasValue,
_props$cssVariables = props.cssVariables,

@@ -86,4 +105,5 @@ cssVariables = _props$cssVariables === void 0 ? {} : _props$cssVariables,

var value = valueGetter && typeof valueGetter === 'function' ? valueGetter() : childrenOriginProps[(_inputPropsName$value = inputPropsName.value) != null ? _inputPropsName$value : defaultInputPropsName.value];
if (!value) return isFocused;
var value = childrenOriginProps[(_inputPropsName$value = inputPropsName.value) != null ? _inputPropsName$value : defaultInputPropsName.value];
var hasValue = judgeHasValue$1(value);
if (!hasValue) return isFocused;
return true;

@@ -97,4 +117,4 @@ }, [isFocused, inputPropsName.value, childrenOriginProps]);

if (!childrenOriginProps.hasOwnProperty(inputPropsName.value) && !props.valueGetter) {
process.env.NODE_ENV !== "production" ? warning("children props error, children be must have correct value prop (for controlled component) or valueGetter (for uncontrolled component), current value prop is '" + inputPropsName.value + "'") : void 0;
if (!childrenOriginProps.hasOwnProperty(inputPropsName.value)) {
process.env.NODE_ENV !== "production" ? warning("children props error, children be must be controlled component and have correct value prop , current value prop is '" + inputPropsName.value + "'") : void 0;
return children;

@@ -101,0 +121,0 @@ }

{
"version": "0.1.5",
"version": "0.1.6",
"license": "MIT",

@@ -4,0 +4,0 @@ "main": "dist/index.js",

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

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