@uni-design-system/uni-core 5.1.0 → 6.0.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/esm/index.js CHANGED
@@ -761,6 +761,28 @@ var Z_INDEX = {
761
761
  overlay: 1080
762
762
  };
763
763
  //#endregion
764
+ //#region src/concepts/generation/dtcg.emitter.ts
765
+ var dimensionEntries = (record) => Object.fromEntries(Object.entries(record ?? {}).filter(([, value]) => value !== void 0 && value !== "none").map(([key, value]) => [key, {
766
+ $value: String(value),
767
+ $type: "dimension"
768
+ }]));
769
+ /**
770
+ * Render one theme mode's tokens as W3C DTCG JSON for external pipelines
771
+ * (Style Dictionary etc.). Token names are exactly Uni's `ColorToken` strings —
772
+ * one vocabulary everywhere. The native `UniTheme` object remains the primary,
773
+ * lossless output; this is the interop layer.
774
+ */
775
+ var emitDtcgTokens = (input) => ({
776
+ color: Object.fromEntries(Object.entries(input.colors).filter(([, value]) => value !== void 0).map(([key, value]) => [key, {
777
+ $value: value,
778
+ $type: "color"
779
+ }])),
780
+ size: {
781
+ radius: dimensionEntries(input.radii),
782
+ spacing: dimensionEntries(input.spacing)
783
+ }
784
+ });
785
+ //#endregion
764
786
  //#region src/concepts/generation/shadow.generator.ts
765
787
  var rgba = (hex, alpha) => {
766
788
  const { red, green, blue } = hexToRgb(hex);
@@ -798,6 +820,28 @@ var generateShadows = (colors, mode = "light") => {
798
820
  };
799
821
  };
800
822
  //#endregion
