@rolster/react-components 19.12.0 → 19.12.2
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 +67 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/es/index.mjs +65 -2
- package/dist/es/index.mjs.map +1 -1
- package/dist/esm/helpers/color.d.ts +12 -0
- package/dist/esm/helpers/color.js +64 -1
- package/dist/esm/helpers/color.js.map +1 -1
- package/package.json +2 -2
package/dist/cjs/index.cjs
CHANGED
|
@@ -1253,13 +1253,18 @@ function generateThemeCSS(colors, theme) {
|
|
|
1253
1253
|
const rgb900 = rgbChannels(parseHex(colors['900']));
|
|
1254
1254
|
const rgb700 = rgbChannels(parseHex(colors['700']));
|
|
1255
1255
|
const rgb500 = rgbChannels(parseHex(colors['500']));
|
|
1256
|
+
const rgb300 = rgbChannels(parseHex(colors['300']));
|
|
1256
1257
|
const colorProps = SHADE_LABELS.map((label) => prop(`color-${label}`, colors[label]));
|
|
1257
1258
|
const gradientProps = GRADIENT_LABELS.map((label) => {
|
|
1258
1259
|
const darker = SHADE_LABELS[SHADE_LABELS.indexOf(label) - 1];
|
|
1259
1260
|
return prop(`gradient-${label}`, `linear-gradient(180deg, ${colors[label]} 15%, ${colors[darker]} 85%)`);
|
|
1260
1261
|
});
|
|
1261
1262
|
const backdropProps = BACKDROP_LABELS.map((label) => prop(`backdrop-${label}`, `rgba(${rgb900}, ${Number(label) / 1000})`));
|
|
1262
|
-
const
|
|
1263
|
+
const skeletonOpacities = Object.entries(SKELETON_OPACITY);
|
|
1264
|
+
const skeletonProps = skeletonOpacities.map(([label, opacity]) => prop(`skeleton-${label}`, `rgba(${rgb700}, ${opacity})`));
|
|
1265
|
+
// Skeleton tokens for dark surfaces, taken from the light step that mirrors
|
|
1266
|
+
// color-700 around color-500, as the foundations mixin does.
|
|
1267
|
+
const skeletonDarkProps = skeletonOpacities.map(([label, opacity]) => prop(`skeleton-dark-${label}`, `rgba(${rgb300}, ${opacity})`));
|
|
1263
1268
|
const shadowProps = [
|
|
1264
1269
|
prop('shadow-color-500', `rgba(${rgb500}, 0.24)`),
|
|
1265
1270
|
prop('shadow-500', `0px 0px 0px 3px rgba(${rgb500}, 0.24)`)
|
|
@@ -1269,6 +1274,7 @@ function generateThemeCSS(colors, theme) {
|
|
|
1269
1274
|
...gradientProps,
|
|
1270
1275
|
...backdropProps,
|
|
1271
1276
|
...skeletonProps,
|
|
1277
|
+
...skeletonDarkProps,
|
|
1272
1278
|
...shadowProps
|
|
1273
1279
|
];
|
|
1274
1280
|
}
|
|
@@ -1338,12 +1344,69 @@ function setThemeColor(baseColor, theme = 'primary') {
|
|
|
1338
1344
|
if (typeof document === 'undefined') {
|
|
1339
1345
|
return;
|
|
1340
1346
|
}
|
|
1347
|
+
resetTheme(theme);
|
|
1341
1348
|
const { properties } = generateThemePalette(baseColor, theme);
|
|
1342
1349
|
const target = document.body || document.documentElement;
|
|
1343
1350
|
properties.forEach(({ name, value }) => {
|
|
1344
1351
|
target.style.setProperty(name, value);
|
|
1345
1352
|
});
|
|
1346
1353
|
}
|
|
1354
|
+
const ALIAS_LABELS = [
|
|
1355
|
+
'900',
|
|
1356
|
+
'800',
|
|
1357
|
+
'700',
|
|
1358
|
+
'600',
|
|
1359
|
+
'500',
|
|
1360
|
+
'400',
|
|
1361
|
+
'300',
|
|
1362
|
+
'200',
|
|
1363
|
+
'100'
|
|
1364
|
+
];
|
|
1365
|
+
const SKELETON_LABELS = Object.keys(SKELETON_OPACITY);
|
|
1366
|
+
const ALIAS_TOKENS = [
|
|
1367
|
+
...SHADE_LABELS.map((label) => `color-${label}`),
|
|
1368
|
+
...ALIAS_LABELS.map((label) => `gradient-${label}`),
|
|
1369
|
+
...ALIAS_LABELS.map((label) => `backdrop-${label}`),
|
|
1370
|
+
...SKELETON_LABELS.map((label) => `skeleton-${label}`),
|
|
1371
|
+
...SKELETON_LABELS.map((label) => `skeleton-dark-${label}`),
|
|
1372
|
+
'shadow-color-500',
|
|
1373
|
+
'shadow-500'
|
|
1374
|
+
];
|
|
1375
|
+
function resetTheme(theme = 'primary') {
|
|
1376
|
+
if (typeof document === 'undefined') {
|
|
1377
|
+
return;
|
|
1378
|
+
}
|
|
1379
|
+
const target = document.body || document.documentElement;
|
|
1380
|
+
ALIAS_TOKENS.forEach((token) => {
|
|
1381
|
+
target.style.removeProperty(`--rls-${theme}-${token}`);
|
|
1382
|
+
});
|
|
1383
|
+
}
|
|
1384
|
+
function generateThemeAlias(source, theme = 'primary') {
|
|
1385
|
+
const properties = ALIAS_TOKENS.map((token) => ({
|
|
1386
|
+
name: `--rls-${theme}-${token}`,
|
|
1387
|
+
value: `var(--rls-${source}-${token})`
|
|
1388
|
+
}));
|
|
1389
|
+
return {
|
|
1390
|
+
source,
|
|
1391
|
+
theme,
|
|
1392
|
+
properties,
|
|
1393
|
+
css: properties.map((p) => `${p.name}: ${p.value};`).join('\n')
|
|
1394
|
+
};
|
|
1395
|
+
}
|
|
1396
|
+
function setThemeAlias(source, theme = 'primary') {
|
|
1397
|
+
if (typeof document === 'undefined') {
|
|
1398
|
+
return;
|
|
1399
|
+
}
|
|
1400
|
+
if (source === theme) {
|
|
1401
|
+
resetTheme(theme);
|
|
1402
|
+
return;
|
|
1403
|
+
}
|
|
1404
|
+
const { properties } = generateThemeAlias(source, theme);
|
|
1405
|
+
const target = document.body || document.documentElement;
|
|
1406
|
+
properties.forEach(({ name, value }) => {
|
|
1407
|
+
target.style.setProperty(name, value);
|
|
1408
|
+
});
|
|
1409
|
+
}
|
|
1347
1410
|
const DEFAULT_COLOR = '#1780e0';
|
|
1348
1411
|
|
|
1349
1412
|
const CONTENT_BACKGROUND = '--pvt-content-background';
|
|
@@ -5633,6 +5696,7 @@ exports.RlsTabs = RlsTabs;
|
|
|
5633
5696
|
exports.RlsTabularText = RlsTabularText;
|
|
5634
5697
|
exports.RlsToolbar = RlsToolbar;
|
|
5635
5698
|
exports.calculateImgDimension = calculateImgDimension;
|
|
5699
|
+
exports.generateThemeAlias = generateThemeAlias;
|
|
5636
5700
|
exports.generateThemePalette = generateThemePalette;
|
|
5637
5701
|
exports.getAppTheme = getAppTheme;
|
|
5638
5702
|
exports.getRemSize = getRemSize$1;
|
|
@@ -5646,12 +5710,14 @@ exports.hsvToRgb = hsvToRgb;
|
|
|
5646
5710
|
exports.normalizeHex = normalizeHex;
|
|
5647
5711
|
exports.rangeFormatTemplate = rangeFormatTemplate;
|
|
5648
5712
|
exports.renderClassStatus = renderClassStatus;
|
|
5713
|
+
exports.resetTheme = resetTheme;
|
|
5649
5714
|
exports.rgbToHex = rgbToHex;
|
|
5650
5715
|
exports.rgbToHsl = rgbToHsl;
|
|
5651
5716
|
exports.rgbToHsv = rgbToHsv;
|
|
5652
5717
|
exports.setAppTheme = setAppTheme;
|
|
5653
5718
|
exports.setDesignSystem = setDesignSystem;
|
|
5654
5719
|
exports.setErrorsI18n = setErrorsI18n;
|
|
5720
|
+
exports.setThemeAlias = setThemeAlias;
|
|
5655
5721
|
exports.setThemeColor = setThemeColor;
|
|
5656
5722
|
exports.toggleAppTheme = toggleAppTheme;
|
|
5657
5723
|
exports.useAppThemeController = useAppThemeController;
|