@uni-design-system/uni-core 8.3.1 → 9.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
@@ -59,183 +59,6 @@ var collapseFadeOut = {
59
59
  }
60
60
  };
61
61
  //#endregion
62
- //#region src/concepts/color/color.records.ts
63
- /**
64
- * @deprecated HSL saturation ranges are superseded by the perceptual OKLCH
65
- * chroma model inside `concepts/generation` (see `generateThemes`). Kept for
66
- * legacy callers of `uniColor`; removal follows the changeset major process.
67
- */
68
- var CategorySaturation = {
69
- jewel: {
70
- low: 73,
71
- high: 83
72
- },
73
- pastel: {
74
- low: 14,
75
- high: 21
76
- },
77
- earth: {
78
- low: 36,
79
- high: 41
80
- },
81
- neutral: {
82
- low: 1,
83
- high: 10
84
- },
85
- florescent: {
86
- low: 63,
87
- high: 100
88
- },
89
- shades: {
90
- low: 0,
91
- high: 0
92
- }
93
- };
94
- /**
95
- * @deprecated HSL lightness ranges are superseded by the perceptual OKLCH
96
- * tone slots inside `concepts/generation` (see `generateThemes`).
97
- */
98
- var CategoryLightness = {
99
- jewel: {
100
- low: 56,
101
- high: 76
102
- },
103
- pastel: {
104
- low: 89,
105
- high: 96
106
- },
107
- earth: {
108
- low: 36,
109
- high: 77
110
- },
111
- neutral: {
112
- low: 70,
113
- high: 99
114
- },
115
- florescent: {
116
- low: 82,
117
- high: 100
118
- },
119
- shades: {
120
- low: 0,
121
- high: 100
122
- }
123
- };
124
- var RoleHues = {
125
- primary: {
126
- low: 73,
127
- high: 83,
128
- default: 0
129
- },
130
- secondary: {
131
- low: 14,
132
- high: 21,
133
- default: 0
134
- },
135
- tertiary: {
136
- low: 36,
137
- high: 41,
138
- default: 0
139
- },
140
- inverse: {
141
- low: 63,
142
- high: 100,
143
- default: 0
144
- },
145
- ghost: {
146
- low: 0,
147
- high: 0,
148
- default: 0
149
- },
150
- warn: {
151
- low: 320,
152
- high: 20,
153
- default: 0
154
- },
155
- alert: {
156
- low: 40,
157
- high: 70,
158
- default: 60
159
- },
160
- success: {
161
- low: 90,
162
- high: 150,
163
- default: 120
164
- },
165
- info: {
166
- low: 200,
167
- high: 260,
168
- default: 240
169
- }
170
- };
171
- //#endregion
172
- //#region src/concepts/color/color.utils.ts
173
- /**
174
- * @deprecated Randomized generation is superseded by the deterministic OKLCH
175
- * engine in `concepts/generation` — same input, same theme. Seeded "surprise
176
- * me" behavior belongs in the consumer (playground), not the engine.
177
- */
178
- var randomRangeValue = ({ low, high }) => {
179
- low = Math.ceil(low);
180
- high = Math.floor(high);
181
- return Math.floor(Math.random() * (high - low + 1)) + low;
182
- };
183
- var cycle = (angle) => {
184
- if (angle > 360) return angle - 360;
185
- if (angle < 0) return angle + 360;
186
- return angle;
187
- };
188
- var getAnalogousHues = (hue) => [cycle(hue + 30), cycle(hue + 60)];
189
- var getComplimentaryHue = (hue) => cycle(hue + 180);
190
- var getTriadicHues = (hue) => [cycle(hue + 120), cycle(hue - 120)];
191
- var getSplitComplimentaryHues = (hue) => [cycle(hue + 150), cycle(hue - 150)];
192
- /**
193
- * Derive the primary/secondary/tertiary hues from a seed hue using the color
194
- * wheel relationships in {@link ColorScheme}. Pure angle math — works in any
195
- * hue space (HSL historically, OKLCH in the generation engine).
196
- */
197
- var schemeHues = (hue, scheme) => {
198
- switch (scheme) {
199
- case "monochromatic": return {
200
- primary: hue,
201
- secondary: hue,
202
- tertiary: hue
203
- };
204
- case "analogous": {
205
- const [a, b] = getAnalogousHues(hue);
206
- return {
207
- primary: hue,
208
- secondary: a,
209
- tertiary: b
210
- };
211
- }
212
- case "complimentary": {
213
- const [a] = getAnalogousHues(hue);
214
- return {
215
- primary: hue,
216
- secondary: getComplimentaryHue(hue),
217
- tertiary: a
218
- };
219
- }
220
- case "splitComplimentary": {
221
- const [a, b] = getSplitComplimentaryHues(hue);
222
- return {
223
- primary: hue,
224
- secondary: a,
225
- tertiary: b
226
- };
227
- }
228
- case "triadic": {
229
- const [a, b] = getTriadicHues(hue);
230
- return {
231
- primary: hue,
232
- secondary: a,
233
- tertiary: b
234
- };
235
- }
236
- }
237
- };
238
- //#endregion
239
62
  //#region src/concepts/color/color.helper.ts
