@operato/font 1.0.0-beta.17 → 1.0.0-beta.18
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 +11 -0
- package/custom-elements.json +841 -0
- package/dist/src/font-creation-card.d.ts +18 -0
- package/dist/src/font-creation-card.js +258 -0
- package/dist/src/font-creation-card.js.map +1 -0
- package/dist/src/font-selector.d.ts +36 -0
- package/dist/src/font-selector.js +285 -0
- package/dist/src/font-selector.js.map +1 -0
- package/dist/src/graphql-client.d.ts +20 -0
- package/dist/src/graphql-client.js +109 -0
- package/dist/src/graphql-client.js.map +1 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.js +6 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/ox-file-selector.d.ts +12 -0
- package/dist/src/ox-file-selector.js +129 -0
- package/dist/src/ox-file-selector.js.map +1 -0
- package/dist/src/ox-font-selector.d.ts +15 -0
- package/dist/src/ox-font-selector.js +88 -0
- package/dist/src/ox-font-selector.js.map +1 -0
- package/dist/src/ox-property-editor-font-selector.d.ts +8 -0
- package/dist/src/ox-property-editor-font-selector.js +13 -0
- package/dist/src/ox-property-editor-font-selector.js.map +1 -0
- package/dist/src/redux-font-actions.d.ts +7 -0
- package/dist/src/redux-font-actions.js +19 -0
- package/dist/src/redux-font-actions.js.map +1 -0
- package/dist/src/redux-font-reducers.d.ts +12 -0
- package/dist/src/redux-font-reducers.js +70 -0
- package/dist/src/redux-font-reducers.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +30 -18
- package/src/font-creation-card.ts +260 -0
- package/src/font-selector.ts +284 -0
- package/src/{graphql-client.js → graphql-client.ts} +5 -6
- package/src/index.ts +6 -0
- package/src/ox-file-selector.ts +114 -0
- package/src/{ox-font-selector.js → ox-font-selector.ts} +32 -36
- package/src/{ox-property-editor-font-selector.js → ox-property-editor-font-selector.ts} +1 -2
- package/src/redux-font-actions.ts +21 -0
- package/src/{redux-font-reducers.js → redux-font-reducers.ts} +17 -9
- package/src/font-creation-card.js +0 -270
- package/src/font-selector.js +0 -287
- package/src/index.js +0 -6
- package/src/ox-file-selector.js +0 -138
- package/src/redux-font-actions.js +0 -20
- package/things-factory.config.js +0 -5
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { client } from '@operato/graphql';
|
|
2
|
+
import gql from 'graphql-tag';
|
|
3
|
+
/**
|
|
4
|
+
* @param {Object} listParam {filters, pagination, sortings}
|
|
5
|
+
*/
|
|
6
|
+
export async function fetchFontList(listParam) {
|
|
7
|
+
const response = await client.query({
|
|
8
|
+
query: gql `
|
|
9
|
+
query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
|
|
10
|
+
fonts(filters: $filters, pagination: $pagination, sortings: $sortings) {
|
|
11
|
+
items {
|
|
12
|
+
id
|
|
13
|
+
name
|
|
14
|
+
provider
|
|
15
|
+
uri
|
|
16
|
+
path
|
|
17
|
+
active
|
|
18
|
+
files {
|
|
19
|
+
name
|
|
20
|
+
fullpath
|
|
21
|
+
}
|
|
22
|
+
createdAt
|
|
23
|
+
updatedAt
|
|
24
|
+
}
|
|
25
|
+
total
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
`,
|
|
29
|
+
variables: listParam
|
|
30
|
+
});
|
|
31
|
+
return response.data && response.data.fonts;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* @param {Object} font Font patch
|
|
35
|
+
*/
|
|
36
|
+
export async function createFont(font) {
|
|
37
|
+
const response = await client.mutate({
|
|
38
|
+
mutation: gql `
|
|
39
|
+
mutation CreateFont($font: NewFont!) {
|
|
40
|
+
createFont(font: $font) {
|
|
41
|
+
name
|
|
42
|
+
provider
|
|
43
|
+
uri
|
|
44
|
+
path
|
|
45
|
+
active
|
|
46
|
+
createdAt
|
|
47
|
+
updatedAt
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
`,
|
|
51
|
+
variables: {
|
|
52
|
+
font: { active: false, ...font }
|
|
53
|
+
},
|
|
54
|
+
context: {
|
|
55
|
+
hasUpload: true
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
return response.data;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* @param {Object} font Font patch
|
|
62
|
+
*/
|
|
63
|
+
export async function updateFont(font) {
|
|
64
|
+
var { id, ...patch } = font;
|
|
65
|
+
const response = await client.mutate({
|
|
66
|
+
mutation: gql `
|
|
67
|
+
mutation UpdateFont($id: String!, $patch: FontPatch!) {
|
|
68
|
+
updateFont(id: $id, patch: $patch) {
|
|
69
|
+
id
|
|
70
|
+
name
|
|
71
|
+
provider
|
|
72
|
+
files {
|
|
73
|
+
name
|
|
74
|
+
fullpath
|
|
75
|
+
}
|
|
76
|
+
path
|
|
77
|
+
active
|
|
78
|
+
createdAt
|
|
79
|
+
updatedAt
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
`,
|
|
83
|
+
variables: {
|
|
84
|
+
id,
|
|
85
|
+
patch
|
|
86
|
+
},
|
|
87
|
+
context: {
|
|
88
|
+
hasUpload: true
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
return response.data;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* @param {String} id Font id
|
|
95
|
+
*/
|
|
96
|
+
export async function deleteFont(id) {
|
|
97
|
+
const response = await client.mutate({
|
|
98
|
+
mutation: gql `
|
|
99
|
+
mutation ($id: String!) {
|
|
100
|
+
deleteFont(id: $id)
|
|
101
|
+
}
|
|
102
|
+
`,
|
|
103
|
+
variables: {
|
|
104
|
+
id
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
return response.data;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=graphql-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql-client.js","sourceRoot":"","sources":["../../src/graphql-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE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,CAAC;QACnC,QAAQ,EAAE,GAAG,CAAA;;;;KAIZ;QACD,SAAS,EAAE;YACT,EAAE;SACH;KACF,CAAC,CAAA;IAEF,OAAO,QAAQ,CAAC,IAAI,CAAA;AACtB,CAAC","sourcesContent":["import { client } from '@operato/graphql'\nimport gql from 'graphql-tag'\n\n/**\n * @param {Object} listParam {filters, pagination, sortings}\n */\nexport async function fetchFontList(listParam?: { sortings?: any; filters?: any; pagination?: any }) {\n const response = await client.query({\n query: gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {\n fonts(filters: $filters, pagination: $pagination, sortings: $sortings) {\n items {\n id\n name\n provider\n uri\n path\n active\n files {\n name\n fullpath\n }\n createdAt\n updatedAt\n }\n total\n }\n }\n `,\n variables: listParam\n })\n\n return response.data && response.data.fonts\n}\n\n/**\n * @param {Object} font Font patch\n */\nexport async function createFont(font: any) {\n const response = await client.mutate({\n mutation: gql`\n mutation CreateFont($font: NewFont!) {\n createFont(font: $font) {\n name\n provider\n uri\n path\n active\n createdAt\n updatedAt\n }\n }\n `,\n variables: {\n font: { active: false, ...font }\n },\n context: {\n hasUpload: true\n }\n })\n\n return response.data\n}\n\n/**\n * @param {Object} font Font patch\n */\nexport async function updateFont(font: any) {\n var { id, ...patch } = font\n\n const response = await client.mutate({\n mutation: gql`\n mutation UpdateFont($id: String!, $patch: FontPatch!) {\n updateFont(id: $id, patch: $patch) {\n id\n name\n provider\n files {\n name\n fullpath\n }\n path\n active\n createdAt\n updatedAt\n }\n }\n `,\n variables: {\n id,\n patch\n },\n context: {\n hasUpload: true\n }\n })\n\n return response.data\n}\n\n/**\n * @param {String} id Font id\n */\nexport async function deleteFont(id: string) {\n const response = await client.mutate({\n mutation: gql`\n mutation ($id: String!) {\n deleteFont(id: $id)\n }\n `,\n variables: {\n id\n }\n })\n\n return response.data\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './font-selector.js';
|
|
2
|
+
export * from './ox-font-selector.js';
|
|
3
|
+
export * from './ox-property-editor-font-selector.js';
|
|
4
|
+
export * from './redux-font-actions.js';
|
|
5
|
+
export { default as ReducerFont } from './redux-font-reducers.js';
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,uBAAuB,CAAA;AACrC,cAAc,uCAAuC,CAAA;AAErD,cAAc,yBAAyB,CAAA;AACvC,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,0BAA0B,CAAA","sourcesContent":["export * from './font-selector.js'\nexport * from './ox-font-selector.js'\nexport * from './ox-property-editor-font-selector.js'\n\nexport * from './redux-font-actions.js'\nexport { default as ReducerFont } from './redux-font-reducers.js'\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import '@material/mwc-icon';
|
|
2
|
+
import '@material/mwc-icon-button';
|
|
3
|
+
import { LitElement } from 'lit';
|
|
4
|
+
export declare class OxFileSelector extends LitElement {
|
|
5
|
+
static styles: import("lit").CSSResult[];
|
|
6
|
+
label: string;
|
|
7
|
+
accept?: string;
|
|
8
|
+
showFilename: boolean;
|
|
9
|
+
multiple: boolean;
|
|
10
|
+
_files: Array<any>;
|
|
11
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import '@material/mwc-icon';
|
|
3
|
+
import '@material/mwc-icon-button';
|
|
4
|
+
import { LitElement, css, html } from 'lit';
|
|
5
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
6
|
+
let OxFileSelector = class OxFileSelector extends LitElement {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.label = 'select file';
|
|
10
|
+
this.showFilename = false;
|
|
11
|
+
this.multiple = false;
|
|
12
|
+
this._files = [];
|
|
13
|
+
}
|
|
14
|
+
render() {
|
|
15
|
+
return html `
|
|
16
|
+
<div id="input-box">
|
|
17
|
+
${this.showFilename
|
|
18
|
+
? html `
|
|
19
|
+
<input class="upload-name" value=${this._files.map(f => f.name).join(', ') || this.label} disabled />
|
|
20
|
+
`
|
|
21
|
+
: html ``}
|
|
22
|
+
<label for="input-file">${this.label}</label>
|
|
23
|
+
<input
|
|
24
|
+
id="input-file"
|
|
25
|
+
type="file"
|
|
26
|
+
accept="${this.accept}"
|
|
27
|
+
class="upload-hidden"
|
|
28
|
+
?multiple=${this.multiple}
|
|
29
|
+
hidden
|
|
30
|
+
@change=${(e) => {
|
|
31
|
+
const el = e.currentTarget;
|
|
32
|
+
this.dispatchEvent(new CustomEvent('file-change', {
|
|
33
|
+
bubbles: true,
|
|
34
|
+
composed: true,
|
|
35
|
+
detail: {
|
|
36
|
+
files: el.files
|
|
37
|
+
}
|
|
38
|
+
}));
|
|
39
|
+
el.value = '';
|
|
40
|
+
}}
|
|
41
|
+
/>
|
|
42
|
+
</div>
|
|
43
|
+
`;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
OxFileSelector.styles = [
|
|
47
|
+
css `
|
|
48
|
+
:host {
|
|
49
|
+
flex: 1;
|
|
50
|
+
display: flex;
|
|
51
|
+
flex-direction: column;
|
|
52
|
+
position: relative;
|
|
53
|
+
overflow: hidden;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
#input-box {
|
|
57
|
+
display: flex;
|
|
58
|
+
width: 100%;
|
|
59
|
+
height: 100%;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
input[type='file'] {
|
|
63
|
+
position: absolute;
|
|
64
|
+
width: 0px;
|
|
65
|
+
height: 0px;
|
|
66
|
+
padding: 0;
|
|
67
|
+
margin: -1px;
|
|
68
|
+
overflow: hidden;
|
|
69
|
+
clip: rect(0, 0, 0, 0);
|
|
70
|
+
border: 0;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
label {
|
|
74
|
+
padding: unset;
|
|
75
|
+
width: 100%;
|
|
76
|
+
height: 100%;
|
|
77
|
+
box-sizing: border-box;
|
|
78
|
+
display: flex;
|
|
79
|
+
align-items: center;
|
|
80
|
+
justify-content: center;
|
|
81
|
+
|
|
82
|
+
color: var(--file-selector-color, #999);
|
|
83
|
+
font-size: inherit;
|
|
84
|
+
line-height: normal;
|
|
85
|
+
vertical-align: middle;
|
|
86
|
+
background-color: var(--file-selector-bg-color, #fdfdfd);
|
|
87
|
+
cursor: pointer;
|
|
88
|
+
border: var(--file-selector-border, 1px solid #ebebeb);
|
|
89
|
+
border-radius: var(--file-selector-border-radius, 0.25em);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/* named upload */
|
|
93
|
+
.upload-name {
|
|
94
|
+
flex: 1;
|
|
95
|
+
padding: 0.5em 0.75em; /* label의 패딩값과 일치 */
|
|
96
|
+
font-size: inherit;
|
|
97
|
+
font-family: inherit;
|
|
98
|
+
line-height: normal;
|
|
99
|
+
vertical-align: middle;
|
|
100
|
+
background-color: #f5f5f5;
|
|
101
|
+
border: 1px solid #ebebeb;
|
|
102
|
+
border-bottom-color: #e2e2e2;
|
|
103
|
+
border-radius: 0.25em;
|
|
104
|
+
-webkit-appearance: none; /* 네이티브 외형 감추기 */
|
|
105
|
+
-moz-appearance: none;
|
|
106
|
+
appearance: none;
|
|
107
|
+
}
|
|
108
|
+
`
|
|
109
|
+
];
|
|
110
|
+
__decorate([
|
|
111
|
+
property({ type: String })
|
|
112
|
+
], OxFileSelector.prototype, "label", void 0);
|
|
113
|
+
__decorate([
|
|
114
|
+
property({ type: String })
|
|
115
|
+
], OxFileSelector.prototype, "accept", void 0);
|
|
116
|
+
__decorate([
|
|
117
|
+
property({ type: Boolean, attribute: 'show-filename' })
|
|
118
|
+
], OxFileSelector.prototype, "showFilename", void 0);
|
|
119
|
+
__decorate([
|
|
120
|
+
property({ type: Boolean, attribute: 'multiple' })
|
|
121
|
+
], OxFileSelector.prototype, "multiple", void 0);
|
|
122
|
+
__decorate([
|
|
123
|
+
property({ type: Array })
|
|
124
|
+
], OxFileSelector.prototype, "_files", void 0);
|
|
125
|
+
OxFileSelector = __decorate([
|
|
126
|
+
customElement('ox-file-selector')
|
|
127
|
+
], OxFileSelector);
|
|
128
|
+
export { OxFileSelector };
|
|
129
|
+
//# sourceMappingURL=ox-file-selector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ox-file-selector.js","sourceRoot":"","sources":["../../src/ox-file-selector.ts"],"names":[],"mappings":";AAAA,OAAO,oBAAoB,CAAA;AAC3B,OAAO,2BAA2B,CAAA;AAElC,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAG3D,IAAa,cAAc,GAA3B,MAAa,cAAe,SAAQ,UAAU;IAA9C;;QAkE8B,UAAK,GAAW,aAAa,CAAA;QAEA,iBAAY,GAAY,KAAK,CAAA;QAClC,aAAQ,GAAY,KAAK,CAAA;QAClD,WAAM,GAAe,EAAE,CAAA;IAoCpD,CAAC;IAlCC,MAAM;QACJ,OAAO,IAAI,CAAA;;UAEL,IAAI,CAAC,YAAY;YACjB,CAAC,CAAC,IAAI,CAAA;iDACiC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK;aACzF;YACH,CAAC,CAAC,IAAI,CAAA,EAAE;kCACgB,IAAI,CAAC,KAAK;;;;oBAIxB,IAAI,CAAC,MAAM;;sBAET,IAAI,CAAC,QAAQ;;oBAEf,CAAC,CAAQ,EAAE,EAAE;YACrB,MAAM,EAAE,GAAG,CAAC,CAAC,aAAiC,CAAA;YAC9C,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,aAAa,EAAE;gBAC7B,OAAO,EAAE,IAAI;gBACb,QAAQ,EAAE,IAAI;gBACd,MAAM,EAAE;oBACN,KAAK,EAAE,EAAE,CAAC,KAAK;iBAChB;aACF,CAAC,CACH,CAAA;YAED,EAAE,CAAC,KAAK,GAAG,EAAE,CAAA;QACf,CAAC;;;KAGN,CAAA;IACH,CAAC;CACF,CAAA;AAzGQ,qBAAM,GAAG;IACd,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA6DF;CACF,CAAA;AAE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAA8B;AAC7B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAAgB;AACc;IAAxD,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;oDAA8B;AAClC;IAAnD,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;gDAA0B;AAClD;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;8CAAwB;AAtEvC,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CA0G1B;SA1GY,cAAc","sourcesContent":["import '@material/mwc-icon'\nimport '@material/mwc-icon-button'\n\nimport { LitElement, css, html } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\n@customElement('ox-file-selector')\nexport class OxFileSelector extends LitElement {\n static styles = [\n css`\n :host {\n flex: 1;\n display: flex;\n flex-direction: column;\n position: relative;\n overflow: hidden;\n }\n\n #input-box {\n display: flex;\n width: 100%;\n height: 100%;\n }\n\n input[type='file'] {\n position: absolute;\n width: 0px;\n height: 0px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n border: 0;\n }\n\n label {\n padding: unset;\n width: 100%;\n height: 100%;\n box-sizing: border-box;\n display: flex;\n align-items: center;\n justify-content: center;\n\n color: var(--file-selector-color, #999);\n font-size: inherit;\n line-height: normal;\n vertical-align: middle;\n background-color: var(--file-selector-bg-color, #fdfdfd);\n cursor: pointer;\n border: var(--file-selector-border, 1px solid #ebebeb);\n border-radius: var(--file-selector-border-radius, 0.25em);\n }\n\n /* named upload */\n .upload-name {\n flex: 1;\n padding: 0.5em 0.75em; /* label의 패딩값과 일치 */\n font-size: inherit;\n font-family: inherit;\n line-height: normal;\n vertical-align: middle;\n background-color: #f5f5f5;\n border: 1px solid #ebebeb;\n border-bottom-color: #e2e2e2;\n border-radius: 0.25em;\n -webkit-appearance: none; /* 네이티브 외형 감추기 */\n -moz-appearance: none;\n appearance: none;\n }\n `\n ]\n\n @property({ type: String }) label: string = 'select file'\n @property({ type: String }) accept?: string\n @property({ type: Boolean, attribute: 'show-filename' }) showFilename: boolean = false\n @property({ type: Boolean, attribute: 'multiple' }) multiple: boolean = false\n @property({ type: Array }) _files: Array<any> = []\n\n render() {\n return html`\n <div id=\"input-box\">\n ${this.showFilename\n ? html`\n <input class=\"upload-name\" value=${this._files.map(f => f.name).join(', ') || this.label} disabled />\n `\n : html``}\n <label for=\"input-file\">${this.label}</label>\n <input\n id=\"input-file\"\n type=\"file\"\n accept=\"${this.accept}\"\n class=\"upload-hidden\"\n ?multiple=${this.multiple}\n hidden\n @change=${(e: Event) => {\n const el = e.currentTarget as HTMLInputElement\n this.dispatchEvent(\n new CustomEvent('file-change', {\n bubbles: true,\n composed: true,\n detail: {\n files: el.files\n }\n })\n )\n\n el.value = ''\n }}\n />\n </div>\n `\n }\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import '@material/mwc-icon';
|
|
5
|
+
import './font-selector';
|
|
6
|
+
import { LitElement } from 'lit';
|
|
7
|
+
export default class OxFontSelector extends LitElement {
|
|
8
|
+
static styles: import("lit").CSSResult[];
|
|
9
|
+
value?: string;
|
|
10
|
+
properties: any;
|
|
11
|
+
popup: any;
|
|
12
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
13
|
+
_onInputChanged(e: Event): void;
|
|
14
|
+
openSelector(): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import { __decorate } from "tslib";
|
|
5
|
+
import '@material/mwc-icon';
|
|
6
|
+
import './font-selector';
|
|
7
|
+
import { css, html, LitElement } from 'lit';
|
|
8
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
9
|
+
import { i18next } from '@operato/i18n';
|
|
10
|
+
import { openPopup } from '@operato/layout';
|
|
11
|
+
let OxFontSelector = class OxFontSelector extends LitElement {
|
|
12
|
+
render() {
|
|
13
|
+
return html `
|
|
14
|
+
<input
|
|
15
|
+
id="text"
|
|
16
|
+
type="text"
|
|
17
|
+
.value=${this.value || ''}
|
|
18
|
+
@change=${(e) => this._onInputChanged(e)}
|
|
19
|
+
.placeholder=${this.getAttribute('placeholder') || ''}
|
|
20
|
+
/>
|
|
21
|
+
|
|
22
|
+
<mwc-icon @click=${() => this.openSelector()}>font_download</mwc-icon>
|
|
23
|
+
`;
|
|
24
|
+
}
|
|
25
|
+
_onInputChanged(e) {
|
|
26
|
+
this.value = e.target.value;
|
|
27
|
+
this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }));
|
|
28
|
+
}
|
|
29
|
+
openSelector() {
|
|
30
|
+
if (this.popup) {
|
|
31
|
+
delete this.popup;
|
|
32
|
+
}
|
|
33
|
+
/*
|
|
34
|
+
* 기존 설정된 보드가 선택된 상태가 되게 하기 위해서는 selector에 value를 전달해줄 필요가 있음.
|
|
35
|
+
* 주의. value는 object일 수도 있고, string일 수도 있다.
|
|
36
|
+
* string인 경우에는 해당 보드의 id로 해석한다.
|
|
37
|
+
*/
|
|
38
|
+
var value = this.value || {};
|
|
39
|
+
var template = html `
|
|
40
|
+
<font-selector
|
|
41
|
+
.creatable=${true}
|
|
42
|
+
@font-selected=${async (e) => {
|
|
43
|
+
var font = e.detail.font;
|
|
44
|
+
this.value = font.name;
|
|
45
|
+
this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }));
|
|
46
|
+
this.popup && this.popup.close();
|
|
47
|
+
}}
|
|
48
|
+
></font-selector>
|
|
49
|
+
`;
|
|
50
|
+
this.popup = openPopup(template, {
|
|
51
|
+
backdrop: true,
|
|
52
|
+
size: 'large',
|
|
53
|
+
title: i18next.t('title.select font')
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
OxFontSelector.styles = [
|
|
58
|
+
css `
|
|
59
|
+
:host {
|
|
60
|
+
position: relative;
|
|
61
|
+
display: inline-block;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
input[type='text'] {
|
|
65
|
+
box-sizing: border-box;
|
|
66
|
+
width: 100%;
|
|
67
|
+
height: 100%;
|
|
68
|
+
border: 1px solid rgba(0, 0, 0, 0.2);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
mwc-icon {
|
|
72
|
+
position: absolute;
|
|
73
|
+
top: 0;
|
|
74
|
+
right: 0;
|
|
75
|
+
}
|
|
76
|
+
`
|
|
77
|
+
];
|
|
78
|
+
__decorate([
|
|
79
|
+
property({ type: String })
|
|
80
|
+
], OxFontSelector.prototype, "value", void 0);
|
|
81
|
+
__decorate([
|
|
82
|
+
property({ type: Object })
|
|
83
|
+
], OxFontSelector.prototype, "properties", void 0);
|
|
84
|
+
OxFontSelector = __decorate([
|
|
85
|
+
customElement('ox-font-selector')
|
|
86
|
+
], OxFontSelector);
|
|
87
|
+
export default OxFontSelector;
|
|
88
|
+
//# sourceMappingURL=ox-font-selector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
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AAC,CAAC,MAAM,CAAC,IAAI,CAAA;YACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAA;YAEtB,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;YAEhF,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;QAClC,CAAC;;KAEJ,CAAA;QAED,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,QAAQ,EAAE;YAC/B,QAAQ,EAAE,IAAI;YACd,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,mBAAmB,CAAC;SACtC,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AA9EQ,qBAAM,GAAG;IACd,GAAG,CAAA;;;;;;;;;;;;;;;;;;KAkBF;CACF,CAAA;AAE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAAe;AACd;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAAgB;AAxBxB,cAAc;IADlC,aAAa,CAAC,kBAAkB,CAAC;GACb,cAAc,CA+ElC;eA/EoB,cAAc","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport '@material/mwc-icon'\nimport './font-selector'\n\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { i18next } from '@operato/i18n'\nimport { openPopup } from '@operato/layout'\n\n@customElement('ox-font-selector')\nexport default class OxFontSelector extends LitElement {\n static styles = [\n css`\n :host {\n position: relative;\n display: inline-block;\n }\n\n input[type='text'] {\n box-sizing: border-box;\n width: 100%;\n height: 100%;\n border: 1px solid rgba(0, 0, 0, 0.2);\n }\n\n mwc-icon {\n position: absolute;\n top: 0;\n right: 0;\n }\n `\n ]\n\n @property({ type: String }) value?: string\n @property({ type: Object }) properties: any\n\n popup: any\n\n render() {\n return html`\n <input\n id=\"text\"\n type=\"text\"\n .value=${this.value || ''}\n @change=${(e: Event) => this._onInputChanged(e)}\n .placeholder=${this.getAttribute('placeholder') || ''}\n />\n\n <mwc-icon @click=${() => this.openSelector()}>font_download</mwc-icon>\n `\n }\n\n _onInputChanged(e: Event) {\n this.value = (e.target as HTMLInputElement).value\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))\n }\n\n openSelector() {\n if (this.popup) {\n delete this.popup\n }\n\n /*\n * 기존 설정된 보드가 선택된 상태가 되게 하기 위해서는 selector에 value를 전달해줄 필요가 있음.\n * 주의. value는 object일 수도 있고, string일 수도 있다.\n * string인 경우에는 해당 보드의 id로 해석한다.\n */\n var value = this.value || {}\n\n var template = html`\n <font-selector\n .creatable=${true}\n @font-selected=${async (e: CustomEvent) => {\n var font = e.detail.font\n this.value = font.name\n\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))\n\n this.popup && this.popup.close()\n }}\n ></font-selector>\n `\n\n this.popup = openPopup(template, {\n backdrop: true,\n size: 'large',\n title: i18next.t('title.select font')\n })\n }\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import './ox-font-selector';
|
|
5
|
+
import { OxPropertyEditor } from '@operato/property-editor';
|
|
6
|
+
export declare class OxPropertyEditorFontSelector extends OxPropertyEditor {
|
|
7
|
+
editorTemplate(): import("lit-html").TemplateResult<1>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import './ox-font-selector';
|
|
5
|
+
import { OxPropertyEditor } from '@operato/property-editor';
|
|
6
|
+
import { html } from 'lit';
|
|
7
|
+
export class OxPropertyEditorFontSelector extends OxPropertyEditor {
|
|
8
|
+
editorTemplate() {
|
|
9
|
+
return html ` <ox-font-selector id="editor" .value=${this.value} .properties=${this.property}></ox-font-selector> `;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
customElements.define('ox-property-editor-font-selector', OxPropertyEditorFontSelector);
|
|
13
|
+
//# sourceMappingURL=ox-property-editor-font-selector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ox-property-editor-font-selector.js","sourceRoot":"","sources":["../../src/ox-property-editor-font-selector.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,oBAAoB,CAAA;AAE3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAE1B,MAAM,OAAO,4BAA6B,SAAQ,gBAAgB;IAChE,cAAc;QACZ,OAAO,IAAI,CAAA,yCAAyC,IAAI,CAAC,KAAK,gBAAgB,IAAI,CAAC,QAAQ,uBAAuB,CAAA;IACpH,CAAC;CACF;AAED,cAAc,CAAC,MAAM,CAAC,kCAAkC,EAAE,4BAA4B,CAAC,CAAA","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport './ox-font-selector'\n\nimport { OxPropertyEditor } from '@operato/property-editor'\nimport { html } from 'lit'\n\nexport class OxPropertyEditorFontSelector extends OxPropertyEditor {\n editorTemplate() {\n return html` <ox-font-selector id=\"editor\" .value=${this.value} .properties=${this.property}></ox-font-selector> `\n }\n}\n\ncustomElements.define('ox-property-editor-font-selector', OxPropertyEditorFontSelector)\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const UPDATE_FONT_LIST = "UPDATE_FONT_LIST";
|
|
2
|
+
export declare const CLEAR_FONT_LIST = "CLEAR_FONT_LIST";
|
|
3
|
+
export declare const actionUpdateFontList: (listParams?: {
|
|
4
|
+
sortings?: any;
|
|
5
|
+
filters?: any;
|
|
6
|
+
pagination?: any;
|
|
7
|
+
} | undefined) => (dispatch: any) => Promise<void>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as client from './graphql-client';
|
|
2
|
+
export const UPDATE_FONT_LIST = 'UPDATE_FONT_LIST';
|
|
3
|
+
export const CLEAR_FONT_LIST = 'CLEAR_FONT_LIST';
|
|
4
|
+
export const actionUpdateFontList = (listParams) => async (dispatch) => {
|
|
5
|
+
try {
|
|
6
|
+
const fonts = await client.fetchFontList(listParams || { filters: [] });
|
|
7
|
+
dispatch({
|
|
8
|
+
type: UPDATE_FONT_LIST,
|
|
9
|
+
list: fonts && fonts.items
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
console.error(error);
|
|
14
|
+
dispatch({
|
|
15
|
+
type: CLEAR_FONT_LIST
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=redux-font-actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redux-font-actions.js","sourceRoot":"","sources":["../../src/redux-font-actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAA;AAE1C,MAAM,CAAC,MAAM,gBAAgB,GAAG,kBAAkB,CAAA;AAClD,MAAM,CAAC,MAAM,eAAe,GAAG,iBAAiB,CAAA;AAEhD,MAAM,CAAC,MAAM,oBAAoB,GAC/B,CAAC,UAAgE,EAAE,EAAE,CAAC,KAAK,EAAE,QAAa,EAAE,EAAE;IAC5F,IAAI;QACF,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,UAAU,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAA;QAEvE,QAAQ,CAAC;YACP,IAAI,EAAE,gBAAgB;YACtB,IAAI,EAAE,KAAK,IAAI,KAAK,CAAC,KAAK;SAC3B,CAAC,CAAA;KACH;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACpB,QAAQ,CAAC;YACP,IAAI,EAAE,eAAe;SACtB,CAAC,CAAA;KACH;AACH,CAAC,CAAA","sourcesContent":["import * as client from './graphql-client'\n\nexport const UPDATE_FONT_LIST = 'UPDATE_FONT_LIST'\nexport const CLEAR_FONT_LIST = 'CLEAR_FONT_LIST'\n\nexport const actionUpdateFontList =\n (listParams?: { sortings?: any; filters?: any; pagination?: any }) => async (dispatch: any) => {\n try {\n const fonts = await client.fetchFontList(listParams || { filters: [] })\n\n dispatch({\n type: UPDATE_FONT_LIST,\n list: fonts && fonts.items\n })\n } catch (error) {\n console.error(error)\n dispatch({\n type: CLEAR_FONT_LIST\n })\n }\n }\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare type Font = {
|
|
2
|
+
name: string;
|
|
3
|
+
provider: string;
|
|
4
|
+
uri: string;
|
|
5
|
+
active: boolean;
|
|
6
|
+
files: Array<{
|
|
7
|
+
name: string;
|
|
8
|
+
fullpath: string;
|
|
9
|
+
}>;
|
|
10
|
+
};
|
|
11
|
+
declare const ReducerFont: (state: never[] | undefined, action: any) => Font[];
|
|
12
|
+
export default ReducerFont;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { CLEAR_FONT_LIST, UPDATE_FONT_LIST } from './redux-font-actions.js';
|
|
2
|
+
import WebFont from 'webfontloader';
|
|
3
|
+
const ReducerFont = (state = [], action) => {
|
|
4
|
+
switch (action.type) {
|
|
5
|
+
case UPDATE_FONT_LIST:
|
|
6
|
+
let newState = action.list;
|
|
7
|
+
let activatedFonts = newState.filter(font => font.active);
|
|
8
|
+
let googles = [];
|
|
9
|
+
let customs = [];
|
|
10
|
+
let customFontCSS = '';
|
|
11
|
+
activatedFonts.forEach(font => {
|
|
12
|
+
const { name, provider, files, uri } = font;
|
|
13
|
+
if (provider === 'google') {
|
|
14
|
+
googles.push(name);
|
|
15
|
+
}
|
|
16
|
+
else if (provider === 'custom') {
|
|
17
|
+
customs.push(name);
|
|
18
|
+
if (files && files.length > 0) {
|
|
19
|
+
customFontCSS += files
|
|
20
|
+
.map(file => {
|
|
21
|
+
const { name: filename, fullpath } = file;
|
|
22
|
+
const bold = filename.toUpperCase().indexOf('BOLD') !== -1;
|
|
23
|
+
return `@font-face {
|
|
24
|
+
font-family: '${name}';
|
|
25
|
+
src: local('${name}'), url(${fullpath});
|
|
26
|
+
font-weight: ${bold ? 'bold' : 'normal'};
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
29
|
+
})
|
|
30
|
+
.join('\n');
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
customFontCSS += `@font-face {
|
|
34
|
+
font-family: '${name}';
|
|
35
|
+
src: local('${name}')${uri ? `, url(${uri})` : ''};
|
|
36
|
+
}
|
|
37
|
+
`;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
let style = document.head.querySelector('#custom-fonts');
|
|
42
|
+
if (!style) {
|
|
43
|
+
style = document.createElement('style');
|
|
44
|
+
style.id = 'custom-fonts';
|
|
45
|
+
document.head.appendChild(style);
|
|
46
|
+
}
|
|
47
|
+
style.innerHTML = customFontCSS;
|
|
48
|
+
// TODO: typekit 등 타 서비스 지원
|
|
49
|
+
let WebFontConfig = {};
|
|
50
|
+
if (googles.length) {
|
|
51
|
+
WebFontConfig.google = {
|
|
52
|
+
families: googles
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
if (customs.length) {
|
|
56
|
+
WebFontConfig.custom = {
|
|
57
|
+
families: customs
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
if (Object.keys(WebFontConfig).length)
|
|
61
|
+
WebFont.load(WebFontConfig);
|
|
62
|
+
return newState;
|
|
63
|
+
case CLEAR_FONT_LIST:
|
|
64
|
+
return [];
|
|
65
|
+
default:
|
|
66
|
+
return state;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
export default ReducerFont;
|
|
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AED,eAAe,WAAW,CAAA","sourcesContent":["import { CLEAR_FONT_LIST, UPDATE_FONT_LIST } from './redux-font-actions.js'\n\nimport { Action } from 'redux'\nimport WebFont from 'webfontloader'\n\ntype Font = {\n name: string\n provider: string\n uri: string\n active: boolean\n files: Array<{ name: string; fullpath: string }>\n}\n\nconst ReducerFont = (state = [], action: any) => {\n switch (action.type) {\n case UPDATE_FONT_LIST:\n let newState = action.list as Array<Font>\n let activatedFonts = newState.filter(font => font.active)\n\n let googles = [] as Array<string>\n let customs = [] as Array<string>\n let customFontCSS = ''\n\n activatedFonts.forEach(font => {\n const { name, provider, files, uri } = font\n\n if (provider === 'google') {\n googles.push(name)\n } else if (provider === 'custom') {\n customs.push(name)\n\n if (files && files.length > 0) {\n customFontCSS += files\n .map(file => {\n const { name: filename, fullpath } = file\n const bold = filename.toUpperCase().indexOf('BOLD') !== -1\n\n return `@font-face {\n font-family: '${name}';\n src: local('${name}'), url(${fullpath});\n font-weight: ${bold ? 'bold' : 'normal'};\n }\n `\n })\n .join('\\n')\n } else {\n customFontCSS += `@font-face {\n font-family: '${name}';\n src: local('${name}')${uri ? `, url(${uri})` : ''};\n }\n `\n }\n }\n })\n\n let style = document.head.querySelector('#custom-fonts') as HTMLStyleElement\n if (!style) {\n style = document.createElement('style')\n style.id = 'custom-fonts'\n document.head.appendChild(style)\n }\n style.innerHTML = customFontCSS\n\n // TODO: typekit 등 타 서비스 지원\n let WebFontConfig = {} as any\n if (googles.length) {\n WebFontConfig.google = {\n families: googles\n }\n }\n if (customs.length) {\n WebFontConfig.custom = {\n families: customs\n }\n }\n if (Object.keys(WebFontConfig).length) WebFont.load(WebFontConfig)\n\n return newState\n\n case CLEAR_FONT_LIST:\n return []\n\n default:\n return state\n }\n}\n\nexport default ReducerFont\n"]}
|