techsbcn-storybook 0.9.1 → 0.11.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.
Files changed (36) hide show
  1. package/README.md +0 -1
  2. package/dist/components/fields/TextFieldComponent/TextFieldComponent.d.ts +2 -0
  3. package/dist/components/fields/TextSimpleComponent/TextSimpleComponent.d.ts +15 -0
  4. package/dist/components/navigation/VerticalNav/VerticalNav.d.ts +1 -1
  5. package/dist/components/navigation/VerticalNav/VerticalNavItem.d.ts +1 -1
  6. package/dist/components/navigation/VerticalNav/VerticalNavItemCollapse.d.ts +1 -1
  7. package/dist/data/SelectMock.d.ts +1 -1
  8. package/dist/data/enums/scopes.d.ts +5 -0
  9. package/dist/data/index.d.ts +1 -0
  10. package/dist/index.d.ts +1 -0
  11. package/dist/stories/Fields/Fields.stories.d.ts +1 -0
  12. package/dist/stories/MainWrapper/MainWrapper.stories.d.ts +1 -1
  13. package/dist/techsbcn-storybook.cjs.development.js +50 -9
  14. package/dist/techsbcn-storybook.cjs.development.js.map +1 -1
  15. package/dist/techsbcn-storybook.cjs.production.min.js +1 -1
  16. package/dist/techsbcn-storybook.cjs.production.min.js.map +1 -1
  17. package/dist/techsbcn-storybook.esm.js +50 -10
  18. package/dist/techsbcn-storybook.esm.js.map +1 -1
  19. package/package.json +3 -1
  20. package/src/components/fields/TextFieldComponent/TextFieldComponent.scss +5 -0
  21. package/src/components/fields/TextFieldComponent/TextFieldComponent.tsx +5 -2
  22. package/src/components/fields/TextSimpleComponent/TextSimpleComponent.scss +39 -0
  23. package/src/components/fields/TextSimpleComponent/TextSimpleComponent.tsx +40 -0
  24. package/src/components/navigation/VerticalNav/VerticalNav.tsx +1 -1
  25. package/src/components/navigation/VerticalNav/VerticalNavItem.tsx +1 -1
  26. package/src/components/navigation/VerticalNav/VerticalNavItemCollapse.tsx +1 -1
  27. package/src/components/tables/SearchComponent/SearchComponent.tsx +2 -2
  28. package/src/components/tables/TableComponent/TableComponent.tsx +1 -1
  29. package/src/data/SelectMock.tsx +1 -1
  30. package/src/data/enums/scopes.ts +5 -0
  31. package/src/data/index.ts +1 -0
  32. package/src/helpers/CheckPermission.tsx +12 -0
  33. package/src/index.tsx +1 -0
  34. package/src/stories/Fields/Fields.stories.tsx +274 -0
  35. package/src/stories/Layouts/MainLayoutSimple.stories.tsx +13 -1
  36. package/src/stories/MainWrapper/MainWrapper.stories.tsx +31 -2
package/README.md CHANGED
@@ -116,7 +116,6 @@ declare var __DEV__: boolean;
116
116
 
117
117
  // inside your code...
118
118
  if (__DEV__) {
119
- console.log('foo');
120
119
  }
