@udixio/theme 1.0.0-beta.3 → 1.0.0-beta.5

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.
@@ -0,0 +1 @@
1
+ export * from './color.entity';
@@ -0,0 +1,6 @@
1
+ export * from './color-manager.service';
2
+ export * from './color.interface';
3
+ export * from './color.module';
4
+ export * from './color.service';
5
+ export * from './entities';
6
+ export * from './models';
@@ -0,0 +1 @@
1
+ export * from './default-color.model';
package/dist/index.d.ts CHANGED
@@ -1 +1,6 @@
1
+ export * from './app.module';
2
+ export * from './app.service';
3
+ export * from './color';
1
4
  export * from './main';
5
+ export * from './material-color-utilities';
6
+ export * from './theme';
@@ -1,2 +1,3 @@
1
1
  export * from './contrastCurve';
2
+ export * from './dynamic_color';
2
3
  export * from './toneDeltaPair';
@@ -0,0 +1,2 @@
1
+ export * from './scheme.entity';
2
+ export * from './variant.entity';
@@ -0,0 +1,4 @@
1
+ export * from './entities';
2
+ export * from './models';
3
+ export * from './services';
4
+ export * from './theme.module';
@@ -0,0 +1 @@
1
+ export * from './variant.model';
@@ -0,0 +1,3 @@
1
+ export * from './scheme.service';
2
+ export * from './theme.service';
3
+ export * from './variant.service';
@@ -2,11 +2,11 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var core = require('@nestjs/core');
6
5
  var tslib = require('tslib');
7
6
  var common = require('@nestjs/common');
8
7
  var materialColorUtilities = require('@material/material-color-utilities');
9
8
  var mergeDeep = require('merge-deep');
9
+ var core = require('@nestjs/core');
10
10
 
