@symply.io/basic-components 1.5.0 → 1.5.2-alpha.1

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.
@@ -4,7 +4,6 @@ export interface ClickableFabButtonProps {
4
4
  text: string;
5
5
  fabIcon: ReactElement;
6
6
  disabled?: boolean;
7
- size?: ButtonProps["size"];
8
7
  color?: "error" | "primary" | "secondary" | "success" | "info" | "warning";
9
8
  onClick: ButtonProps["onClick"];
10
9
  primaryColor?: CSSProperties["color"];
@@ -1,14 +1,3 @@
1
- import { CSSProperties } from "react";
2
- import { TextFieldProps } from "@mui/material/TextField";
3
- export interface NumberInputProps extends Omit<TextFieldProps, "onChange"> {
4
- onChange: (value: string) => void;
5
- value: string;
6
- integerOnly?: boolean;
7
- tooltip?: string;
8
- maxValue?: number;
9
- minValue?: number;
10
- primaryColor?: CSSProperties["color"];
11
- secondaryColor?: CSSProperties["color"];
12
- }
1
+ import type { NumberInputProps } from "./types";
13
2
  declare function NumberInput(props: NumberInputProps): JSX.Element;
14
3
  export default NumberInput;
@@ -27,12 +27,19 @@ import ThemeProvider from "@mui/material/styles/ThemeProvider";
27
27
  import useInteractions from "./useInteractions";
28
28
  import useCustomTheme from "../useCustomTheme";
29
29
  function NumberInput(props) {
30
- var onChange = props.onChange, value = props.value, _a = props.size, size = _a === void 0 ? "small" : _a, tooltip = props.tooltip, _b = props.integerOnly, integerOnly = _b === void 0 ? false : _b, _c = props.minValue, minValue = _c === void 0 ? Number.MIN_SAFE_INTEGER : _c, _d = props.maxValue, maxValue = _d === void 0 ? Number.MAX_SAFE_INTEGER : _d, error = props.error, helperText = props.helperText, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor, rest = __rest(props, ["onChange", "value", "size", "tooltip", "integerOnly", "minValue", "maxValue", "error", "helperText", "primaryColor", "secondaryColor"]);
30
+ var onChange = props.onChange, value = props.value, _a = props.size, size = _a === void 0 ? "small" : _a, tooltip = props.tooltip, _b = props.integerOnly, integerOnly = _b === void 0 ? false : _b, _c = props.decimals, decimals = _c === void 0 ? 0 : _c, _d = props.minValue, minValue = _d === void 0 ? Number.MIN_SAFE_INTEGER : _d, _e = props.maxValue, maxValue = _e === void 0 ? Number.MAX_SAFE_INTEGER : _e, error = props.error, helperText = props.helperText, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor, rest = __rest(props, ["onChange", "value", "size", "tooltip", "integerOnly", "decimals", "minValue", "maxValue", "error", "helperText", "primaryColor", "secondaryColor"]);
31
31
  var theme = useCustomTheme({ primaryColor: primaryColor, secondaryColor: secondaryColor });
32
32
  var EXCEED_ERROR = "Your value exceeds the exceptable input range";
33
33
  if (maxValue < minValue)
34
34
  throw new Error("Max should be bigger than the `miniValue`!");
35
- var _e = useInteractions({ maxValue: maxValue, minValue: minValue, value: value, integerOnly: integerOnly, onChange: onChange }), exceedError = _e.exceedError, tooltipOpen = _e.tooltipOpen, handleBlur = _e.handleBlur, handleChange = _e.handleChange, onOpenTooltip = _e.onOpenTooltip, onCloseTooltip = _e.onCloseTooltip, handleKeyboardEvent = _e.handleKeyboardEvent;
35
+ var _f = useInteractions({
36
+ value: value,
37
+ maxValue: maxValue,
38
+ minValue: minValue,
39
+ decimals: decimals,
40
+ integerOnly: integerOnly,
41
+ onChange: onChange
42
+ }), exceedError = _f.exceedError, tooltipOpen = _f.tooltipOpen, handleBlur = _f.handleBlur, handleChange = _f.handleChange, onOpenTooltip = _f.onOpenTooltip, onCloseTooltip = _f.onCloseTooltip, handleKeyboardEvent = _f.handleKeyboardEvent;
36
43
  return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Tooltip, __assign({ arrow: true, placement: "top", title: tooltip !== null && tooltip !== void 0 ? tooltip : "", open: !!tooltip && tooltipOpen }, { children: _jsx(Field, __assign({ size: size, margin: "dense", type: "number", value: value === undefined || value === null ? "" : value, onMouseEnter: onOpenTooltip, onMouseLeave: onCloseTooltip, onBlur: handleBlur, onChange: handleChange, error: error || exceedError, helperText: helperText || (exceedError ? EXCEED_ERROR : ""), inputProps: { onKeyDown: handleKeyboardEvent } }, rest)) })) })));
