@bryntum/grid-angular-thin 7.2.4 → 7.3.1

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 (43) hide show
  1. package/README.md +5 -5
  2. package/bundles/bryntum-grid-angular-thin.umd.js +773 -230
  3. package/bundles/bryntum-grid-angular-thin.umd.js.map +1 -1
  4. package/esm2015/lib/bryntum-a-i-filter-field.component.js +66 -14
  5. package/esm2015/lib/bryntum-checklist-filter-combo.component.js +66 -14
  6. package/esm2015/lib/bryntum-grid-base.component.js +78 -35
  7. package/esm2015/lib/bryntum-grid-chart-designer.component.js +61 -12
  8. package/esm2015/lib/bryntum-grid-field-filter-picker-group.component.js +65 -21
  9. package/esm2015/lib/bryntum-grid-field-filter-picker.component.js +65 -21
  10. package/esm2015/lib/bryntum-grid.component.js +78 -35
  11. package/esm2015/lib/bryntum-group-bar.component.js +61 -12
  12. package/esm2015/lib/bryntum-tree-combo.component.js +66 -14
  13. package/esm2015/lib/bryntum-tree-grid.component.js +78 -35
  14. package/esm2015/lib/grid.module.js +5 -4
  15. package/esm2015/lib/shadowdom.helper.js +82 -0
  16. package/fesm2015/bryntum-grid-angular-thin.js +750 -207
  17. package/fesm2015/bryntum-grid-angular-thin.js.map +1 -1
  18. package/lib/bryntum-a-i-filter-field.component.d.ts +97 -133
  19. package/lib/bryntum-checklist-filter-combo.component.d.ts +116 -166
  20. package/lib/bryntum-grid-base.component.d.ts +238 -303
  21. package/lib/bryntum-grid-chart-designer.component.d.ts +71 -108
  22. package/lib/bryntum-grid-field-filter-picker-group.component.d.ts +93 -143
  23. package/lib/bryntum-grid-field-filter-picker.component.d.ts +94 -145
  24. package/lib/bryntum-grid.component.d.ts +238 -303
  25. package/lib/bryntum-group-bar.component.d.ts +77 -118
  26. package/lib/bryntum-tree-combo.component.d.ts +117 -168
  27. package/lib/bryntum-tree-grid.component.d.ts +238 -303
  28. package/lib/grid.module.d.ts +2 -1
  29. package/lib/shadowdom.helper.d.ts +3 -0
  30. package/package.json +1 -1
  31. package/src/lib/bryntum-a-i-filter-field.component.ts +159 -142
  32. package/src/lib/bryntum-checklist-filter-combo.component.ts +179 -176
  33. package/src/lib/bryntum-grid-base.component.ts +300 -344
  34. package/src/lib/bryntum-grid-chart-designer.component.ts +127 -113
  35. package/src/lib/bryntum-grid-field-filter-picker-group.component.ts +154 -154
  36. package/src/lib/bryntum-grid-field-filter-picker.component.ts +153 -154
  37. package/src/lib/bryntum-grid.component.ts +300 -344
  38. package/src/lib/bryntum-group-bar.component.ts +134 -124
  39. package/src/lib/bryntum-theme-combo.component.ts +127 -0
  40. package/src/lib/bryntum-tree-combo.component.ts +179 -177
  41. package/src/lib/bryntum-tree-grid.component.ts +300 -344
  42. package/src/lib/grid.module.ts +2 -1
  43. package/src/lib/shadowdom.helper.ts +91 -0
