@pallasoft/ps-mobile-components 1.10.2 → 1.12.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 (110) hide show
  1. package/dist/components/ps-cartesian-chart/ps-cartesian-chart-props.d.ts +1 -0
  2. package/dist/components/ps-cartesian-chart/ps-cartesian-chart.d.ts +1 -1
  3. package/dist/components/ps-cartesian-chart/ps-cartesian-chart.js +6 -5
  4. package/dist/components/ps-chart-frame/ps-chart-frame.js +5 -1
  5. package/dist/components/ps-document-highlight-layer/index.d.ts +2 -0
  6. package/dist/components/ps-document-highlight-layer/index.js +2 -0
  7. package/dist/components/ps-document-highlight-layer/ps-document-highlight-layer-props.d.ts +8 -0
  8. package/dist/components/ps-document-highlight-layer/ps-document-highlight-layer-props.js +1 -0
  9. package/dist/components/ps-document-highlight-layer/ps-document-highlight-layer.d.ts +2 -0
  10. package/dist/components/ps-document-highlight-layer/ps-document-highlight-layer.js +19 -0
  11. package/dist/components/ps-document-page/ps-document-page-props.d.ts +2 -0
  12. package/dist/components/ps-document-page/ps-document-page.d.ts +1 -1
  13. package/dist/components/ps-document-page/ps-document-page.js +3 -3
  14. package/dist/components/ps-document-search-bar/index.d.ts +2 -0
  15. package/dist/components/ps-document-search-bar/index.js +2 -0
  16. package/dist/components/ps-document-search-bar/ps-document-search-bar-props.d.ts +11 -0
  17. package/dist/components/ps-document-search-bar/ps-document-search-bar-props.js +1 -0
  18. package/dist/components/ps-document-search-bar/ps-document-search-bar.d.ts +2 -0
  19. package/dist/components/ps-document-search-bar/ps-document-search-bar.js +46 -0
  20. package/dist/components/ps-document-search-step/index.d.ts +2 -0
  21. package/dist/components/ps-document-search-step/index.js +2 -0
  22. package/dist/components/ps-document-search-step/ps-document-search-step-props.d.ts +7 -0
  23. package/dist/components/ps-document-search-step/ps-document-search-step-props.js +1 -0
  24. package/dist/components/ps-document-search-step/ps-document-search-step.d.ts +2 -0
  25. package/dist/components/ps-document-search-step/ps-document-search-step.js +30 -0
  26. package/dist/components/ps-document-text-page/ps-document-text-page-props.d.ts +2 -0
  27. package/dist/components/ps-document-text-page/ps-document-text-page.d.ts +1 -1
  28. package/dist/components/ps-document-text-page/ps-document-text-page.js +27 -3
  29. package/dist/components/ps-document-viewer/ps-document-viewer.js +51 -2
  30. package/dist/components/ps-document-zoom-image/ps-document-zoom-image-props.d.ts +4 -0
  31. package/dist/components/ps-document-zoom-image/ps-document-zoom-image.d.ts +1 -1
  32. package/dist/components/ps-document-zoom-image/ps-document-zoom-image.js +20 -3
  33. package/dist/components/ps-donut-chart/ps-donut-chart-props.d.ts +1 -0
  34. package/dist/components/ps-donut-chart/ps-donut-chart.d.ts +1 -1
  35. package/dist/components/ps-donut-chart/ps-donut-chart.js +2 -2
  36. package/dist/components/ps-menu-popup/ps-menu-popup.js +10 -8
  37. package/dist/components/ps-sheet-presenter/ps-sheet-presenter.ios.js +8 -1
  38. package/dist/components/ps-sparkline/ps-sparkline-props.d.ts +1 -0
  39. package/dist/components/ps-sparkline/ps-sparkline.d.ts +1 -1
  40. package/dist/components/ps-sparkline/ps-sparkline.js +2 -2
  41. package/dist/components/ps-text/ps-text-props.d.ts +1 -0
  42. package/dist/components/ps-text/ps-text.d.ts +1 -1
  43. package/dist/components/ps-text/ps-text.js +2 -2
  44. package/dist/components/ps-waterfall-chart/ps-waterfall-chart-props.d.ts +1 -0
  45. package/dist/components/ps-waterfall-chart/ps-waterfall-chart.d.ts +1 -1
  46. package/dist/components/ps-waterfall-chart/ps-waterfall-chart.js +6 -5
  47. package/dist/constants/ps-chart-config.d.ts +3 -0
  48. package/dist/constants/ps-chart-config.js +3 -0
  49. package/dist/constants/ps-document-search-config.d.ts +19 -0
  50. package/dist/constants/ps-document-search-config.js +19 -0
  51. package/dist/hooks/use-ps-chart-reveal.d.ts +1 -1
  52. package/dist/hooks/use-ps-chart-reveal.js +4 -2
  53. package/dist/hooks/use-ps-chart-scrub.js +17 -18
  54. package/dist/hooks/use-ps-document-search-texts.d.ts +2 -0
  55. package/dist/hooks/use-ps-document-search-texts.js +26 -0
  56. package/dist/hooks/use-ps-infinite-data.d.ts +1 -1
  57. package/dist/hooks/use-ps-infinite-data.js +23 -7
  58. package/dist/hooks/use-ps-keyboard-height.d.ts +1 -0
  59. package/dist/hooks/use-ps-keyboard-height.js +14 -0
  60. package/dist/index.d.ts +5 -0
  61. package/dist/index.js +5 -0
  62. package/dist/interfaces/ps-chart-scrub-result.d.ts +2 -2
  63. package/dist/interfaces/ps-document-highlight-rect.d.ts +5 -0
  64. package/dist/interfaces/ps-document-highlight-rect.js +1 -0
  65. package/dist/interfaces/ps-document-item.d.ts +3 -0
  66. package/dist/interfaces/ps-document-labels.d.ts +7 -0
  67. package/dist/interfaces/ps-document-normalized-text.d.ts +5 -0
  68. package/dist/interfaces/ps-document-normalized-text.js +1 -0
  69. package/dist/interfaces/ps-document-point.d.ts +4 -0
  70. package/dist/interfaces/ps-document-point.js +1 -0
  71. package/dist/interfaces/ps-document-search-labels.d.ts +9 -0
  72. package/dist/interfaces/ps-document-search-labels.js +1 -0
  73. package/dist/interfaces/ps-document-search-location.d.ts +4 -0
  74. package/dist/interfaces/ps-document-search-location.js +1 -0
  75. package/dist/interfaces/ps-document-search-match.d.ts +4 -0
  76. package/dist/interfaces/ps-document-search-match.js +1 -0
  77. package/dist/interfaces/ps-document-search-state.d.ts +4 -0
  78. package/dist/interfaces/ps-document-search-state.js +1 -0
  79. package/dist/interfaces/ps-document-text-box.d.ts +6 -0
  80. package/dist/interfaces/ps-document-text-box.js +1 -0
  81. package/dist/interfaces/ps-document-text-layer-word.d.ts +5 -0
  82. package/dist/interfaces/ps-document-text-layer-word.js +1 -0
  83. package/dist/interfaces/ps-document-text-layer.d.ts +6 -0
  84. package/dist/interfaces/ps-document-text-layer.js +1 -0
  85. package/dist/interfaces/ps-document-text-line.d.ts +4 -0
  86. package/dist/interfaces/ps-document-text-line.js +1 -0
  87. package/dist/interfaces/ps-document-text-segment.d.ts +4 -0
  88. package/dist/interfaces/ps-document-text-segment.js +1 -0
  89. package/dist/interfaces/ps-document-word-match.d.ts +3 -0
  90. package/dist/interfaces/ps-document-word-match.js +1 -0
  91. package/dist/interfaces/ps-infinite-data-options.d.ts +1 -0
  92. package/dist/interfaces/ps-infinite-data-result.d.ts +1 -0
  93. package/dist/interfaces/ps-menu-popup-insets.d.ts +4 -0
  94. package/dist/interfaces/ps-menu-popup-insets.js +1 -0
  95. package/dist/services/ps-chart-series-service.d.ts +0 -1
  96. package/dist/services/ps-chart-series-service.js +0 -3
  97. package/dist/services/ps-document-search-service.d.ts +40 -0
  98. package/dist/services/ps-document-search-service.js +201 -0
  99. package/dist/services/ps-document-search-style-service.d.ts +7 -0
  100. package/dist/services/ps-document-search-style-service.js +22 -0
  101. package/dist/services/ps-document-viewer-entry-service.js +1 -0
  102. package/dist/services/ps-document-zoom-service.d.ts +1 -0
  103. package/dist/services/ps-document-zoom-service.js +3 -0
  104. package/dist/services/ps-infinite-data-service.d.ts +1 -0
  105. package/dist/services/ps-infinite-data-service.js +3 -0
  106. package/dist/services/ps-menu-popup-service.d.ts +2 -1
  107. package/dist/services/ps-menu-popup-service.js +3 -3
  108. package/dist/services/ps-sheet-service.d.ts +1 -0
  109. package/dist/services/ps-sheet-service.js +3 -0
  110. package/package.json +1 -1
