@react-pdf-kit/viewer 2.0.0-rc.1 → 2.0.1-beta.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.
@@ -1,25 +1,25 @@
1
- import { jsx as o, Fragment as at, jsxs as C } from "react/jsx-runtime";
2
- import { UIButton as ct } from "../../ui/Button.js";
1
+ import { jsx as o, Fragment as pt, jsxs as x } from "react/jsx-runtime";
2
+ import { UIButton as mt } from "../../ui/Button.js";
3
3
  import { SearchIcon as A } from "../../icons/SearchIcon.js";
4
- import { useState as b, useCallback as i, useEffect as l, useMemo as W } from "react";
5
- import { useLayoutContainer as pt } from "../../../contexts/LayoutContainerContext.js";
4
+ import { useState as S, useCallback as i, useEffect as h, useMemo as W } from "react";
5
+ import { useLayoutContainer as st } from "../../../contexts/LayoutContainerContext.js";
6
6
  import { c as n } from "../../../SearchTool.module-99f60dc7.js";
7
- import { UIInput as mt } from "../../ui/Input.js";
7
+ import { UIInput as lt } from "../../ui/Input.js";
8
8
  import { UICheckbox as $ } from "../../ui/Checkbox.js";
9
9
  import { ClearIcon as ht } from "../../icons/ClearIcon.js";
10
- import { LoaderIcon as lt } from "../../icons/LoaderIcon.js";
11
- import { useSearchContext as st } from "../../../contexts/SearchContext.js";
12
- import { useIconContext as dt } from "../../../contexts/IconContext.js";
13
- import { useDocumentContext as ut } from "../../../contexts/RPDocumentContext.js";
14
- import E from "../../ui/RPTooltip.js";
15
- import { useToolbarComponentContext as ft } from "../../../contexts/ToolbarComponentContext.js";
16
- import { useLocalizationContext as It } from "../../../contexts/LocalizationContext.js";
10
+ import { LoaderIcon as dt } from "../../icons/LoaderIcon.js";
11
+ import { useSearchContext as ut } from "../../../contexts/SearchContext.js";
12
+ import { useIconContext as F } from "../../../contexts/IconContext.js";
13
+ import { useDocumentContext as ft } from "../../../contexts/RPDocumentContext.js";
14
+ import v from "../../ui/RPTooltip.js";
15
+ import { useToolbarComponentContext as It } from "../../../contexts/ToolbarComponentContext.js";
16
+ import { useLocalizationContext as Ct } from "../../../contexts/LocalizationContext.js";
17
17
  import { InfoIcon as j } from "../../icons/InfoIcon.js";
18
- import { useViewportContext as Ct } from "../../../contexts/ViewportContext.js";
18
+ import { useViewportContext as bt } from "../../../contexts/ViewportContext.js";
19
19
  import { SearchResultNavigator as q } from "./SearchResultNavigator.js";
20
20
  import { SearchCloseButton as z } from "./SearchCloseButton.js";
21
- import { UIDropDown as bt } from "../../ui/DropDown.js";
22
- import { useIconToolContext as xt } from "../../../contexts/IconToolContext.js";
21
+ import { UIDropDown as xt } from "../../ui/DropDown.js";
22
+ import { useIconToolContext as H } from "../../../contexts/IconToolContext.js";
23
23
  import { useToolComponentContext as St } from "../../../contexts/ToolComponentContext.js";
24
24
  import "../../../clsx-0c6e471a.js";
25
25
  import "../../../utils/withRef.js";
@@ -69,78 +69,81 @@ import "../../icons/CloseIcon.js";
69
69
  import "../../../index-61f59539.js";
70
70
  import "../../../Combination-136ff99c.js";
