vira 29.0.0 → 29.1.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/dist/elements/form/vira-form-fields.d.ts +11 -1
- package/dist/elements/form/vira-form-fields.js +1 -0
- package/dist/elements/form/vira-form.element.js +42 -0
- package/dist/elements/vira-button.element.js +4 -0
- package/dist/elements/vira-input.element.d.ts +2 -1
- package/dist/elements/vira-input.element.js +1 -0
- package/package.json +1 -1
|
@@ -15,6 +15,7 @@ export declare enum ViraFormFieldType {
|
|
|
15
15
|
/** Uses a password input without any attributes applied for auto complete hints. */
|
|
16
16
|
PlainPassword = "plain-password",
|
|
17
17
|
Email = "email",
|
|
18
|
+
Number = "number",
|
|
18
19
|
Select = "select",
|
|
19
20
|
Checkbox = "checkbox"
|
|
20
21
|
}
|
|
@@ -75,7 +76,16 @@ export type ViraFormField = ({
|
|
|
75
76
|
}> & CommonViraFormFields) | ({
|
|
76
77
|
type: ViraFormFieldType.Checkbox;
|
|
77
78
|
value: boolean | undefined;
|
|
78
|
-
} & CommonViraFormFields)
|
|
79
|
+
} & CommonViraFormFields) | ({
|
|
80
|
+
type: ViraFormFieldType.Number;
|
|
81
|
+
value: number | undefined;
|
|
82
|
+
} & PartialWithUndefined<{
|
|
83
|
+
placeholder: string;
|
|
84
|
+
icon: ViraIconSvg;
|
|
85
|
+
min: number;
|
|
86
|
+
max: number;
|
|
87
|
+
step: number;
|
|
88
|
+
}> & CommonViraFormFields);
|
|
79
89
|
/**
|
|
80
90
|
* A collection of form fields for `ViraForm`.
|
|
81
91
|
*
|
|
@@ -15,6 +15,7 @@ export var ViraFormFieldType;
|
|
|
15
15
|
/** Uses a password input without any attributes applied for auto complete hints. */
|
|
16
16
|
ViraFormFieldType["PlainPassword"] = "plain-password";
|
|
17
17
|
ViraFormFieldType["Email"] = "email";
|
|
18
|
+
ViraFormFieldType["Number"] = "number";
|
|
18
19
|
ViraFormFieldType["Select"] = "select";
|
|
19
20
|
ViraFormFieldType["Checkbox"] = "checkbox";
|
|
20
21
|
})(ViraFormFieldType || (ViraFormFieldType = {}));
|
|
@@ -92,6 +92,48 @@ export const ViraForm = defineViraElement()({
|
|
|
92
92
|
></${ViraSelect}>
|
|
93
93
|
`;
|
|
94
94
|
}
|
|
95
|
+
else if (field.type === ViraFormFieldType.Number) {
|
|
96
|
+
return html `
|
|
97
|
+
<${ViraInput.assign({
|
|
98
|
+
value: field.value?.toString() || '',
|
|
99
|
+
disabled: inputs.isDisabled || field.isDisabled,
|
|
100
|
+
allowedInputs: /\d/,
|
|
101
|
+
hasError: field.hasError,
|
|
102
|
+
icon: field.icon,
|
|
103
|
+
label: applyRequiredLabel(field.label, !!field.isRequired && !inputs.hideRequiredMarkers),
|
|
104
|
+
placeholder: field.placeholder,
|
|
105
|
+
showClearButton: inputs.showClearButtons,
|
|
106
|
+
type: ViraInputType.Number,
|
|
107
|
+
attributePassthrough: {
|
|
108
|
+
...(field.min === undefined
|
|
109
|
+
? {}
|
|
110
|
+
: {
|
|
111
|
+
min: String(field.min),
|
|
112
|
+
}),
|
|
113
|
+
...(field.max === undefined
|
|
114
|
+
? {}
|
|
115
|
+
: {
|
|
116
|
+
max: String(field.max),
|
|
117
|
+
}),
|
|
118
|
+
...(field.step === undefined
|
|
119
|
+
? {}
|
|
120
|
+
: {
|
|
121
|
+
step: String(field.step),
|
|
122
|
+
}),
|
|
123
|
+
},
|
|
124
|
+
})}
|
|
125
|
+
${field.testId ? testId(field.testId) : nothing}
|
|
126
|
+
${listen(ViraInput.events.valueChange, (event) => {
|
|
127
|
+
const numericValue = event.detail === '' ? undefined : Number(event.detail);
|
|
128
|
+
dispatch(new events.valueChange({
|
|
129
|
+
key,
|
|
130
|
+
...field,
|
|
131
|
+
value: numericValue,
|
|
132
|
+
}));
|
|
133
|
+
})}
|
|
134
|
+
></${ViraInput}>
|
|
135
|
+
`;
|
|
136
|
+
}
|
|
95
137
|
else {
|
|
96
138
|
return html `
|
|
97
139
|
<${ViraInput.assign({
|
|
@@ -59,6 +59,10 @@ export const ViraButton = defineViraElement()({
|
|
|
59
59
|
${viraFormCssVars['vira-form-focus-outline-color'].name}: ${viraFormCssVars['vira-form-accent-primary-hover-color'].value}
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
${hostClasses['vira-button-icon-only'].selector} {
|
|
63
|
+
${cssVars['vira-button-padding'].name}: 5px;
|
|
64
|
+
}
|
|
65
|
+
|
|
62
66
|
${hostClasses['vira-button-disabled'].selector} {
|
|
63
67
|
${viraDisabledStyles};
|
|
64
68
|
}
|
|
@@ -9,7 +9,8 @@ export * from './shared-text-input-logic.js';
|
|
|
9
9
|
export declare enum ViraInputType {
|
|
10
10
|
Default = "text",
|
|
11
11
|
Password = "password",
|
|
12
|
-
Email = "email"
|
|
12
|
+
Email = "email",
|
|
13
|
+
Number = "number"
|
|
13
14
|
}
|
|
14
15
|
/**
|
|
15
16
|
* A single line input element with all listeners properly attached. Multiple types are allowed with
|
|
@@ -22,6 +22,7 @@ export var ViraInputType;
|
|
|
22
22
|
ViraInputType["Default"] = "text";
|
|
23
23
|
ViraInputType["Password"] = "password";
|
|
24
24
|
ViraInputType["Email"] = "email";
|
|
25
|
+
ViraInputType["Number"] = "number";
|
|
25
26
|
})(ViraInputType || (ViraInputType = {}));
|
|
26
27
|
/**
|
|
27
28
|
* A single line input element with all listeners properly attached. Multiple types are allowed with
|