@edu-tosel/design 1.0.64 → 1.0.65

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.
@@ -37,9 +37,10 @@ export interface InputWidget extends Widget {
37
37
  state: State<string> | State<string | undefined>;
38
38
  onKeyDown?: (e: React.KeyboardEvent) => void;
39
39
  placeholder?: string;
40
- flag?: boolean;
40
+ isValid?: boolean;
41
41
  type?: InputType;
42
42
  label?: LabelWidget;
43
+ maxLength?: number;
43
44
  }
44
45
  export interface CheckBoxWidget extends Widget {
45
46
  state: State<boolean>;
@@ -2,5 +2,5 @@ import { InputWidget } from "../../../interface";
2
2
  interface InputWithTitleProps extends InputWidget {
3
3
  title: string;
4
4
  }
5
- declare function WithTitle({ title, placeholder, state, flag, type, }: InputWithTitleProps): import("react/jsx-runtime").JSX.Element;
5
+ declare function WithTitle(props: InputWithTitleProps): import("react/jsx-runtime").JSX.Element;
6
6
  export default WithTitle;
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Input } from "../../../widget";
3
- function WithTitle({ title, placeholder, state, flag, type, }) {
4
- return (_jsxs("div", { className: "flex flex-col gap-1", children: [_jsx("div", { className: "leading-none", children: title }), _jsx(Input.Form, { placeholder: placeholder, state: state, flag: flag, type: type })] }));
3
+ function WithTitle(props) {
4
+ return (_jsxs("div", { className: "flex flex-col gap-1", children: [_jsx("div", { className: "leading-none", children: props.title }), _jsx(Input.Form, { ...props })] }));
5
5
  }
6
6
  export default WithTitle;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edu-tosel/design",
3
- "version": "1.0.64",
3
+ "version": "1.0.65",
4
4
  "description": "UI components for International TOSEL Committee",
5
5
  "keywords": [
6
6
  "jsx",
package/version.txt CHANGED
@@ -1 +1 @@
1
- 1.0.64
1
+ 1.0.65
@@ -1,2 +1,2 @@
1
1
  import { InputWidget } from "../../../interface";
2
- export default function LG({ state, placeholder, flag, type, label, }: InputWidget): import("react/jsx-runtime").JSX.Element;
2
+ export default function LG({ state, placeholder, isValid, type, label, maxLength, }: InputWidget): import("react/jsx-runtime").JSX.Element;
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useRef, useState } from "react";
3
3
  import { cn, gradient } from "../../../util";
4
4
  import Label from "../Label";
5
- export default function LG({ state, placeholder, flag, type, label, }) {
5
+ export default function LG({ state, placeholder, isValid, type, label, maxLength, }) {
6
6
  const [value, setValue] = state;
7
7
  const [onFocus, setOnFocus] = useState(false);
8
8
  const ref = useRef(null);
@@ -23,17 +23,21 @@ export default function LG({ state, placeholder, flag, type, label, }) {
23
23
  return "bg-crimson-burgundy/10 text-crimson-burgundy border-crimson-burgundy";
24
24
  };
25
25
  const inputBox = {
26
- styles: styleByFlag(flag),
26
+ styles: styleByFlag(isValid),
27
27
  sizes: "w-102.5 h-13.5",
28
28
  paddings: `${placeholder && "pt-3"} pl-5`,
29
29
  fonts: "text-sm",
30
30
  boundaries: "rounded-md outline-none",
31
31
  focuses: onFocus ? "border " : "border-0",
32
32
  shadows: onFocus &&
33
- !(flag === false) &&
33
+ !(isValid === false) &&
34
34
  "shadow-[0px_0px_10px_0px_rgba(16,86,82,0.38)]",
35
35
  };
36
- return (_jsxs("div", { className: cn(container), children: [_jsx("div", { onClick: () => ref.current?.focus(), className: cn(placeholderBox), children: placeholder }), _jsx("input", { ref: ref, className: cn(inputBox), value: value, onFocus: () => setOnFocus(true), onBlur: () => setOnFocus(false), onChange: (e) => setValue(e.target.value), type: type ?? "text" }), label && (_jsx(Label.Button, { title: label.title, onClick: label.onClick, option: {
36
+ return (_jsxs("div", { className: cn(container), children: [_jsx("div", { onClick: () => ref.current?.focus(), className: cn(placeholderBox), children: placeholder }), _jsx("input", { ref: ref, className: cn(inputBox), value: value, onFocus: () => setOnFocus(true), onBlur: () => setOnFocus(false), onChange: (e) => {
37
+ if (maxLength && e.target.value.length > maxLength)
38
+ return;
39
+ setValue(e.target.value);
40
+ }, type: type ?? "text" }), label && (_jsx(Label.Button, { title: label.title, onClick: label.onClick, option: {
37
41
  width: "sm",
38
42
  height: "xs",
39
43
  className: "absolute top-3.5 right-3.75",