math-main-components 0.0.45 → 0.0.47
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 +2 -2
- 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 +27 -14
- package/dist/index.esm.js +27 -14
- package/package.json +1 -1
@@ -1,6 +1,6 @@
|
|
1
|
-
import React, { MouseEvent } from 'react';
|
1
|
+
import React, { MouseEvent, ReactNode } from 'react';
|
2
2
|
export declare function Checkbox({ text, name, defaultChecked, onInput, }: {
|
3
|
-
text:
|
3
|
+
text: ReactNode;
|
4
4
|
name: string;
|
5
5
|
onInput?: (event: MouseEvent<HTMLInputElement>) => void;
|
6
6
|
defaultChecked?: boolean;
|
@@ -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}";
|
@@ -137,7 +136,8 @@ styleInject(css_248z$m);
|
|
137
136
|
function Dialog({ data, text, onClose, onSubmit, children }) {
|
138
137
|
function onClick(event) {
|
139
138
|
event.preventDefault();
|
140
|
-
const
|
139
|
+
const element = event.target;
|
140
|
+
const id = element.id;
|
141
141
|
if (["dialog-backdrop", "cancel-button"].includes(id)) {
|
142
142
|
if (onClose)
|
143
143
|
onClose(event, data?.data);
|
@@ -288,7 +288,9 @@ function InputPin({ name, length, onFinished = () => { } }) {
|
|
288
288
|
const addedDigitsCount = value.length - digitCountBefore;
|
289
289
|
// One digit was added
|
290
290
|
if (addedDigitsCount == 1) {
|
291
|
-
fieldRefs.current[(position + 1) % length]
|
291
|
+
const nextFieldRef = fieldRefs.current[(position + 1) % length];
|
292
|
+
if (nextFieldRef.current)
|
293
|
+
nextFieldRef.current.focus();
|
292
294
|
setDigit(position, value.slice(-1));
|
293
295
|
return;
|
294
296
|
}
|
@@ -298,10 +300,14 @@ function InputPin({ name, length, onFinished = () => { } }) {
|
|
298
300
|
let newState = { ...state };
|
299
301
|
digits.forEach((digit, relativePosition) => {
|
300
302
|
newState[relativePosition % length + position] = digit;
|
301
|
-
fieldRefs.current[relativePosition % length + position]
|
303
|
+
const fieldRef = fieldRefs.current[relativePosition % length + position];
|
304
|
+
if (fieldRef.current)
|
305
|
+
fieldRef.current.value = digit;
|
302
306
|
});
|
303
307
|
if (digits.length >= 6) {
|
304
|
-
fieldRefs.current[length - 1]
|
308
|
+
const lastFieldRef = fieldRefs.current[length - 1];
|
309
|
+
if (lastFieldRef.current)
|
310
|
+
lastFieldRef.current.focus();
|
305
311
|
}
|
306
312
|
setState(newState);
|
307
313
|
}
|
@@ -309,21 +315,28 @@ function InputPin({ name, length, onFinished = () => { } }) {
|
|
309
315
|
event.preventDefault();
|
310
316
|
// Keys: Backspace, Arrow left
|
311
317
|
if ([8, 37].includes(event.keyCode)) {
|
312
|
-
fieldRefs.current[(((position) - 1) + length) % length]
|
318
|
+
const beforeFieldRef = fieldRefs.current[(((position) - 1) + length) % length];
|
319
|
+
if (beforeFieldRef.current)
|
320
|
+
beforeFieldRef.current.focus();
|
313
321
|
}
|
314
322
|
// Keys: Tab (automatically), Arrow Right
|
315
323
|
if ([39].includes(event.keyCode)) {
|
316
|
-
fieldRefs.current[(position + 1) % length]
|
324
|
+
const nextFieldRef = fieldRefs.current[(position + 1) % length];
|
325
|
+
if (nextFieldRef.current)
|
326
|
+
nextFieldRef.current.focus();
|
317
327
|
}
|
318
328
|
}
|
319
329
|
function setDigit(position, digit) {
|
320
|
-
fieldRefs.current[position % length]
|
330
|
+
const fieldRef = fieldRefs.current[position % length];
|
331
|
+
if (fieldRef.current)
|
332
|
+
fieldRef.current.value = digit;
|
321
333
|
setState({ ...state, [position % length]: digit });
|
322
334
|
}
|
323
335
|
function resetValues() {
|
324
336
|
setState({});
|
325
337
|
fieldRefs.current.forEach((ref) => {
|
326
|
-
ref.current
|
338
|
+
if (ref.current)
|
339
|
+
ref.current.value = "";
|
327
340
|
});
|
328
341
|
}
|
329
342
|
return (React__default["default"].createElement("div", { className: styles$e.container },
|
@@ -598,7 +611,7 @@ class TableItem {
|
|
598
611
|
moreText;
|
599
612
|
iconName;
|
600
613
|
data;
|
601
|
-
constructor(title, subtitle, moreText, iconName, data
|
614
|
+
constructor(title, subtitle, moreText, iconName, data) {
|
602
615
|
this.title = title;
|
603
616
|
this.subtitle = subtitle;
|
604
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}";
|
@@ -129,7 +128,8 @@ styleInject(css_248z$m);
|
|
129
128
|
function Dialog({ data, text, onClose, onSubmit, children }) {
|
130
129
|
function onClick(event) {
|
131
130
|
event.preventDefault();
|
132
|
-
const
|
131
|
+
const element = event.target;
|
132
|
+
const id = element.id;
|
133
133
|
if (["dialog-backdrop", "cancel-button"].includes(id)) {
|
134
134
|
if (onClose)
|
135
135
|
onClose(event, data?.data);
|
@@ -280,7 +280,9 @@ function InputPin({ name, length, onFinished = () => { } }) {
|
|
280
280
|
const addedDigitsCount = value.length - digitCountBefore;
|
281
281
|
// One digit was added
|
282
282
|
if (addedDigitsCount == 1) {
|
283
|
-
fieldRefs.current[(position + 1) % length]
|
283
|
+
const nextFieldRef = fieldRefs.current[(position + 1) % length];
|
284
|
+
if (nextFieldRef.current)
|
285
|
+
nextFieldRef.current.focus();
|
284
286
|
setDigit(position, value.slice(-1));
|
285
287
|
return;
|
286
288
|
}
|
@@ -290,10 +292,14 @@ function InputPin({ name, length, onFinished = () => { } }) {
|
|
290
292
|
let newState = { ...state };
|
291
293
|
digits.forEach((digit, relativePosition) => {
|
292
294
|
newState[relativePosition % length + position] = digit;
|
293
|
-
fieldRefs.current[relativePosition % length + position]
|
295
|
+
const fieldRef = fieldRefs.current[relativePosition % length + position];
|
296
|
+
if (fieldRef.current)
|
297
|
+
fieldRef.current.value = digit;
|
294
298
|
});
|
295
299
|
if (digits.length >= 6) {
|
296
|
-
fieldRefs.current[length - 1]
|
300
|
+
const lastFieldRef = fieldRefs.current[length - 1];
|
301
|
+
if (lastFieldRef.current)
|
302
|
+
lastFieldRef.current.focus();
|
297
303
|
}
|
298
304
|
setState(newState);
|
299
305
|
}
|
@@ -301,21 +307,28 @@ function InputPin({ name, length, onFinished = () => { } }) {
|
|
301
307
|
event.preventDefault();
|
302
308
|
// Keys: Backspace, Arrow left
|
303
309
|
if ([8, 37].includes(event.keyCode)) {
|
304
|
-
fieldRefs.current[(((position) - 1) + length) % length]
|
310
|
+
const beforeFieldRef = fieldRefs.current[(((position) - 1) + length) % length];
|
311
|
+
if (beforeFieldRef.current)
|
312
|
+
beforeFieldRef.current.focus();
|
305
313
|
}
|
306
314
|
// Keys: Tab (automatically), Arrow Right
|
307
315
|
if ([39].includes(event.keyCode)) {
|
308
|
-
fieldRefs.current[(position + 1) % length]
|
316
|
+
const nextFieldRef = fieldRefs.current[(position + 1) % length];
|
317
|
+
if (nextFieldRef.current)
|
318
|
+
nextFieldRef.current.focus();
|
309
319
|
}
|
310
320
|
}
|
311
321
|
function setDigit(position, digit) {
|
312
|
-
fieldRefs.current[position % length]
|
322
|
+
const fieldRef = fieldRefs.current[position % length];
|
323
|
+
if (fieldRef.current)
|
324
|
+
fieldRef.current.value = digit;
|
313
325
|
setState({ ...state, [position % length]: digit });
|
314
326
|
}
|
315
327
|
function resetValues() {
|
316
328
|
setState({});
|
317
329
|
fieldRefs.current.forEach((ref) => {
|
318
|
-
ref.current
|
330
|
+
if (ref.current)
|
331
|
+
ref.current.value = "";
|
319
332
|
});
|
320
333
|
}
|
321
334
|
return (React.createElement("div", { className: styles$e.container },
|
@@ -590,7 +603,7 @@ class TableItem {
|
|
590
603
|
moreText;
|
591
604
|
iconName;
|
592
605
|
data;
|
593
|
-
constructor(title, subtitle, moreText, iconName, data
|
606
|
+
constructor(title, subtitle, moreText, iconName, data) {
|
594
607
|
this.title = title;
|
595
608
|
this.subtitle = subtitle;
|
596
609
|
this.moreText = moreText;
|