@symbo.ls/link 3.0.100 → 3.1.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 (2) hide show
  1. package/index.js +49 -33
  2. package/package.json +4 -4
package/index.js CHANGED
@@ -5,59 +5,75 @@ import { router as defaultRouter } from '@domql/router'
5
5
  export const Link = {
6
6
  extends: 'Focusable',
7
7
  tag: 'a',
8
- props: {
9
- aria: {},
10
- fontWeight: 'bold',
11
- textDecoration: 'none',
12
- color: 'currentColor',
13
- draggable: false
14
- },
8
+
9
+ aria: {},
10
+ fontWeight: 'bold',
11
+ textDecoration: 'none',
12
+ color: 'currentColor',
13
+ draggable: false,
14
+
15
15
  attr: {
16
16
  href: (el, s, ctx) => {
17
17
  const props = el.props
18
- const href = el.call('exec', props.href, el) || el.call('exec', el.call('exec', props, el).href, el)
18
+ const href =
19
+ el.call('exec', props.href, el) ||
20
+ el.call('exec', el.call('exec', props, el).href, el)
19
21
  if (el.call('isString', href) && href.includes('{{')) {
20
22
  return el.call('replaceLiteralsWithObjectFields', href)
21
23
  }
22
24
  return href
23
25
  },
24
26
  target: ({ props }) => props.target,
25
- 'aria-label': ({ props }) => props.aria ? props.aria.label : props.text,
27
+ 'aria-label': ({ props }) => (props.aria ? props.aria.label : props.text),
26
28
  draggable: ({ props }) => props.draggable
27
29
  }
28
30
  }
29
31
 
30
32
  export const RouterLink = {
31
- on: {
32
- click: (event, el, s) => {
33
- const { props, context: ctx } = el
34
- const { href: h, scrollToTop, stopPropagation } = props
35
- let href = el.call('exec', h, el)
33
+ onClick: (event, el, s) => {
34
+ const { props, context: ctx } = el
35
+ const { href: h, scrollToTop, stopPropagation } = props
36
+ let href = el.call('exec', h, el)
36
37
 
37
- if (el.call('isString', href) && href.includes('{{')) {
38
- href = el.call('replaceLiteralsWithObjectFields', href)
39
- }
38
+ if (el.call('isString', href) && href.includes('{{')) {
39
+ href = el.call('replaceLiteralsWithObjectFields', href)
40
+ }
40
41
 
41
- if (stopPropagation) event.stopPropagation()
42
- if (!href) return
43
- const { utils, snippets, functions, routerOptions } = ctx
44
- const root = el.__ref.root
45
- const linkIsExternal = href.includes('http://') ||
46
- href.includes('https://') ||
47
- href.includes('mailto:') ||
48
- href.includes('tel:')
49
- if (href && !linkIsExternal) {
50
- try {
51
- (functions.router || snippets.router || utils.router || defaultRouter)(href, root, {}, {
42
+ if (stopPropagation) event.stopPropagation()
43
+ if (!href) return
44
+ const { utils, snippets, functions, routerOptions } = ctx
45
+ const root = el.__ref.root
46
+ const linkIsExternal =
47
+ href.startsWith('http://') ||
48
+ href.startsWith('https://') ||
49
+ href.startsWith('mailto:') ||
50
+ href.startsWith('tel:') ||
51
+ href.startsWith('sketch:') ||
52
+ href.startsWith('whatsapp:') ||
53
+ href.startsWith('sms:') ||
54
+ href.startsWith('skype:') ||
55
+ href.startsWith('viber:') ||
56
+ href.startsWith('callto:') ||
57
+ href.startsWith('facetime:') ||
58
+ href.startsWith('facetime-audio:') ||
59
+ href.startsWith('geo:') ||
60
+ href.startsWith('maps:')
61
+ if (href && !linkIsExternal) {
62
+ try {
63
+ ;(functions.router || snippets.router || utils.router || defaultRouter)(
64
+ href,
65
+ root,
66
+ {},
67
+ {
52
68
  scrollToOptions: { behaviour: 'instant' },
53
69
  scrollToTop: el.call('isDefined', scrollToTop) ? scrollToTop : true,
54
70
  ...routerOptions,
55
71
  ...props.routerOptions
56
- })
57
- event.preventDefault()
58
- } catch (e) {
59
- console.warn(e)
60
- }
72
+ }
73
+ )
74
+ event.preventDefault()
75
+ } catch (e) {
76
+ console.warn(e)
61
77
  }
62
78
  }
63
79
  }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@symbo.ls/link",
3
- "version": "3.0.100",
3
+ "version": "3.1.2",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
- "gitHead": "1302a0674cc4d420f304737973a7f7bece86f359",
6
+ "gitHead": "429b36616aa04c8587a26ce3c129815115e35897",
7
7
  "dependencies": {
8
- "@domql/router": "^3.0.0",
9
- "@symbo.ls/atoms": "^3.0.100"
8
+ "@domql/router": "^3.1.2",
9
+ "@symbo.ls/atoms": "^3.1.2"
10
10
  },
11
11
  "source": "src/index.js"
12
12
  }