@trismegisto/primitives 3.3.3 → 3.3.5
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.
- package/dist/account.d.ts +62 -0
- package/dist/account.js +102 -0
- package/dist/account.js.map +1 -0
- package/dist/address.d.ts +61 -0
- package/dist/address.js +119 -0
- package/dist/address.js.map +1 -0
- package/dist/announcer.d.ts +48 -0
- package/dist/announcer.js +130 -0
- package/dist/announcer.js.map +1 -0
- package/dist/billing.d.ts +171 -0
- package/dist/billing.js +184 -0
- package/dist/billing.js.map +1 -0
- package/dist/bottom-sheet.d.ts +64 -0
- package/dist/bottom-sheet.js +91 -0
- package/dist/bottom-sheet.js.map +1 -0
- package/dist/color-field.d.ts +18 -0
- package/dist/color-field.js +32 -0
- package/dist/color-field.js.map +1 -0
- package/dist/commerce.d.ts +268 -0
- package/dist/commerce.js +259 -0
- package/dist/commerce.js.map +1 -0
- package/dist/consent.d.ts +25 -0
- package/dist/consent.js +29 -0
- package/dist/consent.js.map +1 -0
- package/dist/data-grid-column-groups.d.ts +23 -0
- package/dist/data-grid-column-groups.js +32 -0
- package/dist/data-grid-column-groups.js.map +1 -0
- package/dist/data-grid-edit.d.ts +105 -0
- package/dist/data-grid-edit.js +236 -0
- package/dist/data-grid-edit.js.map +1 -0
- package/dist/data-grid-tree.d.ts +43 -0
- package/dist/data-grid-tree.js +75 -0
- package/dist/data-grid-tree.js.map +1 -0
- package/dist/data-grid.d.ts +6 -0
- package/dist/data-grid.js +3 -0
- package/dist/data-grid.js.map +1 -1
- package/dist/date-time.d.ts +90 -0
- package/dist/date-time.js +216 -0
- package/dist/date-time.js.map +1 -0
- package/dist/dev-tools.d.ts +78 -0
- package/dist/dev-tools.js +176 -0
- package/dist/dev-tools.js.map +1 -0
- package/dist/event-calendar-edit.d.ts +46 -0
- package/dist/event-calendar-edit.js +96 -0
- package/dist/event-calendar-edit.js.map +1 -0
- package/dist/event-calendar.d.ts +17 -0
- package/dist/event-calendar.js.map +1 -1
- package/dist/file-browser.d.ts +57 -0
- package/dist/file-browser.js +142 -0
- package/dist/file-browser.js.map +1 -0
- package/dist/file-manager.d.ts +124 -0
- package/dist/file-manager.js +124 -0
- package/dist/file-manager.js.map +1 -0
- package/dist/finance.d.ts +120 -0
- package/dist/finance.js +139 -0
- package/dist/finance.js.map +1 -0
- package/dist/focus.d.ts +11 -0
- package/dist/focus.js +82 -0
- package/dist/focus.js.map +1 -1
- package/dist/form-errors.d.ts +35 -0
- package/dist/form-errors.js +28 -0
- package/dist/form-errors.js.map +1 -0
- package/dist/gallery.d.ts +37 -0
- package/dist/gallery.js +45 -0
- package/dist/gallery.js.map +1 -0
- package/dist/icalendar.d.ts +50 -0
- package/dist/icalendar.js +213 -0
- package/dist/icalendar.js.map +1 -0
- package/dist/identity-document.d.ts +44 -0
- package/dist/identity-document.js +191 -0
- package/dist/identity-document.js.map +1 -0
- package/dist/in-page-focus.d.ts +27 -0
- package/dist/in-page-focus.js +93 -0
- package/dist/in-page-focus.js.map +1 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.js +57 -0
- package/dist/index.js.map +1 -1
- package/dist/integrations.d.ts +218 -0
- package/dist/integrations.js +281 -0
- package/dist/integrations.js.map +1 -0
- package/dist/json-tree.d.ts +74 -0
- package/dist/json-tree.js +213 -0
- package/dist/json-tree.js.map +1 -0
- package/dist/kanban.d.ts +20 -0
- package/dist/kanban.js +26 -0
- package/dist/kanban.js.map +1 -1
- package/dist/log-view.d.ts +53 -0
- package/dist/log-view.js +116 -0
- package/dist/log-view.js.map +1 -0
- package/dist/mentions.d.ts +58 -0
- package/dist/mentions.js +88 -0
- package/dist/mentions.js.map +1 -0
- package/dist/messages-calendar-files.d.ts +363 -0
- package/dist/messages-calendar-files.js +2 -0
- package/dist/messages-calendar-files.js.map +1 -0
- package/dist/messages-en.js +8 -0
- package/dist/messages-en.js.map +1 -1
- package/dist/messages-es.js +8 -0
- package/dist/messages-es.js.map +1 -1
- package/dist/messages.d.ts +11 -0
- package/dist/messages.js +8 -0
- package/dist/messages.js.map +1 -1
- package/dist/monitoring-format.d.ts +32 -0
- package/dist/monitoring-format.js +44 -0
- package/dist/monitoring-format.js.map +1 -0
- package/dist/monitoring.d.ts +182 -0
- package/dist/monitoring.js +324 -0
- package/dist/monitoring.js.map +1 -0
- package/dist/number-format.d.ts +164 -0
- package/dist/number-format.js +345 -0
- package/dist/number-format.js.map +1 -0
- package/dist/observability-format.d.ts +20 -0
- package/dist/observability-format.js +43 -0
- package/dist/observability-format.js.map +1 -0
- package/dist/payments.d.ts +188 -0
- package/dist/payments.js +372 -0
- package/dist/payments.js.map +1 -0
- package/dist/pdf-view.d.ts +34 -0
- package/dist/pdf-view.js +63 -0
- package/dist/pdf-view.js.map +1 -0
- package/dist/people.d.ts +236 -0
- package/dist/people.js +348 -0
- package/dist/people.js.map +1 -0
- package/dist/popover.d.ts +2 -0
- package/dist/popover.js.map +1 -1
- package/dist/progress-circle.d.ts +16 -0
- package/dist/progress-circle.js +20 -0
- package/dist/progress-circle.js.map +1 -0
- package/dist/project-planning.d.ts +71 -0
- package/dist/project-planning.js +134 -0
- package/dist/project-planning.js.map +1 -0
- package/dist/rating.d.ts +30 -0
- package/dist/rating.js +76 -0
- package/dist/rating.js.map +1 -0
- package/dist/recurrence.d.ts +99 -0
- package/dist/recurrence.js +270 -0
- package/dist/recurrence.js.map +1 -0
- package/dist/reports.d.ts +83 -0
- package/dist/reports.js +100 -0
- package/dist/reports.js.map +1 -0
- package/dist/save-status.d.ts +32 -0
- package/dist/save-status.js +24 -0
- package/dist/save-status.js.map +1 -0
- package/dist/scheduling.d.ts +178 -0
- package/dist/scheduling.js +240 -0
- package/dist/scheduling.js.map +1 -0
- package/dist/scrollspy.d.ts +43 -0
- package/dist/scrollspy.js +106 -0
- package/dist/scrollspy.js.map +1 -0
- package/dist/service-graph.d.ts +74 -0
- package/dist/service-graph.js +157 -0
- package/dist/service-graph.js.map +1 -0
- package/dist/sidebar.d.ts +12 -3
- package/dist/sidebar.js +26 -5
- package/dist/sidebar.js.map +1 -1
- package/dist/storefront.d.ts +45 -0
- package/dist/storefront.js +72 -0
- package/dist/storefront.js.map +1 -0
- package/dist/tag-input.d.ts +53 -0
- package/dist/tag-input.js +105 -0
- package/dist/tag-input.js.map +1 -0
- package/dist/tasks.d.ts +266 -0
- package/dist/tasks.js +340 -0
- package/dist/tasks.js.map +1 -0
- package/dist/tour.d.ts +63 -0
- package/dist/tour.js +66 -0
- package/dist/tour.js.map +1 -0
- package/dist/trace.d.ts +64 -0
- package/dist/trace.js +108 -0
- package/dist/trace.js.map +1 -0
- package/dist/tree-select.d.ts +65 -0
- package/dist/tree-select.js +150 -0
- package/dist/tree-select.js.map +1 -0
- package/dist/unsaved-changes.d.ts +43 -0
- package/dist/unsaved-changes.js +64 -0
- package/dist/unsaved-changes.js.map +1 -0
- package/dist/vehicle-plate.d.ts +44 -0
- package/dist/vehicle-plate.js +106 -0
- package/dist/vehicle-plate.js.map +1 -0
- package/dist/workflow.d.ts +268 -0
- package/dist/workflow.js +392 -0
- package/dist/workflow.js.map +1 -0
- package/dist/workspace.d.ts +29 -0
- package/dist/workspace.js +61 -0
- package/dist/workspace.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Comércio sem framework: preço e desconto, estoque, variantes de produto, totais de carrinho, situação
|
|
3
|
+
* do pedido, opções de entrega, rastreio, devolução e endereço. Tudo recebe o dado pronto e devolve o
|
|
4
|
+
* cálculo; nada chama backend nem formata texto (a formatação de moeda fica na camada de apresentação).
|
|
5
|
+
*
|
|
6
|
+
* Valores de dinheiro chegam na unidade principal da moeda (`199.9` = R$ 199,90). As somas são feitas
|
|
7
|
+
* em unidades menores inteiras (centavos), com as casas decimais da própria moeda, para não acumular
|
|
8
|
+
* erro de ponto flutuante (`0.1 + 0.2`).
|
|
9
|
+
*/
|
|
10
|
+
/** Tom visual de uma situação, o mesmo vocabulário do `hm-tag`. */
|
|
11
|
+
export type CommerceTone = 'neutral' | 'primary' | 'info' | 'success' | 'warning' | 'danger';
|
|
12
|
+
/** Casas decimais da moeda (BRL 2, JPY 0, KWD 3); moeda desconhecida = 2. */
|
|
13
|
+
export declare function currencyFractionDigits(currency: string): number;
|
|
14
|
+
/** Valor na unidade principal → inteiro na menor unidade da moeda (`19.9`, BRL → `1990`). */
|
|
15
|
+
export declare function toMinorUnits(amount: number, currency?: string): number;
|
|
16
|
+
/** Inteiro na menor unidade → valor na unidade principal (`1990`, BRL → `19.9`). */
|
|
17
|
+
export declare function fromMinorUnits(minor: number, currency?: string): number;
|
|
18
|
+
/** Soma valores sem erro de ponto flutuante. */
|
|
19
|
+
export declare function sumAmounts(amounts: readonly number[], currency?: string): number;
|
|
20
|
+
/** Multiplica um preço unitário por uma quantidade, arredondando na menor unidade. */
|
|
21
|
+
export declare function multiplyAmount(amount: number, quantity: number, currency?: string): number;
|
|
22
|
+
export interface PriceInput {
|
|
23
|
+
/** Preço cobrado. */
|
|
24
|
+
readonly amount: number;
|
|
25
|
+
/** Preço de referência ("de"), riscado quando maior que `amount`. */
|
|
26
|
+
readonly compareAt?: number | null;
|
|
27
|
+
}
|
|
28
|
+
export interface ResolvedPrice {
|
|
29
|
+
readonly amount: number;
|
|
30
|
+
/** Só existe quando é maior que o preço cobrado. */
|
|
31
|
+
readonly compareAt: number | null;
|
|
32
|
+
readonly onSale: boolean;
|
|
33
|
+
/** Quanto se economiza (`compareAt - amount`); 0 sem desconto. */
|
|
34
|
+
readonly savings: number;
|
|
35
|
+
/** Desconto em porcentagem inteira, arredondada para baixo (nunca promete mais do que dá). */
|
|
36
|
+
readonly discountPercent: number;
|
|
37
|
+
}
|
|
38
|
+
export declare function resolvePrice(price: PriceInput, currency?: string): ResolvedPrice;
|
|
39
|
+
/** Parcelamento: valor de cada parcela, arredondado para cima na menor unidade (a soma cobre o total). */
|
|
40
|
+
export declare function installmentAmount(total: number, count: number, currency?: string): number;
|
|
41
|
+
export type StockLevel = 'in-stock' | 'low-stock' | 'out-of-stock' | 'backorder' | 'preorder';
|
|
42
|
+
export interface StockInput {
|
|
43
|
+
/** Unidades disponíveis; `null` = não controlado (sempre disponível). */
|
|
44
|
+
readonly quantity: number | null;
|
|
45
|
+
/** A partir de quantas unidades (inclusive) o estoque é "baixo". Padrão 5. */
|
|
46
|
+
readonly lowThreshold?: number;
|
|
47
|
+
/** Aceita pedido sem estoque (entrega quando repor). */
|
|
48
|
+
readonly backorder?: boolean;
|
|
49
|
+
/** Ainda não lançado: vende em pré-venda. */
|
|
50
|
+
readonly preorder?: boolean;
|
|
51
|
+
}
|
|
52
|
+
export declare function resolveStockLevel(stock: StockInput): StockLevel;
|
|
53
|
+
/** Pode ir para o carrinho? */
|
|
54
|
+
export declare function isPurchasable(level: StockLevel): boolean;
|
|
55
|
+
export declare const STOCK_LEVEL_TONES: Readonly<Record<StockLevel, CommerceTone>>;
|
|
56
|
+
export interface ProductImage {
|
|
57
|
+
readonly src: string;
|
|
58
|
+
/** O que a imagem mostra; vazio = decorativa. */
|
|
59
|
+
readonly alt: string;
|
|
60
|
+
}
|
|
61
|
+
/** O que um cartão/lista de produto precisa saber (o app monta a partir do próprio catálogo). */
|
|
62
|
+
export interface ProductSummary {
|
|
63
|
+
readonly id: string;
|
|
64
|
+
readonly name: string;
|
|
65
|
+
readonly price: number;
|
|
66
|
+
readonly compareAt?: number | null;
|
|
67
|
+
readonly image?: string;
|
|
68
|
+
readonly imageAlt?: string;
|
|
69
|
+
/** Link da página do produto; sem ele, o título vira botão que emite `view`. */
|
|
70
|
+
readonly href?: string;
|
|
71
|
+
/** Selo curto sobre a imagem ("Novo", "Frete grátis"). */
|
|
72
|
+
readonly badge?: string;
|
|
73
|
+
/** Marca ou categoria, em letra miúda acima do nome. */
|
|
74
|
+
readonly brand?: string;
|
|
75
|
+
/** Estoque; ausente = não controlado. */
|
|
76
|
+
readonly stock?: StockInput | null;
|
|
77
|
+
/** Parcelas exibidas sob o preço (0 = nenhuma). */
|
|
78
|
+
readonly installments?: number;
|
|
79
|
+
readonly interestFree?: boolean;
|
|
80
|
+
}
|
|
81
|
+
export interface ProductOptionValue {
|
|
82
|
+
readonly id: string;
|
|
83
|
+
readonly label: string;
|
|
84
|
+
/** Cor da amostra (qualquer cor CSS) para opção de cor; vazio = botão com texto. */
|
|
85
|
+
readonly swatch?: string;
|
|
86
|
+
}
|
|
87
|
+
export interface ProductOption {
|
|
88
|
+
readonly id: string;
|
|
89
|
+
readonly label: string;
|
|
90
|
+
readonly values: readonly ProductOptionValue[];
|
|
91
|
+
}
|
|
92
|
+
export interface ProductVariant {
|
|
93
|
+
readonly id: string;
|
|
94
|
+
/** Valor escolhido em cada opção: `{ cor: 'azul', tamanho: 'm' }`. */
|
|
95
|
+
readonly options: Readonly<Record<string, string>>;
|
|
96
|
+
/** `false` = esgotada (padrão: disponível). */
|
|
97
|
+
readonly available?: boolean;
|
|
98
|
+
/** Preço próprio da variante (vence o do produto). */
|
|
99
|
+
readonly price?: number;
|
|
100
|
+
readonly compareAt?: number | null;
|
|
101
|
+
readonly sku?: string;
|
|
102
|
+
/** Estoque próprio da variante. */
|
|
103
|
+
readonly stock?: StockInput | null;
|
|
104
|
+
/** Índice da imagem do produto que mostra esta variante. */
|
|
105
|
+
readonly imageIndex?: number;
|
|
106
|
+
}
|
|
107
|
+
/** Seleção parcial ou completa: id da opção → id do valor. */
|
|
108
|
+
export type VariantSelection = Readonly<Record<string, string>>;
|
|
109
|
+
/** Variante que casa com TODAS as opções da seleção; `null` se a seleção estiver incompleta ou não existir. */
|
|
110
|
+
export declare function findVariant(options: readonly ProductOption[], variants: readonly ProductVariant[], selection: VariantSelection): ProductVariant | null;
|
|
111
|
+
export type OptionValueState = 'available' | 'unavailable' | 'missing';
|
|
112
|
+
/**
|
|
113
|
+
* Situação de um valor de opção diante do que já foi escolhido nas OUTRAS opções: `available` se existe
|
|
114
|
+
* variante disponível com ele, `unavailable` se só existe esgotada, `missing` se a combinação não existe.
|
|
115
|
+
*/
|
|
116
|
+
export declare function optionValueState(variants: readonly ProductVariant[], selection: VariantSelection, optionId: string, valueId: string): OptionValueState;
|
|
117
|
+
/** Troca um valor na seleção (mesmo valor de novo = mantém; não desmarca). */
|
|
118
|
+
export declare function selectOptionValue(selection: VariantSelection, optionId: string, valueId: string): VariantSelection;
|
|
119
|
+
export interface CartLine {
|
|
120
|
+
readonly id: string;
|
|
121
|
+
readonly name: string;
|
|
122
|
+
readonly unitPrice: number;
|
|
123
|
+
readonly quantity: number;
|
|
124
|
+
/** Preço unitário de referência ("de"). */
|
|
125
|
+
readonly compareAtUnitPrice?: number | null;
|
|
126
|
+
/** Texto curto da variante ("Azul · M"). */
|
|
127
|
+
readonly variant?: string;
|
|
128
|
+
readonly image?: string;
|
|
129
|
+
/** Teto de unidades (estoque ou limite por pedido). */
|
|
130
|
+
readonly maxQuantity?: number | null;
|
|
131
|
+
/** Código do item (SKU), exibido em letra miúda. */
|
|
132
|
+
readonly sku?: string;
|
|
133
|
+
}
|
|
134
|
+
export type CartDiscountKind = 'percent' | 'amount';
|
|
135
|
+
export interface CartDiscount {
|
|
136
|
+
readonly id: string;
|
|
137
|
+
/** Rótulo exibido ("Cupom BEMVINDO"). */
|
|
138
|
+
readonly label: string;
|
|
139
|
+
readonly kind: CartDiscountKind;
|
|
140
|
+
/** Porcentagem (10 = 10%) ou valor fixo na unidade principal. */
|
|
141
|
+
readonly value: number;
|
|
142
|
+
}
|
|
143
|
+
export interface CartTotalsInput {
|
|
144
|
+
readonly lines: readonly CartLine[];
|
|
145
|
+
readonly discounts?: readonly CartDiscount[];
|
|
146
|
+
/** Frete; `null` = ainda não calculado. */
|
|
147
|
+
readonly shipping?: number | null;
|
|
148
|
+
/** Imposto já calculado pelo app (valor). Tem prioridade sobre `taxRate`. */
|
|
149
|
+
readonly tax?: number | null;
|
|
150
|
+
/** Alíquota sobre (subtotal − desconto), em porcentagem. */
|
|
151
|
+
readonly taxRate?: number | null;
|
|
152
|
+
readonly currency?: string;
|
|
153
|
+
}
|
|
154
|
+
export interface CartTotals {
|
|
155
|
+
/** Soma dos itens (preço × quantidade). */
|
|
156
|
+
readonly subtotal: number;
|
|
157
|
+
/** Desconto total, positivo (nunca maior que o subtotal). */
|
|
158
|
+
readonly discount: number;
|
|
159
|
+
/** Desconto por regra, na ordem recebida. */
|
|
160
|
+
readonly discounts: readonly {
|
|
161
|
+
readonly id: string;
|
|
162
|
+
readonly label: string;
|
|
163
|
+
readonly amount: number;
|
|
164
|
+
}[];
|
|
165
|
+
readonly shipping: number | null;
|
|
166
|
+
readonly tax: number;
|
|
167
|
+
readonly total: number;
|
|
168
|
+
/** Economia nos preços "de" dos itens (fora dos descontos de carrinho). */
|
|
169
|
+
readonly itemSavings: number;
|
|
170
|
+
/** Quantidade de unidades. */
|
|
171
|
+
readonly itemCount: number;
|
|
172
|
+
}
|
|
173
|
+
export declare function lineTotal(line: CartLine, currency?: string): number;
|
|
174
|
+
/**
|
|
175
|
+
* Totais do carrinho. Descontos percentuais incidem sobre o subtotal; os de valor fixo, na ordem; o
|
|
176
|
+
* total de desconto é limitado ao subtotal (o total dos itens nunca fica negativo).
|
|
177
|
+
*/
|
|
178
|
+
export declare function computeCartTotals(input: CartTotalsInput): CartTotals;
|
|
179
|
+
/** Quantidade dentro de [min, max]; inteiro. `max` nulo = sem teto. */
|
|
180
|
+
export declare function clampQuantity(quantity: number, min?: number, max?: number | null): number;
|
|
181
|
+
/** Frete grátis: quanto falta para atingir o mínimo (0 = já atingiu). */
|
|
182
|
+
export declare function freeShippingRemaining(subtotal: number, threshold: number, currency?: string): number;
|
|
183
|
+
export type OrderStatus = 'pending' | 'paid' | 'processing' | 'shipped' | 'delivered' | 'cancelled' | 'returned' | 'refunded';
|
|
184
|
+
export declare const ORDER_STATUS_TONES: Readonly<Record<OrderStatus, CommerceTone>>;
|
|
185
|
+
/** O caminho feliz de um pedido, na ordem. */
|
|
186
|
+
export declare const ORDER_FLOW: readonly OrderStatus[];
|
|
187
|
+
export interface OrderProgress {
|
|
188
|
+
/** Etapa do fluxo em que o pedido está (ou parou). */
|
|
189
|
+
readonly current: OrderStatus;
|
|
190
|
+
/** `running` enquanto corre, `completed` entregue, `failed` cancelado no meio. */
|
|
191
|
+
readonly outcome: 'running' | 'completed' | 'failed';
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Situação → posição no fluxo. Cancelado para na última etapa alcançada (`reachedBefore`, padrão
|
|
195
|
+
* `pending`); devolvido/reembolsado contam como fluxo concluído (a entrega aconteceu).
|
|
196
|
+
*/
|
|
197
|
+
export declare function orderProgress(status: OrderStatus, reachedBefore?: OrderStatus): OrderProgress;
|
|
198
|
+
/** Situações em que ainda se pode cancelar o pedido (antes de sair para entrega). */
|
|
199
|
+
export declare function canCancelOrder(status: OrderStatus): boolean;
|
|
200
|
+
/** Situações em que se pode pedir devolução. */
|
|
201
|
+
export declare function canReturnOrder(status: OrderStatus): boolean;
|
|
202
|
+
export interface ShippingOption {
|
|
203
|
+
readonly id: string;
|
|
204
|
+
readonly label: string;
|
|
205
|
+
/** Preço do frete; 0 = grátis. */
|
|
206
|
+
readonly price: number;
|
|
207
|
+
/** Prazo em dias úteis (mínimo e máximo). */
|
|
208
|
+
readonly minDays: number;
|
|
209
|
+
readonly maxDays: number;
|
|
210
|
+
/** Transportadora ou modalidade ("Correios", "Retirada"). */
|
|
211
|
+
readonly carrier?: string;
|
|
212
|
+
readonly disabled?: boolean;
|
|
213
|
+
}
|
|
214
|
+
/** Soma `days` dias úteis (seg. a sex.) a uma data. */
|
|
215
|
+
export declare function addBusinessDays(from: Date, days: number): Date;
|
|
216
|
+
/** Janela de entrega estimada a partir de hoje (ou `from`), em dias úteis. */
|
|
217
|
+
export declare function deliveryWindow(option: Pick<ShippingOption, 'minDays' | 'maxDays'>, from?: Date): {
|
|
218
|
+
start: Date;
|
|
219
|
+
end: Date;
|
|
220
|
+
};
|
|
221
|
+
/** Opção mais barata e mais rápida (empate no preço: a mais rápida; ignora as desabilitadas). */
|
|
222
|
+
export declare function highlightShippingOptions(options: readonly ShippingOption[]): {
|
|
223
|
+
cheapest: string | null;
|
|
224
|
+
fastest: string | null;
|
|
225
|
+
};
|
|
226
|
+
export type ShipmentStatus = 'label-created' | 'in-transit' | 'out-for-delivery' | 'delivered' | 'exception' | 'returned';
|
|
227
|
+
export declare const SHIPMENT_STATUS_TONES: Readonly<Record<ShipmentStatus, CommerceTone>>;
|
|
228
|
+
export interface ShipmentEvent {
|
|
229
|
+
readonly id?: string;
|
|
230
|
+
readonly status: ShipmentStatus;
|
|
231
|
+
/** Quando aconteceu: `Date`, ISO ou epoch. */
|
|
232
|
+
readonly date: Date | string | number;
|
|
233
|
+
/** Descrição livre do evento, como a transportadora mandou. */
|
|
234
|
+
readonly description?: string;
|
|
235
|
+
/** Cidade/unidade onde aconteceu. */
|
|
236
|
+
readonly location?: string;
|
|
237
|
+
}
|
|
238
|
+
/** Eventos do mais recente para o mais antigo (datas inválidas no fim). */
|
|
239
|
+
export declare function sortShipmentEvents(events: readonly ShipmentEvent[]): ShipmentEvent[];
|
|
240
|
+
/** Situação atual do envio = a do evento mais recente; sem eventos, etiqueta criada. */
|
|
241
|
+
export declare function currentShipmentStatus(events: readonly ShipmentEvent[]): ShipmentStatus;
|
|
242
|
+
export type ReturnReason = 'damaged' | 'wrong-item' | 'not-as-described' | 'size' | 'changed-mind' | 'other';
|
|
243
|
+
export declare const RETURN_REASONS: readonly ReturnReason[];
|
|
244
|
+
export type RefundMethod = 'original' | 'store-credit';
|
|
245
|
+
/** Unidades a devolver por linha do pedido (`lineId → quantidade`). */
|
|
246
|
+
export type ReturnSelection = Readonly<Record<string, number>>;
|
|
247
|
+
export interface RefundInput {
|
|
248
|
+
readonly lines: readonly CartLine[];
|
|
249
|
+
readonly selection: ReturnSelection;
|
|
250
|
+
/** Taxa de reposição sobre os itens, em porcentagem (0 = nenhuma). */
|
|
251
|
+
readonly restockingFeePercent?: number;
|
|
252
|
+
/** Frete pago no pedido, devolvido só quando a devolução é total e `refundShipping`. */
|
|
253
|
+
readonly shipping?: number;
|
|
254
|
+
readonly refundShipping?: boolean;
|
|
255
|
+
readonly currency?: string;
|
|
256
|
+
}
|
|
257
|
+
export interface RefundEstimate {
|
|
258
|
+
readonly items: number;
|
|
259
|
+
readonly fee: number;
|
|
260
|
+
readonly shipping: number;
|
|
261
|
+
readonly total: number;
|
|
262
|
+
/** Unidades selecionadas. */
|
|
263
|
+
readonly units: number;
|
|
264
|
+
/** Todas as unidades do pedido voltam. */
|
|
265
|
+
readonly full: boolean;
|
|
266
|
+
}
|
|
267
|
+
/** Estimativa do reembolso: valor dos itens escolhidos − taxa de reposição (+ frete na devolução total). */
|
|
268
|
+
export declare function estimateRefund(input: RefundInput): RefundEstimate;
|
package/dist/commerce.js
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Comércio sem framework: preço e desconto, estoque, variantes de produto, totais de carrinho, situação
|
|
3
|
+
* do pedido, opções de entrega, rastreio, devolução e endereço. Tudo recebe o dado pronto e devolve o
|
|
4
|
+
* cálculo; nada chama backend nem formata texto (a formatação de moeda fica na camada de apresentação).
|
|
5
|
+
*
|
|
6
|
+
* Valores de dinheiro chegam na unidade principal da moeda (`199.9` = R$ 199,90). As somas são feitas
|
|
7
|
+
* em unidades menores inteiras (centavos), com as casas decimais da própria moeda, para não acumular
|
|
8
|
+
* erro de ponto flutuante (`0.1 + 0.2`).
|
|
9
|
+
*/
|
|
10
|
+
// ---------------------------------------------------------------- dinheiro
|
|
11
|
+
const fractionCache = new Map();
|
|
12
|
+
/** Casas decimais da moeda (BRL 2, JPY 0, KWD 3); moeda desconhecida = 2. */
|
|
13
|
+
export function currencyFractionDigits(currency) {
|
|
14
|
+
const code = (currency || '').toUpperCase();
|
|
15
|
+
let digits = fractionCache.get(code);
|
|
16
|
+
if (digits === undefined) {
|
|
17
|
+
try {
|
|
18
|
+
digits = new Intl.NumberFormat('en', { style: 'currency', currency: code }).resolvedOptions().maximumFractionDigits ?? 2;
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
digits = 2;
|
|
22
|
+
}
|
|
23
|
+
fractionCache.set(code, digits);
|
|
24
|
+
}
|
|
25
|
+
return digits;
|
|
26
|
+
}
|
|
27
|
+
/** Valor na unidade principal → inteiro na menor unidade da moeda (`19.9`, BRL → `1990`). */
|
|
28
|
+
export function toMinorUnits(amount, currency = 'BRL') {
|
|
29
|
+
if (!Number.isFinite(amount))
|
|
30
|
+
return 0;
|
|
31
|
+
return Math.round(amount * 10 ** currencyFractionDigits(currency));
|
|
32
|
+
}
|
|
33
|
+
/** Inteiro na menor unidade → valor na unidade principal (`1990`, BRL → `19.9`). */
|
|
34
|
+
export function fromMinorUnits(minor, currency = 'BRL') {
|
|
35
|
+
return minor / 10 ** currencyFractionDigits(currency);
|
|
36
|
+
}
|
|
37
|
+
/** Soma valores sem erro de ponto flutuante. */
|
|
38
|
+
export function sumAmounts(amounts, currency = 'BRL') {
|
|
39
|
+
return fromMinorUnits(amounts.reduce((total, amount) => total + toMinorUnits(amount, currency), 0), currency);
|
|
40
|
+
}
|
|
41
|
+
/** Multiplica um preço unitário por uma quantidade, arredondando na menor unidade. */
|
|
42
|
+
export function multiplyAmount(amount, quantity, currency = 'BRL') {
|
|
43
|
+
return fromMinorUnits(Math.round(toMinorUnits(amount, currency) * quantity), currency);
|
|
44
|
+
}
|
|
45
|
+
export function resolvePrice(price, currency = 'BRL') {
|
|
46
|
+
const amount = Number.isFinite(price.amount) ? price.amount : 0;
|
|
47
|
+
const reference = price.compareAt ?? null;
|
|
48
|
+
const onSale = reference !== null && Number.isFinite(reference) && reference > amount && reference > 0;
|
|
49
|
+
if (!onSale)
|
|
50
|
+
return { amount, compareAt: null, onSale: false, savings: 0, discountPercent: 0 };
|
|
51
|
+
const savings = fromMinorUnits(toMinorUnits(reference, currency) - toMinorUnits(amount, currency), currency);
|
|
52
|
+
return { amount, compareAt: reference, onSale, savings, discountPercent: Math.floor((savings / reference) * 100) };
|
|
53
|
+
}
|
|
54
|
+
/** Parcelamento: valor de cada parcela, arredondado para cima na menor unidade (a soma cobre o total). */
|
|
55
|
+
export function installmentAmount(total, count, currency = 'BRL') {
|
|
56
|
+
if (count <= 1)
|
|
57
|
+
return total;
|
|
58
|
+
return fromMinorUnits(Math.ceil(toMinorUnits(total, currency) / count), currency);
|
|
59
|
+
}
|
|
60
|
+
export function resolveStockLevel(stock) {
|
|
61
|
+
if (stock.preorder)
|
|
62
|
+
return 'preorder';
|
|
63
|
+
const quantity = stock.quantity;
|
|
64
|
+
if (quantity === null || quantity === undefined)
|
|
65
|
+
return 'in-stock';
|
|
66
|
+
if (quantity <= 0)
|
|
67
|
+
return stock.backorder ? 'backorder' : 'out-of-stock';
|
|
68
|
+
return quantity <= (stock.lowThreshold ?? 5) ? 'low-stock' : 'in-stock';
|
|
69
|
+
}
|
|
70
|
+
/** Pode ir para o carrinho? */
|
|
71
|
+
export function isPurchasable(level) {
|
|
72
|
+
return level !== 'out-of-stock';
|
|
73
|
+
}
|
|
74
|
+
export const STOCK_LEVEL_TONES = {
|
|
75
|
+
'in-stock': 'success',
|
|
76
|
+
'low-stock': 'warning',
|
|
77
|
+
'out-of-stock': 'danger',
|
|
78
|
+
backorder: 'info',
|
|
79
|
+
preorder: 'primary',
|
|
80
|
+
};
|
|
81
|
+
/** Variante que casa com TODAS as opções da seleção; `null` se a seleção estiver incompleta ou não existir. */
|
|
82
|
+
export function findVariant(options, variants, selection) {
|
|
83
|
+
if (options.some((option) => !selection[option.id]))
|
|
84
|
+
return null;
|
|
85
|
+
return variants.find((variant) => options.every((option) => variant.options[option.id] === selection[option.id])) ?? null;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Situação de um valor de opção diante do que já foi escolhido nas OUTRAS opções: `available` se existe
|
|
89
|
+
* variante disponível com ele, `unavailable` se só existe esgotada, `missing` se a combinação não existe.
|
|
90
|
+
*/
|
|
91
|
+
export function optionValueState(variants, selection, optionId, valueId) {
|
|
92
|
+
const candidates = variants.filter((variant) => variant.options[optionId] === valueId &&
|
|
93
|
+
Object.entries(selection).every(([key, value]) => key === optionId || !value || variant.options[key] === value));
|
|
94
|
+
if (!candidates.length)
|
|
95
|
+
return 'missing';
|
|
96
|
+
return candidates.some((variant) => variant.available !== false) ? 'available' : 'unavailable';
|
|
97
|
+
}
|
|
98
|
+
/** Troca um valor na seleção (mesmo valor de novo = mantém; não desmarca). */
|
|
99
|
+
export function selectOptionValue(selection, optionId, valueId) {
|
|
100
|
+
return { ...selection, [optionId]: valueId };
|
|
101
|
+
}
|
|
102
|
+
export function lineTotal(line, currency = 'BRL') {
|
|
103
|
+
return multiplyAmount(line.unitPrice, line.quantity, currency);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Totais do carrinho. Descontos percentuais incidem sobre o subtotal; os de valor fixo, na ordem; o
|
|
107
|
+
* total de desconto é limitado ao subtotal (o total dos itens nunca fica negativo).
|
|
108
|
+
*/
|
|
109
|
+
export function computeCartTotals(input) {
|
|
110
|
+
const currency = input.currency ?? 'BRL';
|
|
111
|
+
const minor = (value) => toMinorUnits(value, currency);
|
|
112
|
+
const major = (value) => fromMinorUnits(value, currency);
|
|
113
|
+
let subtotal = 0;
|
|
114
|
+
let savings = 0;
|
|
115
|
+
let itemCount = 0;
|
|
116
|
+
for (const line of input.lines) {
|
|
117
|
+
const quantity = Math.max(0, line.quantity);
|
|
118
|
+
subtotal += Math.round(minor(line.unitPrice) * quantity);
|
|
119
|
+
itemCount += quantity;
|
|
120
|
+
const reference = line.compareAtUnitPrice ?? null;
|
|
121
|
+
if (reference !== null && reference > line.unitPrice)
|
|
122
|
+
savings += Math.round((minor(reference) - minor(line.unitPrice)) * quantity);
|
|
123
|
+
}
|
|
124
|
+
let remaining = subtotal;
|
|
125
|
+
const discounts = (input.discounts ?? []).map((rule) => {
|
|
126
|
+
const wanted = rule.kind === 'percent' ? Math.round((subtotal * Math.max(0, rule.value)) / 100) : minor(Math.max(0, rule.value));
|
|
127
|
+
const amount = Math.min(wanted, remaining);
|
|
128
|
+
remaining -= amount;
|
|
129
|
+
return { id: rule.id, label: rule.label, amount: major(amount) };
|
|
130
|
+
});
|
|
131
|
+
const discount = subtotal - remaining;
|
|
132
|
+
const shipping = input.shipping ?? null;
|
|
133
|
+
const shippingMinor = shipping === null ? 0 : minor(shipping);
|
|
134
|
+
const tax = input.tax !== null && input.tax !== undefined
|
|
135
|
+
? minor(input.tax)
|
|
136
|
+
: input.taxRate
|
|
137
|
+
? Math.round((remaining * input.taxRate) / 100)
|
|
138
|
+
: 0;
|
|
139
|
+
return {
|
|
140
|
+
subtotal: major(subtotal),
|
|
141
|
+
discount: major(discount),
|
|
142
|
+
discounts,
|
|
143
|
+
shipping,
|
|
144
|
+
tax: major(tax),
|
|
145
|
+
total: major(remaining + shippingMinor + tax),
|
|
146
|
+
itemSavings: major(savings),
|
|
147
|
+
itemCount,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/** Quantidade dentro de [min, max]; inteiro. `max` nulo = sem teto. */
|
|
151
|
+
export function clampQuantity(quantity, min = 1, max = null) {
|
|
152
|
+
const whole = Number.isFinite(quantity) ? Math.round(quantity) : min;
|
|
153
|
+
const floor = Math.max(min, whole);
|
|
154
|
+
return max === null || max === undefined ? floor : Math.min(floor, Math.max(min, max));
|
|
155
|
+
}
|
|
156
|
+
/** Frete grátis: quanto falta para atingir o mínimo (0 = já atingiu). */
|
|
157
|
+
export function freeShippingRemaining(subtotal, threshold, currency = 'BRL') {
|
|
158
|
+
const missing = toMinorUnits(threshold, currency) - toMinorUnits(subtotal, currency);
|
|
159
|
+
return missing > 0 ? fromMinorUnits(missing, currency) : 0;
|
|
160
|
+
}
|
|
161
|
+
export const ORDER_STATUS_TONES = {
|
|
162
|
+
pending: 'warning',
|
|
163
|
+
paid: 'info',
|
|
164
|
+
processing: 'info',
|
|
165
|
+
shipped: 'primary',
|
|
166
|
+
delivered: 'success',
|
|
167
|
+
cancelled: 'danger',
|
|
168
|
+
returned: 'neutral',
|
|
169
|
+
refunded: 'neutral',
|
|
170
|
+
};
|
|
171
|
+
/** O caminho feliz de um pedido, na ordem. */
|
|
172
|
+
export const ORDER_FLOW = ['pending', 'paid', 'processing', 'shipped', 'delivered'];
|
|
173
|
+
/**
|
|
174
|
+
* Situação → posição no fluxo. Cancelado para na última etapa alcançada (`reachedBefore`, padrão
|
|
175
|
+
* `pending`); devolvido/reembolsado contam como fluxo concluído (a entrega aconteceu).
|
|
176
|
+
*/
|
|
177
|
+
export function orderProgress(status, reachedBefore = 'pending') {
|
|
178
|
+
if (status === 'delivered' || status === 'returned' || status === 'refunded')
|
|
179
|
+
return { current: 'delivered', outcome: 'completed' };
|
|
180
|
+
if (status === 'cancelled')
|
|
181
|
+
return { current: ORDER_FLOW.includes(reachedBefore) ? reachedBefore : 'pending', outcome: 'failed' };
|
|
182
|
+
return { current: status, outcome: 'running' };
|
|
183
|
+
}
|
|
184
|
+
/** Situações em que ainda se pode cancelar o pedido (antes de sair para entrega). */
|
|
185
|
+
export function canCancelOrder(status) {
|
|
186
|
+
return status === 'pending' || status === 'paid' || status === 'processing';
|
|
187
|
+
}
|
|
188
|
+
/** Situações em que se pode pedir devolução. */
|
|
189
|
+
export function canReturnOrder(status) {
|
|
190
|
+
return status === 'delivered';
|
|
191
|
+
}
|
|
192
|
+
/** Soma `days` dias úteis (seg. a sex.) a uma data. */
|
|
193
|
+
export function addBusinessDays(from, days) {
|
|
194
|
+
const date = new Date(from.getTime());
|
|
195
|
+
let left = Math.max(0, Math.round(days));
|
|
196
|
+
while (left > 0) {
|
|
197
|
+
date.setDate(date.getDate() + 1);
|
|
198
|
+
const weekday = date.getDay();
|
|
199
|
+
if (weekday !== 0 && weekday !== 6)
|
|
200
|
+
left--;
|
|
201
|
+
}
|
|
202
|
+
return date;
|
|
203
|
+
}
|
|
204
|
+
/** Janela de entrega estimada a partir de hoje (ou `from`), em dias úteis. */
|
|
205
|
+
export function deliveryWindow(option, from = new Date()) {
|
|
206
|
+
const min = Math.min(option.minDays, option.maxDays);
|
|
207
|
+
const max = Math.max(option.minDays, option.maxDays);
|
|
208
|
+
return { start: addBusinessDays(from, min), end: addBusinessDays(from, max) };
|
|
209
|
+
}
|
|
210
|
+
/** Opção mais barata e mais rápida (empate no preço: a mais rápida; ignora as desabilitadas). */
|
|
211
|
+
export function highlightShippingOptions(options) {
|
|
212
|
+
const usable = options.filter((option) => !option.disabled);
|
|
213
|
+
if (!usable.length)
|
|
214
|
+
return { cheapest: null, fastest: null };
|
|
215
|
+
const cheapest = [...usable].sort((a, b) => a.price - b.price || a.maxDays - b.maxDays)[0];
|
|
216
|
+
const fastest = [...usable].sort((a, b) => a.maxDays - b.maxDays || a.price - b.price)[0];
|
|
217
|
+
return { cheapest: cheapest.id, fastest: fastest.id };
|
|
218
|
+
}
|
|
219
|
+
export const SHIPMENT_STATUS_TONES = {
|
|
220
|
+
'label-created': 'neutral',
|
|
221
|
+
'in-transit': 'info',
|
|
222
|
+
'out-for-delivery': 'primary',
|
|
223
|
+
delivered: 'success',
|
|
224
|
+
exception: 'danger',
|
|
225
|
+
returned: 'warning',
|
|
226
|
+
};
|
|
227
|
+
/** Eventos do mais recente para o mais antigo (datas inválidas no fim). */
|
|
228
|
+
export function sortShipmentEvents(events) {
|
|
229
|
+
const time = (event) => {
|
|
230
|
+
const value = new Date(event.date).getTime();
|
|
231
|
+
return Number.isNaN(value) ? -Infinity : value;
|
|
232
|
+
};
|
|
233
|
+
return [...events].sort((a, b) => time(b) - time(a));
|
|
234
|
+
}
|
|
235
|
+
/** Situação atual do envio = a do evento mais recente; sem eventos, etiqueta criada. */
|
|
236
|
+
export function currentShipmentStatus(events) {
|
|
237
|
+
return sortShipmentEvents(events)[0]?.status ?? 'label-created';
|
|
238
|
+
}
|
|
239
|
+
export const RETURN_REASONS = ['damaged', 'wrong-item', 'not-as-described', 'size', 'changed-mind', 'other'];
|
|
240
|
+
/** Estimativa do reembolso: valor dos itens escolhidos − taxa de reposição (+ frete na devolução total). */
|
|
241
|
+
export function estimateRefund(input) {
|
|
242
|
+
const currency = input.currency ?? 'BRL';
|
|
243
|
+
let items = 0;
|
|
244
|
+
let units = 0;
|
|
245
|
+
let all = true;
|
|
246
|
+
for (const line of input.lines) {
|
|
247
|
+
const wanted = clampQuantity(input.selection[line.id] ?? 0, 0, line.quantity);
|
|
248
|
+
if (wanted < line.quantity)
|
|
249
|
+
all = false;
|
|
250
|
+
units += wanted;
|
|
251
|
+
items += Math.round(toMinorUnits(line.unitPrice, currency) * wanted);
|
|
252
|
+
}
|
|
253
|
+
const fee = Math.round((items * Math.max(0, input.restockingFeePercent ?? 0)) / 100);
|
|
254
|
+
const full = all && units > 0;
|
|
255
|
+
const shipping = full && input.refundShipping ? toMinorUnits(input.shipping ?? 0, currency) : 0;
|
|
256
|
+
const major = (value) => fromMinorUnits(value, currency);
|
|
257
|
+
return { items: major(items), fee: major(fee), shipping: major(shipping), total: major(items - fee + shipping), units, full };
|
|
258
|
+
}
|
|
259
|
+
//# sourceMappingURL=commerce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commerce.js","sourceRoot":"","sources":["../src/commerce.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,4EAA4E;AAE5E,MAAM,aAAa,GAAG,IAAI,GAAG,EAAkB,CAAC;AAEhD,6EAA6E;AAC7E,MAAM,UAAU,sBAAsB,CAAC,QAAgB;IACrD,MAAM,IAAI,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IAC5C,IAAI,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACrC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,IAAI,CAAC;YACH,MAAM,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE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,EAAE,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC9E,IAAI,MAAM,GAAG,IAAI,CAAC,QAAQ;YAAE,GAAG,GAAG,KAAK,CAAC;QACxC,KAAK,IAAI,MAAM,CAAC;QAChB,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,GAAG,MAAM,CAAC,CAAC;IACvE,CAAC;IACD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,oBAAoB,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;IACrF,MAAM,IAAI,GAAG,GAAG,IAAI,KAAK,GAAG,CAAC,CAAC;IAC9B,MAAM,QAAQ,GAAG,IAAI,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,QAAQ,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAChG,MAAM,KAAK,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,cAAc,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACjE,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,GAAG,GAAG,GAAG,QAAQ,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAChI,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** Uma categoria de consentimento ("Essenciais", "Medição", "Marketing"). Os textos são do app. */
|
|
2
|
+
export interface ConsentCategory {
|
|
3
|
+
readonly id: string;
|
|
4
|
+
readonly label: string;
|
|
5
|
+
readonly description?: string;
|
|
6
|
+
/** Necessária para o serviço funcionar: aparece ligada e travada. */
|
|
7
|
+
readonly required?: boolean;
|
|
8
|
+
/** Valor inicial quando não há escolha salva. Padrão: desligada (consentimento é opt-in). */
|
|
9
|
+
readonly defaultValue?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/** Escolha da pessoa: id da categoria → consentiu. */
|
|
12
|
+
export type ConsentState = Readonly<Record<string, boolean>>;
|
|
13
|
+
/** Estado inicial: a escolha salva (quando houver) por cima dos padrões; obrigatórias sempre ligadas. */
|
|
14
|
+
export declare function initialConsent(categories: readonly ConsentCategory[], saved?: ConsentState | null): ConsentState;
|
|
15
|
+
/** Liga ou desliga uma categoria; obrigatória não muda. */
|
|
16
|
+
export declare function setConsent(state: ConsentState, categories: readonly ConsentCategory[], id: string, value: boolean): ConsentState;
|
|
17
|
+
/** Aceitar tudo. */
|
|
18
|
+
export declare function acceptAllConsent(categories: readonly ConsentCategory[]): ConsentState;
|
|
19
|
+
/** Recusar o que é opcional (as obrigatórias continuam ligadas). */
|
|
20
|
+
export declare function rejectOptionalConsent(categories: readonly ConsentCategory[]): ConsentState;
|
|
21
|
+
/**
|
|
22
|
+
* A rolagem chegou ao fim do texto? `tolerance` absorve o arredondamento de subpixel. Conteúdo que cabe
|
|
23
|
+
* inteiro (sem rolagem) conta como lido até o fim.
|
|
24
|
+
*/
|
|
25
|
+
export declare function scrolledToEnd(scrollTop: number, clientHeight: number, scrollHeight: number, tolerance?: number): boolean;
|
package/dist/consent.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Consentimento (privacidade, cookies, termos) — estado sem framework. O app guarda e envia a escolha; aqui
|
|
2
|
+
// só se garante a regra: categoria obrigatória fica sempre ligada e "recusar" desliga só as opcionais.
|
|
3
|
+
/** Estado inicial: a escolha salva (quando houver) por cima dos padrões; obrigatórias sempre ligadas. */
|
|
4
|
+
export function initialConsent(categories, saved) {
|
|
5
|
+
return Object.fromEntries(categories.map((c) => [c.id, c.required ? true : (saved?.[c.id] ?? c.defaultValue ?? false)]));
|
|
6
|
+
}
|
|
7
|
+
/** Liga ou desliga uma categoria; obrigatória não muda. */
|
|
8
|
+
export function setConsent(state, categories, id, value) {
|
|
9
|
+
const category = categories.find((c) => c.id === id);
|
|
10
|
+
if (!category || category.required)
|
|
11
|
+
return state;
|
|
12
|
+
return { ...state, [id]: value };
|
|
13
|
+
}
|
|
14
|
+
/** Aceitar tudo. */
|
|
15
|
+
export function acceptAllConsent(categories) {
|
|
16
|
+
return Object.fromEntries(categories.map((c) => [c.id, true]));
|
|
17
|
+
}
|
|
18
|
+
/** Recusar o que é opcional (as obrigatórias continuam ligadas). */
|
|
19
|
+
export function rejectOptionalConsent(categories) {
|
|
20
|
+
return Object.fromEntries(categories.map((c) => [c.id, !!c.required]));
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A rolagem chegou ao fim do texto? `tolerance` absorve o arredondamento de subpixel. Conteúdo que cabe
|
|
24
|
+
* inteiro (sem rolagem) conta como lido até o fim.
|
|
25
|
+
*/
|
|
26
|
+
export function scrolledToEnd(scrollTop, clientHeight, scrollHeight, tolerance = 2) {
|
|
27
|
+
return scrollHeight - clientHeight - scrollTop <= tolerance;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=consent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consent.js","sourceRoot":"","sources":["../src/consent.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAC5G,uGAAuG;AAgBvG,yGAAyG;AACzG,MAAM,UAAU,cAAc,CAAC,UAAsC,EAAE,KAA2B;IAChG,OAAO,MAAM,CAAC,WAAW,CACvB,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,YAA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
5
|
+
export interface GridColumnGroup {
|
|
6
|
+
readonly key: string;
|
|
7
|
+
readonly title: string;
|
|
8
|
+
/** Chaves das colunas do grupo; a ordem na tela é a das colunas, não a desta lista. */
|
|
9
|
+
readonly columns: readonly string[];
|
|
10
|
+
}
|
|
11
|
+
/** Um trecho da linha de grupos: colunas vizinhas do mesmo grupo, ou colunas sem grupo (`key = null`). */
|
|
12
|
+
export interface GridColumnGroupSpan {
|
|
13
|
+
readonly key: string | null;
|
|
14
|
+
readonly title: string;
|
|
15
|
+
readonly span: number;
|
|
16
|
+
readonly columns: readonly string[];
|
|
17
|
+
}
|
|
18
|
+
export declare function hasGridColumnGroups(groups: readonly GridColumnGroup[]): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Trechos da linha de grupos para as colunas exibidas, na ordem delas. Um grupo partido (coluna movida
|
|
21
|
+
* para longe) vira dois trechos com o mesmo título.
|
|
22
|
+
*/
|
|
23
|
+
export declare function gridColumnGroupSpans(shownKeys: readonly string[], groups: readonly GridColumnGroup[]): readonly GridColumnGroupSpan[];
|