@ebrains/react 0.7.0-alpha.0 → 0.8.0-alpha.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 (80) hide show
  1. package/color-primary-palette_6.entry.esm.js +106 -106
  2. package/correct-use-of-colors.entry.esm.js +33 -33
  3. package/eds-accordion_17.entry.esm.js +196 -0
  4. package/eds-alert.entry.esm.js +14 -6
  5. package/eds-app-root.entry.esm.js +4 -4
  6. package/eds-breadcrumb.entry.esm.js +6 -3
  7. package/{eds-avatar_4.entry.esm.js → eds-card-desc_3.entry.esm.js} +6 -66
  8. package/eds-card-generic.entry.esm.js +1 -1
  9. package/eds-card-project.entry.esm.js +10 -10
  10. package/eds-card-tags.entry.esm.js +1 -1
  11. package/eds-card-tool.entry.esm.js +4 -4
  12. package/eds-card-wrapper.entry.esm.js +4 -4
  13. package/eds-code-block.entry.esm.js +7 -7
  14. package/eds-components-section.entry.esm.js +27 -24
  15. package/eds-cookies-preference.entry.esm.js +2 -2
  16. package/eds-docs-palettes.entry.esm.js +1 -1
  17. package/eds-docs-tokens.entry.esm.js +1 -1
  18. package/eds-feedback.entry.esm.js +5 -5
  19. package/eds-form.entry.esm.js +233 -170
  20. package/eds-frame.entry.esm.js +6 -6
  21. package/eds-icon-arrow-diagonal.entry.esm.js +3 -3
  22. package/eds-icon-arrow-right.entry.esm.js +1 -1
  23. package/eds-icon-bluesky.entry.esm.js +1 -1
  24. package/eds-icon-chevron-down.entry.esm.js +1 -1
  25. package/eds-icon-chevron-left.entry.esm.js +1 -1
  26. package/eds-icon-chevron-right.entry.esm.js +1 -1
  27. package/eds-icon-chevron-up.entry.esm.js +1 -1
  28. package/eds-icon-close.entry.esm.js +1 -1
  29. package/eds-icon-copy.entry.esm.js +1 -1
  30. package/eds-icon-eu.entry.esm.js +1 -1
  31. package/eds-icon-facebook.entry.esm.js +1 -1
  32. package/eds-icon-gitlab.entry.esm.js +1 -1
  33. package/eds-icon-linkedin.entry.esm.js +1 -1
  34. package/eds-icon-loader.entry.esm.js +1 -1
  35. package/eds-icon-mastodon.entry.esm.js +1 -1
  36. package/eds-icon-menu.entry.esm.js +1 -1
  37. package/eds-icon-more.entry.esm.js +1 -1
  38. package/eds-icon-search.entry.esm.js +1 -1
  39. package/eds-icon-star.entry.esm.js +1 -1
  40. package/eds-icon-success.entry.esm.js +1 -1
  41. package/eds-icon-thumbs-down.entry.esm.js +1 -1
  42. package/eds-icon-thumbs-up.entry.esm.js +1 -1
  43. package/eds-icon-twitter.entry.esm.js +1 -1
  44. package/eds-icon-user.entry.esm.js +1 -1
  45. package/eds-icon-youtube.entry.esm.js +1 -1
  46. package/eds-input_7.entry.esm.js +569 -0
  47. package/eds-login_2.entry.esm.js +2 -2
  48. package/eds-logo-variations.entry.esm.js +1 -1
  49. package/eds-modal.entry.esm.js +8 -8
  50. package/eds-pagination_2.entry.esm.js +493 -0
  51. package/eds-progress-bar.entry.esm.js +2 -2
  52. package/eds-rating.entry.esm.js +1 -1
  53. package/eds-section-core_2.entry.esm.js +6 -6
  54. package/eds-spinner.entry.esm.js +3 -3
  55. package/eds-svg-repository.entry.esm.js +11 -6
  56. package/eds-switch.entry.esm.js +5 -5
  57. package/eds-tabs.entry.esm.js +4 -4
  58. package/eds-timeline.entry.esm.js +7 -4
  59. package/eds-toast-manager.entry.esm.js +1 -1
  60. package/eds-tooltip.entry.esm.js +3 -3
  61. package/eds-trl.entry.esm.js +3 -3
  62. package/incorrect-use-of-colors.entry.esm.js +7 -7
  63. package/index.esm.js +1 -1
  64. package/index.esm2.js +15 -23
  65. package/logo-space.entry.esm.js +4 -4
  66. package/logo-variations-horizontal_2.entry.esm.js +26 -26
  67. package/logo-wrong-usage.entry.esm.js +37 -37
  68. package/package.json +1 -1
  69. package/src/components.d.ts +1 -3
  70. package/token-list_3.entry.esm.js +5 -5
  71. package/token-ratios.entry.esm.js +3 -3
  72. package/token-spacing.entry.esm.js +26 -26
  73. package/token-typography.entry.esm.js +2 -2
  74. package/README.md +0 -7
  75. package/eds-accordion_22.entry.esm.js +0 -269
  76. package/eds-dropdown.entry.esm.js +0 -156
  77. package/eds-steps.entry.esm.js +0 -89
  78. package/eds-user.entry.esm.js +0 -95
  79. package/eds-vertical-stepper.entry.esm.js +0 -81
  80. package/formUtils-ac68474d.esm.js +0 -247
