@proef/common-ui 2.6.34 → 2.6.36

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 (24) hide show
  1. package/dist/esm/index.js +10 -1
  2. package/dist/esm/index.js.map +1 -1
  3. package/dist/esm/v1/capabilities/onepoint-rn/connectInbox.js +26 -4
  4. package/dist/esm/v1/capabilities/onepoint-rn/connectInbox.js.map +1 -1
  5. package/dist/esm/v1/capabilities/onepoint-rn/connectOutbox.js.map +1 -1
  6. package/dist/esm/v1/capabilities/onepoint-rn/useOfflineBoxes.js +103 -0
  7. package/dist/esm/v1/capabilities/onepoint-rn/useOfflineBoxes.js.map +1 -0
  8. package/dist/esm/v1/components/feedback/OfflineBoxes/OfflineBoxes.js +78 -0
  9. package/dist/esm/v1/components/feedback/OfflineBoxes/OfflineBoxes.js.map +1 -0
  10. package/dist/esm/v1/components/feedback/OfflineBoxes/OfflineBoxesIcon.js +86 -0
  11. package/dist/esm/v1/components/feedback/OfflineBoxes/OfflineBoxesIcon.js.map +1 -0
  12. package/dist/esm/v1/components/feedback/OfflineBoxes/OfflineBoxesView.js +243 -0
  13. package/dist/esm/v1/components/feedback/OfflineBoxes/OfflineBoxesView.js.map +1 -0
  14. package/dist/style.components.css +1 -1
  15. package/dist/style.css +1 -1
  16. package/dist/style.layered.css +1 -1
  17. package/dist/types/v1/capabilities/onepoint-rn/connectInbox.d.ts +6 -0
  18. package/dist/types/v1/capabilities/onepoint-rn/connectOutbox.d.ts +2 -0
  19. package/dist/types/v1/capabilities/onepoint-rn/useOfflineBoxes.d.ts +14 -0
  20. package/dist/types/v1/components/feedback/OfflineBoxes/OfflineBoxes.d.ts +30 -0
  21. package/dist/types/v1/components/feedback/OfflineBoxes/OfflineBoxesIcon.d.ts +12 -0
  22. package/dist/types/v1/components/feedback/OfflineBoxes/OfflineBoxesView.d.ts +86 -0
  23. package/dist/types/v1/index.d.ts +5 -1
  24. package/package.json +6 -5
@@ -48,6 +48,11 @@ export type InboxProgress = {
48
48
  };
49
49
  export type InboxStatus = InboxProgress & {
50
50
  finishedAt: string | null;
51
+ saved?: string[];
52
+ };
53
+ export type InboxEvent = InboxProgress & {
54
+ inboxId: string;
55
+ finishedAt: string | null;
51
56
  };
