@arkyn/components 3.0.1-beta.140 → 3.0.1-beta.141
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/bundle.js +985 -968
- package/dist/components/checkbox/index.d.ts +5 -1
- package/dist/components/checkbox/index.d.ts.map +1 -1
- package/dist/components/checkbox/index.js +6 -6
- package/dist/components/currencyInput/index.d.ts +5 -0
- package/dist/components/currencyInput/index.d.ts.map +1 -1
- package/dist/components/currencyInput/index.js +6 -5
- package/dist/components/imageUpload/index.d.ts +4 -0
- package/dist/components/imageUpload/index.d.ts.map +1 -1
- package/dist/components/imageUpload/index.js +5 -5
- package/dist/components/input/index.d.ts +4 -0
- package/dist/components/input/index.d.ts.map +1 -1
- package/dist/components/input/index.js +5 -5
- package/dist/components/multiSelect/index.d.ts +4 -0
- package/dist/components/multiSelect/index.d.ts.map +1 -1
- package/dist/components/multiSelect/index.js +5 -5
- package/dist/components/phoneInput/index.d.ts +48 -0
- package/dist/components/phoneInput/index.d.ts.map +1 -1
- package/dist/components/phoneInput/index.js +60 -16
- package/dist/components/radio/radioGroup/index.d.ts +4 -0
- package/dist/components/radio/radioGroup/index.d.ts.map +1 -1
- package/dist/components/radio/radioGroup/index.js +5 -5
- package/dist/components/richText/index.d.ts +2 -0
- package/dist/components/richText/index.d.ts.map +1 -1
- package/dist/components/richText/index.js +12 -12
- package/dist/components/select/index.d.ts +4 -0
- package/dist/components/select/index.d.ts.map +1 -1
- package/dist/components/select/index.js +5 -5
- package/dist/components/switch/index.d.ts +5 -1
- package/dist/components/switch/index.d.ts.map +1 -1
- package/dist/components/switch/index.js +6 -6
- package/dist/hooks/useAutomation.d.ts +29 -24
- package/dist/hooks/useAutomation.d.ts.map +1 -1
- package/dist/hooks/useAutomation.js +50 -38
- package/dist/services/fieldTemplate.d.ts +14 -0
- package/dist/services/fieldTemplate.d.ts.map +1 -0
- package/dist/services/fieldTemplate.js +11 -0
- package/dist/types/richTextTypes.d.ts +3 -0
- package/dist/types/richTextTypes.d.ts.map +1 -1
- package/package.json +3 -1
|
@@ -2,6 +2,8 @@ import { ButtonHTMLAttributes } from "react";
|
|
|
2
2
|
import "./styles.css";
|
|
3
3
|
type CheckboxProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, "size" | "prefix" | "type" | "name" | "defaultValue" | "value" | "onChange" | "onSelect" | "onClick"> & {
|
|
4
4
|
label?: string;
|
|
5
|
+
showAsterisk?: boolean;
|
|
6
|
+
unShowFieldTemplate?: boolean;
|
|
5
7
|
errorMessage?: string;
|
|
6
8
|
size?: "md" | "lg" | "sm";
|
|
7
9
|
name: string;
|
|
@@ -23,7 +25,9 @@ type CheckboxProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, "size" | "pre
|
|
|
23
25
|
* @param props.checked - Controlled checked state of the checkbox
|
|
24
26
|
* @param props.defaultChecked - Default checked state for uncontrolled usage. Default: false
|
|
25
27
|
* @param props.onCheck - Callback function called when checkbox state changes, receives the value or empty string
|
|
26
|
-
* @param props.
|
|
28
|
+
* @param props.showAsterisk - Whether to show asterisk on label for required fields
|
|
29
|
+
* @param props.unShowFieldTemplate - When true, skips `FieldTemplate` structure (wrapper, label and error text) and renders only the checkbox button content.
|
|
30
|
+
* @param props.orientation - Layout direction forwarded to `FieldTemplate`/`FieldWrapper` (`horizontal`, `vertical`, `horizontalReverse`). Default: "horizontalReverse"
|
|
27
31
|
*
|
|
28
32
|
* **...Other valid HTML properties for button element (except type, name, defaultValue, value, onChange, onSelect, onClick)**
|
|
29
33
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/checkbox/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAA2B,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/checkbox/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAA2B,MAAM,OAAO,CAAC;AAKtE,OAAO,cAAc,CAAC;AAEtB,KAAK,aAAa,GAAG,IAAI,CACvB,oBAAoB,CAAC,iBAAiB,CAAC,EACrC,MAAM,GACN,QAAQ,GACR,MAAM,GACN,MAAM,GACN,cAAc,GACd,OAAO,GACP,UAAU,GACV,UAAU,GACV,SAAS,CACZ,GAAG;IACF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAE1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,WAAW,CAAC,EAAE,YAAY,GAAG,UAAU,GAAG,mBAAmB,CAAC;CAC/D,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AAEH,iBAAS,QAAQ,CAAC,KAAK,EAAE,aAAa,2CAsErC;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -2,9 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Check } from "lucide-react";
|
|
3
3
|
import { useId, useRef, useState } from "react";
|
|
4
4
|
import { useForm } from "../../hooks/useForm";
|
|
5
|
-
import {
|
|
6
|
-
import { FieldError } from "../fieldError";
|
|
7
|
-
import { FieldLabel } from "../fieldLabel";
|
|
5
|
+
import { FieldTemplate } from "../../services/fieldTemplate";
|
|
8
6
|
import "./styles.css";
|
|
9
7
|
/**
|
|
10
8
|
* Checkbox component - used for creating interactive checkbox inputs with customizable styling and validation
|
|
@@ -18,7 +16,9 @@ import "./styles.css";
|
|
|
18
16
|
* @param props.checked - Controlled checked state of the checkbox
|
|
19
17
|
* @param props.defaultChecked - Default checked state for uncontrolled usage. Default: false
|
|
20
18
|
* @param props.onCheck - Callback function called when checkbox state changes, receives the value or empty string
|
|
21
|
-
* @param props.
|
|
19
|
+
* @param props.showAsterisk - Whether to show asterisk on label for required fields
|
|
20
|
+
* @param props.unShowFieldTemplate - When true, skips `FieldTemplate` structure (wrapper, label and error text) and renders only the checkbox button content.
|
|
21
|
+
* @param props.orientation - Layout direction forwarded to `FieldTemplate`/`FieldWrapper` (`horizontal`, `vertical`, `horizontalReverse`). Default: "horizontalReverse"
|
|
22
22
|
*
|
|
23
23
|
* **...Other valid HTML properties for button element (except type, name, defaultValue, value, onChange, onSelect, onClick)**
|
|
24
24
|
*
|
|
@@ -66,7 +66,7 @@ import "./styles.css";
|
|
|
66
66
|
* ```
|
|
67
67
|
*/
|
|
68
68
|
function Checkbox(props) {
|
|
69
|
-
const { id, name, className: wrapperClassName = "", size = "md", errorMessage: baseErrorMessage, defaultChecked = false, label, checked: baseChecked = null, onCheck, orientation = "horizontalReverse", value, ...rest } = props;
|
|
69
|
+
const { id, name, className: wrapperClassName = "", size = "md", errorMessage: baseErrorMessage, defaultChecked = false, label, checked: baseChecked = null, onCheck, orientation = "horizontalReverse", showAsterisk, unShowFieldTemplate, value, ...rest } = props;
|
|
70
70
|
const { fieldErrors } = useForm();
|
|
71
71
|
const checkboxRef = useRef(null);
|
|
72
72
|
const checkboxId = id || useId();
|
|
@@ -82,6 +82,6 @@ function Checkbox(props) {
|
|
|
82
82
|
setIsChecked(!defaultChecked);
|
|
83
83
|
onCheck && onCheck(!defaultChecked ? value || "checked" : "");
|
|
84
84
|
}
|
|
85
|
-
return (
|
|
85
|
+
return (_jsx(FieldTemplate, { name: name, label: label, showAsterisk: showAsterisk, className: wrapperClassName, errorMessage: errorMessage, unShowFieldTemplate: unShowFieldTemplate, orientation: orientation, children: _jsxs("button", { id: checkboxId, type: "button", className: className, onClick: handleCheck, ...rest, children: [_jsx("input", { type: "hidden", name: name, ref: checkboxRef, value: currentChecked ? value || "checked" : "" }), _jsx(Check, {})] }) }));
|
|
86
86
|
}
|
|
87
87
|
export { Checkbox };
|
|
@@ -8,8 +8,10 @@ type CurrencyInputProps = Omit<InputHTMLAttributes<HTMLInputElement>, "size" | "
|
|
|
8
8
|
label?: string;
|
|
9
9
|
errorMessage?: string;
|
|
10
10
|
isLoading?: boolean;
|
|
11
|
+
unShowFieldTemplate?: boolean;
|
|
11
12
|
size?: "md" | "lg";
|
|
12
13
|
variant?: "solid" | "outline" | "underline";
|
|
14
|
+
orientation?: "horizontal" | "vertical" | "horizontalReverse";
|
|
13
15
|
prefix?: string | LucideIcon;
|
|
14
16
|
suffix?: string | LucideIcon;
|
|
15
17
|
showAsterisk?: boolean;
|
|
@@ -40,6 +42,9 @@ type CurrencyInputProps = Omit<InputHTMLAttributes<HTMLInputElement>, "size" | "
|
|
|
40
42
|
* @param props.value - Controlled value (number) for the input
|
|
41
43
|
* @param props.defaultValue - Default value (number) for uncontrolled usage
|
|
42
44
|
* @param props.onChange - Callback function called when value changes, receives event, original value and masked value
|
|
45
|
+
* @param props.unShowFieldTemplate - When true, skips `FieldTemplate` structure (wrapper, label and error text) and renders only the checkbox button content.
|
|
46
|
+
* @param props.orientation - Layout direction forwarded to `FieldTemplate`/`FieldWrapper` (`horizontal`, `vertical`, `horizontalReverse`). Default: "horizontalReverse"
|
|
47
|
+
*
|
|
43
48
|
*
|
|
44
49
|
* **...Other valid HTML properties for input element (except type, max, defaultValue, value, onChange)**
|
|
45
50
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/currencyInput/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAW,UAAU,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EACL,WAAW,EACX,mBAAmB,EAMpB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/currencyInput/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAW,UAAU,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EACL,WAAW,EACX,mBAAmB,EAMpB,MAAM,OAAO,CAAC;AAUf,OAAO,aAAa,CAAC;AAErB,KAAK,MAAM,GACP,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,CAAC;AAEV,KAAK,kBAAkB,GAAG,IAAI,CAC5B,mBAAmB,CAAC,gBAAgB,CAAC,EACnC,MAAM,GACN,QAAQ,GACR,MAAM,GACN,MAAM,GACN,KAAK,GACL,cAAc,GACd,OAAO,GACP,UAAU,GACV,aAAa,CAChB,GAAG;IACF,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IAEf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,WAAW,CAAC;IAC5C,WAAW,CAAC,EAAE,YAAY,GAAG,UAAU,GAAG,mBAAmB,CAAC;IAE9D,MAAM,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAC7B,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,SAAS,CAAC,EAAE,UAAU,CAAC;IAEvB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,QAAQ,CAAC,EAAE,CACT,KAAK,EAAE,WAAW,CAAC,gBAAgB,CAAC,EACpC,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,KAChB,IAAI,CAAC;CACX,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2EG;AAEH,iBAAS,aAAa,CAAC,KAAK,EAAE,kBAAkB,2CAuK/C;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -2,11 +2,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Loader2 } from "lucide-react";
|
|
3
3
|
import { useEffect, useId, useRef, useState, } from "react";
|
|
4
4
|
import { useForm } from "../../hooks/useForm";
|
|
5
|
+
import { FieldTemplate } from "../../services/fieldTemplate";
|
|
5
6
|
import { IconRenderer } from "../../services/iconRenderer";
|
|
6
7
|
import { maskCurrencyValues, normalizeValue, } from "../../services/maskCurrencyValues";
|
|
7
|
-
import { FieldError } from "../fieldError";
|
|
8
|
-
import { FieldLabel } from "../fieldLabel";
|
|
9
|
-
import { FieldWrapper } from "../fieldWrapper";
|
|
10
8
|
import "./style.css";
|
|
11
9
|
/**
|
|
12
10
|
* CurrencyInput component - used for currency input fields with automatic formatting based on locale
|
|
@@ -28,6 +26,9 @@ import "./style.css";
|
|
|
28
26
|
* @param props.value - Controlled value (number) for the input
|
|
29
27
|
* @param props.defaultValue - Default value (number) for uncontrolled usage
|
|
30
28
|
* @param props.onChange - Callback function called when value changes, receives event, original value and masked value
|
|
29
|
+
* @param props.unShowFieldTemplate - When true, skips `FieldTemplate` structure (wrapper, label and error text) and renders only the checkbox button content.
|
|
30
|
+
* @param props.orientation - Layout direction forwarded to `FieldTemplate`/`FieldWrapper` (`horizontal`, `vertical`, `horizontalReverse`). Default: "horizontalReverse"
|
|
31
|
+
*
|
|
31
32
|
*
|
|
32
33
|
* **...Other valid HTML properties for input element (except type, max, defaultValue, value, onChange)**
|
|
33
34
|
*
|
|
@@ -82,7 +83,7 @@ import "./style.css";
|
|
|
82
83
|
* ```
|
|
83
84
|
*/
|
|
84
85
|
function CurrencyInput(props) {
|
|
85
|
-
const { name, disabled, title, style, variant = "solid", label, className: wrapperClassName = "", value, defaultValue, max = 1000000000, locale, onChange, prefix, suffix, isLoading = false, leftIcon, readOnly, onFocus, onBlur, errorMessage: baseErrorMessage, showAsterisk, rightIcon, size = "md", id, ...rest } = props;
|
|
86
|
+
const { name, disabled, title, style, variant = "solid", label, className: wrapperClassName = "", value, defaultValue, max = 1000000000, locale, onChange, prefix, suffix, isLoading = false, leftIcon, readOnly, onFocus, onBlur, errorMessage: baseErrorMessage, unShowFieldTemplate, orientation, showAsterisk, rightIcon, size = "md", id, ...rest } = props;
|
|
86
87
|
const { fieldErrors } = useForm();
|
|
87
88
|
const [isFocused, setIsFocused] = useState(false);
|
|
88
89
|
const [maskedValue, setMaskedValue] = useState("0");
|
|
@@ -142,6 +143,6 @@ function CurrencyInput(props) {
|
|
|
142
143
|
const opacity = isDisabled || readOnly || isLoading ? "opacity" : "";
|
|
143
144
|
const focused = isFocused ? "focused" : "";
|
|
144
145
|
const className = `arkynCurrencyInput ${hasPrefix} ${hasSuffix} ${variant} ${size} ${opacity} ${errored} ${focused}`;
|
|
145
|
-
return (
|
|
146
|
+
return (_jsx(FieldTemplate, { name: name, label: label, showAsterisk: showAsterisk, className: wrapperClassName, errorMessage: errorMessage, unShowFieldTemplate: unShowFieldTemplate, orientation: orientation, children: _jsxs("section", { title: title, style: style, className: className, onClick: handleSectionClick, children: [_jsx(IconRenderer, { iconSize: iconSize, icon: prefix, className: "prefix" }), _jsx(IconRenderer, { show: showLeftSpinner, iconSize: iconSize, className: "spinner", icon: Loader2 }), _jsx(IconRenderer, { show: !isLoading, icon: leftIcon, iconSize: iconSize }), _jsx("input", { disabled: isDisabled, readOnly: readOnly, ref: inputRef, onFocus: handleFocus, onBlur: handleBlur, onChange: handleChange, id: inputId, placeholder: isDisabled ? maskedValue : undefined, value: isDisabled ? undefined : maskedValue, ...rest }), _jsx("input", { type: "hidden", name: name, value: normalizeValue(maskedValue), readOnly: true }), _jsx(IconRenderer, { show: !isLoading, icon: rightIcon, iconSize: iconSize }), _jsx(IconRenderer, { show: showRightSpinner, iconSize: iconSize, className: "spinner", icon: Loader2 }), _jsx(IconRenderer, { iconSize: iconSize, icon: suffix, className: "suffix" })] }) }));
|
|
146
147
|
}
|
|
147
148
|
export { CurrencyInput };
|
|
@@ -15,6 +15,8 @@ type ImageUploadProps = {
|
|
|
15
15
|
fileResponseName?: string;
|
|
16
16
|
acceptImage?: string;
|
|
17
17
|
onChange?: (url: string) => void;
|
|
18
|
+
unShowFieldTemplate?: boolean;
|
|
19
|
+
orientation?: "horizontal" | "vertical" | "horizontalReverse";
|
|
18
20
|
};
|
|
19
21
|
/**
|
|
20
22
|
* ImageUpload component - specialized file upload component for image files with preview functionality
|
|
@@ -35,6 +37,8 @@ type ImageUploadProps = {
|
|
|
35
37
|
* @param props.fileResponseName - Property name in the response object containing the image URL. Default: "url"
|
|
36
38
|
* @param props.acceptImage - Image file types accepted by the input (e.g., "image/*", ".jpg,.png"). Default: "image/*"
|
|
37
39
|
* @param props.onChange - Callback function called when image upload completes successfully, receives the image URL
|
|
40
|
+
* @param props.unShowFieldTemplate - When true, skips `FieldTemplate` structure (wrapper, label and error text) and renders only the checkbox button content.
|
|
41
|
+
* @param props.orientation - Layout direction forwarded to `FieldTemplate`/`FieldWrapper` (`horizontal`, `vertical`, `horizontalReverse`). Default: "horizontalReverse"
|
|
38
42
|
*
|
|
39
43
|
* @returns ImageUpload JSX element wrapped in FieldGroup with optional label, image preview, and error handling
|
|
40
44
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/imageUpload/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/imageUpload/index.tsx"],"names":[],"mappings":"AAOA,OAAO,cAAc,CAAC;AAEtB,KAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAEjC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,WAAW,CAAC,EAAE,YAAY,GAAG,UAAU,GAAG,mBAAmB,CAAC;CAC/D,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgGG;AAEH,iBAAS,WAAW,CAAC,KAAK,EAAE,gBAAgB,2CA2G3C;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from "react";
|
|
3
3
|
import { useForm } from "../../hooks/useForm";
|
|
4
|
-
import {
|
|
5
|
-
import { FieldLabel } from "../fieldLabel";
|
|
6
|
-
import { FieldWrapper } from "../fieldWrapper";
|
|
4
|
+
import { FieldTemplate } from "../../services/fieldTemplate";
|
|
7
5
|
import { HasFileContent } from "./hasFileContent";
|
|
8
6
|
import { NoFileContent } from "./noFileContent";
|
|
9
7
|
import "./styles.css";
|
|
@@ -26,6 +24,8 @@ import "./styles.css";
|
|
|
26
24
|
* @param props.fileResponseName - Property name in the response object containing the image URL. Default: "url"
|
|
27
25
|
* @param props.acceptImage - Image file types accepted by the input (e.g., "image/*", ".jpg,.png"). Default: "image/*"
|
|
28
26
|
* @param props.onChange - Callback function called when image upload completes successfully, receives the image URL
|
|
27
|
+
* @param props.unShowFieldTemplate - When true, skips `FieldTemplate` structure (wrapper, label and error text) and renders only the checkbox button content.
|
|
28
|
+
* @param props.orientation - Layout direction forwarded to `FieldTemplate`/`FieldWrapper` (`horizontal`, `vertical`, `horizontalReverse`). Default: "horizontalReverse"
|
|
29
29
|
*
|
|
30
30
|
* @returns ImageUpload JSX element wrapped in FieldGroup with optional label, image preview, and error handling
|
|
31
31
|
*
|
|
@@ -103,7 +103,7 @@ import "./styles.css";
|
|
|
103
103
|
* ```
|
|
104
104
|
*/
|
|
105
105
|
function ImageUpload(props) {
|
|
106
|
-
const { name, defaultValue = "", label, showAsterisk = false, action, fileName = "file", className: wrapperClassName = "", method = "POST", acceptImage = "image/*", fileResponseName = "url", changeImageButtonText = "Alterar imagem", selectImageButtonText = "Selecionar imagem", dropImageText = "Ou arraste e solte a imagem aqui", onChange, disabled = false, } = props;
|
|
106
|
+
const { name, defaultValue = "", label, showAsterisk = false, action, fileName = "file", className: wrapperClassName = "", method = "POST", acceptImage = "image/*", fileResponseName = "url", changeImageButtonText = "Alterar imagem", selectImageButtonText = "Selecionar imagem", dropImageText = "Ou arraste e solte a imagem aqui", onChange, disabled = false, unShowFieldTemplate = false, orientation = "horizontal", } = props;
|
|
107
107
|
const { fieldErrors } = useForm();
|
|
108
108
|
const fieldError = fieldErrors?.[name];
|
|
109
109
|
const [value, setValue] = useState(defaultValue);
|
|
@@ -144,6 +144,6 @@ function ImageUpload(props) {
|
|
|
144
144
|
const hasErrorClassName = errorMessage ? "hasError" : "noHasError";
|
|
145
145
|
const hasImageClassName = filePath ? "hasImage" : "noHasImage";
|
|
146
146
|
const className = `arkynImageUpload ${hasErrorClassName} ${hasImageClassName}`;
|
|
147
|
-
return (
|
|
147
|
+
return (_jsx(FieldTemplate, { name: name, label: label, showAsterisk: showAsterisk, className: wrapperClassName, errorMessage: errorMessage, unShowFieldTemplate: unShowFieldTemplate, orientation: orientation, children: _jsxs("div", { className: className, children: [_jsx("input", { type: "hidden", name: name, value: value || "" }), !filePath && (_jsx(NoFileContent, { disabled: disabled, isLoading: isLoading, acceptImage: acceptImage, dropImageText: dropImageText, handleSelectFile: handleSelectFile, selectImageButtonText: selectImageButtonText })), filePath && (_jsx(HasFileContent, { disabled: disabled, isLoading: isLoading, acceptImage: acceptImage, filePath: filePath, handleSelectFile: handleSelectFile, changeImageButtonText: changeImageButtonText, reSendImage: !!errorMessage && file ? () => handleUploadImage(file) : undefined }))] }) }));
|
|
148
148
|
}
|
|
149
149
|
export { ImageUpload };
|
|
@@ -6,11 +6,13 @@ type InputProps = Omit<InputHTMLAttributes<HTMLInputElement>, "size" | "prefix"
|
|
|
6
6
|
label?: string;
|
|
7
7
|
errorMessage?: string;
|
|
8
8
|
isLoading?: boolean;
|
|
9
|
+
unShowFieldTemplate?: boolean;
|
|
9
10
|
size?: "md" | "lg";
|
|
10
11
|
variant?: "solid" | "outline" | "underline";
|
|
11
12
|
prefix?: string | LucideIcon;
|
|
12
13
|
suffix?: string | LucideIcon;
|
|
13
14
|
showAsterisk?: boolean;
|
|
15
|
+
orientation?: "horizontal" | "vertical" | "horizontalReverse";
|
|
14
16
|
leftIcon?: LucideIcon;
|
|
15
17
|
rightIcon?: LucideIcon;
|
|
16
18
|
value?: string;
|
|
@@ -31,6 +33,8 @@ type InputProps = Omit<InputHTMLAttributes<HTMLInputElement>, "size" | "prefix"
|
|
|
31
33
|
* @param props.showAsterisk - Whether to show asterisk on label for required fields
|
|
32
34
|
* @param props.leftIcon - Optional icon to display on the left side
|
|
33
35
|
* @param props.rightIcon - Optional icon to display on the right side
|
|
36
|
+
* @param props.unShowFieldTemplate - When true, skips `FieldTemplate` structure (wrapper, label and error text) and renders only the checkbox button content.
|
|
37
|
+
* @param props.orientation - Layout direction forwarded to `FieldTemplate`/`FieldWrapper` (`horizontal`, `vertical`, `horizontalReverse`). Default: "horizontalReverse"
|
|
34
38
|
*
|
|
35
39
|
* **...Other valid HTML properties for input element**
|
|
36
40
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/input/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAW,UAAU,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EACL,mBAAmB,EAKpB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/input/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAW,UAAU,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EACL,mBAAmB,EAKpB,MAAM,OAAO,CAAC;AAMf,OAAO,aAAa,CAAC;AAErB,KAAK,UAAU,GAAG,IAAI,CACpB,mBAAmB,CAAC,gBAAgB,CAAC,EACrC,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,cAAc,CACtD,GAAG;IACF,IAAI,EAAE,MAAM,CAAC;IAEb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,WAAW,CAAC;IAE5C,MAAM,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAC7B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,YAAY,GAAG,UAAU,GAAG,mBAAmB,CAAC;IAE9D,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,SAAS,CAAC,EAAE,UAAU,CAAC;IAEvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AAEH,iBAAS,KAAK,CAAC,KAAK,EAAE,UAAU,2CAyI/B;AAED,OAAO,EAAE,KAAK,EAAE,KAAK,UAAU,EAAE,CAAC"}
|
|
@@ -2,10 +2,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Loader2 } from "lucide-react";
|
|
3
3
|
import { useId, useRef, useState, } from "react";
|
|
4
4
|
import { useForm } from "../../hooks/useForm";
|
|
5
|
+
import { FieldTemplate } from "../../services/fieldTemplate";
|
|
5
6
|
import { IconRenderer } from "../../services/iconRenderer";
|
|
6
|
-
import { FieldError } from "../fieldError";
|
|
7
|
-
import { FieldLabel } from "../fieldLabel";
|
|
8
|
-
import { FieldWrapper } from "../fieldWrapper";
|
|
9
7
|
import "./style.css";
|
|
10
8
|
/**
|
|
11
9
|
* Input component - used for text input fields with support for labels, validation, icons, and loading states
|
|
@@ -22,6 +20,8 @@ import "./style.css";
|
|
|
22
20
|
* @param props.showAsterisk - Whether to show asterisk on label for required fields
|
|
23
21
|
* @param props.leftIcon - Optional icon to display on the left side
|
|
24
22
|
* @param props.rightIcon - Optional icon to display on the right side
|
|
23
|
+
* @param props.unShowFieldTemplate - When true, skips `FieldTemplate` structure (wrapper, label and error text) and renders only the checkbox button content.
|
|
24
|
+
* @param props.orientation - Layout direction forwarded to `FieldTemplate`/`FieldWrapper` (`horizontal`, `vertical`, `horizontalReverse`). Default: "horizontalReverse"
|
|
25
25
|
*
|
|
26
26
|
* **...Other valid HTML properties for input element**
|
|
27
27
|
*
|
|
@@ -70,7 +70,7 @@ import "./style.css";
|
|
|
70
70
|
* ```
|
|
71
71
|
*/
|
|
72
72
|
function Input(props) {
|
|
73
|
-
const { name, disabled, title, style, variant = "solid", label, className: wrapperClassName = "", prefix, suffix, isLoading = false, leftIcon, readOnly, onFocus, onBlur, errorMessage: baseErrorMessage, showAsterisk, rightIcon, type = "text", size = "md", id, value, placeholder, ...rest } = props;
|
|
73
|
+
const { name, disabled, title, style, variant = "solid", label, className: wrapperClassName = "", prefix, suffix, isLoading = false, leftIcon, readOnly, onFocus, onBlur, unShowFieldTemplate = false, errorMessage: baseErrorMessage, showAsterisk, rightIcon, type = "text", size = "md", id, value, placeholder, orientation, ...rest } = props;
|
|
74
74
|
const { fieldErrors } = useForm();
|
|
75
75
|
const [isFocused, setIsFocused] = useState(false);
|
|
76
76
|
const inputRef = useRef(null);
|
|
@@ -109,6 +109,6 @@ function Input(props) {
|
|
|
109
109
|
const focused = isFocused ? "focused" : "";
|
|
110
110
|
const disabledClass = disabled ? "disabled" : "";
|
|
111
111
|
const className = `arkynInput ${hasPrefix} ${disabledClass} ${hasSuffix} ${variant} ${size} ${opacity} ${errored} ${focused}`;
|
|
112
|
-
return (
|
|
112
|
+
return (_jsx(FieldTemplate, { name: name, label: label, showAsterisk: showAsterisk, className: wrapperClassName, errorMessage: errorMessage, unShowFieldTemplate: unShowFieldTemplate, orientation: orientation, children: _jsxs("section", { title: title, style: style, onClick: handleSectionClick, className: className, children: [_jsx(IconRenderer, { iconSize: iconSize, icon: prefix, className: "prefix" }), _jsx(IconRenderer, { show: showLeftSpinner, iconSize: iconSize, className: "spinner", icon: Loader2 }), _jsx(IconRenderer, { show: !isLoading, icon: leftIcon, iconSize: iconSize }), _jsx("input", { disabled: isDisabled, readOnly: readOnly, ref: inputRef, onFocus: handleFocus, onBlur: handleBlur, type: type, id: inputId, name: name, placeholder: isDisabled ? value || placeholder : placeholder, value: isDisabled ? undefined : value, ...rest }), _jsx(IconRenderer, { show: !isLoading, icon: rightIcon, iconSize: iconSize }), _jsx(IconRenderer, { show: showRightSpinner, iconSize: iconSize, className: "spinner", icon: Loader2 }), _jsx(IconRenderer, { iconSize: iconSize, icon: suffix, className: "suffix" })] }) }));
|
|
113
113
|
}
|
|
114
114
|
export { Input };
|
|
@@ -29,6 +29,8 @@ type MultiSelectProps = {
|
|
|
29
29
|
prefix?: string | LucideIcon;
|
|
30
30
|
leftIcon?: LucideIcon;
|
|
31
31
|
optionMaxHeight?: number;
|
|
32
|
+
unShowFieldTemplate?: boolean;
|
|
33
|
+
orientation?: "horizontal" | "vertical" | "horizontalReverse";
|
|
32
34
|
};
|
|
33
35
|
/**
|
|
34
36
|
* MultiSelect component - used for selecting multiple options from a dropdown list with support for search, labels, and validation
|
|
@@ -59,6 +61,8 @@ type MultiSelectProps = {
|
|
|
59
61
|
* @param props.prefix - Text or icon to display at the beginning of the multiselect
|
|
60
62
|
* @param props.leftIcon - Optional icon to display on the left side
|
|
61
63
|
* @param props.optionMaxHeight - Maximum height for the options dropdown
|
|
64
|
+
* @param props.unShowFieldTemplate - When true, skips `FieldTemplate` structure (wrapper, label and error text) and renders only the checkbox button content.
|
|
65
|
+
* @param props.orientation - Layout direction forwarded to `FieldTemplate`/`FieldWrapper` (`horizontal`, `vertical`, `horizontalReverse`). Default: "horizontalReverse"
|
|
62
66
|
*
|
|
63
67
|
* @returns MultiSelect JSX element wrapped in FieldWrapper with optional label and error
|
|
64
68
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/multiSelect/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAA2B,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/multiSelect/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAA2B,MAAM,OAAO,CAAC;AAe5D,KAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAE5C,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAErC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,CAAC,cAAc,CAAC,KAAK,IAAI,CAAC;IAEjD,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,WAAW,CAAC;IAE5C,MAAM,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAC7B,QAAQ,CAAC,EAAE,UAAU,CAAC;IAEtB,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,WAAW,CAAC,EAAE,YAAY,GAAG,UAAU,GAAG,mBAAmB,CAAC;CAC/D,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2FG;AAEH,iBAAS,WAAW,CAAC,KAAK,EAAE,gBAAgB,2CA8K3C;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -2,9 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useId, useRef, useState } from "react";
|
|
3
3
|
import { useForm } from "../../hooks/useForm";
|
|
4
4
|
import { IconRenderer } from "../../services/iconRenderer";
|
|
5
|
-
import {
|
|
6
|
-
import { FieldLabel } from "../fieldLabel";
|
|
7
|
-
import { FieldWrapper } from "../fieldWrapper";
|
|
5
|
+
import { FieldTemplate } from "@components/services/fieldTemplate";
|
|
8
6
|
import { MultiSelectChevron } from "./multiSelectChevron";
|
|
9
7
|
import { MultiSelectContainer } from "./multiSelectContainer";
|
|
10
8
|
import { MultiSelectContent } from "./multiSelectContent";
|
|
@@ -42,6 +40,8 @@ import { MultiSelectSpinner } from "./multiSelectSpinner";
|
|
|
42
40
|
* @param props.prefix - Text or icon to display at the beginning of the multiselect
|
|
43
41
|
* @param props.leftIcon - Optional icon to display on the left side
|
|
44
42
|
* @param props.optionMaxHeight - Maximum height for the options dropdown
|
|
43
|
+
* @param props.unShowFieldTemplate - When true, skips `FieldTemplate` structure (wrapper, label and error text) and renders only the checkbox button content.
|
|
44
|
+
* @param props.orientation - Layout direction forwarded to `FieldTemplate`/`FieldWrapper` (`horizontal`, `vertical`, `horizontalReverse`). Default: "horizontalReverse"
|
|
45
45
|
*
|
|
46
46
|
* @returns MultiSelect JSX element wrapped in FieldWrapper with optional label and error
|
|
47
47
|
*
|
|
@@ -104,7 +104,7 @@ import { MultiSelectSpinner } from "./multiSelectSpinner";
|
|
|
104
104
|
* ```
|
|
105
105
|
*/
|
|
106
106
|
function MultiSelect(props) {
|
|
107
|
-
const { name, options, className: wrapperClassName = "", placeholder = "Selecione...", closeOnSelect = false, defaultValue = [], errorMessage: baseErrorMessage, isLoading = false, readOnly = false, isSearchable = false, id, label, optionMaxHeight, showAsterisk, leftIcon: LeftIcon, onSearch, onChange, onBlur, notFoundText = "Sem opções disponíveis", onFocus, disabled: baseDisabled = false, prefix, size = "md", value, variant = "solid", } = props;
|
|
107
|
+
const { name, options, className: wrapperClassName = "", placeholder = "Selecione...", closeOnSelect = false, defaultValue = [], errorMessage: baseErrorMessage, isLoading = false, readOnly = false, isSearchable = false, id, label, optionMaxHeight, showAsterisk, leftIcon: LeftIcon, onSearch, onChange, onBlur, notFoundText = "Sem opções disponíveis", onFocus, disabled: baseDisabled = false, prefix, size = "md", value, variant = "solid", unShowFieldTemplate = false, orientation = "horizontal", } = props;
|
|
108
108
|
const { fieldErrors } = useForm();
|
|
109
109
|
const multiSelectRef = useRef(null);
|
|
110
110
|
const multiSelectId = id || useId();
|
|
@@ -164,6 +164,6 @@ function MultiSelect(props) {
|
|
|
164
164
|
return true;
|
|
165
165
|
return false;
|
|
166
166
|
});
|
|
167
|
-
return (
|
|
167
|
+
return (_jsx(FieldTemplate, { name: name, label: label, showAsterisk: showAsterisk, className: wrapperClassName, errorMessage: errorMessage, unShowFieldTemplate: unShowFieldTemplate, orientation: orientation, children: _jsxs(MultiSelectContainer, { handleContainerFocus: handleContainerFocus, disabled: disabled, isError: isError, isFocused: isFocused, isLoading: isLoading, readOnly: readOnly, size: size, variant: variant, prefixExists: !!prefix, id: multiSelectId, children: [_jsx("input", { ref: multiSelectRef, name: name, value: JSON.stringify(forceSelectedOptions), type: "hidden" }), _jsx(IconRenderer, { iconSize: iconSize, icon: prefix, className: "prefix" }), LeftIcon && _jsx(LeftIcon, { size: iconSize, strokeWidth: 2.5 }), _jsxs(MultiSelectContent, { size: size, children: [forceSelectedOptions.map((value) => (_jsx(MultiSelectMark, { label: getOptionLabel(value), value: value, handleChangeValue: handleChangeValue, disabled: disabled }, value))), forceSelectedOptions.length <= 0 && _jsx("p", { children: placeholder })] }), _jsxs(MultiSelectOptionsContainer, { isFocused: isFocused, isSearchable: isSearchable, search: search, onSearch: handleSearch, children: [mappedOptions.map(({ label, value }) => (_jsx(MultiSelectOption, { label: label, value: value, size: size, handleChangeValue: handleChangeValue, optionHasSelected: optionHasSelected }, value))), mappedOptions.length <= 0 && _jsx("p", { children: notFoundText })] }), _jsx(MultiSelectChevron, { disabled: disabled, isFocused: isFocused, readOnly: readOnly, iconSize: iconSize, isLoading: isLoading }), _jsx(MultiSelectSpinner, { iconSize: iconSize, isLoading: isLoading }), _jsx(MultiSelectOverlay, { handleBlur: handleBlur, isFocused: isFocused })] }) }));
|
|
168
168
|
}
|
|
169
169
|
export { MultiSelect };
|
|
@@ -17,7 +17,55 @@ type PhoneInputProps = {
|
|
|
17
17
|
defaultCountryIso?: (typeof countries)[number]["iso"];
|
|
18
18
|
onChange?: (e: string) => void;
|
|
19
19
|
value?: string;
|
|
20
|
+
unShowFieldTemplate?: boolean;
|
|
21
|
+
orientation?: "horizontal" | "vertical" | "horizontalReverse";
|
|
20
22
|
};
|
|
23
|
+
/**
|
|
24
|
+
* Phone input with country selector, mask formatting, and hidden form value.
|
|
25
|
+
*
|
|
26
|
+
* The component formats the visible value according to the selected country mask,
|
|
27
|
+
* while the hidden input stores a numeric string prefixed with the country code.
|
|
28
|
+
* It also integrates with `useForm` to display validation errors by field name.
|
|
29
|
+
*
|
|
30
|
+
* @param {PhoneInputProps} props Component properties.
|
|
31
|
+
* @param {string} props.name Hidden input name used in form submission.
|
|
32
|
+
* @param {string} [props.label] Optional field label.
|
|
33
|
+
* @param {boolean} [props.showAsterisk] Displays required marker in the label.
|
|
34
|
+
* @param {string} [props.errorMessage] Custom error message (overrides form context error).
|
|
35
|
+
* @param {"md" | "lg"} [props.size="md"] Visual size.
|
|
36
|
+
* @param {"solid" | "outline"} [props.variant="solid"] Visual variant.
|
|
37
|
+
* @param {boolean} [props.disabled=false] Disables interactions.
|
|
38
|
+
* @param {boolean} [props.readOnly=false] Prevents editing while keeping value visible.
|
|
39
|
+
* @param {boolean} [props.isLoading=false] Applies loading state and disables interactions.
|
|
40
|
+
* @param {string} [props.defaultValue=""] Initial phone value for uncontrolled usage.
|
|
41
|
+
* @param {string} [props.value] Controlled phone value.
|
|
42
|
+
* @param {(value: string) => void} [props.onChange] Callback with numeric value including country code.
|
|
43
|
+
* @param {(typeof countries)[number]["iso"]} [props.defaultCountryIso] Reserved prop for default country ISO.
|
|
44
|
+
* @param {string} [props.searchCountryPlaceholder="Pesquisar país"] Placeholder for country search input.
|
|
45
|
+
* @param {string} [props.notFoundCountryText="Nenhum país encontrado"] Text shown when no country matches search.
|
|
46
|
+
* @param {string} [props.className] Class applied to the field wrapper.
|
|
47
|
+
* @param {string} [props.id] Optional id for the visible phone input.
|
|
48
|
+
* @param {boolean} [props.unShowFieldTemplate=false] When `true`, skips wrapper/label/error rendering from `FieldTemplate`.
|
|
49
|
+
* @param {"horizontal" | "vertical" | "horizontalReverse"} [props.orientation="horizontal"] Layout direction forwarded to `FieldTemplate`/`FieldWrapper`.
|
|
50
|
+
*
|
|
51
|
+
* @returns {JSX.Element} Phone input field with country picker and hidden input for form submission.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```tsx
|
|
55
|
+
* <PhoneInput name="phone" label="Telefone" />
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```tsx
|
|
60
|
+
* <PhoneInput
|
|
61
|
+
* name="contactPhone"
|
|
62
|
+
* value={phone}
|
|
63
|
+
* onChange={setPhone}
|
|
64
|
+
* variant="outline"
|
|
65
|
+
* size="lg"
|
|
66
|
+
* />
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
21
69
|
declare function PhoneInput(props: PhoneInputProps): import("react/jsx-runtime").JSX.Element;
|
|
22
70
|
export { PhoneInput };
|
|
23
71
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/phoneInput/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/phoneInput/index.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAqB7C,KAAK,eAAe,GAAG;IACrB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,iBAAiB,CAAC,EAAE,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC;IACtD,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,WAAW,CAAC,EAAE,YAAY,GAAG,UAAU,GAAG,mBAAmB,CAAC;CAC/D,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,iBAAS,UAAU,CAAC,KAAK,EAAE,eAAe,2CAuKzC;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -1,19 +1,63 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { findCountryMask, formatToPhone, removeNonNumeric, } from "@arkyn/shared";
|
|
2
3
|
import { countries } from "@arkyn/templates";
|
|
3
4
|
import { useId, useRef, useState } from "react";
|
|
4
|
-
import { findCountryMask, formatToPhone, removeNonNumeric, } from "@arkyn/shared";
|
|
5
5
|
import { useForm } from "../../hooks/useForm";
|
|
6
|
-
import {
|
|
7
|
-
import { FieldLabel } from "../fieldLabel";
|
|
8
|
-
import { FieldWrapper } from "../fieldWrapper";
|
|
6
|
+
import { FieldTemplate } from "../../services/fieldTemplate";
|
|
9
7
|
import { PhoneInputContainer } from "./phoneInputContainer";
|
|
10
8
|
import { PhoneInputCountriesOverlay } from "./phoneInputCountriesOverlay";
|
|
11
9
|
import { PhoneInputCountryOption } from "./phoneInputCountryOption";
|
|
12
10
|
import { PhoneInputCountryOptionsContainer } from "./phoneInputCountryOptionsContainer";
|
|
13
11
|
import { PhoneInputCountrySelector } from "./phoneInputCountrySelector";
|
|
14
12
|
import { PhoneInputMask } from "./phoneInputMask";
|
|
13
|
+
/**
|
|
14
|
+
* Phone input with country selector, mask formatting, and hidden form value.
|
|
15
|
+
*
|
|
16
|
+
* The component formats the visible value according to the selected country mask,
|
|
17
|
+
* while the hidden input stores a numeric string prefixed with the country code.
|
|
18
|
+
* It also integrates with `useForm` to display validation errors by field name.
|
|
19
|
+
*
|
|
20
|
+
* @param {PhoneInputProps} props Component properties.
|
|
21
|
+
* @param {string} props.name Hidden input name used in form submission.
|
|
22
|
+
* @param {string} [props.label] Optional field label.
|
|
23
|
+
* @param {boolean} [props.showAsterisk] Displays required marker in the label.
|
|
24
|
+
* @param {string} [props.errorMessage] Custom error message (overrides form context error).
|
|
25
|
+
* @param {"md" | "lg"} [props.size="md"] Visual size.
|
|
26
|
+
* @param {"solid" | "outline"} [props.variant="solid"] Visual variant.
|
|
27
|
+
* @param {boolean} [props.disabled=false] Disables interactions.
|
|
28
|
+
* @param {boolean} [props.readOnly=false] Prevents editing while keeping value visible.
|
|
29
|
+
* @param {boolean} [props.isLoading=false] Applies loading state and disables interactions.
|
|
30
|
+
* @param {string} [props.defaultValue=""] Initial phone value for uncontrolled usage.
|
|
31
|
+
* @param {string} [props.value] Controlled phone value.
|
|
32
|
+
* @param {(value: string) => void} [props.onChange] Callback with numeric value including country code.
|
|
33
|
+
* @param {(typeof countries)[number]["iso"]} [props.defaultCountryIso] Reserved prop for default country ISO.
|
|
34
|
+
* @param {string} [props.searchCountryPlaceholder="Pesquisar país"] Placeholder for country search input.
|
|
35
|
+
* @param {string} [props.notFoundCountryText="Nenhum país encontrado"] Text shown when no country matches search.
|
|
36
|
+
* @param {string} [props.className] Class applied to the field wrapper.
|
|
37
|
+
* @param {string} [props.id] Optional id for the visible phone input.
|
|
38
|
+
* @param {boolean} [props.unShowFieldTemplate=false] When `true`, skips wrapper/label/error rendering from `FieldTemplate`.
|
|
39
|
+
* @param {"horizontal" | "vertical" | "horizontalReverse"} [props.orientation="horizontal"] Layout direction forwarded to `FieldTemplate`/`FieldWrapper`.
|
|
40
|
+
*
|
|
41
|
+
* @returns {JSX.Element} Phone input field with country picker and hidden input for form submission.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```tsx
|
|
45
|
+
* <PhoneInput name="phone" label="Telefone" />
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```tsx
|
|
50
|
+
* <PhoneInput
|
|
51
|
+
* name="contactPhone"
|
|
52
|
+
* value={phone}
|
|
53
|
+
* onChange={setPhone}
|
|
54
|
+
* variant="outline"
|
|
55
|
+
* size="lg"
|
|
56
|
+
* />
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
15
59
|
function PhoneInput(props) {
|
|
16
|
-
const { defaultCountryIso, value: rawValue, label, className: wrapperClassName = "", disabled = false, errorMessage: baseErrorMessage, isLoading = false, readOnly = false, size = "md", defaultValue = "", variant = "solid", showAsterisk, name, onChange, searchCountryPlaceholder = "Pesquisar país", notFoundCountryText = "Nenhum país encontrado", id, } = props;
|
|
60
|
+
const { defaultCountryIso, value: rawValue, label, className: wrapperClassName = "", disabled = false, errorMessage: baseErrorMessage, isLoading = false, readOnly = false, size = "md", defaultValue = "", variant = "solid", showAsterisk, name, onChange, searchCountryPlaceholder = "Pesquisar país", notFoundCountryText = "Nenhum país encontrado", id, unShowFieldTemplate = false, orientation = "horizontal", } = props;
|
|
17
61
|
const brasilCountry = countries.find((country) => country.iso === "BR");
|
|
18
62
|
const defaultData = defaultValue ? formatToPhone(defaultValue) : "";
|
|
19
63
|
const defaultCountry = defaultValue
|
|
@@ -63,16 +107,16 @@ function PhoneInput(props) {
|
|
|
63
107
|
returnValue += removeNonNumeric(props || value);
|
|
64
108
|
return returnValue;
|
|
65
109
|
}
|
|
66
|
-
return (
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
110
|
+
return (_jsx(FieldTemplate, { name: name, label: label, showAsterisk: showAsterisk, className: wrapperClassName, errorMessage: errorMessage, unShowFieldTemplate: unShowFieldTemplate, orientation: orientation, children: _jsxs(PhoneInputContainer, { disabled: isDisabled, isError: isError, isLoading: isLoading, isFocused: isFocused, readOnly: readOnly, size: size, variant: variant, onFocus: handleContainerFocus, children: [_jsx(PhoneInputCountrySelector, { currentCountry: currentCountry, onClick: handleOpenCountryOptions, size: size }), _jsxs(PhoneInputCountryOptionsContainer, { isOpen: isDisabled ? false : readOnly ? false : showCountryOptions, search: search, placeholder: searchCountryPlaceholder, onSearch: setSearch, children: [countries
|
|
111
|
+
.filter((country) => filterCountryFunction(country))
|
|
112
|
+
.map((country) => (_jsx(PhoneInputCountryOption, { country: country, handleChangeValue: () => {
|
|
113
|
+
setCurrentCountry(country);
|
|
114
|
+
setShowCountryOptions(false);
|
|
115
|
+
setValue("");
|
|
116
|
+
}, isActive: country.iso === currentCountry.iso, size: size }, country.iso))), countries.filter((country) => filterCountryFunction(country))
|
|
117
|
+
.length === 0 && _jsx("p", { children: notFoundCountryText })] }), _jsx(PhoneInputCountriesOverlay, { isOpen: isDisabled ? false : readOnly ? false : showCountryOptions, onClick: handleCloseCountryOptions }), _jsx(PhoneInputMask, { id: phoneInputId, ref: inputPhoneMaskRef, readonly: readOnly, currentCountry: currentCountry, value: value, disabled: isDisabled, onBlur: handleInputBlur, onFocus: handleInputFocus, size: size, onChange: (e) => {
|
|
118
|
+
setValue(e);
|
|
119
|
+
onChange && onChange(inputValue(e));
|
|
120
|
+
} }), _jsx("input", { ref: phoneInputRef, type: "hidden", name: name, value: inputValue() })] }) }));
|
|
77
121
|
}
|
|
78
122
|
export { PhoneInput };
|
|
@@ -10,6 +10,8 @@ type RadioGroupProps = Omit<HTMLAttributes<HTMLDivElement>, "onChange"> & {
|
|
|
10
10
|
onChange?: (value: string) => void;
|
|
11
11
|
size?: "sm" | "md" | "lg";
|
|
12
12
|
disabled?: boolean;
|
|
13
|
+
unShowFieldTemplate?: boolean;
|
|
14
|
+
orientation?: "horizontal" | "vertical" | "horizontalReverse";
|
|
13
15
|
};
|
|
14
16
|
/**
|
|
15
17
|
* RadioGroup component - used for creating a group of radio button options with shared state management
|
|
@@ -23,6 +25,8 @@ type RadioGroupProps = Omit<HTMLAttributes<HTMLDivElement>, "onChange"> & {
|
|
|
23
25
|
* @param props.defaultValue - Default selected value for uncontrolled usage. Default: ""
|
|
24
26
|
* @param props.onChange - Callback function called when radio selection changes, receives the selected value
|
|
25
27
|
* @param props.size - Size variant for all radio buttons in the group. Default: "md"
|
|
28
|
+
* @param props.unShowFieldTemplate - When true, skips `FieldTemplate` structure (wrapper, label and error text) and renders only the checkbox button content.
|
|
29
|
+
* @param props.orientation - Layout direction forwarded to `FieldTemplate`/`FieldWrapper` (`horizontal`, `vertical`, `horizontalReverse`). Default: "horizontalReverse"
|
|
26
30
|
*
|
|
27
31
|
* **...Other valid HTML properties for div element (except onChange)**
|
|
28
32
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/radio/radioGroup/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAY,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/radio/radioGroup/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAY,MAAM,OAAO,CAAC;AAMjD,OAAO,cAAc,CAAC;AAEtB,KAAK,eAAe,GAAG,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,UAAU,CAAC,GAAG;IACxE,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,WAAW,CAAC,EAAE,YAAY,GAAG,UAAU,GAAG,mBAAmB,CAAC;CAC/D,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8EG;AAEH,iBAAS,UAAU,CAAC,KAAK,EAAE,eAAe,2CA0DzC;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from "react";
|
|
3
|
-
import { FieldError } from "../../../components/fieldError";
|
|
4
|
-
import { FieldLabel } from "../../../components/fieldLabel";
|
|
5
|
-
import { FieldWrapper } from "../../../components/fieldWrapper";
|
|
6
3
|
import { useForm } from "../../../hooks/useForm";
|
|
4
|
+
import { FieldTemplate } from "../../../services/fieldTemplate";
|
|
7
5
|
import { RadioProvider } from "../radioContext";
|
|
8
6
|
import "./styles.css";
|
|
9
7
|
/**
|
|
@@ -18,6 +16,8 @@ import "./styles.css";
|
|
|
18
16
|
* @param props.defaultValue - Default selected value for uncontrolled usage. Default: ""
|
|
19
17
|
* @param props.onChange - Callback function called when radio selection changes, receives the selected value
|
|
20
18
|
* @param props.size - Size variant for all radio buttons in the group. Default: "md"
|
|
19
|
+
* @param props.unShowFieldTemplate - When true, skips `FieldTemplate` structure (wrapper, label and error text) and renders only the checkbox button content.
|
|
20
|
+
* @param props.orientation - Layout direction forwarded to `FieldTemplate`/`FieldWrapper` (`horizontal`, `vertical`, `horizontalReverse`). Default: "horizontalReverse"
|
|
21
21
|
*
|
|
22
22
|
* **...Other valid HTML properties for div element (except onChange)**
|
|
23
23
|
*
|
|
@@ -84,7 +84,7 @@ import "./styles.css";
|
|
|
84
84
|
* ```
|
|
85
85
|
*/
|
|
86
86
|
function RadioGroup(props) {
|
|
87
|
-
const { defaultValue = "", name, label, showAsterisk, errorMessage: baseErrorMessage, value: forceValue, onChange, size = "md", className: wrapperClassName = "", disabled = false, ...rest } = props;
|
|
87
|
+
const { defaultValue = "", name, label, showAsterisk, errorMessage: baseErrorMessage, value: forceValue, onChange, size = "md", className: wrapperClassName = "", disabled = false, unShowFieldTemplate = false, orientation = "horizontal", ...rest } = props;
|
|
88
88
|
const [value, setValue] = useState(defaultValue);
|
|
89
89
|
const { fieldErrors } = useForm();
|
|
90
90
|
function handleChange(value) {
|
|
@@ -95,6 +95,6 @@ function RadioGroup(props) {
|
|
|
95
95
|
const errorMessage = baseErrorMessage || fieldErrors?.[name];
|
|
96
96
|
const isError = !!errorMessage;
|
|
97
97
|
const className = `arkynRadioGroup ${size}`;
|
|
98
|
-
return (
|
|
98
|
+
return (_jsx(FieldTemplate, { name: name, label: label, showAsterisk: showAsterisk, className: wrapperClassName, errorMessage: errorMessage, unShowFieldTemplate: unShowFieldTemplate, orientation: orientation, children: _jsxs(RadioProvider, { isError: isError, size: size, value: forceValue || value, handleChange: handleChange, disabled: disabled, children: [_jsx("input", { style: { display: "none" }, type: "text", readOnly: true, name: name, value: forceValue || value }), _jsx("div", { className: className.trim(), ...rest })] }) }));
|
|
99
99
|
}
|
|
100
100
|
export { RadioGroup };
|