@symply.io/basic-components 1.0.0-alpha.17 → 1.0.0-alpha.19
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/CheckBox/types.d.ts +2 -2
- package/FeinInput/index.d.ts +6 -0
- package/FeinInput/index.js +73 -0
- package/FeinInput/types.d.ts +9 -0
- package/FeinInput/types.js +1 -0
- package/FeinInput/useInteractions.d.ts +8 -0
- package/FeinInput/useInteractions.js +16 -0
- package/README.md +33 -6
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/package.json +1 -1
package/CheckBox/types.d.ts
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
import { CSSProperties } from "react";
|
1
|
+
import { CSSProperties, ReactNode } from "react";
|
2
2
|
import { CheckboxProps } from "@mui/material/Checkbox";
|
3
3
|
import { FormGroupProps } from "@mui/material/FormGroup";
|
4
4
|
export interface CheckBoxProps extends Omit<CheckboxProps, "onChange"> {
|
5
|
-
label: string;
|
5
|
+
label: string | ReactNode;
|
6
6
|
onChange: (val: boolean) => void;
|
7
7
|
primaryColor?: CSSProperties["color"];
|
8
8
|
secondaryColor?: CSSProperties["color"];
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import { FeinInputProps } from "./types";
|
2
|
+
export declare function FeinInputFormat(str: string): string;
|
3
|
+
export declare function verifyFein(feinString: string): boolean;
|
4
|
+
declare function FeinInput(props: FeinInputProps): JSX.Element;
|
5
|
+
export default FeinInput;
|
6
|
+
export * from "./types";
|
@@ -0,0 +1,73 @@
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
2
|
+
__assign = Object.assign || function(t) {
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
4
|
+
s = arguments[i];
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
6
|
+
t[p] = s[p];
|
7
|
+
}
|
8
|
+
return t;
|
9
|
+
};
|
10
|
+
return __assign.apply(this, arguments);
|
11
|
+
};
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
13
|
+
var t = {};
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
15
|
+
t[p] = s[p];
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
19
|
+
t[p[i]] = s[p[i]];
|
20
|
+
}
|
21
|
+
return t;
|
22
|
+
};
|
23
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
24
|
+
import { useRifm } from "rifm";
|
25
|
+
import ThemeProvider from "@mui/material/styles/ThemeProvider";
|
26
|
+
import TextField from "@mui/material/TextField";
|
27
|
+
import useInteractions from "./useInteractions";
|
28
|
+
import useCustomTheme from "../useCustomTheme";
|
29
|
+
export function FeinInputFormat(str) {
|
30
|
+
var digits = (str.match(/\d+/g) || []).join("");
|
31
|
+
var chars = digits.split("");
|
32
|
+
return chars.reduce(function (prev, curr, index) {
|
33
|
+
if (index === 2) {
|
34
|
+
return "".concat(prev, " - ").concat(curr);
|
35
|
+
}
|
36
|
+
else {
|
37
|
+
return "".concat(prev).concat(curr);
|
38
|
+
}
|
39
|
+
}, "");
|
40
|
+
}
|
41
|
+
export function verifyFein(feinString) {
|
42
|
+
var reg = /^\d{2}\s?-\s?\d{7}$/g;
|
43
|
+
return reg.test(feinString);
|
44
|
+
}
|
45
|
+
function FeinInput(props) {
|
46
|
+
var value = props.value, _a = props.error, error = _a === void 0 ? false : _a, _b = props.helperText, helperText = _b === void 0 ? "Please enter a valid FEIN" : _b, onChange = props.onChange, verifyFn = props.verifyFn, onFocus = props.onFocus, onBlur = props.onBlur, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor, rest = __rest(props, ["value", "error", "helperText", "onChange", "verifyFn", "onFocus", "onBlur", "primaryColor", "secondaryColor"]);
|
47
|
+
var theme = useCustomTheme({ primaryColor: primaryColor, secondaryColor: secondaryColor });
|
48
|
+
var _c = useInteractions({ value: value }), valLength = _c.valLength, addMask = _c.addMask;
|
49
|
+
var rifm = useRifm({
|
50
|
+
mask: true,
|
51
|
+
value: String(value),
|
52
|
+
onChange: onChange,
|
53
|
+
replace: addMask,
|
54
|
+
format: FeinInputFormat
|
55
|
+
});
|
56
|
+
return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(TextField, __assign({ value: rifm.value, onChange: rifm.onChange, error: error ||
|
57
|
+
(valLength > 0 && (verifyFn ? !verifyFn(value) : verifyFein(value))), helperText: valLength > 0 && (verifyFn ? !verifyFn(value) : verifyFein(value))
|
58
|
+
? helperText
|
59
|
+
: "", onFocus: function (event) {
|
60
|
+
if (onFocus) {
|
61
|
+
onFocus(event);
|
62
|
+
}
|
63
|
+
}, onBlur: function (event) {
|
64
|
+
onChange(value.trim());
|
65
|
+
if (onBlur) {
|
66
|
+
onBlur(event);
|
67
|
+
}
|
68
|
+
}, InputLabelProps: {
|
69
|
+
shrink: true
|
70
|
+
} }, rest)) })));
|
71
|
+
}
|
72
|
+
export default FeinInput;
|
73
|
+
export * from "./types";
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { CSSProperties } from "react";
|
2
|
+
import { TextFieldProps } from "@mui/material/TextField";
|
3
|
+
export interface FeinInputProps extends Omit<TextFieldProps, "onChange"> {
|
4
|
+
onChange: (value: string) => void;
|
5
|
+
verifyFn?: (value?: string) => boolean;
|
6
|
+
value: string;
|
7
|
+
primaryColor?: CSSProperties["color"];
|
8
|
+
secondaryColor?: CSSProperties["color"];
|
9
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { useCallback, useMemo } from "react";
|
2
|
+
function useInteractions(props) {
|
3
|
+
var value = props.value;
|
4
|
+
var addMask = useCallback(function (str) {
|
5
|
+
var digits = (str.match(/\d+/g) || []).join("");
|
6
|
+
var areaCode = digits.slice(0, 2).padEnd(2, "_");
|
7
|
+
var prefixCode = digits.slice(2, 9).padEnd(7, "_");
|
8
|
+
return "".concat(areaCode, " - ").concat(prefixCode);
|
9
|
+
}, []);
|
10
|
+
var valLength = useMemo(function () {
|
11
|
+
var digitsArr = String(value).match(/\d/g);
|
12
|
+
return digitsArr ? digitsArr.length : 0;
|
13
|
+
}, [value]);
|
14
|
+
return { valLength: valLength, addMask: addMask };
|
15
|
+
}
|
16
|
+
export default useInteractions;
|
package/README.md
CHANGED
@@ -20,6 +20,7 @@
|
|
20
20
|
- [CheckBoxGroup](#checkboxgroup)
|
21
21
|
- [Copyright](#copyright)
|
22
22
|
- [DigitInput](#digitinput)
|
23
|
+
- [FeinInput](#feininput)
|
23
24
|
- [FormRadioGroup](#formradiogroup)
|
24
25
|
- [FormSelector](#formselector)
|
25
26
|
- [HelpCaption](#helpcaption)
|
@@ -226,16 +227,16 @@ It is extended from `@mui/material/Checkbox`, so it includes all properties of `
|
|
226
227
|
import { CheckBox } from '@symply.io/basic-components/';
|
227
228
|
// or
|
228
229
|
import { CheckBox } from '@symply.io/basic-components/CheckBox';
|
230
|
+
// or
|
231
|
+
import CheckBox from '@symply.io/basic-components/CheckBox/CheckBox';
|
229
232
|
```
|
230
233
|
|
231
234
|
<h5>Props</h5>
|
232
235
|
|
233
|
-
| Name | Type
|
234
|
-
| -------- |
|
235
|
-
| label | string | | true | The label of the checkbox. |
|
236
|
-
| onChange | func
|
237
|
-
|
238
|
-
|
236
|
+
| Name | Type | Default | Required | Description |
|
237
|
+
| -------- | ------------------- | ------- | -------- | ------------------------------------------------------------ |
|
238
|
+
| label | string \| ReactNode | | true | The label of the checkbox. |
|
239
|
+
| onChange | func | | true | Callback fired when the `checkbox` value is changed.<br />**Signature:**<br/>`function(value: boolean) => void`<br/>*value:* The value of the `checkbox` element. |
|
239
240
|
|
240
241
|
|
241
242
|
|
@@ -251,6 +252,8 @@ It is extended from `@mui/material/FormGroup`, so it includes all properties of
|
|
251
252
|
import { CheckBoxGroup } from '@symply.io/basic-components/';
|
252
253
|
// or
|
253
254
|
import { CheckBoxGroup } from '@symply.io/basic-components/CheckBox';
|
255
|
+
// or
|
256
|
+
import CheckBoxGroup from '@symply.io/basic-components/CheckBox/CheckBoxGroup';
|
254
257
|
```
|
255
258
|
|
256
259
|
<h5>Props</h5>
|
@@ -302,6 +305,30 @@ import DigitInput from '@symply.io/basic-components/DigitInput';
|
|
302
305
|
|
303
306
|
|
304
307
|
|
308
|
+
<h3>FeinInput</h3>
|
309
|
+
|
310
|
+
Input component for FEIN.
|
311
|
+
|
312
|
+
It is extended from `@mui/material/TextField`, so it includes all properties of `@mui/material/TextField`.
|
313
|
+
|
314
|
+
<h5>Import</h5>
|
315
|
+
|
316
|
+
```typescript
|
317
|
+
import { FeinInput } from '@symply.io/basic-components/';
|
318
|
+
// or
|
319
|
+
import FeinInput from '@symply.io/basic-components/FeinInput';
|
320
|
+
```
|
321
|
+
|
322
|
+
<h5>Props</h5>
|
323
|
+
|
324
|
+
| Name | Type | Default | Required | Description |
|
325
|
+
| -------- | ------ | ------- | -------- | ------------------------------------------------------------ |
|
326
|
+
| onChange | func | | true | Callback fired when the `Input` value is changed.<br />**Signature:**<br/>`function(value: string) => void`<br/>*value:* The value of the `Input` element. |
|
327
|
+
| value | string | | true | The value of the `Input` element. |
|
328
|
+
| verifyFn | func | | false | Customized verification function. |
|
329
|
+
|
330
|
+
|
331
|
+
|
305
332
|
<h3>FormRadioGroup</h3>
|
306
333
|
|
307
334
|
Radio Group allow the user to select one option from a set.
|
package/index.d.ts
CHANGED
@@ -7,6 +7,7 @@ export * from "./CheckBox";
|
|
7
7
|
export * from "./Copyright";
|
8
8
|
export * from "./DigitInput";
|
9
9
|
export * from "./DynamicHeaderBar";
|
10
|
+
export * from "./FeinInput";
|
10
11
|
export * from "./FormRadioGroup";
|
11
12
|
export * from "./FormSelector";
|
12
13
|
export * from "./HelpCaption";
|
@@ -28,6 +29,7 @@ export { default as BreadCrumbs } from "./BreadCrumbs";
|
|
28
29
|
export { default as Copyright } from "./Copyright";
|
29
30
|
export { default as DigitInput } from "./DigitInput";
|
30
31
|
export { default as DynamicHeaderBar } from "./DynamicHeaderBar";
|
32
|
+
export { default as FeinInput } from "./FeinInput";
|
31
33
|
export { default as FormRadioGroup } from "./FormRadioGroup";
|
32
34
|
export { default as HelpCaption } from "./HelpCaption";
|
33
35
|
export { default as LoadingModal } from "./LoadingModal";
|
package/index.js
CHANGED
@@ -7,6 +7,7 @@ export * from "./CheckBox";
|
|
7
7
|
export * from "./Copyright";
|
8
8
|
export * from "./DigitInput";
|
9
9
|
export * from "./DynamicHeaderBar";
|
10
|
+
export * from "./FeinInput";
|
10
11
|
export * from "./FormRadioGroup";
|
11
12
|
export * from "./FormSelector";
|
12
13
|
export * from "./HelpCaption";
|
@@ -28,6 +29,7 @@ export { default as BreadCrumbs } from "./BreadCrumbs";
|
|
28
29
|
export { default as Copyright } from "./Copyright";
|
29
30
|
export { default as DigitInput } from "./DigitInput";
|
30
31
|
export { default as DynamicHeaderBar } from "./DynamicHeaderBar";
|
32
|
+
export { default as FeinInput } from "./FeinInput";
|
31
33
|
export { default as FormRadioGroup } from "./FormRadioGroup";
|
32
34
|
export { default as HelpCaption } from "./HelpCaption";
|
33
35
|
export { default as LoadingModal } from "./LoadingModal";
|