@aleph-alpha/ui-library 5.0.0 → 5.2.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/README.md +2 -0
- package/config.js +123 -2
- package/dist/system/components/core/sidebar/SidebarInset.vue.d.ts +14 -1
- package/dist/system/lib.js +11 -5
- package/package.json +14 -5
- package/src/components/UiButton/UiButton.stories.ts +526 -38
- package/src/components/core/sidebar/SidebarInset.vue +19 -2
- package/src/patterns/UiSidebar/UiSidebar.stories.ts +4 -1
- package/src/patterns/UiSidebar/UiSidebarInset.stories.ts +259 -0
- package/src/patterns/UiSidebar/__tests__/UiSidebarInset.test.ts +20 -0
- package/src/theme/Shadow.stories.ts +20 -41
- package/tokens.json +147 -13
package/README.md
CHANGED
package/config.js
CHANGED
|
@@ -649,6 +649,123 @@ const getBorderRadiusExactUtilityRules = () => {
|
|
|
649
649
|
return entriesToRules(entries);
|
|
650
650
|
};
|
|
651
651
|
|
|
652
|
+
// Brand-tinted drop shadows resolved from the selected `2-theme/*` shadow group.
|
|
653
|
+
// Only the `sm`/`md`/`lg`/`xl` levels are layered, brand-tinted elevation scales
|
|
654
|
+
// (numbered children `1`, `2`, … combined into one CSS `box-shadow` value); the
|
|
655
|
+
// other token levels are left to preset-wind defaults. Color references (e.g.
|
|
656
|
+
// `{aa.colors.alpha.rose.20}`) resolve against the active theme search order.
|
|
657
|
+
const SHADOW_TOKEN_LEVELS = Object.freeze(['sm', 'md', 'lg', 'xl']);
|
|
658
|
+
|
|
659
|
+
// Each layer property is exposed as its own `--shadow-{level}-{n}-{prop}`
|
|
660
|
+
// variable so consumers can override a single sub-value; the resolved token is
|
|
661
|
+
// used as the inline fallback when the variable is undefined.
|
|
662
|
+
const SHADOW_LAYER_PROPS = Object.freeze([
|
|
663
|
+
'offset-x',
|
|
664
|
+
'offset-y',
|
|
665
|
+
'blur-radius',
|
|
666
|
+
'spread-radius',
|
|
667
|
+
]);
|
|
668
|
+
|
|
669
|
+
const resolveShadowDimension = (leaf, options) => {
|
|
670
|
+
if (!leaf || typeof leaf !== 'object' || !('value' in leaf)) return '0';
|
|
671
|
+
const resolved = resolveReferences(leaf.value, new Set(), options);
|
|
672
|
+
return typeof resolved === 'string' && resolved.trim()
|
|
673
|
+
? resolved.trim()
|
|
674
|
+
: '0';
|
|
675
|
+
};
|
|
676
|
+
|
|
677
|
+
// Shadow colors are emitted as `rgba(...)` so they read as plain colors in the
|
|
678
|
+
// composed `box-shadow` (hex8 would otherwise be normalized to oklch components).
|
|
679
|
+
const formatShadowColor = (raw) => {
|
|
680
|
+
const rgba = parseHexColorToRgba(raw);
|
|
681
|
+
if (!rgba) return raw;
|
|
682
|
+
const alpha = roundTo(rgba.a, 2);
|
|
683
|
+
return `rgba(${rgba.r}, ${rgba.g}, ${rgba.b}, ${alpha})`;
|
|
684
|
+
};
|
|
685
|
+
|
|
686
|
+
const resolveShadowLayer = (level, layerKey, layer, options) => {
|
|
687
|
+
if (!layer || typeof layer !== 'object') return null;
|
|
688
|
+
|
|
689
|
+
const prefix = `--shadow-${level}-${layerKey}`;
|
|
690
|
+
const parts = SHADOW_LAYER_PROPS.map((prop) => {
|
|
691
|
+
const value = resolveShadowDimension(layer[prop], options);
|
|
692
|
+
return `var(${prefix}-${prop}, ${value})`;
|
|
693
|
+
});
|
|
694
|
+
|
|
695
|
+
const colorLeaf = layer.color;
|
|
696
|
+
const rawColor =
|
|
697
|
+
colorLeaf && typeof colorLeaf === 'object' && 'value' in colorLeaf
|
|
698
|
+
? resolveReferences(colorLeaf.value, new Set(), options)
|
|
699
|
+
: null;
|
|
700
|
+
const color = formatShadowColor(
|
|
701
|
+
typeof rawColor === 'string' && rawColor.trim()
|
|
702
|
+
? rawColor.trim()
|
|
703
|
+
: 'rgba(0, 0, 0, 0)',
|
|
704
|
+
);
|
|
705
|
+
parts.push(`var(${prefix}-color, ${color})`);
|
|
706
|
+
|
|
707
|
+
return parts.join(' ');
|
|
708
|
+
};
|
|
709
|
+
|
|
710
|
+
const resolveShadowGroup = (level, group, options) => {
|
|
711
|
+
const layerKeys = Object.keys(group)
|
|
712
|
+
.filter((key) => /^\d+$/.test(key))
|
|
713
|
+
.sort((a, b) => Number(a) - Number(b));
|
|
714
|
+
const layers = layerKeys
|
|
715
|
+
.map((key) => resolveShadowLayer(level, key, group[key], options))
|
|
716
|
+
.filter(Boolean);
|
|
717
|
+
return layers.length ? layers.join(', ') : null;
|
|
718
|
+
};
|
|
719
|
+
|
|
720
|
+
/**
|
|
721
|
+
* Resolve the design-token drop shadows into CSS `box-shadow` values.
|
|
722
|
+
* Reads the `shadow` group from the selected `2-theme/*` set (AA Base by
|
|
723
|
+
* default, WCAG 2.2 in accessible mode) and powers the `shadow-sm` …
|
|
724
|
+
* `shadow-xl` utilities. Each layer sub-property is referenced through a
|
|
725
|
+
* `--shadow-{level}-{n}-{prop}` variable with the token value as fallback.
|
|
726
|
+
* @param {object} [options] Token resolution options.
|
|
727
|
+
* @returns {Record<string, string>} Box-shadow values keyed by level (e.g. `sm`).
|
|
728
|
+
*/
|
|
729
|
+
export const getUiLibraryShadows = (options = {}) => {
|
|
730
|
+
const referenceThemeSet = getUiLibraryThemeMode(options);
|
|
731
|
+
const shadowGroup = getTokens()?.[referenceThemeSet]?.shadow;
|
|
732
|
+
if (!shadowGroup || typeof shadowGroup !== 'object') return {};
|
|
733
|
+
|
|
734
|
+
const shadows = {};
|
|
735
|
+
for (const level of SHADOW_TOKEN_LEVELS) {
|
|
736
|
+
const group = shadowGroup[level];
|
|
737
|
+
if (!group || typeof group !== 'object') continue;
|
|
738
|
+
const value = resolveShadowGroup(level, group, options);
|
|
739
|
+
if (value) shadows[level] = value;
|
|
740
|
+
}
|
|
741
|
+
return shadows;
|
|
742
|
+
};
|
|
743
|
+
|
|
744
|
+
// Token-backed shadows are emitted as `--shadow-*` custom properties — the same
|
|
745
|
+
// public contract the design-system token preset uses (e.g. `--shadow-dropdowns`).
|
|
746
|
+
// Exposing them lets portalled DOM (outside the Uno-scanned tree) and external
|
|
747
|
+
// consumers reference shadows directly instead of hardcoding values, and lets
|
|
748
|
+
// the accessible theme override them via CSS cascade.
|
|
749
|
+
const getUiLibraryShadowVars = (options = {}) =>
|
|
750
|
+
Object.fromEntries(
|
|
751
|
+
Object.entries(getUiLibraryShadows(options)).map(([level, value]) => [
|
|
752
|
+
`shadow-${level}`,
|
|
753
|
+
value,
|
|
754
|
+
]),
|
|
755
|
+
);
|
|
756
|
+
|
|
757
|
+
// UnoCSS `theme.shadow` entries that point each `shadow-*` utility at its
|
|
758
|
+
// `--shadow-*` variable. Routing through the variable (instead of a literal)
|
|
759
|
+
// keeps preset-wind's ring/inset shadow composition intact AND lets theme
|
|
760
|
+
// switching (e.g. accessible variant) cascade without parallel rules.
|
|
761
|
+
const getUiLibraryShadowTheme = (options = {}) =>
|
|
762
|
+
Object.fromEntries(
|
|
763
|
+
Object.keys(getUiLibraryShadows(options)).map((level) => [
|
|
764
|
+
level,
|
|
765
|
+
`var(--shadow-${level})`,
|
|
766
|
+
]),
|
|
767
|
+
);
|
|
768
|
+
|
|
652
769
|
export const defineThemeConfig = (config) => config;
|
|
653
770
|
|
|
654
771
|
export const presetUiLibraryTheme = (theme, options = {}) => {
|
|
@@ -726,9 +843,10 @@ export const presetUiLibraryThemeFromTokens = (options = {}) => {
|
|
|
726
843
|
const tokenBorderRadiusVars = getUiLibraryTokenBorderRadiusVars();
|
|
727
844
|
const buildTheme = (modeOptions = {}) => {
|
|
728
845
|
const baseTheme = getUiLibraryThemeFromTokens(modeOptions);
|
|
846
|
+
const shadowVars = getUiLibraryShadowVars(modeOptions);
|
|
729
847
|
let resolvedTheme = {
|
|
730
|
-
light: { ...baseTheme.light, ...tokenBorderRadiusVars },
|
|
731
|
-
dark: { ...baseTheme.dark, ...tokenBorderRadiusVars },
|
|
848
|
+
light: { ...baseTheme.light, ...tokenBorderRadiusVars, ...shadowVars },
|
|
849
|
+
dark: { ...baseTheme.dark, ...tokenBorderRadiusVars, ...shadowVars },
|
|
732
850
|
};
|
|
733
851
|
|
|
734
852
|
if (includeAllTokens) {
|
|
@@ -811,6 +929,9 @@ export const presetUiLibraryThemeFromTokens = (options = {}) => {
|
|
|
811
929
|
...tokenColors,
|
|
812
930
|
...semanticColors,
|
|
813
931
|
},
|
|
932
|
+
// Token-backed drop shadows (shadow-sm … shadow-xl) routed through
|
|
933
|
+
// --shadow-* so preset-wind's ring composition and theme switching work.
|
|
934
|
+
shadow: getUiLibraryShadowTheme(modeOptions),
|
|
814
935
|
},
|
|
815
936
|
rules: [
|
|
816
937
|
...getBorderRadiusExactUtilityRules(),
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
import { Component } from 'vue';
|
|
2
|
+
type Tag = keyof HTMLElementTagNameMap | (string & {}) | Component;
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
/**
|
|
5
|
+
* The tag or component to render as the root element.
|
|
6
|
+
* Defaults to `main`. Use a different tag (e.g. `div` or `section`) when
|
|
7
|
+
* rendering multiple insets on a single page to avoid duplicate `main`
|
|
8
|
+
* landmarks.
|
|
9
|
+
*/
|
|
10
|
+
as?: Tag;
|
|
11
|
+
};
|
|
1
12
|
declare function __VLS_template(): {
|
|
2
13
|
attrs: Partial<{}>;
|
|
3
14
|
slots: {
|
|
@@ -7,7 +18,9 @@ declare function __VLS_template(): {
|
|
|
7
18
|
rootEl: any;
|
|
8
19
|
};
|
|
9
20
|
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
10
|
-
declare const __VLS_component: import('vue').DefineComponent<
|
|
21
|
+
declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
22
|
+
as: Tag;
|
|
23
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
11
24
|
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
12
25
|
export default _default;
|
|
13
26
|
type __VLS_WithTemplateSlots<T, S> = T & {
|
package/dist/system/lib.js
CHANGED
|
@@ -56212,19 +56212,25 @@ const PT = /* @__PURE__ */ _({
|
|
|
56212
56212
|
}, Symbol.toStringTag, { value: "Module" })), P1e = /* @__PURE__ */ _({
|
|
56213
56213
|
inheritAttrs: !1,
|
|
56214
56214
|
__name: "SidebarInset",
|
|
56215
|
+
props: {
|
|
56216
|
+
as: { default: "main" }
|
|
56217
|
+
},
|
|
56215
56218
|
setup(e) {
|
|
56216
|
-
return (t, a) => (h(),
|
|
56219
|
+
return (t, a) => (h(), b(Ee(e.as), q(t.$attrs, {
|
|
56217
56220
|
"data-slot": "sidebar-inset",
|
|
56218
56221
|
class: l(D)(
|
|
56219
56222
|
"bg-background relative flex w-full flex-1 flex-col transition-[border-radius,box-shadow,opacity,transform] duration-(--sidebar-mobile-transition-duration) ease-out will-change-[opacity,transform]",
|
|
56220
56223
|
"md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",
|
|
56221
56224
|
t.$attrs.class ?? ""
|
|
56222
56225
|
)
|
|
56223
|
-
}),
|
|
56224
|
-
|
|
56225
|
-
|
|
56226
|
+
}), {
|
|
56227
|
+
default: v(() => [
|
|
56228
|
+
k(t.$slots, "default", {}, void 0, !0)
|
|
56229
|
+
]),
|
|
56230
|
+
_: 3
|
|
56231
|
+
}, 16, ["class"]));
|
|
56226
56232
|
}
|
|
56227
|
-
}), xB = /* @__PURE__ */ Os(P1e, [["__scopeId", "data-v-
|
|
56233
|
+
}), xB = /* @__PURE__ */ Os(P1e, [["__scopeId", "data-v-f9cff196"]]), D1e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
56228
56234
|
__proto__: null,
|
|
56229
56235
|
default: xB
|
|
56230
56236
|
}, Symbol.toStringTag, { value: "Module" })), CB = /* @__PURE__ */ _({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aleph-alpha/ui-library",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.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",
|
|
84
85
|
"@aleph-alpha/prettier-config-frontend": "2.1.0",
|
|
85
|
-
"@aleph-alpha/tsconfig-frontend": "0.7.0"
|
|
86
|
-
"@aleph-alpha/eslint-config-frontend": "0.7.0"
|
|
86
|
+
"@aleph-alpha/tsconfig-frontend": "0.7.0"
|
|
87
87
|
},
|
|
88
88
|
"peerDependencies": {
|
|
89
89
|
"@unocss/preset-wind4": ">=66.0.0",
|
|
@@ -118,6 +118,15 @@
|
|
|
118
118
|
"vue-sonner": "^2.0.9",
|
|
119
119
|
"@aleph-alpha/config-unocss": "0.2.0"
|
|
120
120
|
},
|
|
121
|
+
"jest-junit": {
|
|
122
|
+
"outputDirectory": "reports/storybook",
|
|
123
|
+
"outputName": "junit.xml",
|
|
124
|
+
"ancestorSeparator": " › ",
|
|
125
|
+
"uniqueOutputName": "false",
|
|
126
|
+
"suiteNameTemplate": "{filepath}",
|
|
127
|
+
"classNameTemplate": "{classname}",
|
|
128
|
+
"titleTemplate": "{title}"
|
|
129
|
+
},
|
|
121
130
|
"scripts": {
|
|
122
131
|
"build": "node scripts/prepare-build.cjs && vite build",
|
|
123
132
|
"ci": "pnpm install --immutable --immutable-cache --check-cache",
|
|
@@ -128,8 +137,8 @@
|
|
|
128
137
|
"lint": "eslint 'src/**/*.{js,vue,ts}' --cache",
|
|
129
138
|
"test": "vitest --run --project=unit",
|
|
130
139
|
"test:watch": "vitest --project=unit",
|
|
131
|
-
"test:storybook": "pnpm concurrently -k --ks SIGKILL -s command-test -n \"storybook,test\" \"pnpm http-server ../../dist/storybook/ui-library --port 4400 --silent\" \"wait-on tcp:4400 && test-storybook --url http://127.0.0.1:4400\"",
|
|
132
|
-
"test:storybook:local": "pnpm build-storybook && pnpm concurrently -k --ks SIGKILL -s command-test -n \"storybook,test\" \"pnpm http-server storybook-static --port 4400 --silent\" \"wait-on tcp:4400 && test-storybook --url http://127.0.0.1:4400\"",
|
|
140
|
+
"test:storybook": "pnpm concurrently -k --ks SIGKILL -s command-test -n \"storybook,test\" \"pnpm http-server ../../dist/storybook/ui-library --port 4400 --silent\" \"wait-on tcp:4400 && test-storybook --url http://127.0.0.1:4400 --junit\"",
|
|
141
|
+
"test:storybook:local": "pnpm build-storybook && pnpm concurrently -k --ks SIGKILL -s command-test -n \"storybook,test\" \"pnpm http-server storybook-static --port 4400 --silent\" \"wait-on tcp:4400 && test-storybook --url http://127.0.0.1:4400 --junit\"",
|
|
133
142
|
"test:all": "vitest --run",
|
|
134
143
|
"storybook": "storybook dev -p 6006",
|
|
135
144
|
"build-storybook": "storybook build",
|