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