Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
"@types/dotenv": "^8.2.3",
"@types/jest": "^29.5.12",
"@types/node": "^22.5.0",
"@types/react-dom": "^18.0.10",
"@types/sinon": "^17.0.1",
"@types/web": "^0.0.222",
"babel-jest": "^29.7.0",
Expand Down
38 changes: 19 additions & 19 deletions packages/browser/src/extensions/surveys.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as Preact from 'preact'
import { type JSX, type RefObject, render, Fragment } from 'preact'
import { useContext, useEffect, useMemo, useRef, useState } from 'preact/hooks'
import { PostHog } from '../posthog-core'
import {
Expand Down Expand Up @@ -185,7 +185,7 @@ const SURVEY_NEXT_TO_TRIGGER_PARAMS = {
TRIGGER_SPACING: 12,
} as const

function getNextToTriggerPosition(target: HTMLElement, surveyWidth: number): React.CSSProperties | null {
function getNextToTriggerPosition(target: HTMLElement, surveyWidth: number): JSX.CSSProperties | null {
try {
const buttonRect = target.getBoundingClientRect()
const viewportHeight = window.innerHeight
Expand All @@ -212,7 +212,7 @@ function getNextToTriggerPosition(target: HTMLElement, surveyWidth: number): Rea
right: 'auto',
bottom: showAbove ? `${viewportHeight - buttonRect.top + spacing}px` : 'auto',
zIndex: defaultSurveyAppearance.zIndex,
} satisfies React.CSSProperties
} satisfies JSX.CSSProperties
} catch (error) {
logger.warn('Failed to calculate trigger position:', error)
return null
Expand Down Expand Up @@ -270,7 +270,7 @@ export class SurveyManager {
const delaySeconds = survey.appearance?.surveyPopupDelaySeconds || 0
const { shadow } = retrieveSurveyShadow(survey, this._posthog)
if (delaySeconds <= 0) {
return Preact.render(
return render(
<SurveyPopup
posthog={this._posthog}
survey={survey}
Expand All @@ -287,7 +287,7 @@ export class SurveyManager {
return this._removeSurveyFromFocus(survey)
}
// rendering with surveyPopupDelaySeconds = 0 because we're already handling the timeout here
Preact.render(
render(
<SurveyPopup
posthog={this._posthog}
survey={{ ...survey, appearance: { ...survey.appearance, surveyPopupDelaySeconds: 0 } }}
Expand All @@ -308,7 +308,7 @@ export class SurveyManager {
return
}

Preact.render(<FeedbackWidget posthog={this._posthog} survey={survey} key={survey.id} />, shadow)
render(<FeedbackWidget posthog={this._posthog} survey={survey} key={survey.id} />, shadow)
}

private _removeWidgetSelectorListener = (survey: Pick<Survey, 'id' | 'type' | 'appearance'>): void => {
Expand Down Expand Up @@ -406,7 +406,7 @@ export class SurveyManager {

public renderPopover = (survey: Survey): void => {
const { shadow } = retrieveSurveyShadow(survey, this._posthog)
Preact.render(
render(
<SurveyPopup posthog={this._posthog} survey={survey} removeSurveyFromFocus={this._removeSurveyFromFocus} />,
shadow
)
Expand All @@ -417,7 +417,7 @@ export class SurveyManager {
this._handleUrlPrefill(survey)
}

Preact.render(
render(
<SurveyPopup
posthog={this._posthog}
survey={survey}
Expand Down Expand Up @@ -669,7 +669,7 @@ export class SurveyManager {
try {
const shadowContainer = document.querySelector(getSurveyContainerClass(survey, true))
if (shadowContainer?.shadowRoot) {
Preact.render(null, shadowContainer.shadowRoot)
render(null, shadowContainer.shadowRoot)
}
shadowContainer?.remove()
} catch (error) {
Expand Down Expand Up @@ -703,7 +703,7 @@ export class SurveyManager {
}
}

const DEFAULT_PREVIEW_POSITION_STYLES: React.CSSProperties = {
const DEFAULT_PREVIEW_POSITION_STYLES: JSX.CSSProperties = {
position: 'relative',
left: 'unset',
right: 'unset',
Expand All @@ -726,7 +726,7 @@ export const renderSurveysPreview = ({
forceDisableHtml?: boolean
onPreviewSubmit?: (res: string | string[] | number | null) => void
posthog?: PostHog
positionStyles?: React.CSSProperties
positionStyles?: JSX.CSSProperties
}) => {
const currentStyle = parentElement.querySelector('style[data-ph-survey-style]')
if (currentStyle) {
Expand All @@ -737,7 +737,7 @@ export const renderSurveysPreview = ({
parentElement.appendChild(stylesheet)
addSurveyCSSVariablesToElement(parentElement, survey.type, survey.appearance)
}
Preact.render(
render(
<SurveyPopup
survey={survey}
forceDisableHtml={forceDisableHtml}
Expand Down Expand Up @@ -765,7 +765,7 @@ export const renderFeedbackWidgetPreview = ({
addSurveyCSSVariablesToElement(root, survey.type, survey.appearance)
}

Preact.render(<FeedbackWidget forceDisableHtml={forceDisableHtml} survey={survey} readOnly={true} />, root)
render(<FeedbackWidget forceDisableHtml={forceDisableHtml} survey={survey} readOnly={true} />, root)
}

// This is the main exported function
Expand Down Expand Up @@ -904,7 +904,7 @@ export function usePopupVisibility(
isPreviewMode: boolean,
removeSurveyFromFocus: (survey: SurveyWithTypeAndAppearance) => void,
isPopup: boolean,
surveyContainerRef?: React.RefObject<HTMLDivElement>
surveyContainerRef?: RefObject<HTMLDivElement>
) {
const [isPopupVisible, setIsPopupVisible] = useState(
isPreviewMode || millisecondDelay === 0 || survey.type === SurveyType.ExternalSurvey
Expand Down Expand Up @@ -1019,7 +1019,7 @@ interface SurveyPopupProps {
survey: Survey
forceDisableHtml?: boolean
posthog?: PostHog
style?: React.CSSProperties
style?: JSX.CSSProperties
previewPageIndex?: number | undefined
removeSurveyFromFocus?: (survey: SurveyWithTypeAndAppearance) => void
isPopup?: boolean
Expand Down Expand Up @@ -1063,7 +1063,7 @@ function getPopoverPosition(
}
}

function getTabPositionStyles(position: SurveyTabPosition = SurveyTabPosition.Right): React.CSSProperties {
function getTabPositionStyles(position: SurveyTabPosition = SurveyTabPosition.Right): JSX.CSSProperties {
switch (position) {
case SurveyTabPosition.Top:
return { top: '0', left: '50%', transform: 'translateX(-50%)' }
Expand Down Expand Up @@ -1293,7 +1293,7 @@ export function FeedbackWidget({
}): JSX.Element | null {
const [isFeedbackButtonVisible, setIsFeedbackButtonVisible] = useState(true)
const [showSurvey, setShowSurvey] = useState(false)
const [styleOverrides, setStyleOverrides] = useState<React.CSSProperties>({})
const [styleOverrides, setStyleOverrides] = useState<JSX.CSSProperties>({})

const toggleSurvey = () => {
setShowSurvey(!showSurvey)
Expand Down Expand Up @@ -1360,7 +1360,7 @@ export function FeedbackWidget({
}

return (
<Preact.Fragment>
<Fragment>
{survey.appearance?.widgetType === 'tab' && (
<button
className={`ph-survey-widget-tab ${survey.appearance?.tabPosition === SurveyTabPosition.Top ? 'widget-tab-top' : ''}`}
Expand All @@ -1381,7 +1381,7 @@ export function FeedbackWidget({
onCloseConfirmationMessage={resetShowSurvey}
/>
)}
</Preact.Fragment>
</Fragment>
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Fragment } from 'preact'
import { Fragment, type JSX } from 'preact'
import { useEffect, useMemo, useRef, useState } from 'preact/hooks'
import {
BasicSurveyQuestion,
Expand Down Expand Up @@ -368,7 +368,7 @@ export function MultipleChoiceQuestion({
}
}

const handleOpenEndedInputChange = (e: React.FormEvent<HTMLInputElement>) => {
const handleOpenEndedInputChange = (e: JSX.TargetedEvent<HTMLInputElement>) => {
e.stopPropagation()
const newValue = e.currentTarget.value

Expand All @@ -382,7 +382,7 @@ export function MultipleChoiceQuestion({
}
}

const handleOpenEndedKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
const handleOpenEndedKeyDown = (e: JSX.TargetedKeyboardEvent<HTMLInputElement>) => {
e.stopPropagation()

// Handle Enter key to submit form if valid
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { VNode, cloneElement, createContext } from 'preact'
import { VNode, cloneElement, createContext, type JSX } from 'preact'
import { PostHog } from '../../posthog-core'
import {
MultipleSurveyQuestion,
Expand Down Expand Up @@ -585,7 +585,7 @@ interface RenderProps {
component: VNode<{ className: string }>
children: string
renderAsHtml?: boolean
style?: React.CSSProperties
style?: JSX.CSSProperties
}

export const renderChildrenAsTextOrHtml = ({ component, children, renderAsHtml, style }: RenderProps) => {
Expand Down
5 changes: 2 additions & 3 deletions packages/browser/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@
"resolveJsonModule": true,
"downlevelIteration": true,
"declaration": true,
"jsx": "preserve",
"jsxFactory": "h",
"jsxFragmentFactory": "Fragment"
"jsx": "react-jsx",
"jsxImportSource": "preact"
},
"include": ["./src/**/*.ts*"],
"exclude": ["./src/__tests__/**/*.ts*"]
Expand Down
10 changes: 0 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading