@bigbinary/neeto-rules-frontend 2.7.6 → 2.7.8

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 (68) hide show
  1. package/app/javascript/src/translations/ar.json +6 -3
  2. package/app/javascript/src/translations/bg.json +6 -3
  3. package/app/javascript/src/translations/ca.json +6 -3
  4. package/app/javascript/src/translations/cs.json +6 -3
  5. package/app/javascript/src/translations/da.json +6 -3
  6. package/app/javascript/src/translations/de.json +6 -3
  7. package/app/javascript/src/translations/en.json +4 -1
  8. package/app/javascript/src/translations/es-MX.json +6 -3
  9. package/app/javascript/src/translations/es.json +6 -3
  10. package/app/javascript/src/translations/et.json +6 -3
  11. package/app/javascript/src/translations/fi.json +6 -3
  12. package/app/javascript/src/translations/fil.json +6 -3
  13. package/app/javascript/src/translations/fr.json +6 -3
  14. package/app/javascript/src/translations/he.json +6 -3
  15. package/app/javascript/src/translations/hi.json +6 -3
  16. package/app/javascript/src/translations/hr.json +6 -3
  17. package/app/javascript/src/translations/hu.json +6 -3
  18. package/app/javascript/src/translations/id.json +6 -3
  19. package/app/javascript/src/translations/it.json +6 -3
  20. package/app/javascript/src/translations/ja.json +6 -3
  21. package/app/javascript/src/translations/ko.json +6 -3
  22. package/app/javascript/src/translations/nl.json +6 -3
  23. package/app/javascript/src/translations/pl.json +6 -3
  24. package/app/javascript/src/translations/pt-BR.json +6 -3
  25. package/app/javascript/src/translations/pt.json +6 -3
  26. package/app/javascript/src/translations/ro.json +6 -3
  27. package/app/javascript/src/translations/ru.json +6 -3
  28. package/app/javascript/src/translations/sk.json +6 -3
  29. package/app/javascript/src/translations/sl.json +6 -3
  30. package/app/javascript/src/translations/sv.json +6 -3
  31. package/app/javascript/src/translations/th.json +6 -3
  32. package/app/javascript/src/translations/tr.json +6 -3
  33. package/app/javascript/src/translations/uk.json +6 -3
  34. package/app/javascript/src/translations/vi.json +6 -3
  35. package/app/javascript/src/translations/zh-CN.json +6 -3
  36. package/app/javascript/src/translations/zh-TW.json +6 -3
  37. package/dist/.ready +1 -1
  38. package/dist/NeetoRulesBuilder.js +168 -101
  39. package/dist/NeetoRulesBuilder.js.map +1 -1
  40. package/dist/NeetoRulesForm.js +2 -2
  41. package/dist/cjs/NeetoRulesBuilder.js +187 -101
  42. package/dist/cjs/NeetoRulesBuilder.js.map +1 -1
  43. package/dist/cjs/NeetoRulesForm.js +2 -2
  44. package/dist/cjs/index.js +2 -2
  45. package/dist/cjs/v2/NeetoRulesBuilder.js +2 -2
  46. package/dist/cjs/v2/NeetoRulesForm.js +2 -2
  47. package/dist/cjs/v2/index.js +2 -2
  48. package/dist/{index-DFg6NbA-.js → index-7Oqmz32n.js} +2 -2
  49. package/dist/{index-DFg6NbA-.js.map → index-7Oqmz32n.js.map} +1 -1
  50. package/dist/{index-BTE3mSY7.js → index-BL9TdE9q.js} +2 -2
  51. package/dist/{index-BTE3mSY7.js.map → index-BL9TdE9q.js.map} +1 -1
  52. package/dist/{index-qw90tLi9.js → index-C9u2JDEa.js} +41 -8
  53. package/dist/index-C9u2JDEa.js.map +1 -0
  54. package/dist/{index-Df_k2p4V.js → index-Co-qUEtS.js} +42 -7
  55. package/dist/index-Co-qUEtS.js.map +1 -0
  56. package/dist/index.js +2 -2
  57. package/dist/keyboardShortcuts-DcvmDX_K.js +88 -0
  58. package/dist/{keyboardShortcuts-BvIE6AHg.js.map → keyboardShortcuts-DcvmDX_K.js.map} +1 -1
  59. package/dist/keyboardShortcuts-Dg7lUOmj.js +92 -0
  60. package/dist/{keyboardShortcuts-NxcrOxzv.js.map → keyboardShortcuts-Dg7lUOmj.js.map} +1 -1
  61. package/dist/v2/NeetoRulesBuilder.js +2 -2
  62. package/dist/v2/NeetoRulesForm.js +2 -2
  63. package/dist/v2/index.js +2 -2
  64. package/package.json +1 -1
  65. package/dist/index-Df_k2p4V.js.map +0 -1
  66. package/dist/index-qw90tLi9.js.map +0 -1
  67. package/dist/keyboardShortcuts-BvIE6AHg.js +0 -88
  68. package/dist/keyboardShortcuts-NxcrOxzv.js +0 -92
