@charcoal-ui/react 1.0.0 → 2.0.0-alpha.2

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.
Files changed (43) hide show
  1. package/dist/_lib/compat.d.ts +2 -3
  2. package/dist/_lib/compat.d.ts.map +1 -1
  3. package/dist/components/Radio/index.d.ts +2 -2
  4. package/dist/components/Radio/index.d.ts.map +1 -1
  5. package/dist/components/Radio/index.story.d.ts +14 -5
  6. package/dist/components/Radio/index.story.d.ts.map +1 -1
  7. package/dist/components/Select/context.d.ts +14 -0
  8. package/dist/components/Select/context.d.ts.map +1 -0
  9. package/dist/components/Select/index.d.ts +24 -0
  10. package/dist/components/Select/index.d.ts.map +1 -0
  11. package/dist/components/Select/index.story.d.ts +75 -0
  12. package/dist/components/Select/index.story.d.ts.map +1 -0
  13. package/dist/components/Select/index.test.d.ts +2 -0
  14. package/dist/components/Select/index.test.d.ts.map +1 -0
  15. package/dist/components/TextField/index.d.ts +4 -0
  16. package/dist/components/TextField/index.d.ts.map +1 -1
  17. package/dist/components/TextField/index.story.d.ts +11 -4
  18. package/dist/components/TextField/index.story.d.ts.map +1 -1
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.ts +1 -0
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.modern.js +97 -35
  24. package/dist/index.modern.js.map +1 -1
  25. package/dist/index.module.js +1 -1
  26. package/dist/index.module.js.map +1 -1
  27. package/dist/styled.d.ts +10 -0
  28. package/dist/styled.d.ts.map +1 -1
  29. package/package.json +11 -6
  30. package/src/_lib/compat.ts +1 -4
  31. package/src/components/IconButton/index.tsx +1 -0
  32. package/src/components/Radio/index.story.tsx +16 -17
  33. package/src/components/Radio/index.test.tsx +15 -16
  34. package/src/components/Radio/index.tsx +4 -7
  35. package/src/components/Select/context.ts +23 -0
  36. package/src/components/Select/index.story.tsx +153 -0
  37. package/src/components/Select/index.test.tsx +281 -0
  38. package/src/components/Select/index.tsx +210 -0
  39. package/src/components/TextField/index.story.tsx +10 -0
  40. package/src/components/TextField/index.tsx +105 -23
  41. package/src/components/a11y.test.tsx +32 -24
  42. package/src/index.ts +6 -0
  43. package/src/type.d.ts +0 -4
