Skip to content

Commit

Permalink
v0.9.2 -> v0.9.3 (#229)
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-dassana authored Feb 24, 2021
1 parent d279806 commit 1c948b3
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dassana-io/web-components",
"version": "0.9.2",
"version": "0.9.3",
"publishConfig": {
"registry": "https://npm.pkg.github.com/dassana-io"
},
Expand Down
5 changes: 4 additions & 1 deletion src/components/Form/FormTimezone/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ const FormTimezone: FC<FormTimezoneProps> = ({
loading={loading}
onChange={value => {
onChange(value)
triggerSubmit && triggerOnSubmit(value)
triggerSubmit &&
triggerOnSubmit(
(value as unknown) as ChangeEvent
)
}}
value={value}
{...rest}
Expand Down
3 changes: 2 additions & 1 deletion src/components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ const Modal: FC<ModalProps> = ({
const onModalClose = () => (onClose ? onClose() : unsetModal())

useShortcut({
callback: disableKeyboardShortcut ? noop : onModalClose,
callback:
disableKeyboardShortcut || hideCloseButton ? noop : onModalClose,
key: 'Escape',
keyEvent: 'keydown'
})
Expand Down
18 changes: 15 additions & 3 deletions src/components/Timezone/index.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,38 @@
import isNull from 'lodash/isNull'
import { getTimezoneDefaultValue, mappedTimezoneOpts } from './utils'
import React, { FC } from 'react'
import React, { ChangeEventHandler, FC, useEffect } from 'react'
import { Select, SelectProps } from 'components/Select'

export interface TimezoneProps
extends Omit<
SelectProps,
'defaultValue' | 'options' | 'optionsConfig' | 'showSearch' | 'value'
| 'defaultValue'
| 'options'
| 'onChange'
| 'optionsConfig'
| 'showSearch'
| 'value'
> {
onChange?: (value?: string) => void
format?: string
// null is so an empty defaultValue can be passed through react-hook-form without console.warnings. If a value is null, the component will guess the timezone
value?: string | null
}

export const Timezone: FC<TimezoneProps> = ({
onChange,
value,
...rest
}: TimezoneProps) => {
// if value is null and we're guessing the user's tz, then call onChange with the new value
useEffect(() => {
if (isNull(value) && onChange) onChange(getTimezoneDefaultValue(value))
}, [onChange, value])

return (
<Select
{...rest}
defaultValue={getTimezoneDefaultValue(value)}
onChange={(onChange as unknown) as ChangeEventHandler}
options={mappedTimezoneOpts()}
showSearch
value={isNull(value) ? getTimezoneDefaultValue(value) : value}
Expand Down
4 changes: 1 addition & 3 deletions src/components/Timezone/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ interface GetTimezoneValue {
(value: TimezoneProps['value']): string | undefined
}

export const getTimezoneDefaultValue: GetTimezoneValue = (
value: TimezoneProps['value']
) => {
export const getTimezoneDefaultValue: GetTimezoneValue = value => {
const guessedUserTz = guessUserTimezone()

// if a value is provided and it exists, return the value
Expand Down

0 comments on commit 1c948b3

Please sign in to comment.