@awell-health/ui-library 0.1.111 → 0.1.113

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.css CHANGED
@@ -6696,6 +6696,7 @@ html {
6696
6696
  width: 100%;
6697
6697
  z-index: 1001;
6698
6698
  transition: opacity 0.3s ease-in-out;
6699
+ background-color: white;
6699
6700
  }
6700
6701
  @media (min-width: 640px) {
6701
6702
  .awell__hostedPageFooter_footer .awell__hostedPageFooter_scrollHint {
package/dist/index.js CHANGED
@@ -34850,8 +34850,22 @@ Check the top-level render call using <` + t + ">.");
34850
34850
  React.useEffect(function () {
34851
34851
  if (isOpen) {
34852
34852
  var container = document.getElementById('ahp_main_content_with_scroll_hint');
34853
- if (container) {
34854
- container.scrollTo({ top: container.scrollHeight, behavior: 'smooth' });
34853
+ if (container && selectWrapperRef.current) {
34854
+ var dropdownElement = selectWrapperRef.current.querySelector(".".concat(classes$h.dropdown_open));
34855
+ if (dropdownElement) {
34856
+ var containerRect = container.getBoundingClientRect();
34857
+ var dropdownRect = dropdownElement.getBoundingClientRect();
34858
+ var selectRect = selectWrapperRef.current.getBoundingClientRect();
34859
+ var dropdownBottom = selectRect.bottom + dropdownRect.height;
34860
+ var containerBottom = containerRect.bottom;
34861
+ if (dropdownBottom > containerBottom) {
34862
+ var scrollAmount = dropdownBottom - containerBottom + 20;
34863
+ container.scrollTo({
34864
+ top: container.scrollTop + scrollAmount,
34865
+ behavior: 'smooth' });
34866
+
34867
+ }
34868
+ }
34855
34869
  }
34856
34870
  }
34857
34871
  }, [isOpen]);
@@ -37337,18 +37351,27 @@ Check the top-level render call using <` + t + ">.");
37337
37351
 
37338
37352
  var PhoneInputField = function (_a) {
37339
37353
  var onChange = _a.onChange,id = _a.id,label = _a.label,mandatory = _a.mandatory,value = _a.value,placeholder = _a.placeholder,_b = _a.initialCountry,initialCountry = _b === void 0 ? 'us' : _b,availableCountries = _a.availableCountries,_c = _a.forceDialCode,forceDialCode = _c === void 0 ? false : _c,props = __rest(_a, ["onChange", "id", "label", "mandatory", "value", "placeholder", "initialCountry", "availableCountries", "forceDialCode"]);
37354
+ var _d = React.useState(false),touched = _d[0],setTouched = _d[1];
37340
37355
  var countries = getDefaultCountries(availableCountries, initialCountry);
37341
- var _d = build.exports.usePhoneInput({
37356
+ var _e = build.exports.usePhoneInput({
37342
37357
  initialCountry: initialCountry,
37343
37358
  value: value,
37344
37359
  hideSpaceAfterDialCode: true,
37345
37360
  countries: countries,
37346
37361
  forceDialCode: forceDialCode,
37347
37362
  onPhoneUpdate: function (phone) {
37348
- onChange({ target: { value: phone } });
37363
+ if (touched && phone.length > 3) {
37364
+ onChange({ target: { value: phone } });
37365
+ } else
37366
+ {
37367
+ onChange({ target: { value: undefined } });
37368
+ }
37349
37369
  } }),
37350
- phone = _d.phone,handlePhoneValueChange = _d.handlePhoneValueChange,inputRef = _d.inputRef,country = _d.country,setCountry = _d.setCountry;
37370
+ phone = _e.phone,handlePhoneValueChange = _e.handlePhoneValueChange,inputRef = _e.inputRef,country = _e.country,setCountry = _e.setCountry;
37351
37371
  var handleInputChange = function (e) {
37372
+ if (!touched) {
37373
+ setTouched(true);
37374
+ }
37352
37375
  handlePhoneValueChange(e);
37353
37376
  };
37354
37377
  var handleCountrySelect = function (_a) {
@@ -48352,14 +48375,14 @@ var Kr=[{
48352
48375
  var availableCountries_1 = ((_h = (_g = config === null || config === void 0 ? void 0 : config.phone) === null || _g === void 0 ? void 0 : _g.available_countries) !== null && _h !== void 0 ? _h : []).
48353
48376
  map(function (c) {return c === null || c === void 0 ? void 0 : c.toLocaleLowerCase();}).
48354
48377
  filter(function (x) {return !lodash.exports.isNil(x);});
48355
- var initialCountry_1 = (_l = (_k = (_j = config === null || config === void 0 ? void 0 : config.phone) === null || _j === void 0 ? void 0 : _j.default_country) === null || _k === void 0 ? void 0 : _k.toLocaleLowerCase()) !== null && _l !== void 0 ? _l : 'gb';
48378
+ var initialCountry_1 = (_l = (_k = (_j = config === null || config === void 0 ? void 0 : config.phone) === null || _j === void 0 ? void 0 : _j.default_country) === null || _k === void 0 ? void 0 : _k.toLocaleLowerCase()) !== null && _l !== void 0 ? _l : 'us';
48356
48379
  return jsxRuntime.exports.jsx(Controller, { name: question.id, control: control, defaultValue: "", render: function (_a) {
48357
48380
  var _b;
48358
48381
  var _c = _a.field,onChange = _c.onChange,value = _c.value;
48359
48382
  return jsxRuntime.exports.jsx(PhoneInputField, { autoFocus: inputAutoFocus, onChange: function (e) {
48360
48383
  onChange(e.target.value);
48361
48384
  onAnswerChange();
48362
- }, label: question.title, id: question.id, value: value, mandatory: (_b = question.questionConfig) === null || _b === void 0 ? void 0 : _b.mandatory, availableCountries: availableCountries_1, initialCountry: initialCountry_1, forceDialCode: true });
48385
+ }, label: question.title, id: question.id, value: value !== null && value !== void 0 ? value : '', mandatory: (_b = question.questionConfig) === null || _b === void 0 ? void 0 : _b.mandatory, availableCountries: availableCountries_1, initialCountry: initialCountry_1, forceDialCode: true });
48363
48386
  } });
48364
48387
  case exports.UserQuestionType.Slider:
48365
48388
  return jsxRuntime.exports.jsx(Controller, { name: question.id, control: control, rules: {
@@ -48498,29 +48521,20 @@ var Kr=[{
48498
48521
  }) }));
48499
48522
  };
48500
48523
 
48501
- var useScrollHint = function (fixPosition) {
48502
- if (fixPosition === void 0) {fixPosition = false;}
48524
+ var useScrollHint = function () {
48503
48525
  var _a = React.useState(false),showScrollHint = _a[0],setShowScrollHint = _a[1];
48504
48526
  var rafIdRef = React.useRef();
48505
48527
  var checkScrollHint = React.useCallback(function () {
48506
- if (fixPosition) {
48507
- var isPageScrollable = document.documentElement.scrollHeight > window.innerHeight;
48508
- var isAtBottom = Math.ceil(window.scrollY + window.innerHeight) >=
48509
- document.documentElement.scrollHeight - 5;
48510
- setShowScrollHint(isPageScrollable && !isAtBottom);
48511
- } else
48512
- {
48513
- var mainContentEl = document.getElementById('ahp_main_content_with_scroll_hint');
48514
- if (!mainContentEl) {
48515
- setShowScrollHint(false);
48516
- return;
48517
- }
48518
- var isScrollable = mainContentEl.scrollHeight > mainContentEl.offsetHeight;
48519
- var isAtBottom = Math.ceil(mainContentEl.scrollTop + mainContentEl.offsetHeight) >=
48520
- mainContentEl.scrollHeight - 5;
48521
- setShowScrollHint(isScrollable && !isAtBottom);
48528
+ var mainContentEl = document.getElementById('ahp_main_content_with_scroll_hint');
48529
+ if (!mainContentEl) {
48530
+ setShowScrollHint(false);
48531
+ return;
48522
48532
  }
48523
- }, [fixPosition]);
48533
+ var isScrollable = mainContentEl.scrollHeight > mainContentEl.offsetHeight;
48534
+ var isAtBottom = Math.ceil(mainContentEl.scrollTop + mainContentEl.offsetHeight) >=
48535
+ mainContentEl.scrollHeight - 5;
48536
+ setShowScrollHint(isScrollable && !isAtBottom);
48537
+ }, []);
48524
48538
  var debouncedCheckScrollHint = React.useCallback(function () {
48525
48539
  if (rafIdRef.current) {
48526
48540
  cancelAnimationFrame(rafIdRef.current);
@@ -48532,52 +48546,31 @@ var Kr=[{
48532
48546
  var rafCheck = requestAnimationFrame(function () {
48533
48547
  checkScrollHint();
48534
48548
  });
48535
- if (fixPosition) {
48536
- window.addEventListener('resize', checkScrollHint);
48537
- window.addEventListener('scroll', checkScrollHint);
48538
- var mutationObserver_1 = new MutationObserver(debouncedCheckScrollHint);
48539
- mutationObserver_1.observe(document.body, {
48549
+ var mainContentEl = document.getElementById('ahp_main_content_with_scroll_hint');
48550
+ window.addEventListener('resize', checkScrollHint);
48551
+ if (mainContentEl) {
48552
+ mainContentEl.addEventListener('scroll', checkScrollHint);
48553
+ }
48554
+ var mutationObserver = new MutationObserver(debouncedCheckScrollHint);
48555
+ if (mainContentEl) {
48556
+ mutationObserver.observe(mainContentEl, {
48540
48557
  childList: true,
48541
48558
  subtree: true,
48542
48559
  attributes: false });
48543
48560
 
48544
- return function () {
48545
- cancelAnimationFrame(rafCheck);
48546
- if (rafIdRef.current) {
48547
- cancelAnimationFrame(rafIdRef.current);
48548
- }
48549
- window.removeEventListener('resize', checkScrollHint);
48550
- window.removeEventListener('scroll', checkScrollHint);
48551
- mutationObserver_1.disconnect();
48552
- };
48553
- } else
48554
- {
48555
- var mainContentEl_1 = document.getElementById('ahp_main_content_with_scroll_hint');
48556
- window.addEventListener('resize', checkScrollHint);
48557
- if (mainContentEl_1) {
48558
- mainContentEl_1.addEventListener('scroll', checkScrollHint);
48561
+ }
48562
+ return function () {
48563
+ cancelAnimationFrame(rafCheck);
48564
+ if (rafIdRef.current) {
48565
+ cancelAnimationFrame(rafIdRef.current);
48559
48566
  }
48560
- var mutationObserver_2 = new MutationObserver(debouncedCheckScrollHint);
48561
- if (mainContentEl_1) {
48562
- mutationObserver_2.observe(mainContentEl_1, {
48563
- childList: true,
48564
- subtree: true,
48565
- attributes: false });
48566
-
48567
+ window.removeEventListener('resize', checkScrollHint);
48568
+ if (mainContentEl) {
48569
+ mainContentEl.removeEventListener('scroll', checkScrollHint);
48567
48570
  }
48568
- return function () {
48569
- cancelAnimationFrame(rafCheck);
48570
- if (rafIdRef.current) {
48571
- cancelAnimationFrame(rafIdRef.current);
48572
- }
48573
- window.removeEventListener('resize', checkScrollHint);
48574
- if (mainContentEl_1) {
48575
- mainContentEl_1.removeEventListener('scroll', checkScrollHint);
48576
- }
48577
- mutationObserver_2.disconnect();
48578
- };
48579
- }
48580
- }, [fixPosition, checkScrollHint, debouncedCheckScrollHint]);
48571
+ mutationObserver.disconnect();
48572
+ };
48573
+ }, [checkScrollHint, debouncedCheckScrollHint]);
48581
48574
  return {
48582
48575
  showScrollHint: showScrollHint };
48583
48576
 
@@ -48587,7 +48580,7 @@ var Kr=[{
48587
48580
 
48588
48581
  var HostedPageFooter = function (_a) {
48589
48582
  var children = _a.children,_b = _a.hideScrollHint,hideScrollHint = _b === void 0 ? false : _b,_c = _a.fixPosition,fixPosition = _c === void 0 ? false : _c;
48590
- var showScrollHint = useScrollHint(fixPosition).showScrollHint;
48583
+ var showScrollHint = useScrollHint().showScrollHint;
48591
48584
  var footerClass = fixPosition ?
48592
48585
  "".concat(classes$7.footer, " ").concat(classes$7.fixed) :
48593
48586
  classes$7.footer;
@@ -49451,8 +49444,7 @@ var Kr=[{
49451
49444
 
49452
49445
  var TraditionalForm = function (_a) {
49453
49446
  var form = _a.form,onSubmit = _a.onSubmit,buttonLabels = _a.buttonLabels,evaluateDisplayConditions = _a.evaluateDisplayConditions,errorLabels = _a.errorLabels,storedAnswers = _a.storedAnswers,onAnswersChange = _a.onAnswersChange,_b = _a.autosaveAnswers,autosaveAnswers = _b === void 0 ? true : _b,questionLabels = _a.questionLabels,onFileUpload = _a.onFileUpload;
49454
- var _c = useTheme(),updateLayoutMode = _c.updateLayoutMode,resetLayoutMode = _c.resetLayoutMode;
49455
- var _d = useTraditionalForm({
49447
+ var _c = useTraditionalForm({
49456
49448
  questions: form.questions,
49457
49449
  onSubmit: onSubmit,
49458
49450
  evaluateDisplayConditions: evaluateDisplayConditions,
@@ -49460,13 +49452,7 @@ var Kr=[{
49460
49452
  storedAnswers: storedAnswers,
49461
49453
  autosaveAnswers: autosaveAnswers,
49462
49454
  onAnswersChange: onAnswersChange }),
49463
- updateQuestionVisibility = _d.updateQuestionVisibility,submitForm = _d.submitForm,isSubmittingForm = _d.isSubmittingForm,_e = _d.formMethods,control = _e.control,getValues = _e.getValues,errors = _d.errors,questionWithVisiblity = _d.questionWithVisiblity,formHasErrors = _d.formHasErrors;
49464
- React.useEffect(function () {
49465
- updateLayoutMode('flexible');
49466
- return function () {
49467
- resetLayoutMode();
49468
- };
49469
- });
49455
+ updateQuestionVisibility = _c.updateQuestionVisibility,submitForm = _c.submitForm,isSubmittingForm = _c.isSubmittingForm,_d = _c.formMethods,control = _d.control,getValues = _d.getValues,errors = _c.errors,questionWithVisiblity = _c.questionWithVisiblity,formHasErrors = _c.formHasErrors;
49470
49456
  return jsxRuntime.exports.jsxs(jsxRuntime.exports.Fragment, { children: [jsxRuntime.exports.jsx("main", __assign({ id: "ahp_main_content_with_scroll_hint", className: clsx(layoutClasses.main_content, classes$4.traditional_form) }, { children: jsxRuntime.exports.jsxs("div", __assign({ className: clsx(classes$4.container, classes$4.traditional_container) }, { children: [!questionWithVisiblity ? jsxRuntime.exports.jsx("div", __assign({ className: classes$4.loadingContainer }, { children: jsxRuntime.exports.jsx(LoadActivityPlaceholder, {}) })) : jsxRuntime.exports.jsx("div", { children: jsxRuntime.exports.jsx("div", { children: questionWithVisiblity.
49471
49457
  filter(function (vb) {return vb.visible;}).
49472
49458
  map(function (visibleQuestion) {return jsxRuntime.exports.jsx("div", __assign({ className: classes$4.traditional_form_question }, { children: jsxRuntime.exports.jsx(Question, { question: visibleQuestion, control: control, getValues: getValues, errors: errors, inputAutoFocus: false, onAnswerChange: updateQuestionVisibility, labels: questionLabels, onFileUpload: onFileUpload }, visibleQuestion.id) }), visibleQuestion.id);}) }) }), (form === null || form === void 0 ? void 0 : form.trademark) && jsxRuntime.exports.jsx("div", __assign({ className: classes$4.trademark }, { children: form.trademark }))] })) })), jsxRuntime.exports.jsx(HostedPageFooter, __assign({ fixPosition: true }, { children: jsxRuntime.exports.jsxs("div", __assign({ className: classes$4.traditional_button_wrapper }, { children: [formHasErrors && jsxRuntime.exports.jsx("div", { children: jsxRuntime.exports.jsx(Text, __assign({ variant: "textSmall", color: "var(--awell-signalError100)" }, { children: errorLabels.formHasErrors })) }), jsxRuntime.exports.jsx("div", {}), jsxRuntime.exports.jsx(Button, __assign({ onClick: submitForm, type: "submit", "data-cy": "submitFormButton", disabled: isSubmittingForm }, { children: buttonLabels.submit }))] })) }))] });
@@ -4,9 +4,9 @@ import { CountryIso2 } from 'react-international-phone';
4
4
  export interface PhoneInputFieldProps extends InputHTMLAttributes<HTMLInputElement> {
5
5
  label: string;
6
6
  id: string;
7
- onChange: ({ target: { value } }: {
7
+ onChange: ({ target: { value }, }: {
8
8
  target: {
9
- value: string;
9
+ value: string | undefined;
10
10
  };
11
11
  }) => void;
12
12
  onClick?: MouseEventHandler<HTMLInputElement>;
@@ -1,5 +1,5 @@
1
1
  interface UseScrollHintHook {
2
2
  showScrollHint: boolean;
3
3
  }
4
- export declare const useScrollHint: (fixPosition?: boolean) => UseScrollHintHook;
4
+ export declare const useScrollHint: () => UseScrollHintHook;
5
5
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awell-health/ui-library",
3
- "version": "0.1.111",
3
+ "version": "0.1.113",
4
4
  "description": "UI components to integrate with Awell Health",
5
5
  "repository": {
6
6
  "type": "git",