@rebilly/instruments 2.0.0-beta → 3.0.1-beta.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 (197) hide show
  1. package/dist/events/index.js +2 -1
  2. package/dist/functions/mount/fetch-data.js +187 -0
  3. package/dist/functions/mount/fetch-data.spec.js +189 -0
  4. package/dist/functions/mount/index.js +132 -164
  5. package/dist/functions/mount/mount.spec.js +2 -4
  6. package/dist/functions/mount/setup-element.js +40 -0
  7. package/dist/functions/mount/setup-framepay-theme.js +95 -0
  8. package/dist/functions/mount/setup-framepay.js +5 -1
  9. package/dist/functions/mount/setup-i18n.js +33 -0
  10. package/dist/functions/mount/setup-options.js +68 -47
  11. package/dist/functions/mount/setup-options.spec.js +66 -0
  12. package/dist/functions/mount/setup-storefront.js +6 -4
  13. package/dist/functions/mount/setup-styles.js +4 -2
  14. package/dist/functions/purchase.js +129 -24
  15. package/dist/functions/purchase.spec.js +13 -10
  16. package/dist/functions/setup.js +85 -0
  17. package/dist/functions/setup.spec.js +87 -0
  18. package/dist/functions/show.js +8 -4
  19. package/dist/functions/show.spec.js +9 -5
  20. package/dist/functions/update.js +39 -24
  21. package/dist/functions/update.spec.js +0 -4
  22. package/dist/i18n/en.json +5 -2
  23. package/dist/i18n/es.json +4 -1
  24. package/dist/index.js +17 -3
  25. package/dist/index.spec.js +3 -16
  26. package/dist/loader/index.js +4 -3
  27. package/dist/storefront/index.js +33 -0
  28. package/dist/storefront/invoices.js +27 -0
  29. package/dist/storefront/models/base-model.js +18 -0
  30. package/dist/storefront/models/invoice-model.js +14 -0
  31. package/dist/storefront/models/plan-model.js +4 -35
  32. package/dist/storefront/models/product-model.js +4 -23
  33. package/dist/storefront/models/summary-model.js +12 -25
  34. package/dist/storefront/models/transaction-model.js +31 -0
  35. package/dist/storefront/payment-instruments.js +47 -0
  36. package/dist/storefront/payment-instruments.spec.js +55 -0
  37. package/dist/storefront/plans.js +10 -18
  38. package/dist/storefront/plans.spec.js +3 -13
  39. package/dist/storefront/products.js +10 -13
  40. package/dist/storefront/products.spec.js +12 -19
  41. package/dist/storefront/purchase.js +23 -12
  42. package/dist/storefront/purchase.spec.js +1 -20
  43. package/dist/storefront/ready-to-pay.js +18 -15
  44. package/dist/storefront/ready-to-pay.spec.js +2 -12
  45. package/dist/storefront/summary.js +21 -17
  46. package/dist/storefront/summary.spec.js +4 -15
  47. package/dist/storefront/transactions.js +27 -0
  48. package/dist/style/base/__snapshots__/theme.spec.js.snap +188 -45
  49. package/dist/style/base/default-theme.js +699 -0
  50. package/dist/style/base/index.js +48 -16
  51. package/dist/style/base/theme.js +16 -48
  52. package/dist/style/base/theme.spec.js +4 -15
  53. package/dist/style/components/address.js +3 -3
  54. package/dist/style/components/button.js +32 -22
  55. package/dist/style/components/divider.js +9 -9
  56. package/dist/style/components/forms/checkbox.js +12 -9
  57. package/dist/style/components/forms/field.js +18 -6
  58. package/dist/style/components/forms/form.js +2 -2
  59. package/dist/style/components/forms/input.js +54 -13
  60. package/dist/style/components/forms/label.js +39 -18
  61. package/dist/style/components/forms/select.js +54 -22
  62. package/dist/style/components/forms/validation.js +53 -6
  63. package/dist/style/components/icons.js +4 -4
  64. package/dist/style/components/loader.js +5 -3
  65. package/dist/style/components/methods.js +18 -15
  66. package/dist/style/components/overlay.js +5 -5
  67. package/dist/style/helpers/index.js +46 -46
  68. package/dist/style/index.js +3 -1
  69. package/dist/style/payment-instruments/payment-card.js +4 -4
  70. package/dist/style/utils/border.js +47 -0
  71. package/dist/style/utils/color-values.js +39 -3
  72. package/dist/style/utils/remove-empty-null.js +20 -0
  73. package/dist/style/vendor/framepay.js +11 -8
  74. package/dist/style/vendor/postmate.js +2 -2
  75. package/dist/style/views/confirmation.js +13 -13
  76. package/dist/style/views/method-selector.js +2 -2
  77. package/dist/style/views/modal.js +6 -6
  78. package/dist/style/views/result.js +4 -4
  79. package/dist/style/views/summary.js +26 -22
  80. package/dist/views/__snapshots__/summary.spec.js.snap +77 -119
  81. package/dist/views/common/iframe/base-iframe.js +2 -0
  82. package/dist/views/common/iframe/modal-iframe.js +50 -4
  83. package/dist/views/confirmation.js +19 -8
  84. package/dist/views/method-selector/generate-digital-wallet.js +12 -3
  85. package/dist/views/method-selector/generate-digital-wallet.spec.js +11 -0
  86. package/dist/views/method-selector/get-payment-methods.js +13 -2
  87. package/dist/views/method-selector/get-payment-methods.spec.js +21 -19
  88. package/dist/views/method-selector/index.js +23 -34
  89. package/dist/views/method-selector/method-selector.spec.js +50 -55
  90. package/dist/views/method-selector/mount-methods.js +5 -8
  91. package/dist/views/modal.js +8 -2
  92. package/dist/views/result.js +3 -4
  93. package/dist/views/summary.js +156 -97
  94. package/dist/views/summary.spec.js +53 -58
  95. package/package.json +4 -2
  96. package/src/events/index.js +2 -1
  97. package/src/functions/mount/fetch-data.js +152 -0
  98. package/src/functions/mount/fetch-data.spec.js +238 -0
  99. package/src/functions/mount/index.js +101 -158
  100. package/src/functions/mount/mount.spec.js +3 -5
  101. package/src/functions/mount/setup-element.js +26 -0
  102. package/src/functions/mount/setup-framepay-theme.js +82 -0
  103. package/src/functions/mount/setup-framepay.js +5 -1
  104. package/src/functions/mount/setup-i18n.js +19 -0
  105. package/src/functions/mount/setup-options.js +78 -48
  106. package/src/functions/mount/setup-options.spec.js +60 -0
  107. package/src/functions/mount/setup-storefront.js +6 -4
  108. package/src/functions/mount/setup-styles.js +4 -2
  109. package/src/functions/on.spec.js +1 -1
  110. package/src/functions/purchase.js +99 -23
  111. package/src/functions/purchase.spec.js +10 -10
  112. package/src/functions/setup.js +48 -0
  113. package/src/functions/setup.spec.js +98 -0
  114. package/src/functions/show.js +2 -4
  115. package/src/functions/show.spec.js +3 -4
  116. package/src/functions/update.js +40 -25
  117. package/src/functions/update.spec.js +0 -4
  118. package/src/i18n/en.json +5 -2
  119. package/src/i18n/es.json +4 -1
  120. package/src/index.js +9 -3
  121. package/src/index.spec.js +3 -21
  122. package/src/loader/index.js +3 -3
  123. package/src/storefront/index.js +28 -0
  124. package/src/storefront/invoices.js +11 -0
  125. package/src/storefront/models/base-model.js +10 -0
  126. package/src/storefront/models/invoice-model.js +3 -0
  127. package/src/storefront/models/plan-model.js +3 -35
  128. package/src/storefront/models/product-model.js +3 -23
  129. package/src/storefront/models/summary-model.js +12 -19
  130. package/src/storefront/models/transaction-model.js +19 -0
  131. package/src/storefront/payment-instruments.js +30 -0
  132. package/src/storefront/payment-instruments.spec.js +69 -0
  133. package/src/storefront/plans.js +6 -17
  134. package/src/storefront/plans.spec.js +4 -11
  135. package/src/storefront/products.js +8 -16
  136. package/src/storefront/products.spec.js +16 -22
  137. package/src/storefront/purchase.js +14 -16
  138. package/src/storefront/purchase.spec.js +2 -14
  139. package/src/storefront/ready-to-pay.js +13 -16
  140. package/src/storefront/ready-to-pay.spec.js +3 -10
  141. package/src/storefront/summary.js +19 -17
  142. package/src/storefront/summary.spec.js +5 -12
  143. package/src/storefront/transactions.js +11 -0
  144. package/src/style/base/__snapshots__/theme.spec.js.snap +188 -45
  145. package/src/style/base/default-theme.js +674 -0
  146. package/src/style/base/index.js +48 -16
  147. package/src/style/base/theme.js +17 -47
  148. package/src/style/base/theme.spec.js +4 -16
  149. package/src/style/components/address.js +3 -3
  150. package/src/style/components/button.js +32 -24
  151. package/src/style/components/divider.js +9 -9
  152. package/src/style/components/forms/checkbox.js +11 -11
  153. package/src/style/components/forms/field.js +18 -6
  154. package/src/style/components/forms/form.js +2 -2
  155. package/src/style/components/forms/input.js +54 -13
  156. package/src/style/components/forms/label.js +39 -18
  157. package/src/style/components/forms/select.js +54 -22
  158. package/src/style/components/forms/validation.js +53 -6
  159. package/src/style/components/icons.js +4 -4
  160. package/src/style/components/loader.js +4 -5
  161. package/src/style/components/methods.js +18 -15
  162. package/src/style/components/overlay.js +5 -5
  163. package/src/style/helpers/index.js +46 -46
  164. package/src/style/index.js +2 -1
  165. package/src/style/payment-instruments/payment-card.js +4 -4
  166. package/src/style/utils/border.js +34 -0
  167. package/src/style/utils/color-values.js +27 -1
  168. package/src/style/utils/remove-empty-null.js +10 -0
  169. package/src/style/vendor/framepay.js +11 -8
  170. package/src/style/vendor/postmate.js +2 -2
  171. package/src/style/views/confirmation.js +13 -13
  172. package/src/style/views/method-selector.js +2 -2
  173. package/src/style/views/modal.js +6 -6
  174. package/src/style/views/result.js +4 -4
  175. package/src/style/views/summary.js +26 -22
  176. package/src/views/__snapshots__/summary.spec.js.snap +77 -119
  177. package/src/views/common/iframe/base-iframe.js +2 -0
  178. package/src/views/common/iframe/modal-iframe.js +45 -3
  179. package/src/views/confirmation.js +15 -5
  180. package/src/views/method-selector/generate-digital-wallet.js +10 -3
  181. package/src/views/method-selector/generate-digital-wallet.spec.js +10 -0
  182. package/src/views/method-selector/get-payment-methods.js +7 -2
  183. package/src/views/method-selector/get-payment-methods.spec.js +26 -23
  184. package/src/views/method-selector/index.js +21 -28
  185. package/src/views/method-selector/method-selector.spec.js +49 -64
  186. package/src/views/method-selector/mount-methods.js +5 -8
  187. package/src/views/modal.js +6 -2
  188. package/src/views/result.js +4 -3
  189. package/src/views/summary.js +161 -117
  190. package/src/views/summary.spec.js +60 -75
  191. package/tests/mocks/rebilly-instruments-mock.js +37 -7
  192. package/tests/mocks/storefront-api-mock.js +8 -0
  193. package/tests/mocks/storefront-mock.js +17 -0
  194. package/dist/functions/mount/fetch-summary-data.js +0 -46
  195. package/dist/functions/mount/fetch-summary-data.spec.js +0 -43
  196. package/src/functions/mount/fetch-summary-data.js +0 -29
  197. package/src/functions/mount/fetch-summary-data.spec.js +0 -40
