@ably/ui 14.0.0-dev.2944826 → 14.0.0-dev.450e302
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/Accordion.js +1 -1
- package/core/Expander.js +1 -1
- package/core/Slider.js +1 -1
- package/core/Table/Table.js +1 -1
- package/core/Table/TableCell.js +2 -2
- package/core/Table/data.js +1 -1
- package/core/Table.js +1 -1
- package/package.json +1 -1
- package/src/core/Accordion.tsx +3 -1
- package/src/core/Expander.tsx +1 -1
- package/src/core/Slider.tsx +47 -15
- package/src/core/Table/Table.tsx +1 -2
- package/src/core/Table/TableCell.tsx +1 -39
- package/src/core/Table/data.tsx +21 -1
- package/src/core/Table.tsx +1 -12
package/core/Accordion.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import React,{useState}from"react";import Icon from"./Icon";const AccordionRow=({name,children,index,setActiveIndex,active,topBorder,bottomBorder,last,arrowIcon})=>{let iconActive,iconInactive;const handleSetIndex=()=>{setActiveIndex(index)};if(arrowIcon){iconActive=React.createElement(Icon,{name:"icon-gui-disclosure-arrow",color:"text-dark-grey",size:"1.5rem",additionalCSS:"-rotate-90"});iconInactive=React.createElement(Icon,{name:"icon-gui-disclosure-arrow",color:"text-dark-grey",size:"1.5rem",additionalCSS:"rotate-90"})}else{iconActive=React.createElement(Icon,{name:"icon-gui-minus",color:"text-dark-grey",size:"1.5rem"});iconInactive=React.createElement(Icon,{name:"icon-gui-plus",color:"text-dark-grey",size:"1.5rem"})}return React.createElement("div",{className:`border-mid-grey ${last&&!bottomBorder?"":"border-b"} ${topBorder?"border-t":""}`},React.createElement("button",{type:"button",onClick:handleSetIndex,className:`flex w-full px-0 focus:outline-none py-20`},React.createElement("span",{className:"ui-text-p1 font-bold text-left mr-8"},name),React.createElement("span",{className:"ml-auto"},active?iconActive:iconInactive)),React.createElement("section",{className:"ui-text-p2 transition-all overflow-hidden",style:{maxHeight:active?"500px":"0",paddingBottom:active?"1.5rem":"0"}},children))};const Accordion=({data,id="id-accordion",topBorder,bottomBorder,arrowIcon,autoClose})=>{const[activeIndexes,setActiveIndexes]=useState([]);const handleSetIndex=index=>{const currentIndexIsActive=activeIndexes.includes(index);if(autoClose){setActiveIndexes(currentIndexIsActive?[]:[index])}else{setActiveIndexes(currentIndexIsActive?activeIndexes.filter(i=>i!==index):[...activeIndexes,index])}};return React.createElement("div",{className:
|
|
1
|
+
import React,{useState}from"react";import Icon from"./Icon";const AccordionRow=({name,children,index,setActiveIndex,active,topBorder,bottomBorder,last,arrowIcon})=>{let iconActive,iconInactive;const handleSetIndex=()=>{setActiveIndex(index)};if(arrowIcon){iconActive=React.createElement(Icon,{name:"icon-gui-disclosure-arrow",color:"text-dark-grey",size:"1.5rem",additionalCSS:"-rotate-90"});iconInactive=React.createElement(Icon,{name:"icon-gui-disclosure-arrow",color:"text-dark-grey",size:"1.5rem",additionalCSS:"rotate-90"})}else{iconActive=React.createElement(Icon,{name:"icon-gui-minus",color:"text-dark-grey",size:"1.5rem"});iconInactive=React.createElement(Icon,{name:"icon-gui-plus",color:"text-dark-grey",size:"1.5rem"})}return React.createElement("div",{className:`border-mid-grey ${last&&!bottomBorder?"":"border-b"} ${topBorder?"border-t":""}`},React.createElement("button",{type:"button",onClick:handleSetIndex,className:`flex w-full px-0 focus:outline-none py-20`},React.createElement("span",{className:"ui-text-p1 font-bold text-left mr-8"},name),React.createElement("span",{className:"ml-auto"},active?iconActive:iconInactive)),React.createElement("section",{className:"ui-text-p2 transition-all overflow-hidden",style:{maxHeight:active?"500px":"0",paddingBottom:active?"1.5rem":"0"}},children))};const Accordion=({data,id="id-accordion",topBorder,bottomBorder,arrowIcon,autoClose,className})=>{const[activeIndexes,setActiveIndexes]=useState([]);const handleSetIndex=index=>{const currentIndexIsActive=activeIndexes.includes(index);if(autoClose){setActiveIndexes(currentIndexIsActive?[]:[index])}else{setActiveIndexes(currentIndexIsActive?activeIndexes.filter(i=>i!==index):[...activeIndexes,index])}};return React.createElement("div",{className:className,id:id},data.map((item,currentIndex)=>{return React.createElement(AccordionRow,{key:item.name,name:item.name,arrowIcon:arrowIcon,index:currentIndex,last:data.length===currentIndex+1,topBorder:topBorder&¤tIndex===0,bottomBorder:bottomBorder&&data.length===currentIndex+1,active:activeIndexes.includes(currentIndex),setActiveIndex:handleSetIndex},item.content)}))};export default Accordion;
|
package/core/Expander.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import React,{useEffect,useRef,useState}from"react";const Expander=({heightThreshold=200,className,fadeClassName,children})=>{const innerRef=useRef(null);const[showControls,setShowControls]=useState(false);const[height,setHeight]=useState(heightThreshold);const[expanded,setExpanded]=useState(false);useEffect(()=>{var _innerRef_current;var _innerRef_current_clientHeight;const contentHeight=(_innerRef_current_clientHeight=(_innerRef_current=innerRef.current)===null||_innerRef_current===void 0?void 0:_innerRef_current.clientHeight)!==null&&_innerRef_current_clientHeight!==void 0?_innerRef_current_clientHeight:heightThreshold;if(contentHeight<heightThreshold){setHeight("auto")}else if(expanded){setHeight(contentHeight)}else{setHeight(heightThreshold)}setShowControls(contentHeight>=heightThreshold)},[heightThreshold,expanded]);return React.createElement(React.Fragment,null,React.createElement("div",{style:{height},className:`overflow-hidden transition-all relative ${className!==null&&className!==void 0?className:""}`},showControls&&!expanded&&React.createElement("div",{className:`h-64 w-full bg-gradient-to-t from-white to-transparent absolute bottom-0 left-0 right-0 ${fadeClassName!==null&&fadeClassName!==void 0?fadeClassName:""}`}),React.createElement("div",{ref:innerRef},children)),showControls&&React.createElement("div",{onClick:()=>setExpanded(!expanded),onKeyDown:e=>e.key==="Enter"&&setExpanded(!expanded),tabIndex:0,className:"mt-16 cursor-pointer font-bold text-gui-blue-default-light hover:text-gui-blue-hover-light
|
|
1
|
+
import React,{useEffect,useRef,useState}from"react";const Expander=({heightThreshold=200,className,fadeClassName,children})=>{const innerRef=useRef(null);const[showControls,setShowControls]=useState(false);const[height,setHeight]=useState(heightThreshold);const[expanded,setExpanded]=useState(false);useEffect(()=>{var _innerRef_current;var _innerRef_current_clientHeight;const contentHeight=(_innerRef_current_clientHeight=(_innerRef_current=innerRef.current)===null||_innerRef_current===void 0?void 0:_innerRef_current.clientHeight)!==null&&_innerRef_current_clientHeight!==void 0?_innerRef_current_clientHeight:heightThreshold;if(contentHeight<heightThreshold){setHeight("auto")}else if(expanded){setHeight(contentHeight)}else{setHeight(heightThreshold)}setShowControls(contentHeight>=heightThreshold)},[heightThreshold,expanded]);return React.createElement(React.Fragment,null,React.createElement("div",{style:{height},className:`overflow-hidden transition-all relative ${className!==null&&className!==void 0?className:""}`},showControls&&!expanded&&React.createElement("div",{className:`h-64 w-full bg-gradient-to-t from-white to-transparent absolute bottom-0 left-0 right-0 ${fadeClassName!==null&&fadeClassName!==void 0?fadeClassName:""}`}),React.createElement("div",{ref:innerRef},children)),showControls&&React.createElement("div",{onClick:()=>setExpanded(!expanded),onKeyDown:e=>e.key==="Enter"&&setExpanded(!expanded),tabIndex:0,className:"mt-16 cursor-pointer font-bold text-gui-blue-default-light hover:text-gui-blue-hover-light"},expanded?"View less -":"View all +"))};export default Expander;
|
package/core/Slider.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import React,{useState,useEffect,useRef}from"react";import Icon from"./Icon";const SlideIndicator=({numSlides,activeIndex,interval,intervalIndicator,isInline})=>{return React.createElement("ul",{className:`flex gap-4 left-1/2 ${isInline?"bottom-0":"absolute
|
|
1
|
+
import React,{useState,useEffect,useRef}from"react";import Icon from"./Icon";const SLIDE_TRANSITION_LENGTH=300;const SlideIndicator=({numSlides,activeIndex,interval,intervalIndicator,isInline})=>{return React.createElement("ul",{className:`flex gap-4 left-1/2 ${isInline?"bottom-0":"absolute bottom-0 transform -translate-x-1/2"}`},Array.from({length:numSlides},(_,i)=>intervalIndicator?React.createElement("li",{key:i,className:"relative w-40 h-4 mx-1 rounded-full bg-neutral-500"},i===activeIndex&&React.createElement("span",{className:"absolute inset-0 rounded-full bg-active-orange",style:{animation:`fillAnimation ${interval}ms linear`}})):React.createElement("li",{key:i},React.createElement("span",{className:`ui-slider-marker ${i===activeIndex?"text-active-orange":"text-cool-black"}`,"data-id":"slider-marker"},"⬤"))))};const setupSlides=(children,activeIndex)=>[children[activeIndex===0?children.length-1:activeIndex-1],children[activeIndex],children[activeIndex===children.length-1?0:activeIndex+1]];const Slider=({children,options})=>{const[activeIndex,setActiveIndex]=useState(0);const[touchStartX,setTouchStartX]=useState(0);const[touchEndX,setTouchEndX]=useState(0);const[slides,setSlides]=useState(setupSlides(children,activeIndex));const[translationCoefficient,setTranslationCoefficient]=useState(0);const timerRef=useRef(null);const[slideLock,setSlideLock]=useState(false);const isInline=(options===null||options===void 0?void 0:options.controlPosition)==="inline";const next=()=>{if(!slideLock){setActiveIndex(prevIndex=>(prevIndex+1)%children.length);setTranslationCoefficient(1);resetInterval();setSlideLock(true)}};const prev=()=>{if(!slideLock){setActiveIndex(prevIndex=>prevIndex>0?prevIndex-1:children.length-1);setTranslationCoefficient(-1);resetInterval();setSlideLock(true)}};const resetInterval=()=>{if(timerRef.current)clearInterval(timerRef.current);var _options_interval;timerRef.current=setInterval(next,(_options_interval=options===null||options===void 0?void 0:options.interval)!==null&&_options_interval!==void 0?_options_interval:1e4)};const handleTouchStart=e=>{setTouchStartX(e.touches[0].clientX)};const handleTouchMove=e=>{setTouchEndX(e.touches[0].clientX)};const handleTouchEnd=()=>{if(touchStartX-touchEndX>50){next()}if(touchStartX-touchEndX<-50){prev()}};useEffect(()=>{resetInterval();return()=>{if(timerRef.current)clearInterval(timerRef.current)}},[children.length,options===null||options===void 0?void 0:options.interval]);useEffect(()=>{setTimeout(()=>{setSlides(setupSlides(children,activeIndex));setTranslationCoefficient(0);setSlideLock(false)},SLIDE_TRANSITION_LENGTH)},[activeIndex]);var _options_interval;return React.createElement("div",{className:"relative",onTouchStart:handleTouchStart,onTouchMove:handleTouchMove,onTouchEnd:handleTouchEnd},React.createElement("div",{className:"overflow-y-visible overflow-x-clip w-full py-40"},React.createElement("div",{className:`flex items-center ${translationCoefficient!==0?`transition-transform ease-in-out duration-${SLIDE_TRANSITION_LENGTH}`:""} `,style:{transform:`translateX(-${(translationCoefficient+1)*100}%)`}},slides.map((child,index)=>React.createElement("div",{key:index,className:"w-full flex-shrink-0 flex justify-center sm:px-60"},child)))),React.createElement("div",{className:`flex items-center pointer-events-none ${isInline?"ui-standard-container justify-center gap-24 -mt-16":"sm:flex sm:absolute inset-0 justify-between"}`},React.createElement("button",{className:`${isInline?"w-32 h-32":"hidden sm:flex w-48 h-48"} pointer-events-auto rounded border border-mid-grey hover:border-active-orange flex justify-center items-center ui-icon-cta ui-icon-cta-left`,onClick:prev},React.createElement("div",{className:"ui-icon-cta-holder flex gap-4"},React.createElement("div",{className:"w-full h-full flex-shrink-0 flex items-center justify-center"},React.createElement(Icon,{name:"icon-gui-arrow-left",size:"1.5rem"})),React.createElement("div",{className:"w-full h-full flex-shrink-0 flex items-center justify-center"},React.createElement(Icon,{name:"icon-gui-arrow-left",size:"1.5rem"})))),React.createElement(SlideIndicator,{numSlides:children.length,activeIndex:activeIndex,interval:(_options_interval=options===null||options===void 0?void 0:options.interval)!==null&&_options_interval!==void 0?_options_interval:1e4,intervalIndicator:options===null||options===void 0?void 0:options.intervalIndicator,isInline:isInline}),React.createElement("button",{className:`${isInline?"w-32 h-32":"hidden sm:flex w-48 h-48"} pointer-events-auto rounded border border-mid-grey hover:border-active-orange justify-center items-center ui-icon-cta ui-icon-cta-right`,onClick:next},React.createElement("div",{className:"ui-icon-cta-holder flex gap-4"},React.createElement("div",{className:"w-full h-full flex-shrink-0 flex items-center justify-center"},React.createElement(Icon,{name:"icon-gui-arrow-right",size:"1.5rem"})),React.createElement("div",{className:"w-full h-full flex-shrink-0 flex items-center justify-center"},React.createElement(Icon,{name:"icon-gui-arrow-right",size:"1.5rem"}))))))};export default Slider;
|
package/core/Table/Table.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import React,{cloneElement}from"react";export const Table=({id,children,...rest})=>{var _rest_className;return React.createElement("table",{id:id,...rest,className:`ui-standard-container mb-4 sm:table-fixed ${(_rest_className=rest===null||rest===void 0?void 0:rest.className)!==null&&_rest_className!==void 0?_rest_className:""}`},children)};export const TableBody=({children,...rest})=>React.createElement("tbody",rest,children);export const TableHeader=({children,...rest})=>{var _rest_className;return React.createElement("thead",{...rest,className:`sticky bg-white z-10 top-0 ${(_rest_className=rest===null||rest===void 0?void 0:rest.className)!==null&&_rest_className!==void 0?_rest_className:""}`},cloneElement(children,{isHeader:true}))};export const TableRowHeader=({children,...rest})=>{var _rest_className;return React.createElement("tr",{className:`-ml-24 mt-8 sm:ml-0 sm:mt-0
|
|
1
|
+
import React,{cloneElement}from"react";export const Table=({id,children,...rest})=>{var _rest_className;return React.createElement("table",{id:id,...rest,className:`ui-standard-container mb-4 sm:table-fixed ${(_rest_className=rest===null||rest===void 0?void 0:rest.className)!==null&&_rest_className!==void 0?_rest_className:""}`},children)};export const TableBody=({children,...rest})=>React.createElement("tbody",rest,children);export const TableHeader=({children,...rest})=>{var _rest_className;return React.createElement("thead",{...rest,className:`sticky bg-white z-10 top-0 ${(_rest_className=rest===null||rest===void 0?void 0:rest.className)!==null&&_rest_className!==void 0?_rest_className:""}`},cloneElement(children,{isHeader:true}))};export const TableRowHeader=({children,...rest})=>{var _rest_className;return React.createElement("tr",{className:`-ml-24 mt-8 sm:ml-0 sm:mt-0 sm:sticky z-10 ${(_rest_className=rest===null||rest===void 0?void 0:rest.className)!==null&&_rest_className!==void 0?_rest_className:""}`},cloneElement(children,{isRowHeader:true}))};
|
package/core/Table/TableCell.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React from"react";
|
|
1
|
+
import React from"react";const LabelCell=({children,...rest})=>{var _rest_className;const classes=`
|
|
2
2
|
ui-text-p1 font-bold pt-24 pb-8 border-light-grey sm:p-24 sm:relative sm:top-2 flex sm:table-cell ${(_rest_className=rest===null||rest===void 0?void 0:rest.className)!==null&&_rest_className!==void 0?_rest_className:""}
|
|
3
3
|
`;return React.createElement("td",{...rest,className:classes},children)};const TableCell=({children,isRowHeader,...rest})=>{var _rest_className;return React.createElement("td",{...rest,className:`
|
|
4
4
|
border-light-grey sm:p-24 leading-none flex sm:table-cell
|
|
5
5
|
${isRowHeader?"rounded-l-none rounded-r sm:rounded-lg py-20 px-24":"py-6"}
|
|
6
6
|
${(_rest_className=rest===null||rest===void 0?void 0:rest.className)!==null&&_rest_className!==void 0?_rest_className:""}
|
|
7
|
-
`},children)};const HeaderCell=({children,...rest})=>{var _rest_className;return React.createElement("td",{...rest,className:`ui-text-h3 px-24 py-24 hidden sm:table-cell ${(_rest_className=rest===null||rest===void 0?void 0:rest.className)!==null&&_rest_className!==void 0?_rest_className:""}`},children)};const CtaCell=({children,...rest})=>{var _rest_className;return React.createElement("td",{...rest,className:`pt-24 hidden sm:table-cell ${(_rest_className=rest===null||rest===void 0?void 0:rest.className)!==null&&_rest_className!==void 0?_rest_className:""}`},children)};export{TableCell,LabelCell,HeaderCell,CtaCell
|
|
7
|
+
`},children)};const HeaderCell=({children,...rest})=>{var _rest_className;return React.createElement("td",{...rest,className:`ui-text-h3 px-24 py-24 hidden sm:table-cell ${(_rest_className=rest===null||rest===void 0?void 0:rest.className)!==null&&_rest_className!==void 0?_rest_className:""}`},children)};const CtaCell=({children,...rest})=>{var _rest_className;return React.createElement("td",{...rest,className:`pt-24 hidden sm:table-cell ${(_rest_className=rest===null||rest===void 0?void 0:rest.className)!==null&&_rest_className!==void 0?_rest_className:""}`},children)};export{TableCell,LabelCell,HeaderCell,CtaCell};
|
package/core/Table/data.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import React,{Fragment}from"react";import Tooltip from"../Tooltip";import
|
|
1
|
+
import React,{Fragment}from"react";import Tooltip from"../Tooltip";import Table from"../Table";import Icon from"../Icon";const Supported=()=>React.createElement(Icon,{name:"icon-gui-check-circled-fill",size:"1.5rem",color:"text-gui-success",additionalCSS:"flex-grow-0 flex-shrink-0","data-testid":"supported-icon"});const Unsupported=()=>React.createElement(Icon,{name:"icon-gui-cross-circled-fill",size:"1.5rem",color:"text-gui-error",additionalCSS:"flex-grow-0 flex-shrink-0","data-testid":"unsupported-icon"});const testRow=index=>({label:`Label ${index+1}`,cells:[{label:"text",content:"Cell content",column:"Free"},{label:"yes",content:React.createElement("div",{className:"flex items-center sm:flex-col sm:items-start"},React.createElement("span",{className:"sm:order-1 px-6 sm:py-6 sm:px-0"},"Supported"),React.createElement("span",{className:"sm:order-0"},React.createElement(Supported,null))),column:"PAYG"},{label:"no",content:React.createElement("div",{className:"flex items-center sm:flex-col sm:items-start"},React.createElement("span",{className:"sm:order-1 px-6 sm:py-6 sm:px-0"},"Unsupported"),React.createElement("span",{className:"sm:order-0"},React.createElement(Unsupported,null))),column:"Custom"}]});const sections=["Features","Support","Technical Support"].map(label=>({label,rows:[...Array(5)].map((_,i)=>testRow(i))}));export const PricingPageTable=()=>{return React.createElement("div",{className:"ui-standard-container"},React.createElement("h2",{className:"ui-text-h2 text-center m-32"},"Pricing Page Table"),React.createElement("p",{className:"text-center m-32"},"Example content"),React.createElement(Table.Root,null,React.createElement(Table.Header,null,React.createElement(Table.Row,null,React.createElement(Table.Cell,null,React.createElement("span",{className:"ui-text-h3 hidden sm:block"},"Free")),React.createElement(Table.Cell,null,React.createElement("span",{className:"ui-text-h3 hidden sm:block"},"PAYG")),React.createElement(Table.Cell,null,React.createElement("span",{className:"ui-text-h3 hidden sm:block"},"Custom")))),React.createElement(Table.Body,null,sections.map(section=>React.createElement(Fragment,{key:section.label},React.createElement(Table.RowHeader,null,React.createElement(Table.Cell,{colSpan:4},section.label)),section.rows.map(row=>React.createElement(Table.Row,{key:row.label},React.createElement(Table.LabelCell,{key:row.label,className:"border-t border-light-grey"},React.createElement("a",{className:"ui-link",href:"#"},row.label),React.createElement(Tooltip,null,"Example tooltip")),row.cells.map(cell=>React.createElement(Table.Cell,{key:cell.label,className:"last:mb-16 sm:mb-0"},React.createElement("div",{className:"flex-1 sm:hidden !text-dark-grey ui-text-overline2"},cell.column),cell.content)))))),React.createElement(Table.Row,null,React.createElement(Table.Cell,null),React.createElement(Table.CtaCell,null,React.createElement("a",{href:"#",className:"ui-btn-secondary"},"Get started")),React.createElement(Table.CtaCell,null,React.createElement("a",{href:"#",className:"ui-btn-secondary"},"Get started")),React.createElement(Table.CtaCell,null,React.createElement("a",{href:"#",className:"ui-btn"},"Contact sales"))))))};
|
package/core/Table.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Table,TableRowHeader,TableHeader,TableBody}from"./Table/Table";import{TableRow}from"./Table/TableRow";import{TableCell,LabelCell,HeaderCell,CtaCell
|
|
1
|
+
import{Table,TableRowHeader,TableHeader,TableBody}from"./Table/Table";import{TableRow}from"./Table/TableRow";import{TableCell,LabelCell,HeaderCell,CtaCell}from"./Table/TableCell";export default{Root:Table,Row:TableRow,Cell:TableCell,LabelCell,HeaderCell,CtaCell,RowHeader:TableRowHeader,Body:TableBody,Header:TableHeader};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ably/ui",
|
|
3
|
-
"version": "14.0.0-dev.
|
|
3
|
+
"version": "14.0.0-dev.450e302",
|
|
4
4
|
"description": "Home of the Ably design system library ([design.ably.com](https://design.ably.com)). It provides a showcase, development/test environment and a publishing pipeline for different distributables.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
package/src/core/Accordion.tsx
CHANGED
|
@@ -25,6 +25,7 @@ export type AccordionProps = {
|
|
|
25
25
|
bottomBorder?: boolean;
|
|
26
26
|
id?: string;
|
|
27
27
|
autoClose?: boolean;
|
|
28
|
+
className?: string;
|
|
28
29
|
};
|
|
29
30
|
|
|
30
31
|
const AccordionRow = ({
|
|
@@ -104,6 +105,7 @@ const Accordion = ({
|
|
|
104
105
|
bottomBorder,
|
|
105
106
|
arrowIcon,
|
|
106
107
|
autoClose,
|
|
108
|
+
className,
|
|
107
109
|
}: AccordionProps) => {
|
|
108
110
|
const [activeIndexes, setActiveIndexes] = useState<number[]>([]);
|
|
109
111
|
|
|
@@ -122,7 +124,7 @@ const Accordion = ({
|
|
|
122
124
|
};
|
|
123
125
|
|
|
124
126
|
return (
|
|
125
|
-
<div className=
|
|
127
|
+
<div className={className} id={id}>
|
|
126
128
|
{data.map((item, currentIndex) => {
|
|
127
129
|
return (
|
|
128
130
|
<AccordionRow
|
package/src/core/Expander.tsx
CHANGED
|
@@ -51,7 +51,7 @@ const Expander = ({
|
|
|
51
51
|
onClick={() => setExpanded(!expanded)}
|
|
52
52
|
onKeyDown={(e) => e.key === "Enter" && setExpanded(!expanded)}
|
|
53
53
|
tabIndex={0}
|
|
54
|
-
className="mt-16 cursor-pointer font-bold text-gui-blue-default-light hover:text-gui-blue-hover-light
|
|
54
|
+
className="mt-16 cursor-pointer font-bold text-gui-blue-default-light hover:text-gui-blue-hover-light"
|
|
55
55
|
>
|
|
56
56
|
{expanded ? "View less -" : "View all +"}
|
|
57
57
|
</div>
|
package/src/core/Slider.tsx
CHANGED
|
@@ -18,6 +18,8 @@ interface SliderIndicatorProps {
|
|
|
18
18
|
isInline?: boolean;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
const SLIDE_TRANSITION_LENGTH = 300;
|
|
22
|
+
|
|
21
23
|
const SlideIndicator = ({
|
|
22
24
|
numSlides,
|
|
23
25
|
activeIndex,
|
|
@@ -28,7 +30,7 @@ const SlideIndicator = ({
|
|
|
28
30
|
return (
|
|
29
31
|
<ul
|
|
30
32
|
className={`flex gap-4 left-1/2 ${
|
|
31
|
-
isInline ? "bottom-0" : "absolute
|
|
33
|
+
isInline ? "bottom-0" : "absolute bottom-0 transform -translate-x-1/2"
|
|
32
34
|
}`}
|
|
33
35
|
>
|
|
34
36
|
{Array.from({ length: numSlides }, (_, i) =>
|
|
@@ -63,24 +65,43 @@ const SlideIndicator = ({
|
|
|
63
65
|
);
|
|
64
66
|
};
|
|
65
67
|
|
|
68
|
+
const setupSlides = (children: ReactNode[], activeIndex: number) => [
|
|
69
|
+
children[activeIndex === 0 ? children.length - 1 : activeIndex - 1],
|
|
70
|
+
children[activeIndex],
|
|
71
|
+
children[activeIndex === children.length - 1 ? 0 : activeIndex + 1],
|
|
72
|
+
];
|
|
73
|
+
|
|
66
74
|
const Slider = ({ children, options }: SliderProps) => {
|
|
67
75
|
const [activeIndex, setActiveIndex] = useState(0);
|
|
68
76
|
const [touchStartX, setTouchStartX] = useState(0);
|
|
69
77
|
const [touchEndX, setTouchEndX] = useState(0);
|
|
78
|
+
const [slides, setSlides] = useState<ReactNode[]>(
|
|
79
|
+
setupSlides(children, activeIndex)
|
|
80
|
+
);
|
|
81
|
+
const [translationCoefficient, setTranslationCoefficient] = useState(0);
|
|
70
82
|
const timerRef = useRef<NodeJS.Timeout | null>(null);
|
|
83
|
+
const [slideLock, setSlideLock] = useState(false);
|
|
71
84
|
|
|
72
85
|
const isInline = options?.controlPosition === "inline";
|
|
73
86
|
|
|
74
87
|
const next = () => {
|
|
75
|
-
|
|
76
|
-
|
|
88
|
+
if (!slideLock) {
|
|
89
|
+
setActiveIndex((prevIndex) => (prevIndex + 1) % children.length);
|
|
90
|
+
setTranslationCoefficient(1);
|
|
91
|
+
resetInterval();
|
|
92
|
+
setSlideLock(true);
|
|
93
|
+
}
|
|
77
94
|
};
|
|
78
95
|
|
|
79
96
|
const prev = () => {
|
|
80
|
-
|
|
81
|
-
prevIndex
|
|
82
|
-
|
|
83
|
-
|
|
97
|
+
if (!slideLock) {
|
|
98
|
+
setActiveIndex((prevIndex) =>
|
|
99
|
+
prevIndex > 0 ? prevIndex - 1 : children.length - 1
|
|
100
|
+
);
|
|
101
|
+
setTranslationCoefficient(-1);
|
|
102
|
+
resetInterval();
|
|
103
|
+
setSlideLock(true);
|
|
104
|
+
}
|
|
84
105
|
};
|
|
85
106
|
|
|
86
107
|
const resetInterval = () => {
|
|
@@ -112,6 +133,14 @@ const Slider = ({ children, options }: SliderProps) => {
|
|
|
112
133
|
};
|
|
113
134
|
}, [children.length, options?.interval]);
|
|
114
135
|
|
|
136
|
+
useEffect(() => {
|
|
137
|
+
setTimeout(() => {
|
|
138
|
+
setSlides(setupSlides(children, activeIndex));
|
|
139
|
+
setTranslationCoefficient(0);
|
|
140
|
+
setSlideLock(false);
|
|
141
|
+
}, SLIDE_TRANSITION_LENGTH);
|
|
142
|
+
}, [activeIndex]);
|
|
143
|
+
|
|
115
144
|
return (
|
|
116
145
|
<div
|
|
117
146
|
className="relative"
|
|
@@ -121,16 +150,19 @@ const Slider = ({ children, options }: SliderProps) => {
|
|
|
121
150
|
>
|
|
122
151
|
<div className="overflow-y-visible overflow-x-clip w-full py-40">
|
|
123
152
|
<div
|
|
124
|
-
className=
|
|
125
|
-
|
|
153
|
+
className={`flex items-center ${
|
|
154
|
+
translationCoefficient !== 0
|
|
155
|
+
? `transition-transform ease-in-out duration-${SLIDE_TRANSITION_LENGTH}`
|
|
156
|
+
: ""
|
|
157
|
+
} `}
|
|
158
|
+
style={{
|
|
159
|
+
transform: `translateX(-${(translationCoefficient + 1) * 100}%)`,
|
|
160
|
+
}}
|
|
126
161
|
>
|
|
127
|
-
{
|
|
162
|
+
{slides.map((child, index) => (
|
|
128
163
|
<div
|
|
129
164
|
key={index}
|
|
130
|
-
className="w-full flex-shrink-0 flex justify-center sm:px-60
|
|
131
|
-
style={{
|
|
132
|
-
opacity: activeIndex === index ? 1 : 0.1,
|
|
133
|
-
}}
|
|
165
|
+
className="w-full flex-shrink-0 flex justify-center sm:px-60"
|
|
134
166
|
>
|
|
135
167
|
{child}
|
|
136
168
|
</div>
|
|
@@ -141,7 +173,7 @@ const Slider = ({ children, options }: SliderProps) => {
|
|
|
141
173
|
<div
|
|
142
174
|
className={`flex items-center pointer-events-none ${
|
|
143
175
|
isInline
|
|
144
|
-
? "ui-standard-container justify-center gap-24"
|
|
176
|
+
? "ui-standard-container justify-center gap-24 -mt-16"
|
|
145
177
|
: "sm:flex sm:absolute inset-0 justify-between"
|
|
146
178
|
}`}
|
|
147
179
|
>
|
package/src/core/Table/Table.tsx
CHANGED
|
@@ -49,10 +49,9 @@ export const TableRowHeader = ({
|
|
|
49
49
|
...rest
|
|
50
50
|
}: PropsWithChildren<TableHTMLAttributes<HTMLTableRowElement>>) => (
|
|
51
51
|
<tr
|
|
52
|
-
className={`-ml-24 mt-8 sm:ml-0 sm:mt-0
|
|
52
|
+
className={`-ml-24 mt-8 sm:ml-0 sm:mt-0 sm:sticky z-10 ${
|
|
53
53
|
rest?.className ?? ""
|
|
54
54
|
}`}
|
|
55
|
-
style={{ top: "4rem" }}
|
|
56
55
|
>
|
|
57
56
|
{cloneElement(children as ReactElement, { isRowHeader: true })}
|
|
58
57
|
</tr>
|
|
@@ -1,39 +1,9 @@
|
|
|
1
1
|
import React, { PropsWithChildren } from "react";
|
|
2
|
-
import Icon from "../Icon";
|
|
3
2
|
|
|
4
3
|
type TableCellProps = {
|
|
5
4
|
isRowHeader?: boolean;
|
|
6
5
|
} & React.TdHTMLAttributes<HTMLTableCellElement>;
|
|
7
6
|
|
|
8
|
-
const Supported = () => (
|
|
9
|
-
<Icon
|
|
10
|
-
name="icon-gui-check-circled-fill"
|
|
11
|
-
size="1.5rem"
|
|
12
|
-
color="text-gui-success"
|
|
13
|
-
additionalCSS="flex-grow-0 flex-shrink-0"
|
|
14
|
-
data-testid="supported-icon"
|
|
15
|
-
/>
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
const Unsupported = () => (
|
|
19
|
-
<Icon
|
|
20
|
-
name="icon-gui-cross-circled-fill"
|
|
21
|
-
size="1.5rem"
|
|
22
|
-
color="text-gui-error"
|
|
23
|
-
additionalCSS="flex-grow-0 flex-shrink-0"
|
|
24
|
-
data-testid="unsupported-icon"
|
|
25
|
-
/>
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
const Partial = () => (
|
|
29
|
-
<Icon
|
|
30
|
-
name="icon-gui-partial"
|
|
31
|
-
size="1.5rem"
|
|
32
|
-
additionalCSS="flex-grow-0 flex-shrink-0"
|
|
33
|
-
data-testid="partial-icon"
|
|
34
|
-
/>
|
|
35
|
-
);
|
|
36
|
-
|
|
37
7
|
const LabelCell = ({
|
|
38
8
|
children,
|
|
39
9
|
...rest
|
|
@@ -98,12 +68,4 @@ const CtaCell = ({
|
|
|
98
68
|
</td>
|
|
99
69
|
);
|
|
100
70
|
|
|
101
|
-
export {
|
|
102
|
-
TableCell,
|
|
103
|
-
LabelCell,
|
|
104
|
-
HeaderCell,
|
|
105
|
-
CtaCell,
|
|
106
|
-
Supported,
|
|
107
|
-
Unsupported,
|
|
108
|
-
Partial,
|
|
109
|
-
};
|
|
71
|
+
export { TableCell, LabelCell, HeaderCell, CtaCell };
|
package/src/core/Table/data.tsx
CHANGED
|
@@ -1,8 +1,28 @@
|
|
|
1
1
|
import React, { Fragment } from "react";
|
|
2
2
|
|
|
3
3
|
import Tooltip from "../Tooltip";
|
|
4
|
-
import { Supported, Unsupported } from "./TableCell";
|
|
5
4
|
import Table from "../Table";
|
|
5
|
+
import Icon from "../Icon";
|
|
6
|
+
|
|
7
|
+
const Supported = () => (
|
|
8
|
+
<Icon
|
|
9
|
+
name="icon-gui-check-circled-fill"
|
|
10
|
+
size="1.5rem"
|
|
11
|
+
color="text-gui-success"
|
|
12
|
+
additionalCSS="flex-grow-0 flex-shrink-0"
|
|
13
|
+
data-testid="supported-icon"
|
|
14
|
+
/>
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
const Unsupported = () => (
|
|
18
|
+
<Icon
|
|
19
|
+
name="icon-gui-cross-circled-fill"
|
|
20
|
+
size="1.5rem"
|
|
21
|
+
color="text-gui-error"
|
|
22
|
+
additionalCSS="flex-grow-0 flex-shrink-0"
|
|
23
|
+
data-testid="unsupported-icon"
|
|
24
|
+
/>
|
|
25
|
+
);
|
|
6
26
|
|
|
7
27
|
const testRow = (index) => ({
|
|
8
28
|
label: `Label ${index + 1}`,
|
package/src/core/Table.tsx
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import { Table, TableRowHeader, TableHeader, TableBody } from "./Table/Table";
|
|
2
2
|
import { TableRow } from "./Table/TableRow";
|
|
3
|
-
import {
|
|
4
|
-
TableCell,
|
|
5
|
-
LabelCell,
|
|
6
|
-
HeaderCell,
|
|
7
|
-
CtaCell,
|
|
8
|
-
Supported,
|
|
9
|
-
Unsupported,
|
|
10
|
-
Partial,
|
|
11
|
-
} from "./Table/TableCell";
|
|
3
|
+
import { TableCell, LabelCell, HeaderCell, CtaCell } from "./Table/TableCell";
|
|
12
4
|
|
|
13
5
|
export default {
|
|
14
6
|
Root: Table,
|
|
@@ -20,7 +12,4 @@ export default {
|
|
|
20
12
|
RowHeader: TableRowHeader,
|
|
21
13
|
Body: TableBody,
|
|
22
14
|
Header: TableHeader,
|
|
23
|
-
Supported,
|
|
24
|
-
Unsupported,
|
|
25
|
-
Partial,
|
|
26
15
|
};
|