@santi020k/lumen-elements 3.0.1 → 4.1.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 +518 -5
- package/dist/bullet-chart-html.d.ts +5 -0
- package/dist/bullet-chart-html.d.ts.map +1 -0
- package/dist/bullet-chart-html.js +56 -0
- package/dist/chart-activation.d.ts +15 -0
- package/dist/chart-activation.d.ts.map +1 -0
- package/dist/chart-activation.js +93 -0
- package/dist/chart-html.d.ts +22 -0
- package/dist/chart-html.d.ts.map +1 -0
- package/dist/chart-html.js +1 -0
- package/dist/comparison-chart-html.d.ts +4 -0
- package/dist/comparison-chart-html.d.ts.map +1 -0
- package/dist/comparison-chart-html.js +36 -0
- package/dist/components/ai-surfaces.d.ts +115 -0
- package/dist/components/ai-surfaces.d.ts.map +1 -0
- package/dist/components/ai-surfaces.js +270 -0
- package/dist/components/button.d.ts +55 -2
- package/dist/components/button.d.ts.map +1 -1
- package/dist/components/button.js +110 -2
- package/dist/components/card.d.ts +6 -0
- package/dist/components/card.d.ts.map +1 -1
- package/dist/components/card.js +6 -1
- package/dist/components/combobox.d.ts +1 -2
- package/dist/components/combobox.d.ts.map +1 -1
- package/dist/components/combobox.js +27 -121
- package/dist/components/dashboard.d.ts +41 -0
- package/dist/components/dashboard.d.ts.map +1 -0
- package/dist/components/dashboard.js +88 -0
- package/dist/components/device-frame.d.ts +31 -0
- package/dist/components/device-frame.d.ts.map +1 -0
- package/dist/components/device-frame.js +95 -0
- package/dist/components/foundations.d.ts +58 -18
- package/dist/components/foundations.d.ts.map +1 -1
- package/dist/components/foundations.js +160 -9
- package/dist/components/image-comparison.d.ts +33 -0
- package/dist/components/image-comparison.d.ts.map +1 -0
- package/dist/components/image-comparison.js +144 -0
- package/dist/components/media-selection.d.ts +41 -0
- package/dist/components/media-selection.d.ts.map +1 -0
- package/dist/components/media-selection.js +114 -0
- package/dist/components/media-viewport.d.ts +30 -0
- package/dist/components/media-viewport.d.ts.map +1 -0
- package/dist/components/media-viewport.js +108 -0
- package/dist/components/virtual-list.d.ts +38 -0
- package/dist/components/virtual-list.d.ts.map +1 -0
- package/dist/components/virtual-list.js +30 -0
- package/dist/components/visual-interactions.d.ts +65 -0
- package/dist/components/visual-interactions.d.ts.map +1 -0
- package/dist/components/visual-interactions.js +91 -0
- package/dist/components/world-map.d.ts +46 -0
- package/dist/components/world-map.d.ts.map +1 -0
- package/dist/components/world-map.js +312 -0
- package/dist/consumer-behaviors.d.ts +36 -0
- package/dist/consumer-behaviors.d.ts.map +1 -0
- package/dist/consumer-behaviors.js +1 -0
- package/dist/define.d.ts +229 -6
- package/dist/define.d.ts.map +1 -1
- package/dist/define.js +1 -1
- package/dist/element-base.js +1 -1
- package/dist/expanded-chart-html.d.ts +9 -0
- package/dist/expanded-chart-html.d.ts.map +1 -0
- package/dist/expanded-chart-html.js +61 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/package.json +34 -6
- package/styles/critical.css +696 -66
|
@@ -1,136 +1,42 @@
|
|
|
1
|
+
import { createLumenComboboxController } from '@santi020k/lumen-core';
|
|
1
2
|
import { defineLumenElement, LumenElement } from '../element-base.js';
|
|
2
3
|
export const lumenComboboxElementConfig = {
|
|
3
4
|
baseClassName: 'ui-combobox',
|
|
4
5
|
defaults: { 'data-ui-combobox': '' },
|
|
5
6
|
tagName: 'lumen-combobox'
|
|
6
7
|
};
|
|
7
|
-
let comboboxId = 0;
|
|
8
|
-
const createComboboxId = () => `ui-combobox-list-${++comboboxId}`;
|
|
9
|
-
const getEventTarget = (event) => {
|
|
10
|
-
const target = event.composedPath()[0] ?? event.target;
|
|
11
|
-
return target instanceof Node ? target : null;
|
|
12
|
-
};
|
|
13
|
-
const getLoopedIndex = (key, currentIndex, itemCount) => {
|
|
14
|
-
if (key === 'Home')
|
|
15
|
-
return 0;
|
|
16
|
-
if (key === 'End')
|
|
17
|
-
return itemCount - 1;
|
|
18
|
-
if (key === 'ArrowDown')
|
|
19
|
-
return (currentIndex + 1) % itemCount;
|
|
20
|
-
return (currentIndex - 1 + itemCount) % itemCount;
|
|
21
|
-
};
|
|
22
8
|
export class LumenComboboxElement extends LumenElement {
|
|
23
9
|
static config = lumenComboboxElementConfig;
|
|
24
|
-
|
|
10
|
+
#controller;
|
|
11
|
+
#observer;
|
|
12
|
+
#input = null;
|
|
13
|
+
#list = null;
|
|
14
|
+
#bind() {
|
|
15
|
+
const input = this.querySelector('input[role="combobox"]');
|
|
16
|
+
const list = this.querySelector('[role="listbox"]');
|
|
17
|
+
if (input === this.#input && list === this.#list)
|
|
18
|
+
return;
|
|
19
|
+
this.#controller?.destroy();
|
|
20
|
+
this.#input = input;
|
|
21
|
+
this.#list = list;
|
|
22
|
+
this.#controller = input && list ? createLumenComboboxController(this) : undefined;
|
|
23
|
+
}
|
|
25
24
|
connectedCallback() {
|
|
26
25
|
super.connectedCallback();
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
this
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
this.#observer?.disconnect();
|
|
27
|
+
this.#bind();
|
|
28
|
+
this.#observer = new MutationObserver(() => {
|
|
29
|
+
this.#bind();
|
|
30
|
+
});
|
|
31
|
+
this.#observer.observe(this, { childList: true, subtree: true });
|
|
32
32
|
}
|
|
33
33
|
disconnectedCallback() {
|
|
34
|
-
this
|
|
35
|
-
this
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (!input || !listbox)
|
|
41
|
-
return;
|
|
42
|
-
const items = [...listbox.querySelectorAll('[role="option"]')];
|
|
43
|
-
if (!listbox.id)
|
|
44
|
-
listbox.id = createComboboxId();
|
|
45
|
-
input.setAttribute('aria-autocomplete', input.getAttribute('aria-autocomplete') ?? 'list');
|
|
46
|
-
input.setAttribute('aria-controls', listbox.id);
|
|
47
|
-
const getVisibleItems = () => items.filter(item => (!item.hidden && !item.hasAttribute('disabled') &&
|
|
48
|
-
item.getAttribute('aria-disabled') !== 'true'));
|
|
49
|
-
const close = () => {
|
|
50
|
-
input.setAttribute('aria-expanded', 'false');
|
|
51
|
-
listbox.hidden = true;
|
|
52
|
-
listbox.dataset.state = 'closed';
|
|
53
|
-
};
|
|
54
|
-
const open = () => {
|
|
55
|
-
input.setAttribute('aria-expanded', 'true');
|
|
56
|
-
listbox.hidden = false;
|
|
57
|
-
listbox.dataset.state = 'open';
|
|
58
|
-
};
|
|
59
|
-
const filter = () => {
|
|
60
|
-
const query = input.value.trim().toLowerCase();
|
|
61
|
-
for (const item of items) {
|
|
62
|
-
const value = item.getAttribute('data-value') ?? item.textContent.trim();
|
|
63
|
-
item.hidden = Boolean(query) && !value.toLowerCase().includes(query);
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
const select = (item) => {
|
|
67
|
-
input.value = item.getAttribute('data-value') ?? item.textContent.trim();
|
|
68
|
-
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
69
|
-
input.dispatchEvent(new Event('change', { bubbles: true }));
|
|
70
|
-
input.focus({ preventScroll: true });
|
|
71
|
-
close();
|
|
72
|
-
};
|
|
73
|
-
const focusItem = (item, key) => {
|
|
74
|
-
const visibleItems = getVisibleItems();
|
|
75
|
-
if (!visibleItems.length)
|
|
76
|
-
return;
|
|
77
|
-
const currentIndex = Math.max(0, visibleItems.indexOf(item));
|
|
78
|
-
visibleItems[getLoopedIndex(key, currentIndex, visibleItems.length)]?.focus();
|
|
79
|
-
};
|
|
80
|
-
close();
|
|
81
|
-
input.addEventListener('focus', open, { signal });
|
|
82
|
-
input.addEventListener('input', () => {
|
|
83
|
-
filter();
|
|
84
|
-
open();
|
|
85
|
-
}, { signal });
|
|
86
|
-
input.addEventListener('keydown', event => {
|
|
87
|
-
if (event.key === 'Escape') {
|
|
88
|
-
close();
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
if (!['ArrowDown', 'ArrowUp', 'Enter'].includes(event.key))
|
|
92
|
-
return;
|
|
93
|
-
const visibleItems = getVisibleItems();
|
|
94
|
-
if (!visibleItems.length)
|
|
95
|
-
return;
|
|
96
|
-
event.preventDefault();
|
|
97
|
-
open();
|
|
98
|
-
if (event.key === 'Enter') {
|
|
99
|
-
const firstVisibleItem = visibleItems.at(0);
|
|
100
|
-
if (firstVisibleItem)
|
|
101
|
-
select(firstVisibleItem);
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
const targetIndex = event.key === 'ArrowUp' ? visibleItems.length - 1 : 0;
|
|
105
|
-
visibleItems[targetIndex]?.focus();
|
|
106
|
-
}, { signal });
|
|
107
|
-
for (const item of items) {
|
|
108
|
-
item.tabIndex = -1;
|
|
109
|
-
item.addEventListener('click', () => {
|
|
110
|
-
select(item);
|
|
111
|
-
}, { signal });
|
|
112
|
-
item.addEventListener('keydown', event => {
|
|
113
|
-
if (event.key === 'Escape') {
|
|
114
|
-
close();
|
|
115
|
-
input.focus({ preventScroll: true });
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
if (event.key === 'Enter' || event.key === ' ') {
|
|
119
|
-
event.preventDefault();
|
|
120
|
-
select(item);
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
if (!['ArrowDown', 'ArrowUp', 'Home', 'End'].includes(event.key))
|
|
124
|
-
return;
|
|
125
|
-
event.preventDefault();
|
|
126
|
-
focusItem(item, event.key);
|
|
127
|
-
}, { signal });
|
|
128
|
-
}
|
|
129
|
-
document.addEventListener('pointerdown', event => {
|
|
130
|
-
const target = getEventTarget(event);
|
|
131
|
-
if (target && !this.contains(target))
|
|
132
|
-
close();
|
|
133
|
-
}, { signal });
|
|
34
|
+
this.#observer?.disconnect();
|
|
35
|
+
this.#observer = undefined;
|
|
36
|
+
this.#controller?.destroy();
|
|
37
|
+
this.#controller = undefined;
|
|
38
|
+
this.#input = null;
|
|
39
|
+
this.#list = null;
|
|
134
40
|
}
|
|
135
41
|
}
|
|
136
42
|
export const defineLumenCombobox = (registry) => {
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type LumenChangeSummaryItem } from '@santi020k/lumen-core';
|
|
2
|
+
import { type LumenCustomElementRegistry, LumenElement } from '../element-base.js';
|
|
3
|
+
export declare const lumenChangeSummaryElementConfig: {
|
|
4
|
+
readonly baseClassName: "ui-change-summary";
|
|
5
|
+
readonly observedAttributes: readonly ["label", "summary", "before-label", "after-label", "changed-label", "unchanged-label"];
|
|
6
|
+
readonly role: "region";
|
|
7
|
+
readonly tagName: "lumen-change-summary";
|
|
8
|
+
};
|
|
9
|
+
export declare class LumenChangeSummaryElement extends LumenElement {
|
|
10
|
+
static config: {
|
|
11
|
+
readonly baseClassName: "ui-change-summary";
|
|
12
|
+
readonly observedAttributes: readonly ["label", "summary", "before-label", "after-label", "changed-label", "unchanged-label"];
|
|
13
|
+
readonly role: "region";
|
|
14
|
+
readonly tagName: "lumen-change-summary";
|
|
15
|
+
};
|
|
16
|
+
private records;
|
|
17
|
+
private content;
|
|
18
|
+
get items(): readonly LumenChangeSummaryItem[];
|
|
19
|
+
set items(value: readonly LumenChangeSummaryItem[]);
|
|
20
|
+
connectedCallback(): void;
|
|
21
|
+
attributeChangedCallback(): void;
|
|
22
|
+
private renderRecord;
|
|
23
|
+
private render;
|
|
24
|
+
}
|
|
25
|
+
export declare const lumenFilterBarElementConfig: {
|
|
26
|
+
readonly baseClassName: "ui-filter-bar";
|
|
27
|
+
readonly observedAttributes: readonly [];
|
|
28
|
+
readonly role: "region";
|
|
29
|
+
readonly tagName: "lumen-filter-bar";
|
|
30
|
+
};
|
|
31
|
+
export declare class LumenFilterBarElement extends LumenElement {
|
|
32
|
+
static config: {
|
|
33
|
+
readonly baseClassName: "ui-filter-bar";
|
|
34
|
+
readonly observedAttributes: readonly [];
|
|
35
|
+
readonly role: "region";
|
|
36
|
+
readonly tagName: "lumen-filter-bar";
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export declare const defineLumenChangeSummary: (registry?: LumenCustomElementRegistry) => void;
|
|
40
|
+
export declare const defineLumenFilterBar: (registry?: LumenCustomElementRegistry) => void;
|
|
41
|
+
//# sourceMappingURL=dashboard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dashboard.d.ts","sourceRoot":"","sources":["../../src/components/dashboard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,sBAAsB,EAA+B,MAAM,uBAAuB,CAAA;AAEhG,OAAO,EAAsB,KAAK,0BAA0B,EAAE,YAAY,EAA2B,MAAM,oBAAoB,CAAA;AAE/H,eAAO,MAAM,+BAA+B;;;;;CAKL,CAAA;AAYvC,qBAAa,yBAA0B,SAAQ,YAAY;IACzD,OAAgB,MAAM;;;;;MAAkC;IACxD,OAAO,CAAC,OAAO,CAA+B;IAC9C,OAAO,CAAC,OAAO,CAA4B;IAE3C,IAAI,KAAK,IAAI,SAAS,sBAAsB,EAAE,CAE7C;IAED,IAAI,KAAK,CAAC,KAAK,EAAE,SAAS,sBAAsB,EAAE,EAIjD;IAEQ,iBAAiB,IAAI,IAAI;IAMzB,wBAAwB,IAAI,IAAI;IAMzC,OAAO,CAAC,YAAY;IA0BpB,OAAO,CAAC,MAAM;CA0Bf;AAGD,eAAO,MAAM,2BAA2B;;;;;CAKD,CAAA;AAEvC,qBAAa,qBAAsB,SAAQ,YAAY;IACrD,OAAgB,MAAM;;;;;MAA8B;CACrD;AAED,eAAO,MAAM,wBAAwB,GAAI,WAAW,0BAA0B,KAAG,IAEhF,CAAA;AACD,eAAO,MAAM,oBAAoB,GAAI,WAAW,0BAA0B,KAAG,IAE5E,CAAA"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { readLumenChangeSummaryItems } from '@santi020k/lumen-core';
|
|
2
|
+
import { defineLumenElement, LumenElement } from '../element-base.js';
|
|
3
|
+
export const lumenChangeSummaryElementConfig = {
|
|
4
|
+
baseClassName: 'ui-change-summary',
|
|
5
|
+
observedAttributes: ['label', 'summary', 'before-label', 'after-label', 'changed-label', 'unchanged-label'],
|
|
6
|
+
role: 'region',
|
|
7
|
+
tagName: 'lumen-change-summary'
|
|
8
|
+
};
|
|
9
|
+
const textNode = (document, tag, text, className) => {
|
|
10
|
+
const node = document.createElement(tag);
|
|
11
|
+
node.textContent = text;
|
|
12
|
+
if (className)
|
|
13
|
+
node.className = className;
|
|
14
|
+
return node;
|
|
15
|
+
};
|
|
16
|
+
export class LumenChangeSummaryElement extends LumenElement {
|
|
17
|
+
static config = lumenChangeSummaryElementConfig;
|
|
18
|
+
records = [];
|
|
19
|
+
content;
|
|
20
|
+
get items() {
|
|
21
|
+
return this.records.map(item => ({ ...item }));
|
|
22
|
+
}
|
|
23
|
+
set items(value) {
|
|
24
|
+
this.records = readLumenChangeSummaryItems(value);
|
|
25
|
+
if (this.isConnected)
|
|
26
|
+
this.render();
|
|
27
|
+
}
|
|
28
|
+
connectedCallback() {
|
|
29
|
+
super.connectedCallback();
|
|
30
|
+
this.render();
|
|
31
|
+
}
|
|
32
|
+
attributeChangedCallback() {
|
|
33
|
+
super.attributeChangedCallback();
|
|
34
|
+
if (this.isConnected)
|
|
35
|
+
this.render();
|
|
36
|
+
}
|
|
37
|
+
renderRecord(item) {
|
|
38
|
+
const document = this.ownerDocument;
|
|
39
|
+
const row = document.createElement('div');
|
|
40
|
+
const term = textNode(document, 'dt', item.label);
|
|
41
|
+
row.className = 'ui-change-summary__item';
|
|
42
|
+
row.dataset.changed = String(item.changed);
|
|
43
|
+
term.append(textNode(document, 'span', this.getAttribute(item.changed ? 'changed-label' : 'unchanged-label') ??
|
|
44
|
+
(item.changed ? 'Changed' : 'Unchanged'), 'ui-change-summary__state'));
|
|
45
|
+
row.append(term);
|
|
46
|
+
for (const [name, value] of [['before', item.before], ['after', item.after]]) {
|
|
47
|
+
const detail = document.createElement('dd');
|
|
48
|
+
detail.append(textNode(document, 'span', this.getAttribute(`${name}-label`) ??
|
|
49
|
+
(name === 'before' ? 'Before' : 'After'), 'ui-change-summary__value-label'), document.createTextNode(value));
|
|
50
|
+
row.append(detail);
|
|
51
|
+
}
|
|
52
|
+
return row;
|
|
53
|
+
}
|
|
54
|
+
render() {
|
|
55
|
+
const document = this.ownerDocument;
|
|
56
|
+
const label = this.getAttribute('label') ?? 'Changes';
|
|
57
|
+
const content = this.content ?? document.createElement('div');
|
|
58
|
+
const list = document.createElement('dl');
|
|
59
|
+
const heading = textNode(document, 'h3', label, 'ui-change-summary__heading');
|
|
60
|
+
const summary = this.getAttribute('summary');
|
|
61
|
+
content.className = 'ui-change-summary';
|
|
62
|
+
this.setAttribute('aria-label', label);
|
|
63
|
+
list.className = 'ui-change-summary__list';
|
|
64
|
+
list.append(...this.records.map(item => this.renderRecord(item)));
|
|
65
|
+
content.replaceChildren(heading);
|
|
66
|
+
if (summary)
|
|
67
|
+
content.append(textNode(document, 'p', summary, 'ui-change-summary__summary'));
|
|
68
|
+
content.append(list);
|
|
69
|
+
if (!this.content)
|
|
70
|
+
this.prepend(content);
|
|
71
|
+
this.content = content;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export const lumenFilterBarElementConfig = {
|
|
75
|
+
baseClassName: 'ui-filter-bar',
|
|
76
|
+
observedAttributes: [],
|
|
77
|
+
role: 'region',
|
|
78
|
+
tagName: 'lumen-filter-bar'
|
|
79
|
+
};
|
|
80
|
+
export class LumenFilterBarElement extends LumenElement {
|
|
81
|
+
static config = lumenFilterBarElementConfig;
|
|
82
|
+
}
|
|
83
|
+
export const defineLumenChangeSummary = (registry) => {
|
|
84
|
+
defineLumenElement(lumenChangeSummaryElementConfig, LumenChangeSummaryElement, registry);
|
|
85
|
+
};
|
|
86
|
+
export const defineLumenFilterBar = (registry) => {
|
|
87
|
+
defineLumenElement(lumenFilterBarElementConfig, LumenFilterBarElement, registry);
|
|
88
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type LumenCustomElementRegistry, LumenElement } from '../element-base.js';
|
|
2
|
+
export declare const lumenDeviceFrameElementConfig: {
|
|
3
|
+
readonly baseClassName: "ui-device-frame";
|
|
4
|
+
readonly defaults: {
|
|
5
|
+
readonly 'data-device': "laptop";
|
|
6
|
+
readonly 'data-tone': "dark";
|
|
7
|
+
};
|
|
8
|
+
readonly observedAttributes: readonly ["device", "orientation", "tone", "color", "screen-width", "screen-height", "scroll"];
|
|
9
|
+
readonly tagName: "lumen-device-frame";
|
|
10
|
+
};
|
|
11
|
+
export declare class LumenDeviceFrameElement extends LumenElement {
|
|
12
|
+
static config: {
|
|
13
|
+
readonly baseClassName: "ui-device-frame";
|
|
14
|
+
readonly defaults: {
|
|
15
|
+
readonly 'data-device': "laptop";
|
|
16
|
+
readonly 'data-tone': "dark";
|
|
17
|
+
};
|
|
18
|
+
readonly observedAttributes: readonly ["device", "orientation", "tone", "color", "screen-width", "screen-height", "scroll"];
|
|
19
|
+
readonly tagName: "lumen-device-frame";
|
|
20
|
+
};
|
|
21
|
+
private screen;
|
|
22
|
+
private cleanup;
|
|
23
|
+
private colorOverride;
|
|
24
|
+
connectedCallback(): void;
|
|
25
|
+
attributeChangedCallback(): void;
|
|
26
|
+
disconnectedCallback(): void;
|
|
27
|
+
private update;
|
|
28
|
+
private updateColor;
|
|
29
|
+
}
|
|
30
|
+
export declare const defineLumenDeviceFrame: (registry?: LumenCustomElementRegistry) => void;
|
|
31
|
+
//# sourceMappingURL=device-frame.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"device-frame.d.ts","sourceRoot":"","sources":["../../src/components/device-frame.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsB,KAAK,0BAA0B,EAAE,YAAY,EAA2B,MAAM,oBAAoB,CAAA;AAI/H,eAAO,MAAM,6BAA6B;;;;;;;;CAKH,CAAA;AAEvC,qBAAa,uBAAwB,SAAQ,YAAY;IACvD,OAAgB,MAAM;;;;;;;;MAAgC;IACtD,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,OAAO,CAA0B;IACzC,OAAO,CAAC,aAAa,CAAiD;IAE7D,iBAAiB,IAAI,IAAI;IAmDzB,wBAAwB,IAAI,IAAI;IAMhC,oBAAoB,IAAI,IAAI;IAMrC,OAAO,CAAC,MAAM;IAiCd,OAAO,CAAC,WAAW;CAgBpB;AAED,eAAO,MAAM,sBAAsB,GAAI,WAAW,0BAA0B,KAAG,IAE9E,CAAA"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { lumenDeviceFrameSizes, observeLumenDeviceFrame, resolveLumenDeviceFrame, resolveLumenDeviceFrameColor } from '@santi020k/lumen-core';
|
|
2
|
+
import { defineLumenElement, LumenElement } from '../element-base.js';
|
|
3
|
+
const isDevice = (name) => name !== null && Object.hasOwn(lumenDeviceFrameSizes, name);
|
|
4
|
+
export const lumenDeviceFrameElementConfig = {
|
|
5
|
+
baseClassName: 'ui-device-frame',
|
|
6
|
+
defaults: { 'data-device': 'laptop', 'data-tone': 'dark' },
|
|
7
|
+
observedAttributes: ['device', 'orientation', 'tone', 'color', 'screen-width', 'screen-height', 'scroll'],
|
|
8
|
+
tagName: 'lumen-device-frame'
|
|
9
|
+
};
|
|
10
|
+
export class LumenDeviceFrameElement extends LumenElement {
|
|
11
|
+
static config = lumenDeviceFrameElementConfig;
|
|
12
|
+
screen;
|
|
13
|
+
cleanup;
|
|
14
|
+
colorOverride;
|
|
15
|
+
connectedCallback() {
|
|
16
|
+
super.connectedCallback();
|
|
17
|
+
if (!this.screen) {
|
|
18
|
+
const shell = this.ownerDocument.createElement('div');
|
|
19
|
+
const glass = this.ownerDocument.createElement('div');
|
|
20
|
+
const camera = this.ownerDocument.createElement('span');
|
|
21
|
+
const screen = this.ownerDocument.createElement('div');
|
|
22
|
+
const base = this.ownerDocument.createElement('span');
|
|
23
|
+
const hardware = this.ownerDocument.createElement('span');
|
|
24
|
+
hardware.className = 'ui-device-frame__hardware';
|
|
25
|
+
hardware.setAttribute('aria-hidden', 'true');
|
|
26
|
+
for (const part of ['action', 'volume-up', 'volume-down', 'power', 'rail-left', 'rail-right']) {
|
|
27
|
+
const detail = this.ownerDocument.createElement('span');
|
|
28
|
+
detail.className = `ui-device-frame__${part}`;
|
|
29
|
+
hardware.append(detail);
|
|
30
|
+
}
|
|
31
|
+
shell.className = 'ui-device-frame__shell';
|
|
32
|
+
glass.className = 'ui-device-frame__glass';
|
|
33
|
+
camera.className = 'ui-device-frame__camera';
|
|
34
|
+
camera.setAttribute('aria-hidden', 'true');
|
|
35
|
+
screen.className = 'ui-device-frame__screen';
|
|
36
|
+
base.className = 'ui-device-frame__base';
|
|
37
|
+
base.setAttribute('aria-hidden', 'true');
|
|
38
|
+
screen.append(...this.childNodes);
|
|
39
|
+
glass.append(camera, screen);
|
|
40
|
+
shell.append(hardware, glass);
|
|
41
|
+
this.append(shell, base);
|
|
42
|
+
this.screen = screen;
|
|
43
|
+
}
|
|
44
|
+
this.update();
|
|
45
|
+
}
|
|
46
|
+
attributeChangedCallback() {
|
|
47
|
+
super.attributeChangedCallback();
|
|
48
|
+
if (this.isConnected)
|
|
49
|
+
this.update();
|
|
50
|
+
}
|
|
51
|
+
disconnectedCallback() {
|
|
52
|
+
this.cleanup?.();
|
|
53
|
+
this.cleanup = undefined;
|
|
54
|
+
}
|
|
55
|
+
update() {
|
|
56
|
+
const screen = this.screen;
|
|
57
|
+
if (!screen)
|
|
58
|
+
return;
|
|
59
|
+
const rawDevice = this.getAttribute('device');
|
|
60
|
+
const device = isDevice(rawDevice) ? rawDevice : 'laptop';
|
|
61
|
+
const rawOrientation = this.getAttribute('orientation');
|
|
62
|
+
const orientation = rawOrientation === 'portrait' || rawOrientation === 'landscape' ? rawOrientation : undefined;
|
|
63
|
+
const size = resolveLumenDeviceFrame(device, orientation, Number(this.getAttribute('screen-width')), Number(this.getAttribute('screen-height')));
|
|
64
|
+
this.dataset.device = device;
|
|
65
|
+
this.dataset.tone = this.getAttribute('tone') === 'light' ? 'light' : 'dark';
|
|
66
|
+
if (orientation)
|
|
67
|
+
this.dataset.orientation = orientation;
|
|
68
|
+
else
|
|
69
|
+
delete this.dataset.orientation;
|
|
70
|
+
this.updateColor();
|
|
71
|
+
screen.dataset.scroll = String(this.getAttribute('scroll') !== 'false');
|
|
72
|
+
screen.style.aspectRatio = `${size.width} / ${size.height}`;
|
|
73
|
+
screen.style.setProperty('--ui-device-frame-width', `${size.width}px`);
|
|
74
|
+
screen.style.setProperty('--ui-device-frame-height', `${size.height}px`);
|
|
75
|
+
this.cleanup?.();
|
|
76
|
+
this.cleanup = observeLumenDeviceFrame(screen, size.width);
|
|
77
|
+
}
|
|
78
|
+
updateColor() {
|
|
79
|
+
const color = resolveLumenDeviceFrameColor(this.getAttribute('color'));
|
|
80
|
+
if (color) {
|
|
81
|
+
this.colorOverride ??= {
|
|
82
|
+
value: this.style.getPropertyValue('--ui-device-color'),
|
|
83
|
+
priority: this.style.getPropertyPriority('--ui-device-color')
|
|
84
|
+
};
|
|
85
|
+
this.style.setProperty('--ui-device-color', color);
|
|
86
|
+
}
|
|
87
|
+
else if (this.colorOverride) {
|
|
88
|
+
this.style.setProperty('--ui-device-color', this.colorOverride.value, this.colorOverride.priority);
|
|
89
|
+
this.colorOverride = undefined;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
export const defineLumenDeviceFrame = (registry) => {
|
|
94
|
+
defineLumenElement(lumenDeviceFrameElementConfig, LumenDeviceFrameElement, registry);
|
|
95
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type LumenCustomElementRegistry } from '../element-base.js';
|
|
1
|
+
import { type LumenCustomElementRegistry, type LumenElementConstructor } from '../element-base.js';
|
|
2
2
|
export declare const lumenCardContentElementConfig: {
|
|
3
3
|
readonly baseClassName: "ui-card__content";
|
|
4
4
|
readonly defaults: {
|
|
@@ -69,6 +69,12 @@ export declare const lumenGridElementConfig: {
|
|
|
69
69
|
readonly auto: "ui-grid--columns-auto";
|
|
70
70
|
};
|
|
71
71
|
readonly gap: {
|
|
72
|
+
readonly '2xl': "ui-grid--gap-2xl";
|
|
73
|
+
readonly '3xl': "ui-grid--gap-3xl";
|
|
74
|
+
readonly group: "ui-grid--gap-group";
|
|
75
|
+
readonly related: "ui-grid--gap-related";
|
|
76
|
+
readonly section: "ui-grid--gap-section";
|
|
77
|
+
readonly xs: "ui-grid--gap-xs";
|
|
72
78
|
readonly lg: "ui-grid--gap-lg";
|
|
73
79
|
readonly md: "ui-grid--gap-md";
|
|
74
80
|
readonly none: "ui-grid--gap-none";
|
|
@@ -80,7 +86,7 @@ export declare const lumenGridElementConfig: {
|
|
|
80
86
|
readonly defaults: {
|
|
81
87
|
readonly 'data-ui-grid': "";
|
|
82
88
|
readonly columns: "auto";
|
|
83
|
-
readonly gap: "
|
|
89
|
+
readonly gap: "group";
|
|
84
90
|
};
|
|
85
91
|
readonly tagName: "lumen-grid";
|
|
86
92
|
};
|
|
@@ -102,20 +108,54 @@ export declare const lumenSeparatorElementConfig: {
|
|
|
102
108
|
readonly tagName: "lumen-separator";
|
|
103
109
|
};
|
|
104
110
|
export declare const lumenSkeletonElementConfig: {
|
|
111
|
+
readonly attributeClasses: {
|
|
112
|
+
readonly animation: {
|
|
113
|
+
readonly none: "ui-skeleton--static";
|
|
114
|
+
readonly pulse: "ui-skeleton--pulse";
|
|
115
|
+
};
|
|
116
|
+
readonly shape: {
|
|
117
|
+
readonly circle: "ui-skeleton--circle";
|
|
118
|
+
readonly text: "ui-skeleton--text";
|
|
119
|
+
};
|
|
120
|
+
};
|
|
105
121
|
readonly baseClassName: "ui-skeleton";
|
|
122
|
+
readonly observedAttributes: readonly ["animation", "height", "shape", "width", "aria-hidden", "aria-label", "aria-labelledby", "role"];
|
|
106
123
|
readonly tagName: "lumen-skeleton";
|
|
107
124
|
};
|
|
108
125
|
export declare const lumenSpinnerElementConfig: {
|
|
109
126
|
readonly baseClassName: "ui-spinner";
|
|
127
|
+
readonly observedAttributes: readonly ["aria-hidden", "aria-label", "aria-labelledby", "role"];
|
|
110
128
|
readonly tagName: "lumen-spinner";
|
|
111
129
|
};
|
|
112
130
|
export declare const lumenStackElementConfig: {
|
|
113
131
|
readonly attributeClasses: {
|
|
132
|
+
readonly align: {
|
|
133
|
+
readonly center: "ui-stack--align-center";
|
|
134
|
+
readonly end: "ui-stack--align-end";
|
|
135
|
+
readonly start: "ui-stack--align-start";
|
|
136
|
+
readonly stretch: "ui-stack--align-stretch";
|
|
137
|
+
};
|
|
114
138
|
readonly direction: {
|
|
115
139
|
readonly horizontal: "ui-stack--horizontal";
|
|
116
140
|
readonly vertical: "ui-stack--vertical";
|
|
117
141
|
};
|
|
142
|
+
readonly justify: {
|
|
143
|
+
readonly between: "ui-stack--justify-between";
|
|
144
|
+
readonly center: "ui-stack--justify-center";
|
|
145
|
+
readonly end: "ui-stack--justify-end";
|
|
146
|
+
readonly start: "ui-stack--justify-start";
|
|
147
|
+
};
|
|
148
|
+
readonly wrap: {
|
|
149
|
+
readonly '': "ui-stack--wrap";
|
|
150
|
+
readonly true: "ui-stack--wrap";
|
|
151
|
+
};
|
|
118
152
|
readonly gap: {
|
|
153
|
+
readonly '2xl': "ui-stack--gap-2xl";
|
|
154
|
+
readonly '3xl': "ui-stack--gap-3xl";
|
|
155
|
+
readonly group: "ui-stack--gap-group";
|
|
156
|
+
readonly related: "ui-stack--gap-related";
|
|
157
|
+
readonly section: "ui-stack--gap-section";
|
|
158
|
+
readonly xs: "ui-stack--gap-xs";
|
|
119
159
|
readonly lg: "ui-stack--gap-lg";
|
|
120
160
|
readonly md: "ui-stack--gap-md";
|
|
121
161
|
readonly none: "ui-stack--gap-none";
|
|
@@ -127,7 +167,7 @@ export declare const lumenStackElementConfig: {
|
|
|
127
167
|
readonly defaults: {
|
|
128
168
|
readonly 'data-ui-stack': "";
|
|
129
169
|
readonly direction: "vertical";
|
|
130
|
-
readonly gap: "
|
|
170
|
+
readonly gap: "group";
|
|
131
171
|
};
|
|
132
172
|
readonly tagName: "lumen-stack";
|
|
133
173
|
};
|
|
@@ -142,20 +182,20 @@ export declare const lumenVisuallyHiddenElementConfig: {
|
|
|
142
182
|
};
|
|
143
183
|
readonly tagName: "lumen-visually-hidden";
|
|
144
184
|
};
|
|
145
|
-
export declare const LumenCardContentElement:
|
|
146
|
-
export declare const LumenCardDescriptionElement:
|
|
147
|
-
export declare const LumenCardFooterElement:
|
|
148
|
-
export declare const LumenCardHeaderElement:
|
|
149
|
-
export declare const LumenCardTitleElement:
|
|
150
|
-
export declare const LumenContainerElement:
|
|
151
|
-
export declare const LumenDirectionElement:
|
|
152
|
-
export declare const LumenGridElement:
|
|
153
|
-
export declare const LumenLabelElement:
|
|
154
|
-
export declare const LumenSeparatorElement:
|
|
155
|
-
export declare const LumenSkeletonElement:
|
|
156
|
-
export declare const LumenSpinnerElement:
|
|
157
|
-
export declare const LumenStackElement:
|
|
158
|
-
export declare const LumenTypographyElement:
|
|
159
|
-
export declare const LumenVisuallyHiddenElement:
|
|
185
|
+
export declare const LumenCardContentElement: LumenElementConstructor;
|
|
186
|
+
export declare const LumenCardDescriptionElement: LumenElementConstructor;
|
|
187
|
+
export declare const LumenCardFooterElement: LumenElementConstructor;
|
|
188
|
+
export declare const LumenCardHeaderElement: LumenElementConstructor;
|
|
189
|
+
export declare const LumenCardTitleElement: LumenElementConstructor;
|
|
190
|
+
export declare const LumenContainerElement: LumenElementConstructor;
|
|
191
|
+
export declare const LumenDirectionElement: LumenElementConstructor;
|
|
192
|
+
export declare const LumenGridElement: LumenElementConstructor;
|
|
193
|
+
export declare const LumenLabelElement: LumenElementConstructor;
|
|
194
|
+
export declare const LumenSeparatorElement: LumenElementConstructor;
|
|
195
|
+
export declare const LumenSkeletonElement: LumenElementConstructor;
|
|
196
|
+
export declare const LumenSpinnerElement: LumenElementConstructor;
|
|
197
|
+
export declare const LumenStackElement: LumenElementConstructor;
|
|
198
|
+
export declare const LumenTypographyElement: LumenElementConstructor;
|
|
199
|
+
export declare const LumenVisuallyHiddenElement: LumenElementConstructor;
|
|
160
200
|
export declare const defineLumenFoundations: (registry?: LumenCustomElementRegistry) => void;
|
|
161
201
|
//# sourceMappingURL=foundations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"foundations.d.ts","sourceRoot":"","sources":["../../src/components/foundations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"foundations.d.ts","sourceRoot":"","sources":["../../src/components/foundations.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,0BAA0B,EAG/B,KAAK,uBAAuB,EAC7B,MAAM,oBAAoB,CAAA;AAuK3B,eAAO,MAAM,6BAA6B;;;;;;CAIH,CAAA;AAEvC,eAAO,MAAM,iCAAiC;;;;;;CAIP,CAAA;AAEvC,eAAO,MAAM,4BAA4B;;;;;;CAIF,CAAA;AAEvC,eAAO,MAAM,4BAA4B;;;;;;CAIF,CAAA;AAEvC,eAAO,MAAM,2BAA2B;;;;;;CAID,CAAA;AAEvC,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;CAYD,CAAA;AAEvC,eAAO,MAAM,2BAA2B;;;;;;CAID,CAAA;AAEvC,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BI,CAAA;AAEvC,eAAO,MAAM,uBAAuB;;;CAGG,CAAA;AAEvC,eAAO,MAAM,2BAA2B;;;;;;;;;;;;CAUD,CAAA;AAEvC,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;CAQA,CAAA;AAEvC,eAAO,MAAM,yBAAyB;;;;CAIC,CAAA;AAEvC,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoCG,CAAA;AAEvC,eAAO,MAAM,4BAA4B;;;CAGF,CAAA;AAEvC,eAAO,MAAM,gCAAgC;;;;;;CAIN,CAAA;AA+BvC,eAAO,MAAM,uBAAuB,yBAAsB,CAAA;AAC1D,eAAO,MAAM,2BAA2B,yBAA0B,CAAA;AAClE,eAAO,MAAM,sBAAsB,yBAAqB,CAAA;AACxD,eAAO,MAAM,sBAAsB,yBAAqB,CAAA;AACxD,eAAO,MAAM,qBAAqB,yBAAoB,CAAA;AACtD,eAAO,MAAM,qBAAqB,yBAAoB,CAAA;AACtD,eAAO,MAAM,qBAAqB,yBAAoB,CAAA;AACtD,eAAO,MAAM,gBAAgB,yBAAe,CAAA;AAC5C,eAAO,MAAM,iBAAiB,yBAAgB,CAAA;AAC9C,eAAO,MAAM,qBAAqB,yBAAoB,CAAA;AACtD,eAAO,MAAM,oBAAoB,yBAAmB,CAAA;AACpD,eAAO,MAAM,mBAAmB,yBAAkB,CAAA;AAClD,eAAO,MAAM,iBAAiB,yBAAgB,CAAA;AAC9C,eAAO,MAAM,sBAAsB,yBAAqB,CAAA;AACxD,eAAO,MAAM,0BAA0B,yBAAyB,CAAA;AAoBhE,eAAO,MAAM,sBAAsB,GACjC,WAAW,0BAA0B,KACpC,IAIF,CAAA"}
|