@bigbinary/neeto-form-frontend 2.0.0 → 2.0.1

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
@@ -1,7 +1,8 @@
1
1
  import * as React$2 from 'react';
2
2
  import React__default, { useState, useRef, useEffect, useContext, useLayoutEffect as useLayoutEffect$1, forwardRef, useImperativeHandle, Fragment, useReducer, useCallback as useCallback$1, useMemo as useMemo$1, createContext, createElement } from 'react';
3
+ import classnames from 'classnames';
3
4
  import { useFormikContext, useField, FieldArray, Form as Form$3, Formik, Field, FastField } from 'formik';
4
- import { filterNonNull, noop as noop$4, findBy, toLabelAndValue, isPresent as isPresent$1, truncate, humanize, isNotPresent, slugify, filterBy, removeBy, isNotEmpty, findById, notEqualsDeep } from '@bigbinary/neeto-cist';
5
+ import { filterNonNull, noop as noop$4, findBy, toLabelAndValue, isPresent as isPresent$1, truncate, humanize, slugify, filterBy, removeBy, isNotPresent, isNotEmpty, findById, notEqualsDeep } from '@bigbinary/neeto-cist';
5
6
  import { buildUrl, showThumbsUpToastr, withEventTargetValue, getQueryParams, dateFormat } from '@bigbinary/neeto-commons-frontend/utils';
6
7
  import PageLoader from '@bigbinary/neeto-molecules/PageLoader';
7
8
  import { assoc, mergeLeft, compose as compose$1, isEmpty, trim, useWith, path, split, either, isNil, values, equals, modify, prop, range, includes, __, reduce, reject, keys, pick, omit, pluck, without, difference, pipe as pipe$1, last, not, toLower, map, identity, clamp as clamp$2, isNotNil, filter as filter$1 } from 'ramda';
@@ -20,7 +21,6 @@ import MoreDropdown from '@bigbinary/neeto-molecules/MoreDropdown';
20
21
  import Typography from '@bigbinary/neetoui/Typography';
21
22
  import Dropdown from '@bigbinary/neetoui/Dropdown';
22
23
  import Tooltip from '@bigbinary/neetoui/Tooltip';
23
- import classnames from 'classnames';
24
24
  import Pane from '@bigbinary/neetoui/Pane';
25
25
  import Form$2 from '@bigbinary/neetoui/formik/Form';
26
26
  import Select from '@bigbinary/neetoui/formik/Select';
