@ticketlayer/elements 0.2.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 (195) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +55 -0
  3. package/dist/cjs/index-DfzcrE9-.js +3598 -0
  4. package/dist/cjs/index.cjs.js +16 -0
  5. package/dist/cjs/loader.cjs.js +12 -0
  6. package/dist/cjs/order-summary-ZMkJ5bez.js +116 -0
  7. package/dist/cjs/sdk-connector-ClDF3013.js +108 -0
  8. package/dist/cjs/ticketlayer-elements.cjs.js +24 -0
  9. package/dist/cjs/tl-buy-modal.cjs.entry.js +127 -0
  10. package/dist/cjs/tl-buy-tickets-button.cjs.entry.js +131 -0
  11. package/dist/cjs/tl-buy-tickets-wrapper.cjs.entry.js +58 -0
  12. package/dist/cjs/tl-cart-badge.cjs.entry.js +109 -0
  13. package/dist/cjs/tl-cart-drawer.cjs.entry.js +67 -0
  14. package/dist/cjs/tl-cart.cjs.entry.js +148 -0
  15. package/dist/cjs/tl-checkout-wrapper.cjs.entry.js +57 -0
  16. package/dist/cjs/tl-event-card.cjs.entry.js +140 -0
  17. package/dist/cjs/tl-event-list.cjs.entry.js +80 -0
  18. package/dist/cjs/tl-login.cjs.entry.js +184 -0
  19. package/dist/cjs/tl-my-orders.cjs.entry.js +123 -0
  20. package/dist/cjs/tl-occurrence-selector_2.cjs.entry.js +754 -0
  21. package/dist/cjs/tl-order-confirmation.cjs.entry.js +146 -0
  22. package/dist/cjs/tl-order-tickets_2.cjs.entry.js +3198 -0
  23. package/dist/cjs/tl-promo-code.cjs.entry.js +75 -0
  24. package/dist/cjs/tl-seat-map.cjs.entry.js +147 -0
  25. package/dist/collection/collection-manifest.json +29 -0
  26. package/dist/collection/components/tl-buy-modal/tl-buy-modal.css +264 -0
  27. package/dist/collection/components/tl-buy-modal/tl-buy-modal.js +249 -0
  28. package/dist/collection/components/tl-buy-tickets-button/tl-buy-tickets-button.css +120 -0
  29. package/dist/collection/components/tl-buy-tickets-button/tl-buy-tickets-button.js +412 -0
  30. package/dist/collection/components/tl-buy-tickets-wrapper/tl-buy-tickets-wrapper.css +23 -0
  31. package/dist/collection/components/tl-buy-tickets-wrapper/tl-buy-tickets-wrapper.js +192 -0
  32. package/dist/collection/components/tl-cart/tl-cart.css +251 -0
  33. package/dist/collection/components/tl-cart/tl-cart.js +314 -0
  34. package/dist/collection/components/tl-cart-badge/tl-cart-badge.css +138 -0
  35. package/dist/collection/components/tl-cart-badge/tl-cart-badge.js +217 -0
  36. package/dist/collection/components/tl-cart-drawer/tl-cart-drawer.css +98 -0
  37. package/dist/collection/components/tl-cart-drawer/tl-cart-drawer.js +185 -0
  38. package/dist/collection/components/tl-checkout-wrapper/tl-checkout-wrapper.css +23 -0
  39. package/dist/collection/components/tl-checkout-wrapper/tl-checkout-wrapper.js +148 -0
  40. package/dist/collection/components/tl-event-card/event-card-adapter.js +23 -0
  41. package/dist/collection/components/tl-event-card/tl-event-card.css +175 -0
  42. package/dist/collection/components/tl-event-card/tl-event-card.js +205 -0
  43. package/dist/collection/components/tl-event-list/tl-event-list.css +134 -0
  44. package/dist/collection/components/tl-event-list/tl-event-list.js +171 -0
  45. package/dist/collection/components/tl-login/tl-login.css +133 -0
  46. package/dist/collection/components/tl-login/tl-login.js +309 -0
  47. package/dist/collection/components/tl-my-orders/tl-my-orders.css +204 -0
  48. package/dist/collection/components/tl-my-orders/tl-my-orders.js +221 -0
  49. package/dist/collection/components/tl-occurrence-selector/tl-occurrence-selector.css +658 -0
  50. package/dist/collection/components/tl-occurrence-selector/tl-occurrence-selector.js +707 -0
  51. package/dist/collection/components/tl-order-confirmation/tl-order-confirmation.css +176 -0
  52. package/dist/collection/components/tl-order-confirmation/tl-order-confirmation.js +298 -0
  53. package/dist/collection/components/tl-order-tickets/tl-order-tickets.css +30 -0
  54. package/dist/collection/components/tl-order-tickets/tl-order-tickets.js +122 -0
  55. package/dist/collection/components/tl-promo-code/tl-promo-code.css +106 -0
  56. package/dist/collection/components/tl-promo-code/tl-promo-code.js +181 -0
  57. package/dist/collection/components/tl-seat-map/tl-seat-map.css +85 -0
  58. package/dist/collection/components/tl-seat-map/tl-seat-map.js +366 -0
  59. package/dist/collection/components/tl-ticket/tl-ticket.css +90 -0
  60. package/dist/collection/components/tl-ticket/tl-ticket.js +129 -0
  61. package/dist/collection/components/tl-ticket-selector/tl-ticket-selector.css +205 -0
  62. package/dist/collection/components/tl-ticket-selector/tl-ticket-selector.js +332 -0
  63. package/dist/collection/index.js +10 -0
  64. package/dist/collection/utils/order-summary.js +101 -0
  65. package/dist/collection/utils/sdk-connector.js +100 -0
  66. package/dist/collection/utils/testing/mock-sdk.js +95 -0
  67. package/dist/components/index.d.ts +35 -0
  68. package/dist/components/index.js +1 -0
  69. package/dist/components/order-summary.js +1 -0
  70. package/dist/components/sdk-connector.js +1 -0
  71. package/dist/components/tl-buy-modal.d.ts +11 -0
  72. package/dist/components/tl-buy-modal.js +1 -0
  73. package/dist/components/tl-buy-tickets-button.d.ts +11 -0
  74. package/dist/components/tl-buy-tickets-button.js +1 -0
  75. package/dist/components/tl-buy-tickets-wrapper.d.ts +11 -0
  76. package/dist/components/tl-buy-tickets-wrapper.js +1 -0
  77. package/dist/components/tl-buy-tickets-wrapper2.js +1 -0
  78. package/dist/components/tl-cart-badge.d.ts +11 -0
  79. package/dist/components/tl-cart-badge.js +1 -0
  80. package/dist/components/tl-cart-drawer.d.ts +11 -0
  81. package/dist/components/tl-cart-drawer.js +1 -0
  82. package/dist/components/tl-cart.d.ts +11 -0
  83. package/dist/components/tl-cart.js +1 -0
  84. package/dist/components/tl-cart2.js +1 -0
  85. package/dist/components/tl-checkout-wrapper.d.ts +11 -0
  86. package/dist/components/tl-checkout-wrapper.js +1 -0
  87. package/dist/components/tl-checkout-wrapper2.js +1 -0
  88. package/dist/components/tl-event-card.d.ts +11 -0
  89. package/dist/components/tl-event-card.js +1 -0
  90. package/dist/components/tl-event-card2.js +1 -0
  91. package/dist/components/tl-event-list.d.ts +11 -0
  92. package/dist/components/tl-event-list.js +1 -0
  93. package/dist/components/tl-login.d.ts +11 -0
  94. package/dist/components/tl-login.js +1 -0
  95. package/dist/components/tl-login2.js +1 -0
  96. package/dist/components/tl-my-orders.d.ts +11 -0
  97. package/dist/components/tl-my-orders.js +1 -0
  98. package/dist/components/tl-occurrence-selector.d.ts +11 -0
  99. package/dist/components/tl-occurrence-selector.js +1 -0
  100. package/dist/components/tl-occurrence-selector2.js +1 -0
  101. package/dist/components/tl-order-confirmation.d.ts +11 -0
  102. package/dist/components/tl-order-confirmation.js +1 -0
  103. package/dist/components/tl-order-tickets.d.ts +11 -0
  104. package/dist/components/tl-order-tickets.js +1 -0
  105. package/dist/components/tl-order-tickets2.js +1 -0
  106. package/dist/components/tl-promo-code.d.ts +11 -0
  107. package/dist/components/tl-promo-code.js +1 -0
  108. package/dist/components/tl-seat-map.d.ts +11 -0
  109. package/dist/components/tl-seat-map.js +1 -0
  110. package/dist/components/tl-ticket-selector.d.ts +11 -0
  111. package/dist/components/tl-ticket-selector.js +1 -0
  112. package/dist/components/tl-ticket-selector2.js +1 -0
  113. package/dist/components/tl-ticket.d.ts +11 -0
  114. package/dist/components/tl-ticket.js +1 -0
  115. package/dist/components/tl-ticket2.js +1 -0
  116. package/dist/elements.docs.d.ts +454 -0
  117. package/dist/elements.docs.json +3008 -0
  118. package/dist/esm/index-Ba-RZTFI.js +3588 -0
  119. package/dist/esm/index.js +4 -0
  120. package/dist/esm/loader.js +10 -0
  121. package/dist/esm/order-summary-BGekdjN9.js +103 -0
  122. package/dist/esm/sdk-connector-CqhvfyKV.js +102 -0
  123. package/dist/esm/ticketlayer-elements.js +20 -0
  124. package/dist/esm/tl-buy-modal.entry.js +125 -0
  125. package/dist/esm/tl-buy-tickets-button.entry.js +129 -0
  126. package/dist/esm/tl-buy-tickets-wrapper.entry.js +56 -0
  127. package/dist/esm/tl-cart-badge.entry.js +107 -0
  128. package/dist/esm/tl-cart-drawer.entry.js +65 -0
  129. package/dist/esm/tl-cart.entry.js +146 -0
  130. package/dist/esm/tl-checkout-wrapper.entry.js +55 -0
  131. package/dist/esm/tl-event-card.entry.js +138 -0
  132. package/dist/esm/tl-event-list.entry.js +78 -0
  133. package/dist/esm/tl-login.entry.js +182 -0
  134. package/dist/esm/tl-my-orders.entry.js +121 -0
  135. package/dist/esm/tl-occurrence-selector_2.entry.js +751 -0
  136. package/dist/esm/tl-order-confirmation.entry.js +144 -0
  137. package/dist/esm/tl-order-tickets_2.entry.js +3195 -0
  138. package/dist/esm/tl-promo-code.entry.js +73 -0
  139. package/dist/esm/tl-seat-map.entry.js +145 -0
  140. package/dist/index.cjs.js +1 -0
  141. package/dist/index.js +1 -0
  142. package/dist/ticketlayer-elements/index.esm.js +1 -0
  143. package/dist/ticketlayer-elements/p-0291df4c.entry.js +1 -0
  144. package/dist/ticketlayer-elements/p-10f01a1f.entry.js +1 -0
  145. package/dist/ticketlayer-elements/p-11273f8f.entry.js +1 -0
  146. package/dist/ticketlayer-elements/p-340ab4f5.entry.js +1 -0
  147. package/dist/ticketlayer-elements/p-41d22d7c.entry.js +1 -0
  148. package/dist/ticketlayer-elements/p-82752e3b.entry.js +1 -0
  149. package/dist/ticketlayer-elements/p-976770f3.entry.js +1 -0
  150. package/dist/ticketlayer-elements/p-9a903ff6.entry.js +1 -0
  151. package/dist/ticketlayer-elements/p-9c9072c8.entry.js +1 -0
  152. package/dist/ticketlayer-elements/p-9d8163d6.entry.js +1 -0
  153. package/dist/ticketlayer-elements/p-BGekdjN9.js +1 -0
  154. package/dist/ticketlayer-elements/p-Ba-RZTFI.js +2 -0
  155. package/dist/ticketlayer-elements/p-CqhvfyKV.js +1 -0
  156. package/dist/ticketlayer-elements/p-a5c90b68.entry.js +1 -0
  157. package/dist/ticketlayer-elements/p-b6d479ad.entry.js +1 -0
  158. package/dist/ticketlayer-elements/p-dd43f015.entry.js +1 -0
  159. package/dist/ticketlayer-elements/p-eb640760.entry.js +1 -0
  160. package/dist/ticketlayer-elements/p-ee3aa227.entry.js +1 -0
  161. package/dist/ticketlayer-elements/p-fb9444c4.entry.js +1 -0
  162. package/dist/ticketlayer-elements/ticketlayer-elements.css +1 -0
  163. package/dist/ticketlayer-elements/ticketlayer-elements.esm.js +1 -0
  164. package/dist/types/components/tl-buy-modal/tl-buy-modal.d.ts +54 -0
  165. package/dist/types/components/tl-buy-tickets-button/tl-buy-tickets-button.d.ts +61 -0
  166. package/dist/types/components/tl-buy-tickets-wrapper/tl-buy-tickets-wrapper.d.ts +52 -0
  167. package/dist/types/components/tl-cart/tl-cart.d.ts +80 -0
  168. package/dist/types/components/tl-cart-badge/tl-cart-badge.d.ts +36 -0
  169. package/dist/types/components/tl-cart-drawer/tl-cart-drawer.d.ts +35 -0
  170. package/dist/types/components/tl-checkout-wrapper/tl-checkout-wrapper.d.ts +39 -0
  171. package/dist/types/components/tl-event-card/event-card-adapter.d.ts +23 -0
  172. package/dist/types/components/tl-event-card/tl-event-card.d.ts +55 -0
  173. package/dist/types/components/tl-event-list/tl-event-list.d.ts +30 -0
  174. package/dist/types/components/tl-login/tl-login.d.ts +59 -0
  175. package/dist/types/components/tl-my-orders/tl-my-orders.d.ts +39 -0
  176. package/dist/types/components/tl-occurrence-selector/tl-occurrence-selector.d.ts +208 -0
  177. package/dist/types/components/tl-order-confirmation/tl-order-confirmation.d.ts +54 -0
  178. package/dist/types/components/tl-order-tickets/tl-order-tickets.d.ts +21 -0
  179. package/dist/types/components/tl-promo-code/tl-promo-code.d.ts +39 -0
  180. package/dist/types/components/tl-seat-map/tl-seat-map.d.ts +68 -0
  181. package/dist/types/components/tl-ticket/tl-ticket.d.ts +28 -0
  182. package/dist/types/components/tl-ticket-selector/tl-ticket-selector.d.ts +78 -0
  183. package/dist/types/components.d.ts +1629 -0
  184. package/dist/types/index.d.ts +14 -0
  185. package/dist/types/stencil-public-runtime.d.ts +1839 -0
  186. package/dist/types/utils/order-summary.d.ts +67 -0
  187. package/dist/types/utils/sdk-connector.d.ts +113 -0
  188. package/dist/types/utils/testing/mock-sdk.d.ts +36 -0
  189. package/elements.catalogue.json +968 -0
  190. package/loader/cdn.js +1 -0
  191. package/loader/index.cjs.js +1 -0
  192. package/loader/index.d.ts +24 -0
  193. package/loader/index.es2017.js +1 -0
  194. package/loader/index.js +2 -0
  195. package/package.json +101 -0
