@pallasoft/ps-mobile-components 1.11.0 → 1.13.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.
Files changed (118) hide show
  1. package/dist/components/ps-action-sheet/ps-action-sheet.js +18 -2
  2. package/dist/components/ps-barcode-scanner-sheet/ps-barcode-scanner-sheet.js +2 -1
  3. package/dist/components/ps-document-highlight-layer/index.d.ts +2 -0
  4. package/dist/components/ps-document-highlight-layer/index.js +2 -0
  5. package/dist/components/ps-document-highlight-layer/ps-document-highlight-layer-props.d.ts +8 -0
  6. package/dist/components/ps-document-highlight-layer/ps-document-highlight-layer-props.js +1 -0
  7. package/dist/components/ps-document-highlight-layer/ps-document-highlight-layer.d.ts +2 -0
  8. package/dist/components/ps-document-highlight-layer/ps-document-highlight-layer.js +19 -0
  9. package/dist/components/ps-document-page/ps-document-page-props.d.ts +2 -0
  10. package/dist/components/ps-document-page/ps-document-page.d.ts +1 -1
  11. package/dist/components/ps-document-page/ps-document-page.js +3 -3
  12. package/dist/components/ps-document-search-bar/index.d.ts +2 -0
  13. package/dist/components/ps-document-search-bar/index.js +2 -0
  14. package/dist/components/ps-document-search-bar/ps-document-search-bar-props.d.ts +11 -0
  15. package/dist/components/ps-document-search-bar/ps-document-search-bar-props.js +1 -0
  16. package/dist/components/ps-document-search-bar/ps-document-search-bar.d.ts +2 -0
  17. package/dist/components/ps-document-search-bar/ps-document-search-bar.js +46 -0
  18. package/dist/components/ps-document-search-step/index.d.ts +2 -0
  19. package/dist/components/ps-document-search-step/index.js +2 -0
  20. package/dist/components/ps-document-search-step/ps-document-search-step-props.d.ts +7 -0
  21. package/dist/components/ps-document-search-step/ps-document-search-step-props.js +1 -0
  22. package/dist/components/ps-document-search-step/ps-document-search-step.d.ts +2 -0
  23. package/dist/components/ps-document-search-step/ps-document-search-step.js +30 -0
  24. package/dist/components/ps-document-text-page/ps-document-text-page-props.d.ts +2 -0
  25. package/dist/components/ps-document-text-page/ps-document-text-page.d.ts +1 -1
  26. package/dist/components/ps-document-text-page/ps-document-text-page.js +27 -3
  27. package/dist/components/ps-document-viewer/ps-document-viewer.js +53 -3
  28. package/dist/components/ps-document-zoom-image/ps-document-zoom-image-props.d.ts +4 -0
  29. package/dist/components/ps-document-zoom-image/ps-document-zoom-image.d.ts +1 -1
  30. package/dist/components/ps-document-zoom-image/ps-document-zoom-image.js +30 -3
  31. package/dist/components/ps-infinite-list/ps-infinite-list-props.d.ts +2 -0
  32. package/dist/components/ps-infinite-list/ps-infinite-list.d.ts +1 -1
  33. package/dist/components/ps-infinite-list/ps-infinite-list.js +12 -5
  34. package/dist/components/ps-list/ps-list-props.d.ts +2 -0
  35. package/dist/components/ps-list/ps-list.d.ts +1 -1
  36. package/dist/components/ps-list/ps-list.js +1 -1
  37. package/dist/components/ps-menu-popup/ps-menu-popup.js +3 -2
  38. package/dist/components/ps-screen/ps-screen-props.d.ts +2 -0
  39. package/dist/components/ps-screen/ps-screen.d.ts +1 -1
  40. package/dist/components/ps-screen/ps-screen.js +12 -5
  41. package/dist/components/ps-sheet-content/ps-sheet-content.js +4 -2
  42. package/dist/components/ps-sheet-presenter/ps-sheet-presenter.ios.js +15 -5
  43. package/dist/components/ps-sheet-presenter/ps-sheet-presenter.js +16 -3
  44. package/dist/components/ps-sortable-grid/ps-sortable-grid.js +4 -1
  45. package/dist/components/ps-text/ps-text-props.d.ts +1 -0
  46. package/dist/components/ps-text/ps-text.d.ts +1 -1
  47. package/dist/components/ps-text/ps-text.js +2 -2
  48. package/dist/components/ps-widget-list/ps-widget-grid.js +16 -7
  49. package/dist/components/ps-widget-list/ps-widget-list-props.d.ts +2 -0
  50. package/dist/components/ps-widget-list/ps-widget-list.d.ts +1 -1
  51. package/dist/components/ps-widget-list/ps-widget-list.js +12 -5
  52. package/dist/constants/ps-content-width.d.ts +6 -0
  53. package/dist/constants/ps-content-width.js +5 -0
  54. package/dist/constants/ps-document-search-config.d.ts +16 -0
  55. package/dist/constants/ps-document-search-config.js +16 -0
  56. package/dist/constants/ps-layout-class-config.d.ts +12 -0
  57. package/dist/constants/ps-layout-class-config.js +12 -0
  58. package/dist/constants/ps-layout-class.d.ts +5 -0
  59. package/dist/constants/ps-layout-class.js +4 -0
  60. package/dist/constants/ps-menu-popup-config.d.ts +1 -0
  61. package/dist/constants/ps-menu-popup-config.js +1 -0
  62. package/dist/constants/ps-orientation-config.d.ts +3 -0
  63. package/dist/constants/ps-orientation-config.js +3 -0
  64. package/dist/constants/ps-sheet-config.d.ts +1 -0
  65. package/dist/constants/ps-sheet-config.js +1 -0
  66. package/dist/constants/ps-sortable-grid-config.d.ts +2 -0
  67. package/dist/constants/ps-sortable-grid-config.js +2 -0
  68. package/dist/hooks/use-ps-document-search-texts.d.ts +2 -0
  69. package/dist/hooks/use-ps-document-search-texts.js +26 -0
  70. package/dist/hooks/use-ps-layout-class.d.ts +2 -0
  71. package/dist/hooks/use-ps-layout-class.js +6 -0
  72. package/dist/hooks/use-ps-menu-anchor.d.ts +1 -1
  73. package/dist/hooks/use-ps-menu-anchor.js +14 -2
  74. package/dist/index.d.ts +9 -0
  75. package/dist/index.js +9 -0
  76. package/dist/interfaces/ps-document-highlight-rect.d.ts +5 -0
  77. package/dist/interfaces/ps-document-highlight-rect.js +1 -0
  78. package/dist/interfaces/ps-document-item.d.ts +3 -0
  79. package/dist/interfaces/ps-document-labels.d.ts +7 -0
  80. package/dist/interfaces/ps-document-point.d.ts +4 -0
  81. package/dist/interfaces/ps-document-point.js +1 -0
  82. package/dist/interfaces/ps-document-search-labels.d.ts +9 -0
  83. package/dist/interfaces/ps-document-search-labels.js +1 -0
  84. package/dist/interfaces/ps-document-search-location.d.ts +4 -0
  85. package/dist/interfaces/ps-document-search-location.js +1 -0
  86. package/dist/interfaces/ps-document-search-match.d.ts +2 -0
  87. package/dist/interfaces/ps-document-search-match.js +1 -0
  88. package/dist/interfaces/ps-document-search-state.d.ts +4 -0
  89. package/dist/interfaces/ps-document-search-state.js +1 -0
  90. package/dist/interfaces/ps-document-text-box.d.ts +2 -0
  91. package/dist/interfaces/ps-document-text-box.js +1 -0
  92. package/dist/interfaces/ps-document-text-layer-word.d.ts +2 -0
  93. package/dist/interfaces/ps-document-text-layer-word.js +1 -0
  94. package/dist/interfaces/ps-document-text-layer.d.ts +2 -0
  95. package/dist/interfaces/ps-document-text-layer.js +1 -0
  96. package/dist/interfaces/ps-document-text-line.d.ts +4 -0
  97. package/dist/interfaces/ps-document-text-line.js +1 -0
  98. package/dist/interfaces/ps-document-text-segment.d.ts +2 -0
  99. package/dist/interfaces/ps-document-text-segment.js +1 -0
  100. package/dist/interfaces/ps-document-word-match.d.ts +3 -0
  101. package/dist/interfaces/ps-document-word-match.js +1 -0
  102. package/dist/interfaces/ps-menu-popup-insets.d.ts +2 -0
  103. package/dist/interfaces/ps-menu-popup-layout.d.ts +1 -0
  104. package/dist/services/ps-document-search-service.d.ts +36 -0
  105. package/dist/services/ps-document-search-service.js +114 -0
  106. package/dist/services/ps-document-search-style-service.d.ts +7 -0
  107. package/dist/services/ps-document-search-style-service.js +22 -0
  108. package/dist/services/ps-document-viewer-entry-service.js +1 -0
  109. package/dist/services/ps-document-zoom-service.d.ts +1 -0
  110. package/dist/services/ps-document-zoom-service.js +3 -0
  111. package/dist/services/ps-layout-service.d.ts +12 -0
  112. package/dist/services/ps-layout-service.js +41 -0
  113. package/dist/services/ps-menu-popup-service.js +8 -4
  114. package/dist/services/ps-sheet-service.d.ts +5 -2
  115. package/dist/services/ps-sheet-service.js +17 -4
  116. package/dist/services/ps-sortable-grid-service.d.ts +3 -2
  117. package/dist/services/ps-sortable-grid-service.js +26 -22
  118. package/package.json +2 -2
