@wawjs/ngx-bos 22.0.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/AGENTS.md +23 -0
- package/README.md +105 -0
- package/RELEASES.md +21 -0
- package/ai/architecture.md +40 -0
- package/ai/code-style.md +33 -0
- package/ai/decisions/2026-06-02-browser-only-bos-spa.md +16 -0
- package/ai/decisions/2026-06-02-package-boundary.md +22 -0
- package/ai/decisions/2026-06-02-version-start.md +12 -0
- package/ai/decisions/index.md +7 -0
- package/ai/onboarding.md +19 -0
- package/ai/task-execution.md +35 -0
- package/ai/tooling.md +33 -0
- package/fesm2022/wawjs-ngx-bos.mjs +2287 -0
- package/fesm2022/wawjs-ngx-bos.mjs.map +1 -0
- package/package.json +38 -0
- package/src/feature/file/file.component.html +123 -0
- package/src/feature/file/file.component.scss +209 -0
- package/src/feature/file/file.component.ts +220 -0
- package/src/feature/file/file.const.ts +20 -0
- package/src/feature/file/file.interface.ts +12 -0
- package/src/feature/file/file.service.ts +34 -0
- package/src/feature/file/file.util.ts +72 -0
- package/src/feature/file/index.ts +9 -0
- package/src/feature/file/pages/files/files.component.html +12 -0
- package/src/feature/file/pages/files/files.component.ts +117 -0
- package/src/feature/file/pages/files/files.routes.ts +9 -0
- package/src/feature/file/selectors/file/file-selector.component.html +11 -0
- package/src/feature/file/selectors/file/file-selector.component.ts +27 -0
- package/src/feature/user/LICENSE +21 -0
- package/src/feature/user/README.md +1 -0
- package/src/feature/user/components/user-preview/user-preview.component.html +7 -0
- package/src/feature/user/components/user-preview/user-preview.component.scss +27 -0
- package/src/feature/user/components/user-preview/user-preview.component.ts +16 -0
- package/src/feature/user/guards/admins.guard.ts +22 -0
- package/src/feature/user/guards/authenticated.guard.ts +14 -0
- package/src/feature/user/guards/guest.guard.ts +14 -0
- package/src/feature/user/module.json +1 -0
- package/src/feature/user/pages/clients/clients.component.html +8 -0
- package/src/feature/user/pages/clients/clients.component.scss +0 -0
- package/src/feature/user/pages/clients/clients.component.ts +45 -0
- package/src/feature/user/pages/clients/clients.routes.ts +9 -0
- package/src/feature/user/pages/users/users.component.html +18 -0
- package/src/feature/user/pages/users/users.component.ts +57 -0
- package/src/feature/user/pages/users/users.routes.ts +9 -0
- package/src/feature/user/selectors/user/user-selector.component.html +6 -0
- package/src/feature/user/selectors/user/user-selector.component.scss +0 -0
- package/src/feature/user/selectors/user/user-selector.component.ts +17 -0
- package/src/feature/user/user.const.ts +13 -0
- package/src/feature/user/user.form.ts +54 -0
- package/src/feature/user/user.interface.ts +12 -0
- package/src/feature/user/user.service.ts +176 -0
- package/src/form-components/ace/ace.component.html +14 -0
- package/src/form-components/ace/ace.component.scss +22 -0
- package/src/form-components/ace/ace.component.ts +210 -0
- package/src/form-components/ace/ace.form.ts +184 -0
- package/src/form-components/button/button.component.html +15 -0
- package/src/form-components/button/button.component.ts +31 -0
- package/src/form-components/button/button.form.ts +74 -0
- package/src/form-components/file/file.component.html +73 -0
- package/src/form-components/file/file.component.ts +91 -0
- package/src/form-components/file/file.form.ts +112 -0
- package/src/form-components/form-bridge.interface.ts +27 -0
- package/src/form-components/index.ts +85 -0
- package/src/form-components/input/input.component.html +16 -0
- package/src/form-components/input/input.component.ts +31 -0
- package/src/form-components/input/input.form.ts +117 -0
- package/src/form-components/select/select.component.html +24 -0
- package/src/form-components/select/select.component.ts +31 -0
- package/src/form-components/select/select.form.ts +88 -0
- package/src/form-components/tinymce/tinymce.component.html +13 -0
- package/src/form-components/tinymce/tinymce.component.scss +19 -0
- package/src/form-components/tinymce/tinymce.component.ts +221 -0
- package/src/form-components/tinymce/tinymce.form.ts +191 -0
- package/src/icons/spider/LICENSE +21 -0
- package/src/icons/spider/README.md +127 -0
- package/src/icons/spider/index.ts +1 -0
- package/src/icons/spider/module.json +4 -0
- package/src/icons/spider/spider.component.html +115 -0
- package/src/icons/spider/spider.component.scss +20 -0
- package/src/icons/spider/spider.component.ts +20 -0
- package/src/ngx-bos.config.ts +55 -0
- package/src/pages/form/form.component.html +9 -0
- package/src/pages/form/form.component.ts +86 -0
- package/src/pages/form/form.routes.ts +9 -0
- package/src/pages/forms/forms.component.html +9 -0
- package/src/pages/forms/forms.component.ts +77 -0
- package/src/pages/forms/forms.routes.ts +9 -0
- package/src/pipes/phone.pipe.ts +17 -0
- package/src/public-api.ts +36 -0
- package/types/wawjs-ngx-bos.d.ts +332 -0
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Component,
|
|
3
|
+
OnInit,
|
|
4
|
+
TemplateRef,
|
|
5
|
+
inject,
|
|
6
|
+
viewChild,
|
|
7
|
+
} from '@angular/core';
|
|
8
|
+
import { AceComponent, AceConfigInterface } from '@wawjs/ngx-ace';
|
|
9
|
+
import { FormService } from '@wawjs/ngx-form';
|
|
10
|
+
import { FormBridgeData } from '../form-bridge.interface';
|
|
11
|
+
|
|
12
|
+
interface Interface {}
|
|
13
|
+
|
|
14
|
+
const DEFAULT_ACE_CONFIG: AceConfigInterface = {
|
|
15
|
+
// keep empty if you don’t want global defaults
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
@Component({
|
|
19
|
+
templateUrl: './ace.component.html',
|
|
20
|
+
styleUrl: './ace.component.scss',
|
|
21
|
+
imports: [AceComponent],
|
|
22
|
+
})
|
|
23
|
+
export class AceFormComponent implements OnInit {
|
|
24
|
+
private readonly _form = inject(FormService);
|
|
25
|
+
|
|
26
|
+
readonly templateRef =
|
|
27
|
+
viewChild.required<TemplateRef<Interface>>('templateRef');
|
|
28
|
+
|
|
29
|
+
ngOnInit(): void {
|
|
30
|
+
this._form.addTemplateComponent<Interface>('Ace', this.templateRef());
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/* ------------ value bridge (Signal Forms + legacy) ------------ */
|
|
34
|
+
|
|
35
|
+
getValue(data: FormBridgeData): string {
|
|
36
|
+
const key = (data?.key as string | null) ?? null;
|
|
37
|
+
|
|
38
|
+
// Signal Forms field (preferred)
|
|
39
|
+
if (data?.field) {
|
|
40
|
+
try {
|
|
41
|
+
const state = data.field();
|
|
42
|
+
if (state?.value && typeof state.value === 'function') {
|
|
43
|
+
return (state.value() as string) ?? '';
|
|
44
|
+
}
|
|
45
|
+
} catch {
|
|
46
|
+
// fall through
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Model signal
|
|
51
|
+
if (data?.model && typeof data.model === 'function' && key) {
|
|
52
|
+
const current = data.model() as Record<string, unknown>;
|
|
53
|
+
return (current?.[key] as string) ?? '';
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Legacy submission object
|
|
57
|
+
if (!key || !data?.submition) return '';
|
|
58
|
+
return (data.submition[key] as string) ?? '';
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
onValueChange(data: FormBridgeData, value: string): void {
|
|
62
|
+
const key = (data?.key as string | null) ?? null;
|
|
63
|
+
|
|
64
|
+
// 1) Signal Forms field
|
|
65
|
+
if (data?.field) {
|
|
66
|
+
try {
|
|
67
|
+
const state = data.field();
|
|
68
|
+
if (state?.value?.set) state.value.set(value);
|
|
69
|
+
} catch {
|
|
70
|
+
// ignore and fall through
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// 2) Model signal
|
|
74
|
+
else if (
|
|
75
|
+
data?.model &&
|
|
76
|
+
typeof data.model.update === 'function' &&
|
|
77
|
+
key
|
|
78
|
+
) {
|
|
79
|
+
data.model.update((current: Record<string, unknown>) => ({
|
|
80
|
+
...current,
|
|
81
|
+
[key]: value,
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
84
|
+
// 3) Legacy submission object
|
|
85
|
+
else if (data?.submition && key) {
|
|
86
|
+
data.submition[key] = value;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (typeof data?.wChange === 'function') data.wChange();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/* ------------ config / props helpers ------------ */
|
|
93
|
+
|
|
94
|
+
getConfig(data: FormBridgeData): AceConfigInterface {
|
|
95
|
+
const props = (data?.props ?? {}) as Record<string, unknown>;
|
|
96
|
+
const config: AceConfigInterface = { ...DEFAULT_ACE_CONFIG };
|
|
97
|
+
|
|
98
|
+
const toNumber = (v: unknown): number | undefined => {
|
|
99
|
+
if (v === null || v === undefined || v === '') return undefined;
|
|
100
|
+
const n = Number(v);
|
|
101
|
+
return Number.isNaN(n) ? undefined : n;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
// Layout
|
|
105
|
+
const minLines = toNumber(props['minLines']);
|
|
106
|
+
const maxLines = toNumber(props['maxLines']);
|
|
107
|
+
const tabSize = toNumber(props['tabSize']);
|
|
108
|
+
|
|
109
|
+
if (
|
|
110
|
+
props['fontSize'] !== undefined &&
|
|
111
|
+
props['fontSize'] !== null &&
|
|
112
|
+
props['fontSize'] !== ''
|
|
113
|
+
) {
|
|
114
|
+
config.fontSize = String(props['fontSize']);
|
|
115
|
+
}
|
|
116
|
+
if (minLines !== undefined) config.minLines = minLines;
|
|
117
|
+
if (maxLines !== undefined) config.maxLines = maxLines;
|
|
118
|
+
if (tabSize !== undefined) config.tabSize = tabSize;
|
|
119
|
+
|
|
120
|
+
// Behavior toggles
|
|
121
|
+
if (typeof props['useSoftTabs'] === 'boolean')
|
|
122
|
+
config.useSoftTabs = props['useSoftTabs'];
|
|
123
|
+
if (typeof props['wrap'] === 'boolean') config.wrap = props['wrap'];
|
|
124
|
+
if (typeof props['showLineNumbers'] === 'boolean')
|
|
125
|
+
config.showLineNumbers = props['showLineNumbers'];
|
|
126
|
+
if (typeof props['showGutter'] === 'boolean')
|
|
127
|
+
config.showGutter = props['showGutter'];
|
|
128
|
+
if (typeof props['highlightActiveLine'] === 'boolean')
|
|
129
|
+
config.highlightActiveLine = props['highlightActiveLine'];
|
|
130
|
+
if (typeof props['showPrintMargin'] === 'boolean')
|
|
131
|
+
config.showPrintMargin = props['showPrintMargin'];
|
|
132
|
+
if (typeof props['readOnly'] === 'boolean')
|
|
133
|
+
config.readOnly = props['readOnly'];
|
|
134
|
+
if (typeof props['useWorker'] === 'boolean')
|
|
135
|
+
config.useWorker = props['useWorker'];
|
|
136
|
+
|
|
137
|
+
// Local config object from props
|
|
138
|
+
const localConfig = props['config'];
|
|
139
|
+
if (
|
|
140
|
+
localConfig &&
|
|
141
|
+
typeof localConfig === 'object' &&
|
|
142
|
+
!Array.isArray(localConfig)
|
|
143
|
+
) {
|
|
144
|
+
Object.assign(config, localConfig as Partial<AceConfigInterface>);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Per-field config (code-level override)
|
|
148
|
+
const fieldConfig = data?.field?.['Config'];
|
|
149
|
+
if (
|
|
150
|
+
fieldConfig &&
|
|
151
|
+
typeof fieldConfig === 'object' &&
|
|
152
|
+
!Array.isArray(fieldConfig)
|
|
153
|
+
) {
|
|
154
|
+
Object.assign(config, fieldConfig as Partial<AceConfigInterface>);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Extra config JSON string
|
|
158
|
+
const configJson = props['configJson'];
|
|
159
|
+
if (typeof configJson === 'string' && configJson.trim()) {
|
|
160
|
+
try {
|
|
161
|
+
const json: unknown = JSON.parse(configJson);
|
|
162
|
+
if (json && typeof json === 'object' && !Array.isArray(json)) {
|
|
163
|
+
Object.assign(config, json as Partial<AceConfigInterface>);
|
|
164
|
+
}
|
|
165
|
+
} catch {
|
|
166
|
+
// invalid JSON -> ignore
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return config;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
getMode(data: FormBridgeData): string {
|
|
174
|
+
const propsMode = data?.props?.['mode'];
|
|
175
|
+
const fieldMode = data?.field?.['Mode'];
|
|
176
|
+
|
|
177
|
+
if (propsMode) return String(propsMode);
|
|
178
|
+
if (fieldMode) return String(fieldMode);
|
|
179
|
+
|
|
180
|
+
return 'text';
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
getTheme(data: FormBridgeData): string {
|
|
184
|
+
const propsTheme = data?.props?.['theme'];
|
|
185
|
+
const fieldTheme = data?.field?.['Theme'];
|
|
186
|
+
|
|
187
|
+
if (propsTheme) return String(propsTheme);
|
|
188
|
+
if (fieldTheme) return String(fieldTheme);
|
|
189
|
+
|
|
190
|
+
return 'github';
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
isDisabled(data: FormBridgeData): boolean {
|
|
194
|
+
return !!(
|
|
195
|
+
data?.props?.['disabled'] ||
|
|
196
|
+
data?.component?.disabled ||
|
|
197
|
+
data?.field?.['Disabled']
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
getUseAceClass(data: FormBridgeData): boolean {
|
|
202
|
+
const prop = data?.props?.['useAceClass'];
|
|
203
|
+
if (typeof prop === 'boolean') return prop;
|
|
204
|
+
|
|
205
|
+
const field = data?.field?.['UseAceClass'];
|
|
206
|
+
if (typeof field === 'boolean') return field;
|
|
207
|
+
|
|
208
|
+
return true;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
export const aceForm = {
|
|
2
|
+
formId: 'ace',
|
|
3
|
+
title: 'Ace editor',
|
|
4
|
+
components: [
|
|
5
|
+
// Language / theme
|
|
6
|
+
{
|
|
7
|
+
name: 'Select',
|
|
8
|
+
key: 'mode',
|
|
9
|
+
props: {
|
|
10
|
+
label: 'Mode (language)',
|
|
11
|
+
placeholder: 'Select language mode...',
|
|
12
|
+
items: [
|
|
13
|
+
'text',
|
|
14
|
+
'javascript',
|
|
15
|
+
'typescript',
|
|
16
|
+
'json',
|
|
17
|
+
'html',
|
|
18
|
+
'css',
|
|
19
|
+
'scss',
|
|
20
|
+
'markdown',
|
|
21
|
+
'sql',
|
|
22
|
+
'yaml',
|
|
23
|
+
'xml',
|
|
24
|
+
'sh',
|
|
25
|
+
'powershell',
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'Select',
|
|
31
|
+
key: 'theme',
|
|
32
|
+
props: {
|
|
33
|
+
label: 'Theme',
|
|
34
|
+
placeholder: 'Select theme...',
|
|
35
|
+
items: [
|
|
36
|
+
'github',
|
|
37
|
+
'monokai',
|
|
38
|
+
'tomorrow',
|
|
39
|
+
'twilight',
|
|
40
|
+
'solarized_light',
|
|
41
|
+
'solarized_dark',
|
|
42
|
+
'dracula',
|
|
43
|
+
'chaos',
|
|
44
|
+
'chrome',
|
|
45
|
+
'clouds',
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
// Layout
|
|
51
|
+
{
|
|
52
|
+
name: 'Input',
|
|
53
|
+
key: 'fontSize',
|
|
54
|
+
props: {
|
|
55
|
+
label: 'Font size',
|
|
56
|
+
placeholder: 'Example: 12px or 12pt',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: 'Input',
|
|
61
|
+
key: 'minLines',
|
|
62
|
+
props: {
|
|
63
|
+
label: 'Min lines',
|
|
64
|
+
placeholder: 'e.g. 10',
|
|
65
|
+
type: 'number',
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: 'Input',
|
|
70
|
+
key: 'maxLines',
|
|
71
|
+
props: {
|
|
72
|
+
label: 'Max lines',
|
|
73
|
+
placeholder: 'e.g. 60',
|
|
74
|
+
type: 'number',
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
// Tabs / wrapping
|
|
79
|
+
{
|
|
80
|
+
name: 'Input',
|
|
81
|
+
key: 'tabSize',
|
|
82
|
+
props: {
|
|
83
|
+
label: 'Tab size',
|
|
84
|
+
placeholder: 'e.g. 2 or 4',
|
|
85
|
+
type: 'number',
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: 'Input',
|
|
90
|
+
key: 'useSoftTabs',
|
|
91
|
+
props: {
|
|
92
|
+
label: 'Use soft tabs (spaces)',
|
|
93
|
+
type: 'checkbox',
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
name: 'Input',
|
|
98
|
+
key: 'wrap',
|
|
99
|
+
props: {
|
|
100
|
+
label: 'Wrap long lines',
|
|
101
|
+
type: 'checkbox',
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
// Visibility / UX
|
|
106
|
+
{
|
|
107
|
+
name: 'Input',
|
|
108
|
+
key: 'showLineNumbers',
|
|
109
|
+
props: {
|
|
110
|
+
label: 'Show line numbers',
|
|
111
|
+
type: 'checkbox',
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: 'Input',
|
|
116
|
+
key: 'showGutter',
|
|
117
|
+
props: {
|
|
118
|
+
label: 'Show gutter',
|
|
119
|
+
type: 'checkbox',
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
name: 'Input',
|
|
124
|
+
key: 'highlightActiveLine',
|
|
125
|
+
props: {
|
|
126
|
+
label: 'Highlight active line',
|
|
127
|
+
type: 'checkbox',
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
name: 'Input',
|
|
132
|
+
key: 'showPrintMargin',
|
|
133
|
+
props: {
|
|
134
|
+
label: 'Show print margin',
|
|
135
|
+
type: 'checkbox',
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
// Behavior
|
|
140
|
+
{
|
|
141
|
+
name: 'Input',
|
|
142
|
+
key: 'readOnly',
|
|
143
|
+
props: {
|
|
144
|
+
label: 'Read only',
|
|
145
|
+
type: 'checkbox',
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
name: 'Input',
|
|
150
|
+
key: 'useWorker',
|
|
151
|
+
props: {
|
|
152
|
+
label: 'Use web worker (linting, etc.)',
|
|
153
|
+
type: 'checkbox',
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
name: 'Input',
|
|
158
|
+
key: 'disabled',
|
|
159
|
+
props: {
|
|
160
|
+
label: 'Disabled (component)',
|
|
161
|
+
type: 'checkbox',
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
name: 'Input',
|
|
166
|
+
key: 'useAceClass',
|
|
167
|
+
props: {
|
|
168
|
+
label: 'Use Ace built-in styles',
|
|
169
|
+
type: 'checkbox',
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
|
|
173
|
+
// Extra config escape hatch
|
|
174
|
+
{
|
|
175
|
+
name: 'Input',
|
|
176
|
+
key: 'configJson',
|
|
177
|
+
props: {
|
|
178
|
+
label: 'Extra Ace config (JSON)',
|
|
179
|
+
placeholder: '{"printMarginColumn": 120, "scrollPastEnd": 0.5}',
|
|
180
|
+
type: 'textarea',
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
],
|
|
184
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<ng-template #templateRef let-data>
|
|
2
|
+
<wbutton
|
|
3
|
+
[type]="data.props.type ?? buttonDefaults.type"
|
|
4
|
+
[extraClass]="data.props.extraClass ?? buttonDefaults.extraClass"
|
|
5
|
+
[disabled]="data.props.disabled === true || data.component?.disabled === true"
|
|
6
|
+
[disableSubmit]="data.props.disableSubmit ?? buttonDefaults.disableSubmit"
|
|
7
|
+
[isMultipleClicksAllowed]="
|
|
8
|
+
data.props.isMultipleClicksAllowed ??
|
|
9
|
+
buttonDefaults.isMultipleClicksAllowed
|
|
10
|
+
"
|
|
11
|
+
(wClick)="data.props.onClick?.($event); data.wClick?.()"
|
|
12
|
+
>
|
|
13
|
+
{{ data.props.label || data.props.text || 'Button' }}
|
|
14
|
+
</wbutton>
|
|
15
|
+
</ng-template>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Component,
|
|
3
|
+
OnInit,
|
|
4
|
+
TemplateRef,
|
|
5
|
+
inject,
|
|
6
|
+
viewChild,
|
|
7
|
+
} from '@angular/core';
|
|
8
|
+
import { ButtonComponent, buttonDefaults } from '@wawjs/ngx-ui';
|
|
9
|
+
import { FormService } from '@wawjs/ngx-form';
|
|
10
|
+
|
|
11
|
+
interface ButtonTemplateContext {}
|
|
12
|
+
|
|
13
|
+
@Component({
|
|
14
|
+
imports: [ButtonComponent],
|
|
15
|
+
templateUrl: './button.component.html',
|
|
16
|
+
})
|
|
17
|
+
export class ButtonFormComponent implements OnInit {
|
|
18
|
+
private readonly _formService = inject(FormService);
|
|
19
|
+
|
|
20
|
+
readonly templateRef =
|
|
21
|
+
viewChild.required<TemplateRef<ButtonTemplateContext>>('templateRef');
|
|
22
|
+
|
|
23
|
+
readonly buttonDefaults = buttonDefaults;
|
|
24
|
+
|
|
25
|
+
ngOnInit(): void {
|
|
26
|
+
this._formService.addTemplateComponent<ButtonTemplateContext>(
|
|
27
|
+
'Button',
|
|
28
|
+
this.templateRef(),
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export const buttonForm = {
|
|
2
|
+
formId: 'button',
|
|
3
|
+
title: 'Button',
|
|
4
|
+
components: [
|
|
5
|
+
{
|
|
6
|
+
name: 'Input',
|
|
7
|
+
key: 'label',
|
|
8
|
+
focused: true,
|
|
9
|
+
props: {
|
|
10
|
+
label: 'Label',
|
|
11
|
+
placeholder: 'Enter button label...',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
name: 'Input',
|
|
16
|
+
key: 'text',
|
|
17
|
+
props: {
|
|
18
|
+
label: 'Text (fallback)',
|
|
19
|
+
placeholder: 'Optional alternative text...',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: 'Select',
|
|
24
|
+
key: 'type',
|
|
25
|
+
props: {
|
|
26
|
+
label: 'Button type',
|
|
27
|
+
placeholder: 'Select button type...',
|
|
28
|
+
items: [
|
|
29
|
+
'primary',
|
|
30
|
+
'secondary',
|
|
31
|
+
'success',
|
|
32
|
+
'danger',
|
|
33
|
+
'warning',
|
|
34
|
+
'info',
|
|
35
|
+
'light',
|
|
36
|
+
'dark',
|
|
37
|
+
'link',
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: 'Input',
|
|
43
|
+
key: 'extraClass',
|
|
44
|
+
props: {
|
|
45
|
+
label: 'Extra CSS classes',
|
|
46
|
+
placeholder: 'wbutton--wide, my-custom-class...',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: 'Input',
|
|
51
|
+
key: 'disabled',
|
|
52
|
+
props: {
|
|
53
|
+
label: 'Disabled',
|
|
54
|
+
type: 'checkbox',
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: 'Input',
|
|
59
|
+
key: 'disableSubmit',
|
|
60
|
+
props: {
|
|
61
|
+
label: 'Disable submit (use type="button")',
|
|
62
|
+
type: 'checkbox',
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: 'Input',
|
|
67
|
+
key: 'isMultipleClicksAllowed',
|
|
68
|
+
props: {
|
|
69
|
+
label: 'Allow multiple rapid clicks',
|
|
70
|
+
type: 'checkbox',
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
<ng-template #templateRef let-data>
|
|
2
|
+
@let mode = (data.props.mode ?? fileDefaults.mode); @switch (mode) { @case
|
|
3
|
+
('single-image') {
|
|
4
|
+
<ngx-file
|
|
5
|
+
[label]="data.props.label ?? fileDefaults.label"
|
|
6
|
+
[placeholder]="data.props.placeholder ?? fileDefaults.placeholder"
|
|
7
|
+
[disabled]="data.props.disabled === true || data.component?.disabled === true"
|
|
8
|
+
[clearable]="data.props.clearable ?? fileDefaults.clearable"
|
|
9
|
+
[accept]="data.props.accept ?? fileDefaults.accept"
|
|
10
|
+
[preview]="data.props.preview ?? fileDefaults.preview"
|
|
11
|
+
[mode]="mode"
|
|
12
|
+
[view]="data.props.view ?? fileDefaults.view"
|
|
13
|
+
[cropWidth]="data.props.cropWidth ?? fileDefaults.cropWidth"
|
|
14
|
+
[cropHeight]="data.props.cropHeight ?? fileDefaults.cropHeight"
|
|
15
|
+
[container]="data.props.container ?? fileDefaults.container"
|
|
16
|
+
[name]="data.props.name ?? fileDefaults.name"
|
|
17
|
+
[wImage]="getValue(data)"
|
|
18
|
+
(wImageChange)="onValueChange(data, $event)"
|
|
19
|
+
></ngx-file>
|
|
20
|
+
} @case ('single-file') {
|
|
21
|
+
<ngx-file
|
|
22
|
+
[label]="data.props.label ?? fileDefaults.label"
|
|
23
|
+
[placeholder]="data.props.placeholder ?? fileDefaults.placeholder"
|
|
24
|
+
[disabled]="data.props.disabled === true || data.component?.disabled === true"
|
|
25
|
+
[clearable]="data.props.clearable ?? fileDefaults.clearable"
|
|
26
|
+
[accept]="data.props.accept ?? fileDefaults.accept"
|
|
27
|
+
[preview]="data.props.preview ?? fileDefaults.preview"
|
|
28
|
+
[mode]="mode"
|
|
29
|
+
[view]="data.props.view ?? fileDefaults.view"
|
|
30
|
+
[cropWidth]="data.props.cropWidth ?? fileDefaults.cropWidth"
|
|
31
|
+
[cropHeight]="data.props.cropHeight ?? fileDefaults.cropHeight"
|
|
32
|
+
[container]="data.props.container ?? fileDefaults.container"
|
|
33
|
+
[name]="data.props.name ?? fileDefaults.name"
|
|
34
|
+
[wFile]="getValue(data)"
|
|
35
|
+
(wFileChange)="onValueChange(data, $event)"
|
|
36
|
+
></ngx-file>
|
|
37
|
+
} @case ('multi-image') {
|
|
38
|
+
<ngx-file
|
|
39
|
+
[label]="data.props.label ?? fileDefaults.label"
|
|
40
|
+
[placeholder]="data.props.placeholder ?? fileDefaults.placeholder"
|
|
41
|
+
[disabled]="data.props.disabled === true || data.component?.disabled === true"
|
|
42
|
+
[clearable]="data.props.clearable ?? fileDefaults.clearable"
|
|
43
|
+
[accept]="data.props.accept ?? fileDefaults.accept"
|
|
44
|
+
[preview]="data.props.preview ?? fileDefaults.preview"
|
|
45
|
+
[mode]="mode"
|
|
46
|
+
[view]="data.props.view ?? fileDefaults.view"
|
|
47
|
+
[cropWidth]="data.props.cropWidth ?? fileDefaults.cropWidth"
|
|
48
|
+
[cropHeight]="data.props.cropHeight ?? fileDefaults.cropHeight"
|
|
49
|
+
[container]="data.props.container ?? fileDefaults.container"
|
|
50
|
+
[name]="data.props.name ?? fileDefaults.name"
|
|
51
|
+
[wImages]="getValue(data)"
|
|
52
|
+
(wImagesChange)="onValueChange(data, $event)"
|
|
53
|
+
></ngx-file>
|
|
54
|
+
} @default {
|
|
55
|
+
<!-- multi-file (default) -->
|
|
56
|
+
<ngx-file
|
|
57
|
+
[label]="data.props.label ?? fileDefaults.label"
|
|
58
|
+
[placeholder]="data.props.placeholder ?? fileDefaults.placeholder"
|
|
59
|
+
[disabled]="data.props.disabled === true || data.component?.disabled === true"
|
|
60
|
+
[clearable]="data.props.clearable ?? fileDefaults.clearable"
|
|
61
|
+
[accept]="data.props.accept ?? fileDefaults.accept"
|
|
62
|
+
[preview]="data.props.preview ?? fileDefaults.preview"
|
|
63
|
+
[mode]="mode"
|
|
64
|
+
[view]="data.props.view ?? fileDefaults.view"
|
|
65
|
+
[cropWidth]="data.props.cropWidth ?? fileDefaults.cropWidth"
|
|
66
|
+
[cropHeight]="data.props.cropHeight ?? fileDefaults.cropHeight"
|
|
67
|
+
[container]="data.props.container ?? fileDefaults.container"
|
|
68
|
+
[name]="data.props.name ?? fileDefaults.name"
|
|
69
|
+
[wFiles]="getValue(data)"
|
|
70
|
+
(wFilesChange)="onValueChange(data, $event)"
|
|
71
|
+
></ngx-file>
|
|
72
|
+
} }
|
|
73
|
+
</ng-template>
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Component,
|
|
3
|
+
OnInit,
|
|
4
|
+
TemplateRef,
|
|
5
|
+
inject,
|
|
6
|
+
viewChild,
|
|
7
|
+
} from '@angular/core';
|
|
8
|
+
import { FileComponent, fileDefaults } from '../../feature/file';
|
|
9
|
+
import { FormService } from '@wawjs/ngx-form';
|
|
10
|
+
import { FormBridgeData } from '../form-bridge.interface';
|
|
11
|
+
|
|
12
|
+
interface FileTemplateContext {}
|
|
13
|
+
|
|
14
|
+
@Component({
|
|
15
|
+
imports: [FileComponent],
|
|
16
|
+
templateUrl: './file.component.html',
|
|
17
|
+
})
|
|
18
|
+
export class FileFormComponent implements OnInit {
|
|
19
|
+
private readonly _formService = inject(FormService);
|
|
20
|
+
|
|
21
|
+
readonly templateRef =
|
|
22
|
+
viewChild.required<TemplateRef<FileTemplateContext>>('templateRef');
|
|
23
|
+
|
|
24
|
+
readonly fileDefaults = fileDefaults;
|
|
25
|
+
|
|
26
|
+
ngOnInit(): void {
|
|
27
|
+
this._formService.addTemplateComponent<FileTemplateContext>(
|
|
28
|
+
'File',
|
|
29
|
+
this.templateRef(),
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/* ------------ value bridge (Signal Forms + model + legacy) ------------ */
|
|
34
|
+
|
|
35
|
+
getValue(data: FormBridgeData): any {
|
|
36
|
+
const key = (data?.key as string | null) ?? null;
|
|
37
|
+
|
|
38
|
+
// 1) Signal Forms field (preferred)
|
|
39
|
+
if (data?.field) {
|
|
40
|
+
try {
|
|
41
|
+
const state = data.field();
|
|
42
|
+
if (state?.value && typeof state.value === 'function') {
|
|
43
|
+
return state.value();
|
|
44
|
+
}
|
|
45
|
+
} catch {
|
|
46
|
+
// fall through
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// 2) Model signal
|
|
51
|
+
if (data?.model && typeof data.model === 'function' && key) {
|
|
52
|
+
const current = data.model() as Record<string, unknown>;
|
|
53
|
+
return current?.[key];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// 3) Legacy submission object
|
|
57
|
+
if (!key || !data?.submition) return null;
|
|
58
|
+
return data.submition[key] ?? null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
onValueChange(data: FormBridgeData, value: unknown): void {
|
|
62
|
+
const key = (data?.key as string | null) ?? null;
|
|
63
|
+
|
|
64
|
+
// 1) Signal Forms field
|
|
65
|
+
if (data?.field) {
|
|
66
|
+
try {
|
|
67
|
+
const state = data.field();
|
|
68
|
+
if (state?.value?.set) state.value.set(value);
|
|
69
|
+
} catch {
|
|
70
|
+
// ignore and fall through
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// 2) Model signal
|
|
74
|
+
else if (
|
|
75
|
+
data?.model &&
|
|
76
|
+
typeof data.model.update === 'function' &&
|
|
77
|
+
key
|
|
78
|
+
) {
|
|
79
|
+
data.model.update((current: Record<string, unknown>) => ({
|
|
80
|
+
...current,
|
|
81
|
+
[key]: value,
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
84
|
+
// 3) Legacy submission object
|
|
85
|
+
else if (data?.submition && key) {
|
|
86
|
+
data.submition[key] = value;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (typeof data?.wChange === 'function') data.wChange();
|
|
90
|
+
}
|
|
91
|
+
}
|