121
120
  ```
122
121
 
@@ -24,9 +24,11 @@ interface TextFieldComponentProps {
24
24
  multiline?: boolean;
25
25
  rows?: number;
26
26
  maxLength?: number;
27
+ defaultValue?: string;
27
28
  onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
28
29
  onKeyUp?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
29
30
  step?: number | string;
31
+ noBorders?: boolean;
30
32
  }
31
33
  export declare const TextFieldComponent: React.FC<TextFieldComponentProps>;
32
34
  export {};
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import './TextSimpleComponent.scss';
3
+ interface TextSimpleComponentProps {
4
+ label?: string;
5
+ value?: any;
6
+ className?: string;
7
+ error?: boolean;
8
+ startIcon?: React.ReactNode;
9
+ endIcon?: React.ReactNode;
10
+ helperText?: string;
11
+ noBorders?: boolean;
12
+ fullWidth?: boolean;
13
+ }
14
+ export declare const TextSimpleComponent: React.FC<TextSimpleComponentProps>;
15
+ export {};
@@ -14,7 +14,7 @@ export interface NavigationProps {
14
14
  }
15
15
  interface VerticalNavProps {
16
16
  items: NavigationProps[];
17
- userPermisions?: string[];
17
+ userPermisions?: string[] | string;
18
18
  onHide?: () => void;
19
19
  }
20
20
  export declare const VerticalNav: React.FC<VerticalNavProps>;
@@ -2,7 +2,7 @@ import { NavigationProps } from './VerticalNav';
2
2
  import React from 'react';
3
3
  interface VerticalNavItemProps {
4
4
  item: NavigationProps;
5
- userPermisions?: string[];
5
+ userPermisions?: string[] | string;
6
6
  onHide?: () => void;
7
7
  }
8
8
  declare const _default: React.NamedExoticComponent<VerticalNavItemProps>;
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { NavigationProps } from './VerticalNav';
3
3
  interface VerticalNavItemCollapseProps {
4
4
  item: NavigationProps;
5
- userPermisions?: string[];
5
+ userPermisions?: string[] | string;
6
6
  onHide?: () => void;
7
7
  }
8
8
  declare const _default: React.NamedExoticComponent<VerticalNavItemCollapseProps>;
@@ -5,5 +5,5 @@ interface ColourOption {
5
5
  }
6
6
  export declare const colourOptions: ColourOption[];
7
7
  export declare const ResponseHandler: (response: any) => any;
8
- export declare const SearchSimple: (filters: SearchFilters) => Promise<SearchResult<SearchSimpleResult>>;
8
+ export declare const SearchSimple: (_filters: SearchFilters) => Promise<SearchResult<SearchSimpleResult>>;
9
9
  export {};
@@ -0,0 +1,5 @@
1
+ export declare enum Scope {
2
+ SUPERADMIN = 1,
3
+ ADMIN = 2,
4
+ DRIVER = 3
5
+ }
@@ -1,3 +1,4 @@
1
1
  export * from './SelectMock';
2
2
  export * from './UserList';
3
3
  export * from './Values';
4
+ export * from './enums/scopes';
package/dist/index.d.ts CHANGED
@@ -10,6 +10,7 @@ export * from './components/layouts/DrawerLayout/DrawerSidebar/DrawerSidebar';
10
10
  export * from './components/layouts/Standard/AppHeader/AppHeader';
11
11
  export * from './components/fields/ButtonComponent/ButtonComponent';
12
12
  export * from './components/fields/TextFieldComponent/TextFieldComponent';
13
+ export * from './components/fields/TextSimpleComponent/TextSimpleComponent';
13
14
  export * from './components/fields/SelectFieldComponent/SelectField';
14
15
  export * from './components/fields/SelectFieldComponent/SelectAsyncField';
15
16
  export * from './components/forms/LoginForm';
@@ -3,3 +3,4 @@ declare const meta: Meta;
3
3
  export default meta;
4
4
  export declare const TextField: Story<import("@storybook/react").Args>;
5
5
  export declare const SelectFieldTemplate: Story<import("@storybook/react").Args>;
6
+ export declare const TextSimple: Story<import("@storybook/react").Args>;
@@ -1,4 +1,4 @@
1
1
  import { Meta, Story } from '@storybook/react';
2
2
  declare const meta: Meta;
3
3
  export default meta;
4
- export declare const Default: Story<import("@storybook/react").Args>;
4
+ export declare const Examples: Story<import("@storybook/react").Args>;
@@ -108,7 +108,7 @@ var DoubleFilter = function DoubleFilter(filters) {
108
108
  };
109
109
 
110
110
  var SearchComponent = function SearchComponent(props) {
111
- var _useState = React.useState(false),
111
+ var _useState = React.useState(!props.searchBar && !!props.filters),
112
112
  isOpen = _useState[0],
113
113
  setIsOpen = _useState[1];
114
114
 
@@ -207,7 +207,7 @@ var SearchComponent = function SearchComponent(props) {
207
207
  },
208
208
  display: "flex",
209
209
  width: "100%"
210
- }, props.searchBar, props.filters && React__default.createElement(material.Box, {
210
+ }, props.searchBar, props.filters && props.searchBar && React__default.createElement(material.Box, {
211
211
  onClick: function onClick() {
212
212
  return setIsOpen(!isOpen);
213
213
  },
@@ -477,7 +477,9 @@ var TableComponent = function TableComponent(props) {
477
477
  overflow: 'inherit !important',
478
478
  height: props.rows.length > 0 ? 'auto' : '80px'
479
479
  }
480
- }, React__default.createElement(_.CircularProgress, null))), props.rows && props.rows.length > 0 ? props.rows.map(function (row, index) {
480
+ }, React__default.createElement(_.CircularProgress, {
481
+ className: "circular-progress-main-color"
482
+ }))), props.rows && props.rows.length > 0 ? props.rows.map(function (row, index) {
481
483
  var rowColor = props.rowsColorColumn && ObjectbyString(row, props.rowsColorColumn.columnName) === props.rowsColorColumn.columnValue ? "row-color-" + props.rowsColorColumn.columnValue : '';
482
484
  return React__default.createElement(_.TableRow, {
483
485
  className: "table-rows " + rowColor + " " + (props.onClickRow ? 'row-click' : ''),
@@ -606,6 +608,10 @@ var MainLayoutSimple = function MainLayoutSimple(props) {
606
608
  var checkPermission = function checkPermission(persmisionAvailable, userRoles) {
607
609
  if (persmisionAvailable === null || persmisionAvailable === undefined || persmisionAvailable.length === 0) {
608
610
  return true;
611
+ } else {
612
+ if (userRoles === undefined || userRoles === null || userRoles === 0) {
613
+ return false;
614
+ }
609
615
  }
610
616
 
611
617
  if (userRoles && Array.isArray(userRoles) && Array.isArray(persmisionAvailable)) {
@@ -614,6 +620,14 @@ var checkPermission = function checkPermission(persmisionAvailable, userRoles) {
614
620
  });
615
621
  }
616
622
 
623
+ if (userRoles && !Array.isArray(userRoles) && !Array.isArray(persmisionAvailable)) {
624
+ return userRoles === persmisionAvailable;
625
+ }
626
+
627
+ if (userRoles && !Array.isArray(userRoles) && Array.isArray(persmisionAvailable)) {
628
+ return persmisionAvailable.indexOf(userRoles) >= 0;
629
+ }
630
+
617
631
  return userRoles.indexOf(persmisionAvailable) >= 0;
618
632
  };
619
633
 
@@ -951,7 +965,7 @@ var ButtonComponent = function ButtonComponent(props) {
951
965
  }) : props.label);
952
966
  };
953
967
 
954
- var css_248z$b = ".text-field-component .MuiFormLabel-root {\n color: #666666 !important;\n font-size: calc(12pt + (14 - 12) * calc(100vw - 300px)/1300) !important;\n transform: translate(0, 0.5px) scale(0.85);\n transform-origin: top left;\n text-overflow: initial !important;\n}\n.text-field-component .MuiFormLabel-root + .MuiInputBase-formControl {\n margin-top: 25px !important;\n}\n.text-field-component .MuiInputBase-root {\n color: #666666 !important;\n border: 1px solid grey;\n padding: 0.43rem 0.87rem;\n background-color: white !important;\n border-radius: 3px !important;\n}\n.text-field-component .MuiInputBase-root.Mui-error {\n border: 1px solid #F24726 !important;\n}\n.text-field-component .MuiInputBase-root:not(.Mui-disabled):hover {\n border: 1px solid grey;\n}\n.text-field-component .MuiInputBase-root.Mui-focused {\n border: 1px solid #3299C7;\n}\n.text-field-component .MuiInputBase-root .MuiInputBase-input {\n color: #666666 !important;\n background-color: white !important;\n}\n.text-field-component .MuiInputBase-root .MuiInputBase-input::placeholder {\n text-overflow: ellipsis !important;\n color: #666666 !important;\n opacity: 1;\n}\n.text-field-component .MuiInputBase-root .Mui-disabled {\n -webkit-text-fill-color: #666666 !important;\n}\n.text-field-component .MuiFormHelperText-root {\n padding: 0 !important;\n font-size: 0.85rem !important;\n color: #666666;\n}";
968
+ var css_248z$b = ".text-field-component .MuiFormLabel-root {\n color: #666666 !important;\n font-size: calc(12pt + (14 - 12) * calc(100vw - 300px)/1300) !important;\n transform: translate(0, 0.5px) scale(0.85);\n transform-origin: top left;\n text-overflow: initial !important;\n}\n.text-field-component .MuiFormLabel-root + .MuiInputBase-formControl {\n margin-top: 25px !important;\n}\n.text-field-component .MuiInputBase-root.no-border {\n border: none !important;\n padding: 0 !important;\n width: fit-content !important;\n}\n.text-field-component .MuiInputBase-root {\n color: #666666 !important;\n border: 1px solid grey;\n padding: 0.43rem 0.87rem;\n background-color: white !important;\n border-radius: 3px !important;\n}\n.text-field-component .MuiInputBase-root.Mui-error {\n border: 1px solid #F24726 !important;\n}\n.text-field-component .MuiInputBase-root:not(.Mui-disabled):hover {\n border: 1px solid grey;\n}\n.text-field-component .MuiInputBase-root.Mui-focused {\n border: 1px solid #3299C7;\n}\n.text-field-component .MuiInputBase-root .MuiInputBase-input {\n color: #666666 !important;\n background-color: white !important;\n}\n.text-field-component .MuiInputBase-root .MuiInputBase-input::placeholder {\n text-overflow: ellipsis !important;\n color: #666666 !important;\n opacity: 1;\n}\n.text-field-component .MuiInputBase-root .Mui-disabled {\n -webkit-text-fill-color: #666666 !important;\n}\n.text-field-component .MuiFormHelperText-root {\n padding: 0 !important;\n font-size: 0.85rem !important;\n color: #666666;\n}";
955
969
  styleInject(css_248z$b);
956
970
 
957
971
  var TextFieldComponent = function TextFieldComponent(props) {
@@ -973,7 +987,8 @@ var TextFieldComponent = function TextFieldComponent(props) {
973
987
  error: props.error,
974
988
  id: props.id,
975
989
  label: props.label,
976
- defaultValue: props.value,
990
+ value: props.value,
991
+ defaultValue: props.defaultValue,
977
992
  className: props.className,
978
993
  required: props.required,
979
994
  disabled: props.disabled,
@@ -983,7 +998,7 @@ var TextFieldComponent = function TextFieldComponent(props) {
983
998
  variant: "standard",
984
999
  ref: props.inputRef,
985
1000
  InputProps: {
986
- className: "" + (!props.disabled && hover ? 'main-border-color' : ''),
1001
+ className: (props.noBorders ? 'no-border' : '') + " " + (!props.disabled && hover ? 'main-border-color' : ''),
987
1002
  disableUnderline: true,
988
1003
  startAdornment: props.startIcon,
989
1004
  endAdornment: props.endIcon,
@@ -1015,9 +1030,34 @@ TextFieldComponent.defaultProps = {
1015
1030
  type: 'text'
1016
1031
  };
1017
1032
 
1018
- var css_248z$c = ".select-field .MuiFormLabel-root {\n color: #666666 !important;\n font-size: calc(12pt + (14 - 12) * calc(100vw - 300px)/1300) !important;\n transform: translate(0, 0.5px) scale(0.85);\n transform-origin: top left;\n text-overflow: initial !important;\n}\n.select-field .select {\n font-size: 1rem;\n}\n.select-field .select__menu {\n z-index: 3 !important;\n background-color: white;\n}\n.select-field .select__control {\n cursor: pointer;\n border: 1px solid grey;\n border-radius: 5px !important;\n padding: 0.33rem 0.2rem;\n font-size: 1rem;\n color: grey !important;\n background-color: transparent;\n}\n.select-field .select__option {\n cursor: pointer;\n color: #666666 !important;\n background-color: white !important;\n}\n.select-field .select__option--is-focused {\n background-color: rgba(0, 0, 0, 0.04) !important;\n color: #666666 !important;\n}\n.select-field .select__option--is-selected {\n color: white !important;\n}\n.select-field .select__indicator {\n color: grey !important;\n}\n.select-field .select__indicator:hover {\n color: black !important;\n}\n.select-field .select__placeholder {\n text-overflow: ellipsis !important;\n color: #666666 !important;\n opacity: 1;\n}\n.select-field .select__single-value {\n color: #666666 !important;\n}\n.select-field .select__multi-value__label {\n color: #666666 !important;\n font-size: 1rem;\n}\n.select-field .select__control--is-focused {\n border-color: grey !important;\n box-shadow: none !important;\n}\n.select-field .helper-text {\n font-size: 0.85rem !important;\n padding: 0 !important;\n margin-top: 3px;\n line-height: 1.66;\n color: #666666 !important;\n letter-spacing: 0.03333em;\n}\n.select-field .has-error {\n color: #F24726 !important;\n}\n.select-field .has-error .select__control {\n border: 1px #F24726 solid !important;\n}\n.select-field .has-error .select__control--is-focused {\n border-color: #F24726 !important;\n box-shadow: 0 0 0 1px #F24726;\n}";
1033
+ var css_248z$c = ".text-simple-component .MuiFormLabel-root {\n color: #666666 !important;\n font-size: calc(12pt + (14 - 12) * calc(100vw - 300px)/1300) !important;\n transform: translate(0, 0.5px) scale(0.85);\n transform-origin: top left;\n text-overflow: initial !important;\n}\n.text-simple-component .MuiFormLabel-root + .text-simple-box.no-border {\n margin-top: 7px !important;\n}\n.text-simple-component .text-simple-box.no-border {\n border: none !important;\n padding: 0 !important;\n}\n.text-simple-component .text-simple-box {\n color: #666666 !important;\n font-size: 1rem;\n border: 1px solid grey;\n padding: 0.868rem;\n border-radius: 3px !important;\n}\n.text-simple-component .helper-text {\n font-size: 0.85rem !important;\n padding: 0 !important;\n margin-top: 3px;\n line-height: 1.66;\n color: #666666 !important;\n letter-spacing: 0.03333em;\n}\n.text-simple-component .has-error-border {\n border-color: #F24726 !important;\n}\n.text-simple-component .has-error {\n color: #F24726 !important;\n}";
1019
1034
  styleInject(css_248z$c);
1020
1035
 
1036
+ var TextSimpleComponent = function TextSimpleComponent(props) {
1037
+ return React__default.createElement(_.Box, {
1038
+ className: "text-simple-component",
1039
+ display: "flex",
1040
+ flexDirection: "column"
1041
+ }, props.label && React__default.createElement(_.FormLabel, null, props.label), React__default.createElement(_.Box, {
1042
+ display: "flex",
1043
+ alignItems: "center",
1044
+ className: "text-simple-box " + (props.className ? props.className : '') + " " + (props.noBorders ? 'no-border' : '') + " " + (props.error ? 'has-error-border' : ''),
1045
+ width: "" + (props.fullWidth ? 'auto' : 'fit-content')
1046
+ }, props.startIcon && React__default.createElement(_.Box, {
1047
+ mr: 1
1048
+ }, props.startIcon), props.value, props.endIcon && React__default.createElement(_.Box, {
1049
+ ml: "" + (props.fullWidth ? 'auto' : 1)
1050
+ }, props.endIcon)), props.helperText && React__default.createElement(_.Box, {
1051
+ className: "helper-text " + (props.error ? 'has-error' : '')
1052
+ }, props.helperText));
1053
+ };
1054
+ TextSimpleComponent.defaultProps = {
1055
+ noBorders: true
1056
+ };
1057
+
1058
+ var css_248z$d = ".select-field .MuiFormLabel-root {\n color: #666666 !important;\n font-size: calc(12pt + (14 - 12) * calc(100vw - 300px)/1300) !important;\n transform: translate(0, 0.5px) scale(0.85);\n transform-origin: top left;\n text-overflow: initial !important;\n}\n.select-field .select {\n font-size: 1rem;\n}\n.select-field .select__menu {\n z-index: 3 !important;\n background-color: white;\n}\n.select-field .select__control {\n cursor: pointer;\n border: 1px solid grey;\n border-radius: 5px !important;\n padding: 0.33rem 0.2rem;\n font-size: 1rem;\n color: grey !important;\n background-color: transparent;\n}\n.select-field .select__option {\n cursor: pointer;\n color: #666666 !important;\n background-color: white !important;\n}\n.select-field .select__option--is-focused {\n background-color: rgba(0, 0, 0, 0.04) !important;\n color: #666666 !important;\n}\n.select-field .select__option--is-selected {\n color: white !important;\n}\n.select-field .select__indicator {\n color: grey !important;\n}\n.select-field .select__indicator:hover {\n color: black !important;\n}\n.select-field .select__placeholder {\n text-overflow: ellipsis !important;\n color: #666666 !important;\n opacity: 1;\n}\n.select-field .select__single-value {\n color: #666666 !important;\n}\n.select-field .select__multi-value__label {\n color: #666666 !important;\n font-size: 1rem;\n}\n.select-field .select__control--is-focused {\n border-color: grey !important;\n box-shadow: none !important;\n}\n.select-field .helper-text {\n font-size: 0.85rem !important;\n padding: 0 !important;\n margin-top: 3px;\n line-height: 1.66;\n color: #666666 !important;\n letter-spacing: 0.03333em;\n}\n.select-field .has-error {\n color: #F24726 !important;\n}\n.select-field .has-error .select__control {\n border: 1px #F24726 solid !important;\n}\n.select-field .has-error .select__control--is-focused {\n border-color: #F24726 !important;\n box-shadow: 0 0 0 1px #F24726;\n}";
1059
+ styleInject(css_248z$d);
1060
+
1021
1061
  var SelectField = function SelectField(props) {
1022
1062
  return React__default.createElement(_.Box, {
1023
1063
  className: "select-field",
@@ -2255,8 +2295,8 @@ ModalComponent.defaultProps = {
2255
2295
  dividers: true
2256
2296
  };
2257
2297
 
2258
- var css_248z$d = ".tabs-component .Mui-selected {\n color: white !important;\n border: none !important;\n background-color: #3299C7;\n}\n.tabs-component .MuiTabs-indicator {\n display: none;\n}\n.tabs-component .MuiTab-root {\n margin: 2px 2px 0px;\n border: 1px solid #00000038;\n border-bottom: none;\n border-radius: 5% 5% 0% 0%;\n color: rgba(0, 0, 0, 0.54);\n}\n.tabs-component .MuiTabPanel-root {\n border: 1px solid #00000038;\n margin: 0px 2px 0px;\n border-radius: 0% 5px 5px 5px;\n}";
2259
- styleInject(css_248z$d);
2298
+ var css_248z$e = ".tabs-component .Mui-selected {\n color: white !important;\n border: none !important;\n background-color: #3299C7;\n}\n.tabs-component .MuiTabs-indicator {\n display: none;\n}\n.tabs-component .MuiTab-root {\n margin: 2px 2px 0px;\n border: 1px solid #00000038;\n border-bottom: none;\n border-radius: 5% 5% 0% 0%;\n color: rgba(0, 0, 0, 0.54);\n}\n.tabs-component .MuiTabPanel-root {\n border: 1px solid #00000038;\n margin: 0px 2px 0px;\n border-radius: 0% 5px 5px 5px;\n}";
2299
+ styleInject(css_248z$e);
2260
2300
 
2261
2301
  var TabsComponent = function TabsComponent(props) {
2262
2302
  var _React$useState = React__default.useState(props.tabActive.toString()),
@@ -2308,6 +2348,7 @@ exports.SelectField = SelectField;
2308
2348
  exports.TableComponent = TableComponent;
2309
2349
  exports.TabsComponent = TabsComponent;
2310
2350
  exports.TextFieldComponent = TextFieldComponent;
2351
+ exports.TextSimpleComponent = TextSimpleComponent;
2311
2352
  exports.UserInfo = UserInfo;
2312
2353
  exports.VerticalNav = VerticalNav;
2313
2354
  //# sourceMappingURL=techsbcn-storybook.cjs.development.js.map