@operato/input 9.0.14 → 9.0.17
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/CHANGELOG.md +9 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/ox-input-secret.d.ts +16 -0
- package/dist/src/ox-input-secret.js +173 -0
- package/dist/src/ox-input-secret.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -2
- package/translations/en.json +5 -1
- package/translations/ja.json +5 -1
- package/translations/ko.json +5 -1
- package/translations/ms.json +5 -1
- package/translations/zh.json +5 -1
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,15 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
+
### [9.0.17](https://github.com/hatiolab/operato/compare/v9.0.16...v9.0.17) (2025-08-02)
|
7
|
+
|
8
|
+
|
9
|
+
### :bug: Bug Fix
|
10
|
+
|
11
|
+
* add ox-input-secret, ox-property-editor-secret, ox-grist-secret ([8afbeae](https://github.com/hatiolab/operato/commit/8afbeae2c8eee9c3983d35ce5a709e25329eb6a7))
|
12
|
+
|
13
|
+
|
14
|
+
|
6
15
|
### [9.0.14](https://github.com/hatiolab/operato/compare/v9.0.13...v9.0.14) (2025-07-27)
|
7
16
|
|
8
17
|
|
package/dist/src/index.d.ts
CHANGED
package/dist/src/index.js
CHANGED
@@ -28,5 +28,6 @@ export * from './ox-input-textarea.js';
|
|
28
28
|
export * from './ox-input-direction.js';
|
29
29
|
export * from './ox-input-table-column-config.js';
|
30
30
|
export * from './ox-input-search.js';
|
31
|
+
export * from './ox-input-secret.js';
|
31
32
|
export * from './ox-input-signature.js';
|
32
33
|
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,oBAAoB,CAAA;AAClC,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,sBAAsB,CAAA;AACpC,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,uBAAuB,CAAA;AACrC,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,yBAAyB,CAAA;AACvC,cAAc,kCAAkC,CAAA;AAChD,cAAc,uBAAuB,CAAA;AACrC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,wBAAwB,CAAA;AACtC,cAAc,0BAA0B,CAAA;AACxC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,wBAAwB,CAAA;AACtC,cAAc,yBAAyB,CAAA;AACvC,cAAc,mCAAmC,CAAA;AACjD,cAAc,sBAAsB,CAAA;AACpC,cAAc,yBAAyB,CAAA","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nexport * from './ox-form-field.js'\nexport * from './ox-buttons-radio.js'\nexport * from './ox-checkbox.js'\nexport * from './ox-select.js'\nexport * from './ox-input-switch.js'\nexport * from './ox-input-angle.js'\nexport * from './ox-input-3dish.js'\nexport * from './ox-input-3axis.js'\nexport * from './ox-input-stack.js'\nexport * from './ox-input-barcode.js'\nexport * from './ox-input-code.js'\nexport * from './ox-input-color.js'\nexport * from './ox-input-multiple-colors.js'\nexport * from './ox-input-file.js'\nexport * from './ox-input-image.js'\nexport * from './ox-input-value-ranges.js'\nexport * from './ox-input-value-map.js'\nexport * from './ox-input-scene-component-id.js'\nexport * from './ox-input-crontab.js'\nexport * from './ox-input-partition-keys.js'\nexport * from './ox-input-duration.js'\nexport * from './ox-input-quantifier.js'\nexport * from './ox-input-select-buttons.js'\nexport * from './ox-input-textarea.js'\nexport * from './ox-input-direction.js'\nexport * from './ox-input-table-column-config.js'\nexport * from './ox-input-search.js'\nexport * from './ox-input-signature.js'\n"]}
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,oBAAoB,CAAA;AAClC,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,sBAAsB,CAAA;AACpC,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,uBAAuB,CAAA;AACrC,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,yBAAyB,CAAA;AACvC,cAAc,kCAAkC,CAAA;AAChD,cAAc,uBAAuB,CAAA;AACrC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,wBAAwB,CAAA;AACtC,cAAc,0BAA0B,CAAA;AACxC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,wBAAwB,CAAA;AACtC,cAAc,yBAAyB,CAAA;AACvC,cAAc,mCAAmC,CAAA;AACjD,cAAc,sBAAsB,CAAA;AACpC,cAAc,sBAAsB,CAAA;AACpC,cAAc,yBAAyB,CAAA","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nexport * from './ox-form-field.js'\nexport * from './ox-buttons-radio.js'\nexport * from './ox-checkbox.js'\nexport * from './ox-select.js'\nexport * from './ox-input-switch.js'\nexport * from './ox-input-angle.js'\nexport * from './ox-input-3dish.js'\nexport * from './ox-input-3axis.js'\nexport * from './ox-input-stack.js'\nexport * from './ox-input-barcode.js'\nexport * from './ox-input-code.js'\nexport * from './ox-input-color.js'\nexport * from './ox-input-multiple-colors.js'\nexport * from './ox-input-file.js'\nexport * from './ox-input-image.js'\nexport * from './ox-input-value-ranges.js'\nexport * from './ox-input-value-map.js'\nexport * from './ox-input-scene-component-id.js'\nexport * from './ox-input-crontab.js'\nexport * from './ox-input-partition-keys.js'\nexport * from './ox-input-duration.js'\nexport * from './ox-input-quantifier.js'\nexport * from './ox-input-select-buttons.js'\nexport * from './ox-input-textarea.js'\nexport * from './ox-input-direction.js'\nexport * from './ox-input-table-column-config.js'\nexport * from './ox-input-search.js'\nexport * from './ox-input-secret.js'\nexport * from './ox-input-signature.js'\n"]}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
/**
|
2
|
+
* @license Copyright © HatioLab Inc. All rights reserved.
|
3
|
+
*/
|
4
|
+
import '@material/web/icon/icon.js';
|
5
|
+
import { OxFormField } from './ox-form-field.js';
|
6
|
+
export declare class OxInputSecret extends OxFormField<string | undefined> {
|
7
|
+
static styles: import("lit").CSSResult[];
|
8
|
+
placeholder?: string;
|
9
|
+
selectAfterChange?: boolean;
|
10
|
+
value?: string | undefined;
|
11
|
+
input: HTMLInputElement;
|
12
|
+
private togglePasswordVisibility;
|
13
|
+
render(): import("lit-html").TemplateResult<1>;
|
14
|
+
firstUpdated(): void;
|
15
|
+
dispatchChangeEvent(value: string): void;
|
16
|
+
}
|
@@ -0,0 +1,173 @@
|
|
1
|
+
/**
|
2
|
+
* @license Copyright © HatioLab Inc. All rights reserved.
|
3
|
+
*/
|
4
|
+
import { __decorate } from "tslib";
|
5
|
+
import '@material/web/icon/icon.js';
|
6
|
+
import { css, html } from 'lit';
|
7
|
+
import { customElement, property, query } from 'lit/decorators.js';
|
8
|
+
import { i18next } from '@operato/i18n';
|
9
|
+
import { OxFormField } from './ox-form-field.js';
|
10
|
+
let OxInputSecret = class OxInputSecret extends OxFormField {
|
11
|
+
static { this.styles = [
|
12
|
+
css `
|
13
|
+
:host {
|
14
|
+
display: flex;
|
15
|
+
position: relative;
|
16
|
+
align-items: center;
|
17
|
+
|
18
|
+
color: var(--ox-input-secret-color, var(--md-sys-color-on-surface-variant));
|
19
|
+
background-color: var(--ox-input-secret-background-color, var(--md-sys-color-surface-variant));
|
20
|
+
|
21
|
+
--md-icon-size: 20px;
|
22
|
+
}
|
23
|
+
|
24
|
+
.secret-container {
|
25
|
+
display: flex;
|
26
|
+
align-items: center;
|
27
|
+
justify-content: space-between;
|
28
|
+
position: relative;
|
29
|
+
width: 100%;
|
30
|
+
}
|
31
|
+
|
32
|
+
input {
|
33
|
+
flex: 1;
|
34
|
+
color: inherit;
|
35
|
+
background-color: transparent;
|
36
|
+
border: 0;
|
37
|
+
padding: var(--input-secret-padding, var(--spacing-tiny));
|
38
|
+
overflow: hidden;
|
39
|
+
text-overflow: ellipsis;
|
40
|
+
font-family: inherit;
|
41
|
+
font-size: inherit;
|
42
|
+
letter-spacing: 0.5px;
|
43
|
+
}
|
44
|
+
|
45
|
+
input:focus {
|
46
|
+
outline: none;
|
47
|
+
}
|
48
|
+
|
49
|
+
input:focus {
|
50
|
+
outline: none;
|
51
|
+
border: none;
|
52
|
+
box-shadow: none;
|
53
|
+
}
|
54
|
+
|
55
|
+
.secret-toggle {
|
56
|
+
position: absolute;
|
57
|
+
right: 0px;
|
58
|
+
cursor: pointer;
|
59
|
+
font-size: 16px;
|
60
|
+
color: var(--md-sys-color-on-surface-variant);
|
61
|
+
user-select: none;
|
62
|
+
opacity: 0.7;
|
63
|
+
transition: opacity 0.2s;
|
64
|
+
}
|
65
|
+
|
66
|
+
.secret-toggle:hover {
|
67
|
+
opacity: 1;
|
68
|
+
color: var(--md-sys-color-primary);
|
69
|
+
}
|
70
|
+
|
71
|
+
.secret-container:hover .secret-toggle {
|
72
|
+
opacity: 1;
|
73
|
+
}
|
74
|
+
`
|
75
|
+
]; }
|
76
|
+
togglePasswordVisibility() {
|
77
|
+
if (!this.input)
|
78
|
+
return;
|
79
|
+
if (this.input.type === 'password') {
|
80
|
+
this.input.type = 'text';
|
81
|
+
const icon = this.renderRoot.querySelector('.secret-toggle');
|
82
|
+
if (icon) {
|
83
|
+
icon.textContent = 'visibility';
|
84
|
+
icon.title = i18next.t('text.input-secret-hide');
|
85
|
+
}
|
86
|
+
}
|
87
|
+
else {
|
88
|
+
this.input.type = 'password';
|
89
|
+
const icon = this.renderRoot.querySelector('.secret-toggle');
|
90
|
+
if (icon) {
|
91
|
+
icon.textContent = 'visibility_off';
|
92
|
+
icon.title = i18next.t('text.input-secret-show');
|
93
|
+
}
|
94
|
+
}
|
95
|
+
}
|
96
|
+
render() {
|
97
|
+
return html `
|
98
|
+
<div class="secret-container">
|
99
|
+
<input
|
100
|
+
type="password"
|
101
|
+
.value=${this.value || ''}
|
102
|
+
.placeholder=${this.placeholder || i18next.t('text.input-secret-placeholder')}
|
103
|
+
@change=${(e) => {
|
104
|
+
e.stopPropagation();
|
105
|
+
this.dispatchChangeEvent(e.target.value);
|
106
|
+
}}
|
107
|
+
@keydown=${(e) => {
|
108
|
+
if (e.key === 'Enter') {
|
109
|
+
if (e.target.value == this.value) {
|
110
|
+
/* Even if the value has not changed, the enter key triggers a change event. */
|
111
|
+
e.preventDefault(); /* Prevent change event from occurring twice. */
|
112
|
+
this.input.dispatchEvent(new CustomEvent('change', {
|
113
|
+
detail: e.target.value
|
114
|
+
}));
|
115
|
+
}
|
116
|
+
}
|
117
|
+
}}
|
118
|
+
?disabled=${this.disabled}
|
119
|
+
autocomplete="off"
|
120
|
+
autocorrect="off"
|
121
|
+
autocapitalize="off"
|
122
|
+
spellcheck="false"
|
123
|
+
data-form-type="other"
|
124
|
+
/>
|
125
|
+
<md-icon
|
126
|
+
class="secret-toggle"
|
127
|
+
@click=${(e) => {
|
128
|
+
e.stopPropagation();
|
129
|
+
this.togglePasswordVisibility();
|
130
|
+
}}
|
131
|
+
title=${i18next.t('text.input-secret-toggle')}
|
132
|
+
>
|
133
|
+
visibility_off
|
134
|
+
</md-icon>
|
135
|
+
</div>
|
136
|
+
`;
|
137
|
+
}
|
138
|
+
firstUpdated() {
|
139
|
+
if (this.autofocus) {
|
140
|
+
this.input.focus();
|
141
|
+
}
|
142
|
+
}
|
143
|
+
dispatchChangeEvent(value) {
|
144
|
+
this.value = value;
|
145
|
+
this.dispatchEvent(new CustomEvent('change', {
|
146
|
+
bubbles: true,
|
147
|
+
composed: true,
|
148
|
+
detail: value
|
149
|
+
}));
|
150
|
+
if (this.selectAfterChange) {
|
151
|
+
requestAnimationFrame(() => {
|
152
|
+
this.input.select();
|
153
|
+
});
|
154
|
+
}
|
155
|
+
}
|
156
|
+
};
|
157
|
+
__decorate([
|
158
|
+
property({ type: String })
|
159
|
+
], OxInputSecret.prototype, "placeholder", void 0);
|
160
|
+
__decorate([
|
161
|
+
property({ attribute: 'select-after-change', type: Boolean })
|
162
|
+
], OxInputSecret.prototype, "selectAfterChange", void 0);
|
163
|
+
__decorate([
|
164
|
+
property({ type: String })
|
165
|
+
], OxInputSecret.prototype, "value", void 0);
|
166
|
+
__decorate([
|
167
|
+
query('input')
|
168
|
+
], OxInputSecret.prototype, "input", void 0);
|
169
|
+
OxInputSecret = __decorate([
|
170
|
+
customElement('ox-input-secret')
|
171
|
+
], OxInputSecret);
|
172
|
+
export { OxInputSecret };
|
173
|
+
//# sourceMappingURL=ox-input-secret.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ox-input-secret.js","sourceRoot":"","sources":["../../src/ox-input-secret.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,4BAA4B,CAAA;AAEnC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EA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AA;YACrB,CAAC,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;;AA9F2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAAqB;AACe;IAA9D,QAAQ,CAAC,EAAE,SAAS,EAAE,qBAAqB,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wDAA4B;AAC9D;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAA2B;AAEtC;IAAf,KAAK,CAAC,OAAO,CAAC;4CAAyB;AAvE7B,aAAa;IADzB,aAAa,CAAC,iBAAiB,CAAC;GACpB,aAAa,CAkKzB","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport '@material/web/icon/icon.js'\n\nimport { css, html } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\nimport { i18next } from '@operato/i18n'\n\nimport { OxFormField } from './ox-form-field.js'\n\n@customElement('ox-input-secret')\nexport class OxInputSecret extends OxFormField<string | undefined> {\n static styles = [\n css`\n :host {\n display: flex;\n position: relative;\n align-items: center;\n\n color: var(--ox-input-secret-color, var(--md-sys-color-on-surface-variant));\n background-color: var(--ox-input-secret-background-color, var(--md-sys-color-surface-variant));\n\n --md-icon-size: 20px;\n }\n\n .secret-container {\n display: flex;\n align-items: center;\n justify-content: space-between;\n position: relative;\n width: 100%;\n }\n\n input {\n flex: 1;\n color: inherit;\n background-color: transparent;\n border: 0;\n padding: var(--input-secret-padding, var(--spacing-tiny));\n overflow: hidden;\n text-overflow: ellipsis;\n font-family: inherit;\n font-size: inherit;\n letter-spacing: 0.5px;\n }\n\n input:focus {\n outline: none;\n }\n\n input:focus {\n outline: none;\n border: none;\n box-shadow: none;\n }\n\n .secret-toggle {\n position: absolute;\n right: 0px;\n cursor: pointer;\n font-size: 16px;\n color: var(--md-sys-color-on-surface-variant);\n user-select: none;\n opacity: 0.7;\n transition: opacity 0.2s;\n }\n\n .secret-toggle:hover {\n opacity: 1;\n color: var(--md-sys-color-primary);\n }\n\n .secret-container:hover .secret-toggle {\n opacity: 1;\n }\n `\n ]\n\n @property({ type: String }) placeholder?: string\n @property({ attribute: 'select-after-change', type: Boolean }) selectAfterChange?: boolean\n @property({ type: String }) value?: string | undefined\n\n @query('input') input!: HTMLInputElement\n\n private togglePasswordVisibility() {\n if (!this.input) return\n\n if (this.input.type === 'password') {\n this.input.type = 'text'\n const icon = this.renderRoot.querySelector('.secret-toggle') as HTMLElement\n if (icon) {\n icon.textContent = 'visibility'\n icon.title = i18next.t('text.input-secret-hide')\n }\n } else {\n this.input.type = 'password'\n const icon = this.renderRoot.querySelector('.secret-toggle') as HTMLElement\n if (icon) {\n icon.textContent = 'visibility_off'\n icon.title = i18next.t('text.input-secret-show')\n }\n }\n }\n\n render() {\n return html`\n <div class=\"secret-container\">\n <input\n type=\"password\"\n .value=${this.value || ''}\n .placeholder=${this.placeholder || i18next.t('text.input-secret-placeholder')}\n @change=${(e: Event) => {\n e.stopPropagation()\n this.dispatchChangeEvent((e.target as HTMLInputElement).value)\n }}\n @keydown=${(e: KeyboardEvent) => {\n if (e.key === 'Enter') {\n if ((e.target as HTMLInputElement).value == this.value) {\n /* Even if the value has not changed, the enter key triggers a change event. */\n e.preventDefault() /* Prevent change event from occurring twice. */\n\n this.input.dispatchEvent(\n new CustomEvent('change', {\n detail: (e.target as HTMLInputElement).value\n })\n )\n }\n }\n }}\n ?disabled=${this.disabled}\n autocomplete=\"off\"\n autocorrect=\"off\"\n autocapitalize=\"off\"\n spellcheck=\"false\"\n data-form-type=\"other\"\n />\n <md-icon\n class=\"secret-toggle\"\n @click=${(e: Event) => {\n e.stopPropagation()\n this.togglePasswordVisibility()\n }}\n title=${i18next.t('text.input-secret-toggle')}\n >\n visibility_off\n </md-icon>\n </div>\n `\n }\n\n firstUpdated() {\n if (this.autofocus) {\n this.input.focus()\n }\n }\n\n dispatchChangeEvent(value: string) {\n this.value = value\n\n this.dispatchEvent(\n new CustomEvent('change', {\n bubbles: true,\n composed: true,\n detail: value\n })\n )\n\n if (this.selectAfterChange) {\n requestAnimationFrame(() => {\n this.input.select()\n })\n }\n }\n}\n"]}
|