@sincpro/mobile-ui 3.1.0 → 3.3.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 (37) hide show
  1. package/dist/Dialog/Dialog.EditValue.js +6 -19
  2. package/dist/Dialog/Dialog.Sheet.js +48 -12
  3. package/dist/Dialog/OverlayHost.d.ts +2 -1
  4. package/dist/Dialog/OverlayHost.js +36 -2
  5. package/dist/Dialog/SheetSurface.d.ts +19 -0
  6. package/dist/Dialog/SheetSurface.js +279 -225
  7. package/dist/Display/Display.DocumentPreview.d.ts +15 -0
  8. package/dist/Display/Display.DocumentPreview.js +349 -0
  9. package/dist/Display/Display.DocumentViewer.d.ts +15 -0
  10. package/dist/Display/Display.DocumentViewer.js +465 -0
  11. package/dist/Display/Display.SwipeableRow.js +30 -23
  12. package/dist/Display/document-pages.d.ts +21 -0
  13. package/dist/Display/document-pages.js +282 -0
  14. package/dist/Display/document-renderer.d.ts +30 -0
  15. package/dist/Display/document-renderer.js +28 -0
  16. package/dist/Display/icon-map.d.ts +10 -10
  17. package/dist/Display/icon-map.js +14 -10
  18. package/dist/Display/index.d.ts +8 -0
  19. package/dist/Display/index.js +6 -0
  20. package/dist/Form/Form.DatePicker.js +2 -0
  21. package/dist/Form/Form.Input.d.ts +1 -1
  22. package/dist/Form/Form.Input.js +234 -215
  23. package/dist/Form/Form.KeyboardToolbarHost.js +78 -37
  24. package/dist/Form/Form.PickerField.js +133 -156
  25. package/dist/Form/Form.RadioButton.d.ts +1 -0
  26. package/dist/Form/Form.RadioButton.js +11 -122
  27. package/dist/Form/Form.Select.d.ts +2 -1
  28. package/dist/Form/Form.Select.js +183 -286
  29. package/dist/Form/choice-row.d.ts +15 -0
  30. package/dist/Form/choice-row.js +236 -0
  31. package/dist/theme/active.d.ts +2 -0
  32. package/dist/theme/active.js +13 -0
  33. package/dist/theme/useTheme.d.ts +4 -0
  34. package/dist/theme/useTheme.js +7 -12
  35. package/dist/utils/document.d.ts +18 -0
  36. package/dist/utils/document.js +46 -0
  37. package/package.json +4 -1
