@luscii-healthtech/web-ui 1.0.0 → 2.2.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.
- package/dist/components/Accordion/Accordion.d.ts +10 -0
- package/dist/components/Accordion/AccordionItem.d.ts +9 -0
- package/dist/components/Form/Form.d.ts +9 -0
- package/dist/components/Form/FormFieldDecorator.d.ts +8 -0
- package/dist/components/Form/FormInput.d.ts +3 -0
- package/dist/components/Form/FormRadioGroup.d.ts +3 -0
- package/dist/components/Form/FormSelect.d.ts +3 -0
- package/dist/components/Form/form.transformer.d.ts +20 -0
- package/dist/components/Form/form.types.d.ts +54 -0
- package/dist/components/Icons/types/IconProps.type.d.ts +2 -1
- package/dist/components/Input/Input.d.ts +8 -7
- package/dist/components/Input/SearchInput.d.ts +1 -1
- package/dist/components/Radio/Radio.d.ts +3 -0
- package/dist/components/Radio/RadioV2.d.ts +17 -0
- package/dist/components/RadioGroup/RadioGroup.d.ts +3 -0
- package/dist/components/RadioGroup/RadioGroupV2.d.ts +9 -0
- package/dist/components/Select/Select.d.ts +3 -0
- package/dist/components/Select/SelectV2.d.ts +31 -0
- package/dist/index.d.ts +2 -0
- package/dist/web-ui-tailwind.css +34 -0
- package/dist/web-ui.cjs.development.js +523 -20
- package/dist/web-ui.cjs.development.js.map +1 -1
- package/dist/web-ui.cjs.production.min.js +1 -1
- package/dist/web-ui.cjs.production.min.js.map +1 -1
- package/dist/web-ui.esm.js +523 -21
- package/dist/web-ui.esm.js.map +1 -1
- package/package.json +6 -3
- package/src/components/Accordion/Accordion.tsx +33 -0
- package/src/components/Accordion/AccordionItem.tsx +50 -0
- package/src/components/Checkbox/Checkbox.tsx +1 -0
- package/src/components/CheckboxList/CheckboxGroup.tsx +8 -2
- package/src/components/CheckboxList/CheckboxListItem.tsx +4 -1
- package/src/components/Form/Form.tsx +106 -0
- package/src/components/Form/FormFieldDecorator.tsx +66 -0
- package/src/components/Form/FormInput.tsx +47 -0
- package/src/components/Form/FormRadioGroup.tsx +23 -0
- package/src/components/Form/FormSelect.tsx +32 -0
- package/src/components/Form/form.transformer.ts +9 -0
- package/src/components/Form/form.types.ts +132 -0
- package/src/components/Icons/types/IconProps.type.ts +1 -1
- package/src/components/Input/Input.tsx +160 -165
- package/src/components/Input/SearchInput.tsx +13 -3
- package/src/components/Radio/Radio.js +3 -0
- package/src/components/Radio/RadioV2.css +15 -0
- package/src/components/Radio/RadioV2.tsx +87 -0
- package/src/components/RadioGroup/RadioGroup.js +3 -0
- package/src/components/RadioGroup/RadioGroupV2.tsx +35 -0
- package/src/components/Select/Select.tsx +38 -12
- package/src/components/Select/SelectV2.tsx +171 -0
- package/src/index.tsx +3 -0
- package/src/types/general.types.ts +1 -1
- package/src/components/Select/Select.examples.md +0 -161
|
@@ -26,6 +26,8 @@ var reactDraftWysiwyg = require('react-draft-wysiwyg');
|
|
|
26
26
|
var draftToHtml = _interopDefault(require('draftjs-to-html'));
|
|
27
27
|
var htmlToDraft = _interopDefault(require('html-to-draftjs'));
|
|
28
28
|
require('react-draft-wysiwyg/dist/react-draft-wysiwyg.css');
|
|
29
|
+
var reactHookForm = require('react-hook-form');
|
|
30
|
+
var errorMessage = require('@hookform/error-message');
|
|
29
31
|
|
|
30
32
|
function styleInject(css, ref) {
|
|
31
33
|
if ( ref === void 0 ) ref = {};
|
|
@@ -1002,6 +1004,7 @@ var Checkbox = function Checkbox(_ref) {
|
|
|
1002
1004
|
}, [indeterminate]);
|
|
1003
1005
|
|
|
1004
1006
|
var handleChange = function handleChange(event) {
|
|
1007
|
+
event.stopPropagation();
|
|
1005
1008
|
setIndeterminate(false);
|
|
1006
1009
|
|
|
1007
1010
|
if (onChange) {
|
|
@@ -1861,7 +1864,7 @@ var CrossIcon = function CrossIcon(props) {
|
|
|
1861
1864
|
var css_248z$c = ".input::-ms-clear {\n display: none;\n}";
|
|
1862
1865
|
styleInject(css_248z$c);
|
|
1863
1866
|
|
|
1864
|
-
var _excluded$6 = ["withSuffix", "withPrefix", "className", "clearable", "type", "isDisabled", "icon", "
|
|
1867
|
+
var _excluded$6 = ["withSuffix", "withPrefix", "className", "clearable", "type", "isDisabled", "icon", "name", "value", "onChange", "isError"];
|
|
1865
1868
|
// Don't know why yet but it can be fixed later.
|
|
1866
1869
|
|
|
1867
1870
|
var INPUT_TYPES = {
|
|
@@ -1870,8 +1873,7 @@ var INPUT_TYPES = {
|
|
|
1870
1873
|
PASSWORD: "password",
|
|
1871
1874
|
TEXT: "text"
|
|
1872
1875
|
};
|
|
1873
|
-
|
|
1874
|
-
var Input = function Input(_ref) {
|
|
1876
|
+
var Input = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
1875
1877
|
var _ref$withSuffix = _ref.withSuffix,
|
|
1876
1878
|
withSuffix = _ref$withSuffix === void 0 ? "" : _ref$withSuffix,
|
|
1877
1879
|
_ref$withPrefix = _ref.withPrefix,
|
|
@@ -1884,10 +1886,11 @@ var Input = function Input(_ref) {
|
|
|
1884
1886
|
_ref$isDisabled = _ref.isDisabled,
|
|
1885
1887
|
isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
|
|
1886
1888
|
icon = _ref.icon,
|
|
1887
|
-
setRef = _ref.setRef,
|
|
1888
1889
|
name = _ref.name,
|
|
1889
|
-
value = _ref.value,
|
|
1890
|
+
_ref$value = _ref.value,
|
|
1891
|
+
value = _ref$value === void 0 ? "" : _ref$value,
|
|
1890
1892
|
onChange = _ref.onChange,
|
|
1893
|
+
isError = _ref.isError,
|
|
1891
1894
|
otherProps = _objectWithoutPropertiesLoose(_ref, _excluded$6);
|
|
1892
1895
|
|
|
1893
1896
|
var hasNoExtraContent = withPrefix === "" && withSuffix === "";
|
|
@@ -1896,7 +1899,6 @@ var Input = function Input(_ref) {
|
|
|
1896
1899
|
innerValue = _useState[0],
|
|
1897
1900
|
setInnerValue = _useState[1];
|
|
1898
1901
|
|
|
1899
|
-
var inputRef = React.useRef(null);
|
|
1900
1902
|
React.useEffect(function () {
|
|
1901
1903
|
setInnerValue(value);
|
|
1902
1904
|
}, [value]);
|
|
@@ -1938,13 +1940,13 @@ var Input = function Input(_ref) {
|
|
|
1938
1940
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
1939
1941
|
className: "flex flex-row"
|
|
1940
1942
|
}, /*#__PURE__*/React__default.createElement("span", {
|
|
1941
|
-
className: classNames("h-11", {
|
|
1943
|
+
className: classNames("h-11 border-t border-b border-solid border-input-border", {
|
|
1942
1944
|
hidden: hasNoExtraContent,
|
|
1943
1945
|
"order-1": withPrefix !== "",
|
|
1944
1946
|
"order-2": withSuffix !== "",
|
|
1945
1947
|
"rounded-l border-l": withPrefix !== "",
|
|
1946
1948
|
"rounded-r border-r": withSuffix !== ""
|
|
1947
|
-
}, "
|
|
1949
|
+
}, "flex flex-col items-center p-3", "text-sm", "text-slate-500", "bg-main-background")
|
|
1948
1950
|
}, withSuffix || withPrefix), icon && /*#__PURE__*/React__default.createElement("div", {
|
|
1949
1951
|
className: "absolute top-1/2 left-4",
|
|
1950
1952
|
style: {
|
|
@@ -1957,10 +1959,7 @@ var Input = function Input(_ref) {
|
|
|
1957
1959
|
name: name,
|
|
1958
1960
|
value: innerValue,
|
|
1959
1961
|
onChange: handleChangeEvent,
|
|
1960
|
-
ref:
|
|
1961
|
-
inputRef.current = element;
|
|
1962
|
-
element && (setRef == null ? void 0 : setRef(element));
|
|
1963
|
-
},
|
|
1962
|
+
ref: ref,
|
|
1964
1963
|
size: otherProps.maxLength,
|
|
1965
1964
|
type: type,
|
|
1966
1965
|
disabled: isDisabled,
|
|
@@ -1970,10 +1969,14 @@ var Input = function Input(_ref) {
|
|
|
1970
1969
|
}, {
|
|
1971
1970
|
"text-slate-400 bg-slate-50": isDisabled,
|
|
1972
1971
|
"text-slate-700": !isDisabled,
|
|
1973
|
-
"border-input-border": !isDisabled,
|
|
1972
|
+
"border-input-border": !isDisabled && !isError,
|
|
1974
1973
|
"hover:border-input-border-dark": !isDisabled,
|
|
1974
|
+
"border-red-700": isError,
|
|
1975
|
+
"focus:outline-negative": isError,
|
|
1976
|
+
"focus:border-blue-800": !isError,
|
|
1977
|
+
"focus:outline-primary": !isError,
|
|
1975
1978
|
"bg-white": !isDisabled
|
|
1976
|
-
}, "h-11", "p-2", "border", "text-sm", "placeholder-slate-500", "border-solid", "
|
|
1979
|
+
}, "h-11", "p-2", "border", "text-sm", "placeholder-slate-500", "border-solid", "transition-colors", "duration-300", {
|
|
1977
1980
|
"z-10": withSuffix !== "" || withPrefix !== "",
|
|
1978
1981
|
rounded: hasNoExtraContent,
|
|
1979
1982
|
"rounded-l": withSuffix !== "",
|
|
@@ -1993,7 +1996,7 @@ var Input = function Input(_ref) {
|
|
|
1993
1996
|
}),
|
|
1994
1997
|
onClick: clearField
|
|
1995
1998
|
}))));
|
|
1996
|
-
};
|
|
1999
|
+
});
|
|
1997
2000
|
|
|
1998
2001
|
var Line = function Line(_ref) {
|
|
1999
2002
|
var left = _ref.left,
|
|
@@ -2337,6 +2340,10 @@ function generateCustomStyles(hasError, isIE11) {
|
|
|
2337
2340
|
}
|
|
2338
2341
|
};
|
|
2339
2342
|
}
|
|
2343
|
+
/**
|
|
2344
|
+
* @deprecated: use SelectV2 instead
|
|
2345
|
+
*/
|
|
2346
|
+
|
|
2340
2347
|
|
|
2341
2348
|
var CustomSelect = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
2342
2349
|
var className = props.className,
|
|
@@ -2827,7 +2834,9 @@ var CheckboxListItem = function CheckboxListItem(_ref) {
|
|
|
2827
2834
|
setChecked(isChecked || false);
|
|
2828
2835
|
}, [isChecked]);
|
|
2829
2836
|
|
|
2830
|
-
var handleItemClick = function handleItemClick() {
|
|
2837
|
+
var handleItemClick = function handleItemClick(event) {
|
|
2838
|
+
event.stopPropagation();
|
|
2839
|
+
|
|
2831
2840
|
if (onChange) {
|
|
2832
2841
|
onChange({
|
|
2833
2842
|
id: id,
|
|
@@ -2839,6 +2848,7 @@ var CheckboxListItem = function CheckboxListItem(_ref) {
|
|
|
2839
2848
|
};
|
|
2840
2849
|
|
|
2841
2850
|
var handleCheckboxClick = function handleCheckboxClick(event) {
|
|
2851
|
+
event.stopPropagation();
|
|
2842
2852
|
var targetId = event.target.id;
|
|
2843
2853
|
var newCheckedValue = event.target.checked;
|
|
2844
2854
|
|
|
@@ -2936,7 +2946,9 @@ var CheckboxGroup = function CheckboxGroup(_ref) {
|
|
|
2936
2946
|
}
|
|
2937
2947
|
}, [items]);
|
|
2938
2948
|
|
|
2939
|
-
var handleGroupClick = function handleGroupClick() {
|
|
2949
|
+
var handleGroupClick = function handleGroupClick(event) {
|
|
2950
|
+
event.stopPropagation();
|
|
2951
|
+
|
|
2940
2952
|
if ((groupCheckboxState === CheckboxState.CHECKED || groupCheckboxState === CheckboxState.INDETERMINATE) && onChange) {
|
|
2941
2953
|
//if checked or indeterminate >> make all items unchecked
|
|
2942
2954
|
items.forEach(function (item) {
|
|
@@ -2956,7 +2968,11 @@ var CheckboxGroup = function CheckboxGroup(_ref) {
|
|
|
2956
2968
|
}
|
|
2957
2969
|
};
|
|
2958
2970
|
|
|
2959
|
-
var handleGroupCollapse = function handleGroupCollapse() {
|
|
2971
|
+
var handleGroupCollapse = function handleGroupCollapse(event) {
|
|
2972
|
+
if (event) {
|
|
2973
|
+
event.stopPropagation();
|
|
2974
|
+
}
|
|
2975
|
+
|
|
2960
2976
|
setCollapsed(!collapsed);
|
|
2961
2977
|
};
|
|
2962
2978
|
|
|
@@ -3809,6 +3825,10 @@ var PreviewPhone = function PreviewPhone(_ref) {
|
|
|
3809
3825
|
var css_248z$j = ".cweb-radio {\n outline: none;\n}\n\n.cweb-radio .cweb-radio-input {\n -webkit-appearance: none;\n height: 1px;\n opacity: 0;\n width: 1px;\n}\n\n.cweb-radio .cweb-radio-label-text {\n margin-left: 8px;\n -ms-user-select: none;\n user-select: none;\n text-align: left;\n}\n\n.cweb-radio .cweb-radio-label {\n display: flex;\n align-items: center;\n margin-bottom: 0;\n}\n\n.cweb-radio .cweb-radio-icon-container {\n width: 16px;\n height: 16px;\n position: relative;\n border: 1px solid #cccccc;\n border-radius: 50%;\n transition: background-color 0.3s ease-in-out;\n}\n\n.cweb-radio .cweb-radio-icon {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n display: block;\n}\n\n.cweb-radio.is-focused .cweb-radio-icon-container {\n border-color: #0074dd;\n}\n\n.cweb-radio.is-checked .cweb-radio-icon {\n width: 5px;\n height: 5px;\n background-color: #ffffff;\n border-radius: 50%;\n}\n";
|
|
3810
3826
|
styleInject(css_248z$j);
|
|
3811
3827
|
|
|
3828
|
+
/**
|
|
3829
|
+
* @deprecated: use RadioV2 instead
|
|
3830
|
+
*/
|
|
3831
|
+
|
|
3812
3832
|
var Radio = /*#__PURE__*/function (_PureComponent) {
|
|
3813
3833
|
_inheritsLoose(Radio, _PureComponent);
|
|
3814
3834
|
|
|
@@ -3909,6 +3929,9 @@ var css_248z$k = ".cweb-radio-group {\n display: flex;\n justify-content: flex
|
|
|
3909
3929
|
styleInject(css_248z$k);
|
|
3910
3930
|
|
|
3911
3931
|
var _excluded$b = ["className", "radioClassName", "name", "selectedOption", "isVertical", "radioOptions", "onChange", "error", "isDisabled"];
|
|
3932
|
+
/**
|
|
3933
|
+
* @deprecated: use RadioV2 instead
|
|
3934
|
+
*/
|
|
3912
3935
|
|
|
3913
3936
|
function RadioGroup(_ref) {
|
|
3914
3937
|
var className = _ref.className,
|
|
@@ -4773,14 +4796,493 @@ var SearchIcon = function SearchIcon(props) {
|
|
|
4773
4796
|
}));
|
|
4774
4797
|
};
|
|
4775
4798
|
|
|
4776
|
-
var SearchInput = function
|
|
4799
|
+
var SearchInput = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
4777
4800
|
return /*#__PURE__*/React__default.createElement(Input, Object.assign({}, props, {
|
|
4778
4801
|
icon: SearchIcon,
|
|
4779
4802
|
type: "text",
|
|
4780
|
-
clearable: true
|
|
4803
|
+
clearable: true,
|
|
4804
|
+
ref: ref
|
|
4781
4805
|
}));
|
|
4806
|
+
});
|
|
4807
|
+
|
|
4808
|
+
/**
|
|
4809
|
+
* Decorator for any input component. Adds a label and additional information to be shown.
|
|
4810
|
+
*
|
|
4811
|
+
* Includes the default error handling from react-hook-form.
|
|
4812
|
+
*/
|
|
4813
|
+
|
|
4814
|
+
function FormFieldDecorator(_ref) {
|
|
4815
|
+
var name = _ref.name,
|
|
4816
|
+
children = _ref.children,
|
|
4817
|
+
label = _ref.label,
|
|
4818
|
+
fieldRequired = _ref.fieldRequired,
|
|
4819
|
+
info = _ref.info,
|
|
4820
|
+
fieldErrors = _ref.fieldErrors,
|
|
4821
|
+
decoratorClassname = _ref.decoratorClassname;
|
|
4822
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
4823
|
+
className: classNames(decoratorClassname)
|
|
4824
|
+
}, label && /*#__PURE__*/React__default.createElement("label", {
|
|
4825
|
+
className: "cweb-form-field-label block mb-1",
|
|
4826
|
+
htmlFor: name,
|
|
4827
|
+
"data-is-required": fieldRequired
|
|
4828
|
+
}, /*#__PURE__*/React__default.createElement(Text, {
|
|
4829
|
+
className: "cweb-form-field-label-text",
|
|
4830
|
+
inline: true,
|
|
4831
|
+
text: label
|
|
4832
|
+
})), /*#__PURE__*/React__default.createElement("fieldset", {
|
|
4833
|
+
className: "cweb-form-fieldset"
|
|
4834
|
+
}, children), info && /*#__PURE__*/React__default.createElement(Text, {
|
|
4835
|
+
className: "mt-1 cweb-form-info-text",
|
|
4836
|
+
type: "sm",
|
|
4837
|
+
color: "slate-500",
|
|
4838
|
+
text: info
|
|
4839
|
+
}), /*#__PURE__*/React__default.createElement(errorMessage.ErrorMessage, {
|
|
4840
|
+
errors: fieldErrors,
|
|
4841
|
+
name: name,
|
|
4842
|
+
render: function render(_ref2) {
|
|
4843
|
+
var messages = _ref2.messages;
|
|
4844
|
+
return messages && Object.entries(messages).map(function (_ref3) {
|
|
4845
|
+
var key = _ref3[0],
|
|
4846
|
+
message = _ref3[1];
|
|
4847
|
+
return /*#__PURE__*/React__default.createElement(Text, {
|
|
4848
|
+
key: key,
|
|
4849
|
+
className: "mt-1",
|
|
4850
|
+
text: message,
|
|
4851
|
+
color: "red"
|
|
4852
|
+
});
|
|
4853
|
+
});
|
|
4854
|
+
}
|
|
4855
|
+
}));
|
|
4856
|
+
}
|
|
4857
|
+
|
|
4858
|
+
var hasError = function hasError(name, errors) {
|
|
4859
|
+
return !!(name && errors && name in errors);
|
|
4860
|
+
};
|
|
4861
|
+
var isRequired = function isRequired(options) {
|
|
4862
|
+
return !!(options && "required" in options);
|
|
4782
4863
|
};
|
|
4783
4864
|
|
|
4865
|
+
var _excluded$h = ["name", "fieldErrors", "fieldRequired", "label", "info", "decoratorClassname"];
|
|
4866
|
+
/**
|
|
4867
|
+
* Input field that can be used in any react-hook-form context.
|
|
4868
|
+
*/
|
|
4869
|
+
|
|
4870
|
+
var FormInputInner = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
4871
|
+
var name = _ref.name,
|
|
4872
|
+
fieldErrors = _ref.fieldErrors,
|
|
4873
|
+
fieldRequired = _ref.fieldRequired,
|
|
4874
|
+
label = _ref.label,
|
|
4875
|
+
info = _ref.info,
|
|
4876
|
+
decoratorClassname = _ref.decoratorClassname,
|
|
4877
|
+
fieldProps = _objectWithoutPropertiesLoose(_ref, _excluded$h);
|
|
4878
|
+
|
|
4879
|
+
return /*#__PURE__*/React__default.createElement(FormFieldDecorator, {
|
|
4880
|
+
name: name,
|
|
4881
|
+
fieldErrors: fieldErrors,
|
|
4882
|
+
fieldRequired: fieldRequired,
|
|
4883
|
+
label: label,
|
|
4884
|
+
info: info,
|
|
4885
|
+
decoratorClassname: decoratorClassname
|
|
4886
|
+
}, /*#__PURE__*/React__default.createElement(Input, Object.assign({}, fieldProps, {
|
|
4887
|
+
isError: hasError(name, fieldErrors),
|
|
4888
|
+
ref: ref,
|
|
4889
|
+
name: name
|
|
4890
|
+
})));
|
|
4891
|
+
});
|
|
4892
|
+
var FormInput = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
4893
|
+
return /*#__PURE__*/React__default.createElement(FormInputInner, Object.assign({}, props, {
|
|
4894
|
+
ref: ref
|
|
4895
|
+
}));
|
|
4896
|
+
});
|
|
4897
|
+
|
|
4898
|
+
var css_248z$r = ".radio-form-field-label input[type=\"radio\"]:checked + .radio-circle {\n --bg-opacity: 1;\n background-color: #0074DD;\n background-color: rgba(0, 116, 221, var(--bg-opacity));\n}\n\n.radio-form-field-label[data-has-error=\"true\"] .radio-circle {\n --border-opacity: 1;\n border-color: #c53030;\n border-color: rgba(197, 48, 48, var(--border-opacity));\n outline: 4px solid rgba(255, 98, 102, 0.3);\n outline-offset: 0;\n}\n\n.radio-form-field-label\n input[type=\"radio\"]:checked\n + .radio-circle\n .radio-inner-circle {\n --bg-opacity: 1;\n background-color: #fff;\n background-color: rgba(255, 255, 255, var(--bg-opacity));\n}\n";
|
|
4899
|
+
styleInject(css_248z$r);
|
|
4900
|
+
|
|
4901
|
+
var _excluded$i = ["text", "info", "isError", "innerRef", "className"];
|
|
4902
|
+
|
|
4903
|
+
function RadioInner(_ref) {
|
|
4904
|
+
var text = _ref.text,
|
|
4905
|
+
info = _ref.info,
|
|
4906
|
+
isError = _ref.isError,
|
|
4907
|
+
innerRef = _ref.innerRef,
|
|
4908
|
+
className = _ref.className,
|
|
4909
|
+
otherProps = _objectWithoutPropertiesLoose(_ref, _excluded$i);
|
|
4910
|
+
|
|
4911
|
+
var value = otherProps.value,
|
|
4912
|
+
disabled = otherProps.disabled;
|
|
4913
|
+
var nameHtmlFor = "field-" + value;
|
|
4914
|
+
return /*#__PURE__*/React__default.createElement("label", {
|
|
4915
|
+
className: "radio-form-field-label leading-tight",
|
|
4916
|
+
htmlFor: nameHtmlFor,
|
|
4917
|
+
"data-has-error": isError,
|
|
4918
|
+
"data-test-id": nameHtmlFor
|
|
4919
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
4920
|
+
className: "flex flex-row items-center "
|
|
4921
|
+
}, /*#__PURE__*/React__default.createElement("input", Object.assign({}, otherProps, {
|
|
4922
|
+
className: classNames("appearance-none", className),
|
|
4923
|
+
ref: innerRef,
|
|
4924
|
+
type: "radio",
|
|
4925
|
+
id: nameHtmlFor,
|
|
4926
|
+
disabled: disabled
|
|
4927
|
+
})), /*#__PURE__*/React__default.createElement("span", {
|
|
4928
|
+
className: classNames("flex flex-col items-center justify-center w-4 h-4 transition-colors duration-300 ease-in-out border radio-circle rounded-xl border-slate-300")
|
|
4929
|
+
}, /*#__PURE__*/React__default.createElement("span", {
|
|
4930
|
+
className: "block transition-colors duration-300 ease-in-out radio-inner-circle w-1.5 h-1.5 rounded-xl"
|
|
4931
|
+
})), text && /*#__PURE__*/React__default.createElement("div", {
|
|
4932
|
+
className: "ml-2"
|
|
4933
|
+
}, /*#__PURE__*/React__default.createElement(Text, {
|
|
4934
|
+
inline: true,
|
|
4935
|
+
text: text,
|
|
4936
|
+
type: "base",
|
|
4937
|
+
color: disabled ? "slate-500" : undefined
|
|
4938
|
+
}))), info && /*#__PURE__*/React__default.createElement(Text, {
|
|
4939
|
+
inline: true,
|
|
4940
|
+
className: "ml-6",
|
|
4941
|
+
text: info,
|
|
4942
|
+
type: "sm",
|
|
4943
|
+
color: disabled ? "slate-200" : "slate-500"
|
|
4944
|
+
}));
|
|
4945
|
+
}
|
|
4946
|
+
/**
|
|
4947
|
+
* TODO: The CSS styling is all messed up, including isError
|
|
4948
|
+
* Warning: don't use this prop before this is resolved
|
|
4949
|
+
* Issue to track: https://github.com/Luscii/web-ui/issues/57
|
|
4950
|
+
* TODO: remove this comment once this is resolved
|
|
4951
|
+
*/
|
|
4952
|
+
|
|
4953
|
+
|
|
4954
|
+
var RadioV2 = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
4955
|
+
return /*#__PURE__*/React__default.createElement(RadioInner, Object.assign({}, props, {
|
|
4956
|
+
innerRef: ref
|
|
4957
|
+
}));
|
|
4958
|
+
});
|
|
4959
|
+
|
|
4960
|
+
var _excluded$j = ["innerRef", "options"];
|
|
4961
|
+
|
|
4962
|
+
function RadioGroupInner(_ref) {
|
|
4963
|
+
var innerRef = _ref.innerRef,
|
|
4964
|
+
options = _ref.options,
|
|
4965
|
+
registerProps = _objectWithoutPropertiesLoose(_ref, _excluded$j);
|
|
4966
|
+
|
|
4967
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
4968
|
+
className: classNames("flex flex-col space-y-2")
|
|
4969
|
+
}, options.map(function (option) {
|
|
4970
|
+
return /*#__PURE__*/React__default.createElement(RadioV2, Object.assign({
|
|
4971
|
+
key: option.value
|
|
4972
|
+
}, option, registerProps, {
|
|
4973
|
+
ref: innerRef
|
|
4974
|
+
}));
|
|
4975
|
+
}));
|
|
4976
|
+
}
|
|
4977
|
+
|
|
4978
|
+
var RadioGroupV2 = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
4979
|
+
return /*#__PURE__*/React__default.createElement(RadioGroupInner, Object.assign({}, props, {
|
|
4980
|
+
innerRef: ref
|
|
4981
|
+
}));
|
|
4982
|
+
});
|
|
4983
|
+
|
|
4984
|
+
var _excluded$k = ["innerRef", "name", "fieldErrors", "fieldRequired", "label", "info", "decoratorClassname"];
|
|
4985
|
+
/**
|
|
4986
|
+
* Input field that can be used in any react-hook-form context.
|
|
4987
|
+
*/
|
|
4988
|
+
|
|
4989
|
+
function FormRadioGroupInner(_ref) {
|
|
4990
|
+
var innerRef = _ref.innerRef,
|
|
4991
|
+
name = _ref.name,
|
|
4992
|
+
fieldErrors = _ref.fieldErrors,
|
|
4993
|
+
fieldRequired = _ref.fieldRequired,
|
|
4994
|
+
label = _ref.label,
|
|
4995
|
+
info = _ref.info,
|
|
4996
|
+
decoratorClassname = _ref.decoratorClassname,
|
|
4997
|
+
fieldProps = _objectWithoutPropertiesLoose(_ref, _excluded$k);
|
|
4998
|
+
|
|
4999
|
+
return /*#__PURE__*/React__default.createElement(FormFieldDecorator, {
|
|
5000
|
+
name: name,
|
|
5001
|
+
fieldErrors: fieldErrors,
|
|
5002
|
+
fieldRequired: fieldRequired,
|
|
5003
|
+
label: label,
|
|
5004
|
+
info: info,
|
|
5005
|
+
decoratorClassname: decoratorClassname
|
|
5006
|
+
}, /*#__PURE__*/React__default.createElement(RadioGroupV2, Object.assign({}, fieldProps, {
|
|
5007
|
+
isError: hasError(name, fieldErrors),
|
|
5008
|
+
ref: innerRef,
|
|
5009
|
+
name: name
|
|
5010
|
+
})));
|
|
5011
|
+
}
|
|
5012
|
+
|
|
5013
|
+
var FormRadioGroup = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
5014
|
+
return /*#__PURE__*/React__default.createElement(FormRadioGroupInner, Object.assign({}, props, {
|
|
5015
|
+
innerRef: ref
|
|
5016
|
+
}));
|
|
5017
|
+
});
|
|
5018
|
+
|
|
5019
|
+
var _excluded$l = ["isError", "styles", "options", "onChange", "value", "isMulti", "className"];
|
|
5020
|
+
|
|
5021
|
+
function generateCustomStyles$1(hasError, isIE11) {
|
|
5022
|
+
return {
|
|
5023
|
+
option: function option(baseStyles, state) {
|
|
5024
|
+
return _extends({}, baseStyles, {
|
|
5025
|
+
fontWeight: state.isSelected ? "bold" : "normal",
|
|
5026
|
+
fontSize: "14px",
|
|
5027
|
+
backgroundColor: "none",
|
|
5028
|
+
color: "inherit",
|
|
5029
|
+
position: "relative",
|
|
5030
|
+
padding: "0.75rem",
|
|
5031
|
+
opacity: state.isDisabled ? "0.5" : 1,
|
|
5032
|
+
"&:after": {
|
|
5033
|
+
visibility: state.isSelected ? "visible" : "hidden"
|
|
5034
|
+
},
|
|
5035
|
+
transition: "background-color 0.3s ease-in-out",
|
|
5036
|
+
"&:hover": {
|
|
5037
|
+
// tailwind blue-50
|
|
5038
|
+
backgroundColor: state.isSelected ? "transparent" : "#F2FAFD"
|
|
5039
|
+
},
|
|
5040
|
+
pointerEvents: state.isDisabled ? "none" : "auto"
|
|
5041
|
+
});
|
|
5042
|
+
},
|
|
5043
|
+
container: function container(baseStyles) {
|
|
5044
|
+
return _extends({}, baseStyles, {
|
|
5045
|
+
flexGrow: isIE11 ? 0.5 : "initial"
|
|
5046
|
+
});
|
|
5047
|
+
},
|
|
5048
|
+
control: function control(baseStyles, state) {
|
|
5049
|
+
var defaultBorderColor = state.isFocused ? "#045baa" : "#D1D5DB";
|
|
5050
|
+
var validatedBorderColor = hasError ? "#c53030" : defaultBorderColor;
|
|
5051
|
+
var defaultOutline = hasError ? "rgba(255, 98, 102, 0.3)" : "rgba(0, 159, 227, 0.3)";
|
|
5052
|
+
var validatedOutline = "4px solid " + (state.isFocused ? defaultOutline : "transparent");
|
|
5053
|
+
return _extends({}, baseStyles, {
|
|
5054
|
+
fontSize: "14px",
|
|
5055
|
+
transition: "border 0.3s ease-in-out",
|
|
5056
|
+
height: isIE11 ? "50px" : "2.75rem",
|
|
5057
|
+
// primary outline
|
|
5058
|
+
outline: validatedOutline,
|
|
5059
|
+
borderColor: validatedBorderColor,
|
|
5060
|
+
borderWidth: "1px !important",
|
|
5061
|
+
borderStyle: "solid",
|
|
5062
|
+
borderRadius: "4px",
|
|
5063
|
+
boxShadow: "0px 1px 2px rgba(0, 0, 0, 0.05)",
|
|
5064
|
+
"&:hover": {
|
|
5065
|
+
borderColor: "#9CA3AF",
|
|
5066
|
+
// selector for the chevron
|
|
5067
|
+
"> [class*=\"IndicatorsContainer\"]": {
|
|
5068
|
+
opacity: 1
|
|
5069
|
+
}
|
|
5070
|
+
}
|
|
5071
|
+
});
|
|
5072
|
+
},
|
|
5073
|
+
// The placeholder has the following css prop: grid-area: 1/1/2/3;
|
|
5074
|
+
// And grid-area doesn't work on IE11, so we need to style it slightly different.
|
|
5075
|
+
placeholder: function placeholder(baseStyles) {
|
|
5076
|
+
return _extends({}, baseStyles, {
|
|
5077
|
+
fontWeight: 100,
|
|
5078
|
+
color: "#6B7280",
|
|
5079
|
+
paddingTop: isIE11 ? "1.2rem" : undefined
|
|
5080
|
+
});
|
|
5081
|
+
},
|
|
5082
|
+
singleValue: function singleValue(baseStyles) {
|
|
5083
|
+
return _extends({}, baseStyles, {
|
|
5084
|
+
paddingTop: isIE11 ? "1.2rem" : undefined,
|
|
5085
|
+
fontSize: "14px"
|
|
5086
|
+
});
|
|
5087
|
+
},
|
|
5088
|
+
indicatorSeparator: function indicatorSeparator() {
|
|
5089
|
+
return {
|
|
5090
|
+
display: "none"
|
|
5091
|
+
};
|
|
5092
|
+
},
|
|
5093
|
+
menu: function menu(baseStyles) {
|
|
5094
|
+
return _extends({}, baseStyles, {
|
|
5095
|
+
zIndex: 20
|
|
5096
|
+
});
|
|
5097
|
+
}
|
|
5098
|
+
};
|
|
5099
|
+
}
|
|
5100
|
+
/**
|
|
5101
|
+
* A wrapper around react-select to style it according to our design specification.
|
|
5102
|
+
*
|
|
5103
|
+
* In addition, the value is taken out of the option, instead of returning the complete option.
|
|
5104
|
+
*
|
|
5105
|
+
* Care when using grouped options: the value of the options overspanning all groups need to be unique!
|
|
5106
|
+
* For instance, if you have an option with value "chocolate" in both the groups "flavor" and "dip", then you get unforeseen errors.
|
|
5107
|
+
* This is a problem within react-select itself, not our wrapper.
|
|
5108
|
+
*
|
|
5109
|
+
* Care when using defaultValue: this still requires the complete Option (instead of the value of the Option).
|
|
5110
|
+
* So far there wasn't a use-case for this.
|
|
5111
|
+
*/
|
|
5112
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5113
|
+
|
|
5114
|
+
|
|
5115
|
+
var Select = /*#__PURE__*/React__default.forwardRef(function (_ref, innerRef) {
|
|
5116
|
+
var _ref$isError = _ref.isError,
|
|
5117
|
+
isError = _ref$isError === void 0 ? false : _ref$isError,
|
|
5118
|
+
styles = _ref.styles,
|
|
5119
|
+
options = _ref.options,
|
|
5120
|
+
onChange = _ref.onChange,
|
|
5121
|
+
value = _ref.value,
|
|
5122
|
+
isMulti = _ref.isMulti,
|
|
5123
|
+
className = _ref.className,
|
|
5124
|
+
otherProps = _objectWithoutPropertiesLoose(_ref, _excluded$l);
|
|
5125
|
+
|
|
5126
|
+
var isIE11 = "MSInputMethodContext" in window && "documentMode" in document;
|
|
5127
|
+
var customStyles = generateCustomStyles$1(isError, isIE11);
|
|
5128
|
+
var mergedStyles = ReactSelect.mergeStyles(customStyles, styles); // the options can be either a list of options or a grouped list of options
|
|
5129
|
+
// this is a typechecker to verify it is the case.
|
|
5130
|
+
|
|
5131
|
+
var isOptionsGrouped = !options ? false : options.reduce(function (acc, o) {
|
|
5132
|
+
return acc || "options" in o && !("values" in o);
|
|
5133
|
+
}, false); // we subsequently flatmap to ensure it's always a list of options
|
|
5134
|
+
|
|
5135
|
+
var flatmappedOptions = !options ? [] : isOptionsGrouped ? options.flatMap(function (g) {
|
|
5136
|
+
return g.options;
|
|
5137
|
+
}) : options; // based on: https://stackoverflow.com/a/70022957
|
|
5138
|
+
|
|
5139
|
+
var onChangeWrapped = !onChange ? undefined : isMulti ? function (val, a) {
|
|
5140
|
+
return onChange(val.map(function (v) {
|
|
5141
|
+
return v.value;
|
|
5142
|
+
}), a);
|
|
5143
|
+
} : function (val, a) {
|
|
5144
|
+
return onChange(val == null ? void 0 : val.value, a);
|
|
5145
|
+
}; // TODO: how can we report the error if a value was given that is not within the options?
|
|
5146
|
+
|
|
5147
|
+
var valueWrapped = !value || !options ? value : isMulti ? flatmappedOptions.filter(function (o) {
|
|
5148
|
+
return value.includes(o.value);
|
|
5149
|
+
}) : flatmappedOptions.find(function (o) {
|
|
5150
|
+
return o.value === value;
|
|
5151
|
+
});
|
|
5152
|
+
return /*#__PURE__*/React__default.createElement(ReactSelect__default, Object.assign({}, otherProps, {
|
|
5153
|
+
ref: innerRef,
|
|
5154
|
+
styles: mergedStyles,
|
|
5155
|
+
options: options,
|
|
5156
|
+
onChange: onChangeWrapped,
|
|
5157
|
+
value: valueWrapped,
|
|
5158
|
+
isMulti: isMulti,
|
|
5159
|
+
className: classNames("customized-select", className)
|
|
5160
|
+
}));
|
|
5161
|
+
});
|
|
5162
|
+
|
|
5163
|
+
var _excluded$m = ["control", "name", "rules", "fieldErrors", "fieldRequired", "label", "info", "decoratorClassname"];
|
|
5164
|
+
|
|
5165
|
+
var FormSelect = /*#__PURE__*/React__default.forwardRef(function (_ref, innerRef) {
|
|
5166
|
+
var control = _ref.control,
|
|
5167
|
+
name = _ref.name,
|
|
5168
|
+
rules = _ref.rules,
|
|
5169
|
+
fieldErrors = _ref.fieldErrors,
|
|
5170
|
+
fieldRequired = _ref.fieldRequired,
|
|
5171
|
+
label = _ref.label,
|
|
5172
|
+
info = _ref.info,
|
|
5173
|
+
decoratorClassname = _ref.decoratorClassname,
|
|
5174
|
+
selectProps = _objectWithoutPropertiesLoose(_ref, _excluded$m);
|
|
5175
|
+
|
|
5176
|
+
return /*#__PURE__*/React__default.createElement(FormFieldDecorator, {
|
|
5177
|
+
name: name,
|
|
5178
|
+
fieldErrors: fieldErrors,
|
|
5179
|
+
fieldRequired: fieldRequired,
|
|
5180
|
+
label: label,
|
|
5181
|
+
info: info,
|
|
5182
|
+
decoratorClassname: decoratorClassname
|
|
5183
|
+
}, /*#__PURE__*/React__default.createElement(reactHookForm.Controller, {
|
|
5184
|
+
name: name,
|
|
5185
|
+
control: control,
|
|
5186
|
+
rules: rules,
|
|
5187
|
+
render: function render(_ref2) {
|
|
5188
|
+
var field = _ref2.field;
|
|
5189
|
+
return /*#__PURE__*/React__default.createElement(Select, Object.assign({}, selectProps, field, {
|
|
5190
|
+
isError: hasError(name, fieldErrors),
|
|
5191
|
+
ref: innerRef
|
|
5192
|
+
}));
|
|
5193
|
+
}
|
|
5194
|
+
}));
|
|
5195
|
+
});
|
|
5196
|
+
|
|
5197
|
+
var _excluded$n = ["type", "name", "options", "fieldProps"];
|
|
5198
|
+
/**
|
|
5199
|
+
* Create a straight forward Form.
|
|
5200
|
+
*
|
|
5201
|
+
* TODO: wrap this in some Page component to style the div and buttons
|
|
5202
|
+
* WARNING: don't use this component before some styling errors are resolved.
|
|
5203
|
+
*/
|
|
5204
|
+
|
|
5205
|
+
function Form(_ref) {
|
|
5206
|
+
var fields = _ref.fields,
|
|
5207
|
+
onValid = _ref.onValid,
|
|
5208
|
+
onError = _ref.onError,
|
|
5209
|
+
defaultValues = _ref.defaultValues;
|
|
5210
|
+
|
|
5211
|
+
var _useForm = reactHookForm.useForm({
|
|
5212
|
+
criteriaMode: "all",
|
|
5213
|
+
defaultValues: defaultValues
|
|
5214
|
+
}),
|
|
5215
|
+
register = _useForm.register,
|
|
5216
|
+
handleSubmit = _useForm.handleSubmit,
|
|
5217
|
+
control = _useForm.control,
|
|
5218
|
+
errors = _useForm.formState.errors;
|
|
5219
|
+
|
|
5220
|
+
var fieldMapper = function fieldMapper(_ref2) {
|
|
5221
|
+
var type = _ref2.type,
|
|
5222
|
+
name = _ref2.name,
|
|
5223
|
+
options = _ref2.options,
|
|
5224
|
+
_ref2$fieldProps = _ref2.fieldProps,
|
|
5225
|
+
fieldProps = _ref2$fieldProps === void 0 ? {} : _ref2$fieldProps,
|
|
5226
|
+
decoratorProps = _objectWithoutPropertiesLoose(_ref2, _excluded$n);
|
|
5227
|
+
|
|
5228
|
+
switch (type) {
|
|
5229
|
+
case "text":
|
|
5230
|
+
case "number":
|
|
5231
|
+
case "email":
|
|
5232
|
+
case "password":
|
|
5233
|
+
return /*#__PURE__*/React__default.createElement(FormInput, Object.assign({
|
|
5234
|
+
key: name
|
|
5235
|
+
}, decoratorProps, {
|
|
5236
|
+
fieldRequired: isRequired(options),
|
|
5237
|
+
fieldErrors: errors
|
|
5238
|
+
}, fieldProps, register(name, options), {
|
|
5239
|
+
type: type || "text"
|
|
5240
|
+
}));
|
|
5241
|
+
|
|
5242
|
+
case "select":
|
|
5243
|
+
return /*#__PURE__*/React__default.createElement(FormSelect, Object.assign({
|
|
5244
|
+
key: name
|
|
5245
|
+
}, decoratorProps, {
|
|
5246
|
+
fieldRequired: isRequired(options),
|
|
5247
|
+
fieldErrors: errors
|
|
5248
|
+
}, fieldProps, {
|
|
5249
|
+
control: control,
|
|
5250
|
+
rules: options,
|
|
5251
|
+
name: name
|
|
5252
|
+
}));
|
|
5253
|
+
|
|
5254
|
+
case "radioGroup":
|
|
5255
|
+
return /*#__PURE__*/React__default.createElement(FormRadioGroup, Object.assign({
|
|
5256
|
+
key: name
|
|
5257
|
+
}, decoratorProps, {
|
|
5258
|
+
fieldRequired: isRequired(options),
|
|
5259
|
+
fieldErrors: errors
|
|
5260
|
+
}, fieldProps, register(name, options)));
|
|
5261
|
+
|
|
5262
|
+
default:
|
|
5263
|
+
return undefined;
|
|
5264
|
+
}
|
|
5265
|
+
};
|
|
5266
|
+
|
|
5267
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
5268
|
+
className: "space-y-4"
|
|
5269
|
+
}, fields.map(function (props) {
|
|
5270
|
+
if (props.type === "row") {
|
|
5271
|
+
var rowFields = props.fields,
|
|
5272
|
+
key = props.key;
|
|
5273
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
5274
|
+
className: "flex flex-row",
|
|
5275
|
+
key: key
|
|
5276
|
+
}, rowFields.map(fieldMapper));
|
|
5277
|
+
}
|
|
5278
|
+
|
|
5279
|
+
return fieldMapper(props);
|
|
5280
|
+
}), /*#__PURE__*/React__default.createElement(PrimaryButton, {
|
|
5281
|
+
onClick: handleSubmit(onValid, onError),
|
|
5282
|
+
text: "submit"
|
|
5283
|
+
}));
|
|
5284
|
+
}
|
|
5285
|
+
|
|
4784
5286
|
var AlertsIcon = function AlertsIcon(props) {
|
|
4785
5287
|
return /*#__PURE__*/React__default.createElement("svg", {
|
|
4786
5288
|
className: props.className,
|
|
@@ -5582,6 +6084,7 @@ exports.EmptyStateDashboardIcon = EmptyStateDashboardIcon;
|
|
|
5582
6084
|
exports.ErrorBlock = ErrorBlock;
|
|
5583
6085
|
exports.ExclamationMarkIcon = ExclamationMarkIcon;
|
|
5584
6086
|
exports.EyeIcon = EyeIcon;
|
|
6087
|
+
exports.Form = Form;
|
|
5585
6088
|
exports.GearIcon = GearIcon;
|
|
5586
6089
|
exports.GroupIcon = GroupIcon;
|
|
5587
6090
|
exports.HamburgerIcon = HamburgerIcon;
|