@zendeskgarden/react-theming 9.0.0-next.9 → 9.1.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.
package/dist/index.cjs.js CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  var React = require('react');
10
10
  var styled = require('styled-components');
11
- var chromaJs = require('chroma-js');
11
+ var color2k = require('color2k');
12
12
  var polished = require('polished');
13
13
  var get = require('lodash.get');
14
14
  var memoize = require('lodash.memoize');
@@ -310,26 +310,27 @@ const colors = {
310
310
  recessed: 'neutralHue.1200',
311
311
  subtle: 'neutralHue.1000',
312
312
  emphasis: 'neutralHue.600',
313
- primary: 'primaryHue.900',
314
313
  success: 'successHue.1000',
315
314
  warning: 'warningHue.1000',
316
315
  danger: 'dangerHue.1000',
317
316
  primaryEmphasis: 'primaryHue.600',
318
317
  successEmphasis: 'successHue.600',
319
318
  warningEmphasis: 'warningHue.600',
320
- dangerEmphasis: 'dangerHue.600'
319
+ dangerEmphasis: 'dangerHue.600',
320
+ disabled: 'rgba(neutralHue.500, 100)'
321
321
  },
322
322
  border: {
323
323
  default: 'neutralHue.800',
324
324
  emphasis: 'neutralHue.600',
325
325
  subtle: 'neutralHue.900',
326
- success: 'successHue.800',
327
- warning: 'warningHue.800',
328
- danger: 'dangerHue.800',
326
+ success: 'successHue.900',
327
+ warning: 'warningHue.900',
328
+ danger: 'dangerHue.900',
329
329
  primaryEmphasis: 'primaryHue.600',
330
330
  successEmphasis: 'successHue.600',
331
331
  warningEmphasis: 'warningHue.600',
332
- dangerEmphasis: 'dangerHue.600'
332
+ dangerEmphasis: 'dangerHue.600',
333
+ disabled: 'neutralHue.800'
333
334
  },
334
335
  foreground: {
335
336
  default: 'neutralHue.300',
@@ -341,7 +342,13 @@ const colors = {
341
342
  danger: 'dangerHue.400',
342
343
  successEmphasis: 'successHue.300',
343
344
  warningEmphasis: 'warningHue.300',
344
- dangerEmphasis: 'dangerHue.300'
345
+ dangerEmphasis: 'dangerHue.300',
346
+ disabled: 'neutralHue.700'
347
+ },
348
+ shadow: {
349
+ small: 'rgba(neutralHue.1200, 1100)',
350
+ medium: 'rgba(neutralHue.1200, 800)',
351
+ large: 'rgba(neutralHue.1200, 1000)'
345
352
  }
346
353
  },