11
11
  function asyncGeneratorStep(n, t, e, r, o, a, c) {
12
12
  try {
@@ -435,67 +435,6 @@ var ContrastCurve = /*#__PURE__*/function () {
435
435
  return ContrastCurve;
436
436
  }();
437
437
 
438
- /**
439
- * @license
440
- * Copyright 2023 Google LLC
441
- *
442
- * Licensed under the Apache License, Version 2.0 (the "License");
443
- * you may not use this file except in compliance with the License.
444
- * You may obtain a copy of the License at
445
- *
446
- * http://www.apache.org/licenses/LICENSE-2.0
447
- *
448
- * Unless required by applicable law or agreed to in writing, software
449
- * distributed under the License is distributed on an "AS IS" BASIS,
450
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
451
- * See the License for the specific language governing permissions and
452
- * limitations under the License.
453
- */
454
- /**
455
- * Documents a constraint between two DynamicColors, in which their tones must
456
- * have a certain distance from each other.
457
- *
458
- * Prefer a DynamicColor with a background, this is for special cases when
459
- * designers want tonal distance, literally contrast, between two colors that
460
- * don't have a background / foreground relationship or a contrast guarantee.
461
- */
462
- var ToneDeltaPair =
463
- /**
464
- * Documents a constraint in tone distance between two DynamicColors.
465
- *
466
- * The polarity is an adjective that describes "A", compared to "B".
467
- *
468
- * For instance, ToneDeltaPair(A, B, 15, 'darker', stayTogether) states that
469
- * A's tone should be at least 15 darker than B's.
470
- *
471
- * 'nearer' and 'farther' describes closeness to the surface roles. For
472
- * instance, ToneDeltaPair(A, B, 10, 'nearer', stayTogether) states that A
473
- * should be 10 lighter than B in light mode, and 10 darker than B in dark
474
- * mode.
475
- *
476
- * @param roleA The first role in a pair.
477
- * @param roleB The second role in a pair.
478
- * @param delta Required difference between tones. Absolute value, negative
479
- * values have undefined behavior.
480
- * @param polarity The relative relation between tones of roleA and roleB,
481
- * as described above.
482
- * @param stayTogether Whether these two roles should stay on the same side of
483
- * the "awkward zone" (T50-59). This is necessary for certain cases where
484
- * one role has two backgrounds.
485
- */
486
- function ToneDeltaPair(roleA, roleB, delta, polarity, stayTogether) {
487
- this.roleA = void 0;
488
- this.roleB = void 0;
489
- this.delta = void 0;
490
- this.polarity = void 0;
491
- this.stayTogether = void 0;
492
- this.roleA = roleA;
493
- this.roleB = roleB;
494
- this.delta = delta;
495
- this.polarity = polarity;
496
- this.stayTogether = stayTogether;
497
- };
498
-
499
438
  /**
500
439
  * @license
501
440
  * Copyright 2022 Google LLC
@@ -832,6 +771,67 @@ var DynamicColor = /*#__PURE__*/function () {
832
771
  return DynamicColor;
833
772
  }();
834
773
 
774
+ /**
775
+ * @license
776
+ * Copyright 2023 Google LLC
777
+ *
778
+ * Licensed under the Apache License, Version 2.0 (the "License");
779
+ * you may not use this file except in compliance with the License.
780
+ * You may obtain a copy of the License at
781
+ *
782
+ * http://www.apache.org/licenses/LICENSE-2.0
783
+ *
784
+ * Unless required by applicable law or agreed to in writing, software
785
+ * distributed under the License is distributed on an "AS IS" BASIS,
786
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
787
+ * See the License for the specific language governing permissions and
788
+ * limitations under the License.
789
+ */
790
+ /**
791
+ * Documents a constraint between two DynamicColors, in which their tones must
792
+ * have a certain distance from each other.
793
+ *
794
+ * Prefer a DynamicColor with a background, this is for special cases when
795
+ * designers want tonal distance, literally contrast, between two colors that
796
+ * don't have a background / foreground relationship or a contrast guarantee.
797
+ */
798
+ var ToneDeltaPair =
799
+ /**
800
+ * Documents a constraint in tone distance between two DynamicColors.
801
+ *
802
+ * The polarity is an adjective that describes "A", compared to "B".
803
+ *
804
+ * For instance, ToneDeltaPair(A, B, 15, 'darker', stayTogether) states that
805
+ * A's tone should be at least 15 darker than B's.
806
+ *
807
+ * 'nearer' and 'farther' describes closeness to the surface roles. For
808
+ * instance, ToneDeltaPair(A, B, 10, 'nearer', stayTogether) states that A
809
+ * should be 10 lighter than B in light mode, and 10 darker than B in dark
810
+ * mode.
811
+ *
812
+ * @param roleA The first role in a pair.
813
+ * @param roleB The second role in a pair.
814
+ * @param delta Required difference between tones. Absolute value, negative
815
+ * values have undefined behavior.
816
+ * @param polarity The relative relation between tones of roleA and roleB,
817
+ * as described above.
818
+ * @param stayTogether Whether these two roles should stay on the same side of
819
+ * the "awkward zone" (T50-59). This is necessary for certain cases where
820
+ * one role has two backgrounds.
821
+ */
822
+ function ToneDeltaPair(roleA, roleB, delta, polarity, stayTogether) {
823
+ this.roleA = void 0;
824
+ this.roleB = void 0;
825
+ this.delta = void 0;
826
+ this.polarity = void 0;
827
+ this.stayTogether = void 0;
828
+ this.roleA = roleA;
829
+ this.roleB = roleB;
830
+ this.delta = delta;
831
+ this.polarity = polarity;
832
+ this.stayTogether = stayTogether;
833
+ };
834
+
835
835
  var ColorEntity = /*#__PURE__*/function () {
836
836
  function ColorEntity(option, schemeService, colorService) {
837
837
  this.option = void 0;
@@ -910,7 +910,7 @@ var SchemeEntity = /*#__PURE__*/function () {
910
910
  }]);
911
911
  }();
912
912
 
913
- var SchemeService = /*#__PURE__*/function () {
913
+ exports.SchemeService = /*#__PURE__*/function () {
914
914
  function SchemeService() {
915
915
  this.schemeEntity = void 0;
916
916
  this.options = void 0;
@@ -944,7 +944,7 @@ var SchemeService = /*#__PURE__*/function () {
944
944
  };
945
945
  return SchemeService;
946
946
  }();
947
- SchemeService = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Injectable()], SchemeService);
947
+ exports.SchemeService = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Injectable()], exports.SchemeService);
948
948
 
