@odx/foundation 1.0.0-beta.235 → 1.0.0-beta.236
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/breakpoints/main.d.ts +1 -1
- package/dist/breakpoints/utils.d.ts +3 -3
- package/dist/breakpoints.js +48 -39
- package/dist/components.js +1 -1
- package/dist/i18n.js +1 -1
- package/dist/vendor.js +1 -24
- package/package.json +2 -2
|
@@ -16,7 +16,7 @@ export declare const defaultBreakpoints: {
|
|
|
16
16
|
readonly max: 1199.98;
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
|
-
export default function setupBreakpoints(breakpointsConfig?: BreakpointConfig[]
|
|
19
|
+
export default function setupBreakpoints(breakpointsConfig?: BreakpointConfig[]): () => void;
|
|
20
20
|
export * from './models.js';
|
|
21
21
|
export * from './plugins.js';
|
|
22
22
|
export * from './utils.js';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Signal } from '@preact/signals-core';
|
|
2
|
-
import { Breakpoint, BreakpointChange, BreakpointConfig, BreakpointOperator
|
|
2
|
+
import { Breakpoint, BreakpointChange, BreakpointConfig, BreakpointOperator } from './models.js';
|
|
3
3
|
export declare const breakpointDirective: import('../utils/main.js').StringAttributeDirective<"odx-breakpoint">;
|
|
4
4
|
export declare function buildBreakpoint(breakpoint: BreakpointConfig, operator?: BreakpointOperator): Breakpoint;
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function expandBreakpoints(...breakpoints: BreakpointConfig[]): Record<string, Breakpoint>;
|
|
5
|
+
export declare function expandBreakpoints(...breakpoints: BreakpointConfig[]): Breakpoint[];
|
|
7
6
|
export declare function observeBreakpoint(breakpoint: Breakpoint, initialValue?: boolean): Signal<Breakpoint & {
|
|
8
7
|
matches: boolean;
|
|
9
8
|
}>;
|
|
9
|
+
export declare function createBreakpointDirectiveUpdater(breakpoints: Breakpoint[], update: (target: HTMLElement, change: BreakpointChange) => void): () => void;
|
|
10
10
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/breakpoints.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
+
import { signal, effect } from '@preact/signals-core';
|
|
1
2
|
import { stringAttributeDirective, observeMedia } from '@odx/foundation/utils';
|
|
2
|
-
import { signal } from '@preact/signals-core';
|
|
3
|
-
import { k as keyBy, g as groupBy } from './vendor.js';
|
|
4
3
|
|
|
5
4
|
const BreakpointHideTargetPlugin = (target, change) => {
|
|
6
5
|
target.hidden = !change.matches;
|
|
@@ -34,23 +33,10 @@ function buildBreakpoint(breakpoint, operator) {
|
|
|
34
33
|
query = `(min-width: ${breakpoint.max + 0.02}px)`;
|
|
35
34
|
break;
|
|
36
35
|
}
|
|
37
|
-
query
|
|
38
|
-
return { ...breakpoint, id, operator, query };
|
|
39
|
-
}
|
|
40
|
-
function createBreakpointHandler(plugins, targets) {
|
|
41
|
-
return (change) => {
|
|
42
|
-
for (const plugin of plugins) {
|
|
43
|
-
for (const target of targets) {
|
|
44
|
-
plugin(target, change);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
};
|
|
36
|
+
return { ...breakpoint, id, operator, query: [query, breakpoint.customQuery].filter(Boolean).join(" and ") };
|
|
48
37
|
}
|
|
49
38
|
function expandBreakpoints(...breakpoints) {
|
|
50
|
-
|
|
51
|
-
(breakpoint) => [void 0, ...operators].map((operator) => buildBreakpoint(breakpoint, operator))
|
|
52
|
-
);
|
|
53
|
-
return keyBy(expandBreakpoints2, (breakpoint) => breakpoint.id);
|
|
39
|
+
return breakpoints.flatMap((breakpoint) => [void 0, ...operators].map((operator) => buildBreakpoint(breakpoint, operator)));
|
|
54
40
|
}
|
|
55
41
|
function observeBreakpoint(breakpoint, initialValue = false) {
|
|
56
42
|
let unobserveMedia;
|
|
@@ -68,38 +54,61 @@ function observeBreakpoint(breakpoint, initialValue = false) {
|
|
|
68
54
|
}
|
|
69
55
|
);
|
|
70
56
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
57
|
+
function createBreakpointDirectiveUpdater(breakpoints, update) {
|
|
58
|
+
const breakpointObservers = breakpoints.map((breakpoint) => observeBreakpoint(breakpoint));
|
|
59
|
+
return () => {
|
|
60
|
+
const results = breakpointObservers.reduce(
|
|
61
|
+
(breakpoints2, { value }) => {
|
|
62
|
+
breakpoints2[value.id] = value;
|
|
63
|
+
return breakpoints2;
|
|
64
|
+
},
|
|
65
|
+
{}
|
|
66
|
+
);
|
|
67
|
+
const directives = document.querySelectorAll(breakpointDirective.selector);
|
|
68
|
+
let i = directives.length;
|
|
69
|
+
while (i--) {
|
|
70
|
+
const directive = directives[i];
|
|
71
|
+
const result = results[breakpointDirective.value(directive) ?? ""];
|
|
72
|
+
if (!result) continue;
|
|
73
|
+
update(directive, result);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
77
76
|
}
|
|
77
|
+
|
|
78
78
|
const defaultBreakpoints = {
|
|
79
79
|
mobile: { id: "mobile", min: 0, max: 575.98 },
|
|
80
80
|
tablet: { id: "tablet", min: 576, max: 991.98 },
|
|
81
81
|
desktop: { id: "desktop", min: 992, max: 1199.98 }
|
|
82
82
|
};
|
|
83
|
-
function setupBreakpoints(breakpointsConfig = []
|
|
83
|
+
function setupBreakpoints(breakpointsConfig = []) {
|
|
84
84
|
const breakpoints = expandBreakpoints(...Object.values(defaultBreakpoints), ...breakpointsConfig);
|
|
85
85
|
const plugins = [BreakpointHideTargetPlugin, BreakpointClassNamePlugin];
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const breakpointDirectives = Array.from(document.querySelectorAll(breakpointDirective.selector));
|
|
90
|
-
unsubscribeAll(subscriptions);
|
|
91
|
-
const breakpointTargets = groupBy(breakpointDirectives, (host) => breakpointDirective.value(host) ?? "");
|
|
92
|
-
for (const [breakpointId, targets] of Object.entries(breakpointTargets)) {
|
|
93
|
-
const breakpoint = breakpoints[breakpointId];
|
|
94
|
-
if (!breakpoint) continue;
|
|
95
|
-
subscriptions.add(observeBreakpoint(breakpoint).subscribe(createBreakpointHandler(plugins, targets)));
|
|
86
|
+
const directiveUpdater = createBreakpointDirectiveUpdater(breakpoints, (target, change) => {
|
|
87
|
+
for (const plugin of plugins) {
|
|
88
|
+
plugin(target, change);
|
|
96
89
|
}
|
|
97
90
|
});
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
unsubscribeAll(subscriptions);
|
|
101
|
-
observer.disconnect();
|
|
91
|
+
let mutationObserver;
|
|
92
|
+
let unobserveBreakpoints = () => {
|
|
102
93
|
};
|
|
94
|
+
function initBreakpoints() {
|
|
95
|
+
destroyBreakpoints();
|
|
96
|
+
mutationObserver = new MutationObserver(directiveUpdater);
|
|
97
|
+
unobserveBreakpoints = effect(directiveUpdater);
|
|
98
|
+
mutationObserver.observe(document.documentElement, {
|
|
99
|
+
attributes: true,
|
|
100
|
+
subtree: true,
|
|
101
|
+
childList: true,
|
|
102
|
+
attributeFilter: [breakpointDirective.attribute]
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function destroyBreakpoints() {
|
|
106
|
+
unobserveBreakpoints();
|
|
107
|
+
mutationObserver?.disconnect();
|
|
108
|
+
globalThis.removeEventListener("DOMContentLoaded", initBreakpoints);
|
|
109
|
+
}
|
|
110
|
+
globalThis.addEventListener("DOMContentLoaded", initBreakpoints);
|
|
111
|
+
return destroyBreakpoints;
|
|
103
112
|
}
|
|
104
113
|
|
|
105
|
-
export { BreakpointClassNamePlugin, BreakpointHideTargetPlugin, breakpointDirective, buildBreakpoint,
|
|
114
|
+
export { BreakpointClassNamePlugin, BreakpointHideTargetPlugin, breakpointDirective, buildBreakpoint, createBreakpointDirectiveUpdater, setupBreakpoints as default, defaultBreakpoints, expandBreakpoints, observeBreakpoint };
|
package/dist/components.js
CHANGED
|
@@ -3,7 +3,7 @@ import { CustomElement, customElement, CanBeExpanded, InteractiveControlElement,
|
|
|
3
3
|
import { getUniqueId, toAriaBooleanAttribute, getAssignedElements, booleanAttributeDirective, optionalAttr, interactionResponse, getElementFromEvent, observeElementResize, unobserveElementResize, toPx, enableMotion, findClosestDocument, commandDirective, addGlobalEventListener, waitForAnimations, removeGlobalEventListener, getKeyInfo, clickedOutside, setFocusable, optionalSlot, parseDate, supportsHover, forwardEvent } from '@odx/foundation/utils';
|
|
4
4
|
import { html, isServer, unsafeCSS, css, nothing } from 'lit';
|
|
5
5
|
import { property, query, state } from 'lit/decorators.js';
|
|
6
|
-
import { p as pick, R as RovingTabindexController, e, c as computePosition, o as offset, s as shift, f as flip, a as size, b as arrow, h as hide, d as autoUpdate, r as round,
|
|
6
|
+
import { p as pick, R as RovingTabindexController, e, c as computePosition, o as offset, s as shift, f as flip, a as size, b as arrow, h as hide, d as autoUpdate, r as round, g as debounce } from './vendor.js';
|
|
7
7
|
import { when } from 'lit/directives/when.js';
|
|
8
8
|
import { OdxIconElement } from '@odx/icons';
|
|
9
9
|
import { IsLocalized } from '@odx/foundation/i18n';
|
package/dist/i18n.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { signal, computed } from '@preact/signals-core';
|
|
2
|
-
import {
|
|
2
|
+
import { i as flattenObject, e } from './vendor.js';
|
|
3
3
|
import { parseDate } from '@odx/foundation/utils';
|
|
4
4
|
import { _ as __decorateClass } from './_virtual_class-decorator-runtime.js';
|
|
5
5
|
import 'lit/html.js';
|
package/dist/vendor.js
CHANGED
|
@@ -3,29 +3,6 @@ import 'lit/html.js';
|
|
|
3
3
|
import { directive } from 'lit/directive.js';
|
|
4
4
|
import { AsyncDirective } from 'lit/async-directive.js';
|
|
5
5
|
|
|
6
|
-
function groupBy(arr, getKeyFromItem) {
|
|
7
|
-
const result = {};
|
|
8
|
-
for (let i = 0; i < arr.length; i++) {
|
|
9
|
-
const item = arr[i];
|
|
10
|
-
const key = getKeyFromItem(item);
|
|
11
|
-
if (!Object.hasOwn(result, key)) {
|
|
12
|
-
result[key] = [];
|
|
13
|
-
}
|
|
14
|
-
result[key].push(item);
|
|
15
|
-
}
|
|
16
|
-
return result;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function keyBy(arr, getKeyFromItem) {
|
|
20
|
-
const result = {};
|
|
21
|
-
for (let i = 0; i < arr.length; i++) {
|
|
22
|
-
const item = arr[i];
|
|
23
|
-
const key = getKeyFromItem(item);
|
|
24
|
-
result[key] = item;
|
|
25
|
-
}
|
|
26
|
-
return result;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
6
|
function minBy(items, getValue) {
|
|
30
7
|
if (items.length === 0) {
|
|
31
8
|
return undefined;
|
|
@@ -1988,4 +1965,4 @@ function throttle(func, throttleMs, { signal, edges = ['leading', 'trailing'] }
|
|
|
1988
1965
|
return throttled;
|
|
1989
1966
|
}
|
|
1990
1967
|
|
|
1991
|
-
export { RovingTabindexController as R, size as a, arrow as b, computePosition as c, autoUpdate as d, e, flip as f,
|
|
1968
|
+
export { RovingTabindexController as R, size as a, arrow as b, computePosition as c, autoUpdate as d, e, flip as f, debounce as g, hide as h, flattenObject as i, minBy as m, offset as o, pick as p, round as r, shift as s, throttle as t, uniqBy as u };
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@odx/foundation",
|
|
3
3
|
"displayName": "ODX Design System Foundation",
|
|
4
4
|
"description": "A library of Web Component building blocks for ODX",
|
|
5
|
-
"version": "1.0.0-beta.
|
|
5
|
+
"version": "1.0.0-beta.236",
|
|
6
6
|
"author": "Drägerwerk AG & Co.KGaA",
|
|
7
7
|
"license": "SEE LICENSE IN LICENSE",
|
|
8
8
|
"homepage": "https://odx.draeger.com",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@lit-labs/preact-signals": "1.0.3",
|
|
29
29
|
"@lit-labs/rollup-plugin-minify-html-literals": "0.1.0",
|
|
30
30
|
"@odx/icons": "4.0.0-rc.49",
|
|
31
|
-
"@spectrum-web-components/reactive-controllers": "1.
|
|
31
|
+
"@spectrum-web-components/reactive-controllers": "1.9.0",
|
|
32
32
|
"es-toolkit": "1.40.0",
|
|
33
33
|
"sass-embedded": "1.93.2",
|
|
34
34
|
"stylelint": "16.25.0",
|