ar-design 0.2.99 → 0.3.0

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.
@@ -0,0 +1,4 @@
1
+ import { IBorder, IColors, ISize, IUpperCase, IValidation, IVariant } from "../../../libs/types/IGlobalProps";
2
+ interface IProps extends IVariant, IColors, IBorder, ISize, IUpperCase, IValidation, Omit<React.InputHTMLAttributes<HTMLInputElement>, "children" | "size" | "color" | "type"> {
3
+ }
4
+ export default IProps;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import IProps from "./IProps";
3
+ declare const InputNumber: React.FC<IProps>;
4
+ export default InputNumber;
@@ -0,0 +1,38 @@
1
+ "use client";
2
+ import React, { useMemo, useRef, useState } from "react";
3
+ import Input from "../input";
4
+ const InputNumber = ({ ...attributes }) => {
5
+ // refs
6
+ const _input = useRef(null);
7
+ const _caretPosition = useRef(null);
8
+ // states
9
+ const [value, setValue] = useState(null);
10
+ // methods
11
+ const handleChange = (event) => {
12
+ let { value } = event.target;
13
+ // Temizle.
14
+ const cleanedValue = (value = value.replace(/[^0-9,]/g, ""));
15
+ // Numara olarak çevir.
16
+ const normalized = value.replace(/\./g, "").replace(",", ".");
17
+ const parsed = parseFloat(normalized);
18
+ const numberValue = isNaN(parsed) ? 0 : parsed;
19
+ // Formatla ve Kullanıcı , (virgül) girdiyse kuruş göster.
20
+ const isDecimals = cleanedValue.includes(",");
21
+ const formatted = numberValue === 0 && cleanedValue === "" ? "" : formatter(isDecimals).format(numberValue);
22
+ setValue(formatted);
23
+ };
24
+ const handleKeyUp = (event) => {
25
+ const caretPosition = event.currentTarget.selectionStart ?? 0;
26
+ _caretPosition.current = caretPosition;
27
+ };
28
+ const formatter = useMemo(() => {
29
+ return (isDecimals) => new Intl.NumberFormat("tr-TR", {
30
+ style: "currency",
31
+ currency: "TRY",
32
+ minimumFractionDigits: isDecimals ? 2 : 0,
33
+ maximumFractionDigits: 2,
34
+ });
35
+ }, []);
36
+ return (React.createElement(Input, { ref: _input, ...attributes, value: value ?? "", onChange: handleChange, onKeyUp: handleKeyUp, type: "text", inputMode: "decimal" }));
37
+ };
38
+ export default InputNumber;
package/dist/index.d.ts CHANGED
@@ -5,6 +5,7 @@ import ButtonGroup from "./components/form/button-group";
5
5
  import Checkbox from "./components/form/checkbox";
6
6
  import DatePicker from "./components/form/date-picker";
7
7
  import Input from "./components/form/input";
8
+ import InputNumber from "./components/form/input-number";
8
9
  import InputTag from "./components/form/input-tag";
9
10
  import Radio from "./components/form/radio";
10
11
  import Select from "./components/form/select";
@@ -32,4 +33,4 @@ import Menu from "./components/navigation/menu";
32
33
  import Steps from "./components/navigation/steps";
33
34
  import Grid from "./components/data-display/grid-system";
34
35
  import Layout from "./components/layout";
35
- export { Button, ButtonAction, ButtonGroup, Checkbox, DatePicker, Input, InputTag, Radio, Select, Switch, TextEditor, Upload, Card, Chip, Diagram, Divider, DnD, Paper, SyntaxHighlighter, Table, Tabs, Typography, Alert, Drawer, Modal, Popover, Progress, Tooltip, Breadcrumb, Menu, Steps, Grid, Layout, };
36
+ export { Button, ButtonAction, ButtonGroup, Checkbox, DatePicker, Input, InputNumber, InputTag, Radio, Select, Switch, TextEditor, Upload, Card, Chip, Diagram, Divider, DnD, Paper, SyntaxHighlighter, Table, Tabs, Typography, Alert, Drawer, Modal, Popover, Progress, Tooltip, Breadcrumb, Menu, Steps, Grid, Layout, };
package/dist/index.js CHANGED
@@ -6,6 +6,7 @@ import ButtonGroup from "./components/form/button-group";
6
6
  import Checkbox from "./components/form/checkbox";
7
7
  import DatePicker from "./components/form/date-picker";
8
8
  import Input from "./components/form/input";
9
+ import InputNumber from "./components/form/input-number";
9
10
  import InputTag from "./components/form/input-tag";
10
11
  import Radio from "./components/form/radio";
11
12
  import Select from "./components/form/select";
@@ -39,7 +40,7 @@ import Grid from "./components/data-display/grid-system";
39
40
  import Layout from "./components/layout";
40
41
  export {
41
42
  // Form Elements
42
- Button, ButtonAction, ButtonGroup, Checkbox, DatePicker, Input, InputTag, Radio, Select, Switch, TextEditor, Upload,
43
+ Button, ButtonAction, ButtonGroup, Checkbox, DatePicker, Input, InputNumber, InputTag, Radio, Select, Switch, TextEditor, Upload,
43
44
  // Data Display
44
45
  Card, Chip, Diagram, Divider, DnD, Paper, SyntaxHighlighter, Table, Tabs, Typography,
45
46
  // Feedback
@@ -2,11 +2,13 @@ declare class Api {
2
2
  private _host?;
3
3
  private _core?;
4
4
  private _token?;
5
+ private _init?;
5
6
  private _url;
6
7
  constructor(values: {
7
8
  host?: string;
8
9
  core?: string;
9
10
  token?: string;
11
+ init?: RequestInit;
10
12
  });
11
13
  Get(values: {
12
14
  input?: RequestInfo | undefined;
@@ -2,11 +2,13 @@ class Api {
2
2
  _host;
3
3
  _core;
4
4
  _token;
5
+ _init;
5
6
  _url;
6
7
  constructor(values) {
7
8
  this._host = values.host || (typeof window !== "undefined" ? window.location.origin : "");
8
9
  this._core = values.core || "";
9
10
  this._token = values.token;
11
+ this._init = values.init;
10
12
  // Url
11
13
  this._url = `${this._host}/${this._core ? this._core + "/" : ""}`;
12
14
  }
@@ -114,7 +116,9 @@ class Api {
114
116
  async CustomFetch(input, init) {
115
117
  try {
116
118
  // # Request Interceptor
117
- const request = await fetch(input, init);
119
+ console.log(init);
120
+ console.log(this._init);
121
+ const request = await fetch(input, { ...init, ...this._init });
118
122
  // # Response Interceptor
119
123
  // Error Handling
120
124
  if (!request.ok) {
@@ -13,6 +13,7 @@ declare class Service {
13
13
  core?: string;
14
14
  endPoint?: string;
15
15
  token?: string;
16
+ init?: RequestInit;
16
17
  });
17
18
  Get<TResponse>(values?: {
18
19
  input?: string;
@@ -3,7 +3,7 @@ class Service {
3
3
  _api;
4
4
  _endPoint;
5
5
  constructor(values) {
6
- this._api = new Api({ host: values.host, core: values.core, token: values.token });
6
+ this._api = new Api({ host: values.host, core: values.core, token: values.token, init: values.init });
7
7
  this._endPoint = values.endPoint;
8
8
  }
9
9
  async Get(values) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ar-design",
3
- "version": "0.2.99",
3
+ "version": "0.3.0",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",