@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.
@@ -762,6 +762,28 @@ var Z_INDEX = {
762
762
  overlay: 1080
763
763
  };
764
764
  //#endregion
765
+ //#region src/concepts/generation/dtcg.emitter.ts
766
+ var dimensionEntries = (record) => Object.fromEntries(Object.entries(record ?? {}).filter(([, value]) => value !== void 0 && value !== "none").map(([key, value]) => [key, {
767
+ $value: String(value),
768
+ $type: "dimension"
769
+ }]));
770
+ /**
771
+ * Render one theme mode's tokens as W3C DTCG JSON for external pipelines
772
+ * (Style Dictionary etc.). Token names are exactly Uni's `ColorToken` strings —
773
+ * one vocabulary everywhere. The native `UniTheme` object remains the primary,
774
+ * lossless output; this is the interop layer.
775
+ */
776
+ var emitDtcgTokens = (input) => ({
777
+ color: Object.fromEntries(Object.entries(input.colors).filter(([, value]) => value !== void 0).map(([key, value]) => [key, {
778
+ $value: value,
779
+ $type: "color"
780
+ }])),
781
+ size: {
782
+ radius: dimensionEntries(input.radii),
783
+ spacing: dimensionEntries(input.spacing)
784
+ }
785
+ });
786
+ //#endregion
765
787
  //#region src/concepts/generation/shadow.generator.ts
766
788
  var rgba = (hex, alpha) => {
767
789
  const { red, green, blue } = hexToRgb(hex);
@@ -799,6 +821,28 @@ var generateShadows = (colors, mode = "light") => {
799
821
  };
800
822
  };
801
823
  //#endregion
824
+ //#region src/concepts/iconography/icon.records.ts
825
+ /**
826
+ * Default icon primitives shipped with every theme. Each icon is an inline
827
+ * SVG data URI rendered as a CSS mask over `currentColor`, so icons recolor
828
+ * with the theme automatically. `createTheme` merges a theme's own `icons`
829
+ * over this set — add or override under any name; components render them by
830
+ * token via `uni-icon`, never by inlining SVG.
831
+ */
832
+ var BaseIcons = {
833
+ 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",
834
+ 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",
835
+ 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",
836
+ 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",
837
+ 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",
838
+ 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",
839
+ 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",
840
+ 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",
841
+ 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",
842
+ 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",
843
+ 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 "
844
+ };
845
+ //#endregion
802
846
  //#region src/concepts/theme/themes/base.theme.ts
