Skip to content

Commit

Permalink
🐛 (phone) Fix phone number parsing and default country
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Feb 21, 2023
1 parent d8194ff commit 4efe2c4
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ export const parseReactBotProps = ({ typebot, apiHost }: BotProps) => {
return `${typebotLine} ${apiHostLine}`
}

export const typebotImportUrl = `https://cdn.jsdelivr.net/npm/@typebot.io/[email protected].10/dist/web.js`
export const typebotImportUrl = `https://cdn.jsdelivr.net/npm/@typebot.io/[email protected].13/dist/web.js`
2 changes: 1 addition & 1 deletion packages/js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@typebot.io/js",
"version": "0.0.12",
"version": "0.0.13",
"description": "Javascript library to display typebots on your website",
"type": "module",
"main": "dist/index.js",
Expand Down
5 changes: 5 additions & 0 deletions packages/js/src/assets/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,8 @@ textarea {
background-color: var(--typebot-host-bubble-bg-color);
color: var(--typebot-host-bubble-color);
}

.typebot-country-select {
color: var(--typebot-input-color);
background-color: var(--typebot-input-bg-color);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { InputSubmitContent } from '@/types'
import { isMobile } from '@/utils/isMobileSignal'
import type { PhoneNumberInputBlock } from 'models'
import { createSignal, For, onMount } from 'solid-js'
import { isEmpty } from 'utils'
import { phoneCountries } from 'utils/phoneCountries'

type PhoneInputProps = {
Expand All @@ -14,7 +15,12 @@ type PhoneInputProps = {
}

export const PhoneInput = (props: PhoneInputProps) => {
const [selectedCountryCode, setSelectedCountryCode] = createSignal('INT')
// eslint-disable-next-line solid/reactivity
const defaultCountryCode = props.block.options.defaultCountryCode

const [selectedCountryCode, setSelectedCountryCode] = createSignal(
isEmpty(defaultCountryCode) ? 'INT' : defaultCountryCode
)
const [inputValue, setInputValue] = createSignal(props.defaultValue ?? '')
let inputRef: HTMLInputElement | undefined

Expand All @@ -32,7 +38,15 @@ export const PhoneInput = (props: PhoneInputProps) => {
inputValue() !== '' && inputRef?.reportValidity()

const submit = () => {
if (checkIfInputIsValid()) props.onSubmit({ value: inputValue() })
const selectedCountryDialCode = phoneCountries.find(
(country) => country.code === selectedCountryCode()
)?.dial_code
if (checkIfInputIsValid())
props.onSubmit({
value: inputValue().startsWith('+')
? inputValue()
: `${selectedCountryDialCode ?? ''}${inputValue()}`,
})
}

const submitWhenEnter = (e: KeyboardEvent) => {
Expand Down Expand Up @@ -62,7 +76,7 @@ export const PhoneInput = (props: PhoneInputProps) => {
<div class="flex flex-1">
<select
onChange={selectNewCountryCode}
class="w-12 pl-2 focus:outline-none"
class="w-12 pl-2 focus:outline-none rounded-lg typebot-country-select"
>
<option selected>
{
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@typebot.io/react",
"version": "0.0.12",
"version": "0.0.13",
"description": "React library to display typebots on your website",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down

4 comments on commit 4efe2c4

@vercel
Copy link

@vercel vercel bot commented on 4efe2c4 Feb 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

builder-v2-typebot-io.vercel.app
app.typebot.io
builder-v2-git-main-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 4efe2c4 Feb 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

docs – ./apps/docs

docs-git-main-typebot-io.vercel.app
docs.typebot.io
docs-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 4efe2c4 Feb 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

viewer-v2 – ./apps/viewer

ns8.vn
1stop.au
yobot.me
klujo.com
247987.com
8jours.top
aginap.com
bee.cr8.ai
bot.aws.bj
bot.bbc.bj
cat.cr8.ai
finplex.be
nepkit.com
pig.cr8.ai
sat.cr8.ai
bot.aipr.kr
bot.joof.it
bull.cr8.ai
docs.cr8.ai
minipost.uk
mole.cr8.ai
team.cr8.ai
wolf.cr8.ai
cinecorn.com
kusamint.com
rhino.cr8.ai
sheep.cr8.ai
snake.cr8.ai
svhm.mprs.in
tiger.cr8.ai
video.cr8.ai
yoda.riku.ai
zebra.cr8.ai
bergamo.store
bot.krdfy.com
bot.tvbeat.it
cgcassets.com
cnvhub.com.br
filmylogy.com
goldorayo.com
rabbit.cr8.ai
signup.cr8.ai
turkey.cr8.ai
vhpage.cr8.ai
vitamyway.com
am.nigerias.io
myrentalhost.com
stan.vselise.com
start.taxtree.io
typebot.aloe.bot
voicehelp.cr8.ai
zap.fundviser.in
app.chatforms.net
bot.hostnation.de
bot.maitempah.com
bot.phuonghub.com
bot.reviewzer.com
bot.rihabilita.it
cares.urlabout.me
chat.gaswadern.de
fmm.wpwakanda.com
gentleman-shop.fr
k1.kandabrand.com
lb.ticketfute.com
ov1.wpwakanda.com
ov2.wpwakanda.com
ov3.wpwakanda.com
support.triplo.ai
viewer.typebot.io
1988.bouclidom.com
andreimayer.com.br
bot.danyservice.it
bot.iconicbrows.it
bot.megafox.com.br
bot.neferlopez.com
bots.robomotion.io
cadu.uninta.edu.br
dicanatural.online
digitalhelp.com.au
goalsettingbot.com
pant.maxbot.com.br
positivobra.com.br
survey.digienge.io
this-is-a-test.com
zap.techadviser.in
bot.boston-voip.com
bot.cabinpromos.com
bot.digitalbled.com
bot.dsignagency.com
bot.eventhub.com.au
bot.jepierre.com.br
bot.ltmidias.com.br
bot.hotelplayarimini.it
bot.upgradesolutions.eu
bots.baptiste-arnaud.fr
help.comebackreward.com
link.venturasuceder.com
mainmenu.diddancing.com
manualhandlingcourse.ie
register.kandabrand.com

@vercel
Copy link

@vercel vercel bot commented on 4efe2c4 Feb 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.