linear-react-components-ui 1.1.3 → 1.1.4

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/lib/list/Item.js CHANGED
@@ -51,14 +51,23 @@ const Item = props => {
51
51
  const options = [_permissionValidations.OPTIONS_ON_DENIED.disabled, _permissionValidations.OPTIONS_ON_DENIED.unvisible];
52
52
  const [onDenied] = (0, _react.useState)((0, _permissionValidations.actionsOnPermissionDenied)(options, permissionAttr));
53
53
  const navigate = (0, _reactRouterDom.useNavigate)();
54
+ const disabledByPermission = onDenied.disabled;
54
55
  const shouldDisable = () => disabled || onDenied.disabled;
56
+ const disabledIconColor = 'rgb(193, 193, 193)';
55
57
  const getClass = () => "item ".concat(customClass, " ").concat(separator && 'list-separator', " ").concat(shouldDisable() && 'disabled', "\n ").concat(displayCheckbox && 'list-checkbox');
56
58
  const getIcon = (iconName, icon) => {
59
+ const noIconDisabledByPermission = !icon && !displayCheckbox && !leftElement && !leftIconName && !leftIcon && onDenied.disabled;
57
60
  if (icon) {
58
61
  return icon;
62
+ } else if (noIconDisabledByPermission) {
63
+ return /*#__PURE__*/_react.default.createElement(_icons.default, {
64
+ name: "padlock",
65
+ color: disabledIconColor
66
+ });
59
67
  } else if (iconName) {
60
68
  return /*#__PURE__*/_react.default.createElement(_icons.default, {
61
- name: iconName
69
+ name: !disabledByPermission ? iconName : 'padlock',
70
+ color: !disabledByPermission ? '' : disabledIconColor
62
71
  });
63
72
  }
64
73
  return null;
@@ -94,6 +103,18 @@ const Item = props => {
94
103
  document.removeEventListener('keydown', onKeyDown);
95
104
  };
96
105
  }, [url, selectedItemId, itemId]);
106
+ const renderCheckBox = (0, _react.useMemo)(() => {
107
+ if (!disabledByPermission && displayCheckbox) {
108
+ return /*#__PURE__*/_react.default.createElement(_checkbox.default, {
109
+ name: "checkbox"
110
+ });
111
+ } else if (disabledByPermission && displayCheckbox) {
112
+ return /*#__PURE__*/_react.default.createElement(_icons.default, {
113
+ name: "padlock"
114
+ });
115
+ }
116
+ return null;
117
+ }, [disabledByPermission && displayCheckbox]);
97
118
  if (!visible || onDenied.unvisible) return null;
98
119
  return /*#__PURE__*/_react.default.createElement("li", _extends({
99
120
  ref: itemId && selectedItemId === itemId ? selectedItemRef : null,
@@ -106,15 +127,13 @@ const Item = props => {
106
127
  to: url
107
128
  }), (displayCheckbox || leftElement || leftIconName || leftIcon) && /*#__PURE__*/_react.default.createElement("div", {
108
129
  className: "".concat(getClass(), " -icon-left")
109
- }, displayCheckbox && /*#__PURE__*/_react.default.createElement(_checkbox.default, {
110
- name: "checkbox"
111
- }), leftElement, getIcon(leftIconName, leftIcon)), (text || subText || children) && /*#__PURE__*/_react.default.createElement("div", {
130
+ }, renderCheckBox, leftElement, getIcon(leftIconName, leftIcon)), (text || subText || children) && /*#__PURE__*/_react.default.createElement("div", {
112
131
  className: "".concat(getClass())
113
132
  }, /*#__PURE__*/_react.default.createElement("p", {
114
133
  className: "".concat(text && 'text')
115
134
  }, text), /*#__PURE__*/_react.default.createElement("p", {
116
135
  className: "".concat(subText && 'subtext')
117
- }, subText), children), (rightIconName || rightIcon || rightElement) && /*#__PURE__*/_react.default.createElement("div", {
136
+ }, subText), children), (rightIconName || rightIcon || rightElement || disabledByPermission) && /*#__PURE__*/_react.default.createElement("div", {
118
137
  className: "".concat(getClass(), " -icon-right")
119
138
  }, getIcon(rightIconName, rightIcon), rightElement));
120
139
  };
@@ -1,6 +1,6 @@
1
1
  import { ITableHeaderProps } from './types.js';
2
2
  import 'react';
3
3
 
