@constela/ui 0.2.4 → 0.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.
Files changed (39) hide show
  1. package/components/accordion/accordion-content.constela.json +20 -0
  2. package/components/accordion/accordion-item.constela.json +20 -0
  3. package/components/accordion/accordion-trigger.constela.json +21 -0
  4. package/components/accordion/accordion.constela.json +18 -0
  5. package/components/accordion/accordion.styles.json +54 -0
  6. package/components/accordion/accordion.test.ts +608 -0
  7. package/components/calendar/calendar.constela.json +195 -0
  8. package/components/calendar/calendar.styles.json +33 -0
  9. package/components/calendar/calendar.test.ts +458 -0
  10. package/components/chart/area-chart.constela.json +482 -0
  11. package/components/chart/bar-chart.constela.json +342 -0
  12. package/components/chart/chart-axis.constela.json +224 -0
  13. package/components/chart/chart-legend.constela.json +82 -0
  14. package/components/chart/chart-tooltip.constela.json +61 -0
  15. package/components/chart/chart.styles.json +183 -0
  16. package/components/chart/chart.test.ts +3260 -0
  17. package/components/chart/donut-chart.constela.json +369 -0
  18. package/components/chart/line-chart.constela.json +380 -0
  19. package/components/chart/pie-chart.constela.json +259 -0
  20. package/components/chart/radar-chart.constela.json +297 -0
  21. package/components/chart/scatter-chart.constela.json +300 -0
  22. package/components/data-table/data-table-cell.constela.json +22 -0
  23. package/components/data-table/data-table-header.constela.json +30 -0
  24. package/components/data-table/data-table-pagination.constela.json +19 -0
  25. package/components/data-table/data-table-row.constela.json +30 -0
  26. package/components/data-table/data-table.constela.json +32 -0
  27. package/components/data-table/data-table.styles.json +84 -0
  28. package/components/data-table/data-table.test.ts +873 -0
  29. package/components/datepicker/datepicker.constela.json +128 -0
  30. package/components/datepicker/datepicker.styles.json +47 -0
  31. package/components/datepicker/datepicker.test.ts +540 -0
  32. package/components/tree/tree-node.constela.json +26 -0
  33. package/components/tree/tree.constela.json +24 -0
  34. package/components/tree/tree.styles.json +50 -0
  35. package/components/tree/tree.test.ts +542 -0
  36. package/components/virtual-scroll/virtual-scroll.constela.json +27 -0
  37. package/components/virtual-scroll/virtual-scroll.styles.json +17 -0
  38. package/components/virtual-scroll/virtual-scroll.test.ts +345 -0
  39. package/package.json +2 -2
