@operato/font 10.29.34 → 10.29.37

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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@operato/font",
3
3
  "description": "User interface to select font and create font.",
4
4
  "author": "heartyoh",
5
- "version": "10.29.34",
5
+ "version": "10.29.37",
6
6
  "type": "module",
7
7
  "main": "dist/src/index.js",
8
8
  "module": "dist/src/index.js",
@@ -51,15 +51,15 @@
51
51
  },
52
52
  "dependencies": {
53
53
  "@material/web": "^2.0.0",
54
- "@operato/attachment": "^10.29.34",
54
+ "@operato/attachment": "^10.29.37",
55
55
  "@operato/headroom": "^10.29.1",
56
56
  "@operato/i18n": "^10.29.27",
57
- "@operato/input": "^10.29.30",
58
- "@operato/layout": "^10.29.30",
59
- "@operato/property-editor": "^10.29.34",
57
+ "@operato/input": "^10.29.37",
58
+ "@operato/layout": "^10.29.37",
59
+ "@operato/property-editor": "^10.29.37",
60
60
  "@operato/pull-to-refresh": "^10.29.23",
61
- "@operato/shell": "^10.29.30",
62
- "@operato/utils": "^10.29.23",
61
+ "@operato/shell": "^10.29.37",
62
+ "@operato/utils": "^10.29.37",
63
63
  "webfontloader": "^1.6.28"
64
64
  },
65
65
  "devDependencies": {
@@ -96,5 +96,5 @@
96
96
  "prettier --write"
97
97
  ]
98
98
  },
99
- "gitHead": "0d3019a310120559ca3d3fcaeeff365d875b208f"
99
+ "gitHead": "38361a65226ee9f23814747b4f0520edf42c3184"
100
100
  }
