sbwb-ds 1.0.57 → 1.0.58

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/dist/index.d.ts CHANGED
@@ -1,5 +1,12 @@
1
1
  import { Icons } from './src/main/helpers/functions/icons';
2
2
  import { sg } from './src/presentation/styles/styleGuide';
3
+ import { Props } from './src/presentation/components/atoms/Tree';
4
+ import { TooltipProps } from './src/presentation/components/atoms/Tooltip';
5
+ import { ButtonProps } from './src/presentation/components/atoms/Button';
6
+ import { InputProps } from './src/presentation/components/atoms/Input';
7
+ import { AlertProps } from './src/presentation/components/atoms/Alert';
8
+ import { TextareaProps } from './src/presentation/components/atoms/Textarea';
9
+ import { SelectProps } from './src/presentation/components/atoms/Select';
3
10
  export { default as Accordion } from './src/presentation/components/atoms/Accordion';
4
11
  export { default as ActionButton } from './src/presentation/components/atoms/ActionButton';
5
12
  export { default as Actions } from './src/presentation/components/atoms/Actions';
@@ -42,4 +49,11 @@ export { default as Table } from './src/presentation/components/molecules/Table'
42
49
  export { default as HeaderTitle } from './src/presentation/components/molecules/HeaderTitle';
43
50
  export { TableProvider, useTableContext, } from './src/presentation/context/table/index';
44
51
  export type IconType = keyof typeof Icons;
52
+ export type { Props as TreeProps };
53
+ export type { TooltipProps };
54
+ export type { ButtonProps };
55
+ export type { InputProps };
56
+ export type { AlertProps };
57
+ export type { TextareaProps };
58
+ export type { SelectProps };
45
59
  export { sg };
