@charcoal-ui/react-sandbox 4.2.0 → 4.3.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@charcoal-ui/react-sandbox",
3
- "version": "4.2.0",
3
+ "version": "4.3.0-beta.0",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index.cjs.js",
6
6
  "module": "./dist/index.esm.js",
@@ -21,7 +21,8 @@
21
21
  "test": "vitest run --passWithNoTests"
22
22
  },
23
23
  "devDependencies": {
24
- "@charcoal-ui/esbuild-plugin-styled-components": "^4.2.0",
24
+ "@babel/core": "^7.23.9",
25
+ "@charcoal-ui/esbuild-plugin-styled-components": "4.3.0-beta.0",
25
26
  "@storybook/addon-actions": "^7.4.1",
26
27
  "@storybook/addon-knobs": "^7.0.2",
27
28
  "@storybook/addons": "^7.4.1",
@@ -50,11 +51,11 @@
50
51
  "vitest": "^2.0.2"
51
52
  },
52
53
  "dependencies": {
53
- "@charcoal-ui/foundation": "^4.2.0",
54
- "@charcoal-ui/react": "^4.2.0",
55
- "@charcoal-ui/styled": "^4.2.0",
56
- "@charcoal-ui/theme": "^4.2.0",
57
- "@charcoal-ui/utils": "^4.2.0",
54
+ "@charcoal-ui/foundation": "4.3.0-beta.0",
55
+ "@charcoal-ui/react": "4.3.0-beta.0",
56
+ "@charcoal-ui/styled": "4.3.0-beta.0",
57
+ "@charcoal-ui/theme": "4.3.0-beta.0",
58
+ "@charcoal-ui/utils": "4.3.0-beta.0",
58
59
  "polished": "^4.1.4",
59
60
  "react-spring": "^9.0.0",
60
61
  "warning": "^4.0.3"
@@ -76,5 +77,5 @@
76
77
  "url": "https://github.com/pixiv/charcoal.git",
77
78
  "directory": "packages/react-sandbox"
78
79
  },
79
- "gitHead": "45c93231d4b0feffe8f3a6bef2cdab96302c8eb4"
80
+ "gitHead": "864fc9a6c8ad391df01c7765ab0dff66842c612d"
80
81
  }
@@ -0,0 +1,34 @@
1
+ import { Meta, StoryObj } from '@storybook/react'
2
+ import Carousel from '.'
3
+
4
+ export default {
5
+ title: 'react-sandbox/Carousel',
6
+ component: Carousel,
7
+ argTypes: {},
8
+ } satisfies Meta<typeof Carousel>
9
+
10
+ const items = [1, 2, 3, 4, 5]
11
+ export const Default: StoryObj<typeof Carousel> = {
12
+ render: (props) => (
13
+ <Carousel {...props}>
14
+ <div
15
+ style={{
16
+ display: 'flex',
17
+ gap: '8px',
18
+ }}
19
+ >
20
+ {items.map((item) => (
21
+ <div
22
+ key={item}
23
+ style={{
24
+ width: '200px',
25
+ height: '100px',
26
+ backgroundColor: 'var(--charcoal-brand)',
27
+ filter: `hue-rotate(0.${item}turn)`,
28
+ }}
29
+ />
30
+ ))}
31
+ </div>
32
+ </Carousel>
33
+ ),
34
+ }
@@ -0,0 +1,22 @@
1
+ import { Meta, StoryObj } from '@storybook/react'
2
+ import { FilterButton, FilterLink, FilterIconButton } from '.'
3
+
4
+ export default {
5
+ title: 'react-sandbox/Filter',
6
+ component: FilterButton,
7
+ } satisfies Meta<typeof FilterButton>
8
+
9
+ export const Default: StoryObj<typeof Filter> = {
10
+ render: (props) => {
11
+ return (
12
+ <>
13
+ FilterButton: <FilterButton {...props}>test</FilterButton>
14
+ FilterLink: <FilterLink {...props}>test</FilterLink>
15
+ FilterIconButton:{' '}
16
+ <FilterIconButton width={40} height={40} {...props}>
17
+ test
18
+ </FilterIconButton>
19
+ </>
20
+ )
21
+ },
22
+ }
@@ -0,0 +1,17 @@
1
+ import { Meta, StoryObj } from '@storybook/react'
2
+ import Layout from '.'
3
+
4
+ export default {
5
+ title: 'react-sandbox/Layout',
6
+ component: Layout,
7
+ } satisfies Meta<typeof Layout>
8
+
9
+ export const Default: StoryObj<typeof Layout> = {
10
+ render: (props) => {
11
+ return (
12
+ <Layout {...props} menu={<>menu</>} header={<>header</>}>
13
+ children
14
+ </Layout>
15
+ )
16
+ },
17
+ }
@@ -0,0 +1,22 @@
1
+ import { Meta, StoryObj } from '@storybook/react'
2
+ import LeftMenu from '.'
3
+
4
+ export default {
5
+ title: 'react-sandbox/LeftMenu',
6
+ component: LeftMenu,
7
+ } satisfies Meta<typeof LeftMenu>
8
+
9
+ const links = [
10
+ { text: 'text1', to: '', id: '1' },
11
+ { text: 'text2', to: '', id: '2' },
12
+ { text: 'text3', to: '', id: '3' },
13
+ ]
14
+ export const Default: StoryObj<typeof LeftMenu> = {
15
+ render: (props) => {
16
+ return (
17
+ <LeftMenu {...props} links={links} active="1">
18
+ children
19
+ </LeftMenu>
20
+ )
21
+ },
22
+ }
@@ -0,0 +1,17 @@
1
+ import { Meta, StoryObj } from '@storybook/react'
2
+ import Pager from '.'
3
+
4
+ export default {
5
+ title: 'react-sandbox/Pager',
6
+ component: Pager,
7
+ args: {
8
+ page: 5,
9
+ pageCount: 10,
10
+ },
11
+ } satisfies Meta<typeof Pager>
12
+
13
+ export const Default: StoryObj<typeof Pager> = {
14
+ render: (props) => {
15
+ return <Pager {...props}>children</Pager>
16
+ },
17
+ }
@@ -0,0 +1,13 @@
1
+ import { Meta, StoryObj } from '@storybook/react'
2
+ import SwitchCheckbox from '.'
3
+
4
+ export default {
5
+ title: 'react-sandbox/SwitchCheckbox',
6
+ component: SwitchCheckbox,
7
+ } satisfies Meta<typeof SwitchCheckbox>
8
+
9
+ export const Default: StoryObj<typeof SwitchCheckbox> = {
10
+ render: (props) => {
11
+ return <SwitchCheckbox {...props}>children</SwitchCheckbox>
12
+ },
13
+ }
@@ -1,12 +1,6 @@
1
1
  // https://github.com/fernandopasik/react-children-utilities/blob/971d8a0324e6183734d8d1af9a65dbad18ab3d00/src/lib/onlyText.ts
