Skip to content

Commit

Permalink
Merge pull request #755 from opengovsg/release-v1.24.0
Browse files Browse the repository at this point in the history
build: release v1.24.0
  • Loading branch information
karrui authored Sep 16, 2024
2 parents b43b610 + 06e23c9 commit 2dfbe9c
Show file tree
Hide file tree
Showing 16 changed files with 90 additions and 16 deletions.
9 changes: 9 additions & 0 deletions react/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,21 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [v1.24.0](https://github.com/opengovsg/design-system/compare/v1.23.0...v1.24.0)

- feat: fix Input prefill style regression, add `isPrefilled` prop to Datepicker and Select [`#754`](https://github.com/opengovsg/design-system/pull/754)
- chore: merge v1.23.0 back to main [`#747`](https://github.com/opengovsg/design-system/pull/747)
- build: release v1.23.0 [`#746`](https://github.com/opengovsg/design-system/pull/746)

#### [v1.23.0](https://github.com/opengovsg/design-system/compare/v1.22.0...v1.23.0)

> 20 August 2024
- fix!(DatePicker): add `renderInputElement` prop [`#745`](https://github.com/opengovsg/design-system/pull/745)
- chore: enable dual publish to GitHub [`#740`](https://github.com/opengovsg/design-system/pull/740)
- chore: merge latest v1.22.0 back to main [`#732`](https://github.com/opengovsg/design-system/pull/732)
- build: release v1.22.0 [`#731`](https://github.com/opengovsg/design-system/pull/731)
- build: release v1.23.0 [`224b03c`](https://github.com/opengovsg/design-system/commit/224b03c263672eccb9a409309b4c549cb718b6f2)

#### [v1.22.0](https://github.com/opengovsg/design-system/compare/v1.21.0...v1.22.0)

Expand Down
4 changes: 2 additions & 2 deletions react/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 react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opengovsg/design-system-react",
"version": "1.23.0",
"version": "1.24.0",
"description": "React components",
"homepage": "https://github.com/opengovsg/design-system/react#readme",
"bugs": "https://github.com/opengovsg/design-system/issues",
Expand Down
5 changes: 5 additions & 0 deletions react/src/DatePicker/DatePicker.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ FixedHeightCalendarPopover.args = {
isCalendarFixedHeight: true,
}

export const Prefilled = Template.bind({})
Prefilled.args = {
isPrefilled: true,
}

export const SizeSmall = Template.bind({})
SizeSmall.args = {
size: 'sm',
Expand Down
2 changes: 2 additions & 0 deletions react/src/DatePicker/DatePickerContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ const useProvideDatePicker = ({
isReadOnly: isReadOnlyProp,
isRequired: isRequiredProp,
isInvalid: isInvalidProp,
isPrefilled,
locale,
allowManualInput = true,
allowInvalidDates = true,
Expand Down Expand Up @@ -260,6 +261,7 @@ const useProvideDatePicker = ({
const styles = useMultiStyleConfig('DatePicker', {
size,
colorScheme,
isPrefilled,
})

const placeholder = useMemo(
Expand Down
3 changes: 3 additions & 0 deletions react/src/DatePicker/components/DatePickerInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const DatePickerInput = forwardRef<{}, 'input'>((_props, ref) => {
size,
inputPattern,
innerRef,
styles,
} = useDatePicker()

const mergedInputRef = useMergeRefs(inputRef, innerRef, ref)
Expand Down Expand Up @@ -71,13 +72,15 @@ export const DatePickerInput = forwardRef<{}, 'input'>((_props, ref) => {
onBlur={handleInputBlur}
onClick={handleInputClick}
isReadOnly={fcProps.isReadOnly || !allowManualInput}
sx={styles.field}
/>
) : (
<Input
size={size}
inputMode="numeric"
placeholder={placeholder}
pattern={inputPattern}
sx={styles.field}
/>
)}
<InputRightAddon p={0} border="none">
Expand Down
4 changes: 4 additions & 0 deletions react/src/DatePicker/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ export interface DatePickerBaseProps
* @defaultValue `true`
*/
allowInvalidDates?: boolean
/**
* Whether the input is in a prefilled state.
*/
isPrefilled?: boolean
/**
* Whether the calendar will close once a date is selected.
* @defaultValue `true`
Expand Down
6 changes: 6 additions & 0 deletions react/src/DateRangePicker/DateRangePicker.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ DatePickerDisabled.args = {
defaultValue: [new Date('2001-01-01'), new Date('2002-01-03')],
}

export const Prefilled = Template.bind({})
Prefilled.args = {
isPrefilled: true,
defaultValue: [new Date('2001-01-01'), new Date('2002-01-03')],
}

export const Mobile = Template.bind({})
Mobile.parameters = getMobileViewParameters()

Expand Down
2 changes: 2 additions & 0 deletions react/src/DateRangePicker/DateRangePickerContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ const useProvideDateRangePicker = ({
isReadOnly: isReadOnlyProp,
isRequired: isRequiredProp,
isInvalid: isInvalidProp,
isPrefilled,
locale,
allowManualInput = true,
allowInvalidDates = true,
Expand Down Expand Up @@ -333,6 +334,7 @@ const useProvideDateRangePicker = ({
const styles = useMultiStyleConfig('DateRangePicker', {
size,
colorScheme,
isPrefilled,
})

const placeholder = useMemo(
Expand Down
8 changes: 7 additions & 1 deletion react/src/Input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ export const Input = forwardRef<InputProps, 'input'>((props, ref) => {

// Return normal input component if not success state.
if (!props.isSuccess) {
return <ChakraInput ref={ref} __css={inputStyles.field} {...inputProps} />
return (
<ChakraInput
ref={ref}
sx={merge({}, inputStyles.field, props.sx)}
{...inputProps}
/>
)
}

return (
Expand Down
6 changes: 6 additions & 0 deletions react/src/MultiSelect/MultiSelect.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ DisabledWithSelection.args = {
values: ['What happens when the label is fairly long', 'Bat'],
}

export const Prefilled = Template.bind({})
Prefilled.args = {
isPrefilled: true,
values: ['What happens when the label is fairly long', 'Bat'],
}

export const WithFixedItemHeight = Template.bind({})
WithFixedItemHeight.args = {
size: 'md',
Expand Down
6 changes: 6 additions & 0 deletions react/src/MultiSelect/MultiSelectProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ export interface MultiSelectProviderProps<
* If `true`, the selected items will take up the full width of the input container. Defaults to `false`.
*/
isStretchLayout?: boolean
/**
* Whether the input is in a prefilled state.
*/
isPrefilled?: boolean
}
export const MultiSelectProvider = ({
items: rawItems,
Expand All @@ -81,6 +85,7 @@ export const MultiSelectProvider = ({
placeholder: placeholderProp,
clearButtonLabel = 'Clear selection',
isSearchable = true,
isPrefilled = false,
defaultIsOpen,
isInvalid: isInvalidProp,
isReadOnly: isReadOnlyProp,
Expand Down Expand Up @@ -297,6 +302,7 @@ export const MultiSelectProvider = ({
size,
isFocused: isFocused || isOpen,
isEmpty: selectedItems.length === 0,
isPrefilled,
})

const virtualListHeight = useMemo(() => {
Expand Down
6 changes: 6 additions & 0 deletions react/src/SingleSelect/SingleSelect.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ Disabled.args = {
isDisabled: true,
}

export const Prefilled = Template.bind({})
Prefilled.args = {
isPrefilled: true,
value: itemToValue(INITIAL_COMBOBOX_ITEMS[2]),
}

export const FormInput: StoryFn<SingleSelectProps> = (args) => {
const [value, setValue] = useState<string>(args.value)

Expand Down
6 changes: 6 additions & 0 deletions react/src/SingleSelect/SingleSelectProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export interface SingleSelectProviderProps<
/** Color scheme of component */
colorScheme?: ThemingProps<'SingleSelect'>['colorScheme']
fixedItemHeight?: number
/**
* Whether the input is in a prefilled state.
*/
isPrefilled?: boolean
}
export const SingleSelectProvider = ({
items: rawItems,
Expand All @@ -51,6 +55,7 @@ export const SingleSelectProvider = ({
clearButtonLabel = 'Clear selection',
isClearable = true,
isSearchable = true,
isPrefilled = false,
initialIsOpen,
isInvalid: isInvalidProp,
isReadOnly: isReadOnlyProp,
Expand Down Expand Up @@ -234,6 +239,7 @@ export const SingleSelectProvider = ({
const styles = useMultiStyleConfig('SingleSelect', {
size,
isClearable,
isPrefilled,
colorScheme,
})

Expand Down
28 changes: 20 additions & 8 deletions react/src/theme/components/DatePicker.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,52 @@
import { createMultiStyleConfigHelpers } from '@chakra-ui/react'
import { anatomy } from '@chakra-ui/theme-tools'
import { memoizedGet as get } from '@chakra-ui/utils'
import omit from 'lodash/omit'

import { Input } from './Input'

export const datepickerAnatomy = anatomy('datepicker').parts(
'header',
'inputButton',
'container',
'calendarButton',
'field',
)
const { defineMultiStyleConfig, definePartsStyle } =
createMultiStyleConfigHelpers(datepickerAnatomy.keys)

const sizes = {
xs: definePartsStyle({
xs: definePartsStyle((props) => ({
field: Input.sizes?.xs(props).field,
inputButton: {
fontSize: '1rem',
},
}),
sm: definePartsStyle({
})),
sm: definePartsStyle((props) => ({
field: Input.sizes?.sm(props).field,
inputButton: {
fontSize: '1.25rem',
},
}),
md: definePartsStyle({
})),
md: definePartsStyle((props) => ({
field: Input.sizes?.md(props).field,
inputButton: {
fontSize: '1.25rem',
},
}),
})),
}

const baseStyle = definePartsStyle(({ theme }) => {
const themeTextStyles = get(theme, 'textStyles')
const baseStyle = definePartsStyle((props) => {
const themeTextStyles = get(props.theme, 'textStyles')
const inputFieldStyle = omit(
Input.variants?.outline(props).field,
'borderRadius',
)
return {
container: {
bg: 'utility.ui',
},
field: inputFieldStyle,
calendarButton: {
_active: {
zIndex: '1',
Expand Down
9 changes: 5 additions & 4 deletions react/src/theme/components/DateRangePicker.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createMultiStyleConfigHelpers } from '@chakra-ui/react'
import omit from 'lodash/omit'

import { DatePicker, datepickerAnatomy } from './DatePicker'
import { Input } from './Input'
Expand Down Expand Up @@ -40,19 +41,19 @@ const sizes = {
xs: definePartsStyle((props) => {
return {
fieldwrapper: Input.sizes?.xs(props).field,
inputButton: DatePicker.sizes?.xs.inputButton,
inputButton: DatePicker.sizes?.xs(props).inputButton,
}
}),
sm: definePartsStyle((props) => {
return {
fieldwrapper: Input.sizes?.sm(props).field,
inputButton: DatePicker.sizes?.sm.inputButton,
inputButton: DatePicker.sizes?.sm(props).inputButton,
}
}),
md: definePartsStyle((props) => {
return {
fieldwrapper: Input.sizes?.md(props).field,
inputButton: DatePicker.sizes?.md.inputButton,
inputButton: DatePicker.sizes?.md(props).inputButton,
}
}),
}
Expand All @@ -64,7 +65,7 @@ const variants = {
export const DateRangePicker = defineMultiStyleConfig({
variants,
sizes,
baseStyle: DatePicker.baseStyle,
baseStyle: (props) => omit(DatePicker.baseStyle?.(props), 'field'),
defaultProps: {
variant: 'outline',
size: 'md',
Expand Down

0 comments on commit 2dfbe9c

Please sign in to comment.