@sincpro/web-ui 2.21.0 → 2.22.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.
- package/README.md +2 -0
- package/dist/components/lines/LineItems.d.ts +13 -1
- package/dist/components/lines/LineItems.js +17 -3
- package/dist/components/lines/index.d.ts +1 -1
- package/dist/foundations/copy.es.d.ts +10 -0
- package/dist/foundations/copy.es.js +53 -0
- package/dist/foundations/index.d.ts +1 -1
- package/dist/foundations/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -84,6 +84,8 @@ the tokens once — fonts, theme and Tailwind come with it:
|
|
|
84
84
|
import { Field, installCopy, SPANISH_COPY, TextInput } from "@sincpro/web-ui";
|
|
85
85
|
|
|
86
86
|
installCopy(SPANISH_COPY); // optional: the interface in Spanish — once, where the app starts
|
|
87
|
+
// SPANISH_COPY is written in vos («Elegí»); SPANISH_COPY_TU in tú («Elige»). Choose one, the
|
|
88
|
+
// same voice as the framework's and the composer's tables.
|
|
87
89
|
|
|
88
90
|
export function CompanyName({
|
|
89
91
|
value,
|
|
@@ -20,6 +20,11 @@ export type LineItemColumn<T> = Pick<DataColumn<T>, "id" | "header" | "value" |
|
|
|
20
20
|
* with `structure`; without it the section says nothing in this column. */
|
|
21
21
|
subtotal?: (lines: readonly T[]) => ReactNode;
|
|
22
22
|
};
|
|
23
|
+
/** Another way to add lines, beside «Agregar una línea»: its words, and what starts it. */
|
|
24
|
+
export type LineAdd = {
|
|
25
|
+
label: string;
|
|
26
|
+
onAdd: () => void;
|
|
27
|
+
};
|
|
23
28
|
/** Which lines are sections or notes, and how their text is read and written. See
|
|
24
29
|
* «Sections and notes» in the file's header. */
|
|
25
30
|
export type LineStructure<T> = {
|
|
@@ -57,6 +62,13 @@ export type LineItemsProps<T> = {
|
|
|
57
62
|
/** The blank line «Agregar una línea» starts from. Required for adding. It carries its
|
|
58
63
|
* local key from here — `{ key: crypto.randomUUID(), … }` — since it has no server id. */
|
|
59
64
|
newLine?: () => T;
|
|
65
|
+
/**
|
|
66
|
+
* Other ways to add, beside «Agregar una línea» and quieter than it: several at once («Agregar
|
|
67
|
+
* varios…», one line per record chosen), from a catalog. Each starts its own flow; the lines it
|
|
68
|
+
* makes arrive in `lines` as any other. In place they sit in the table's add row, beside a
|
|
69
|
+
* section and a note; with the dialog, beside the add button. None in `read`.
|
|
70
|
+
*/
|
|
71
|
+
moreAdds?: readonly LineAdd[];
|
|
60
72
|
/** A line was removed. It is gone at once; the notice offers to undo it. */
|
|
61
73
|
onRemove?: (id: string) => void;
|
|
62
74
|
/** Put a removed line back where it was. Without it the notice has no «Deshacer». */
|
|
@@ -122,4 +134,4 @@ export type LineItemsProps<T> = {
|
|
|
122
134
|
* removing asked first, what an empty document said. One component, built on
|
|
123
135
|
* `EditableTable` and `Dialog`, makes the one2many the same block everywhere.
|
|
124
136
|
*/
|
|
125
|
-
export declare function LineItems<T>({ lines, columns, getLineId, lineLabel, mode, onChange, onAdd, newLine, onRemove, onRestore, editor, isValid, context, searchText, searchFrom, totals, layout, adding, onOpenLine, flag, cellState, rowState, structure, onReorder, visibleColumnIds, onVisibleColumnIdsChange, }: LineItemsProps<T>): import("react").JSX.Element;
|
|
137
|
+
export declare function LineItems<T>({ lines, columns, getLineId, lineLabel, mode, onChange, onAdd, newLine, moreAdds, onRemove, onRestore, editor, isValid, context, searchText, searchFrom, totals, layout, adding, onOpenLine, flag, cellState, rowState, structure, onReorder, visibleColumnIds, onVisibleColumnIdsChange, }: LineItemsProps<T>): import("react").JSX.Element;
|
|
@@ -38,7 +38,7 @@ function plain(v) {
|
|
|
38
38
|
* removing asked first, what an empty document said. One component, built on
|
|
39
39
|
* `EditableTable` and `Dialog`, makes the one2many the same block everywhere.
|
|
40
40
|
*/
|
|
41
|
-
export function LineItems({ lines, columns, getLineId, lineLabel, mode, onChange, onAdd, newLine, onRemove, onRestore, editor, isValid, context, searchText, searchFrom = 8, totals, layout = "auto", adding, onOpenLine, flag, cellState, rowState, structure, onReorder, visibleColumnIds, onVisibleColumnIdsChange, }) {
|
|
41
|
+
export function LineItems({ lines, columns, getLineId, lineLabel, mode, onChange, onAdd, newLine, moreAdds, onRemove, onRestore, editor, isValid, context, searchText, searchFrom = 8, totals, layout = "auto", adding, onOpenLine, flag, cellState, rowState, structure, onReorder, visibleColumnIds, onVisibleColumnIdsChange, }) {
|
|
42
42
|
const copy = useUiCopy();
|
|
43
43
|
const toast = useOptionalToast();
|
|
44
44
|
const read = useFormMode(mode) === "read";
|
|
@@ -185,6 +185,20 @@ export function LineItems({ lines, columns, getLineId, lineLabel, mode, onChange
|
|
|
185
185
|
: [{ label: copy.lines.addNote, onAdd: () => addInline(structure.newNote) }]),
|
|
186
186
|
];
|
|
187
187
|
const inPlace = inline || bandAdds.length > 0;
|
|
188
|
+
/* The other ways to add: in the table's add row in place, beside the button otherwise. Each
|
|
189
|
+
clears the search first, as adding a line does — what it adds would land out of sight —, and
|
|
190
|
+
answers nothing: its lines arrive through `lines`, never as the table's new draft row (which
|
|
191
|
+
the table would take back, with no «Deshacer», if left untouched). */
|
|
192
|
+
const others = read
|
|
193
|
+
? []
|
|
194
|
+
: (moreAdds ?? []).map((other) => ({
|
|
195
|
+
label: other.label,
|
|
196
|
+
onAdd: () => {
|
|
197
|
+
setQuery("");
|
|
198
|
+
other.onAdd();
|
|
199
|
+
},
|
|
200
|
+
}));
|
|
201
|
+
const tableAdds = inline ? [...bandAdds, ...others] : bandAdds;
|
|
188
202
|
const bands = structure === undefined
|
|
189
203
|
? undefined
|
|
190
204
|
: {
|
|
@@ -271,7 +285,7 @@ export function LineItems({ lines, columns, getLineId, lineLabel, mode, onChange
|
|
|
271
285
|
});
|
|
272
286
|
}
|
|
273
287
|
/* In place, «add» is the table's own row under the grid: where the line will appear. */
|
|
274
|
-
const addButton = canAdd && !inline ? (_jsx(Button, { role: "secondary", size: "sm", icon: Plus, onClick: add, "data-line-add": "", children: copy.lines.add })) : null;
|
|
288
|
+
const addButton = canAdd && !inline ? (_jsxs("span", { className: "flex items-center gap-2", children: [others.map((other) => (_jsx(Button, { role: "ghost", size: "sm", onClick: other.onAdd, children: other.label }, other.label))), _jsx(Button, { role: "secondary", size: "sm", icon: Plus, onClick: add, "data-line-add": "", children: copy.lines.add })] })) : null;
|
|
275
289
|
const count = q === ""
|
|
276
290
|
? fillCopy(lineCount === 1 ? copy.lineItems.one : copy.lineItems.many, {
|
|
277
291
|
count: lineCount.toLocaleString(copy.locale),
|
|
@@ -293,7 +307,7 @@ export function LineItems({ lines, columns, getLineId, lineLabel, mode, onChange
|
|
|
293
307
|
invalid: false,
|
|
294
308
|
}, children: _jsx(SearchField, { value: query, onChange: setQuery, placeholder: copy.lines.search }) })] })) : null, _jsx("span", { className: "text-meta text-muted tabular-nums", "aria-live": "polite", children: count }), columnControl.hasOptional || addButton !== null ? (_jsxs("span", { className: "ml-auto flex items-center gap-2", children: [_jsx(ColumnsMenu, { control: columnControl }), addButton] })) : null] }), _jsx(EditableTable, { rows: shown, columns: tableColumns, getRowId: getLineId, empty: lines.length === 0
|
|
295
309
|
? copy.lines.empty
|
|
296
|
-
: fillCopy(copy.lineItems.noMatch, { query: query.trim() }), layout: layout, ...(inline ? { onAdd: () => addInline(), addLabel: copy.lines.add } : {}), ...(
|
|
310
|
+
: fillCopy(copy.lineItems.noMatch, { query: query.trim() }), layout: layout, ...(inline ? { onAdd: () => addInline(), addLabel: copy.lines.add } : {}), ...(tableAdds.length === 0 ? {} : { adds: tableAdds }), ...(bands === undefined ? {} : { bands }), ...(flag === undefined ? {} : { flag }), ...(cellState === undefined ? {} : { cellState }), ...(rowState === undefined ? {} : { rowState }), ...(onReorder === undefined || read ? {} : { onReorder }), ...(inPlace && onRemove !== undefined
|
|
297
311
|
? /* A blank row nobody wrote in is taken back without a notice: nobody
|
|
298
312
|
removed anything, so there is nothing to undo. */
|
|
299
313
|
{ onDiscard: onRemove }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { type LineEditorState, type LineItemColumn, LineItems, type LineItemsProps, } from "./LineItems.js";
|
|
1
|
+
export { type LineAdd, type LineEditorState, type LineItemColumn, LineItems, type LineItemsProps, } from "./LineItems.js";
|
|
@@ -1,2 +1,12 @@
|
|
|
1
1
|
import type { UiCopyOverride } from "./uiCopy.js";
|
|
2
2
|
export declare const SPANISH_COPY: UiCopyOverride;
|
|
3
|
+
/**
|
|
4
|
+
* The same Spanish, in tú — what most of the region writes (Bolivia, Perú, México, Colombia…);
|
|
5
|
+
* `SPANISH_COPY` is in vos, as Argentina and Uruguay write. An application chooses once, with
|
|
6
|
+
* the framework's and the composer's tables in the same voice: three voices on one screen read
|
|
7
|
+
* as three authors.
|
|
8
|
+
*
|
|
9
|
+
* Only what is said TO the person changes — «Elegí» / «Elige», «podés» / «puedes» —; every other
|
|
10
|
+
* word is the vos table's. A new sentence that tells the person to do something goes in both.
|
|
11
|
+
*/
|
|
12
|
+
export declare const SPANISH_COPY_TU: UiCopyOverride;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { mergeCopyOver } from "./copyStore.js";
|
|
1
2
|
/* ==================================================================== *
|
|
2
3
|
* EL CASTELLANO DEL SISTEMA.
|
|
3
4
|
*
|
|
@@ -882,3 +883,55 @@ export const SPANISH_COPY = {
|
|
|
882
883
|
signature: "Firma",
|
|
883
884
|
},
|
|
884
885
|
};
|
|
886
|
+
/**
|
|
887
|
+
* The same Spanish, in tú — what most of the region writes (Bolivia, Perú, México, Colombia…);
|
|
888
|
+
* `SPANISH_COPY` is in vos, as Argentina and Uruguay write. An application chooses once, with
|
|
889
|
+
* the framework's and the composer's tables in the same voice: three voices on one screen read
|
|
890
|
+
* as three authors.
|
|
891
|
+
*
|
|
892
|
+
* Only what is said TO the person changes — «Elegí» / «Elige», «podés» / «puedes» —; every other
|
|
893
|
+
* word is the vos table's. A new sentence that tells the person to do something goes in both.
|
|
894
|
+
*/
|
|
895
|
+
export const SPANISH_COPY_TU = mergeCopyOver(SPANISH_COPY, {
|
|
896
|
+
field: {
|
|
897
|
+
drop: "Suelta un archivo acá, o elige uno.",
|
|
898
|
+
dropMany: "Suelta archivos acá, o elígelos.",
|
|
899
|
+
tryAnother: "Prueba con otro",
|
|
900
|
+
},
|
|
901
|
+
search: { typeValue: "escribe el valor", askAttribute: "elige un atributo" },
|
|
902
|
+
activity: { messagePlaceholder: "Escribe un mensaje…" },
|
|
903
|
+
richText: {
|
|
904
|
+
badLink: "Escribe una web (empresa.bo), un correo o un teléfono.",
|
|
905
|
+
badVideo: "Pega el enlace de un video de {providers}.",
|
|
906
|
+
},
|
|
907
|
+
editable: { reorderHint: "Arrástrala, o Alt + ↑ / ↓" },
|
|
908
|
+
picker: { placeholder: "elige uno…", refine: "— afina el filtro" },
|
|
909
|
+
chart: { pieNegative: "Una torta no puede mostrar valores negativos: prueba con barras." },
|
|
910
|
+
board: { moveHint: "Arrástrala, o Alt + ← / → para pasarla a otra etapa" },
|
|
911
|
+
kiosk: { start: "Toca para empezar" },
|
|
912
|
+
timeline: {
|
|
913
|
+
moveHint: "Arrástrala para moverla, su borde derecho para estirarla; Alt + flechas con el teclado",
|
|
914
|
+
},
|
|
915
|
+
attachments: {
|
|
916
|
+
emptyAdd: "Todavía no hay archivos adjuntos. Suéltalos acá o elígelos.",
|
|
917
|
+
add: "Suelta más archivos acá o elígelos.",
|
|
918
|
+
},
|
|
919
|
+
fieldPath: {
|
|
920
|
+
failedHint: "Prueba de nuevo en un momento, o copia el error para quien mantiene el modelo.",
|
|
921
|
+
},
|
|
922
|
+
preview: {
|
|
923
|
+
unsupported: "No hay vista previa para este tipo de archivo. Igual lo puedes descargar.",
|
|
924
|
+
officeSentence: "Se ve mejor en su programa. Ábrelo o descárgalo.",
|
|
925
|
+
},
|
|
926
|
+
chat: {
|
|
927
|
+
empty: "Todavía no hay mensajes. Escribe el primero.",
|
|
928
|
+
placeholder: "Escribe un mensaje… Enter lo envía, Shift+Enter hace otro renglón",
|
|
929
|
+
},
|
|
930
|
+
assist: { noneChosen: "Elige al menos un cambio." },
|
|
931
|
+
media: {
|
|
932
|
+
dropImage: "Suelta una imagen acá, pégala o elígela.",
|
|
933
|
+
notImage: "El archivo no es una imagen. Elige un PNG, JPG o WebP.",
|
|
934
|
+
cropHelp: "Arrastra la imagen o muévela con las flechas; + y − acercan y alejan.",
|
|
935
|
+
signatureHelp: "Firma con el mouse o con el dedo sobre la línea.",
|
|
936
|
+
},
|
|
937
|
+
});
|
|
@@ -17,7 +17,7 @@ export { applyTheme, ThemeProvider, type ThemeProviderProps, useTheme, } from ".
|
|
|
17
17
|
export { isTheme, type ResolvedTheme, resolveTheme, type Theme, THEME_ATTRIBUTE, THEMES, } from "./themeChoice.js";
|
|
18
18
|
export type { Density, OpenTarget, Size, Surface, Tone, } from "./types.js";
|
|
19
19
|
/** The system's Spanish, for whoever wants to install it whole. */
|
|
20
|
-
export { SPANISH_COPY } from "./copy.es.js";
|
|
20
|
+
export { SPANISH_COPY, SPANISH_COPY_TU } from "./copy.es.js";
|
|
21
21
|
export { flatten, loose, pick, pickAll, propsOf, slot, slotOf, type Slotted, } from "./slots.js";
|
|
22
22
|
export { dateKey, dateKeysBetween, dateKeyYear, dateLabel, dateTick, grainName, monthName, nextDateKey, } from "./calendar.js";
|
|
23
23
|
export { GRAIN_ORDER, type GroupableField, type GroupGrain, type Grouping, type GroupLevel, itemPath, levelKey, moveLevel, normalizeLevels, pathKey, pathLabels, type Pile, pileCount, type PileFoot, pileFoot, pileIsOpen, pileItems, pileLabel, type PileLabelOf, type PileOf, type PilePage, pilePage, pilesFoot, pilesFrom, pilesOf, type PilesPaging, } from "./grouping.js";
|
|
@@ -34,7 +34,7 @@ export { SurfaceProvider, useSurface } from "./surface.js";
|
|
|
34
34
|
export { applyTheme, ThemeProvider, useTheme, } from "./theme.js";
|
|
35
35
|
export { isTheme, resolveTheme, THEME_ATTRIBUTE, THEMES, } from "./themeChoice.js";
|
|
36
36
|
/** The system's Spanish, for whoever wants to install it whole. */
|
|
37
|
-
export { SPANISH_COPY } from "./copy.es.js";
|
|
37
|
+
export { SPANISH_COPY, SPANISH_COPY_TU } from "./copy.es.js";
|
|
38
38
|
/* THE SLOTS — how an archetype is written as a TREE. It lives here and not inside
|
|
39
39
|
one because all of them speak it: while it was hidden in
|
|
40
40
|
`Record.tsx`, being a tree was a privilege of records. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sincpro/web-ui",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.22.0",
|
|
4
4
|
"description": "An enterprise web design system for business software — ERPs, back offices, management tools — in React and Tailwind: tokens, primitives, components and the two views every management screen is made of.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|