@uni-design-system/uni-core 5.0.0 → 5.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/cjs/index.cjs +80 -24
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +80 -25
- package/dist/esm/index.js.map +1 -1
- package/dist/types/concepts/generation/generation.types.d.ts +3 -2
- package/dist/types/concepts/generation/generation.types.d.ts.map +1 -1
- package/dist/types/concepts/generation/index.d.ts +1 -0
- package/dist/types/concepts/generation/index.d.ts.map +1 -1
- package/dist/types/concepts/generation/shadow.generator.d.ts +13 -0
- package/dist/types/concepts/generation/shadow.generator.d.ts.map +1 -0
- package/dist/types/concepts/generation/theme-file.emitter.d.ts.map +1 -1
- package/dist/types/concepts/generation/theme.generator.d.ts.map +1 -1
- package/dist/types/concepts/theme/themes/base.theme.d.ts.map +1 -1
- package/dist/types/concepts/theme/themes/dark.theme.d.ts.map +1 -1
- package/dist/types/concepts/theme/themes/light.theme.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -761,6 +761,43 @@ var Z_INDEX = {
|
|
|
761
761
|
overlay: 1080
|
|
762
762
|
};
|
|
763
763
|
//#endregion
|
|
764
|
+
//#region src/concepts/generation/shadow.generator.ts
|
|
765
|
+
var rgba = (hex, alpha) => {
|
|
766
|
+
const { red, green, blue } = hexToRgb(hex);
|
|
767
|
+
return `rgba(${red}, ${green}, ${blue}, ${alpha})`;
|
|
768
|
+
};
|
|
769
|
+
/**
|
|
770
|
+
* Brand-tinted, theme-scoped elevation shadows (PRD §3.5.C).
|
|
771
|
+
*
|
|
772
|
+
* Light mode replaces the dead-neutral black stacks with a shadow ink pulled
|
|
773
|
+
* toward the brand hue — dark and low-chroma enough to read as shadow, tinted
|
|
774
|
+
* enough to kill the grey "mud" where shadows meet brand surfaces. Dark mode
|
|
775
|
+
* goes near-zero: elevation is carried by the surface lightness steps, with
|
|
776
|
+
* only a faint veil kept on floating overlays (menus/dialogs genuinely need
|
|
777
|
+
* separation) and the `warn` glow tinted by the theme's own error color.
|
|
778
|
+
*/
|
|
779
|
+
var generateShadows = (colors, mode = "light") => {
|
|
780
|
+
const error = colors["error"] ?? "#CC2827";
|
|
781
|
+
if (mode === "dark") return {
|
|
782
|
+
raised: "none",
|
|
783
|
+
menu: `0px 4px 12px ${rgba("#000000", .45)}`,
|
|
784
|
+
dialog: `0px 8px 28px ${rgba("#000000", .55)}`,
|
|
785
|
+
warn: `0 0 5px ${rgba(error, .55)}, inset 0 0 5px ${rgba(error, .35)}`
|
|
786
|
+
};
|
|
787
|
+
const { h } = hexToOklch(colors["primary"] ?? "#000000");
|
|
788
|
+
const ink = oklchToHex({
|
|
789
|
+
l: .22,
|
|
790
|
+
c: .035,
|
|
791
|
+
h
|
|
792
|
+
});
|
|
793
|
+
return {
|
|
794
|
+
raised: `${rgba(ink, .2)} 0px 2px 1px -1px, ${rgba(ink, .14)} 0px 1px 1px 0px, ${rgba(ink, .12)} 0px 1px 3px 0px`,
|
|
795
|
+
menu: `${rgba(ink, .2)} 0px 3px 3px -2px, ${rgba(ink, .14)} 0px 3px 4px 0px, ${rgba(ink, .12)} 0px 1px 8px 0px`,
|
|
796
|
+
dialog: `${rgba(ink, .2)} 0px 3px 5px -1px, ${rgba(ink, .14)} 0px 6px 10px 0px, ${rgba(ink, .12)} 0px 1px 18px 0px`,
|
|
797
|
+
warn: `0 0 5px ${rgba(error, .5)}, inset 0 0 5px ${rgba(error, .3)}`
|
|
798
|
+
};
|
|
799
|
+
};
|
|
800
|
+
//#endregion
|
|
764
801
|
//#region src/concepts/theme/themes/base.theme.ts
|
|
765
802
|
var BaseTypography = {
|
|
766
803
|
"display-large": {
|
|
@@ -1336,12 +1373,16 @@ var createTheme = ({ id, name, colors, icons = {}, radii = BaseRadii, shadows =
|
|
|
1336
1373
|
* one-call path a theme builder uses to turn a brand color (or a seed +
|
|
1337
1374
|
* scheme + category) into a complete, ready-to-apply theme.
|
|
1338
1375
|
*/
|
|
1339
|
-
var createThemeFromPalette = (config) =>
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1376
|
+
var createThemeFromPalette = (config) => {
|
|
1377
|
+
const colors = generatePalette(config);
|
|
1378
|
+
return createTheme({
|
|
1379
|
+
id: config.id ?? "CustomTheme",
|
|
1380
|
+
name: config.name ?? "Custom Theme",
|
|
1381
|
+
colors,
|
|
1382
|
+
shadows: generateShadows(colors, config.mode ?? "light"),
|
|
1383
|
+
icons: config.icons
|
|
1384
|
+
});
|
|
1385
|
+
};
|
|
1345
1386
|
/**
|
|
1346
1387
|
* Seed for the shipped Light/Dark themes. Swap these three values (or call
|
|
1347
1388
|
* `generatePalette` with your own) to reskin the entire system — every color
|
|
@@ -1464,6 +1505,8 @@ var generateThemes = (input) => {
|
|
|
1464
1505
|
lightColors,
|
|
1465
1506
|
darkColors,
|
|
1466
1507
|
radii: input.shape ? ShapeRadii[input.shape] : void 0,
|
|
1508
|
+
lightShadows: generateShadows(lightColors, "light"),
|
|
1509
|
+
darkShadows: generateShadows(darkColors, "dark"),
|
|
1467
1510
|
report: {
|
|
1468
1511
|
checks,
|
|
1469
1512
|
worstRatio,
|
|
@@ -1476,7 +1519,7 @@ var generateThemes = (input) => {
|
|
|
1476
1519
|
* returning a registration-ready light/dark {@link UniTheme} pair.
|
|
1477
1520
|
*/
|
|
1478
1521
|
var generateUniThemes = (input) => {
|
|
1479
|
-
const { lightColors, darkColors, radii } = generateThemes(input);
|
|
1522
|
+
const { lightColors, darkColors, radii, lightShadows, darkShadows } = generateThemes(input);
|
|
1480
1523
|
const name = input.name ?? "Brand";
|
|
1481
1524
|
const id = name.replace(/\W+/g, "") || "Brand";
|
|
1482
1525
|
return {
|
|
@@ -1484,13 +1527,15 @@ var generateUniThemes = (input) => {
|
|
|
1484
1527
|
id: `${id}Light`,
|
|
1485
1528
|
name: `${name} Light`,
|
|
1486
1529
|
colors: lightColors,
|
|
1487
|
-
radii
|
|
1530
|
+
radii,
|
|
1531
|
+
shadows: lightShadows
|
|
1488
1532
|
}),
|
|
1489
1533
|
dark: createTheme({
|
|
1490
1534
|
id: `${id}Dark`,
|
|
1491
1535
|
name: `${name} Dark`,
|
|
1492
1536
|
colors: darkColors,
|
|
1493
|
-
radii
|
|
1537
|
+
radii,
|
|
1538
|
+
shadows: darkShadows
|
|
1494
1539
|
})
|
|
1495
1540
|
};
|
|
1496
1541
|
};
|
|
@@ -1507,24 +1552,25 @@ var bordersLiteral = () => [
|
|
|
1507
1552
|
" * shared token picks up the change.",
|
|
1508
1553
|
" */",
|
|
1509
1554
|
"const borders = (colors: Colors): Borders => ({",
|
|
1510
|
-
" primary: `1px solid ${colors
|
|
1511
|
-
" secondary: `1px solid ${colors
|
|
1512
|
-
" tertiary: `1px solid ${colors
|
|
1513
|
-
" quaternary: `1px solid ${colors
|
|
1514
|
-
" warn: `1px solid ${colors
|
|
1515
|
-
" success: `1px solid ${colors
|
|
1516
|
-
" light: `1px solid ${colors
|
|
1555
|
+
" primary: `1px solid ${colors['primary']}`,",
|
|
1556
|
+
" secondary: `1px solid ${colors['secondary']}`,",
|
|
1557
|
+
" tertiary: `1px solid ${colors['tertiary']}`,",
|
|
1558
|
+
" quaternary: `1px solid ${colors['quaternary']}`,",
|
|
1559
|
+
" warn: `1px solid ${colors['warn']}`,",
|
|
1560
|
+
" success: `1px solid ${colors['success']}`,",
|
|
1561
|
+
" light: `1px solid ${colors['outline']}`,",
|
|
1517
1562
|
" dark: `1px solid ${colors['on-background']}`,",
|
|
1518
1563
|
" dotted: `1px dotted ${colors['on-background']}`,",
|
|
1519
1564
|
"});"
|
|
1520
1565
|
].join("\n");
|
|
1521
|
-
var themeExport = (exportName, displayName, colorsConst, radii) => [
|
|
1566
|
+
var themeExport = (exportName, displayName, colorsConst, shadowsConst, radii) => [
|
|
1522
1567
|
`export const ${exportName}: UniTheme = createTheme({`,
|
|
1523
1568
|
` id: '${exportName}',`,
|
|
1524
1569
|
` name: '${displayName}',`,
|
|
1525
1570
|
` colors: ${colorsConst},`,
|
|
1526
1571
|
` borders: borders(${colorsConst}),`,
|
|
1527
1572
|
` components: components(${colorsConst}),`,
|
|
1573
|
+
` shadows: ${shadowsConst},`,
|
|
1528
1574
|
...radii ? [" radii,"] : [],
|
|
1529
1575
|
"});"
|
|
1530
1576
|
].join("\n");
|
|
@@ -1539,7 +1585,7 @@ var themeExport = (exportName, displayName, colorsConst, radii) => [
|
|
|
1539
1585
|
*/
|
|
1540
1586
|
var emitThemeFile = (input) => {
|
|
1541
1587
|
const { darkMode = true, name = "Brand" } = input;
|
|
1542
|
-
const { lightColors, darkColors, radii, report } = generateThemes(input);
|
|
1588
|
+
const { lightColors, darkColors, radii, lightShadows, darkShadows, report } = generateThemes(input);
|
|
1543
1589
|
const id = name.replace(/\W+/g, "") || "Brand";
|
|
1544
1590
|
const regenerate = [
|
|
1545
1591
|
`--brand=${(Array.isArray(input.seed) ? input.seed : [input.seed]).join(",")}`,
|
|
@@ -1553,12 +1599,16 @@ var emitThemeFile = (input) => {
|
|
|
1553
1599
|
exportName: `${id}Light`,
|
|
1554
1600
|
displayName: `${name} Light`,
|
|
1555
1601
|
colorsConst: "lightColors",
|
|
1556
|
-
colors: lightColors
|
|
1602
|
+
colors: lightColors,
|
|
1603
|
+
shadowsConst: "lightShadows",
|
|
1604
|
+
shadows: lightShadows
|
|
1557
1605
|
}, ...darkMode ? [{
|
|
1558
1606
|
exportName: `${id}Dark`,
|
|
1559
1607
|
displayName: `${name} Dark`,
|
|
1560
1608
|
colorsConst: "darkColors",
|
|
1561
|
-
colors: darkColors
|
|
1609
|
+
colors: darkColors,
|
|
1610
|
+
shadowsConst: "darkShadows",
|
|
1611
|
+
shadows: darkShadows
|
|
1562
1612
|
}] : []];
|
|
1563
1613
|
return {
|
|
1564
1614
|
content: [
|
|
@@ -1575,16 +1625,19 @@ var emitThemeFile = (input) => {
|
|
|
1575
1625
|
" type Borders,",
|
|
1576
1626
|
" type Colors,",
|
|
1577
1627
|
" type ComponentThemes,",
|
|
1628
|
+
" type Shadows,",
|
|
1578
1629
|
" type UniTheme,",
|
|
1579
1630
|
"} from '@uni-design-system/uni-core';",
|
|
1580
1631
|
"",
|
|
1581
1632
|
...modes.map(({ colorsConst, colors }) => `const ${colorsConst}: Colors = {\n${recordLiteral(colors, " ")}\n};\n`),
|
|
1633
|
+
"/** Brand-tinted elevation shadows — theme-scoped, edit freely. */",
|
|
1634
|
+
...modes.map(({ shadowsConst, shadows }) => `const ${shadowsConst}: Shadows = {\n${recordLiteral(shadows, " ")}\n};\n`),
|
|
1582
1635
|
bordersLiteral(),
|
|
1583
1636
|
"",
|
|
1584
1637
|
"/**",
|
|
1585
1638
|
" * Sparse component overrides, deep-merged over Uni component defaults: only",
|
|
1586
1639
|
" * what you write here changes. Point components at your own primitives, e.g.:",
|
|
1587
|
-
" * button: { variants: { secondary: { border: `2px dashed ${colors
|
|
1640
|
+
" * button: { variants: { secondary: { border: `2px dashed ${colors['tertiary']}` } } },",
|
|
1588
1641
|
" * input: { options: { borderRadius: 'max' } },",
|
|
1589
1642
|
" */",
|
|
1590
1643
|
"const components = (colors: Colors): ComponentThemes => ({});",
|
|
@@ -1594,7 +1647,7 @@ var emitThemeFile = (input) => {
|
|
|
1594
1647
|
`const radii = {\n${recordLiteral(radii, " ")}\n};`,
|
|
1595
1648
|
""
|
|
1596
1649
|
] : [],
|
|
1597
|
-
...modes.map(({ exportName, displayName, colorsConst }) => `${themeExport(exportName, displayName, colorsConst, !!radii)}\n`),
|
|
1650
|
+
...modes.map(({ exportName, displayName, colorsConst, shadowsConst }) => `${themeExport(exportName, displayName, colorsConst, shadowsConst, !!radii)}\n`),
|
|
1598
1651
|
"/** First key wins as the default theme when registered via UNI_THEMES. */",
|
|
1599
1652
|
`export const ${id}Themes = { ${modes.map((m) => m.exportName).join(", ")} };`,
|
|
1600
1653
|
""
|
|
@@ -1729,14 +1782,16 @@ var darkColors = generatePalette({
|
|
|
1729
1782
|
var DarkTheme = createTheme({
|
|
1730
1783
|
id: "DarkTheme",
|
|
1731
1784
|
name: "Dark Theme",
|
|
1732
|
-
colors: darkColors
|
|
1785
|
+
colors: darkColors,
|
|
1786
|
+
shadows: generateShadows(darkColors, "dark")
|
|
1733
1787
|
});
|
|
1734
1788
|
//#endregion
|
|
1735
1789
|
//#region src/concepts/theme/themes/light.theme.ts
|
|
1736
1790
|
var LightTheme = createTheme({
|
|
1737
1791
|
id: "LightTheme",
|
|
1738
1792
|
name: "Light Theme",
|
|
1739
|
-
colors: lightColors
|
|
1793
|
+
colors: lightColors,
|
|
1794
|
+
shadows: generateShadows(lightColors, "light")
|
|
1740
1795
|
});
|
|
1741
1796
|
//#endregion
|
|
1742
1797
|
//#region src/concepts/theme/theme.records.ts
|
|
@@ -1795,6 +1850,6 @@ var debounce = (callback, timeout) => {
|
|
|
1795
1850
|
};
|
|
1796
1851
|
};
|
|
1797
1852
|
//#endregion
|
|
1798
|
-
export { BASE_PALETTE_CONFIG, BaseTheme, CategoryChroma, CategoryLightness, CategorySaturation, DarkTheme, DefaultThemeId, FontWeightMap, HSLAToString, HSLToHex, HSLToRGB, LightTheme, RGBToHSL, RGBToString, RoleHues, ShadowCssMap, ShadowMap, ShapeRadii, UniThemes, Z_INDEX, classifyScheme, collapseFadeOut, contrastRatio, createTheme, createThemeFromPalette, cycle, darkColors, debounce, emitThemeFile, expandFadeIn, fadeIn, fadeOut, generateColors, generatePalette, generateThemes, generateUniThemes, getAnalogousHues, getComplimentaryHue, getDeviceOrientation, getDeviceSize, getSplitComplimentaryHues, getTriadicHues, getValue, gradient, hexToHSL, hexToOklch, hexToRgb, inferCategory, lightColors, oklchToHex, randomRangeValue, relativeLuminance, removeInputPlatformStyling, rgbToHex, schemeHues, toTypeface, toTypefaces, uniColor };
|
|
1853
|
+
export { BASE_PALETTE_CONFIG, BaseTheme, CategoryChroma, CategoryLightness, CategorySaturation, DarkTheme, DefaultThemeId, FontWeightMap, HSLAToString, HSLToHex, HSLToRGB, LightTheme, RGBToHSL, RGBToString, RoleHues, ShadowCssMap, ShadowMap, ShapeRadii, UniThemes, Z_INDEX, classifyScheme, collapseFadeOut, contrastRatio, createTheme, createThemeFromPalette, cycle, darkColors, debounce, emitThemeFile, expandFadeIn, fadeIn, fadeOut, generateColors, generatePalette, generateShadows, generateThemes, generateUniThemes, getAnalogousHues, getComplimentaryHue, getDeviceOrientation, getDeviceSize, getSplitComplimentaryHues, getTriadicHues, getValue, gradient, hexToHSL, hexToOklch, hexToRgb, inferCategory, lightColors, oklchToHex, randomRangeValue, relativeLuminance, removeInputPlatformStyling, rgbToHex, schemeHues, toTypeface, toTypefaces, uniColor };
|
|
1799
1854
|
|
|
1800
1855
|
//# sourceMappingURL=index.js.map
|