@platforma-sdk/ui-vue 1.41.11 → 1.41.17
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/.turbo/turbo-build.log +8 -8
- package/.turbo/turbo-type-check.log +1 -1
- package/CHANGELOG.md +13 -0
- package/dist/internal/createAppV2.d.ts +1 -7
- package/dist/internal/createAppV2.d.ts.map +1 -1
- package/dist/internal/createAppV2.js +66 -64
- package/dist/internal/createAppV2.js.map +1 -1
- package/dist/lib/ui/uikit/dist/components/DataTable/TableComponent.vue.js +1 -1
- package/dist/lib/ui/uikit/dist/components/PlFileInput/PlFileInput.vue.js +11 -11
- package/dist/lib/ui/uikit/dist/components/PlFileInput/PlFileInput.vue.js.map +1 -1
- package/dist/lib/ui/uikit/dist/components/PlSlideModal/PlPureSlideModal.vue.js +1 -1
- package/package.json +4 -4
- package/src/internal/createAppV2.ts +52 -36
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
WARN Issue while reading "/home/runner/_work/platforma/platforma/.npmrc". Failed to replace env in config: ${NPMJS_TOKEN}
|
|
2
2
|
|
|
3
|
-
> @platforma-sdk/ui-vue@1.41.
|
|
3
|
+
> @platforma-sdk/ui-vue@1.41.17 build /home/runner/_work/platforma/platforma/sdk/ui-vue
|
|
4
4
|
> vite build
|
|
5
5
|
|
|
6
6
|
[36mvite v6.3.5 [32mbuilding for production...[36m[39m
|
|
@@ -10,7 +10,7 @@ rendering chunks...
|
|
|
10
10
|
|
|
11
11
|
[vite:dts] Start generate declaration files...
|
|
12
12
|
computing gzip size...
|
|
13
|
-
[vite:dts] Declaration files built in
|
|
13
|
+
[vite:dts] Declaration files built in 5282ms.
|
|
14
14
|
|
|
15
15
|
[2mdist/[22m[36m_virtual/re.js [39m[1m[2m 0.08 kB[22m[1m[22m[2m │ gzip: 0.10 kB[22m[2m │ map: 0.09 kB[22m
|
|
16
16
|
[2mdist/[22m[36mlib/ui/uikit/dist/node_modules/.pnpm/d3-interpolate@3.0.1/node_modules/d3-interpolate/src/constant.js [39m[1m[2m 0.09 kB[22m[1m[22m[2m │ gzip: 0.10 kB[22m[2m │ map: 0.32 kB[22m
|
|
@@ -44,8 +44,8 @@ computing gzip size...
|
|
|
44
44
|
[2mdist/[22m[36mlib/ui/uikit/dist/node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/constant.js [39m[1m[2m 0.12 kB[22m[1m[22m[2m │ gzip: 0.12 kB[22m[2m │ map: 0.40 kB[22m
|
|
45
45
|
[2mdist/[22m[36mlib/ui/uikit/dist/node_modules/.pnpm/d3-scale@4.0.2/node_modules/d3-scale/src/constant.js [39m[1m[2m 0.12 kB[22m[1m[22m[2m │ gzip: 0.12 kB[22m[2m │ map: 0.40 kB[22m
|
|
46
46
|
[2mdist/[22m[36mcomponents/PlAgDataTable/PlAgOverlayLoading.vue2.js [39m[1m[2m 0.12 kB[22m[1m[22m[2m │ gzip: 0.12 kB[22m[2m │ map: 0.11 kB[22m
|
|
47
|
-
[2mdist/[22m[36mcomponents/PlAgRowNumCheckbox/PlAgRowNumCheckbox.vue2.js [39m[1m[2m 0.12 kB[22m[1m[22m[2m │ gzip: 0.12 kB[22m[2m │ map: 0.11 kB[22m
|
|
48
47
|
[2mdist/[22m[36mcomponents/PlTableFilters/PlTableAddFilterV2.vue2.js [39m[1m[2m 0.12 kB[22m[1m[22m[2m │ gzip: 0.12 kB[22m[2m │ map: 0.11 kB[22m
|
|
48
|
+
[2mdist/[22m[36mcomponents/PlAgRowNumCheckbox/PlAgRowNumCheckbox.vue2.js [39m[1m[2m 0.12 kB[22m[1m[22m[2m │ gzip: 0.12 kB[22m[2m │ map: 0.11 kB[22m
|
|
49
49
|
[2mdist/[22m[36mplugins/Monetization/MonetizationSidebar.vue2.js [39m[1m[2m 0.13 kB[22m[1m[22m[2m │ gzip: 0.12 kB[22m[2m │ map: 0.11 kB[22m
|
|
50
50
|
[2mdist/[22m[36mcomponents/PlTableFilters/PlTableFilterEntryV2.vue2.js [39m[1m[2m 0.13 kB[22m[1m[22m[2m │ gzip: 0.12 kB[22m[2m │ map: 0.11 kB[22m
|
|
51
51
|
[2mdist/[22m[36mcomponents/PlAgGridColumnManager/PlAgGridColumnManager.vue2.js [39m[1m[2m 0.13 kB[22m[1m[22m[2m │ gzip: 0.12 kB[22m[2m │ map: 0.11 kB[22m
|
|
@@ -861,7 +861,7 @@ computing gzip size...
|
|
|
861
861
|
[2mdist/[22m[36minternal/createAppV1.js [39m[1m[2m 5.80 kB[22m[1m[22m[2m │ gzip: 1.89 kB[22m[2m │ map: 15.32 kB[22m
|
|
862
862
|
[2mdist/[22m[36mlib/ui/uikit/dist/components/PlDialogModal/PlDialogModal.vue.js [39m[1m[2m 5.80 kB[22m[1m[22m[2m │ gzip: 2.01 kB[22m[2m │ map: 5.33 kB[22m
|
|
863
863
|
[2mdist/[22m[36mlib/ui/uikit/dist/components/PlSidebar/PlSidebarItem.vue3.js [39m[1m[2m 5.87 kB[22m[1m[22m[2m │ gzip: 1.77 kB[22m[2m │ map: 0.12 kB[22m
|
|
864
|
-
[2mdist/[22m[36minternal/createAppV2.js [39m[1m[2m 6.
|
|
864
|
+
[2mdist/[22m[36minternal/createAppV2.js [39m[1m[2m 6.49 kB[22m[1m[22m[2m │ gzip: 2.29 kB[22m[2m │ map: 18.40 kB[22m
|
|
865
865
|
[2mdist/[22m[36mlib/ui/uikit/dist/components/PlLogView/PlLogView.vue.js [39m[1m[2m 6.50 kB[22m[1m[22m[2m │ gzip: 2.32 kB[22m[2m │ map: 5.68 kB[22m
|
|
866
866
|
[2mdist/[22m[36mcomponents/PlTableFilters/PlTableFiltersV2.vue2.js [39m[1m[2m 6.57 kB[22m[1m[22m[2m │ gzip: 2.06 kB[22m[2m │ map: 9.28 kB[22m
|
|
867
867
|
[2mdist/[22m[36mnode_modules/.pnpm/semver@7.7.2/node_modules/semver/classes/semver.js [39m[1m[2m 6.70 kB[22m[1m[22m[2m │ gzip: 1.86 kB[22m[2m │ map: 15.20 kB[22m
|
|
@@ -885,7 +885,7 @@ computing gzip size...
|
|
|
885
885
|
[2mdist/[22m[36mlib/ui/uikit/dist/node_modules/.pnpm/d3-color@3.1.0/node_modules/d3-color/src/color.js [39m[1m[2m 9.19 kB[22m[1m[22m[2m │ gzip: 3.33 kB[22m[2m │ map: 22.02 kB[22m
|
|
886
886
|
[2mdist/[22m[36mcomponents/PlTableFilters/filters_logic.js [39m[1m[2m 9.69 kB[22m[1m[22m[2m │ gzip: 2.25 kB[22m[2m │ map: 20.32 kB[22m
|
|
887
887
|
[2mdist/[22m[36mlib/ui/uikit/dist/components/PlNumberField/PlNumberField.vue.js [39m[1m[2m 10.42 kB[22m[1m[22m[2m │ gzip: 3.33 kB[22m[2m │ map: 13.57 kB[22m
|
|
888
|
-
[2mdist/[22m[36mlib/ui/uikit/dist/components/PlFileInput/PlFileInput.vue.js [39m[1m[2m 10.
|
|
888
|
+
[2mdist/[22m[36mlib/ui/uikit/dist/components/PlFileInput/PlFileInput.vue.js [39m[1m[2m 10.78 kB[22m[1m[22m[2m │ gzip: 3.38 kB[22m[2m │ map: 8.09 kB[22m
|
|
889
889
|
[2mdist/[22m[36mlib/ui/uikit/dist/demo-site-data/all-css-variables.js [39m[1m[2m 11.00 kB[22m[1m[22m[2m │ gzip: 1.76 kB[22m[2m │ map: 18.24 kB[22m
|
|
890
890
|
[2mdist/[22m[36mlib/ui/uikit/dist/components/PlDropdownLine/PlDropdownLine.vue.js [39m[1m[2m 14.70 kB[22m[1m[22m[2m │ gzip: 3.91 kB[22m[2m │ map: 12.75 kB[22m
|
|
891
891
|
[2mdist/[22m[36mlib/ui/uikit/dist/lib/model/common/dist/index.js [39m[1m[2m 15.38 kB[22m[1m[22m[2m │ gzip: 4.26 kB[22m[2m │ map: 89.29 kB[22m
|
|
@@ -911,6 +911,6 @@ computing gzip size...
|
|
|
911
911
|
[2mdist/[22m[36mlib/ui/uikit/dist/node_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/index.js [39m[1m[2m 83.80 kB[22m[1m[22m[2m │ gzip: 17.23 kB[22m[2m │ map: 240.83 kB[22m
|
|
912
912
|
[2mdist/[22m[36mnode_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/index.js [39m[1m[2m 83.81 kB[22m[1m[22m[2m │ gzip: 17.26 kB[22m[2m │ map: 241.15 kB[22m
|
|
913
913
|
[2mdist/[22m[36mlib/ui/uikit/dist/index.js [39m[1m[2m497.97 kB[22m[1m[22m[2m │ gzip: 191.79 kB[22m[2m │ map: 0.19 kB[22m
|
|
914
|
-
[2mdist/[22m[36mlib/ui/uikit/dist/components/PlSlideModal/PlPureSlideModal.vue.js [39m[1m[33m601.
|
|
915
|
-
[2mdist/[22m[36mlib/ui/uikit/dist/components/DataTable/TableComponent.vue.js [39m[1m[33m603.
|
|
916
|
-
[32m✓ built in 9.
|
|
914
|
+
[2mdist/[22m[36mlib/ui/uikit/dist/components/PlSlideModal/PlPureSlideModal.vue.js [39m[1m[33m601.22 kB[39m[22m[2m │ gzip: 204.76 kB[22m[2m │ map: 0.22 kB[22m
|
|
915
|
+
[2mdist/[22m[36mlib/ui/uikit/dist/components/DataTable/TableComponent.vue.js [39m[1m[33m603.11 kB[39m[22m[2m │ gzip: 205.62 kB[22m[2m │ map: 0.28 kB[22m
|
|
916
|
+
[32m✓ built in 9.48s[39m
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
WARN Issue while reading "/home/runner/_work/platforma/platforma/.npmrc". Failed to replace env in config: ${NPMJS_TOKEN}
|
|
2
2
|
|
|
3
|
-
> @platforma-sdk/ui-vue@1.41.
|
|
3
|
+
> @platforma-sdk/ui-vue@1.41.17 type-check /home/runner/_work/platforma/platforma/sdk/ui-vue
|
|
4
4
|
> vue-tsc --noEmit --project ./tsconfig.json
|
|
5
5
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @platforma-sdk/ui-vue
|
|
2
2
|
|
|
3
|
+
## 1.41.17
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [093dbda]
|
|
8
|
+
- @milaboratories/uikit@2.3.22
|
|
9
|
+
|
|
10
|
+
## 1.41.13
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- d29cbad: Simplify app model for v2 api
|
|
15
|
+
|
|
3
16
|
## 1.41.11
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -18,19 +18,13 @@ export declare const createNextAuthorMarker: (marker: AuthorMarker | undefined)
|
|
|
18
18
|
* @returns A reactive application object with methods, getters, and state.
|
|
19
19
|
*/
|
|
20
20
|
export declare function createAppV2<Args = unknown, Outputs extends BlockOutputsBase = BlockOutputsBase, UiState = unknown, Href extends `/${string}` = `/${string}`>(state: ValueWithUTag<BlockState<Args, Outputs, UiState, Href>>, platforma: PlatformaV2<Args, Outputs, UiState, Href>, settings: AppSettings): {
|
|
21
|
+
error: string;
|
|
21
22
|
model: {
|
|
22
23
|
args: import('vue').UnwrapRef<Args>;
|
|
23
24
|
ui: import('vue').UnwrapRef<UiState>;
|
|
24
25
|
outputs: import('vue').UnwrapRef<OutputValues<Outputs>>;
|
|
25
26
|
outputErrors: import('vue').UnwrapRef<OutputErrors<Outputs>>;
|
|
26
27
|
};
|
|
27
|
-
readonly valid: boolean;
|
|
28
|
-
readonly isChanged: boolean;
|
|
29
|
-
readonly error: Error | undefined;
|
|
30
|
-
readonly errorString: string | undefined;
|
|
31
|
-
readonly save: () => void;
|
|
32
|
-
readonly revert: () => void;
|
|
33
|
-
readonly setError: (cause: unknown) => void;
|
|
34
28
|
cloneArgs: () => Args;
|
|
35
29
|
cloneUiState: () => UiState;
|
|
36
30
|
cloneNavigationState: () => Mutable<NavigationState<Href>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createAppV2.d.ts","sourceRoot":"","sources":["../../src/internal/createAppV2.ts"],"names":[],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,CAAC,IAAI,CAAC,CAAC;sBAM5F,CAAC,SAAS,IAAI,mBAAkB,iBAAiB,CAAC,IAAI,EAAE,CAAC,CAAC;oBAmB5D,CAAC,SAAS,OAAO,qBAAqB,iBAAiB,CAAC,OAAO,EAAE,CAAC,CAAC,8BAAuB,MAAM,OAAO;oBAwBvG,CAAC,SAAS,MAAM,OAAO,WAAW,CAAC,EAAE,KAAG,aAAa,CAAC,OAAO,EAAE,CAAC,CAAC;qBAWhE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,KAAG,OAAO,CAAC,OAAO,CAAC;wBAcpC,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,KAAG,OAAO,CAAC,OAAO,CAAC;uBAY9C,IAAI;;;;cAlNf,IAAI;iBACD,OAAO,CAAC,OAAO,CAAC;YACrB,OAAO;yBACM,eAAe,CAAC,IAAI,CAAC;;;;;EAmOzC;AAED,MAAM,MAAM,SAAS,CACnB,IAAI,GAAG,OAAO,EACd,OAAO,SAAS,gBAAgB,GAAG,gBAAgB,EACnD,OAAO,GAAG,OAAO,EACjB,IAAI,SAAS,IAAI,MAAM,EAAE,GAAG,IAAI,MAAM,EAAE,IACtC,UAAU,CAAC,OAAO,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC"}
|
|
@@ -1,73 +1,75 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { deepClone as l, uniqueId as V, delay as L } from "../lib/util/helpers/dist/index.js";
|
|
2
2
|
import "../sdk/model/dist/index.js";
|
|
3
|
-
import { ref as A, computed as
|
|
3
|
+
import { ref as A, computed as p, reactive as B, watch as W } from "vue";
|
|
4
4
|
import { createModel as N } from "../createModel.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { MultiError as F, unwrapValueOrErrors as G } from "../utils.js";
|
|
5
|
+
import { parseQuery as F } from "../urls.js";
|
|
6
|
+
import { MultiError as G, unwrapValueOrErrors as H } from "../utils.js";
|
|
8
7
|
import "../node_modules/.pnpm/fast-json-patch@3.1.1/node_modules/fast-json-patch/index.js";
|
|
9
|
-
import { UpdateSerializer as
|
|
10
|
-
import { unwrapResult as
|
|
8
|
+
import { UpdateSerializer as m } from "./UpdateSerializer.js";
|
|
9
|
+
import { unwrapResult as c, hasAbortError as K } from "../lib/model/common/dist/index.js";
|
|
11
10
|
import { applyPatch as O } from "../node_modules/.pnpm/fast-json-patch@3.1.1/node_modules/fast-json-patch/module/core.js";
|
|
12
|
-
const
|
|
13
|
-
authorId: (n == null ? void 0 : n.authorId) ??
|
|
11
|
+
const Q = 100, X = (n) => ({
|
|
12
|
+
authorId: (n == null ? void 0 : n.authorId) ?? V(),
|
|
14
13
|
localVersion: ((n == null ? void 0 : n.localVersion) ?? 0) + 1
|
|
15
14
|
});
|
|
16
|
-
function
|
|
15
|
+
function se(n, d, h) {
|
|
17
16
|
const r = (e, ...t) => {
|
|
18
|
-
|
|
17
|
+
h.debug && console.log(`%c>>> %c${e}`, "color: orange; font-weight: bold", "color: orange", h.appId, ...t);
|
|
19
18
|
}, b = (e, ...t) => {
|
|
20
|
-
console.error(`%c>>> %c${e}`, "color: red; font-weight: bold", "color: red",
|
|
19
|
+
console.error(`%c>>> %c${e}`, "color: red; font-weight: bold", "color: red", h.appId, ...t);
|
|
21
20
|
}, u = {
|
|
22
21
|
isExternalSnapshot: !1,
|
|
23
22
|
author: {
|
|
24
|
-
authorId:
|
|
23
|
+
authorId: V(),
|
|
25
24
|
localVersion: 0
|
|
26
25
|
}
|
|
27
|
-
}, S = () => (u.author =
|
|
26
|
+
}, S = () => (u.author = X(u.author), r("nextAuthorMarker", u.author), u.author), g = A(!1), f = A(n.uTag), v = h.debounceSpan ?? 200, y = new m({ debounceSpan: v }), M = new m({ debounceSpan: v }), U = new m({ debounceSpan: v }), R = new m({ debounceSpan: v }), o = A(n.value), T = async (e) => d.setBlockArgs(e, S()), x = async (e) => d.setBlockUiState(e, S()), k = async (e, t) => d.setBlockArgsAndUiState(e, t, S()), q = async (e) => d.setNavigationState(e), C = p(() => {
|
|
27
|
+
const e = Object.entries(o.value.outputs).map(([t, a]) => [t, a.ok && a.value !== void 0 ? a.value : void 0]);
|
|
28
|
+
return Object.fromEntries(e);
|
|
29
|
+
}), D = p(() => {
|
|
30
|
+
const e = Object.entries(o.value.outputs).map(([t, a]) => [t, a && !a.ok ? new G(a.errors) : void 0]);
|
|
31
|
+
return Object.fromEntries(e);
|
|
32
|
+
}), s = B({
|
|
33
|
+
error: "",
|
|
34
|
+
model: {
|
|
35
|
+
args: l(o.value.args),
|
|
36
|
+
ui: l(o.value.ui),
|
|
37
|
+
outputs: C,
|
|
38
|
+
outputErrors: D
|
|
39
|
+
}
|
|
40
|
+
}), E = W(
|
|
41
|
+
() => s.model,
|
|
42
|
+
(e) => {
|
|
43
|
+
const t = l(e);
|
|
44
|
+
r("appModel.model", t), U.run(() => k(t.args, t.ui).then(c));
|
|
45
|
+
},
|
|
46
|
+
{ deep: !0 }
|
|
47
|
+
), $ = (e) => {
|
|
48
|
+
r("updateAppModelSilently", e), E.pause(), s.model.args = l(e.args), s.model.ui = l(e.ui), E.resume();
|
|
49
|
+
};
|
|
28
50
|
(async () => {
|
|
29
51
|
var e, t;
|
|
30
52
|
for (window.addEventListener("beforeunload", () => {
|
|
31
|
-
|
|
53
|
+
g.value = !0, d.dispose().then(c).catch((a) => {
|
|
32
54
|
b("error in dispose", a);
|
|
33
55
|
});
|
|
34
|
-
}); !
|
|
56
|
+
}); !g.value; )
|
|
35
57
|
try {
|
|
36
|
-
const a = await
|
|
37
|
-
if (r("patches",
|
|
38
|
-
await new Promise((
|
|
58
|
+
const a = await d.getPatches(f.value).then(c);
|
|
59
|
+
if (r("patches.length", a.value.length), r("uTagRef.value", f.value), r("patches.uTag", a.uTag), r("patches.author", a.author), r("data.author", u.author), f.value = a.uTag, a.value.length === 0) {
|
|
60
|
+
await new Promise((w) => setTimeout(w, Q));
|
|
39
61
|
continue;
|
|
40
62
|
}
|
|
41
|
-
const
|
|
42
|
-
|
|
63
|
+
const i = ((e = u.author) == null ? void 0 : e.authorId) !== ((t = a.author) == null ? void 0 : t.authorId);
|
|
64
|
+
i || u.isExternalSnapshot ? (r("got external changes, applying them to the snapshot", JSON.stringify(o.value, null, 2)), o.value = O(o.value, a.value, !1, !1).newDocument, $(o.value), u.isExternalSnapshot = i) : o.value = O(o.value, a.value).newDocument, await new Promise((w) => setTimeout(w, Q));
|
|
43
65
|
} catch (a) {
|
|
44
|
-
|
|
66
|
+
K(a) ? (r("patches loop aborted"), g.value = !0) : (b("error in patches loop", a), await new Promise((i) => setTimeout(i, 1e3)));
|
|
45
67
|
}
|
|
46
68
|
})();
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const e = Object.entries(o.value.outputs).map(([t, a]) => [t, a && !a.ok ? new F(a.errors) : void 0]);
|
|
52
|
-
return Object.fromEntries(e);
|
|
53
|
-
}), i = D(
|
|
54
|
-
{
|
|
55
|
-
get() {
|
|
56
|
-
return { args: o.value.args, ui: o.value.ui };
|
|
57
|
-
},
|
|
58
|
-
autoSave: !0,
|
|
59
|
-
onSave(e) {
|
|
60
|
-
r("onSave", e), M.run(() => V(e.args, e.ui).then(s));
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
outputs: k,
|
|
65
|
-
outputErrors: q
|
|
66
|
-
}
|
|
67
|
-
), E = () => w(i.model.args), I = () => w(i.model.ui), j = () => w(o.value.navigationState), C = {
|
|
68
|
-
cloneArgs: E,
|
|
69
|
-
cloneUiState: I,
|
|
70
|
-
cloneNavigationState: j,
|
|
69
|
+
const I = () => l(s.model.args), j = () => l(s.model.ui), P = () => l(o.value.navigationState), z = {
|
|
70
|
+
cloneArgs: I,
|
|
71
|
+
cloneUiState: j,
|
|
72
|
+
cloneNavigationState: P,
|
|
71
73
|
createArgsModel(e = {}) {
|
|
72
74
|
return N({
|
|
73
75
|
get() {
|
|
@@ -76,7 +78,7 @@ function ue(n, c, d) {
|
|
|
76
78
|
validate: e.validate,
|
|
77
79
|
autoSave: !0,
|
|
78
80
|
onSave(t) {
|
|
79
|
-
y.run(() => T(t).then(
|
|
81
|
+
y.run(() => T(t).then(c));
|
|
80
82
|
}
|
|
81
83
|
});
|
|
82
84
|
},
|
|
@@ -91,7 +93,7 @@ function ue(n, c, d) {
|
|
|
91
93
|
validate: e.validate,
|
|
92
94
|
autoSave: !0,
|
|
93
95
|
onSave(a) {
|
|
94
|
-
|
|
96
|
+
M.run(() => x(a).then(c));
|
|
95
97
|
}
|
|
96
98
|
});
|
|
97
99
|
},
|
|
@@ -104,7 +106,7 @@ function ue(n, c, d) {
|
|
|
104
106
|
* @returns An object with unwrapped output values.
|
|
105
107
|
*/
|
|
106
108
|
unwrapOutputs(...e) {
|
|
107
|
-
const t = o.value.outputs, a = e.map((
|
|
109
|
+
const t = o.value.outputs, a = e.map((i) => [i, H(t[i])]);
|
|
108
110
|
return Object.fromEntries(a);
|
|
109
111
|
},
|
|
110
112
|
/**
|
|
@@ -114,8 +116,8 @@ function ue(n, c, d) {
|
|
|
114
116
|
* @returns A promise resolving after the update is applied.
|
|
115
117
|
*/
|
|
116
118
|
updateArgs(e) {
|
|
117
|
-
const t =
|
|
118
|
-
return e(t), r("updateArgs", t),
|
|
119
|
+
const t = I();
|
|
120
|
+
return e(t), r("updateArgs", t), s.model.args = t, y.run(() => T(t).then(c));
|
|
119
121
|
},
|
|
120
122
|
/**
|
|
121
123
|
* Updates the UI state by applying a callback.
|
|
@@ -125,8 +127,8 @@ function ue(n, c, d) {
|
|
|
125
127
|
* @todo Make it mutable since there is already an initial one
|
|
126
128
|
*/
|
|
127
129
|
updateUiState(e) {
|
|
128
|
-
const t = e(
|
|
129
|
-
return r("updateUiState", t),
|
|
130
|
+
const t = e(j());
|
|
131
|
+
return r("updateUiState", t), s.model.ui = t, M.run(() => x(t).then(c));
|
|
130
132
|
},
|
|
131
133
|
/**
|
|
132
134
|
* Navigates to a specific href by updating the navigation state.
|
|
@@ -135,24 +137,24 @@ function ue(n, c, d) {
|
|
|
135
137
|
* @returns A promise resolving after the navigation state is updated.
|
|
136
138
|
*/
|
|
137
139
|
navigateTo(e) {
|
|
138
|
-
const t =
|
|
139
|
-
return t.href = e,
|
|
140
|
+
const t = P();
|
|
141
|
+
return t.href = e, R.run(() => q(t).then(c));
|
|
140
142
|
},
|
|
141
143
|
async allSettled() {
|
|
142
|
-
return await
|
|
144
|
+
return await L(0), U.allSettled();
|
|
143
145
|
}
|
|
144
146
|
}, J = {
|
|
145
|
-
closedRef:
|
|
147
|
+
closedRef: g,
|
|
146
148
|
snapshot: o,
|
|
147
|
-
queryParams:
|
|
148
|
-
href:
|
|
149
|
-
hasErrors:
|
|
149
|
+
queryParams: p(() => F(o.value.navigationState.href)),
|
|
150
|
+
href: p(() => o.value.navigationState.href),
|
|
151
|
+
hasErrors: p(() => Object.values(o.value.outputs).some((e) => !(e != null && e.ok)))
|
|
150
152
|
};
|
|
151
|
-
return
|
|
153
|
+
return B(Object.assign(s, z, J));
|
|
152
154
|
}
|
|
153
155
|
export {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
156
|
+
se as createAppV2,
|
|
157
|
+
X as createNextAuthorMarker,
|
|
158
|
+
Q as patchPoolingDelay
|
|
157
159
|
};
|
|
158
160
|
//# sourceMappingURL=createAppV2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createAppV2.js","sources":["../../src/internal/createAppV2.ts"],"sourcesContent":["import { deepClone, delay, uniqueId } from '@milaboratories/helpers';\nimport type { Mutable } from '@milaboratories/helpers';\nimport type { NavigationState, BlockOutputsBase, BlockState, PlatformaV2, ValueWithUTag, AuthorMarker } from '@platforma-sdk/model';\nimport { hasAbortError, unwrapResult } from '@platforma-sdk/model';\nimport type { Ref } from 'vue';\nimport { reactive, computed, ref } from 'vue';\nimport type { StateModelOptions, UnwrapOutputs, OutputValues, OutputErrors, AppSettings } from '../types';\nimport { createModel } from '../createModel';\nimport { createAppModel } from './createAppModel';\nimport { parseQuery } from '../urls';\nimport { MultiError, unwrapValueOrErrors } from '../utils';\nimport { applyPatch } from 'fast-json-patch';\nimport { UpdateSerializer } from './UpdateSerializer';\n\nexport const patchPoolingDelay = 100;\n\nexport const createNextAuthorMarker = (marker: AuthorMarker | undefined): AuthorMarker => ({\n authorId: marker?.authorId ?? uniqueId(),\n localVersion: (marker?.localVersion ?? 0) + 1,\n});\n\n/**\n * Creates an application instance with reactive state management, outputs, and methods for state updates and navigation.\n *\n * @template Args - The type of arguments used in the application.\n * @template Outputs - The type of block outputs extending `BlockOutputsBase`.\n * @template UiState - The type of the UI state.\n * @template Href - The type of navigation href, defaulting to a string starting with `/`.\n *\n * @param state - Initial state of the application, including args, outputs, UI state, and navigation state.\n * @param platforma - A platform interface for interacting with block states.\n * @param settings - Application settings, such as debug flags.\n *\n * @returns A reactive application object with methods, getters, and state.\n */\nexport function createAppV2<\n Args = unknown,\n Outputs extends BlockOutputsBase = BlockOutputsBase,\n UiState = unknown,\n Href extends `/${string}` = `/${string}`,\n>(\n state: ValueWithUTag<BlockState<Args, Outputs, UiState, Href>>,\n platforma: PlatformaV2<Args, Outputs, UiState, Href>,\n settings: AppSettings,\n) {\n type AppModel = {\n args: Args;\n ui: UiState;\n };\n\n const debug = (msg: string, ...rest: unknown[]) => {\n if (settings.debug) {\n console.log(`%c>>> %c${msg}`, 'color: orange; font-weight: bold', 'color: orange', settings.appId, ...rest);\n }\n };\n\n const error = (msg: string, ...rest: unknown[]) => {\n console.error(`%c>>> %c${msg}`, 'color: red; font-weight: bold', 'color: red', settings.appId, ...rest);\n };\n\n const data = {\n isExternalSnapshot: false,\n author: {\n authorId: uniqueId(),\n localVersion: 0,\n },\n };\n\n const nextAuthorMarker = () => {\n data.author = createNextAuthorMarker(data.author);\n debug('nextAuthorMarker', data.author);\n return data.author;\n };\n\n const closedRef = ref(false);\n\n const uTagRef = ref(state.uTag);\n\n const debounceSpan = settings.debounceSpan ?? 200;\n\n const setArgsQueue = new UpdateSerializer({ debounceSpan });\n const setUiStateQueue = new UpdateSerializer({ debounceSpan });\n const setArgsAndUiStateQueue = new UpdateSerializer({ debounceSpan });\n const setNavigationStateQueue = new UpdateSerializer({ debounceSpan });\n /**\n * Reactive snapshot of the application state, including args, outputs, UI state, and navigation state.\n */\n const snapshot = ref<{\n args: Args;\n outputs: Partial<Outputs>;\n ui: UiState;\n navigationState: NavigationState<Href>;\n }>(state.value) as Ref<{\n args: Args;\n outputs: Partial<Outputs>;\n ui: UiState;\n navigationState: NavigationState<Href>;\n }>;\n\n const setBlockArgs = async (args: Args) => {\n return platforma.setBlockArgs(args, nextAuthorMarker());\n };\n\n const setBlockUiState = async (ui: UiState) => {\n return platforma.setBlockUiState(ui, nextAuthorMarker());\n };\n\n const setBlockArgsAndUiState = async (args: Args, ui: UiState) => {\n return platforma.setBlockArgsAndUiState(args, ui, nextAuthorMarker());\n };\n\n const setNavigationState = async (state: NavigationState<Href>) => {\n return platforma.setNavigationState(state);\n };\n\n (async () => {\n window.addEventListener('beforeunload', () => {\n closedRef.value = true;\n platforma.dispose().then(unwrapResult).catch((err) => {\n error('error in dispose', err);\n });\n });\n\n while (!closedRef.value) {\n try {\n const patches = await platforma.getPatches(uTagRef.value).then(unwrapResult);\n\n debug('patches', JSON.stringify(patches, null, 2));\n debug('uTagRef.value', uTagRef.value);\n debug('patches.uTag', patches.uTag);\n debug('patches.author', patches.author);\n debug('data.author', data.author);\n\n uTagRef.value = patches.uTag;\n\n if (patches.value.length === 0) {\n await new Promise((resolve) => setTimeout(resolve, patchPoolingDelay));\n continue;\n }\n\n const isAuthorChanged = data.author?.authorId !== patches.author?.authorId;\n\n // Immutable behavior, apply external changes to the snapshot\n if (isAuthorChanged || data.isExternalSnapshot) {\n debug('got external changes, applying them to the snapshot', JSON.stringify(snapshot.value, null, 2));\n snapshot.value = applyPatch(snapshot.value, patches.value, false, false).newDocument;\n data.isExternalSnapshot = isAuthorChanged;\n } else {\n // Mutable behavior\n snapshot.value = applyPatch(snapshot.value, patches.value).newDocument;\n }\n\n await new Promise((resolve) => setTimeout(resolve, patchPoolingDelay));\n } catch (err) {\n if (hasAbortError(err)) {\n debug('patches loop aborted');\n closedRef.value = true;\n } else {\n error('error in patches loop', err);\n await new Promise((resolve) => setTimeout(resolve, 1000));\n }\n }\n }\n })();\n\n const outputs = computed<OutputValues<Outputs>>(() => {\n const entries = Object.entries(snapshot.value.outputs as Partial<Readonly<Outputs>>).map(([k, vOrErr]) => [k, vOrErr.ok && vOrErr.value !== undefined ? vOrErr.value : undefined]);\n return Object.fromEntries(entries);\n });\n\n const outputErrors = computed<OutputErrors<Outputs>>(() => {\n const entries = Object.entries(snapshot.value.outputs as Partial<Readonly<Outputs>>).map(([k, vOrErr]) => [k, vOrErr && !vOrErr.ok ? new MultiError(vOrErr.errors) : undefined]);\n return Object.fromEntries(entries);\n });\n\n const appModel = createAppModel(\n {\n get() {\n return { args: snapshot.value.args, ui: snapshot.value.ui } as AppModel;\n },\n autoSave: true,\n onSave(newData: AppModel) {\n debug('onSave', newData);\n setArgsAndUiStateQueue.run(() => setBlockArgsAndUiState(newData.args, newData.ui).then(unwrapResult));\n },\n },\n {\n outputs,\n outputErrors,\n },\n settings,\n );\n\n const cloneArgs = () => deepClone(appModel.model.args) as Args;\n const cloneUiState = () => deepClone(appModel.model.ui) as UiState;\n const cloneNavigationState = () => deepClone(snapshot.value.navigationState) as Mutable<NavigationState<Href>>;\n\n const methods = {\n cloneArgs,\n cloneUiState,\n cloneNavigationState,\n createArgsModel<T extends Args = Args>(options: StateModelOptions<Args, T> = {}) {\n return createModel<T, Args>({\n get() {\n if (options.transform) {\n return options.transform(snapshot.value.args as Args);\n }\n\n return snapshot.value.args as T;\n },\n validate: options.validate,\n autoSave: true,\n onSave(newArgs) {\n setArgsQueue.run(() => setBlockArgs(newArgs).then(unwrapResult));\n },\n });\n },\n /**\n * defaultUiState is temporarily here, remove it after implementing initialUiState\n */\n createUiModel<T extends UiState = UiState>(options: StateModelOptions<UiState, T> = {}, defaultUiState: () => UiState) {\n return createModel<T, UiState>({\n get() {\n if (options.transform) {\n return options.transform(snapshot.value.ui as UiState);\n }\n\n return (snapshot.value.ui ?? defaultUiState()) as T;\n },\n validate: options.validate,\n autoSave: true,\n onSave(newData) {\n setUiStateQueue.run(() => setBlockUiState(newData).then(unwrapResult));\n },\n });\n },\n /**\n * Retrieves the unwrapped values of outputs for the given keys.\n *\n * @template K - Keys of the outputs to unwrap.\n * @param keys - List of output names.\n * @throws Error if the outputs contain errors.\n * @returns An object with unwrapped output values.\n */\n unwrapOutputs<K extends keyof Outputs>(...keys: K[]): UnwrapOutputs<Outputs, K> {\n const outputs = snapshot.value.outputs as Partial<Readonly<Outputs>>;\n const entries = keys.map((key) => [key, unwrapValueOrErrors(outputs[key])]);\n return Object.fromEntries(entries);\n },\n /**\n * Updates the arguments state by applying a callback.\n *\n * @param cb - Callback to modify the current arguments.\n * @returns A promise resolving after the update is applied.\n */\n updateArgs(cb: (args: Args) => void): Promise<boolean> {\n const newArgs = cloneArgs();\n cb(newArgs);\n debug('updateArgs', newArgs);\n appModel.model.args = newArgs;\n return setArgsQueue.run(() => setBlockArgs(newArgs).then(unwrapResult));\n },\n /**\n * Updates the UI state by applying a callback.\n *\n * @param cb - Callback to modify the current UI state.\n * @returns A promise resolving after the update is applied.\n * @todo Make it mutable since there is already an initial one\n */\n updateUiState(cb: (args: UiState) => UiState): Promise<boolean> {\n const newUiState = cb(cloneUiState());\n debug('updateUiState', newUiState);\n appModel.model.ui = newUiState;\n return setUiStateQueue.run(() => setBlockUiState(newUiState).then(unwrapResult));\n },\n /**\n * Navigates to a specific href by updating the navigation state.\n *\n * @param href - The target href to navigate to.\n * @returns A promise resolving after the navigation state is updated.\n */\n navigateTo(href: Href) {\n const newState = cloneNavigationState();\n newState.href = href;\n return setNavigationStateQueue.run(() => setNavigationState(newState).then(unwrapResult));\n },\n async allSettled() {\n await delay(0);\n return setArgsAndUiStateQueue.allSettled();\n },\n };\n\n const getters = {\n closedRef,\n snapshot,\n queryParams: computed(() => parseQuery<Href>(snapshot.value.navigationState.href as Href)),\n href: computed(() => snapshot.value.navigationState.href),\n hasErrors: computed(() => Object.values(snapshot.value.outputs as Partial<Readonly<Outputs>>).some((v) => !v?.ok)),\n };\n\n return reactive(Object.assign(appModel, methods, getters));\n}\n\nexport type BaseAppV2<\n Args = unknown,\n Outputs extends BlockOutputsBase = BlockOutputsBase,\n UiState = unknown,\n Href extends `/${string}` = `/${string}`,\n> = ReturnType<typeof createAppV2<Args, Outputs, UiState, Href>>;\n"],"names":["patchPoolingDelay","createNextAuthorMarker","marker","uniqueId","createAppV2","state","platforma","settings","debug","msg","rest","error","data","nextAuthorMarker","closedRef","ref","uTagRef","debounceSpan","setArgsQueue","UpdateSerializer","setUiStateQueue","setArgsAndUiStateQueue","setNavigationStateQueue","snapshot","setBlockArgs","args","setBlockUiState","ui","setBlockArgsAndUiState","setNavigationState","unwrapResult","err","patches","resolve","isAuthorChanged","_a","_b","applyPatch","hasAbortError","outputs","computed","entries","k","vOrErr","outputErrors","MultiError","appModel","createAppModel","newData","cloneArgs","deepClone","cloneUiState","cloneNavigationState","methods","options","createModel","newArgs","defaultUiState","keys","key","unwrapValueOrErrors","cb","newUiState","href","newState","delay","getters","parseQuery","v","reactive"],"mappings":";;;;;;;;;;;AAcO,MAAMA,IAAoB,KAEpBC,IAAyB,CAACC,OAAoD;AAAA,EACzF,WAAUA,KAAA,gBAAAA,EAAQ,aAAYC,EAAS;AAAA,EACvC,gBAAeD,KAAA,gBAAAA,EAAQ,iBAAgB,KAAK;AAC9C;AAgBgB,SAAAE,GAMdC,GACAC,GACAC,GACA;AAMM,QAAAC,IAAQ,CAACC,MAAgBC,MAAoB;AACjD,IAAIH,EAAS,SACH,QAAA,IAAI,WAAWE,CAAG,IAAI,oCAAoC,iBAAiBF,EAAS,OAAO,GAAGG,CAAI;AAAA,EAE9G,GAEM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AAY;AACrB,YAAMC,IAAWZ,EAAqB;AACtC,aAAAY,EAAS,OAAOD,GACTzC,EAAwB,IAAI,MAAMO,EAAmBmC,CAAQ,EAAE,KAAKlC,CAAY,CAAC;AAAA,IAC1F;AAAA,IACA,MAAM,aAAa;AACjB,mBAAMmC,EAAM,CAAC,GACN5C,EAAuB,WAAW;AAAA,IAAA;AAAA,EAE7C,GAEM6C,IAAU;AAAA,IACd,WAAApD;AAAA,IACA,UAAAS;AAAA,IACA,aAAaiB,EAAS,MAAM2B,EAAiB5C,EAAS,MAAM,gBAAgB,IAAY,CAAC;AAAA,IACzF,MAAMiB,EAAS,MAAMjB,EAAS,MAAM,gBAAgB,IAAI;AAAA,IACxD,WAAWiB,EAAS,MAAM,OAAO,OAAOjB,EAAS,MAAM,OAAqC,EAAE,KAAK,CAAC6C,MAAM,EAACA,KAAA,QAAAA,EAAG,GAAE,CAAC;AAAA,EACnH;AAEA,SAAOC,EAAS,OAAO,OAAOvB,GAAUO,GAASa,CAAO,CAAC;AAC3D;"}
|
|
1
|
+
{"version":3,"file":"createAppV2.js","sources":["../../src/internal/createAppV2.ts"],"sourcesContent":["import { deepClone, delay, uniqueId } from '@milaboratories/helpers';\nimport type { Mutable } from '@milaboratories/helpers';\nimport type { NavigationState, BlockOutputsBase, BlockState, PlatformaV2, ValueWithUTag, AuthorMarker } from '@platforma-sdk/model';\nimport { hasAbortError, unwrapResult } from '@platforma-sdk/model';\nimport type { Ref } from 'vue';\nimport { reactive, computed, ref, watch } from 'vue';\nimport type { StateModelOptions, UnwrapOutputs, OutputValues, OutputErrors, AppSettings } from '../types';\nimport { createModel } from '../createModel';\nimport { parseQuery } from '../urls';\nimport { MultiError, unwrapValueOrErrors } from '../utils';\nimport { applyPatch } from 'fast-json-patch';\nimport { UpdateSerializer } from './UpdateSerializer';\n\nexport const patchPoolingDelay = 100;\n\nexport const createNextAuthorMarker = (marker: AuthorMarker | undefined): AuthorMarker => ({\n authorId: marker?.authorId ?? uniqueId(),\n localVersion: (marker?.localVersion ?? 0) + 1,\n});\n\n/**\n * Creates an application instance with reactive state management, outputs, and methods for state updates and navigation.\n *\n * @template Args - The type of arguments used in the application.\n * @template Outputs - The type of block outputs extending `BlockOutputsBase`.\n * @template UiState - The type of the UI state.\n * @template Href - The type of navigation href, defaulting to a string starting with `/`.\n *\n * @param state - Initial state of the application, including args, outputs, UI state, and navigation state.\n * @param platforma - A platform interface for interacting with block states.\n * @param settings - Application settings, such as debug flags.\n *\n * @returns A reactive application object with methods, getters, and state.\n */\nexport function createAppV2<\n Args = unknown,\n Outputs extends BlockOutputsBase = BlockOutputsBase,\n UiState = unknown,\n Href extends `/${string}` = `/${string}`,\n>(\n state: ValueWithUTag<BlockState<Args, Outputs, UiState, Href>>,\n platforma: PlatformaV2<Args, Outputs, UiState, Href>,\n settings: AppSettings,\n) {\n const debug = (msg: string, ...rest: unknown[]) => {\n if (settings.debug) {\n console.log(`%c>>> %c${msg}`, 'color: orange; font-weight: bold', 'color: orange', settings.appId, ...rest);\n }\n };\n\n const error = (msg: string, ...rest: unknown[]) => {\n console.error(`%c>>> %c${msg}`, 'color: red; font-weight: bold', 'color: red', settings.appId, ...rest);\n };\n\n const data = {\n isExternalSnapshot: false,\n author: {\n authorId: uniqueId(),\n localVersion: 0,\n },\n };\n\n const nextAuthorMarker = () => {\n data.author = createNextAuthorMarker(data.author);\n debug('nextAuthorMarker', data.author);\n return data.author;\n };\n\n const closedRef = ref(false);\n\n const uTagRef = ref(state.uTag);\n\n const debounceSpan = settings.debounceSpan ?? 200;\n\n const setArgsQueue = new UpdateSerializer({ debounceSpan });\n const setUiStateQueue = new UpdateSerializer({ debounceSpan });\n const setArgsAndUiStateQueue = new UpdateSerializer({ debounceSpan });\n const setNavigationStateQueue = new UpdateSerializer({ debounceSpan });\n /**\n * Reactive snapshot of the application state, including args, outputs, UI state, and navigation state.\n */\n const snapshot = ref<{\n args: Args;\n outputs: Partial<Outputs>;\n ui: UiState;\n navigationState: NavigationState<Href>;\n }>(state.value) as Ref<{\n args: Args;\n outputs: Partial<Outputs>;\n ui: UiState;\n navigationState: NavigationState<Href>;\n }>;\n\n const setBlockArgs = async (args: Args) => {\n return platforma.setBlockArgs(args, nextAuthorMarker());\n };\n\n const setBlockUiState = async (ui: UiState) => {\n return platforma.setBlockUiState(ui, nextAuthorMarker());\n };\n\n const setBlockArgsAndUiState = async (args: Args, ui: UiState) => {\n return platforma.setBlockArgsAndUiState(args, ui, nextAuthorMarker());\n };\n\n const setNavigationState = async (state: NavigationState<Href>) => {\n return platforma.setNavigationState(state);\n };\n\n const outputs = computed<OutputValues<Outputs>>(() => {\n const entries = Object.entries(snapshot.value.outputs as Partial<Readonly<Outputs>>).map(([k, vOrErr]) => [k, vOrErr.ok && vOrErr.value !== undefined ? vOrErr.value : undefined]);\n return Object.fromEntries(entries);\n });\n\n const outputErrors = computed<OutputErrors<Outputs>>(() => {\n const entries = Object.entries(snapshot.value.outputs as Partial<Readonly<Outputs>>).map(([k, vOrErr]) => [k, vOrErr && !vOrErr.ok ? new MultiError(vOrErr.errors) : undefined]);\n return Object.fromEntries(entries);\n });\n\n const appModel = reactive({\n error: '',\n model: {\n args: deepClone(snapshot.value.args) as Args,\n ui: deepClone(snapshot.value.ui) as UiState,\n outputs,\n outputErrors,\n },\n }) as {\n error: string;\n model: {\n args: Args;\n ui: UiState;\n outputs: OutputValues<Outputs>;\n outputErrors: OutputErrors<Outputs>;\n };\n };\n\n const appModelWatch = watch(\n () => appModel.model,\n (_newData) => {\n const newData = deepClone(_newData);\n debug('appModel.model', newData);\n setArgsAndUiStateQueue.run(() => setBlockArgsAndUiState(newData.args, newData.ui).then(unwrapResult));\n },\n { deep: true },\n );\n\n const updateAppModelSilently = (newData: {\n args: Args;\n ui: UiState;\n }) => {\n debug('updateAppModelSilently', newData);\n appModelWatch.pause();\n appModel.model.args = deepClone(newData.args) as Args;\n appModel.model.ui = deepClone(newData.ui) as UiState;\n appModelWatch.resume();\n };\n\n (async () => {\n window.addEventListener('beforeunload', () => {\n closedRef.value = true;\n platforma.dispose().then(unwrapResult).catch((err) => {\n error('error in dispose', err);\n });\n });\n\n while (!closedRef.value) {\n try {\n const patches = await platforma.getPatches(uTagRef.value).then(unwrapResult);\n\n debug('patches.length', patches.value.length);\n debug('uTagRef.value', uTagRef.value);\n debug('patches.uTag', patches.uTag);\n debug('patches.author', patches.author);\n debug('data.author', data.author);\n\n uTagRef.value = patches.uTag;\n\n if (patches.value.length === 0) {\n await new Promise((resolve) => setTimeout(resolve, patchPoolingDelay));\n continue;\n }\n\n const isAuthorChanged = data.author?.authorId !== patches.author?.authorId;\n\n // Immutable behavior, apply external changes to the snapshot\n if (isAuthorChanged || data.isExternalSnapshot) {\n debug('got external changes, applying them to the snapshot', JSON.stringify(snapshot.value, null, 2));\n snapshot.value = applyPatch(snapshot.value, patches.value, false, false).newDocument;\n updateAppModelSilently(snapshot.value);\n data.isExternalSnapshot = isAuthorChanged;\n } else {\n // Mutable behavior\n snapshot.value = applyPatch(snapshot.value, patches.value).newDocument;\n }\n\n await new Promise((resolve) => setTimeout(resolve, patchPoolingDelay));\n } catch (err) {\n if (hasAbortError(err)) {\n debug('patches loop aborted');\n closedRef.value = true;\n } else {\n error('error in patches loop', err);\n await new Promise((resolve) => setTimeout(resolve, 1000));\n }\n }\n }\n })();\n\n const cloneArgs = () => deepClone(appModel.model.args) as Args;\n const cloneUiState = () => deepClone(appModel.model.ui) as UiState;\n const cloneNavigationState = () => deepClone(snapshot.value.navigationState) as Mutable<NavigationState<Href>>;\n\n const methods = {\n cloneArgs,\n cloneUiState,\n cloneNavigationState,\n createArgsModel<T extends Args = Args>(options: StateModelOptions<Args, T> = {}) {\n return createModel<T, Args>({\n get() {\n if (options.transform) {\n return options.transform(snapshot.value.args as Args);\n }\n\n return snapshot.value.args as T;\n },\n validate: options.validate,\n autoSave: true,\n onSave(newArgs) {\n setArgsQueue.run(() => setBlockArgs(newArgs).then(unwrapResult));\n },\n });\n },\n /**\n * defaultUiState is temporarily here, remove it after implementing initialUiState\n */\n createUiModel<T extends UiState = UiState>(options: StateModelOptions<UiState, T> = {}, defaultUiState: () => UiState) {\n return createModel<T, UiState>({\n get() {\n if (options.transform) {\n return options.transform(snapshot.value.ui as UiState);\n }\n\n return (snapshot.value.ui ?? defaultUiState()) as T;\n },\n validate: options.validate,\n autoSave: true,\n onSave(newData) {\n setUiStateQueue.run(() => setBlockUiState(newData).then(unwrapResult));\n },\n });\n },\n /**\n * Retrieves the unwrapped values of outputs for the given keys.\n *\n * @template K - Keys of the outputs to unwrap.\n * @param keys - List of output names.\n * @throws Error if the outputs contain errors.\n * @returns An object with unwrapped output values.\n */\n unwrapOutputs<K extends keyof Outputs>(...keys: K[]): UnwrapOutputs<Outputs, K> {\n const outputs = snapshot.value.outputs as Partial<Readonly<Outputs>>;\n const entries = keys.map((key) => [key, unwrapValueOrErrors(outputs[key])]);\n return Object.fromEntries(entries);\n },\n /**\n * Updates the arguments state by applying a callback.\n *\n * @param cb - Callback to modify the current arguments.\n * @returns A promise resolving after the update is applied.\n */\n updateArgs(cb: (args: Args) => void): Promise<boolean> {\n const newArgs = cloneArgs();\n cb(newArgs);\n debug('updateArgs', newArgs);\n appModel.model.args = newArgs;\n return setArgsQueue.run(() => setBlockArgs(newArgs).then(unwrapResult));\n },\n /**\n * Updates the UI state by applying a callback.\n *\n * @param cb - Callback to modify the current UI state.\n * @returns A promise resolving after the update is applied.\n * @todo Make it mutable since there is already an initial one\n */\n updateUiState(cb: (args: UiState) => UiState): Promise<boolean> {\n const newUiState = cb(cloneUiState());\n debug('updateUiState', newUiState);\n appModel.model.ui = newUiState;\n return setUiStateQueue.run(() => setBlockUiState(newUiState).then(unwrapResult));\n },\n /**\n * Navigates to a specific href by updating the navigation state.\n *\n * @param href - The target href to navigate to.\n * @returns A promise resolving after the navigation state is updated.\n */\n navigateTo(href: Href) {\n const newState = cloneNavigationState();\n newState.href = href;\n return setNavigationStateQueue.run(() => setNavigationState(newState).then(unwrapResult));\n },\n async allSettled() {\n await delay(0);\n return setArgsAndUiStateQueue.allSettled();\n },\n };\n\n const getters = {\n closedRef,\n snapshot,\n queryParams: computed(() => parseQuery<Href>(snapshot.value.navigationState.href as Href)),\n href: computed(() => snapshot.value.navigationState.href),\n hasErrors: computed(() => Object.values(snapshot.value.outputs as Partial<Readonly<Outputs>>).some((v) => !v?.ok)),\n };\n\n return reactive(Object.assign(appModel, methods, getters));\n}\n\nexport type BaseAppV2<\n Args = unknown,\n Outputs extends BlockOutputsBase = BlockOutputsBase,\n UiState = unknown,\n Href extends `/${string}` = `/${string}`,\n> = ReturnType<typeof createAppV2<Args, Outputs, UiState, Href>>;\n"],"names":["patchPoolingDelay","createNextAuthorMarker","marker","uniqueId","createAppV2","state","platforma","settings","debug","msg","rest","error","data","nextAuthorMarker","closedRef","ref","uTagRef","debounceSpan","setArgsQueue","UpdateSerializer","setUiStateQueue","setArgsAndUiStateQueue","setNavigationStateQueue","snapshot","setBlockArgs","args","setBlockUiState","ui","setBlockArgsAndUiState","setNavigationState","outputs","computed","entries","k","vOrErr","outputErrors","MultiError","appModel","reactive","deepClone","appModelWatch","watch","_newData","newData","unwrapResult","updateAppModelSilently","err","patches","resolve","isAuthorChanged","_a","_b","applyPatch","hasAbortError","cloneArgs","cloneUiState","cloneNavigationState","methods","options","createModel","newArgs","defaultUiState","keys","key","unwrapValueOrErrors","cb","newUiState","href","newState","delay","getters","parseQuery","v"],"mappings":";;;;;;;;;;AAaO,MAAMA,IAAoB,KAEpBC,IAAyB,CAACC,OAAoD;AAAA,EACzF,WAAUA,KAAA,gBAAAA,EAAQ,aAAYC,EAAS;AAAA,EACvC,gBAAeD,KAAA,gBAAAA,EAAQ,iBAAgB,KAAK;AAC9C;AAgBgB,SAAAE,GAMdC,GACAC,GACAC,GACA;AACM,QAAAC,IAAQ,CAACC,MAAgBC,MAAoB;AACjD,IAAIH,EAAS,SACH,QAAA,IAAI,WAAWE,CAAG,IAAI,oCAAoC,iBAAiBF,EAAS,OAAO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AAI,MAAMM,EAAaoC,CAAO,EAAE,KAAKhB,CAAY,CAAC;AAAA,IACxE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQA,cAAcqB,GAAkD;AACxD,YAAAC,IAAaD,EAAGV,GAAc;AACpC,aAAA/C,EAAM,iBAAiB0D,CAAU,GACjC7B,EAAS,MAAM,KAAK6B,GACb9C,EAAgB,IAAI,MAAMM,EAAgBwC,CAAU,EAAE,KAAKtB,CAAY,CAAC;AAAA,IACjF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOA,WAAWuB,GAAY;AACrB,YAAMC,IAAWZ,EAAqB;AACtC,aAAAY,EAAS,OAAOD,GACT7C,EAAwB,IAAI,MAAMO,EAAmBuC,CAAQ,EAAE,KAAKxB,CAAY,CAAC;AAAA,IAC1F;AAAA,IACA,MAAM,aAAa;AACjB,mBAAMyB,EAAM,CAAC,GACNhD,EAAuB,WAAW;AAAA,IAAA;AAAA,EAE7C,GAEMiD,IAAU;AAAA,IACd,WAAAxD;AAAA,IACA,UAAAS;AAAA,IACA,aAAaQ,EAAS,MAAMwC,EAAiBhD,EAAS,MAAM,gBAAgB,IAAY,CAAC;AAAA,IACzF,MAAMQ,EAAS,MAAMR,EAAS,MAAM,gBAAgB,IAAI;AAAA,IACxD,WAAWQ,EAAS,MAAM,OAAO,OAAOR,EAAS,MAAM,OAAqC,EAAE,KAAK,CAACiD,MAAM,EAACA,KAAA,QAAAA,EAAG,GAAE,CAAC;AAAA,EACnH;AAEA,SAAOlC,EAAS,OAAO,OAAOD,GAAUoB,GAASa,CAAO,CAAC;AAC3D;"}
|
|
@@ -65,7 +65,7 @@ import "../../colors/gradient.js";
|
|
|
65
65
|
.ui-text-area{--contour-color: var(--txt-01);--label-color: var(--txt-01);--contour-border-width: 1px;--contour-box-shadow: none;--label-offset-left-x: 8px;--label-offset-right-x: 8px;--prefix-color: var(--color-placeholder);width:100%;min-height:var(--control-height);position:relative;border-radius:var(--border-radius-control);display:flex;flex-direction:row;align-items:center;outline:none}.ui-text-area__envelope{font-family:var(--font-family-base)}.ui-text-area textarea{min-height:calc(var(--control-height) - 2px);width:100%;padding:10px 12px;border:none;font-size:inherit;background-color:transparent;color:var(--txt-01);caret-color:var(--border-color-focus);cursor:inherit;resize:none;--thumb-color: var(--ic-02);overflow-y:auto}.ui-text-area textarea::-webkit-scrollbar{width:var(--scrollbar-width, 6px);height:5px;background-color:transparent;display:block}.ui-text-area textarea::-webkit-scrollbar-thumb{background:var(--thumb-color);border-radius:5px}.ui-text-area textarea::-webkit-scrollbar-thumb:hover{--thumb-color: var(--border-color-focus)}.ui-text-area textarea:focus{outline:none}.ui-text-area textarea::placeholder{color:var(--color-placeholder)}.ui-text-area label{display:flex;align-items:center;gap:4px;position:absolute;top:0;transform:translateY(-60%);left:var(--label-offset-left-x);padding:0 4px;max-width:calc(100% - 16px);overflow:hidden;white-space:pre;text-overflow:ellipsis;cursor:inherit;color:var(--label-color);font-size:12px;font-weight:500;border-bottom-right-radius:4px;border-bottom-left-radius:4px;background:var(--bg-elevated-01)}.ui-text-area label>span{overflow:hidden;white-space:pre;text-overflow:ellipsis}.ui-text-area__contour{position:absolute;top:0;left:0;right:0;bottom:0;border-radius:var(--border-radius-control);border-width:var(--contour-border-width);border-color:var(--contour-color);border-style:solid;box-shadow:var(--contour-box-shadow);z-index:0;pointer-events:none}.ui-text-area__append{display:flex;flex-direction:row;align-items:center;gap:4px}.ui-text-area__helper{font-size:12px;color:var(--txt-03);padding:2px 0 0;white-space:pre-wrap;text-overflow:ellipsis;font-weight:500;line-height:16px;margin-top:6px}.ui-text-area__error{font-size:12px;color:var(--txt-error);padding:2px 0 0;white-space:pre-wrap;text-overflow:ellipsis;font-weight:500;line-height:16px;margin-top:6px}.ui-text-area:hover{--contour-color: var(--control-hover-color)}.ui-text-area:focus-within:not(.error){--label-color: var(--txt-focus);--contour-color: var(--border-color-focus);--contour-border-width: 2px;--contour-box-shadow: 0 0 0 4px var(--border-color-focus-shadow)}.ui-text-area:focus-within.error{--contour-border-width: 2px;--contour-box-shadow: 0 0 0 4px var(--color-error-shadow)}.ui-text-area.dashed .ui-text-area__contour{border-style:dashed}.ui-text-area.nonEmpty{--prefix-color: var(--txt-01)}.ui-text-area.error{--contour-color: var(--txt-error)}.ui-text-area.disabled{--contour-color: var(--color-dis-01);cursor:not-allowed;pointer-events:none}.ui-text-area.disabled *{color:var(--contour-color)}
|
|
66
66
|
.pl-text-field{--pl-text-field-text-color: var(--txt-01);--contour-color: var(--txt-01);--label-color: var(--txt-01);--contour-border-width: 1px;--contour-box-shadow: none;--label-offset-left-x: 8px;--label-offset-right-x: 8px;--prefix-color: var(--color-placeholder);--show-clearable: none;width:100%;min-width:160px;min-height:var(--control-height);position:relative;border-radius:var(--border-radius-control);display:flex;flex-direction:row;align-items:center;outline:none}.pl-text-field__envelope{font-family:var(--font-family-base)}.pl-text-field input{font-family:var(--font-family-base);font-weight:500;min-height:calc(var(--control-height) - 2px);line-height:20px;width:100%;padding:0 12px;border:none;font-size:inherit;background-color:transparent;color:var(--pl-text-field-text-color);caret-color:var(--border-color-focus);cursor:inherit}.pl-text-field input:focus{outline:none}.pl-text-field input::placeholder{color:var(--color-placeholder)}.pl-text-field label{display:flex;align-items:center;gap:4px;position:absolute;top:0;transform:translateY(-60%);left:var(--label-offset-left-x);padding:0 4px;max-width:calc(100% - 16px);overflow:hidden;white-space:pre;text-overflow:ellipsis;cursor:inherit;color:var(--label-color);font-size:12px;font-weight:500;border-bottom-right-radius:4px;border-bottom-left-radius:4px;background:var(--bg-elevated-01)}.pl-text-field label>span{overflow:hidden;white-space:pre;text-overflow:ellipsis}.pl-text-field__contour{position:absolute;top:0;left:0;right:0;bottom:0;border-radius:var(--border-radius-control);border-width:var(--contour-border-width);border-color:var(--contour-color);border-style:solid;box-shadow:var(--contour-box-shadow);z-index:0;pointer-events:none}.pl-text-field__prefix{padding-left:12px;white-space:nowrap;margin-right:-12px;color:var(--prefix-color)}.pl-text-field__append{padding-right:12px;display:flex;flex-direction:row;align-items:center;gap:4px;cursor:text}.pl-text-field__append .icon-16{cursor:pointer}.pl-text-field__append .mask-16{--icon-color: var(--control-mask-fill);cursor:pointer}.pl-text-field__clearable{display:var(--show-clearable)!important;--icon-color: var(--ic-02) !important}.pl-text-field__helper{font-size:12px;color:var(--txt-03);padding:2px 0 0;white-space:pre-wrap;text-overflow:ellipsis;font-weight:500;line-height:16px;margin-top:6px}.pl-text-field__error{font-size:12px;color:var(--txt-error);padding:2px 0 0;white-space:pre-wrap;text-overflow:ellipsis;font-weight:500;line-height:16px;margin-top:6px}.pl-text-field:hover{--contour-color: var(--control-hover-color);--show-clearable: inline-block}.pl-text-field:focus-within{--show-clearable: inline-block}.pl-text-field:focus-within:not(.error){--label-color: var(--txt-focus);--contour-color: var(--border-color-focus);--contour-border-width: 2px;--contour-box-shadow: 0 0 0 4px var(--border-color-focus-shadow)}.pl-text-field:focus-within.error{--contour-border-width: 2px;--contour-box-shadow: 0 0 0 4px var(--color-error-shadow)}.pl-text-field.dashed .pl-text-field__contour{border-style:dashed}.pl-text-field.nonEmpty{--prefix-color: var(--txt-01)}.pl-text-field.error{--contour-color: var(--txt-error);--label-color: var(--txt-error)}.pl-text-field.disabled{--contour-color: var(--color-dis-01);--label-color: var(--dis-01);--pl-text-field-text-color: var(--dis-01);--mask-icon-bg-color: var(--dis-01);cursor:not-allowed}
|
|
67
67
|
.ui-toggle-switch{--handle-ml: 0;--body-bg: var(--bg-base-light);--body-shadow: var(--btn-group-shape-shadow);display:flex;align-items:center;gap:12px;outline:none}.ui-toggle-switch__body{width:40px;height:24px;display:flex;padding:5px;border-radius:12px;border:1px solid var(--color-ic-01);box-shadow:var(--body-shadow);background:var(--body-bg);cursor:pointer}.ui-toggle-switch__handle{width:12px;height:12px;border-radius:12px;border:1px solid var(--color-ic-01);background:var(--color-ic-00);margin-left:var(--handle-ml)}.ui-toggle-switch.active{--body-bg: var(--btn-switcher-bg);--handle-ml: auto}.ui-toggle-switch:focus-visible{--label-color: var(--txt-focus);--body-shadow: var(--btn-group-shape-shadow), 0 0 0 2px #fff, 0 0 0 4px var(--border-color-focus)}
|
|
68
|
-
.pl-file-input{--contour-color: var(--txt-01);--label-color: var(--txt-01);--text-color: var(--txt-01);--contour-border-width: 1px;--contour-box-shadow: none;--label-offset-left-x: 8px;--label-offset-right-x: 8px;--prefix-color: var(--color-placeholder);--contour-offset: 2px;--icon-color: #000;width:100%;height:var(--control-height, 40px);
|
|
68
|
+
.pl-file-input{--contour-color: var(--txt-01);--label-color: var(--txt-01);--text-color: var(--txt-01);--contour-border-width: 1px;--contour-box-shadow: none;--label-offset-left-x: 8px;--label-offset-right-x: 8px;--prefix-color: var(--color-placeholder);--contour-offset: 2px;--icon-color: #000;position:relative;z-index:0;width:100%;height:var(--control-height, 40px);border-radius:var(--border-radius-control);display:flex;flex-direction:row;align-items:center;outline:none;padding:0 8px;gap:8px;cursor:pointer}.pl-file-input__envelope{font-family:var(--font-family-base);display:flex;flex-direction:column;min-width:160px}.pl-file-input .mask-24{display:block;min-width:24px}.pl-file-input .mask-close{cursor:pointer}.pl-file-input__progress{position:absolute;z-index:-1;top:0;bottom:0;left:0;right:0;background:linear-gradient(90deg,#fff,#d8fac8);pointer-events:none;width:0}.pl-file-input__clear{--icon-color: var(--ic-02)}.pl-file-input__filename{width:100%;border:none;font-size:inherit;background-color:transparent;color:var(--text-color);caret-color:var(--border-color-focus);z-index:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:18px}.pl-file-input__filename:empty:before{color:var(--color-placeholder);content:attr(data-placeholder);color:var(--txt-03);font-size:14px;font-weight:500;line-height:20px}.pl-file-input__stats{white-space:nowrap;z-index:1;font-size:11px;font-weight:600;letter-spacing:.44px;text-transform:uppercase;color:var(--txt-03)}.pl-file-input label{display:flex;align-items:center;gap:4px;position:absolute;top:0;transform:translateY(-60%);left:var(--label-offset-left-x);padding:0 4px;max-width:calc(100% - 16px);overflow:hidden;white-space:pre;text-overflow:ellipsis;cursor:inherit;color:var(--label-color);font-size:12px;font-weight:500;border-bottom-right-radius:4px;border-bottom-left-radius:4px;background:var(--bg-elevated-01)}.pl-file-input label>span{overflow:hidden;white-space:pre;text-overflow:ellipsis}.pl-file-input__contour{position:absolute;top:0;left:0;right:0;bottom:0;border-radius:var(--border-radius-control);border-width:var(--contour-border-width);border-color:var(--contour-color);border-style:solid;box-shadow:var(--contour-box-shadow);z-index:0;pointer-events:none}.pl-file-input__prefix{padding-left:12px;white-space:nowrap;margin-right:-12px;color:var(--prefix-color)}.pl-file-input__helper{font-size:12px;color:var(--txt-03);padding:2px 0 0;white-space:pre-wrap;text-overflow:ellipsis;font-weight:500;line-height:16px;margin-top:6px}.pl-file-input__error{font-size:12px;color:var(--txt-error);padding:2px 0 0;white-space:pre-wrap;text-overflow:ellipsis;font-weight:500;line-height:16px;margin-top:6px}.pl-file-input:hover{--contour-color: var(--control-hover-color)}.pl-file-input:focus-within:not(.error){--label-color: var(--txt-focus);--contour-color: var(--border-color-focus);--contour-border-width: 2px;--contour-box-shadow: 0 0 0 4px var(--border-color-focus-shadow)}.pl-file-input:focus-within.error{--contour-border-width: 2px;--contour-box-shadow: 0 0 0 4px var(--color-error-shadow)}.pl-file-input.dashed .pl-file-input__contour{border-style:dashed}.pl-file-input.nonEmpty{--prefix-color: var(--txt-01)}.pl-file-input.error{--contour-color: var(--txt-error);--label-color: var(--txt-error);--text-color: var(--txt-error);--icon-color: var(--txt-error)}.pl-file-input.error .pl-file-input__progress{display:none}.pl-file-input.disabled{--contour-color: var(--color-dis-01);cursor:not-allowed}.pl-file-input__cell-style{--border-radius-control: 0px;--input-active-color: var(--bg-base-light);--border-color: var(--border-color-div-grey);background-color:var(--input-active-color);padding:4px;height:100%;position:relative}.pl-file-input__cell-style .mask-paper-clip{display:none}.pl-file-input__cell-style .pl-file-input{height:100%!important;position:unset}.pl-file-input__cell-style .pl-file-input .double-contour{top:2px;right:2px;bottom:2px;left:2px}.pl-file-input__cell-style .pl-file-input__contour{border-width:1px;box-shadow:unset!important;border-color:var(--border-color);border-style:dashed}.pl-file-input__cell-style .pl-file-input__filename{text-align:center!important}.pl-file-input__cell-style .pl-file-input__error{margin-top:0;margin-right:8px}.pl-file-input__cell-style:hover{--border-color: var(--border-color-focus);background-color:#d9f8ca}.pl-file-input__cell-style:hover .pl-file-input__filename:before{color:#110529!important}.pl-file-input__cell-style.has-file:hover{background-color:var(--input-active-color)}.pl-file-input__cell-style.has-file{padding-left:0;padding-right:0}.pl-file-input__cell-style.has-file .pl-file-input__contour{border:unset}.pl-file-input__cell-style.has-file .pl-file-input__filename{text-align:left!important}.pl-file-input__cell-style.has-file .mask-paper-clip{display:block}
|
|
69
69
|
.pl-notification-alert{padding:12px;position:relative;border-radius:6px;border:1px solid var(--border-color-default);min-height:40px;width:256px;max-height:100%;overflow:auto}.pl-notification-alert .ui-btn-ghost{position:absolute;right:0;top:0}.pl-notification-alert__close{width:32px;min-width:28px}.pl-notification-alert__close .pl-btn-ghost{position:absolute;top:0;right:0;width:40px!important;height:40px!important}.pl-notification-alert__wrapper{flex-grow:1;overflow:auto}.pl-notification-alert.neutral{background:var(--notification-neutral)}.pl-notification-alert.error{background:var(--notification-error)}.pl-notification-alert.success{background:var(--notification-success)}.pl-notification-alert.warning{background:var(--notification-warning)}`)), document.head.appendChild(w);
|
|
70
70
|
}
|
|
71
71
|
} catch (p) {
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { defineComponent as M, reactive as P, useSlots as j, computed as i, watch as I, ref as q, createElementBlock as n, openBlock as o, Fragment as S, createElementVNode as u, createVNode as D, normalizeClass as B, createCommentVNode as s, withModifiers as N, withKeys as H, createBlock as p, normalizeStyle as K, toDisplayString as c, unref as r, withCtx as L, renderSlot as Q, createTextVNode as R } from "vue";
|
|
2
|
-
import
|
|
3
|
-
import Y from "../PlFileDialog/PlFileDialog.vue.js";
|
|
4
|
-
import f from "../PlIcon24/PlIcon24.vue.js";
|
|
2
|
+
import { prettyBytes as x } from "../../lib/util/helpers/dist/index.js";
|
|
5
3
|
import "../../sdk/model/dist/index.js";
|
|
4
|
+
import U from "../../generated/components/svg/images/SvgRequired.vue2.js";
|
|
5
|
+
import { getErrorMessage as Y } from "../../helpers/error.js";
|
|
6
6
|
import A from "../../utils/DoubleContour.vue.js";
|
|
7
7
|
import { useLabelNotch as G } from "../../utils/useLabelNotch.js";
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
8
|
+
import J from "../PlFileDialog/PlFileDialog.vue.js";
|
|
9
|
+
import f from "../PlIcon24/PlIcon24.vue.js";
|
|
10
|
+
import W from "../PlTooltip/PlTooltip.vue.js";
|
|
11
11
|
import { getFileNameFromHandle as X, getFilePathFromHandle as Z } from "../../lib/model/common/dist/index.js";
|
|
12
12
|
(function() {
|
|
13
13
|
try {
|
|
14
14
|
if (typeof document < "u") {
|
|
15
15
|
var h = document.createElement("style");
|
|
16
|
-
h.appendChild(document.createTextNode(".pl-file-input{--contour-color: var(--txt-01);--label-color: var(--txt-01);--text-color: var(--txt-01);--contour-border-width: 1px;--contour-box-shadow: none;--label-offset-left-x: 8px;--label-offset-right-x: 8px;--prefix-color: var(--color-placeholder);--contour-offset: 2px;--icon-color: #000;width:100%;height:var(--control-height, 40px);
|
|
16
|
+
h.appendChild(document.createTextNode(".pl-file-input{--contour-color: var(--txt-01);--label-color: var(--txt-01);--text-color: var(--txt-01);--contour-border-width: 1px;--contour-box-shadow: none;--label-offset-left-x: 8px;--label-offset-right-x: 8px;--prefix-color: var(--color-placeholder);--contour-offset: 2px;--icon-color: #000;position:relative;z-index:0;width:100%;height:var(--control-height, 40px);border-radius:var(--border-radius-control);display:flex;flex-direction:row;align-items:center;outline:none;padding:0 8px;gap:8px;cursor:pointer}.pl-file-input__envelope{font-family:var(--font-family-base);display:flex;flex-direction:column;min-width:160px}.pl-file-input .mask-24{display:block;min-width:24px}.pl-file-input .mask-close{cursor:pointer}.pl-file-input__progress{position:absolute;z-index:-1;top:0;bottom:0;left:0;right:0;background:linear-gradient(90deg,#fff,#d8fac8);pointer-events:none;width:0}.pl-file-input__clear{--icon-color: var(--ic-02)}.pl-file-input__filename{width:100%;border:none;font-size:inherit;background-color:transparent;color:var(--text-color);caret-color:var(--border-color-focus);z-index:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:18px}.pl-file-input__filename:empty:before{color:var(--color-placeholder);content:attr(data-placeholder);color:var(--txt-03);font-size:14px;font-weight:500;line-height:20px}.pl-file-input__stats{white-space:nowrap;z-index:1;font-size:11px;font-weight:600;letter-spacing:.44px;text-transform:uppercase;color:var(--txt-03)}.pl-file-input label{display:flex;align-items:center;gap:4px;position:absolute;top:0;transform:translateY(-60%);left:var(--label-offset-left-x);padding:0 4px;max-width:calc(100% - 16px);overflow:hidden;white-space:pre;text-overflow:ellipsis;cursor:inherit;color:var(--label-color);font-size:12px;font-weight:500;border-bottom-right-radius:4px;border-bottom-left-radius:4px;background:var(--bg-elevated-01)}.pl-file-input label>span{overflow:hidden;white-space:pre;text-overflow:ellipsis}.pl-file-input__contour{position:absolute;top:0;left:0;right:0;bottom:0;border-radius:var(--border-radius-control);border-width:var(--contour-border-width);border-color:var(--contour-color);border-style:solid;box-shadow:var(--contour-box-shadow);z-index:0;pointer-events:none}.pl-file-input__prefix{padding-left:12px;white-space:nowrap;margin-right:-12px;color:var(--prefix-color)}.pl-file-input__helper{font-size:12px;color:var(--txt-03);padding:2px 0 0;white-space:pre-wrap;text-overflow:ellipsis;font-weight:500;line-height:16px;margin-top:6px}.pl-file-input__error{font-size:12px;color:var(--txt-error);padding:2px 0 0;white-space:pre-wrap;text-overflow:ellipsis;font-weight:500;line-height:16px;margin-top:6px}.pl-file-input:hover{--contour-color: var(--control-hover-color)}.pl-file-input:focus-within:not(.error){--label-color: var(--txt-focus);--contour-color: var(--border-color-focus);--contour-border-width: 2px;--contour-box-shadow: 0 0 0 4px var(--border-color-focus-shadow)}.pl-file-input:focus-within.error{--contour-border-width: 2px;--contour-box-shadow: 0 0 0 4px var(--color-error-shadow)}.pl-file-input.dashed .pl-file-input__contour{border-style:dashed}.pl-file-input.nonEmpty{--prefix-color: var(--txt-01)}.pl-file-input.error{--contour-color: var(--txt-error);--label-color: var(--txt-error);--text-color: var(--txt-error);--icon-color: var(--txt-error)}.pl-file-input.error .pl-file-input__progress{display:none}.pl-file-input.disabled{--contour-color: var(--color-dis-01);cursor:not-allowed}.pl-file-input__cell-style{--border-radius-control: 0px;--input-active-color: var(--bg-base-light);--border-color: var(--border-color-div-grey);background-color:var(--input-active-color);padding:4px;height:100%;position:relative}.pl-file-input__cell-style .mask-paper-clip{display:none}.pl-file-input__cell-style .pl-file-input{height:100%!important;position:unset}.pl-file-input__cell-style .pl-file-input .double-contour{top:2px;right:2px;bottom:2px;left:2px}.pl-file-input__cell-style .pl-file-input__contour{border-width:1px;box-shadow:unset!important;border-color:var(--border-color);border-style:dashed}.pl-file-input__cell-style .pl-file-input__filename{text-align:center!important}.pl-file-input__cell-style .pl-file-input__error{margin-top:0;margin-right:8px}.pl-file-input__cell-style:hover{--border-color: var(--border-color-focus);background-color:#d9f8ca}.pl-file-input__cell-style:hover .pl-file-input__filename:before{color:#110529!important}.pl-file-input__cell-style.has-file:hover{background-color:var(--input-active-color)}.pl-file-input__cell-style.has-file{padding-left:0;padding-right:0}.pl-file-input__cell-style.has-file .pl-file-input__contour{border:unset}.pl-file-input__cell-style.has-file .pl-file-input__filename{text-align:left!important}.pl-file-input__cell-style.has-file .mask-paper-clip{display:block}")), document.head.appendChild(h);
|
|
17
17
|
}
|
|
18
18
|
} catch (v) {
|
|
19
19
|
console.error("vite-plugin-css-injected-by-js", v);
|
|
@@ -59,7 +59,7 @@ const ee = {
|
|
|
59
59
|
} catch (d) {
|
|
60
60
|
return a.error = d instanceof Error ? d.message : String(d), e;
|
|
61
61
|
}
|
|
62
|
-
}, y = i(() => b(l.modelValue, X)), w = i(() => b(l.modelValue, Z)), O = i(() => l.progress && !l.progress.done), E = i(() => l.progress && l.progress.done), k = i(() =>
|
|
62
|
+
}, y = i(() => b(l.modelValue, X)), w = i(() => b(l.modelValue, Z)), O = i(() => l.progress && !l.progress.done), E = i(() => l.progress && l.progress.done), k = i(() => Y(a.error, l.error)), m = i(() => typeof k.value == "string"), V = i(() => {
|
|
63
63
|
const { status: e, done: t } = l.progress ?? {};
|
|
64
64
|
return !e || !e.bytesTotal ? "" : e.bytesProcessed && !t ? x(e.bytesProcessed, {}) + " / " + x(e.bytesTotal, {}) : x(e.bytesTotal, {});
|
|
65
65
|
}), T = i(() => {
|
|
@@ -96,9 +96,9 @@ const ee = {
|
|
|
96
96
|
class: "pl-file-input__progress"
|
|
97
97
|
}, null, 4),
|
|
98
98
|
!e.cellStyle && e.label ? (o(), n("label", ee, [
|
|
99
|
-
e.required ? (o(), p(
|
|
99
|
+
e.required ? (o(), p(U, { key: 0 })) : s("", !0),
|
|
100
100
|
u("span", null, c(e.label), 1),
|
|
101
|
-
r(_).tooltip || w.value ? (o(), p(r(
|
|
101
|
+
r(_).tooltip || w.value ? (o(), p(r(W), {
|
|
102
102
|
key: 1,
|
|
103
103
|
class: "info",
|
|
104
104
|
position: "top"
|
|
@@ -139,7 +139,7 @@ const ee = {
|
|
|
139
139
|
], 34),
|
|
140
140
|
m.value ? (o(), n("div", te, c(k.value), 1)) : e.helper ? (o(), n("div", re, c(e.helper), 1)) : s("", !0)
|
|
141
141
|
], 2),
|
|
142
|
-
D(r(
|
|
142
|
+
D(r(J), {
|
|
143
143
|
modelValue: a.fileDialogOpen,
|
|
144
144
|
"onUpdate:modelValue": t[0] || (t[0] = (d) => a.fileDialogOpen = d),
|
|
145
145
|
"close-on-outside-click": e.fileDialogCloseOnOutsideClick,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlFileInput.vue.js","sources":["../../../../../../../../../lib/ui/uikit/src/components/PlFileInput/PlFileInput.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport
|
|
1
|
+
{"version":3,"file":"PlFileInput.vue.js","sources":["../../../../../../../../../lib/ui/uikit/src/components/PlFileInput/PlFileInput.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { prettyBytes } from '@milaboratories/helpers';\nimport type { ImportFileHandle, ImportProgress } from '@platforma-sdk/model';\nimport { getFileNameFromHandle, getFilePathFromHandle } from '@platforma-sdk/model';\nimport { computed, reactive, ref, useSlots, watch } from 'vue';\nimport SvgRequired from '../../generated/components/svg/images/SvgRequired.vue';\nimport { getErrorMessage } from '../../helpers/error.ts';\nimport type { ImportedFiles } from '../../types';\nimport DoubleContour from '../../utils/DoubleContour.vue';\nimport { useLabelNotch } from '../../utils/useLabelNotch';\nimport { PlFileDialog } from '../PlFileDialog';\nimport { PlMaskIcon24 } from '../PlMaskIcon24';\nimport { PlTooltip } from '../PlTooltip';\nimport './pl-file-input.scss';\n\nconst data = reactive({\n fileDialogOpen: false,\n error: undefined as undefined | string,\n});\n\nconst slots = useSlots();\n\nconst emit = defineEmits<{\n (e: 'update:modelValue', value: ImportFileHandle | undefined): void;\n}>();\n\nconst props = withDefaults(\n defineProps<{\n /**\n * The current import file handle.\n */\n modelValue: ImportFileHandle | undefined;\n /**\n * The label to display above the input field.\n */\n label?: string;\n /**\n * If `true`, the input field is marked as required.\n */\n required?: boolean;\n /**\n * If `true`, the component border is dashed.\n */\n dashed?: boolean;\n /**\n * Allowed file extensions (should start with `.`)\n */\n extensions?: string[];\n /**\n * Placeholder text\n */\n placeholder?: string;\n /**\n * Import/Upload progress\n */\n progress?: ImportProgress;\n /**\n * An error message to display below the input field.\n */\n error?: unknown;\n /**\n * A helper text to display below the input field when there are no errors.\n */\n helper?: string;\n /**\n * Remove rounded border and change styles\n */\n cellStyle?: boolean;\n /**\n * File dialog title\n */\n fileDialogTitle?: string;\n /**\n * If `true`, the file dialog window closes when clicking outside the modal area (default: `true`)\n */\n fileDialogCloseOnOutsideClick?: boolean;\n }>(),\n {\n label: undefined,\n extensions: undefined,\n fileDialogTitle: undefined,\n placeholder: undefined,\n progress: undefined,\n error: undefined,\n helper: undefined,\n cellStyle: false,\n fileDialogCloseOnOutsideClick: true,\n },\n);\n\nconst tryValue = <T extends ImportFileHandle>(v: T | undefined, cb: (v: T) => string | undefined) => {\n if (!v) {\n return undefined;\n }\n\n try {\n return cb(v);\n } catch (err) {\n data.error = err instanceof Error ? err.message : String(err);\n return v;\n }\n};\n\nconst fileName = computed(() => tryValue(props.modelValue, getFileNameFromHandle));\n\nconst filePath = computed(() => tryValue(props.modelValue, getFilePathFromHandle));\n\nconst isUploading = computed(() => props.progress && !props.progress.done);\n\nconst isUploaded = computed(() => props.progress && props.progress.done);\n\nconst computedErrorMessage = computed(() => getErrorMessage(data.error, props.error));\n\nconst hasErrors = computed(() => typeof computedErrorMessage.value === 'string');\n\nconst uploadStats = computed(() => {\n const { status, done } = props.progress ?? {};\n\n if (!status || !status.bytesTotal) {\n return '';\n }\n\n if (status.bytesProcessed && !done) {\n return prettyBytes(status.bytesProcessed, {}) + ' / ' + prettyBytes(status.bytesTotal, {});\n }\n\n return prettyBytes(status.bytesTotal, {});\n});\n\nconst progressStyle = computed(() => {\n const { progress } = props;\n\n if (!progress) {\n return {};\n }\n\n return {\n width: progress.done ? '100%' : Math.round((progress.status?.progress ?? 0) * 100) + '%',\n };\n});\n\nconst openFileDialog = () => {\n data.fileDialogOpen = true;\n};\n\nconst onImport = (v: ImportedFiles) => {\n if (v.files.length) {\n emit('update:modelValue', v.files[0]);\n }\n};\n\nconst clear = () => emit('update:modelValue', undefined);\n\nwatch(\n () => props.modelValue,\n () => (data.error = undefined),\n { immediate: true },\n);\n\nconst rootRef = ref();\n\nif (!props.cellStyle) {\n useLabelNotch(rootRef);\n}\n</script>\n\n<template>\n <div :class=\"{ 'pl-file-input__cell-style': !!cellStyle, 'has-file': !!fileName }\" class=\"pl-file-input__envelope\">\n <div\n ref=\"rootRef\"\n :class=\"{ dashed, error: hasErrors }\"\n class=\"pl-file-input\"\n tabindex=\"0\"\n @keyup.enter=\"openFileDialog\"\n @click.stop=\"openFileDialog\"\n >\n <div :style=\"progressStyle\" class=\"pl-file-input__progress\" />\n <label v-if=\"!cellStyle && label\" ref=\"label\">\n <SvgRequired v-if=\"required\" />\n <span>{{ label }}</span>\n <PlTooltip v-if=\"slots.tooltip || filePath\" class=\"info\" position=\"top\">\n <template #tooltip>\n <slot v-if=\"slots.tooltip\" name=\"tooltip\" />\n <template v-else>{{ filePath }}</template>\n </template>\n </PlTooltip>\n </label>\n <PlMaskIcon24 v-if=\"hasErrors\" name=\"restart\" />\n <PlMaskIcon24 v-else-if=\"isUploading\" name=\"cloud-upload\" />\n <PlMaskIcon24 v-else-if=\"isUploaded\" name=\"success\" />\n <PlMaskIcon24 v-else name=\"paper-clip\" />\n <div :data-placeholder=\"placeholder ?? 'Choose file'\" class=\"pl-file-input__filename\">\n {{ fileName }}\n </div>\n <div v-if=\"uploadStats\" class=\"pl-file-input__stats\">{{ uploadStats }}</div>\n <PlMaskIcon24 v-if=\"modelValue\" class=\"pl-file-input__clear\" name=\"close\" @click.stop=\"clear\" />\n <DoubleContour class=\"pl-file-input__contour\" />\n </div>\n <div v-if=\"hasErrors\" class=\"pl-file-input__error\">\n {{ computedErrorMessage }}\n </div>\n <div v-else-if=\"helper\" class=\"pl-file-input__helper\">{{ helper }}</div>\n </div>\n <PlFileDialog\n v-model=\"data.fileDialogOpen\"\n :close-on-outside-click=\"fileDialogCloseOnOutsideClick\"\n :extensions=\"extensions\"\n :title=\"fileDialogTitle\"\n @import:files=\"onImport\"\n />\n</template>\n"],"names":["N","T","K","useSlots","v","err","data","k","s","props","h","o","x","E","P","V","J","b","status","computed","y","t","e","progress","openFileDialog","emit","clear","watch","U","useLabelNotch"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAeA,MAAAA,WAAsBC,EAAA,GAAA;AAAA,UACJ,IAAAC,EAAA;AAAA,MAChB,gBAAO;AAAA,MACR,OAEaC;AAA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IAAAA,MAAAA,EAAAA,qBAAAA,MAAAA;AAAAC,IAAAA;AAAAA,MAEE,MAAOtB,EAAK;AAAA,MACZ,gBAAkB;AAAA,MACpB,EAAA,WAAA,GAAA;AAAA,IAEA;AAEKG,UAAAA,IACHoB,EAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -56,7 +56,7 @@ import "../../colors/gradient.js";
|
|
|
56
56
|
.ui-text-area{--contour-color: var(--txt-01);--label-color: var(--txt-01);--contour-border-width: 1px;--contour-box-shadow: none;--label-offset-left-x: 8px;--label-offset-right-x: 8px;--prefix-color: var(--color-placeholder);width:100%;min-height:var(--control-height);position:relative;border-radius:var(--border-radius-control);display:flex;flex-direction:row;align-items:center;outline:none}.ui-text-area__envelope{font-family:var(--font-family-base)}.ui-text-area textarea{min-height:calc(var(--control-height) - 2px);width:100%;padding:10px 12px;border:none;font-size:inherit;background-color:transparent;color:var(--txt-01);caret-color:var(--border-color-focus);cursor:inherit;resize:none;--thumb-color: var(--ic-02);overflow-y:auto}.ui-text-area textarea::-webkit-scrollbar{width:var(--scrollbar-width, 6px);height:5px;background-color:transparent;display:block}.ui-text-area textarea::-webkit-scrollbar-thumb{background:var(--thumb-color);border-radius:5px}.ui-text-area textarea::-webkit-scrollbar-thumb:hover{--thumb-color: var(--border-color-focus)}.ui-text-area textarea:focus{outline:none}.ui-text-area textarea::placeholder{color:var(--color-placeholder)}.ui-text-area label{display:flex;align-items:center;gap:4px;position:absolute;top:0;transform:translateY(-60%);left:var(--label-offset-left-x);padding:0 4px;max-width:calc(100% - 16px);overflow:hidden;white-space:pre;text-overflow:ellipsis;cursor:inherit;color:var(--label-color);font-size:12px;font-weight:500;border-bottom-right-radius:4px;border-bottom-left-radius:4px;background:var(--bg-elevated-01)}.ui-text-area label>span{overflow:hidden;white-space:pre;text-overflow:ellipsis}.ui-text-area__contour{position:absolute;top:0;left:0;right:0;bottom:0;border-radius:var(--border-radius-control);border-width:var(--contour-border-width);border-color:var(--contour-color);border-style:solid;box-shadow:var(--contour-box-shadow);z-index:0;pointer-events:none}.ui-text-area__append{display:flex;flex-direction:row;align-items:center;gap:4px}.ui-text-area__helper{font-size:12px;color:var(--txt-03);padding:2px 0 0;white-space:pre-wrap;text-overflow:ellipsis;font-weight:500;line-height:16px;margin-top:6px}.ui-text-area__error{font-size:12px;color:var(--txt-error);padding:2px 0 0;white-space:pre-wrap;text-overflow:ellipsis;font-weight:500;line-height:16px;margin-top:6px}.ui-text-area:hover{--contour-color: var(--control-hover-color)}.ui-text-area:focus-within:not(.error){--label-color: var(--txt-focus);--contour-color: var(--border-color-focus);--contour-border-width: 2px;--contour-box-shadow: 0 0 0 4px var(--border-color-focus-shadow)}.ui-text-area:focus-within.error{--contour-border-width: 2px;--contour-box-shadow: 0 0 0 4px var(--color-error-shadow)}.ui-text-area.dashed .ui-text-area__contour{border-style:dashed}.ui-text-area.nonEmpty{--prefix-color: var(--txt-01)}.ui-text-area.error{--contour-color: var(--txt-error)}.ui-text-area.disabled{--contour-color: var(--color-dis-01);cursor:not-allowed;pointer-events:none}.ui-text-area.disabled *{color:var(--contour-color)}
|
|
57
57
|
.pl-text-field{--pl-text-field-text-color: var(--txt-01);--contour-color: var(--txt-01);--label-color: var(--txt-01);--contour-border-width: 1px;--contour-box-shadow: none;--label-offset-left-x: 8px;--label-offset-right-x: 8px;--prefix-color: var(--color-placeholder);--show-clearable: none;width:100%;min-width:160px;min-height:var(--control-height);position:relative;border-radius:var(--border-radius-control);display:flex;flex-direction:row;align-items:center;outline:none}.pl-text-field__envelope{font-family:var(--font-family-base)}.pl-text-field input{font-family:var(--font-family-base);font-weight:500;min-height:calc(var(--control-height) - 2px);line-height:20px;width:100%;padding:0 12px;border:none;font-size:inherit;background-color:transparent;color:var(--pl-text-field-text-color);caret-color:var(--border-color-focus);cursor:inherit}.pl-text-field input:focus{outline:none}.pl-text-field input::placeholder{color:var(--color-placeholder)}.pl-text-field label{display:flex;align-items:center;gap:4px;position:absolute;top:0;transform:translateY(-60%);left:var(--label-offset-left-x);padding:0 4px;max-width:calc(100% - 16px);overflow:hidden;white-space:pre;text-overflow:ellipsis;cursor:inherit;color:var(--label-color);font-size:12px;font-weight:500;border-bottom-right-radius:4px;border-bottom-left-radius:4px;background:var(--bg-elevated-01)}.pl-text-field label>span{overflow:hidden;white-space:pre;text-overflow:ellipsis}.pl-text-field__contour{position:absolute;top:0;left:0;right:0;bottom:0;border-radius:var(--border-radius-control);border-width:var(--contour-border-width);border-color:var(--contour-color);border-style:solid;box-shadow:var(--contour-box-shadow);z-index:0;pointer-events:none}.pl-text-field__prefix{padding-left:12px;white-space:nowrap;margin-right:-12px;color:var(--prefix-color)}.pl-text-field__append{padding-right:12px;display:flex;flex-direction:row;align-items:center;gap:4px;cursor:text}.pl-text-field__append .icon-16{cursor:pointer}.pl-text-field__append .mask-16{--icon-color: var(--control-mask-fill);cursor:pointer}.pl-text-field__clearable{display:var(--show-clearable)!important;--icon-color: var(--ic-02) !important}.pl-text-field__helper{font-size:12px;color:var(--txt-03);padding:2px 0 0;white-space:pre-wrap;text-overflow:ellipsis;font-weight:500;line-height:16px;margin-top:6px}.pl-text-field__error{font-size:12px;color:var(--txt-error);padding:2px 0 0;white-space:pre-wrap;text-overflow:ellipsis;font-weight:500;line-height:16px;margin-top:6px}.pl-text-field:hover{--contour-color: var(--control-hover-color);--show-clearable: inline-block}.pl-text-field:focus-within{--show-clearable: inline-block}.pl-text-field:focus-within:not(.error){--label-color: var(--txt-focus);--contour-color: var(--border-color-focus);--contour-border-width: 2px;--contour-box-shadow: 0 0 0 4px var(--border-color-focus-shadow)}.pl-text-field:focus-within.error{--contour-border-width: 2px;--contour-box-shadow: 0 0 0 4px var(--color-error-shadow)}.pl-text-field.dashed .pl-text-field__contour{border-style:dashed}.pl-text-field.nonEmpty{--prefix-color: var(--txt-01)}.pl-text-field.error{--contour-color: var(--txt-error);--label-color: var(--txt-error)}.pl-text-field.disabled{--contour-color: var(--color-dis-01);--label-color: var(--dis-01);--pl-text-field-text-color: var(--dis-01);--mask-icon-bg-color: var(--dis-01);cursor:not-allowed}
|
|
58
58
|
.ui-toggle-switch{--handle-ml: 0;--body-bg: var(--bg-base-light);--body-shadow: var(--btn-group-shape-shadow);display:flex;align-items:center;gap:12px;outline:none}.ui-toggle-switch__body{width:40px;height:24px;display:flex;padding:5px;border-radius:12px;border:1px solid var(--color-ic-01);box-shadow:var(--body-shadow);background:var(--body-bg);cursor:pointer}.ui-toggle-switch__handle{width:12px;height:12px;border-radius:12px;border:1px solid var(--color-ic-01);background:var(--color-ic-00);margin-left:var(--handle-ml)}.ui-toggle-switch.active{--body-bg: var(--btn-switcher-bg);--handle-ml: auto}.ui-toggle-switch:focus-visible{--label-color: var(--txt-focus);--body-shadow: var(--btn-group-shape-shadow), 0 0 0 2px #fff, 0 0 0 4px var(--border-color-focus)}
|
|
59
|
-
.pl-file-input{--contour-color: var(--txt-01);--label-color: var(--txt-01);--text-color: var(--txt-01);--contour-border-width: 1px;--contour-box-shadow: none;--label-offset-left-x: 8px;--label-offset-right-x: 8px;--prefix-color: var(--color-placeholder);--contour-offset: 2px;--icon-color: #000;width:100%;height:var(--control-height, 40px);
|
|
59
|
+
.pl-file-input{--contour-color: var(--txt-01);--label-color: var(--txt-01);--text-color: var(--txt-01);--contour-border-width: 1px;--contour-box-shadow: none;--label-offset-left-x: 8px;--label-offset-right-x: 8px;--prefix-color: var(--color-placeholder);--contour-offset: 2px;--icon-color: #000;position:relative;z-index:0;width:100%;height:var(--control-height, 40px);border-radius:var(--border-radius-control);display:flex;flex-direction:row;align-items:center;outline:none;padding:0 8px;gap:8px;cursor:pointer}.pl-file-input__envelope{font-family:var(--font-family-base);display:flex;flex-direction:column;min-width:160px}.pl-file-input .mask-24{display:block;min-width:24px}.pl-file-input .mask-close{cursor:pointer}.pl-file-input__progress{position:absolute;z-index:-1;top:0;bottom:0;left:0;right:0;background:linear-gradient(90deg,#fff,#d8fac8);pointer-events:none;width:0}.pl-file-input__clear{--icon-color: var(--ic-02)}.pl-file-input__filename{width:100%;border:none;font-size:inherit;background-color:transparent;color:var(--text-color);caret-color:var(--border-color-focus);z-index:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:18px}.pl-file-input__filename:empty:before{color:var(--color-placeholder);content:attr(data-placeholder);color:var(--txt-03);font-size:14px;font-weight:500;line-height:20px}.pl-file-input__stats{white-space:nowrap;z-index:1;font-size:11px;font-weight:600;letter-spacing:.44px;text-transform:uppercase;color:var(--txt-03)}.pl-file-input label{display:flex;align-items:center;gap:4px;position:absolute;top:0;transform:translateY(-60%);left:var(--label-offset-left-x);padding:0 4px;max-width:calc(100% - 16px);overflow:hidden;white-space:pre;text-overflow:ellipsis;cursor:inherit;color:var(--label-color);font-size:12px;font-weight:500;border-bottom-right-radius:4px;border-bottom-left-radius:4px;background:var(--bg-elevated-01)}.pl-file-input label>span{overflow:hidden;white-space:pre;text-overflow:ellipsis}.pl-file-input__contour{position:absolute;top:0;left:0;right:0;bottom:0;border-radius:var(--border-radius-control);border-width:var(--contour-border-width);border-color:var(--contour-color);border-style:solid;box-shadow:var(--contour-box-shadow);z-index:0;pointer-events:none}.pl-file-input__prefix{padding-left:12px;white-space:nowrap;margin-right:-12px;color:var(--prefix-color)}.pl-file-input__helper{font-size:12px;color:var(--txt-03);padding:2px 0 0;white-space:pre-wrap;text-overflow:ellipsis;font-weight:500;line-height:16px;margin-top:6px}.pl-file-input__error{font-size:12px;color:var(--txt-error);padding:2px 0 0;white-space:pre-wrap;text-overflow:ellipsis;font-weight:500;line-height:16px;margin-top:6px}.pl-file-input:hover{--contour-color: var(--control-hover-color)}.pl-file-input:focus-within:not(.error){--label-color: var(--txt-focus);--contour-color: var(--border-color-focus);--contour-border-width: 2px;--contour-box-shadow: 0 0 0 4px var(--border-color-focus-shadow)}.pl-file-input:focus-within.error{--contour-border-width: 2px;--contour-box-shadow: 0 0 0 4px var(--color-error-shadow)}.pl-file-input.dashed .pl-file-input__contour{border-style:dashed}.pl-file-input.nonEmpty{--prefix-color: var(--txt-01)}.pl-file-input.error{--contour-color: var(--txt-error);--label-color: var(--txt-error);--text-color: var(--txt-error);--icon-color: var(--txt-error)}.pl-file-input.error .pl-file-input__progress{display:none}.pl-file-input.disabled{--contour-color: var(--color-dis-01);cursor:not-allowed}.pl-file-input__cell-style{--border-radius-control: 0px;--input-active-color: var(--bg-base-light);--border-color: var(--border-color-div-grey);background-color:var(--input-active-color);padding:4px;height:100%;position:relative}.pl-file-input__cell-style .mask-paper-clip{display:none}.pl-file-input__cell-style .pl-file-input{height:100%!important;position:unset}.pl-file-input__cell-style .pl-file-input .double-contour{top:2px;right:2px;bottom:2px;left:2px}.pl-file-input__cell-style .pl-file-input__contour{border-width:1px;box-shadow:unset!important;border-color:var(--border-color);border-style:dashed}.pl-file-input__cell-style .pl-file-input__filename{text-align:center!important}.pl-file-input__cell-style .pl-file-input__error{margin-top:0;margin-right:8px}.pl-file-input__cell-style:hover{--border-color: var(--border-color-focus);background-color:#d9f8ca}.pl-file-input__cell-style:hover .pl-file-input__filename:before{color:#110529!important}.pl-file-input__cell-style.has-file:hover{background-color:var(--input-active-color)}.pl-file-input__cell-style.has-file{padding-left:0;padding-right:0}.pl-file-input__cell-style.has-file .pl-file-input__contour{border:unset}.pl-file-input__cell-style.has-file .pl-file-input__filename{text-align:left!important}.pl-file-input__cell-style.has-file .mask-paper-clip{display:block}
|
|
60
60
|
.pl-notification-alert{padding:12px;position:relative;border-radius:6px;border:1px solid var(--border-color-default);min-height:40px;width:256px;max-height:100%;overflow:auto}.pl-notification-alert .ui-btn-ghost{position:absolute;right:0;top:0}.pl-notification-alert__close{width:32px;min-width:28px}.pl-notification-alert__close .pl-btn-ghost{position:absolute;top:0;right:0;width:40px!important;height:40px!important}.pl-notification-alert__wrapper{flex-grow:1;overflow:auto}.pl-notification-alert.neutral{background:var(--notification-neutral)}.pl-notification-alert.error{background:var(--notification-error)}.pl-notification-alert.success{background:var(--notification-success)}.pl-notification-alert.warning{background:var(--notification-warning)}`)), document.head.appendChild(o);
|
|
61
61
|
}
|
|
62
62
|
} catch (e) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platforma-sdk/ui-vue",
|
|
3
|
-
"version": "1.41.
|
|
3
|
+
"version": "1.41.17",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/lib.js",
|
|
6
6
|
"styles": "dist/lib.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"d3-format": "^3.1.0",
|
|
27
27
|
"zod": "~3.23.8",
|
|
28
28
|
"@milaboratories/biowasm-tools": "^1.1.0",
|
|
29
|
-
"@milaboratories/uikit": "2.3.
|
|
29
|
+
"@milaboratories/uikit": "2.3.22",
|
|
30
30
|
"@platforma-sdk/model": "~1.41.6"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"@faker-js/faker": "^9.2.0",
|
|
46
46
|
"@milaboratories/build-configs": "1.0.5",
|
|
47
47
|
"@milaboratories/helpers": "^1.6.19",
|
|
48
|
-
"@milaboratories/
|
|
49
|
-
"@milaboratories/
|
|
48
|
+
"@milaboratories/eslint-config": "^1.0.4",
|
|
49
|
+
"@milaboratories/ts-configs": "1.0.5"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"test": "vitest run --passWithNoTests",
|
|
@@ -3,10 +3,9 @@ import type { Mutable } from '@milaboratories/helpers';
|
|
|
3
3
|
import type { NavigationState, BlockOutputsBase, BlockState, PlatformaV2, ValueWithUTag, AuthorMarker } from '@platforma-sdk/model';
|
|
4
4
|
import { hasAbortError, unwrapResult } from '@platforma-sdk/model';
|
|
5
5
|
import type { Ref } from 'vue';
|
|
6
|
-
import { reactive, computed, ref } from 'vue';
|
|
6
|
+
import { reactive, computed, ref, watch } from 'vue';
|
|
7
7
|
import type { StateModelOptions, UnwrapOutputs, OutputValues, OutputErrors, AppSettings } from '../types';
|
|
8
8
|
import { createModel } from '../createModel';
|
|
9
|
-
import { createAppModel } from './createAppModel';
|
|
10
9
|
import { parseQuery } from '../urls';
|
|
11
10
|
import { MultiError, unwrapValueOrErrors } from '../utils';
|
|
12
11
|
import { applyPatch } from 'fast-json-patch';
|
|
@@ -43,11 +42,6 @@ export function createAppV2<
|
|
|
43
42
|
platforma: PlatformaV2<Args, Outputs, UiState, Href>,
|
|
44
43
|
settings: AppSettings,
|
|
45
44
|
) {
|
|
46
|
-
type AppModel = {
|
|
47
|
-
args: Args;
|
|
48
|
-
ui: UiState;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
45
|
const debug = (msg: string, ...rest: unknown[]) => {
|
|
52
46
|
if (settings.debug) {
|
|
53
47
|
console.log(`%c>>> %c${msg}`, 'color: orange; font-weight: bold', 'color: orange', settings.appId, ...rest);
|
|
@@ -113,6 +107,55 @@ export function createAppV2<
|
|
|
113
107
|
return platforma.setNavigationState(state);
|
|
114
108
|
};
|
|
115
109
|
|
|
110
|
+
const outputs = computed<OutputValues<Outputs>>(() => {
|
|
111
|
+
const entries = Object.entries(snapshot.value.outputs as Partial<Readonly<Outputs>>).map(([k, vOrErr]) => [k, vOrErr.ok && vOrErr.value !== undefined ? vOrErr.value : undefined]);
|
|
112
|
+
return Object.fromEntries(entries);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
const outputErrors = computed<OutputErrors<Outputs>>(() => {
|
|
116
|
+
const entries = Object.entries(snapshot.value.outputs as Partial<Readonly<Outputs>>).map(([k, vOrErr]) => [k, vOrErr && !vOrErr.ok ? new MultiError(vOrErr.errors) : undefined]);
|
|
117
|
+
return Object.fromEntries(entries);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const appModel = reactive({
|
|
121
|
+
error: '',
|
|
122
|
+
model: {
|
|
123
|
+
args: deepClone(snapshot.value.args) as Args,
|
|
124
|
+
ui: deepClone(snapshot.value.ui) as UiState,
|
|
125
|
+
outputs,
|
|
126
|
+
outputErrors,
|
|
127
|
+
},
|
|
128
|
+
}) as {
|
|
129
|
+
error: string;
|
|
130
|
+
model: {
|
|
131
|
+
args: Args;
|
|
132
|
+
ui: UiState;
|
|
133
|
+
outputs: OutputValues<Outputs>;
|
|
134
|
+
outputErrors: OutputErrors<Outputs>;
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const appModelWatch = watch(
|
|
139
|
+
() => appModel.model,
|
|
140
|
+
(_newData) => {
|
|
141
|
+
const newData = deepClone(_newData);
|
|
142
|
+
debug('appModel.model', newData);
|
|
143
|
+
setArgsAndUiStateQueue.run(() => setBlockArgsAndUiState(newData.args, newData.ui).then(unwrapResult));
|
|
144
|
+
},
|
|
145
|
+
{ deep: true },
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
const updateAppModelSilently = (newData: {
|
|
149
|
+
args: Args;
|
|
150
|
+
ui: UiState;
|
|
151
|
+
}) => {
|
|
152
|
+
debug('updateAppModelSilently', newData);
|
|
153
|
+
appModelWatch.pause();
|
|
154
|
+
appModel.model.args = deepClone(newData.args) as Args;
|
|
155
|
+
appModel.model.ui = deepClone(newData.ui) as UiState;
|
|
156
|
+
appModelWatch.resume();
|
|
157
|
+
};
|
|
158
|
+
|
|
116
159
|
(async () => {
|
|
117
160
|
window.addEventListener('beforeunload', () => {
|
|
118
161
|
closedRef.value = true;
|
|
@@ -125,7 +168,7 @@ export function createAppV2<
|
|
|
125
168
|
try {
|
|
126
169
|
const patches = await platforma.getPatches(uTagRef.value).then(unwrapResult);
|
|
127
170
|
|
|
128
|
-
debug('patches',
|
|
171
|
+
debug('patches.length', patches.value.length);
|
|
129
172
|
debug('uTagRef.value', uTagRef.value);
|
|
130
173
|
debug('patches.uTag', patches.uTag);
|
|
131
174
|
debug('patches.author', patches.author);
|
|
@@ -144,6 +187,7 @@ export function createAppV2<
|
|
|
144
187
|
if (isAuthorChanged || data.isExternalSnapshot) {
|
|
145
188
|
debug('got external changes, applying them to the snapshot', JSON.stringify(snapshot.value, null, 2));
|
|
146
189
|
snapshot.value = applyPatch(snapshot.value, patches.value, false, false).newDocument;
|
|
190
|
+
updateAppModelSilently(snapshot.value);
|
|
147
191
|
data.isExternalSnapshot = isAuthorChanged;
|
|
148
192
|
} else {
|
|
149
193
|
// Mutable behavior
|
|
@@ -163,34 +207,6 @@ export function createAppV2<
|
|
|
163
207
|
}
|
|
164
208
|
})();
|
|
165
209
|
|
|
166
|
-
const outputs = computed<OutputValues<Outputs>>(() => {
|
|
167
|
-
const entries = Object.entries(snapshot.value.outputs as Partial<Readonly<Outputs>>).map(([k, vOrErr]) => [k, vOrErr.ok && vOrErr.value !== undefined ? vOrErr.value : undefined]);
|
|
168
|
-
return Object.fromEntries(entries);
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
const outputErrors = computed<OutputErrors<Outputs>>(() => {
|
|
172
|
-
const entries = Object.entries(snapshot.value.outputs as Partial<Readonly<Outputs>>).map(([k, vOrErr]) => [k, vOrErr && !vOrErr.ok ? new MultiError(vOrErr.errors) : undefined]);
|
|
173
|
-
return Object.fromEntries(entries);
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
const appModel = createAppModel(
|
|
177
|
-
{
|
|
178
|
-
get() {
|
|
179
|
-
return { args: snapshot.value.args, ui: snapshot.value.ui } as AppModel;
|
|
180
|
-
},
|
|
181
|
-
autoSave: true,
|
|
182
|
-
onSave(newData: AppModel) {
|
|
183
|
-
debug('onSave', newData);
|
|
184
|
-
setArgsAndUiStateQueue.run(() => setBlockArgsAndUiState(newData.args, newData.ui).then(unwrapResult));
|
|
185
|
-
},
|
|
186
|
-
},
|
|
187
|
-
{
|
|
188
|
-
outputs,
|
|
189
|
-
outputErrors,
|
|
190
|
-
},
|
|
191
|
-
settings,
|
|
192
|
-
);
|
|
193
|
-
|
|
194
210
|
const cloneArgs = () => deepClone(appModel.model.args) as Args;
|
|
195
211
|
const cloneUiState = () => deepClone(appModel.model.ui) as UiState;
|
|
196
212
|
const cloneNavigationState = () => deepClone(snapshot.value.navigationState) as Mutable<NavigationState<Href>>;
|