colibri-ui 0.8.78 → 0.8.81
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 +6 -0
- package/Sheet/Sheet.d.ts +3 -0
- package/Sheet/Sheet.js +273 -0
- package/Sheet/Sheet.module.css +153 -0
- package/Sheet/index.d.ts +2 -0
- package/Sheet/index.js +7 -0
- package/Sheet/index.props.d.ts +26 -0
- package/Sheet/package.json +9 -0
- package/Theme/index.d.ts +60 -0
- package/Theme/themes/buenos_aires.d.ts +30 -0
- package/Theme/themes/buenos_aires.js +30 -0
- package/Theme/themes/jaipur.d.ts +30 -0
- package/Theme/themes/jaipur.js +30 -0
- package/esm/Autocomplete/index.js +1 -0
- package/esm/Calendar/index.js +1 -0
- package/esm/Card/index.js +1 -0
- package/esm/CodeField/index.js +1 -0
- package/esm/Drawer/index.js +1 -0
- package/esm/Dropzone/index.js +1 -0
- package/esm/Editable/index.js +1 -0
- package/esm/Icons/index.js +21 -0
- package/esm/List/index.js +1 -0
- package/esm/NumberInput/index.js +1 -0
- package/esm/Progress/index.js +1 -0
- package/esm/Rating/index.js +1 -0
- package/esm/Sheet/Sheet.d.ts +3 -0
- package/esm/Sheet/Sheet.js +263 -0
- package/esm/Sheet/Sheet.module.css +153 -0
- package/esm/Sheet/index.d.ts +2 -0
- package/esm/Sheet/index.js +1 -0
- package/esm/Sheet/index.props.d.ts +26 -0
- package/esm/Slider/index.js +1 -0
- package/esm/Theme/index.d.ts +60 -0
- package/esm/Theme/index.js +1 -0
- package/esm/Theme/themes/buenos_aires.d.ts +30 -0
- package/esm/Theme/themes/buenos_aires.js +30 -0
- package/esm/Theme/themes/jaipur.d.ts +30 -0
- package/esm/Theme/themes/jaipur.js +30 -0
- package/esm/hooks/useMediaSizes/index.d.ts +4 -0
- package/esm/hooks/useMediaSizes/index.js +24 -30
- package/esm/index.d.ts +2 -0
- package/esm/index.js +1 -0
- package/esm/theme_ba_variables.css +30 -0
- package/esm/theme_jaipur_variables.css +30 -0
- package/hooks/useMediaSizes/index.d.ts +4 -0
- package/hooks/useMediaSizes/index.js +23 -33
- package/index.d.ts +2 -0
- package/index.js +3 -0
- package/package.json +1 -1
- package/theme_ba_variables.css +30 -0
- package/theme_jaipur_variables.css +30 -0
package/README.md
CHANGED
|
@@ -190,6 +190,12 @@ const css = `@media ${media.down("sm")} { … }`;
|
|
|
190
190
|
|
|
191
191
|
`BREAKPOINTS` and `media` are also exported from `colibri-ui/Theme`.
|
|
192
192
|
|
|
193
|
+
### useMediaSizes
|
|
194
|
+
|
|
195
|
+
`useMediaSizes(query)` takes a query string or a function that receives `media`, and returns whether the query matches. It updates when the viewport crosses the edge.
|
|
196
|
+
|
|
197
|
+
Returns `false` on the server and during hydration. Use it to decide whether to mount a heavy component; to show/hide markup use CSS media queries, otherwise the wrong variant renders until hydration.
|
|
198
|
+
|
|
193
199
|
## License
|
|
194
200
|
|
|
195
201
|
MIT
|
package/Sheet/Sheet.d.ts
ADDED
package/Sheet/Sheet.js
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
|
4
|
+
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var ReactDOM = require('react-dom');
|
|
8
|
+
var clsx = require('clsx');
|
|
9
|
+
var styles = require('./Sheet.module.css');
|
|
10
|
+
|
|
11
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
|
|
13
|
+
var _toConsumableArray__default = /*#__PURE__*/_interopDefault(_toConsumableArray);
|
|
14
|
+
var _slicedToArray__default = /*#__PURE__*/_interopDefault(_slicedToArray);
|
|
15
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
16
|
+
var clsx__default = /*#__PURE__*/_interopDefault(clsx);
|
|
17
|
+
var styles__default = /*#__PURE__*/_interopDefault(styles);
|
|
18
|
+
|
|
19
|
+
var defaultSnapPoints = ["60dvh"];
|
|
20
|
+
var focusableSelector = 'a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])';
|
|
21
|
+
var toCssSize = function toCssSize(point) {
|
|
22
|
+
return typeof point === "number" ? "".concat(point, "px") : point;
|
|
23
|
+
};
|
|
24
|
+
var toPixels = function toPixels(point, viewportHeight) {
|
|
25
|
+
if (typeof point === "number") return point;
|
|
26
|
+
var value = Number.parseFloat(point);
|
|
27
|
+
if (!Number.isFinite(value)) return 0;
|
|
28
|
+
if (point.endsWith("%") || point.endsWith("vh") || point.endsWith("dvh")) return viewportHeight * value / 100;
|
|
29
|
+
return value;
|
|
30
|
+
};
|
|
31
|
+
var findPoint = function findPoint(points, preferred) {
|
|
32
|
+
var _a;
|
|
33
|
+
if (preferred !== undefined && points.includes(preferred)) return preferred;
|
|
34
|
+
return (_a = points[0]) !== null && _a !== void 0 ? _a : "60dvh";
|
|
35
|
+
};
|
|
36
|
+
var Sheet = /*#__PURE__*/React.forwardRef(function SheetComponent(_a, forwardedRef) {
|
|
37
|
+
var open = _a.open,
|
|
38
|
+
onOpenChange = _a.onOpenChange,
|
|
39
|
+
title = _a.title,
|
|
40
|
+
description = _a.description,
|
|
41
|
+
header = _a.header,
|
|
42
|
+
footer = _a.footer,
|
|
43
|
+
_a$snapPoints = _a.snapPoints,
|
|
44
|
+
snapPoints = _a$snapPoints === void 0 ? defaultSnapPoints : _a$snapPoints,
|
|
45
|
+
snapPoint = _a.snapPoint,
|
|
46
|
+
defaultSnapPoint = _a.defaultSnapPoint,
|
|
47
|
+
onSnapPointChange = _a.onSnapPointChange,
|
|
48
|
+
_a$modal = _a.modal,
|
|
49
|
+
modal = _a$modal === void 0 ? true : _a$modal,
|
|
50
|
+
_a$blurOverlay = _a.blurOverlay,
|
|
51
|
+
blurOverlay = _a$blurOverlay === void 0 ? false : _a$blurOverlay,
|
|
52
|
+
_a$closeOnOverlayClic = _a.closeOnOverlayClick,
|
|
53
|
+
closeOnOverlayClick = _a$closeOnOverlayClic === void 0 ? true : _a$closeOnOverlayClic,
|
|
54
|
+
_a$closeOnEscape = _a.closeOnEscape,
|
|
55
|
+
closeOnEscape = _a$closeOnEscape === void 0 ? true : _a$closeOnEscape,
|
|
56
|
+
_a$draggable = _a.draggable,
|
|
57
|
+
draggable = _a$draggable === void 0 ? true : _a$draggable,
|
|
58
|
+
_a$showHandle = _a.showHandle,
|
|
59
|
+
showHandle = _a$showHandle === void 0 ? true : _a$showHandle,
|
|
60
|
+
_a$lockBodyScroll = _a.lockBodyScroll,
|
|
61
|
+
lockBodyScroll = _a$lockBodyScroll === void 0 ? true : _a$lockBodyScroll,
|
|
62
|
+
portalContainer = _a.portalContainer,
|
|
63
|
+
initialFocusRef = _a.initialFocusRef,
|
|
64
|
+
returnFocusRef = _a.returnFocusRef,
|
|
65
|
+
zIndex = _a.zIndex,
|
|
66
|
+
className = _a.className,
|
|
67
|
+
style = _a.style,
|
|
68
|
+
children = _a.children,
|
|
69
|
+
ariaLabel = _a["aria-label"],
|
|
70
|
+
ariaLabelledBy = _a["aria-labelledby"],
|
|
71
|
+
ariaDescribedBy = _a["aria-describedby"],
|
|
72
|
+
rest = tslib.__rest(_a, ["open", "onOpenChange", "title", "description", "header", "footer", "snapPoints", "snapPoint", "defaultSnapPoint", "onSnapPointChange", "modal", "blurOverlay", "closeOnOverlayClick", "closeOnEscape", "draggable", "showHandle", "lockBodyScroll", "portalContainer", "initialFocusRef", "returnFocusRef", "zIndex", "className", "style", "children", "aria-label", "aria-labelledby", "aria-describedby"]);
|
|
73
|
+
var normalizedPoints = snapPoints.length ? snapPoints : defaultSnapPoints;
|
|
74
|
+
var controlledSnap = snapPoint !== undefined;
|
|
75
|
+
var _useState = React.useState(function () {
|
|
76
|
+
return findPoint(normalizedPoints, defaultSnapPoint);
|
|
77
|
+
}),
|
|
78
|
+
_useState2 = _slicedToArray__default.default(_useState, 2),
|
|
79
|
+
internalSnap = _useState2[0],
|
|
80
|
+
setInternalSnap = _useState2[1];
|
|
81
|
+
var activeSnap = findPoint(normalizedPoints, controlledSnap ? snapPoint : internalSnap);
|
|
82
|
+
var _useState3 = React.useState(open),
|
|
83
|
+
_useState4 = _slicedToArray__default.default(_useState3, 2),
|
|
84
|
+
rendered = _useState4[0],
|
|
85
|
+
setRendered = _useState4[1];
|
|
86
|
+
var _useState5 = React.useState(false),
|
|
87
|
+
_useState6 = _slicedToArray__default.default(_useState5, 2),
|
|
88
|
+
closing = _useState6[0],
|
|
89
|
+
setClosing = _useState6[1];
|
|
90
|
+
var panelRef = React.useRef(null);
|
|
91
|
+
var previousFocusRef = React.useRef(null);
|
|
92
|
+
var dragRef = React.useRef({
|
|
93
|
+
pointerId: -1,
|
|
94
|
+
startY: 0,
|
|
95
|
+
startHeight: 0,
|
|
96
|
+
currentHeight: 0
|
|
97
|
+
});
|
|
98
|
+
var titleId = React.useId();
|
|
99
|
+
var descriptionId = React.useId();
|
|
100
|
+
var setPanelRef = function setPanelRef(node) {
|
|
101
|
+
panelRef.current = node;
|
|
102
|
+
if (typeof forwardedRef === "function") forwardedRef(node);else if (forwardedRef) forwardedRef.current = node;
|
|
103
|
+
};
|
|
104
|
+
var sortedPoints = React.useMemo(function () {
|
|
105
|
+
return _toConsumableArray__default.default(normalizedPoints).sort(function (left, right) {
|
|
106
|
+
var height = typeof window === "undefined" ? 1000 : window.innerHeight;
|
|
107
|
+
return toPixels(left, height) - toPixels(right, height);
|
|
108
|
+
});
|
|
109
|
+
}, [normalizedPoints]);
|
|
110
|
+
var changeSnap = function changeSnap(next) {
|
|
111
|
+
if (!controlledSnap) setInternalSnap(next);
|
|
112
|
+
onSnapPointChange === null || onSnapPointChange === void 0 ? void 0 : onSnapPointChange(next);
|
|
113
|
+
};
|
|
114
|
+
React.useEffect(function () {
|
|
115
|
+
if (open) {
|
|
116
|
+
setRendered(true);
|
|
117
|
+
setClosing(false);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (!rendered) return;
|
|
121
|
+
setClosing(true);
|
|
122
|
+
var duration = panelRef.current ? Number.parseFloat(getComputedStyle(panelRef.current).animationDuration) * 1000 : 220;
|
|
123
|
+
var timer = window.setTimeout(function () {
|
|
124
|
+
setRendered(false);
|
|
125
|
+
setClosing(false);
|
|
126
|
+
}, Number.isFinite(duration) ? duration : 220);
|
|
127
|
+
return function () {
|
|
128
|
+
return window.clearTimeout(timer);
|
|
129
|
+
};
|
|
130
|
+
}, [open, rendered]);
|
|
131
|
+
React.useEffect(function () {
|
|
132
|
+
var _a;
|
|
133
|
+
if (!open || typeof document === "undefined") return;
|
|
134
|
+
previousFocusRef.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
135
|
+
var returnFocusElement = (_a = returnFocusRef === null || returnFocusRef === void 0 ? void 0 : returnFocusRef.current) !== null && _a !== void 0 ? _a : previousFocusRef.current;
|
|
136
|
+
var previousOverflow = document.body.style.overflow;
|
|
137
|
+
if (modal && lockBodyScroll) document.body.style.overflow = "hidden";
|
|
138
|
+
var frame = window.requestAnimationFrame(function () {
|
|
139
|
+
var _a, _b, _c, _d;
|
|
140
|
+
var first = (_a = panelRef.current) === null || _a === void 0 ? void 0 : _a.querySelector(focusableSelector);
|
|
141
|
+
(_d = (_c = (_b = initialFocusRef === null || initialFocusRef === void 0 ? void 0 : initialFocusRef.current) !== null && _b !== void 0 ? _b : first) !== null && _c !== void 0 ? _c : panelRef.current) === null || _d === void 0 ? void 0 : _d.focus();
|
|
142
|
+
});
|
|
143
|
+
var onKeyDown = function onKeyDown(event) {
|
|
144
|
+
if (event.key === "Escape" && closeOnEscape) {
|
|
145
|
+
event.preventDefault();
|
|
146
|
+
onOpenChange(false, "escape");
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
if (!modal || event.key !== "Tab" || !panelRef.current) return;
|
|
150
|
+
var focusable = Array.from(panelRef.current.querySelectorAll(focusableSelector));
|
|
151
|
+
if (!focusable.length) {
|
|
152
|
+
event.preventDefault();
|
|
153
|
+
panelRef.current.focus();
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
var first = focusable[0];
|
|
157
|
+
var last = focusable[focusable.length - 1];
|
|
158
|
+
if (event.shiftKey && document.activeElement === first) {
|
|
159
|
+
event.preventDefault();
|
|
160
|
+
last.focus();
|
|
161
|
+
} else if (!event.shiftKey && document.activeElement === last) {
|
|
162
|
+
event.preventDefault();
|
|
163
|
+
first.focus();
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
document.addEventListener("keydown", onKeyDown);
|
|
167
|
+
return function () {
|
|
168
|
+
window.cancelAnimationFrame(frame);
|
|
169
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
170
|
+
if (modal && lockBodyScroll) document.body.style.overflow = previousOverflow;
|
|
171
|
+
returnFocusElement === null || returnFocusElement === void 0 ? void 0 : returnFocusElement.focus();
|
|
172
|
+
};
|
|
173
|
+
}, [open, modal, lockBodyScroll, closeOnEscape, onOpenChange, initialFocusRef, returnFocusRef]);
|
|
174
|
+
var startDrag = function startDrag(event) {
|
|
175
|
+
if (!draggable || !panelRef.current) return;
|
|
176
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
177
|
+
var height = panelRef.current.getBoundingClientRect().height;
|
|
178
|
+
dragRef.current = {
|
|
179
|
+
pointerId: event.pointerId,
|
|
180
|
+
startY: event.clientY,
|
|
181
|
+
startHeight: height,
|
|
182
|
+
currentHeight: height
|
|
183
|
+
};
|
|
184
|
+
panelRef.current.classList.add(styles__default.default.dragging);
|
|
185
|
+
};
|
|
186
|
+
var moveDrag = function moveDrag(event) {
|
|
187
|
+
if (dragRef.current.pointerId !== event.pointerId || !panelRef.current) return;
|
|
188
|
+
var viewportHeight = window.innerHeight;
|
|
189
|
+
var maximum = Math.max.apply(Math, _toConsumableArray__default.default(sortedPoints.map(function (point) {
|
|
190
|
+
return toPixels(point, viewportHeight);
|
|
191
|
+
})));
|
|
192
|
+
var nextHeight = Math.max(0, Math.min(maximum, dragRef.current.startHeight - (event.clientY - dragRef.current.startY)));
|
|
193
|
+
dragRef.current.currentHeight = nextHeight;
|
|
194
|
+
panelRef.current.style.height = "".concat(nextHeight, "px");
|
|
195
|
+
};
|
|
196
|
+
var endDrag = function endDrag(event) {
|
|
197
|
+
if (dragRef.current.pointerId !== event.pointerId || !panelRef.current) return;
|
|
198
|
+
event.currentTarget.releasePointerCapture(event.pointerId);
|
|
199
|
+
panelRef.current.classList.remove(styles__default.default.dragging);
|
|
200
|
+
var _dragRef$current = dragRef.current,
|
|
201
|
+
currentHeight = _dragRef$current.currentHeight,
|
|
202
|
+
startHeight = _dragRef$current.startHeight;
|
|
203
|
+
dragRef.current.pointerId = -1;
|
|
204
|
+
var pointHeights = sortedPoints.map(function (point) {
|
|
205
|
+
return toPixels(point, window.innerHeight);
|
|
206
|
+
});
|
|
207
|
+
var minimum = pointHeights[0];
|
|
208
|
+
if (currentHeight < Math.min(minimum * 0.65, startHeight * 0.65)) {
|
|
209
|
+
panelRef.current.style.height = toCssSize(activeSnap);
|
|
210
|
+
onOpenChange(false, "drag");
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
var nearest = 0;
|
|
214
|
+
pointHeights.forEach(function (height, index) {
|
|
215
|
+
if (Math.abs(height - currentHeight) < Math.abs(pointHeights[nearest] - currentHeight)) nearest = index;
|
|
216
|
+
});
|
|
217
|
+
var next = sortedPoints[nearest];
|
|
218
|
+
panelRef.current.style.height = toCssSize(next);
|
|
219
|
+
changeSnap(next);
|
|
220
|
+
};
|
|
221
|
+
if (!rendered || typeof document === "undefined") return null;
|
|
222
|
+
var panelStyle = Object.assign(Object.assign({}, style), {
|
|
223
|
+
height: toCssSize(activeSnap)
|
|
224
|
+
});
|
|
225
|
+
var node = /*#__PURE__*/React__default.default.createElement("div", {
|
|
226
|
+
className: clsx__default.default(styles__default.default.root, !modal && styles__default.default["non-modal"], closing && styles__default.default.closing),
|
|
227
|
+
style: {
|
|
228
|
+
zIndex: zIndex
|
|
229
|
+
}
|
|
230
|
+
}, modal && (/*#__PURE__*/React__default.default.createElement("div", {
|
|
231
|
+
className: clsx__default.default(styles__default.default.overlay, blurOverlay && styles__default.default.blur),
|
|
232
|
+
"aria-hidden": "true",
|
|
233
|
+
onClick: function onClick() {
|
|
234
|
+
return closeOnOverlayClick && onOpenChange(false, "overlay");
|
|
235
|
+
}
|
|
236
|
+
})), /*#__PURE__*/React__default.default.createElement("div", Object.assign({}, rest, {
|
|
237
|
+
ref: setPanelRef,
|
|
238
|
+
role: "dialog",
|
|
239
|
+
"aria-modal": modal || undefined,
|
|
240
|
+
"aria-label": ariaLabel,
|
|
241
|
+
"aria-labelledby": ariaLabelledBy !== null && ariaLabelledBy !== void 0 ? ariaLabelledBy : title ? titleId : undefined,
|
|
242
|
+
"aria-describedby": ariaDescribedBy !== null && ariaDescribedBy !== void 0 ? ariaDescribedBy : description ? descriptionId : undefined,
|
|
243
|
+
tabIndex: -1,
|
|
244
|
+
className: clsx__default.default(styles__default.default.sheet, className),
|
|
245
|
+
style: panelStyle
|
|
246
|
+
}), (showHandle || draggable) && (/*#__PURE__*/React__default.default.createElement("div", {
|
|
247
|
+
className: styles__default.default["drag-area"],
|
|
248
|
+
onPointerDown: startDrag,
|
|
249
|
+
onPointerMove: moveDrag,
|
|
250
|
+
onPointerUp: endDrag,
|
|
251
|
+
onPointerCancel: endDrag
|
|
252
|
+
}, showHandle && (/*#__PURE__*/React__default.default.createElement("span", {
|
|
253
|
+
className: styles__default.default.handle,
|
|
254
|
+
"aria-hidden": "true"
|
|
255
|
+
})))), (title || description || header) && (/*#__PURE__*/React__default.default.createElement("header", {
|
|
256
|
+
className: styles__default.default.header
|
|
257
|
+
}, /*#__PURE__*/React__default.default.createElement("div", {
|
|
258
|
+
className: styles__default.default.heading
|
|
259
|
+
}, title && /*#__PURE__*/React__default.default.createElement("h2", {
|
|
260
|
+
id: titleId
|
|
261
|
+
}, title), description && /*#__PURE__*/React__default.default.createElement("p", {
|
|
262
|
+
id: descriptionId
|
|
263
|
+
}, description)), header && (/*#__PURE__*/React__default.default.createElement("div", {
|
|
264
|
+
className: styles__default.default["header-actions"]
|
|
265
|
+
}, header)))), /*#__PURE__*/React__default.default.createElement("div", {
|
|
266
|
+
className: styles__default.default.body
|
|
267
|
+
}, children), footer && /*#__PURE__*/React__default.default.createElement("footer", {
|
|
268
|
+
className: styles__default.default.footer
|
|
269
|
+
}, footer)));
|
|
270
|
+
return /*#__PURE__*/ReactDOM.createPortal(node, portalContainer !== null && portalContainer !== void 0 ? portalContainer : document.body);
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
exports.Sheet = Sheet;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
font-family: var(--font-family-ui);
|
|
3
|
+
inset: 0;
|
|
4
|
+
pointer-events: none;
|
|
5
|
+
position: fixed;
|
|
6
|
+
z-index: var(--component-sheet-z-index);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.overlay {
|
|
10
|
+
animation: fade-in var(--component-sheet-motion-duration) ease-out both;
|
|
11
|
+
background: var(--component-sheet-overlay);
|
|
12
|
+
inset: 0;
|
|
13
|
+
pointer-events: auto;
|
|
14
|
+
position: absolute;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.blur {
|
|
18
|
+
backdrop-filter: blur(var(--component-sheet-overlay-blur));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.sheet {
|
|
22
|
+
animation: sheet-in var(--component-sheet-motion-duration) var(--component-sheet-motion-easing) both;
|
|
23
|
+
background: var(--component-sheet-bg);
|
|
24
|
+
border-radius: var(--component-sheet-radius) var(--component-sheet-radius) 0 0;
|
|
25
|
+
bottom: 0;
|
|
26
|
+
box-shadow: var(--component-sheet-shadow);
|
|
27
|
+
box-sizing: border-box;
|
|
28
|
+
color: var(--component-sheet-text);
|
|
29
|
+
display: flex;
|
|
30
|
+
flex-direction: column;
|
|
31
|
+
left: 0;
|
|
32
|
+
max-height: min(var(--component-sheet-max-height), 100%);
|
|
33
|
+
outline: none;
|
|
34
|
+
overflow: hidden;
|
|
35
|
+
pointer-events: auto;
|
|
36
|
+
position: absolute;
|
|
37
|
+
right: 0;
|
|
38
|
+
transition: height var(--component-sheet-resize-duration) ease, transform var(--component-sheet-motion-duration) ease;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.dragging {
|
|
42
|
+
transition: none;
|
|
43
|
+
user-select: none;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.drag-area {
|
|
47
|
+
align-items: center;
|
|
48
|
+
cursor: ns-resize;
|
|
49
|
+
display: flex;
|
|
50
|
+
flex: none;
|
|
51
|
+
justify-content: center;
|
|
52
|
+
min-height: var(--component-sheet-drag-area-height);
|
|
53
|
+
touch-action: none;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.handle {
|
|
57
|
+
background: var(--component-sheet-secondary);
|
|
58
|
+
border-radius: var(--component-sheet-handle-radius);
|
|
59
|
+
height: var(--component-sheet-handle-height);
|
|
60
|
+
opacity: var(--component-sheet-handle-opacity);
|
|
61
|
+
width: var(--component-sheet-handle-width);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.header {
|
|
65
|
+
align-items: flex-start;
|
|
66
|
+
border-bottom: var(--component-sheet-border-width) solid var(--component-sheet-border-color);
|
|
67
|
+
display: flex;
|
|
68
|
+
flex: none;
|
|
69
|
+
gap: var(--component-sheet-header-gap);
|
|
70
|
+
padding: var(--component-sheet-header-padding);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.heading {
|
|
74
|
+
flex: 1;
|
|
75
|
+
min-width: 0;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.heading h2 {
|
|
79
|
+
font-size: var(--component-sheet-title-font-size);
|
|
80
|
+
font-weight: var(--component-sheet-title-font-weight);
|
|
81
|
+
line-height: var(--component-sheet-title-line-height);
|
|
82
|
+
margin: 0;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.heading p {
|
|
86
|
+
color: var(--component-sheet-secondary);
|
|
87
|
+
font-size: var(--component-sheet-description-font-size);
|
|
88
|
+
margin: var(--component-sheet-description-offset) 0 0;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.header-actions {
|
|
92
|
+
align-items: center;
|
|
93
|
+
display: flex;
|
|
94
|
+
flex: none;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.body {
|
|
98
|
+
flex: 1;
|
|
99
|
+
min-height: 0;
|
|
100
|
+
overflow: auto;
|
|
101
|
+
overscroll-behavior: contain;
|
|
102
|
+
padding: var(--component-sheet-body-padding);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.footer {
|
|
106
|
+
background: var(--component-sheet-bg);
|
|
107
|
+
border-top: var(--component-sheet-border-width) solid var(--component-sheet-border-color);
|
|
108
|
+
flex: none;
|
|
109
|
+
padding: var(--component-sheet-footer-padding-block) var(--component-sheet-footer-padding-inline) max(var(--component-sheet-footer-padding-block), env(safe-area-inset-bottom));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.closing .overlay {
|
|
113
|
+
animation: fade-out var(--component-sheet-motion-duration) ease-in both;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.closing .sheet {
|
|
117
|
+
animation: sheet-out var(--component-sheet-motion-duration) ease-in both;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.non-modal {
|
|
121
|
+
height: 100%;
|
|
122
|
+
inset: auto 0 0;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
@keyframes fade-in {
|
|
126
|
+
from {
|
|
127
|
+
opacity: 0;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
@keyframes fade-out {
|
|
131
|
+
to {
|
|
132
|
+
opacity: 0;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
@keyframes sheet-in {
|
|
136
|
+
from {
|
|
137
|
+
transform: translateY(100%);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
@keyframes sheet-out {
|
|
141
|
+
to {
|
|
142
|
+
transform: translateY(100%);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
@media (prefers-reduced-motion: reduce) {
|
|
146
|
+
.overlay,
|
|
147
|
+
.sheet,
|
|
148
|
+
.closing .overlay,
|
|
149
|
+
.closing .sheet {
|
|
150
|
+
animation-duration: var(--component-sheet-reduced-motion-duration);
|
|
151
|
+
transition-duration: var(--component-sheet-reduced-motion-duration);
|
|
152
|
+
}
|
|
153
|
+
}
|
package/Sheet/index.d.ts
ADDED
package/Sheet/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode, RefObject } from "react";
|
|
2
|
+
export type SheetSnapPoint = number | `${number}px` | `${number}%` | `${number}vh` | `${number}dvh`;
|
|
3
|
+
export type SheetCloseReason = "overlay" | "escape" | "drag";
|
|
4
|
+
export interface SheetProps extends Omit<HTMLAttributes<HTMLDivElement>, "title" | "onChange"> {
|
|
5
|
+
open: boolean;
|
|
6
|
+
onOpenChange: (open: boolean, reason?: SheetCloseReason) => void;
|
|
7
|
+
title?: ReactNode;
|
|
8
|
+
description?: ReactNode;
|
|
9
|
+
header?: ReactNode;
|
|
10
|
+
footer?: ReactNode;
|
|
11
|
+
snapPoints?: readonly SheetSnapPoint[];
|
|
12
|
+
snapPoint?: SheetSnapPoint;
|
|
13
|
+
defaultSnapPoint?: SheetSnapPoint;
|
|
14
|
+
onSnapPointChange?: (snapPoint: SheetSnapPoint) => void;
|
|
15
|
+
modal?: boolean;
|
|
16
|
+
blurOverlay?: boolean;
|
|
17
|
+
closeOnOverlayClick?: boolean;
|
|
18
|
+
closeOnEscape?: boolean;
|
|
19
|
+
draggable?: boolean;
|
|
20
|
+
showHandle?: boolean;
|
|
21
|
+
lockBodyScroll?: boolean;
|
|
22
|
+
portalContainer?: HTMLElement | null;
|
|
23
|
+
initialFocusRef?: RefObject<HTMLElement | null>;
|
|
24
|
+
returnFocusRef?: RefObject<HTMLElement | null>;
|
|
25
|
+
zIndex?: number;
|
|
26
|
+
}
|
package/Theme/index.d.ts
CHANGED
|
@@ -597,6 +597,36 @@ export declare const THEMES: {
|
|
|
597
597
|
"component-avatar-font-size-xxxl": string;
|
|
598
598
|
"component-accordion-text": string;
|
|
599
599
|
"component-accordion-line": string;
|
|
600
|
+
"component-sheet-bg": string;
|
|
601
|
+
"component-sheet-text": string;
|
|
602
|
+
"component-sheet-secondary": string;
|
|
603
|
+
"component-sheet-overlay": string;
|
|
604
|
+
"component-sheet-radius": string;
|
|
605
|
+
"component-sheet-shadow": string;
|
|
606
|
+
"component-sheet-z-index": string;
|
|
607
|
+
"component-sheet-max-height": string;
|
|
608
|
+
"component-sheet-overlay-blur": string;
|
|
609
|
+
"component-sheet-motion-duration": string;
|
|
610
|
+
"component-sheet-resize-duration": string;
|
|
611
|
+
"component-sheet-motion-easing": string;
|
|
612
|
+
"component-sheet-reduced-motion-duration": string;
|
|
613
|
+
"component-sheet-drag-area-height": string;
|
|
614
|
+
"component-sheet-handle-width": string;
|
|
615
|
+
"component-sheet-handle-height": string;
|
|
616
|
+
"component-sheet-handle-radius": string;
|
|
617
|
+
"component-sheet-handle-opacity": string;
|
|
618
|
+
"component-sheet-header-gap": string;
|
|
619
|
+
"component-sheet-header-padding": string;
|
|
620
|
+
"component-sheet-border-width": string;
|
|
621
|
+
"component-sheet-border-color": string;
|
|
622
|
+
"component-sheet-title-font-size": string;
|
|
623
|
+
"component-sheet-title-line-height": string;
|
|
624
|
+
"component-sheet-title-font-weight": string;
|
|
625
|
+
"component-sheet-description-offset": string;
|
|
626
|
+
"component-sheet-description-font-size": string;
|
|
627
|
+
"component-sheet-body-padding": string;
|
|
628
|
+
"component-sheet-footer-padding-block": string;
|
|
629
|
+
"component-sheet-footer-padding-inline": string;
|
|
600
630
|
"component-modal-bg": string;
|
|
601
631
|
"component-modal-border": string;
|
|
602
632
|
"component-modal-overlay": string;
|
|
@@ -1384,6 +1414,36 @@ export declare const THEMES: {
|
|
|
1384
1414
|
"component-avatar-font-size-xxxl": string;
|
|
1385
1415
|
"component-accordion-text": string;
|
|
1386
1416
|
"component-accordion-line": string;
|
|
1417
|
+
"component-sheet-bg": string;
|
|
1418
|
+
"component-sheet-text": string;
|
|
1419
|
+
"component-sheet-secondary": string;
|
|
1420
|
+
"component-sheet-overlay": string;
|
|
1421
|
+
"component-sheet-radius": string;
|
|
1422
|
+
"component-sheet-shadow": string;
|
|
1423
|
+
"component-sheet-z-index": string;
|
|
1424
|
+
"component-sheet-max-height": string;
|
|
1425
|
+
"component-sheet-overlay-blur": string;
|
|
1426
|
+
"component-sheet-motion-duration": string;
|
|
1427
|
+
"component-sheet-resize-duration": string;
|
|
1428
|
+
"component-sheet-motion-easing": string;
|
|
1429
|
+
"component-sheet-reduced-motion-duration": string;
|
|
1430
|
+
"component-sheet-drag-area-height": string;
|
|
1431
|
+
"component-sheet-handle-width": string;
|
|
1432
|
+
"component-sheet-handle-height": string;
|
|
1433
|
+
"component-sheet-handle-radius": string;
|
|
1434
|
+
"component-sheet-handle-opacity": string;
|
|
1435
|
+
"component-sheet-header-gap": string;
|
|
1436
|
+
"component-sheet-header-padding": string;
|
|
1437
|
+
"component-sheet-border-width": string;
|
|
1438
|
+
"component-sheet-border-color": string;
|
|
1439
|
+
"component-sheet-title-font-size": string;
|
|
1440
|
+
"component-sheet-title-line-height": string;
|
|
1441
|
+
"component-sheet-title-font-weight": string;
|
|
1442
|
+
"component-sheet-description-offset": string;
|
|
1443
|
+
"component-sheet-description-font-size": string;
|
|
1444
|
+
"component-sheet-body-padding": string;
|
|
1445
|
+
"component-sheet-footer-padding-block": string;
|
|
1446
|
+
"component-sheet-footer-padding-inline": string;
|
|
1387
1447
|
"component-modal-bg": string;
|
|
1388
1448
|
"component-modal-border": string;
|
|
1389
1449
|
"component-modal-overlay": string;
|
|
@@ -518,6 +518,36 @@ declare const _default: {
|
|
|
518
518
|
"component-avatar-font-size-xxxl": string;
|
|
519
519
|
"component-accordion-text": string;
|
|
520
520
|
"component-accordion-line": string;
|
|
521
|
+
"component-sheet-bg": string;
|
|
522
|
+
"component-sheet-text": string;
|
|
523
|
+
"component-sheet-secondary": string;
|
|
524
|
+
"component-sheet-overlay": string;
|
|
525
|
+
"component-sheet-radius": string;
|
|
526
|
+
"component-sheet-shadow": string;
|
|
527
|
+
"component-sheet-z-index": string;
|
|
528
|
+
"component-sheet-max-height": string;
|
|
529
|
+
"component-sheet-overlay-blur": string;
|
|
530
|
+
"component-sheet-motion-duration": string;
|
|
531
|
+
"component-sheet-resize-duration": string;
|
|
532
|
+
"component-sheet-motion-easing": string;
|
|
533
|
+
"component-sheet-reduced-motion-duration": string;
|
|
534
|
+
"component-sheet-drag-area-height": string;
|
|
535
|
+
"component-sheet-handle-width": string;
|
|
536
|
+
"component-sheet-handle-height": string;
|
|
537
|
+
"component-sheet-handle-radius": string;
|
|
538
|
+
"component-sheet-handle-opacity": string;
|
|
539
|
+
"component-sheet-header-gap": string;
|
|
540
|
+
"component-sheet-header-padding": string;
|
|
541
|
+
"component-sheet-border-width": string;
|
|
542
|
+
"component-sheet-border-color": string;
|
|
543
|
+
"component-sheet-title-font-size": string;
|
|
544
|
+
"component-sheet-title-line-height": string;
|
|
545
|
+
"component-sheet-title-font-weight": string;
|
|
546
|
+
"component-sheet-description-offset": string;
|
|
547
|
+
"component-sheet-description-font-size": string;
|
|
548
|
+
"component-sheet-body-padding": string;
|
|
549
|
+
"component-sheet-footer-padding-block": string;
|
|
550
|
+
"component-sheet-footer-padding-inline": string;
|
|
521
551
|
"component-modal-bg": string;
|
|
522
552
|
"component-modal-border": string;
|
|
523
553
|
"component-modal-overlay": string;
|
|
@@ -524,6 +524,36 @@ var THEME_BA = {
|
|
|
524
524
|
"component-avatar-font-size-xxxl": "9rem",
|
|
525
525
|
"component-accordion-text": theme_buenos_aires.default.BRAND_BA_FOREST,
|
|
526
526
|
"component-accordion-line": theme_buenos_aires.default.NEUTRAL_BA_300,
|
|
527
|
+
"component-sheet-bg": "var(--color-bg-surface)",
|
|
528
|
+
"component-sheet-text": "var(--color-text-primary)",
|
|
529
|
+
"component-sheet-secondary": "var(--color-text-secondary)",
|
|
530
|
+
"component-sheet-overlay": "var(--component-modal-overlay)",
|
|
531
|
+
"component-sheet-radius": "var(--radius-xl)",
|
|
532
|
+
"component-sheet-shadow": "var(--shadow-raised)",
|
|
533
|
+
"component-sheet-z-index": "1000",
|
|
534
|
+
"component-sheet-max-height": "96dvh",
|
|
535
|
+
"component-sheet-overlay-blur": "var(--space-3)",
|
|
536
|
+
"component-sheet-motion-duration": "220ms",
|
|
537
|
+
"component-sheet-resize-duration": "200ms",
|
|
538
|
+
"component-sheet-motion-easing": "cubic-bezier(0.2, 0.8, 0.2, 1)",
|
|
539
|
+
"component-sheet-reduced-motion-duration": "0.001ms",
|
|
540
|
+
"component-sheet-drag-area-height": "var(--space-6)",
|
|
541
|
+
"component-sheet-handle-width": "calc(var(--space-10) + var(--space-1))",
|
|
542
|
+
"component-sheet-handle-height": "var(--space-1)",
|
|
543
|
+
"component-sheet-handle-radius": "var(--radius-full)",
|
|
544
|
+
"component-sheet-handle-opacity": "0.45",
|
|
545
|
+
"component-sheet-header-gap": "var(--space-4)",
|
|
546
|
+
"component-sheet-header-padding": "var(--space-3) var(--space-5) var(--space-4)",
|
|
547
|
+
"component-sheet-border-width": "var(--border-width-hairline)",
|
|
548
|
+
"component-sheet-border-color": "var(--color-border-subtle)",
|
|
549
|
+
"component-sheet-title-font-size": "var(--font-size-heading-sm)",
|
|
550
|
+
"component-sheet-title-line-height": "var(--line-height-heading-sm)",
|
|
551
|
+
"component-sheet-title-font-weight": "var(--font-weight-semibold)",
|
|
552
|
+
"component-sheet-description-offset": "var(--space-1)",
|
|
553
|
+
"component-sheet-description-font-size": "var(--font-size-text-sm)",
|
|
554
|
+
"component-sheet-body-padding": "var(--space-5)",
|
|
555
|
+
"component-sheet-footer-padding-block": "var(--space-4)",
|
|
556
|
+
"component-sheet-footer-padding-inline": "var(--space-5)",
|
|
527
557
|
"component-modal-bg": theme_buenos_aires.default.NEUTRAL_BA_0,
|
|
528
558
|
"component-modal-border": theme_buenos_aires.default.NEUTRAL_BA_200,
|
|
529
559
|
"component-modal-overlay": "rgb(22 51 0 / 28%)",
|