@unbxd-ui/unbxd-react-components 0.2.221 → 0.3.1
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/README.md +17 -1
- package/components/Accordian/Accordian.js +14 -11
- package/components/Accordian/Accordian.stories.js +141 -118
- package/components/Accordian/index.js +1 -1
- package/components/Button/Button.js +8 -6
- package/components/Button/Button.stories.js +181 -62
- package/components/Button/DropdownButton.js +5 -6
- package/components/Button/buttonTheme.css +1 -1
- package/components/Button/index.js +2 -3
- package/components/DataLoader/DataLoader.js +6 -7
- package/components/DataLoader/DataLoader.stories.js +244 -58
- package/components/DataLoader/index.js +1 -1
- package/components/Form/Checkbox.js +12 -11
- package/components/Form/DragDropFileUploader.js +6 -7
- package/components/Form/Dropdown.js +14 -12
- package/components/Form/FileUploader.js +3 -4
- package/components/Form/Form.js +6 -7
- package/components/Form/FormElementWrapper.js +1 -1
- package/components/Form/Input.js +24 -15
- package/components/Form/RadioList.js +8 -9
- package/components/Form/RangeSlider.js +12 -13
- package/components/Form/SearchableDropdown.js +563 -0
- package/components/Form/ServerPaginatedDDList.js +53 -44
- package/components/Form/Textarea.js +26 -10
- package/components/Form/Toggle.js +6 -7
- package/components/Form/formCore.css +1 -1
- package/components/Form/formTheme.css +1 -1
- package/components/Form/index.js +8 -1
- package/components/Form/stories/Checkbox.stories.js +139 -40
- package/components/Form/stories/Dropdown.stories.js +323 -92
- package/components/Form/stories/FileUploader.stories.js +178 -19
- package/components/Form/stories/Input.stories.js +115 -0
- package/components/Form/stories/RangeSlider.stories.js +162 -64
- package/components/Form/stories/SearchableDropdown.stories.js +189 -0
- package/components/Form/stories/ServerPaginatedDropdown.stories.js +365 -0
- package/components/Form/stories/Textarea.stories.js +113 -34
- package/components/Form/stories/Toggle.stories.js +193 -14
- package/components/Form/variables.css +0 -0
- package/components/InlineModal/InlineModal.js +119 -21
- package/components/InlineModal/InlineModal.stories.js +239 -45
- package/components/InlineModal/index.js +1 -2
- package/components/InlineModal/inlineModalCore.css +1 -1
- package/components/Link/Link.js +139 -0
- package/components/Link/Link.stories.js +489 -0
- package/components/Link/index.js +28 -0
- package/components/Link/linkCore.css +1 -0
- package/components/Link/linkTheme.css +1 -0
- package/components/List/List.js +11 -8
- package/components/List/List.stories.js +238 -0
- package/components/List/index.js +1 -1
- package/components/Modal/Modal.js +67 -20
- package/components/Modal/Modal.stories.js +257 -38
- package/components/Modal/index.js +1 -1
- package/components/Modal/modalCore.css +1 -1
- package/components/NoDataPlaceholder/NoDataPlaceholder.js +41 -0
- package/components/NoDataPlaceholder/NoDataPlaceholder.stories.js +42 -0
- package/components/NoDataPlaceholder/index.js +9 -0
- package/components/NoDataPlaceholder/noDataPlaceholderCore.css +1 -0
- package/components/NotificationComponent/NotificationComponent.js +20 -10
- package/components/NotificationComponent/NotificationComponent.stories.js +171 -19
- package/components/NotificationComponent/index.js +1 -1
- package/components/NotificationComponent/notificationTheme.css +1 -1
- package/components/PageLoader/PageLoader.js +84 -0
- package/components/PageLoader/PageLoader.stories.js +276 -0
- package/components/PageLoader/index.js +9 -0
- package/components/PageLoader/pageLoaderCore.css +1 -0
- package/components/ProgressBar/ProgressBar.css +0 -0
- package/components/ProgressBar/ProgressBar.js +1 -1
- package/components/ProgressBar/ProgressBar.stories.js +203 -10
- package/components/ProgressBar/index.js +1 -1
- package/components/ProgressBar/progressBarCore.css +1 -1
- package/components/Table/BaseTable.js +86 -342
- package/components/Table/PaginationComponent.js +4 -4
- package/components/Table/Table.js +7 -326
- package/components/Table/Table.stories.js +2117 -158
- package/components/Table/TableChild.js +383 -0
- package/components/Table/TableConstants.js +15 -0
- package/components/Table/hooks/usePrevious.js +14 -0
- package/components/Table/index.js +14 -1
- package/components/Table/tableCore.css +1 -1
- package/components/TableOld/BaseTable.js +373 -0
- package/components/TableOld/PaginationComponent.js +86 -0
- package/components/TableOld/TableOld.js +367 -0
- package/components/TableOld/index.js +15 -0
- package/components/TabsComponent/TabsComponent.js +6 -7
- package/components/TabsComponent/TabsComponent.stories.js +291 -53
- package/components/TabsComponent/index.js +1 -1
- package/components/ToastNotification/ToastNotificationWrapper.js +212 -0
- package/components/ToastNotification/ToastNotificationWrapper.stories.js +554 -0
- package/components/ToastNotification/index.js +40 -0
- package/components/ToastNotification/toastNotificationCore.css +1 -0
- package/components/Tooltip/Tooltip.js +231 -56
- package/components/Tooltip/Tooltip.stories.js +380 -15
- package/components/Tooltip/index.js +1 -1
- package/components/Tooltip/tooltipCore.css +1 -1
- package/components/Tooltip/tooltipTheme.css +1 -1
- package/components/common/NoDataDropdown.js +50 -0
- package/components/common/common.css +1 -0
- package/components/core.css +2 -3
- package/components/core.scss +21 -1
- package/components/index.js +91 -3
- package/components/theme.css +2 -3
- package/components/theme.scss +2 -1
- package/core/Validators.js +1 -1
- package/core/customHooks.js +4 -4
- package/core/dataLoader.js +58 -17
- package/core/index.js +1 -1
- package/core/utils.js +15 -4
- package/index.js +54 -0
- package/package.json +41 -28
- package/components/Button/DropdownButton.stories.js +0 -49
- package/components/Form/stories/DragDropFileUploader.stories.js +0 -25
- package/components/Form/stories/FormDefault.stories.js +0 -115
- package/components/Form/stories/RadioList.stories.js +0 -53
- package/components/Form/stories/TextInput.stories.js +0 -76
- package/components/Form/stories/form.stories.js +0 -233
- package/components/List/list.stories.js +0 -35
- package/core/dataLoader.stories.js +0 -119
|
@@ -3,21 +3,200 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports["default"] = exports.
|
|
6
|
+
exports["default"] = exports.WithLabel = exports.Disabled = exports.Default = exports.CustomSizes = exports.ControlledToggle = exports.Checked = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _Toggle = _interopRequireDefault(require("../Toggle"));
|
|
9
|
-
function _interopRequireDefault(
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
10
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
11
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
12
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
13
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
14
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
15
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
16
|
+
var meta = {
|
|
17
|
+
title: 'Components/Form/Toggle',
|
|
18
|
+
component: _Toggle["default"],
|
|
19
|
+
parameters: {
|
|
20
|
+
layout: 'centered'
|
|
21
|
+
},
|
|
22
|
+
tags: ['autodocs'],
|
|
23
|
+
argTypes: {
|
|
24
|
+
label: {
|
|
25
|
+
control: 'text',
|
|
26
|
+
description: 'Label text for the toggle'
|
|
27
|
+
},
|
|
28
|
+
disabled: {
|
|
29
|
+
control: 'boolean',
|
|
30
|
+
description: 'Whether the toggle is disabled'
|
|
31
|
+
},
|
|
32
|
+
checked: {
|
|
33
|
+
control: 'boolean',
|
|
34
|
+
description: 'Whether the toggle is checked'
|
|
35
|
+
},
|
|
36
|
+
className: {
|
|
37
|
+
control: 'text',
|
|
38
|
+
description: 'Additional CSS classes'
|
|
39
|
+
},
|
|
40
|
+
toggleElWidth: {
|
|
41
|
+
control: 'number',
|
|
42
|
+
description: 'Width of the toggle element in pixels'
|
|
43
|
+
},
|
|
44
|
+
toggleKnobSize: {
|
|
45
|
+
control: 'number',
|
|
46
|
+
description: 'Size of the toggle knob in pixels'
|
|
47
|
+
}
|
|
48
|
+
}
|
|
12
49
|
};
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
50
|
+
var _default = exports["default"] = meta;
|
|
51
|
+
var Default = exports.Default = {
|
|
52
|
+
render: function render() {
|
|
53
|
+
var _React$useState = _react["default"].useState(false),
|
|
54
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
55
|
+
toggleValue = _React$useState2[0],
|
|
56
|
+
setToggleValue = _React$useState2[1];
|
|
57
|
+
return /*#__PURE__*/_react["default"].createElement(_Toggle["default"], {
|
|
58
|
+
value: toggleValue,
|
|
59
|
+
onChange: function onChange(checked) {
|
|
60
|
+
console.log('Toggle changed:', checked);
|
|
61
|
+
setToggleValue(checked);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
var WithLabel = exports.WithLabel = {
|
|
67
|
+
render: function render() {
|
|
68
|
+
var _React$useState3 = _react["default"].useState(false),
|
|
69
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
70
|
+
toggleValue = _React$useState4[0],
|
|
71
|
+
setToggleValue = _React$useState4[1];
|
|
72
|
+
return /*#__PURE__*/_react["default"].createElement(_Toggle["default"], {
|
|
73
|
+
label: "Notifications",
|
|
74
|
+
value: toggleValue,
|
|
75
|
+
onChange: function onChange(checked) {
|
|
76
|
+
console.log('Toggle changed:', checked);
|
|
77
|
+
setToggleValue(checked);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
var Checked = exports.Checked = {
|
|
83
|
+
render: function render() {
|
|
84
|
+
var _React$useState5 = _react["default"].useState(true),
|
|
85
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
86
|
+
toggleValue = _React$useState6[0],
|
|
87
|
+
setToggleValue = _React$useState6[1];
|
|
88
|
+
return /*#__PURE__*/_react["default"].createElement(_Toggle["default"], {
|
|
89
|
+
label: "Active Status",
|
|
90
|
+
value: toggleValue,
|
|
91
|
+
onChange: function onChange(checked) {
|
|
92
|
+
console.log('Toggle changed:', checked);
|
|
93
|
+
setToggleValue(checked);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
var Disabled = exports.Disabled = {
|
|
99
|
+
render: function render() {
|
|
100
|
+
var _React$useState7 = _react["default"].useState(false),
|
|
101
|
+
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
102
|
+
toggleValue1 = _React$useState8[0],
|
|
103
|
+
setToggleValue1 = _React$useState8[1];
|
|
104
|
+
var _React$useState9 = _react["default"].useState(true),
|
|
105
|
+
_React$useState0 = _slicedToArray(_React$useState9, 2),
|
|
106
|
+
toggleValue2 = _React$useState0[0],
|
|
107
|
+
setToggleValue2 = _React$useState0[1];
|
|
108
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
109
|
+
style: {
|
|
110
|
+
display: 'flex',
|
|
111
|
+
flexDirection: 'column',
|
|
112
|
+
gap: '20px'
|
|
113
|
+
}
|
|
114
|
+
}, /*#__PURE__*/_react["default"].createElement(_Toggle["default"], {
|
|
115
|
+
label: "Disabled (Off)",
|
|
116
|
+
disabled: true,
|
|
117
|
+
value: toggleValue1,
|
|
118
|
+
onChange: function onChange(checked) {
|
|
119
|
+
console.log('Toggle changed:', checked);
|
|
120
|
+
setToggleValue1(checked);
|
|
121
|
+
}
|
|
122
|
+
}), /*#__PURE__*/_react["default"].createElement(_Toggle["default"], {
|
|
123
|
+
label: "Disabled (On)",
|
|
124
|
+
disabled: true,
|
|
125
|
+
value: toggleValue2,
|
|
126
|
+
onChange: function onChange(checked) {
|
|
127
|
+
console.log('Toggle changed:', checked);
|
|
128
|
+
setToggleValue2(checked);
|
|
129
|
+
}
|
|
130
|
+
}));
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
var ControlledToggle = exports.ControlledToggle = {
|
|
134
|
+
render: function render() {
|
|
135
|
+
var _React$useState1 = _react["default"].useState(false),
|
|
136
|
+
_React$useState10 = _slicedToArray(_React$useState1, 2),
|
|
137
|
+
toggleValue = _React$useState10[0],
|
|
138
|
+
setToggleValue = _React$useState10[1];
|
|
139
|
+
return /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_Toggle["default"], {
|
|
140
|
+
label: "Feature is ".concat(toggleValue ? 'enabled' : 'disabled'),
|
|
141
|
+
value: toggleValue,
|
|
142
|
+
onChange: function onChange(checked) {
|
|
143
|
+
console.log('Toggle changed:', checked);
|
|
144
|
+
setToggleValue(checked);
|
|
145
|
+
}
|
|
146
|
+
}), /*#__PURE__*/_react["default"].createElement("div", {
|
|
147
|
+
style: {
|
|
148
|
+
marginTop: '10px',
|
|
149
|
+
color: '#666'
|
|
150
|
+
}
|
|
151
|
+
}, "Current state: ", toggleValue ? 'On' : 'Off'));
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
var CustomSizes = exports.CustomSizes = {
|
|
155
|
+
render: function render() {
|
|
156
|
+
var _React$useState11 = _react["default"].useState(false),
|
|
157
|
+
_React$useState12 = _slicedToArray(_React$useState11, 2),
|
|
158
|
+
toggleValue1 = _React$useState12[0],
|
|
159
|
+
setToggleValue1 = _React$useState12[1];
|
|
160
|
+
var _React$useState13 = _react["default"].useState(true),
|
|
161
|
+
_React$useState14 = _slicedToArray(_React$useState13, 2),
|
|
162
|
+
toggleValue2 = _React$useState14[0],
|
|
163
|
+
setToggleValue2 = _React$useState14[1];
|
|
164
|
+
var _React$useState15 = _react["default"].useState(false),
|
|
165
|
+
_React$useState16 = _slicedToArray(_React$useState15, 2),
|
|
166
|
+
toggleValue3 = _React$useState16[0],
|
|
167
|
+
setToggleValue3 = _React$useState16[1];
|
|
168
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
169
|
+
style: {
|
|
170
|
+
display: 'flex',
|
|
171
|
+
flexDirection: 'column',
|
|
172
|
+
gap: '20px'
|
|
173
|
+
}
|
|
174
|
+
}, /*#__PURE__*/_react["default"].createElement(_Toggle["default"], {
|
|
175
|
+
label: "Default Size",
|
|
176
|
+
value: toggleValue1,
|
|
177
|
+
onChange: function onChange(checked) {
|
|
178
|
+
console.log('Toggle changed:', checked);
|
|
179
|
+
setToggleValue1(checked);
|
|
180
|
+
}
|
|
181
|
+
}), /*#__PURE__*/_react["default"].createElement(_Toggle["default"], {
|
|
182
|
+
label: "Large Toggle (60x30)",
|
|
183
|
+
value: toggleValue2,
|
|
184
|
+
toggleElWidth: 60,
|
|
185
|
+
className: "custom-toggle-large",
|
|
186
|
+
toggleKnobSize: 30,
|
|
187
|
+
onChange: function onChange(checked) {
|
|
188
|
+
console.log('Toggle changed:', checked);
|
|
189
|
+
setToggleValue2(checked);
|
|
190
|
+
}
|
|
191
|
+
}), /*#__PURE__*/_react["default"].createElement(_Toggle["default"], {
|
|
192
|
+
label: "Small Toggle (32x16)",
|
|
193
|
+
value: toggleValue3,
|
|
194
|
+
toggleElWidth: 32,
|
|
195
|
+
toggleKnobSize: 16,
|
|
196
|
+
onChange: function onChange(checked) {
|
|
197
|
+
console.log('Toggle changed:', checked);
|
|
198
|
+
setToggleValue3(checked);
|
|
199
|
+
}
|
|
200
|
+
}));
|
|
201
|
+
}
|
|
23
202
|
};
|
|
File without changes
|
|
@@ -6,17 +6,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports["default"] = exports.InlineModalBody = exports.InlineModalActivator = void 0;
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _react2 = require("motion/react");
|
|
9
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
-
function _interopRequireDefault(
|
|
11
|
-
function
|
|
12
|
-
function
|
|
13
|
-
function
|
|
14
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
12
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
13
|
+
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); }
|
|
14
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
15
15
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
16
|
-
function _unsupportedIterableToArray(
|
|
17
|
-
function _arrayLikeToArray(
|
|
16
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
17
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
18
18
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
19
|
-
function _arrayWithHoles(
|
|
19
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
20
20
|
var InlineModalActivator = exports.InlineModalActivator = function InlineModalActivator(props) {
|
|
21
21
|
return props.children;
|
|
22
22
|
};
|
|
@@ -26,33 +26,119 @@ var InlineModalBody = exports.InlineModalBody = function InlineModalBody(props)
|
|
|
26
26
|
var InlineModal = function InlineModal(props, ref) {
|
|
27
27
|
var children = props.children,
|
|
28
28
|
activatorAction = props.activatorAction,
|
|
29
|
+
activatorClassName = props.activatorClassName,
|
|
29
30
|
className = props.className,
|
|
30
31
|
propIsOpen = props.isModalOpen,
|
|
31
32
|
halign = props.halign,
|
|
32
|
-
onModalStateChange = props.onModalStateChange
|
|
33
|
+
onModalStateChange = props.onModalStateChange,
|
|
34
|
+
_props$closeOnBodyCli = props.closeOnBodyClick,
|
|
35
|
+
closeOnBodyClick = _props$closeOnBodyCli === void 0 ? false : _props$closeOnBodyCli,
|
|
36
|
+
closeOnOutsideClick = props.closeOnOutsideClick,
|
|
37
|
+
animateBody = props.animateBody;
|
|
33
38
|
var _useState = (0, _react.useState)(propIsOpen),
|
|
34
39
|
_useState2 = _slicedToArray(_useState, 2),
|
|
35
40
|
isModalOpen = _useState2[0],
|
|
36
41
|
setIsModalOpen = _useState2[1];
|
|
37
42
|
var activatorProps = {};
|
|
43
|
+
var modalCloseProps = {};
|
|
38
44
|
var inlineModalClassName = "RCB-inline-modal ".concat(className);
|
|
39
|
-
var
|
|
45
|
+
var _useState3 = (0, _react.useState)(isModalOpen),
|
|
46
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
47
|
+
showModalBody = _useState4[0],
|
|
48
|
+
setShowModalBody = _useState4[1];
|
|
49
|
+
// let showModalBody = isModalOpen;
|
|
40
50
|
var inlineModalRef = (0, _react.useRef)();
|
|
51
|
+
var inlineModalBodyRef = (0, _react.useRef)();
|
|
41
52
|
var isFirstRun = (0, _react.useRef)(true);
|
|
53
|
+
var activatorRef = (0, _react.useRef)(null);
|
|
54
|
+
var transformOriginRef = (0, _react.useRef)("top center");
|
|
55
|
+
var computeTransformOrigin = function computeTransformOrigin() {
|
|
56
|
+
if (activatorRef.current && inlineModalBodyRef.current) {
|
|
57
|
+
var activatorRect = activatorRef.current.getBoundingClientRect();
|
|
58
|
+
var modalRect = inlineModalBodyRef.current.getBoundingClientRect();
|
|
59
|
+
|
|
60
|
+
//to get the center point of the activator
|
|
61
|
+
var activatorCenterX = activatorRect.left + activatorRect.width / 2;
|
|
62
|
+
var activatorCenterY = activatorRect.top + activatorRect.height / 2;
|
|
63
|
+
var originX = (activatorCenterX - modalRect.left) / modalRect.width * 100;
|
|
64
|
+
var originY = (activatorCenterY - modalRect.top) / modalRect.height * 100;
|
|
65
|
+
|
|
66
|
+
//check originX and originY are valid numbers
|
|
67
|
+
if (isNaN(originX) || isNaN(originY)) {
|
|
68
|
+
return "top center";
|
|
69
|
+
}
|
|
70
|
+
return "".concat(originX, "% ").concat(originY, "%");
|
|
71
|
+
}
|
|
72
|
+
return "top center";
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
//default animation of inline modal body
|
|
76
|
+
var fadeInScaleVariants = {
|
|
77
|
+
hidden: {
|
|
78
|
+
opacity: 0,
|
|
79
|
+
scale: 0.8,
|
|
80
|
+
transformOrigin: transformOriginRef.current,
|
|
81
|
+
transition: {
|
|
82
|
+
ease: "easeInOut",
|
|
83
|
+
duration: 0.1
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
visible: {
|
|
87
|
+
opacity: 1,
|
|
88
|
+
scale: 1,
|
|
89
|
+
transformOrigin: transformOriginRef.current,
|
|
90
|
+
transition: {
|
|
91
|
+
ease: "easeInOut",
|
|
92
|
+
duration: 0.1
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
exit: {
|
|
96
|
+
opacity: 0,
|
|
97
|
+
scale: 0.8,
|
|
98
|
+
transformOrigin: transformOriginRef.current,
|
|
99
|
+
transition: {
|
|
100
|
+
ease: "easeInOut",
|
|
101
|
+
duration: 0.1
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
(0, _react.useEffect)(function () {
|
|
106
|
+
if (showModalBody) {
|
|
107
|
+
var origin = computeTransformOrigin();
|
|
108
|
+
transformOriginRef.current = origin;
|
|
109
|
+
}
|
|
110
|
+
}, [showModalBody]);
|
|
111
|
+
(0, _react.useEffect)(function () {
|
|
112
|
+
if (isModalOpen !== undefined) setShowModalBody(isModalOpen);
|
|
113
|
+
}, [isModalOpen]);
|
|
42
114
|
var changeModalState = function changeModalState(newState) {
|
|
43
115
|
setIsModalOpen(newState);
|
|
44
116
|
};
|
|
45
117
|
var onActivatorClick = function onActivatorClick(e) {
|
|
46
|
-
e.stopPropagation();
|
|
118
|
+
//e.stopPropagation();
|
|
47
119
|
changeModalState(!isModalOpen);
|
|
48
120
|
};
|
|
121
|
+
var onActivatorHover = function onActivatorHover(e) {
|
|
122
|
+
//e.stopPropagation();
|
|
123
|
+
setShowModalBody(true);
|
|
124
|
+
};
|
|
125
|
+
var onActivatorMouseOut = function onActivatorMouseOut(e) {
|
|
126
|
+
setShowModalBody(false);
|
|
127
|
+
};
|
|
49
128
|
var onBodyClick = function onBodyClick(e) {
|
|
50
129
|
var eventTarget = e.target;
|
|
51
130
|
var inlineModalNode = inlineModalRef.current;
|
|
131
|
+
var inlineModalBodyNode = inlineModalBodyRef.current;
|
|
52
132
|
var eventPathNodes = e.composedPath();
|
|
53
133
|
var isWithinModal = false;
|
|
54
134
|
if (inlineModalNode.contains(eventTarget)) {
|
|
55
135
|
isWithinModal = true;
|
|
136
|
+
if (closeOnBodyClick) {
|
|
137
|
+
if (inlineModalBodyNode.contains(eventTarget)) {
|
|
138
|
+
/* close modal */
|
|
139
|
+
changeModalState(false);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
56
142
|
} else {
|
|
57
143
|
for (var i = 0; i < eventPathNodes.length; i++) {
|
|
58
144
|
var node = eventPathNodes[i];
|
|
@@ -62,7 +148,7 @@ var InlineModal = function InlineModal(props, ref) {
|
|
|
62
148
|
}
|
|
63
149
|
}
|
|
64
150
|
}
|
|
65
|
-
if (!isWithinModal) {
|
|
151
|
+
if (!isWithinModal && closeOnOutsideClick) {
|
|
66
152
|
/* outside click -> close modal */
|
|
67
153
|
changeModalState(false);
|
|
68
154
|
}
|
|
@@ -89,8 +175,13 @@ var InlineModal = function InlineModal(props, ref) {
|
|
|
89
175
|
onClick: onActivatorClick
|
|
90
176
|
};
|
|
91
177
|
} else if (activatorAction === "hover") {
|
|
92
|
-
|
|
93
|
-
|
|
178
|
+
activatorProps = {
|
|
179
|
+
onMouseOver: onActivatorHover
|
|
180
|
+
};
|
|
181
|
+
modalCloseProps = {
|
|
182
|
+
onMouseLeave: onActivatorMouseOut
|
|
183
|
+
};
|
|
184
|
+
// setShowModalBody(true);
|
|
94
185
|
}
|
|
95
186
|
|
|
96
187
|
/* add methods that can be accessed via this component's ref */
|
|
@@ -101,14 +192,20 @@ var InlineModal = function InlineModal(props, ref) {
|
|
|
101
192
|
}
|
|
102
193
|
};
|
|
103
194
|
});
|
|
104
|
-
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
195
|
+
return /*#__PURE__*/_react["default"].createElement("div", _extends({
|
|
105
196
|
className: inlineModalClassName,
|
|
106
197
|
ref: inlineModalRef
|
|
107
|
-
}, /*#__PURE__*/_react["default"].createElement("div", _extends({}, activatorProps, {
|
|
108
|
-
className: "RCB-inline-modal-btn"
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
198
|
+
}, modalCloseProps), /*#__PURE__*/_react["default"].createElement("div", _extends({}, activatorProps, {
|
|
199
|
+
className: "RCB-inline-modal-btn ".concat(activatorClassName),
|
|
200
|
+
ref: activatorRef
|
|
201
|
+
}), children[0]), /*#__PURE__*/_react["default"].createElement(_react2.AnimatePresence, null, showModalBody && /*#__PURE__*/_react["default"].createElement(_react2.motion.div, {
|
|
202
|
+
className: "RCB-inline-modal-body RCB-align-".concat(halign),
|
|
203
|
+
ref: inlineModalBodyRef,
|
|
204
|
+
variants: animateBody ? animateBody : fadeInScaleVariants,
|
|
205
|
+
initial: "hidden",
|
|
206
|
+
animate: "visible",
|
|
207
|
+
exit: "exit"
|
|
208
|
+
}, children[1])));
|
|
112
209
|
};
|
|
113
210
|
InlineModal = /*#__PURE__*/(0, _react.forwardRef)(InlineModal);
|
|
114
211
|
InlineModal.propTypes = {
|
|
@@ -137,7 +234,8 @@ InlineModal.defaultProps = {
|
|
|
137
234
|
halign: "left",
|
|
138
235
|
activatorAction: "click",
|
|
139
236
|
// or "hover"
|
|
140
|
-
isModalOpen: false
|
|
237
|
+
isModalOpen: false,
|
|
238
|
+
closeOnOutsideClick: true
|
|
141
239
|
};
|
|
142
240
|
InlineModal.displayName = "InlineModal";
|
|
143
241
|
var _default = exports["default"] = InlineModal;
|