@uni-design-system/uni-core 8.4.0 → 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/CHANGELOG.md +107 -0
- package/dist/cjs/index.cjs +75 -198
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +76 -194
- package/dist/esm/index.js.map +1 -1
- package/dist/types/concepts/color/color.helper.d.ts +1 -7
- package/dist/types/concepts/color/color.helper.d.ts.map +1 -1
- package/dist/types/concepts/color/color.model.d.ts +0 -6
- package/dist/types/concepts/color/color.model.d.ts.map +1 -1
- package/dist/types/concepts/color/color.utils.d.ts +0 -7
- package/dist/types/concepts/color/color.utils.d.ts.map +1 -1
- package/dist/types/concepts/color/index.d.ts +0 -1
- package/dist/types/concepts/color/index.d.ts.map +1 -1
- package/dist/types/concepts/generation/theme-file.emitter.d.ts.map +1 -1
- package/dist/types/concepts/size/size.types.d.ts +15 -1
- package/dist/types/concepts/size/size.types.d.ts.map +1 -1
- package/dist/types/concepts/theme/spacing.spec.d.ts +2 -0
- package/dist/types/concepts/theme/spacing.spec.d.ts.map +1 -0
- package/dist/types/concepts/theme/theme.model.d.ts +13 -2
- package/dist/types/concepts/theme/theme.model.d.ts.map +1 -1
- package/dist/types/concepts/theme/themes/base.theme.d.ts +9 -2
- package/dist/types/concepts/theme/themes/base.theme.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/types/concepts/color/color.records.d.ts +0 -15
- package/dist/types/concepts/color/color.records.d.ts.map +0 -1
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,7 +985,8 @@ 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,
|
|
@@ -1916,7 +1784,7 @@ var deepMerge = (base, override) => {
|
|
|
1916
1784
|
for (const [key, value] of Object.entries(override)) out[key] = isRecord$1(value) && isRecord$1(out[key]) ? deepMerge(out[key], value) : value;
|
|
1917
1785
|
return out;
|
|
1918
1786
|
};
|
|
1919
|
-
var createTheme = ({ id, name, colors, icons = {}, radii = BaseRadii, shadows = BaseShadows, motion, typography, borders, thicknesses, components }) => ({
|
|
1787
|
+
var createTheme = ({ id, name, colors, icons = {}, radii = BaseRadii, shadows = BaseShadows, motion, typography, borders, thicknesses, spacing, components }) => ({
|
|
1920
1788
|
id,
|
|
1921
1789
|
name,
|
|
1922
1790
|
colors,
|
|
@@ -1924,7 +1792,10 @@ var createTheme = ({ id, name, colors, icons = {}, radii = BaseRadii, shadows =
|
|
|
1924
1792
|
borders: deepMerge(buildBorders(colors), borders),
|
|
1925
1793
|
radii,
|
|
1926
1794
|
shadows,
|
|
1927
|
-
spacing:
|
|
1795
|
+
spacing: {
|
|
1796
|
+
...BaseSpacing,
|
|
1797
|
+
...spacing
|
|
1798
|
+
},
|
|
1928
1799
|
motion: {
|
|
1929
1800
|
...BaseMotion,
|
|
1930
1801
|
...motion
|
|
@@ -2177,6 +2048,7 @@ var themeExport = (exportName, displayName, colorsConst, shadowsConst, radii) =>
|
|
|
2177
2048
|
` shadows: ${shadowsConst},`,
|
|
2178
2049
|
" icons,",
|
|
2179
2050
|
...radii ? [" radii,"] : [],
|
|
2051
|
+
" spacing,",
|
|
2180
2052
|
"});"
|
|
2181
2053
|
].join("\n");
|
|
2182
2054
|
/**
|
|
@@ -2232,6 +2104,7 @@ var emitThemeFile = (input) => {
|
|
|
2232
2104
|
" type ComponentThemes,",
|
|
2233
2105
|
" type Icons,",
|
|
2234
2106
|
" type Shadows,",
|
|
2107
|
+
" type Spacing,",
|
|
2235
2108
|
" type UniTheme,",
|
|
2236
2109
|
"} from '@uni-design-system/uni-core';",
|
|
2237
2110
|
"",
|
|
@@ -2268,6 +2141,15 @@ var emitThemeFile = (input) => {
|
|
|
2268
2141
|
" */",
|
|
2269
2142
|
"const icons: Icons = {};",
|
|
2270
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
|
+
"",
|
|
2271
2153
|
...radii ? [
|
|
2272
2154
|
`/** Shape language: '${input.shape}'. */`,
|
|
2273
2155
|
`const radii = {\n${recordLiteral(radii, " ")}\n};`,
|
|
@@ -2771,6 +2653,6 @@ var debounce = (callback, timeout) => {
|
|
|
2771
2653
|
};
|
|
2772
2654
|
};
|
|
2773
2655
|
//#endregion
|
|
2774
|
-
export { BASE_PALETTE_CONFIG, BaseIcons, BaseTheme, CategoryChroma,
|
|
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 };
|
|
2775
2657
|
|
|
2776
2658
|
//# sourceMappingURL=index.js.map
|