package/dist/sbwb-ds.js CHANGED
@@ -52253,22 +52253,23 @@ const Uue = () => {
52253
52253
  }, ghe = ({
52254
52254
  title: e,
52255
52255
  content: r,
52256
- children: t,
52256
+ childrens: t,
52257
52257
  onClickTitle: n,
52258
52258
  onClickContent: a,
52259
- disabled: i = !1
52259
+ disabled: i = !1,
52260
+ isOpenByDefault: o = !1
52260
52261
  }) => {
52261
- const [o, s] = Ne(!1), l = xt(null), c = () => {
52262
+ const [s, l] = Ne(o), c = xt(null), u = () => {
52262
52263
  typeof n == "function" && !i && n(e);
52263
- }, u = () => {
52264
+ }, h = () => {
52264
52265
  typeof a == "function" && !i && a(r);
52265
52266
  };
52266
- return /* @__PURE__ */ ue(che, { ref: l, children: [
52267
- /* @__PURE__ */ ue(uhe, { onClick: i ? void 0 : () => s(!o), children: [
52267
+ return /* @__PURE__ */ ue(che, { ref: c, children: [
52268
+ /* @__PURE__ */ ue(uhe, { onClick: i ? void 0 : () => l(!s), children: [
52268
52269
  /* @__PURE__ */ R(
52269
52270
  Qa,
52270
52271
  {
52271
- iconName: o ? "DoNotDisturbOnFill0Sm" : "AddCircleSm",
52272
+ iconName: s ? "DoNotDisturbOnFill0Sm" : "AddCircleSm",
52272
52273
  color: i ? "#A6B0C4" : "#4E5666",
52273
52274
  customStyles: i ? { cursor: "not-allowed" } : {},
52274
52275
  width: "16px",
@@ -52279,32 +52280,32 @@ const Uue = () => {
52279
52280
  fhe,
52280
52281
  {
52281
52282
  disabled: i,
52282
- onClick: i ? void 0 : () => c(),
52283
+ onClick: i ? void 0 : () => u(),
52283
52284
  children: e
52284
52285
  }
52285
52286
  )
52286
52287
  ] }),
52287
- o && /* @__PURE__ */ ue(hhe, { children: [
52288
+ s && /* @__PURE__ */ ue(hhe, { children: [
52288
52289
  /* @__PURE__ */ R(
52289
52290
  phe,
52290
52291
  {
52291
52292
  title: e,
52292
52293
  content: r,
52293
- onClickContent: u,
52294
+ onClickContent: h,
52294
52295
  disabled: i
52295
52296
  }
52296
52297
  ),
52297
- t == null ? void 0 : t.map((h, f) => /* @__PURE__ */ R(
52298
+ t == null ? void 0 : t.map((f, d) => /* @__PURE__ */ R(
52298
52299
  ghe,
52299
52300
  {
52300
- title: h.title,
52301
- content: h.content,
52302
- children: h.children,
52303
- onClickTitle: c,
52304
- onClickContent: u,
52305
- disabled: h.disabled
52301
+ title: f.title,
52302
+ content: f.content,
52303
+ childrens: f.childrens,
52304
+ onClickTitle: u,
52305
+ onClickContent: h,
52306
+ disabled: f.disabled
52306
52307
  },
52307
- f
52308
+ d
52308
52309
  ))
52309
52310
  ] })
52310
52311
  ] });
@@ -2298,7 +2298,7 @@ echarts.use([`+T+"]);":"Unknown series "+V))}return}if(h==="tooltip"){if(w){proc
2298
2298
  margin-left: 8px;
2299
2299
  color: ${({disabled:e})=>e?"#A6B0C4":"#4E5666"};
2300
2300
  cursor: ${({disabled:e})=>e?"not-allowed":"pointer"};
2301
- `,moe=({title:e,content:r,onClickContent:t,disabled:n})=>{const[a,i]=$.useState(!1),o=$.useRef(null);return $.useEffect(()=>{const l=c=>{o.current&&!o.current.contains(c.target)&&i(!1)};return document.addEventListener("mousedown",l),()=>{document.removeEventListener("mousedown",l)}},[]),ue(goe,{ref:o,onClick:()=>{typeof t=="function"&&!n&&(t(r),i(!0))},children:[N(ta,{iconName:a?"FiberManualRecordFill1Sm":"FiberManualRecordFILL0Sm",color:n?"#A6B0C4":"#4E5666",customStyles:n?{cursor:"not-allowed"}:{},width:"16px",height:"16px"}),N(Coe,{disabled:n,children:r})]})},Zk=({title:e,content:r,children:t,onClickTitle:n,onClickContent:a,disabled:i=!1})=>{const[o,s]=$.useState(!1),l=$.useRef(null),c=()=>{typeof n=="function"&&!i&&n(e)},u=()=>{typeof a=="function"&&!i&&a(r)};return ue(foe,{ref:l,children:[ue(doe,{onClick:i?void 0:()=>s(!o),children:[N(ta,{iconName:o?"DoNotDisturbOnFill0Sm":"AddCircleSm",color:i?"#A6B0C4":"#4E5666",customStyles:i?{cursor:"not-allowed"}:{},width:"16px",height:"16px"}),N(poe,{disabled:i,onClick:i?void 0:()=>c(),children:e})]}),o&&ue(voe,{children:[N(moe,{title:e,content:r,onClickContent:u,disabled:i}),t==null?void 0:t.map((h,f)=>N(Zk,{title:h.title,content:h.content,children:h.children,onClickTitle:c,onClickContent:u,disabled:h.disabled},f))]})]})},yoe=(e,r,t)=>($.useEffect(()=>{let n;return r&&e&&(n=setTimeout(()=>{t&&t()},r)),()=>{n&&clearTimeout(n)}},[e,r,t]),{}),woe=z.div`
2301
+ `,moe=({title:e,content:r,onClickContent:t,disabled:n})=>{const[a,i]=$.useState(!1),o=$.useRef(null);return $.useEffect(()=>{const l=c=>{o.current&&!o.current.contains(c.target)&&i(!1)};return document.addEventListener("mousedown",l),()=>{document.removeEventListener("mousedown",l)}},[]),ue(goe,{ref:o,onClick:()=>{typeof t=="function"&&!n&&(t(r),i(!0))},children:[N(ta,{iconName:a?"FiberManualRecordFill1Sm":"FiberManualRecordFILL0Sm",color:n?"#A6B0C4":"#4E5666",customStyles:n?{cursor:"not-allowed"}:{},width:"16px",height:"16px"}),N(Coe,{disabled:n,children:r})]})},Zk=({title:e,content:r,childrens:t,onClickTitle:n,onClickContent:a,disabled:i=!1,isOpenByDefault:o=!1})=>{const[s,l]=$.useState(o),c=$.useRef(null),u=()=>{typeof n=="function"&&!i&&n(e)},h=()=>{typeof a=="function"&&!i&&a(r)};return ue(foe,{ref:c,children:[ue(doe,{onClick:i?void 0:()=>l(!s),children:[N(ta,{iconName:s?"DoNotDisturbOnFill0Sm":"AddCircleSm",color:i?"#A6B0C4":"#4E5666",customStyles:i?{cursor:"not-allowed"}:{},width:"16px",height:"16px"}),N(poe,{disabled:i,onClick:i?void 0:()=>u(),children:e})]}),s&&ue(voe,{children:[N(moe,{title:e,content:r,onClickContent:h,disabled:i}),t==null?void 0:t.map((f,d)=>N(Zk,{title:f.title,content:f.content,childrens:f.childrens,onClickTitle:u,onClickContent:h,disabled:f.disabled},d))]})]})},yoe=(e,r,t)=>($.useEffect(()=>{let n;return r&&e&&(n=setTimeout(()=>{t&&t()},r)),()=>{n&&clearTimeout(n)}},[e,r,t]),{}),woe=z.div`
2302
2302
  display: flex;
2303
2303
  flex-direction: row;
2304
2304
  justify-content: space-between;
@@ -1,7 +1,7 @@
1
1
  export interface TreeItem {
2
2
  title: string;
3
3
  content: string;
4
- children?: TreeItem[];
4
+ childrens?: TreeItem[];
5
5
  disabled?: boolean;
6
6
  }
7
7
  export declare const mockData: TreeItem[];
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  export interface AlertElementProps {
3
3
  }
4
- interface AlertProps extends AlertElementProps {
4
+ export interface AlertProps extends AlertElementProps {
5
5
  title: string;
6
6
  type: 'success' | 'warning' | 'error';
7
7
  description?: string;
@@ -1,7 +1,7 @@
1
1
  import { ChangeEventHandler } from 'react';
2
2
  export interface TextareaElementProps {
3
3
  }
4
- interface TextareaProps extends TextareaElementProps {
4
+ export interface TextareaProps extends TextareaElementProps {
5
5
  id?: string;
6
6
  label?: string;
7
7
  placeholder?: string;
@@ -1,12 +1,13 @@
1
1
  /// <reference types="react" />
2
2
  import { TreeItem as TreeItemType } from '../../../../data/mocks/mock-data';
3
- interface Props {
3
+ export interface Props {
4
4
  title: string;
5
5
  content: string;
6
- children?: TreeItemType[];
6
+ childrens?: TreeItemType[];
7
7
  onClickTitle: (title: string) => void;
8
8
  onClickContent: (content: string) => void;
9
9
  disabled?: boolean;
10
+ isOpenByDefault?: boolean;
10
11
  }
11
12
  declare const Tree: React.FC<Props>;
12
13
  export default Tree;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbwb-ds",
3
- "version": "1.0.57",
3
+ "version": "1.0.58",
4
4
  "type": "module",
5
5
  "description": "Sistema de design para padronização dos processos visuais do portal SUBWEB",
6
6
  "main": "dist/sbwb-ds.js",
@@ -1,7 +1,7 @@
1
1
  export interface TreeItem {
2
2
  title: string;
3
3
  content: string;
4
- children?: TreeItem[];
4
+ childrens?: TreeItem[];
5
5
  disabled?: boolean;
6
6
  }
7
7
 
@@ -19,9 +19,9 @@ const generateRandomItem = (depth: number): TreeItem => {
19
19
 
20
20
  if (depth > 1 && Math.random() > 0.5) {
21
21
  const numChildren = Math.floor(Math.random() * 3) + 1;
22
- item.children = [];
22
+ item.childrens = [];
23
23
  for (let i = 1; i <= numChildren; i++) {
24
- item.children.push(generateRandomItem(depth - 1));
24
+ item.childrens.push(generateRandomItem(depth - 1));
25
25
  }
26
26
  }
27
27
  return item;
@@ -3,7 +3,7 @@ import { useAlertHide } from './hooks/useAlertHide';
3
3
  import * as C from './styles';
4
4
  export interface AlertElementProps {}
5
5
 
6
- interface AlertProps extends AlertElementProps {
6
+ export interface AlertProps extends AlertElementProps {
7
7
  title: string;
8
8
  type: 'success' | 'warning' | 'error';
9
9
  description?: string;
@@ -6,7 +6,7 @@ import Tooltip from '../Tooltip';
6
6
 
7
7
  export interface TextareaElementProps {}
8
8
 
9
- interface TextareaProps extends TextareaElementProps {
9
+ export interface TextareaProps extends TextareaElementProps {
10
10
  id?: string;
11
11
  label?: string;
12
12
  placeholder?: string;
@@ -23,7 +23,7 @@ const mockDataMap = mockData.map((data) => {
23
23
  return {
24
24
  title: data.title,
25
25
  content: data.content,
26
- children: data.children,
26
+ childrens: data.childrens,
27
27
  disabled: data.disabled,
28
28
  };
29
29
  });
@@ -38,7 +38,7 @@ const TreeList = (args) => (
38
38
  key={data.title + index}
39
39
  title={data.title}
40
40
  content={data.content}
41
- children={data.children}
41
+ childrens={data.childrens}
42
42
  disabled={data.disabled}
43
43
  />
44
44
  ))}
@@ -52,4 +52,5 @@ export const Default = Template.bind({});
52
52
  Default.args = {
53
53
  onClickContent: () => {},
54
54
  onClickTitle: () => {},
55
+ isOpenByDefault: true,
55
56
  };
@@ -6,7 +6,7 @@ describe('<Tree />', () => {
6
6
  const mockData = {
7
7
  title: 'TestTitle',
8
8
  content: 'TestContent',
9
- children: [
9
+ childrens: [
10
10
  {
11
11
  title: 'Child1',
12
12
  content: 'ChildContent1',
@@ -55,17 +55,15 @@ describe('<Tree />', () => {
55
55
  <Tree
56
56
  title={mockData.title}
57
57
  content={mockData.content}
58
- children={mockData.children}
58
+ childrens={mockData.childrens}
59
59
  onClickTitle={() => {}}
60
60
  onClickContent={() => {}}
61
61
  />
62
62
  );
63
63
 
64
- expect(queryByText(mockData.children[0].title)).toBeNull();
65
-
66
64
  fireEvent.click(getByText(mockData.title));
67
65
 
68
- expect(getByText(mockData.children[0].title)).toBeInTheDocument();
69
- expect(getByText(mockData.children[1].title)).toBeInTheDocument();
66
+ expect(getByText(mockData.childrens[0].title)).toBeInTheDocument();
67
+ expect(getByText(mockData.childrens[1].title)).toBeInTheDocument();
70
68
  });
71
69
  });
@@ -3,13 +3,14 @@ import * as C from './styles';
3
3
  import Icon from '../Icon';
4
4
  import { TreeItem as TreeItemType } from '../../../../data/mocks/mock-data';
5
5
 
6
- interface Props {
6
+ export interface Props {
7
7
  title: string;
8
8
  content: string;
9
- children?: TreeItemType[];
9
+ childrens?: TreeItemType[];
10
10
  onClickTitle: (title: string) => void;
11
11
  onClickContent: (content: string) => void;
12
12
  disabled?: boolean;
13
+ isOpenByDefault?: boolean;
13
14
  }
14
15
 
15
16
  interface TreeItemProps {
@@ -68,12 +69,14 @@ const TreeItemComponent: React.FC<TreeItemProps> = ({
68
69
  const Tree: React.FC<Props> = ({
69
70
  title,
70
71
  content,
71
- children,
72
+ childrens,
72
73
  onClickTitle,
73
74
  onClickContent,
74
75
  disabled = false,
76
+ isOpenByDefault = false,
75
77
  }) => {
76
- const [isOpen, setIsOpen] = useState(false);
78
+ const [isOpen, setIsOpen] = useState(isOpenByDefault);
79
+
77
80
  const treeRef = useRef(null);
78
81
 
79
82
  const handleTitleClick = () => {
@@ -113,12 +116,12 @@ const Tree: React.FC<Props> = ({
113
116
  onClickContent={handleContentClick}
114
117
  disabled={disabled}
115
118
  />
116
- {children?.map((item, index) => (
119
+ {childrens?.map((item, index) => (
117
120
  <Tree
118
121
  key={index}
119
122
  title={item.title}
120
123
  content={item.content}
121
- children={item.children}
124
+ childrens={item.childrens}
122
125
  onClickTitle={handleTitleClick}
123
126
  onClickContent={handleContentClick}
124
127
  disabled={item.disabled}