@ucd-lib/theme-elements 0.0.15 → 1.0.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.
package/.eslintrc.json CHANGED
@@ -1,3 +1,7 @@
1
1
  {
2
- "ignorePatterns" : ["*.tpl.js"]
2
+ "ignorePatterns" : ["*.tpl.js"],
3
+ "globals": {
4
+ "UCD_LIB_THEME_LOADER" : "readonly",
5
+ "WebComponents" : "readonly"
6
+ }
3
7
  }
@@ -0,0 +1,214 @@
1
+ import {html, LitElement} from 'lit';
2
+ import {render, styles} from "./ucd-theme-author-profile.tpl.js";
3
+ import {TaskController} from '../../utils/controllers/task.js';
4
+
5
+ /**
6
+ * @class AuthorProfile
7
+ * @description This author profile hydrates with the website wordpress api and goes into a profile block.
8
+ * @property {String} email - Email to reference person
9
+ * @property {String} domain - Specify the domain to choose from
10
+ *
11
+ * <ucdlib-author-profile domain="sandbox" email='sabaggett@ucdavis.edu></ucdlib-author-profile>
12
+ */
13
+ export default class UcdlibAuthorProfile extends LitElement {
14
+ static get properties() {
15
+ return {
16
+ results : {type: Object, attribute:false},
17
+ email : {type: String},
18
+ id: {type: Number},
19
+ nameLast: {type: String},
20
+ nameFirst: {type: String},
21
+ link: {type: String},
22
+ contactWebsite: {type: String},
23
+ contactEmail: {type: String},
24
+ contactPhone: {type: String},
25
+ contactWebsiteLabel: {type: String},
26
+ contactEmailLabel: {type: String},
27
+ contactPhoneLabel: {type: String},
28
+ contactAppointmentUrl: {type: String},
29
+ positionTitle: {type: String},
30
+ photo: {type: Object},
31
+ department: {type: String},
32
+ domain: {type: String}
33
+ };
34
+ }
35
+
36
+ static get styles() {
37
+ return styles();
38
+ }
39
+
40
+ constructor() {
41
+ super();
42
+ this.PENDING = false;
43
+ this.LOADING = false;
44
+ this.COMPLETE = false;
45
+ this.ERROR = false;
46
+ this.results = {};
47
+ this.email = '';
48
+ this.domain = '';
49
+ this.errorMessage = 'This is not an email.';
50
+
51
+ this.svgIcon = {
52
+ 'url': html`
53
+ <svg class="svg-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640">
54
+ <path d="M640,328V312a16,16,0,0,0-16-16H344V256h72a32,32,0,0,0,32-32V96a32,32,0,0,0-32-32H224a32,32,0,0,0-32,32V224a32,32,0,0,0,32,32h72v40H16A16,16,0,0,0,0,312v16a16,16,0,0,0,16,16H120v40H64a32,32,0,0,0-32,32V544a32,32,0,0,0,32,32H224a32,32,0,0,0,32-32V416a32,32,0,0,0-32-32H168V344H472v40H416a32,32,0,0,0-32,32V544a32,32,0,0,0,32,32H576a32,32,0,0,0,32-32V416a32,32,0,0,0-32-32H520V344H624A16,16,0,0,0,640,328ZM256,192V128H384v64ZM192,512H96V448h96Zm352,0H448V448h96Z"/>
55
+ </svg> `,
56
+ 'email': html`
57
+ <svg class="svg-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
58
+ <path d="M502.3,190.8a6,6,0,0,1,9.7,4.7V400a48,48,0,0,1-48,48H48A48,48,0,0,1,0,400V195.6a6,6,0,0,1,9.7-4.7c22.4,17.4,52.1,39.5,154.1,113.6,21.1,15.4,56.7,47.8,92.2,47.6,35.7.3,72-32.8,92.3-47.6C450.3,230.4,479.9,208.2,502.3,190.8ZM256,320c23.2.4,56.6-29.2,73.4-41.4,132.7-96.3,142.8-104.7,173.4-128.7A23.93,23.93,0,0,0,512,131V112a48,48,0,0,0-48-48H48A48,48,0,0,0,0,112v19a24.08,24.08,0,0,0,9.2,18.9c30.6,23.9,40.7,32.4,173.4,128.7,16.8,12.2,50.2,41.8,73.4,41.4Z"/>
59
+ </svg>`,
60
+ 'calendar': html `
61
+ <svg class="svg-icon" xmlns="http://www.w3.org/2000/svg"viewBox="0 0 512 512">
62
+ <path d="M12 192h424c6.6 0 12 5.4 12 12v260c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V204c0-6.6 5.4-12 12-12zm436-44v-36c0-26.5-21.5-48-48-48h-48V12c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v52H160V12c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v52H48C21.5 64 0 85.5 0 112v36c0 6.6 5.4 12 12 12h424c6.6 0 12-5.4 12-12z"/>
63
+ </svg>`,
64
+ 'phone': html `
65
+ <svg class="svg-icon" xmlns="http://www.w3.org/2000/svg"viewBox="0 0 512 512">
66
+ <path d="M497.39 361.8l-112-48a24 24 0 0 0-28 6.9l-49.6 60.6A370.66 370.66 0 0 1 130.6 204.11l60.6-49.6a23.94 23.94 0 0 0 6.9-28l-48-112A24.16 24.16 0 0 0 122.6.61l-104 24A24 24 0 0 0 0 48c0 256.5 207.9 464 464 464a24 24 0 0 0 23.4-18.6l24-104a24.29 24.29 0 0 0-14.01-27.6z"/>
67
+ </svg>
68
+ `
69
+ };
70
+ this.render=render.bind(this);
71
+
72
+ }
73
+
74
+
75
+ /**
76
+ * @method firstUpdated
77
+ *
78
+ * @description updated when the page first renders
79
+ *
80
+ * @param {Object} changedProperties
81
+ *
82
+ */
83
+ firstUpdated(){
84
+ if(this.email != ''){
85
+ this.eController = new TaskController(this, this._requestUrl());
86
+
87
+ this.requestUpdate();
88
+ }
89
+ }
90
+
91
+
92
+ /**
93
+ * @method validationLink
94
+ *
95
+ * @description Validates the email to make sure it is an email
96
+ *
97
+ * @param {String} email
98
+ *
99
+ * @returns {String}
100
+ *
101
+ */
102
+ validationLink(email){
103
+ const regexExp = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/gi;
104
+ return regexExp.test(email);
105
+ }
106
+
107
+ /**
108
+ * @method validationLink
109
+ *
110
+ * @description Validates the email to make sure it is an email
111
+ *
112
+ * @param {String} email
113
+ *
114
+ * @returns {String}
115
+ *
116
+ */
117
+ _onPending(){
118
+ this.PENDING = true;
119
+ }
120
+
121
+ /**
122
+ * @method _onError
123
+ *
124
+ * @description Sets error variable to true
125
+ *
126
+ * @param {String} e
127
+ *
128
+ */
129
+ _onError(e){
130
+ this.ERROR = true;
131
+ console.error(e);
132
+ }
133
+
134
+ /**
135
+ * @method _onComplete
136
+ *
137
+ * @description on complete defines the forms and updates
138
+ *
139
+ * @param {Object} results
140
+ *
141
+ *
142
+ */
143
+ _onComplete(results){
144
+ this.COMPLETE = true;
145
+ this.PENDING = false;
146
+ this.LOADING = false;
147
+ this.results = results;
148
+
149
+ this.id = this.results.id;
150
+
151
+ this.nameLast = this.results.nameLast;
152
+
153
+ this.nameFirst = this.results.nameFirst;
154
+
155
+ this.link = this.results.link;
156
+
157
+ this.contactWebsite = this.results.contactWebsite.length !== 0 ? this.results.contactWebsite[0].value :null;
158
+
159
+ this.contactEmail = this.results.contactEmail.length !== 0 ? this.results.contactEmail[0].value : null;
160
+
161
+ this.contactPhone = this.results.contactPhone.length !== 0 ? this.results.contactPhone[0].value : null;
162
+
163
+ this.contactAppointmentUrl = this.results.contactAppointmentUrl;
164
+
165
+ this.positionTitle = this.results.positionTitle;
166
+
167
+ this.photo = Object.keys(this.results.photo).length !== 0 ? this.results.photo : "Empty";
168
+
169
+ this.department = this.results.department.title;
170
+
171
+ this.photoAlt = this.nameFirst + "_" + this.nameLast + "_Img";
172
+
173
+ this.requestUpdate();
174
+
175
+
176
+ }
177
+
178
+ /**
179
+ * @method _requestUrl
180
+ *
181
+ * @description configures the url and checks for email validation
182
+ *
183
+ * @returns {String}
184
+ *
185
+ */
186
+ _requestUrl(){
187
+ let email =this.email;
188
+ let validate = this.validationLink(email);
189
+ if(!validate) console.error(email);
190
+ let url;
191
+
192
+ url = "https://library.ucdavis.edu/wp-json/ucdlib-directory/person/" + String(email);
193
+ if (this.domain != "")
194
+ url = "https://" + this.domain + ".library.ucdavis.edu/wp-json/ucdlib-directory/person/" + String(email);
195
+ this.requestUpdate();
196
+
197
+ return url;
198
+ }
199
+
200
+ /**
201
+ * @method _onLoading
202
+ *
203
+ * @description Sets loading variable to true
204
+ *
205
+ *
206
+ */
207
+ _onLoading(){
208
+ this.LOADING = true;
209
+ }
210
+
211
+
212
+ }
213
+
214
+ customElements.define('ucdlib-author-profile', UcdlibAuthorProfile);
@@ -0,0 +1,193 @@
1
+ import { html, css } from 'lit';
2
+
3
+ import normalizeCss from "@ucd-lib/theme-sass/normalize.css.js";
4
+ import teaserStyles from "@ucd-lib/theme-sass/4_component/_index.css.js";
5
+ import baseStyles from "@ucd-lib/theme-sass/1_base_html/_index.css.js";
6
+ import buttons from "@ucd-lib/theme-sass/2_base_class/_index.css.js";
7
+ export function styles() {
8
+ const elementStyles = css`
9
+ :host {
10
+ display: block;
11
+ }
12
+ form {
13
+ width:100%;
14
+ }
15
+ `;
16
+
17
+ return [elementStyles,baseStyles,teaserStyles,normalizeCss, buttons];
18
+ }
19
+
20
+ export function render() {
21
+ return html`
22
+ <style>
23
+ .vm-teaser__figure.category_loading{
24
+ background-color:#dcdcdc;
25
+ height:165px;
26
+ width:135px;
27
+ }
28
+ .load_teaser_a{
29
+ background-color:#dcdcdc;
30
+ width: 85%;
31
+ height:25px;
32
+ }
33
+ .load_teaser_b{
34
+ background-color:#dcdcdc;
35
+ width: 67%;
36
+ height:20px;
37
+ }
38
+ .load_teaser_c{
39
+ background-color:#dcdcdc;
40
+ width: 33.3%;
41
+ height:18px;
42
+ }
43
+ .container {
44
+ display: inline-grid;
45
+ grid-template-columns: 15% 85%;
46
+ width:100%;
47
+ }
48
+ .container-no-image {
49
+ display: inline-grid;
50
+ width:100%;
51
+ }
52
+ article {
53
+ margin-bottom: 50px;
54
+ }
55
+
56
+ .photo {
57
+ position: relative;
58
+ width:90%;
59
+ height:90%;
60
+ }
61
+
62
+ .photo:after {
63
+ content: "";
64
+ display:inline-block;
65
+ }
66
+
67
+ .content {
68
+ position: absolute;
69
+ width: 70%;
70
+ height: 70%;
71
+ }
72
+
73
+ .text_container {
74
+ vertical-align:top;
75
+ display:inline-block;
76
+ }
77
+ .name {
78
+ color:var(--ucd-blue-80);
79
+ margin-bottom:0;
80
+ }
81
+ .title {
82
+ margin-bottom:0;
83
+ }
84
+ .info {
85
+ color:var(--ucd-blue-80);
86
+ margin-bottom:0;
87
+ }
88
+ .svg-icon {
89
+ width: 20px;
90
+ height: 20px;
91
+ fill: #73ABDD;
92
+ margin-right: 5px;
93
+ }
94
+ .contact-list{
95
+ display:inline-block;
96
+ margin-top:5px;
97
+ }
98
+ .pipe {
99
+ font-size:30px;
100
+ vertical-align: middle;
101
+ font-weight: lighter;
102
+ line-height: 25px;
103
+ color:#36454F;
104
+ }
105
+
106
+ @media (max-width: 800px) {
107
+
108
+ .contact-list {
109
+ display:block;
110
+ margin-bottom:5px;
111
+ }
112
+
113
+ .contact-list .pipe {
114
+ display:none;
115
+ }
116
+ .photo {
117
+ width:90%;
118
+ height:90%;
119
+ }
120
+
121
+ }
122
+
123
+ @media (max-width: 550px) {
124
+ .container {
125
+ grid-template-columns: 35% 65%;
126
+ }
127
+ .photo {
128
+ width:80%;
129
+ height:80%;
130
+ }
131
+
132
+ }
133
+ </style>
134
+ <!--
135
+ Starts the Permalink Fetch
136
+ -->
137
+ ${this.eController ? html`
138
+ ${this.eController.render({
139
+ complete: (result) => this._onComplete(result),
140
+ initial: () => this._onLoading(),
141
+ pending: () => this._onPending(),
142
+ error: (e) => this._onError(e)
143
+ })
144
+ }`:html``
145
+ }
146
+
147
+ <article>
148
+ ${!this.LOADING ? html`
149
+ ${this.photo != "Empty" && this.photo != undefined ?
150
+ html`
151
+ <div class="container">
152
+ <div class="photo"><img src="${this.photo.link}" alt="${this.photoAlt}"></div>
153
+ <div class="text_container">
154
+ <h3 class="name"><a class="name" href="">${this.nameFirst} ${this.nameLast}</a></h3>
155
+ <p class="title">${this.positionTitle} <span class="pipe">&#124;</span> ${this.department}</p>
156
+ <p class="contact-list">${this.contactPhone ? html`${this.svgIcon.phone} <a class="info" href="tel:${this.contactPhone}">${this.contactPhone}</a> <span class="pipe">&#124;</span>`: html``}</p>
157
+ <p class="contact-list">${this.contactEmail ? html`${this.svgIcon.email} <a class="info" href="mailto:${this.contactEmail}">${this.contactEmail}</a> <span class="pipe">&#124;</span>`: html``}</p>
158
+ <p class="contact-list">${this.svgIcon.calendar} <a class="info" href="${this.contactAppointmentUrl}">Book an Appointment</a></p>
159
+ </div>
160
+ </div>
161
+ `
162
+ :html`
163
+ <div class="container-no-image">
164
+ <div class="text_container">
165
+ <h3 class="name"><a class="name" href="">${this.nameFirst} ${this.nameLast}</a></h3>
166
+ <p class="title">${this.positionTitle} <span class="pipe">&#124;</span> ${this.department}</p>
167
+ <p class="contact-list">${this.contactPhone ? html`${this.svgIcon.phone} <a class="info" href="tel:${this.contactPhone}">${this.contactPhone}</a> <span class="pipe">&#124;</span> `: html``}</p>
168
+ <p class="contact-list">${this.contactEmail ? html`${this.svgIcon.email} <a class="info" href="mailto:${this.contactEmail}">${this.contactEmail}</a> <span class="pipe">&#124;</span>`: html``}</p>
169
+ <p class="contact-list">${this.svgIcon.calendar} <a class="info" href="${this.contactAppointmentUrl ? this.contactAppointmentUrl:"#"}">Book an Appointment</a></p>
170
+ </div>
171
+ </div>
172
+ `}
173
+
174
+ `:html`
175
+ <!--
176
+ If it is in the loading stage of the permalink fetch
177
+ it will render this
178
+ look.
179
+ -->
180
+ <div class="vm-teaser__figure category_loading"></div>
181
+ <div class="vm-teaser__body">
182
+ <div class="load_teaser_a"></div>
183
+ <br/>
184
+ <div class="load_teaser_b"></div>
185
+ <br/>
186
+ <div class="load_teaser_c"></div>
187
+ <br/>
188
+ <div class="load_teaser_c"></div>
189
+ </div>
190
+ `}
191
+ </article>
192
+ `;
193
+ }
@@ -149,7 +149,6 @@ export default class UcdThemeSubnav extends Mixin(LitElement)
149
149
  * @description Fires an 'item-click' event
150
150
  * @param {Object} item - The link item
151
151
  * @param {Array} location - The link location in links array
152
- * @returns
153
152
  */
154
153
  _dispatchItemClick(item, location){
155
154
  if (item.href) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ucd-lib/theme-elements",
3
- "version": "0.0.15",
3
+ "version": "1.0.0",
4
4
  "description": "Custom elements for the UCD brand theme",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -9,8 +9,12 @@
9
9
  "author": "jrmerz@ucdavis.edu",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
+ "@lit-labs/task": "^1.0.0",
12
13
  "@ucd-lib/theme-sass": "^5.0.15",
14
+ "dompurify": "^2.3.9",
15
+ "ip-cidr": "^3.0.4",
13
16
  "lit": "^2.0.2",
17
+ "marked": "^4.0.18",
14
18
  "photoswipe": "^4.1.3",
15
19
  "slim-select": "^1.26.2"
16
20
  }
@@ -0,0 +1,31 @@
1
+ import { LitElement } from 'lit';
2
+ import { MutationObserverController } from '../../utils/controllers';
3
+
4
+ /**
5
+ * @class UcdlibMdContent
6
+ * @classdesc Component class for declaritively wrapping markdown and translating into sanitized html
7
+ */
8
+ export default class UcdlibMdContent extends LitElement {
9
+
10
+ static get properties() {
11
+ return {};
12
+ }
13
+
14
+ mutationObserver = new MutationObserverController(this, { characterData: true, attributes: false, childList: true, subtree: true });
15
+
16
+ constructor() {
17
+ super();
18
+ }
19
+
20
+ createRenderRoot() {
21
+ this.style.display = 'none';
22
+ return this;
23
+ }
24
+
25
+ _onChildListMutation() {
26
+ // send event to ucdlib-md
27
+ this.dispatchEvent(new CustomEvent('content-updated', { bubbles: true }));
28
+ }
29
+ }
30
+
31
+ customElements.define('ucdlib-md-content', UcdlibMdContent);
@@ -0,0 +1,120 @@
1
+ import { LitElement, css } from 'lit';
2
+ import { marked } from 'marked';
3
+ import DOMPurify from 'dompurify';
4
+ import { UcdlibMdContent } from './ucdlib-md-content.js';
5
+ import { MutationObserverController } from '../../utils/controllers/mutation-observer.js';
6
+
7
+ /**
8
+ * @class UcdlibMd
9
+ * @classdesc Component class for translating/displaying markdown into sanitized html
10
+ * @property {String} data - text to hold markdown code
11
+ * @property {Object} renderer - an object holding element functions to override the default markdown behavior
12
+ * Format: reference the Marked Renderer documentation at https://marked.js.org/using_pro#renderer
13
+ * @property {Object} use - marked use object
14
+ * @property {Object} options - marked options object
15
+ */
16
+ export default class UcdlibMd extends LitElement {
17
+
18
+ static get properties() {
19
+ return {
20
+ // ignore: {type: String},
21
+ // exclude: {type: String},
22
+ // subset: {type: String},
23
+ data: {type: String},
24
+ renderer: {type: Object},
25
+ use: {type: Object},
26
+ options: {type: Object}
27
+ };
28
+ }
29
+
30
+ mutationObserver = new MutationObserverController(this, { characterData: true, attributes: false, childList: true, subtree: true });
31
+
32
+ constructor() {
33
+ super();
34
+ this.data = '';
35
+ this.renderer = null;
36
+
37
+ this.renderedElement = document.createElement('div');
38
+ this.renderedElement.setAttribute('rendered', '');
39
+ }
40
+
41
+ createRenderRoot() {
42
+ this.appendChild(this.renderedElement);
43
+ return this;
44
+ }
45
+
46
+ _onChildListMutation() {
47
+ if( this.contentElement ) return;
48
+
49
+ // query children for ucdlib-md-content
50
+ // wire up listener if it exists
51
+ this.contentElement = this.querySelector('ucdlib-md-content');
52
+ if( this.contentElement ) {
53
+ this.contentElement.addEventListener('content-updated', this._updateFromContentElementMd.bind(this));
54
+ }
55
+ }
56
+
57
+ disconnectedCallback() {
58
+ if( this.contentElement ) {
59
+ this.contentElement.removeEventListener('content-updated', this._updateFromContentElementMd.bind(this));
60
+ }
61
+ }
62
+
63
+ /**
64
+ * @method updated
65
+ * @description Lit method called when element is updated.
66
+ */
67
+ updated() {
68
+ // config markdown renderer so elements are correctly styled
69
+ this._setRendererOverrides();
70
+
71
+ // update markdown data with the latest, either when the content changes or data property is updated
72
+ this.data = DOMPurify.sanitize(marked.parse(this.data));
73
+ this.renderedElement.innerHTML = this.data;
74
+ }
75
+
76
+ /**
77
+ * @method _updateFromContentElementMd
78
+ * @description Updates the local data property with the text from the ucdlib-md-content element (if it exists)
79
+ * @private
80
+ */
81
+ _updateFromContentElementMd() {
82
+ // remove whitespace between lines
83
+ this.data = this.contentElement.innerText.split('\n').map(line => line.trim()).join('\n');
84
+ }
85
+
86
+ /**
87
+ * @method _setRendererOverrides
88
+ * @description Updates the marked package renderer overrides to customize how element types are rendered
89
+ * @private
90
+ */
91
+ _setRendererOverrides() {
92
+ if (!this.renderer) {
93
+ this.renderer = {
94
+ list(body, ordered, start) {
95
+ let renderedContent = '';
96
+ if (ordered) {
97
+ renderedContent = `<ul class="list--multilevel">${body}</ul>`;
98
+ } else {
99
+ renderedContent = `<ul class="list--bordered">${body}</ul>`;
100
+ }
101
+ return renderedContent;
102
+ }
103
+ };
104
+ }
105
+
106
+ if (!this.options) {
107
+ this.options = { breaks: true, gfm: true };
108
+ }
109
+
110
+ if (!this.use) {
111
+ this.use = { renderer: this.renderer };
112
+ }
113
+
114
+ marked.use(this.use);
115
+ marked.setOptions(this.options);
116
+ }
117
+
118
+ }
119
+
120
+ customElements.define('ucdlib-md', UcdlibMd);
@@ -0,0 +1,22 @@
1
+ # SILS Permalink
2
+
3
+ Allows users to easily add links to SILS permalinks in webpages.
4
+
5
+ ## Inline Version
6
+
7
+ By default add simple links to the pages. If you identified a tag inline like
8
+ `<ucdlib-sils-permalink
9
+ href="https://search.library.ucdavis.edu/permalink/01UCD_INST/1uov27j/alma9981249369903126"/>`,
10
+ then the link would format as something like
11
+
12
+ * [Engineering victory : the Union siege of
13
+ Vicksburg](https://search.library.ucdavis.edu/permalink/01UCD_INST/1uov27j/alma9981249369903126)
14
+
15
+ For more citation information, we'd could add
16
+
17
+ * `<ucdlib-sils-permalink href=".." cite="full" />` => [Solonick, Justin
18
+ S. Engineering Victory : the Union Siege of Vicksburg . Carbondale: Southern
19
+ Illinois University
20
+ Press, 2015. Print.](https://search.library.ucdavis.edu/permalink/01UCD_INST/1uov27j/alma9981249369903126)
21
+
22
+ ## Expanded Version
@@ -0,0 +1,36 @@
1
+ import {Task} from '@lit-labs/task';
2
+
3
+ export class PermalinkController {
4
+ // host;
5
+ // value;
6
+ // kinds = Names.kinds;
7
+ // task;
8
+ constructor(host, url) {
9
+ const baseUrl = url;
10
+ this.url = baseUrl;
11
+ this.host = host;
12
+ this.task = new Task(
13
+ this.host,
14
+ async () => {
15
+ const response = await fetch(`${baseUrl}`);
16
+ const result = await response.json();
17
+ const error = result.error;
18
+ if (error !== undefined) {
19
+ throw new Error(error);
20
+ }
21
+ return result;
22
+ },
23
+
24
+ () => [this.url]
25
+ );
26
+
27
+ }
28
+
29
+
30
+ render(renderFunctions) {
31
+ return this.task.render(renderFunctions);
32
+ }
33
+
34
+
35
+
36
+ }