@dktunited-techoff/techoff-suite-ui 1.6.5 → 1.6.7

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.
@@ -24,6 +24,7 @@
24
24
  }
25
25
  .ts-input-error--label {
26
26
  font-size: 12px;
27
+ font-weight: 500;
27
28
  }
28
29
  input::placeholder {
29
30
  color: #7a7a7a;
@@ -1,4 +1,4 @@
1
1
  import * as React from 'react';
2
2
  import { TsInputProps } from './TsInput.types';
3
3
  import './TsInput.css';
4
- export declare const TsInput: ({ icon, label, value, onChange, onValidate, ...props }: TsInputProps) => React.JSX.Element;
4
+ export declare const TsInput: ({ error, icon, label, value, onChange, ...props }: TsInputProps) => React.JSX.Element;
@@ -1,30 +1,16 @@
1
1
  import * as React from 'react';
2
- import { useState } from 'react';
3
2
  import { TsIcon } from '../../TsIcon/TsIcon';
4
3
  import './TsInput.css';
5
- export const TsInput = ({ icon, label, value, onChange, onValidate, ...props }) => {
6
- const [error, setError] = useState();
7
- // ########
8
- // Handlers
9
- const handleBlur = (e) => {
10
- props.onBlur?.(e);
11
- if (onValidate) {
12
- const validateResult = onValidate();
13
- if (validateResult instanceof Promise)
14
- validateResult.then(setError);
15
- else
16
- setError(validateResult);
17
- }
18
- };
4
+ export const TsInput = ({ error, icon, label, value, onChange, ...props }) => {
19
5
  // #########
20
6
  // Rendering
21
7
  return (React.createElement("div", { className: `ts-input ${icon ? 'ts-input--padding-1' : 'ts-input--padding-0'}` },
22
8
  label && React.createElement("div", { className: "ts-input-label" }, label),
23
- React.createElement("div", { className: `ts-input-container ${error ? 'ts-input-container--error' : ''}` },
24
- React.createElement("input", { type: "text", value: value, onBlur: handleBlur, onChange: e => onChange(e.target.value), ...props }),
9
+ React.createElement("div", { className: `ts-input-container ${error || error !== '' ? 'ts-input-container--error' : ''}` },
10
+ React.createElement("input", { type: "text", value: value, onChange: e => onChange(e.target.value), ...props }),
25
11
  icon && (React.createElement("div", { className: "ts-input-icon" },
26
12
  React.createElement(TsIcon, { name: icon, size: "16" })))),
27
- error && (React.createElement("div", { className: "ts-input-error" },
13
+ (error || error !== '') && (React.createElement("div", { className: "ts-input-error" },
28
14
  React.createElement("div", { className: "ts-input-error--icon" },
29
15
  React.createElement(TsIcon, { name: "alert-circle", size: "16" })),
30
16
  React.createElement("div", { className: "ts-input-error--label" }, error)))));
@@ -1 +1 @@
1
- {"version":3,"file":"TsInput.js","sourceRoot":"","sources":["../../../../src/components/TsInput/TsInput/TsInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAc,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,eAAe,CAAC;AAEvB,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,KAAK,EAAgB,EAAE,EAAE;IAC9F,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAAU,CAAC;IAE7C,WAAW;IACX,WAAW;IACX,MAAM,UAAU,GAAG,CAAC,CAA+B,EAAE,EAAE;QACrD,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;QAElB,IAAI,UAAU,EAAE;YACd,MAAM,cAAc,GAAG,UAAU,EAAE,CAAC;YACpC,IAAI,cAAc,YAAY,OAAO;gBAAE,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;;gBAChE,QAAQ,CAAC,cAAc,CAAC,CAAC;SAC/B;IACH,CAAC,CAAC;IAEF,YAAY;IACZ,YAAY;IACZ,OAAO,CACL,6BAAK,SAAS,EAAE,YAAY,IAAI,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,qBAAqB,EAAE;QAC/E,KAAK,IAAI,6BAAK,SAAS,EAAC,gBAAgB,IAAE,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IAAE,KAAK,CAAO;QACvD,6BAAK,SAAS,EAAE,sBAAsB,KAAK,IAAI,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,EAAE,EAAE;YAC9F,+BAAO,IAAI,EAAC,MAAM,EAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KAAM,KAAK,GAAI;YACtF,IAAI,IAAI,CACP,6BAAK,SAAS,EAAC,eAAe;gBAC5B,oBAAC,MAAM,IAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAC,IAAI,GAAG,CAC5B,CACP,CACG;QAEL,CAAC,KAAK,IAAI,KAAK,KAAK,EAAE,CAAC,IAAI,CAC1B,6BAAK,SAAS,EAAC,gBAAgB;YAC7B,6BAAK,SAAS,EAAC,sBAAsB;gBACnC,oBAAC,MAAM,IAAC,IAAI,EAAC,cAAc,EAAC,IAAI,EAAC,IAAI,GAAG,CACpC;YACN,6BAAK,SAAS,EAAC,uBAAuB,IAAE,KAAK,CAAO,CAChD,CACP,CACG,CACP,CAAC;AACJ,CAAC,CAAC"}
@@ -1,31 +1,16 @@
1
1
  import * as React from 'react';
2
- import { FocusEvent, useState } from 'react';
3
2
  import { TsIcon } from '../../TsIcon/TsIcon';
4
3
  import { TsInputProps } from './TsInput.types';
5
4
  import './TsInput.css';
6
5
 
7
- export const TsInput = ({ icon, label, value, onChange, onValidate, ...props }: TsInputProps) => {
8
- const [error, setError] = useState<string>();
9
-
10
- // ########
11
- // Handlers
12
- const handleBlur = (e: FocusEvent<HTMLInputElement>) => {
13
- props.onBlur?.(e);
14
-
15
- if (onValidate) {
16
- const validateResult = onValidate();
17
- if (validateResult instanceof Promise) validateResult.then(setError);
18
- else setError(validateResult);
19
- }
20
- };
21
-
6
+ export const TsInput = ({ error, icon, label, value, onChange, ...props }: TsInputProps) => {
22
7
  // #########
23
8
  // Rendering
24
9
  return (
25
10
  <div className={`ts-input ${icon ? 'ts-input--padding-1' : 'ts-input--padding-0'}`}>
26
11
  {label && <div className="ts-input-label">{label}</div>}
27
- <div className={`ts-input-container ${error ? 'ts-input-container--error' : ''}`}>
28
- <input type="text" value={value} onBlur={handleBlur} onChange={e => onChange(e.target.value)} {...props} />
12
+ <div className={`ts-input-container ${error || error !== '' ? 'ts-input-container--error' : ''}`}>
13
+ <input type="text" value={value} onChange={e => onChange(e.target.value)} {...props} />
29
14
  {icon && (
30
15
  <div className="ts-input-icon">
31
16
  <TsIcon name={icon} size="16" />
@@ -33,7 +18,7 @@ export const TsInput = ({ icon, label, value, onChange, onValidate, ...props }:
33
18
  )}
34
19
  </div>
35
20
 
36
- {error && (
21
+ {(error || error !== '') && (
37
22
  <div className="ts-input-error">
38
23
  <div className="ts-input-error--icon">
39
24
  <TsIcon name="alert-circle" size="16" />
@@ -1,7 +1,7 @@
1
1
  import { InputHTMLAttributes } from 'react';
2
2
  export type TsInputProps = {
3
+ error?: string;
3
4
  icon?: string;
4
5
  label?: string;
5
6
  onChange: (value: string) => void;
6
- onValidate?: () => Promise<string | undefined> | string | undefined;
7
7
  } & Omit<Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange'>, 'size'>;
@@ -1,8 +1,8 @@
1
1
  import { InputHTMLAttributes } from 'react';
2
2
 
3
3
  export type TsInputProps = {
4
+ error?: string;
4
5
  icon?: string;
5
6
  label?: string;
6
7
  onChange: (value: string) => void;
7
- onValidate?: () => Promise<string | undefined> | string | undefined;
8
8
  } & Omit<Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange'>, 'size'>;
@@ -24,6 +24,7 @@
24
24
  }
25
25
  .ts-input-error--label {
26
26
  font-size: 12px;
27
+ font-weight: 500;
27
28
  }
28
29
  input::placeholder {
29
30
  color: #7a7a7a;
@@ -1,4 +1,4 @@
1
1
  import * as React from 'react';
2
2
  import { TsInputProps } from './TsInput.types';
3
3
  import './TsInput.css';
4
- export declare const TsInput: ({ icon, label, value, onChange, onValidate, ...props }: TsInputProps) => React.JSX.Element;
4
+ export declare const TsInput: ({ error, icon, label, value, onChange, ...props }: TsInputProps) => React.JSX.Element;
@@ -2,32 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TsInput = void 0;
4
4
  const React = require("react");
5
- const react_1 = require("react");
6
5
  const TsIcon_1 = require("../../TsIcon/TsIcon");
7
6
  require("./TsInput.css");
8
- const TsInput = ({ icon, label, value, onChange, onValidate, ...props }) => {
9
- const [error, setError] = (0, react_1.useState)();
10
- // ########
11
- // Handlers
12
- const handleBlur = (e) => {
13
- props.onBlur?.(e);
14
- if (onValidate) {
15
- const validateResult = onValidate();
16
- if (validateResult instanceof Promise)
17
- validateResult.then(setError);
18
- else
19
- setError(validateResult);
20
- }
21
- };
7
+ const TsInput = ({ error, icon, label, value, onChange, ...props }) => {
22
8
  // #########
23
9
  // Rendering
24
10
  return (React.createElement("div", { className: `ts-input ${icon ? 'ts-input--padding-1' : 'ts-input--padding-0'}` },
25
11
  label && React.createElement("div", { className: "ts-input-label" }, label),
26
- React.createElement("div", { className: `ts-input-container ${error ? 'ts-input-container--error' : ''}` },
27
- React.createElement("input", { type: "text", value: value, onBlur: handleBlur, onChange: e => onChange(e.target.value), ...props }),
12
+ React.createElement("div", { className: `ts-input-container ${error || error !== '' ? 'ts-input-container--error' : ''}` },
13
+ React.createElement("input", { type: "text", value: value, onChange: e => onChange(e.target.value), ...props }),
28
14
  icon && (React.createElement("div", { className: "ts-input-icon" },
29
15
  React.createElement(TsIcon_1.TsIcon, { name: icon, size: "16" })))),
30
- error && (React.createElement("div", { className: "ts-input-error" },
16
+ (error || error !== '') && (React.createElement("div", { className: "ts-input-error" },
31
17
  React.createElement("div", { className: "ts-input-error--icon" },
32
18
  React.createElement(TsIcon_1.TsIcon, { name: "alert-circle", size: "16" })),
33
19
  React.createElement("div", { className: "ts-input-error--label" }, error)))));
@@ -1 +1 @@
1
- {"version":3,"file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AAG,CAC5B,CACP,CACG;QAEL,CAAC,KAAK,IAAI,KAAK,KAAK,EAAE,CAAC,IAAI,CAC1B,6BAAK,SAAS,EAAC,gBAAgB;YAC7B,6BAAK,SAAS,EAAC,sBAAsB;gBACnC,oBAAC,eAAM,IAAC,IAAI,EAAC,cAAc,EAAC,IAAI,EAAC,IAAI,GAAG,CACpC;YACN,6BAAK,SAAS,EAAC,uBAAuB,IAAE,KAAK,CAAO,CAChD,CACP,CACG,CACP,CAAC;AACJ,CAAC,CAAC;AAzBW,QAAA,OAAO,WAyBlB"}
@@ -1,31 +1,16 @@
1
1
  import * as React from 'react';
2
- import { FocusEvent, useState } from 'react';
3
2
  import { TsIcon } from '../../TsIcon/TsIcon';
4
3
  import { TsInputProps } from './TsInput.types';
5
4
  import './TsInput.css';
6
5
 
7
- export const TsInput = ({ icon, label, value, onChange, onValidate, ...props }: TsInputProps) => {
8
- const [error, setError] = useState<string>();
9
-
10
- // ########
11
- // Handlers
12
- const handleBlur = (e: FocusEvent<HTMLInputElement>) => {
13
- props.onBlur?.(e);
14
-
15
- if (onValidate) {
16
- const validateResult = onValidate();
17
- if (validateResult instanceof Promise) validateResult.then(setError);
18
- else setError(validateResult);
19
- }
20
- };
21
-
6
+ export const TsInput = ({ error, icon, label, value, onChange, ...props }: TsInputProps) => {
22
7
  // #########
23
8
  // Rendering
24
9
  return (
25
10
  <div className={`ts-input ${icon ? 'ts-input--padding-1' : 'ts-input--padding-0'}`}>
26
11
  {label && <div className="ts-input-label">{label}</div>}
27
- <div className={`ts-input-container ${error ? 'ts-input-container--error' : ''}`}>
28
- <input type="text" value={value} onBlur={handleBlur} onChange={e => onChange(e.target.value)} {...props} />
12
+ <div className={`ts-input-container ${error || error !== '' ? 'ts-input-container--error' : ''}`}>
13
+ <input type="text" value={value} onChange={e => onChange(e.target.value)} {...props} />
29
14
  {icon && (
30
15
  <div className="ts-input-icon">
31
16
  <TsIcon name={icon} size="16" />
@@ -33,7 +18,7 @@ export const TsInput = ({ icon, label, value, onChange, onValidate, ...props }:
33
18
  )}
34
19
  </div>
35
20
 
36
- {error && (
21
+ {(error || error !== '') && (
37
22
  <div className="ts-input-error">
38
23
  <div className="ts-input-error--icon">
39
24
  <TsIcon name="alert-circle" size="16" />
@@ -1,7 +1,7 @@
1
1
  import { InputHTMLAttributes } from 'react';
2
2
  export type TsInputProps = {
3
+ error?: string;
3
4
  icon?: string;
4
5
  label?: string;
5
6
  onChange: (value: string) => void;
6
- onValidate?: () => Promise<string | undefined> | string | undefined;
7
7
  } & Omit<Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange'>, 'size'>;
@@ -1,8 +1,8 @@
1
1
  import { InputHTMLAttributes } from 'react';
2
2
 
3
3
  export type TsInputProps = {
4
+ error?: string;
4
5
  icon?: string;
5
6
  label?: string;
6
7
  onChange: (value: string) => void;
7
- onValidate?: () => Promise<string | undefined> | string | undefined;
8
8
  } & Omit<Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange'>, 'size'>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dktunited-techoff/techoff-suite-ui",
3
- "version": "1.6.5",
3
+ "version": "1.6.7",
4
4
  "main": "lib/index.js",
5
5
  "types": "./lib",
6
6
  "module": "esm/index.js",
@@ -24,6 +24,7 @@
24
24
  }
25
25
  .ts-input-error--label {
26
26
  font-size: 12px;
27
+ font-weight: 500;
27
28
  }
28
29
  input::placeholder {
29
30
  color: #7a7a7a;
@@ -1,31 +1,16 @@
1
1
  import * as React from 'react';
2
- import { FocusEvent, useState } from 'react';
3
2
  import { TsIcon } from '../../TsIcon/TsIcon';
4
3
  import { TsInputProps } from './TsInput.types';
5
4
  import './TsInput.css';
6
5
 
7
- export const TsInput = ({ icon, label, value, onChange, onValidate, ...props }: TsInputProps) => {
8
- const [error, setError] = useState<string>();
9
-
10
- // ########
11
- // Handlers
12
- const handleBlur = (e: FocusEvent<HTMLInputElement>) => {
13
- props.onBlur?.(e);
14
-
15
- if (onValidate) {
16
- const validateResult = onValidate();
17
- if (validateResult instanceof Promise) validateResult.then(setError);
18
- else setError(validateResult);
19
- }
20
- };
21
-
6
+ export const TsInput = ({ error, icon, label, value, onChange, ...props }: TsInputProps) => {
22
7
  // #########
23
8
  // Rendering
24
9
  return (
25
10
  <div className={`ts-input ${icon ? 'ts-input--padding-1' : 'ts-input--padding-0'}`}>
26
11
  {label && <div className="ts-input-label">{label}</div>}
27
- <div className={`ts-input-container ${error ? 'ts-input-container--error' : ''}`}>
28
- <input type="text" value={value} onBlur={handleBlur} onChange={e => onChange(e.target.value)} {...props} />
12
+ <div className={`ts-input-container ${error || error !== '' ? 'ts-input-container--error' : ''}`}>
13
+ <input type="text" value={value} onChange={e => onChange(e.target.value)} {...props} />
29
14
  {icon && (
30
15
  <div className="ts-input-icon">
31
16
  <TsIcon name={icon} size="16" />
@@ -33,7 +18,7 @@ export const TsInput = ({ icon, label, value, onChange, onValidate, ...props }:
33
18
  )}
34
19
  </div>
35
20
 
36
- {error && (
21
+ {(error || error !== '') && (
37
22
  <div className="ts-input-error">
38
23
  <div className="ts-input-error--icon">
39
24
  <TsIcon name="alert-circle" size="16" />
@@ -1,8 +1,8 @@
1
1
  import { InputHTMLAttributes } from 'react';
2
2
 
3
3
  export type TsInputProps = {
4
+ error?: string;
4
5
  icon?: string;
5
6
  label?: string;
6
7
  onChange: (value: string) => void;
7
- onValidate?: () => Promise<string | undefined> | string | undefined;
8
8
  } & Omit<Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange'>, 'size'>;