347
354
  light: {
@@ -351,14 +358,14 @@ const colors = {
351
358
  recessed: 'neutralHue.100',
352
359
  subtle: 'neutralHue.100',
353
360
  emphasis: 'neutralHue.700',
354
- primary: 'primaryHue.100',
355
361
  success: 'successHue.100',
356
362
  warning: 'warningHue.100',
357
363
  danger: 'dangerHue.100',
358
364
  primaryEmphasis: 'primaryHue.700',
359
365
  successEmphasis: 'successHue.700',
360
366
  warningEmphasis: 'warningHue.700',
361
- dangerEmphasis: 'dangerHue.700'
367
+ dangerEmphasis: 'dangerHue.700',
368
+ disabled: 'rgba(neutralHue.700, 100)'
362
369
  },
363
370
  border: {
364
371
  default: 'neutralHue.300',
@@ -370,7 +377,8 @@ const colors = {
370
377
  primaryEmphasis: 'primaryHue.700',
371
378
  successEmphasis: 'successHue.700',
372
379
  warningEmphasis: 'warningHue.700',
373
- dangerEmphasis: 'dangerHue.700'
380
+ dangerEmphasis: 'dangerHue.700',
381
+ disabled: 'neutralHue.300'
374
382
  },
375
383
  foreground: {
376
384
  default: 'neutralHue.900',
@@ -382,7 +390,13 @@ const colors = {
382
390
  danger: 'dangerHue.700',
383
391
  successEmphasis: 'successHue.900',
384
392
  warningEmphasis: 'warningHue.900',
385
- dangerEmphasis: 'dangerHue.900'
393
+ dangerEmphasis: 'dangerHue.900',
394
+ disabled: 'neutralHue.600'
395
+ },
396
+ shadow: {
397
+ small: 'rgba(neutralHue.1200, 200)',
398
+ medium: 'rgba(neutralHue.1200, 200)',
399
+ large: 'rgba(neutralHue.1200, 200)'
386
400
  }
387
401
  }
388
402
  }
@@ -489,158 +503,13 @@ const DEFAULT_THEME = {
489
503
 
490
504
  const ThemeProvider = _ref => {
491
505
  let {
492
- theme,
506
+ theme = DEFAULT_THEME,
493
507
  ...other
494
508
  } = _ref;
495
509
  return React__default.default.createElement(styled.ThemeProvider, Object.assign({
496
510
  theme: theme
497
511
  }, other));
498
512
  };
499
- ThemeProvider.defaultProps = {
500
- theme: DEFAULT_THEME
501
- };
502
-
503
- const PALETTE_V8 = {
504
- black: '#000',
505
- white: '#fff',
506
- product: {
507
- support: '#00a656',
508
- message: '#37b8af',
509
- explore: '#30aabc',
510
- gather: '#f6c8be',
511
- guide: '#eb4962',
512
- connect: '#ff6224',
513
- chat: '#f79a3e',
514
- talk: '#efc93d',
515
- sell: '#c38f00'
516
- },
517
- grey: {
518
- 100: '#f8f9f9',
519
- 200: '#e9ebed',
520
- 300: '#d8dcde',
521
- 400: '#c2c8cc',
522
- 500: '#87929d',
523
- 600: '#68737d',
524
- 700: '#49545c',
525
- 800: '#2f3941'
526
- },
527
- blue: {
528
- 100: '#edf7ff',
529
- 200: '#cee2f2',
530
- 300: '#adcce4',
531
- 400: '#5293c7',
532
- 500: '#337fbd',
533
- 600: '#1f73b7',
534
- 700: '#144a75',
535
- 800: '#0f3554'
536
- },
537
- red: {
538
- 100: '#fff0f1',
539
- 200: '#f5d5d8',
540
- 300: '#f5b5ba',
541
- 400: '#e35b66',
542
- 500: '#d93f4c',
543
- 600: '#cc3340',
544
- 700: '#8c232c',
545
- 800: '#681219'
546
- },
547
- yellow: {
548
- 100: '#fff7ed',
549
- 200: '#ffeedb',
550
- 300: '#fed6a8',
551
- 400: '#ffb057',
552
- 500: '#f79a3e',
553
- 600: '#ed8f1c',
554
- 700: '#ad5918',
555
- 800: '#703815'
556
- },
557
- green: {
558
- 100: '#edf8f4',
559
- 200: '#d1e8df',
560
- 300: '#aecfc2',
561
- 400: '#5eae91',
562
- 500: '#228f67',
563
- 600: '#038153',
564
- 700: '#186146',
565
- 800: '#0b3b29'
566
- },
567
- kale: {
568
- 100: '#f5fcfc',
569
- 200: '#daeded',
570
- 300: '#bdd9d7',
571
- 400: '#90bbbb',
572
- 500: '#498283',
573
- 600: '#17494d',
574
- 700: '#03363d',
575
- 800: '#012b30'
576
- },
577
- fuschia: {
578
- 400: '#d653c2',
579
- 600: '#a81897',
580
- M400: '#cf62a8',
581
- M600: '#a8458c'
582
- },
583
- pink: {
584
- 400: '#ec4d63',
585
- 600: '#d42054',
586
- M400: '#d57287',
587
- M600: '#b23a5d'
588
- },
589
- crimson: {
590
- 400: '#e34f32',
591
- 600: '#c72a1c',
592
- M400: '#cc6c5b',
593
- M600: '#b24a3c'
594
- },
595
- orange: {
596
- 400: '#de701d',
597
- 600: '#bf5000',
598
- M400: '#d4772c',
599
- M600: '#b35827'
600
- },
601
- lemon: {
602
- 400: '#ffd424',
603
- 600: '#ffbb10',
604
- M400: '#e7a500',
605
- M600: '#c38f00'
606
- },
607
- lime: {
608
- 400: '#43b324',
609
- 600: '#2e8200',
610
- M400: '#519e2d',
611
- M600: '#47782c'
612
- },
613
- mint: {
614
- 400: '#00a656',
615
- 600: '#058541',
616
- M400: '#299c66',
617
- M600: '#2e8057'
618
- },
619
- teal: {
620
- 400: '#02a191',
621
- 600: '#028079',
622
- M400: '#2d9e8f',
623
- M600: '#3c7873'
624
- },
625
- azure: {
626
- 400: '#3091ec',
627
- 600: '#1371d6',
628
- M400: '#5f8dcf',
629
- M600: '#3a70b2'
630
- },
631
- royal: {
632
- 400: '#5d7df5',
633
- 600: '#3353e2',
634
- M400: '#7986d8',
635
- M600: '#4b61c3'
636
- },
637
- purple: {
638
- 400: '#b552e2',
639
- 600: '#6a27b8',
640
- M400: '#b072cc',
641
- M600: '#9358b0'
642
- }
643
- };
644
513
 
645
514
  function retrieveComponentStyles(componentId, props) {
646
515
  const components = props.theme && props.theme.components;
@@ -682,7 +551,6 @@ const getArrowPosition = (theme, placement) => {
682
551
  return retVal;
683
552
  };
684
553
 
685
- const PALETTE_SIZE = Object.keys(PALETTE.blue).length;
686
554
  const adjust$1 = (color, expected, actual) => {
687
555
  if (expected !== actual) {
688
556
  const amount = Math.abs(expected - actual) / 100 * 0.05;
@@ -713,6 +581,78 @@ const toHex = (hue, shade, offset, scheme) => {
713
581
  }
714
582
  return retVal;
715
583
  };
584
+ const isValidColor = maybeColor => {
585
+ let retVal = ['currentcolor', 'inherit', 'transparent'].includes(maybeColor);
586
+ if (!retVal) {
587
+ try {
588
+ retVal = !!color2k.parseToRgba(maybeColor);
589
+ } catch {
590
+ retVal = false;
591
+ }
592
+ }
593
+ return retVal;
594
+ };
595
+ function findNearestIndex(target, arr) {
596
+ let startIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
597
+ if (typeof target !== 'number' || isNaN(target)) {
598
+ throw new Error('Target must be a number.');
599
+ }
600
+ if (!Array.isArray(arr)) {
601
+ throw new Error('Second argument must be an array.');
602
+ }
603
+ let left = startIndex;
604
+ let right = arr.length - 1;
605
+ if (target < arr[left]) return left;
606
+ if (target > arr[right]) return right;
607
+ while (left <= right) {
608
+ const mid = Math.floor((left + right) / 2);
609
+ if (arr[mid] === target) {
610
+ return mid;
611
+ } else if (arr[mid] < target) {
612
+ left = mid + 1;
613
+ } else {
614
+ right = mid - 1;
615
+ }
616
+ }
617
+ return arr[left] - target < target - arr[right] ? left : right;
618
+ }
619
+ const OFFSET_TO_TARGET_RATIO = {
620
+ 100: 1.08,
621
+ 200: 1.2,
622
+ 300: 1.35,
623
+ 400: 2,
624
+ 500: 2.8,
625
+ 600: 3.3,
626
+ 700: 5,
627
+ 800: 10,
628
+ 900: 13,
629
+ 1000: 16,
630
+ 1100: 17.5,
631
+ 1200: 19
632
+ };
633
+ const generateColorScale = memoize__default.default(color => {
634
+ const scaleSize = 200;
635
+ const _scale = color2k.getScale('#FFF', color, '#000');
636
+ const scale = x => _scale(x / scaleSize);
637
+ const colors = [];
638
+ const contrastRatios = [];
639
+ for (let i = 0; i <= scaleSize; i++) {
640
+ const _color = scale(i);
641
+ colors.push(_color);
642
+ contrastRatios.push(polished.getContrast('#FFF', _color));
643
+ }
644
+ const palette = {};
645
+ let startIndex = 0;
646
+ for (const offset in OFFSET_TO_TARGET_RATIO) {
647
+ if (Object.prototype.hasOwnProperty.call(OFFSET_TO_TARGET_RATIO, offset)) {
648
+ const ratio = OFFSET_TO_TARGET_RATIO[offset];
649
+ const nearestIndex = findNearestIndex(ratio, contrastRatios, startIndex);
650
+ startIndex = nearestIndex + 1;
651
+ palette[offset] = colors[nearestIndex];
652
+ }
653
+ }
654
+ return palette;
655
+ });
716
656
  const toColor = (colors, palette, opacity, scheme, hue, shade, offset, transparency) => {
717
657
  let retVal;
718
658
  let _hue = colors[hue] || hue;
@@ -721,17 +661,11 @@ const toColor = (colors, palette, opacity, scheme, hue, shade, offset, transpare
721
661
  }
722
662
  if (typeof _hue === 'object') {
723
663
  retVal = toHex(_hue, shade, offset, scheme);
724
- } else if (_hue === 'transparent' || chromaJs.valid(_hue)) {
664
+ } else if (isValidColor(_hue)) {
725
665
  if (shade === undefined) {
726
666
  retVal = _hue;
727
667
  } else {
728
- const _colors = chromaJs.scale([PALETTE.white, _hue, PALETTE.black]).correctLightness().colors(PALETTE_SIZE + 2);
729
- _hue = _colors.reduce((_retVal, color, index) => {
730
- if (index > 0 && index <= PALETTE_SIZE) {
731
- _retVal[index * 100] = color;
732
- }
733
- return _retVal;
734
- }, {});
668
+ _hue = generateColorScale(_hue);
735
669
  retVal = toHex(_hue, shade, offset, scheme);
736
670
  }
737
671
  }
@@ -754,7 +688,51 @@ const toProperty = (object, path) => {
754
688
  throw new TypeError(`Error: unexpected '${typeof retVal}' type for color variable "${path}"`);
755
689
  }
756
690
  };
757
- const getColor = memoize__default.default(_ref => {
691
+ const fromRgba = value => {
692
+ let retVal;
693
+ const regex = /rgba\s*\(\s*(?<property>[#\w.]+)\s*,\s*(?<alpha>[\w.]+)\s*\)/gu;
694
+ const _rgba = regex.exec(value);
695
+ if (_rgba && _rgba.groups) {
696
+ const property = _rgba.groups.property;
697
+ const transparency = parseFloat(_rgba.groups.alpha);
698
+ retVal = {
699
+ property,
700
+ transparency
701
+ };
702
+ } else {
703
+ throw new Error(`Error: invalid \`rgba\` value "${value}"`);
704
+ }
705
+ return retVal;
706
+ };
707
+ const fromVariable = (variable, variables, palette) => {
708
+ const retVal = {};
709
+ let property = toProperty(variables, variable);
710
+ if (property.startsWith('rgba')) {
711
+ const value = fromRgba(property);
712
+ property = value.property;
713
+ retVal.transparency = value.transparency;
714
+ }
715
+ const [key, value] = property.split(/\.(?<value>.*)/u);
716
+ if (key === 'palette') {
717
+ retVal.hue = toProperty(palette, value);
718
+ } else {
719
+ retVal.hue = key;
720
+ if (value !== undefined) {
721
+ retVal.shade = parseInt(value, 10);
722
+ }
723
+ }
724
+ return retVal;
725
+ };
726
+ const CACHE$1 = new WeakMap();
727
+ const KEYS$1 = {
728
+ colors: 0,
729
+ palette: 0,
730
+ opacity: 0
731
+ };
732
+ CACHE$1.set(DEFAULT_THEME.colors, KEYS$1.colors);
733
+ CACHE$1.set(DEFAULT_THEME.palette, KEYS$1.palette);
734
+ CACHE$1.set(DEFAULT_THEME.opacity, KEYS$1.opacity);
735
+ const toKey$1 = _ref => {
758
736
  let {
759
737
  dark,
760
738
  hue,
@@ -765,6 +743,56 @@ const getColor = memoize__default.default(_ref => {
765
743
  transparency,
766
744
  variable
767
745
  } = _ref;
746
+ let themeColorsKey = CACHE$1.get(theme.colors);
747
+ if (themeColorsKey === undefined) {
748
+ themeColorsKey = ++KEYS$1.colors;
749
+ CACHE$1.set(theme.colors, themeColorsKey);
750
+ }
751
+ let themeOpacityKey = CACHE$1.get(theme.opacity);
752
+ if (themeOpacityKey === undefined) {
753
+ themeOpacityKey = ++KEYS$1.opacity;
754
+ CACHE$1.set(theme.opacity, themeOpacityKey);
755
+ }
756
+ let themePaletteKey = CACHE$1.get(theme.palette);
757
+ if (themePaletteKey === undefined) {
758
+ themePaletteKey = ++KEYS$1.palette;
759
+ CACHE$1.set(theme.palette, themePaletteKey);
760
+ }
761
+ let retVal = `{${themeColorsKey},${themePaletteKey},${themeOpacityKey}}`;
762
+ if (variable !== undefined) {
763
+ retVal += `,${variable}`;
764
+ }
765
+ if (hue !== undefined) {
766
+ retVal += `,${hue}`;
767
+ }
768
+ if (shade !== undefined) {
769
+ retVal += `,${shade}`;
770
+ }
771
+ if (offset !== undefined) {
772
+ retVal += `,${offset}`;
773
+ }
774
+ if (transparency !== undefined) {
775
+ retVal += `,${transparency}`;
776
+ }
777
+ if (dark !== undefined) {
778
+ retVal += `,${JSON.stringify(dark)}`;
779
+ }
780
+ if (light !== undefined) {
781
+ retVal += `,${JSON.stringify(light)}`;
782
+ }
783
+ return retVal;
784
+ };
785
+ const getColor = memoize__default.default(_ref2 => {
786
+ let {
787
+ dark,
788
+ hue,
789
+ light,
790
+ offset,
791
+ shade,
792
+ theme,
793
+ transparency,
794
+ variable
795
+ } = _ref2;
768
796
  let retVal;
769
797
  const palette = theme.palette && Object.keys(theme.palette).length > 0 ? theme.palette : DEFAULT_THEME.palette;
770
798
  const {
@@ -777,17 +805,13 @@ const getColor = memoize__default.default(_ref => {
777
805
  let _hue = mode?.hue || hue;
778
806
  let _shade = mode?.shade === undefined ? shade : mode.shade;
779
807
  const _offset = mode?.offset === undefined ? offset : mode.offset;
780
- const _transparency = mode?.transparency === undefined ? transparency : mode.transparency;
808
+ let _transparency = mode?.transparency === undefined ? transparency : mode.transparency;
781
809
  if (variable) {
782
810
  const _variables = variables?.[scheme] ? variables[scheme] : DEFAULT_THEME.colors.variables[scheme];
783
- const property = toProperty(_variables, variable);
784
- const [key, value] = property.split(/\.(?<value>.*)/u);
785
- if (key === 'palette') {
786
- _hue = toProperty(palette, value);
787
- } else {
788
- _hue = key;
789
- _shade = parseInt(value, 10);
790
- }
811
+ const value = fromVariable(variable, _variables, palette);
812
+ _hue = value.hue;
813
+ _shade = value.shade;
814
+ _transparency = _transparency === undefined ? value.transparency : _transparency;
791
815
  }
792
816
  if (_hue) {
793
817
  const opacity = theme.opacity && Object.keys(theme.opacity).length > 0 ? theme.opacity : DEFAULT_THEME.opacity;
@@ -797,7 +821,7 @@ const getColor = memoize__default.default(_ref => {
797
821
  throw new Error('Error: invalid `getColor` parameters');
798
822
  }
799
823
  return retVal;
800
- }, _ref2 => {
824
+ }, _ref3 => {
801
825
  let {
802
826
  dark,
803
827
  hue,
@@ -807,15 +831,14 @@ const getColor = memoize__default.default(_ref => {
807
831
  theme,
808
832
  transparency,
809
833
  variable
810
- } = _ref2;
811
- return JSON.stringify({
834
+ } = _ref3;
835
+ return toKey$1({
812
836
  dark,
813
837
  hue,
814
838
  light,
815
839
  offset,
816
840
  shade,
817
- colors: theme.colors,
818
- palette: theme.palette,
841
+ theme,
819
842
  transparency,
820
843
  variable
821
844
  });
@@ -852,6 +875,148 @@ const getCheckeredBackground = _ref => {
852
875
  return retVal;
853
876
  };
854
877
 
878
+ const PALETTE_V8 = {
879
+ black: '#000',
880
+ white: '#fff',
881
+ product: {
882
+ support: '#00a656',
883
+ message: '#37b8af',
884
+ explore: '#30aabc',
885
+ gather: '#f6c8be',
886
+ guide: '#eb4962',
887
+ connect: '#ff6224',
888
+ chat: '#f79a3e',
889
+ talk: '#efc93d',
890
+ sell: '#c38f00'
891
+ },
892
+ grey: {
893
+ 100: '#f8f9f9',
894
+ 200: '#e9ebed',
895
+ 300: '#d8dcde',
896
+ 400: '#c2c8cc',
897
+ 500: '#87929d',
898
+ 600: '#68737d',
899
+ 700: '#49545c',
900
+ 800: '#2f3941'
901
+ },
902
+ blue: {
903
+ 100: '#edf7ff',
904
+ 200: '#cee2f2',
905
+ 300: '#adcce4',
906
+ 400: '#5293c7',
907
+ 500: '#337fbd',
908
+ 600: '#1f73b7',
909
+ 700: '#144a75',
910
+ 800: '#0f3554'
911
+ },
912
+ red: {
913
+ 100: '#fff0f1',
914
+ 200: '#f5d5d8',
915
+ 300: '#f5b5ba',
916
+ 400: '#e35b66',
917
+ 500: '#d93f4c',
918
+ 600: '#cc3340',
919
+ 700: '#8c232c',
920
+ 800: '#681219'
921
+ },
922
+ yellow: {
923
+ 100: '#fff7ed',
924
+ 200: '#ffeedb',
925
+ 300: '#fed6a8',
926
+ 400: '#ffb057',
927
+ 500: '#f79a3e',
928
+ 600: '#ed8f1c',
929
+ 700: '#ad5918',
930
+ 800: '#703815'
931
+ },
932
+ green: {
933
+ 100: '#edf8f4',
934
+ 200: '#d1e8df',
935
+ 300: '#aecfc2',
936
+ 400: '#5eae91',
937
+ 500: '#228f67',
938
+ 600: '#038153',
939
+ 700: '#186146',
940
+ 800: '#0b3b29'
941
+ },
942
+ kale: {
943
+ 100: '#f5fcfc',
944
+ 200: '#daeded',
945
+ 300: '#bdd9d7',
946
+ 400: '#90bbbb',
947
+ 500: '#498283',
948
+ 600: '#17494d',
949
+ 700: '#03363d',
950
+ 800: '#012b30'
951
+ },
952
+ fuschia: {
953
+ 400: '#d653c2',
954
+ 600: '#a81897',
955
+ M400: '#cf62a8',
956
+ M600: '#a8458c'
957
+ },
958
+ pink: {
959
+ 400: '#ec4d63',
960
+ 600: '#d42054',
961
+ M400: '#d57287',
962
+ M600: '#b23a5d'
963
+ },
964
+ crimson: {
965
+ 400: '#e34f32',
966
+ 600: '#c72a1c',
967
+ M400: '#cc6c5b',
968
+ M600: '#b24a3c'
969
+ },
970
+ orange: {
971
+ 400: '#de701d',
972
+ 600: '#bf5000',
973
+ M400: '#d4772c',
974
+ M600: '#b35827'
975
+ },
976
+ lemon: {
977
+ 400: '#ffd424',
978
+ 600: '#ffbb10',
979
+ M400: '#e7a500',
980
+ M600: '#c38f00'
981
+ },
982
+ lime: {
983
+ 400: '#43b324',
984
+ 600: '#2e8200',
985
+ M400: '#519e2d',
986
+ M600: '#47782c'
987
+ },
988
+ mint: {
989
+ 400: '#00a656',
990
+ 600: '#058541',
991
+ M400: '#299c66',
992
+ M600: '#2e8057'
993
+ },
994
+ teal: {
995
+ 400: '#02a191',
996
+ 600: '#028079',
997
+ M400: '#2d9e8f',
998
+ M600: '#3c7873'
999
+ },
1000
+ azure: {
1001
+ 400: '#3091ec',
1002
+ 600: '#1371d6',
1003
+ M400: '#5f8dcf',
1004
+ M600: '#3a70b2'
1005
+ },
1006
+ royal: {
1007
+ 400: '#5d7df5',
1008
+ 600: '#3353e2',
1009
+ M400: '#7986d8',
1010
+ M600: '#4b61c3'
1011
+ },
1012
+ purple: {
1013
+ 400: '#b552e2',
1014
+ 600: '#6a27b8',
1015
+ M400: '#b072cc',
1016
+ M600: '#9358b0'
1017
+ }
1018
+ };
1019
+
855
1020
  const DEFAULT_SHADE = 600;
856
1021
  const adjust = (color, expected, actual) => {
857
1022
  if (expected !== actual) {
@@ -860,6 +1025,42 @@ const adjust = (color, expected, actual) => {
860
1025
  }
861
1026
  return color;
862
1027
  };
1028
+ const CACHE = new WeakMap();
1029
+ const KEYS = {
1030
+ colors: 0,
1031
+ palette: 0
1032
+ };
1033
+ CACHE.set(DEFAULT_THEME.colors, KEYS.colors);
1034
+ CACHE.set(DEFAULT_THEME.palette, KEYS.palette);
1035
+ const toKey = _ref => {
1036
+ let {
1037
+ hue,
1038
+ shade,
1039
+ theme,
1040
+ transparency
1041
+ } = _ref;
1042
+ let retVal = `${hue}`;
1043
+ if (shade !== undefined) {
1044
+ retVal += `,${shade}`;
1045
+ }
1046
+ if (theme !== undefined) {
1047
+ let themeColorsKey = CACHE.get(theme.colors);
1048
+ if (themeColorsKey === undefined) {
1049
+ themeColorsKey = ++KEYS.colors;
1050
+ CACHE.set(theme.colors, themeColorsKey);
1051
+ }
1052
+ let themePaletteKey = CACHE.get(theme.palette);
1053
+ if (themePaletteKey === undefined) {
1054
+ themePaletteKey = ++KEYS.palette;
1055
+ CACHE.set(theme.palette, themePaletteKey);
1056
+ }
1057
+ retVal += `,{${themeColorsKey},${themePaletteKey}}`;
1058
+ }
1059
+ if (transparency !== undefined) {
1060
+ retVal += `,${transparency}`;
1061
+ }
1062
+ return retVal;
1063
+ };
863
1064
  const getColorV8 = memoize__default.default(function (hue) {
864
1065
  let shade = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_SHADE;
865
1066
  let theme = arguments.length > 2 ? arguments[2] : undefined;
@@ -904,11 +1105,10 @@ const getColorV8 = memoize__default.default(function (hue) {
904
1105
  retVal = polished.rgba(retVal, transparency);
905
1106
  }
906
1107
  return retVal;
907
- }, (hue, shade, theme, transparency) => JSON.stringify({
1108
+ }, (hue, shade, theme, transparency) => toKey({
908
1109
  hue,
909
1110
  shade,
910
- palette: theme?.palette,
911
- colors: theme?.colors,
1111
+ theme,
912
1112
  transparency
913
1113
  }));
914
1114
 
@@ -1060,58 +1260,47 @@ function mediaQuery(query, breakpoint, theme) {
1060
1260
  return retVal;
1061
1261
  }
1062
1262
 
1063
- const exponentialSymbols = {
1064
- symbols: {
1065
- sqrt: {
1066
- func: {
1067
- symbol: 'sqrt',
1068
- f: a => Math.sqrt(a),
1069
- notation: 'func',
1070
- precedence: 0,
1071
- rightToLeft: 0,
1072
- argCount: 1
1073
- },
1074
- symbol: 'sqrt',
1075
- regSymbol: 'sqrt\\b'
1076
- }
1077
- }
1078
- };
1079
1263
  const animationStyles$1 = (position, modifier) => {
1080
1264
  const property = position.split('-')[0];
1081
1265
  const animationName = styled.keyframes(["0%,66%{", ":2px;border:transparent;}"], property);
1082
1266
  return styled.css(["&", "::before,&", "::after{animation:0.3s ease-in-out ", ";}"], modifier, modifier, animationName);
1083
1267
  };
1084
- const positionStyles = (position, size, inset) => {
1085
- const margin = polished.math(`${size} / -2`);
1086
- const placement = polished.math(`${margin} + ${inset}`);
1087
- let clipPath;
1268
+ const positionStyles = (position, size, inset, shift) => {
1269
+ const defaultInset = 0.3;
1270
+ const margin = size / -2;
1271
+ const placement = Math.round((margin + inset + defaultInset) * 100) / 100;
1272
+ const marginPx = `${margin}px`;
1273
+ const placementPx = `${placement}px`;
1274
+ const offsetPx = `${size + shift}px`;
1088
1275
  let positionCss;
1089
- let propertyRadius;
1276
+ let transform;
1090
1277
  if (position.startsWith('top')) {
1091
- propertyRadius = 'border-bottom-right-radius';
1092
- clipPath = 'polygon(100% 0, 100% 1px, 1px 100%, 0 100%, 0 0)';
1093
- positionCss = styled.css(["top:", ";right:", ";left:", ";margin-left:", ";"], placement, position === 'top-right' && size, position === 'top' ? '50%' : position === 'top-left' && size, position === 'top' && margin);
1278
+ transform = 'rotate(-135deg)';
1279
+ positionCss = styled.css(["top:", ";right:", ";left:", ";margin-left:", ";"], placementPx, position === 'top-right' && offsetPx, position === 'top' ? '50%' : position === 'top-left' && offsetPx, position === 'top' && marginPx);
1094
1280
  } else if (position.startsWith('right')) {
1095
- propertyRadius = 'border-bottom-left-radius';
1096
- clipPath = 'polygon(100% 0, 100% 100%, calc(100% - 1px) 100%, 0 1px, 0 0)';
1097
- positionCss = styled.css(["top:", ";right:", ";bottom:", ";margin-top:", ";"], position === 'right' ? '50%' : position === 'right-top' && size, placement, position === 'right-bottom' && size, position === 'right' && margin);
1281
+ transform = 'rotate(-45deg)';
1282
+ positionCss = styled.css(["top:", ";right:", ";bottom:", ";margin-top:", ";"], position === 'right' ? '50%' : position === 'right-top' && offsetPx, placementPx, position === 'right-bottom' && offsetPx, position === 'right' && marginPx);
1098
1283
  } else if (position.startsWith('bottom')) {
1099
- propertyRadius = 'border-top-left-radius';
1100
- clipPath = 'polygon(100% 0, calc(100% - 1px) 0, 0 calc(100% - 1px), 0 100%, 100% 100%)';
1101
- positionCss = styled.css(["right:", ";bottom:", ";left:", ";margin-left:", ";"], position === 'bottom-right' && size, placement, position === 'bottom' ? '50%' : position === 'bottom-left' && size, position === 'bottom' && margin);
1284
+ transform = 'rotate(45deg)';
1285
+ positionCss = styled.css(["right:", ";bottom:", ";left:", ";margin-left:", ";"], position === 'bottom-right' && offsetPx, placementPx, position === 'bottom' ? '50%' : position === 'bottom-left' && offsetPx, position === 'bottom' && marginPx);
1102
1286
  } else if (position.startsWith('left')) {
1103
- propertyRadius = 'border-top-right-radius';
1104
- clipPath = 'polygon(0 100%, 100% 100%, 100% calc(100% - 1px), 1px 0, 0 0)';
1105
- positionCss = styled.css(["top:", ";bottom:", ";left:", ";margin-top:", ";"], position === 'left' ? '50%' : position === 'left-top' && size, size, placement, position === 'left' && margin);
1287
+ transform = 'rotate(135deg)';
1288
+ positionCss = styled.css(["top:", ";bottom:", ";left:", ";margin-top:", ";"], position === 'left' ? '50%' : position === 'left-top' && offsetPx, offsetPx, placementPx, position === 'left' && marginPx);
1106
1289
  }
1107
- return styled.css(["&::before{", ":100%;clip-path:", ";}&::before,&::after{", "}"], propertyRadius, clipPath, positionCss);
1290
+ return styled.css(["&::before,&::after{transform:", ";", ";}"], transform, positionCss);
1108
1291
  };
1109
1292
  function arrowStyles(position) {
1110
1293
  let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1111
- const size = options.size || '6px';
1112
- const inset = options.inset || '0';
1113
- const squareSize = polished.math(`${size} * 2 / sqrt(2)`, exponentialSymbols);
1114
- return styled.css(["position:relative;&::before{border-width:inherit;border-style:inherit;border-color:transparent;background-clip:content-box;}&::after{z-index:-1;border:inherit;box-shadow:inherit;}&::before,&::after{position:absolute;transform:rotate(45deg);background-color:inherit;box-sizing:inherit;width:", ";height:", ";content:'';}", ";", ";"], squareSize, squareSize, positionStyles(position, squareSize, inset), options.animationModifier && animationStyles$1(position, options.animationModifier));
1294
+ const inset = polished.stripUnit(options.inset || '0');
1295
+ const size = polished.stripUnit(options.size || '6');
1296
+ const shift = polished.stripUnit(options.shift || '0');
1297
+ const sizeOffset = 2;
1298
+ const squareSize = size * 2 / Math.sqrt(2) + sizeOffset;
1299
+ const squareSizeRounded = Math.round(squareSize * 100) / 100;
1300
+ const squareSizePx = `${squareSizeRounded}px`;
1301
+ const afterOffset = 0;
1302
+ const beforeOffset = afterOffset + 2;
1303
+ return styled.css(["position:relative;&::before,&::after{position:absolute;border-width:inherit;border-style:inherit;background-color:inherit;width:", ";height:", ";content:'';box-sizing:inherit;}&::before{border-color:inherit;clip-path:polygon(100% ", "px,", "px 100%,100% 100%);}&::after{border-color:transparent;background-clip:content-box;clip-path:polygon(100% ", "px,", "px 100%,100% 100%);}", ";", ";"], squareSizePx, squareSizePx, beforeOffset, beforeOffset, afterOffset, afterOffset, positionStyles(position, squareSizeRounded, inset, shift), options.animationModifier && animationStyles$1(position, options.animationModifier));
1115
1304
  }
1116
1305
 
1117
1306
  const useDocument = theme => {
@@ -1173,9 +1362,30 @@ const animationStyles = (position, options) => {
1173
1362
  } else {
1174
1363
  transformFunction = 'translateX';
1175
1364
  }
1176
- const animationName = styled.keyframes(["0%{transform:", "(", ");}"], transformFunction, translateValue);
1365
+ const animationName = styled.keyframes(["0%{transform:", "(", ");pointer-events:none;}100%{pointer-events:auto;}"], transformFunction, translateValue);
1177
1366
  return styled.css(["&", " ", "{animation:0.2s cubic-bezier(0.15,0.85,0.35,1.2) ", ";}"], options.animationModifier, options.childSelector || '> *', animationName);
1178
1367
  };
1368
+ const colorStyles = theme => {
1369
+ const backgroundColor = getColor({
1370
+ theme,
1371
+ variable: 'background.raised'
1372
+ });
1373
+ const borderColor = getColor({
1374
+ theme,
1375
+ variable: 'border.default'
1376
+ });
1377
+ const boxShadowColor = getColor({
1378
+ variable: 'shadow.medium',
1379
+ theme
1380
+ });
1381
+ const boxShadowBlurRadius = `${theme.space.base * (theme.colors.base === 'dark' ? 5 : 6)}px`;
1382
+ const boxShadowOffsetY = `${theme.space.base * (theme.colors.base === 'dark' ? 4 : 5)}px`;
1383
+ const foregroundColor = getColor({
1384
+ theme,
1385
+ variable: 'foreground.default'
1386
+ });
1387
+ return styled.css(["border-color:", ";box-shadow:", ";background-color:", ";color:", ";"], borderColor, theme.shadows.lg(boxShadowOffsetY, boxShadowBlurRadius, boxShadowColor), backgroundColor, foregroundColor);
1388
+ };
1179
1389
  const hiddenStyles = options => {
1180
1390
  const transition = 'opacity 0.2s ease-in-out, 0.2s visibility 0s linear';
1181
1391
  return styled.css(["transition:", ";visibility:hidden;opacity:0;"], options.animationModifier && transition);
@@ -1193,21 +1403,7 @@ function menuStyles(position) {
1193
1403
  } else {
1194
1404
  marginProperty = 'margin-right';
1195
1405
  }
1196
- return styled.css(["position:absolute;z-index:", ";", ":", ";line-height:0;font-size:0.01px;& ", "{display:inline-block;position:relative;margin:0;box-sizing:border-box;border:", " ", ";border-radius:", ";box-shadow:", ";background-color:", ";cursor:default;padding:0;text-align:", ";white-space:normal;color:", ";font-size:", ";font-weight:", ";direction:", ";:focus{outline:none;}}", ";", ";"], options.zIndex || 0, marginProperty, options.margin, options.childSelector || '> *', theme.borders.sm, getColor({
1197
- theme,
1198
- variable: 'border.default'
1199
- }), theme.borderRadii.md, theme.shadows.lg(`${theme.space.base * 5}px`, `${theme.space.base * 7.5}px`, getColor({
1200
- theme,
1201
- hue: 'chromeHue',
1202
- shade: 600,
1203
- transparency: 0.15
1204
- })), getColor({
1205
- theme,
1206
- variable: 'background.raised'
1207
- }), theme.rtl ? 'right' : 'left', getColor({
1208
- theme,
1209
- variable: 'foreground.default'
1210
- }), theme.fontSizes.md, theme.fontWeights.regular, theme.rtl && 'rtl', options.animationModifier && animationStyles(position, options), options.hidden && hiddenStyles(options));
1406
+ return styled.css(["position:absolute;z-index:", ";", ":", ";line-height:0;font-size:0.01px;color-scheme:only ", ";& ", "{display:inline-block;position:relative;margin:0;box-sizing:border-box;border:", ";border-radius:", ";cursor:default;padding:0;text-align:", ";white-space:normal;font-size:", ";font-weight:", ";direction:", ";", ";:focus{outline:none;}}", ";", ";"], options.zIndex || 0, marginProperty, options.margin, p => p.theme.colors.base, options.childSelector || '> *', theme.borders.sm, theme.borderRadii.md, theme.rtl ? 'right' : 'left', theme.fontSizes.md, theme.fontWeights.regular, theme.rtl && 'rtl', colorStyles(theme), options.animationModifier && animationStyles(position, options), options.hidden && hiddenStyles(options));
1211
1407
  }
1212
1408
 
1213
1409
  const SELECTOR_FOCUS_VISIBLE = '&:focus-visible';
@@ -1262,7 +1458,6 @@ exports.ARROW_POSITION = ARROW_POSITION;
1262
1458
  exports.DEFAULT_THEME = DEFAULT_THEME;
1263
1459
  exports.MENU_POSITION = MENU_POSITION;
1264
1460
  exports.PALETTE = PALETTE;
1265
- exports.PALETTE_V8 = PALETTE_V8;
1266
1461
  exports.PLACEMENT = PLACEMENT;
1267
1462
  exports.SELECTOR_FOCUS_VISIBLE = SELECTOR_FOCUS_VISIBLE;
1268
1463
  exports.StyledBaseIcon = StyledBaseIcon;