@@ -0,0 +1,465 @@
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import ExpoImage from "./Display.ExpoImage.js";
3
+ import { documentHeading, documentMeta, DocumentStatus, useDocumentPages } from "./document-pages.js";
4
+ import State from "../Feedback/Feedback.State.js";
5
+ import { AppBar } from "../Navigation/Navigation.AppBar.js";
6
+ import { useTheme, useThemeVars } from "../theme/index.js";
7
+ import { Typography } from "../Typography/index.js";
8
+ import { useReducedMotion } from "../utils/useReducedMotion.js";
9
+ import { useState } from "react";
10
+ import { Modal, ScrollView, useWindowDimensions, View } from "react-native";
11
+ import { useSafeAreaInsets } from "react-native-safe-area-context";
12
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "nativewind/jsx-runtime";
13
+ const MAX_RENDER_WIDTH = 2048;
14
+ const ZOOM_SCALE = 2;
15
+ const GUTTER = 12;
16
+ const A4_RATIO = 1 / Math.SQRT2;
17
+ function ViewerPage(t0) {
18
+ const $ = _c(26);
19
+ const {
20
+ page,
21
+ width,
22
+ number,
23
+ pageCount,
24
+ label,
25
+ onError
26
+ } = t0;
27
+ const theme = useTheme();
28
+ const [loadedRatio, setLoadedRatio] = useState(null);
29
+ const ratio = page.width && page.height ? page.width / page.height : loadedRatio ?? A4_RATIO;
30
+ let t1;
31
+ if ($[0] !== width) {
32
+ t1 = {
33
+ width,
34
+ gap: 6
35
+ };
36
+ $[0] = width;
37
+ $[1] = t1;
38
+ } else {
39
+ t1 = $[1];
40
+ }
41
+ let t2;
42
+ if ($[2] !== ratio || $[3] !== theme.border.light || $[4] !== theme.shadow.sm || $[5] !== width) {
43
+ t2 = {
44
+ width,
45
+ aspectRatio: ratio,
46
+ borderColor: theme.border.light,
47
+ borderWidth: 1,
48
+ ...theme.shadow.sm
49
+ };
50
+ $[2] = ratio;
51
+ $[3] = theme.border.light;
52
+ $[4] = theme.shadow.sm;
53
+ $[5] = width;
54
+ $[6] = t2;
55
+ } else {
56
+ t2 = $[6];
57
+ }
58
+ const t3 = pageCount > 1 ? `${label}, página ${number} de ${pageCount}` : label;
59
+ let t4;
60
+ if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
61
+ t4 = event => {
62
+ if (event.source.height > 0) {
63
+ setLoadedRatio(event.source.width / event.source.height);
64
+ }
65
+ };
66
+ $[7] = t4;
67
+ } else {
68
+ t4 = $[7];
69
+ }
70
+ let t5;
71
+ if ($[8] !== page.uri) {
72
+ t5 = {
73
+ uri: page.uri
74
+ };
75
+ $[8] = page.uri;
76
+ $[9] = t5;
77
+ } else {
78
+ t5 = $[9];
79
+ }
80
+ let t6;
81
+ if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
82
+ t6 = {
83
+ width: "100%",
84
+ height: "100%"
85
+ };
86
+ $[10] = t6;
87
+ } else {
88
+ t6 = $[10];
89
+ }
90
+ let t7;
91
+ if ($[11] !== onError || $[12] !== t3 || $[13] !== t5) {
92
+ t7 = _jsx(ExpoImage, {
93
+ accessibilityLabel: t3,
94
+ accessible: true,
95
+ contentFit: "contain",
96
+ onError: onError,
97
+ onLoad: t4,
98
+ source: t5,
99
+ style: t6
100
+ });
101
+ $[11] = onError;
102
+ $[12] = t3;
103
+ $[13] = t5;
104
+ $[14] = t7;
105
+ } else {
106
+ t7 = $[14];
107
+ }
108
+ let t8;
109
+ if ($[15] !== t2 || $[16] !== t7) {
110
+ t8 = _jsx(View, {
111
+ style: t2,
112
+ children: t7
113
+ });
114
+ $[15] = t2;
115
+ $[16] = t7;
116
+ $[17] = t8;
117
+ } else {
118
+ t8 = $[17];
119
+ }
120
+ let t9;
121
+ if ($[18] !== number || $[19] !== pageCount || $[20] !== theme.text) {
122
+ t9 = pageCount > 1 ? _jsxs(Typography.Text, {
123
+ align: "center",
124
+ style: {
125
+ color: theme.text.secondary
126
+ },
127
+ variant: "caption",
128
+ children: ["P\xE1gina ", number, " de ", pageCount]
129
+ }) : null;
130
+ $[18] = number;
131
+ $[19] = pageCount;
132
+ $[20] = theme.text;
133
+ $[21] = t9;
134
+ } else {
135
+ t9 = $[21];
136
+ }
137
+ let t10;
138
+ if ($[22] !== t1 || $[23] !== t8 || $[24] !== t9) {
139
+ t10 = _jsxs(View, {
140
+ style: t1,
141
+ children: [t8, t9]
142
+ });
143
+ $[22] = t1;
144
+ $[23] = t8;
145
+ $[24] = t9;
146
+ $[25] = t10;
147
+ } else {
148
+ t10 = $[25];
149
+ }
150
+ return t10;
151
+ }
152
+ function ViewerContent(t0) {
153
+ const $ = _c(55);
154
+ const {
155
+ source,
156
+ title,
157
+ onClose,
158
+ actions,
159
+ renderer
160
+ } = t0;
161
+ const theme = useTheme();
162
+ const insets = useSafeAreaInsets();
163
+ const {
164
+ width,
165
+ scale
166
+ } = useWindowDimensions();
167
+ const [zoomed, setZoomed] = useState(false);
168
+ let t1;
169
+ if ($[0] !== scale || $[1] !== width) {
170
+ t1 = Math.round(width * scale * ZOOM_SCALE);
171
+ $[0] = scale;
172
+ $[1] = width;
173
+ $[2] = t1;
174
+ } else {
175
+ t1 = $[2];
176
+ }
177
+ const document = useDocumentPages(source, Math.min(MAX_RENDER_WIDTH, t1), false, renderer);
178
+ const ready = document.status === DocumentStatus.READY;
179
+ let t2;
180
+ if ($[3] !== document || $[4] !== title) {
181
+ t2 = title ?? documentHeading(document);
182
+ $[3] = document;
183
+ $[4] = title;
184
+ $[5] = t2;
185
+ } else {
186
+ t2 = $[5];
187
+ }
188
+ const heading = t2;
189
+ const fitWidth = width - insets.left - insets.right - GUTTER * 2;
190
+ const pageWidth = zoomed ? fitWidth * ZOOM_SCALE : fitWidth;
191
+ let t3;
192
+ if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
193
+ t3 = {
194
+ gap: GUTTER * 2
195
+ };
196
+ $[6] = t3;
197
+ } else {
198
+ t3 = $[6];
199
+ }
200
+ let t4;
201
+ if ($[7] !== document.attempt || $[8] !== document.pageCount || $[9] !== document.pages || $[10] !== document.reportPageError || $[11] !== heading || $[12] !== pageWidth) {
202
+ let t5;
203
+ if ($[14] !== document.attempt || $[15] !== document.pageCount || $[16] !== document.reportPageError || $[17] !== heading || $[18] !== pageWidth) {
204
+ t5 = (page, index) => _jsx(ViewerPage, {
205
+ label: heading,
206
+ number: index + 1,
207
+ onError: document.reportPageError,
208
+ page: page,
209
+ pageCount: document.pageCount,
210
+ width: pageWidth
211
+ }, `${document.attempt}:${index}`);
212
+ $[14] = document.attempt;
213
+ $[15] = document.pageCount;
214
+ $[16] = document.reportPageError;
215
+ $[17] = heading;
216
+ $[18] = pageWidth;
217
+ $[19] = t5;
218
+ } else {
219
+ t5 = $[19];
220
+ }
221
+ t4 = document.pages.map(t5);
222
+ $[7] = document.attempt;
223
+ $[8] = document.pageCount;
224
+ $[9] = document.pages;
225
+ $[10] = document.reportPageError;
226
+ $[11] = heading;
227
+ $[12] = pageWidth;
228
+ $[13] = t4;
229
+ } else {
230
+ t4 = $[13];
231
+ }
232
+ let t5;
233
+ if ($[20] !== t4) {
234
+ t5 = _jsx(View, {
235
+ style: t3,
236
+ children: t4
237
+ });
238
+ $[20] = t4;
239
+ $[21] = t5;
240
+ } else {
241
+ t5 = $[21];
242
+ }
243
+ const pages = t5;
244
+ let t6;
245
+ if ($[22] !== theme.bg.muted) {
246
+ t6 = {
247
+ flex: 1,
248
+ backgroundColor: theme.bg.muted
249
+ };
250
+ $[22] = theme.bg.muted;
251
+ $[23] = t6;
252
+ } else {
253
+ t6 = $[23];
254
+ }
255
+ let t7;
256
+ if ($[24] !== ready || $[25] !== zoomed) {
257
+ t7 = ready ? _jsx(AppBar.Action, {
258
+ accessibilityLabel: zoomed ? "Ajustar al ancho" : "Ampliar",
259
+ label: zoomed ? "Ajustar" : "Ampliar",
260
+ onPress: () => setZoomed(_temp)
261
+ }) : null;
262
+ $[24] = ready;
263
+ $[25] = zoomed;
264
+ $[26] = t7;
265
+ } else {
266
+ t7 = $[26];
267
+ }
268
+ let t8;
269
+ if ($[27] !== actions || $[28] !== t7) {
270
+ t8 = _jsxs(_Fragment, {
271
+ children: [t7, actions]
272
+ });
273
+ $[27] = actions;
274
+ $[28] = t7;
275
+ $[29] = t8;
276
+ } else {
277
+ t8 = $[29];
278
+ }
279
+ let t9;
280
+ if ($[30] !== onClose) {
281
+ t9 = _jsx(AppBar.Action, {
282
+ accessibilityLabel: "Cerrar",
283
+ icon: "close",
284
+ onPress: onClose
285
+ });
286
+ $[30] = onClose;
287
+ $[31] = t9;
288
+ } else {
289
+ t9 = $[31];
290
+ }
291
+ let t10;
292
+ if ($[32] !== document.isImage || $[33] !== document.label || $[34] !== document.pageCount) {
293
+ t10 = documentMeta(document.label, document.isImage, document.pageCount);
294
+ $[32] = document.isImage;
295
+ $[33] = document.label;
296
+ $[34] = document.pageCount;
297
+ $[35] = t10;
298
+ } else {
299
+ t10 = $[35];
300
+ }
301
+ let t11;
302
+ if ($[36] !== heading || $[37] !== t10 || $[38] !== t8 || $[39] !== t9) {
303
+ t11 = _jsx(AppBar, {
304
+ actions: t8,
305
+ leading: t9,
306
+ subtitle: t10,
307
+ title: heading
308
+ });
309
+ $[36] = heading;
310
+ $[37] = t10;
311
+ $[38] = t8;
312
+ $[39] = t9;
313
+ $[40] = t11;
314
+ } else {
315
+ t11 = $[40];
316
+ }
317
+ let t12;
318
+ if ($[41] !== document.label || $[42] !== document.retry || $[43] !== document.status || $[44] !== insets.bottom || $[45] !== insets.left || $[46] !== insets.right || $[47] !== pages || $[48] !== ready || $[49] !== zoomed) {
319
+ t12 = ready ? _jsx(ScrollView, {
320
+ contentContainerStyle: {
321
+ paddingTop: GUTTER,
322
+ paddingLeft: insets.left + GUTTER,
323
+ paddingRight: insets.right + GUTTER,
324
+ paddingBottom: insets.bottom + GUTTER * 2
325
+ },
326
+ children: zoomed ? _jsx(ScrollView, {
327
+ horizontal: true,
328
+ children: pages
329
+ }) : pages
330
+ }) : _jsxs(View, {
331
+ style: {
332
+ flex: 1,
333
+ paddingBottom: insets.bottom
334
+ },
335
+ children: [document.status === DocumentStatus.LOADING ? _jsx(State, {
336
+ kind: "loading",
337
+ message: "Generando vista previa\u2026"
338
+ }) : null, document.status === DocumentStatus.ERROR ? _jsx(State, {
339
+ kind: "error",
340
+ message: "No se pudo generar la vista previa del documento.",
341
+ onRetry: document.retry
342
+ }) : null, document.status === DocumentStatus.UNSUPPORTED ? _jsx(State, {
343
+ description: `Esta app no tiene un visor configurado para ${document.label}.`,
344
+ icon: "document",
345
+ kind: "empty",
346
+ title: "Vista previa no disponible"
347
+ }) : null]
348
+ });
349
+ $[41] = document.label;
350
+ $[42] = document.retry;
351
+ $[43] = document.status;
352
+ $[44] = insets.bottom;
353
+ $[45] = insets.left;
354
+ $[46] = insets.right;
355
+ $[47] = pages;
356
+ $[48] = ready;
357
+ $[49] = zoomed;
358
+ $[50] = t12;
359
+ } else {
360
+ t12 = $[50];
361
+ }
362
+ let t13;
363
+ if ($[51] !== t11 || $[52] !== t12 || $[53] !== t6) {
364
+ t13 = _jsxs(View, {
365
+ style: t6,
366
+ children: [t11, t12]
367
+ });
368
+ $[51] = t11;
369
+ $[52] = t12;
370
+ $[53] = t6;
371
+ $[54] = t13;
372
+ } else {
373
+ t13 = $[54];
374
+ }
375
+ return t13;
376
+ }
377
+ function _temp(previous) {
378
+ return !previous;
379
+ }
380
+ function DocumentViewer(t0) {
381
+ const $ = _c(18);
382
+ const {
383
+ visible,
384
+ source,
385
+ title,
386
+ onClose,
387
+ actions,
388
+ renderer,
389
+ testID
390
+ } = t0;
391
+ const reducedMotion = useReducedMotion();
392
+ const themeVars = useThemeVars();
393
+ const t1 = reducedMotion ? "none" : "slide";
394
+ const t2 = visible && source !== null;
395
+ let t3;
396
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
397
+ t3 = {
398
+ flex: 1
399
+ };
400
+ $[0] = t3;
401
+ } else {
402
+ t3 = $[0];
403
+ }
404
+ let t4;
405
+ if ($[1] !== themeVars) {
406
+ t4 = [t3, themeVars];
407
+ $[1] = themeVars;
408
+ $[2] = t4;
409
+ } else {
410
+ t4 = $[2];
411
+ }
412
+ let t5;
413
+ if ($[3] !== actions || $[4] !== onClose || $[5] !== renderer || $[6] !== source || $[7] !== title) {
414
+ t5 = source ? _jsx(ViewerContent, {
415
+ actions: actions,
416
+ onClose: onClose,
417
+ renderer: renderer,
418
+ source: source,
419
+ title: title
420
+ }) : null;
421
+ $[3] = actions;
422
+ $[4] = onClose;
423
+ $[5] = renderer;
424
+ $[6] = source;
425
+ $[7] = title;
426
+ $[8] = t5;
427
+ } else {
428
+ t5 = $[8];
429
+ }
430
+ let t6;
431
+ if ($[9] !== t4 || $[10] !== t5 || $[11] !== testID) {
432
+ t6 = _jsx(View, {
433
+ style: t4,
434
+ testID: testID,
435
+ children: t5
436
+ });
437
+ $[9] = t4;
438
+ $[10] = t5;
439
+ $[11] = testID;
440
+ $[12] = t6;
441
+ } else {
442
+ t6 = $[12];
443
+ }
444
+ let t7;
445
+ if ($[13] !== onClose || $[14] !== t1 || $[15] !== t2 || $[16] !== t6) {
446
+ t7 = _jsx(Modal, {
447
+ animationType: t1,
448
+ navigationBarTranslucent: true,
449
+ onRequestClose: onClose,
450
+ statusBarTranslucent: true,
451
+ visible: t2,
452
+ children: t6
453
+ });
454
+ $[13] = onClose;
455
+ $[14] = t1;
456
+ $[15] = t2;
457
+ $[16] = t6;
458
+ $[17] = t7;
459
+ } else {
460
+ t7 = $[17];
461
+ }
462
+ return t7;
463
+ }
464
+ export default DocumentViewer;
465
+ export { DocumentViewer };
@@ -1,6 +1,7 @@
1
1
  import { c as _c } from "react/compiler-runtime";