949
949
  function capitalizeFirstLetter(string) {
950
950
  return string.charAt(0).toUpperCase() + string.slice(1);
@@ -952,7 +952,7 @@ function capitalizeFirstLetter(string) {
952
952
  var highestSurface = function highestSurface(s, colorManagerService) {
953
953
  return s.isDark ? colorManagerService.get('surfaceBright').getDynamicColor() : colorManagerService.get('surfaceDim').getDynamicColor();
954
954
  };
955
- var ColorManagerService = /*#__PURE__*/function () {
955
+ exports.ColorManagerService = /*#__PURE__*/function () {
956
956
  function ColorManagerService(schemeService) {
957
957
  this.schemeService = void 0;
958
958
  this.colorMap = new Map();
@@ -1141,7 +1141,7 @@ var ColorManagerService = /*#__PURE__*/function () {
1141
1141
  };
1142
1142
  return ColorManagerService;
1143
1143
  }();
1144
- ColorManagerService = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Injectable(), /*#__PURE__*/tslib.__metadata("design:paramtypes", [SchemeService])], ColorManagerService);
1144
+ exports.ColorManagerService = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Injectable(), /*#__PURE__*/tslib.__metadata("design:paramtypes", [exports.SchemeService])], exports.ColorManagerService);
1145
1145
 
1146
1146
  function findDesiredChromaByTone(hue, chroma, tone, byDecreasingTone) {
1147
1147
  var answer = tone;
@@ -1481,7 +1481,7 @@ var defaultColors = function defaultColors(colorManagerService) {
1481
1481
  };
1482
1482
  };
1483
1483
 
1484
- var ColorService = /*#__PURE__*/function () {
1484
+ exports.ColorService = /*#__PURE__*/function () {
1485
1485
  function ColorService(colorManagerService) {
1486
1486
  this.colorManagerService = void 0;
1487
1487
  this.colorManagerService = colorManagerService;
@@ -1532,9 +1532,9 @@ var ColorService = /*#__PURE__*/function () {
1532
1532
  };
1533
1533
  return ColorService;
1534
1534
  }();
1535
- ColorService = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Injectable(), /*#__PURE__*/tslib.__metadata("design:paramtypes", [ColorManagerService])], ColorService);
1535
+ exports.ColorService = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Injectable(), /*#__PURE__*/tslib.__metadata("design:paramtypes", [exports.ColorManagerService])], exports.ColorService);
1536
1536
 
1537
- var VariantService = /*#__PURE__*/function () {
1537
+ exports.VariantService = /*#__PURE__*/function () {
1538
1538
  function VariantService(schemeService) {
1539
1539
  this.schemeService = void 0;
1540
1540
  this.schemeService = schemeService;
@@ -1550,9 +1550,9 @@ var VariantService = /*#__PURE__*/function () {
1550
1550
  };
1551
1551
  return VariantService;
1552
1552
  }();
1553
- VariantService = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Injectable(), /*#__PURE__*/tslib.__metadata("design:paramtypes", [SchemeService])], VariantService);
1553
+ exports.VariantService = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Injectable(), /*#__PURE__*/tslib.__metadata("design:paramtypes", [exports.SchemeService])], exports.VariantService);
1554
1554
 
1555
- var ThemeService = /*#__PURE__*/function () {
1555
+ exports.ThemeService = /*#__PURE__*/function () {
1556
1556
  function ThemeService(schemeService, variantService) {
1557
1557
  this.schemeService = void 0;
1558
1558
  this.variantService = void 0;
@@ -1591,34 +1591,34 @@ var ThemeService = /*#__PURE__*/function () {
1591
1591
  };
1592
1592
  return ThemeService;
1593
1593
  }();
1594
- ThemeService = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Injectable(), /*#__PURE__*/tslib.__metadata("design:paramtypes", [SchemeService, VariantService])], ThemeService);
1594
+ exports.ThemeService = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Injectable(), /*#__PURE__*/tslib.__metadata("design:paramtypes", [exports.SchemeService, exports.VariantService])], exports.ThemeService);
1595
1595
 