@@ -1 +1 @@
1
- {"version":3,"file":"index.module.js","sources":["../src/core/ComponentAbstraction.tsx","../src/styled.ts","../src/components/Clickable/index.tsx","../src/components/Button/index.tsx","../src/_lib/index.ts","../src/components/IconButton/index.tsx","../src/components/Radio/index.tsx","../src/components/Switch/index.tsx","../src/components/FieldLabel/index.tsx","../src/components/TextField/index.tsx"],"sourcesContent":["import React, { useContext } from 'react'\n\nexport type LinkProps = {\n /**\n * リンクのURL\n */\n to: string\n} & Omit<React.ComponentPropsWithoutRef<'a'>, 'href'>\n\nexport const DefaultLink = React.forwardRef<HTMLAnchorElement, LinkProps>(\n function DefaultLink({ to, children, ...rest }, ref) {\n return (\n <a href={to} ref={ref} {...rest}>\n {children}\n </a>\n )\n }\n)\n\ninterface Components {\n Link: React.ComponentType<React.ComponentPropsWithRef<typeof DefaultLink>>\n}\n\nconst DefaultValue: Components = {\n Link: DefaultLink,\n}\n\nconst ComponentAbstractionContext = React.createContext(DefaultValue)\n\ninterface Props {\n children: React.ReactNode\n components: Partial<Components>\n}\n\nexport default function ComponentAbstraction({ children, components }: Props) {\n return (\n <ComponentAbstractionContext.Provider\n value={{ ...DefaultValue, ...components }}\n >\n {children}\n </ComponentAbstractionContext.Provider>\n )\n}\n\nexport function useComponentAbstraction() {\n return useContext(ComponentAbstractionContext)\n}\n","import styled from 'styled-components'\nimport createTheme from '@charcoal-ui/styled'\nexport const theme = createTheme(styled)\n","import React from 'react'\nimport styled, { css } from 'styled-components'\nimport {\n LinkProps,\n useComponentAbstraction,\n} from '../../core/ComponentAbstraction'\nimport { disabledSelector } from '@charcoal-ui/utils'\n\ninterface BaseProps {\n /**\n * クリックの無効化\n */\n disabled?: boolean\n}\n\ninterface LinkBaseProps {\n /**\n * リンクのURL。指定するとbuttonタグではなくaタグとして描画される\n */\n to: string\n}\n\nexport type ClickableProps =\n | (BaseProps & Omit<React.ComponentPropsWithoutRef<'button'>, 'disabled'>)\n | (BaseProps & LinkBaseProps & Omit<LinkProps, 'to'>)\nexport type ClickableElement = HTMLButtonElement & HTMLAnchorElement\n\nconst Clickable = React.forwardRef<ClickableElement, ClickableProps>(\n function Clickable(props, ref) {\n const { Link } = useComponentAbstraction()\n if ('to' in props) {\n const { onClick, disabled = false, ...rest } = props\n return (\n <A<typeof Link>\n {...rest}\n as={disabled ? undefined : Link}\n onClick={disabled ? undefined : onClick}\n aria-disabled={disabled}\n ref={ref}\n />\n )\n } else {\n return <Button {...props} ref={ref} />\n }\n }\n)\nexport default Clickable\n\nconst clickableCss = css`\n /* Clickable style */\n cursor: pointer;\n\n ${disabledSelector} {\n cursor: default;\n }\n`\n\nconst Button = styled.button`\n /* Reset button appearance */\n appearance: none;\n background: transparent;\n padding: 0;\n border-style: none;\n outline: none;\n color: inherit;\n text-rendering: inherit;\n letter-spacing: inherit;\n word-spacing: inherit;\n\n &:focus {\n outline: none;\n }\n\n /* Change the font styles in all browsers. */\n font: inherit;\n\n /* Remove the margin in Firefox and Safari. */\n margin: 0;\n\n /* Show the overflow in Edge. */\n overflow: visible;\n\n /* Remove the inheritance of text transform in Firefox. */\n text-transform: none;\n\n /* Remove the inner border and padding in Firefox. */\n &::-moz-focus-inner {\n border-style: none;\n padding: 0;\n }\n\n ${clickableCss}\n`\n\nconst A = styled.span`\n /* Reset a-tag appearance */\n color: inherit;\n\n &:focus {\n outline: none;\n }\n\n .text {\n top: calc(1em + 2em);\n }\n\n ${clickableCss}\n`\n","import React from 'react'\nimport styled from 'styled-components'\nimport { unreachable } from '../../_lib'\nimport { theme } from '../../styled'\nimport Clickable, { ClickableElement, ClickableProps } from '../Clickable'\n\ntype Variant = 'Primary' | 'Default' | 'Overlay' | 'Danger' | 'Navigation'\ntype Size = 'S' | 'M'\n\ninterface StyledProps {\n /**\n * ボタンのスタイル\n */\n variant: Variant\n /**\n * ボタンのサイズ\n */\n size: Size\n /**\n * 幅を最大まで広げて描画\n */\n fixed: boolean\n}\n\nexport type ButtonProps = Partial<StyledProps> & ClickableProps\n\nconst Button = React.forwardRef<ClickableElement, ButtonProps>(function Button(\n {\n children,\n variant = 'Default',\n size = 'M',\n fixed = false,\n disabled = false,\n ...rest\n },\n ref\n) {\n return (\n <StyledButton\n {...rest}\n disabled={disabled}\n variant={variant}\n size={size}\n fixed={fixed}\n ref={ref}\n >\n {children}\n </StyledButton>\n )\n})\nexport default Button\n\nconst StyledButton = styled(Clickable)\n .withConfig<StyledProps>({\n shouldForwardProp(prop) {\n // fixed は <button> 要素に渡ってはいけない\n return prop !== 'fixed'\n },\n })\n .attrs<StyledProps, ReturnType<typeof styledProps>>(styledProps)`\n width: ${(p) => (p.fixed ? 'stretch' : 'min-content')};\n display: inline-grid;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n user-select: none;\n white-space: nowrap;\n\n ${(p) =>\n theme((o) => [\n o.font[p.font].hover.press,\n o.bg[p.background].hover.press,\n o.typography(14).bold.preserveHalfLeading,\n o.padding.horizontal(p.padding),\n o.disabled,\n o.borderRadius('oval'),\n o.outline.default.focus,\n ])}\n\n /* よく考えたらheight=32って定義が存在しないな... */\n height: ${(p) => p.height}px;\n`\n\nfunction styledProps(props: StyledProps) {\n return {\n ...props,\n ...variantToProps(props.variant),\n ...sizeToProps(props.size),\n }\n}\n\nfunction variantToProps(variant: Variant) {\n switch (variant) {\n case 'Overlay':\n return { font: 'text5', background: 'surface4' } as const\n case 'Default':\n return { font: 'text2', background: 'surface3' } as const\n case 'Primary':\n return { font: 'text5', background: 'brand' } as const\n case 'Navigation':\n return { font: 'text5', background: 'surface6' } as const\n case 'Danger':\n return { font: 'text5', background: 'assertive' } as const\n default:\n return unreachable(variant)\n }\n}\n\nfunction sizeToProps(size: Size) {\n switch (size) {\n case 'S':\n return {\n height: 32,\n padding: 16,\n } as const\n case 'M':\n return {\n height: 40,\n padding: 24,\n } as const\n }\n}\n","/**\n * 今後ポートされる予定の汎用的な関数群\n */\n\n/**\n * Function used to assert a given code path is unreachable\n */\nexport function unreachable(): never\n/**\n * Function used to assert a given code path is unreachable.\n * Very useful for ensuring switches are exhaustive:\n *\n * ```ts\n * switch (a.type) {\n * case Types.A:\n * case Types.B:\n * break\n * default:\n * unreachable(a) // will cause a build error if there was\n * // a Types.C that was not checked\n * }\n * ```\n *\n * @param value Value to be asserted as unreachable\n */\n// NOTE: Uses separate overloads, _not_ `value?: never`, to not allow `undefined` to be passed\n// eslint-disable-next-line @typescript-eslint/unified-signatures\nexport function unreachable(value: never): never\nexport function unreachable(value?: never): never {\n throw new Error(\n arguments.length === 0\n ? 'unreachable'\n : `unreachable (${JSON.stringify(value)})`\n )\n}\n","import React from 'react'\nimport styled from 'styled-components'\nimport { theme } from '../../styled'\nimport Clickable, { ClickableElement, ClickableProps } from '../Clickable'\nimport type { KnownIconType } from '@charcoal-ui/icons'\n\ntype Variant = 'Default' | 'Overlay'\ntype Size = 'XS' | 'S' | 'M'\n\ninterface StyledProps {\n readonly variant?: Variant\n readonly size?: Size\n readonly icon: keyof KnownIconType\n}\n\nexport type IconButtonProps = StyledProps & ClickableProps\n\nconst IconButton = React.forwardRef<ClickableElement, IconButtonProps>(\n function IconButtonInner(\n { variant = 'Default', size = 'M', icon, ...rest }: IconButtonProps,\n ref\n ) {\n validateIconSize(size, icon)\n return (\n <StyledIconButton {...rest} ref={ref} variant={variant} size={size}>\n <pixiv-icon name={icon} />\n </StyledIconButton>\n )\n }\n)\n\nexport default IconButton\n\nconst StyledIconButton = styled(Clickable).attrs<\n Required<StyledProps>,\n ReturnType<typeof styledProps>\n>(styledProps)`\n user-select: none;\n\n width: ${(p) => p.width}px;\n height: ${(p) => p.height}px;\n display: flex;\n align-items: center;\n justify-content: center;\n\n ${({ font, background }) =>\n theme((o) => [\n o.font[font],\n o.bg[background].hover.press,\n o.disabled,\n o.borderRadius('oval'),\n o.outline.default.focus,\n ])}\n`\n\nfunction styledProps(props: Required<StyledProps>) {\n return {\n ...props,\n ...variantToProps(props.variant),\n ...sizeToProps(props.size),\n }\n}\n\nfunction variantToProps(variant: Variant) {\n switch (variant) {\n case 'Default':\n return { font: 'text3', background: 'transparent' } as const\n case 'Overlay':\n return { font: 'text5', background: 'surface4' } as const\n }\n}\n\nfunction sizeToProps(size: Size) {\n switch (size) {\n case 'XS':\n return {\n width: 20,\n height: 20,\n }\n case 'S':\n return {\n width: 32,\n height: 32,\n }\n case 'M':\n return {\n width: 40,\n height: 40,\n }\n }\n}\n\n/**\n * validates matches of size and icon\n */\nfunction validateIconSize(size: Size, icon: keyof KnownIconType) {\n let requiredIconSize: string\n switch (size) {\n case 'XS':\n requiredIconSize = '16'\n break\n case 'S':\n case 'M':\n requiredIconSize = '24'\n break\n }\n // アイコン名は サイズ/名前\n const result = /^\\d*/u.exec(icon)\n if (result == null) {\n throw new Error('Invalid icon name')\n }\n const [iconSize] = result\n if (iconSize !== requiredIconSize) {\n console.warn(\n `IconButton with size \"${size}\" expect icon size \"${requiredIconSize}, but got \"${iconSize}\"`\n )\n }\n}\n","import React, { useCallback, useContext, useState } from 'react'\nimport styled from 'styled-components'\nimport warning from 'warning'\nimport { theme } from '../../styled'\nimport { px } from '@charcoal-ui/utils'\n\nexport type RadioProps = React.PropsWithChildren<{\n value: string\n forceChecked?: boolean\n disabled?: boolean\n}>\n\nexport default function Radio({\n value,\n forceChecked = false,\n disabled = false,\n children,\n}: RadioProps) {\n const {\n name,\n selected,\n disabled: isParentDisabled,\n readonly,\n hasError,\n onChange,\n } = useContext(RadioGroupContext)\n\n warning(\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n name !== undefined,\n `\"name\" is not Provided for <Radio>. Perhaps you forgot to wrap with <RadioGroup> ?`\n )\n\n const isSelected = value === selected\n const isDisabled = disabled || isParentDisabled\n const isReadonly = readonly && !isSelected\n\n const handleChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n onChange(e.currentTarget.value)\n },\n [onChange]\n )\n\n return (\n <RadioRoot aria-disabled={isDisabled || isReadonly}>\n <RadioInput\n name={name}\n value={value}\n checked={forceChecked || isSelected}\n hasError={hasError}\n onChange={handleChange}\n disabled={isDisabled || isReadonly}\n />\n {children != null && <RadioLabel>{children}</RadioLabel>}\n </RadioRoot>\n )\n}\n\nconst RadioRoot = styled.label`\n display: grid;\n grid-template-columns: auto 1fr;\n grid-gap: ${({ theme }) => px(theme.spacing[4])};\n align-items: center;\n cursor: pointer;\n\n ${theme((o) => [o.disabled])}\n`\n\nexport const RadioInput = styled.input.attrs({ type: 'radio' })<{\n hasError?: boolean\n}>`\n /** Make prior to browser default style */\n &[type='radio'] {\n appearance: none;\n display: block;\n box-sizing: border-box;\n\n padding: 6px;\n\n width: 20px;\n height: 20px;\n\n ${({ hasError = false }) =>\n theme((o) => [\n o.borderRadius('oval'),\n o.bg.text5.hover.press,\n hasError && o.outline.assertive,\n ])};\n\n &:not(:checked) {\n border-width: 2px;\n border-style: solid;\n border-color: ${({ theme }) => theme.color.text4};\n }\n\n &:checked {\n ${theme((o) => o.bg.brand.hover.press)}\n\n &::after {\n content: '';\n display: block;\n width: 8px;\n height: 8px;\n pointer-events: none;\n\n ${theme((o) => [o.bg.text5.hover.press, o.borderRadius('oval')])}\n }\n }\n\n ${theme((o) => o.outline.default.focus)}\n }\n`\n\nconst RadioLabel = styled.div`\n ${theme((o) => [o.typography(14)])}\n`\n\nexport type RadioGroupProps = React.PropsWithChildren<{\n className?: string\n defaultValue?: string\n label: string\n name: string\n onChange(next: string): void\n disabled?: boolean\n readonly?: boolean\n hasError?: boolean\n}>\n\n// TODO: use (or polyfill) flex gap\nconst StyledRadioGroup = styled.div`\n display: grid;\n grid-template-columns: 1fr;\n grid-gap: ${({ theme }) => px(theme.spacing[8])};\n`\n\ninterface RadioGroupContext {\n name: string\n selected?: string\n disabled: boolean\n readonly: boolean\n hasError: boolean\n onChange: (next: string) => void\n}\n\nconst RadioGroupContext = React.createContext<RadioGroupContext>({\n name: undefined as never,\n selected: undefined,\n disabled: false,\n readonly: false,\n hasError: false,\n onChange() {\n throw new Error(\n 'Cannot find onChange() handler. Perhaps you forgot to wrap with <RadioGroup> ?'\n )\n },\n})\n\nexport function RadioGroup({\n className,\n defaultValue,\n label,\n name,\n onChange,\n disabled,\n readonly,\n hasError,\n children,\n}: RadioGroupProps) {\n const [selected, setSelected] = useState(defaultValue)\n\n const handleChange = useCallback(\n (next: string) => {\n setSelected(next)\n onChange(next)\n },\n [onChange]\n )\n\n return (\n <RadioGroupContext.Provider\n value={{\n name,\n selected,\n disabled: disabled ?? false,\n readonly: readonly ?? false,\n hasError: hasError ?? false,\n onChange: handleChange,\n }}\n >\n <StyledRadioGroup\n role=\"radiogroup\"\n aria-orientation=\"vertical\"\n aria-label={label}\n aria-invalid={hasError}\n className={className}\n >\n {children}\n </StyledRadioGroup>\n </RadioGroupContext.Provider>\n )\n}\n","import { useSwitch } from '@react-aria/switch'\nimport type { AriaSwitchProps } from '@react-types/switch'\nimport React, { useRef, useMemo } from 'react'\nimport { useToggleState } from 'react-stately'\nimport styled from 'styled-components'\nimport { theme } from '../../styled'\nimport { disabledSelector, px } from '@charcoal-ui/utils'\n\nexport type SwitchProps = {\n name: string\n className?: string\n value?: string\n checked?: boolean\n disabled?: boolean\n onChange(checked: boolean): void\n} & (\n | // children か label は片方が必須\n {\n children: React.ReactNode\n }\n | {\n label: string\n }\n)\n\nexport default function SwitchCheckbox(props: SwitchProps) {\n const { disabled, className } = props\n\n const ariaSwitchProps: AriaSwitchProps = useMemo(\n () => ({\n ...props,\n\n // children がいない場合は aria-label をつけないといけない\n 'aria-label': 'children' in props ? undefined : props.label,\n isDisabled: props.disabled,\n isSelected: props.checked,\n }),\n [props]\n )\n\n const state = useToggleState(ariaSwitchProps)\n const ref = useRef<HTMLInputElement>(null)\n const {\n inputProps: { className: _className, type: _type, ...rest },\n } = useSwitch(ariaSwitchProps, state, ref)\n\n return (\n <Label className={className} aria-disabled={disabled}>\n <SwitchInput {...rest} ref={ref} />\n {'children' in props ? (\n // eslint-disable-next-line react/destructuring-assignment\n <LabelInner>{props.children}</LabelInner>\n ) : undefined}\n </Label>\n )\n}\n\nconst Label = styled.label`\n display: inline-grid;\n grid-template-columns: auto 1fr;\n gap: ${({ theme }) => px(theme.spacing[4])};\n cursor: pointer;\n outline: 0;\n\n ${theme((o) => o.disabled)}\n\n ${disabledSelector} {\n cursor: default;\n }\n`\n\nconst LabelInner = styled.div`\n ${theme((o) => o.typography(14))}\n`\n\nconst SwitchInput = styled.input.attrs({\n type: 'checkbox',\n})`\n &[type='checkbox'] {\n appearance: none;\n display: inline-flex;\n position: relative;\n box-sizing: border-box;\n width: 28px;\n border: 2px solid transparent;\n transition: box-shadow 0.2s, background-color 0.2s;\n cursor: inherit;\n ${theme((o) => [\n o.borderRadius(16),\n o.height.px(16),\n o.bg.text4.hover.press,\n o.outline.default.focus,\n ])}\n\n &::after {\n content: '';\n position: absolute;\n display: block;\n top: 0;\n left: 0;\n width: 12px;\n height: 12px;\n transform: translateX(0);\n transition: transform 0.2s;\n ${theme((o) => [o.bg.text5.hover.press, o.borderRadius('oval')])}\n }\n\n &:checked {\n ${theme((o) => o.bg.brand.hover.press)}\n\n &::after {\n transform: translateX(12px);\n }\n }\n }\n`\n","import React from 'react'\nimport styled from 'styled-components'\nimport createTheme from '@charcoal-ui/styled'\n\nexport interface FieldLabelProps\n extends React.LabelHTMLAttributes<HTMLLabelElement> {\n readonly className?: string\n readonly label: string\n readonly subLabel?: React.ReactNode\n readonly required?: boolean\n // TODO: 翻訳用のContextで注入する\n readonly requiredText?: string\n}\n\nconst FieldLabel = React.forwardRef<HTMLLabelElement, FieldLabelProps>(\n function FieldLabel(\n {\n style,\n className,\n label,\n required = false,\n requiredText,\n subLabel,\n ...labelProps\n },\n ref\n ) {\n return (\n <FieldLabelWrapper style={style} className={className}>\n <Label ref={ref} {...labelProps}>\n {label}\n </Label>\n {required && <RequiredText>{requiredText}</RequiredText>}\n <SubLabelClickable>\n <span>{subLabel}</span>\n </SubLabelClickable>\n </FieldLabelWrapper>\n )\n }\n)\n\nexport default FieldLabel\n\nconst theme = createTheme(styled)\n\nconst Label = styled.label`\n ${theme((o) => [o.typography(14).bold, o.font.text1])}\n`\n\nconst RequiredText = styled.span`\n ${theme((o) => [o.typography(14), o.font.text3])}\n`\n\nconst SubLabelClickable = styled.div`\n ${theme((o) => [\n o.typography(14),\n o.font.text3.hover.press,\n o.outline.default.focus,\n ])}\n`\n\nconst FieldLabelWrapper = styled.div`\n display: inline-flex;\n align-items: center;\n\n > ${RequiredText} {\n ${theme((o) => o.margin.left(4))}\n }\n\n > ${SubLabelClickable} {\n ${theme((o) => o.margin.left('auto'))}\n }\n`\n","import { useTextField } from '@react-aria/textfield'\nimport { useVisuallyHidden } from '@react-aria/visually-hidden'\nimport React, { useCallback, useEffect, useRef, useState } from 'react'\nimport styled, { css } from 'styled-components'\nimport FieldLabel, { FieldLabelProps } from '../FieldLabel'\nimport createTheme from '@charcoal-ui/styled'\n\nconst theme = createTheme(styled)\n\ninterface TextFieldBaseProps\n extends Pick<FieldLabelProps, 'label' | 'requiredText' | 'subLabel'> {\n readonly className?: string\n readonly defaultValue?: string\n readonly value?: string\n readonly onChange?: (value: string) => void\n readonly showCount?: boolean\n readonly showLabel?: boolean\n readonly placeholder?: string\n readonly assistiveText?: string\n readonly disabled?: boolean\n readonly required?: boolean\n readonly invalid?: boolean\n readonly maxLength?: number\n /**\n * tab-indexがー1かどうか\n */\n readonly excludeFromTabOrder?: boolean\n}\n\nexport interface SingleLineTextFieldProps extends TextFieldBaseProps {\n readonly autoHeight?: never\n readonly multiline?: false\n readonly rows?: never\n readonly type?: string\n}\n\nexport interface MultiLineTextFieldProps extends TextFieldBaseProps {\n readonly autoHeight?: boolean\n readonly multiline: true\n readonly rows?: number\n readonly type?: never\n}\n\nexport type TextFieldProps = SingleLineTextFieldProps | MultiLineTextFieldProps\ntype TextFieldElement = HTMLInputElement & HTMLTextAreaElement\n\nfunction mergeRefs<T>(...refs: React.Ref<T>[]): React.RefCallback<T> {\n return (value) => {\n for (const ref of refs) {\n if (typeof ref === 'function') {\n ref(value)\n } else if (ref !== null) {\n ;(ref as React.MutableRefObject<T | null>).current = value\n }\n }\n }\n}\n\nfunction countStringInCodePoints(string: string) {\n return [...string].length\n}\n\nconst TextField = React.forwardRef<TextFieldElement, TextFieldProps>(\n function TextField(props, ref) {\n return props.multiline !== undefined && props.multiline ? (\n <MultiLineTextField ref={ref} {...props} />\n ) : (\n <SingleLineTextField ref={ref} {...props} />\n )\n }\n)\n\nexport default TextField\n\nconst SingleLineTextField = React.forwardRef<\n HTMLInputElement,\n SingleLineTextFieldProps\n>(function SingleLineTextFieldInner({ onChange, ...props }, forwardRef) {\n const {\n className,\n showLabel = false,\n showCount = false,\n label,\n requiredText,\n subLabel,\n disabled = false,\n required,\n invalid = false,\n assistiveText,\n maxLength,\n } = props\n\n const { visuallyHiddenProps } = useVisuallyHidden()\n const ariaRef = useRef<HTMLInputElement>(null)\n const [count, setCount] = useState(countStringInCodePoints(props.value ?? ''))\n\n const handleChange = useCallback(\n (value: string) => {\n const count = countStringInCodePoints(value)\n if (maxLength !== undefined && count > maxLength) {\n return\n }\n setCount(count)\n onChange?.(value)\n },\n [maxLength, onChange]\n )\n\n const { inputProps, labelProps, descriptionProps, errorMessageProps } =\n useTextField(\n {\n inputElementType: 'input',\n isDisabled: disabled,\n isRequired: required,\n validationState: invalid ? 'invalid' : 'valid',\n description: !invalid && assistiveText,\n errorMessage: invalid && assistiveText,\n onChange: handleChange,\n ...props,\n },\n ariaRef\n )\n\n return (\n <TextFieldRoot className={className} isDisabled={disabled}>\n <TextFieldLabel\n label={label}\n requiredText={requiredText}\n required={required}\n subLabel={subLabel}\n {...labelProps}\n {...(!showLabel ? visuallyHiddenProps : {})}\n />\n <StyledInputContainer>\n <StyledInput\n ref={mergeRefs(forwardRef, ariaRef)}\n invalid={invalid}\n {...inputProps}\n />\n {showCount && maxLength && (\n <SingleLineCounter>\n {count}/{maxLength}\n </SingleLineCounter>\n )}\n </StyledInputContainer>\n {assistiveText != null && assistiveText.length !== 0 && (\n <AssistiveText\n invalid={invalid}\n {...(invalid ? errorMessageProps : descriptionProps)}\n >\n {assistiveText}\n </AssistiveText>\n )}\n </TextFieldRoot>\n )\n})\n\nconst MultiLineTextField = React.forwardRef<\n HTMLTextAreaElement,\n MultiLineTextFieldProps\n>(function MultiLineTextFieldInner({ onChange, ...props }, forwardRef) {\n const {\n className,\n showCount = false,\n showLabel = false,\n label,\n requiredText,\n subLabel,\n disabled = false,\n required,\n invalid = false,\n assistiveText,\n maxLength,\n autoHeight = false,\n rows: initialRows = 4,\n } = props\n\n const { visuallyHiddenProps } = useVisuallyHidden()\n const textareaRef = useRef<HTMLTextAreaElement>(null)\n const ariaRef = useRef<HTMLTextAreaElement>(null)\n const [count, setCount] = useState(countStringInCodePoints(props.value ?? ''))\n const [rows, setRows] = useState(initialRows)\n\n const syncHeight = useCallback(\n (textarea: HTMLTextAreaElement) => {\n const rows = `${textarea.value}\\n`.match(/\\n/gu)?.length ?? 1\n if (initialRows <= rows) {\n setRows(rows)\n }\n },\n [initialRows]\n )\n\n const handleChange = useCallback(\n (value: string) => {\n const count = countStringInCodePoints(value)\n if (maxLength !== undefined && count > maxLength) {\n return\n }\n setCount(count)\n if (autoHeight && textareaRef.current !== null) {\n syncHeight(textareaRef.current)\n }\n onChange?.(value)\n },\n [autoHeight, maxLength, onChange, syncHeight]\n )\n\n const { inputProps, labelProps, descriptionProps, errorMessageProps } =\n useTextField(\n {\n inputElementType: 'textarea',\n isDisabled: disabled,\n isRequired: required,\n validationState: invalid ? 'invalid' : 'valid',\n description: !invalid && assistiveText,\n errorMessage: invalid && assistiveText,\n onChange: handleChange,\n ...props,\n },\n ariaRef\n )\n\n useEffect(() => {\n if (autoHeight && textareaRef.current !== null) {\n syncHeight(textareaRef.current)\n }\n }, [autoHeight, syncHeight])\n\n return (\n <TextFieldRoot className={className} isDisabled={disabled}>\n <TextFieldLabel\n label={label}\n requiredText={requiredText}\n required={required}\n subLabel={subLabel}\n {...labelProps}\n {...(showLabel ? visuallyHiddenProps : {})}\n />\n <StyledTextareaContainer rows={rows}>\n <StyledTextarea\n ref={mergeRefs(textareaRef, forwardRef, ariaRef)}\n invalid={invalid}\n rows={rows}\n {...inputProps}\n />\n {showCount && <MultiLineCounter>{count}</MultiLineCounter>}\n </StyledTextareaContainer>\n {assistiveText != null && assistiveText.length !== 0 && (\n <AssistiveText\n invalid={invalid}\n {...(invalid ? errorMessageProps : descriptionProps)}\n >\n {assistiveText}\n </AssistiveText>\n )}\n </TextFieldRoot>\n )\n})\n\nconst TextFieldRoot = styled.div<{ isDisabled: boolean }>`\n display: flex;\n flex-direction: column;\n\n ${(p) => p.isDisabled && { opacity: p.theme.elementEffect.disabled.opacity }}\n`\n\nconst TextFieldLabel = styled(FieldLabel)`\n ${theme((o) => o.margin.bottom(8))}\n`\n\nconst StyledInputContainer = styled.div`\n height: 40px;\n display: grid;\n position: relative;\n`\n\nconst StyledInput = styled.input<{ invalid: boolean }>`\n border: none;\n box-sizing: border-box;\n outline: none;\n\n /* Prevent zooming for iOS Safari */\n transform-origin: top left;\n transform: scale(0.875);\n width: calc(100% / 0.875);\n height: calc(40px / 0.875);\n font-size: calc(14px / 0.875);\n line-height: calc(22px / 0.875);\n padding: calc(9px / 0.875) calc(8px / 0.875);\n border-radius: calc(4px / 0.875);\n\n /* Display box-shadow for iOS Safari */\n appearance: none;\n\n ${(p) =>\n theme((o) => [\n o.bg.surface3.hover,\n o.outline.default.focus,\n p.invalid && o.outline.assertive,\n o.font.text2,\n ])}\n\n &::placeholder {\n ${theme((o) => o.font.text3)}\n }\n`\n\nconst StyledTextareaContainer = styled.div<{ rows: number }>`\n display: grid;\n position: relative;\n\n ${({ rows }) => css`\n max-height: calc(22px * ${rows} + 18px);\n `};\n`\n\nconst StyledTextarea = styled.textarea<{ invalid: boolean }>`\n border: none;\n box-sizing: border-box;\n outline: none;\n resize: none;\n\n /* Prevent zooming for iOS Safari */\n transform-origin: top left;\n transform: scale(0.875);\n width: calc(100% / 0.875);\n font-size: calc(14px / 0.875);\n line-height: calc(22px / 0.875);\n padding: calc(9px / 0.875) calc(8px / 0.875);\n border-radius: calc(4px / 0.875);\n\n ${({ rows }) => css`\n height: calc(22px / 0.875 * ${rows} + 18px / 0.875);\n `};\n\n /* Display box-shadow for iOS Safari */\n appearance: none;\n\n ${(p) =>\n theme((o) => [\n o.bg.surface3.hover,\n o.outline.default.focus,\n p.invalid && o.outline.assertive,\n o.font.text2,\n ])}\n\n &::placeholder {\n ${theme((o) => o.font.text3)}\n }\n\n /* Hide scrollbar for Chrome, Safari and Opera */\n &::-webkit-scrollbar {\n display: none;\n }\n /* Hide scrollbar for IE, Edge and Firefox */\n -ms-overflow-style: none; /* IE and Edge */\n scrollbar-width: none; /* Firefox */\n`\n\nconst SingleLineCounter = styled.span`\n position: absolute;\n top: 50%;\n right: 8px;\n transform: translateY(-50%);\n\n ${theme((o) => [o.typography(14).preserveHalfLeading, o.font.text3])}\n`\n\nconst MultiLineCounter = styled.span`\n position: absolute;\n bottom: 9px;\n right: 8px;\n\n ${theme((o) => [o.typography(14).preserveHalfLeading, o.font.text3])}\n`\n\nconst AssistiveText = styled.p<{ invalid: boolean }>`\n ${(p) =>\n theme((o) => [\n o.typography(14),\n o.margin.top(8),\n o.margin.bottom(0),\n o.font[p.invalid ? 'assertive' : 'text1'],\n ])}\n`\n"],"names":["DefaultValue","Link","React","forwardRef","ref","to","children","rest","href","ComponentAbstractionContext","createContext","ComponentAbstraction","Provider","value","components","useComponentAbstraction","useContext","theme","createTheme","styled","Clickable","props","onClick","disabled","A","as","undefined","Button","clickableCss","css","disabledSelector","button","span","variant","size","fixed","StyledButton","withConfig","shouldForwardProp","prop","attrs","font","background","Error","arguments","length","JSON","stringify","unreachable","variantToProps","height","padding","sizeToProps","p","o","hover","press","bg","typography","bold","preserveHalfLeading","horizontal","borderRadius","outline","focus","IconButton","icon","requiredIconSize","result","exec","iconSize","console","warn","validateIconSize","StyledIconButton","name","width","Radio","forceChecked","RadioGroupContext","selected","isParentDisabled","readonly","hasError","onChange","warning","isSelected","isDisabled","isReadonly","handleChange","useCallback","e","currentTarget","RadioRoot","RadioInput","checked","RadioLabel","label","px","spacing","input","type","text5","assertive","color","text4","brand","div","StyledRadioGroup","RadioGroup","className","useState","defaultValue","setSelected","next","role","SwitchCheckbox","ariaSwitchProps","useMemo","state","useToggleState","useRef","useSwitch","inputProps","Label","SwitchInput","LabelInner","FieldLabel","style","required","requiredText","subLabel","labelProps","FieldLabelWrapper","RequiredText","SubLabelClickable","text1","text3","margin","left","mergeRefs","current","countStringInCodePoints","string","TextField","multiline","MultiLineTextField","SingleLineTextField","showLabel","showCount","invalid","assistiveText","maxLength","visuallyHiddenProps","useVisuallyHidden","ariaRef","count","setCount","useTextField","inputElementType","isRequired","validationState","description","errorMessage","descriptionProps","errorMessageProps","TextFieldRoot","TextFieldLabel","StyledInputContainer","StyledInput","SingleLineCounter","AssistiveText","autoHeight","rows","initialRows","textareaRef","setRows","syncHeight","textarea","match","_$match","useEffect","StyledTextareaContainer","StyledTextarea","MultiLineCounter","opacity","elementEffect","bottom","surface3","text2","top"],"mappings":"wrDAuBMA,EAA2B,CAC/BC,KAfyBC,EAAMC,WAC/B,WAAgDC,OAAzBC,IAAAA,GAAIC,IAAAA,SAAaC,sBACtC,OACEL,uBAAGM,KAAMH,EAAID,IAAKA,GAASG,GACxBD,MAcHG,EAA8BP,EAAMQ,cAAcV,YAOhCW,SAAuBL,IAAAA,sBAC7C,OACEJ,gBAACO,EAA4BG,UAC3BC,WAAYb,IAHuCc,aAKlDR,YAKSS,IACd,OAAOC,EAAWP,yBC3CPQ,EAAQC,EAAYC,4BCyB3BC,EAAYlB,EAAMC,WACtB,SAAmBkB,EAAOjB,GACxB,IAAQH,EAASc,IAATd,KACR,GAAI,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,SAACqC,SAAM,CACXA,EAAEG,GAAGmI,SAASrI,MACdD,EAAES,gBAAgBC,MAClBX,EAAEiG,SAAWhG,EAAES,QAAQwC,UACvBjD,EAAEb,KAAKoJ,UAIP5K,GAAM,SAACqC,UAAMA,EAAEb,KAAKgG,SAIpB6C,GAA0BnK,EAAOwF,0EAInC,gBAAGkE,IAAAA,YAAWhJ,iEACYgJ,KAIxBU,GAAiBpK,EAAO+J,qvBAe1B,gBAAGL,IAAAA,YAAWhJ,6EACgBgJ,IAM9B,SAACxH,UACDpC,GAAM,SAACqC,SAAM,CACXA,EAAEG,GAAGmI,SAASrI,MACdD,EAAES,gBAAgBC,MAClBX,EAAEiG,SAAWhG,EAAES,QAAQwC,UACvBjD,EAAEb,KAAKoJ,UAIP5K,GAAM,SAACqC,UAAMA,EAAEb,KAAKgG,SAYpBiC,GAAoBvJ,EAAOa,oHAM7Bf,GAAM,SAACqC,SAAM,CAACA,EAAEI,WAAW,IAAIE,oBAAqBN,EAAEb,KAAKgG,UAGzD+C,GAAmBrK,EAAOa,uFAK5Bf,GAAM,SAACqC,SAAM,CAACA,EAAEI,WAAW,IAAIE,oBAAqBN,EAAEb,KAAKgG,UAGzDkC,GAAgBxJ,EAAOkC,4BACzB,SAACA,UACDpC,GAAM,SAACqC,SAAM,CACXA,EAAEI,WAAW,IACbJ,EAAEoF,OAAOoD,IAAI,GACbxI,EAAEoF,OAAOiD,OAAO,GAChBrI,EAAEb,KAAKY,EAAEiG,QAAU,YAAc"}
1
+ {"version":3,"file":"index.module.js","sources":["../src/core/ComponentAbstraction.tsx","../src/styled.ts","../src/components/Clickable/index.tsx","../src/components/Button/index.tsx","../src/_lib/index.ts","../src/components/IconButton/index.tsx","../src/components/Radio/index.tsx","../src/components/Select/context.ts","../src/components/Select/index.tsx","../src/components/Switch/index.tsx","../src/components/FieldLabel/index.tsx","../src/components/TextField/index.tsx"],"sourcesContent":["import React, { useContext } from 'react'\n\nexport type LinkProps = {\n /**\n * リンクのURL\n */\n to: string\n} & Omit<React.ComponentPropsWithoutRef<'a'>, 'href'>\n\nexport const DefaultLink = React.forwardRef<HTMLAnchorElement, LinkProps>(\n function DefaultLink({ to, children, ...rest }, ref) {\n return (\n <a href={to} ref={ref} {...rest}>\n {children}\n </a>\n )\n }\n)\n\ninterface Components {\n Link: React.ComponentType<React.ComponentPropsWithRef<typeof DefaultLink>>\n}\n\nconst DefaultValue: Components = {\n Link: DefaultLink,\n}\n\nconst ComponentAbstractionContext = React.createContext(DefaultValue)\n\ninterface Props {\n children: React.ReactNode\n components: Partial<Components>\n}\n\nexport default function ComponentAbstraction({ children, components }: Props) {\n return (\n <ComponentAbstractionContext.Provider\n value={{ ...DefaultValue, ...components }}\n >\n {children}\n </ComponentAbstractionContext.Provider>\n )\n}\n\nexport function useComponentAbstraction() {\n return useContext(ComponentAbstractionContext)\n}\n","import styled from 'styled-components'\nimport createTheme from '@charcoal-ui/styled'\nexport const theme = createTheme(styled)\n","import React from 'react'\nimport styled, { css } from 'styled-components'\nimport {\n LinkProps,\n useComponentAbstraction,\n} from '../../core/ComponentAbstraction'\nimport { disabledSelector } from '@charcoal-ui/utils'\n\ninterface BaseProps {\n /**\n * クリックの無効化\n */\n disabled?: boolean\n}\n\ninterface LinkBaseProps {\n /**\n * リンクのURL。指定するとbuttonタグではなくaタグとして描画される\n */\n to: string\n}\n\nexport type ClickableProps =\n | (BaseProps & Omit<React.ComponentPropsWithoutRef<'button'>, 'disabled'>)\n | (BaseProps & LinkBaseProps & Omit<LinkProps, 'to'>)\nexport type ClickableElement = HTMLButtonElement & HTMLAnchorElement\n\nconst Clickable = React.forwardRef<ClickableElement, ClickableProps>(\n function Clickable(props, ref) {\n const { Link } = useComponentAbstraction()\n if ('to' in props) {\n const { onClick, disabled = false, ...rest } = props\n return (\n <A<typeof Link>\n {...rest}\n as={disabled ? undefined : Link}\n onClick={disabled ? undefined : onClick}\n aria-disabled={disabled}\n ref={ref}\n />\n )\n } else {\n return <Button {...props} ref={ref} />\n }\n }\n)\nexport default Clickable\n\nconst clickableCss = css`\n /* Clickable style */\n cursor: pointer;\n\n ${disabledSelector} {\n cursor: default;\n }\n`\n\nconst Button = styled.button`\n /* Reset button appearance */\n appearance: none;\n background: transparent;\n padding: 0;\n border-style: none;\n outline: none;\n color: inherit;\n text-rendering: inherit;\n letter-spacing: inherit;\n word-spacing: inherit;\n\n &:focus {\n outline: none;\n }\n\n /* Change the font styles in all browsers. */\n font: inherit;\n\n /* Remove the margin in Firefox and Safari. */\n margin: 0;\n\n /* Show the overflow in Edge. */\n overflow: visible;\n\n /* Remove the inheritance of text transform in Firefox. */\n text-transform: none;\n\n /* Remove the inner border and padding in Firefox. */\n &::-moz-focus-inner {\n border-style: none;\n padding: 0;\n }\n\n ${clickableCss}\n`\n\nconst A = styled.span`\n /* Reset a-tag appearance */\n color: inherit;\n\n &:focus {\n outline: none;\n }\n\n .text {\n top: calc(1em + 2em);\n }\n\n ${clickableCss}\n`\n","import React from 'react'\nimport styled from 'styled-components'\nimport { unreachable } from '../../_lib'\nimport { theme } from '../../styled'\nimport Clickable, { ClickableElement, ClickableProps } from '../Clickable'\n\ntype Variant = 'Primary' | 'Default' | 'Overlay' | 'Danger' | 'Navigation'\ntype Size = 'S' | 'M'\n\ninterface StyledProps {\n /**\n * ボタンのスタイル\n */\n variant: Variant\n /**\n * ボタンのサイズ\n */\n size: Size\n /**\n * 幅を最大まで広げて描画\n */\n fixed: boolean\n}\n\nexport type ButtonProps = Partial<StyledProps> & ClickableProps\n\nconst Button = React.forwardRef<ClickableElement, ButtonProps>(function Button(\n {\n children,\n variant = 'Default',\n size = 'M',\n fixed = false,\n disabled = false,\n ...rest\n },\n ref\n) {\n return (\n <StyledButton\n {...rest}\n disabled={disabled}\n variant={variant}\n size={size}\n fixed={fixed}\n ref={ref}\n >\n {children}\n </StyledButton>\n )\n})\nexport default Button\n\nconst StyledButton = styled(Clickable)\n .withConfig<StyledProps>({\n shouldForwardProp(prop) {\n // fixed は <button> 要素に渡ってはいけない\n return prop !== 'fixed'\n },\n })\n .attrs<StyledProps, ReturnType<typeof styledProps>>(styledProps)`\n width: ${(p) => (p.fixed ? 'stretch' : 'min-content')};\n display: inline-grid;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n user-select: none;\n white-space: nowrap;\n\n ${(p) =>\n theme((o) => [\n o.font[p.font].hover.press,\n o.bg[p.background].hover.press,\n o.typography(14).bold.preserveHalfLeading,\n o.padding.horizontal(p.padding),\n o.disabled,\n o.borderRadius('oval'),\n o.outline.default.focus,\n ])}\n\n /* よく考えたらheight=32って定義が存在しないな... */\n height: ${(p) => p.height}px;\n`\n\nfunction styledProps(props: StyledProps) {\n return {\n ...props,\n ...variantToProps(props.variant),\n ...sizeToProps(props.size),\n }\n}\n\nfunction variantToProps(variant: Variant) {\n switch (variant) {\n case 'Overlay':\n return { font: 'text5', background: 'surface4' } as const\n case 'Default':\n return { font: 'text2', background: 'surface3' } as const\n case 'Primary':\n return { font: 'text5', background: 'brand' } as const\n case 'Navigation':\n return { font: 'text5', background: 'surface6' } as const\n case 'Danger':\n return { font: 'text5', background: 'assertive' } as const\n default:\n return unreachable(variant)\n }\n}\n\nfunction sizeToProps(size: Size) {\n switch (size) {\n case 'S':\n return {\n height: 32,\n padding: 16,\n } as const\n case 'M':\n return {\n height: 40,\n padding: 24,\n } as const\n }\n}\n","/**\n * 今後ポートされる予定の汎用的な関数群\n */\n\n/**\n * Function used to assert a given code path is unreachable\n */\nexport function unreachable(): never\n/**\n * Function used to assert a given code path is unreachable.\n * Very useful for ensuring switches are exhaustive:\n *\n * ```ts\n * switch (a.type) {\n * case Types.A:\n * case Types.B:\n * break\n * default:\n * unreachable(a) // will cause a build error if there was\n * // a Types.C that was not checked\n * }\n * ```\n *\n * @param value Value to be asserted as unreachable\n */\n// NOTE: Uses separate overloads, _not_ `value?: never`, to not allow `undefined` to be passed\n// eslint-disable-next-line @typescript-eslint/unified-signatures\nexport function unreachable(value: never): never\nexport function unreachable(value?: never): never {\n throw new Error(\n arguments.length === 0\n ? 'unreachable'\n : `unreachable (${JSON.stringify(value)})`\n )\n}\n","import React from 'react'\nimport styled from 'styled-components'\nimport { theme } from '../../styled'\nimport Clickable, { ClickableElement, ClickableProps } from '../Clickable'\nimport type { KnownIconType } from '@charcoal-ui/icons'\n\ntype Variant = 'Default' | 'Overlay'\ntype Size = 'XS' | 'S' | 'M'\n\ninterface StyledProps {\n readonly variant?: Variant\n readonly size?: Size\n readonly icon: keyof KnownIconType\n}\n\nexport type IconButtonProps = StyledProps & ClickableProps\n\nconst IconButton = React.forwardRef<ClickableElement, IconButtonProps>(\n function IconButtonInner(\n { variant = 'Default', size = 'M', icon, ...rest }: IconButtonProps,\n ref\n ) {\n validateIconSize(size, icon)\n return (\n <StyledIconButton {...rest} ref={ref} variant={variant} size={size}>\n <pixiv-icon name={icon} />\n </StyledIconButton>\n )\n }\n)\n\nexport default IconButton\n\nconst StyledIconButton = styled(Clickable).attrs<\n Required<StyledProps>,\n ReturnType<typeof styledProps>\n>(styledProps)`\n user-select: none;\n\n width: ${(p) => p.width}px;\n height: ${(p) => p.height}px;\n display: flex;\n align-items: center;\n justify-content: center;\n\n ${({ font, background }) =>\n theme((o) => [\n o.font[font],\n o.bg[background].hover.press,\n o.disabled,\n o.borderRadius('oval'),\n o.outline.default.focus,\n ])}\n`\n\nfunction styledProps(props: Required<StyledProps>) {\n return {\n ...props,\n ...variantToProps(props.variant),\n ...sizeToProps(props.size),\n }\n}\n\nfunction variantToProps(variant: Variant) {\n switch (variant) {\n case 'Default':\n return { font: 'text3', background: 'transparent' } as const\n case 'Overlay':\n return { font: 'text5', background: 'surface4' } as const\n }\n}\n\nfunction sizeToProps(size: Size) {\n switch (size) {\n case 'XS':\n return {\n width: 20,\n height: 20,\n }\n case 'S':\n return {\n width: 32,\n height: 32,\n }\n case 'M':\n return {\n width: 40,\n height: 40,\n }\n }\n}\n\n/**\n * validates matches of size and icon\n */\nfunction validateIconSize(size: Size, icon: keyof KnownIconType) {\n let requiredIconSize: string\n switch (size) {\n case 'XS':\n requiredIconSize = '16'\n break\n case 'S':\n case 'M':\n requiredIconSize = '24'\n break\n }\n // アイコン名は サイズ/名前\n const result = /^\\d*/u.exec(icon)\n if (result == null) {\n throw new Error('Invalid icon name')\n }\n const [iconSize] = result\n if (iconSize !== requiredIconSize) {\n // eslint-disable-next-line no-console\n console.warn(\n `IconButton with size \"${size}\" expect icon size \"${requiredIconSize}, but got \"${iconSize}\"`\n )\n }\n}\n","import React, { useCallback, useContext } from 'react'\nimport styled from 'styled-components'\nimport warning from 'warning'\nimport { theme } from '../../styled'\nimport { px } from '@charcoal-ui/utils'\n\nexport type RadioProps = React.PropsWithChildren<{\n value: string\n forceChecked?: boolean\n disabled?: boolean\n}>\n\nexport default function Radio({\n value,\n forceChecked = false,\n disabled = false,\n children,\n}: RadioProps) {\n const {\n name,\n selected,\n disabled: isParentDisabled,\n readonly,\n hasError,\n onChange,\n } = useContext(RadioGroupContext)\n\n warning(\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n name !== undefined,\n `\"name\" is not Provided for <Radio>. Perhaps you forgot to wrap with <RadioGroup> ?`\n )\n\n const isSelected = value === selected\n const isDisabled = disabled || isParentDisabled\n const isReadonly = readonly && !isSelected\n\n const handleChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n onChange(e.currentTarget.value)\n },\n [onChange]\n )\n\n return (\n <RadioRoot aria-disabled={isDisabled || isReadonly}>\n <RadioInput\n name={name}\n value={value}\n checked={forceChecked || isSelected}\n hasError={hasError}\n onChange={handleChange}\n disabled={isDisabled || isReadonly}\n />\n {children != null && <RadioLabel>{children}</RadioLabel>}\n </RadioRoot>\n )\n}\n\nconst RadioRoot = styled.label`\n display: grid;\n grid-template-columns: auto 1fr;\n grid-gap: ${({ theme }) => px(theme.spacing[4])};\n align-items: center;\n cursor: pointer;\n\n ${theme((o) => [o.disabled])}\n`\n\nexport const RadioInput = styled.input.attrs({ type: 'radio' })<{\n hasError?: boolean\n}>`\n /** Make prior to browser default style */\n &[type='radio'] {\n appearance: none;\n display: block;\n box-sizing: border-box;\n\n padding: 6px;\n\n width: 20px;\n height: 20px;\n\n ${({ hasError = false }) =>\n theme((o) => [\n o.borderRadius('oval'),\n o.bg.text5.hover.press,\n hasError && o.outline.assertive,\n ])};\n\n &:not(:checked) {\n border-width: 2px;\n border-style: solid;\n border-color: ${({ theme }) => theme.color.text4};\n }\n\n &:checked {\n ${theme((o) => o.bg.brand.hover.press)}\n\n &::after {\n content: '';\n display: block;\n width: 8px;\n height: 8px;\n pointer-events: none;\n\n ${theme((o) => [o.bg.text5.hover.press, o.borderRadius('oval')])}\n }\n }\n\n ${theme((o) => o.outline.default.focus)}\n }\n`\n\nconst RadioLabel = styled.div`\n ${theme((o) => [o.typography(14)])}\n`\n\nexport type RadioGroupProps = React.PropsWithChildren<{\n className?: string\n value?: string\n label: string\n name: string\n onChange(next: string): void\n disabled?: boolean\n readonly?: boolean\n hasError?: boolean\n}>\n\n// TODO: use (or polyfill) flex gap\nconst StyledRadioGroup = styled.div`\n display: grid;\n grid-template-columns: 1fr;\n grid-gap: ${({ theme }) => px(theme.spacing[8])};\n`\n\ninterface RadioGroupContext {\n name: string\n selected?: string\n disabled: boolean\n readonly: boolean\n hasError: boolean\n onChange: (next: string) => void\n}\n\nconst RadioGroupContext = React.createContext<RadioGroupContext>({\n name: undefined as never,\n selected: undefined,\n disabled: false,\n readonly: false,\n hasError: false,\n onChange() {\n throw new Error(\n 'Cannot find onChange() handler. Perhaps you forgot to wrap with <RadioGroup> ?'\n )\n },\n})\n\nexport function RadioGroup({\n className,\n value,\n label,\n name,\n onChange,\n disabled,\n readonly,\n hasError,\n children,\n}: RadioGroupProps) {\n const handleChange = useCallback(\n (next: string) => {\n onChange(next)\n },\n [onChange]\n )\n\n return (\n <RadioGroupContext.Provider\n value={{\n name,\n selected: value,\n disabled: disabled ?? false,\n readonly: readonly ?? false,\n hasError: hasError ?? false,\n onChange: handleChange,\n }}\n >\n <StyledRadioGroup\n role=\"radiogroup\"\n aria-orientation=\"vertical\"\n aria-label={label}\n aria-invalid={hasError}\n className={className}\n >\n {children}\n </StyledRadioGroup>\n </RadioGroupContext.Provider>\n )\n}\n","import { createContext } from 'react'\n\ntype SelectGroupContext = {\n name: string\n selected: string[]\n disabled: boolean\n readonly: boolean\n hasError: boolean\n onChange: ({ value, selected }: { value: string; selected: boolean }) => void\n}\n\nexport const SelectGroupContext = createContext<SelectGroupContext>({\n name: undefined as never,\n selected: [],\n disabled: false,\n readonly: false,\n hasError: false,\n onChange() {\n throw new Error(\n 'Cannot find `onChange()` handler. Perhaps you forgot to wrap it with `<SelectGroup />` ?'\n )\n },\n})\n","import React, { ChangeEvent, useCallback, useContext } from 'react'\nimport styled, { css } from 'styled-components'\nimport warning from 'warning'\nimport { theme } from '../../styled'\nimport { disabledSelector, px } from '@charcoal-ui/utils'\n\nimport { SelectGroupContext } from './context'\n\nexport type SelectProps = React.PropsWithChildren<{\n value: string\n forceChecked?: boolean\n disabled?: boolean\n variant?: 'default' | 'overlay'\n onChange?: (payload: { value: string; selected: boolean }) => void\n}>\n\nexport default function Select({\n value,\n forceChecked = false,\n disabled = false,\n onChange,\n variant = 'default',\n children,\n}: SelectProps) {\n const {\n name,\n selected,\n disabled: parentDisabled,\n readonly,\n hasError,\n onChange: parentOnChange,\n } = useContext(SelectGroupContext)\n\n warning(\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n name !== undefined,\n `\"name\" is not Provided for <Select>. Perhaps you forgot to wrap with <SelectGroup> ?`\n )\n\n const isSelected = selected.includes(value) || forceChecked\n const isDisabled = disabled || parentDisabled || readonly\n\n const handleChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n if (!(event.currentTarget instanceof HTMLInputElement)) {\n return\n }\n if (onChange) onChange({ value, selected: event.currentTarget.checked })\n parentOnChange({ value, selected: event.currentTarget.checked })\n },\n [onChange, parentOnChange, value]\n )\n\n return (\n <SelectRoot aria-disabled={isDisabled}>\n <SelectInput\n {...{\n name,\n value,\n hasError,\n }}\n checked={isSelected}\n disabled={isDisabled}\n onChange={handleChange}\n overlay={variant === 'overlay'}\n aria-invalid={hasError}\n />\n <SelectInputOverlay\n overlay={variant === 'overlay'}\n hasError={hasError}\n aria-hidden={true}\n >\n <pixiv-icon name=\"24/Check\" unsafe-non-guideline-scale={16 / 24} />\n </SelectInputOverlay>\n {Boolean(children) && <SelectLabel>{children}</SelectLabel>}\n </SelectRoot>\n )\n}\n\nconst SelectRoot = styled.label`\n display: grid;\n grid-template-columns: auto 1fr;\n align-items: center;\n position: relative;\n cursor: pointer;\n ${disabledSelector} {\n cursor: default;\n }\n gap: ${({ theme }) => px(theme.spacing[4])};\n ${theme((o) => o.disabled)}\n`\n\nconst SelectLabel = styled.div`\n display: flex;\n align-items: center;\n ${theme((o) => [o.typography(14), o.font.text1])}\n`\n\nconst SelectInput = styled.input.attrs({ type: 'checkbox' })<{\n hasError: boolean\n overlay: boolean\n}>`\n &[type='checkbox'] {\n appearance: none;\n display: block;\n width: 20px;\n height: 20px;\n margin: 0;\n\n &:checked {\n ${theme((o) => o.bg.brand.hover.press)}\n }\n\n ${({ hasError, overlay }) =>\n theme((o) => [\n o.bg.text3.hover.press,\n o.borderRadius('oval'),\n hasError && !overlay && o.outline.assertive,\n overlay && o.bg.surface4,\n ])};\n }\n`\n\nconst SelectInputOverlay = styled.div<{ overlay: boolean; hasError: boolean }>`\n position: absolute;\n top: -2px;\n left: -2px;\n box-sizing: border-box;\n display: flex;\n align-items: center;\n justify-content: center;\n\n ${({ hasError, overlay }) =>\n theme((o) => [\n o.width.px(24),\n o.height.px(24),\n o.borderRadius('oval'),\n o.font.text5,\n hasError && overlay && o.outline.assertive,\n ])}\n\n ${({ overlay }) =>\n overlay &&\n css`\n border-color: ${({ theme }) => theme.color.text5};\n border-width: 2px;\n border-style: solid;\n `}\n`\n\nexport type SelectGroupProps = React.PropsWithChildren<{\n className?: string\n name: string\n ariaLabel: string\n selected: string[]\n onChange: (selected: string[]) => void\n disabled?: boolean\n readonly?: boolean\n hasError?: boolean\n}>\n\nexport function SelectGroup({\n className,\n name,\n ariaLabel,\n selected,\n onChange,\n disabled = false,\n readonly = false,\n hasError = false,\n children,\n}: SelectGroupProps) {\n const handleChange = useCallback(\n (payload: { value: string; selected: boolean }) => {\n const index = selected.indexOf(payload.value)\n\n if (payload.selected) {\n if (index < 0) {\n onChange([...selected, payload.value])\n }\n } else {\n if (index >= 0) {\n onChange([...selected.slice(0, index), ...selected.slice(index + 1)])\n }\n }\n },\n [onChange, selected]\n )\n\n return (\n <SelectGroupContext.Provider\n value={{\n name,\n selected: Array.from(new Set(selected)),\n disabled,\n readonly,\n hasError,\n onChange: handleChange,\n }}\n >\n <div\n className={className}\n aria-label={ariaLabel}\n data-testid=\"SelectGroup\"\n >\n {children}\n </div>\n </SelectGroupContext.Provider>\n )\n}\n","import { useSwitch } from '@react-aria/switch'\nimport type { AriaSwitchProps } from '@react-types/switch'\nimport React, { useRef, useMemo } from 'react'\nimport { useToggleState } from 'react-stately'\nimport styled from 'styled-components'\nimport { theme } from '../../styled'\nimport { disabledSelector, px } from '@charcoal-ui/utils'\n\nexport type SwitchProps = {\n name: string\n className?: string\n value?: string\n checked?: boolean\n disabled?: boolean\n onChange(checked: boolean): void\n} & (\n | // children か label は片方が必須\n {\n children: React.ReactNode\n }\n | {\n label: string\n }\n)\n\nexport default function SwitchCheckbox(props: SwitchProps) {\n const { disabled, className } = props\n\n const ariaSwitchProps: AriaSwitchProps = useMemo(\n () => ({\n ...props,\n\n // children がいない場合は aria-label をつけないといけない\n 'aria-label': 'children' in props ? undefined : props.label,\n isDisabled: props.disabled,\n isSelected: props.checked,\n }),\n [props]\n )\n\n const state = useToggleState(ariaSwitchProps)\n const ref = useRef<HTMLInputElement>(null)\n const {\n inputProps: { className: _className, type: _type, ...rest },\n } = useSwitch(ariaSwitchProps, state, ref)\n\n return (\n <Label className={className} aria-disabled={disabled}>\n <SwitchInput {...rest} ref={ref} />\n {'children' in props ? (\n // eslint-disable-next-line react/destructuring-assignment\n <LabelInner>{props.children}</LabelInner>\n ) : undefined}\n </Label>\n )\n}\n\nconst Label = styled.label`\n display: inline-grid;\n grid-template-columns: auto 1fr;\n gap: ${({ theme }) => px(theme.spacing[4])};\n cursor: pointer;\n outline: 0;\n\n ${theme((o) => o.disabled)}\n\n ${disabledSelector} {\n cursor: default;\n }\n`\n\nconst LabelInner = styled.div`\n ${theme((o) => o.typography(14))}\n`\n\nconst SwitchInput = styled.input.attrs({\n type: 'checkbox',\n})`\n &[type='checkbox'] {\n appearance: none;\n display: inline-flex;\n position: relative;\n box-sizing: border-box;\n width: 28px;\n border: 2px solid transparent;\n transition: box-shadow 0.2s, background-color 0.2s;\n cursor: inherit;\n ${theme((o) => [\n o.borderRadius(16),\n o.height.px(16),\n o.bg.text4.hover.press,\n o.outline.default.focus,\n ])}\n\n &::after {\n content: '';\n position: absolute;\n display: block;\n top: 0;\n left: 0;\n width: 12px;\n height: 12px;\n transform: translateX(0);\n transition: transform 0.2s;\n ${theme((o) => [o.bg.text5.hover.press, o.borderRadius('oval')])}\n }\n\n &:checked {\n ${theme((o) => o.bg.brand.hover.press)}\n\n &::after {\n transform: translateX(12px);\n }\n }\n }\n`\n","import React from 'react'\nimport styled from 'styled-components'\nimport createTheme from '@charcoal-ui/styled'\n\nexport interface FieldLabelProps\n extends React.LabelHTMLAttributes<HTMLLabelElement> {\n readonly className?: string\n readonly label: string\n readonly subLabel?: React.ReactNode\n readonly required?: boolean\n // TODO: 翻訳用のContextで注入する\n readonly requiredText?: string\n}\n\nconst FieldLabel = React.forwardRef<HTMLLabelElement, FieldLabelProps>(\n function FieldLabel(\n {\n style,\n className,\n label,\n required = false,\n requiredText,\n subLabel,\n ...labelProps\n },\n ref\n ) {\n return (\n <FieldLabelWrapper style={style} className={className}>\n <Label ref={ref} {...labelProps}>\n {label}\n </Label>\n {required && <RequiredText>{requiredText}</RequiredText>}\n <SubLabelClickable>\n <span>{subLabel}</span>\n </SubLabelClickable>\n </FieldLabelWrapper>\n )\n }\n)\n\nexport default FieldLabel\n\nconst theme = createTheme(styled)\n\nconst Label = styled.label`\n ${theme((o) => [o.typography(14).bold, o.font.text1])}\n`\n\nconst RequiredText = styled.span`\n ${theme((o) => [o.typography(14), o.font.text3])}\n`\n\nconst SubLabelClickable = styled.div`\n ${theme((o) => [\n o.typography(14),\n o.font.text3.hover.press,\n o.outline.default.focus,\n ])}\n`\n\nconst FieldLabelWrapper = styled.div`\n display: inline-flex;\n align-items: center;\n\n > ${RequiredText} {\n ${theme((o) => o.margin.left(4))}\n }\n\n > ${SubLabelClickable} {\n ${theme((o) => o.margin.left('auto'))}\n }\n`\n","import { useTextField } from '@react-aria/textfield'\nimport { useVisuallyHidden } from '@react-aria/visually-hidden'\nimport React, { useCallback, useEffect, useRef, useState } from 'react'\nimport styled, { css } from 'styled-components'\nimport FieldLabel, { FieldLabelProps } from '../FieldLabel'\nimport createTheme from '@charcoal-ui/styled'\n\nconst theme = createTheme(styled)\n\ninterface TextFieldBaseProps\n extends Pick<FieldLabelProps, 'label' | 'requiredText' | 'subLabel'> {\n readonly className?: string\n readonly defaultValue?: string\n readonly value?: string\n readonly onChange?: (value: string) => void\n readonly showCount?: boolean\n readonly showLabel?: boolean\n readonly placeholder?: string\n readonly assistiveText?: string\n readonly disabled?: boolean\n readonly required?: boolean\n readonly invalid?: boolean\n readonly maxLength?: number\n /**\n * tab-indexがー1かどうか\n */\n readonly excludeFromTabOrder?: boolean\n}\n\nexport interface SingleLineTextFieldProps extends TextFieldBaseProps {\n readonly autoHeight?: never\n readonly multiline?: false\n readonly rows?: never\n readonly type?: string\n readonly prefix?: string\n readonly suffix?: string\n}\n\nexport interface MultiLineTextFieldProps extends TextFieldBaseProps {\n readonly autoHeight?: boolean\n readonly multiline: true\n readonly rows?: number\n readonly type?: never\n readonly prefix?: never\n readonly suffix?: never\n}\n\nexport type TextFieldProps = SingleLineTextFieldProps | MultiLineTextFieldProps\ntype TextFieldElement = HTMLInputElement & HTMLTextAreaElement\n\nfunction mergeRefs<T>(...refs: React.Ref<T>[]): React.RefCallback<T> {\n return (value) => {\n for (const ref of refs) {\n if (typeof ref === 'function') {\n ref(value)\n } else if (ref !== null) {\n ;(ref as React.MutableRefObject<T | null>).current = value\n }\n }\n }\n}\n\nfunction countCodePointsInString(string: string) {\n // [...string] とするとproduction buildで動かなくなる\n // cf. https://twitter.com/f_subal/status/1497214727511891972\n return Array.from(string).length\n}\n\nconst TextField = React.forwardRef<TextFieldElement, TextFieldProps>(\n function TextField(props, ref) {\n return props.multiline !== undefined && props.multiline ? (\n <MultiLineTextField ref={ref} {...props} />\n ) : (\n <SingleLineTextField ref={ref} {...props} />\n )\n }\n)\n\nexport default TextField\n\nconst SingleLineTextField = React.forwardRef<\n HTMLInputElement,\n SingleLineTextFieldProps\n>(function SingleLineTextFieldInner({ onChange, ...props }, forwardRef) {\n const {\n className,\n showLabel = false,\n showCount = false,\n label,\n requiredText,\n subLabel,\n disabled = false,\n required,\n invalid = false,\n assistiveText,\n maxLength,\n prefix = '',\n suffix = '',\n } = props\n\n const { visuallyHiddenProps } = useVisuallyHidden()\n const ariaRef = useRef<HTMLInputElement>(null)\n const prefixRef = useRef<HTMLSpanElement>(null)\n const suffixRef = useRef<HTMLSpanElement>(null)\n const [count, setCount] = useState(countCodePointsInString(props.value ?? ''))\n const [prefixWidth, setPrefixWidth] = useState(0)\n const [suffixWidth, setSuffixWidth] = useState(0)\n\n const nonControlled = props.value === undefined\n const handleChange = useCallback(\n (value: string) => {\n const count = countCodePointsInString(value)\n if (maxLength !== undefined && count > maxLength) {\n return\n }\n if (nonControlled) {\n setCount(count)\n }\n onChange?.(value)\n },\n [maxLength, nonControlled, onChange]\n )\n\n useEffect(() => {\n setCount(countCodePointsInString(props.value ?? ''))\n }, [props.value])\n\n const { inputProps, labelProps, descriptionProps, errorMessageProps } =\n useTextField(\n {\n inputElementType: 'input',\n isDisabled: disabled,\n isRequired: required,\n validationState: invalid ? 'invalid' : 'valid',\n description: !invalid && assistiveText,\n errorMessage: invalid && assistiveText,\n onChange: handleChange,\n ...props,\n },\n ariaRef\n )\n\n useEffect(() => {\n const prefixObserver = new ResizeObserver((entries) => {\n setPrefixWidth(entries[0].contentRect.width)\n })\n const suffixObserver = new ResizeObserver((entries) => {\n setSuffixWidth(entries[0].contentRect.width)\n })\n\n if (prefixRef.current !== null) {\n prefixObserver.observe(prefixRef.current)\n }\n if (suffixRef.current !== null) {\n suffixObserver.observe(suffixRef.current)\n }\n\n return () => {\n suffixObserver.disconnect()\n prefixObserver.disconnect()\n }\n }, [])\n\n return (\n <TextFieldRoot className={className} isDisabled={disabled}>\n <TextFieldLabel\n label={label}\n requiredText={requiredText}\n required={required}\n subLabel={subLabel}\n {...labelProps}\n {...(!showLabel ? visuallyHiddenProps : {})}\n />\n <StyledInputContainer>\n <PrefixContainer ref={prefixRef}>\n <Affix>{prefix}</Affix>\n </PrefixContainer>\n <StyledInput\n ref={mergeRefs(forwardRef, ariaRef)}\n invalid={invalid}\n extraLeftPadding={prefixWidth}\n extraRightPadding={suffixWidth}\n {...inputProps}\n />\n <SuffixContainer ref={suffixRef}>\n <Affix>{suffix}</Affix>\n {showCount && maxLength && (\n <SingleLineCounter>\n {count}/{maxLength}\n </SingleLineCounter>\n )}\n </SuffixContainer>\n </StyledInputContainer>\n {assistiveText != null && assistiveText.length !== 0 && (\n <AssistiveText\n invalid={invalid}\n {...(invalid ? errorMessageProps : descriptionProps)}\n >\n {assistiveText}\n </AssistiveText>\n )}\n </TextFieldRoot>\n )\n})\n\nconst MultiLineTextField = React.forwardRef<\n HTMLTextAreaElement,\n MultiLineTextFieldProps\n>(function MultiLineTextFieldInner({ onChange, ...props }, forwardRef) {\n const {\n className,\n showCount = false,\n showLabel = false,\n label,\n requiredText,\n subLabel,\n disabled = false,\n required,\n invalid = false,\n assistiveText,\n maxLength,\n autoHeight = false,\n rows: initialRows = 4,\n } = props\n\n const { visuallyHiddenProps } = useVisuallyHidden()\n const textareaRef = useRef<HTMLTextAreaElement>(null)\n const ariaRef = useRef<HTMLTextAreaElement>(null)\n const [count, setCount] = useState(countCodePointsInString(props.value ?? ''))\n const [rows, setRows] = useState(initialRows)\n\n const syncHeight = useCallback(\n (textarea: HTMLTextAreaElement) => {\n const rows = `${textarea.value}\\n`.match(/\\n/gu)?.length ?? 1\n if (initialRows <= rows) {\n setRows(rows)\n }\n },\n [initialRows]\n )\n\n const nonControlled = props.value === undefined\n const handleChange = useCallback(\n (value: string) => {\n const count = countCodePointsInString(value)\n if (maxLength !== undefined && count > maxLength) {\n return\n }\n if (nonControlled) {\n setCount(count)\n }\n if (autoHeight && textareaRef.current !== null) {\n syncHeight(textareaRef.current)\n }\n onChange?.(value)\n },\n [autoHeight, maxLength, nonControlled, onChange, syncHeight]\n )\n\n useEffect(() => {\n setCount(countCodePointsInString(props.value ?? ''))\n }, [props.value])\n\n const { inputProps, labelProps, descriptionProps, errorMessageProps } =\n useTextField(\n {\n inputElementType: 'textarea',\n isDisabled: disabled,\n isRequired: required,\n validationState: invalid ? 'invalid' : 'valid',\n description: !invalid && assistiveText,\n errorMessage: invalid && assistiveText,\n onChange: handleChange,\n ...props,\n },\n ariaRef\n )\n\n useEffect(() => {\n if (autoHeight && textareaRef.current !== null) {\n syncHeight(textareaRef.current)\n }\n }, [autoHeight, syncHeight])\n\n return (\n <TextFieldRoot className={className} isDisabled={disabled}>\n <TextFieldLabel\n label={label}\n requiredText={requiredText}\n required={required}\n subLabel={subLabel}\n {...labelProps}\n {...(showLabel ? visuallyHiddenProps : {})}\n />\n <StyledTextareaContainer rows={rows}>\n <StyledTextarea\n ref={mergeRefs(textareaRef, forwardRef, ariaRef)}\n invalid={invalid}\n rows={rows}\n {...inputProps}\n />\n {showCount && <MultiLineCounter>{count}</MultiLineCounter>}\n </StyledTextareaContainer>\n {assistiveText != null && assistiveText.length !== 0 && (\n <AssistiveText\n invalid={invalid}\n {...(invalid ? errorMessageProps : descriptionProps)}\n >\n {assistiveText}\n </AssistiveText>\n )}\n </TextFieldRoot>\n )\n})\n\nconst TextFieldRoot = styled.div<{ isDisabled: boolean }>`\n display: flex;\n flex-direction: column;\n\n ${(p) => p.isDisabled && { opacity: p.theme.elementEffect.disabled.opacity }}\n`\n\nconst TextFieldLabel = styled(FieldLabel)`\n ${theme((o) => o.margin.bottom(8))}\n`\n\nconst StyledInputContainer = styled.div`\n height: 40px;\n display: grid;\n position: relative;\n`\n\nconst PrefixContainer = styled.span`\n position: absolute;\n top: 50%;\n left: 8px;\n transform: translateY(-50%);\n`\n\nconst SuffixContainer = styled.span`\n position: absolute;\n top: 50%;\n right: 8px;\n transform: translateY(-50%);\n\n display: flex;\n gap: 8px;\n`\n\nconst Affix = styled.span`\n user-select: none;\n\n ${theme((o) => [o.typography(14).preserveHalfLeading, o.font.text2])}\n`\n\nconst StyledInput = styled.input<{\n invalid: boolean\n extraLeftPadding: number\n extraRightPadding: number\n}>`\n border: none;\n box-sizing: border-box;\n outline: none;\n font-family: inherit;\n\n /* Prevent zooming for iOS Safari */\n transform-origin: top left;\n transform: scale(0.875);\n width: calc(100% / 0.875);\n height: calc(100% / 0.875);\n font-size: calc(14px / 0.875);\n line-height: calc(22px / 0.875);\n padding-top: calc(9px / 0.875);\n padding-bottom: calc(9px / 0.875);\n padding-left: calc((8px + ${(p) => p.extraLeftPadding}px) / 0.875);\n padding-right: calc((8px + ${(p) => p.extraRightPadding}px) / 0.875);\n border-radius: calc(4px / 0.875);\n\n /* Display box-shadow for iOS Safari */\n appearance: none;\n\n ${(p) =>\n theme((o) => [\n o.bg.surface3.hover,\n o.outline.default.focus,\n p.invalid && o.outline.assertive,\n o.font.text2,\n ])}\n\n &::placeholder {\n ${theme((o) => o.font.text3)}\n }\n`\n\nconst StyledTextareaContainer = styled.div<{ rows: number }>`\n display: grid;\n position: relative;\n\n ${({ rows }) => css`\n max-height: calc(22px * ${rows} + 18px);\n `};\n`\n\nconst StyledTextarea = styled.textarea<{ invalid: boolean }>`\n border: none;\n box-sizing: border-box;\n outline: none;\n resize: none;\n font-family: inherit;\n\n /* Prevent zooming for iOS Safari */\n transform-origin: top left;\n transform: scale(0.875);\n width: calc(100% / 0.875);\n font-size: calc(14px / 0.875);\n line-height: calc(22px / 0.875);\n padding: calc(9px / 0.875) calc(8px / 0.875);\n border-radius: calc(4px / 0.875);\n\n ${({ rows }) => css`\n height: calc(22px / 0.875 * ${rows} + 18px / 0.875);\n `};\n\n /* Display box-shadow for iOS Safari */\n appearance: none;\n\n ${(p) =>\n theme((o) => [\n o.bg.surface3.hover,\n o.outline.default.focus,\n p.invalid && o.outline.assertive,\n o.font.text2,\n ])}\n\n &::placeholder {\n ${theme((o) => o.font.text3)}\n }\n\n /* Hide scrollbar for Chrome, Safari and Opera */\n &::-webkit-scrollbar {\n display: none;\n }\n /* Hide scrollbar for IE, Edge and Firefox */\n -ms-overflow-style: none; /* IE and Edge */\n scrollbar-width: none; /* Firefox */\n`\n\nconst SingleLineCounter = styled.span`\n ${theme((o) => [o.typography(14).preserveHalfLeading, o.font.text3])}\n`\n\nconst MultiLineCounter = styled.span`\n position: absolute;\n bottom: 9px;\n right: 8px;\n\n ${theme((o) => [o.typography(14).preserveHalfLeading, o.font.text3])}\n`\n\nconst AssistiveText = styled.p<{ invalid: boolean }>`\n ${(p) =>\n theme((o) => [\n o.typography(14),\n o.margin.top(8),\n o.margin.bottom(0),\n o.font[p.invalid ? 'assertive' : 'text1'],\n ])}\n`\n"],"names":["DefaultValue","Link","React","forwardRef","ref","to","children","rest","href","ComponentAbstractionContext","createContext","ComponentAbstraction","Provider","value","components","useComponentAbstraction","useContext","theme","createTheme","styled","Clickable","props","onClick","disabled","A","as","undefined","Button","clickableCss","css","disabledSelector","button","span","variant","size","fixed","StyledButton","withConfig","shouldForwardProp","prop","attrs","font","background","Error","arguments","length","JSON","stringify","unreachable","variantToProps","height","padding","sizeToProps","p","o","hover","press","bg","typography","bold","preserveHalfLeading","horizontal","borderRadius","outline","focus","IconButton","icon","requiredIconSize","result","exec","iconSize","console","warn","validateIconSize","StyledIconButton","name","width","Radio","forceChecked","RadioGroupContext","selected","isParentDisabled","readonly","hasError","onChange","warning","isSelected","isDisabled","isReadonly","handleChange","useCallback","e","currentTarget","RadioRoot","RadioInput","checked","RadioLabel","label","px","spacing","input","type","text5","assertive","color","text4","brand","div","StyledRadioGroup","RadioGroup","className","next","role","SelectGroupContext","Select","parentDisabled","parentOnChange","includes","event","HTMLInputElement","SelectRoot","SelectInput","overlay","SelectInputOverlay","Boolean","SelectLabel","text1","text3","surface4","SelectGroup","ariaLabel","payload","index","indexOf","slice","Array","from","Set","SwitchCheckbox","ariaSwitchProps","useMemo","state","useToggleState","useRef","useSwitch","inputProps","Label","SwitchInput","LabelInner","FieldLabel","style","required","requiredText","subLabel","labelProps","FieldLabelWrapper","RequiredText","SubLabelClickable","margin","left","mergeRefs","current","countCodePointsInString","string","TextField","multiline","MultiLineTextField","SingleLineTextField","showLabel","showCount","invalid","assistiveText","maxLength","prefix","suffix","visuallyHiddenProps","useVisuallyHidden","ariaRef","prefixRef","suffixRef","useState","count","setCount","prefixWidth","setPrefixWidth","suffixWidth","setSuffixWidth","nonControlled","useEffect","useTextField","inputElementType","isRequired","validationState","description","errorMessage","descriptionProps","errorMessageProps","prefixObserver","ResizeObserver","entries","contentRect","suffixObserver","observe","disconnect","TextFieldRoot","TextFieldLabel","StyledInputContainer","PrefixContainer","Affix","StyledInput","extraLeftPadding","extraRightPadding","SuffixContainer","SingleLineCounter","AssistiveText","autoHeight","rows","initialRows","textareaRef","setRows","syncHeight","textarea","match","_$match","StyledTextareaContainer","StyledTextarea","MultiLineCounter","opacity","elementEffect","bottom","text2","surface3","top"],"mappings":"2sDAuBMA,EAA2B,CAC/BC,KAfyBC,EAAMC,WAC/B,WAAgDC,OAAzBC,IAAAA,GAAIC,IAAAA,SAAaC,sBACtC,OACEL,uBAAGM,KAAMH,EAAID,IAAKA,GAASG,GACxBD,MAcHG,EA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IAAIE,oBAAqBN,EAAEb,KAAK6L,UAGzDrB,GAAc9L,EAAOiF,kpBAmBG,SAAC/C,UAAMA,EAAE6J,kBACR,SAAC7J,UAAMA,EAAE8J,mBAMpC,SAAC9J,UACDpC,GAAM,SAACqC,SAAM,CACXA,EAAEG,GAAG8K,SAAShL,MACdD,EAAES,gBAAgBC,MAClBX,EAAEqH,SAAWpH,EAAES,QAAQwC,UACvBjD,EAAEb,KAAK6L,UAIPrN,GAAM,SAACqC,UAAMA,EAAEb,KAAKsF,SAIpBiG,GAA0B7M,EAAOwF,0EAInC,gBAAG6G,IAAAA,YAAW3L,iEACY2L,KAIxBS,GAAiB9M,EAAO0M,8wBAgB1B,gBAAGL,IAAAA,YAAW3L,6EACgB2L,IAM9B,SAACnK,UACDpC,GAAM,SAACqC,SAAM,CACXA,EAAEG,GAAG8K,SAAShL,MACdD,EAAES,gBAAgBC,MAClBX,EAAEqH,SAAWpH,EAAES,QAAQwC,UACvBjD,EAAEb,KAAK6L,UAIPrN,GAAM,SAACqC,UAAMA,EAAEb,KAAKsF,SAYpBsF,GAAoBlM,EAAOa,+BAC7Bf,GAAM,SAACqC,SAAM,CAACA,EAAEI,WAAW,IAAIE,oBAAqBN,EAAEb,KAAKsF,UAGzDmG,GAAmB/M,EAAOa,uFAK5Bf,GAAM,SAACqC,SAAM,CAACA,EAAEI,WAAW,IAAIE,oBAAqBN,EAAEb,KAAKsF,UAGzDuF,GAAgBnM,EAAOkC,4BACzB,SAACA,UACDpC,GAAM,SAACqC,SAAM,CACXA,EAAEI,WAAW,IACbJ,EAAEwG,OAAO0E,IAAI,GACblL,EAAEwG,OAAOuE,OAAO,GAChB/K,EAAEb,KAAKY,EAAEqH,QAAU,YAAc"}
package/dist/styled.d.ts CHANGED
@@ -11,6 +11,7 @@ export declare const theme: (spec: (o: Record<string, unknown> & Readonly<{
11
11
  readonly surface7: import("@charcoal-ui/styled").Modified<import("@charcoal-ui/styled").Internal, keyof import("@charcoal-ui/theme").ThemeEffect>;
12
12
  readonly surface8: import("@charcoal-ui/styled").Modified<import("@charcoal-ui/styled").Internal, keyof import("@charcoal-ui/theme").ThemeEffect>;
13
13
  readonly surface9: import("@charcoal-ui/styled").Modified<import("@charcoal-ui/styled").Internal, keyof import("@charcoal-ui/theme").ThemeEffect>;
14
+ readonly surface10: import("@charcoal-ui/styled").Modified<import("@charcoal-ui/styled").Internal, keyof import("@charcoal-ui/theme").ThemeEffect>;
14
15
  readonly link1: import("@charcoal-ui/styled").Modified<import("@charcoal-ui/styled").Internal, keyof import("@charcoal-ui/theme").ThemeEffect>;
15
16
  readonly link2: import("@charcoal-ui/styled").Modified<import("@charcoal-ui/styled").Internal, keyof import("@charcoal-ui/theme").ThemeEffect>;
16
17
  readonly text1: import("@charcoal-ui/styled").Modified<import("@charcoal-ui/styled").Internal, keyof import("@charcoal-ui/theme").ThemeEffect>;
@@ -21,6 +22,10 @@ export declare const theme: (spec: (o: Record<string, unknown> & Readonly<{
21
22
  readonly icon6: import("@charcoal-ui/styled").Modified<import("@charcoal-ui/styled").Internal, keyof import("@charcoal-ui/theme").ThemeEffect>;
22
23
  readonly brand: import("@charcoal-ui/styled").Modified<import("@charcoal-ui/styled").Internal, keyof import("@charcoal-ui/theme").ThemeEffect>;
23
24
  readonly assertive: import("@charcoal-ui/styled").Modified<import("@charcoal-ui/styled").Internal, keyof import("@charcoal-ui/theme").ThemeEffect>;
25
+ readonly warning: import("@charcoal-ui/styled").Modified<import("@charcoal-ui/styled").Internal, keyof import("@charcoal-ui/theme").ThemeEffect>;
26
+ readonly success: import("@charcoal-ui/styled").Modified<import("@charcoal-ui/styled").Internal, keyof import("@charcoal-ui/theme").ThemeEffect>;
27
+ readonly updatedItem: import("@charcoal-ui/styled").Modified<import("@charcoal-ui/styled").Internal, keyof import("@charcoal-ui/theme").ThemeEffect>;
28
+ readonly border: import("@charcoal-ui/styled").Modified<import("@charcoal-ui/styled").Internal, keyof import("@charcoal-ui/theme").ThemeEffect>;
24
29
  } & {
25
30
  readonly surface5: (direction: "to top" | "to bottom" | "to left" | "to right") => import("@charcoal-ui/styled").Modified<import("@charcoal-ui/styled").Internal, keyof import("@charcoal-ui/theme").ThemeEffect>;
26
31
  readonly callToAction: (direction: "to top" | "to bottom" | "to left" | "to right") => import("@charcoal-ui/styled").Modified<import("@charcoal-ui/styled").Internal, keyof import("@charcoal-ui/theme").ThemeEffect>;
@@ -37,6 +42,7 @@ export declare const theme: (spec: (o: Record<string, unknown> & Readonly<{
37
42
  readonly surface7: import("@charcoal-ui/styled").Modified<import("@charcoal-ui/styled").Internal, keyof import("@charcoal-ui/theme").ThemeEffect>;
38
43
  readonly surface8: import("@charcoal-ui/styled").Modified<import("@charcoal-ui/styled").Internal, keyof import("@charcoal-ui/theme").ThemeEffect>;
39
44
  readonly surface9: import("@charcoal-ui/styled").Modified<import("@charcoal-ui/styled").Internal, keyof import("@charcoal-ui/theme").ThemeEffect>;
45
+ readonly surface10: import("@charcoal-ui/styled").Modified<import("@charcoal-ui/styled").Internal, keyof import("@charcoal-ui/theme").ThemeEffect>;
40
46
  readonly link1: import("@charcoal-ui/styled").Modified<import("@charcoal-ui/styled").Internal, keyof import("@charcoal-ui/theme").ThemeEffect>;
41
47
  readonly link2: import("@charcoal-ui/styled").Modified<import("@charcoal-ui/styled").Internal, keyof import("@charcoal-ui/theme").ThemeEffect>;
42
48
  readonly text1: import("@charcoal-ui/styled").Modified<import("@charcoal-ui/styled").Internal, keyof import("@charcoal-ui/theme").ThemeEffect>;
@@ -47,6 +53,10 @@ export declare const theme: (spec: (o: Record<string, unknown> & Readonly<{
47
53
  readonly icon6: import("@charcoal-ui/styled").Modified<import("@charcoal-ui/styled").Internal, keyof import("@charcoal-ui/theme").ThemeEffect>;
48
54
  readonly brand: import("@charcoal-ui/styled").Modified<import("@charcoal-ui/styled").Internal, keyof import("@charcoal-ui/theme").ThemeEffect>;
49
55
  readonly assertive: import("@charcoal-ui/styled").Modified<import("@charcoal-ui/styled").Internal, keyof import("@charcoal-ui/theme").ThemeEffect>;
56
+ readonly warning: import("@charcoal-ui/styled").Modified<import("@charcoal-ui/styled").Internal, keyof import("@charcoal-ui/theme").ThemeEffect>;
57
+ readonly success: import("@charcoal-ui/styled").Modified<import("@charcoal-ui/styled").Internal, keyof import("@charcoal-ui/theme").ThemeEffect>;
58
+ readonly updatedItem: import("@charcoal-ui/styled").Modified<import("@charcoal-ui/styled").Internal, keyof import("@charcoal-ui/theme").ThemeEffect>;
59
+ readonly border: import("@charcoal-ui/styled").Modified<import("@charcoal-ui/styled").Internal, keyof import("@charcoal-ui/theme").ThemeEffect>;
50
60
  };
51
61
  }> & {
52
62
  readonly typography: (size: keyof import("@charcoal-ui/theme").Typography) => import("@charcoal-ui/styled").Modified<import("@charcoal-ui/styled").Internal, "bold" | "monospace" | "preserveHalfLeading">;
@@ -1 +1 @@
1
- {"version":3,"file":"styled.d.ts","sourceRoot":"","sources":["../src/styled.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0OAAsB,CAAA"}
1
+ {"version":3,"file":"styled.d.ts","sourceRoot":"","sources":["../src/styled.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0OAAsB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@charcoal-ui/react",
3
- "version": "1.0.0",
3
+ "version": "2.0.0-alpha.2",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",
@@ -18,7 +18,7 @@
18
18
  "clean": "rimraf dist"
19
19
  },
20
20
  "devDependencies": {
21
- "@charcoal-ui/icons": "^1.0.0",
21
+ "@charcoal-ui/icons": "^1.0.1-alpha.1",
22
22
  "@react-types/switch": "^3.1.2",
23
23
  "@storybook/addon-actions": "^6.4.17",
24
24
  "@storybook/addon-knobs": "^6.4.0",
@@ -49,9 +49,9 @@
49
49
  "typescript": "^4.5.5"
50
50
  },
51
51
  "dependencies": {
52
- "@charcoal-ui/styled": "^1.0.0",
53
- "@charcoal-ui/theme": "^1.0.0",
54
- "@charcoal-ui/utils": "^1.0.0",
52
+ "@charcoal-ui/styled": "^1.0.1-alpha.2",
53
+ "@charcoal-ui/theme": "^2.0.0-alpha.1",
54
+ "@charcoal-ui/utils": "^1.0.1-alpha.0",
55
55
  "@react-aria/checkbox": "^3.2.3",
56
56
  "@react-aria/switch": "^3.1.3",
57
57
  "@react-aria/textfield": "^3.5.0",
@@ -71,5 +71,10 @@
71
71
  "publishConfig": {
72
72
  "access": "public"
73
73
  },
74
- "gitHead": "addc6d8f443865a8b56327ef9a4ff2e69942a30b"
74
+ "repository": {
75
+ "type": "git",
76
+ "url": "https://github.com/pixiv/charcoal.git",
77
+ "directory": "packages/react"
78
+ },
79
+ "gitHead": "6740b50cd147f29b8da7c16e93c15b5799900d33"
75
80
  }
@@ -9,7 +9,4 @@ import React from 'react'
9
9
  * node_modules/@types/styled-components/ts3.7/index.d.ts
10
10
  * `Type alias 'Interpolation' circularly references itself. ts(2456)`
11
11
  */
12
- export interface Story<P> {
13
- (args: P): React.ReactNode
14
- args?: P
15
- }
12
+ export type Story<P> = React.ComponentType<P> & { args?: P }
@@ -111,6 +111,7 @@ function validateIconSize(size: Size, icon: keyof KnownIconType) {
111
111
  }
112
112
  const [iconSize] = result
113
113
  if (iconSize !== requiredIconSize) {
114
+ // eslint-disable-next-line no-console
114
115
  console.warn(
115
116
  `IconButton with size "${size}" expect icon size "${requiredIconSize}, but got "${iconSize}"`
116
117
  )
@@ -11,14 +11,22 @@ export default {
11
11
  title: 'Radio',
12
12
  component: Radio,
13
13
  argTypes: {
14
- defaultValue: {
15
- control: { type: 'select', options },
14
+ value: {
15
+ control: { type: 'select' },
16
+ options,
16
17
  },
17
18
  },
19
+ args: {
20
+ hasError: false,
21
+ parentDisabled: false,
22
+ childDisabled: false,
23
+ forceChecked: false,
24
+ readonly: false,
25
+ },
18
26
  }
19
27
 
20
28
  interface Props {
21
- defaultValue: string
29
+ value?: string
22
30
  hasError: boolean
23
31
  parentDisabled: boolean
24
32
  childDisabled: boolean
@@ -26,14 +34,14 @@ interface Props {
26
34
  readonly: boolean
27
35
  }
28
36
 
29
- const DefaultStory = ({
30
- defaultValue,
37
+ const Template: Story<Partial<Props>> = ({
38
+ value,
31
39
  forceChecked,
32
40
  hasError,
33
41
  parentDisabled,
34
42
  childDisabled,
35
43
  readonly,
36
- }: Props) => (
44
+ }) => (
37
45
  <div
38
46
  css={css`
39
47
  display: flex;
@@ -46,7 +54,7 @@ const DefaultStory = ({
46
54
  key={name}
47
55
  label={`選択肢-${name}`}
48
56
  name={name}
49
- defaultValue={defaultValue}
57
+ value={value}
50
58
  onChange={action('onChange')}
51
59
  disabled={parentDisabled}
52
60
  readonly={readonly}
@@ -67,13 +75,4 @@ const DefaultStory = ({
67
75
  </div>
68
76
  )
69
77
 
70
- export const Normal: Story<Props> = DefaultStory.bind({})
71
-
72
- Normal.args = {
73
- defaultValue: options[0],
74
- hasError: false,
75
- parentDisabled: false,
76
- childDisabled: false,
77
- forceChecked: false,
78
- readonly: false,
79
- }
78
+ export const Default = Template.bind({})
@@ -5,15 +5,14 @@ import Radio, { RadioGroup } from '.'
5
5
  import { light } from '@charcoal-ui/theme'
6
6
 
7
7
  describe('Radio', () => {
8
- describe('__DEV__ mode', () => {
8
+ describe('development mode', () => {
9
9
  beforeEach(() => {
10
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
11
- // @ts-expect-error
12
- global.__DEV__ = {}
10
+ global.process.env.NODE_ENV = 'development'
13
11
  })
14
12
 
15
13
  describe('<Radio> is not surrounded by <RadioGroup>', () => {
16
14
  beforeEach(() => {
15
+ // eslint-disable-next-line no-console
17
16
  console.error = jest.fn()
18
17
 
19
18
  render(
@@ -24,6 +23,7 @@ describe('Radio', () => {
24
23
  })
25
24
 
26
25
  it('console.error()', () => {
26
+ // eslint-disable-next-line no-console
27
27
  expect(console.error).toHaveBeenCalledWith(
28
28
  expect.stringMatching(/Perhaps you forgot to wrap with <RadioGroup>/u)
29
29
  )
@@ -31,12 +31,13 @@ describe('Radio', () => {
31
31
  })
32
32
  })
33
33
 
34
- describe('defaultValue is the first option', () => {
34
+ describe('value is the first option', () => {
35
35
  let option1: HTMLInputElement
36
36
  let option2: HTMLInputElement
37
+ const handleChange = jest.fn()
37
38
 
38
39
  beforeEach(() => {
39
- render(<TestComponent defaultValue="option1" />)
40
+ render(<TestComponent value="option1" onChange={handleChange} />)
40
41
 
41
42
  option1 = screen.getByDisplayValue('option1')
42
43
  option2 = screen.getByDisplayValue('option2')
@@ -48,18 +49,16 @@ describe('Radio', () => {
48
49
  })
49
50
 
50
51
  describe('clicking the second', () => {
51
- it('the second <Radio> is checked', () => {
52
+ it('event handler is called', () => {
52
53
  fireEvent.click(option2)
53
-
54
- expect(option1.checked).toBeFalsy()
55
- expect(option2.checked).toBeTruthy()
54
+ expect(handleChange).toHaveBeenCalledWith('option2')
56
55
  })
57
56
  })
58
57
  })
59
58
 
60
59
  describe('<RadioGroup> is disabled', () => {
61
60
  it('all <Radio>s are disabled', () => {
62
- render(<TestComponent defaultValue="option1" radioGroupDisabled />)
61
+ render(<TestComponent value="option1" radioGroupDisabled />)
63
62
  screen.getAllByRole<HTMLInputElement>('radio').forEach((element) => {
64
63
  expect(element.disabled).toBeTruthy()
65
64
  })
@@ -71,7 +70,7 @@ describe('Radio', () => {
71
70
  let option2: HTMLInputElement
72
71
 
73
72
  beforeEach(() => {
74
- render(<TestComponent defaultValue="option1" option1Disabled />)
73
+ render(<TestComponent value="option1" option1Disabled />)
75
74
 
76
75
  option1 = screen.getByDisplayValue('option1')
77
76
  option2 = screen.getByDisplayValue('option2')
@@ -91,7 +90,7 @@ describe('Radio', () => {
91
90
  let option2: HTMLInputElement
92
91
 
93
92
  beforeEach(() => {
94
- render(<TestComponent defaultValue="option1" readonly />)
93
+ render(<TestComponent value="option1" readonly />)
95
94
 
96
95
  option1 = screen.getByDisplayValue('option1')
97
96
  option2 = screen.getByDisplayValue('option2')
@@ -109,7 +108,7 @@ describe('Radio', () => {
109
108
  })
110
109
 
111
110
  function TestComponent({
112
- defaultValue,
111
+ value,
113
112
  onChange = jest.fn(),
114
113
  radioGroupDisabled = false,
115
114
  readonly = false,
@@ -117,7 +116,7 @@ function TestComponent({
117
116
  option1Disabled = false,
118
117
  option2Disabled = false,
119
118
  }: {
120
- defaultValue: string
119
+ value?: string
121
120
  onChange?: () => void
122
121
  radioGroupDisabled?: boolean
123
122
  readonly?: boolean
@@ -130,7 +129,7 @@ function TestComponent({
130
129
  <RadioGroup
131
130
  label="テスト項目"
132
131
  name="test"
133
- defaultValue={defaultValue}
132
+ value={value}
134
133
  onChange={onChange}
135
134
  disabled={radioGroupDisabled}
136
135
  readonly={readonly}
@@ -1,4 +1,4 @@
1
- import React, { useCallback, useContext, useState } from 'react'
1
+ import React, { useCallback, useContext } from 'react'
2
2
  import styled from 'styled-components'
3
3
  import warning from 'warning'
4
4
  import { theme } from '../../styled'
@@ -118,7 +118,7 @@ const RadioLabel = styled.div`
118
118
 
119
119
  export type RadioGroupProps = React.PropsWithChildren<{
120
120
  className?: string
121
- defaultValue?: string
121
+ value?: string
122
122
  label: string
123
123
  name: string
124
124
  onChange(next: string): void
@@ -158,7 +158,7 @@ const RadioGroupContext = React.createContext<RadioGroupContext>({
158
158
 
159
159
  export function RadioGroup({
160
160
  className,
161
- defaultValue,
161
+ value,
162
162
  label,
163
163
  name,
164
164
  onChange,
@@ -167,11 +167,8 @@ export function RadioGroup({
167
167
  hasError,
168
168
  children,
169
169
  }: RadioGroupProps) {
170
- const [selected, setSelected] = useState(defaultValue)
171
-
172
170
  const handleChange = useCallback(
173
171
  (next: string) => {
174
- setSelected(next)
175
172
  onChange(next)
176
173
  },
177
174
  [onChange]
@@ -181,7 +178,7 @@ export function RadioGroup({
181
178
  <RadioGroupContext.Provider
182
179
  value={{
183
180
  name,
184
- selected,
181
+ selected: value,
185
182
  disabled: disabled ?? false,
186
183
  readonly: readonly ?? false,
187
184
  hasError: hasError ?? false,
@@ -0,0 +1,23 @@
1
+ import { createContext } from 'react'
2
+
3
+ type SelectGroupContext = {
4
+ name: string
5
+ selected: string[]
6
+ disabled: boolean
7
+ readonly: boolean
8
+ hasError: boolean
9
+ onChange: ({ value, selected }: { value: string; selected: boolean }) => void
10
+ }
11
+
12
+ export const SelectGroupContext = createContext<SelectGroupContext>({
13
+ name: undefined as never,
14
+ selected: [],
15
+ disabled: false,
16
+ readonly: false,
17
+ hasError: false,
18
+ onChange() {
19
+ throw new Error(
20
+ 'Cannot find `onChange()` handler. Perhaps you forgot to wrap it with `<SelectGroup />` ?'
21
+ )
22
+ },
23
+ })