@lvl99dotcom/paintcanvas 0.0.0-stage → 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.
Files changed (284) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +131 -2
  3. package/dist/index.d.ts +2 -0
  4. package/dist/index.js +5 -0
  5. package/dist/lib/brushes/BrushTipCache/index.d.ts +32 -0
  6. package/dist/lib/brushes/BrushTipCache/index.js +60 -0
  7. package/dist/lib/brushes/StrokeEngine/index.d.ts +171 -0
  8. package/dist/lib/brushes/StrokeEngine/index.js +324 -0
  9. package/dist/lib/brushes/StrokePath/index.d.ts +53 -0
  10. package/dist/lib/brushes/StrokePath/index.js +161 -0
  11. package/dist/lib/brushes/StrokeSampler/index.d.ts +55 -0
  12. package/dist/lib/brushes/StrokeSampler/index.js +75 -0
  13. package/dist/lib/brushes/authors/index.d.ts +55 -0
  14. package/dist/lib/brushes/authors/index.js +60 -0
  15. package/dist/lib/brushes/configRanges/index.d.ts +52 -0
  16. package/dist/lib/brushes/configRanges/index.js +206 -0
  17. package/dist/lib/brushes/index.d.ts +5 -0
  18. package/dist/lib/brushes/index.js +19 -0
  19. package/dist/lib/brushes/params/index.d.ts +108 -0
  20. package/dist/lib/brushes/params/index.js +139 -0
  21. package/dist/lib/brushes/presetFile/index.d.ts +32 -0
  22. package/dist/lib/brushes/presetFile/index.js +55 -0
  23. package/dist/lib/brushes/presets/drawing/brush-pen.js +3 -0
  24. package/dist/lib/brushes/presets/drawing/felt-pen.js +3 -0
  25. package/dist/lib/brushes/presets/drawing/index.d.ts +13 -0
  26. package/dist/lib/brushes/presets/drawing/index.js +88 -0
  27. package/dist/lib/brushes/presets/drawing/pencil-2b.js +3 -0
  28. package/dist/lib/brushes/presets/drawing/pencil-hb.js +3 -0
  29. package/dist/lib/brushes/presets/painting/grass.js +3 -0
  30. package/dist/lib/brushes/presets/painting/hair.js +3 -0
  31. package/dist/lib/brushes/presets/painting/index.d.ts +18 -0
  32. package/dist/lib/brushes/presets/painting/index.js +118 -0
  33. package/dist/lib/brushes/presets/painting/splatter.js +3 -0
  34. package/dist/lib/brushes/presets/painting/textured-paint.js +3 -0
  35. package/dist/lib/brushes/presets/painting/watery-paint.js +3 -0
  36. package/dist/lib/brushes/presets/round/index.d.ts +9 -0
  37. package/dist/lib/brushes/presets/round/index.js +44 -0
  38. package/dist/lib/brushes/presets/round/round.js +3 -0
  39. package/dist/lib/brushes/presets/round/soft-round.js +3 -0
  40. package/dist/lib/brushes/presets/sized/index.d.ts +20 -0
  41. package/dist/lib/brushes/presets/sized/index.js +30 -0
  42. package/dist/lib/brushes/presets/sketching/index.d.ts +14 -0
  43. package/dist/lib/brushes/presets/sketching/index.js +107 -0
  44. package/dist/lib/brushes/presets/square/index.d.ts +7 -0
  45. package/dist/lib/brushes/presets/square/index.js +22 -0
  46. package/dist/lib/brushes/presets/square/square.js +3 -0
  47. package/dist/lib/brushes/shapeImage/index.d.ts +40 -0
  48. package/dist/lib/brushes/shapeImage/index.js +61 -0
  49. package/dist/lib/brushes/types/index.d.ts +243 -0
  50. package/dist/lib/brushes/types/index.js +20 -0
  51. package/dist/lib/classes/BackgroundWork/index.d.ts +55 -0
  52. package/dist/lib/classes/BackgroundWork/index.js +97 -0
  53. package/dist/lib/classes/BrushSettings/index.d.ts +91 -0
  54. package/dist/lib/classes/BrushSettings/index.js +152 -0
  55. package/dist/lib/classes/CustomPresets/index.d.ts +53 -0
  56. package/dist/lib/classes/CustomPresets/index.js +71 -0
  57. package/dist/lib/classes/ExternalSheets/index.d.ts +64 -0
  58. package/dist/lib/classes/ExternalSheets/index.js +112 -0
  59. package/dist/lib/classes/GestureTracker/index.d.ts +62 -0
  60. package/dist/lib/classes/GestureTracker/index.js +122 -0
  61. package/dist/lib/classes/History/index.d.ts +83 -0
  62. package/dist/lib/classes/History/index.js +126 -0
  63. package/dist/lib/classes/HistoryGuard/index.d.ts +58 -0
  64. package/dist/lib/classes/HistoryGuard/index.js +97 -0
  65. package/dist/lib/classes/InputSettings/index.d.ts +74 -0
  66. package/dist/lib/classes/InputSettings/index.js +101 -0
  67. package/dist/lib/classes/KeyboardShortcuts/index.d.ts +48 -0
  68. package/dist/lib/classes/KeyboardShortcuts/index.js +137 -0
  69. package/dist/lib/classes/Layer/index.d.ts +86 -0
  70. package/dist/lib/classes/Layer/index.js +111 -0
  71. package/dist/lib/classes/LayerAutosave/index.d.ts +180 -0
  72. package/dist/lib/classes/LayerAutosave/index.js +346 -0
  73. package/dist/lib/classes/LayerStack/index.d.ts +177 -0
  74. package/dist/lib/classes/LayerStack/index.js +394 -0
  75. package/dist/lib/classes/PaintCanvas/index.d.ts +537 -0
  76. package/dist/lib/classes/PaintCanvas/index.js +965 -0
  77. package/dist/lib/classes/StrokeLog/index.d.ts +149 -0
  78. package/dist/lib/classes/StrokeLog/index.js +257 -0
  79. package/dist/lib/classes/Viewport/index.d.ts +108 -0
  80. package/dist/lib/classes/Viewport/index.js +194 -0
  81. package/dist/lib/document/index.d.ts +17 -0
  82. package/dist/lib/document/index.js +25 -0
  83. package/dist/lib/document/schema.d.ts +132 -0
  84. package/dist/lib/document/schema.js +110 -0
  85. package/dist/lib/i18n/index.d.ts +131 -0
  86. package/dist/lib/i18n/index.js +277 -0
  87. package/dist/lib/image/index.d.ts +90 -0
  88. package/dist/lib/image/index.js +147 -0
  89. package/dist/lib/messages/PatchSender/index.d.ts +75 -0
  90. package/dist/lib/messages/PatchSender/index.js +125 -0
  91. package/dist/lib/messages/index.d.ts +26 -0
  92. package/dist/lib/messages/index.js +59 -0
  93. package/dist/lib/messages/schema.d.ts +1775 -0
  94. package/dist/lib/messages/schema.js +192 -0
  95. package/dist/lib/presets/index.d.ts +32 -0
  96. package/dist/lib/presets/index.js +35 -0
  97. package/dist/lib/presets/schema.d.ts +753 -0
  98. package/dist/lib/presets/schema.js +181 -0
  99. package/dist/lib/rendering/BrushTip/index.d.ts +63 -0
  100. package/dist/lib/rendering/BrushTip/index.js +112 -0
  101. package/dist/lib/rendering/checkerboard/index.d.ts +22 -0
  102. package/dist/lib/rendering/checkerboard/index.js +31 -0
  103. package/dist/lib/rendering/compositing/index.d.ts +64 -0
  104. package/dist/lib/rendering/compositing/index.js +124 -0
  105. package/dist/lib/rendering/cursor/index.d.ts +14 -0
  106. package/dist/lib/rendering/cursor/index.js +39 -0
  107. package/dist/lib/rendering/cursors/index.d.ts +18 -0
  108. package/dist/lib/rendering/cursors/index.js +23 -0
  109. package/dist/lib/rendering/maskOutline/index.d.ts +22 -0
  110. package/dist/lib/rendering/maskOutline/index.js +78 -0
  111. package/dist/lib/rendering/outline/index.d.ts +36 -0
  112. package/dist/lib/rendering/outline/index.js +120 -0
  113. package/dist/lib/rendering/sample/index.d.ts +55 -0
  114. package/dist/lib/rendering/sample/index.js +83 -0
  115. package/dist/lib/rendering/screenshot/index.d.ts +67 -0
  116. package/dist/lib/rendering/screenshot/index.js +96 -0
  117. package/dist/lib/rendering/transformBox/index.d.ts +10 -0
  118. package/dist/lib/rendering/transformBox/index.js +57 -0
  119. package/dist/lib/selection/Lasso/index.d.ts +70 -0
  120. package/dist/lib/selection/Lasso/index.js +156 -0
  121. package/dist/lib/selection/Selection/index.d.ts +86 -0
  122. package/dist/lib/selection/Selection/index.js +228 -0
  123. package/dist/lib/selection/geometry/index.d.ts +37 -0
  124. package/dist/lib/selection/geometry/index.js +57 -0
  125. package/dist/lib/storage/index.d.ts +63 -0
  126. package/dist/lib/storage/index.js +114 -0
  127. package/dist/lib/transform/Transformer/index.d.ts +124 -0
  128. package/dist/lib/transform/Transformer/index.js +286 -0
  129. package/dist/lib/transform/geometry/index.d.ts +95 -0
  130. package/dist/lib/transform/geometry/index.js +258 -0
  131. package/dist/lib/utils/array/index.d.ts +10 -0
  132. package/dist/lib/utils/array/index.js +21 -0
  133. package/dist/lib/utils/gestures/index.d.ts +35 -0
  134. package/dist/lib/utils/gestures/index.js +81 -0
  135. package/dist/lib/utils/navigation/index.d.ts +51 -0
  136. package/dist/lib/utils/navigation/index.js +59 -0
  137. package/dist/lib/utils/random/index.d.ts +18 -0
  138. package/dist/lib/utils/random/index.js +27 -0
  139. package/dist/lib/utils/shortcuts/index.d.ts +74 -0
  140. package/dist/lib/utils/shortcuts/index.js +189 -0
  141. package/dist/lib/validation/validators.generated.d.ts +27 -0
  142. package/dist/lib/validation/validators.generated.js +19826 -0
  143. package/dist/locales/en-GB.js +181 -0
  144. package/dist/locales/en-US.js +181 -0
  145. package/dist/locales/fr.js +181 -0
  146. package/dist/locales/ja.js +181 -0
  147. package/dist/locales/ko.js +181 -0
  148. package/dist/locales/zh-Hans.js +181 -0
  149. package/dist/locales/zh-Hant.js +181 -0
  150. package/dist/package.js +3 -0
  151. package/dist/testing/app.d.ts +7 -0
  152. package/dist/testing/app.js +16 -0
  153. package/dist/testing/elements.d.ts +42 -0
  154. package/dist/testing/elements.js +58 -0
  155. package/dist/testing/fakeCanvas.d.ts +21 -0
  156. package/dist/testing/fakeCanvas.js +26 -0
  157. package/dist/testing/layerStore.d.ts +26 -0
  158. package/dist/testing/layerStore.js +43 -0
  159. package/dist/testing/locks.d.ts +15 -0
  160. package/dist/testing/locks.js +41 -0
  161. package/dist/testing/recordingCanvas.d.ts +14 -0
  162. package/dist/testing/recordingCanvas.js +28 -0
  163. package/dist/testing/recordingContext.d.ts +10 -0
  164. package/dist/testing/recordingContext.js +19 -0
  165. package/dist/ui/ChangeController/index.d.ts +40 -0
  166. package/dist/ui/ChangeController/index.js +62 -0
  167. package/dist/ui/base/index.d.ts +69 -0
  168. package/dist/ui/base/index.js +94 -0
  169. package/dist/ui/elements/PaintCanvas/index.d.ts +249 -0
  170. package/dist/ui/elements/PaintCanvas/index.js +584 -0
  171. package/dist/ui/elements/PaintCanvas/style.js +3 -0
  172. package/dist/ui/elements/PcBrushConfig/index.d.ts +130 -0
  173. package/dist/ui/elements/PcBrushConfig/index.js +465 -0
  174. package/dist/ui/elements/PcBrushConfig/style.js +3 -0
  175. package/dist/ui/elements/PcBrushMenu/index.d.ts +121 -0
  176. package/dist/ui/elements/PcBrushMenu/index.js +362 -0
  177. package/dist/ui/elements/PcBrushMenu/style.js +3 -0
  178. package/dist/ui/elements/PcBrushTest/index.d.ts +71 -0
  179. package/dist/ui/elements/PcBrushTest/index.js +136 -0
  180. package/dist/ui/elements/PcBrushTest/style.js +3 -0
  181. package/dist/ui/elements/PcButton/index.d.ts +57 -0
  182. package/dist/ui/elements/PcButton/index.js +124 -0
  183. package/dist/ui/elements/PcButtonGroup/index.d.ts +44 -0
  184. package/dist/ui/elements/PcButtonGroup/index.js +93 -0
  185. package/dist/ui/elements/PcCanvas/index.d.ts +356 -0
  186. package/dist/ui/elements/PcCanvas/index.js +1004 -0
  187. package/dist/ui/elements/PcCanvas/style.js +3 -0
  188. package/dist/ui/elements/PcCanvasMap/index.d.ts +96 -0
  189. package/dist/ui/elements/PcCanvasMap/index.js +187 -0
  190. package/dist/ui/elements/PcCanvasMap/style.js +3 -0
  191. package/dist/ui/elements/PcContextMenu/index.d.ts +72 -0
  192. package/dist/ui/elements/PcContextMenu/index.js +148 -0
  193. package/dist/ui/elements/PcDialog/index.d.ts +63 -0
  194. package/dist/ui/elements/PcDialog/index.js +114 -0
  195. package/dist/ui/elements/PcIcon/index.d.ts +36 -0
  196. package/dist/ui/elements/PcIcon/index.js +43 -0
  197. package/dist/ui/elements/PcIconToggle/index.d.ts +46 -0
  198. package/dist/ui/elements/PcIconToggle/index.js +87 -0
  199. package/dist/ui/elements/PcInfoTip/index.d.ts +40 -0
  200. package/dist/ui/elements/PcInfoTip/index.js +95 -0
  201. package/dist/ui/elements/PcInputSettings/index.d.ts +69 -0
  202. package/dist/ui/elements/PcInputSettings/index.js +154 -0
  203. package/dist/ui/elements/PcLayerItem/index.d.ts +221 -0
  204. package/dist/ui/elements/PcLayerItem/index.js +561 -0
  205. package/dist/ui/elements/PcLayerItem/style.js +3 -0
  206. package/dist/ui/elements/PcLayersMenu/index.d.ts +108 -0
  207. package/dist/ui/elements/PcLayersMenu/index.js +208 -0
  208. package/dist/ui/elements/PcLayersMenu/style.js +3 -0
  209. package/dist/ui/elements/PcMatch/index.d.ts +31 -0
  210. package/dist/ui/elements/PcMatch/index.js +58 -0
  211. package/dist/ui/elements/PcPanel/index.d.ts +43 -0
  212. package/dist/ui/elements/PcPanel/index.js +51 -0
  213. package/dist/ui/elements/PcPopover/index.d.ts +48 -0
  214. package/dist/ui/elements/PcPopover/index.js +86 -0
  215. package/dist/ui/elements/PcSlider/index.d.ts +57 -0
  216. package/dist/ui/elements/PcSlider/index.js +88 -0
  217. package/dist/ui/elements/PcStats/index.d.ts +54 -0
  218. package/dist/ui/elements/PcStats/index.js +144 -0
  219. package/dist/ui/elements/PcThemePicker/index.d.ts +56 -0
  220. package/dist/ui/elements/PcThemePicker/index.js +134 -0
  221. package/dist/ui/elements/PcToast/index.d.ts +58 -0
  222. package/dist/ui/elements/PcToast/index.js +110 -0
  223. package/dist/ui/elements/PcToggleCheckbox/index.d.ts +37 -0
  224. package/dist/ui/elements/PcToggleCheckbox/index.js +105 -0
  225. package/dist/ui/elements/PcToolSettings/index.d.ts +128 -0
  226. package/dist/ui/elements/PcToolSettings/index.js +549 -0
  227. package/dist/ui/elements/PcToolSettings/style.js +3 -0
  228. package/dist/ui/elements/PcToolbar/index.d.ts +71 -0
  229. package/dist/ui/elements/PcToolbar/index.js +190 -0
  230. package/dist/ui/elements/PcToolbar/style.js +3 -0
  231. package/dist/ui/icons/images/brush.js +3 -0
  232. package/dist/ui/icons/images/circle-mask.js +3 -0
  233. package/dist/ui/icons/images/clipboard.js +3 -0
  234. package/dist/ui/icons/images/cursor.js +3 -0
  235. package/dist/ui/icons/images/eraser.js +3 -0
  236. package/dist/ui/icons/images/eyedropper.js +3 -0
  237. package/dist/ui/icons/images/flip-horizontal.js +3 -0
  238. package/dist/ui/icons/images/flip-vertical.js +3 -0
  239. package/dist/ui/icons/images/focus-pen.js +3 -0
  240. package/dist/ui/icons/images/freehand-mask.js +3 -0
  241. package/dist/ui/icons/images/hidden.js +3 -0
  242. package/dist/ui/icons/images/layers.js +3 -0
  243. package/dist/ui/icons/images/linked.js +3 -0
  244. package/dist/ui/icons/images/locked.js +3 -0
  245. package/dist/ui/icons/images/moon.js +3 -0
  246. package/dist/ui/icons/images/pan.js +3 -0
  247. package/dist/ui/icons/images/polygon-mask.js +3 -0
  248. package/dist/ui/icons/images/pressure.js +3 -0
  249. package/dist/ui/icons/images/randomise.js +3 -0
  250. package/dist/ui/icons/images/rectangle-mask.js +3 -0
  251. package/dist/ui/icons/images/redo.js +3 -0
  252. package/dist/ui/icons/images/rotate-90-left.js +3 -0
  253. package/dist/ui/icons/images/rotate-90-right.js +3 -0
  254. package/dist/ui/icons/images/smoothing-bezier-cubic.js +3 -0
  255. package/dist/ui/icons/images/smoothing-bezier-quad.js +3 -0
  256. package/dist/ui/icons/images/smoothing-linear.js +3 -0
  257. package/dist/ui/icons/images/star.js +3 -0
  258. package/dist/ui/icons/images/sun.js +3 -0
  259. package/dist/ui/icons/images/tilt.js +3 -0
  260. package/dist/ui/icons/images/undo.js +3 -0
  261. package/dist/ui/icons/images/unlinked.js +3 -0
  262. package/dist/ui/icons/images/unlocked.js +3 -0
  263. package/dist/ui/icons/images/visible.js +3 -0
  264. package/dist/ui/icons/images/zoom-in.js +3 -0
  265. package/dist/ui/icons/images/zoom-out.js +3 -0
  266. package/dist/ui/icons/images/zoom.js +3 -0
  267. package/dist/ui/icons/index.d.ts +42 -0
  268. package/dist/ui/icons/index.js +130 -0
  269. package/dist/ui/index.d.ts +21 -0
  270. package/dist/ui/index.js +22 -0
  271. package/dist/ui/layout/index.d.ts +88 -0
  272. package/dist/ui/layout/index.js +96 -0
  273. package/dist/ui/styles/index.d.ts +13 -0
  274. package/dist/ui/styles/index.js +195 -0
  275. package/dist/ui/tokens/index.d.ts +29 -0
  276. package/dist/ui/tokens/index.js +114 -0
  277. package/locales/en-GB.json +179 -0
  278. package/locales/en-US.json +179 -0
  279. package/locales/fr.json +179 -0
  280. package/locales/ja.json +179 -0
  281. package/locales/ko.json +179 -0
  282. package/locales/zh-Hans.json +179 -0
  283. package/locales/zh-Hant.json +179 -0
  284. package/package.json +97 -3
