@apexcura/ui-components 0.0.1 → 0.0.3

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/index.d.mts CHANGED
@@ -15,9 +15,10 @@ type ElementType = {
15
15
  label?: string;
16
16
  name?: string;
17
17
  suffix?: React.ReactNode;
18
+ maxLength?: number;
18
19
  };
19
20
 
20
- declare const InputElement: (props: ElementType) => React$1.JSX.Element;
21
+ declare const TextElement: (props: ElementType) => React$1.JSX.Element;
21
22
 
22
23
  interface InputData {
23
24
  placeholder?: string;
@@ -31,11 +32,10 @@ interface PasswordProps {
31
32
  }
32
33
  declare const PasswordElement: React$1.FC<PasswordProps>;
33
34
 
34
- interface SelectProps {
35
- placeholder: string;
36
- defaultValue: string;
37
- id: string;
38
- }
39
- declare const SelectElement: React$1.FC<SelectProps>;
35
+ declare const NumberElement: (props: ElementType) => React$1.JSX.Element;
36
+
37
+ declare const TextareaElement: (props: ElementType) => React$1.JSX.Element;
38
+
39
+ declare const SelectElement: (props: ElementType) => React$1.JSX.Element;
40
40
 
41
- export { InputElement, PasswordElement, SelectElement };
41
+ export { NumberElement, PasswordElement, SelectElement, TextElement, TextareaElement };
package/dist/index.d.ts CHANGED
@@ -15,9 +15,10 @@ type ElementType = {
15
15
  label?: string;
16
16
  name?: string;
17
17
  suffix?: React.ReactNode;
18
+ maxLength?: number;
18
19
  };
19
20
 
20
- declare const InputElement: (props: ElementType) => React$1.JSX.Element;
21
+ declare const TextElement: (props: ElementType) => React$1.JSX.Element;
21
22
 
22
23
  interface InputData {
23
24
  placeholder?: string;
@@ -31,11 +32,10 @@ interface PasswordProps {
31
32
  }
32
33
  declare const PasswordElement: React$1.FC<PasswordProps>;
33
34
 
34
- interface SelectProps {
35
- placeholder: string;
36
- defaultValue: string;
37
- id: string;
38
- }
39
- declare const SelectElement: React$1.FC<SelectProps>;
35
+ declare const NumberElement: (props: ElementType) => React$1.JSX.Element;
36
+
37
+ declare const TextareaElement: (props: ElementType) => React$1.JSX.Element;
38
+
39
+ declare const SelectElement: (props: ElementType) => React$1.JSX.Element;
40
40
 
41
- export { InputElement, PasswordElement, SelectElement };
41
+ export { NumberElement, PasswordElement, SelectElement, TextElement, TextareaElement };
package/dist/index.js CHANGED
@@ -30,19 +30,21 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var src_exports = {};
32
32
  __export(src_exports, {
33
- InputElement: () => InputElement,
33
+ NumberElement: () => NumberElement,
34
34
  PasswordElement: () => PasswordElement,
35
- SelectElement: () => SelectElement
35
+ SelectElement: () => SelectElement,
36
+ TextElement: () => TextElement,
37
+ TextareaElement: () => TextareaElement
36
38
  });
37
39
  module.exports = __toCommonJS(src_exports);
38
40
 
39
- // src/Components/InputElement.tsx
41
+ // src/Components/TextElement.tsx
40
42
  var import_react = __toESM(require("react"));
41
43
  var import_antd = require("antd");
42
44
  var onHandleChange = ($event) => {
43
45
  console.log($event);
44
46
  };
45
- var InputElement = (props) => {
47
+ var TextElement = (props) => {
46
48
  return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement("label", { htmlFor: props.name }, props.label), /* @__PURE__ */ import_react.default.createElement(
47
49
  import_antd.Input,
48
50
  {
@@ -90,32 +92,116 @@ var PasswordElement = ({ inputData }) => {
90
92
  return /* @__PURE__ */ import_react2.default.createElement(import_antd2.Space, { direction: "vertical" }, renderPasswordInput(), /* @__PURE__ */ import_react2.default.createElement(import_antd2.Space, { direction: "horizontal" }, renderPasswordInput(), /* @__PURE__ */ import_react2.default.createElement(import_antd2.Button, { style: { width: 80 }, onClick: handleVisibilityToggle }, passwordVisible ? "Hide" : "Show")));
91
93
  };
92
94
 
93
- // src/Components/SelectElement.tsx
95
+ // src/Components/NumberElement.tsx
94
96
  var import_react3 = __toESM(require("react"));
95
97
  var import_antd3 = require("antd");
98
+ var formatNumber = (value) => new Intl.NumberFormat().format(value);
99
+ var NumericInput = (props) => {
100
+ const { value, onChange } = props;
101
+ const handleChange = (e) => {
102
+ const { value: inputValue } = e.target;
103
+ const reg = /^-?\d*(\.\d*)?$/;
104
+ if (reg.test(inputValue) || inputValue === "" || inputValue === "-") {
105
+ onChange(inputValue);
106
+ }
107
+ };
108
+ const handleBlur = () => {
109
+ let valueTemp = value;
110
+ if (value.charAt(value.length - 1) === "." || value === "-") {
111
+ valueTemp = value.slice(0, -1);
112
+ }
113
+ onChange(valueTemp.replace(/0*(\d+)/, "$1"));
114
+ };
115
+ const title = value ? /* @__PURE__ */ import_react3.default.createElement("span", { className: "numeric-input-title" }, value !== "-" ? formatNumber(Number(value)) : "-") : "Input a number";
116
+ return /* @__PURE__ */ import_react3.default.createElement(import_antd3.Tooltip, { trigger: ["focus"], title, placement: "topLeft", overlayClassName: "numeric-input" }, /* @__PURE__ */ import_react3.default.createElement(
117
+ import_antd3.Input,
118
+ {
119
+ ...props,
120
+ onChange: handleChange,
121
+ onBlur: handleBlur,
122
+ placeholder: "Input a number",
123
+ maxLength: 16
124
+ }
125
+ ));
126
+ };
127
+ var NumberElement = (props) => {
128
+ const [value, setValue] = (0, import_react3.useState)("");
129
+ return /* @__PURE__ */ import_react3.default.createElement(
130
+ NumericInput,
131
+ {
132
+ ...props,
133
+ style: { width: 120 },
134
+ value,
135
+ onChange: setValue
136
+ }
137
+ );
138
+ };
139
+
140
+ // src/Components/TextareaElement.tsx
141
+ var import_react4 = __toESM(require("react"));
142
+ var import_antd4 = require("antd");
143
+ var { TextArea } = import_antd4.Input;
144
+ var onHandleChange2 = ($event) => {
145
+ console.log($event);
146
+ };
147
+ var TextareaElement = (props) => /* @__PURE__ */ import_react4.default.createElement(import_antd4.Flex, { vertical: true, gap: 32 }, /* @__PURE__ */ import_react4.default.createElement(
148
+ TextArea,
149
+ {
150
+ placeholder: props.placeholder,
151
+ allowClear: true,
152
+ defaultValue: props.defaultValue,
153
+ disabled: props.disabled,
154
+ id: props.name,
155
+ value: props.value,
156
+ status: props.status,
157
+ style: props.styles,
158
+ className: props.classNames,
159
+ variant: props.variant,
160
+ name: props.name,
161
+ showCount: true,
162
+ maxLength: props.maxLength,
163
+ onChange: onHandleChange2
164
+ }
165
+ ));
166
+
167
+ // src/Components/SelectElement.tsx
168
+ var import_react5 = __toESM(require("react"));
169
+ var import_antd5 = require("antd");
96
170
  var options = [
97
171
  {
98
- value: "zhejiang",
99
- label: "Zhejiang"
172
+ value: "male",
173
+ label: "male"
174
+ },
175
+ {
176
+ value: "female",
177
+ label: "female"
100
178
  },
101
179
  {
102
- value: "jiangsu",
103
- label: "Jiangsu"
180
+ value: "other",
181
+ label: "other"
104
182
  }
105
183
  ];
106
- var SelectElement = (props) => /* @__PURE__ */ import_react3.default.createElement(
107
- import_antd3.Select,
184
+ var SelectElement = (props) => /* @__PURE__ */ import_react5.default.createElement(
185
+ import_antd5.Select,
108
186
  {
109
187
  placeholder: props.placeholder,
110
188
  allowClear: true,
111
189
  defaultValue: props.defaultValue,
112
- id: props.id,
190
+ disabled: props.disabled,
191
+ id: props.name,
192
+ value: props.value,
193
+ status: props.status,
194
+ style: props.styles,
195
+ className: props.classNames,
196
+ variant: props.variant,
113
197
  options
114
198
  }
115
199
  );
116
200
  // Annotate the CommonJS export names for ESM import in node:
117
201
  0 && (module.exports = {
118
- InputElement,
202
+ NumberElement,
119
203
  PasswordElement,
120
- SelectElement
204
+ SelectElement,
205
+ TextElement,
206
+ TextareaElement
121
207
  });
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
- // src/Components/InputElement.tsx
1
+ // src/Components/TextElement.tsx
2
2
  import React from "react";
3
3
  import { Input as AntInput } from "antd";
4
4
  var onHandleChange = ($event) => {
5
5
  console.log($event);
6
6
  };
7
- var InputElement = (props) => {
7
+ var TextElement = (props) => {
8
8
  return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("label", { htmlFor: props.name }, props.label), /* @__PURE__ */ React.createElement(
9
9
  AntInput,
10
10
  {
@@ -52,31 +52,115 @@ var PasswordElement = ({ inputData }) => {
52
52
  return /* @__PURE__ */ React2.createElement(Space, { direction: "vertical" }, renderPasswordInput(), /* @__PURE__ */ React2.createElement(Space, { direction: "horizontal" }, renderPasswordInput(), /* @__PURE__ */ React2.createElement(Button, { style: { width: 80 }, onClick: handleVisibilityToggle }, passwordVisible ? "Hide" : "Show")));
53
53
  };
54
54
 
55
+ // src/Components/NumberElement.tsx
56
+ import React3, { useState as useState2 } from "react";
57
+ import { Input as Input2, Tooltip } from "antd";
58
+ var formatNumber = (value) => new Intl.NumberFormat().format(value);
59
+ var NumericInput = (props) => {
60
+ const { value, onChange } = props;
61
+ const handleChange = (e) => {
62
+ const { value: inputValue } = e.target;
63
+ const reg = /^-?\d*(\.\d*)?$/;
64
+ if (reg.test(inputValue) || inputValue === "" || inputValue === "-") {
65
+ onChange(inputValue);
66
+ }
67
+ };
68
+ const handleBlur = () => {
69
+ let valueTemp = value;
70
+ if (value.charAt(value.length - 1) === "." || value === "-") {
71
+ valueTemp = value.slice(0, -1);
72
+ }
73
+ onChange(valueTemp.replace(/0*(\d+)/, "$1"));
74
+ };
75
+ const title = value ? /* @__PURE__ */ React3.createElement("span", { className: "numeric-input-title" }, value !== "-" ? formatNumber(Number(value)) : "-") : "Input a number";
76
+ return /* @__PURE__ */ React3.createElement(Tooltip, { trigger: ["focus"], title, placement: "topLeft", overlayClassName: "numeric-input" }, /* @__PURE__ */ React3.createElement(
77
+ Input2,
78
+ {
79
+ ...props,
80
+ onChange: handleChange,
81
+ onBlur: handleBlur,
82
+ placeholder: "Input a number",
83
+ maxLength: 16
84
+ }
85
+ ));
86
+ };
87
+ var NumberElement = (props) => {
88
+ const [value, setValue] = useState2("");
89
+ return /* @__PURE__ */ React3.createElement(
90
+ NumericInput,
91
+ {
92
+ ...props,
93
+ style: { width: 120 },
94
+ value,
95
+ onChange: setValue
96
+ }
97
+ );
98
+ };
99
+
100
+ // src/Components/TextareaElement.tsx
101
+ import React4 from "react";
102
+ import { Flex, Input as Input3 } from "antd";
103
+ var { TextArea } = Input3;
104
+ var onHandleChange2 = ($event) => {
105
+ console.log($event);
106
+ };
107
+ var TextareaElement = (props) => /* @__PURE__ */ React4.createElement(Flex, { vertical: true, gap: 32 }, /* @__PURE__ */ React4.createElement(
108
+ TextArea,
109
+ {
110
+ placeholder: props.placeholder,
111
+ allowClear: true,
112
+ defaultValue: props.defaultValue,
113
+ disabled: props.disabled,
114
+ id: props.name,
115
+ value: props.value,
116
+ status: props.status,
117
+ style: props.styles,
118
+ className: props.classNames,
119
+ variant: props.variant,
120
+ name: props.name,
121
+ showCount: true,
122
+ maxLength: props.maxLength,
123
+ onChange: onHandleChange2
124
+ }
125
+ ));
126
+
55
127
  // src/Components/SelectElement.tsx
56
- import React3 from "react";
128
+ import React5 from "react";
57
129
  import { Select as AntSelect } from "antd";
58
130
  var options = [
59
131
  {
60
- value: "zhejiang",
61
- label: "Zhejiang"
132
+ value: "male",
133
+ label: "male"
134
+ },
135
+ {
136
+ value: "female",
137
+ label: "female"
62
138
  },
63
139
  {
64
- value: "jiangsu",
65
- label: "Jiangsu"
140
+ value: "other",
141
+ label: "other"
66
142
  }
67
143
  ];
68
- var SelectElement = (props) => /* @__PURE__ */ React3.createElement(
144
+ var SelectElement = (props) => /* @__PURE__ */ React5.createElement(
69
145
  AntSelect,
70
146
  {
71
147
  placeholder: props.placeholder,
72
148
  allowClear: true,
73
149
  defaultValue: props.defaultValue,
74
- id: props.id,
150
+ disabled: props.disabled,
151
+ id: props.name,
152
+ value: props.value,
153
+ status: props.status,
154
+ style: props.styles,
155
+ className: props.classNames,
156
+ variant: props.variant,
75
157
  options
76
158
  }
77
159
  );
78
160
  export {
79
- InputElement,
161
+ NumberElement,
80
162
  PasswordElement,
81
- SelectElement
163
+ SelectElement,
164
+ TextElement,
165
+ TextareaElement
82
166
  };
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@apexcura/ui-components",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "Apex cura React components library",
5
- "keywords" : ["apec cura", "input", "ui", "react", "react-component"],
5
+ "keywords" : ["apex cura", "input", "ui", "react", "react-component"],
6
6
  "homepage": "https://www.apexcura.com/",
7
7
  "bugs": {
8
8
  "url": "https://github.com/apexcura/ui-components/issues"