@bigbinary/neeto-fields-frontend 2.0.0 → 2.2.0

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 (74) hide show
  1. package/dist/DeleteAlert-b92f7c05.js +763 -0
  2. package/dist/DeleteAlert-b92f7c05.js.map +1 -0
  3. package/dist/DeleteAlert-fbc41b31.js +780 -0
  4. package/dist/DeleteAlert-fbc41b31.js.map +1 -0
  5. package/dist/FieldDeleteAlert.js +22 -0
  6. package/dist/FieldDeleteAlert.js.map +1 -0
  7. package/dist/FieldInputs.js +58 -0
  8. package/dist/FieldInputs.js.map +1 -0
  9. package/dist/FieldValueInputWrapper-adbbc915.js +198 -0
  10. package/dist/FieldValueInputWrapper-adbbc915.js.map +1 -0
  11. package/dist/FieldValueInputWrapper-f1f2e095.js +189 -0
  12. package/dist/FieldValueInputWrapper-f1f2e095.js.map +1 -0
  13. package/dist/FieldValuesContainer.js +223 -0
  14. package/dist/FieldValuesContainer.js.map +1 -0
  15. package/dist/FieldsDashboard.js +5000 -0
  16. package/dist/FieldsDashboard.js.map +1 -0
  17. package/dist/FieldsPane.js +563 -0
  18. package/dist/FieldsPane.js.map +1 -0
  19. package/dist/InlineFieldValueInput.js +157 -0
  20. package/dist/InlineFieldValueInput.js.map +1 -0
  21. package/dist/_commonjsHelpers-1789f0cf.js +8 -0
  22. package/dist/_commonjsHelpers-1789f0cf.js.map +1 -0
  23. package/dist/_commonjsHelpers-b3309d7b.js +11 -0
  24. package/dist/_commonjsHelpers-b3309d7b.js.map +1 -0
  25. package/dist/cjs/FieldDeleteAlert.js +28 -0
  26. package/dist/cjs/FieldDeleteAlert.js.map +1 -0
  27. package/dist/cjs/FieldInputs.js +64 -0
  28. package/dist/cjs/FieldInputs.js.map +1 -0
  29. package/dist/cjs/FieldValuesContainer.js +232 -0
  30. package/dist/cjs/FieldValuesContainer.js.map +1 -0
  31. package/dist/{index.cjs.js → cjs/FieldsDashboard.js} +120 -3427
  32. package/dist/cjs/FieldsDashboard.js.map +1 -0
  33. package/dist/cjs/FieldsPane.js +598 -0
  34. package/dist/cjs/FieldsPane.js.map +1 -0
  35. package/dist/cjs/InlineFieldValueInput.js +164 -0
  36. package/dist/cjs/InlineFieldValueInput.js.map +1 -0
  37. package/dist/cjs/hooks.js +20 -0
  38. package/dist/cjs/hooks.js.map +1 -0
  39. package/dist/cjs/index.js +84 -0
  40. package/dist/cjs/index.js.map +1 -0
  41. package/dist/cjs/utils.js +34 -0
  42. package/dist/cjs/utils.js.map +1 -0
  43. package/dist/constants-0e6017ea.js +57 -0
  44. package/dist/constants-0e6017ea.js.map +1 -0
  45. package/dist/constants-c71008a3.js +64 -0
  46. package/dist/constants-c71008a3.js.map +1 -0
  47. package/dist/hooks.js +8 -0
  48. package/dist/hooks.js.map +1 -0
  49. package/dist/index-265f7913.js +117 -0
  50. package/dist/index-265f7913.js.map +1 -0
  51. package/dist/index-27e54c2c.js +130 -0
  52. package/dist/index-27e54c2c.js.map +1 -0
  53. package/dist/index.js +64 -8255
  54. package/dist/index.js.map +1 -1
  55. package/dist/query-0df5b2dd.js +13 -0
  56. package/dist/query-0df5b2dd.js.map +1 -0
  57. package/dist/query-1a62b3ac.js +10 -0
  58. package/dist/query-1a62b3ac.js.map +1 -0
  59. package/dist/slicedToArray-50f7cc19.js +46 -0
  60. package/dist/slicedToArray-50f7cc19.js.map +1 -0
  61. package/dist/slicedToArray-6198349b.js +44 -0
  62. package/dist/slicedToArray-6198349b.js.map +1 -0
  63. package/dist/useFieldsApi-14928ecf.js +161 -0
  64. package/dist/useFieldsApi-14928ecf.js.map +1 -0
  65. package/dist/useFieldsApi-5c114bac.js +149 -0
  66. package/dist/useFieldsApi-5c114bac.js.map +1 -0
  67. package/dist/utils-4812fc6c.js +1140 -0
  68. package/dist/utils-4812fc6c.js.map +1 -0
  69. package/dist/utils-85ed1903.js +1180 -0
  70. package/dist/utils-85ed1903.js.map +1 -0
  71. package/dist/utils.js +26 -0
  72. package/dist/utils.js.map +1 -0
  73. package/package.json +27 -13
  74. package/dist/index.cjs.js.map +0 -1
