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