@okshaun/components 4.1.5 → 4.2.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.js +308 -35
- package/dist/index.js.map +1 -1
- package/dist/panda.buildinfo.json +20 -4
- package/dist/{preset-jXQwQ5KL.js → preset-CsYXL2Bm.js} +95 -1
- package/dist/preset-CsYXL2Bm.js.map +1 -0
- package/dist/preset.js +1 -1
- package/dist/specs/recipes.json +11 -0
- package/dist/sprite.symbol.html +1 -1
- package/dist/styles.css +127 -8
- package/dist/types/index.d.ts +266 -0
- package/package.json +1 -1
- package/src/recipes/printPreview.ts +101 -0
- package/src/recipes/recipes-slot.ts +1 -0
- package/dist/preset-jXQwQ5KL.js.map +0 -1
package/dist/preset.js
CHANGED
package/dist/specs/recipes.json
CHANGED
|
@@ -1113,6 +1113,17 @@
|
|
|
1113
1113
|
"<Modal size=\"sm\" position=\"centered\" />"
|
|
1114
1114
|
]
|
|
1115
1115
|
},
|
|
1116
|
+
{
|
|
1117
|
+
"name": "printPreview",
|
|
1118
|
+
"variants": {},
|
|
1119
|
+
"defaultVariants": {},
|
|
1120
|
+
"functionExamples": [
|
|
1121
|
+
"printPreview()"
|
|
1122
|
+
],
|
|
1123
|
+
"jsxExamples": [
|
|
1124
|
+
"<PrintPreview />"
|
|
1125
|
+
]
|
|
1126
|
+
},
|
|
1116
1127
|
{
|
|
1117
1128
|
"name": "radio",
|
|
1118
1129
|
"variants": {},
|
package/dist/sprite.symbol.html
CHANGED
|
@@ -4768,7 +4768,7 @@ embedded above. They may be styled via CSS.
|
|
|
4768
4768
|
|
|
4769
4769
|
<footer>
|
|
4770
4770
|
<p>
|
|
4771
|
-
Generated <span class="date">
|
|
4771
|
+
Generated <span class="date">Tue, 10 Nov 2026 19:41:52 GMT</span> using
|
|
4772
4772
|
<a href="https://github.com/svg-sprite/svg-sprite" target="_blank" rel="noopener noreferrer">svg-sprite</a>.
|
|
4773
4773
|
</p>
|
|
4774
4774
|
</footer>
|
package/dist/styles.css
CHANGED
|
@@ -5385,6 +5385,89 @@
|
|
|
5385
5385
|
justify-content: flex-end;
|
|
5386
5386
|
}
|
|
5387
5387
|
|
|
5388
|
+
.oks-printPreview__root {
|
|
5389
|
+
background: var(--oks-colors-surface-sunken);
|
|
5390
|
+
padding: var(--oks-spacing-24);
|
|
5391
|
+
overflow: auto;
|
|
5392
|
+
position: relative;
|
|
5393
|
+
scrollbar-gutter: stable;
|
|
5394
|
+
width: var(--oks-sizes-full);
|
|
5395
|
+
height: var(--oks-sizes-full);
|
|
5396
|
+
}
|
|
5397
|
+
|
|
5398
|
+
.oks-printPreview__root:is(:focus-visible, [data-focus-visible=true]) {
|
|
5399
|
+
outline-width: var(--oks-border-widths-2);
|
|
5400
|
+
outline-style: solid;
|
|
5401
|
+
outline-color: var(--oks-colors-border-focused);
|
|
5402
|
+
outline-offset: calc(var(--oks-spacing-2) * -1);
|
|
5403
|
+
}
|
|
5404
|
+
|
|
5405
|
+
.oks-printPreview__stack {
|
|
5406
|
+
gap: var(--oks-spacing-24);
|
|
5407
|
+
display: flex;
|
|
5408
|
+
flex-direction: column;
|
|
5409
|
+
align-items: flex-start;
|
|
5410
|
+
width: max-content;
|
|
5411
|
+
min-width: var(--oks-sizes-full);
|
|
5412
|
+
}
|
|
5413
|
+
|
|
5414
|
+
.oks-printPreview__page {
|
|
5415
|
+
margin-inline: var(--oks-spacing-auto);
|
|
5416
|
+
position: relative;
|
|
5417
|
+
flex-shrink: 0;
|
|
5418
|
+
box-shadow: var(--oks-shadows-raised);
|
|
5419
|
+
width: calc(var(--print-page-w) * var(--print-scale));
|
|
5420
|
+
height: calc(var(--print-page-h) * var(--print-scale));
|
|
5421
|
+
}
|
|
5422
|
+
|
|
5423
|
+
.oks-printPreview__page[data-measuring=true] {
|
|
5424
|
+
visibility: hidden;
|
|
5425
|
+
}
|
|
5426
|
+
|
|
5427
|
+
.oks-printPreview__sheet {
|
|
5428
|
+
background: var(--oks-colors-neutral-0);
|
|
5429
|
+
overflow: hidden;
|
|
5430
|
+
position: absolute;
|
|
5431
|
+
color: var(--oks-colors-neutral-110);
|
|
5432
|
+
transform: scale(var(--print-scale));
|
|
5433
|
+
transform-origin: top left;
|
|
5434
|
+
top: var(--oks-spacing-0);
|
|
5435
|
+
left: var(--oks-spacing-0);
|
|
5436
|
+
width: var(--print-page-w);
|
|
5437
|
+
height: var(--print-page-h);
|
|
5438
|
+
}
|
|
5439
|
+
|
|
5440
|
+
.oks-printPreview__overlay,.oks-printPreview__marginArea {
|
|
5441
|
+
inset: var(--oks-spacing-0);
|
|
5442
|
+
position: absolute;
|
|
5443
|
+
pointer-events: none;
|
|
5444
|
+
}
|
|
5445
|
+
|
|
5446
|
+
.oks-printPreview__marginArea {
|
|
5447
|
+
mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
|
|
5448
|
+
-webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
|
|
5449
|
+
background-image: repeating-linear-gradient(-45deg, var(--oks-colors-border-info) 0 var(--oks-sizes-1), transparent var(--oks-sizes-1) var(--oks-sizes-8));
|
|
5450
|
+
opacity: 0.3;
|
|
5451
|
+
mask-composite: exclude;
|
|
5452
|
+
-webkit-mask-composite: xor;
|
|
5453
|
+
padding-top: calc(var(--print-margin-top) * var(--print-scale));
|
|
5454
|
+
padding-right: calc(var(--print-margin-right) * var(--print-scale));
|
|
5455
|
+
padding-bottom: calc(var(--print-margin-bottom) * var(--print-scale));
|
|
5456
|
+
padding-left: calc(var(--print-margin-left) * var(--print-scale));
|
|
5457
|
+
}
|
|
5458
|
+
|
|
5459
|
+
.oks-printPreview__margins {
|
|
5460
|
+
border-width: var(--oks-border-widths-1);
|
|
5461
|
+
border-style: dashed;
|
|
5462
|
+
border-color: var(--oks-colors-border-info);
|
|
5463
|
+
position: absolute;
|
|
5464
|
+
pointer-events: none;
|
|
5465
|
+
top: calc(var(--print-margin-top) * var(--print-scale));
|
|
5466
|
+
right: calc(var(--print-margin-right) * var(--print-scale));
|
|
5467
|
+
bottom: calc(var(--print-margin-bottom) * var(--print-scale));
|
|
5468
|
+
left: calc(var(--print-margin-left) * var(--print-scale));
|
|
5469
|
+
}
|
|
5470
|
+
|
|
5388
5471
|
.oks-radio__container {
|
|
5389
5472
|
place-content: center;
|
|
5390
5473
|
position: relative;
|
|
@@ -17723,6 +17806,10 @@
|
|
|
17723
17806
|
padding: var(--oks-spacing-40);
|
|
17724
17807
|
}
|
|
17725
17808
|
|
|
17809
|
+
.oks-p_8 {
|
|
17810
|
+
padding: var(--oks-spacing-8);
|
|
17811
|
+
}
|
|
17812
|
+
|
|
17726
17813
|
.oks-p_0 {
|
|
17727
17814
|
padding: var(--oks-spacing-0);
|
|
17728
17815
|
}
|
|
@@ -17735,10 +17822,6 @@
|
|
|
17735
17822
|
border: 0;
|
|
17736
17823
|
}
|
|
17737
17824
|
|
|
17738
|
-
.oks-p_8 {
|
|
17739
|
-
padding: var(--oks-spacing-8);
|
|
17740
|
-
}
|
|
17741
|
-
|
|
17742
17825
|
.oks-p_2 {
|
|
17743
17826
|
padding: var(--oks-spacing-2);
|
|
17744
17827
|
}
|
|
@@ -17927,6 +18010,26 @@
|
|
|
17927
18010
|
padding-block: var(--oks-spacing-16);
|
|
17928
18011
|
}
|
|
17929
18012
|
|
|
18013
|
+
.oks-bd-c_neutral\.30 {
|
|
18014
|
+
border-color: var(--oks-colors-neutral-30);
|
|
18015
|
+
}
|
|
18016
|
+
|
|
18017
|
+
.oks-bd-w_0 {
|
|
18018
|
+
border-width: var(--oks-border-widths-0);
|
|
18019
|
+
}
|
|
18020
|
+
|
|
18021
|
+
.oks-bd-w_2 {
|
|
18022
|
+
border-width: var(--oks-border-widths-2);
|
|
18023
|
+
}
|
|
18024
|
+
|
|
18025
|
+
.oks-border-style_solid {
|
|
18026
|
+
border-style: solid;
|
|
18027
|
+
}
|
|
18028
|
+
|
|
18029
|
+
.oks-bd-c_border\.danger {
|
|
18030
|
+
border-color: var(--oks-colors-border-danger);
|
|
18031
|
+
}
|
|
18032
|
+
|
|
17930
18033
|
.oks-flex_1 {
|
|
17931
18034
|
flex: 1 1 0%;
|
|
17932
18035
|
}
|
|
@@ -23680,6 +23783,10 @@
|
|
|
23680
23783
|
position: absolute;
|
|
23681
23784
|
}
|
|
23682
23785
|
|
|
23786
|
+
.oks-grid-tc_repeat\(3\,_minmax\(0\,_1fr\)\) {
|
|
23787
|
+
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
23788
|
+
}
|
|
23789
|
+
|
|
23683
23790
|
.oks-cp-path_inset\(50\%\) {
|
|
23684
23791
|
clip-path: inset(50%);
|
|
23685
23792
|
-webkit-clip-path: inset(50%);
|
|
@@ -23772,10 +23879,6 @@
|
|
|
23772
23879
|
grid-template-columns: repeat(1, minmax(0, 1fr));
|
|
23773
23880
|
}
|
|
23774
23881
|
|
|
23775
|
-
.oks-grid-tc_repeat\(3\,_minmax\(0\,_1fr\)\) {
|
|
23776
|
-
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
23777
|
-
}
|
|
23778
|
-
|
|
23779
23882
|
.oks-li-t_disc {
|
|
23780
23883
|
list-style-type: disc;
|
|
23781
23884
|
}
|
|
@@ -26374,6 +26477,22 @@
|
|
|
26374
26477
|
min-width: 180px;
|
|
26375
26478
|
}
|
|
26376
26479
|
|
|
26480
|
+
.oks-pt_12 {
|
|
26481
|
+
padding-top: var(--oks-spacing-12);
|
|
26482
|
+
}
|
|
26483
|
+
|
|
26484
|
+
.oks-top_96 {
|
|
26485
|
+
top: var(--oks-spacing-96);
|
|
26486
|
+
}
|
|
26487
|
+
|
|
26488
|
+
.oks-left_48 {
|
|
26489
|
+
left: var(--oks-spacing-48);
|
|
26490
|
+
}
|
|
26491
|
+
|
|
26492
|
+
.oks-bd-b-w_1 {
|
|
26493
|
+
border-bottom-width: var(--oks-border-widths-1);
|
|
26494
|
+
}
|
|
26495
|
+
|
|
26377
26496
|
.oks-ov-x_visible {
|
|
26378
26497
|
overflow-x: visible;
|
|
26379
26498
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -5421,6 +5421,150 @@ export declare type OptionProps = {
|
|
|
5421
5421
|
iconRight?: IconNamesList;
|
|
5422
5422
|
};
|
|
5423
5423
|
|
|
5424
|
+
/** A page resolved to CSS pixels at scale 1. */
|
|
5425
|
+
declare type PageBox = {
|
|
5426
|
+
width: number;
|
|
5427
|
+
height: number;
|
|
5428
|
+
margins: PageMarginBox;
|
|
5429
|
+
};
|
|
5430
|
+
|
|
5431
|
+
/** Page margins in CSS pixels. */
|
|
5432
|
+
declare type PageMarginBox = {
|
|
5433
|
+
top: number;
|
|
5434
|
+
right: number;
|
|
5435
|
+
bottom: number;
|
|
5436
|
+
left: number;
|
|
5437
|
+
};
|
|
5438
|
+
|
|
5439
|
+
/**
|
|
5440
|
+
* Page margins in the page's `unit`. A number applies the same margin to all
|
|
5441
|
+
* four sides.
|
|
5442
|
+
*/
|
|
5443
|
+
export declare type PageMargins = number | {
|
|
5444
|
+
top: number;
|
|
5445
|
+
right: number;
|
|
5446
|
+
bottom: number;
|
|
5447
|
+
left: number;
|
|
5448
|
+
};
|
|
5449
|
+
|
|
5450
|
+
/**
|
|
5451
|
+
* Page orientation. `portrait` makes the page taller than it is wide and
|
|
5452
|
+
* `landscape` makes it wider than it is tall, whichever way the size is given.
|
|
5453
|
+
*/
|
|
5454
|
+
export declare type PageOrientation = 'portrait' | 'landscape';
|
|
5455
|
+
|
|
5456
|
+
/**
|
|
5457
|
+
* Physical size of a printed page.
|
|
5458
|
+
*
|
|
5459
|
+
* Pass one of the {@link pageSizes} presets or any object of this shape, such
|
|
5460
|
+
* as a size read from a template's `@page` rule.
|
|
5461
|
+
*
|
|
5462
|
+
* @example
|
|
5463
|
+
* ```ts
|
|
5464
|
+
* const shippingLabel: PageSize = { width: 4, height: 6, unit: 'in' };
|
|
5465
|
+
* ```
|
|
5466
|
+
*/
|
|
5467
|
+
export declare type PageSize = {
|
|
5468
|
+
/** Page width in `unit`. */
|
|
5469
|
+
width: number;
|
|
5470
|
+
/** Page height in `unit`. */
|
|
5471
|
+
height: number;
|
|
5472
|
+
/** Unit for `width`, `height`, and the page margins. */
|
|
5473
|
+
unit: PageUnit;
|
|
5474
|
+
};
|
|
5475
|
+
|
|
5476
|
+
/**
|
|
5477
|
+
* Common page and label stock sizes.
|
|
5478
|
+
*
|
|
5479
|
+
* Presets are plain {@link PageSize} values. Use an object literal for any size
|
|
5480
|
+
* not listed here.
|
|
5481
|
+
*
|
|
5482
|
+
* @example
|
|
5483
|
+
* ```tsx
|
|
5484
|
+
* <PrintPage size={pageSizes.a4} />
|
|
5485
|
+
* ```
|
|
5486
|
+
*/
|
|
5487
|
+
export declare const pageSizes: {
|
|
5488
|
+
readonly letter: {
|
|
5489
|
+
readonly width: 8.5;
|
|
5490
|
+
readonly height: 11;
|
|
5491
|
+
readonly unit: "in";
|
|
5492
|
+
};
|
|
5493
|
+
readonly legal: {
|
|
5494
|
+
readonly width: 8.5;
|
|
5495
|
+
readonly height: 14;
|
|
5496
|
+
readonly unit: "in";
|
|
5497
|
+
};
|
|
5498
|
+
readonly tabloid: {
|
|
5499
|
+
readonly width: 11;
|
|
5500
|
+
readonly height: 17;
|
|
5501
|
+
readonly unit: "in";
|
|
5502
|
+
};
|
|
5503
|
+
readonly halfLetter: {
|
|
5504
|
+
readonly width: 5.5;
|
|
5505
|
+
readonly height: 8.5;
|
|
5506
|
+
readonly unit: "in";
|
|
5507
|
+
};
|
|
5508
|
+
readonly a3: {
|
|
5509
|
+
readonly width: 297;
|
|
5510
|
+
readonly height: 420;
|
|
5511
|
+
readonly unit: "mm";
|
|
5512
|
+
};
|
|
5513
|
+
readonly a4: {
|
|
5514
|
+
readonly width: 210;
|
|
5515
|
+
readonly height: 297;
|
|
5516
|
+
readonly unit: "mm";
|
|
5517
|
+
};
|
|
5518
|
+
readonly a5: {
|
|
5519
|
+
readonly width: 148;
|
|
5520
|
+
readonly height: 210;
|
|
5521
|
+
readonly unit: "mm";
|
|
5522
|
+
};
|
|
5523
|
+
readonly a6: {
|
|
5524
|
+
readonly width: 105;
|
|
5525
|
+
readonly height: 148;
|
|
5526
|
+
readonly unit: "mm";
|
|
5527
|
+
};
|
|
5528
|
+
readonly postcard: {
|
|
5529
|
+
readonly width: 4;
|
|
5530
|
+
readonly height: 6;
|
|
5531
|
+
readonly unit: "in";
|
|
5532
|
+
};
|
|
5533
|
+
readonly card5x7: {
|
|
5534
|
+
readonly width: 5;
|
|
5535
|
+
readonly height: 7;
|
|
5536
|
+
readonly unit: "in";
|
|
5537
|
+
};
|
|
5538
|
+
readonly label4x6: {
|
|
5539
|
+
readonly width: 4;
|
|
5540
|
+
readonly height: 6;
|
|
5541
|
+
readonly unit: "in";
|
|
5542
|
+
};
|
|
5543
|
+
readonly label4x3: {
|
|
5544
|
+
readonly width: 4;
|
|
5545
|
+
readonly height: 3;
|
|
5546
|
+
readonly unit: "in";
|
|
5547
|
+
};
|
|
5548
|
+
readonly label4x2: {
|
|
5549
|
+
readonly width: 4;
|
|
5550
|
+
readonly height: 2;
|
|
5551
|
+
readonly unit: "in";
|
|
5552
|
+
};
|
|
5553
|
+
readonly label3x2: {
|
|
5554
|
+
readonly width: 3;
|
|
5555
|
+
readonly height: 2;
|
|
5556
|
+
readonly unit: "in";
|
|
5557
|
+
};
|
|
5558
|
+
readonly label2x1: {
|
|
5559
|
+
readonly width: 2;
|
|
5560
|
+
readonly height: 1;
|
|
5561
|
+
readonly unit: "in";
|
|
5562
|
+
};
|
|
5563
|
+
};
|
|
5564
|
+
|
|
5565
|
+
/** Unit used by a {@link PageSize} and its margins. */
|
|
5566
|
+
export declare type PageUnit = 'in' | 'mm' | 'pt';
|
|
5567
|
+
|
|
5424
5568
|
declare type ParentSelector = `${DataAttributes | AriaAttributes} &`
|
|
5425
5569
|
|
|
5426
5570
|
export declare type Parts = Record<string, SystemStyleObject>;
|
|
@@ -5529,6 +5673,111 @@ export declare type PreProps = BoxProps & {
|
|
|
5529
5673
|
as?: string;
|
|
5530
5674
|
};
|
|
5531
5675
|
|
|
5676
|
+
/**
|
|
5677
|
+
* One printed page at its true proportions.
|
|
5678
|
+
*
|
|
5679
|
+
* Place inside a `PrintPreview`, which sets the scale. Outside a preview the
|
|
5680
|
+
* page renders at scale 1.
|
|
5681
|
+
*
|
|
5682
|
+
* The sheet is white with dark text in both themes, because paper is white.
|
|
5683
|
+
* Design-system components placed directly on the sheet still follow the app
|
|
5684
|
+
* theme. Content in an iframe is not affected.
|
|
5685
|
+
*
|
|
5686
|
+
* Content inside can call `usePrintPage` for the scale and the page geometry.
|
|
5687
|
+
*
|
|
5688
|
+
* @example
|
|
5689
|
+
* ```tsx
|
|
5690
|
+
* <PrintPage size={pageSizes.label4x6} orientation="landscape">
|
|
5691
|
+
* <ShippingLabel />
|
|
5692
|
+
* </PrintPage>
|
|
5693
|
+
* ```
|
|
5694
|
+
*/
|
|
5695
|
+
export declare const PrintPage: (props: PrintPageProps) => JSX.Element;
|
|
5696
|
+
|
|
5697
|
+
/** Geometry of one page, shared with its content. */
|
|
5698
|
+
declare interface PrintPageContextValue extends PageBox {
|
|
5699
|
+
/** Current scale from the parent preview. `1` outside a preview. */
|
|
5700
|
+
scale: number;
|
|
5701
|
+
}
|
|
5702
|
+
|
|
5703
|
+
declare type PrintPageOwnProps = {
|
|
5704
|
+
/** Physical page size. Use a `pageSizes` preset or any `PageSize` object. */
|
|
5705
|
+
size: PageSize;
|
|
5706
|
+
/**
|
|
5707
|
+
* Forces the page to be taller (`portrait`) or wider (`landscape`) than it
|
|
5708
|
+
* is wide. Leave unset to use `size` as given.
|
|
5709
|
+
*/
|
|
5710
|
+
orientation?: PageOrientation;
|
|
5711
|
+
/**
|
|
5712
|
+
* Page margins in the unit of `size`. Margins do not pad the content. They
|
|
5713
|
+
* set the guide drawn by `showMargins` and the values from `usePrintPage`.
|
|
5714
|
+
*/
|
|
5715
|
+
/** @default 0 */
|
|
5716
|
+
margins?: PageMargins;
|
|
5717
|
+
/** Stripes the margin area and draws a dashed line at the content edge. */
|
|
5718
|
+
/** @default false */
|
|
5719
|
+
showMargins?: boolean;
|
|
5720
|
+
/**
|
|
5721
|
+
* Layer drawn above the content in page space, such as error markers or a
|
|
5722
|
+
* selection outline. The layer ignores the pointer. Set `pointerEvents` on
|
|
5723
|
+
* its children to make them interactive.
|
|
5724
|
+
*/
|
|
5725
|
+
overlay?: ReactNode;
|
|
5726
|
+
/**
|
|
5727
|
+
* Page content. It fills the whole sheet at 96 CSS pixels per inch, so an
|
|
5728
|
+
* iframe with full width and height lays out as it prints.
|
|
5729
|
+
*/
|
|
5730
|
+
children?: ReactNode;
|
|
5731
|
+
};
|
|
5732
|
+
|
|
5733
|
+
/** Props accepted by {@link PrintPage}. Includes `Box` and native `div` props. */
|
|
5734
|
+
export declare type PrintPageProps = Omit<BoxProps, keyof PrintPageOwnProps> & PrintPageOwnProps;
|
|
5735
|
+
|
|
5736
|
+
/**
|
|
5737
|
+
* Shows printed pages at their true proportions, scaled to fit the area.
|
|
5738
|
+
*
|
|
5739
|
+
* Wrap one or more `PrintPage` elements. The preview measures itself and
|
|
5740
|
+
* applies one scale to every page, chosen by `fit`. Pages stack vertically
|
|
5741
|
+
* and the preview scrolls when they do not fit.
|
|
5742
|
+
*
|
|
5743
|
+
* The preview does not know what is on the page. Page size comes from each
|
|
5744
|
+
* `PrintPage`'s `size` prop, so it works for server-rendered HTML in an iframe,
|
|
5745
|
+
* an editable canvas, or a rendered PDF page.
|
|
5746
|
+
*
|
|
5747
|
+
* Renders a focusable `div` so keyboard users can scroll it. Give it an
|
|
5748
|
+
* `aria-label` that names what is previewed.
|
|
5749
|
+
*
|
|
5750
|
+
* @example
|
|
5751
|
+
* ```tsx
|
|
5752
|
+
* <PrintPreview aria-label="Document preview">
|
|
5753
|
+
* <PrintPage size={pageSizes.letter} margins={0.5} showMargins>
|
|
5754
|
+
* <iframe title="Document" srcDoc={html} />
|
|
5755
|
+
* </PrintPage>
|
|
5756
|
+
* </PrintPreview>
|
|
5757
|
+
* ```
|
|
5758
|
+
*/
|
|
5759
|
+
export declare const PrintPreview: (props: PrintPreviewProps) => JSX.Element;
|
|
5760
|
+
|
|
5761
|
+
/** Fit mode for {@link PrintPreview}. */
|
|
5762
|
+
export declare type PrintPreviewFit = 'page' | 'width' | number;
|
|
5763
|
+
|
|
5764
|
+
declare type PrintPreviewOwnProps = {
|
|
5765
|
+
/**
|
|
5766
|
+
* How pages scale to the preview area. `page` fits the whole largest page.
|
|
5767
|
+
* `width` fits its width and scrolls vertically. A number is a fixed zoom,
|
|
5768
|
+
* where `1` lays the page out at 96 CSS pixels per inch.
|
|
5769
|
+
*/
|
|
5770
|
+
/** @default "page" */
|
|
5771
|
+
fit?: PrintPreviewFit;
|
|
5772
|
+
/** One or more `PrintPage` elements. */
|
|
5773
|
+
children?: ReactNode;
|
|
5774
|
+
/** Ref to the scrolling root element. */
|
|
5775
|
+
ref?: Ref<HTMLDivElement>;
|
|
5776
|
+
};
|
|
5777
|
+
|
|
5778
|
+
/** Props accepted by {@link PrintPreview}. Includes `Box` and native `div` props. */
|
|
5779
|
+
export declare type PrintPreviewProps = Omit<BoxProps, keyof PrintPreviewOwnProps> & PrintPreviewOwnProps;
|
|
5780
|
+
|
|
5532
5781
|
declare interface PropertiesFallback<TLength = (string & {}) | 0, TTime = string & {}>
|
|
5533
5782
|
extends StandardPropertiesFallback<TLength, TTime>,
|
|
5534
5783
|
VendorPropertiesFallback<TLength, TTime>,
|
|
@@ -22408,6 +22657,23 @@ export declare const useMenuListContext: () => MenuListContextValue | null;
|
|
|
22408
22657
|
*/
|
|
22409
22658
|
export declare const useModalWrapperContext: () => ModalWrapperContextValue;
|
|
22410
22659
|
|
|
22660
|
+
/**
|
|
22661
|
+
* Returns the geometry of the closest parent {@link PrintPage}.
|
|
22662
|
+
*
|
|
22663
|
+
* All lengths are CSS pixels at scale 1, which is page space: 96 per inch.
|
|
22664
|
+
* Divide a screen distance by `scale` to get a page distance, for example to
|
|
22665
|
+
* map a pointer position to a block on the page.
|
|
22666
|
+
*
|
|
22667
|
+
* Call only inside a `PrintPage`; it throws when no page is present.
|
|
22668
|
+
*
|
|
22669
|
+
* @example
|
|
22670
|
+
* ```tsx
|
|
22671
|
+
* const { scale, margins } = usePrintPage();
|
|
22672
|
+
* const pageX = (event.clientX - rect.left) / scale;
|
|
22673
|
+
* ```
|
|
22674
|
+
*/
|
|
22675
|
+
export declare const usePrintPage: () => PrintPageContextValue;
|
|
22676
|
+
|
|
22411
22677
|
export declare const useSelectContext: () => SelectContextValue;
|
|
22412
22678
|
|
|
22413
22679
|
export declare function useTheme(): ThemeContextType;
|
package/package.json
CHANGED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { defineSlotRecipe } from '@pandacss/dev';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Print preview geometry comes from CSS variables that the components set:
|
|
5
|
+
* `--print-scale`, `--print-page-w`, `--print-page-h`, and
|
|
6
|
+
* `--print-margin-{top,right,bottom,left}`. Lengths are page-space pixels.
|
|
7
|
+
*/
|
|
8
|
+
export const printPreviewRecipe = defineSlotRecipe({
|
|
9
|
+
className: 'printPreview',
|
|
10
|
+
jsx: ['PrintPreview', 'PrintPage'],
|
|
11
|
+
slots: ['root', 'stack', 'page', 'sheet', 'overlay', 'marginArea', 'margins'],
|
|
12
|
+
base: {
|
|
13
|
+
root: {
|
|
14
|
+
position: 'relative',
|
|
15
|
+
w: 'full',
|
|
16
|
+
h: 'full',
|
|
17
|
+
overflow: 'auto',
|
|
18
|
+
// A scrollbar that appears would change the width and the fit scale.
|
|
19
|
+
scrollbarGutter: 'stable',
|
|
20
|
+
bg: 'surface.sunken',
|
|
21
|
+
p: '24',
|
|
22
|
+
_focusVisible: {
|
|
23
|
+
outlineWidth: '2',
|
|
24
|
+
outlineStyle: 'solid',
|
|
25
|
+
outlineColor: 'border.focused',
|
|
26
|
+
outlineOffset: '-2',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
stack: {
|
|
30
|
+
display: 'flex',
|
|
31
|
+
flexDirection: 'column',
|
|
32
|
+
alignItems: 'flex-start',
|
|
33
|
+
gap: '24',
|
|
34
|
+
w: 'max-content',
|
|
35
|
+
minW: 'full',
|
|
36
|
+
},
|
|
37
|
+
page: {
|
|
38
|
+
position: 'relative',
|
|
39
|
+
flexShrink: 0,
|
|
40
|
+
// Auto margins center the page without clipping it when it overflows.
|
|
41
|
+
mx: 'auto',
|
|
42
|
+
w: 'calc(var(--print-page-w) * var(--print-scale))',
|
|
43
|
+
h: 'calc(var(--print-page-h) * var(--print-scale))',
|
|
44
|
+
boxShadow: 'raised',
|
|
45
|
+
'&[data-measuring=true]': {
|
|
46
|
+
visibility: 'hidden',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
sheet: {
|
|
50
|
+
position: 'absolute',
|
|
51
|
+
top: '0',
|
|
52
|
+
left: '0',
|
|
53
|
+
w: 'var(--print-page-w)',
|
|
54
|
+
h: 'var(--print-page-h)',
|
|
55
|
+
overflow: 'hidden',
|
|
56
|
+
// Paper is white in both themes. The token system has no light scope to
|
|
57
|
+
// reset semantic colors inside dark mode, so these are primitives.
|
|
58
|
+
bg: 'neutral.0',
|
|
59
|
+
color: 'neutral.110',
|
|
60
|
+
transform: 'scale(var(--print-scale))',
|
|
61
|
+
transformOrigin: 'top left',
|
|
62
|
+
},
|
|
63
|
+
overlay: {
|
|
64
|
+
position: 'absolute',
|
|
65
|
+
inset: '0',
|
|
66
|
+
pointerEvents: 'none',
|
|
67
|
+
},
|
|
68
|
+
// Stripes fill the margins. The padding is the margin, and the mask cuts
|
|
69
|
+
// out the content box. Drawn outside the scaled sheet, so stripe width and
|
|
70
|
+
// spacing stay the same at any zoom.
|
|
71
|
+
marginArea: {
|
|
72
|
+
position: 'absolute',
|
|
73
|
+
inset: '0',
|
|
74
|
+
pt: 'calc(var(--print-margin-top) * var(--print-scale))',
|
|
75
|
+
pr: 'calc(var(--print-margin-right) * var(--print-scale))',
|
|
76
|
+
pb: 'calc(var(--print-margin-bottom) * var(--print-scale))',
|
|
77
|
+
pl: 'calc(var(--print-margin-left) * var(--print-scale))',
|
|
78
|
+
bgImage:
|
|
79
|
+
'repeating-linear-gradient(-45deg, token(colors.border.info) 0 token(sizes.1), transparent token(sizes.1) token(sizes.8))',
|
|
80
|
+
opacity: '0.3',
|
|
81
|
+
// validate-ignore: no-hardcoded-design-values-in-recipes — mask alpha only, never painted
|
|
82
|
+
mask: 'linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0)',
|
|
83
|
+
maskComposite: 'exclude',
|
|
84
|
+
// biome-ignore lint/style/useNamingConvention: vendor-prefixed CSS property
|
|
85
|
+
WebkitMaskComposite: 'xor',
|
|
86
|
+
pointerEvents: 'none',
|
|
87
|
+
},
|
|
88
|
+
// Drawn outside the scaled sheet so the guide stays one pixel wide.
|
|
89
|
+
margins: {
|
|
90
|
+
position: 'absolute',
|
|
91
|
+
top: 'calc(var(--print-margin-top) * var(--print-scale))',
|
|
92
|
+
right: 'calc(var(--print-margin-right) * var(--print-scale))',
|
|
93
|
+
bottom: 'calc(var(--print-margin-bottom) * var(--print-scale))',
|
|
94
|
+
left: 'calc(var(--print-margin-left) * var(--print-scale))',
|
|
95
|
+
borderWidth: '1',
|
|
96
|
+
borderStyle: 'dashed',
|
|
97
|
+
borderColor: 'border.info',
|
|
98
|
+
pointerEvents: 'none',
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
});
|
|
@@ -14,6 +14,7 @@ export { listItemRecipe } from './listItem';
|
|
|
14
14
|
export { listItemGroupRecipe } from './listItemGroup';
|
|
15
15
|
export { menuRecipe } from './menu';
|
|
16
16
|
export { modalRecipe } from './modal';
|
|
17
|
+
export { printPreviewRecipe } from './printPreview';
|
|
17
18
|
export { radioRecipe } from './radio';
|
|
18
19
|
export { segmentedFieldsRecipe } from './segmentedFields';
|
|
19
20
|
export { segmentedInputsRecipe } from './segmentedInputs';
|