@operato/property-editor 0.1.19 → 0.2.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/.storybook/main.js +2 -2
  2. package/.storybook/server.mjs +4 -4
  3. package/CHANGELOG.md +16 -1
  4. package/LICENSE +2 -2
  5. package/README.md +26 -7
  6. package/custom-elements.json +317 -0
  7. package/demo/index.html +18 -4
  8. package/dist/src/index.d.ts +1 -3
  9. package/dist/src/index.js +1 -3
  10. package/dist/src/index.js.map +1 -1
  11. package/dist/src/ox-property-editor.d.ts +28 -0
  12. package/dist/src/ox-property-editor.js +161 -0
  13. package/dist/src/ox-property-editor.js.map +1 -0
  14. package/dist/stories/index.stories.d.ts +1 -1
  15. package/dist/stories/index.stories.js +11 -15
  16. package/dist/stories/index.stories.js.map +1 -1
  17. package/dist/test/property-editor.test.d.ts +1 -0
  18. package/dist/test/property-editor.test.js +24 -0
  19. package/dist/test/property-editor.test.js.map +1 -0
  20. package/dist/tsconfig.tsbuildinfo +1 -1
  21. package/package.json +14 -33
  22. package/src/index.ts +1 -3
  23. package/src/ox-property-editor.ts +158 -0
  24. package/stories/index.stories.ts +30 -38
  25. package/test/property-editor.test.ts +34 -0
  26. package/tsconfig.json +2 -2
  27. package/web-dev-server.config.mjs +9 -8
  28. package/web-test-runner.config.mjs +7 -19
  29. package/.editorconfig +0 -29
  30. package/demo/index-3dish.html +0 -22
  31. package/demo/index-angle.html +0 -31
  32. package/demo/index-button-radio.html +0 -30
  33. package/dist/src/property-3dish.d.ts +0 -30
  34. package/dist/src/property-3dish.js +0 -140
  35. package/dist/src/property-3dish.js.map +0 -1
  36. package/dist/src/property-angle.d.ts +0 -14
  37. package/dist/src/property-angle.js +0 -56
  38. package/dist/src/property-angle.js.map +0 -1
  39. package/dist/src/property-buttons-radio.d.ts +0 -28
  40. package/dist/src/property-buttons-radio.js +0 -90
  41. package/dist/src/property-buttons-radio.js.map +0 -1
  42. package/dist/src/property-stack.d.ts +0 -21
  43. package/dist/src/property-stack.js +0 -108
  44. package/dist/src/property-stack.js.map +0 -1
  45. package/dist/test/property-angle.test.d.ts +0 -1
  46. package/dist/test/property-angle.test.js +0 -23
  47. package/dist/test/property-angle.test.js.map +0 -1
  48. package/src/property-3dish.ts +0 -150
  49. package/src/property-angle.ts +0 -56
  50. package/src/property-buttons-radio.ts +0 -87
  51. package/src/property-stack.ts +0 -109
  52. package/test/property-angle.test.ts +0 -32
