@trineui/cli 0.1.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/dist/index.js +662 -0
- package/package.json +41 -0
- package/src/commands/add.ts +101 -0
- package/src/commands/diff.test.ts +55 -0
- package/src/commands/diff.ts +104 -0
- package/src/commands/eject.ts +95 -0
- package/src/commands/init.ts +92 -0
- package/src/commands/sync-interactive.ts +108 -0
- package/src/commands/sync.test.ts +35 -0
- package/src/commands/sync.ts +113 -0
- package/src/index.ts +18 -0
- package/src/types/manifest.ts +14 -0
- package/src/utils/__tests__/hash.test.ts +35 -0
- package/src/utils/__tests__/template.test.ts +47 -0
- package/src/utils/eject-merger.ts +149 -0
- package/src/utils/hash.ts +43 -0
- package/src/utils/manifest.ts +43 -0
- package/src/utils/template.ts +26 -0
- package/templates/button.blueprint.ts.hbs +41 -0
- package/templates/button.skin.ts.hbs +35 -0
- package/templates/checkbox.blueprint.ts.hbs +57 -0
- package/templates/checkbox.skin.ts.hbs +44 -0
- package/templates/dialog.blueprint.ts.hbs +61 -0
- package/templates/dialog.skin.ts.hbs +27 -0
- package/templates/input.blueprint.ts.hbs +83 -0
- package/templates/input.skin.ts.hbs +29 -0
- package/templates/select.blueprint.ts.hbs +86 -0
- package/templates/select.skin.ts.hbs +53 -0
- package/tsconfig.json +10 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// @trine-generated
|
|
2
|
+
// @trine-version: {{engineVersion}}
|
|
3
|
+
// @trine-schema: {{blueprintSchemaVersion}}
|
|
4
|
+
import {
|
|
5
|
+
ChangeDetectionStrategy,
|
|
6
|
+
Component,
|
|
7
|
+
inject,
|
|
8
|
+
ViewChild,
|
|
9
|
+
ViewContainerRef,
|
|
10
|
+
} from '@angular/core';
|
|
11
|
+
import { DialogEngine } from '@trineui/engine/dialog';
|
|
12
|
+
import { DialogSkin } from './dialog.skin';
|
|
13
|
+
import { DIALOG_STYLING_CONTRACT } from '@trineui/engine/dialog';
|
|
14
|
+
|
|
15
|
+
@Component({
|
|
16
|
+
selector: 'ui-dialog',
|
|
17
|
+
standalone: true,
|
|
18
|
+
providers: [
|
|
19
|
+
DialogEngine,
|
|
20
|
+
{
|
|
21
|
+
provide: DIALOG_STYLING_CONTRACT,
|
|
22
|
+
useExisting: DialogEngine,
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
template: `
|
|
26
|
+
<ng-template #dialogContent>
|
|
27
|
+
<div
|
|
28
|
+
class="dialog-panel"
|
|
29
|
+
role="dialog"
|
|
30
|
+
aria-modal="true"
|
|
31
|
+
[attr.aria-labelledby]="titleId"
|
|
32
|
+
[attr.data-state]="engine.dialogState()"
|
|
33
|
+
>
|
|
34
|
+
<ng-content select="[slot=title]"></ng-content>
|
|
35
|
+
<ng-content select="[slot=body]"></ng-content>
|
|
36
|
+
<ng-content select="[slot=footer]"></ng-content>
|
|
37
|
+
</div>
|
|
38
|
+
</ng-template>
|
|
39
|
+
`,
|
|
40
|
+
host: {
|
|
41
|
+
'[class]': 'skin.classes()',
|
|
42
|
+
},
|
|
43
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
44
|
+
})
|
|
45
|
+
export class DialogComponent {
|
|
46
|
+
protected engine = inject(DialogEngine);
|
|
47
|
+
protected skin = inject(DialogSkin);
|
|
48
|
+
protected vcr = inject(ViewContainerRef);
|
|
49
|
+
protected titleId = `dialog-title-${Math.random().toString(36).slice(2)}`;
|
|
50
|
+
|
|
51
|
+
@ViewChild('dialogContent') dialogContent: any;
|
|
52
|
+
|
|
53
|
+
open(): void {
|
|
54
|
+
this.engine.setViewContainerRef(this.vcr);
|
|
55
|
+
this.engine.open(this.dialogContent);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
close(): void {
|
|
59
|
+
this.engine.close();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// @trine-owned
|
|
2
|
+
// DO NOT EDIT — owned by user, never synced
|
|
3
|
+
import { cva } from 'class-variance-authority';
|
|
4
|
+
import { inject, Injectable } from '@angular/core';
|
|
5
|
+
import { DIALOG_STYLING_CONTRACT, DialogStylingContract, DialogState } from '@trineui/engine/dialog';
|
|
6
|
+
|
|
7
|
+
@Injectable()
|
|
8
|
+
export class DialogSkin {
|
|
9
|
+
private contract = inject(DIALOG_STYLING_CONTRACT);
|
|
10
|
+
|
|
11
|
+
private dialogVariants = cva('dialog-base', {
|
|
12
|
+
variants: {
|
|
13
|
+
state: {
|
|
14
|
+
open: 'dialog-open',
|
|
15
|
+
closed: 'dialog-closed',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
defaultVariants: {
|
|
19
|
+
state: 'closed',
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
classes(): string {
|
|
24
|
+
const state = this.contract.dialogState();
|
|
25
|
+
return this.dialogVariants({ state });
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// @trine-generated
|
|
2
|
+
// @trine-version: {{engineVersion}}
|
|
3
|
+
// @trine-schema: {{blueprintSchemaVersion}}
|
|
4
|
+
import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
|
|
5
|
+
import { InputEngine } from '@trineui/engine/input';
|
|
6
|
+
import { InputSkin } from './input.skin';
|
|
7
|
+
import { INPUT_STYLING_CONTRACT } from '@trineui/engine/input';
|
|
8
|
+
|
|
9
|
+
@Component({
|
|
10
|
+
selector: 'ui-input',
|
|
11
|
+
standalone: true,
|
|
12
|
+
hostDirectives: [
|
|
13
|
+
{
|
|
14
|
+
directive: InputEngine,
|
|
15
|
+
inputs: ['value', 'disabled', 'readonly', 'required', 'placeholder', 'errorMessage'],
|
|
16
|
+
outputs: ['valueChange'],
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
providers: [
|
|
20
|
+
InputSkin,
|
|
21
|
+
{
|
|
22
|
+
provide: INPUT_STYLING_CONTRACT,
|
|
23
|
+
useExisting: InputEngine,
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
template: `
|
|
27
|
+
<div class="input-wrapper" [attr.data-state]="engine.inputState()">
|
|
28
|
+
@if (engine.hasPrefix()) {
|
|
29
|
+
<div class="input-prefix">
|
|
30
|
+
<ng-content select="[slot=prefix]"></ng-content>
|
|
31
|
+
</div>
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
<input
|
|
35
|
+
class="input-field"
|
|
36
|
+
[value]="engine.value()"
|
|
37
|
+
[disabled]="engine.disabled()"
|
|
38
|
+
[readOnly]="engine.readonly()"
|
|
39
|
+
[placeholder]="engine.placeholder()"
|
|
40
|
+
[attr.aria-invalid]="engine.ariaInvalid()"
|
|
41
|
+
[attr.aria-required]="engine.ariaRequired()"
|
|
42
|
+
[attr.aria-describedby]="hintId"
|
|
43
|
+
(input)="onInput($event)"
|
|
44
|
+
(focus)="engine.isFocused.set(true)"
|
|
45
|
+
(blur)="onBlur()"
|
|
46
|
+
/>
|
|
47
|
+
|
|
48
|
+
@if (engine.hasSuffix()) {
|
|
49
|
+
<div class="input-suffix">
|
|
50
|
+
<ng-content select="[slot=suffix]"></ng-content>
|
|
51
|
+
</div>
|
|
52
|
+
}
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
@if (engine.hasHint() || engine.isInvalid()) {
|
|
56
|
+
<div [id]="hintId" class="input-hint">
|
|
57
|
+
<ng-content select="[slot=hint]"></ng-content>
|
|
58
|
+
@if (engine.isInvalid() && engine.errorMessage()) {
|
|
59
|
+
<span class="input-error">\{{ engine.errorMessage() }}</span>
|
|
60
|
+
}
|
|
61
|
+
</div>
|
|
62
|
+
}
|
|
63
|
+
`,
|
|
64
|
+
host: {
|
|
65
|
+
'[class]': 'skin.classes()',
|
|
66
|
+
},
|
|
67
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
68
|
+
})
|
|
69
|
+
export class InputComponent {
|
|
70
|
+
protected engine = inject(InputEngine);
|
|
71
|
+
protected skin = inject(InputSkin);
|
|
72
|
+
protected hintId = `input-hint-${Math.random().toString(36).slice(2)}`;
|
|
73
|
+
|
|
74
|
+
onInput(event: Event): void {
|
|
75
|
+
const target = event.target as HTMLInputElement;
|
|
76
|
+
this.engine.value.set(target.value);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
onBlur(): void {
|
|
80
|
+
this.engine.isFocused.set(false);
|
|
81
|
+
this.engine.markTouched();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// @trine-owned
|
|
2
|
+
// DO NOT EDIT — owned by user, never synced
|
|
3
|
+
import { cva } from 'class-variance-authority';
|
|
4
|
+
import { inject, Injectable } from '@angular/core';
|
|
5
|
+
import { INPUT_STYLING_CONTRACT, InputStylingContract, InputState } from '@trineui/engine/input';
|
|
6
|
+
|
|
7
|
+
@Injectable()
|
|
8
|
+
export class InputSkin {
|
|
9
|
+
private contract = inject(INPUT_STYLING_CONTRACT);
|
|
10
|
+
|
|
11
|
+
private inputVariants = cva('input-field-base', {
|
|
12
|
+
variants: {
|
|
13
|
+
state: {
|
|
14
|
+
idle: 'input-idle',
|
|
15
|
+
focused: 'input-focused',
|
|
16
|
+
error: 'input-error',
|
|
17
|
+
disabled: 'input-disabled',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
defaultVariants: {
|
|
21
|
+
state: 'idle',
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
classes(): string {
|
|
26
|
+
const state = this.contract.inputState();
|
|
27
|
+
return this.inputVariants({ state });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// @trine-generated
|
|
2
|
+
// @trine-version: {{engineVersion}}
|
|
3
|
+
// @trine-schema: {{blueprintSchemaVersion}}
|
|
4
|
+
import {
|
|
5
|
+
AfterViewInit,
|
|
6
|
+
ChangeDetectionStrategy,
|
|
7
|
+
Component,
|
|
8
|
+
inject,
|
|
9
|
+
ViewChild,
|
|
10
|
+
ViewContainerRef,
|
|
11
|
+
} from '@angular/core';
|
|
12
|
+
import { SelectEngine } from '@trineui/engine/select';
|
|
13
|
+
import { SelectSkin } from './select.skin';
|
|
14
|
+
import { SELECT_STYLING_CONTRACT } from '@trineui/engine/select';
|
|
15
|
+
|
|
16
|
+
@Component({
|
|
17
|
+
selector: 'ui-select',
|
|
18
|
+
standalone: true,
|
|
19
|
+
providers: [
|
|
20
|
+
SelectEngine,
|
|
21
|
+
{
|
|
22
|
+
provide: SELECT_STYLING_CONTRACT,
|
|
23
|
+
useExisting: SelectEngine,
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
template: `
|
|
27
|
+
<button
|
|
28
|
+
type="button"
|
|
29
|
+
class="select-trigger"
|
|
30
|
+
role="combobox"
|
|
31
|
+
[attr.aria-expanded]="engine.ariaExpanded()"
|
|
32
|
+
[attr.aria-haspopup]="'listbox'"
|
|
33
|
+
[attr.aria-activedescendant]="engine.ariaActiveDescendant()"
|
|
34
|
+
[attr.data-state]="engine.selectState()"
|
|
35
|
+
[disabled]="engine.disabled()"
|
|
36
|
+
(click)="engine.toggle()"
|
|
37
|
+
(keydown)="engine.handleKeydown($event)"
|
|
38
|
+
>
|
|
39
|
+
<span class="select-value">\{{engine.selectedLabel()}}</span>
|
|
40
|
+
<span class="select-arrow" [attr.data-state]="engine.selectState()">
|
|
41
|
+
<svg viewBox="0 0 16 16" fill="none" class="select-arrow-icon">
|
|
42
|
+
<path d="M4 6L8 10L12 6" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
43
|
+
</svg>
|
|
44
|
+
</span>
|
|
45
|
+
</button>
|
|
46
|
+
|
|
47
|
+
<ng-template #panelTemplate>
|
|
48
|
+
<ul
|
|
49
|
+
class="select-panel"
|
|
50
|
+
role="listbox"
|
|
51
|
+
[attr.data-state]="engine.selectState()"
|
|
52
|
+
>
|
|
53
|
+
@for (option of engine.options(); track option.value; let i = $index) {
|
|
54
|
+
<li
|
|
55
|
+
role="option"
|
|
56
|
+
[id]="'select-option-' + i"
|
|
57
|
+
class="select-option"
|
|
58
|
+
[class.select-option-disabled]="option.disabled"
|
|
59
|
+
[attr.aria-selected]="engine.selectedValue() === option.value"
|
|
60
|
+
[attr.aria-disabled]="option.disabled ?? false"
|
|
61
|
+
[attr.data-state]="engine.selectedValue() === option.value ? 'selected' : 'unselected'"
|
|
62
|
+
[attr.data-active]="engine.activeIndex() === i ? 'true' : 'false'"
|
|
63
|
+
(click)="!option.disabled && engine.selectOption(option.value)"
|
|
64
|
+
>
|
|
65
|
+
{{ option.label }}
|
|
66
|
+
</li>
|
|
67
|
+
}
|
|
68
|
+
</ul>
|
|
69
|
+
</ng-template>
|
|
70
|
+
`,
|
|
71
|
+
host: {
|
|
72
|
+
'[class]': 'skin.classes()',
|
|
73
|
+
},
|
|
74
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
75
|
+
})
|
|
76
|
+
export class SelectComponent implements AfterViewInit {
|
|
77
|
+
protected engine = inject(SelectEngine);
|
|
78
|
+
protected skin = inject(SelectSkin);
|
|
79
|
+
private vcr = inject(ViewContainerRef);
|
|
80
|
+
|
|
81
|
+
@ViewChild('panelTemplate') panelTemplate: any;
|
|
82
|
+
|
|
83
|
+
ngAfterViewInit(): void {
|
|
84
|
+
this.engine.registerPanel(this.panelTemplate, this.vcr);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// @trine-owned
|
|
2
|
+
// DO NOT EDIT — owned by user, never synced
|
|
3
|
+
import { cva } from 'class-variance-authority';
|
|
4
|
+
import { inject, Injectable } from '@angular/core';
|
|
5
|
+
import { SELECT_STYLING_CONTRACT, SelectStylingContract, SelectState } from '@trineui/engine/select';
|
|
6
|
+
|
|
7
|
+
@Injectable()
|
|
8
|
+
export class SelectSkin {
|
|
9
|
+
private contract = inject(SELECT_STYLING_CONTRACT);
|
|
10
|
+
|
|
11
|
+
private triggerVariants = cva('select-trigger-base', {
|
|
12
|
+
variants: {
|
|
13
|
+
state: {
|
|
14
|
+
open: 'select-trigger-open',
|
|
15
|
+
closed: 'select-trigger-closed',
|
|
16
|
+
},
|
|
17
|
+
disabled: {
|
|
18
|
+
true: 'select-trigger-disabled',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
compoundVariants: [
|
|
22
|
+
{
|
|
23
|
+
state: 'open',
|
|
24
|
+
disabled: true,
|
|
25
|
+
class: 'select-trigger-open-disabled',
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
defaultVariants: {
|
|
29
|
+
state: 'closed',
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
private panelVariants = cva('select-panel-base', {
|
|
34
|
+
variants: {
|
|
35
|
+
state: {
|
|
36
|
+
open: 'select-panel-open',
|
|
37
|
+
closed: 'select-panel-closed',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
defaultVariants: {
|
|
41
|
+
state: 'closed',
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
classes(): string {
|
|
46
|
+
const state = this.contract.selectState();
|
|
47
|
+
const disabled = this.contract.disabled();
|
|
48
|
+
return [
|
|
49
|
+
this.triggerVariants({ state, disabled }),
|
|
50
|
+
this.panelVariants({ state }),
|
|
51
|
+
].join(' ');
|
|
52
|
+
}
|
|
53
|
+
}
|