@@ -0,0 +1,251 @@
1
+ :host {
2
+ display: block;
3
+ font-family: var(--tl-font-family, system-ui, sans-serif);
4
+ }
5
+
6
+ /* Skeleton loading */
7
+ .skeleton-container {
8
+ padding: var(--tl-spacing-4, 1rem);
9
+ }
10
+
11
+ .skeleton-item {
12
+ height: 70px;
13
+ background: var(--tl-color-muted, #f3f4f6);
14
+ border-radius: var(--tl-radius-md, 0.5rem);
15
+ margin-bottom: var(--tl-spacing-3, 0.75rem);
16
+ animation: pulse 1.5s ease-in-out infinite;
17
+ }
18
+
19
+ .skeleton-totals {
20
+ height: 100px;
21
+ background: var(--tl-color-muted, #f3f4f6);
22
+ border-radius: var(--tl-radius-md, 0.5rem);
23
+ animation: pulse 1.5s ease-in-out infinite;
24
+ }
25
+
26
+ @keyframes pulse {
27
+ 0%, 100% { opacity: 1; }
28
+ 50% { opacity: 0.5; }
29
+ }
30
+
31
+ /* Empty cart */
32
+ .empty-cart {
33
+ display: flex;
34
+ flex-direction: column;
35
+ align-items: center;
36
+ justify-content: center;
37
+ padding: var(--tl-spacing-8, 2rem);
38
+ text-align: center;
39
+ }
40
+
41
+ .empty-icon {
42
+ width: 48px;
43
+ height: 48px;
44
+ color: var(--tl-color-muted-foreground, #9ca3af);
45
+ margin-bottom: var(--tl-spacing-4, 1rem);
46
+ }
47
+
48
+ .empty-title {
49
+ margin: 0 0 var(--tl-spacing-2, 0.5rem);
50
+ font-size: 16px;
51
+ font-weight: 600;
52
+ color: var(--tl-color-foreground, #111827);
53
+ }
54
+
55
+ .empty-message {
56
+ margin: 0;
57
+ font-size: 14px;
58
+ color: var(--tl-color-muted-foreground, #6b7280);
59
+ }
60
+
61
+ /* Cart */
62
+ .cart {
63
+ background: var(--tl-color-background, #ffffff);
64
+ }
65
+
66
+ .cart.compact .cart-items {
67
+ margin-bottom: var(--tl-spacing-2, 0.5rem);
68
+ }
69
+
70
+ /* Cart items */
71
+ .cart-items {
72
+ margin-bottom: var(--tl-spacing-4, 1rem);
73
+ }
74
+
75
+ .cart-item {
76
+ display: flex;
77
+ justify-content: space-between;
78
+ align-items: flex-start;
79
+ padding: var(--tl-spacing-3, 0.75rem) 0;
80
+ border-bottom: 1px solid var(--tl-color-border, #e5e7eb);
81
+ transition: opacity 0.2s;
82
+ }
83
+
84
+ .cart-item:last-child {
85
+ border-bottom: none;
86
+ }
87
+
88
+ .cart-item.removing {
89
+ opacity: 0.5;
90
+ }
91
+
92
+ .item-info {
93
+ flex: 1;
94
+ min-width: 0;
95
+ }
96
+
97
+ .item-name {
98
+ margin: 0;
99
+ font-weight: 600;
100
+ font-size: 15px;
101
+ color: var(--tl-color-foreground, #111827);
102
+ }
103
+
104
+ .item-event {
105
+ margin: var(--tl-spacing-1, 0.25rem) 0 0;
106
+ font-size: 14px;
107
+ color: var(--tl-color-muted-foreground, #6b7280);
108
+ }
109
+
110
+ .item-date {
111
+ margin: var(--tl-spacing-1, 0.25rem) 0 0;
112
+ font-size: 13px;
113
+ color: var(--tl-color-muted-foreground, #9ca3af);
114
+ }
115
+
116
+ .item-quantity {
117
+ margin: var(--tl-spacing-1, 0.25rem) 0 0;
118
+ font-size: 13px;
119
+ color: var(--tl-color-muted-foreground, #6b7280);
120
+ }
121
+
122
+ .item-actions {
123
+ display: flex;
124
+ align-items: center;
125
+ gap: var(--tl-spacing-3, 0.75rem);
126
+ margin-left: var(--tl-spacing-4, 1rem);
127
+ }
128
+
129
+ .item-price {
130
+ margin: 0;
131
+ font-weight: 600;
132
+ font-size: 15px;
133
+ color: var(--tl-color-foreground, #111827);
134
+ white-space: nowrap;
135
+ }
136
+
137
+ .remove-btn {
138
+ width: 28px;
139
+ height: 28px;
140
+ padding: 0;
141
+ border: none;
142
+ background: transparent;
143
+ border-radius: var(--tl-radius-sm, 0.25rem);
144
+ color: var(--tl-color-muted-foreground, #9ca3af);
145
+ cursor: pointer;
146
+ display: flex;
147
+ align-items: center;
148
+ justify-content: center;
149
+ transition: background-color 0.15s, color 0.15s;
150
+ }
151
+
152
+ .remove-btn:hover:not(:disabled) {
153
+ background-color: var(--tl-color-destructive-bg, #fee2e2);
154
+ color: var(--tl-color-destructive, #ef4444);
155
+ }
156
+
157
+ .remove-btn:disabled {
158
+ cursor: not-allowed;
159
+ opacity: 0.5;
160
+ }
161
+
162
+ .remove-btn svg {
163
+ width: 16px;
164
+ height: 16px;
165
+ }
166
+
167
+ .spinner {
168
+ width: 14px;
169
+ height: 14px;
170
+ border: 2px solid var(--tl-color-border, #e5e7eb);
171
+ border-top-color: var(--tl-color-primary, #6366f1);
172
+ border-radius: 50%;
173
+ animation: spin 0.6s linear infinite;
174
+ }
175
+
176
+ @keyframes spin {
177
+ to { transform: rotate(360deg); }
178
+ }
179
+
180
+ /* Cart totals */
181
+ .cart-totals {
182
+ padding: var(--tl-spacing-3, 0.75rem) 0;
183
+ border-top: 1px solid var(--tl-color-border, #e5e7eb);
184
+ }
185
+
186
+ .total-row {
187
+ display: flex;
188
+ justify-content: space-between;
189
+ align-items: center;
190
+ padding: var(--tl-spacing-1, 0.25rem) 0;
191
+ }
192
+
193
+ .total-row.subtotal,
194
+ .total-row.fees {
195
+ font-size: 14px;
196
+ color: var(--tl-color-muted-foreground, #6b7280);
197
+ }
198
+
199
+ .total-row.total {
200
+ font-size: 16px;
201
+ font-weight: 700;
202
+ color: var(--tl-color-foreground, #111827);
203
+ padding-top: var(--tl-spacing-2, 0.5rem);
204
+ border-top: 1px solid var(--tl-color-border, #e5e7eb);
205
+ margin-top: var(--tl-spacing-2, 0.5rem);
206
+ }
207
+
208
+ /* Checkout button */
209
+ .checkout-btn {
210
+ width: 100%;
211
+ margin-top: var(--tl-spacing-4, 1rem);
212
+ padding: var(--tl-spacing-3, 0.75rem) var(--tl-spacing-4, 1rem);
213
+ border-radius: var(--tl-radius-md, 0.5rem);
214
+ border: none;
215
+ background-color: var(--tl-color-primary, #6366f1);
216
+ color: var(--tl-color-primary-foreground, #ffffff);
217
+ font-weight: 600;
218
+ font-size: 16px;
219
+ cursor: pointer;
220
+ transition: opacity 0.15s, transform 0.1s;
221
+ }
222
+
223
+ .checkout-btn:hover:not(:disabled) {
224
+ opacity: 0.9;
225
+ }
226
+
227
+ .checkout-btn:active:not(:disabled) {
228
+ transform: scale(0.98);
229
+ }
230
+
231
+ .checkout-btn:disabled {
232
+ background-color: var(--tl-color-muted, #d1d5db);
233
+ color: var(--tl-color-muted-foreground, #6b7280);
234
+ cursor: not-allowed;
235
+ }
236
+
237
+ /* Compact mode overrides */
238
+ .cart.compact .item-info {
239
+ flex-direction: row;
240
+ align-items: center;
241
+ }
242
+
243
+ .cart.compact .cart-totals {
244
+ padding: var(--tl-spacing-2, 0.5rem) 0;
245
+ }
246
+
247
+ .cart.compact .total-row.total {
248
+ margin-top: 0;
249
+ border-top: none;
250
+ padding-top: 0;
251
+ }
@@ -0,0 +1,314 @@
1
+ import { h } from "@stencil/core";
2
+ import { getSDK, hasSDK, whenSDK } from "../../utils/sdk-connector";
3
+ export class TlCart {
4
+ constructor() {
5
+ /**
6
+ * Show checkout button
7
+ */
8
+ this.showCheckoutButton = true;
9
+ /**
10
+ * Checkout button label
11
+ */
12
+ this.checkoutLabel = 'Checkout';
13
+ /**
14
+ * Show remove item buttons
15
+ */
16
+ this.showRemoveButtons = true;
17
+ /**
18
+ * Compact mode - hides some details
19
+ */
20
+ this.compact = false;
21
+ this.cart = null;
22
+ this.loading = true;
23
+ this.error = null;
24
+ this.removingItemId = null;
25
+ this.handleCheckout = () => {
26
+ if (this.cart && this.cart.items.length > 0) {
27
+ this.tlCheckout.emit({ cart: this.cart });
28
+ }
29
+ };
30
+ }
31
+ componentWillLoad() {
32
+ this.loadCart();
33
+ }
34
+ componentDidLoad() {
35
+ this.subscribeToCartUpdates();
36
+ }
37
+ disconnectedCallback() {
38
+ if (this.unsubscribe) {
39
+ this.unsubscribe();
40
+ }
41
+ }
42
+ async loadCart() {
43
+ try {
44
+ console.log('[tl-cart] Loading cart...');
45
+ this.loading = true;
46
+ this.error = null;
47
+ const sdk = await whenSDK();
48
+ const cartManager = sdk.getCartManager?.();
49
+ if (cartManager) {
50
+ const cartData = await cartManager.get();
51
+ console.log('[tl-cart] Cart loaded:', cartData);
52
+ this.cart = cartData;
53
+ }
54
+ }
55
+ catch (err) {
56
+ console.error('[tl-cart] Failed to load cart:', err);
57
+ this.error = err instanceof Error ? err.message : 'Failed to load cart';
58
+ this.tlError.emit({ message: this.error });
59
+ }
60
+ finally {
61
+ this.loading = false;
62
+ }
63
+ }
64
+ async subscribeToCartUpdates() {
65
+ const sdk = await whenSDK().catch(() => null);
66
+ if (!sdk)
67
+ return;
68
+ const cartManager = sdk.getCartManager?.();
69
+ if (!cartManager)
70
+ return;
71
+ this.unsubscribe = cartManager.on?.('cart:updated', (cartData) => {
72
+ console.log('[tl-cart] Cart updated:', cartData);
73
+ this.cart = cartData;
74
+ this.tlCartUpdated.emit({ cart: cartData });
75
+ });
76
+ }
77
+ async handleRemoveItem(itemId) {
78
+ if (!hasSDK())
79
+ return;
80
+ this.removingItemId = itemId;
81
+ try {
82
+ const sdk = getSDK();
83
+ const cartManager = sdk.getCartManager?.();
84
+ if (cartManager) {
85
+ await cartManager.removeItem(itemId);
86
+ console.log('[tl-cart] Item removed:', itemId);
87
+ this.tlItemRemoved.emit({ itemId });
88
+ }
89
+ }
90
+ catch (err) {
91
+ console.error('[tl-cart] Failed to remove item:', err);
92
+ this.error = err instanceof Error ? err.message : 'Failed to remove item';
93
+ this.tlError.emit({ message: this.error });
94
+ }
95
+ finally {
96
+ this.removingItemId = null;
97
+ }
98
+ }
99
+ formatPrice(priceInPence, currency = 'GBP') {
100
+ return new Intl.NumberFormat('en-GB', {
101
+ style: 'currency',
102
+ currency,
103
+ }).format(priceInPence / 100);
104
+ }
105
+ formatDate(dateString) {
106
+ const date = new Date(dateString);
107
+ return date.toLocaleDateString('en-GB', {
108
+ weekday: 'short',
109
+ day: 'numeric',
110
+ month: 'short',
111
+ hour: '2-digit',
112
+ minute: '2-digit',
113
+ });
114
+ }
115
+ renderSkeleton() {
116
+ return (h("div", { class: "skeleton-container" }, h("div", { class: "skeleton-item" }), h("div", { class: "skeleton-item" }), h("div", { class: "skeleton-totals" })));
117
+ }
118
+ renderEmptyCart() {
119
+ return (h("div", { class: "empty-cart" }, h("svg", { class: "empty-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "1.5", d: "M3 3h2l.4 2M7 13h10l4-8H5.4M7 13L5.4 5M7 13l-2.293 2.293c-.63.63-.184 1.707.707 1.707H17m0 0a2 2 0 100 4 2 2 0 000-4zm-8 2a2 2 0 11-4 0 2 2 0 014 0z" })), h("p", { class: "empty-title" }, "Your cart is empty"), h("p", { class: "empty-message" }, "Add tickets to get started")));
120
+ }
121
+ renderCartItem(item) {
122
+ const isRemoving = this.removingItemId === item.id;
123
+ return (h("div", { class: `cart-item ${isRemoving ? 'removing' : ''}`, key: item.id }, h("div", { class: "item-info" }, h("p", { class: "item-name" }, item.ticketTypeName), !this.compact && (h("p", { class: "item-event" }, item.eventName)), !this.compact && item.occurrenceDate && (h("p", { class: "item-date" }, this.formatDate(item.occurrenceDate))), h("p", { class: "item-quantity" }, "Qty: ", item.quantity)), h("div", { class: "item-actions" }, h("p", { class: "item-price" }, this.formatPrice(item.totalPrice, item.currency)), this.showRemoveButtons && (h("button", { class: "remove-btn", onClick: () => this.handleRemoveItem(item.id), disabled: isRemoving, "aria-label": "Remove item" }, isRemoving ? (h("span", { class: "spinner" })) : (h("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "2", d: "M6 18L18 6M6 6l12 12" }))))))));
124
+ }
125
+ render() {
126
+ if (this.loading) {
127
+ return this.renderSkeleton();
128
+ }
129
+ if (!this.cart || this.cart.items.length === 0) {
130
+ return this.renderEmptyCart();
131
+ }
132
+ const { items, subtotal, fees, total, currency } = this.cart;
133
+ return (h("div", { class: `cart ${this.compact ? 'compact' : ''}` }, h("div", { class: "cart-items" }, items.map(item => this.renderCartItem(item))), h("div", { class: "cart-totals" }, !this.compact && (h("div", { class: "total-row subtotal" }, h("span", null, "Subtotal"), h("span", null, this.formatPrice(subtotal, currency)))), fees > 0 && !this.compact && (h("div", { class: "total-row fees" }, h("span", null, "Fees"), h("span", null, this.formatPrice(fees, currency)))), h("div", { class: "total-row total" }, h("span", null, "Total"), h("span", null, this.formatPrice(total, currency)))), this.showCheckoutButton && (h("button", { class: "checkout-btn", onClick: this.handleCheckout, disabled: items.length === 0 }, this.checkoutLabel))));
134
+ }
135
+ static get is() { return "tl-cart"; }
136
+ static get encapsulation() { return "shadow"; }
137
+ static get originalStyleUrls() {
138
+ return {
139
+ "$": ["tl-cart.css"]
140
+ };
141
+ }
142
+ static get styleUrls() {
143
+ return {
144
+ "$": ["tl-cart.css"]
145
+ };
146
+ }
147
+ static get properties() {
148
+ return {
149
+ "showCheckoutButton": {
150
+ "type": "boolean",
151
+ "mutable": false,
152
+ "complexType": {
153
+ "original": "boolean",
154
+ "resolved": "boolean",
155
+ "references": {}
156
+ },
157
+ "required": false,
158
+ "optional": false,
159
+ "docs": {
160
+ "tags": [],
161
+ "text": "Show checkout button"
162
+ },
163
+ "getter": false,
164
+ "setter": false,
165
+ "reflect": false,
166
+ "attribute": "show-checkout-button",
167
+ "defaultValue": "true"
168
+ },
169
+ "checkoutLabel": {
170
+ "type": "string",
171
+ "mutable": false,
172
+ "complexType": {
173
+ "original": "string",
174
+ "resolved": "string",
175
+ "references": {}
176
+ },
177
+ "required": false,
178
+ "optional": false,
179
+ "docs": {
180
+ "tags": [],
181
+ "text": "Checkout button label"
182
+ },
183
+ "getter": false,
184
+ "setter": false,
185
+ "reflect": false,
186
+ "attribute": "checkout-label",
187
+ "defaultValue": "'Checkout'"
188
+ },
189
+ "showRemoveButtons": {
190
+ "type": "boolean",
191
+ "mutable": false,
192
+ "complexType": {
193
+ "original": "boolean",
194
+ "resolved": "boolean",
195
+ "references": {}
196
+ },
197
+ "required": false,
198
+ "optional": false,
199
+ "docs": {
200
+ "tags": [],
201
+ "text": "Show remove item buttons"
202
+ },
203
+ "getter": false,
204
+ "setter": false,
205
+ "reflect": false,
206
+ "attribute": "show-remove-buttons",
207
+ "defaultValue": "true"
208
+ },
209
+ "compact": {
210
+ "type": "boolean",
211
+ "mutable": false,
212
+ "complexType": {
213
+ "original": "boolean",
214
+ "resolved": "boolean",
215
+ "references": {}
216
+ },
217
+ "required": false,
218
+ "optional": false,
219
+ "docs": {
220
+ "tags": [],
221
+ "text": "Compact mode - hides some details"
222
+ },
223
+ "getter": false,
224
+ "setter": false,
225
+ "reflect": false,
226
+ "attribute": "compact",
227
+ "defaultValue": "false"
228
+ }
229
+ };
230
+ }
231
+ static get states() {
232
+ return {
233
+ "cart": {},
234
+ "loading": {},
235
+ "error": {},
236
+ "removingItemId": {}
237
+ };
238
+ }
239
+ static get events() {
240
+ return [{
241
+ "method": "tlCheckout",
242
+ "name": "tlCheckout",
243
+ "bubbles": true,
244
+ "cancelable": true,
245
+ "composed": true,
246
+ "docs": {
247
+ "tags": [],
248
+ "text": "Emitted when checkout is clicked"
249
+ },
250
+ "complexType": {
251
+ "original": "{ cart: TlCartData }",
252
+ "resolved": "{ cart: TlCartData; }",
253
+ "references": {
254
+ "TlCartData": {
255
+ "location": "local",
256
+ "path": "/home/runner/work/live-elements/live-elements/src/components/tl-cart/tl-cart.tsx",
257
+ "id": "src/components/tl-cart/tl-cart.tsx::TlCartData"
258
+ }
259
+ }
260
+ }
261
+ }, {
262
+ "method": "tlItemRemoved",
263
+ "name": "tlItemRemoved",
264
+ "bubbles": true,
265
+ "cancelable": true,
266
+ "composed": true,
267
+ "docs": {
268
+ "tags": [],
269
+ "text": "Emitted when item is removed"
270
+ },
271
+ "complexType": {
272
+ "original": "{ itemId: string }",
273
+ "resolved": "{ itemId: string; }",
274
+ "references": {}
275
+ }
276
+ }, {
277
+ "method": "tlCartUpdated",
278
+ "name": "tlCartUpdated",
279
+ "bubbles": true,
280
+ "cancelable": true,
281
+ "composed": true,
282
+ "docs": {
283
+ "tags": [],
284
+ "text": "Emitted when cart is updated"
285
+ },
286
+ "complexType": {
287
+ "original": "{ cart: TlCartData }",
288
+ "resolved": "{ cart: TlCartData; }",
289
+ "references": {
290
+ "TlCartData": {
291
+ "location": "local",
292
+ "path": "/home/runner/work/live-elements/live-elements/src/components/tl-cart/tl-cart.tsx",
293
+ "id": "src/components/tl-cart/tl-cart.tsx::TlCartData"
294
+ }
295
+ }
296
+ }
297
+ }, {
298
+ "method": "tlError",
299
+ "name": "tlError",
300
+ "bubbles": true,
301
+ "cancelable": true,
302
+ "composed": true,
303
+ "docs": {
304
+ "tags": [],
305
+ "text": "Emitted on error"
306
+ },
307
+ "complexType": {
308
+ "original": "{ message: string }",
309
+ "resolved": "{ message: string; }",
310
+ "references": {}
311
+ }
312
+ }];
313
+ }
314
+ }
@@ -0,0 +1,138 @@
1
+ :host {
2
+ display: inline-block;
3
+ }
4
+
5
+ .cart-badge {
6
+ position: relative;
7
+ display: inline-flex;
8
+ align-items: center;
9
+ justify-content: center;
10
+ background: transparent;
11
+ border: none;
12
+ cursor: pointer;
13
+ padding: var(--tl-spacing-2, 0.5rem);
14
+ border-radius: var(--tl-radius-md, 0.5rem);
15
+ color: var(--tl-color-foreground, #111827);
16
+ transition: background-color 0.2s, transform 0.15s;
17
+ }
18
+
19
+ .cart-badge:hover {
20
+ background-color: var(--tl-color-muted, #f3f4f6);
21
+ }
22
+
23
+ .cart-badge:active {
24
+ transform: scale(0.95);
25
+ }
26
+
27
+ .cart-badge:focus-visible {
28
+ outline: 2px solid var(--tl-color-primary, #6366f1);
29
+ outline-offset: 2px;
30
+ }
31
+
32
+ /* Size variants */
33
+ .size-sm {
34
+ padding: var(--tl-spacing-1, 0.25rem);
35
+ }
36
+
37
+ .size-sm .icon-svg,
38
+ .size-sm .icon-text {
39
+ width: 18px;
40
+ height: 18px;
41
+ font-size: 18px;
42
+ }
43
+
44
+ .size-md .icon-svg,
45
+ .size-md .icon-text {
46
+ width: 24px;
47
+ height: 24px;
48
+ font-size: 24px;
49
+ }
50
+
51
+ .size-lg {
52
+ padding: var(--tl-spacing-3, 0.75rem);
53
+ }
54
+
55
+ .size-lg .icon-svg,
56
+ .size-lg .icon-text {
57
+ width: 32px;
58
+ height: 32px;
59
+ font-size: 32px;
60
+ }
61
+
62
+ /* Icon styles */
63
+ .icon-svg {
64
+ width: 24px;
65
+ height: 24px;
66
+ stroke-width: 2;
67
+ }
68
+
69
+ .icon-text {
70
+ line-height: 1;
71
+ }
72
+
73
+ /* Badge count */
74
+ .badge-count {
75
+ position: absolute;
76
+ top: 0;
77
+ right: 0;
78
+ transform: translate(30%, -30%);
79
+ min-width: 18px;
80
+ height: 18px;
81
+ padding: 0 5px;
82
+ border-radius: 9px;
83
+ background-color: var(--tl-color-primary, #6366f1);
84
+ color: var(--tl-color-primary-foreground, #ffffff);
85
+ font-size: 11px;
86
+ font-weight: 600;
87
+ font-family: var(--tl-font-family, system-ui, sans-serif);
88
+ display: flex;
89
+ align-items: center;
90
+ justify-content: center;
91
+ line-height: 1;
92
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
93
+ }
94
+
95
+ .size-sm .badge-count {
96
+ min-width: 16px;
97
+ height: 16px;
98
+ font-size: 10px;
99
+ padding: 0 4px;
100
+ }
101
+
102
+ .size-lg .badge-count {
103
+ min-width: 22px;
104
+ height: 22px;
105
+ font-size: 13px;
106
+ padding: 0 6px;
107
+ }
108
+
109
+ /* Badge only mode */
110
+ .badge-only {
111
+ display: inline-flex;
112
+ align-items: center;
113
+ justify-content: center;
114
+ min-width: 20px;
115
+ height: 20px;
116
+ padding: 0 6px;
117
+ border-radius: 10px;
118
+ background-color: rgba(255, 255, 255, 0.3);
119
+ color: inherit;
120
+ font-size: 12px;
121
+ font-weight: 600;
122
+ font-family: var(--tl-font-family, system-ui, sans-serif);
123
+ line-height: 1;
124
+ }
125
+
126
+ .badge-only.size-sm {
127
+ min-width: 18px;
128
+ height: 18px;
129
+ font-size: 11px;
130
+ padding: 0 5px;
131
+ }
132
+
133
+ .badge-only.size-lg {
134
+ min-width: 22px;
135
+ height: 22px;
136
+ font-size: 13px;
137
+ padding: 0 7px;
138
+ }