823
+ //#region src/concepts/iconography/icon.records.ts
824
+ /**
825
+ * Default icon primitives shipped with every theme. Each icon is an inline
826
+ * SVG data URI rendered as a CSS mask over `currentColor`, so icons recolor
827
+ * with the theme automatically. `createTheme` merges a theme's own `icons`
828
+ * over this set — add or override under any name; components render them by
829
+ * token via `uni-icon`, never by inlining SVG.
830
+ */
831
+ var BaseIcons = {
832
+ alertCircle: "data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3e%3cpath d='M0 0h24v24H0V0z' fill='none'/%3e%3cpath d='M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z'/%3e%3c/svg%3e",
833
+ calendar: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M19 3h-1V1h-2v2H8V1H6v2H5c-1.11 0-1.99.9-1.99 2L3 19c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V8h14v11zM7 10h5v5H7z'%3E%3C/path%3E%3C/svg%3E",
834
+ checkCircle: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cg%3E%3Cpath d='M32,0A32,32,0,1,0,64,32,32,32,0,0,0,32,0Zm2.0873,41.5-5.4107,5.4106-.02.02L14.1751,32.4492l5.4306-5.4306,9.051,9.0509L46.2861,18.44l5.4305,5.4306Z'/%3E%3C/g%3E%3C/svg%3E",
835
+ chevronUp: "data:image/svg+xml,%0A%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'%3E%3Cpath d='m296-345-56-56 240-240 240 240-56 56-184-184-184 184Z'/%3E%3C/svg%3E",
836
+ chevronDown: "data:image/svg+xml,%0A%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'%3E%3Cpath d='M480-345 240-585l56-56 184 184 184-184 56 56-240 240Z'/%3E%3C/svg%3E",
837
+ chevronLeft: "data:image/svg+xml, %3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'%3E%3Cpath d='M560-240 320-480l240-240 56 56-184 184 184 184-56 56Z'/%3E%3C/svg%3E",
838
+ chevronRight: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'%3E%3Cpath d='M504-480 320-664l56-56 240 240-240 240-56-56 184-184Z'/%3E%3C/svg%3E",
839
+ xCircle: "data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3e%3cg%3e%3cpath d='M32,0A32,32,0,1,0,64,32,32,32,0,0,0,32,0ZM47.4649,42.3543l-5.4306,5.43L31.68,37.4305,21.3257,47.7848l-5.4306-5.43L26.25,32,15.8951,21.6456l5.4306-5.4305L31.68,26.5694,42.0343,16.2151l5.4306,5.4305L37.1106,32Z'/%3e%3c/g%3e%3c/svg%3e",
840
+ search: "data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 50 50'%3e%3cg%3e%3cpath d='M 21 3 C 11.601563 3 4 10.601563 4 20 C 4 29.398438 11.601563 37 21 37 C 24.355469 37 27.460938 36.015625 30.09375 34.34375 L 42.375 46.625 L 46.625 42.375 L 34.5 30.28125 C 36.679688 27.421875 38 23.878906 38 20 C 38 10.601563 30.398438 3 21 3 Z M 21 7 C 28.199219 7 34 12.800781 34 20 C 34 27.199219 28.199219 33 21 33 C 13.800781 33 8 27.199219 8 20 C 8 12.800781 13.800781 7 21 7 Z'%3e%3c/path%3e%3c/g%3e%3c/svg%3e",
841
+ close: "data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3e%3cg%3e%3cpath fill='currentColor' d='M.439,21.44a1.5,1.5,0,0,0,2.122,2.121L11.823,14.3a.25.25,0,0,1,.354,0l9.262,9.263a1.5,1.5,0,1,0,2.122-2.121L14.3,12.177a.25.25,0,0,1,0-.354l9.263-9.262A1.5,1.5,0,0,0,21.439.44L12.177,9.7a.25.25,0,0,1-.354,0L2.561.44A1.5,1.5,0,0,0,.439,2.561L9.7,11.823a.25.25,0,0,1,0,.354Z'%3e%3c/path%3e%3c/g%3e%3c/svg%3e",
842
+ spinner: "data:image/svg+xml;charset=UTF-8,%3csvg stroke='%23000' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg' %3e%3cstyle%3e .oui_spinner %7b transform-origin: center; animation: rotate_360 2s linear infinite;%7d .oui_spinner circle %7b stroke-linecap: round; animation: dash 1.5s ease-in-out infinite;%7d %40keyframes rotate_360 %7b 100%25 %7b transform: rotate(360deg);%7d %7d %40keyframes dash %7b 0%25 %7b stroke-dasharray: 0 150; stroke-dashoffset: 0;%7d 47.5%25 %7b stroke-dasharray: 42 150; stroke-dashoffset: -16;%7d 95%25, 100%25 %7b stroke-dasharray: 42 150; stroke-dashoffset: -59;%7d %7d %3c/style%3e%3cg class='oui_spinner'%3e%3ccircle cx='12' cy='12' r='9.5' fill='none' stroke-width='3'%3e%3c/circle%3e%3c/g%3e%3c/svg%3e "
843
+ };
844
+ //#endregion
801
845
  //#region src/concepts/theme/themes/base.theme.ts
