@ebrains/react 0.8.0-alpha.0 → 0.9.0-beta

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 (83) hide show
  1. package/README.md +7 -0
  2. package/bookmark-c200037c.esm.js +16 -0
  3. package/color-primary-palette_6.entry.esm.js +163 -141
  4. package/{eds-components-section.entry.esm.js → components-section.entry.esm.js} +22 -18
  5. package/correct-use-of-colors.entry.esm.js +49 -49
  6. package/{eds-docs-palettes.entry.esm.js → docs-palettes.entry.esm.js} +3 -3
  7. package/{eds-docs-tokens.entry.esm.js → docs-tokens.entry.esm.js} +3 -3
  8. package/eds-accordion.entry.esm.js +132 -0
  9. package/eds-app-root.entry.esm.js +4 -4
  10. package/{eds-accordion_17.entry.esm.js → eds-avatar_24.entry.esm.js} +128 -49
  11. package/eds-card-desc_3.entry.esm.js +1 -1
  12. package/eds-cookies-preference.entry.esm.js +2 -2
  13. package/eds-feedback.entry.esm.js +9 -9
  14. package/eds-frame.entry.esm.js +9 -15
  15. package/eds-icon-bluesky.entry.esm.js +1 -1
  16. package/eds-icon-bookmark.entry.esm.js +21 -0
  17. package/eds-icon-close.entry.esm.js +1 -1
  18. package/eds-icon-copy.entry.esm.js +1 -1
  19. package/eds-icon-eu.entry.esm.js +1 -1
  20. package/eds-icon-external.entry.esm.js +21 -0
  21. package/eds-icon-facebook.entry.esm.js +1 -1
  22. package/eds-icon-gitlab.entry.esm.js +1 -1
  23. package/eds-icon-linkedin.entry.esm.js +1 -1
  24. package/eds-icon-loader.entry.esm.js +1 -1
  25. package/eds-icon-mastodon.entry.esm.js +1 -1
  26. package/eds-icon-menu.entry.esm.js +1 -1
  27. package/eds-icon-minus.entry.esm.js +21 -0
  28. package/eds-icon-more.entry.esm.js +1 -1
  29. package/eds-icon-paper.entry.esm.js +21 -0
  30. package/eds-icon-plus.entry.esm.js +21 -0
  31. package/eds-icon-portal.entry.esm.js +21 -0
  32. package/eds-icon-private.entry.esm.js +21 -0
  33. package/eds-icon-public.entry.esm.js +21 -0
  34. package/eds-icon-search.entry.esm.js +1 -1
  35. package/eds-icon-star.entry.esm.js +1 -1
  36. package/eds-icon-success.entry.esm.js +1 -1
  37. package/eds-icon-thumbs-down.entry.esm.js +1 -1
  38. package/eds-icon-thumbs-up.entry.esm.js +1 -1
  39. package/eds-icon-tutorial.entry.esm.js +21 -0
  40. package/eds-icon-twitter.entry.esm.js +1 -1
  41. package/eds-icon-unknown.entry.esm.js +21 -0
  42. package/eds-icon-updown.entry.esm.js +21 -0
  43. package/eds-icon-user.entry.esm.js +1 -1
  44. package/eds-icon-youtube.entry.esm.js +1 -1
  45. package/eds-login_2.entry.esm.js +27 -15
  46. package/eds-matomo-notice.entry.esm.js +162 -0
  47. package/eds-modal.entry.esm.js +13 -13
  48. package/eds-pagination_2.entry.esm.js +12 -12
  49. package/eds-progress-bar.entry.esm.js +2 -2
  50. package/eds-rating.entry.esm.js +1 -1
  51. package/eds-section-core_2.entry.esm.js +5 -5
  52. package/eds-spinner.entry.esm.js +3 -3
  53. package/eds-switch.entry.esm.js +5 -5
  54. package/eds-tabs.entry.esm.js +4 -4
  55. package/eds-timeline.entry.esm.js +5 -5
  56. package/eds-toast-manager.entry.esm.js +1 -1
  57. package/eds-tooltip.entry.esm.js +3 -3
  58. package/eds-trl.entry.esm.js +2 -2
  59. package/incorrect-use-of-colors.entry.esm.js +9 -9
  60. package/index.esm.js +1 -1
  61. package/index.esm2.js +58 -30
  62. package/logo-space.entry.esm.js +28 -12
  63. package/logo-variations-horizontal_2.entry.esm.js +73 -66
  64. package/{eds-logo-variations.entry.esm.js → logo-variations-tabs.entry.esm.js} +3 -3
  65. package/logo-wrong-usage.entry.esm.js +71 -107
  66. package/minus-b30a7c71.esm.js +11 -0
  67. package/package.json +1 -1
  68. package/paper-8e74ea31.esm.js +15 -0
  69. package/plus-89c07be2.esm.js +12 -0
  70. package/portal-d6c8ce56.esm.js +18 -0
  71. package/private-1c25ff8e.esm.js +25 -0
  72. package/public-d4d8c585.esm.js +16 -0
  73. package/src/components.d.ts +0 -2
  74. package/{eds-svg-repository.entry.esm.js → svg-repository.entry.esm.js} +29 -28
  75. package/token-list_3.entry.esm.js +9 -9
  76. package/token-ratios.entry.esm.js +3 -3
  77. package/token-typography.entry.esm.js +10 -7
  78. package/tutotial-150ee1fd.esm.js +27 -0
  79. package/unknown-ed01a24c.esm.js +22 -0
  80. package/up-and-down-d747abee.esm.js +12 -0
  81. package/eds-form.entry.esm.js +0 -473
  82. package/eds-input_7.entry.esm.js +0 -569
  83. package/token-spacing.entry.esm.js +0 -93