240
63
  function HSLAToString({ hue, saturation, lightness, alpha = 1 }) {
241
64
  return `hsla(${hue}, ${saturation}%, ${lightness}%, ${alpha})`;
@@ -243,19 +66,6 @@ function HSLAToString({ hue, saturation, lightness, alpha = 1 }) {
243
66
  function RGBToString({ red, green, blue }) {
244
67
  return `rgb(${red}, ${green}, ${blue})`;
245
68
  }
246
- /**
247
- * @deprecated Random HSL generation produces non-deterministic, perceptually
248
- * uneven colors. Use the OKLCH engine (`generateThemes` in
249
- * `concepts/generation`) or `generatePalette` instead.
250
- */
251
- function uniColor({ role, category, alpha = 1 }) {
252
- return HSLAToString({
253
- hue: randomRangeValue(RoleHues[role]),
254
- saturation: randomRangeValue(CategorySaturation[category]),
255
- lightness: randomRangeValue(CategoryLightness[category]),
256
- alpha
257
- });
258
- }
259
69
  var RGBToHSL = ({ red, green, blue }) => {
260
70
  red /= 255;
261
71
  green /= 255;
@@ -339,6 +149,63 @@ var contrastRatio = (a, b) => {
339
149
  return (hi + .05) / (lo + .05);
340
150
  };
341
151
  //#endregion
152
+ //#region src/concepts/color/color.utils.ts
153
+ var cycle = (angle) => {
154
+ if (angle > 360) return angle - 360;
155
+ if (angle < 0) return angle + 360;
156
+ return angle;
157
+ };
158
+ var getAnalogousHues = (hue) => [cycle(hue + 30), cycle(hue + 60)];
159
+ var getComplimentaryHue = (hue) => cycle(hue + 180);
160
+ var getTriadicHues = (hue) => [cycle(hue + 120), cycle(hue - 120)];
161
+ var getSplitComplimentaryHues = (hue) => [cycle(hue + 150), cycle(hue - 150)];
162
+ /**
163
+ * Derive the primary/secondary/tertiary hues from a seed hue using the color
164
+ * wheel relationships in {@link ColorScheme}. Pure angle math — works in any
165
+ * hue space (HSL historically, OKLCH in the generation engine).
166
+ */
167
+ var schemeHues = (hue, scheme) => {
168
+ switch (scheme) {
169
+ case "monochromatic": return {
170
+ primary: hue,
171
+ secondary: hue,
172
+ tertiary: hue
173
+ };
174
+ case "analogous": {
175
+ const [a, b] = getAnalogousHues(hue);
176
+ return {
177
+ primary: hue,
178
+ secondary: a,
179
+ tertiary: b
180
+ };
181
+ }
182
+ case "complimentary": {
183
+ const [a] = getAnalogousHues(hue);
184
+ return {
185
+ primary: hue,
186
+ secondary: getComplimentaryHue(hue),
187
+ tertiary: a
188
+ };
189
+ }
190
+ case "splitComplimentary": {
191
+ const [a, b] = getSplitComplimentaryHues(hue);
192
+ return {
193
+ primary: hue,
194
+ secondary: a,
195
+ tertiary: b
196
+ };
197
+ }
198
+ case "triadic": {
199
+ const [a, b] = getTriadicHues(hue);
200
+ return {
201
+ primary: hue,
202
+ secondary: a,
203
+ tertiary: b
204
+ };
205
+ }
206
+ }
207
+ };
208
+ //#endregion
342
209
  //#region src/concepts/generation/oklch.helper.ts
343
210
  var clamp$1 = (value, min, max) => Math.min(max, Math.max(min, value));
344
211
  var srgbToLinear = (channel) => channel <= .04045 ? channel / 12.92 : Math.pow((channel + .055) / 1.055, 2.4);
@@ -1118,13 +985,51 @@ var BaseSpacing = {
1118
985
  sm: "8px",
1119
986
  md: "16px",
1120
987
  lg: "32px",
1121
- xl: "64px"
988
+ xl: "64px",
989
+ xxl: "128px"
1122
990
  };
1123
991
  var BaseThicknesses = {
1124
992
  thin: 1,
1125
993
  standard: 2,
1126
994
  thick: 4
1127
995
  };
996
+ /**
997
+ * Shared motion timing, named by what moves rather than by how fast:
998
+ * a small panel attached to a control snaps (`popup`), a larger free-floating
999
+ * surface settles (`panel`), content growing in place eases at both ends
1000
+ * (`reveal`), a transient message arrives and leaves under its own steam
1001
+ * (`notification`), and a control answering a pointer should feel immediate
1002
+ * (`control`).
1003
+ *
1004
+ * Fast and linear is deliberate for `popup`. It is the timing every
1005
+ * trigger-anchored panel in the library uses — dropdown, menu, multi-select
1006
+ * and the combobox-style listboxes — so a form full of them opens uniformly;
1007
+ * at 100ms an easing curve is imperceptible anyway, and linear avoids the
1008
+ * lag a slow-in curve adds to something the user is waiting on.
1009
+ */
1010
+ var BaseMotion = {
1011
+ popup: {
1012
+ duration: 100,
1013
+ easing: "linear",
1014
+ scale: .8
1015
+ },
1016
+ panel: {
1017
+ duration: 250,
1018
+ easing: "ease"
1019
+ },
1020
+ reveal: {
1021
+ duration: 350,
1022
+ easing: "ease-in-out"
1023
+ },
1024
+ notification: {
1025
+ duration: 350,
1026
+ easing: "ease-in-out"
1027
+ },
1028
+ control: {
1029
+ duration: 300,
1030
+ easing: "ease"
1031
+ }
1032
+ };
1128
1033
  var BaseRadii = {
1129
1034
  none: "none",
1130
1035
  xxs: "4px",
@@ -1168,7 +1073,7 @@ var buildComponents = (c) => ({
1168
1073
  alert: { options: {
1169
1074
  topPosition: 40,
1170
1075
  borderRadius: "sm",
1171
- transitionSpeed: .35,
1076
+ motion: "notification",
1172
1077
  elevation: "md"
1173
1078
  } },
1174
1079
  breadcrumb: { options: {
@@ -1274,7 +1179,7 @@ var buildComponents = (c) => ({
1274
1179
  size: 20,
1275
1180
  ringColor: "outline",
1276
1181
  fillColor: "surface",
1277
- transitionSpeed: .3
1182
+ motion: "control"
1278
1183
  } },
1279
1184
  dialog: { options: {
1280
1185
  borderRadius: "lg",
@@ -1311,7 +1216,8 @@ var buildComponents = (c) => ({
1311
1216
  border: "none",
1312
1217
  borderRadius: "xxs",
1313
1218
  color: "primary-surface",
1314
- shadow: "menu"
1219
+ shadow: "menu",
1220
+ motion: "popup"
1315
1221
  } },
1316
1222
  menu: { options: {
1317
1223
  minWidth: 184,
@@ -1334,7 +1240,7 @@ var buildComponents = (c) => ({
1334
1240
  textColor: void 0,
1335
1241
  hoverColor: "primary-container",
1336
1242
  activeSymbol: "check",
1337
- transitionSpeed: .35
1243
+ motion: "control"
1338
1244
  },
1339
1245
  variants: { warn: {
1340
1246
  color: c.warn,
@@ -1358,9 +1264,10 @@ var buildComponents = (c) => ({
1358
1264
  headerTypeface: "title-small",
1359
1265
  tooltipPadding: "4px 8px",
1360
1266
  tooltipOpenDelay: 500,
1361
- tooltipCloseDelay: 150
1267
+ tooltipCloseDelay: 150,
1268
+ motion: "panel"
1362
1269
  } },
1363
- expand: { options: { transitionSpeed: .35 } },
1270
+ expand: { options: { motion: "reveal" } },
1364
1271
  footer: { options: {
1365
1272
  height: 52,
1366
1273
  color: "primary",
@@ -1821,11 +1728,13 @@ var buildComponents = (c) => ({
1821
1728
  borderRadius: "xs",
1822
1729
  animation: "shimmer",
1823
1730
  duration: 1.4,
1731
+ direction: "ltr",
1732
+ highlightWidth: 40,
1824
1733
  gap: "sm"
1825
1734
  } },
1826
1735
  snackbar: { options: {
1827
1736
  bottomPosition: 40,
1828
- transitionDelay: "0.35s",
1737
+ motion: "notification",
1829
1738
  autoCloseDelay: 35e3
1830
1739
  } },
1831
1740
  symbol: { options: {
@@ -1861,7 +1770,7 @@ var buildComponents = (c) => ({
1861
1770
  spotlightPadding: 6,
1862
1771
  spotlightRadius: "xs",
1863
1772
  ringWidth: 2,
1864
- transitionMs: 250
1773
+ motion: "panel"
1865
1774
  } },
1866
1775
  tour: { options: {
1867
1776
  progressStyle: "dots",
@@ -1875,7 +1784,7 @@ var deepMerge = (base, override) => {
1875
1784
  for (const [key, value] of Object.entries(override)) out[key] = isRecord$1(value) && isRecord$1(out[key]) ? deepMerge(out[key], value) : value;
1876
1785
  return out;
1877
1786
  };
1878
- var createTheme = ({ id, name, colors, icons = {}, radii = BaseRadii, shadows = BaseShadows, typography, borders, thicknesses, components }) => ({
1787
+ var createTheme = ({ id, name, colors, icons = {}, radii = BaseRadii, shadows = BaseShadows, motion, typography, borders, thicknesses, spacing, components }) => ({
1879
1788
  id,
1880
1789
  name,
1881
1790
  colors,
@@ -1883,7 +1792,14 @@ var createTheme = ({ id, name, colors, icons = {}, radii = BaseRadii, shadows =
1883
1792
  borders: deepMerge(buildBorders(colors), borders),
1884
1793
  radii,
1885
1794
  shadows,
1886
- spacing: BaseSpacing,
1795
+ spacing: {
1796
+ ...BaseSpacing,
1797
+ ...spacing
1798
+ },
1799
+ motion: {
1800
+ ...BaseMotion,
1801
+ ...motion
1802
+ },
1887
1803
  thicknesses: {
1888
1804
  ...BaseThicknesses,
1889
1805
  ...thicknesses
@@ -2132,6 +2048,7 @@ var themeExport = (exportName, displayName, colorsConst, shadowsConst, radii) =>
2132
2048
  ` shadows: ${shadowsConst},`,
2133
2049
  " icons,",
2134
2050
  ...radii ? [" radii,"] : [],
2051
+ " spacing,",
2135
2052
  "});"
2136
2053
  ].join("\n");
2137
2054
  /**
@@ -2187,6 +2104,7 @@ var emitThemeFile = (input) => {
2187
2104
  " type ComponentThemes,",
2188
2105
  " type Icons,",
2189
2106
  " type Shadows,",
2107
+ " type Spacing,",
2190
2108
  " type UniTheme,",
2191
2109
  "} from '@uni-design-system/uni-core';",
2192
2110
  "",
@@ -2223,6 +2141,15 @@ var emitThemeFile = (input) => {
2223
2141
  " */",
2224
2142
  "const icons: Icons = {};",
2225
2143
  "",
2144
+ "/**",
2145
+ " * Spacing steps, merged over the base scale",
2146
+ " * (none: 0, xxs: 2px, xs: 4px, sm: 8px, md: 16px, lg: 32px, xl: 64px, xxl: 128px).",
2147
+ " * Restate a named step to retune the rhythm, and add your own names for the",
2148
+ " * gaps your design actually uses — every extra key is then a valid `padding`,",
2149
+ " * `gap` or `marginInline` value: `<div stack-layout gap='tight'>`.",
2150
+ " */",
2151
+ "const spacing: Spacing = {};",
2152
+ "",
2226
2153
  ...radii ? [
2227
2154
  `/** Shape language: '${input.shape}'. */`,
2228
2155
  `const radii = {\n${recordLiteral(radii, " ")}\n};`,
@@ -2726,6 +2653,6 @@ var debounce = (callback, timeout) => {
2726
2653
  };
2727
2654
  };
2728
2655
  //#endregion
2729
- export { BASE_PALETTE_CONFIG, BaseIcons, BaseTheme, CategoryChroma, CategoryLightness, CategorySaturation, DarkTheme, DefaultThemeId, EXPAND_DEFAULT_SPEED, EXPAND_MAX_DURATION, EXPAND_MIN_DURATION, EXPAND_REFERENCE_HEIGHT, FontWeightMap, HOVER_OR_KEYBOARD_FOCUS, HSLAToString, HSLToHex, HSLToRGB, LightTheme, REQUIRED_COLOR_TOKENS, REQUIRED_RADII_SIZES, REQUIRED_SHADOWS, REQUIRED_SPACING_SIZES, REQUIRED_TEXT_ROLES, REQUIRED_THICKNESSES, RGBToHSL, RGBToString, RoleHues, ShadowCssMap, ShadowMap, ShapeRadii, UniThemes, Z_INDEX, assertTheme, classifyScheme, collapseFadeOut, contrastRatio, createTheme, createThemeFromPalette, cycle, darkColors, debounce, dehydrateTheme, emitDtcgTokens, emitThemeFile, expandDuration, expandFadeIn, fadeIn, fadeOut, formatThemeIssues, generateColors, generatePalette, generateShadows, generateThemes, generateUniThemes, getAnalogousHues, getComplimentaryHue, getDeviceOrientation, getDeviceSize, getSplitComplimentaryHues, getTriadicHues, getValue, gradient, hexToHSL, hexToOklch, hexToRgb, hydrateTheme, inferCategory, isUniTheme, lightColors, oklchToHex, parseTheme, randomRangeValue, relativeLuminance, removeInputPlatformStyling, rgbToHex, schemeHues, summarizeContrast, svgToIconUri, toTypeface, toTypefaces, uniColor };
2656
+ export { BASE_PALETTE_CONFIG, BaseIcons, BaseTheme, CategoryChroma, DarkTheme, DefaultThemeId, EXPAND_DEFAULT_SPEED, EXPAND_MAX_DURATION, EXPAND_MIN_DURATION, EXPAND_REFERENCE_HEIGHT, FontWeightMap, HOVER_OR_KEYBOARD_FOCUS, HSLAToString, HSLToHex, HSLToRGB, LightTheme, REQUIRED_COLOR_TOKENS, REQUIRED_RADII_SIZES, REQUIRED_SHADOWS, REQUIRED_SPACING_SIZES, REQUIRED_TEXT_ROLES, REQUIRED_THICKNESSES, RGBToHSL, RGBToString, ShadowCssMap, ShadowMap, ShapeRadii, UniThemes, Z_INDEX, assertTheme, classifyScheme, collapseFadeOut, contrastRatio, createTheme, createThemeFromPalette, cycle, darkColors, debounce, dehydrateTheme, emitDtcgTokens, emitThemeFile, expandDuration, expandFadeIn, fadeIn, fadeOut, formatThemeIssues, generateColors, generatePalette, generateShadows, generateThemes, generateUniThemes, getAnalogousHues, getComplimentaryHue, getDeviceOrientation, getDeviceSize, getSplitComplimentaryHues, getTriadicHues, getValue, gradient, hexToHSL, hexToOklch, hexToRgb, hydrateTheme, inferCategory, isUniTheme, lightColors, oklchToHex, parseTheme, relativeLuminance, removeInputPlatformStyling, rgbToHex, schemeHues, summarizeContrast, svgToIconUri, toTypeface, toTypefaces };
2730
2657
 
2731
2658
  //# sourceMappingURL=index.js.map