@@ -0,0 +1,158 @@
1
+ import { LitElement, css, html } from 'lit'
2
+ import { property, state } from 'lit/decorators.js'
3
+
4
+ import deepClone from 'lodash/cloneDeep'
5
+
6
+ export class OxPropertyEditor extends LitElement {
7
+ static registry: { [type: string]: string } = {}
8
+
9
+ public static register(types: { [type: string]: string }) {
10
+ Object.keys(types).forEach(type => {
11
+ OxPropertyEditor.registry[type] = types[type]
12
+ })
13
+ }
14
+
15
+ public static getEditor(type: string): string {
16
+ return OxPropertyEditor.registry[type]
17
+ }
18
+
19
+ static styles = [
20
+ css`
21
+ :host {
22
+ margin: 5px;
23
+
24
+ display: grid;
25
+ grid-template-columns: repeat(10, 1fr);
26
+ grid-gap: 5px;
27
+
28
+ align-items: center;
29
+
30
+ color: var(--property-sidebar-fieldset-legend-color);
31
+ }
32
+
33
+ :host > * {
34
+ box-sizing: border-box;
35
+
36
+ grid-column: span 7;
37
+ order: 2;
38
+
39
+ align-self: stretch;
40
+ }
41
+
42
+ :host > label {
43
+ grid-column: span 3;
44
+ order: 1;
45
+
46
+ text-align: right;
47
+
48
+ font-size: 0.8em;
49
+ line-height: 2;
50
+ text-transform: capitalize;
51
+
52
+ align-self: center;
53
+ }
54
+
55
+ :host > input[type='checkbox'] ~ label {
56
+ grid-column: span 6;
57
+ order: 2;
58
+
59
+ text-align: left;
60
+ }
61
+
62
+ :host > select,
63
+ :host > input[type='text'],
64
+ :host > input[type='number'] {
65
+ border: 1px solid rgba(0, 0, 0, 0.2);
66
+ }
67
+
68
+ :host > legend {
69
+ grid-column: 1 / -1;
70
+
71
+ display: inline-block;
72
+
73
+ text-align: left;
74
+ text-transform: capitalize;
75
+ }
76
+
77
+ :host > [fullwidth] {
78
+ grid-column: 1 / -1;
79
+ }
80
+
81
+ :host > input[type='checkbox'] {
82
+ grid-column: span 4;
83
+ order: 1;
84
+
85
+ justify-self: end;
86
+ align-self: center;
87
+ }
88
+ `
89
+ ]
90
+
91
+ @property({ type: Object }) value: any
92
+ @property({ type: String }) type!: string
93
+ @property({ type: String }) label!: string
94
+ @property({ type: String }) placeholder?: string
95
+ @property({ type: Object }) property: any
96
+ @property({ type: Object }) host: any
97
+ @property({ type: Object }) observe?: (value: any) => void
98
+
99
+ connectedCallback() {
100
+ super.connectedCallback()
101
+
102
+ this.renderRoot.addEventListener('change', this._valueChanged.bind(this))
103
+ }
104
+
105
+ editorTemplate(props: { [key: string]: any }) {
106
+ return html``
107
+ }
108
+
109
+ render() {
110
+ return html`
111
+ ${this.editorTemplate(this)}
112
+ ${this.label
113
+ ? html`
114
+ <label for="editor">
115
+ <i18n-msg msgid=${this._computeLabelId(this.label)}>${this.label}</i18n-msg>
116
+ </label>
117
+ `
118
+ : html``}
119
+ `
120
+ }
121
+
122
+ @state() __by_me = false
123
+
124
+ shouldUpdate(changedProperties: any) {
125
+ if (this.__by_me) {
126
+ return false
127
+ }
128
+
129
+ if (changedProperties.has('value')) {
130
+ this.__by_me = true
131
+ this.value = deepClone(this.value)
132
+ this.__by_me = false
133
+ }
134
+
135
+ return true
136
+ }
137
+
138
+ get valueProperty() {
139
+ return 'value'
140
+ }
141
+
142
+ _computeLabelId(label: string) {
143
+ if (label.indexOf('label.') >= 0) return label
144
+
145
+ return 'label.' + label
146
+ }
147
+
148
+ _valueChanged(e: Event) {
149
+ e.stopPropagation()
150
+
151
+ this.value = deepClone((e.target as any)[this.valueProperty])
152
+
153
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
154
+
155
+ if (!this.observe) return
156
+ this.observe.call(this, this.value)
157
+ }
158
+ }
@@ -1,60 +1,52 @@
1
- import { html, TemplateResult } from 'lit';
2
- import '../src/property-editor.js';
1
+ import '../index.js'
2
+
3
+ import { TemplateResult, html } from 'lit'
3
4
 
4
5
  export default {
5
6
  title: 'PropertyEditor',
6
- component: 'property-editor',
7
+ component: 'ox-property-editor',
7
8
  argTypes: {
8
9
  title: { control: 'text' },
9
10
  counter: { control: 'number' },
10
- textColor: { control: 'color' },
11
- },
12
- };
11
+ textColor: { control: 'color' }
12
+ }
13
+ }
13
14
 
