@playpilot/tpi 8.37.1 → 8.38.0

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@playpilot/tpi",
3
- "version": "8.37.1",
3
+ "version": "8.38.0",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
@@ -17,7 +17,7 @@ export function getLinkInjectionElements(parentElement: HTMLElement, excludeElem
17
17
  if (validElements.includes(element)) continue
18
18
  if (excludeElementsSelector && element.matches(excludeElementsSelector)) continue
19
19
 
20
- if (/^(A|BUTTON|SCRIPT|NOSCRIPT|STYLE|IFRAME|FIGCAPTION|TIME|LABEL|BLOCKQUOTE|H1)$/.test(element.tagName)) continue
20
+ if (/^(A|BUTTON|SCRIPT|NOSCRIPT|STYLE|IFRAME|FIGCAPTION|TIME|LABEL|BLOCKQUOTE|H1|H2|H3|H4|H5)$/.test(element.tagName)) continue
21
21
 
22
22
  // Ignore elements that are visibly hidden as they are likely only for screen readers.
23
23
  // These elements can be hidden via display: none or via a tiny width or perhaps even a clip path.
@@ -48,6 +48,7 @@
48
48
  label: t('IMDb'),
49
49
  param: 'imdb_score',
50
50
  range: [0, 10] as [number, number],
51
+ step: 0.1,
51
52
  }, {
52
53
  label: t('Year'),
53
54
  param: 'year',
@@ -18,6 +18,7 @@
18
18
  data?: ExploreFilterItemArrayValue[] | null
19
19
  fetchData?: (() => Promise<ExploreFilterItemArrayValue[]>) | null
20
20
  range?: [number, number] | null
21
+ step?: number
21
22
  valueAppend?: string
22
23
  }
23
24
 
@@ -29,6 +30,7 @@
29
30
  data = null,
30
31
  fetchData = null,
31
32
  range = null,
33
+ step = 1,
32
34
  valueAppend = '',
33
35
  }: Props = $props()
34
36
 
@@ -87,7 +89,7 @@
87
89
  <TogglesWithSearch options={data} {selected} onchange={(selected) => setFilter(selected, 'array')} />
88
90
  {:else if range}
89
91
  {@const value = filter[param]?.value as unknown as [number, number]}
90
- <Range {range} {value} label={label} {valueAppend} onchange={(value) => setFilter(value, 'range')} />
92
+ <Range {range} {value} {step} label={label} {valueAppend} onchange={(value) => setFilter(value, 'range')} />
91
93
  {/if}
92
94
  </div>
93
95
  {/snippet}
@@ -1,6 +1,7 @@
1
1
  <script lang="ts">