@@ -0,0 +1,127 @@
1
+ /**
2
+ * Angular wrapper for Bryntum Theme combo
3
+ */
4
+ import { Component, ElementRef, Input, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core';
5
+ import { BrowserHelper, Combo, DomHelper, Store, StoreConfig } from '@bryntum/core-thin';
6
+ import { initThemeInShadowRoots, registerShadowRoot, unregisterShadowRoot } from './shadowdom.helper';
7
+
8
+ const defaultThemes: Record<string, string> = {
9
+ 'material3-light' : 'Material3 Light',
10
+ 'material3-dark' : 'Material3 Dark',
11
+ 'stockholm-light' : 'Stockholm Light',
12
+ 'stockholm-dark' : 'Stockholm Dark',
13
+ 'svalbard-light' : 'Svalbard Light',
14
+ 'svalbard-dark' : 'Svalbard Dark',
15
+ 'visby-light' : 'Visby Light',
16
+ 'visby-dark' : 'Visby Dark',
17
+ 'fluent2-light' : 'Fluent2 Light',
18
+ 'fluent2-dark' : 'Fluent2 Dark',
19
+ 'high-contrast-light' : 'High Contrast Light',
20
+ 'high-contrast-dark' : 'High Contrast Dark'
21
+ };
22
+
23
+ const syncedProps = ['store', 'label', 'width'] as const;
24
+
25
+ export type BryntumThemeComboProps = {
26
+ store?: Store | StoreConfig | object;
27
+ label?: string;
28
+ width?: string | number;
29
+ };
30
+
31
+ @Component({
32
+ selector : 'bryntum-theme-combo',
33
+ template : ''
34
+ })
35
+ export class BryntumThemeComboComponent implements OnInit, OnChanges, OnDestroy {
36
+
37
+ private elementRef: ElementRef;
38
+ private combo!: Combo;
39
+
40
+ @Input() store?: Store | StoreConfig | object;
41
+ @Input() label?: string;
42
+ @Input() width?: string | number;
43
+
44
+ constructor(element: ElementRef) {
45
+ this.elementRef = element;
46
+ }
47
+
48
+ /**
49
+ * Initializes the component and creates the Bryntum Combo widget
50
+ */
51
+ ngOnInit(): void {
52
+ const shadowRoot = this.elementRef.nativeElement.getRootNode();
53
+ if (shadowRoot instanceof ShadowRoot) {
54
+ registerShadowRoot(shadowRoot);
55
+ }
56
+
57
+ this.combo = new Combo({
58
+ appendTo : this.elementRef.nativeElement,
59
+ ...(this.store ? { store : this.store } : { items : defaultThemes }),
60
+ label : this.label ?? 'Theme',
61
+ width : this.width ?? '16em',
62
+ value : 'material3-light',
63
+ editable : false,
64
+ labelPosition : 'before',
65
+ ref : 'themeCombo',
66
+ listeners : {
67
+ change({ value }) {
68
+ DomHelper.setTheme(value).then(context => {
69
+ if (context) {
70
+ // Remove all b-theme-* classes — don't rely on context.prev which may
71
+ // be stale (CSS vars unreadable in Angular ViewEncapsulation.ShadowDom)
72
+ Array.from(document.body.classList)
73
+ .filter(cls => cls.startsWith('b-theme-'))
74
+ .forEach(cls => document.body.classList.remove(cls));
75
+ document.body.classList.add(`b-theme-${context.theme}`);
76
+ }
77
+ });
78
+ }
79
+ }
80
+ });
81
+
82
+ // Apply theme from URL search param (?theme=xxx), detect from loaded CSS, or read from link href
83
+ const
84
+ themeLink = document.querySelector<HTMLLinkElement>('link[data-bryntum-theme]'),
85
+ themeFromHref = themeLink ? new URL(themeLink.href).pathname.split('/').pop()?.replace('.css', '') : '',
86
+ theme = BrowserHelper.searchParam('theme') || DomHelper.getThemeInfo()?.filename || themeFromHref;
87
+
88
+ if (theme) {
89
+ this.combo.value = theme;
90
+ }
91
+
92
+ // Always set the initial body class — even when theme detection falls back to the
93
+ // combo's default value (CSS vars may be unreadable in shadow DOM contexts)
94
+ document.body.classList.add(`b-theme-${this.combo.value as string}`);
95
+
96
+ initThemeInShadowRoots();
97
+ }
98
+
99
+ /**
100
+ * Responds to Input property changes and updates the Combo widget accordingly
101
+ */
102
+ ngOnChanges(changes: SimpleChanges): void {
103
+ const { combo } = this;
104
+ if (!combo) {
105
+ return;
106
+ }
107
+ for (const prop of syncedProps) {
108
+ if (prop in changes) {
109
+ (combo as any)[prop] = changes[prop].currentValue;
110
+ }
111
+ }
112
+ }
113
+
114
+ /**
115
+ * Destroys the component and the underlying Combo widget
116
+ */
117
+ ngOnDestroy(): void {
118
+ const shadowRoot = this.elementRef.nativeElement.getRootNode();
119
+ if (shadowRoot instanceof ShadowRoot) {
120
+ unregisterShadowRoot(shadowRoot);
121
+ }
122
+
123
+ if (this.combo) {
124
+ this.combo.destroy();
125
+ }
126
+ }
127
+ }