@fluid-topics/ft-text-input 1.2.71
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/README.md +19 -0
- package/build/TextInputMessages.d.ts +9 -0
- package/build/TextInputMessages.js +8 -0
- package/build/ft-text-input.light.js +808 -0
- package/build/ft-text-input.min.js +1023 -0
- package/build/ftds-text-input.d.ts +22 -0
- package/build/ftds-text-input.js +133 -0
- package/build/ftds-text-input.properties.d.ts +13 -0
- package/build/ftds-text-input.properties.js +10 -0
- package/build/ftds-text-input.styles.d.ts +2 -0
- package/build/ftds-text-input.styles.js +40 -0
- package/build/index.d.ts +3 -0
- package/build/index.js +6 -0
- package/package.json +29 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { FtdsTextInputProperties, FtdsTextInputType } from "./ftds-text-input.properties";
|
|
2
|
+
import { PropertyValues } from "lit/development";
|
|
3
|
+
import { ElementDefinitionsMap, FtdsBase } from "@fluid-topics/ft-wc-utils";
|
|
4
|
+
import { FtIcons } from "@fluid-topics/ft-icon";
|
|
5
|
+
declare const FtdsTextInput_base: typeof FtdsBase & import("@fluid-topics/ft-wc-utils").Constructor<import("@fluid-topics/ft-wc-utils").FtInputInterface<String>> & import("@fluid-topics/ft-wc-utils").Constructor<import("@fluid-topics/ft-i18n").FtLitElementWithI18nInterface>;
|
|
6
|
+
export declare class FtdsTextInput extends FtdsTextInput_base implements FtdsTextInputProperties {
|
|
7
|
+
static elementDefinitions: ElementDefinitionsMap;
|
|
8
|
+
static styles: import("lit").CSSResult[];
|
|
9
|
+
type: FtdsTextInputType;
|
|
10
|
+
private showClearPassword;
|
|
11
|
+
private input?;
|
|
12
|
+
constructor();
|
|
13
|
+
get inputType(): FtdsTextInputType;
|
|
14
|
+
onInput(): void;
|
|
15
|
+
connectedCallback(): void;
|
|
16
|
+
protected willUpdate(props: PropertyValues): void;
|
|
17
|
+
get showLabel(): string | false;
|
|
18
|
+
get passwordIconForCurrentState(): FtIcons.EYE_SLASH | FtIcons.EYE | undefined;
|
|
19
|
+
protected render(): import("lit-html").TemplateResult<1>;
|
|
20
|
+
private updateTypeBasedAdditionalRules;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { html } from "lit";
|
|
8
|
+
import { property, query, state } from "lit/decorators.js";
|
|
9
|
+
import { FtdsTextInputType } from "./ftds-text-input.properties";
|
|
10
|
+
import { styles, } from "./ftds-text-input.styles";
|
|
11
|
+
import { classMap } from "lit/directives/class-map.js";
|
|
12
|
+
import { ifDefined } from "lit/directives/if-defined.js";
|
|
13
|
+
import { FtdsBase, toFtInput, ValidationRules, } from "@fluid-topics/ft-wc-utils";
|
|
14
|
+
import { FtdsInputLabel } from "@fluid-topics/ft-input-label/build/ftds-input-label";
|
|
15
|
+
import { FtdsInputHelperText } from "@fluid-topics/ft-input-helper-text";
|
|
16
|
+
import { FtIcon, FtIcons } from "@fluid-topics/ft-icon";
|
|
17
|
+
import { withI18n } from "@fluid-topics/ft-i18n";
|
|
18
|
+
import { textInputContext, textInputDefaultMessages } from "./TextInputMessages";
|
|
19
|
+
import { FtTooltip } from "@fluid-topics/ft-tooltip";
|
|
20
|
+
import { FtdsBaseInput } from "@fluid-topics/ft-base-input";
|
|
21
|
+
class FtdsTextInput extends withI18n(toFtInput(FtdsBase, String)) {
|
|
22
|
+
constructor() {
|
|
23
|
+
var _a;
|
|
24
|
+
super();
|
|
25
|
+
this.type = FtdsTextInputType.text;
|
|
26
|
+
this.showClearPassword = false;
|
|
27
|
+
this.value = (_a = this.value) !== null && _a !== void 0 ? _a : "";
|
|
28
|
+
this.addI18nContext(textInputContext, textInputDefaultMessages);
|
|
29
|
+
}
|
|
30
|
+
get inputType() {
|
|
31
|
+
return (this.type === FtdsTextInputType.password && this.showClearPassword)
|
|
32
|
+
? FtdsTextInputType.text
|
|
33
|
+
: this.type;
|
|
34
|
+
}
|
|
35
|
+
onInput() {
|
|
36
|
+
var _a;
|
|
37
|
+
this.value = ((_a = this.input) === null || _a === void 0 ? void 0 : _a.value) || "";
|
|
38
|
+
super.onInput();
|
|
39
|
+
}
|
|
40
|
+
connectedCallback() {
|
|
41
|
+
this.updateTypeBasedAdditionalRules(this.type);
|
|
42
|
+
super.connectedCallback();
|
|
43
|
+
}
|
|
44
|
+
willUpdate(props) {
|
|
45
|
+
super.willUpdate(props);
|
|
46
|
+
if (props.has("type")) {
|
|
47
|
+
this.updateTypeBasedAdditionalRules(this.type);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
get showLabel() {
|
|
51
|
+
return !this.hideLabel && this.label;
|
|
52
|
+
}
|
|
53
|
+
get passwordIconForCurrentState() {
|
|
54
|
+
return (this.type === FtdsTextInputType.password && !this.disabled) ? (this.showClearPassword ? FtIcons.EYE_SLASH : FtIcons.EYE) : undefined;
|
|
55
|
+
}
|
|
56
|
+
render() {
|
|
57
|
+
const inputClasses = classMap({
|
|
58
|
+
"ftds-input": true,
|
|
59
|
+
...this.getDesignSystemBaseClasses()
|
|
60
|
+
});
|
|
61
|
+
return html `
|
|
62
|
+
<ftds-base-input
|
|
63
|
+
|
|
64
|
+
.status=${this.status}
|
|
65
|
+
.size=${this.size}
|
|
66
|
+
?disabled="${this.disabled}"
|
|
67
|
+
|
|
68
|
+
.errorMessages=${this.errorMessages}
|
|
69
|
+
.warningMessages=${this.warningMessages}
|
|
70
|
+
.helperText=${this.helperText}
|
|
71
|
+
|
|
72
|
+
.label=${ifDefined(this.label)}
|
|
73
|
+
?hideLabel=${this.hideLabel}
|
|
74
|
+
?raiseLabel=${(this.type == FtdsTextInputType.date || this.type == FtdsTextInputType.time || this.focused || this.value != "")}
|
|
75
|
+
|
|
76
|
+
.appendIcon=${this.passwordIconForCurrentState}
|
|
77
|
+
.appendIconLabel=${this.showClearPassword ? textInputContext.messages.hidePassword() : textInputContext.messages.showPassword()}
|
|
78
|
+
appendIconIsClickable
|
|
79
|
+
@append-icon-click=${() => this.showClearPassword = !this.showClearPassword}
|
|
80
|
+
|
|
81
|
+
>
|
|
82
|
+
|
|
83
|
+
<input class=${inputClasses}
|
|
84
|
+
name="${this.name}"
|
|
85
|
+
.value="${this.value}"
|
|
86
|
+
.type="${this.inputType}"
|
|
87
|
+
?disabled=${this.disabled}
|
|
88
|
+
@input=${this.onInput}
|
|
89
|
+
@focus=${this.onFocus}
|
|
90
|
+
@blur=${this.onBlur}
|
|
91
|
+
aria-label="${ifDefined(this.label)}"
|
|
92
|
+
/>
|
|
93
|
+
|
|
94
|
+
</ftds-base-input>
|
|
95
|
+
`;
|
|
96
|
+
}
|
|
97
|
+
updateTypeBasedAdditionalRules(type) {
|
|
98
|
+
this.additionalErrorRules = (() => {
|
|
99
|
+
switch (type) {
|
|
100
|
+
case FtdsTextInputType.email:
|
|
101
|
+
return [ValidationRules.email(textInputContext.messages.invalidEmail())];
|
|
102
|
+
case FtdsTextInputType.url:
|
|
103
|
+
return [ValidationRules.url(textInputContext.messages.invalidUrl())];
|
|
104
|
+
default:
|
|
105
|
+
return [];
|
|
106
|
+
}
|
|
107
|
+
})();
|
|
108
|
+
this.additionalWarningRules = (() => {
|
|
109
|
+
switch (type) {
|
|
110
|
+
default:
|
|
111
|
+
return [];
|
|
112
|
+
}
|
|
113
|
+
})();
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
FtdsTextInput.elementDefinitions = {
|
|
117
|
+
"ftds-input-helper-text": FtdsInputHelperText,
|
|
118
|
+
"ftds-input-label": FtdsInputLabel,
|
|
119
|
+
"ftds-base-input": FtdsBaseInput,
|
|
120
|
+
"ft-icon": FtIcon,
|
|
121
|
+
"ft-tooltip": FtTooltip,
|
|
122
|
+
};
|
|
123
|
+
FtdsTextInput.styles = [styles];
|
|
124
|
+
__decorate([
|
|
125
|
+
property()
|
|
126
|
+
], FtdsTextInput.prototype, "type", void 0);
|
|
127
|
+
__decorate([
|
|
128
|
+
state()
|
|
129
|
+
], FtdsTextInput.prototype, "showClearPassword", void 0);
|
|
130
|
+
__decorate([
|
|
131
|
+
query("input")
|
|
132
|
+
], FtdsTextInput.prototype, "input", void 0);
|
|
133
|
+
export { FtdsTextInput };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FtInputInterface } from "@fluid-topics/ft-wc-utils";
|
|
2
|
+
export declare enum FtdsTextInputType {
|
|
3
|
+
text = "text",
|
|
4
|
+
password = "password",
|
|
5
|
+
email = "email",
|
|
6
|
+
url = "url",
|
|
7
|
+
number = "number",
|
|
8
|
+
date = "date",
|
|
9
|
+
time = "time"
|
|
10
|
+
}
|
|
11
|
+
export interface FtdsTextInputProperties extends FtInputInterface<String> {
|
|
12
|
+
type: FtdsTextInputType;
|
|
13
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export var FtdsTextInputType;
|
|
2
|
+
(function (FtdsTextInputType) {
|
|
3
|
+
FtdsTextInputType["text"] = "text";
|
|
4
|
+
FtdsTextInputType["password"] = "password";
|
|
5
|
+
FtdsTextInputType["email"] = "email";
|
|
6
|
+
FtdsTextInputType["url"] = "url";
|
|
7
|
+
FtdsTextInputType["number"] = "number";
|
|
8
|
+
FtdsTextInputType["date"] = "date";
|
|
9
|
+
FtdsTextInputType["time"] = "time";
|
|
10
|
+
})(FtdsTextInputType || (FtdsTextInputType = {}));
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { css, } from "lit";
|
|
2
|
+
import { typographyBody2Medium } from "@fluid-topics/design-system-variables";
|
|
3
|
+
export { textInput as FtdsTextInputCssVariables } from "@fluid-topics/design-system-variables";
|
|
4
|
+
//language=css
|
|
5
|
+
export const styles = css `
|
|
6
|
+
|
|
7
|
+
/* TODO override toutes les variables de base-input */
|
|
8
|
+
|
|
9
|
+
input {
|
|
10
|
+
background-color: transparent; /* so it doesn't grey out when disabled */
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
input[type="number"]::-webkit-outer-spin-button,
|
|
14
|
+
input[type="number"]::-webkit-inner-spin-button {
|
|
15
|
+
-webkit-appearance: none;
|
|
16
|
+
margin: 0;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
input[type="number"] {
|
|
20
|
+
-moz-appearance: textfield;
|
|
21
|
+
appearance: textfield;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
input[type="date"]::-webkit-inner-spin-button,
|
|
25
|
+
input[type="time"]::-webkit-inner-spin-button,
|
|
26
|
+
input[type="date"]::-webkit-calendar-picker-indicator,
|
|
27
|
+
input[type="time"]::-webkit-calendar-picker-indicator{
|
|
28
|
+
display: none;
|
|
29
|
+
-webkit-appearance: none;
|
|
30
|
+
}
|
|
31
|
+
/* We didn't found a way to remove the calendar icon from Firefox yet, sad.png */
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
input[type="date"], input[type="time"] {
|
|
35
|
+
font-family: ${typographyBody2Medium.fontFamily};
|
|
36
|
+
font-size: ${typographyBody2Medium.fontSize};
|
|
37
|
+
font-weight: ${typographyBody2Medium.fontWeight};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
`;
|
package/build/index.d.ts
ADDED
package/build/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { customElement } from "@fluid-topics/ft-wc-utils";
|
|
2
|
+
import { FtdsTextInput } from "./ftds-text-input";
|
|
3
|
+
export * from "./ftds-text-input.styles";
|
|
4
|
+
export * from "./ftds-text-input.properties";
|
|
5
|
+
export * from "./ftds-text-input";
|
|
6
|
+
customElement("ftds-text-input")(FtdsTextInput);
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fluid-topics/ft-text-input",
|
|
3
|
+
"version": "1.2.71",
|
|
4
|
+
"description": "Text Input",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"Lit"
|
|
7
|
+
],
|
|
8
|
+
"author": "Fluid Topics <devtopics@antidot.net>",
|
|
9
|
+
"license": "ISC",
|
|
10
|
+
"main": "build/index.js",
|
|
11
|
+
"web": "build/ft-text-input.min.js",
|
|
12
|
+
"typings": "build/index",
|
|
13
|
+
"files": [
|
|
14
|
+
"build/**/*.js",
|
|
15
|
+
"build/**/*.ts"
|
|
16
|
+
],
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@fluid-topics/ft-wc-utils": "1.2.71",
|
|
23
|
+
"lit": "3.1.0"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@fluid-topics/ft-wc-test-utils": "1.2.71"
|
|
27
|
+
},
|
|
28
|
+
"gitHead": "b4c6a27961db848c53bcc5f9344ec146f1e4629c"
|
|
29
|
+
}
|