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

@entur/form

Package Overview
Dependencies
Maintainers
0
Versions
215
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@entur/form - npm Package Compare versions

Comparing version 8.1.0-beta.0 to 8.1.0-beta.1

1

dist/form.cjs.development.js

@@ -208,3 +208,2 @@ 'use strict';

var currentVariant = variant || contextVariant;
console.log('baseF', labelTooltipPlacement);
return React.createElement(InputGroupContextProvider, null, React.createElement("div", {

@@ -211,0 +210,0 @@ className: classNames('eds-form-control__field-and-feedback-text', className, {

2

dist/form.cjs.production.min.js

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@entur/utils"),a=require("react"),l=require("classnames"),n=require("@entur/icons"),t=require("@entur/tooltip"),r=require("@entur/button"),i=require("@entur/typography"),o=require("@entur/tokens");function d(e){var a=Object.create(null);return e&&Object.keys(e).forEach((function(l){if("default"!==l){var n=Object.getOwnPropertyDescriptor(e,l);Object.defineProperty(a,l,n.get?n:{enumerable:!0,get:function(){return e[l]}})}})),a.default=e,a}var c=d(a);function s(){return s=Object.assign?Object.assign.bind():function(e){for(var a=1;a<arguments.length;a++){var l=arguments[a];for(var n in l)Object.prototype.hasOwnProperty.call(l,n)&&(e[n]=l[n])}return e},s.apply(this,arguments)}function u(e,a){if(null==e)return{};var l,n,t={},r=Object.keys(e);for(n=0;n<r.length;n++)a.indexOf(l=r[n])>=0||(t[l]=e[l]);return t}var m=["children","hideIcon","variant","className"],b=function(e){var l=e.variant,t="eds-feedback-text__icon eds-feedback-text__icon--"+l;switch(l){case"success":return a.createElement(n.ValidationSuccessFilledIcon,{"aria-label":"Suksessmelding",className:t});case"negative":case"error":return a.createElement(n.ValidationErrorFilledIcon,{"aria-label":"Feilmelding",className:t});case"information":default:return null;case"warning":return a.createElement(n.ValidationExclamationFilledIcon,{"aria-label":"Varselmelding",className:t})}},p=function(e){var n=e.children,t=e.hideIcon,r=void 0!==t&&t,o=e.variant,d=e.className,c=u(e,m);return a.createElement(i.SubLabel,s({className:l("eds-feedback-text",{"eds-feedback-text--information":"info"===o||"information"===o},d)},c),!r&&a.createElement(b,{variant:o}),a.createElement("span",{className:"eds-feedback-text__text"},n))},f=c.createContext({isFilled:!1,setFilled:function(){return null}}),v=function(e){var a=e.children,l=c.useState(!1);return c.createElement(f.Provider,{value:{isFilled:l[0],setFilled:l[1]}},a)},h=function(){return c.useContext(f)},g=["label","required","labelId","staticAnimation"],E=function(e){var n=e.label,t=e.required,r=e.labelId,i=e.staticAnimation,o=void 0!==i&&i,d=u(e,g),c=h(),m=o||c.isFilled;return a.createElement("label",s({className:l(d.className,{"eds-input-group-label-wrapper--filled":m}),id:r},d),a.createElement("span",{className:l("eds-input-group__label",{"eds-input-group__label--filled":m})},n," ",t&&a.createElement("span",null,"*")))},y=a.createContext(null),C=function(){return a.useContext(y)},_=["children","className","disabled","readOnly","variant","prepend","append","size","isFilled","label","required","labelTooltip","labelTooltipButtonAriaLabel","labelTooltipPlacement","feedback","labelId","labelProps","style","disableLabelAnimation","ariaAlertOnFeedback"],x=a.forwardRef((function(e,i){var o=e.children,d=e.className,c=e.disabled,m=void 0!==c&&c,b=e.readOnly,f=void 0!==b&&b,h=e.variant,g=e.prepend,y=e.append,x=e.size,k=void 0===x?"medium":x,N=e.isFilled,w=e.label,O=e.required,I=e.labelTooltip,F=e.labelTooltipButtonAriaLabel,L=void 0===F?"Klikk for tilleggsinfo om feltet":F,R=e.labelTooltipPlacement,A=void 0===R?"top":R,P=e.feedback,T=e.labelId,z=e.labelProps,S=e.style,V=e.disableLabelAnimation,q=void 0!==V&&V,B=e.ariaAlertOnFeedback,j=void 0!==B&&B,M=u(e,_),G=C(),H=h||G;return console.log("baseF",A),a.createElement(v,null,a.createElement("div",{className:l("eds-form-control__field-and-feedback-text",d,{"eds-form-control__field-and-feedback-text--has-tooltip":void 0!==I}),style:S},a.createElement("div",s({className:l("eds-form-control-wrapper","eds-form-control-wrapper--size-"+k,{"eds-form-control-wrapper--success":"success"===H,"eds-form-control-wrapper--negative":"negative"===H||"error"===H,"eds-form-control-wrapper--disabled":m,"eds-form-control-wrapper--readonly":f,"eds-form-control-wrapper--is-filled":N}),ref:i},M),g&&a.createElement("div",{className:"eds-form-control__prepend"},g),a.createElement(E,s({label:w,required:O,labelId:T,staticAnimation:q},z)),I&&a.createElement(t.Tooltip,{content:I,placement:A,showCloseButton:!1,disableFocusListener:!0,disableHoverListener:!0,disableClickListner:!1,disableKeyboardListener:!1},a.createElement(r.IconButton,{as:"span",tabIndex:0,role:"button",className:"eds-form-control__append eds-form-control__append--tooltip","aria-label":L},a.createElement(n.QuestionIcon,{className:"eds-input-group__label-tooltip-icon","aria-hidden":"true"}))),o,y&&a.createElement("div",{className:"eds-form-control__append"},y)),P&&H&&a.createElement(p,{variant:H,role:j?"alert":void 0},P)))})),k=["checked","className","children","style","disabled","reduceClickArea"],N=a.forwardRef((function(n,t){var r=n.checked,o=n.className,d=n.children,c=n.style,m=n.disabled,b=void 0!==m&&m,p=n.reduceClickArea,f=u(n,k),v=a.useRef(null),h="indeterminate"===r,g=void 0!==r;return a.useEffect((function(){v&&v.current&&(v.current.indeterminate=h)}),[h]),a.createElement("label",{className:l("eds-checkbox__container",o,{"eds-checkbox--disabled":b,"eds-checkbox__container--reduced-click-area":p}),style:c},a.createElement("input",s({type:"checkbox",ref:e.mergeRefs(t,v),checked:g?!0===r:void 0,disabled:b},f)),a.createElement("span",{className:l("eds-checkbox__icon",{"eds-checkbox__icon--disabled":b,"eds-checkbox__icon--reduced-click-area":p})},a.createElement(w,{indeterminate:h})),d&&a.createElement(i.Paragraph,{className:"eds-checkbox__label",margin:"none",as:"span"},d))})),w=function(e){var l=e.indeterminate;return a.createElement("svg",{className:"eds-checkbox-icon",width:"11px",height:"9px",viewBox:"6 11 37 33","aria-hidden":!0},void 0!==l&&l?a.createElement("rect",{x:"10",y:"25",width:"28",height:"5",fill:"white"}):a.createElement("path",{d:"M14.1 27.2l7.1 7.2 14.6-14.8",fill:"none"}))},O=["children","className","label"],I=function(e){var n=e.children,t=e.className,r=e.label,o=u(e,O);return a.createElement("fieldset",s({className:l("eds-fieldset",t)},o),r&&a.createElement(i.Heading5,{as:"legend"},r),n)},F=a.createContext(null),L=F.Provider,R=function(){var e=a.useContext(F);if(!e)throw new Error("You need to wrap your RadioButtons in a RadioGroup component");return e},A=["className","children","value","disabled"],P=a.forwardRef((function(e,n){var t,r,o,d=e.className,c=e.children,m=e.value,b=e.disabled,p=u(e,A),f=l(d,"eds-form-component--radio__radio",{"eds-form-component--radio__radio--disabled":b}),v=R();return a.createElement("label",{className:"eds-form-component--radio__container"},a.createElement("input",s({type:"radio",name:null!=(t=p.name)?t:v.name,ref:n,value:m,checked:null!=(r=p.checked)?r:v.value===m,onChange:null!=(o=p.onChange)?o:v.onChange,disabled:b},p)),a.createElement("span",{className:f},a.createElement("span",{className:"eds-form-component--radio__circle"})),c&&a.createElement(i.Paragraph,{margin:"none",as:"span",className:"eds-form-component--radio__label"},c))})),T=["className","children","value","title","secondaryLabel","size","hideSelectionIndicator","style","id","disabled","type","onChange","checked","name"],z=a.forwardRef((function(n,t){var r,i,o,d,c=n.className,m=n.children,b=n.value,p=n.title,f=n.secondaryLabel,v=n.size,h=void 0===v?"medium":v,g=n.hideSelectionIndicator,E=void 0!==g&&g,y=n.style,C=n.id,_=n.disabled,x=void 0!==_&&_,k=n.type,w=void 0===k?"radio":k,O=n.onChange,I=n.checked,F=n.name,L=u(n,T),R=l(c,"eds-input-panel__container","eds-input-panel--"+h),A=a.useRef(null),z=e.useRandomId("eds-inputpanel"),S=C||z,V=e.useForceUpdate();return a.createElement("label",{className:"eds-input-panel",htmlFor:S},a.createElement("input",s({type:w,name:F,ref:e.mergeRefs(t,A),value:b,checked:I,onChange:function(e){void 0===O&&V(),null==O||O(e)},id:S,disabled:x},L)),a.createElement("div",{className:R,style:y},a.createElement("div",{className:"eds-input-panel__title-wrapper"},a.createElement("div",{className:"eds-input-panel__title"},p),a.createElement("div",{className:"eds-input-panel__secondary-label-and-icon-wrapper"},void 0!==f&&a.createElement(a.Fragment,null,f),a.createElement("span",{style:{pointerEvents:"none"}},!(x||E)&&("radio"===w?a.createElement(P,{name:"",value:"",checked:null!=(r=null!=I?I:null==(i=A.current)?void 0:i.checked)&&r,onChange:function(){},"aria-hidden":"true",tabIndex:-1}):a.createElement(N,{checked:null!=(o=null!=I?I:null==(d=A.current)?void 0:d.checked)&&o,onChange:function(){return null},"aria-hidden":"true",tabIndex:-1}))))),m&&a.createElement("div",{className:"eds-input-panel__additional-content"},m)))})),S=["className","children","value","title","secondaryLabel","size","hideRadioButton","style","id","disabled"],V=a.forwardRef((function(e,l){var n=e.className,t=e.children,r=e.value,i=e.title,o=e.secondaryLabel,d=e.size,c=void 0===d?"medium":d,m=e.hideRadioButton,b=void 0!==m&&m,p=e.style,f=e.id,v=e.disabled,h=void 0!==v&&v,g=u(e,S),E=R();return a.createElement(z,s({type:"radio",name:E.name,title:i,value:r,checked:E.value===r,onChange:E.onChange,className:n,secondaryLabel:o,size:c,hideSelectionIndicator:b,style:p,id:f,disabled:h},g,{ref:l}),t)})),q=["name","checked","onChange","className","children","value","title","secondaryLabel","size","hideCheckbox","style","id","disabled"],B=a.forwardRef((function(e,l){var n=e.name,t=e.checked,r=e.onChange,i=e.className,o=e.children,d=e.value,c=e.title,m=e.secondaryLabel,b=e.size,p=void 0===b?"medium":b,f=e.hideCheckbox,v=void 0!==f&&f,h=e.style,g=e.id,E=e.disabled,y=void 0!==E&&E,C=u(e,q);return a.createElement(z,s({type:"checkbox",name:n,title:c,value:d,checked:t,onChange:r,className:i,secondaryLabel:m,size:p,hideSelectionIndicator:v,style:h,id:g,disabled:y},C,{ref:l}),o)})),j=["name","value","children","onChange","label"],M=["className","children","labelPlacement","icon","hideIcon","color","contrastColor","size","checked"],G=a.forwardRef((function(e,t){var r=e.className,i=e.children,d=e.labelPlacement,c=void 0===d?"right":d,m=e.icon,b=e.hideIcon,p=void 0!==b&&b,f=e.color,v=void 0===f?o.colors.validation.mint:f,h=e.contrastColor,g=void 0===h?o.colors.validation.mintContrast:h,E=e.size,y=void 0===E?"medium":E,C=e.checked,_=u(e,M);return a.createElement("label",{className:l("eds-switch","eds-switch--"+c,r),style:s({},_.style)},a.createElement("input",s({type:"checkbox",ref:t,checked:C},_)),a.createElement("span",{className:l("eds-switch__switch","eds-switch__switch--"+y),style:{"--eds-switch-color":v,"--eds-switch-contrast-color":g},"aria-hidden":"true"},a.createElement("span",{className:"eds-switch__circle"},!p&&(m||(void 0===C?a.createElement(a.Fragment,null):a.createElement(C?n.CheckIcon:n.CloseSmallIcon,{size:"large"===y?23:void 0}))))),i&&a.createElement("span",{className:l("eds-switch__label","eds-switch__label--"+y+"--"+c)},i))}));function H(e){return null!=e&&!(Array.isArray(e)&&0===e.length)}function K(e,a){return void 0===a&&(a=!1),e&&(H(e.value)&&""!==e.value||a&&H(e.defaultValue)&&""!==e.defaultValue)}var Y=["variant","disabled","readOnly","className","style","label","feedback","labelTooltip","labelTooltipButtonAriaLabel","labelTooltipPlacement","onChange","disableLabelAnimation"],D=["readOnly","disabled","onChange","value","variant"],Q=a.forwardRef((function(n,t){var r=n.variant,i=n.disabled,o=void 0!==i&&i,d=n.readOnly,c=void 0!==d&&d,m=n.className,b=n.style,p=n.label,f=n.feedback,v=n.labelTooltip,h=n.labelTooltipButtonAriaLabel,g=n.labelTooltipPlacement,E=n.onChange,y=n.disableLabelAnimation,C=u(n,Y),_=e.useRandomId("eds-textarea"),k=a.useRef(null);return a.createElement(x,{className:l(m,"eds-textarea__wrapper"),disabled:o,readOnly:c,variant:r,style:b,label:p,labelId:_,feedback:f,labelTooltip:v,labelTooltipButtonAriaLabel:h,labelTooltipPlacement:g,labelProps:{className:"eds-textarea__label"},disableLabelAnimation:y,onClick:function(e){var a;e.target===e.currentTarget&&(null==k||null==(a=k.current)||a.focus())}},a.createElement(U,s({readOnly:c,disabled:o,ref:e.mergeRefs(t,k),"aria-labelledby":_,onChange:E,variant:r},C)))})),U=a.forwardRef((function(l,n){var t=l.readOnly,r=l.disabled,i=l.onChange,o=l.value,d=l.variant,c=u(l,D),m=C(),b=d||m,p=h(),f=p.isFilled,v=p.setFilled;return e.useOnMount((function(){(null!=o&&o.toString()||c.defaultValue)&&v&&!f&&v(!0)})),a.useEffect((function(){null!=o&&o.toString()&&v&&!f&&v(!0)}),[o,v,f]),a.createElement("textarea",s({className:"eds-form-control eds-textarea",ref:n,readOnly:t,disabled:r,onChange:function(e){K(e.target)?v&&!f&&v(!0):v&&f&&v(!1),i&&i(e)},value:o,"aria-invalid":"error"===b},c))})),J=["prepend","append","variant","disabled","readOnly","className","style","size","label","required","labelTooltip","labelTooltipButtonAriaLabel","labelTooltipPlacement","feedback","onChange","disableLabelAnimation","labelProps","clearable","onClear","value","ariaAlertOnFeedback"],W=["disabled","readOnly","placeholder","onChange","value","variant"],X=["onClear"],Z=a.forwardRef((function(n,t){var r=n.prepend,i=n.append,o=n.variant,d=n.disabled,c=void 0!==d&&d,m=n.readOnly,b=void 0!==m&&m,p=n.className,f=n.style,v=n.size,h=void 0===v?"medium":v,g=n.label,E=n.required,y=n.labelTooltip,C=n.labelTooltipButtonAriaLabel,_=n.labelTooltipPlacement,k=n.feedback,N=n.onChange,w=n.disableLabelAnimation,O=n.labelProps,I=n.clearable,F=void 0!==I&&I,L=n.onClear,R=n.value,A=n.ariaAlertOnFeedback,P=void 0!==A&&A,T=u(n,J),z=e.useRandomId("eds-textfield"),S=O&&O.id?O.id:z,V=a.useRef(null);return a.createElement(x,{disabled:c,readOnly:b,variant:o,prepend:r,append:F&&L?a.createElement(ee,{onClear:L}):i,className:l(p,"eds-textfield__wrapper"),style:f,size:h,label:g,required:E,labelTooltip:y,labelTooltipButtonAriaLabel:C,labelTooltipPlacement:_,labelId:S,feedback:k,disableLabelAnimation:w,labelProps:O,ariaAlertOnFeedback:P,onClick:function(e){var a;e.target===e.currentTarget&&(null==V||null==(a=V.current)||a.focus())}},a.createElement($,s({disabled:c,readOnly:b,ref:e.mergeRefs(t,V),"aria-labelledby":S,onChange:N,value:R,variant:o},T)))})),$=a.forwardRef((function(l,n){var t=l.disabled,r=l.readOnly,i=l.placeholder,o=l.onChange,d=l.value,c=l.variant,m=u(l,W),b=C(),p=c||b,f=h(),v=f.isFilled,g=f.setFilled;return e.useOnMount((function(){(null!=d&&d.toString()||m.defaultValue)&&g&&!v&&g(!0)})),a.useEffect((function(){null!=d&&d.toString()&&g&&!v&&g(!0)}),[d,g,v]),a.createElement("input",s({"aria-invalid":"error"===p,className:"eds-form-control",disabled:t,readOnly:r,ref:n,placeholder:i,onChange:function(e){K(e.target)?g&&!v&&g(!0):g&&v&&g(!1),o&&o(e)},value:d},m))})),ee=function(e){var l=e.onClear,t=u(e,X),r=h(),i=r.isFilled,o=r.setFilled;return a.createElement("div",{className:"eds-textfield__clear-button-wrapper"},i&&a.createElement("div",{className:"eds-textfield__divider"}),i&&a.createElement("button",s({className:"eds-textfield__clear-button",type:"button",tabIndex:-1,onClick:function(){o(!1),l()}},t),a.createElement(n.CloseSmallIcon,null)))},ae=["name","onChange","selectedValue","multiple","size"],le=a.createContext(null),ne=function(l){var n=l.name,t=l.onChange,r=void 0===t?function(){}:t,i=l.selectedValue,o=l.multiple,d=l.size,c=u(l,ae),m=e.useRandomId("eds-segmented-control"),b=a.useMemo((function(){return{name:n||m,onChange:r,multiple:o,selectedValue:i,size:d}}),[m,o,n,r,i,d]);return a.createElement(le.Provider,s({value:b},c))},te=["children","className","style","value","name","onChange"],re=a.forwardRef((function(e,n){var t=e.children,r=e.className,i=e.style,o=e.value,d=e.name,c=e.onChange,m=void 0===c?function(){}:c,b=u(e,te),p=function(){var e=a.useContext(le);if(!e)throw new Error("You need to wrap your SegmentedChoice in either SegmentedControl or MultipleSegmentedControl");return e}(),f=p.name,v=p.selectedValue,h=p.onChange,g=p.multiple,E=p.size,y=g?v[o]:v===o;return a.createElement("label",{className:l("eds-segmented-choice",r),style:i},a.createElement("input",s({type:g?"checkbox":"radio",name:d||f,checked:y,value:o,onChange:function(e){var a;m(e),g?h(s({},v,((a={})[o]=e.target.checked,a))):e.target.checked&&h(o)},ref:n},b)),a.createElement("div",{className:l("eds-base-segmented",{"eds-base-segmented--large":"large"===E})},t))})),ie=["children","label","name","onChange","selectedValue","size","className"],oe=["children","label","name","onChange","selectedValue"];e.warnAboutMissingStyles("form","icons","typography"),exports.BaseFormControl=x,exports.Checkbox=N,exports.CheckboxPanel=B,exports.FeedbackText=p,exports.Fieldset=I,exports.InputGroupContextProvider=v,exports.InputGroupLabel=E,exports.MultipleSegmentedControl=function(e){var l=e.children,n=e.label,t=e.name,r=e.onChange,o=e.selectedValue,d=u(e,oe);return a.createElement(ne,{name:t,selectedValue:o,onChange:r,multiple:!0,size:"medium"},a.createElement(i.Label,{as:"div"},n),a.createElement("div",s({className:"eds-segmented-control"},d),l))},exports.Radio=P,exports.RadioGroup=function(e){var l=e.name,n=e.value,t=e.children,r=e.onChange,i=e.label,o=u(e,j),d=a.useMemo((function(){return{name:l,value:n,onChange:r}}),[l,n,r]);return a.createElement(L,{value:d},i?a.createElement(I,s({label:i},o),t):t)},exports.RadioPanel=V,exports.SegmentedChoice=re,exports.SegmentedControl=function(e){var n=e.children,t=e.label,r=e.name,i=e.onChange,o=e.selectedValue,d=e.size,c=void 0===d?"medium":d,m=e.className,b=u(e,ie);return a.createElement(ne,{name:r,selectedValue:o,onChange:i,multiple:!1,size:c},a.createElement(I,{label:t},a.createElement("div",s({className:l("eds-segmented-control",m)},b),n)))},exports.Switch=G,exports.TextArea=Q,exports.TextField=Z,exports.VariantProvider=function(e){var l=e.variant;return a.createElement(y.Provider,{value:void 0===l?null:l},e.children)},exports.hasValue=H,exports.isFilled=K,exports.useInputGroupContext=h,exports.useVariant=C;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@entur/utils"),a=require("react"),l=require("classnames"),n=require("@entur/icons"),t=require("@entur/tooltip"),r=require("@entur/button"),i=require("@entur/typography"),o=require("@entur/tokens");function d(e){var a=Object.create(null);return e&&Object.keys(e).forEach((function(l){if("default"!==l){var n=Object.getOwnPropertyDescriptor(e,l);Object.defineProperty(a,l,n.get?n:{enumerable:!0,get:function(){return e[l]}})}})),a.default=e,a}var c=d(a);function s(){return s=Object.assign?Object.assign.bind():function(e){for(var a=1;a<arguments.length;a++){var l=arguments[a];for(var n in l)Object.prototype.hasOwnProperty.call(l,n)&&(e[n]=l[n])}return e},s.apply(this,arguments)}function u(e,a){if(null==e)return{};var l,n,t={},r=Object.keys(e);for(n=0;n<r.length;n++)a.indexOf(l=r[n])>=0||(t[l]=e[l]);return t}var m=["children","hideIcon","variant","className"],b=function(e){var l=e.variant,t="eds-feedback-text__icon eds-feedback-text__icon--"+l;switch(l){case"success":return a.createElement(n.ValidationSuccessFilledIcon,{"aria-label":"Suksessmelding",className:t});case"negative":case"error":return a.createElement(n.ValidationErrorFilledIcon,{"aria-label":"Feilmelding",className:t});case"information":default:return null;case"warning":return a.createElement(n.ValidationExclamationFilledIcon,{"aria-label":"Varselmelding",className:t})}},p=function(e){var n=e.children,t=e.hideIcon,r=void 0!==t&&t,o=e.variant,d=e.className,c=u(e,m);return a.createElement(i.SubLabel,s({className:l("eds-feedback-text",{"eds-feedback-text--information":"info"===o||"information"===o},d)},c),!r&&a.createElement(b,{variant:o}),a.createElement("span",{className:"eds-feedback-text__text"},n))},f=c.createContext({isFilled:!1,setFilled:function(){return null}}),v=function(e){var a=e.children,l=c.useState(!1);return c.createElement(f.Provider,{value:{isFilled:l[0],setFilled:l[1]}},a)},h=function(){return c.useContext(f)},g=["label","required","labelId","staticAnimation"],E=function(e){var n=e.label,t=e.required,r=e.labelId,i=e.staticAnimation,o=void 0!==i&&i,d=u(e,g),c=h(),m=o||c.isFilled;return a.createElement("label",s({className:l(d.className,{"eds-input-group-label-wrapper--filled":m}),id:r},d),a.createElement("span",{className:l("eds-input-group__label",{"eds-input-group__label--filled":m})},n," ",t&&a.createElement("span",null,"*")))},y=a.createContext(null),C=function(){return a.useContext(y)},_=["children","className","disabled","readOnly","variant","prepend","append","size","isFilled","label","required","labelTooltip","labelTooltipButtonAriaLabel","labelTooltipPlacement","feedback","labelId","labelProps","style","disableLabelAnimation","ariaAlertOnFeedback"],x=a.forwardRef((function(e,i){var o=e.children,d=e.className,c=e.disabled,m=void 0!==c&&c,b=e.readOnly,f=void 0!==b&&b,h=e.variant,g=e.prepend,y=e.append,x=e.size,k=void 0===x?"medium":x,N=e.isFilled,w=e.label,O=e.required,I=e.labelTooltip,F=e.labelTooltipButtonAriaLabel,L=void 0===F?"Klikk for tilleggsinfo om feltet":F,R=e.labelTooltipPlacement,A=void 0===R?"top":R,P=e.feedback,T=e.labelId,z=e.labelProps,S=e.style,V=e.disableLabelAnimation,q=void 0!==V&&V,B=e.ariaAlertOnFeedback,j=void 0!==B&&B,M=u(e,_),G=C(),H=h||G;return a.createElement(v,null,a.createElement("div",{className:l("eds-form-control__field-and-feedback-text",d,{"eds-form-control__field-and-feedback-text--has-tooltip":void 0!==I}),style:S},a.createElement("div",s({className:l("eds-form-control-wrapper","eds-form-control-wrapper--size-"+k,{"eds-form-control-wrapper--success":"success"===H,"eds-form-control-wrapper--negative":"negative"===H||"error"===H,"eds-form-control-wrapper--disabled":m,"eds-form-control-wrapper--readonly":f,"eds-form-control-wrapper--is-filled":N}),ref:i},M),g&&a.createElement("div",{className:"eds-form-control__prepend"},g),a.createElement(E,s({label:w,required:O,labelId:T,staticAnimation:q},z)),I&&a.createElement(t.Tooltip,{content:I,placement:A,showCloseButton:!1,disableFocusListener:!0,disableHoverListener:!0,disableClickListner:!1,disableKeyboardListener:!1},a.createElement(r.IconButton,{as:"span",tabIndex:0,role:"button",className:"eds-form-control__append eds-form-control__append--tooltip","aria-label":L},a.createElement(n.QuestionIcon,{className:"eds-input-group__label-tooltip-icon","aria-hidden":"true"}))),o,y&&a.createElement("div",{className:"eds-form-control__append"},y)),P&&H&&a.createElement(p,{variant:H,role:j?"alert":void 0},P)))})),k=["checked","className","children","style","disabled","reduceClickArea"],N=a.forwardRef((function(n,t){var r=n.checked,o=n.className,d=n.children,c=n.style,m=n.disabled,b=void 0!==m&&m,p=n.reduceClickArea,f=u(n,k),v=a.useRef(null),h="indeterminate"===r,g=void 0!==r;return a.useEffect((function(){v&&v.current&&(v.current.indeterminate=h)}),[h]),a.createElement("label",{className:l("eds-checkbox__container",o,{"eds-checkbox--disabled":b,"eds-checkbox__container--reduced-click-area":p}),style:c},a.createElement("input",s({type:"checkbox",ref:e.mergeRefs(t,v),checked:g?!0===r:void 0,disabled:b},f)),a.createElement("span",{className:l("eds-checkbox__icon",{"eds-checkbox__icon--disabled":b,"eds-checkbox__icon--reduced-click-area":p})},a.createElement(w,{indeterminate:h})),d&&a.createElement(i.Paragraph,{className:"eds-checkbox__label",margin:"none",as:"span"},d))})),w=function(e){var l=e.indeterminate;return a.createElement("svg",{className:"eds-checkbox-icon",width:"11px",height:"9px",viewBox:"6 11 37 33","aria-hidden":!0},void 0!==l&&l?a.createElement("rect",{x:"10",y:"25",width:"28",height:"5",fill:"white"}):a.createElement("path",{d:"M14.1 27.2l7.1 7.2 14.6-14.8",fill:"none"}))},O=["children","className","label"],I=function(e){var n=e.children,t=e.className,r=e.label,o=u(e,O);return a.createElement("fieldset",s({className:l("eds-fieldset",t)},o),r&&a.createElement(i.Heading5,{as:"legend"},r),n)},F=a.createContext(null),L=F.Provider,R=function(){var e=a.useContext(F);if(!e)throw new Error("You need to wrap your RadioButtons in a RadioGroup component");return e},A=["className","children","value","disabled"],P=a.forwardRef((function(e,n){var t,r,o,d=e.className,c=e.children,m=e.value,b=e.disabled,p=u(e,A),f=l(d,"eds-form-component--radio__radio",{"eds-form-component--radio__radio--disabled":b}),v=R();return a.createElement("label",{className:"eds-form-component--radio__container"},a.createElement("input",s({type:"radio",name:null!=(t=p.name)?t:v.name,ref:n,value:m,checked:null!=(r=p.checked)?r:v.value===m,onChange:null!=(o=p.onChange)?o:v.onChange,disabled:b},p)),a.createElement("span",{className:f},a.createElement("span",{className:"eds-form-component--radio__circle"})),c&&a.createElement(i.Paragraph,{margin:"none",as:"span",className:"eds-form-component--radio__label"},c))})),T=["className","children","value","title","secondaryLabel","size","hideSelectionIndicator","style","id","disabled","type","onChange","checked","name"],z=a.forwardRef((function(n,t){var r,i,o,d,c=n.className,m=n.children,b=n.value,p=n.title,f=n.secondaryLabel,v=n.size,h=void 0===v?"medium":v,g=n.hideSelectionIndicator,E=void 0!==g&&g,y=n.style,C=n.id,_=n.disabled,x=void 0!==_&&_,k=n.type,w=void 0===k?"radio":k,O=n.onChange,I=n.checked,F=n.name,L=u(n,T),R=l(c,"eds-input-panel__container","eds-input-panel--"+h),A=a.useRef(null),z=e.useRandomId("eds-inputpanel"),S=C||z,V=e.useForceUpdate();return a.createElement("label",{className:"eds-input-panel",htmlFor:S},a.createElement("input",s({type:w,name:F,ref:e.mergeRefs(t,A),value:b,checked:I,onChange:function(e){void 0===O&&V(),null==O||O(e)},id:S,disabled:x},L)),a.createElement("div",{className:R,style:y},a.createElement("div",{className:"eds-input-panel__title-wrapper"},a.createElement("div",{className:"eds-input-panel__title"},p),a.createElement("div",{className:"eds-input-panel__secondary-label-and-icon-wrapper"},void 0!==f&&a.createElement(a.Fragment,null,f),a.createElement("span",{style:{pointerEvents:"none"}},!(x||E)&&("radio"===w?a.createElement(P,{name:"",value:"",checked:null!=(r=null!=I?I:null==(i=A.current)?void 0:i.checked)&&r,onChange:function(){},"aria-hidden":"true",tabIndex:-1}):a.createElement(N,{checked:null!=(o=null!=I?I:null==(d=A.current)?void 0:d.checked)&&o,onChange:function(){return null},"aria-hidden":"true",tabIndex:-1}))))),m&&a.createElement("div",{className:"eds-input-panel__additional-content"},m)))})),S=["className","children","value","title","secondaryLabel","size","hideRadioButton","style","id","disabled"],V=a.forwardRef((function(e,l){var n=e.className,t=e.children,r=e.value,i=e.title,o=e.secondaryLabel,d=e.size,c=void 0===d?"medium":d,m=e.hideRadioButton,b=void 0!==m&&m,p=e.style,f=e.id,v=e.disabled,h=void 0!==v&&v,g=u(e,S),E=R();return a.createElement(z,s({type:"radio",name:E.name,title:i,value:r,checked:E.value===r,onChange:E.onChange,className:n,secondaryLabel:o,size:c,hideSelectionIndicator:b,style:p,id:f,disabled:h},g,{ref:l}),t)})),q=["name","checked","onChange","className","children","value","title","secondaryLabel","size","hideCheckbox","style","id","disabled"],B=a.forwardRef((function(e,l){var n=e.name,t=e.checked,r=e.onChange,i=e.className,o=e.children,d=e.value,c=e.title,m=e.secondaryLabel,b=e.size,p=void 0===b?"medium":b,f=e.hideCheckbox,v=void 0!==f&&f,h=e.style,g=e.id,E=e.disabled,y=void 0!==E&&E,C=u(e,q);return a.createElement(z,s({type:"checkbox",name:n,title:c,value:d,checked:t,onChange:r,className:i,secondaryLabel:m,size:p,hideSelectionIndicator:v,style:h,id:g,disabled:y},C,{ref:l}),o)})),j=["name","value","children","onChange","label"],M=["className","children","labelPlacement","icon","hideIcon","color","contrastColor","size","checked"],G=a.forwardRef((function(e,t){var r=e.className,i=e.children,d=e.labelPlacement,c=void 0===d?"right":d,m=e.icon,b=e.hideIcon,p=void 0!==b&&b,f=e.color,v=void 0===f?o.colors.validation.mint:f,h=e.contrastColor,g=void 0===h?o.colors.validation.mintContrast:h,E=e.size,y=void 0===E?"medium":E,C=e.checked,_=u(e,M);return a.createElement("label",{className:l("eds-switch","eds-switch--"+c,r),style:s({},_.style)},a.createElement("input",s({type:"checkbox",ref:t,checked:C},_)),a.createElement("span",{className:l("eds-switch__switch","eds-switch__switch--"+y),style:{"--eds-switch-color":v,"--eds-switch-contrast-color":g},"aria-hidden":"true"},a.createElement("span",{className:"eds-switch__circle"},!p&&(m||(void 0===C?a.createElement(a.Fragment,null):a.createElement(C?n.CheckIcon:n.CloseSmallIcon,{size:"large"===y?23:void 0}))))),i&&a.createElement("span",{className:l("eds-switch__label","eds-switch__label--"+y+"--"+c)},i))}));function H(e){return null!=e&&!(Array.isArray(e)&&0===e.length)}function K(e,a){return void 0===a&&(a=!1),e&&(H(e.value)&&""!==e.value||a&&H(e.defaultValue)&&""!==e.defaultValue)}var Y=["variant","disabled","readOnly","className","style","label","feedback","labelTooltip","labelTooltipButtonAriaLabel","labelTooltipPlacement","onChange","disableLabelAnimation"],D=["readOnly","disabled","onChange","value","variant"],Q=a.forwardRef((function(n,t){var r=n.variant,i=n.disabled,o=void 0!==i&&i,d=n.readOnly,c=void 0!==d&&d,m=n.className,b=n.style,p=n.label,f=n.feedback,v=n.labelTooltip,h=n.labelTooltipButtonAriaLabel,g=n.labelTooltipPlacement,E=n.onChange,y=n.disableLabelAnimation,C=u(n,Y),_=e.useRandomId("eds-textarea"),k=a.useRef(null);return a.createElement(x,{className:l(m,"eds-textarea__wrapper"),disabled:o,readOnly:c,variant:r,style:b,label:p,labelId:_,feedback:f,labelTooltip:v,labelTooltipButtonAriaLabel:h,labelTooltipPlacement:g,labelProps:{className:"eds-textarea__label"},disableLabelAnimation:y,onClick:function(e){var a;e.target===e.currentTarget&&(null==k||null==(a=k.current)||a.focus())}},a.createElement(U,s({readOnly:c,disabled:o,ref:e.mergeRefs(t,k),"aria-labelledby":_,onChange:E,variant:r},C)))})),U=a.forwardRef((function(l,n){var t=l.readOnly,r=l.disabled,i=l.onChange,o=l.value,d=l.variant,c=u(l,D),m=C(),b=d||m,p=h(),f=p.isFilled,v=p.setFilled;return e.useOnMount((function(){(null!=o&&o.toString()||c.defaultValue)&&v&&!f&&v(!0)})),a.useEffect((function(){null!=o&&o.toString()&&v&&!f&&v(!0)}),[o,v,f]),a.createElement("textarea",s({className:"eds-form-control eds-textarea",ref:n,readOnly:t,disabled:r,onChange:function(e){K(e.target)?v&&!f&&v(!0):v&&f&&v(!1),i&&i(e)},value:o,"aria-invalid":"error"===b},c))})),J=["prepend","append","variant","disabled","readOnly","className","style","size","label","required","labelTooltip","labelTooltipButtonAriaLabel","labelTooltipPlacement","feedback","onChange","disableLabelAnimation","labelProps","clearable","onClear","value","ariaAlertOnFeedback"],W=["disabled","readOnly","placeholder","onChange","value","variant"],X=["onClear"],Z=a.forwardRef((function(n,t){var r=n.prepend,i=n.append,o=n.variant,d=n.disabled,c=void 0!==d&&d,m=n.readOnly,b=void 0!==m&&m,p=n.className,f=n.style,v=n.size,h=void 0===v?"medium":v,g=n.label,E=n.required,y=n.labelTooltip,C=n.labelTooltipButtonAriaLabel,_=n.labelTooltipPlacement,k=n.feedback,N=n.onChange,w=n.disableLabelAnimation,O=n.labelProps,I=n.clearable,F=void 0!==I&&I,L=n.onClear,R=n.value,A=n.ariaAlertOnFeedback,P=void 0!==A&&A,T=u(n,J),z=e.useRandomId("eds-textfield"),S=O&&O.id?O.id:z,V=a.useRef(null);return a.createElement(x,{disabled:c,readOnly:b,variant:o,prepend:r,append:F&&L?a.createElement(ee,{onClear:L}):i,className:l(p,"eds-textfield__wrapper"),style:f,size:h,label:g,required:E,labelTooltip:y,labelTooltipButtonAriaLabel:C,labelTooltipPlacement:_,labelId:S,feedback:k,disableLabelAnimation:w,labelProps:O,ariaAlertOnFeedback:P,onClick:function(e){var a;e.target===e.currentTarget&&(null==V||null==(a=V.current)||a.focus())}},a.createElement($,s({disabled:c,readOnly:b,ref:e.mergeRefs(t,V),"aria-labelledby":S,onChange:N,value:R,variant:o},T)))})),$=a.forwardRef((function(l,n){var t=l.disabled,r=l.readOnly,i=l.placeholder,o=l.onChange,d=l.value,c=l.variant,m=u(l,W),b=C(),p=c||b,f=h(),v=f.isFilled,g=f.setFilled;return e.useOnMount((function(){(null!=d&&d.toString()||m.defaultValue)&&g&&!v&&g(!0)})),a.useEffect((function(){null!=d&&d.toString()&&g&&!v&&g(!0)}),[d,g,v]),a.createElement("input",s({"aria-invalid":"error"===p,className:"eds-form-control",disabled:t,readOnly:r,ref:n,placeholder:i,onChange:function(e){K(e.target)?g&&!v&&g(!0):g&&v&&g(!1),o&&o(e)},value:d},m))})),ee=function(e){var l=e.onClear,t=u(e,X),r=h(),i=r.isFilled,o=r.setFilled;return a.createElement("div",{className:"eds-textfield__clear-button-wrapper"},i&&a.createElement("div",{className:"eds-textfield__divider"}),i&&a.createElement("button",s({className:"eds-textfield__clear-button",type:"button",tabIndex:-1,onClick:function(){o(!1),l()}},t),a.createElement(n.CloseSmallIcon,null)))},ae=["name","onChange","selectedValue","multiple","size"],le=a.createContext(null),ne=function(l){var n=l.name,t=l.onChange,r=void 0===t?function(){}:t,i=l.selectedValue,o=l.multiple,d=l.size,c=u(l,ae),m=e.useRandomId("eds-segmented-control"),b=a.useMemo((function(){return{name:n||m,onChange:r,multiple:o,selectedValue:i,size:d}}),[m,o,n,r,i,d]);return a.createElement(le.Provider,s({value:b},c))},te=["children","className","style","value","name","onChange"],re=a.forwardRef((function(e,n){var t=e.children,r=e.className,i=e.style,o=e.value,d=e.name,c=e.onChange,m=void 0===c?function(){}:c,b=u(e,te),p=function(){var e=a.useContext(le);if(!e)throw new Error("You need to wrap your SegmentedChoice in either SegmentedControl or MultipleSegmentedControl");return e}(),f=p.name,v=p.selectedValue,h=p.onChange,g=p.multiple,E=p.size,y=g?v[o]:v===o;return a.createElement("label",{className:l("eds-segmented-choice",r),style:i},a.createElement("input",s({type:g?"checkbox":"radio",name:d||f,checked:y,value:o,onChange:function(e){var a;m(e),g?h(s({},v,((a={})[o]=e.target.checked,a))):e.target.checked&&h(o)},ref:n},b)),a.createElement("div",{className:l("eds-base-segmented",{"eds-base-segmented--large":"large"===E})},t))})),ie=["children","label","name","onChange","selectedValue","size","className"],oe=["children","label","name","onChange","selectedValue"];e.warnAboutMissingStyles("form","icons","typography"),exports.BaseFormControl=x,exports.Checkbox=N,exports.CheckboxPanel=B,exports.FeedbackText=p,exports.Fieldset=I,exports.InputGroupContextProvider=v,exports.InputGroupLabel=E,exports.MultipleSegmentedControl=function(e){var l=e.children,n=e.label,t=e.name,r=e.onChange,o=e.selectedValue,d=u(e,oe);return a.createElement(ne,{name:t,selectedValue:o,onChange:r,multiple:!0,size:"medium"},a.createElement(i.Label,{as:"div"},n),a.createElement("div",s({className:"eds-segmented-control"},d),l))},exports.Radio=P,exports.RadioGroup=function(e){var l=e.name,n=e.value,t=e.children,r=e.onChange,i=e.label,o=u(e,j),d=a.useMemo((function(){return{name:l,value:n,onChange:r}}),[l,n,r]);return a.createElement(L,{value:d},i?a.createElement(I,s({label:i},o),t):t)},exports.RadioPanel=V,exports.SegmentedChoice=re,exports.SegmentedControl=function(e){var n=e.children,t=e.label,r=e.name,i=e.onChange,o=e.selectedValue,d=e.size,c=void 0===d?"medium":d,m=e.className,b=u(e,ie);return a.createElement(ne,{name:r,selectedValue:o,onChange:i,multiple:!1,size:c},a.createElement(I,{label:t},a.createElement("div",s({className:l("eds-segmented-control",m)},b),n)))},exports.Switch=G,exports.TextArea=Q,exports.TextField=Z,exports.VariantProvider=function(e){var l=e.variant;return a.createElement(y.Provider,{value:void 0===l?null:l},e.children)},exports.hasValue=H,exports.isFilled=K,exports.useInputGroupContext=h,exports.useVariant=C;
//# sourceMappingURL=form.cjs.production.min.js.map

@@ -186,3 +186,2 @@ import { mergeRefs, useRandomId, useForceUpdate, useOnMount, warnAboutMissingStyles } from '@entur/utils';

var currentVariant = variant || contextVariant;
console.log('baseF', labelTooltipPlacement);
return React__default.createElement(InputGroupContextProvider, null, React__default.createElement("div", {

@@ -189,0 +188,0 @@ className: classNames('eds-form-control__field-and-feedback-text', className, {

{
"name": "@entur/form",
"version": "8.1.0-beta.0",
"version": "8.1.0-beta.1",
"license": "EUPL-1.2",

@@ -32,8 +32,8 @@ "main": "dist/index.js",

"@entur/tokens": "^3.17.0",
"@entur/tooltip": "^4.0.0-beta.0",
"@entur/typography": "^1.8.43",
"@entur/utils": "^0.11.1",
"@entur/tooltip": "^4.0.0-beta.1",
"@entur/typography": "^1.8.44-beta.0",
"@entur/utils": "^0.11.2-beta.0",
"classnames": "^2.3.1"
},
"gitHead": "cf307ea5b19e314649370964a7368666df04305b"
"gitHead": "bf6f8921dac8b869172f77ab6da76401e40bbc9b"
}

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