@awell-health/ui-library 0.1.111 → 0.1.112

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
@@ -48498,29 +48498,20 @@ var Kr=[{
48498
48498
  }) }));
48499
48499
  };
48500
48500
 
48501
- var useScrollHint = function (fixPosition) {
48502
- if (fixPosition === void 0) {fixPosition = false;}
48501
+ var useScrollHint = function () {
48503
48502
  var _a = React.useState(false),showScrollHint = _a[0],setShowScrollHint = _a[1];
48504
48503
  var rafIdRef = React.useRef();
48505
48504
  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);
48505
+ var mainContentEl = document.getElementById('ahp_main_content_with_scroll_hint');
48506
+ if (!mainContentEl) {
48507
+ setShowScrollHint(false);
48508
+ return;
48522
48509
  }
48523
- }, [fixPosition]);
48510
+ var isScrollable = mainContentEl.scrollHeight > mainContentEl.offsetHeight;
48511
+ var isAtBottom = Math.ceil(mainContentEl.scrollTop + mainContentEl.offsetHeight) >=
48512
+ mainContentEl.scrollHeight - 5;
48513
+ setShowScrollHint(isScrollable && !isAtBottom);
48514
+ }, []);
48524
48515
  var debouncedCheckScrollHint = React.useCallback(function () {
48525
48516
  if (rafIdRef.current) {
48526
48517
  cancelAnimationFrame(rafIdRef.current);
@@ -48532,52 +48523,31 @@ var Kr=[{
48532
48523
  var rafCheck = requestAnimationFrame(function () {
48533
48524
  checkScrollHint();
48534
48525
  });
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, {
48526
+ var mainContentEl = document.getElementById('ahp_main_content_with_scroll_hint');
48527
+ window.addEventListener('resize', checkScrollHint);
48528
+ if (mainContentEl) {
48529
+ mainContentEl.addEventListener('scroll', checkScrollHint);
48530
+ }
48531
+ var mutationObserver = new MutationObserver(debouncedCheckScrollHint);
48532
+ if (mainContentEl) {
48533
+ mutationObserver.observe(mainContentEl, {
48540
48534
  childList: true,
48541
48535
  subtree: true,
48542
48536
  attributes: false });
48543
48537
 
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);
48538
+ }
48539
+ return function () {
48540
+ cancelAnimationFrame(rafCheck);
48541
+ if (rafIdRef.current) {
48542
+ cancelAnimationFrame(rafIdRef.current);
48559
48543
  }
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
-
48544
+ window.removeEventListener('resize', checkScrollHint);
48545
+ if (mainContentEl) {
48546
+ mainContentEl.removeEventListener('scroll', checkScrollHint);
48567
48547
  }
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]);
48548
+ mutationObserver.disconnect();
48549
+ };
48550
+ }, [checkScrollHint, debouncedCheckScrollHint]);
48581
48551
  return {
48582
48552
  showScrollHint: showScrollHint };
48583
48553
 
@@ -48587,7 +48557,7 @@ var Kr=[{
48587
48557
 
48588
48558
  var HostedPageFooter = function (_a) {
48589
48559
  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;
48560
+ var showScrollHint = useScrollHint().showScrollHint;
48591
48561
  var footerClass = fixPosition ?
48592
48562
  "".concat(classes$7.footer, " ").concat(classes$7.fixed) :
48593
48563
  classes$7.footer;
@@ -49451,8 +49421,7 @@ var Kr=[{
49451
49421
 
49452
49422
  var TraditionalForm = function (_a) {
49453
49423
  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({
49424
+ var _c = useTraditionalForm({
49456
49425
  questions: form.questions,
49457
49426
  onSubmit: onSubmit,
49458
49427
  evaluateDisplayConditions: evaluateDisplayConditions,
@@ -49460,13 +49429,7 @@ var Kr=[{
49460
49429
  storedAnswers: storedAnswers,
49461
49430
  autosaveAnswers: autosaveAnswers,
49462
49431
  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
- });
49432
+ 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
49433
  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
49434
  filter(function (vb) {return vb.visible;}).
49472
49435
  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 }))] })) }))] });
@@ -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.112",
4
4
  "description": "UI components to integrate with Awell Health",
5
5
  "repository": {
6
6
  "type": "git",