@@ -0,0 +1,674 @@
1
+ import { mutedTextColor, mutedBorderColor, darken } from '../utils/color-values';
2
+ import Border from '../utils/border';
3
+
4
+ const properties = {
5
+ /** Base Colors */
6
+ colorPrimary: {
7
+ fallback: {
8
+ type: 'static',
9
+ value: '#0044D4',
10
+ }
11
+ },
12
+ colorBackground: {
13
+ fallback: {
14
+ type: 'static',
15
+ value: '#FFFFFF',
16
+ }
17
+ },
18
+ colorText: {
19
+ fallback: {
20
+ type: 'static',
21
+ value: '#0D2B3E',
22
+ }
23
+ },
24
+ colorMutedText: {
25
+ fallback: {
26
+ type: 'func',
27
+ value: theme => mutedTextColor(theme.colorText)
28
+ }
29
+ },
30
+ colorMutedBorder: {
31
+ fallback: {
32
+ type: 'func',
33
+ value: theme => mutedBorderColor(theme.colorText)
34
+ }
35
+ },
36
+ colorDanger: {
37
+ fallback: {
38
+ type: 'static',
39
+ value: '#CD5C5C',
40
+ }
41
+ },
42
+
43
+ /** Base Fonts */
44
+ fontFamily: {
45
+ fallback: {
46
+ type: 'static',
47
+ value: 'Avenir, Helvetica, Arial, sans-serif',
48
+ }
49
+ },
50
+ fontSizeBase: {
51
+ fallback: {
52
+ type: 'static',
53
+ value: '16px',
54
+ }
55
+ },
56
+ fontWeightBase: {
57
+ fallback: {
58
+ type: 'static',
59
+ value: '400',
60
+ }
61
+ },
62
+ fontLineHeightBase: {
63
+ fallback: {
64
+ type: 'static',
65
+ value: 'initial',
66
+ }
67
+ },
68
+ fontSmooth: {
69
+ fallback: {
70
+ type: 'static',
71
+ value: 'auto',
72
+ }
73
+ },
74
+
75
+ /** Misc */
76
+ borderRadius: {
77
+ fallback: {
78
+ type: 'static',
79
+ value: '4px',
80
+ }
81
+ },
82
+
83
+ /** Headings */
84
+ headingFontFamily: {
85
+ fallback: {
86
+ type: 'variable',
87
+ value: 'fontFamily',
88
+ }
89
+ },
90
+ headingFontWeight: {
91
+ fallback: {
92
+ type: 'static',
93
+ value: '500',
94
+ }
95
+ },
96
+ headingColorText: {
97
+ fallback: {
98
+ type: 'variable',
99
+ value: 'colorText',
100
+ }
101
+ },
102
+
103
+ /** Buttons */
104
+ buttonColorBackground: {
105
+ fallback: {
106
+ type: 'variable',
107
+ value: 'colorPrimary',
108
+ }
109
+ },
110
+ buttonColorText: {
111
+ fallback: {
112
+ type: 'static',
113
+ value: '#FFFFFF',
114
+ }
115
+ },
116
+ buttonFontFamily: {
117
+ fallback: {
118
+ type: 'variable',
119
+ value: 'fontFamily',
120
+ }
121
+ },
122
+ buttonFontSize: {
123
+ fallback: {
124
+ type: 'variable',
125
+ value: 'fontSizeBase',
126
+ }
127
+ },
128
+ buttonFontLineHeight: {
129
+ fallback: {
130
+ type: 'static',
131
+ value: '1.5',
132
+ }
133
+ },
134
+ buttonFontWeight: {
135
+ fallback: {
136
+ type: 'variable',
137
+ value: 'fontWeightBase',
138
+ }
139
+ },
140
+ buttonBorder: {
141
+ fallback: {
142
+ type: 'static',
143
+ value: '1px solid transparent',
144
+ }
145
+ },
146
+ buttonBorderRadius: {
147
+ fallback: {
148
+ type: 'variable',
149
+ value: 'borderRadius',
150
+ }
151
+ },
152
+ buttonBoxShadow: {
153
+ fallback: {
154
+ type: 'static',
155
+ value: 'none',
156
+ }
157
+ },
158
+
159
+ /** Buttons: Alternative States */
160
+ buttonHoverColorBackground: {
161
+ fallback: {
162
+ type: 'func',
163
+ value: theme => {
164
+ if(theme.buttonColorBackgroundProvided) {
165
+ return darken(theme.buttonColorBackground, 20);
166
+ }
167
+ return darken(theme.colorPrimary, 20);
168
+ }
169
+ }
170
+ },
171
+
172
+ buttonActiveColorBackground: {
173
+ fallback: {
174
+ type: 'variable',
175
+ value: 'buttonHoverColorBackground',
176
+ }
177
+ },
178
+
179
+ /** Inputs: Base */
180
+ inputColorBackground: {
181
+ fallback: {
182
+ type: 'static',
183
+ value: 'transparent',
184
+ }
185
+ },
186
+ inputColorText: {
187
+ fallback: {
188
+ type: 'variable',
189
+ value: 'colorText'
190
+ }
191
+ },
192
+ inputFontFamily: {
193
+ fallback: {
194
+ type: 'variable',
195
+ value: 'fontFamily',
196
+ }
197
+ },
198
+ inputFontSize: {
199
+ fallback: {
200
+ type: 'variable',
201
+ value: 'fontSizeBase',
202
+ }
203
+ },
204
+ inputFontLineHeight: {
205
+ fallback: {
206
+ type: 'static',
207
+ value: '1.5',
208
+ }
209
+ },
210
+ inputFontWeight: {
211
+ fallback: {
212
+ type: 'variable',
213
+ value: 'fontWeightBase',
214
+ }
215
+ },
216
+ inputBorder: {
217
+ fallback: {
218
+ type: 'func',
219
+ value: theme => `1px solid ${mutedBorderColor(theme.colorText)}`
220
+ }
221
+ },
222
+ inputBorderRadius: {
223
+ fallback: {
224
+ type: 'variable',
225
+ value: 'borderRadius',
226
+ }
227
+ },
228
+ inputBoxShadow: {
229
+ fallback: {
230
+ type: 'static',
231
+ value: 'none',
232
+ }
233
+ },
234
+
235
+ /** Inputs: Hover */
236
+ inputHoverColorBackground: {
237
+ fallback: {
238
+ type: 'variable',
239
+ value: 'inputColorBackground',
240
+ }
241
+ },
242
+ inputHoverColorText: {
243
+ fallback: {
244
+ type: 'variable',
245
+ value: 'inputColorText'
246
+ }
247
+ },
248
+ inputHoverFontFamily: {
249
+ fallback: {
250
+ type: 'variable',
251
+ value: 'inputFontFamily',
252
+ }
253
+ },
254
+ inputHoverFontSize: {
255
+ fallback: {
256
+ type: 'variable',
257
+ value: 'inputFontSize',
258
+ }
259
+ },
260
+ inputHoverFontLineHeight: {
261
+ fallback: {
262
+ type: 'variable',
263
+ value: 'inputFontLineHeight',
264
+ }
265
+ },
266
+ inputHoverFontWeight: {
267
+ fallback: {
268
+ type: 'variable',
269
+ value: 'inputFontWeight',
270
+ }
271
+ },
272
+ inputHoverBorder: {
273
+ fallback: {
274
+ type: 'variable',
275
+ value: 'inputBorder',
276
+ }
277
+ },
278
+ inputHoverBorderRadius: {
279
+ fallback: {
280
+ type: 'variable',
281
+ value: 'inputBorderRadius',
282
+ }
283
+ },
284
+ inputHoverBoxShadow: {
285
+ fallback: {
286
+ type: 'variable',
287
+ value: 'inputBoxShadow',
288
+ }
289
+ },
290
+
291
+ /** Inputs: Focus */
292
+ inputFocusColorBackground: {
293
+ fallback: {
294
+ type: 'variable',
295
+ value: 'inputHoverColorBackground',
296
+ }
297
+ },
298
+ inputFocusColorText: {
299
+ fallback: {
300
+ type: 'variable',
301
+ value: 'inputHoverColorText'
302
+ }
303
+ },
304
+ inputFocusFontFamily: {
305
+ fallback: {
306
+ type: 'variable',
307
+ value: 'inputHoverFontFamily',
308
+ }
309
+ },
310
+ inputFocusFontSize: {
311
+ fallback: {
312
+ type: 'variable',
313
+ value: 'inputHoverFontSize',
314
+ }
315
+ },
316
+ inputFocusFontLineHeight: {
317
+ fallback: {
318
+ type: 'variable',
319
+ value: 'inputHoverFontLineHeight',
320
+ }
321
+ },
322
+ inputFocusFontWeight: {
323
+ fallback: {
324
+ type: 'variable',
325
+ value: 'inputHoverFontWeight',
326
+ }
327
+ },
328
+ inputFocusBorder: {
329
+ fallback: {
330
+ type: 'func',
331
+ value: theme => {
332
+ if(theme.inputHoverBorderProvided) {
333
+ return theme.inputHoverBorder;
334
+ }
335
+ const inputBorder = new Border(theme.inputBorder);
336
+ return inputBorder.updateColor(theme.colorPrimary).value;
337
+ }
338
+ }
339
+ },
340
+ inputFocusBorderRadius: {
341
+ fallback: {
342
+ type: 'variable',
343
+ value: 'inputHoverBorderRadius',
344
+ }
345
+ },
346
+ inputFocusBoxShadow: {
347
+ fallback: {
348
+ type: 'func',
349
+ value: theme => `0 0 0 1px ${theme.colorPrimary}`,
350
+ }
351
+ },
352
+
353
+ /** Inputs: Placholder */
354
+ inputPlaceholderColorText: {
355
+ fallback: {
356
+ type: 'func',
357
+ value: theme => {
358
+ if(theme.inputColorTextProvided) {
359
+ return mutedTextColor(theme.inputColorText);
360
+ }
361
+ return mutedTextColor(theme.colorText);
362
+ }
363
+ }
364
+ },
365
+ inputPlaceholderFontFamily: {
366
+ fallback: {
367
+ type: 'variable',
368
+ value: 'inputFontFamily',
369
+ }
370
+ },
371
+ inputPlaceholderFontSize: {
372
+ fallback: {
373
+ type: 'variable',
374
+ value: 'inputFontSize',
375
+ }
376
+ },
377
+ inputPlaceholderFontLineHeight: {
378
+ fallback: {
379
+ type: 'variable',
380
+ value: 'inputFontLineHeight',
381
+ }
382
+ },
383
+ inputPlaceholderFontWeight: {
384
+ fallback: {
385
+ type: 'variable',
386
+ value: 'inputFontWeight',
387
+ }
388
+ },
389
+
390
+ /** Inputs: Selection */
391
+ inputSelectionColorText: {
392
+ fallback: {
393
+ type: 'static',
394
+ value: 'initial',
395
+ }
396
+ },
397
+ inputSelectionColorBackground: {
398
+ fallback: {
399
+ type: 'static',
400
+ value: 'highlight',
401
+ }
402
+ },
403
+
404
+ /** Inputs Error */
405
+ inputErrorColorBackground: {
406
+ fallback: {
407
+ type: 'variable',
408
+ value: 'inputColorBackground',
409
+ }
410
+ },
411
+ inputErrorColorText: {
412
+ fallback: {
413
+ type: 'variable',
414
+ value: 'colorDanger'
415
+ }
416
+ },
417
+ inputErrorFontFamily: {
418
+ fallback: {
419
+ type: 'variable',
420
+ value: 'inputFontFamily',
421
+ }
422
+ },
423
+ inputErrorFontSize: {
424
+ fallback: {
425
+ type: 'variable',
426
+ value: 'inputFontSize',
427
+ }
428
+ },
429
+ inputErrorFontLineHeight: {
430
+ fallback: {
431
+ type: 'variable',
432
+ value: 'inputFontLineHeight',
433
+ }
434
+ },
435
+ inputErrorFontWeight: {
436
+ fallback: {
437
+ type: 'variable',
438
+ value: 'inputFontWeight',
439
+ }
440
+ },
441
+ inputErrorBorder: {
442
+ fallback: {
443
+ type: 'func',
444
+ value: theme => {
445
+ if(theme.inputBorderProvided) {
446
+ const inputBorder = new Border(theme.inputBorder);
447
+ return inputBorder.updateColor(theme.colorDanger).value;
448
+ }
449
+ return `1px solid ${theme.colorDanger}`;
450
+ }
451
+ }
452
+ },
453
+ inputErrorBorderRadius: {
454
+ fallback: {
455
+ type: 'variable',
456
+ value: 'inputBorderRadius',
457
+ }
458
+ },
459
+ inputErrorBoxShadow: {
460
+ fallback: {
461
+ type: 'variable',
462
+ value: 'inputBoxShadow',
463
+ }
464
+ },
465
+
466
+ /** Inputs Error: Hover */
467
+ inputErrorHoverColorBackground: {
468
+ fallback: {
469
+ type: 'variable',
470
+ value: 'inputErrorColorBackground',
471
+ }
472
+ },
473
+ inputErrorHoverColorText: {
474
+ fallback: {
475
+ type: 'variable',
476
+ value: 'inputErrorColorText'
477
+ }
478
+ },
479
+ inputErrorHoverFontFamily: {
480
+ fallback: {
481
+ type: 'variable',
482
+ value: 'inputErrorFontFamily',
483
+ }
484
+ },
485
+ inputErrorHoverFontSize: {
486
+ fallback: {
487
+ type: 'variable',
488
+ value: 'inputErrorFontSize',
489
+ }
490
+ },
491
+ inputErrorHoverFontLineHeight: {
492
+ fallback: {
493
+ type: 'variable',
494
+ value: 'inputErrorFontLineHeight',
495
+ }
496
+ },
497
+ inputErrorHoverFontWeight: {
498
+ fallback: {
499
+ type: 'variable',
500
+ value: 'inputErrorFontWeight',
501
+ }
502
+ },
503
+ inputErrorHoverBorder: {
504
+ fallback: {
505
+ type: 'variable',
506
+ value: 'inputErrorBorder'
507
+ }
508
+ },
509
+ inputErrorHoverBorderRadius: {
510
+ fallback: {
511
+ type: 'variable',
512
+ value: 'inputErrorBorderRadius',
513
+ }
514
+ },
515
+ inputErrorHoverBoxShadow: {
516
+ fallback: {
517
+ type: 'variable',
518
+ value: 'inputErrorBoxShadow',
519
+ }
520
+ },
521
+
522
+ /** Inputs Error: Focus */
523
+ inputErrorFocusColorBackground: {
524
+ fallback: {
525
+ type: 'variable',
526
+ value: 'inputErrorHoverColorBackground',
527
+ }
528
+ },
529
+ inputErrorFocusColorText: {
530
+ fallback: {
531
+ type: 'variable',
532
+ value: 'inputErrorHoverColorText'
533
+ }
534
+ },
535
+ inputErrorFocusFontFamily: {
536
+ fallback: {
537
+ type: 'variable',
538
+ value: 'inputErrorHoverFontFamily',
539
+ }
540
+ },
541
+ inputErrorFocusFontSize: {
542
+ fallback: {
543
+ type: 'variable',
544
+ value: 'inputErrorHoverFontSize',
545
+ }
546
+ },
547
+ inputErrorFocusFontLineHeight: {
548
+ fallback: {
549
+ type: 'variable',
550
+ value: 'inputErrorHoverFontLineHeight',
551
+ }
552
+ },
553
+ inputErrorFocusFontWeight: {
554
+ fallback: {
555
+ type: 'variable',
556
+ value: 'inputErrorHoverFontWeight',
557
+ }
558
+ },
559
+ inputErrorFocusBorder: {
560
+ fallback: {
561
+ type: 'variable',
562
+ value: 'inputErrorHoverBorder'
563
+ }
564
+ },
565
+ inputErrorFocusBorderRadius: {
566
+ fallback: {
567
+ type: 'variable',
568
+ value: 'inputErrorHoverBorderRadius',
569
+ }
570
+ },
571
+ inputErrorFocusBoxShadow: {
572
+ fallback: {
573
+ type: 'variable',
574
+ value: 'inputErrorHoverBoxShadow',
575
+ }
576
+ },
577
+
578
+ /** Inputs Error: Placholder */
579
+ inputErrorPlaceholderColorText: {
580
+ fallback: {
581
+ type: 'func',
582
+ value: theme => {
583
+ if(theme.inputErrorColorTextProvided) {
584
+ return mutedTextColor(theme.inputErrorColorText);
585
+ }
586
+ return mutedTextColor(theme.colorDanger);
587
+ }
588
+ }
589
+ },
590
+ inputErrorPlaceholderFontFamily: {
591
+ fallback: {
592
+ type: 'variable',
593
+ value: 'inputPlaceholderFontFamily',
594
+ }
595
+ },
596
+ inputErrorPlaceholderFontSize: {
597
+ fallback: {
598
+ type: 'variable',
599
+ value: 'inputPlaceholderFontSize',
600
+ }
601
+ },
602
+ inputErrorPlaceholderFontLineHeight: {
603
+ fallback: {
604
+ type: 'variable',
605
+ value: 'inputPlaceholderFontLineHeight',
606
+ }
607
+ },
608
+ inputErrorPlaceholderFontWeight: {
609
+ fallback: {
610
+ type: 'variable',
611
+ value: 'inputPlaceholderFontWeight',
612
+ }
613
+ },
614
+
615
+ /** Inputs Error: Selection */
616
+ inputErrorSelectionColorText: {
617
+ fallback: {
618
+ type: 'variable',
619
+ value: 'inputSelectionColorText',
620
+ }
621
+ },
622
+ inputErrorSelectionColorBackground: {
623
+ fallback: {
624
+ type: 'variable',
625
+ value: 'inputSelectionColorBackground',
626
+ }
627
+ },
628
+
629
+ /** Labels */
630
+ labels: {
631
+ fallback: {
632
+ type: 'static',
633
+ value: 'floating',
634
+ }
635
+ },
636
+ }
637
+
638
+
639
+ export default new Proxy(properties, {
640
+ get(obj, prop, receiver) {
641
+ if(prop in obj) {
642
+ if(obj[prop].value) {
643
+ return obj[prop].value;
644
+ }
645
+ const { type, value } = obj[prop].fallback;
646
+ if(type === 'static') {
647
+ return value;
648
+ }
649
+ if(type === 'variable') {
650
+ return `var(--rebilly-${value})`;
651
+ }
652
+ if(type === 'func') {
653
+ return value(receiver);
654
+ }
655
+ }
656
+ if(prop.endsWith('Provided')) {
657
+ const target = prop.replace('Provided', '');
658
+ if(target in obj) {
659
+ return obj[target].isProvided;
660
+ }
661
+ }
662
+ return undefined;
663
+ },
664
+
665
+ set: (obj, prop, value) => {
666
+ if(!(prop in obj) || !value) {
667
+ throw new Error(`Invalid theme option provided: ${prop}`);
668
+ }
669
+
670
+ obj[prop].value = value;
671
+ obj[prop].isProvided = true;
672
+ return true;
673
+ }
674
+ });