@santi020k/lumen-elements 3.0.0 → 4.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.
Files changed (66) hide show
  1. package/README.md +497 -5
  2. package/dist/bullet-chart-html.d.ts +5 -0
  3. package/dist/bullet-chart-html.d.ts.map +1 -0
  4. package/dist/bullet-chart-html.js +56 -0
  5. package/dist/chart-activation.d.ts +15 -0
  6. package/dist/chart-activation.d.ts.map +1 -0
  7. package/dist/chart-activation.js +93 -0
  8. package/dist/chart-html.d.ts +22 -0
  9. package/dist/chart-html.d.ts.map +1 -0
  10. package/dist/chart-html.js +1 -0
  11. package/dist/comparison-chart-html.d.ts +4 -0
  12. package/dist/comparison-chart-html.d.ts.map +1 -0
  13. package/dist/comparison-chart-html.js +36 -0
  14. package/dist/components/ai-surfaces.d.ts +115 -0
  15. package/dist/components/ai-surfaces.d.ts.map +1 -0
  16. package/dist/components/ai-surfaces.js +270 -0
  17. package/dist/components/button.d.ts +51 -2
  18. package/dist/components/button.d.ts.map +1 -1
  19. package/dist/components/button.js +81 -2
  20. package/dist/components/card.d.ts +6 -0
  21. package/dist/components/card.d.ts.map +1 -1
  22. package/dist/components/card.js +6 -1
  23. package/dist/components/combobox.d.ts +1 -2
  24. package/dist/components/combobox.d.ts.map +1 -1
  25. package/dist/components/combobox.js +27 -121
  26. package/dist/components/dashboard.d.ts +41 -0
  27. package/dist/components/dashboard.d.ts.map +1 -0
  28. package/dist/components/dashboard.js +88 -0
  29. package/dist/components/device-frame.d.ts +31 -0
  30. package/dist/components/device-frame.d.ts.map +1 -0
  31. package/dist/components/device-frame.js +95 -0
  32. package/dist/components/foundations.d.ts +30 -2
  33. package/dist/components/foundations.d.ts.map +1 -1
  34. package/dist/components/foundations.js +27 -2
  35. package/dist/components/image-comparison.d.ts +33 -0
  36. package/dist/components/image-comparison.d.ts.map +1 -0
  37. package/dist/components/image-comparison.js +144 -0
  38. package/dist/components/media-selection.d.ts +41 -0
  39. package/dist/components/media-selection.d.ts.map +1 -0
  40. package/dist/components/media-selection.js +114 -0
  41. package/dist/components/media-viewport.d.ts +30 -0
  42. package/dist/components/media-viewport.d.ts.map +1 -0
  43. package/dist/components/media-viewport.js +108 -0
  44. package/dist/components/virtual-list.d.ts +38 -0
  45. package/dist/components/virtual-list.d.ts.map +1 -0
  46. package/dist/components/virtual-list.js +30 -0
  47. package/dist/components/visual-interactions.d.ts +65 -0
  48. package/dist/components/visual-interactions.d.ts.map +1 -0
  49. package/dist/components/visual-interactions.js +91 -0
  50. package/dist/components/world-map.d.ts +46 -0
  51. package/dist/components/world-map.d.ts.map +1 -0
  52. package/dist/components/world-map.js +312 -0
  53. package/dist/consumer-behaviors.d.ts +36 -0
  54. package/dist/consumer-behaviors.d.ts.map +1 -0
  55. package/dist/consumer-behaviors.js +1 -0
  56. package/dist/define.d.ts +229 -6
  57. package/dist/define.d.ts.map +1 -1
  58. package/dist/define.js +1 -1
  59. package/dist/element-base.js +1 -1
  60. package/dist/expanded-chart-html.d.ts +9 -0
  61. package/dist/expanded-chart-html.d.ts.map +1 -0
  62. package/dist/expanded-chart-html.js +61 -0
  63. package/dist/index.d.ts +2 -1
  64. package/dist/index.d.ts.map +1 -1
  65. package/package.json +34 -6
  66. package/styles/critical.css +634 -61
