@tenancy.nz/feature-ui 1.10.5 → 1.10.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/_virtual/_rollupPluginBabelHelpers.cjs +14 -0
- package/dist/cjs/components/BackButton.cjs +18 -0
- package/dist/cjs/components/ConfirmButton.cjs +91 -0
- package/dist/cjs/components/ContactCard.cjs +73 -0
- package/dist/cjs/components/ContactCardHeader.cjs +59 -0
- package/dist/cjs/components/ContactMethod.cjs +111 -0
- package/dist/cjs/components/DeleteIconButton.cjs +17 -0
- package/dist/cjs/components/DownloadIconButton.cjs +17 -0
- package/dist/cjs/components/EditIconButton.cjs +17 -0
- package/dist/cjs/components/LogoutButton.cjs +17 -0
- package/dist/cjs/components/OpenInNewIconButton.cjs +17 -0
- package/dist/cjs/components/ScrollTopButton.cjs +194 -0
- package/dist/cjs/index.cjs +22 -0
- package/dist/esm/_virtual/_rollupPluginBabelHelpers.js +13 -1
- package/dist/esm/components/BackButton.js +14 -0
- package/dist/esm/components/ConfirmButton.js +87 -0
- package/dist/esm/components/ContactCard.js +69 -0
- package/dist/esm/components/ContactCardHeader.js +55 -0
- package/dist/esm/components/ContactMethod.js +107 -0
- package/dist/esm/components/DeleteIconButton.js +13 -0
- package/dist/esm/components/DownloadIconButton.js +13 -0
- package/dist/esm/components/EditIconButton.js +13 -0
- package/dist/esm/components/LogoutButton.js +13 -0
- package/dist/esm/components/OpenInNewIconButton.js +13 -0
- package/dist/esm/components/ScrollTopButton.js +190 -0
- package/dist/esm/index.js +11 -0
- package/package.json +5 -5
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2, slicedToArray as _slicedToArray, defineProperty as _defineProperty } from '../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import React, { useState, useEffect } from 'react';
|
|
3
|
+
import Box from '@mui/material/Box';
|
|
4
|
+
import Portal from '@mui/material/Portal';
|
|
5
|
+
import { IconButton, Button } from '@tenancy.nz/ui';
|
|
6
|
+
import ChevronUpOutlinedIcon from '@tenancy.nz/icons/ChevronUpOutlined';
|
|
7
|
+
|
|
8
|
+
var _excluded = ["anchorOrigin", "asIcon", "behavior", "container", "disablePortal", "label", "onClick", "position", "scrollContainer", "threshold", "x", "y"];
|
|
9
|
+
var icon = /* @__PURE__ */React.createElement(ChevronUpOutlinedIcon, null);
|
|
10
|
+
var defaultAnchorOrigin = {
|
|
11
|
+
horizontal: "right",
|
|
12
|
+
vertical: "bottom"
|
|
13
|
+
};
|
|
14
|
+
function resolveTarget(target) {
|
|
15
|
+
if (!target) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
if (typeof target === "function") {
|
|
19
|
+
return target();
|
|
20
|
+
}
|
|
21
|
+
if ("current" in target) {
|
|
22
|
+
return target.current;
|
|
23
|
+
}
|
|
24
|
+
return target;
|
|
25
|
+
}
|
|
26
|
+
function isDocumentScroller(element) {
|
|
27
|
+
if (!element) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
return element === document.body || element === document.documentElement;
|
|
31
|
+
}
|
|
32
|
+
function getScrollEventTarget(element) {
|
|
33
|
+
if (isDocumentScroller(element)) {
|
|
34
|
+
return window;
|
|
35
|
+
}
|
|
36
|
+
return element;
|
|
37
|
+
}
|
|
38
|
+
function getScrollTop(element) {
|
|
39
|
+
if (!element || isDocumentScroller(element)) {
|
|
40
|
+
return window.scrollY;
|
|
41
|
+
}
|
|
42
|
+
return element.scrollTop;
|
|
43
|
+
}
|
|
44
|
+
function scrollToTop(scrollElement, behavior) {
|
|
45
|
+
if (!scrollElement || isDocumentScroller(scrollElement)) {
|
|
46
|
+
window.scrollTo({
|
|
47
|
+
top: 0,
|
|
48
|
+
behavior: behavior
|
|
49
|
+
});
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
scrollElement.scrollTo({
|
|
53
|
+
top: 0,
|
|
54
|
+
behavior: behavior
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function getPosition(position, portalElement) {
|
|
58
|
+
if (position) {
|
|
59
|
+
return position;
|
|
60
|
+
}
|
|
61
|
+
if (!portalElement) {
|
|
62
|
+
return "static";
|
|
63
|
+
}
|
|
64
|
+
if (portalElement === document.body) {
|
|
65
|
+
return "fixed";
|
|
66
|
+
}
|
|
67
|
+
return "absolute";
|
|
68
|
+
}
|
|
69
|
+
function getPlacementSx(position, anchorOrigin, x, y) {
|
|
70
|
+
return _defineProperty(_defineProperty({
|
|
71
|
+
position: position,
|
|
72
|
+
zIndex: "fab"
|
|
73
|
+
}, anchorOrigin.horizontal, x), anchorOrigin.vertical, y);
|
|
74
|
+
}
|
|
75
|
+
function useResolvedTarget(target, fallbackToBody) {
|
|
76
|
+
var _useState = useState(null),
|
|
77
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
78
|
+
element = _useState2[0],
|
|
79
|
+
setElement = _useState2[1];
|
|
80
|
+
useEffect(function () {
|
|
81
|
+
var resolved = resolveTarget(target);
|
|
82
|
+
if (resolved) {
|
|
83
|
+
setElement(resolved);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (fallbackToBody) {
|
|
87
|
+
setElement(document.body);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
setElement(null);
|
|
91
|
+
}, [target, fallbackToBody]);
|
|
92
|
+
return element;
|
|
93
|
+
}
|
|
94
|
+
function useScrolledPast(scrollElement, threshold) {
|
|
95
|
+
var _useState3 = useState(threshold <= 0),
|
|
96
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
97
|
+
scrolled = _useState4[0],
|
|
98
|
+
setScrolled = _useState4[1];
|
|
99
|
+
useEffect(function () {
|
|
100
|
+
if (threshold <= 0) {
|
|
101
|
+
setScrolled(true);
|
|
102
|
+
return void 0;
|
|
103
|
+
}
|
|
104
|
+
var eventTarget = getScrollEventTarget(scrollElement);
|
|
105
|
+
var update = function update() {
|
|
106
|
+
return setScrolled(getScrollTop(scrollElement) > threshold);
|
|
107
|
+
};
|
|
108
|
+
update();
|
|
109
|
+
eventTarget.addEventListener("scroll", update, {
|
|
110
|
+
passive: true
|
|
111
|
+
});
|
|
112
|
+
return function () {
|
|
113
|
+
return eventTarget.removeEventListener("scroll", update);
|
|
114
|
+
};
|
|
115
|
+
}, [scrollElement, threshold]);
|
|
116
|
+
return scrolled;
|
|
117
|
+
}
|
|
118
|
+
function ScrollTopButton(_ref2) {
|
|
119
|
+
var _ref2$anchorOrigin = _ref2.anchorOrigin,
|
|
120
|
+
anchorOrigin = _ref2$anchorOrigin === void 0 ? defaultAnchorOrigin : _ref2$anchorOrigin,
|
|
121
|
+
_ref2$asIcon = _ref2.asIcon,
|
|
122
|
+
asIcon = _ref2$asIcon === void 0 ? false : _ref2$asIcon,
|
|
123
|
+
_ref2$behavior = _ref2.behavior,
|
|
124
|
+
behavior = _ref2$behavior === void 0 ? "smooth" : _ref2$behavior,
|
|
125
|
+
_ref2$container = _ref2.container,
|
|
126
|
+
container = _ref2$container === void 0 ? null : _ref2$container,
|
|
127
|
+
_ref2$disablePortal = _ref2.disablePortal,
|
|
128
|
+
disablePortal = _ref2$disablePortal === void 0 ? false : _ref2$disablePortal,
|
|
129
|
+
_ref2$label = _ref2.label,
|
|
130
|
+
label = _ref2$label === void 0 ? "Back to top" : _ref2$label,
|
|
131
|
+
_ref2$onClick = _ref2.onClick,
|
|
132
|
+
onClick = _ref2$onClick === void 0 ? void 0 : _ref2$onClick,
|
|
133
|
+
_ref2$position = _ref2.position,
|
|
134
|
+
position = _ref2$position === void 0 ? void 0 : _ref2$position,
|
|
135
|
+
_ref2$scrollContainer = _ref2.scrollContainer,
|
|
136
|
+
scrollContainer = _ref2$scrollContainer === void 0 ? null : _ref2$scrollContainer,
|
|
137
|
+
_ref2$threshold = _ref2.threshold,
|
|
138
|
+
threshold = _ref2$threshold === void 0 ? 120 : _ref2$threshold,
|
|
139
|
+
_ref2$x = _ref2.x,
|
|
140
|
+
x = _ref2$x === void 0 ? 32 : _ref2$x,
|
|
141
|
+
_ref2$y = _ref2.y,
|
|
142
|
+
y = _ref2$y === void 0 ? 32 : _ref2$y,
|
|
143
|
+
rest = _objectWithoutProperties(_ref2, _excluded);
|
|
144
|
+
var portalElement = useResolvedTarget(container, !disablePortal);
|
|
145
|
+
var scrollElement = useResolvedTarget(scrollContainer, true);
|
|
146
|
+
var scrolled = useScrolledPast(scrollElement, threshold);
|
|
147
|
+
var handleClick = function handleClick(event) {
|
|
148
|
+
scrollToTop(scrollElement, behavior);
|
|
149
|
+
onClick === null || onClick === void 0 || onClick(event);
|
|
150
|
+
};
|
|
151
|
+
if (!scrolled) {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
if (!disablePortal && !portalElement) {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
var resolvedPosition = getPosition(position, portalElement);
|
|
158
|
+
var withPlacement = function withPlacement(node) {
|
|
159
|
+
if (resolvedPosition === "static") {
|
|
160
|
+
return node;
|
|
161
|
+
}
|
|
162
|
+
return /* @__PURE__ */React.createElement(Box, {
|
|
163
|
+
sx: getPlacementSx(resolvedPosition, anchorOrigin, x, y)
|
|
164
|
+
}, node);
|
|
165
|
+
};
|
|
166
|
+
var withPortal = function withPortal(node) {
|
|
167
|
+
if (!portalElement) {
|
|
168
|
+
return node;
|
|
169
|
+
}
|
|
170
|
+
return /* @__PURE__ */React.createElement(Portal, {
|
|
171
|
+
container: portalElement
|
|
172
|
+
}, node);
|
|
173
|
+
};
|
|
174
|
+
if (asIcon) {
|
|
175
|
+
return withPortal(withPlacement(/* @__PURE__ */React.createElement(IconButton, _objectSpread2({
|
|
176
|
+
variant: "outlined",
|
|
177
|
+
size: "large",
|
|
178
|
+
onClick: handleClick,
|
|
179
|
+
color: "primary"
|
|
180
|
+
}, rest), icon)));
|
|
181
|
+
}
|
|
182
|
+
return withPortal(withPlacement(/* @__PURE__ */React.createElement(Button, _objectSpread2({
|
|
183
|
+
variant: "outlined",
|
|
184
|
+
startIcon: icon,
|
|
185
|
+
size: "large",
|
|
186
|
+
onClick: handleClick
|
|
187
|
+
}, rest), label)));
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export { ScrollTopButton as default };
|
package/dist/esm/index.js
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
export { default as AgentDetailsCard } from './components/AgentDetailsCard.js';
|
|
2
2
|
export { default as AnalyticsBox } from './components/AnalyticsBox.js';
|
|
3
3
|
export { default as AnalyticsSection } from './components/AnalyticsSection.js';
|
|
4
|
+
export { default as BackButton } from './components/BackButton.js';
|
|
4
5
|
export { default as BookingChart } from './components/BookingChart.js';
|
|
5
6
|
export { default as BookingTable } from './components/BookingTable.js';
|
|
6
7
|
export { default as BookingTableRow } from './components/BookingTableRow.js';
|
|
7
8
|
export { default as BookingTableRowHeader } from './components/BookingTableRowHeader.js';
|
|
8
9
|
export { default as BookingTableRowSkeleton } from './components/BookingTableRowSkeleton.js';
|
|
10
|
+
export { default as ConfirmButton } from './components/ConfirmButton.js';
|
|
11
|
+
export { default as ContactCard } from './components/ContactCard.js';
|
|
12
|
+
export { default as ContactCardHeader } from './components/ContactCardHeader.js';
|
|
13
|
+
export { default as ContactMethod } from './components/ContactMethod.js';
|
|
14
|
+
export { default as DeleteIconButton } from './components/DeleteIconButton.js';
|
|
15
|
+
export { default as DownloadIconButton } from './components/DownloadIconButton.js';
|
|
16
|
+
export { default as EditIconButton } from './components/EditIconButton.js';
|
|
9
17
|
export { default as IntegrationTag } from './components/IntegrationTag.js';
|
|
10
18
|
export { default as CheckedIcon } from './components/CheckedIcon.js';
|
|
11
19
|
export { default as DoughnutChart } from './components/doughnut-chart.js';
|
|
@@ -15,9 +23,12 @@ export { default as PartnerLogo } from './components/partner-logo.js';
|
|
|
15
23
|
export { default as GridList } from './components/GridList.js';
|
|
16
24
|
export { default as Hidden } from './components/Hidden.js';
|
|
17
25
|
export { default as IconLabel } from './components/IconLabel.js';
|
|
26
|
+
export { default as LogoutButton } from './components/LogoutButton.js';
|
|
18
27
|
export { default as NotesCard } from './components/NotesCard.js';
|
|
28
|
+
export { default as OpenInNewIconButton } from './components/OpenInNewIconButton.js';
|
|
19
29
|
export { default as PersonCard } from './components/PersonCard.js';
|
|
20
30
|
export { default as PersonDetailHeader } from './components/PersonDetailHeader.js';
|
|
21
31
|
export { default as PropertyCard } from './components/PropertyCard.js';
|
|
32
|
+
export { default as ScrollTopButton } from './components/ScrollTopButton.js';
|
|
22
33
|
export { default as StatusButton } from './components/StatusButton.js';
|
|
23
34
|
export { default as TenantAvatarGroup } from './components/TenantAvatarGroup.js';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tenancy.nz/feature-ui",
|
|
3
3
|
"description": "React UI feature components.",
|
|
4
|
-
"version": "1.10.
|
|
4
|
+
"version": "1.10.7",
|
|
5
5
|
"author": "TPS <https://www.tenancy.co.nz>",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/cjs/index.cjs",
|
|
@@ -19,15 +19,15 @@
|
|
|
19
19
|
"primereact": "3.1.3",
|
|
20
20
|
"react": "^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
21
21
|
"react-dom": "^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
22
|
-
"@tenancy.nz/icons": "1.10.
|
|
23
|
-
"@tenancy.nz/ui": "1.10.
|
|
22
|
+
"@tenancy.nz/icons": "1.10.7",
|
|
23
|
+
"@tenancy.nz/ui": "1.10.7"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@emotion/react": "^11.14.0",
|
|
27
27
|
"@emotion/styled": "^11.14.1",
|
|
28
28
|
"@mui/material": "^7.3.1",
|
|
29
|
-
"@tenancy.nz/icons": "1.10.
|
|
30
|
-
"@tenancy.nz/ui": "1.10.
|
|
29
|
+
"@tenancy.nz/icons": "1.10.7",
|
|
30
|
+
"@tenancy.nz/ui": "1.10.7"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"react-uid": "^2.4.0"
|