@@ -11567,13 +11567,6 @@ var getActiveQuestionKindDetails = function getActiveQuestionKindDetails(_ref) {
11567
11567
  var generateArray = function generateArray(start, end) {
11568
11568
  return range(start, end + 1);
11569
11569
  };
11570
- var isElementOverflowing = function isElementOverflowing(_ref2) {
11571
- var clientWidth = _ref2.clientWidth,
11572
- clientHeight = _ref2.clientHeight,
11573
- scrollWidth = _ref2.scrollWidth,
11574
- scrollHeight = _ref2.scrollHeight;
11575
- return scrollHeight > clientHeight || scrollWidth > clientWidth;
11576
- };
11577
11570
  var htmlToPlainText = function htmlToPlainText(htmlContent) {
11578
11571
  var formattedContent = htmlContent.replaceAll(EMPTY_PARAGRAPH_REGEX, "\n");
11579
11572
  var node = document.createElement("div");
@@ -11928,7 +11921,7 @@ var Overview = function Overview(_ref) {
11928
11921
  onLanguageChange = _ref.onLanguageChange,
11929
11922
  additionalActionOptions = _ref.additionalActionOptions;
11930
11923
  return /*#__PURE__*/React__default.createElement("div", {
11931
- className: "mb-6 flex-shrink-0 space-y-6"
11924
+ className: "neeto-form-nano-form-wrapper__overview mb-4 w-full flex-shrink-0 space-y-4 px-6 pt-6"
11932
11925
  }, /*#__PURE__*/React__default.createElement("div", {
11933
11926
  className: "flex items-center justify-between"
11934
11927
  }, /*#__PURE__*/React__default.createElement(Typography, {
@@ -12037,14 +12030,21 @@ var Drag = function Drag(props) {
12037
12030
  height: size,
12038
12031
  viewBox: "0 0 24 24",
12039
12032
  width: size
12040
- }, other), /*#__PURE__*/React__default.createElement("path", {
12041
- d: "M8.997 17.5c-.275 0-.5.225-.497.5 0 .275.225.5.5.5s.5-.225.5-.5-.225-.5-.503-.5zM14.497 17.5c-.275 0-.5.225-.497.5 0 .275.225.5.5.5s.5-.225.5-.5-.225-.5-.503-.5zM8.997 11.5c-.275 0-.5.225-.497.5 0 .275.225.5.5.5s.5-.225.5-.5-.225-.5-.503-.5zM14.497 11.5c-.275 0-.5.225-.497.5 0 .275.225.5.5.5s.5-.225.5-.5-.225-.5-.503-.5zM8.997 5.5c-.275 0-.5.225-.497.5 0 .275.225.5.5.5s.5-.225.5-.5-.225-.5-.503-.5zM14.497 5.5c-.275 0-.5.225-.497.5 0 .275.225.5.5.5s.5-.225.5-.5-.225-.5-.503-.5z",
12033
+ }, other), /*#__PURE__*/React__default.createElement("g", {
12034
+ clipPath: "url(#clip0_6290_43)",
12042
12035
  fill: color,
12043
12036
  stroke: color,
12044
12037
  strokeLinecap: "round",
12045
12038
  strokeLinejoin: "round",
12046
12039
  strokeWidth: "1.5"
12047
- }));
12040
+ }, /*#__PURE__*/React__default.createElement("path", {
12041
+ d: "M8 12a1 1 0 102 0 1 1 0 00-2 0zM8 18a1 1 0 102 0 1 1 0 00-2 0zM8 6a1 1 0 102 0 1 1 0 00-2 0zM14 12a1 1 0 102 0 1 1 0 00-2 0zM14 18a1 1 0 102 0 1 1 0 00-2 0zM14 6a1 1 0 102 0 1 1 0 00-2 0z"
12042
+ })), /*#__PURE__*/React__default.createElement("defs", null, /*#__PURE__*/React__default.createElement("clipPath", {
12043
+ id: "clip0_6290_43"
12044
+ }, /*#__PURE__*/React__default.createElement("path", {
12045
+ d: "M0 0H24V24H0z",
12046
+ fill: color
12047
+ }))));
12048
12048
  };
12049
12049
  Drag.defaultProps = {
12050
12050
  color: "currentColor",
@@ -12077,11 +12077,6 @@ var Card = function Card(_ref) {
12077
12077
  onEdit = _ref.onEdit,
12078
12078
  onClone = _ref.onClone,
12079
12079
  onDelete = _ref.onDelete;
12080
- var _useState = useState(false),
12081
- _useState2 = _slicedToArray$3(_useState, 2),
12082
- isTooltipEnabled = _useState2[0],
12083
- setIsTooltipEnabled = _useState2[1];
12084
- var questionLabelRef = useRef(null);
12085
12080
  var _useTranslation = useTranslation(),
12086
12081
  t = _useTranslation.t;
12087
12082
  var _getActiveKindDetails = getActiveKindDetails({
@@ -12092,34 +12087,27 @@ var Card = function Card(_ref) {
12092
12087
  label = _getActiveKindDetails.label,
12093
12088
  isSingular = _getActiveKindDetails.isSingular;
12094
12089
  var questionLabel = isRichTextQuestion(kind) ? htmlToPlainText(label) : label;
12095
- useEffect(function () {
12096
- var element = questionLabelRef.current;
12097
- if (isNotPresent(element)) return;
12098
- setIsTooltipEnabled(isElementOverflowing(element));
12099
- }, [questionLabel]);
12100
12090
  return /*#__PURE__*/React__default.createElement("div", {
12101
12091
  "data-cy": "neeto-form-engine-".concat(slugify(questionLabel)),
12102
- className: classnames("neeto-ui-rounded neeto-ui-border-gray-300 flex h-10 w-full items-center justify-between border p-2", {
12103
- "neeto-ui-border-primary-500 border-2": isActive
12092
+ className: classnames("neeto-ui-rounded neeto-ui-border-gray-300 neeto-ui-bg-white neeto-form-nano-form__card flex h-10 w-full items-center justify-between border p-2", {
12093
+ "neeto-ui-border-primary-500 neeto-form-nano-form__card--active": isActive
12104
12094
  }),
12105
12095
  onClick: function onClick() {
12106
12096
  return onSelect(question);
12107
12097
  }
12108
12098
  }, /*#__PURE__*/React__default.createElement("div", {
12109
- className: "flex items-center justify-between space-x-2"
12099
+ className: "flex min-w-0 flex-grow items-center gap-1"
12110
12100
  }, /*#__PURE__*/React__default.createElement(Drag, {
12111
- className: "flex-shrink-0 cursor-move"
12112
- }), /*#__PURE__*/React__default.createElement(Tooltip, {
12113
- content: questionLabel,
12114
- disabled: !isTooltipEnabled,
12115
- position: "top"
12116
- }, /*#__PURE__*/React__default.createElement(Typography, {
12117
- className: "max-w-md truncate",
12118
- lineHeight: "neeto-ui-leading-tight",
12119
- ref: questionLabelRef,
12120
- style: "h5",
12121
- weight: "neeto-ui-font-medium"
12122
- }, questionLabel))), /*#__PURE__*/React__default.createElement(MoreDropdown, {
12101
+ className: "neeto-ui-text-gray-600 flex-shrink-0"
12102
+ }), /*#__PURE__*/React__default.createElement(Typography, {
12103
+ className: "line-clamp-2 min-w-0 flex-grow truncate break-words",
12104
+ lineHeight: "snug",
12105
+ style: "body2",
12106
+ weight: "medium"
12107
+ }, questionLabel)), /*#__PURE__*/React__default.createElement(MoreDropdown, {
12108
+ dropdownButtonProps: {
12109
+ className: "shrink-0"
12110
+ },
12123
12111
  dropdownProps: {
12124
12112
  strategy: "fixed"
12125
12113
  },
@@ -13455,7 +13443,7 @@ var Form = function Form(_ref) {
13455
13443
  return setIsDeleteAlertOpen(false);
13456
13444
  }
13457
13445
  }), /*#__PURE__*/React__default.createElement(Form$3, _extends$8({
13458
- className: "flex h-full flex-col"
13446
+ className: "neeto-form-nano-form-wrapper flex h-full flex-col"
13459
13447
  }, formDomProps, {
13460
13448
  noValidate: true
13461
13449
  }), formTitle && /*#__PURE__*/React__default.createElement(Overview, {
@@ -13466,7 +13454,7 @@ var Form = function Form(_ref) {
13466
13454
  title: formTitle,
13467
13455
  onLanguageChange: handleLanguageChange
13468
13456
  }), /*#__PURE__*/React__default.createElement("div", {
13469
- className: "w-full flex-grow space-y-6 overflow-y-auto"
13457
+ className: "neeto-form-nano-form-wrapper__body min-h-0 w-full flex-grow space-y-6 overflow-y-auto px-6 pb-6"
13470
13458
  }, hasActiveQuestions ? /*#__PURE__*/React__default.createElement("div", {
13471
13459
  className: "space-y-6",
13472
13460
  ref: containerRef
@@ -13502,7 +13490,7 @@ var Form = function Form(_ref) {
13502
13490
  isDisabled: isEmpty(availableQuestionKinds),
13503
13491
  onAdd: handleAdd
13504
13492
  }))), (showActionBlock || dirty) && /*#__PURE__*/React__default.createElement("div", {
13505
- className: "neeto-ui-border-gray-300 flex flex-shrink-0 justify-end border-t p-6"
13493
+ className: "neeto-ui-border-gray-300 neeto-form-nano-form-wrapper__footer flex flex-shrink-0 justify-end border-t px-6 py-4"
13506
13494
  }, /*#__PURE__*/React__default.createElement(ActionBlock, {
13507
13495
  submitButtonProps: submitButtonProps,
13508
13496
  isSubmitting: isReordering,
@@ -13574,7 +13562,8 @@ var BuildForm = function BuildForm(_ref) {
13574
13562
  onLanguageChange = _ref$onLanguageChange === void 0 ? noop$4 : _ref$onLanguageChange,
13575
13563
  _ref$additionalAction = _ref.additionalActionOptions,
13576
13564
  additionalActionOptions = _ref$additionalAction === void 0 ? [] : _ref$additionalAction,
13577
- additionalQuestionKindPattern = _ref.additionalQuestionKindPattern;
13565
+ additionalQuestionKindPattern = _ref.additionalQuestionKindPattern,
13566
+ className = _ref.className;
13578
13567
  var queryClient = useQueryClient();
13579
13568
  var _useReorderQuestions = useReorderQuestions(id, {
13580
13569
  onSuccess: showThumbsUpToastr
@@ -13647,7 +13636,7 @@ var BuildForm = function BuildForm(_ref) {
13647
13636
  type: QUESTION_KIND.ADDITIONAL_GUESTS.value
13648
13637
  }, QUESTION_KINDS);
13649
13638
  return /*#__PURE__*/React__default.createElement("div", {
13650
- className: "relative h-full"
13639
+ className: classnames("neeto-form-nano-form-outer-wrapper relative", className)
13651
13640
  }, /*#__PURE__*/React__default.createElement(Formik, {
13652
13641
  enableReinitialize: true,
13653
13642
  initialValues: {
@@ -13690,7 +13679,7 @@ var BuildForm = function BuildForm(_ref) {
13690
13679
  }
13691
13680
  }));
13692
13681
  }), isQuestionsLoading && /*#__PURE__*/React__default.createElement("div", {
13693
- className: "neeto-ui-bg-gray-100 absolute bottom-0 left-0 right-0 top-0 flex items-center justify-center opacity-75"
13682
+ className: "neeto-ui-bg-white absolute inset-0 flex items-center justify-center"
13694
13683
  }, /*#__PURE__*/React__default.createElement(PageLoader, null)));
13695
13684
  };
13696
13685