@juo/blocks 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ExtensionRoot-sq31lwIQ.js → ExtensionRoot-BmfKKpcU.js} +3 -2
- package/dist/{theme-state-D3w_B6gQ.js → block-C8lPBCF8.js} +46 -209
- package/dist/block.d.ts +43 -1
- package/dist/block.d.ts.map +1 -1
- package/dist/{bridge-DAUIcGuq.js → bridge-BOcO9toS.js} +48 -25
- package/dist/core.js +96 -25
- package/dist/editor/bridge.d.ts.map +1 -1
- package/dist/editor/components.d.ts +12 -0
- package/dist/editor/components.d.ts.map +1 -1
- package/dist/editor/messages.d.ts +35 -3
- package/dist/editor/messages.d.ts.map +1 -1
- package/dist/editor.js +424 -36
- package/dist/flows/WorkflowService.d.ts.map +1 -1
- package/dist/{juo-workflow-BVrh5lpE.js → juo-workflow-B3OHYsp-.js} +7 -5
- package/dist/main.d.ts +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/preact/block.d.ts.map +1 -1
- package/dist/preact.js +4 -2
- package/dist/react/block.d.ts.map +1 -1
- package/dist/react.js +4 -2
- package/dist/services/subscription/adapter.d.ts +21 -3
- package/dist/services/subscription/adapter.d.ts.map +1 -1
- package/dist/services/subscription/discountErrors.d.ts +27 -0
- package/dist/services/subscription/discountErrors.d.ts.map +1 -0
- package/dist/services/subscription/index.d.ts +2 -1
- package/dist/services/subscription/index.d.ts.map +1 -1
- package/dist/services/subscription/subscriptionService.d.ts.map +1 -1
- package/dist/services/subscription/subscriptionService.test.d.ts +2 -0
- package/dist/services/subscription/subscriptionService.test.d.ts.map +1 -0
- package/dist/services/subscription/types.d.ts +11 -3
- package/dist/services/subscription/types.d.ts.map +1 -1
- package/dist/theme-state-LZS5T-Xb.js +202 -0
- package/dist/vue/block.d.ts +2 -1
- package/dist/vue/block.d.ts.map +1 -1
- package/dist/vue/setupTests.d.ts +2 -0
- package/dist/vue/setupTests.d.ts.map +1 -0
- package/dist/vue.js +7 -2
- package/dist/web-components/editor/InlineText.d.ts +2 -0
- package/dist/web-components/editor/InlineText.d.ts.map +1 -1
- package/dist/web-components/editor/InlineText.test.d.ts +2 -0
- package/dist/web-components/editor/InlineText.test.d.ts.map +1 -0
- package/dist/web-components-editor.js +16 -5
- package/dist/web-components-runtime.js +3 -3
- package/package.json +1 -1
package/dist/preact.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import { effect, injectContext, provideContext, createCeRenderer } from "@juo/blocks";
|
|
4
|
+
import { effect, injectContext, provideContext, createCeRenderer, attachEmptyTracking } from "@juo/blocks";
|
|
5
5
|
import { useState, useRef, useEffect, useContext as useContext$1, useMemo } from "preact/hooks";
|
|
6
6
|
import { g as getSignalValue, s as setSignalValue, w as wrapContext, c as createSlotChildren } from "./block-VhmfGB3N.js";
|
|
7
7
|
import { t } from "./block-VhmfGB3N.js";
|
|
8
8
|
import { createContext, h, render } from "preact";
|
|
9
|
-
import { a as createEditorBridge } from "./bridge-
|
|
9
|
+
import { a as createEditorBridge } from "./bridge-BOcO9toS.js";
|
|
10
10
|
function toState(signal) {
|
|
11
11
|
const [value, setValue] = useState(() => getSignalValue(signal));
|
|
12
12
|
const disposeRef = useRef(null);
|
|
@@ -121,6 +121,7 @@ function createPreactRenderer(component) {
|
|
|
121
121
|
return (block) => {
|
|
122
122
|
const wrapper = document.createElement("div");
|
|
123
123
|
wrapper.setAttribute("data-block-id", block.id);
|
|
124
|
+
wrapper.setAttribute("data-block-type", block.type);
|
|
124
125
|
render(
|
|
125
126
|
h(ContextProvider, {
|
|
126
127
|
children: h(
|
|
@@ -130,6 +131,7 @@ function createPreactRenderer(component) {
|
|
|
130
131
|
}),
|
|
131
132
|
wrapper
|
|
132
133
|
);
|
|
134
|
+
attachEmptyTracking(wrapper);
|
|
133
135
|
return wrapper;
|
|
134
136
|
};
|
|
135
137
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../src/react/block.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAuBjD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,GAAG,GAAG,EACzC,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,GAChC,CAAC,KAAK,EAAE,aAAa,KAAK,WAAW,
|
|
1
|
+
{"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../src/react/block.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAuBjD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,GAAG,GAAG,EACzC,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,GAChC,CAAC,KAAK,EAAE,aAAa,KAAK,WAAW,CAmCvC;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,GAAG,GAAG,EAC3C,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,EACjC,EAAE,UAAiB,EAAE,GAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAO,GACnD,CAAC,KAAK,EAAE,aAAa,KAAK,WAAW,CAyEvC"}
|
package/dist/react.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import { effect, injectContext, provideContext, createCeRenderer } from "@juo/blocks";
|
|
4
|
+
import { effect, injectContext, provideContext, createCeRenderer, attachEmptyTracking } from "@juo/blocks";
|
|
5
5
|
import React, { useSyncExternalStore, createContext, useState, useContext as useContext$1, useMemo, useRef, useEffect } from "react";
|
|
6
6
|
import { g as getSignalValue, s as setSignalValue, w as wrapContext, c as createSlotChildren } from "./block-VhmfGB3N.js";
|
|
7
7
|
import { t } from "./block-VhmfGB3N.js";
|
|
8
8
|
import { createRoot } from "react-dom/client";
|
|
9
|
-
import { a as createEditorBridge } from "./bridge-
|
|
9
|
+
import { a as createEditorBridge } from "./bridge-BOcO9toS.js";
|
|
10
10
|
function toState(signal) {
|
|
11
11
|
const subscribe = (callback) => {
|
|
12
12
|
const dispose = effect(() => {
|
|
@@ -103,6 +103,7 @@ function createReactRenderer(component) {
|
|
|
103
103
|
return (block) => {
|
|
104
104
|
const wrapper = document.createElement("div");
|
|
105
105
|
wrapper.setAttribute("data-block-id", block.id);
|
|
106
|
+
wrapper.setAttribute("data-block-type", block.type);
|
|
106
107
|
const root = createRoot(wrapper);
|
|
107
108
|
root.render(
|
|
108
109
|
React.createElement(ContextProvider, {
|
|
@@ -112,6 +113,7 @@ function createReactRenderer(component) {
|
|
|
112
113
|
)
|
|
113
114
|
})
|
|
114
115
|
);
|
|
116
|
+
attachEmptyTracking(wrapper);
|
|
115
117
|
return wrapper;
|
|
116
118
|
};
|
|
117
119
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Subscription, SellingPlan, SearchOptions, PostableSubscriptionItem } from './types';
|
|
2
|
+
import { ApplyDiscountError, DiscountRejectionReason, RemoveDiscountError } from './discountErrors';
|
|
2
3
|
import { Result, PaginatedList } from '../../utils';
|
|
3
4
|
/**
|
|
4
5
|
* Adapter interface for subscription.
|
|
@@ -18,11 +19,11 @@ export interface SubscriptionAdapter {
|
|
|
18
19
|
addDiscount(params: {
|
|
19
20
|
subscriptionId: string;
|
|
20
21
|
code: string;
|
|
21
|
-
}): Promise<Result
|
|
22
|
+
}): Promise<Result<void, ApplyDiscountError>>;
|
|
22
23
|
removeDiscount(params: {
|
|
23
24
|
subscriptionId: string;
|
|
24
25
|
discountId: string;
|
|
25
|
-
}): Promise<Result
|
|
26
|
+
}): Promise<Result<void, RemoveDiscountError>>;
|
|
26
27
|
reschedule(params: {
|
|
27
28
|
subscriptionId: string;
|
|
28
29
|
newDate: string;
|
|
@@ -45,5 +46,22 @@ export interface SubscriptionAdapter {
|
|
|
45
46
|
}): Promise<Result<SellingPlan[]>>;
|
|
46
47
|
getDefaultSubscriptionId(): Promise<Result<string | null>>;
|
|
47
48
|
}
|
|
48
|
-
export
|
|
49
|
+
export interface MockSubscriptionAdapterOptions {
|
|
50
|
+
addDiscountBehavior?: {
|
|
51
|
+
kind: "success";
|
|
52
|
+
} | {
|
|
53
|
+
kind: "rejected";
|
|
54
|
+
reason: DiscountRejectionReason;
|
|
55
|
+
} | {
|
|
56
|
+
kind: "error";
|
|
57
|
+
error: "NETWORK" | "UNKNOWN" | "SUBSCRIPTION_NOT_FOUND";
|
|
58
|
+
};
|
|
59
|
+
removeDiscountBehavior?: {
|
|
60
|
+
kind: "success";
|
|
61
|
+
} | {
|
|
62
|
+
kind: "error";
|
|
63
|
+
error: "NETWORK" | "UNKNOWN" | "SUBSCRIPTION_NOT_FOUND" | "DISCOUNT_NOT_FOUND";
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export declare function createMockSubscriptionAdapter(options?: MockSubscriptionAdapterOptions): SubscriptionAdapter;
|
|
49
67
|
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../src/services/subscription/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,WAAW,EACX,aAAa,EACb,wBAAwB,EACzB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEzD;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAE9E,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC,CAAC;IAE1D,OAAO,CAAC,MAAM,EAAE;QACd,cAAc,EAAE,MAAM,CAAC;QACvB,IAAI,EAAE,wBAAwB,CAAC;KAChC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEpB,UAAU,CAAC,MAAM,EAAE;QACjB,cAAc,EAAE,MAAM,CAAC;QACvB,MAAM,EAAE,MAAM,CAAC;KAChB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEpB,WAAW,CAAC,MAAM,EAAE;QAClB,cAAc,EAAE,MAAM,CAAC;QACvB,IAAI,EAAE,MAAM,CAAC;KACd,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../src/services/subscription/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,WAAW,EACX,aAAa,EACb,wBAAwB,EACzB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EACV,kBAAkB,EAClB,uBAAuB,EACvB,mBAAmB,EACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEzD;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAA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cAAc,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;IAE9E,MAAM,CAAC,MAAM,EAAE;QAAE,cAAc,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;IAE3F,iBAAiB,CAAC,MAAM,EAAE;QAAE,cAAc,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;IAEtF,wBAAwB,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC;CAC5D;AAED,MAAM,WAAW,8BAA8B;IAC7C,mBAAmB,CAAC,EAChB;QAAE,IAAI,EAAE,SAAS,CAAA;KAAE,GACnB;QAAE,IAAI,EAAE,UAAU,CAAC;QAAC,MAAM,EAAE,uBAAuB,CAAA;KAAE,GACrD;QACE,IAAI,EAAE,OAAO,CAAC;QACd,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,wBAAwB,CAAC;KACzD,CAAC;IACN,sBAAsB,CAAC,EACnB;QAAE,IAAI,EAAE,SAAS,CAAA;KAAE,GACnB;QACE,IAAI,EAAE,OAAO,CAAC;QACd,KAAK,EACD,SAAS,GACT,SAAS,GACT,wBAAwB,GACxB,oBAAoB,CAAC;KAC1B,CAAC;CACP;AAED,wBAAgB,6BAA6B,CAC3C,OAAO,GAAE,8BAAmC,GAC3C,mBAAmB,CAuSrB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare const DISCOUNT_REJECTION_REASONS: readonly ["INVALID_CODE", "INACTIVE", "NOT_APPLICABLE_TO_CUSTOMER", "ALREADY_ADDED", "ALREADY_USED", "NOT_APPLICABLE_TO_PRODUCTS", "NOT_APPLICABLE_TO_SUBSCRIPTION", "INVALID_COMBINATION", "QUANTITY_REQUIREMENT_NOT_MET"];
|
|
2
|
+
export type DiscountRejectionReason = (typeof DISCOUNT_REJECTION_REASONS)[number];
|
|
3
|
+
export type ApplyDiscountError = {
|
|
4
|
+
kind: "REJECTED";
|
|
5
|
+
reason: DiscountRejectionReason;
|
|
6
|
+
message?: string;
|
|
7
|
+
} | {
|
|
8
|
+
kind: "SUBSCRIPTION_NOT_FOUND";
|
|
9
|
+
} | {
|
|
10
|
+
kind: "NETWORK";
|
|
11
|
+
message?: string;
|
|
12
|
+
} | {
|
|
13
|
+
kind: "UNKNOWN";
|
|
14
|
+
message?: string;
|
|
15
|
+
};
|
|
16
|
+
export type RemoveDiscountError = {
|
|
17
|
+
kind: "DISCOUNT_NOT_FOUND";
|
|
18
|
+
} | {
|
|
19
|
+
kind: "SUBSCRIPTION_NOT_FOUND";
|
|
20
|
+
} | {
|
|
21
|
+
kind: "NETWORK";
|
|
22
|
+
message?: string;
|
|
23
|
+
} | {
|
|
24
|
+
kind: "UNKNOWN";
|
|
25
|
+
message?: string;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=discountErrors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discountErrors.d.ts","sourceRoot":"","sources":["../../../src/services/subscription/discountErrors.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,0BAA0B,6NAU7B,CAAC;AAEX,MAAM,MAAM,uBAAuB,GACjC,CAAC,OAAO,0BAA0B,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9C,MAAM,MAAM,kBAAkB,GAC1B;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,uBAAuB,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GACvE;IAAE,IAAI,EAAE,wBAAwB,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GACrC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1C,MAAM,MAAM,mBAAmB,GAC3B;IAAE,IAAI,EAAE,oBAAoB,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,wBAAwB,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GACrC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export type { SubscriptionAdapter } from './adapter';
|
|
1
|
+
export type { SubscriptionAdapter, MockSubscriptionAdapterOptions } from './adapter';
|
|
2
2
|
export { createMockSubscriptionAdapter } from './adapter';
|
|
3
3
|
export { createSubscriptionService, SubscriptionServiceContext } from './subscriptionService';
|
|
4
4
|
export * from './types';
|
|
5
|
+
export * from './discountErrors';
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/subscription/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/subscription/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,mBAAmB,EAAE,8BAA8B,EAAE,MAAM,WAAW,CAAC;AACrF,OAAO,EAAE,6BAA6B,EAAE,MAAM,WAAW,CAAC;AAE1D,OAAO,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAE9F,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscriptionService.d.ts","sourceRoot":"","sources":["../../../src/services/subscription/subscriptionService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAiB,MAAM,eAAe,CAAC;AAC3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,KAAK,EAGV,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,0BAA0B;;CACsB,CAAC;AAqC9D;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,mBAAmB,GAC3B,WAAW,CAAC,OAAO,0BAA0B,CAAC,
|
|
1
|
+
{"version":3,"file":"subscriptionService.d.ts","sourceRoot":"","sources":["../../../src/services/subscription/subscriptionService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAiB,MAAM,eAAe,CAAC;AAC3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,KAAK,EAGV,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,0BAA0B;;CACsB,CAAC;AAqC9D;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,mBAAmB,GAC3B,WAAW,CAAC,OAAO,0BAA0B,CAAC,CAyEhD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscriptionService.test.d.ts","sourceRoot":"","sources":["../../../src/services/subscription/subscriptionService.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Signal } from '@preact/signals-core';
|
|
1
|
+
import { ReadonlySignal, Signal } from '@preact/signals-core';
|
|
2
2
|
import { PaginatedList, PriceWithCurrency, Result } from '../../utils';
|
|
3
|
+
import { ApplyDiscountError, RemoveDiscountError } from './discountErrors';
|
|
3
4
|
export interface SubscriptionItem {
|
|
4
5
|
id: string;
|
|
5
6
|
productId: string;
|
|
@@ -67,10 +68,17 @@ export type SubscriptionService = {
|
|
|
67
68
|
* the service factory creates it; hosts sync route or other context by assigning `current.value`.
|
|
68
69
|
*/
|
|
69
70
|
current: Signal<Subscription | null>;
|
|
71
|
+
/**
|
|
72
|
+
* Monotonically-increasing counter that bumps after every successful
|
|
73
|
+
* `addDiscount`/`removeDiscount`. Consumers (e.g. the customer portal page)
|
|
74
|
+
* can watch this signal to re-fetch any non-blocks state that depends on the
|
|
75
|
+
* subscription's discounts.
|
|
76
|
+
*/
|
|
77
|
+
discountsChangedAt: ReadonlySignal<number>;
|
|
70
78
|
addItem(subscriptionId: string, item: PostableSubscriptionItem): Promise<Result>;
|
|
71
79
|
removeItem(subscriptionId: string, itemId: string): Promise<Result>;
|
|
72
|
-
addDiscount(
|
|
73
|
-
removeDiscount(
|
|
80
|
+
addDiscount(code: string, subscriptionId?: string): Promise<Result<void, ApplyDiscountError>>;
|
|
81
|
+
removeDiscount(discountId: string, subscriptionId?: string): Promise<Result<void, RemoveDiscountError>>;
|
|
74
82
|
reschedule(subscriptionId: string, newDate: string): Promise<Result<Subscription>>;
|
|
75
83
|
resume(subscriptionId: string): Promise<Result<Subscription>>;
|
|
76
84
|
pause(subscriptionId: string): Promise<Result<Subscription>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/services/subscription/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/services/subscription/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEhF,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,M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U,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;IACnF,MAAM,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;IAC9D,KAAK,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;IAC7D,UAAU,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;IAClE,MAAM,CAAC,cAAc,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;IAC/E,iBAAiB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;IAC1E,wBAAwB,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC;CAC5D,CAAC"}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { c as createContext, d, h as createBlockInstanceFromObject, m as getDefinedBlocks, f as createBlockInstance, t as serializeBlocks, q as onRegisterBlock } from "./block-C8lPBCF8.js";
|
|
2
|
+
import { reportBlockError } from "./observability.js";
|
|
3
|
+
const DEFAULT_GLOBAL_STYLES = {
|
|
4
|
+
volume: "comfort",
|
|
5
|
+
style: "ghost",
|
|
6
|
+
corners: "round",
|
|
7
|
+
buttonCorners: "round",
|
|
8
|
+
thumbnailCorners: "circle",
|
|
9
|
+
theme: "preset",
|
|
10
|
+
themeType: "neutral",
|
|
11
|
+
colors: {
|
|
12
|
+
accent: "#000000",
|
|
13
|
+
secondary: "#000000",
|
|
14
|
+
tint: "#111111",
|
|
15
|
+
callout: "#F5F5F5",
|
|
16
|
+
success: "#287a25",
|
|
17
|
+
error: "#a93c3c",
|
|
18
|
+
information: "#0075a3",
|
|
19
|
+
warning: "#8a5e00",
|
|
20
|
+
background: "#FFFFFF"
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const ThemeStateContext = createContext("theme-state");
|
|
24
|
+
function normalizeLocale(locale) {
|
|
25
|
+
return locale.trim().toLowerCase().split("-")[0] || "en";
|
|
26
|
+
}
|
|
27
|
+
function toStringRecord(input) {
|
|
28
|
+
if (input == null) return {};
|
|
29
|
+
return Object.fromEntries(
|
|
30
|
+
Object.entries(input).filter(([, value]) => typeof value === "string")
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
function parseBlockLocaleFile(file) {
|
|
34
|
+
if (file == null) {
|
|
35
|
+
return { defaults: {}, modes: {} };
|
|
36
|
+
}
|
|
37
|
+
const entries = Object.entries(file).filter(
|
|
38
|
+
([key, value]) => key !== "overrides" && typeof value === "string"
|
|
39
|
+
);
|
|
40
|
+
const topLevel = Object.fromEntries(entries);
|
|
41
|
+
const overrides = toStringRecord(file.overrides);
|
|
42
|
+
return {
|
|
43
|
+
defaults: { ...topLevel, ...overrides },
|
|
44
|
+
modes: {
|
|
45
|
+
...Object.fromEntries(
|
|
46
|
+
Object.keys(topLevel).map((key) => [key, "default"])
|
|
47
|
+
),
|
|
48
|
+
...Object.fromEntries(
|
|
49
|
+
Object.keys(overrides).map((key) => [key, "override"])
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function indexOverrides(overrides) {
|
|
55
|
+
const indexed = {
|
|
56
|
+
theme: {},
|
|
57
|
+
blocks: {}
|
|
58
|
+
};
|
|
59
|
+
for (const item of overrides) {
|
|
60
|
+
if (item.scope.kind === "theme") {
|
|
61
|
+
indexed.theme[item.key] = item.value;
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (indexed.blocks[item.scope.blockId] == null) {
|
|
65
|
+
indexed.blocks[item.scope.blockId] = {};
|
|
66
|
+
}
|
|
67
|
+
indexed.blocks[item.scope.blockId][item.key] = item.value;
|
|
68
|
+
}
|
|
69
|
+
return indexed;
|
|
70
|
+
}
|
|
71
|
+
function createThemeState(deps) {
|
|
72
|
+
var _a;
|
|
73
|
+
const surfaces = {
|
|
74
|
+
page: { blocks: d([]) },
|
|
75
|
+
overlay: { blocks: d([]) }
|
|
76
|
+
};
|
|
77
|
+
const locale = d("en");
|
|
78
|
+
const catalogs = d(null);
|
|
79
|
+
const globalStyles = d(
|
|
80
|
+
deps.initialGlobalStyles ?? DEFAULT_GLOBAL_STYLES
|
|
81
|
+
);
|
|
82
|
+
function setGlobalStyles(styles) {
|
|
83
|
+
globalStyles.value = styles;
|
|
84
|
+
}
|
|
85
|
+
async function collectBlockDefaults(loc) {
|
|
86
|
+
const nextDefaults = {};
|
|
87
|
+
const nextModes = {};
|
|
88
|
+
for (const block of getDefinedBlocks()) {
|
|
89
|
+
if (block.locales == null) continue;
|
|
90
|
+
let file = null;
|
|
91
|
+
try {
|
|
92
|
+
file = await block.locales.load(loc);
|
|
93
|
+
} catch {
|
|
94
|
+
file = null;
|
|
95
|
+
}
|
|
96
|
+
const parsed = parseBlockLocaleFile(file);
|
|
97
|
+
nextDefaults[block.name] = parsed.defaults;
|
|
98
|
+
nextModes[block.name] = parsed.modes;
|
|
99
|
+
}
|
|
100
|
+
return { defaults: nextDefaults, modes: nextModes };
|
|
101
|
+
}
|
|
102
|
+
async function setLocale(nextLocaleRaw) {
|
|
103
|
+
var _a2;
|
|
104
|
+
const nextLocale = normalizeLocale(nextLocaleRaw);
|
|
105
|
+
const [blockData, loadedOverrides] = await Promise.all([
|
|
106
|
+
collectBlockDefaults(nextLocale),
|
|
107
|
+
((_a2 = deps.translations) == null ? void 0 : _a2.resolveTranslations(nextLocale).catch(() => [])) ?? Promise.resolve([])
|
|
108
|
+
]);
|
|
109
|
+
const overrides = loadedOverrides.filter(
|
|
110
|
+
(item) => normalizeLocale(item.locale) === nextLocale
|
|
111
|
+
);
|
|
112
|
+
const indexed = indexOverrides(overrides);
|
|
113
|
+
catalogs.value = {
|
|
114
|
+
theme: {
|
|
115
|
+
defaults: {},
|
|
116
|
+
overrides: indexed.theme
|
|
117
|
+
},
|
|
118
|
+
blocks: {
|
|
119
|
+
defaults: blockData.defaults,
|
|
120
|
+
modes: blockData.modes,
|
|
121
|
+
overrides: indexed.blocks
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
locale.value = nextLocale;
|
|
125
|
+
}
|
|
126
|
+
async function resolve(surface, path) {
|
|
127
|
+
var _a2, _b, _c, _d;
|
|
128
|
+
surfaces[surface].blocks.value = [];
|
|
129
|
+
const stored = await deps.resolve(surface, path);
|
|
130
|
+
if (stored != null) {
|
|
131
|
+
surfaces[surface].blocks.value = stored.blocks.flatMap((block) => {
|
|
132
|
+
try {
|
|
133
|
+
return [createBlockInstanceFromObject(block)];
|
|
134
|
+
} catch (error) {
|
|
135
|
+
reportBlockError(error, {
|
|
136
|
+
site: "theme-state.resolve.hydrate",
|
|
137
|
+
extra: {
|
|
138
|
+
surface,
|
|
139
|
+
path,
|
|
140
|
+
blockType: typeof (block == null ? void 0 : block.type) === "string" ? block.type : "(unknown)"
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
return [];
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
return stored;
|
|
147
|
+
}
|
|
148
|
+
const blockToUse = surface === "page" ? (_b = (_a2 = deps.routerService) == null ? void 0 : _a2.getPages().find((p) => p.path === path)) == null ? void 0 : _b.block : (_c = getDefinedBlocks().find((b) => b.name === path)) == null ? void 0 : _c.name;
|
|
149
|
+
if (blockToUse != null) {
|
|
150
|
+
const instance = createBlockInstance(blockToUse);
|
|
151
|
+
surfaces[surface].blocks.value = [instance];
|
|
152
|
+
const serialized = serializeBlocks([instance]);
|
|
153
|
+
(_d = deps.upsertState) == null ? void 0 : _d.call(deps, surface, path, serialized);
|
|
154
|
+
return { blocks: serialized };
|
|
155
|
+
}
|
|
156
|
+
return { blocks: [] };
|
|
157
|
+
}
|
|
158
|
+
onRegisterBlock(async (_, block) => {
|
|
159
|
+
if (block.locales == null || catalogs.value == null) return;
|
|
160
|
+
const localeAtLoadStart = locale.value;
|
|
161
|
+
let file = null;
|
|
162
|
+
try {
|
|
163
|
+
file = await block.locales.load(localeAtLoadStart);
|
|
164
|
+
} catch {
|
|
165
|
+
file = null;
|
|
166
|
+
}
|
|
167
|
+
if (catalogs.value == null || locale.value !== localeAtLoadStart) return;
|
|
168
|
+
const parsed = parseBlockLocaleFile(file);
|
|
169
|
+
const current = catalogs.value;
|
|
170
|
+
catalogs.value = {
|
|
171
|
+
...current,
|
|
172
|
+
blocks: {
|
|
173
|
+
...current.blocks,
|
|
174
|
+
defaults: {
|
|
175
|
+
...current.blocks.defaults,
|
|
176
|
+
[block.name]: parsed.defaults
|
|
177
|
+
},
|
|
178
|
+
modes: {
|
|
179
|
+
...current.blocks.modes,
|
|
180
|
+
[block.name]: parsed.modes
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
});
|
|
185
|
+
(_a = deps.routerService) == null ? void 0 : _a.subscribe(({ path }) => {
|
|
186
|
+
resolve("page", path);
|
|
187
|
+
});
|
|
188
|
+
return {
|
|
189
|
+
page: surfaces.page,
|
|
190
|
+
overlay: surfaces.overlay,
|
|
191
|
+
locales: { locale, catalogs, setLocale },
|
|
192
|
+
globalStyles,
|
|
193
|
+
setGlobalStyles,
|
|
194
|
+
resolve
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
export {
|
|
198
|
+
DEFAULT_GLOBAL_STYLES as D,
|
|
199
|
+
ThemeStateContext as T,
|
|
200
|
+
createThemeState as c,
|
|
201
|
+
indexOverrides as i
|
|
202
|
+
};
|
package/dist/vue/block.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { App, Component } from 'vue';
|
|
2
2
|
import { BlockInstance } from '../main.ts';
|
|
3
|
+
export { hasRenderedContent } from '../block';
|
|
3
4
|
export declare function createVueRenderer(component: Component, options?: {
|
|
4
5
|
hostApp?: App;
|
|
5
6
|
}): (block: BlockInstance) => HTMLElement;
|
|
6
7
|
export declare function createVueCeRenderer(name: string, component: Component, { shadowRoot }?: {
|
|
7
8
|
shadowRoot?: boolean;
|
|
8
|
-
}): (block: BlockInstance) =>
|
|
9
|
+
}): (block: BlockInstance) => HTMLElement;
|
|
9
10
|
//# sourceMappingURL=block.d.ts.map
|
package/dist/vue/block.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../src/vue/block.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,GAAG,EAGR,SAAS,EAUV,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAoB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../src/vue/block.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,GAAG,EAGR,SAAS,EAUV,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAoB,MAAM,aAAa,CAAC;AAK9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AA2B9C,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,SAAS,EACpB,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,GAAG,CAAA;CAAE,WAuCZ,aAAa,iBA6D7B;AAED,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,SAAS,EACpB,EAAE,UAAiB,EAAE,GAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAO,yCAoCrD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setupTests.d.ts","sourceRoot":"","sources":["../../src/vue/setupTests.ts"],"names":[],"mappings":""}
|
package/dist/vue.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { customRef, toValue, watchEffect, defineComponent, ref, getCurrentInstance, onMounted, provide, h, renderSlot, inject, computed, useHost, defineCustomElement, triggerRef, render, shallowRef } from "vue";
|
|
2
2
|
import { effect, signal, injectContext, provideContext, createCeRenderer } from "@juo/blocks";
|
|
3
|
-
import {
|
|
3
|
+
import { b as attachEmptyTracking } from "./block-C8lPBCF8.js";
|
|
4
|
+
import { n } from "./block-C8lPBCF8.js";
|
|
5
|
+
import { c as createRegisterBlockTranslationKeysMessage, a as createEditorBridge } from "./bridge-BOcO9toS.js";
|
|
4
6
|
const signalsMap = /* @__PURE__ */ new WeakMap();
|
|
5
7
|
function toSignal(ref2) {
|
|
6
8
|
if (!signalsMap.has(ref2)) {
|
|
@@ -207,13 +209,15 @@ function createVueRenderer(component, options) {
|
|
|
207
209
|
if (!existing) {
|
|
208
210
|
wrapper.setAttribute("data-block-id", block.id);
|
|
209
211
|
wrapper.setAttribute("data-block-type", block.type);
|
|
210
|
-
wrapper.style.display = "contents";
|
|
211
212
|
}
|
|
212
213
|
const vnode = h(Root);
|
|
213
214
|
if (options == null ? void 0 : options.hostApp) {
|
|
214
215
|
vnode.appContext = options.hostApp._context;
|
|
215
216
|
}
|
|
216
217
|
render(vnode, wrapper);
|
|
218
|
+
if (!existing) {
|
|
219
|
+
attachEmptyTracking(wrapper);
|
|
220
|
+
}
|
|
217
221
|
cache.set(block.id, { wrapper, propsRef, slotsRef, parentInstance });
|
|
218
222
|
return wrapper;
|
|
219
223
|
};
|
|
@@ -286,6 +290,7 @@ export {
|
|
|
286
290
|
ContextProvider,
|
|
287
291
|
createVueCeRenderer,
|
|
288
292
|
createVueRenderer,
|
|
293
|
+
n as hasRenderedContent,
|
|
289
294
|
toRef,
|
|
290
295
|
toSignal,
|
|
291
296
|
useBlockId,
|
|
@@ -6,6 +6,7 @@ export default class InlineText extends HTMLElement {
|
|
|
6
6
|
private blockType;
|
|
7
7
|
private boundHandleBlur;
|
|
8
8
|
private boundHandlePointerDown;
|
|
9
|
+
private boundHandleClick;
|
|
9
10
|
private lastValue;
|
|
10
11
|
private dispose?;
|
|
11
12
|
static get observedAttributes(): string[];
|
|
@@ -14,6 +15,7 @@ export default class InlineText extends HTMLElement {
|
|
|
14
15
|
private get isReadonly();
|
|
15
16
|
private initializeEditorMode;
|
|
16
17
|
private handlePointerDown;
|
|
18
|
+
private handleClick;
|
|
17
19
|
private handleBlur;
|
|
18
20
|
private static injectedRoots;
|
|
19
21
|
private injectStyles;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InlineText.d.ts","sourceRoot":"","sources":["../../../src/web-components/editor/InlineText.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,WAAW;IACjD,OAAO,CAAC,YAAY,CAAsD;IAC1E,OAAO,CAAC,kBAAkB,CAAmC;IAC7D,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,OAAO,CAAuB;IACtC,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,eAAe,CAA8B;IACrD,OAAO,CAAC,sBAAsB,CAAqC;IACnE,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,OAAO,CAAC,CAAa;IAE7B,MAAM,KAAK,kBAAkB,aAE5B;;IAMD,iBAAiB;IA0CjB,OAAO,KAAK,UAAU,GAErB;IAED,OAAO,CAAC,oBAAoB;
|
|
1
|
+
{"version":3,"file":"InlineText.d.ts","sourceRoot":"","sources":["../../../src/web-components/editor/InlineText.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,WAAW;IACjD,OAAO,CAAC,YAAY,CAAsD;IAC1E,OAAO,CAAC,kBAAkB,CAAmC;IAC7D,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,OAAO,CAAuB;IACtC,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,eAAe,CAA8B;IACrD,OAAO,CAAC,sBAAsB,CAAqC;IACnE,OAAO,CAAC,gBAAgB,CAA+B;IACvD,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,OAAO,CAAC,CAAa;IAE7B,MAAM,KAAK,kBAAkB,aAE5B;;IAMD,iBAAiB;IA0CjB,OAAO,KAAK,UAAU,GAErB;IAED,OAAO,CAAC,oBAAoB;IAiD5B,OAAO,CAAC,iBAAiB;IAoBzB,OAAO,CAAC,WAAW;IAKnB,OAAO,CAAC,UAAU;IAKlB,OAAO,CAAC,MAAM,CAAC,aAAa,CAAwC;IAEpE,OAAO,CAAC,YAAY;IA8BpB,OAAO,CAAC,UAAU;IA+BlB,wBAAwB,CACtB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,QAAQ,EAAE,MAAM,GAAG,IAAI;IAOzB,oBAAoB;CASrB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,UAAU,EAAE,UAAU,CAAC;KACxB;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InlineText.test.d.ts","sourceRoot":"","sources":["../../../src/web-components/editor/InlineText.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import { o as injectContext, E, z as ContextRoot } from "./
|
|
5
|
-
import { E as ExtensionRoot, B as Block } from "./ExtensionRoot-
|
|
6
|
-
import { a as createEditorBridge, b as createFocusInlineTextMessage, d as createUpdateBlockTranslationMessage } from "./bridge-
|
|
7
|
-
import { T as TranslationContext } from "./juo-workflow-
|
|
4
|
+
import { o as injectContext, E, z as ContextRoot } from "./block-C8lPBCF8.js";
|
|
5
|
+
import { E as ExtensionRoot, B as Block } from "./ExtensionRoot-BmfKKpcU.js";
|
|
6
|
+
import { a as createEditorBridge, b as createFocusInlineTextMessage, d as createUpdateBlockTranslationMessage } from "./bridge-BOcO9toS.js";
|
|
7
|
+
import { T as TranslationContext } from "./juo-workflow-B3OHYsp-.js";
|
|
8
8
|
const _InlineText = class _InlineText extends HTMLElement {
|
|
9
9
|
constructor() {
|
|
10
10
|
super();
|
|
@@ -15,6 +15,7 @@ const _InlineText = class _InlineText extends HTMLElement {
|
|
|
15
15
|
__publicField(this, "blockType", null);
|
|
16
16
|
__publicField(this, "boundHandleBlur", this.handleBlur.bind(this));
|
|
17
17
|
__publicField(this, "boundHandlePointerDown", this.handlePointerDown.bind(this));
|
|
18
|
+
__publicField(this, "boundHandleClick", this.handleClick.bind(this));
|
|
18
19
|
__publicField(this, "lastValue", null);
|
|
19
20
|
__publicField(this, "dispose");
|
|
20
21
|
}
|
|
@@ -75,6 +76,7 @@ const _InlineText = class _InlineText extends HTMLElement {
|
|
|
75
76
|
}
|
|
76
77
|
this.addEventListener("blur", this.boundHandleBlur);
|
|
77
78
|
this.addEventListener("pointerdown", this.boundHandlePointerDown);
|
|
79
|
+
this.addEventListener("click", this.boundHandleClick);
|
|
78
80
|
this.lastValue = this.textContent || "";
|
|
79
81
|
if (this.translationService && this.propName && this.blockType && this.blockId) {
|
|
80
82
|
const key = this.propName;
|
|
@@ -91,9 +93,10 @@ const _InlineText = class _InlineText extends HTMLElement {
|
|
|
91
93
|
});
|
|
92
94
|
}
|
|
93
95
|
}
|
|
94
|
-
handlePointerDown() {
|
|
96
|
+
handlePointerDown(event) {
|
|
95
97
|
if (this.isReadonly) return;
|
|
96
98
|
if (this.contentEditable === "plaintext-only") return;
|
|
99
|
+
event.stopPropagation();
|
|
97
100
|
if (this.editorBridge && this.blockId && this.propName) {
|
|
98
101
|
this.editorBridge.sendMessage(
|
|
99
102
|
createFocusInlineTextMessage(
|
|
@@ -105,6 +108,10 @@ const _InlineText = class _InlineText extends HTMLElement {
|
|
|
105
108
|
this.textContent = this.lastValue ?? "";
|
|
106
109
|
this.contentEditable = "plaintext-only";
|
|
107
110
|
}
|
|
111
|
+
handleClick(event) {
|
|
112
|
+
if (this.isReadonly) return;
|
|
113
|
+
event.stopPropagation();
|
|
114
|
+
}
|
|
108
115
|
handleBlur() {
|
|
109
116
|
this.contentEditable = "false";
|
|
110
117
|
this.sendUpdate();
|
|
@@ -123,6 +130,9 @@ const _InlineText = class _InlineText extends HTMLElement {
|
|
|
123
130
|
juo-text:focus {
|
|
124
131
|
outline-color: #717171 !important;
|
|
125
132
|
}
|
|
133
|
+
:is(button, a):has(juo-text[contenteditable="plaintext-only"]):active {
|
|
134
|
+
transform: none !important;
|
|
135
|
+
}
|
|
126
136
|
`;
|
|
127
137
|
if (root instanceof ShadowRoot) {
|
|
128
138
|
root.appendChild(style);
|
|
@@ -162,6 +172,7 @@ const _InlineText = class _InlineText extends HTMLElement {
|
|
|
162
172
|
var _a;
|
|
163
173
|
this.removeEventListener("blur", this.boundHandleBlur);
|
|
164
174
|
this.removeEventListener("pointerdown", this.boundHandlePointerDown);
|
|
175
|
+
this.removeEventListener("click", this.boundHandleClick);
|
|
165
176
|
(_a = this.dispose) == null ? void 0 : _a.call(this);
|
|
166
177
|
this.dispose = void 0;
|
|
167
178
|
this.editorBridge = null;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import { o as injectContext, E, z as ContextRoot } from "./
|
|
5
|
-
import { E as ExtensionRoot, B as Block } from "./ExtensionRoot-
|
|
6
|
-
import { T as TranslationContext } from "./juo-workflow-
|
|
4
|
+
import { o as injectContext, E, z as ContextRoot } from "./block-C8lPBCF8.js";
|
|
5
|
+
import { E as ExtensionRoot, B as Block } from "./ExtensionRoot-BmfKKpcU.js";
|
|
6
|
+
import { T as TranslationContext } from "./juo-workflow-B3OHYsp-.js";
|
|
7
7
|
class InlineText extends HTMLElement {
|
|
8
8
|
constructor() {
|
|
9
9
|
super(...arguments);
|