@@ -1,6 +1,6 @@
1
1
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
2
  import _objectDestructuringEmpty from '@babel/runtime/helpers/objectDestructuringEmpty';
3
- import './keyboardShortcuts-BvIE6AHg.js';
3
+ import './keyboardShortcuts-DcvmDX_K.js';
4
4
  import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
5
5
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
6
6
  import { useShallow } from 'zustand/shallow';
@@ -15,7 +15,7 @@ import { u as useUtilityStore } from './useUtilityStore-CCUYS1mS.js';
15
15
  import classNames from 'classnames';
16
16
  import Typography from '@bigbinary/neetoui/Typography';
17
17
  import { isNotNil, isEmpty, pluck } from 'ramda';
18
- import { g as getActionOptions, a as getFieldDetails, b as getSlackChannelErrors, c as getOptionsKey, d as getActionLabel, A as ActionSubItem, F as FIELDS_WITH_OPTIONS, P as PANEL_TYPES, D as DEFAULT_RULE_ACTION, e as getLogicalOperatorOptions, f as getFieldDetails$1, h as getVerbOptions, R as RadioField$1, S as SelectField$1, V as ValueField, i as DEFAULT_DELAY, j as getAllEvents, O as OPERATORS$1, k as STATUS_KEYS, l as formatData, u as usePollRuleName, T as TouchErrors, m as buildPayload, n as ScrollToErrorField, o as Panel, p as getValidationSchema, q as DEFAULT_INITIAL_VALUE } from './index-qw90tLi9.js';
18
+ import { g as getActionOptions, a as getFieldDetails, b as getSlackChannelErrors, c as getOptionsKey, d as getActionLabel, A as ActionSubItem, F as FIELDS_WITH_OPTIONS, P as PANEL_TYPES, D as DEFAULT_RULE_ACTION, e as getLogicalOperatorOptions, f as getFieldDetails$1, h as getVerbOptions, R as RadioField$1, S as SelectField$1, V as ValueField, i as DEFAULT_DELAY, j as getAllEvents, O as OPERATORS$1, k as STATUS_KEYS, l as formatData, u as usePollRuleName, T as TouchErrors, m as buildPayload, n as ScrollToErrorField, o as Panel, p as getValidationSchema, q as DEFAULT_INITIAL_VALUE } from './index-C9u2JDEa.js';
19
19
  import { a as useActiveField, u as useCustomDataStore } from './useCustomDataStore-BtKYtLVc.js';
20
20
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
21
21
  import { joinHyphenCase } from '@bigbinary/neeto-commons-frontend/utils';
@@ -2,7 +2,7 @@
2
2
 
3
3
  var _defineProperty = require('@babel/runtime/helpers/defineProperty');
4
4
  var _objectDestructuringEmpty = require('@babel/runtime/helpers/objectDestructuringEmpty');
5
- var keyboardShortcuts = require('../keyboardShortcuts-NxcrOxzv.js');
5
+ var keyboardShortcuts = require('../keyboardShortcuts-Dg7lUOmj.js');
6
6
  var shallow = require('zustand/shallow');
7
7
  var react = require('react');
8
8
  var classNames = require('classnames');
@@ -13,7 +13,7 @@ var Header = require('@bigbinary/neeto-molecules/Header');
13
13
  var Spinner = require('@bigbinary/neetoui/Spinner');
14
14
  var ActionBlock = require('@bigbinary/neetoui/formik/ActionBlock');
15
15
  var reactI18next = require('react-i18next');
16
- var index = require('../index-Df_k2p4V.js');
16
+ var index = require('../index-Co-qUEtS.js');
17
17
  var useCustomDataStore = require('../useCustomDataStore-DxFx8aCf.js');
18
18
  var useUtilityStore = require('../useUtilityStore-C_U20IMX.js');
19
19
  var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
@@ -25,6 +25,7 @@ var Delete = require('@bigbinary/neeto-icons/Delete');
25
25
  var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
