@luscii-healthtech/web-ui 2.0.0 → 2.1.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.
Files changed (42) hide show
  1. package/dist/components/Form/Form.d.ts +9 -0
  2. package/dist/components/Form/FormFieldDecorator.d.ts +8 -0
  3. package/dist/components/Form/FormInput.d.ts +3 -0
  4. package/dist/components/Form/FormRadioGroup.d.ts +3 -0
  5. package/dist/components/Form/FormSelect.d.ts +3 -0
  6. package/dist/components/Form/form.transformer.d.ts +20 -0
  7. package/dist/components/Form/form.types.d.ts +54 -0
  8. package/dist/components/Input/Input.d.ts +8 -7
  9. package/dist/components/Input/SearchInput.d.ts +1 -1
  10. package/dist/components/Radio/Radio.d.ts +3 -0
  11. package/dist/components/Radio/RadioV2.d.ts +17 -0
  12. package/dist/components/RadioGroup/RadioGroup.d.ts +3 -0
  13. package/dist/components/RadioGroup/RadioGroupV2.d.ts +9 -0
  14. package/dist/components/Select/Select.d.ts +3 -0
  15. package/dist/components/Select/SelectV2.d.ts +31 -0
  16. package/dist/index.d.ts +2 -0
  17. package/dist/web-ui-tailwind.css +34 -0
  18. package/dist/web-ui.cjs.development.js +510 -17
  19. package/dist/web-ui.cjs.development.js.map +1 -1
  20. package/dist/web-ui.cjs.production.min.js +1 -1
  21. package/dist/web-ui.cjs.production.min.js.map +1 -1
  22. package/dist/web-ui.esm.js +510 -18
  23. package/dist/web-ui.esm.js.map +1 -1
  24. package/package.json +6 -3
  25. package/src/components/Form/Form.tsx +106 -0
  26. package/src/components/Form/FormFieldDecorator.tsx +66 -0
  27. package/src/components/Form/FormInput.tsx +47 -0
  28. package/src/components/Form/FormRadioGroup.tsx +23 -0
  29. package/src/components/Form/FormSelect.tsx +32 -0
  30. package/src/components/Form/form.transformer.ts +9 -0
  31. package/src/components/Form/form.types.ts +132 -0
  32. package/src/components/Input/Input.tsx +160 -165
  33. package/src/components/Input/SearchInput.tsx +13 -3
  34. package/src/components/Radio/Radio.js +3 -0
  35. package/src/components/Radio/RadioV2.css +15 -0
  36. package/src/components/Radio/RadioV2.tsx +87 -0
  37. package/src/components/RadioGroup/RadioGroup.js +3 -0
  38. package/src/components/RadioGroup/RadioGroupV2.tsx +35 -0
  39. package/src/components/Select/Select.tsx +38 -12
  40. package/src/components/Select/SelectV2.tsx +171 -0
  41. package/src/index.tsx +3 -0
  42. package/src/components/Select/Select.examples.md +0 -161
@@ -18,6 +18,8 @@ import { Editor } from 'react-draft-wysiwyg';
18
18
  import draftToHtml from 'draftjs-to-html';
19
19
  import htmlToDraft from 'html-to-draftjs';
20
20
  import 'react-draft-wysiwyg/dist/react-draft-wysiwyg.css';
21
+ import { Controller, useForm } from 'react-hook-form';
22
+ import { ErrorMessage } from '@hookform/error-message';
21
23
 
