@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,6 +1,6 @@
1
1
  {
2
2
  "name": "@sats-group/ui-lib",
3
- "version": "87.3.0",
3
+ "version": "88.0.0",
4
4
  "description": "SATS web user interface library",
5
5
  "author": "developer@sats.no",
6
6
  "license": "UNLICENSED",
@@ -1,2 +1,2 @@
1
- var f=Object.defineProperty,x=Object.defineProperties;var y=Object.getOwnPropertyDescriptors;var g=Object.getOwnPropertySymbols;var T=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable;var u=(o,e,t)=>e in o?f(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,i=(o,e)=>{for(var t in e||(e={}))T.call(e,t)&&u(o,t,e[t]);if(g)for(var t of g(e))$.call(e,t)&&u(o,t,e[t]);return o},a=(o,e)=>x(o,y(e));import s,{useState as z}from"react";import _ from"classnames";import p from"../text";const P=({tabs:o,onSelectionChange:e})=>{const[t,b]=z(o!=null?o:[]),r=t?t.length:0,n=t.findIndex(l=>l.isSelected),v=l=>{b(d=>d.map((m,c)=>a(i({},m),{isSelected:c===l}))),e==null||e(l)};return s.createElement("div",{className:"segmented-controller"},s.createElement("div",{className:_("segmented-controller__tabs",{[`segmented-controller__tabs--col-${r}`]:r,[`segmented-controller__tabs--selected-${n}`]:n})},s.createElement("div",{className:_("segmented-controller__indicator",{[`segmented-controller__indicator--col-${r}`]:r,[`segmented-controller__indicator--pos-${n}`]:n})}),t?t.map(({label:l,isSelected:d,leadingIcon:m,button:c},N)=>s.createElement("button",a(i({},c),{key:l,onClick:()=>v(N),type:"button",className:_("segmented-controller__tab",{"segmented-controller__tab--selected":d})}),s.createElement(p,{className:"segmented-controller__tab-title",size:p.sizes.small,theme:p.themes.emphasis},m?s.createElement("div",{className:"segmented-controller__tab-icon"},m):null,s.createElement("div",{className:"segmented-controller__tab-label"},l)))):null))};var F=P;export{F as default};
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?.(clickedIndex);\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, button }, index) => (\n <button\n {...button}\n key={label}\n onClick={() => changeView(index)}\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": "6aAAA,OAAOA,GAAS,YAAAC,MAAgB,QAChC,OAAOC,MAAQ,aACf,OAAOC,MAAU,UAIjB,MAAMC,EAAsD,CAAC,CA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text", "SegmentedController", "tabs", "onSelectionChange", "localTabs", "setLocalTabs", "columnCount", "selectedIndex", "tab", "changeView", "clickedIndex", "prevTabs", "index", "__spreadProps", "__spreadValues", "label", "isSelected", "leadingIcon", "button", "segmented_controller_default"]
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,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AM,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?: (index: number) => void;
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 {};
@@ -1,5 +1,5 @@
1
- /* Mode 1 */
2
- /* color */
1
+ // Figma: https://www.figma.com/file/WzKCwRY09zn4rzRVfY0YvdRt/%F0%9F%8E%A8-sats-ds-styles?type=design&node-id=8481%3A40159&mode=design&t=4Gq1pqiSLpmo4bBj-1
2
+
3
3
  $black-10: #e5e5e5;
4
4
  $black-100: #000000;
5
5
  $black-20: #cccccc;