opus-toolkit-components 0.3.8 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -832,7 +832,9 @@ function DatePicker(_ref) {
|
|
|
832
832
|
// Add name prop for form identification
|
|
833
833
|
onChange,
|
|
834
834
|
// Add onChange prop for passing event to parent
|
|
835
|
-
value
|
|
835
|
+
value,
|
|
836
|
+
className = '',
|
|
837
|
+
required = false // Add the required prop
|
|
836
838
|
} = _ref;
|
|
837
839
|
const [selectedDate, setSelectedDate] = (0,external_react_.useState)(value || initialDate);
|
|
838
840
|
(0,external_react_.useEffect)(() => {
|
|
@@ -848,54 +850,88 @@ function DatePicker(_ref) {
|
|
|
848
850
|
onChange(e); // Pass the full event object to the parent component
|
|
849
851
|
}
|
|
850
852
|
};
|
|
851
|
-
const inputClasses =
|
|
853
|
+
const inputClasses = `${className} flex items-center rounded-md bg-white border ${isValid ? 'border-greyLight500' : 'border-utilRed1000'} p-2 text-md font-normal text-gray-900`;
|
|
852
854
|
return /*#__PURE__*/external_react_default().createElement("div", {
|
|
853
855
|
className: "flex flex-col mb-4"
|
|
854
856
|
}, /*#__PURE__*/external_react_default().createElement("label", {
|
|
855
857
|
htmlFor: "date"
|
|
856
|
-
}, label
|
|
858
|
+
}, label, required && /*#__PURE__*/external_react_default().createElement("span", {
|
|
859
|
+
className: "text-utilRed1000 ml-1"
|
|
860
|
+
}, "*")), /*#__PURE__*/external_react_default().createElement("input", {
|
|
857
861
|
type: "date",
|
|
858
862
|
id: "date",
|
|
859
863
|
name: name // Pass the name to identify the input in the event
|
|
860
864
|
,
|
|
861
865
|
value: selectedDate,
|
|
862
866
|
onChange: handleDateChange,
|
|
863
|
-
className: inputClasses
|
|
867
|
+
className: inputClasses,
|
|
868
|
+
required: required // Apply the required attribute to the input
|
|
864
869
|
}), !isValid && /*#__PURE__*/external_react_default().createElement("span", {
|
|
865
|
-
className: "text-
|
|
870
|
+
className: "text-utilRed1000 text-sm"
|
|
866
871
|
}, errorMessage));
|
|
867
872
|
}
|
|
868
873
|
;// ./src/components/Forms/Radios/RadioButton.js
|
|
869
874
|
|
|
870
|
-
|
|
875
|
+
const RadioButtonGroup = _ref => {
|
|
871
876
|
let {
|
|
877
|
+
label,
|
|
878
|
+
options = [{
|
|
879
|
+
value: 'single',
|
|
880
|
+
label: 'Single'
|
|
881
|
+
}, {
|
|
882
|
+
value: 'married',
|
|
883
|
+
label: 'Married'
|
|
884
|
+
}, {
|
|
885
|
+
value: 'divorced',
|
|
886
|
+
label: 'Divorced'
|
|
887
|
+
}, {
|
|
888
|
+
value: 'other',
|
|
889
|
+
label: 'Other'
|
|
890
|
+
}],
|
|
872
891
|
name,
|
|
873
|
-
value,
|
|
874
|
-
checked,
|
|
875
892
|
onChange,
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
893
|
+
className = '',
|
|
894
|
+
isValid = true,
|
|
895
|
+
errorMessage = `${label} is required`,
|
|
896
|
+
required = false
|
|
880
897
|
} = _ref;
|
|
881
|
-
|
|
882
|
-
const
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
898
|
+
const [selectedValue, setSelectedValue] = (0,external_react_.useState)('');
|
|
899
|
+
const handleChange = item => {
|
|
900
|
+
setSelectedValue(item.value);
|
|
901
|
+
const event = {
|
|
902
|
+
target: {
|
|
903
|
+
name: name,
|
|
904
|
+
value: item.value
|
|
905
|
+
}
|
|
906
|
+
};
|
|
907
|
+
if (onChange) {
|
|
908
|
+
onChange(event);
|
|
909
|
+
}
|
|
910
|
+
};
|
|
911
|
+
return /*#__PURE__*/external_react_default().createElement("div", {
|
|
912
|
+
className: "flex flex-col mb-4"
|
|
913
|
+
}, /*#__PURE__*/external_react_default().createElement("label", {
|
|
914
|
+
className: "text-greyLight700 mb-2 flex items-center"
|
|
915
|
+
}, label, required && /*#__PURE__*/external_react_default().createElement("span", {
|
|
916
|
+
className: "text-utilRed1000 ml-1"
|
|
917
|
+
}, "*")), /*#__PURE__*/external_react_default().createElement("div", {
|
|
918
|
+
className: "flex space-x-4"
|
|
919
|
+
}, options.map(option => /*#__PURE__*/external_react_default().createElement("label", {
|
|
920
|
+
key: option.value,
|
|
921
|
+
className: `cursor-pointer py-2 px-4 border rounded-lg ${selectedValue === option.value ? 'bg-greyBaseDark900 text-greyBaseLight border-greyBaseDark900' : `bg-white text-greyLight700 ${!isValid && selectedValue === '' ? 'border-utilRed1000' : 'border-greyLight500'}`} transition duration-200`
|
|
890
922
|
}, /*#__PURE__*/external_react_default().createElement("input", {
|
|
891
923
|
type: "radio",
|
|
892
924
|
name: name,
|
|
893
|
-
value: value,
|
|
894
|
-
checked:
|
|
895
|
-
onChange:
|
|
896
|
-
className:
|
|
897
|
-
}),
|
|
898
|
-
|
|
925
|
+
value: option.value,
|
|
926
|
+
checked: selectedValue === option.value,
|
|
927
|
+
onChange: () => handleChange(option),
|
|
928
|
+
className: "hidden"
|
|
929
|
+
}), option.label))), !isValid && /*#__PURE__*/external_react_default().createElement("span", {
|
|
930
|
+
className: "text-utilRed1000 text-sm mt-1"
|
|
931
|
+
}, errorMessage));
|
|
932
|
+
};
|
|
933
|
+
RadioButtonGroup.displayName = 'RadioButtonGroup';
|
|
934
|
+
/* harmony default export */ const RadioButton = (RadioButtonGroup);
|
|
899
935
|
;// ./src/components/Tables/Table.js
|
|
900
936
|
|
|
901
937
|
function Table() {
|
|
@@ -9112,7 +9148,7 @@ function Dropdown(_ref) {
|
|
|
9112
9148
|
const newSelectedItem = items.find(item => item.value === value) || null;
|
|
9113
9149
|
setSelectedItem(newSelectedItem);
|
|
9114
9150
|
}, [value, items]);
|
|
9115
|
-
const inputClasses = `inline-flex w-full justify-between items-center rounded-md bg-white text-md font-normal border p-2 text-greyLight700 ${isValid ? 'border-greyLight500' : 'border-
|
|
9151
|
+
const inputClasses = `inline-flex w-full justify-between items-center rounded-md bg-white text-md font-normal border p-2 text-greyLight700 ${isValid ? 'border-greyLight500' : 'border-utilRed1000'} ${className}`;
|
|
9116
9152
|
const handleSelect = item => {
|
|
9117
9153
|
setSelectedItem(item);
|
|
9118
9154
|
const event = {
|
|
@@ -9130,7 +9166,7 @@ function Dropdown(_ref) {
|
|
|
9130
9166
|
}, /*#__PURE__*/external_react_default().createElement("label", {
|
|
9131
9167
|
className: "flex items-center"
|
|
9132
9168
|
}, label, required && /*#__PURE__*/external_react_default().createElement("span", {
|
|
9133
|
-
className: "ml-1 text-
|
|
9169
|
+
className: "ml-1 text-utilRed1000"
|
|
9134
9170
|
}, "*"), " "), /*#__PURE__*/external_react_default().createElement("div", null, /*#__PURE__*/external_react_default().createElement(It, {
|
|
9135
9171
|
className: inputClasses,
|
|
9136
9172
|
onClick: () => setIsOpen(prev => !prev)
|
|
@@ -9159,7 +9195,7 @@ function Dropdown(_ref) {
|
|
|
9159
9195
|
className: `block w-full px-4 py-2 text-left text-sm text-greyLight700 ${active ? 'bg-greyLight100 text-greyLight700' : ''} hover:bg-greyLight100`
|
|
9160
9196
|
}, item.label);
|
|
9161
9197
|
})))), !isValid && /*#__PURE__*/external_react_default().createElement("span", {
|
|
9162
|
-
className: "text-
|
|
9198
|
+
className: "text-utilRed1000 text-sm"
|
|
9163
9199
|
}, errorMessage));
|
|
9164
9200
|
}
|
|
9165
9201
|
;// ./src/index.js
|
|
@@ -9175,4 +9211,4 @@ function Dropdown(_ref) {
|
|
|
9175
9211
|
/******/ })()
|
|
9176
9212
|
;
|
|
9177
9213
|
});
|
|
9178
|
-
//# sourceMappingURL=main.
|
|
9214
|
+
//# sourceMappingURL=main.80f90d68be593e9d6d31.js.map
|