@juo/blocks 1.8.1 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.js CHANGED
@@ -513,6 +513,34 @@ function createLoginService(init) {
513
513
  return service;
514
514
  }
515
515
  const LoginServiceContext = createContext("services/login");
516
+ function createMockOrdersAdapter() {
517
+ return {
518
+ async getOrders() {
519
+ return {
520
+ items: [],
521
+ pageInfo: {
522
+ hasNextPage: false,
523
+ hasPrevPage: false,
524
+ startCursor: null,
525
+ endCursor: null
526
+ }
527
+ };
528
+ }
529
+ };
530
+ }
531
+ function createOrdersService(adapter) {
532
+ return {
533
+ async getOrders(params) {
534
+ try {
535
+ const data = await adapter.getOrders(params);
536
+ return { _tag: "Success", data };
537
+ } catch (error) {
538
+ return { _tag: "Failure", error };
539
+ }
540
+ }
541
+ };
542
+ }
543
+ const OrdersServiceContext = createContext("services/orders");
516
544
  function createMockProductAdapter() {
517
545
  const products = [
518
546
  {
@@ -1378,6 +1406,7 @@ export {
1378
1406
  D as DEFAULT_GLOBAL_STYLES,
1379
1407
  DISCOUNT_REJECTION_REASONS,
1380
1408
  LoginServiceContext,
1409
+ OrdersServiceContext,
1381
1410
  ProductServiceContext,
1382
1411
  RouterServiceContext,
1383
1412
  S as SelectedBlockContext,
@@ -1396,10 +1425,12 @@ export {
1396
1425
  i as createCeRenderer,
1397
1426
  createContext,
1398
1427
  createCustomerService,
1428
+ createMockOrdersAdapter,
1399
1429
  createMockProductAdapter,
1400
1430
  createMockRouterService,
1401
1431
  createMockSubscriptionAdapter,
1402
1432
  createMockWorkflowApiAdapter,
1433
+ createOrdersService,
1403
1434
  createProductService,
1404
1435
  createRouterService,
1405
1436
  j as createSelectedBlock,
@@ -1 +1 @@
1
- {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/editor/components.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAmgB9C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,OAAO,CAAC,WAAW,CAA4B;IAC/C,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,uBAAuB,CAA0C;IACzE,OAAO,CAAC,UAAU,CAA2B;IAC7C,OAAO,CAAC,OAAO,CAA4B;IAE3C,MAAM,KAAK,kBAAkB,aAE5B;;IASD,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,aAAa;IA8GrB,OAAO,CAAC,eAAe;IAsCvB,OAAO,CAAC,cAAc;IAgCtB,OAAO,CAAC,uBAAuB;IAO/B,iBAAiB;IAuCjB;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,MAAM,CAAC,oBAAoB;IAuBnC,OAAO,CAAC,kBAAkB,CAA4B;IAEtD,OAAO,CAAC,gBAAgB,CAUtB;IAEF,OAAO,CAAC,gBAAgB,CAKtB;IAEF,oBAAoB;IAUpB,OAAO,CAAC,UAAU;IAQlB,OAAO,CAAC,QAAQ;IAahB,OAAO,CAAC,SAAS;IAWjB,QAAQ,CAAC,KAAK,EAAE,aAAa;IAQ7B,OAAO,CAAC,iBAAiB;IAazB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAaxB,OAAO,CAAC,iBAAiB;CAmD1B;AAMD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,0BAA0B,EAAE,YAAY,CAAC;KAC1C;CACF"}
package/dist/editor.js CHANGED
@@ -717,7 +717,7 @@ const styles = `
717
717
  :host(.active:hover) .block-wrapper__add-btn:hover .block-wrapper__add-btn-surface,
718
718
  :host(.active) .block-wrapper__add-btn--menu-open .block-wrapper__add-btn-surface {
719
719
  width: 60px;
720
- border-radius: 32px;
720
+ border-radius: 2px;
721
721
  padding: 0 6px;
722
722
  }
723
723
 
@@ -769,8 +769,14 @@ const styles = `
769
769
  </style>
770
770
  `;
771
771
  const blockIconSvg = `
772
- <svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
773
- <path d="M4.36328 6.5459C4.96626 6.5459 5.4541 7.03374 5.4541 7.63672V10.9092C5.45405 11.5121 4.96623 12 4.36328 12H1.09082C0.96088 12 0.834934 11.9772 0.717773 11.9346C0.626296 11.9016 0.540642 11.8561 0.461914 11.8008C0.182984 11.6037 3.23667e-05 11.2776 0 10.9092V7.63672C0 7.03377 0.487878 6.54595 1.09082 6.5459H4.36328ZM10.9092 6.5459C11.5122 6.5459 12 7.03374 12 7.63672V10.9092C11.9999 11.5121 11.5121 12 10.9092 12H7.63672C7.50675 12 7.38086 11.9772 7.26367 11.9346C7.17215 11.9016 7.08658 11.8561 7.00781 11.8008C6.72883 11.6037 6.54593 11.2777 6.5459 10.9092V7.63672C6.5459 7.03374 7.03374 6.5459 7.63672 6.5459H10.9092ZM1.09082 7.63672V10.9092H4.36328V7.63672H1.09082ZM7.63672 10.9092H10.9092V7.63672H7.63672V10.9092ZM4.36328 0C4.96623 0 5.45405 0.487878 5.4541 1.09082V4.36328C5.4541 4.96626 4.96626 5.4541 4.36328 5.4541H1.09082C0.96088 5.45409 0.834934 5.43225 0.717773 5.38965C0.626233 5.35663 0.54069 5.31024 0.461914 5.25488C0.183079 5.05776 0 4.73167 0 4.36328V1.09082C4.77994e-05 0.487908 0.487908 4.79046e-05 1.09082 0H4.36328ZM10.9092 0C11.5121 0 12 0.487878 12 1.09082V4.36328C12 4.96626 11.5122 5.4541 10.9092 5.4541H7.63672C7.50675 5.4541 7.38086 5.43226 7.26367 5.38965C7.17208 5.35663 7.08662 5.31026 7.00781 5.25488C6.72893 5.05777 6.5459 4.73171 6.5459 4.36328V1.09082C6.54595 0.487878 7.03377 0 7.63672 0H10.9092ZM1.09082 4.36328H4.36328V1.09082H1.09082V4.36328ZM7.63672 4.36328H10.9092V1.09082H7.63672V4.36328Z" fill="currentColor"/>
772
+ <svg width="14" height="12" viewBox="0 0 14 13" fill="none" xmlns="http://www.w3.org/2000/svg">
773
+ <path d="M2 9.34521H1V10.3452C1 11.4497 1.89453 12.3452 3 12.3452H4V11.3452H3C2.44727 11.3452 2 10.8979 2 10.3452V9.34521Z" fill="currentColor"/>
774
+ <path d="M2 3.34521H1V2.34521C1 1.24072 1.89453 0.345215 3 0.345215H4V1.34521H3C2.44727 1.34521 2 1.79248 2 2.34521V3.34521Z" fill="currentColor"/>
775
+ <path d="M10 1.34521V0.345215H11C12.1055 0.345215 13 1.24072 13 2.34521V3.34521H12V2.34521C12 2.24072 11.9844 2.14014 11.9551 2.04541C11.9023 1.87842 11.8066 1.72998 11.6816 1.61377C11.5039 1.44775 11.2637 1.34521 11 1.34521H10Z" fill="currentColor"/>
776
+ <path d="M12 9.34521H13V10.3452C13 11.4497 12.1055 12.3452 11 12.3452H10V11.3452H11C11.5527 11.3452 12 10.8979 12 10.3452V9.34521Z" fill="currentColor"/>
777
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M0 5.34521C0 4.79248 0.447266 4.34521 1 4.34521H13C13.5527 4.34521 14 4.79248 14 5.34521V7.34521C14 7.89795 13.5527 8.34521 13 8.34521H1C0.880859 8.34521 0.765625 8.32471 0.658203 8.28564C0.574219 8.25537 0.496094 8.21338 0.423828 8.1626C0.167969 7.98193 0 7.68311 0 7.34521V5.34521ZM1 5.34521H13V7.34521H1V5.34521Z" fill="currentColor"/>
778
+ <path d="M5.5 0.345215H8.5V1.34521H5.5V0.345215Z" fill="currentColor"/>
779
+ <path d="M8.5 11.3452H5.5V12.3452H8.5V11.3452Z" fill="currentColor"/>
774
780
  </svg>
775
781
 
776
782
  `;
@@ -1167,7 +1173,7 @@ async function serializeBlock(block) {
1167
1173
  locales
1168
1174
  };
1169
1175
  }
1170
- const EDITOR_BODY_TOP_PADDING_PX = 32;
1176
+ const EDITOR_BODY_TOP_PADDING_PX = 48;
1171
1177
  async function setupEditorMode(deps) {
1172
1178
  const { routerService, themeState } = deps;
1173
1179
  const padStyle = document.createElement("style");
@@ -1,5 +1,6 @@
1
1
  export * from './customer';
2
2
  export * from './login';
3
+ export * from './orders';
3
4
  export * from './product';
4
5
  export * from './router';
5
6
  export * from './subscription';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { OrdersAdapter } from './types';
2
+ /**
3
+ * Returns an empty `OrdersAdapter` shape. Hosts override the methods to seed real fixtures.
4
+ * Used as a starting point by storybook helpers (`createMockOrdersService`) and theme preview.
5
+ */
6
+ export declare function createMockOrdersAdapter(): OrdersAdapter;
7
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../src/services/orders/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C;;;GAGG;AACH,wBAAgB,uBAAuB,IAAI,aAAa,CAcvD"}
@@ -0,0 +1,4 @@
1
+ export type { GetOrdersParams, Order, OrderLine, OrdersAdapter, OrdersService, } from './types';
2
+ export { createMockOrdersAdapter } from './adapter';
3
+ export { createOrdersService, OrdersServiceContext, } from './ordersService';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/orders/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,eAAe,EACf,KAAK,EACL,SAAS,EACT,aAAa,EACb,aAAa,GACd,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAEpD,OAAO,EACL,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { OrdersAdapter, OrdersService } from './types';
2
+ export declare function createOrdersService(adapter: OrdersAdapter): OrdersService;
3
+ export declare const OrdersServiceContext: {
4
+ __context__: OrdersService;
5
+ };
6
+ //# sourceMappingURL=ordersService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ordersService.d.ts","sourceRoot":"","sources":["../../../src/services/orders/ordersService.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE5D,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,aAAa,GAAG,aAAa,CAWzE;AAED,eAAO,MAAM,oBAAoB;;CACgB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ordersService.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ordersService.test.d.ts","sourceRoot":"","sources":["../../../src/services/orders/ordersService.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,52 @@
1
+ import { Image, PaginatedList, Result } from '../../utils';
2
+ export interface OrderLine {
3
+ id: string;
4
+ title: string;
5
+ quantity: number;
6
+ variantImage: Image | null;
7
+ }
8
+ export interface Order {
9
+ /** Numeric Shopify order id (the trailing segment of the order GID). The block prepends `#` for display. */
10
+ id: string;
11
+ createdAt: string;
12
+ placedAt: string | null;
13
+ currencyCode: string;
14
+ totalPrice: number | null;
15
+ /** Raw Shopify financial-status token (e.g. `PAID`, `PARTIALLY_REFUNDED`); the block humanizes it for display. `null` = unknown. */
16
+ financialStatus: string | null;
17
+ /** Raw Shopify fulfillment-status token (e.g. `FULFILLED`, `PARTIALLY_FULFILLED`); the block humanizes it for display. `null` = unknown. */
18
+ fulfillmentStatus: string | null;
19
+ lines: OrderLine[];
20
+ }
21
+ export interface GetOrdersParams {
22
+ limit?: number;
23
+ after?: string;
24
+ before?: string;
25
+ /**
26
+ * DEPRECATED: previously used for free-text / per-subscriptionId server-side
27
+ * search. The backend proxy implementation ignores this parameter; accepted
28
+ * for SDK backward compatibility only. Use `includeOneTime` to control
29
+ * which order types are returned.
30
+ *
31
+ * @deprecated
32
+ */
33
+ query?: string;
34
+ /**
35
+ * When `false` (default), only subscription-driven orders are returned.
36
+ * When `true`, one-time orders are included alongside subscription orders.
37
+ */
38
+ includeOneTime?: boolean;
39
+ /**
40
+ * Sort order. When set to `"placedAt"`, orders are sorted by placement
41
+ * date (newest first). When omitted, the endpoint's default sort is used.
42
+ */
43
+ sort?: "placedAt";
44
+ }
45
+ /** Adapter consumed by `createOrdersService`. Hosts (customer portal, theme, storybook) implement this. */
46
+ export interface OrdersAdapter {
47
+ getOrders(params?: GetOrdersParams): Promise<PaginatedList<Order>>;
48
+ }
49
+ export interface OrdersService {
50
+ getOrders(params?: GetOrdersParams): Promise<Result<PaginatedList<Order>>>;
51
+ }
52
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/services/orders/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAEhE,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,KAAK,GAAG,IAAI,CAAC;CAC5B;AAED,MAAM,WAAW,KAAK;IACpB,4GAA4G;IAC5G,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1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IAAI,CAAC,CAIjD;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,IAAI,CAC5C,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KACzB,IAAI,CAeR;AAED,wBAAgB,UAAU,CAAC,CAAC,SAAS,cAAc,EACjD,OAAO,EAAE,CAAC,GACT,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAOtB;AAED,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,cAAc,EACxD,OAAO,EAAE,CAAC,EACV,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,GACnB,IAAI,CAON;AAED,KAAK,IAAI,CAAC,CAAC,IACT,CAAC,SAAS,MAAM,CAAC,MAAM,CAAC,CAAC,GACrB,GAAG,CAAC,CAAC,CAAC,GACN,CAAC,SAAS,QAAQ,GAChB,CAAC,GACD,CAAC,SAAS,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,GACxB;KACG,CAAC,IAAI,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC3B,GAAG;IAAE,CAAC,EAAE,CAAC,CAAA;CAAE,GACZ,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=context.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.test.d.ts","sourceRoot":"","sources":["../../src/vue/context.test.ts"],"names":[],"mappings":""}
package/dist/vue.js CHANGED
@@ -67,27 +67,28 @@ const ContextProvider = defineComponent((_, { slots }) => {
67
67
  function useProvideContextProvider(root) {
68
68
  provide(key, root);
69
69
  }
70
+ function findBlockAttr(el, attr) {
71
+ var _a;
72
+ if (!el) {
73
+ return null;
74
+ }
75
+ const direct = el.closest(`[${attr}]`);
76
+ if (direct) {
77
+ return direct.getAttribute(attr);
78
+ }
79
+ const rootNode = el.getRootNode();
80
+ if (rootNode instanceof ShadowRoot && rootNode.host instanceof HTMLElement) {
81
+ return ((_a = rootNode.host.closest(`[${attr}]`)) == null ? void 0 : _a.getAttribute(attr)) ?? null;
82
+ }
83
+ return null;
84
+ }
70
85
  function useBlockId() {
71
86
  const root = inject(key);
72
- return computed(() => {
73
- var _a;
74
- if (!((_a = root == null ? void 0 : root.value) == null ? void 0 : _a.parentElement)) {
75
- return null;
76
- }
77
- const parent = root.value.parentElement;
78
- return parent.getAttribute("data-block-id");
79
- });
87
+ return computed(() => findBlockAttr((root == null ? void 0 : root.value) ?? null, "data-block-id"));
80
88
  }
81
89
  function useBlockType() {
82
90
  const root = inject(key);
83
- return computed(() => {
84
- var _a;
85
- if (!((_a = root == null ? void 0 : root.value) == null ? void 0 : _a.parentElement)) {
86
- return null;
87
- }
88
- const parent = root.value.parentElement;
89
- return parent.getAttribute("data-block-type");
90
- });
91
+ return computed(() => findBlockAttr((root == null ? void 0 : root.value) ?? null, "data-block-type"));
91
92
  }
92
93
  function useRegisterTranslationKeys() {
93
94
  const blockId = useBlockId();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@juo/blocks",
3
3
  "private": false,
4
- "version": "1.8.1",
4
+ "version": "1.9.0",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"