@inizioevoke/veeva-astroclm 1.1.12 → 1.2.1

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@inizioevoke/veeva-astroclm",
3
3
  "type": "module",
4
- "version": "1.1.12",
4
+ "version": "1.2.1",
5
5
  "bin": "./bin/create.js",
6
6
  "scripts": {
7
7
  "start": "astro dev",
@@ -27,7 +27,7 @@
27
27
  "dependencies": {
28
28
  "@astrojs/preact": "^6.1.6",
29
29
  "@inizioevoke/astro-core": "^3.4.0",
30
- "@inizioevoke/veeva-astroclm-core": "^1.4.10",
30
+ "@inizioevoke/veeva-astroclm-core": "^1.4.11",
31
31
  "@inizioevoke/veeva-clmjs": "^1.0.1",
32
32
  "@inizioevoke/veeva-iva": "^1.4.1",
33
33
  "astro": "^7.4.12",
@@ -1,5 +1,7 @@
1
1
  ---
2
2
  import { BUILD_TARGET, VEEVA_CONTROLS } from 'astro:env/client';
3
+ import { PageUrls, type PageHref } from '@data/pages';
4
+ import Link from '@components/ui/Link.astro';
3
5
  import Image from '@components/ui/Image.astro';
4
6
  import imgAction from '@shared/img/veeva/veeva-action.png';
5
7
  import imgHighlighter from '@shared/img/veeva/veeva-highlighter.png';
@@ -15,41 +17,55 @@ import imgDesktopNavigation from '@shared/img/veeva/veeva-desktop-navigation.png
15
17
  import './VeevaControls.scss';
16
18
 
17
19
  interface Props {
20
+ prevNext?: PageHref[] | true;
18
21
  highlighter?: boolean | 'true' | 'false';
19
22
  history?: boolean | 'true' | 'false';
20
23
  reactions?: boolean | 'true' | 'false';
21
24
  navigation?: boolean | 'true' | 'false';
22
25
  }
23
26
 
24
- function shouldInclude(value: boolean | string | undefined) {
27
+ const prevNext: PageHref[] = Astro.props.prevNext === true ? PageUrls.filter(u => u.href !== undefined).map(u => u.href) as PageHref[] : (Astro.props.prevNext ?? []) as PageHref[];
28
+
29
+ function parseBool(value: boolean | string | undefined) {
25
30
  return typeof value == 'string' ? value.trim().toLowerCase() !== 'false' : value !== false;
26
31
  }
27
- const highlighter = shouldInclude(Astro.props.highlighter);
28
- const history = shouldInclude(Astro.props.history);
29
- const reactions = shouldInclude(Astro.props.reactions);
30
- const navigation = shouldInclude(Astro.props.navigation);
32
+
33
+ const highlighter = parseBool(Astro.props.highlighter);
34
+ const history = parseBool(Astro.props.history);
35
+ const reactions = parseBool(Astro.props.reactions);
36
+ const navigation = parseBool(Astro.props.navigation);
37
+
38
+ const pageIndex = prevNext.findIndex(p => p === Astro.url.pathname);
39
+ const previousPage = pageIndex > 0 ? prevNext[pageIndex-1]: undefined;
40
+ const nextPage = pageIndex !== -1 ? prevNext[pageIndex+1] : undefined;
31
41
  ---
32
- {(() => {
33
- if (BUILD_TARGET === 'web' && VEEVA_CONTROLS) {
34
- return (<>
35
- <div id="veeva-action" class="veeva-control"><Image src={imgAction} /></div>
36
- { highlighter &&
37
- <div id="veeva-highlighter" class="veeva-control"><Image src={imgHighlighter} /></div>
38
- }
39
- { history &&
40
- <div id="veeva-history-back" class:list={['veeva-control', highlighter ? 'veeva-has-highlighter' : '']}><Image src={imgHistoryBack} /></div>
41
- <div id="veeva-history-forward" class:list={['veeva-control', highlighter ? 'veeva-has-highlighter' : '']}><Image src={imgHistoryForward} /></div>
42
- }
43
- { reactions &&
44
- <div id="veeva-reactions" class="veeva-control"><Image src={imgReactions} /></div>
42
+ { BUILD_TARGET === 'web' && VEEVA_CONTROLS && <>
43
+ <div id="veeva-action" class="veeva-control"><Image src={imgAction} /></div>
44
+ { highlighter &&
45
+ <div id="veeva-highlighter" class="veeva-control"><Image src={imgHighlighter} /></div>
46
+ }
47
+ { history &&
48
+ <div id="veeva-history-back" class:list={['veeva-control', highlighter ? 'veeva-has-highlighter' : '']}>
49
+ {previousPage ?
50
+ <Link href={previousPage}><Image src={imgHistoryBack} /></Link> :
51
+ <Image src={imgHistoryBack} />
45
52
  }
46
- { navigation &&
47
- <div id="veeva-navigation" class="veeva-control"><Image src={imgNavigation} /></div>
53
+ </div>
54
+ <div id="veeva-history-forward" class:list={['veeva-control', highlighter ? 'veeva-has-highlighter' : '']}>
55
+ {nextPage ?
56
+ <Link href={nextPage}><Image src={imgHistoryForward} /></Link> :
57
+ <Image src={imgHistoryForward} />
48
58
  }
49
- <div id="veeva-desktop-action" class="veeva-desktop-control"><Image src={imgDesktopAction} /></div>
50
- <div id="veeva-desktop-previous" class="veeva-desktop-control"><Image src={imgDesktopPrevious} /></div>
51
- <div id="veeva-desktop-next" class="veeva-desktop-control"><Image src={imgDesktopNext} /></div>
52
- <div id="veeva-desktop-navigation" class="veeva-desktop-control"><Image src={imgDesktopNavigation} /></div>
53
- </>);
59
+ </div>
60
+ }
61
+ { reactions &&
62
+ <div id="veeva-reactions" class="veeva-control"><Image src={imgReactions} /></div>
63
+ }
64
+ { navigation &&
65
+ <div id="veeva-navigation" class="veeva-control"><Image src={imgNavigation} /></div>
54
66
  }
55
- })()}
67
+ <div id="veeva-desktop-action" class="veeva-desktop-control"><Image src={imgDesktopAction} /></div>
68
+ <div id="veeva-desktop-previous" class="veeva-desktop-control"><Image src={imgDesktopPrevious} /></div>
69
+ <div id="veeva-desktop-next" class="veeva-desktop-control"><Image src={imgDesktopNext} /></div>
70
+ <div id="veeva-desktop-navigation" class="veeva-desktop-control"><Image src={imgDesktopNavigation} /></div>
71
+ </>}
@@ -1,7 +1,7 @@
1
1
  import { BUILD_TARGET, VEEVA_ENV, WEB_SCALING } from 'astro:env/client';
2
2
  import * as IVA from '@inizioevoke/veeva-iva';
3
3
  import { logError, logDebug } from '@components/ui/IvaConsole/IvaConsole';
4
- // import swipeNav, { type SwipeNavLink, type SwipeType } from './swipe-nav';
4
+ // import swipeNav, { type SwipeNavLink } from './swipe-nav';
5
5
  // import { PageUrls } from '@/data/pages';
6
6
 
7
7
  IVA.init({
@@ -24,7 +24,7 @@ IVA.init({
24
24
  * If using the custom swipe, figure out which page to go to when swiping.
25
25
  * This is only example. Create something different for your IVA.
26
26
  */
27
- // swipeNav({
27
+ // swipeNav({
28
28
  // threshold: '1/4',
29
29
  // handler: (type) => {
30
30
  // let link: SwipeNavLink | undefined = undefined;
@@ -32,10 +32,10 @@ IVA.init({
32
32
  // if (i !== -1) {
33
33
  // if (type === 'previous') {
34
34
  // if (i > 0) {
35
- // link = PageUrls[i-1];
35
+ // link = PageUrls[i - 1];
36
36
  // }
37
37
  // } else if (i < PageUrls.length - 1) {
38
- // link = PageUrls[i+1];
38
+ // link = PageUrls[i + 1];
39
39
  // }
40
40
  // }
41
41
  // return link;