linear-react-components-ui 1.1.20-beta.12 → 1.1.20-beta.14
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/alerts/BaseAlert.js +1 -1
- package/lib/alerts/Message.js +1 -1
- package/lib/assets/styles/button.scss +0 -1
- package/lib/assets/styles/select.scss +2 -1
- package/lib/assets/styles/table.scss +10 -6
- package/lib/assets/styles/toolbar.scss +3 -0
- package/lib/assets/styles/wizard.scss +127 -0
- package/lib/avatar/index.js +8 -9
- package/lib/badge/index.js +4 -4
- package/lib/buttons/DangerButton.js +1 -1
- package/lib/buttons/DefaultButton.js +5 -17
- package/lib/buttons/InfoButton.js +1 -1
- package/lib/buttons/PrimaryButton.js +1 -1
- package/lib/buttons/SuccessButton.js +1 -1
- package/lib/buttons/WarningButton.js +1 -1
- package/lib/buttons/button_container/index.js +1 -1
- package/lib/buttons/split_button/index.js +1 -1
- package/lib/buttons/types.d.ts +0 -1
- package/lib/calendar/base/Day.js +1 -1
- package/lib/calendar/base/Month.js +1 -1
- package/lib/calendar/base/helpers.js +2 -2
- package/lib/calendar/base/index.js +1 -1
- package/lib/dialog/Custom.js +1 -1
- package/lib/dialog/base/Content.d.ts +1 -1
- package/lib/dialog/base/Content.js +3 -2
- package/lib/dialog/base/Header.js +2 -2
- package/lib/dialog/base/index.js +6 -4
- package/lib/dialog/form/index.js +8 -3
- package/lib/dialog/types.d.ts +36 -4
- package/lib/dialog/wizard/index.d.ts +13 -0
- package/lib/dialog/wizard/index.js +78 -0
- package/lib/dialog/wizard/progressbar.d.ts +13 -0
- package/lib/dialog/wizard/progressbar.js +36 -0
- package/lib/dialog/wizard/step.d.ts +9 -0
- package/lib/dialog/wizard/step.js +22 -0
- package/lib/dialog/wizard/useWizard.d.ts +9 -0
- package/lib/dialog/wizard/useWizard.js +48 -0
- package/lib/drawer/Drawer.js +3 -3
- package/lib/drawer/Header.js +1 -1
- package/lib/dropdown/Popup.d.ts +1 -1
- package/lib/dropdown/Popup.js +22 -43
- package/lib/dropdown/helper.js +1 -1
- package/lib/dropdown/types.d.ts +2 -6
- package/lib/dropdown/withDropdown.js +6 -7
- package/lib/fieldset/index.js +7 -7
- package/lib/form/Field.js +11 -24
- package/lib/form/FieldArray.js +10 -25
- package/lib/form/FieldNumber.js +9 -21
- package/lib/form/FieldPeriod.js +5 -5
- package/lib/form/index.js +9 -6
- package/lib/form/types.d.ts +10 -6
- package/lib/form/withFieldHOC.js +2 -2
- package/lib/gridlayout/GridCol.js +5 -5
- package/lib/gridlayout/GridRow.js +1 -4
- package/lib/gridlayout/types.d.ts +1 -1
- package/lib/hint/index.js +1 -7
- package/lib/icons/helper.d.ts +20 -0
- package/lib/icons/helper.js +20 -0
- package/lib/icons/index.js +27 -24
- package/lib/inputs/base/InputTextBase.js +9 -6
- package/lib/inputs/base/Label.js +1 -1
- package/lib/inputs/base/helpers.js +3 -7
- package/lib/inputs/date/helpers.js +1 -4
- package/lib/inputs/date/index.js +15 -9
- package/lib/inputs/errorMessage/index.js +1 -1
- package/lib/inputs/file/DefaultFile.js +6 -5
- package/lib/inputs/file/DragDropFile.js +17 -15
- package/lib/inputs/file/File.js +4 -3
- package/lib/inputs/mask/BaseMask.js +1 -1
- package/lib/inputs/multiSelect/Dropdown.js +10 -9
- package/lib/inputs/multiSelect/helper.js +2 -1
- package/lib/inputs/multiSelect/index.js +9 -7
- package/lib/inputs/number/BaseNumber.d.ts +1 -1
- package/lib/inputs/number/BaseNumber.js +2 -9
- package/lib/inputs/number/Currency.d.ts +1 -1
- package/lib/inputs/number/Currency.js +4 -11
- package/lib/inputs/number/index.js +1 -1
- package/lib/inputs/period/PeriodList.js +1 -1
- package/lib/inputs/period/helper.js +1 -3
- package/lib/inputs/period/index.js +14 -9
- package/lib/inputs/search/index.js +1 -1
- package/lib/inputs/select/Dropdown.js +1 -1
- package/lib/inputs/select/helper.js +13 -10
- package/lib/inputs/select/multiple/Selecteds.js +1 -1
- package/lib/inputs/select/multiple/index.js +19 -12
- package/lib/inputs/select/simple/index.js +22 -13
- package/lib/inputs/select/types.d.ts +1 -0
- package/lib/inputs/textarea/index.js +1 -1
- package/lib/internals/withTooltip.js +9 -9
- package/lib/labelMessages/index.js +3 -4
- package/lib/labels/DefaultLabel.js +1 -4
- package/lib/labels/label_container/index.js +1 -1
- package/lib/list/Header.js +1 -1
- package/lib/list/Item.js +7 -9
- package/lib/list/index.js +1 -1
- package/lib/menus/float/MenuItem.js +2 -2
- package/lib/menus/float/SubMenuContainer.js +1 -1
- package/lib/menus/float/index.js +1 -1
- package/lib/menus/sidenav/ExpandMenu.js +1 -1
- package/lib/menus/sidenav/NavMenuGroup.js +1 -1
- package/lib/menus/sidenav/NavMenuItem.js +9 -7
- package/lib/menus/sidenav/NavSubMenuItem.js +1 -1
- package/lib/menus/sidenav/helpers.js +1 -1
- package/lib/menus/sidenav/index.js +5 -5
- package/lib/panel/Content.js +7 -5
- package/lib/panel/Default.js +2 -2
- package/lib/panel/Header.js +3 -3
- package/lib/permissionValidations.js +1 -1
- package/lib/popover/PopoverText.d.ts +2 -3
- package/lib/popover/PopoverText.js +8 -5
- package/lib/popover/PopoverTitle.d.ts +0 -1
- package/lib/popover/index.d.ts +5 -3
- package/lib/popover/index.js +14 -20
- package/lib/popover/types.d.ts +1 -12
- package/lib/progress/Bar.js +6 -6
- package/lib/radio/index.d.ts +1 -1
- package/lib/radio/index.js +4 -4
- package/lib/radio/types.d.ts +2 -1
- package/lib/shortcuts/index.js +1 -1
- package/lib/skeleton/SkeletonContainer.js +1 -2
- package/lib/skeleton/index.js +1 -4
- package/lib/spinner/index.js +2 -2
- package/lib/split/Split.js +1 -1
- package/lib/split/SplitSide.js +3 -3
- package/lib/table/Body.js +3 -3
- package/lib/table/Header.js +11 -8
- package/lib/table/HeaderColumn.d.ts +1 -1
- package/lib/table/HeaderColumn.js +7 -6
- package/lib/table/Row.js +3 -3
- package/lib/table/RowColumn.js +3 -2
- package/lib/table/index.js +1 -6
- package/lib/table/types.d.ts +4 -2
- package/lib/tabs/DropdownTabs.js +1 -1
- package/lib/tabs/Menu.js +1 -1
- package/lib/tabs/MenuTabs.js +2 -2
- package/lib/tabs/Panel.js +7 -5
- package/lib/tabs/context.js +6 -3
- package/lib/textContent/index.js +1 -1
- package/lib/toolbar/ButtonBar.js +1 -1
- package/lib/toolbar/index.js +1 -1
- package/lib/tooltip/index.js +7 -7
- package/lib/treetable/Body.js +1 -1
- package/lib/treetable/Header.js +2 -2
- package/lib/treetable/Row.js +10 -13
- package/lib/treeview/Header.js +1 -1
- package/lib/treeview/Node.js +15 -11
- package/lib/treeview/index.js +11 -7
- package/lib/treeview/types.d.ts +4 -0
- package/lib/uitour/index.js +8 -6
- package/package.json +2 -2
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Container = Wizard;
|
|
7
|
+
Object.defineProperty(exports, "Step", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _step.WizardStep;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
exports.default = exports.WizardContext = void 0;
|
|
14
|
+
Object.defineProperty(exports, "useWizard", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () {
|
|
17
|
+
return _useWizard.useWizard;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
exports.useWizardContext = void 0;
|
|
21
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
22
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
23
|
+
var _form = _interopRequireDefault(require("../form/"));
|
|
24
|
+
var _progressbar = require("./progressbar");
|
|
25
|
+
require("../../assets/styles/wizard.scss");
|
|
26
|
+
var _step = require("./step");
|
|
27
|
+
var _useWizard = require("./useWizard");
|
|
28
|
+
const _excluded = ["children", "controls", "showProgressbar", "customStyleForProgressBar", "customStyleForBody"];
|
|
29
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
30
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
31
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
32
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
33
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
34
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
|
|
35
|
+
const WizardContext = exports.WizardContext = /*#__PURE__*/_react.default.createContext(null);
|
|
36
|
+
const useWizardContext = () => _react.default.useContext(WizardContext);
|
|
37
|
+
exports.useWizardContext = useWizardContext;
|
|
38
|
+
function Wizard(_ref) {
|
|
39
|
+
let {
|
|
40
|
+
children,
|
|
41
|
+
controls,
|
|
42
|
+
showProgressbar = true,
|
|
43
|
+
customStyleForProgressBar,
|
|
44
|
+
customStyleForBody
|
|
45
|
+
} = _ref,
|
|
46
|
+
dialogProps = _objectWithoutProperties(_ref, _excluded);
|
|
47
|
+
const {
|
|
48
|
+
currentStep,
|
|
49
|
+
setTotalSteps
|
|
50
|
+
} = controls;
|
|
51
|
+
const steps = _react.default.Children.toArray(children);
|
|
52
|
+
const stepsTitle = steps.map((step, index) => {
|
|
53
|
+
return {
|
|
54
|
+
title: String(step.props.title),
|
|
55
|
+
number: index + 1,
|
|
56
|
+
completed: index < currentStep - 1 && index !== currentStep
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
const currentStepElement = steps[currentStep - 1];
|
|
60
|
+
if (!controls || _lodash.default.isEmpty(controls)) throw new Error('Wizard must be have controls by using useWizard hook or creating manually.');
|
|
61
|
+
(0, _react.useEffect)(() => {
|
|
62
|
+
setTotalSteps(steps.length);
|
|
63
|
+
}, [steps.length]);
|
|
64
|
+
return /*#__PURE__*/_react.default.createElement(WizardContext.Provider, {
|
|
65
|
+
value: controls
|
|
66
|
+
}, /*#__PURE__*/_react.default.createElement(_form.default, _extends({
|
|
67
|
+
className: "wizard-dialog",
|
|
68
|
+
wrapperClassName: "wizard-wrapper",
|
|
69
|
+
contentClassName: "wizard-content"
|
|
70
|
+
}, dialogProps), showProgressbar && /*#__PURE__*/_react.default.createElement(_progressbar.Progressbar, {
|
|
71
|
+
stepsTitle: stepsTitle,
|
|
72
|
+
customStyle: customStyleForProgressBar
|
|
73
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
74
|
+
className: "wizard-body",
|
|
75
|
+
style: customStyleForBody
|
|
76
|
+
}, currentStepElement)));
|
|
77
|
+
}
|
|
78
|
+
var _default = exports.default = Wizard;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
|
|
3
|
+
declare function Progressbar({ customClass, customStyle, stepsTitle }: Readonly<{
|
|
4
|
+
customClass?: string;
|
|
5
|
+
stepsTitle: {
|
|
6
|
+
title: string;
|
|
7
|
+
number: number;
|
|
8
|
+
completed: boolean;
|
|
9
|
+
}[];
|
|
10
|
+
customStyle?: CSSProperties;
|
|
11
|
+
}>): JSX.Element;
|
|
12
|
+
|
|
13
|
+
export { Progressbar };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Progressbar = Progressbar;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _ = require(".");
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
function Progressbar(_ref) {
|
|
11
|
+
let {
|
|
12
|
+
customClass,
|
|
13
|
+
customStyle,
|
|
14
|
+
stepsTitle
|
|
15
|
+
} = _ref;
|
|
16
|
+
const context = (0, _.useWizardContext)();
|
|
17
|
+
if (!context) throw new Error('WizardProgressbar must be used within a Wizard component');
|
|
18
|
+
const {
|
|
19
|
+
currentStep
|
|
20
|
+
} = context;
|
|
21
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
22
|
+
className: "wizard-progresbar ".concat(customClass),
|
|
23
|
+
style: customStyle
|
|
24
|
+
}, stepsTitle.map(step => /*#__PURE__*/_react.default.createElement("div", {
|
|
25
|
+
key: step.number,
|
|
26
|
+
className: "title",
|
|
27
|
+
"data-completed": step.completed,
|
|
28
|
+
"data-disabled": step.number > currentStep
|
|
29
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
30
|
+
className: "step"
|
|
31
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
32
|
+
className: "number"
|
|
33
|
+
}, step.number)), /*#__PURE__*/_react.default.createElement("span", {
|
|
34
|
+
className: "step-title"
|
|
35
|
+
}, step.title))));
|
|
36
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { WizardStepComponentProps } from '../types.js';
|
|
2
|
+
import 'react';
|
|
3
|
+
import '../../@types/Align.js';
|
|
4
|
+
import '../../@types/Icon.js';
|
|
5
|
+
import '../../icons/helper.js';
|
|
6
|
+
|
|
7
|
+
declare function WizardStep({ children, customClass, customStyle }: Readonly<WizardStepComponentProps>): JSX.Element;
|
|
8
|
+
|
|
9
|
+
export { WizardStep };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.WizardStep = WizardStep;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _ = require(".");
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
function WizardStep(_ref) {
|
|
11
|
+
let {
|
|
12
|
+
children,
|
|
13
|
+
customClass = '',
|
|
14
|
+
customStyle
|
|
15
|
+
} = _ref;
|
|
16
|
+
const context = (0, _.useWizardContext)();
|
|
17
|
+
if (!context) throw new Error('WizardStep must be used within a Wizard component');
|
|
18
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
19
|
+
className: "wizard-step-component ".concat(customClass),
|
|
20
|
+
style: customStyle
|
|
21
|
+
}, children);
|
|
22
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useWizard = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
9
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
10
|
+
const useWizard = () => {
|
|
11
|
+
const [totalSteps, setTotalSteps] = (0, _react.useState)(0);
|
|
12
|
+
const [currentStep, setCurrentStep] = _react.default.useState(1);
|
|
13
|
+
const hasNextStep = currentStep < totalSteps;
|
|
14
|
+
const hasPreviousStep = currentStep > 1;
|
|
15
|
+
const changeStep = nextStep => {
|
|
16
|
+
setCurrentStep(state => state + nextStep);
|
|
17
|
+
};
|
|
18
|
+
const nextStep = () => {
|
|
19
|
+
if (hasNextStep) {
|
|
20
|
+
changeStep(1);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const previousStep = () => {
|
|
24
|
+
if (hasPreviousStep) {
|
|
25
|
+
changeStep(-1);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
changeStep,
|
|
30
|
+
nextStep,
|
|
31
|
+
hasNextStep,
|
|
32
|
+
previousStep,
|
|
33
|
+
hasPreviousStep,
|
|
34
|
+
currentStep,
|
|
35
|
+
totalSteps,
|
|
36
|
+
controls: {
|
|
37
|
+
changeStep,
|
|
38
|
+
nextStep,
|
|
39
|
+
hasNextStep,
|
|
40
|
+
previousStep,
|
|
41
|
+
hasPreviousStep,
|
|
42
|
+
currentStep,
|
|
43
|
+
totalSteps,
|
|
44
|
+
setTotalSteps
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
exports.useWizard = useWizard;
|
package/lib/drawer/Drawer.js
CHANGED
|
@@ -83,7 +83,7 @@ const BaseDrawer = _ref => {
|
|
|
83
83
|
};
|
|
84
84
|
const closeDrawerOnEsc = e => {
|
|
85
85
|
if (closeOnEsc && e.key === 'Escape') {
|
|
86
|
-
handlerClose
|
|
86
|
+
handlerClose === null || handlerClose === void 0 ? void 0 : handlerClose();
|
|
87
87
|
e.stopPropagation();
|
|
88
88
|
}
|
|
89
89
|
};
|
|
@@ -124,12 +124,12 @@ const BaseDrawer = _ref => {
|
|
|
124
124
|
value: contextValues
|
|
125
125
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
126
126
|
"data-testid": "drawercontainer-component",
|
|
127
|
-
className:
|
|
127
|
+
className: "".concat(position, " ").concat(customClass),
|
|
128
128
|
style: style
|
|
129
129
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
130
130
|
style: overlayStyle,
|
|
131
131
|
"data-testid": "drawercontent",
|
|
132
|
-
className:
|
|
132
|
+
className: "drawercontent ".concat(skeletonize ? '-skeletonized' : '', " ").concat(customClassForContent)
|
|
133
133
|
}, title && /*#__PURE__*/_react.default.createElement(_.DrawerHeader, _extends({}, headerProps, {
|
|
134
134
|
customClass: customClassForDrawer
|
|
135
135
|
})), content ? /*#__PURE__*/_react.default.createElement(_.DrawerContent, null, content) : children, getSpinner())));
|
package/lib/drawer/Header.js
CHANGED
|
@@ -61,7 +61,7 @@ const Header = _ref => {
|
|
|
61
61
|
};
|
|
62
62
|
const checkHandlerClose = () => handlerClose ? handlerClose() : undefined;
|
|
63
63
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
64
|
-
className:
|
|
64
|
+
className: "drawerheader ".concat(customClass),
|
|
65
65
|
"data-testid": "drawerheader"
|
|
66
66
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
67
67
|
className: "left"
|
package/lib/dropdown/Popup.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { IPopUpProps } from './types.js';
|
|
3
3
|
|
|
4
|
-
declare const DropdownPopup: ({ id, customClassForDropdown, align, isFloatMenu, topPosition, leftPosition, rightPosition, minWidth,
|
|
4
|
+
declare const DropdownPopup: ({ id, customClassForDropdown, align, isFloatMenu, topPosition, leftPosition, rightPosition, minWidth, ...props }: IPopUpProps) => React.ReactPortal;
|
|
5
5
|
|
|
6
6
|
export { DropdownPopup as default };
|
package/lib/dropdown/Popup.js
CHANGED
|
@@ -7,46 +7,28 @@ exports.default = void 0;
|
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
9
9
|
var _uuid = require("uuid");
|
|
10
|
-
const _excluded = ["id", "customClassForDropdown", "align", "isFloatMenu", "topPosition", "leftPosition", "rightPosition", "minWidth"
|
|
10
|
+
const _excluded = ["id", "customClassForDropdown", "align", "isFloatMenu", "topPosition", "leftPosition", "rightPosition", "minWidth"];
|
|
11
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
12
|
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
13
13
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
|
|
14
|
-
const
|
|
14
|
+
const getCalendarDropdownStyle = _ref => {
|
|
15
15
|
let {
|
|
16
|
+
topPosition,
|
|
17
|
+
leftPosition,
|
|
18
|
+
rightPosition,
|
|
16
19
|
align,
|
|
17
20
|
isFloatMenu,
|
|
18
|
-
minWidth
|
|
19
|
-
container,
|
|
20
|
-
target
|
|
21
|
+
minWidth
|
|
21
22
|
} = _ref;
|
|
22
|
-
|
|
23
|
-
const targetDimensions = target.getBoundingClientRect();
|
|
24
|
-
const rightPosition = !isFloatMenu ? window.innerWidth - targetDimensions.x - targetDimensions.width - 4 : undefined;
|
|
25
|
-
const leftPosition = targetDimensions.left;
|
|
26
|
-
let topPosition = targetDimensions.top + window.scrollY + targetDimensions.height;
|
|
27
|
-
let top = topPosition + (isFloatMenu ? 6 : 2);
|
|
28
|
-
let maxHeight = undefined;
|
|
29
|
-
let showScroll = false;
|
|
30
|
-
const isOverflowing = top + container.scrollHeight > window.innerHeight;
|
|
31
|
-
if (isOverflowing) {
|
|
32
|
-
const targetPosition = targetDimensions.top;
|
|
33
|
-
const containerHeight = container.scrollHeight;
|
|
34
|
-
showScroll = containerHeight > targetPosition;
|
|
35
|
-
maxHeight = showScroll ? targetPosition - 10 : containerHeight;
|
|
36
|
-
top = top - maxHeight - targetDimensions.height - (isFloatMenu ? 6 : 2) - 5;
|
|
37
|
-
}
|
|
38
|
-
let style = `top: ${top}px; min-width: ${minWidth}px;`;
|
|
39
|
-
if (showScroll) style += `max-height: ${maxHeight}px; overflow-y: scroll;`;
|
|
23
|
+
let style = "top: ".concat(topPosition + (isFloatMenu ? 6 : 2), "px; min-width: ").concat(minWidth, "px;");
|
|
40
24
|
if (align === 'left') {
|
|
41
|
-
style +=
|
|
25
|
+
style += "left: ".concat(leftPosition, "px;");
|
|
42
26
|
} else if (align === 'right') {
|
|
43
|
-
style +=
|
|
27
|
+
style += "right: ".concat(rightPosition, "px;");
|
|
44
28
|
}
|
|
45
29
|
return style;
|
|
46
30
|
};
|
|
47
|
-
const
|
|
48
|
-
body
|
|
49
|
-
} = document;
|
|
31
|
+
const body = document.getElementsByTagName('body')[0];
|
|
50
32
|
const DropdownPopup = _ref2 => {
|
|
51
33
|
let {
|
|
52
34
|
id,
|
|
@@ -56,31 +38,28 @@ const DropdownPopup = _ref2 => {
|
|
|
56
38
|
topPosition = 0,
|
|
57
39
|
leftPosition = 0,
|
|
58
40
|
rightPosition = 0,
|
|
59
|
-
minWidth = 0
|
|
60
|
-
targetRef
|
|
41
|
+
minWidth = 0
|
|
61
42
|
} = _ref2,
|
|
62
43
|
props = _objectWithoutProperties(_ref2, _excluded);
|
|
63
44
|
const popup = (0, _react.useRef)(document.createElement('div'));
|
|
64
|
-
popup.current.className =
|
|
45
|
+
popup.current.className = "dropdown-component ".concat(customClassForDropdown);
|
|
65
46
|
popup.current.dataset.testid = 'dropdown-component';
|
|
47
|
+
popup.current.style.cssText = getCalendarDropdownStyle({
|
|
48
|
+
topPosition,
|
|
49
|
+
leftPosition,
|
|
50
|
+
rightPosition,
|
|
51
|
+
align,
|
|
52
|
+
isFloatMenu,
|
|
53
|
+
minWidth
|
|
54
|
+
});
|
|
66
55
|
if (popup && popup.current) {
|
|
67
56
|
const modalContainers = document.body.getElementsByClassName('modalcontainer');
|
|
68
57
|
const lastModalContainer = modalContainers[modalContainers.length - 1];
|
|
69
|
-
popup.current.style.zIndex =
|
|
58
|
+
popup.current.style.zIndex = "".concat(modalContainers.length ? Number(lastModalContainer.style.zIndex) + 1 : 99999);
|
|
70
59
|
}
|
|
71
60
|
(0, _react.useEffect)(() => {
|
|
72
61
|
body.appendChild(popup.current);
|
|
73
|
-
popup.current.id = id ||
|
|
74
|
-
popup.current.style.cssText = getDropdownStyles({
|
|
75
|
-
topPosition,
|
|
76
|
-
leftPosition,
|
|
77
|
-
rightPosition,
|
|
78
|
-
align,
|
|
79
|
-
isFloatMenu,
|
|
80
|
-
minWidth,
|
|
81
|
-
container: popup.current,
|
|
82
|
-
target: targetRef
|
|
83
|
-
});
|
|
62
|
+
popup.current.id = id || "dropdown-component-".concat((0, _uuid.v1)());
|
|
84
63
|
return () => {
|
|
85
64
|
body.removeChild(popup.current);
|
|
86
65
|
};
|
package/lib/dropdown/helper.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getDropdownItemCssClass = exports.contentClass = void 0;
|
|
7
|
-
const contentClass = showClearButton =>
|
|
7
|
+
const contentClass = showClearButton => "content ".concat(showClearButton ? '' : 'noclear');
|
|
8
8
|
exports.contentClass = contentClass;
|
|
9
9
|
const getDropdownItemCssClass = (selected, disabled, striped) => {
|
|
10
10
|
let className = 'item';
|
package/lib/dropdown/types.d.ts
CHANGED
|
@@ -10,7 +10,6 @@ interface WithDropdownProps {
|
|
|
10
10
|
closeDropdownOnClickOutside?: boolean;
|
|
11
11
|
showDropdown?: () => void;
|
|
12
12
|
isFloatMenu?: boolean;
|
|
13
|
-
handlerClose?: (cb: () => void) => void;
|
|
14
13
|
}
|
|
15
14
|
interface WrappedComponentProps extends WithDropdownProps {
|
|
16
15
|
getDropdownPopup?: (ref: Ref<HTMLElement | null>) => ReactElement;
|
|
@@ -32,17 +31,14 @@ interface IPopUpProps {
|
|
|
32
31
|
leftPosition?: number;
|
|
33
32
|
rightPosition?: number;
|
|
34
33
|
minWidth?: number;
|
|
35
|
-
targetRef?: HTMLElement;
|
|
36
34
|
}
|
|
37
|
-
interface
|
|
35
|
+
interface GetCalendarDropdownStyleParams {
|
|
38
36
|
align: 'left' | 'right';
|
|
39
37
|
minWidth: number;
|
|
40
38
|
isFloatMenu: boolean;
|
|
41
39
|
topPosition: number;
|
|
42
40
|
leftPosition: number;
|
|
43
41
|
rightPosition: number;
|
|
44
|
-
container?: HTMLDivElement;
|
|
45
|
-
target?: HTMLElement;
|
|
46
42
|
}
|
|
47
43
|
|
|
48
|
-
export {
|
|
44
|
+
export { GetCalendarDropdownStyleParams, GetDisplayNameParams, IPopUpProps, WithDropdownContextProps, WithDropdownProps, WrappedComponentProps };
|
|
@@ -20,7 +20,6 @@ const withDropdown = WrappedComponent => {
|
|
|
20
20
|
showDropdown,
|
|
21
21
|
dropdown,
|
|
22
22
|
closeDropdownOnClickOutside = true,
|
|
23
|
-
handlerClose,
|
|
24
23
|
customClassForDropdown,
|
|
25
24
|
children,
|
|
26
25
|
dropdownAlign = 'left',
|
|
@@ -39,7 +38,7 @@ const withDropdown = WrappedComponent => {
|
|
|
39
38
|
const {
|
|
40
39
|
target
|
|
41
40
|
} = event;
|
|
42
|
-
if (popupRef
|
|
41
|
+
if (popupRef !== null && popupRef !== void 0 && popupRef.current && target !== (popupRef === null || popupRef === void 0 ? void 0 : popupRef.current) && !event.composedPath().includes(popupRef.current) && wrappedComponentRef.current !== target) {
|
|
43
42
|
setOpened(false);
|
|
44
43
|
}
|
|
45
44
|
};
|
|
@@ -49,8 +48,11 @@ const withDropdown = WrappedComponent => {
|
|
|
49
48
|
const getDropdown = targetRef => {
|
|
50
49
|
if (!targetRef || !opened) return null;
|
|
51
50
|
wrappedComponentRef.current = targetRef;
|
|
51
|
+
const targetDimensions = targetRef.getBoundingClientRect();
|
|
52
52
|
return /*#__PURE__*/_react.default.createElement(_Popup.default, {
|
|
53
|
-
|
|
53
|
+
topPosition: targetDimensions.top + window.scrollY + targetDimensions.height,
|
|
54
|
+
rightPosition: !isFloatMenu ? window.innerWidth - targetDimensions.x - targetDimensions.width - 4 : undefined,
|
|
55
|
+
leftPosition: targetDimensions.left,
|
|
54
56
|
align: dropdownAlign,
|
|
55
57
|
customClassForDropdown: customClassForDropdown,
|
|
56
58
|
isFloatMenu: isFloatMenu
|
|
@@ -71,9 +73,6 @@ const withDropdown = WrappedComponent => {
|
|
|
71
73
|
}
|
|
72
74
|
};
|
|
73
75
|
}, []);
|
|
74
|
-
(0, _react.useEffect)(() => {
|
|
75
|
-
if (handlerClose) handlerClose(() => setOpened(false));
|
|
76
|
-
}, [handlerClose]);
|
|
77
76
|
const contextValues = {
|
|
78
77
|
handleDropdownClose: onDropdownClick
|
|
79
78
|
};
|
|
@@ -87,7 +86,7 @@ const withDropdown = WrappedComponent => {
|
|
|
87
86
|
value: contextValues
|
|
88
87
|
}, /*#__PURE__*/_react.default.createElement(WrappedComponent, _extends({}, props, newProps)));
|
|
89
88
|
};
|
|
90
|
-
EnhancedComponent.displayName =
|
|
89
|
+
EnhancedComponent.displayName = "withDropdown(".concat(getDisplayName(WrappedComponent), ")");
|
|
91
90
|
return EnhancedComponent;
|
|
92
91
|
};
|
|
93
92
|
var _default = exports.default = withDropdown;
|
package/lib/fieldset/index.js
CHANGED
|
@@ -43,9 +43,9 @@ const Fieldset = props => {
|
|
|
43
43
|
customClass,
|
|
44
44
|
hasError
|
|
45
45
|
} = _ref;
|
|
46
|
-
let cssClass =
|
|
47
|
-
if (type) cssClass =
|
|
48
|
-
if (hasError) cssClass =
|
|
46
|
+
let cssClass = "fieldset-component ".concat(customClass);
|
|
47
|
+
if (type) cssClass = "".concat(cssClass, " -").concat(type);
|
|
48
|
+
if (hasError) cssClass = "".concat(cssClass, " -witherror");
|
|
49
49
|
return cssClass;
|
|
50
50
|
};
|
|
51
51
|
const getContentStyle = _ref2 => {
|
|
@@ -55,11 +55,11 @@ const Fieldset = props => {
|
|
|
55
55
|
} = _ref2;
|
|
56
56
|
if (template === 'rows') {
|
|
57
57
|
return {
|
|
58
|
-
gridTemplateRows:
|
|
58
|
+
gridTemplateRows: "repeat(".concat(rowsCount, ", 1fr)")
|
|
59
59
|
};
|
|
60
60
|
} else if (template === 'columns') {
|
|
61
61
|
return {
|
|
62
|
-
gridTemplateColumns:
|
|
62
|
+
gridTemplateColumns: "repeat(".concat(colsCount, ", 1fr)")
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
65
|
return {};
|
|
@@ -70,9 +70,9 @@ const Fieldset = props => {
|
|
|
70
70
|
}, onDenied.hideContent ? /*#__PURE__*/_react.default.createElement(_noPermission.default, null) : /*#__PURE__*/_react.default.createElement(_react.Fragment, null, title && /*#__PURE__*/_react.default.createElement("legend", {
|
|
71
71
|
style: styleTitle,
|
|
72
72
|
align: titleAlign,
|
|
73
|
-
className:
|
|
73
|
+
className: "legend ".concat(titleCustomClass)
|
|
74
74
|
}, leftElements, title, rightElements), /*#__PURE__*/_react.default.createElement("div", {
|
|
75
|
-
className:
|
|
75
|
+
className: "contentfieldset -template".concat(template, " "),
|
|
76
76
|
style: Object.assign(getContentStyle(props), styleContent)
|
|
77
77
|
}, children)));
|
|
78
78
|
if (onDenied.unvisible) return null;
|
package/lib/form/Field.js
CHANGED
|
@@ -8,7 +8,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
8
8
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
9
9
|
var _withFieldHOC = _interopRequireDefault(require("./withFieldHOC"));
|
|
10
10
|
var _helpers = require("./helpers");
|
|
11
|
-
const _excluded = ["handlerFieldChange", "
|
|
11
|
+
const _excluded = ["handlerFieldChange", "handlerFieldValidate", "onChange", "onBlur", "name", "validators", "data", "fieldErrors", "handlerStoreValidators", "handlerRemoveValidators", "component", "externalFieldErrors", "originalData"];
|
|
12
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
13
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
14
14
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -25,25 +25,23 @@ const getEvents = _ref => {
|
|
|
25
25
|
validators = [],
|
|
26
26
|
name,
|
|
27
27
|
onBlur,
|
|
28
|
-
|
|
28
|
+
handlerFieldValidate,
|
|
29
29
|
validatorFromComponent,
|
|
30
30
|
handlerFieldChange,
|
|
31
|
-
onChange
|
|
32
|
-
handleShowValidateMessages
|
|
31
|
+
onChange
|
|
33
32
|
} = _ref;
|
|
34
33
|
if (!(validators || validatorFromComponent || onBlur || onChange)) return {};
|
|
35
34
|
const validatorsArray = (0, _helpers.getValidatorsArray)(validators, validatorFromComponent);
|
|
36
35
|
return {
|
|
37
36
|
onBlur: e => {
|
|
38
|
-
if (validatorsArray && e.target &&
|
|
39
|
-
|
|
40
|
-
handleShowValidateMessages(true);
|
|
37
|
+
if (validatorsArray && e.target && handlerFieldValidate) {
|
|
38
|
+
handlerFieldValidate(name, e.target.value, validatorsArray);
|
|
41
39
|
}
|
|
42
40
|
if (onBlur) onBlur(e);
|
|
43
41
|
},
|
|
44
42
|
onChange: e => {
|
|
45
|
-
if (validatorsArray && e.target &&
|
|
46
|
-
|
|
43
|
+
if (validatorsArray && e.target && handlerFieldValidate) {
|
|
44
|
+
handlerFieldValidate(name, e.target.value, validatorsArray);
|
|
47
45
|
}
|
|
48
46
|
if (handlerFieldChange) handlerFieldChange(e);
|
|
49
47
|
if (onChange) onChange(e);
|
|
@@ -82,7 +80,7 @@ const getCustomProps = (props, handlerSetComponentValidator) => {
|
|
|
82
80
|
const Field = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
83
81
|
const {
|
|
84
82
|
handlerFieldChange,
|
|
85
|
-
|
|
83
|
+
handlerFieldValidate,
|
|
86
84
|
onChange,
|
|
87
85
|
onBlur,
|
|
88
86
|
name,
|
|
@@ -96,34 +94,23 @@ const Field = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
|
96
94
|
originalData
|
|
97
95
|
} = props,
|
|
98
96
|
rest = _objectWithoutProperties(props, _excluded);
|
|
99
|
-
const [showValidateMessages, setShowValidateMessages] = (0, _react.useState)(false);
|
|
100
97
|
const {
|
|
101
98
|
handlerSetValidatorFromComponent,
|
|
102
99
|
validatorFromComponent
|
|
103
100
|
} = (0, _react.useContext)(_helpers.withFieldContext);
|
|
104
|
-
const currentValue = _lodash.default.get(data, name);
|
|
105
|
-
const originalValue = _lodash.default.get(originalData, name);
|
|
106
|
-
(0, _react.useEffect)(() => {
|
|
107
|
-
if (currentValue && currentValue !== originalValue && (!!currentValue || currentValue === 0 || Array.isArray(currentValue) && currentValue.length > 0)) {
|
|
108
|
-
setShowValidateMessages(true);
|
|
109
|
-
} else if (_lodash.default.isEmpty(data) || _lodash.default.every(data, _lodash.default.isEmpty) || currentValue === originalValue) {
|
|
110
|
-
setShowValidateMessages(false);
|
|
111
|
-
}
|
|
112
|
-
}, [currentValue, originalValue]);
|
|
113
101
|
return /*#__PURE__*/_react.default.createElement(Component, _extends({}, rest, getEvents({
|
|
114
102
|
name,
|
|
115
103
|
validators,
|
|
116
104
|
onBlur,
|
|
117
105
|
validatorFromComponent,
|
|
118
|
-
|
|
106
|
+
handlerFieldValidate,
|
|
119
107
|
handlerFieldChange,
|
|
120
|
-
onChange
|
|
121
|
-
handleShowValidateMessages: value => setShowValidateMessages(value)
|
|
108
|
+
onChange
|
|
122
109
|
}), getCustomProps(props, handlerSetValidatorFromComponent), {
|
|
123
110
|
ref: ref,
|
|
124
111
|
name: name,
|
|
125
112
|
errorMessages: (0, _helpers.getErrorMessages)(_objectSpread(_objectSpread({}, props), {}, {
|
|
126
|
-
fieldErrors:
|
|
113
|
+
fieldErrors: props.fieldErrors
|
|
127
114
|
}))
|
|
128
115
|
}));
|
|
129
116
|
});
|