14
15
  interface Story<T> {
15
- (args: T): TemplateResult;
16
- args?: Partial<T>;
17
- argTypes?: Record<string, unknown>;
16
+ (args: T): TemplateResult
17
+ args?: Partial<T>
18
+ argTypes?: Record<string, unknown>
18
19
  }
19
20
 
20
21
  interface ArgTypes {
21
- title?: string;
22
- counter?: number;
23
- textColor?: string;
24
- slot?: TemplateResult;
22
+ title?: string
23
+ counter?: number
24
+ textColor?: string
25
+ slot?: TemplateResult
25
26
  }
26
27
 
27
- const Template: Story<ArgTypes> = ({
28
- title = 'Hello world',
29
- counter = 5,
30
- textColor,
31
- slot,
32
- }: ArgTypes) => html`
33
- <property-editor
34
- style="--property-editor-text-color: ${textColor || 'black'}"
35
- .title=${title}
36
- .counter=${counter}
37
- >
28
+ const Template: Story<ArgTypes> = ({ title = 'Hello world', counter = 5, textColor, slot }: ArgTypes) => html`
29
+ <ox-board-viewer style="--board-viewer-text-color: ${textColor || 'black'}" .title=${title} .counter=${counter}>
38
30
  ${slot}
39
- </property-editor>
40
- `;
31
+ </ox-board-viewer>
32
+ `
41
33
 
42
- export const Regular = Template.bind({});
34
+ export const Regular = Template.bind({})
43
35
 
44
- export const CustomTitle = Template.bind({});
36
+ export const CustomTitle = Template.bind({})
45
37
  CustomTitle.args = {
46
- title: 'My title',
47
- };
38
+ title: 'My title'
39
+ }
48
40
 
49
- export const CustomCounter = Template.bind({});
41
+ export const CustomCounter = Template.bind({})
50
42
  CustomCounter.args = {
51
- counter: 123456,
52
- };
43
+ counter: 123456
44
+ }
53
45
 
54
- export const SlottedContent = Template.bind({});
46
+ export const SlottedContent = Template.bind({})
55
47
  SlottedContent.args = {
56
- slot: html`<p>Slotted content</p>`,
57
- };
48
+ slot: html`<p>Slotted content</p>`
49
+ }
58
50
  SlottedContent.argTypes = {
59
- slot: { table: { disable: true } },
60
- };
51
+ slot: { table: { disable: true } }
52
+ }
@@ -0,0 +1,34 @@
1
+ import '../src/ox-property-editor'
2
+
3
+ import { expect, fixture } from '@open-wc/testing'
4
+
5
+ import { OxPropertyEditor } from '../src/ox-property-editor'
6
+ import { html } from 'lit'
7
+
8
+ describe('OxPropertyEditor', () => {
9
+ it('has a default title "Hey there" and counter 5', async () => {
10
+ const el = await fixture<OxPropertyEditor>(html` <ox-property-editor></ox-property-editor> `)
11
+
12
+ // expect(el.title).to.equal('Hey there')
13
+ // expect(el.counter).to.equal(5)
14
+ })
15
+
16
+ it('increases the counter on button click', async () => {
17
+ const el = await fixture<OxPropertyEditor>(html` <ox-property-editor></ox-property-editor> `)
18
+ el.renderRoot!.querySelector('button')!.click()
19
+
20
+ // expect(el.counter).to.equal(6)
21
+ })
22
+
23
+ it('can override the title via attribute', async () => {
24
+ const el = await fixture<OxPropertyEditor>(html` <property-editor title="attribute title"></ox-property-editor> `)
25
+
26
+ expect(el.title).to.equal('attribute title')
27
+ })
28
+
29
+ it('passes the a11y audit', async () => {
30
+ const el = await fixture<OxPropertyEditor>(html` <ox-property-editor></ox-property-editor> `)
31
+
32
+ await expect(el).shadowDom.to.be.accessible()
33
+ })
34
+ })
package/tsconfig.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "rootDir": "./",
17
17
  "declaration": true,
18
18
  "incremental": true,
19
- "types": ["node", "mocha", "three"]
19
+ "types": ["node", "mocha"]
20
20
  },
