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