@odx/foundation 1.0.0-rc.3 → 1.0.0-rc.5
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 +17 -0
- package/README.md +10 -0
- package/dist/lib/breakpoints.d.ts +49 -49
- package/dist/lib/breakpoints.js +141 -122
- package/dist/lib/format.d.ts +52 -50
- package/dist/lib/format.js +53 -50
- package/dist/lib/localization.d.ts +14 -11
- package/dist/lib/localization.js +15 -15
- package/dist/lib/models.d.ts +5 -39
- package/dist/lib/signals.d.ts +16 -13
- package/dist/lib/signals.js +37 -32
- package/dist/lib/theming.d.ts +16 -13
- package/dist/lib/theming.js +21 -24
- package/dist/lib/utils/shared-media-observer.js +33 -35
- package/dist/main.d.ts +7 -7
- package/dist/main.js +6 -5
- package/dist/styles.css +1069 -1
- package/package.json +15 -17
- package/types/styles.d.ts +3 -0
- package/dist/lib/models.js +0 -34
- package/dist/lib/utils/breakpoint.d.ts +0 -38
- package/dist/lib/utils/breakpoint.js +0 -103
- package/dist/lib/utils/shared-media-observer.d.ts +0 -4
- package/dist/oss-licenses.json +0 -1
package/package.json
CHANGED
|
@@ -2,33 +2,31 @@
|
|
|
2
2
|
"name": "@odx/foundation",
|
|
3
3
|
"displayName": "ODX Design System Foundation",
|
|
4
4
|
"description": "The design foundation of the ODX Design System, providing base styles and utilities",
|
|
5
|
-
"version": "1.0.0-rc.
|
|
5
|
+
"version": "1.0.0-rc.5",
|
|
6
6
|
"author": "Drägerwerk AG & Co.KGaA",
|
|
7
7
|
"license": "SEE LICENSE IN LICENSE",
|
|
8
8
|
"homepage": "https://odx.draeger.com",
|
|
9
9
|
"files": [
|
|
10
10
|
"dist",
|
|
11
|
+
"types",
|
|
11
12
|
"CHANGELOG.md",
|
|
12
13
|
"LICENSE",
|
|
13
14
|
"!dist/**/*.map"
|
|
14
15
|
],
|
|
15
16
|
"type": "module",
|
|
16
17
|
"dependencies": {
|
|
17
|
-
"@lit-labs/signals": "0.2.0",
|
|
18
18
|
"signal-polyfill": "0.2.2"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
|
-
"@odx/design-tokens": "^4.0.
|
|
21
|
+
"@odx/design-tokens": "^4.0.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@
|
|
25
|
-
"lit": "3.3.
|
|
26
|
-
"stylelint": "17.
|
|
27
|
-
"
|
|
28
|
-
"@odx-internal/config-vite": "0.0.0",
|
|
24
|
+
"@tsdown/css": "0.22.0",
|
|
25
|
+
"lit": "3.3.3",
|
|
26
|
+
"stylelint": "17.11.1",
|
|
27
|
+
"tsdown": "0.22.0",
|
|
29
28
|
"@odx-internal/config-stylelint": "0.0.0",
|
|
30
|
-
"@odx-internal/utils-storybook": "0.0.0"
|
|
31
|
-
"@odx-internal/config-typescript": "0.0.0"
|
|
29
|
+
"@odx-internal/utils-storybook": "0.0.0"
|
|
32
30
|
},
|
|
33
31
|
"style": "./dist/styles.css",
|
|
34
32
|
"sideEffects": [
|
|
@@ -42,7 +40,10 @@
|
|
|
42
40
|
"import": "./dist/main.js",
|
|
43
41
|
"types": "./dist/main.d.ts"
|
|
44
42
|
},
|
|
45
|
-
"./styles":
|
|
43
|
+
"./styles": {
|
|
44
|
+
"import": "./dist/styles.css",
|
|
45
|
+
"types": "./types/styles.d.ts"
|
|
46
|
+
}
|
|
46
47
|
},
|
|
47
48
|
"publishConfig": {
|
|
48
49
|
"access": "public",
|
|
@@ -52,12 +53,9 @@
|
|
|
52
53
|
"extends": "@odx-internal/config-stylelint"
|
|
53
54
|
},
|
|
54
55
|
"scripts": {
|
|
55
|
-
"build": "
|
|
56
|
-
"dev": "
|
|
57
|
-
"dev:tsc": "tsc --build tsconfig.lib.json --noEmit --watch",
|
|
56
|
+
"build": "tsdown",
|
|
57
|
+
"dev": "tsdown --no-clean --watch",
|
|
58
58
|
"lint": "biome lint src",
|
|
59
|
-
"lint:styles": "stylelint '**/*.css'"
|
|
60
|
-
"test": "vitest run",
|
|
61
|
-
"test:watch": "vitest --watch"
|
|
59
|
+
"lint:styles": "stylelint '**/*.css'"
|
|
62
60
|
}
|
|
63
61
|
}
|
package/dist/lib/models.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
const Alignment = {
|
|
2
|
-
START: "start",
|
|
3
|
-
CENTER: "center",
|
|
4
|
-
END: "end"
|
|
5
|
-
};
|
|
6
|
-
const Spacing = {
|
|
7
|
-
0: "0",
|
|
8
|
-
SM: "sm",
|
|
9
|
-
MD: "md",
|
|
10
|
-
LG: "lg"
|
|
11
|
-
};
|
|
12
|
-
const Justify = {
|
|
13
|
-
START: "start",
|
|
14
|
-
END: "end",
|
|
15
|
-
CENTER: "center",
|
|
16
|
-
SPACE_BETWEEN: "space-between",
|
|
17
|
-
SPACE_AROUND: "space-around",
|
|
18
|
-
SPACE_EVENLY: "space-evenly"
|
|
19
|
-
};
|
|
20
|
-
const Variant = {
|
|
21
|
-
NEUTRAL: "neutral",
|
|
22
|
-
PRIMARY: "primary",
|
|
23
|
-
ACCENT: "accent",
|
|
24
|
-
SUCCESS: "success",
|
|
25
|
-
WARNING: "warning",
|
|
26
|
-
DANGER: "danger",
|
|
27
|
-
ACCENT_GHOST: "accent-ghost",
|
|
28
|
-
DANGER_GHOST: "danger-ghost",
|
|
29
|
-
CONFIRMATION: "confirmation",
|
|
30
|
-
SUBTLE: "subtle",
|
|
31
|
-
GHOST: "ghost"
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export { Alignment, Justify, Spacing, Variant };
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Signal } from '../signals.js';
|
|
2
|
-
declare global {
|
|
3
|
-
namespace ODX.Breakpoints {
|
|
4
|
-
interface Config {
|
|
5
|
-
sm: true;
|
|
6
|
-
md: true;
|
|
7
|
-
lg: true;
|
|
8
|
-
xl: true;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
type FilteredKeys<T extends object> = {
|
|
13
|
-
[K in keyof T as T[K] extends true ? K : never]: T[K];
|
|
14
|
-
};
|
|
15
|
-
export type BreakpointOperator = '<' | '<=' | '>=' | '>';
|
|
16
|
-
export interface BreakpointConfig {
|
|
17
|
-
name: keyof FilteredKeys<ODX.Breakpoints.Config>;
|
|
18
|
-
min: number;
|
|
19
|
-
max: number;
|
|
20
|
-
customQuery?: string;
|
|
21
|
-
}
|
|
22
|
-
export interface Breakpoint extends BreakpointConfig {
|
|
23
|
-
id: BreakpointConfig['name'] | `${BreakpointOperator}${BreakpointConfig['name']}`;
|
|
24
|
-
query: string;
|
|
25
|
-
operator?: BreakpointOperator;
|
|
26
|
-
}
|
|
27
|
-
export declare const registeredBreakpoints: ReadonlyMap<Breakpoint['id'], Breakpoint>;
|
|
28
|
-
export declare const breakpointAttribute = "odx-breakpoint";
|
|
29
|
-
export declare function buildBreakpoint(breakpoint: BreakpointConfig, operator?: BreakpointOperator): Breakpoint;
|
|
30
|
-
export declare function expandBreakpoints(...breakpoints: BreakpointConfig[]): Breakpoint[];
|
|
31
|
-
export declare function observeBreakpoint(id: Breakpoint['id'], initialValue?: boolean): Signal<Breakpoint & {
|
|
32
|
-
matches: boolean;
|
|
33
|
-
}>;
|
|
34
|
-
export declare function createBreakpointUpdater(breakpoints: Breakpoint[], update?: (target: HTMLElement, change: Breakpoint & {
|
|
35
|
-
matches: boolean;
|
|
36
|
-
}) => void): () => void;
|
|
37
|
-
export {};
|
|
38
|
-
//# sourceMappingURL=breakpoint.d.ts.map
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { signal } from '../signals.js';
|
|
2
|
-
import { observeMedia } from './shared-media-observer.js';
|
|
3
|
-
|
|
4
|
-
const operators = ["<", "<=", ">=", ">"];
|
|
5
|
-
const registeredBreakpoints = /* @__PURE__ */ new Map();
|
|
6
|
-
const breakpointAttribute = "odx-breakpoint";
|
|
7
|
-
function buildBreakpoint(breakpoint, operator) {
|
|
8
|
-
const id = operator ? `${operator}${breakpoint.name}` : breakpoint.name;
|
|
9
|
-
let query = `(min-width: ${breakpoint.min}px) and (max-width: ${breakpoint.max}px)`;
|
|
10
|
-
switch (operator) {
|
|
11
|
-
case "<":
|
|
12
|
-
query = `(max-width: ${breakpoint.min - 0.02}px)`;
|
|
13
|
-
break;
|
|
14
|
-
case "<=":
|
|
15
|
-
query = `(max-width: ${breakpoint.max}px)`;
|
|
16
|
-
break;
|
|
17
|
-
case ">=":
|
|
18
|
-
query = `(min-width: ${breakpoint.min}px)`;
|
|
19
|
-
break;
|
|
20
|
-
case ">":
|
|
21
|
-
query = `(min-width: ${breakpoint.max + 0.02}px)`;
|
|
22
|
-
break;
|
|
23
|
-
}
|
|
24
|
-
return { ...breakpoint, id, operator, query: [query, breakpoint.customQuery].filter(Boolean).join(" and ") };
|
|
25
|
-
}
|
|
26
|
-
function expandBreakpoints(...breakpoints) {
|
|
27
|
-
return breakpoints.flatMap((breakpoint) => [void 0, ...operators].map((operator) => buildBreakpoint(breakpoint, operator)));
|
|
28
|
-
}
|
|
29
|
-
function observeBreakpoint(id, initialValue = false) {
|
|
30
|
-
const breakpoint = registeredBreakpoints.get(id);
|
|
31
|
-
let unobserveMedia;
|
|
32
|
-
const state = signal(
|
|
33
|
-
{ ...breakpoint, matches: initialValue },
|
|
34
|
-
{
|
|
35
|
-
watched() {
|
|
36
|
-
if (!breakpoint) return;
|
|
37
|
-
unobserveMedia = observeMedia(breakpoint.query, ({ matches }) => {
|
|
38
|
-
state.set({ ...breakpoint, matches });
|
|
39
|
-
});
|
|
40
|
-
},
|
|
41
|
-
unwatched() {
|
|
42
|
-
unobserveMedia?.();
|
|
43
|
-
unobserveMedia = void 0;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
);
|
|
47
|
-
return state;
|
|
48
|
-
}
|
|
49
|
-
function createBreakpointUpdater(breakpoints, update) {
|
|
50
|
-
for (const breakpoint of breakpoints) {
|
|
51
|
-
registeredBreakpoints.set(breakpoint.id, breakpoint);
|
|
52
|
-
}
|
|
53
|
-
const breakpointCache = /* @__PURE__ */ new WeakMap();
|
|
54
|
-
const breakpointObservers = breakpoints.map((breakpoint) => observeBreakpoint(breakpoint.id, false));
|
|
55
|
-
return () => {
|
|
56
|
-
const elements = document.querySelectorAll(`[${breakpointAttribute}]`);
|
|
57
|
-
const changes = breakpointObservers.reduce(
|
|
58
|
-
(breakpoints2, breakpoint) => {
|
|
59
|
-
breakpoints2[breakpoint.get().id] = breakpoint.get();
|
|
60
|
-
return breakpoints2;
|
|
61
|
-
},
|
|
62
|
-
{}
|
|
63
|
-
);
|
|
64
|
-
let i = elements.length;
|
|
65
|
-
while (i--) {
|
|
66
|
-
const element = elements[i];
|
|
67
|
-
const change = changes[element.getAttribute(breakpointAttribute) || ""];
|
|
68
|
-
if (!change || change.matches === breakpointCache.get(element)) continue;
|
|
69
|
-
breakpointCache.set(element, change.matches);
|
|
70
|
-
updateHostElement(element, change.matches);
|
|
71
|
-
update?.(element, change);
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
function updateHostElement(host, active) {
|
|
76
|
-
const attributeName = "data-odx-breakpoint-slot";
|
|
77
|
-
const classNames = host.getAttribute("odx-breakpoint-class");
|
|
78
|
-
if (classNames) {
|
|
79
|
-
for (const className of classNames.split(" ")) {
|
|
80
|
-
host.classList.toggle(className, active);
|
|
81
|
-
}
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
host.hidden = !active;
|
|
85
|
-
let initialSlot = host.getAttribute(attributeName);
|
|
86
|
-
if (initialSlot == null) {
|
|
87
|
-
initialSlot = host.slot;
|
|
88
|
-
host.setAttribute(attributeName, initialSlot);
|
|
89
|
-
}
|
|
90
|
-
if (active) {
|
|
91
|
-
host.removeAttribute(attributeName);
|
|
92
|
-
if (initialSlot === "") {
|
|
93
|
-
host.removeAttribute("slot");
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
host.slot = "";
|
|
97
|
-
host.slot = initialSlot;
|
|
98
|
-
} else {
|
|
99
|
-
host.slot = "_odx_breakpoint_hidden";
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export { breakpointAttribute, buildBreakpoint, createBreakpointUpdater, expandBreakpoints, observeBreakpoint, registeredBreakpoints };
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export type MediaObserverEventListener = (event: MediaQueryListEvent) => void;
|
|
2
|
-
export declare function observeMedia(query: string, listener: MediaObserverEventListener): () => void;
|
|
3
|
-
export declare function unobserveMedia(query: string, listener: MediaObserverEventListener): void;
|
|
4
|
-
//# sourceMappingURL=shared-media-observer.d.ts.map
|
package/dist/oss-licenses.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
[]
|