21
- "include": ["**/*.ts"]
21
+ "include": ["**/*.ts", "*.d.ts"]
22
22
  }
@@ -1,16 +1,12 @@
1
1
  // import { hmrPlugin, presets } from '@open-wc/dev-server-hmr';
2
2
 
3
3
  /** Use Hot Module replacement by adding --hmr to the start command */
4
- const hmr = process.argv.includes('--hmr');
4
+ const hmr = process.argv.includes('--hmr')
5
5
 
6
6
  export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
7
+ nodeResolve: true,
7
8
  open: '/demo/',
8
- /** Use regular watch mode if HMR is not enabled. */
9
9
  watch: !hmr,
10
- /** Resolve bare module imports */
11
- nodeResolve: {
12
- exportConditions: ['browser', 'development'],
13
- },
14
10
 
15
11
  /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
16
12
  // esbuildTarget: 'auto'
@@ -18,10 +14,15 @@ export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
18
14
  /** Set appIndex to enable SPA routing */
19
15
  // appIndex: 'demo/index.html',
20
16
 
17
+ /** Confgure bare import resolve plugin */
18
+ // nodeResolve: {
19
+ // exportConditions: ['browser', 'development']
20
+ // },
21
+
21
22
  plugins: [
22
23
  /** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */
23
24
  // hmr && hmrPlugin({ exclude: ['**/*/node_modules/**/*'], presets: [presets.litElement] }),
24
- ],
25
+ ]
25
26
 
26
27
  // See documentation for all available options
27
- });
28
+ })
@@ -1,29 +1,17 @@
1
1
  // import { playwrightLauncher } from '@web/test-runner-playwright';
2
2
 