71
71
  const yt = () => {
72
- const { searchIcon: x } = dt(), { searchIcon: v } = xt();
73
- return x || v || /* @__PURE__ */ o(A, {});
74
- }, jo = ({ icon: x }) => {
75
- const { container: v } = pt(), [s, L] = b(!1), { pdf: S } = ut(), [k, F] = b(null), {
72
+ const { searchIcon: s } = F(), { searchIcon: d } = H();
73
+ return s ?? d ?? /* @__PURE__ */ o(A, {});
74
+ }, Tt = () => {
75
+ const { searchClearIcon: s } = F(), { searchClearIcon: d } = H();
76
+ return s ?? d ?? /* @__PURE__ */ o(ht, {});
77
+ }, qo = ({ icon: s }) => {
78
+ const { container: d } = st(), [u, L] = S(!1), { pdf: y } = ft(), [k, G] = S(null), {
76
79
  searchOptions: D,
77
- setSearchOptions: y,
78
- loading: H,
80
+ setSearchOptions: T,
81
+ loading: J,
79
82
  setSearch: c,
80
83
  totalMatches: K,
81
84
  currentMatchPosition: B,
82
85
  nextMatch: O,
83
86
  prevMatch: P,
84
87
  search: e
85
- } = st(), { searchTool: G = !0 } = ft(), { searchTool: J = !0 } = St(), [d, u] = b(e), { localeMessages: t } = It(), { isSmallScreen: f } = Ct(), [T, Q] = b(null), [X, Y] = b(!1), Z = i(() => {
88
+ } = ut(), { searchTool: Q = !0 } = It(), { searchTool: X = !0 } = St(), [f, I] = S(e), { localeMessages: t } = Ct(), { isSmallScreen: C } = bt(), [E, Y] = S(null), [Z, _] = S(!1), g = i(() => {
86
89
  L(!0);
87
- }, []), h = i(() => {
88
- c(""), u(""), L(!1);
90
+ }, []), l = i(() => {
91
+ c(""), I(""), L(!1);
89
92
  }, [c]), R = (r) => {
90
- const a = r.key === "Enter", I = r.key === " ";
91
- (a || I) && h();
93
+ const a = r.key === "Enter", b = r.key === " ";
94
+ (a || b) && l();
92
95
  }, w = i(
93
96
  (r) => {
94
- r.key === "Escape" && s && h();
97
+ r.key === "Escape" && u && l();
95
98
  },
96
- [s]
97
- ), _ = i(
99
+ [u]
100
+ ), M = i(
98
101
  (r) => {
99
- r.shiftKey && r.key === "Enter" ? P() : r.key === "Enter" && e !== d ? c(d) : r.key === "Enter" && O();
102
+ r.shiftKey && r.key === "Enter" ? P() : r.key === "Enter" && e !== f ? c(f) : r.key === "Enter" && O();
100
103
  },
101
- [d, P, O, c, e]
104
+ [f, P, O, c, e]
102
105
  );
103
- l(() => {
104
- u(e);
105
- }, [e]), l(() => {
106
- e && S && Y(!0);
107
- }, [e, S]), l(() => {
108
- e && e.trim() !== "" && (u(e), c(e));
109
- }, []), l(() => (window.addEventListener("keydown", w), () => {
106
+ h(() => {
107
+ I(e);
108
+ }, [e]), h(() => {
109
+ e && y && _(!0);
110
+ }, [e, y]), h(() => {
111
+ e && e.trim() !== "" && (I(e), c(e));
112
+ }, []), h(() => (window.addEventListener("keydown", w), () => {
110
113
  window.removeEventListener("keydown", w);
111
- }), [w]), l(() => {
114
+ }), [w]), h(() => {
112
115
  k && setTimeout(() => {
113
116
  k.focus();
114
117
  }, 0);
115
118
  }, [k]);
116
- const g = i((r) => {
117
- u(r.target.value);
119
+ const tt = i((r) => {
120
+ I(r.target.value);
118
121
  }, []), U = i(() => {
119
- u(""), c("");
120
- }, [c]), M = W(() => `${B} / ${K}`, [B, K]), { wholeWords: tt, matchCase: ot } = W(() => D, [D]), rt = i(
122
+ I(""), c("");
123
+ }, [c]), ot = W(() => `${B} / ${K}`, [B, K]), { wholeWords: rt, matchCase: et } = W(() => D, [D]), nt = i(
121
124
  (r) => {
122
- y((a) => ({ ...a, matchCase: r }));
125
+ T((a) => ({ ...a, matchCase: r }));
123
126
  },
124
- [y]
125
- ), et = i(
127
+ [T]
128
+ ), it = i(
126
129
  (r) => {
127
- y((a) => ({ ...a, wholeWords: r }));
130
+ T((a) => ({ ...a, wholeWords: r }));
128
131
  },
129
- [y]
132
+ [T]
130
133
  );
131
- l(() => {
132
- S && X && h();
133
- }, [S, h]);
134
- const p = W(() => (T == null ? void 0 : T.querySelectorAll('[tabindex]:not([tabindex="-1"])')) || [], [T]), nt = i(
134
+ h(() => {
135
+ y && Z && l();
136
+ }, [y, l]);
137
+ const p = W(() => (E == null ? void 0 : E.querySelectorAll('[tabindex]:not([tabindex="-1"])')) || [], [E]), at = i(
135
138
  (r) => {
136
139
  if (r.key === "Tab") {
137
140
  const a = document.activeElement;
138
- let I = 0;
139
- p.forEach((m, it) => {
140
- m === a && (I = it);
141
+ let b = 0;
142
+ p.forEach((m, ct) => {
143
+ m === a && (b = ct);
141
144
  });
142
- let N = I + 1;
143
- r.shiftKey && (N = I - 1);
145
+ let N = b + 1;
146
+ r.shiftKey && (N = b - 1);
144
147
  const V = p[N];
145
148
  if (V)
146
149
  V.focus();
@@ -155,54 +158,54 @@ const yt = () => {
155
158
  },
156
159
  [p]
157
160
  );
158
- return !G || !J ? null : /* @__PURE__ */ o(at, { children: /* @__PURE__ */ o(
159
- bt,
161
+ return !Q || !X ? null : /* @__PURE__ */ o(pt, { children: /* @__PURE__ */ o(
162
+ xt,
160
163
  {
161
- open: s,
162
- container: v,
164
+ open: u,
165
+ container: d,
163
166
  side: "bottom",
164
167
  align: "start",
165
168
  tabIndex: 0,
166
169
  avoidCollisions: !1,
167
- triggerComponent: /* @__PURE__ */ o(E, { content: t == null ? void 0 : t.searchButtonTooltip, children: /* @__PURE__ */ o(
168
- ct,
170
+ triggerComponent: /* @__PURE__ */ o(v, { content: t == null ? void 0 : t.searchButtonTooltip, children: /* @__PURE__ */ o(
171
+ mt,
169
172
  {
170
- active: s,
171
- onClick: Z,
173
+ active: u,
174
+ onClick: g,
172
175
  "aria-label": t == null ? void 0 : t.searchButtonTooltip,
173
- "aria-expanded": s,
176
+ "aria-expanded": u,
174
177
  "aria-haspopup": "dialog",
175
- children: x || /* @__PURE__ */ o(yt, {})
178
+ children: s || /* @__PURE__ */ o(yt, {})
176
179
  }
177
180
  ) }),
178
- children: /* @__PURE__ */ C(
181
+ children: /* @__PURE__ */ x(
179
182
  "div",
180
183
  {
181
- ref: Q,
184
+ ref: Y,
182
185
  className: n["rp-search-tool-content"],
183
186
  tabIndex: 0,
184
- onKeyDown: nt,
187
+ onKeyDown: at,
185
188
  role: "dialog",
186
189
  "aria-label": (t == null ? void 0 : t.searchInputTooltip) || "Search dialog",
187
190
  children: [
188
- /* @__PURE__ */ C("div", { className: n["rp-search-tool-input-wrapper"], children: [
189
- /* @__PURE__ */ C("div", { className: n["rp-search-tool-input"], children: [
190
- /* @__PURE__ */ o(E, { content: t == null ? void 0 : t.searchInputTooltip, children: /* @__PURE__ */ o(
191
- mt,
191
+ /* @__PURE__ */ x("div", { className: n["rp-search-tool-input-wrapper"], children: [
192
+ /* @__PURE__ */ x("div", { className: n["rp-search-tool-input"], children: [
193
+ /* @__PURE__ */ o(v, { content: t == null ? void 0 : t.searchInputTooltip, children: /* @__PURE__ */ o(
194
+ lt,
192
195
  {
193
- value: d,
194
- onKeyDown: _,
195
- onChange: g,
196
+ value: f,
197
+ onKeyDown: M,
198
+ onChange: tt,
196
199
  icon: /* @__PURE__ */ o(A, {}),
197
200
  placeholder: t == null ? void 0 : t.searchInputPlaceholder,
198
201
  className: n["rp-search-input"],
199
- ref: F,
202
+ ref: G,
200
203
  id: "search-input",
201
204
  name: "search-input",
202
205
  tabIndex: 0,
203
206
  "aria-label": (t == null ? void 0 : t.searchInputTooltip) || (t == null ? void 0 : t.searchInputPlaceholder),
204
207
  "aria-describedby": "search-results-count",
205
- children: !!d && /* @__PURE__ */ o(
208
+ children: !!f && /* @__PURE__ */ o(
206
209
  "span",
207
210
  {
208
211
  className: n["rp-search-tool-input-clear"],
@@ -213,45 +216,45 @@ const yt = () => {
213
216
  onKeyDown: (r) => {
214
217
  (r.key === "Enter" || r.key === " ") && (r.preventDefault(), U());
215
218
  },
216
- children: /* @__PURE__ */ o(ht, {})
219
+ children: /* @__PURE__ */ o(Tt, {})
217
220
  }
218
221
  )
219
222
  }
220
223
  ) }),
221
- H ? /* @__PURE__ */ o("span", { "aria-live": "polite", "aria-label": "Searching", children: /* @__PURE__ */ o(lt, { className: n["rp-search-loader-icon"], "aria-hidden": "true" }) }) : /* @__PURE__ */ o("span", { id: "search-results-count", "aria-live": "polite", children: M }),
222
- f && /* @__PURE__ */ o("div", { className: n["rp-search-tool-controls"], children: /* @__PURE__ */ o(z, { onKeyPress: R, handleClose: h }) })
224
+ J ? /* @__PURE__ */ o("span", { "aria-live": "polite", "aria-label": "Searching", children: /* @__PURE__ */ o(dt, { className: n["rp-search-loader-icon"], "aria-hidden": "true" }) }) : /* @__PURE__ */ o("span", { id: "search-results-count", "aria-live": "polite", children: ot }),
225
+ C && /* @__PURE__ */ o("div", { className: n["rp-search-tool-controls"], children: /* @__PURE__ */ o(z, { onKeyPress: R, handleClose: l }) })
223
226
  ] }),
224
- /* @__PURE__ */ C("div", { className: n["rp-search-tool-input-checkboxes"], children: [
225
- f && /* @__PURE__ */ o(q, {}),
227
+ /* @__PURE__ */ x("div", { className: n["rp-search-tool-input-checkboxes"], children: [
228
+ C && /* @__PURE__ */ o(q, {}),
226
229
  /* @__PURE__ */ o(
227
230
  $,
228
231
  {
229
232
  tabIndex: 0,
230
233
  name: "matchCase",
231
- value: ot,
232
- onChange: rt,
234
+ value: et,
235
+ onChange: nt,
233
236
  "aria-label": t == null ? void 0 : t.searchMatchCaseLabel,
234
237
  children: t == null ? void 0 : t.searchMatchCaseLabel
235
238
  }
236
239
  ),
237
- !f && /* @__PURE__ */ o(E, { content: t == null ? void 0 : t.searchMatchCaseTooltip, children: /* @__PURE__ */ o("div", { className: n["rp-search-icon-info"], tabIndex: 0, children: /* @__PURE__ */ o(j, {}) }) }),
240
+ !C && /* @__PURE__ */ o(v, { content: t == null ? void 0 : t.searchMatchCaseTooltip, children: /* @__PURE__ */ o("div", { className: n["rp-search-icon-info"], tabIndex: 0, children: /* @__PURE__ */ o(j, {}) }) }),
238
241
  /* @__PURE__ */ o(
239
242
  $,
240
243
  {
241
244
  tabIndex: 0,
242
245
  name: "wholeWord",
243
- value: tt,
244
- onChange: et,
246
+ value: rt,
247
+ onChange: it,
245
248
  "aria-label": t == null ? void 0 : t.searchWholeWordsLabel,
246
249
  children: t == null ? void 0 : t.searchWholeWordsLabel
247
250
  }
248
251
  ),
249
- !f && /* @__PURE__ */ o(E, { content: t == null ? void 0 : t.searchWholeWordsTooltip, children: /* @__PURE__ */ o("div", { tabIndex: 0, className: n["rp-search-icon-info"], children: /* @__PURE__ */ o(j, {}) }) })
252
+ !C && /* @__PURE__ */ o(v, { content: t == null ? void 0 : t.searchWholeWordsTooltip, children: /* @__PURE__ */ o("div", { tabIndex: 0, className: n["rp-search-icon-info"], children: /* @__PURE__ */ o(j, {}) }) })
250
253
  ] })
251
254
  ] }),
252
- !f && /* @__PURE__ */ C("div", { className: n["rp-search-tool-controls"], children: [
255
+ !C && /* @__PURE__ */ x("div", { className: n["rp-search-tool-controls"], children: [
253
256
  /* @__PURE__ */ o(q, {}),
254
- /* @__PURE__ */ o(z, { onKeyPress: R, handleClose: h })
257
+ /* @__PURE__ */ o(z, { onKeyPress: R, handleClose: l })
255
258
  ] })
256
259
  ]
257
260
  }
@@ -260,5 +263,5 @@ const yt = () => {
260
263
  ) });
261
264
  };
262
265
  export {
263
- jo as SearchTool
266
+ qo as SearchTool
264
267
  };
@@ -1,13 +1,11 @@
1
- import { jsx as o } from "react/jsx-runtime";
2
- import { createContext as r, useContext as i } from "react";
3
- const t = r({
4
- instanceId: ""
5
- }), x = ({
1
+ import { jsx as r } from "react/jsx-runtime";
2
+ import { createContext as n, useContext as i } from "react";
3
+ const t = n({}), x = ({
6
4
  children: e,
7
- ...n
8
- }) => /* @__PURE__ */ o(t.Provider, { value: n, children: e }), c = () => i(t);
5
+ ...o
6
+ }) => /* @__PURE__ */ r(t.Provider, { value: o, children: e }), u = () => i(t);
9
7
  export {
10
8
  t as InitialStateContext,
11
9
  x as InitialStateProvider,
12
- c as useInitialStateContext
10
+ u as useInitialStateContext
13
11
  };
@@ -1 +1 @@
1
- export declare const useWatermark: (instanceId?: string) => void;
1
+ export declare const useWatermark: (container: HTMLDivElement | null) => void;
@@ -540,7 +540,6 @@ export interface ZoomContextType {
540
540
  }
541
541
  export type ZoomProps = Omit<ZoomContextType, 'currentZoom'>;
542
542
  export type InitialStateContextType = {
543
- instanceId: string;
544
543
  interactiveForm?: boolean;
545
544
  } & ZoomProviderProps & PageProviderProps & ViewModeInitialProps & ScrollModeInitialProps & RotateProviderProps;
546
545
  export interface ZoomProviderProps {
@@ -820,6 +819,7 @@ export interface RPHorizontalBarIcons {
820
819
  documentPropertiesIcon?: React.ReactNode;
821
820
  printIcon?: React.ReactNode;
822
821
  searchIcon?: React.ReactNode;
822
+ searchClearIcon?: React.ReactNode;
823
823
  textSelectionIcon?: React.ReactNode;
824
824
  handModeIcon?: React.ReactNode;
825
825
  }
@@ -1,6 +1,6 @@
1
1
  import { useState as E, useCallback as h, useEffect as A } from "react";
2
2
  import { appConsole as l } from "../appConsole.js";
3
- const b = /* @__PURE__ */ new Date("2026-02-20T02:47:06.577Z"), d = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", s = {
3
+ const b = /* @__PURE__ */ new Date("2026-02-25T08:16:21.019Z"), d = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", s = {
4
4
  invalidLicense: `You are currently using without a valid license. ${d}`,
5
5
  mismatchedDomain: `Your license key is not valid for the current domain / IP. ${d}`,
6
6
  expired: `Your license key has expired. ${d}`,