26
26
  var jsxRuntime = require('react/jsx-runtime');
27
27
  var i18next = require('i18next');
28
+ var yup = require('yup');
28
29
  var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
29
30
  var _asyncToGenerator = require('@babel/runtime/helpers/asyncToGenerator');
30
31
  var Search = require('@bigbinary/neeto-icons/Search');
@@ -48,7 +49,6 @@ require('../useAutomationRulesApi-C1T2E1AN.js');
48
49
  require('@tanstack/react-query');
49
50
  require('axios');
50
51
  require('../index-DFwPrb81.js');
51
- require('yup');
52
52
  require('@bigbinary/neetoui/formik/Radio');
53
53
  require('@bigbinary/neetoui/managers');
54
54
  require('@bigbinary/neeto-icons/Close');
@@ -77,6 +77,25 @@ require('@bigbinary/neetoui/TimePicker');
77
77
  require('@bigbinary/neeto-editor/utils');
78
78
  require('zustand');
79
79
 
80
+ function _interopNamespaceDefault(e) {
81
+ var n = Object.create(null);
82
+ if (e) {
83
+ Object.keys(e).forEach(function (k) {
84
+ if (k !== 'default') {
85
+ var d = Object.getOwnPropertyDescriptor(e, k);
86
+ Object.defineProperty(n, k, d.get ? d : {
87
+ enumerable: true,
88
+ get: function () { return e[k]; }
89
+ });
90
+ }
91
+ });
92
+ }
93
+ n.default = e;
94
+ return Object.freeze(n);
95
+ }
96
+
97
+ var yup__namespace = /*#__PURE__*/_interopNamespaceDefault(yup);
98
+
80
99
  var _TOKEN_TO_PANEL_TYPE;
