@juo/blocks 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/dist/ExtensionRoot-CZyBNJZY.js +159 -0
  2. package/dist/block-VhmfGB3N.js +51 -0
  3. package/dist/block.d.ts +96 -0
  4. package/dist/block.d.ts.map +1 -0
  5. package/dist/bridge-DQsM97cH.js +490 -0
  6. package/dist/context.d.ts +76 -0
  7. package/dist/context.d.ts.map +1 -0
  8. package/dist/context.test.d.ts +2 -0
  9. package/dist/context.test.d.ts.map +1 -0
  10. package/dist/core.js +1163 -0
  11. package/dist/editor/bridge.d.ts +75 -0
  12. package/dist/editor/bridge.d.ts.map +1 -0
  13. package/dist/editor/bridge.test.d.ts +2 -0
  14. package/dist/editor/bridge.test.d.ts.map +1 -0
  15. package/dist/editor/components.d.ts +31 -0
  16. package/dist/editor/components.d.ts.map +1 -0
  17. package/dist/editor/handler.d.ts +10 -0
  18. package/dist/editor/handler.d.ts.map +1 -0
  19. package/dist/editor/main.d.ts +17 -0
  20. package/dist/editor/main.d.ts.map +1 -0
  21. package/dist/editor/messages.d.ts +233 -0
  22. package/dist/editor/messages.d.ts.map +1 -0
  23. package/dist/editor.js +711 -0
  24. package/dist/flows/MockWorkflowApiAdapter.d.ts +13 -0
  25. package/dist/flows/MockWorkflowApiAdapter.d.ts.map +1 -0
  26. package/dist/flows/WorkflowService.d.ts +175 -0
  27. package/dist/flows/WorkflowService.d.ts.map +1 -0
  28. package/dist/flows/__tests__/WorkflowService.test.d.ts +2 -0
  29. package/dist/flows/__tests__/WorkflowService.test.d.ts.map +1 -0
  30. package/dist/flows/__tests__/defaults.test.d.ts +2 -0
  31. package/dist/flows/__tests__/defaults.test.d.ts.map +1 -0
  32. package/dist/flows/__tests__/juo-workflow.test.d.ts +2 -0
  33. package/dist/flows/__tests__/juo-workflow.test.d.ts.map +1 -0
  34. package/dist/flows/__tests__/overlay-behavior.test.d.ts +2 -0
  35. package/dist/flows/__tests__/overlay-behavior.test.d.ts.map +1 -0
  36. package/dist/flows/__tests__/theme-state-surfaces.test.d.ts +2 -0
  37. package/dist/flows/__tests__/theme-state-surfaces.test.d.ts.map +1 -0
  38. package/dist/flows/defaults.d.ts +15 -0
  39. package/dist/flows/defaults.d.ts.map +1 -0
  40. package/dist/flows/index.d.ts +4 -0
  41. package/dist/flows/index.d.ts.map +1 -0
  42. package/dist/flows/juo-workflow.d.ts +48 -0
  43. package/dist/flows/juo-workflow.d.ts.map +1 -0
  44. package/dist/juo-workflow-RSrOuKUH.js +591 -0
  45. package/dist/main.d.ts +11 -0
  46. package/dist/main.d.ts.map +1 -0
  47. package/dist/preact/block.d.ts +21 -0
  48. package/dist/preact/block.d.ts.map +1 -0
  49. package/dist/preact/block.test.d.ts +2 -0
  50. package/dist/preact/block.test.d.ts.map +1 -0
  51. package/dist/preact/bridge.d.ts +11 -0
  52. package/dist/preact/bridge.d.ts.map +1 -0
  53. package/dist/preact/context.d.ts +31 -0
  54. package/dist/preact/context.d.ts.map +1 -0
  55. package/dist/preact/main.d.ts +11 -0
  56. package/dist/preact/main.d.ts.map +1 -0
  57. package/dist/preact/signals.d.ts +23 -0
  58. package/dist/preact/signals.d.ts.map +1 -0
  59. package/dist/preact.js +230 -0
  60. package/dist/react/block.d.ts +21 -0
  61. package/dist/react/block.d.ts.map +1 -0
  62. package/dist/react/block.test.d.ts +2 -0
  63. package/dist/react/block.test.d.ts.map +1 -0
  64. package/dist/react/bridge.d.ts +11 -0
  65. package/dist/react/bridge.d.ts.map +1 -0
  66. package/dist/react/context.d.ts +28 -0
  67. package/dist/react/context.d.ts.map +1 -0
  68. package/dist/react/main.d.ts +11 -0
  69. package/dist/react/main.d.ts.map +1 -0
  70. package/dist/react/signals.d.ts +23 -0
  71. package/dist/react/signals.d.ts.map +1 -0
  72. package/dist/react.js +205 -0
  73. package/dist/services/index.d.ts +4 -0
  74. package/dist/services/index.d.ts.map +1 -0
  75. package/dist/services/login/index.d.ts +23 -0
  76. package/dist/services/login/index.d.ts.map +1 -0
  77. package/dist/services/login/loginService.d.ts +82 -0
  78. package/dist/services/login/loginService.d.ts.map +1 -0
  79. package/dist/services/product/adapter.d.ts +20 -0
  80. package/dist/services/product/adapter.d.ts.map +1 -0
  81. package/dist/services/product/index.d.ts +5 -0
  82. package/dist/services/product/index.d.ts.map +1 -0
  83. package/dist/services/product/productService.d.ts +12 -0
  84. package/dist/services/product/productService.d.ts.map +1 -0
  85. package/dist/services/product/types.d.ts +32 -0
  86. package/dist/services/product/types.d.ts.map +1 -0
  87. package/dist/services/subscription/adapter.d.ts +49 -0
  88. package/dist/services/subscription/adapter.d.ts.map +1 -0
  89. package/dist/services/subscription/index.d.ts +5 -0
  90. package/dist/services/subscription/index.d.ts.map +1 -0
  91. package/dist/services/subscription/list.d.ts +22 -0
  92. package/dist/services/subscription/list.d.ts.map +1 -0
  93. package/dist/services/subscription/store.d.ts +30 -0
  94. package/dist/services/subscription/store.d.ts.map +1 -0
  95. package/dist/services/subscription/subscriptionService.d.ts +12 -0
  96. package/dist/services/subscription/subscriptionService.d.ts.map +1 -0
  97. package/dist/services/subscription/types.d.ts +76 -0
  98. package/dist/services/subscription/types.d.ts.map +1 -0
  99. package/dist/shared/block.d.ts +17 -0
  100. package/dist/shared/block.d.ts.map +1 -0
  101. package/dist/shared/context.d.ts +16 -0
  102. package/dist/shared/context.d.ts.map +1 -0
  103. package/dist/shared/signals.d.ts +17 -0
  104. package/dist/shared/signals.d.ts.map +1 -0
  105. package/dist/state.d.ts +81 -0
  106. package/dist/state.d.ts.map +1 -0
  107. package/dist/theme-state-BZplRS92.js +886 -0
  108. package/dist/theme-state.d.ts +85 -0
  109. package/dist/theme-state.d.ts.map +1 -0
  110. package/dist/theme-state.locales.test.d.ts +2 -0
  111. package/dist/theme-state.locales.test.d.ts.map +1 -0
  112. package/dist/translation.d.ts +14 -0
  113. package/dist/translation.d.ts.map +1 -0
  114. package/dist/translation.test.d.ts +2 -0
  115. package/dist/translation.test.d.ts.map +1 -0
  116. package/dist/utils/index.d.ts +32 -0
  117. package/dist/utils/index.d.ts.map +1 -0
  118. package/dist/utils/login.d.ts +11 -0
  119. package/dist/utils/login.d.ts.map +1 -0
  120. package/dist/utils/uuid.d.ts +2 -0
  121. package/dist/utils/uuid.d.ts.map +1 -0
  122. package/dist/vue/block.d.ts +7 -0
  123. package/dist/vue/block.d.ts.map +1 -0
  124. package/dist/vue/bridge.d.ts +11 -0
  125. package/dist/vue/bridge.d.ts.map +1 -0
  126. package/dist/vue/context.d.ts +24 -0
  127. package/dist/vue/context.d.ts.map +1 -0
  128. package/dist/vue/main.d.ts +6 -0
  129. package/dist/vue/main.d.ts.map +1 -0
  130. package/dist/vue/signals.d.ts +5 -0
  131. package/dist/vue/signals.d.ts.map +1 -0
  132. package/dist/vue/target.d.ts +2 -0
  133. package/dist/vue/target.d.ts.map +1 -0
  134. package/dist/vue/transform.d.ts +2 -0
  135. package/dist/vue/transform.d.ts.map +1 -0
  136. package/dist/vue.js +254 -0
  137. package/dist/web-components/Block.d.ts +17 -0
  138. package/dist/web-components/Block.d.ts.map +1 -0
  139. package/dist/web-components/Block.test.d.ts +2 -0
  140. package/dist/web-components/Block.test.d.ts.map +1 -0
  141. package/dist/web-components/ExtensionRoot.d.ts +29 -0
  142. package/dist/web-components/ExtensionRoot.d.ts.map +1 -0
  143. package/dist/web-components/editor/InlineText.d.ts +29 -0
  144. package/dist/web-components/editor/InlineText.d.ts.map +1 -0
  145. package/dist/web-components/editor/main.d.ts +2 -0
  146. package/dist/web-components/editor/main.d.ts.map +1 -0
  147. package/dist/web-components/runtime/InlineText.d.ts +6 -0
  148. package/dist/web-components/runtime/InlineText.d.ts.map +1 -0
  149. package/dist/web-components/runtime/main.d.ts +2 -0
  150. package/dist/web-components/runtime/main.d.ts.map +1 -0
  151. package/dist/web-components-editor.js +183 -0
  152. package/dist/web-components-runtime.js +55 -0
  153. package/package.json +62 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InlineText.d.ts","sourceRoot":"","sources":["../../../src/web-components/runtime/InlineText.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,WAAW;IACjD,OAAO,CAAC,OAAO,CAAC,CAAa;IAE7B,iBAAiB;IAqCjB,oBAAoB;CAIrB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=main.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/web-components/runtime/main.ts"],"names":[],"mappings":""}