2
2
 
3
- import {
4
- Children,
5
- isValidElement,
6
- ReactElement,
7
- ReactNode,
8
- ReactText,
9
- } from 'react'
3
+ import { Children, isValidElement, ReactElement, ReactNode } from 'react'
10
4
 
11
5
  const hasChildren = (
12
6
  element: ReactNode
@@ -16,7 +10,7 @@ const hasChildren = (
16
10
 
17
11
  export const childToString = (
18
12
  // eslint-disable-next-line @typescript-eslint/ban-types
19
- child?: ReactText | boolean | {} | null
13
+ child?: number | string | boolean | {} | null
20
14
  ): string => {
21
15
  if (
22
16
  typeof child === 'undefined' ||
@@ -0,0 +1,31 @@
1
+ import { Meta, StoryObj } from '@storybook/react'
2
+ import WithIcon from '.'
3
+
4
+ export default {
5
+ title: 'react-sandbox/WithIcon',
6
+ component: WithIcon,
7
+ argTypes: {
8
+ prefix: {
9
+ type: 'boolean',
10
+ },
11
+ fit: {
12
+ type: 'boolean',
13
+ },
14
+ width: {
15
+ type: 'number',
16
+ },
17
+ fixed: {
18
+ type: 'boolean',
19
+ },
20
+ },
21
+ } satisfies Meta<typeof WithIcon>
22
+
23
+ export const Default: StoryObj<typeof WithIcon> = {
24
+ render: (props) => {
25
+ return (
26
+ <WithIcon {...props} icon={<pixiv-icon name="16/Like" />}>
27
+ children
28
+ </WithIcon>
29
+ )
30
+ },
31
+ }
@@ -7,7 +7,7 @@ interface Props {
7
7
 
8
8
  export { DotsIcon as default }
9
9
 
10
- function DotsIcon({ size }: Props) {
10
+ function DotsIcon({ size = 16 }: Props) {
11
11
  return (
12
12
  <StyledSVG viewBox="0 0 20 6" width={size} height={size}>
13
13
  <path
@@ -23,9 +23,6 @@ function DotsIcon({ size }: Props) {
23
23
  </StyledSVG>
24
24
  )
25
25
  }
26
- DotsIcon.defaultProps = {
27
- size: 16,
28
- }
29
26
 
30
27
  const StyledSVG = styled.svg`
31
28
  fill: currentColor;
@@ -14,7 +14,7 @@ interface Props {
14
14
  direction: WedgeDirection
15
15
  }
16
16
 
17
- export default function WedgeIcon({ size, direction }: Props) {
17
+ export default function WedgeIcon({ size = 16, direction }: Props) {
18
18
  return (
19
19
  // NOTE: directionToTransform depends on the value of viewBox
20
20
  <svg viewBox="0 0 10 8" width={size} height={size}>
@@ -26,11 +26,6 @@ export default function WedgeIcon({ size, direction }: Props) {
26
26
  </svg>
27
27
  )
28
28
  }
29
- WedgeIcon.defaultProps = {
30
- size: 16,
31
- white: false,
32
- lightGray: false,
33
- }
34
29
 
35
30
  function directionToTransform(direction: WedgeDirection) {
36
31
  // "5 4" is the center point of the "0 0 10 8" viewBox
@@ -96,7 +96,7 @@ function measure(ref: Element | null): ElementSize | undefined {
96
96
  }
97
97
 
98
98
  export function useElementSize(
99
- ref: React.RefObject<Element>,
99
+ ref: React.RefObject<Element | null>,
100
100
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
101
101
  deps: any[] = []
102
102
  ) {
@@ -174,7 +174,9 @@ export function useElementSize(
174
174
  */
175
175
  export function useDebounceAnimationState<T>(defaultValue: T) {
176
176
  const [state, setState] = useState(defaultValue)
177
- const timer = useRef<ReturnType<typeof requestAnimationFrame>>()
177
+ const timer = useRef<ReturnType<typeof requestAnimationFrame> | undefined>(
178
+ undefined
179
+ )
178
180
  // typescript bug? (any when omitting type annotation)
179
181
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
180
182
  const setDebounceState = useCallback((value: T, force: boolean = false) => {