@ebrains/react 0.7.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.
- package/README.md +3 -3
- package/bookmark-c200037c.esm.js +16 -0
- package/color-primary-palette_6.entry.esm.js +163 -141
- package/components-section.entry.esm.js +165 -0
- package/correct-use-of-colors.entry.esm.js +49 -49
- package/{eds-docs-palettes.entry.esm.js → docs-palettes.entry.esm.js} +3 -3
- package/{eds-docs-tokens.entry.esm.js → docs-tokens.entry.esm.js} +3 -3
- package/eds-accordion.entry.esm.js +132 -0
- package/eds-alert.entry.esm.js +14 -6
- package/eds-app-root.entry.esm.js +4 -4
- package/eds-avatar_24.entry.esm.js +275 -0
- package/eds-breadcrumb.entry.esm.js +6 -3
- package/{eds-avatar_4.entry.esm.js → eds-card-desc_3.entry.esm.js} +6 -66
- package/eds-card-generic.entry.esm.js +1 -1
- package/eds-card-project.entry.esm.js +10 -10
- package/eds-card-tags.entry.esm.js +1 -1
- package/eds-card-tool.entry.esm.js +4 -4
- package/eds-card-wrapper.entry.esm.js +4 -4
- package/eds-code-block.entry.esm.js +7 -7
- package/eds-cookies-preference.entry.esm.js +2 -2
- package/eds-feedback.entry.esm.js +9 -9
- package/eds-frame.entry.esm.js +11 -17
- package/eds-icon-arrow-diagonal.entry.esm.js +3 -3
- package/eds-icon-arrow-right.entry.esm.js +1 -1
- package/eds-icon-bookmark.entry.esm.js +21 -0
- package/eds-icon-chevron-down.entry.esm.js +1 -1
- package/eds-icon-chevron-left.entry.esm.js +1 -1
- package/eds-icon-chevron-right.entry.esm.js +1 -1
- package/eds-icon-chevron-up.entry.esm.js +1 -1
- package/eds-icon-close.entry.esm.js +1 -1
- package/eds-icon-copy.entry.esm.js +1 -1
- package/eds-icon-eu.entry.esm.js +1 -1
- package/eds-icon-external.entry.esm.js +21 -0
- package/eds-icon-gitlab.entry.esm.js +1 -1
- package/eds-icon-loader.entry.esm.js +1 -1
- package/eds-icon-menu.entry.esm.js +1 -1
- package/eds-icon-minus.entry.esm.js +21 -0
- package/eds-icon-more.entry.esm.js +1 -1
- package/eds-icon-paper.entry.esm.js +21 -0
- package/eds-icon-plus.entry.esm.js +21 -0
- package/eds-icon-portal.entry.esm.js +21 -0
- package/eds-icon-private.entry.esm.js +21 -0
- package/eds-icon-public.entry.esm.js +21 -0
- package/eds-icon-search.entry.esm.js +1 -1
- package/eds-icon-star.entry.esm.js +1 -1
- package/eds-icon-success.entry.esm.js +1 -1
- package/eds-icon-thumbs-down.entry.esm.js +1 -1
- package/eds-icon-thumbs-up.entry.esm.js +1 -1
- package/eds-icon-tutorial.entry.esm.js +21 -0
- package/eds-icon-unknown.entry.esm.js +21 -0
- package/eds-icon-updown.entry.esm.js +21 -0
- package/eds-login_2.entry.esm.js +27 -15
- package/eds-matomo-notice.entry.esm.js +162 -0
- package/eds-modal.entry.esm.js +13 -13
- package/eds-pagination_2.entry.esm.js +493 -0
- package/eds-section-core_2.entry.esm.js +3 -3
- package/eds-switch.entry.esm.js +5 -5
- package/eds-tabs.entry.esm.js +4 -4
- package/eds-timeline.entry.esm.js +7 -4
- package/eds-toast-manager.entry.esm.js +1 -1
- package/eds-tooltip.entry.esm.js +3 -3
- package/eds-trl.entry.esm.js +3 -3
- package/incorrect-use-of-colors.entry.esm.js +9 -9
- package/index.esm.js +1 -1
- package/index.esm2.js +66 -46
- package/logo-space.entry.esm.js +28 -12
- package/logo-variations-horizontal_2.entry.esm.js +73 -66
- package/{eds-logo-variations.entry.esm.js → logo-variations-tabs.entry.esm.js} +3 -3
- package/logo-wrong-usage.entry.esm.js +71 -107
- package/minus-b30a7c71.esm.js +11 -0
- package/package.json +1 -1
- package/paper-8e74ea31.esm.js +15 -0
- package/plus-89c07be2.esm.js +12 -0
- package/portal-d6c8ce56.esm.js +18 -0
- package/private-1c25ff8e.esm.js +25 -0
- package/public-d4d8c585.esm.js +16 -0
- package/src/components.d.ts +1 -5
- package/{eds-svg-repository.entry.esm.js → svg-repository.entry.esm.js} +35 -29
- package/token-list_3.entry.esm.js +9 -9
- package/token-ratios.entry.esm.js +3 -3
- package/token-typography.entry.esm.js +10 -7
- package/tutotial-150ee1fd.esm.js +27 -0
- package/unknown-ed01a24c.esm.js +22 -0
- package/up-and-down-d747abee.esm.js +12 -0
- package/eds-accordion_22.entry.esm.js +0 -269
- package/eds-components-section.entry.esm.js +0 -158
- package/eds-dropdown.entry.esm.js +0 -156
- package/eds-form.entry.esm.js +0 -410
- package/eds-steps.entry.esm.js +0 -89
- package/eds-user.entry.esm.js +0 -95
- package/eds-vertical-stepper.entry.esm.js +0 -81
- package/formUtils-ac68474d.esm.js +0 -247
- package/token-spacing.entry.esm.js +0 -93
|
@@ -1,158 +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 EdsComponentsOverview = () => h("div", {
|
|
7
|
-
class: "static-content container"
|
|
8
|
-
}, h("h2", null, "Load the module"), h("p", null, "Integrating EDSs components to a project without a JavaScript framework is straight forward. If you\u2019re working on a simple HTML page, you can start using the components immediately by adding the tags below to the", ' ', h("code", null, "head"), "."), h("eds-code-block", {
|
|
9
|
-
code: "<script type='module'>\n import { defineCustomElements } from 'https://unpkg.com/@ebrains/components@latest/loader/index.js'; \n // Define custom elements\n defineCustomElements(window);\n</script>",
|
|
10
|
-
language: "javascript",
|
|
11
|
-
"copy-label": "Copy Code"
|
|
12
|
-
}), h("h2", null, "Load the styles"), h("p", null, "To directly use the produced css framework with a few predefined custom utility classes, add the tag below to the", ' ', h("code", null, "head")), h("eds-code-block", {
|
|
13
|
-
code: '<link rel="stylesheet" href="https://unpkg.com/@ebrains/assets@latest/styles/output.css"/>',
|
|
14
|
-
language: "css",
|
|
15
|
-
"copy-label": "Copy Code"
|
|
16
|
-
}), h("div", {
|
|
17
|
-
class: "my-4"
|
|
18
|
-
}, h("eds-alert", {
|
|
19
|
-
message: "Note that, loading the predefined CSS framework above, automatically loads the fonts so you can skip loading them separately.",
|
|
20
|
-
intent: "warning"
|
|
21
|
-
})), h("h2", null, "Load the fonts"), h("p", null, "To load the webfonts, add the tag below to the ", h("code", null, "head")), h("eds-code-block", {
|
|
22
|
-
code: '<link rel="stylesheet" href="https://unpkg.com/@ebrains/assets@0.0.1/styles/base/fonts.css"/>',
|
|
23
|
-
language: "css",
|
|
24
|
-
"copy-label": "Copy Code"
|
|
25
|
-
}), h("h2", null, "Component Usage"), h("p", null, "Once included, components can be used in your markup like any other regular HTML elements:"), h("eds-code-block", {
|
|
26
|
-
code: '<eds-button \n label="my bytton" \n intent="primary">\n</eds-button>',
|
|
27
|
-
language: "html",
|
|
28
|
-
"copy-label": "Copy Code"
|
|
29
|
-
}));
|
|
30
|
-
const EdsDocsInstallation = () => h("div", null, h("p", null, "Before proceeding, ensure that Node.js is installed on your machine\u2014you can download the latest version from the official website. If your project doesn\u2019t already use npm and you plan to integrate EBRAINS Components, you'll need to create a package.json file by running npm init and following the on-screen instructions."), h("div", {
|
|
31
|
-
class: "my-8"
|
|
32
|
-
}, h("eds-code-block", {
|
|
33
|
-
code: "npm install @ebrains/components",
|
|
34
|
-
language: "html",
|
|
35
|
-
"copy-label": "Copy Code"
|
|
36
|
-
})), h("div", {
|
|
37
|
-
class: "my-8"
|
|
38
|
-
}, h("eds-code-block", {
|
|
39
|
-
code: "npm install @ebrains/assets",
|
|
40
|
-
language: "html",
|
|
41
|
-
"copy-label": "Copy Code"
|
|
42
|
-
})), h("div", {
|
|
43
|
-
class: "my-8"
|
|
44
|
-
}, h("eds-code-block", {
|
|
45
|
-
code: "npm install @ebrains/react",
|
|
46
|
-
language: "html",
|
|
47
|
-
"copy-label": "Copy Code"
|
|
48
|
-
})), h("div", {
|
|
49
|
-
class: "my-8"
|
|
50
|
-
}, h("eds-code-block", {
|
|
51
|
-
code: "npm install @ebrains/vue",
|
|
52
|
-
language: "html",
|
|
53
|
-
"copy-label": "Copy Code"
|
|
54
|
-
})), h("div", {
|
|
55
|
-
class: "my-8"
|
|
56
|
-
}, h("eds-code-block", {
|
|
57
|
-
code: "npm install @ebrains/angular",
|
|
58
|
-
language: "html",
|
|
59
|
-
"copy-label": "Copy Code"
|
|
60
|
-
})));
|
|
61
|
-
const EdsDocsReact = () => h("div", null, h("h2", null, "React Wrappers"), h("p", null, "Learn how to use our components in a React Application.Simple install the package below and check out the examples"), h("div", {
|
|
62
|
-
class: "my-8"
|
|
63
|
-
}, h("eds-code-block", {
|
|
64
|
-
code: "npm install @ebrains/react",
|
|
65
|
-
language: "javascript",
|
|
66
|
-
"copy-label": "Copy Code"
|
|
67
|
-
})), h("eds-section-core", {
|
|
68
|
-
"section-title": "Example React App",
|
|
69
|
-
"heading-level": "h3"
|
|
70
|
-
}, h("eds-code-block", {
|
|
71
|
-
code: '\nimport {\n EdsHeader,\n EdsFullscreenMenu,\n EdsUser\n} from "@ebrains/react";\n\ninterface User {\n firstname: string;\n lastname: string;\n // Add any other properties your user object might have\n}\n\ninterface AuthStatus {\n authenticated: boolean;\n user: User | null;\n}\n\nimport { useEffect, useState } from "react";\n\nexport function App() {\n const [authStatus, setAuthStatus] = useState<AuthStatus>({\n authenticated: false,\n user: null,\n });\n const [activeTabIndex, setActiveTabIndex] = useState<number>(0);\n\n // Use useEffect to render Stencil components dynamically after the component mounts\n useEffect(() => {\n const handleAuthStatusChange = (event: CustomEvent) => {\n console.log(event.detail);\n setAuthStatus(event.detail); // Set the entire object\n };\n\n document.addEventListener(\n "authStatusChanged",\n handleAuthStatusChange as EventListener,\n );\n\n return () => {\n document.removeEventListener(\n "authStatusChanged",\n handleAuthStatusChange as EventListener,\n );\n };\n }, []);\n\n return (\n <div>\n <EdsHeader\n homeUrl="/"\n menuEnabled={true}\n inverseHeader={false}\n links={[\n { label: "About", url: "#" },\n { label: "Focus Areas", url: "#" },\n { label: "News & Events", url: "#" },\n { label: "Contact", url: "#" }\n ]}\n >\n <div className="px-16">\n <EdsUser\n keycloak-url="http://localhost:8080"\n keycloak-realm="nigeor-realm"\n keycloak-client-id="stencil-app"\n ></EdsUser>\n </div>\n </EdsHeader>\n\n <EdsFullscreenMenu\n home-url="/"\n links={[\n { label: "About", url: "#" },\n { label: "Focus Areas", url: "#" },\n { label: "News & Events", url: "#" },\n { label: "Contact", url: "#" }\n ]}\n ></EdsFullscreenMenu>\n \n <div>\n User is{" "}\n {authStatus.authenticated ? "authenticated" : "not authenticated"}\n </div>\n {authStatus.user && <div>Welcome, {authStatus.user.firstname}</div>}\n\n <div id="main"></div>\n </div>\n );\n}\n\nexport default App;\n\n',
|
|
72
|
-
language: "javascript",
|
|
73
|
-
"copy-label": "Copy Code"
|
|
74
|
-
})));
|
|
75
|
-
const EdsDocsVue = () => h("div", null, h("h2", null, "Vue Wrappers"), h("p", null, "Learn how to use our components in a Vue Application."), h("p", null, "Simply install the latest version of our NPM package."), h("eds-code-block", {
|
|
76
|
-
code: "npm install @ebrains/vue",
|
|
77
|
-
language: "javascript",
|
|
78
|
-
"copy-label": "Copy Code"
|
|
79
|
-
}), h("p", null, "Our NPM package already includes the custom elements definitions. However, you can use the components as they are by simply importing and executing the initialization command in your \"main.ts\" file."), h("eds-code-block", {
|
|
80
|
-
code: "import { defineCustomElements } from '@ebrains/components/loader';\ndefineCustomElements();",
|
|
81
|
-
language: "javascript",
|
|
82
|
-
"copy-label": "Copy Code"
|
|
83
|
-
}), h("h2", null, "Passing Properties to Custom Elements Using the ", h("b", null, ".prop"), " Modifier in Vue Wrappers"), h("p", null, "When using Vue wrappers for Stencil components (or any custom elements), you might encounter issues with property names being altered due to HTML\u2019s attribute handling. By default, Vue binds values as HTML attributes, and HTML attributes are case-insensitive. This means that camelCase property names can be transformed into lowercase strings, which can prevent your component from receiving the correct data."), h("h3", null, "How to Use the ", h("b", null, ".prop"), " Modifier"), h("p", null, "When using Vue wrappers, you can pass properties with the .prop modifier by adding it to your binding expression. Here\u2019s an example of how to do it:"), h("div", {
|
|
84
|
-
class: "mt-8"
|
|
85
|
-
}, h("eds-alert", {
|
|
86
|
-
message: "This may lead to issues because Vue binds these as attributes .",
|
|
87
|
-
intent: "error"
|
|
88
|
-
})), h("eds-code-block", {
|
|
89
|
-
code: '<EdsAlert\n message="This is a default informational alert."\n intent="default"\n :pressableLabel="Press Me"\n :pressableUrl="https://ebrains.eu"\n></EdsAlert>',
|
|
90
|
-
language: "javascript",
|
|
91
|
-
"copy-label": "Copy Code"
|
|
92
|
-
}), h("div", {
|
|
93
|
-
class: "mt-8"
|
|
94
|
-
}, h("eds-alert", {
|
|
95
|
-
message: "Use the .prop modifier to ensure properties are passed correctly.",
|
|
96
|
-
intent: "success"
|
|
97
|
-
})), h("eds-code-block", {
|
|
98
|
-
code: '<EdsAlert\n message="This is a default informational alert."\n intent="default"\n :pressableLabel.prop="Press Me"\n :pressableUrl.prop="https://ebrains.eu"\n></EdsAlert>',
|
|
99
|
-
language: "javascript",
|
|
100
|
-
"copy-label": "Copy Code"
|
|
101
|
-
}), h("p", null, "Using the ", h("b", null, ".prop"), " modifier in Vue ensures that the data you pass to your custom elements is received as intended. It prevents Vue (and the browser) from transforming camelCase property names into lowercase attributes, thereby maintaining the correct data mapping in your Stencil components."), h("eds-section-core", {
|
|
102
|
-
"section-title": "Example Vue App",
|
|
103
|
-
"heading-level": "h3"
|
|
104
|
-
}, h("eds-code-block", {
|
|
105
|
-
code: '\n<template>\n <EdsHeader \n :inverseHeader.prop="true"\n :menuEnabled.prop="true">\n </EdsHeader>\n</template>\n\n<script>\n\nimport { EdsHeader } from "@ebrains/vue";\n\nexport default {\n name: "App",\n components: {\n EdsHeader,\n }\n};\n</script>\n',
|
|
106
|
-
language: "javascript",
|
|
107
|
-
"copy-label": "Copy Code"
|
|
108
|
-
})));
|
|
109
|
-
const EdsDocsAngular = () => h("div", null, h("h2", null, "Angular Wrappers"), h("p", null, "Learn how to use our components in a Angular Application."), h("eds-code-block", {
|
|
110
|
-
code: "npm install @ebrains/angular",
|
|
111
|
-
language: "javascript",
|
|
112
|
-
"copy-label": "Copy Code"
|
|
113
|
-
}), h("p", null, "Define the custom elements"), h("eds-code-block", {
|
|
114
|
-
code: "import { defineCustomElements } from '@ebrains/components/loader';\ndefineCustomElements();",
|
|
115
|
-
language: "javascript",
|
|
116
|
-
"copy-label": "Copy Code"
|
|
117
|
-
}), h("p", null, "Angular Custom Elements Schema"), h("eds-code-block", {
|
|
118
|
-
code: 'import { CUSTOM_ELEMENTS_SCHEMA } from "@angular/core";',
|
|
119
|
-
language: "javascript",
|
|
120
|
-
"copy-label": "Copy Code"
|
|
121
|
-
}), h("eds-section-core", {
|
|
122
|
-
"section-title": "Example Angular App",
|
|
123
|
-
"heading-level": "h3"
|
|
124
|
-
}, h("eds-code-block", {
|
|
125
|
-
code: '\n<div class="container">\n <eds-breadcrumb\n intent="tertiary"\n items="[\n { "label": "Home", "url": "#" },\n { "label": "Products", "url": "#" },\n ]">\n </eds-breadcrumb>\n <eds-footer></eds-footer>\n</div>',
|
|
126
|
-
language: "javascript",
|
|
127
|
-
"copy-label": "Copy Code"
|
|
128
|
-
})));
|
|
129
|
-
const EdsComponentsSection = class {
|
|
130
|
-
constructor(hostRef) {
|
|
131
|
-
registerInstance(this, hostRef);
|
|
132
|
-
this.tabIndex = undefined;
|
|
133
|
-
}
|
|
134
|
-
renderContent() {
|
|
135
|
-
switch (this.tabIndex) {
|
|
136
|
-
case 0:
|
|
137
|
-
return h(EdsComponentsOverview, null);
|
|
138
|
-
case 1:
|
|
139
|
-
return h(EdsDocsInstallation, null);
|
|
140
|
-
case 2:
|
|
141
|
-
return h(EdsDocsReact, null);
|
|
142
|
-
case 3:
|
|
143
|
-
return h(EdsDocsVue, null);
|
|
144
|
-
case 4:
|
|
145
|
-
return h(EdsDocsAngular, null);
|
|
146
|
-
default:
|
|
147
|
-
return h("p", null, "Content not available.");
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
render() {
|
|
151
|
-
return h("div", {
|
|
152
|
-
key: '69eda93b8845c5fdf5edc0f58ede763866b5f8c7',
|
|
153
|
-
class: "container"
|
|
154
|
-
}, this.renderContent());
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
export { EdsComponentsSection as eds_components_section };
|
|
@@ -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 };
|