@demos-europe/demosplan-ui 0.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.
Files changed (133) hide show
  1. package/LICENSE +21 -0
  2. package/buildTokens.js +59 -0
  3. package/components/DpButton/DpButton.stories.mdx +136 -0
  4. package/components/DpButton/DpButton.vue +118 -0
  5. package/components/DpDetails/DpDetails.stories.mdx +55 -0
  6. package/components/DpDetails/DpDetails.vue +58 -0
  7. package/components/DpIcon/DpIcon.stories.mdx +396 -0
  8. package/components/DpIcon/DpIcon.vue +51 -0
  9. package/components/DpIcon/util/iconVariables.js +148 -0
  10. package/components/DpInput/DpInput.stories.mdx +127 -0
  11. package/components/DpInput/DpInput.vue +284 -0
  12. package/components/DpLabel/DpLabel.stories.mdx +103 -0
  13. package/components/DpLabel/DpLabel.vue +112 -0
  14. package/components/DpLoading/DpLoading.stories.mdx +63 -0
  15. package/components/DpLoading/DpLoading.vue +63 -0
  16. package/components/core/DpAccordion.vue +108 -0
  17. package/components/core/DpAnonymizeText.vue +136 -0
  18. package/components/core/DpAutocomplete.vue +133 -0
  19. package/components/core/DpBulkEditHeader.vue +53 -0
  20. package/components/core/DpButtonIcon.vue +47 -0
  21. package/components/core/DpButtonRow.vue +155 -0
  22. package/components/core/DpCard.vue +54 -0
  23. package/components/core/DpChangeStateAtDate.vue +223 -0
  24. package/components/core/DpCheckboxGroup.vue +93 -0
  25. package/components/core/DpContextualHelp.vue +54 -0
  26. package/components/core/DpCopyPasteButton.vue +47 -0
  27. package/components/core/DpDashboardTaskCard.vue +123 -0
  28. package/components/core/DpDataTable/DataTableSearch.js +44 -0
  29. package/components/core/DpDataTable/DpColumnSelector.vue +133 -0
  30. package/components/core/DpDataTable/DpDataTable.vue +647 -0
  31. package/components/core/DpDataTable/DpDataTableExtended.vue +377 -0
  32. package/components/core/DpDataTable/DpResizeHandle.vue +37 -0
  33. package/components/core/DpDataTable/DpSelectPageItemCount.vue +70 -0
  34. package/components/core/DpDataTable/DpTableHeader.vue +197 -0
  35. package/components/core/DpDataTable/DpTableRow.vue +355 -0
  36. package/components/core/DpDataTable/DpWrapTrigger.vue +48 -0
  37. package/components/core/DpDataTable/lib/ResizableColumns.js +83 -0
  38. package/components/core/DpEditableList.vue +161 -0
  39. package/components/core/DpEditor/DpBoilerPlate.vue +140 -0
  40. package/components/core/DpEditor/DpBoilerPlateModal.vue +166 -0
  41. package/components/core/DpEditor/DpEditor.vue +1281 -0
  42. package/components/core/DpEditor/DpLinkModal.vue +117 -0
  43. package/components/core/DpEditor/DpRecommendationModal/DpInsertableRecommendation.vue +137 -0
  44. package/components/core/DpEditor/DpRecommendationModal.vue +283 -0
  45. package/components/core/DpEditor/DpResizableImage.vue +121 -0
  46. package/components/core/DpEditor/DpUploadModal.vue +121 -0
  47. package/components/core/DpEditor/libs/Decoration.js +66 -0
  48. package/components/core/DpEditor/libs/SegmentRangeChangePlugin.js +35 -0
  49. package/components/core/DpEditor/libs/editorAnonymize.js +66 -0
  50. package/components/core/DpEditor/libs/editorBuildSuggestion.js +269 -0
  51. package/components/core/DpEditor/libs/editorCustomDelete.js +32 -0
  52. package/components/core/DpEditor/libs/editorCustomImage.js +100 -0
  53. package/components/core/DpEditor/libs/editorCustomInsert.js +32 -0
  54. package/components/core/DpEditor/libs/editorCustomLink.js +46 -0
  55. package/components/core/DpEditor/libs/editorCustomMark.js +32 -0
  56. package/components/core/DpEditor/libs/editorInsertAtCursorPos.js +41 -0
  57. package/components/core/DpEditor/libs/editorObscure.js +60 -0
  58. package/components/core/DpEditor/libs/editorUnAnonymize.js +56 -0
  59. package/components/core/DpEditor/libs/handleWordPaste.js +360 -0
  60. package/components/core/DpEditor/libs/preventDrop.js +31 -0
  61. package/components/core/DpEditor/libs/preventKeyboardInput.js +27 -0
  62. package/components/core/DpEditor/libs/preventPaste.js +28 -0
  63. package/components/core/DpFlyout.vue +119 -0
  64. package/components/core/DpInlineNotification.vue +116 -0
  65. package/components/core/DpModal.vue +208 -0
  66. package/components/core/DpObscure.vue +29 -0
  67. package/components/core/DpPager.vue +139 -0
  68. package/components/core/DpProgressBar.vue +67 -0
  69. package/components/core/DpRegisterFlyout.vue +58 -0
  70. package/components/core/DpResettableInput.vue +140 -0
  71. package/components/core/DpSkeletonBox.vue +32 -0
  72. package/components/core/DpSlidebar.vue +86 -0
  73. package/components/core/DpSlidingPagination.vue +45 -0
  74. package/components/core/DpSplitButton.vue +77 -0
  75. package/components/core/DpSwitcher.vue +62 -0
  76. package/components/core/DpTableCardList/DpTableCard.vue +61 -0
  77. package/components/core/DpTableCardList/DpTableCardListHeader.vue +83 -0
  78. package/components/core/DpTabs/DpTab.vue +52 -0
  79. package/components/core/DpTabs/DpTabs.vue +165 -0
  80. package/components/core/DpTextWrapper.vue +65 -0
  81. package/components/core/DpToggleForm.vue +72 -0
  82. package/components/core/DpTooltipIcon.vue +52 -0
  83. package/components/core/DpTransitionExpand.vue +87 -0
  84. package/components/core/DpTreeList/DpTreeList.vue +334 -0
  85. package/components/core/DpTreeList/DpTreeListCheckbox.vue +79 -0
  86. package/components/core/DpTreeList/DpTreeListNode.vue +348 -0
  87. package/components/core/DpTreeList/DpTreeListToggle.vue +71 -0
  88. package/components/core/DpTreeList/utils/constants.js +14 -0
  89. package/components/core/DpUpload/DpUpload.vue +223 -0
  90. package/components/core/DpUpload/DpUploadFiles.vue +269 -0
  91. package/components/core/DpUpload/DpUploadedFile.vue +80 -0
  92. package/components/core/DpUpload/DpUploadedFileList.vue +56 -0
  93. package/components/core/DpUpload/utils/GetFileIdsByHash.js +42 -0
  94. package/components/core/DpUpload/utils/UppyTranslations.js +31 -0
  95. package/components/core/DpVideoPlayer.vue +115 -0
  96. package/components/core/HeightLimit.vue +121 -0
  97. package/components/core/MultistepNav.vue +89 -0
  98. package/components/core/form/DpCheckbox.vue +108 -0
  99. package/components/core/form/DpDateRangePicker.vue +186 -0
  100. package/components/core/form/DpDatepicker.vue +160 -0
  101. package/components/core/form/DpDatetimePicker.vue +194 -0
  102. package/components/core/form/DpFormRow.vue +79 -0
  103. package/components/core/form/DpMultiselect.vue +164 -0
  104. package/components/core/form/DpRadio.vue +128 -0
  105. package/components/core/form/DpSearchField.vue +110 -0
  106. package/components/core/form/DpSelect.vue +149 -0
  107. package/components/core/form/DpTextArea.vue +152 -0
  108. package/components/core/form/DpTimePicker.vue +374 -0
  109. package/components/core/form/DpToggle.vue +78 -0
  110. package/components/core/index.js +132 -0
  111. package/components/core/notify/DpNotifyContainer.vue +122 -0
  112. package/components/core/notify/DpNotifyMessage.vue +95 -0
  113. package/components/core/shared/DpStickyElement.vue +95 -0
  114. package/components/index.js +24 -0
  115. package/components/shared/translations.js +15 -0
  116. package/directives/CleanHtml/CleanHtml.js +50 -0
  117. package/directives/CleanHtml/CleanHtml.stories.mdx +64 -0
  118. package/directives/Tooltip/Tooltip.js +40 -0
  119. package/directives/Tooltip/Tooltip.stories.mdx +42 -0
  120. package/directives/index.js +17 -0
  121. package/lib/index.js +14 -0
  122. package/lib/prefixClass.js +47 -0
  123. package/mixins/index.js +14 -0
  124. package/mixins/prefixClassMixin.js +22 -0
  125. package/package.json +52 -0
  126. package/shared/props.js +86 -0
  127. package/style/index.css +7 -0
  128. package/tailwind.config.js +24 -0
  129. package/tokens/color.json +358 -0
  130. package/tokens/color.stories.mdx +45 -0
  131. package/tokens/fontSize.json +100 -0
  132. package/tokens/space.json +33 -0
  133. package/utils/lengthHint.js +69 -0
