@ebrains/react 0.3.0-alpha.0 → 0.4.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.
@@ -1,117 +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 EdsFrame = class {
7
- constructor(hostRef) {
8
- registerInstance(this, hostRef);
9
- this.frameLabel = undefined;
10
- this.urlLabel = 'Open in Storybook';
11
- this.errorMessage = 'Could not load the requested Storybook content. Please check the URL or try again later.';
12
- this.storybookUrl = undefined;
13
- this.storyPath = undefined;
14
- this.intent = 'strong';
15
- this.tiny = false;
16
- this.size = 'auto';
17
- this.bg = true;
18
- this.iframeError = false;
19
- }
20
- articleClasses() {
21
- return [this.tiny ? 'min-h-120' : 'min-h-156', this.bg ? 'bg-inverse' : 'bg-default', 'rounded border-softer effect-focus-within relative flex grow flex-col border-2', 'w-full h-full'].join(' ');
22
- }
23
- getFrameHeight() {
24
- switch (this.size) {
25
- case 'sm':
26
- return '100px';
27
- case 'md':
28
- return '200px';
29
- case 'lg':
30
- return '400px';
31
- case 'xl':
32
- return '700px';
33
- default:
34
- return 'auto';
35
- }
36
- }
37
- async checkIframeAvailability() {
38
- try {
39
- const response = await fetch(this.frameSrc, {
40
- method: 'GET'
41
- });
42
- if (!response.ok) {
43
- throw new Error('Failed to load');
44
- }
45
- } catch (error) {
46
- this.iframeError = true;
47
- }
48
- }
49
- componentWillLoad() {
50
- this.checkIframeAvailability();
51
- }
52
- componentDidLoad() {
53
- // Emit context for each eds-link element after the component is fully loaded
54
- const links = this.el.querySelectorAll('eds-link');
55
- links.forEach(link => {
56
- this.emitContext(link);
57
- });
58
- }
59
- /**
60
- * Emits a custom event called `parentContext` for a given link element.
61
- * This event provides context information about the breadcrumb component.
62
- *
63
- * @param linkElement - The link element to which the event will be dispatched.
64
- */
65
- emitContext(linkElement) {
66
- const event = new CustomEvent('parentContext', {
67
- detail: {
68
- componentName: this.el.tagName.toLowerCase(),
69
- identifier: this.frameLabel
70
- }
71
- });
72
- linkElement.dispatchEvent(event);
73
- }
74
- get storyLink() {
75
- return `${this.storybookUrl}/?path=/story/${this.storyPath}`;
76
- }
77
- get frameSrc() {
78
- return `${this.storybookUrl}/iframe.html?id=${this.storyPath}&viewMode=story`;
79
- }
80
- render() {
81
- return h("div", {
82
- key: '0c3a43efc1a125af5999af88c4eb071b5c3bc6c5',
83
- class: this.articleClasses()
84
- }, h("div", {
85
- key: '32303d5e2c2f3b01efe1ceaf828346f873bea6b6',
86
- class: "effect-height flex items-center justify-between py-8 px-12"
87
- }, h("span", {
88
- key: '75f7f6750413dad4af2ea62c12ffb994491d5d01',
89
- class: "f-ui-02"
90
- }, this.frameLabel), !this.iframeError ? h("eds-link", {
91
- label: this.urlLabel,
92
- url: this.storyLink,
93
- intent: this.intent,
94
- class: "ml-auto",
95
- external: true,
96
- disabled: false,
97
- icon: "arrow-diagonal"
98
- }) : null), h("div", {
99
- key: '1fd99f6eda026814910b0cd93635616b7d3ffe09',
100
- class: "border-softer border-t-2"
101
- }, this.iframeError ? h("div", {
102
- class: "container ml-8 mr-8 mt-16"
103
- }, this.errorMessage) : h("iframe", {
104
- src: this.frameSrc,
105
- width: "100%",
106
- height: this.getFrameHeight(),
107
- title: this.frameLabel,
108
- frameBorder: "0",
109
- allowFullScreen: true
110
- })));
111
- }
112
- get el() {
113
- return getElement(this);
114
- }
115
- };
116
-
117
- export { EdsFrame as eds_frame };