2
2
  import Icon from "./Display.Icon.js";
3
3
  import { useTheme } from "../theme/index.js";
4
+ import { resolveOnColor } from "../theme/contrast.js";
4
5
  import { Typography } from "../Typography/index.js";
5
6
  import { useRef } from "react";
6
7
  import { TouchableOpacity, View } from "react-native";
@@ -26,29 +27,35 @@ function ActionButtons(t0) {
26
27
  if ($[1] !== actions || $[2] !== onDone || $[3] !== theme) {
27
28
  let t3;
28
29
  if ($[5] !== onDone || $[6] !== theme) {
29
- t3 = (action, index) => _jsxs(TouchableOpacity, {
30
- accessibilityLabel: action.label ?? "Acci\xF3n",
31
- accessibilityRole: "button",
32
- activeOpacity: 0.8,
33
- onPress: () => {
34
- onDone();
35
- action.onPress();
36
- },
37
- style: {
38
- backgroundColor: action.color ?? theme.danger,
39
- justifyContent: "center",
40
- alignItems: "center",
41
- paddingHorizontal: 20
42
- },
43
- children: [action.icon ? _jsx(Icon, {
44
- color: theme.text.inverse,
45
- name: action.icon,
46
- size: 20
47
- }) : null, action.label ? _jsx(Typography.Text, {
48
- className: "text-text-inverse mt-1",
49
- children: action.label
50
- }) : null]
51
- }, index);
30
+ t3 = (action, index) => {
31
+ const ink = action.color ? resolveOnColor(action.color) : theme.text.onDanger;
32
+ return _jsxs(TouchableOpacity, {
33
+ accessibilityLabel: action.label ?? "Acci\xF3n",
34
+ accessibilityRole: "button",
35
+ activeOpacity: 0.8,
36
+ onPress: () => {
37
+ onDone();
38
+ action.onPress();
39
+ },
40
+ style: {
41
+ backgroundColor: action.color ?? theme.danger,
42
+ justifyContent: "center",
43
+ alignItems: "center",
44
+ paddingHorizontal: 20
45
+ },
46
+ children: [action.icon ? _jsx(Icon, {
47
+ color: ink,
48
+ name: action.icon,
49
+ size: 20
50
+ }) : null, action.label ? _jsx(Typography.Text, {
51
+ className: "mt-1",
52
+ style: {
53
+ color: ink
54
+ },
55
+ children: action.label
56
+ }) : null]
57
+ }, index);
58
+ };
52
59
  $[5] = onDone;
53
60
  $[6] = theme;
54
61
  $[7] = t3;
@@ -0,0 +1,21 @@
1
+ import { type DocumentRenderer } from "./document-renderer.js";
2
+ import { type DocumentPage, type DocumentSource } from "../utils/document.js";
3
+ export declare enum DocumentStatus {
4
+ LOADING = "loading",
5
+ READY = "ready",
6
+ UNSUPPORTED = "unsupported",
7
+ ERROR = "error"
8
+ }
9
+ export interface DocumentPagesState {
10
+ label: string;
11
+ isImage: boolean;
12
+ status: DocumentStatus;
13
+ pageCount: number;
14
+ pages: DocumentPage[];
15
+ attempt: number;
16
+ retry: () => void;
17
+ reportPageError: () => void;
18
+ }
19
+ export declare function documentMeta(label: string, isImage: boolean, pageCount: number): string;
20
+ export declare function documentHeading(state: DocumentPagesState): string;
21
+ export declare function useDocumentPages(source: DocumentSource, maxWidth: number, firstPageOnly: boolean, override?: DocumentRenderer): DocumentPagesState;