@viasat/beam-web-components 2.69.0 → 2.70.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/Alert/Alert.d.ts +1 -1
- package/Breadcrumbs/Breadcrumbs.js +1 -1
- package/Breadcrumbs/BreadcrumbsItem.js +2 -2
- package/Breadcrumbs/index.js +1 -1
- package/SegmentedControl/SegmentedControlItem.js +1 -1
- package/{wip/TextArea → TextArea}/TextArea.d.ts +37 -6
- package/{wip/TextArea → TextArea}/TextArea.js +185 -131
- package/TextField/TextField.d.ts +10 -4
- package/TextField/TextField.js +71 -65
- package/Tooltip/Tooltip.js +1 -1
- package/chunks/{BreadcrumbsItem.xWwSJgcO.js → BreadcrumbsItem.kovG2GHz.js} +1 -1
- package/chunks/{helpers.C43UgSdK.js → helpers.Ds5YZETV.js} +4 -4
- package/custom-elements.json +3963 -3205
- package/local/{wip/TextArea → TextArea}/TextArea.js +183 -128
- package/local/TextField/TextField.js +71 -65
- package/local/wip/Form/Form.decorator.js +119 -63
- package/local/wip/NativeSelect/NativeSelect.js +79 -82
- package/package.json +6 -6
- package/vscode.html-custom-data.json +361 -316
- package/wip/Form/Form.decorator.d.ts +19 -2
- package/wip/Form/Form.decorator.js +119 -63
- package/wip/NativeSelect/NativeSelect.d.ts +0 -4
- package/wip/NativeSelect/NativeSelect.js +75 -78
- /package/{wip/TextArea → TextArea}/index.d.ts +0 -0
- /package/{local/wip/TextArea → TextArea}/index.js +0 -0
- /package/{wip → local}/TextArea/index.js +0 -0
|
@@ -20,11 +20,26 @@ export declare class FormField extends LitElement {
|
|
|
20
20
|
value: string;
|
|
21
21
|
validationRules: Array<FormValidator>;
|
|
22
22
|
inputAriaLabel: Optional<string>;
|
|
23
|
+
/**
|
|
24
|
+
* Specify error text and display error state.
|
|
25
|
+
* Pass a string to show an error message, or `true` to show the error
|
|
26
|
+
* state without a message.
|
|
27
|
+
*/
|
|
28
|
+
error?: Optional<boolean | string>;
|
|
23
29
|
formContext: BmFormContext;
|
|
24
30
|
private _validationErrors;
|
|
25
31
|
protected validationErrors: () => Array<Optional<string>>;
|
|
32
|
+
protected resolveError: () => {
|
|
33
|
+
invalid: boolean;
|
|
34
|
+
errorMessage: Optional<string>;
|
|
35
|
+
};
|
|
26
36
|
protected setAssociatedValue(value: FormValue): void;
|
|
27
37
|
protected requestAssociatedSubmit(): void;
|
|
38
|
+
get validity(): ValidityState;
|
|
39
|
+
get validationMessage(): string;
|
|
40
|
+
get willValidate(): boolean;
|
|
41
|
+
checkValidity(): boolean;
|
|
42
|
+
reportValidity(): boolean;
|
|
28
43
|
protected setValidationErrors: (errors: Array<Optional<string>>) => void;
|
|
29
44
|
protected validationErrorShown: () => boolean;
|
|
30
45
|
connectedCallback(): void;
|
|
@@ -37,11 +52,13 @@ export declare class FormField extends LitElement {
|
|
|
37
52
|
protected forwardLabelFocus: () => void;
|
|
38
53
|
protected validateFieldOnBlur: (event: FocusEvent) => void;
|
|
39
54
|
protected validateFieldOnChange: (event: Event) => void;
|
|
55
|
+
protected syncValidity: () => void;
|
|
56
|
+
updated(cP: Map<string, unknown>): void;
|
|
40
57
|
protected getContextValue: () => string;
|
|
41
58
|
protected setContextValue: () => void;
|
|
42
59
|
protected setContextValidation: () => void;
|
|
43
60
|
protected contextInitialsChanged: () => boolean;
|
|
44
|
-
protected renderError: (error: Optional<string>, disabled: boolean) =>
|
|
45
|
-
protected renderValidationErrors: () =>
|
|
61
|
+
protected renderError: (error: Optional<string>, disabled: boolean) => import('lit').TemplateResult<1> | typeof nothing;
|
|
62
|
+
protected renderValidationErrors: () => import('lit').TemplateResult<1> | typeof nothing;
|
|
46
63
|
}
|
|
47
64
|
//# sourceMappingURL=Form.decorator.d.ts.map
|
|
@@ -1,65 +1,88 @@
|
|
|
1
|
-
var
|
|
2
|
-
throw TypeError(
|
|
1
|
+
var C = (e) => {
|
|
2
|
+
throw TypeError(e);
|
|
3
3
|
};
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
import { consume as
|
|
7
|
-
import { LitElement as
|
|
8
|
-
import { property as
|
|
9
|
-
import { createRef as
|
|
10
|
-
import { b as
|
|
11
|
-
import { bmFormInitials as
|
|
12
|
-
import { createId as
|
|
4
|
+
var E = (e, s, t) => s.has(e) || C("Cannot " + t);
|
|
5
|
+
var h = (e, s, t) => (E(e, s, "read from private field"), t ? t.call(e) : s.get(e)), y = (e, s, t) => s.has(e) ? C("Cannot add the same private member more than once") : s instanceof WeakSet ? s.add(e) : s.set(e, t), f = (e, s, t, i) => (E(e, s, "write to private field"), i ? i.call(e, t) : s.set(e, t), t);
|
|
6
|
+
import { consume as k } from "@lit/context";
|
|
7
|
+
import { LitElement as F, nothing as V, html as g } from "lit";
|
|
8
|
+
import { property as u, state as A } from "lit/decorators.js";
|
|
9
|
+
import { createRef as I } from "lit/directives/ref.js";
|
|
10
|
+
import { b as S } from "../../chunks/tokens.CTW8Tt94.js";
|
|
11
|
+
import { bmFormInitials as p, bmFormContext as R } from "./Form.context.js";
|
|
12
|
+
import { createId as b } from "./Form.utils.js";
|
|
13
13
|
import "../../chunks/HelperText.Cc_6DlKP.js";
|
|
14
|
-
var
|
|
15
|
-
for (var
|
|
16
|
-
(
|
|
17
|
-
return
|
|
18
|
-
},
|
|
19
|
-
const
|
|
14
|
+
var w = Object.defineProperty, l = (e, s, t, i) => {
|
|
15
|
+
for (var r = void 0, a = e.length - 1, n; a >= 0; a--)
|
|
16
|
+
(n = e[a]) && (r = n(s, t, r) || r);
|
|
17
|
+
return r && w(s, t, r), r;
|
|
18
|
+
}, d, c, m;
|
|
19
|
+
const x = class x extends F {
|
|
20
20
|
constructor() {
|
|
21
21
|
super(...arguments);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
y(this, d);
|
|
23
|
+
// Captured once, on first form association. Native reset restores this
|
|
24
|
+
// value; bm-form's initialValues seed is a separate concern, handled in
|
|
25
|
+
// formResetCallback below.
|
|
26
|
+
y(this, c);
|
|
27
|
+
y(this, m);
|
|
28
|
+
this.labelId = b(), this.errorId = b(), this.helperTextId = b(), this.validationErrorsId = b(), this.internals = this.attachInternals(), this.formFieldRef = I(), this.id = "", this.name = "", this.value = "", this.validationRules = [], this._validationErrors = [], this.validationErrors = () => this._validationErrors, this.resolveError = () => ({
|
|
29
|
+
invalid: !!this.error,
|
|
30
|
+
errorMessage: typeof this.error == "string" && this.error.length ? this.error : void 0
|
|
31
|
+
}), f(this, d, !1), this.setValidationErrors = (t) => {
|
|
32
|
+
this._validationErrors = t, this.syncValidity();
|
|
33
|
+
}, this.validationErrorShown = () => this.validationErrors().some((t) => !!(t != null && t.length)), f(this, m, /* @__PURE__ */ new WeakMap()), this.submitFormByEnter = ({ key: t }) => {
|
|
27
34
|
t === "Enter" && this.requestAssociatedSubmit();
|
|
28
35
|
}, this.forwardLabelFocus = () => {
|
|
29
36
|
const { value: t } = this.formFieldRef;
|
|
30
37
|
t.focus();
|
|
31
38
|
}, this.validateFieldOnBlur = (t) => {
|
|
32
|
-
const { formBlurHandler:
|
|
33
|
-
|
|
39
|
+
const { formBlurHandler: i } = this.formContext || p;
|
|
40
|
+
i(t);
|
|
34
41
|
}, this.validateFieldOnChange = (t) => {
|
|
35
|
-
const { value:
|
|
36
|
-
|
|
42
|
+
const { value: i } = t.target, { formChangeHandler: r } = this.formContext || p;
|
|
43
|
+
r(t), this.setAssociatedValue(i), this.syncValidity();
|
|
44
|
+
}, this.syncValidity = () => {
|
|
45
|
+
const { value: t } = this.formFieldRef;
|
|
46
|
+
if (!t) return;
|
|
47
|
+
const i = t, { validity: r, validationMessage: a } = i;
|
|
48
|
+
if (!r.valid) {
|
|
49
|
+
this.internals.setValidity(r, a, i);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const n = this.validationErrors().find(
|
|
53
|
+
(v) => !!v
|
|
54
|
+
);
|
|
55
|
+
if (n) {
|
|
56
|
+
this.internals.setValidity({ customError: !0 }, n, i);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
this.internals.setValidity({});
|
|
37
60
|
}, this.getContextValue = () => {
|
|
38
|
-
const { initialValues: t } = this.formContext ||
|
|
61
|
+
const { initialValues: t } = this.formContext || p;
|
|
39
62
|
return (t == null ? void 0 : t[this.name]) || this.value;
|
|
40
63
|
}, this.setContextValue = () => {
|
|
41
|
-
const { value: t } = this.formFieldRef, { ctxValue:
|
|
42
|
-
} } = this.finalizeAssociatedCallback(this.getContextValue()),
|
|
43
|
-
|
|
64
|
+
const { value: t } = this.formFieldRef, { ctxValue: i, finalizeCallback: r = () => {
|
|
65
|
+
} } = this.finalizeAssociatedCallback(this.getContextValue()), a = t;
|
|
66
|
+
a.value !== i && (a.value = i, r()), this.setAssociatedValue(i), this.syncValidity();
|
|
44
67
|
}, this.setContextValidation = () => {
|
|
45
|
-
const { value: t } = this.formFieldRef, { registerField:
|
|
46
|
-
|
|
68
|
+
const { value: t } = this.formFieldRef, { registerField: i } = this.formContext || p;
|
|
69
|
+
i({
|
|
47
70
|
field: t,
|
|
48
71
|
validators: this.validationRules,
|
|
49
72
|
initializer: this.setContextValue,
|
|
50
73
|
errorSetter: this.setValidationErrors
|
|
51
74
|
});
|
|
52
75
|
}, this.contextInitialsChanged = () => {
|
|
53
|
-
const { initialValues: t } = this.formContext ||
|
|
54
|
-
return
|
|
55
|
-
}, this.renderError = (t,
|
|
76
|
+
const { initialValues: t } = this.formContext || p, i = t == null ? void 0 : t[this.name], r = i !== this.contextInitialValue;
|
|
77
|
+
return r && (this.contextInitialValue = i), r;
|
|
78
|
+
}, this.renderError = (t, i) => t ? g`
|
|
56
79
|
<bm-helper-text
|
|
57
80
|
text="${t}"
|
|
58
81
|
id="${this.errorId}"
|
|
59
82
|
appearance="negative"
|
|
60
|
-
.disabled="${
|
|
83
|
+
.disabled="${i}"
|
|
61
84
|
></bm-helper-text>
|
|
62
|
-
` :
|
|
85
|
+
` : V, this.renderValidationErrors = () => this.validationErrorShown() ? g`
|
|
63
86
|
<div
|
|
64
87
|
role="log"
|
|
65
88
|
aria-live="polite"
|
|
@@ -68,78 +91,111 @@ const C = class C extends k {
|
|
|
68
91
|
id="${this.validationErrorsId}"
|
|
69
92
|
>
|
|
70
93
|
${this.validationErrors().map(
|
|
71
|
-
(t) => t ?
|
|
94
|
+
(t) => t ? g`
|
|
72
95
|
<bm-helper-text
|
|
73
96
|
text="${t}"
|
|
74
97
|
appearance="negative"
|
|
75
|
-
style="display: block; margin-top: ${
|
|
98
|
+
style="display: block; margin-top: ${S};"
|
|
76
99
|
></bm-helper-text>
|
|
77
|
-
` :
|
|
100
|
+
` : V
|
|
78
101
|
)}
|
|
79
102
|
</div>
|
|
80
|
-
` :
|
|
103
|
+
` : V;
|
|
81
104
|
}
|
|
82
105
|
setAssociatedValue(t) {
|
|
83
106
|
if (typeof t == "string") {
|
|
84
|
-
if (this.value === t &&
|
|
107
|
+
if (this.value === t && h(this, d)) return;
|
|
85
108
|
this.value = t;
|
|
86
109
|
}
|
|
87
|
-
let
|
|
110
|
+
let i = null;
|
|
88
111
|
if (typeof t == "boolean")
|
|
89
|
-
|
|
112
|
+
i = t ? "on" : null;
|
|
90
113
|
else if (typeof t == "number")
|
|
91
|
-
|
|
114
|
+
i = t.toString();
|
|
92
115
|
else if (Array.isArray(t)) {
|
|
93
|
-
const
|
|
94
|
-
t.forEach((
|
|
116
|
+
const r = new FormData();
|
|
117
|
+
t.forEach((a) => r.append(this.name, a.toString())), i = r;
|
|
95
118
|
} else
|
|
96
|
-
|
|
97
|
-
|
|
119
|
+
i = t;
|
|
120
|
+
f(this, d, !0), this.internals.form && this.internals.setFormValue(i);
|
|
98
121
|
}
|
|
99
122
|
requestAssociatedSubmit() {
|
|
100
123
|
this.internals.form && this.internals.form.requestSubmit();
|
|
101
124
|
}
|
|
125
|
+
// ElementInternals holds the real validity state, but nothing exposes it
|
|
126
|
+
// on the element unless we delegate it. Without this, field.checkValidity()
|
|
127
|
+
// and field.validity.valueMissing throw, even though :invalid CSS and
|
|
128
|
+
// native form submission already work.
|
|
129
|
+
get validity() {
|
|
130
|
+
return this.internals.validity;
|
|
131
|
+
}
|
|
132
|
+
get validationMessage() {
|
|
133
|
+
return this.internals.validationMessage;
|
|
134
|
+
}
|
|
135
|
+
get willValidate() {
|
|
136
|
+
return this.internals.willValidate;
|
|
137
|
+
}
|
|
138
|
+
checkValidity() {
|
|
139
|
+
return this.internals.checkValidity();
|
|
140
|
+
}
|
|
141
|
+
reportValidity() {
|
|
142
|
+
return this.internals.reportValidity();
|
|
143
|
+
}
|
|
102
144
|
connectedCallback() {
|
|
103
145
|
super.connectedCallback(), this.addEventListener("bm-label-click", this.forwardLabelFocus);
|
|
104
146
|
}
|
|
105
|
-
ctxValueChanged(t,
|
|
106
|
-
const { value:
|
|
107
|
-
return
|
|
147
|
+
ctxValueChanged(t, i) {
|
|
148
|
+
const { value: r } = i, a = h(this, m).get(r), { initialValues: { [this.name]: n } = {} } = t, v = n !== a;
|
|
149
|
+
return v && h(this, m).set(r, n), v;
|
|
108
150
|
}
|
|
109
151
|
disconnectedCallback() {
|
|
110
152
|
super.disconnectedCallback(), this.removeEventListener("bm-label-click", this.forwardLabelFocus);
|
|
111
153
|
}
|
|
112
154
|
formAssociatedCallback() {
|
|
113
|
-
|
|
155
|
+
f(this, d, !1), h(this, c) === void 0 && f(this, c, this.value), this.setAssociatedValue(this.value), this.syncValidity();
|
|
114
156
|
}
|
|
115
157
|
formResetCallback() {
|
|
116
|
-
this.setContextValue();
|
|
158
|
+
!this.formContext && h(this, c) !== void 0 && (this.value = h(this, c)), this.setContextValue();
|
|
117
159
|
}
|
|
118
160
|
finalizeAssociatedCallback(t) {
|
|
119
161
|
return { ctxValue: t, finalizeCallback: () => {
|
|
120
162
|
} };
|
|
121
163
|
}
|
|
164
|
+
// Any reactive prop can change what's valid (required, minLength,
|
|
165
|
+
// maxLength), not just a keystroke. Owning this here, not in each
|
|
166
|
+
// subclass's updated(), means every FormField subclass that opts in
|
|
167
|
+
// gets it as long as it calls super.updated(cP) — see TextField.ts/TextArea.ts.
|
|
168
|
+
updated(t) {
|
|
169
|
+
super.updated(t), this.syncValidity();
|
|
170
|
+
}
|
|
122
171
|
};
|
|
123
|
-
|
|
124
|
-
let o =
|
|
172
|
+
d = new WeakMap(), c = new WeakMap(), m = new WeakMap(), x.formAssociated = !0;
|
|
173
|
+
let o = x;
|
|
125
174
|
l([
|
|
126
|
-
|
|
175
|
+
u({ type: String })
|
|
127
176
|
], o.prototype, "id");
|
|
128
177
|
l([
|
|
129
|
-
|
|
178
|
+
u({ type: String, reflect: !0 })
|
|
130
179
|
], o.prototype, "name");
|
|
131
180
|
l([
|
|
132
|
-
|
|
181
|
+
u({ type: String })
|
|
133
182
|
], o.prototype, "value");
|
|
134
183
|
l([
|
|
135
|
-
|
|
184
|
+
u({ type: Array })
|
|
136
185
|
], o.prototype, "validationRules");
|
|
137
186
|
l([
|
|
138
|
-
|
|
187
|
+
u({ type: String, attribute: "input-aria-label" })
|
|
139
188
|
], o.prototype, "inputAriaLabel");
|
|
140
189
|
l([
|
|
141
|
-
|
|
142
|
-
|
|
190
|
+
u({
|
|
191
|
+
converter: {
|
|
192
|
+
fromAttribute: (e) => e === null ? void 0 : e === "" ? !0 : e
|
|
193
|
+
}
|
|
194
|
+
})
|
|
195
|
+
], o.prototype, "error");
|
|
196
|
+
l([
|
|
197
|
+
k({ context: R, subscribe: !0 }),
|
|
198
|
+
u({ attribute: !1 })
|
|
143
199
|
], o.prototype, "formContext");
|
|
144
200
|
l([
|
|
145
201
|
A()
|
|
@@ -28,10 +28,6 @@ export declare class BmNativeSelect extends FormField {
|
|
|
28
28
|
* @default false
|
|
29
29
|
*/
|
|
30
30
|
disabled: boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Specify error text and display error state of a NativeSelect
|
|
33
|
-
*/
|
|
34
|
-
error: Optional<string>;
|
|
35
31
|
/**
|
|
36
32
|
* Specify if NativeSelect is fluid
|
|
37
33
|
* @default false
|