@operato/input 1.1.30 → 1.1.34
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 +18 -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-select-buttons.d.ts +18 -0
- package/dist/src/ox-input-select-buttons.js +85 -0
- package/dist/src/ox-input-select-buttons.js.map +1 -0
- package/dist/src/ox-input-unit-number.js +8 -3
- package/dist/src/ox-input-unit-number.js.map +1 -1
- package/dist/src/ox-input-work-shift.d.ts +0 -1
- package/dist/src/ox-input-work-shift.js +2 -3
- package/dist/src/ox-input-work-shift.js.map +1 -1
- package/dist/stories/ox-input-select-buttons.stories.d.ts +34 -0
- package/dist/stories/ox-input-select-buttons.stories.js +63 -0
- package/dist/stories/ox-input-select-buttons.stories.js.map +1 -0
- package/dist/stories/ox-input-unit.stories.d.ts +1 -0
- package/dist/stories/ox-input-unit.stories.js +4 -2
- package/dist/stories/ox-input-unit.stories.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -2
- package/src/index.ts +1 -0
- package/src/ox-input-select-buttons.ts +86 -0
- package/src/ox-input-unit-number.ts +9 -3
- package/src/ox-input-work-shift.ts +2 -4
- package/stories/ox-input-select-buttons.stories.ts +80 -0
- package/stories/ox-input-unit.stories.ts +6 -2
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,24 @@
|
|
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.1.34](https://github.com/hatiolab/operato/compare/v1.1.33...v1.1.34) (2022-12-16)
|
7
|
+
|
8
|
+
|
9
|
+
### :bug: Bug Fix
|
10
|
+
|
11
|
+
* ox-input-unit-number ([64ce83a](https://github.com/hatiolab/operato/commit/64ce83a82a5b04aba35ba7f2435d22211247d3f4))
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
### [1.1.31](https://github.com/hatiolab/operato/compare/v1.1.30...v1.1.31) (2022-12-12)
|
16
|
+
|
17
|
+
|
18
|
+
### :bug: Bug Fix
|
19
|
+
|
20
|
+
* add ox-input-select-buttons ([4516a54](https://github.com/hatiolab/operato/commit/4516a543251bbe182afc27fce1222fd7bc0a4fd4))
|
21
|
+
|
22
|
+
|
23
|
+
|
6
24
|
### [1.1.30](https://github.com/hatiolab/operato/compare/v1.1.29...v1.1.30) (2022-12-08)
|
7
25
|
|
8
26
|
|
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,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","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-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'\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,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","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-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'\n"]}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
/**
|
2
|
+
* @license Copyright © HatioLab Inc. All rights reserved.
|
3
|
+
*/
|
4
|
+
import { OxFormField } from './ox-form-field';
|
5
|
+
type Option = {
|
6
|
+
display: string;
|
7
|
+
value: string;
|
8
|
+
};
|
9
|
+
export declare class OxInputSelectButtons extends OxFormField {
|
10
|
+
static styles: import("lit").CSSResult;
|
11
|
+
value: string[] | string | undefined;
|
12
|
+
options: Option[];
|
13
|
+
multiple: boolean;
|
14
|
+
render(): import("lit-html").TemplateResult<1>;
|
15
|
+
onClick(e: MouseEvent): void;
|
16
|
+
protected appendFormData({ formData }: FormDataEvent): void;
|
17
|
+
}
|
18
|
+
export {};
|
@@ -0,0 +1,85 @@
|
|
1
|
+
/**
|
2
|
+
* @license Copyright © HatioLab Inc. All rights reserved.
|
3
|
+
*/
|
4
|
+
import { __decorate } from "tslib";
|
5
|
+
import { css, html } from 'lit';
|
6
|
+
import { customElement, property } from 'lit/decorators.js';
|
7
|
+
import { OxFormField } from './ox-form-field';
|
8
|
+
let OxInputSelectButtons = class OxInputSelectButtons extends OxFormField {
|
9
|
+
constructor() {
|
10
|
+
super(...arguments);
|
11
|
+
this.value = [];
|
12
|
+
this.options = [];
|
13
|
+
this.multiple = false;
|
14
|
+
}
|
15
|
+
static { this.styles = css `
|
16
|
+
:host {
|
17
|
+
display: flex;
|
18
|
+
flex-flow: row;
|
19
|
+
flex-wrap: wrap;
|
20
|
+
gap: var(--margin-default);
|
21
|
+
}
|
22
|
+
|
23
|
+
span {
|
24
|
+
border-radius: 9999px;
|
25
|
+
background-color: #efefef;
|
26
|
+
padding: 2px 10px;
|
27
|
+
}
|
28
|
+
|
29
|
+
span[selected] {
|
30
|
+
background-color: var(--focus-background-color, #38a25b);
|
31
|
+
color: var(--focus-color, #efefef);
|
32
|
+
}
|
33
|
+
`; }
|
34
|
+
render() {
|
35
|
+
const options = this.options.filter(option => !!option.value);
|
36
|
+
const values = this.value instanceof Array ? this.value : typeof this.value == 'string' ? [this.value] : [];
|
37
|
+
return html `
|
38
|
+
${(options || []).map(({ display, value }) => html `
|
39
|
+
<span data-value=${value} ?selected=${values.includes(value)} @click=${(e) => this.onClick(e)}
|
40
|
+
>${display}</span
|
41
|
+
>
|
42
|
+
`)}
|
43
|
+
`;
|
44
|
+
}
|
45
|
+
onClick(e) {
|
46
|
+
e.stopPropagation();
|
47
|
+
const target = e.target;
|
48
|
+
const value = target.getAttribute('data-value');
|
49
|
+
if (this.multiple) {
|
50
|
+
const values = this.value instanceof Array ? this.value : typeof this.value == 'string' ? [this.value] : [];
|
51
|
+
const idx = (this.value || []).indexOf(value);
|
52
|
+
if (idx != -1) {
|
53
|
+
values.splice(idx, 1);
|
54
|
+
}
|
55
|
+
else {
|
56
|
+
values.push(value);
|
57
|
+
}
|
58
|
+
this.value = [...values];
|
59
|
+
}
|
60
|
+
else {
|
61
|
+
this.value = this.value === value ? undefined : value;
|
62
|
+
}
|
63
|
+
this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }));
|
64
|
+
}
|
65
|
+
appendFormData({ formData }) {
|
66
|
+
if (!this.name)
|
67
|
+
return;
|
68
|
+
const value = this.value;
|
69
|
+
formData.append(this.name, typeof value === 'string' ? value : value === undefined || value === null ? '' : JSON.stringify(value));
|
70
|
+
}
|
71
|
+
};
|
72
|
+
__decorate([
|
73
|
+
property({ type: Array })
|
74
|
+
], OxInputSelectButtons.prototype, "value", void 0);
|
75
|
+
__decorate([
|
76
|
+
property({ type: Array })
|
77
|
+
], OxInputSelectButtons.prototype, "options", void 0);
|
78
|
+
__decorate([
|
79
|
+
property({ type: Boolean })
|
80
|
+
], OxInputSelectButtons.prototype, "multiple", void 0);
|
81
|
+
OxInputSelectButtons = __decorate([
|
82
|
+
customElement('ox-input-select-buttons')
|
83
|
+
], OxInputSelectButtons);
|
84
|
+
export { OxInputSelectButtons };
|
85
|
+
//# sourceMappingURL=ox-input-select-buttons.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ox-input-select-buttons.js","sourceRoot":"","sources":["../../src/ox-input-select-buttons.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,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;AAKtC,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,WAAW;IAA9C;;QAqBsB,UAAK,GAAkC,EAAE,CAAA;QACzC,YAAO,GAAa,EAAE,CAAA;QACpB,aAAQ,GAAY,KAAK,CAAA;IAkDxD,CAAC;aAxEQ,WAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;GAkBlB,CAAA;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,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AC,GAAG,MAAM,CAAC,CAAA;SACzB;aAAM;YACL,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAA;SACtD;QAED,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;IAES,cAAc,CAAC,EAAE,QAAQ,EAAiB;QAClD,IAAI,CAAC,IAAI,CAAC,IAAI;YAAE,OAAM;QAEtB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAA;QAExB,QAAQ,CAAC,MAAM,CACb,IAAI,CAAC,IAAK,EACV,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CACvG,CAAA;IACH,CAAC;;AAnD0B;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;mDAA0C;AACzC;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;qDAAuB;AACpB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;sDAA0B;AAvB3C,oBAAoB;IADhC,aAAa,CAAC,yBAAyB,CAAC;GAC5B,oBAAoB,CAyEhC;SAzEY,oBAAoB","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport { css, html } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { OxFormField } from './ox-form-field'\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(--margin-default);\n }\n\n span {\n border-radius: 9999px;\n background-color: #efefef;\n padding: 2px 10px;\n }\n\n span[selected] {\n background-color: var(--focus-background-color, #38a25b);\n color: var(--focus-color, #efefef);\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 ${(options || []).map(\n ({ display, value }) => html`\n <span data-value=${value} ?selected=${values.includes(value)} @click=${(e: MouseEvent) => this.onClick(e)}\n >${display}</span\n >\n `\n )}\n `\n }\n\n onClick(e: MouseEvent) {\n e.stopPropagation()\n\n const target = e.target as HTMLSpanElement\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 protected appendFormData({ formData }: FormDataEvent): void {\n if (!this.name) return\n\n const value = this.value\n\n formData.append(\n this.name!,\n typeof value === 'string' ? value : value === undefined || value === null ? '' : JSON.stringify(value)\n )\n }\n}\n"]}
|
@@ -150,6 +150,7 @@ const UNIT_SYSTEMS = {
|
|
150
150
|
'm2 oC/kW': 1000
|
151
151
|
},
|
152
152
|
'%': {},
|
153
|
+
'ppm (11%, O2 corrected)': {},
|
153
154
|
K: {
|
154
155
|
C: [(v) => v - 273.15, (v) => v + 273.15]
|
155
156
|
}
|
@@ -233,9 +234,9 @@ let OxInputUnit = class OxInputUnit extends OxFormField {
|
|
233
234
|
`;
|
234
235
|
}
|
235
236
|
updated(changes) {
|
236
|
-
if (changes.has('stdUnit')) {
|
237
|
-
|
238
|
-
}
|
237
|
+
// if (changes.has('stdUnit')) {
|
238
|
+
// this.userUnit = this.userUnit || this.stdUnit
|
239
|
+
// }
|
239
240
|
}
|
240
241
|
_onChangeValue(e) {
|
241
242
|
this.value = this._toStdUnit(this.input.value);
|
@@ -253,6 +254,10 @@ let OxInputUnit = class OxInputUnit extends OxFormField {
|
|
253
254
|
return Number(stdValue);
|
254
255
|
}
|
255
256
|
const converterValue = UNIT_SYSTEMS[this.stdUnit][this.userUnit];
|
257
|
+
if (!converterValue) {
|
258
|
+
delete this.userUnit;
|
259
|
+
return;
|
260
|
+
}
|
256
261
|
if (typeof converterValue === 'number') {
|
257
262
|
return this._toUserUnitByRate(stdValue, converterValue || 1);
|
258
263
|
} /* should be converter function array */
|
@@ -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,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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AO,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,cAAc,IAAI,CAAC,CAAC,CAAA;SAC7D,CAAC,wCAAwC;aAAM;YAC9C,OAAO,IAAI,CAAC,oBAAoB,CAAC,SAAS,EAAE,cAA2C,CAAC,CAAA;SACzF;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;;AA/G2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDAAqB;AACG;IAAlD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;4CAAiB;AACf;IAAnD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;6CAAkB;AAErD;IAAf,KAAK,CAAC,OAAO,CAAC;0CAAyB;AAChB;IAAvB,KAAK,CAAC,eAAe,CAAC;0CAAoB;AAlDhC,WAAW;IADvB,aAAa,CAAC,sBAAsB,CAAC;GACzB,WAAW,CA6JvB;SA7JY,WAAW","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\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 '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 K: {\n C: [(v: number) => v - 273.15, (v: number) => v + 273.15]\n }\n}\n\n@customElement('ox-input-unit-number')\nexport class OxInputUnit extends OxFormField {\n static styles = [\n css`\n :host {\n display: flex;\n flex-direction: row;\n align-items: center;\n }\n\n input {\n flex: 1;\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 min-width: 40px;\n }\n\n input:focus {\n outline: none;\n border-bottom: 1px solid var(--primary-color);\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 -moz-appearance: textfield;\n }\n\n #unit {\n display: inline;\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 ]\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 = Object.keys(UNIT_SYSTEMS[this.stdUnit])\n const rate = !this.userUnit || this.userUnit === this.stdUnit ? 1 : UNIT_SYSTEMS[this.stdUnit][this.userUnit] || 1\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 />\n <div\n id=\"unit\"\n @click=${(e: Event) => {\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 </div>\n `\n }\n\n updated(changes: PropertyValues<this>) {\n if (changes.has('stdUnit')) {\n 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 (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,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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AQ,CAAC,CAAA;QAEhE,IAAI,OAAO,cAAc,KAAK,QAAQ,EAAE;YACtC,OAAO,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,cAAc,IAAI,CAAC,CAAC,CAAA;SAC7D,CAAC,wCAAwC;aAAM;YAC9C,OAAO,IAAI,CAAC,oBAAoB,CAAC,SAAS,EAAE,cAA2C,CAAC,CAAA;SACzF;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;;AApH2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDAAqB;AACG;IAAlD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;4CAAiB;AACf;IAAnD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;6CAAkB;AAErD;IAAf,KAAK,CAAC,OAAO,CAAC;0CAAyB;AAChB;IAAvB,KAAK,CAAC,eAAe,CAAC;0CAAoB;AAlDhC,WAAW;IADvB,aAAa,CAAC,sBAAsB,CAAC;GACzB,WAAW,CAkKvB;SAlKY,WAAW","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\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 '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 (11%, O2 corrected)': {},\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 OxInputUnit extends OxFormField {\n static styles = [\n css`\n :host {\n display: flex;\n flex-direction: row;\n align-items: center;\n }\n\n input {\n flex: 1;\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 min-width: 40px;\n }\n\n input:focus {\n outline: none;\n border-bottom: 1px solid var(--primary-color);\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 -moz-appearance: textfield;\n }\n\n #unit {\n display: inline;\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 ]\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 = Object.keys(UNIT_SYSTEMS[this.stdUnit])\n const rate = !this.userUnit || this.userUnit === this.stdUnit ? 1 : UNIT_SYSTEMS[this.stdUnit][this.userUnit] || 1\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 />\n <div\n id=\"unit\"\n @click=${(e: Event) => {\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 </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"]}
|
@@ -2,7 +2,6 @@
|
|
2
2
|
* @license Copyright © HatioLab Inc. All rights reserved.
|
3
3
|
*/
|
4
4
|
import { __decorate } from "tslib";
|
5
|
-
import './ox-input-color';
|
6
5
|
import { css, html } from 'lit';
|
7
6
|
import { customElement, property } from 'lit/decorators.js';
|
8
7
|
import { localized, msg } from '@lit/localize';
|
@@ -126,14 +125,14 @@ let OxInputWorkShift = class OxInputWorkShift extends OxFormField {
|
|
126
125
|
<div data-record>
|
127
126
|
<input type="text" data-name .value=${item.name} required />
|
128
127
|
|
129
|
-
<select data-from-date .value=${item.fromDate || 0}>
|
128
|
+
<select data-from-date .value=${String(item.fromDate || 0)}>
|
130
129
|
<option value="-1">${msg('The day before')}</option>
|
131
130
|
<option value="0">${msg('The day')}</option>
|
132
131
|
<option value="1">${msg('The day after')}</option>
|
133
132
|
</select>
|
134
133
|
<input type="time" data-from-time .value=${item.fromTime} step="1800" required />
|
135
134
|
|
136
|
-
<select data-to-date .value=${item.toDate || 0}>
|
135
|
+
<select data-to-date .value=${String(item.toDate || 0)}>
|
137
136
|
<option value="-1">${msg('The day before')}</option>
|
138
137
|
<option value="0">${msg('The day')}</option>
|
139
138
|
<option value="1">${msg('The day after')}</option>
|
@@ -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,kBAAkB,CAAA;AAEzB,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,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;;QAuFuB,UAAK,GAAgB,EAAE,CAAA;QAE3C,iBAAY,GAAY,KAAK,CAAA;IA2KvC,CAAC;aAnQQ,WAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoFlB,CAAA;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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AC,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;;AA5K2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CAAwB;AAvFxC,gBAAgB;IAF5B,SAAS,EAAE;IACX,aAAa,CAAC,qBAAqB,CAAC;GACxB,gBAAgB,CAoQ5B;SApQY,gBAAgB","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport './ox-input-color'\n\nimport { css, html } 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\n div {\n display: flex;\n flex-flow: row nowrap;\n gap: var(--margin-default);\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(--primary-color-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: var(--border-dark-color);\n padding: var(--input-padding);\n font: var(--input-font);\n color: var(--primary-text-color);\n\n max-height: 35px;\n }\n input:focus,\n select:focus {\n outline: none;\n border-bottom: 1px solid var(--primary-color);\n }\n\n input:required:invalid {\n border: 1px dashed red;\n }\n input[type='time'] {\n padding: 2px var(--padding-default);\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 mwc-icon {\n font-size: var(--fontsize-default);\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(--theme-white-color);\n }\n\n [placeholder='value'] {\n flex: 2;\n }\n `\n\n @property({ type: Object }) 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 />\n\n <select data-from-date .value=${item.fromDate || 0}>\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 />\n\n <select data-to-date .value=${item.toDate || 0}>\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 />\n\n <button class=\"record-action\" @click=${(e: Event) => this._delete(e)} tabindex=\"-1\">\n <mwc-icon>remove</mwc-icon>\n </button>\n </div>\n `\n )}\n\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 <mwc-icon>add</mwc-icon>\n </button>\n </div>\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,MAAM,KAAK,CAAA;AAC/B,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;;QAuFuB,UAAK,GAAgB,EAAE,CAAA;QAE3C,iBAAY,GAAY,KAAK,CAAA;IA2KvC,CAAC;aAnQQ,WAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoFlB,CAAA;IAMD,YAAY;QACV,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,IA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uD,CACO,CAAA;QAEhE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACtC,IAAI,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;YACrB,KAAK,CAAC,KAAK,GAAG,EAAE,CAAA;SACjB;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;;AA5K2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CAAwB;AAvFxC,gBAAgB;IAF5B,SAAS,EAAE;IACX,aAAa,CAAC,qBAAqB,CAAC;GACxB,gBAAgB,CAoQ5B;SApQY,gBAAgB","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport { css, html } 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\n div {\n display: flex;\n flex-flow: row nowrap;\n gap: var(--margin-default);\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(--primary-color-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: var(--border-dark-color);\n padding: var(--input-padding);\n font: var(--input-font);\n color: var(--primary-text-color);\n\n max-height: 35px;\n }\n input:focus,\n select:focus {\n outline: none;\n border-bottom: 1px solid var(--primary-color);\n }\n\n input:required:invalid {\n border: 1px dashed red;\n }\n input[type='time'] {\n padding: 2px var(--padding-default);\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 mwc-icon {\n font-size: var(--fontsize-default);\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(--theme-white-color);\n }\n\n [placeholder='value'] {\n flex: 2;\n }\n `\n\n @property({ type: Object }) 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 />\n\n <select data-from-date .value=${String(item.fromDate || 0)}>\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 />\n\n <select data-to-date .value=${String(item.toDate || 0)}>\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 />\n\n <button class=\"record-action\" @click=${(e: Event) => this._delete(e)} tabindex=\"-1\">\n <mwc-icon>remove</mwc-icon>\n </button>\n </div>\n `\n )}\n\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 <mwc-icon>add</mwc-icon>\n </button>\n </div>\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-select-buttons.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
|
+
options: {
|
11
|
+
control: string;
|
12
|
+
};
|
13
|
+
multiple: {
|
14
|
+
control: string;
|
15
|
+
};
|
16
|
+
name: {
|
17
|
+
control: string;
|
18
|
+
};
|
19
|
+
};
|
20
|
+
};
|
21
|
+
export default _default;
|
22
|
+
interface Story<T> {
|
23
|
+
(args: T): TemplateResult;
|
24
|
+
args?: Partial<T>;
|
25
|
+
argTypes?: Record<string, unknown>;
|
26
|
+
}
|
27
|
+
interface ArgTypes {
|
28
|
+
name?: string;
|
29
|
+
value?: object | string;
|
30
|
+
options: object;
|
31
|
+
multiple?: boolean;
|
32
|
+
}
|
33
|
+
export declare const Regular: Story<ArgTypes>;
|
34
|
+
export declare const Multiple: Story<ArgTypes>;
|
@@ -0,0 +1,63 @@
|
|
1
|
+
import '../src/ox-input-select-buttons.js';
|
2
|
+
import { html } from 'lit';
|
3
|
+
export default {
|
4
|
+
title: 'ox-input-select-buttons',
|
5
|
+
component: 'ox-input-select-buttons',
|
6
|
+
argTypes: {
|
7
|
+
value: { control: 'object' },
|
8
|
+
options: { control: 'object' },
|
9
|
+
multiple: { control: 'boolean' },
|
10
|
+
name: { control: 'text' }
|
11
|
+
}
|
12
|
+
};
|
13
|
+
const Template = ({ name = 'options', value, multiple = false, options = [] }) => html `
|
14
|
+
<link href="/themes/app-theme.css" rel="stylesheet" />
|
15
|
+
<link href="https://fonts.googleapis.com/css?family=Material+Icons&display=block" rel="stylesheet" />
|
16
|
+
<style>
|
17
|
+
ox-input-select-buttons {
|
18
|
+
max-width: 400px;
|
19
|
+
}
|
20
|
+
</style>
|
21
|
+
|
22
|
+
<ox-input-select-buttons
|
23
|
+
@change=${(e) => {
|
24
|
+
console.log(e.target.value);
|
25
|
+
}}
|
26
|
+
name=${name}
|
27
|
+
.value=${value}
|
28
|
+
.options=${options}
|
29
|
+
?multiple=${multiple}
|
30
|
+
>
|
31
|
+
</ox-input-select-buttons>
|
32
|
+
`;
|
33
|
+
export const Regular = Template.bind({});
|
34
|
+
Regular.args = {
|
35
|
+
name: 'options',
|
36
|
+
value: 'Clothes',
|
37
|
+
options: [
|
38
|
+
{ display: 'SHOOSE', value: 'Shoose' },
|
39
|
+
{ display: 'CHOTHES', value: 'Clothes' },
|
40
|
+
{ display: 'GLOVES', value: 'Gloves' }
|
41
|
+
]
|
42
|
+
};
|
43
|
+
export const Multiple = Template.bind({});
|
44
|
+
Multiple.args = {
|
45
|
+
name: 'options',
|
46
|
+
value: ['Clothes'],
|
47
|
+
multiple: true,
|
48
|
+
options: [
|
49
|
+
{ display: 'SHOOSE1', value: 'Shoose1' },
|
50
|
+
{ display: 'CHOTHES1', value: 'Clothes1' },
|
51
|
+
{ display: 'GLOVES1', value: 'Gloves1' },
|
52
|
+
{ display: 'SHOOSE2', value: 'Shoose2' },
|
53
|
+
{ display: 'CHOTHES2', value: 'Clothes2' },
|
54
|
+
{ display: 'GLOVES2', value: 'Gloves2' },
|
55
|
+
{ display: 'SHOOSE3', value: 'Shoose3' },
|
56
|
+
{ display: 'CHOTHES3', value: 'Clothes3' },
|
57
|
+
{ display: 'GLOVES3', value: 'Gloves3' },
|
58
|
+
{ display: 'SHOOSE4', value: 'Shoose4' },
|
59
|
+
{ display: 'CHOTHES4', value: 'Clothes4' },
|
60
|
+
{ display: 'GLOVES4', value: 'Gloves4' }
|
61
|
+
]
|
62
|
+
};
|
63
|
+
//# sourceMappingURL=ox-input-select-buttons.stories.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ox-input-select-buttons.stories.js","sourceRoot":"","sources":["../../stories/ox-input-select-buttons.stories.ts"],"names":[],"mappings":"AAAA,OAAO,mCAAmC,CAAA;AAE1C,OAAO,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAA;AAE1C,eAAe;IACb,KAAK,EAAE,yBAAyB;IAChC,SAAS,EAAE,yBAAyB;IACpC,QAAQ,EAAE;QACR,KAAK,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE;QAC5B,OAAO,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE;QAC9B,QAAQ,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE;QAChC,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;KAC1B;CACF,CAAA;AAeD,MAAM,QAAQ,GAAoB,CAAC,EAAE,IAAI,GAAG,SAAS,EAAE,KAAK,EAAE,QAAQ,GAAG,KAAK,EAAE,OAAO,GAAG,EAAE,EAAY,EAAE,EAAE,CAAC,IAAI,CAAA;;;;;;;;;;cAUnG,CAAC,CAAQ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C,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;QACxC,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;QACxC,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE;QAC1C,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;KACzC;CACF,CAAA","sourcesContent":["import '../src/ox-input-select-buttons.js'\n\nimport { html, TemplateResult } from 'lit'\n\nexport default {\n title: 'ox-input-select-buttons',\n component: 'ox-input-select-buttons',\n argTypes: {\n value: { control: 'object' },\n options: { control: 'object' },\n multiple: { control: 'boolean' },\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?: object | string\n options: object\n multiple?: boolean\n}\n\nconst Template: Story<ArgTypes> = ({ name = 'options', value, multiple = false, options = [] }: 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 ox-input-select-buttons {\n max-width: 400px;\n }\n </style>\n\n <ox-input-select-buttons\n @change=${(e: Event) => {\n console.log((e.target as HTMLInputElement).value)\n }}\n name=${name}\n .value=${value}\n .options=${options}\n ?multiple=${multiple}\n >\n </ox-input-select-buttons>\n`\n\nexport const Regular = Template.bind({})\nRegular.args = {\n name: 'options',\n value: 'Clothes',\n options: [\n { display: 'SHOOSE', value: 'Shoose' },\n { display: 'CHOTHES', value: 'Clothes' },\n { display: 'GLOVES', value: 'Gloves' }\n ]\n}\n\nexport const Multiple = Template.bind({})\nMultiple.args = {\n name: 'options',\n value: ['Clothes'],\n multiple: true,\n options: [\n { display: 'SHOOSE1', value: 'Shoose1' },\n { display: 'CHOTHES1', value: 'Clothes1' },\n { display: 'GLOVES1', value: 'Gloves1' },\n { display: 'SHOOSE2', value: 'Shoose2' },\n { display: 'CHOTHES2', value: 'Clothes2' },\n { display: 'GLOVES2', value: 'Gloves2' },\n { display: 'SHOOSE3', value: 'Shoose3' },\n { display: 'CHOTHES3', value: 'Clothes3' },\n { display: 'GLOVES3', value: 'Gloves3' },\n { display: 'SHOOSE4', value: 'Shoose4' },\n { display: 'CHOTHES4', value: 'Clothes4' },\n { display: 'GLOVES4', value: 'Gloves4' }\n ]\n}\n"]}
|
@@ -41,13 +41,14 @@ export default {
|
|
41
41
|
}
|
42
42
|
}
|
43
43
|
};
|
44
|
-
const Template = ({ placeholder = 'unit', name = 'hello', value = 0, stdUnit = 'kg' }) => html `
|
44
|
+
const Template = ({ placeholder = 'unit', name = 'hello', value = 0, stdUnit = 'kg', userUnit }) => html `
|
45
45
|
<link href="/themes/app-theme.css" rel="stylesheet" />
|
46
46
|
<ox-input-unit-number
|
47
47
|
name=${name}
|
48
48
|
placeholder=${placeholder}
|
49
49
|
.value=${value}
|
50
50
|
std-unit=${stdUnit}
|
51
|
+
user-unit=${userUnit}
|
51
52
|
@change=${(e) => console.log(e.detail)}
|
52
53
|
>
|
53
54
|
</ox-input-unit-number>
|
@@ -71,7 +72,8 @@ Temperature.args = {
|
|
71
72
|
placeholder: 'temperature',
|
72
73
|
name: 'temperature',
|
73
74
|
value: 0,
|
74
|
-
stdUnit: 'K'
|
75
|
+
stdUnit: 'K',
|
76
|
+
userUnit: 'C'
|
75
77
|
};
|
76
78
|
export const Percentage = Template.bind({});
|
77
79
|
Percentage.args = {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ox-input-unit.stories.js","sourceRoot":"","sources":["../../stories/ox-input-unit.stories.ts"],"names":[],"mappings":"AAAA,OAAO,gCAAgC,CAAA;AAEvC,OAAO,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAA;AAE1C,eAAe;IACb,KAAK,EAAE,sBAAsB;IAC7B,SAAS,EAAE,sBAAsB;IACjC,QAAQ,EAAE;QACR,WAAW,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;QAChC,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;QACzB,KAAK,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE;QAC5B,OAAO,EAAE;YACP,OAAO,EAAE,QAAQ;YACjB,OAAO,EAAE;gBACP,IAAI;gBACJ,KAAK;gBACL,GAAG;gBACH,OAAO;gBACP,IAAI;gBACJ,IAAI;gBACJ,OAAO;gBACP,OAAO;gBACP,GAAG;gBACH,IAAI;gBACJ,QAAQ;gBACR,WAAW;gBACX,SAAS;gBACT,YAAY;gBACZ,SAAS;gBACT,SAAS;gBACT,GAAG;gBACH,GAAG;gBACH,MAAM;gBACN,MAAM;gBACN,QAAQ;gBACR,OAAO;gBACP,QAAQ;gBACR,UAAU;gBACV,SAAS;gBACT,GAAG;gBACH,GAAG;aACJ;SACF;KACF;CACF,CAAA;
|
1
|
+
{"version":3,"file":"ox-input-unit.stories.js","sourceRoot":"","sources":["../../stories/ox-input-unit.stories.ts"],"names":[],"mappings":"AAAA,OAAO,gCAAgC,CAAA;AAEvC,OAAO,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAA;AAE1C,eAAe;IACb,KAAK,EAAE,sBAAsB;IAC7B,SAAS,EAAE,sBAAsB;IACjC,QAAQ,EAAE;QACR,WAAW,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;QAChC,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;QACzB,KAAK,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE;QAC5B,OAAO,EAAE;YACP,OAAO,EAAE,QAAQ;YACjB,OAAO,EAAE;gBACP,IAAI;gBACJ,KAAK;gBACL,GAAG;gBACH,OAAO;gBACP,IAAI;gBACJ,IAAI;gBACJ,OAAO;gBACP,OAAO;gBACP,GAAG;gBACH,IAAI;gBACJ,QAAQ;gBACR,WAAW;gBACX,SAAS;gBACT,YAAY;gBACZ,SAAS;gBACT,SAAS;gBACT,GAAG;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AAC3C,UAAU,CAAC,IAAI,GAAG;IAChB,WAAW,EAAE,YAAY;IACzB,IAAI,EAAE,YAAY;IAClB,KAAK,EAAE,CAAC;IACR,OAAO,EAAE,GAAG;CACb,CAAA","sourcesContent":["import '../src/ox-input-unit-number.js'\n\nimport { html, TemplateResult } from 'lit'\n\nexport default {\n title: 'ox-input-unit-number',\n component: 'ox-input-unit-number',\n argTypes: {\n placeholder: { control: 'text' },\n name: { control: 'text' },\n value: { control: 'number' },\n stdUnit: {\n control: 'select',\n options: [\n 'kg',\n 'rad',\n 'm',\n 'g/mol',\n 'm2',\n 'm3',\n 'kg/m3',\n 'm/sec',\n 'N',\n 'Pa',\n 'kg/sec',\n 'kg/m2/sec',\n 'mol/sec',\n 'mol/m2/sec',\n 'Sm3/sec',\n 'Nm3/sec',\n 'J',\n 'W',\n 'W/m2',\n 'J/kg',\n 'J/kg/K',\n 'W/m/K',\n 'W/m2/K',\n 'N sec/m2',\n 'm2 oC/W',\n '%',\n 'K'\n ]\n }\n }\n}\n\ninterface Story<T> {\n (args: T): TemplateResult\n args?: Partial<T>\n argTypes?: Record<string, unknown>\n}\n\ninterface ArgTypes {\n placeholder?: string\n name?: string\n value?: number\n stdUnit: string\n userUnit: string\n}\n\nconst Template: Story<ArgTypes> = ({\n placeholder = 'unit',\n name = 'hello',\n value = 0,\n stdUnit = 'kg',\n userUnit\n}: ArgTypes) => html`\n <link href=\"/themes/app-theme.css\" rel=\"stylesheet\" />\n <ox-input-unit-number\n name=${name}\n placeholder=${placeholder}\n .value=${value}\n std-unit=${stdUnit}\n user-unit=${userUnit}\n @change=${(e: CustomEvent) => console.log(e.detail)}\n >\n </ox-input-unit-number>\n`\n\nexport const Weight = Template.bind({})\nWeight.args = {\n placeholder: 'weight',\n name: 'weight',\n value: 0,\n stdUnit: 'kg'\n}\n\nexport const Angle = Template.bind({})\nAngle.args = {\n placeholder: 'angle',\n name: 'angle',\n value: 0,\n stdUnit: 'rad'\n}\n\nexport const Temperature = Template.bind({})\nTemperature.args = {\n placeholder: 'temperature',\n name: 'temperature',\n value: 0,\n stdUnit: 'K',\n userUnit: 'C'\n}\n\nexport const Percentage = Template.bind({})\nPercentage.args = {\n placeholder: 'percentage',\n name: 'percentage',\n value: 0,\n stdUnit: '%'\n}\n"]}
|