@operato/input 1.0.0-beta.30 → 1.0.0-beta.31
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 +10 -0
- package/dist/src/index.d.ts +3 -2
- package/dist/src/index.js +3 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/ox-input-barcode.d.ts +3 -1
- package/dist/src/ox-input-barcode.js +35 -5
- package/dist/src/ox-input-barcode.js.map +1 -1
- package/dist/src/ox-input-duration.d.ts +13 -0
- package/dist/src/ox-input-duration.js +138 -0
- package/dist/src/ox-input-duration.js.map +1 -0
- package/dist/stories/ox-input-barcode.stories.d.ts +5 -0
- package/dist/stories/ox-input-barcode.stories.js +20 -4
- package/dist/stories/ox-input-barcode.stories.js.map +1 -1
- package/dist/stories/ox-input-duration.stories.d.ts +26 -0
- package/dist/stories/ox-input-duration.stories.js +37 -0
- package/dist/stories/ox-input-duration.stories.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -7
- package/src/index.ts +3 -2
- package/src/ox-input-barcode.ts +40 -5
- package/src/ox-input-duration.ts +143 -0
- package/stories/ox-input-barcode.stories.ts +27 -4
- package/stories/ox-input-duration.stories.ts +51 -0
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,16 @@
|
|
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
|
+
## [1.0.0-beta.31](https://github.com/hatiolab/operato/compare/v1.0.0-beta.30...v1.0.0-beta.31) (2022-06-15)
|
7
|
+
|
8
|
+
|
9
|
+
### :rocket: New Features
|
10
|
+
|
11
|
+
* add ox-input-duration ([34e727f](https://github.com/hatiolab/operato/commit/34e727fff77c5a6764b5fba63c56564919766373))
|
12
|
+
* ox-input-barcode english-only ([c062ab9](https://github.com/hatiolab/operato/commit/c062ab99be827e8d5e4f55a6f95a0df7c2dd10d8))
|
13
|
+
|
14
|
+
|
15
|
+
|
6
16
|
## [1.0.0-beta.30](https://github.com/hatiolab/operato/compare/v1.0.0-beta.29...v1.0.0-beta.30) (2022-06-13)
|
7
17
|
|
8
18
|
|
package/dist/src/index.d.ts
CHANGED
@@ -17,5 +17,6 @@ export * from './ox-input-value-ranges.js';
|
|
17
17
|
export * from './ox-input-value-map.js';
|
18
18
|
export * from './ox-input-table.js';
|
19
19
|
export * from './ox-input-scene-component-id.js';
|
20
|
-
export * from './ox-input-crontab';
|
21
|
-
export * from './ox-input-partition-keys';
|
20
|
+
export * from './ox-input-crontab.js';
|
21
|
+
export * from './ox-input-partition-keys.js';
|
22
|
+
export * from './ox-input-duration.js';
|
package/dist/src/index.js
CHANGED
@@ -17,6 +17,7 @@ export * from './ox-input-value-ranges.js';
|
|
17
17
|
export * from './ox-input-value-map.js';
|
18
18
|
export * from './ox-input-table.js';
|
19
19
|
export * from './ox-input-scene-component-id.js';
|
20
|
-
export * from './ox-input-crontab';
|
21
|
-
export * from './ox-input-partition-keys';
|
20
|
+
export * from './ox-input-crontab.js';
|
21
|
+
export * from './ox-input-partition-keys.js';
|
22
|
+
export * from './ox-input-duration.js';
|
22
23
|
//# 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,cAAc,oBAAoB,CAAA;AAClC,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,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,2BAA2B,CAAA;AACzC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,kCAAkC,CAAA;AAChD,cAAc,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,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,2BAA2B,CAAA;AACzC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,kCAAkC,CAAA;AAChD,cAAc,uBAAuB,CAAA;AACrC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,wBAAwB,CAAA","sourcesContent":["export * 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-angle.js'\nexport * from './ox-input-3dish.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-color-stops.js'\nexport * from './ox-input-color-gradient.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-table.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'\n"]}
|
@@ -7,6 +7,7 @@ export declare class OxInputBarcode extends OxFormField {
|
|
7
7
|
scannable?: boolean;
|
8
8
|
withoutEnter?: boolean;
|
9
9
|
value?: string;
|
10
|
+
englishOnly?: boolean;
|
10
11
|
stream?: MediaStream;
|
11
12
|
reader?: BrowserMultiFormatReader;
|
12
13
|
input: HTMLInputElement;
|
@@ -15,7 +16,8 @@ export declare class OxInputBarcode extends OxFormField {
|
|
15
16
|
connectedCallback(): void;
|
16
17
|
disconnectedCallback(): void;
|
17
18
|
render(): import("lit-html").TemplateResult<1>;
|
18
|
-
|
19
|
+
onInputChange(e: Event): void;
|
20
|
+
onInputKeyDown(e: KeyboardEvent): void;
|
19
21
|
scan(e: MouseEvent): Promise<void>;
|
20
22
|
stopScan(): void;
|
21
23
|
}
|
@@ -103,9 +103,8 @@ let OxInputBarcode = class OxInputBarcode extends OxFormField {
|
|
103
103
|
<input
|
104
104
|
type="text"
|
105
105
|
.value=${this.value || ''}
|
106
|
-
|
107
|
-
@
|
108
|
-
@keypress=${(e) => this.onChange(e)}
|
106
|
+
@change=${(e) => this.onInputChange(e)}
|
107
|
+
@keydown=${(e) => this.onInputKeyDown(e)}
|
109
108
|
/>
|
110
109
|
<button
|
111
110
|
?hidden=${!this.scannable}
|
@@ -124,12 +123,40 @@ let OxInputBarcode = class OxInputBarcode extends OxFormField {
|
|
124
123
|
</ox-popup>
|
125
124
|
`;
|
126
125
|
}
|
127
|
-
|
126
|
+
onInputChange(e) {
|
128
127
|
e.stopPropagation();
|
129
|
-
this.
|
128
|
+
if (this.englishOnly) {
|
129
|
+
/* englishOnly 인 경우에는 멀티바이트 문자들을 모두 제거한다. */
|
130
|
+
this.value = this.input.value = this.input.value?.replace(/[^\x00-\x7F]/g, '');
|
131
|
+
}
|
132
|
+
else {
|
133
|
+
this.value = this.input.value;
|
134
|
+
}
|
130
135
|
//@ts-ignore
|
131
136
|
this.dispatchEvent(new e.constructor(e.type, e));
|
132
137
|
}
|
138
|
+
onInputKeyDown(e) {
|
139
|
+
if (this.englishOnly && !e.metaKey && !e.ctrlKey && !e.altKey && /^(Digit|Key)/.test(e.code)) {
|
140
|
+
e.stopPropagation();
|
141
|
+
e.preventDefault();
|
142
|
+
/* englishOnly 인 경우에 문자와 숫자들은 여기에서 처리한다. 멀티바이트 문자들이 대부분 알파벳과 숫자 키보드의 자모음을 조합하므로, ... */
|
143
|
+
switch (true) {
|
144
|
+
case /^Key/.test(e.code):
|
145
|
+
var key = e.shiftKey ? e.code.charAt(3) : e.code.charAt(3).toLowerCase();
|
146
|
+
break;
|
147
|
+
case /^Digit/.test(e.code):
|
148
|
+
var key = e.code.charAt(5);
|
149
|
+
break;
|
150
|
+
default:
|
151
|
+
var key = '';
|
152
|
+
}
|
153
|
+
const value = this.input.value;
|
154
|
+
const start = this.input.selectionStart || 0;
|
155
|
+
const end = this.input.selectionEnd || 0;
|
156
|
+
this.input.value = [value.substring(0, start), key, value.substring(end)].join('');
|
157
|
+
this.input.selectionEnd = this.input.selectionStart = start + 1;
|
158
|
+
}
|
159
|
+
}
|
133
160
|
async scan(e) {
|
134
161
|
try {
|
135
162
|
this.popup.open({});
|
@@ -186,6 +213,9 @@ __decorate([
|
|
186
213
|
__decorate([
|
187
214
|
property({ type: String })
|
188
215
|
], OxInputBarcode.prototype, "value", void 0);
|
216
|
+
__decorate([
|
217
|
+
property({ attribute: 'english-only', type: Boolean })
|
218
|
+
], OxInputBarcode.prototype, "englishOnly", void 0);
|
189
219
|
__decorate([
|
190
220
|
state()
|
191
221
|
], OxInputBarcode.prototype, "stream", void 0);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ox-input-barcode.js","sourceRoot":"","sources":["../../src/ox-input-barcode.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AAEnC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE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,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;CACF,CAAA;AA5H8B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;iDAAoB;AACS;IAAxD,QAAQ,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;oDAAuB;AACnD;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAAuB;AAEzC;IAAR,KAAK,EAAE;8CAAqB;AACpB;IAAR,KAAK,EAAE;8CAAkC;AAE1B;IAAf,KAAK,CAAC,OAAO,CAAC;6CAAyB;AACrB;IAAlB,KAAK,CAAC,UAAU,CAAC;6CAAgB;AAClB;IAAf,KAAK,CAAC,OAAO,CAAC;6CAAyB;AAhF7B,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CAmM1B;SAnMY,cAAc","sourcesContent":["import '@operato/popup/ox-popup.js'\n\nimport { css, html } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\n\nimport { OxPopup } from '@operato/popup'\nimport { BrowserMultiFormatReader } from '@zxing/library'\n\nimport { OxFormField } from './ox-form-field.js'\n\nconst barcodeIcon = `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAYBAMAAAAfR1CMAAADKGlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMxNDUgNzkuMTYzNDk5LCAyMDE4LzA4LzEzLTE2OjQwOjIyICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaX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n css`\n :host {\n display: flex;\n align-items: center;\n border: none;\n overflow: hidden;\n }\n\n * {\n align-self: stretch;\n }\n\n *:focus {\n outline: none;\n }\n\n input {\n flex: 1;\n border: 0;\n border-bottom: var(--border-dark-color);\n padding: var(--input-padding);\n padding-right: 35px;\n font: var(--input-font);\n color: var(--primary-text-color);\n }\n input:focus {\n outline: none;\n border-bottom: 1px solid var(--primary-color);\n }\n\n #scan-button {\n display: block;\n position: relative;\n margin-left: -30px;\n width: 30px;\n border: none;\n background: var(--barcodescan-input-button-icon) no-repeat center center;\n }\n\n #scan-button[hidden] {\n display: none;\n }\n\n ox-popup {\n position: fixed;\n\n width: 80vw;\n height: 80vh;\n transform: translate(10%, 10%);\n }\n\n video {\n width: 100%;\n height: 100%;\n }\n\n @media screen and (max-width: 460px) {\n ox-popup {\n position: fixed;\n left: 0;\n top: 0;\n width: 100vw;\n height: 100vh;\n transform: translate(0%, 0%);\n }\n }\n `\n ]\n\n @property({ type: Boolean }) scannable?: boolean\n @property({ attribute: 'without-enter', type: Boolean }) withoutEnter?: boolean\n @property({ type: String }) declare value?: string\n\n @state() stream?: MediaStream\n @state() reader?: BrowserMultiFormatReader\n\n @query('input') input!: HTMLInputElement\n @query('ox-popup') popup!: OxPopup\n @query('video') video!: HTMLVideoElement\n\n connectedCallback() {\n super.connectedCallback()\n\n this.scannable = false\n\n if (navigator.mediaDevices) {\n ;(async () => {\n try {\n var stream = await navigator.mediaDevices.getUserMedia({ video: { facingMode: 'environment' } })\n if (stream) {\n stream.getTracks().forEach(track => track.stop())\n this.scannable = true\n }\n } catch (e) {\n console.warn('this device not support camera for barcode scan', e)\n }\n })()\n }\n }\n\n disconnectedCallback() {\n this.stopScan()\n }\n\n render() {\n this.style.setProperty('--barcodescan-input-button-icon', `url(${barcodeIcon})`)\n\n return html`\n <input\n type=\"text\"\n .value=${this.value || ''}\n maxlength=\"50\"\n @change=${(e: Event) => this.onChange(e)}\n @keypress=${(e: Event) => this.onChange(e)}\n />\n <button\n ?hidden=${!this.scannable}\n id=\"scan-button\"\n @click=${(e: MouseEvent) => {\n this.scan(e)\n }}\n ></button>\n\n <ox-popup\n @focusout=${() => {\n this.stopScan()\n }}\n >\n <video></video>\n </ox-popup>\n `\n }\n\n onChange(e: Event) {\n e.stopPropagation()\n this.value = (e.target as HTMLInputElement)?.value\n //@ts-ignore\n this.dispatchEvent(new e.constructor(e.type, e))\n }\n\n async scan(e: MouseEvent) {\n try {\n this.popup.open({})\n\n /* template.video가 생성된 후에 접근하기 위해서, 한 프레임을 강제로 건너뛴다. */\n await this.updateComplete\n\n var constraints = { video: { facingMode: 'environment' } } /* backside camera first */\n this.stream = await navigator.mediaDevices.getUserMedia(constraints)\n\n this.reader = new BrowserMultiFormatReader()\n if (getComputedStyle(this.popup).display !== 'none' /* popup not hidden */ && this.stream) {\n var result = await this.reader.decodeOnceFromStream(this.stream, this.video)\n var input = this.input\n input.focus()\n this.value = input.value = String(result)\n\n if (!this.withoutEnter) {\n input.dispatchEvent(new KeyboardEvent('keypress', { keyCode: 0x0d, key: 'Enter' }))\n input.dispatchEvent(\n new CustomEvent('change', {\n bubbles: true,\n composed: true,\n detail: this.value\n })\n )\n }\n } else {\n /* popup이 비동기 진행 중에 close된 경우라면, stopScan()을 처리하지 못하게 되므로, 다시한번 clear해준다. */\n this.stopScan()\n }\n } catch (err) {\n /*\n * 1. stream device 문제로 예외 발생한 경우.\n * 2. 뒤로가기 등으로 popup이 종료된 경우에도 NotFoundException: Video stream has ended before any code could be detected. 이 발생한다.\n */\n console.warn(err)\n } finally {\n this.popup.close()\n\n this.stopScan()\n }\n }\n\n stopScan() {\n this.video.pause()\n\n this.stream && this.stream.getTracks().forEach(track => track.stop())\n this.reader && this.reader.reset()\n\n delete this.stream\n delete this.reader\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"ox-input-barcode.js","sourceRoot":"","sources":["../../src/ox-input-barcode.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AAEnC,OAAO,EA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,EAAE,CAAA;SAChB;IACH,CAAC;IAED,QAAQ;QACN,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;QAElB,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAA;QACrE,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAA;QAElC,OAAO,IAAI,CAAC,MAAM,CAAA;QAClB,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;CACF,CAAA;AA/J8B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;iDAAoB;AACS;IAAxD,QAAQ,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;oDAAuB;AACnD;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAAuB;AACM;IAAvD,QAAQ,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;mDAAsB;AAEpE;IAAR,KAAK,EAAE;8CAAqB;AACpB;IAAR,KAAK,EAAE;8CAAkC;AAE1B;IAAf,KAAK,CAAC,OAAO,CAAC;6CAAyB;AACrB;IAAlB,KAAK,CAAC,UAAU,CAAC;6CAAgB;AAClB;IAAf,KAAK,CAAC,OAAO,CAAC;6CAAyB;AAjF7B,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CAsO1B;SAtOY,cAAc","sourcesContent":["import '@operato/popup/ox-popup.js'\n\nimport { css, html } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\n\nimport { OxPopup } from '@operato/popup'\nimport { BrowserMultiFormatReader } from '@zxing/library'\n\nimport { OxFormField } from './ox-form-field.js'\n\nconst barcodeIcon = `data:image/png;base64,iVBORw0KGgoAA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L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+55pr/QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAAkUExURQAAAEdwTAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEus/7UCWQwAAAALdFJOU9YAg3wKBFBDSz9PnvQNDgAAAE9JREFUGNNjEEQFDKLJSnCOklkgg9QUJFn3RgZhRyS+iCGDEIp2RSBfQICRkRGIgTSQL4jCF6ScvxsZYOFT2T50/6D7Fz080MMLPTzRwhsAHVspfelur08AAAAASUVORK5CYII=`\n\n@customElement('ox-input-barcode')\nexport class OxInputBarcode extends OxFormField {\n static styles = [\n css`\n :host {\n display: flex;\n align-items: center;\n border: none;\n overflow: hidden;\n }\n\n * {\n align-self: stretch;\n }\n\n *:focus {\n outline: none;\n }\n\n input {\n flex: 1;\n border: 0;\n border-bottom: var(--border-dark-color);\n padding: var(--input-padding);\n padding-right: 35px;\n font: var(--input-font);\n color: var(--primary-text-color);\n }\n input:focus {\n outline: none;\n border-bottom: 1px solid var(--primary-color);\n }\n\n #scan-button {\n display: block;\n position: relative;\n margin-left: -30px;\n width: 30px;\n border: none;\n background: var(--barcodescan-input-button-icon) no-repeat center center;\n }\n\n #scan-button[hidden] {\n display: none;\n }\n\n ox-popup {\n position: fixed;\n\n width: 80vw;\n height: 80vh;\n transform: translate(10%, 10%);\n }\n\n video {\n width: 100%;\n height: 100%;\n }\n\n @media screen and (max-width: 460px) {\n ox-popup {\n position: fixed;\n left: 0;\n top: 0;\n width: 100vw;\n height: 100vh;\n transform: translate(0%, 0%);\n }\n }\n `\n ]\n\n @property({ type: Boolean }) scannable?: boolean\n @property({ attribute: 'without-enter', type: Boolean }) withoutEnter?: boolean\n @property({ type: String }) declare value?: string\n @property({ attribute: 'english-only', type: Boolean }) englishOnly?: boolean\n\n @state() stream?: MediaStream\n @state() reader?: BrowserMultiFormatReader\n\n @query('input') input!: HTMLInputElement\n @query('ox-popup') popup!: OxPopup\n @query('video') video!: HTMLVideoElement\n\n connectedCallback() {\n super.connectedCallback()\n\n this.scannable = false\n\n if (navigator.mediaDevices) {\n ;(async () => {\n try {\n var stream = await navigator.mediaDevices.getUserMedia({ video: { facingMode: 'environment' } })\n if (stream) {\n stream.getTracks().forEach(track => track.stop())\n this.scannable = true\n }\n } catch (e) {\n console.warn('this device not support camera for barcode scan', e)\n }\n })()\n }\n }\n\n disconnectedCallback() {\n this.stopScan()\n }\n\n render() {\n this.style.setProperty('--barcodescan-input-button-icon', `url(${barcodeIcon})`)\n\n return html`\n <input\n type=\"text\"\n .value=${this.value || ''}\n @change=${(e: Event) => this.onInputChange(e)}\n @keydown=${(e: KeyboardEvent) => this.onInputKeyDown(e)}\n />\n <button\n ?hidden=${!this.scannable}\n id=\"scan-button\"\n @click=${(e: MouseEvent) => {\n this.scan(e)\n }}\n ></button>\n\n <ox-popup\n @focusout=${() => {\n this.stopScan()\n }}\n >\n <video></video>\n </ox-popup>\n `\n }\n\n onInputChange(e: Event) {\n e.stopPropagation()\n\n if (this.englishOnly) {\n /* englishOnly 인 경우에는 멀티바이트 문자들을 모두 제거한다. */\n this.value = this.input.value = this.input.value?.replace(/[^\\x00-\\x7F]/g, '')\n } else {\n this.value = this.input.value\n }\n\n //@ts-ignore\n this.dispatchEvent(new e.constructor(e.type, e))\n }\n\n onInputKeyDown(e: KeyboardEvent) {\n if (this.englishOnly && !e.metaKey && !e.ctrlKey && !e.altKey && /^(Digit|Key)/.test(e.code)) {\n e.stopPropagation()\n e.preventDefault()\n\n /* englishOnly 인 경우에 문자와 숫자들은 여기에서 처리한다. 멀티바이트 문자들이 대부분 알파벳과 숫자 키보드의 자모음을 조합하므로, ... */\n switch (true) {\n case /^Key/.test(e.code):\n var key = e.shiftKey ? e.code.charAt(3) : e.code.charAt(3).toLowerCase()\n break\n case /^Digit/.test(e.code):\n var key = e.code.charAt(5)\n break\n default:\n var key = ''\n }\n\n const value = this.input.value\n\n const start = this.input.selectionStart || 0\n const end = this.input.selectionEnd || 0\n\n this.input.value = [value.substring(0, start), key, value.substring(end)].join('')\n\n this.input.selectionEnd = this.input.selectionStart = start + 1\n }\n }\n\n async scan(e: MouseEvent) {\n try {\n this.popup.open({})\n\n /* template.video가 생성된 후에 접근하기 위해서, 한 프레임을 강제로 건너뛴다. */\n await this.updateComplete\n\n var constraints = { video: { facingMode: 'environment' } } /* backside camera first */\n this.stream = await navigator.mediaDevices.getUserMedia(constraints)\n\n this.reader = new BrowserMultiFormatReader()\n if (getComputedStyle(this.popup).display !== 'none' /* popup not hidden */ && this.stream) {\n var result = await this.reader.decodeOnceFromStream(this.stream, this.video)\n var input = this.input\n input.focus()\n this.value = input.value = String(result)\n\n if (!this.withoutEnter) {\n input.dispatchEvent(new KeyboardEvent('keypress', { keyCode: 0x0d, key: 'Enter' }))\n input.dispatchEvent(\n new CustomEvent('change', {\n bubbles: true,\n composed: true,\n detail: this.value\n })\n )\n }\n } else {\n /* popup이 비동기 진행 중에 close된 경우라면, stopScan()을 처리하지 못하게 되므로, 다시한번 clear해준다. */\n this.stopScan()\n }\n } catch (err) {\n /*\n * 1. stream device 문제로 예외 발생한 경우.\n * 2. 뒤로가기 등으로 popup이 종료된 경우에도 NotFoundException: Video stream has ended before any code could be detected. 이 발생한다.\n */\n console.warn(err)\n } finally {\n this.popup.close()\n\n this.stopScan()\n }\n }\n\n stopScan() {\n this.video.pause()\n\n this.stream && this.stream.getTracks().forEach(track => track.stop())\n this.reader && this.reader.reset()\n\n delete this.stream\n delete this.reader\n }\n}\n"]}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import '@material/mwc-button';
|
2
|
+
import { OxFormField } from './ox-form-field';
|
3
|
+
export declare class OxInputDuration extends OxFormField {
|
4
|
+
static styles: import("lit").CSSResult;
|
5
|
+
value?: number;
|
6
|
+
render(): import("lit-html").TemplateResult<1>;
|
7
|
+
firstUpdated(): void;
|
8
|
+
days: HTMLInputElement;
|
9
|
+
hours: HTMLInputElement;
|
10
|
+
minutes: HTMLInputElement;
|
11
|
+
seconds: HTMLInputElement;
|
12
|
+
onChange(e: Event): void;
|
13
|
+
}
|
@@ -0,0 +1,138 @@
|
|
1
|
+
import { __decorate } from "tslib";
|
2
|
+
import '@material/mwc-button';
|
3
|
+
import { css, html } from 'lit';
|
4
|
+
import { customElement, property, query } from 'lit/decorators.js';
|
5
|
+
import { i18next } from '@operato/i18n';
|
6
|
+
import { OxFormField } from './ox-form-field';
|
7
|
+
let OxInputDuration = class OxInputDuration extends OxFormField {
|
8
|
+
static { this.styles = css `
|
9
|
+
:host {
|
10
|
+
display: block;
|
11
|
+
width: 100%;
|
12
|
+
height: 100%;
|
13
|
+
}
|
14
|
+
|
15
|
+
:host * {
|
16
|
+
box-sizing: border-box;
|
17
|
+
}
|
18
|
+
|
19
|
+
:host *:focus {
|
20
|
+
outline: none;
|
21
|
+
}
|
22
|
+
|
23
|
+
form {
|
24
|
+
width: 100%;
|
25
|
+
height: 100%;
|
26
|
+
justify-content: center;
|
27
|
+
}
|
28
|
+
|
29
|
+
input {
|
30
|
+
margin-top: var(--margin-default);
|
31
|
+
padding: 5px;
|
32
|
+
border: 0;
|
33
|
+
border-bottom: var(--border-dark-color);
|
34
|
+
padding: var(--input-padding);
|
35
|
+
font: var(--input-font);
|
36
|
+
color: var(--primary-text-color);
|
37
|
+
}
|
38
|
+
|
39
|
+
input:focus {
|
40
|
+
outline: none;
|
41
|
+
border-bottom: 1px solid var(--primary-color);
|
42
|
+
}
|
43
|
+
|
44
|
+
input:invalid {
|
45
|
+
border-bottom: 1px solid var(--status-danger-color);
|
46
|
+
color: var(--status-danger-color);
|
47
|
+
}
|
48
|
+
|
49
|
+
label {
|
50
|
+
width: 100%;
|
51
|
+
font: normal 0.8em var(--theme-font);
|
52
|
+
color: var(--primary-color);
|
53
|
+
}
|
54
|
+
`; }
|
55
|
+
render() {
|
56
|
+
var d = Number(this.value || 0);
|
57
|
+
const days = Math.floor(d / (3600 * 24));
|
58
|
+
d -= days * 24 * 3600;
|
59
|
+
const hours = Math.floor(d / 3600);
|
60
|
+
d -= hours * 3600;
|
61
|
+
const minutes = Math.floor(d / 60);
|
62
|
+
const seconds = d - minutes * 60;
|
63
|
+
return html `
|
64
|
+
<form @change=${this.onChange.bind(this)}>
|
65
|
+
<input id="days" type="number" .value=${days} pattern="\\d*" />
|
66
|
+
<label for="days">${i18next.t('label.days')}</label>
|
67
|
+
|
68
|
+
<input id="hours" type="number" .value=${hours} pattern="[01]?\\d|2[0-3]" />
|
69
|
+
<label for="hour">${i18next.t('label.hours')}</label>
|
70
|
+
|
71
|
+
<input id="minutes" type="number" .value=${minutes} pattern="[0-5]?\\d" />
|
72
|
+
<label for="minute">${i18next.t('label.minutes')}</label>
|
73
|
+
|
74
|
+
<input id="seconds" type="number" .value=${seconds} pattern="[0-5]?\\d" />
|
75
|
+
<label for="second">${i18next.t('label.seconds')}</label>
|
76
|
+
|
77
|
+
<button
|
78
|
+
type="button"
|
79
|
+
@click=${(e) => {
|
80
|
+
e.preventDefault();
|
81
|
+
e.stopPropagation();
|
82
|
+
this.value = 0;
|
83
|
+
this.dispatchEvent(new CustomEvent('change', {
|
84
|
+
bubbles: true,
|
85
|
+
composed: true,
|
86
|
+
detail: this.value
|
87
|
+
}));
|
88
|
+
}}
|
89
|
+
>
|
90
|
+
Clear
|
91
|
+
</button>
|
92
|
+
</form>
|
93
|
+
`;
|
94
|
+
}
|
95
|
+
firstUpdated() {
|
96
|
+
;
|
97
|
+
this.renderRoot.querySelector('input').focus();
|
98
|
+
}
|
99
|
+
onChange(e) {
|
100
|
+
e.stopPropagation();
|
101
|
+
var form = this.renderRoot.querySelector('form');
|
102
|
+
var valid = form.checkValidity();
|
103
|
+
if (!valid) {
|
104
|
+
form.reportValidity();
|
105
|
+
return;
|
106
|
+
}
|
107
|
+
const days = Number(this.days.value);
|
108
|
+
const hours = Number(this.hours.value);
|
109
|
+
const minutes = Number(this.minutes.value);
|
110
|
+
const seconds = Number(this.seconds.value);
|
111
|
+
this.value = (days || 0) * 24 * 60 * 60 + (hours || 0) * 60 * 60 + (minutes || 0) * 60 + (seconds || 0);
|
112
|
+
this.dispatchEvent(new CustomEvent('change', {
|
113
|
+
bubbles: true,
|
114
|
+
composed: true,
|
115
|
+
detail: this.value
|
116
|
+
}));
|
117
|
+
}
|
118
|
+
};
|
119
|
+
__decorate([
|
120
|
+
property({ type: Number })
|
121
|
+
], OxInputDuration.prototype, "value", void 0);
|
122
|
+
__decorate([
|
123
|
+
query('#days')
|
124
|
+
], OxInputDuration.prototype, "days", void 0);
|
125
|
+
__decorate([
|
126
|
+
query('#hours')
|
127
|
+
], OxInputDuration.prototype, "hours", void 0);
|
128
|
+
__decorate([
|
129
|
+
query('#minutes')
|
130
|
+
], OxInputDuration.prototype, "minutes", void 0);
|
131
|
+
__decorate([
|
132
|
+
query('#seconds')
|
133
|
+
], OxInputDuration.prototype, "seconds", void 0);
|
134
|
+
OxInputDuration = __decorate([
|
135
|
+
customElement('ox-input-duration')
|
136
|
+
], OxInputDuration);
|
137
|
+
export { OxInputDuration };
|
138
|
+
//# sourceMappingURL=ox-input-duration.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ox-input-duration.js","sourceRoot":"","sources":["../../src/ox-input-duration.ts"],"names":[],"mappings":";AAAA,OAAO,sBAAsB,CAAA;AAE7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAElE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEvC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAG7C,IAAa,eAAe,GAA5B,MAAa,eAAgB,SAAQ,WAAW;aACvC,WAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8ClB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AK,CAAC,QAAQ,CAAC;8CAAyB;AACtB;IAAlB,KAAK,CAAC,UAAU,CAAC;gDAA2B;AAC1B;IAAlB,KAAK,CAAC,UAAU,CAAC;gDAA2B;AAzGlC,eAAe;IAD3B,aAAa,CAAC,mBAAmB,CAAC;GACtB,eAAe,CAoI3B;SApIY,eAAe","sourcesContent":["import '@material/mwc-button'\n\nimport { css, html } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\n\nimport { i18next } from '@operato/i18n'\n\nimport { OxFormField } from './ox-form-field'\n\n@customElement('ox-input-duration')\nexport class OxInputDuration extends OxFormField {\n static styles = css`\n :host {\n display: block;\n width: 100%;\n height: 100%;\n }\n\n :host * {\n box-sizing: border-box;\n }\n\n :host *:focus {\n outline: none;\n }\n\n form {\n width: 100%;\n height: 100%;\n justify-content: center;\n }\n\n input {\n margin-top: var(--margin-default);\n padding: 5px;\n border: 0;\n border-bottom: var(--border-dark-color);\n padding: var(--input-padding);\n font: var(--input-font);\n color: var(--primary-text-color);\n }\n\n input:focus {\n outline: none;\n border-bottom: 1px solid var(--primary-color);\n }\n\n input:invalid {\n border-bottom: 1px solid var(--status-danger-color);\n color: var(--status-danger-color);\n }\n\n label {\n width: 100%;\n font: normal 0.8em var(--theme-font);\n color: var(--primary-color);\n }\n `\n\n @property({ type: Number }) declare value?: number\n\n render() {\n var d = Number(this.value || 0)\n\n const days = Math.floor(d / (3600 * 24))\n d -= days * 24 * 3600\n const hours = Math.floor(d / 3600)\n d -= hours * 3600\n const minutes = Math.floor(d / 60)\n const seconds = d - minutes * 60\n\n return html`\n <form @change=${this.onChange.bind(this)}>\n <input id=\"days\" type=\"number\" .value=${days} pattern=\"\\\\d*\" />\n <label for=\"days\">${i18next.t('label.days')}</label>\n\n <input id=\"hours\" type=\"number\" .value=${hours} pattern=\"[01]?\\\\d|2[0-3]\" />\n <label for=\"hour\">${i18next.t('label.hours')}</label>\n\n <input id=\"minutes\" type=\"number\" .value=${minutes} pattern=\"[0-5]?\\\\d\" />\n <label for=\"minute\">${i18next.t('label.minutes')}</label>\n\n <input id=\"seconds\" type=\"number\" .value=${seconds} pattern=\"[0-5]?\\\\d\" />\n <label for=\"second\">${i18next.t('label.seconds')}</label>\n\n <button\n type=\"button\"\n @click=${(e: Event) => {\n e.preventDefault()\n e.stopPropagation()\n\n this.value = 0\n\n this.dispatchEvent(\n new CustomEvent('change', {\n bubbles: true,\n composed: true,\n detail: this.value\n })\n )\n }}\n >\n Clear\n </button>\n </form>\n `\n }\n\n firstUpdated() {\n ;(this.renderRoot.querySelector('input') as HTMLInputElement).focus()\n }\n\n @query('#days') days!: HTMLInputElement\n @query('#hours') hours!: HTMLInputElement\n @query('#minutes') minutes!: HTMLInputElement\n @query('#seconds') seconds!: HTMLInputElement\n\n onChange(e: Event) {\n e.stopPropagation()\n\n var form = this.renderRoot.querySelector('form') as HTMLFormElement\n var valid = form.checkValidity()\n if (!valid) {\n form.reportValidity()\n return\n }\n\n const days = Number(this.days.value)\n const hours = Number(this.hours.value)\n const minutes = Number(this.minutes.value)\n const seconds = Number(this.seconds.value)\n\n this.value = (days || 0) * 24 * 60 * 60 + (hours || 0) * 60 * 60 + (minutes || 0) * 60 + (seconds || 0)\n\n this.dispatchEvent(\n new CustomEvent('change', {\n bubbles: true,\n composed: true,\n detail: this.value\n })\n )\n }\n}\n"]}
|
@@ -16,6 +16,9 @@ declare const _default: {
|
|
16
16
|
withoutEnter: {
|
17
17
|
control: string;
|
18
18
|
};
|
19
|
+
englishOnly: {
|
20
|
+
control: string;
|
21
|
+
};
|
19
22
|
};
|
20
23
|
};
|
21
24
|
export default _default;
|
@@ -29,5 +32,7 @@ interface ArgTypes {
|
|
29
32
|
value?: string;
|
30
33
|
scannable?: boolean;
|
31
34
|
withoutEnter?: boolean;
|
35
|
+
englishOnly?: boolean;
|
32
36
|
}
|
33
37
|
export declare const Regular: Story<ArgTypes>;
|
38
|
+
export declare const EnglishOnly: Story<ArgTypes>;
|
@@ -7,18 +7,34 @@ export default {
|
|
7
7
|
name: { control: 'text' },
|
8
8
|
value: { control: 'text' },
|
9
9
|
scannable: { control: 'boolean' },
|
10
|
-
withoutEnter: { control: 'boolean' }
|
10
|
+
withoutEnter: { control: 'boolean' },
|
11
|
+
englishOnly: { control: 'boolean' }
|
11
12
|
}
|
12
13
|
};
|
13
|
-
const Template = ({ name = 'barcode', scannable = true, withoutEnter = true }) => html `
|
14
|
+
const Template = ({ name = 'barcode', scannable = true, withoutEnter = true, englishOnly = false }) => html `
|
14
15
|
<link href="/themes/app-theme.css" rel="stylesheet" />
|
15
16
|
<link href="https://fonts.googleapis.com/css?family=Material+Icons&display=block" rel="stylesheet" />
|
16
|
-
<ox-input-barcode
|
17
|
+
<ox-input-barcode
|
18
|
+
name=${name}
|
19
|
+
?without-enter=${withoutEnter}
|
20
|
+
?scannable=${scannable}
|
21
|
+
?english-only=${englishOnly}
|
22
|
+
@change=${(e) => console.log(e.detail)}
|
23
|
+
>
|
24
|
+
</ox-input-barcode>
|
17
25
|
`;
|
18
26
|
export const Regular = Template.bind({});
|
19
27
|
Regular.args = {
|
20
28
|
name: 'barcode',
|
21
29
|
scannable: true,
|
22
|
-
withoutEnter: true
|
30
|
+
withoutEnter: true,
|
31
|
+
englishOnly: false
|
32
|
+
};
|
33
|
+
export const EnglishOnly = Template.bind({});
|
34
|
+
EnglishOnly.args = {
|
35
|
+
name: 'barcode',
|
36
|
+
scannable: true,
|
37
|
+
withoutEnter: true,
|
38
|
+
englishOnly: true
|
23
39
|
};
|
24
40
|
//# sourceMappingURL=ox-input-barcode.stories.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ox-input-barcode.stories.js","sourceRoot":"","sources":["../../stories/ox-input-barcode.stories.ts"],"names":[],"mappings":"AAAA,OAAO,4BAA4B,CAAA;AAEnC,OAAO,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAA;AAE1C,eAAe;IACb,KAAK,EAAE,kBAAkB;IACzB,SAAS,EAAE,kBAAkB;IAC7B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,KAAK;CACnB,CAAA;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AAC5C,WAAW,CAAC,IAAI,GAAG;IACjB,IAAI,EAAE,SAAS;IACf,SAAS,EAAE,IAAI;IACf,YAAY,EAAE,IAAI;IAClB,WAAW,EAAE,IAAI;CAClB,CAAA","sourcesContent":["import '../src/ox-input-barcode.js'\n\nimport { html, TemplateResult } from 'lit'\n\nexport default {\n title: 'ox-input-barcode',\n component: 'ox-input-barcode',\n argTypes: {\n name: { control: 'text' },\n value: { control: 'text' },\n scannable: { control: 'boolean' },\n withoutEnter: { control: 'boolean' },\n englishOnly: { control: 'boolean' }\n }\n}\n\ninterface Story<T> {\n (args: T): TemplateResult\n args?: Partial<T>\n argTypes?: Record<string, unknown>\n}\n\ninterface ArgTypes {\n name?: string\n value?: string\n scannable?: boolean\n withoutEnter?: boolean\n englishOnly?: boolean\n}\n\nconst Template: Story<ArgTypes> = ({\n name = 'barcode',\n scannable = true,\n withoutEnter = true,\n englishOnly = false\n}: ArgTypes) => html`\n <link href=\"/themes/app-theme.css\" rel=\"stylesheet\" />\n <link href=\"https://fonts.googleapis.com/css?family=Material+Icons&display=block\" rel=\"stylesheet\" />\n <ox-input-barcode\n name=${name}\n ?without-enter=${withoutEnter}\n ?scannable=${scannable}\n ?english-only=${englishOnly}\n @change=${(e: CustomEvent) => console.log(e.detail)}\n >\n </ox-input-barcode>\n`\n\nexport const Regular = Template.bind({})\nRegular.args = {\n name: 'barcode',\n scannable: true,\n withoutEnter: true,\n englishOnly: false\n}\n\nexport const EnglishOnly = Template.bind({})\nEnglishOnly.args = {\n name: 'barcode',\n scannable: true,\n withoutEnter: true,\n englishOnly: true\n}\n"]}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import '../src/ox-input-duration.js';
|
2
|
+
import '../src/locale/locale-picker.js';
|
3
|
+
import { TemplateResult } from 'lit';
|
4
|
+
declare const _default: {
|
5
|
+
title: string;
|
6
|
+
component: string;
|
7
|
+
argTypes: {
|
8
|
+
value: {
|
9
|
+
control: string;
|
10
|
+
};
|
11
|
+
name: {
|
12
|
+
control: string;
|
13
|
+
};
|
14
|
+
};
|
15
|
+
};
|
16
|
+
export default _default;
|
17
|
+
interface Story<T> {
|
18
|
+
(args: T): TemplateResult;
|
19
|
+
args?: Partial<T>;
|
20
|
+
argTypes?: Record<string, unknown>;
|
21
|
+
}
|
22
|
+
interface ArgTypes {
|
23
|
+
name?: string;
|
24
|
+
value?: number;
|
25
|
+
}
|
26
|
+
export declare const Regular: Story<ArgTypes>;
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import '../src/ox-input-duration.js';
|
2
|
+
import '../src/locale/locale-picker.js';
|
3
|
+
import { html } from 'lit';
|
4
|
+
export default {
|
5
|
+
title: 'ox-input-duration',
|
6
|
+
component: 'ox-input-duration',
|
7
|
+
argTypes: {
|
8
|
+
value: { control: 'number' },
|
9
|
+
name: { control: 'text' }
|
10
|
+
}
|
11
|
+
};
|
12
|
+
const Template = ({ name = 'duration', value = 3601 }) => html `
|
13
|
+
<link href="/themes/app-theme.css" rel="stylesheet" />
|
14
|
+
<link href="https://fonts.googleapis.com/css?family=Material+Icons&display=block" rel="stylesheet" />
|
15
|
+
<style>
|
16
|
+
body {
|
17
|
+
}
|
18
|
+
</style>
|
19
|
+
|
20
|
+
<locale-picker></locale-picker>
|
21
|
+
<br /><br />
|
22
|
+
|
23
|
+
<ox-input-duration
|
24
|
+
@change=${(e) => {
|
25
|
+
console.log(e.target.value);
|
26
|
+
}}
|
27
|
+
name=${name}
|
28
|
+
.value=${value}
|
29
|
+
>
|
30
|
+
</ox-input-duration>
|
31
|
+
`;
|
32
|
+
export const Regular = Template.bind({});
|
33
|
+
Regular.args = {
|
34
|
+
name: 'duration',
|
35
|
+
value: 3601
|
36
|
+
};
|
37
|
+
//# sourceMappingURL=ox-input-duration.stories.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ox-input-duration.stories.js","sourceRoot":"","sources":["../../stories/ox-input-duration.stories.ts"],"names":[],"mappings":"AAAA,OAAO,6BAA6B,CAAA;AACpC,OAAO,gCAAgC,CAAA;AAEvC,OAAO,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAA;AAE1C,eAAe;IACb,KAAK,EAAE,mBAAmB;IAC1B,SAAS,EAAE,mBAAmB;IAC9B,QAAQ,EAAE;QACR,KAAK,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE;QAC5B,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;KAC1B;CACF,CAAA;AAaD,MAAM,QAAQ,GAAoB,CAAC,EAAE,IAAI,GAAG,UAAU,EAAE,KAAK,GAAG,IAAI,EAAY,EAAE,EAAE,CAAC,IAAI,CAAA;;;;;;;;;;;;cAY3E,CAAC,CAAQ,EAAE,EAAE;IACrB,OAAO,CAAC,GAAG,CAAE,CAAC,CAAC,MAA2B,CAAC,KAAK,CAAC,CAAA;AACnD,CAAC;WACM,IAAI;aACF,KAAK;;;CAGjB,CAAA;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AACxC,OAAO,CAAC,IAAI,GAAG;IACb,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,IAAI;CACZ,CAAA","sourcesContent":["import '../src/ox-input-duration.js'\nimport '../src/locale/locale-picker.js'\n\nimport { html, TemplateResult } from 'lit'\n\nexport default {\n title: 'ox-input-duration',\n component: 'ox-input-duration',\n argTypes: {\n value: { control: 'number' },\n name: { control: 'text' }\n }\n}\n\ninterface Story<T> {\n (args: T): TemplateResult\n args?: Partial<T>\n argTypes?: Record<string, unknown>\n}\n\ninterface ArgTypes {\n name?: string\n value?: number\n}\n\nconst Template: Story<ArgTypes> = ({ name = 'duration', value = 3601 }: ArgTypes) => html`\n <link href=\"/themes/app-theme.css\" rel=\"stylesheet\" />\n <link href=\"https://fonts.googleapis.com/css?family=Material+Icons&display=block\" rel=\"stylesheet\" />\n <style>\n body {\n }\n </style>\n\n <locale-picker></locale-picker>\n <br /><br />\n\n <ox-input-duration\n @change=${(e: Event) => {\n console.log((e.target as HTMLInputElement).value)\n }}\n name=${name}\n .value=${value}\n >\n </ox-input-duration>\n`\n\nexport const Regular = Template.bind({})\nRegular.args = {\n name: 'duration',\n value: 3601\n}\n"]}
|