@@ -0,0 +1,358 @@
1
+ {
2
+ "color": {
3
+ "palette": {
4
+ "$description": "The raw hex values that other color tokens inherit from. Do not use directly.",
5
+ "white": {
6
+ "value": "#fff"
7
+ },
8
+ "black": {
9
+ "value": "#000"
10
+ },
11
+ "neutral": {
12
+ "$description": "Greyscale palette.",
13
+ "light-4": {
14
+ "value": "#f5f5f5",
15
+ "themeable": true
16
+ },
17
+ "light-3": {
18
+ "value": "#ebe9e9",
19
+ "themeable": true
20
+ },
21
+ "light-2": {
22
+ "value": "#d3d3d3",
23
+ "themeable": true
24
+ },
25
+ "light-1": {
26
+ "value": "#aeaeae",
27
+ "themeable": true
28
+ },
29
+ "base": {
30
+ "value": "#757575",
31
+ "themeable": true
32
+ },
33
+ "dark-1": {
34
+ "value": "#595959",
35
+ "themeable": true
36
+ },
37
+ "dark-2": {
38
+ "value": "#333333",
39
+ "themeable": true
40
+ }
41
+ },
42
+ "blue": {
43
+ "light-4": {
44
+ "value": "#ebf5ff",
45
+ "themeable": true
46
+ },
47
+ "light-3": {
48
+ "value": "#cee6fb",
49
+ "themeable": true
50
+ },
51
+ "light-2": {
52
+ "value": "#82c5ff",
53
+ "themeable": true
54
+ },
55
+ "light-1": {
56
+ "value": "#44a8ff",
57
+ "themeable": true
58
+ },
59
+ "base": {
60
+ "value": "#006fd0",
61
+ "themeable": true
62
+ },
63
+ "dark-1": {
64
+ "value": "#005eb1",
65
+ "themeable": true
66
+ },
67
+ "dark-2": {
68
+ "value": "#004078",
69
+ "themeable": true
70
+ }
71
+ },
72
+ "red": {
73
+ "light-4": {
74
+ "value": "#fff0f0",
75
+ "themeable": true
76
+ },
77
+ "light-3": {
78
+ "value": "#fcdddd",
79
+ "themeable": true
80
+ },
81
+ "light-2": {
82
+ "value": "#ffb3b3",
83
+ "themeable": true
84
+ },
85
+ "light-1": {
86
+ "value": "#fc5e5e",
87
+ "themeable": true
88
+ },
89
+ "base": {
90
+ "value": "#e81616",
91
+ "themeable": true
92
+ },
93
+ "dark-1": {
94
+ "value": "#b20000",
95
+ "themeable": true
96
+ },
97
+ "dark-2": {
98
+ "value": "#820000",
99
+ "themeable": true
100
+ }
101
+ },
102
+ "green": {
103
+ "light-4": {
104
+ "value": "#effbef",
105
+ "themeable": true
106
+ },
107
+ "light-3": {
108
+ "value": "#def7de",
109
+ "themeable": true
110
+ },
111
+ "light-2": {
112
+ "value": "#93e293",
113
+ "themeable": true
114
+ },
115
+ "light-1": {
116
+ "value": "#5cba5c",
117
+ "themeable": true
118
+ },
119
+ "base": {
120
+ "value": "#228b22",
121
+ "themeable": true
122
+ },
123
+ "dark-1": {
124
+ "value": "#186218",
125
+ "themeable": true
126
+ },
127
+ "dark-2": {
128
+ "value": "#064006",
129
+ "themeable": true
130
+ }
131
+ },
132
+ "yellow": {
133
+ "light-4": {
134
+ "value": "#fff7e5",
135
+ "themeable": true
136
+ },
137
+ "light-3": {
138
+ "value": "#ffefca",
139
+ "themeable": true
140
+ },
141
+ "light-2": {
142
+ "value": "#ffe5a7",
143
+ "themeable": true
144
+ },
145
+ "light-1": {
146
+ "value": "#ffd87c",
147
+ "themeable": true
148
+ },
149
+ "base": {
150
+ "value": "#ffbe24",
151
+ "themeable": true
152
+ },
153
+ "dark-1": {
154
+ "value": "#eea700",
155
+ "themeable": true
156
+ },
157
+ "dark-2": {
158
+ "value": "#845d01",
159
+ "themeable": true
160
+ }
161
+ },
162
+ "purple": {
163
+ "light-4": {
164
+ "value": "#f3ecf8",
165
+ "themeable": true
166
+ },
167
+ "light-3": {
168
+ "value": "#dfcced",
169
+ "themeable": true
170
+ },
171
+ "light-2": {
172
+ "value": "#bf99db",
173
+ "themeable": true
174
+ },
175
+ "light-1": {
176
+ "value": "#a572cd",
177
+ "themeable": true
178
+ },
179
+ "base": {
180
+ "value": "#8f4fc0",
181
+ "themeable": true
182
+ },
183
+ "dark-1": {
184
+ "value": "#5e00a6",
185
+ "themeable": true
186
+ },
187
+ "dark-2": {
188
+ "value": "#4b0085",
189
+ "themeable": true
190
+ }
191
+ },
192
+ "magenta": {
193
+ "light-3": {
194
+ "value": "#f3ecf8",
195
+ "themeable": true
196
+ },
197
+ "light-2": {
198
+ "value": "#fbdbe5",
199
+ "themeable": true
200
+ },
201
+ "light-1": {
202
+ "value": "#ff9fbd",
203
+ "themeable": true
204
+ },
205
+ "base": {
206
+ "value": "#d4004b",
207
+ "themeable": true
208
+ },
209
+ "dark-1": {
210
+ "value": "#84002e",
211
+ "themeable": true
212
+ },
213
+ "dark-2": {
214
+ "value": "#600021",
215
+ "themeable": true
216
+ }
217
+ }
218
+ },
219
+ "message": {
220
+ "$description": "Color used to communicate system feedback.",
221
+ "$todo": "Add all other system colors here.",
222
+ "info": {
223
+ "text": {
224
+ "value": "{color.palette.blue.dark-2}"
225
+ }
226
+ }
227
+ },
228
+ "brand": {
229
+ "$description": "Color tokens that are used to express brand.",
230
+ "$todo": "Add other brand colors here. How to deal with small brand palettes? How to deal with css variables inside tokens?",
231
+ "main": {
232
+ "light-3": {
233
+ "value": "{color.palette.blue.light-3}",
234
+ "themeable": true
235
+ },
236
+ "light-2": {
237
+ "value": "{color.palette.blue.light-2}",
238
+ "themeable": true
239
+ },
240
+ "light-1": {
241
+ "value": "{color.palette.blue.light-1}",
242
+ "themeable": true
243
+ },
244
+ "base": {
245
+ "value": "{color.palette.blue.base}",
246
+ "themeable": true
247
+ },
248
+ "dark-1": {
249
+ "value": "{color.palette.blue.dark-1}",
250
+ "themeable": true
251
+ },
252
+ "dark-2": {
253
+ "value": "{color.palette.blue.dark-2}",
254
+ "themeable": true
255
+ }
256
+ }
257
+ },
258
+ "data":{
259
+ "$description": "Data visualization colors",
260
+ "11": {
261
+ "$description": "11 Step palette",
262
+ "1": {
263
+ "value": "#a50026"
264
+ },
265
+ "2": {
266
+ "value": "#d73027"
267
+ },
268
+ "3": {
269
+ "value": "#f46d43"
270
+ },
271
+ "4": {
272
+ "value": "#fdae61"
273
+ },
274
+ "5": {
275
+ "value": "#fee090"
276
+ },
277
+ "6": {
278
+ "value": "#ffffbf"
279
+ },
280
+ "7": {
281
+ "value": "#e0f3f8"
282
+ },
283
+ "8": {
284
+ "value": "#abd9e9"
285
+ },
286
+ "9": {
287
+ "value": "#74add1"
288
+ },
289
+ "10": {
290
+ "value": "#4575b4"
291
+ },
292
+ "11": {
293
+ "value": "#313695"
294
+ }
295
+ },
296
+ "8": {
297
+ "$description": "8 Step palette",
298
+ "1": {
299
+ "value": "#d73027"
300
+ },
301
+ "2": {
302
+ "value": "#f46d43"
303
+ },
304
+ "3": {
305
+ "value": "#fdae61"
306
+ },
307
+ "4": {
308
+ "value": "#fee090"
309
+ },
310
+ "5": {
311
+ "value": "#e0f3f8"
312
+ },
313
+ "6": {
314
+ "value": "#abd9e9"
315
+ },
316
+ "7": {
317
+ "value": "#74add1"
318
+ },
319
+ "8": {
320
+ "value": "#4575b4"
321
+ }
322
+ },
323
+ "6": {
324
+ "$description": "6 Step palette",
325
+ "1": {
326
+ "value": "#d73027"
327
+ },
328
+ "2": {
329
+ "value": "#fc8d59"
330
+ },
331
+ "3": {
332
+ "value": "#fee090"
333
+ },
334
+ "4": {
335
+ "value": "#e0f3f8"
336
+ },
337
+ "5": {
338
+ "value": "#91bfdb"
339
+ },
340
+ "6": {
341
+ "value": "#4575b4"
342
+ }
343
+ },
344
+ "3": {
345
+ "$description": "3 Step palette",
346
+ "1": {
347
+ "value": "#fc8d59"
348
+ },
349
+ "2": {
350
+ "value": "#f1f1a3"
351
+ },
352
+ "3": {
353
+ "value": "#91bfdb"
354
+ }
355
+ }
356
+ }
357
+ }
358
+ }
@@ -0,0 +1,45 @@
1
+ import { Meta } from '@storybook/addon-docs'
2
+
3
+ <Meta
4
+ title="Design Tokens/Color"
5
+ parameters={{
6
+ viewMode: 'docs',
7
+ previewTabs: {
8
+ canvas: {
9
+ hidden: true
10
+ }
11
+ },
12
+ }} />
13
+
14
+ <!-- @TODO integrate https://github.com/UX-and-I/storybook-design-token -->
15
+
16
+ # Color Tokens
17
+
18
+ The demosplan-ui colors are grouped into "scale" (the raw values which should not be used directly), "brand" (for
19
+ colors used in branded context), "message" and "status" (to communicate system state), "data" (for data visualization)
20
+ and "interaction" (to indicate interaction). apart from "brand", colors are not meant to be themeable.
21
+
22
+ ## Color scales
23
+
24
+ Available color scales contain 7 steps: a base color plus 2 shades and 4 lights.
25
+
26
+ ## Neutrals
27
+
28
+ Black, white, and greys.
29
+
30
+ ## Data visualization colors
31
+
32
+ The 4 distinct scales can be used for data visualizations with a defined number of needed colors that differentiate
33
+ from each other.
34
+
35
+ These are generated with https://colorbrewer2.org/#type=diverging&scheme=BrBG&n=8 to be colorblind safe
36
+ and intentionally separate from other color scales.
37
+
38
+ Although these colors are universally used for charts, they need to be refined into "sequential", "categorical",
39
+ and "diverging" when appropriate. Read more if the need arises:
40
+
41
+ - https://design.gitlab.com/data-visualization/color/
42
+ - https://www.carbondesignsystem.com/data-visualization/color-palettes/
43
+ - https://medium.com/design-ibm/inclusive-color-sequences-for-data-viz-in-6-steps-712869b910c2
44
+ - https://medium.com/carbondesign/color-palettes-and-accessibility-features-for-data-visualization-7869f4874fca
45
+ - https://blog.graphiq.com/finding-the-right-color-palettes-for-data-visualizations-fcd4e707a283
@@ -0,0 +1,100 @@
1
+ {
2
+ "font-size": {
3
+ "scale": {
4
+ "0": {
5
+ "value": "11px",
6
+ "themeable": true
7
+ },
8
+ "1": {
9
+ "value": "12px",
10
+ "themeable": true
11
+ },
12
+ "2": {
13
+ "value": "14px",
14
+ "themeable": true
15
+ },
16
+ "3": {
17
+ "value": "16px",
18
+ "themeable": true
19
+ },
20
+ "4": {
21
+ "value": "19.2px",
22
+ "themeable": true
23
+ },
24
+ "5": {
25
+ "value": "23px",
26
+ "themeable": true
27
+ },
28
+ "6": {
29
+ "value": "27.65px",
30
+ "themeable": true
31
+ },
32
+ "7": {
33
+ "value": "50px",
34
+ "themeable": true
35
+ }
36
+ },
37
+ "brand": {
38
+ "hero": {
39
+ "value": "{font-size.scale.7}",
40
+ "themeable": true
41
+ },
42
+ "header": {
43
+ "value": "{font-size.scale.5}",
44
+ "themeable": true
45
+ }
46
+ },
47
+ "heading": {
48
+ "1": {
49
+ "value": "{font-size.scale.6}",
50
+ "themeable": true
51
+ },
52
+ "2": {
53
+ "value": "{font-size.scale.5}",
54
+ "themeable": true
55
+ },
56
+ "3": {
57
+ "value": "{font-size.scale.4}",
58
+ "themeable": true
59
+ },
60
+ "4": {
61
+ "value": "{font-size.scale.3}",
62
+ "themeable": true
63
+ },
64
+ "5": {
65
+ "value": "{font-size.scale.2}",
66
+ "themeable": true
67
+ },
68
+ "6": {
69
+ "value": "{font-size.scale.1}",
70
+ "themeable": true
71
+ }
72
+ },
73
+ "ui": {
74
+ "larger": {
75
+ "value": "{font-size.scale.5}",
76
+ "themeable": true
77
+ },
78
+ "large": {
79
+ "value": "{font-size.scale.4}",
80
+ "themeable": true
81
+ },
82
+ "medium": {
83
+ "value": "{font-size.scale.3}",
84
+ "themeable": true
85
+ },
86
+ "small": {
87
+ "value": "{font-size.scale.2}",
88
+ "themeable": true
89
+ },
90
+ "smaller": {
91
+ "value": "{font-size.scale.1}",
92
+ "themeable": true
93
+ },
94
+ "smallest": {
95
+ "value": "{font-size.scale.0}",
96
+ "themeable": true
97
+ }
98
+ }
99
+ }
100
+ }
@@ -0,0 +1,33 @@
1
+ {
2
+ "dp": {
3
+ "space": {
4
+ "0": {
5
+ "value": "0px"
6
+ },
7
+ "1": {
8
+ "value": "3px"
9
+ },
10
+ "2": {
11
+ "value": "6px"
12
+ },
13
+ "3": {
14
+ "value": "9px"
15
+ },
16
+ "4": {
17
+ "value": "12px"
18
+ },
19
+ "6": {
20
+ "value": "18px"
21
+ },
22
+ "8": {
23
+ "value": "24px"
24
+ },
25
+ "12": {
26
+ "value": "36px"
27
+ },
28
+ "16": {
29
+ "value": "48px"
30
+ }
31
+ }
32
+ }
33
+ }
@@ -0,0 +1,69 @@
1
+ /**
2
+ * (c) 2010-present DEMOS E-Partizipation GmbH.
3
+ *
4
+ * This file is part of the package @demos-europe/demosplan-ui,
5
+ * for more information see the license file.
6
+ *
7
+ * All rights reserved
8
+ */
9
+
10
+ /**
11
+ * Return a translated hint on exact matching characters.
12
+ * @param {Number} currentLength Currently used character count
13
+ * @param {*|String} requiredLength Expected amount of characters
14
+ * @return {*|string}
15
+ */
16
+ const exactlengthHint = (currentLength, requiredLength) => {
17
+ const reqLength = Number(requiredLength)
18
+
19
+ return reqLength
20
+ ? Translator.trans('input.text.exactlength.short', {
21
+ requiredlength: requiredLength,
22
+ count: currentLength,
23
+ class: (currentLength === reqLength) ? 'color-ui-info' : 'color-ui-error'
24
+ })
25
+ : ''
26
+ }
27
+
28
+ /**
29
+ * Return a translated hint on maximum available characters.
30
+ * @param {Number} currentLength Currently used character count
31
+ * @param {*|String} maxlength Max available characters
32
+ * @return {*|string}
33
+ */
34
+ const maxlengthHint = (currentLength, maxlength) => {
35
+ /*
36
+ * In cases with more than 50 characters available, the available characters should be highlighted with a different
37
+ * color when dropping below 15. For less than 50 characters, only the remaining 3 chars are highlighted that way.
38
+ */
39
+ const errorThreshold = maxlength > 50 ? 15 : 3
40
+ const max = Number(maxlength)
41
+
42
+ return max
43
+ ? Translator.trans('input.text.maxlength.short', {
44
+ max,
45
+ count: max - currentLength,
46
+ class: (max - currentLength > errorThreshold) ? 'color-ui-info' : 'color-ui-error'
47
+ })
48
+ : ''
49
+ }
50
+
51
+ /**
52
+ * Return a translated hint on minimum available characters.
53
+ * @param {Number} currentLength Currently used character count
54
+ * @param {*|String} minlength Min available characters
55
+ * @return {*|string}
56
+ */
57
+ const minlengthHint = (currentLength, minlength) => {
58
+ const min = Number(minlength)
59
+
60
+ return min
61
+ ? Translator.trans('input.text.minlength.short', {
62
+ min: min,
63
+ count: min - currentLength,
64
+ class: (min <= currentLength) ? 'color-ui-info' : 'color-ui-error'
65
+ })
66
+ : ''
67
+ }
68
+
69
+ export { exactlengthHint, maxlengthHint, minlengthHint }