@arcanejs/toolkit-frontend 0.3.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.
- package/LICENSE +21 -0
- package/README.md +43 -0
- package/dist/chunk-35U577MM.mjs +75 -0
- package/dist/chunk-6Z2ACPNM.mjs +155 -0
- package/dist/chunk-7P6ASYW6.mjs +9 -0
- package/dist/chunk-KNYDA6D6.js +53 -0
- package/dist/chunk-MLKGABMK.js +9 -0
- package/dist/chunk-UJVH3PQF.mjs +53 -0
- package/dist/chunk-XEIKOLS2.js +75 -0
- package/dist/chunk-Y5UYS6EX.js +155 -0
- package/dist/components/core/index.d.mts +2 -0
- package/dist/components/core/index.d.ts +2 -0
- package/dist/components/core/index.js +12 -0
- package/dist/components/core/index.mjs +12 -0
- package/dist/components/index.d.mts +81 -0
- package/dist/components/index.d.ts +81 -0
- package/dist/components/index.js +1100 -0
- package/dist/components/index.mjs +1100 -0
- package/dist/index-Db4cPoyC.d.mts +21 -0
- package/dist/index-Db4cPoyC.d.ts +21 -0
- package/dist/styling.d.mts +36 -0
- package/dist/styling.d.ts +36 -0
- package/dist/styling.js +27 -0
- package/dist/styling.mjs +27 -0
- package/dist/types.d.mts +9 -0
- package/dist/types.d.ts +9 -0
- package/dist/types.js +1 -0
- package/dist/types.mjs +0 -0
- package/dist/util/index.d.mts +23 -0
- package/dist/util/index.d.ts +23 -0
- package/dist/util/index.js +17 -0
- package/dist/util/index.mjs +17 -0
- package/package.json +77 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Sam Lanning
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# `@arcanejs/diff`
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@arcanejs/diff)
|
|
4
|
+
|
|
5
|
+
This package provides an easy way to:
|
|
6
|
+
|
|
7
|
+
- Create diffs by comparing objects
|
|
8
|
+
- Update objects by applying diffs
|
|
9
|
+
|
|
10
|
+
This library is written in TypeScript,
|
|
11
|
+
and produces diffs that are type-safe,
|
|
12
|
+
and can only be applied to objects that match the type
|
|
13
|
+
of the objects being compared.
|
|
14
|
+
|
|
15
|
+
This package is part of the
|
|
16
|
+
[`arcanejs` project](https://github.com/arcanejs/arcanejs#arcanejs),
|
|
17
|
+
and is used to maintain a copy of a JSON tree in downstream clients in real-time
|
|
18
|
+
via websockets.
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { diffJson, Diff } from '@arcanejs/diff/diff';
|
|
24
|
+
import { patchJson } from '@arcanejs/diff/patch';
|
|
25
|
+
|
|
26
|
+
type E = {
|
|
27
|
+
foo: string;
|
|
28
|
+
bar?: number[];
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const a: E = { foo: 'bar' };
|
|
32
|
+
const b: E = { foo: 'baz', bar: [1] };
|
|
33
|
+
|
|
34
|
+
const diffA: Diff<E> = diffJson(a, b);
|
|
35
|
+
|
|
36
|
+
const resultA = patchJson(a, diffA);
|
|
37
|
+
|
|
38
|
+
console.log(resultB); // { foo: 'baz', bar: [1] }
|
|
39
|
+
|
|
40
|
+
const c = { baz: 'foo' };
|
|
41
|
+
|
|
42
|
+
const resultB = patchJson(c, diffA); // TypeScript Type Error: Property 'baz' is missing in type '{ foo: string; bar?: number[] | undefined; }' but required in type '{ baz: string; }'
|
|
43
|
+
```
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// src/util/touch.ts
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
function switchToMouseMode(ev) {
|
|
4
|
+
if (ev.movementX === 0 && ev.movementY === 0) return;
|
|
5
|
+
document.body.classList.remove("touch-mode");
|
|
6
|
+
}
|
|
7
|
+
function switchToTouchMode() {
|
|
8
|
+
document.body.classList.add("touch-mode");
|
|
9
|
+
}
|
|
10
|
+
function initialiseListeners() {
|
|
11
|
+
window.addEventListener("mousemove", switchToMouseMode);
|
|
12
|
+
window.addEventListener("touchstart", switchToTouchMode, { passive: false });
|
|
13
|
+
window.addEventListener("contextmenu", (e) => {
|
|
14
|
+
if (e.pointerType === "touch") {
|
|
15
|
+
e.preventDefault();
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
var usePressable = (click) => {
|
|
20
|
+
const [touching, setTouching] = useState(false);
|
|
21
|
+
return {
|
|
22
|
+
touching,
|
|
23
|
+
handlers: {
|
|
24
|
+
onClick: click,
|
|
25
|
+
onTouchStart: () => {
|
|
26
|
+
setTouching(true);
|
|
27
|
+
},
|
|
28
|
+
onTouchMove: () => {
|
|
29
|
+
setTouching(false);
|
|
30
|
+
},
|
|
31
|
+
onTouchEnd: (event) => {
|
|
32
|
+
if (touching) {
|
|
33
|
+
event.preventDefault();
|
|
34
|
+
setTouching(false);
|
|
35
|
+
click();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
function trackTouch(touch, move, end) {
|
|
42
|
+
const touchMove = (ev) => {
|
|
43
|
+
ev.preventDefault();
|
|
44
|
+
for (const t of Array.from(ev.changedTouches)) {
|
|
45
|
+
if (t.identifier === touch.identifier) {
|
|
46
|
+
move({ pageX: t.pageX, pageY: t.pageY });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const touchEnd = (ev) => {
|
|
51
|
+
for (const t of Array.from(ev.changedTouches)) {
|
|
52
|
+
if (t.identifier === touch.identifier) {
|
|
53
|
+
end({ pageX: t.pageX, pageY: t.pageY });
|
|
54
|
+
window.removeEventListener("touchmove", touchMove);
|
|
55
|
+
window.removeEventListener("touchend", touchEnd);
|
|
56
|
+
window.removeEventListener("touchcancel", touchEnd);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
window.addEventListener("touchmove", touchMove, { passive: false });
|
|
61
|
+
window.addEventListener("touchend", touchEnd);
|
|
62
|
+
window.addEventListener("touchcancel", touchEnd);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// src/util/index.ts
|
|
66
|
+
var calculateClass = (...args) => args.filter((a) => !!a).join(" ");
|
|
67
|
+
|
|
68
|
+
export {
|
|
69
|
+
switchToMouseMode,
|
|
70
|
+
switchToTouchMode,
|
|
71
|
+
initialiseListeners,
|
|
72
|
+
usePressable,
|
|
73
|
+
trackTouch,
|
|
74
|
+
calculateClass
|
|
75
|
+
};
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
// src/styling.ts
|
|
2
|
+
import { createGlobalStyle, css } from "styled-components";
|
|
3
|
+
var GlobalStyle = createGlobalStyle`
|
|
4
|
+
body {
|
|
5
|
+
&.touch-mode * {
|
|
6
|
+
cursor: none !important;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
`;
|
|
10
|
+
var THEME = {
|
|
11
|
+
colorGreen: "#98c379",
|
|
12
|
+
colorRed: "#e06c75",
|
|
13
|
+
colorAmber: "#d19a66",
|
|
14
|
+
bgDark1: "#252524",
|
|
15
|
+
bg: "#2a2a2b",
|
|
16
|
+
bgLight1: "#353638",
|
|
17
|
+
borderDark: "#151516",
|
|
18
|
+
borderLight: "#1c1d1d",
|
|
19
|
+
borderLighter: "#252524",
|
|
20
|
+
borderLighterer: "#6b6b67",
|
|
21
|
+
hint: "#4286f4",
|
|
22
|
+
hintRGB: "66, 134, 244",
|
|
23
|
+
hintDark1: "#2a77f3",
|
|
24
|
+
textNormal: "#F3F3F5",
|
|
25
|
+
textMuted: "#777777",
|
|
26
|
+
sizingPx: {
|
|
27
|
+
spacing: 15,
|
|
28
|
+
unitHeight: 40
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
var BaseStyle = createGlobalStyle`
|
|
32
|
+
* {
|
|
33
|
+
box-sizing: border-box;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
body {
|
|
37
|
+
background: #333;
|
|
38
|
+
margin: 0;
|
|
39
|
+
padding: 0;
|
|
40
|
+
font-size: 14px;
|
|
41
|
+
font-family: sans-serif;
|
|
42
|
+
}
|
|
43
|
+
`;
|
|
44
|
+
var buttonStateNormal = css`
|
|
45
|
+
color: ${(p) => p.theme.textNormal};
|
|
46
|
+
background: linear-gradient(to bottom, #4f5053, #343436);
|
|
47
|
+
text-shadow: 0 -1px rgba(0, 0, 0, 0.7);
|
|
48
|
+
box-shadow:
|
|
49
|
+
inset 0 1px 0 rgba(255, 255, 255, 0.15),
|
|
50
|
+
0 1px 0 0 rgba(0, 0, 0, 0.25);
|
|
51
|
+
`;
|
|
52
|
+
var buttonStateNormalHover = css`
|
|
53
|
+
color: ${(p) => p.theme.textNormal};
|
|
54
|
+
outline-color: rgba(243, 243, 245, 0.3);
|
|
55
|
+
background: linear-gradient(to bottom, #5e6064, #393a3b);
|
|
56
|
+
text-shadow: 0 -1px rgba(0, 0, 0, 0.7);
|
|
57
|
+
`;
|
|
58
|
+
var buttonStateNormalActive = css`
|
|
59
|
+
color: #ffffff;
|
|
60
|
+
outline-color: rgba(255, 255, 255, 0.3);
|
|
61
|
+
background: linear-gradient(to bottom, #242525, #37383a);
|
|
62
|
+
text-shadow: 0 -1px rgba(0, 0, 0, 0.4);
|
|
63
|
+
box-shadow:
|
|
64
|
+
inset 0 1px 2px rgba(0, 0, 0, 0.2),
|
|
65
|
+
0 1px 0 0 rgba(255, 255, 255, 0.15);
|
|
66
|
+
transition-duration: 50ms;
|
|
67
|
+
`;
|
|
68
|
+
var buttonStatePressed = css`
|
|
69
|
+
${buttonStateNormalActive}
|
|
70
|
+
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.1), 0 1px 0 0 rgba(255,255,255,0.15);
|
|
71
|
+
`;
|
|
72
|
+
var buttonStatePressedHover = css`
|
|
73
|
+
${buttonStateNormalActive}
|
|
74
|
+
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.1), 0 1px 0 0 rgba(255,255,255,0.15);
|
|
75
|
+
background: linear-gradient(to bottom, #282929, #414243);
|
|
76
|
+
`;
|
|
77
|
+
var buttonStatePressedActive = buttonStateNormalActive;
|
|
78
|
+
var buttonStateDisabled = css`
|
|
79
|
+
${buttonStateNormal}
|
|
80
|
+
|
|
81
|
+
cursor: default;
|
|
82
|
+
background: ${(p) => p.theme.bg} !important;
|
|
83
|
+
color: rgba(${(p) => p.theme.textNormal}, 0.4);
|
|
84
|
+
`;
|
|
85
|
+
var button = css`
|
|
86
|
+
position: relative;
|
|
87
|
+
box-sizing: border-box;
|
|
88
|
+
cursor: pointer;
|
|
89
|
+
transition: all 200ms;
|
|
90
|
+
border-radius: 3px;
|
|
91
|
+
border: 1px solid ${(p) => p.theme.borderDark};
|
|
92
|
+
overflow: hidden;
|
|
93
|
+
display: flex;
|
|
94
|
+
justify-content: center;
|
|
95
|
+
align-items: center;
|
|
96
|
+
outline-color: transparent;
|
|
97
|
+
${buttonStateNormal}
|
|
98
|
+
|
|
99
|
+
&:hover {
|
|
100
|
+
${buttonStateNormalHover}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
&:active {
|
|
104
|
+
${buttonStateNormalActive}
|
|
105
|
+
}
|
|
106
|
+
`;
|
|
107
|
+
var buttonPressed = css`
|
|
108
|
+
${buttonStatePressed}
|
|
109
|
+
|
|
110
|
+
&:hover {
|
|
111
|
+
${buttonStatePressedHover}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
&:active {
|
|
115
|
+
${buttonStatePressedActive}
|
|
116
|
+
}
|
|
117
|
+
`;
|
|
118
|
+
var buttonDisabled = css`
|
|
119
|
+
${buttonStateDisabled}
|
|
120
|
+
|
|
121
|
+
&:hover, &:active {
|
|
122
|
+
${buttonStateDisabled}
|
|
123
|
+
}
|
|
124
|
+
`;
|
|
125
|
+
var rectButton = button;
|
|
126
|
+
var touchIndicatorNormal = css`
|
|
127
|
+
position: absolute;
|
|
128
|
+
top: -6px;
|
|
129
|
+
right: -6px;
|
|
130
|
+
left: -6px;
|
|
131
|
+
bottom: -6px;
|
|
132
|
+
border-radius: 6px;
|
|
133
|
+
border: 2px solid rgba(0, 0, 0, 0);
|
|
134
|
+
background-color: none;
|
|
135
|
+
transition: border-color 300ms;
|
|
136
|
+
`;
|
|
137
|
+
var touchIndicatorTouching = css`
|
|
138
|
+
border-color: ${(p) => p.theme.hint};
|
|
139
|
+
background-color: rgba(${(p) => p.theme.hintRGB}, 0.2);
|
|
140
|
+
transition: border-color 0s;
|
|
141
|
+
`;
|
|
142
|
+
|
|
143
|
+
export {
|
|
144
|
+
GlobalStyle,
|
|
145
|
+
THEME,
|
|
146
|
+
BaseStyle,
|
|
147
|
+
buttonStateNormal,
|
|
148
|
+
buttonStateNormalHover,
|
|
149
|
+
buttonStateNormalActive,
|
|
150
|
+
buttonPressed,
|
|
151
|
+
buttonDisabled,
|
|
152
|
+
rectButton,
|
|
153
|
+
touchIndicatorNormal,
|
|
154
|
+
touchIndicatorTouching
|
|
155
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkXEIKOLS2js = require('./chunk-XEIKOLS2.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkMLKGABMKjs = require('./chunk-MLKGABMK.js');
|
|
7
|
+
|
|
8
|
+
// src/components/core/index.ts
|
|
9
|
+
var core_exports = {};
|
|
10
|
+
_chunkMLKGABMKjs.__export.call(void 0, core_exports, {
|
|
11
|
+
Icon: () => Icon,
|
|
12
|
+
TRANSPARENCY_SVG: () => TRANSPARENCY_SVG,
|
|
13
|
+
TRANSPARENCY_SVG_URI: () => TRANSPARENCY_SVG_URI
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
// src/components/core/icon.tsx
|
|
17
|
+
var _styledcomponents = require('styled-components');
|
|
18
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
19
|
+
var ICON_CLASS = "icon";
|
|
20
|
+
var Span = _styledcomponents.styled.span`
|
|
21
|
+
font-family: 'Material Symbols Outlined';
|
|
22
|
+
font-weight: normal;
|
|
23
|
+
font-style: normal;
|
|
24
|
+
font-size: 22px;
|
|
25
|
+
display: inline-block;
|
|
26
|
+
line-height: 1;
|
|
27
|
+
text-transform: none;
|
|
28
|
+
letter-spacing: normal;
|
|
29
|
+
word-wrap: normal;
|
|
30
|
+
white-space: nowrap;
|
|
31
|
+
direction: ltr;
|
|
32
|
+
font-variation-settings:
|
|
33
|
+
'wght' 300,
|
|
34
|
+
'GRAD' -25;
|
|
35
|
+
`;
|
|
36
|
+
var Icon = ({ icon, ...props }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Span, { className: _chunkXEIKOLS2js.calculateClass.call(void 0, props.className, ICON_CLASS), ...props, children: icon });
|
|
37
|
+
|
|
38
|
+
// src/components/core/index.ts
|
|
39
|
+
var TRANSPARENCY_SVG = `
|
|
40
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10">
|
|
41
|
+
<rect width="10px" height="10px" fill="#333" />
|
|
42
|
+
<rect width="5px" height="5px" fill="#ddd" y="5"/>
|
|
43
|
+
<rect width="5px" height="5px" fill="#ddd" x="5"/>
|
|
44
|
+
</svg>
|
|
45
|
+
`;
|
|
46
|
+
var TRANSPARENCY_SVG_URI = `data:image/svg+xml,${encodeURIComponent(TRANSPARENCY_SVG)}`;
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
exports.Icon = Icon; exports.TRANSPARENCY_SVG = TRANSPARENCY_SVG; exports.TRANSPARENCY_SVG_URI = TRANSPARENCY_SVG_URI; exports.core_exports = core_exports;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
exports.__export = __export;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import {
|
|
2
|
+
calculateClass
|
|
3
|
+
} from "./chunk-35U577MM.mjs";
|
|
4
|
+
import {
|
|
5
|
+
__export
|
|
6
|
+
} from "./chunk-7P6ASYW6.mjs";
|
|
7
|
+
|
|
8
|
+
// src/components/core/index.ts
|
|
9
|
+
var core_exports = {};
|
|
10
|
+
__export(core_exports, {
|
|
11
|
+
Icon: () => Icon,
|
|
12
|
+
TRANSPARENCY_SVG: () => TRANSPARENCY_SVG,
|
|
13
|
+
TRANSPARENCY_SVG_URI: () => TRANSPARENCY_SVG_URI
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
// src/components/core/icon.tsx
|
|
17
|
+
import { styled } from "styled-components";
|
|
18
|
+
import { jsx } from "react/jsx-runtime";
|
|
19
|
+
var ICON_CLASS = "icon";
|
|
20
|
+
var Span = styled.span`
|
|
21
|
+
font-family: 'Material Symbols Outlined';
|
|
22
|
+
font-weight: normal;
|
|
23
|
+
font-style: normal;
|
|
24
|
+
font-size: 22px;
|
|
25
|
+
display: inline-block;
|
|
26
|
+
line-height: 1;
|
|
27
|
+
text-transform: none;
|
|
28
|
+
letter-spacing: normal;
|
|
29
|
+
word-wrap: normal;
|
|
30
|
+
white-space: nowrap;
|
|
31
|
+
direction: ltr;
|
|
32
|
+
font-variation-settings:
|
|
33
|
+
'wght' 300,
|
|
34
|
+
'GRAD' -25;
|
|
35
|
+
`;
|
|
36
|
+
var Icon = ({ icon, ...props }) => /* @__PURE__ */ jsx(Span, { className: calculateClass(props.className, ICON_CLASS), ...props, children: icon });
|
|
37
|
+
|
|
38
|
+
// src/components/core/index.ts
|
|
39
|
+
var TRANSPARENCY_SVG = `
|
|
40
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10">
|
|
41
|
+
<rect width="10px" height="10px" fill="#333" />
|
|
42
|
+
<rect width="5px" height="5px" fill="#ddd" y="5"/>
|
|
43
|
+
<rect width="5px" height="5px" fill="#ddd" x="5"/>
|
|
44
|
+
</svg>
|
|
45
|
+
`;
|
|
46
|
+
var TRANSPARENCY_SVG_URI = `data:image/svg+xml,${encodeURIComponent(TRANSPARENCY_SVG)}`;
|
|
47
|
+
|
|
48
|
+
export {
|
|
49
|
+
Icon,
|
|
50
|
+
TRANSPARENCY_SVG,
|
|
51
|
+
TRANSPARENCY_SVG_URI,
|
|
52
|
+
core_exports
|
|
53
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/util/touch.ts
|
|
2
|
+
var _react = require('react');
|
|
3
|
+
function switchToMouseMode(ev) {
|
|
4
|
+
if (ev.movementX === 0 && ev.movementY === 0) return;
|
|
5
|
+
document.body.classList.remove("touch-mode");
|
|
6
|
+
}
|
|
7
|
+
function switchToTouchMode() {
|
|
8
|
+
document.body.classList.add("touch-mode");
|
|
9
|
+
}
|
|
10
|
+
function initialiseListeners() {
|
|
11
|
+
window.addEventListener("mousemove", switchToMouseMode);
|
|
12
|
+
window.addEventListener("touchstart", switchToTouchMode, { passive: false });
|
|
13
|
+
window.addEventListener("contextmenu", (e) => {
|
|
14
|
+
if (e.pointerType === "touch") {
|
|
15
|
+
e.preventDefault();
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
var usePressable = (click) => {
|
|
20
|
+
const [touching, setTouching] = _react.useState.call(void 0, false);
|
|
21
|
+
return {
|
|
22
|
+
touching,
|
|
23
|
+
handlers: {
|
|
24
|
+
onClick: click,
|
|
25
|
+
onTouchStart: () => {
|
|
26
|
+
setTouching(true);
|
|
27
|
+
},
|
|
28
|
+
onTouchMove: () => {
|
|
29
|
+
setTouching(false);
|
|
30
|
+
},
|
|
31
|
+
onTouchEnd: (event) => {
|
|
32
|
+
if (touching) {
|
|
33
|
+
event.preventDefault();
|
|
34
|
+
setTouching(false);
|
|
35
|
+
click();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
function trackTouch(touch, move, end) {
|
|
42
|
+
const touchMove = (ev) => {
|
|
43
|
+
ev.preventDefault();
|
|
44
|
+
for (const t of Array.from(ev.changedTouches)) {
|
|
45
|
+
if (t.identifier === touch.identifier) {
|
|
46
|
+
move({ pageX: t.pageX, pageY: t.pageY });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const touchEnd = (ev) => {
|
|
51
|
+
for (const t of Array.from(ev.changedTouches)) {
|
|
52
|
+
if (t.identifier === touch.identifier) {
|
|
53
|
+
end({ pageX: t.pageX, pageY: t.pageY });
|
|
54
|
+
window.removeEventListener("touchmove", touchMove);
|
|
55
|
+
window.removeEventListener("touchend", touchEnd);
|
|
56
|
+
window.removeEventListener("touchcancel", touchEnd);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
window.addEventListener("touchmove", touchMove, { passive: false });
|
|
61
|
+
window.addEventListener("touchend", touchEnd);
|
|
62
|
+
window.addEventListener("touchcancel", touchEnd);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// src/util/index.ts
|
|
66
|
+
var calculateClass = (...args) => args.filter((a) => !!a).join(" ");
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
exports.switchToMouseMode = switchToMouseMode; exports.switchToTouchMode = switchToTouchMode; exports.initialiseListeners = initialiseListeners; exports.usePressable = usePressable; exports.trackTouch = trackTouch; exports.calculateClass = calculateClass;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/styling.ts
|
|
2
|
+
var _styledcomponents = require('styled-components');
|
|
3
|
+
var GlobalStyle = _styledcomponents.createGlobalStyle`
|
|
4
|
+
body {
|
|
5
|
+
&.touch-mode * {
|
|
6
|
+
cursor: none !important;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
`;
|
|
10
|
+
var THEME = {
|
|
11
|
+
colorGreen: "#98c379",
|
|
12
|
+
colorRed: "#e06c75",
|
|
13
|
+
colorAmber: "#d19a66",
|
|
14
|
+
bgDark1: "#252524",
|
|
15
|
+
bg: "#2a2a2b",
|
|
16
|
+
bgLight1: "#353638",
|
|
17
|
+
borderDark: "#151516",
|
|
18
|
+
borderLight: "#1c1d1d",
|
|
19
|
+
borderLighter: "#252524",
|
|
20
|
+
borderLighterer: "#6b6b67",
|
|
21
|
+
hint: "#4286f4",
|
|
22
|
+
hintRGB: "66, 134, 244",
|
|
23
|
+
hintDark1: "#2a77f3",
|
|
24
|
+
textNormal: "#F3F3F5",
|
|
25
|
+
textMuted: "#777777",
|
|
26
|
+
sizingPx: {
|
|
27
|
+
spacing: 15,
|
|
28
|
+
unitHeight: 40
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
var BaseStyle = _styledcomponents.createGlobalStyle`
|
|
32
|
+
* {
|
|
33
|
+
box-sizing: border-box;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
body {
|
|
37
|
+
background: #333;
|
|
38
|
+
margin: 0;
|
|
39
|
+
padding: 0;
|
|
40
|
+
font-size: 14px;
|
|
41
|
+
font-family: sans-serif;
|
|
42
|
+
}
|
|
43
|
+
`;
|
|
44
|
+
var buttonStateNormal = _styledcomponents.css`
|
|
45
|
+
color: ${(p) => p.theme.textNormal};
|
|
46
|
+
background: linear-gradient(to bottom, #4f5053, #343436);
|
|
47
|
+
text-shadow: 0 -1px rgba(0, 0, 0, 0.7);
|
|
48
|
+
box-shadow:
|
|
49
|
+
inset 0 1px 0 rgba(255, 255, 255, 0.15),
|
|
50
|
+
0 1px 0 0 rgba(0, 0, 0, 0.25);
|
|
51
|
+
`;
|
|
52
|
+
var buttonStateNormalHover = _styledcomponents.css`
|
|
53
|
+
color: ${(p) => p.theme.textNormal};
|
|
54
|
+
outline-color: rgba(243, 243, 245, 0.3);
|
|
55
|
+
background: linear-gradient(to bottom, #5e6064, #393a3b);
|
|
56
|
+
text-shadow: 0 -1px rgba(0, 0, 0, 0.7);
|
|
57
|
+
`;
|
|
58
|
+
var buttonStateNormalActive = _styledcomponents.css`
|
|
59
|
+
color: #ffffff;
|
|
60
|
+
outline-color: rgba(255, 255, 255, 0.3);
|
|
61
|
+
background: linear-gradient(to bottom, #242525, #37383a);
|
|
62
|
+
text-shadow: 0 -1px rgba(0, 0, 0, 0.4);
|
|
63
|
+
box-shadow:
|
|
64
|
+
inset 0 1px 2px rgba(0, 0, 0, 0.2),
|
|
65
|
+
0 1px 0 0 rgba(255, 255, 255, 0.15);
|
|
66
|
+
transition-duration: 50ms;
|
|
67
|
+
`;
|
|
68
|
+
var buttonStatePressed = _styledcomponents.css`
|
|
69
|
+
${buttonStateNormalActive}
|
|
70
|
+
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.1), 0 1px 0 0 rgba(255,255,255,0.15);
|
|
71
|
+
`;
|
|
72
|
+
var buttonStatePressedHover = _styledcomponents.css`
|
|
73
|
+
${buttonStateNormalActive}
|
|
74
|
+
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.1), 0 1px 0 0 rgba(255,255,255,0.15);
|
|
75
|
+
background: linear-gradient(to bottom, #282929, #414243);
|
|
76
|
+
`;
|
|
77
|
+
var buttonStatePressedActive = buttonStateNormalActive;
|
|
78
|
+
var buttonStateDisabled = _styledcomponents.css`
|
|
79
|
+
${buttonStateNormal}
|
|
80
|
+
|
|
81
|
+
cursor: default;
|
|
82
|
+
background: ${(p) => p.theme.bg} !important;
|
|
83
|
+
color: rgba(${(p) => p.theme.textNormal}, 0.4);
|
|
84
|
+
`;
|
|
85
|
+
var button = _styledcomponents.css`
|
|
86
|
+
position: relative;
|
|
87
|
+
box-sizing: border-box;
|
|
88
|
+
cursor: pointer;
|
|
89
|
+
transition: all 200ms;
|
|
90
|
+
border-radius: 3px;
|
|
91
|
+
border: 1px solid ${(p) => p.theme.borderDark};
|
|
92
|
+
overflow: hidden;
|
|
93
|
+
display: flex;
|
|
94
|
+
justify-content: center;
|
|
95
|
+
align-items: center;
|
|
96
|
+
outline-color: transparent;
|
|
97
|
+
${buttonStateNormal}
|
|
98
|
+
|
|
99
|
+
&:hover {
|
|
100
|
+
${buttonStateNormalHover}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
&:active {
|
|
104
|
+
${buttonStateNormalActive}
|
|
105
|
+
}
|
|
106
|
+
`;
|
|
107
|
+
var buttonPressed = _styledcomponents.css`
|
|
108
|
+
${buttonStatePressed}
|
|
109
|
+
|
|
110
|
+
&:hover {
|
|
111
|
+
${buttonStatePressedHover}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
&:active {
|
|
115
|
+
${buttonStatePressedActive}
|
|
116
|
+
}
|
|
117
|
+
`;
|
|
118
|
+
var buttonDisabled = _styledcomponents.css`
|
|
119
|
+
${buttonStateDisabled}
|
|
120
|
+
|
|
121
|
+
&:hover, &:active {
|
|
122
|
+
${buttonStateDisabled}
|
|
123
|
+
}
|
|
124
|
+
`;
|
|
125
|
+
var rectButton = button;
|
|
126
|
+
var touchIndicatorNormal = _styledcomponents.css`
|
|
127
|
+
position: absolute;
|
|
128
|
+
top: -6px;
|
|
129
|
+
right: -6px;
|
|
130
|
+
left: -6px;
|
|
131
|
+
bottom: -6px;
|
|
132
|
+
border-radius: 6px;
|
|
133
|
+
border: 2px solid rgba(0, 0, 0, 0);
|
|
134
|
+
background-color: none;
|
|
135
|
+
transition: border-color 300ms;
|
|
136
|
+
`;
|
|
137
|
+
var touchIndicatorTouching = _styledcomponents.css`
|
|
138
|
+
border-color: ${(p) => p.theme.hint};
|
|
139
|
+
background-color: rgba(${(p) => p.theme.hintRGB}, 0.2);
|
|
140
|
+
transition: border-color 0s;
|
|
141
|
+
`;
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
exports.GlobalStyle = GlobalStyle; exports.THEME = THEME; exports.BaseStyle = BaseStyle; exports.buttonStateNormal = buttonStateNormal; exports.buttonStateNormalHover = buttonStateNormalHover; exports.buttonStateNormalActive = buttonStateNormalActive; exports.buttonPressed = buttonPressed; exports.buttonDisabled = buttonDisabled; exports.rectButton = rectButton; exports.touchIndicatorNormal = touchIndicatorNormal; exports.touchIndicatorTouching = touchIndicatorTouching;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var _chunkKNYDA6D6js = require('../../chunk-KNYDA6D6.js');
|
|
6
|
+
require('../../chunk-XEIKOLS2.js');
|
|
7
|
+
require('../../chunk-MLKGABMK.js');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
exports.Icon = _chunkKNYDA6D6js.Icon; exports.TRANSPARENCY_SVG = _chunkKNYDA6D6js.TRANSPARENCY_SVG; exports.TRANSPARENCY_SVG_URI = _chunkKNYDA6D6js.TRANSPARENCY_SVG_URI;
|