@pg-labs-incubator/cobweb 0.0.0-stage → 0.0.2

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 (320) hide show
  1. package/LICENSE +163 -0
  2. package/README.md +82 -2
  3. package/package.json +112 -3
  4. package/src/action/action.yaml +291 -0
  5. package/src/action/button-group.yaml +56 -0
  6. package/src/action/button.yaml +239 -0
  7. package/src/action/split-button.yaml +87 -0
  8. package/src/color/color.yaml +181 -0
  9. package/src/color/palette.yaml +147 -0
  10. package/src/container/card.yaml +170 -0
  11. package/src/container/corner-radius.yaml +50 -0
  12. package/src/container/elevation.yaml +19 -0
  13. package/src/design.yaml +41 -0
  14. package/src/feedback/feedback.yaml +225 -0
  15. package/src/icon/icon-font.yaml +28 -0
  16. package/src/icon/icon.yaml +31 -0
  17. package/src/input/date-picker.yaml +144 -0
  18. package/src/input/date-range-input.yaml +162 -0
  19. package/src/input/range-slider.yaml +161 -0
  20. package/src/input/select.yaml +230 -0
  21. package/src/input/slider.yaml +172 -0
  22. package/src/input/text-field.yaml +240 -0
  23. package/src/input/time-picker.yaml +220 -0
  24. package/src/motion/motion.yaml +371 -0
  25. package/src/navigation/app-bar.yaml +147 -0
  26. package/src/navigation/navigation.yaml +339 -0
  27. package/src/navigation/scroll.yaml +23 -0
  28. package/src/navigation/search.yaml +112 -0
  29. package/src/navigation/tabs.yaml +144 -0
  30. package/src/navigation/toolbar.yaml +130 -0
  31. package/src/selection/checkbox.yaml +162 -0
  32. package/src/selection/chip.yaml +219 -0
  33. package/src/selection/radio.yaml +125 -0
  34. package/src/selection/segmented-group.yaml +11 -0
  35. package/src/selection/segmented.yaml +69 -0
  36. package/src/selection/switch.yaml +209 -0
  37. package/src/spacing/measurement.yaml +80 -0
  38. package/src/state/state.yaml +38 -0
  39. package/src/surface/surface.yaml +483 -0
  40. package/src/text/line-height.yaml +144 -0
  41. package/src/text/typeface.yaml +31 -0
  42. package/src/text/typescale.yaml +726 -0
  43. package/target/esbuild/action/action.css +1 -0
  44. package/target/esbuild/action/base.jsx +1 -0
  45. package/target/esbuild/action/button.jsx +17 -0
  46. package/target/esbuild/action/fab-menu-context.jsx +1 -0
  47. package/target/esbuild/action/fab-menu.jsx +15 -0
  48. package/target/esbuild/action/fab.jsx +7 -0
  49. package/target/esbuild/action/group.jsx +22 -0
  50. package/target/esbuild/action/icon-button.jsx +5 -0
  51. package/target/esbuild/action/index.jsx +1 -0
  52. package/target/esbuild/action/split-button.jsx +12 -0
  53. package/target/esbuild/color/contrast.jsx +1 -0
  54. package/target/esbuild/color/dynamic.jsx +1 -0
  55. package/target/esbuild/color/hct.jsx +1 -0
  56. package/target/esbuild/color/index.css +1 -0
  57. package/target/esbuild/color/index.jsx +1 -0
  58. package/target/esbuild/color/palette.jsx +1 -0
  59. package/target/esbuild/color/scheme.jsx +1 -0
  60. package/target/esbuild/color/temperature.jsx +1 -0
  61. package/target/esbuild/container/card.css +1 -0
  62. package/target/esbuild/container/card.jsx +1 -0
  63. package/target/esbuild/container/elevation-shadow.css +1 -0
  64. package/target/esbuild/container/elevation-shadow.jsx +1 -0
  65. package/target/esbuild/container/index.jsx +1 -0
  66. package/target/esbuild/dom/client.jsx +1 -0
  67. package/target/esbuild/dom/index.jsx +1 -0
  68. package/target/esbuild/dom/server.jsx +1 -0
  69. package/target/esbuild/dom/types.jsx +1 -0
  70. package/target/esbuild/feedback/badge.jsx +15 -0
  71. package/target/esbuild/feedback/feedback.css +1 -0
  72. package/target/esbuild/feedback/focus.jsx +1 -0
  73. package/target/esbuild/feedback/index.jsx +1 -0
  74. package/target/esbuild/feedback/loading.jsx +7 -0
  75. package/target/esbuild/feedback/observe.jsx +1 -0
  76. package/target/esbuild/feedback/progress.jsx +35 -0
  77. package/target/esbuild/feedback/snackbar.jsx +23 -0
  78. package/target/esbuild/feedback/tooltip.jsx +24 -0
  79. package/target/esbuild/icon/icon.css +1 -0
  80. package/target/esbuild/icon/icon.jsx +1 -0
  81. package/target/esbuild/icon/index.jsx +1 -0
  82. package/target/esbuild/index.css +1 -0
  83. package/target/esbuild/index.jsx +1 -0
  84. package/target/esbuild/input/autocomplete.jsx +5 -0
  85. package/target/esbuild/input/base.jsx +4 -0
  86. package/target/esbuild/input/date-picker.css +1 -0
  87. package/target/esbuild/input/date-picker.jsx +104 -0
  88. package/target/esbuild/input/date-range-input.css +1 -0
  89. package/target/esbuild/input/date-time.jsx +21 -0
  90. package/target/esbuild/input/index.css +1 -0
  91. package/target/esbuild/input/index.jsx +1 -0
  92. package/target/esbuild/input/paired-input.jsx +1 -0
  93. package/target/esbuild/input/picker-dialog.css +1 -0
  94. package/target/esbuild/input/picker-dialog.jsx +14 -0
  95. package/target/esbuild/input/select.css +1 -0
  96. package/target/esbuild/input/select.jsx +63 -0
  97. package/target/esbuild/input/slider.css +1 -0
  98. package/target/esbuild/input/slider.jsx +51 -0
  99. package/target/esbuild/input/text-field.css +1 -0
  100. package/target/esbuild/input/text-field.jsx +67 -0
  101. package/target/esbuild/input/time-picker.css +1 -0
  102. package/target/esbuild/input/time-picker.jsx +29 -0
  103. package/target/esbuild/motion/frame.jsx +1 -0
  104. package/target/esbuild/motion/index.css +1 -0
  105. package/target/esbuild/motion/index.jsx +1 -0
  106. package/target/esbuild/motion/material.jsx +1 -0
  107. package/target/esbuild/motion/motion.jsx +1 -0
  108. package/target/esbuild/motion/spring.jsx +1 -0
  109. package/target/esbuild/motion/transition.css +1 -0
  110. package/target/esbuild/motion/transition.jsx +1 -0
  111. package/target/esbuild/motion/velocity.jsx +1 -0
  112. package/target/esbuild/navigation/app-bar.jsx +51 -0
  113. package/target/esbuild/navigation/base.jsx +1 -0
  114. package/target/esbuild/navigation/drawer.jsx +25 -0
  115. package/target/esbuild/navigation/index.jsx +1 -0
  116. package/target/esbuild/navigation/navigation.css +1 -0
  117. package/target/esbuild/navigation/navigation.jsx +29 -0
  118. package/target/esbuild/navigation/scroll.jsx +1 -0
  119. package/target/esbuild/navigation/search.jsx +29 -0
  120. package/target/esbuild/navigation/tabs.jsx +7 -0
  121. package/target/esbuild/navigation/toolbar.jsx +23 -0
  122. package/target/esbuild/selection/base.jsx +1 -0
  123. package/target/esbuild/selection/checkbox.jsx +14 -0
  124. package/target/esbuild/selection/chip.jsx +23 -0
  125. package/target/esbuild/selection/index.jsx +1 -0
  126. package/target/esbuild/selection/radio.jsx +9 -0
  127. package/target/esbuild/selection/segmented.jsx +15 -0
  128. package/target/esbuild/selection/selection.css +1 -0
  129. package/target/esbuild/selection/switch.jsx +14 -0
  130. package/target/esbuild/shape/corner-rounding.jsx +1 -0
  131. package/target/esbuild/shape/cubic.jsx +1 -0
  132. package/target/esbuild/shape/index.jsx +1 -0
  133. package/target/esbuild/shape/material-shapes.jsx +1 -0
  134. package/target/esbuild/shape/morph.jsx +1 -0
  135. package/target/esbuild/shape/path.jsx +1 -0
  136. package/target/esbuild/shape/point.jsx +1 -0
  137. package/target/esbuild/shape/rounded-polygon.jsx +1 -0
  138. package/target/esbuild/shape/shapes.jsx +1 -0
  139. package/target/esbuild/spacing/index.jsx +1 -0
  140. package/target/esbuild/state/component.css +1 -0
  141. package/target/esbuild/state/component.jsx +1 -0
  142. package/target/esbuild/state/controller.jsx +1 -0
  143. package/target/esbuild/state/index.jsx +1 -0
  144. package/target/esbuild/state/ripple.jsx +1 -0
  145. package/target/esbuild/state/state.jsx +1 -0
  146. package/target/esbuild/state/style.jsx +1 -0
  147. package/target/esbuild/surface/carousel-layout.jsx +1 -0
  148. package/target/esbuild/surface/carousel.css +1 -0
  149. package/target/esbuild/surface/carousel.jsx +10 -0
  150. package/target/esbuild/surface/dialog.jsx +35 -0
  151. package/target/esbuild/surface/divider.jsx +1 -0
  152. package/target/esbuild/surface/drag.jsx +1 -0
  153. package/target/esbuild/surface/gestures.css +1 -0
  154. package/target/esbuild/surface/gestures.jsx +7 -0
  155. package/target/esbuild/surface/index.css +1 -0
  156. package/target/esbuild/surface/index.jsx +1 -0
  157. package/target/esbuild/surface/interactive.jsx +1 -0
  158. package/target/esbuild/surface/list-patterns.jsx +26 -0
  159. package/target/esbuild/surface/list.css +1 -0
  160. package/target/esbuild/surface/list.jsx +9 -0
  161. package/target/esbuild/surface/menu.css +1 -0
  162. package/target/esbuild/surface/menu.jsx +12 -0
  163. package/target/esbuild/surface/scaffold.jsx +47 -0
  164. package/target/esbuild/surface/sheet.jsx +21 -0
  165. package/target/esbuild/surface/side-sheet.jsx +17 -0
  166. package/target/esbuild/surface/slots.jsx +1 -0
  167. package/target/esbuild/surface/surface.css +1 -0
  168. package/target/esbuild/surface/surface.jsx +1 -0
  169. package/target/esbuild/text/index.css +1 -0
  170. package/target/esbuild/text/index.jsx +1 -0
  171. package/target/esbuild/text/text.css +1 -0
  172. package/target/esbuild/text/text.jsx +3 -0
  173. package/target/esbuild/text/typography.css +1 -0
  174. package/target/esbuild/text/typography.jsx +1 -0
  175. package/target/esbuild/util/box-side.jsx +1 -0
  176. package/target/esbuild/util/debug.jsx +1 -0
  177. package/target/esbuild/util/dom.jsx +1 -0
  178. package/target/esbuild/util/event.jsx +1 -0
  179. package/target/esbuild/util/index.jsx +1 -0
  180. package/target/esbuild/util/preconditions.jsx +1 -0
  181. package/target/esbuild/util/reactive.jsx +1 -0
  182. package/target/tsc/action/action.css.d.ts +3 -0
  183. package/target/tsc/action/base.d.ts +211 -0
  184. package/target/tsc/action/button.d.ts +126 -0
  185. package/target/tsc/action/fab-menu-context.d.ts +16 -0
  186. package/target/tsc/action/fab-menu.d.ts +112 -0
  187. package/target/tsc/action/fab.d.ts +98 -0
  188. package/target/tsc/action/group.d.ts +166 -0
  189. package/target/tsc/action/icon-button.d.ts +79 -0
  190. package/target/tsc/action/index.d.ts +24 -0
  191. package/target/tsc/action/split-button.d.ts +78 -0
  192. package/target/tsc/color/contrast.d.ts +48 -0
  193. package/target/tsc/color/dynamic.d.ts +203 -0
  194. package/target/tsc/color/hct.d.ts +114 -0
  195. package/target/tsc/color/index.css.d.ts +3 -0
  196. package/target/tsc/color/index.d.ts +23 -0
  197. package/target/tsc/color/palette.d.ts +30 -0
  198. package/target/tsc/color/scheme.d.ts +446 -0
  199. package/target/tsc/color/temperature.d.ts +24 -0
  200. package/target/tsc/container/card.css.d.ts +3 -0
  201. package/target/tsc/container/card.d.ts +110 -0
  202. package/target/tsc/container/elevation-shadow.css.d.ts +3 -0
  203. package/target/tsc/container/elevation-shadow.d.ts +23 -0
  204. package/target/tsc/container/index.d.ts +44 -0
  205. package/target/tsc/dom/client.d.ts +387 -0
  206. package/target/tsc/dom/index.d.ts +93 -0
  207. package/target/tsc/dom/server.d.ts +65 -0
  208. package/target/tsc/dom/types.d.ts +134 -0
  209. package/target/tsc/feedback/badge.d.ts +116 -0
  210. package/target/tsc/feedback/feedback.css.d.ts +3 -0
  211. package/target/tsc/feedback/focus.d.ts +20 -0
  212. package/target/tsc/feedback/index.d.ts +17 -0
  213. package/target/tsc/feedback/loading.d.ts +194 -0
  214. package/target/tsc/feedback/observe.d.ts +75 -0
  215. package/target/tsc/feedback/progress.d.ts +281 -0
  216. package/target/tsc/feedback/snackbar.d.ts +398 -0
  217. package/target/tsc/feedback/tooltip.d.ts +326 -0
  218. package/target/tsc/icon/icon.css.d.ts +3 -0
  219. package/target/tsc/icon/icon.d.ts +69 -0
  220. package/target/tsc/icon/index.d.ts +13 -0
  221. package/target/tsc/index.css.d.ts +3 -0
  222. package/target/tsc/index.d.ts +7 -0
  223. package/target/tsc/input/autocomplete.d.ts +119 -0
  224. package/target/tsc/input/base.d.ts +282 -0
  225. package/target/tsc/input/date-picker.css.d.ts +3 -0
  226. package/target/tsc/input/date-picker.d.ts +351 -0
  227. package/target/tsc/input/date-range-input.css.d.ts +3 -0
  228. package/target/tsc/input/date-time.d.ts +171 -0
  229. package/target/tsc/input/index.css.d.ts +3 -0
  230. package/target/tsc/input/index.d.ts +27 -0
  231. package/target/tsc/input/paired-input.d.ts +435 -0
  232. package/target/tsc/input/picker-dialog.css.d.ts +3 -0
  233. package/target/tsc/input/picker-dialog.d.ts +84 -0
  234. package/target/tsc/input/select.css.d.ts +3 -0
  235. package/target/tsc/input/select.d.ts +267 -0
  236. package/target/tsc/input/slider.css.d.ts +3 -0
  237. package/target/tsc/input/slider.d.ts +372 -0
  238. package/target/tsc/input/text-field.css.d.ts +3 -0
  239. package/target/tsc/input/text-field.d.ts +415 -0
  240. package/target/tsc/input/time-picker.css.d.ts +3 -0
  241. package/target/tsc/input/time-picker.d.ts +212 -0
  242. package/target/tsc/motion/frame.d.ts +36 -0
  243. package/target/tsc/motion/index.css.d.ts +3 -0
  244. package/target/tsc/motion/index.d.ts +34 -0
  245. package/target/tsc/motion/material.d.ts +110 -0
  246. package/target/tsc/motion/motion.d.ts +235 -0
  247. package/target/tsc/motion/spring.d.ts +223 -0
  248. package/target/tsc/motion/transition.css.d.ts +3 -0
  249. package/target/tsc/motion/transition.d.ts +597 -0
  250. package/target/tsc/motion/velocity.d.ts +54 -0
  251. package/target/tsc/navigation/app-bar.d.ts +473 -0
  252. package/target/tsc/navigation/base.d.ts +331 -0
  253. package/target/tsc/navigation/drawer.d.ts +301 -0
  254. package/target/tsc/navigation/index.d.ts +25 -0
  255. package/target/tsc/navigation/navigation.css.d.ts +3 -0
  256. package/target/tsc/navigation/navigation.d.ts +537 -0
  257. package/target/tsc/navigation/scroll.d.ts +218 -0
  258. package/target/tsc/navigation/search.d.ts +332 -0
  259. package/target/tsc/navigation/tabs.d.ts +497 -0
  260. package/target/tsc/navigation/toolbar.d.ts +248 -0
  261. package/target/tsc/selection/base.d.ts +100 -0
  262. package/target/tsc/selection/checkbox.d.ts +194 -0
  263. package/target/tsc/selection/chip.d.ts +358 -0
  264. package/target/tsc/selection/index.d.ts +21 -0
  265. package/target/tsc/selection/radio.d.ts +198 -0
  266. package/target/tsc/selection/segmented.d.ts +333 -0
  267. package/target/tsc/selection/selection.css.d.ts +3 -0
  268. package/target/tsc/selection/switch.d.ts +165 -0
  269. package/target/tsc/shape/corner-rounding.d.ts +36 -0
  270. package/target/tsc/shape/cubic.d.ts +215 -0
  271. package/target/tsc/shape/index.d.ts +35 -0
  272. package/target/tsc/shape/material-shapes.d.ts +176 -0
  273. package/target/tsc/shape/morph.d.ts +91 -0
  274. package/target/tsc/shape/path.d.ts +177 -0
  275. package/target/tsc/shape/point.d.ts +165 -0
  276. package/target/tsc/shape/rounded-polygon.d.ts +289 -0
  277. package/target/tsc/shape/shapes.d.ts +76 -0
  278. package/target/tsc/spacing/index.d.ts +19 -0
  279. package/target/tsc/state/component.css.d.ts +3 -0
  280. package/target/tsc/state/component.d.ts +276 -0
  281. package/target/tsc/state/controller.d.ts +257 -0
  282. package/target/tsc/state/index.d.ts +19 -0
  283. package/target/tsc/state/ripple.d.ts +50 -0
  284. package/target/tsc/state/state.d.ts +129 -0
  285. package/target/tsc/state/style.d.ts +22 -0
  286. package/target/tsc/surface/carousel-layout.d.ts +212 -0
  287. package/target/tsc/surface/carousel.css.d.ts +3 -0
  288. package/target/tsc/surface/carousel.d.ts +231 -0
  289. package/target/tsc/surface/dialog.d.ts +582 -0
  290. package/target/tsc/surface/divider.d.ts +92 -0
  291. package/target/tsc/surface/drag.d.ts +92 -0
  292. package/target/tsc/surface/gestures.css.d.ts +3 -0
  293. package/target/tsc/surface/gestures.d.ts +292 -0
  294. package/target/tsc/surface/index.css.d.ts +3 -0
  295. package/target/tsc/surface/index.d.ts +29 -0
  296. package/target/tsc/surface/interactive.d.ts +22 -0
  297. package/target/tsc/surface/list-patterns.d.ts +384 -0
  298. package/target/tsc/surface/list.css.d.ts +3 -0
  299. package/target/tsc/surface/list.d.ts +340 -0
  300. package/target/tsc/surface/menu.css.d.ts +3 -0
  301. package/target/tsc/surface/menu.d.ts +590 -0
  302. package/target/tsc/surface/scaffold.d.ts +337 -0
  303. package/target/tsc/surface/sheet.d.ts +384 -0
  304. package/target/tsc/surface/side-sheet.d.ts +183 -0
  305. package/target/tsc/surface/slots.d.ts +21 -0
  306. package/target/tsc/surface/surface.css.d.ts +3 -0
  307. package/target/tsc/surface/surface.d.ts +192 -0
  308. package/target/tsc/text/index.css.d.ts +3 -0
  309. package/target/tsc/text/index.d.ts +18 -0
  310. package/target/tsc/text/text.css.d.ts +3 -0
  311. package/target/tsc/text/text.d.ts +94 -0
  312. package/target/tsc/text/typography.css.d.ts +3 -0
  313. package/target/tsc/text/typography.d.ts +82 -0
  314. package/target/tsc/util/box-side.d.ts +76 -0
  315. package/target/tsc/util/debug.d.ts +20 -0
  316. package/target/tsc/util/dom.d.ts +35 -0
  317. package/target/tsc/util/event.d.ts +93 -0
  318. package/target/tsc/util/index.d.ts +12 -0
  319. package/target/tsc/util/preconditions.d.ts +79 -0
  320. package/target/tsc/util/reactive.d.ts +36 -0