@@ -1,156 +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 'react';
4
- import 'react/jsx-runtime';
5
- import 'react-dom';
6
-
7
- const edsDropdownCss = ".z-focus{z-index:99}.relative{position:relative}.shadow-small{--tw-shadow:0px 1.5px 2px rgba(0, 0, 0, 0.1);--tw-shadow-colored:0px 1.5px 2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}.bg-inverse{background-color:var(--white)}.border-softest{border:2px solid rgba(0, 0, 0, .05)}.z-10{z-index:10}.z-on-top{z-index:99999}.absolute{position:absolute}.top-full{top:100%}.mt-4{margin-top:0.25rem}.mt-6{margin-top:0.375rem}.mt-8{margin-top:0.5rem}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.flex-col{flex-direction:column}.gap-y-4{row-gap:0.25rem}.rounded-lg{border-radius:16px}.border-2{border-width:2px}.p-8{padding:0.5rem}.left-0{left:0rem}.left-1\\/2{left:50%}.left-4{left:0.25rem}.left-\\[4px\\]{left:4px}.right-0{right:0rem}.right-4{right:0.25rem}.right-8{right:0.5rem}";
8
- const EdsDropdownStyle0 = edsDropdownCss;
9
- const EdsDropdown = class {
10
- constructor(hostRef) {
11
- registerInstance(this, hostRef);
12
- this.dropdown = createEvent(this, "dropdown", 7);
13
- this.focusableItems = [];
14
- /**
15
- * Toggles the visibility of the dropdown and manages focus.
16
- */
17
- this.handleClick = () => {
18
- var _a;
19
- this.isOpen = !this.isOpen;
20
- if (this.isOpen) {
21
- this.focusIndex = 0;
22
- this.focusItem();
23
- } else {
24
- this.closeDropdown();
25
- }
26
- this.dropdown.emit({
27
- expanded: this.isOpen
28
- });
29
- sendAnalytics({
30
- category: 'ui-component',
31
- parentContext: null,
32
- tag: this.host.tagName.toLowerCase(),
33
- name: ((_a = this.label) === null || _a === void 0 ? void 0 : _a.toLowerCase()) || '',
34
- action: this.isOpen ? 'expanded' : 'collapsed'
35
- });
36
- };
37
- this.icon = 'chevron-down';
38
- this.label = undefined;
39
- this.rounded = false;
40
- this.ariaLabel = 'Open dropdown';
41
- this.asNav = true;
42
- this.dropdownPos = 'left';
43
- this.dropdownOffset = true;
44
- this.intent = 'tertiary';
45
- this.isOpen = false;
46
- this.focusIndex = -1;
47
- }
48
- /**
49
- * Closes the dropdown when a click occurs outside of it.
50
- * @param {Event} e - The click event.
51
- */
52
- handleWindowClick(e) {
53
- if (!this.host.contains(e.target)) {
54
- this.closeDropdown();
55
- this.dropdown.emit({
56
- expanded: false
57
- });
58
- }
59
- }
60
- /**
61
- * Handles keyboard navigation and accessibility within the dropdown.
62
- * @param {KeyboardEvent} event - The keyboard event.
63
- */
64
- handleKeyDown(event) {
65
- if (this.isOpen) {
66
- const key = event.key;
67
- switch (key) {
68
- case 'Tab':
69
- this.closeDropdown();
70
- this.dropdown.emit({
71
- expanded: false
72
- });
73
- break;
74
- case 'ArrowUp':
75
- event.preventDefault();
76
- this.focusIndex = (this.focusIndex - 1 + this.focusableItems.length) % this.focusableItems.length;
77
- this.focusItem();
78
- break;
79
- case 'ArrowDown':
80
- event.preventDefault();
81
- this.focusIndex = (this.focusIndex + 1) % this.focusableItems.length;
82
- this.focusItem();
83
- break;
84
- }
85
- }
86
- }
87
- /**
88
- * Closes the dropdown and resets focus.
89
- */
90
- closeDropdown() {
91
- this.isOpen = false;
92
- this.focusIndex = -1;
93
- this.dropdown.emit({
94
- expanded: false
95
- });
96
- }
97
- /**
98
- * Sets focus on the currently selected item in the dropdown.
99
- */
100
- focusItem() {
101
- var _a;
102
- (_a = this.focusableItems[this.focusIndex]) === null || _a === void 0 ? void 0 : _a.focus();
103
- }
104
- /**
105
- * Lifecycle method that runs after the component has been added to the DOM.
106
- * Initializes focusable items within the dropdown.
107
- */
108
- componentDidLoad() {
109
- var _a;
110
- this.focusableItems = Array.from(((_a = this.dropdownContent) === null || _a === void 0 ? void 0 : _a.querySelectorAll('a, button')) || []);
111
- }
112
- /**
113
- * Renders the dropdown component and displays its content when open.
114
- * @returns {JSX.Element} The rendered dropdown component.
115
- */
116
- render() {
117
- return h("div", {
118
- key: '3edd3453afbd52ee9e3c4d925baa46e07cfdbfc0',
119
- class: "z-focus relative",
120
- ref: el => this.dropdownContent = el
121
- }, h("eds-button", {
122
- key: '7c69acb6d6213af2cec8c1e00c68d83a5d23d676',
123
- label: this.label,
124
- "aria-label": this.ariaLabel,
125
- icon: this.icon,
126
- intent: this.intent,
127
- onClick: this.handleClick,
128
- "aria-expanded": this.isOpen.toString(),
129
- "aria-haspopup": "menu"
130
- }), h("nav", {
131
- key: '5048b1c3cb42418736d471c2331330afef49cbc5',
132
- role: "menu",
133
- class: {
134
- 'shadow-small bg-inverse border-softest z-10 z-on-top absolute top-full mt-4 flex flex-col gap-y-4 border-2 p-8': true,
135
- 'left-4': this.dropdownPos === 'left' && this.dropdownOffset,
136
- 'left-0': this.dropdownPos === 'left' && !this.dropdownOffset,
137
- 'right-4': this.dropdownPos === 'right' && this.dropdownOffset,
138
- 'right-0': this.dropdownPos === 'right' && !this.dropdownOffset,
139
- 'rounded-lg': this.rounded
140
- },
141
- style: {
142
- display: this.isOpen ? 'block' : 'none'
143
- },
144
- "aria-label": "Dropdown",
145
- "aria-hidden": !this.isOpen
146
- }, h("slot", {
147
- key: '842f316e9a7910aa8b34823e883c54c1979668d1'
148
- })));
149
- }
150
- get host() {
151
- return getElement(this);
152
- }
153
- };
154
- EdsDropdown.style = EdsDropdownStyle0;
155
-
156
- export { EdsDropdown as eds_dropdown };
@@ -1,89 +0,0 @@
1
- import { r as registerInstance, c as createEvent, h } from './index.esm2.js';
2
- import { p as parseData } from './sharedUtils-a550989c.esm.js';
3
- import 'react';
4
- import 'react/jsx-runtime';
5
- import 'react-dom';
6
-
7
- const edsStepsCss = ".steps{position:sticky;margin-left:16px;margin-bottom:12px;border-left:1px solid var(--soft-color, #ddd);padding-left:23px;counter-reset:step}.steps h3{counter-increment:step;font-size:var(--f-heading-05-fontSize);font-weight:var(--f-heading-05-fontWeight);line-height:var(--f-heading-05-lineHeight);position:relative}.steps h3::before{content:counter(step);position:absolute;left:-40px;top:0;display:flex;align-items:center;justify-content:center;width:32px;height:32px;font-size:1rem;border:1px solid #ccc;background:var(--grey-900);color:#fff;border-radius:50%}.steps h4{counter-increment:step;font-size:var(--f-heading-06-fontSize);font-weight:var(--f-heading-06-fontWeight);line-height:var(--f-heading-06-lineHeight);position:relative}.steps h4::before{content:counter(step);position:absolute;left:-40px;top:0;display:flex;align-items:center;justify-content:center;width:30px;height:30px;font-size:0.875rem;border:1px solid #ccc;background:#333;color:#fff;border-radius:50%}.steps blockquote{margin-top:16px;margin-bottom:16px;font-style:italic;color:#aaa;padding-left:6px}.f-body-01{font-family:var(--f-body-01-fontFamily);font-weight:var(--f-body-01-fontWeight);font-size:var(--f-body-01-fontSize);line-height:var(--f-body-01-lineHeight);letter-spacing:var(--f-body-01-letterSpacing)}.f-body-02{font-family:var(--f-body-02-fontFamily);font-weight:var(--f-body-02-fontWeight);font-size:var(--f-body-02-fontSize);line-height:var(--f-body-02-lineHeight);letter-spacing:var(--f-body-02-letterSpacing)}.f-ui-01{font-family:var(--f-ui-01-fontFamily);font-weight:var(--f-ui-01-fontWeight);font-size:var(--f-ui-01-fontSize);line-height:var(--f-ui-01-lineHeight);letter-spacing:var(--f-ui-01-letterSpacing)}.text-default{color:var(--black)}.text-error{color:var(--red-700)}.text-extra-light{color:var(--grey-300)}.text-inverse{color:var(--white)}.text-light{color:var(--grey-700)}.text-lighter{color:var(--grey-600)}.text-lightest{color:var(--grey-500)}.my-16{margin-top:1rem;margin-bottom:1rem}.my-20{margin-top:1.25rem;margin-bottom:1.25rem}.mb-28{margin-bottom:1.75rem}";
8
- const EdsStepsStyle0 = edsStepsCss;
9
- const EdsSteps = class {
10
- constructor(hostRef) {
11
- registerInstance(this, hostRef);
12
- this.step = createEvent(this, "step", 7);
13
- this.handleNext = () => {
14
- this.activeStep = this.activeStep + 1;
15
- if (this.activeStep < this.parsedSteps.length) {
16
- this.step.emit(this.activeStep);
17
- }
18
- };
19
- this.handleBack = () => {
20
- if (this.activeStep > 0) {
21
- this.activeStep = this.activeStep - 1;
22
- this.step.emit(this.activeStep);
23
- }
24
- };
25
- this.steps = [];
26
- this.type = 'static';
27
- this.activeStep = 0;
28
- }
29
- handleStepClick(index) {
30
- this.step.emit(index);
31
- // In linear mode, update the active step on header click.
32
- if (this.type === 'linear') {
33
- this.activeStep = index;
34
- }
35
- }
36
- /**
37
- * Parse the JSON string into an array of steps.
38
- */
39
- get parsedSteps() {
40
- return parseData(this.steps);
41
- }
42
- render() {
43
- const steps = this.parsedSteps;
44
- if (this.type === 'linear') {
45
- return h("div", null, h("div", {
46
- class: "steps"
47
- }, steps.map((step, index) => h("div", {
48
- class: "step mb-28",
49
- key: index
50
- }, h("h3", {
51
- onClick: () => this.handleStepClick(index)
52
- }, step.title), this.activeStep === index && h("div", {
53
- class: "content"
54
- }, h("div", {
55
- class: "f-body-02 text-lighter my-16"
56
- }, step.content), h("eds-button", {
57
- label: index === steps.length - 1 ? 'Finish' : 'Continue',
58
- intent: "primary",
59
- class: "next-btn",
60
- onClick: this.handleNext
61
- }), h("eds-button", {
62
- label: "Back",
63
- intent: "ghostInverse",
64
- onClick: this.handleBack,
65
- disabled: index === 0,
66
- "extra-class": index === 0 ? 'hidden' : 'ml-8 block'
67
- }))))), this.activeStep === steps.length && h("div", {
68
- class: "completed"
69
- }, h("eds-alert", {
70
- intent: "success",
71
- message: "All steps completed - you're finished!"
72
- })));
73
- }
74
- // Static mode: show all steps with their content, no navigation buttons.
75
- return h("div", {
76
- class: "steps"
77
- }, steps.map((step, index) => h("div", {
78
- class: "step mb-28",
79
- key: index
80
- }, h("h3", null, step.title), h("div", {
81
- class: "content"
82
- }, h("div", {
83
- class: "f-body-02 text-lighter my-16"
84
- }, step.content)))));
85
- }
86
- };
87
- EdsSteps.style = EdsStepsStyle0;
88
-
89
- export { EdsSteps as eds_steps };
@@ -1,95 +0,0 @@
1
- import { r as registerInstance, h, g as getElement } from './index.esm2.js';
2
- import 'react';
3
- import 'react/jsx-runtime';
4
- import 'react-dom';
5
-
6
- const EdsUser = class {
7
- constructor(hostRef) {
8
- registerInstance(this, hostRef);
9
- this.user = undefined;
10
- }
11
- /**
12
- * Lifecycle method that runs when the component is about to load.
13
- * It initializes authentication by calling the `initAuth` method.
14
- */
15
- async componentWillLoad() {}
16
- get initials() {
17
- var _a, _b, _c, _d, _e, _f, _g;
18
- const initials = `${((_b = (_a = this.user) === null || _a === void 0 ? void 0 : _a.given_name) === null || _b === void 0 ? void 0 : _b.charAt(0)) || ''}${((_d = (_c = this.user) === null || _c === void 0 ? void 0 : _c.family_name) === null || _d === void 0 ? void 0 : _d.charAt(0)) || ''}`.toUpperCase();
19
- return initials || ((_g = (_f = (_e = this.user) === null || _e === void 0 ? void 0 : _e.name) === null || _f === void 0 ? void 0 : _f.charAt(0)) === null || _g === void 0 ? void 0 : _g.toUpperCase()) || '';
20
- }
21
- render() {
22
- var _a, _b, _c, _d, _e, _f;
23
- return h("div", {
24
- key: '68bc37b43d006a35e088a647d41b2257fbef25a7',
25
- class: "block"
26
- }, h("div", {
27
- key: '3f4badcb645238de9ac8aaad78e1c132407f5b0d',
28
- class: "flex items-center"
29
- }, h("eds-dropdown", {
30
- key: '7f065f82c5845fd0ebc9c6b465ac56a695a99b77',
31
- label: `Welcome, ${(_a = this.user) === null || _a === void 0 ? void 0 : _a.preferred_username}`,
32
- intent: "tertiary",
33
- "aria-label": "User Menu",
34
- "dropdown-pos": "right",
35
- "dropdown-offset": "false",
36
- icon: "chevron-down",
37
- class: "text-default"
38
- }, h("div", {
39
- key: '2b1e9279c8d4feae16bf64c15837b61b945af447',
40
- class: "min-w-[280px] p-8"
41
- }, h("div", {
42
- key: 'efa9aef50bc1eb4961e53a89f6e07cc5ff78d67b',
43
- class: "flex gap-x-16 pb-16 border-b-2 border-softer"
44
- }, h("eds-avatar", {
45
- key: '2b78a6768ecb101138ab742d812d407e1b4fdd89',
46
- "first-name": (_b = this.user) === null || _b === void 0 ? void 0 : _b.given_name,
47
- "last-name": (_c = this.user) === null || _c === void 0 ? void 0 : _c.family_name,
48
- initials: this.initials,
49
- color: "grey",
50
- rounded: true,
51
- "initials-strong": true
52
- }), h("div", {
53
- key: 'd538dfe8df5e8af92fa204493b8b59b0d0e9f61a',
54
- class: "max-w-full"
55
- }, ((_d = this.user) === null || _d === void 0 ? void 0 : _d.name) && h("p", {
56
- key: 'a644c3cdda0ce7bf2f62438a3866692f4222efeb',
57
- class: "f-ui-01 text-default w-full text-ellipsis"
58
- }, this.user.name), ((_e = this.user) === null || _e === void 0 ? void 0 : _e.preferred_username) && h("p", {
59
- key: '2a6cf5f0324d27ebdfd2b331e5f232c23e544ad5',
60
- class: "f-ui-03-light text-light mt-4"
61
- }, this.user.preferred_username), ((_f = this.user) === null || _f === void 0 ? void 0 : _f.email) && h("p", {
62
- key: '02b9dd4f2999b68107eabc2c1e2a1bc3bb98f26a',
63
- class: "f-ui-03-light text-light mt-4"
64
- }, this.user.email))), h("div", {
65
- key: '3a68427dc603f0a3fb2652bfbea292eb718046dd',
66
- class: "text-default mt-16 flex w-full flex-col gap-y-8"
67
- }, h("div", {
68
- key: '3f3f617385efc57502794f78079b8486b6801425',
69
- class: "border-softer mb-10 border-b-2 pb-16"
70
- }, h("eds-link", {
71
- key: '62fbc143f710605c7d840277dc90054a1162831d',
72
- label: "My EBRAINS",
73
- "aria-label": "My EBRAINS",
74
- url: "https://www.ebrains.eu/dashboard",
75
- intent: "primary",
76
- "extra-class": "w-full",
77
- external: true
78
- })), h("eds-link", {
79
- key: 1,
80
- label: "Account Settings",
81
- url: "https://iam.ebrains.eu/auth/realms/hbp/account/",
82
- intent: "secondary",
83
- icon: "arrow-diagonal",
84
- external: true,
85
- "extra-class": "w-full"
86
- }), h("slot", {
87
- key: 'f48a4c872784b60e421fda6e48f67f4c85b101d7'
88
- }))))));
89
- }
90
- get hostEl() {
91
- return getElement(this);
92
- }
93
- };
94
-
95
- export { EdsUser as eds_user };
@@ -1,81 +0,0 @@
1
- import { r as registerInstance, h } from './index.esm2.js';
2
- import 'react';
3
- import 'react/jsx-runtime';
4
- import 'react-dom';
5
-
6
- const edsVerticalStepperCss = ":host{display:block}.stepper-container{margin:0 auto}.stepper{position:sticky;margin-left:16px;margin-bottom:12px;border-left:1px solid var(--soft-color, #ddd);padding-left:24px;counter-reset:step}.step{margin-bottom:24px}.step-label{counter-increment:step;font-size:1.25rem;font-weight:600;position:relative;margin-top:1em;margin-bottom:1em}.step-label::before{content:counter(step);position:absolute;left:-40px;top:0;display:flex;align-items:center;justify-content:center;width:30px;height:30px;font-size:1rem;border:1px solid #ccc;background:var(--grey-900);color:#fff;border-radius:50%}.optional{font-size:0.8rem;color:#888;margin-left:8px}.step-content{margin-top:8px}.step-buttons{margin-top:12px}.step-buttons button{margin-right:8px;padding:6px 12px;font-size:0.875rem}.completed{padding:16px;border:1px solid #ddd;margin-top:16px;text-align:center}";
7
- const EdsVerticalStepperStyle0 = edsVerticalStepperCss;
8
- const EdsVerticalStepper = class {
9
- constructor(hostRef) {
10
- registerInstance(this, hostRef);
11
- this.handleNext = () => {
12
- if (this.activeStep < this.parsedSteps.length) {
13
- this.activeStep = this.activeStep + 1;
14
- }
15
- };
16
- this.handleBack = () => {
17
- if (this.activeStep > 0) {
18
- this.activeStep = this.activeStep - 1;
19
- }
20
- };
21
- this.handleReset = () => {
22
- this.activeStep = 0;
23
- };
24
- this.steps = '[]';
25
- this.activeStep = 0;
26
- }
27
- get parsedSteps() {
28
- try {
29
- return JSON.parse(this.steps);
30
- } catch (error) {
31
- //console.error('Invalid steps JSON', error);
32
- return [];
33
- }
34
- }
35
- render() {
36
- const steps = this.parsedSteps;
37
- return h("div", {
38
- key: '89344ad340f9eb8d20f463d3990ec4832cbdc900',
39
- class: "stepper-container"
40
- }, h("div", {
41
- key: 'da8d7fae2b30cfc93d04d5d8c3a61d95ccf91383',
42
- class: "stepper"
43
- }, steps.map((step, index) => h("div", {
44
- class: "step",
45
- key: index
46
- }, h("div", {
47
- class: "step-label"
48
- }, h("span", null, step.label), index === steps.length - 1 && h("span", {
49
- class: "f-ui-03 text-lightest ml-4"
50
- }, "(Last step)")), this.activeStep === index && h("div", {
51
- class: "step-content"
52
- }, h("p", null, step.description), h("div", {
53
- class: "step-buttons"
54
- }, h("eds-button", {
55
- label: index === steps.length - 1 ? 'Finish' : 'Continue',
56
- class: "next-btn",
57
- onClick: this.handleNext
58
- }), h("eds-button", {
59
- label: "Back",
60
- intent: "ghostInverse",
61
- onClick: this.handleBack,
62
- disabled: index === 0,
63
- "extra-class": index === 0 ? 'hidden' : 'ml-8 block'
64
- })))))), this.activeStep === steps.length && h("div", {
65
- key: '1e3272723281d9a10603b4d1e79badfdd6591cc5',
66
- class: ""
67
- }, h("eds-alert", {
68
- key: '7cc81e7e7097891364ff9894d383fd7bb9f7fce4',
69
- intent: "success",
70
- message: "All steps completed - you're finished!"
71
- }), h("eds-button", {
72
- key: 'a4d68698fa7831c7e2b6afae435979ccac46a726',
73
- label: "Start again",
74
- onClick: this.handleReset,
75
- "extra-class": "mt-4"
76
- })));
77
- }
78
- };
79
- EdsVerticalStepper.style = EdsVerticalStepperStyle0;
80
-
81
- export { EdsVerticalStepper as eds_vertical_stepper };
@@ -1,247 +0,0 @@
1
- // utils/validators.ts
2
- function validateField(name, value, type, required, maxLength) {
3
- const errors = [];
4
- if (required && !value) {
5
- errors.push(`${name} is required.`);
6
- }
7
- if (maxLength && typeof value === 'string' && value.length > maxLength) {
8
- errors.push(`${name} must be at most ${maxLength} characters.`);
9
- }
10
- if (type === 'email' && value && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value.toString())) {
11
- errors.push('Invalid email format.');
12
- }
13
- return errors;
14
- }
15
- function validateFieldGroup(name, required, formEl) {
16
- // Find all eds-input-field components that contain inputs with the given name.
17
- const groupFields = Array.from(formEl.querySelectorAll('eds-input-field')).filter(edsField => {
18
- var _a, _b;
19
- 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;
20
- });
21
- // Collect all input elements with the matching name inside those components.
22
- const groupElements = groupFields.flatMap(edsField => {
23
- var _a;
24
- return Array.from(((_a = edsField.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll(`input[name="${name}"]`)) || []);
25
- });
26
- // Check if at least one input is checked.
27
- const isChecked = groupElements.some(el => el.checked);
28
- const errors = [];
29
- if (required && !isChecked) {
30
- errors.push(`At least one option in ${name} is required.`);
31
- }
32
- return errors;
33
- }
34
- function validateSingleBox(name, required, formEl) {
35
- var _a;
36
- const errors = [];
37
- // Find the eds-input-field component containing the input with the given name.
38
- const edsField = Array.from(formEl.querySelectorAll('eds-input-field')).find(field => {
39
- var _a;
40
- return (_a = field.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(`[name="${name}"]`);
41
- });
42
- // If no such field is found and it's required, return an error.
43
- if (!edsField) {
44
- if (required) {
45
- errors.push(`${name} is required.`);
46
- }
47
- return errors;
48
- }
49
- // Query within the component's shadow root.
50
- const inputEl = (_a = edsField.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(`[name="${name}"]`);
51
- if (required && inputEl && !inputEl.checked) {
52
- errors.push(`${name} is required.`);
53
- }
54
- return errors;
55
- }
56
-
57
- /**
58
- * Finds the first input element for a given field name inside eds-input-field components.
59
- */
60
- function findFieldElement(formEl, name) {
61
- const elements = Array.from(formEl.querySelectorAll('eds-input-field'));
62
- for (const element of elements) {
63
- if (element.shadowRoot) {
64
- const input = element.shadowRoot.querySelector(`[name="${name}"]`);
65
- if (input) {
66
- return input;
67
- }
68
- }
69
- }
70
- return null;
71
- }
72
- /**
73
- * Validates all fields and returns an object containing the errors and a flag indicating any errors.
74
- */
75
- function validateFormFields(parsedFields, formEl, values,
76
- // eslint-disable-next-line
77
- isFieldVisible) {
78
- const errors = {};
79
- let hasError = false;
80
- parsedFields.forEach(field => {
81
- // Only validate fields that are visible.
82
- if (!isFieldVisible(field, values)) {
83
- // If a field is hidden, clear its error.
84
- delete errors[field.name];
85
- return;
86
- }
87
- if (field.type !== 'hidden') {
88
- if ((field.type === 'checkbox' || field.type === 'radio') && !field.options) {
89
- // Single checkbox or radio without multiple options
90
- const fieldErrors = validateSingleBox(field.name, field.required, formEl);
91
- if (fieldErrors.length > 0) {
92
- errors[field.name] = fieldErrors;
93
- hasError = true;
94
- }
95
- } else if (field.options && (field.type === 'checkbox' || field.type === 'radio')) {
96
- // Checkbox or radio group with options
97
- const fieldErrors = validateFieldGroup(field.name, field.required, formEl);
98
- if (fieldErrors.length > 0) {
99
- errors[field.name] = fieldErrors;
100
- hasError = true;
101
- }
102
- } else {
103
- // For all other types, find the first matching element.
104
- const inputEl = findFieldElement(formEl, field.name);
105
- if (inputEl) {
106
- const value = inputEl.value;
107
- const fieldErrors = validateField(field.name, value, field.type, field.required, field.maxlength);
108
- if (fieldErrors.length > 0) {
109
- errors[field.name] = fieldErrors;
110
- hasError = true;
111
- }
112
- }
113
- }
114
- }
115
- });
116
- return {
117
- errors,
118
- hasError
119
- };
120
- }
121
-
122
- /**
123
- * Validates a field based on its type and returns an array of error messages.
124
- * @param field - The field configuration object.
125
- * @param value - The input value (if applicable).
126
- * @param formEl - The form element used for DOM queries.
127
- */
128
- function validateInputField(field, value, formEl) {
129
- if (field.type === 'checkbox' || field.type === 'radio') {
130
- if (field.options) {
131
- return validateFieldGroup(field.name, field.required, formEl);
132
- }
133
- return validateSingleBox(field.name, field.required, formEl);
134
- }
135
- return validateField(field.name, value, field.type, field.required, field.maxlength);
136
- }
137
-
138
- /**
139
- * Updates state values based on draft data and, after a delay, updates the corresponding DOM inputs.
140
- */
141
- function getFormInitData({
142
- initData,
143
- parsedFields,
144
- currentValues,
145
- formEl,
146
- isFieldVisible
147
- }) {
148
- // Pass 1: Update state for all fields.
149
- const updatedValues = Object.assign({}, currentValues);
150
- parsedFields.forEach(field => {
151
- const value = initData[field.name];
152
- if (value !== undefined) {
153
- updatedValues[field.name] = value;
154
- }
155
- });
156
- // Pass 2: Delay DOM updates to ensure nested fields are rendered.
157
- setTimeout(() => {
158
- parsedFields.forEach(field => {
159
- // Only update if the field is visible.
160
- if (isFieldVisible(field, updatedValues)) {
161
- const value = initData[field.name];
162
- if (value !== undefined) {
163
- if (field.type === 'checkbox' || field.type === 'radio') {
164
- // Query all eds-input-field components and update matching inputs.
165
- const elements = Array.from(formEl.querySelectorAll('eds-input-field'));
166
- elements.forEach(element => {
167
- if (element.shadowRoot) {
168
- const inputs = Array.from(element.shadowRoot.querySelectorAll(`[name="${field.name}"]`));
169
- // Convert stored comma-separated value into a trimmed array.
170
- const valuesArray = value.split(',').map(v => v.trim());
171
- inputs.forEach(inputEl => {
172
- // eslint-disable-next-line
173
- inputEl.checked = valuesArray.includes(inputEl.value);
174
- });
175
- }
176
- });
177
- } else {
178
- // For non-checkbox/radio inputs, update the first matching element using findFieldElement.
179
- const inputEl = findFieldElement(formEl, field.name);
180
- if (inputEl) {
181
- inputEl.value = value;
182
- }
183
- }
184
- }
185
- }
186
- });
187
- }, 50); // A 50ms delay to allow re-render
188
- return {
189
- updatedValues
190
- };
191
- }
192
- /**
193
- * Updates state values based on draft data and, after a delay, updates the corresponding DOM inputs.
194
- */
195
- function getFormDraftData({
196
- draftData,
197
- parsedFields,
198
- currentValues,
199
- formEl,
200
- isFieldVisible
201
- }) {
202
- // Pass 1: Update state for all fields.
203
- const updatedValues = Object.assign({}, currentValues);
204
- parsedFields.forEach(field => {
205
- const value = draftData[field.name];
206
- if (value !== undefined) {
207
- updatedValues[field.name] = value;
208
- }
209
- });
210
- // Pass 2: Delay DOM updates to ensure nested fields are rendered.
211
- setTimeout(() => {
212
- parsedFields.forEach(field => {
213
- // Only update if the field is visible.
214
- if (isFieldVisible(field, updatedValues)) {
215
- const value = draftData[field.name];
216
- if (value !== undefined) {
217
- if (field.type === 'checkbox' || field.type === 'radio') {
218
- // Query all eds-input-field components and update matching inputs.
219
- const elements = Array.from(formEl.querySelectorAll('eds-input-field'));
220
- elements.forEach(element => {
221
- if (element.shadowRoot) {
222
- const inputs = Array.from(element.shadowRoot.querySelectorAll(`[name="${field.name}"]`));
223
- // Convert stored comma-separated value into a trimmed array.
224
- const valuesArray = value.split(',').map(v => v.trim());
225
- inputs.forEach(inputEl => {
226
- // eslint-disable-next-line
227
- inputEl.checked = valuesArray.includes(inputEl.value);
228
- });
229
- }
230
- });
231
- } else {
232
- // For non-checkbox/radio inputs, update the first matching element using findFieldElement.
233
- const inputEl = findFieldElement(formEl, field.name);
234
- if (inputEl) {
235
- inputEl.value = value;
236
- }
237
- }
238
- }
239
- }
240
- });
241
- }, 50); // A 50ms delay to allow re-render
242
- return {
243
- updatedValues
244
- };
245
- }
246
-
247
- export { validateInputField as a, getFormDraftData as b, getFormInitData as g, validateFormFields as v };