803
847
  var BaseTypography = {
804
848
  "display-large": {
@@ -937,6 +981,13 @@ var BaseTypography = {
937
981
  fontSize: 16,
938
982
  lineHeight: 24
939
983
  },
984
+ stat: {
985
+ fontFamily: "Red Hat Display",
986
+ fontSize: 32,
987
+ lineHeight: 38,
988
+ fontWeight: 600,
989
+ letterSpacing: -.32
990
+ },
940
991
  tag: {
941
992
  fontFamily: "Red Hat Display",
942
993
  fontSize: 15,
@@ -996,7 +1047,107 @@ var buildComponents = (c) => ({
996
1047
  transitionSpeed: .35,
997
1048
  elevation: "md"
998
1049
  } },
999
- checkbox: { options: { size: 20 } },
1050
+ breadcrumb: { options: {
1051
+ typeface: "label",
1052
+ color: "on-background-variant",
1053
+ currentColor: "on-background",
1054
+ separatorSymbol: "chevron_right",
1055
+ gap: "xs"
1056
+ } },
1057
+ appBar: { options: {
1058
+ color: "surface",
1059
+ height: 56,
1060
+ divider: "light",
1061
+ typeface: "title-large",
1062
+ padding: "md",
1063
+ gap: "md",
1064
+ elevation: void 0
1065
+ } },
1066
+ drawer: { options: {
1067
+ color: "surface",
1068
+ width: 280,
1069
+ divider: "light",
1070
+ elevation: "menu",
1071
+ padding: "md",
1072
+ backdrop: { background: "rgba(0, 0, 0, 0.4)" }
1073
+ } },
1074
+ avatar: {
1075
+ options: {
1076
+ borderRadius: "max",
1077
+ typeface: "subtitle-2",
1078
+ fallbackSymbol: "person"
1079
+ },
1080
+ variants: {
1081
+ primary: {
1082
+ backgroundColor: c["primary-container"],
1083
+ color: c["on-primary-container"]
1084
+ },
1085
+ secondary: {
1086
+ backgroundColor: c["secondary-container"],
1087
+ color: c["on-secondary-container"]
1088
+ },
1089
+ tertiary: {
1090
+ backgroundColor: c["tertiary-container"],
1091
+ color: c["on-tertiary-container"]
1092
+ },
1093
+ quaternary: {
1094
+ backgroundColor: c["surface-variant"],
1095
+ color: c["on-surface-variant"]
1096
+ },
1097
+ warn: {
1098
+ backgroundColor: c["warn-container"],
1099
+ color: c["on-warn-container"]
1100
+ },
1101
+ success: {
1102
+ backgroundColor: c["success-container"],
1103
+ color: c["on-success-container"]
1104
+ }
1105
+ },
1106
+ sizes: {
1107
+ sm: {
1108
+ height: 24,
1109
+ width: 24,
1110
+ fontSize: 10
1111
+ },
1112
+ md: {
1113
+ height: 32,
1114
+ width: 32,
1115
+ fontSize: 13
1116
+ },
1117
+ lg: {
1118
+ height: 40,
1119
+ width: 40,
1120
+ fontSize: 16
1121
+ },
1122
+ xl: {
1123
+ height: 56,
1124
+ width: 56,
1125
+ fontSize: 22
1126
+ }
1127
+ }
1128
+ },
1129
+ avatarGroup: { options: {
1130
+ overlap: "sm",
1131
+ ringColor: "surface",
1132
+ ringWidth: 2
1133
+ } },
1134
+ searchInput: { options: {
1135
+ searchSymbol: "search",
1136
+ clearSymbol: "close",
1137
+ listColor: "primary-surface",
1138
+ listShadow: "menu",
1139
+ listBorderRadius: "xs",
1140
+ maxSuggestions: 8
1141
+ } },
1142
+ checkbox: { options: {
1143
+ size: 20,
1144
+ boxColor: "surface"
1145
+ } },
1146
+ radio: { options: {
1147
+ size: 20,
1148
+ ringColor: "outline",
1149
+ fillColor: "surface"
1150
+ } },
1000
1151
  dialog: { options: {
1001
1152
  borderRadius: "lg",
1002
1153
  color: "primary-surface",
@@ -1044,6 +1195,22 @@ var buildComponents = (c) => ({
1044
1195
  focusOutline: `2px solid ${c.primary}`,
1045
1196
  focusOutlineOffset: 2
1046
1197
  } },
1198
+ textarea: { options: {
1199
+ rows: 3,
1200
+ resize: "vertical"
1201
+ } },
1202
+ tabs: { options: {
1203
+ typeface: "title-small",
1204
+ textColor: "on-surface-variant",
1205
+ activeTextColor: "primary",
1206
+ indicatorColor: "primary",
1207
+ indicatorThickness: "standard",
1208
+ divider: "light",
1209
+ gap: "sm",
1210
+ borderRadius: "none",
1211
+ padding: "md",
1212
+ activeColor: void 0
1213
+ } },
1047
1214
  multiSelectDropdown: { options: {
1048
1215
  textRole: "input",
1049
1216
  textColor: "on-primary-surface",
@@ -1055,13 +1222,16 @@ var buildComponents = (c) => ({
1055
1222
  } },
1056
1223
  badge: { options: { borderRadius: "xxs" } },
1057
1224
  button: {
1225
+ options: {
1226
+ borderRadius: "max",
1227
+ typeface: "button"
1228
+ },
1058
1229
  fixed: {
1059
1230
  position: "relative",
1060
1231
  overflow: "hidden",
1061
1232
  outline: "0",
1062
1233
  border: "0",
1063
1234
  cursor: "pointer",
1064
- fontFamily: "Euphemia, sans-serif",
1065
1235
  transition: "all 0.28s ease"
1066
1236
  },
1067
1237
  variants: {
@@ -1112,33 +1282,29 @@ var buildComponents = (c) => ({
1112
1282
  sizes: {
1113
1283
  sm: {
1114
1284
  height: 22,
1115
- borderRadius: 11,
1116
1285
  fontSize: 12,
1117
1286
  padding: "0 12px",
1118
- fontFamily: "Euphemia Bold, sans-serif",
1119
1287
  fontWeight: 600
1120
1288
  },
1121
1289
  md: {
1122
1290
  height: 26,
1123
- borderRadius: 13,
1124
1291
  fontSize: 16,
1125
1292
  padding: "0 16px"
1126
1293
  },
1127
1294
  lg: {
1128
1295
  height: 36,
1129
- borderRadius: 18,
1130
1296
  fontSize: 18,
1131
1297
  padding: "0 18px"
1132
1298
  },
1133
1299
  xl: {
1134
1300
  height: 48,
1135
- borderRadius: 24,
1136
1301
  fontSize: 24,
1137
1302
  padding: "0 22px"
1138
1303
  }
1139
1304
  }
1140
1305
  },
1141
1306
  iconButton: {
1307
+ options: { borderRadius: "max" },
1142
1308
  variants: {
1143
1309
  ghost: {
1144
1310
  backgroundColor: "transparent",
@@ -1204,23 +1370,23 @@ var buildComponents = (c) => ({
1204
1370
  fixed: { textFill: c["on-background"] },
1205
1371
  variants: {
1206
1372
  primary: {
1207
- backgroundColor: "#b3d4ea",
1373
+ backgroundColor: c["primary-container"],
1208
1374
  color: c.primary
1209
1375
  },
1210
1376
  secondary: {
1211
- backgroundColor: "#b3e7c2",
1377
+ backgroundColor: c["secondary-container"],
1212
1378
  color: c.secondary
1213
1379
  },
1214
1380
  tertiary: {
1215
- backgroundColor: "#ffe2b3",
1381
+ backgroundColor: c["tertiary-container"],
1216
1382
  color: c.tertiary
1217
1383
  },
1218
1384
  warn: {
1219
- backgroundColor: "#ffc2b3",
1385
+ backgroundColor: c["warn-container"],
1220
1386
  color: c.warn
1221
1387
  },
1222
1388
  success: {
1223
- backgroundColor: "#b3e7c2",
1389
+ backgroundColor: c["success-container"],
1224
1390
  color: c.success
1225
1391
  }
1226
1392
  },
@@ -1232,33 +1398,10 @@ var buildComponents = (c) => ({
1232
1398
  }
1233
1399
  },
1234
1400
  card: {
1401
+ options: { borderRadius: "xs" },
1235
1402
  fixed: {
1236
- borderStyle: "solid",
1237
- borderWidth: "1px",
1238
- borderRadius: "8px",
1239
- overflow: "hidden"
1240
- },
1241
- variants: {
1242
- primary: {
1243
- borderColor: c.primary,
1244
- backgroundColor: c.background
1245
- },
1246
- secondary: {
1247
- borderColor: c.secondary,
1248
- backgroundColor: c.background
1249
- },
1250
- tertiary: {
1251
- borderColor: c.tertiary,
1252
- backgroundColor: c.background
1253
- },
1254
- warn: {
1255
- borderColor: c.warn,
1256
- backgroundColor: c.background
1257
- },
1258
- success: {
1259
- borderColor: c.success,
1260
- backgroundColor: c.background
1261
- }
1403
+ overflow: "hidden",
1404
+ backgroundColor: c.background
1262
1405
  }
1263
1406
  },
1264
1407
  cardHeader: {
@@ -1329,6 +1472,34 @@ var buildComponents = (c) => ({
1329
1472
  currentPageBorder: "light",
1330
1473
  currentPageBorderRadius: "xs"
1331
1474
  } },
1475
+ stat: { options: {
1476
+ labelTypeface: "label",
1477
+ valueTypeface: "stat",
1478
+ color: "surface",
1479
+ border: "light",
1480
+ borderRadius: "xs",
1481
+ positiveColor: "success",
1482
+ negativeColor: "error",
1483
+ trendColor: "outline",
1484
+ trendAccent: "primary",
1485
+ padding: "md",
1486
+ gap: "xxs"
1487
+ } },
1488
+ slider: { options: {
1489
+ color: "primary",
1490
+ trackColor: "surface-variant",
1491
+ borderRadius: "max",
1492
+ trackHeight: 4,
1493
+ thumbSize: 16
1494
+ } },
1495
+ skeleton: { options: {
1496
+ color: "surface-variant",
1497
+ highlightColor: "surface",
1498
+ borderRadius: "xs",
1499
+ animation: "shimmer",
1500
+ duration: 1.4,
1501
+ gap: "sm"
1502
+ } },
1332
1503
  snackbar: { options: {
1333
1504
  bottomPosition: 40,
1334
1505
  transitionDelay: "0.35s",
@@ -1340,7 +1511,11 @@ var buildComponents = (c) => ({
1340
1511
  grade: 0,
1341
1512
  opticalSize: 24
1342
1513
  } },
1343
- toggle: { options: { size: 20 } },
1514
+ toggle: { options: {
1515
+ size: 20,
1516
+ trackColor: "surface-variant",
1517
+ knobColor: "surface"
1518
+ } },
1344
1519
  tooltip: { options: {
1345
1520
  border: void 0,
1346
1521
  borderRadius: "xs",
@@ -1366,7 +1541,10 @@ var createTheme = ({ id, name, colors, icons = {}, radii = BaseRadii, shadows =
1366
1541
  shadows,
1367
1542
  spacing: BaseSpacing,
1368
1543
  thicknesses: BaseThicknesses,
1369
- icons,
1544
+ icons: {
1545
+ ...BaseIcons,
1546
+ ...icons
1547
+ },
1370
1548
  components: deepMerge(buildComponents(colors), components)
1371
1549
  });
1372
1550
  /**
@@ -1380,6 +1558,7 @@ var createThemeFromPalette = (config) => {
1380
1558
  id: config.id ?? "CustomTheme",
1381
1559
  name: config.name ?? "Custom Theme",
1382
1560
  colors,
1561
+ radii: config.radii,
1383
1562
  shadows: generateShadows(colors, config.mode ?? "light"),
1384
1563
  icons: config.icons
1385
1564
  });
@@ -1572,6 +1751,7 @@ var themeExport = (exportName, displayName, colorsConst, shadowsConst, radii) =>
1572
1751
  ` borders: borders(${colorsConst}),`,
1573
1752
  ` components: components(${colorsConst}),`,
1574
1753
  ` shadows: ${shadowsConst},`,
1754
+ " icons,",
1575
1755
  ...radii ? [" radii,"] : [],
1576
1756
  "});"
1577
1757
  ].join("\n");
@@ -1626,6 +1806,7 @@ var emitThemeFile = (input) => {
1626
1806
  " type Borders,",
1627
1807
  " type Colors,",
1628
1808
  " type ComponentThemes,",
1809
+ " type Icons,",
1629
1810
  " type Shadows,",
1630
1811
  " type UniTheme,",
1631
1812
  "} from '@uni-design-system/uni-core';",
@@ -1643,6 +1824,15 @@ var emitThemeFile = (input) => {
1643
1824
  " */",
1644
1825
  "const components = (colors: Colors): ComponentThemes => ({});",
1645
1826
  "",
1827
+ "/**",
1828
+ " * Icon primitives, merged over the built-in set (close, search, spinner,",
1829
+ " * chevrons, …). Define an icon ONCE here as an inline SVG data URI — it is",
1830
+ " * masked with currentColor, so it recolors with the theme — and render it",
1831
+ " * anywhere via `<uni-icon name='…'/>`. Never inline SVG in components.",
1832
+ " * Example: logo: \"data:image/svg+xml,%3Csvg xmlns='…' viewBox='0 0 24 24'%3E…%3C/svg%3E\",",
1833
+ " */",
1834
+ "const icons: Icons = {};",
1835
+ "",
1646
1836
  ...radii ? [
1647
1837
  `/** Shape language: '${input.shape}'. */`,
1648
1838
  `const radii = {\n${recordLiteral(radii, " ")}\n};`,
@@ -1852,6 +2042,7 @@ var debounce = (callback, timeout) => {
1852
2042
  };
1853
2043
  //#endregion
1854
2044
  exports.BASE_PALETTE_CONFIG = BASE_PALETTE_CONFIG;
2045
+ exports.BaseIcons = BaseIcons;
1855
2046
  exports.BaseTheme = BaseTheme;
1856
2047
  exports.CategoryChroma = CategoryChroma;
1857
2048
  exports.CategoryLightness = CategoryLightness;
@@ -1879,6 +2070,7 @@ exports.createThemeFromPalette = createThemeFromPalette;
1879
2070
  exports.cycle = cycle;
1880
2071
  exports.darkColors = darkColors;
1881
2072
  exports.debounce = debounce;
2073
+ exports.emitDtcgTokens = emitDtcgTokens;
1882
2074
  exports.emitThemeFile = emitThemeFile;
1883
2075
  exports.expandFadeIn = expandFadeIn;
1884
2076
  exports.fadeIn = fadeIn;