@operato/input 2.0.0-beta.0 → 2.0.0-beta.12
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 +79 -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-direction.d.ts +11 -0
- package/dist/src/ox-input-direction.js +60 -0
- package/dist/src/ox-input-direction.js.map +1 -0
- package/dist/src/ox-input-mass-fraction.js +1 -0
- package/dist/src/ox-input-mass-fraction.js.map +1 -1
- package/dist/src/ox-input-select-buttons.d.ts +1 -1
- package/dist/src/ox-input-select-buttons.js +2 -2
- package/dist/src/ox-input-select-buttons.js.map +1 -1
- package/dist/src/ox-input-unit-number.d.ts +0 -2
- package/dist/src/ox-input-unit-number.js +4 -6
- package/dist/src/ox-input-unit-number.js.map +1 -1
- package/dist/src/ox-input-work-shift.js +1 -1
- package/dist/src/ox-input-work-shift.js.map +1 -1
- package/dist/stories/ox-input-direction.stories.d.ts +34 -0
- package/dist/stories/ox-input-direction.stories.js +70 -0
- package/dist/stories/ox-input-direction.stories.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -6
- package/src/index.ts +1 -0
- package/src/ox-input-direction.ts +65 -0
- package/src/ox-input-mass-fraction.ts +1 -0
- package/src/ox-input-select-buttons.ts +2 -2
- package/src/ox-input-unit-number.ts +6 -7
- package/src/ox-input-work-shift.ts +1 -1
- package/stories/ox-input-direction.stories.ts +86 -0
- package/themes/grist-theme.css +4 -0
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,85 @@
|
|
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
|
+
## [2.0.0-beta.12](https://github.com/hatiolab/operato/compare/v2.0.0-beta.11...v2.0.0-beta.12) (2024-06-09)
|
7
|
+
|
8
|
+
**Note:** Version bump only for package @operato/input
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
## [2.0.0-beta.9](https://github.com/hatiolab/operato/compare/v2.0.0-beta.8...v2.0.0-beta.9) (2024-06-08)
|
15
|
+
|
16
|
+
**Note:** Version bump only for package @operato/input
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
## [2.0.0-beta.8](https://github.com/hatiolab/operato/compare/v2.0.0-beta.7...v2.0.0-beta.8) (2024-06-07)
|
23
|
+
|
24
|
+
|
25
|
+
### :bug: Bug Fix
|
26
|
+
|
27
|
+
* ox-input-select-buttons 모바일에서 click 이벤트가 발생하지 않으므로, tap 이벤트 처리로 변경함 ([4bef771](https://github.com/hatiolab/operato/commit/4bef771d93875138a44a2edd60bf38734dedc50b))
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
## [2.0.0-beta.7](https://github.com/hatiolab/operato/compare/v2.0.0-beta.6...v2.0.0-beta.7) (2024-06-07)
|
32
|
+
|
33
|
+
|
34
|
+
### :rocket: New Features
|
35
|
+
|
36
|
+
* add user-preference-context into p13n module ([ba9901d](https://github.com/hatiolab/operato/commit/ba9901d5cc5df85ed1db8aeae471819be03244ca))
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
## [2.0.0-beta.5](https://github.com/hatiolab/operato/compare/v2.0.0-beta.4...v2.0.0-beta.5) (2024-06-04)
|
41
|
+
|
42
|
+
|
43
|
+
### :bug: Bug Fix
|
44
|
+
|
45
|
+
* theming design token : --border-dark-color => --border-dim-color ([eaf0866](https://github.com/hatiolab/operato/commit/eaf08667f6133cc4bcabf161bbe04305e0ff57e7))
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
## [2.0.0-beta.4](https://github.com/hatiolab/operato/compare/v2.0.0-beta.3...v2.0.0-beta.4) (2024-06-04)
|
50
|
+
|
51
|
+
|
52
|
+
### :bug: Bug Fix
|
53
|
+
|
54
|
+
* theming styles ([15fa201](https://github.com/hatiolab/operato/commit/15fa20198d7adc6b57f16e408f8dee94c40113f5))
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
## [2.0.0-beta.3](https://github.com/hatiolab/operato/compare/v2.0.0-beta.2...v2.0.0-beta.3) (2024-06-04)
|
59
|
+
|
60
|
+
**Note:** Version bump only for package @operato/input
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
## [2.0.0-beta.2](https://github.com/hatiolab/operato/compare/v2.0.0-beta.1...v2.0.0-beta.2) (2024-06-04)
|
67
|
+
|
68
|
+
|
69
|
+
### :bug: Bug Fix
|
70
|
+
|
71
|
+
* search form theming styles ([a8924a4](https://github.com/hatiolab/operato/commit/a8924a440d249a226dee4df277d7009c629c9b18))
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
## [2.0.0-beta.1](https://github.com/hatiolab/operato/compare/v2.0.0-beta.0...v2.0.0-beta.1) (2024-06-03)
|
76
|
+
|
77
|
+
|
78
|
+
### :bug: Bug Fix
|
79
|
+
|
80
|
+
* ox-input-direction ([0553490](https://github.com/hatiolab/operato/commit/05534907e4499eba5e557321dd93a16cec4eb291))
|
81
|
+
* style for label in ox-input-mass-fraction ([5bc6ec1](https://github.com/hatiolab/operato/commit/5bc6ec116c9caadbdaeed13712979927cd86bdc0))
|
82
|
+
|
83
|
+
|
84
|
+
|
6
85
|
## [2.0.0-beta.0](https://github.com/hatiolab/operato/compare/v2.0.0-alpha.158...v2.0.0-beta.0) (2024-06-01)
|
7
86
|
|
8
87
|
**Note:** Version bump only for package @operato/input
|
package/dist/src/index.d.ts
CHANGED
package/dist/src/index.js
CHANGED
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,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,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;AACtC,cAAc,0BAA0B,CAAA;AACxC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,wBAAwB,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-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-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'\nexport * from './ox-input-quantifier.js'\nexport * from './ox-input-select-buttons.js'\nexport * from './ox-input-textarea.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,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,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;AACtC,cAAc,0BAA0B,CAAA;AACxC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,wBAAwB,CAAA;AACtC,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-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-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'\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'\n"]}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
/**
|
2
|
+
* @license Copyright © HatioLab Inc. All rights reserved.
|
3
|
+
*/
|
4
|
+
import '@material/web/icon/icon.js';
|
5
|
+
import { OxFormField } from './ox-form-field';
|
6
|
+
export declare class OxInputDirection extends OxFormField {
|
7
|
+
static styles: import("lit").CSSResult;
|
8
|
+
value?: string;
|
9
|
+
render(): import("lit-html").TemplateResult<1>;
|
10
|
+
onClick(e: MouseEvent): void;
|
11
|
+
}
|
@@ -0,0 +1,60 @@
|
|
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 } from 'lit/decorators.js';
|
8
|
+
import { OxFormField } from './ox-form-field';
|
9
|
+
let OxInputDirection = class OxInputDirection extends OxFormField {
|
10
|
+
static { this.styles = css `
|
11
|
+
:host {
|
12
|
+
--md-icon-size: 1.4em;
|
13
|
+
}
|
14
|
+
|
15
|
+
div {
|
16
|
+
display: flex;
|
17
|
+
justify-content: space-between;
|
18
|
+
max-width: 140px;
|
19
|
+
}
|
20
|
+
|
21
|
+
md-icon {
|
22
|
+
color: var(--md-sys-color-on-background);
|
23
|
+
background-color: var(--md-sys-color-background);
|
24
|
+
}
|
25
|
+
|
26
|
+
md-icon[selected] {
|
27
|
+
color: var(--md-sys-color-on-primary);
|
28
|
+
background-color: var(--md-sys-color-primary);
|
29
|
+
}
|
30
|
+
`; }
|
31
|
+
render() {
|
32
|
+
const value = this.value;
|
33
|
+
return html `
|
34
|
+
<div @click=${this.onClick.bind(this)}>
|
35
|
+
<md-icon ?selected=${value == 'W'} data-value="W">arrow_back</md-icon>
|
36
|
+
<md-icon ?selected=${value == 'N'} data-value="N">arrow_upward</md-icon>
|
37
|
+
<md-icon ?selected=${value == 'S'} data-value="S">arrow_downward</md-icon>
|
38
|
+
<md-icon ?selected=${value == 'E'} data-value="E">arrow_forward</md-icon>
|
39
|
+
</div>
|
40
|
+
`;
|
41
|
+
}
|
42
|
+
onClick(e) {
|
43
|
+
e.stopPropagation();
|
44
|
+
if (this.disabled) {
|
45
|
+
return;
|
46
|
+
}
|
47
|
+
const target = e.target;
|
48
|
+
const value = target.getAttribute('data-value');
|
49
|
+
this.value = this.value === value ? undefined : value;
|
50
|
+
this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }));
|
51
|
+
}
|
52
|
+
};
|
53
|
+
__decorate([
|
54
|
+
property({ type: String })
|
55
|
+
], OxInputDirection.prototype, "value", void 0);
|
56
|
+
OxInputDirection = __decorate([
|
57
|
+
customElement('ox-input-direction')
|
58
|
+
], OxInputDirection);
|
59
|
+
export { OxInputDirection };
|
60
|
+
//# sourceMappingURL=ox-input-direction.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ox-input-direction.js","sourceRoot":"","sources":["../../src/ox-input-direction.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,MAAM,mBAAmB,CAAA;AAE3D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAGtC,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,WAAW;aACxC,WAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;GAoBlB,AApBY,CAoBZ;IAID,MAAM;QACJ,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAA;QAExB,OAAO,IAAI,CAAA;oBACK,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;6BACd,KAAK,IAAI,GAAG;6BACZ,KAAK,IAAI,GAAG;6BACZ,KAAK,IAAI,GAAG;6BACZ,KAAK,IAAI,GAAG;;KAEpC,CAAA;IACH,CAAC;IAED,OAAO,CAAC,CAAa;QACnB,CAAC,CAAC,eAAe,EAAE,CAAA;QAEnB,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,OAAM;QACR,CAAC;QAED,MAAM,MAAM,GAAG,CAAC,CAAC,MAAiB,CAAA;QAClC,MAAM,KAAK,GAAG,MAAM,CAAC,YAAY,CAAC,YAAY,CAAW,CAAA;QAEzD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAA;QAErD,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;IACtG,CAAC;;AA5B2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CAAe;AAvB/B,gBAAgB;IAD5B,aAAa,CAAC,oBAAoB,CAAC;GACvB,gBAAgB,CAoD5B","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 } from 'lit/decorators.js'\n\nimport { OxFormField } from './ox-form-field'\n\n@customElement('ox-input-direction')\nexport class OxInputDirection extends OxFormField {\n static styles = css`\n :host {\n --md-icon-size: 1.4em;\n }\n\n div {\n display: flex;\n justify-content: space-between;\n max-width: 140px;\n }\n\n md-icon {\n color: var(--md-sys-color-on-background);\n background-color: var(--md-sys-color-background);\n }\n\n md-icon[selected] {\n color: var(--md-sys-color-on-primary);\n background-color: var(--md-sys-color-primary);\n }\n `\n\n @property({ type: String }) value?: string\n\n render() {\n const value = this.value\n\n return html`\n <div @click=${this.onClick.bind(this)}>\n <md-icon ?selected=${value == 'W'} data-value=\"W\">arrow_back</md-icon>\n <md-icon ?selected=${value == 'N'} data-value=\"N\">arrow_upward</md-icon>\n <md-icon ?selected=${value == 'S'} data-value=\"S\">arrow_downward</md-icon>\n <md-icon ?selected=${value == 'E'} data-value=\"E\">arrow_forward</md-icon>\n </div>\n `\n }\n\n onClick(e: MouseEvent) {\n e.stopPropagation()\n\n if (this.disabled) {\n return\n }\n\n const target = e.target as Element\n const value = target.getAttribute('data-value') as string\n\n this.value = this.value === value ? undefined : value\n\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))\n }\n}\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ox-input-mass-fraction.js","sourceRoot":"","sources":["../../src/ox-input-mass-fraction.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,4BAA4B,CAAA;AACnC,OAAO,iCAAiC,CAAA;AACxC,OAAO,gBAAgB,CAAA;AAEvB,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AACrE,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAA;AAE7C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAE7C,MAAM,MAAM,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;AAW9F;;;;;;;;G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I,CAAC,CAAA;YAC7B,OAAO,GAAG,CAAA;QACZ,CAAC,EAAE,EAAkB,CAAC,CAAA;QAEtB,IAAI,CAAC,mBAAmB,EAAE,CAAA;IAC5B,CAAC;IAED,mBAAmB;QACjB,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;IACtG,CAAC;;AA5R2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yDAAgC;AAC/B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAAyB;AACN;IAA7C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;uDAA4B;AAE9C;IAA1B,QAAQ,CAAC,eAAe,CAAC;oDAAkC;AArHjD,mBAAmB;IAD/B,aAAa,CAAC,wBAAwB,CAAC;GAC3B,mBAAmB,CA8Y/B","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport '@material/web/icon/icon.js'\nimport '@operato/popup/ox-popup-list.js'\nimport './ox-select.js'\n\nimport { css, html, nothing } from 'lit'\nimport { customElement, property, queryAll } from 'lit/decorators.js'\nimport { live } from 'lit/directives/live.js'\n\nimport { ScrollbarStyles } from '@operato/styles'\n\nimport { OxFormField } from './ox-form-field'\n\nconst FLUIDS = ['CH4', 'C2H6', 'C3H8', 'C4H10', 'CO2', 'H2O', 'H2S', 'N2', 'N2O', 'NO2', 'O2']\n\ntype ArrayElement<ArrayType extends readonly unknown[]> = ArrayType extends readonly (infer ElementType)[]\n ? ElementType\n : never\n\ntype FLUID = ArrayElement<typeof FLUIDS>\n\ntype MassFraction = { [key: FLUID]: number }\ntype ArrayedMassFraction = { key: FLUID; value: number }[]\n\n/**\n input component for mass-fraction map\n \n Example:\n \n <ox-input-mass-fraction \n value=${map}\n </ox-input-mass-fraction>\n */\n@customElement('ox-input-mass-fraction')\nexport class OxInputMassFraction extends OxFormField {\n static styles = [\n ScrollbarStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n\n --md-icon-size: var(--fontsize-default, 14px);\n }\n\n [records] {\n flex: 1;\n\n overflow: overlay;\n\n > div {\n display: flex;\n flex-flow: row nowrap;\n gap: var(--mass-fraction-gap, 3px);\n margin-bottom: var(--margin-narrow);\n }\n\n > [nofraction] {\n display: block;\n text-align: center;\n }\n }\n\n [data-record-new] {\n display: flex;\n flex-flow: row nowrap;\n gap: var(--mass-fraction-gap, 3px);\n margin: var(--margin-narrow) 0;\n }\n\n button {\n display: inherit;\n align-self: center;\n border: var(--button-border);\n border-radius: var(--border-radius);\n background-color: var(--button-background-color);\n padding: var(--mass-fraction-button-padding-vertical, 3px) var(--mass-fraction-button-padding-horizontal, 3px);\n color: var(--button-color);\n cursor: pointer;\n\n &:focus,\n &:hover,\n &:active {\n border: var(--button-active-border, 1px solid rgba(0, 0, 0, 0.2));\n background-color: var(--button-background-focus-color);\n color: var(--md-sys-color-primary-container);\n }\n }\n\n input,\n label,\n ox-select {\n border: 0;\n border-bottom: 1px solid rgba(0, 0, 0, 0.15);\n font: var(--input-font);\n color: var(--md-sys-color-on-primary-container);\n min-width: 50px;\n }\n\n input,\n label {\n padding: var(--spacing-tiny);\n }\n\n label {\n text-align: center;\n }\n\n ox-select {\n padding: 0;\n }\n\n [data-key] {\n flex: 2;\n }\n\n [data-value] {\n flex: 1;\n }\n\n input:focus {\n outline: none;\n border-bottom: 1px solid var(--md-sys-color-on-primary-container);\n }\n\n button.hidden {\n opacity: 0;\n cursor: default;\n }\n\n ox-popup-list {\n max-height: 300px;\n overflow: auto;\n left: 0;\n }\n\n [right-end] {\n margin-left: auto;\n }\n\n [hidden] {\n opacity: 0;\n }\n `\n ]\n\n @property({ type: Object }) defaultValue: MassFraction = {}\n @property({ type: Object }) value: MassFraction = {}\n @property({ type: Boolean, attribute: true }) composable: boolean = false\n\n @queryAll('[data-record]') records!: NodeListOf<HTMLElement>\n\n private options = FLUIDS.map(fluid => html`<div option value=${fluid}>${fluid}</div>`)\n private changingNow: boolean = false\n\n firstUpdated() {\n this.renderRoot.addEventListener('change', this._onChange.bind(this))\n }\n\n render() {\n const value = !this.value || typeof this.value !== 'object' ? {} : this.value\n const arrayed = this._toArray(value)\n\n return html`\n <div records>\n <div data-header>\n <label data-key>성분</label>\n <label data-value>체적비(몰분율)</label>\n <button hidden><md-icon>remove</md-icon></button>\n <button hidden><md-icon>remove</md-icon></button>\n ${this.composable ? html` <button hidden><md-icon>remove</md-icon></button>` : nothing}\n </div>\n ${arrayed.length\n ? arrayed.map(\n (item, idx) => html`\n <div data-record>\n <input type=\"text\" data-key .value=${item.key} disabled />\n <input\n type=\"number\"\n data-value\n placeholder=\"fraction\"\n min=\"0\"\n max=\"1\"\n step=\"0.01\"\n .value=${String(item.value)}\n list=\"value-template\"\n ?disabled=${this.disabled}\n />\n ${this.composable\n ? html`\n <button\n class=\"record-action\"\n @click=${(e: MouseEvent) => this._delete(e)}\n tabindex=\"-1\"\n ?disabled=${this.disabled}\n >\n <md-icon>remove</md-icon>\n </button>\n `\n : nothing}\n <button\n class=\"record-action\"\n @click=${(e: MouseEvent) => this._up(e)}\n tabindex=\"-1\"\n ?disabled=${this.disabled || idx === 0}\n >\n <md-icon>arrow_upward</md-icon>\n </button>\n <button\n class=\"record-action\"\n @click=${(e: MouseEvent) => this._down(e)}\n tabindex=\"-1\"\n ?disabled=${this.disabled || idx === arrayed.length - 1}\n >\n <md-icon>arrow_downward</md-icon>\n </button>\n </div>\n `\n )\n : html`<div nofraction>No Fractions</div>`}\n </div>\n\n ${this.disabled\n ? nothing\n : html`\n <div data-record-new>\n ${this.composable\n ? html`\n <ox-select\n data-key\n placeholder=\"Fluid\"\n .value=${live('')}\n @change=${(e: Event) => {\n e.stopPropagation()\n }}\n >\n <ox-popup-list with-search> ${this.options} </ox-popup-list>\n </ox-select>\n\n <input\n type=\"number\"\n data-value\n placeholder=\"proportion\"\n min=\"0\"\n max=\"1\"\n step=\"0.01\"\n value=\"\"\n list=\"value-template\"\n />\n <button class=\"record-action\" @click=${(e: MouseEvent) => this._add()} tabindex=\"-1\">\n <md-icon>add</md-icon>\n </button>\n `\n : nothing}\n <button\n title=\"fill with the values suggested\"\n @click=${() => {\n this.value = { ...this.defaultValue }\n this.dispatchChangeEvent()\n }}\n right-end\n >\n <md-icon>settings_suggest</md-icon>\n </button>\n <button\n title=\"normalize fraction\"\n @click=${() => {\n this._normalize()\n }}\n >\n <md-icon>repartition</md-icon>\n </button>\n </div>\n `}\n `\n }\n\n _onChange(e: Event) {\n if (this.changingNow) {\n return\n }\n\n this.changingNow = true\n\n const input = e.target as HTMLInputElement\n\n const record = (e.target as Element).closest('[data-record],[data-record-new]') as HTMLElement\n\n if (record.hasAttribute('data-record')) {\n this._build()\n } else if (record.hasAttribute('data-record-new') && input.hasAttribute('data-value')) {\n this._add()\n }\n\n this.changingNow = false\n }\n\n _normalize() {\n const fraction: MassFraction = this.value || {}\n const sum = Object.values(fraction).reduce((a, b) => a + b, 0)\n this.value = Object.keys(fraction).reduce((newvalue, key) => {\n newvalue[key] = fraction[key] / sum\n return newvalue\n }, {} as MassFraction)\n\n this.dispatchChangeEvent()\n }\n\n _build(includeNewRecord?: boolean) {\n if (includeNewRecord) {\n var records = this.renderRoot.querySelectorAll('[data-record],[data-record-new]') as NodeListOf<HTMLElement>\n } else {\n var records = this.renderRoot.querySelectorAll('[data-record]') as NodeListOf<HTMLElement>\n }\n\n var newmap: MassFraction = {}\n\n for (var i = 0; i < records.length; i++) {\n var record = records[i]\n\n const key = (record.querySelector('[data-key]') as HTMLInputElement).value\n const inputs = record.querySelectorAll(\n '[data-value]:not([style*=\"display: none\"])'\n ) as NodeListOf<HTMLInputElement>\n\n if (!inputs || inputs.length == 0) {\n continue\n }\n\n var input = inputs[inputs.length - 1]\n\n var value = input.value\n\n if (key) {\n newmap[key] = Number(value) || 0\n }\n }\n\n this.value = newmap\n\n this.dispatchChangeEvent()\n }\n\n /* map아이템들을 template(dom-repeat)용 배열로 변환하는 함수 */\n _toArray(map: MassFraction) {\n var array: ArrayedMassFraction = []\n\n for (var key in map) {\n array.push({\n key: key,\n value: map[key]\n })\n }\n\n return array\n }\n\n _add() {\n this._build(true)\n\n const inputs = this.renderRoot.querySelectorAll(\n '[data-record-new] input:not([style*=\"display: none\"])'\n ) as NodeListOf<HTMLInputElement & { value: any }>\n\n for (var i = 0; i < inputs.length; i++) {\n let input = inputs[i]\n\n if (input.type == 'checkbox') input.checked = false\n else input.value = ''\n }\n\n inputs[0].focus()\n }\n\n _delete(e: MouseEvent) {\n const record = (e.target as Element).closest('[data-record]') as HTMLElement\n\n ;(record!.querySelector('[data-key]') as HTMLInputElement)!.value = ''\n\n this._build()\n }\n\n _up(e: MouseEvent) {\n const record = (e.target as Element).closest('[data-record]') as HTMLElement\n const array = Array.from(this.records)\n const index = array.indexOf(record) - 1\n\n if (index < 0) {\n return\n }\n\n const deleted = array.splice(index, 1)\n array.splice(index + 1, 0, ...deleted)\n\n this.value = array.reduce((sum, record) => {\n const key = (record.querySelector('[data-key]') as HTMLInputElement).value\n const value = (record.querySelector('[data-value]') as HTMLInputElement).value\n\n sum[key] = Number(value) || 0\n return sum\n }, {} as MassFraction)\n\n this.dispatchChangeEvent()\n }\n\n _down(e: MouseEvent) {\n const record = (e.target as Element).closest('[data-record]') as HTMLElement\n const array = Array.from(this.records)\n const index = array.indexOf(record)\n\n if (index > array.length) {\n return\n }\n\n array.splice(index, 1)\n array.splice(index + 1, 0, record)\n\n this.value = array.reduce((sum, record) => {\n const key = (record.querySelector('[data-key]') as HTMLInputElement).value\n const value = (record.querySelector('[data-value]') as HTMLInputElement).value\n\n sum[key] = Number(value) || 0\n return sum\n }, {} as MassFraction)\n\n this.dispatchChangeEvent()\n }\n\n dispatchChangeEvent() {\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"ox-input-mass-fraction.js","sourceRoot":"","sources":["../../src/ox-input-mass-fraction.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,4BAA4B,CAAA;AACnC,OAAO,iCAAiC,CAAA;AACxC,OAAO,gBAAgB,CAAA;AAEvB,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AACrE,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAA;AAE7C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAE7C,MAAM,MAAM,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;AAW9F;;;;;;;;GAQG;AAEI,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,WAAW;IAA7C;;QAkHuB,iBAAY,GAAiB,EAAE,CAAA;QAC/B,UAAK,GAAiB,EAAE,CAAA;QACN,eAAU,GAAY,KAAK,CAAA;QAIjE,YAAO,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAA,qBAAqB,KAAK,IAAI,KAAK,QAAQ,CAAC,CAAA;QAC9E,gBAAW,GAAY,KAAK,CAAA;IAsRtC,CAAC;aA9YQ,WAAM,GAAG;QACd,eAAe;QACf,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;uDAA4B;AAE9C;IAA1B,QAAQ,CAAC,eAAe,CAAC;oDAAkC;AAtHjD,mBAAmB;IAD/B,aAAa,CAAC,wBAAwB,CAAC;GAC3B,mBAAmB,CA+Y/B","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport '@material/web/icon/icon.js'\nimport '@operato/popup/ox-popup-list.js'\nimport './ox-select.js'\n\nimport { css, html, nothing } from 'lit'\nimport { customElement, property, queryAll } from 'lit/decorators.js'\nimport { live } from 'lit/directives/live.js'\n\nimport { ScrollbarStyles } from '@operato/styles'\n\nimport { OxFormField } from './ox-form-field'\n\nconst FLUIDS = ['CH4', 'C2H6', 'C3H8', 'C4H10', 'CO2', 'H2O', 'H2S', 'N2', 'N2O', 'NO2', 'O2']\n\ntype ArrayElement<ArrayType extends readonly unknown[]> = ArrayType extends readonly (infer ElementType)[]\n ? ElementType\n : never\n\ntype FLUID = ArrayElement<typeof FLUIDS>\n\ntype MassFraction = { [key: FLUID]: number }\ntype ArrayedMassFraction = { key: FLUID; value: number }[]\n\n/**\n input component for mass-fraction map\n \n Example:\n \n <ox-input-mass-fraction \n value=${map}\n </ox-input-mass-fraction>\n */\n@customElement('ox-input-mass-fraction')\nexport class OxInputMassFraction extends OxFormField {\n static styles = [\n ScrollbarStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n\n --md-icon-size: var(--fontsize-default, 14px);\n }\n\n [records] {\n flex: 1;\n\n overflow: overlay;\n\n > div {\n display: flex;\n flex-flow: row nowrap;\n gap: var(--mass-fraction-gap, 3px);\n margin-bottom: var(--margin-narrow);\n }\n\n > [nofraction] {\n display: block;\n text-align: center;\n }\n }\n\n [data-record-new] {\n display: flex;\n flex-flow: row nowrap;\n gap: var(--mass-fraction-gap, 3px);\n margin: var(--margin-narrow) 0;\n }\n\n button {\n display: inherit;\n align-self: center;\n border: var(--button-border);\n border-radius: var(--border-radius);\n background-color: var(--button-background-color);\n padding: var(--mass-fraction-button-padding-vertical, 3px) var(--mass-fraction-button-padding-horizontal, 3px);\n color: var(--button-color);\n cursor: pointer;\n\n &:focus,\n &:hover,\n &:active {\n border: var(--button-active-border, 1px solid rgba(0, 0, 0, 0.2));\n background-color: var(--button-background-focus-color);\n color: var(--md-sys-color-primary-container);\n }\n }\n\n input,\n label,\n ox-select {\n border: 0;\n border-bottom: 1px solid rgba(0, 0, 0, 0.15);\n font: var(--input-font);\n color: var(--md-sys-color-on-primary-container);\n min-width: 50px;\n }\n\n input,\n label {\n padding: var(--spacing-tiny);\n }\n\n label {\n text-align: center;\n text-wrap: nowrap;\n }\n\n ox-select {\n padding: 0;\n }\n\n [data-key] {\n flex: 2;\n }\n\n [data-value] {\n flex: 1;\n }\n\n input:focus {\n outline: none;\n border-bottom: 1px solid var(--md-sys-color-on-primary-container);\n }\n\n button.hidden {\n opacity: 0;\n cursor: default;\n }\n\n ox-popup-list {\n max-height: 300px;\n overflow: auto;\n left: 0;\n }\n\n [right-end] {\n margin-left: auto;\n }\n\n [hidden] {\n opacity: 0;\n }\n `\n ]\n\n @property({ type: Object }) defaultValue: MassFraction = {}\n @property({ type: Object }) value: MassFraction = {}\n @property({ type: Boolean, attribute: true }) composable: boolean = false\n\n @queryAll('[data-record]') records!: NodeListOf<HTMLElement>\n\n private options = FLUIDS.map(fluid => html`<div option value=${fluid}>${fluid}</div>`)\n private changingNow: boolean = false\n\n firstUpdated() {\n this.renderRoot.addEventListener('change', this._onChange.bind(this))\n }\n\n render() {\n const value = !this.value || typeof this.value !== 'object' ? {} : this.value\n const arrayed = this._toArray(value)\n\n return html`\n <div records>\n <div data-header>\n <label data-key>성분</label>\n <label data-value>체적비(몰분율)</label>\n <button hidden><md-icon>remove</md-icon></button>\n <button hidden><md-icon>remove</md-icon></button>\n ${this.composable ? html` <button hidden><md-icon>remove</md-icon></button>` : nothing}\n </div>\n ${arrayed.length\n ? arrayed.map(\n (item, idx) => html`\n <div data-record>\n <input type=\"text\" data-key .value=${item.key} disabled />\n <input\n type=\"number\"\n data-value\n placeholder=\"fraction\"\n min=\"0\"\n max=\"1\"\n step=\"0.01\"\n .value=${String(item.value)}\n list=\"value-template\"\n ?disabled=${this.disabled}\n />\n ${this.composable\n ? html`\n <button\n class=\"record-action\"\n @click=${(e: MouseEvent) => this._delete(e)}\n tabindex=\"-1\"\n ?disabled=${this.disabled}\n >\n <md-icon>remove</md-icon>\n </button>\n `\n : nothing}\n <button\n class=\"record-action\"\n @click=${(e: MouseEvent) => this._up(e)}\n tabindex=\"-1\"\n ?disabled=${this.disabled || idx === 0}\n >\n <md-icon>arrow_upward</md-icon>\n </button>\n <button\n class=\"record-action\"\n @click=${(e: MouseEvent) => this._down(e)}\n tabindex=\"-1\"\n ?disabled=${this.disabled || idx === arrayed.length - 1}\n >\n <md-icon>arrow_downward</md-icon>\n </button>\n </div>\n `\n )\n : html`<div nofraction>No Fractions</div>`}\n </div>\n\n ${this.disabled\n ? nothing\n : html`\n <div data-record-new>\n ${this.composable\n ? html`\n <ox-select\n data-key\n placeholder=\"Fluid\"\n .value=${live('')}\n @change=${(e: Event) => {\n e.stopPropagation()\n }}\n >\n <ox-popup-list with-search> ${this.options} </ox-popup-list>\n </ox-select>\n\n <input\n type=\"number\"\n data-value\n placeholder=\"proportion\"\n min=\"0\"\n max=\"1\"\n step=\"0.01\"\n value=\"\"\n list=\"value-template\"\n />\n <button class=\"record-action\" @click=${(e: MouseEvent) => this._add()} tabindex=\"-1\">\n <md-icon>add</md-icon>\n </button>\n `\n : nothing}\n <button\n title=\"fill with the values suggested\"\n @click=${() => {\n this.value = { ...this.defaultValue }\n this.dispatchChangeEvent()\n }}\n right-end\n >\n <md-icon>settings_suggest</md-icon>\n </button>\n <button\n title=\"normalize fraction\"\n @click=${() => {\n this._normalize()\n }}\n >\n <md-icon>repartition</md-icon>\n </button>\n </div>\n `}\n `\n }\n\n _onChange(e: Event) {\n if (this.changingNow) {\n return\n }\n\n this.changingNow = true\n\n const input = e.target as HTMLInputElement\n\n const record = (e.target as Element).closest('[data-record],[data-record-new]') as HTMLElement\n\n if (record.hasAttribute('data-record')) {\n this._build()\n } else if (record.hasAttribute('data-record-new') && input.hasAttribute('data-value')) {\n this._add()\n }\n\n this.changingNow = false\n }\n\n _normalize() {\n const fraction: MassFraction = this.value || {}\n const sum = Object.values(fraction).reduce((a, b) => a + b, 0)\n this.value = Object.keys(fraction).reduce((newvalue, key) => {\n newvalue[key] = fraction[key] / sum\n return newvalue\n }, {} as MassFraction)\n\n this.dispatchChangeEvent()\n }\n\n _build(includeNewRecord?: boolean) {\n if (includeNewRecord) {\n var records = this.renderRoot.querySelectorAll('[data-record],[data-record-new]') as NodeListOf<HTMLElement>\n } else {\n var records = this.renderRoot.querySelectorAll('[data-record]') as NodeListOf<HTMLElement>\n }\n\n var newmap: MassFraction = {}\n\n for (var i = 0; i < records.length; i++) {\n var record = records[i]\n\n const key = (record.querySelector('[data-key]') as HTMLInputElement).value\n const inputs = record.querySelectorAll(\n '[data-value]:not([style*=\"display: none\"])'\n ) as NodeListOf<HTMLInputElement>\n\n if (!inputs || inputs.length == 0) {\n continue\n }\n\n var input = inputs[inputs.length - 1]\n\n var value = input.value\n\n if (key) {\n newmap[key] = Number(value) || 0\n }\n }\n\n this.value = newmap\n\n this.dispatchChangeEvent()\n }\n\n /* map아이템들을 template(dom-repeat)용 배열로 변환하는 함수 */\n _toArray(map: MassFraction) {\n var array: ArrayedMassFraction = []\n\n for (var key in map) {\n array.push({\n key: key,\n value: map[key]\n })\n }\n\n return array\n }\n\n _add() {\n this._build(true)\n\n const inputs = this.renderRoot.querySelectorAll(\n '[data-record-new] input:not([style*=\"display: none\"])'\n ) as NodeListOf<HTMLInputElement & { value: any }>\n\n for (var i = 0; i < inputs.length; i++) {\n let input = inputs[i]\n\n if (input.type == 'checkbox') input.checked = false\n else input.value = ''\n }\n\n inputs[0].focus()\n }\n\n _delete(e: MouseEvent) {\n const record = (e.target as Element).closest('[data-record]') as HTMLElement\n\n ;(record!.querySelector('[data-key]') as HTMLInputElement)!.value = ''\n\n this._build()\n }\n\n _up(e: MouseEvent) {\n const record = (e.target as Element).closest('[data-record]') as HTMLElement\n const array = Array.from(this.records)\n const index = array.indexOf(record) - 1\n\n if (index < 0) {\n return\n }\n\n const deleted = array.splice(index, 1)\n array.splice(index + 1, 0, ...deleted)\n\n this.value = array.reduce((sum, record) => {\n const key = (record.querySelector('[data-key]') as HTMLInputElement).value\n const value = (record.querySelector('[data-value]') as HTMLInputElement).value\n\n sum[key] = Number(value) || 0\n return sum\n }, {} as MassFraction)\n\n this.dispatchChangeEvent()\n }\n\n _down(e: MouseEvent) {\n const record = (e.target as Element).closest('[data-record]') as HTMLElement\n const array = Array.from(this.records)\n const index = array.indexOf(record)\n\n if (index > array.length) {\n return\n }\n\n array.splice(index, 1)\n array.splice(index + 1, 0, record)\n\n this.value = array.reduce((sum, record) => {\n const key = (record.querySelector('[data-key]') as HTMLInputElement).value\n const value = (record.querySelector('[data-value]') as HTMLInputElement).value\n\n sum[key] = Number(value) || 0\n return sum\n }, {} as MassFraction)\n\n this.dispatchChangeEvent()\n }\n\n dispatchChangeEvent() {\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))\n }\n}\n"]}
|
@@ -32,13 +32,13 @@ let OxInputSelectButtons = class OxInputSelectButtons extends OxFormField {
|
|
32
32
|
data-value=${value}
|
33
33
|
label=${display}
|
34
34
|
?selected=${values.includes(value)}
|
35
|
-
@
|
35
|
+
@tap=${(e) => !this.disabled && this.onTap(e)}
|
36
36
|
></md-filter-chip>
|
37
37
|
`)}
|
38
38
|
</md-chip-set>
|
39
39
|
`;
|
40
40
|
}
|
41
|
-
|
41
|
+
onTap(e) {
|
42
42
|
e.stopPropagation();
|
43
43
|
const target = e.target;
|
44
44
|
const value = target.getAttribute('data-value');
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ox-input-select-buttons.js","sourceRoot":"","sources":["../../src/ox-input-select-buttons.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,oCAAoC,CAAA;AAC3C,OAAO,iCAAiC,CAAA;AAExC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE3D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAMtC,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,WAAW;IAA9C;;QAUsB,UAAK,GAAkC,EAAE,CAAA;QACzC,YAAO,GAAa,EAAE,CAAA;QACpB,aAAQ,GAAY,KAAK,CAAA;IA4CxD,CAAC;aAvDQ,WAAM,GAAG,GAAG,CAAA;;;;;;;GAOlB,AAPY,CAOZ;IAMD,MAAM;QACJ,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QAC7D,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,KAAK,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;QAE3G,OAAO,IAAI,CAAA;;UAEL,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,GAAG,CACnB,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,IAAI,CAAA;;2BAEX,KAAK;sBACV,OAAO;0BACH,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;
|
1
|
+
{"version":3,"file":"ox-input-select-buttons.js","sourceRoot":"","sources":["../../src/ox-input-select-buttons.ts"],"names":[],"mappings":"AAAA;;GAEG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;qDAAuB;AACpB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;sDAA0B;AAZ3C,oBAAoB;IADhC,aAAa,CAAC,yBAAyB,CAAC;GAC5B,oBAAoB,CAwDhC","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport '@material/web/chips/filter-chip.js'\nimport '@material/web/chips/chip-set.js'\n\nimport { css, html } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { OxFormField } from './ox-form-field'\nimport { MdFilterChip } from '@material/web/chips/filter-chip.js'\n\ntype Option = { display: string; value: string }\n\n@customElement('ox-input-select-buttons')\nexport class OxInputSelectButtons extends OxFormField {\n static styles = css`\n :host {\n display: flex;\n flex-flow: row;\n flex-wrap: wrap;\n gap: var(--spacing-medium);\n }\n `\n\n @property({ type: Array }) value: string[] | string | undefined = []\n @property({ type: Array }) options: Option[] = []\n @property({ type: Boolean }) multiple: boolean = false\n\n render() {\n const options = this.options.filter(option => !!option.value)\n const values = this.value instanceof Array ? this.value : typeof this.value == 'string' ? [this.value] : []\n\n return html`\n <md-chip-set>\n ${(options || []).map(\n ({ display, value }) => html`\n <md-filter-chip\n data-value=${value}\n label=${display}\n ?selected=${values.includes(value)}\n @tap=${(e: MouseEvent | TouchEvent) => !this.disabled && this.onTap(e)}\n ></md-filter-chip>\n `\n )}\n </md-chip-set>\n `\n }\n\n onTap(e: MouseEvent | TouchEvent) {\n e.stopPropagation()\n\n const target = e.target as MdFilterChip\n const value = target.getAttribute('data-value') as string\n\n if (this.multiple) {\n const values = this.value instanceof Array ? this.value : typeof this.value == 'string' ? [this.value] : []\n\n const idx = (this.value || []).indexOf(value)\n if (idx != -1) {\n values.splice(idx, 1)\n } else {\n values.push(value)\n }\n this.value = [...values]\n } else {\n this.value = this.value === value ? undefined : value\n }\n\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))\n }\n}\n"]}
|
@@ -2,7 +2,6 @@
|
|
2
2
|
* @license Copyright © HatioLab Inc. All rights reserved.
|
3
3
|
*/
|
4
4
|
import '@material/web/icon/icon.js';
|
5
|
-
import { PropertyValues } from 'lit';
|
6
5
|
import { OxPopupList } from '@operato/popup';
|
7
6
|
import { OxFormField } from './ox-form-field';
|
8
7
|
export declare class OxInputUnitNumber extends OxFormField {
|
@@ -13,7 +12,6 @@ export declare class OxInputUnitNumber extends OxFormField {
|
|
13
12
|
input: HTMLInputElement;
|
14
13
|
popup: OxPopupList;
|
15
14
|
render(): import("lit-html").TemplateResult<1>;
|
16
|
-
updated(changes: PropertyValues<this>): void;
|
17
15
|
_onChangeValue(e: Event): void;
|
18
16
|
_toUserUnit(stdValue: string | number | undefined): number | undefined;
|
19
17
|
_toUserUnitByRate(stdValue: string | number | undefined, converterRate: number): number;
|
@@ -208,7 +208,7 @@ let OxInputUnitNumber = class OxInputUnitNumber extends OxFormField {
|
|
208
208
|
position: relative;
|
209
209
|
margin-left: var(--margin-narrow);
|
210
210
|
font: var(--label-font);
|
211
|
-
color: var(--label-color);
|
211
|
+
color: var(--label-color, var(--md-sys-color-on-surface));
|
212
212
|
min-width: 24px;
|
213
213
|
}
|
214
214
|
|
@@ -251,6 +251,9 @@ let OxInputUnitNumber = class OxInputUnitNumber extends OxFormField {
|
|
251
251
|
.value=${userUnit}
|
252
252
|
@select=${(e) => {
|
253
253
|
this.userUnit = e.detail;
|
254
|
+
this.dispatchEvent(new CustomEvent('user-unit-change', {
|
255
|
+
detail: this.userUnit
|
256
|
+
}));
|
254
257
|
}}
|
255
258
|
>
|
256
259
|
<div option value=${this.stdUnit}>${this.stdUnit}</div>
|
@@ -260,11 +263,6 @@ let OxInputUnitNumber = class OxInputUnitNumber extends OxFormField {
|
|
260
263
|
</div>
|
261
264
|
`;
|
262
265
|
}
|
263
|
-
updated(changes) {
|
264
|
-
// if (changes.has('stdUnit')) {
|
265
|
-
// this.userUnit = this.userUnit || this.stdUnit
|
266
|
-
// }
|
267
|
-
}
|
268
266
|
_onChangeValue(e) {
|
269
267
|
this.value = this._toStdUnit(this.input.value);
|
270
268
|
this.dispatchEvent(new CustomEvent('change', {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ox-input-unit-number.js","sourceRoot":"","sources":["../../src/ox-input-unit-number.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,4BAA4B,CAAA;AAEnC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAA;AAIxD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAE7C,MAAM,YAAY,GAA+E;IAC/F,EAAE,EAAE;QACF,EAAE,EAAE,OAAO;QACX,CAAC,EAAE,IAAI;QACP,GAAG,EAAE,KAAK;KACX;IACD,GAAG,EAAE;QACH,MAAM,EAAE,GAAG,GAAG,IAAI,CAAC,EAAE;KACtB;IACD,GAAG,EAAE;QACH,IAAI,EAAE,IAAI;QACV,GAAG,EAAE,CAAC,GAAG,EAAE;QACX,EAAE,EAAE,CAAC,GAAG,IAAI;QACZ,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,GAAG,EAAE,CAAC;QACpB,IAAI,EAAE,CAAC,GAAG,CAAC,IAAI,GAAG,EAAE,GAAG,GAAG,CAAC;KAC5B;IACD,CAAC,EAAE;QACD,EAAE,EAAE,IAAI;QACR,EAAE,EAAE,GAAG;QACP,IAAI,EAAE,QAAQ;KACf;IACD,OAAO,EAAE;QACP,SAAS,EAAE,CAAC;QACZ,QAAQ,EAAE,IAAI;KACf;IACD,EAAE,EAAE;QACF,GAAG,EAAE,OAAO;QACZ,GAAG,EAAE,IAAI;KACV;IACD,EAAE,EAAE;QACF,GAAG,EAAE,OAAO;QACZ,CAAC,EAAE,IAAI;QACP,EAAE,EAAE,OAAO;K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,SAAS,EAAE,cAA2C,CAAC,CAAA;QAC1F,CAAC;IACH,CAAC;IAED,gBAAgB,CAAC,SAAsC,EAAE,aAAqB;QAC5E,OAAO,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,aAAa,CAAA;IACjF,CAAC;IAED,oBAAoB,CAAC,SAAsC,EAAE,kBAA6C;QACxG,OAAO,kBAAkB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAA;IACjD,CAAC;;AAzH2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sDAAqB;AACG;IAAlD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;kDAAiB;AACf;IAAnD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;mDAAkB;AAErD;IAAf,KAAK,CAAC,OAAO,CAAC;gDAAyB;AAChB;IAAvB,KAAK,CAAC,eAAe,CAAC;gDAAoB;AAhEhC,iBAAiB;IAD7B,aAAa,CAAC,sBAAsB,CAAC;GACzB,iBAAiB,CAqL7B","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport '@material/web/icon/icon.js'\n\nimport { css, html, PropertyValues } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\nimport { ifDefined } from 'lit/directives/if-defined.js'\n\nimport { OxPopupList } from '@operato/popup'\n\nimport { OxFormField } from './ox-form-field'\n\nconst UNIT_SYSTEMS: { [unit: string]: { [unit: string]: number | ((v: number) => number)[] } } = {\n kg: {\n mg: 1000000,\n g: 1000,\n ton: 0.001\n },\n rad: {\n degree: 180 / Math.PI\n },\n sec: {\n msec: 1000,\n min: 1 / 60,\n hr: 1 / 3600,\n day: 1 / (3600 * 24),\n year: 1 / (3600 * 24 * 365)\n },\n m: {\n mm: 1000,\n cm: 100,\n inch: 39.37008\n },\n 'g/mol': {\n 'kg/kmol': 1,\n 'g/kmol': 1000\n },\n m2: {\n mm2: 1000000,\n cm2: 1000\n },\n m3: {\n cm3: 1000000,\n L: 1000,\n mL: 1000000\n },\n 'kg/m3': {\n 'g/m3': 1000,\n 'g/L': 1,\n 'g/cm3': 0.001,\n 'kg/L': 0.001,\n 'g/mL': 0.001\n },\n 'm/sec': {\n 'm/min': 60,\n 'm/hr': 3600,\n 'cm/sec': 100,\n 'cm/min': 6000,\n 'cm/hr': 360000\n },\n N: {\n kN: 0.001,\n kgf: 0.101971621\n },\n Pa: {\n atm: 1 / 101325,\n bar: 1 / 100000,\n 'kgf/cm2': 1 / 9.80665 / 10000,\n MPa: 1 / 1000000,\n kPa: 1 / 1000,\n psi: 1 / 6894.76,\n mmH2O: 1 / 9.80665,\n mmHg: 1 / 133.32\n },\n 'kg/sec': {\n 'kg/min': 60,\n 'kg/hr': 3600,\n 'ton/hr': 3.6,\n 'ton/year': (60 * 60 * 24 * 365) / 1000\n },\n 'kg/m2/sec': {\n 'kg/m2/min': 60,\n 'kg/m2/hr': 3600\n },\n 'mol/sec': {\n 'kmol/sec': 1 / 1000\n },\n 'mol/m2/sec': {\n 'kmol/m2/sec': 1 / 1000\n },\n 'Sm3/sec': {\n 'Sm3/hr': 3600,\n 'Sm3/min': 60,\n 'SL/min': 60000,\n 'SL/sec': 1000,\n 'Scm3/min': 60000000,\n 'Scm3/sec': 1000000\n },\n 'Nm3/sec': {\n 'Nm3/hr': 3600,\n 'Nm3/min': 60,\n 'NL/min': 60000,\n 'NL/sec': 1000,\n 'Ncm3/min': 60000000,\n 'Ncm3/sec': 1000000\n },\n 'Am3/sec': {\n 'Am3/hr': 3600,\n 'Am3/min': 60,\n 'AL/min': 60000,\n 'AL/sec': 1000,\n 'Acm3/min': 60000000,\n 'Acm3/sec': 1000000\n },\n J: {\n kJ: 1 / 1000,\n MJ: 1 / 1000000,\n cal: 1 / 4.184,\n kcal: 1 / 4.184 / 1000\n },\n W: {\n kW: 1 / 1000,\n MW: 1 / 1000000,\n 'kcal/hr': 859.85 / 1000,\n hp: 1 / 745.7\n },\n 'W/m2': {\n 'kW/m2': 1 / 1000,\n 'W/cm2': 1 / 10000,\n 'kW/cm2': 1 / 10000000\n },\n 'J/kg': {\n 'kJ/kg': 1 / 1000,\n 'cal/g': 1 / 4.184 / 1000,\n 'cal/kg': 1 / 4.184,\n 'kcal/kg': 1 / 4.184 / 1000\n },\n 'J/kg/K': {\n 'kJ/kg/K': 1 / 1000,\n 'cal/kg/K': 1 / 4.184,\n 'kcal/kg/K': 1 / 4.184 / 1000,\n 'cal/g/K': 1 / 4.184 / 1000\n },\n 'W/m/K': {\n 'kW/m/K': 1 / 1000,\n 'W/cm/K': 1 / 100,\n 'kW/cm/K': 1 / 100 / 1000\n },\n 'W/m2/K': {\n 'kW/m2/K': 1 / 1000,\n 'kcal/hr/m2/oC': 1 / 1.163\n },\n 'N sec/m2': {\n 'Pa sec': 1,\n 'mPa sec': 1000,\n 'kg/m/sec': 1,\n 'g/cm/sec': 10,\n P: 10,\n cP: 1000\n },\n 'm2 oC/W': {\n 'm2 oC/kW': 1000\n },\n '%': {},\n ppm: {},\n K: {\n '°C': [(v: number) => v - 273.15, (v: number) => v + 273.15]\n }\n}\n\n@customElement('ox-input-unit-number')\nexport class OxInputUnitNumber extends OxFormField {\n static styles = [\n css`\n :host {\n display: flex;\n flex-direction: row;\n align-items: center;\n\n --md-icon-size: var(--fontsize-default, 14px);\n }\n\n input {\n flex: 1;\n border: 0;\n border-bottom: 1px solid rgba(0, 0, 0, 0.15);\n padding: var(--spacing-tiny);\n font: var(--input-font);\n color: var(--md-sys-color-on-primary-container);\n min-width: 40px;\n }\n\n input:focus {\n outline: none;\n border-bottom: 1px solid var(--md-sys-color-on-primary-container);\n }\n\n input::-webkit-outer-spin-button,\n input::-webkit-inner-spin-button {\n -webkit-appearance: none;\n margin: 0;\n }\n\n input[type='number'] {\n text-align: right;\n -moz-appearance: textfield;\n }\n\n #unit {\n flex: 1;\n display: flex;\n align-items: center;\n position: relative;\n margin-left: var(--margin-narrow);\n font: var(--label-font);\n color: var(--label-color);\n min-width: 24px;\n }\n\n md-icon {\n color: var(--md-sys-color-on-primary-container, #3c3938);\n margin-left: auto;\n }\n\n ox-popup-list {\n right: 0;\n }\n `\n ]\n\n @property({ type: String }) placeholder?: string\n @property({ type: String, attribute: 'std-unit' }) stdUnit!: string\n @property({ type: String, attribute: 'user-unit' }) userUnit?: string\n\n @query('input') input!: HTMLInputElement\n @query('ox-popup-list') popup!: OxPopupList\n\n render() {\n const userUnit = this.userUnit || this.stdUnit\n const units = (UNIT_SYSTEMS[this.stdUnit] && Object.keys(UNIT_SYSTEMS[this.stdUnit])) || []\n\n return html`\n <input\n type=\"number\"\n .value=${this._toUserUnit(this.value)}\n placeholder=${ifDefined(this.placeholder)}\n @change=${(e: Event) => this._onChangeValue(e)}\n ?disabled=${this.disabled}\n />\n <div\n id=\"unit\"\n @click=${(e: Event) => {\n if (this.disabled) {\n return\n }\n\n const target = e.currentTarget as HTMLElement\n this.popup.open({\n right: 0,\n top: target.clientTop + target.offsetHeight\n })\n }}\n >\n ${userUnit}\n <ox-popup-list\n .value=${userUnit}\n @select=${(e: CustomEvent) => {\n this.userUnit = e.detail\n }}\n >\n <div option value=${this.stdUnit}>${this.stdUnit}</div>\n ${units.map(unit => html`<div option value=${unit}>${unit}</div>`)}\n </ox-popup-list>\n <md-icon>expand_more</md-icon>\n </div>\n `\n }\n\n updated(changes: PropertyValues<this>) {\n // if (changes.has('stdUnit')) {\n // this.userUnit = this.userUnit || this.stdUnit\n // }\n }\n\n _onChangeValue(e: Event) {\n this.value = this._toStdUnit(this.input.value)\n\n this.dispatchEvent(\n new CustomEvent('change', {\n bubbles: true,\n composed: true,\n detail: this.value\n })\n )\n }\n\n _toUserUnit(stdValue: string | number | undefined) {\n if (!this.userUnit) {\n return\n }\n\n if (this.userUnit === this.stdUnit) {\n return Number(stdValue)\n }\n\n const converterValue = UNIT_SYSTEMS[this.stdUnit][this.userUnit]\n\n if (!converterValue) {\n delete this.userUnit\n return\n }\n\n if (typeof converterValue === 'number') {\n return this._toUserUnitByRate(stdValue, converterValue || 1)\n } /* should be converter function array */ else {\n return this._toUserUnitByFunction(stdValue, converterValue as ((v: number) => number)[])\n }\n }\n\n _toUserUnitByRate(stdValue: string | number | undefined, converterRate: number) {\n return Number(stdValue) * converterRate\n }\n\n _toUserUnitByFunction(stdValue: string | number | undefined, converterFunctions: ((v: number) => number)[]) {\n return converterFunctions[0](Number(stdValue))\n }\n\n _toStdUnit(userValue: string | number | undefined) {\n if (!this.userUnit) {\n return\n }\n\n if (this.userUnit === this.stdUnit) {\n return Number(userValue)\n }\n\n const converterValue = UNIT_SYSTEMS[this.stdUnit][this.userUnit]\n\n if (typeof converterValue === 'number') {\n return this._toStdUnitByRate(userValue, converterValue || 1)\n } /* should be converter function array */ else {\n return this._toStdUnitByFunction(userValue, converterValue as ((v: number) => number)[])\n }\n }\n\n _toStdUnitByRate(userValue: string | number | undefined, converterRate: number) {\n return isNaN(Number(userValue)) ? undefined : Number(userValue) / converterRate\n }\n\n _toStdUnitByFunction(userValue: string | number | undefined, converterFunctions: ((v: number) => number)[]) {\n return converterFunctions[1](Number(userValue))\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"ox-input-unit-number.js","sourceRoot":"","sources":["../../src/ox-input-unit-number.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,4BAA4B,CAAA;AAEnC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAA;AAIxD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAE7C,MAAM,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AC;sDAAqB;AACG;IAAlD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;kDAAiB;AACf;IAAnD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;mDAAkB;AAErD;IAAf,KAAK,CAAC,OAAO,CAAC;gDAAyB;AAChB;IAAvB,KAAK,CAAC,eAAe,CAAC;gDAAoB;AAhEhC,iBAAiB;IAD7B,aAAa,CAAC,sBAAsB,CAAC;GACzB,iBAAiB,CAoL7B","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport '@material/web/icon/icon.js'\n\nimport { css, html, PropertyValues } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\nimport { ifDefined } from 'lit/directives/if-defined.js'\n\nimport { OxPopupList } from '@operato/popup'\n\nimport { OxFormField } from './ox-form-field'\n\nconst UNIT_SYSTEMS: { [unit: string]: { [unit: string]: number | ((v: number) => number)[] } } = {\n kg: {\n mg: 1000000,\n g: 1000,\n ton: 0.001\n },\n rad: {\n degree: 180 / Math.PI\n },\n sec: {\n msec: 1000,\n min: 1 / 60,\n hr: 1 / 3600,\n day: 1 / (3600 * 24),\n year: 1 / (3600 * 24 * 365)\n },\n m: {\n mm: 1000,\n cm: 100,\n inch: 39.37008\n },\n 'g/mol': {\n 'kg/kmol': 1,\n 'g/kmol': 1000\n },\n m2: {\n mm2: 1000000,\n cm2: 1000\n },\n m3: {\n cm3: 1000000,\n L: 1000,\n mL: 1000000\n },\n 'kg/m3': {\n 'g/m3': 1000,\n 'g/L': 1,\n 'g/cm3': 0.001,\n 'kg/L': 0.001,\n 'g/mL': 0.001\n },\n 'm/sec': {\n 'm/min': 60,\n 'm/hr': 3600,\n 'cm/sec': 100,\n 'cm/min': 6000,\n 'cm/hr': 360000\n },\n N: {\n kN: 0.001,\n kgf: 0.101971621\n },\n Pa: {\n atm: 1 / 101325,\n bar: 1 / 100000,\n 'kgf/cm2': 1 / 9.80665 / 10000,\n MPa: 1 / 1000000,\n kPa: 1 / 1000,\n psi: 1 / 6894.76,\n mmH2O: 1 / 9.80665,\n mmHg: 1 / 133.32\n },\n 'kg/sec': {\n 'kg/min': 60,\n 'kg/hr': 3600,\n 'ton/hr': 3.6,\n 'ton/year': (60 * 60 * 24 * 365) / 1000\n },\n 'kg/m2/sec': {\n 'kg/m2/min': 60,\n 'kg/m2/hr': 3600\n },\n 'mol/sec': {\n 'kmol/sec': 1 / 1000\n },\n 'mol/m2/sec': {\n 'kmol/m2/sec': 1 / 1000\n },\n 'Sm3/sec': {\n 'Sm3/hr': 3600,\n 'Sm3/min': 60,\n 'SL/min': 60000,\n 'SL/sec': 1000,\n 'Scm3/min': 60000000,\n 'Scm3/sec': 1000000\n },\n 'Nm3/sec': {\n 'Nm3/hr': 3600,\n 'Nm3/min': 60,\n 'NL/min': 60000,\n 'NL/sec': 1000,\n 'Ncm3/min': 60000000,\n 'Ncm3/sec': 1000000\n },\n 'Am3/sec': {\n 'Am3/hr': 3600,\n 'Am3/min': 60,\n 'AL/min': 60000,\n 'AL/sec': 1000,\n 'Acm3/min': 60000000,\n 'Acm3/sec': 1000000\n },\n J: {\n kJ: 1 / 1000,\n MJ: 1 / 1000000,\n cal: 1 / 4.184,\n kcal: 1 / 4.184 / 1000\n },\n W: {\n kW: 1 / 1000,\n MW: 1 / 1000000,\n 'kcal/hr': 859.85 / 1000,\n hp: 1 / 745.7\n },\n 'W/m2': {\n 'kW/m2': 1 / 1000,\n 'W/cm2': 1 / 10000,\n 'kW/cm2': 1 / 10000000\n },\n 'J/kg': {\n 'kJ/kg': 1 / 1000,\n 'cal/g': 1 / 4.184 / 1000,\n 'cal/kg': 1 / 4.184,\n 'kcal/kg': 1 / 4.184 / 1000\n },\n 'J/kg/K': {\n 'kJ/kg/K': 1 / 1000,\n 'cal/kg/K': 1 / 4.184,\n 'kcal/kg/K': 1 / 4.184 / 1000,\n 'cal/g/K': 1 / 4.184 / 1000\n },\n 'W/m/K': {\n 'kW/m/K': 1 / 1000,\n 'W/cm/K': 1 / 100,\n 'kW/cm/K': 1 / 100 / 1000\n },\n 'W/m2/K': {\n 'kW/m2/K': 1 / 1000,\n 'kcal/hr/m2/oC': 1 / 1.163\n },\n 'N sec/m2': {\n 'Pa sec': 1,\n 'mPa sec': 1000,\n 'kg/m/sec': 1,\n 'g/cm/sec': 10,\n P: 10,\n cP: 1000\n },\n 'm2 oC/W': {\n 'm2 oC/kW': 1000\n },\n '%': {},\n ppm: {},\n K: {\n '°C': [(v: number) => v - 273.15, (v: number) => v + 273.15]\n }\n}\n\n@customElement('ox-input-unit-number')\nexport class OxInputUnitNumber extends OxFormField {\n static styles = [\n css`\n :host {\n display: flex;\n flex-direction: row;\n align-items: center;\n\n --md-icon-size: var(--fontsize-default, 14px);\n }\n\n input {\n flex: 1;\n border: 0;\n border-bottom: 1px solid rgba(0, 0, 0, 0.15);\n padding: var(--spacing-tiny);\n font: var(--input-font);\n color: var(--md-sys-color-on-primary-container);\n min-width: 40px;\n }\n\n input:focus {\n outline: none;\n border-bottom: 1px solid var(--md-sys-color-on-primary-container);\n }\n\n input::-webkit-outer-spin-button,\n input::-webkit-inner-spin-button {\n -webkit-appearance: none;\n margin: 0;\n }\n\n input[type='number'] {\n text-align: right;\n -moz-appearance: textfield;\n }\n\n #unit {\n flex: 1;\n display: flex;\n align-items: center;\n position: relative;\n margin-left: var(--margin-narrow);\n font: var(--label-font);\n color: var(--label-color, var(--md-sys-color-on-surface));\n min-width: 24px;\n }\n\n md-icon {\n color: var(--md-sys-color-on-primary-container, #3c3938);\n margin-left: auto;\n }\n\n ox-popup-list {\n right: 0;\n }\n `\n ]\n\n @property({ type: String }) placeholder?: string\n @property({ type: String, attribute: 'std-unit' }) stdUnit!: string\n @property({ type: String, attribute: 'user-unit' }) userUnit?: string\n\n @query('input') input!: HTMLInputElement\n @query('ox-popup-list') popup!: OxPopupList\n\n render() {\n const userUnit = this.userUnit || this.stdUnit\n const units = (UNIT_SYSTEMS[this.stdUnit] && Object.keys(UNIT_SYSTEMS[this.stdUnit])) || []\n\n return html`\n <input\n type=\"number\"\n .value=${this._toUserUnit(this.value)}\n placeholder=${ifDefined(this.placeholder)}\n @change=${(e: Event) => this._onChangeValue(e)}\n ?disabled=${this.disabled}\n />\n <div\n id=\"unit\"\n @click=${(e: Event) => {\n if (this.disabled) {\n return\n }\n\n const target = e.currentTarget as HTMLElement\n this.popup.open({\n right: 0,\n top: target.clientTop + target.offsetHeight\n })\n }}\n >\n ${userUnit}\n <ox-popup-list\n .value=${userUnit}\n @select=${(e: CustomEvent) => {\n this.userUnit = e.detail\n this.dispatchEvent(\n new CustomEvent('user-unit-change', {\n detail: this.userUnit\n })\n )\n }}\n >\n <div option value=${this.stdUnit}>${this.stdUnit}</div>\n ${units.map(unit => html`<div option value=${unit}>${unit}</div>`)}\n </ox-popup-list>\n <md-icon>expand_more</md-icon>\n </div>\n `\n }\n\n _onChangeValue(e: Event) {\n this.value = this._toStdUnit(this.input.value)\n\n this.dispatchEvent(\n new CustomEvent('change', {\n bubbles: true,\n composed: true,\n detail: this.value\n })\n )\n }\n\n _toUserUnit(stdValue: string | number | undefined) {\n if (!this.userUnit) {\n return\n }\n\n if (this.userUnit === this.stdUnit) {\n return Number(stdValue)\n }\n\n const converterValue = UNIT_SYSTEMS[this.stdUnit][this.userUnit]\n\n if (!converterValue) {\n delete this.userUnit\n return\n }\n\n if (typeof converterValue === 'number') {\n return this._toUserUnitByRate(stdValue, converterValue || 1)\n } /* should be converter function array */ else {\n return this._toUserUnitByFunction(stdValue, converterValue as ((v: number) => number)[])\n }\n }\n\n _toUserUnitByRate(stdValue: string | number | undefined, converterRate: number) {\n return Number(stdValue) * converterRate\n }\n\n _toUserUnitByFunction(stdValue: string | number | undefined, converterFunctions: ((v: number) => number)[]) {\n return converterFunctions[0](Number(stdValue))\n }\n\n _toStdUnit(userValue: string | number | undefined) {\n if (!this.userUnit) {\n return\n }\n\n if (this.userUnit === this.stdUnit) {\n return Number(userValue)\n }\n\n const converterValue = UNIT_SYSTEMS[this.stdUnit][this.userUnit]\n\n if (typeof converterValue === 'number') {\n return this._toStdUnitByRate(userValue, converterValue || 1)\n } /* should be converter function array */ else {\n return this._toStdUnitByFunction(userValue, converterValue as ((v: number) => number)[])\n }\n }\n\n _toStdUnitByRate(userValue: string | number | undefined, converterRate: number) {\n return isNaN(Number(userValue)) ? undefined : Number(userValue) / converterRate\n }\n\n _toStdUnitByFunction(userValue: string | number | undefined, converterFunctions: ((v: number) => number)[]) {\n return converterFunctions[1](Number(userValue))\n }\n}\n"]}
|
@@ -54,7 +54,7 @@ let OxInputWorkShift = class OxInputWorkShift extends OxFormField {
|
|
54
54
|
}
|
55
55
|
[data-header] span {
|
56
56
|
font: var(--label-font);
|
57
|
-
color: var(--label-color);
|
57
|
+
color: var(--label-color, var(--md-sys-color-on-surface));
|
58
58
|
text-transform: var(--label-text-transform);
|
59
59
|
text-align: center;
|
60
60
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ox-input-work-shift.js","sourceRoot":"","sources":["../../src/ox-input-work-shift.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE3D,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,eAAe,CAAA;AAE9C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAIhD;;;;;;;;EAQE;AAIK,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,WAAW;IAA1C;;QAmFsB,UAAK,GAAgB,EAAE,CAAA;QAE1C,iBAAY,GAAY,KAAK,CAAA;IAmLvC,CAAC;aAvQQ,WAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AC,qBAAqB,CAAC;GACxB,gBAAgB,CAwQ5B","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport { css, html, nothing } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { localized, msg } from '@lit/localize'\n\nimport { OxFormField } from './ox-form-field.js'\n\ntype WorkShift = { name: string; fromDate: number; fromTime: string; toDate: number; toTime: string }\n\n/**\nwork-shift array value editor element\n\nExample:\n\n <ox-input-work-shift\n .value=${value}\n </ox-input-work-shift>\n*/\n\n@localized()\n@customElement('ox-input-work-shift')\nexport class OxInputWorkShift extends OxFormField {\n static styles = css`\n :host {\n display: flex;\n flex-direction: column;\n\n width: 100%;\n overflow: hidden;\n\n --md-icon-size: var(--fontsize-default, 14px);\n }\n\n div {\n display: flex;\n flex-flow: row nowrap;\n gap: var(--spacing-medium);\n }\n\n empty-element {\n width: 34px;\n text-align: center;\n }\n\n input,\n select,\n span {\n flex: 1;\n }\n [data-header] {\n background-color: rgba(var(--md-sys-color-on-primary-container-rgb), 0.05);\n padding: var(--padding-narrow);\n }\n [data-header] span {\n font: var(--label-font);\n color: var(--label-color);\n text-transform: var(--label-text-transform);\n text-align: center;\n }\n [data-record] {\n margin-bottom: var(--margin-narrow);\n }\n input,\n select {\n border: 0;\n border-bottom: 1px solid rgba(0, 0, 0, 0.15);\n padding: var(--spacing-tiny);\n font: var(--input-font);\n color: var(--md-sys-color-on-primary-container);\n\n max-height: 35px;\n }\n input:focus,\n select:focus {\n outline: none;\n border-bottom: 1px solid var(--md-sys-color-on-primary-container);\n }\n\n input:required:invalid {\n border: 1px dashed red;\n }\n\n button {\n border: var(--button-border);\n border-radius: var(--border-radius);\n background-color: var(--button-background-color);\n padding: var(--padding-narrow) var(--padding-default);\n line-height: 0.8;\n color: var(--button-color);\n cursor: pointer;\n }\n button:focus,\n button:hover,\n button:active {\n border: var(--button-activ-border);\n background-color: var(--button-background-focus-color);\n color: var(--md-sys-color-primary-container);\n }\n\n [placeholder='value'] {\n flex: 2;\n }\n `\n\n @property({ type: Array }) value: WorkShift[] = []\n\n private _changingNow: boolean = false\n\n firstUpdated() {\n this.renderRoot.addEventListener('change', this._onChange.bind(this))\n }\n\n render() {\n const workshifts = this.value || []\n\n return html`\n <div data-header>\n <span>${msg('name')}</span>\n <span>${msg('from date')}</span>\n <span>${msg('from time')}</span>\n <span>${msg('to date')}</span>\n <span>${msg('to time')}</span>\n <empty-element></empty-element>\n </div>\n\n ${workshifts.map(\n item => html`\n <div data-record>\n <input type=\"text\" data-name .value=${item.name} required ?disabled=${this.disabled} />\n\n <select data-from-date .value=${String(item.fromDate || 0)} ?disabled=${this.disabled}>\n <option value=\"-1\">${msg('The day before')}</option>\n <option value=\"0\">${msg('The day')}</option>\n <option value=\"1\">${msg('The day after')}</option>\n </select>\n <input type=\"time\" data-from-time .value=${item.fromTime} step=\"1800\" required ?disabled=${this.disabled} />\n\n <select data-to-date .value=${String(item.toDate || 0)} ?disabled=${this.disabled}>\n <option value=\"-1\">${msg('The day before')}</option>\n <option value=\"0\">${msg('The day')}</option>\n <option value=\"1\">${msg('The day after')}</option>\n </select>\n <input type=\"time\" data-to-time .value=${item.toTime} step=\"1800\" required ?disabled=${this.disabled} />\n\n <button\n class=\"record-action\"\n @click=${(e: Event) => this._delete(e)}\n tabindex=\"-1\"\n ?disabled=${this.disabled}\n >\n <md-icon>remove</md-icon>\n </button>\n </div>\n `\n )}\n ${this.disabled\n ? nothing\n : html`\n <div data-record-new>\n <input type=\"text\" data-name />\n\n <select data-from-date>\n <option value=\"-1\">${msg('The day before')}</option>\n <option value=\"0\" selected>${msg('The day')}</option>\n <option value=\"+1\">${msg('The day after')}</option>\n </select>\n <input type=\"time\" data-from-time step=\"1800\" />\n\n <select data-to-date>\n <option value=\"-1\">${msg('The day before')}</option>\n <option value=\"0\" selected>${msg('The day')}</option>\n <option value=\"+1\">${msg('The day after')}</option>\n </select>\n <input type=\"time\" data-to-time step=\"1800\" />\n\n <button class=\"record-action\" @click=${(e: Event) => this._add()} tabindex=\"-1\">\n <md-icon>add</md-icon>\n </button>\n </div>\n `}\n `\n }\n\n _onChange(e: Event) {\n if (this._changingNow) {\n return\n }\n\n this._changingNow = true\n\n const input = e.target as HTMLInputElement\n\n const div = input.parentElement as HTMLDivElement\n\n if (div.hasAttribute('data-record')) {\n this._build()\n } else if (div.hasAttribute('data-record-new') && input.hasAttribute('data-value')) {\n this._add()\n }\n\n this._changingNow = false\n }\n\n _build(includeNewRecord?: boolean) {\n if (includeNewRecord) {\n var records = this.renderRoot.querySelectorAll('[data-record],[data-record-new]')\n } else {\n var records = this.renderRoot.querySelectorAll('[data-record]')\n }\n\n var value: WorkShift[] = []\n for (var i = 0; i < records.length; i++) {\n const record = records[i]\n\n const name = (record.querySelector('[data-name]') as HTMLInputElement).value\n\n const fromDate = (record.querySelector('[data-from-date]') as HTMLSelectElement).value\n const fromTime = (record.querySelector('[data-from-time]') as HTMLInputElement).value\n const toDate = (record.querySelector('[data-to-date]') as HTMLSelectElement).value\n const toTime = (record.querySelector('[data-to-time]') as HTMLInputElement).value\n\n if (!name) {\n ;(record.querySelector('[data-name]') as HTMLInputElement).focus()\n return\n }\n\n if (!fromDate) {\n ;(record.querySelector('[data-from-date]') as HTMLInputElement).focus()\n return\n }\n\n if (!fromTime) {\n ;(record.querySelector('[data-from-time]') as HTMLInputElement).focus()\n return\n }\n\n if (!toDate) {\n ;(record.querySelector('[data-to-date]') as HTMLInputElement).focus()\n return\n }\n\n if (!toTime) {\n ;(record.querySelector('[data-to-time]') as HTMLInputElement).focus()\n return\n }\n\n if (name) {\n value.push({\n name,\n fromDate: Number(fromDate),\n fromTime,\n toDate: Number(toDate),\n toTime\n })\n }\n }\n\n this.value = value\n\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))\n }\n\n _add() {\n this._build(true)\n\n const inputs = this.renderRoot.querySelectorAll(\n '[data-record-new] input:not([style*=\"display: none\"])'\n ) as NodeListOf<HTMLInputElement & { value: any; type: string }>\n\n for (var i = 0; i < inputs.length; i++) {\n let input = inputs[i]\n input.value = ''\n }\n\n inputs[0].focus()\n }\n\n _delete(e: Event) {\n const record = (e.target as Element).parentElement\n\n const dataName = record!.querySelector('[data-name]') as HTMLInputElement\n dataName.name = ''\n\n this._build()\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"ox-input-work-shift.js","sourceRoot":"","sources":["../../src/ox-input-work-shift.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE3D,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,eAAe,CAAA;AAE9C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAIhD;;;;;;;;EAQE;AAIK,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,WAAW;IAA1C;;QAmFsB,UAAK,GAAgB,EAAE,CAAA;QAE1C,iBAAY,GAAY,KAAK,CAAA;IAmLvC,CAAC;aAvQQ,WAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgFlB,AAhFY,CAgFZ;IAMD,YAAY;QACV,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IACvE,CAAC;IAED,MAAM;QACJ,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE,CAAA;QAEnC,OAAO,IAAI,CAAA;;gBAEC,GAAG,CAAC,MAAM,CAAC;gBACX,GAAG,CAAC,WAAW,CAAC;gBAChB,GAAG,CAAC,WAAW,CAAC;gBAChB,GAAG,CAAC,SAAS,CAAC;gBACd,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IAAI;QACF,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QAEjB,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAC7C,uDAAuD,CACO,CAAA;QAEhE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACvC,IAAI,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;YACrB,KAAK,CAAC,KAAK,GAAG,EAAE,CAAA;QAClB,CAAC;QAED,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAA;IACnB,CAAC;IAED,OAAO,CAAC,CAAQ;QACd,MAAM,MAAM,GAAI,CAAC,CAAC,MAAkB,CAAC,aAAa,CAAA;QAElD,MAAM,QAAQ,GAAG,MAAO,CAAC,aAAa,CAAC,aAAa,CAAqB,CAAA;QACzE,QAAQ,CAAC,IAAI,GAAG,EAAE,CAAA;QAElB,IAAI,CAAC,MAAM,EAAE,CAAA;IACf,CAAC;;AApL0B;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;+CAAwB;AAnFvC,gBAAgB;IAF5B,SAAS,EAAE;IACX,aAAa,CAAC,qBAAqB,CAAC;GACxB,gBAAgB,CAwQ5B","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport { css, html, nothing } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { localized, msg } from '@lit/localize'\n\nimport { OxFormField } from './ox-form-field.js'\n\ntype WorkShift = { name: string; fromDate: number; fromTime: string; toDate: number; toTime: string }\n\n/**\nwork-shift array value editor element\n\nExample:\n\n <ox-input-work-shift\n .value=${value}\n </ox-input-work-shift>\n*/\n\n@localized()\n@customElement('ox-input-work-shift')\nexport class OxInputWorkShift extends OxFormField {\n static styles = css`\n :host {\n display: flex;\n flex-direction: column;\n\n width: 100%;\n overflow: hidden;\n\n --md-icon-size: var(--fontsize-default, 14px);\n }\n\n div {\n display: flex;\n flex-flow: row nowrap;\n gap: var(--spacing-medium);\n }\n\n empty-element {\n width: 34px;\n text-align: center;\n }\n\n input,\n select,\n span {\n flex: 1;\n }\n [data-header] {\n background-color: rgba(var(--md-sys-color-on-primary-container-rgb), 0.05);\n padding: var(--padding-narrow);\n }\n [data-header] span {\n font: var(--label-font);\n color: var(--label-color, var(--md-sys-color-on-surface));\n text-transform: var(--label-text-transform);\n text-align: center;\n }\n [data-record] {\n margin-bottom: var(--margin-narrow);\n }\n input,\n select {\n border: 0;\n border-bottom: 1px solid rgba(0, 0, 0, 0.15);\n padding: var(--spacing-tiny);\n font: var(--input-font);\n color: var(--md-sys-color-on-primary-container);\n\n max-height: 35px;\n }\n input:focus,\n select:focus {\n outline: none;\n border-bottom: 1px solid var(--md-sys-color-on-primary-container);\n }\n\n input:required:invalid {\n border: 1px dashed red;\n }\n\n button {\n border: var(--button-border);\n border-radius: var(--border-radius);\n background-color: var(--button-background-color);\n padding: var(--padding-narrow) var(--padding-default);\n line-height: 0.8;\n color: var(--button-color);\n cursor: pointer;\n }\n button:focus,\n button:hover,\n button:active {\n border: var(--button-activ-border);\n background-color: var(--button-background-focus-color);\n color: var(--md-sys-color-primary-container);\n }\n\n [placeholder='value'] {\n flex: 2;\n }\n `\n\n @property({ type: Array }) value: WorkShift[] = []\n\n private _changingNow: boolean = false\n\n firstUpdated() {\n this.renderRoot.addEventListener('change', this._onChange.bind(this))\n }\n\n render() {\n const workshifts = this.value || []\n\n return html`\n <div data-header>\n <span>${msg('name')}</span>\n <span>${msg('from date')}</span>\n <span>${msg('from time')}</span>\n <span>${msg('to date')}</span>\n <span>${msg('to time')}</span>\n <empty-element></empty-element>\n </div>\n\n ${workshifts.map(\n item => html`\n <div data-record>\n <input type=\"text\" data-name .value=${item.name} required ?disabled=${this.disabled} />\n\n <select data-from-date .value=${String(item.fromDate || 0)} ?disabled=${this.disabled}>\n <option value=\"-1\">${msg('The day before')}</option>\n <option value=\"0\">${msg('The day')}</option>\n <option value=\"1\">${msg('The day after')}</option>\n </select>\n <input type=\"time\" data-from-time .value=${item.fromTime} step=\"1800\" required ?disabled=${this.disabled} />\n\n <select data-to-date .value=${String(item.toDate || 0)} ?disabled=${this.disabled}>\n <option value=\"-1\">${msg('The day before')}</option>\n <option value=\"0\">${msg('The day')}</option>\n <option value=\"1\">${msg('The day after')}</option>\n </select>\n <input type=\"time\" data-to-time .value=${item.toTime} step=\"1800\" required ?disabled=${this.disabled} />\n\n <button\n class=\"record-action\"\n @click=${(e: Event) => this._delete(e)}\n tabindex=\"-1\"\n ?disabled=${this.disabled}\n >\n <md-icon>remove</md-icon>\n </button>\n </div>\n `\n )}\n ${this.disabled\n ? nothing\n : html`\n <div data-record-new>\n <input type=\"text\" data-name />\n\n <select data-from-date>\n <option value=\"-1\">${msg('The day before')}</option>\n <option value=\"0\" selected>${msg('The day')}</option>\n <option value=\"+1\">${msg('The day after')}</option>\n </select>\n <input type=\"time\" data-from-time step=\"1800\" />\n\n <select data-to-date>\n <option value=\"-1\">${msg('The day before')}</option>\n <option value=\"0\" selected>${msg('The day')}</option>\n <option value=\"+1\">${msg('The day after')}</option>\n </select>\n <input type=\"time\" data-to-time step=\"1800\" />\n\n <button class=\"record-action\" @click=${(e: Event) => this._add()} tabindex=\"-1\">\n <md-icon>add</md-icon>\n </button>\n </div>\n `}\n `\n }\n\n _onChange(e: Event) {\n if (this._changingNow) {\n return\n }\n\n this._changingNow = true\n\n const input = e.target as HTMLInputElement\n\n const div = input.parentElement as HTMLDivElement\n\n if (div.hasAttribute('data-record')) {\n this._build()\n } else if (div.hasAttribute('data-record-new') && input.hasAttribute('data-value')) {\n this._add()\n }\n\n this._changingNow = false\n }\n\n _build(includeNewRecord?: boolean) {\n if (includeNewRecord) {\n var records = this.renderRoot.querySelectorAll('[data-record],[data-record-new]')\n } else {\n var records = this.renderRoot.querySelectorAll('[data-record]')\n }\n\n var value: WorkShift[] = []\n for (var i = 0; i < records.length; i++) {\n const record = records[i]\n\n const name = (record.querySelector('[data-name]') as HTMLInputElement).value\n\n const fromDate = (record.querySelector('[data-from-date]') as HTMLSelectElement).value\n const fromTime = (record.querySelector('[data-from-time]') as HTMLInputElement).value\n const toDate = (record.querySelector('[data-to-date]') as HTMLSelectElement).value\n const toTime = (record.querySelector('[data-to-time]') as HTMLInputElement).value\n\n if (!name) {\n ;(record.querySelector('[data-name]') as HTMLInputElement).focus()\n return\n }\n\n if (!fromDate) {\n ;(record.querySelector('[data-from-date]') as HTMLInputElement).focus()\n return\n }\n\n if (!fromTime) {\n ;(record.querySelector('[data-from-time]') as HTMLInputElement).focus()\n return\n }\n\n if (!toDate) {\n ;(record.querySelector('[data-to-date]') as HTMLInputElement).focus()\n return\n }\n\n if (!toTime) {\n ;(record.querySelector('[data-to-time]') as HTMLInputElement).focus()\n return\n }\n\n if (name) {\n value.push({\n name,\n fromDate: Number(fromDate),\n fromTime,\n toDate: Number(toDate),\n toTime\n })\n }\n }\n\n this.value = value\n\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))\n }\n\n _add() {\n this._build(true)\n\n const inputs = this.renderRoot.querySelectorAll(\n '[data-record-new] input:not([style*=\"display: none\"])'\n ) as NodeListOf<HTMLInputElement & { value: any; type: string }>\n\n for (var i = 0; i < inputs.length; i++) {\n let input = inputs[i]\n input.value = ''\n }\n\n inputs[0].focus()\n }\n\n _delete(e: Event) {\n const record = (e.target as Element).parentElement\n\n const dataName = record!.querySelector('[data-name]') as HTMLInputElement\n dataName.name = ''\n\n this._build()\n }\n}\n"]}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import '../src/ox-input-direction.js';
|
2
|
+
import { TemplateResult } from 'lit';
|
3
|
+
declare const _default: {
|
4
|
+
title: string;
|
5
|
+
component: string;
|
6
|
+
argTypes: {
|
7
|
+
value: {
|
8
|
+
control: string;
|
9
|
+
};
|
10
|
+
name: {
|
11
|
+
control: string;
|
12
|
+
};
|
13
|
+
disabled: {
|
14
|
+
control: string;
|
15
|
+
};
|
16
|
+
theme: {
|
17
|
+
control: string;
|
18
|
+
options: string[];
|
19
|
+
};
|
20
|
+
};
|
21
|
+
};
|
22
|
+
export default _default;
|
23
|
+
interface Story<T> {
|
24
|
+
(args: T): TemplateResult;
|
25
|
+
args?: Partial<T>;
|
26
|
+
argTypes?: Record<string, unknown>;
|
27
|
+
}
|
28
|
+
interface ArgTypes {
|
29
|
+
name?: string;
|
30
|
+
value?: object | string;
|
31
|
+
disabled?: boolean;
|
32
|
+
theme?: string;
|
33
|
+
}
|
34
|
+
export declare const Regular: Story<ArgTypes>;
|