@yamato-daiwa/frontend-vue 0.1.0 → 0.2.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/.idea/inspectionProfiles/Project_Default.xml +0 -5
- package/README.md +8 -2
- package/Source/GUI_Components/AdmonitionBlock/AdmonitionBlock.vue.ts +8 -8
- package/Source/GUI_Components/Badge/Badge.vue.ts +10 -10
- package/Source/GUI_Components/Badge/LoadingPlaceholder/Badge-LoadingPlaceholder.vue.ts +4 -4
- package/Source/GUI_Components/Controls/Buttons/Plain/Button.vue.pug +5 -7
- package/Source/GUI_Components/Controls/Buttons/Plain/Button.vue.ts +59 -30
- package/Source/GUI_Components/Controls/Buttons/Plain/LoadingPlaceholder/Button-LoadingPlaceholder.vue.pug +1 -1
- package/Source/GUI_Components/Controls/Buttons/Plain/LoadingPlaceholder/Button-LoadingPlaceholder.vue.ts +9 -8
- package/Source/GUI_Components/Controls/ValidatableControlShell/ValidatableControlShell.vue.pug +51 -0
- package/Source/GUI_Components/Controls/ValidatableControlShell/ValidatableControlShell.vue.ts +296 -0
- package/Source/GUI_Components/Controls/Validatables/InputtableControl.ts +134 -0
- package/Source/GUI_Components/Controls/Validatables/TextBox/TextBox.vue.pug +29 -0
- package/Source/GUI_Components/Controls/Validatables/TextBox/TextBox.vue.ts +260 -0
- package/Source/GUI_Components/Controls/{ValidatableControl.ts → Validatables/ValidatableControl.ts} +1 -1
- package/Source/GUI_Components/{ComponentsAuxiliaries.ts → YDF_ComponentsCoordinator.ts} +35 -1
- package/Source/GUI_Components/_Decorators/OptionalButNotNullableVueProperty.ts +65 -0
- package/Source/GUI_Components/_Errors/ForbiddenNullValueOfOptionalVueProperty/ForbiddenNullValueOfOptionalVuePropertyError.ts +47 -0
- package/Source/GUI_Components/_Errors/ForbiddenNullValueOfOptionalVueProperty/ForbiddenNullValueOfOptionalVuePropertyErrorLocalization.english.ts +24 -0
- package/Source/GUI_Components/_Utils/validateVuePropertyAndLogIfInvalid.ts +34 -0
- package/Source/index.ts +12 -5
- package/Workbenches/Source/GUI_Components/AdmonitionBlock/AdmonitionBlockComponentTestSite.vue +15 -0
- package/Workbenches/Source/GUI_Components/Badge/BadgeBlockComponentTestSite.vue +15 -0
- package/Workbenches/Source/GUI_Components/Controls/Buttons/Plain/Button.workbench.pug +20 -0
- package/Workbenches/Source/GUI_Components/Controls/Buttons/Plain/Button.workbench.ts +5 -0
- package/Workbenches/Source/GUI_Components/Controls/Buttons/Plain/ButtonComponentTestSite.vue +49 -0
- package/Workbenches/Source/GUI_Components/Controls/Validatable/TextBox/TextBox.workbench.pug +20 -0
- package/Workbenches/Source/GUI_Components/Controls/Validatable/TextBox/TextBox.workbench.ts +5 -0
- package/Workbenches/Source/GUI_Components/Controls/Validatable/TextBox/TextBoxWorkbench.vue +43 -0
- package/Workbenches/Source/GUI_Components/Controls/ValidatableControlShell/ValidatableControlShell.workbench.pug +20 -0
- package/Workbenches/Source/GUI_Components/Controls/ValidatableControlShell/ValidatableControlShell.workbench.ts +5 -0
- package/Workbenches/Source/GUI_Components/Controls/ValidatableControlShell/ValidatableControlShellTestSite.vue +61 -0
- package/Workbenches/Source/Workbenches.pug +56 -0
- package/package.json +8 -8
- package/yda.config.yaml +65 -65
- package/Source/GUI_Components/Controls/InputtableControl.ts +0 -97
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { Vue3SlideUpDown as VerticallySlidingAlwaysMountedContainer } from "vue3-slide-up-down";
|
|
2
|
+
|
|
3
|
+
/* ─── Assets ─────────────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
4
|
+
import componentVueTemplate from "./ValidatableControlShell.vue.pug";
|
|
5
|
+
import {
|
|
6
|
+
type ValidatableControlShellLocalization,
|
|
7
|
+
validatableControlShellYDF_ComponentLocalization__english
|
|
8
|
+
} from "@yamato-daiwa/frontend";
|
|
9
|
+
|
|
10
|
+
/* ─── Framework ──────────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
11
|
+
import {
|
|
12
|
+
ComponentBase as VueComponentConfiguration,
|
|
13
|
+
Vue as VueComponent,
|
|
14
|
+
Prop as VueProperty,
|
|
15
|
+
Watch as onVueComponentFieldUpdated
|
|
16
|
+
} from "vue-facing-decorator";
|
|
17
|
+
|
|
18
|
+
/* ─── Utils ──────────────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
19
|
+
import YDF_ComponentsCoordinator from "../../YDF_ComponentsCoordinator";
|
|
20
|
+
import OptionalButNotNullableVueProperty from "../../_Decorators/OptionalButNotNullableVueProperty";
|
|
21
|
+
import validateVuePropertyAndLogIfInvalid from "../../_Utils/validateVuePropertyAndLogIfInvalid";
|
|
22
|
+
import {
|
|
23
|
+
isNonEmptyString,
|
|
24
|
+
isElementOfEnumeration,
|
|
25
|
+
secondsToMilliseconds,
|
|
26
|
+
isNeitherUndefinedNorNull
|
|
27
|
+
} from "@yamato-daiwa/es-extensions";
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@VueComponentConfiguration({
|
|
31
|
+
name: ValidatableControlShell.CSS_NAMESPACE,
|
|
32
|
+
template: componentVueTemplate,
|
|
33
|
+
components: {
|
|
34
|
+
VerticallySlidingAlwaysMountedContainer
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
class ValidatableControlShell extends VueComponent {
|
|
38
|
+
|
|
39
|
+
public static CSS_NAMESPACE: string = "ValidatableControlShell--YDF";
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
/* ━━━ Component Common Properties ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
|
|
43
|
+
/* ─── Textings ─────────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
44
|
+
@VueProperty({
|
|
45
|
+
validator: validateVuePropertyAndLogIfInvalid({
|
|
46
|
+
checker: isNonEmptyString,
|
|
47
|
+
message: "If string specified it must be non-empty."
|
|
48
|
+
})
|
|
49
|
+
})
|
|
50
|
+
@OptionalButNotNullableVueProperty
|
|
51
|
+
protected readonly label?: string;
|
|
52
|
+
|
|
53
|
+
@VueProperty({
|
|
54
|
+
validator: validateVuePropertyAndLogIfInvalid({
|
|
55
|
+
checker: isNonEmptyString,
|
|
56
|
+
message: "If string specified it must be non-empty."
|
|
57
|
+
})
|
|
58
|
+
})
|
|
59
|
+
@OptionalButNotNullableVueProperty
|
|
60
|
+
protected readonly guidance?: string;
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
/* ─── Inputting Requirement ────────────────────────────────────────────────────────────────────────────────────── */
|
|
64
|
+
@VueProperty({ type: Boolean, default: false })
|
|
65
|
+
@OptionalButNotNullableVueProperty
|
|
66
|
+
protected readonly required!: boolean;
|
|
67
|
+
|
|
68
|
+
@VueProperty({ type: Boolean, default: false })
|
|
69
|
+
@OptionalButNotNullableVueProperty
|
|
70
|
+
protected readonly mustDisplayAppropriateBadgeIfInputIsRequired!: boolean;
|
|
71
|
+
|
|
72
|
+
@VueProperty({ type: Boolean, default: false })
|
|
73
|
+
@OptionalButNotNullableVueProperty
|
|
74
|
+
protected readonly mustDisplayAppropriateBadgeIfInputIsOptional!: boolean;
|
|
75
|
+
|
|
76
|
+
@VueProperty({ type: Boolean, default: false })
|
|
77
|
+
@OptionalButNotNullableVueProperty
|
|
78
|
+
protected readonly mustAddInvisibleBadgeForHeightEqualizingWhenNoBadge!: boolean;
|
|
79
|
+
|
|
80
|
+
/* ─── HTML IDs ─────────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
81
|
+
@VueProperty({
|
|
82
|
+
validator: validateVuePropertyAndLogIfInvalid({
|
|
83
|
+
checker: isNonEmptyString,
|
|
84
|
+
message: "If string specified it must be non-empty."
|
|
85
|
+
})
|
|
86
|
+
})
|
|
87
|
+
@OptionalButNotNullableVueProperty
|
|
88
|
+
protected readonly coreElementHTML_ID?: string;
|
|
89
|
+
|
|
90
|
+
@VueProperty({
|
|
91
|
+
validator: validateVuePropertyAndLogIfInvalid({
|
|
92
|
+
checker: isNonEmptyString,
|
|
93
|
+
message: "If string specified it must be non-empty."
|
|
94
|
+
})
|
|
95
|
+
})
|
|
96
|
+
@OptionalButNotNullableVueProperty
|
|
97
|
+
protected readonly labelElementHTML_ID?: string;
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
/* ─── Displaying of Validation Messages ────────────────────────────────────────────────────────────────────────── */
|
|
101
|
+
@VueProperty({ type: Boolean, default: false })
|
|
102
|
+
@OptionalButNotNullableVueProperty
|
|
103
|
+
protected readonly invalidInputHighlightingIfAnyValidationErrorsMessages!: boolean;
|
|
104
|
+
|
|
105
|
+
@VueProperty({ type: Boolean, default: false })
|
|
106
|
+
@OptionalButNotNullableVueProperty
|
|
107
|
+
protected readonly validValueHighlightingIfNoValidationErrorsMessages!: boolean;
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
/* ─── CSS Classes ──────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
111
|
+
@VueProperty({ type: [ Array ], default: (): ReadonlyArray<string> => [] })
|
|
112
|
+
@OptionalButNotNullableVueProperty
|
|
113
|
+
protected readonly mainSlotWrapperAdditionalCSS_Classes!: ReadonlyArray<string>;
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
/* ━━━ Validation Errors Messages ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
|
|
117
|
+
@VueProperty({ type: Array, default: (): ReadonlyArray<string> => [] })
|
|
118
|
+
@OptionalButNotNullableVueProperty
|
|
119
|
+
protected readonly validationErrorsMessages!: ReadonlyArray<string>;
|
|
120
|
+
|
|
121
|
+
/* [ Theory ]
|
|
122
|
+
* Even if `validationErrorsMessages` has become to empty array, the validation errors messages are still
|
|
123
|
+
* require to animate the expanding. */
|
|
124
|
+
protected validationErrorsMessagesCopyForAnimating: ReadonlyArray<string> = [ ...this.validationErrorsMessages ];
|
|
125
|
+
|
|
126
|
+
protected static readonly ERRORS_LIST_EXPANDING_ANIMATION_DURATION_PER_ONE_ERROR_MESSAGE__SECONDS: number = 0.2;
|
|
127
|
+
protected static readonly ERRORS_LIST_COLLAPSING_ANIMATION_DURATION__SECONDS: number = 0.2;
|
|
128
|
+
|
|
129
|
+
@onVueComponentFieldUpdated("validationErrorsMessages")
|
|
130
|
+
protected onValidationErrorsMessagesUpdated(newValidationErrorsMessages: ReadonlyArray<string>): void {
|
|
131
|
+
|
|
132
|
+
if (newValidationErrorsMessages.length > 0) {
|
|
133
|
+
this.validationErrorsMessagesCopyForAnimating = [ ...newValidationErrorsMessages ];
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
setTimeout(
|
|
139
|
+
(): void => {
|
|
140
|
+
this.validationErrorsMessagesCopyForAnimating = [];
|
|
141
|
+
},
|
|
142
|
+
secondsToMilliseconds(ValidatableControlShell.ERRORS_LIST_COLLAPSING_ANIMATION_DURATION__SECONDS)
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
/* ━━━ Theming ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
|
|
149
|
+
public static readonly Themes: ValidatableControlShell.Themes = { regular: "REGULAR" };
|
|
150
|
+
|
|
151
|
+
@VueProperty({
|
|
152
|
+
type: String,
|
|
153
|
+
default: ValidatableControlShell.Themes.regular,
|
|
154
|
+
validator: validateVuePropertyAndLogIfInvalid({
|
|
155
|
+
checker: (rawValue: string): boolean => isElementOfEnumeration(rawValue, ValidatableControlShell.Themes),
|
|
156
|
+
message:
|
|
157
|
+
"Must be the one among values of `ValidatableControlShell.Themes` associative array including the ones " +
|
|
158
|
+
"defined via `ValidatableControlShell.defineThemes()`."
|
|
159
|
+
})
|
|
160
|
+
})
|
|
161
|
+
@OptionalButNotNullableVueProperty
|
|
162
|
+
protected readonly theme!: string;
|
|
163
|
+
|
|
164
|
+
public static defineThemes(themesNames: ReadonlyArray<string>): typeof ValidatableControlShell {
|
|
165
|
+
return YDF_ComponentsCoordinator.defineThemes(themesNames, ValidatableControlShell);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
public static areThemesCSS_ClassesCommon: boolean = YDF_ComponentsCoordinator.areThemesCSS_ClassesCommon;
|
|
169
|
+
|
|
170
|
+
public static considerThemesAsCommon(): void {
|
|
171
|
+
ValidatableControlShell.areThemesCSS_ClassesCommon = true;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
@VueProperty({ type: Boolean, default: ValidatableControlShell.areThemesCSS_ClassesCommon })
|
|
175
|
+
@OptionalButNotNullableVueProperty
|
|
176
|
+
private readonly areThemesCSS_ClassesCommon!: boolean;
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
/* ─── Geometry ─────────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
180
|
+
public static readonly GeometricVariations: ValidatableControlShell.GeometricVariations = {
|
|
181
|
+
regular: "REGULAR",
|
|
182
|
+
small: "SMALL"
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
@VueProperty({
|
|
186
|
+
type: String,
|
|
187
|
+
default: ValidatableControlShell.GeometricVariations.regular,
|
|
188
|
+
validator: validateVuePropertyAndLogIfInvalid({
|
|
189
|
+
checker: (rawValue: string): boolean => isElementOfEnumeration(rawValue, ValidatableControlShell.GeometricVariations),
|
|
190
|
+
message:
|
|
191
|
+
"Must be the one among values of `ValidatableControlShell.GeometricVariations` associative array including the ones " +
|
|
192
|
+
"defined via `ValidatableControlShell.defineGeometricVariations()`."
|
|
193
|
+
})
|
|
194
|
+
})
|
|
195
|
+
@OptionalButNotNullableVueProperty
|
|
196
|
+
protected readonly geometricVariation!: string;
|
|
197
|
+
|
|
198
|
+
public static defineGeometricVariations(geometricVariationsNames: ReadonlyArray<string>): typeof ValidatableControlShell {
|
|
199
|
+
return YDF_ComponentsCoordinator.defineGeometricVariations(geometricVariationsNames, ValidatableControlShell);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
/* ─── Decoration ───────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
204
|
+
public static readonly DecorativeVariations: ValidatableControlShell.DecorativeVariations = {
|
|
205
|
+
regular: "REGULAR"
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
@VueProperty({
|
|
209
|
+
type: String,
|
|
210
|
+
default: ValidatableControlShell.DecorativeVariations.regular,
|
|
211
|
+
validator: validateVuePropertyAndLogIfInvalid({
|
|
212
|
+
checker: (rawValue: string): boolean => isElementOfEnumeration(rawValue, ValidatableControlShell.DecorativeVariations),
|
|
213
|
+
message:
|
|
214
|
+
"Must be the one among values of `ValidatableControlShell.DecorativeVariations` associative array including the ones " +
|
|
215
|
+
"defined via `ValidatableControlShell.defineDecorativeVariations()`."
|
|
216
|
+
})
|
|
217
|
+
})
|
|
218
|
+
protected readonly decorativeVariation!: string;
|
|
219
|
+
|
|
220
|
+
public static defineDecorativeVariations(decorativeVariationsNames: ReadonlyArray<string>): typeof ValidatableControlShell {
|
|
221
|
+
return YDF_ComponentsCoordinator.defineDecorativeVariations(decorativeVariationsNames, ValidatableControlShell);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
/* ━━━ CSS Classes ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
|
|
226
|
+
protected get rootElementModifierCSS_Classes(): ReadonlyArray<string> {
|
|
227
|
+
return YDF_ComponentsCoordinator.generateRootElementModifierCSS_Classes({
|
|
228
|
+
CSS_Namespace: ValidatableControlShell.CSS_NAMESPACE,
|
|
229
|
+
activeTheme: this.theme,
|
|
230
|
+
allThemes: ValidatableControlShell.Themes,
|
|
231
|
+
areThemesCSS_ClassesCommon: this.areThemesCSS_ClassesCommon,
|
|
232
|
+
activeGeometricVariation: this.geometricVariation,
|
|
233
|
+
allGeometricVariations: ValidatableControlShell.GeometricVariations,
|
|
234
|
+
activeDecorativeVariation: this.decorativeVariation,
|
|
235
|
+
allDecorativeVariations: ValidatableControlShell.DecorativeVariations
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
// ━━━ TODO ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
241
|
+
/* ━━━ Conditional Rendering ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
|
|
242
|
+
private get mustDisplayRequiredInputBadge(): boolean {
|
|
243
|
+
return this.required && this.mustDisplayAppropriateBadgeIfInputIsRequired;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
private get mustDisplayOptionalInputBadge(): boolean {
|
|
247
|
+
return this.required && this.mustDisplayAppropriateBadgeIfInputIsOptional;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
protected get mustDisplayHeader(): boolean {
|
|
251
|
+
return isNeitherUndefinedNorNull(this.label) ||
|
|
252
|
+
this.mustDisplayRequiredInputBadge ||
|
|
253
|
+
this.mustDisplayOptionalInputBadge ||
|
|
254
|
+
this.mustAddInvisibleBadgeForHeightEqualizingWhenNoBadge;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
/* ━━━ Lifecycle Hooks ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
|
|
259
|
+
public created(): void {
|
|
260
|
+
this.initializeNonReactiveClassFields();
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
/* ━━━ Non-reactive Fields ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
|
|
265
|
+
public static localization: ValidatableControlShellLocalization = validatableControlShellYDF_ComponentLocalization__english;
|
|
266
|
+
protected localization!: ValidatableControlShellLocalization;
|
|
267
|
+
|
|
268
|
+
private initializeNonReactiveClassFields(): void {
|
|
269
|
+
this.localization = ValidatableControlShell.localization;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
namespace ValidatableControlShell {
|
|
276
|
+
|
|
277
|
+
export type Themes = {
|
|
278
|
+
readonly regular: "REGULAR";
|
|
279
|
+
[themeName: string]: string;
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
export type GeometricVariations = {
|
|
283
|
+
readonly regular: "REGULAR";
|
|
284
|
+
readonly small: "SMALL";
|
|
285
|
+
[geometricVariationName: string]: string;
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
export type DecorativeVariations = {
|
|
289
|
+
readonly regular: "REGULAR";
|
|
290
|
+
[decorativeVariationName: string]: string;
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
export default ValidatableControlShell;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/* ─── Framework ──────────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
2
|
+
import {
|
|
3
|
+
ComponentBase as VueComponentConfiguration,
|
|
4
|
+
Vue as VueComponent,
|
|
5
|
+
Prop as VueProperty
|
|
6
|
+
} from "vue-facing-decorator";
|
|
7
|
+
|
|
8
|
+
/* ─── Utils ──────────────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
9
|
+
import {
|
|
10
|
+
Logger,
|
|
11
|
+
isNonEmptyString,
|
|
12
|
+
isEitherUndefinedOrNull
|
|
13
|
+
} from "@yamato-daiwa/es-extensions";
|
|
14
|
+
import InvalidVuePropertiesCombinationError from
|
|
15
|
+
"../../_Errors/InvalidVuePropertiesCombination/InvalidVuePropertiesCombinationError";
|
|
16
|
+
import OptionalButNotNullableVueProperty from "../../_Decorators/OptionalButNotNullableVueProperty";
|
|
17
|
+
import validateVuePropertyAndLogIfInvalid from "../../_Utils/validateVuePropertyAndLogIfInvalid";
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@VueComponentConfiguration({})
|
|
21
|
+
export default class InputtableControl extends VueComponent {
|
|
22
|
+
|
|
23
|
+
/* ━━━ Component Common Properties ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
|
|
24
|
+
/* ─── Textings ─────────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
25
|
+
@VueProperty({
|
|
26
|
+
validator: validateVuePropertyAndLogIfInvalid({
|
|
27
|
+
checker: isNonEmptyString,
|
|
28
|
+
message: "If string specified it must be non-empty"
|
|
29
|
+
})
|
|
30
|
+
})
|
|
31
|
+
@OptionalButNotNullableVueProperty
|
|
32
|
+
protected readonly label?: string;
|
|
33
|
+
|
|
34
|
+
@VueProperty({
|
|
35
|
+
validator: validateVuePropertyAndLogIfInvalid({
|
|
36
|
+
checker: isNonEmptyString,
|
|
37
|
+
message: "If string specified it must be non-empty"
|
|
38
|
+
})
|
|
39
|
+
})
|
|
40
|
+
@OptionalButNotNullableVueProperty
|
|
41
|
+
protected readonly accessibilityGuidance?: string;
|
|
42
|
+
|
|
43
|
+
@VueProperty({
|
|
44
|
+
validator: validateVuePropertyAndLogIfInvalid({
|
|
45
|
+
checker: isNonEmptyString,
|
|
46
|
+
message: "If string specified it must be non-empty"
|
|
47
|
+
})
|
|
48
|
+
})
|
|
49
|
+
@OptionalButNotNullableVueProperty
|
|
50
|
+
protected readonly externalLabelHTML_ID?: string;
|
|
51
|
+
|
|
52
|
+
@VueProperty({
|
|
53
|
+
validator: validateVuePropertyAndLogIfInvalid({
|
|
54
|
+
checker: isNonEmptyString,
|
|
55
|
+
message: "If string specified it must be non-empty"
|
|
56
|
+
})
|
|
57
|
+
})
|
|
58
|
+
@OptionalButNotNullableVueProperty
|
|
59
|
+
protected readonly guidance?: string;
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
/* ─── Requirement ──────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
63
|
+
@VueProperty({ type: Boolean, default: false })
|
|
64
|
+
@OptionalButNotNullableVueProperty
|
|
65
|
+
protected readonly required!: boolean;
|
|
66
|
+
|
|
67
|
+
@VueProperty({ type: Boolean, default: false })
|
|
68
|
+
@OptionalButNotNullableVueProperty
|
|
69
|
+
protected readonly mustDisplayAppropriateBadgeIfInputIsRequired!: boolean;
|
|
70
|
+
|
|
71
|
+
@VueProperty({ type: Boolean, default: false })
|
|
72
|
+
@OptionalButNotNullableVueProperty
|
|
73
|
+
protected readonly mustDisplayAppropriateBadgeIfInputIsOptional!: boolean;
|
|
74
|
+
|
|
75
|
+
@VueProperty({ type: Boolean, default: false })
|
|
76
|
+
@OptionalButNotNullableVueProperty
|
|
77
|
+
protected readonly mustAddInvisibleBadgeForHeightEqualizingWhenNoBadge!: boolean;
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
/* ─── State Limitations ─────────────────────────────────────────────────────────────────────────────────────────── */
|
|
81
|
+
@VueProperty({ type: Boolean, default: false })
|
|
82
|
+
@OptionalButNotNullableVueProperty
|
|
83
|
+
protected readonly disabled!: boolean;
|
|
84
|
+
|
|
85
|
+
@VueProperty({ type: Boolean, default: false })
|
|
86
|
+
@OptionalButNotNullableVueProperty
|
|
87
|
+
protected readonly readonly!: boolean;
|
|
88
|
+
// ━━━ TODO ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
89
|
+
/* === State ====================================================================================================== */
|
|
90
|
+
protected invalidInputHighlightingIfAnyValidationErrorsMessages: boolean = false;
|
|
91
|
+
protected validInputHighlightingIfAnyErrorsMessages: boolean = false;
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
/* === Methods ==================================================================================================== */
|
|
95
|
+
public highlightInvalidInput(): this {
|
|
96
|
+
this.invalidInputHighlightingIfAnyValidationErrorsMessages = true;
|
|
97
|
+
return this;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
public getRootElement(): Element {
|
|
101
|
+
return this.$el;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
public resetStateToInitial(): void {
|
|
105
|
+
Object.assign(this.$data, this.$options.data?.({}));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
/* === Livecycle hooks ========================================================================================== */
|
|
110
|
+
public beforeCreate(): void {
|
|
111
|
+
|
|
112
|
+
const inheritedComponentNameForLogging: string = this.$options.name ?? "(Unnamed component)";
|
|
113
|
+
|
|
114
|
+
if (
|
|
115
|
+
isEitherUndefinedOrNull(this.label) &&
|
|
116
|
+
isEitherUndefinedOrNull(this.accessibilityGuidance) &&
|
|
117
|
+
isEitherUndefinedOrNull(this.externalLabelHTML_ID)
|
|
118
|
+
) {
|
|
119
|
+
Logger.logError({
|
|
120
|
+
errorType: InvalidVuePropertiesCombinationError.NAME,
|
|
121
|
+
title: InvalidVuePropertiesCombinationError.localization.defaultTitle,
|
|
122
|
+
description: InvalidVuePropertiesCombinationError.localization.generateMessage({
|
|
123
|
+
vueComponentName: inheritedComponentNameForLogging,
|
|
124
|
+
messageSpecificPart: "From the accessibility requirements, one of next properties must be specified:\n" +
|
|
125
|
+
"● label\n● accessibilityGuidance\n● externalLabelHTML_ID"
|
|
126
|
+
|
|
127
|
+
}),
|
|
128
|
+
occurrenceLocation: `${ inheritedComponentNameForLogging }.beforeCreate()`
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
ValidatableControlShell.TextBox--YDF(
|
|
2
|
+
|
|
3
|
+
:label="label"
|
|
4
|
+
:guidance="guidance"
|
|
5
|
+
|
|
6
|
+
:required="required"
|
|
7
|
+
:mustDisplayAppropriateBadgeIfInputIsRequired="mustDisplayAppropriateBadgeIfInputIsRequired"
|
|
8
|
+
:mustDisplayAppropriateBadgeIfInputIsOptional="mustDisplayAppropriateBadgeIfInputIsOptional"
|
|
9
|
+
:mustAddInvisibleBadgeForHeightEqualizingWhenNoBadge="mustAddInvisibleBadgeForHeightEqualizingWhenNoBadge"
|
|
10
|
+
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
textarea.TextBox--YDF-InputOrTextAreaElement(
|
|
14
|
+
v-if="multiline"
|
|
15
|
+
:placeholder="placeholder"
|
|
16
|
+
:readonly="readonly"
|
|
17
|
+
:disabled="disabled"
|
|
18
|
+
:required="required"
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
//- [ Bundler bug ] The `v-else` is being compiled to `v-else="v-else"`
|
|
22
|
+
input.TextBox--YDF-InputOrTextAreaElement(
|
|
23
|
+
v-else-if="!multiline"
|
|
24
|
+
:type="HTML_Type"
|
|
25
|
+
:placeholder="placeholder"
|
|
26
|
+
:readonly="readonly"
|
|
27
|
+
:disabled="disabled"
|
|
28
|
+
:required="required"
|
|
29
|
+
)
|