@operato/contact 1.1.66 → 1.1.68
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 +20 -0
- package/demo/index.html +2 -6
- package/dist/src/ox-contact-edit.d.ts +5 -3
- package/dist/src/ox-contact-edit.js +25 -37
- package/dist/src/ox-contact-edit.js.map +1 -1
- package/dist/src/ox-contact-view.js +9 -12
- package/dist/src/ox-contact-view.js.map +1 -1
- package/dist/src/ox-contact.d.ts +8 -5
- package/dist/src/ox-contact.js +42 -21
- package/dist/src/ox-contact.js.map +1 -1
- package/dist/src/ox-pfp-edit.js +13 -10
- package/dist/src/ox-pfp-edit.js.map +1 -1
- package/dist/src/ox-pfp-view.d.ts +1 -0
- package/dist/src/ox-pfp-view.js.map +1 -1
- package/dist/src/ox-pfp.js +6 -4
- package/dist/src/ox-pfp.js.map +1 -1
- package/dist/stories/ox-contact.stories.js +2 -6
- package/dist/stories/ox-contact.stories.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -3
- package/src/ox-contact-edit.ts +21 -40
- package/src/ox-contact-view.ts +9 -17
- package/src/ox-contact.ts +56 -25
- package/src/ox-pfp-edit.ts +14 -10
- package/src/ox-pfp-view.ts +1 -0
- package/src/ox-pfp.ts +6 -4
- package/stories/ox-contact.stories.ts +2 -6
package/src/ox-contact-view.ts
CHANGED
|
@@ -79,7 +79,7 @@ export class OxContactView extends LitElement {
|
|
|
79
79
|
@property({ type: Object }) contact: Contact = {}
|
|
80
80
|
|
|
81
81
|
render() {
|
|
82
|
-
const { profile, items = [], note } = this.contact || {}
|
|
82
|
+
const { profile, items = [], name, company, note } = this.contact || {}
|
|
83
83
|
var sorted: { [type: string]: ContactItem[] } = {}
|
|
84
84
|
|
|
85
85
|
items.forEach(item => {
|
|
@@ -90,28 +90,20 @@ export class OxContactView extends LitElement {
|
|
|
90
90
|
}
|
|
91
91
|
})
|
|
92
92
|
|
|
93
|
-
const names = sorted[ContactField.Name] || []
|
|
94
|
-
const companies = sorted[ContactField.Company] || []
|
|
95
|
-
|
|
96
93
|
return html`
|
|
97
94
|
<div name>
|
|
98
|
-
<ox-pfp-view .profile=${profile} .name=${
|
|
95
|
+
<ox-pfp-view .profile=${profile} .name=${name}></ox-pfp-view>
|
|
99
96
|
|
|
100
97
|
<div name-content>
|
|
101
|
-
|
|
102
|
-
item
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
${companies.map(
|
|
108
|
-
item =>
|
|
109
|
-
html`<div>
|
|
110
|
-
<span data-item="value">${item.value}</span>
|
|
111
|
-
</div>`
|
|
112
|
-
)}
|
|
98
|
+
<div>
|
|
99
|
+
<span data-item="value">${name}</span>
|
|
100
|
+
</div>
|
|
101
|
+
<div>
|
|
102
|
+
<span data-item="value">${company}</span>
|
|
103
|
+
</div>
|
|
113
104
|
</div>
|
|
114
105
|
</div>
|
|
106
|
+
|
|
115
107
|
${['email', 'phone', 'address', 'company', 'etc']
|
|
116
108
|
.map(type => sorted[type])
|
|
117
109
|
.filter(items => items && items.length > 0)
|
package/src/ox-contact.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
import './ox-contact-edit.js'
|
|
2
|
+
import './ox-contact-view.js'
|
|
3
|
+
|
|
1
4
|
import { html, css, LitElement } from 'lit'
|
|
2
|
-
import { customElement, property, state } from 'lit/decorators.js'
|
|
3
|
-
|
|
4
|
-
import '
|
|
5
|
+
import { customElement, property, query, state } from 'lit/decorators.js'
|
|
6
|
+
|
|
7
|
+
import { ButtonContainerStyles } from '@operato/styles'
|
|
8
|
+
|
|
9
|
+
import { OxContactEdit } from './ox-contact-edit.js'
|
|
5
10
|
import { Profile } from './ox-pfp-view.js'
|
|
6
11
|
|
|
7
12
|
export enum ContactField {
|
|
8
|
-
Name = 'name',
|
|
9
13
|
JobTitle = 'job-title',
|
|
10
14
|
Phone = 'phone',
|
|
11
15
|
Address = 'address',
|
|
@@ -14,7 +18,6 @@ export enum ContactField {
|
|
|
14
18
|
Profile = 'profile',
|
|
15
19
|
Picture = 'picture',
|
|
16
20
|
Department = 'department',
|
|
17
|
-
Company = 'company',
|
|
18
21
|
Homepage = 'homepage'
|
|
19
22
|
}
|
|
20
23
|
|
|
@@ -33,39 +36,67 @@ export type ContactItem = {
|
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
export type Contact = {
|
|
39
|
+
id?: string
|
|
36
40
|
profile?: Profile
|
|
41
|
+
name?: string
|
|
42
|
+
company?: string
|
|
37
43
|
items?: ContactItem[]
|
|
38
44
|
note?: string
|
|
39
45
|
}
|
|
40
46
|
|
|
41
47
|
@customElement('ox-contact')
|
|
42
48
|
export class OxContact extends LitElement {
|
|
43
|
-
static styles =
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
static styles = [
|
|
50
|
+
ButtonContainerStyles,
|
|
51
|
+
css`
|
|
52
|
+
:host {
|
|
53
|
+
display: flex;
|
|
54
|
+
flex-direction: column;
|
|
55
|
+
background-color: var(--main-section-background-color);
|
|
56
|
+
}
|
|
47
57
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
58
|
+
ox-contact-view,
|
|
59
|
+
ox-contact-edit {
|
|
60
|
+
padding: var(--pading-default);
|
|
61
|
+
flex: 1;
|
|
62
|
+
}
|
|
63
|
+
`
|
|
64
|
+
]
|
|
53
65
|
|
|
54
66
|
@property({ type: Object }) contact: Contact = {}
|
|
55
67
|
|
|
56
68
|
@state() editMode?: boolean = false
|
|
57
69
|
|
|
70
|
+
@query('ox-contact-edit') editor!: OxContactEdit
|
|
71
|
+
|
|
58
72
|
render() {
|
|
59
|
-
return html
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
73
|
+
return html`
|
|
74
|
+
<div container>
|
|
75
|
+
${
|
|
76
|
+
this.editMode
|
|
77
|
+
? html`<ox-contact-edit
|
|
78
|
+
.contact=${this.contact}
|
|
79
|
+
@edit-cancel=${() => (this.editMode = false)}
|
|
80
|
+
@edit-done=${(e: CustomEvent) => {
|
|
81
|
+
this.contact = e.detail
|
|
82
|
+
this.editMode = false
|
|
83
|
+
}}
|
|
84
|
+
></ox-contact-edit>`
|
|
85
|
+
: html` <ox-contact-view .contact=${this.contact}></ox-contact-view> `
|
|
86
|
+
}
|
|
87
|
+
</div>
|
|
88
|
+
|
|
89
|
+
<div class="button-container">
|
|
90
|
+
${
|
|
91
|
+
this.editMode
|
|
92
|
+
? html`
|
|
93
|
+
<button value="Done" @click=${() => this.editor.save()}>Done</button>
|
|
94
|
+
<button value="Cancel" @click=${() => this.editor.cancel()}>Cancel</button>
|
|
95
|
+
<button value="Reset" @click=${() => this.editor.reset()}>Reset</button>
|
|
96
|
+
`
|
|
97
|
+
: html` <button value="Edit" @click=${() => (this.editMode = true)}>Edit</button> `
|
|
98
|
+
}
|
|
99
|
+
</div>
|
|
100
|
+
</div>`
|
|
70
101
|
}
|
|
71
102
|
}
|
package/src/ox-pfp-edit.ts
CHANGED
|
@@ -62,7 +62,6 @@ export class OxPfpEdit extends LitElement {
|
|
|
62
62
|
right: 0;
|
|
63
63
|
width: 100%;
|
|
64
64
|
height: 100%;
|
|
65
|
-
z-index: -1;
|
|
66
65
|
background-repeat: no-repeat;
|
|
67
66
|
background-image: var(
|
|
68
67
|
--background-image,
|
|
@@ -133,6 +132,7 @@ export class OxPfpEdit extends LitElement {
|
|
|
133
132
|
@query('[circle]') circle!: HTMLDivElement
|
|
134
133
|
|
|
135
134
|
private dragStart?: { x: number; y: number }
|
|
135
|
+
|
|
136
136
|
private dragEndHandler = this.onDragEnd.bind(this) as EventListener
|
|
137
137
|
private dragMoveHandler = this.onDragMove.bind(this) as EventListener
|
|
138
138
|
private dragStartHandler = this.onDragStart.bind(this) as EventListener
|
|
@@ -193,7 +193,7 @@ export class OxPfpEdit extends LitElement {
|
|
|
193
193
|
capture="environment"
|
|
194
194
|
@change=${(e: Event) => this.onChangeFile(e)}
|
|
195
195
|
/>
|
|
196
|
-
<mwc-icon>image_search</mwc-icon>
|
|
196
|
+
<mwc-icon title="select image">image_search</mwc-icon>
|
|
197
197
|
</label>
|
|
198
198
|
</div>
|
|
199
199
|
|
|
@@ -202,12 +202,12 @@ export class OxPfpEdit extends LitElement {
|
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
updated(changes: PropertyValues<this>) {
|
|
205
|
-
const { picture, zoom = 1, left = 0, top = 0 } = this.profile
|
|
205
|
+
const { picture, zoom = 1, left = 0, top = 0 } = this.profile || {}
|
|
206
206
|
|
|
207
207
|
if (picture) {
|
|
208
208
|
const style = this.style
|
|
209
209
|
|
|
210
|
-
style.setProperty('--background-image', `url(${picture})`)
|
|
210
|
+
style.setProperty('--background-image', `url('${picture}')`)
|
|
211
211
|
style.setProperty('--image-transform', `translate(${left}%, ${top}%) scale(${zoom}, ${zoom})`)
|
|
212
212
|
}
|
|
213
213
|
}
|
|
@@ -225,12 +225,13 @@ export class OxPfpEdit extends LitElement {
|
|
|
225
225
|
|
|
226
226
|
var delta = Math.max(-1, Math.min(1, (e as WheelEvent).deltaY || -(e as WheelEvent).detail))
|
|
227
227
|
|
|
228
|
-
const { top = 0, left = 0, zoom = 1, picture } = this.profile
|
|
228
|
+
const { top = 0, left = 0, zoom = 1, picture, file } = this.profile || {}
|
|
229
229
|
this.profile = {
|
|
230
230
|
top,
|
|
231
231
|
left,
|
|
232
232
|
zoom: zoom * (1 - delta / 20),
|
|
233
|
-
picture
|
|
233
|
+
picture,
|
|
234
|
+
file
|
|
234
235
|
}
|
|
235
236
|
|
|
236
237
|
this.dispatchEvent(
|
|
@@ -272,14 +273,15 @@ export class OxPfpEdit extends LitElement {
|
|
|
272
273
|
|
|
273
274
|
this.dragStart = dragStart
|
|
274
275
|
|
|
275
|
-
const { top = 0, left = 0, zoom = 1, picture } = this.profile
|
|
276
|
+
const { top = 0, left = 0, zoom = 1, picture, file } = this.profile || {}
|
|
276
277
|
const { offsetHeight, offsetWidth } = this
|
|
277
278
|
|
|
278
279
|
this.profile = {
|
|
279
280
|
top: top + (y / offsetHeight) * 100,
|
|
280
281
|
left: left + (x / offsetWidth) * 100,
|
|
281
282
|
zoom,
|
|
282
|
-
picture
|
|
283
|
+
picture,
|
|
284
|
+
file
|
|
283
285
|
}
|
|
284
286
|
|
|
285
287
|
this.dispatchEvent(
|
|
@@ -313,7 +315,8 @@ export class OxPfpEdit extends LitElement {
|
|
|
313
315
|
left: 0,
|
|
314
316
|
top: 0,
|
|
315
317
|
zoom: 1,
|
|
316
|
-
picture
|
|
318
|
+
picture,
|
|
319
|
+
file: imageFile
|
|
317
320
|
}
|
|
318
321
|
}
|
|
319
322
|
|
|
@@ -330,7 +333,8 @@ export class OxPfpEdit extends LitElement {
|
|
|
330
333
|
left: 0,
|
|
331
334
|
top: 0,
|
|
332
335
|
zoom: 1,
|
|
333
|
-
picture
|
|
336
|
+
picture,
|
|
337
|
+
file: imageFile
|
|
334
338
|
}
|
|
335
339
|
|
|
336
340
|
fileInput.files = null
|
package/src/ox-pfp-view.ts
CHANGED
package/src/ox-pfp.ts
CHANGED
|
@@ -34,6 +34,7 @@ export class OxPfp extends LitElement {
|
|
|
34
34
|
|
|
35
35
|
mwc-icon-button {
|
|
36
36
|
position: absolute;
|
|
37
|
+
font-size: smaller;
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
mwc-icon-button[icon='fit_screen'] {
|
|
@@ -72,9 +73,10 @@ export class OxPfp extends LitElement {
|
|
|
72
73
|
render() {
|
|
73
74
|
return this.editMode
|
|
74
75
|
? html`<ox-pfp-edit .profile=${this.profile} name=${this.name || ''}>
|
|
75
|
-
<mwc-icon-button icon="fit_screen" @click=${() => this.edit.fit()}></mwc-icon-button>
|
|
76
|
-
<mwc-icon-button icon="clear" @click=${() => this.edit.clear()}></mwc-icon-button>
|
|
76
|
+
<mwc-icon-button title="fit size" icon="fit_screen" @click=${() => this.edit.fit()}></mwc-icon-button>
|
|
77
|
+
<mwc-icon-button title="clear" icon="clear" @click=${() => this.edit.clear()}></mwc-icon-button>
|
|
77
78
|
<mwc-icon-button
|
|
79
|
+
title="save"
|
|
78
80
|
icon="save"
|
|
79
81
|
@click=${() => {
|
|
80
82
|
this.profile = this.edit.profile
|
|
@@ -86,11 +88,11 @@ export class OxPfp extends LitElement {
|
|
|
86
88
|
)
|
|
87
89
|
}}
|
|
88
90
|
></mwc-icon-button>
|
|
89
|
-
<mwc-icon-button icon="cancel" @click=${() => (this.editMode = false)}></mwc-icon-button>
|
|
91
|
+
<mwc-icon-button title="cancel" icon="cancel" @click=${() => (this.editMode = false)}></mwc-icon-button>
|
|
90
92
|
</ox-pfp-edit> `
|
|
91
93
|
: html`
|
|
92
94
|
<ox-pfp-view .profile=${this.profile} name=${this.name || ''}>
|
|
93
|
-
<mwc-icon-button icon="edit" @click=${() => (this.editMode = true)}></mwc-icon-button>
|
|
95
|
+
<mwc-icon-button title="edit" icon="edit" @click=${() => (this.editMode = true)}></mwc-icon-button>
|
|
94
96
|
</ox-pfp-view>
|
|
95
97
|
`
|
|
96
98
|
}
|
|
@@ -38,13 +38,9 @@ export const Regular = Template.bind({})
|
|
|
38
38
|
Regular.args = {
|
|
39
39
|
contact: {
|
|
40
40
|
note: 'abcdefg',
|
|
41
|
+
name: '남 상혁',
|
|
42
|
+
company: 'Hatiolab',
|
|
41
43
|
items: [
|
|
42
|
-
{
|
|
43
|
-
id: '1',
|
|
44
|
-
type: ContactField.Name,
|
|
45
|
-
label: 'name',
|
|
46
|
-
value: '남 상혁'
|
|
47
|
-
},
|
|
48
44
|
{
|
|
49
45
|
id: '2',
|
|
50
46
|
type: ContactField.Phone,
|