81
100
  var PARAM_KIND = {
82
101
  ENUM_SINGLE: "enum-single",
@@ -104,6 +123,22 @@ var TIME_UNITS = [{
104
123
  /* eslint-enable @bigbinary/neeto/neetocommons-tips */
105
124
 
106
125
  var LEAD_TIME_UNITS = TIME_UNITS;
126
+
127
+ // Mirrors the classic form's three-digit input cap; 999 days equals the
128
+ // backend's maximum lead time.
129
+ var MAX_LEAD_TIME_VALUE = 999;
130
+ var STEPPER_DELTA = {
131
+ INCREMENT: 1,
132
+ DECREMENT: -1
133
+ };
134
+ var STEPPER_MIN_VALUE = 1;
135
+ var DEFAULT_DELAY_VALUE = 10;
136
+
137
+ // Matches the token flash animation duration in sentence-builder.css.
138
+ var FLASH_DURATION_MS = 2200;
139
+
140
+ // Keeps an element out of the keyboard tab order (HTML tabindex sentinel).
141
+ var SKIP_TAB_INDEX = -1;
107
142
  var CONDITION_VERBS = {
108
143
  IS: "is",
109
144
  IS_NOT: "is_not",
@@ -565,6 +600,25 @@ var partsToMinutes = function partsToMinutes(_ref19) {
565
600
  (Number(value) || 0) * (UNIT_MINUTES[unit] || 1)
566
601
  );
567
602
  };
603
+ var leadTimeExceedsMax = function leadTimeExceedsMax(minutes) {
604
+ return minutesToParts(minutes).value > MAX_LEAD_TIME_VALUE;
605
+ };
606
+ var leadTimeValidationSchema = function leadTimeValidationSchema(schema) {
607
+ var _schema$triggers2;
608
+ var fieldKey = schema === null || schema === void 0 || (_schema$triggers2 = schema.triggers) === null || _schema$triggers2 === void 0 || (_schema$triggers2 = _schema$triggers2.leadTime) === null || _schema$triggers2 === void 0 ? void 0 : _schema$triggers2.fieldKey;
609
+ if (!fieldKey) return yup__namespace.object();
610
+ return yup__namespace.object().shape(_defineProperty({}, fieldKey, yup__namespace.object().shape({
611
+ // yup 0.32 can only concat schemas of the same type, and the host's
612
+ // generic field schema for the lead time key is a string schema.
613
+ value: yup__namespace.string().test("max-lead-time", function () {
614
+ return i18next.t("neetoRules.validations.maxLeadTime", {
615
+ max: MAX_LEAD_TIME_VALUE
616
+ });
617
+ }, function (minutes) {
618
+ return !leadTimeExceedsMax(minutes);
619
+ })
620
+ })));
621
+ };
568
622
  var leadTimeLabel = function leadTimeLabel(minutes) {
569
623
  var _minutesToParts = minutesToParts(minutes),
570
624
  value = _minutesToParts.value,
@@ -605,15 +659,15 @@ var asArray = function asArray(maybeArray) {
605
659
  return Array.isArray(maybeArray) ? maybeArray : [];
606
660
  };
607
661
  var fieldKeysFromSchema = function fieldKeysFromSchema() {
608
- var _schema$triggers2, _schema$actor2, _schema$conditions3, _schema$actions3, _schema$delay, _schema$triggers3, _schema$scope2;
662
+ var _schema$triggers3, _schema$actor2, _schema$conditions3, _schema$actions3, _schema$delay, _schema$triggers4, _schema$scope2;
609
663
  var schema = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
610
664
  return {
611
- triggers: ((_schema$triggers2 = schema.triggers) === null || _schema$triggers2 === void 0 ? void 0 : _schema$triggers2.fieldKey) || "events",
665
+ triggers: ((_schema$triggers3 = schema.triggers) === null || _schema$triggers3 === void 0 ? void 0 : _schema$triggers3.fieldKey) || "events",
612
666
  performer: ((_schema$actor2 = schema.actor) === null || _schema$actor2 === void 0 ? void 0 : _schema$actor2.fieldKey) || "performer",
613
667
  conditions: ((_schema$conditions3 = schema.conditions) === null || _schema$conditions3 === void 0 ? void 0 : _schema$conditions3.fieldKey) || "conditions",
614
668
  actions: ((_schema$actions3 = schema.actions) === null || _schema$actions3 === void 0 ? void 0 : _schema$actions3.fieldKey) || "actions",
615
669
  delay: ((_schema$delay = schema.delay) === null || _schema$delay === void 0 ? void 0 : _schema$delay.fieldKey) || "execution_delay",
616
- leadTime: (_schema$triggers3 = schema.triggers) === null || _schema$triggers3 === void 0 || (_schema$triggers3 = _schema$triggers3.leadTime) === null || _schema$triggers3 === void 0 ? void 0 : _schema$triggers3.fieldKey,
670
+ leadTime: (_schema$triggers4 = schema.triggers) === null || _schema$triggers4 === void 0 || (_schema$triggers4 = _schema$triggers4.leadTime) === null || _schema$triggers4 === void 0 ? void 0 : _schema$triggers4.fieldKey,
617
671
  scope: ((_schema$scope2 = schema.scope) === null || _schema$scope2 === void 0 ? void 0 : _schema$scope2.fieldKey) || "meetingIds",
618
672
  status: "status",
619
673
  name: "name"
@@ -1639,6 +1693,10 @@ var WhenBlock = function WhenBlock(_ref) {
1639
1693
  type: BUILDER_ANCHORS.TRIGGER_LEAD_TIME,
1640
1694
  index: index
1641
1695
  }),
1696
+ invalid: isInvalid({
1697
+ type: BUILDER_ANCHORS.TRIGGER_LEAD_TIME,
1698
+ index: index
1699
+ }),
1642
1700
  onClick: handleToken && function () {
1643
1701
  return handleToken({
1644
1702
  type: BUILDER_ANCHORS.TRIGGER_LEAD_TIME,
@@ -2684,7 +2742,7 @@ var applyPreview = function applyPreview(_ref19) {
2684
2742
  function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2685
2743
  function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2686
2744
  var Canvas = function Canvas(_ref) {
2687
- var _schema$scope, _schema$scope2, _schema$conditions, _schema$triggers, _schema$delay, _schema$meta$showName, _schema$meta;
2745
+ var _schema$scope, _schema$conditions, _schema$triggers, _schema$delay, _schema$meta$showName, _schema$meta;
2688
2746
  var schema = _ref.schema;
2689
2747
  var _useTranslation = reactI18next.useTranslation(),
2690
2748
  t = _useTranslation.t;
@@ -2750,7 +2808,7 @@ var Canvas = function Canvas(_ref) {
2750
2808
  setFlashing(true);
2751
2809
  var timer = setTimeout(function () {
2752
2810
  return setFlashing(false);
2753
- }, 2200);
2811
+ }, FLASH_DURATION_MS);
2754
2812
  return function () {
2755
2813
  return clearTimeout(timer);
2756
2814
  };
@@ -2804,6 +2862,10 @@ var Canvas = function Canvas(_ref) {
2804
2862
  prefix: "".concat(actorKey, ".value")
2805
2863
  });
2806
2864
  }
2865
+ case BUILDER_ANCHORS.TRIGGER_LEAD_TIME:
2866
+ return hasErrorAt({
2867
+ prefix: "".concat(fieldKeys.leadTime, ".value")
2868
+ });
2807
2869
  case BUILDER_ANCHORS.COND_FIELD:
2808
2870
  return hasErrorAt({
2809
2871
  prefix: "".concat(fieldKeys.conditions, ".value.").concat(index, ".field")
@@ -2898,8 +2960,6 @@ var Canvas = function Canvas(_ref) {
2898
2960
  return (action === null || action === void 0 ? void 0 : action.channel) || (action === null || action === void 0 ? void 0 : action.name);
2899
2961
  });
2900
2962
  var isScopeEnabled = (schema === null || schema === void 0 || (_schema$scope = schema.scope) === null || _schema$scope === void 0 ? void 0 : _schema$scope.enabled) && isTriggerSet && hasAction;
2901
- var isScopeComplete = !(schema !== null && schema !== void 0 && (_schema$scope2 = schema.scope) !== null && _schema$scope2 !== void 0 && _schema$scope2.enabled) || neetoCist.isNotEmpty(rule.scope || []);
2902
- var isComplete = isRuleComplete(rule) && isScopeComplete;
2903
2963
  var handleRemoveScope = function handleRemoveScope(index) {
2904
2964
  closePaneIfTargeting({
2905
2965
  anchors: [BUILDER_ANCHORS.SCOPE_PHONE_FIELD],
@@ -3031,24 +3091,22 @@ var Canvas = function Canvas(_ref) {
3031
3091
  onRemoveScope: handleRemoveScope,
3032
3092
  onToken: openPane
3033
3093
  })]
3034
- }), isComplete && /*#__PURE__*/jsxRuntime.jsxs(react.Fragment, {
3035
- children: [/*#__PURE__*/jsxRuntime.jsx(Connector, {
3036
- active: true
3037
- }), /*#__PURE__*/jsxRuntime.jsx(MetaBlock, {
3038
- rule: rule,
3039
- isInvalid: isInvalid({
3094
+ }), /*#__PURE__*/jsxRuntime.jsx(Connector, {
3095
+ active: true
3096
+ }), /*#__PURE__*/jsxRuntime.jsx(MetaBlock, {
3097
+ rule: rule,
3098
+ isInvalid: isInvalid({
3099
+ type: BUILDER_ANCHORS.META_NAME
3100
+ }),
3101
+ showName: (_schema$meta$showName = schema === null || schema === void 0 || (_schema$meta = schema.meta) === null || _schema$meta === void 0 ? void 0 : _schema$meta.showName) !== null && _schema$meta$showName !== void 0 ? _schema$meta$showName : true,
3102
+ onEditName: function onEditName() {
3103
+ return openPane({
3040
3104
  type: BUILDER_ANCHORS.META_NAME
3041
- }),
3042
- showName: (_schema$meta$showName = schema === null || schema === void 0 || (_schema$meta = schema.meta) === null || _schema$meta === void 0 ? void 0 : _schema$meta.showName) !== null && _schema$meta$showName !== void 0 ? _schema$meta$showName : true,
3043
- onEditName: function onEditName() {
3044
- return openPane({
3045
- type: BUILDER_ANCHORS.META_NAME
3046
- });
3047
- },
3048
- onToggleActive: function onToggleActive(event) {
3049
- return setActive(event.target.checked);
3050
- }
3051
- })]
3105
+ });
3106
+ },
3107
+ onToggleActive: function onToggleActive(event) {
3108
+ return setActive(event.target.checked);
3109
+ }
3052
3110
  })]
3053
3111
  })
3054
3112
  });
@@ -3508,19 +3566,14 @@ var ConfigPane = function ConfigPane(_ref) {
3508
3566
  message: disabledReason,
3509
3567
  selectedField: flatOption
3510
3568
  })
3511
- }), isSms ? /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
3512
- children: [/*#__PURE__*/jsxRuntime.jsx(index.SmsFields, {
3513
- action: action,
3514
- index: index$1,
3515
- name: name,
3516
- shouldAutoFocus: true,
3517
- selectedField: flatOption,
3518
- showPhoneNumberInput: false
3519
- }), /*#__PURE__*/jsxRuntime.jsx(Typography, {
3520
- className: "neeto-ui-text-gray-500 mt-2",
3521
- style: "body3",
3522
- children: t("neetoRules.builder.config.smsSegmentHint")
3523
- })]
3569
+ }), isSms ? /*#__PURE__*/jsxRuntime.jsx(index.SmsFields, {
3570
+ action: action,
3571
+ index: index$1,
3572
+ name: name,
3573
+ shouldAutoFocus: true,
3574
+ hint: t("neetoRules.builder.config.smsSegmentHint"),
3575
+ selectedField: flatOption,
3576
+ showPhoneNumberInput: false
3524
3577
  }) : (_hostRenderConfig = hostRenderConfig === null || hostRenderConfig === void 0 ? void 0 : hostRenderConfig({
3525
3578
  name: name,
3526
3579
  action: action,
@@ -3551,7 +3604,9 @@ var DelayPane = function DelayPane(_ref) {
3551
3604
  var _useRuleModel = useRuleModel(schema),
3552
3605
  fieldKeys = _useRuleModel.fieldKeys;
3553
3606
  var _useFormikContext = formik.useFormikContext(),
3554
- setFieldValue = _useFormikContext.setFieldValue;
3607
+ setFieldValue = _useFormikContext.setFieldValue,
3608
+ setFieldTouched = _useFormikContext.setFieldTouched,
3609
+ getFieldMeta = _useFormikContext.getFieldMeta;
3555
3610
  var bodyRef = react.useRef(null);
3556
3611
  var name = fieldKeys.delay;
3557
3612
  var _useField = formik.useField("".concat(name, ".value")),
@@ -3560,12 +3615,18 @@ var DelayPane = function DelayPane(_ref) {
3560
3615
  var units = normalizeOptions((_schema$delay = schema.delay) === null || _schema$delay === void 0 ? void 0 : _schema$delay.units);
3561
3616
  var unitOptions = neetoCist.isNotEmpty(units) ? units : DEFAULT_DELAY_UNITS;
3562
3617
  usePaneValidation("".concat(name, ".value"));
3618
+ react.useEffect(function () {
3619
+ if ((value === null || value === void 0 ? void 0 : value.value) === undefined) return;
3620
+ if (getFieldMeta("".concat(name, ".value.value")).touched) return;
3621
+ setFieldTouched("".concat(name, ".value.value"), true, false);
3622
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3623
+ }, [value === null || value === void 0 ? void 0 : value.value]);
3563
3624
  react.useEffect(function () {
3564
3625
  if (ramda.isEmpty(value || {})) {
3565
3626
  var _unitOptions$0$value, _unitOptions$;
3566
3627
  setFieldValue("".concat(name, ".value"), {
3567
- value: 10,
3568
- unit: (_unitOptions$0$value = (_unitOptions$ = unitOptions[0]) === null || _unitOptions$ === void 0 ? void 0 : _unitOptions$.value) !== null && _unitOptions$0$value !== void 0 ? _unitOptions$0$value : "minutes"
3628
+ value: DEFAULT_DELAY_VALUE,
3629
+ unit: (_unitOptions$0$value = (_unitOptions$ = unitOptions[0]) === null || _unitOptions$ === void 0 ? void 0 : _unitOptions$.value) !== null && _unitOptions$0$value !== void 0 ? _unitOptions$0$value : DEFAULT_DELAY_UNITS[0].value
3569
3630
  });
3570
3631
  }
3571
3632
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -3604,8 +3665,8 @@ var DelayPane = function DelayPane(_ref) {
3604
3665
  className: "flex items-start gap-x-2",
3605
3666
  children: [/*#__PURE__*/jsxRuntime.jsx(Input$1, {
3606
3667
  className: "w-44",
3607
- max: 999,
3608
- min: 1,
3668
+ max: index.MAX_DELAY_VALUE,
3669
+ min: index.MIN_DELAY_VALUE,
3609
3670
  name: "".concat(name, ".value.value"),
3610
3671
  placeholder: t("neetoRules.placeholders.enterDelay"),
3611
3672
  size: "large",
@@ -3649,9 +3710,10 @@ var NumberStepper = function NumberStepper(_ref) {
3649
3710
  onChange = _ref.onChange,
3650
3711
  label = _ref.label,
3651
3712
  _ref$min = _ref.min,
3652
- min = _ref$min === void 0 ? 1 : _ref$min,
3713
+ min = _ref$min === void 0 ? STEPPER_MIN_VALUE : _ref$min,
3653
3714
  max = _ref.max,
3654
- required = _ref.required;
3715
+ required = _ref.required,
3716
+ error = _ref.error;
3655
3717
  var _useTranslation = reactI18next.useTranslation(),
3656
3718
  t = _useTranslation.t;
3657
3719
  var _useState = react.useState(null),
@@ -3676,15 +3738,38 @@ var NumberStepper = function NumberStepper(_ref) {
3676
3738
  max: max
3677
3739
  }));
3678
3740
  };
3679
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
3741
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
3680
3742
  className: "mb-stepper",
3681
- children: [/*#__PURE__*/jsxRuntime.jsx(Input, {
3743
+ children: /*#__PURE__*/jsxRuntime.jsx(Input, {
3744
+ error: error,
3682
3745
  label: label,
3683
3746
  min: min,
3684
3747
  required: required,
3685
3748
  autoFocus: true,
3686
3749
  type: "number",
3687
3750
  value: display,
3751
+ suffix: /*#__PURE__*/jsxRuntime.jsxs("div", {
3752
+ className: "mb-stepper-controls",
3753
+ children: [/*#__PURE__*/jsxRuntime.jsx("button", {
3754
+ "aria-label": t("neetoRules.builder.aria.increase"),
3755
+ className: "mb-stepper-btn",
3756
+ tabIndex: SKIP_TAB_INDEX,
3757
+ type: "button",
3758
+ onClick: function onClick() {
3759
+ return step(STEPPER_DELTA.INCREMENT);
3760
+ },
3761
+ children: /*#__PURE__*/jsxRuntime.jsx(Up, {})
3762
+ }), /*#__PURE__*/jsxRuntime.jsx("button", {
3763
+ "aria-label": t("neetoRules.builder.aria.decrease"),
3764
+ className: "mb-stepper-btn",
3765
+ tabIndex: SKIP_TAB_INDEX,
3766
+ type: "button",
3767
+ onClick: function onClick() {
3768
+ return step(STEPPER_DELTA.DECREMENT);
3769
+ },
3770
+ children: /*#__PURE__*/jsxRuntime.jsx(Down, {})
3771
+ })]
3772
+ }),
3688
3773
  onBlur: function onBlur() {
3689
3774
  return setDraft(null);
3690
3775
  },
@@ -3694,28 +3779,7 @@ var NumberStepper = function NumberStepper(_ref) {
3694
3779
  onFocus: function onFocus(event) {
3695
3780
  return event.target.select();
3696
3781
  }
3697
- }), /*#__PURE__*/jsxRuntime.jsxs("div", {
3698
- className: "mb-stepper-controls",
3699
- children: [/*#__PURE__*/jsxRuntime.jsx("button", {
3700
- "aria-label": t("neetoRules.builder.aria.increase"),
3701
- className: "mb-stepper-btn",
3702
- tabIndex: -1,
3703
- type: "button",
3704
- onClick: function onClick() {
3705
- return step(1);
3706
- },
3707
- children: /*#__PURE__*/jsxRuntime.jsx(Up, {})
3708
- }), /*#__PURE__*/jsxRuntime.jsx("button", {
3709
- "aria-label": t("neetoRules.builder.aria.decrease"),
3710
- className: "mb-stepper-btn",
3711
- tabIndex: -1,
3712
- type: "button",
3713
- onClick: function onClick() {
3714
- return step(-1);
3715
- },
3716
- children: /*#__PURE__*/jsxRuntime.jsx(Down, {})
3717
- })]
3718
- })]
3782
+ })
3719
3783
  });
3720
3784
  };
3721
3785
 
@@ -3724,7 +3788,9 @@ var LeadTimePane = function LeadTimePane(_ref) {
3724
3788
  var _useTranslation = reactI18next.useTranslation(),
3725
3789
  t = _useTranslation.t;
3726
3790
  var _useFormikContext = formik.useFormikContext(),
3727
- setFieldValue = _useFormikContext.setFieldValue;
3791
+ setFieldValue = _useFormikContext.setFieldValue,
3792
+ setFieldTouched = _useFormikContext.setFieldTouched,
3793
+ getFieldMeta = _useFormikContext.getFieldMeta;
3728
3794
  var _useRuleModel = useRuleModel(schema),
3729
3795
  rule = _useRuleModel.rule,
3730
3796
  fieldKeys = _useRuleModel.fieldKeys;
@@ -3732,6 +3798,11 @@ var LeadTimePane = function LeadTimePane(_ref) {
3732
3798
  amount = _minutesToParts.value,
3733
3799
  unit = _minutesToParts.unit;
3734
3800
  var path = "".concat(fieldKeys.leadTime, ".value");
3801
+ var _useField = formik.useField(path),
3802
+ _useField2 = _slicedToArray(_useField, 2),
3803
+ _useField2$ = _useField2[1],
3804
+ error = _useField2$.error,
3805
+ touched = _useField2$.touched;
3735
3806
  var update = function update(_ref2) {
3736
3807
  var value = _ref2.value,
3737
3808
  nextUnit = _ref2.unit;
@@ -3740,6 +3811,13 @@ var LeadTimePane = function LeadTimePane(_ref) {
3740
3811
  unit: nextUnit
3741
3812
  }));
3742
3813
  };
3814
+ usePaneValidation(path);
3815
+ react.useEffect(function () {
3816
+ if (rule.leadTime === undefined) return;
3817
+ if (getFieldMeta(path).touched) return;
3818
+ setFieldTouched(path, true, false);
3819
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3820
+ }, [rule.leadTime]);
3743
3821
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
3744
3822
  children: [/*#__PURE__*/jsxRuntime.jsx(index.Panel.Header, {
3745
3823
  children: /*#__PURE__*/jsxRuntime.jsxs("div", {
@@ -3755,34 +3833,42 @@ var LeadTimePane = function LeadTimePane(_ref) {
3755
3833
  })
3756
3834
  }), /*#__PURE__*/jsxRuntime.jsx(index.Panel.Body, {
3757
3835
  children: /*#__PURE__*/jsxRuntime.jsxs("div", {
3758
- className: "flex items-end gap-x-3",
3759
- children: [/*#__PURE__*/jsxRuntime.jsx("div", {
3760
- className: "flex-1",
3761
- children: /*#__PURE__*/jsxRuntime.jsx(NumberStepper, {
3762
- label: t("neetoRules.builder.before"),
3763
- value: amount,
3764
- onChange: function onChange(value) {
3765
- return update({
3766
- value: value === "" ? 0 : value,
3767
- unit: unit
3768
- });
3769
- }
3770
- })
3771
- }), /*#__PURE__*/jsxRuntime.jsx("div", {
3772
- className: "w-32 shrink-0",
3773
- children: /*#__PURE__*/jsxRuntime.jsx(Select$1, {
3774
- isSearchable: false,
3775
- options: LEAD_TIME_UNITS,
3776
- value: neetoCist.findBy({
3777
- value: unit
3778
- }, LEAD_TIME_UNITS) || null,
3779
- onChange: function onChange(option) {
3780
- return update({
3781
- value: amount,
3782
- unit: option === null || option === void 0 ? void 0 : option.value
3783
- });
3784
- }
3785
- })
3836
+ className: "flex flex-col gap-y-1.5",
3837
+ children: [/*#__PURE__*/jsxRuntime.jsx(Typography, {
3838
+ className: "neeto-ui-text-gray-800",
3839
+ style: "body2",
3840
+ weight: "medium",
3841
+ children: t("neetoRules.builder.before")
3842
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
3843
+ className: "flex items-start gap-x-3",
3844
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
3845
+ className: "flex-1",
3846
+ children: /*#__PURE__*/jsxRuntime.jsx(NumberStepper, {
3847
+ error: touched ? error : "",
3848
+ value: amount,
3849
+ onChange: function onChange(value) {
3850
+ return update({
3851
+ value: value === "" ? 0 : value,
3852
+ unit: unit
3853
+ });
3854
+ }
3855
+ })
3856
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
3857
+ className: "w-32 shrink-0",
3858
+ children: /*#__PURE__*/jsxRuntime.jsx(Select$1, {
3859
+ isSearchable: false,
3860
+ options: LEAD_TIME_UNITS,
3861
+ value: neetoCist.findBy({
3862
+ value: unit
3863
+ }, LEAD_TIME_UNITS) || null,
3864
+ onChange: function onChange(option) {
3865
+ return update({
3866
+ value: amount,
3867
+ unit: option === null || option === void 0 ? void 0 : option.value
3868
+ });
3869
+ }
3870
+ })
3871
+ })]
3786
3872
  })]
3787
3873
  })
3788
3874
  })]
@@ -4577,7 +4663,7 @@ var Form = function Form(_ref) {
4577
4663
  data: data,
4578
4664
  customData: customData,
4579
4665
  isNameGenerationDisabled: isNameRequired
4580
- }),
4666
+ }).concat(leadTimeValidationSchema(schema)),
4581
4667
  onSubmit: submitForm,
4582
4668
  children: function children() {
4583
4669
  return /*#__PURE__*/jsxRuntime.jsxs("div", {