@uibit/table 0.1.1 → 0.2.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.
@@ -1,99 +1,119 @@
1
1
  import { Component, ChangeDetectionStrategy, ElementRef, input, effect, booleanAttribute } from '@angular/core';
2
2
  import '@uibit/table';
3
3
  import type { Table as HTMLElementClass } from '@uibit/table';
4
-
5
4
  @Component({
6
- selector: 'uibit-table',
7
- template: '<ng-content></ng-content>',
8
- changeDetection: ChangeDetectionStrategy.OnPush,
9
- standalone: true
5
+ selector: 'uibit-table',
6
+ template: '<ng-content></ng-content>',
7
+ changeDetection: ChangeDetectionStrategy.OnPush,
8
+ standalone: true
10
9
  })
11
10
  export class NgxTable {
12
- constructor(private el: ElementRef<HTMLElementClass>) {
13
- effect(() => {
14
- if (this.el.nativeElement) {
15
- this.el.nativeElement.searchable = this.searchable();
16
- }
11
+ constructor(private el: ElementRef<HTMLElementClass>){
12
+ effect(()=>{
13
+ if (this.el.nativeElement) {
14
+ this.el.nativeElement.searchable = this.searchable();
15
+ }
16
+ });
17
+ effect(()=>{
18
+ if (this.el.nativeElement) {
19
+ this.el.nativeElement.paginated = this.paginated();
20
+ }
21
+ });
22
+ effect(()=>{
23
+ if (this.el.nativeElement) {
24
+ this.el.nativeElement.exportable = this.exportable();
25
+ }
26
+ });
27
+ effect(()=>{
28
+ if (this.el.nativeElement) {
29
+ this.el.nativeElement.selectable = this.selectable();
30
+ }
31
+ });
32
+ effect(()=>{
33
+ if (this.el.nativeElement) {
34
+ this.el.nativeElement.filterable = this.filterable();
35
+ }
36
+ });
37
+ effect(()=>{
38
+ if (this.el.nativeElement) {
39
+ this.el.nativeElement.resizable = this.resizable();
40
+ }
41
+ });
42
+ effect(()=>{
43
+ if (this.el.nativeElement) {
44
+ this.el.nativeElement.columnChooser = this.columnChooser();
45
+ }
46
+ });
47
+ effect(()=>{
48
+ if (this.el.nativeElement) {
49
+ this.el.nativeElement.striped = this.striped();
50
+ }
51
+ });
52
+ effect(()=>{
53
+ if (this.el.nativeElement) {
54
+ this.el.nativeElement.stickyHeader = this.stickyHeader();
55
+ }
56
+ });
57
+ effect(()=>{
58
+ if (this.el.nativeElement) {
59
+ this.el.nativeElement.pageSizes = this.pageSizes();
60
+ }
61
+ });
62
+ effect(()=>{
63
+ if (this.el.nativeElement) {
64
+ this.el.nativeElement.controlsLayout = this.controlsLayout();
65
+ }
66
+ });
67
+ effect(()=>{
68
+ if (this.el.nativeElement) {
69
+ this.el.nativeElement.infiniteScroll = this.infiniteScroll();
70
+ }
71
+ });
72
+ effect(()=>{
73
+ if (this.el.nativeElement) {
74
+ this.el.nativeElement.loading = this.loading();
75
+ }
76
+ });
77
+ effect(()=>{
78
+ if (this.el.nativeElement) {
79
+ this.el.nativeElement.locale = this.locale();
80
+ }
81
+ });
82
+ }
83
+ readonly searchable = input<boolean, any>(true, {
84
+ transform: booleanAttribute
17
85
  });
18
- effect(() => {
19
- if (this.el.nativeElement) {
20
- this.el.nativeElement.paginated = this.paginated();
21
- }
86
+ readonly paginated = input<boolean, any>(true, {
87
+ transform: booleanAttribute
22
88
  });
23
- effect(() => {
24
- if (this.el.nativeElement) {
25
- this.el.nativeElement.exportable = this.exportable();
26
- }
89
+ readonly exportable = input<boolean, any>(true, {
90
+ transform: booleanAttribute
27
91
  });
28
- effect(() => {
29
- if (this.el.nativeElement) {
30
- this.el.nativeElement.selectable = this.selectable();
31
- }
92
+ readonly selectable = input<boolean, any>(false, {
93
+ transform: booleanAttribute
32
94
  });
33
- effect(() => {
34
- if (this.el.nativeElement) {
35
- this.el.nativeElement.filterable = this.filterable();
36
- }
95
+ readonly filterable = input<boolean, any>(false, {
96
+ transform: booleanAttribute
37
97
  });
38
- effect(() => {
39
- if (this.el.nativeElement) {
40
- this.el.nativeElement.resizable = this.resizable();
41
- }
98
+ readonly resizable = input<boolean, any>(false, {
99
+ transform: booleanAttribute
42
100
  });
43
- effect(() => {
44
- if (this.el.nativeElement) {
45
- this.el.nativeElement.columnChooser = this.columnChooser();
46
- }
101
+ readonly columnChooser = input<boolean, any>(false, {
102
+ transform: booleanAttribute
47
103
  });
48
- effect(() => {
49
- if (this.el.nativeElement) {
50
- this.el.nativeElement.striped = this.striped();
51
- }
104
+ readonly striped = input<boolean, any>(false, {
105
+ transform: booleanAttribute
52
106
  });
53
- effect(() => {
54
- if (this.el.nativeElement) {
55
- this.el.nativeElement.stickyHeader = this.stickyHeader();
56
- }
107
+ readonly stickyHeader = input<boolean, any>(false, {
108
+ transform: booleanAttribute
57
109
  });
58
- effect(() => {
59
- if (this.el.nativeElement) {
60
- this.el.nativeElement.pageSizes = this.pageSizes();
61
- }
110
+ readonly pageSizes = input<string>('10,25,50,100');
111
+ readonly controlsLayout = input<'inline' | 'menu'>('inline');
112
+ readonly infiniteScroll = input<boolean, any>(false, {
113
+ transform: booleanAttribute
62
114
  });
63
- effect(() => {
64
- if (this.el.nativeElement) {
65
- this.el.nativeElement.controlsLayout = this.controlsLayout();
66
- }
115
+ readonly loading = input<boolean, any>(false, {
116
+ transform: booleanAttribute
67
117
  });
68
- effect(() => {
69
- if (this.el.nativeElement) {
70
- this.el.nativeElement.infiniteScroll = this.infiniteScroll();
71
- }
72
- });
73
- effect(() => {
74
- if (this.el.nativeElement) {
75
- this.el.nativeElement.loading = this.loading();
76
- }
77
- });
78
- effect(() => {
79
- if (this.el.nativeElement) {
80
- this.el.nativeElement.locale = this.locale();
81
- }
82
- });
83
- }
84
-
85
- readonly searchable = input<boolean, any>(true, { transform: booleanAttribute });
86
- readonly paginated = input<boolean, any>(true, { transform: booleanAttribute });
87
- readonly exportable = input<boolean, any>(true, { transform: booleanAttribute });
88
- readonly selectable = input<boolean, any>(false, { transform: booleanAttribute });
89
- readonly filterable = input<boolean, any>(false, { transform: booleanAttribute });
90
- readonly resizable = input<boolean, any>(false, { transform: booleanAttribute });
91
- readonly columnChooser = input<boolean, any>(false, { transform: booleanAttribute });
92
- readonly striped = input<boolean, any>(false, { transform: booleanAttribute });
93
- readonly stickyHeader = input<boolean, any>(false, { transform: booleanAttribute });
94
- readonly pageSizes = input<string, any>('10,25,50,100');
95
- readonly controlsLayout = input<'inline' | 'menu', any>('inline');
96
- readonly infiniteScroll = input<boolean, any>(false, { transform: booleanAttribute });
97
- readonly loading = input<boolean, any>(false, { transform: booleanAttribute });
98
- readonly locale = input<string, any>('');
118
+ readonly locale = input<string>('');
99
119
  }
@@ -4,7 +4,23 @@ import '@uibit/table';
4
4
  declare global {
5
5
  namespace astroHTML.JSX {
6
6
  interface IntrinsicElements {
7
- 'uibit-table': Partial<HTMLElementClass> & astroHTML.JSX.HTMLAttributes;
7
+ 'uibit-table': Partial<HTMLElementClass> & astroHTML.JSX.HTMLAttributes & {
8
+ searchable?: boolean;
9
+ paginated?: boolean;
10
+ exportable?: boolean;
11
+ selectable?: boolean;
12
+ filterable?: boolean;
13
+ resizable?: boolean;
14
+ columnChooser?: boolean;
15
+ striped?: boolean;
16
+ stickyHeader?: boolean;
17
+ pageSizes?: string;
18
+ controlsLayout?: 'inline' | 'menu';
19
+ infiniteScroll?: boolean;
20
+ loading?: boolean;
21
+ locale?: string;
22
+
23
+ };
8
24
  }
9
25
  }
10
26
  }
@@ -20,6 +20,7 @@ declare module 'preact' {
20
20
  infiniteScroll?: boolean;
21
21
  loading?: boolean;
22
22
  locale?: string;
23
+
23
24
  };
24
25
  }
25
26
  }
@@ -0,0 +1,193 @@
1
+ import React, { useRef, useEffect, useLayoutEffect, useImperativeHandle } from 'react';
2
+ import type { Table as HTMLElementClass } from '@uibit/table';
3
+ import '@uibit/table';
4
+ const useTypeOfLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
5
+ export interface TableProps extends Omit<React.HTMLAttributes<HTMLElementClass>, 'searchable' | 'paginated' | 'exportable' | 'selectable' | 'filterable' | 'resizable' | 'columnChooser' | 'striped' | 'stickyHeader' | 'pageSizes' | 'controlsLayout' | 'infiniteScroll' | 'loading' | 'locale'> {
6
+ children?: React.ReactNode;
7
+ searchable?: boolean;
8
+ paginated?: boolean;
9
+ exportable?: boolean;
10
+ selectable?: boolean;
11
+ filterable?: boolean;
12
+ resizable?: boolean;
13
+ columnChooser?: boolean;
14
+ striped?: boolean;
15
+ stickyHeader?: boolean;
16
+ pageSizes?: string;
17
+ controlsLayout?: 'inline' | 'menu';
18
+ infiniteScroll?: boolean;
19
+ loading?: boolean;
20
+ locale?: string;
21
+ }
22
+ export const Table = ({ ref, children, ...props }: TableProps & {
23
+ ref?: React.Ref<HTMLElementClass>;
24
+ })=>{
25
+ const innerRef = useRef<HTMLElementClass>(null);
26
+ const propsRef = useRef(props);
27
+ propsRef.current = props;
28
+ useImperativeHandle(ref, ()=>innerRef.current!);
29
+ useTypeOfLayoutEffect(()=>{
30
+ const element = innerRef.current;
31
+ if (element && props.searchable !== undefined) {
32
+ (element as any).searchable = props.searchable;
33
+ }
34
+ }, [
35
+ props.searchable
36
+ ]);
37
+ useTypeOfLayoutEffect(()=>{
38
+ const element = innerRef.current;
39
+ if (element && props.paginated !== undefined) {
40
+ (element as any).paginated = props.paginated;
41
+ }
42
+ }, [
43
+ props.paginated
44
+ ]);
45
+ useTypeOfLayoutEffect(()=>{
46
+ const element = innerRef.current;
47
+ if (element && props.exportable !== undefined) {
48
+ (element as any).exportable = props.exportable;
49
+ }
50
+ }, [
51
+ props.exportable
52
+ ]);
53
+ useTypeOfLayoutEffect(()=>{
54
+ const element = innerRef.current;
55
+ if (element && props.selectable !== undefined) {
56
+ (element as any).selectable = props.selectable;
57
+ }
58
+ }, [
59
+ props.selectable
60
+ ]);
61
+ useTypeOfLayoutEffect(()=>{
62
+ const element = innerRef.current;
63
+ if (element && props.filterable !== undefined) {
64
+ (element as any).filterable = props.filterable;
65
+ }
66
+ }, [
67
+ props.filterable
68
+ ]);
69
+ useTypeOfLayoutEffect(()=>{
70
+ const element = innerRef.current;
71
+ if (element && props.resizable !== undefined) {
72
+ (element as any).resizable = props.resizable;
73
+ }
74
+ }, [
75
+ props.resizable
76
+ ]);
77
+ useTypeOfLayoutEffect(()=>{
78
+ const element = innerRef.current;
79
+ if (element && props.columnChooser !== undefined) {
80
+ (element as any).columnChooser = props.columnChooser;
81
+ }
82
+ }, [
83
+ props.columnChooser
84
+ ]);
85
+ useTypeOfLayoutEffect(()=>{
86
+ const element = innerRef.current;
87
+ if (element && props.striped !== undefined) {
88
+ (element as any).striped = props.striped;
89
+ }
90
+ }, [
91
+ props.striped
92
+ ]);
93
+ useTypeOfLayoutEffect(()=>{
94
+ const element = innerRef.current;
95
+ if (element && props.stickyHeader !== undefined) {
96
+ (element as any).stickyHeader = props.stickyHeader;
97
+ }
98
+ }, [
99
+ props.stickyHeader
100
+ ]);
101
+ useTypeOfLayoutEffect(()=>{
102
+ const element = innerRef.current;
103
+ if (element && props.pageSizes !== undefined) {
104
+ (element as any).pageSizes = props.pageSizes;
105
+ }
106
+ }, [
107
+ props.pageSizes
108
+ ]);
109
+ useTypeOfLayoutEffect(()=>{
110
+ const element = innerRef.current;
111
+ if (element && props.controlsLayout !== undefined) {
112
+ (element as any).controlsLayout = props.controlsLayout;
113
+ }
114
+ }, [
115
+ props.controlsLayout
116
+ ]);
117
+ useTypeOfLayoutEffect(()=>{
118
+ const element = innerRef.current;
119
+ if (element && props.infiniteScroll !== undefined) {
120
+ (element as any).infiniteScroll = props.infiniteScroll;
121
+ }
122
+ }, [
123
+ props.infiniteScroll
124
+ ]);
125
+ useTypeOfLayoutEffect(()=>{
126
+ const element = innerRef.current;
127
+ if (element && props.loading !== undefined) {
128
+ (element as any).loading = props.loading;
129
+ }
130
+ }, [
131
+ props.loading
132
+ ]);
133
+ useTypeOfLayoutEffect(()=>{
134
+ const element = innerRef.current;
135
+ if (element && props.locale !== undefined) {
136
+ (element as any).locale = props.locale;
137
+ }
138
+ }, [
139
+ props.locale
140
+ ]);
141
+ const domProps = {
142
+ ...props
143
+ };
144
+ const customPropNames = [
145
+ 'searchable',
146
+ 'paginated',
147
+ 'exportable',
148
+ 'selectable',
149
+ 'filterable',
150
+ 'resizable',
151
+ 'columnChooser',
152
+ 'striped',
153
+ 'stickyHeader',
154
+ 'pageSizes',
155
+ 'controlsLayout',
156
+ 'infiniteScroll',
157
+ 'loading',
158
+ 'locale'
159
+ ];
160
+ for (const key of customPropNames){
161
+ delete (domProps as any)[key];
162
+ }
163
+ return React.createElement('uibit-table', {
164
+ ref: innerRef,
165
+ ...domProps
166
+ }, children);
167
+ };
168
+ declare global {
169
+ namespace React {
170
+ namespace JSX {
171
+ interface IntrinsicElements {
172
+ 'uibit-table': React.ClassAttributes<HTMLElementClass> & React.HTMLAttributes<HTMLElementClass> & {
173
+ children?: React.ReactNode;
174
+ class?: string;
175
+ searchable?: boolean;
176
+ paginated?: boolean;
177
+ exportable?: boolean;
178
+ selectable?: boolean;
179
+ filterable?: boolean;
180
+ resizable?: boolean;
181
+ columnChooser?: boolean;
182
+ striped?: boolean;
183
+ stickyHeader?: boolean;
184
+ pageSizes?: string;
185
+ controlsLayout?: 'inline' | 'menu';
186
+ infiniteScroll?: boolean;
187
+ loading?: boolean;
188
+ locale?: string;
189
+ };
190
+ }
191
+ }
192
+ }
193
+ }
@@ -19,6 +19,7 @@ declare module '@stencil/core' {
19
19
  infiniteScroll?: boolean;
20
20
  loading?: boolean;
21
21
  locale?: string;
22
+
22
23
  };
23
24
  }
24
25
  }
@@ -1,25 +1,26 @@
1
1
  <script lang="ts">
2
2
  import '@uibit/table';
3
3
  import type { Table as HTMLElementClass } from '@uibit/table';
4
-
5
- let {
6
- searchable = undefined,
7
- paginated = undefined,
8
- exportable = undefined,
9
- selectable = undefined,
10
- filterable = undefined,
11
- resizable = undefined,
12
- columnChooser = undefined,
13
- striped = undefined,
14
- stickyHeader = undefined,
15
- pageSizes = undefined,
16
- controlsLayout = undefined,
17
- infiniteScroll = undefined,
18
- loading = undefined,
19
- locale = undefined,
20
- children
4
+
5
+ let {
6
+ searchable = $bindable(),
7
+ paginated = $bindable(),
8
+ exportable = $bindable(),
9
+ selectable = $bindable(),
10
+ filterable = $bindable(),
11
+ resizable = $bindable(),
12
+ columnChooser = $bindable(),
13
+ striped = $bindable(),
14
+ stickyHeader = $bindable(),
15
+ pageSizes = $bindable(),
16
+ controlsLayout = $bindable(),
17
+ infiniteScroll = $bindable(),
18
+ loading = $bindable(),
19
+ locale = $bindable(),
20
+ children,
21
+ ...restProps
21
22
  } = $props<{
22
- children?: any;
23
+ children?: import('svelte').Snippet;
23
24
  searchable?: boolean;
24
25
  paginated?: boolean;
25
26
  exportable?: boolean;
@@ -34,59 +35,120 @@
34
35
  infiniteScroll?: boolean;
35
36
  loading?: boolean;
36
37
  locale?: string;
37
-
38
+
39
+ [key: string]: any;
38
40
  }>();
39
-
40
- let elementRef: HTMLElementClass | null = $state(null);
41
-
42
- $effect(() => {
43
- if (elementRef && searchable !== undefined) {
41
+
42
+ let elementRef: HTMLElementClass | null = $state(null);
43
+
44
+ $effect(() => {
45
+ if (elementRef && searchable !== undefined && elementRef.searchable !== searchable) {
44
46
  elementRef.searchable = searchable;
45
47
  }
46
- if (elementRef && paginated !== undefined) {
48
+ if (elementRef && paginated !== undefined && elementRef.paginated !== paginated) {
47
49
  elementRef.paginated = paginated;
48
50
  }
49
- if (elementRef && exportable !== undefined) {
51
+ if (elementRef && exportable !== undefined && elementRef.exportable !== exportable) {
50
52
  elementRef.exportable = exportable;
51
53
  }
52
- if (elementRef && selectable !== undefined) {
54
+ if (elementRef && selectable !== undefined && elementRef.selectable !== selectable) {
53
55
  elementRef.selectable = selectable;
54
56
  }
55
- if (elementRef && filterable !== undefined) {
57
+ if (elementRef && filterable !== undefined && elementRef.filterable !== filterable) {
56
58
  elementRef.filterable = filterable;
57
59
  }
58
- if (elementRef && resizable !== undefined) {
60
+ if (elementRef && resizable !== undefined && elementRef.resizable !== resizable) {
59
61
  elementRef.resizable = resizable;
60
62
  }
61
- if (elementRef && columnChooser !== undefined) {
63
+ if (elementRef && columnChooser !== undefined && elementRef.columnChooser !== columnChooser) {
62
64
  elementRef.columnChooser = columnChooser;
63
65
  }
64
- if (elementRef && striped !== undefined) {
66
+ if (elementRef && striped !== undefined && elementRef.striped !== striped) {
65
67
  elementRef.striped = striped;
66
68
  }
67
- if (elementRef && stickyHeader !== undefined) {
69
+ if (elementRef && stickyHeader !== undefined && elementRef.stickyHeader !== stickyHeader) {
68
70
  elementRef.stickyHeader = stickyHeader;
69
71
  }
70
- if (elementRef && pageSizes !== undefined) {
72
+ if (elementRef && pageSizes !== undefined && elementRef.pageSizes !== pageSizes) {
71
73
  elementRef.pageSizes = pageSizes;
72
74
  }
73
- if (elementRef && controlsLayout !== undefined) {
75
+ if (elementRef && controlsLayout !== undefined && elementRef.controlsLayout !== controlsLayout) {
74
76
  elementRef.controlsLayout = controlsLayout;
75
77
  }
76
- if (elementRef && infiniteScroll !== undefined) {
78
+ if (elementRef && infiniteScroll !== undefined && elementRef.infiniteScroll !== infiniteScroll) {
77
79
  elementRef.infiniteScroll = infiniteScroll;
78
80
  }
79
- if (elementRef && loading !== undefined) {
81
+ if (elementRef && loading !== undefined && elementRef.loading !== loading) {
80
82
  elementRef.loading = loading;
81
83
  }
82
- if (elementRef && locale !== undefined) {
84
+ if (elementRef && locale !== undefined && elementRef.locale !== locale) {
83
85
  elementRef.locale = locale;
84
86
  }
85
87
  });
86
-
88
+
89
+ $effect(() => {
90
+ const element = elementRef;
91
+ if (!element) return;
92
+
93
+ const handleEvent = () => {
94
+ if (searchable !== element.searchable) {
95
+ searchable = element.searchable as any;
96
+ }
97
+ if (paginated !== element.paginated) {
98
+ paginated = element.paginated as any;
99
+ }
100
+ if (exportable !== element.exportable) {
101
+ exportable = element.exportable as any;
102
+ }
103
+ if (selectable !== element.selectable) {
104
+ selectable = element.selectable as any;
105
+ }
106
+ if (filterable !== element.filterable) {
107
+ filterable = element.filterable as any;
108
+ }
109
+ if (resizable !== element.resizable) {
110
+ resizable = element.resizable as any;
111
+ }
112
+ if (columnChooser !== element.columnChooser) {
113
+ columnChooser = element.columnChooser as any;
114
+ }
115
+ if (striped !== element.striped) {
116
+ striped = element.striped as any;
117
+ }
118
+ if (stickyHeader !== element.stickyHeader) {
119
+ stickyHeader = element.stickyHeader as any;
120
+ }
121
+ if (pageSizes !== element.pageSizes) {
122
+ pageSizes = element.pageSizes as any;
123
+ }
124
+ if (controlsLayout !== element.controlsLayout) {
125
+ controlsLayout = element.controlsLayout as any;
126
+ }
127
+ if (infiniteScroll !== element.infiniteScroll) {
128
+ infiniteScroll = element.infiniteScroll as any;
129
+ }
130
+ if (loading !== element.loading) {
131
+ loading = element.loading as any;
132
+ }
133
+ if (locale !== element.locale) {
134
+ locale = element.locale as any;
135
+ }
136
+ };
137
+
138
+ const events = ['change', 'input'];
139
+ for (const event of events) {
140
+ element.addEventListener(event, handleEvent);
141
+ }
142
+ return () => {
143
+ for (const event of events) {
144
+ element.removeEventListener(event, handleEvent);
145
+ }
146
+ };
147
+ });
148
+
87
149
  </script>
88
150
 
89
- <uibit-table bind:this={elementRef} {...$$restProps}>
151
+ <uibit-table bind:this={elementRef} {...restProps}>
90
152
 
91
153
  {#if children}
92
154
  {@render children()}
@@ -1,35 +1,232 @@
1
- import { defineComponent, h } from 'vue';
1
+ import { defineComponent, h, ref, watch } from 'vue';
2
2
  import type { Table as HTMLElementClass } from '@uibit/table';
3
3
  import '@uibit/table';
4
-
5
4
  export const Table = defineComponent({
6
- name: 'Table',
7
- props: {
8
- searchable: { type: [String, Number, Boolean, Array, Object] as any },
9
- paginated: { type: [String, Number, Boolean, Array, Object] as any },
10
- exportable: { type: [String, Number, Boolean, Array, Object] as any },
11
- selectable: { type: [String, Number, Boolean, Array, Object] as any },
12
- filterable: { type: [String, Number, Boolean, Array, Object] as any },
13
- resizable: { type: [String, Number, Boolean, Array, Object] as any },
14
- columnChooser: { type: [String, Number, Boolean, Array, Object] as any },
15
- striped: { type: [String, Number, Boolean, Array, Object] as any },
16
- stickyHeader: { type: [String, Number, Boolean, Array, Object] as any },
17
- pageSizes: { type: [String, Number, Boolean, Array, Object] as any },
18
- controlsLayout: { type: [String, Number, Boolean, Array, Object] as any },
19
- infiniteScroll: { type: [String, Number, Boolean, Array, Object] as any },
20
- loading: { type: [String, Number, Boolean, Array, Object] as any },
21
- locale: { type: [String, Number, Boolean, Array, Object] as any }
22
- },
23
- emits: [],
24
- setup(props, { slots, emit }) {
25
- return () => {
26
- const eventListeners: Record<string, any> = {};
27
-
28
-
29
- return h('uibit-table', {
30
- ...props,
31
- ...eventListeners
32
- }, slots.default?.());
33
- };
34
- }
5
+ name: 'Table',
6
+ props: {
7
+ searchable: {
8
+ type: [
9
+ String,
10
+ Number,
11
+ Boolean,
12
+ Array,
13
+ Object
14
+ ] as any
15
+ },
16
+ paginated: {
17
+ type: [
18
+ String,
19
+ Number,
20
+ Boolean,
21
+ Array,
22
+ Object
23
+ ] as any
24
+ },
25
+ exportable: {
26
+ type: [
27
+ String,
28
+ Number,
29
+ Boolean,
30
+ Array,
31
+ Object
32
+ ] as any
33
+ },
34
+ selectable: {
35
+ type: [
36
+ String,
37
+ Number,
38
+ Boolean,
39
+ Array,
40
+ Object
41
+ ] as any
42
+ },
43
+ filterable: {
44
+ type: [
45
+ String,
46
+ Number,
47
+ Boolean,
48
+ Array,
49
+ Object
50
+ ] as any
51
+ },
52
+ resizable: {
53
+ type: [
54
+ String,
55
+ Number,
56
+ Boolean,
57
+ Array,
58
+ Object
59
+ ] as any
60
+ },
61
+ columnChooser: {
62
+ type: [
63
+ String,
64
+ Number,
65
+ Boolean,
66
+ Array,
67
+ Object
68
+ ] as any
69
+ },
70
+ striped: {
71
+ type: [
72
+ String,
73
+ Number,
74
+ Boolean,
75
+ Array,
76
+ Object
77
+ ] as any
78
+ },
79
+ stickyHeader: {
80
+ type: [
81
+ String,
82
+ Number,
83
+ Boolean,
84
+ Array,
85
+ Object
86
+ ] as any
87
+ },
88
+ pageSizes: {
89
+ type: [
90
+ String,
91
+ Number,
92
+ Boolean,
93
+ Array,
94
+ Object
95
+ ] as any
96
+ },
97
+ controlsLayout: {
98
+ type: [
99
+ String,
100
+ Number,
101
+ Boolean,
102
+ Array,
103
+ Object
104
+ ] as any
105
+ },
106
+ infiniteScroll: {
107
+ type: [
108
+ String,
109
+ Number,
110
+ Boolean,
111
+ Array,
112
+ Object
113
+ ] as any
114
+ },
115
+ loading: {
116
+ type: [
117
+ String,
118
+ Number,
119
+ Boolean,
120
+ Array,
121
+ Object
122
+ ] as any
123
+ },
124
+ locale: {
125
+ type: [
126
+ String,
127
+ Number,
128
+ Boolean,
129
+ Array,
130
+ Object
131
+ ] as any
132
+ }
133
+ },
134
+ emits: [],
135
+ setup (props, { slots, emit }) {
136
+ const elementRef = ref<HTMLElementClass | null>(null);
137
+ if (false) {
138
+ watch(()=>props.modelValue, (newVal)=>{
139
+ if (elementRef.value && newVal !== undefined && elementRef.value.value !== newVal) {
140
+ elementRef.value.value = newVal;
141
+ }
142
+ });
143
+ watch(()=>props.value, (newVal)=>{
144
+ if (elementRef.value && newVal !== undefined && elementRef.value.value !== newVal) {
145
+ elementRef.value.value = newVal;
146
+ }
147
+ });
148
+ }
149
+ watch(()=>props.searchable, (newVal)=>{
150
+ if (elementRef.value && newVal !== undefined) {
151
+ (elementRef.value as any).searchable = newVal;
152
+ }
153
+ });
154
+ watch(()=>props.paginated, (newVal)=>{
155
+ if (elementRef.value && newVal !== undefined) {
156
+ (elementRef.value as any).paginated = newVal;
157
+ }
158
+ });
159
+ watch(()=>props.exportable, (newVal)=>{
160
+ if (elementRef.value && newVal !== undefined) {
161
+ (elementRef.value as any).exportable = newVal;
162
+ }
163
+ });
164
+ watch(()=>props.selectable, (newVal)=>{
165
+ if (elementRef.value && newVal !== undefined) {
166
+ (elementRef.value as any).selectable = newVal;
167
+ }
168
+ });
169
+ watch(()=>props.filterable, (newVal)=>{
170
+ if (elementRef.value && newVal !== undefined) {
171
+ (elementRef.value as any).filterable = newVal;
172
+ }
173
+ });
174
+ watch(()=>props.resizable, (newVal)=>{
175
+ if (elementRef.value && newVal !== undefined) {
176
+ (elementRef.value as any).resizable = newVal;
177
+ }
178
+ });
179
+ watch(()=>props.columnChooser, (newVal)=>{
180
+ if (elementRef.value && newVal !== undefined) {
181
+ (elementRef.value as any).columnChooser = newVal;
182
+ }
183
+ });
184
+ watch(()=>props.striped, (newVal)=>{
185
+ if (elementRef.value && newVal !== undefined) {
186
+ (elementRef.value as any).striped = newVal;
187
+ }
188
+ });
189
+ watch(()=>props.stickyHeader, (newVal)=>{
190
+ if (elementRef.value && newVal !== undefined) {
191
+ (elementRef.value as any).stickyHeader = newVal;
192
+ }
193
+ });
194
+ watch(()=>props.pageSizes, (newVal)=>{
195
+ if (elementRef.value && newVal !== undefined) {
196
+ (elementRef.value as any).pageSizes = newVal;
197
+ }
198
+ });
199
+ watch(()=>props.controlsLayout, (newVal)=>{
200
+ if (elementRef.value && newVal !== undefined) {
201
+ (elementRef.value as any).controlsLayout = newVal;
202
+ }
203
+ });
204
+ watch(()=>props.infiniteScroll, (newVal)=>{
205
+ if (elementRef.value && newVal !== undefined) {
206
+ (elementRef.value as any).infiniteScroll = newVal;
207
+ }
208
+ });
209
+ watch(()=>props.loading, (newVal)=>{
210
+ if (elementRef.value && newVal !== undefined) {
211
+ (elementRef.value as any).loading = newVal;
212
+ }
213
+ });
214
+ watch(()=>props.locale, (newVal)=>{
215
+ if (elementRef.value && newVal !== undefined) {
216
+ (elementRef.value as any).locale = newVal;
217
+ }
218
+ });
219
+ return ()=>{
220
+ const eventListeners: Record<string, any> = {};
221
+ const mergedProps = {
222
+ ...props,
223
+ ...eventListeners,
224
+ ref: elementRef
225
+ };
226
+ if (false && props.modelValue !== undefined) {
227
+ (mergedProps as any).value = props.modelValue;
228
+ }
229
+ return h('uibit-table', mergedProps, slots.default?.());
230
+ };
231
+ }
35
232
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uibit/table",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "Wraps any standard HTML <table> in the default slot and adds a full datagrid feature set — without touching the source markup. All features are individually opt-in via boolean attributes.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -11,7 +11,7 @@
11
11
  "import": "./dist/index.js"
12
12
  },
13
13
  "./custom-elements.json": "./custom-elements.json",
14
- "./react": "./dist/frameworks/react/index.d.ts",
14
+ "./react": "./dist/frameworks/react/index.ts",
15
15
  "./vue": "./dist/frameworks/vue/index.ts",
16
16
  "./svelte": "./dist/frameworks/svelte/index.svelte",
17
17
  "./angular": "./dist/frameworks/angular/index.ts",
@@ -53,7 +53,7 @@
53
53
  "@types/node": "^20.19.43",
54
54
  "lit": "^3.3.3",
55
55
  "typescript": "7.0.2",
56
- "@uibit/codegen": "0.1.0"
56
+ "@uibit/codegen": "0.2.0"
57
57
  },
58
58
  "peerDependencies": {
59
59
  "lit": "^3.0.0",
@@ -1,30 +0,0 @@
1
- import type { HTMLAttributes, ClassAttributes } from 'react';
2
- import type { Table as HTMLElementClass } from '@uibit/table';
3
- import '@uibit/table';
4
-
5
- declare global {
6
- namespace React {
7
- namespace JSX {
8
- interface IntrinsicElements {
9
- 'uibit-table': ClassAttributes<HTMLElementClass> & HTMLAttributes<HTMLElementClass> & {
10
- children?: React.ReactNode;
11
- class?: string;
12
- searchable?: boolean;
13
- paginated?: boolean;
14
- exportable?: boolean;
15
- selectable?: boolean;
16
- filterable?: boolean;
17
- resizable?: boolean;
18
- columnChooser?: boolean;
19
- striped?: boolean;
20
- stickyHeader?: boolean;
21
- pageSizes?: string;
22
- controlsLayout?: 'inline' | 'menu';
23
- infiniteScroll?: boolean;
24
- loading?: boolean;
25
- locale?: string;
26
- };
27
- }
28
- }
29
- }
30
- }