@sats-group/ui-lib 87.3.0 → 88.0.0
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/package.json
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var k=Object.defineProperty,z=Object.defineProperties;var P=Object.getOwnPropertyDescriptors;var c=Object.getOwnPropertySymbols;var f=Object.prototype.hasOwnProperty,x=Object.prototype.propertyIsEnumerable;var N=(e,o,t)=>o in e?k(e,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[o]=t,p=(e,o)=>{for(var t in o||(o={}))f.call(o,t)&&N(e,t,o[t]);if(c)for(var t of c(o))x.call(o,t)&&N(e,t,o[t]);return e},g=(e,o)=>z(e,P(o));var y=(e,o)=>{var t={};for(var l in e)f.call(e,l)&&o.indexOf(l)<0&&(t[l]=e[l]);if(e!=null&&c)for(var l of c(e))o.indexOf(l)<0&&x.call(e,l)&&(t[l]=e[l]);return t};import s,{useState as h}from"react";import u from"classnames";import b from"../text";const w=({tabs:e,onSelectionChange:o})=>{const[t,l]=h(e!=null?e:[]),n=t?t.length:0,m=t.findIndex(r=>r.isSelected),T=(r,i)=>{l(d=>d.map((a,_)=>g(p({},a),{isSelected:_===r}))),o==null||o(i)};return s.createElement("div",{className:"segmented-controller"},s.createElement("div",{className:u("segmented-controller__tabs",{[`segmented-controller__tabs--col-${n}`]:n,[`segmented-controller__tabs--selected-${m}`]:m})},s.createElement("div",{className:u("segmented-controller__indicator",{[`segmented-controller__indicator--col-${n}`]:n,[`segmented-controller__indicator--pos-${m}`]:m})}),t?t.map((C,$)=>{var v=C,{label:r,isSelected:i,leadingIcon:d,id:a}=v,_=y(v,["label","isSelected","leadingIcon","id"]);return s.createElement("button",g(p({},_),{key:r,onClick:()=>T($,a),type:"button",className:u("segmented-controller__tab",{"segmented-controller__tab--selected":i})}),s.createElement(b,{className:"segmented-controller__tab-title",size:b.sizes.small,theme:b.themes.emphasis},d?s.createElement("div",{className:"segmented-controller__tab-icon"},d):null,s.createElement("div",{className:"segmented-controller__tab-label"},r)))}):null))};var V=w;export{V as default};
|
|
2
2
|
//# sourceMappingURL=segmented-controller.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../react/segmented-controller/segmented-controller.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, { useState } from 'react';\nimport cn from 'classnames';\nimport Text from '../text';\n\nimport type { SegmentedController as Props } from './segmented-controller.types';\n\nconst SegmentedController: React.FunctionComponent<Props> = ({\n tabs,\n onSelectionChange,\n}) => {\n const [localTabs, setLocalTabs] = useState(tabs ?? []);\n const columnCount = localTabs ? localTabs.length : 0;\n const selectedIndex = localTabs.findIndex(tab => tab.isSelected);\n const changeView = (clickedIndex: number) => {\n setLocalTabs(prevTabs =>\n prevTabs.map((tab, index) => ({\n ...tab,\n isSelected: index === clickedIndex,\n })),\n );\n onSelectionChange?.(
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["React", "useState", "cn", "Text", "SegmentedController", "tabs", "onSelectionChange", "localTabs", "setLocalTabs", "columnCount", "selectedIndex", "tab", "changeView", "clickedIndex", "prevTabs", "index", "__spreadProps", "__spreadValues", "label", "isSelected", "leadingIcon", "
|
|
4
|
+
"sourcesContent": ["import React, { useState } from 'react';\nimport cn from 'classnames';\nimport Text from '../text';\n\nimport type { SegmentedController as Props } from './segmented-controller.types';\n\nconst SegmentedController: React.FunctionComponent<Props> = ({\n tabs,\n onSelectionChange,\n}) => {\n const [localTabs, setLocalTabs] = useState(tabs ?? []);\n const columnCount = localTabs ? localTabs.length : 0;\n const selectedIndex = localTabs.findIndex(tab => tab.isSelected);\n const changeView = (clickedIndex: number, id: string) => {\n setLocalTabs(prevTabs =>\n prevTabs.map((tab, index) => ({\n ...tab,\n isSelected: index === clickedIndex,\n })),\n );\n onSelectionChange?.(id);\n };\n\n return (\n <div className=\"segmented-controller\">\n <div\n className={cn('segmented-controller__tabs', {\n [`segmented-controller__tabs--col-${columnCount}`]: columnCount,\n [`segmented-controller__tabs--selected-${selectedIndex}`]:\n selectedIndex,\n })}\n >\n <div\n className={cn('segmented-controller__indicator', {\n [`segmented-controller__indicator--col-${columnCount}`]:\n columnCount,\n [`segmented-controller__indicator--pos-${selectedIndex}`]:\n selectedIndex,\n })}\n />\n {localTabs\n ? localTabs.map(\n ({ label, isSelected, leadingIcon, id, ...props }, index) => (\n <button\n {...props}\n key={label}\n onClick={() => changeView(index, id)}\n type=\"button\"\n className={cn('segmented-controller__tab', {\n 'segmented-controller__tab--selected': isSelected,\n })}\n >\n <Text\n className=\"segmented-controller__tab-title\"\n size={Text.sizes.small}\n theme={Text.themes.emphasis}\n >\n {leadingIcon ? (\n <div className=\"segmented-controller__tab-icon\">\n {leadingIcon}\n </div>\n ) : null}\n <div className=\"segmented-controller__tab-label\">\n {label}\n </div>\n </Text>\n </button>\n ),\n )\n : null}\n </div>\n </div>\n );\n};\n\nexport default SegmentedController;\n"],
|
|
5
|
+
"mappings": "+kBAAA,OAAOA,GAAS,YAAAC,MAAgB,QAChC,OAAOC,MAAQ,aACf,OAAOC,MAAU,UAIjB,MAAMC,EAAsD,CAAC,CAC3D,KAAAC,EACA,kBAAAC,CACF,IAAM,CACJ,KAAM,CAACC,EAAWC,CAAY,EAAIP,EAASI,GAAA,KAAAA,EAAQ,CAAC,CAAC,EAC/CI,EAAcF,EAAYA,EAAU,OAAS,EAC7CG,EAAgBH,EAAU,UAAUI,GAAOA,EAAI,UAAU,EACzDC,EAAa,CAACC,EAAsBC,IAAe,CACvDN,EAAaO,GACXA,EAAS,IAAI,CAACJ,EAAKK,IAAWC,EAAAC,EAAA,GACzBP,GADyB,CAE5B,WAAYK,IAAUH,CACxB,EAAE,CACJ,EACAP,GAAA,MAAAA,EAAoBQ,EACtB,EAEA,OACEd,EAAA,cAAC,OAAI,UAAU,wBACbA,EAAA,cAAC,OACC,UAAWE,EAAG,6BAA8B,CAC1C,CAAC,mCAAmCO,CAAW,EAAE,EAAGA,EACpD,CAAC,wCAAwCC,CAAa,EAAE,EACtDA,CACJ,CAAC,GAEDV,EAAA,cAAC,OACC,UAAWE,EAAG,kCAAmC,CAC/C,CAAC,wCAAwCO,CAAW,EAAE,EACpDA,EACF,CAAC,wCAAwCC,CAAa,EAAE,EACtDA,CACJ,CAAC,EACH,EACCH,EACGA,EAAU,IACR,CAACY,EAAkDH,IAAO,CAAzD,IAAAI,EAAAD,EAAE,OAAAE,EAAO,WAAAC,EAAY,YAAAC,EAAa,GAAAT,CA1CjD,EA0CeM,EAAyCI,EAAAC,EAAzCL,EAAyC,CAAvC,QAAO,aAAY,cAAa,OACjC,OAAApB,EAAA,cAAC,SAAAiB,EAAAC,EAAA,GACKM,GADL,CAEC,IAAKH,EACL,QAAS,IAAMT,EAAWI,EAAOF,CAAE,EACnC,KAAK,SACL,UAAWZ,EAAG,4BAA6B,CACzC,sCAAuCoB,CACzC,CAAC,IAEDtB,EAAA,cAACG,EAAA,CACC,UAAU,kCACV,KAAMA,EAAK,MAAM,MACjB,MAAOA,EAAK,OAAO,UAElBoB,EACCvB,EAAA,cAAC,OAAI,UAAU,kCACZuB,CACH,EACE,KACJvB,EAAA,cAAC,OAAI,UAAU,mCACZqB,CACH,CACF,CACF,EAEJ,EACA,IACN,CACF,CAEJ,EAEA,IAAOK,EAAQtB",
|
|
6
|
+
"names": ["React", "useState", "cn", "Text", "SegmentedController", "tabs", "onSelectionChange", "localTabs", "setLocalTabs", "columnCount", "selectedIndex", "tab", "changeView", "clickedIndex", "id", "prevTabs", "index", "__spreadProps", "__spreadValues", "_a", "_b", "label", "isSelected", "leadingIcon", "props", "__objRest", "segmented_controller_default"]
|
|
7
7
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { ReactElement } from 'react';
|
|
2
2
|
import type { ButtonHtmlProps } from '../types';
|
|
3
|
+
type SegmentedTab = {
|
|
4
|
+
label: string;
|
|
5
|
+
isSelected: boolean;
|
|
6
|
+
id: string;
|
|
7
|
+
leadingIcon?: ReactElement;
|
|
8
|
+
} & ButtonHtmlProps;
|
|
3
9
|
export type SegmentedController = {
|
|
4
|
-
onSelectionChange?: (
|
|
5
|
-
tabs:
|
|
6
|
-
label: string;
|
|
7
|
-
isSelected: boolean;
|
|
8
|
-
leadingIcon?: ReactElement;
|
|
9
|
-
button?: ButtonHtmlProps;
|
|
10
|
-
}[];
|
|
10
|
+
onSelectionChange?: (id: string) => void;
|
|
11
|
+
tabs: SegmentedTab[];
|
|
11
12
|
};
|
|
13
|
+
export {};
|
package/tokens/primitives.scss
CHANGED