2
2
  interface Props {
3
3
  range?: [number, number]
4
+ step?: number
4
5
  value?: [number, number]
5
6
  label?: string
6
7
  valueAppend?: string
@@ -10,6 +11,7 @@
10
11
 
11
12
  const {
12
13
  range = [0, 100],
14
+ step = 1,
13
15
  value = range,
14
16
  label = '',
15
17
  valueAppend = '',
@@ -67,6 +69,7 @@
67
69
  bind:value={lower}
68
70
  min={range[0]}
69
71
  max={range[1]}
72
+ {step}
70
73
  id="lower"
71
74
  class:active />
72
75
  <input
@@ -77,6 +80,7 @@
77
80
  bind:value={upper}
78
81
  min={range[0]}
79
82
  max={range[1]}
83
+ {step}
80
84
  id="upper"
81
85
  class:active />
82
86
 
@@ -49,10 +49,12 @@
49
49
  </script>
50
50
 
51
51
  <div class="header" class:small>
52
- <ParticipantImage {participant} />
52
+ {#if participant.image}
53
+ <ParticipantImage {participant} />
54
+ {/if}
53
55
 
54
56
  <div>
55
- <div class="heading" use:heading={2} id="heading">{name}</div>
57
+ <div class="heading" class:no-image={!participant.image} use:heading={2} id="heading">{name}</div>
56
58
 
57
59
  {#if description}
58
60
  <p class="description" class:expanded={descriptionExpanded}>
@@ -126,6 +128,10 @@
126
128
  font-size: theme(detail-title-small-font-size, margin(1.25));
127
129
  }
128
130
 
131
+ &.no-image {
132
+ margin-top: margin(0.5);
133
+ }
134
+
129
135
  .small & {
130
136
  font-size: 1.25em;
131
137
  }
@@ -24,7 +24,7 @@
24
24
  }
25
25
  </script>
26
26
 
27
- <div class="image">
27
+ <div class="image" data-testid="participant-image">
28
28
  {#if participant?.image}
29
29
  <img loading="lazy" src={participant.image} alt="" />
30
30
 
@@ -79,9 +79,11 @@ describe('injectionElements.ts', () => {
79
79
  expect(getLinkInjectionElements(parent)[1].tagName).toBe('OL')
80
80
  })
81
81
 
82
- it('Should ignore links, buttons, script tags, style tags, iframes, h1, and more', () => {
82
+ it('Should ignore links, buttons, script tags, style tags, iframes, headings, and more', () => {
83
83
  document.body.innerHTML = `<section>
84
84
  <h1>Some header</h1>
85
+ <h2>Some header</h2>
86
+ <h3>Some header</h3>
85
87
 
86
88
  <a>I am a link</a>
87
89
  <button>And I am a button</button>
@@ -97,7 +99,7 @@ describe('injectionElements.ts', () => {
97
99
 
98
100
  <div>
99
101
  <a>I am another link</a>
100
- <h4>Some smaller header</h4>
102
+ <span>Some smaller header</span>
101
103
  <p>And finally, some text</p>
102
104
  </div>
103
105
  </section>`
@@ -152,9 +152,9 @@ describe('ManualInjection.svelte', () => {
152
152
  vi.mocked(searchTitles).mockResolvedValueOnce([title])
153
153
  vi.mocked(getIndexOfSelection).mockReturnValueOnce({ start: 0, end: 0 })
154
154
 
155
- document.body.innerHTML = '<main><h2>Some title</h2> <p>Some paragraph</p></main>'
155
+ document.body.innerHTML = '<main><span>Some title</span> <p>Some paragraph</p></main>'
156
156
 
157
- const container = document.querySelector('h2')
157
+ const container = document.querySelector('span')
158
158
 
159
159
  // @ts-ignore
160
160
  window.getSelection = vi.fn(() => ({
@@ -23,6 +23,13 @@ describe('Range.svelte', () => {
23
23
  expect(getByText(90)).toBeTruthy()
24
24
  })
25
25
 
26
+ it('Should use given step', () => {
27
+ const { container } = render(Range, { range: [0, 100], step: 0.1 })
28
+
29
+ expect(/** @type HTMLInputElement */ (container.querySelectorAll('input')[0]).step).toBe('0.1')
30
+ expect(/** @type HTMLInputElement */ (container.querySelectorAll('input')[1]).step).toBe('0.1')
31
+ })
32
+
26
33
  it('Should add append text with the given value in the label', () => {
27
34
  const { getByText } = render(Range, {
28
35
  range: [0, 100],
@@ -1,4 +1,4 @@
1
- import { fireEvent, render, waitFor } from '@testing-library/svelte'
1
+ import { fireEvent, getByTestId, render, waitFor } from '@testing-library/svelte'
2
2
  import { describe, expect, it, vi, beforeEach } from 'vitest'
3
3
 
4
4
  import Participant from '../../../../routes/components/Participants/Participant.svelte'
@@ -124,18 +124,19 @@ describe('Participant.svelte', () => {
124
124
  it('Should render image if given', async () => {
125
125
  const participantWithImage = { ...participants[0], image: 'some-image.jpg' }
126
126
 
127
- const { getByRole } = render(Participant, { participant: participantWithImage })
127
+ const { getByTestId } = render(Participant, { participant: participantWithImage })
128
128
 
129
129
  await waitFor(() => {
130
- expect(getByRole('presentation')).toBeTruthy()
130
+ expect(getByTestId('participant-image')).toBeTruthy()
131
131
  })
132
132
  })
133
133
 
134
134
  it('Should not render image if not given', async () => {
135
- const { queryByRole } = render(Participant, { participant: participants[0] })
135
+ const { queryByTestId } = render(Participant, { participant: participants[0] })
136
136
 
137
137
  await waitFor(() => {
138
- expect(queryByRole('presentation')).not.toBeTruthy()
138
+ expect(queryByTestId('participant-image')).not.toBeTruthy()
139
+ expect(queryByTestId('participant-image')).not.toBeTruthy()
139
140
  })
140
141
  })
141
142