@ntmats/hc-ui 0.7.0 → 0.8.0
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/index.d.ts +10 -1
- package/dist/index.js +3 -2
- package/dist/styles.css +9 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -310,6 +310,7 @@ export interface DialogProps extends Omit<HTMLAttributes<HTMLDialogElement>, 'ti
|
|
|
310
310
|
*/
|
|
311
311
|
export declare const Dialog: ForwardRefExoticComponent<DialogProps & RefAttributes<HTMLDialogElement>>;
|
|
312
312
|
export type SheetPresentation = 'bottom' | 'center' | 'auto';
|
|
313
|
+
export type SheetHeight = 'content' | 'half';
|
|
313
314
|
interface SheetBaseProps extends Omit<DialogProps, 'size' | 'actions' | 'description' | 'closeLabel' | 'title'> {
|
|
314
315
|
/** Slot under the scrolling body, for the buttons (Clear | Done). */
|
|
315
316
|
footer?: ReactNode;
|
|
@@ -321,6 +322,13 @@ interface SheetBaseProps extends Omit<DialogProps, 'size' | 'actions' | 'descrip
|
|
|
321
322
|
presentation?: SheetPresentation;
|
|
322
323
|
/** Maximum width of the centered panel, in px. Default 440. */
|
|
323
324
|
width?: number;
|
|
325
|
+
/**
|
|
326
|
+
* Resting height at the bottom. `content` (default) grows with the content up to almost the
|
|
327
|
+
* whole screen. `half` rests at half the screen, so what is behind stays in sight (dimmed),
|
|
328
|
+
* and the content scrolls inside; a drag up from the grabber or header still goes to full
|
|
329
|
+
* height, and a drag down from there comes back to half. No effect on the centered panel.
|
|
330
|
+
*/
|
|
331
|
+
height?: SheetHeight;
|
|
324
332
|
}
|
|
325
333
|
/**
|
|
326
334
|
* `Sheet` props. By default the sheet has a header with the title (its accessible name) and a
|
|
@@ -346,7 +354,8 @@ export type SheetProps = SheetBaseProps & ({
|
|
|
346
354
|
* Tab trap, Esc, focus return, scroll lock, stacking and controlled `open`/`onClose`.
|
|
347
355
|
* At the bottom it has a grabber, drag to close (past 20% of its height or a quick
|
|
348
356
|
* flick) and drag up from the grabber or header to full height; content that has
|
|
349
|
-
* scrolled down scrolls back before the sheet moves.
|
|
357
|
+
* scrolled down scrolls back before the sheet moves. `height="half"` rests at half the
|
|
358
|
+
* screen instead of growing with the content.
|
|
350
359
|
*/
|
|
351
360
|
export declare const Sheet: ForwardRefExoticComponent<SheetProps & RefAttributes<HTMLDialogElement>>;
|
|
352
361
|
export interface SheetOption<T extends string> {
|
package/dist/index.js
CHANGED
|
@@ -602,7 +602,7 @@ function useSheetDrag(sheet, latest) {
|
|
|
602
602
|
};
|
|
603
603
|
}, [sheet, latest]);
|
|
604
604
|
}
|
|
605
|
-
var Sheet = forwardRef(function Sheet2({ presentation = "auto", width = 440, footer, dismissible = true, header = true, onClose, className, style, ...props }, ref) {
|
|
605
|
+
var Sheet = forwardRef(function Sheet2({ presentation = "auto", width = 440, height = "content", footer, dismissible = true, header = true, onClose, className, style, ...props }, ref) {
|
|
606
606
|
const [node, setNode] = useState(null);
|
|
607
607
|
const setRef = useCallback((element) => {
|
|
608
608
|
setNode(element);
|
|
@@ -626,7 +626,8 @@ var Sheet = forwardRef(function Sheet2({ presentation = "auto", width = 440, foo
|
|
|
626
626
|
headerless: !header,
|
|
627
627
|
className: classes("hc-ui-sheet", className),
|
|
628
628
|
style: sized,
|
|
629
|
-
"data-presentation": presentation
|
|
629
|
+
"data-presentation": presentation,
|
|
630
|
+
"data-height": height === "half" ? "half" : void 0
|
|
630
631
|
}
|
|
631
632
|
);
|
|
632
633
|
});
|
package/dist/styles.css
CHANGED
|
@@ -854,6 +854,11 @@
|
|
|
854
854
|
border-radius: 20px 20px 0 0;
|
|
855
855
|
}
|
|
856
856
|
[data-hc-ds] .hc-ui-sheet[data-presentation='bottom'][data-closing] { animation: hc-ui-sheet-down var(--hc-dur-medium) var(--hc-ease-emphasized-accel) forwards; }
|
|
857
|
+
/* height="half": rests at half the screen; the body scrolls. Expanded still wins (full height). */
|
|
858
|
+
[data-hc-ds] .hc-ui-sheet[data-presentation='bottom'][data-height='half']:not([data-expanded]) {
|
|
859
|
+
height: 50dvh;
|
|
860
|
+
max-height: 50dvh;
|
|
861
|
+
}
|
|
857
862
|
|
|
858
863
|
@media (max-width: 959.98px) {
|
|
859
864
|
[data-hc-ds] .hc-ui-sheet[data-presentation='auto'] {
|
|
@@ -888,6 +893,10 @@
|
|
|
888
893
|
border-radius: 20px 20px 0 0;
|
|
889
894
|
}
|
|
890
895
|
[data-hc-ds] .hc-ui-sheet[data-presentation='auto'][data-closing] { animation: hc-ui-sheet-down var(--hc-dur-medium) var(--hc-ease-emphasized-accel) forwards; }
|
|
896
|
+
[data-hc-ds] .hc-ui-sheet[data-presentation='auto'][data-height='half']:not([data-expanded]) {
|
|
897
|
+
height: 50dvh;
|
|
898
|
+
max-height: 50dvh;
|
|
899
|
+
}
|
|
891
900
|
}
|
|
892
901
|
|
|
893
902
|
/* Closing by drag: the backdrop fades with the sheet instead of waiting for the exit. */
|