22
24
  function styleInject(css, ref) {
23
25
  if ( ref === void 0 ) ref = {};
@@ -1854,7 +1856,7 @@ var CrossIcon = function CrossIcon(props) {
1854
1856
  var css_248z$c = ".input::-ms-clear {\n display: none;\n}";
1855
1857
  styleInject(css_248z$c);
1856
1858
 
1857
- var _excluded$6 = ["withSuffix", "withPrefix", "className", "clearable", "type", "isDisabled", "icon", "setRef", "name", "value", "onChange"];
1859
+ var _excluded$6 = ["withSuffix", "withPrefix", "className", "clearable", "type", "isDisabled", "icon", "name", "value", "onChange", "isError"];
1858
1860
  // Don't know why yet but it can be fixed later.
1859
1861
 
1860
1862
  var INPUT_TYPES = {
@@ -1863,8 +1865,7 @@ var INPUT_TYPES = {
1863
1865
  PASSWORD: "password",
1864
1866
  TEXT: "text"
1865
1867
  };
1866
-
1867
- var Input = function Input(_ref) {
1868
+ var Input = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
1868
1869
  var _ref$withSuffix = _ref.withSuffix,
1869
1870
  withSuffix = _ref$withSuffix === void 0 ? "" : _ref$withSuffix,
1870
1871
  _ref$withPrefix = _ref.withPrefix,
@@ -1877,10 +1878,11 @@ var Input = function Input(_ref) {
1877
1878
  _ref$isDisabled = _ref.isDisabled,
1878
1879
  isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
1879
1880
  icon = _ref.icon,
1880
- setRef = _ref.setRef,
1881
1881
  name = _ref.name,
1882
- value = _ref.value,
1882
+ _ref$value = _ref.value,
1883
+ value = _ref$value === void 0 ? "" : _ref$value,
1883
1884
  onChange = _ref.onChange,
1885
+ isError = _ref.isError,
1884
1886
  otherProps = _objectWithoutPropertiesLoose(_ref, _excluded$6);
1885
1887
 
1886
1888
  var hasNoExtraContent = withPrefix === "" && withSuffix === "";
@@ -1889,7 +1891,6 @@ var Input = function Input(_ref) {
1889
1891
  innerValue = _useState[0],
1890
1892
  setInnerValue = _useState[1];
1891
1893
 
1892
- var inputRef = useRef(null);
1893
1894
  useEffect(function () {
1894
1895
  setInnerValue(value);
1895
1896
  }, [value]);
@@ -1931,13 +1932,13 @@ var Input = function Input(_ref) {
1931
1932
  }, /*#__PURE__*/React__default.createElement("div", {
1932
1933
  className: "flex flex-row"
1933
1934
  }, /*#__PURE__*/React__default.createElement("span", {
1934
- className: classNames("h-11", {
1935
+ className: classNames("h-11 border-t border-b border-solid border-input-border", {
1935
1936
  hidden: hasNoExtraContent,
1936
1937
  "order-1": withPrefix !== "",
1937
1938
  "order-2": withSuffix !== "",
1938
1939
  "rounded-l border-l": withPrefix !== "",
1939
1940
  "rounded-r border-r": withSuffix !== ""
1940
- }, "border-t border-b border-solid border-input-border", "flex flex-col items-center p-3", "text-sm", "text-slate-500", "bg-main-background")
1941
+ }, "flex flex-col items-center p-3", "text-sm", "text-slate-500", "bg-main-background")
1941
1942
  }, withSuffix || withPrefix), icon && /*#__PURE__*/React__default.createElement("div", {
1942
1943
  className: "absolute top-1/2 left-4",
1943
1944
  style: {
@@ -1950,10 +1951,7 @@ var Input = function Input(_ref) {
1950
1951
  name: name,
1951
1952
  value: innerValue,
1952
1953
  onChange: handleChangeEvent,
1953
- ref: function ref(element) {
1954
- inputRef.current = element;
1955
- element && (setRef == null ? void 0 : setRef(element));
1956
- },
1954
+ ref: ref,
1957
1955
  size: otherProps.maxLength,
1958
1956
  type: type,
1959
1957
  disabled: isDisabled,
@@ -1963,10 +1961,14 @@ var Input = function Input(_ref) {
1963
1961
  }, {
1964
1962
  "text-slate-400 bg-slate-50": isDisabled,
1965
1963
  "text-slate-700": !isDisabled,
1966
- "border-input-border": !isDisabled,
1964
+ "border-input-border": !isDisabled && !isError,
1967
1965
  "hover:border-input-border-dark": !isDisabled,
1966
+ "border-red-700": isError,
1967
+ "focus:outline-negative": isError,
1968
+ "focus:border-blue-800": !isError,
1969
+ "focus:outline-primary": !isError,
1968
1970
  "bg-white": !isDisabled
1969
- }, "h-11", "p-2", "border", "text-sm", "placeholder-slate-500", "border-solid", "focus:outline-primary", "transition-colors", "duration-300", "focus:border-blue-800", {
1971
+ }, "h-11", "p-2", "border", "text-sm", "placeholder-slate-500", "border-solid", "transition-colors", "duration-300", {
1970
1972
  "z-10": withSuffix !== "" || withPrefix !== "",
1971
1973
  rounded: hasNoExtraContent,
1972
1974
  "rounded-l": withSuffix !== "",
@@ -1986,7 +1988,7 @@ var Input = function Input(_ref) {
1986
1988
  }),
1987
1989
  onClick: clearField
1988
1990
  }))));
1989
- };
1991
+ });
1990
1992
 
1991
1993
  var Line = function Line(_ref) {
1992
1994
  var left = _ref.left,
@@ -2330,6 +2332,10 @@ function generateCustomStyles(hasError, isIE11) {
2330
2332
  }
2331
2333
  };
2332
2334
  }
2335
+ /**
2336
+ * @deprecated: use SelectV2 instead
2337
+ */
2338
+
2333
2339
 
2334
2340
  var CustomSelect = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
2335
2341
  var className = props.className,
@@ -3811,6 +3817,10 @@ var PreviewPhone = function PreviewPhone(_ref) {
3811
3817
  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";
3812
3818
  styleInject(css_248z$j);
3813
3819
 
3820
+ /**
3821
+ * @deprecated: use RadioV2 instead
3822
+ */
3823
+
3814
3824
  var Radio = /*#__PURE__*/function (_PureComponent) {
3815
3825
  _inheritsLoose(Radio, _PureComponent);
3816
3826
 
@@ -3911,6 +3921,9 @@ var css_248z$k = ".cweb-radio-group {\n display: flex;\n justify-content: flex
3911
3921
  styleInject(css_248z$k);
3912
3922
 
3913
3923
  var _excluded$b = ["className", "radioClassName", "name", "selectedOption", "isVertical", "radioOptions", "onChange", "error", "isDisabled"];
3924
+ /**
3925
+ * @deprecated: use RadioV2 instead
3926
+ */
3914
3927
 
3915
3928
  function RadioGroup(_ref) {
3916
3929
  var className = _ref.className,
@@ -4775,14 +4788,493 @@ var SearchIcon = function SearchIcon(props) {
4775
4788
  }));
4776
4789
  };
4777
4790
 
4778
- var SearchInput = function SearchInput(props) {
4791
+ var SearchInput = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
4779
4792
  return /*#__PURE__*/React__default.createElement(Input, Object.assign({}, props, {
4780
4793
  icon: SearchIcon,
4781
4794
  type: "text",
4782
- clearable: true
4795
+ clearable: true,
4796
+ ref: ref
4783
4797
  }));
4798
+ });
4799
+
4800
+ /**
4801
+ * Decorator for any input component. Adds a label and additional information to be shown.
4802
+ *
4803
+ * Includes the default error handling from react-hook-form.
4804
+ */
4805
+
4806
+ function FormFieldDecorator(_ref) {
4807
+ var name = _ref.name,
4808
+ children = _ref.children,
4809
+ label = _ref.label,
4810
+ fieldRequired = _ref.fieldRequired,
4811
+ info = _ref.info,
4812
+ fieldErrors = _ref.fieldErrors,
4813
+ decoratorClassname = _ref.decoratorClassname;
4814
+ return /*#__PURE__*/React__default.createElement("div", {
4815
+ className: classNames(decoratorClassname)
4816
+ }, label && /*#__PURE__*/React__default.createElement("label", {
4817
+ className: "cweb-form-field-label block mb-1",
4818
+ htmlFor: name,
4819
+ "data-is-required": fieldRequired
4820
+ }, /*#__PURE__*/React__default.createElement(Text, {
4821
+ className: "cweb-form-field-label-text",
4822
+ inline: true,
4823
+ text: label
4824
+ })), /*#__PURE__*/React__default.createElement("fieldset", {
4825
+ className: "cweb-form-fieldset"
4826
+ }, children), info && /*#__PURE__*/React__default.createElement(Text, {
4827
+ className: "mt-1 cweb-form-info-text",
4828
+ type: "sm",
4829
+ color: "slate-500",
4830
+ text: info
4831
+ }), /*#__PURE__*/React__default.createElement(ErrorMessage, {
4832
+ errors: fieldErrors,
4833
+ name: name,
4834
+ render: function render(_ref2) {
4835
+ var messages = _ref2.messages;
4836
+ return messages && Object.entries(messages).map(function (_ref3) {
4837
+ var key = _ref3[0],
4838
+ message = _ref3[1];
4839
+ return /*#__PURE__*/React__default.createElement(Text, {
4840
+ key: key,
4841
+ className: "mt-1",
4842
+ text: message,
4843
+ color: "red"
4844
+ });
4845
+ });
4846
+ }
4847
+ }));
4848
+ }
4849
+
4850
+ var hasError = function hasError(name, errors) {
4851
+ return !!(name && errors && name in errors);
4852
+ };
4853
+ var isRequired = function isRequired(options) {
4854
+ return !!(options && "required" in options);
4784
4855
  };
4785
4856
 
4857
+ var _excluded$h = ["name", "fieldErrors", "fieldRequired", "label", "info", "decoratorClassname"];
4858
+ /**
4859
+ * Input field that can be used in any react-hook-form context.
4860
+ */
4861
+
4862
+ var FormInputInner = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
4863
+ var name = _ref.name,
4864
+ fieldErrors = _ref.fieldErrors,
4865
+ fieldRequired = _ref.fieldRequired,
4866
+ label = _ref.label,
4867
+ info = _ref.info,
4868
+ decoratorClassname = _ref.decoratorClassname,
4869
+ fieldProps = _objectWithoutPropertiesLoose(_ref, _excluded$h);
4870
+
4871
+ return /*#__PURE__*/React__default.createElement(FormFieldDecorator, {
4872
+ name: name,
4873
+ fieldErrors: fieldErrors,
4874
+ fieldRequired: fieldRequired,
4875
+ label: label,
4876
+ info: info,
4877
+ decoratorClassname: decoratorClassname
4878
+ }, /*#__PURE__*/React__default.createElement(Input, Object.assign({}, fieldProps, {
4879
+ isError: hasError(name, fieldErrors),
4880
+ ref: ref,
4881
+ name: name
4882
+ })));
4883
+ });
4884
+ var FormInput = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
4885
+ return /*#__PURE__*/React__default.createElement(FormInputInner, Object.assign({}, props, {
4886
+ ref: ref
4887
+ }));
4888
+ });
4889
+
4890
+ 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";
4891
+ styleInject(css_248z$r);
4892
+
4893
+ var _excluded$i = ["text", "info", "isError", "innerRef", "className"];
4894
+
4895
+ function RadioInner(_ref) {
4896
+ var text = _ref.text,
4897
+ info = _ref.info,
4898
+ isError = _ref.isError,
4899
+ innerRef = _ref.innerRef,
4900
+ className = _ref.className,
4901
+ otherProps = _objectWithoutPropertiesLoose(_ref, _excluded$i);
4902
+
4903
+ var value = otherProps.value,
4904
+ disabled = otherProps.disabled;
4905
+ var nameHtmlFor = "field-" + value;
4906
+ return /*#__PURE__*/React__default.createElement("label", {
4907
+ className: "radio-form-field-label leading-tight",
4908
+ htmlFor: nameHtmlFor,
4909
+ "data-has-error": isError,
4910
+ "data-test-id": nameHtmlFor
4911
+ }, /*#__PURE__*/React__default.createElement("div", {
4912
+ className: "flex flex-row items-center "
4913
+ }, /*#__PURE__*/React__default.createElement("input", Object.assign({}, otherProps, {
4914
+ className: classNames("appearance-none", className),
4915
+ ref: innerRef,
4916
+ type: "radio",
4917
+ id: nameHtmlFor,
4918
+ disabled: disabled
4919
+ })), /*#__PURE__*/React__default.createElement("span", {
4920
+ 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")
4921
+ }, /*#__PURE__*/React__default.createElement("span", {
4922
+ className: "block transition-colors duration-300 ease-in-out radio-inner-circle w-1.5 h-1.5 rounded-xl"
4923
+ })), text && /*#__PURE__*/React__default.createElement("div", {
4924
+ className: "ml-2"
4925
+ }, /*#__PURE__*/React__default.createElement(Text, {
4926
+ inline: true,
4927
+ text: text,
4928
+ type: "base",
4929
+ color: disabled ? "slate-500" : undefined
4930
+ }))), info && /*#__PURE__*/React__default.createElement(Text, {
4931
+ inline: true,
4932
+ className: "ml-6",
4933
+ text: info,
4934
+ type: "sm",
4935
+ color: disabled ? "slate-200" : "slate-500"
4936
+ }));
4937
+ }
4938
+ /**
4939
+ * TODO: The CSS styling is all messed up, including isError
4940
+ * Warning: don't use this prop before this is resolved
4941
+ * Issue to track: https://github.com/Luscii/web-ui/issues/57
4942
+ * TODO: remove this comment once this is resolved
4943
+ */
4944
+
4945
+
4946
+ var RadioV2 = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
4947
+ return /*#__PURE__*/React__default.createElement(RadioInner, Object.assign({}, props, {
4948
+ innerRef: ref
4949
+ }));
4950
+ });
4951
+
4952
+ var _excluded$j = ["innerRef", "options"];
4953
+
4954
+ function RadioGroupInner(_ref) {
4955
+ var innerRef = _ref.innerRef,
4956
+ options = _ref.options,
4957
+ registerProps = _objectWithoutPropertiesLoose(_ref, _excluded$j);
4958
+
4959
+ return /*#__PURE__*/React__default.createElement("div", {
4960
+ className: classNames("flex flex-col space-y-2")
4961
+ }, options.map(function (option) {
4962
+ return /*#__PURE__*/React__default.createElement(RadioV2, Object.assign({
4963
+ key: option.value
4964
+ }, option, registerProps, {
4965
+ ref: innerRef
4966
+ }));
4967
+ }));
4968
+ }
4969
+
4970
+ var RadioGroupV2 = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
4971
+ return /*#__PURE__*/React__default.createElement(RadioGroupInner, Object.assign({}, props, {
4972
+ innerRef: ref
4973
+ }));
4974
+ });
4975
+
4976
+ var _excluded$k = ["innerRef", "name", "fieldErrors", "fieldRequired", "label", "info", "decoratorClassname"];
4977
+ /**
4978
+ * Input field that can be used in any react-hook-form context.
4979
+ */
4980
+
4981
+ function FormRadioGroupInner(_ref) {
4982
+ var innerRef = _ref.innerRef,
4983
+ name = _ref.name,
4984
+ fieldErrors = _ref.fieldErrors,
4985
+ fieldRequired = _ref.fieldRequired,
4986
+ label = _ref.label,
4987
+ info = _ref.info,
4988
+ decoratorClassname = _ref.decoratorClassname,
4989
+ fieldProps = _objectWithoutPropertiesLoose(_ref, _excluded$k);
4990
+
4991
+ return /*#__PURE__*/React__default.createElement(FormFieldDecorator, {
4992
+ name: name,
4993
+ fieldErrors: fieldErrors,
4994
+ fieldRequired: fieldRequired,
4995
+ label: label,
4996
+ info: info,
4997
+ decoratorClassname: decoratorClassname
4998
+ }, /*#__PURE__*/React__default.createElement(RadioGroupV2, Object.assign({}, fieldProps, {
4999
+ isError: hasError(name, fieldErrors),
5000
+ ref: innerRef,
5001
+ name: name
5002
+ })));
5003
+ }
5004
+
5005
+ var FormRadioGroup = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
5006
+ return /*#__PURE__*/React__default.createElement(FormRadioGroupInner, Object.assign({}, props, {
5007
+ innerRef: ref
5008
+ }));
5009
+ });
5010
+
5011
+ var _excluded$l = ["isError", "styles", "options", "onChange", "value", "isMulti", "className"];
5012
+
5013
+ function generateCustomStyles$1(hasError, isIE11) {
5014
+ return {
5015
+ option: function option(baseStyles, state) {
5016
+ return _extends({}, baseStyles, {
5017
+ fontWeight: state.isSelected ? "bold" : "normal",
5018
+ fontSize: "14px",
5019
+ backgroundColor: "none",
5020
+ color: "inherit",
5021
+ position: "relative",
5022
+ padding: "0.75rem",
5023
+ opacity: state.isDisabled ? "0.5" : 1,
5024
+ "&:after": {
5025
+ visibility: state.isSelected ? "visible" : "hidden"
5026
+ },
5027
+ transition: "background-color 0.3s ease-in-out",
5028
+ "&:hover": {
5029
+ // tailwind blue-50
5030
+ backgroundColor: state.isSelected ? "transparent" : "#F2FAFD"
5031
+ },
5032
+ pointerEvents: state.isDisabled ? "none" : "auto"
5033
+ });
5034
+ },
5035
+ container: function container(baseStyles) {
5036
+ return _extends({}, baseStyles, {
5037
+ flexGrow: isIE11 ? 0.5 : "initial"
5038
+ });
5039
+ },
5040
+ control: function control(baseStyles, state) {
5041
+ var defaultBorderColor = state.isFocused ? "#045baa" : "#D1D5DB";
5042
+ var validatedBorderColor = hasError ? "#c53030" : defaultBorderColor;
5043
+ var defaultOutline = hasError ? "rgba(255, 98, 102, 0.3)" : "rgba(0, 159, 227, 0.3)";
5044
+ var validatedOutline = "4px solid " + (state.isFocused ? defaultOutline : "transparent");
5045
+ return _extends({}, baseStyles, {
5046
+ fontSize: "14px",
5047
+ transition: "border 0.3s ease-in-out",
5048
+ height: isIE11 ? "50px" : "2.75rem",
5049
+ // primary outline
5050
+ outline: validatedOutline,
5051
+ borderColor: validatedBorderColor,
5052
+ borderWidth: "1px !important",
5053
+ borderStyle: "solid",
5054
+ borderRadius: "4px",
5055
+ boxShadow: "0px 1px 2px rgba(0, 0, 0, 0.05)",
5056
+ "&:hover": {
5057
+ borderColor: "#9CA3AF",
5058
+ // selector for the chevron
5059
+ "> [class*=\"IndicatorsContainer\"]": {
5060
+ opacity: 1
5061
+ }
5062
+ }
5063
+ });
5064
+ },
5065
+ // The placeholder has the following css prop: grid-area: 1/1/2/3;
5066
+ // And grid-area doesn't work on IE11, so we need to style it slightly different.
5067
+ placeholder: function placeholder(baseStyles) {
5068
+ return _extends({}, baseStyles, {
5069
+ fontWeight: 100,
5070
+ color: "#6B7280",
5071
+ paddingTop: isIE11 ? "1.2rem" : undefined
5072
+ });
5073
+ },
5074
+ singleValue: function singleValue(baseStyles) {
5075
+ return _extends({}, baseStyles, {
5076
+ paddingTop: isIE11 ? "1.2rem" : undefined,
5077
+ fontSize: "14px"
5078
+ });
5079
+ },
5080
+ indicatorSeparator: function indicatorSeparator() {
5081
+ return {
5082
+ display: "none"
5083
+ };
5084
+ },
5085
+ menu: function menu(baseStyles) {
5086
+ return _extends({}, baseStyles, {
5087
+ zIndex: 20
5088
+ });
5089
+ }
5090
+ };
5091
+ }
5092
+ /**
5093
+ * A wrapper around react-select to style it according to our design specification.
5094
+ *
5095
+ * In addition, the value is taken out of the option, instead of returning the complete option.
5096
+ *
5097
+ * Care when using grouped options: the value of the options overspanning all groups need to be unique!
5098
+ * For instance, if you have an option with value "chocolate" in both the groups "flavor" and "dip", then you get unforeseen errors.
5099
+ * This is a problem within react-select itself, not our wrapper.
5100
+ *
5101
+ * Care when using defaultValue: this still requires the complete Option (instead of the value of the Option).
5102
+ * So far there wasn't a use-case for this.
5103
+ */
5104
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5105
+
5106
+
5107
+ var Select = /*#__PURE__*/React__default.forwardRef(function (_ref, innerRef) {
5108
+ var _ref$isError = _ref.isError,
5109
+ isError = _ref$isError === void 0 ? false : _ref$isError,
5110
+ styles = _ref.styles,
5111
+ options = _ref.options,
5112
+ onChange = _ref.onChange,
5113
+ value = _ref.value,
5114
+ isMulti = _ref.isMulti,
5115
+ className = _ref.className,
5116
+ otherProps = _objectWithoutPropertiesLoose(_ref, _excluded$l);
5117
+
5118
+ var isIE11 = "MSInputMethodContext" in window && "documentMode" in document;
5119
+ var customStyles = generateCustomStyles$1(isError, isIE11);
5120
+ var mergedStyles = mergeStyles(customStyles, styles); // the options can be either a list of options or a grouped list of options
5121
+ // this is a typechecker to verify it is the case.
5122
+
5123
+ var isOptionsGrouped = !options ? false : options.reduce(function (acc, o) {
5124
+ return acc || "options" in o && !("values" in o);
5125
+ }, false); // we subsequently flatmap to ensure it's always a list of options
5126
+
5127
+ var flatmappedOptions = !options ? [] : isOptionsGrouped ? options.flatMap(function (g) {
5128
+ return g.options;
5129
+ }) : options; // based on: https://stackoverflow.com/a/70022957
5130
+
5131
+ var onChangeWrapped = !onChange ? undefined : isMulti ? function (val, a) {
5132
+ return onChange(val.map(function (v) {
5133
+ return v.value;
5134
+ }), a);
5135
+ } : function (val, a) {
5136
+ return onChange(val == null ? void 0 : val.value, a);
5137
+ }; // TODO: how can we report the error if a value was given that is not within the options?
5138
+
5139
+ var valueWrapped = !value || !options ? value : isMulti ? flatmappedOptions.filter(function (o) {
5140
+ return value.includes(o.value);
5141
+ }) : flatmappedOptions.find(function (o) {
5142
+ return o.value === value;
5143
+ });
5144
+ return /*#__PURE__*/React__default.createElement(ReactSelect, Object.assign({}, otherProps, {
5145
+ ref: innerRef,
5146
+ styles: mergedStyles,
5147
+ options: options,
5148
+ onChange: onChangeWrapped,
5149
+ value: valueWrapped,
5150
+ isMulti: isMulti,
5151
+ className: classNames("customized-select", className)
5152
+ }));
5153
+ });
5154
+
5155
+ var _excluded$m = ["control", "name", "rules", "fieldErrors", "fieldRequired", "label", "info", "decoratorClassname"];
5156
+
5157
+ var FormSelect = /*#__PURE__*/React__default.forwardRef(function (_ref, innerRef) {
5158
+ var control = _ref.control,
5159
+ name = _ref.name,
5160
+ rules = _ref.rules,
5161
+ fieldErrors = _ref.fieldErrors,
5162
+ fieldRequired = _ref.fieldRequired,
5163
+ label = _ref.label,
5164
+ info = _ref.info,
5165
+ decoratorClassname = _ref.decoratorClassname,
5166
+ selectProps = _objectWithoutPropertiesLoose(_ref, _excluded$m);
5167
+
5168
+ return /*#__PURE__*/React__default.createElement(FormFieldDecorator, {
5169
+ name: name,
5170
+ fieldErrors: fieldErrors,
5171
+ fieldRequired: fieldRequired,
5172
+ label: label,
5173
+ info: info,
5174
+ decoratorClassname: decoratorClassname
5175
+ }, /*#__PURE__*/React__default.createElement(Controller, {
5176
+ name: name,
5177
+ control: control,
5178
+ rules: rules,
5179
+ render: function render(_ref2) {
5180
+ var field = _ref2.field;
5181
+ return /*#__PURE__*/React__default.createElement(Select, Object.assign({}, selectProps, field, {
5182
+ isError: hasError(name, fieldErrors),
5183
+ ref: innerRef
5184
+ }));
5185
+ }
5186
+ }));
5187
+ });
5188
+
5189
+ var _excluded$n = ["type", "name", "options", "fieldProps"];
5190
+ /**
5191
+ * Create a straight forward Form.
5192
+ *
5193
+ * TODO: wrap this in some Page component to style the div and buttons
5194
+ * WARNING: don't use this component before some styling errors are resolved.
5195
+ */
5196
+
5197
+ function Form(_ref) {
5198
+ var fields = _ref.fields,
5199
+ onValid = _ref.onValid,
5200
+ onError = _ref.onError,
5201
+ defaultValues = _ref.defaultValues;
5202
+
5203
+ var _useForm = useForm({
5204
+ criteriaMode: "all",
5205
+ defaultValues: defaultValues
5206
+ }),
5207
+ register = _useForm.register,
5208
+ handleSubmit = _useForm.handleSubmit,
5209
+ control = _useForm.control,
5210
+ errors = _useForm.formState.errors;
5211
+
5212
+ var fieldMapper = function fieldMapper(_ref2) {
5213
+ var type = _ref2.type,
5214
+ name = _ref2.name,
5215
+ options = _ref2.options,
5216
+ _ref2$fieldProps = _ref2.fieldProps,
5217
+ fieldProps = _ref2$fieldProps === void 0 ? {} : _ref2$fieldProps,
5218
+ decoratorProps = _objectWithoutPropertiesLoose(_ref2, _excluded$n);
5219
+
5220
+ switch (type) {
5221
+ case "text":
5222
+ case "number":
5223
+ case "email":
5224
+ case "password":
5225
+ return /*#__PURE__*/React__default.createElement(FormInput, Object.assign({
5226
+ key: name
5227
+ }, decoratorProps, {
5228
+ fieldRequired: isRequired(options),
5229
+ fieldErrors: errors
5230
+ }, fieldProps, register(name, options), {
5231
+ type: type || "text"
5232
+ }));
5233
+
5234
+ case "select":
5235
+ return /*#__PURE__*/React__default.createElement(FormSelect, Object.assign({
5236
+ key: name
5237
+ }, decoratorProps, {
5238
+ fieldRequired: isRequired(options),
5239
+ fieldErrors: errors
5240
+ }, fieldProps, {
5241
+ control: control,
5242
+ rules: options,
5243
+ name: name
5244
+ }));
5245
+
5246
+ case "radioGroup":
5247
+ return /*#__PURE__*/React__default.createElement(FormRadioGroup, Object.assign({
5248
+ key: name
5249
+ }, decoratorProps, {
5250
+ fieldRequired: isRequired(options),
5251
+ fieldErrors: errors
5252
+ }, fieldProps, register(name, options)));
5253
+
5254
+ default:
5255
+ return undefined;
5256
+ }
5257
+ };
5258
+
5259
+ return /*#__PURE__*/React__default.createElement("div", {
5260
+ className: "space-y-4"
5261
+ }, fields.map(function (props) {
5262
+ if (props.type === "row") {
5263
+ var rowFields = props.fields,
5264
+ key = props.key;
5265
+ return /*#__PURE__*/React__default.createElement("div", {
5266
+ className: "flex flex-row",
5267
+ key: key
5268
+ }, rowFields.map(fieldMapper));
5269
+ }
5270
+
5271
+ return fieldMapper(props);
5272
+ }), /*#__PURE__*/React__default.createElement(PrimaryButton, {
5273
+ onClick: handleSubmit(onValid, onError),
5274
+ text: "submit"
5275
+ }));
5276
+ }
5277
+
4786
5278
  var AlertsIcon = function AlertsIcon(props) {
4787
5279
  return /*#__PURE__*/React__default.createElement("svg", {
4788
5280
  className: props.className,
@@ -5554,5 +6046,5 @@ var SearchCancelIcon = function SearchCancelIcon(props) {
5554
6046
  }));
5555
6047
  };
