@sebgroup/green-core 2.9.0 → 2.10.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/components/input/input.component.d.ts +9 -0
- package/components/input/input.component.js +20 -5
- package/components/textarea/textarea.component.d.ts +21 -1
- package/components/textarea/textarea.component.js +29 -7
- package/gds-element.js +1 -1
- package/generated/react/form-control-footer/index.d.ts +1 -1
- package/generated/react/index.d.ts +3 -3
- package/generated/react/index.js +3 -3
- package/generated/react/input/index.d.ts +4 -1
- package/generated/react/textarea/index.d.ts +4 -1
- package/package.json +1 -1
- package/primitives/form-control-footer/form-control-footer.component.d.ts +2 -1
- package/primitives/form-control-footer/form-control-footer.component.js +6 -14
- package/utils/helpers/custom-element-scoping.js +1 -1
|
@@ -65,6 +65,14 @@ declare class Input extends GdsFormControlElement<string> {
|
|
|
65
65
|
* keyboard on supportive devices.
|
|
66
66
|
*/
|
|
67
67
|
inputmode?: 'none' | 'text' | 'decimal' | 'numeric' | 'tel' | 'search' | 'email' | 'url';
|
|
68
|
+
/**
|
|
69
|
+
* This callback allows for customization of the character counter. It should return a tuple
|
|
70
|
+
* with the first value being the number of remaining characters, and the second value being
|
|
71
|
+
* the variant of the badge. If the second value is `false`, no badge will be displayed.
|
|
72
|
+
*/
|
|
73
|
+
charCounterCallback: (self: GdsFormControlElement<string> & {
|
|
74
|
+
maxlength: number;
|
|
75
|
+
}) => readonly [number, false | "positive" | "negative"];
|
|
68
76
|
private elInputAsync;
|
|
69
77
|
private elInput;
|
|
70
78
|
/**
|
|
@@ -81,6 +89,7 @@ declare class Input extends GdsFormControlElement<string> {
|
|
|
81
89
|
constructor();
|
|
82
90
|
focus(options?: FocusOptions): void;
|
|
83
91
|
render(): any;
|
|
92
|
+
private _handleValueChange;
|
|
84
93
|
_getValidityAnchor(): HTMLInputElement;
|
|
85
94
|
}
|
|
86
95
|
declare const GdsInput_base: (new (...args: any[]) => import("../../utils/mixins/declarative-layout-mixins").SizeXProps) & (new (...args: any[]) => import("../../utils/mixins/declarative-layout-mixins").MarginProps) & (new (...args: any[]) => import("../../utils/mixins/declarative-layout-mixins").LayoutChildProps) & typeof Input;
|
|
@@ -2,9 +2,10 @@ import {
|
|
|
2
2
|
__decorateClass,
|
|
3
3
|
__privateAdd,
|
|
4
4
|
__privateGet,
|
|
5
|
-
__privateMethod
|
|
5
|
+
__privateMethod,
|
|
6
|
+
__privateSet
|
|
6
7
|
} from "../../chunks/chunk.QU3DSPNU.js";
|
|
7
|
-
var _Input_instances, shouldShowFooter_fn, _handleOnInput, _handleOnChange, _handleFieldClick, _handleClearBtnClick, renderFieldContents_fn, renderSlotLead_fn, renderSlotTrail_fn, renderNativeInput_fn, renderClearButton_fn, shouldShowRemainingChars_get;
|
|
8
|
+
var _charCounterComputed, _Input_instances, shouldShowFooter_fn, _handleOnInput, _handleOnChange, _handleFieldClick, _handleClearBtnClick, renderFieldContents_fn, renderSlotLead_fn, renderSlotTrail_fn, renderNativeInput_fn, renderClearButton_fn, shouldShowRemainingChars_get;
|
|
8
9
|
import { localized, msg } from "@lit/localize";
|
|
9
10
|
import { property, query, queryAsync } from "lit/decorators.js";
|
|
10
11
|
import { ifDefined } from "lit/directives/if-defined.js";
|
|
@@ -16,6 +17,7 @@ import { GdsFormControlHeader } from "../../primitives/form-control-header/form-
|
|
|
16
17
|
import { gdsCustomElement, html } from "../../scoping.js";
|
|
17
18
|
import formControlHostStyles from "../../shared-styles/form-control-host.style.js";
|
|
18
19
|
import { tokens } from "../../tokens.style.js";
|
|
20
|
+
import { watch } from "../../utils/decorators/watch.js";
|
|
19
21
|
import {
|
|
20
22
|
withLayoutChildProps,
|
|
21
23
|
withMarginProps,
|
|
@@ -25,6 +27,7 @@ import { GdsButton } from "../button/button.component.js";
|
|
|
25
27
|
import { GdsFlex } from "../flex/flex.component.js";
|
|
26
28
|
import { GdsFormControlElement } from "../form/form-control.js";
|
|
27
29
|
import { IconCrossSmall } from "../icon/icons/cross-small.component.js";
|
|
30
|
+
import { charCounterCallbackDefault } from "../textarea/textarea.component.js";
|
|
28
31
|
import InputStyles from "./input.styles.js";
|
|
29
32
|
let Input = class extends GdsFormControlElement {
|
|
30
33
|
constructor() {
|
|
@@ -41,6 +44,8 @@ let Input = class extends GdsFormControlElement {
|
|
|
41
44
|
this.autocorrect = false;
|
|
42
45
|
this.autofocus = false;
|
|
43
46
|
this.spellcheck = true;
|
|
47
|
+
this.charCounterCallback = charCounterCallbackDefault;
|
|
48
|
+
__privateAdd(this, _charCounterComputed, this.charCounterCallback(this));
|
|
44
49
|
__privateAdd(this, _handleOnInput, (e) => {
|
|
45
50
|
const element = e.target;
|
|
46
51
|
this.value = element.value;
|
|
@@ -116,16 +121,20 @@ let Input = class extends GdsFormControlElement {
|
|
|
116
121
|
() => html` <gds-form-control-footer
|
|
117
122
|
id="message"
|
|
118
123
|
class="size-${this.size}"
|
|
119
|
-
.charCounter=${__privateGet(this,
|
|
124
|
+
.charCounter=${__privateGet(this, _charCounterComputed)}
|
|
120
125
|
.errorMessage=${this.invalid ? this.errorMessage : void 0}
|
|
121
126
|
></gds-form-control-footer>`
|
|
122
127
|
)}
|
|
123
128
|
`;
|
|
124
129
|
}
|
|
130
|
+
_handleValueChange() {
|
|
131
|
+
__privateSet(this, _charCounterComputed, this.charCounterCallback(this));
|
|
132
|
+
}
|
|
125
133
|
_getValidityAnchor() {
|
|
126
134
|
return this.elInput;
|
|
127
135
|
}
|
|
128
136
|
};
|
|
137
|
+
_charCounterComputed = new WeakMap();
|
|
129
138
|
_Input_instances = new WeakSet();
|
|
130
139
|
shouldShowFooter_fn = function() {
|
|
131
140
|
return !this.plain;
|
|
@@ -183,7 +192,7 @@ renderClearButton_fn = function() {
|
|
|
183
192
|
return html`<gds-button
|
|
184
193
|
size="${this.size === "small" ? "xs" : "small"}"
|
|
185
194
|
rank="tertiary"
|
|
186
|
-
variant="${this.invalid ? "negative" :
|
|
195
|
+
variant="${ifDefined(this.invalid ? "negative" : void 0)}"
|
|
187
196
|
?disabled="${this.disabled}"
|
|
188
197
|
label="${msg("Clear input")}"
|
|
189
198
|
@click=${__privateGet(this, _handleClearBtnClick)}
|
|
@@ -195,7 +204,7 @@ renderClearButton_fn = function() {
|
|
|
195
204
|
else return nothing;
|
|
196
205
|
};
|
|
197
206
|
shouldShowRemainingChars_get = function() {
|
|
198
|
-
return this
|
|
207
|
+
return __privateGet(this, _charCounterComputed)[1] !== false;
|
|
199
208
|
};
|
|
200
209
|
Input.styles = [tokens, formControlHostStyles, InputStyles];
|
|
201
210
|
__decorateClass([
|
|
@@ -260,12 +269,18 @@ __decorateClass([
|
|
|
260
269
|
__decorateClass([
|
|
261
270
|
property()
|
|
262
271
|
], Input.prototype, "inputmode", 2);
|
|
272
|
+
__decorateClass([
|
|
273
|
+
property({ attribute: false })
|
|
274
|
+
], Input.prototype, "charCounterCallback", 2);
|
|
263
275
|
__decorateClass([
|
|
264
276
|
queryAsync("input")
|
|
265
277
|
], Input.prototype, "elInputAsync", 2);
|
|
266
278
|
__decorateClass([
|
|
267
279
|
query("input")
|
|
268
280
|
], Input.prototype, "elInput", 2);
|
|
281
|
+
__decorateClass([
|
|
282
|
+
watch("value")
|
|
283
|
+
], Input.prototype, "_handleValueChange", 1);
|
|
269
284
|
Input = __decorateClass([
|
|
270
285
|
localized()
|
|
271
286
|
], Input);
|
|
@@ -46,7 +46,7 @@ declare class Textarea extends GdsFormControlElement<string> {
|
|
|
46
46
|
/** Controls whether and how text input is automatically capitalized as it is entered by the user. */
|
|
47
47
|
autocapitalize: 'off' | 'none' | 'on' | 'sentences' | 'words' | 'characters';
|
|
48
48
|
/** Indicates whether the browser's autocorrect feature is on or off. */
|
|
49
|
-
autocorrect
|
|
49
|
+
autocorrect: boolean;
|
|
50
50
|
/**
|
|
51
51
|
* Specifies what permission the browser has to provide assistance in filling out form field values. Refer to
|
|
52
52
|
* [this page on MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete) for available values.
|
|
@@ -56,6 +56,10 @@ declare class Textarea extends GdsFormControlElement<string> {
|
|
|
56
56
|
autofocus: boolean;
|
|
57
57
|
/** Enables spell checking on the input. */
|
|
58
58
|
spellcheck: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Indicates how the control should wrap the value for form submission. Refer to
|
|
61
|
+
* [this page on MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/textarea#wrap) for available values.
|
|
62
|
+
*/
|
|
59
63
|
wrap: 'hard' | 'soft';
|
|
60
64
|
/** Used to customize the label or icon of the Enter key on virtual keyboards. */
|
|
61
65
|
enterkeyhint?: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send';
|
|
@@ -64,6 +68,14 @@ declare class Textarea extends GdsFormControlElement<string> {
|
|
|
64
68
|
* keyboard on supportive devices.
|
|
65
69
|
*/
|
|
66
70
|
inputmode?: 'none' | 'text' | 'decimal' | 'numeric' | 'tel' | 'search' | 'email' | 'url';
|
|
71
|
+
/**
|
|
72
|
+
* This callback allows for customization of the character counter. It should return a tuple
|
|
73
|
+
* with the first value being the number of remaining characters, and the second value being
|
|
74
|
+
* the variant of the badge. If the second value is `false`, no badge will be shown.
|
|
75
|
+
*/
|
|
76
|
+
charCounterCallback: (self: GdsFormControlElement<string> & {
|
|
77
|
+
maxlength: number;
|
|
78
|
+
}) => readonly [number, false | "positive" | "negative"];
|
|
67
79
|
private elTextareaAsync;
|
|
68
80
|
private elTextarea;
|
|
69
81
|
private fieldBase;
|
|
@@ -85,6 +97,7 @@ declare class Textarea extends GdsFormControlElement<string> {
|
|
|
85
97
|
connectedCallback(): void;
|
|
86
98
|
disconnectedCallback(): void;
|
|
87
99
|
render(): any;
|
|
100
|
+
private _handleValueChange;
|
|
88
101
|
protected _getValidityAnchor(): HTMLTextAreaElement;
|
|
89
102
|
private _setAutoHeight;
|
|
90
103
|
private _handleRowsChange;
|
|
@@ -103,4 +116,11 @@ declare const GdsTextarea_base: (new (...args: any[]) => import("../../utils/mix
|
|
|
103
116
|
*/
|
|
104
117
|
export declare class GdsTextarea extends GdsTextarea_base {
|
|
105
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* Default character counter callback function.
|
|
121
|
+
* Returns the number of remaining characters and the badge variant based on the current value length and maxlength.
|
|
122
|
+
*/
|
|
123
|
+
export declare const charCounterCallbackDefault: (self: GdsFormControlElement<string> & {
|
|
124
|
+
maxlength: number;
|
|
125
|
+
}) => readonly [number, false | "positive" | "negative"];
|
|
106
126
|
export {};
|
|
@@ -2,9 +2,10 @@ import {
|
|
|
2
2
|
__decorateClass,
|
|
3
3
|
__privateAdd,
|
|
4
4
|
__privateGet,
|
|
5
|
-
__privateMethod
|
|
5
|
+
__privateMethod,
|
|
6
|
+
__privateSet
|
|
6
7
|
} from "../../chunks/chunk.QU3DSPNU.js";
|
|
7
|
-
var _Textarea_instances, shouldShowFooter_fn, _handleOnInput, _handleOnChange, _handleOnPaste, _handleFieldClick, _handleClearBtnClick, renderFieldContents_fn, renderSlotLead_fn, renderSlotTrail_fn, renderNativeTextarea_fn, renderClearButton_fn, shouldShowRemainingChars_get;
|
|
8
|
+
var _charCounterComputed, _Textarea_instances, shouldShowFooter_fn, _handleOnInput, _handleOnChange, _handleOnPaste, _handleFieldClick, _handleClearBtnClick, renderFieldContents_fn, renderSlotLead_fn, renderSlotTrail_fn, renderNativeTextarea_fn, renderClearButton_fn, shouldShowRemainingChars_get;
|
|
8
9
|
import { localized, msg } from "@lit/localize";
|
|
9
10
|
import { property, query, queryAsync } from "lit/decorators.js";
|
|
10
11
|
import { ifDefined } from "lit/directives/if-defined.js";
|
|
@@ -42,8 +43,11 @@ let Textarea = class extends GdsFormControlElement {
|
|
|
42
43
|
this.size = "large";
|
|
43
44
|
this.plain = false;
|
|
44
45
|
this.autocapitalize = "off";
|
|
46
|
+
this.autocorrect = false;
|
|
45
47
|
this.autofocus = false;
|
|
46
48
|
this.spellcheck = true;
|
|
49
|
+
this.charCounterCallback = charCounterCallbackDefault;
|
|
50
|
+
__privateAdd(this, _charCounterComputed, this.charCounterCallback(this));
|
|
47
51
|
this._handleSlotChange = () => {
|
|
48
52
|
requestAnimationFrame(() => {
|
|
49
53
|
this._handleResize();
|
|
@@ -179,12 +183,15 @@ let Textarea = class extends GdsFormControlElement {
|
|
|
179
183
|
() => html`<gds-form-control-footer
|
|
180
184
|
id="footer"
|
|
181
185
|
class="size-${this.size}"
|
|
182
|
-
.charCounter=${__privateGet(this,
|
|
186
|
+
.charCounter=${__privateGet(this, _charCounterComputed)}
|
|
183
187
|
.errorMessage=${this.invalid ? this.errorMessage : void 0}
|
|
184
188
|
></gds-form-control-footer>`
|
|
185
189
|
)}
|
|
186
190
|
`;
|
|
187
191
|
}
|
|
192
|
+
_handleValueChange() {
|
|
193
|
+
__privateSet(this, _charCounterComputed, this.charCounterCallback(this));
|
|
194
|
+
}
|
|
188
195
|
_getValidityAnchor() {
|
|
189
196
|
return this.elTextarea;
|
|
190
197
|
}
|
|
@@ -227,6 +234,7 @@ let Textarea = class extends GdsFormControlElement {
|
|
|
227
234
|
});
|
|
228
235
|
}
|
|
229
236
|
};
|
|
237
|
+
_charCounterComputed = new WeakMap();
|
|
230
238
|
_Textarea_instances = new WeakSet();
|
|
231
239
|
shouldShowFooter_fn = function() {
|
|
232
240
|
return !this.plain;
|
|
@@ -282,7 +290,7 @@ renderClearButton_fn = function() {
|
|
|
282
290
|
<gds-button
|
|
283
291
|
size="small"
|
|
284
292
|
rank="tertiary"
|
|
285
|
-
variant="${this.invalid ? "negative" :
|
|
293
|
+
variant="${ifDefined(this.invalid ? "negative" : void 0)}"
|
|
286
294
|
?disabled="${this.disabled}"
|
|
287
295
|
label="${msg("Clear input")}"
|
|
288
296
|
@click=${__privateGet(this, _handleClearBtnClick)}
|
|
@@ -295,7 +303,7 @@ renderClearButton_fn = function() {
|
|
|
295
303
|
else return nothing;
|
|
296
304
|
};
|
|
297
305
|
shouldShowRemainingChars_get = function() {
|
|
298
|
-
return this
|
|
306
|
+
return __privateGet(this, _charCounterComputed)[1] !== false;
|
|
299
307
|
};
|
|
300
308
|
Textarea.styles = [tokens, formControlHostStyle, TextareaStyles];
|
|
301
309
|
__decorateClass([
|
|
@@ -337,7 +345,7 @@ __decorateClass([
|
|
|
337
345
|
property()
|
|
338
346
|
], Textarea.prototype, "autocapitalize", 2);
|
|
339
347
|
__decorateClass([
|
|
340
|
-
property()
|
|
348
|
+
property({ type: Boolean })
|
|
341
349
|
], Textarea.prototype, "autocorrect", 2);
|
|
342
350
|
__decorateClass([
|
|
343
351
|
property()
|
|
@@ -364,6 +372,9 @@ __decorateClass([
|
|
|
364
372
|
__decorateClass([
|
|
365
373
|
property()
|
|
366
374
|
], Textarea.prototype, "inputmode", 2);
|
|
375
|
+
__decorateClass([
|
|
376
|
+
property({ attribute: false })
|
|
377
|
+
], Textarea.prototype, "charCounterCallback", 2);
|
|
367
378
|
__decorateClass([
|
|
368
379
|
queryAsync("textarea")
|
|
369
380
|
], Textarea.prototype, "elTextareaAsync", 2);
|
|
@@ -376,6 +387,9 @@ __decorateClass([
|
|
|
376
387
|
__decorateClass([
|
|
377
388
|
resizeObserver()
|
|
378
389
|
], Textarea.prototype, "_handleResize", 1);
|
|
390
|
+
__decorateClass([
|
|
391
|
+
watch("value")
|
|
392
|
+
], Textarea.prototype, "_handleValueChange", 1);
|
|
379
393
|
__decorateClass([
|
|
380
394
|
watch("value")
|
|
381
395
|
], Textarea.prototype, "_setAutoHeight", 1);
|
|
@@ -400,6 +414,14 @@ GdsTextarea = __decorateClass([
|
|
|
400
414
|
]
|
|
401
415
|
})
|
|
402
416
|
], GdsTextarea);
|
|
417
|
+
const charCounterCallbackDefault = (self) => {
|
|
418
|
+
const badgeType = (self.value?.length || 0) >= self.maxlength ? "negative" : "positive";
|
|
419
|
+
return [
|
|
420
|
+
self.maxlength - (self.value?.length || 0),
|
|
421
|
+
self.maxlength < Number.MAX_SAFE_INTEGER && badgeType
|
|
422
|
+
];
|
|
423
|
+
};
|
|
403
424
|
export {
|
|
404
|
-
GdsTextarea
|
|
425
|
+
GdsTextarea,
|
|
426
|
+
charCounterCallbackDefault
|
|
405
427
|
};
|
package/gds-element.js
CHANGED
|
@@ -14,7 +14,7 @@ class GdsElement extends LitElement {
|
|
|
14
14
|
/**
|
|
15
15
|
* The semantic version of this element. Can be used for troubleshooting to verify the version being used.
|
|
16
16
|
*/
|
|
17
|
-
this.semanticVersion = "2.
|
|
17
|
+
this.semanticVersion = "2.10.0";
|
|
18
18
|
this._isUsingTransitionalStyles = false;
|
|
19
19
|
this._dynamicStylesController = new DynamicStylesController(this);
|
|
20
20
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getReactComponent } from "../../../utils/react";
|
|
2
2
|
import { GdsFormControlFooter as GdsFormControlFooterClass } from "../../../primitives/form-control-footer/form-control-footer.component";
|
|
3
3
|
export declare const GdsFormControlFooter: (props: React.ComponentProps<ReturnType<typeof getReactComponent<GdsFormControlFooterClass>>>) => import("react").ReactElement<Omit<{
|
|
4
|
-
charCounter?: number | undefined;
|
|
4
|
+
charCounter?: [number, import("../../..").GdsBadge["variant"] | boolean] | undefined;
|
|
5
5
|
errorMessage?: string | undefined;
|
|
6
6
|
connectedCallback?: (() => void) | undefined;
|
|
7
7
|
render?: (() => any) | undefined;
|
|
@@ -52,9 +52,6 @@ export * from './formatted-date/index.js';
|
|
|
52
52
|
export * from './formatted-number/index.js';
|
|
53
53
|
export * from './radio-group/index.js';
|
|
54
54
|
export * from './segment/index.js';
|
|
55
|
-
export * from './sensitive-account/index.js';
|
|
56
|
-
export * from './sensitive-date/index.js';
|
|
57
|
-
export * from './sensitive-number/index.js';
|
|
58
55
|
export * from './icons/icon-ai/index.js';
|
|
59
56
|
export * from './icons/icon-airplane-up/index.js';
|
|
60
57
|
export * from './icons/icon-archive/index.js';
|
|
@@ -380,3 +377,6 @@ export * from './icons/icon-youtube/index.js';
|
|
|
380
377
|
export * from './icons/icon-zap/index.js';
|
|
381
378
|
export * from './icons/icon-zoom-in/index.js';
|
|
382
379
|
export * from './icons/icon-zoom-out/index.js';
|
|
380
|
+
export * from './sensitive-account/index.js';
|
|
381
|
+
export * from './sensitive-date/index.js';
|
|
382
|
+
export * from './sensitive-number/index.js';
|
package/generated/react/index.js
CHANGED
|
@@ -52,9 +52,6 @@ export * from "./formatted-date/index.js";
|
|
|
52
52
|
export * from "./formatted-number/index.js";
|
|
53
53
|
export * from "./radio-group/index.js";
|
|
54
54
|
export * from "./segment/index.js";
|
|
55
|
-
export * from "./sensitive-account/index.js";
|
|
56
|
-
export * from "./sensitive-date/index.js";
|
|
57
|
-
export * from "./sensitive-number/index.js";
|
|
58
55
|
export * from "./icons/icon-ai/index.js";
|
|
59
56
|
export * from "./icons/icon-airplane-up/index.js";
|
|
60
57
|
export * from "./icons/icon-archive/index.js";
|
|
@@ -380,3 +377,6 @@ export * from "./icons/icon-youtube/index.js";
|
|
|
380
377
|
export * from "./icons/icon-zap/index.js";
|
|
381
378
|
export * from "./icons/icon-zoom-in/index.js";
|
|
382
379
|
export * from "./icons/icon-zoom-out/index.js";
|
|
380
|
+
export * from "./sensitive-account/index.js";
|
|
381
|
+
export * from "./sensitive-date/index.js";
|
|
382
|
+
export * from "./sensitive-number/index.js";
|
|
@@ -23,7 +23,7 @@ export declare const GdsInput: (props: React.ComponentProps<ReturnType<typeof ge
|
|
|
23
23
|
maxlength?: number | undefined;
|
|
24
24
|
size?: "small" | "large" | undefined;
|
|
25
25
|
plain?: boolean | undefined;
|
|
26
|
-
type?: "number" | "search" | "time" | "text" | "date" | "email" | "
|
|
26
|
+
type?: "number" | "search" | "time" | "text" | "date" | "email" | "tel" | "url" | "datetime-local" | "password" | undefined;
|
|
27
27
|
min?: (number | string) | undefined;
|
|
28
28
|
max?: (number | string) | undefined;
|
|
29
29
|
step?: (number | "any") | undefined;
|
|
@@ -34,6 +34,9 @@ export declare const GdsInput: (props: React.ComponentProps<ReturnType<typeof ge
|
|
|
34
34
|
enterkeyhint?: ("enter" | "done" | "go" | "next" | "previous" | "search" | "send") | undefined;
|
|
35
35
|
spellcheck?: boolean | undefined;
|
|
36
36
|
inputmode?: ("none" | "text" | "decimal" | "numeric" | "tel" | "search" | "email" | "url") | undefined;
|
|
37
|
+
charCounterCallback?: ((self: import("../../../components/form/form-control").GdsFormControlElement<string> & {
|
|
38
|
+
maxlength: number;
|
|
39
|
+
}) => readonly [number, false | "positive" | "negative"]) | undefined;
|
|
37
40
|
test_getClearButton?: (() => import("../../..").GdsButton | null | undefined) | undefined;
|
|
38
41
|
test_getFieldElement?: (() => Element | null | undefined) | undefined;
|
|
39
42
|
focus?: ((options?: FocusOptions) => void) | undefined;
|
|
@@ -26,13 +26,16 @@ export declare const GdsTextarea: (props: React.ComponentProps<ReturnType<typeof
|
|
|
26
26
|
size?: "small" | "large" | undefined;
|
|
27
27
|
plain?: boolean | undefined;
|
|
28
28
|
autocapitalize?: "none" | "off" | "on" | "sentences" | "words" | "characters" | undefined;
|
|
29
|
-
autocorrect?:
|
|
29
|
+
autocorrect?: boolean | undefined;
|
|
30
30
|
autocomplete?: string | undefined;
|
|
31
31
|
autofocus?: boolean | undefined;
|
|
32
32
|
spellcheck?: boolean | undefined;
|
|
33
33
|
wrap?: "hard" | "soft" | undefined;
|
|
34
34
|
enterkeyhint?: ("enter" | "done" | "go" | "next" | "previous" | "search" | "send") | undefined;
|
|
35
35
|
inputmode?: ("none" | "text" | "decimal" | "numeric" | "tel" | "search" | "email" | "url") | undefined;
|
|
36
|
+
charCounterCallback?: ((self: import("../../../components/form/form-control").GdsFormControlElement<string> & {
|
|
37
|
+
maxlength: number;
|
|
38
|
+
}) => readonly [number, false | "positive" | "negative"]) | undefined;
|
|
36
39
|
test_getClearButton?: (() => import("../../..").GdsButton | null | undefined) | undefined;
|
|
37
40
|
test_getFieldElement?: (() => Element | null | undefined) | undefined;
|
|
38
41
|
focus?: ((options?: FocusOptions) => void) | undefined;
|
package/package.json
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { GdsBadge } from '../../components/badge/badge.component';
|
|
1
2
|
import { GdsElement } from '../../gds-element';
|
|
2
3
|
/**
|
|
3
4
|
* @element gds-form-control-footer
|
|
@@ -5,7 +6,7 @@ import { GdsElement } from '../../gds-element';
|
|
|
5
6
|
export declare class GdsFormControlFooter extends GdsElement {
|
|
6
7
|
#private;
|
|
7
8
|
static styles: import("lit").CSSResult[];
|
|
8
|
-
charCounter?: number;
|
|
9
|
+
charCounter?: [number, GdsBadge['variant'] | boolean];
|
|
9
10
|
errorMessage?: string;
|
|
10
11
|
private _handleVisibilityChange;
|
|
11
12
|
connectedCallback(): void;
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
__privateMethod
|
|
5
5
|
} from "../../chunks/chunk.QU3DSPNU.js";
|
|
6
6
|
var _GdsFormControlFooter_instances, renderRemainingCharsBadge_fn;
|
|
7
|
+
import { nothing } from "lit";
|
|
7
8
|
import { property } from "lit/decorators.js";
|
|
8
9
|
import { when } from "lit/directives/when.js";
|
|
9
10
|
import { GdsBadge } from "../../components/badge/badge.component.js";
|
|
@@ -46,29 +47,20 @@ let GdsFormControlFooter = class extends GdsElement {
|
|
|
46
47
|
>
|
|
47
48
|
</div>
|
|
48
49
|
<div class="char-counter" aria-hidden="true">
|
|
49
|
-
${
|
|
50
|
-
Number.isInteger(this.charCounter),
|
|
51
|
-
() => __privateMethod(this, _GdsFormControlFooter_instances, renderRemainingCharsBadge_fn).call(this, this.charCounter)
|
|
52
|
-
)}
|
|
50
|
+
${__privateMethod(this, _GdsFormControlFooter_instances, renderRemainingCharsBadge_fn).call(this)}
|
|
53
51
|
</div>
|
|
54
52
|
</div>`;
|
|
55
53
|
}
|
|
56
54
|
};
|
|
57
55
|
_GdsFormControlFooter_instances = new WeakSet();
|
|
58
|
-
renderRemainingCharsBadge_fn = function(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
variant = "negative";
|
|
62
|
-
} else if (remaining < 20) {
|
|
63
|
-
variant = "warning";
|
|
64
|
-
} else {
|
|
65
|
-
variant = "positive";
|
|
66
|
-
}
|
|
56
|
+
renderRemainingCharsBadge_fn = function() {
|
|
57
|
+
if (!this.charCounter || this.charCounter[1] === false) return nothing;
|
|
58
|
+
const [remaining, variant] = this.charCounter;
|
|
67
59
|
return html`<gds-badge variant="${variant}">${remaining}</gds-badge>`;
|
|
68
60
|
};
|
|
69
61
|
GdsFormControlFooter.styles = [FormControlFooterStyles];
|
|
70
62
|
__decorateClass([
|
|
71
|
-
property({ type:
|
|
63
|
+
property({ type: Array })
|
|
72
64
|
], GdsFormControlFooter.prototype, "charCounter", 2);
|
|
73
65
|
__decorateClass([
|
|
74
66
|
property()
|