cruzo 0.9.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/LICENSE +21 -0
- package/README.md +268 -0
- package/assets/cruzo.png +0 -0
- package/dist/component-CH-TJ5VF.js +1850 -0
- package/dist/component-CH-TJ5VF.js.map +1 -0
- package/dist/component.d.ts +62 -0
- package/dist/component.d.ts.map +1 -0
- package/dist/components-registry.service.d.ts +21 -0
- package/dist/components-registry.service.d.ts.map +1 -0
- package/dist/http.d.ts +54 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +355 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces.d.ts +39 -0
- package/dist/interfaces.d.ts.map +1 -0
- package/dist/lib/component.d.ts +62 -0
- package/dist/lib/component.d.ts.map +1 -0
- package/dist/lib/components-registry.service.d.ts +21 -0
- package/dist/lib/components-registry.service.d.ts.map +1 -0
- package/dist/lib/http.d.ts +54 -0
- package/dist/lib/http.d.ts.map +1 -0
- package/dist/lib/index.d.ts +14 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/interfaces.d.ts +39 -0
- package/dist/lib/interfaces.d.ts.map +1 -0
- package/dist/lib/router.service.d.ts +84 -0
- package/dist/lib/router.service.d.ts.map +1 -0
- package/dist/lib/rx-scope.d.ts +76 -0
- package/dist/lib/rx-scope.d.ts.map +1 -0
- package/dist/lib/rx.d.ts +21 -0
- package/dist/lib/rx.d.ts.map +1 -0
- package/dist/lib/service.d.ts +10 -0
- package/dist/lib/service.d.ts.map +1 -0
- package/dist/lib/template.d.ts +141 -0
- package/dist/lib/template.d.ts.map +1 -0
- package/dist/lib/utils.d.ts +4 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/vm.d.ts +118 -0
- package/dist/lib/vm.d.ts.map +1 -0
- package/dist/router.service-CYzZn3L6.js +231 -0
- package/dist/router.service-CYzZn3L6.js.map +1 -0
- package/dist/router.service.d.ts +84 -0
- package/dist/router.service.d.ts.map +1 -0
- package/dist/rx-scope.d.ts +76 -0
- package/dist/rx-scope.d.ts.map +1 -0
- package/dist/rx.d.ts +21 -0
- package/dist/rx.d.ts.map +1 -0
- package/dist/service.d.ts +10 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/template.d.ts +141 -0
- package/dist/template.d.ts.map +1 -0
- package/dist/ui-components/button-group/button-group.component.d.ts +17 -0
- package/dist/ui-components/button-group/button-group.component.d.ts.map +1 -0
- package/dist/ui-components/button-group.css +38 -0
- package/dist/ui-components/button-group.js +35 -0
- package/dist/ui-components/button-group.js.map +1 -0
- package/dist/ui-components/input/input.component.d.ts +41 -0
- package/dist/ui-components/input/input.component.d.ts.map +1 -0
- package/dist/ui-components/input.css +13 -0
- package/dist/ui-components/input.js +104 -0
- package/dist/ui-components/input.js.map +1 -0
- package/dist/ui-components/modal/modal.component.d.ts +32 -0
- package/dist/ui-components/modal/modal.component.d.ts.map +1 -0
- package/dist/ui-components/modal.css +35 -0
- package/dist/ui-components/modal.js +45 -0
- package/dist/ui-components/modal.js.map +1 -0
- package/dist/ui-components/router-link/router-link.d.ts +29 -0
- package/dist/ui-components/router-link/router-link.d.ts.map +1 -0
- package/dist/ui-components/router-link.js +46 -0
- package/dist/ui-components/router-link.js.map +1 -0
- package/dist/ui-components/select/select.component.d.ts +30 -0
- package/dist/ui-components/select/select.component.d.ts.map +1 -0
- package/dist/ui-components/select.css +111 -0
- package/dist/ui-components/select.js +77 -0
- package/dist/ui-components/select.js.map +1 -0
- package/dist/ui-components/spinner/spinner.component.d.ts +30 -0
- package/dist/ui-components/spinner/spinner.component.d.ts.map +1 -0
- package/dist/ui-components/spinner.css +106 -0
- package/dist/ui-components/spinner.js +83 -0
- package/dist/ui-components/spinner.js.map +1 -0
- package/dist/ui-components/upload/upload.component.d.ts +17 -0
- package/dist/ui-components/upload/upload.component.d.ts.map +1 -0
- package/dist/ui-components/upload.css +31 -0
- package/dist/ui-components/upload.js +34 -0
- package/dist/ui-components/upload.js.map +1 -0
- package/dist/utils.d.ts +4 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +26 -0
- package/dist/utils.js.map +1 -0
- package/dist/vm.d.ts +118 -0
- package/dist/vm.d.ts.map +1 -0
- package/package.json +74 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
var a = Object.defineProperty;
|
|
2
|
+
var u = (o, s, e) => s in o ? a(o, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[s] = e;
|
|
3
|
+
var t = (o, s, e) => u(o, typeof s != "symbol" ? s + "" : s, e);
|
|
4
|
+
import { c as r, A as p } from "../component-CH-TJ5VF.js";
|
|
5
|
+
function g(o) {
|
|
6
|
+
return Object.assign({}, o);
|
|
7
|
+
}
|
|
8
|
+
class l extends p {
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
t(this, "hasConfig", !0);
|
|
12
|
+
t(this, "hasOuterScope", !0);
|
|
13
|
+
t(this, "open$", this.newRx(!1));
|
|
14
|
+
t(this, "items$", this.newRx(null));
|
|
15
|
+
t(this, "selectedLabel$", this.newRx(""));
|
|
16
|
+
t(this, "getItems$", this.newRxFunc(async (e, n) => {
|
|
17
|
+
if (!e || !(n != null && n.length)) return;
|
|
18
|
+
const c = n.filter((i) => e[i.value]).map((i) => i.label);
|
|
19
|
+
c.length ? this.selectedLabel$.update(c.join(", ")) : this.config && this.selectedLabel$.update(this.config.placeholder);
|
|
20
|
+
}, this.value$, this.items$));
|
|
21
|
+
t(this, "handleOutsideClick", (e) => {
|
|
22
|
+
this.node && !this.node.contains(e.target) && this.open$.update(!1);
|
|
23
|
+
});
|
|
24
|
+
this.value$.update({});
|
|
25
|
+
}
|
|
26
|
+
connectedCallback() {
|
|
27
|
+
super.connectedCallback(), document.addEventListener("click", this.handleOutsideClick), this.getItems();
|
|
28
|
+
}
|
|
29
|
+
async getItems() {
|
|
30
|
+
const e = await this.config.getItems();
|
|
31
|
+
this.items$.update(e);
|
|
32
|
+
}
|
|
33
|
+
disconnectedCallback() {
|
|
34
|
+
document.removeEventListener("click", this.handleOutsideClick), super.disconnectedCallback();
|
|
35
|
+
}
|
|
36
|
+
toggle() {
|
|
37
|
+
this.open$.update(!this.open$.actual);
|
|
38
|
+
}
|
|
39
|
+
toggleItem(e) {
|
|
40
|
+
const n = this.config.multi ? Object.assign({}, this.value) : { [e.value]: this.value[e.value] };
|
|
41
|
+
n[e.value] = !n[e.value], this.outerScope.setValue(this.id, n, this.index, !0), this.config.multi || this.open$.update(!1);
|
|
42
|
+
}
|
|
43
|
+
getItemContent() {
|
|
44
|
+
return `${this.config.multi ? `<label class="checkbox">
|
|
45
|
+
<input
|
|
46
|
+
type="checkbox"
|
|
47
|
+
checked="{{root.value$::rx?.[this.value]}}"
|
|
48
|
+
/>
|
|
49
|
+
</label>` : ""} <span>{{this.label}}</span>`;
|
|
50
|
+
}
|
|
51
|
+
getHTML() {
|
|
52
|
+
return `<div class="cruzo-ui-component_select">
|
|
53
|
+
<button type="button" class="cruzo-ui-component_trigger" onclick="{{root.toggle()}}">
|
|
54
|
+
<span class="cruzo-ui-component_value">{{root.selectedLabel$::rx}}</span>
|
|
55
|
+
<span class="cruzo-ui-component_caret {{root.open$::rx ? 'cruzo-ui-component_caret-open' : ''}}">▴</span>
|
|
56
|
+
</button>
|
|
57
|
+
<div class="cruzo-ui-component_dropdown" style="{{root.open$::rx ? '' : 'display:none'}}">
|
|
58
|
+
<div class="cruzo-ui-component_list" style="{{root.items$::rx && root.items$::rx.length ? '' : 'display:none'}}">
|
|
59
|
+
<div
|
|
60
|
+
repeat="{{root.items$::rx}}"
|
|
61
|
+
class="cruzo-ui-component_option {{root.value$::rx?.[this.value] ? 'cruzo-ui-component_option-selected' : ''}}"
|
|
62
|
+
onclick="{{root.toggleItem(this)}}">
|
|
63
|
+
${this.getItemContent()}
|
|
64
|
+
</div>
|
|
65
|
+
</div>
|
|
66
|
+
<div class="cruzo-ui-component_empty" style="{{root.items$::rx && root.items$::rx.length ? 'display:none' : ''}}">Нет вариантов</div>
|
|
67
|
+
</div>
|
|
68
|
+
</div>`;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
t(l, "selector", "select-component");
|
|
72
|
+
r.define(l);
|
|
73
|
+
export {
|
|
74
|
+
l as SelectComponent,
|
|
75
|
+
g as SelectConfig
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=select.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select.js","sources":["../../ui-components/select/select.component.ts"],"sourcesContent":["import { AbstractComponent, componentsRegistryService } from \"../../lib\";\n\nexport interface SelectItem {\n label: string;\n value: any;\n}\n\nexport interface SelectConfigParams {\n placeholder: string;\n multi?: boolean;\n getItems: (...args: any[]) => Promise<SelectItem[]>;\n}\n\nexport function SelectConfig(params: SelectConfigParams) {\n return Object.assign({}, params);\n}\n\nexport class SelectComponent extends AbstractComponent<SelectConfigParams, Record<string, boolean>> {\n static selector = \"select-component\";\n hasConfig = true;\n hasOuterScope = true;\n\n open$ = this.newRx(false);\n\n items$ = this.newRx<SelectItem[]>(null);\n\n selectedLabel$ = this.newRx(\"\");\n\n getItems$ = this.newRxFunc(async (val, items) => {\n if (!val || !items?.length) return;\n\n const selectedItems = items.filter((item) => val[item.value]).map((item) => item.label);\n\n if (selectedItems.length) {\n this.selectedLabel$.update(selectedItems.join(', '));\n } else if (this.config) {\n this.selectedLabel$.update(this.config.placeholder);\n }\n }, this.value$, this.items$)\n\n constructor() {\n super();\n this.value$.update({})\n }\n\n connectedCallback() {\n super.connectedCallback();\n document.addEventListener(\"click\", this.handleOutsideClick);\n this.getItems();\n }\n\n async getItems() {\n const items = await this.config.getItems();\n this.items$.update(items);\n }\n\n disconnectedCallback() {\n document.removeEventListener(\"click\", this.handleOutsideClick);\n super.disconnectedCallback();\n }\n\n private handleOutsideClick = (e: MouseEvent) => {\n if (this.node && !this.node.contains(e.target as Node)) {\n this.open$.update(false);\n }\n };\n\n toggle() {\n this.open$.update(!this.open$.actual);\n }\n\n toggleItem(item: SelectItem) {\n const value = this.config.multi \n ? Object.assign({}, this.value) \n : {[item.value]: this.value[item.value]};\n\n value[item.value] = !value[item.value];\n\n this.outerScope.setValue(this.id, value, this.index, true);\n\n if (!this.config.multi) this.open$.update(false);\n }\n\n getItemContent() {\n let checkbox = this.config.multi ? `<label class=\"checkbox\">\n <input\n type=\"checkbox\"\n checked=\"{{root.value$::rx?.[this.value]}}\"\n />\n </label>`: '';\n\n return `${checkbox} <span>{{this.label}}</span>`;\n }\n\n getHTML() {\n return `<div class=\"cruzo-ui-component_select\">\n <button type=\"button\" class=\"cruzo-ui-component_trigger\" onclick=\"{{root.toggle()}}\">\n <span class=\"cruzo-ui-component_value\">{{root.selectedLabel$::rx}}</span>\n <span class=\"cruzo-ui-component_caret {{root.open$::rx ? 'cruzo-ui-component_caret-open' : ''}}\">▴</span>\n </button>\n <div class=\"cruzo-ui-component_dropdown\" style=\"{{root.open$::rx ? '' : 'display:none'}}\">\n <div class=\"cruzo-ui-component_list\" style=\"{{root.items$::rx && root.items$::rx.length ? '' : 'display:none'}}\">\n <div\n repeat=\"{{root.items$::rx}}\"\n class=\"cruzo-ui-component_option {{root.value$::rx?.[this.value] ? 'cruzo-ui-component_option-selected' : ''}}\"\n onclick=\"{{root.toggleItem(this)}}\">\n ${this.getItemContent()}\n </div>\n </div>\n <div class=\"cruzo-ui-component_empty\" style=\"{{root.items$::rx && root.items$::rx.length ? 'display:none' : ''}}\">Нет вариантов</div>\n </div>\n </div>`;\n }\n}\n\ncomponentsRegistryService.define(SelectComponent);\n"],"names":["SelectConfig","params","SelectComponent","AbstractComponent","__publicField","val","items","selectedItems","item","value","componentsRegistryService"],"mappings":";;;;AAaO,SAASA,EAAaC,GAA4B;AACvD,SAAO,OAAO,OAAO,CAAA,GAAIA,CAAM;AACjC;AAEO,MAAMC,UAAwBC,EAA+D;AAAA,EAuBlG,cAAc;AACZ,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AO,QACtB,OAAO,OAAO,CAAA,GAAI,KAAK,KAAK,IAC5B,EAAC,CAACD,EAAK,KAAK,GAAG,KAAK,MAAMA,EAAK,KAAK,EAAA;AAExC,IAAAC,EAAMD,EAAK,KAAK,IAAI,CAACC,EAAMD,EAAK,KAAK,GAErC,KAAK,WAAW,SAAS,KAAK,IAAIC,GAAO,KAAK,OAAO,EAAI,GAEpD,KAAK,OAAO,SAAO,KAAK,MAAM,OAAO,EAAK;AAAA,EACjD;AAAA,EAEA,iBAAiB;AAQf,WAAO,GAPQ,KAAK,OAAO,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA,kBAKtB,EAEK;AAAA,EACpB;AAAA,EAEA,UAAU;AACR,WAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAWK,KAAK,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMnC;AACF;AA/FEL,EADWF,GACJ,YAAW;AAiGpBQ,EAA0B,OAAOR,CAAe;"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { AbstractComponent } from "../../lib";
|
|
2
|
+
export declare enum SpinnerValue {
|
|
3
|
+
"inactive" = "inactive",
|
|
4
|
+
"active" = "active"
|
|
5
|
+
}
|
|
6
|
+
export interface SpinnerConfigParams {
|
|
7
|
+
color?: string;
|
|
8
|
+
size?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function SpinnerConfig(params: SpinnerConfigParams): SpinnerConfigParams;
|
|
11
|
+
export declare class SpinnerComponent extends AbstractComponent<SpinnerConfigParams, SpinnerValue> {
|
|
12
|
+
static selector: string;
|
|
13
|
+
hasConfig: boolean;
|
|
14
|
+
hasOuterScope: boolean;
|
|
15
|
+
isDirective: boolean;
|
|
16
|
+
private contentNode;
|
|
17
|
+
private hostPositionWasPatched;
|
|
18
|
+
private hostPrevPosition;
|
|
19
|
+
getSpinnerStyle(): string;
|
|
20
|
+
getHTML(): string;
|
|
21
|
+
connectedCallback(): void;
|
|
22
|
+
getCls(value: SpinnerValue): string;
|
|
23
|
+
private syncContentFromState;
|
|
24
|
+
private ensureContent;
|
|
25
|
+
private ensureHostPositionForOverlay;
|
|
26
|
+
private destroyContent;
|
|
27
|
+
protected setValue(byUser?: boolean): void;
|
|
28
|
+
disconnectedCallback(): void;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=spinner.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spinner.component.d.ts","sourceRoot":"","sources":["../../../ui-components/spinner/spinner.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAuC,MAAM,WAAW,CAAC;AAEnF,oBAAY,YAAY;IACtB,UAAU,aAAa;IACvB,QAAQ,WAAW;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,mBAAmB,uBAExD;AAMD,qBAAa,gBAAiB,SAAQ,iBAAiB,CAAC,mBAAmB,EAAE,YAAY,CAAC;IACxF,MAAM,CAAC,QAAQ,SAAoB;IACnC,SAAS,UAAQ;IACjB,aAAa,UAAQ;IACrB,WAAW,UAAQ;IAEnB,OAAO,CAAC,WAAW,CAAqB;IACxC,OAAO,CAAC,sBAAsB,CAAS;IACvC,OAAO,CAAC,gBAAgB,CAAM;IAE9B,eAAe,IAAI,MAAM;IAOzB,OAAO;IAUP,iBAAiB;IAKjB,MAAM,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM;IAWnC,OAAO,CAAC,oBAAoB;IAQ5B,OAAO,CAAC,aAAa;IA+BrB,OAAO,CAAC,4BAA4B;IAUpC,OAAO,CAAC,cAAc;IAkBtB,SAAS,CAAC,QAAQ,CAAC,MAAM,UAAQ;IAMjC,oBAAoB;CAIrB"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
.cruzo-ui-component_spinner-wrapper {
|
|
2
|
+
width: 100%;
|
|
3
|
+
height: 100%;
|
|
4
|
+
position: absolute;
|
|
5
|
+
z-index: 99999;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.cruzo-ui-component_spinner {
|
|
9
|
+
display: flex;
|
|
10
|
+
position: absolute;
|
|
11
|
+
left: 0;
|
|
12
|
+
right: 0;
|
|
13
|
+
top: 0;
|
|
14
|
+
bottom: 0;
|
|
15
|
+
margin: auto;
|
|
16
|
+
gap: calc(var(--spinner-size) / 3);
|
|
17
|
+
width: calc(var(--spinner-size) * 4);
|
|
18
|
+
height: var(--spinner-size);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.cruzo-ui-component_spinner-dot {
|
|
22
|
+
width: var(--spinner-size);
|
|
23
|
+
height: var(--spinner-size);
|
|
24
|
+
border-radius: 50%;
|
|
25
|
+
background: var(--spinner-color, var(--accent, currentColor));
|
|
26
|
+
opacity: 0.4;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.cruzo-ui-component--inactive .cruzo-ui-component_spinner-dot {
|
|
30
|
+
display: none;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.cruzo-ui-component--active .cruzo-ui-component_spinner-dot {
|
|
34
|
+
display: block;
|
|
35
|
+
animation: spinnerBounce 0.6s ease-in-out infinite both;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.cruzo-ui-component--active .cruzo-ui-component_spinner-dot-1 {
|
|
39
|
+
animation-delay: 0s;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.cruzo-ui-component--active .cruzo-ui-component_spinner-dot-2 {
|
|
43
|
+
animation-delay: 0.1s;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.cruzo-ui-component--active .cruzo-ui-component_spinner-dot-3 {
|
|
47
|
+
animation-delay: 0.2s;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.cruzo-ui-component--active .cruzo-ui-component_spinner-dot-2,
|
|
51
|
+
.cruzo-ui-component--active .cruzo-ui-component_spinner-dot-3 {
|
|
52
|
+
transform: none;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.cruzo-ui-component--active .cruzo-ui-component_spinner-dot-2 {
|
|
56
|
+
animation-name: spinnerBounce2;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.cruzo-ui-component--active .cruzo-ui-component_spinner-dot-3 {
|
|
60
|
+
animation-name: spinnerBounce3;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@keyframes spinnerBounce {
|
|
64
|
+
|
|
65
|
+
0%,
|
|
66
|
+
80%,
|
|
67
|
+
100% {
|
|
68
|
+
transform: scale(0.6);
|
|
69
|
+
opacity: 0.4;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
40% {
|
|
73
|
+
transform: scale(1);
|
|
74
|
+
opacity: 1;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@keyframes spinnerBounce2 {
|
|
79
|
+
|
|
80
|
+
0%,
|
|
81
|
+
80%,
|
|
82
|
+
100% {
|
|
83
|
+
transform: scale(0.6);
|
|
84
|
+
opacity: 0.4;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
40% {
|
|
88
|
+
transform: scale(1);
|
|
89
|
+
opacity: 1;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
@keyframes spinnerBounce3 {
|
|
94
|
+
|
|
95
|
+
0%,
|
|
96
|
+
80%,
|
|
97
|
+
100% {
|
|
98
|
+
transform: scale(0.6);
|
|
99
|
+
opacity: 0.4;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
40% {
|
|
103
|
+
transform: scale(1);
|
|
104
|
+
opacity: 1;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
var c = Object.defineProperty;
|
|
2
|
+
var r = (e, o, t) => o in e ? c(e, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[o] = t;
|
|
3
|
+
var n = (e, o, t) => r(e, typeof o != "symbol" ? o + "" : o, t);
|
|
4
|
+
import { c as a, A as l, T as d } from "../component-CH-TJ5VF.js";
|
|
5
|
+
var u = /* @__PURE__ */ ((e) => (e.inactive = "inactive", e.active = "active", e))(u || {});
|
|
6
|
+
function m(e) {
|
|
7
|
+
return Object.assign({}, e);
|
|
8
|
+
}
|
|
9
|
+
const h = [
|
|
10
|
+
"inactive"
|
|
11
|
+
/* inactive */
|
|
12
|
+
];
|
|
13
|
+
class s extends l {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
n(this, "hasConfig", !0);
|
|
17
|
+
n(this, "hasOuterScope", !0);
|
|
18
|
+
n(this, "isDirective", !0);
|
|
19
|
+
n(this, "contentNode", null);
|
|
20
|
+
n(this, "hostPositionWasPatched", !1);
|
|
21
|
+
n(this, "hostPrevPosition", "");
|
|
22
|
+
}
|
|
23
|
+
getSpinnerStyle() {
|
|
24
|
+
const t = [];
|
|
25
|
+
return this.config.color && t.push(`--spinner-color:${this.config.color}`), this.config.size && t.push(`--spinner-size:${this.config.size}`), t.join(";");
|
|
26
|
+
}
|
|
27
|
+
getHTML() {
|
|
28
|
+
return `<div let-value="{{root.value$::rx}}"
|
|
29
|
+
class="cruzo-ui-component_spinner {{root.getCls(value)}}"
|
|
30
|
+
style="{{root.getSpinnerStyle()}}">
|
|
31
|
+
<div class="cruzo-ui-component_spinner-dot cruzo-ui-component_spinner-dot-1"></div>
|
|
32
|
+
<div class="cruzo-ui-component_spinner-dot cruzo-ui-component_spinner-dot-2"></div>
|
|
33
|
+
<div class="cruzo-ui-component_spinner-dot cruzo-ui-component_spinner-dot-3"></div>
|
|
34
|
+
</div>`;
|
|
35
|
+
}
|
|
36
|
+
connectedCallback() {
|
|
37
|
+
super.connectedCallback(), this.syncContentFromState();
|
|
38
|
+
}
|
|
39
|
+
getCls(t) {
|
|
40
|
+
switch (t) {
|
|
41
|
+
case "inactive":
|
|
42
|
+
return "cruzo-ui-component--inactive";
|
|
43
|
+
case "active":
|
|
44
|
+
return "cruzo-ui-component--active";
|
|
45
|
+
default:
|
|
46
|
+
return "cruzo-ui-component--inactive";
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
syncContentFromState() {
|
|
50
|
+
h.includes(this.value) || !this.value ? this.destroyContent() : this.ensureContent();
|
|
51
|
+
}
|
|
52
|
+
ensureContent() {
|
|
53
|
+
if (this.contentNode) return;
|
|
54
|
+
this.contentNode = document.createElement("div"), this.contentNode.innerHTML = this.getHTML(), this.contentNode.classList.add("cruzo-ui-component_spinner-wrapper");
|
|
55
|
+
const t = getComputedStyle(this.node), i = t.backgroundImage;
|
|
56
|
+
i.includes("gradient") ? this.contentNode.style.backgroundImage = i : this.contentNode.style.backgroundColor = t.backgroundColor, this.contentNode.style.borderRadius = t.borderRadius, this.ensureHostPositionForOverlay(), this.template = new d({
|
|
57
|
+
node: this.contentNode,
|
|
58
|
+
self: () => this,
|
|
59
|
+
selector: this.selector,
|
|
60
|
+
__tplFile: this.__tplFile
|
|
61
|
+
}), this.template.detectChanges(), this.node.appendChild(this.contentNode);
|
|
62
|
+
}
|
|
63
|
+
ensureHostPositionForOverlay() {
|
|
64
|
+
getComputedStyle(this.node).position === "static" && (this.hostPositionWasPatched = !0, this.hostPrevPosition = this.node.style.position || "", this.node.style.position = "relative");
|
|
65
|
+
}
|
|
66
|
+
destroyContent() {
|
|
67
|
+
this.template && (this.template.fullDestroy(), this.template = null), this.contentNode && (this.contentNode.remove(), this.contentNode = null), this.hostPositionWasPatched && (this.node.style.position = this.hostPrevPosition, this.hostPositionWasPatched = !1, this.hostPrevPosition = "");
|
|
68
|
+
}
|
|
69
|
+
setValue(t = !1) {
|
|
70
|
+
this.value = this.outerScope.getValue(this.id, this.index) ?? "inactive", this.value$.update(this.value), this.syncContentFromState();
|
|
71
|
+
}
|
|
72
|
+
disconnectedCallback() {
|
|
73
|
+
this.destroyContent(), super.disconnectedCallback();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
n(s, "selector", '[is="spinner"]');
|
|
77
|
+
a.define(s);
|
|
78
|
+
export {
|
|
79
|
+
s as SpinnerComponent,
|
|
80
|
+
m as SpinnerConfig,
|
|
81
|
+
u as SpinnerValue
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=spinner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spinner.js","sources":["../../ui-components/spinner/spinner.component.ts"],"sourcesContent":["import { AbstractComponent, componentsRegistryService, Template } from \"../../lib\";\n\nexport enum SpinnerValue {\n \"inactive\" = \"inactive\",\n \"active\" = \"active\",\n}\n\nexport interface SpinnerConfigParams {\n color?: string;\n size?: string;\n}\n\nexport function SpinnerConfig(params: SpinnerConfigParams) {\n return Object.assign({}, params);\n}\n\nconst DESTROY_STATES: SpinnerValue[] = [\n SpinnerValue.inactive,\n];\n\nexport class SpinnerComponent extends AbstractComponent<SpinnerConfigParams, SpinnerValue> {\n static selector = '[is=\"spinner\"]';\n hasConfig = true;\n hasOuterScope = true;\n isDirective = true;\n\n private contentNode: HTMLElement = null;\n private hostPositionWasPatched = false;\n private hostPrevPosition = \"\";\n\n getSpinnerStyle(): string {\n const parts: string[] = [];\n if (this.config.color) parts.push(`--spinner-color:${this.config.color}`);\n if (this.config.size) parts.push(`--spinner-size:${this.config.size}`);\n return parts.join(\";\");\n }\n\n getHTML() {\n return `<div let-value=\"{{root.value$::rx}}\"\n class=\"cruzo-ui-component_spinner {{root.getCls(value)}}\"\n style=\"{{root.getSpinnerStyle()}}\">\n <div class=\"cruzo-ui-component_spinner-dot cruzo-ui-component_spinner-dot-1\"></div>\n <div class=\"cruzo-ui-component_spinner-dot cruzo-ui-component_spinner-dot-2\"></div>\n <div class=\"cruzo-ui-component_spinner-dot cruzo-ui-component_spinner-dot-3\"></div>\n </div>`;\n }\n\n connectedCallback() {\n super.connectedCallback();\n this.syncContentFromState();\n }\n\n getCls(value: SpinnerValue): string {\n switch (value) {\n case SpinnerValue.inactive:\n return \"cruzo-ui-component--inactive\";\n case SpinnerValue.active:\n return \"cruzo-ui-component--active\";\n default:\n return \"cruzo-ui-component--inactive\";\n }\n }\n\n private syncContentFromState() {\n if (DESTROY_STATES.includes(this.value) || !this.value) {\n this.destroyContent();\n } else {\n this.ensureContent();\n }\n }\n\n private ensureContent() {\n if (this.contentNode) return;\n this.contentNode = document.createElement(\"div\");\n this.contentNode.innerHTML = this.getHTML();\n\n this.contentNode.classList.add('cruzo-ui-component_spinner-wrapper');\n\n const styles = getComputedStyle(this.node)\n const bgImage = styles.backgroundImage\n\n if (bgImage.includes('gradient')) {\n this.contentNode.style.backgroundImage = bgImage\n } else {\n this.contentNode.style.backgroundColor = styles.backgroundColor\n }\n\n this.contentNode.style.borderRadius = styles.borderRadius\n\n this.ensureHostPositionForOverlay();\n\n this.template = new Template({\n node: this.contentNode,\n self: () => this,\n selector: this.selector,\n __tplFile: this.__tplFile,\n });\n\n this.template.detectChanges();\n this.node.appendChild(this.contentNode);\n }\n\n private ensureHostPositionForOverlay() {\n const position = getComputedStyle(this.node).position;\n\n if (position !== \"static\") return;\n\n this.hostPositionWasPatched = true;\n this.hostPrevPosition = this.node.style.position || \"\";\n this.node.style.position = \"relative\";\n }\n\n private destroyContent() {\n if (this.template) {\n this.template.fullDestroy();\n this.template = null;\n }\n\n if (this.contentNode) {\n this.contentNode.remove();\n this.contentNode = null;\n }\n\n if (this.hostPositionWasPatched) {\n this.node.style.position = this.hostPrevPosition;\n this.hostPositionWasPatched = false;\n this.hostPrevPosition = \"\";\n }\n }\n\n protected setValue(byUser = false) {\n this.value = this.outerScope.getValue(this.id, this.index) ?? SpinnerValue.inactive;\n this.value$.update(this.value);\n this.syncContentFromState();\n }\n\n disconnectedCallback() {\n this.destroyContent();\n super.disconnectedCallback();\n }\n}\n\ncomponentsRegistryService.define(SpinnerComponent);\n"],"names":["SpinnerValue","SpinnerConfig","params","DESTROY_STATES","SpinnerComponent","AbstractComponent","__publicField","parts","value","styles","bgImage","Template","byUser","componentsRegistryService"],"mappings":";;;;AAEO,IAAKA,sBAAAA,OACVA,EAAA,WAAa,YACbA,EAAA,SAAW,UAFDA,IAAAA,KAAA,CAAA,CAAA;AAUL,SAASC,EAAcC,GAA6B;AACzD,SAAO,OAAO,OAAO,CAAA,GAAIA,CAAM;AACjC;AAEA,MAAMC,IAAiC;AAAA,EACrC;AAAA;AACF;AAEO,MAAMC,UAAyBC,EAAqD;AAAA,EAApF;AAAA;AAEL,IAAAC,EAAA,mBAAY;AACZ,IAAAA,EAAA,uBAAgB;AAChB,IAAAA,EAAA,qBAAc;AAEN,IAAAA,EAAA,qBAA2B;AAC3B,IAAAA,EAAA,gCAAyB;AACzB,IAAAA,EAAA,0BAAmB;AAAA;AAAA,EAE3B,kBAA0B;AACxB,UAAMC,IAAkB,CAAA;AACxB,WAAI,KAAK,OAAO,SAAOA,EAAM,KAAK,mBAAmB,KAAK,OAAO,KAAK,EAAE,GACpE,KAAK,OAAO,QAAMA,EAAM,KAAK,kBAAkB,KAAK,OAAO,IAAI,EAAE,GAC9DA,EAAM,KAAK,GAAG;AAAA,EACvB;AAAA,EAEA,UAAU;AACR,WAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOT;AAAA,EAEA,oBAAoB;AAClB,UAAM,kBAAA,GACN,KAAK,qBAAA;AAAA,EACP;AAAA,EAEA,OAAOC,GAA6B;AAClC,YAAQA,GAAA;AAAA,MACN,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT;AACE,eAAO;AAAA,IAAA;AAAA,EAEb;AAAA,EAEQ,uBAAuB;AAC7B,IAAIL,EAAe,SAAS,KAAK,KAAK,KAAK,CAAC,KAAK,QAC/C,KAAK,eAAA,IAEL,KAAK,cAAA;AAAA,EAET;AAAA,EAEQ,gBAAgB;AACtB,QAAI,KAAK,YAAa;AACtB,SAAK,cAAc,SAAS,cAAc,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OT,CAAgB;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AbstractComponent } from "../../lib";
|
|
2
|
+
interface UploadConfigParams {
|
|
3
|
+
accept: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function UploadConfig(params: UploadConfigParams): UploadConfigParams;
|
|
6
|
+
export declare class UploadComponent extends AbstractComponent<UploadConfigParams> {
|
|
7
|
+
static selector: string;
|
|
8
|
+
hasOuterScope: boolean;
|
|
9
|
+
hasConfig: boolean;
|
|
10
|
+
constructor();
|
|
11
|
+
connectedCallback(): Promise<void>;
|
|
12
|
+
disconnectedCallback(): void;
|
|
13
|
+
getHTML(): string;
|
|
14
|
+
upload: (event: Event) => void;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=upload.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload.component.d.ts","sourceRoot":"","sources":["../../../ui-components/upload/upload.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAA6B,MAAM,WAAW,CAAC;AAEzE,UAAU,kBAAkB;IAC1B,MAAM,EAAE,MAAM,CAAA;CACf;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,kBAAkB,sBAEtD;AAED,qBAAa,eAAgB,SAAQ,iBAAiB,CAAC,kBAAkB,CAAC;IACxE,MAAM,CAAC,QAAQ,SAAsB;IACrC,aAAa,UAAQ;IACrB,SAAS,UAAQ;;IAMX,iBAAiB;IAIvB,oBAAoB,IAAI,IAAI;IAI5B,OAAO;IAIP,MAAM,GAAI,OAAO,KAAK,UAGrB;CACF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
.cruzo-ui-component_upload {
|
|
2
|
+
width: 100%;
|
|
3
|
+
max-width: 320px;
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
border: none;
|
|
6
|
+
background: var(--light, #f5f5f5);
|
|
7
|
+
border-radius: 8px;
|
|
8
|
+
padding: 8px 10px;
|
|
9
|
+
font-size: 14px;
|
|
10
|
+
line-height: 1.5;
|
|
11
|
+
color: var(--dark, #1a1a1a);
|
|
12
|
+
font-family: var(--font, inherit);
|
|
13
|
+
-webkit-font-smoothing: antialiased;
|
|
14
|
+
-moz-osx-font-smoothing: grayscale;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.cruzo-ui-component_upload::file-selector-button {
|
|
18
|
+
border: none;
|
|
19
|
+
border-radius: 6px;
|
|
20
|
+
padding: 8px 12px;
|
|
21
|
+
margin-right: 10px;
|
|
22
|
+
background: var(--brand, #111);
|
|
23
|
+
color: #fff;
|
|
24
|
+
cursor: pointer;
|
|
25
|
+
font-size: 13px;
|
|
26
|
+
font-family: inherit;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.cruzo-ui-component_upload::file-selector-button:hover {
|
|
30
|
+
background: #222;
|
|
31
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
var a = Object.defineProperty;
|
|
2
|
+
var i = (e, t, c) => t in e ? a(e, t, { enumerable: !0, configurable: !0, writable: !0, value: c }) : e[t] = c;
|
|
3
|
+
var n = (e, t, c) => i(e, typeof t != "symbol" ? t + "" : t, c);
|
|
4
|
+
import { c as r, A as l } from "../component-CH-TJ5VF.js";
|
|
5
|
+
function d(e) {
|
|
6
|
+
return Object.assign({}, e);
|
|
7
|
+
}
|
|
8
|
+
class o extends l {
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
n(this, "hasOuterScope", !0);
|
|
12
|
+
n(this, "hasConfig", !0);
|
|
13
|
+
n(this, "upload", (c) => {
|
|
14
|
+
const s = c.target.files;
|
|
15
|
+
this.outerScope.setValue(this.id, s, this.index, !0);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
async connectedCallback() {
|
|
19
|
+
super.connectedCallback();
|
|
20
|
+
}
|
|
21
|
+
disconnectedCallback() {
|
|
22
|
+
super.disconnectedCallback();
|
|
23
|
+
}
|
|
24
|
+
getHTML() {
|
|
25
|
+
return `<input class="cruzo-ui-component_upload" accept="${this.config.accept}" type="file" onchange="{{this.upload(event)}}"/>`;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
n(o, "selector", "upload-component");
|
|
29
|
+
r.define(o);
|
|
30
|
+
export {
|
|
31
|
+
o as UploadComponent,
|
|
32
|
+
d as UploadConfig
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=upload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload.js","sources":["../../ui-components/upload/upload.component.ts"],"sourcesContent":["import { AbstractComponent, componentsRegistryService } from \"../../lib\";\n\ninterface UploadConfigParams {\n accept: string\n}\n\nexport function UploadConfig(params: UploadConfigParams) {\n return Object.assign({}, params);\n}\n\nexport class UploadComponent extends AbstractComponent<UploadConfigParams> {\n static selector = \"upload-component\";\n hasOuterScope = true;\n hasConfig = true;\n\n constructor() {\n super();\n }\n\n async connectedCallback() {\n super.connectedCallback();\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n }\n\n getHTML() {\n return `<input class=\"cruzo-ui-component_upload\" accept=\"${this.config.accept}\" type=\"file\" onchange=\"{{this.upload(event)}}\"/>`\n }\n\n upload = (event: Event) => {\n const files = (event.target as HTMLInputElement).files;\n this.outerScope.setValue(this.id, files, this.index, true);\n }\n}\n\ncomponentsRegistryService.define(UploadComponent);"],"names":["UploadConfig","params","UploadComponent","AbstractComponent","__publicField","event","files","componentsRegistryService"],"mappings":";;;;AAMO,SAASA,EAAaC,GAA4B;AACvD,SAAO,OAAO,OAAO,CAAA,GAAIA,CAAM;AACjC;AAEO,MAAMC,UAAwBC,EAAsC;AAAA,EAKzE,cAAc;AACZ,UAAA;AAJF,IAAAC,EAAA,uBAAgB;AAChB,IAAAA,EAAA,mBAAY;AAkBZ,IAAAA,EAAA,gBAAS,CAACC,MAAiB;AACzB,YAAMC,IAASD,EAAM,OAA4B;AACjD,WAAK,WAAW,SAAS,KAAK,IAAIC,GAAO,KAAK,OAAO,EAAI;AAAA,IAC3D;AAAA,EAjBA;AAAA,EAEA,MAAM,oBAAoB;AACxB,UAAM,kBAAA;AAAA,EACR;AAAA,EAEA,uBAA6B;AAC3B,UAAM,qBAAA;AAAA,EACR;AAAA,EAEA,UAAU;AACR,WAAO,oDAAoD,KAAK,OAAO,MAAM;AAAA,EAC/E;AAMF;AAxBEF,EADWF,GACJ,YAAW;AA0BpBK,EAA0B,OAAOL,CAAe;"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function arrayToHash<I extends Record<PropertyKey, any>, K extends keyof I>(arr: I[], key: K): Record<string, I>;
|
|
2
|
+
export declare function delay(ms: number): Promise<unknown>;
|
|
3
|
+
export declare function debounce<T extends (...args: any[]) => any>(ms: number, cb: T): (this: ThisParameterType<T>, ...args: Parameters<T>) => void;
|
|
4
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../lib/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,EAC/E,GAAG,EAAE,CAAC,EAAE,EACR,GAAG,EAAE,CAAC,GACL,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAInB;AAED,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,oBAM/B;AAED,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EACxD,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,CAAC,IAIW,MAAM,iBAAiB,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,UAAU,CAAC,CAAC,CAAC,UAOnE"}
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
function r(t, e) {
|
|
2
|
+
const n = {};
|
|
3
|
+
for (const o of t) n[o[e]] = o;
|
|
4
|
+
return n;
|
|
5
|
+
}
|
|
6
|
+
function u(t) {
|
|
7
|
+
return new Promise((e) => {
|
|
8
|
+
setTimeout(() => {
|
|
9
|
+
e(!0);
|
|
10
|
+
}, t);
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
function i(t, e) {
|
|
14
|
+
let n;
|
|
15
|
+
return function(...o) {
|
|
16
|
+
clearTimeout(n), n = setTimeout(() => {
|
|
17
|
+
e.apply(this, o);
|
|
18
|
+
}, t);
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
r as arrayToHash,
|
|
23
|
+
i as debounce,
|
|
24
|
+
u as delay
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../lib/utils.ts"],"sourcesContent":["export function arrayToHash<I extends Record<PropertyKey, any>, K extends keyof I>(\n arr: I[],\n key: K\n): Record<string, I> {\n const hash: Record<string, I> = {};\n for (const item of arr) hash[item[key]] = item;\n return hash;\n}\n\nexport function delay(ms: number) {\n return new Promise((resolve) => {\n setTimeout(() => {\n resolve(true);\n }, ms);\n });\n}\n\nexport function debounce<T extends (...args: any[]) => any>(\n ms: number,\n cb: T\n) {\n let tm: any;\n\n return function(this: ThisParameterType<T>, ...args: Parameters<T>) {\n clearTimeout(tm);\n\n tm = setTimeout(() => {\n cb.apply(this, args);\n }, ms);\n };\n}\n"],"names":["arrayToHash","arr","key","hash","item","delay","ms","resolve","debounce","cb","tm","args"],"mappings":"AAAO,SAASA,EACdC,GACAC,GACmB;AACnB,QAAMC,IAA0B,CAAA;AAChC,aAAWC,KAAQH,EAAK,CAAAE,EAAKC,EAAKF,CAAG,CAAC,IAAIE;AAC1C,SAAOD;AACT;AAEO,SAASE,EAAMC,GAAY;AAChC,SAAO,IAAI,QAAQ,CAACC,MAAY;AAC9B,eAAW,MAAM;AACf,MAAAA,EAAQ,EAAI;AAAA,IACd,GAAGD,CAAE;AAAA,EACP,CAAC;AACH;AAEO,SAASE,EACdF,GACAG,GACA;AACA,MAAIC;AAEJ,SAAO,YAAwCC,GAAqB;AAClE,iBAAaD,CAAE,GAEfA,IAAK,WAAW,MAAM;AACpB,MAAAD,EAAG,MAAM,MAAME,CAAI;AAAA,IACrB,GAAGL,CAAE;AAAA,EACP;AACF;"}
|
package/dist/vm.d.ts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
export type Tok = {
|
|
2
|
+
t: "num";
|
|
3
|
+
v: number;
|
|
4
|
+
} | {
|
|
5
|
+
t: "str";
|
|
6
|
+
v: string;
|
|
7
|
+
} | {
|
|
8
|
+
t: "id";
|
|
9
|
+
v: string;
|
|
10
|
+
} | {
|
|
11
|
+
t: "op";
|
|
12
|
+
v: string;
|
|
13
|
+
} | {
|
|
14
|
+
t: "punc";
|
|
15
|
+
v: string;
|
|
16
|
+
} | {
|
|
17
|
+
t: "eof";
|
|
18
|
+
};
|
|
19
|
+
export declare function tokenizeExpr(input: string): Tok[];
|
|
20
|
+
export declare enum OP {
|
|
21
|
+
PUSH_CONST = 1,
|
|
22
|
+
LOAD_ID = 2,
|
|
23
|
+
LOAD_THIS = 3,
|
|
24
|
+
GET_PROP = 4,
|
|
25
|
+
GET_PROP_KEEP = 5,
|
|
26
|
+
GET_INDEX = 6,
|
|
27
|
+
GET_INDEX_KEEP = 7,
|
|
28
|
+
POP = 8,
|
|
29
|
+
POP_BELOW = 9,
|
|
30
|
+
UNARY_NOT = 10,
|
|
31
|
+
UNARY_POS = 11,
|
|
32
|
+
UNARY_NEG = 12,
|
|
33
|
+
BIN_ADD = 13,
|
|
34
|
+
BIN_SUB = 14,
|
|
35
|
+
BIN_MUL = 15,
|
|
36
|
+
BIN_DIV = 16,
|
|
37
|
+
BIN_MOD = 17,
|
|
38
|
+
BIN_EQ = 18,
|
|
39
|
+
BIN_NEQ = 19,
|
|
40
|
+
BIN_SEQ = 20,
|
|
41
|
+
BIN_SNEQ = 21,
|
|
42
|
+
BIN_LT = 22,
|
|
43
|
+
BIN_LTE = 23,
|
|
44
|
+
BIN_GT = 24,
|
|
45
|
+
BIN_GTE = 25,
|
|
46
|
+
CALL_FN = 26,
|
|
47
|
+
CALL_METHOD = 27,
|
|
48
|
+
RX_UI = 28,
|
|
49
|
+
JMP = 29,
|
|
50
|
+
JMP_IF_FALSE = 30,
|
|
51
|
+
JMP_IF_FALSE_KEEP = 31,
|
|
52
|
+
JMP_IF_TRUE_KEEP = 32,
|
|
53
|
+
JMP_IF_NULLISH = 33,
|
|
54
|
+
MAKE_ARRAY = 34,
|
|
55
|
+
MAKE_OBJECT = 35,
|
|
56
|
+
ONCE_ENTER = 36,
|
|
57
|
+
ONCE_STORE = 37
|
|
58
|
+
}
|
|
59
|
+
export declare class Bytecode {
|
|
60
|
+
private code;
|
|
61
|
+
private consts;
|
|
62
|
+
private idNames;
|
|
63
|
+
private exprCount;
|
|
64
|
+
private onceCount;
|
|
65
|
+
expr: string;
|
|
66
|
+
constructor(code: Uint32Array, consts: any[], idNames: string[], exprCount: number, onceCount: number, expr: string);
|
|
67
|
+
onlyOnce(): boolean;
|
|
68
|
+
fmtArg(op: OP, a: number, wide?: number): string[];
|
|
69
|
+
log(): void;
|
|
70
|
+
noRunNeeded(template: any): any;
|
|
71
|
+
setOnceSlotValue(template: any, slot: number, slotValue: any): void;
|
|
72
|
+
getOnceSlotValue(template: any, slot: number): any;
|
|
73
|
+
getSafeErrorMsg(obj: any, prop: string): string;
|
|
74
|
+
run(template: any, ctx: number, linkIndex: number, app: any, allowRxLink: boolean, event: Event): any;
|
|
75
|
+
}
|
|
76
|
+
export declare class VMProgramCompiler {
|
|
77
|
+
private tokens;
|
|
78
|
+
private pos;
|
|
79
|
+
private code;
|
|
80
|
+
private consts;
|
|
81
|
+
private constMap;
|
|
82
|
+
private idNames;
|
|
83
|
+
private idMap;
|
|
84
|
+
private onceSlot;
|
|
85
|
+
private exprDepth;
|
|
86
|
+
private exprCount;
|
|
87
|
+
constructor(tokens: Tok[]);
|
|
88
|
+
private withNestedExpr;
|
|
89
|
+
private allocOnceSlot;
|
|
90
|
+
private peek;
|
|
91
|
+
private next;
|
|
92
|
+
private expectPunc;
|
|
93
|
+
private expectOp;
|
|
94
|
+
private c;
|
|
95
|
+
private id;
|
|
96
|
+
private emit;
|
|
97
|
+
private emitJump;
|
|
98
|
+
private patch;
|
|
99
|
+
private canCount;
|
|
100
|
+
private parseBinaryCounted;
|
|
101
|
+
private parseShortCircuit;
|
|
102
|
+
private parseNullishChain;
|
|
103
|
+
getBytecode(expr: string): Bytecode;
|
|
104
|
+
private parseExpression;
|
|
105
|
+
private parseTernary;
|
|
106
|
+
private parseNullish;
|
|
107
|
+
private parseOr;
|
|
108
|
+
private parseAnd;
|
|
109
|
+
private parseEq;
|
|
110
|
+
private parseRel;
|
|
111
|
+
private parseAdd;
|
|
112
|
+
private parseMul;
|
|
113
|
+
private parseUnary;
|
|
114
|
+
private parsePostfix;
|
|
115
|
+
private parseArgsAndCount;
|
|
116
|
+
private parsePrimary;
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=vm.d.ts.map
|
package/dist/vm.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vm.d.ts","sourceRoot":"","sources":["../lib/vm.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG,GACX;IAAE,CAAC,EAAE,KAAK,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GACvB;IAAE,CAAC,EAAE,KAAK,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GACvB;IAAE,CAAC,EAAE,IAAI,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GACtB;IAAE,CAAC,EAAE,IAAI,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GACtB;IAAE,CAAC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