1596
- var AppService = function AppService(colorService, themeService) {
1596
+ exports.AppService = function AppService(colorService, themeService) {
1597
1597
  this.colorService = void 0;
1598
1598
  this.themeService = void 0;
1599
1599
  this.colorService = colorService;
1600
1600
  this.themeService = themeService;
1601
1601
  };
1602
- AppService = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Injectable(), /*#__PURE__*/tslib.__metadata("design:paramtypes", [ColorService, ThemeService])], AppService);
1602
+ exports.AppService = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Injectable(), /*#__PURE__*/tslib.__metadata("design:paramtypes", [exports.ColorService, exports.ThemeService])], exports.AppService);
1603
1603
 
1604
- var ThemeModule = function ThemeModule() {};
1605
- ThemeModule = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Module({
1606
- providers: [SchemeService, ThemeService, VariantService],
1607
- exports: [ThemeService, SchemeService]
1608
- })], ThemeModule);
1604
+ exports.ThemeModule = function ThemeModule() {};
1605
+ exports.ThemeModule = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Module({
1606
+ providers: [exports.SchemeService, exports.ThemeService, exports.VariantService],
1607
+ exports: [exports.ThemeService, exports.SchemeService]
1608
+ })], exports.ThemeModule);
1609
1609
 
1610
- var ColorModule = function ColorModule() {};
1611
- ColorModule = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Module({
1612
- imports: [ThemeModule],
1613
- providers: [ColorService, ColorManagerService],
1614
- exports: [ColorService]
1615
- })], ColorModule);
1610
+ exports.ColorModule = function ColorModule() {};
1611
+ exports.ColorModule = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Module({
1612
+ imports: [exports.ThemeModule],
1613
+ providers: [exports.ColorService, exports.ColorManagerService],
1614
+ exports: [exports.ColorService]
1615
+ })], exports.ColorModule);
1616
1616
 
1617
- var AppModule = function AppModule() {};
1618
- AppModule = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Module({
1619
- imports: [ColorModule, ThemeModule],
1620
- providers: [AppService]
1621
- })], AppModule);
1617
+ exports.AppModule = function AppModule() {};
1618
+ exports.AppModule = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Module({
1619
+ imports: [exports.ColorModule, exports.ThemeModule],
1620
+ providers: [exports.AppService]
1621
+ })], exports.AppModule);
1622
1622
 
