caplink-saas-ui-shared-component-library 0.3.0 → 0.3.2
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/components/spreadsheet/lib/date-formatter.d.ts +1 -0
- package/dist/components/spreadsheet/lib/get-alphabet-columns.d.ts +1 -0
- package/dist/components/spreadsheet/lib/get-text-width-by-font.d.ts +1 -0
- package/dist/components/spreadsheet/lib/indexed-alphabet.d.ts +1 -0
- package/dist/components/spreadsheet/lib/normalize-value.d.ts +5 -0
- package/dist/components/spreadsheet/lib/one-line-string.d.ts +1 -0
- package/dist/components/spreadsheet/lib/text-overflow.d.ts +1 -0
- package/dist/components/spreadsheet/lib/use-spreadsheet.d.ts +1 -0
- package/dist/components/spreadsheet/model/matrix.d.ts +59 -0
- package/dist/components/spreadsheet/model/spreadsheet.d.ts +167 -0
- package/dist/components/spreadsheet/ui/cell.d.ts +2 -0
- package/dist/components/spreadsheet/ui/containers/index.d.ts +7 -0
- package/dist/components/spreadsheet/ui/containers/matrix.d.ts +7 -0
- package/dist/components/spreadsheet/ui/containers/root.d.ts +7 -0
- package/dist/components/spreadsheet/ui/context.d.ts +4 -0
- package/dist/components/spreadsheet/ui/data-editor/boolean.d.ts +3 -0
- package/dist/components/spreadsheet/ui/data-editor/date.d.ts +3 -0
- package/dist/components/spreadsheet/ui/data-editor/index.d.ts +20 -0
- package/dist/components/spreadsheet/ui/data-editor/numeric.d.ts +3 -0
- package/dist/components/spreadsheet/ui/data-editor/select.d.ts +7 -0
- package/dist/components/spreadsheet/ui/data-editor/text.d.ts +3 -0
- package/dist/components/spreadsheet/ui/header.d.ts +1 -0
- package/dist/components/spreadsheet/ui/icons/add-row-icon.d.ts +3 -0
- package/dist/components/spreadsheet/ui/icons/integer-icon.d.ts +3 -0
- package/dist/components/spreadsheet/ui/icons/remove-row-icon.d.ts +3 -0
- package/dist/components/spreadsheet/ui/index.d.ts +3 -0
- package/dist/components/spreadsheet/ui/indicators/column-indicator.d.ts +11 -0
- package/dist/components/spreadsheet/ui/indicators/column-title-indicator.d.ts +9 -0
- package/dist/components/spreadsheet/ui/indicators/corner-indicator.d.ts +3 -0
- package/dist/components/spreadsheet/ui/indicators/drag-indicator.d.ts +10 -0
- package/dist/components/spreadsheet/ui/indicators/row-indicator.d.ts +3 -0
- package/dist/components/spreadsheet/ui/rows.d.ts +1 -0
- package/dist/components/spreadsheet/ui/start.d.ts +3 -0
- package/dist/components/spreadsheet/ui/toolbar.d.ts +1 -0
- package/dist/components/tmp/numeric.d.ts +25 -0
- package/dist/index.d.ts +7 -323
- package/dist/index.es.js +2032 -2005
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +34 -34
- package/dist/index.umd.js.map +1 -1
- package/dist/shared/lib/cn.d.ts +3 -0
- package/dist/shared/lib/move-input-cursor-to-end.d.ts +2 -0
- package/dist/shared/lib/read-text-from-clipboard.d.ts +5 -0
- package/dist/shared/lib/use-focused.d.ts +3 -0
- package/dist/shared/lib/use-select-on-focus.d.ts +3 -0
- package/dist/shared/ui/button.d.ts +12 -0
- package/dist/shared/ui/dropdown-menu.d.ts +27 -0
- package/dist/shared/ui/input.d.ts +5 -0
- package/dist/shared/ui/select.d.ts +13 -0
- package/dist/shared/ui/tooltip.d.ts +7 -0
- package/dist/stories/spreadsheet.stories.d.ts +21 -0
- package/dist/types.d.ts +3 -0
- package/package.json +10 -15
package/dist/index.d.ts
CHANGED
|
@@ -1,323 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
/** Spreadsheet Cell component */
|
|
10
|
-
declare type Cell = {
|
|
11
|
-
/** The cell value */
|
|
12
|
-
value?: unknown;
|
|
13
|
-
/** Point coordinates of the cell */
|
|
14
|
-
coordinates: MatrixTypes.Point;
|
|
15
|
-
width: number;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
/** Spreadsheet cell initial height */
|
|
19
|
-
declare const CELL_INITIAL_HEIGHT = 26;
|
|
20
|
-
|
|
21
|
-
/** Spreadsheet column meta data and settings */
|
|
22
|
-
declare type Column = {
|
|
23
|
-
/** Column identifier */
|
|
24
|
-
id: string;
|
|
25
|
-
/** Column name to be displayed */
|
|
26
|
-
name: string;
|
|
27
|
-
/** Column tooltip description */
|
|
28
|
-
description?: string;
|
|
29
|
-
/** Column position */
|
|
30
|
-
position: number;
|
|
31
|
-
/** Column data editor type */
|
|
32
|
-
dataEditorType: DataEditorType;
|
|
33
|
-
/** Alphabet letter by position */
|
|
34
|
-
alphabetLetter?: string;
|
|
35
|
-
/** Column element states */
|
|
36
|
-
state: ColumnState;
|
|
37
|
-
/** Column settings */
|
|
38
|
-
settings?: ColumnSettings;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
/** Spreadsheet column initial width */
|
|
42
|
-
declare const COLUMN_INITIAL_WIDTH = 160;
|
|
43
|
-
|
|
44
|
-
/** Spreadsheet column max width */
|
|
45
|
-
declare const COLUMN_MAX_WIDTH = 480;
|
|
46
|
-
|
|
47
|
-
/** Spreadsheet column min width */
|
|
48
|
-
declare const COLUMN_MIN_WIDTH: number;
|
|
49
|
-
|
|
50
|
-
/** Spreadsheet column title single char length */
|
|
51
|
-
declare const COLUMN_TITLE_CHAR_LENGTH = 12;
|
|
52
|
-
|
|
53
|
-
declare const COLUMN_TITLE_CONTAINER_PADDING_X = 16;
|
|
54
|
-
|
|
55
|
-
declare const COLUMN_TITLE_ICON_WIDTH = 16;
|
|
56
|
-
|
|
57
|
-
/** Spreadsheet column title initial height */
|
|
58
|
-
declare const COLUMN_TITLE_INITIAL_HEIGHT = 36;
|
|
59
|
-
|
|
60
|
-
declare type ColumnSettings = {
|
|
61
|
-
select?: {
|
|
62
|
-
items: Array<SelectItem>;
|
|
63
|
-
};
|
|
64
|
-
numeric?: {
|
|
65
|
-
min?: number;
|
|
66
|
-
max?: number;
|
|
67
|
-
allowNegative?: boolean;
|
|
68
|
-
roundingRule?: string;
|
|
69
|
-
decimalScale?: number;
|
|
70
|
-
currency?: string;
|
|
71
|
-
};
|
|
72
|
-
string?: {
|
|
73
|
-
maskData?: string;
|
|
74
|
-
maskVisible?: boolean;
|
|
75
|
-
charLimit?: number;
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
declare type ColumnState = {
|
|
80
|
-
/** Whether column is readonly to user */
|
|
81
|
-
readonly?: boolean;
|
|
82
|
-
/** Whether column is visible to user */
|
|
83
|
-
visible?: boolean;
|
|
84
|
-
/** Column width in px */
|
|
85
|
-
width: number;
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
declare type Context = {
|
|
89
|
-
size: MatrixTypes.Size;
|
|
90
|
-
matrix: MatrixTypes.Matrix<unknown>;
|
|
91
|
-
columns: Column[];
|
|
92
|
-
emptySize: boolean;
|
|
93
|
-
/** Defines if user can add or delete rows */
|
|
94
|
-
staticRows?: boolean;
|
|
95
|
-
hasSomeEntireRow?: boolean;
|
|
96
|
-
/** Whether last row is highlighted */
|
|
97
|
-
highlightLastRow?: boolean;
|
|
98
|
-
pointRange: MatrixTypes.PointRange | null;
|
|
99
|
-
setPointRange: (pointRange: MatrixTypes.PointRange | null) => void;
|
|
100
|
-
containerDimensions: Dimensions;
|
|
101
|
-
setContainerDimensions: (dimensions: Dimensions) => void;
|
|
102
|
-
onPaste: (point: MatrixTypes.Point) => void;
|
|
103
|
-
onChange: (params: {
|
|
104
|
-
data: unknown;
|
|
105
|
-
point: MatrixTypes.Point;
|
|
106
|
-
}) => void;
|
|
107
|
-
onRemoveRow: () => void;
|
|
108
|
-
onSelectRow: (row: number, event?: MouseEvent_2) => void;
|
|
109
|
-
onSelectCell: (point: MatrixTypes.Point) => void;
|
|
110
|
-
isCellSelected: (point: MatrixTypes.Point) => boolean;
|
|
111
|
-
onInsertNewRow: () => void;
|
|
112
|
-
onColumnResize: (params: {
|
|
113
|
-
width: number;
|
|
114
|
-
position: number;
|
|
115
|
-
}) => void;
|
|
116
|
-
onSelectSpreadsheet: () => void;
|
|
117
|
-
onColumnVisibilityChange: (params: {
|
|
118
|
-
columnId: string;
|
|
119
|
-
visible?: boolean;
|
|
120
|
-
}) => void;
|
|
121
|
-
onRestoreColumnsVisibility: () => void;
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
declare type ContextProvider = Omit<PropsWithChildren<Props>, 'className'>;
|
|
125
|
-
|
|
126
|
-
/** Creates an empty matrix with given rows and columns */
|
|
127
|
-
declare function createEmpty<T>(size: Size, fill?: T): Matrix<T>;
|
|
128
|
-
|
|
129
|
-
declare type DataEditor = {
|
|
130
|
-
mode: Mode;
|
|
131
|
-
/** Data editor current value */
|
|
132
|
-
value?: unknown;
|
|
133
|
-
/** Whether data editor data changes */
|
|
134
|
-
onChange?: ({ data, point }: {
|
|
135
|
-
data: unknown;
|
|
136
|
-
point?: MatrixTypes.Point;
|
|
137
|
-
}) => void;
|
|
138
|
-
/** Whether user paste any value on data editor */
|
|
139
|
-
onPaste?: (point?: MatrixTypes.Point) => void;
|
|
140
|
-
/** Whether user blur current data editor */
|
|
141
|
-
onBlur?: () => void;
|
|
142
|
-
/** Whether user clicks current data editor */
|
|
143
|
-
onClick?: <T>(e: MouseEvent_2<T>) => void;
|
|
144
|
-
/** Cell mode setter */
|
|
145
|
-
setMode?: (mode: Mode) => void;
|
|
146
|
-
selected?: boolean;
|
|
147
|
-
column: Column;
|
|
148
|
-
width: number;
|
|
149
|
-
coordinates: MatrixTypes.Point;
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
/** Cell data editor type */
|
|
153
|
-
declare type DataEditorType = 'Boolean' | 'String' | 'Select' | 'Date' | 'Integer' | 'Currency' | 'Float' | 'Decimal' | 'Percentage';
|
|
154
|
-
|
|
155
|
-
declare type DataViewer = {
|
|
156
|
-
width: number;
|
|
157
|
-
mode: Mode;
|
|
158
|
-
/** Data viewer current value */
|
|
159
|
-
value?: unknown;
|
|
160
|
-
column: Column;
|
|
161
|
-
coordinates: MatrixTypes.Point;
|
|
162
|
-
selected?: boolean;
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
/** Dimensions of an element */
|
|
166
|
-
declare type Dimensions = {
|
|
167
|
-
/** The element's width in pixels */
|
|
168
|
-
width: number;
|
|
169
|
-
/** The element's height in pixels */
|
|
170
|
-
height: number;
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
/** Gets the count of columns of given matrix */
|
|
174
|
-
declare function getColumnsCount(matrix: Matrix<unknown>): number;
|
|
175
|
-
|
|
176
|
-
/** Gets the value at row and column of matrix. */
|
|
177
|
-
declare function getPoint<T>(params: {
|
|
178
|
-
point: Point;
|
|
179
|
-
matrix: Matrix<T>;
|
|
180
|
-
}): T | undefined;
|
|
181
|
-
|
|
182
|
-
/** Gets the count of rows of given matrix */
|
|
183
|
-
declare function getRowsCount(matrix: Matrix<unknown>): number;
|
|
184
|
-
|
|
185
|
-
/** Gets the count of rows and columns of given matrix */
|
|
186
|
-
declare function getSize(matrix: Matrix<unknown>): Size;
|
|
187
|
-
|
|
188
|
-
/** Determines whether all columns are selected */
|
|
189
|
-
declare function hasEntireColumns(params: {
|
|
190
|
-
matrix: Matrix<unknown>;
|
|
191
|
-
pointRange: PointRange;
|
|
192
|
-
}): boolean;
|
|
193
|
-
|
|
194
|
-
/** Determines which row is entirely selected in given selection */
|
|
195
|
-
declare function hasEntireRows(params: {
|
|
196
|
-
matrix: Matrix<unknown>;
|
|
197
|
-
pointRange: PointRange;
|
|
198
|
-
row: number;
|
|
199
|
-
}): boolean;
|
|
200
|
-
|
|
201
|
-
/** Returns whether given point exists in given range */
|
|
202
|
-
declare function hasPointInRange(pointRange: PointRange, point: Point): boolean;
|
|
203
|
-
|
|
204
|
-
/** Initial column params before spreadsheet internal setup */
|
|
205
|
-
declare type InitialColumn = Pick<Column, Exclude<keyof Column, 'alphabetLetter' | 'position' | 'width'>>;
|
|
206
|
-
|
|
207
|
-
/** Checks if the source and target point are equal */
|
|
208
|
-
declare function isSamePoint(source: Point, target: Point): boolean;
|
|
209
|
-
|
|
210
|
-
declare type Matrix<T> = Array<Array<T | undefined>>;
|
|
211
|
-
|
|
212
|
-
declare namespace MatrixTypes {
|
|
213
|
-
export {
|
|
214
|
-
createEmpty,
|
|
215
|
-
getRowsCount,
|
|
216
|
-
getColumnsCount,
|
|
217
|
-
getSize,
|
|
218
|
-
getPoint,
|
|
219
|
-
isSamePoint,
|
|
220
|
-
hasPointInRange,
|
|
221
|
-
hasEntireColumns,
|
|
222
|
-
hasEntireRows,
|
|
223
|
-
parseString,
|
|
224
|
-
overlap,
|
|
225
|
-
Point,
|
|
226
|
-
PointRange,
|
|
227
|
-
Size,
|
|
228
|
-
Matrix
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
export { MatrixTypes }
|
|
232
|
-
|
|
233
|
-
/** The mode of the cell */
|
|
234
|
-
declare type Mode = 'edit' | 'readonly' | 'view';
|
|
235
|
-
|
|
236
|
-
declare const NUMERIC_DATA_EDITOR_TYPES: readonly DataEditorType[];
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* Overlaps a given Matrix B (mB) starting in a specific point into a given Matrix A (mA)
|
|
240
|
-
* Matrix B (mB) always has priority when replacing cell values
|
|
241
|
-
*/
|
|
242
|
-
declare function overlap(params: {
|
|
243
|
-
mA: Matrix<unknown>;
|
|
244
|
-
mB: Matrix<unknown>;
|
|
245
|
-
point: Point;
|
|
246
|
-
}): Matrix<unknown>;
|
|
247
|
-
|
|
248
|
-
/** Converts string value into an matrix */
|
|
249
|
-
declare function parseString(value: string): Matrix<unknown>;
|
|
250
|
-
|
|
251
|
-
/** A cell cordinates in matrix */
|
|
252
|
-
declare type Point = {
|
|
253
|
-
row: number;
|
|
254
|
-
column: number;
|
|
255
|
-
};
|
|
256
|
-
|
|
257
|
-
/** Range between two points. */
|
|
258
|
-
declare type PointRange = {
|
|
259
|
-
/** The top-left point */
|
|
260
|
-
start: Point;
|
|
261
|
-
/** The bottom-right point */
|
|
262
|
-
end: Point;
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
declare type Props = {
|
|
266
|
-
matrix: MatrixTypes.Matrix<unknown>;
|
|
267
|
-
onMatrixChange?: (matrix: MatrixTypes.Matrix<unknown>) => void;
|
|
268
|
-
startingColumns: InitialColumn[];
|
|
269
|
-
/** Defines if user can add or delete rows */
|
|
270
|
-
staticRows?: boolean;
|
|
271
|
-
className?: string;
|
|
272
|
-
};
|
|
273
|
-
|
|
274
|
-
/** Select component item props */
|
|
275
|
-
declare type SelectItem = {
|
|
276
|
-
text: string;
|
|
277
|
-
value: string;
|
|
278
|
-
};
|
|
279
|
-
|
|
280
|
-
/** Spreadsheet columns internal states and values setup function */
|
|
281
|
-
declare function setupColumns(columns: InitialColumn[]): Column[];
|
|
282
|
-
|
|
283
|
-
/** Counts of the rows and column in a matrix */
|
|
284
|
-
declare type Size = {
|
|
285
|
-
/** Count of the rows in the matrix */
|
|
286
|
-
rows: number;
|
|
287
|
-
/** Count of the columns in the matrix */
|
|
288
|
-
columns: number;
|
|
289
|
-
};
|
|
290
|
-
|
|
291
|
-
declare function Spreadsheet(props: Props): JSX_2.Element;
|
|
292
|
-
|
|
293
|
-
declare namespace SpreadsheetTypes {
|
|
294
|
-
export {
|
|
295
|
-
setupColumns,
|
|
296
|
-
COLUMN_TITLE_CONTAINER_PADDING_X,
|
|
297
|
-
COLUMN_TITLE_ICON_WIDTH,
|
|
298
|
-
COLUMN_INITIAL_WIDTH,
|
|
299
|
-
COLUMN_MAX_WIDTH,
|
|
300
|
-
COLUMN_MIN_WIDTH,
|
|
301
|
-
COLUMN_TITLE_CHAR_LENGTH,
|
|
302
|
-
COLUMN_TITLE_INITIAL_HEIGHT,
|
|
303
|
-
CELL_INITIAL_HEIGHT,
|
|
304
|
-
NUMERIC_DATA_EDITOR_TYPES,
|
|
305
|
-
Dimensions,
|
|
306
|
-
SelectItem,
|
|
307
|
-
Mode,
|
|
308
|
-
DataEditorType,
|
|
309
|
-
DataEditor,
|
|
310
|
-
DataViewer,
|
|
311
|
-
ColumnState,
|
|
312
|
-
ColumnSettings,
|
|
313
|
-
Column,
|
|
314
|
-
InitialColumn,
|
|
315
|
-
Cell,
|
|
316
|
-
Props,
|
|
317
|
-
Context,
|
|
318
|
-
ContextProvider
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
export { SpreadsheetTypes }
|
|
322
|
-
|
|
323
|
-
export { }
|
|
1
|
+
import { Spreadsheet } from './components/spreadsheet/ui';
|
|
2
|
+
import { MatrixTypes, SpreadsheetTypes } from './types';
|
|
3
|
+
|
|
4
|
+
export declare const CapLink: {
|
|
5
|
+
Spreadsheet: typeof Spreadsheet;
|
|
6
|
+
};
|
|
7
|
+
export type { MatrixTypes, SpreadsheetTypes };
|