@@ -1,5 +1,5 @@
1
1
  import { type ElementRef, type RefObject } from 'react';
2
- import type { View } from 'react-native';
2
+ import { type View } from 'react-native';
3
3
  import type { PsMenuAnchor } from '../interfaces/ps-menu-anchor';
4
4
  export interface PsMenuAnchorResult {
5
5
  anchor: PsMenuAnchor | undefined;
@@ -1,12 +1,24 @@
1
- import { useRef, useState } from 'react';
1
+ import { useEffect, useRef, useState } from 'react';
2
+ import { useWindowDimensions } from 'react-native';
3
+ import { PsMenuPopupConfig } from '../constants/ps-menu-popup-config';
2
4
  export const usePsMenuAnchor = () => {
3
5
  const ref = useRef(null);
4
6
  const [anchor, setAnchor] = useState(undefined);
7
+ const { height, width } = useWindowDimensions();
8
+ const isOpen = anchor !== undefined;
9
+ useEffect(() => {
10
+ if (!isOpen)
11
+ return;
12
+ const timer = setTimeout(() => {
13
+ ref.current?.measureInWindow((x, y, anchorWidth, anchorHeight) => setAnchor({ height: anchorHeight, width: anchorWidth, x, y }));
14
+ }, PsMenuPopupConfig.remeasureMs);
15
+ return () => clearTimeout(timer);
16
+ }, [height, isOpen, width]);
5
17
  return {
6
18
  anchor,
7
19
  close: () => setAnchor(undefined),
8
20
  open: () => {
9
- ref.current?.measureInWindow((x, y, width, height) => setAnchor({ height, width, x, y }));
21
+ ref.current?.measureInWindow((x, y, anchorWidth, anchorHeight) => setAnchor({ height: anchorHeight, width: anchorWidth, x, y }));
10
22
  },
11
23
  ref,
12
24
  };
package/dist/index.d.ts CHANGED
@@ -77,7 +77,11 @@ export * from './interfaces/ps-device-file';
77
77
  export * from './interfaces/ps-document-item';
78
78
  export * from './interfaces/ps-document-labels';
79
79
  export * from './interfaces/ps-document-scanner-options';
80
+ export * from './interfaces/ps-document-search-labels';
80
81
  export * from './interfaces/ps-document-source';
82
+ export * from './interfaces/ps-document-text-box';
83
+ export * from './interfaces/ps-document-text-layer';
84
+ export * from './interfaces/ps-document-text-layer-word';
81
85
  export * from './interfaces/ps-file-upload-options';
82
86
  export * from './interfaces/use-ps-file-upload-result';
83
87
  export * from './interfaces/ps-tab-bar-context-data';
@@ -107,6 +111,7 @@ export { PsActionMenuService } from './services/ps-action-menu-service';
107
111
  export { PsSelectionService } from './services/ps-selection-service';
108
112
  export { PsSortableGridService } from './services/ps-sortable-grid-service';
109
113
  export { PsDocumentPagerService } from './services/ps-document-pager-service';
114
+ export { PsDocumentSearchService } from './services/ps-document-search-service';
110
115
  export { PsDocumentZoomService } from './services/ps-document-zoom-service';
111
116
  export { PsDocumentScannerService } from './services/ps-document-scanner-service';
112
117
  export { PsCapturePickerService } from './services/ps-capture-picker-service';
@@ -189,3 +194,7 @@ export * from './interfaces/ps-infinite-data-result';
189
194
  export * from './interfaces/ps-infinite-data-update';
190
195
  export * from './interfaces/ps-infinite-page';
191
196
  export { usePsDebouncedValue } from '@pallasoft/ps-utilities/react';
197
+ export * from './constants/ps-layout-class';
198
+ export * from './constants/ps-content-width';
199
+ export * from './hooks/use-ps-layout-class';
200
+ export { PsLayoutService } from './services/ps-layout-service';
package/dist/index.js CHANGED
@@ -76,7 +76,11 @@ export * from './interfaces/ps-device-file';
76
76
  export * from './interfaces/ps-document-item';
77
77
  export * from './interfaces/ps-document-labels';
78
78
  export * from './interfaces/ps-document-scanner-options';
79
+ export * from './interfaces/ps-document-search-labels';
79
80
  export * from './interfaces/ps-document-source';
81
+ export * from './interfaces/ps-document-text-box';
82
+ export * from './interfaces/ps-document-text-layer';
83
+ export * from './interfaces/ps-document-text-layer-word';
80
84
  export * from './interfaces/ps-file-upload-options';
81
85
  export * from './interfaces/use-ps-file-upload-result';
82
86
  export * from './interfaces/ps-tab-bar-context-data';
@@ -106,6 +110,7 @@ export { PsActionMenuService } from './services/ps-action-menu-service';
106
110
  export { PsSelectionService } from './services/ps-selection-service';
107
111
  export { PsSortableGridService } from './services/ps-sortable-grid-service';
108
112
  export { PsDocumentPagerService } from './services/ps-document-pager-service';
113
+ export { PsDocumentSearchService } from './services/ps-document-search-service';
109
114
  export { PsDocumentZoomService } from './services/ps-document-zoom-service';
110
115
  export { PsDocumentScannerService } from './services/ps-document-scanner-service';
111
116
  export { PsCapturePickerService } from './services/ps-capture-picker-service';
@@ -184,3 +189,7 @@ export * from './interfaces/ps-infinite-data-result';
184
189
  export * from './interfaces/ps-infinite-data-update';
185
190
  export * from './interfaces/ps-infinite-page';
186
191
  export { usePsDebouncedValue } from '@pallasoft/ps-utilities/react';
192
+ export * from './constants/ps-layout-class';
193
+ export * from './constants/ps-content-width';
194
+ export * from './hooks/use-ps-layout-class';
195
+ export { PsLayoutService } from './services/ps-layout-service';
@@ -0,0 +1,5 @@
1
+ import type { PsDocumentTextBox } from './ps-document-text-box';
2
+ export interface PsDocumentHighlightRect {
3
+ box: PsDocumentTextBox;
4
+ isActive: boolean;
5
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,9 +1,12 @@
1
1
  import type { PsDocumentKind } from '../constants/ps-document-kind';
2
2
  import type { PsDocumentSource } from './ps-document-source';
3
+ import type { PsDocumentTextLayer } from './ps-document-text-layer';
3
4
  export interface PsDocumentItem {
4
5
  id: string;
5
6
  kind: PsDocumentKind;
6
7
  name: string;
8
+ pageTextLayers?: PsDocumentTextLayer[];
7
9
  source: PsDocumentSource | null;
8
10
  text: string | null;
11
+ textLayer?: PsDocumentTextLayer;
9
12
  }
@@ -1,10 +1,17 @@
1
1
  export interface PsDocumentLabels {
2
2
  close: string;
3
+ closeSearch?: string;
3
4
  empty: string;
4
5
  error: string;
5
6
  expand: string;
6
7
  loadFailed: string;
8
+ matchCount?: string;
9
+ nextMatch?: string;
10
+ noMatches?: string;
7
11
  open?: string;
12
+ previousMatch?: string;
8
13
  retry: string;
14
+ search?: string;
15
+ searchPlaceholder?: string;
9
16
  unsupported: string;
10
17
  }
@@ -0,0 +1,4 @@
1
+ export interface PsDocumentPoint {
2
+ x: number;
3
+ y: number;
4
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ export interface PsDocumentSearchLabels {
2
+ closeSearch: string;
3
+ matchCount: string;
4
+ nextMatch: string;
5
+ noMatches: string;
6
+ previousMatch: string;
7
+ search: string;
8
+ searchPlaceholder: string;
9
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ export interface PsDocumentSearchLocation {
2
+ entryIndex: number;
3
+ localIndex: number;
4
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { TextMatch } from '@pallasoft/ps-utilities';
2
+ export type PsDocumentSearchMatch = TextMatch;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ export interface PsDocumentSearchState {
2
+ activeIndex: number;
3
+ query: string;
4
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { TextLayerBox } from '@pallasoft/ps-utilities';
2
+ export type PsDocumentTextBox = TextLayerBox;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { TextLayerWord } from '@pallasoft/ps-utilities';
2
+ export type PsDocumentTextLayerWord = TextLayerWord;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { TextLayer } from '@pallasoft/ps-utilities';
2
+ export type PsDocumentTextLayer = TextLayer;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ export interface PsDocumentTextLine {
2
+ text: string;
3
+ y: number;
4
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { TextSegment } from '@pallasoft/ps-utilities';
2
+ export type PsDocumentTextSegment = TextSegment;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ export interface PsDocumentWordMatch {
2
+ wordIndices: number[];
3
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,6 @@
1
1
  export interface PsMenuPopupInsets {
2
2
  bottom: number;
3
+ left: number;
4
+ right: number;
3
5
  top: number;
4
6
  }
@@ -2,6 +2,7 @@ export interface PsMenuPopupLayout {
2
2
  isBelow: boolean;
3
3
  left: number;
4
4
  maxHeight: number;
5
+ maxWidth: number;
5
6
  top: number;
6
7
  width: number | undefined;
7
8
  }
@@ -0,0 +1,36 @@
1
+ import type { PsDocumentHighlightRect } from '../interfaces/ps-document-highlight-rect';
2
+ import type { PsDocumentItem } from '../interfaces/ps-document-item';
3
+ import type { PsDocumentLabels } from '../interfaces/ps-document-labels';
4
+ import type { PsDocumentPoint } from '../interfaces/ps-document-point';
5
+ import type { PsDocumentSearchLabels } from '../interfaces/ps-document-search-labels';
6
+ import type { PsDocumentSearchLocation } from '../interfaces/ps-document-search-location';
7
+ import type { PsDocumentSearchMatch } from '../interfaces/ps-document-search-match';
8
+ import type { PsDocumentTextBox } from '../interfaces/ps-document-text-box';
9
+ import type { PsDocumentTextLayer } from '../interfaces/ps-document-text-layer';
10
+ import type { PsDocumentTextLine } from '../interfaces/ps-document-text-line';
11
+ import type { PsDocumentTextSegment } from '../interfaces/ps-document-text-segment';
12
+ import type { PsDocumentViewerEntry } from '../interfaces/ps-document-viewer-entry';
13
+ import type { PsDocumentWordMatch } from '../interfaces/ps-document-word-match';
14
+ import type { PsSize } from '../interfaces/ps-size';
15
+ export declare class PsDocumentSearchService {
16
+ static terms(query: string): string[];
17
+ static matches(text: string, query: string): PsDocumentSearchMatch[];
18
+ static segments(text: string, matches: PsDocumentSearchMatch[]): PsDocumentTextSegment[];
19
+ static wordMatches(layer: PsDocumentTextLayer, query: string): PsDocumentWordMatch[];
20
+ static fit(layer: PsDocumentTextLayer, container: PsSize): PsDocumentTextBox;
21
+ static rect(box: PsDocumentTextBox, layer: PsDocumentTextLayer, container: PsSize): PsDocumentTextBox;
22
+ static highlights(layer: PsDocumentTextLayer, query: string, container: PsSize, activeIndex: number): PsDocumentHighlightRect[];
23
+ static center(box: PsDocumentTextBox): PsDocumentPoint;
24
+ static scrollOffset(lines: PsDocumentTextLine[], start: number): number;
25
+ static entryMatchCount(entry: PsDocumentViewerEntry, texts: Record<string, string>, query: string): number;
26
+ static counts(entries: PsDocumentViewerEntry[], texts: Record<string, string>, query: string): number[];
27
+ static total(counts: number[]): number;
28
+ static locate(counts: number[], active: number): PsDocumentSearchLocation | null;
29
+ static activeFor(counts: number[], active: number, entryIndex: number): number;
30
+ static firstIndexOf(counts: number[], entryIndex: number): number;
31
+ static step(active: number, total: number, direction: 1 | -1): number;
32
+ static startIndex(counts: number[], entryIndex: number): number;
33
+ static countLabel(template: string, current: number, total: number): string;
34
+ static labels(labels: PsDocumentLabels): PsDocumentSearchLabels | null;
35
+ static isSearchable(items: PsDocumentItem[]): boolean;
36
+ }
@@ -0,0 +1,114 @@
1
+ import { Common } from '@pallasoft/ps-utilities';
2
+ import { PsDocumentKind } from '../constants/ps-document-kind';
3
+ import { PsDocumentSearchConfig } from '../constants/ps-document-search-config';
4
+ export class PsDocumentSearchService {
5
+ static terms(query) {
6
+ return Common.TextSearchService.terms(query);
7
+ }
8
+ static matches(text, query) {
9
+ return Common.TextSearchService.findTerms(text, query);
10
+ }
11
+ static segments(text, matches) {
12
+ return Common.TextSearchService.segments(text, matches);
13
+ }
14
+ static wordMatches(layer, query) {
15
+ return Common.TextLayerService.termMatches(layer, query).map((match) => ({
16
+ wordIndices: match.parts.map((part) => part.itemIndex),
17
+ }));
18
+ }
19
+ static fit(layer, container) {
20
+ return Common.TextLayerService.fit(layer, container);
21
+ }
22
+ static rect(box, layer, container) {
23
+ return Common.TextLayerService.rect(box, layer, container);
24
+ }
25
+ static highlights(layer, query, container, activeIndex) {
26
+ return Common.TextLayerService.wordRects(layer, Common.TextLayerService.termMatches(layer, query), container).map((rect) => ({ box: rect.box, isActive: rect.matchIndex === activeIndex }));
27
+ }
28
+ static center(box) {
29
+ return { x: box.left + box.width / 2, y: box.top + box.height / 2 };
30
+ }
31
+ static scrollOffset(lines, start) {
32
+ let cursor = 0;
33
+ for (const line of lines) {
34
+ cursor += line.text.length;
35
+ if (start < cursor)
36
+ return line.y;
37
+ }
38
+ const last = lines[lines.length - 1];
39
+ return last === undefined ? 0 : last.y;
40
+ }
41
+ static entryMatchCount(entry, texts, query) {
42
+ if (entry.item.kind === PsDocumentKind.Text) {
43
+ const text = entry.item.text === null ? texts[entry.item.id] : entry.item.text;
44
+ return text === undefined ? 0 : PsDocumentSearchService.matches(text, query).length;
45
+ }
46
+ const layer = entry.item.textLayer;
47
+ return layer === undefined ? 0 : PsDocumentSearchService.wordMatches(layer, query).length;
48
+ }
49
+ static counts(entries, texts, query) {
50
+ return entries.map((entry) => PsDocumentSearchService.entryMatchCount(entry, texts, query));
51
+ }
52
+ static total(counts) {
53
+ return counts.reduce((sum, count) => sum + count, 0);
54
+ }
55
+ static locate(counts, active) {
56
+ let remaining = active;
57
+ for (let entryIndex = 0; entryIndex < counts.length; entryIndex += 1) {
58
+ if (remaining < counts[entryIndex])
59
+ return { entryIndex, localIndex: remaining };
60
+ remaining -= counts[entryIndex];
61
+ }
62
+ return null;
63
+ }
64
+ static activeFor(counts, active, entryIndex) {
65
+ const location = PsDocumentSearchService.locate(counts, active);
66
+ return location !== null && location.entryIndex === entryIndex
67
+ ? location.localIndex
68
+ : PsDocumentSearchConfig.noActive;
69
+ }
70
+ static firstIndexOf(counts, entryIndex) {
71
+ return counts.slice(0, entryIndex).reduce((sum, count) => sum + count, 0);
72
+ }
73
+ static step(active, total, direction) {
74
+ if (total <= 0)
75
+ return PsDocumentSearchConfig.noActive;
76
+ return (active + direction + total) % total;
77
+ }
78
+ static startIndex(counts, entryIndex) {
79
+ const total = PsDocumentSearchService.total(counts);
80
+ if (total === 0)
81
+ return PsDocumentSearchConfig.noActive;
82
+ return counts[entryIndex] > 0 ? PsDocumentSearchService.firstIndexOf(counts, entryIndex) : 0;
83
+ }
84
+ static countLabel(template, current, total) {
85
+ return template
86
+ .replace(PsDocumentSearchConfig.currentToken, String(current))
87
+ .replace(PsDocumentSearchConfig.totalToken, String(total));
88
+ }
89
+ static labels(labels) {
90
+ const { closeSearch, matchCount, nextMatch, noMatches, previousMatch, search, searchPlaceholder, } = labels;
91
+ if (closeSearch === undefined ||
92
+ matchCount === undefined ||
93
+ nextMatch === undefined ||
94
+ noMatches === undefined ||
95
+ previousMatch === undefined ||
96
+ search === undefined ||
97
+ searchPlaceholder === undefined)
98
+ return null;
99
+ return {
100
+ closeSearch,
101
+ matchCount,
102
+ nextMatch,
103
+ noMatches,
104
+ previousMatch,
105
+ search,
106
+ searchPlaceholder,
107
+ };
108
+ }
109
+ static isSearchable(items) {
110
+ return items.some((item) => (item.kind === PsDocumentKind.Text && (item.text !== null || item.source !== null)) ||
111
+ item.textLayer !== undefined ||
112
+ (item.pageTextLayers !== undefined && item.pageTextLayers.length > 0));
113
+ }
114
+ }
@@ -0,0 +1,7 @@
1
+ import type { TextStyle, ViewStyle } from 'react-native';
2
+ import type { PsMobileTheme } from '../interfaces/ps-mobile-theme';
3
+ export declare class PsDocumentSearchStyleService {
4
+ static span(theme: PsMobileTheme, isActive: boolean): TextStyle;
5
+ static rect(theme: PsMobileTheme, isActive: boolean): ViewStyle;
6
+ static fieldRadius(isMaterial: boolean): number;
7
+ }
@@ -0,0 +1,22 @@
1
+ import { PsDocumentSearchConfig } from '../constants/ps-document-search-config';
2
+ import { PsMobileColorService } from './ps-mobile-color-service';
3
+ export class PsDocumentSearchStyleService {
4
+ static span(theme, isActive) {
5
+ return isActive
6
+ ? { backgroundColor: theme.primary, color: theme.primaryContrast }
7
+ : {
8
+ backgroundColor: PsMobileColorService.withAlpha(theme.primary, PsDocumentSearchConfig.highlightAlpha),
9
+ };
10
+ }
11
+ static rect(theme, isActive) {
12
+ return {
13
+ backgroundColor: PsMobileColorService.withAlpha(theme.primary, isActive ? PsDocumentSearchConfig.activeAlpha : PsDocumentSearchConfig.highlightAlpha),
14
+ borderRadius: PsDocumentSearchConfig.highlightRadius,
15
+ };
16
+ }
17
+ static fieldRadius(isMaterial) {
18
+ return isMaterial
19
+ ? PsDocumentSearchConfig.androidFieldRadius
20
+ : PsDocumentSearchConfig.iosFieldRadius;
21
+ }
22
+ }
@@ -63,6 +63,7 @@ export class PsDocumentViewerEntryService {
63
63
  name: item.name,
64
64
  source: { headers: {}, uri: page.uri },
65
65
  text: null,
66
+ textLayer: item.pageTextLayers === undefined ? undefined : item.pageTextLayers[index],
66
67
  },
67
68
  sourceId: item.id,
68
69
  status: PsDocumentLoadStatus.Ready,
@@ -1,5 +1,6 @@
1
1
  export declare class PsDocumentZoomService {
2
2
  static clampAxis(value: number, container: number, scale: number): number;
3
+ static centerOffset(point: number, container: number, scale: number): number;
3
4
  static clampScale(scale: number): number;
4
5
  static dragOffset(translationY: number): number;
5
6
  static focalOffset(tap: number, container: number, scale: number): number;
@@ -4,6 +4,9 @@ export class PsDocumentZoomService {
4
4
  const limit = (container * (scale - 1)) / 2;
5
5
  return Math.min(limit, Math.max(-limit, value));
6
6
  }
7
+ static centerOffset(point, container, scale) {
8
+ return PsDocumentZoomService.clampAxis((container / 2 - point) * scale, container, scale);
9
+ }
7
10
  static clampScale(scale) {
8
11
  return Math.min(PsDocumentConfig.maxZoom, Math.max(PsDocumentConfig.minZoom, scale));
9
12
  }
@@ -0,0 +1,12 @@
1
+ import type { ViewStyle } from 'react-native';
2
+ import { PsContentWidth } from '../constants/ps-content-width';
3
+ import { PsLayoutClass } from '../constants/ps-layout-class';
4
+ export declare class PsLayoutService {
5
+ static classOf(width: number, height: number): PsLayoutClass;
6
+ static maxWidth(layoutClass: PsLayoutClass, contentWidth: PsContentWidth): number | undefined;
7
+ static frame(layoutClass: PsLayoutClass, contentWidth: PsContentWidth): ViewStyle;
8
+ static gridUnits(layoutClass: PsLayoutClass): number;
9
+ static widgetBasis(layoutClass: PsLayoutClass): string;
10
+ static widgetWidth(containerWidth: number, layoutClass: PsLayoutClass, gap: number): number | undefined;
11
+ static menuMaxWidth(windowWidth: number, edgeMargin: number): number;
12
+ }
@@ -0,0 +1,41 @@
1
+ import { PsContentWidth } from '../constants/ps-content-width';
2
+ import { PsLayoutClass } from '../constants/ps-layout-class';
3
+ import { PsLayoutClassConfig } from '../constants/ps-layout-class-config';
4
+ export class PsLayoutService {
5
+ static classOf(width, height) {
6
+ return width >= PsLayoutClassConfig.regularMinWidth &&
7
+ height >= PsLayoutClassConfig.regularMinHeight
8
+ ? PsLayoutClass.regular
9
+ : PsLayoutClass.compact;
10
+ }
11
+ static maxWidth(layoutClass, contentWidth) {
12
+ if (layoutClass === PsLayoutClass.compact || contentWidth === PsContentWidth.full)
13
+ return undefined;
14
+ return contentWidth === PsContentWidth.wide
15
+ ? PsLayoutClassConfig.wideMaxWidth
16
+ : PsLayoutClassConfig.readableMaxWidth;
17
+ }
18
+ static frame(layoutClass, contentWidth) {
19
+ const maxWidth = PsLayoutService.maxWidth(layoutClass, contentWidth);
20
+ return maxWidth === undefined ? {} : { alignSelf: 'center', maxWidth, width: '100%' };
21
+ }
22
+ static gridUnits(layoutClass) {
23
+ return layoutClass === PsLayoutClass.regular
24
+ ? PsLayoutClassConfig.regularGridUnits
25
+ : PsLayoutClassConfig.compactGridUnits;
26
+ }
27
+ static widgetBasis(layoutClass) {
28
+ return layoutClass === PsLayoutClass.regular
29
+ ? PsLayoutClassConfig.regularWidgetBasis
30
+ : PsLayoutClassConfig.compactWidgetBasis;
31
+ }
32
+ static widgetWidth(containerWidth, layoutClass, gap) {
33
+ if (layoutClass === PsLayoutClass.compact || containerWidth <= 0)
34
+ return undefined;
35
+ const columns = PsLayoutService.gridUnits(layoutClass);
36
+ return Math.max((containerWidth - gap * (columns - 1)) / columns, 0);
37
+ }
38
+ static menuMaxWidth(windowWidth, edgeMargin) {
39
+ return Math.max(windowWidth - edgeMargin * 2, 0);
40
+ }
41
+ }
@@ -3,20 +3,24 @@ export class PsMenuPopupService {
3
3
  static layout(anchor, window, insets, contentHeight, contentWidth, isFullWidth) {
4
4
  const margin = PsMenuPopupConfig.edgeMargin;
5
5
  const gap = PsMenuPopupConfig.anchorGap;
6
- const width = isFullWidth ? anchor.width : undefined;
7
- const menuWidth = width === undefined ? contentWidth : width;
6
+ const minX = Math.max(margin, insets.left);
7
+ const maxX = window.width - Math.max(margin, insets.right);
8
+ const maxWidth = Math.max(maxX - minX, 0);
9
+ const width = isFullWidth ? Math.min(anchor.width, maxWidth) : undefined;
10
+ const menuWidth = Math.min(width === undefined ? contentWidth : width, maxWidth);
8
11
  const below = window.height - (anchor.y + anchor.height) - gap - Math.max(margin, insets.bottom);
9
12
  const above = anchor.y - gap - Math.max(margin, insets.top);
10
13
  const isBelow = contentHeight <= below || below >= above;
11
14
  const room = isBelow ? below : above;
12
15
  const height = Math.min(contentHeight, Math.max(room, 0));
13
16
  const top = isBelow ? anchor.y + anchor.height + gap : anchor.y - gap - height;
14
- const alignedRight = anchor.x + menuWidth > window.width - margin;
17
+ const alignedRight = anchor.x + menuWidth > maxX;
15
18
  const left = alignedRight ? anchor.x + anchor.width - menuWidth : anchor.x;
16
19
  return {
17
20
  isBelow,
18
- left: Math.max(margin, Math.min(left, window.width - margin - menuWidth)),
21
+ left: Math.max(minX, Math.min(left, maxX - menuWidth)),
19
22
  maxHeight: Math.max(room, 0),
23
+ maxWidth,
20
24
  top,
21
25
  width,
22
26
  };
@@ -1,11 +1,14 @@
1
1
  import type { ViewStyle } from 'react-native';
2
+ import { PsLayoutClass } from '../constants/ps-layout-class';
2
3
  import type { PsSheetAction } from '../interfaces/ps-sheet-action';
3
4
  import type { PsSheetLeadingKind } from '../interfaces/ps-sheet-leading-kind';
4
5
  export declare class PsSheetService {
5
- static maxHeight(windowHeight: number): number;
6
+ static maxHeight(windowHeight: number, layoutClass?: PsLayoutClass): number;
7
+ static fittedMaxWidth(windowWidth: number, layoutClass: PsLayoutClass): number | undefined;
8
+ static supportsFormSizing(iosVersion: string | number): boolean;
6
9
  static handlesInset(os: string): boolean;
7
10
  static bottomPadding(isFloating: boolean, bottomInset: number): number;
8
- static fittedHeight(headerHeight: number, bodyHeight: number, windowHeight: number): number;
11
+ static fittedHeight(headerHeight: number, bodyHeight: number, windowHeight: number, layoutClass?: PsLayoutClass): number;
9
12
  static raisedHeight(height: number, keyboardHeight: number, windowHeight: number, topInset: number): number;
10
13
  static closeAction(label: string | undefined, onPress: () => void): PsSheetAction | undefined;
11
14
  static isActionInactive(action: PsSheetAction): boolean;
@@ -1,8 +1,21 @@
1
+ import { PsLayoutClass } from '../constants/ps-layout-class';
2
+ import { PsLayoutClassConfig } from '../constants/ps-layout-class-config';
1
3
  import { PsLayoutConfig } from '../constants/ps-layout-config';
2
4
  import { PsSheetConfig } from '../constants/ps-sheet-config';
3
5
  export class PsSheetService {
4
- static maxHeight(windowHeight) {
5
- return Math.floor(windowHeight * PsSheetConfig.maxHeightFraction);
6
+ static maxHeight(windowHeight, layoutClass = PsLayoutClass.compact) {
7
+ return Math.floor(windowHeight *
8
+ (layoutClass === PsLayoutClass.regular
9
+ ? PsLayoutClassConfig.formSheetMaxHeightFraction
10
+ : PsSheetConfig.maxHeightFraction));
11
+ }
12
+ static fittedMaxWidth(windowWidth, layoutClass) {
13
+ return layoutClass === PsLayoutClass.regular
14
+ ? Math.min(PsLayoutClassConfig.formSheetWidth, windowWidth)
15
+ : undefined;
16
+ }
17
+ static supportsFormSizing(iosVersion) {
18
+ return Number.parseInt(String(iosVersion), 10) >= PsSheetConfig.formSizingMinIos;
6
19
  }
7
20
  static handlesInset(os) {
8
21
  return os === 'ios' || os === 'android';
@@ -10,8 +23,8 @@ export class PsSheetService {
10
23
  static bottomPadding(isFloating, bottomInset) {
11
24
  return PsLayoutConfig.sheetGutter + (isFloating ? 0 : bottomInset);
12
25
  }
13
- static fittedHeight(headerHeight, bodyHeight, windowHeight) {
14
- return Math.min(Math.ceil(headerHeight + bodyHeight), PsSheetService.maxHeight(windowHeight));
26
+ static fittedHeight(headerHeight, bodyHeight, windowHeight, layoutClass = PsLayoutClass.compact) {
27
+ return Math.min(Math.ceil(headerHeight + bodyHeight), PsSheetService.maxHeight(windowHeight, layoutClass));
15
28
  }
16
29
  static raisedHeight(height, keyboardHeight, windowHeight, topInset) {
17
30
  return Math.min(height + keyboardHeight, windowHeight - topInset);
@@ -8,8 +8,9 @@ export declare class PsSortableGridService {
8
8
  id: string;
9
9
  }>(items: T[]): string[];
10
10
  static isSameOrder(first: string[], second: string[]): boolean;
11
- static rows(spans: PsSortableGridSpan[]): number[][];
12
- static layout(spans: PsSortableGridSpan[], heights: number[], width: number): PsSortableRect[];
11
+ static units(span: PsSortableGridSpan): number;
12
+ static rows(spans: PsSortableGridSpan[], capacity?: number): number[][];
13
+ static layout(spans: PsSortableGridSpan[], heights: number[], width: number, capacity?: number): PsSortableRect[];
13
14
  static extras(rects: PsSortableRect[], heights: number[]): number[];
14
15
  static natural(total: number, extra: number): number;
15
16
  static contentHeight(rects: PsSortableRect[]): number;