@shopify/ui-extensions 2023.10.0 → 2023.10.2
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/build/cjs/surfaces/checkout/style/style.js +4 -0
- package/build/esm/surfaces/checkout/style/style.mjs +4 -0
- package/build/esnext/surfaces/checkout/style/style.esnext +4 -0
- package/build/ts/surfaces/admin/extension-targets.d.ts +1 -1
- package/build/ts/surfaces/checkout/api/standard/standard.d.ts +2 -2
- package/build/ts/surfaces/checkout/components/shared.d.ts +25 -1
- package/build/ts/surfaces/checkout/components/shared.d.ts.map +1 -1
- package/build/ts/surfaces/checkout/style/style.d.ts +19 -3
- package/build/ts/surfaces/checkout/style/style.d.ts.map +1 -1
- package/build/ts/surfaces/checkout/style/types.d.ts +38 -1
- package/build/ts/surfaces/checkout/style/types.d.ts.map +1 -1
- package/build/ts/surfaces/checkout/targets.d.ts +19 -17
- package/build/ts/surfaces/checkout/targets.d.ts.map +1 -1
- package/build/ts/surfaces/customer-account/targets.d.ts +5 -5
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/surfaces/admin/extension-targets.ts +1 -1
- package/src/surfaces/checkout/api/standard/standard.ts +2 -2
- package/src/surfaces/checkout/components/shared.ts +26 -4
- package/src/surfaces/checkout/style/style.ts +30 -3
- package/src/surfaces/checkout/style/types.ts +54 -4
- package/src/surfaces/checkout/targets.ts +19 -17
- package/src/surfaces/customer-account/targets.ts +5 -5
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import {memoize} from './memoize';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Conditions,
|
|
4
|
+
ConditionalStyle,
|
|
5
|
+
BaseConditions,
|
|
6
|
+
StylesConditions,
|
|
7
|
+
StylesConditionalStyle,
|
|
8
|
+
} from './types';
|
|
3
9
|
import {isEqual} from './isEqual';
|
|
4
10
|
|
|
5
11
|
const MAX_CACHE_SIZE = 50;
|
|
@@ -80,9 +86,30 @@ const when: WhenFunction = function when<
|
|
|
80
86
|
) as WhenReturnType<T, TContext, AcceptedConditions>;
|
|
81
87
|
};
|
|
82
88
|
|
|
89
|
+
// This interface is only used to provide documentation for the Style helper.
|
|
90
|
+
// It is not used in the implementation.
|
|
83
91
|
export interface DocsStyle {
|
|
84
|
-
|
|
85
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Sets an optional default value to use when no other condition is met.
|
|
94
|
+
*
|
|
95
|
+
* @param defaultValue The default value
|
|
96
|
+
* @returns The chainable condition style
|
|
97
|
+
*/
|
|
98
|
+
default: <T>(defaultValue: T) => StylesConditionalStyle<T>;
|
|
99
|
+
/**
|
|
100
|
+
* Adjusts the style based on different conditions. All conditions, expressed
|
|
101
|
+
* as a literal object, must be met for the associated value to be applied.
|
|
102
|
+
*
|
|
103
|
+
* The `when` method can be chained together to build more complex styles.
|
|
104
|
+
*
|
|
105
|
+
* @param conditions The condition(s)
|
|
106
|
+
* @param value The conditional value that can be applied if the conditions are met
|
|
107
|
+
* @returns The chainable condition style
|
|
108
|
+
*/
|
|
109
|
+
when: <T>(
|
|
110
|
+
conditions: StylesConditions,
|
|
111
|
+
value: T,
|
|
112
|
+
) => StylesConditionalStyle<T>;
|
|
86
113
|
}
|
|
87
114
|
|
|
88
115
|
/**
|
|
@@ -26,6 +26,57 @@ export type BaseConditions = AtLeastOne<
|
|
|
26
26
|
DefaultConditions & ResolutionCondition
|
|
27
27
|
>;
|
|
28
28
|
|
|
29
|
+
// This interface is only used to provide documentation for the Style helper.
|
|
30
|
+
// It is not used in the implementation.
|
|
31
|
+
export interface StylesBaseConditions {
|
|
32
|
+
viewportInlineSize?: {min: 'small' | 'medium' | 'large'};
|
|
33
|
+
hover?: true;
|
|
34
|
+
focus?: true;
|
|
35
|
+
resolution?: 1 | 1.3 | 1.5 | 2 | 2.6 | 3 | 3.5 | 4;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// This interface is only used to provide documentation for the Style helper.
|
|
39
|
+
// It is not used in the implementation.
|
|
40
|
+
export interface StylesConditions {
|
|
41
|
+
viewportInlineSize?: {min: 'small' | 'medium' | 'large'};
|
|
42
|
+
hover?: true;
|
|
43
|
+
focus?: true;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// This interface is only used to provide documentation for the Style helper.
|
|
47
|
+
// It is not used in the implementation.
|
|
48
|
+
export interface StylesConditionalValue<
|
|
49
|
+
T,
|
|
50
|
+
AcceptedConditions extends StylesBaseConditions = StylesBaseConditions,
|
|
51
|
+
> {
|
|
52
|
+
/**
|
|
53
|
+
* The conditions that must be met for the value to be applied. At least one
|
|
54
|
+
* condition must be specified.
|
|
55
|
+
*/
|
|
56
|
+
conditions: AcceptedConditions;
|
|
57
|
+
/**
|
|
58
|
+
* The value that will be applied if the conditions are met.
|
|
59
|
+
*/
|
|
60
|
+
value: T;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// This interface is only used to provide documentation for the Style helper.
|
|
64
|
+
// It is not used in the implementation.
|
|
65
|
+
export interface StylesConditionalStyle<
|
|
66
|
+
T,
|
|
67
|
+
AcceptedConditions extends StylesBaseConditions = StylesBaseConditions,
|
|
68
|
+
> {
|
|
69
|
+
/**
|
|
70
|
+
* The default value applied when none of the conditional values
|
|
71
|
+
* specified in `conditionals` are met.
|
|
72
|
+
*/
|
|
73
|
+
default?: T;
|
|
74
|
+
/**
|
|
75
|
+
* An array of conditional values.
|
|
76
|
+
*/
|
|
77
|
+
conditionals: StylesConditionalValue<T, AcceptedConditions>[];
|
|
78
|
+
}
|
|
79
|
+
|
|
29
80
|
export interface ConditionalValue<
|
|
30
81
|
T,
|
|
31
82
|
AcceptedConditions extends BaseConditions = Conditions,
|
|
@@ -66,7 +117,6 @@ export type MaybeConditionalStyle<
|
|
|
66
117
|
AcceptedConditions extends BaseConditions = Conditions,
|
|
67
118
|
> = T | ConditionalStyle<T, AcceptedConditions>;
|
|
68
119
|
|
|
69
|
-
export type MaybeResponsiveConditionalStyle<T> =
|
|
70
|
-
T
|
|
71
|
-
ViewportSizeCondition
|
|
72
|
-
>;
|
|
120
|
+
export type MaybeResponsiveConditionalStyle<T> =
|
|
121
|
+
| T
|
|
122
|
+
| ConditionalStyle<T, ViewportSizeCondition>;
|
|
@@ -81,6 +81,7 @@ export interface ExtensionTargets {
|
|
|
81
81
|
/**
|
|
82
82
|
* A static extension target that renders on every bundle line item, inside the details
|
|
83
83
|
* under the line item properties element. It replaces the default bundle products rendering.
|
|
84
|
+
* @private
|
|
84
85
|
*/
|
|
85
86
|
'purchase.cart-line-item.line-components.render': RenderExtension<
|
|
86
87
|
CartLineItemApi &
|
|
@@ -92,6 +93,7 @@ export interface ExtensionTargets {
|
|
|
92
93
|
* under the line item properties element. It replaces the default bundle products rendering.
|
|
93
94
|
*
|
|
94
95
|
* @deprecated Use `purchase.cart-line-item.line-components.render` instead.
|
|
96
|
+
* @private
|
|
95
97
|
*/
|
|
96
98
|
'Checkout::CartLineDetails::RenderLineComponents': RenderExtension<
|
|
97
99
|
CartLineItemApi &
|
|
@@ -180,7 +182,7 @@ export interface ExtensionTargets {
|
|
|
180
182
|
AnyComponent
|
|
181
183
|
>;
|
|
182
184
|
/**
|
|
183
|
-
* A [block extension target](https://shopify.dev/docs/api/checkout-ui-extensions/extension-targets-overview#block-extension-targets) that renders exclusively on the Thank
|
|
185
|
+
* A [block extension target](https://shopify.dev/docs/api/checkout-ui-extensions/extension-targets-overview#block-extension-targets) that renders exclusively on the **Thank you** page.
|
|
184
186
|
* Unlike static extension targets, block extension targets render where the merchant
|
|
185
187
|
* sets them using the [checkout editor](https://shopify.dev/apps/checkout/test-ui-extensions#test-the-extension-in-the-checkout-editor).
|
|
186
188
|
*
|
|
@@ -193,7 +195,7 @@ export interface ExtensionTargets {
|
|
|
193
195
|
AnyComponent
|
|
194
196
|
>;
|
|
195
197
|
/**
|
|
196
|
-
* A [block extension target](https://shopify.dev/docs/api/checkout-ui-extensions/extension-targets-overview#block-extension-targets) that renders exclusively on the Thank
|
|
198
|
+
* A [block extension target](https://shopify.dev/docs/api/checkout-ui-extensions/extension-targets-overview#block-extension-targets) that renders exclusively on the **Thank you** page.
|
|
197
199
|
* Unlike static extension targets, block extension targets render where the merchant
|
|
198
200
|
* sets them using the [checkout editor](https://shopify.dev/apps/checkout/test-ui-extensions#test-the-extension-in-the-checkout-editor).
|
|
199
201
|
*
|
|
@@ -208,7 +210,7 @@ export interface ExtensionTargets {
|
|
|
208
210
|
>;
|
|
209
211
|
/**
|
|
210
212
|
* A static extension target that renders on every line item, inside the details
|
|
211
|
-
* under the line item properties element on the Thank
|
|
213
|
+
* under the line item properties element on the **Thank you** page.
|
|
212
214
|
*/
|
|
213
215
|
'purchase.thank-you.cart-line-item.render-after': RenderExtension<
|
|
214
216
|
CartLineItemApi &
|
|
@@ -217,7 +219,7 @@ export interface ExtensionTargets {
|
|
|
217
219
|
>;
|
|
218
220
|
/**
|
|
219
221
|
* A static extension target that renders on every line item, inside the details
|
|
220
|
-
* under the line item properties element on the Thank
|
|
222
|
+
* under the line item properties element on the **Thank you** page.
|
|
221
223
|
*
|
|
222
224
|
* @deprecated Use `purchase.thank-you.cart-line-item.render-after` instead.
|
|
223
225
|
*/
|
|
@@ -227,14 +229,14 @@ export interface ExtensionTargets {
|
|
|
227
229
|
AnyComponent
|
|
228
230
|
>;
|
|
229
231
|
/**
|
|
230
|
-
* A static extension target that is rendered after all line items on the Thank
|
|
232
|
+
* A static extension target that is rendered after all line items on the **Thank you** page.
|
|
231
233
|
*/
|
|
232
234
|
'purchase.thank-you.cart-line-list.render-after': RenderExtension<
|
|
233
235
|
StandardApi<'purchase.thank-you.cart-line-list.render-after'>,
|
|
234
236
|
AnyComponent
|
|
235
237
|
>;
|
|
236
238
|
/**
|
|
237
|
-
* A static extension target that is rendered after all line items on the Thank
|
|
239
|
+
* A static extension target that is rendered after all line items on the **Thank you** page.
|
|
238
240
|
*
|
|
239
241
|
* @deprecated Use `purchase.thank-you.cart-line-list.render-after` instead.
|
|
240
242
|
*/
|
|
@@ -243,14 +245,14 @@ export interface ExtensionTargets {
|
|
|
243
245
|
AnyComponent
|
|
244
246
|
>;
|
|
245
247
|
/**
|
|
246
|
-
* A static extension target that is rendered after a purchase below the customer information on the Thank
|
|
248
|
+
* A static extension target that is rendered after a purchase below the customer information on the **Thank you** page.
|
|
247
249
|
*/
|
|
248
250
|
'purchase.thank-you.customer-information.render-after': RenderExtension<
|
|
249
251
|
StandardApi<'purchase.thank-you.customer-information.render-after'>,
|
|
250
252
|
AnyComponent
|
|
251
253
|
>;
|
|
252
254
|
/**
|
|
253
|
-
* A static extension target that is rendered after a purchase below the customer information on the Thank
|
|
255
|
+
* A static extension target that is rendered after a purchase below the customer information on the **Thank you** page.
|
|
254
256
|
*
|
|
255
257
|
* @deprecated Use `purchase.thank-you.customer-information.render-after` instead.
|
|
256
258
|
*/
|
|
@@ -259,7 +261,7 @@ export interface ExtensionTargets {
|
|
|
259
261
|
AnyComponent
|
|
260
262
|
>;
|
|
261
263
|
/**
|
|
262
|
-
* A [block extension target](https://shopify.dev/docs/api/checkout-ui-extensions/extension-targets-overview#block-extension-targets) that renders exclusively on the Order
|
|
264
|
+
* A [block extension target](https://shopify.dev/docs/api/checkout-ui-extensions/extension-targets-overview#block-extension-targets) that renders exclusively on the **Order status** page.
|
|
263
265
|
* Unlike static extension targets, block extension targets render where the merchant
|
|
264
266
|
* sets them using the [checkout editor](https://shopify.dev/apps/checkout/test-ui-extensions#test-the-extension-in-the-checkout-editor).
|
|
265
267
|
*
|
|
@@ -274,7 +276,7 @@ export interface ExtensionTargets {
|
|
|
274
276
|
AnyComponent
|
|
275
277
|
>;
|
|
276
278
|
/**
|
|
277
|
-
* A [block extension target](https://shopify.dev/docs/api/checkout-ui-extensions/extension-targets-overview#block-extension-targets) that renders exclusively on the Order
|
|
279
|
+
* A [block extension target](https://shopify.dev/docs/api/checkout-ui-extensions/extension-targets-overview#block-extension-targets) that renders exclusively on the **Order status** page.
|
|
278
280
|
* Unlike static extension targets, block extension targets render where the merchant
|
|
279
281
|
* sets them using the [checkout editor](https://shopify.dev/apps/checkout/test-ui-extensions#test-the-extension-in-the-checkout-editor).
|
|
280
282
|
*
|
|
@@ -290,7 +292,7 @@ export interface ExtensionTargets {
|
|
|
290
292
|
>;
|
|
291
293
|
/**
|
|
292
294
|
* A static extension target that renders on every line item, inside the details
|
|
293
|
-
* under the line item properties element on the Order
|
|
295
|
+
* under the line item properties element on the **Order status** page.
|
|
294
296
|
*
|
|
295
297
|
* @deprecated Use `customer-account.order-status.cart-line-item.render-after` from `@shopify/ui-extension/customer-account` instead.
|
|
296
298
|
*/
|
|
@@ -302,7 +304,7 @@ export interface ExtensionTargets {
|
|
|
302
304
|
>;
|
|
303
305
|
/**
|
|
304
306
|
* A static extension target that renders on every line item, inside the details
|
|
305
|
-
* under the line item properties element on the Order
|
|
307
|
+
* under the line item properties element on the **Order status** page.
|
|
306
308
|
*
|
|
307
309
|
* @deprecated Use `customer-account.order-status.cart-line-item.render-after` instead.
|
|
308
310
|
*/
|
|
@@ -313,7 +315,7 @@ export interface ExtensionTargets {
|
|
|
313
315
|
AnyComponent
|
|
314
316
|
>;
|
|
315
317
|
/**
|
|
316
|
-
* A static extension target that is rendered after all line items on the Order
|
|
318
|
+
* A static extension target that is rendered after all line items on the **Order status** page.
|
|
317
319
|
*
|
|
318
320
|
* @deprecated Use `customer-account.order-status.cart-line-list.render-after` from `@shopify/ui-extension/customer-account` instead.
|
|
319
321
|
*/
|
|
@@ -323,7 +325,7 @@ export interface ExtensionTargets {
|
|
|
323
325
|
AnyComponent
|
|
324
326
|
>;
|
|
325
327
|
/**
|
|
326
|
-
* A static extension target that is rendered after all line items on the Order
|
|
328
|
+
* A static extension target that is rendered after all line items on the **Order status** page.
|
|
327
329
|
*
|
|
328
330
|
* @deprecated Use `customer-account.order-status.cart-line-list.render-after` from `@shopify/ui-extension/customer-account` instead.
|
|
329
331
|
*/
|
|
@@ -333,7 +335,7 @@ export interface ExtensionTargets {
|
|
|
333
335
|
AnyComponent
|
|
334
336
|
>;
|
|
335
337
|
/**
|
|
336
|
-
* A static extension target that is rendered after a purchase below the customer information on the Order
|
|
338
|
+
* A static extension target that is rendered after a purchase below the customer information on the **Order status** page.
|
|
337
339
|
*
|
|
338
340
|
* @deprecated Use `customer-account.order-status.customer-information.render-after` from `@shopify/ui-extension/customer-account` instead.
|
|
339
341
|
*/
|
|
@@ -343,7 +345,7 @@ export interface ExtensionTargets {
|
|
|
343
345
|
AnyComponent
|
|
344
346
|
>;
|
|
345
347
|
/**
|
|
346
|
-
* A static extension target that is rendered after a purchase below the customer information on the Order
|
|
348
|
+
* A static extension target that is rendered after a purchase below the customer information on the **Order status** page.
|
|
347
349
|
*
|
|
348
350
|
* @deprecated Use `customer-account.order-status.customer-information.render-after` from `@shopify/ui-extension/customer-account` instead.
|
|
349
351
|
*/
|
|
@@ -678,7 +680,7 @@ export type ArgumentsForExtension<Target extends keyof ExtensionTargets> =
|
|
|
678
680
|
|
|
679
681
|
/**
|
|
680
682
|
* A union type containing all of the extension targets that follow the pattern of
|
|
681
|
-
* accepting a [`@remote-ui/core` `RemoteRoot`](https://github.com/Shopify/remote-
|
|
683
|
+
* accepting a [`@remote-ui/core` `RemoteRoot`](https://github.com/Shopify/remote-dom/tree/remote-ui/packages/core)
|
|
682
684
|
* and an additional `api` argument, and using those arguments to render
|
|
683
685
|
* UI.
|
|
684
686
|
*/
|
|
@@ -14,7 +14,7 @@ import type {RenderExtension} from './extension';
|
|
|
14
14
|
*/
|
|
15
15
|
export interface ExtensionTargets {
|
|
16
16
|
/**
|
|
17
|
-
* A [dynamic extension target](https://shopify.dev/docs/api/checkout-ui-extensions/extension-targets-overview#dynamic-extension-targets) that renders exclusively on the Order
|
|
17
|
+
* A [dynamic extension target](https://shopify.dev/docs/api/checkout-ui-extensions/extension-targets-overview#dynamic-extension-targets) that renders exclusively on the **Order status** page.
|
|
18
18
|
* Unlike static extension targets, dynamic extension targets render where the merchant
|
|
19
19
|
* sets them using the [checkout editor](https://shopify.dev/apps/checkout/test-ui-extensions#test-the-extension-in-the-checkout-editor).
|
|
20
20
|
*
|
|
@@ -27,7 +27,7 @@ export interface ExtensionTargets {
|
|
|
27
27
|
>;
|
|
28
28
|
/**
|
|
29
29
|
* A static extension target that renders on every line item, inside the details
|
|
30
|
-
* under the line item properties element on the Order
|
|
30
|
+
* under the line item properties element on the **Order status** page.
|
|
31
31
|
*/
|
|
32
32
|
'customer-account.order-status.cart-line-item.render-after': RenderExtension<
|
|
33
33
|
CartLineItemApi &
|
|
@@ -35,14 +35,14 @@ export interface ExtensionTargets {
|
|
|
35
35
|
AnyComponent
|
|
36
36
|
>;
|
|
37
37
|
/**
|
|
38
|
-
* A static extension target that is rendered after all line items on the Order
|
|
38
|
+
* A static extension target that is rendered after all line items on the **Order status** page.
|
|
39
39
|
*/
|
|
40
40
|
'customer-account.order-status.cart-line-list.render-after': RenderExtension<
|
|
41
41
|
OrderStatusApi<'customer-account.order-status.cart-line-list.render-after'>,
|
|
42
42
|
AnyComponent
|
|
43
43
|
>;
|
|
44
44
|
/**
|
|
45
|
-
* A static extension target that is rendered after a purchase below the customer information on the Order
|
|
45
|
+
* A static extension target that is rendered after a purchase below the customer information on the **Order status** page.
|
|
46
46
|
*/
|
|
47
47
|
'customer-account.order-status.customer-information.render-after': RenderExtension<
|
|
48
48
|
OrderStatusApi<'customer-account.order-status.cart-line-list.render-after'>,
|
|
@@ -68,7 +68,7 @@ export type ArgumentsForExtension<Target extends keyof ExtensionTargets> =
|
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
70
|
* A union type containing all of the extension targets that follow the pattern of
|
|
71
|
-
* accepting a [`@remote-ui/core` `RemoteRoot`](https://github.com/Shopify/remote-
|
|
71
|
+
* accepting a [`@remote-ui/core` `RemoteRoot`](https://github.com/Shopify/remote-dom/tree/remote-ui/packages/core)
|
|
72
72
|
* and an additional `api` argument, and using those arguments to render
|
|
73
73
|
* UI.
|
|
74
74
|
*/
|