@aleph-alpha/ui-library 3.3.0 → 5.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/config.js
CHANGED
|
@@ -691,6 +691,21 @@ export const presetUiLibraryTheme = (theme, options = {}) => {
|
|
|
691
691
|
}))();
|
|
692
692
|
};
|
|
693
693
|
|
|
694
|
+
const toAccessibleDarkSelector = (selector) =>
|
|
695
|
+
selector
|
|
696
|
+
.split(',')
|
|
697
|
+
.map((part) => {
|
|
698
|
+
const trimmed = part.trim();
|
|
699
|
+
if (trimmed === 'html.accessible-theme') {
|
|
700
|
+
return 'html.dark.accessible-theme';
|
|
701
|
+
}
|
|
702
|
+
if (trimmed === '.accessible-theme') {
|
|
703
|
+
return 'html.dark .accessible-theme';
|
|
704
|
+
}
|
|
705
|
+
return `${trimmed}.dark`;
|
|
706
|
+
})
|
|
707
|
+
.join(', ');
|
|
708
|
+
|
|
694
709
|
export const presetUiLibraryThemeFromTokens = (options = {}) => {
|
|
695
710
|
const {
|
|
696
711
|
theme,
|
|
@@ -740,7 +755,7 @@ export const presetUiLibraryThemeFromTokens = (options = {}) => {
|
|
|
740
755
|
? presetUiLibraryTheme(buildTheme({ themeMode: 'accessible' }), {
|
|
741
756
|
...presetOptions,
|
|
742
757
|
rootSelector: accessibleSelector,
|
|
743
|
-
darkSelector:
|
|
758
|
+
darkSelector: toAccessibleDarkSelector(accessibleSelector),
|
|
744
759
|
})
|
|
745
760
|
: null;
|
|
746
761
|
|
|
@@ -1093,17 +1108,6 @@ const fontWeightMap = {
|
|
|
1093
1108
|
/** Design-tool sizes are px; rem token values resolve against a 16px base. */
|
|
1094
1109
|
const ROOT_FONT_SIZE_PX = 16;
|
|
1095
1110
|
|
|
1096
|
-
const formatPx = (value) => {
|
|
1097
|
-
const rounded = Math.round(value * 10000) / 10000;
|
|
1098
|
-
return `${rounded}px`;
|
|
1099
|
-
};
|
|
1100
|
-
|
|
1101
|
-
const numericDesignPxToPx = (raw) => {
|
|
1102
|
-
const n = typeof raw === 'number' ? raw : parseFloat(String(raw).trim());
|
|
1103
|
-
if (!Number.isFinite(n)) return null;
|
|
1104
|
-
return formatPx(n);
|
|
1105
|
-
};
|
|
1106
|
-
|
|
1107
1111
|
const numericDesignPxToRem = (raw) => {
|
|
1108
1112
|
const n = typeof raw === 'number' ? raw : parseFloat(String(raw).trim());
|
|
1109
1113
|
if (!Number.isFinite(n)) return null;
|
|
@@ -1112,28 +1116,23 @@ const numericDesignPxToRem = (raw) => {
|
|
|
1112
1116
|
return `${rounded}rem`;
|
|
1113
1117
|
};
|
|
1114
1118
|
|
|
1115
|
-
const remToPx = (raw) => {
|
|
1116
|
-
const n = parseFloat(String(raw).trim());
|
|
1117
|
-
if (!Number.isFinite(n)) return null;
|
|
1118
|
-
return formatPx(n * ROOT_FONT_SIZE_PX);
|
|
1119
|
-
};
|
|
1120
|
-
|
|
1121
1119
|
/**
|
|
1122
|
-
* Token Studio may export dimensions as strings; font-size output is
|
|
1120
|
+
* Token Studio may export dimensions as strings; font-size output is rem so text
|
|
1121
|
+
* responds to the root font size (`rootFontSize` in ui-library config).
|
|
1123
1122
|
* @param {string | number | null | undefined} value Raw token font-size value.
|
|
1124
1123
|
* @returns {string | number | null | undefined} CSS-ready font-size value.
|
|
1125
1124
|
*/
|
|
1126
1125
|
const normalizeFontSizeForCss = (value) => {
|
|
1127
1126
|
if (value == null) return value;
|
|
1128
1127
|
if (typeof value === 'number' && Number.isFinite(value))
|
|
1129
|
-
return
|
|
1128
|
+
return numericDesignPxToRem(value) ?? value;
|
|
1130
1129
|
if (typeof value === 'string') {
|
|
1131
1130
|
const t = value.trim();
|
|
1132
1131
|
if (/^(calc|var|--)/i.test(t)) return t;
|
|
1133
|
-
if (/^-?\d+(\.\d+)?rem$/i.test(t)) return
|
|
1134
|
-
if (/^-?\d+(\.\d+)?px$/i.test(t)) return t;
|
|
1132
|
+
if (/^-?\d+(\.\d+)?rem$/i.test(t)) return t;
|
|
1133
|
+
if (/^-?\d+(\.\d+)?px$/i.test(t)) return numericDesignPxToRem(t) ?? t;
|
|
1135
1134
|
if (/[a-z%]/i.test(t)) return t;
|
|
1136
|
-
if (/^\d+(\.\d+)?$/.test(t)) return
|
|
1135
|
+
if (/^\d+(\.\d+)?$/.test(t)) return numericDesignPxToRem(t) ?? t;
|
|
1137
1136
|
}
|
|
1138
1137
|
return value;
|
|
1139
1138
|
};
|
package/dist/system/lib.js
CHANGED
|
@@ -54436,7 +54436,7 @@ const PT = /* @__PURE__ */ _({
|
|
|
54436
54436
|
const a = e, o = t, n = he(a, "class"), r = me(n, o);
|
|
54437
54437
|
return (s, d) => (h(), b(l(XZ), q({ "data-slot": "switch" }, l(r), {
|
|
54438
54438
|
class: l(D)(
|
|
54439
|
-
"peer data-[state=checked]:bg-background-accent-default data-[state=unchecked]:bg-
|
|
54439
|
+
"peer data-[state=checked]:bg-background-accent-default data-[state=unchecked]:bg-background-surface-muted-strong focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 p-0.5 h-5 w-9",
|
|
54440
54440
|
a.class
|
|
54441
54441
|
)
|
|
54442
54442
|
}), {
|
|
@@ -54445,7 +54445,7 @@ const PT = /* @__PURE__ */ _({
|
|
|
54445
54445
|
"data-slot": "switch-thumb",
|
|
54446
54446
|
class: F(
|
|
54447
54447
|
l(D)(
|
|
54448
|
-
"data-[state=checked]:bg-background-accent-soft data-[state=unchecked]:bg-background dark:data-[state=unchecked]:bg-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0"
|
|
54448
|
+
"data-[state=checked]:bg-background-accent-soft data-[state=unchecked]:bg-background-surface-secondary dark:data-[state=unchecked]:bg-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0"
|
|
54449
54449
|
)
|
|
54450
54450
|
)
|
|
54451
54451
|
}, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aleph-alpha/ui-library",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/system/lib.js",
|
|
@@ -81,9 +81,9 @@
|
|
|
81
81
|
"vue-router": "4.6.4",
|
|
82
82
|
"vue-tsc": "^2.2.12",
|
|
83
83
|
"wait-on": "9.0.3",
|
|
84
|
-
"@aleph-alpha/eslint-config-frontend": "0.7.0",
|
|
85
84
|
"@aleph-alpha/prettier-config-frontend": "2.1.0",
|
|
86
|
-
"@aleph-alpha/tsconfig-frontend": "0.7.0"
|
|
85
|
+
"@aleph-alpha/tsconfig-frontend": "0.7.0",
|
|
86
|
+
"@aleph-alpha/eslint-config-frontend": "0.7.0"
|
|
87
87
|
},
|
|
88
88
|
"peerDependencies": {
|
|
89
89
|
"@unocss/preset-wind4": ">=66.0.0",
|
|
@@ -39,7 +39,7 @@ const enabled = ref(false)
|
|
|
39
39
|
</script>
|
|
40
40
|
|
|
41
41
|
<template>
|
|
42
|
-
<div class="flex items-center gap-x-
|
|
42
|
+
<div class="flex items-center gap-x-3">
|
|
43
43
|
<UiSwitch id="airplane-mode" v-model="enabled" name="airplane-mode" />
|
|
44
44
|
<label for="airplane-mode" class="text-sm font-medium">Airplane Mode</label>
|
|
45
45
|
</div>
|
|
@@ -62,7 +62,7 @@ export const Default: Story = {
|
|
|
62
62
|
return { args, enabled };
|
|
63
63
|
},
|
|
64
64
|
template: `
|
|
65
|
-
<div class="flex items-center gap-x-
|
|
65
|
+
<div class="flex items-center gap-x-3">
|
|
66
66
|
<UiSwitch id="airplane-mode" v-model="enabled" name="airplane-mode" :disabled="args.disabled" />
|
|
67
67
|
<label for="airplane-mode" class="text-sm font-medium">Airplane Mode</label>
|
|
68
68
|
</div>
|
|
@@ -82,7 +82,7 @@ import { UiSwitch } from '@aleph-alpha/ui-library'
|
|
|
82
82
|
</script>
|
|
83
83
|
|
|
84
84
|
<template>
|
|
85
|
-
<div class="flex items-center gap-x-
|
|
85
|
+
<div class="flex items-center gap-x-3">
|
|
86
86
|
<UiSwitch id="airplane-mode" name="airplane-mode" disabled />
|
|
87
87
|
<label for="airplane-mode" class="text-sm font-medium text-muted-foreground">Airplane Mode</label>
|
|
88
88
|
</div>
|
|
@@ -108,7 +108,7 @@ export const Disabled: Story = {
|
|
|
108
108
|
return { args, enabled };
|
|
109
109
|
},
|
|
110
110
|
template: `
|
|
111
|
-
<div class="flex items-center gap-x-
|
|
111
|
+
<div class="flex items-center gap-x-3">
|
|
112
112
|
<UiSwitch id="airplane-mode" v-model="enabled" name="airplane-mode" :disabled="args.disabled" />
|
|
113
113
|
<label for="airplane-mode" class="text-sm font-medium text-muted-foreground">Airplane Mode</label>
|
|
114
114
|
</div>
|
|
@@ -23,7 +23,7 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
|
|
23
23
|
v-bind="forwarded"
|
|
24
24
|
:class="
|
|
25
25
|
cn(
|
|
26
|
-
'peer data-[state=checked]:bg-background-accent-default data-[state=unchecked]:bg-
|
|
26
|
+
'peer data-[state=checked]:bg-background-accent-default data-[state=unchecked]:bg-background-surface-muted-strong focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 p-0.5 h-5 w-9',
|
|
27
27
|
props.class,
|
|
28
28
|
)
|
|
29
29
|
"
|
|
@@ -32,7 +32,7 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
|
|
32
32
|
data-slot="switch-thumb"
|
|
33
33
|
:class="
|
|
34
34
|
cn(
|
|
35
|
-
'data-[state=checked]:bg-background-accent-soft data-[state=unchecked]:bg-background dark:data-[state=unchecked]:bg-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0',
|
|
35
|
+
'data-[state=checked]:bg-background-accent-soft data-[state=unchecked]:bg-background-surface-secondary dark:data-[state=unchecked]:bg-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0',
|
|
36
36
|
)
|
|
37
37
|
"
|
|
38
38
|
>
|