52
57
  declare module 'axios' {
53
58
  interface AxiosRequestConfig {
@@ -60,4 +65,5 @@ export declare function inboxSavedAt(response: AxiosResponse): string | null;
60
65
  export declare function inboxStatus(options: InboxOptions & {
61
66
  inboxId: string;
62
67
  }): Promise<InboxStatus | null>;
68
+ export declare function watchInbox(options: InboxOptions, onEvent: (event: InboxEvent) => void): () => void;
63
69
  export declare function syncInbox(api: AxiosInstance, options: InboxSyncOptions, onProgress?: (progress: InboxProgress) => void): Promise<InboxStatus | null>;
@@ -23,6 +23,8 @@ export type OutboxActionStatus = {
23
23
  state: OutboxState;
24
24
  createdAt?: string;
25
25
  reason?: string;
26
+ method?: string;
27
+ path?: string;
26
28
  };
27
29
  export type OutboxWatch = {
28
30
  actions: OutboxActionStatus[];
@@ -0,0 +1,14 @@
1
+ import { type InboxStatus } from './connectInbox';
2
+ import { type OutboxActionStatus } from './connectOutbox';
3
+ export type OfflineBoxesOptions = {
4
+ storageId: string | undefined;
5
+ inboxIds: string[];
6
+ };
7
+ export type OfflineBoxesState = {
8
+ inbox: InboxStatus & {
9
+ saved: string[];
10
+ };
11
+ downloading: boolean;
12
+ waiting: OutboxActionStatus[];
13
+ };
14
+ export declare function useOfflineBoxes({ storageId, inboxIds }: OfflineBoxesOptions): OfflineBoxesState | null;
@@ -0,0 +1,30 @@
1
+ import React from 'react';
2
+ import { type OfflineBoxesLabels, type OfflineSavedSummary, type OfflineWrite, type OfflineWriteDescription } from './OfflineBoxesView';
3
+ export { DEFAULT_OFFLINE_BOXES_LABELS, type OfflineBoxesLabels, type OfflineSavedItem, type OfflineSavedSummary, type OfflineSavedTag, type OfflineWrite, type OfflineWriteDescription, } from './OfflineBoxesView';
4
+ export interface OfflineBoxesProps {
5
+ /** O mesmo `storageId` do `connectOutbox` e do `connectInbox`. */
6
+ storageId: string | undefined;
7
+ /** As inboxes que este sítio mostra (ex: `['ajustes']`). Somam-se. */
8
+ inboxIds: string[];
9
+ /** O que o botão Atualizar faz (ex: chamar o `syncInbox`). Sem ele, não há botão. */
10
+ onRefresh?: () => void;
11
+ /** Endereço da API (`api.defaults.baseURL`): os endereços chegam ao `describeSaved` e ao `describeWrite` sem ele à frente. */
12
+ address?: string;
13
+ /** Linha ao lado do título na vista (ex: o nome do ecrã). */
14
+ subtitle?: string;
15
+ /** Transforma os endereços guardados nas linhas que se mostram (ex: uma por OT). Sem ele, mostra os endereços. */
16
+ describeSaved?: (paths: string[]) => OfflineSavedSummary;
17
+ /** Diz o que é cada escrita por enviar (ex: "Ajuste guardado"). Sem ele, ou se devolver `null`, mostra método e endereço. */
18
+ describeWrite?: (write: OfflineWrite) => OfflineWriteDescription | null;
19
+ labels?: Partial<OfflineBoxesLabels>;
20
+ className?: string;
21
+ }
22
+ /**
23
+ * O que a app tem guardado para usar sem rede (Inbox, verde) e o que tem por
24
+ * enviar (Outbox, laranja), num ícone que se põe onde se quiser (ex: à
25
+ * direita do título). Ao lado, a percentagem guardada, que sobe enquanto a
26
+ * descarga corre, e quantas escritas faltam enviar. Tocar abre a vista inteira
27
+ * com o detalhe. Fora da app OnePoint não aparece.
28
+ */
29
+ export default function OfflineBoxes({ storageId, inboxIds, onRefresh, address, subtitle, describeSaved, describeWrite, labels, className }: OfflineBoxesProps): React.JSX.Element | null;
30
+ export { OfflineBoxes };
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ export interface OfflineBoxesIconProps {
3
+ size?: number;
4
+ className?: string;
5
+ }
6
+ /**
7
+ * O tabuleiro de inbox em 3D, dividido na diagonal: verde (Inbox) em cima à
8
+ * esquerda, laranja (Outbox) em baixo à direita. Só desenho; os números vão
9
+ * ao lado, no OfflineBoxes.
10
+ */
11
+ export default function OfflineBoxesIcon({ size, className }: OfflineBoxesIconProps): React.JSX.Element;
12
+ export { OfflineBoxesIcon };
@@ -0,0 +1,86 @@
1
+ import React from 'react';
2
+ import type { OfflineBoxesState } from '../../../capabilities/onepoint-rn/useOfflineBoxes';
3
+ export interface OfflineBoxesLabels {
4
+ /** Título da vista. */
5
+ title: string;
6
+ /** Separador da Inbox. */
7
+ saved: string;
8
+ /** Separador da Outbox. */
9
+ waiting: string;
10
+ /** Ao lado do ícone, com `{n}`. */
11
+ toSend: string;
12
+ /** A descarregar, com `{ready}` e `{total}`. */
13
+ downloading: string;
14
+ /** Quantos itens estão guardados, com `{n}`. */
15
+ savedCount: string;
16
+ /** Última descarga, com `{date}` e `{time}`. */
17
+ savedAt: string;
18
+ /** Ainda nada guardado. */
19
+ nothingSaved: string;
20
+ /** Falharam pedidos, com `{n}`. */
21
+ failed: string;
22
+ /** Nada por enviar. */
23
+ nothingWaiting: string;
24
+ /** Por cima da lista do que falta enviar. */
25
+ waitingHint: string;
26
+ /** Texto da caixa de procura. */
27
+ search: string;
28
+ /** A procura não encontrou nada. */
29
+ noMatches: string;
30
+ refresh: string;
31
+ back: string;
32
+ pending: string;
33
+ sending: string;
34
+ rejected: string;
35
+ }
36
+ export declare const DEFAULT_OFFLINE_BOXES_LABELS: OfflineBoxesLabels;
37
+ /** Uma marca curta numa linha guardada (ex: `{ short: 'F', label: 'Ficha' }`). */
38
+ export interface OfflineSavedTag {
39
+ short: string;
40
+ label: string;
41
+ }
42
+ /** Uma linha da lista do que está guardado, como o portal a quer mostrar. */
43
+ export interface OfflineSavedItem {
44
+ key: string;
45
+ title: string;
46
+ /** Ao lado do título, mais pequeno (ex: concelho · mês). */
47
+ meta?: string;
48
+ /** Por baixo do título (ex: a descrição). */
49
+ detail?: string;
50
+ tags?: OfflineSavedTag[];
51
+ }
52
+ /** O que o portal faz dos endereços guardados. */
53
+ export interface OfflineSavedSummary {
54
+ items: OfflineSavedItem[];
55
+ /** Linha no fim da lista (ex: o que também está guardado e não é item). */
56
+ note?: string;
57
+ }
58
+ /** Uma escrita por enviar, em palavras do portal. */
59
+ export interface OfflineWriteDescription {
60
+ title: string;
61
+ detail?: string;
62
+ }
63
+ export interface OfflineWrite {
64
+ method: string;
65
+ path: string;
66
+ }
67
+ export interface OfflineBoxesViewProps {
68
+ state: OfflineBoxesState;
69
+ labels: OfflineBoxesLabels;
70
+ subtitle?: string;
71
+ address?: string;
72
+ onRefresh?: () => void;
73
+ onBack: () => void;
74
+ describeSaved?: (paths: string[]) => OfflineSavedSummary;
75
+ describeWrite?: (write: OfflineWrite) => OfflineWriteDescription | null;
76
+ }
77
+ export declare function filled(template: string, values: Record<string, string | number>): string;
78
+ export declare function percentOf(state: OfflineBoxesState): number | null;
79
+ export declare function toSendOf(state: OfflineBoxesState): number;
80
+ /**
81
+ * A vista inteira que o `OfflineBoxes` abre: dois separadores, o que está
82
+ * guardado (Inbox) e o que falta enviar (Outbox). Cada linha diz o que é nas
83
+ * palavras do portal (`describeSaved`, `describeWrite`); sem elas, mostra os
84
+ * endereços.
85
+ */
86
+ export default function OfflineBoxesView({ state, labels: L, subtitle, address, onRefresh, onBack, describeSaved, describeWrite }: OfflineBoxesViewProps): React.JSX.Element;
@@ -16,7 +16,11 @@ export { nativo } from './capabilities/onepoint-rn/nativo';
16
16
  export { type Coordenadas, type RespostaFicheiro } from './capabilities/onepoint-rn/device';
17
17
  export { type OrientacaoEcra } from './capabilities/onepoint-rn/frame';
18
18
  export { connectOutbox, isOutboxSaved, OutboxSavedError, OUTBOX_SAVED_MESSAGE, type OutboxOptions, type OutboxRequestOptions, watchOutbox, type OutboxActionStatus, type OutboxState, type OutboxWatch, } from './capabilities/onepoint-rn/connectOutbox';
19
- export { connectInbox, INBOX_SAVED_AT_HEADER, inboxSavedAt, inboxStatus, syncInbox, type InboxBundle, type InboxConnectOptions, type InboxEach, type InboxGet, type InboxOptions, type InboxProgress, type InboxStatus, type InboxSyncOptions, type InboxTier, } from './capabilities/onepoint-rn/connectInbox';
19
+ export { connectInbox, INBOX_SAVED_AT_HEADER, inboxSavedAt, inboxStatus, syncInbox, watchInbox, type InboxBundle, type InboxEvent, type InboxConnectOptions, type InboxEach, type InboxGet, type InboxOptions, type InboxProgress, type InboxStatus, type InboxSyncOptions, type InboxTier, } from './capabilities/onepoint-rn/connectInbox';
20
+ export { useOfflineBoxes, type OfflineBoxesOptions, type OfflineBoxesState } from './capabilities/onepoint-rn/useOfflineBoxes';
21
+ export { default as OfflineBoxes, DEFAULT_OFFLINE_BOXES_LABELS } from './components/feedback/OfflineBoxes/OfflineBoxes';
22
+ export type { OfflineBoxesLabels, OfflineBoxesProps, OfflineSavedItem, OfflineSavedSummary, OfflineSavedTag, OfflineWrite, OfflineWriteDescription, } from './components/feedback/OfflineBoxes/OfflineBoxes';
23
+ export { default as OfflineBoxesIcon } from './components/feedback/OfflineBoxes/OfflineBoxesIcon';
20
24
  export { useOrientacaoNaApp } from './capabilities/onepoint-rn/useOrientacaoNaApp';
21
25
  export { useMenuLateralNaApp } from './capabilities/onepoint-rn/useMenuLateralNaApp';
22
26
  export { useBarraEstadoNaApp } from './capabilities/onepoint-rn/useBarraEstadoNaApp';
package/package.json CHANGED
@@ -1,7 +1,11 @@
1
1
  {
2
2
  "name": "@proef/common-ui",
3
- "version": "2.6.34",
4
- "description": "",
3
+ "version": "2.6.36",
4
+ "description": "Biblioteca de componentes e tema partilhada pelos portais Proef.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://dev.azure.com/ProefNext/FTTx%20BoM/_git/CommonUI"
8
+ },
5
9
  "main": "dist/esm/index.js",
6
10
  "module": "dist/esm/index.js",
7
11
  "types": "dist/types/index.d.ts",
@@ -26,9 +30,6 @@
26
30
  "build": "vite build --config vite.lib.config.ts && tsc -p tsconfig.build.json && tailwindcss -i src/styles/tailwind.css -o dist/style.css --minify && tailwindcss -i src/styles/tailwind.layered.css -o dist/style.layered.css --minify && node scripts/css-components-layer.mjs && node scripts/extrair-imagens-css.mjs && node scripts/gerar-tema.mjs && node -e \"const fs=require('fs');fs.copyFileSync('src/styles/tailwind.app.css','dist/tailwind.css');fs.copyFileSync('src/styles/tokens.css','dist/tokens.css')\" && node -e \"import('./dist/esm/v1/capabilities/theme/useTheme.js').then(m=>require('fs').writeFileSync('dist/theme-boot.js',m.themeBootScript))\"",
27
31
  "storybook": "storybook dev -p 6006",
28
32
  "build-storybook": "storybook build",
29
- "pub": "git add . && git commit -m \"update\" && git push && npm test && npm version patch && npm run build && npm publish",
30
- "pubOnly": "npm test && npm version patch && npm run build && npm publish",
31
- "pubOnlySameVersion": "npm run build && npm publish",
32
33
  "test": "vitest run",
33
34
  "test:watch": "vitest",
34
35
  "test:ci": "vitest run --coverage",