@_unit/unit 1.0.23 → 1.0.24

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 (44) hide show
  1. package/build/web.js +10 -10
  2. package/lib/API.d.ts +1 -0
  3. package/lib/client/PositionObserver.js +55 -18
  4. package/lib/client/PositionObserver.js.map +1 -1
  5. package/lib/client/platform/web/api/window.js +3 -0
  6. package/lib/client/platform/web/api/window.js.map +1 -1
  7. package/lib/host/none.js +3 -0
  8. package/lib/host/none.js.map +1 -1
  9. package/lib/system/_classes.d.ts +2 -0
  10. package/lib/system/_classes.js +2 -0
  11. package/lib/system/_classes.js.map +1 -1
  12. package/lib/system/_components.d.ts +2 -0
  13. package/lib/system/_components.js +44 -42
  14. package/lib/system/_components.js.map +1 -1
  15. package/lib/system/_ids.d.ts +1 -0
  16. package/lib/system/_ids.js +8 -7
  17. package/lib/system/_ids.js.map +1 -1
  18. package/lib/system/_specs.js +1 -1
  19. package/lib/system/_specs.js.map +1 -1
  20. package/lib/system/platform/component/svg/Object/Component.d.ts +23 -0
  21. package/lib/system/platform/component/svg/Object/Component.js +82 -0
  22. package/lib/system/platform/component/svg/Object/Component.js.map +1 -0
  23. package/lib/system/platform/component/svg/Object/index.d.ts +13 -0
  24. package/lib/system/platform/component/svg/Object/index.js +17 -0
  25. package/lib/system/platform/component/svg/Object/index.js.map +1 -0
  26. package/lib/types/global/IPositionObserver.d.ts +5 -1
  27. package/package.json +1 -1
  28. package/public/_worker.js +5 -5
  29. package/public/_worker.js.map +4 -4
  30. package/public/build.json +1 -1
  31. package/public/index.js +10 -10
  32. package/public/index.js.map +4 -4
  33. package/src/API.ts +1 -0
  34. package/src/client/PositionObserver.ts +72 -15
  35. package/src/client/platform/web/api/window.ts +4 -1
  36. package/src/host/none.ts +3 -0
  37. package/src/system/_classes.ts +2 -0
  38. package/src/system/_components.ts +2 -0
  39. package/src/system/_ids.ts +1 -0
  40. package/src/system/_specs.ts +1 -1
  41. package/src/system/platform/component/svg/Object/Component.ts +107 -0
  42. package/src/system/platform/component/svg/Object/index.ts +30 -0
  43. package/src/system/platform/component/svg/Object/spec.json +37 -0
  44. package/src/types/global/IPositionObserver.ts +9 -1