@@ -0,0 +1,36 @@
1
+ import { nothing } from "lit";
2
+ import { PcElement } from "../../base";
3
+ /**
4
+ * An icon from the icon registry (see `icons`), by name. With a `label`, screen readers read it; without one, it's
5
+ * decorative and hidden from them. Sized by `--pc-icon-size`.
6
+ *
7
+ * @example
8
+ * html`<pc-icon name="brush" label="Brush"></pc-icon>`
9
+ */
10
+ export declare class PcIcon extends PcElement {
11
+ static properties: {
12
+ name: {
13
+ type: StringConstructor;
14
+ };
15
+ label: {
16
+ type: StringConstructor;
17
+ };
18
+ translations: {
19
+ attribute: boolean;
20
+ };
21
+ icons: {
22
+ attribute: boolean;
23
+ };
24
+ theme: {
25
+ type: StringConstructor;
26
+ reflect: boolean;
27
+ };
28
+ };
29
+ static styles: import("lit").CSSResultGroup[];
30
+ /** The icon's name in the registry */
31
+ name: string;
32
+ /** What the icon means, for screen readers (empty for a decorative icon) */
33
+ label: string;
34
+ constructor();
35
+ render(): import("lit").TemplateResult<1> | typeof nothing;
36
+ }
@@ -0,0 +1,43 @@
1
+ import { PcElement, defineElement } from "../../base/index.js";
2
+ import { css, html, nothing } from "lit";
3
+ // src/ui/elements/PcIcon/index.ts
4
+ /**
5
+ * An icon from the icon registry (see `icons`), by name. With a `label`, screen readers read it; without one, it's
6
+ * decorative and hidden from them. Sized by `--pc-icon-size`.
7
+ *
8
+ * @example
9
+ * html`<pc-icon name="brush" label="Brush"></pc-icon>`
10
+ */
11
+ var PcIcon = class extends PcElement {
12
+ static properties = {
13
+ ...PcElement.properties,
14
+ name: { type: String },
15
+ label: { type: String }
16
+ };
17
+ static styles = [PcElement.styles, css`
18
+ :host {
19
+ display: inline-flex;
20
+ width: var(--pc-icon-size);
21
+ height: var(--pc-icon-size);
22
+ flex: none;
23
+ }
24
+ img {
25
+ display: block;
26
+ width: 100%;
27
+ height: 100%;
28
+ filter: var(--pc-icon-filter);
29
+ }
30
+ `];
31
+ constructor() {
32
+ super();
33
+ this.name = "";
34
+ this.label = "";
35
+ }
36
+ render() {
37
+ const url = this.icons.get(this.name);
38
+ if (!url) return nothing;
39
+ return this.label ? html`<img part="image" src=${url} alt=${this.label} />` : html`<img part="image" src=${url} alt="" aria-hidden="true" />`;
40
+ }
41
+ };
42
+ defineElement("pc-icon", PcIcon);
43
+ export { PcIcon };
@@ -0,0 +1,46 @@
1
+ import { PcElement } from "../../base";
2
+ import "../PcIcon";
3
+ /**
4
+ * An on/off setting shown as its icon in a box, purple while on (the icon stays the same). Its `label` names it for screen
5
+ * readers and as a tooltip. Fires `change` when the user turns it on or off.
6
+ *
7
+ * @example
8
+ * html`<pc-icon-toggle icon="pressure" label="Pressure" .checked=${on} @change=${toggle}></pc-icon-toggle>`
9
+ */
10
+ export declare class PcIconToggle extends PcElement {
11
+ static properties: {
12
+ icon: {
13
+ type: StringConstructor;
14
+ };
15
+ label: {
16
+ type: StringConstructor;
17
+ };
18
+ checked: {
19
+ type: BooleanConstructor;
20
+ reflect: boolean;
21
+ };
22
+ disabled: {
23
+ type: BooleanConstructor;
24
+ reflect: boolean;
25
+ };
26
+ translations: {
27
+ attribute: boolean;
28
+ };
29
+ icons: {
30
+ attribute: boolean;
31
+ };
32
+ theme: {
33
+ type: StringConstructor;
34
+ reflect: boolean;
35
+ };
36
+ };
37
+ static styles: import("lit").CSSResultGroup[];
38
+ icon: string;
39
+ label: string;
40
+ checked: boolean;
41
+ disabled: boolean;
42
+ constructor();
43
+ /** Follow the user's change, and tell listeners */
44
+ private onChange;
45
+ render(): import("lit").TemplateResult<1>;
46
+ }
@@ -0,0 +1,87 @@
1
+ import { PcElement, defineElement, emit } from "../../base/index.js";
2
+ import { css, html } from "lit";
3
+ import { live } from "lit/directives/live.js";
4
+ // src/ui/elements/PcIconToggle/index.ts
5
+ /**
6
+ * An on/off setting shown as its icon in a box, purple while on (the icon stays the same). Its `label` names it for screen
7
+ * readers and as a tooltip. Fires `change` when the user turns it on or off.
8
+ *
9
+ * @example
10
+ * html`<pc-icon-toggle icon="pressure" label="Pressure" .checked=${on} @change=${toggle}></pc-icon-toggle>`
11
+ */
12
+ var PcIconToggle = class extends PcElement {
13
+ static properties = {
14
+ ...PcElement.properties,
15
+ icon: { type: String },
16
+ label: { type: String },
17
+ checked: {
18
+ type: Boolean,
19
+ reflect: true
20
+ },
21
+ disabled: {
22
+ type: Boolean,
23
+ reflect: true
24
+ }
25
+ };
26
+ static styles = [PcElement.styles, css`
27
+ :host {
28
+ display: inline-flex;
29
+ }
30
+ label {
31
+ position: relative;
32
+ display: inline-flex;
33
+ padding: 2px;
34
+ border: 1px solid var(--pc-border);
35
+ border-radius: var(--pc-radius-small);
36
+ background: var(--pc-surface);
37
+ cursor: pointer;
38
+ }
39
+ label:hover {
40
+ background: var(--pc-surface-hover);
41
+ }
42
+ :host([checked]) label {
43
+ border-color: var(--pc-accent);
44
+ background: var(--pc-accent);
45
+ }
46
+ label:has(input:focus-visible) {
47
+ outline: var(--pc-focus-width) solid var(--pc-focus);
48
+ }
49
+ :host([disabled]) label {
50
+ opacity: 0.4;
51
+ cursor: default;
52
+ }
53
+ input {
54
+ position: absolute;
55
+ inset: 0;
56
+ margin: 0;
57
+ opacity: 0;
58
+ cursor: inherit;
59
+ }
60
+ `];
61
+ constructor() {
62
+ super();
63
+ this.icon = "";
64
+ this.label = "";
65
+ this.checked = false;
66
+ this.disabled = false;
67
+ }
68
+ /** Follow the user's change, and tell listeners */
69
+ onChange(event) {
70
+ this.checked = event.target.checked;
71
+ emit(this, "change", { checked: this.checked });
72
+ }
73
+ render() {
74
+ return html`<label part="toggle" title=${this.label}>
75
+ <input
76
+ type="checkbox"
77
+ .checked=${live(this.checked)}
78
+ ?disabled=${this.disabled}
79
+ aria-label=${this.label}
80
+ @change=${this.onChange}
81
+ />
82
+ <pc-icon name=${this.icon}></pc-icon>
83
+ </label>`;
84
+ }
85
+ };
86
+ defineElement("pc-icon-toggle", PcIconToggle);
87
+ export { PcIconToggle };
@@ -0,0 +1,40 @@
1
+ import { PcElement } from "../../base";
2
+ /**
3
+ * A small ⓘ button that shows a short explanation (the element's content) beside it, and hides it again when pressed
4
+ * again, when focus or a press goes elsewhere, or with Escape.
5
+ *
6
+ * @example
7
+ * html`<pc-info-tip>Focus pen mode stops fingers and palms from drawing.</pc-info-tip>`
8
+ */
9
+ export declare class PcInfoTip extends PcElement {
10
+ static properties: {
11
+ label: {
12
+ type: StringConstructor;
13
+ };
14
+ open: {
15
+ type: BooleanConstructor;
16
+ reflect: boolean;
17
+ };
18
+ translations: {
19
+ attribute: boolean;
20
+ };
21
+ icons: {
22
+ attribute: boolean;
23
+ };
24
+ theme: {
25
+ type: StringConstructor;
26
+ reflect: boolean;
27
+ };
28
+ };
29
+ static styles: import("lit").CSSResultGroup[];
30
+ /** The button's name for screen readers (default "More information", translated) */
31
+ label?: string;
32
+ open: boolean;
33
+ private readonly onPointerDown;
34
+ constructor();
35
+ connectedCallback(): void;
36
+ disconnectedCallback(): void;
37
+ /** Escape hides the tip */
38
+ private onKeyDown;
39
+ render(): import("lit").TemplateResult<1>;
40
+ }
@@ -0,0 +1,95 @@
1
+ import { PcElement, defineElement } from "../../base/index.js";
2
+ import { css, html, nothing } from "lit";
3
+ // src/ui/elements/PcInfoTip/index.ts
4
+ /**
5
+ * A small ⓘ button that shows a short explanation (the element's content) beside it, and hides it again when pressed
6
+ * again, when focus or a press goes elsewhere, or with Escape.
7
+ *
8
+ * @example
9
+ * html`<pc-info-tip>Focus pen mode stops fingers and palms from drawing.</pc-info-tip>`
10
+ */
11
+ var PcInfoTip = class extends PcElement {
12
+ static properties = {
13
+ ...PcElement.properties,
14
+ label: { type: String },
15
+ open: {
16
+ type: Boolean,
17
+ reflect: true
18
+ }
19
+ };
20
+ static styles = [PcElement.styles, css`
21
+ :host {
22
+ position: relative;
23
+ display: inline-flex;
24
+ }
25
+ button {
26
+ width: 20px;
27
+ height: 20px;
28
+ padding: 0;
29
+ border: 1px solid var(--pc-border);
30
+ border-radius: 50%;
31
+ background: var(--pc-surface);
32
+ color: var(--pc-text);
33
+ font: bold 12px var(--pc-font);
34
+ cursor: pointer;
35
+ }
36
+ button:focus-visible {
37
+ outline: var(--pc-focus-width) solid var(--pc-focus);
38
+ outline-offset: 2px;
39
+ }
40
+ [role="tooltip"] {
41
+ position: absolute;
42
+ z-index: 10;
43
+ top: calc(100% + var(--pc-space-1));
44
+ left: 0;
45
+ width: max-content;
46
+ max-width: 240px;
47
+ padding: var(--pc-space-2);
48
+ border-radius: var(--pc-radius);
49
+ background: var(--pc-surface-raised);
50
+ color: var(--pc-text);
51
+ box-shadow: var(--pc-shadow);
52
+ font-family: var(--pc-font);
53
+ font-size: var(--pc-font-size-small);
54
+ }
55
+ `];
56
+ onPointerDown = (event) => {
57
+ if (this.open && !event.composedPath().includes(this)) this.open = false;
58
+ };
59
+ constructor() {
60
+ super();
61
+ this.open = false;
62
+ }
63
+ connectedCallback() {
64
+ super.connectedCallback();
65
+ document.addEventListener("pointerdown", this.onPointerDown, true);
66
+ }
67
+ disconnectedCallback() {
68
+ super.disconnectedCallback();
69
+ document.removeEventListener("pointerdown", this.onPointerDown, true);
70
+ }
71
+ /** Escape hides the tip */
72
+ onKeyDown(event) {
73
+ if (event.key === "Escape" && this.open) {
74
+ event.preventDefault();
75
+ this.open = false;
76
+ }
77
+ }
78
+ render() {
79
+ return html`<button
80
+ part="button"
81
+ type="button"
82
+ aria-label=${this.label || this.t("paintCanvas.common.moreInformation")}
83
+ aria-expanded=${String(this.open)}
84
+ aria-describedby=${this.open ? "tip" : nothing}
85
+ @click=${() => this.open = !this.open}
86
+ @keydown=${this.onKeyDown}
87
+ @blur=${() => this.open = false}
88
+ >
89
+ i
90
+ </button>
91
+ ${this.open ? html`<div id="tip" part="tip" role="tooltip"><slot></slot></div>` : nothing}`;
92
+ }
93
+ };
94
+ defineElement("pc-info-tip", PcInfoTip);
95
+ export { PcInfoTip };
@@ -0,0 +1,69 @@
1
+ import { nothing } from "lit";
2
+ import { PcElement } from "../../base";
3
+ import { type InputSettingsData } from "../../../lib/classes/InputSettings";
4
+ /** Settings `pc-input-settings` can change: PaintCanvas's `InputSettings`, or anything with the same data and `update` */
5
+ export interface InputSettingsLike extends EventTarget {
6
+ readonly data: Readonly<InputSettingsData>;
7
+ update(changes: Partial<InputSettingsData>): void;
8
+ }
9
+ /**
10
+ * How the user's input devices control the canvas: scrolling and pinching (with Cmd/Ctrl + scroll to zoom on devices
11
+ * with a mouse or trackpad), focus pen mode, which touch gesture undoes, redoes, copies and pastes (on touch devices),
12
+ * and the language. Changes apply straight away. Hide focus pen mode or the language with `focusPen` and `languages`
13
+ * set to false. Fires `pc-language-change` (with the locale) when the user picks a language.
14
+ *
15
+ * @example
16
+ * html`<pc-input-settings .settings=${canvas.input}></pc-input-settings>`
17
+ */
18
+ export declare class PcInputSettings extends PcElement {
19
+ static properties: {
20
+ settings: {
21
+ attribute: boolean;
22
+ };
23
+ focusPen: {
24
+ type: BooleanConstructor;
25
+ };
26
+ languages: {
27
+ type: BooleanConstructor;
28
+ };
29
+ touch: {
30
+ type: BooleanConstructor;
31
+ };
32
+ modifier: {
33
+ type: StringConstructor;
34
+ };
35
+ translations: {
36
+ attribute: boolean;
37
+ };
38
+ icons: {
39
+ attribute: boolean;
40
+ };
41
+ theme: {
42
+ type: StringConstructor;
43
+ reflect: boolean;
44
+ };
45
+ };
46
+ static styles: import("lit").CSSResultGroup[];
47
+ /** The settings shown and changed */
48
+ settings?: InputSettingsLike;
49
+ /** Whether to show focus pen mode (default true) */
50
+ focusPen: boolean;
51
+ /** Whether to show the language (default true) */
52
+ languages: boolean;
53
+ /** Whether the device is a phone or tablet: shows touch gestures, hides Cmd/Ctrl + scroll (detected by default) */
54
+ touch: boolean;
55
+ /** Name of the zoom modifier key ("Cmd" or "Ctrl", detected by default) */
56
+ modifier: string;
57
+ private changes;
58
+ constructor();
59
+ /** A checkbox for an on/off setting */
60
+ private toggle;
61
+ /**
62
+ * The touch gestures: which gesture undoes, redoes, copies and pastes. Choosing a gesture another action uses swaps
63
+ * them.
64
+ */
65
+ private renderGestures;
66
+ /** The language picker */
67
+ private renderLanguage;
68
+ render(): import("lit").TemplateResult<1> | typeof nothing;
69
+ }
@@ -0,0 +1,154 @@
1
+ import { PcElement, defineElement, emit } from "../../base/index.js";
2
+ import ChangeController from "../../ChangeController/index.js";
3
+ import { languageName } from "../../../lib/i18n/index.js";
4
+ import { isTouchDevice, zoomModifierName } from "../../../lib/classes/InputSettings/index.js";
5
+ import { GESTURE_ACTIONS, TOUCH_GESTURES, assignGesture } from "../../../lib/utils/gestures/index.js";
6
+ import { css, html, nothing } from "lit";
7
+ // src/ui/elements/PcInputSettings/index.ts
8
+ /** Translation keys of the gesture actions' names */
9
+ var ACTION_KEYS = {
10
+ undo: "paintCanvas.common.undo",
11
+ redo: "paintCanvas.common.redo",
12
+ copy: "paintCanvas.common.copy",
13
+ paste: "paintCanvas.common.paste"
14
+ };
15
+ /**
16
+ * How the user's input devices control the canvas: scrolling and pinching (with Cmd/Ctrl + scroll to zoom on devices
17
+ * with a mouse or trackpad), focus pen mode, which touch gesture undoes, redoes, copies and pastes (on touch devices),
18
+ * and the language. Changes apply straight away. Hide focus pen mode or the language with `focusPen` and `languages`
19
+ * set to false. Fires `pc-language-change` (with the locale) when the user picks a language.
20
+ *
21
+ * @example
22
+ * html`<pc-input-settings .settings=${canvas.input}></pc-input-settings>`
23
+ */
24
+ var PcInputSettings = class extends PcElement {
25
+ static properties = {
26
+ ...PcElement.properties,
27
+ settings: { attribute: false },
28
+ focusPen: { type: Boolean },
29
+ languages: { type: Boolean },
30
+ touch: { type: Boolean },
31
+ modifier: { type: String }
32
+ };
33
+ static styles = [PcElement.styles, css`
34
+ :host {
35
+ display: flex;
36
+ flex-direction: column;
37
+ gap: var(--pc-space-2);
38
+ font-family: var(--pc-font);
39
+ font-size: var(--pc-font-size);
40
+ }
41
+ fieldset {
42
+ display: grid;
43
+ grid-template-columns: auto 1fr;
44
+ gap: var(--pc-space-1) var(--pc-space-2);
45
+ align-items: center;
46
+ margin: 0;
47
+ padding: var(--pc-space-2);
48
+ border: 1px solid var(--pc-border);
49
+ border-radius: var(--pc-radius);
50
+ }
51
+ legend {
52
+ padding: 0 var(--pc-space-1);
53
+ font-weight: bold;
54
+ }
55
+ .toggle {
56
+ display: flex;
57
+ grid-column: 1 / -1;
58
+ gap: var(--pc-space-2);
59
+ align-items: center;
60
+ }
61
+ input[type="checkbox"] {
62
+ accent-color: var(--pc-accent);
63
+ }
64
+ input:focus-visible,
65
+ select:focus-visible {
66
+ outline: var(--pc-focus-width) solid var(--pc-focus);
67
+ outline-offset: 2px;
68
+ }
69
+ `];
70
+ changes = new ChangeController(this, () => [this.settings]);
71
+ constructor() {
72
+ super();
73
+ this.focusPen = true;
74
+ this.languages = true;
75
+ this.touch = isTouchDevice();
76
+ this.modifier = zoomModifierName();
77
+ }
78
+ /** A checkbox for an on/off setting */
79
+ toggle(data, key, label) {
80
+ return html`<label class="toggle">
81
+ <input
82
+ type="checkbox"
83
+ name=${key}
84
+ .checked=${data[key]}
85
+ @change=${(e) => this.settings?.update({ [key]: e.target.checked })}
86
+ />
87
+ ${label}
88
+ </label>`;
89
+ }
90
+ /**
91
+ * The touch gestures: which gesture undoes, redoes, copies and pastes. Choosing a gesture another action uses swaps
92
+ * them.
93
+ */
94
+ renderGestures(data) {
95
+ return html`<fieldset part="gestures">
96
+ <legend>${this.t("paintCanvas.inputSettings.gestures")}</legend>
97
+ ${GESTURE_ACTIONS.map((action) => html`<label for="gesture-${action}"
98
+ >${this.t(ACTION_KEYS[action])}</label
99
+ >
100
+ <select
101
+ id="gesture-${action}"
102
+ name="gesture-${action}"
103
+ @change=${(e) => this.settings?.update({ gestures: assignGesture(data.gestures, action, e.target.value) })}
104
+ >
105
+ ${[...TOUCH_GESTURES, "off"].map((gesture) => html`<option
106
+ value=${gesture}
107
+ ?selected=${data.gestures[action] === gesture}
108
+ >
109
+ ${this.t(gesture === "off" ? "paintCanvas.common.off" : `paintCanvas.gesture.${gesture}`)}
110
+ </option>`)}
111
+ </select>`)}
112
+ </fieldset>`;
113
+ }
114
+ /** The language picker */
115
+ renderLanguage() {
116
+ const translations = this.translations;
117
+ return html`<fieldset part="language">
118
+ <label for="language"
119
+ >${this.t("paintCanvas.inputSettings.language")}</label
120
+ >
121
+ <select
122
+ id="language"
123
+ name="language"
124
+ @change=${(e) => {
125
+ const locale = e.target.value;
126
+ translations.setLocale(locale).then(() => emit(this, "pc-language-change", { locale }));
127
+ }}
128
+ >
129
+ ${translations.locales.map((locale) => html`<option
130
+ value=${locale}
131
+ lang=${locale}
132
+ ?selected=${translations.locale === locale}
133
+ >
134
+ ${languageName(locale)}
135
+ </option>`)}
136
+ </select>
137
+ </fieldset>`;
138
+ }
139
+ render() {
140
+ const data = this.settings?.data;
141
+ if (!data) return nothing;
142
+ return html`<fieldset part="controls">
143
+ <legend>${this.t("paintCanvas.inputSettings.title")}</legend>
144
+ ${this.toggle(data, "scrollPan", this.t(this.touch ? "paintCanvas.inputSettings.touchPan" : "paintCanvas.inputSettings.scrollPan"))}
145
+ ${this.toggle(data, "pinchZoom", this.t("paintCanvas.inputSettings.pinchZoom"))}
146
+ ${this.touch ? nothing : this.toggle(data, "modifierScrollZoom", this.t("paintCanvas.inputSettings.modifierScrollZoom", { key: this.modifier }))}
147
+ ${this.focusPen ? this.toggle(data, "focusPen", this.t("paintCanvas.inputSettings.focusPen")) : nothing}
148
+ </fieldset>
149
+ ${this.touch ? this.renderGestures(data) : nothing}
150
+ ${this.languages ? this.renderLanguage() : nothing}`;
151
+ }
152
+ };
153
+ defineElement("pc-input-settings", PcInputSettings);
154
+ export { PcInputSettings };