norma-library 0.5.122 → 0.5.123

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.
@@ -0,0 +1,14 @@
1
+ import React, { SyntheticEvent } from 'react';
2
+ import { SxProps } from '@mui/material';
3
+ import { ColorVariant, DataTabs, MuiTabsBaseProps, TabsVariant } from '@/types';
4
+ import { Theme } from '@emotion/react';
5
+ interface Props extends MuiTabsBaseProps {
6
+ sx?: SxProps<Theme>;
7
+ tabs: DataTabs[];
8
+ tab: number;
9
+ onTabChange: (event: SyntheticEvent, tab: number) => void;
10
+ color?: ColorVariant;
11
+ variant?: TabsVariant;
12
+ }
13
+ declare const UncontrolledTabs: ({ tabs, tab, color, onTabChange, ...props }: Props) => React.JSX.Element;
14
+ export default UncontrolledTabs;
@@ -0,0 +1,26 @@
1
+ import { __assign, __rest } from "tslib";
2
+ import React from 'react';
3
+ import { Box } from '@mui/material';
4
+ import { NormaTab, NormaTabs } from './UncontrolledTabs.style';
5
+ function TabPanel(props) {
6
+ var children = props.children, value = props.value, index = props.index, other = __rest(props, ["children", "value", "index"]);
7
+ return (React.createElement("div", __assign({ role: "tabpanel", hidden: value !== index, id: "simple-tabpanel-".concat(index), "aria-labelledby": "simple-tab-".concat(index) }, other), value === index && React.createElement(Box, { sx: { p: 3 } }, children)));
8
+ }
9
+ function a11yProps(index) {
10
+ return {
11
+ id: "simple-tab-".concat(index),
12
+ 'aria-controls': "simple-tabpanel-".concat(index),
13
+ };
14
+ }
15
+ var UncontrolledTabs = function (_a) {
16
+ var tabs = _a.tabs, tab = _a.tab, _b = _a.color, color = _b === void 0 ? 'primary' : _b, onTabChange = _a.onTabChange, props = __rest(_a, ["tabs", "tab", "color", "onTabChange"]);
17
+ var handleChange = function (event, newValue) {
18
+ onTabChange(event, newValue);
19
+ };
20
+ return (React.createElement(Box, { sx: { width: '100%' } },
21
+ React.createElement(Box, null,
22
+ React.createElement(NormaTabs, __assign({ value: tab, color: color, onChange: handleChange, "aria-label": "tabs" }, props), tabs.map(function (item, key) { return (React.createElement(NormaTab, __assign({ label: item.label, color: color }, a11yProps(key)))); }))),
23
+ tabs.map(function (item, key) { return (React.createElement(TabPanel, { key: key, value: tab, index: key }, item.children)); })));
24
+ };
25
+ export default UncontrolledTabs;
26
+ //# sourceMappingURL=UncontrolledTabs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UncontrolledTabs.js","sourceRoot":"","sources":["../../../../src/components/UncontrolledTabs/UncontrolledTabs.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAyB,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAE,GAAG,EAAW,MAAM,eAAe,CAAC;AAE7C,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAkB/D,SAAS,QAAQ,CAAC,KAAoB;IAC5B,IAAA,QAAQ,GAA6B,KAAK,SAAlC,EAAE,KAAK,GAAsB,KAAK,MAA3B,EAAE,KAAK,GAAe,KAAK,MAApB,EAAK,KAAK,UAAK,KAAK,EAA5C,8BAAoC,CAAF,CAAW;IAEnD,OAAO,CACL,sCACE,IAAI,EAAC,UAAU,EACf,MAAM,EAAE,KAAK,KAAK,KAAK,EACvB,EAAE,EAAE,0BAAmB,KAAK,CAAE,qBACb,qBAAc,KAAK,CAAE,IAClC,KAAK,GAER,KAAK,KAAK,KAAK,IAAI,oBAAC,GAAG,IAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,IAAG,QAAQ,CAAO,CACnD,CACP,CAAC;AACJ,CAAC;AAED,SAAS,SAAS,CAAC,KAAa;IAC9B,OAAO;QACL,EAAE,EAAE,qBAAc,KAAK,CAAE;QACzB,eAAe,EAAE,0BAAmB,KAAK,CAAE;KAC5C,CAAC;AACJ,CAAC;AAED,IAAM,gBAAgB,GAAG,UAAC,EAA8D;IAA5D,IAAA,IAAI,UAAA,EAAE,GAAG,SAAA,EAAE,aAAiB,EAAjB,KAAK,mBAAG,SAAS,KAAA,EAAE,WAAW,iBAAA,EAAK,KAAK,cAArD,uCAAuD,CAAF;IAC7E,IAAM,YAAY,GAAG,UAAC,KAAqB,EAAE,QAAgB;QAC3D,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC/B,CAAC,CAAC;IAEF,OAAO,CACL,oBAAC,GAAG,IAAC,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE;QACxB,oBAAC,GAAG;YACF,oBAAC,SAAS,aAAC,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,gBAAa,MAAM,IAAK,KAAK,GACrF,IAAI,CAAC,GAAG,CAAC,UAAC,IAAI,EAAE,GAAG,IAAK,OAAA,CACvB,oBAAC,QAAQ,aAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,IAAM,SAAS,CAAC,GAAG,CAAC,EAAI,CAClE,EAFwB,CAExB,CAAC,CACQ,CACR;QACL,IAAI,CAAC,GAAG,CAAC,UAAC,IAAI,EAAE,GAAG,IAAK,OAAA,CACvB,oBAAC,QAAQ,IAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,IACvC,IAAI,CAAC,QAAQ,CACL,CACZ,EAJwB,CAIxB,CAAC,CACE,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { ColorVariant } from '@/types';
3
+ interface StyledTabProps {
4
+ label: string;
5
+ color: ColorVariant;
6
+ }
7
+ export declare const NormaTabs: import("@emotion/styled").StyledComponent<import("@mui/material").TabsOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
8
+ ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
9
+ }, "style" | "className" | "classes" | "action" | "children" | "sx" | "variant" | "value" | "aria-label" | "aria-labelledby" | "onChange" | "slots" | "slotProps" | "orientation" | "allowScrollButtonsMobile" | "centered" | "indicatorColor" | "ScrollButtonComponent" | "scrollButtons" | "selectionFollowsFocus" | "TabIndicatorProps" | "TabScrollButtonProps" | "textColor" | "visibleScrollbar"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
10
+ color: ColorVariant;
11
+ }, {}, {}>;
12
+ export declare const NormaTab: import("@emotion/styled").StyledComponent<StyledTabProps & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
13
+ export {};
@@ -0,0 +1,50 @@
1
+ import { __assign } from "tslib";
2
+ import React from 'react';
3
+ import { styled } from '@mui/material/styles';
4
+ import { Tab, Tabs } from '@mui/material';
5
+ import { palette } from '../../helpers';
6
+ var colorMap = {
7
+ inherit: palette.inherit,
8
+ primary: palette.primary,
9
+ secondary: palette.secondary,
10
+ error: palette.error,
11
+ warning: palette.warning,
12
+ info: palette.info,
13
+ success: palette.success,
14
+ };
15
+ export var NormaTabs = styled(Tabs)(function (_a) {
16
+ var color = _a.color;
17
+ return ({
18
+ borderBottom: '1px solid #e8e8e8',
19
+ '& .Mui-selected': {
20
+ color: colorMap[color],
21
+ },
22
+ '& .MuiTabs-indicator': {
23
+ backgroundColor: colorMap[color],
24
+ },
25
+ '& .MuiButtonBase-root': {
26
+ textTransform: 'none',
27
+ },
28
+ });
29
+ });
30
+ export var NormaTab = styled(function (props) { return React.createElement(Tab, __assign({ disableRipple: true }, props)); })(function (_a) {
31
+ var theme = _a.theme, color = _a.color;
32
+ return ({
33
+ textTransform: 'none',
34
+ fontWeight: theme.typography.fontWeightRegular,
35
+ fontSize: theme.typography.pxToRem(15),
36
+ marginRight: theme.spacing(1),
37
+ font: 'normal normal normal 15px/25px Source Sans Pro',
38
+ color: '#666666',
39
+ padding: '5px 15px',
40
+ top: '5px',
41
+ minWidth: '60px',
42
+ '&.Mui-selected': {
43
+ color: colorMap[color],
44
+ },
45
+ '&.Mui-focusVisible': {
46
+ backgroundColor: 'rgba(100, 95, 228, 0.32)',
47
+ },
48
+ });
49
+ });
50
+ //# sourceMappingURL=UncontrolledTabs.style.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UncontrolledTabs.style.js","sourceRoot":"","sources":["../../../../src/components/UncontrolledTabs/UncontrolledTabs.style.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAE1C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,IAAM,QAAQ,GAAiC;IAC7C,OAAO,EAAE,OAAO,CAAC,OAAO;IACxB,OAAO,EAAE,OAAO,CAAC,OAAO;IACxB,SAAS,EAAE,OAAO,CAAC,SAAS;IAC5B,KAAK,EAAE,OAAO,CAAC,KAAK;IACpB,OAAO,EAAE,OAAO,CAAC,OAAO;IACxB,IAAI,EAAE,OAAO,CAAC,IAAI;IAClB,OAAO,EAAE,OAAO,CAAC,OAAO;CACzB,CAAC;AAOF,MAAM,CAAC,IAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,CAA0B,UAAC,EAAS;QAAP,KAAK,WAAA;IAAO,OAAA,CAAC;QAC7E,YAAY,EAAE,mBAAmB;QACjC,iBAAiB,EAAE;YACjB,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC;SACvB;QACD,sBAAsB,EAAE;YACtB,eAAe,EAAE,QAAQ,CAAC,KAAK,CAAC;SACjC;QACD,uBAAuB,EAAE;YACvB,aAAa,EAAE,MAAM;SACtB;KACF,CAAC;AAX4E,CAW5E,CAAC,CAAC;AAEJ,MAAM,CAAC,IAAM,QAAQ,GAAG,MAAM,CAAC,UAAC,KAAqB,IAAK,OAAA,oBAAC,GAAG,aAAC,aAAa,UAAK,KAAK,EAAI,EAAhC,CAAgC,CAAC,CAAC,UAAC,EAAgB;QAAd,KAAK,WAAA,EAAE,KAAK,WAAA;IAAO,OAAA,CAAC;QACjH,aAAa,EAAE,MAAM;QACrB,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB;QAC9C,QAAQ,EAAE,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QACtC,WAAW,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAC7B,IAAI,EAAE,gDAAgD;QACtD,KAAK,EAAE,SAAS;QAChB,OAAO,EAAE,UAAU;QACnB,GAAG,EAAE,KAAK;QACV,QAAQ,EAAE,MAAM;QAChB,gBAAgB,EAAE;YAChB,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC;SACvB;QACD,oBAAoB,EAAE;YACpB,eAAe,EAAE,0BAA0B;SAC5C;KACF,CAAC;AAhBgH,CAgBhH,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "norma-library",
3
- "version": "0.5.122",
3
+ "version": "0.5.123",
4
4
  "private": false,