@@ -0,0 +1 @@
1
+ {"version":3,"file":"virtual-list.d.ts","sourceRoot":"","sources":["../../src/components/virtual-list.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,0BAA0B,EAC/B,YAAY,EAEb,MAAM,oBAAoB,CAAA;AAE3B,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;CAWH,CAAA;AAEvC,qBAAa,uBAAwB,SAAQ,YAAY;IACvD,OAAgB,MAAM;;;;;;;;;;;;;;MAAgC;IAEtD,OAAO,CAAC,UAAU,CAAwC;IAEjD,iBAAiB,IAAI,IAAI;IAQzB,oBAAoB,IAAI,IAAI;CAKtC;AAED,eAAO,MAAM,sBAAsB,GAAI,WAAW,0BAA0B,KAAG,IAE9E,CAAA"}
@@ -0,0 +1,30 @@
1
+ import { createLumenVirtualListController } from '@santi020k/lumen-core/virtual-list';
2
+ import { defineLumenElement, LumenElement } from '../element-base.js';
3
+ export const lumenVirtualListElementConfig = {
4
+ attributeClasses: {
5
+ glass: {
6
+ true: 'ui-virtual-list--glass',
7
+ subtle: 'ui-virtual-list--glass ui-glass-subtle',
8
+ strong: 'ui-virtual-list--glass ui-glass-strong'
9
+ }
10
+ },
11
+ baseClassName: 'ui-virtual-list',
12
+ defaults: { 'data-ui-virtual-list': '', tabindex: '0' },
13
+ tagName: 'lumen-virtual-list'
14
+ };
15
+ export class LumenVirtualListElement extends LumenElement {
16
+ static config = lumenVirtualListElementConfig;
17
+ controller;
18
+ connectedCallback() {
19
+ super.connectedCallback();
20
+ this.controller?.destroy();
21
+ this.controller = createLumenVirtualListController(this);
22
+ }
23
+ disconnectedCallback() {
24
+ this.controller?.destroy();
25
+ this.controller = undefined;
26
+ }
27
+ }
28
+ export const defineLumenVirtualList = (registry) => {
29
+ defineLumenElement(lumenVirtualListElementConfig, LumenVirtualListElement, registry);
30
+ };
@@ -0,0 +1,65 @@
1
+ import { LumenElement } from '../element-base.js';
2
+ export declare const lumenMotionGroupElementConfig: {
3
+ readonly baseClassName: "ui-motion-group";
4
+ readonly defaults: {
5
+ readonly 'data-ui-motion-group': "";
6
+ };
7
+ readonly observedAttributes: readonly ["duration", "enter-exit"];
8
+ readonly tagName: "lumen-motion-group";
9
+ };
10
+ export declare class LumenMotionGroupElement extends LumenElement {
11
+ static config: {
12
+ readonly baseClassName: "ui-motion-group";
13
+ readonly defaults: {
14
+ readonly 'data-ui-motion-group': "";
15
+ };
16
+ readonly observedAttributes: readonly ["duration", "enter-exit"];
17
+ readonly tagName: "lumen-motion-group";
18
+ };
19
+ private cleanup;
20
+ connectedCallback(): void;
21
+ disconnectedCallback(): void;
22
+ attributeChangedCallback(): void;
23
+ private bind;
24
+ }
25
+ export declare const lumenChartMotionElementConfig: {
26
+ readonly baseClassName: "ui-chart-motion";
27
+ readonly defaults: {
28
+ readonly 'data-ui-chart-motion': "";
29
+ };
30
+ readonly observedAttributes: readonly ["duration"];
31
+ readonly tagName: "lumen-chart-motion";
32
+ };
33
+ export declare class LumenChartMotionElement extends LumenElement {
34
+ static config: {
35
+ readonly baseClassName: "ui-chart-motion";
36
+ readonly defaults: {
37
+ readonly 'data-ui-chart-motion': "";
38
+ };
39
+ readonly observedAttributes: readonly ["duration"];
40
+ readonly tagName: "lumen-chart-motion";
41
+ };
42
+ private cleanup;
43
+ connectedCallback(): void;
44
+ disconnectedCallback(): void;
45
+ attributeChangedCallback(): void;
46
+ private bind;
47
+ }
48
+ export declare const lumenVisualEffectElementConfig: {
49
+ readonly baseClassName: "ui-visual-effect";
50
+ readonly observedAttributes: readonly ["variant", "animated", "intensity"];
51
+ readonly tagName: "lumen-visual-effect";
52
+ };
53
+ export declare class LumenVisualEffectElement extends LumenElement {
54
+ static config: {
55
+ readonly baseClassName: "ui-visual-effect";
56
+ readonly observedAttributes: readonly ["variant", "animated", "intensity"];
57
+ readonly tagName: "lumen-visual-effect";
58
+ };
59
+ private cleanup;
60
+ connectedCallback(): void;
61
+ disconnectedCallback(): void;
62
+ attributeChangedCallback(): void;
63
+ private update;
64
+ }
65
+ //# sourceMappingURL=visual-interactions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"visual-interactions.d.ts","sourceRoot":"","sources":["../../src/components/visual-interactions.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,YAAY,EAA2B,MAAM,oBAAoB,CAAA;AAE1E,eAAO,MAAM,6BAA6B;;;;;;;CAKH,CAAA;AAEvC,qBAAa,uBAAwB,SAAQ,YAAY;IACvD,OAAgB,MAAM;;;;;;;MAAgC;IACtD,OAAO,CAAC,OAAO,CAA0B;IAEhC,iBAAiB,IAAI,IAAI;IAMzB,oBAAoB,IAAI,IAAI;IAM5B,wBAAwB,IAAI,IAAI;IAMzC,OAAO,CAAC,IAAI;CAQb;AAED,eAAO,MAAM,6BAA6B;;;;;;;CAKH,CAAA;AAEvC,qBAAa,uBAAwB,SAAQ,YAAY;IACvD,OAAgB,MAAM;;;;;;;MAAgC;IACtD,OAAO,CAAC,OAAO,CAA0B;IAChC,iBAAiB,IAAI,IAAI;IAMzB,oBAAoB,IAAI,IAAI;IAM5B,wBAAwB,IAAI,IAAI;IAMzC,OAAO,CAAC,IAAI;CAOb;AAED,eAAO,MAAM,8BAA8B;;;;CAIJ,CAAA;AAEvC,qBAAa,wBAAyB,SAAQ,YAAY;IACxD,OAAgB,MAAM;;;;MAAiC;IACvD,OAAO,CAAC,OAAO,CAA0B;IAEhC,iBAAiB,IAAI,IAAI;IAMzB,oBAAoB,IAAI,IAAI;IAM5B,wBAAwB,IAAI,IAAI;IAMzC,OAAO,CAAC,MAAM;CAef"}
@@ -0,0 +1,91 @@
1
+ import { bindLumenChartMotion, bindLumenMotionGroup, createLumenSpotlightController, normalizeLumenEffectIntensity } from '@santi020k/lumen-core';
2
+ import { LumenElement } from '../element-base.js';
3
+ export const lumenMotionGroupElementConfig = {
4
+ baseClassName: 'ui-motion-group',
5
+ defaults: { 'data-ui-motion-group': '' },
6
+ observedAttributes: ['duration', 'enter-exit'],
7
+ tagName: 'lumen-motion-group'
8
+ };
9
+ export class LumenMotionGroupElement extends LumenElement {
10
+ static config = lumenMotionGroupElementConfig;
11
+ cleanup;
12
+ connectedCallback() {
13
+ super.connectedCallback();
14
+ this.bind();
15
+ }
16
+ disconnectedCallback() {
17
+ this.cleanup?.();
18
+ this.cleanup = undefined;
19
+ }
20
+ attributeChangedCallback() {
21
+ super.attributeChangedCallback();
22
+ if (this.isConnected)
23
+ this.bind();
24
+ }
25
+ bind() {
26
+ this.cleanup?.();
27
+ const value = this.getAttribute('duration');
28
+ const duration = value === 'fast' || value === 'slow' ? value : 'standard';
29
+ this.cleanup = bindLumenMotionGroup(this, { duration, enterExit: this.getAttribute('enter-exit') !== 'false' });
30
+ }
31
+ }
32
+ export const lumenChartMotionElementConfig = {
33
+ baseClassName: 'ui-chart-motion',
34
+ defaults: { 'data-ui-chart-motion': '' },
35
+ observedAttributes: ['duration'],
36
+ tagName: 'lumen-chart-motion'
37
+ };
38
+ export class LumenChartMotionElement extends LumenElement {
39
+ static config = lumenChartMotionElementConfig;
40
+ cleanup;
41
+ connectedCallback() {
42
+ super.connectedCallback();
43
+ this.bind();
44
+ }
45
+ disconnectedCallback() {
46
+ this.cleanup?.();
47
+ this.cleanup = undefined;
48
+ }
49
+ attributeChangedCallback() {
50
+ super.attributeChangedCallback();
51
+ if (this.isConnected)
52
+ this.bind();
53
+ }
54
+ bind() {
55
+ this.cleanup?.();
56
+ const duration = this.getAttribute('duration');
57
+ this.cleanup = bindLumenChartMotion(this, duration === 'fast' || duration === 'slow' ? duration : 'standard');
58
+ }
59
+ }
60
+ export const lumenVisualEffectElementConfig = {
61
+ baseClassName: 'ui-visual-effect',
62
+ observedAttributes: ['variant', 'animated', 'intensity'],
63
+ tagName: 'lumen-visual-effect'
64
+ };
65
+ export class LumenVisualEffectElement extends LumenElement {
66
+ static config = lumenVisualEffectElementConfig;
67
+ cleanup;
68
+ connectedCallback() {
69
+ super.connectedCallback();
70
+ this.update();
71
+ }
72
+ disconnectedCallback() {
73
+ this.cleanup?.();
74
+ this.cleanup = undefined;
75
+ }
76
+ attributeChangedCallback() {
77
+ super.attributeChangedCallback();
78
+ if (this.isConnected)
79
+ this.update();
80
+ }
81
+ update() {
82
+ this.cleanup?.();
83
+ this.cleanup = undefined;
84
+ this.dataset.uiVisualEffect = this.getAttribute('variant') ?? 'mesh';
85
+ this.dataset.uiEffectAnimated = String(this.hasAttribute('animated') && this.getAttribute('animated') !== 'false');
86
+ const raw = this.getAttribute('intensity');
87
+ this.style.setProperty('--ui-effect-intensity', String(normalizeLumenEffectIntensity(raw === null ? undefined : Number(raw))));
88
+ if (this.dataset.uiVisualEffect === 'spotlight')
89
+ this.cleanup = createLumenSpotlightController(this);
90
+ }
91
+ }
@@ -0,0 +1,46 @@
1
+ import { type LumenWorldMapCountryGeometry, type LumenWorldMapMarker } from '@santi020k/lumen-core/world-map';
2
+ import { type LumenCustomElementRegistry, LumenElement } from '../element-base.js';
3
+ export declare const lumenWorldMapElementConfig: {
4
+ readonly baseClassName: "ui-world-map";
5
+ readonly observedAttributes: readonly ["animated", "countries", "highlighted-countries", "interactive", "label", "labels", "list-label", "markers", "selected-country", "variant", "zoomable", "zoom-labels", "initial-view"];
6
+ readonly tagName: "lumen-world-map";
7
+ };
8
+ export declare class LumenWorldMapElement extends LumenElement {
9
+ static config: {
10
+ readonly baseClassName: "ui-world-map";
11
+ readonly observedAttributes: readonly ["animated", "countries", "highlighted-countries", "interactive", "label", "labels", "list-label", "markers", "selected-country", "variant", "zoomable", "zoom-labels", "initial-view"];
12
+ readonly tagName: "lumen-world-map";
13
+ };
14
+ private countryData;
15
+ private highlightedData;
16
+ private markerData;
17
+ private labelData;
18
+ private abortController;
19
+ private instanceId;
20
+ get countries(): readonly LumenWorldMapCountryGeometry[];
21
+ set countries(value: readonly LumenWorldMapCountryGeometry[]);
22
+ get highlightedCountries(): readonly string[];
23
+ set highlightedCountries(value: readonly string[]);
24
+ get markers(): readonly LumenWorldMapMarker[];
25
+ set markers(value: readonly LumenWorldMapMarker[]);
26
+ get labels(): Readonly<Record<string, string>>;
27
+ set labels(value: Readonly<Record<string, string>>);
28
+ get selectedCountry(): string;
29
+ set selectedCountry(value: string);
30
+ connectedCallback(): void;
31
+ disconnectedCallback(): void;
32
+ adoptedCallback(): void;
33
+ attributeChangedCallback(name: string): void;
34
+ private updateSelection;
35
+ private render;
36
+ private get zoomText();
37
+ private appendZoomControls;
38
+ private countryPath;
39
+ private highlightList;
40
+ private appendMarkers;
41
+ private bindPointer;
42
+ private appendChooser;
43
+ private selectCountry;
44
+ }
45
+ export declare const defineLumenWorldMap: (registry?: LumenCustomElementRegistry) => void;
46
+ //# sourceMappingURL=world-map.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"world-map.d.ts","sourceRoot":"","sources":["../../src/components/world-map.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,4BAA4B,EACjC,KAAK,mBAAmB,EAMzB,MAAM,iCAAiC,CAAA;AAGxC,OAAO,EAAsB,KAAK,0BAA0B,EAAE,YAAY,EAA2B,MAAM,oBAAoB,CAAA;AAE/H,eAAO,MAAM,0BAA0B;;;;CAIA,CAAA;AAuDvC,qBAAa,oBAAqB,SAAQ,YAAY;IACpD,OAAgB,MAAM;;;;MAA6B;IAEnD,OAAO,CAAC,WAAW,CAAqD;IACxE,OAAO,CAAC,eAAe,CAA+B;IACtD,OAAO,CAAC,UAAU,CAA4C;IAC9D,OAAO,CAAC,SAAS,CAA8C;IAC/D,OAAO,CAAC,eAAe,CAA6B;IACpD,OAAO,CAAC,UAAU,CAAwC;IAE1D,IAAI,SAAS,IAAI,SAAS,4BAA4B,EAAE,CAEvD;IAED,IAAI,SAAS,CAAC,KAAK,EAAE,SAAS,4BAA4B,EAAE,EAI3D;IAED,IAAI,oBAAoB,IAAI,SAAS,MAAM,EAAE,CAI5C;IAED,IAAI,oBAAoB,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,EAIhD;IAED,IAAI,OAAO,IAAI,SAAS,mBAAmB,EAAE,CAE5C;IAED,IAAI,OAAO,CAAC,KAAK,EAAE,SAAS,mBAAmB,EAAE,EAIhD;IAED,IAAI,MAAM,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAE7C;IAED,IAAI,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAIjD;IAED,IAAI,eAAe,IAAI,MAAM,CAE5B;IAED,IAAI,eAAe,CAAC,KAAK,EAAE,MAAM,EAEhC;IAEQ,iBAAiB,IAAI,IAAI;IAMzB,oBAAoB,IAAI,IAAI;IAIrC,eAAe,IAAI,IAAI;IAId,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAoBrD,OAAO,CAAC,eAAe;IAqBvB,OAAO,CAAC,MAAM;IAkEd,OAAO,KAAK,QAAQ,GAEnB;IAED,OAAO,CAAC,kBAAkB;IAwC1B,OAAO,CAAC,WAAW;IAsBnB,OAAO,CAAC,aAAa;IAmBrB,OAAO,CAAC,aAAa;IA+BrB,OAAO,CAAC,WAAW;IA4BnB,OAAO,CAAC,aAAa;IA6CrB,OAAO,CAAC,aAAa;CActB;AAED,eAAO,MAAM,mBAAmB,GAAI,WAAW,0BAA0B,KAAG,IAE3E,CAAA"}
@@ -0,0 +1,312 @@
1
+ import { createLumenWorldMapSelectDetail, findLumenWorldMapCountry, normalizeLumenWorldMapCountries, normalizeLumenWorldMapHighlightedCountries, normalizeLumenWorldMapMarkers, projectLumenWorldMapCoordinate, resolveLumenWorldMapCountryLabel } from '@santi020k/lumen-core/world-map';
2
+ import { initLumenWorldMapZoom, lumenWorldMapZoomLabels } from '@santi020k/lumen-core/world-map-zoom';
3
+ import { defineLumenElement, LumenElement } from '../element-base.js';
4
+ export const lumenWorldMapElementConfig = {
5
+ baseClassName: 'ui-world-map',
6
+ observedAttributes: ['animated', 'countries', 'highlighted-countries', 'interactive', 'label', 'labels', 'list-label', 'markers', 'selected-country', 'variant', 'zoomable', 'zoom-labels', 'initial-view'],
7
+ tagName: 'lumen-world-map'
8
+ };
9
+ const readJson = (value) => {
10
+ try {
11
+ return value === null ? undefined : JSON.parse(value);
12
+ }
13
+ catch {
14
+ return undefined;
15
+ }
16
+ };
17
+ const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
18
+ const parseLabels = (value) => {
19
+ if (!isRecord(value))
20
+ return {};
21
+ return Object.fromEntries(Object.entries(value).filter((entry) => typeof entry[1] === 'string'));
22
+ };
23
+ const svgNode = (document, tag, attributes) => {
24
+ const node = document.createElementNS('http://www.w3.org/2000/svg', tag);
25
+ for (const [name, value] of Object.entries(attributes))
26
+ node.setAttribute(name, value);
27
+ return node;
28
+ };
29
+ const readCountry = (target) => {
30
+ try {
31
+ return Element.prototype.closest.call(target, '[data-country]')?.getAttribute('data-country') ?? undefined;
32
+ }
33
+ catch {
34
+ return undefined;
35
+ }
36
+ };
37
+ const appendPatterns = (plot, instanceId) => {
38
+ const defs = svgNode(plot.ownerDocument, 'defs', {});
39
+ for (const state of ['neutral', 'highlight']) {
40
+ const pattern = svgNode(plot.ownerDocument, 'pattern', {
41
+ height: '4', id: `${instanceId}-${state}`, patternUnits: 'userSpaceOnUse', width: '4'
42
+ });
43
+ pattern.append(svgNode(plot.ownerDocument, 'circle', {
44
+ class: `ui-world-map__dot ui-world-map__dot--${state}`, cx: '2', cy: '2', r: '1.1'
45
+ }));
46
+ defs.append(pattern);
47
+ }
48
+ plot.append(defs);
49
+ };
50
+ export class LumenWorldMapElement extends LumenElement {
51
+ static config = lumenWorldMapElementConfig;
52
+ countryData;
53
+ highlightedData;
54
+ markerData;
55
+ labelData;
56
+ abortController;
57
+ instanceId = `ui-world-map-${crypto.randomUUID()}`;
58
+ get countries() {
59
+ return this.countryData ?? normalizeLumenWorldMapCountries(readJson(this.getAttribute('countries')));
60
+ }
61
+ set countries(value) {
62
+ this.countryData = normalizeLumenWorldMapCountries(value);
63
+ this.render();
64
+ }
65
+ get highlightedCountries() {
66
+ return normalizeLumenWorldMapHighlightedCountries(this.highlightedData ?? readJson(this.getAttribute('highlighted-countries')), this.countries);
67
+ }
68
+ set highlightedCountries(value) {
69
+ this.highlightedData = value;
70
+ this.render();
71
+ }
72
+ get markers() {
73
+ return normalizeLumenWorldMapMarkers(this.markerData ?? readJson(this.getAttribute('markers')));
74
+ }
75
+ set markers(value) {
76
+ this.markerData = value;
77
+ this.render();
78
+ }
79
+ get labels() {
80
+ return this.labelData ?? parseLabels(readJson(this.getAttribute('labels')));
81
+ }
82
+ set labels(value) {
83
+ this.labelData = parseLabels(value);
84
+ this.render();
85
+ }
86
+ get selectedCountry() {
87
+ return findLumenWorldMapCountry(this.countries, this.getAttribute('selected-country'))?.id ?? '';
88
+ }
89
+ set selectedCountry(value) {
90
+ this.setAttribute('selected-country', value);
91
+ }
92
+ connectedCallback() {
93
+ super.connectedCallback();
94
+ this.render();
95
+ }
96
+ disconnectedCallback() {
97
+ this.abortController?.abort();
98
+ }
99
+ adoptedCallback() {
100
+ this.render();
101
+ }
102
+ attributeChangedCallback(name) {
103
+ super.attributeChangedCallback();
104
+ if (name === 'countries')
105
+ this.countryData = undefined;
106
+ if (name === 'highlighted-countries')
107
+ this.highlightedData = undefined;
108
+ if (name === 'markers')
109
+ this.markerData = undefined;
110
+ if (name === 'labels')
111
+ this.labelData = undefined;
112
+ if (name === 'selected-country') {
113
+ this.updateSelection();
114
+ return;
115
+ }
116
+ this.render();
117
+ }
118
+ updateSelection() {
119
+ const id = this.selectedCountry;
120
+ const country = findLumenWorldMapCountry(this.countries, id);
121
+ const select = this.querySelector('select');
122
+ const inspection = this.querySelector('.ui-world-map__inspection');
123
+ this.querySelector('.ui-world-map__selection')?.setAttribute('d', country?.path ?? '');
124
+ if (select)
125
+ select.value = id;
126
+ if (inspection) {
127
+ inspection.textContent = country ? resolveLumenWorldMapCountryLabel(country, this.labels) : '';
128
+ inspection.hidden = !country;
129
+ }
130
+ for (const path of this.querySelectorAll('[data-country]')) {
131
+ path.classList.toggle('ui-world-map__country--selected', path.dataset.country === id);
132
+ }
133
+ }
134
+ render() {
135
+ if (!this.isConnected)
136
+ return;
137
+ this.abortController?.abort();
138
+ this.abortController = new AbortController();
139
+ this.dataset.animated = String(this.getAttribute('animated') !== 'false');
140
+ this.dataset.interactive = String(this.getAttribute('interactive') !== 'false');
141
+ this.dataset.variant = this.getAttribute('variant') === 'solid' ? 'solid' : 'dotted';
142
+ const frame = this.ownerDocument.createElement('div');
143
+ const plot = svgNode(this.ownerDocument, 'svg', {
144
+ 'aria-label': this.getAttribute('label') || 'World map', class: 'ui-world-map__plot', role: 'img', viewBox: '0 0 1000 400'
145
+ });
146
+ const group = svgNode(this.ownerDocument, 'g', { 'aria-hidden': 'true', class: 'ui-world-map__countries' });
147
+ frame.className = 'ui-world-map__frame';
148
+ const viewport = this.ownerDocument.createElement('div');
149
+ viewport.className = 'ui-world-map__viewport';
150
+ viewport.dataset.uiWorldMapViewport = '';
151
+ viewport.setAttribute('role', 'region');
152
+ viewport.ariaLabel = `${this.zoomText.viewport}: ${this.getAttribute('label') || 'World map'}`;
153
+ if (this.getAttribute('zoomable') !== 'false')
154
+ viewport.tabIndex = 0;
155
+ if (this.dataset.variant === 'dotted')
156
+ appendPatterns(plot, this.instanceId);
157
+ for (const country of this.countries)
158
+ group.append(this.countryPath(country));
159
+ plot.append(group);
160
+ const markerList = this.appendMarkers(plot);
161
+ plot.append(svgNode(this.ownerDocument, 'path', { 'aria-hidden': 'true', class: 'ui-world-map__selection', d: '' }));
162
+ const inspection = this.ownerDocument.createElement('span');
163
+ inspection.className = 'ui-world-map__inspection';
164
+ viewport.append(plot);
165
+ frame.append(viewport, inspection, markerList);
166
+ this.replaceChildren(frame, this.highlightList());
167
+ this.bindPointer(group, inspection);
168
+ if (this.dataset.interactive === 'true')
169
+ this.appendChooser();
170
+ this.appendZoomControls();
171
+ initLumenWorldMapZoom(this, this.abortController.signal);
172
+ this.updateSelection();
173
+ }
174
+ get zoomText() {
175
+ return { ...lumenWorldMapZoomLabels, ...parseLabels(readJson(this.getAttribute('zoom-labels'))) };
176
+ }
177
+ appendZoomControls() {
178
+ this.dataset.initialView = this.getAttribute('initial-view') ?? 'world';
179
+ if (this.getAttribute('zoomable') === 'false')
180
+ return;
181
+ const controls = this.ownerDocument.createElement('div');
182
+ const status = this.ownerDocument.createElement('output');
183
+ const labels = this.zoomText;
184
+ controls.className = 'ui-world-map__zoom-controls';
185
+ status.dataset.uiWorldMapZoomStatus = '';
186
+ status.ariaLabel = labels.level;
187
+ status.setAttribute('aria-live', 'polite');
188
+ status.value = '100%';
189
+ for (const [action, text, label] of [['out', '−', labels.zoomOut], ['in', '+', labels.zoomIn], ['fit', labels.fit, labels.fit], ['reset', labels.reset, labels.reset]]) {
190
+ const button = this.ownerDocument.createElement('button');
191
+ button.type = 'button';
192
+ button.className = 'ui-button ui-button--outline ui-world-map__zoom-button';
193
+ button.dataset.uiWorldMapZoom = action;
194
+ button.textContent = text ?? '';
195
+ button.ariaLabel = label ?? '';
196
+ controls.append(button);
197
+ if (action === 'out')
198
+ controls.append(status);
199
+ }
200
+ this.prepend(controls);
201
+ }
202
+ countryPath(country) {
203
+ const highlighted = this.highlightedCountries.includes(country.id);
204
+ const path = svgNode(this.ownerDocument, 'path', {
205
+ class: 'ui-world-map__country', d: country.path, 'data-country': country.id, 'fill-rule': 'evenodd'
206
+ });
207
+ path.classList.toggle('ui-world-map__country--highlighted', highlighted);
208
+ path.classList.toggle('ui-world-map__country--selected', this.selectedCountry === country.id);
209
+ if (this.dataset.variant === 'dotted')
210
+ path.setAttribute('fill', `url(#${this.instanceId}-${highlighted ? 'highlight' : 'neutral'})`);
211
+ const title = svgNode(this.ownerDocument, 'title', {});
212
+ title.textContent = resolveLumenWorldMapCountryLabel(country, this.labels);
213
+ path.append(title);
214
+ return path;
215
+ }
216
+ highlightList() {
217
+ const list = this.ownerDocument.createElement('ul');
218
+ list.className = 'ui-world-map__highlights';
219
+ list.ariaLabel = 'Highlighted countries';
220
+ for (const id of this.highlightedCountries) {
221
+ const country = findLumenWorldMapCountry(this.countries, id);
222
+ const item = this.ownerDocument.createElement('li');
223
+ if (country)
224
+ item.textContent = resolveLumenWorldMapCountryLabel(country, this.labels);
225
+ list.append(item);
226
+ }
227
+ return list;
228
+ }
229
+ appendMarkers(plot) {
230
+ const group = svgNode(this.ownerDocument, 'g', { 'aria-hidden': 'true', class: 'ui-world-map__markers' });
231
+ const list = this.ownerDocument.createElement('ul');
232
+ list.className = 'ui-sr-only';
233
+ list.ariaLabel = 'Map markers';
234
+ for (const marker of this.markers) {
235
+ const { x, y } = projectLumenWorldMapCoordinate(marker.longitude, marker.latitude);
236
+ const point = svgNode(this.ownerDocument, 'circle', { class: 'ui-world-map__marker', cx: String(x), cy: String(y), r: '4' });
237
+ const title = svgNode(this.ownerDocument, 'title', {});
238
+ const item = this.ownerDocument.createElement('li');
239
+ title.textContent = marker.label;
240
+ item.textContent = marker.label;
241
+ point.append(title);
242
+ group.append(point);
243
+ list.append(item);
244
+ }
245
+ plot.append(group);
246
+ return list;
247
+ }
248
+ bindPointer(group, inspection) {
249
+ const showCountry = (id) => {
250
+ const country = findLumenWorldMapCountry(this.countries, id);
251
+ inspection.textContent = country ? resolveLumenWorldMapCountryLabel(country, this.labels) : '';
252
+ inspection.hidden = !country;
253
+ };
254
+ const signal = this.abortController?.signal;
255
+ if (!signal)
256
+ return;
257
+ showCountry(this.selectedCountry);
258
+ group.addEventListener('mouseover', event => {
259
+ showCountry(readCountry(event.target));
260
+ }, { signal });
261
+ group.addEventListener('mouseleave', () => {
262
+ showCountry(this.selectedCountry);
263
+ }, { signal });
264
+ group.addEventListener('click', event => {
265
+ if (this.dataset.interactive === 'true')
266
+ this.selectCountry(readCountry(event.target) ?? '');
267
+ }, { signal });
268
+ }
269
+ appendChooser() {
270
+ const signal = this.abortController?.signal;
271
+ if (!signal)
272
+ return;
273
+ const label = this.ownerDocument.createElement('label');
274
+ const text = this.ownerDocument.createElement('span');
275
+ const select = this.ownerDocument.createElement('select');
276
+ const listLabel = this.getAttribute('list-label') ?? 'Choose a country';
277
+ label.className = 'ui-world-map__select-label';
278
+ select.className = 'ui-select ui-world-map__select';
279
+ text.textContent = listLabel;
280
+ const placeholder = this.ownerDocument.createElement('option');
281
+ placeholder.value = '';
282
+ placeholder.textContent = listLabel;
283
+ select.append(placeholder);
284
+ for (const country of this.countries) {
285
+ const option = this.ownerDocument.createElement('option');
286
+ option.value = country.id;
287
+ option.textContent = resolveLumenWorldMapCountryLabel(country, this.labels);
288
+ select.append(option);
289
+ }
290
+ select.value = this.selectedCountry;
291
+ select.addEventListener('change', () => {
292
+ this.selectCountry(select.value);
293
+ }, { signal });
294
+ label.append(text, select);
295
+ this.append(label);
296
+ }
297
+ selectCountry(id) {
298
+ const country = findLumenWorldMapCountry(this.countries, id);
299
+ if (this.selectedCountry === (country?.id ?? ''))
300
+ return;
301
+ this.selectedCountry = country?.id ?? '';
302
+ if (country) {
303
+ this.dispatchEvent(new CustomEvent('ui:world-map-select', {
304
+ bubbles: true,
305
+ detail: createLumenWorldMapSelectDetail(country, new Set(this.highlightedCountries), this.labels)
306
+ }));
307
+ }
308
+ }
309
+ }
310
+ export const defineLumenWorldMap = (registry) => {
311
+ defineLumenElement(lumenWorldMapElementConfig, LumenWorldMapElement, registry);
312
+ };
@@ -0,0 +1,36 @@
1
+ import { LumenElement } from './element-base.js';
2
+ export declare class LumenAmountFieldElement extends LumenElement {
3
+ #private;
4
+ static config: {
5
+ baseClassName: string;
6
+ defaults: {
7
+ 'data-ui-amount-field': string;
8
+ };
9
+ tagName: string;
10
+ };
11
+ static get observedAttributes(): string[];
12
+ get value(): string;
13
+ set value(draft: string);
14
+ connectedCallback(): void;
15
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
16
+ disconnectedCallback(): void;
17
+ }
18
+ export declare class MessageElement extends LumenElement {
19
+ #private;
20
+ static config: {
21
+ attributeClasses: {
22
+ glass: {
23
+ strong: string;
24
+ subtle: string;
25
+ true: string;
26
+ };
27
+ };
28
+ baseClassName: string;
29
+ tagName: string;
30
+ };
31
+ static get observedAttributes(): string[];
32
+ connectedCallback(): void;
33
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
34
+ disconnectedCallback(): void;
35
+ }
36
+ //# sourceMappingURL=consumer-behaviors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consumer-behaviors.d.ts","sourceRoot":"","sources":["../src/consumer-behaviors.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAQhD,qBAAa,uBAAwB,SAAQ,YAAY;;IACvD,OAAgB,MAAM;;;;;;MAAgC;IAEtD,WAAoB,kBAAkB,aAErC;IAKD,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,IAAI,KAAK,CAAC,KAAK,EAAE,MAAM,EAEtB;IAEQ,iBAAiB;IAMjB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAoEvF,oBAAoB;CAK9B;AAcD,qBAAa,cAAe,SAAQ,YAAY;;IAC9C,OAAgB,MAAM;;;;;;;;;;MAAoC;IAE1D,WAAoB,kBAAkB,aAErC;IAIQ,iBAAiB;IAMjB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAYvF,oBAAoB;CAK9B"}
@@ -0,0 +1 @@
1
+ import{createLumenAmountFieldController as u,createLumenMessageScrollerController as d}from"@santi020k/lumen-core";import{LumenElement as l}from"./element-base.js";const n={baseClassName:"ui-amount-field-root",defaults:{"data-ui-amount-field":""},tagName:"lumen-amount-field"};class m extends l{static config=n;static get observedAttributes(){return["value","locale","fraction-digits","allow-negative","default-value","invalid-message","name","form","disabled","readonly","required","id","aria-label","aria-labelledby","aria-describedby","placeholder"]}#e;#t;get value(){return this.getAttribute("value")??""}set value(e){this.setAttribute("value",e)}connectedCallback(){super.connectedCallback(),this.#s()}attributeChangedCallback(e,s,t){super.attributeChangedCallback(),!(!this.#e||!this.isConnected||s===t)&&(e==="value"?this.#e.setValue(t??""):this.#s())}#s(){this.#e?.destroy();const e=this.#i("data-ui-amount-input"),s=this.#i("data-ui-amount-value");e.type="text",e.inputMode="decimal",e.classList.add("ui-input","ui-amount-field"),s.type="hidden",this.#a(s,["name","form"]),this.#a(e,["form","aria-label","aria-labelledby","aria-describedby","placeholder","disabled","readonly","required"]);const t=this.#t,a=t?.[0]===e&&t[2]===e.id?t[1]:e.id,i=this.id?`${this.id}-input`:a;this.#t=[e,a,i],i?e.id=i:e.removeAttribute("id"),s.disabled=e.disabled,this.#e=u(this,o=>{this.value=o.draft})}#a(e,s){for(const t of s){const a=this.getAttribute(t);a===null?e.removeAttribute(t):e.setAttribute(t,a)}}#i(e){const s=this.querySelector(`[${e}]`);if(s)return s;const t=this.ownerDocument.createElement("input");return t.setAttribute(e,""),this.append(t),t}disconnectedCallback(){this.#e?.destroy(),this.#e=void 0}}const c={attributeClasses:{glass:{strong:"ui-message-scroller--glass ui-glass-strong",subtle:"ui-message-scroller--glass ui-glass-subtle",true:"ui-message-scroller--glass"}},baseClassName:"ui-message-scroller",tagName:"lumen-message-scroller"};class g extends l{static config=c;static get observedAttributes(){return[...super.observedAttributes,"auto-scroll","scroll-threshold"]}#e;connectedCallback(){super.connectedCallback(),this.#t()}attributeChangedCallback(e,s,t){super.attributeChangedCallback(e,s,t),this.isConnected&&s!==t&&["auto-scroll","scroll-threshold"].includes(e)&&this.#t()}#t(){this.#e?.destroy(),this.#e=this.hasAttribute("auto-scroll")?d(this,{threshold:Number(this.getAttribute("scroll-threshold")??32)}):void 0}disconnectedCallback(){this.#e?.destroy(),this.#e=void 0}}export{m as LumenAmountFieldElement,g as MessageElement};