@konomi-app/ui 2.2.4 → 3.0.0

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.
@@ -1,17 +0,0 @@
1
- export declare const ATTRIBUTE_KEY = "data-konomi-ui-overlay";
2
- export declare const ATTRIBUTE_SHOWN = "data-shown";
3
- export declare class Overlay {
4
- protected readonly _root: HTMLDivElement;
5
- protected _shown: boolean;
6
- protected _disableBeforeUnload: boolean;
7
- constructor();
8
- show(): void;
9
- hide(): void;
10
- protected render(): void;
11
- /** JavaScript中にページを離れようとした場合にアラートを表示します */
12
- private beforeunload;
13
- /** @deprecated このメソッドは非推奨です。代わりに`show`メソッドを使用してください。 */
14
- start(): void;
15
- /** @deprecated このメソッドは非推奨です。代わりに`hide`メソッドを使用してください。 */
16
- stop(): void;
17
- }
@@ -1,47 +0,0 @@
1
- import { getBodyStyle, getRootStyle } from './style';
2
- export const ATTRIBUTE_KEY = 'data-konomi-ui-overlay';
3
- export const ATTRIBUTE_SHOWN = 'data-shown';
4
- export class Overlay {
5
- _root;
6
- _shown;
7
- _disableBeforeUnload;
8
- constructor() {
9
- this._shown = false;
10
- this._disableBeforeUnload = false;
11
- const root = document.createElement('div');
12
- this._root = root;
13
- this._root.classList.add(getRootStyle());
14
- document.body.classList.add(getBodyStyle());
15
- this._root.setAttribute(ATTRIBUTE_KEY, '');
16
- document.body.append(root);
17
- }
18
- show() {
19
- this._shown = true;
20
- this._root.setAttribute(ATTRIBUTE_SHOWN, '');
21
- document.body.setAttribute(ATTRIBUTE_KEY, '');
22
- window.addEventListener('beforeunload', this.beforeunload);
23
- this.render();
24
- }
25
- hide() {
26
- this._shown = false;
27
- this._root.removeAttribute(ATTRIBUTE_SHOWN);
28
- document.body.removeAttribute(ATTRIBUTE_KEY);
29
- window.removeEventListener('beforeunload', this.beforeunload);
30
- this.render();
31
- }
32
- render() { }
33
- /** JavaScript中にページを離れようとした場合にアラートを表示します */
34
- beforeunload(event) {
35
- event.preventDefault();
36
- event.returnValue = '';
37
- }
38
- /** @deprecated このメソッドは非推奨です。代わりに`show`メソッドを使用してください。 */
39
- start() {
40
- this.show();
41
- }
42
- /** @deprecated このメソッドは非推奨です。代わりに`hide`メソッドを使用してください。 */
43
- stop() {
44
- this.hide();
45
- }
46
- }
47
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/overlay/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAErD,MAAM,CAAC,MAAM,aAAa,GAAG,wBAAwB,CAAC;AACtD,MAAM,CAAC,MAAM,eAAe,GAAG,YAAY,CAAC;AAE5C,MAAM,OAAO,OAAO;IACC,KAAK,CAAiB;IAC/B,MAAM,CAAU;IAChB,oBAAoB,CAAU;IAExC;QACE,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,oBAAoB,GAAG,KAAK,CAAC;QAElC,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC3C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC,CAAC;QACzC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC,CAAC;QAC5C,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;QAC3C,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAEM,IAAI;QACT,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;QAC7C,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;QAC9C,MAAM,CAAC,gBAAgB,CAAC,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC3D,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;IAEM,IAAI;QACT,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC;QAC5C,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;QAC7C,MAAM,CAAC,mBAAmB,CAAC,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC9D,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;IAES,MAAM,KAAU,CAAC;IAE3B,2CAA2C;IACnC,YAAY,CAAC,KAAwB;QAC3C,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,KAAK,CAAC,WAAW,GAAG,EAAE,CAAC;IACzB,CAAC;IAED,wDAAwD;IACjD,KAAK;QACV,IAAI,CAAC,IAAI,EAAE,CAAC;IACd,CAAC;IACD,wDAAwD;IACjD,IAAI;QACT,IAAI,CAAC,IAAI,EAAE,CAAC;IACd,CAAC;CACF"}
@@ -1,2 +0,0 @@
1
- export declare const getBodyStyle: () => string;
2
- export declare const getRootStyle: () => string;
@@ -1,44 +0,0 @@
1
- import { css } from '@emotion/css';
2
- import { ATTRIBUTE_KEY, ATTRIBUTE_SHOWN } from '.';
3
- export const getBodyStyle = () => css `
4
- overflow: visible;
5
- &[${ATTRIBUTE_KEY}] {
6
- overflow: hidden;
7
- }
8
- `;
9
- export const getRootStyle = () => css `
10
- font-family: 'Yu Gothic Medium', '游ゴシック', YuGothic, 'メイリオ', 'Hiragino Kaku Gothic ProN',
11
- Meiryo, sans-serif;
12
- color: #356;
13
- font-size: 14px;
14
-
15
- overflow: hidden;
16
- background-color: #fffb;
17
- backdrop-filter: blur(4px);
18
- box-sizing: content-box;
19
-
20
- position: fixed;
21
- inset: 0;
22
- width: 100vw;
23
- height: 100vh;
24
-
25
- display: grid;
26
- transition: all 250ms ease;
27
- z-index: 1000;
28
- opacity: 0;
29
- transition: all 250ms ease;
30
-
31
- place-items: end stretch;
32
- @media (min-width: 640px) {
33
- font-size: 16px;
34
- place-items: center;
35
- }
36
-
37
- opacity: 0;
38
- pointer-events: none;
39
- &[${ATTRIBUTE_SHOWN}] {
40
- opacity: 1;
41
- pointer-events: all;
42
- }
43
- `;
44
- //# sourceMappingURL=style.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"style.js","sourceRoot":"","sources":["../../src/overlay/style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,GAAG,CAAC;AAEnD,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,EAAE,CAAC,GAAG,CAAA;;MAE/B,aAAa;;;CAGlB,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,EAAE,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA8B/B,eAAe;;;;CAIpB,CAAC"}
@@ -1,34 +0,0 @@
1
- import { Overlay } from './overlay';
2
- type Label = string | string[];
3
- type TaskStatus = 'new' | 'in-progress' | 'done' | 'error';
4
- type Task = {
5
- key: string;
6
- label: Label;
7
- status: TaskStatus;
8
- };
9
- type ConstructorProps = Readonly<Partial<{
10
- taskList: Task[];
11
- }>>;
12
- export declare class TaskListOverlay extends Overlay {
13
- #private;
14
- protected readonly _contentElement: HTMLDivElement;
15
- constructor(props?: ConstructorProps);
16
- hide(): void;
17
- done(key: string): void;
18
- error(key: string): void;
19
- inProgress(key: string): void;
20
- addTask(...tasks: {
21
- key: string;
22
- label: Label;
23
- }[]): void;
24
- render(): void;
25
- private renderTask;
26
- private getTaskStatusElement;
27
- private containerStyle;
28
- private contentStyle;
29
- private taskListContainerStyle;
30
- private taskContainerStyle;
31
- private taskLabelStyle;
32
- private taskStatusStyle;
33
- }
34
- export {};
@@ -1,177 +0,0 @@
1
- import { css } from '@emotion/css';
2
- import { Overlay } from './overlay';
3
- export class TaskListOverlay extends Overlay {
4
- #taskList;
5
- _contentElement;
6
- constructor(props = {}) {
7
- super();
8
- this.#taskList = props.taskList ?? [];
9
- const container = document.createElement('div');
10
- container.classList.add(this.containerStyle);
11
- this._root.append(container);
12
- const contentElement = document.createElement('div');
13
- this._contentElement = contentElement;
14
- contentElement.classList.add(this.contentStyle);
15
- container.append(contentElement);
16
- this.render();
17
- }
18
- hide() {
19
- this.#taskList = [];
20
- super.hide();
21
- }
22
- done(key) {
23
- const task = this.#taskList.find((t) => t.key === key);
24
- if (task) {
25
- task.status = 'done';
26
- this.render();
27
- }
28
- }
29
- error(key) {
30
- const task = this.#taskList.find((t) => t.key === key);
31
- if (task) {
32
- task.status = 'error';
33
- this.render();
34
- }
35
- }
36
- inProgress(key) {
37
- const task = this.#taskList.find((t) => t.key === key);
38
- if (task) {
39
- task.status = 'in-progress';
40
- this.render();
41
- }
42
- }
43
- addTask(...tasks) {
44
- this.#taskList.push(...tasks.map(({ key, label }) => ({ key, label, status: 'new' })));
45
- this.render();
46
- }
47
- render() {
48
- super.render();
49
- this._contentElement.innerHTML = `
50
- <div class="${this.taskListContainerStyle}">
51
- ${this.#taskList.map((task) => this.renderTask(task)).join('')}
52
- </div>
53
- `;
54
- }
55
- renderTask(task) {
56
- const label = Array.isArray(task.label) ? task.label.join(' ') : task.label;
57
- const status = task.status;
58
- return `
59
- <div class="${this.taskContainerStyle}">
60
- <div class="${this.taskStatusStyle} status-${status}">${this.getTaskStatusElement(task.status)}</div>
61
- <div class="${this.taskLabelStyle}">${label}</div>
62
- </div>
63
- `;
64
- }
65
- getTaskStatusElement(status) {
66
- switch (status) {
67
- case 'new':
68
- return `<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" fill="none" stroke="#ddd" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-minus-circle"><circle cx="12" cy="12" r="10"></circle><line x1="8" y1="12" x2="16" y2="12"></line></svg>`;
69
- case 'in-progress':
70
- return `<div><div></div></div>`;
71
- case 'done':
72
- return `<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" fill="none" stroke="#80beaf" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-check-circle"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path><polyline points="22 4 12 14.01 9 11.01"></polyline></svg>`;
73
- default:
74
- return ``;
75
- }
76
- }
77
- containerStyle = css `
78
- display: flex;
79
- flex-direction: column;
80
- align-items: center;
81
- justify-content: center;
82
- gap: 32px;
83
- padding: 32px 64px;
84
- background-color: #fffc;
85
- border-radius: 8px;
86
- box-shadow: 0 5px 24px -6px #0002;
87
- width: 300px;
88
- max-width: 90vw;
89
- min-height: 200px;
90
- position: relative;
91
- overflow: hidden;
92
- transition: all 250ms ease;
93
-
94
- @keyframes spin {
95
- 0% {
96
- transform: rotate(0deg);
97
- border-radius: 1em;
98
- }
99
- 20% {
100
- transform: rotate(0deg);
101
- }
102
- 30%,
103
- 60% {
104
- border-radius: 0.25em;
105
- }
106
- 70% {
107
- transform: rotate(180deg);
108
- }
109
- 100% {
110
- transform: rotate(180deg);
111
- border-radius: 1em;
112
- }
113
- }
114
- `;
115
- contentStyle = css `
116
- width: 100%;
117
- `;
118
- taskListContainerStyle = css `
119
- display: flex;
120
- flex-direction: column;
121
- gap: 1em;
122
- width: 100%;
123
- `;
124
- taskContainerStyle = css `
125
- display: flex;
126
- align-items: center;
127
- gap: 1em;
128
- `;
129
- taskLabelStyle = css ``;
130
- taskStatusStyle = css `
131
- font-size: 32px;
132
- width: 1em;
133
- height: 1em;
134
- display: flex;
135
- justify-content: center;
136
- align-items: center;
137
-
138
- &.status-new {
139
- }
140
-
141
- &.status-in-progress {
142
- border-radius: 50%;
143
- box-shadow: inset 0 0 0 1px #3b82f633;
144
- position: relative;
145
- animation: rotate 1.2s infinite linear;
146
- > div {
147
- position: absolute;
148
- left: 50%;
149
- top: 50%;
150
- width: 0.5em;
151
- height: 1em;
152
- margin-left: -0.5em;
153
- margin-top: -0.5em;
154
- overflow: hidden;
155
- transform-origin: 0.5em 0.5em;
156
- mask-image: linear-gradient(top, #000f, #0000);
157
- -webkit-mask-image: -webkit-linear-gradient(top, #000f, #0000);
158
-
159
- > div {
160
- width: 1em;
161
- height: 1em;
162
- border-radius: 50%;
163
- box-shadow: inset 0 0 0 1px #3b82f6;
164
- }
165
- }
166
- @keyframes rotate {
167
- 0% {
168
- transform: rotate(0deg);
169
- }
170
- 100% {
171
- transform: rotate(360deg);
172
- }
173
- }
174
- }
175
- `;
176
- }
177
- //# sourceMappingURL=task-list-overlay.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"task-list-overlay.js","sourceRoot":"","sources":["../src/task-list-overlay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAYpC,MAAM,OAAO,eAAgB,SAAQ,OAAO;IAC1C,SAAS,CAAS;IAEC,eAAe,CAAiB;IAEnD,YAAmB,QAA0B,EAAE;QAC7C,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAC;QAEtC,MAAM,SAAS,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAChD,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC7C,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAE7B,MAAM,cAAc,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QACrD,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;QACtC,cAAc,CAAC,SAAS,CAAC,GAA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