1623
1623
  function main() {
1624
1624
  return _main.apply(this, arguments);
@@ -1630,10 +1630,10 @@ function _main() {
1630
1630
  while (1) switch (_context.prev = _context.next) {
1631
1631
  case 0:
1632
1632
  _context.next = 2;
1633
- return core.NestFactory.create(AppModule);
1633
+ return core.NestFactory.create(exports.AppModule);
1634
1634
  case 2:
1635
1635
  app = _context.sent;
1636
- appService = app.get(AppService);
1636
+ appService = app.get(exports.AppService);
1637
1637
  close = function close() {
1638
1638
  return app.close();
1639
1639
  };
@@ -1647,5 +1647,88 @@ function _main() {
1647
1647
  return _main.apply(this, arguments);
1648
1648
  }
1649
1649
 
1650
+ var getRotatedHue = function getRotatedHue(sourceColor, hues, rotations) {
1651
+ var sourceHue = sourceColor.hue;
1652
+ if (hues.length !== rotations.length) {
1653
+ throw new Error("mismatch between hue length " + hues.length + " & rotations " + rotations.length);
1654
+ }
1655
+ if (rotations.length === 1) {
1656
+ return materialColorUtilities.sanitizeDegreesDouble(sourceColor.hue + rotations[0]);
1657
+ }
1658
+ var size = hues.length;
1659
+ for (var i = 0; i <= size - 2; i++) {
1660
+ var thisHue = hues[i];
1661
+ var nextHue = hues[i + 1];
1662
+ if (thisHue < sourceHue && sourceHue < nextHue) {
1663
+ return materialColorUtilities.sanitizeDegreesDouble(sourceHue + rotations[i]);
1664
+ }
1665
+ }
1666
+ // If this statement executes, something is wrong, there should have been a
1667
+ // rotation found using the arrays.
1668
+ return sourceHue;
1669
+ };
1670
+ var VariantEntity = function VariantEntity(palettes) {
1671
+ if (palettes === void 0) {
1672
+ palettes = {};
1673
+ }
1674
+ this.palettes = void 0;
1675
+ this.palettes = palettes;
1676
+ };
1677
+
1678
+ var _VariantModel;
1679
+ var VariantModel = function VariantModel() {};
1680
+ _VariantModel = VariantModel;
1681
+ VariantModel.tonalSpot = {
1682
+ palettes: {
1683
+ primary: function primary(sourceColorHct) {
1684
+ return materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 36.0);
1685
+ },
1686
+ secondary: function secondary(sourceColorHct) {
1687
+ return materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 16.0);
1688
+ },
1689
+ tertiary: function tertiary(sourceColorHct) {
1690
+ return materialColorUtilities.TonalPalette.fromHueAndChroma(materialColorUtilities.sanitizeDegreesDouble(sourceColorHct.hue + 60.0), 24.0);
1691
+ },
1692
+ neutral: function neutral(sourceColorHct) {
1693
+ return materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 6.0);
1694
+ },
1695
+ neutralVariant: function neutralVariant(sourceColorHct) {
1696
+ return materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 8.0);
1697
+ }
1698
+ }
1699
+ };
1700
+ VariantModel.vibrant = {
1701
+ palettes: {
1702
+ primary: function primary(sourceColorHct) {
1703
+ return materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 200.0);
1704
+ },
1705
+ secondary: function secondary(sourceColorHct) {
1706
+ return materialColorUtilities.TonalPalette.fromHueAndChroma(getRotatedHue(sourceColorHct, _VariantModel.hues, _VariantModel.secondaryRotations), 24.0);
1707
+ },
1708
+ tertiary: function tertiary(sourceColorHct) {
1709
+ return materialColorUtilities.TonalPalette.fromHueAndChroma(getRotatedHue(sourceColorHct, _VariantModel.hues, _VariantModel.tertiaryRotations), 32.0);
1710
+ },
1711
+ neutral: function neutral(sourceColorHct) {
1712
+ return materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 6.0);
1713
+ },
1714
+ neutralVariant: function neutralVariant(sourceColorHct) {
1715
+ return materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 8.0);
1716
+ }
1717
+ }
1718
+ };
1719
+ VariantModel.hues = [0.0, 41.0, 61.0, 101.0, 131.0, 181.0, 251.0, 301.0, 360.0];
1720
+ VariantModel.secondaryRotations = [18.0, 15.0, 10.0, 12.0, 15.0, 18.0, 15.0, 12.0, 12.0];
1721
+ VariantModel.tertiaryRotations = [35.0, 30.0, 20.0, 25.0, 30.0, 35.0, 30.0, 25.0, 25.0];
1722
+
1723
+ exports.ColorEntity = ColorEntity;
1724
+ exports.ContrastCurve = ContrastCurve;
1725
+ exports.DynamicColor = DynamicColor;
1726
+ exports.SchemeEntity = SchemeEntity;
1727
+ exports.ToneDeltaPair = ToneDeltaPair;
1728
+ exports.VariantEntity = VariantEntity;
1729
+ exports.VariantModel = VariantModel;
1730
+ exports.defaultColors = defaultColors;
1731
+ exports.getRotatedHue = getRotatedHue;
1732
+ exports.highestSurface = highestSurface;
1650
1733
  exports.main = main;
1651
1734
  //# sourceMappingURL=theme.cjs.development.js.map