4
- declare const HeaderColumn: ({ customClass, style, children, textAlign, visible, id, rowSpan, colSpan, }: ITableHeaderProps) => JSX.Element | null;
4
+ declare const HeaderColumn: ({ customClass, style, children, textAlign, visible, id, rowSpan, colSpan, isMenuColumn, }: ITableHeaderProps) => JSX.Element | null;
5
5
 
6
6
  export { HeaderColumn as default };
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
+ var _icons = _interopRequireDefault(require("../icons"));
8
9
  var _skeleton = _interopRequireDefault(require("../skeleton"));
9
10
  var _helpers = _interopRequireDefault(require("./helpers"));
10
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -19,7 +20,8 @@ const HeaderColumn = _ref => {
19
20
  visible = true,
20
21
  id,
21
22
  rowSpan,
22
- colSpan
23
+ colSpan,
24
+ isMenuColumn = false
23
25
  } = _ref;
24
26
  const {
25
27
  skeletonize,
@@ -27,18 +29,26 @@ const HeaderColumn = _ref => {
27
29
  skeletonInHeader,
28
30
  skeletonInRows = 10
29
31
  } = (0, _react.useContext)(_helpers.default);
32
+ const getChildren = function () {
33
+ let childrenIsMenuColum = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
34
+ if (!childrenIsMenuColum) return children;
35
+ return /*#__PURE__*/_react.default.createElement(_icons.default, {
36
+ name: "menu4",
37
+ size: 22
38
+ });
39
+ };
30
40
  if (!visible) return null;
31
41
  return /*#__PURE__*/_react.default.createElement("th", {
32
42
  id: id,
33
43
  rowSpan: rowSpan,
34
44
  colSpan: colSpan,
35
- className: "headercolumn ".concat(customClass, " text-align-").concat(textAlign),
45
+ className: "headercolumn ".concat(customClass, " text-align-").concat(textAlign, " ").concat(isMenuColumn && 'menu-column'),
36
46
  style: style
37
47
  }, skeletonize && (skeletonInHeader || !skeletonInRows) && !vertical ? /*#__PURE__*/_react.default.createElement(_skeleton.default, {
38
48
  height: style && style.height ? undefined : 16,
39
49
  style: {
40
50
  marginBottom: 0
41
51
  }
42
- }) : children);
52
+ }) : getChildren(isMenuColumn));
43
53
  };
44
54
  var _default = exports.default = HeaderColumn;
@@ -42,7 +42,8 @@ const RowColumn = props => {
42
42
  textAlign,
43
43
  visible = true,
44
44
  rowSpan,
45
- colSpan
45
+ colSpan,
46
+ children
46
47
  } = props;
47
48
  const context = (0, _react.useContext)(_helpers.RowContext);