5556
6048
 
5557
- export { ACKNOWLEDGEMENT_TYPE_OPTIONS, Acknowledgement, AddIcon, AlertsIcon, Avatar, Badge, BellIcon, Breadcrumbs, CRUDPage, Carousel, CenteredHero, ChartIcon, ChatBoxIcon, CheckIcon, Checkbox, CheckboxList, ChevronDoubleIcon, ConfirmationDialog, CrossIcon, Datepicker as DatePicker, DeleteIcon, DownArrowIcon, DragIcon, Dropdown, EditIcon, EmptyListMessage, EmptyStateDashboardIcon, ErrorBlock, ExclamationMarkIcon, EyeIcon, GearIcon, GroupIcon, HamburgerIcon, HeartIcon, INPUT_TYPES, InfoBlock, InfoField, Input, LeftArrowIcon, LightBulbIcon, Line, List, LoadingIndicator, LockIcon, Menu, MessagesIcon, MultiSelect, NavLayout, NavMenu, NotesIcon, NotificationBanner, Page, PageHeader, PaginationMenu, PinIcon, PreviewPhone, PrimaryButton, PrintIcon, Radio, RadioGroup, RightArrowIcon, SearchCancelIcon, SearchIcon, SearchInput, SecondaryButton, Section, SectionItem, SectionItemWithContent, SettingsMenuButton, SmallCircleIcon, SmallDiamondIcon, SmallSquareIcon, SpaceRocketIcon, Spinner, StarIcon, Steps, Switcher, TabLinks, Tabbar, Table, Tag, TagGroup, TertiaryButton, Text, Textarea as TextArea, TextEditor, TextEditorV2, TextLink, Timeline, Title, ViewItem };
6049
+ export { ACKNOWLEDGEMENT_TYPE_OPTIONS, Acknowledgement, AddIcon, AlertsIcon, Avatar, Badge, BellIcon, Breadcrumbs, CRUDPage, Carousel, CenteredHero, ChartIcon, ChatBoxIcon, CheckIcon, Checkbox, CheckboxList, ChevronDoubleIcon, ConfirmationDialog, CrossIcon, Datepicker as DatePicker, DeleteIcon, DownArrowIcon, DragIcon, Dropdown, EditIcon, EmptyListMessage, EmptyStateDashboardIcon, ErrorBlock, ExclamationMarkIcon, EyeIcon, Form, GearIcon, GroupIcon, HamburgerIcon, HeartIcon, INPUT_TYPES, InfoBlock, InfoField, Input, LeftArrowIcon, LightBulbIcon, Line, List, LoadingIndicator, LockIcon, Menu, MessagesIcon, MultiSelect, NavLayout, NavMenu, NotesIcon, NotificationBanner, Page, PageHeader, PaginationMenu, PinIcon, PreviewPhone, PrimaryButton, PrintIcon, Radio, RadioGroup, RightArrowIcon, SearchCancelIcon, SearchIcon, SearchInput, SecondaryButton, Section, SectionItem, SectionItemWithContent, SettingsMenuButton, SmallCircleIcon, SmallDiamondIcon, SmallSquareIcon, SpaceRocketIcon, Spinner, StarIcon, Steps, Switcher, TabLinks, Tabbar, Table, Tag, TagGroup, TertiaryButton, Text, Textarea as TextArea, TextEditor, TextEditorV2, TextLink, Timeline, Title, ViewItem };
5558
6050
  //# sourceMappingURL=web-ui.esm.js.map