All Downloads are FREE. Search and download functionalities are using the official Maven repository.

theme.keycloak.v2.admin.resources.assets.ExpandableSection-CSay1Wbo.js Maven / Gradle / Ivy

There is a newer version: 26.0.7
Show newest version
import{aL as A,aK as U,_ as V,bU as v,m as r,n as q}from"./main-C7ps2lmX.js";import*as i from"react";const n={dirRtl:"pf-v5-m-dir-rtl",expandableSection:"pf-v5-c-expandable-section",expandableSectionContent:"pf-v5-c-expandable-section__content",expandableSectionToggle:"pf-v5-c-expandable-section__toggle",expandableSectionToggleIcon:"pf-v5-c-expandable-section__toggle-icon",expandableSectionToggleText:"pf-v5-c-expandable-section__toggle-text",modifiers:{expanded:"pf-m-expanded",detached:"pf-m-detached",truncate:"pf-m-truncate",limitWidth:"pf-m-limit-width",displayLg:"pf-m-display-lg",indented:"pf-m-indented",active:"pf-m-active",expandTop:"pf-m-expand-top"}},C={name:"--pf-v5-c-expandable-section--m-truncate__content--LineClamp",value:"3",var:"var(--pf-v5-c-expandable-section--m-truncate__content--LineClamp)"};var a;(function(s){s.default="default",s.truncate="truncate"})(a||(a={}));const T=(s,e)=>{!e||s<1||e.style.setProperty(C.name,s.toString())};class _ extends i.Component{constructor(e){super(e),this.expandableContentRef=i.createRef(),this.observer=()=>{},this.checkToggleVisibility=()=>{var t;if(!((t=this.expandableContentRef)===null||t===void 0)&&t.current){const o=this.props.truncateMaxLines||parseInt(C.value),d=this.expandableContentRef.current.scrollHeight/parseInt(getComputedStyle(this.expandableContentRef.current).lineHeight);this.setState({hasToggle:d>o})}},this.resize=()=>{const{offsetWidth:t}=this.expandableContentRef.current;this.state.previousWidth!==t&&(this.setState({previousWidth:t}),this.checkToggleVisibility())},this.handleResize=A(this.resize,250),this.state={isExpanded:e.isExpanded,hasToggle:!0,previousWidth:void 0}}calculateToggleText(e,t,o,d){return d&&t!==""?t:!d&&o!==""?o:e}componentDidMount(){if(this.props.variant===a.truncate){const e=this.expandableContentRef.current;this.setState({previousWidth:e.offsetWidth}),this.observer=U(e,this.handleResize,!1),this.props.truncateMaxLines&&T(this.props.truncateMaxLines,e),this.checkToggleVisibility()}}componentDidUpdate(e){if(this.props.variant===a.truncate&&(e.truncateMaxLines!==this.props.truncateMaxLines||e.children!==this.props.children)){const t=this.expandableContentRef.current;T(this.props.truncateMaxLines,t),this.checkToggleVisibility()}}componentWillUnmount(){this.props.variant===a.truncate&&this.observer()}render(){const e=this.props,{onToggle:t,isActive:o,className:d,toggleText:S,toggleTextExpanded:E,toggleTextCollapsed:L,toggleContent:y,children:I,isExpanded:h,isDetached:p,displaySize:R,isWidthLimited:W,isIndented:M,contentId:N,toggleId:x,variant:c,truncateMaxLines:w}=e,z=V(e,["onToggle","isActive","className","toggleText","toggleTextExpanded","toggleTextCollapsed","toggleContent","children","isExpanded","isDetached","displaySize","isWidthLimited","isIndented","contentId","toggleId","variant","truncateMaxLines"]);p&&!x&&console.warn("ExpandableSection: The toggleId value must be passed in and must match the toggleId of the ExpandableSectionToggle.");let u=t,l=h;const f=N||v("expandable-section-content"),m=x||v("expandable-section-toggle");h===void 0&&(l=this.state.isExpanded,u=(g,D)=>{this.setState({isExpanded:D},()=>t(g,this.state.isExpanded))});const k=this.calculateToggleText(S,E,L,l),b=!p&&i.createElement("button",{className:r(n.expandableSectionToggle),type:"button","aria-expanded":l,"aria-controls":f,id:m,onClick:g=>u(g,!l)},c!==a.truncate&&i.createElement("span",{className:r(n.expandableSectionToggleIcon)},i.createElement(q,{"aria-hidden":!0})),i.createElement("span",{className:r(n.expandableSectionToggleText)},y||k));return i.createElement("div",Object.assign({className:r(n.expandableSection,l&&n.modifiers.expanded,o&&n.modifiers.active,p&&n.modifiers.detached,R==="lg"&&n.modifiers.displayLg,W&&n.modifiers.limitWidth,M&&n.modifiers.indented,c===a.truncate&&n.modifiers.truncate,d)},z),c===a.default&&b,i.createElement("div",{ref:this.expandableContentRef,className:r(n.expandableSectionContent),hidden:c!==a.truncate&&!l,id:f,"aria-labelledby":m,role:"region"},I),c===a.truncate&&this.state.hasToggle&&b)}}_.displayName="ExpandableSection";_.defaultProps={className:"",toggleText:"",toggleTextExpanded:"",toggleTextCollapsed:"",onToggle:(s,e)=>{},isActive:!1,isDetached:!1,displaySize:"default",isWidthLimited:!1,isIndented:!1,variant:"default"};export{_ as E};
//# sourceMappingURL=ExpandableSection-CSay1Wbo.js.map




© 2015 - 2025 Weber Informatics LLC | Privacy Policy