@carbon/ibm-products 2.43.2-canary.173 → 2.43.2-canary.174

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. package/css/index-full-carbon.css +9 -1
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +1 -1
  4. package/css/index-full-carbon.min.css.map +1 -1
  5. package/css/index-without-carbon.css +9 -1
  6. package/css/index-without-carbon.css.map +1 -1
  7. package/css/index-without-carbon.min.css +1 -1
  8. package/css/index-without-carbon.min.css.map +1 -1
  9. package/css/index.css +9 -1
  10. package/css/index.css.map +1 -1
  11. package/css/index.min.css +1 -1
  12. package/css/index.min.css.map +1 -1
  13. package/es/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +7 -3
  14. package/es/components/ConditionBuilder/ConditionBuilder.js +2 -1
  15. package/es/components/ConditionBuilder/ConditionBuilder.types.d.ts +2 -1
  16. package/es/components/ConditionBuilder/ConditionBuilderActions/ConditionBuilderActions.js +1 -1
  17. package/es/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.js +1 -1
  18. package/es/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.d.ts +3 -1
  19. package/es/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +1 -1
  20. package/es/components/ConditionBuilder/ConditionBuilderConnector/ConditionConnector.js +4 -2
  21. package/es/components/ConditionBuilder/ConditionBuilderConnector/GroupConnector.js +4 -1
  22. package/es/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +2 -2
  23. package/es/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.js +1 -1
  24. package/es/components/ConditionBuilder/ConditionBuilderContext/translationObject.d.ts +5 -0
  25. package/es/components/ConditionBuilder/ConditionBuilderContext/translationObject.js +5 -0
  26. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +9 -3
  27. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemDate/ConditionBuilderItemDate.js +1 -2
  28. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemNumber/ConditionBuilderItemNumber.js +1 -1
  29. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.d.ts +3 -1
  30. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.js +11 -5
  31. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOptionForValueField.js +1 -1
  32. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemText/ConditionBuilderItemText.js +1 -2
  33. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemTime/ConditionBuilderItemTime.js +1 -1
  34. package/es/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +7 -4
  35. package/es/components/ConditionBuilder/ConditionPreview/ConditionPreview.js +1 -1
  36. package/es/components/ConditionBuilder/utils/handleKeyboardEvents.js +1 -2
  37. package/es/components/ConditionBuilder/utils/useDataConfigs.d.ts +18 -0
  38. package/es/components/ConditionBuilder/utils/useDataConfigs.js +120 -0
  39. package/es/components/ConditionBuilder/utils/useTranslations.d.ts +1 -1
  40. package/es/components/ConditionBuilder/utils/useTranslations.js +4 -1
  41. package/es/components/ConditionBuilder/utils/util.d.ts +12 -0
  42. package/es/components/ConditionBuilder/utils/util.js +48 -2
  43. package/lib/components/ConditionBuilder/ConditionBlock/ConditionBlock.js +17 -13
  44. package/lib/components/ConditionBuilder/ConditionBuilder.js +5 -4
  45. package/lib/components/ConditionBuilder/ConditionBuilder.types.d.ts +2 -1
  46. package/lib/components/ConditionBuilder/ConditionBuilderActions/ConditionBuilderActions.js +9 -9
  47. package/lib/components/ConditionBuilder/ConditionBuilderAdd/ConditionBuilderAdd.js +6 -6
  48. package/lib/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.d.ts +3 -1
  49. package/lib/components/ConditionBuilder/ConditionBuilderButton/ConditionBuilderButton.js +3 -3
  50. package/lib/components/ConditionBuilder/ConditionBuilderConnector/ConditionConnector.js +7 -5
  51. package/lib/components/ConditionBuilder/ConditionBuilderConnector/GroupConnector.js +8 -5
  52. package/lib/components/ConditionBuilder/ConditionBuilderContent/ConditionBuilderContent.js +11 -11
  53. package/lib/components/ConditionBuilder/ConditionBuilderContext/ConditionBuilderProvider.js +1 -1
  54. package/lib/components/ConditionBuilder/ConditionBuilderContext/translationObject.d.ts +5 -0
  55. package/lib/components/ConditionBuilder/ConditionBuilderContext/translationObject.js +5 -0
  56. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +13 -7
  57. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemDate/ConditionBuilderItemDate.js +2 -3
  58. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemNumber/ConditionBuilderItemNumber.js +2 -2
  59. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.d.ts +3 -1
  60. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.js +17 -11
  61. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOptionForValueField.js +12 -12
  62. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemText/ConditionBuilderItemText.js +1 -2
  63. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemTime/ConditionBuilderItemTime.js +2 -2
  64. package/lib/components/ConditionBuilder/ConditionGroupBuilder/ConditionGroupBuilder.js +20 -17
  65. package/lib/components/ConditionBuilder/ConditionPreview/ConditionPreview.js +17 -17
  66. package/lib/components/ConditionBuilder/utils/handleKeyboardEvents.js +8 -9
  67. package/lib/components/ConditionBuilder/utils/useDataConfigs.d.ts +18 -0
  68. package/lib/components/ConditionBuilder/utils/useDataConfigs.js +124 -0
  69. package/lib/components/ConditionBuilder/utils/useTranslations.d.ts +1 -1
  70. package/lib/components/ConditionBuilder/utils/useTranslations.js +4 -1
  71. package/lib/components/ConditionBuilder/utils/util.d.ts +12 -0
  72. package/lib/components/ConditionBuilder/utils/util.js +53 -3
  73. package/package.json +3 -3
  74. package/scss/components/ConditionBuilder/styles/_conditionBuilderItem.scss +10 -1
  75. package/es/components/ConditionBuilder/ConditionBuilderContext/DataConfigs.d.ts +0 -30
  76. package/es/components/ConditionBuilder/ConditionBuilderContext/DataConfigs.js +0 -125
  77. package/lib/components/ConditionBuilder/ConditionBuilderContext/DataConfigs.d.ts +0 -30
  78. package/lib/components/ConditionBuilder/ConditionBuilderContext/DataConfigs.js +0 -135