@@ -1,473 +0,0 @@
1
- import { r as registerInstance, c as createEvent, h, g as getElement } from './index.esm2.js';
2
- import { s as sendAnalytics } from './analytics-44b1416b.esm.js';
3
- import { p as parseData } from './sharedUtils-a550989c.esm.js';
4
- import 'react';
5
- import 'react/jsx-runtime';
6
- import 'react-dom';
7
-
8
- // utils/validators.ts
9
- function validateField(name, value, type, required, maxLength) {
10
- const errors = [];
11
- if (required && !value) {
12
- errors.push(`${name} is required.`);
13
- }
14
- if (maxLength && typeof value === 'string' && value.length > maxLength) {
15
- errors.push(`${name} must be at most ${maxLength} characters.`);
16
- }
17
- if (type === 'email' && value && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value.toString())) {
18
- errors.push('Invalid email format.');
19
- }
20
- return errors;
21
- }
22
- function validateFieldGroup(name, required, formEl) {
23
- // Find all eds-input-field components that contain inputs with the given name.
24
- const groupFields = Array.from(formEl.querySelectorAll('eds-input-field')).filter(edsField => {
25
- var _a, _b;
26
- return ((_b = (_a = edsField.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll(`input[name="${name}"]`)) === null || _b === void 0 ? void 0 : _b.length) > 0;
27
- });
28
- // Collect all input elements with the matching name inside those components.
29
- const groupElements = groupFields.flatMap(edsField => {
30
- var _a;
31
- return Array.from(((_a = edsField.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll(`input[name="${name}"]`)) || []);
32
- });
33
- // Check if at least one input is checked.
34
- const isChecked = groupElements.some(el => el.checked);
35
- const errors = [];
36
- if (required && !isChecked) {
37
- errors.push(`At least one option in ${name} is required.`);
38
- }
39
- return errors;
40
- }
41
- function validateSingleBox(name, required, formEl) {
42
- var _a;
43
- const errors = [];
44
- // Find the eds-input-field component containing the input with the given name.
45
- const edsField = Array.from(formEl.querySelectorAll('eds-input-field')).find(field => {
46
- var _a;
47
- return (_a = field.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(`[name="${name}"]`);
48
- });
49
- // If no such field is found and it's required, return an error.
50
- if (!edsField) {
51
- if (required) {
52
- errors.push(`${name} is required.`);
53
- }
54
- return errors;
55
- }
56
- // Query within the component's shadow root.
57
- const inputEl = (_a = edsField.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(`[name="${name}"]`);
58
- if (required && inputEl && !inputEl.checked) {
59
- errors.push(`${name} is required.`);
60
- }
61
- return errors;
62
- }
63
-
64
- /**
65
- * Finds the first input element for a given field name inside eds-input-field components.
66
- */
67
- function findFieldElement(formEl, name) {
68
- const elements = Array.from(formEl.querySelectorAll('eds-input-field'));
69
- for (const element of elements) {
70
- if (element.shadowRoot) {
71
- const input = element.shadowRoot.querySelector(`[name="${name}"]`);
72
- if (input) {
73
- return input;
74
- }
75
- }
76
- }
77
- return null;
78
- }
79
- /**
80
- * Validates all fields and returns an object containing the errors and a flag indicating any errors.
81
- */
82
- function validateFormFields(parsedFields, formEl, values,
83
- // eslint-disable-next-line
84
- isFieldVisible) {
85
- const errors = {};
86
- let hasError = false;
87
- parsedFields.forEach(field => {
88
- // Only validate fields that are visible.
89
- if (!isFieldVisible(field, values)) {
90
- // If a field is hidden, clear its error.
91
- delete errors[field.name];
92
- return;
93
- }
94
- if (field.type !== 'hidden') {
95
- if ((field.type === 'checkbox' || field.type === 'radio') && !field.options) {
96
- // Single checkbox or radio without multiple options
97
- const fieldErrors = validateSingleBox(field.name, field.required, formEl);
98
- if (fieldErrors.length > 0) {
99
- errors[field.name] = fieldErrors;
100
- hasError = true;
101
- }
102
- } else if (field.options && (field.type === 'checkbox' || field.type === 'radio')) {
103
- // Checkbox or radio group with options
104
- const fieldErrors = validateFieldGroup(field.name, field.required, formEl);
105
- if (fieldErrors.length > 0) {
106
- errors[field.name] = fieldErrors;
107
- hasError = true;
108
- }
109
- } else {
110
- // For all other types, find the first matching element.
111
- const inputEl = findFieldElement(formEl, field.name);
112
- if (inputEl) {
113
- const value = inputEl.value;
114
- const fieldErrors = validateField(field.name, value, field.type, field.required, field.maxlength);
115
- if (fieldErrors.length > 0) {
116
- errors[field.name] = fieldErrors;
117
- hasError = true;
118
- }
119
- }
120
- }
121
- }
122
- });
123
- return {
124
- errors,
125
- hasError
126
- };
127
- }
128
-
129
- /**
130
- * Validates a field based on its type and returns an array of error messages.
131
- * @param field - The field configuration object.
132
- * @param value - The input value (if applicable).
133
- * @param formEl - The form element used for DOM queries.
134
- */
135
- function validateInputField(field, value, formEl) {
136
- if (field.type === 'checkbox' || field.type === 'radio') {
137
- if (field.options) {
138
- return validateFieldGroup(field.name, field.required, formEl);
139
- }
140
- return validateSingleBox(field.name, field.required, formEl);
141
- }
142
- return validateField(field.name, value, field.type, field.required, field.maxlength);
143
- }
144
-
145
- /**
146
- * Updates state values based on draft data and, after a delay, updates the corresponding DOM inputs.
147
- */
148
- function getFormInitData({
149
- initData,
150
- parsedFields,
151
- currentValues,
152
- formEl,
153
- isFieldVisible
154
- }) {
155
- // Pass 1: Update state for all fields.
156
- const updatedValues = Object.assign({}, currentValues);
157
- parsedFields.forEach(field => {
158
- const value = initData[field.name];
159
- if (value !== undefined) {
160
- updatedValues[field.name] = value;
161
- }
162
- });
163
- // Pass 2: Delay DOM updates to ensure nested fields are rendered.
164
- setTimeout(() => {
165
- parsedFields.forEach(field => {
166
- // Only update if the field is visible.
167
- if (isFieldVisible(field, updatedValues)) {
168
- const value = initData[field.name];
169
- if (value !== undefined) {
170
- if (field.type === 'checkbox' || field.type === 'radio') {
171
- // Query all eds-input-field components and update matching inputs.
172
- const elements = Array.from(formEl.querySelectorAll('eds-input-field'));
173
- elements.forEach(element => {
174
- if (element.shadowRoot) {
175
- const inputs = Array.from(element.shadowRoot.querySelectorAll(`[name="${field.name}"]`));
176
- // Convert stored comma-separated value into a trimmed array.
177
- const valuesArray = value.split(',').map(v => v.trim());
178
- inputs.forEach(inputEl => {
179
- // eslint-disable-next-line
180
- inputEl.checked = valuesArray.includes(inputEl.value);
181
- });
182
- }
183
- });
184
- } else {
185
- // For non-checkbox/radio inputs, update the first matching element using findFieldElement.
186
- const inputEl = findFieldElement(formEl, field.name);
187
- if (inputEl) {
188
- inputEl.value = value;
189
- }
190
- }
191
- }
192
- }
193
- });
194
- }, 50); // A 50ms delay to allow re-render
195
- return {
196
- updatedValues
197
- };
198
- }
199
- const edsFormCss = ".mt-20{margin-top:1.25rem}";
200
- const EdsFormStyle0 = edsFormCss;
201
- const EdsForm = class {
202
- constructor(hostRef) {
203
- registerInstance(this, hostRef);
204
- this.form = createEvent(this, "form", 7);
205
- this.name = 'eds-form';
206
- this.setFormUrl = true;
207
- this.formBtn = true;
208
- this.formBtnLabel = 'Submit';
209
- this.errorMessage = 'Some fields in your form are incorrect.';
210
- this.fields = [];
211
- this.initData = {};
212
- this.values = {};
213
- this.isSubmitting = false;
214
- this.hasError = false;
215
- this.errors = {};
216
- this.parsedFields = [];
217
- }
218
- componentWillLoad() {
219
- this.parseFields(this.fields);
220
- // Emit context for each eds-link element after the component is fully loaded
221
- const links = this.el.querySelectorAll('eds-button');
222
- links.forEach(link => {
223
- this.emitContext(link);
224
- });
225
- }
226
- componentDidLoad() {
227
- if (this.shouldFormProcessInitData) {
228
- this.populateFormWithInitData(this.initData);
229
- }
230
- }
231
- get shouldFormProcessInitData() {
232
- var _a;
233
- return !!((_a = this.initData) === null || _a === void 0 ? void 0 : _a._id);
234
- }
235
- parseFields(newValue) {
236
- this.parsedFields = parseData(newValue);
237
- }
238
- emitContext(linkElement) {
239
- const event = new CustomEvent('parentContext', {
240
- detail: {
241
- componentName: this.el.tagName.toLowerCase(),
242
- identifier: null
243
- }
244
- });
245
- linkElement.dispatchEvent(event);
246
- }
247
- isFieldVisible(field) {
248
- if (!field.condition) {
249
- return true;
250
- }
251
- const parentValue = this.values[field.condition.field];
252
- return parentValue === field.condition.value;
253
- }
254
- validateForm() {
255
- const {
256
- errors,
257
- hasError
258
- } = validateFormFields(this.parsedFields, this.formEl, this.values, (field, values) => {
259
- if (!field.condition) {
260
- return true;
261
- }
262
- const parentValue = values[field.condition.field];
263
- return parentValue === field.condition.value;
264
- });
265
- this.errors = errors;
266
- this.hasError = hasError;
267
- }
268
- populateFormWithInitData(initData) {
269
- const {
270
- updatedValues
271
- } = getFormInitData({
272
- initData,
273
- parsedFields: this.parsedFields,
274
- currentValues: this.values,
275
- formEl: this.formEl,
276
- isFieldVisible: (field, values) => {
277
- if (!field.condition) {
278
- return true;
279
- }
280
- const parentValue = values[field.condition.field];
281
- return parentValue === field.condition.value;
282
- }
283
- });
284
- this.values = updatedValues;
285
- }
286
- getFormData() {
287
- const formData = new FormData();
288
- // Add the form name
289
- formData.append('form_name', this.name);
290
- // Add the form URL
291
- if (this.setFormUrl && typeof window !== 'undefined') {
292
- formData.set('form_url', window.location.href);
293
- }
294
- // Get all input elements within `eds-input-field`
295
- const elements = Array.from(this.formEl.querySelectorAll('eds-input-field'));
296
- elements.forEach(element => {
297
- if (element.shadowRoot) {
298
- // Get input/textarea/select from the shadow DOM
299
- const input = element.shadowRoot.querySelector('input, textarea, select');
300
- if (input && input.name) {
301
- if (input.type === 'checkbox' || input.type === 'radio') {
302
- // Handle checkboxes and radio buttons
303
- const checkboxes = Array.from(element.shadowRoot.querySelectorAll(`input[name="${input.name}"]:checked`));
304
- const values = checkboxes.map(checkbox => checkbox.value);
305
- formData.append(input.name, values.join(',')); // Join multiple values with a comma
306
- } else if (input.type === 'file') {
307
- // Handle file uploads.
308
- const fileInput = input;
309
- if (fileInput.files && fileInput.files.length > 0) {
310
- // If multiple files are allowed, you can append them all.
311
- Array.from(fileInput.files).forEach(file => {
312
- // You can either append each file under the same name (if your backend expects an array)
313
- // or you can give them unique names. Here we use the same name.
314
- formData.append(fileInput.name, file);
315
- });
316
- }
317
- } else {
318
- // Handle other input types
319
- formData.append(input.name, input.value);
320
- }
321
- }
322
- }
323
- });
324
- return formData;
325
- }
326
- handleChange(e, field) {
327
- const target = e.target;
328
- this.values = Object.assign(Object.assign({}, this.values), {
329
- [field.name]: target.value
330
- });
331
- // Emit an input event with message and current form values
332
- this.form.emit({
333
- event: 'change',
334
- field: field.name,
335
- value: target.value,
336
- message: `${field.name} updated`,
337
- data: this.getFormData()
338
- });
339
- }
340
- handleInput(e, field) {
341
- const target = e.target;
342
- // Update the field's value in state.
343
- this.values = Object.assign(Object.assign({}, this.values), {
344
- [field.name]: target.value
345
- });
346
- // Create a copy of the current errors.
347
- const newErrors = Object.assign({}, this.errors);
348
- // Use the utility to validate the field.
349
- const fieldErrors = validateInputField(field, target.value, this.formEl);
350
- if (fieldErrors.length > 0) {
351
- newErrors[field.name] = fieldErrors;
352
- } else {
353
- delete newErrors[field.name];
354
- }
355
- // Update the errors state and the hasError flag.
356
- this.errors = newErrors;
357
- this.hasError = Object.keys(newErrors).length > 0;
358
- }
359
- handleSubmit() {
360
- var _a, _b;
361
- if (this.isSubmitting) {
362
- return;
363
- }
364
- this.isSubmitting = true;
365
- this.validateForm();
366
- if (this.hasError) {
367
- this.form.emit({
368
- event: 'submit',
369
- validated: false,
370
- success: false,
371
- message: this.errorMessage,
372
- data: this.getFormData()
373
- }); // Emit form status submit false validation error
374
- sendAnalytics({
375
- category: 'ui-component',
376
- parentContext: null,
377
- tag: this.el.tagName.toLowerCase(),
378
- name: `${(_a = this.formBtnLabel) === null || _a === void 0 ? void 0 : _a.toLowerCase()}/non-validated` || '',
379
- action: 'click'
380
- });
381
- return;
382
- }
383
- // Log each entry in FormData to see file details
384
- /*formData.forEach((value, key) => {
385
- if (value instanceof File) {
386
- console.log(`File field: ${key}, File name: ${value.name}, File size: ${value.size}`);
387
- } else {
388
- console.log(`Field: ${key}, Value: ${value}`);
389
- }
390
- });*/
391
- this.form.emit({
392
- event: 'submit',
393
- success: true,
394
- validated: true,
395
- message: 'Form data validated successfully',
396
- data: this.getFormData()
397
- });
398
- sendAnalytics({
399
- category: 'ui-component',
400
- parentContext: null,
401
- tag: this.el.tagName.toLowerCase(),
402
- name: `${(_b = this.formBtnLabel) === null || _b === void 0 ? void 0 : _b.toLowerCase()}/validated` || '',
403
- action: 'click'
404
- });
405
- // Reset form states
406
- this.errors = {};
407
- this.formEl.reset();
408
- this.isSubmitting = false;
409
- return;
410
- }
411
- render() {
412
- const hiddenFields = this.parsedFields.filter(field => field.type === 'hidden');
413
- const otherFields = this.parsedFields.filter(field => field.type !== 'hidden');
414
- return h("form", {
415
- key: '695438941134ef6a3c43b70008b1904b03700743',
416
- ref: el => this.formEl = el,
417
- autocomplete: "on",
418
- onSubmit: this.handleSubmit
419
- }, h("div", {
420
- key: '870ff661aded11c890e4f144a970c5ab5120a61f'
421
- }, h("slot", {
422
- key: 'b1070ccc8984afe457d28a6bbf52255dcbbc9b33'
423
- }), hiddenFields.map((field, index) => h("eds-input", {
424
- key: index,
425
- type: "hidden",
426
- name: field.name,
427
- value: field.value
428
- })), otherFields.map((field, index) => {
429
- var _a, _b;
430
- if (!this.isFieldVisible(field)) {
431
- return null;
432
- }
433
- return h("eds-input-field", {
434
- key: index,
435
- name: field.name,
436
- id: `${this.name}_${field.name}`,
437
- label: field.label,
438
- type: field.type,
439
- icon: field.icon || null,
440
- required: field.required,
441
- maxLength: field.maxlength,
442
- hint: field.hint,
443
- error: ((_a = this.errors[field.name]) === null || _a === void 0 ? void 0 : _a.length) > 0,
444
- errorMessage: (_b = this.errors[field.name]) === null || _b === void 0 ? void 0 : _b.join('<br />'),
445
- onInput: e => this.handleInput(e, field),
446
- onChange: e => this.handleChange(e, field),
447
- class: index > 0 ? 'mt-20' : '',
448
- options: field.options
449
- });
450
- })), this.formBtn && h("div", {
451
- key: '80e0af076f3c57124f8a1f6718a0d45cfd45c0cd',
452
- class: "mt-20"
453
- }, h("eds-button", {
454
- key: '51dd28fb2a6610983e50ddb60409b3acf18dba1b',
455
- intent: "primary",
456
- label: this.formBtnLabel,
457
- disabled: this.isSubmitting,
458
- loading: this.isSubmitting,
459
- onClick: () => this.handleSubmit()
460
- })));
461
- }
462
- get el() {
463
- return getElement(this);
464
- }
465
- static get watchers() {
466
- return {
467
- "fields": ["parseFields"]
468
- };
469
- }
470
- };
471
- EdsForm.style = EdsFormStyle0;
472
-
473
- export { EdsForm as eds_form };