dasar-ui 1.1.0 → 1.3.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 +19 -14
- package/fesm2022/dasar-ui.mjs +9664 -0
- package/fesm2022/dasar-ui.mjs.map +1 -0
- package/package.json +39 -42
- package/types/dasar-ui.d.ts +2114 -0
- package/.editorconfig +0 -17
- package/.nvmrc +0 -1
- package/.prettierrc +0 -12
- package/.vscode/extensions.json +0 -4
- package/.vscode/launch.json +0 -20
- package/.vscode/settings.json +0 -4
- package/.vscode/tasks.json +0 -42
- package/CHANGELOG.md +0 -18
- package/angular.json +0 -37
- package/projects/dasar-ui/README.md +0 -64
- package/projects/dasar-ui/ng-package.json +0 -10
- package/projects/dasar-ui/package.json +0 -27
- package/projects/dasar-ui/src/lib/components/dasar-button/dasar-button.html +0 -9
- package/projects/dasar-ui/src/lib/components/dasar-button/dasar-button.scss +0 -352
- package/projects/dasar-ui/src/lib/components/dasar-button/dasar-button.spec.ts +0 -21
- package/projects/dasar-ui/src/lib/components/dasar-button/dasar-button.ts +0 -154
- package/projects/dasar-ui/src/lib/components/dasar-button-group/dasar-button-group.html +0 -1
- package/projects/dasar-ui/src/lib/components/dasar-button-group/dasar-button-group.scss +0 -69
- package/projects/dasar-ui/src/lib/components/dasar-button-group/dasar-button-group.spec.ts +0 -21
- package/projects/dasar-ui/src/lib/components/dasar-button-group/dasar-button-group.ts +0 -30
- package/projects/dasar-ui/src/lib/components/dasar-calendar/dasar-calendar.html +0 -158
- package/projects/dasar-ui/src/lib/components/dasar-calendar/dasar-calendar.scss +0 -371
- package/projects/dasar-ui/src/lib/components/dasar-calendar/dasar-calendar.spec.ts +0 -21
- package/projects/dasar-ui/src/lib/components/dasar-calendar/dasar-calendar.ts +0 -458
- package/projects/dasar-ui/src/lib/components/dasar-card/dasar-card.html +0 -80
- package/projects/dasar-ui/src/lib/components/dasar-card/dasar-card.scss +0 -184
- package/projects/dasar-ui/src/lib/components/dasar-card/dasar-card.spec.ts +0 -21
- package/projects/dasar-ui/src/lib/components/dasar-card/dasar-card.ts +0 -294
- package/projects/dasar-ui/src/lib/components/dasar-chip/dasar-chip.html +0 -42
- package/projects/dasar-ui/src/lib/components/dasar-chip/dasar-chip.scss +0 -38
- package/projects/dasar-ui/src/lib/components/dasar-chip/dasar-chip.ts +0 -207
- package/projects/dasar-ui/src/lib/components/dasar-datepicker/dasar-datepicker.html +0 -102
- package/projects/dasar-ui/src/lib/components/dasar-datepicker/dasar-datepicker.scss +0 -301
- package/projects/dasar-ui/src/lib/components/dasar-datepicker/dasar-datepicker.spec.ts +0 -21
- package/projects/dasar-ui/src/lib/components/dasar-datepicker/dasar-datepicker.ts +0 -527
- package/projects/dasar-ui/src/lib/components/dasar-icon/dasar-icon.html +0 -1
- package/projects/dasar-ui/src/lib/components/dasar-icon/dasar-icon.registry.ts +0 -5089
- package/projects/dasar-ui/src/lib/components/dasar-icon/dasar-icon.scss +0 -24
- package/projects/dasar-ui/src/lib/components/dasar-icon/dasar-icon.spec.ts +0 -21
- package/projects/dasar-ui/src/lib/components/dasar-icon/dasar-icon.ts +0 -97
- package/projects/dasar-ui/src/lib/components/dasar-input/dasar-input.html +0 -54
- package/projects/dasar-ui/src/lib/components/dasar-input/dasar-input.scss +0 -281
- package/projects/dasar-ui/src/lib/components/dasar-input/dasar-input.spec.ts +0 -21
- package/projects/dasar-ui/src/lib/components/dasar-input/dasar-input.ts +0 -323
- package/projects/dasar-ui/src/lib/components/dasar-menu/dasar-menu.html +0 -63
- package/projects/dasar-ui/src/lib/components/dasar-menu/dasar-menu.scss +0 -195
- package/projects/dasar-ui/src/lib/components/dasar-menu/dasar-menu.spec.ts +0 -21
- package/projects/dasar-ui/src/lib/components/dasar-menu/dasar-menu.ts +0 -240
- package/projects/dasar-ui/src/lib/components/dasar-number-input/dasar-number-input.html +0 -90
- package/projects/dasar-ui/src/lib/components/dasar-number-input/dasar-number-input.scss +0 -358
- package/projects/dasar-ui/src/lib/components/dasar-number-input/dasar-number-input.spec.ts +0 -21
- package/projects/dasar-ui/src/lib/components/dasar-number-input/dasar-number-input.ts +0 -337
- package/projects/dasar-ui/src/lib/components/dasar-pagination/dasar-pagination.html +0 -98
- package/projects/dasar-ui/src/lib/components/dasar-pagination/dasar-pagination.scss +0 -51
- package/projects/dasar-ui/src/lib/components/dasar-pagination/dasar-pagination.spec.ts +0 -21
- package/projects/dasar-ui/src/lib/components/dasar-pagination/dasar-pagination.ts +0 -99
- package/projects/dasar-ui/src/lib/components/dasar-pin/dasar-pin.css +0 -0
- package/projects/dasar-ui/src/lib/components/dasar-pin/dasar-pin.html +0 -1
- package/projects/dasar-ui/src/lib/components/dasar-pin/dasar-pin.spec.ts +0 -21
- package/projects/dasar-ui/src/lib/components/dasar-pin/dasar-pin.ts +0 -9
- package/projects/dasar-ui/src/lib/components/dasar-pivot-table/dasar-pivot-table.html +0 -163
- package/projects/dasar-ui/src/lib/components/dasar-pivot-table/dasar-pivot-table.scss +0 -283
- package/projects/dasar-ui/src/lib/components/dasar-pivot-table/dasar-pivot-table.ts +0 -230
- package/projects/dasar-ui/src/lib/components/dasar-radio/dasar-radio.css +0 -0
- package/projects/dasar-ui/src/lib/components/dasar-radio/dasar-radio.html +0 -1
- package/projects/dasar-ui/src/lib/components/dasar-radio/dasar-radio.spec.ts +0 -21
- package/projects/dasar-ui/src/lib/components/dasar-radio/dasar-radio.ts +0 -9
- package/projects/dasar-ui/src/lib/components/dasar-select/dasar-select.html +0 -185
- package/projects/dasar-ui/src/lib/components/dasar-select/dasar-select.scss +0 -347
- package/projects/dasar-ui/src/lib/components/dasar-select/dasar-select.spec.ts +0 -21
- package/projects/dasar-ui/src/lib/components/dasar-select/dasar-select.ts +0 -497
- package/projects/dasar-ui/src/lib/components/dasar-slider/dasar-slider.css +0 -0
- package/projects/dasar-ui/src/lib/components/dasar-slider/dasar-slider.html +0 -1
- package/projects/dasar-ui/src/lib/components/dasar-slider/dasar-slider.spec.ts +0 -21
- package/projects/dasar-ui/src/lib/components/dasar-slider/dasar-slider.ts +0 -9
- package/projects/dasar-ui/src/lib/components/dasar-table/dasar-table.html +0 -162
- package/projects/dasar-ui/src/lib/components/dasar-table/dasar-table.scss +0 -283
- package/projects/dasar-ui/src/lib/components/dasar-table/dasar-table.spec.ts +0 -21
- package/projects/dasar-ui/src/lib/components/dasar-table/dasar-table.ts +0 -380
- package/projects/dasar-ui/src/lib/components/dasar-tabs/dasar-tabs.html +0 -41
- package/projects/dasar-ui/src/lib/components/dasar-tabs/dasar-tabs.scss +0 -126
- package/projects/dasar-ui/src/lib/components/dasar-tabs/dasar-tabs.spec.ts +0 -21
- package/projects/dasar-ui/src/lib/components/dasar-tabs/dasar-tabs.ts +0 -72
- package/projects/dasar-ui/src/lib/components/dasar-textarea/dasar-textarea.html +0 -43
- package/projects/dasar-ui/src/lib/components/dasar-textarea/dasar-textarea.scss +0 -189
- package/projects/dasar-ui/src/lib/components/dasar-textarea/dasar-textarea.spec.ts +0 -21
- package/projects/dasar-ui/src/lib/components/dasar-textarea/dasar-textarea.ts +0 -139
- package/projects/dasar-ui/src/lib/components/dasar-theme-provider/dasar-theme-provider.ts +0 -286
- package/projects/dasar-ui/src/lib/components/dasar-toast/dasar-toast.css +0 -0
- package/projects/dasar-ui/src/lib/components/dasar-toast/dasar-toast.html +0 -1
- package/projects/dasar-ui/src/lib/components/dasar-toast/dasar-toast.spec.ts +0 -21
- package/projects/dasar-ui/src/lib/components/dasar-toast/dasar-toast.ts +0 -9
- package/projects/dasar-ui/src/lib/components/dasar-toggle/dasar-toggle.css +0 -0
- package/projects/dasar-ui/src/lib/components/dasar-toggle/dasar-toggle.html +0 -1
- package/projects/dasar-ui/src/lib/components/dasar-toggle/dasar-toggle.spec.ts +0 -21
- package/projects/dasar-ui/src/lib/components/dasar-toggle/dasar-toggle.ts +0 -9
- package/projects/dasar-ui/src/lib/components/dasar-tooltip/dasar-tooltip.css +0 -0
- package/projects/dasar-ui/src/lib/components/dasar-tooltip/dasar-tooltip.html +0 -1
- package/projects/dasar-ui/src/lib/components/dasar-tooltip/dasar-tooltip.spec.ts +0 -21
- package/projects/dasar-ui/src/lib/components/dasar-tooltip/dasar-tooltip.ts +0 -9
- package/projects/dasar-ui/src/lib/models/theme.model.ts +0 -643
- package/projects/dasar-ui/src/lib/models/type.model.ts +0 -11
- package/projects/dasar-ui/src/lib/services/theme.service.ts +0 -643
- package/projects/dasar-ui/src/lib/styles/theme.ts +0 -70
- package/projects/dasar-ui/src/lib/utils/common.ts +0 -175
- package/projects/dasar-ui/src/public-api.ts +0 -23
- package/projects/dasar-ui/tsconfig.lib.json +0 -21
- package/projects/dasar-ui/tsconfig.lib.prod.json +0 -11
- package/projects/dasar-ui/tsconfig.spec.json +0 -11
- package/tsconfig.json +0 -37
- /package/{projects/dasar-ui/src/lib/styles → styles}/theme.scss +0 -0
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
@use '../../styles/theme.scss' as *;
|
|
2
|
-
|
|
3
|
-
.dasar-table {
|
|
4
|
-
display: block;
|
|
5
|
-
width: 100%;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
.dasar-table-container {
|
|
9
|
-
display: flex;
|
|
10
|
-
flex-direction: column;
|
|
11
|
-
width: 100%;
|
|
12
|
-
border-radius: var(--table-radius, var(--radius-md));
|
|
13
|
-
overflow: hidden;
|
|
14
|
-
background-color: var(--table-background, var(--theme-bg-surface-color));
|
|
15
|
-
|
|
16
|
-
&.fluid {
|
|
17
|
-
width: 100%;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
&.appearance-outline {
|
|
21
|
-
border: 1px solid var(--table-outline-border, var(--theme-border-strong-color));
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
&.appearance-filled {
|
|
25
|
-
background-color: var(--table-filled-background, var(--theme-bg-default-color));
|
|
26
|
-
border: 1px solid var(--table-filled-border, transparent);
|
|
27
|
-
|
|
28
|
-
.dasar-table-native tbody tr.dasar-table-row {
|
|
29
|
-
border-bottom: 1px solid var(--table-filled-row-border, var(--theme-bg-default-color));
|
|
30
|
-
background-color: var(--table-filled-row-background, var(--theme-bg-surface-color));
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
&.appearance-elevated {
|
|
35
|
-
border: var(--table-elevated-border, none);
|
|
36
|
-
box-shadow: var(
|
|
37
|
-
--table-elevated-shadow,
|
|
38
|
-
0 10px 25px -5px rgba(0, 0, 0, 0.1),
|
|
39
|
-
0 8px 10px -6px rgba(0, 0, 0, 0.1)
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
&.appearance-borderless {
|
|
44
|
-
border: none;
|
|
45
|
-
border-radius: var(--table-radius-none, var(--radius-none));
|
|
46
|
-
background-color: var(--table-borderless-background, transparent);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
&.size-xs {
|
|
50
|
-
font-size: var(--table-font-size-sm, var(--font-size-xs));
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
&.size-sm {
|
|
54
|
-
font-size: var(--table-font-size-sm, var(--font-size-sm));
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
&.size-md {
|
|
58
|
-
font-size: var(--table-font-size-md, var(--font-size-base));
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
&.size-lg {
|
|
62
|
-
font-size: var(--table-font-size-lg, var(--font-size-lg));
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
&.size-xl {
|
|
66
|
-
font-size: var(--table-font-size-lg, var(--font-size-xl));
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
&.spacing-compact .dasar-table-native {
|
|
70
|
-
th,
|
|
71
|
-
td {
|
|
72
|
-
padding: var(--table-compact-padding-vertical, var(--space-base))
|
|
73
|
-
var(--table-compact-padding-horizontal, var(--space-3));
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
&.spacing-normal .dasar-table-native {
|
|
78
|
-
th,
|
|
79
|
-
td {
|
|
80
|
-
padding: var(--table-normal-padding-vertical, var(--space-4))
|
|
81
|
-
var(--table-normal-padding-horizontal, var(--space-5));
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
&.spacing-relaxed .dasar-table-native {
|
|
86
|
-
th,
|
|
87
|
-
td {
|
|
88
|
-
padding: var(--table-relaxed-padding-vertical, var(--space-6))
|
|
89
|
-
var(--table-relaxed-padding-horizontal, var(--space-8));
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
.dasar-table-wrapper {
|
|
95
|
-
width: 100%;
|
|
96
|
-
overflow-x: auto;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
.dasar-table-native {
|
|
100
|
-
width: 100%;
|
|
101
|
-
border-collapse: collapse;
|
|
102
|
-
border-spacing: 0;
|
|
103
|
-
text-align: left;
|
|
104
|
-
font-size: inherit;
|
|
105
|
-
color: var(--table-color, var(--theme-text-primary-color));
|
|
106
|
-
|
|
107
|
-
thead {
|
|
108
|
-
background-color: var(--table-header-background, var(--theme-primary-color));
|
|
109
|
-
|
|
110
|
-
th {
|
|
111
|
-
font-weight: var(--table-header-font-weight, var(--font-weight-semibold));
|
|
112
|
-
color: var(--table-header-color, var(--theme-text-inverse-color));
|
|
113
|
-
white-space: nowrap;
|
|
114
|
-
|
|
115
|
-
&.sortable {
|
|
116
|
-
cursor: pointer;
|
|
117
|
-
user-select: none;
|
|
118
|
-
|
|
119
|
-
&:hover {
|
|
120
|
-
background-color: var(--table-header-hover-background, var(--theme-primary-hover-color));
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
.th-content {
|
|
125
|
-
display: flex;
|
|
126
|
-
align-items: center;
|
|
127
|
-
gap: var(--table-header-content-gap, var(--space-base));
|
|
128
|
-
|
|
129
|
-
.sort-indicator {
|
|
130
|
-
font-size: var(--table-sort-indicator-size, var(--font-size-sm));
|
|
131
|
-
opacity: 0.5;
|
|
132
|
-
transition: opacity 0.2s;
|
|
133
|
-
|
|
134
|
-
&.active {
|
|
135
|
-
opacity: 1;
|
|
136
|
-
color: var(--table-sort-active-color, var(--theme-text-inverse-color));
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
tbody {
|
|
144
|
-
tr.dasar-table-row {
|
|
145
|
-
border-bottom: 1px solid var(--table-row-border, var(--theme-border-subtle-color));
|
|
146
|
-
transition:
|
|
147
|
-
background-color 0.2s ease,
|
|
148
|
-
box-shadow 0.2s ease;
|
|
149
|
-
|
|
150
|
-
&:last-child:not(.expanded) {
|
|
151
|
-
border-bottom: none;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
td {
|
|
155
|
-
vertical-align: middle;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
tr.dasar-table-expanded-row {
|
|
160
|
-
&:last-child {
|
|
161
|
-
border-bottom: none;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
&.hoverable tbody tr.dasar-table-row:not(.state-row):hover {
|
|
167
|
-
background-color: var(--table-row-hover-background, var(--theme-primary-surface-color));
|
|
168
|
-
cursor: pointer;
|
|
169
|
-
|
|
170
|
-
td:first-child {
|
|
171
|
-
box-shadow: inset var(--table-row-hover-indicator-width, var(--space-0-5)) 0 0 0
|
|
172
|
-
var(--table-row-hover-indicator-color, var(--theme-primary-color));
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
&.striped tbody tr.dasar-table-row:nth-child(odd) {
|
|
177
|
-
background-color: transparent;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
&.striped tbody tr.dasar-table-row:nth-child(even) {
|
|
181
|
-
background-color: var(--table-stripe-background, var(--theme-bg-hover-color));
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
&.striped.hoverable tbody tr.dasar-table-row:not(.state-row):hover {
|
|
185
|
-
background-color: var(--table-row-hover-background, var(--theme-primary-surface-color));
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
.expand-btn {
|
|
190
|
-
display: inline-flex;
|
|
191
|
-
align-items: center;
|
|
192
|
-
justify-content: center;
|
|
193
|
-
width: 24px;
|
|
194
|
-
height: 24px;
|
|
195
|
-
border: none;
|
|
196
|
-
background: transparent;
|
|
197
|
-
cursor: pointer;
|
|
198
|
-
color: var(--table-expand-btn-color, var(--theme-text-secondary-color));
|
|
199
|
-
border-radius: var(--table-expand-btn-radius, var(--radius-sm));
|
|
200
|
-
transition: all 0.2s;
|
|
201
|
-
|
|
202
|
-
&:hover {
|
|
203
|
-
background-color: var(--table-expand-btn-hover-background, var(--theme-border-strong-color));
|
|
204
|
-
color: var(--table-expand-btn-hover-color, var(--theme-text-primary-color));
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
svg {
|
|
208
|
-
transition: transform 0.2s ease;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
&.is-expanded svg {
|
|
212
|
-
transform: rotate(90deg);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
.state-row {
|
|
217
|
-
background-color: transparent !important;
|
|
218
|
-
|
|
219
|
-
&:hover {
|
|
220
|
-
background-color: transparent !important;
|
|
221
|
-
cursor: default !important;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
.state-cell {
|
|
226
|
-
text-align: center;
|
|
227
|
-
padding: var(--table-state-cell-padding, var(--space-8)) !important;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
.state-content {
|
|
231
|
-
display: flex;
|
|
232
|
-
flex-direction: column;
|
|
233
|
-
align-items: center;
|
|
234
|
-
justify-content: center;
|
|
235
|
-
gap: var(--table-state-content-gap, var(--space-3));
|
|
236
|
-
color: var(--table-state-content-color, var(--theme-text-secondary-color));
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
.dasar-spinner {
|
|
240
|
-
width: 24px;
|
|
241
|
-
height: 24px;
|
|
242
|
-
border: 3px solid var(--table-spinner-track, var(--theme-border-subtle-color));
|
|
243
|
-
border-top-color: var(--table-spinner-color, var(--theme-primary-color));
|
|
244
|
-
border-radius: 50%;
|
|
245
|
-
animation: spin 1s linear infinite;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
@keyframes spin {
|
|
249
|
-
100% {
|
|
250
|
-
transform: rotate(360deg);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
.empty-content {
|
|
255
|
-
display: flex;
|
|
256
|
-
flex-direction: column;
|
|
257
|
-
align-items: center;
|
|
258
|
-
justify-content: center;
|
|
259
|
-
gap: var(--table-empty-content-gap, var(--space-1));
|
|
260
|
-
|
|
261
|
-
h5 {
|
|
262
|
-
margin: 0;
|
|
263
|
-
font-weight: var(--table-empty-title-font-weight, var(--font-weight-semibold));
|
|
264
|
-
color: var(--table-empty-title-color, var(--theme-text-primary-color));
|
|
265
|
-
font-size: var(--table-empty-title-font-size, var(--font-size-base));
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
p {
|
|
269
|
-
margin: 0;
|
|
270
|
-
color: var(--table-empty-desc-color, var(--theme-text-secondary-color));
|
|
271
|
-
font-size: var(--table-empty-desc-font-size, var(--font-size-base));
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
.dasar-table-pagination {
|
|
276
|
-
display: flex;
|
|
277
|
-
align-items: center;
|
|
278
|
-
justify-content: flex-end;
|
|
279
|
-
padding: var(--table-pagination-padding-vertical, var(--space-3))
|
|
280
|
-
var(--table-pagination-padding-horizontal, var(--space-4));
|
|
281
|
-
border-top: 1px solid var(--table-pagination-border, var(--theme-border-subtle-color));
|
|
282
|
-
background-color: var(--table-pagination-background, var(--theme-bg-surface-color));
|
|
283
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
-
import { DasarTable } from './dasar-table';
|
|
3
|
-
|
|
4
|
-
describe('DasarTable', () => {
|
|
5
|
-
let component: DasarTable;
|
|
6
|
-
let fixture: ComponentFixture<DasarTable>;
|
|
7
|
-
|
|
8
|
-
beforeEach(async () => {
|
|
9
|
-
await TestBed.configureTestingModule({
|
|
10
|
-
imports: [DasarTable],
|
|
11
|
-
}).compileComponents();
|
|
12
|
-
|
|
13
|
-
fixture = TestBed.createComponent(DasarTable);
|
|
14
|
-
component = fixture.componentInstance;
|
|
15
|
-
await fixture.whenStable();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('should create', () => {
|
|
19
|
-
expect(component).toBeTruthy();
|
|
20
|
-
});
|
|
21
|
-
});
|
|
@@ -1,380 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Component,
|
|
3
|
-
Directive,
|
|
4
|
-
Input,
|
|
5
|
-
Output,
|
|
6
|
-
EventEmitter,
|
|
7
|
-
ContentChild,
|
|
8
|
-
ContentChildren,
|
|
9
|
-
QueryList,
|
|
10
|
-
TemplateRef,
|
|
11
|
-
ViewEncapsulation,
|
|
12
|
-
booleanAttribute,
|
|
13
|
-
HostBinding,
|
|
14
|
-
inject,
|
|
15
|
-
} from '@angular/core';
|
|
16
|
-
import { CommonModule } from '@angular/common';
|
|
17
|
-
|
|
18
|
-
import { DASAR_THEME_PROVIDER } from '../dasar-theme-provider/dasar-theme-provider';
|
|
19
|
-
import { DasarChipComponent, DasarChipVariantType } from '../dasar-chip/dasar-chip';
|
|
20
|
-
import { ClassType, StyleType, ScaleAttributeType } from '../../models/type.model';
|
|
21
|
-
import { DasarButtonComponent } from '../dasar-button/dasar-button';
|
|
22
|
-
import { DasarThemeService } from '../../services/theme.service';
|
|
23
|
-
import { DasarIconComponent } from '../dasar-icon/dasar-icon';
|
|
24
|
-
import { resolveThemeDefault } from '../../utils/common';
|
|
25
|
-
|
|
26
|
-
export type DasarTableAppearance = 'outline' | 'filled' | 'elevated' | 'borderless';
|
|
27
|
-
export type DasarTableSize = Extract<ScaleAttributeType, 'sm' | 'md' | 'lg'>;
|
|
28
|
-
export type DasarTableSpacing = 'compact' | 'normal' | 'relaxed';
|
|
29
|
-
export type DasarTableSortDirection = 'asc' | 'desc' | null;
|
|
30
|
-
export interface DasarTableColumn {
|
|
31
|
-
cellClass?: ClassType | ((row: any, index: number) => ClassType);
|
|
32
|
-
cellStyle?: StyleType | ((row: any, index: number) => StyleType);
|
|
33
|
-
align?: 'left' | 'center' | 'right';
|
|
34
|
-
headerClass?: ClassType;
|
|
35
|
-
headerStyle?: StyleType;
|
|
36
|
-
sortable?: boolean;
|
|
37
|
-
width?: string;
|
|
38
|
-
label?: string;
|
|
39
|
-
key: string;
|
|
40
|
-
}
|
|
41
|
-
export interface DasarTableSortEvent {
|
|
42
|
-
column: string;
|
|
43
|
-
direction: DasarTableSortDirection;
|
|
44
|
-
}
|
|
45
|
-
export interface DasarTableConfig {
|
|
46
|
-
data?: any[];
|
|
47
|
-
columns?: DasarTableColumn[];
|
|
48
|
-
fluid?: boolean;
|
|
49
|
-
striped?: boolean;
|
|
50
|
-
hoverable?: boolean;
|
|
51
|
-
loading?: boolean;
|
|
52
|
-
expandable?: boolean;
|
|
53
|
-
appearance?: DasarTableAppearance;
|
|
54
|
-
spacing?: DasarTableSpacing;
|
|
55
|
-
size?: DasarTableSize;
|
|
56
|
-
sortKey?: string | null;
|
|
57
|
-
sortDirection?: DasarTableSortDirection;
|
|
58
|
-
emptyTitle?: string;
|
|
59
|
-
emptyDescription?: string;
|
|
60
|
-
loadingText?: string;
|
|
61
|
-
containerClass?: ClassType;
|
|
62
|
-
containerStyle?: StyleType;
|
|
63
|
-
wrapperClass?: ClassType;
|
|
64
|
-
wrapperStyle?: StyleType;
|
|
65
|
-
tableClass?: ClassType;
|
|
66
|
-
tableStyle?: StyleType;
|
|
67
|
-
headerClass?: ClassType;
|
|
68
|
-
headerStyle?: StyleType;
|
|
69
|
-
bodyClass?: ClassType;
|
|
70
|
-
bodyStyle?: StyleType;
|
|
71
|
-
paginationClass?: ClassType;
|
|
72
|
-
paginationStyle?: StyleType;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
@Directive({ selector: '[header-slot]', standalone: true })
|
|
76
|
-
export class DasarTableHeaderSlot {}
|
|
77
|
-
@Directive({ selector: '[body-slot]', standalone: true })
|
|
78
|
-
export class DasarTableBodySlot {}
|
|
79
|
-
@Directive({ selector: '[empty-slot]', standalone: true })
|
|
80
|
-
export class DasarTableEmptySlot {}
|
|
81
|
-
@Directive({ selector: '[pagination-slot]', standalone: true })
|
|
82
|
-
export class DasarTablePaginationSlot {}
|
|
83
|
-
@Directive({ selector: '[expanded-slot]', standalone: true })
|
|
84
|
-
export class DasarTableExpandedSlot {
|
|
85
|
-
constructor(public templateRef: TemplateRef<any>) {}
|
|
86
|
-
}
|
|
87
|
-
@Directive({ selector: '[cell-slot]', standalone: true })
|
|
88
|
-
export class DasarTableCellDirective {
|
|
89
|
-
@Input('cell-slot') columnName!: string;
|
|
90
|
-
constructor(public templateRef: TemplateRef<any>) {}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
@Component({
|
|
94
|
-
imports: [CommonModule, DasarButtonComponent, DasarIconComponent],
|
|
95
|
-
encapsulation: ViewEncapsulation.None,
|
|
96
|
-
templateUrl: './dasar-table.html',
|
|
97
|
-
styleUrls: ['./dasar-table.scss'],
|
|
98
|
-
selector: 'dasar-table',
|
|
99
|
-
standalone: true,
|
|
100
|
-
})
|
|
101
|
-
export class DasarTable {
|
|
102
|
-
@ContentChildren(DasarTableCellDirective) cellTemplates!: QueryList<DasarTableCellDirective>;
|
|
103
|
-
@ContentChild(DasarTablePaginationSlot) providedPagination?: DasarTablePaginationSlot;
|
|
104
|
-
@ContentChild(DasarTableExpandedSlot) providedExpanded?: DasarTableExpandedSlot;
|
|
105
|
-
@ContentChild(DasarTableHeaderSlot) providedHeader?: DasarTableHeaderSlot;
|
|
106
|
-
@ContentChild(DasarTableEmptySlot) providedEmpty?: DasarTableEmptySlot;
|
|
107
|
-
@ContentChild(DasarTableBodySlot) providedBody?: DasarTableBodySlot;
|
|
108
|
-
|
|
109
|
-
private themeProvider = inject(DASAR_THEME_PROVIDER, { optional: true });
|
|
110
|
-
private themeService = inject(DasarThemeService, { optional: true });
|
|
111
|
-
|
|
112
|
-
@Input() data = resolveThemeDefault('table', 'data', [], this.themeProvider, this.themeService);
|
|
113
|
-
@Input() columns = resolveThemeDefault(
|
|
114
|
-
'table',
|
|
115
|
-
'columns',
|
|
116
|
-
[],
|
|
117
|
-
this.themeProvider,
|
|
118
|
-
this.themeService,
|
|
119
|
-
);
|
|
120
|
-
@Input({ transform: booleanAttribute }) fluid = resolveThemeDefault(
|
|
121
|
-
'table',
|
|
122
|
-
'fluid',
|
|
123
|
-
true,
|
|
124
|
-
this.themeProvider,
|
|
125
|
-
this.themeService,
|
|
126
|
-
);
|
|
127
|
-
@Input({ transform: booleanAttribute }) striped = resolveThemeDefault(
|
|
128
|
-
'table',
|
|
129
|
-
'striped',
|
|
130
|
-
false,
|
|
131
|
-
this.themeProvider,
|
|
132
|
-
this.themeService,
|
|
133
|
-
);
|
|
134
|
-
@Input({ transform: booleanAttribute }) hoverable = resolveThemeDefault(
|
|
135
|
-
'table',
|
|
136
|
-
'hoverable',
|
|
137
|
-
true,
|
|
138
|
-
this.themeProvider,
|
|
139
|
-
this.themeService,
|
|
140
|
-
);
|
|
141
|
-
@Input({ transform: booleanAttribute }) loading = resolveThemeDefault(
|
|
142
|
-
'table',
|
|
143
|
-
'loading',
|
|
144
|
-
false,
|
|
145
|
-
this.themeProvider,
|
|
146
|
-
this.themeService,
|
|
147
|
-
);
|
|
148
|
-
@Input({ transform: booleanAttribute }) expandable = resolveThemeDefault(
|
|
149
|
-
'table',
|
|
150
|
-
'expandable',
|
|
151
|
-
false,
|
|
152
|
-
this.themeProvider,
|
|
153
|
-
this.themeService,
|
|
154
|
-
);
|
|
155
|
-
@Input() appearance = resolveThemeDefault(
|
|
156
|
-
'table',
|
|
157
|
-
'appearance',
|
|
158
|
-
'outline',
|
|
159
|
-
this.themeProvider,
|
|
160
|
-
this.themeService,
|
|
161
|
-
);
|
|
162
|
-
@Input() spacing = resolveThemeDefault(
|
|
163
|
-
'table',
|
|
164
|
-
'spacing',
|
|
165
|
-
'normal',
|
|
166
|
-
this.themeProvider,
|
|
167
|
-
this.themeService,
|
|
168
|
-
);
|
|
169
|
-
@Input() size = resolveThemeDefault('table', 'size', 'md', this.themeProvider, this.themeService);
|
|
170
|
-
@Input() sortKey = resolveThemeDefault(
|
|
171
|
-
'table',
|
|
172
|
-
'sortKey',
|
|
173
|
-
null,
|
|
174
|
-
this.themeProvider,
|
|
175
|
-
this.themeService,
|
|
176
|
-
);
|
|
177
|
-
@Input() sortDirection: DasarTableSortDirection = resolveThemeDefault(
|
|
178
|
-
'table',
|
|
179
|
-
'sortDirection',
|
|
180
|
-
null,
|
|
181
|
-
this.themeProvider,
|
|
182
|
-
this.themeService,
|
|
183
|
-
);
|
|
184
|
-
|
|
185
|
-
@Input() emptyTitle = resolveThemeDefault(
|
|
186
|
-
'table',
|
|
187
|
-
'emptyTitle',
|
|
188
|
-
'Data empty',
|
|
189
|
-
this.themeProvider,
|
|
190
|
-
this.themeService,
|
|
191
|
-
);
|
|
192
|
-
@Input() emptyDescription = resolveThemeDefault(
|
|
193
|
-
'table',
|
|
194
|
-
'emptyDescription',
|
|
195
|
-
'No records found',
|
|
196
|
-
this.themeProvider,
|
|
197
|
-
this.themeService,
|
|
198
|
-
);
|
|
199
|
-
@Input() loadingText = resolveThemeDefault(
|
|
200
|
-
'table',
|
|
201
|
-
'loadingText',
|
|
202
|
-
'loading...',
|
|
203
|
-
this.themeProvider,
|
|
204
|
-
this.themeService,
|
|
205
|
-
);
|
|
206
|
-
@Input() containerClass = resolveThemeDefault(
|
|
207
|
-
'table',
|
|
208
|
-
'containerClass',
|
|
209
|
-
'',
|
|
210
|
-
this.themeProvider,
|
|
211
|
-
this.themeService,
|
|
212
|
-
);
|
|
213
|
-
@Input() wrapperClass = resolveThemeDefault(
|
|
214
|
-
'table',
|
|
215
|
-
'wrapperClass',
|
|
216
|
-
'',
|
|
217
|
-
this.themeProvider,
|
|
218
|
-
this.themeService,
|
|
219
|
-
);
|
|
220
|
-
@Input() tableClass = resolveThemeDefault(
|
|
221
|
-
'table',
|
|
222
|
-
'tableClass',
|
|
223
|
-
'',
|
|
224
|
-
this.themeProvider,
|
|
225
|
-
this.themeService,
|
|
226
|
-
);
|
|
227
|
-
@Input() headerClass = resolveThemeDefault(
|
|
228
|
-
'table',
|
|
229
|
-
'headerClass',
|
|
230
|
-
'',
|
|
231
|
-
this.themeProvider,
|
|
232
|
-
this.themeService,
|
|
233
|
-
);
|
|
234
|
-
@Input() bodyClass = resolveThemeDefault(
|
|
235
|
-
'table',
|
|
236
|
-
'bodyClass',
|
|
237
|
-
'',
|
|
238
|
-
this.themeProvider,
|
|
239
|
-
this.themeService,
|
|
240
|
-
);
|
|
241
|
-
@Input() paginationClass = resolveThemeDefault(
|
|
242
|
-
'table',
|
|
243
|
-
'paginationClass',
|
|
244
|
-
'',
|
|
245
|
-
this.themeProvider,
|
|
246
|
-
this.themeService,
|
|
247
|
-
);
|
|
248
|
-
@Input() containerStyle = resolveThemeDefault(
|
|
249
|
-
'table',
|
|
250
|
-
'containerStyle',
|
|
251
|
-
null,
|
|
252
|
-
this.themeProvider,
|
|
253
|
-
this.themeService,
|
|
254
|
-
);
|
|
255
|
-
@Input() wrapperStyle = resolveThemeDefault(
|
|
256
|
-
'table',
|
|
257
|
-
'wrapperStyle',
|
|
258
|
-
null,
|
|
259
|
-
this.themeProvider,
|
|
260
|
-
this.themeService,
|
|
261
|
-
);
|
|
262
|
-
@Input() tableStyle = resolveThemeDefault(
|
|
263
|
-
'table',
|
|
264
|
-
'tableStyle',
|
|
265
|
-
null,
|
|
266
|
-
this.themeProvider,
|
|
267
|
-
this.themeService,
|
|
268
|
-
);
|
|
269
|
-
@Input() headerStyle = resolveThemeDefault(
|
|
270
|
-
'table',
|
|
271
|
-
'headerStyle',
|
|
272
|
-
null,
|
|
273
|
-
this.themeProvider,
|
|
274
|
-
this.themeService,
|
|
275
|
-
);
|
|
276
|
-
@Input() bodyStyle = resolveThemeDefault(
|
|
277
|
-
'table',
|
|
278
|
-
'bodyStyle',
|
|
279
|
-
null,
|
|
280
|
-
this.themeProvider,
|
|
281
|
-
this.themeService,
|
|
282
|
-
);
|
|
283
|
-
@Input() paginationStyle = resolveThemeDefault(
|
|
284
|
-
'table',
|
|
285
|
-
'paginationStyle',
|
|
286
|
-
null,
|
|
287
|
-
this.themeProvider,
|
|
288
|
-
this.themeService,
|
|
289
|
-
);
|
|
290
|
-
|
|
291
|
-
@Output() onRowClick = new EventEmitter<{ row: any; index: number; event: MouseEvent }>();
|
|
292
|
-
@Output() onRowDblClick = new EventEmitter<{ row: any; index: number; event: MouseEvent }>();
|
|
293
|
-
@Output() onRowContextMenu = new EventEmitter<{ row: any; index: number; event: MouseEvent }>();
|
|
294
|
-
@Output() onSortChange = new EventEmitter<DasarTableSortEvent>();
|
|
295
|
-
@Output() onRowExpandChange = new EventEmitter<{ row: any; index: number; expanded: boolean }>();
|
|
296
|
-
|
|
297
|
-
@HostBinding('class.dasar-table') readonly baseClass = true;
|
|
298
|
-
expandedRows = new Set<number>();
|
|
299
|
-
|
|
300
|
-
get hasHeader(): boolean {
|
|
301
|
-
return !!this.providedHeader;
|
|
302
|
-
}
|
|
303
|
-
get hasBody(): boolean {
|
|
304
|
-
return !!this.providedBody;
|
|
305
|
-
}
|
|
306
|
-
get hasEmpty(): boolean {
|
|
307
|
-
return !!this.providedEmpty;
|
|
308
|
-
}
|
|
309
|
-
get hasPagination(): boolean {
|
|
310
|
-
return !!this.providedPagination;
|
|
311
|
-
}
|
|
312
|
-
get hasExpanded(): boolean {
|
|
313
|
-
return !!this.providedExpanded;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
getColHeaderClass(col: DasarTableColumn): ClassType {
|
|
317
|
-
return col.headerClass || '';
|
|
318
|
-
}
|
|
319
|
-
getColHeaderStyle(col: DasarTableColumn): StyleType {
|
|
320
|
-
return { ...(col.headerStyle as object) };
|
|
321
|
-
}
|
|
322
|
-
getColCellClass(col: DasarTableColumn, row: any, index: number): ClassType {
|
|
323
|
-
const dynamicClass =
|
|
324
|
-
typeof col.cellClass === 'function' ? col.cellClass(row, index) : col.cellClass;
|
|
325
|
-
return dynamicClass || '';
|
|
326
|
-
}
|
|
327
|
-
getColCellStyle(col: DasarTableColumn, row: any, index: number): StyleType {
|
|
328
|
-
const dynamicStyle =
|
|
329
|
-
typeof col.cellStyle === 'function' ? col.cellStyle(row, index) : col.cellStyle;
|
|
330
|
-
return { ...(dynamicStyle as object) };
|
|
331
|
-
}
|
|
332
|
-
getCellTemplate(columnName: string): TemplateRef<any> | null {
|
|
333
|
-
const directive = this.cellTemplates?.find((t) => t.columnName === columnName);
|
|
334
|
-
return directive ? directive.templateRef : null;
|
|
335
|
-
}
|
|
336
|
-
onSort(columnKey: string): void {
|
|
337
|
-
if (this.sortKey === columnKey) {
|
|
338
|
-
this.sortDirection =
|
|
339
|
-
this.sortDirection === 'asc' ? 'desc' : this.sortDirection === 'desc' ? null : 'asc';
|
|
340
|
-
if (this.sortDirection === null) this.sortKey = null;
|
|
341
|
-
} else {
|
|
342
|
-
this.sortKey = columnKey;
|
|
343
|
-
this.sortDirection = 'asc';
|
|
344
|
-
}
|
|
345
|
-
this.onSortChange.emit({ column: columnKey, direction: this.sortDirection });
|
|
346
|
-
}
|
|
347
|
-
toggleExpand(row: any, index: number, event: MouseEvent): void {
|
|
348
|
-
event.stopPropagation();
|
|
349
|
-
const isExpanded = this.expandedRows.has(index);
|
|
350
|
-
if (isExpanded) {
|
|
351
|
-
this.expandedRows.delete(index);
|
|
352
|
-
} else {
|
|
353
|
-
this.expandedRows.add(index);
|
|
354
|
-
}
|
|
355
|
-
this.expandedRows = new Set(this.expandedRows);
|
|
356
|
-
this.onRowExpandChange.emit({ row, index, expanded: !isExpanded });
|
|
357
|
-
}
|
|
358
|
-
isExpanded(index: number): boolean {
|
|
359
|
-
return this.expandedRows.has(index);
|
|
360
|
-
}
|
|
361
|
-
rowClick(row: any, index: number, event: MouseEvent): void {
|
|
362
|
-
this.onRowClick.emit({ row, index, event });
|
|
363
|
-
}
|
|
364
|
-
rowDblClick(row: any, index: number, event: MouseEvent): void {
|
|
365
|
-
this.onRowDblClick.emit({ row, index, event });
|
|
366
|
-
}
|
|
367
|
-
rowContextMenu(row: any, index: number, event: MouseEvent): void {
|
|
368
|
-
this.onRowContextMenu.emit({ row, index, event });
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
export const DasarTableComponent = [
|
|
373
|
-
DasarTablePaginationSlot,
|
|
374
|
-
DasarTableCellDirective,
|
|
375
|
-
DasarTableExpandedSlot,
|
|
376
|
-
DasarTableHeaderSlot,
|
|
377
|
-
DasarTableEmptySlot,
|
|
378
|
-
DasarTableBodySlot,
|
|
379
|
-
DasarTable,
|
|
380
|
-
] as const;
|