@codecademy/gamut-styles 17.12.0-alpha.f66feb.0 → 17.12.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.
@@ -1,5 +1,7 @@
1
1
  import { CacheProvider, ThemeProvider } from '@emotion/react';
2
- import { useContext, useRef } from 'react';
2
+ import { MotionConfig } from 'framer-motion';
3
+ import { setNonce } from 'get-nonce';
4
+ import { useContext, useEffect, useMemo, useRef } from 'react';
3
5
  import * as React from 'react';
4
6
  import { createEmotionCache } from './cache';
5
7
  import { Reboot, Typography } from './globals';
@@ -11,6 +13,11 @@ export const GamutContext = /*#__PURE__*/React.createContext({
11
13
  hasCache: false
12
14
  });
13
15
  GamutContext.displayName = 'GamutContext';
16
+
17
+ /**
18
+ * Returns the CSP nonce passed to GamutProvider, if any.
19
+ */
20
+ export const useNonce = () => useContext(GamutContext).nonce;
14
21
  export const GamutProvider = ({
15
22
  children,
16
23
  cache,
@@ -19,7 +26,7 @@ export const GamutProvider = ({
19
26
  useGlobals = true,
20
27
  useCache = true,
21
28
  nonce,
22
- useLogicalProperties = true
29
+ useLogicalProperties = false
23
30
  }) => {
24
31
  const {
25
32
  hasGlobals,
@@ -28,6 +35,13 @@ export const GamutProvider = ({
28
35
  const shouldCreateCache = useCache && !hasCache;
29
36
  const shouldInsertGlobals = useGlobals && !hasGlobals;
30
37
 
38
+ // Feed nonce to get-nonce singleton so react-style-singleton (e.g. via react-aria-components) can set it on injected style tags for CSP
39
+ useEffect(() => {
40
+ if (nonce) {
41
+ setNonce(nonce);
42
+ }
43
+ }, [nonce]);
44
+
31
45
  // Do not initialize a new cache if one has been provided as props
32
46
  const activeCache = useRef(shouldCreateCache && (cache ?? createEmotionCache(nonce ? {
33
47
  nonce
@@ -35,7 +49,8 @@ export const GamutProvider = ({
35
49
  const contextValue = {
36
50
  hasGlobals: shouldInsertGlobals,
37
51
  hasCache: shouldCreateCache,
38
- useLogicalProperties
52
+ useLogicalProperties,
53
+ nonce
39
54
  };
40
55
  const globals = shouldInsertGlobals && /*#__PURE__*/_jsxs(_Fragment, {
41
56
  children: [/*#__PURE__*/_jsx(Typography, {
@@ -49,28 +64,29 @@ export const GamutProvider = ({
49
64
  })]
50
65
  });
51
66
 
52
- // Merge useLogicalProperties into theme so variance can access it via props.theme
53
- const themeWithLogicalProperties = {
67
+ // Merge useLogicalProperties into theme so variance can access it via props.theme.
68
+ const themeWithLogicalProperties = useMemo(() => ({
54
69
  ...theme,
55
70
  useLogicalProperties
56
- };
71
+ }), [theme, useLogicalProperties]);
72
+ const content = useMemo(() => /*#__PURE__*/_jsx(ThemeProvider, {
73
+ theme: themeWithLogicalProperties,
74
+ children: nonce ? /*#__PURE__*/_jsx(MotionConfig, {
75
+ nonce: nonce,
76
+ children: children
77
+ }) : children
78
+ }), [themeWithLogicalProperties, nonce, children]);
57
79
  if (activeCache.current) {
58
80
  return /*#__PURE__*/_jsx(GamutContext.Provider, {
59
81
  value: contextValue,
60
82
  children: /*#__PURE__*/_jsxs(CacheProvider, {
61
83
  value: activeCache.current,
62
- children: [globals, /*#__PURE__*/_jsx(ThemeProvider, {
63
- theme: themeWithLogicalProperties,
64
- children: children
65
- })]
84
+ children: [globals, content]
66
85
  })
67
86
  });
68
87
  }
69
88
  return /*#__PURE__*/_jsxs(GamutContext.Provider, {
70
89
  value: contextValue,
71
- children: [globals, /*#__PURE__*/_jsx(ThemeProvider, {
72
- theme: themeWithLogicalProperties,
73
- children: children
74
- })]
90
+ children: [globals, content]
75
91
  });
76
92
  };
@@ -414,23 +414,43 @@ export declare const positioning: {
414
414
  };
415
415
  readonly inset: {
416
416
  readonly property: "inset";
417
- readonly properties: readonly ["top", "right", "bottom", "left"];
417
+ readonly properties: {
418
+ readonly physical: readonly ["top", "right", "bottom", "left"];
419
+ readonly logical: readonly ["insetBlockStart", "insetInlineEnd", "insetBlockEnd", "insetInlineStart"];
420
+ };
421
+ readonly resolveProperty: (useLogicalProperties: boolean) => import("@codecademy/variance/dist/types/properties").PropertyMode;
418
422
  readonly transform: (value: string | number) => string | 0;
419
423
  };
420
424
  readonly top: {
421
- readonly property: "top";
425
+ readonly property: {
426
+ readonly physical: "top";
427
+ readonly logical: "insetBlockStart";
428
+ };
429
+ readonly resolveProperty: (useLogicalProperties: boolean) => import("@codecademy/variance/dist/types/properties").PropertyMode;
422
430
  readonly transform: (value: string | number) => string | 0;
423
431
  };
424
432
  readonly right: {
425
- readonly property: "right";
433
+ readonly property: {
434
+ readonly physical: "right";
435
+ readonly logical: "insetInlineEnd";
436
+ };
437
+ readonly resolveProperty: (useLogicalProperties: boolean) => import("@codecademy/variance/dist/types/properties").PropertyMode;
426
438
  readonly transform: (value: string | number) => string | 0;
427
439
  };
428
440
  readonly bottom: {
429
- readonly property: "bottom";
441
+ readonly property: {
442
+ readonly physical: "bottom";
443
+ readonly logical: "insetBlockEnd";
444
+ };
445
+ readonly resolveProperty: (useLogicalProperties: boolean) => import("@codecademy/variance/dist/types/properties").PropertyMode;
430
446
  readonly transform: (value: string | number) => string | 0;
431
447
  };
432
448
  readonly left: {
433
- readonly property: "left";
449
+ readonly property: {
450
+ readonly physical: "left";
451
+ readonly logical: "insetInlineStart";
452
+ };
453
+ readonly resolveProperty: (useLogicalProperties: boolean) => import("@codecademy/variance/dist/types/properties").PropertyMode;
434
454
  readonly transform: (value: string | number) => string | 0;
435
455
  };
436
456
  readonly zIndex: {
@@ -498,43 +518,82 @@ export declare const layout: {
498
518
  readonly property: "overflow";
499
519
  };
500
520
  readonly overflowX: {
501
- readonly property: "overflowX";
521
+ readonly property: {
522
+ readonly physical: "overflowX";
523
+ readonly logical: "overflowInline";
524
+ };
525
+ readonly resolveProperty: (useLogicalProperties: boolean) => import("@codecademy/variance/dist/types/properties").PropertyMode;
502
526
  };
503
527
  readonly overflowY: {
504
- readonly property: "overflowY";
528
+ readonly property: {
529
+ readonly physical: "overflowY";
530
+ readonly logical: "overflowBlock";
531
+ };
532
+ readonly resolveProperty: (useLogicalProperties: boolean) => import("@codecademy/variance/dist/types/properties").PropertyMode;
505
533
  };
506
534
  readonly dimensions: {
507
535
  readonly property: "width";
508
- readonly properties: readonly ["width", "height"];
536
+ readonly properties: {
537
+ readonly physical: readonly ["width", "height"];
538
+ readonly logical: readonly ["inlineSize", "blockSize"];
539
+ };
540
+ readonly resolveProperty: (useLogicalProperties: boolean) => import("@codecademy/variance/dist/types/properties").PropertyMode;
509
541
  readonly transform: (value: string | number) => string | 0;
510
542
  };
511
543
  readonly width: {
512
- readonly property: "width";
544
+ readonly property: {
545
+ readonly physical: "width";
546
+ readonly logical: "inlineSize";
547
+ };
548
+ readonly resolveProperty: (useLogicalProperties: boolean) => import("@codecademy/variance/dist/types/properties").PropertyMode;
513
549
  readonly transform: (value: string | number) => string | 0;
514
550
  };
515
551
  readonly minWidth: {
516
- readonly property: "minWidth";
552
+ readonly property: {
553
+ readonly physical: "minWidth";
554
+ readonly logical: "minInlineSize";
555
+ };
556
+ readonly resolveProperty: (useLogicalProperties: boolean) => import("@codecademy/variance/dist/types/properties").PropertyMode;
517
557
  readonly transform: (value: string | number) => string | 0;
518
558
  };
519
559
  readonly maxWidth: {
520
- readonly property: "maxWidth";
560
+ readonly property: {
561
+ readonly physical: "maxWidth";
562
+ readonly logical: "maxInlineSize";
563
+ };
564
+ readonly resolveProperty: (useLogicalProperties: boolean) => import("@codecademy/variance/dist/types/properties").PropertyMode;
521
565
  readonly transform: (value: string | number) => string | 0;
522
566
  };
523
567
  readonly height: {
524
- readonly property: "height";
568
+ readonly property: {
569
+ readonly physical: "height";
570
+ readonly logical: "blockSize";
571
+ };
572
+ readonly resolveProperty: (useLogicalProperties: boolean) => import("@codecademy/variance/dist/types/properties").PropertyMode;
525
573
  readonly transform: (value: string | number) => string | 0;
526
574
  };
527
575
  readonly minHeight: {
528
- readonly property: "minHeight";
576
+ readonly property: {
577
+ readonly physical: "minHeight";
578
+ readonly logical: "minBlockSize";
579
+ };
580
+ readonly resolveProperty: (useLogicalProperties: boolean) => import("@codecademy/variance/dist/types/properties").PropertyMode;
529
581
  readonly transform: (value: string | number) => string | 0;
530
582
  };
531
583
  readonly maxHeight: {
532
- readonly property: "maxHeight";
584
+ readonly property: {
585
+ readonly physical: "maxHeight";
586
+ readonly logical: "maxBlockSize";
587
+ };
588
+ readonly resolveProperty: (useLogicalProperties: boolean) => import("@codecademy/variance/dist/types/properties").PropertyMode;
533
589
  readonly transform: (value: string | number) => string | 0;
534
590
  };
535
591
  readonly verticalAlign: {
536
592
  readonly property: "verticalAlign";
537
593
  };
594
+ readonly direction: {
595
+ readonly property: "direction";
596
+ };
538
597
  };
539
598
  export declare const list: {
540
599
  readonly listStyle: {
@@ -1115,23 +1174,43 @@ export declare const all: {
1115
1174
  };
1116
1175
  inset: {
1117
1176
  readonly property: "inset";
1118
- readonly properties: readonly ["top", "right", "bottom", "left"];
1177
+ readonly properties: {
1178
+ readonly physical: readonly ["top", "right", "bottom", "left"];
1179
+ readonly logical: readonly ["insetBlockStart", "insetInlineEnd", "insetBlockEnd", "insetInlineStart"];
1180
+ };
1181
+ readonly resolveProperty: (useLogicalProperties: boolean) => import("@codecademy/variance/dist/types/properties").PropertyMode;
1119
1182
  readonly transform: (value: string | number) => string | 0;
1120
1183
  };
1121
1184
  top: {
1122
- readonly property: "top";
1185
+ readonly property: {
1186
+ readonly physical: "top";
1187
+ readonly logical: "insetBlockStart";
1188
+ };
1189
+ readonly resolveProperty: (useLogicalProperties: boolean) => import("@codecademy/variance/dist/types/properties").PropertyMode;
1123
1190
  readonly transform: (value: string | number) => string | 0;
1124
1191
  };
1125
1192
  right: {
1126
- readonly property: "right";
1193
+ readonly property: {
1194
+ readonly physical: "right";
1195
+ readonly logical: "insetInlineEnd";
1196
+ };
1197
+ readonly resolveProperty: (useLogicalProperties: boolean) => import("@codecademy/variance/dist/types/properties").PropertyMode;
1127
1198
  readonly transform: (value: string | number) => string | 0;
1128
1199
  };
1129
1200
  bottom: {
1130
- readonly property: "bottom";
1201
+ readonly property: {
1202
+ readonly physical: "bottom";
1203
+ readonly logical: "insetBlockEnd";
1204
+ };
1205
+ readonly resolveProperty: (useLogicalProperties: boolean) => import("@codecademy/variance/dist/types/properties").PropertyMode;
1131
1206
  readonly transform: (value: string | number) => string | 0;
1132
1207
  };
1133
1208
  left: {
1134
- readonly property: "left";
1209
+ readonly property: {
1210
+ readonly physical: "left";
1211
+ readonly logical: "insetInlineStart";
1212
+ };
1213
+ readonly resolveProperty: (useLogicalProperties: boolean) => import("@codecademy/variance/dist/types/properties").PropertyMode;
1135
1214
  readonly transform: (value: string | number) => string | 0;
1136
1215
  };
1137
1216
  zIndex: {
@@ -1189,43 +1268,82 @@ export declare const all: {
1189
1268
  readonly property: "overflow";
1190
1269
  };
1191
1270
  overflowX: {
1192
- readonly property: "overflowX";
1271
+ readonly property: {
1272
+ readonly physical: "overflowX";
1273
+ readonly logical: "overflowInline";
1274
+ };
1275
+ readonly resolveProperty: (useLogicalProperties: boolean) => import("@codecademy/variance/dist/types/properties").PropertyMode;
1193
1276
  };
1194
1277
  overflowY: {
1195
- readonly property: "overflowY";
1278
+ readonly property: {
1279
+ readonly physical: "overflowY";
1280
+ readonly logical: "overflowBlock";
1281
+ };
1282
+ readonly resolveProperty: (useLogicalProperties: boolean) => import("@codecademy/variance/dist/types/properties").PropertyMode;
1196
1283
  };
1197
1284
  dimensions: {
1198
1285
  readonly property: "width";
1199
- readonly properties: readonly ["width", "height"];
1286
+ readonly properties: {
1287
+ readonly physical: readonly ["width", "height"];
1288
+ readonly logical: readonly ["inlineSize", "blockSize"];
1289
+ };
1290
+ readonly resolveProperty: (useLogicalProperties: boolean) => import("@codecademy/variance/dist/types/properties").PropertyMode;
1200
1291
  readonly transform: (value: string | number) => string | 0;
1201
1292
  };
1202
1293
  width: {
1203
- readonly property: "width";
1294
+ readonly property: {
1295
+ readonly physical: "width";
1296
+ readonly logical: "inlineSize";
1297
+ };
1298
+ readonly resolveProperty: (useLogicalProperties: boolean) => import("@codecademy/variance/dist/types/properties").PropertyMode;
1204
1299
  readonly transform: (value: string | number) => string | 0;
1205
1300
  };
1206
1301
  minWidth: {
1207
- readonly property: "minWidth";
1302
+ readonly property: {
1303
+ readonly physical: "minWidth";
1304
+ readonly logical: "minInlineSize";
1305
+ };
1306
+ readonly resolveProperty: (useLogicalProperties: boolean) => import("@codecademy/variance/dist/types/properties").PropertyMode;
1208
1307
  readonly transform: (value: string | number) => string | 0;
1209
1308
  };
1210
1309
  maxWidth: {
1211
- readonly property: "maxWidth";
1310
+ readonly property: {
1311
+ readonly physical: "maxWidth";
1312
+ readonly logical: "maxInlineSize";
1313
+ };
1314
+ readonly resolveProperty: (useLogicalProperties: boolean) => import("@codecademy/variance/dist/types/properties").PropertyMode;
1212
1315
  readonly transform: (value: string | number) => string | 0;
1213
1316
  };
1214
1317
  height: {
1215
- readonly property: "height";
1318
+ readonly property: {
1319
+ readonly physical: "height";
1320
+ readonly logical: "blockSize";
1321
+ };
1322
+ readonly resolveProperty: (useLogicalProperties: boolean) => import("@codecademy/variance/dist/types/properties").PropertyMode;
1216
1323
  readonly transform: (value: string | number) => string | 0;
1217
1324
  };
1218
1325
  minHeight: {
1219
- readonly property: "minHeight";
1326
+ readonly property: {
1327
+ readonly physical: "minHeight";
1328
+ readonly logical: "minBlockSize";
1329
+ };
1330
+ readonly resolveProperty: (useLogicalProperties: boolean) => import("@codecademy/variance/dist/types/properties").PropertyMode;
1220
1331
  readonly transform: (value: string | number) => string | 0;
1221
1332
  };
1222
1333
  maxHeight: {
1223
- readonly property: "maxHeight";
1334
+ readonly property: {
1335
+ readonly physical: "maxHeight";
1336
+ readonly logical: "maxBlockSize";
1337
+ };
1338
+ readonly resolveProperty: (useLogicalProperties: boolean) => import("@codecademy/variance/dist/types/properties").PropertyMode;
1224
1339
  readonly transform: (value: string | number) => string | 0;
1225
1340
  };
1226
1341
  verticalAlign: {
1227
1342
  readonly property: "verticalAlign";
1228
1343
  };
1344
+ direction: {
1345
+ readonly property: "direction";
1346
+ };
1229
1347
  justifyContent: {
1230
1348
  readonly property: "justifyContent";
1231
1349
  };
@@ -411,23 +411,43 @@ export const positioning = {
411
411
  },
412
412
  inset: {
413
413
  property: 'inset',
414
- properties: ['top', 'right', 'bottom', 'left'],
414
+ properties: {
415
+ physical: ['top', 'right', 'bottom', 'left'],
416
+ logical: ['insetBlockStart', 'insetInlineEnd', 'insetBlockEnd', 'insetInlineStart']
417
+ },
418
+ resolveProperty: getPropertyMode,
415
419
  transform: transformSize
416
420
  },
417
421
  top: {
418
- property: 'top',
422
+ property: {
423
+ physical: 'top',
424
+ logical: 'insetBlockStart'
425
+ },
426
+ resolveProperty: getPropertyMode,
419
427
  transform: transformSize
420
428
  },
421
429
  right: {
422
- property: 'right',
430
+ property: {
431
+ physical: 'right',
432
+ logical: 'insetInlineEnd'
433
+ },
434
+ resolveProperty: getPropertyMode,
423
435
  transform: transformSize
424
436
  },
425
437
  bottom: {
426
- property: 'bottom',
438
+ property: {
439
+ physical: 'bottom',
440
+ logical: 'insetBlockEnd'
441
+ },
442
+ resolveProperty: getPropertyMode,
427
443
  transform: transformSize
428
444
  },
429
445
  left: {
430
- property: 'left',
446
+ property: {
447
+ physical: 'left',
448
+ logical: 'insetInlineStart'
449
+ },
450
+ resolveProperty: getPropertyMode,
431
451
  transform: transformSize
432
452
  },
433
453
  zIndex: {
@@ -456,43 +476,82 @@ export const layout = {
456
476
  property: 'overflow'
457
477
  },
458
478
  overflowX: {
459
- property: 'overflowX'
479
+ property: {
480
+ physical: 'overflowX',
481
+ logical: 'overflowInline'
482
+ },
483
+ resolveProperty: getPropertyMode
460
484
  },
461
485
  overflowY: {
462
- property: 'overflowY'
486
+ property: {
487
+ physical: 'overflowY',
488
+ logical: 'overflowBlock'
489
+ },
490
+ resolveProperty: getPropertyMode
463
491
  },
464
492
  dimensions: {
465
493
  property: 'width',
466
- properties: ['width', 'height'],
494
+ properties: {
495
+ physical: ['width', 'height'],
496
+ logical: ['inlineSize', 'blockSize']
497
+ },
498
+ resolveProperty: getPropertyMode,
467
499
  transform: transformSize
468
500
  },
469
501
  width: {
470
- property: 'width',
502
+ property: {
503
+ physical: 'width',
504
+ logical: 'inlineSize'
505
+ },
506
+ resolveProperty: getPropertyMode,
471
507
  transform: transformSize
472
508
  },
473
509
  minWidth: {
474
- property: 'minWidth',
510
+ property: {
511
+ physical: 'minWidth',
512
+ logical: 'minInlineSize'
513
+ },
514
+ resolveProperty: getPropertyMode,
475
515
  transform: transformSize
476
516
  },
477
517
  maxWidth: {
478
- property: 'maxWidth',
518
+ property: {
519
+ physical: 'maxWidth',
520
+ logical: 'maxInlineSize'
521
+ },
522
+ resolveProperty: getPropertyMode,
479
523
  transform: transformSize
480
524
  },
481
525
  height: {
482
- property: 'height',
526
+ property: {
527
+ physical: 'height',
528
+ logical: 'blockSize'
529
+ },
530
+ resolveProperty: getPropertyMode,
483
531
  transform: transformSize
484
532
  },
485
533
  minHeight: {
486
- property: 'minHeight',
534
+ property: {
535
+ physical: 'minHeight',
536
+ logical: 'minBlockSize'
537
+ },
538
+ resolveProperty: getPropertyMode,
487
539
  transform: transformSize
488
540
  },
489
541
  maxHeight: {
490
- property: 'maxHeight',
542
+ property: {
543
+ physical: 'maxHeight',
544
+ logical: 'maxBlockSize'
545
+ },
546
+ resolveProperty: getPropertyMode,
491
547
  transform: transformSize
492
548
  },
493
549
  verticalAlign: {
494
550
  property: 'verticalAlign'
495
551
  },
552
+ direction: {
553
+ property: 'direction'
554
+ },
496
555
  ...selfAlignments,
497
556
  ...gridItems,
498
557
  ...flexItems