@@ -0,0 +1,763 @@
1
+ import { slugify, humanize, findBy, isPresent, isNotEmpty } from '@bigbinary/neeto-cist';
2
+ import Alert from '@bigbinary/neetoui/Alert';
3
+ import { Trans, useTranslation } from 'react-i18next';
4
+ import { f as useFetchDependencies } from './useFieldsApi-5c114bac.js';
5
+ import { t } from 'i18next';
6
+ import MenuBar from '@bigbinary/neeto-molecules/MenuBar';
7
+ import MoreDropdown from '@bigbinary/neeto-molecules/MoreDropdown';
8
+ import Tab from '@bigbinary/neetoui/Tab';
9
+ import Typography from '@bigbinary/neetoui/Typography';
10
+ import Button from '@bigbinary/neetoui/Button';
11
+ import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './_commonjsHelpers-1789f0cf.js';
12
+ import { not } from 'ramda';
13
+ import { a as DISPLAY_KINDS, F as FIELD_STATES, M as MENU_ITEMS } from './constants-0e6017ea.js';
14
+ import { jsx, jsxs } from 'react/jsx-runtime';
15
+
16
+ function commonjsRequire(path) {
17
+ throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
18
+ }
19
+
20
+ var pluralize$1 = {exports: {}};
21
+
22
+ /* global define */
23
+ pluralize$1.exports;
24
+
25
+ (function (module, exports) {
26
+ (function (root, pluralize) {
27
+ /* istanbul ignore else */
28
+ if (typeof commonjsRequire === 'function' && 'object' === 'object' && 'object' === 'object') {
29
+ // Node.
30
+ module.exports = pluralize();
31
+ } else {
32
+ // Browser global.
33
+ root.pluralize = pluralize();
34
+ }
35
+ })(commonjsGlobal, function () {
36
+ // Rule storage - pluralize and singularize need to be run sequentially,
37
+ // while other rules can be optimized using an object for instant lookups.
38
+ var pluralRules = [];
39
+ var singularRules = [];
40
+ var uncountables = {};
41
+ var irregularPlurals = {};
42
+ var irregularSingles = {};
43
+
44
+ /**
45
+ * Sanitize a pluralization rule to a usable regular expression.
46
+ *
47
+ * @param {(RegExp|string)} rule
48
+ * @return {RegExp}
49
+ */
50
+ function sanitizeRule (rule) {
51
+ if (typeof rule === 'string') {
52
+ return new RegExp('^' + rule + '$', 'i');
53
+ }
54
+
55
+ return rule;
56
+ }
57
+
58
+ /**
59
+ * Pass in a word token to produce a function that can replicate the case on
60
+ * another word.
61
+ *
62
+ * @param {string} word
63
+ * @param {string} token
64
+ * @return {Function}
65
+ */
66
+ function restoreCase (word, token) {
67
+ // Tokens are an exact match.
68
+ if (word === token) return token;
69
+
70
+ // Lower cased words. E.g. "hello".
71
+ if (word === word.toLowerCase()) return token.toLowerCase();
72
+
73
+ // Upper cased words. E.g. "WHISKY".
74
+ if (word === word.toUpperCase()) return token.toUpperCase();
75
+
76
+ // Title cased words. E.g. "Title".
77
+ if (word[0] === word[0].toUpperCase()) {
78
+ return token.charAt(0).toUpperCase() + token.substr(1).toLowerCase();
79
+ }
80
+
81
+ // Lower cased words. E.g. "test".
82
+ return token.toLowerCase();
83
+ }
84
+
85
+ /**
86
+ * Interpolate a regexp string.
87
+ *
88
+ * @param {string} str
89
+ * @param {Array} args
90
+ * @return {string}
91
+ */
92
+ function interpolate (str, args) {
93
+ return str.replace(/\$(\d{1,2})/g, function (match, index) {
94
+ return args[index] || '';
95
+ });
96
+ }
97
+
98
+ /**
99
+ * Replace a word using a rule.
100
+ *
101
+ * @param {string} word
102
+ * @param {Array} rule
103
+ * @return {string}
104
+ */
105
+ function replace (word, rule) {
106
+ return word.replace(rule[0], function (match, index) {
107
+ var result = interpolate(rule[1], arguments);
108
+
109
+ if (match === '') {
110
+ return restoreCase(word[index - 1], result);
111
+ }
112
+
113
+ return restoreCase(match, result);
114
+ });
115
+ }
116
+
117
+ /**
118
+ * Sanitize a word by passing in the word and sanitization rules.
119
+ *
120
+ * @param {string} token
121
+ * @param {string} word
122
+ * @param {Array} rules
123
+ * @return {string}
124
+ */
125
+ function sanitizeWord (token, word, rules) {
126
+ // Empty string or doesn't need fixing.
127
+ if (!token.length || uncountables.hasOwnProperty(token)) {
128
+ return word;
129
+ }
130
+
131
+ var len = rules.length;
132
+
133
+ // Iterate over the sanitization rules and use the first one to match.
134
+ while (len--) {
135
+ var rule = rules[len];
136
+
137
+ if (rule[0].test(word)) return replace(word, rule);
138
+ }
139
+
140
+ return word;
141
+ }
142
+
143
+ /**
144
+ * Replace a word with the updated word.
145
+ *
146
+ * @param {Object} replaceMap
147
+ * @param {Object} keepMap
148
+ * @param {Array} rules
149
+ * @return {Function}
150
+ */
151
+ function replaceWord (replaceMap, keepMap, rules) {
152
+ return function (word) {
153
+ // Get the correct token and case restoration functions.
154
+ var token = word.toLowerCase();
155
+
156
+ // Check against the keep object map.
157
+ if (keepMap.hasOwnProperty(token)) {
158
+ return restoreCase(word, token);
159
+ }
160
+
161
+ // Check against the replacement map for a direct word replacement.
162
+ if (replaceMap.hasOwnProperty(token)) {
163
+ return restoreCase(word, replaceMap[token]);
164
+ }
165
+
166
+ // Run all the rules against the word.
167
+ return sanitizeWord(token, word, rules);
168
+ };
169
+ }
170
+
171
+ /**
172
+ * Check if a word is part of the map.
173
+ */
174
+ function checkWord (replaceMap, keepMap, rules, bool) {
175
+ return function (word) {
176
+ var token = word.toLowerCase();
177
+
178
+ if (keepMap.hasOwnProperty(token)) return true;
179
+ if (replaceMap.hasOwnProperty(token)) return false;
180
+
181
+ return sanitizeWord(token, token, rules) === token;
182
+ };
183
+ }
184
+
185
+ /**
186
+ * Pluralize or singularize a word based on the passed in count.
187
+ *
188
+ * @param {string} word The word to pluralize
189
+ * @param {number} count How many of the word exist
190
+ * @param {boolean} inclusive Whether to prefix with the number (e.g. 3 ducks)
191
+ * @return {string}
192
+ */
193
+ function pluralize (word, count, inclusive) {
194
+ var pluralized = count === 1
195
+ ? pluralize.singular(word) : pluralize.plural(word);
196
+
197
+ return (inclusive ? count + ' ' : '') + pluralized;
198
+ }
199
+
200
+ /**
201
+ * Pluralize a word.
202
+ *
203
+ * @type {Function}
204
+ */
205
+ pluralize.plural = replaceWord(
206
+ irregularSingles, irregularPlurals, pluralRules
207
+ );
208
+
209
+ /**
210
+ * Check if a word is plural.
211
+ *
212
+ * @type {Function}
213
+ */
214
+ pluralize.isPlural = checkWord(
215
+ irregularSingles, irregularPlurals, pluralRules
216
+ );
217
+
218
+ /**
219
+ * Singularize a word.
220
+ *
221
+ * @type {Function}
222
+ */
223
+ pluralize.singular = replaceWord(
224
+ irregularPlurals, irregularSingles, singularRules
225
+ );
226
+
227
+ /**
228
+ * Check if a word is singular.
229
+ *
230
+ * @type {Function}
231
+ */
232
+ pluralize.isSingular = checkWord(
233
+ irregularPlurals, irregularSingles, singularRules
234
+ );
235
+
236
+ /**
237
+ * Add a pluralization rule to the collection.
238
+ *
239
+ * @param {(string|RegExp)} rule
240
+ * @param {string} replacement
241
+ */
242
+ pluralize.addPluralRule = function (rule, replacement) {
243
+ pluralRules.push([sanitizeRule(rule), replacement]);
244
+ };
245
+
246
+ /**
247
+ * Add a singularization rule to the collection.
248
+ *
249
+ * @param {(string|RegExp)} rule
250
+ * @param {string} replacement
251
+ */
252
+ pluralize.addSingularRule = function (rule, replacement) {
253
+ singularRules.push([sanitizeRule(rule), replacement]);
254
+ };
255
+
256
+ /**
257
+ * Add an uncountable word rule.
258
+ *
259
+ * @param {(string|RegExp)} word
260
+ */
261
+ pluralize.addUncountableRule = function (word) {
262
+ if (typeof word === 'string') {
263
+ uncountables[word.toLowerCase()] = true;
264
+ return;
265
+ }
266
+
267
+ // Set singular and plural references for the word.
268
+ pluralize.addPluralRule(word, '$0');
269
+ pluralize.addSingularRule(word, '$0');
270
+ };
271
+
272
+ /**
273
+ * Add an irregular word definition.
274
+ *
275
+ * @param {string} single
276
+ * @param {string} plural
277
+ */
278
+ pluralize.addIrregularRule = function (single, plural) {
279
+ plural = plural.toLowerCase();
280
+ single = single.toLowerCase();
281
+
282
+ irregularSingles[single] = plural;
283
+ irregularPlurals[plural] = single;
284
+ };
285
+
286
+ /**
287
+ * Irregular rules.
288
+ */
289
+ [
290
+ // Pronouns.
291
+ ['I', 'we'],
292
+ ['me', 'us'],
293
+ ['he', 'they'],
294
+ ['she', 'they'],
295
+ ['them', 'them'],
296
+ ['myself', 'ourselves'],
297
+ ['yourself', 'yourselves'],
298
+ ['itself', 'themselves'],
299
+ ['herself', 'themselves'],
300
+ ['himself', 'themselves'],
301
+ ['themself', 'themselves'],
302
+ ['is', 'are'],
303
+ ['was', 'were'],
304
+ ['has', 'have'],
305
+ ['this', 'these'],
306
+ ['that', 'those'],
307
+ // Words ending in with a consonant and `o`.
308
+ ['echo', 'echoes'],
309
+ ['dingo', 'dingoes'],
310
+ ['volcano', 'volcanoes'],
311
+ ['tornado', 'tornadoes'],
312
+ ['torpedo', 'torpedoes'],
313
+ // Ends with `us`.
314
+ ['genus', 'genera'],
315
+ ['viscus', 'viscera'],
316
+ // Ends with `ma`.
317
+ ['stigma', 'stigmata'],
318
+ ['stoma', 'stomata'],
319
+ ['dogma', 'dogmata'],
320
+ ['lemma', 'lemmata'],
321
+ ['schema', 'schemata'],
322
+ ['anathema', 'anathemata'],
323
+ // Other irregular rules.
324
+ ['ox', 'oxen'],
325
+ ['axe', 'axes'],
326
+ ['die', 'dice'],
327
+ ['yes', 'yeses'],
328
+ ['foot', 'feet'],
329
+ ['eave', 'eaves'],
330
+ ['goose', 'geese'],
331
+ ['tooth', 'teeth'],
332
+ ['quiz', 'quizzes'],
333
+ ['human', 'humans'],
334
+ ['proof', 'proofs'],
335
+ ['carve', 'carves'],
336
+ ['valve', 'valves'],
337
+ ['looey', 'looies'],
338
+ ['thief', 'thieves'],
339
+ ['groove', 'grooves'],
340
+ ['pickaxe', 'pickaxes'],
341
+ ['passerby', 'passersby']
342
+ ].forEach(function (rule) {
343
+ return pluralize.addIrregularRule(rule[0], rule[1]);
344
+ });
345
+
346
+ /**
347
+ * Pluralization rules.
348
+ */
349
+ [
350
+ [/s?$/i, 's'],
351
+ [/[^\u0000-\u007F]$/i, '$0'],
352
+ [/([^aeiou]ese)$/i, '$1'],
353
+ [/(ax|test)is$/i, '$1es'],
354
+ [/(alias|[^aou]us|t[lm]as|gas|ris)$/i, '$1es'],
355
+ [/(e[mn]u)s?$/i, '$1s'],
356
+ [/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i, '$1'],
357
+ [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, '$1i'],
358
+ [/(alumn|alg|vertebr)(?:a|ae)$/i, '$1ae'],
359
+ [/(seraph|cherub)(?:im)?$/i, '$1im'],
360
+ [/(her|at|gr)o$/i, '$1oes'],
361
+ [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i, '$1a'],
362
+ [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i, '$1a'],
363
+ [/sis$/i, 'ses'],
364
+ [/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i, '$1$2ves'],
365
+ [/([^aeiouy]|qu)y$/i, '$1ies'],
366
+ [/([^ch][ieo][ln])ey$/i, '$1ies'],
367
+ [/(x|ch|ss|sh|zz)$/i, '$1es'],
368
+ [/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i, '$1ices'],
369
+ [/\b((?:tit)?m|l)(?:ice|ouse)$/i, '$1ice'],
370
+ [/(pe)(?:rson|ople)$/i, '$1ople'],
371
+ [/(child)(?:ren)?$/i, '$1ren'],
372
+ [/eaux$/i, '$0'],
373
+ [/m[ae]n$/i, 'men'],
374
+ ['thou', 'you']
375
+ ].forEach(function (rule) {
376
+ return pluralize.addPluralRule(rule[0], rule[1]);
377
+ });
378
+
379
+ /**
380
+ * Singularization rules.
381
+ */
382
+ [
383
+ [/s$/i, ''],
384
+ [/(ss)$/i, '$1'],
385
+ [/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i, '$1fe'],
386
+ [/(ar|(?:wo|[ae])l|[eo][ao])ves$/i, '$1f'],
387
+ [/ies$/i, 'y'],
388
+ [/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i, '$1ie'],
389
+ [/\b(mon|smil)ies$/i, '$1ey'],
390
+ [/\b((?:tit)?m|l)ice$/i, '$1ouse'],
391
+ [/(seraph|cherub)im$/i, '$1'],
392
+ [/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i, '$1'],
393
+ [/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i, '$1sis'],
394
+ [/(movie|twelve|abuse|e[mn]u)s$/i, '$1'],
395
+ [/(test)(?:is|es)$/i, '$1is'],
396
+ [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, '$1us'],
397
+ [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i, '$1um'],
398
+ [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i, '$1on'],
399
+ [/(alumn|alg|vertebr)ae$/i, '$1a'],
400
+ [/(cod|mur|sil|vert|ind)ices$/i, '$1ex'],
401
+ [/(matr|append)ices$/i, '$1ix'],
402
+ [/(pe)(rson|ople)$/i, '$1rson'],
403
+ [/(child)ren$/i, '$1'],
404
+ [/(eau)x?$/i, '$1'],
405
+ [/men$/i, 'man']
406
+ ].forEach(function (rule) {
407
+ return pluralize.addSingularRule(rule[0], rule[1]);
408
+ });
409
+
410
+ /**
411
+ * Uncountable rules.
412
+ */
413
+ [
414
+ // Singular words with no plurals.
415
+ 'adulthood',
416
+ 'advice',
417
+ 'agenda',
418
+ 'aid',
419
+ 'aircraft',
420
+ 'alcohol',
421
+ 'ammo',
422
+ 'analytics',
423
+ 'anime',
424
+ 'athletics',
425
+ 'audio',
426
+ 'bison',
427
+ 'blood',
428
+ 'bream',
429
+ 'buffalo',
430
+ 'butter',
431
+ 'carp',
432
+ 'cash',
433
+ 'chassis',
434
+ 'chess',
435
+ 'clothing',
436
+ 'cod',
437
+ 'commerce',
438
+ 'cooperation',
439
+ 'corps',
440
+ 'debris',
441
+ 'diabetes',
442
+ 'digestion',
443
+ 'elk',
444
+ 'energy',
445
+ 'equipment',
446
+ 'excretion',
447
+ 'expertise',
448
+ 'firmware',
449
+ 'flounder',
450
+ 'fun',
451
+ 'gallows',
452
+ 'garbage',
453
+ 'graffiti',
454
+ 'hardware',
455
+ 'headquarters',
456
+ 'health',
457
+ 'herpes',
458
+ 'highjinks',
459
+ 'homework',
460
+ 'housework',
461
+ 'information',
462
+ 'jeans',
463
+ 'justice',
464
+ 'kudos',
465
+ 'labour',
466
+ 'literature',
467
+ 'machinery',
468
+ 'mackerel',
469
+ 'mail',
470
+ 'media',
471
+ 'mews',
472
+ 'moose',
473
+ 'music',
474
+ 'mud',
475
+ 'manga',
476
+ 'news',
477
+ 'only',
478
+ 'personnel',
479
+ 'pike',
480
+ 'plankton',
481
+ 'pliers',
482
+ 'police',
483
+ 'pollution',
484
+ 'premises',
485
+ 'rain',
486
+ 'research',
487
+ 'rice',
488
+ 'salmon',
489
+ 'scissors',
490
+ 'series',
491
+ 'sewage',
492
+ 'shambles',
493
+ 'shrimp',
494
+ 'software',
495
+ 'species',
496
+ 'staff',
497
+ 'swine',
498
+ 'tennis',
499
+ 'traffic',
500
+ 'transportation',
501
+ 'trout',
502
+ 'tuna',
503
+ 'wealth',
504
+ 'welfare',
505
+ 'whiting',
506
+ 'wildebeest',
507
+ 'wildlife',
508
+ 'you',
509
+ /pok[eé]mon$/i,
510
+ // Regexes.
511
+ /[^aeiou]ese$/i, // "chinese", "japanese"
512
+ /deer$/i, // "deer", "reindeer"
513
+ /fish$/i, // "fish", "blowfish", "angelfish"
514
+ /measles$/i,
515
+ /o[iu]s$/i, // "carnivorous"
516
+ /pox$/i, // "chickpox", "smallpox"
517
+ /sheep$/i
518
+ ].forEach(pluralize.addUncountableRule);
519
+
520
+ return pluralize;
521
+ });
522
+ } (pluralize$1, pluralize$1.exports));
523
+
524
+ var pluralizeExports = pluralize$1.exports;
525
+ var pluralize = /*@__PURE__*/getDefaultExportFromCjs(pluralizeExports);
526
+
527
+ var getMenuItems = function getMenuItems(_ref) {
528
+ var field = _ref.field,
529
+ onDeleteClick = _ref.onDeleteClick,
530
+ onEditClick = _ref.onEditClick;
531
+ return [{
532
+ key: MENU_ITEMS.EDIT,
533
+ "data-cy": "edit-menu-item-button",
534
+ label: t("neetoFields.labels.edit"),
535
+ onClick: function onClick() {
536
+ return onEditClick(field);
537
+ }
538
+ }, {
539
+ key: MENU_ITEMS.DELETE,
540
+ "data-cy": "delete-menu-item-button",
541
+ label: t("neetoFields.labels.delete"),
542
+ isVisible: not(field.isSystem),
543
+ onClick: function onClick() {
544
+ return onDeleteClick(field);
545
+ }
546
+ }];
547
+ };
548
+ var buildDefaultColumns = function buildDefaultColumns(_ref2) {
549
+ var onDeleteClick = _ref2.onDeleteClick,
550
+ onEditClick = _ref2.onEditClick;
551
+ return [{
552
+ key: "name",
553
+ dataIndex: "name",
554
+ title: t("neetoFields.titles.fieldName"),
555
+ width: 300,
556
+ render: function render(name, field) {
557
+ return /*#__PURE__*/jsxs("div", {
558
+ className: "flex items-center justify-between gap-x-3",
559
+ children: [/*#__PURE__*/jsx(Typography, {
560
+ style: "body2",
561
+ children: name
562
+ }), /*#__PURE__*/jsx(MoreDropdown, {
563
+ dropdownProps: {
564
+ strategy: "fixed"
565
+ },
566
+ menuItems: getMenuItems({
567
+ field: field,
568
+ onDeleteClick: onDeleteClick,
569
+ onEditClick: onEditClick
570
+ }),
571
+ dropdownButtonProps: {
572
+ className: "flex-shrink-0",
573
+ "data-cy": "neeto-fields-options-dropdown"
574
+ }
575
+ })]
576
+ });
577
+ }
578
+ }, {
579
+ key: "kind",
580
+ dataIndex: "kind",
581
+ title: t("neetoFields.titles.fieldKind"),
582
+ render: function render(kind) {
583
+ return DISPLAY_KINDS[kind];
584
+ },
585
+ width: 180
586
+ }, {
587
+ key: "isRequired",
588
+ dataIndex: "isRequired",
589
+ title: t("neetoFields.titles.required"),
590
+ width: 140,
591
+ render: function render(boolVal) {
592
+ return boolVal ? t("neetoFields.common.yes") : t("neetoFields.common.no");
593
+ }
594
+ }];
595
+ };
596
+ var renderMenuBarItems = function renderMenuBarItems(_ref3) {
597
+ var items = _ref3.items,
598
+ isOwnerBased = _ref3.isOwnerBased,
599
+ selectedMenu = _ref3.selectedMenu,
600
+ handleBlockClick = _ref3.handleBlockClick,
601
+ nameAliases = _ref3.nameAliases,
602
+ title = _ref3.title;
603
+ title = title.toLocaleLowerCase();
604
+ if (isOwnerBased) {
605
+ return items.map(function (item) {
606
+ return /*#__PURE__*/jsx(MenuBar.Item, {
607
+ active: selectedMenu === item.id,
608
+ "data-cy": "menubar-".concat(slugify(item.name), "-menu-item"),
609
+ label: humanize(item.name),
610
+ description: t("neetoFields.messages.manageTitleForResource", {
611
+ title: title,
612
+ resource: humanize(item.name)
613
+ }),
614
+ onClick: handleBlockClick({
615
+ resource: item.id
616
+ })
617
+ }, item.id);
618
+ });
619
+ }
620
+ return items.length > 1 && items.map(function (_ref4) {
621
+ var label = _ref4.label,
622
+ value = _ref4.value;
623
+ var itemLabel = nameAliases[label] || humanize(label);
624
+ return /*#__PURE__*/jsx(MenuBar.Item, {
625
+ active: selectedMenu === value,
626
+ "data-cy": "neeto-fields-".concat(slugify(itemLabel), "-menu-item"),
627
+ label: itemLabel,
628
+ description: t("neetoFields.messages.manageTitleForResource", {
629
+ title: title,
630
+ resource: itemLabel
631
+ }),
632
+ onClick: handleBlockClick({
633
+ resource: value
634
+ })
635
+ }, label);
636
+ });
637
+ };
638
+ var renderStateFilterTabs = function renderStateFilterTabs(_ref5) {
639
+ var selectedState = _ref5.selectedState,
640
+ fieldStatesTaxonomy = _ref5.fieldStatesTaxonomy,
641
+ activeFieldsCount = _ref5.activeFieldsCount,
642
+ inactiveFieldsCount = _ref5.inactiveFieldsCount,
643
+ handleBlockClick = _ref5.handleBlockClick;
644
+ return /*#__PURE__*/jsxs(Tab, {
645
+ className: "mb-4",
646
+ children: [/*#__PURE__*/jsxs(Tab.Item, {
647
+ active: selectedState === FIELD_STATES.active,
648
+ "data-cy": "menubar-active-block",
649
+ onClick: handleBlockClick({
650
+ state: FIELD_STATES.active
651
+ }),
652
+ children: [fieldStatesTaxonomy.active, "(", activeFieldsCount, ")"]
653
+ }), /*#__PURE__*/jsxs(Tab.Item, {
654
+ active: selectedState === FIELD_STATES.inactive,
655
+ "data-cy": "menubar-inactive-block",
656
+ onClick: handleBlockClick({
657
+ state: FIELD_STATES.inactive
658
+ }),
659
+ children: [fieldStatesTaxonomy.inactive, "(", inactiveFieldsCount, ")"]
660
+ })]
661
+ });
662
+ };
663
+ var getResourceName = function getResourceName(_ref6) {
664
+ var _findBy2;
665
+ var isOwnerBased = _ref6.isOwnerBased,
666
+ menuItems = _ref6.menuItems,
667
+ selectedVal = _ref6.selectedVal,
668
+ nameAliases = _ref6.nameAliases;
669
+ if (isOwnerBased) {
670
+ var _findBy;
671
+ return (_findBy = findBy({
672
+ id: selectedVal
673
+ }, menuItems)) === null || _findBy === void 0 ? void 0 : _findBy.name;
674
+ }
675
+ var selectedName = (_findBy2 = findBy({
676
+ value: selectedVal
677
+ }, menuItems)) === null || _findBy2 === void 0 ? void 0 : _findBy2.label;
678
+ return nameAliases[selectedName] || selectedName;
679
+ };
680
+ var getDashBoardTitle = function getDashBoardTitle(_ref7) {
681
+ var resourceName = _ref7.resourceName,
682
+ isSingleResource = _ref7.isSingleResource,
683
+ title = _ref7.title;
684
+ var displayTitle = !isSingleResource && isPresent(resourceName) ? t("neetoFields.messages.titleForResource", {
685
+ title: title,
686
+ resource: resourceName
687
+ }) : title;
688
+ return humanize(displayTitle);
689
+ };
690
+ var renderNoDataHelpText = function renderNoDataHelpText(title, url) {
691
+ return /*#__PURE__*/jsx(Trans, {
692
+ i18nKey: "neetoFields.helpTexts.noData",
693
+ values: {
694
+ title: title
695
+ },
696
+ components: {
697
+ a: /*#__PURE__*/jsx(Button, {
698
+ "data-cy": "no-data-help-text-link",
699
+ style: "link",
700
+ target: "_blank",
701
+ to: {
702
+ pathname: url
703
+ }
704
+ })
705
+ }
706
+ });
707
+ };
708
+ var getDeletionConfirmationMessage = function getDeletionConfirmationMessage(_ref8) {
709
+ var resource = _ref8.resource,
710
+ fieldName = _ref8.fieldName,
711
+ affectedResourcesCount = _ref8.affectedResourcesCount;
712
+ return affectedResourcesCount > 0 ? /*#__PURE__*/jsx(Trans, {
713
+ i18nKey: "neetoFields.messages.confirmDeleteWithCount",
714
+ values: {
715
+ resource: pluralize(resource, affectedResourcesCount),
716
+ name: fieldName,
717
+ count: affectedResourcesCount
718
+ }
719
+ }) : /*#__PURE__*/jsx(Trans, {
720
+ i18nKey: "neetoFields.messages.confirmDelete",
721
+ values: {
722
+ name: fieldName
723
+ }
724
+ });
725
+ };
726
+
727
+ var DeleteAlert = function DeleteAlert(_ref) {
728
+ var selectedField = _ref.selectedField,
729
+ ownerId = _ref.ownerId,
730
+ isDeleteAlertOpen = _ref.isDeleteAlertOpen,
731
+ isDeleting = _ref.isDeleting,
732
+ resourceTypeName = _ref.resourceTypeName,
733
+ handleAlertClose = _ref.handleAlertClose,
734
+ handleDelete = _ref.handleDelete;
735
+ var _useTranslation = useTranslation(),
736
+ t = _useTranslation.t;
737
+ var _useFetchDependencies = useFetchDependencies({
738
+ fieldId: selectedField.id,
739
+ ownerId: ownerId
740
+ }, {
741
+ enabled: isDeleteAlertOpen && isNotEmpty(selectedField)
742
+ }),
743
+ _useFetchDependencies2 = _useFetchDependencies.data,
744
+ _useFetchDependencies3 = _useFetchDependencies2 === void 0 ? {} : _useFetchDependencies2,
745
+ affectedResourcesCount = _useFetchDependencies3.affectedResourcesCount;
746
+ return /*#__PURE__*/jsx(Alert, {
747
+ affectedResourcesCount: affectedResourcesCount,
748
+ isOpen: isDeleteAlertOpen,
749
+ isSubmitting: isDeleting,
750
+ submitButtonLabel: t("neetoFields.labels.delete"),
751
+ title: t("neetoFields.titles.deleteField"),
752
+ message: getDeletionConfirmationMessage({
753
+ resource: resourceTypeName,
754
+ affectedResourcesCount: affectedResourcesCount,
755
+ fieldName: selectedField === null || selectedField === void 0 ? void 0 : selectedField.name
756
+ }),
757
+ onClose: handleAlertClose,
758
+ onSubmit: handleDelete
759
+ });
760
+ };
761
+
762
+ export { DeleteAlert as D, getDashBoardTitle as a, buildDefaultColumns as b, renderMenuBarItems as c, renderNoDataHelpText as d, getResourceName as g, renderStateFilterTabs as r };
763
+ //# sourceMappingURL=DeleteAlert-b92f7c05.js.map