@awell-health/ui-library 0.1.38 → 0.1.40

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/index.js CHANGED
@@ -33712,7 +33712,7 @@ Check the top-level render call using <` + t + ">.");
33712
33712
  };
33713
33713
  var Select = function (_a) {
33714
33714
  var _b;
33715
- var onChange = _a.onChange,id = _a.id,labels = _a.labels,type = _a.type,mandatory = _a.mandatory,options = _a.options,_c = _a.optionsShown,optionsShown = _c === void 0 ? 4 : _c,_d = _a.showCount,showCount = _d === void 0 ? false : _d,_e = _a.displayMaxLength,displayMaxLength = _e === void 0 ? 15 : _e,value = _a.value,_f = _a.filtering,filtering = _f === void 0 ? false : _f,props = __rest(_a, ["onChange", "id", "labels", "type", "mandatory", "options", "optionsShown", "showCount", "displayMaxLength", "value", "filtering"]);
33715
+ var onChange = _a.onChange,onSearch = _a.onSearch,id = _a.id,labels = _a.labels,type = _a.type,mandatory = _a.mandatory,options = _a.options,_c = _a.optionsShown,optionsShown = _c === void 0 ? 4 : _c,_d = _a.showCount,showCount = _d === void 0 ? false : _d,_e = _a.displayMaxLength,displayMaxLength = _e === void 0 ? 15 : _e,value = _a.value,_f = _a.filtering,filtering = _f === void 0 ? false : _f,props = __rest(_a, ["onChange", "onSearch", "id", "labels", "type", "mandatory", "options", "optionsShown", "showCount", "displayMaxLength", "value", "filtering"]);
33716
33716
  var _g = React.useState(false),isOpen = _g[0],setIsOpen = _g[1];
33717
33717
  var _h = React.useState(options),filteredOptions = _h[0],setFilteredOptions = _h[1];
33718
33718
  var _j = React.useState(''),searchValue = _j[0],setSearchValue = _j[1];
@@ -33735,6 +33735,11 @@ Check the top-level render call using <` + t + ">.");
33735
33735
  var selectWrapperRef = React.useRef(null);
33736
33736
  var handleInputChange = function (event) {
33737
33737
  var inputText = event.target.value.toLowerCase();
33738
+ if (!lodash.exports.isNil(onSearch)) {
33739
+ setSearchValue(inputText);
33740
+ onSearch(inputText);
33741
+ return;
33742
+ }
33738
33743
  if (inputText === '') {
33739
33744
  setSearchValue('');
33740
33745
  setFilteredOptions(options);
@@ -33763,6 +33768,11 @@ Check the top-level render call using <` + t + ">.");
33763
33768
  document.removeEventListener('mousedown', handleClickOutside);
33764
33769
  };
33765
33770
  }, [isOpen, handleClickOutside]);
33771
+ React.useEffect(function () {
33772
+ if (!lodash.exports.isNil(onSearch)) {
33773
+ setFilteredOptions(options);
33774
+ }
33775
+ }, [options]);
33766
33776
  var toggleDropdown = React.useCallback(function () {
33767
33777
  setIsOpen(!isOpen);
33768
33778
  }, [isOpen]);
@@ -33853,7 +33863,10 @@ Check the top-level render call using <` + t + ">.");
33853
33863
  setSearchValue('');
33854
33864
  setFilteredOptions(options);
33855
33865
  }, [options]);
