@sonny-ui/core 0.1.0-alpha.10 → 0.1.0-alpha.12
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/fesm2022/sonny-ui-core.mjs +35 -13
- package/fesm2022/sonny-ui-core.mjs.map +1 -1
- package/package.json +1 -1
- package/schematics/ng-add/index.js +27 -0
- package/schematics/ng-generate/component/index.js +187 -6
- package/schematics/ng-generate/component/schema.json +32 -32
- package/types/sonny-ui-core.d.ts +4 -1
package/package.json
CHANGED
|
@@ -21,6 +21,33 @@ function ngAdd(options) {
|
|
|
21
21
|
context.logger.info('Added SonnyUI theme import to styles.css');
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
+
// Add provideSonnyUI to app.config.ts
|
|
25
|
+
const configPath = 'src/app/app.config.ts';
|
|
26
|
+
if (tree.exists(configPath)) {
|
|
27
|
+
let configContent = tree.read(configPath).toString('utf-8');
|
|
28
|
+
const theme = options.theme || 'light';
|
|
29
|
+
if (!configContent.includes('provideSonnyUI')) {
|
|
30
|
+
// Add import statement
|
|
31
|
+
const importLine = `import { provideSonnyUI } from '@sonny-ui/core';\n`;
|
|
32
|
+
const lastImportIndex = configContent.lastIndexOf('import ');
|
|
33
|
+
const lastImportEnd = configContent.indexOf('\n', lastImportIndex);
|
|
34
|
+
configContent =
|
|
35
|
+
configContent.slice(0, lastImportEnd + 1) +
|
|
36
|
+
importLine +
|
|
37
|
+
configContent.slice(lastImportEnd + 1);
|
|
38
|
+
// Add provider to providers array
|
|
39
|
+
const providersMatch = configContent.match(/providers\s*:\s*\[/);
|
|
40
|
+
if (providersMatch && providersMatch.index !== undefined) {
|
|
41
|
+
const insertPos = providersMatch.index + providersMatch[0].length;
|
|
42
|
+
configContent =
|
|
43
|
+
configContent.slice(0, insertPos) +
|
|
44
|
+
`\n provideSonnyUI({ defaultTheme: '${theme}' }),` +
|
|
45
|
+
configContent.slice(insertPos);
|
|
46
|
+
}
|
|
47
|
+
tree.overwrite(configPath, configContent);
|
|
48
|
+
context.logger.info('Added provideSonnyUI to app.config.ts');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
24
51
|
return tree;
|
|
25
52
|
};
|
|
26
53
|
}
|
|
@@ -37,33 +37,66 @@ exports.generateComponent = generateComponent;
|
|
|
37
37
|
const path = __importStar(require("path"));
|
|
38
38
|
const AVAILABLE_COMPONENTS = [
|
|
39
39
|
'accordion',
|
|
40
|
+
'alert',
|
|
40
41
|
'avatar',
|
|
41
42
|
'badge',
|
|
42
43
|
'breadcrumb',
|
|
43
44
|
'button',
|
|
44
45
|
'button-group',
|
|
46
|
+
'calendar',
|
|
45
47
|
'card',
|
|
48
|
+
'carousel',
|
|
49
|
+
'chat-bubble',
|
|
46
50
|
'checkbox',
|
|
47
51
|
'combobox',
|
|
52
|
+
'diff',
|
|
53
|
+
'divider',
|
|
54
|
+
'dock',
|
|
55
|
+
'drawer',
|
|
56
|
+
'dropdown',
|
|
57
|
+
'fab',
|
|
58
|
+
'fieldset',
|
|
59
|
+
'file-input',
|
|
60
|
+
'indicator',
|
|
48
61
|
'input',
|
|
62
|
+
'kbd',
|
|
63
|
+
'link',
|
|
64
|
+
'list',
|
|
49
65
|
'loader',
|
|
50
66
|
'modal',
|
|
67
|
+
'navbar',
|
|
68
|
+
'pagination',
|
|
69
|
+
'progress',
|
|
70
|
+
'radial-progress',
|
|
51
71
|
'radio',
|
|
72
|
+
'rating',
|
|
52
73
|
'select',
|
|
53
74
|
'sheet',
|
|
54
75
|
'skeleton',
|
|
55
76
|
'slider',
|
|
77
|
+
'stat',
|
|
78
|
+
'status',
|
|
79
|
+
'steps',
|
|
56
80
|
'switch',
|
|
57
81
|
'table',
|
|
58
82
|
'tabs',
|
|
83
|
+
'textarea',
|
|
84
|
+
'timeline',
|
|
59
85
|
'toast',
|
|
60
86
|
'toggle',
|
|
87
|
+
'tooltip',
|
|
88
|
+
'validator',
|
|
61
89
|
];
|
|
62
90
|
const COMPONENT_FILES = {
|
|
63
91
|
accordion: [
|
|
64
92
|
'accordion.directives.ts',
|
|
65
93
|
'index.ts',
|
|
66
94
|
],
|
|
95
|
+
alert: [
|
|
96
|
+
'alert.directives.ts',
|
|
97
|
+
'alert.variants.ts',
|
|
98
|
+
'index.ts',
|
|
99
|
+
],
|
|
67
100
|
avatar: [
|
|
68
101
|
'avatar.component.ts',
|
|
69
102
|
'avatar.variants.ts',
|
|
@@ -88,11 +121,23 @@ const COMPONENT_FILES = {
|
|
|
88
121
|
'button-group.variants.ts',
|
|
89
122
|
'index.ts',
|
|
90
123
|
],
|
|
124
|
+
calendar: [
|
|
125
|
+
'calendar.component.ts',
|
|
126
|
+
'index.ts',
|
|
127
|
+
],
|
|
91
128
|
card: [
|
|
92
129
|
'card.directives.ts',
|
|
93
130
|
'card.variants.ts',
|
|
94
131
|
'index.ts',
|
|
95
132
|
],
|
|
133
|
+
carousel: [
|
|
134
|
+
'carousel.directives.ts',
|
|
135
|
+
'index.ts',
|
|
136
|
+
],
|
|
137
|
+
'chat-bubble': [
|
|
138
|
+
'chat-bubble.directives.ts',
|
|
139
|
+
'index.ts',
|
|
140
|
+
],
|
|
96
141
|
checkbox: [
|
|
97
142
|
'checkbox.directive.ts',
|
|
98
143
|
'checkbox.variants.ts',
|
|
@@ -103,12 +148,66 @@ const COMPONENT_FILES = {
|
|
|
103
148
|
'combobox.variants.ts',
|
|
104
149
|
'index.ts',
|
|
105
150
|
],
|
|
151
|
+
diff: [
|
|
152
|
+
'diff.component.ts',
|
|
153
|
+
'index.ts',
|
|
154
|
+
],
|
|
155
|
+
divider: [
|
|
156
|
+
'divider.component.ts',
|
|
157
|
+
'divider.variants.ts',
|
|
158
|
+
'index.ts',
|
|
159
|
+
],
|
|
160
|
+
dock: [
|
|
161
|
+
'dock.directives.ts',
|
|
162
|
+
'index.ts',
|
|
163
|
+
],
|
|
164
|
+
drawer: [
|
|
165
|
+
'drawer.directives.ts',
|
|
166
|
+
'index.ts',
|
|
167
|
+
],
|
|
168
|
+
dropdown: [
|
|
169
|
+
'dropdown.directives.ts',
|
|
170
|
+
'dropdown.variants.ts',
|
|
171
|
+
'index.ts',
|
|
172
|
+
],
|
|
173
|
+
fab: [
|
|
174
|
+
'fab.directives.ts',
|
|
175
|
+
'index.ts',
|
|
176
|
+
],
|
|
177
|
+
fieldset: [
|
|
178
|
+
'fieldset.directives.ts',
|
|
179
|
+
'fieldset.variants.ts',
|
|
180
|
+
'index.ts',
|
|
181
|
+
],
|
|
182
|
+
'file-input': [
|
|
183
|
+
'file-input.component.ts',
|
|
184
|
+
'file-input.variants.ts',
|
|
185
|
+
'index.ts',
|
|
186
|
+
],
|
|
187
|
+
indicator: [
|
|
188
|
+
'indicator.directives.ts',
|
|
189
|
+
'index.ts',
|
|
190
|
+
],
|
|
106
191
|
input: [
|
|
107
192
|
'input.directive.ts',
|
|
108
193
|
'input.variants.ts',
|
|
109
194
|
'label.directive.ts',
|
|
110
195
|
'index.ts',
|
|
111
196
|
],
|
|
197
|
+
kbd: [
|
|
198
|
+
'kbd.directive.ts',
|
|
199
|
+
'kbd.variants.ts',
|
|
200
|
+
'index.ts',
|
|
201
|
+
],
|
|
202
|
+
link: [
|
|
203
|
+
'link.directive.ts',
|
|
204
|
+
'link.variants.ts',
|
|
205
|
+
'index.ts',
|
|
206
|
+
],
|
|
207
|
+
list: [
|
|
208
|
+
'list.directives.ts',
|
|
209
|
+
'index.ts',
|
|
210
|
+
],
|
|
112
211
|
loader: [
|
|
113
212
|
'loader.component.ts',
|
|
114
213
|
'loader.variants.ts',
|
|
@@ -121,11 +220,34 @@ const COMPONENT_FILES = {
|
|
|
121
220
|
'dialog.directives.ts',
|
|
122
221
|
'index.ts',
|
|
123
222
|
],
|
|
223
|
+
navbar: [
|
|
224
|
+
'navbar.directives.ts',
|
|
225
|
+
'index.ts',
|
|
226
|
+
],
|
|
227
|
+
pagination: [
|
|
228
|
+
'pagination.component.ts',
|
|
229
|
+
'pagination.variants.ts',
|
|
230
|
+
'index.ts',
|
|
231
|
+
],
|
|
232
|
+
progress: [
|
|
233
|
+
'progress.component.ts',
|
|
234
|
+
'progress.variants.ts',
|
|
235
|
+
'index.ts',
|
|
236
|
+
],
|
|
237
|
+
'radial-progress': [
|
|
238
|
+
'radial-progress.component.ts',
|
|
239
|
+
'index.ts',
|
|
240
|
+
],
|
|
124
241
|
radio: [
|
|
125
242
|
'radio.directive.ts',
|
|
126
243
|
'radio.variants.ts',
|
|
127
244
|
'index.ts',
|
|
128
245
|
],
|
|
246
|
+
rating: [
|
|
247
|
+
'rating.component.ts',
|
|
248
|
+
'rating.variants.ts',
|
|
249
|
+
'index.ts',
|
|
250
|
+
],
|
|
129
251
|
select: [
|
|
130
252
|
'select.component.ts',
|
|
131
253
|
'select.variants.ts',
|
|
@@ -148,6 +270,19 @@ const COMPONENT_FILES = {
|
|
|
148
270
|
'slider.variants.ts',
|
|
149
271
|
'index.ts',
|
|
150
272
|
],
|
|
273
|
+
stat: [
|
|
274
|
+
'stat.directives.ts',
|
|
275
|
+
'index.ts',
|
|
276
|
+
],
|
|
277
|
+
status: [
|
|
278
|
+
'status.directive.ts',
|
|
279
|
+
'status.variants.ts',
|
|
280
|
+
'index.ts',
|
|
281
|
+
],
|
|
282
|
+
steps: [
|
|
283
|
+
'steps.directives.ts',
|
|
284
|
+
'index.ts',
|
|
285
|
+
],
|
|
151
286
|
switch: [
|
|
152
287
|
'switch.component.ts',
|
|
153
288
|
'switch.variants.ts',
|
|
@@ -163,6 +298,15 @@ const COMPONENT_FILES = {
|
|
|
163
298
|
'tabs.variants.ts',
|
|
164
299
|
'index.ts',
|
|
165
300
|
],
|
|
301
|
+
textarea: [
|
|
302
|
+
'textarea.directive.ts',
|
|
303
|
+
'textarea.variants.ts',
|
|
304
|
+
'index.ts',
|
|
305
|
+
],
|
|
306
|
+
timeline: [
|
|
307
|
+
'timeline.directives.ts',
|
|
308
|
+
'index.ts',
|
|
309
|
+
],
|
|
166
310
|
toast: [
|
|
167
311
|
'toast.service.ts',
|
|
168
312
|
'toast.variants.ts',
|
|
@@ -174,30 +318,67 @@ const COMPONENT_FILES = {
|
|
|
174
318
|
'toggle.variants.ts',
|
|
175
319
|
'index.ts',
|
|
176
320
|
],
|
|
321
|
+
tooltip: [
|
|
322
|
+
'tooltip.directive.ts',
|
|
323
|
+
'tooltip.variants.ts',
|
|
324
|
+
'index.ts',
|
|
325
|
+
],
|
|
326
|
+
validator: [
|
|
327
|
+
'validator.directives.ts',
|
|
328
|
+
'index.ts',
|
|
329
|
+
],
|
|
177
330
|
};
|
|
178
331
|
const COMPONENT_SPEC_FILES = {
|
|
179
332
|
accordion: ['accordion.directives.spec.ts'],
|
|
333
|
+
alert: ['alert.directives.spec.ts'],
|
|
180
334
|
avatar: ['avatar.component.spec.ts'],
|
|
181
335
|
badge: ['badge.directive.spec.ts'],
|
|
182
336
|
breadcrumb: ['breadcrumb.directives.spec.ts'],
|
|
183
337
|
button: ['button.directive.spec.ts'],
|
|
184
338
|
'button-group': ['button-group.directive.spec.ts'],
|
|
339
|
+
calendar: ['calendar.component.spec.ts'],
|
|
185
340
|
card: ['card.directives.spec.ts'],
|
|
341
|
+
carousel: ['carousel.directives.spec.ts'],
|
|
342
|
+
'chat-bubble': ['chat-bubble.directives.spec.ts'],
|
|
186
343
|
checkbox: ['checkbox.directive.spec.ts'],
|
|
187
344
|
combobox: ['combobox.component.spec.ts'],
|
|
345
|
+
diff: ['diff.component.spec.ts'],
|
|
346
|
+
divider: ['divider.component.spec.ts'],
|
|
347
|
+
dock: ['dock.directives.spec.ts'],
|
|
348
|
+
drawer: ['drawer.directives.spec.ts'],
|
|
349
|
+
dropdown: ['dropdown.directives.spec.ts'],
|
|
350
|
+
fab: ['fab.directives.spec.ts'],
|
|
351
|
+
fieldset: ['fieldset.directives.spec.ts'],
|
|
352
|
+
'file-input': ['file-input.component.spec.ts'],
|
|
353
|
+
indicator: ['indicator.directives.spec.ts'],
|
|
188
354
|
input: ['input.directive.spec.ts'],
|
|
355
|
+
kbd: ['kbd.directive.spec.ts'],
|
|
356
|
+
link: ['link.directive.spec.ts'],
|
|
357
|
+
list: ['list.directives.spec.ts'],
|
|
189
358
|
loader: ['loader.component.spec.ts'],
|
|
190
359
|
modal: ['dialog.service.spec.ts'],
|
|
360
|
+
navbar: ['navbar.directives.spec.ts'],
|
|
361
|
+
pagination: ['pagination.component.spec.ts'],
|
|
362
|
+
progress: ['progress.component.spec.ts'],
|
|
363
|
+
'radial-progress': ['radial-progress.component.spec.ts'],
|
|
191
364
|
radio: ['radio.directive.spec.ts'],
|
|
365
|
+
rating: ['rating.component.spec.ts'],
|
|
192
366
|
select: ['select.component.spec.ts'],
|
|
193
367
|
sheet: ['sheet.component.spec.ts'],
|
|
194
368
|
skeleton: ['skeleton.directive.spec.ts'],
|
|
195
369
|
slider: ['slider.component.spec.ts'],
|
|
370
|
+
stat: ['stat.directives.spec.ts'],
|
|
371
|
+
status: ['status.directive.spec.ts'],
|
|
372
|
+
steps: ['steps.directives.spec.ts'],
|
|
196
373
|
switch: ['switch.component.spec.ts'],
|
|
197
374
|
table: ['table.directives.spec.ts'],
|
|
198
375
|
tabs: ['tabs.directives.spec.ts'],
|
|
376
|
+
textarea: ['textarea.directive.spec.ts'],
|
|
377
|
+
timeline: ['timeline.directives.spec.ts'],
|
|
199
378
|
toast: ['toast.service.spec.ts'],
|
|
200
379
|
toggle: ['toggle.directive.spec.ts'],
|
|
380
|
+
tooltip: ['tooltip.directive.spec.ts'],
|
|
381
|
+
validator: ['validator.directives.spec.ts'],
|
|
201
382
|
};
|
|
202
383
|
function generateComponent(options) {
|
|
203
384
|
return (tree, context) => {
|
|
@@ -212,12 +393,12 @@ function generateComponent(options) {
|
|
|
212
393
|
// Ensure cn.ts utility exists
|
|
213
394
|
const cnTargetPath = `${targetDir}/utils/cn.ts`;
|
|
214
395
|
if (!tree.exists(cnTargetPath)) {
|
|
215
|
-
const cnContent = `import { clsx, type ClassValue } from 'clsx';
|
|
216
|
-
import { twMerge } from 'tailwind-merge';
|
|
217
|
-
|
|
218
|
-
export function cn(...inputs: ClassValue[]): string {
|
|
219
|
-
return twMerge(clsx(inputs));
|
|
220
|
-
}
|
|
396
|
+
const cnContent = `import { clsx, type ClassValue } from 'clsx';
|
|
397
|
+
import { twMerge } from 'tailwind-merge';
|
|
398
|
+
|
|
399
|
+
export function cn(...inputs: ClassValue[]): string {
|
|
400
|
+
return twMerge(clsx(inputs));
|
|
401
|
+
}
|
|
221
402
|
`;
|
|
222
403
|
tree.create(cnTargetPath, cnContent);
|
|
223
404
|
context.logger.info('Created utils/cn.ts');
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/schema",
|
|
3
|
-
"$id": "SonnyUIGenerateComponentSchema",
|
|
4
|
-
"title": "SonnyUI component generator (copy-paste style)",
|
|
5
|
-
"type": "object",
|
|
6
|
-
"properties": {
|
|
7
|
-
"name": {
|
|
8
|
-
"type": "string",
|
|
9
|
-
"description": "The component to copy (accordion, avatar, badge, breadcrumb, button, button-group, card, checkbox, combobox, input, loader, modal, radio, select, sheet, skeleton, slider, switch, table, tabs, toast, toggle).",
|
|
10
|
-
"$default": {
|
|
11
|
-
"$source": "argv",
|
|
12
|
-
"index": 0
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
"path": {
|
|
16
|
-
"type": "string",
|
|
17
|
-
"default": "src/app/ui",
|
|
18
|
-
"description": "The path to copy the component into."
|
|
19
|
-
},
|
|
20
|
-
"prefix": {
|
|
21
|
-
"type": "string",
|
|
22
|
-
"default": "sny",
|
|
23
|
-
"description": "The prefix to use for selectors."
|
|
24
|
-
},
|
|
25
|
-
"skipTests": {
|
|
26
|
-
"type": "boolean",
|
|
27
|
-
"default": false,
|
|
28
|
-
"description": "Skip copying test files."
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
"required": ["name"]
|
|
32
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "SonnyUIGenerateComponentSchema",
|
|
4
|
+
"title": "SonnyUI component generator (copy-paste style)",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"name": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "The component to copy (accordion, alert, avatar, badge, breadcrumb, button, button-group, calendar, card, carousel, chat-bubble, checkbox, combobox, diff, divider, dock, drawer, dropdown, fab, fieldset, file-input, indicator, input, kbd, link, list, loader, modal, navbar, pagination, progress, radial-progress, radio, rating, select, sheet, skeleton, slider, stat, status, steps, switch, table, tabs, textarea, timeline, toast, toggle, tooltip, validator).",
|
|
10
|
+
"$default": {
|
|
11
|
+
"$source": "argv",
|
|
12
|
+
"index": 0
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"path": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"default": "src/app/ui",
|
|
18
|
+
"description": "The path to copy the component into."
|
|
19
|
+
},
|
|
20
|
+
"prefix": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"default": "sny",
|
|
23
|
+
"description": "The prefix to use for selectors."
|
|
24
|
+
},
|
|
25
|
+
"skipTests": {
|
|
26
|
+
"type": "boolean",
|
|
27
|
+
"default": false,
|
|
28
|
+
"description": "Skip copying test files."
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"required": ["name"]
|
|
32
|
+
}
|
package/types/sonny-ui-core.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ declare function cn(...inputs: ClassValue[]): string;
|
|
|
13
13
|
|
|
14
14
|
interface SonnyConfig {
|
|
15
15
|
prefix?: string;
|
|
16
|
-
defaultTheme?: 'light' | 'dark' | 'corporate';
|
|
16
|
+
defaultTheme?: 'light' | 'dark' | 'corporate' | 'system';
|
|
17
17
|
}
|
|
18
18
|
declare const SNY_CONFIG: InjectionToken<SonnyConfig>;
|
|
19
19
|
declare function provideSonnyUI(config?: Partial<SonnyConfig>): EnvironmentProviders;
|
|
@@ -22,11 +22,14 @@ type Theme = 'light' | 'dark' | 'corporate';
|
|
|
22
22
|
declare class ThemeService {
|
|
23
23
|
private readonly document;
|
|
24
24
|
private readonly isBrowser;
|
|
25
|
+
private readonly config;
|
|
25
26
|
private readonly _theme;
|
|
26
27
|
readonly theme: _angular_core.Signal<Theme>;
|
|
27
28
|
readonly isDark: _angular_core.Signal<boolean>;
|
|
29
|
+
constructor();
|
|
28
30
|
setTheme(theme: Theme): void;
|
|
29
31
|
toggleDark(): void;
|
|
32
|
+
private resolveInitialTheme;
|
|
30
33
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<ThemeService, never>;
|
|
31
34
|
static ɵprov: _angular_core.ɵɵInjectableDeclaration<ThemeService>;
|
|
32
35
|
}
|