hi-tm 0.0.1
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/README.md +0 -0
- package/dist/components/AutoComplete/AutoComplete.d.ts +4 -0
- package/dist/components/AutoComplete/AutoComplete.js +132 -0
- package/dist/components/AutoComplete/AutoCompleteMultiSelect.d.ts +4 -0
- package/dist/components/AutoComplete/AutoCompleteMultiSelect.js +155 -0
- package/dist/components/AutoComplete/TreeAutoComplete.d.ts +65 -0
- package/dist/components/AutoComplete/TreeAutoComplete.js +150 -0
- package/dist/components/Cards/AutoComplete&DropDown/CourierCard.d.ts +4 -0
- package/dist/components/Cards/AutoComplete&DropDown/CourierCard.js +13 -0
- package/dist/components/Cards/AutoComplete&DropDown/GeographyCard.d.ts +4 -0
- package/dist/components/Cards/AutoComplete&DropDown/GeographyCard.js +11 -0
- package/dist/components/Cards/AutoComplete&DropDown/ItemCard.d.ts +4 -0
- package/dist/components/Cards/AutoComplete&DropDown/ItemCard.js +12 -0
- package/dist/components/Cards/AutoComplete&DropDown/PersonCard.d.ts +4 -0
- package/dist/components/Cards/AutoComplete&DropDown/PersonCard.js +12 -0
- package/dist/components/Cards/AutoComplete&DropDown/SimpleCard.d.ts +4 -0
- package/dist/components/Cards/AutoComplete&DropDown/SimpleCard.js +11 -0
- package/dist/components/DropDowns/DropDown.d.ts +4 -0
- package/dist/components/DropDowns/DropDown.js +170 -0
- package/dist/components/DropDowns/DropDownItemsPerPage.d.ts +8 -0
- package/dist/components/DropDowns/DropDownItemsPerPage.js +44 -0
- package/dist/components/DropDowns/DropDownMultiSelect.d.ts +4 -0
- package/dist/components/DropDowns/DropDownMultiSelect.js +154 -0
- package/dist/components/Inputs/Buttons/Button.d.ts +14 -0
- package/dist/components/Inputs/Buttons/Button.js +39 -0
- package/dist/components/Inputs/DaysCheckBox.d.ts +4 -0
- package/dist/components/Inputs/DaysCheckBox.js +27 -0
- package/dist/components/Inputs/InputBarcode.d.ts +4 -0
- package/dist/components/Inputs/InputBarcode.js +148 -0
- package/dist/components/Inputs/InputCurrency.d.ts +25 -0
- package/dist/components/Inputs/InputCurrency.js +105 -0
- package/dist/components/Inputs/InputMultiselect.d.ts +20 -0
- package/dist/components/Inputs/InputMultiselect.js +106 -0
- package/dist/components/Inputs/InputPercent.d.ts +40 -0
- package/dist/components/Inputs/InputPercent.js +100 -0
- package/dist/components/Inputs/InputSearch.d.ts +4 -0
- package/dist/components/Inputs/InputSearch.js +35 -0
- package/dist/components/Inputs/RangePicker.d.ts +18 -0
- package/dist/components/Inputs/RangePicker.js +132 -0
- package/dist/components/Inputs/TextArea.d.ts +4 -0
- package/dist/components/Inputs/TextArea.js +61 -0
- package/dist/components/Inputs/TextInput.d.ts +4 -0
- package/dist/components/Inputs/TextInput.js +74 -0
- package/dist/components/Inputs/Toggle.d.ts +20 -0
- package/dist/components/Inputs/Toggle.js +83 -0
- package/dist/components/Layout/Footers/FooterLayout.d.ts +5 -0
- package/dist/components/Layout/Footers/FooterLayout.js +80 -0
- package/dist/components/Layout/Headers/HeaderLayout.d.ts +85 -0
- package/dist/components/Layout/Headers/HeaderLayout.js +333 -0
- package/dist/components/Layout/Headers/HeaderSelectBranch.d.ts +38 -0
- package/dist/components/Layout/Headers/HeaderSelectBranch.js +153 -0
- package/dist/components/Layout/Sidebar.d.ts +4 -0
- package/dist/components/Layout/Sidebar.js +304 -0
- package/dist/components/Pagination/PaginationPrimary.d.ts +8 -0
- package/dist/components/Pagination/PaginationPrimary.js +40 -0
- package/dist/components/Table/TableHeader.d.ts +17 -0
- package/dist/components/Table/TableHeader.js +73 -0
- package/dist/components/Table/TableHeaderDiv.d.ts +33 -0
- package/dist/components/Table/TableHeaderDiv.js +121 -0
- package/dist/components/Table/TableRow.d.ts +4 -0
- package/dist/components/Table/TableRow.js +156 -0
- package/dist/components/Table/TableRowCards/TableRowCardChildren.d.ts +11 -0
- package/dist/components/Table/TableRowCards/TableRowCardChildren.js +68 -0
- package/dist/components/Table/TableRowCards/TableRowCardSimple.d.ts +12 -0
- package/dist/components/Table/TableRowCards/TableRowCardSimple.js +66 -0
- package/dist/components/Table/TableRowDiv.d.ts +59 -0
- package/dist/components/Table/TableRowDiv.js +329 -0
- package/dist/components/Tabs/Tabs.d.ts +15 -0
- package/dist/components/Tabs/Tabs.js +45 -0
- package/dist/components/Wrapper/Bounded.d.ts +30 -0
- package/dist/components/Wrapper/Bounded.js +17 -0
- package/dist/components/Wrapper/GlobalWrapper.d.ts +6 -0
- package/dist/components/Wrapper/GlobalWrapper.js +12 -0
- package/dist/components/Wrapper/Modals/Modal.d.ts +9 -0
- package/dist/components/Wrapper/Modals/Modal.js +77 -0
- package/dist/components/Wrapper/TableBodyBounded.d.ts +5 -0
- package/dist/components/Wrapper/TableBodyBounded.js +50 -0
- package/dist/components/Wrapper/TableBodyBoundedDiv.d.ts +6 -0
- package/dist/components/Wrapper/TableBodyBoundedDiv.js +11 -0
- package/dist/components/Wrapper/TableBounded.d.ts +18 -0
- package/dist/components/Wrapper/TableBounded.js +22 -0
- package/dist/components/Wrapper/TableBoundedDiv.d.ts +6 -0
- package/dist/components/Wrapper/TableBoundedDiv.js +11 -0
- package/dist/components/sections/components/Inputs/Toggle.d.ts +6 -0
- package/dist/components/sections/components/Inputs/Toggle.js +19 -0
- package/dist/components/sections/components/Loader/BtnLoader.d.ts +3 -0
- package/dist/components/sections/components/Loader/BtnLoader.js +15 -0
- package/dist/components/sections/components/Modals/ModalProvider.d.ts +4 -0
- package/dist/components/sections/components/Modals/ModalProvider.js +10 -0
- package/dist/components/sections/components/Modals/ModalSearchContentInHeader.d.ts +4 -0
- package/dist/components/sections/components/Modals/ModalSearchContentInHeader.js +104 -0
- package/dist/components/sections/components/Tabs/BreadCrumbs.d.ts +4 -0
- package/dist/components/sections/components/Tabs/BreadCrumbs.js +23 -0
- package/dist/components/sections/components/Tabs/TabsComponent.d.ts +4 -0
- package/dist/components/sections/components/Tabs/TabsComponent.js +109 -0
- package/dist/helper/formatNumberWithCommas.d.ts +1 -0
- package/dist/helper/formatNumberWithCommas.js +32 -0
- package/dist/helper/getValueByTypeInList.d.ts +2 -0
- package/dist/helper/getValueByTypeInList.js +7 -0
- package/dist/helper/modalStyleOperationHandler.d.ts +3 -0
- package/dist/helper/modalStyleOperationHandler.js +12 -0
- package/dist/helper/truncateText.d.ts +2 -0
- package/dist/helper/truncateText.js +19 -0
- package/dist/helper/useBackAndEscModal.d.ts +24 -0
- package/dist/helper/useBackAndEscModal.js +26 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +85 -0
- package/dist/styles/globals.css +176 -0
- package/dist/tailwind-preset.d.ts +42 -0
- package/dist/tailwind-preset.js +43 -0
- package/dist/tailwind-preset.ts +41 -0
- package/dist/types/AutoComplete/AutoComplete.d.ts +22 -0
- package/dist/types/AutoComplete/AutoComplete.js +2 -0
- package/dist/types/AutoComplete/AutoCompleteMultiSelect.d.ts +27 -0
- package/dist/types/AutoComplete/AutoCompleteMultiSelect.js +2 -0
- package/dist/types/BreakCrumbTypes.d.ts +12 -0
- package/dist/types/BreakCrumbTypes.js +2 -0
- package/dist/types/Buttons/PrimaryButton.d.ts +14 -0
- package/dist/types/Buttons/PrimaryButton.js +2 -0
- package/dist/types/Cards/AutoComplete&DropDown/CardsType.d.ts +30 -0
- package/dist/types/Cards/AutoComplete&DropDown/CardsType.js +2 -0
- package/dist/types/DropDown/DropDownMultiSelectType.d.ts +31 -0
- package/dist/types/DropDown/DropDownMultiSelectType.js +2 -0
- package/dist/types/DropDown/DropDownType.d.ts +30 -0
- package/dist/types/DropDown/DropDownType.js +2 -0
- package/dist/types/Inputs/AutoCompleteType.d.ts +37 -0
- package/dist/types/Inputs/AutoCompleteType.js +2 -0
- package/dist/types/Inputs/DaysCheckBoxType.d.ts +13 -0
- package/dist/types/Inputs/DaysCheckBoxType.js +2 -0
- package/dist/types/Inputs/DropDownType.d.ts +24 -0
- package/dist/types/Inputs/DropDownType.js +2 -0
- package/dist/types/Inputs/InputBarcodeType.d.ts +17 -0
- package/dist/types/Inputs/InputBarcodeType.js +2 -0
- package/dist/types/Inputs/InputCurrencyType.d.ts +17 -0
- package/dist/types/Inputs/InputCurrencyType.js +2 -0
- package/dist/types/Inputs/InputMultiselectType.d.ts +19 -0
- package/dist/types/Inputs/InputMultiselectType.js +2 -0
- package/dist/types/Inputs/InputSearchType.d.ts +19 -0
- package/dist/types/Inputs/InputSearchType.js +2 -0
- package/dist/types/Inputs/RangePickerType.d.ts +14 -0
- package/dist/types/Inputs/RangePickerType.js +2 -0
- package/dist/types/Inputs/TextAreaType.d.ts +12 -0
- package/dist/types/Inputs/TextAreaType.js +2 -0
- package/dist/types/Inputs/TextInputType.d.ts +20 -0
- package/dist/types/Inputs/TextInputType.js +2 -0
- package/dist/types/Inputs/ToggleType.d.ts +11 -0
- package/dist/types/Inputs/ToggleType.js +2 -0
- package/dist/types/Layout/Headers/HeaderLayout.d.ts +75 -0
- package/dist/types/Layout/Headers/HeaderLayout.js +2 -0
- package/dist/types/Layout/Sidebar.d.ts +21 -0
- package/dist/types/Layout/Sidebar.js +2 -0
- package/dist/types/Layout/SidebarType.d.ts +42 -0
- package/dist/types/Layout/SidebarType.js +2 -0
- package/dist/types/Modals/ModalProviderType.d.ts +4 -0
- package/dist/types/Modals/ModalProviderType.js +2 -0
- package/dist/types/Modals/ModalSearchContentInHeaderPropsType.d.ts +10 -0
- package/dist/types/Modals/ModalSearchContentInHeaderPropsType.js +2 -0
- package/dist/types/Table/TableRowType.d.ts +41 -0
- package/dist/types/Table/TableRowType.js +2 -0
- package/dist/types/TabsType.d.ts +24 -0
- package/dist/types/TabsType.js +2 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +17 -0
- package/package.json +44 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { InputCurrencyPropsType } from '../../types/Inputs/InputCurrencyType';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* InputCurrency Component
|
|
5
|
+
* A controlled input field for currency values, supporting Persian and English numerals,
|
|
6
|
+
* and providing validation, error handling, and additional handlers for customization.
|
|
7
|
+
*
|
|
8
|
+
* @param placeholder - The placeholder text for the input field.
|
|
9
|
+
* @param value - The initial value of the input field => (Just Number whit number type OR Null).
|
|
10
|
+
* @param required - Indicates if the input field is required. Displays a red asterisk (*) if true. => (boolean)
|
|
11
|
+
* @param currencyUnit - The currency unit to be displayed. => (string)
|
|
12
|
+
* @param textError - (optional) The error message to display when validation fails. => {string or null}
|
|
13
|
+
* @param label - The label for the input field. => (string)
|
|
14
|
+
* @param autoComplete - Enables or disables autocomplete => (boolean).
|
|
15
|
+
* @param autoFocus - Automatically focuses the input field when true. => (boolean)
|
|
16
|
+
* @param onChangeValueHandler - A callback function triggered when the input value changes.
|
|
17
|
+
* @param onBlurHandler - (optional) A callback function triggered when the input field loses focus. => If not received, the input will not be blurred.
|
|
18
|
+
* @param onFocusHandler - (optional) A callback function triggered when the input field gains focus. => If not received, the input will not be focused.
|
|
19
|
+
* @param onKeyUpHandler - (optional) A callback function triggered on key release events.
|
|
20
|
+
* @param onKeyDownHandler - (optional) A callback function triggered on key press events.
|
|
21
|
+
*
|
|
22
|
+
* @returns React.JSX.Element
|
|
23
|
+
*/
|
|
24
|
+
declare const InputCurrency: ({ placeholder, value, required, currencyUnit, textError, label, autoComplete, autoFocus, inlineCss, onChangeValueHandler, onBlurHandler, onFocusHandler, onKeyUpHandler, onKeyDownHandler, disabled, }: InputCurrencyPropsType) => React.JSX.Element;
|
|
25
|
+
export default InputCurrency;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
const react_1 = __importStar(require("react"));
|
|
38
|
+
/**
|
|
39
|
+
* InputCurrency Component
|
|
40
|
+
* A controlled input field for currency values, supporting Persian and English numerals,
|
|
41
|
+
* and providing validation, error handling, and additional handlers for customization.
|
|
42
|
+
*
|
|
43
|
+
* @param placeholder - The placeholder text for the input field.
|
|
44
|
+
* @param value - The initial value of the input field => (Just Number whit number type OR Null).
|
|
45
|
+
* @param required - Indicates if the input field is required. Displays a red asterisk (*) if true. => (boolean)
|
|
46
|
+
* @param currencyUnit - The currency unit to be displayed. => (string)
|
|
47
|
+
* @param textError - (optional) The error message to display when validation fails. => {string or null}
|
|
48
|
+
* @param label - The label for the input field. => (string)
|
|
49
|
+
* @param autoComplete - Enables or disables autocomplete => (boolean).
|
|
50
|
+
* @param autoFocus - Automatically focuses the input field when true. => (boolean)
|
|
51
|
+
* @param onChangeValueHandler - A callback function triggered when the input value changes.
|
|
52
|
+
* @param onBlurHandler - (optional) A callback function triggered when the input field loses focus. => If not received, the input will not be blurred.
|
|
53
|
+
* @param onFocusHandler - (optional) A callback function triggered when the input field gains focus. => If not received, the input will not be focused.
|
|
54
|
+
* @param onKeyUpHandler - (optional) A callback function triggered on key release events.
|
|
55
|
+
* @param onKeyDownHandler - (optional) A callback function triggered on key press events.
|
|
56
|
+
*
|
|
57
|
+
* @returns React.JSX.Element
|
|
58
|
+
*/
|
|
59
|
+
const InputCurrency = ({ placeholder, value, required, currencyUnit, textError, label, autoComplete, autoFocus, inlineCss, onChangeValueHandler, onBlurHandler, onFocusHandler, onKeyUpHandler, onKeyDownHandler, disabled = false, }) => {
|
|
60
|
+
const [inputValue, setInputValue] = (0, react_1.useState)(value?.toString() || '');
|
|
61
|
+
const inputRef = (0, react_1.useRef)(null);
|
|
62
|
+
(0, react_1.useEffect)(() => {
|
|
63
|
+
if (value !== null) {
|
|
64
|
+
setInputValue(value?.toString());
|
|
65
|
+
}
|
|
66
|
+
}, [value]);
|
|
67
|
+
// Cursor display direction
|
|
68
|
+
(0, react_1.useEffect)(() => {
|
|
69
|
+
if (inputRef.current && value !== null) {
|
|
70
|
+
inputRef.current.selectionStart = inputRef.current.value.length;
|
|
71
|
+
inputRef.current.selectionEnd = inputRef.current.value.length;
|
|
72
|
+
}
|
|
73
|
+
}, [value]);
|
|
74
|
+
const isErrorVisible = () => {
|
|
75
|
+
return !(textError && textError.trim() !== '');
|
|
76
|
+
};
|
|
77
|
+
const handleChange = (event) => {
|
|
78
|
+
const newValue = event.target.value;
|
|
79
|
+
// Being allowed to enter Persian numbers
|
|
80
|
+
const validValue = newValue.replace(/[^\d۰-۹]/g, '');
|
|
81
|
+
setInputValue(validValue);
|
|
82
|
+
onChangeValueHandler(event);
|
|
83
|
+
};
|
|
84
|
+
const handleKeyDown = (event) => {
|
|
85
|
+
const allowedKeys = ['Backspace', 'ArrowLeft', 'ArrowRight', 'Delete', 'Tab'];
|
|
86
|
+
const isNumber = /[0-9۰-۹]/.test(event.key);
|
|
87
|
+
if (!isNumber && !allowedKeys.includes(event.key)) {
|
|
88
|
+
event.preventDefault();
|
|
89
|
+
}
|
|
90
|
+
if (onKeyDownHandler)
|
|
91
|
+
onKeyDownHandler(event);
|
|
92
|
+
};
|
|
93
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
94
|
+
react_1.default.createElement("div", { className: "w-full relative", style: inlineCss },
|
|
95
|
+
react_1.default.createElement("label", { htmlFor: label, className: "flex items-center gap-2 mx-3" },
|
|
96
|
+
react_1.default.createElement("p", { className: "text-sm text-text-color-primary font-medium cursor-pointer" }, label),
|
|
97
|
+
react_1.default.createElement("span", { className: `text-red-primary ${required ? 'opacity-100' : 'opacity-0'} ` }, "*")),
|
|
98
|
+
react_1.default.createElement("div", { className: `w-full h-9 flex items-center justify-between bg-inherit outline-none border rounded-lg text-sm px-2 ${isErrorVisible()
|
|
99
|
+
? 'border-gray-tertiary focus:border-gray-quaternary'
|
|
100
|
+
: 'border-red-primary'}` },
|
|
101
|
+
react_1.default.createElement("input", { ref: inputRef, type: "text", id: label, disabled: disabled, value: Number(inputValue).toLocaleString(), placeholder: placeholder, autoComplete: autoComplete ? 'on' : 'off', autoFocus: autoFocus, onChange: handleChange, onBlur: onBlurHandler, onFocus: onFocusHandler, onKeyUp: onKeyUpHandler, onKeyDown: handleKeyDown, className: "outline-none bg-inherit w-full h-full", required: required }),
|
|
102
|
+
react_1.default.createElement("p", { className: "text-sm text-text-color-primary border-r border-gray-tertiary px-2" }, currencyUnit)),
|
|
103
|
+
!isErrorVisible() && react_1.default.createElement("p", { className: "text-sm mt-1 text-red-primary" }, textError?.trim()))));
|
|
104
|
+
};
|
|
105
|
+
exports.default = InputCurrency;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { InputMultiselectProps } from '../../types/Inputs/InputMultiselectType';
|
|
3
|
+
/**
|
|
4
|
+
* @param {string} label - The label for the input field.
|
|
5
|
+
* @param {boolean} required - Indicates whether the input is required.
|
|
6
|
+
* @param {string | undefined} textError - The error message to display if validation fails.
|
|
7
|
+
* @param {string} placeholder - The placeholder text for the input field.
|
|
8
|
+
* @param {Function} onChangeHandler - Callback function triggered when the list of items changes.
|
|
9
|
+
* @param {boolean} autoComplete - Specifies whether autocomplete is enabled for the input field.
|
|
10
|
+
* @param {string[]} value - The initial list of selected items. => string[]
|
|
11
|
+
* @param {boolean} autoFocus - Determines whether the input should autofocus on render.
|
|
12
|
+
* @param {Function | undefined} onFocusHandler - Callback function triggered when the input gains focus.
|
|
13
|
+
* @param {Function | undefined} onKeyUpHandler - Callback function triggered when a key is released while the input is focused.
|
|
14
|
+
* @param {Function | undefined} handleKeyDown - Callback function triggered when a key is pressed while the input is focused.
|
|
15
|
+
* @param {Function | undefined} onBlurHandler - Callback function triggered when the input loses focus.
|
|
16
|
+
* @param {string} closeIconSRC - The source URL for the close icon image.
|
|
17
|
+
* @param {string} [width=w-full] - The width of the input container, with a default value of 'w-full'.
|
|
18
|
+
*/
|
|
19
|
+
declare const InputMultiselect: ({ label, required, textError, placeholder, onChangeHandler, autoComplete, value, autoFocus, onFocusHandler, onKeyUpHandler, handleKeyDown: propHandleKeyDown, onBlurHandler, closeIconSRC, style, }: InputMultiselectProps) => React.JSX.Element;
|
|
20
|
+
export default InputMultiselect;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
const react_1 = __importStar(require("react"));
|
|
41
|
+
const image_1 = __importDefault(require("next/image"));
|
|
42
|
+
/**
|
|
43
|
+
* @param {string} label - The label for the input field.
|
|
44
|
+
* @param {boolean} required - Indicates whether the input is required.
|
|
45
|
+
* @param {string | undefined} textError - The error message to display if validation fails.
|
|
46
|
+
* @param {string} placeholder - The placeholder text for the input field.
|
|
47
|
+
* @param {Function} onChangeHandler - Callback function triggered when the list of items changes.
|
|
48
|
+
* @param {boolean} autoComplete - Specifies whether autocomplete is enabled for the input field.
|
|
49
|
+
* @param {string[]} value - The initial list of selected items. => string[]
|
|
50
|
+
* @param {boolean} autoFocus - Determines whether the input should autofocus on render.
|
|
51
|
+
* @param {Function | undefined} onFocusHandler - Callback function triggered when the input gains focus.
|
|
52
|
+
* @param {Function | undefined} onKeyUpHandler - Callback function triggered when a key is released while the input is focused.
|
|
53
|
+
* @param {Function | undefined} handleKeyDown - Callback function triggered when a key is pressed while the input is focused.
|
|
54
|
+
* @param {Function | undefined} onBlurHandler - Callback function triggered when the input loses focus.
|
|
55
|
+
* @param {string} closeIconSRC - The source URL for the close icon image.
|
|
56
|
+
* @param {string} [width=w-full] - The width of the input container, with a default value of 'w-full'.
|
|
57
|
+
*/
|
|
58
|
+
const InputMultiselect = ({ label, required, textError, placeholder, onChangeHandler, autoComplete, value, autoFocus, onFocusHandler, onKeyUpHandler, handleKeyDown: propHandleKeyDown, onBlurHandler, closeIconSRC, style = {
|
|
59
|
+
margin: 'mt-[-6px]',
|
|
60
|
+
width: 'w-full',
|
|
61
|
+
}, }) => {
|
|
62
|
+
const [items, setItems] = (0, react_1.useState)([]);
|
|
63
|
+
const [currentValue, setCurrentValue] = (0, react_1.useState)('');
|
|
64
|
+
const inputRef = (0, react_1.useRef)(null);
|
|
65
|
+
const isErrorVisible = () => {
|
|
66
|
+
return !(textError && textError.trim() !== '');
|
|
67
|
+
};
|
|
68
|
+
(0, react_1.useEffect)(() => {
|
|
69
|
+
if (inputRef.current) {
|
|
70
|
+
inputRef.current.value = currentValue;
|
|
71
|
+
}
|
|
72
|
+
}, [currentValue]);
|
|
73
|
+
(0, react_1.useEffect)(() => {
|
|
74
|
+
if (value && value.length > 0) {
|
|
75
|
+
setItems(value);
|
|
76
|
+
}
|
|
77
|
+
}, [value]);
|
|
78
|
+
const handleChange = (e) => {
|
|
79
|
+
setCurrentValue(e.target.value);
|
|
80
|
+
};
|
|
81
|
+
const handleKeyDown = (e) => {
|
|
82
|
+
if (e.key === 'Enter' && currentValue.trim() !== '') {
|
|
83
|
+
e.preventDefault();
|
|
84
|
+
setItems((prevItems) => [...prevItems, currentValue.trim()]);
|
|
85
|
+
setCurrentValue('');
|
|
86
|
+
}
|
|
87
|
+
propHandleKeyDown?.(e);
|
|
88
|
+
};
|
|
89
|
+
(0, react_1.useEffect)(() => {
|
|
90
|
+
onChangeHandler(items);
|
|
91
|
+
}, [items]);
|
|
92
|
+
const handleRemoveItem = (index) => {
|
|
93
|
+
setItems((prevItems) => prevItems.filter((_, i) => i !== index));
|
|
94
|
+
};
|
|
95
|
+
return (react_1.default.createElement("div", { className: `${style.width} ${style.margin} relative ` },
|
|
96
|
+
react_1.default.createElement("label", { htmlFor: label, className: 'flex items-center gap-2 mx-3' },
|
|
97
|
+
react_1.default.createElement("p", { className: 'text-sm text-text-color-primary font-medium cursor-pointer' }, label),
|
|
98
|
+
react_1.default.createElement("span", { className: `text-red-primary font-bold ${required ? 'block' : 'hidden'}` }, "*")),
|
|
99
|
+
react_1.default.createElement("div", { className: `w-full h-10 flex gap-1 items-center justify-between bg-inherit outline-none border rounded-lg text-sm px-2 ${isErrorVisible() ? 'border-gray-tertiary focus:border-gray-quaternary' : 'border-red-primary'}` },
|
|
100
|
+
items.map((item, index) => (react_1.default.createElement("span", { key: index, className: 'bg-gray-secondary text-text-color-primary px-2 py-1 rounded flex items-center justify-center gap-1' },
|
|
101
|
+
item,
|
|
102
|
+
react_1.default.createElement(image_1.default, { src: closeIconSRC, alt: 'close', width: 22, height: 22, onClick: () => handleRemoveItem(index), className: 'inline-block cursor-pointer' })))),
|
|
103
|
+
react_1.default.createElement("input", { ref: inputRef, type: 'text', id: label, placeholder: items.length === 0 ? placeholder : '', onChange: handleChange, autoComplete: autoComplete ? 'on' : 'off', autoFocus: autoFocus, className: 'outline-none bg-inherit flex-grow', required: required, onFocus: onFocusHandler, onKeyUp: onKeyUpHandler, onKeyDown: handleKeyDown, onBlur: onBlurHandler })),
|
|
104
|
+
!isErrorVisible() && react_1.default.createElement("p", { className: 'text-sm mt-1 text-red-primary' }, textError?.trim())));
|
|
105
|
+
};
|
|
106
|
+
exports.default = InputMultiselect;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* PercentInput component allows users to input percentage values with a maximum of 100.
|
|
4
|
+
* It provides customization for label, error handling, and input behaviors.
|
|
5
|
+
*
|
|
6
|
+
* @param {string} label - The label for the input field. This label is displayed to the user.
|
|
7
|
+
* @param {string | null} value - The value of the input. If null, the input value will be controlled locally.
|
|
8
|
+
* @param {boolean} required - Flag indicating whether the field is required or not. Asterisk will appear if true.
|
|
9
|
+
* @param {string} placeholderText - The placeholder text to display when the input is empty.
|
|
10
|
+
* @param {boolean} autoComplete - Enables or disables autocomplete for the input field.
|
|
11
|
+
* @param {boolean} autoFocus - Enables or disables autofocus for the input field when it is rendered.
|
|
12
|
+
* @param {string} textError - Error message to display if the input value is invalid.
|
|
13
|
+
* @param {Function} onChangeValueHandler - Handler function to manage input changes (pass a function to update the parent state).
|
|
14
|
+
* @param {Function} [onBlurHandler] - Optional handler for the blur event (losing focus).
|
|
15
|
+
* @param {Function} [onFocusHandler] - Optional handler for the focus event (gaining focus).
|
|
16
|
+
* @param {Function} [onKeyUpHandler] - Optional handler for the key up event (when a key is released).
|
|
17
|
+
* @param {Function} [onKeyDownHandler] - Optional handler for the key down event (when a key is pressed).
|
|
18
|
+
* @param {boolean} [disabled] - Optional flag to disable the input field (default is false).
|
|
19
|
+
* @param {object} [style] - Optional custom styles to apply to the component (width, margin).
|
|
20
|
+
*
|
|
21
|
+
* @returns {React.JSX.Element} The JSX element representing the PercentInput component.
|
|
22
|
+
*/
|
|
23
|
+
export interface TextInputPropsType {
|
|
24
|
+
label: string;
|
|
25
|
+
value: number | null;
|
|
26
|
+
required: boolean;
|
|
27
|
+
placeholderText: string;
|
|
28
|
+
autoComplete: boolean;
|
|
29
|
+
autoFocus: boolean;
|
|
30
|
+
textError: string;
|
|
31
|
+
onChangeValueHandler: React.ChangeEventHandler<HTMLInputElement>;
|
|
32
|
+
onBlurHandler?: React.FocusEventHandler<HTMLInputElement>;
|
|
33
|
+
onFocusHandler?: React.FocusEventHandler<HTMLInputElement>;
|
|
34
|
+
onKeyUpHandler?: React.KeyboardEventHandler<HTMLInputElement>;
|
|
35
|
+
onKeyDownHandler?: React.KeyboardEventHandler<HTMLInputElement>;
|
|
36
|
+
disabled?: boolean;
|
|
37
|
+
inlineCSS?: object;
|
|
38
|
+
}
|
|
39
|
+
declare const InputPercent: ({ label, required, value, placeholderText, autoComplete, autoFocus, textError, onChangeValueHandler, onBlurHandler, onFocusHandler, onKeyUpHandler, onKeyDownHandler, disabled, inlineCSS, }: TextInputPropsType) => React.JSX.Element;
|
|
40
|
+
export default InputPercent;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
const react_1 = __importStar(require("react"));
|
|
38
|
+
const InputPercent = ({ label, required, value, placeholderText, autoComplete, autoFocus, textError, onChangeValueHandler, onBlurHandler, onFocusHandler, onKeyUpHandler, onKeyDownHandler, disabled = false, inlineCSS, }) => {
|
|
39
|
+
const [inputValue, setInputValue] = (0, react_1.useState)(null);
|
|
40
|
+
(0, react_1.useEffect)(() => {
|
|
41
|
+
if (value !== null) {
|
|
42
|
+
setInputValue(value);
|
|
43
|
+
}
|
|
44
|
+
}, [value]);
|
|
45
|
+
// Use ref to focus the input programmatically
|
|
46
|
+
const inputRef = (0, react_1.useRef)(null);
|
|
47
|
+
/**
|
|
48
|
+
* Handle the change in input value.
|
|
49
|
+
* This function is called whenever the user types in the input.
|
|
50
|
+
* It ensures that the value doesn't exceed 100 and updates the input value accordingly.
|
|
51
|
+
*
|
|
52
|
+
* @param {React.ChangeEvent<HTMLInputElement>} e - The change event triggered by the user input.
|
|
53
|
+
*/
|
|
54
|
+
const handleInputChange = (e) => {
|
|
55
|
+
const value = e.target.value;
|
|
56
|
+
// Allow only numbers and restrict the value to 100 or below
|
|
57
|
+
if (/^\d+$/.test(value) && parseInt(value) <= 100) {
|
|
58
|
+
setInputValue(Number(value));
|
|
59
|
+
onChangeValueHandler(e);
|
|
60
|
+
}
|
|
61
|
+
else if (value === '') {
|
|
62
|
+
// Handle the case where the input is cleared
|
|
63
|
+
setInputValue(0);
|
|
64
|
+
e.target.value = '0';
|
|
65
|
+
onChangeValueHandler(e);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Handle the focus event of the input field.
|
|
70
|
+
* This function ensures that the cursor is placed at the end of the input text when focused.
|
|
71
|
+
*
|
|
72
|
+
* @param {React.FocusEvent<HTMLInputElement>} e - The focus event triggered when the input is focused.
|
|
73
|
+
*/
|
|
74
|
+
const handleFocus = (e) => {
|
|
75
|
+
if (onFocusHandler) {
|
|
76
|
+
onFocusHandler(e);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Determines whether to show the error message.
|
|
81
|
+
* This is based on the textError prop.
|
|
82
|
+
*
|
|
83
|
+
* @returns {boolean} True if no error message exists, false otherwise.
|
|
84
|
+
*/
|
|
85
|
+
const showError = () => {
|
|
86
|
+
return textError === '' || textError === null || textError.trim() === '';
|
|
87
|
+
};
|
|
88
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
89
|
+
react_1.default.createElement("div", { style: inlineCSS || {}, className: `h-full bg-inherit w-full relative` },
|
|
90
|
+
react_1.default.createElement("label", { htmlFor: label, className: `flex flex-row items-center justify-start ${disabled ? 'cursor-default' : ''} ` },
|
|
91
|
+
react_1.default.createElement("p", { className: `text-sm font-medium text-text-color-primary ${disabled ? 'cursor-default' : 'cursor-pointer'}` }, label),
|
|
92
|
+
react_1.default.createElement("span", { className: `text-red-primary ${required ? 'opacity-100' : 'opacity-0'} ` }, "*")),
|
|
93
|
+
react_1.default.createElement("div", { className: `flex h-9 w-full flex-row items-center justify-between rounded-lg border-solid bg-inherit text-sm outline-none ${disabled ? 'cursor-not-allowed' : ''} text-gray-secondary px-1 ${showError()
|
|
94
|
+
? 'border-gray-tertiary focus:border-gray-quaternary border-2 focus:border-[2.5px]'
|
|
95
|
+
: 'border-[2.5px] border-red-primary'}` },
|
|
96
|
+
react_1.default.createElement("input", { ref: inputRef, type: "number", id: label, disabled: disabled, value: inputValue !== null ? inputValue : '', required: false, onChange: handleInputChange, onBlur: onBlurHandler ? onBlurHandler : () => { }, onFocus: handleFocus, onKeyDown: onKeyDownHandler ? onKeyDownHandler : () => { }, onKeyUp: onKeyUpHandler ? onKeyUpHandler : () => { }, placeholder: placeholderText, autoComplete: autoComplete ? 'on' : 'off', autoFocus: autoFocus, className: "h-full w-full bg-transparent px-1 outline-none" }),
|
|
97
|
+
react_1.default.createElement("p", { className: "border-gray-tertiary bg-gray-tertiary flex h-full w-6 flex-row items-center justify-center border-r-2 border-solid text-lg opacity-65" }, "%")),
|
|
98
|
+
!showError() && react_1.default.createElement("p", { className: "text-sm mt-1 text-red-primary" }, textError?.trim()))));
|
|
99
|
+
};
|
|
100
|
+
exports.default = InputPercent;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { InputSearchProps } from '../../types/Inputs/InputSearchType';
|
|
3
|
+
declare const InputSearch: ({ searchSRC, label, required, placeholderText, autoComplete, autoFocus, textError, onChangeValueHandler, onBlurHandler, onFocusHandler, onKeyUpHandler, onKeyDownHandler, style, }: InputSearchProps) => React.JSX.Element;
|
|
4
|
+
export default InputSearch;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const image_1 = __importDefault(require("next/image"));
|
|
9
|
+
const InputSearch = ({ searchSRC, label, required, placeholderText, autoComplete, autoFocus, textError, onChangeValueHandler, onBlurHandler, onFocusHandler, onKeyUpHandler, onKeyDownHandler, style = {
|
|
10
|
+
margin: '',
|
|
11
|
+
width: 'w-full',
|
|
12
|
+
height: 'h-9',
|
|
13
|
+
}, }) => {
|
|
14
|
+
const handleInputChange = (event) => {
|
|
15
|
+
onChangeValueHandler(event);
|
|
16
|
+
};
|
|
17
|
+
const showError = () => {
|
|
18
|
+
return textError === '' || textError === null || textError.trim() === '';
|
|
19
|
+
};
|
|
20
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
21
|
+
react_1.default.createElement("div", { className: `${style.width} ${style.height} ${style.margin} bg-inherit` },
|
|
22
|
+
react_1.default.createElement("div", { className: "flex flex-col h-full justify-center items-star" },
|
|
23
|
+
label && (react_1.default.createElement("label", { htmlFor: label, className: "flex flex-row justify-start items-center gap-1 pb-1" },
|
|
24
|
+
react_1.default.createElement("p", { className: "text-sm text-nowrap text-text-color-primary font-medium cursor-pointer" }, label),
|
|
25
|
+
required && (react_1.default.createElement("span", { className: `text-red-primary ${required ? 'opacity-100' : 'opacity-0'}` }, "*")))),
|
|
26
|
+
react_1.default.createElement("div", { className: `w-full flex flex-row-reverse gap-2 h-full bg-inherit outline-none border-solid rounded-lg text-sm text-text-color-primary px-1 ${showError()
|
|
27
|
+
? 'border-gray-tertiary border-2 focus:border-gray-quaternary focus:border-[2.5px]'
|
|
28
|
+
: ' border-red-primary border-[2.5px]'}` },
|
|
29
|
+
react_1.default.createElement("input", { type: "text", id: label, required: false, onChange: handleInputChange, onBlur: onBlurHandler ? onBlurHandler : () => { }, onFocus: onFocusHandler ? onFocusHandler : () => { }, onKeyDown: onKeyDownHandler ? onKeyDownHandler : () => { }, onKeyUp: onKeyUpHandler ? onKeyUpHandler : () => { }, placeholder: placeholderText, autoComplete: autoComplete ? 'on' : 'off', autoFocus: autoFocus, className: "w-full h-full bg-inherit outline-none" }),
|
|
30
|
+
react_1.default.createElement("div", { className: "flex flex-row items-center justify-center gap-1" },
|
|
31
|
+
react_1.default.createElement(image_1.default, { src: searchSRC, alt: "search", width: 20, height: 20 }),
|
|
32
|
+
react_1.default.createElement("div", { className: "w-[3px] h-4/5 bg-gray-secondary" })))),
|
|
33
|
+
react_1.default.createElement("p", { className: `text-sm mr-1 mt-2 text-nowrap font-normal text-red-primary ${showError() ? 'hidden' : 'flex'}` }, textError?.trim()))));
|
|
34
|
+
};
|
|
35
|
+
exports.default = InputSearch;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { RangePickerProps } from '../../types/Inputs/RangePickerType';
|
|
3
|
+
/**
|
|
4
|
+
* RangePicker Component
|
|
5
|
+
*
|
|
6
|
+
* @param {number} minNumber - The minimum value for the range picker.
|
|
7
|
+
* @param {number} maxNumber - The maximum value for the range picker.
|
|
8
|
+
* @param {number} step - The step interval for the range picker.
|
|
9
|
+
* @param {number} [value] - The initial value for the range picker (optional).
|
|
10
|
+
* @param {string} label - The label displayed above the range picker.
|
|
11
|
+
* @param {boolean} [required] - Whether the field is required (optional).
|
|
12
|
+
* @param {string} [textError] - The error message to display when there is a validation issue (optional).
|
|
13
|
+
* @param {function} onChangeValueHandler - The callback function triggered when the range picker value changes.
|
|
14
|
+
*
|
|
15
|
+
* @returns {JSX.Element} A range picker component with a label and error message.
|
|
16
|
+
*/
|
|
17
|
+
declare const RangePicker: ({ minNumber, maxNumber, step, value, label, required, textError, onChangeValueHandler, style, }: RangePickerProps) => React.JSX.Element;
|
|
18
|
+
export default RangePicker;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// 'use client';
|
|
3
|
+
// import React, { useState } from 'react';
|
|
4
|
+
// import { RangePickerProps } from '../../types/Inputs/RangePickerType';
|
|
5
|
+
// /**
|
|
6
|
+
// * RangePicker Component
|
|
7
|
+
// *
|
|
8
|
+
// * @param {number} minNumber - The minimum value for the range picker.
|
|
9
|
+
// * @param {number} maxNumber - The maximum value for the range picker.
|
|
10
|
+
// * @param {number} step - The step interval for the range picker.
|
|
11
|
+
// * @param {number} [value] - The initial value for the range picker (optional).
|
|
12
|
+
// * @param {string} label - The label displayed above the range picker.
|
|
13
|
+
// * @param {boolean} [required] - Whether the field is required (optional).
|
|
14
|
+
// * @param {string} [textError] - The error message to display when there is a validation issue (optional).
|
|
15
|
+
// * @param {function} onChangeValueHandler - The callback function triggered when the range picker value changes.
|
|
16
|
+
// *
|
|
17
|
+
// * @returns {JSX.Element} A range picker component with a label and error message.
|
|
18
|
+
// */
|
|
19
|
+
// const RangePicker = ({ minNumber, maxNumber, step, value, label, required, textError, onChangeValueHandler }: RangePickerProps) => {
|
|
20
|
+
// const [currentValue, setCurrentValue] = useState(value ?? 0);
|
|
21
|
+
// const isErrorVisible = (): boolean => {
|
|
22
|
+
// return !(textError && textError.trim() !== '');
|
|
23
|
+
// };
|
|
24
|
+
// const handleChange = (e: React.ChangeEvent<HTMLInputElement>): void => {
|
|
25
|
+
// setCurrentValue(Number(e.target.value));
|
|
26
|
+
// onChangeValueHandler(e);
|
|
27
|
+
// };
|
|
28
|
+
// return (
|
|
29
|
+
// <>
|
|
30
|
+
// <div className='w-full'>
|
|
31
|
+
// <label htmlFor='rangePicker' className='flex items-center gap-2 mx-3 relative'>
|
|
32
|
+
// <p className='text-sm text-text-color-primary font-medium cursor-pointer'>{label}</p>
|
|
33
|
+
// <span className={`text-red-primary font-bold ${required ? 'block' : 'hidden'}`}>*</span>
|
|
34
|
+
// <p className='text-sm text-white-color font-medium absolute left-0 bg-blue-primary w-5 h-5 flex flex-row items-center justify-center rounded-md'>
|
|
35
|
+
// {currentValue}
|
|
36
|
+
// </p>
|
|
37
|
+
// </label>
|
|
38
|
+
// <input type='range' id='rangePicker' min={minNumber} max={maxNumber} step={step} value={currentValue} onChange={handleChange} className='w-full outline-none' />
|
|
39
|
+
// {!isErrorVisible() && <p className='text-sm mt-1 text-red-primary'>{textError?.trim()}</p>}
|
|
40
|
+
// </div>
|
|
41
|
+
// </>
|
|
42
|
+
// );
|
|
43
|
+
// };
|
|
44
|
+
// export default RangePicker;
|
|
45
|
+
'use client';
|
|
46
|
+
// 'use client';
|
|
47
|
+
// import React, { useState } from 'react';
|
|
48
|
+
// import { RangePickerProps } from '../../types/Inputs/RangePickerType';
|
|
49
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
50
|
+
if (k2 === undefined) k2 = k;
|
|
51
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
52
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
53
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
54
|
+
}
|
|
55
|
+
Object.defineProperty(o, k2, desc);
|
|
56
|
+
}) : (function(o, m, k, k2) {
|
|
57
|
+
if (k2 === undefined) k2 = k;
|
|
58
|
+
o[k2] = m[k];
|
|
59
|
+
}));
|
|
60
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
61
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
62
|
+
}) : function(o, v) {
|
|
63
|
+
o["default"] = v;
|
|
64
|
+
});
|
|
65
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
66
|
+
var ownKeys = function(o) {
|
|
67
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
68
|
+
var ar = [];
|
|
69
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
70
|
+
return ar;
|
|
71
|
+
};
|
|
72
|
+
return ownKeys(o);
|
|
73
|
+
};
|
|
74
|
+
return function (mod) {
|
|
75
|
+
if (mod && mod.__esModule) return mod;
|
|
76
|
+
var result = {};
|
|
77
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
78
|
+
__setModuleDefault(result, mod);
|
|
79
|
+
return result;
|
|
80
|
+
};
|
|
81
|
+
})();
|
|
82
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
83
|
+
const react_1 = __importStar(require("react"));
|
|
84
|
+
/**
|
|
85
|
+
* RangePicker Component
|
|
86
|
+
*
|
|
87
|
+
* @param {number} minNumber - The minimum value for the range picker.
|
|
88
|
+
* @param {number} maxNumber - The maximum value for the range picker.
|
|
89
|
+
* @param {number} step - The step interval for the range picker.
|
|
90
|
+
* @param {number} [value] - The initial value for the range picker (optional).
|
|
91
|
+
* @param {string} label - The label displayed above the range picker.
|
|
92
|
+
* @param {boolean} [required] - Whether the field is required (optional).
|
|
93
|
+
* @param {string} [textError] - The error message to display when there is a validation issue (optional).
|
|
94
|
+
* @param {function} onChangeValueHandler - The callback function triggered when the range picker value changes.
|
|
95
|
+
*
|
|
96
|
+
* @returns {JSX.Element} A range picker component with a label and error message.
|
|
97
|
+
*/
|
|
98
|
+
const RangePicker = ({ minNumber, maxNumber, step, value, label, required, textError, onChangeValueHandler, style = {
|
|
99
|
+
margin: '',
|
|
100
|
+
width: 'w-full',
|
|
101
|
+
}, }) => {
|
|
102
|
+
const [currentValue, setCurrentValue] = (0, react_1.useState)(value ?? 0);
|
|
103
|
+
const [isHovered, setIsHovered] = (0, react_1.useState)(false); // Hover state
|
|
104
|
+
const [isTouching, setIsTouching] = (0, react_1.useState)(false); // Touch state
|
|
105
|
+
const isErrorVisible = () => {
|
|
106
|
+
return !(textError && textError.trim() !== '');
|
|
107
|
+
};
|
|
108
|
+
const handleChange = (e) => {
|
|
109
|
+
setCurrentValue(Number(e.target.value));
|
|
110
|
+
onChangeValueHandler(e);
|
|
111
|
+
};
|
|
112
|
+
(0, react_1.useEffect)(() => {
|
|
113
|
+
setCurrentValue(value ?? 0);
|
|
114
|
+
}, [value]);
|
|
115
|
+
return (react_1.default.createElement("div", { className: `relative ${style.width} ${style.margin}`, dir: 'rtl' },
|
|
116
|
+
react_1.default.createElement("label", { htmlFor: 'rangePicker', className: 'flex items-center gap-2 mx-3 relative' },
|
|
117
|
+
react_1.default.createElement("p", { className: 'text-sm text-text-color-primary font-medium cursor-pointer' }, label),
|
|
118
|
+
react_1.default.createElement("span", { className: `text-red-primary font-bold ${required ? 'block' : 'hidden'}` }, "*")),
|
|
119
|
+
react_1.default.createElement("div", { className: 'relative w-full h-12 flex items-center range-main-wrapper', onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false) },
|
|
120
|
+
react_1.default.createElement("input", { type: 'range', id: 'rangePicker', min: minNumber, max: maxNumber, step: step, value: currentValue, onChange: handleChange, className: 'appearance-none w-full h-12 z-10 bg-transparent relative cursor-pointer', onTouchStart: () => setIsTouching(true), onTouchEnd: () => setIsTouching(false) }),
|
|
121
|
+
(isHovered || isTouching) && currentValue !== minNumber && (react_1.default.createElement("output", { className: 'absolute right-0 top-0 transform -translate-y-8 p-2 bg-gray-800 text-white-color text-sm rounded shadow-lg', style: {
|
|
122
|
+
right: `calc(${((currentValue - minNumber) / (maxNumber - minNumber)) * 100}% - 11px)`,
|
|
123
|
+
} }, currentValue)),
|
|
124
|
+
react_1.default.createElement("div", { className: 'absolute left-0 top-1/2 transform -translate-y-1/2 w-full bg-[#eeeeee] h-[8px] rounded-lg' },
|
|
125
|
+
react_1.default.createElement("div", { className: 'h-full bg-inherit', style: {
|
|
126
|
+
width: `${((currentValue - minNumber) / (maxNumber - minNumber)) * 100}%`,
|
|
127
|
+
background: currentValue > minNumber ? '#0366d6' : '#eeeeee', // Only blue when there's a value
|
|
128
|
+
borderRadius: '20px',
|
|
129
|
+
} }))),
|
|
130
|
+
react_1.default.createElement("div", { className: `text-sm text-red-primary mt-1 ${isErrorVisible() ? 'opacity-0' : 'opacity-100'}`, style: { height: '20px' } }, textError?.trim())));
|
|
131
|
+
};
|
|
132
|
+
exports.default = RangePicker;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TextAreaPropsType } from '../../types/Inputs/TextAreaType';
|
|
3
|
+
declare const TextArea: ({ label, placeholder, required, textError, value, onChangeValueHandler, style, }: TextAreaPropsType) => React.JSX.Element;
|
|
4
|
+
export default TextArea;
|