@@ -0,0 +1,342 @@
1
+ {
2
+ "params": {
3
+ "data": { "type": "list", "required": true },
4
+ "valueKey": { "type": "string", "required": true },
5
+ "labelKey": { "type": "string", "required": false },
6
+ "width": { "type": "number", "required": false },
7
+ "height": { "type": "number", "required": false },
8
+ "colors": { "type": "list", "required": false },
9
+ "showGrid": { "type": "boolean", "required": false },
10
+ "showLabels": { "type": "boolean", "required": false },
11
+ "orientation": { "type": "string", "required": false },
12
+ "barGap": { "type": "number", "required": false },
13
+ "barRadius": { "type": "number", "required": false }
14
+ },
15
+ "localState": {
16
+ "_width": {
17
+ "type": "number",
18
+ "initial": {
19
+ "expr": "cond",
20
+ "test": { "expr": "param", "name": "width" },
21
+ "then": { "expr": "param", "name": "width" },
22
+ "else": { "expr": "lit", "value": 400 }
23
+ }
24
+ },
25
+ "_height": {
26
+ "type": "number",
27
+ "initial": {
28
+ "expr": "cond",
29
+ "test": { "expr": "param", "name": "height" },
30
+ "then": { "expr": "param", "name": "height" },
31
+ "else": { "expr": "lit", "value": 300 }
32
+ }
33
+ },
34
+ "_barGap": {
35
+ "type": "number",
36
+ "initial": {
37
+ "expr": "cond",
38
+ "test": { "expr": "param", "name": "barGap" },
39
+ "then": { "expr": "param", "name": "barGap" },
40
+ "else": { "expr": "lit", "value": 4 }
41
+ }
42
+ },
43
+ "_orientation": {
44
+ "type": "string",
45
+ "initial": {
46
+ "expr": "cond",
47
+ "test": { "expr": "param", "name": "orientation" },
48
+ "then": { "expr": "param", "name": "orientation" },
49
+ "else": { "expr": "lit", "value": "vertical" }
50
+ }
51
+ }
52
+ },
53
+ "view": {
54
+ "kind": "element",
55
+ "tag": "svg",
56
+ "props": {
57
+ "role": { "expr": "lit", "value": "img" },
58
+ "aria-label": { "expr": "lit", "value": "Bar Chart" },
59
+ "aria-labelledby": { "expr": "lit", "value": "bar-chart-title" },
60
+ "viewBox": {
61
+ "expr": "call",
62
+ "target": null,
63
+ "method": "concat",
64
+ "args": [
65
+ { "expr": "lit", "value": "0 0 " },
66
+ { "expr": "local", "name": "_width" },
67
+ { "expr": "lit", "value": " " },
68
+ { "expr": "local", "name": "_height" }
69
+ ]
70
+ },
71
+ "className": {
72
+ "expr": "style",
73
+ "preset": "chartSvg",
74
+ "props": {
75
+ "size": { "expr": "lit", "value": "default" }
76
+ }
77
+ }
78
+ },
79
+ "children": [
80
+ {
81
+ "kind": "element",
82
+ "tag": "title",
83
+ "props": {
84
+ "id": { "expr": "lit", "value": "bar-chart-title" }
85
+ },
86
+ "children": [
87
+ { "kind": "text", "content": { "expr": "lit", "value": "Bar Chart" } }
88
+ ]
89
+ },
90
+ {
91
+ "kind": "if",
92
+ "test": { "expr": "param", "name": "showGrid" },
93
+ "then": {
94
+ "kind": "element",
95
+ "tag": "g",
96
+ "props": {
97
+ "className": {
98
+ "expr": "style",
99
+ "preset": "chartGrid",
100
+ "props": {
101
+ "axis": { "expr": "lit", "value": "both" }
102
+ }
103
+ }
104
+ },
105
+ "children": [
106
+ {
107
+ "kind": "element",
108
+ "tag": "line",
109
+ "props": {
110
+ "x1": { "expr": "lit", "value": "40" },
111
+ "y1": { "expr": "lit", "value": "0" },
112
+ "x2": { "expr": "lit", "value": "40" },
113
+ "y2": { "expr": "local", "name": "_height" }
114
+ }
115
+ }
116
+ ]
117
+ }
118
+ },
119
+ {
120
+ "kind": "element",
121
+ "tag": "g",
122
+ "props": {
123
+ "className": { "expr": "lit", "value": "bars" }
124
+ },
125
+ "children": [
126
+ {
127
+ "kind": "each",
128
+ "items": { "expr": "param", "name": "data" },
129
+ "as": "item",
130
+ "index": "idx",
131
+ "body": {
132
+ "kind": "element",
133
+ "tag": "rect",
134
+ "props": {
135
+ "x": {
136
+ "expr": "get",
137
+ "obj": {
138
+ "expr": "call",
139
+ "target": null,
140
+ "method": "getBarDimensions",
141
+ "args": [
142
+ { "expr": "param", "name": "data" },
143
+ { "expr": "var", "name": "idx" },
144
+ { "expr": "local", "name": "_width" },
145
+ { "expr": "local", "name": "_height" },
146
+ { "expr": "local", "name": "_barGap" },
147
+ { "expr": "local", "name": "_orientation" }
148
+ ]
149
+ },
150
+ "key": "x"
151
+ },
152
+ "y": {
153
+ "expr": "get",
154
+ "obj": {
155
+ "expr": "call",
156
+ "target": null,
157
+ "method": "getBarDimensions",
158
+ "args": [
159
+ { "expr": "param", "name": "data" },
160
+ { "expr": "var", "name": "idx" },
161
+ { "expr": "local", "name": "_width" },
162
+ { "expr": "local", "name": "_height" },
163
+ { "expr": "local", "name": "_barGap" },
164
+ { "expr": "local", "name": "_orientation" }
165
+ ]
166
+ },
167
+ "key": "y"
168
+ },
169
+ "width": {
170
+ "expr": "get",
171
+ "obj": {
172
+ "expr": "call",
173
+ "target": null,
174
+ "method": "getBarDimensions",
175
+ "args": [
176
+ { "expr": "param", "name": "data" },
177
+ { "expr": "var", "name": "idx" },
178
+ { "expr": "local", "name": "_width" },
179
+ { "expr": "local", "name": "_height" },
180
+ { "expr": "local", "name": "_barGap" },
181
+ { "expr": "local", "name": "_orientation" }
182
+ ]
183
+ },
184
+ "key": "width"
185
+ },
186
+ "height": {
187
+ "expr": "get",
188
+ "obj": {
189
+ "expr": "call",
190
+ "target": null,
191
+ "method": "getBarDimensions",
192
+ "args": [
193
+ { "expr": "param", "name": "data" },
194
+ { "expr": "var", "name": "idx" },
195
+ { "expr": "local", "name": "_width" },
196
+ { "expr": "local", "name": "_height" },
197
+ { "expr": "local", "name": "_barGap" },
198
+ { "expr": "local", "name": "_orientation" }
199
+ ]
200
+ },
201
+ "key": "height"
202
+ },
203
+ "rx": {
204
+ "expr": "cond",
205
+ "test": { "expr": "param", "name": "barRadius" },
206
+ "then": { "expr": "param", "name": "barRadius" },
207
+ "else": { "expr": "lit", "value": 0 }
208
+ },
209
+ "fill": {
210
+ "expr": "cond",
211
+ "test": { "expr": "param", "name": "colors" },
212
+ "then": {
213
+ "expr": "call",
214
+ "target": { "expr": "param", "name": "colors" },
215
+ "method": "at",
216
+ "args": [
217
+ {
218
+ "expr": "bin",
219
+ "op": "%",
220
+ "left": { "expr": "var", "name": "idx" },
221
+ "right": {
222
+ "expr": "call",
223
+ "target": { "expr": "param", "name": "colors" },
224
+ "method": "length",
225
+ "args": []
226
+ }
227
+ }
228
+ ]
229
+ },
230
+ "else": { "expr": "lit", "value": "#3b82f6" }
231
+ },
232
+ "className": {
233
+ "expr": "style",
234
+ "preset": "chartBar",
235
+ "props": {
236
+ "state": { "expr": "lit", "value": "default" }
237
+ }
238
+ }
239
+ }
240
+ }
241
+ }
242
+ ]
243
+ },
244
+ {
245
+ "kind": "if",
246
+ "test": { "expr": "param", "name": "showLabels" },
247
+ "then": {
248
+ "kind": "element",
249
+ "tag": "g",
250
+ "props": {
251
+ "className": {
252
+ "expr": "style",
253
+ "preset": "chartLabel",
254
+ "props": {
255
+ "type": { "expr": "lit", "value": "axis" }
256
+ }
257
+ }
258
+ },
259
+ "children": [
260
+ {
261
+ "kind": "each",
262
+ "items": { "expr": "param", "name": "data" },
263
+ "as": "item",
264
+ "index": "idx",
265
+ "body": {
266
+ "kind": "element",
267
+ "tag": "text",
268
+ "props": {
269
+ "x": {
270
+ "expr": "bin",
271
+ "op": "+",
272
+ "left": {
273
+ "expr": "get",
274
+ "obj": {
275
+ "expr": "call",
276
+ "target": null,
277
+ "method": "getBarDimensions",
278
+ "args": [
279
+ { "expr": "param", "name": "data" },
280
+ { "expr": "var", "name": "idx" },
281
+ { "expr": "local", "name": "_width" },
282
+ { "expr": "local", "name": "_height" },
283
+ { "expr": "local", "name": "_barGap" },
284
+ { "expr": "local", "name": "_orientation" }
285
+ ]
286
+ },
287
+ "key": "x"
288
+ },
289
+ "right": {
290
+ "expr": "bin",
291
+ "op": "/",
292
+ "left": {
293
+ "expr": "get",
294
+ "obj": {
295
+ "expr": "call",
296
+ "target": null,
297
+ "method": "getBarDimensions",
298
+ "args": [
299
+ { "expr": "param", "name": "data" },
300
+ { "expr": "var", "name": "idx" },
301
+ { "expr": "local", "name": "_width" },
302
+ { "expr": "local", "name": "_height" },
303
+ { "expr": "local", "name": "_barGap" },
304
+ { "expr": "local", "name": "_orientation" }
305
+ ]
306
+ },
307
+ "key": "width"
308
+ },
309
+ "right": { "expr": "lit", "value": 2 }
310
+ }
311
+ },
312
+ "y": {
313
+ "expr": "bin",
314
+ "op": "+",
315
+ "left": { "expr": "local", "name": "_height" },
316
+ "right": { "expr": "lit", "value": 15 }
317
+ },
318
+ "text-anchor": { "expr": "lit", "value": "middle" }
319
+ },
320
+ "children": [
321
+ {
322
+ "kind": "text",
323
+ "content": {
324
+ "expr": "cond",
325
+ "test": { "expr": "param", "name": "labelKey" },
326
+ "then": {
327
+ "expr": "get",
328
+ "obj": { "expr": "var", "name": "item" },
329
+ "key": { "expr": "param", "name": "labelKey" }
330
+ },
331
+ "else": { "expr": "var", "name": "idx" }
332
+ }
333
+ }
334
+ ]
335
+ }
336
+ }
337
+ ]
338
+ }
339
+ }
340
+ ]
341
+ }
342
+ }
@@ -0,0 +1,224 @@
1
+ {
2
+ "params": {
3
+ "ticks": { "type": "list", "required": true },
4
+ "orientation": { "type": "string", "required": true },
5
+ "width": { "type": "number", "required": false },
6
+ "height": { "type": "number", "required": false },
7
+ "showLabels": { "type": "boolean", "required": false },
8
+ "labelFormatter": { "type": "string", "required": false }
9
+ },
10
+ "view": {
11
+ "kind": "element",
12
+ "tag": "g",
13
+ "props": {
14
+ "aria-hidden": { "expr": "lit", "value": "true" },
15
+ "className": {
16
+ "expr": "style",
17
+ "preset": "chartAxis",
18
+ "props": {
19
+ "position": {
20
+ "expr": "cond",
21
+ "test": {
22
+ "expr": "bin",
23
+ "op": "===",
24
+ "left": { "expr": "param", "name": "orientation" },
25
+ "right": { "expr": "lit", "value": "horizontal" }
26
+ },
27
+ "then": { "expr": "lit", "value": "bottom" },
28
+ "else": { "expr": "lit", "value": "left" }
29
+ }
30
+ }
31
+ }
32
+ },
33
+ "children": [
34
+ {
35
+ "kind": "element",
36
+ "tag": "line",
37
+ "props": {
38
+ "x1": { "expr": "lit", "value": "0" },
39
+ "y1": { "expr": "lit", "value": "0" },
40
+ "x2": {
41
+ "expr": "cond",
42
+ "test": {
43
+ "expr": "bin",
44
+ "op": "===",
45
+ "left": { "expr": "param", "name": "orientation" },
46
+ "right": { "expr": "lit", "value": "horizontal" }
47
+ },
48
+ "then": {
49
+ "expr": "cond",
50
+ "test": { "expr": "param", "name": "width" },
51
+ "then": { "expr": "param", "name": "width" },
52
+ "else": { "expr": "lit", "value": 400 }
53
+ },
54
+ "else": { "expr": "lit", "value": "0" }
55
+ },
56
+ "y2": {
57
+ "expr": "cond",
58
+ "test": {
59
+ "expr": "bin",
60
+ "op": "===",
61
+ "left": { "expr": "param", "name": "orientation" },
62
+ "right": { "expr": "lit", "value": "vertical" }
63
+ },
64
+ "then": {
65
+ "expr": "cond",
66
+ "test": { "expr": "param", "name": "height" },
67
+ "then": { "expr": "param", "name": "height" },
68
+ "else": { "expr": "lit", "value": 300 }
69
+ },
70
+ "else": { "expr": "lit", "value": "0" }
71
+ }
72
+ }
73
+ },
74
+ {
75
+ "kind": "each",
76
+ "items": {
77
+ "expr": "call",
78
+ "target": null,
79
+ "method": "generateTicks",
80
+ "args": [
81
+ { "expr": "lit", "value": 0 },
82
+ { "expr": "lit", "value": 100 },
83
+ { "expr": "lit", "value": 5 }
84
+ ]
85
+ },
86
+ "as": "tick",
87
+ "index": "idx",
88
+ "body": {
89
+ "kind": "element",
90
+ "tag": "g",
91
+ "props": {},
92
+ "children": [
93
+ {
94
+ "kind": "element",
95
+ "tag": "line",
96
+ "props": {
97
+ "x1": {
98
+ "expr": "cond",
99
+ "test": {
100
+ "expr": "bin",
101
+ "op": "===",
102
+ "left": { "expr": "param", "name": "orientation" },
103
+ "right": { "expr": "lit", "value": "horizontal" }
104
+ },
105
+ "then": {
106
+ "expr": "bin",
107
+ "op": "*",
108
+ "left": { "expr": "var", "name": "idx" },
109
+ "right": { "expr": "lit", "value": 80 }
110
+ },
111
+ "else": { "expr": "lit", "value": "0" }
112
+ },
113
+ "y1": {
114
+ "expr": "cond",
115
+ "test": {
116
+ "expr": "bin",
117
+ "op": "===",
118
+ "left": { "expr": "param", "name": "orientation" },
119
+ "right": { "expr": "lit", "value": "vertical" }
120
+ },
121
+ "then": {
122
+ "expr": "bin",
123
+ "op": "*",
124
+ "left": { "expr": "var", "name": "idx" },
125
+ "right": { "expr": "lit", "value": 60 }
126
+ },
127
+ "else": { "expr": "lit", "value": "0" }
128
+ },
129
+ "x2": {
130
+ "expr": "cond",
131
+ "test": {
132
+ "expr": "bin",
133
+ "op": "===",
134
+ "left": { "expr": "param", "name": "orientation" },
135
+ "right": { "expr": "lit", "value": "horizontal" }
136
+ },
137
+ "then": {
138
+ "expr": "bin",
139
+ "op": "*",
140
+ "left": { "expr": "var", "name": "idx" },
141
+ "right": { "expr": "lit", "value": 80 }
142
+ },
143
+ "else": { "expr": "lit", "value": "-6" }
144
+ },
145
+ "y2": {
146
+ "expr": "cond",
147
+ "test": {
148
+ "expr": "bin",
149
+ "op": "===",
150
+ "left": { "expr": "param", "name": "orientation" },
151
+ "right": { "expr": "lit", "value": "vertical" }
152
+ },
153
+ "then": {
154
+ "expr": "bin",
155
+ "op": "*",
156
+ "left": { "expr": "var", "name": "idx" },
157
+ "right": { "expr": "lit", "value": 60 }
158
+ },
159
+ "else": { "expr": "lit", "value": "6" }
160
+ }
161
+ }
162
+ },
163
+ {
164
+ "kind": "if",
165
+ "test": { "expr": "param", "name": "showLabels" },
166
+ "then": {
167
+ "kind": "element",
168
+ "tag": "text",
169
+ "props": {
170
+ "x": {
171
+ "expr": "cond",
172
+ "test": {
173
+ "expr": "bin",
174
+ "op": "===",
175
+ "left": { "expr": "param", "name": "orientation" },
176
+ "right": { "expr": "lit", "value": "horizontal" }
177
+ },
178
+ "then": {
179
+ "expr": "bin",
180
+ "op": "*",
181
+ "left": { "expr": "var", "name": "idx" },
182
+ "right": { "expr": "lit", "value": 80 }
183
+ },
184
+ "else": { "expr": "lit", "value": "-10" }
185
+ },
186
+ "y": {
187
+ "expr": "cond",
188
+ "test": {
189
+ "expr": "bin",
190
+ "op": "===",
191
+ "left": { "expr": "param", "name": "orientation" },
192
+ "right": { "expr": "lit", "value": "vertical" }
193
+ },
194
+ "then": {
195
+ "expr": "bin",
196
+ "op": "*",
197
+ "left": { "expr": "var", "name": "idx" },
198
+ "right": { "expr": "lit", "value": 60 }
199
+ },
200
+ "else": { "expr": "lit", "value": "20" }
201
+ },
202
+ "text-anchor": { "expr": "lit", "value": "middle" },
203
+ "className": {
204
+ "expr": "style",
205
+ "preset": "chartLabel",
206
+ "props": {
207
+ "type": { "expr": "lit", "value": "axis" }
208
+ }
209
+ }
210
+ },
211
+ "children": [
212
+ {
213
+ "kind": "text",
214
+ "content": { "expr": "var", "name": "tick" }
215
+ }
216
+ ]
217
+ }
218
+ }
219
+ ]
220
+ }
221
+ }
222
+ ]
223
+ }
224
+ }
@@ -0,0 +1,82 @@
1
+ {
2
+ "params": {
3
+ "items": { "type": "list", "required": true },
4
+ "orientation": { "type": "string", "required": false },
5
+ "position": { "type": "string", "required": false }
6
+ },
7
+ "view": {
8
+ "kind": "element",
9
+ "tag": "div",
10
+ "props": {
11
+ "role": { "expr": "lit", "value": "list" },
12
+ "className": {
13
+ "expr": "style",
14
+ "preset": "chartLegend",
15
+ "props": {
16
+ "orientation": {
17
+ "expr": "cond",
18
+ "test": { "expr": "param", "name": "orientation" },
19
+ "then": { "expr": "param", "name": "orientation" },
20
+ "else": { "expr": "lit", "value": "horizontal" }
21
+ }
22
+ }
23
+ }
24
+ },
25
+ "children": [
26
+ {
27
+ "kind": "each",
28
+ "items": { "expr": "param", "name": "items" },
29
+ "as": "item",
30
+ "index": "idx",
31
+ "body": {
32
+ "kind": "element",
33
+ "tag": "div",
34
+ "props": {
35
+ "role": { "expr": "lit", "value": "listitem" },
36
+ "className": {
37
+ "expr": "style",
38
+ "preset": "chartLegendItem",
39
+ "props": {
40
+ "state": { "expr": "lit", "value": "default" }
41
+ }
42
+ }
43
+ },
44
+ "children": [
45
+ {
46
+ "kind": "element",
47
+ "tag": "span",
48
+ "props": {
49
+ "className": { "expr": "lit", "value": "w-3 h-3 rounded-sm" },
50
+ "style": {
51
+ "expr": "call",
52
+ "target": null,
53
+ "method": "concat",
54
+ "args": [
55
+ { "expr": "lit", "value": "background-color: " },
56
+ {
57
+ "expr": "cond",
58
+ "test": { "expr": "get", "obj": { "expr": "var", "name": "item" }, "key": "color" },
59
+ "then": { "expr": "get", "obj": { "expr": "var", "name": "item" }, "key": "color" },
60
+ "else": { "expr": "lit", "value": "#3b82f6" }
61
+ }
62
+ ]
63
+ }
64
+ }
65
+ },
66
+ {
67
+ "kind": "element",
68
+ "tag": "span",
69
+ "props": {},
70
+ "children": [
71
+ {
72
+ "kind": "text",
73
+ "content": { "expr": "get", "obj": { "expr": "var", "name": "item" }, "key": "label" }
74
+ }
75
+ ]
76
+ }
77
+ ]
78
+ }
79
+ }
80
+ ]
81
+ }
82
+ }