@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 CHANGED
@@ -18,8 +18,8 @@ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
18
18
  import * as React from "react";
19
19
  import React__default, { useLayoutEffect, forwardRef, useMemo, createElement, createContext, useContext, useRef, useEffect, useState, useCallback, Children, isValidElement, useId as useId$1, useSyncExternalStore, cloneElement, useReducer } from "react";
20
20
  import * as ReactDOM from "react-dom";
21
- import { c as containerSizes, b as breakpoints } from "./preset-jXQwQ5KL.js";
22
- import { o } from "./preset-jXQwQ5KL.js";
21
+ import { c as containerSizes, b as breakpoints } from "./preset-CsYXL2Bm.js";
22
+ import { o } from "./preset-CsYXL2Bm.js";
23
23
  function hasWindow() {
24
24
  return typeof window !== "undefined";
25
25
  }
@@ -6950,7 +6950,7 @@ const autocompleteVariantKeys = [
6950
6950
  "layer",
6951
6951
  "size"
6952
6952
  ];
6953
- const getVariantProps$p = (variants) => ({ ...autocompleteDefaultVariants, ...compact(variants) });
6953
+ const getVariantProps$q = (variants) => ({ ...autocompleteDefaultVariants, ...compact(variants) });
6954
6954
  const autocomplete = /* @__PURE__ */ Object.assign(autocompleteFn, {
6955
6955
  __recipe__: false,
6956
6956
  __name__: "autocomplete",
@@ -6972,7 +6972,7 @@ const autocomplete = /* @__PURE__ */ Object.assign(autocompleteFn, {
6972
6972
  splitVariantProps(props) {
6973
6973
  return splitProps$1(props, autocompleteVariantKeys);
6974
6974
  },
6975
- getVariantProps: getVariantProps$p
6975
+ getVariantProps: getVariantProps$q
6976
6976
  });
6977
6977
  const avatarDefaultVariants = {
6978
6978
  "size": "md",
@@ -7009,7 +7009,7 @@ const avatarVariantKeys = [
7009
7009
  "size",
7010
7010
  "shape"
7011
7011
  ];
7012
- const getVariantProps$o = (variants) => ({ ...avatarDefaultVariants, ...compact(variants) });
7012
+ const getVariantProps$p = (variants) => ({ ...avatarDefaultVariants, ...compact(variants) });
7013
7013
  const avatar = /* @__PURE__ */ Object.assign(avatarFn, {
7014
7014
  __recipe__: false,
7015
7015
  __name__: "avatar",
@@ -7034,7 +7034,7 @@ const avatar = /* @__PURE__ */ Object.assign(avatarFn, {
7034
7034
  splitVariantProps(props) {
7035
7035
  return splitProps$1(props, avatarVariantKeys);
7036
7036
  },
7037
- getVariantProps: getVariantProps$o
7037
+ getVariantProps: getVariantProps$p
7038
7038
  });
7039
7039
  const badgeDefaultVariants = {
7040
7040
  "size": "md",
@@ -7061,7 +7061,7 @@ const badgeVariantKeys = [
7061
7061
  "dot",
7062
7062
  "variant"
7063
7063
  ];
7064
- const getVariantProps$n = (variants) => ({ ...badgeDefaultVariants, ...compact(variants) });
7064
+ const getVariantProps$o = (variants) => ({ ...badgeDefaultVariants, ...compact(variants) });
7065
7065
  const badge = /* @__PURE__ */ Object.assign(badgeFn, {
7066
7066
  __recipe__: false,
7067
7067
  __name__: "badge",
@@ -7097,7 +7097,7 @@ const badge = /* @__PURE__ */ Object.assign(badgeFn, {
7097
7097
  splitVariantProps(props) {
7098
7098
  return splitProps$1(props, badgeVariantKeys);
7099
7099
  },
7100
- getVariantProps: getVariantProps$n
7100
+ getVariantProps: getVariantProps$o
7101
7101
  });
7102
7102
  const breadcrumbsDefaultVariants = {};
7103
7103
  const breadcrumbsCompoundVariants = [];
@@ -7124,7 +7124,7 @@ const breadcrumbsFn = memo((props = {}) => {
7124
7124
  return Object.fromEntries(breadcrumbsSlotFns.map(([slotName, slotFn]) => [slotName, slotFn.recipeFn(props)]));
7125
7125
  });
7126
7126
  const breadcrumbsVariantKeys = [];
7127
- const getVariantProps$m = (variants) => ({ ...breadcrumbsDefaultVariants, ...compact(variants) });
7127
+ const getVariantProps$n = (variants) => ({ ...breadcrumbsDefaultVariants, ...compact(variants) });
7128
7128
  const breadcrumbs = /* @__PURE__ */ Object.assign(breadcrumbsFn, {
7129
7129
  __recipe__: false,
7130
7130
  __name__: "breadcrumbs",
@@ -7135,7 +7135,7 @@ const breadcrumbs = /* @__PURE__ */ Object.assign(breadcrumbsFn, {
7135
7135
  splitVariantProps(props) {
7136
7136
  return splitProps$1(props, breadcrumbsVariantKeys);
7137
7137
  },
7138
- getVariantProps: getVariantProps$m
7138
+ getVariantProps: getVariantProps$n
7139
7139
  });
7140
7140
  const buttonDefaultVariants = {
7141
7141
  "variant": "standard",
@@ -7166,7 +7166,7 @@ const buttonVariantKeys = [
7166
7166
  "before",
7167
7167
  "after"
7168
7168
  ];
7169
- const getVariantProps$l = (variants) => ({ ...buttonDefaultVariants, ...compact(variants) });
7169
+ const getVariantProps$m = (variants) => ({ ...buttonDefaultVariants, ...compact(variants) });
7170
7170
  const button = /* @__PURE__ */ Object.assign(buttonFn, {
7171
7171
  __recipe__: false,
7172
7172
  __name__: "button",
@@ -7199,7 +7199,7 @@ const button = /* @__PURE__ */ Object.assign(buttonFn, {
7199
7199
  splitVariantProps(props) {
7200
7200
  return splitProps$1(props, buttonVariantKeys);
7201
7201
  },
7202
- getVariantProps: getVariantProps$l
7202
+ getVariantProps: getVariantProps$m
7203
7203
  });
7204
7204
  const calendarDefaultVariants = {
7205
7205
  "type": "days"
@@ -7238,7 +7238,7 @@ const calendarFn = memo((props = {}) => {
7238
7238
  const calendarVariantKeys = [
7239
7239
  "type"
7240
7240
  ];
7241
- const getVariantProps$k = (variants) => ({ ...calendarDefaultVariants, ...compact(variants) });
7241
+ const getVariantProps$l = (variants) => ({ ...calendarDefaultVariants, ...compact(variants) });
7242
7242
  const calendar = /* @__PURE__ */ Object.assign(calendarFn, {
7243
7243
  __recipe__: false,
7244
7244
  __name__: "calendar",
@@ -7255,7 +7255,7 @@ const calendar = /* @__PURE__ */ Object.assign(calendarFn, {
7255
7255
  splitVariantProps(props) {
7256
7256
  return splitProps$1(props, calendarVariantKeys);
7257
7257
  },
7258
- getVariantProps: getVariantProps$k
7258
+ getVariantProps: getVariantProps$l
7259
7259
  });
7260
7260
  const checkboxDefaultVariants = {};
7261
7261
  const checkboxCompoundVariants = [];
@@ -7282,7 +7282,7 @@ const checkboxFn = memo((props = {}) => {
7282
7282
  return Object.fromEntries(checkboxSlotFns.map(([slotName, slotFn]) => [slotName, slotFn.recipeFn(props)]));
7283
7283
  });
7284
7284
  const checkboxVariantKeys = [];
7285
- const getVariantProps$j = (variants) => ({ ...checkboxDefaultVariants, ...compact(variants) });
7285
+ const getVariantProps$k = (variants) => ({ ...checkboxDefaultVariants, ...compact(variants) });
7286
7286
  const checkbox = /* @__PURE__ */ Object.assign(checkboxFn, {
7287
7287
  __recipe__: false,
7288
7288
  __name__: "checkbox",
@@ -7293,7 +7293,7 @@ const checkbox = /* @__PURE__ */ Object.assign(checkboxFn, {
7293
7293
  splitVariantProps(props) {
7294
7294
  return splitProps$1(props, checkboxVariantKeys);
7295
7295
  },
7296
- getVariantProps: getVariantProps$j
7296
+ getVariantProps: getVariantProps$k
7297
7297
  });
7298
7298
  const chipDefaultVariants = {
7299
7299
  "size": "md"
@@ -7331,7 +7331,7 @@ const chipVariantKeys = [
7331
7331
  "after",
7332
7332
  "dismissable"
7333
7333
  ];
7334
- const getVariantProps$i = (variants) => ({ ...chipDefaultVariants, ...compact(variants) });
7334
+ const getVariantProps$j = (variants) => ({ ...chipDefaultVariants, ...compact(variants) });
7335
7335
  const chip = /* @__PURE__ */ Object.assign(chipFn, {
7336
7336
  __recipe__: false,
7337
7337
  __name__: "chip",
@@ -7358,7 +7358,7 @@ const chip = /* @__PURE__ */ Object.assign(chipFn, {
7358
7358
  splitVariantProps(props) {
7359
7359
  return splitProps$1(props, chipVariantKeys);
7360
7360
  },
7361
- getVariantProps: getVariantProps$i
7361
+ getVariantProps: getVariantProps$j
7362
7362
  });
7363
7363
  const dateMenusDefaultVariants = {};
7364
7364
  const dateMenusCompoundVariants = [];
@@ -7381,7 +7381,7 @@ const dateMenusFn = memo((props = {}) => {
7381
7381
  return Object.fromEntries(dateMenusSlotFns.map(([slotName, slotFn]) => [slotName, slotFn.recipeFn(props)]));
7382
7382
  });
7383
7383
  const dateMenusVariantKeys = [];
7384
- const getVariantProps$h = (variants) => ({ ...dateMenusDefaultVariants, ...compact(variants) });
7384
+ const getVariantProps$i = (variants) => ({ ...dateMenusDefaultVariants, ...compact(variants) });
7385
7385
  const dateMenus = /* @__PURE__ */ Object.assign(dateMenusFn, {
7386
7386
  __recipe__: false,
7387
7387
  __name__: "dateMenus",
@@ -7392,7 +7392,7 @@ const dateMenus = /* @__PURE__ */ Object.assign(dateMenusFn, {
7392
7392
  splitVariantProps(props) {
7393
7393
  return splitProps$1(props, dateMenusVariantKeys);
7394
7394
  },
7395
- getVariantProps: getVariantProps$h
7395
+ getVariantProps: getVariantProps$i
7396
7396
  });
7397
7397
  const dateTimeMenusDefaultVariants = {};
7398
7398
  const dateTimeMenusCompoundVariants = [];
@@ -7415,7 +7415,7 @@ const dateTimeMenusFn = memo((props = {}) => {
7415
7415
  return Object.fromEntries(dateTimeMenusSlotFns.map(([slotName, slotFn]) => [slotName, slotFn.recipeFn(props)]));
7416
7416
  });
7417
7417
  const dateTimeMenusVariantKeys = [];
7418
- const getVariantProps$g = (variants) => ({ ...dateTimeMenusDefaultVariants, ...compact(variants) });
7418
+ const getVariantProps$h = (variants) => ({ ...dateTimeMenusDefaultVariants, ...compact(variants) });
7419
7419
  const dateTimeMenus = /* @__PURE__ */ Object.assign(dateTimeMenusFn, {
7420
7420
  __recipe__: false,
7421
7421
  __name__: "dateTimeMenus",
@@ -7426,7 +7426,7 @@ const dateTimeMenus = /* @__PURE__ */ Object.assign(dateTimeMenusFn, {
7426
7426
  splitVariantProps(props) {
7427
7427
  return splitProps$1(props, dateTimeMenusVariantKeys);
7428
7428
  },
7429
- getVariantProps: getVariantProps$g
7429
+ getVariantProps: getVariantProps$h
7430
7430
  });
7431
7431
  const formFieldDefaultVariants = {
7432
7432
  "layout": "default",
@@ -7455,7 +7455,7 @@ const formFieldVariantKeys = [
7455
7455
  "layout",
7456
7456
  "size"
7457
7457
  ];
7458
- const getVariantProps$f = (variants) => ({ ...formFieldDefaultVariants, ...compact(variants) });
7458
+ const getVariantProps$g = (variants) => ({ ...formFieldDefaultVariants, ...compact(variants) });
7459
7459
  const formField = /* @__PURE__ */ Object.assign(formFieldFn, {
7460
7460
  __recipe__: false,
7461
7461
  __name__: "formField",
@@ -7477,7 +7477,7 @@ const formField = /* @__PURE__ */ Object.assign(formFieldFn, {
7477
7477
  splitVariantProps(props) {
7478
7478
  return splitProps$1(props, formFieldVariantKeys);
7479
7479
  },
7480
- getVariantProps: getVariantProps$f
7480
+ getVariantProps: getVariantProps$g
7481
7481
  });
7482
7482
  const iconButtonDefaultVariants = {
7483
7483
  "variant": "standard",
@@ -7506,7 +7506,7 @@ const iconButtonVariantKeys = [
7506
7506
  "variant",
7507
7507
  "size"
7508
7508
  ];
7509
- const getVariantProps$e = (variants) => ({ ...iconButtonDefaultVariants, ...compact(variants) });
7509
+ const getVariantProps$f = (variants) => ({ ...iconButtonDefaultVariants, ...compact(variants) });
7510
7510
  const iconButton = /* @__PURE__ */ Object.assign(iconButtonFn, {
7511
7511
  __recipe__: false,
7512
7512
  __name__: "iconButton",
@@ -7533,7 +7533,7 @@ const iconButton = /* @__PURE__ */ Object.assign(iconButtonFn, {
7533
7533
  splitVariantProps(props) {
7534
7534
  return splitProps$1(props, iconButtonVariantKeys);
7535
7535
  },
7536
- getVariantProps: getVariantProps$e
7536
+ getVariantProps: getVariantProps$f
7537
7537
  });
7538
7538
  const kbdDefaultVariants = {
7539
7539
  "variant": "default"
@@ -7556,7 +7556,7 @@ const kbdFn = memo((props = {}) => {
7556
7556
  const kbdVariantKeys = [
7557
7557
  "variant"
7558
7558
  ];
7559
- const getVariantProps$d = (variants) => ({ ...kbdDefaultVariants, ...compact(variants) });
7559
+ const getVariantProps$e = (variants) => ({ ...kbdDefaultVariants, ...compact(variants) });
7560
7560
  const kbd = /* @__PURE__ */ Object.assign(kbdFn, {
7561
7561
  __recipe__: false,
7562
7562
  __name__: "kbd",
@@ -7572,7 +7572,7 @@ const kbd = /* @__PURE__ */ Object.assign(kbdFn, {
7572
7572
  splitVariantProps(props) {
7573
7573
  return splitProps$1(props, kbdVariantKeys);
7574
7574
  },
7575
- getVariantProps: getVariantProps$d
7575
+ getVariantProps: getVariantProps$e
7576
7576
  });
7577
7577
  const listItemGroupDefaultVariants = {
7578
7578
  "density": "compact"
@@ -7599,7 +7599,7 @@ const listItemGroupFn = memo((props = {}) => {
7599
7599
  const listItemGroupVariantKeys = [
7600
7600
  "density"
7601
7601
  ];
7602
- const getVariantProps$c = (variants) => ({ ...listItemGroupDefaultVariants, ...compact(variants) });
7602
+ const getVariantProps$d = (variants) => ({ ...listItemGroupDefaultVariants, ...compact(variants) });
7603
7603
  const listItemGroup = /* @__PURE__ */ Object.assign(listItemGroupFn, {
7604
7604
  __recipe__: false,
7605
7605
  __name__: "listItemGroup",
@@ -7616,7 +7616,7 @@ const listItemGroup = /* @__PURE__ */ Object.assign(listItemGroupFn, {
7616
7616
  splitVariantProps(props) {
7617
7617
  return splitProps$1(props, listItemGroupVariantKeys);
7618
7618
  },
7619
- getVariantProps: getVariantProps$c
7619
+ getVariantProps: getVariantProps$d
7620
7620
  });
7621
7621
  const listItemDefaultVariants = {
7622
7622
  "variant": "default",
@@ -7668,7 +7668,7 @@ const listItemVariantKeys = [
7668
7668
  "iconBefore",
7669
7669
  "iconAfter"
7670
7670
  ];
7671
- const getVariantProps$b = (variants) => ({ ...listItemDefaultVariants, ...compact(variants) });
7671
+ const getVariantProps$c = (variants) => ({ ...listItemDefaultVariants, ...compact(variants) });
7672
7672
  const listItem = /* @__PURE__ */ Object.assign(listItemFn, {
7673
7673
  __recipe__: false,
7674
7674
  __name__: "listItem",
@@ -7703,7 +7703,7 @@ const listItem = /* @__PURE__ */ Object.assign(listItemFn, {
7703
7703
  splitVariantProps(props) {
7704
7704
  return splitProps$1(props, listItemVariantKeys);
7705
7705
  },
7706
- getVariantProps: getVariantProps$b
7706
+ getVariantProps: getVariantProps$c
7707
7707
  });
7708
7708
  const menuDefaultVariants = {
7709
7709
  "density": "compact",
@@ -7749,7 +7749,7 @@ const menuVariantKeys = [
7749
7749
  "density",
7750
7750
  "panel"
7751
7751
  ];
7752
- const getVariantProps$a = (variants) => ({ ...menuDefaultVariants, ...compact(variants) });
7752
+ const getVariantProps$b = (variants) => ({ ...menuDefaultVariants, ...compact(variants) });
7753
7753
  const menu = /* @__PURE__ */ Object.assign(menuFn, {
7754
7754
  __recipe__: false,
7755
7755
  __name__: "menu",
@@ -7773,7 +7773,7 @@ const menu = /* @__PURE__ */ Object.assign(menuFn, {
7773
7773
  splitVariantProps(props) {
7774
7774
  return splitProps$1(props, menuVariantKeys);
7775
7775
  },
7776
- getVariantProps: getVariantProps$a
7776
+ getVariantProps: getVariantProps$b
7777
7777
  });
7778
7778
  const modalDefaultVariants = {
7779
7779
  "size": "md",
@@ -7822,7 +7822,7 @@ const modalVariantKeys = [
7822
7822
  "size",
7823
7823
  "position"
7824
7824
  ];
7825
- const getVariantProps$9 = (variants) => ({ ...modalDefaultVariants, ...compact(variants) });
7825
+ const getVariantProps$a = (variants) => ({ ...modalDefaultVariants, ...compact(variants) });
7826
7826
  const modal = /* @__PURE__ */ Object.assign(modalFn, {
7827
7827
  __recipe__: false,
7828
7828
  __name__: "modal",
@@ -7846,6 +7846,56 @@ const modal = /* @__PURE__ */ Object.assign(modalFn, {
7846
7846
  splitVariantProps(props) {
7847
7847
  return splitProps$1(props, modalVariantKeys);
7848
7848
  },
7849
+ getVariantProps: getVariantProps$a
7850
+ });
7851
+ const printPreviewDefaultVariants = {};
7852
+ const printPreviewCompoundVariants = [];
7853
+ const printPreviewSlotNames = [
7854
+ [
7855
+ "root",
7856
+ "printPreview__root"
7857
+ ],
7858
+ [
7859
+ "stack",
7860
+ "printPreview__stack"
7861
+ ],
7862
+ [
7863
+ "page",
7864
+ "printPreview__page"
7865
+ ],
7866
+ [
7867
+ "sheet",
7868
+ "printPreview__sheet"
7869
+ ],
7870
+ [
7871
+ "overlay",
7872
+ "printPreview__overlay"
7873
+ ],
7874
+ [
7875
+ "marginArea",
7876
+ "printPreview__marginArea"
7877
+ ],
7878
+ [
7879
+ "margins",
7880
+ "printPreview__margins"
7881
+ ]
7882
+ ];
7883
+ const printPreviewSlotFns = /* @__PURE__ */ printPreviewSlotNames.map(([slotName, slotKey]) => [slotName, createRecipe(slotKey, printPreviewDefaultVariants, getSlotCompoundVariant(printPreviewCompoundVariants, slotName))]);
7884
+ const printPreviewFn = memo((props = {}) => {
7885
+ return Object.fromEntries(printPreviewSlotFns.map(([slotName, slotFn]) => [slotName, slotFn.recipeFn(props)]));
7886
+ });
7887
+ const printPreviewVariantKeys = [];
7888
+ const getVariantProps$9 = (variants) => ({ ...printPreviewDefaultVariants, ...compact(variants) });
7889
+ const printPreview = /* @__PURE__ */ Object.assign(printPreviewFn, {
7890
+ __recipe__: false,
7891
+ __name__: "printPreview",
7892
+ raw: (props) => props,
7893
+ classNameMap: {},
7894
+ variantKeys: printPreviewVariantKeys,
7895
+ variantMap: {},
7896
+ splitVariantProps(props) {
7897
+ return splitProps$1(props, printPreviewVariantKeys);
7898
+ },
7849
7899
  getVariantProps: getVariantProps$9
7850
7900
  });
7851
7901
  const radioDefaultVariants = {};
@@ -22687,6 +22737,225 @@ const Modal = (props) => {
22687
22737
  }
22688
22738
  );
22689
22739
  };
22740
+ const PrintPreviewContext = createContext(null);
22741
+ const PrintPageContext = createContext(
22742
+ null
22743
+ );
22744
+ const CSS_PIXELS_PER_UNIT = {
22745
+ in: 96,
22746
+ mm: 96 / 25.4,
22747
+ pt: 96 / 72
22748
+ };
22749
+ const toCssPixels = (value, unit) => value * CSS_PIXELS_PER_UNIT[unit];
22750
+ const resolvePageBox = (size2, orientation, margins = 0) => {
22751
+ let width = toCssPixels(size2.width, size2.unit);
22752
+ let height = toCssPixels(size2.height, size2.unit);
22753
+ const isLandscape = width > height;
22754
+ if (orientation === "landscape" && !isLandscape || orientation === "portrait" && isLandscape) {
22755
+ [width, height] = [height, width];
22756
+ }
22757
+ const sides = typeof margins === "number" ? { top: margins, right: margins, bottom: margins, left: margins } : margins;
22758
+ return {
22759
+ width,
22760
+ height,
22761
+ margins: {
22762
+ top: toCssPixels(sides.top, size2.unit),
22763
+ right: toCssPixels(sides.right, size2.unit),
22764
+ bottom: toCssPixels(sides.bottom, size2.unit),
22765
+ left: toCssPixels(sides.left, size2.unit)
22766
+ }
22767
+ };
22768
+ };
22769
+ const computeScale = (fit, available, largestPage) => {
22770
+ if (typeof fit === "number") return fit;
22771
+ if (!available || !largestPage) return null;
22772
+ if (available.width <= 0 || largestPage.width <= 0) return null;
22773
+ const widthScale = available.width / largestPage.width;
22774
+ if (fit === "width") return widthScale;
22775
+ const heightScale = available.height / largestPage.height;
22776
+ return Math.min(widthScale, heightScale);
22777
+ };
22778
+ const PrintPage = (props) => {
22779
+ const {
22780
+ size: size2,
22781
+ orientation,
22782
+ margins,
22783
+ showMargins = false,
22784
+ overlay,
22785
+ children,
22786
+ style,
22787
+ ...rest
22788
+ } = props;
22789
+ const [className, otherProps] = splitProps(rest);
22790
+ const preview = useContext(PrintPreviewContext);
22791
+ const previewClasses = preview == null ? void 0 : preview.classes;
22792
+ const classes = useMemo(
22793
+ () => previewClasses ?? printPreview(),
22794
+ [previewClasses]
22795
+ );
22796
+ const id = useId$1();
22797
+ const { width, height, unit } = size2;
22798
+ const sides = typeof margins === "object" ? margins : {
22799
+ top: margins ?? 0,
22800
+ right: margins ?? 0,
22801
+ bottom: margins ?? 0,
22802
+ left: margins ?? 0
22803
+ };
22804
+ const { top, right, bottom, left } = sides;
22805
+ const pageBox = useMemo(
22806
+ () => resolvePageBox({ width, height, unit }, orientation, {
22807
+ top,
22808
+ right,
22809
+ bottom,
22810
+ left
22811
+ }),
22812
+ [width, height, unit, orientation, top, right, bottom, left]
22813
+ );
22814
+ const registerPage = preview == null ? void 0 : preview.registerPage;
22815
+ const unregisterPage = preview == null ? void 0 : preview.unregisterPage;
22816
+ useLayoutEffect(() => {
22817
+ if (!registerPage || !unregisterPage) return;
22818
+ registerPage(id, { width: pageBox.width, height: pageBox.height });
22819
+ return () => unregisterPage(id);
22820
+ }, [id, pageBox.width, pageBox.height, registerPage, unregisterPage]);
22821
+ const measuring = preview !== null && preview.scale === null;
22822
+ const scale = preview ? preview.scale ?? 1 : 1;
22823
+ const pageContext = useMemo(
22824
+ () => ({ ...pageBox, scale }),
22825
+ [pageBox, scale]
22826
+ );
22827
+ const pageStyle = {
22828
+ "--print-scale": scale,
22829
+ "--print-page-w": `${String(pageBox.width)}px`,
22830
+ "--print-page-h": `${String(pageBox.height)}px`,
22831
+ "--print-margin-top": `${String(pageBox.margins.top)}px`,
22832
+ "--print-margin-right": `${String(pageBox.margins.right)}px`,
22833
+ "--print-margin-bottom": `${String(pageBox.margins.bottom)}px`,
22834
+ "--print-margin-left": `${String(pageBox.margins.left)}px`,
22835
+ ...style
22836
+ };
22837
+ return /* @__PURE__ */ jsx(PrintPageContext.Provider, { value: pageContext, children: /* @__PURE__ */ jsxs(
22838
+ Box,
22839
+ {
22840
+ ...dsComponent("PrintPage"),
22841
+ className: cx(classes.page, className),
22842
+ "data-measuring": measuring || void 0,
22843
+ style: pageStyle,
22844
+ ...otherProps,
22845
+ children: [
22846
+ /* @__PURE__ */ jsxs(Box, { className: classes.sheet, children: [
22847
+ children,
22848
+ overlay !== void 0 && /* @__PURE__ */ jsx(Box, { className: classes.overlay, children: overlay })
22849
+ ] }),
22850
+ showMargins && /* @__PURE__ */ jsxs(Fragment, { children: [
22851
+ /* @__PURE__ */ jsx(Box, { className: classes.marginArea, "aria-hidden": true }),
22852
+ /* @__PURE__ */ jsx(Box, { className: classes.margins, "aria-hidden": true })
22853
+ ] })
22854
+ ]
22855
+ }
22856
+ ) });
22857
+ };
22858
+ const PrintPreview = (props) => {
22859
+ const { fit = "page", children, ref, ...rest } = props;
22860
+ const [className, otherProps] = splitProps(rest);
22861
+ const classes = useMemo(() => printPreview(), []);
22862
+ const rootRef = useRef(null);
22863
+ const [available, setAvailable] = useState(null);
22864
+ const [pages, setPages] = useState(() => /* @__PURE__ */ new Map());
22865
+ const setRootRef = useCallback(
22866
+ (node) => {
22867
+ rootRef.current = node;
22868
+ if (typeof ref === "function") ref(node);
22869
+ else if (ref) ref.current = node;
22870
+ },
22871
+ [ref]
22872
+ );
22873
+ useLayoutEffect(() => {
22874
+ const node = rootRef.current;
22875
+ if (!node) return;
22876
+ const measure = () => {
22877
+ const style = getComputedStyle(node);
22878
+ const width = node.clientWidth - parseFloat(style.paddingLeft) - parseFloat(style.paddingRight);
22879
+ const height = node.clientHeight - parseFloat(style.paddingTop) - parseFloat(style.paddingBottom);
22880
+ setAvailable(
22881
+ (current) => (current == null ? void 0 : current.width) === width && current.height === height ? current : { width, height }
22882
+ );
22883
+ };
22884
+ measure();
22885
+ const observer = new ResizeObserver(measure);
22886
+ observer.observe(node);
22887
+ return () => observer.disconnect();
22888
+ }, []);
22889
+ const registerPage = useCallback((id, size2) => {
22890
+ setPages((current) => {
22891
+ const existing = current.get(id);
22892
+ if ((existing == null ? void 0 : existing.width) === size2.width && existing.height === size2.height) {
22893
+ return current;
22894
+ }
22895
+ const next = new Map(current);
22896
+ next.set(id, size2);
22897
+ return next;
22898
+ });
22899
+ }, []);
22900
+ const unregisterPage = useCallback((id) => {
22901
+ setPages((current) => {
22902
+ if (!current.has(id)) return current;
22903
+ const next = new Map(current);
22904
+ next.delete(id);
22905
+ return next;
22906
+ });
22907
+ }, []);
22908
+ const largestPage = useMemo(() => {
22909
+ if (pages.size === 0) return null;
22910
+ let width = 0;
22911
+ let height = 0;
22912
+ pages.forEach((size2) => {
22913
+ width = Math.max(width, size2.width);
22914
+ height = Math.max(height, size2.height);
22915
+ });
22916
+ return { width, height };
22917
+ }, [pages]);
22918
+ const scale = computeScale(fit, available, largestPage);
22919
+ const contextValue = useMemo(
22920
+ () => ({ scale, registerPage, unregisterPage, classes }),
22921
+ [scale, registerPage, unregisterPage, classes]
22922
+ );
22923
+ return /* @__PURE__ */ jsx(PrintPreviewContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(
22924
+ Box,
22925
+ {
22926
+ ...dsComponent("PrintPreview"),
22927
+ ref: setRootRef,
22928
+ tabIndex: 0,
22929
+ className: cx(classes.root, className),
22930
+ ...otherProps,
22931
+ children: /* @__PURE__ */ jsx(Box, { className: classes.stack, children })
22932
+ }
22933
+ ) });
22934
+ };
22935
+ const pageSizes = {
22936
+ letter: { width: 8.5, height: 11, unit: "in" },
22937
+ legal: { width: 8.5, height: 14, unit: "in" },
22938
+ tabloid: { width: 11, height: 17, unit: "in" },
22939
+ halfLetter: { width: 5.5, height: 8.5, unit: "in" },
22940
+ a3: { width: 297, height: 420, unit: "mm" },
22941
+ a4: { width: 210, height: 297, unit: "mm" },
22942
+ a5: { width: 148, height: 210, unit: "mm" },
22943
+ a6: { width: 105, height: 148, unit: "mm" },
22944
+ postcard: { width: 4, height: 6, unit: "in" },
22945
+ card5x7: { width: 5, height: 7, unit: "in" },
22946
+ label4x6: { width: 4, height: 6, unit: "in" },
22947
+ label4x3: { width: 4, height: 3, unit: "in" },
22948
+ label4x2: { width: 4, height: 2, unit: "in" },
22949
+ label3x2: { width: 3, height: 2, unit: "in" },
22950
+ label2x1: { width: 2, height: 1, unit: "in" }
22951
+ };
22952
+ const usePrintPage = () => {
22953
+ const context2 = useContext(PrintPageContext);
22954
+ if (!context2) {
22955
+ throw new Error("usePrintPage must be used within a <PrintPage>");
22956
+ }
22957
+ return context2;
22958
+ };
22690
22959
  const Radio = (props) => {
22691
22960
  const fieldContext = useFieldContext();
22692
22961
  const {
@@ -26060,6 +26329,8 @@ export {
26060
26329
  ModalWrapper,
26061
26330
  Option,
26062
26331
  Pre,
26332
+ PrintPage,
26333
+ PrintPreview,
26063
26334
  Radio,
26064
26335
  RadioGroup,
26065
26336
  RadioInput,
@@ -26093,6 +26364,7 @@ export {
26093
26364
  hasMatchingItems,
26094
26365
  isItemMatch,
26095
26366
  o as okshaunPreset,
26367
+ pageSizes,
26096
26368
  splitProps,
26097
26369
  useChipGroup,
26098
26370
  useContainerQuery,
@@ -26106,6 +26378,7 @@ export {
26106
26378
  useMenuFilterContext,
26107
26379
  useMenuListContext,
26108
26380
  useModalWrapperContext,
26381
+ usePrintPage,
26109
26382
  useSelectContext,
26110
26383
  useTheme
26111
26384
  };