@@ -0,0 +1,107 @@
1
+ import { namespaceURI } from '../../../../../client/component/namespaceURI'
2
+ import { Element } from '../../../../../client/element'
3
+ import { PropHandler } from '../../../../../client/propHandler'
4
+ import { applyStyle } from '../../../../../client/style'
5
+ import { System } from '../../../../../system'
6
+ import { Style } from '../../../Props'
7
+
8
+ export interface Props {
9
+ id?: string
10
+ className?: string
11
+ style?: Style
12
+ d?: string
13
+ markerStart?: string
14
+ markerEnd?: string
15
+ fillRule?: string
16
+ }
17
+
18
+ export const DEFAULT_STYLE = {
19
+ strokeWidth: '3px',
20
+ fill: 'none',
21
+ stroke: 'currentColor',
22
+ }
23
+
24
+ export default class SVGObject extends Element<SVGPathElement, Props> {
25
+ private _path_el: SVGPathElement
26
+
27
+ private _prop_handler: PropHandler = {
28
+ className: (className: string | undefined) => {
29
+ this._path_el.className.value = className
30
+ },
31
+ style: (style: Style | undefined) => {
32
+ applyStyle(this._path_el, { ...DEFAULT_STYLE, ...style })
33
+ },
34
+ d: (d: string | undefined) => {
35
+ if (d === undefined) {
36
+ this._path_el.removeAttribute('d')
37
+ } else {
38
+ this._path_el.setAttribute('d', d)
39
+ }
40
+ },
41
+ markerStart: (markerStart: string | undefined) => {
42
+ this._path_el.setAttribute('marker-start', markerStart)
43
+ },
44
+ markerEnd: (markerEnd: string | undefined) => {
45
+ this._path_el.setAttribute('marker-end', markerEnd)
46
+ },
47
+ strokeWidth: (strokeWidth: string | undefined) => {
48
+ if (strokeWidth === undefined) {
49
+ this._path_el.removeAttribute('stroke-width')
50
+ } else {
51
+ this._path_el.setAttribute('stroke-width', `${strokeWidth}`)
52
+ }
53
+ },
54
+ fillRule: (fillRule: string | undefined) => {
55
+ if (fillRule === undefined) {
56
+ this._path_el.removeAttribute('fill-rule')
57
+ } else {
58
+ this._path_el.setAttribute('fill-rule', fillRule)
59
+ }
60
+ },
61
+ }
62
+
63
+ constructor($props: Props, $system: System) {
64
+ super($props, $system)
65
+
66
+ const {
67
+ id,
68
+ className,
69
+ style = {},
70
+ d = '',
71
+ markerStart,
72
+ markerEnd,
73
+ fillRule,
74
+ } = $props
75
+
76
+ const path_el = this.$system.api.document.createElementNS(
77
+ namespaceURI,
78
+ 'path'
79
+ )
80
+ if (id !== undefined) {
81
+ path_el.id = id
82
+ }
83
+ if (className) {
84
+ path_el.classList.value = className
85
+ }
86
+ applyStyle(path_el, { ...DEFAULT_STYLE, ...style })
87
+ path_el.setAttribute('d', d)
88
+ if (markerStart !== undefined) {
89
+ path_el.setAttribute('marker-start', markerStart)
90
+ }
91
+ if (markerEnd !== undefined) {
92
+ path_el.setAttribute('marker-end', markerEnd)
93
+ }
94
+ if (fillRule !== undefined) {
95
+ path_el.setAttribute('fill-rule', fillRule)
96
+ }
97
+ this._path_el = path_el
98
+
99
+ this.$element = path_el
100
+ this.$unbundled = false
101
+ this.$primitive = true
102
+ }
103
+
104
+ onPropChanged(prop: string, current: any): void {
105
+ this._prop_handler[prop](current)
106
+ }
107
+ }
@@ -0,0 +1,30 @@
1
+ import { Element_ } from '../../../../../Class/Element'
2
+ import { System } from '../../../../../system'
3
+ import { Dict } from '../../../../../types/Dict'
4
+ import { ID_PATH } from '../../../../_ids'
5
+
6
+ export interface I {
7
+ style: Dict<string>
8
+ d: string
9
+ fillRule: string
10
+ }
11
+
12
+ export interface O {}
13
+
14
+ export default class SVGObject extends Element_<I, O> {
15
+ constructor(system: System) {
16
+ super(
17
+ {
18
+ i: ['style', 'd', 'fillRule'],
19
+ o: [],
20
+ },
21
+ {},
22
+ system,
23
+ ID_PATH
24
+ )
25
+
26
+ this._defaultState = {
27
+ d: '',
28
+ }
29
+ }
30
+ }
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "svg object",
3
+ "inputs": {
4
+ "style": {
5
+ "type": "object",
6
+ "optional": true
7
+ },
8
+ "d": {
9
+ "type": "string",
10
+ "optional": true,
11
+ "metadata": {
12
+ "examples": []
13
+ }
14
+ },
15
+ "fillRule": {
16
+ "type": "string",
17
+ "optional": true,
18
+ "defaultIgnored": true
19
+ }
20
+ },
21
+ "outputs": {},
22
+ "metadata": {
23
+ "icon": "square",
24
+ "description": "SVG path",
25
+ "complexity": 43,
26
+ "tags": ["platform", "component", "svg"]
27
+ },
28
+ "id": "c90ea697-ba4f-48ca-85e0-d9f26731e33e",
29
+ "base": true,
30
+ "component": {
31
+ "defaultWidth": 200,
32
+ "defaultHeight": 200
33
+ },
34
+ "type": "`U`&`C`&`V`&`J`",
35
+ "system": true,
36
+ "render": true
37
+ }
@@ -20,7 +20,11 @@ export interface IPositionCallback {
20
20
  ry: number,
21
21
  rz: number,
22
22
  px: number,
23
- py: number
23
+ py: number,
24
+ gpx: number,
25
+ gpy: number,
26
+ gbx: number,
27
+ gby: number
24
28
  ): void
25
29
  }
26
30
 
@@ -34,4 +38,8 @@ export interface IPositionEntry {
34
38
  rz: number
35
39
  px: number
36
40
  py: number
41
+ gpx: number
42
+ gpy: number
43
+ gbx: number
44
+ gby: number
37
45
  }