@@ -0,0 +1,18 @@
1
+ export function useDataConfigs(): {
2
+ statementConfig: {
3
+ label: string;
4
+ id: string;
5
+ connector: string;
6
+ text1: any;
7
+ text2: string;
8
+ }[];
9
+ connectorConfig: {
10
+ label: any;
11
+ id: string;
12
+ }[];
13
+ operatorConfig: {
14
+ label: any;
15
+ id: string;
16
+ type: string;
17
+ }[];
18
+ };
@@ -0,0 +1,124 @@
1
+ /**
2
+ * Copyright IBM Corp. 2020, 2024
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ 'use strict';
9
+
10
+ Object.defineProperty(exports, '__esModule', { value: true });
11
+
12
+ var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
13
+ var useTranslations = require('./useTranslations.js');
14
+
15
+ var useDataConfigs = function useDataConfigs() {
16
+ var _useTranslations = useTranslations.useTranslations(['ifAll', 'ifAny', 'unlessAll', 'unlessAny', 'and', 'or', 'is', 'greater', 'greaterEqual', 'lower', 'lowerEqual', 'startsWith', 'endsWith', 'contains', 'oneOf', 'before', 'after', 'between']),
17
+ _useTranslations2 = _rollupPluginBabelHelpers.slicedToArray(_useTranslations, 18),
18
+ ifAll = _useTranslations2[0],
19
+ ifAny = _useTranslations2[1],
20
+ unlessAll = _useTranslations2[2],
21
+ unlessAny = _useTranslations2[3],
22
+ and = _useTranslations2[4],
23
+ or = _useTranslations2[5],
24
+ is = _useTranslations2[6],
25
+ greater = _useTranslations2[7],
26
+ greaterEqual = _useTranslations2[8],
27
+ lower = _useTranslations2[9],
28
+ lowerEqual = _useTranslations2[10],
29
+ startsWith = _useTranslations2[11],
30
+ endsWith = _useTranslations2[12],
31
+ contains = _useTranslations2[13],
32
+ oneOf = _useTranslations2[14],
33
+ before = _useTranslations2[15],
34
+ after = _useTranslations2[16],
35
+ between = _useTranslations2[17];
36
+ var statementConfig = [{
37
+ label: 'ifText',
38
+ id: 'ifAll',
39
+ connector: 'and',
40
+ text1: ifAll,
41
+ text2: '(a && b)'
42
+ }, {
43
+ label: 'ifText',
44
+ id: 'ifAny',
45
+ connector: 'or',
46
+ text1: ifAny,
47
+ text2: '(a || b)'
48
+ }, {
49
+ label: 'unlessText',
50
+ id: 'unlessAll',
51
+ connector: 'and',
52
+ text1: unlessAll,
53
+ text2: '! (a && b)'
54
+ }, {
55
+ label: 'unlessText',
56
+ id: 'unlessAny',
57
+ connector: 'or',
58
+ text1: unlessAny,
59
+ text2: '! (a || b)'
60
+ }];
61
+ var connectorConfig = [{
62
+ label: and,
63
+ id: 'and'
64
+ }, {
65
+ label: or,
66
+ id: 'or'
67
+ }];
68
+ var operatorConfig = [{
69
+ label: is,
70
+ id: 'is',
71
+ type: 'all'
72
+ }, {
73
+ label: greater,
74
+ id: 'greater',
75
+ type: 'number'
76
+ }, {
77
+ label: greaterEqual,
78
+ id: 'greaterEqual',
79
+ type: 'number'
80
+ }, {
81
+ label: lower,
82
+ id: 'lower',
83
+ type: 'number'
84
+ }, {
85
+ label: lowerEqual,
86
+ id: 'lowerEqual',
87
+ type: 'number'
88
+ }, {
89
+ label: startsWith,
90
+ id: 'startsWith',
91
+ type: 'text,textarea'
92
+ }, {
93
+ label: endsWith,
94
+ id: 'endsWith',
95
+ type: 'text,textarea'
96
+ }, {
97
+ label: contains,
98
+ id: 'contains',
99
+ type: 'text,textarea'
100
+ }, {
101
+ label: oneOf,
102
+ id: 'oneOf',
103
+ type: 'option'
104
+ }, {
105
+ label: before,
106
+ id: 'before',
107
+ type: 'date,time'
108
+ }, {
109
+ label: after,
110
+ id: 'after',
111
+ type: 'date,time'
112
+ }, {
113
+ label: between,
114
+ id: 'between',
115
+ type: 'date'
116
+ }];
117
+ return {
118
+ statementConfig: statementConfig,
119
+ connectorConfig: connectorConfig,
120
+ operatorConfig: operatorConfig
121
+ };
122
+ };
123
+
124
+ exports.useDataConfigs = useDataConfigs;
@@ -1 +1 @@
1
- export function useTranslations(translationKeys: any): any;
1
+ export function useTranslations(translationKeys: any, alterTranslationKeyMap: any): any;
@@ -13,10 +13,13 @@ var React = require('react');
13
13
  var ConditionBuilderProvider = require('../ConditionBuilderContext/ConditionBuilderProvider.js');
14
14
  var translationObject = require('../ConditionBuilderContext/translationObject.js');
15
15
 
16
- var useTranslations = function useTranslations(translationKeys) {
16
+ var useTranslations = function useTranslations(translationKeys, alterTranslationKeyMap) {
17
17
  var _useContext = React.useContext(ConditionBuilderProvider.ConditionBuilderContext),
18
18
  translateWithId = _useContext.translateWithId;
19
19
  return translationKeys.map(function (translationKey) {
20
+ if (alterTranslationKeyMap !== null && alterTranslationKeyMap !== void 0 && alterTranslationKeyMap[translationKey]) {
21
+ translationKey = alterTranslationKeyMap[translationKey];
22
+ }
20
23
  if (translateWithId !== null && translateWithId !== void 0 && translateWithId(translationKey)) {
21
24
  return translateWithId(translationKey);
22
25
  } else if (translationObject.translationsObject[translationKey]) {
@@ -1,3 +1,6 @@
1
+ export const blockClass: string;
2
+ export const NON_HIERARCHICAL_VARIANT: "Non-Hierarchical";
3
+ export const HIERARCHICAL_VARIANT: "Hierarchical";
1
4
  export function focusThisField(evt: any, conditionBuilderRef: any): void;
2
5
  export function focusThisItem(currentElement: any, conditionBuilderRef: any): void;
3
6
  export function traverseClockVise(eachElem: any, index: any, allElements: any, rotate: any, trapFocus: any, conditionBuilderRef: any): void;
@@ -5,3 +8,12 @@ export function traverseReverse(eachElem: any, index: any, allElements: any, rot
5
8
  export function checkForHoldingKey(evt: any, key: any): any;
6
9
  export function checkIsValid(item: any): any;
7
10
  export function manageTabIndexAndFocus(currentElement: any, conditionBuilderRef: any): void;
11
+ export namespace getValue {
12
+ function text(value: any): any;
13
+ function textarea(value: any): any;
14
+ function time(value: any): any;
15
+ function number(value: any): any;
16
+ function option(value: any): any;
17
+ function date(value: any): any;
18
+ function custom(value: any): any;
19
+ }
@@ -9,8 +9,11 @@
9
9
 
10
10
  Object.defineProperty(exports, '__esModule', { value: true });
11
11
 
12
- var DataConfigs = require('../ConditionBuilderContext/DataConfigs.js');
12
+ var settings = require('../../../settings.js');
13
13
 
14
+ var blockClass = "".concat(settings.pkg.prefix, "--condition-builder");
15
+ var NON_HIERARCHICAL_VARIANT = 'Non-Hierarchical';
16
+ var HIERARCHICAL_VARIANT = 'Hierarchical';
14
17
  var focusThisField = function focusThisField(evt, conditionBuilderRef) {
15
18
  if (evt) {
16
19
  setTimeout(function () {
@@ -62,19 +65,66 @@ var checkIsValid = function checkIsValid(item) {
62
65
  };
63
66
  var manageTabIndexAndFocus = function manageTabIndexAndFocus(currentElement, conditionBuilderRef) {
64
67
  var _currentElement$close, _conditionBuilderRef$;
65
- var contentContainer = (_currentElement$close = currentElement === null || currentElement === void 0 ? void 0 : currentElement.closest(".".concat(DataConfigs.blockClass, "__content-container"))) !== null && _currentElement$close !== void 0 ? _currentElement$close : currentElement === null || currentElement === void 0 ? void 0 : currentElement.closest(".".concat(DataConfigs.blockClass, "__actions-container"));
68
+ var contentContainer = (_currentElement$close = currentElement === null || currentElement === void 0 ? void 0 : currentElement.closest(".".concat(blockClass, "__content-container"))) !== null && _currentElement$close !== void 0 ? _currentElement$close : currentElement === null || currentElement === void 0 ? void 0 : currentElement.closest(".".concat(blockClass, "__actions-container"));
66
69
  contentContainer && Array.from(contentContainer.querySelectorAll('[tabindex="0"]')).map(function (element) {
67
70
  return element === null || element === void 0 ? void 0 : element.setAttribute('tabindex', '-1');
68
71
  });
69
72
  currentElement === null || currentElement === void 0 || currentElement.setAttribute('tabindex', '0');
70
- (_conditionBuilderRef$ = conditionBuilderRef.current) === null || _conditionBuilderRef$ === void 0 || (_conditionBuilderRef$ = _conditionBuilderRef$.querySelector(".".concat(DataConfigs.blockClass, "__statement-button"))) === null || _conditionBuilderRef$ === void 0 || _conditionBuilderRef$.setAttribute('tabindex', '1');
73
+ (_conditionBuilderRef$ = conditionBuilderRef.current) === null || _conditionBuilderRef$ === void 0 || (_conditionBuilderRef$ = _conditionBuilderRef$.querySelector(".".concat(blockClass, "__statement-button"))) === null || _conditionBuilderRef$ === void 0 || _conditionBuilderRef$.setAttribute('tabindex', '1');
71
74
  currentElement === null || currentElement === void 0 || currentElement.focus();
72
75
  };
76
+ var formatDate = function formatDate(date) {
77
+ var day = String(date.getDate()).padStart(2, '0');
78
+ var month = String(date.getMonth() + 1).padStart(2, '0');
79
+ var year = date.getFullYear();
80
+ return "".concat(day, "/").concat(month, "/").concat(year);
81
+ };
82
+ var getValue = {
83
+ text: function text(value) {
84
+ return value;
85
+ },
86
+ textarea: function textarea(value) {
87
+ return value;
88
+ },
89
+ time: function time(value) {
90
+ return value;
91
+ },
92
+ number: function number(value) {
93
+ return value;
94
+ },
95
+ option: function option(value) {
96
+ if (value && typeof value !== 'string') {
97
+ var selectedValues = Array.isArray(value) ? value : [value];
98
+ return selectedValues.map(function (option) {
99
+ return option.label;
100
+ }).join(', ');
101
+ }
102
+ return value;
103
+ },
104
+ date: function date(value) {
105
+ if (Array.isArray(value) && value.length > 1) {
106
+ var start = value !== null && value !== void 0 && value[0] && !isNaN(new Date(value[0])) ? formatDate(new Date(value[0])) : '';
107
+ var end = value !== null && value !== void 0 && value[1] && !isNaN(new Date(value[1])) ? formatDate(new Date(value[1])) : '';
108
+ return "".concat(start, " To ").concat(end);
109
+ } else if (Array.isArray(value) && !isNaN(new Date(value[0]))) {
110
+ return formatDate(new Date(value[0]));
111
+ } else {
112
+ return value;
113
+ }
114
+ },
115
+ custom: function custom(value) {
116
+ return value;
117
+ }
118
+ };
73
119
 
120
+ exports.HIERARCHICAL_VARIANT = HIERARCHICAL_VARIANT;
121
+ exports.NON_HIERARCHICAL_VARIANT = NON_HIERARCHICAL_VARIANT;
122
+ exports.blockClass = blockClass;
74
123
  exports.checkForHoldingKey = checkForHoldingKey;
75
124
  exports.checkIsValid = checkIsValid;
76
125
  exports.focusThisField = focusThisField;
77
126
  exports.focusThisItem = focusThisItem;
127
+ exports.getValue = getValue;
78
128
  exports.manageTabIndexAndFocus = manageTabIndexAndFocus;
79
129
  exports.traverseClockVise = traverseClockVise;
80
130
  exports.traverseReverse = traverseReverse;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@carbon/ibm-products",
3
3
  "description": "Carbon for IBM Products",
4
- "version": "2.43.2-canary.173+485e8bcac",
4
+ "version": "2.43.2-canary.174+91733fb43",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "module": "es/index.js",
@@ -96,7 +96,7 @@
96
96
  "dependencies": {
97
97
  "@babel/runtime": "^7.23.9",
98
98
  "@carbon/feature-flags": "^0.20.0",
99
- "@carbon/ibm-products-styles": "^2.39.1-canary.183+485e8bcac",
99
+ "@carbon/ibm-products-styles": "^2.39.1-canary.184+91733fb43",
100
100
  "@carbon/telemetry": "^0.1.0",
101
101
  "@dnd-kit/core": "^6.0.8",
102
102
  "@dnd-kit/modifiers": "^7.0.0",
@@ -120,5 +120,5 @@
120
120
  "react": "^16.8.6 || ^17.0.1 || ^18.2.0",
121
121
  "react-dom": "^16.8.6 || ^17.0.1 || ^18.2.0"
122
122
  },
123
- "gitHead": "485e8bcac3193e56d65721076160944b4e126256"
123
+ "gitHead": "91733fb43157eab26c885f0652adaf9276f372d4"
124
124
  }
@@ -54,7 +54,8 @@ $block-class: #{c4p-settings.$pkg-prefix}--condition-builder;
54
54
  }
55
55
 
56
56
  .#{$block-class}__item-option__option {
57
- height: 2rem;
57
+ display: grid;
58
+ min-height: 2rem;
58
59
  cursor: pointer;
59
60
  padding-inline: $spacing-05;
60
61
  }
@@ -297,3 +298,11 @@ $colors: (
297
298
  fill: $icon-primary;
298
299
  }
299
300
  }
301
+
302
+ .#{$block-class}__statement_wrapper {
303
+ padding: $spacing-03 0;
304
+
305
+ :nth-child(2) {
306
+ color: $text-secondary;
307
+ }
308
+ }
@@ -1,30 +0,0 @@
1
- export const statementConfig: {
2
- label: string;
3
- id: string;
4
- connector: string;
5
- }[];
6
- export const connectorConfig: {
7
- label: string;
8
- id: string;
9
- }[];
10
- export const actionConfig: {
11
- label: string;
12
- id: string;
13
- }[];
14
- export const operatorConfig: {
15
- label: string;
16
- id: string;
17
- type: string;
18
- }[];
19
- export const NON_HIERARCHICAL_VARIANT: "Non-Hierarchical";
20
- export const HIERARCHICAL_VARIANT: "Hierarchical";
21
- export const blockClass: string;
22
- export namespace valueRenderers {
23
- function text(val: any): any;
24
- function textarea(val: any): any;
25
- function time(val: any): any;
26
- function number(val: any): any;
27
- function option(value: any): any;
28
- function date(value: any): any;
29
- function custom(value: any): any;
30
- }
@@ -1,125 +0,0 @@
1
- /**
2
- * Copyright IBM Corp. 2020, 2024
3
- *
4
- * This source code is licensed under the Apache-2.0 license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- import { pkg } from '../../../settings.js';
9
-
10
- var statementConfig = [{
11
- label: 'if',
12
- id: 'if',
13
- connector: 'and'
14
- }, {
15
- label: 'excl.if',
16
- id: 'excl_if',
17
- connector: 'or'
18
- }];
19
- var connectorConfig = [{
20
- label: 'and',
21
- id: 'and'
22
- }, {
23
- label: 'or',
24
- id: 'or'
25
- }];
26
- var operatorConfig = [{
27
- label: 'is',
28
- id: 'is',
29
- type: 'all'
30
- }, {
31
- label: 'is greater than',
32
- id: 'greater',
33
- type: 'number'
34
- }, {
35
- label: 'is greater than or equal to',
36
- id: 'greaterEqual',
37
- type: 'number'
38
- }, {
39
- label: 'is lower than',
40
- id: 'lower',
41
- type: 'number'
42
- }, {
43
- label: 'is lower than or equal to',
44
- id: 'lowerEqual',
45
- type: 'number'
46
- }, {
47
- label: 'starts with',
48
- id: 'startsWith',
49
- type: 'text,textarea'
50
- }, {
51
- label: 'ends with',
52
- id: 'endsWith',
53
- type: 'text,textarea'
54
- }, {
55
- label: 'contains',
56
- id: 'contains',
57
- type: 'text,textarea'
58
- }, {
59
- label: 'is one of',
60
- id: 'oneOf',
61
- type: 'option'
62
- }, {
63
- label: 'is before',
64
- id: 'before',
65
- type: 'date,time'
66
- }, {
67
- label: 'is after',
68
- id: 'after',
69
- type: 'date,time'
70
- }, {
71
- label: 'is between',
72
- id: 'between',
73
- type: 'date'
74
- }];
75
- var NON_HIERARCHICAL_VARIANT = 'Non-Hierarchical';
76
- var HIERARCHICAL_VARIANT = 'Hierarchical';
77
- // The block part of our conventional BEM class names (blockClass__E--M).
78
- var blockClass = "".concat(pkg.prefix, "--condition-builder");
79
- var formatDate = function formatDate(date) {
80
- var day = String(date.getDate()).padStart(2, '0');
81
- var month = String(date.getMonth() + 1).padStart(2, '0');
82
- var year = date.getFullYear();
83
- return "".concat(day, "/").concat(month, "/").concat(year);
84
- };
85
- //const translationsObjectCurrent = translationsObject['en']; // TO DO: need to discuss if language is to be passed as prop
86
-
87
- var valueRenderers = {
88
- text: function text(val) {
89
- return val;
90
- },
91
- textarea: function textarea(val) {
92
- return val;
93
- },
94
- time: function time(val) {
95
- return val;
96
- },
97
- number: function number(val) {
98
- return val;
99
- },
100
- option: function option(value) {
101
- if (value && typeof value !== 'string') {
102
- var selectedValues = Array.isArray(value) ? value : [value];
103
- return selectedValues.map(function (option) {
104
- return option.label;
105
- }).join(', ');
106
- }
107
- return value;
108
- },
109
- date: function date(value) {
110
- if (Array.isArray(value) && value.length > 1) {
111
- var start = value !== null && value !== void 0 && value[0] && !isNaN(new Date(value[0])) ? formatDate(new Date(value[0])) : '';
112
- var end = value !== null && value !== void 0 && value[1] && !isNaN(new Date(value[1])) ? formatDate(new Date(value[1])) : '';
113
- return "".concat(start, " To ").concat(end);
114
- } else if (Array.isArray(value) && !isNaN(new Date(value[0]))) {
115
- return formatDate(new Date(value[0]));
116
- } else {
117
- return value;
118
- }
119
- },
120
- custom: function custom(value) {
121
- return value;
122
- }
123
- };
124
-
125
- export { HIERARCHICAL_VARIANT, NON_HIERARCHICAL_VARIANT, blockClass, connectorConfig, operatorConfig, statementConfig, valueRenderers };
@@ -1,30 +0,0 @@
1
- export const statementConfig: {
2
- label: string;
3
- id: string;
4
- connector: string;
5
- }[];
6
- export const connectorConfig: {
7
- label: string;
8
- id: string;
9
- }[];
10
- export const actionConfig: {
11
- label: string;
12
- id: string;
13
- }[];
14
- export const operatorConfig: {
15
- label: string;
16
- id: string;
17
- type: string;
18
- }[];
19
- export const NON_HIERARCHICAL_VARIANT: "Non-Hierarchical";
20
- export const HIERARCHICAL_VARIANT: "Hierarchical";
21
- export const blockClass: string;
22
- export namespace valueRenderers {
23
- function text(val: any): any;
24
- function textarea(val: any): any;
25
- function time(val: any): any;
26
- function number(val: any): any;
27
- function option(value: any): any;
28
- function date(value: any): any;
29
- function custom(value: any): any;
30
- }
@@ -1,135 +0,0 @@
1
- /**
2
- * Copyright IBM Corp. 2020, 2024
3
- *
4
- * This source code is licensed under the Apache-2.0 license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- 'use strict';
9
-
10
- Object.defineProperty(exports, '__esModule', { value: true });
11
-
12
- var settings = require('../../../settings.js');
13
-
14
- var statementConfig = [{
15
- label: 'if',
16
- id: 'if',
17
- connector: 'and'
18
- }, {
19
- label: 'excl.if',
20
- id: 'excl_if',
21
- connector: 'or'
22
- }];
23
- var connectorConfig = [{
24
- label: 'and',
25
- id: 'and'
26
- }, {
27
- label: 'or',
28
- id: 'or'
29
- }];
30
- var operatorConfig = [{
31
- label: 'is',
32
- id: 'is',
33
- type: 'all'
34
- }, {
35
- label: 'is greater than',
36
- id: 'greater',
37
- type: 'number'
38
- }, {
39
- label: 'is greater than or equal to',
40
- id: 'greaterEqual',
41
- type: 'number'
42
- }, {
43
- label: 'is lower than',
44
- id: 'lower',
45
- type: 'number'
46
- }, {
47
- label: 'is lower than or equal to',
48
- id: 'lowerEqual',
49
- type: 'number'
50
- }, {
51
- label: 'starts with',
52
- id: 'startsWith',
53
- type: 'text,textarea'
54
- }, {
55
- label: 'ends with',
56
- id: 'endsWith',
57
- type: 'text,textarea'
58
- }, {
59
- label: 'contains',
60
- id: 'contains',
61
- type: 'text,textarea'
62
- }, {
63
- label: 'is one of',
64
- id: 'oneOf',
65
- type: 'option'
66
- }, {
67
- label: 'is before',
68
- id: 'before',
69
- type: 'date,time'
70
- }, {
71
- label: 'is after',
72
- id: 'after',
73
- type: 'date,time'
74
- }, {
75
- label: 'is between',
76
- id: 'between',
77
- type: 'date'
78
- }];
79
- var NON_HIERARCHICAL_VARIANT = 'Non-Hierarchical';
80
- var HIERARCHICAL_VARIANT = 'Hierarchical';
81
- // The block part of our conventional BEM class names (blockClass__E--M).
82
- var blockClass = "".concat(settings.pkg.prefix, "--condition-builder");
83
- var formatDate = function formatDate(date) {
84
- var day = String(date.getDate()).padStart(2, '0');
85
- var month = String(date.getMonth() + 1).padStart(2, '0');
86
- var year = date.getFullYear();
87
- return "".concat(day, "/").concat(month, "/").concat(year);
88
- };
89
- //const translationsObjectCurrent = translationsObject['en']; // TO DO: need to discuss if language is to be passed as prop
90
-
91
- var valueRenderers = {
92
- text: function text(val) {
93
- return val;
94
- },
95
- textarea: function textarea(val) {
96
- return val;
97
- },
98
- time: function time(val) {
99
- return val;
100
- },
101
- number: function number(val) {
102
- return val;
103
- },
104
- option: function option(value) {
105
- if (value && typeof value !== 'string') {
106
- var selectedValues = Array.isArray(value) ? value : [value];
107
- return selectedValues.map(function (option) {
108
- return option.label;
109
- }).join(', ');
110
- }
111
- return value;
112
- },
113
- date: function date(value) {
114
- if (Array.isArray(value) && value.length > 1) {
115
- var start = value !== null && value !== void 0 && value[0] && !isNaN(new Date(value[0])) ? formatDate(new Date(value[0])) : '';
116
- var end = value !== null && value !== void 0 && value[1] && !isNaN(new Date(value[1])) ? formatDate(new Date(value[1])) : '';
117
- return "".concat(start, " To ").concat(end);
118
- } else if (Array.isArray(value) && !isNaN(new Date(value[0]))) {
119
- return formatDate(new Date(value[0]));
120
- } else {
121
- return value;
122
- }
123
- },
124
- custom: function custom(value) {
125
- return value;
126
- }
127
- };
128
-
129
- exports.HIERARCHICAL_VARIANT = HIERARCHICAL_VARIANT;
130
- exports.NON_HIERARCHICAL_VARIANT = NON_HIERARCHICAL_VARIANT;
131
- exports.blockClass = blockClass;
132
- exports.connectorConfig = connectorConfig;
133
- exports.operatorConfig = operatorConfig;
134
- exports.statementConfig = statementConfig;
135
- exports.valueRenderers = valueRenderers;