Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into SHRUI-1038
Browse files Browse the repository at this point in the history
  • Loading branch information
s-sasaki-0529 committed Sep 18, 2024
2 parents 68bdcba + f3acb48 commit d3cf6c1
Show file tree
Hide file tree
Showing 10 changed files with 1,345 additions and 1,352 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"description": "SmartHR ui components built with React.",
"author": "SmartHR-UI Team",
"devDependencies": {
"@commitlint/cli": "^19.4.1",
"@commitlint/config-conventional": "^19.4.1",
"@commitlint/cli": "^19.5.0",
"@commitlint/config-conventional": "^19.5.0",
"eslint": "^8.57.0",
"eslint-config-smarthr": "^6.33.0",
"eslint-plugin-storybook": "^0.8.0",
Expand All @@ -20,7 +20,7 @@
"stylelint-config-standard": "^36.0.1",
"stylelint-config-styled-components": "^0.1.1",
"ts-node": "^10.9.2",
"typescript": "^5.5.4"
"typescript": "^5.6.2"
},
"scripts": {
"ui": "pnpm -F smarthr-ui",
Expand All @@ -31,7 +31,7 @@
"pnpm": {
"overrides": {
"@babel/helper-compilation-targets": "^7.25.2",
"@types/react": "^18.3.5",
"@types/react": "^18.3.7",
"minimist": "1.2.8",
"react": "^18.3.1",
"react-dom": "^18.3.1",
Expand Down
22 changes: 22 additions & 0 deletions packages/smarthr-ui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [58.0.0](https://github.com/kufu/smarthr-ui/compare/v57.1.0...v58.0.0) (2024-09-17)


### ⚠ BREAKING CHANGES

* useId の独自実装を削除し、React 18 未満のサポートを終了する (#4920)
* Combobox の inputAttributes を消し、input に直接渡すように修正 (#4911)

### Features

* AnchorButtonをnext/linkなどのラップされたコンポーネントに対応 ([#4901](https://github.com/kufu/smarthr-ui/issues/4901)) ([a07d257](https://github.com/kufu/smarthr-ui/commit/a07d2573bff0326cdc959070316de118aec11150))
* Combobox の inputAttributes を消し、input に直接渡すように修正 ([#4911](https://github.com/kufu/smarthr-ui/issues/4911)) ([8b9f611](https://github.com/kufu/smarthr-ui/commit/8b9f6118bbb4a0357f7dfda512afabfc63796c16))
* FormControlのlabelとchildren内のinputの紐づけ方を変更する ([#4894](https://github.com/kufu/smarthr-ui/issues/4894)) ([593ba25](https://github.com/kufu/smarthr-ui/commit/593ba2537bcf6490f797a859af4c6cf4e81b56c8))
* useId の独自実装を削除し、React 18 未満のサポートを終了する ([#4920](https://github.com/kufu/smarthr-ui/issues/4920)) ([28e590e](https://github.com/kufu/smarthr-ui/commit/28e590ed702660a74e136d982b7d3ca9bcae8314))


### Bug Fixes

* SideMenuのPropsにchildrenを追加 ([#4919](https://github.com/kufu/smarthr-ui/issues/4919)) ([51dbdb8](https://github.com/kufu/smarthr-ui/commit/51dbdb86fdb69b6decdbeb4347232c9fd7a89cc7))
* Table コンポーネントの使われていない記述を削除 ([#4921](https://github.com/kufu/smarthr-ui/issues/4921)) ([fe3e56f](https://github.com/kufu/smarthr-ui/commit/fe3e56fd95d1b802ce15114bf1e1962a847ff715))
* Textareaの文字数カウンタをonChangeで処理するように修正 ([#4916](https://github.com/kufu/smarthr-ui/issues/4916)) ([a054e07](https://github.com/kufu/smarthr-ui/commit/a054e07c7a66f496b670e8ca855c5d0f8fe891ea))

## [57.1.0](https://github.com/kufu/smarthr-ui/compare/v57.0.0...v57.1.0) (2024-09-11)


Expand Down
38 changes: 19 additions & 19 deletions packages/smarthr-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "smarthr-ui",
"description": "SmartHR ui components built with React.",
"version": "57.1.0",
"version": "58.0.0",
"author": "SmartHR-UI Team",
"dependencies": {
"@smarthr/wareki": "^1.2.0",
Expand All @@ -21,24 +21,24 @@
"@babel/preset-env": "^7.25.4",
"@babel/preset-react": "^7.24.7",
"@babel/preset-typescript": "^7.24.7",
"@storybook/addon-a11y": "^8.2.9",
"@storybook/addon-actions": "^8.2.9",
"@storybook/addon-essentials": "^8.2.9",
"@storybook/addon-interactions": "^8.2.9",
"@storybook/addon-storysource": "^8.2.9",
"@storybook/addon-a11y": "^8.3.0",
"@storybook/addon-actions": "^8.3.0",
"@storybook/addon-essentials": "^8.3.0",
"@storybook/addon-interactions": "^8.3.0",
"@storybook/addon-storysource": "^8.3.0",
"@storybook/addon-styling": "^1.3.7",
"@storybook/addon-styling-webpack": "^1.0.0",
"@storybook/addon-viewport": "^8.2.9",
"@storybook/addon-viewport": "^8.3.0",
"@storybook/addon-webpack5-compiler-babel": "^3.0.3",
"@storybook/blocks": "^8.2.9",
"@storybook/cli": "^8.2.9",
"@storybook/manager-api": "^8.2.9",
"@storybook/react": "^8.2.9",
"@storybook/react-webpack5": "^8.2.9",
"@storybook/source-loader": "^8.2.9",
"@storybook/test": "^8.2.9",
"@storybook/blocks": "^8.3.0",
"@storybook/cli": "^8.3.0",
"@storybook/manager-api": "^8.3.0",
"@storybook/react": "^8.3.0",
"@storybook/react-webpack5": "^8.3.0",
"@storybook/source-loader": "^8.3.0",
"@storybook/test": "^8.3.0",
"@storybook/test-runner": "^0.19.1",
"@storybook/theming": "^8.2.9",
"@storybook/theming": "^8.3.0",
"@swc/core": "^1.7.24",
"@testing-library/react": "^16.0.1",
"@types/lodash.merge": "^4.6.9",
Expand All @@ -54,8 +54,8 @@
"babel-loader": "^9.1.3",
"babel-plugin-polyfill-corejs2": "^0.4.11",
"babel-plugin-polyfill-regenerator": "^0.6.2",
"chromatic": "^11.7.1",
"css-loader": "^7.1.2",
"chromatic": "^11.10.2",
"ecma-version-validator-webpack-plugin": "^1.2.1",
"fs-extra": "^11.2.0",
"glob": "11.0.0",
Expand All @@ -75,7 +75,7 @@
"react-test-renderer": "^18.3.1",
"rimraf": "^6.0.1",
"standard-version": "^9.3.2",
"storybook": "^8.2.9",
"storybook": "^8.3.0",
"storybook-addon-pseudo-states": "^4.0.2",
"style-loader": "^4.0.0",
"styled-components": "^5.3.11",
Expand All @@ -88,8 +88,8 @@
"webpack": "^5.94.0"
},
"peerDependencies": {
"react": "16.13.0 || ^17.0.1 || ^18.0.0",
"react-dom": "16.13.0 || ^17.0.1 || ^18.0.0",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"styled-components": "^5.0.1"
},
"bugs": {
Expand Down
2 changes: 1 addition & 1 deletion packages/smarthr-ui/public/exports/smarthr-ui-props.json

Large diffs are not rendered by default.

8 changes: 1 addition & 7 deletions packages/smarthr-ui/src/components/Table/Table.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import React, { ComponentProps, FC, PropsWithChildren, createContext, useMemo } from 'react'
import React, { ComponentProps, FC, PropsWithChildren, useMemo } from 'react'
import { VariantProps, tv } from 'tailwind-variants'

export const TableGroupContext = createContext<{
group: 'head' | 'body'
}>({
group: 'body',
})

type Props = PropsWithChildren<VariantProps<typeof table>>
type ElementProps = Omit<ComponentProps<'table'>, keyof Props>

Expand Down
25 changes: 25 additions & 0 deletions packages/smarthr-ui/src/hooks/useId.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { renderHook } from '@testing-library/react'

import { useId } from './useId'

describe('useId', () => {
it('defaultId を指定した場合、毎回同じ値を返す', () => {
const { result: id1 } = renderHook(() => useId('test'))
const { result: id2 } = renderHook(() => useId('test'))
const { result: id3 } = renderHook(() => useId('test'))

expect(id1.current).toEqual('test')
expect(id2.current).toEqual('test')
expect(id3.current).toEqual('test')
})

it('defaultId を指定しない場合、異なる値を返す', () => {
const { result: id1 } = renderHook(() => useId())
const { result: id2 } = renderHook(() => useId())
const { result: id3 } = renderHook(() => useId())

expect(id1.current).not.toEqual(id2.current)
expect(id2.current).not.toEqual(id3.current)
expect(id3.current).not.toEqual(id1.current)
})
})
35 changes: 3 additions & 32 deletions packages/smarthr-ui/src/hooks/useId.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,6 @@
import React, { ReactNode, VFC, createContext, useContext, useMemo } from 'react'

type IdContextValue = {
prefix: number
current: number
}

const defaultContext: IdContextValue = {
prefix: 0,
current: 0,
}

const IdContext = createContext<IdContextValue>(defaultContext)

function useId_OLD() {
const context = useContext(IdContext)
return useMemo(() => `id-${context.prefix}-${++context.current}`, [context])
}
import React from 'react'

export const useId = (defaultId?: string): string => {
if (defaultId) return defaultId

// React v18 以降は React.useId を使う
return ('useId' in React ? React.useId : useId_OLD)()
}

export const SequencePrefixIdProvider: VFC<{ children: ReactNode }> = ({ children }) => {
const context = useContext(IdContext)
// increment `prefix` and reset `current` to 0 on every Provider
const value: IdContextValue = {
prefix: context.prefix + 1,
current: 0,
}
return <IdContext.Provider value={value}>{children}</IdContext.Provider>
const id = React.useId()
return defaultId || id
}
3 changes: 0 additions & 3 deletions packages/smarthr-ui/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,3 @@ export { defaultBreakpoint } from './themes/createBreakpoint'

// constants
export { FONT_FAMILY, CHART_COLORS, OTHER_CHART_COLOR } from './constants'

// utils
export { SequencePrefixIdProvider } from './hooks/useId'
Loading

0 comments on commit d3cf6c1

Please sign in to comment.