@symbo.ls/link 1.1.5 → 1.2.5

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 (2) hide show
  1. package/index.js +28 -6
  2. package/package.json +4 -3
package/index.js CHANGED
@@ -1,16 +1,38 @@
1
1
  'use strict'
2
2
 
3
+ import { router } from '@domql/router'
4
+ import { Focusable } from '@symbo.ls/atoms'
5
+
3
6
  export const Link = {
7
+ extend: Focusable,
4
8
  tag: 'a',
5
9
  props: {
6
- href: '',
7
- target: '',
8
- theme: 'link',
9
- aria: {}
10
+ aria: {},
11
+ fontWeight: 'bold',
12
+ textDecoration: 'none',
13
+ color: 'currentColor'
10
14
  },
11
15
  attr: {
12
- href: ({ props }) => props.href,
16
+ href: element => {
17
+ const exec = element.context.utils
18
+ exec(element.props.href, element) || exec(element.props, element).href
19
+ },
13
20
  target: ({ props }) => props.target,
14
- 'aria-label': ({ props }) => props.aria.label || props.text
21
+ 'aria-label': ({ props }) => props.aria ? props.aria.label : props.text
22
+ }
23
+ }
24
+
25
+ export const RouteLink = {
26
+ extend: Link,
27
+ on: {
28
+ click: (event, element, state) => {
29
+ const root = element.lookup('app')
30
+ const { href } = element.props
31
+ const firstThree = href[0] + href[1] + href[2]
32
+ if (href && firstThree !== 'htt' && firstThree !== 'ske') {
33
+ router(root, href, {})
34
+ event.preventDefault()
35
+ }
36
+ }
15
37
  }
16
38
  }
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@symbo.ls/link",
3
- "version": "1.1.5",
3
+ "version": "1.2.5",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
- "gitHead": "8590863dfd2c60cbe59db0b4bb8239c8a7585259",
6
+ "gitHead": "8f97205ca57c54560c3f7489c518e2153c5c9b5e",
7
7
  "dependencies": {
8
- "@symbo.ls/shape": "latest"
8
+ "@domql/router": "latest",
9
+ "@symbo.ls/atoms": "latest"
9
10
  },
10
11
  "source": "src/index.js"
11
12
  }