37
44
  }
38
45
  export default NumberInput;
@@ -0,0 +1,15 @@
1
+ import { CSSProperties } from "react";
2
+ import { TextFieldProps } from "@mui/material/TextField";
3
+ export interface InteractionProps {
4
+ value: string;
5
+ integerOnly?: boolean;
6
+ decimals?: number;
7
+ maxValue?: number;
8
+ minValue?: number;
9
+ onChange: (value: string) => void;
10
+ }
11
+ export interface NumberInputProps extends InteractionProps, Omit<TextFieldProps, "value" | "onChange"> {
12
+ tooltip?: string;
13
+ primaryColor?: CSSProperties["color"];
14
+ secondaryColor?: CSSProperties["color"];
15
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,11 +1,5 @@
1
1
  import { ChangeEvent, KeyboardEventHandler } from "react";
2
- interface InteractionProps {
3
- value: string;
4
- integerOnly?: boolean;
5
- maxValue?: number;
6
- minValue?: number;
7
- onChange: (value: string) => void;
8
- }
2
+ import type { InteractionProps } from "./types";
9
3
  declare function useInteractions(props: InteractionProps): {
10
4
  exceedError: boolean;
11
5
  tooltipOpen: boolean;
@@ -1,7 +1,7 @@
1
1
  import { useState, useCallback, useMemo } from "react";
2
2
  function useInteractions(props) {
3
- var value = props.value, integerOnly = props.integerOnly, _a = props.minValue, minValue = _a === void 0 ? Number.MIN_SAFE_INTEGER : _a, _b = props.maxValue, maxValue = _b === void 0 ? Number.MAX_SAFE_INTEGER : _b, onChange = props.onChange;
4
- var _c = useState(false), tooltipOpen = _c[0], setTooltipOpen = _c[1];
3
+ var value = props.value, _a = props.decimals, decimals = _a === void 0 ? 0 : _a, integerOnly = props.integerOnly, _b = props.minValue, minValue = _b === void 0 ? Number.MIN_SAFE_INTEGER : _b, _c = props.maxValue, maxValue = _c === void 0 ? Number.MAX_SAFE_INTEGER : _c, onChange = props.onChange;
4
+ var _d = useState(false), tooltipOpen = _d[0], setTooltipOpen = _d[1];
5
5
  var exceedError = useMemo(function () { return !!value && (Number(value) < minValue || Number(value) > maxValue); }, [value, minValue, maxValue]);
6
6
  var handleKeyboardEvent = useCallback(function (event) {
7
7
  var key = event.key;
@@ -16,6 +16,12 @@ function useInteractions(props) {
16
16
  event.preventDefault();
17
17
  }
18
18
  }
19
+ else if (value.includes(".") && decimals > 0) {
20
+ var decimalStrLen = value.split(".")[1].length;
21
+ if (key !== "Backspace" && decimalStrLen >= decimals) {
22
+ event.preventDefault();
23
+ }
24
+ }
19
25
  else {
20
26
  if (key === "-") {
21
27
  event.preventDefault();
package/README.md CHANGED
@@ -18,6 +18,7 @@
18
18
  - [BreadCrumbs](#breadcrumbs)
19
19
  - [CheckBox](#checkbox)
20
20
  - [CheckBoxGroup](#checkboxgroup)
21
+ - [CliickableFabButton](#clickablefabbutton)
21
22
  - [Copyright](#copyright)
22
23
  - [DataTable](#datatable)
23
24
  - [DateInput](#dateinput)
@@ -275,6 +276,30 @@ import CheckBoxGroup from '@symply.io/basic-components/CheckBoxGroup';
275
276
 
276
277
 
277
278
 
279
+ <h3>ClickableFabButton</h3>
280
+
281
+ A fab button with icon and text
282
+
283
+ <h5>Import</h5>
284
+
285
+ ```typescript
286
+ import { ClickableFabButton } from '@symply.io/basic-components/';
287
+ // or
288
+ import ClickableFabButton from '@symply.io/basic-components/ClickableFabButton';
289
+ ```
290
+
291
+ <h5>Props</h5>
292
+
293
+ | Name | Type | Default | Required | Description |
294
+ | -------- | ------------------------------------------------------------ | --------- | -------- | ------------------------------------------------------------ |
295
+ | color | "primary" \|"secondary" \|"success" \|"error" \|"info" \|"warning" | "primary" | false | The button color. |
296
+ | disabled | bool | false | false | If `true`, the button would be disabled. |
297
+ | fabIcon | ReactElement | | true | The icon element.. |
298
+ | onClick | func | | true | The function for button clicking.<br />**Signature:**<br/>`function() => unknown` |
299
+ | text | string | | true | The button text. |
300
+
301
+
302
+
278
303
  <h3>Copyright</h3>
279
304
 
280
305
  A common component for rendering the copyright
package/index.d.ts CHANGED
@@ -5,6 +5,7 @@ export * from "./BasicModal";
5
5
  export * from "./BreadCrumbs";
6
6
  export * from "./CheckBox";
7
7
  export * from "./CheckBoxGroup";
8
+ export * from "./ClickableFabButton";
8
9
  export * from "./ConfirmPasswordInput";
9
10
  export * from "./Copyright";
10
11
  export * from "./DataTable";
@@ -35,6 +36,7 @@ export { default as BasicModal } from "./BasicModal";
35
36
  export { default as BreadCrumbs } from "./BreadCrumbs";
36
37
  export { default as CheckBox } from "./CheckBox";
37
38
  export { default as CheckBoxGroup } from "./CheckBoxGroup";
39
+ export { default as ClickableFabButton } from "./ClickableFabButton";
38
40
  export { default as ConfirmPasswordInput } from "./ConfirmPasswordInput";
39
41
  export { default as Copyright } from "./Copyright";
40
42
  export { default as DataTable } from "./DataTable";
package/index.js CHANGED
@@ -5,6 +5,7 @@ export * from "./BasicModal";
5
5
  export * from "./BreadCrumbs";
6
6
  export * from "./CheckBox";
7
7
  export * from "./CheckBoxGroup";
8
+ export * from "./ClickableFabButton";
8
9
  export * from "./ConfirmPasswordInput";
9
10
  export * from "./Copyright";
10
11
  export * from "./DataTable";
@@ -35,6 +36,7 @@ export { default as BasicModal } from "./BasicModal";
35
36
  export { default as BreadCrumbs } from "./BreadCrumbs";
36
37
  export { default as CheckBox } from "./CheckBox";
37
38
  export { default as CheckBoxGroup } from "./CheckBoxGroup";
39
+ export { default as ClickableFabButton } from "./ClickableFabButton";
38
40
  export { default as ConfirmPasswordInput } from "./ConfirmPasswordInput";
39
41
  export { default as Copyright } from "./Copyright";
40
42
  export { default as DataTable } from "./DataTable";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symply.io/basic-components",
3
- "version": "1.5.0",
3
+ "version": "1.5.2-alpha.1",
4
4
  "description": "Basic and reusable components for all frontend of Symply apps",
5
5
  "keywords": [
6
6
  "react",