33856
- return jsxRuntime.exports.jsxs("div", __assign({ className: classes$f.select_wrapper, ref: selectWrapperRef }, { children: [(labels === null || labels === void 0 ? void 0 : labels.questionLabel) !== undefined && jsxRuntime.exports.jsx(QuestionLabel, { htmlFor: id, label: labels.questionLabel, mandatory: mandatory }), jsxRuntime.exports.jsxs("div", __assign({ className: classes$f.select_input_wrapper, onClick: toggleDropdown }, { children: [jsxRuntime.exports.jsx("input", __assign({}, props, { type: "text", id: id, value: getDisplayValue(), placeholder: filtering ? (_b = labels === null || labels === void 0 ? void 0 : labels.searchPlaceholder) !== null && _b !== void 0 ? _b : '' : '', className: "".concat(classes$f.select_input, " ").concat(filtering ? '' : classes$f.pointer), "data-testid": "input-".concat(id), onChange: filtering ? handleInputChange : function () {return null;}, onClick: filtering ? handleResetSearch : function () {return null;}, readOnly: !filtering, onKeyUp: handleKeyUpOnInput, dir: "ltr" })), type === 'multiple' && selected.length > 0 && showCount && jsxRuntime.exports.jsx("div", __assign({ className: classes$f.badge }, { children: selected.length })), jsxRuntime.exports.jsx("div", { className: "".concat(classes$f.chevron, " ").concat(isOpen ? "".concat(classes$f.open) : '') }), jsxRuntime.exports.jsxs("div", __assign({ className: "".concat(isOpen ? classes$f.dropdown_open : classes$f.dropdown, " ").concat(options.length > optionsShown ? classes$f.dropdown_scroll : ''), style: { maxHeight: "".concat(optionsShown * 50, "px") }, role: "listbox" }, { children: [filteredOptions.length === 0 && jsxRuntime.exports.jsx("div", __assign({ className: classes$f.no_options }, { children: "No options found" })), filteredOptions.map(function (option) {return jsxRuntime.exports.jsxs("div", __assign({ className: classes$f.option, id: "option-".concat(option.value), onClick: function (event) {return handleSelect(event, option);}, onKeyUp: function (e) {return handleKeyUpOnOption(e, option);}, onKeyDown: function (e) {return handleKeyDownOnOption(e, option);}, role: "button", tabIndex: 0 }, { children: [option.label, type === 'multiple' && jsxRuntime.exports.jsx("div", __assign({ className: classes$f.checkbox }, { children: jsxRuntime.exports.jsx("input", { type: "checkbox", id: "checkbox-".concat(option.value), checked: selected === null || selected === void 0 ? void 0 : selected.some(function (item) {return item.value === option.value;}), readOnly: true, tabIndex: -1 }) }))] }), option.value);})] }))] })), (labels === null || labels === void 0 ? void 0 : labels.customError) && jsxRuntime.exports.jsx("div", __assign({ className: classes$f.error }, { children: labels.customError }))] }));
33866
+ return jsxRuntime.exports.jsxs("div", __assign({ className: classes$f.select_wrapper, ref: selectWrapperRef }, { children: [(labels === null || labels === void 0 ? void 0 : labels.questionLabel) !== undefined && jsxRuntime.exports.jsx(QuestionLabel, { htmlFor: id, label: labels.questionLabel, mandatory: mandatory }), jsxRuntime.exports.jsxs("div", __assign({ className: classes$f.select_input_wrapper, onClick: toggleDropdown }, { children: [jsxRuntime.exports.jsx("input", __assign({}, props, { type: "text", id: id, value: getDisplayValue(), placeholder: filtering ? (_b = labels === null || labels === void 0 ? void 0 : labels.searchPlaceholder) !== null && _b !== void 0 ? _b : '' : '', className: "".concat(classes$f.select_input, " ").concat(filtering ? '' : classes$f.pointer), "data-testid": "input-".concat(id), onChange: filtering ? handleInputChange : function () {return null;}, onClick: filtering ? handleResetSearch : function () {return null;}, readOnly: !filtering, onKeyUp: handleKeyUpOnInput, dir: "ltr" })), type === 'multiple' && selected.length > 0 && showCount && jsxRuntime.exports.jsx("div", __assign({ className: classes$f.badge }, { children: selected.length })), jsxRuntime.exports.jsx("div", { className: "".concat(classes$f.chevron, " ").concat(isOpen ? "".concat(classes$f.open) : '') }), jsxRuntime.exports.jsxs("div", __assign({ className: "".concat(isOpen ? classes$f.dropdown_open : classes$f.dropdown, " ").concat(options.length > optionsShown ? classes$f.dropdown_scroll : ''), style: { maxHeight: "".concat(optionsShown * 50, "px") }, role: "listbox" }, { children: [filteredOptions.length === 0 && jsxRuntime.exports.jsx("div", __assign({ className: classes$f.no_options }, { children: "No options found" })), filteredOptions.map(function (option) {
33867
+ var _a;
33868
+ return jsxRuntime.exports.jsxs("div", __assign({ className: classes$f.option, id: "option-".concat(option.value), onClick: function (event) {return handleSelect(event, option);}, onKeyUp: function (e) {return handleKeyUpOnOption(e, option);}, onKeyDown: function (e) {return handleKeyDownOnOption(e, option);}, role: "button", tabIndex: 0 }, { children: [option.label, type === 'multiple' && jsxRuntime.exports.jsx("div", __assign({ className: classes$f.checkbox }, { children: jsxRuntime.exports.jsx("input", { type: "checkbox", id: "checkbox-".concat(option.value), checked: selected === null || selected === void 0 ? void 0 : selected.some(function (item) {return item.value === option.value;}), readOnly: true, tabIndex: -1 }) }))] }), (_a = option.id) !== null && _a !== void 0 ? _a : option.value);
33869
+ })] }))] })), (labels === null || labels === void 0 ? void 0 : labels.customError) && jsxRuntime.exports.jsx("div", __assign({ className: classes$f.error }, { children: labels.customError }))] }));
33857
33870
  };
