1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', { value: true });
|
4 |
|
5 | const core = require('./core-96a5dc61.js');
|
6 |
|
7 | const keys = ['inputs', 'outputs', 'props', 'events', 'methods'];
|
8 | const Api = class {
|
9 | constructor(hostRef) {
|
10 | core.registerInstance(this, hostRef);
|
11 | }
|
12 | hasApi() {
|
13 | if (!this.doc) {
|
14 | return false;
|
15 | }
|
16 | for (const k of keys) {
|
17 | if (this.doc[k] && this.doc[k].length > 0) {
|
18 | return true;
|
19 | }
|
20 | }
|
21 | }
|
22 | angular() {
|
23 | return [
|
24 | this.doc.inputs ? this.doc.inputs.map(i => core.h("ad-input-def", { input: i })) : undefined,
|
25 | this.doc.outputs ? this.doc.outputs.map(i => core.h("ad-output-def", { output: i })) : undefined,
|
26 | this.doc.props ? this.doc.props.map(i => core.h("ad-prop-def", { prop: i })) : undefined
|
27 | ];
|
28 | }
|
29 | stencil() {
|
30 | return [
|
31 | this.doc.props ? this.doc.props.map(i => core.h("ad-prop-def", { prop: i })) : undefined,
|
32 | this.doc.events ? this.doc.events.map(i => core.h("ad-event-def", { event: i })) : undefined,
|
33 | ];
|
34 | }
|
35 | render() {
|
36 | if (!this.hasApi()) {
|
37 | return undefined;
|
38 | }
|
39 | const isAngular = !this.doc.tag;
|
40 | return (core.h("article", { id: "api", class: "api" }, core.h("h2", null, "API"), isAngular ? this.angular() : this.stencil(), this.doc.methods ? this.doc.methods.map(i => core.h("ad-method-def", { method: i })) : undefined));
|
41 | }
|
42 | static get style() { return ".sc-ad-api-h{display:block;font-size:.875rem;font-family:var(--anj-font-family);font-weight:400;line-height:1.5;outline:none}.sc-ad-api-h, .sc-ad-api-h:after, .sc-ad-api-h:before{-webkit-box-sizing:border-box;box-sizing:border-box;outline:none}.sc-ad-api-h:active, .sc-ad-api-h .sc-ad-api:active, .sc-ad-api-h:focus, .sc-ad-api-h .sc-ad-api:focus{outline:none}.sc-ad-api-h .api.sc-ad-api{border-bottom:1px solid var(--anj-border);margin-bottom:3rem;padding-bottom:3rem}.sc-ad-api-h .api.sc-ad-api h2.sc-ad-api{margin-bottom:1.5rem}"; }
|
43 | };
|
44 |
|
45 | const ApiName = class {
|
46 | constructor(hostRef) {
|
47 | core.registerInstance(this, hostRef);
|
48 | }
|
49 | static get style() { return "ad-api-name{display:inline;font-size:.875rem;font-family:var(--anj-font-family);font-weight:400;line-height:1.5;outline:none}ad-api-name,ad-api-name:after,ad-api-name:before{-webkit-box-sizing:border-box;box-sizing:border-box;outline:none}ad-api-name:active,ad-api-name :active,ad-api-name:focus,ad-api-name :focus{outline:none}ad-api-name:after{color:var(--anj-secondary-dark);content:\":\";margin-right:.5rem}"; }
|
50 | };
|
51 |
|
52 | const ArgDef = class {
|
53 | constructor(hostRef) {
|
54 | core.registerInstance(this, hostRef);
|
55 | }
|
56 | render() {
|
57 | return [
|
58 | core.h("ad-api-name", null, this.arg.name),
|
59 | core.h("ad-type-def", null, this.arg.type)
|
60 | ];
|
61 | }
|
62 | static get style() { return "ad-arg-def{display:inline;font-size:.875rem;font-family:var(--anj-font-family);font-weight:400;line-height:1.5;outline:none}ad-arg-def,ad-arg-def:after,ad-arg-def:before{-webkit-box-sizing:border-box;box-sizing:border-box;outline:none}ad-arg-def:active,ad-arg-def :active,ad-arg-def:focus,ad-arg-def :focus{outline:none}ad-arg-def:after{color:var(--anj-secondary-dark);content:\",\";margin-right:.5rem}ad-arg-def:last-child:after{content:none;margin-right:0}"; }
|
63 | };
|
64 |
|
65 | const Decorator = class {
|
66 | constructor(hostRef) {
|
67 | core.registerInstance(this, hostRef);
|
68 | }
|
69 | static get style() { return "ad-decorator{color:var(--anj-secondary-dark)}.api.ng ad-method-def ad-decorator,.api.ng ad-prop-def ad-decorator{display:none}"; }
|
70 | };
|
71 |
|
72 | const EventDef = class {
|
73 | constructor(hostRef) {
|
74 | core.registerInstance(this, hostRef);
|
75 | }
|
76 | render() {
|
77 | return [
|
78 | core.h("h4", null, core.h("ad-decorator", null, "@Event"), "\u00A0", core.h("ad-api-name", null, this.event.event), core.h("ad-type-def", null, "<", this.event.detail, ">")),
|
79 | core.h("p", null, this.event.docs)
|
80 | ];
|
81 | }
|
82 | static get style() { return "ad-event-def,ad-input-def,ad-method-def,ad-output-def,ad-prop-def{display:block;margin-bottom:1.5rem}ad-event-def h4,ad-input-def h4,ad-method-def h4,ad-output-def h4,ad-prop-def h4{color:var(--anj-dark);font-size:1rem;font-weight:400;margin:0 0 .5rem;padding:0}"; }
|
83 | };
|
84 |
|
85 | const InputDef = class {
|
86 | constructor(hostRef) {
|
87 | core.registerInstance(this, hostRef);
|
88 | }
|
89 | render() {
|
90 | return [
|
91 | core.h("h4", null, core.h("ad-decorator", null, "@Input\u00A0"), core.h("ad-api-name", null, this.input.name), core.h("ad-type-def", null, this.input.type)),
|
92 | core.h("p", null, this.input.docs)
|
93 | ];
|
94 | }
|
95 | static get style() { return "ad-event-def,ad-input-def,ad-method-def,ad-output-def,ad-prop-def{display:block;margin-bottom:1.5rem}ad-event-def h4,ad-input-def h4,ad-method-def h4,ad-output-def h4,ad-prop-def h4{color:var(--anj-dark);font-size:1rem;font-weight:400;margin:0 0 .5rem;padding:0}"; }
|
96 | };
|
97 |
|
98 | const MethodDef = class {
|
99 | constructor(hostRef) {
|
100 | core.registerInstance(this, hostRef);
|
101 | }
|
102 | nameless(name) {
|
103 | return `(${name.split('(')[1]}`;
|
104 | }
|
105 | render() {
|
106 | return [
|
107 | core.h("h4", null, core.h("ad-decorator", null, "@Method\u00A0"), core.h("ad-api-name", null, this.method.name), core.h("ad-type-def", null, this.nameless(this.method.signature))),
|
108 | core.h("p", null, this.method.docs)
|
109 | ];
|
110 | }
|
111 | static get style() { return "ad-event-def,ad-input-def,ad-method-def,ad-output-def,ad-prop-def{display:block;margin-bottom:1.5rem}ad-event-def h4,ad-input-def h4,ad-method-def h4,ad-output-def h4,ad-prop-def h4{color:var(--anj-dark);font-size:1rem;font-weight:400;margin:0 0 .5rem;padding:0}"; }
|
112 | };
|
113 |
|
114 | const OutputDef = class {
|
115 | constructor(hostRef) {
|
116 | core.registerInstance(this, hostRef);
|
117 | }
|
118 | render() {
|
119 | return [
|
120 | core.h("h4", null, core.h("ad-decorator", null, "@Output\u00A0"), core.h("ad-api-name", null, this.output.name), core.h("ad-type-def", null, this.output.type)),
|
121 | core.h("p", null, this.output.docs)
|
122 | ];
|
123 | }
|
124 | static get style() { return "ad-event-def,ad-input-def,ad-method-def,ad-output-def,ad-prop-def{display:block;margin-bottom:1.5rem}ad-event-def h4,ad-input-def h4,ad-method-def h4,ad-output-def h4,ad-prop-def h4{color:var(--anj-dark);font-size:1rem;font-weight:400;margin:0 0 .5rem;padding:0}"; }
|
125 | };
|
126 |
|
127 | const PropDef = class {
|
128 | constructor(hostRef) {
|
129 | core.registerInstance(this, hostRef);
|
130 | }
|
131 | render() {
|
132 | return [
|
133 | core.h("h4", null, core.h("ad-decorator", null, "@Prop\u00A0"), core.h("ad-api-name", null, this.prop.name), core.h("ad-type-def", null, this.prop.type)),
|
134 | core.h("p", null, this.prop.docs)
|
135 | ];
|
136 | }
|
137 | static get style() { return "ad-event-def,ad-input-def,ad-method-def,ad-output-def,ad-prop-def{display:block;margin-bottom:1.5rem}ad-event-def h4,ad-input-def h4,ad-method-def h4,ad-output-def h4,ad-prop-def h4{color:var(--anj-dark);font-size:1rem;font-weight:400;margin:0 0 .5rem;padding:0}"; }
|
138 | };
|
139 |
|
140 | const RealTime = class {
|
141 | constructor(hostRef) {
|
142 | core.registerInstance(this, hostRef);
|
143 | }
|
144 | static get style() { return "ad-real-time{border:1px dashed var(--anj-border);border-radius:.25rem;display:block;margin-top:1.5rem;overflow-x:auto;padding:1rem;width:100%}"; }
|
145 | };
|
146 |
|
147 | const Toc = class {
|
148 | constructor(hostRef) {
|
149 | core.registerInstance(this, hostRef);
|
150 | this.activeId = '#overview';
|
151 | |
152 |
|
153 |
|
154 | this.docs = {};
|
155 | |
156 |
|
157 |
|
158 | this.keys = [];
|
159 | }
|
160 | onDemosChange() {
|
161 | this.sectionIds = ['#overview'].concat(this.keys.map(d => `#${d}`)).concat('#api');
|
162 | }
|
163 | connectedCallback() {
|
164 | this.navigate = debounce(this.navigate.bind(this), 100);
|
165 | this.onScroll = debounce(this.onScroll.bind(this), 25);
|
166 | this.onDemosChange();
|
167 | if (window.location.hash) {
|
168 | this.navigate();
|
169 | }
|
170 | }
|
171 | onScroll() {
|
172 | const els = this.sectionIds.map(id => document.querySelector(id));
|
173 | let closest = els[0];
|
174 | els.slice(1).forEach(el => {
|
175 | if (el && Math.abs(window.scrollY - el.offsetTop) < Math.abs(window.scrollY - closest.offsetTop)) {
|
176 | closest = el;
|
177 | }
|
178 | });
|
179 | this.activeId = `#${closest.getAttribute('id')}`;
|
180 | }
|
181 | parseTitle(id) {
|
182 | const usage = id.replace('#', '');
|
183 | const doc = this.docs[usage];
|
184 | return doc ? doc.split(/##(.*?)\n/).find(p => p !== '').trim() : usage;
|
185 | }
|
186 | anchorClass(usage) {
|
187 | return usage === this.activeId ? 'anj-active' : '';
|
188 | }
|
189 | navigate() {
|
190 | return new Promise(resolve => {
|
191 | window.setTimeout(() => {
|
192 | this.activeId = window.location.hash;
|
193 | const el = document.querySelector(this.activeId);
|
194 | if (el) {
|
195 | window.scrollTo(0, el.offsetTop);
|
196 | }
|
197 | resolve();
|
198 | }, 500);
|
199 | });
|
200 | }
|
201 | render() {
|
202 | if (!this.sectionIds) {
|
203 | return;
|
204 | }
|
205 | const path = window.location.pathname;
|
206 | return (core.h("div", { class: "anj-toc" }, this.sectionIds.map(id => core.h("a", { href: `${path}${id}`, onClick: () => this.activeId = id, class: this.anchorClass(id) }, this.parseTitle(id)))));
|
207 | }
|
208 | static get watchers() { return {
|
209 | "keys": ["onDemosChange"]
|
210 | }; }
|
211 | static get style() { return "ad-toc{display:block;position:relative}ad-toc .anj-toc{padding:1rem 0;position:fixed;top:3rem}ad-toc a{display:block;font-size:.75rem;margin-bottom:.5rem;text-transform:capitalize;-webkit-transition:color .2s ease;transition:color .2s ease}ad-toc a:focus{text-decoration:underline}ad-toc a:active{text-decoration:none}ad-toc a.anj-active,ad-toc a.anj-active:focus,ad-toc a.anj-active:hover{color:var(--anj-primary);text-decoration:none}"; }
|
212 | };
|
213 | const debounce = (func, wait = 0) => {
|
214 | let timer;
|
215 | return (...args) => {
|
216 | clearTimeout(timer);
|
217 | timer = setTimeout(func, wait, ...args);
|
218 | };
|
219 | };
|
220 |
|
221 | const TypeDef = class {
|
222 | constructor(hostRef) {
|
223 | core.registerInstance(this, hostRef);
|
224 | }
|
225 | static get style() { return "ad-type-def{color:var(--anj-neutral-dark);font-size:.75rem}"; }
|
226 | };
|
227 |
|
228 | exports.ad_api = Api;
|
229 | exports.ad_api_name = ApiName;
|
230 | exports.ad_arg_def = ArgDef;
|
231 | exports.ad_decorator = Decorator;
|
232 | exports.ad_event_def = EventDef;
|
233 | exports.ad_input_def = InputDef;
|
234 | exports.ad_method_def = MethodDef;
|
235 | exports.ad_output_def = OutputDef;
|
236 | exports.ad_prop_def = PropDef;
|
237 | exports.ad_real_time = RealTime;
|
238 | exports.ad_toc = Toc;
|
239 | exports.ad_type_def = TypeDef;
|