@operato/contact 1.1.52
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/.editorconfig +29 -0
- package/.storybook/main.js +3 -0
- package/.storybook/server.mjs +8 -0
- package/CHANGELOG.md +11 -0
- package/README.md +76 -0
- package/demo/index.html +79 -0
- package/dist/src/OxContact copy.d.ts +38 -0
- package/dist/src/OxContact copy.js +194 -0
- package/dist/src/OxContact copy.js.map +1 -0
- package/dist/src/OxContact.d.ts +38 -0
- package/dist/src/OxContact.js +67 -0
- package/dist/src/OxContact.js.map +1 -0
- package/dist/src/OxContactEdit.d.ts +18 -0
- package/dist/src/OxContactEdit.js +235 -0
- package/dist/src/OxContactEdit.js.map +1 -0
- package/dist/src/OxContactView copy.d.ts +35 -0
- package/dist/src/OxContactView copy.js +143 -0
- package/dist/src/OxContactView copy.js.map +1 -0
- package/dist/src/OxContactView.d.ts +7 -0
- package/dist/src/OxContactView.js +138 -0
- package/dist/src/OxContactView.js.map +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/ox-contact copy.d.ts +1 -0
- package/dist/src/ox-contact copy.js +3 -0
- package/dist/src/ox-contact copy.js.map +1 -0
- package/dist/src/ox-contact-edit copy.d.ts +1 -0
- package/dist/src/ox-contact-edit copy.js +3 -0
- package/dist/src/ox-contact-edit copy.js.map +1 -0
- package/dist/src/ox-contact-edit.d.ts +18 -0
- package/dist/src/ox-contact-edit.js +245 -0
- package/dist/src/ox-contact-edit.js.map +1 -0
- package/dist/src/ox-contact-view.d.ts +7 -0
- package/dist/src/ox-contact-view.js +142 -0
- package/dist/src/ox-contact-view.js.map +1 -0
- package/dist/src/ox-contact.d.ts +38 -0
- package/dist/src/ox-contact.js +67 -0
- package/dist/src/ox-contact.js.map +1 -0
- package/dist/stories/index.stories.d.ts +24 -0
- package/dist/stories/index.stories.js +79 -0
- package/dist/stories/index.stories.js.map +1 -0
- package/dist/test/ox-contact.test.d.ts +1 -0
- package/dist/test/ox-contact.test.js +24 -0
- package/dist/test/ox-contact.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +79 -0
- package/src/index.ts +1 -0
- package/src/ox-contact-edit.ts +261 -0
- package/src/ox-contact-view.ts +146 -0
- package/src/ox-contact.ts +69 -0
- package/stories/index.stories.ts +92 -0
- package/test/ox-contact.test.ts +32 -0
- package/tsconfig.json +23 -0
- package/web-dev-server.config.mjs +27 -0
- package/web-test-runner.config.mjs +41 -0
package/.editorconfig
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
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 = */
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { storybookPlugin } from '@web/dev-server-storybook';
|
|
2
|
+
import baseConfig from '../web-dev-server.config.mjs';
|
|
3
|
+
|
|
4
|
+
export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
|
|
5
|
+
...baseConfig,
|
|
6
|
+
open: '/',
|
|
7
|
+
plugins: [storybookPlugin({ type: 'web-components' }), ...baseConfig.plugins],
|
|
8
|
+
});
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
### [1.1.52](https://github.com/hatiolab/operato/compare/v1.1.51...v1.1.52) (2022-12-31)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### :bug: Bug Fix
|
|
10
|
+
|
|
11
|
+
* add contact webcomponent ([f0e8cdb](https://github.com/hatiolab/operato/commit/f0e8cdb4425812cab106cee8f4c70122f37637c5))
|
package/README.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# \<ox-contact>
|
|
2
|
+
|
|
3
|
+
This webcomponent follows the [open-wc](https://github.com/open-wc/open-wc) recommendation.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i ox-contact
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```html
|
|
14
|
+
<script type="module">
|
|
15
|
+
import 'ox-contact/ox-contact.js';
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<ox-contact></ox-contact>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Linting and formatting
|
|
22
|
+
|
|
23
|
+
To scan the project for linting and formatting errors, run
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm run lint
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
To automatically fix linting and formatting errors, run
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm run format
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Testing with Web Test Runner
|
|
36
|
+
|
|
37
|
+
To execute a single test run:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm run test
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
To run the tests in interactive watch mode run:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npm run test:watch
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Demoing with Storybook
|
|
50
|
+
|
|
51
|
+
To run a local instance of Storybook for your component, run
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npm run storybook
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
To build a production version of Storybook, run
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
npm run storybook:build
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
## Tooling configs
|
|
65
|
+
|
|
66
|
+
For most of the tools, the configuration is in the `package.json` to reduce the amount of files in your project.
|
|
67
|
+
|
|
68
|
+
If you customize the configuration a lot, you can consider moving them to individual files.
|
|
69
|
+
|
|
70
|
+
## Local Demo with `web-dev-server`
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
npm start
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
To run a local development server that serves the basic demo located in `demo/index.html`
|
package/demo/index.html
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet" />
|
|
11
|
+
<link href="https://fonts.googleapis.com/css?family=Material+Icons&display=block" rel="stylesheet" />
|
|
12
|
+
</head>
|
|
13
|
+
<body>
|
|
14
|
+
<div id="demo"></div>
|
|
15
|
+
|
|
16
|
+
<script type="module">
|
|
17
|
+
import { html, render } from 'lit'
|
|
18
|
+
import '@material/mwc-icon'
|
|
19
|
+
import '@material/mwc-icon-button'
|
|
20
|
+
|
|
21
|
+
import '../dist/src/ox-contact.js'
|
|
22
|
+
|
|
23
|
+
var contact = {
|
|
24
|
+
items: [
|
|
25
|
+
{
|
|
26
|
+
id: '1',
|
|
27
|
+
type: 'name',
|
|
28
|
+
label: 'name',
|
|
29
|
+
value: '남 상혁'
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
id: '2',
|
|
33
|
+
type: 'phone',
|
|
34
|
+
label: 'home',
|
|
35
|
+
value: '010-1223-3443'
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
id: '3',
|
|
39
|
+
type: 'phone',
|
|
40
|
+
label: 'mobile',
|
|
41
|
+
value: '010-1122-3344'
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
id: '4',
|
|
45
|
+
type: 'email',
|
|
46
|
+
label: 'work',
|
|
47
|
+
value: 'heartyoh@hatiolab.com'
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
id: '5',
|
|
51
|
+
type: 'email',
|
|
52
|
+
label: 'home',
|
|
53
|
+
value: 'shnam2k@gmail.com'
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: '6',
|
|
57
|
+
type: 'address',
|
|
58
|
+
label: 'home',
|
|
59
|
+
value: '경기도 성남시 분당구 123'
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
id: '7',
|
|
63
|
+
type: 'address',
|
|
64
|
+
label: 'work',
|
|
65
|
+
value: '경기도 성남시 분당구 234'
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
id: '8',
|
|
69
|
+
type: 'address',
|
|
70
|
+
label: 'work',
|
|
71
|
+
value: '서울특별시 종로구 123'
|
|
72
|
+
}
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
render(html` <ox-contact .contact=${contact}> some light-dom </ox-contact> `, document.querySelector('#demo'))
|
|
77
|
+
</script>
|
|
78
|
+
</body>
|
|
79
|
+
</html>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
export declare enum ContactField {
|
|
3
|
+
Name = "name",
|
|
4
|
+
JobTitle = "job-title",
|
|
5
|
+
Phone = "phone",
|
|
6
|
+
Address = "address",
|
|
7
|
+
Email = "email",
|
|
8
|
+
Birthday = "birthday",
|
|
9
|
+
Profile = "profile",
|
|
10
|
+
Picture = "picture",
|
|
11
|
+
Department = "department",
|
|
12
|
+
Company = "company",
|
|
13
|
+
Homepage = "homepage"
|
|
14
|
+
}
|
|
15
|
+
export declare enum ContactLabel {
|
|
16
|
+
home = "home",
|
|
17
|
+
work = "work",
|
|
18
|
+
other = "other",
|
|
19
|
+
mobile = "mobile"
|
|
20
|
+
}
|
|
21
|
+
export type ContactItem = {
|
|
22
|
+
id?: string;
|
|
23
|
+
type: ContactField;
|
|
24
|
+
label: string;
|
|
25
|
+
value: string;
|
|
26
|
+
};
|
|
27
|
+
export type Contact = {
|
|
28
|
+
items?: ContactItem[];
|
|
29
|
+
note?: string;
|
|
30
|
+
};
|
|
31
|
+
export declare class OxContact extends LitElement {
|
|
32
|
+
static styles: import("lit").CSSResult;
|
|
33
|
+
contact: Contact;
|
|
34
|
+
editMode?: boolean;
|
|
35
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
36
|
+
onAddItem(type: ContactField): void;
|
|
37
|
+
onChangeItem(e: Event, item: ContactItem): void;
|
|
38
|
+
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { html, css, LitElement } from 'lit';
|
|
3
|
+
import { property, state } from 'lit/decorators.js';
|
|
4
|
+
export var ContactField;
|
|
5
|
+
(function (ContactField) {
|
|
6
|
+
ContactField["Name"] = "name";
|
|
7
|
+
ContactField["JobTitle"] = "job-title";
|
|
8
|
+
ContactField["Phone"] = "phone";
|
|
9
|
+
ContactField["Address"] = "address";
|
|
10
|
+
ContactField["Email"] = "email";
|
|
11
|
+
ContactField["Birthday"] = "birthday";
|
|
12
|
+
ContactField["Profile"] = "profile";
|
|
13
|
+
ContactField["Picture"] = "picture";
|
|
14
|
+
ContactField["Department"] = "department";
|
|
15
|
+
ContactField["Company"] = "company";
|
|
16
|
+
ContactField["Homepage"] = "homepage";
|
|
17
|
+
})(ContactField || (ContactField = {}));
|
|
18
|
+
export var ContactLabel;
|
|
19
|
+
(function (ContactLabel) {
|
|
20
|
+
ContactLabel["home"] = "home";
|
|
21
|
+
ContactLabel["work"] = "work";
|
|
22
|
+
ContactLabel["other"] = "other";
|
|
23
|
+
ContactLabel["mobile"] = "mobile";
|
|
24
|
+
})(ContactLabel || (ContactLabel = {}));
|
|
25
|
+
export class OxContact extends LitElement {
|
|
26
|
+
constructor() {
|
|
27
|
+
super(...arguments);
|
|
28
|
+
this.contact = {};
|
|
29
|
+
this.editMode = false;
|
|
30
|
+
}
|
|
31
|
+
render() {
|
|
32
|
+
var _a;
|
|
33
|
+
const { items = [], note } = this.contact || {};
|
|
34
|
+
var sorted = {};
|
|
35
|
+
items.forEach(item => {
|
|
36
|
+
if (!sorted[item.type]) {
|
|
37
|
+
sorted[item.type] = [item];
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
sorted[item.type].push(item);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
const names = sorted[ContactField.Name];
|
|
44
|
+
return html `
|
|
45
|
+
<div name>
|
|
46
|
+
<div monogram>${(_a = names[0]) === null || _a === void 0 ? void 0 : _a.value.replace(/\s/g, '').slice(0, 2)}</div>
|
|
47
|
+
${names.map(item => this.editMode
|
|
48
|
+
? html `<div @change=${(e) => this.onChangeItem(e, item)}>
|
|
49
|
+
<input type="text" .value=${item.value} data-item="value" />
|
|
50
|
+
</div>`
|
|
51
|
+
: html `<div>
|
|
52
|
+
<span data-item="value">${item.value}</span>
|
|
53
|
+
</div>`)}
|
|
54
|
+
</div>
|
|
55
|
+
${['email', 'phone', 'address', 'company', 'etc']
|
|
56
|
+
.map(type => sorted[type])
|
|
57
|
+
.filter(items => items && items.length > 0)
|
|
58
|
+
.map(items => html `<div data-type=${items[0].type}>
|
|
59
|
+
${items.map(item => this.editMode
|
|
60
|
+
? html `<div @change=${(e) => this.onChangeItem(e, item)}>
|
|
61
|
+
<select .value=${item.label} data-item="label">
|
|
62
|
+
${['home', 'work', 'other', 'mobile'].map(option => html ` <option value=${option}>${option}</option>`)}
|
|
63
|
+
</select>
|
|
64
|
+
<input type="text" .value=${item.value} data-item="value" />
|
|
65
|
+
</div>`
|
|
66
|
+
: html `<div>
|
|
67
|
+
<label data-item="label">${item.label}</label>
|
|
68
|
+
<span data-item="value">${item.value}</span>
|
|
69
|
+
</div>`)}
|
|
70
|
+
</div>`)}
|
|
71
|
+
<div note>${note || ''}</div>
|
|
72
|
+
<div add>
|
|
73
|
+
<mwc-icon-button icon="mail" @click=${(e) => this.onAddItem(ContactField.Email)}></mwc-icon-button>
|
|
74
|
+
<mwc-icon-button
|
|
75
|
+
icon="phone_enabled"
|
|
76
|
+
@click=${(e) => this.onAddItem(ContactField.Phone)}
|
|
77
|
+
></mwc-icon-button>
|
|
78
|
+
<mwc-icon-button
|
|
79
|
+
icon="add_location"
|
|
80
|
+
@click=${(e) => this.onAddItem(ContactField.Address)}
|
|
81
|
+
></mwc-icon-button>
|
|
82
|
+
<mwc-icon-button
|
|
83
|
+
icon="location_city"
|
|
84
|
+
@click=${(e) => this.onAddItem(ContactField.Company)}
|
|
85
|
+
></mwc-icon-button>
|
|
86
|
+
</div>
|
|
87
|
+
`;
|
|
88
|
+
}
|
|
89
|
+
onAddItem(type) {
|
|
90
|
+
var { items = [] } = this.contact;
|
|
91
|
+
var item = {
|
|
92
|
+
type,
|
|
93
|
+
value: '',
|
|
94
|
+
label: 'work'
|
|
95
|
+
};
|
|
96
|
+
this.contact.items = [...items, item];
|
|
97
|
+
// this.editable = item
|
|
98
|
+
}
|
|
99
|
+
onChangeItem(e, item) {
|
|
100
|
+
const target = e.currentTarget;
|
|
101
|
+
const labelElement = target.querySelector('[data-item="label"');
|
|
102
|
+
const valueElement = target.querySelector('[data-item="value"');
|
|
103
|
+
if (labelElement) {
|
|
104
|
+
item.label = labelElement.value;
|
|
105
|
+
}
|
|
106
|
+
item.value = valueElement.value;
|
|
107
|
+
// this.editable = undefined
|
|
108
|
+
// this.requestUpdate()
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
OxContact.styles = css `
|
|
112
|
+
:host {
|
|
113
|
+
display: block;
|
|
114
|
+
padding: 25px;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
:host > div {
|
|
118
|
+
padding: 10px 0;
|
|
119
|
+
display: block;
|
|
120
|
+
border-bottom: 1px solid blue;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
:host > div > div {
|
|
124
|
+
padding: 4px 0;
|
|
125
|
+
box-sizing: border-box;
|
|
126
|
+
|
|
127
|
+
display: flex;
|
|
128
|
+
flex-direction: row;
|
|
129
|
+
gap: 10px;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
:host > div > div:hover {
|
|
133
|
+
position: relative;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
:host > div > div:hover::before {
|
|
137
|
+
font-family: 'Material Icons';
|
|
138
|
+
content: 'edit';
|
|
139
|
+
display: block;
|
|
140
|
+
position: absolute;
|
|
141
|
+
text-align: left;
|
|
142
|
+
line-height: 24px;
|
|
143
|
+
top: 0;
|
|
144
|
+
right: 0;
|
|
145
|
+
width: 100%;
|
|
146
|
+
height: 100%;
|
|
147
|
+
opacity: 0.5;
|
|
148
|
+
background-image: linear-gradient(var(--primary-color, gray), var(--primary-color, gray));
|
|
149
|
+
z-index: -1;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
[data-item='label'] {
|
|
153
|
+
width: 100px;
|
|
154
|
+
text-align: right;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
[data-item='value'] {
|
|
158
|
+
flex: 1;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
:host > div[name] {
|
|
162
|
+
display: flex;
|
|
163
|
+
align-items: center;
|
|
164
|
+
gap: 10px;
|
|
165
|
+
font-weight: bold;
|
|
166
|
+
font-size: 1.4em;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
:host > div[name] > [monogram] {
|
|
170
|
+
display: inline-block;
|
|
171
|
+
width: 100px;
|
|
172
|
+
height: 100px;
|
|
173
|
+
line-height: 100px;
|
|
174
|
+
border-radius: 999px;
|
|
175
|
+
border: 1px solid darkgray;
|
|
176
|
+
box-sizing: border-box;
|
|
177
|
+
padding: 0;
|
|
178
|
+
font-size: 40px;
|
|
179
|
+
font-family: system-ui;
|
|
180
|
+
overflow: hidden;
|
|
181
|
+
text-align: center;
|
|
182
|
+
vertical-align: center;
|
|
183
|
+
background-color: gray;
|
|
184
|
+
color: white;
|
|
185
|
+
text-transform: uppercase;
|
|
186
|
+
}
|
|
187
|
+
`;
|
|
188
|
+
__decorate([
|
|
189
|
+
property({ type: Object })
|
|
190
|
+
], OxContact.prototype, "contact", void 0);
|
|
191
|
+
__decorate([
|
|
192
|
+
state()
|
|
193
|
+
], OxContact.prototype, "editMode", void 0);
|
|
194
|
+
//# sourceMappingURL=OxContact%20copy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OxContact copy.js","sourceRoot":"","sources":["../../src/OxContact copy.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAEnD,MAAM,CAAN,IAAY,YAYX;AAZD,WAAY,YAAY;IACtB,6BAAa,CAAA;IACb,sCAAsB,CAAA;IACtB,+BAAe,CAAA;IACf,mCAAmB,CAAA;IACnB,+BAAe,CAAA;IACf,qCAAqB,CAAA;IACrB,mCAAmB,CAAA;IACnB,mCAAmB,CAAA;IACnB,yCAAyB,CAAA;IACzB,mCAAmB,CAAA;IACnB,qCAA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,CAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,OAAO,CAAC;;;KAGhE,CAAA;IACH,CAAC;IAED,SAAS,CAAC,IAAkB;QAC1B,IAAI,EAAE,KAAK,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC,OAAO,CAAA;QACjC,IAAI,IAAI,GAAG;YACT,IAAI;YACJ,KAAK,EAAE,EAAE;YACT,KAAK,EAAE,MAAM;SACd,CAAA;QACD,IAAI,CAAC,OAAO,CAAC,KAAK,GAAG,CAAC,GAAG,KAAK,EAAE,IAAI,CAAC,CAAA;QAErC,uBAAuB;IACzB,CAAC;IAED,YAAY,CAAC,CAAQ,EAAE,IAAiB;QACtC,MAAM,MAAM,GAAG,CAAC,CAAC,aAA4B,CAAA;QAC7C,MAAM,YAAY,GAAG,MAAM,CAAC,aAAa,CAAC,oBAAoB,CAAsB,CAAA;QACpF,MAAM,YAAY,GAAG,MAAM,CAAC,aAAa,CAAC,oBAAoB,CAAqB,CAAA;QAEnF,IAAI,YAAY,EAAE;YAChB,IAAI,CAAC,KAAK,GAAG,YAAY,CAAC,KAAK,CAAA;SAChC;QACD,IAAI,CAAC,KAAK,GAAG,YAAY,CAAC,KAAK,CAAA;QAE/B,4BAA4B;QAE5B,uBAAuB;IACzB,CAAC;;AA/KM,gBAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4ElB,CAAA;AAE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0CAAsB;AAExC;IAAR,KAAK,EAAE;2CAA2B","sourcesContent":["import { html, css, LitElement } from 'lit'\nimport { property, state } from 'lit/decorators.js'\n\nexport enum ContactField {\n Name = 'name',\n JobTitle = 'job-title',\n Phone = 'phone',\n Address = 'address',\n Email = 'email',\n Birthday = 'birthday',\n Profile = 'profile',\n Picture = 'picture',\n Department = 'department',\n Company = 'company',\n Homepage = 'homepage'\n}\n\nexport enum ContactLabel {\n home = 'home',\n work = 'work',\n other = 'other',\n mobile = 'mobile'\n}\n\nexport type ContactItem = {\n id?: string\n type: ContactField\n label: string\n value: string\n}\n\nexport type Contact = {\n items?: ContactItem[]\n note?: string\n}\n\nexport class OxContact extends LitElement {\n static styles = css`\n :host {\n display: block;\n padding: 25px;\n }\n\n :host > div {\n padding: 10px 0;\n display: block;\n border-bottom: 1px solid blue;\n }\n\n :host > div > div {\n padding: 4px 0;\n box-sizing: border-box;\n\n display: flex;\n flex-direction: row;\n gap: 10px;\n }\n\n :host > div > div:hover {\n position: relative;\n }\n\n :host > div > div:hover::before {\n font-family: 'Material Icons';\n content: 'edit';\n display: block;\n position: absolute;\n text-align: left;\n line-height: 24px;\n top: 0;\n right: 0;\n width: 100%;\n height: 100%;\n opacity: 0.5;\n background-image: linear-gradient(var(--primary-color, gray), var(--primary-color, gray));\n z-index: -1;\n }\n\n [data-item='label'] {\n width: 100px;\n text-align: right;\n }\n\n [data-item='value'] {\n flex: 1;\n }\n\n :host > div[name] {\n display: flex;\n align-items: center;\n gap: 10px;\n font-weight: bold;\n font-size: 1.4em;\n }\n\n :host > div[name] > [monogram] {\n display: inline-block;\n width: 100px;\n height: 100px;\n line-height: 100px;\n border-radius: 999px;\n border: 1px solid darkgray;\n box-sizing: border-box;\n padding: 0;\n font-size: 40px;\n font-family: system-ui;\n overflow: hidden;\n text-align: center;\n vertical-align: center;\n background-color: gray;\n color: white;\n text-transform: uppercase;\n }\n `\n\n @property({ type: Object }) contact: Contact = {}\n\n @state() editMode?: boolean = false\n\n render() {\n const { items = [], note } = this.contact || {}\n var sorted: { [type: string]: ContactItem[] } = {}\n\n items.forEach(item => {\n if (!sorted[item.type as string]) {\n sorted[item.type] = [item]\n } else {\n sorted[item.type as string].push(item)\n }\n })\n\n const names = sorted[ContactField.Name]\n\n return html`\n <div name>\n <div monogram>${names[0]?.value.replace(/\\s/g, '').slice(0, 2)}</div>\n ${names.map(item =>\n this.editMode\n ? html`<div @change=${(e: Event) => this.onChangeItem(e, item)}>\n <input type=\"text\" .value=${item.value} data-item=\"value\" />\n </div>`\n : html`<div>\n <span data-item=\"value\">${item.value}</span>\n </div>`\n )}\n </div>\n ${['email', 'phone', 'address', 'company', 'etc']\n .map(type => sorted[type])\n .filter(items => items && items.length > 0)\n .map(\n items => html`<div data-type=${items[0].type}>\n ${items.map(item =>\n this.editMode\n ? html`<div @change=${(e: Event) => this.onChangeItem(e, item)}>\n <select .value=${item.label} data-item=\"label\">\n ${['home', 'work', 'other', 'mobile'].map(\n option => html` <option value=${option}>${option}</option>`\n )}\n </select>\n <input type=\"text\" .value=${item.value} data-item=\"value\" />\n </div>`\n : html`<div>\n <label data-item=\"label\">${item.label}</label>\n <span data-item=\"value\">${item.value}</span>\n </div>`\n )}\n </div>`\n )}\n <div note>${note || ''}</div>\n <div add>\n <mwc-icon-button icon=\"mail\" @click=${(e: Event) => this.onAddItem(ContactField.Email)}></mwc-icon-button>\n <mwc-icon-button\n icon=\"phone_enabled\"\n @click=${(e: Event) => this.onAddItem(ContactField.Phone)}\n ></mwc-icon-button>\n <mwc-icon-button\n icon=\"add_location\"\n @click=${(e: Event) => this.onAddItem(ContactField.Address)}\n ></mwc-icon-button>\n <mwc-icon-button\n icon=\"location_city\"\n @click=${(e: Event) => this.onAddItem(ContactField.Company)}\n ></mwc-icon-button>\n </div>\n `\n }\n\n onAddItem(type: ContactField) {\n var { items = [] } = this.contact\n var item = {\n type,\n value: '',\n label: 'work'\n }\n this.contact.items = [...items, item]\n\n // this.editable = item\n }\n\n onChangeItem(e: Event, item: ContactItem) {\n const target = e.currentTarget as HTMLElement\n const labelElement = target.querySelector('[data-item=\"label\"') as HTMLSelectElement\n const valueElement = target.querySelector('[data-item=\"value\"') as HTMLInputElement\n\n if (labelElement) {\n item.label = labelElement.value\n }\n item.value = valueElement.value\n\n // this.editable = undefined\n\n // this.requestUpdate()\n }\n}\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import './ox-contact-edit';
|
|
3
|
+
import './ox-contact-view';
|
|
4
|
+
export declare enum ContactField {
|
|
5
|
+
Name = "name",
|
|
6
|
+
JobTitle = "job-title",
|
|
7
|
+
Phone = "phone",
|
|
8
|
+
Address = "address",
|
|
9
|
+
Email = "email",
|
|
10
|
+
Birthday = "birthday",
|
|
11
|
+
Profile = "profile",
|
|
12
|
+
Picture = "picture",
|
|
13
|
+
Department = "department",
|
|
14
|
+
Company = "company",
|
|
15
|
+
Homepage = "homepage"
|
|
16
|
+
}
|
|
17
|
+
export declare enum ContactLabel {
|
|
18
|
+
home = "home",
|
|
19
|
+
work = "work",
|
|
20
|
+
other = "other",
|
|
21
|
+
mobile = "mobile"
|
|
22
|
+
}
|
|
23
|
+
export type ContactItem = {
|
|
24
|
+
id?: string;
|
|
25
|
+
type: ContactField;
|
|
26
|
+
label: string;
|
|
27
|
+
value: string;
|
|
28
|
+
};
|
|
29
|
+
export type Contact = {
|
|
30
|
+
items?: ContactItem[];
|
|
31
|
+
note?: string;
|
|
32
|
+
};
|
|
33
|
+
export declare class OxContact extends LitElement {
|
|
34
|
+
static styles: import("lit").CSSResult;
|
|
35
|
+
contact: Contact;
|
|
36
|
+
editMode?: boolean;
|
|
37
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
38
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { html, css, LitElement } from 'lit';
|
|
3
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
|
4
|
+
import './ox-contact-edit';
|
|
5
|
+
import './ox-contact-view';
|
|
6
|
+
export var ContactField;
|
|
7
|
+
(function (ContactField) {
|
|
8
|
+
ContactField["Name"] = "name";
|
|
9
|
+
ContactField["JobTitle"] = "job-title";
|
|
10
|
+
ContactField["Phone"] = "phone";
|
|
11
|
+
ContactField["Address"] = "address";
|
|
12
|
+
ContactField["Email"] = "email";
|
|
13
|
+
ContactField["Birthday"] = "birthday";
|
|
14
|
+
ContactField["Profile"] = "profile";
|
|
15
|
+
ContactField["Picture"] = "picture";
|
|
16
|
+
ContactField["Department"] = "department";
|
|
17
|
+
ContactField["Company"] = "company";
|
|
18
|
+
ContactField["Homepage"] = "homepage";
|
|
19
|
+
})(ContactField || (ContactField = {}));
|
|
20
|
+
export var ContactLabel;
|
|
21
|
+
(function (ContactLabel) {
|
|
22
|
+
ContactLabel["home"] = "home";
|
|
23
|
+
ContactLabel["work"] = "work";
|
|
24
|
+
ContactLabel["other"] = "other";
|
|
25
|
+
ContactLabel["mobile"] = "mobile";
|
|
26
|
+
})(ContactLabel || (ContactLabel = {}));
|
|
27
|
+
let OxContact = class OxContact extends LitElement {
|
|
28
|
+
constructor() {
|
|
29
|
+
super(...arguments);
|
|
30
|
+
this.contact = {};
|
|
31
|
+
this.editMode = false;
|
|
32
|
+
}
|
|
33
|
+
render() {
|
|
34
|
+
return html `${this.editMode
|
|
35
|
+
? html `<ox-contact-edit
|
|
36
|
+
.contact=${this.contact}
|
|
37
|
+
@edit-cancel=${() => (this.editMode = false)}
|
|
38
|
+
@edit-done=${(e) => {
|
|
39
|
+
this.contact = e.detail;
|
|
40
|
+
this.editMode = false;
|
|
41
|
+
}}
|
|
42
|
+
></ox-contact-edit>`
|
|
43
|
+
: html ` <ox-contact-view .contact=${this.contact}></ox-contact-view>
|
|
44
|
+
<button value="Edit" @click=${() => (this.editMode = true)}>Edit</button>`} `;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
OxContact.styles = css `
|
|
48
|
+
:host {
|
|
49
|
+
display: block;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
button {
|
|
53
|
+
display: block;
|
|
54
|
+
margin-left: auto;
|
|
55
|
+
}
|
|
56
|
+
`;
|
|
57
|
+
__decorate([
|
|
58
|
+
property({ type: Object })
|
|
59
|
+
], OxContact.prototype, "contact", void 0);
|
|
60
|
+
__decorate([
|
|
61
|
+
state()
|
|
62
|
+
], OxContact.prototype, "editMode", void 0);
|
|
63
|
+
OxContact = __decorate([
|
|
64
|
+
customElement('ox-contact')
|
|
65
|
+
], OxContact);
|
|
66
|
+
export { OxContact };
|
|
67
|
+
//# sourceMappingURL=OxContact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OxContact.js","sourceRoot":"","sources":["../../src/OxContact.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,mBAAmB,CAAA;AAC1B,OAAO,mBAAmB,CAAA;AAE1B,MAAM,CAAN,IAAY,YAYX;AAZD,WAAY,YAAY;IACtB,6BAAa,CAAA;IACb,sCAAsB,CAAA;IACtB,+BAAe,CAAA;IACf,mCAAmB,CAAA;IACnB,+BAAe,CAAA;IACf,qCAAqB,CAAA;IACrB,mCAAmB,CAAA;IACnB,mCAAmB,CAAA;IACnB,yCAAyB,CAAA;IACzB,mCAAmB,CAAA;IACnB,qCAAqB,CAAA;AACvB,CAAC,EAZW,YAAY,KAAZ,YAAY,QAYvB;AAED,MAAM,CAAN,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,6BAAa,CAAA;IACb,6BAAa,CAAA;IACb,+BAAe,CAAA;IACf,iCAAiB,CAAA;AACnB,CAAC,EALW,YAAY,KAAZ,YAAY,QAKvB;AAeM,IAAM,SAAS,GAAf,MAAM,SAAU,SAAQ,UAAU;IAAlC;;QAYuB,YAAO,GAAY,EAAE,CAAA;QAExC,aAAQ,GAAa,KAAK,CAAA;IAerC,CAAC;IAbC,MAAM;QACJ,OAAO,IAAI,CAAA,GAAG,IAAI,CAAC,QAAQ;YACzB,CAAC,CAAC,IAAI,CAAA;qBACS,IAAI,CAAC,OAAO;yBACR,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;uBAC/B,CAAC,CAAc,EAAE,EAAE;gBAC9B,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,MAAM,CAAA;gBACvB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAA;YACvB,CAAC;4BACiB;YACtB,CAAC,CAAC,IAAI,CAAA,8BAA8B,IAAI,CAAC,OAAO;wCACd,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,gBAAgB,GAAG,CAAA;IACrF,CAAC;;AA3BM,gBAAM,GAAG,GAAG,CAAA;;;;;;;;;GASlB,CAAA;AAE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0CAAsB;AAExC;IAAR,KAAK,EAAE;2CAA2B;AAdxB,SAAS;IADrB,aAAa,CAAC,YAAY,CAAC;GACf,SAAS,CA6BrB;SA7BY,SAAS","sourcesContent":["import { html, css, LitElement } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\nimport './ox-contact-edit'\nimport './ox-contact-view'\n\nexport enum ContactField {\n Name = 'name',\n JobTitle = 'job-title',\n Phone = 'phone',\n Address = 'address',\n Email = 'email',\n Birthday = 'birthday',\n Profile = 'profile',\n Picture = 'picture',\n Department = 'department',\n Company = 'company',\n Homepage = 'homepage'\n}\n\nexport enum ContactLabel {\n home = 'home',\n work = 'work',\n other = 'other',\n mobile = 'mobile'\n}\n\nexport type ContactItem = {\n id?: string\n type: ContactField\n label: string\n value: string\n}\n\nexport type Contact = {\n items?: ContactItem[]\n note?: string\n}\n\n@customElement('ox-contact')\nexport class OxContact extends LitElement {\n static styles = css`\n :host {\n display: block;\n }\n\n button {\n display: block;\n margin-left: auto;\n }\n `\n\n @property({ type: Object }) contact: Contact = {}\n\n @state() editMode?: boolean = false\n\n render() {\n return html`${this.editMode\n ? html`<ox-contact-edit\n .contact=${this.contact}\n @edit-cancel=${() => (this.editMode = false)}\n @edit-done=${(e: CustomEvent) => {\n this.contact = e.detail\n this.editMode = false\n }}\n ></ox-contact-edit>`\n : html` <ox-contact-view .contact=${this.contact}></ox-contact-view>\n <button value=\"Edit\" @click=${() => (this.editMode = true)}>Edit</button>`} `\n }\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import '@material/mwc-icon-button';
|
|
2
|
+
import { LitElement, PropertyValues } from 'lit';
|
|
3
|
+
import { Contact, ContactItem } from './OxContact';
|
|
4
|
+
export declare class OxContactEdit extends LitElement {
|
|
5
|
+
static styles: import("lit").CSSResult[];
|
|
6
|
+
contact: Contact;
|
|
7
|
+
private stageContact;
|
|
8
|
+
note: HTMLTextAreaElement;
|
|
9
|
+
fields: NodeListOf<HTMLDivElement>;
|
|
10
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
11
|
+
updated(changes: PropertyValues<this>): void;
|
|
12
|
+
buildItems(): ContactItem[];
|
|
13
|
+
buildStageContact(): void;
|
|
14
|
+
onChangeItem(e: Event, item: ContactItem): void;
|
|
15
|
+
onSave(): void;
|
|
16
|
+
onCancel(): void;
|
|
17
|
+
onReset(): void;
|
|
18
|
+
}
|