@agilant/toga-blox 1.0.92 → 1.0.94
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/components/BaseInput/BaseCheckbox.d.ts +10 -0
- package/dist/components/BaseInput/BaseCheckbox.js +9 -0
- package/dist/components/BaseInput/BaseInput.d.ts +4 -0
- package/dist/components/BaseInput/BaseInput.js +100 -0
- package/dist/components/BaseInput/BaseInput.stories.d.ts +12 -0
- package/dist/components/BaseInput/BaseInput.stories.js +375 -0
- package/dist/components/BaseInput/BaseInput.test.d.ts +1 -0
- package/dist/components/BaseInput/BaseInput.test.js +560 -0
- package/dist/components/BaseInput/BaseInput.types.d.ts +139 -0
- package/dist/components/BaseInput/BaseInput.types.js +1 -0
- package/dist/components/BaseInput/BaseMultiSelect.d.ts +33 -0
- package/dist/components/BaseInput/BaseMultiSelect.js +68 -0
- package/dist/components/BaseInput/BaseRadio.d.ts +18 -0
- package/dist/components/BaseInput/BaseRadio.js +7 -0
- package/dist/components/BaseInput/BaseSelect.d.ts +41 -0
- package/dist/components/BaseInput/BaseSelect.js +83 -0
- package/dist/components/BaseInput/BaseTextInput.d.ts +27 -0
- package/dist/components/BaseInput/BaseTextInput.js +45 -0
- package/dist/components/BaseInput/BaseTextareaInput.d.ts +27 -0
- package/dist/components/BaseInput/BaseTextareaInput.js +36 -0
- package/dist/components/BaseInput/BaseToggle.d.ts +24 -0
- package/dist/components/BaseInput/BaseToggle.js +8 -0
- package/dist/components/BaseInput/DisabledSelect.d.ts +7 -0
- package/dist/components/BaseInput/DisabledSelect.js +6 -0
- package/dist/components/BaseInput/components/BaseErrorMessage.d.ts +8 -0
- package/dist/components/BaseInput/components/BaseErrorMessage.js +5 -0
- package/dist/components/BaseInput/components/CharacterLimitMessage.d.ts +9 -0
- package/dist/components/BaseInput/components/CharacterLimitMessage.js +7 -0
- package/dist/components/BaseInput/components/DropDownIndicator.d.ts +6 -0
- package/dist/components/BaseInput/components/DropDownIndicator.js +5 -0
- package/dist/components/BaseInput/components/MultiValueRemove.d.ts +4 -0
- package/dist/components/BaseInput/components/MultiValueRemove.js +7 -0
- package/dist/components/BaseInput/components/Option.d.ts +2 -0
- package/dist/components/BaseInput/components/Option.js +19 -0
- package/dist/components/BaseInput/components/SingleValue.d.ts +4 -0
- package/dist/components/BaseInput/components/SingleValue.js +14 -0
- package/dist/components/SearchInput/SearchInput.js +2 -2
- package/dist/components/SearchInput/SearchInput.stories.js +0 -4
- package/dist/components/ToggleButton/ToggleButton.js +2 -2
- package/dist/utils/formatePhoneNumber.d.ts +2 -0
- package/dist/utils/formatePhoneNumber.js +14 -0
- package/dist/utils/fromatTableData.d.ts +45 -0
- package/dist/utils/fromatTableData.js +80 -0
- package/dist/utils/getColSPanClass.d.ts +2 -0
- package/dist/utils/getColSPanClass.js +15 -0
- package/package.json +2 -1
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
export interface OptionType {
|
|
2
|
+
name: string;
|
|
3
|
+
uuid: string;
|
|
4
|
+
}
|
|
5
|
+
export type NestedObject = {
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
};
|
|
8
|
+
export interface Field {
|
|
9
|
+
uuid: string;
|
|
10
|
+
label?: string;
|
|
11
|
+
valueKey?: string;
|
|
12
|
+
inputType?: string;
|
|
13
|
+
separatorType?: string;
|
|
14
|
+
labelTextClasses?: string;
|
|
15
|
+
valueTextClasses?: string;
|
|
16
|
+
hasValueLeftIcon?: string;
|
|
17
|
+
hasValueRightIcon?: string;
|
|
18
|
+
detailGridClasses?: string;
|
|
19
|
+
inputGridClasses?: string;
|
|
20
|
+
specificInputContainerClasses?: string;
|
|
21
|
+
isBoolean?: boolean;
|
|
22
|
+
isSearchable?: boolean;
|
|
23
|
+
truthyValue?: string;
|
|
24
|
+
falsyValue?: string;
|
|
25
|
+
isConcatenated?: string;
|
|
26
|
+
isEditOnly?: boolean;
|
|
27
|
+
inputHasLeftIcon?: string;
|
|
28
|
+
inputIconClasses?: string;
|
|
29
|
+
inputClasses?: string;
|
|
30
|
+
placeholder?: string;
|
|
31
|
+
textAreaHeight?: string;
|
|
32
|
+
hasTypeCheck?: string;
|
|
33
|
+
options?: [];
|
|
34
|
+
inputContainerWidth?: string;
|
|
35
|
+
inputWidth?: string;
|
|
36
|
+
inputDirtyFieldClasses?: string;
|
|
37
|
+
inputLabel?: string;
|
|
38
|
+
characterLimit?: number;
|
|
39
|
+
isRequired?: boolean;
|
|
40
|
+
afterInputText?: string;
|
|
41
|
+
isDoubleValue?: boolean;
|
|
42
|
+
noEditClasses?: string;
|
|
43
|
+
hasSetHeight?: boolean;
|
|
44
|
+
useDefaultValue?: boolean;
|
|
45
|
+
saveUuid?: boolean;
|
|
46
|
+
requireUuidField?: boolean;
|
|
47
|
+
afterInputTextClasses?: string;
|
|
48
|
+
isPhoneNumber?: boolean;
|
|
49
|
+
isCurrency?: boolean;
|
|
50
|
+
useMenuList?: boolean;
|
|
51
|
+
showRequiredIndicator?: boolean;
|
|
52
|
+
disabledSelectText?: string;
|
|
53
|
+
inputAndLabelContainerClasses?: string;
|
|
54
|
+
valueType?: string;
|
|
55
|
+
}
|
|
56
|
+
export interface BaseInputTypes {
|
|
57
|
+
field?: Field;
|
|
58
|
+
dataItem?: string;
|
|
59
|
+
mobileBreakpoint?: string;
|
|
60
|
+
onInputChange?: (inputKey: string, value: any) => void;
|
|
61
|
+
inputFontColor?: string;
|
|
62
|
+
inputBorderColor?: string;
|
|
63
|
+
inputBorderHoverColor?: string;
|
|
64
|
+
inputBorderFocusColor?: string;
|
|
65
|
+
dropDownInputBorderFocusColor?: string;
|
|
66
|
+
dropdownIndicatorClasses?: string;
|
|
67
|
+
checkboxBackgroundColor?: string;
|
|
68
|
+
checkboxBorderColorOnChecked?: string;
|
|
69
|
+
menuBackgroundColor?: string;
|
|
70
|
+
menuBorderColor?: string;
|
|
71
|
+
options?: any;
|
|
72
|
+
isRequired?: boolean;
|
|
73
|
+
menuPlacement?: string;
|
|
74
|
+
useDefaultValue?: boolean;
|
|
75
|
+
inputTextSize?: string;
|
|
76
|
+
uuid?: string | null;
|
|
77
|
+
hasParentControl?: any;
|
|
78
|
+
dynamicDefaultValue?: string;
|
|
79
|
+
isArrayValue?: boolean;
|
|
80
|
+
onBlur?: (e: React.FocusEvent<HTMLInputElement>) => void;
|
|
81
|
+
hasDirtyValidation?: boolean;
|
|
82
|
+
allowTextWrap?: boolean;
|
|
83
|
+
labelTextClasses?: string;
|
|
84
|
+
inputAndLabelContainerClasses?: string;
|
|
85
|
+
inputLabel?: string;
|
|
86
|
+
valueKey: string;
|
|
87
|
+
requireUuidField?: boolean;
|
|
88
|
+
hasTypeCheck?: string;
|
|
89
|
+
inputClasses?: string;
|
|
90
|
+
dropDownInputBorderHoverColor?: string;
|
|
91
|
+
afterInputTextClasses?: string;
|
|
92
|
+
afterInputText?: string;
|
|
93
|
+
isDoubleValue?: string;
|
|
94
|
+
isSearchable?: boolean;
|
|
95
|
+
placeholder?: string;
|
|
96
|
+
valueType?: string;
|
|
97
|
+
inputContainerClasses?: string;
|
|
98
|
+
showRequiredIndicator?: boolean;
|
|
99
|
+
inputHasLeftIcon?: string;
|
|
100
|
+
inputType?: string;
|
|
101
|
+
characterLimit?: number;
|
|
102
|
+
disabledSelectContainerClasses?: string;
|
|
103
|
+
disabledSelectText?: string;
|
|
104
|
+
textAreaHeight?: string;
|
|
105
|
+
colSpan?: string;
|
|
106
|
+
dropdownIndicatorColor?: string;
|
|
107
|
+
onSearchChange?: (inputKey: string) => void;
|
|
108
|
+
isSearchLoading?: boolean;
|
|
109
|
+
toggleTextPosition?: "left" | "right" | "top" | "bottom" | "none";
|
|
110
|
+
toggleTextSize?: string;
|
|
111
|
+
toggleActiveColorBackground?: string;
|
|
112
|
+
toggleInactiveColorBackground?: string;
|
|
113
|
+
toggleActiveColorBorder?: string;
|
|
114
|
+
toggleInactiveColorBorder?: string;
|
|
115
|
+
toggleActiveTextColor?: string;
|
|
116
|
+
toggleInactiveTextColor?: string;
|
|
117
|
+
toggleAdditionalClasses?: string;
|
|
118
|
+
toggleHasDivider?: boolean;
|
|
119
|
+
toggleFontFamily?: string;
|
|
120
|
+
toggleActiveLabel?: string;
|
|
121
|
+
toggleInactiveLabel?: string;
|
|
122
|
+
toggleSmallToggle?: boolean;
|
|
123
|
+
toggleBorderStyle?: boolean;
|
|
124
|
+
extraSmallTextAreaClasses?: string;
|
|
125
|
+
smallTextAreaClasses?: string;
|
|
126
|
+
largeTextAreaClasses?: string;
|
|
127
|
+
controlClasses?: string;
|
|
128
|
+
selectInputDirtyFieldClasses?: string;
|
|
129
|
+
selectInputErrorFieldClasses?: string;
|
|
130
|
+
menuClasses?: string;
|
|
131
|
+
textDirtyFieldClasses?: string;
|
|
132
|
+
textErrorFieldClasses?: string;
|
|
133
|
+
textAreaDirtyFieldClasses?: string;
|
|
134
|
+
textAreaErrorFieldClasses?: string;
|
|
135
|
+
radioBorderColorOnChecked?: string;
|
|
136
|
+
radioBackgroundColor?: string;
|
|
137
|
+
containerClasses?: string;
|
|
138
|
+
radioOptionTextClasses?: string;
|
|
139
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { OptionType } from "./BaseInput.types";
|
|
3
|
+
interface BaseMultiSelectProps {
|
|
4
|
+
control: any;
|
|
5
|
+
defaultValue: OptionType[];
|
|
6
|
+
valueKey: string;
|
|
7
|
+
inputContainerClasses: string;
|
|
8
|
+
isRequired: boolean;
|
|
9
|
+
options: OptionType[];
|
|
10
|
+
isSearchable: boolean;
|
|
11
|
+
placeholder: string;
|
|
12
|
+
dropdownIndicatorColor: string;
|
|
13
|
+
useDefaultValue: boolean;
|
|
14
|
+
input: {
|
|
15
|
+
inputWidth: string;
|
|
16
|
+
};
|
|
17
|
+
inputTextSize: string;
|
|
18
|
+
controlClasses: string;
|
|
19
|
+
dropdownIndicatorClasses: string;
|
|
20
|
+
inputBorderColor: string;
|
|
21
|
+
dropDownInputBorderFocusColor: string;
|
|
22
|
+
dropDownInputBorderHoverColor: string;
|
|
23
|
+
selectInputDirtyFieldClasses: string;
|
|
24
|
+
selectInputErrorFieldClasses: string;
|
|
25
|
+
isFieldDirty: boolean;
|
|
26
|
+
isFieldError: boolean;
|
|
27
|
+
hasDirtyValidation: boolean;
|
|
28
|
+
errorMessage: string;
|
|
29
|
+
inputFontColor: string;
|
|
30
|
+
menuClasses: string;
|
|
31
|
+
}
|
|
32
|
+
declare const BaseMultiSelect: React.FC<BaseMultiSelectProps>;
|
|
33
|
+
export default BaseMultiSelect;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Controller } from "react-hook-form";
|
|
3
|
+
import Select from "react-select";
|
|
4
|
+
import Option from "./components/Option";
|
|
5
|
+
import DropDownIndicator from "./components/DropDownIndicator";
|
|
6
|
+
import classNames from "classnames";
|
|
7
|
+
import BaseErrorMessage from "./components/BaseErrorMessage";
|
|
8
|
+
import MultiValueRemove from "./components/MultiValueRemove";
|
|
9
|
+
const BaseMultiSelect = (props) => {
|
|
10
|
+
const { control, defaultValue, valueKey, inputContainerClasses, isRequired, options, isSearchable, placeholder, dropdownIndicatorColor, useDefaultValue, input, inputTextSize, controlClasses, dropdownIndicatorClasses, inputBorderColor, dropDownInputBorderFocusColor, dropDownInputBorderHoverColor, selectInputDirtyFieldClasses, selectInputErrorFieldClasses, isFieldDirty, isFieldError, hasDirtyValidation, errorMessage, inputFontColor, menuClasses, } = props;
|
|
11
|
+
return (_jsxs("div", { className: `${inputContainerClasses}`, children: [_jsx(Controller, { defaultValue: defaultValue, name: valueKey, rules: {
|
|
12
|
+
required: isRequired
|
|
13
|
+
? {
|
|
14
|
+
value: true,
|
|
15
|
+
message: `Required field.`,
|
|
16
|
+
}
|
|
17
|
+
: false,
|
|
18
|
+
}, control: control, render: ({ field, }) => {
|
|
19
|
+
const selectedOptions = Array.isArray(field.value)
|
|
20
|
+
? field.value.map((val) => options.find((option) => option.uuid === val.uuid))
|
|
21
|
+
: [];
|
|
22
|
+
return (_jsx(Select, { isSearchable: isSearchable, id: valueKey, unstyled: true, placeholder: placeholder, ...field, isMulti: true, components: {
|
|
23
|
+
DropdownIndicator: (props) => (_jsx(DropDownIndicator, { ...props, className: dropdownIndicatorColor })),
|
|
24
|
+
Option: (props) => (_jsx(Option, { ...props, isMulti: true })),
|
|
25
|
+
MultiValueRemove: (props) => (_jsx(MultiValueRemove, { ...props })),
|
|
26
|
+
ClearIndicator: () => null,
|
|
27
|
+
}, hideSelectedOptions: true, closeMenuOnSelect: false, options: Array.isArray(options) ? options : [], getOptionValue: (option) => option.uuid, getOptionLabel: (option) => option.name, value: useDefaultValue
|
|
28
|
+
? selectedOptions || null
|
|
29
|
+
: undefined, onChange: (selectedValues) => {
|
|
30
|
+
if (selectedValues === null) {
|
|
31
|
+
field.onChange(null);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
field.onChange(selectedValues);
|
|
35
|
+
const values = selectedValues
|
|
36
|
+
? selectedValues.map((option) => option.value)
|
|
37
|
+
: [];
|
|
38
|
+
}
|
|
39
|
+
}, className: `${input.inputWidth} ${inputTextSize}`, classNames: {
|
|
40
|
+
control: ({ isFocused }) => classNames(controlClasses, isFieldDirty &&
|
|
41
|
+
!isFocused &&
|
|
42
|
+
!isFieldError &&
|
|
43
|
+
hasDirtyValidation
|
|
44
|
+
? selectInputDirtyFieldClasses
|
|
45
|
+
: isFieldError &&
|
|
46
|
+
isFieldDirty &&
|
|
47
|
+
!isFocused &&
|
|
48
|
+
hasDirtyValidation
|
|
49
|
+
? selectInputErrorFieldClasses
|
|
50
|
+
: isFieldDirty
|
|
51
|
+
? selectInputDirtyFieldClasses
|
|
52
|
+
: inputBorderColor, isFocused &&
|
|
53
|
+
`border-1 ${dropDownInputBorderFocusColor}`, !isFocused &&
|
|
54
|
+
`${dropDownInputBorderHoverColor}`),
|
|
55
|
+
dropdownIndicator: ({ isFocused }) => classNames(dropdownIndicatorClasses, isFocused
|
|
56
|
+
? "text-neutral-600"
|
|
57
|
+
: "text-neutral-200", "", isFocused
|
|
58
|
+
? "hover:text-neutral-800"
|
|
59
|
+
: "hover:text-neutral-400"),
|
|
60
|
+
input: () => classNames(inputFontColor, "p-0"),
|
|
61
|
+
menu: () => classNames(menuClasses),
|
|
62
|
+
placeholder: () => classNames("text-gray-500", "text-nowrap", "truncate"),
|
|
63
|
+
valueContainer: () => classNames("py-0.5", "px-2"),
|
|
64
|
+
multiValue: () => classNames("rounded-full", "bg-blue-500", "text-white", "text-xs", "px-2", "py-1", "mr-1", "my-0.5", "items-center"),
|
|
65
|
+
} }));
|
|
66
|
+
} }), errorMessage && _jsx(BaseErrorMessage, { errorMessage: errorMessage })] }));
|
|
67
|
+
};
|
|
68
|
+
export default BaseMultiSelect;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface BaseRadioInputProps {
|
|
3
|
+
control: any;
|
|
4
|
+
valueKey: string;
|
|
5
|
+
defaultValue: string;
|
|
6
|
+
options: {
|
|
7
|
+
value: string;
|
|
8
|
+
label: string;
|
|
9
|
+
}[];
|
|
10
|
+
radioSize?: string;
|
|
11
|
+
innerCircleSize?: string;
|
|
12
|
+
radioBorderColorOnChecked?: string;
|
|
13
|
+
radioBackgroundColor?: string;
|
|
14
|
+
radioOptionTextClasses?: string;
|
|
15
|
+
containerClasses?: string;
|
|
16
|
+
}
|
|
17
|
+
declare const BaseRadioInput: React.FC<BaseRadioInputProps>;
|
|
18
|
+
export default BaseRadioInput;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Controller } from "react-hook-form";
|
|
3
|
+
const BaseRadioInput = (props) => {
|
|
4
|
+
const { control, valueKey, defaultValue, options, radioSize = "h-4 w-4", innerCircleSize = "h-1.5 w-1.5", radioBorderColorOnChecked = "checked:border-blue-600", radioBackgroundColor = "checked:bg-blue-600", radioOptionTextClasses = "text-sm text-gray-800", containerClasses = "flex flex-col space-y-2", } = props;
|
|
5
|
+
return (_jsx(Controller, { name: valueKey, control: control, defaultValue: defaultValue, render: ({ field }) => (_jsx("div", { className: containerClasses, children: options.map((option) => (_jsxs("label", { className: "flex items-center cursor-pointer space-x-2", children: [_jsxs("div", { className: `relative flex items-center justify-center ${radioSize}`, children: [_jsx("input", { type: "radio", className: `peer ${radioSize} cursor-pointer transition-all appearance-none rounded-full border border-gray-400 ${radioBorderColorOnChecked} ${radioBackgroundColor}`, id: `${valueKey}-${option.value}`, value: option.value, checked: field.value === option.value, onChange: () => field.onChange(option.value) }), _jsx("span", { className: "absolute inset-0 flex items-center justify-center peer-checked:opacity-100 peer-checked:scale-100 opacity-0 scale-0 transition-transform duration-150 ease-in-out", children: _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", className: `${innerCircleSize} text-white`, viewBox: "0 0 20 20", fill: "currentColor", stroke: "currentColor", strokeWidth: "1", children: _jsx("circle", { cx: "10", cy: "10", r: "7" }) }) })] }), _jsx("span", { className: radioOptionTextClasses, children: option.label })] }, option.value))) })) }));
|
|
6
|
+
};
|
|
7
|
+
export default BaseRadioInput;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { OptionType } from "./BaseInput.types";
|
|
3
|
+
interface BaseSelectProps {
|
|
4
|
+
inputContainerClasses?: string;
|
|
5
|
+
inputClasses?: string;
|
|
6
|
+
control: any;
|
|
7
|
+
isRequired?: boolean;
|
|
8
|
+
valueKey: string;
|
|
9
|
+
uuid?: string;
|
|
10
|
+
options: OptionType[];
|
|
11
|
+
errorMessage?: string;
|
|
12
|
+
isFieldDirty?: boolean;
|
|
13
|
+
isFieldError?: boolean;
|
|
14
|
+
dropdownIndicatorClasses?: string;
|
|
15
|
+
dropdownIndicatorColor?: string;
|
|
16
|
+
dropDownInputBorderFocusColor?: string;
|
|
17
|
+
dropDownInputBorderHoverColor?: string;
|
|
18
|
+
inputBorderColor?: string;
|
|
19
|
+
inputBorderHoverColor?: string;
|
|
20
|
+
selectInputDirtyFieldClasses?: string;
|
|
21
|
+
selectInputErrorFieldClasses?: string;
|
|
22
|
+
controlClasses?: string;
|
|
23
|
+
menuBackgroundColor?: string;
|
|
24
|
+
menuBorderColor?: string;
|
|
25
|
+
inputFontColor?: string;
|
|
26
|
+
selectRef?: React.RefObject<any>;
|
|
27
|
+
handleInputChange?: (inputValue: string) => void;
|
|
28
|
+
hasParentControl?: any;
|
|
29
|
+
isDoubleValue?: boolean;
|
|
30
|
+
defaultValue?: any;
|
|
31
|
+
isSearchable?: boolean;
|
|
32
|
+
isSearchLoading?: boolean;
|
|
33
|
+
validMenuPlacement?: "auto" | "bottom" | "top";
|
|
34
|
+
hasDirtyValidation?: boolean;
|
|
35
|
+
requireUuidField?: boolean;
|
|
36
|
+
placeholder?: string;
|
|
37
|
+
getValues: (name: string) => any;
|
|
38
|
+
setValue: (name: string, value: any) => void;
|
|
39
|
+
}
|
|
40
|
+
declare const BaseSelect: React.FC<BaseSelectProps>;
|
|
41
|
+
export default BaseSelect;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { Controller } from "react-hook-form";
|
|
4
|
+
import Select from "react-select";
|
|
5
|
+
import Option from "./components/Option";
|
|
6
|
+
import SingleValue from "./components/SingleValue";
|
|
7
|
+
import DropDownIndicator from "./components/DropDownIndicator";
|
|
8
|
+
import classNames from "classnames";
|
|
9
|
+
import BaseErrorMessage from "./components/BaseErrorMessage";
|
|
10
|
+
const BaseSelect = (props) => {
|
|
11
|
+
const { inputContainerClasses = "text-left relative", inputClasses, control, isRequired, valueKey, uuid, options, errorMessage, isFieldDirty, isFieldError, dropdownIndicatorClasses, dropdownIndicatorColor, dropDownInputBorderFocusColor, dropDownInputBorderHoverColor, inputBorderColor, selectInputDirtyFieldClasses, selectInputErrorFieldClasses, controlClasses = "border-1 border-gray-200", menuBackgroundColor = "bg-white", menuBorderColor = "border-gray-200", inputFontColor = "text-gray-800", selectRef = React.createRef(), handleInputChange = () => { }, hasParentControl, isDoubleValue = false, defaultValue, isSearchable = true, isSearchLoading = false, validMenuPlacement = "auto", hasDirtyValidation = true, requireUuidField = false, placeholder = "Select", getValues, setValue, } = props;
|
|
12
|
+
return (options && (_jsxs("div", { className: `${inputContainerClasses} `, children: [_jsx(Controller, { defaultValue: defaultValue, name: `${requireUuidField ? uuid : valueKey}`, rules: {
|
|
13
|
+
...(isRequired
|
|
14
|
+
? {
|
|
15
|
+
required: {
|
|
16
|
+
value: true,
|
|
17
|
+
message: `Required field.`,
|
|
18
|
+
},
|
|
19
|
+
}
|
|
20
|
+
: {}),
|
|
21
|
+
}, control: hasParentControl ? hasParentControl : control, render: ({ field }) => {
|
|
22
|
+
return (_jsx(Select, { menuPlacement: validMenuPlacement, id: valueKey, unstyled: true, isClearable: true, closeMenuOnSelect: true, ref: selectRef, maxMenuHeight: 160, placeholder: placeholder, isSearchable: isSearchable, isLoading: isSearchLoading, onInputChange: handleInputChange, components: {
|
|
23
|
+
DropdownIndicator: (props) => (_jsx(DropDownIndicator, { ...props, className: dropdownIndicatorColor })),
|
|
24
|
+
SingleValue: (props) => (_jsx(SingleValue, { ...props, isDoubleValue: isDoubleValue })),
|
|
25
|
+
Option: (props) => (_jsx(Option, { ...props, isMulti: false, selectedOption: getValues(valueKey), isDoubleValue: isDoubleValue })),
|
|
26
|
+
}, className: `${inputClasses}`, classNames: {
|
|
27
|
+
clearIndicator: ({ isFocused }) => classNames(isFocused
|
|
28
|
+
? "text-neutral-600"
|
|
29
|
+
: "text-neutral-200", isFocused
|
|
30
|
+
? "hover:text-neutral-800"
|
|
31
|
+
: "hover:text-neutral-400"),
|
|
32
|
+
control: ({ isFocused }) => classNames(isDoubleValue ? "h-[50px]" : "", controlClasses, isFieldDirty &&
|
|
33
|
+
!isFocused &&
|
|
34
|
+
hasDirtyValidation &&
|
|
35
|
+
!isFieldError
|
|
36
|
+
? selectInputDirtyFieldClasses
|
|
37
|
+
: isFieldError &&
|
|
38
|
+
isFieldDirty &&
|
|
39
|
+
hasDirtyValidation &&
|
|
40
|
+
!isFocused
|
|
41
|
+
? selectInputErrorFieldClasses
|
|
42
|
+
: isFieldDirty
|
|
43
|
+
? selectInputDirtyFieldClasses
|
|
44
|
+
: inputBorderColor, isFocused &&
|
|
45
|
+
`border-1 ${dropDownInputBorderFocusColor}`, !isFocused &&
|
|
46
|
+
`border-transparent ${dropDownInputBorderHoverColor}`),
|
|
47
|
+
dropdownIndicator: ({ isFocused }) => classNames(dropdownIndicatorClasses, "text-gray-800", isFocused
|
|
48
|
+
? "text-neutral-600"
|
|
49
|
+
: dropdownIndicatorColor, isFocused
|
|
50
|
+
? "hover:text-neutral-800"
|
|
51
|
+
: dropdownIndicatorColor),
|
|
52
|
+
input: () => classNames(inputFontColor, "p-0"),
|
|
53
|
+
menu: () => classNames("rounded border-1 shadow-md", menuBackgroundColor, menuBorderColor, "overflow-x-hidden"),
|
|
54
|
+
menuList: () => classNames("overflow-y-scroll", "overflow-x-hidden"),
|
|
55
|
+
placeholder: () => classNames("text-gray-800", "text-nowrap", "truncate", "text-sm"),
|
|
56
|
+
valueContainer: () => classNames("py-0.5", "px-2"),
|
|
57
|
+
}, getOptionValue: (option) => option.uuid, getOptionLabel: (option) => option.name, options: options, value: options.find((option) => field.value &&
|
|
58
|
+
option.uuid === field.value.uuid &&
|
|
59
|
+
(isDoubleValue ||
|
|
60
|
+
option._name ===
|
|
61
|
+
field.value._name)) || null, onChange: (selectedOption) => {
|
|
62
|
+
if (selectedOption === null) {
|
|
63
|
+
field.onChange(null);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
if (!selectedOption.uuid ||
|
|
67
|
+
!selectedOption.name) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const selectedValue = {
|
|
71
|
+
uuid: selectedOption.uuid,
|
|
72
|
+
name: selectedOption.name,
|
|
73
|
+
};
|
|
74
|
+
setValue(valueKey, selectedValue);
|
|
75
|
+
field.onChange(selectedValue);
|
|
76
|
+
}
|
|
77
|
+
if (selectRef.current) {
|
|
78
|
+
selectRef.current.blur();
|
|
79
|
+
}
|
|
80
|
+
} }));
|
|
81
|
+
} }), errorMessage && (_jsx(BaseErrorMessage, { errorMessage: errorMessage, containerClasses: "flex items-start justify-start" }))] })));
|
|
82
|
+
};
|
|
83
|
+
export default BaseSelect;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface BaseTextInputProps {
|
|
3
|
+
inputBorderColor?: string;
|
|
4
|
+
inputBorderHoverColor?: string;
|
|
5
|
+
inputBorderFocusColor?: string;
|
|
6
|
+
uuid: string;
|
|
7
|
+
defaultValue: any;
|
|
8
|
+
control: any;
|
|
9
|
+
onBlur: (e: React.FocusEvent<HTMLInputElement>) => void;
|
|
10
|
+
inputContainerClasses?: string;
|
|
11
|
+
inputHasLeftIcon?: string;
|
|
12
|
+
isRequired?: boolean;
|
|
13
|
+
showRequiredIndicator?: boolean;
|
|
14
|
+
inputClasses?: string;
|
|
15
|
+
valueType?: string;
|
|
16
|
+
valueKey: string;
|
|
17
|
+
requireUuidField?: boolean;
|
|
18
|
+
hasTypeCheck?: string;
|
|
19
|
+
placeholder?: string;
|
|
20
|
+
errorMessage?: string;
|
|
21
|
+
isFieldDirty?: boolean;
|
|
22
|
+
isFieldError?: boolean;
|
|
23
|
+
textInputDirtyFieldClasses?: string;
|
|
24
|
+
textInputErrorFieldClasses?: string;
|
|
25
|
+
}
|
|
26
|
+
declare const BaseTextInput: React.FC<BaseTextInputProps>;
|
|
27
|
+
export default BaseTextInput;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Controller } from "react-hook-form";
|
|
3
|
+
import { getFontAwesomeIcon } from "../../utils/getFontAwesomeIcon";
|
|
4
|
+
import BaseErrorMessage from "./components/BaseErrorMessage";
|
|
5
|
+
import formatPhoneNumber from "../../utils/formatePhoneNumber";
|
|
6
|
+
const BaseTextInput = (props) => {
|
|
7
|
+
const { inputBorderColor = "border-gray-200", inputBorderHoverColor = "hover:border-1 hover:border-black", inputBorderFocusColor = "focus:border-primary-600", uuid, defaultValue, control, onBlur, inputContainerClasses = "text-left relative", inputHasLeftIcon, isRequired, inputClasses, valueType, valueKey, requireUuidField, hasTypeCheck, placeholder, errorMessage, isFieldDirty, isFieldError, textInputDirtyFieldClasses, textInputErrorFieldClasses, } = props;
|
|
8
|
+
return (_jsxs("div", { className: `w-full ${inputHasLeftIcon ? "relative block" : ""} ${inputContainerClasses} cursor-pointer`, children: [inputHasLeftIcon && (_jsx("div", { className: `pointer-events-none cursor-none text-xs text-navy-300 absolute top-[12px] left-2`, children: getFontAwesomeIcon(inputHasLeftIcon, "solid") })), _jsx(Controller, { name: `${requireUuidField ? uuid : valueKey}`, control: control, defaultValue: defaultValue, rules: {
|
|
9
|
+
...(isRequired
|
|
10
|
+
? {
|
|
11
|
+
required: {
|
|
12
|
+
value: true,
|
|
13
|
+
message: `Required field.`,
|
|
14
|
+
},
|
|
15
|
+
}
|
|
16
|
+
: {}),
|
|
17
|
+
...(hasTypeCheck === "number"
|
|
18
|
+
? {
|
|
19
|
+
pattern: {
|
|
20
|
+
value: /^[0-9]*\.?[0-9]*$/,
|
|
21
|
+
message: `Only numbers allowed.`,
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
: {}),
|
|
25
|
+
}, render: ({ field }) => (_jsx("input", { ...field, id: valueKey, type: hasTypeCheck === "number" ? "number" : "text", className: `h-38px px-2
|
|
26
|
+
${inputClasses}
|
|
27
|
+
${inputBorderHoverColor}
|
|
28
|
+
${inputBorderFocusColor}
|
|
29
|
+
${isFieldDirty &&
|
|
30
|
+
!isFieldError
|
|
31
|
+
? textInputDirtyFieldClasses
|
|
32
|
+
: (isFieldError &&
|
|
33
|
+
isFieldDirty) ||
|
|
34
|
+
(isFieldError &&
|
|
35
|
+
!isFieldDirty)
|
|
36
|
+
? textInputErrorFieldClasses
|
|
37
|
+
: inputBorderColor} `, placeholder: placeholder, onFocus: (e) => e.target.select(), onBlur: onBlur, onChange: (e) => {
|
|
38
|
+
let value = e.target.value;
|
|
39
|
+
if (valueType === "phone") {
|
|
40
|
+
value = formatPhoneNumber(value);
|
|
41
|
+
}
|
|
42
|
+
field.onChange(value);
|
|
43
|
+
} })) }), errorMessage && (_jsx(BaseErrorMessage, { errorMessage: errorMessage, containerClasses: "text-left" }))] }));
|
|
44
|
+
};
|
|
45
|
+
export default BaseTextInput;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface BaseTextareaInputProps {
|
|
3
|
+
input: any;
|
|
4
|
+
inputTextSize: string;
|
|
5
|
+
watch: (name: string) => any;
|
|
6
|
+
control: any;
|
|
7
|
+
defaultValue: string;
|
|
8
|
+
valueKey: string;
|
|
9
|
+
errorMessage?: string;
|
|
10
|
+
isFieldDirty: boolean;
|
|
11
|
+
isFieldError: boolean;
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
characterLimit?: number;
|
|
14
|
+
textAreaHeight?: "small" | "large" | "extraSmall";
|
|
15
|
+
textAreaInputDirtyFieldClasses?: string;
|
|
16
|
+
textAreaInputErrorFieldClasses?: string;
|
|
17
|
+
smallTextAreaClasses?: string;
|
|
18
|
+
largeTextAreaClasses?: string;
|
|
19
|
+
extraSmallTextAreaClasses?: string;
|
|
20
|
+
inputContainerClasses?: string;
|
|
21
|
+
inputFontColor?: string;
|
|
22
|
+
inputBorderColor?: string;
|
|
23
|
+
inputBorderHoverColor?: string;
|
|
24
|
+
inputBorderFocusColor?: string;
|
|
25
|
+
}
|
|
26
|
+
declare const BaseTextareaInput: React.FC<BaseTextareaInputProps>;
|
|
27
|
+
export default BaseTextareaInput;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Controller } from "react-hook-form";
|
|
3
|
+
import BaseErrorMessage from "./components/BaseErrorMessage";
|
|
4
|
+
import CharacterLimitMessage from "./components/CharacterLimitMessage";
|
|
5
|
+
const BaseTextareaInput = (props) => {
|
|
6
|
+
const { input, inputTextSize, watch, control, defaultValue, valueKey, errorMessage, isFieldDirty, isFieldError, placeholder, characterLimit, textAreaHeight, textAreaInputDirtyFieldClasses, textAreaInputErrorFieldClasses, smallTextAreaClasses, largeTextAreaClasses, extraSmallTextAreaClasses, inputContainerClasses = "text-left relative", inputFontColor = "text-gray-800", inputBorderColor = "border-gray-200", inputBorderHoverColor = "hover:border-1 hover:border-black", inputBorderFocusColor = "focus:border-primary-600", } = props;
|
|
7
|
+
return (_jsx("div", { className: `${inputContainerClasses}`, children: _jsx(Controller, { control: control, name: valueKey, defaultValue: defaultValue, render: ({ field }) => {
|
|
8
|
+
const textAreaValue = watch(valueKey);
|
|
9
|
+
const characterCount = textAreaValue
|
|
10
|
+
? textAreaValue.length
|
|
11
|
+
: 0;
|
|
12
|
+
return (_jsxs("div", { className: "w-full", children: [_jsx("div", { className: `w-full flex`, children: _jsx("textarea", { ...field, id: valueKey, placeholder: placeholder, value: field.value || "", className: `p-1 border-1 ${inputFontColor}
|
|
13
|
+
${input.inputClasses}
|
|
14
|
+
${inputBorderHoverColor}
|
|
15
|
+
${inputBorderFocusColor} ${inputTextSize}
|
|
16
|
+
${textAreaHeight ===
|
|
17
|
+
"small"
|
|
18
|
+
? smallTextAreaClasses
|
|
19
|
+
: textAreaHeight ===
|
|
20
|
+
"large"
|
|
21
|
+
? largeTextAreaClasses
|
|
22
|
+
: extraSmallTextAreaClasses}
|
|
23
|
+
${isFieldDirty &&
|
|
24
|
+
!isFieldError
|
|
25
|
+
? textAreaInputDirtyFieldClasses
|
|
26
|
+
: (isFieldError &&
|
|
27
|
+
isFieldDirty) ||
|
|
28
|
+
(isFieldError &&
|
|
29
|
+
!isFieldDirty)
|
|
30
|
+
? textAreaInputErrorFieldClasses
|
|
31
|
+
: inputBorderColor}`, onFocus: (e) => e.target.select() }) }), _jsxs("div", { className: `flex w-full ${characterLimit && !isFieldError
|
|
32
|
+
? "items-end justify-end"
|
|
33
|
+
: "justify-between"}`, children: [errorMessage && (_jsx(BaseErrorMessage, { errorMessage: errorMessage, containerClasses: "flex items-start justify-start" })), characterLimit && (_jsx(CharacterLimitMessage, { isFieldError: isFieldError, isFieldDirty: isFieldDirty, characterLimit: characterLimit, characterCount: characterCount }))] })] }));
|
|
34
|
+
} }) }));
|
|
35
|
+
};
|
|
36
|
+
export default BaseTextareaInput;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface BaseToggleProps {
|
|
3
|
+
control: any;
|
|
4
|
+
valueKey: string;
|
|
5
|
+
inputContainerClasses?: string;
|
|
6
|
+
defaultValue?: any;
|
|
7
|
+
toggleTextPosition?: "left" | "right" | "top" | "bottom" | "none";
|
|
8
|
+
toggleTextSize?: string;
|
|
9
|
+
toggleActiveColorBackground?: string;
|
|
10
|
+
toggleInactiveColorBackground?: string;
|
|
11
|
+
toggleActiveColorBorder?: string;
|
|
12
|
+
toggleInactiveColorBorder?: string;
|
|
13
|
+
toggleActiveTextColor?: string;
|
|
14
|
+
toggleInactiveTextColor?: string;
|
|
15
|
+
toggleAdditionalClasses?: string;
|
|
16
|
+
toggleHasDivider?: boolean;
|
|
17
|
+
toggleFontFamily?: string;
|
|
18
|
+
toggleActiveLabel?: string;
|
|
19
|
+
toggleInactiveLabel?: string;
|
|
20
|
+
toggleSmallToggle?: boolean;
|
|
21
|
+
toggleBorderStyle?: boolean;
|
|
22
|
+
}
|
|
23
|
+
declare const BaseToggle: React.FC<BaseToggleProps>;
|
|
24
|
+
export default BaseToggle;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Controller } from "react-hook-form";
|
|
3
|
+
import ToggleButton from "../ToggleButton/ToggleButton";
|
|
4
|
+
const BaseToggle = (props) => {
|
|
5
|
+
const { control, valueKey, inputContainerClasses, defaultValue, toggleTextPosition = "right", toggleTextSize = "sm", toggleActiveColorBackground = "bg-blue-600", toggleInactiveColorBackground = "bg-blue-300", toggleActiveColorBorder = "border-blue-500", toggleInactiveColorBorder = "border-blue-300", toggleActiveTextColor = "text-blue-800", toggleInactiveTextColor = "text-blue-600", toggleAdditionalClasses = `w-1/4`, toggleHasDivider = false, toggleFontFamily = "font-omnes-regular", toggleActiveLabel = "Yes", toggleInactiveLabel = "No", toggleSmallToggle = true, toggleBorderStyle = true, } = props;
|
|
6
|
+
return (_jsx("div", { className: `${inputContainerClasses}`, children: _jsx(Controller, { control: control, name: valueKey, defaultValue: defaultValue, render: ({ field: { value, onChange } }) => (_jsx(ToggleButton, { initialStatus: Boolean(value), onClick: () => onChange(!value), textPosition: toggleTextPosition, textSize: toggleTextSize, activeColorBackground: toggleActiveColorBackground, inactiveColorBackground: toggleInactiveColorBackground, activeColorBorder: toggleActiveColorBorder, inactiveColorBorder: toggleInactiveColorBorder, activeTextColor: toggleActiveTextColor, inactiveTextColor: toggleInactiveTextColor, additionalClasses: toggleAdditionalClasses, hasDivider: toggleHasDivider, fontFamily: toggleFontFamily, activeLabel: toggleActiveLabel, inactiveLabel: toggleInactiveLabel, id: valueKey, smallToggle: toggleSmallToggle, borderStyle: toggleBorderStyle })) }) }));
|
|
7
|
+
};
|
|
8
|
+
export default BaseToggle;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
const DisabledSelect = ({ disabledSelectText, containerClasses, labelTextClasses = "text-navy-400", }) => {
|
|
3
|
+
const baseContainerClasses = "flex text-left p-1 pr-2 py-2 hover:cursor-not-allowed h-38px";
|
|
4
|
+
return (_jsx("div", { className: `${baseContainerClasses} ${containerClasses}`, children: _jsxs("div", { className: `flex items-center justify-between w-full `, children: [_jsx("div", { className: `${labelTextClasses}`, children: disabledSelectText }), _jsx("svg", { height: "20", width: "20", viewBox: "0 0 20 20", "aria-hidden": "true", focusable: "false", className: "fill-navy-400", children: _jsx("path", { d: "M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z" }) })] }) }));
|
|
5
|
+
};
|
|
6
|
+
export default DisabledSelect;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface BaseErrorMessageProps {
|
|
2
|
+
errorMessage: string;
|
|
3
|
+
containerClasses?: string;
|
|
4
|
+
errorMessageStyles?: React.CSSProperties;
|
|
5
|
+
errorMessageTextClasses?: string;
|
|
6
|
+
}
|
|
7
|
+
declare const BaseErrorMessage: React.FC<BaseErrorMessageProps>;
|
|
8
|
+
export default BaseErrorMessage;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
const BaseErrorMessage = ({ errorMessage, errorMessageStyles = { width: "500px" }, errorMessageTextClasses = "text-xs text-crimson-700", containerClasses = "absolute top-full mt-.5", }) => {
|
|
3
|
+
return (_jsx("span", { className: containerClasses, style: errorMessageStyles, children: _jsx("p", { className: errorMessageTextClasses, children: errorMessage }) }));
|
|
4
|
+
};
|
|
5
|
+
export default BaseErrorMessage;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface BaseCharacterLimitProps {
|
|
2
|
+
containerClasses?: string;
|
|
3
|
+
isFieldError: boolean;
|
|
4
|
+
isFieldDirty: boolean;
|
|
5
|
+
characterLimit: number | string;
|
|
6
|
+
characterCount: number;
|
|
7
|
+
}
|
|
8
|
+
declare const CharacterLimitMessage: React.FC<BaseCharacterLimitProps>;
|
|
9
|
+
export default CharacterLimitMessage;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
const CharacterLimitMessage = ({ containerClasses = "flex items-end justify-end", isFieldError, isFieldDirty, characterLimit, characterCount, }) => {
|
|
3
|
+
return (_jsx("span", { className: containerClasses, children: _jsx("p", { className: `text-xs ${isFieldError && isFieldDirty
|
|
4
|
+
? "text-crimson-700"
|
|
5
|
+
: "text-navy-350"}`, children: `${characterCount}/${characterLimit}` }) }));
|
|
6
|
+
};
|
|
7
|
+
export default CharacterLimitMessage;
|