33858
33871
 
33859
33872
  var getHexColorFromString = function (string) {
@@ -50551,6 +50564,7 @@ Check the top-level render call using <` + t + ">.");
50551
50564
  exports.RangeInput = RangeInput;
50552
50565
  exports.RichTextViewer = RichTextViewer;
50553
50566
  exports.ScrollIndicator = ScrollIndicator;
50567
+ exports.Select = Select;
50554
50568
  exports.SingleChoiceQuestion = SingleChoiceQuestion;
50555
50569
  exports.SubHeading = SubHeading;
50556
50570
  exports.Text = Text;
@@ -8,7 +8,7 @@ export interface SelectProps extends Omit<InputHTMLAttributes<HTMLInputElement>,
8
8
  mandatory?: boolean;
9
9
  options: Array<Option>;
10
10
  optionsShown?: number;
11
- value: Array<Option> | number | undefined;
11
+ value: Array<Option> | number | string | undefined;
12
12
  labels: {
13
13
  questionLabel?: string;
14
14
  searchPlaceholder?: string;
@@ -18,5 +18,6 @@ export interface SelectProps extends Omit<InputHTMLAttributes<HTMLInputElement>,
18
18
  showCount?: boolean;
19
19
  displayMaxLength?: number | null;
20
20
  filtering?: boolean;
21
+ onSearch?: (searchValue: string) => void;
21
22
  }
22
- export declare const Select: ({ onChange, id, labels, type, mandatory, options, optionsShown, showCount, displayMaxLength, value, filtering, ...props }: SelectProps) => JSX.Element;
23
+ export declare const Select: ({ onChange, onSearch, id, labels, type, mandatory, options, optionsShown, showCount, displayMaxLength, value, filtering, ...props }: SelectProps) => JSX.Element;
@@ -1,4 +1,4 @@
1
- export { Button, CheckboxButton, DatePicker, Description, InputField, QuestionLabel, Logo, LongTextField, RadioButton, RangeInput, RichTextViewer, HeadingMain, HeadingSecondary, HeadingTertiary, SubHeading, Heading5, Heading6, Text, InlineText, ExternalLink, InnerText, CircularSpinner, HorizontalSpinner, ThemeProvider, ScrollIndicator, Modal, CalDotComScheduling, type CalDotComBookingSuccessfulFunction, ProgressIndicator, TypingCaret, WithTypingCaret, } from './atoms';
1
+ export { Button, CheckboxButton, DatePicker, Description, InputField, QuestionLabel, Logo, LongTextField, RadioButton, RangeInput, RichTextViewer, HeadingMain, HeadingSecondary, HeadingTertiary, SubHeading, Heading5, Heading6, Text, InlineText, ExternalLink, InnerText, CircularSpinner, HorizontalSpinner, ThemeProvider, ScrollIndicator, Modal, CalDotComScheduling, type CalDotComBookingSuccessfulFunction, ProgressIndicator, TypingCaret, WithTypingCaret, Select, } from './atoms';
2
2
  export { MultipleChoiceQuestion, Navbar, Question, SingleChoiceQuestion, AttachmentList, } from './molecules';
3
3
  export { Checklist, ConversationalForm, TraditionalForm, WizardForm, Message, HostedPageLayout, CloseButton, CloudinaryUpload, CloudinarySingleFileUpload, } from './hostedPages';
4
4
  export { useClickOutsideNotifier, useScrollHint, useConversationalForm, useTraditionalForm, } from './hooks';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awell-health/ui-library",
3
- "version": "0.1.38",
3
+ "version": "0.1.40",
4
4
  "private": false,
5
5
  "description": "UI components to integrate with Awell Health",
6
6
  "repository": {