3
- const filteredLogs = ['Running in dev mode', 'lit-html is in dev mode'];
4
-
5
3
  export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({
6
- /** Test files to run */
7
4
  files: 'dist/test/**/*.test.js',
8
-
9
- /** Resolve bare module imports */
10
- nodeResolve: {
11
- exportConditions: ['browser', 'development'],
12
- },
13
-
14
- /** Filter out lit dev mode logs */
15
- filterBrowserLogs(log) {
16
- for (const arg of log.args) {
17
- if (typeof arg === 'string' && filteredLogs.some(l => arg.includes(l))) {
18
- return false;
19
- }
20
- }
21
- return true;
22
- },
5
+ nodeResolve: true
23
6
 
24
7
  /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
25
8
  // esbuildTarget: 'auto',
26
9
 
10
+ /** Confgure bare import resolve plugin */
11
+ // nodeResolve: {
12
+ // exportConditions: ['browser', 'development']
13
+ // },
14
+
27
15
  /** Amount of browsers to run concurrently */
28
16
  // concurrentBrowsers: 2,
29
17
 
@@ -38,4 +26,4 @@ export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({
38
26
  // ],
39
27
 
40
28
  // See documentation for all available options
41
- });
29
+ })
package/.editorconfig DELETED
@@ -1,29 +0,0 @@
1
- # EditorConfig helps developers define and maintain consistent
2
- # coding styles between different editors and IDEs
3
- # editorconfig.org
4
-
5
- root = true
6
-
7
-
8
- [*]
9
-
10
- # Change these settings to your own preference
11
- indent_style = space
12
- indent_size = 2
13
-
14
- # We recommend you to keep these unchanged
15
- end_of_line = lf
16
- charset = utf-8
17
- trim_trailing_whitespace = true
18
- insert_final_newline = true
19
-
20
- [*.md]
21
- trim_trailing_whitespace = false
22
-
23
- [*.json]
24
- indent_size = 2
25
-
26
- [*.{html,js,md}]
27
- block_comment_start = /**
28
- block_comment = *
29
- block_comment_end = */
@@ -1,22 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en-GB">
3
- <head>
4
- <meta charset="utf-8" />
5
- <style>
6
- body {
7
- background: #fafafa;
8
- }
9
- </style>
10
- </head>
11
- <body>
12
- <div id="demo"></div>
13
-
14
- <script type="module">
15
- import { html, render } from 'lit'
16
- import '../dist/src/property-angle.js'
17
- import '../dist/src/property-3dish.js'
18
-
19
- render(html` <property-3dish></property-3dish> `, document.querySelector('#demo'))
20
- </script>
21
- </body>
22
- </html>
@@ -1,31 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en-GB">
3
- <head>
4
- <meta charset="utf-8" />
5
- <style>
6
- body {
7
- background: #fafafa;
8
- }
9
- </style>
10
- </head>
11
- <body>
12
- <div id="demo"></div>
13
-
14
- <script type="module">
15
- import { html, render } from 'lit'
16
- import '../dist/src/property-angle.js'
17
-
18
- const placeholder = 'enter a angle in degree'
19
- render(
20
- html`
21
- <property-angle
22
- radian="1"
23
- placeholder=${placeholder}
24
- @change=${e => console.log(e.target.radian)}
25
- ></property-angle>
26
- `,
27
- document.querySelector('#demo')
28
- )
29
- </script>
30
- </body>
31
- </html>
@@ -1,30 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en-GB">
3
- <head>
4
- <meta charset="utf-8" />
5
- <style>
6
- body {
7
- background: #fafafa;
8
- }
9
- </style>
10
- </head>
11
- <body>
12
- <div id="demo"></div>
13
-
14
- <script type="module">
15
- import { html, render } from 'lit'
16
- import '../dist/src/property-buttons-radio.js'
17
-
18
- render(
19
- html`
20
- <property-buttons-radio @change=${e => console.log(e.target.value)}>
21
- <div data-value="top">TOP</div>
22
- <div data-value="middle">MID</div>
23
- <div data-value="bottom">BOT</div>
24
- </property-buttons-radio>
25
- `,
26
- document.querySelector('#demo')
27
- )
28
- </script>
29
- </body>
30
- </html>
@@ -1,30 +0,0 @@
1
- /**
2
- * @license Copyright © HatioLab Inc. All rights reserved.
3
- */
4
- import { LitElement } from 'lit';
5
- export declare class Property3Dish extends LitElement {
6
- static styles: import("lit").CSSResult[];
7
- dimension?: {
8
- width: number;
9
- height: number;
10
- depth: number;
11
- };
12
- translatex?: {
13
- x: number;
14
- y: number;
15
- z: number;
16
- };
17
- rotate?: {
18
- x: number;
19
- y: number;
20
- z: number;
21
- };
22
- scale?: {
23
- x: number;
24
- y: number;
25
- z: number;
26
- };
27
- firstUpdated(): void;
28
- _onChange(e: Event): void;
29
- render(): import("lit-html").TemplateResult<1>;
30
- }
@@ -1,140 +0,0 @@
1
- /**
2
- * @license Copyright © HatioLab Inc. All rights reserved.
3
- */
4
- import { __decorate } from "tslib";
5
- import { LitElement, css, html } from 'lit';
6
- import { customElement, property } from 'lit/decorators.js';
7
- let Property3Dish = class Property3Dish extends LitElement {
8
- firstUpdated() {
9
- this.renderRoot.addEventListener('change', this._onChange.bind(this));
10
- }
11
- _onChange(e) {
12
- var element = e.target;
13
- var id = element.id;
14
- var prop = id.substr(1);
15
- var value = Number(element.value);
16
- switch (element.tagName) {
17
- case 'PROPERTY-ANGLE':
18
- value = Number(element.radian || 0);
19
- break;
20
- }
21
- switch (id) {
22
- case 'tx':
23
- case 'ty':
24
- case 'tz':
25
- this.dispatchEvent(new CustomEvent('translate-changed', {
26
- bubbles: true,
27
- composed: true,
28
- detail: {
29
- value: {
30
- ...this.translatex,
31
- [prop]: value
32
- }
33
- }
34
- }));
35
- break;
36
- case 'rx':
37
- case 'ry':
38
- case 'rz':
39
- this.dispatchEvent(new CustomEvent('rotate-changed', {
40
- bubbles: true,
41
- composed: true,
42
- detail: {
43
- value: {
44
- ...this.rotate,
45
- [prop]: value
46
- }
47
- }
48
- }));
49
- break;
50
- case 'sx':
51
- case 'sy':
52
- case 'sz':
53
- this.dispatchEvent(new CustomEvent('scale-changed', {
54
- bubbles: true,
55
- composed: true,
56
- detail: {
57
- value: {
58
- ...this.scale,
59
- [prop]: value
60
- }
61
- }
62
- }));
63
- break;
64
- default:
65
- // dimension
66
- this.dispatchEvent(new CustomEvent('dimension-changed', {
67
- bubbles: true,
68
- composed: true,
69
- detail: {
70
- value: {
71
- ...this.dimension,
72
- [prop]: value
73
- }
74
- }
75
- }));
76
- }
77
- }
78
- render() {
79
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
80
- return html `
81
- <span></span> <span><i18n-msg msgid="label.x-axes">x-axes</i18n-msg></span>
82
- <span><i18n-msg msgid="label.y-axes">y-axes</i18n-msg></span>
83
- <span><i18n-msg msgid="label.z-axes">z-axes</i18n-msg></span>
84
-
85
- <label><i18n-msg msgid="label.dimension">dimension</i18n-msg></label>
86
- <input type="number" id="dwidth" .value=${(_a = this.dimension) === null || _a === void 0 ? void 0 : _a.width} />
87
- <input type="number" id="dheight" .value=${(_b = this.dimension) === null || _b === void 0 ? void 0 : _b.height} />
88
- <input type="number" id="ddepth" .value=${(_c = this.dimension) === null || _c === void 0 ? void 0 : _c.depth} />
89
-
90
- <label><i18n-msg msgid="label.translate">translate</i18n-msg></label>
91
- <input type="number" id="tx" .value=${(_d = this.translatex) === null || _d === void 0 ? void 0 : _d.x} />
92
- <input type="number" id="ty" .value=${(_e = this.translatex) === null || _e === void 0 ? void 0 : _e.y} />
93
- <input type="number" id="tz" .value=${(_f = this.translatex) === null || _f === void 0 ? void 0 : _f.z} />
94
-
95
- <label><i18n-msg msgid="label.rotate">rotate</i18n-msg></label>
96
- <property-angle id="rx" .radian=${(_g = this.rotate) === null || _g === void 0 ? void 0 : _g.x}></property-angle>
97
- <property-angle id="ry" .radian=${(_h = this.rotate) === null || _h === void 0 ? void 0 : _h.y}></property-angle>
98
- <property-angle id="rz" .radian=${(_j = this.rotate) === null || _j === void 0 ? void 0 : _j.z}></property-angle>
99
- `;
100
- }
101
- };
102
- Property3Dish.styles = [
103
- css `
104
- :host {
105
- display: grid;
106
- grid-template-columns: repeat(4, minmax(50px, 1fr));
107
- grid-gap: 5px;
108
- grid-auto-rows: minmax(24px, auto);
109
- }
110
-
111
- :host > * {
112
- grid-column: span 1;
113
- }
114
-
115
- label {
116
- text-align: right;
117
- }
118
-
119
- span {
120
- text-align: center;
121
- }
122
- `
123
- ];
124
- __decorate([
125
- property({ type: Object })
126
- ], Property3Dish.prototype, "dimension", void 0);
127
- __decorate([
128
- property({ type: Object })
129
- ], Property3Dish.prototype, "translatex", void 0);
130
- __decorate([
131
- property({ type: Object })
132
- ], Property3Dish.prototype, "rotate", void 0);
133
- __decorate([
134
- property({ type: Object })
135
- ], Property3Dish.prototype, "scale", void 0);
136
- Property3Dish = __decorate([
137
- customElement('property-3dish')
138
- ], Property3Dish);
139
- export { Property3Dish };
140
- //# sourceMappingURL=property-3dish.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"property-3dish.js","sourceRoot":"","sources":["../../src/property-3dish.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IA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;AA1IQ,oBAAM,GAAG;IACd,GAAG,CAAA;;;;;;;;;;;;;;;;;;;KAmBF;CACF,CAAA;AAE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDAA6D;AAI5D;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iDAAiD;AAChD;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAA6C;AAC5C;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAA4C;AA9B5D,aAAa;IADzB,aAAa,CAAC,gBAAgB,CAAC;GACnB,aAAa,CA2IzB;SA3IY,aAAa","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport { LitElement, css, html } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { PropertyAngle } from './property-angle'\n\n@customElement('property-3dish')\nexport class Property3Dish extends LitElement {\n static styles = [\n css`\n :host {\n display: grid;\n grid-template-columns: repeat(4, minmax(50px, 1fr));\n grid-gap: 5px;\n grid-auto-rows: minmax(24px, auto);\n }\n\n :host > * {\n grid-column: span 1;\n }\n\n label {\n text-align: right;\n }\n\n span {\n text-align: center;\n }\n `\n ]\n\n @property({ type: Object }) dimension?: { width: number; height: number; depth: number }\n /*\n * translate는 고유한 html element의 attribute이므로, property는 translatex로 한다.\n */\n @property({ type: Object }) translatex?: { x: number; y: number; z: number }\n @property({ type: Object }) rotate?: { x: number; y: number; z: number }\n @property({ type: Object }) scale?: { x: number; y: number; z: number }\n\n firstUpdated() {\n this.renderRoot.addEventListener('change', this._onChange.bind(this))\n }\n\n _onChange(e: Event) {\n var element = e.target as HTMLElement\n var id = element.id\n var prop = id.substr(1)\n var value = Number((element as HTMLInputElement).value)\n\n switch (element.tagName) {\n case 'PROPERTY-ANGLE':\n value = Number((element as PropertyAngle).radian || 0)\n break\n }\n\n switch (id) {\n case 'tx':\n case 'ty':\n case 'tz':\n this.dispatchEvent(\n new CustomEvent('translate-changed', {\n bubbles: true,\n composed: true,\n detail: {\n value: {\n ...this.translatex,\n [prop]: value\n }\n }\n })\n )\n break\n\n case 'rx':\n case 'ry':\n case 'rz':\n this.dispatchEvent(\n new CustomEvent('rotate-changed', {\n bubbles: true,\n composed: true,\n detail: {\n value: {\n ...this.rotate,\n [prop]: value\n }\n }\n })\n )\n break\n\n case 'sx':\n case 'sy':\n case 'sz':\n this.dispatchEvent(\n new CustomEvent('scale-changed', {\n bubbles: true,\n composed: true,\n detail: {\n value: {\n ...this.scale,\n [prop]: value\n }\n }\n })\n )\n break\n\n default:\n // dimension\n this.dispatchEvent(\n new CustomEvent('dimension-changed', {\n bubbles: true,\n composed: true,\n detail: {\n value: {\n ...this.dimension,\n [prop]: value\n }\n }\n })\n )\n }\n }\n\n render() {\n return html`\n <span></span> <span><i18n-msg msgid=\"label.x-axes\">x-axes</i18n-msg></span>\n <span><i18n-msg msgid=\"label.y-axes\">y-axes</i18n-msg></span>\n <span><i18n-msg msgid=\"label.z-axes\">z-axes</i18n-msg></span>\n\n <label><i18n-msg msgid=\"label.dimension\">dimension</i18n-msg></label>\n <input type=\"number\" id=\"dwidth\" .value=${this.dimension?.width} />\n <input type=\"number\" id=\"dheight\" .value=${this.dimension?.height} />\n <input type=\"number\" id=\"ddepth\" .value=${this.dimension?.depth} />\n\n <label><i18n-msg msgid=\"label.translate\">translate</i18n-msg></label>\n <input type=\"number\" id=\"tx\" .value=${this.translatex?.x} />\n <input type=\"number\" id=\"ty\" .value=${this.translatex?.y} />\n <input type=\"number\" id=\"tz\" .value=${this.translatex?.z} />\n\n <label><i18n-msg msgid=\"label.rotate\">rotate</i18n-msg></label>\n <property-angle id=\"rx\" .radian=${this.rotate?.x}></property-angle>\n <property-angle id=\"ry\" .radian=${this.rotate?.y}></property-angle>\n <property-angle id=\"rz\" .radian=${this.rotate?.z}></property-angle>\n `\n }\n}\n"]}