math-main-components 0.0.46 → 0.0.48
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/Checkbox/Checkbox.d.ts +3 -3
- package/dist/components/CopyCode/CopyCode.d.ts +2 -2
- package/dist/components/Searchbar/Searchbar.d.ts +8 -4
- package/dist/components/Table/Table.d.ts +11 -11
- package/dist/index.cjs.js +25 -13
- package/dist/index.esm.js +25 -13
- package/package.json +1 -1
@@ -1,7 +1,7 @@
|
|
1
|
-
import React, {
|
1
|
+
import React, { ChangeEvent, ReactNode } from 'react';
|
2
2
|
export declare function Checkbox({ text, name, defaultChecked, onInput, }: {
|
3
|
-
text:
|
3
|
+
text: ReactNode;
|
4
4
|
name: string;
|
5
|
-
onInput?: (event:
|
5
|
+
onInput?: (event: ChangeEvent<HTMLInputElement>) => void;
|
6
6
|
defaultChecked?: boolean;
|
7
7
|
}): React.JSX.Element;
|
@@ -1,5 +1,9 @@
|
|
1
1
|
import React, { ChangeEvent, MouseEvent } from 'react';
|
2
|
-
export
|
2
|
+
export type SearchResult = {
|
3
|
+
title: string;
|
4
|
+
data: unknown;
|
5
|
+
};
|
6
|
+
export declare function Searchbar<Type extends SearchResult>({ placeholder, title, showNoResults, errorTitle, errorMessage, errorButton, helpTitle, helpMessage, errorAction, onInput, onClickResult, withButton, buttonText, suggestions, autoFocus, results }: {
|
3
7
|
placeholder: string;
|
4
8
|
title?: string;
|
5
9
|
showNoResults?: boolean;
|
@@ -10,10 +14,10 @@ export declare function Searchbar({ placeholder, title, showNoResults, errorTitl
|
|
10
14
|
helpMessage?: string;
|
11
15
|
errorAction?: (event: MouseEvent<HTMLButtonElement>) => void;
|
12
16
|
onInput?: (event: ChangeEvent<HTMLInputElement>) => void;
|
13
|
-
onClickResult?: (event: MouseEvent<HTMLLIElement>, result:
|
17
|
+
onClickResult?: (event: MouseEvent<HTMLLIElement>, result: Type) => void;
|
14
18
|
withButton?: boolean;
|
15
19
|
buttonText?: string;
|
16
|
-
suggestions?:
|
20
|
+
suggestions?: string[];
|
17
21
|
autoFocus?: boolean;
|
18
|
-
results?:
|
22
|
+
results?: Type[];
|
19
23
|
}): React.JSX.Element;
|
@@ -1,26 +1,26 @@
|
|
1
|
-
import React, { MouseEvent } from 'react';
|
1
|
+
import React, { MouseEvent, ReactNode } from 'react';
|
2
2
|
export declare enum TableActionType {
|
3
3
|
red = 0,
|
4
4
|
default = 1
|
5
5
|
}
|
6
|
-
export declare class TableItem {
|
6
|
+
export declare class TableItem<DataType> {
|
7
7
|
title: string;
|
8
8
|
subtitle: string;
|
9
9
|
moreText: string;
|
10
10
|
iconName: string;
|
11
|
-
data:
|
12
|
-
constructor(title: string, subtitle: string, moreText: string, iconName: string, data
|
11
|
+
data: DataType;
|
12
|
+
constructor(title: string, subtitle: string, moreText: string, iconName: string, data: DataType);
|
13
13
|
}
|
14
|
-
export declare class TableItemAction {
|
14
|
+
export declare class TableItemAction<DataType> {
|
15
15
|
title: string;
|
16
16
|
iconName: string;
|
17
|
-
onClick: (event: MouseEvent<HTMLDivElement>, item: TableItem
|
17
|
+
onClick: (event: MouseEvent<HTMLDivElement>, item: TableItem<DataType>, index: number) => void;
|
18
18
|
type: TableActionType;
|
19
|
-
constructor(title: string, iconName: string, type: TableActionType, onClick?: (event: MouseEvent<HTMLDivElement>, item: TableItem
|
19
|
+
constructor(title: string, iconName: string, type: TableActionType, onClick?: (event: MouseEvent<HTMLDivElement>, item: TableItem<DataType>, index: number) => void);
|
20
20
|
}
|
21
|
-
export declare function Table({ items, title, actions, moreActions }: {
|
22
|
-
items: TableItem[];
|
21
|
+
export declare function Table<DataType>({ items, title, actions, moreActions }: {
|
22
|
+
items: TableItem<DataType>[];
|
23
23
|
title: string;
|
24
|
-
actions?: TableItemAction[];
|
25
|
-
moreActions?:
|
24
|
+
actions?: TableItemAction<DataType>[];
|
25
|
+
moreActions?: ((data: DataType, index: number) => ReactNode)[];
|
26
26
|
}): React.JSX.Element;
|
package/dist/index.cjs.js
CHANGED
@@ -84,11 +84,10 @@ var styles$p = {"container":"styles-module_container__gCCnD"};
|
|
84
84
|
styleInject(css_248z$p);
|
85
85
|
|
86
86
|
function Checkbox({ text, name, defaultChecked = false, onInput = () => { }, }) {
|
87
|
-
return (React__default["default"].createElement(
|
88
|
-
React__default["default"].createElement("
|
89
|
-
|
90
|
-
|
91
|
-
React__default["default"].createElement(SvgIcon, { iconName: "done", size: "21px" }))));
|
87
|
+
return (React__default["default"].createElement("div", { className: styles$p.container },
|
88
|
+
React__default["default"].createElement("input", { type: "checkbox", onInput: onInput, name: name, id: name, defaultChecked: defaultChecked }),
|
89
|
+
React__default["default"].createElement("label", { htmlFor: name }, text),
|
90
|
+
React__default["default"].createElement(SvgIcon, { iconName: "done", size: "21px" })));
|
92
91
|
}
|
93
92
|
|
94
93
|
var css_248z$o = ".styles-module_container__OqDNA {\n display: flex;\n flex-direction: row;\n}\n.styles-module_container__OqDNA .styles-module_item__1SMCI:nth-child(1) {\n background: #F0F0F0;\n border-color: #F0F0F0;\n}\n.styles-module_container__OqDNA .styles-module_item__1SMCI:nth-child(2) {\n background: #E0E0E0;\n border-color: #E0E0E0;\n}\n.styles-module_container__OqDNA .styles-module_item__1SMCI:nth-child(3) {\n background: #CBCBCB;\n border-color: #CBCBCB;\n}\n.styles-module_container__OqDNA .styles-module_item__1SMCI:first-child {\n border-top-left-radius: 20px;\n border-bottom-left-radius: 20px;\n}\n.styles-module_container__OqDNA .styles-module_item__1SMCI:last-child {\n border-top-right-radius: 20px;\n border-bottom-right-radius: 20px;\n}\n.styles-module_container__OqDNA .styles-module_item__1SMCI {\n border: 1px solid transparent;\n padding: 11px 18px;\n font-size: 14px;\n cursor: pointer;\n transition: 0.2s ease-in-out;\n user-select: none;\n -webkit-user-select: none;\n}\n.styles-module_container__OqDNA .styles-module_item__1SMCI.styles-module_selected__AXIA- {\n background: #C6D4F8;\n border-color: #0075FF;\n color: #0075FF;\n}";
|
@@ -289,7 +288,9 @@ function InputPin({ name, length, onFinished = () => { } }) {
|
|
289
288
|
const addedDigitsCount = value.length - digitCountBefore;
|
290
289
|
// One digit was added
|
291
290
|
if (addedDigitsCount == 1) {
|
292
|
-
fieldRefs.current[(position + 1) % length]
|
291
|
+
const nextFieldRef = fieldRefs.current[(position + 1) % length];
|
292
|
+
if (nextFieldRef.current)
|
293
|
+
nextFieldRef.current.focus();
|
293
294
|
setDigit(position, value.slice(-1));
|
294
295
|
return;
|
295
296
|
}
|
@@ -299,10 +300,14 @@ function InputPin({ name, length, onFinished = () => { } }) {
|
|
299
300
|
let newState = { ...state };
|
300
301
|
digits.forEach((digit, relativePosition) => {
|
301
302
|
newState[relativePosition % length + position] = digit;
|
302
|
-
fieldRefs.current[relativePosition % length + position]
|
303
|
+
const fieldRef = fieldRefs.current[relativePosition % length + position];
|
304
|
+
if (fieldRef.current)
|
305
|
+
fieldRef.current.value = digit;
|
303
306
|
});
|
304
307
|
if (digits.length >= 6) {
|
305
|
-
fieldRefs.current[length - 1]
|
308
|
+
const lastFieldRef = fieldRefs.current[length - 1];
|
309
|
+
if (lastFieldRef.current)
|
310
|
+
lastFieldRef.current.focus();
|
306
311
|
}
|
307
312
|
setState(newState);
|
308
313
|
}
|
@@ -310,21 +315,28 @@ function InputPin({ name, length, onFinished = () => { } }) {
|
|
310
315
|
event.preventDefault();
|
311
316
|
// Keys: Backspace, Arrow left
|
312
317
|
if ([8, 37].includes(event.keyCode)) {
|
313
|
-
fieldRefs.current[(((position) - 1) + length) % length]
|
318
|
+
const beforeFieldRef = fieldRefs.current[(((position) - 1) + length) % length];
|
319
|
+
if (beforeFieldRef.current)
|
320
|
+
beforeFieldRef.current.focus();
|
314
321
|
}
|
315
322
|
// Keys: Tab (automatically), Arrow Right
|
316
323
|
if ([39].includes(event.keyCode)) {
|
317
|
-
fieldRefs.current[(position + 1) % length]
|
324
|
+
const nextFieldRef = fieldRefs.current[(position + 1) % length];
|
325
|
+
if (nextFieldRef.current)
|
326
|
+
nextFieldRef.current.focus();
|
318
327
|
}
|
319
328
|
}
|
320
329
|
function setDigit(position, digit) {
|
321
|
-
fieldRefs.current[position % length]
|
330
|
+
const fieldRef = fieldRefs.current[position % length];
|
331
|
+
if (fieldRef.current)
|
332
|
+
fieldRef.current.value = digit;
|
322
333
|
setState({ ...state, [position % length]: digit });
|
323
334
|
}
|
324
335
|
function resetValues() {
|
325
336
|
setState({});
|
326
337
|
fieldRefs.current.forEach((ref) => {
|
327
|
-
ref.current
|
338
|
+
if (ref.current)
|
339
|
+
ref.current.value = "";
|
328
340
|
});
|
329
341
|
}
|
330
342
|
return (React__default["default"].createElement("div", { className: styles$e.container },
|
@@ -599,7 +611,7 @@ class TableItem {
|
|
599
611
|
moreText;
|
600
612
|
iconName;
|
601
613
|
data;
|
602
|
-
constructor(title, subtitle, moreText, iconName, data
|
614
|
+
constructor(title, subtitle, moreText, iconName, data) {
|
603
615
|
this.title = title;
|
604
616
|
this.subtitle = subtitle;
|
605
617
|
this.moreText = moreText;
|
package/dist/index.esm.js
CHANGED
@@ -76,11 +76,10 @@ var styles$p = {"container":"styles-module_container__gCCnD"};
|
|
76
76
|
styleInject(css_248z$p);
|
77
77
|
|
78
78
|
function Checkbox({ text, name, defaultChecked = false, onInput = () => { }, }) {
|
79
|
-
return (React.createElement(
|
80
|
-
React.createElement("
|
81
|
-
|
82
|
-
|
83
|
-
React.createElement(SvgIcon, { iconName: "done", size: "21px" }))));
|
79
|
+
return (React.createElement("div", { className: styles$p.container },
|
80
|
+
React.createElement("input", { type: "checkbox", onInput: onInput, name: name, id: name, defaultChecked: defaultChecked }),
|
81
|
+
React.createElement("label", { htmlFor: name }, text),
|
82
|
+
React.createElement(SvgIcon, { iconName: "done", size: "21px" })));
|
84
83
|
}
|
85
84
|
|
86
85
|
var css_248z$o = ".styles-module_container__OqDNA {\n display: flex;\n flex-direction: row;\n}\n.styles-module_container__OqDNA .styles-module_item__1SMCI:nth-child(1) {\n background: #F0F0F0;\n border-color: #F0F0F0;\n}\n.styles-module_container__OqDNA .styles-module_item__1SMCI:nth-child(2) {\n background: #E0E0E0;\n border-color: #E0E0E0;\n}\n.styles-module_container__OqDNA .styles-module_item__1SMCI:nth-child(3) {\n background: #CBCBCB;\n border-color: #CBCBCB;\n}\n.styles-module_container__OqDNA .styles-module_item__1SMCI:first-child {\n border-top-left-radius: 20px;\n border-bottom-left-radius: 20px;\n}\n.styles-module_container__OqDNA .styles-module_item__1SMCI:last-child {\n border-top-right-radius: 20px;\n border-bottom-right-radius: 20px;\n}\n.styles-module_container__OqDNA .styles-module_item__1SMCI {\n border: 1px solid transparent;\n padding: 11px 18px;\n font-size: 14px;\n cursor: pointer;\n transition: 0.2s ease-in-out;\n user-select: none;\n -webkit-user-select: none;\n}\n.styles-module_container__OqDNA .styles-module_item__1SMCI.styles-module_selected__AXIA- {\n background: #C6D4F8;\n border-color: #0075FF;\n color: #0075FF;\n}";
|
@@ -281,7 +280,9 @@ function InputPin({ name, length, onFinished = () => { } }) {
|
|
281
280
|
const addedDigitsCount = value.length - digitCountBefore;
|
282
281
|
// One digit was added
|
283
282
|
if (addedDigitsCount == 1) {
|
284
|
-
fieldRefs.current[(position + 1) % length]
|
283
|
+
const nextFieldRef = fieldRefs.current[(position + 1) % length];
|
284
|
+
if (nextFieldRef.current)
|
285
|
+
nextFieldRef.current.focus();
|
285
286
|
setDigit(position, value.slice(-1));
|
286
287
|
return;
|
287
288
|
}
|
@@ -291,10 +292,14 @@ function InputPin({ name, length, onFinished = () => { } }) {
|
|
291
292
|
let newState = { ...state };
|
292
293
|
digits.forEach((digit, relativePosition) => {
|
293
294
|
newState[relativePosition % length + position] = digit;
|
294
|
-
fieldRefs.current[relativePosition % length + position]
|
295
|
+
const fieldRef = fieldRefs.current[relativePosition % length + position];
|
296
|
+
if (fieldRef.current)
|
297
|
+
fieldRef.current.value = digit;
|
295
298
|
});
|
296
299
|
if (digits.length >= 6) {
|
297
|
-
fieldRefs.current[length - 1]
|
300
|
+
const lastFieldRef = fieldRefs.current[length - 1];
|
301
|
+
if (lastFieldRef.current)
|
302
|
+
lastFieldRef.current.focus();
|
298
303
|
}
|
299
304
|
setState(newState);
|
300
305
|
}
|
@@ -302,21 +307,28 @@ function InputPin({ name, length, onFinished = () => { } }) {
|
|
302
307
|
event.preventDefault();
|
303
308
|
// Keys: Backspace, Arrow left
|
304
309
|
if ([8, 37].includes(event.keyCode)) {
|
305
|
-
fieldRefs.current[(((position) - 1) + length) % length]
|
310
|
+
const beforeFieldRef = fieldRefs.current[(((position) - 1) + length) % length];
|
311
|
+
if (beforeFieldRef.current)
|
312
|
+
beforeFieldRef.current.focus();
|
306
313
|
}
|
307
314
|
// Keys: Tab (automatically), Arrow Right
|
308
315
|
if ([39].includes(event.keyCode)) {
|
309
|
-
fieldRefs.current[(position + 1) % length]
|
316
|
+
const nextFieldRef = fieldRefs.current[(position + 1) % length];
|
317
|
+
if (nextFieldRef.current)
|
318
|
+
nextFieldRef.current.focus();
|
310
319
|
}
|
311
320
|
}
|
312
321
|
function setDigit(position, digit) {
|
313
|
-
fieldRefs.current[position % length]
|
322
|
+
const fieldRef = fieldRefs.current[position % length];
|
323
|
+
if (fieldRef.current)
|
324
|
+
fieldRef.current.value = digit;
|
314
325
|
setState({ ...state, [position % length]: digit });
|
315
326
|
}
|
316
327
|
function resetValues() {
|
317
328
|
setState({});
|
318
329
|
fieldRefs.current.forEach((ref) => {
|
319
|
-
ref.current
|
330
|
+
if (ref.current)
|
331
|
+
ref.current.value = "";
|
320
332
|
});
|
321
333
|
}
|
322
334
|
return (React.createElement("div", { className: styles$e.container },
|
@@ -591,7 +603,7 @@ class TableItem {
|
|
591
603
|
moreText;
|
592
604
|
iconName;
|
593
605
|
data;
|
594
|
-
constructor(title, subtitle, moreText, iconName, data
|
606
|
+
constructor(title, subtitle, moreText, iconName, data) {
|
595
607
|
this.title = title;
|
596
608
|
this.subtitle = subtitle;
|
597
609
|
this.moreText = moreText;
|