802
846
  var BaseTypography = {
803
847
  "display-large": {
@@ -936,6 +980,13 @@ var BaseTypography = {
936
980
  fontSize: 16,
937
981
  lineHeight: 24
938
982
  },
983
+ stat: {
984
+ fontFamily: "Red Hat Display",
985
+ fontSize: 32,
986
+ lineHeight: 38,
987
+ fontWeight: 600,
988
+ letterSpacing: -.32
989
+ },
939
990
  tag: {
940
991
  fontFamily: "Red Hat Display",
941
992
  fontSize: 15,
@@ -995,7 +1046,107 @@ var buildComponents = (c) => ({
995
1046
  transitionSpeed: .35,
996
1047
  elevation: "md"
997
1048
  } },
998
- checkbox: { options: { size: 20 } },
1049
+ breadcrumb: { options: {
1050
+ typeface: "label",
1051
+ color: "on-background-variant",
1052
+ currentColor: "on-background",
1053
+ separatorSymbol: "chevron_right",
1054
+ gap: "xs"
1055
+ } },
1056
+ appBar: { options: {
1057
+ color: "surface",
1058
+ height: 56,
1059
+ divider: "light",
1060
+ typeface: "title-large",
1061
+ padding: "md",
1062
+ gap: "md",
1063
+ elevation: void 0
1064
+ } },
1065
+ drawer: { options: {
1066
+ color: "surface",
1067
+ width: 280,
1068
+ divider: "light",
1069
+ elevation: "menu",
1070
+ padding: "md",
1071
+ backdrop: { background: "rgba(0, 0, 0, 0.4)" }
1072
+ } },
1073
+ avatar: {
1074
+ options: {
1075
+ borderRadius: "max",
1076
+ typeface: "subtitle-2",
1077
+ fallbackSymbol: "person"
1078
+ },
1079
+ variants: {
1080
+ primary: {
1081
+ backgroundColor: c["primary-container"],
1082
+ color: c["on-primary-container"]
1083
+ },
1084
+ secondary: {
1085
+ backgroundColor: c["secondary-container"],
1086
+ color: c["on-secondary-container"]
1087
+ },
1088
+ tertiary: {
1089
+ backgroundColor: c["tertiary-container"],
1090
+ color: c["on-tertiary-container"]
1091
+ },
1092
+ quaternary: {
1093
+ backgroundColor: c["surface-variant"],
1094
+ color: c["on-surface-variant"]
1095
+ },
1096
+ warn: {
1097
+ backgroundColor: c["warn-container"],
1098
+ color: c["on-warn-container"]
1099
+ },
1100
+ success: {
1101
+ backgroundColor: c["success-container"],
1102
+ color: c["on-success-container"]
1103
+ }
1104
+ },
1105
+ sizes: {
1106
+ sm: {
1107
+ height: 24,
1108
+ width: 24,
1109
+ fontSize: 10
1110
+ },
1111
+ md: {
1112
+ height: 32,
1113
+ width: 32,
1114
+ fontSize: 13
1115
+ },
1116
+ lg: {
1117
+ height: 40,
1118
+ width: 40,
1119
+ fontSize: 16
1120
+ },
1121
+ xl: {
1122
+ height: 56,
1123
+ width: 56,
1124
+ fontSize: 22
1125
+ }
1126
+ }
1127
+ },
1128
+ avatarGroup: { options: {
1129
+ overlap: "sm",
1130
+ ringColor: "surface",
1131
+ ringWidth: 2
1132
+ } },
1133
+ searchInput: { options: {
1134
+ searchSymbol: "search",
1135
+ clearSymbol: "close",
1136
+ listColor: "primary-surface",
1137
+ listShadow: "menu",
1138
+ listBorderRadius: "xs",
1139
+ maxSuggestions: 8
1140
+ } },
1141
+ checkbox: { options: {
1142
+ size: 20,
1143
+ boxColor: "surface"
1144
+ } },
1145
+ radio: { options: {
1146
+ size: 20,
1147
+ ringColor: "outline",
1148
+ fillColor: "surface"
1149
+ } },
999
1150
  dialog: { options: {
1000
1151
  borderRadius: "lg",
1001
1152
  color: "primary-surface",
@@ -1043,6 +1194,22 @@ var buildComponents = (c) => ({
1043
1194
  focusOutline: `2px solid ${c.primary}`,
1044
1195
  focusOutlineOffset: 2
1045
1196
  } },
1197
+ textarea: { options: {
1198
+ rows: 3,
1199
+ resize: "vertical"
1200
+ } },
1201
+ tabs: { options: {
1202
+ typeface: "title-small",
1203
+ textColor: "on-surface-variant",
1204
+ activeTextColor: "primary",
1205
+ indicatorColor: "primary",
1206
+ indicatorThickness: "standard",
1207
+ divider: "light",
1208
+ gap: "sm",
1209
+ borderRadius: "none",
1210
+ padding: "md",
1211
+ activeColor: void 0
1212
+ } },
1046
1213
  multiSelectDropdown: { options: {
1047
1214
  textRole: "input",
1048
1215
  textColor: "on-primary-surface",
@@ -1054,13 +1221,16 @@ var buildComponents = (c) => ({
1054
1221
  } },
1055
1222
  badge: { options: { borderRadius: "xxs" } },
1056
1223
  button: {
1224
+ options: {
1225
+ borderRadius: "max",
1226
+ typeface: "button"
1227
+ },
1057
1228
  fixed: {
1058
1229
  position: "relative",
1059
1230
  overflow: "hidden",
1060
1231
  outline: "0",
1061
1232
  border: "0",
1062
1233
  cursor: "pointer",
1063
- fontFamily: "Euphemia, sans-serif",
1064
1234
  transition: "all 0.28s ease"
1065
1235
  },
1066
1236
  variants: {
@@ -1111,33 +1281,29 @@ var buildComponents = (c) => ({
1111
1281
  sizes: {
1112
1282
  sm: {
1113
1283
  height: 22,
1114
- borderRadius: 11,
1115
1284
  fontSize: 12,
1116
1285
  padding: "0 12px",
1117
- fontFamily: "Euphemia Bold, sans-serif",
1118
1286
  fontWeight: 600
1119
1287
  },
1120
1288
  md: {
1121
1289
  height: 26,
1122
- borderRadius: 13,
1123
1290
  fontSize: 16,
1124
1291
  padding: "0 16px"
1125
1292
  },
1126
1293
  lg: {
1127
1294
  height: 36,
1128
- borderRadius: 18,
1129
1295
  fontSize: 18,
1130
1296
  padding: "0 18px"
1131
1297
  },
1132
1298
  xl: {
1133
1299
  height: 48,
1134
- borderRadius: 24,
1135
1300
  fontSize: 24,
1136
1301
  padding: "0 22px"
1137
1302
  }
1138
1303
  }
1139
1304
  },
1140
1305
  iconButton: {
1306
+ options: { borderRadius: "max" },
1141
1307
  variants: {
1142
1308
  ghost: {
1143
1309
  backgroundColor: "transparent",
@@ -1203,23 +1369,23 @@ var buildComponents = (c) => ({
1203
1369
  fixed: { textFill: c["on-background"] },
1204
1370
  variants: {
1205
1371
  primary: {
1206
- backgroundColor: "#b3d4ea",
1372
+ backgroundColor: c["primary-container"],
1207
1373
  color: c.primary
1208
1374
  },
1209
1375
  secondary: {
1210
- backgroundColor: "#b3e7c2",
1376
+ backgroundColor: c["secondary-container"],
1211
1377
  color: c.secondary
1212
1378
  },
1213
1379
  tertiary: {
1214
- backgroundColor: "#ffe2b3",
1380
+ backgroundColor: c["tertiary-container"],
1215
1381
  color: c.tertiary
1216
1382
  },
1217
1383
  warn: {
1218
- backgroundColor: "#ffc2b3",
1384
+ backgroundColor: c["warn-container"],
1219
1385
  color: c.warn
1220
1386
  },
1221
1387
  success: {
1222
- backgroundColor: "#b3e7c2",
1388
+ backgroundColor: c["success-container"],
1223
1389
  color: c.success
1224
1390
  }
1225
1391
  },
@@ -1231,33 +1397,10 @@ var buildComponents = (c) => ({
1231
1397
  }
1232
1398
  },
1233
1399
  card: {
1400
+ options: { borderRadius: "xs" },
1234
1401
  fixed: {
1235
- borderStyle: "solid",
1236
- borderWidth: "1px",
1237
- borderRadius: "8px",
1238
- overflow: "hidden"
1239
- },
1240
- variants: {
1241
- primary: {
1242
- borderColor: c.primary,
1243
- backgroundColor: c.background
1244
- },
1245
- secondary: {
1246
- borderColor: c.secondary,
1247
- backgroundColor: c.background
1248
- },
1249
- tertiary: {
1250
- borderColor: c.tertiary,
1251
- backgroundColor: c.background
1252
- },
1253
- warn: {
1254
- borderColor: c.warn,
1255
- backgroundColor: c.background
1256
- },
1257
- success: {
1258
- borderColor: c.success,
1259
- backgroundColor: c.background
1260
- }
1402
+ overflow: "hidden",
1403
+ backgroundColor: c.background
1261
1404
  }
1262
1405
  },
1263
1406
  cardHeader: {
@@ -1328,6 +1471,34 @@ var buildComponents = (c) => ({
1328
1471
  currentPageBorder: "light",
1329
1472
  currentPageBorderRadius: "xs"
1330
1473
  } },
1474
+ stat: { options: {
1475
+ labelTypeface: "label",
1476
+ valueTypeface: "stat",
1477
+ color: "surface",
1478
+ border: "light",
1479
+ borderRadius: "xs",
1480
+ positiveColor: "success",
1481
+ negativeColor: "error",
1482
+ trendColor: "outline",
1483
+ trendAccent: "primary",
1484
+ padding: "md",
1485
+ gap: "xxs"
1486
+ } },
1487
+ slider: { options: {
1488
+ color: "primary",
1489
+ trackColor: "surface-variant",
1490
+ borderRadius: "max",
1491
+ trackHeight: 4,
1492
+ thumbSize: 16
1493
+ } },
1494
+ skeleton: { options: {
1495
+ color: "surface-variant",
1496
+ highlightColor: "surface",
1497
+ borderRadius: "xs",
1498
+ animation: "shimmer",
1499
+ duration: 1.4,
1500
+ gap: "sm"
1501
+ } },
1331
1502
  snackbar: { options: {
1332
1503
  bottomPosition: 40,
1333
1504
  transitionDelay: "0.35s",
@@ -1339,7 +1510,11 @@ var buildComponents = (c) => ({
1339
1510
  grade: 0,
1340
1511
  opticalSize: 24
1341
1512
  } },
1342
- toggle: { options: { size: 20 } },
1513
+ toggle: { options: {
1514
+ size: 20,
1515
+ trackColor: "surface-variant",
1516
+ knobColor: "surface"
1517
+ } },
1343
1518
  tooltip: { options: {
1344
1519
  border: void 0,
1345
1520
  borderRadius: "xs",
@@ -1365,7 +1540,10 @@ var createTheme = ({ id, name, colors, icons = {}, radii = BaseRadii, shadows =
1365
1540
  shadows,
1366
1541
  spacing: BaseSpacing,
1367
1542
  thicknesses: BaseThicknesses,
1368
- icons,
1543
+ icons: {
1544
+ ...BaseIcons,
1545
+ ...icons
1546
+ },
1369
1547
  components: deepMerge(buildComponents(colors), components)
1370
1548
  });
1371
1549
  /**
@@ -1379,6 +1557,7 @@ var createThemeFromPalette = (config) => {
1379
1557
  id: config.id ?? "CustomTheme",
1380
1558
  name: config.name ?? "Custom Theme",
1381
1559
  colors,
1560
+ radii: config.radii,
1382
1561
  shadows: generateShadows(colors, config.mode ?? "light"),
1383
1562
  icons: config.icons
1384
1563
  });
@@ -1571,6 +1750,7 @@ var themeExport = (exportName, displayName, colorsConst, shadowsConst, radii) =>
1571
1750
  ` borders: borders(${colorsConst}),`,
1572
1751
  ` components: components(${colorsConst}),`,
1573
1752
  ` shadows: ${shadowsConst},`,
1753
+ " icons,",
1574
1754
  ...radii ? [" radii,"] : [],
1575
1755
  "});"
1576
1756
  ].join("\n");
@@ -1625,6 +1805,7 @@ var emitThemeFile = (input) => {
1625
1805
  " type Borders,",
1626
1806
  " type Colors,",
1627
1807
  " type ComponentThemes,",
1808
+ " type Icons,",
1628
1809
  " type Shadows,",
1629
1810
  " type UniTheme,",
1630
1811
  "} from '@uni-design-system/uni-core';",
@@ -1642,6 +1823,15 @@ var emitThemeFile = (input) => {
1642
1823
  " */",
1643
1824
  "const components = (colors: Colors): ComponentThemes => ({});",
1644
1825
  "",
1826
+ "/**",
1827
+ " * Icon primitives, merged over the built-in set (close, search, spinner,",
1828
+ " * chevrons, …). Define an icon ONCE here as an inline SVG data URI — it is",
1829
+ " * masked with currentColor, so it recolors with the theme — and render it",
1830
+ " * anywhere via `<uni-icon name='…'/>`. Never inline SVG in components.",
1831
+ " * Example: logo: \"data:image/svg+xml,%3Csvg xmlns='…' viewBox='0 0 24 24'%3E…%3C/svg%3E\",",
1832
+ " */",
1833
+ "const icons: Icons = {};",
1834
+ "",
1645
1835
  ...radii ? [
1646
1836
  `/** Shape language: '${input.shape}'. */`,
1647
1837
  `const radii = {\n${recordLiteral(radii, " ")}\n};`,
@@ -1850,6 +2040,6 @@ var debounce = (callback, timeout) => {
1850
2040
  };
1851
2041
  };
1852
2042
  //#endregion
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 };
2043
+ export { BASE_PALETTE_CONFIG, BaseIcons, 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, emitDtcgTokens, 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 };
1854
2044
 
1855
2045
  //# sourceMappingURL=index.js.map