5
5
  "description": "Olos/Norma-DS. Design System based on Material UI, developed with TypeScript and Styled Components to create reusable and consistent components in web applications.",
6
6
  "scripts": {
@@ -0,0 +1,52 @@
1
+ import React from 'react';
2
+ import { styled } from '@mui/material/styles';
3
+
4
+ import { Tab, Tabs } from '@mui/material';
5
+ import { ColorVariant } from '@/types';
6
+ import { palette } from '../../helpers';
7
+
8
+ const colorMap: Record<ColorVariant, string> = {
9
+ inherit: palette.inherit,
10
+ primary: palette.primary,
11
+ secondary: palette.secondary,
12
+ error: palette.error,
13
+ warning: palette.warning,
14
+ info: palette.info,
15
+ success: palette.success,
16
+ };
17
+
18
+ interface StyledTabProps {
19
+ label: string;
20
+ color: ColorVariant;
21
+ }
22
+
23
+ export const NormaTabs = styled(Tabs)<{ color: ColorVariant }>(({ color }) => ({
24
+ borderBottom: '1px solid #e8e8e8',
25
+ '& .Mui-selected': {
26
+ color: colorMap[color],
27
+ },
28
+ '& .MuiTabs-indicator': {
29
+ backgroundColor: colorMap[color],
30
+ },
31
+ '& .MuiButtonBase-root': {
32
+ textTransform: 'none',
33
+ },
34
+ }));
35
+
36
+ export const NormaTab = styled((props: StyledTabProps) => <Tab disableRipple {...props} />)(({ theme, color }) => ({
37
+ textTransform: 'none',
38
+ fontWeight: theme.typography.fontWeightRegular,
39
+ fontSize: theme.typography.pxToRem(15),
40
+ marginRight: theme.spacing(1),
41
+ font: 'normal normal normal 15px/25px Source Sans Pro',
42
+ color: '#666666',
43
+ padding: '5px 15px',
44
+ top: '5px',
45
+ minWidth: '60px',
46
+ '&.Mui-selected': {
47
+ color: colorMap[color],
48
+ },
49
+ '&.Mui-focusVisible': {
50
+ backgroundColor: 'rgba(100, 95, 228, 0.32)',
51
+ },
52
+ }));
@@ -0,0 +1,68 @@
1
+ import React, { SyntheticEvent } from 'react';
2
+ import { Box, SxProps } from '@mui/material';
3
+ import { ColorVariant, DataTabs, MuiTabsBaseProps, TabsVariant } from '@/types';
4
+ import { NormaTab, NormaTabs } from './UncontrolledTabs.style';
5
+ import { Theme } from '@emotion/react';
6
+
7
+ interface Props extends MuiTabsBaseProps {
8
+ sx?: SxProps<Theme>;
9
+ tabs: DataTabs[];
10
+ tab: number;
11
+ onTabChange: (event: SyntheticEvent, tab: number) => void;
12
+ color?: ColorVariant;
13
+ variant?: TabsVariant;
14
+ }
15
+
16
+ interface TabPanelProps {
17
+ children?: React.ReactNode;
18
+ index: number;
19
+ value: number;
20
+ }
21
+
22
+ function TabPanel(props: TabPanelProps) {
23
+ const { children, value, index, ...other } = props;
24
+
25
+ return (
26
+ <div
27
+ role="tabpanel"
28
+ hidden={value !== index}
29
+ id={`simple-tabpanel-${index}`}
30
+ aria-labelledby={`simple-tab-${index}`}
31
+ {...other}
32
+ >
33
+ {value === index && <Box sx={{ p: 3 }}>{children}</Box>}
34
+ </div>
35
+ );
36
+ }
37
+
38
+ function a11yProps(index: number) {
39
+ return {
40
+ id: `simple-tab-${index}`,
41
+ 'aria-controls': `simple-tabpanel-${index}`,
42
+ };
43
+ }
44
+
45
+ const UncontrolledTabs = ({ tabs, tab, color = 'primary', onTabChange, ...props }: Props) => {
46
+ const handleChange = (event: SyntheticEvent, newValue: number) => {
47
+ onTabChange(event, newValue);
48
+ };
49
+
50
+ return (
51
+ <Box sx={{ width: '100%' }}>
52
+ <Box>
53
+ <NormaTabs value={tab} color={color} onChange={handleChange} aria-label="tabs" {...props}>
54
+ {tabs.map((item, key) => (
55
+ <NormaTab label={item.label} color={color} {...a11yProps(key)} />
56
+ ))}
57
+ </NormaTabs>
58
+ </Box>
59
+ {tabs.map((item, key) => (
60
+ <TabPanel key={key} value={tab} index={key}>
61
+ {item.children}
62
+ </TabPanel>
63
+ ))}
64
+ </Box>
65
+ );
66
+ };
67
+
68
+ export default UncontrolledTabs;
@@ -46,7 +46,6 @@ type Story = StoryObj<typeof meta>;
46
46
 
47
47
  export const Playground: Story = {
48
48
  args: {
49
- textColor: 'primary',
50
49
  data: data,
51
50
  },
52
51
  };
@@ -8,7 +8,7 @@ const Template = args => {
8
8
  };
9
9
 
10
10
  export default {
11
- title: 'Table/UncontrolledTable',
11
+ title: 'Uncontrolled/Table',
12
12
  component: Template,
13
13
  tags: ['autodocs'],
14
14
  parameters: {
@@ -0,0 +1,63 @@
1
+ import React, { useState } from 'react';
2
+
3
+ import type { Meta, StoryObj } from '@storybook/react';
4
+ import UncontrolledTabs from '../components/UncontrolledTabs/UncontrolledTabs';
5
+ import { DataTabs } from '../types';
6
+ import { Typography } from '@mui/material';
7
+
8
+ const data: DataTabs[] = [
9
+ {
10
+ label: 'Tab 1',
11
+ id: 'panel-1',
12
+ children: (
13
+ <Typography>
14
+ Tab 1 - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex, sit amet
15
+ blandit leo lobortis eget.
16
+ </Typography>
17
+ ),
18
+ },
19
+ {
20
+ label: 'Tab 2',
21
+ id: 'panel-2',
22
+ children: (
23
+ <Typography>
24
+ Tab 2 - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex, sit amet
25
+ blandit leo lobortis eget.
26
+ </Typography>
27
+ ),
28
+ },
29
+ ];
30
+
31
+ const meta = {
32
+ title: 'Uncontrolled/Tabs',
33
+ component: UncontrolledTabs,
34
+ tags: ['autodocs'],
35
+ parameters: {
36
+ layout: 'centered',
37
+ },
38
+ argTypes: {
39
+ tabs: data,
40
+ },
41
+ } satisfies Meta<typeof UncontrolledTabs>;
42
+
43
+ export default meta;
44
+
45
+ type Story = StoryObj<typeof meta>;
46
+
47
+ export const Playground: Story = {
48
+ args: {
49
+ tab: 0,
50
+ tabs: data,
51
+ },
52
+ };
53
+
54
+ export const UncontrolledTabsBasic = () => {
55
+ const [tab, setTab] = useState(0);
56
+ return (
57
+ <div style={{ width: '480px', marginBottom: 30 }}>
58
+ <UncontrolledTabs tab={tab} tabs={data} onTabChange={(evt, tab) => setTab(tab)} />
59
+ </div>
60
+ );
61
+ };
62
+
63
+ UncontrolledTabsBasic.storyName = 'Uncontrolled Tabs';