fontdue-js 2.19.1 → 2.20.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 (125) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +11 -10
  3. package/dist/__generated__/CartItemProduct_product.graphql.d.ts +1 -7
  4. package/dist/__generated__/CartItemProduct_product.graphql.js +11 -36
  5. package/dist/__generated__/CartOrderCompleteOrderMutation.graphql.d.ts +1 -1
  6. package/dist/__generated__/CartOrderCompleteOrderMutation.graphql.js +65 -23
  7. package/dist/__generated__/CartOrderRemoveDiscountMutation.graphql.d.ts +1 -1
  8. package/dist/__generated__/CartOrderRemoveDiscountMutation.graphql.js +65 -23
  9. package/dist/__generated__/CartOrderUpdateMutation.graphql.d.ts +1 -1
  10. package/dist/__generated__/CartOrderUpdateMutation.graphql.js +65 -23
  11. package/dist/__generated__/CartQuery.graphql.d.ts +1 -1
  12. package/dist/__generated__/CartQuery.graphql.js +119 -87
  13. package/dist/__generated__/CartStateUpdateMutation.graphql.d.ts +1 -1
  14. package/dist/__generated__/CartStateUpdateMutation.graphql.js +65 -23
  15. package/dist/__generated__/CharacterViewerIDQuery.graphql.d.ts +1 -1
  16. package/dist/__generated__/CharacterViewerIDQuery.graphql.js +40 -26
  17. package/dist/__generated__/CharacterViewerSlugQuery.graphql.d.ts +1 -1
  18. package/dist/__generated__/CharacterViewerSlugQuery.graphql.js +40 -26
  19. package/dist/__generated__/CharacterViewerStyleRefetchQuery.graphql.d.ts +1 -1
  20. package/dist/__generated__/CharacterViewerStyleRefetchQuery.graphql.js +62 -41
  21. package/dist/__generated__/CharacterViewer_collection.graphql.d.ts +1 -3
  22. package/dist/__generated__/CharacterViewer_collection.graphql.js +6 -13
  23. package/dist/__generated__/CharacterViewer_family.graphql.d.ts +1 -2
  24. package/dist/__generated__/CharacterViewer_family.graphql.js +2 -8
  25. package/dist/__generated__/CharacterViewer_style.graphql.d.ts +2 -1
  26. package/dist/__generated__/CharacterViewer_style.graphql.js +6 -2
  27. package/dist/__generated__/CheckoutUpdateCustomerMutation.graphql.d.ts +1 -1
  28. package/dist/__generated__/CheckoutUpdateCustomerMutation.graphql.js +65 -23
  29. package/dist/__generated__/CheckoutUpdateOrderMutation.graphql.d.ts +1 -1
  30. package/dist/__generated__/CheckoutUpdateOrderMutation.graphql.js +65 -23
  31. package/dist/__generated__/CollectionAa_Query.graphql.d.ts +1 -1
  32. package/dist/__generated__/CollectionAa_Query.graphql.js +57 -3
  33. package/dist/__generated__/Family_node.graphql.d.ts +1 -2
  34. package/dist/__generated__/Family_node.graphql.js +2 -8
  35. package/dist/__generated__/FontFamiliesQuery.graphql.d.ts +1 -1
  36. package/dist/__generated__/FontFamiliesQuery.graphql.js +80 -31
  37. package/dist/__generated__/FontStyle_fontStyle.graphql.d.ts +2 -3
  38. package/dist/__generated__/FontStyle_fontStyle.graphql.js +4 -12
  39. package/dist/__generated__/PrecartAddToCartMutation.graphql.d.ts +1 -1
  40. package/dist/__generated__/PrecartAddToCartMutation.graphql.js +71 -29
  41. package/dist/__generated__/ServerConfigProviderQuery.graphql.d.ts +24 -0
  42. package/dist/__generated__/ServerConfigProviderQuery.graphql.js +108 -0
  43. package/dist/__generated__/StoreModalCartQuery.graphql.d.ts +1 -1
  44. package/dist/__generated__/StoreModalCartQuery.graphql.js +108 -76
  45. package/dist/__generated__/StoreModalContainerQuery.graphql.d.ts +4 -7
  46. package/dist/__generated__/StoreModalContainerQuery.graphql.js +58 -25
  47. package/dist/__generated__/StoreModalFamily_collection.graphql.d.ts +1 -2
  48. package/dist/__generated__/StoreModalFamily_collection.graphql.js +2 -8
  49. package/dist/__generated__/StoreModalIndexItem_fontCollection.graphql.d.ts +1 -4
  50. package/dist/__generated__/StoreModalIndexItem_fontCollection.graphql.js +2 -17
  51. package/dist/__generated__/StoreModalIndexQuery.graphql.d.ts +1 -1
  52. package/dist/__generated__/StoreModalIndexQuery.graphql.js +48 -9
  53. package/dist/__generated__/StoreModalProductQuery.graphql.d.ts +1 -1
  54. package/dist/__generated__/StoreModalProductQuery.graphql.js +85 -41
  55. package/dist/__generated__/StoreModalProductRefetchQuery.graphql.d.ts +1 -1
  56. package/dist/__generated__/StoreModalProductRefetchQuery.graphql.js +78 -34
  57. package/dist/__generated__/TestFontsFormUpdateCustomerMutation.graphql.d.ts +1 -1
  58. package/dist/__generated__/TestFontsFormUpdateCustomerMutation.graphql.js +65 -23
  59. package/dist/__generated__/TypeTesterStandaloneChangedStylesQuery.graphql.d.ts +1 -1
  60. package/dist/__generated__/TypeTesterStandaloneChangedStylesQuery.graphql.js +55 -7
  61. package/dist/__generated__/TypeTesterStandaloneQuery.graphql.d.ts +1 -1
  62. package/dist/__generated__/TypeTesterStandaloneQuery.graphql.js +56 -8
  63. package/dist/__generated__/TypeTester_fontStyle.graphql.d.ts +1 -4
  64. package/dist/__generated__/TypeTester_fontStyle.graphql.js +2 -17
  65. package/dist/__generated__/TypeTestersChangedStylesQuery.graphql.d.ts +1 -1
  66. package/dist/__generated__/TypeTestersChangedStylesQuery.graphql.js +55 -7
  67. package/dist/__generated__/TypeTestersIDQuery.graphql.d.ts +1 -1
  68. package/dist/__generated__/TypeTestersIDQuery.graphql.js +55 -7
  69. package/dist/__generated__/TypeTestersRefetchQuery.graphql.d.ts +1 -1
  70. package/dist/__generated__/TypeTestersRefetchQuery.graphql.js +55 -7
  71. package/dist/__generated__/TypeTestersSlugQuery.graphql.d.ts +1 -1
  72. package/dist/__generated__/TypeTestersSlugQuery.graphql.js +55 -7
  73. package/dist/__generated__/useFontStyle_fontStyle.graphql.d.ts +28 -0
  74. package/dist/__generated__/useFontStyle_fontStyle.graphql.js +94 -0
  75. package/dist/__tests__/collectionBundleSelection.test.js +453 -1
  76. package/dist/components/Cart/CartItem/CartItemProduct.js +3 -9
  77. package/dist/components/CharacterViewer/index.js +5 -11
  78. package/dist/components/ConfigContext.d.ts +13 -0
  79. package/dist/components/ConfigContext.js +6 -2
  80. package/dist/components/ConsentBanner/consent.d.ts +18 -0
  81. package/dist/components/ConsentBanner/consent.js +93 -0
  82. package/dist/components/ConsentBanner/index.d.ts +3 -0
  83. package/dist/components/ConsentBanner/index.js +84 -0
  84. package/dist/components/Family/index.js +2 -5
  85. package/dist/components/FontStyle/index.js +2 -8
  86. package/dist/components/FontdueProvider/FontdueProviderClientComponent.js +14 -1
  87. package/dist/components/FontdueProvider/index.js +1 -2
  88. package/dist/components/FontdueProvider/index.server.js +1 -2
  89. package/dist/components/ServerConfigProvider/index.d.ts +8 -0
  90. package/dist/components/ServerConfigProvider/index.js +41 -0
  91. package/dist/components/StoreModal/StoreModalContainer.js +15 -17
  92. package/dist/components/StoreModal/StoreModalFamily.js +1 -5
  93. package/dist/components/StoreModal/StoreModalIndexItem.js +6 -11
  94. package/dist/components/Tracking/index.d.ts +2 -0
  95. package/dist/components/Tracking/index.js +166 -0
  96. package/dist/components/TypeTester/TypeTesterSlider.js +10 -3
  97. package/dist/components/TypeTester/index.js +2 -5
  98. package/dist/components/TypeTester/useTypeTesterStyler.js +27 -85
  99. package/dist/components/UrlContext.d.ts +3 -0
  100. package/dist/components/UrlContext.js +15 -0
  101. package/dist/components/elements/StoreModalContainer/index.d.ts +2 -6
  102. package/dist/components/elements/StoreModalContainer/index.js +3 -8
  103. package/dist/components/elements/StoreModalFamily/index.d.ts +0 -1
  104. package/dist/components/elements/StoreModalFamily/index.js +1 -2
  105. package/dist/components/useConsent.d.ts +9 -0
  106. package/dist/components/useConsent.js +26 -0
  107. package/dist/components/useFont.d.ts +29 -0
  108. package/dist/components/useFont.js +77 -0
  109. package/dist/components/useFontLoaded.d.ts +24 -0
  110. package/dist/components/useFontLoaded.js +60 -0
  111. package/dist/components/useFontStyle.d.ts +3 -4
  112. package/dist/components/useFontStyle.js +24 -16
  113. package/dist/deepMerge.d.ts +4 -0
  114. package/dist/deepMerge.js +24 -0
  115. package/dist/fontLoader.d.ts +13 -0
  116. package/dist/fontLoader.js +55 -0
  117. package/dist/fontdue.css +65 -0
  118. package/dist/hooks/useAutofit.d.ts +20 -0
  119. package/dist/hooks/useAutofit.js +114 -0
  120. package/dist/react-ranger.js +5 -1
  121. package/dist/reducer.d.ts +0 -4
  122. package/dist/reducer.js +32 -21
  123. package/dist/utils.d.ts +3 -0
  124. package/dist/utils.js +19 -8
  125. package/package.json +5 -2