@@ -0,0 +1,183 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+ import { p as injectContext, E, x as ContextRoot } from "./theme-state-BZplRS92.js";
5
+ import { E as ExtensionRoot, B as Block } from "./ExtensionRoot-CZyBNJZY.js";
6
+ import { a as createEditorBridge, b as createFocusInlineTextMessage, d as createUpdateBlockTranslationMessage } from "./bridge-DQsM97cH.js";
7
+ import { T as TranslationContext } from "./juo-workflow-RSrOuKUH.js";
8
+ const _InlineText = class _InlineText extends HTMLElement {
9
+ constructor() {
10
+ super();
11
+ __publicField(this, "editorBridge", null);
12
+ __publicField(this, "translationService", null);
13
+ __publicField(this, "propName", null);
14
+ __publicField(this, "blockId", null);
15
+ __publicField(this, "blockType", null);
16
+ __publicField(this, "boundHandleBlur", this.handleBlur.bind(this));
17
+ __publicField(this, "boundHandlePointerDown", this.handlePointerDown.bind(this));
18
+ __publicField(this, "lastValue", null);
19
+ __publicField(this, "dispose");
20
+ }
21
+ static get observedAttributes() {
22
+ return ["prop", "readonly"];
23
+ }
24
+ connectedCallback() {
25
+ if (!this.style.display) this.style.display = "inline-block";
26
+ if (!this.style.overflowWrap) this.style.overflowWrap = "anywhere";
27
+ this.propName = this.getAttribute("prop");
28
+ if (!this.propName) {
29
+ console.warn("juo-text: 'prop' attribute is required");
30
+ return;
31
+ }
32
+ let blockWrapper = this.closest("[data-block-type]");
33
+ if (!blockWrapper) {
34
+ const rootNode = this.getRootNode();
35
+ if (rootNode instanceof ShadowRoot && rootNode.host) {
36
+ blockWrapper = rootNode.host.closest("[data-block-type]");
37
+ }
38
+ }
39
+ if (!blockWrapper) {
40
+ console.warn(
41
+ "juo-text: Could not find parent block with data-block-type"
42
+ );
43
+ return;
44
+ }
45
+ this.blockId = blockWrapper.getAttribute("data-block-id");
46
+ this.blockType = blockWrapper.getAttribute("data-block-type");
47
+ if (!this.blockId) {
48
+ console.warn("juo-text: Parent block has no data-block-id attribute");
49
+ return;
50
+ }
51
+ if (!this.blockType) {
52
+ console.warn("juo-text: Parent block has no data-block-type attribute");
53
+ return;
54
+ }
55
+ this.translationService = injectContext(this, TranslationContext);
56
+ this.initializeEditorMode();
57
+ }
58
+ get isReadonly() {
59
+ return this.hasAttribute("readonly");
60
+ }
61
+ initializeEditorMode() {
62
+ this.editorBridge = createEditorBridge();
63
+ this.contentEditable = "false";
64
+ if (!this.isReadonly) {
65
+ this.style.cursor = "text";
66
+ this.style.borderRadius = "2px";
67
+ this.style.outline = "0.5px solid transparent";
68
+ this.style.outlineOffset = "2px";
69
+ }
70
+ if (!this.style.width) this.style.width = "100%";
71
+ if (!this.style.overflowWrap) this.style.overflowWrap = "anywhere";
72
+ if (!this.style.whiteSpace) this.style.whiteSpace = "pre-wrap";
73
+ if (!this.isReadonly) {
74
+ this.injectStyles();
75
+ }
76
+ this.addEventListener("blur", this.boundHandleBlur);
77
+ this.addEventListener("pointerdown", this.boundHandlePointerDown);
78
+ this.lastValue = this.textContent || "";
79
+ if (this.translationService && this.propName && this.blockType && this.blockId) {
80
+ const key = this.propName;
81
+ const fallbackText = this.textContent ?? "";
82
+ this.dispose = E(() => {
83
+ const service = this.translationService;
84
+ if (!service) return;
85
+ void service.locale.value;
86
+ const resolved = service.resolve(this.blockType, this.blockId, key);
87
+ const value = resolved === key && fallbackText.trim().length > 0 ? fallbackText : resolved;
88
+ this.textContent = value;
89
+ this.lastValue = value;
90
+ });
91
+ }
92
+ }
93
+ handlePointerDown() {
94
+ if (this.isReadonly) return;
95
+ if (this.contentEditable === "plaintext-only") return;
96
+ if (this.editorBridge && this.blockId && this.propName) {
97
+ this.editorBridge.sendMessage(
98
+ createFocusInlineTextMessage(
99
+ { blockId: this.blockId, key: this.propName },
100
+ this.blockId
101
+ )
102
+ );
103
+ }
104
+ this.textContent = this.lastValue ?? "";
105
+ this.contentEditable = "plaintext-only";
106
+ }
107
+ handleBlur() {
108
+ this.contentEditable = "false";
109
+ this.sendUpdate();
110
+ }
111
+ injectStyles() {
112
+ const rootNode = this.getRootNode();
113
+ const root = rootNode instanceof ShadowRoot ? rootNode : document;
114
+ if (_InlineText.injectedRoots.has(root)) {
115
+ return;
116
+ }
117
+ const style = document.createElement("style");
118
+ style.textContent = `
119
+ juo-text:hover {
120
+ outline-color: #CACACA !important;
121
+ }
122
+ juo-text:focus {
123
+ outline-color: #717171 !important;
124
+ }
125
+ `;
126
+ if (root instanceof ShadowRoot) {
127
+ root.appendChild(style);
128
+ } else {
129
+ document.head.appendChild(style);
130
+ }
131
+ _InlineText.injectedRoots.add(root);
132
+ }
133
+ sendUpdate() {
134
+ var _a;
135
+ if (!this.editorBridge || !this.blockId || !this.blockType || !this.propName) {
136
+ return;
137
+ }
138
+ const newValue = this.textContent ?? "";
139
+ if (this.lastValue === newValue) {
140
+ return;
141
+ }
142
+ const message = createUpdateBlockTranslationMessage(
143
+ {
144
+ blockId: this.blockId,
145
+ blockType: this.blockType,
146
+ key: this.propName,
147
+ value: newValue,
148
+ locale: (_a = this.translationService) == null ? void 0 : _a.locale.value
149
+ },
150
+ this.blockId
151
+ );
152
+ this.editorBridge.sendMessage(message);
153
+ this.lastValue = newValue;
154
+ }
155
+ attributeChangedCallback(name, oldValue, newValue) {
156
+ if (name === "prop" && oldValue !== newValue) {
157
+ this.propName = newValue;
158
+ }
159
+ }
160
+ disconnectedCallback() {
161
+ var _a;
162
+ this.removeEventListener("blur", this.boundHandleBlur);
163
+ this.removeEventListener("pointerdown", this.boundHandlePointerDown);
164
+ (_a = this.dispose) == null ? void 0 : _a.call(this);
165
+ this.dispose = void 0;
166
+ this.editorBridge = null;
167
+ this.translationService = null;
168
+ }
169
+ };
170
+ __publicField(_InlineText, "injectedRoots", /* @__PURE__ */ new WeakSet());
171
+ let InlineText = _InlineText;
172
+ if (customElements.get("juo-context-root") == null) {
173
+ customElements.define("juo-context-root", ContextRoot);
174
+ }
175
+ if (customElements.get("juo-extension-root") == null) {
176
+ customElements.define("juo-extension-root", ExtensionRoot);
177
+ }
178
+ if (customElements.get("juo-block") == null) {
179
+ customElements.define("juo-block", Block);
180
+ }
181
+ if (customElements.get("juo-text") == null) {
182
+ customElements.define("juo-text", InlineText);
183
+ }
@@ -0,0 +1,55 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+ import { p as injectContext, E, x as ContextRoot } from "./theme-state-BZplRS92.js";
5
+ import { E as ExtensionRoot, B as Block } from "./ExtensionRoot-CZyBNJZY.js";
6
+ import { T as TranslationContext } from "./juo-workflow-RSrOuKUH.js";
7
+ class InlineText extends HTMLElement {
8
+ constructor() {
9
+ super(...arguments);
10
+ __publicField(this, "dispose");
11
+ }
12
+ connectedCallback() {
13
+ if (!this.style.display) this.style.display = "inline-block";
14
+ if (!this.style.overflowWrap) this.style.overflowWrap = "anywhere";
15
+ const key = this.getAttribute("prop");
16
+ if (!key) return;
17
+ let blockEl = this.closest("[data-block-type]");
18
+ if (!blockEl) {
19
+ const root = this.getRootNode();
20
+ if (root instanceof ShadowRoot && root.host instanceof HTMLElement) {
21
+ blockEl = root.host.closest("[data-block-type]");
22
+ }
23
+ }
24
+ const blockType = (blockEl == null ? void 0 : blockEl.getAttribute("data-block-type")) ?? null;
25
+ const blockId = (blockEl == null ? void 0 : blockEl.getAttribute("data-block-id")) ?? null;
26
+ const service = injectContext(this, TranslationContext);
27
+ const fallbackText = this.textContent ?? "";
28
+ this.dispose = E(() => {
29
+ void service.locale.value;
30
+ const resolved = service.resolve(blockType, blockId, key);
31
+ const value = resolved === key && fallbackText.trim().length > 0 ? fallbackText : resolved;
32
+ this.textContent = value;
33
+ if (this.hasAttribute("hide-parent-if-empty") && this.parentElement) {
34
+ this.parentElement.hidden = value.trim() === "";
35
+ }
36
+ });
37
+ }
38
+ disconnectedCallback() {
39
+ var _a;
40
+ (_a = this.dispose) == null ? void 0 : _a.call(this);
41
+ this.dispose = void 0;
42
+ }
43
+ }
44
+ if (customElements.get("juo-context-root") == null) {
45
+ customElements.define("juo-context-root", ContextRoot);
46
+ }
47
+ if (customElements.get("juo-extension-root") == null) {
48
+ customElements.define("juo-extension-root", ExtensionRoot);
49
+ }
50
+ if (customElements.get("juo-block") == null) {
51
+ customElements.define("juo-block", Block);
52
+ }
53
+ if (customElements.get("juo-text") == null) {
54
+ customElements.define("juo-text", InlineText);
55
+ }
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@juo/blocks",
3
+ "private": false,
4
+ "version": "1.0.0",
5
+ "type": "module",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "devDependencies": {
10
+ "@types/react": "19.1.0",
11
+ "@types/react-dom": "19.1.0",
12
+ "jsdom": "24.0.0",
13
+ "json-schema-to-ts": "3.1.1",
14
+ "preact": "10.26.8",
15
+ "react": "19.1.0",
16
+ "react-dom": "19.1.0",
17
+ "typescript": "5.7.3",
18
+ "vite": "5.4.21",
19
+ "vite-plugin-dts": "4.5.4",
20
+ "vitest": "3.2.4",
21
+ "vue": "3.5.13"
22
+ },
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/main.d.ts",
26
+ "default": "./dist/core.js"
27
+ },
28
+ "./vue": {
29
+ "types": "./dist/vue/main.d.ts",
30
+ "default": "./dist/vue.js"
31
+ },
32
+ "./react": {
33
+ "types": "./dist/react/main.d.ts",
34
+ "default": "./dist/react.js"
35
+ },
36
+ "./preact": {
37
+ "types": "./dist/preact/main.d.ts",
38
+ "default": "./dist/preact.js"
39
+ },
40
+ "./editor": {
41
+ "types": "./dist/editor/main.d.ts",
42
+ "default": "./dist/editor.js"
43
+ },
44
+ "./web-components/editor": {
45
+ "types": "./dist/web-components/editor/main.d.ts",
46
+ "default": "./dist/web-components-editor.js"
47
+ },
48
+ "./web-components/runtime": {
49
+ "types": "./dist/web-components/runtime/main.d.ts",
50
+ "default": "./dist/web-components-runtime.js"
51
+ }
52
+ },
53
+ "dependencies": {
54
+ "@preact/signals-core": "1.11.0"
55
+ },
56
+ "scripts": {
57
+ "dev": "vite build -w",
58
+ "build": "tsc -b && vite build",
59
+ "preview": "vite preview",
60
+ "test": "vitest"
61
+ }
62
+ }