@@ -0,0 +1,4 @@
1
+ export interface PsDocumentSearchState {
2
+ activeIndex: number;
3
+ query: string;
4
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ export interface PsDocumentTextBox {
2
+ height: number;
3
+ left: number;
4
+ top: number;
5
+ width: number;
6
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { PsDocumentTextBox } from './ps-document-text-box';
2
+ export interface PsDocumentTextLayerWord {
3
+ box: PsDocumentTextBox;
4
+ text: string;
5
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { PsDocumentTextLayerWord } from './ps-document-text-layer-word';
2
+ export interface PsDocumentTextLayer {
3
+ height: number;
4
+ width: number;
5
+ words: PsDocumentTextLayerWord[];
6
+ }
@@ -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,4 @@
1
+ export interface PsDocumentTextSegment {
2
+ matchIndex: number | null;
3
+ text: string;
4
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ export interface PsDocumentWordMatch {
2
+ wordIndices: number[];
3
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -2,6 +2,7 @@ import type { PsInfinitePage } from './ps-infinite-page';
2
2
  export interface PsInfiniteDataOptions<T> {
3
3
  getKey: (item: T) => string;
4
4
  isEnabled?: boolean;
5
+ keepPreviousOnKeyChange?: boolean | ((previousKey: string, nextKey: string) => boolean);
5
6
  key: string;
6
7
  loadPage: (cursor: string | null) => Promise<PsInfinitePage<T>>;
7
8
  onSettled?: () => Promise<unknown>;
@@ -5,6 +5,7 @@ export interface PsInfiniteDataResult<T> {
5
5
  hasMore: boolean;
6
6
  isLoading: boolean;
7
7
  isLoadingMore: boolean;
8
+ isRefreshing: boolean;
8
9
  items: T[];
9
10
  loadMore: () => Promise<void>;
10
11
  refresh: () => Promise<void>;
@@ -0,0 +1,4 @@
1
+ export interface PsMenuPopupInsets {
2
+ bottom: number;
3
+ top: number;
4
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -7,5 +7,4 @@ export declare class PsChartSeriesService {
7
7
  static stackedValues(data: PsAreaChartDatum[], series: PsCartesianChartSeries[]): number[];
8
8
  static color({ count, explicit, index, theme }: PsChartPaletteInput): string;
9
9
  static isEmpty(data: PsAreaChartDatum[], series: PsCartesianChartSeries[]): boolean;
10
- static signature(kind: string, data: PsAreaChartDatum[], series: PsCartesianChartSeries[]): string;
11
10
  }
@@ -28,7 +28,4 @@ export class PsChartSeriesService {
28
28
  static isEmpty(data, series) {
29
29
  return PsChartSeriesService.values(data, series).every((value) => value === 0);
30
30
  }
31
- static signature(kind, data, series) {
32
- return `${kind}:${PsChartSeriesService.values(data, series).join(',')}`;
33
- }
34
31
  }
@@ -0,0 +1,40 @@
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 { PsDocumentNormalizedText } from '../interfaces/ps-document-normalized-text';
5
+ import type { PsDocumentPoint } from '../interfaces/ps-document-point';
6
+ import type { PsDocumentSearchLabels } from '../interfaces/ps-document-search-labels';
7
+ import type { PsDocumentSearchLocation } from '../interfaces/ps-document-search-location';
8
+ import type { PsDocumentSearchMatch } from '../interfaces/ps-document-search-match';
9
+ import type { PsDocumentTextBox } from '../interfaces/ps-document-text-box';
10
+ import type { PsDocumentTextLayer } from '../interfaces/ps-document-text-layer';
11
+ import type { PsDocumentTextLine } from '../interfaces/ps-document-text-line';
12
+ import type { PsDocumentTextSegment } from '../interfaces/ps-document-text-segment';
13
+ import type { PsDocumentViewerEntry } from '../interfaces/ps-document-viewer-entry';
14
+ import type { PsDocumentWordMatch } from '../interfaces/ps-document-word-match';
15
+ import type { PsSize } from '../interfaces/ps-size';
16
+ export declare class PsDocumentSearchService {
17
+ static normalize(text: string): PsDocumentNormalizedText;
18
+ static terms(query: string): string[];
19
+ static matches(text: string, query: string): PsDocumentSearchMatch[];
20
+ static segments(text: string, matches: PsDocumentSearchMatch[]): PsDocumentTextSegment[];
21
+ static joinedWords(layer: PsDocumentTextLayer): string;
22
+ static wordMatches(layer: PsDocumentTextLayer, query: string): PsDocumentWordMatch[];
23
+ static fit(layer: PsDocumentTextLayer, container: PsSize): PsDocumentTextBox;
24
+ static rect(box: PsDocumentTextBox, layer: PsDocumentTextLayer, container: PsSize): PsDocumentTextBox;
25
+ static highlights(layer: PsDocumentTextLayer, query: string, container: PsSize, activeIndex: number): PsDocumentHighlightRect[];
26
+ static center(box: PsDocumentTextBox): PsDocumentPoint;
27
+ static scrollOffset(lines: PsDocumentTextLine[], start: number): number;
28
+ static entryMatchCount(entry: PsDocumentViewerEntry, texts: Record<string, string>, query: string): number;
29
+ static counts(entries: PsDocumentViewerEntry[], texts: Record<string, string>, query: string): number[];
30
+ static total(counts: number[]): number;
31
+ static locate(counts: number[], active: number): PsDocumentSearchLocation | null;
32
+ static activeFor(counts: number[], active: number, entryIndex: number): number;
33
+ static firstIndexOf(counts: number[], entryIndex: number): number;
34
+ static step(active: number, total: number, direction: 1 | -1): number;
35
+ static startIndex(counts: number[], entryIndex: number): number;
36
+ static countLabel(template: string, current: number, total: number): string;
37
+ static labels(labels: PsDocumentLabels): PsDocumentSearchLabels | null;
38
+ static isSearchable(items: PsDocumentItem[]): boolean;
39
+ private static merge;
40
+ }
@@ -0,0 +1,201 @@
1
+ import { PsDocumentKind } from '../constants/ps-document-kind';
2
+ import { PsDocumentSearchConfig } from '../constants/ps-document-search-config';
3
+ export class PsDocumentSearchService {
4
+ static normalize(text) {
5
+ const starts = [];
6
+ const ends = [];
7
+ let value = '';
8
+ let offset = 0;
9
+ for (const character of Array.from(text)) {
10
+ const folded = character
11
+ .normalize('NFD')
12
+ .replace(PsDocumentSearchConfig.combiningMarkPattern, '')
13
+ .toLowerCase();
14
+ for (let position = 0; position < folded.length; position += 1) {
15
+ starts.push(offset);
16
+ ends.push(offset + character.length);
17
+ }
18
+ value += folded;
19
+ offset += character.length;
20
+ }
21
+ return { ends, starts, value };
22
+ }
23
+ static terms(query) {
24
+ return PsDocumentSearchService.normalize(query)
25
+ .value.split(PsDocumentSearchConfig.termSeparatorPattern)
26
+ .filter((term) => term !== '');
27
+ }
28
+ static matches(text, query) {
29
+ const terms = PsDocumentSearchService.terms(query);
30
+ if (terms.length === 0)
31
+ return [];
32
+ const normalized = PsDocumentSearchService.normalize(text);
33
+ const ranges = [];
34
+ for (const term of terms) {
35
+ let from = normalized.value.indexOf(term);
36
+ while (from >= 0) {
37
+ ranges.push({ end: from + term.length, start: from });
38
+ from = normalized.value.indexOf(term, from + term.length);
39
+ }
40
+ }
41
+ return PsDocumentSearchService.merge(ranges).map((range) => ({
42
+ end: normalized.ends[range.end - 1],
43
+ start: normalized.starts[range.start],
44
+ }));
45
+ }
46
+ static segments(text, matches) {
47
+ const segments = [];
48
+ let cursor = 0;
49
+ matches.forEach((match, index) => {
50
+ if (match.start > cursor)
51
+ segments.push({ matchIndex: null, text: text.slice(cursor, match.start) });
52
+ segments.push({ matchIndex: index, text: text.slice(match.start, match.end) });
53
+ cursor = match.end;
54
+ });
55
+ if (cursor < text.length)
56
+ segments.push({ matchIndex: null, text: text.slice(cursor) });
57
+ return segments;
58
+ }
59
+ static joinedWords(layer) {
60
+ return layer.words.map((word) => word.text).join(PsDocumentSearchConfig.wordSeparator);
61
+ }
62
+ static wordMatches(layer, query) {
63
+ const matches = PsDocumentSearchService.matches(PsDocumentSearchService.joinedWords(layer), query);
64
+ const bounds = [];
65
+ let cursor = 0;
66
+ for (const word of layer.words) {
67
+ bounds.push({ end: cursor + word.text.length, start: cursor });
68
+ cursor += word.text.length + PsDocumentSearchConfig.wordSeparator.length;
69
+ }
70
+ return matches.map((match) => ({
71
+ wordIndices: bounds.flatMap((bound, index) => bound.start < match.end && bound.end > match.start ? [index] : []),
72
+ }));
73
+ }
74
+ static fit(layer, container) {
75
+ if (layer.width <= 0 || layer.height <= 0)
76
+ return { height: 0, left: 0, top: 0, width: 0 };
77
+ const scale = Math.min(container.width / layer.width, container.height / layer.height);
78
+ const width = layer.width * scale;
79
+ const height = layer.height * scale;
80
+ return {
81
+ height,
82
+ left: (container.width - width) / 2,
83
+ top: (container.height - height) / 2,
84
+ width,
85
+ };
86
+ }
87
+ static rect(box, layer, container) {
88
+ const fitted = PsDocumentSearchService.fit(layer, container);
89
+ const scale = layer.width <= 0 ? 0 : fitted.width / layer.width;
90
+ return {
91
+ height: box.height * scale,
92
+ left: fitted.left + box.left * scale,
93
+ top: fitted.top + box.top * scale,
94
+ width: box.width * scale,
95
+ };
96
+ }
97
+ static highlights(layer, query, container, activeIndex) {
98
+ return PsDocumentSearchService.wordMatches(layer, query).flatMap((match, matchIndex) => match.wordIndices.map((wordIndex) => ({
99
+ box: PsDocumentSearchService.rect(layer.words[wordIndex].box, layer, container),
100
+ isActive: matchIndex === activeIndex,
101
+ })));
102
+ }
103
+ static center(box) {
104
+ return { x: box.left + box.width / 2, y: box.top + box.height / 2 };
105
+ }
106
+ static scrollOffset(lines, start) {
107
+ let cursor = 0;
108
+ for (const line of lines) {
109
+ cursor += line.text.length;
110
+ if (start < cursor)
111
+ return line.y;
112
+ }
113
+ const last = lines[lines.length - 1];
114
+ return last === undefined ? 0 : last.y;
115
+ }
116
+ static entryMatchCount(entry, texts, query) {
117
+ if (entry.item.kind === PsDocumentKind.Text) {
118
+ const text = entry.item.text === null ? texts[entry.item.id] : entry.item.text;
119
+ return text === undefined ? 0 : PsDocumentSearchService.matches(text, query).length;
120
+ }
121
+ const layer = entry.item.textLayer;
122
+ return layer === undefined ? 0 : PsDocumentSearchService.wordMatches(layer, query).length;
123
+ }
124
+ static counts(entries, texts, query) {
125
+ return entries.map((entry) => PsDocumentSearchService.entryMatchCount(entry, texts, query));
126
+ }
127
+ static total(counts) {
128
+ return counts.reduce((sum, count) => sum + count, 0);
129
+ }
130
+ static locate(counts, active) {
131
+ let remaining = active;
132
+ for (let entryIndex = 0; entryIndex < counts.length; entryIndex += 1) {
133
+ if (remaining < counts[entryIndex])
134
+ return { entryIndex, localIndex: remaining };
135
+ remaining -= counts[entryIndex];
136
+ }
137
+ return null;
138
+ }
139
+ static activeFor(counts, active, entryIndex) {
140
+ const location = PsDocumentSearchService.locate(counts, active);
141
+ return location !== null && location.entryIndex === entryIndex
142
+ ? location.localIndex
143
+ : PsDocumentSearchConfig.noActive;
144
+ }
145
+ static firstIndexOf(counts, entryIndex) {
146
+ return counts.slice(0, entryIndex).reduce((sum, count) => sum + count, 0);
147
+ }
148
+ static step(active, total, direction) {
149
+ if (total <= 0)
150
+ return PsDocumentSearchConfig.noActive;
151
+ return (active + direction + total) % total;
152
+ }
153
+ static startIndex(counts, entryIndex) {
154
+ const total = PsDocumentSearchService.total(counts);
155
+ if (total === 0)
156
+ return PsDocumentSearchConfig.noActive;
157
+ return counts[entryIndex] > 0 ? PsDocumentSearchService.firstIndexOf(counts, entryIndex) : 0;
158
+ }
159
+ static countLabel(template, current, total) {
160
+ return template
161
+ .replace(PsDocumentSearchConfig.currentToken, String(current))
162
+ .replace(PsDocumentSearchConfig.totalToken, String(total));
163
+ }
164
+ static labels(labels) {
165
+ const { closeSearch, matchCount, nextMatch, noMatches, previousMatch, search, searchPlaceholder, } = labels;
166
+ if (closeSearch === undefined ||
167
+ matchCount === undefined ||
168
+ nextMatch === undefined ||
169
+ noMatches === undefined ||
170
+ previousMatch === undefined ||
171
+ search === undefined ||
172
+ searchPlaceholder === undefined)
173
+ return null;
174
+ return {
175
+ closeSearch,
176
+ matchCount,
177
+ nextMatch,
178
+ noMatches,
179
+ previousMatch,
180
+ search,
181
+ searchPlaceholder,
182
+ };
183
+ }
184
+ static isSearchable(items) {
185
+ return items.some((item) => (item.kind === PsDocumentKind.Text && (item.text !== null || item.source !== null)) ||
186
+ item.textLayer !== undefined ||
187
+ (item.pageTextLayers !== undefined && item.pageTextLayers.length > 0));
188
+ }
189
+ static merge(ranges) {
190
+ const sorted = [...ranges].sort((a, b) => a.start === b.start ? a.end - b.end : a.start - b.start);
191
+ const merged = [];
192
+ for (const range of sorted) {
193
+ const last = merged[merged.length - 1];
194
+ if (last !== undefined && range.start < last.end)
195
+ merged[merged.length - 1] = { end: Math.max(last.end, range.end), start: last.start };
196
+ else
197
+ merged.push({ ...range });
198
+ }
199
+ return merged;
200
+ }
201
+ }
@@ -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
  }
@@ -4,5 +4,6 @@ export declare class PsInfiniteDataService {
4
4
  static initial<T>(): PsInfiniteDataState<T>;
5
5
  static merge<T>(existing: T[], incoming: T[], getKey: (item: T) => string): T[];
6
6
  static apply<T>(rows: T[], updates: PsInfiniteDataUpdate<T>[]): T[];
7
+ static keepsPrevious(option: boolean | ((previousKey: string, nextKey: string) => boolean), previousKey: string, nextKey: string): boolean;
7
8
  static hasMore<T>(state: PsInfiniteDataState<T>): boolean;
8
9
  }
@@ -16,6 +16,9 @@ export class PsInfiniteDataService {
16
16
  static apply(rows, updates) {
17
17
  return updates.reduce((current, update) => update(current), rows);
18
18
  }
19
+ static keepsPrevious(option, previousKey, nextKey) {
20
+ return typeof option === 'boolean' ? option : option(previousKey, nextKey);
21
+ }
19
22
  static hasMore(state) {
20
23
  return state.nextCursor !== null;
21
24
  }
@@ -1,6 +1,7 @@
1
1
  import type { PsMenuAnchor } from '../interfaces/ps-menu-anchor';
2
+ import type { PsMenuPopupInsets } from '../interfaces/ps-menu-popup-insets';
2
3
  import type { PsMenuPopupLayout } from '../interfaces/ps-menu-popup-layout';
3
4
  import type { PsMenuPopupWindow } from '../interfaces/ps-menu-popup-window';
4
5
  export declare class PsMenuPopupService {
5
- static layout(anchor: PsMenuAnchor, window: PsMenuPopupWindow, contentHeight: number, contentWidth: number, isFullWidth: boolean): PsMenuPopupLayout;
6
+ static layout(anchor: PsMenuAnchor, window: PsMenuPopupWindow, insets: PsMenuPopupInsets, contentHeight: number, contentWidth: number, isFullWidth: boolean): PsMenuPopupLayout;
6
7
  }
@@ -1,12 +1,12 @@
1
1
  import { PsMenuPopupConfig } from '../constants/ps-menu-popup-config';
2
2
  export class PsMenuPopupService {
3
- static layout(anchor, window, contentHeight, contentWidth, isFullWidth) {
3
+ static layout(anchor, window, insets, contentHeight, contentWidth, isFullWidth) {
4
4
  const margin = PsMenuPopupConfig.edgeMargin;
5
5
  const gap = PsMenuPopupConfig.anchorGap;
6
6
  const width = isFullWidth ? anchor.width : undefined;
7
7
  const menuWidth = width === undefined ? contentWidth : width;
8
- const below = window.height - (anchor.y + anchor.height) - gap - margin;
9
- const above = anchor.y - gap - margin;
8
+ const below = window.height - (anchor.y + anchor.height) - gap - Math.max(margin, insets.bottom);
9
+ const above = anchor.y - gap - Math.max(margin, insets.top);
10
10
  const isBelow = contentHeight <= below || below >= above;
11
11
  const room = isBelow ? below : above;
12
12
  const height = Math.min(contentHeight, Math.max(room, 0));
@@ -6,6 +6,7 @@ export declare class PsSheetService {
6
6
  static handlesInset(os: string): boolean;
7
7
  static bottomPadding(isFloating: boolean, bottomInset: number): number;
8
8
  static fittedHeight(headerHeight: number, bodyHeight: number, windowHeight: number): number;
9
+ static raisedHeight(height: number, keyboardHeight: number, windowHeight: number, topInset: number): number;
9
10
  static closeAction(label: string | undefined, onPress: () => void): PsSheetAction | undefined;
10
11
  static isActionInactive(action: PsSheetAction): boolean;
11
12
  static actionOpacity(action: PsSheetAction, isPressed: boolean): number;
@@ -13,6 +13,9 @@ export class PsSheetService {
13
13
  static fittedHeight(headerHeight, bodyHeight, windowHeight) {
14
14
  return Math.min(Math.ceil(headerHeight + bodyHeight), PsSheetService.maxHeight(windowHeight));
15
15
  }
16
+ static raisedHeight(height, keyboardHeight, windowHeight, topInset) {
17
+ return Math.min(height + keyboardHeight, windowHeight - topInset);
18
+ }
16
19
  static closeAction(label, onPress) {
17
20
  return label === undefined ? undefined : { label, onPress };
18
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pallasoft/ps-mobile-components",
3
- "version": "1.10.2",
3
+ "version": "1.12.0",
4
4
  "private": false,
5
5
  "description": "Native iOS (SwiftUI) and Android (Jetpack Compose) Ps components for Pallasoft mobile apps",
6
6
  "main": "./dist/index.js",