@@ -14,7 +14,6 @@ _vitest.vi.mock('react-relay', () => ({
14
14
  function makeState() {
15
15
  let overrides = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
16
16
  return {
17
- stylesheets: [],
18
17
  cartOpen: false,
19
18
  precartOpen: false,
20
19
  selectedSkuIds: {},
@@ -910,6 +909,86 @@ function makeThunderState() {
910
909
  });
911
910
  (0, _vitest.expect)(newState.selectedSkuIds['text-bundle-sku']).toBe(false);
912
911
  });
912
+ (0, _vitest.it)('deselecting a family bundle deselects the parent collection bundle (transitive)', () => {
913
+ // Collection bundle is selected. A family bundle (style package) within
914
+ // it is shown as selected via transitive isSelected. Clicking to deselect
915
+ // it should find and deselect the collection bundle.
916
+ const state = makeState({
917
+ selectedSkuIds: {
918
+ 'coll-bundle-sku': true,
919
+ 'family-sku': false,
920
+ 'var-sku': false,
921
+ 'pkg-upright-sku': false,
922
+ 'pkg-italic-sku': false,
923
+ s1: false,
924
+ s2: false,
925
+ si1: false,
926
+ si2: false,
927
+ vs1: false
928
+ },
929
+ collectionStyleSkus: {
930
+ 'coll-bundle-sku': {
931
+ fontStyleSkuIds: ['s1', 's2', 'si1', 'si2', 'vs1'],
932
+ fontStyleIds: ['f1', 'f2', 'fi1', 'fi2', 'vf1'],
933
+ childrenSkuIds: ['family-sku', 'var-sku'],
934
+ name: 'Text + Variable'
935
+ },
936
+ 'family-sku': {
937
+ fontStyleSkuIds: ['s1', 's2', 'si1', 'si2'],
938
+ fontStyleIds: ['f1', 'f2', 'fi1', 'fi2'],
939
+ childrenSkuIds: ['pkg-upright-sku', 'pkg-italic-sku'],
940
+ name: 'Text Family'
941
+ },
942
+ 'var-sku': {
943
+ fontStyleSkuIds: ['vs1'],
944
+ fontStyleIds: ['vf1'],
945
+ childrenSkuIds: [],
946
+ name: 'Variable'
947
+ },
948
+ 'pkg-upright-sku': {
949
+ fontStyleSkuIds: ['s1', 's2'],
950
+ fontStyleIds: ['f1', 'f2'],
951
+ childrenSkuIds: [],
952
+ name: 'Package Text'
953
+ },
954
+ 'pkg-italic-sku': {
955
+ fontStyleSkuIds: ['si1', 'si2'],
956
+ fontStyleIds: ['fi1', 'fi2'],
957
+ childrenSkuIds: [],
958
+ name: 'Package Italic'
959
+ }
960
+ },
961
+ skuPrices: {
962
+ 'coll-bundle-sku': 500,
963
+ 'family-sku': 500,
964
+ 'var-sku': 300,
965
+ 'pkg-upright-sku': 250,
966
+ 'pkg-italic-sku': 250,
967
+ s1: 100,
968
+ s2: 100,
969
+ si1: 100,
970
+ si2: 100,
971
+ vs1: 100
972
+ }
973
+ });
974
+
975
+ // Bundle shows as selected via transitive isSelected
976
+ (0, _vitest.expect)((0, _utils.isSelected)('pkg-upright-sku')(state)).toBe(true);
977
+
978
+ // Click to deselect the bundle
979
+ const newState = (0, _reducer.default)(state, {
980
+ type: 'SELECT_SKU_ID',
981
+ skuId: 'pkg-upright-sku',
982
+ selected: false
983
+ });
984
+
985
+ // Collection bundle should be deselected
986
+ (0, _vitest.expect)(newState.selectedSkuIds['coll-bundle-sku']).toBe(false);
987
+ // Nothing should be selected anymore
988
+ (0, _vitest.expect)((0, _utils.isSelected)('pkg-upright-sku')(newState)).toBe(false);
989
+ (0, _vitest.expect)((0, _utils.isSelected)('family-sku')(newState)).toBe(false);
990
+ (0, _vitest.expect)((0, _utils.isSelected)('s1')(newState)).toBe(false);
991
+ });
913
992
  (0, _vitest.it)('deselecting a bundle does not affect other bundles', () => {
914
993
  const state = makeThunderState({
915
994
  selectedSkuIds: {
@@ -1178,4 +1257,377 @@ function makeThunderState() {
1178
1257
  });
1179
1258
  (0, _vitest.expect)(Object.keys(newState.selectedSkuIds)).toHaveLength(0);
1180
1259
  });
1260
+ });
1261
+
1262
+ // =========================================================================
1263
+ // isSelected — family bundles (style packages within a family)
1264
+ // =========================================================================
1265
+ (0, _vitest.describe)('isSelected with family bundles (style packages)', () => {
1266
+ // Helper: a family with two style bundles (upright + italic packages)
1267
+ function makeFamilyWithBundlesState() {
1268
+ let overrides = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1269
+ return makeState({
1270
+ collectionStyleSkus: {
1271
+ 'family-sku': {
1272
+ fontStyleSkuIds: ['s1', 's2', 's3', 's4', 's5', 'si1', 'si2', 'si3', 'si4', 'si5'],
1273
+ fontStyleIds: ['f1', 'f2', 'f3', 'f4', 'f5', 'fi1', 'fi2', 'fi3', 'fi4', 'fi5'],
1274
+ childrenSkuIds: ['pkg-upright-sku', 'pkg-italic-sku'],
1275
+ name: 'Thunder Text Family'
1276
+ },
1277
+ 'pkg-upright-sku': {
1278
+ fontStyleSkuIds: ['s1', 's2', 's3', 's4', 's5'],
1279
+ fontStyleIds: ['f1', 'f2', 'f3', 'f4', 'f5'],
1280
+ childrenSkuIds: [],
1281
+ name: 'Package Text'
1282
+ },
1283
+ 'pkg-italic-sku': {
1284
+ fontStyleSkuIds: ['si1', 'si2', 'si3', 'si4', 'si5'],
1285
+ fontStyleIds: ['fi1', 'fi2', 'fi3', 'fi4', 'fi5'],
1286
+ childrenSkuIds: [],
1287
+ name: 'Package Text Italic'
1288
+ }
1289
+ },
1290
+ skuPrices: {
1291
+ 'family-sku': 500,
1292
+ 'pkg-upright-sku': 250,
1293
+ 'pkg-italic-sku': 250,
1294
+ s1: 100,
1295
+ s2: 100,
1296
+ s3: 100,
1297
+ s4: 100,
1298
+ s5: 100,
1299
+ si1: 100,
1300
+ si2: 100,
1301
+ si3: 100,
1302
+ si4: 100,
1303
+ si5: 100
1304
+ },
1305
+ ...overrides
1306
+ });
1307
+ }
1308
+ (0, _vitest.it)('bundles show selected when family is directly selected', () => {
1309
+ const state = makeFamilyWithBundlesState({
1310
+ selectedSkuIds: {
1311
+ 'family-sku': true,
1312
+ 'pkg-upright-sku': false,
1313
+ 'pkg-italic-sku': false,
1314
+ s1: false,
1315
+ s2: false,
1316
+ s3: false,
1317
+ s4: false,
1318
+ s5: false,
1319
+ si1: false,
1320
+ si2: false,
1321
+ si3: false,
1322
+ si4: false,
1323
+ si5: false
1324
+ }
1325
+ });
1326
+ (0, _vitest.expect)((0, _utils.isSelected)('pkg-upright-sku')(state)).toBe(true);
1327
+ (0, _vitest.expect)((0, _utils.isSelected)('pkg-italic-sku')(state)).toBe(true);
1328
+ (0, _vitest.expect)((0, _utils.isSelected)('s1')(state)).toBe(true);
1329
+ (0, _vitest.expect)((0, _utils.isSelected)('si1')(state)).toBe(true);
1330
+ });
1331
+ (0, _vitest.it)('bundles show selected when collection bundle is selected (transitive)', () => {
1332
+ // Collection bundle is selected → family is false → family bundles should
1333
+ // still show selected because the collection bundle covers all styles
1334
+ const state = makeFamilyWithBundlesState({
1335
+ collectionStyleSkus: {
1336
+ // Collection bundle: groups family + variable family
1337
+ 'coll-bundle-sku': {
1338
+ fontStyleSkuIds: ['s1', 's2', 's3', 's4', 's5', 'si1', 'si2', 'si3', 'si4', 'si5', 'vs1'],
1339
+ fontStyleIds: ['f1', 'f2', 'f3', 'f4', 'f5', 'fi1', 'fi2', 'fi3', 'fi4', 'fi5', 'vf1'],
1340
+ childrenSkuIds: ['family-sku', 'var-sku'],
1341
+ name: 'Thunder Text + Variable'
1342
+ },
1343
+ 'family-sku': {
1344
+ fontStyleSkuIds: ['s1', 's2', 's3', 's4', 's5', 'si1', 'si2', 'si3', 'si4', 'si5'],
1345
+ fontStyleIds: ['f1', 'f2', 'f3', 'f4', 'f5', 'fi1', 'fi2', 'fi3', 'fi4', 'fi5'],
1346
+ childrenSkuIds: ['pkg-upright-sku', 'pkg-italic-sku'],
1347
+ name: 'Thunder Text Family'
1348
+ },
1349
+ 'var-sku': {
1350
+ fontStyleSkuIds: ['vs1'],
1351
+ fontStyleIds: ['vf1'],
1352
+ childrenSkuIds: [],
1353
+ name: 'Thunder Text Variable'
1354
+ },
1355
+ 'pkg-upright-sku': {
1356
+ fontStyleSkuIds: ['s1', 's2', 's3', 's4', 's5'],
1357
+ fontStyleIds: ['f1', 'f2', 'f3', 'f4', 'f5'],
1358
+ childrenSkuIds: [],
1359
+ name: 'Package Text'
1360
+ },
1361
+ 'pkg-italic-sku': {
1362
+ fontStyleSkuIds: ['si1', 'si2', 'si3', 'si4', 'si5'],
1363
+ fontStyleIds: ['fi1', 'fi2', 'fi3', 'fi4', 'fi5'],
1364
+ childrenSkuIds: [],
1365
+ name: 'Package Text Italic'
1366
+ }
1367
+ },
1368
+ selectedSkuIds: {
1369
+ 'coll-bundle-sku': true,
1370
+ 'family-sku': false,
1371
+ 'var-sku': false,
1372
+ 'pkg-upright-sku': false,
1373
+ 'pkg-italic-sku': false,
1374
+ s1: false,
1375
+ s2: false,
1376
+ s3: false,
1377
+ s4: false,
1378
+ s5: false,
1379
+ si1: false,
1380
+ si2: false,
1381
+ si3: false,
1382
+ si4: false,
1383
+ si5: false,
1384
+ vs1: false
1385
+ }
1386
+ });
1387
+
1388
+ // Family shows selected (direct child of collection bundle)
1389
+ (0, _vitest.expect)((0, _utils.isSelected)('family-sku')(state)).toBe(true);
1390
+ // Bundles should show selected (grandchildren — family is child of
1391
+ // collection bundle, bundles are children of family)
1392
+ (0, _vitest.expect)((0, _utils.isSelected)('pkg-upright-sku')(state)).toBe(true);
1393
+ (0, _vitest.expect)((0, _utils.isSelected)('pkg-italic-sku')(state)).toBe(true);
1394
+ // Individual styles should also show selected
1395
+ (0, _vitest.expect)((0, _utils.isSelected)('s1')(state)).toBe(true);
1396
+ });
1397
+ (0, _vitest.it)('selecting one bundle then another upgrades to family via reducer', () => {
1398
+ const state = makeFamilyWithBundlesState();
1399
+
1400
+ // Select first bundle
1401
+ let newState = (0, _reducer.default)(state, {
1402
+ type: 'SELECT_SKU_ID',
1403
+ skuId: 'pkg-upright-sku',
1404
+ selected: true
1405
+ });
1406
+ (0, _vitest.expect)(newState.selectedSkuIds['pkg-upright-sku']).toBe(true);
1407
+
1408
+ // Select second bundle — should upgrade to family
1409
+ newState = (0, _reducer.default)(newState, {
1410
+ type: 'SELECT_SKU_ID',
1411
+ skuId: 'pkg-italic-sku',
1412
+ selected: true
1413
+ });
1414
+
1415
+ // Family should be selected since family ($500) = two bundles ($250+$250)
1416
+ (0, _vitest.expect)(newState.selectedSkuIds['family-sku']).toBe(true);
1417
+ // Both bundles should report as selected
1418
+ (0, _vitest.expect)((0, _utils.isSelected)('pkg-upright-sku')(newState)).toBe(true);
1419
+ (0, _vitest.expect)((0, _utils.isSelected)('pkg-italic-sku')(newState)).toBe(true);
1420
+ });
1421
+ (0, _vitest.it)('auto-upgrades transitively: bundle → family → collection bundle', () => {
1422
+ // When a collection bundle exists at the same price as the family,
1423
+ // selecting both bundles should upgrade all the way to the collection
1424
+ // bundle (not stop at the family)
1425
+ const state = makeFamilyWithBundlesState({
1426
+ collectionStyleSkus: {
1427
+ 'coll-bundle-sku': {
1428
+ fontStyleSkuIds: ['s1', 's2', 's3', 's4', 's5', 'si1', 'si2', 'si3', 'si4', 'si5', 'vs1'],
1429
+ fontStyleIds: ['f1', 'f2', 'f3', 'f4', 'f5', 'fi1', 'fi2', 'fi3', 'fi4', 'fi5', 'vf1'],
1430
+ childrenSkuIds: ['family-sku', 'var-sku'],
1431
+ name: 'Thunder Text + Variable'
1432
+ },
1433
+ 'family-sku': {
1434
+ fontStyleSkuIds: ['s1', 's2', 's3', 's4', 's5', 'si1', 'si2', 'si3', 'si4', 'si5'],
1435
+ fontStyleIds: ['f1', 'f2', 'f3', 'f4', 'f5', 'fi1', 'fi2', 'fi3', 'fi4', 'fi5'],
1436
+ childrenSkuIds: ['pkg-upright-sku', 'pkg-italic-sku'],
1437
+ name: 'Thunder Text Family'
1438
+ },
1439
+ 'var-sku': {
1440
+ fontStyleSkuIds: ['vs1'],
1441
+ fontStyleIds: ['vf1'],
1442
+ childrenSkuIds: [],
1443
+ name: 'Thunder Text Variable'
1444
+ },
1445
+ 'pkg-upright-sku': {
1446
+ fontStyleSkuIds: ['s1', 's2', 's3', 's4', 's5'],
1447
+ fontStyleIds: ['f1', 'f2', 'f3', 'f4', 'f5'],
1448
+ childrenSkuIds: [],
1449
+ name: 'Package Text'
1450
+ },
1451
+ 'pkg-italic-sku': {
1452
+ fontStyleSkuIds: ['si1', 'si2', 'si3', 'si4', 'si5'],
1453
+ fontStyleIds: ['fi1', 'fi2', 'fi3', 'fi4', 'fi5'],
1454
+ childrenSkuIds: [],
1455
+ name: 'Package Text Italic'
1456
+ }
1457
+ },
1458
+ skuPrices: {
1459
+ 'coll-bundle-sku': 500,
1460
+ 'family-sku': 500,
1461
+ 'var-sku': 300,
1462
+ 'pkg-upright-sku': 250,
1463
+ 'pkg-italic-sku': 250,
1464
+ s1: 100,
1465
+ s2: 100,
1466
+ s3: 100,
1467
+ s4: 100,
1468
+ s5: 100,
1469
+ si1: 100,
1470
+ si2: 100,
1471
+ si3: 100,
1472
+ si4: 100,
1473
+ si5: 100,
1474
+ vs1: 100
1475
+ },
1476
+ selectedSkuIds: {
1477
+ 'pkg-upright-sku': true
1478
+ }
1479
+ });
1480
+ const newState = (0, _reducer.default)(state, {
1481
+ type: 'SELECT_SKU_ID',
1482
+ skuId: 'pkg-italic-sku',
1483
+ selected: true
1484
+ });
1485
+
1486
+ // Should transitively upgrade: bundle → family → collection bundle
1487
+ (0, _vitest.expect)(newState.selectedSkuIds['coll-bundle-sku']).toBe(true);
1488
+ (0, _vitest.expect)(newState.selectedSkuIds['family-sku']).toBe(false);
1489
+ (0, _vitest.expect)(newState.selectedSkuIds['pkg-upright-sku']).toBe(false);
1490
+ (0, _vitest.expect)(newState.selectedSkuIds['pkg-italic-sku']).toBe(false);
1491
+
1492
+ // All items should report as selected via isSelected
1493
+ (0, _vitest.expect)((0, _utils.isSelected)('family-sku')(newState)).toBe(true);
1494
+ (0, _vitest.expect)((0, _utils.isSelected)('pkg-upright-sku')(newState)).toBe(true);
1495
+ (0, _vitest.expect)((0, _utils.isSelected)('pkg-italic-sku')(newState)).toBe(true);
1496
+ (0, _vitest.expect)((0, _utils.isSelected)('s1')(newState)).toBe(true);
1497
+ (0, _vitest.expect)((0, _utils.isSelected)('vs1')(newState)).toBe(true);
1498
+ });
1499
+ (0, _vitest.it)('prefers collection bundle over family when family has duplicate fontStyleSkuIds from bundles', () => {
1500
+ // In production data, flattenSkuData produces a family entry whose
1501
+ // fontStyleSkuIds includes BOTH the family's own styles AND the
1502
+ // overlapping styles from its child bundles, creating duplicates.
1503
+ // The tie-breaker must use non-self preference (not raw array length)
1504
+ // to avoid the family's inflated count beating the collection bundle.
1505
+ const state = makeState({
1506
+ collectionStyleSkus: {
1507
+ 'family-sku': {
1508
+ // 10 unique styles, but listed 20 times (family's own + bundle overlap)
1509
+ fontStyleSkuIds: ['s1', 's2', 's3', 's4', 's5', 'si1', 'si2', 'si3', 'si4', 'si5', 's1', 's2', 's3', 's4', 's5', 'si1', 'si2', 'si3', 'si4', 'si5'],
1510
+ fontStyleIds: ['f1', 'f2', 'f3', 'f4', 'f5', 'fi1', 'fi2', 'fi3', 'fi4', 'fi5'],
1511
+ childrenSkuIds: ['pkg-upright-sku', 'pkg-italic-sku'],
1512
+ name: 'Thunder Caption Family'
1513
+ },
1514
+ 'coll-bundle-sku': {
1515
+ // 12 unique styles (family 10 + variable 2)
1516
+ fontStyleSkuIds: ['s1', 's2', 's3', 's4', 's5', 'si1', 'si2', 'si3', 'si4', 'si5', 'vs1', 'vs2'],
1517
+ fontStyleIds: ['f1', 'f2', 'f3', 'f4', 'f5', 'fi1', 'fi2', 'fi3', 'fi4', 'fi5', 'vf1', 'vf2'],
1518
+ childrenSkuIds: ['family-sku', 'var-sku'],
1519
+ name: 'Thunder Caption Family + Variable'
1520
+ },
1521
+ 'var-sku': {
1522
+ fontStyleSkuIds: ['vs1', 'vs2'],
1523
+ fontStyleIds: ['vf1', 'vf2'],
1524
+ childrenSkuIds: [],
1525
+ name: 'Thunder Caption Variable'
1526
+ },
1527
+ 'pkg-upright-sku': {
1528
+ fontStyleSkuIds: ['s1', 's2', 's3', 's4', 's5'],
1529
+ fontStyleIds: ['f1', 'f2', 'f3', 'f4', 'f5'],
1530
+ childrenSkuIds: [],
1531
+ name: 'Package Caption'
1532
+ },
1533
+ 'pkg-italic-sku': {
1534
+ fontStyleSkuIds: ['si1', 'si2', 'si3', 'si4', 'si5'],
1535
+ fontStyleIds: ['fi1', 'fi2', 'fi3', 'fi4', 'fi5'],
1536
+ childrenSkuIds: [],
1537
+ name: 'Package Caption Italic'
1538
+ }
1539
+ },
1540
+ skuPrices: {
1541
+ 'family-sku': 500,
1542
+ 'coll-bundle-sku': 500,
1543
+ 'var-sku': 500,
1544
+ 'pkg-upright-sku': 300,
1545
+ 'pkg-italic-sku': 300,
1546
+ s1: 100,
1547
+ s2: 100,
1548
+ s3: 100,
1549
+ s4: 100,
1550
+ s5: 100,
1551
+ si1: 100,
1552
+ si2: 100,
1553
+ si3: 100,
1554
+ si4: 100,
1555
+ si5: 100,
1556
+ vs1: 100,
1557
+ vs2: 100
1558
+ }
1559
+ });
1560
+
1561
+ // family-sku fontStyleSkuIds.length is 20 (duplicates), coll-bundle is 12.
1562
+ // A naive .length comparison would pick the family. The non-self
1563
+ // preference must win so the collection bundle is auto-selected.
1564
+ const [collId] = (0, _reducer.collectionSkuIdWithDiscount)(state, 'family-sku');
1565
+ (0, _vitest.expect)(collId).toBe('coll-bundle-sku');
1566
+ });
1567
+ (0, _vitest.it)('transitive upgrade prefers the collection with the most font styles', () => {
1568
+ // When two collections have the same price difference, prefer the one
1569
+ // covering more font styles
1570
+ const state = makeFamilyWithBundlesState({
1571
+ collectionStyleSkus: {
1572
+ 'small-bundle-sku': {
1573
+ fontStyleSkuIds: ['s1', 's2', 's3', 's4', 's5', 'si1', 'si2', 'si3', 'si4', 'si5'],
1574
+ fontStyleIds: ['f1', 'f2', 'f3', 'f4', 'f5', 'fi1', 'fi2', 'fi3', 'fi4', 'fi5'],
1575
+ childrenSkuIds: ['family-sku'],
1576
+ name: 'Small Bundle'
1577
+ },
1578
+ 'big-bundle-sku': {
1579
+ fontStyleSkuIds: ['s1', 's2', 's3', 's4', 's5', 'si1', 'si2', 'si3', 'si4', 'si5', 'vs1'],
1580
+ fontStyleIds: ['f1', 'f2', 'f3', 'f4', 'f5', 'fi1', 'fi2', 'fi3', 'fi4', 'fi5', 'vf1'],
1581
+ childrenSkuIds: ['family-sku', 'var-sku'],
1582
+ name: 'Big Bundle'
1583
+ },
1584
+ 'family-sku': {
1585
+ fontStyleSkuIds: ['s1', 's2', 's3', 's4', 's5', 'si1', 'si2', 'si3', 'si4', 'si5'],
1586
+ fontStyleIds: ['f1', 'f2', 'f3', 'f4', 'f5', 'fi1', 'fi2', 'fi3', 'fi4', 'fi5'],
1587
+ childrenSkuIds: ['pkg-upright-sku', 'pkg-italic-sku'],
1588
+ name: 'Thunder Text Family'
1589
+ },
1590
+ 'var-sku': {
1591
+ fontStyleSkuIds: ['vs1'],
1592
+ fontStyleIds: ['vf1'],
1593
+ childrenSkuIds: [],
1594
+ name: 'Variable'
1595
+ },
1596
+ 'pkg-upright-sku': {
1597
+ fontStyleSkuIds: ['s1', 's2', 's3', 's4', 's5'],
1598
+ fontStyleIds: ['f1', 'f2', 'f3', 'f4', 'f5'],
1599
+ childrenSkuIds: [],
1600
+ name: 'Package Text'
1601
+ },
1602
+ 'pkg-italic-sku': {
1603
+ fontStyleSkuIds: ['si1', 'si2', 'si3', 'si4', 'si5'],
1604
+ fontStyleIds: ['fi1', 'fi2', 'fi3', 'fi4', 'fi5'],
1605
+ childrenSkuIds: [],
1606
+ name: 'Package Text Italic'
1607
+ }
1608
+ },
1609
+ skuPrices: {
1610
+ 'small-bundle-sku': 500,
1611
+ 'big-bundle-sku': 500,
1612
+ 'family-sku': 500,
1613
+ 'var-sku': 300,
1614
+ 'pkg-upright-sku': 250,
1615
+ 'pkg-italic-sku': 250,
1616
+ s1: 100,
1617
+ s2: 100,
1618
+ s3: 100,
1619
+ s4: 100,
1620
+ s5: 100,
1621
+ si1: 100,
1622
+ si2: 100,
1623
+ si3: 100,
1624
+ si4: 100,
1625
+ si5: 100,
1626
+ vs1: 100
1627
+ }
1628
+ });
1629
+ const [collId] = (0, _reducer.collectionSkuIdWithDiscount)(state, 'family-sku');
1630
+ // Both bundles have the same price, but big-bundle has more styles
1631
+ (0, _vitest.expect)(collId).toBe('big-bundle-sku');
1632
+ });
1181
1633
  });
@@ -6,29 +6,23 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = CartItemProduct;
7
7
  var _CartItemProduct_product2 = _interopRequireDefault(require("../../../__generated__/CartItemProduct_product.graphql"));
8
8
  var _react = _interopRequireDefault(require("react"));
9
- var _Stylesheet = _interopRequireDefault(require("../../Stylesheet"));
10
9
  var _CollectionAa = require("../../CollectionAa");
11
10
  var _FontStyle = _interopRequireDefault(require("../../FontStyle"));
12
11
  var _reactRelay = require("react-relay");
13
12
  var _utils = require("../../../utils");
14
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
14
  function CartItemProduct(_ref) {
16
- var _product$family, _product$featureStyle, _product$featureStyle2, _product$name, _product$variableInst;
15
+ var _product$name, _product$variableInst;
17
16
  let {
18
17
  product: productKey
19
18
  } = _ref;
20
- const product = (0, _reactRelay.useFragment)((_CartItemProduct_product2.default.hash && _CartItemProduct_product2.default.hash !== "b28cd421e634ecb1162252d953233456" && console.error("The definition of 'CartItemProduct_product' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _CartItemProduct_product2.default), productKey);
21
- let productCss;
22
- if ((product === null || product === void 0 ? void 0 : product.__typename) === 'FontStyle') productCss = (_product$family = product.family) === null || _product$family === void 0 ? void 0 : _product$family.cssUrl;
23
- if ((product === null || product === void 0 ? void 0 : product.__typename) === 'FontCollection') productCss = (_product$featureStyle = product.featureStyle) === null || _product$featureStyle === void 0 ? void 0 : (_product$featureStyle2 = _product$featureStyle.family) === null || _product$featureStyle2 === void 0 ? void 0 : _product$featureStyle2.cssUrl;
19
+ const product = (0, _reactRelay.useFragment)((_CartItemProduct_product2.default.hash && _CartItemProduct_product2.default.hash !== "a3931102e3ec08c57abd262038b5d74a" && console.error("The definition of 'CartItemProduct_product' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _CartItemProduct_product2.default), productKey);
24
20
  let productName = (product === null || product === void 0 ? void 0 : product.name) ?? '??';
25
21
  if ((product === null || product === void 0 ? void 0 : product.__typename) === 'FontStyle' && product.family) productName = `${product.family.name} ${product.name}`;
26
22
  if (((product === null || product === void 0 ? void 0 : product.__typename) === 'Bundle' || (product === null || product === void 0 ? void 0 : product.__typename) === 'CollectionBundle') && product.fontCollection && !((_product$name = product.name) !== null && _product$name !== void 0 && _product$name.startsWith(product.fontCollection.name))) productName = `${product.fontCollection.name} ${product.name}`;
27
23
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
28
24
  className: "cart-item__aa"
29
- }, product ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Stylesheet.default, {
30
- href: productCss
31
- }), ['FontCollection', 'Bundle', 'CollectionBundle'].indexOf(product.__typename) >= 0 ? /*#__PURE__*/_react.default.createElement(_CollectionAa.CollectionAa, {
25
+ }, product ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, ['FontCollection', 'Bundle', 'CollectionBundle'].indexOf(product.__typename) >= 0 ? /*#__PURE__*/_react.default.createElement(_CollectionAa.CollectionAa, {
32
26
  product: product
33
27
  }) : /*#__PURE__*/_react.default.createElement(_FontStyle.default, {
34
28
  fontStyle: product
@@ -17,7 +17,6 @@ var _reactRelay = require("react-relay");
17
17
  var _resizeObserver = _interopRequireDefault(require("@react-hook/resize-observer"));
18
18
  var _utils = require("../../utils");
19
19
  var _useFontStyle = _interopRequireDefault(require("../useFontStyle"));
20
- var _Stylesheet = _interopRequireDefault(require("../Stylesheet"));
21
20
  var _useSerializablePreloadedQuery = _interopRequireDefault(require("../../relay/useSerializablePreloadedQuery"));
22
21
  var _StyleSelect = _interopRequireDefault(require("./StyleSelect"));
23
22
  var _Checkbox = _interopRequireDefault(require("../Checkbox"));
@@ -143,7 +142,7 @@ function flattenCharacterList(charSet, glyphNames) {
143
142
  }))
144
143
  };
145
144
  }
146
- _CharacterViewer_family2.default.hash && _CharacterViewer_family2.default.hash !== "02c42505dc4e330bb7c9034ba54e12f6" && console.error("The definition of 'CharacterViewer_family' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _CharacterViewer_family2.default;
145
+ _CharacterViewer_family2.default.hash && _CharacterViewer_family2.default.hash !== "162b1a99fe187b20ee8560018cd5b3ce" && console.error("The definition of 'CharacterViewer_family' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _CharacterViewer_family2.default;
147
146
  function areCombiningChars(input) {
148
147
  for (const char of input) {
149
148
  const codePoint = char.codePointAt(0);
@@ -171,8 +170,8 @@ function CharacterViewerComponent(_ref3) {
171
170
  let {
172
171
  collection: collectionKey
173
172
  } = _ref3;
174
- const collection = (0, _reactRelay.useFragment)((_CharacterViewer_collection2.default.hash && _CharacterViewer_collection2.default.hash !== "806e33bb73206ac443c6880d2941131d" && console.error("The definition of 'CharacterViewer_collection' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _CharacterViewer_collection2.default), collectionKey);
175
- const [fontStyle, refetchFontStyle] = (0, _reactRelay.useRefetchableFragment)((_CharacterViewer_style2.default.hash && _CharacterViewer_style2.default.hash !== "cd4bc4064dd23132ba3bf3d207fe6cb9" && console.error("The definition of 'CharacterViewer_style' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _CharacterViewer_style2.default), collection.featureStyle);
173
+ const collection = (0, _reactRelay.useFragment)((_CharacterViewer_collection2.default.hash && _CharacterViewer_collection2.default.hash !== "c2116c3c2c795e5306c3a2a0ecd60137" && console.error("The definition of 'CharacterViewer_collection' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _CharacterViewer_collection2.default), collectionKey);
174
+ const [fontStyle, refetchFontStyle] = (0, _reactRelay.useRefetchableFragment)((_CharacterViewer_style2.default.hash && _CharacterViewer_style2.default.hash !== "8cbf3328030930b88b3ec3601aaf7c45" && console.error("The definition of 'CharacterViewer_style' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data."), _CharacterViewer_style2.default), collection.featureStyle);
176
175
  let families = [];
177
176
  if (collection.collectionType === 'family') families = [collection];
178
177
  if (collection.collectionType === 'superfamily' && collection.children) families = collection.children;
@@ -201,9 +200,7 @@ function CharacterViewerComponent(_ref3) {
201
200
  let {
202
201
  style
203
202
  } = (0, _useFontStyle.default)({
204
- fontFamily: `${fontStyle === null || fontStyle === void 0 ? void 0 : fontStyle.cssFamily} ${fontStyle === null || fontStyle === void 0 ? void 0 : fontStyle.name}`,
205
- fontWeight: '400',
206
- fontStyle: 'normal'
203
+ fontStyle: fontStyle
207
204
  });
208
205
  if (variableSettings) {
209
206
  style = {
@@ -326,10 +323,7 @@ function CharacterViewerComponent(_ref3) {
326
323
  '--line-gap': fontStyle.verticalMetrics.lineGap ?? undefined,
327
324
  '--monitor-width': monitorWidth
328
325
  }
329
- }, families.filter(coll => coll.collectionType === 'family').map(coll => /*#__PURE__*/_react.default.createElement(_Stylesheet.default, {
330
- key: coll.id,
331
- href: coll.cssUrl
332
- })), /*#__PURE__*/_react.default.createElement("div", {
326
+ }, /*#__PURE__*/_react.default.createElement("div", {
333
327
  className: "character-viewer__character-map"
334
328
  }, /*#__PURE__*/_react.default.createElement("div", {
335
329
  className: "character-viewer__monitor"
@@ -8,12 +8,19 @@ interface FormConfig {
8
8
  interface StripeConfig {
9
9
  appearance?: Appearance;
10
10
  }
11
+ interface SegmentAnalytics {
12
+ page: Function;
13
+ setAnonymousId: Function;
14
+ }
11
15
  interface SegmentConfig {
12
16
  writeKey?: string;
17
+ analytics?: () => SegmentAnalytics;
13
18
  integrations?: Record<string, boolean>;
14
19
  }
15
20
  interface TrackingConfig {
16
21
  enabled?: boolean;
22
+ consentRequired?: boolean;
23
+ consentMessage?: string;
17
24
  segment?: SegmentConfig;
18
25
  }
19
26
  export interface Config {
@@ -88,6 +95,9 @@ export declare const makeConfig: (config?: Config) => {
88
95
  };
89
96
  tracking: {
90
97
  enabled: boolean;
98
+ consentRequired: boolean;
99
+ consentMessage: string | undefined;
100
+ segment: SegmentConfig | undefined;
91
101
  };
92
102
  };
93
103
  declare const _default: React.Context<{
@@ -155,6 +165,9 @@ declare const _default: React.Context<{
155
165
  };
156
166
  tracking: {
157
167
  enabled: boolean;
168
+ consentRequired: boolean;
169
+ consentMessage: string | undefined;
170
+ segment: SegmentConfig | undefined;
158
171
  };
159
172
  }>;
160
173
  export default _default;
@@ -59,7 +59,7 @@ const makeTypeTesterConfig = config => {
59
59
  };
60
60
  };
61
61
  const makeConfig = config => {
62
- var _config$form, _config$storeModal, _config$storeModal2, _config$storeModal3, _config$stripe, _config$tracking;
62
+ var _config$form, _config$storeModal, _config$storeModal2, _config$storeModal3, _config$stripe, _config$tracking, _config$tracking2, _config$tracking3, _config$tracking4;
63
63
  return {
64
64
  typeTester: makeTypeTesterConfig(config === null || config === void 0 ? void 0 : config.typeTester),
65
65
  form: {
@@ -74,7 +74,11 @@ const makeConfig = config => {
74
74
  appearance: (config === null || config === void 0 ? void 0 : (_config$stripe = config.stripe) === null || _config$stripe === void 0 ? void 0 : _config$stripe.appearance) ?? null
75
75
  },
76
76
  tracking: {
77
- enabled: (config === null || config === void 0 ? void 0 : (_config$tracking = config.tracking) === null || _config$tracking === void 0 ? void 0 : _config$tracking.enabled) ?? false // Explicit opt-in required
77
+ enabled: (config === null || config === void 0 ? void 0 : (_config$tracking = config.tracking) === null || _config$tracking === void 0 ? void 0 : _config$tracking.enabled) ?? false,
78
+ // Explicit opt-in required
79
+ consentRequired: (config === null || config === void 0 ? void 0 : (_config$tracking2 = config.tracking) === null || _config$tracking2 === void 0 ? void 0 : _config$tracking2.consentRequired) ?? false,
80
+ consentMessage: config === null || config === void 0 ? void 0 : (_config$tracking3 = config.tracking) === null || _config$tracking3 === void 0 ? void 0 : _config$tracking3.consentMessage,
81
+ segment: config === null || config === void 0 ? void 0 : (_config$tracking4 = config.tracking) === null || _config$tracking4 === void 0 ? void 0 : _config$tracking4.segment
78
82
  }
79
83
  };
80
84
  };
@@ -0,0 +1,18 @@
1
+ export declare function setClientAnonymousId(id: string): void;
2
+ export declare function getClientAnonymousId(): string | undefined;
3
+ /** Parse the _fontdue_cc cookie and check if it contains the given category. */
4
+ export declare function hasConsent(category: string): boolean;
5
+ /** Set the _fontdue_cc cookie with the given categories. */
6
+ export declare function setConsent(categories: string[]): void;
7
+ /**
8
+ * Call callback when the given consent category is granted.
9
+ * If already granted, calls immediately. Otherwise polls (500ms) and
10
+ * listens for the fontdue:consent event. Returns a cleanup function.
11
+ */
12
+ export declare function onConsent(category: string, callback: () => void): () => void;
13
+ /**
14
+ * Activate blocked scripts for the given consent category.
15
+ * Finds all <script type="text/plain" data-consent-category="<category>">
16
+ * elements and replaces them with executable copies.
17
+ */
18
+ export declare function activateScripts(category: string): void;