@@ -0,0 +1,64 @@
1
+ import { aTimeout, expect, fixture } from '@open-wc/testing'
2
+ import { html } from 'lit'
3
+
4
+ import '../src/font-creation-card.js'
5
+
6
+ /**
7
+ * The font card's file pick.
8
+ *
9
+ * ## Why this is tested
10
+ *
11
+ * The card picked font files with its own `ox-file-selector`, one of several file pickers that did
12
+ * the same thing. It now uses `ox-input-file`, the one picker. What must hold: picked font files
13
+ * reach `create-font`, a file that is not a font is refused, picking does not flip the card, and
14
+ * reset empties the pick.
15
+ */
16
+ describe('font-creation-card', () => {
17
+ const drop = (area: HTMLElement, ...files: File[]) => {
18
+ const dataTransfer = new DataTransfer()
19
+ files.forEach(one => dataTransfer.items.add(one))
20
+ area.dispatchEvent(new DragEvent('drop', { dataTransfer, bubbles: true, cancelable: true }))
21
+ }
22
+
23
+ it('takes the picked font files into create-font', async () => {
24
+ const card: any = await fixture(html`<font-creation-card></font-creation-card>`)
25
+ card.provider = 'custom'
26
+ await card.updateComplete
27
+
28
+ const picker = card.renderRoot.querySelector('ox-input-file')
29
+ expect(picker, 'the card has no picker').to.exist
30
+
31
+ drop(picker, new File(['x'], 'brand.woff2'), new File(['x'], 'notes.txt', { type: 'text/plain' }))
32
+ await aTimeout(0)
33
+ await card.updateComplete
34
+
35
+ expect(card.files.map((one: File) => one.name), 'a non-font was taken').to.deep.equal(['brand.woff2'])
36
+
37
+ let detail: any
38
+ card.addEventListener('create-font', (e: CustomEvent) => (detail = e.detail))
39
+ const form = card.renderRoot.querySelector('form')
40
+ ;(form.elements.namedItem('name') as HTMLInputElement).value = 'Brand'
41
+ form.dispatchEvent(new Event('submit', { cancelable: true }))
42
+
43
+ expect(detail.files.map((one: File) => one.name)).to.deep.equal(['brand.woff2'])
44
+ })
45
+
46
+ it('does not flip when the picker is clicked, and reset empties the pick', async () => {
47
+ const card: any = await fixture(html`<font-creation-card></font-creation-card>`)
48
+ card.provider = 'custom'
49
+ card.classList.add('flipped')
50
+ await card.updateComplete
51
+
52
+ const picker = card.renderRoot.querySelector('ox-input-file')
53
+ picker.click()
54
+ expect(card.classList.contains('flipped'), 'clicking the picker flipped the card').to.equal(true)
55
+
56
+ drop(picker, new File(['x'], 'brand.ttf'))
57
+ await aTimeout(0)
58
+ card.reset()
59
+ await card.updateComplete
60
+
61
+ expect(card.files).to.deep.equal([])
62
+ expect(picker.value).to.deep.equal([])
63
+ })
64
+ })
@@ -1,11 +0,0 @@
1
- import '@material/web/icon/icon.js';
2
- import { LitElement } from 'lit';
3
- export declare class OxFileSelector extends LitElement {
4
- static styles: import("lit").CSSResult[];
5
- label: string;
6
- accept?: string;
7
- showFilename: boolean;
8
- multiple: boolean;
9
- _files: Array<any>;
10
- render(): import("lit-html").TemplateResult<1>;
11
- }
@@ -1,130 +0,0 @@
1
- import { __decorate } from "tslib";
2
- import '@material/web/icon/icon.js';
3
- import { LitElement, css, html } from 'lit';
4
- import { customElement, property } from 'lit/decorators.js';
5
- let OxFileSelector = class OxFileSelector extends LitElement {
6
- constructor() {
7
- super(...arguments);
8
- this.label = 'select file';
9
- this.showFilename = false;
10
- this.multiple = false;
11
- this._files = [];
12
- }
13
- render() {
14
- return html `
15
- <div id="input-box">
16
- ${this.showFilename
17
- ? html `
18
- <input class="upload-name" value=${this._files.map(f => f.name).join(', ') || this.label} disabled />
19
- `
20
- : html ``}
21
- <label for="input-file">${this.label}</label>
22
- <input
23
- id="input-file"
24
- type="file"
25
- accept="${this.accept}"
26
- class="upload-hidden"
27
- ?multiple=${this.multiple}
28
- hidden
29
- @change=${(e) => {
30
- const el = e.currentTarget;
31
- this.dispatchEvent(new CustomEvent('file-change', {
32
- bubbles: true,
33
- composed: true,
34
- detail: {
35
- files: el.files
36
- }
37
- }));
38
- el.value = '';
39
- }}
40
- />
41
- </div>
42
- `;
43
- }
44
- };
45
- OxFileSelector.styles = [
46
- css `
47
- :host {
48
- flex: 1;
49
- display: flex;
50
- flex-direction: column;
51
- position: relative;
52
- overflow: hidden;
53
- }
54
-
55
- #input-box {
56
- display: flex;
57
- width: 100%;
58
- height: 100%;
59
- }
60
-
61
- input[type='file'] {
62
- position: absolute;
63
- width: 0px;
64
- height: 0px;
65
- padding: 0;
66
- margin: -1px;
67
- overflow: hidden;
68
- clip: rect(0, 0, 0, 0);
69
- border: 0;
70
- border-radius: inherit;
71
- background-color: inherit;
72
- }
73
-
74
- label {
75
- padding: unset;
76
- width: 100%;
77
- height: 100%;
78
- box-sizing: border-box;
79
- display: flex;
80
- align-items: center;
81
- justify-content: center;
82
-
83
- color: var(--file-selector-color, #999);
84
- font-size: inherit;
85
- line-height: normal;
86
- vertical-align: middle;
87
- background-color: var(--file-selector-bg-color, #fdfdfd);
88
- cursor: pointer;
89
- border: var(--file-selector-border, 1px solid #ebebeb);
90
- border-radius: var(--file-selector-border-radius, 0.25em);
91
- }
92
-
93
- /* named upload */
94
- .upload-name {
95
- flex: 1;
96
- padding: 0.5em 0.75em; /* label의 패딩값과 일치 */
97
- font-size: inherit;
98
- font-family: inherit;
99
- line-height: normal;
100
- vertical-align: middle;
101
- background-color: #f5f5f5;
102
- border: 1px solid #ebebeb;
103
- border-bottom-color: #e2e2e2;
104
- border-radius: 0.25em;
105
- -webkit-appearance: none; /* 네이티브 외형 감추기 */
106
- -moz-appearance: none;
107
- appearance: none;
108
- }
109
- `
110
- ];
111
- __decorate([
112
- property({ type: String })
113
- ], OxFileSelector.prototype, "label", void 0);
114
- __decorate([
115
- property({ type: String })
116
- ], OxFileSelector.prototype, "accept", void 0);
117
- __decorate([
118
- property({ type: Boolean, attribute: 'show-filename' })
119
- ], OxFileSelector.prototype, "showFilename", void 0);
120
- __decorate([
121
- property({ type: Boolean, attribute: 'multiple' })
122
- ], OxFileSelector.prototype, "multiple", void 0);
123
- __decorate([
124
- property({ type: Array })
125
- ], OxFileSelector.prototype, "_files", void 0);
126
- OxFileSelector = __decorate([
127
- customElement('ox-file-selector')
128
- ], OxFileSelector);
129
- export { OxFileSelector };
130
- //# sourceMappingURL=ox-file-selector.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ox-file-selector.js","sourceRoot":"","sources":["../../src/ox-file-selector.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AAEnC,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAGpD,IAAM,cAAc,GAApB,MAAM,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AAE,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;AAxEvC,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CA4G1B","sourcesContent":["import '@material/web/icon/icon.js'\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 border-radius: inherit;\n background-color: inherit;\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"]}