48
49
  const {
@@ -51,8 +52,7 @@ const RowColumn = props => {
51
52
  skeletonInRows = 10
52
53
  } = context;
53
54
  const hiddenContent = displayContent !== 'always';
54
- const childrenProps = props.children;
55
- const renderContent = () => {
55
+ const renderContent = (0, _react.useCallback)(() => {
56
56
  if (skeletonize && vertical) {
57
57
  return /*#__PURE__*/_react.default.createElement(_skeleton.default, {
58
58
  height: 16,
@@ -63,8 +63,8 @@ const RowColumn = props => {
63
63
  }
64
64
  return hiddenContent && displayContent ? /*#__PURE__*/_react.default.createElement("span", {
65
65
  className: displayClass[displayContent]
66
- }, childrenProps) : childrenProps;
67
- };
66
+ }, children) : children;
67
+ }, [skeletonize, vertical, children, displayContent, hiddenContent, displayClass]);
68
68
  if (!visible) return null;
69
69
  if (skeletonize && !skeletonInRows && !vertical) return null;
70
70
  return /*#__PURE__*/_react.default.createElement("td", {
@@ -72,9 +72,7 @@ const RowColumn = props => {
72
72
  colSpan: colSpan,
73
73
  className: "rowcolumn ".concat(customClass, " text-align-").concat(textAlign, " ").concat(!context.rowBorder && ' -noborder', " ").concat(!rowSpan ? ' -norowspan' : ''),
74
74
  style: style,
75
- onClick: e => {
76
- getColClickEvent(e, _objectSpread(_objectSpread({}, context), props));
77
- },
75
+ onClick: e => getColClickEvent(e, _objectSpread(_objectSpread({}, context), props)),
78
76
  role: "presentation",
79
77
  tabIndex: -1
80
78
  }, renderContent());
@@ -27,6 +27,7 @@ interface ITableHeaderProps extends TableHTMLAttributes<HTMLTableElement> {
27
27
  id?: string;
28
28
  rowSpan?: number;
29
29
  colSpan?: number;
30
+ isMenuColumn?: boolean;
30
31
  }
31
32
  interface ITableBodyProps extends TableHTMLAttributes<HTMLTableElement> {
32
33
  children?: ReactNode;
@@ -26,6 +26,7 @@ interface IButtonBarProps {
26
26
  iconAlign?: Exclude<Position, 'top' | 'bottom'>;
27
27
  validationKey?: string;
28
28
  boxShadow?: boolean;
29
+ id?: string;
29
30
  onNodeElementClick?: (node: NodeItem) => void;
30
31
  }
31
32
  interface ILabelBarProps {
@@ -1,6 +1,7 @@
1
+ import React__default from 'react';
1
2
  import { IUITourProps } from './types.js';
2
3
  import './helpers.js';
3
4
 
4
- declare const UiTour: (props: IUITourProps) => JSX.Element | null;
5
+ declare const UiTour: (props: IUITourProps) => React__default.ReactPortal | null;
5
6
 
6
7
  export { UiTour as default };
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
+ var _reactDom = require("react-dom");
8
9
  var _buttons = _interopRequireWildcard(require("../buttons"));
9
10
  require("../assets/styles/uitour.scss");
10
11
  var _helpers = require("./helpers");
@@ -24,7 +25,8 @@ const UiTour = props => {
24
25
  showCloseButton = true,
25
26
  showBackButton = true,
26
27
  visible = true,
27
- onFinish
28
+ onFinish,
29
+ onStepChange
28
30
  } = props;
29
31
  const [currentStep, setCurrentStep] = (0, _react.useState)(undefined);
30
32
  const [hasNextStep, setHasNextStep] = (0, _react.useState)(false);
@@ -35,6 +37,7 @@ const UiTour = props => {
35
37
  const [stepPosition, setStepPosition] = (0, _react.useState)(_helpers.STEP_POSITIONS.left);
36
38
  const stepRef = (0, _react.useRef)(null);
37
39
  const descriptionRef = (0, _react.useRef)(null);
40
+ const activatedEffects = (0, _react.useRef)([]);
38
41
  const handleNextStep = () => {
39
42
  if (hasNextStep) {
40
43
  const currentStepIndex = data.findIndex(item => item.id === (currentStep === null || currentStep === void 0 ? void 0 : currentStep.id));
@@ -88,6 +91,46 @@ const UiTour = props => {
88
91
  setShowTour(visible);
89
92
  setCurrentStep(step);
90
93
  };
94
+ const removePreviousElementsEffects = () => {
95
+ if (activatedEffects.current.length > 0) {
96
+ const effects = activatedEffects.current;
97
+ effects.forEach(ef => {
98
+ const element = document.getElementById(ef.elementId);
99
+ if (element) {
100
+ delete element.dataset.uitour;
101
+ activatedEffects.current = activatedEffects.current.filter(r => r.elementId !== ef.elementId);
102
+ }
103
+ });
104
+ }
105
+ };
106
+ const addElementEffect = (0, _react.useCallback)(elementEffect => {
107
+ const element = document.getElementById(elementEffect.elementId);
108
+ if (element) {
109
+ element.dataset.uitour = elementEffect.effect;
110
+ if (activatedEffects.current) activatedEffects.current.push(elementEffect);
111
+ }
112
+ }, []);
113
+ const showElementsEffects = currentData => {
114
+ if (currentData.effect) {
115
+ const {
116
+ effect,
117
+ targetId
118
+ } = currentData;
119
+ addElementEffect({
120
+ effect,
121
+ elementId: targetId
122
+ });
123
+ }
124
+ if (currentData.elementsEffects) {
125
+ let {
126
+ elementsEffects
127
+ } = currentData;
128
+ if (!Array.isArray(elementsEffects)) elementsEffects = [elementsEffects];
129
+ elementsEffects.forEach(ef => {
130
+ addElementEffect(ef);
131
+ });
132
+ }
133
+ };
91
134
  (0, _react.useEffect)(() => {
92
135
  if (currentStep) {
93
136
  const target = document.getElementById(currentStep.targetId);
@@ -113,6 +156,9 @@ const UiTour = props => {
113
156
  setIsLastStep(false);
114
157
  }
115
158
  getStepPosition(targetRect);
159
+ removePreviousElementsEffects();
160
+ showElementsEffects(data[currentStepIndex]);
161
+ if (onStepChange) onStepChange(target);
116
162
  }
117
163
  if (descriptionRef.current) {
118
164
  descriptionRef.current.innerHTML = currentStep.description;
@@ -151,8 +197,13 @@ const UiTour = props => {
151
197
  mutationObserver = null;
152
198
  };
153
199
  }, [visible, data]);
154
- if (!showTour) return null;
155
- return /*#__PURE__*/_react.default.createElement("div", {
200
+ (0, _react.useEffect)(() => {
201
+ if (!showTour && activatedEffects.current.length > 0) {
202
+ removePreviousElementsEffects();
203
+ }
204
+ if (showTour) document.body.style.overflow = 'hidden';else document.body.style.overflow = 'auto';
205
+ }, [showTour, activatedEffects.current.length]);
206
+ const component = (0, _react.useMemo)(() => /*#__PURE__*/_react.default.createElement("div", {
156
207
  className: "uitour-component"
157
208
  }, currentStep && /*#__PURE__*/_react.default.createElement("div", {
158
209
  ref: stepRef,
@@ -199,6 +250,8 @@ const UiTour = props => {
199
250
  visible: isLastStep,
200
251
  onClick: onCloseTour,
201
252
  customClass: "finish-button"
202
- }))));
253
+ })))), [currentStep, stepPosition, stepDimensions, showCloseButton, onCloseTour, backButtonLabel, handleBackStep, hasBackStep, showBackButton, nextButtonLabel, handleNextStep, hasNextStep, isLastStep, finishButtonLabel, isLastStep, onCloseTour]);
254
+ if (!showTour) return null;
255
+ return /*#__PURE__*/(0, _reactDom.createPortal)(component, document.body);
203
256
  };
204
257
  var _default = exports.default = UiTour;
@@ -1,11 +1,18 @@
1
1
  import { STEP_POSITIONS } from './helpers.js';
2
2
 
3
+ type Effect = 'hover' | 'focus' | 'blur' | 'active' | 'selected';
4
+ type ElementEffect = {
5
+ elementId: string;
6
+ effect: Effect;
7
+ };
3
8
  type UITourData = {
4
9
  id: string | number;
5
10
  targetId: string;
11
+ effect?: Effect;
6
12
  title: string;
7
13
  description: string;
8
14
  position?: keyof typeof STEP_POSITIONS;
15
+ elementsEffects?: ElementEffect | ElementEffect[];
9
16
  };
10
17
  interface CurrentStep extends UITourData {
11
18
  number: number;
@@ -25,6 +32,7 @@ interface IUITourProps {
25
32
  showBackButton?: boolean;
26
33
  visible?: boolean;
27
34
  onFinish: (value: boolean) => void;
35
+ onStepChange?: (target: HTMLElement) => void;
28
36
  }
29
37
 
30
- export { CurrentStep, IUITourProps, StepDimensions, UITourData };
38
+ export { CurrentStep, Effect, ElementEffect, IUITourProps, StepDimensions, UITourData };
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "linear-react-components-ui",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "Linear Sistemas ReactJs Components",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.cjs",
7
7
  "scripts": {
8
8
  "lib": "babel src/lib/ -d lib/ --extensions \".js,.jsx,.ts,.tsx\" --ignore **/*.spec.tsx && babel src/lib/assets -d lib/assets --copy-files && npm run lib:types",
9
- "lib:types": "NODE_OPTIONS='--max-old-space-size=16384' tsup --dts-only --dts --external react",
9
+ "lib:types": "tsup --dts-only --dts --external react",
10
10
  "demo": "node scripts/start.js",
11
11
  "demo:prod": "webpack --config ./config/webpack.config.js --mode production",
12
12
  "check:js": "eslint ./src/** --ext=.jsx,.js,.tsx,.ts --cache",
@@ -108,8 +108,8 @@
108
108
  "sass": "1.74.1",
109
109
  "sass-loader": "14.1.0",
110
110
  "style-loader": "3.3.4",
111
- "tsup": "8.0.1",
112
- "typescript": "5.3.3",
111
+ "tsup": "6.6.0",
112
+ "typescript": "4.9.5",
113
113
  "webpack": "5.90.0",
114
114
  "webpack-cli": "5.1.4",
115
115
  "webpack-dev-server": "4.15.1",