@@ -0,0 +1,165 @@
1
+ /**
2
+ * Function mapping coordinates to a point.
3
+ *
4
+ * This is invoked once for each point of the {@link ./cubic#Cubic | curve},
5
+ * {@link ./rounded-polygon#PolygonFeature | feature} or
6
+ * {@link ./rounded-polygon#RoundedPolygon | polygon} being transformed.
7
+ *
8
+ * @param x - horizontal coordinate of point to map
9
+ * @param y - vertical coordinate of point to map
10
+ * @returns mapped point
11
+ */
12
+ export type PointTransformer = (x: number, y: number) => Point;
13
+ /**
14
+ * Immutable point, or vector, of the plane.
15
+ *
16
+ * This uses screen coordinates: `x` grows to the right and `y` grows downwards, hence positive
17
+ * rotations turn clockwise. Every operation returns a new point.
18
+ */
19
+ export declare class Point {
20
+ /**
21
+ * Point at the origin, `(0, 0)`.
22
+ */
23
+ static readonly Zero: Point;
24
+ /**
25
+ * Horizontal coordinate, growing to the right.
26
+ */
27
+ readonly x: number;
28
+ /**
29
+ * Vertical coordinate, growing downwards.
30
+ */
31
+ readonly y: number;
32
+ /**
33
+ * Construct a new point.
34
+ *
35
+ * @param x - horizontal coordinate
36
+ * @param y - vertical coordinate
37
+ * @throws {@link Error} `x` or `y` is not finite
38
+ */
39
+ constructor(x: number, y: number);
40
+ /**
41
+ * Interpolate linearly between two points.
42
+ *
43
+ * @param start - point at progress `0`
44
+ * @param end - point at progress `1`
45
+ * @param progress - progress to interpolate at, extrapolating outside `[0, 1]`
46
+ * @returns interpolated point
47
+ * @throws {@link Error} interpolated point is not finite
48
+ */
49
+ static interpolate(start: Point, end: Point, progress: number): Point;
50
+ /**
51
+ * Subtract a vector from this vector.
52
+ *
53
+ * @param other - vector to subtract
54
+ * @returns difference of vectors
55
+ * @throws {@link Error} difference is not finite
56
+ */
57
+ minus(other: Point): Point;
58
+ /**
59
+ * Add a vector to this vector.
60
+ *
61
+ * @param other - vector to add
62
+ * @returns sum of vectors
63
+ * @throws {@link Error} sum is not finite
64
+ */
65
+ plus(other: Point): Point;
66
+ /**
67
+ * Multiply both coordinates by a factor.
68
+ *
69
+ * @param factor - factor to multiply by
70
+ * @returns scaled vector
71
+ * @throws {@link Error} scaled vector is not finite
72
+ */
73
+ times(factor: number): Point;
74
+ /**
75
+ * Divide both coordinates by a divisor.
76
+ *
77
+ * @param factor - divisor to divide by
78
+ * @returns scaled vector
79
+ * @throws {@link Error} scaled vector is not finite, for example after a division by `0`
80
+ */
81
+ div(factor: number): Point;
82
+ /**
83
+ * Compute squared length of this vector.
84
+ *
85
+ * @returns squared length
86
+ */
87
+ distanceSquared(): number;
88
+ /**
89
+ * Compute length of this vector.
90
+ *
91
+ * @returns length
92
+ */
93
+ distance(): number;
94
+ /**
95
+ * Compute dot product with another vector.
96
+ *
97
+ * @param other - vector to multiply with
98
+ * @returns dot product
99
+ */
100
+ dot(other: Point): number;
101
+ /**
102
+ * Compute unit vector of the same direction.
103
+ *
104
+ * @returns unit vector
105
+ * @throws {@link Error} this vector has no length
106
+ */
107
+ direction(): Point;
108
+ /**
109
+ * Turn this vector a quarter turn clockwise.
110
+ *
111
+ * @returns perpendicular vector of the same length
112
+ */
113
+ rotate90(): Point;
114
+ /**
115
+ * Compute cross product with another vector.
116
+ *
117
+ * @param other - vector to multiply with
118
+ * @returns cross product, positive if, and only if, `other` turns clockwise from this vector
119
+ */
120
+ cross(other: Point): number;
121
+ /**
122
+ * Rotate this point around a center.
123
+ *
124
+ * @param degrees - angle in degrees, where positive angles turn clockwise
125
+ * @param center - center to rotate around, or `undefined` to rotate around the origin
126
+ * @returns rotated point
127
+ */
128
+ rotate(degrees: number, center?: Point): Point;
129
+ }
130
+ /**
131
+ * Compute the unit vector of an angle.
132
+ *
133
+ * @param angle - angle in radians, clockwise from the positive `x` axis
134
+ * @returns unit vector
135
+ * @throws {@link Error} `angle` is not finite
136
+ */
137
+ export declare function directionVector(angle: number): Point;
138
+ /**
139
+ * Compute the unit vector of a vector.
140
+ *
141
+ * @param x - horizontal coordinate of vector
142
+ * @param y - vertical coordinate of vector
143
+ * @returns unit vector
144
+ * @throws {@link Error} vector has no length
145
+ */
146
+ export declare function directionVector(x: number, y: number): Point;
147
+ /**
148
+ * Compute the distance between two points.
149
+ *
150
+ * @param a - first point
151
+ * @param b - second point
152
+ * @returns distance between `a` and `b`
153
+ */
154
+ export declare function distanceBetween(a: Point, b: Point): number;
155
+ /**
156
+ * Test whether an outline turns clockwise.
157
+ *
158
+ * A clockwise outline is convex at the points where it turns clockwise.
159
+ *
160
+ * @param previous - point before `current`
161
+ * @param current - point at which outline turns
162
+ * @param next - point after `current`
163
+ * @returns `true` if, and only if, outline turns clockwise at `current`
164
+ */
165
+ export declare function isConvex(previous: Point, current: Point, next: Point): boolean;
@@ -0,0 +1,289 @@
1
+ import type { PointTransformer } from "./point";
2
+ import { CornerRounding } from "./corner-rounding";
3
+ import { Cubic } from "./cubic";
4
+ import { Point } from "./point";
5
+ /**
6
+ * Union of polygon feature kinds.
7
+ *
8
+ * | Kind | Description |
9
+ * | -------- | ----------------------------------------------------- |
10
+ * | `corner` | Rounded or sharp vertex, which morphs match by place. |
11
+ * | `edge` | Straight segment between two corners. |
12
+ *
13
+ * @see {@link PolygonFeature.kind}
14
+ */
15
+ export type PolygonFeatureKind = "corner" | "edge";
16
+ /**
17
+ * {@link RoundedPolygon.fromVertices} options.
18
+ */
19
+ export interface RoundedPolygonOptions {
20
+ /**
21
+ * Rounding of vertices without per-vertex rounding.
22
+ *
23
+ * @defaultValue {@link CornerRounding.Unrounded}
24
+ */
25
+ rounding?: CornerRounding | undefined;
26
+ /**
27
+ * Rounding of each vertex, in vertex order.
28
+ *
29
+ * Vertices without an entry are rounded with
30
+ * {@link RoundedPolygonOptions.rounding | `rounding`}.
31
+ */
32
+ perVertexRounding?: readonly CornerRounding[] | undefined;
33
+ /**
34
+ * Horizontal coordinate of the center.
35
+ *
36
+ * @defaultValue mean horizontal coordinate of vertices
37
+ */
38
+ centerX?: number | undefined;
39
+ /**
40
+ * Vertical coordinate of the center.
41
+ *
42
+ * @defaultValue mean vertical coordinate of vertices
43
+ */
44
+ centerY?: number | undefined;
45
+ }
46
+ /**
47
+ * Corner or edge of a {@link RoundedPolygon}.
48
+ *
49
+ * Morphs match the corners of two polygons by place and convexity, whereas edges only connect
50
+ * corners.
51
+ */
52
+ export declare class PolygonFeature {
53
+ /**
54
+ * Contiguous curves of the feature.
55
+ */
56
+ readonly cubics: readonly Cubic[];
57
+ /**
58
+ * Kind of the feature.
59
+ */
60
+ readonly kind: PolygonFeatureKind;
61
+ /**
62
+ * Corner turns clockwise.
63
+ *
64
+ * This is always `true` for edges.
65
+ */
66
+ readonly convex: boolean;
67
+ /**
68
+ * Construct a new feature.
69
+ *
70
+ * @param cubics - contiguous curves of feature, in outline order
71
+ * @param kind - kind of feature
72
+ * @param convex - `false` if, and only if, corner turns counter-clockwise, which is ignored
73
+ * for edges
74
+ * @throws {@link Error} `cubics` is empty or not contiguous
75
+ */
76
+ constructor(cubics: readonly Cubic[], kind: PolygonFeatureKind, convex?: boolean);
77
+ /**
78
+ * Feature is an edge.
79
+ */
80
+ get isEdge(): boolean;
81
+ /**
82
+ * Feature is a corner.
83
+ */
84
+ get isCorner(): boolean;
85
+ /**
86
+ * Feature may be ignored by morphs.
87
+ *
88
+ * This is `true` if, and only if, the feature is an edge, which morphs may ignore when
89
+ * matching outlines.
90
+ */
91
+ get isIgnorableFeature(): boolean;
92
+ /**
93
+ * Feature is a corner turning clockwise.
94
+ */
95
+ get isConvexCorner(): boolean;
96
+ /**
97
+ * Feature is a corner turning counter-clockwise.
98
+ */
99
+ get isConcaveCorner(): boolean;
100
+ /**
101
+ * Transform the curves of the feature.
102
+ *
103
+ * @param transformer - function to transform each point of each curve with, in order
104
+ * @returns feature of same kind and convexity
105
+ * @throws {@link Error} a transformed coordinate is not finite, or the transformed curves are
106
+ * not contiguous
107
+ */
108
+ transformed(transformer: PointTransformer): PolygonFeature;
109
+ /**
110
+ * Reverse the direction of the feature.
111
+ *
112
+ * @returns feature of same kind running backwards, whose corner turns the other way
113
+ */
114
+ reversed(): PolygonFeature;
115
+ /**
116
+ * Test whether a value is an equal feature.
117
+ *
118
+ * @param other - value to compare with
119
+ * @returns `true` if, and only if, `other` is a feature of equal kind, convexity and curves
120
+ */
121
+ equals(other: unknown): boolean;
122
+ }
123
+ /**
124
+ * Polygon with rounded corners.
125
+ *
126
+ * This is an immutable, closed outline of {@link RoundedPolygon.features | features}: corners,
127
+ * rounded or sharp, alternating with the edges between them. Its
128
+ * {@link RoundedPolygon.cubics | curves} omit curves of zero length, and start in the middle of
129
+ * the first corner if it is rounded. Vertices listed clockwise make convex corners.
130
+ *
131
+ * ```ts
132
+ * // Rounded triangle within the unit square:
133
+ * const triangle = RoundedPolygon.fromVertices(
134
+ * [0.5, 0, 1, 1, 0, 1],
135
+ * { rounding: new CornerRounding(0.1, 0.4) }
136
+ * );
137
+ * ```
138
+ */
139
+ export declare class RoundedPolygon {
140
+ /**
141
+ * Center of the polygon.
142
+ */
143
+ readonly center: Point;
144
+ /**
145
+ * Features of the polygon, in outline order.
146
+ */
147
+ readonly features: readonly PolygonFeature[];
148
+ /**
149
+ * Cubic Bezier curves of the outline.
150
+ *
151
+ * This is a closed outline, without curves of zero length.
152
+ */
153
+ readonly cubics: readonly Cubic[];
154
+ /**
155
+ * Construct a new polygon.
156
+ *
157
+ * @param features - features forming a closed outline
158
+ * @param center - center of polygon
159
+ * @throws {@link Error} there are fewer than two features, or they do not form a closed
160
+ * outline
161
+ */
162
+ private constructor();
163
+ /**
164
+ * Horizontal coordinate of the center.
165
+ */
166
+ get centerX(): number;
167
+ /**
168
+ * Vertical coordinate of the center.
169
+ */
170
+ get centerY(): number;
171
+ /**
172
+ * Create a polygon from its vertices.
173
+ *
174
+ * @param vertices - coordinates of at least three vertices, as `[x, y]` pairs in outline
175
+ * order
176
+ * @param options - roundings and center of polygon, if any
177
+ * @returns new polygon
178
+ * @throws {@link Error} there are fewer than three vertices, a coordinate is not finite, or
179
+ * the per-vertex roundings do not match the vertices
180
+ */
181
+ static fromVertices(vertices: readonly number[], options?: RoundedPolygonOptions): RoundedPolygon;
182
+ /**
183
+ * Create a polygon from its vertices.
184
+ *
185
+ * @param vertices - coordinates of at least three vertices, as `[x, y]` pairs in outline
186
+ * order
187
+ * @param rounding - rounding of vertices without per-vertex rounding, if any
188
+ * @param perVertexRounding - rounding of each vertex, if any
189
+ * @param centerX - horizontal coordinate of center, or `undefined` for the mean of the
190
+ * vertices
191
+ * @param centerY - vertical coordinate of center, or `undefined` for the mean of the
192
+ * vertices
193
+ * @returns new polygon
194
+ * @throws {@link Error} there are fewer than three vertices, a coordinate is not finite, or
195
+ * the per-vertex roundings do not match the vertices
196
+ */
197
+ static fromVertices(vertices: readonly number[], rounding?: CornerRounding, perVertexRounding?: readonly CornerRounding[], centerX?: number, centerY?: number): RoundedPolygon;
198
+ /**
199
+ * Create a polygon from its features.
200
+ *
201
+ * @param features - at least two features forming a closed outline
202
+ * @param centerX - horizontal coordinate of center, or `undefined` for the mean of the start
203
+ * anchors of all curves
204
+ * @param centerY - vertical coordinate of center, or `undefined` for the mean of the start
205
+ * anchors of all curves
206
+ * @returns new polygon
207
+ * @throws {@link Error} there are fewer than two features, they do not form a closed outline,
208
+ * or a coordinate of the center is not finite
209
+ */
210
+ static fromFeatures(features: readonly PolygonFeature[], centerX?: number, centerY?: number): RoundedPolygon;
211
+ /**
212
+ * Create a regular polygon.
213
+ *
214
+ * The first vertex lies at 3 o'clock from the center, and the others follow clockwise.
215
+ *
216
+ * @param numVertices - number of vertices, at least `3`
217
+ * @param radius - distance of vertices from center
218
+ * @param centerX - horizontal coordinate of center
219
+ * @param centerY - vertical coordinate of center
220
+ * @param rounding - rounding of vertices without per-vertex rounding
221
+ * @param perVertexRounding - rounding of each vertex, if any
222
+ * @returns new polygon
223
+ * @throws {@link Error} `numVertices` is not an integer of at least `3`, `radius` is not
224
+ * positive and finite, or the per-vertex roundings do not match the vertices
225
+ */
226
+ static fromNumVertices(numVertices: number, radius?: number, centerX?: number, centerY?: number, rounding?: CornerRounding, perVertexRounding?: readonly CornerRounding[]): RoundedPolygon;
227
+ /**
228
+ * Transform the features and the center of the polygon.
229
+ *
230
+ * @param transformer - function to transform each point of each feature with, in order, and
231
+ * then the center
232
+ * @returns transformed polygon
233
+ * @throws {@link Error} a transformed coordinate is not finite, or the transformed features do
234
+ * not form a closed outline
235
+ */
236
+ transformed(transformer: PointTransformer): RoundedPolygon;
237
+ /**
238
+ * Fit the polygon into the unit square.
239
+ *
240
+ * This scales and moves the polygon until the longer side of its
241
+ * {@link RoundedPolygon.calculateBounds | approximate bounds} spans `[0, 1]`, and centers the
242
+ * shorter side within `[0, 1]`.
243
+ *
244
+ * @returns polygon within the unit square
245
+ * @throws {@link Error} polygon has no extent
246
+ */
247
+ normalized(): RoundedPolygon;
248
+ /**
249
+ * Calculate the bounds of the outline.
250
+ *
251
+ * Approximate bounds contain the control points of the curves, and may thus exceed the
252
+ * outline.
253
+ *
254
+ * @param bounds - array to write `[left, top, right, bottom]` into, if any
255
+ * @param approximate - `true` if, and only if, bounds should be approximate
256
+ * @returns `bounds`, or a new array if `bounds` is `undefined`
257
+ * @throws {@link Error} `bounds` has fewer than four entries
258
+ */
259
+ calculateBounds(bounds?: number[], approximate?: boolean): number[];
260
+ /**
261
+ * Calculate bounds of the polygon in any rotation.
262
+ *
263
+ * This returns the bounds of a square around the center, reaching the farthest start anchor or
264
+ * midpoint of the curves of the outline. In other words, the bounds contain the polygon in any
265
+ * rotation around its center.
266
+ *
267
+ * @param bounds - array to write `[left, top, right, bottom]` into, if any
268
+ * @returns `bounds`, or a new array if `bounds` is `undefined`
269
+ * @throws {@link Error} `bounds` has fewer than four entries
270
+ */
271
+ calculateMaxBounds(bounds?: number[]): number[];
272
+ /**
273
+ * Test whether a value is an equal polygon.
274
+ *
275
+ * This does **not** compare centers.
276
+ *
277
+ * @param other - value to compare with
278
+ * @returns `true` if, and only if, `other` is a polygon whose features equal those of this
279
+ * polygon
280
+ */
281
+ equals(other: unknown): boolean;
282
+ }
283
+ /**
284
+ * Test whether a value is a rounded polygon.
285
+ *
286
+ * @param value - value to test
287
+ * @returns `true` if, and only if, `value` is a {@link RoundedPolygon}
288
+ */
289
+ export declare function isRoundedPolygon(value: unknown): value is RoundedPolygon;
@@ -0,0 +1,76 @@
1
+ import { CornerRounding } from "./corner-rounding";
2
+ import { RoundedPolygon } from "./rounded-polygon";
3
+ /**
4
+ * Factories of common polygons.
5
+ */
6
+ export declare class Shapes {
7
+ /**
8
+ * Create a circle.
9
+ *
10
+ * This creates a regular polygon whose corners are rounded with the radius of the circle. In
11
+ * other words, the outline of the circle consists of `numVertices` circular arcs.
12
+ *
13
+ * @param numVertices - number of arcs, at least `3`
14
+ * @param radius - radius of circle
15
+ * @param centerX - horizontal coordinate of center
16
+ * @param centerY - vertical coordinate of center
17
+ * @returns new circle
18
+ * @throws {@link Error} `numVertices` is not an integer of at least `3`, or `radius` is not
19
+ * positive and finite
20
+ */
21
+ static circle(numVertices?: number, radius?: number, centerX?: number, centerY?: number): RoundedPolygon;
22
+ /**
23
+ * Create a rectangle.
24
+ *
25
+ * The vertices of the rectangle start at its bottom-right corner, and run clockwise.
26
+ *
27
+ * @param width - width of rectangle
28
+ * @param height - height of rectangle
29
+ * @param rounding - rounding of corners without per-vertex rounding
30
+ * @param perVertexRounding - rounding of bottom-right, bottom-left, top-left and top-right
31
+ * corners, respectively, if any
32
+ * @param centerX - horizontal coordinate of center
33
+ * @param centerY - vertical coordinate of center
34
+ * @returns new rectangle
35
+ * @throws {@link Error} `width` or `height` is not positive and finite, or the per-vertex
36
+ * roundings are not four
37
+ */
38
+ static rectangle(width?: number, height?: number, rounding?: CornerRounding, perVertexRounding?: readonly CornerRounding[], centerX?: number, centerY?: number): RoundedPolygon;
39
+ /**
40
+ * Create a star.
41
+ *
42
+ * Outer and inner vertices alternate, starting with an outer vertex at 3 o'clock from the
43
+ * center, and running clockwise.
44
+ *
45
+ * @param numVerticesPerRadius - number of outer vertices, at least `2`
46
+ * @param radius - distance of outer vertices from center
47
+ * @param innerRadius - distance of inner vertices from center, below `radius`
48
+ * @param rounding - rounding of outer vertices, and of inner vertices if `innerRounding` is
49
+ * `undefined`
50
+ * @param innerRounding - rounding of inner vertices, if any
51
+ * @param perVertexRounding - rounding of each vertex, replacing `rounding` and
52
+ * `innerRounding`, if any
53
+ * @param centerX - horizontal coordinate of center
54
+ * @param centerY - vertical coordinate of center
55
+ * @returns new star
56
+ * @throws {@link Error} `numVerticesPerRadius` is not an integer of at least `2`, a radius
57
+ * is not positive and finite, `innerRadius` is not below `radius`, or the per-vertex
58
+ * roundings do not match the vertices
59
+ */
60
+ static star(numVerticesPerRadius: number, radius?: number, innerRadius?: number, rounding?: CornerRounding, innerRounding?: CornerRounding, perVertexRounding?: readonly CornerRounding[], centerX?: number, centerY?: number): RoundedPolygon;
61
+ /**
62
+ * Create a pill.
63
+ *
64
+ * A pill is a rectangle whose shorter sides are semicircles.
65
+ *
66
+ * @param width - width of pill
67
+ * @param height - height of pill
68
+ * @param smoothing - smoothing of corners
69
+ * @param centerX - horizontal coordinate of center
70
+ * @param centerY - vertical coordinate of center
71
+ * @returns new pill
72
+ * @throws {@link Error} `width` or `height` is not positive and finite, or `smoothing` is
73
+ * outside `[0, 1]`
74
+ */
75
+ static pill(width?: number, height?: number, smoothing?: number, centerX?: number, centerY?: number): RoundedPolygon;
76
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Spacing scale for layout.
3
+ *
4
+ * Cobweb exposes one spacing scale as numeric CSS pixel values, through {@link spacing}, and as
5
+ * `cw-Measurement-space<N>` design roles of the [`cw-Measurement`](./measurement.yaml) design
6
+ * attribute, both indexed by the same suffixes. A suffix is the spacing in hundredths of `8px`, so
7
+ * `100` is `8px` and `450` is `36px`. Import this module for numeric layout calculations, or use
8
+ * the design roles with `cw-var()` in stylesheets. Component-specific dimensions remain separate.
9
+ *
10
+ * @packageDocumentation
11
+ */
12
+ /**
13
+ * Spacing values, in CSS pixels, indexed by their {@link Spacing | suffix}.
14
+ */
15
+ export declare const spacing: Readonly<Record<Spacing, number>>;
16
+ /**
17
+ * Suffix of a spacing value, which is the spacing in hundredths of `8px`.
18
+ */
19
+ export type Spacing = 0 | 25 | 50 | 75 | 100 | 125 | 150 | 175 | 200 | 250 | 300 | 400 | 450 | 500 | 600 | 700 | 800 | 900;
@@ -0,0 +1,3 @@
1
+ // SPDX-License-Identifier: MPL-2.0
2
+
3
+ export {};