@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.
- package/dist/_lib/compat.d.ts +2 -3
- package/dist/_lib/compat.d.ts.map +1 -1
- package/dist/components/Radio/index.d.ts +2 -2
- package/dist/components/Radio/index.d.ts.map +1 -1
- package/dist/components/Radio/index.story.d.ts +14 -5
- package/dist/components/Radio/index.story.d.ts.map +1 -1
- package/dist/components/Select/context.d.ts +14 -0
- package/dist/components/Select/context.d.ts.map +1 -0
- package/dist/components/Select/index.d.ts +24 -0
- package/dist/components/Select/index.d.ts.map +1 -0
- package/dist/components/Select/index.story.d.ts +75 -0
- package/dist/components/Select/index.story.d.ts.map +1 -0
- package/dist/components/Select/index.test.d.ts +2 -0
- package/dist/components/Select/index.test.d.ts.map +1 -0
- package/dist/components/TextField/index.d.ts +4 -0
- package/dist/components/TextField/index.d.ts.map +1 -1
- package/dist/components/TextField/index.story.d.ts +11 -4
- package/dist/components/TextField/index.story.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.modern.js +97 -35
- package/dist/index.modern.js.map +1 -1
- package/dist/index.module.js +1 -1
- package/dist/index.module.js.map +1 -1
- package/dist/styled.d.ts +10 -0
- package/dist/styled.d.ts.map +1 -1
- package/package.json +11 -6
- package/src/_lib/compat.ts +1 -4
- package/src/components/IconButton/index.tsx +1 -0
- package/src/components/Radio/index.story.tsx +16 -17
- package/src/components/Radio/index.test.tsx +15 -16
- package/src/components/Radio/index.tsx +4 -7
- package/src/components/Select/context.ts +23 -0
- package/src/components/Select/index.story.tsx +153 -0
- package/src/components/Select/index.test.tsx +281 -0
- package/src/components/Select/index.tsx +210 -0
- package/src/components/TextField/index.story.tsx +10 -0
- package/src/components/TextField/index.tsx +105 -23
- package/src/components/a11y.test.tsx +32 -24
- package/src/index.ts +6 -0
- package/src/type.d.ts +0 -4
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","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","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","value","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","RadioRoot","label","px","spacing","RadioInput","input","type","hasError","text5","assertive","color","text4","brand","RadioLabel","div","StyledRadioGroup","RadioGroupContext","selected","readonly","onChange","Label","LabelInner","SwitchInput","FieldLabel","style","className","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","useRef","useState","count","setCount","handleChange","useCallback","useTextField","inputElementType","isDisabled","isRequired","validationState","description","errorMessage","inputProps","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","Provider","components","forceChecked","isParentDisabled","warning","isSelected","isReadonly","e","currentTarget","checked","defaultValue","setSelected","next","role","ariaSwitchProps","useMemo","state","useToggleState","useSwitch"],"mappings":"ooDAuBMA,EAA2B,CAC/BC,KAfyBC,UAAMC,WAC/B,WAAgDC,OAAzBC,IAAAA,GAAIC,IAAAA,SAAaC,sBACtC,OACEL,+BAAGM,KAAMH,EAAID,IAAKA,GAASG,GACxBD,MAcHG,EAA8BP,UAAMQ,cAAcV,YAiBxCW,IACd,OAAOC,aAAWH,6DC3CPI,EAAQC,UAAYC,oCCyB3BC,EAAYd,UAAMC,WACtB,SAAmBc,EAAOb,GACxB,IAAQH,EAASU,IAATV,KACR,GAAI,OAAQgB,EAAO,CACjB,IAAQC,EAAuCD,EAAvCC,UAAuCD,EAA9BE,SAAAA,gBAAqBZ,IAASU,kBAC/C,OACEf,wBAACkB,QACKb,GACJc,GAAIF,OAAWG,EAAYrB,EAC3BiB,QAASC,OAAWG,EAAYJ,EAChC,gBAAeC,EACff,IAAKA,kBAIT,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,cASOvF,OAAUwF,OAEXhD,EAAeC,cACnB,SAACgD,GACCD,EAAYC,GACZvF,EAASuF,IAEX,CAACvF,iBAGH,OACE3F,wBAACwF,GAAkB8E,UACjBjI,MAAO,CACLiC,KAAAA,EACAmB,SAAAA,EACAxE,eAAUA,GAAAA,EACVyE,eAAUA,GAAAA,EACVX,eAAUA,GAAAA,EACVY,SAAUsC,iBAGZjI,wBAACuF,IACC4F,KAAK,aACL,mBAAiB,WACjB,aAAY1G,EACZ,eAAcM,EACdkB,UAAWA,GAEV7F,6BC5K8BW,GACrC,IAAQE,EAAwBF,EAAxBE,SAAUgF,EAAclF,EAAdkF,UAEZmF,EAAmCC,UACvC,uBACKtK,GAGH,aAAc,aAAcA,OAAQK,EAAYL,EAAM0D,MACtD4D,WAAYtH,EAAME,SAClB0J,WAAY5J,EAAMgK,WAEpB,CAAChK,IAGGuK,EAAQC,iBAAeH,GACvBlL,EAAM2H,SAAyB,MAEkBxH,IACnDmL,YAAUJ,EAAiBE,EAAOpL,GADpCwI,4BAGF,OACE1I,wBAAC4F,IAAMK,UAAWA,EAAW,gBAAehF,gBAC1CjB,wBAAC8F,QAAgBzF,GAAMH,IAAKA,KAC3B,aAAca,eAEbf,wBAAC6F,QAAY9E,EAAMX,eACjBgB"}
|
|
1
|
+
{"version":3,"file":"index.cjs","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","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","value","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","RadioRoot","label","px","spacing","RadioInput","input","type","hasError","text5","assertive","color","text4","brand","RadioLabel","div","StyledRadioGroup","RadioGroupContext","selected","readonly","onChange","SelectGroupContext","SelectRoot","SelectLabel","text1","SelectInput","overlay","text3","surface4","SelectInputOverlay","Label","LabelInner","SwitchInput","FieldLabel","style","className","required","requiredText","subLabel","labelProps","FieldLabelWrapper","RequiredText","SubLabelClickable","margin","left","mergeRefs","current","countCodePointsInString","string","Array","from","TextField","multiline","MultiLineTextField","SingleLineTextField","showLabel","showCount","invalid","assistiveText","maxLength","prefix","suffix","visuallyHiddenProps","useVisuallyHidden","ariaRef","useRef","prefixRef","suffixRef","useState","count","setCount","prefixWidth","setPrefixWidth","suffixWidth","setSuffixWidth","nonControlled","handleChange","useCallback","useEffect","useTextField","inputElementType","isDisabled","isRequired","validationState","description","errorMessage","inputProps","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","Provider","components","forceChecked","isParentDisabled","warning","isSelected","isReadonly","e","currentTarget","checked","next","role","parentDisabled","parentOnChange","includes","event","HTMLInputElement","Boolean","ariaLabel","payload","index","indexOf","slice","Set","ariaSwitchProps","useMemo","state","useToggleState","useSwitch"],"mappings":"ooDAuBMA,EAA2B,CAC/BC,KAfyBC,UAAMC,WAC/B,WAAgDC,OAAzBC,IAAAA,GAAIC,IAAAA,SAAaC,sBACtC,OACEL,+BAAGM,KAAMH,EAAID,IAAKA,GAASG,GACxBD,MAcHG,EAA8BP,UAAMQ,cAAcV,YAiBxCW,IACd,OAAOC,aAAWH,iFC3CPI,GAAQC,UAAYC,qCCyB3BC,GAAYd,UAAMC,WACtB,SAAmBc,EAAOb,GACxB,IAAQH,EAASU,IAATV,KACR,GAAI,OAAQgB,EAAO,CACjB,I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9H,SACN+H,EAAQ,GACV7H,YAAaF,GAAU8H,EAAQlL,SAG7BmL,GAAS,GACX7H,YAAaF,EAASiI,MAAM,EAAGF,GAAW/H,EAASiI,MAAMF,EAAQ,MAIvE,CAAC7H,EAAUF,iBAGb,OACEzF,wBAAC4F,GAAmBwG,UAClB/J,MAAO,CACLiC,KAAAA,EACAmB,SAAU+B,MAAMC,KAAK,IAAIkG,IAAIlI,IAC7BxE,SAAAA,EACAyE,SAAAA,EACAX,SAAAA,EACAY,SAAUwD,iBAGZnJ,+BACE0G,UAAWA,EACX,aAAY4G,EACZ,cAAY,eAEXlN,6BCpL8BW,GACrC,IAAQE,EAAwBF,EAAxBE,SAAUyF,EAAc3F,EAAd2F,UAEZkH,EAAmCC,UACvC,uBACK9M,GAGH,aAAc,aAAcA,OAAQK,EAAYL,EAAM0D,MACtD+E,WAAYzI,EAAME,SAClBwL,WAAY1L,EAAM8L,WAEpB,CAAC9L,IAGG+M,EAAQC,iBAAeH,GACvB1N,EAAMsI,SAAyB,MAEkBnI,IACnD2N,YAAUJ,EAAiBE,EAAO5N,GADpC2J,4BAGF,OACE7J,wBAACqG,IAAMK,UAAWA,EAAW,gBAAezF,gBAC1CjB,wBAACuG,QAAgBlG,GAAMH,IAAKA,KAC3B,aAAca,eAEbf,wBAACsG,QAAYvF,EAAMX,eACjBgB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { default as Button, type ButtonProps } from './components/Button';
|
|
|
3
3
|
export { default as Clickable, type ClickableProps, type ClickableElement, } from './components/Clickable';
|
|
4
4
|
export { default as IconButton, type IconButtonProps, } from './components/IconButton';
|
|
5
5
|
export { default as Radio, type RadioProps, RadioGroup, type RadioGroupProps, } from './components/Radio';
|
|
6
|
+
export { default as Select, type SelectProps, SelectGroup, type SelectGroupProps, } from './components/Select';
|
|
6
7
|
export { default as Switch, type SwitchProps } from './components/Switch';
|
|
7
8
|
export { default as TextField, type TextFieldProps, } from './components/TextField';
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,IAAI,oBAAoB,EAC/B,uBAAuB,EACvB,KAAK,SAAS,GACf,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACzE,OAAO,EACL,OAAO,IAAI,SAAS,EACpB,KAAK,cAAc,EACnB,KAAK,gBAAgB,GACtB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACL,OAAO,IAAI,UAAU,EACrB,KAAK,eAAe,GACrB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACL,OAAO,IAAI,KAAK,EAChB,KAAK,UAAU,EACf,UAAU,EACV,KAAK,eAAe,GACrB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACzE,OAAO,EACL,OAAO,IAAI,SAAS,EACpB,KAAK,cAAc,GACpB,MAAM,wBAAwB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,IAAI,oBAAoB,EAC/B,uBAAuB,EACvB,KAAK,SAAS,GACf,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACzE,OAAO,EACL,OAAO,IAAI,SAAS,EACpB,KAAK,cAAc,EACnB,KAAK,gBAAgB,GACtB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACL,OAAO,IAAI,UAAU,EACrB,KAAK,eAAe,GACrB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACL,OAAO,IAAI,KAAK,EAChB,KAAK,UAAU,EACf,UAAU,EACV,KAAK,eAAe,GACrB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACL,OAAO,IAAI,MAAM,EACjB,KAAK,WAAW,EAChB,WAAW,EACX,KAAK,gBAAgB,GACtB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACzE,OAAO,EACL,OAAO,IAAI,SAAS,EACpB,KAAK,cAAc,GACpB,MAAM,wBAAwB,CAAA"}
|
package/dist/index.modern.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import e,{useContext as t,useCallback as r,
|
|
1
|
+
import e,{useContext as t,useCallback as r,createContext as n,useMemo as a,useRef as o,useState as i,useEffect as l}from"react";import s,{css as c}from"styled-components";import d from"@charcoal-ui/styled";import{disabledSelector as u,px as p}from"@charcoal-ui/utils";import f from"warning";import{useSwitch as h}from"@react-aria/switch";import{useToggleState as g}from"react-stately";import{useTextField as b}from"@react-aria/textfield";import{useVisuallyHidden as m}from"@react-aria/visually-hidden";function v(){return v=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},v.apply(this,arguments)}function x(e,t){if(null==e)return{};var r,n,a={},o=Object.keys(e);for(n=0;n<o.length;n++)t.indexOf(r=o[n])>=0||(a[r]=e[r]);return a}const y=["to","children"],w={Link:e.forwardRef(function(t,r){let{to:n,children:a}=t,o=x(t,y);/*#__PURE__*/return e.createElement("a",v({href:n,ref:r},o),a)})},E=e.createContext(w);function $({children:t,components:r}){/*#__PURE__*/return e.createElement(E.Provider,{value:v({},w,r)},t)}function k(){return t(E)}const C=d(s);let R,P,S,z=e=>e;const L=["onClick","disabled"],N=e.forwardRef(function(t,r){const{Link:n}=k();if("to"in t){const{onClick:a,disabled:o=!1}=t,i=x(t,L);/*#__PURE__*/return e.createElement(q,v({},i,{as:o?void 0:n,onClick:o?void 0:a,"aria-disabled":o,ref:r}))}/*#__PURE__*/return e.createElement(T,v({},t,{ref:r}))}),O=c(R||(R=z`
|
|
2
2
|
/* Clickable style */
|
|
3
3
|
cursor: pointer;
|
|
4
4
|
|
|
5
5
|
${0} {
|
|
6
6
|
cursor: default;
|
|
7
7
|
}
|
|
8
|
-
`),
|
|
8
|
+
`),u),T=s.button(P||(P=z`
|
|
9
9
|
/* Reset button appearance */
|
|
10
10
|
appearance: none;
|
|
11
11
|
background: transparent;
|
|
@@ -40,7 +40,7 @@ import e,{useContext as t,useCallback as r,useState as n,useMemo as a,useRef as
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
${0}
|
|
43
|
-
`),
|
|
43
|
+
`),O),q=s.span(S||(S=z`
|
|
44
44
|
/* Reset a-tag appearance */
|
|
45
45
|
color: inherit;
|
|
46
46
|
|
|
@@ -53,7 +53,7 @@ import e,{useContext as t,useCallback as r,useState as n,useMemo as a,useRef as
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
${0}
|
|
56
|
-
`),
|
|
56
|
+
`),O);let D;const M=["children","variant","size","fixed","disabled"],H=e.forwardRef(function(t,r){let{children:n,variant:a="Default",size:o="M",fixed:i=!1,disabled:l=!1}=t,s=x(t,M);/*#__PURE__*/return e.createElement(j,v({},s,{disabled:l,variant:a,size:o,fixed:i,ref:r}),n)}),j=s(N).withConfig({shouldForwardProp:e=>"fixed"!==e}).attrs(function(e){return v({},e,function(e){switch(e){case"Overlay":return{font:"text5",background:"surface4"};case"Default":return{font:"text2",background:"surface3"};case"Primary":return{font:"text5",background:"brand"};case"Navigation":return{font:"text5",background:"surface6"};case"Danger":return{font:"text5",background:"assertive"};default:return function(e){throw new Error(0===arguments.length?"unreachable":`unreachable (${JSON.stringify(e)})`)}(e)}}(e.variant),function(e){switch(e){case"S":return{height:32,padding:16};case"M":return{height:40,padding:24}}}(e.size))})(D||(D=(e=>e)`
|
|
57
57
|
width: ${0};
|
|
58
58
|
display: inline-grid;
|
|
59
59
|
align-items: center;
|
|
@@ -66,7 +66,7 @@ import e,{useContext as t,useCallback as r,useState as n,useMemo as a,useRef as
|
|
|
66
66
|
|
|
67
67
|
/* よく考えたらheight=32って定義が存在しないな... */
|
|
68
68
|
height: ${0}px;
|
|
69
|
-
`),e=>e.fixed?"stretch":"min-content",e=>
|
|
69
|
+
`),e=>e.fixed?"stretch":"min-content",e=>C(t=>[t.font[e.font].hover.press,t.bg[e.background].hover.press,t.typography(14).bold.preserveHalfLeading,t.padding.horizontal(e.padding),t.disabled,t.borderRadius("oval"),t.outline.default.focus]),e=>e.height);let F;const G=["variant","size","icon"],I=e.forwardRef(function(t,r){let{variant:n="Default",size:a="M",icon:o}=t,i=x(t,G);return function(e,t){let r;switch(e){case"XS":r="16";break;case"S":case"M":r="24"}const n=/^[0-9]*/.exec(t);if(null==n)throw new Error("Invalid icon name");const[a]=n;a!==r&&console.warn(`IconButton with size "${e}" expect icon size "${r}, but got "${a}"`)}(a,o),/*#__PURE__*/e.createElement(X,v({},i,{ref:r,variant:n,size:a}),/*#__PURE__*/e.createElement("pixiv-icon",{name:o}))}),X=s(N).attrs(function(e){return v({},e,function(e){switch(e){case"Default":return{font:"text3",background:"transparent"};case"Overlay":return{font:"text5",background:"surface4"}}}(e.variant),function(e){switch(e){case"XS":return{width:20,height:20};case"S":return{width:32,height:32};case"M":return{width:40,height:40}}}(e.size))})(F||(F=(e=>e)`
|
|
70
70
|
user-select: none;
|
|
71
71
|
|
|
72
72
|
width: ${0}px;
|
|
@@ -76,7 +76,7 @@ import e,{useContext as t,useCallback as r,useState as n,useMemo as a,useRef as
|
|
|
76
76
|
justify-content: center;
|
|
77
77
|
|
|
78
78
|
${0}
|
|
79
|
-
`),e=>e.width,e=>e.height,({font:e,background:t})=>
|
|
79
|
+
`),e=>e.width,e=>e.height,({font:e,background:t})=>C(r=>[r.font[e],r.bg[t].hover.press,r.disabled,r.borderRadius("oval"),r.outline.default.focus]));let A,B,Y,J,K=e=>e;function Q({value:n,forceChecked:a=!1,disabled:o=!1,children:i}){const{name:l,selected:s,disabled:c,readonly:d,hasError:u,onChange:p}=t(_);f(void 0!==l,'"name" is not Provided for <Radio>. Perhaps you forgot to wrap with <RadioGroup> ?');const h=n===s,g=o||c,b=d&&!h,m=r(e=>{p(e.currentTarget.value)},[p]);/*#__PURE__*/return e.createElement(U,{"aria-disabled":g||b},/*#__PURE__*/e.createElement(V,{name:l,value:n,checked:a||h,hasError:u,onChange:m,disabled:g||b}),null!=i&&/*#__PURE__*/e.createElement(W,null,i))}const U=s.label(A||(A=K`
|
|
80
80
|
display: grid;
|
|
81
81
|
grid-template-columns: auto 1fr;
|
|
82
82
|
grid-gap: ${0};
|
|
@@ -84,7 +84,7 @@ import e,{useContext as t,useCallback as r,useState as n,useMemo as a,useRef as
|
|
|
84
84
|
cursor: pointer;
|
|
85
85
|
|
|
86
86
|
${0}
|
|
87
|
-
`),({theme:e})=>
|
|
87
|
+
`),({theme:e})=>p(e.spacing[4]),C(e=>[e.disabled])),V=s.input.attrs({type:"radio"})(B||(B=K`
|
|
88
88
|
/** Make prior to browser default style */
|
|
89
89
|
&[type='radio'] {
|
|
90
90
|
appearance: none;
|
|
@@ -120,13 +120,58 @@ import e,{useContext as t,useCallback as r,useState as n,useMemo as a,useRef as
|
|
|
120
120
|
|
|
121
121
|
${0}
|
|
122
122
|
}
|
|
123
|
-
`),({hasError:e=!1})=>
|
|
123
|
+
`),({hasError:e=!1})=>C(t=>[t.borderRadius("oval"),t.bg.text5.hover.press,e&&t.outline.assertive]),({theme:e})=>e.color.text4,C(e=>e.bg.brand.hover.press),C(e=>[e.bg.text5.hover.press,e.borderRadius("oval")]),C(e=>e.outline.default.focus)),W=s.div(Y||(Y=K`
|
|
124
124
|
${0}
|
|
125
|
-
`),
|
|
125
|
+
`),C(e=>[e.typography(14)])),Z=s.div(J||(J=K`
|
|
126
126
|
display: grid;
|
|
127
127
|
grid-template-columns: 1fr;
|
|
128
128
|
grid-gap: ${0};
|
|
129
|
-
`),({theme:e})=>
|
|
129
|
+
`),({theme:e})=>p(e.spacing[8])),_=e.createContext({name:void 0,selected:void 0,disabled:!1,readonly:!1,hasError:!1,onChange(){throw new Error("Cannot find onChange() handler. Perhaps you forgot to wrap with <RadioGroup> ?")}});function ee({className:t,value:n,label:a,name:o,onChange:i,disabled:l,readonly:s,hasError:c,children:d}){const u=r(e=>{i(e)},[i]);/*#__PURE__*/return e.createElement(_.Provider,{value:{name:o,selected:n,disabled:null!=l&&l,readonly:null!=s&&s,hasError:null!=c&&c,onChange:u}},/*#__PURE__*/e.createElement(Z,{role:"radiogroup","aria-orientation":"vertical","aria-label":a,"aria-invalid":c,className:t},d))}const te=n({name:void 0,selected:[],disabled:!1,readonly:!1,hasError:!1,onChange(){throw new Error("Cannot find `onChange()` handler. Perhaps you forgot to wrap it with `<SelectGroup />` ?")}});let re,ne,ae,oe,ie,le=e=>e;function se({value:n,forceChecked:a=!1,disabled:o=!1,onChange:i,variant:l="default",children:s}){const{name:c,selected:d,disabled:u,readonly:p,hasError:h,onChange:g}=t(te);f(void 0!==c,'"name" is not Provided for <Select>. Perhaps you forgot to wrap with <SelectGroup> ?');const b=d.includes(n)||a,m=o||u||p,v=r(e=>{e.currentTarget instanceof HTMLInputElement&&(i&&i({value:n,selected:e.currentTarget.checked}),g({value:n,selected:e.currentTarget.checked}))},[i,g,n]);/*#__PURE__*/return e.createElement(ce,{"aria-disabled":m},/*#__PURE__*/e.createElement(ue,{name:c,value:n,hasError:h,checked:b,disabled:m,onChange:v,overlay:"overlay"===l,"aria-invalid":h}),/*#__PURE__*/e.createElement(pe,{overlay:"overlay"===l,hasError:h,"aria-hidden":!0},/*#__PURE__*/e.createElement("pixiv-icon",{name:"24/Check","unsafe-non-guideline-scale":16/24})),Boolean(s)&&/*#__PURE__*/e.createElement(de,null,s))}const ce=s.label(re||(re=le`
|
|
130
|
+
display: grid;
|
|
131
|
+
grid-template-columns: auto 1fr;
|
|
132
|
+
align-items: center;
|
|
133
|
+
position: relative;
|
|
134
|
+
cursor: pointer;
|
|
135
|
+
${0} {
|
|
136
|
+
cursor: default;
|
|
137
|
+
}
|
|
138
|
+
gap: ${0};
|
|
139
|
+
${0}
|
|
140
|
+
`),u,({theme:e})=>p(e.spacing[4]),C(e=>e.disabled)),de=s.div(ne||(ne=le`
|
|
141
|
+
display: flex;
|
|
142
|
+
align-items: center;
|
|
143
|
+
${0}
|
|
144
|
+
`),C(e=>[e.typography(14),e.font.text1])),ue=s.input.attrs({type:"checkbox"})(ae||(ae=le`
|
|
145
|
+
&[type='checkbox'] {
|
|
146
|
+
appearance: none;
|
|
147
|
+
display: block;
|
|
148
|
+
width: 20px;
|
|
149
|
+
height: 20px;
|
|
150
|
+
margin: 0;
|
|
151
|
+
|
|
152
|
+
&:checked {
|
|
153
|
+
${0}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
${0};
|
|
157
|
+
}
|
|
158
|
+
`),C(e=>e.bg.brand.hover.press),({hasError:e,overlay:t})=>C(r=>[r.bg.text3.hover.press,r.borderRadius("oval"),e&&!t&&r.outline.assertive,t&&r.bg.surface4])),pe=s.div(oe||(oe=le`
|
|
159
|
+
position: absolute;
|
|
160
|
+
top: -2px;
|
|
161
|
+
left: -2px;
|
|
162
|
+
box-sizing: border-box;
|
|
163
|
+
display: flex;
|
|
164
|
+
align-items: center;
|
|
165
|
+
justify-content: center;
|
|
166
|
+
|
|
167
|
+
${0}
|
|
168
|
+
|
|
169
|
+
${0}
|
|
170
|
+
`),({hasError:e,overlay:t})=>C(r=>[r.width.px(24),r.height.px(24),r.borderRadius("oval"),r.font.text5,e&&t&&r.outline.assertive]),({overlay:e})=>e&&c(ie||(ie=le`
|
|
171
|
+
border-color: ${0};
|
|
172
|
+
border-width: 2px;
|
|
173
|
+
border-style: solid;
|
|
174
|
+
`),({theme:e})=>e.color.text5));function fe({className:t,name:n,ariaLabel:a,selected:o,onChange:i,disabled:l=!1,readonly:s=!1,hasError:c=!1,children:d}){const u=r(e=>{const t=o.indexOf(e.value);e.selected?t<0&&i([...o,e.value]):t>=0&&i([...o.slice(0,t),...o.slice(t+1)])},[i,o]);/*#__PURE__*/return e.createElement(te.Provider,{value:{name:n,selected:Array.from(new Set(o)),disabled:l,readonly:s,hasError:c,onChange:u}},/*#__PURE__*/e.createElement("div",{className:t,"aria-label":a,"data-testid":"SelectGroup"},d))}let he,ge,be,me=e=>e;const ve=["className","type"];function xe(t){const{disabled:r,className:n}=t,i=a(()=>v({},t,{"aria-label":"children"in t?void 0:t.label,isDisabled:t.disabled,isSelected:t.checked}),[t]),l=g(i),s=o(null),c=x(h(i,l,s).inputProps,ve);/*#__PURE__*/return e.createElement(ye,{className:n,"aria-disabled":r},/*#__PURE__*/e.createElement(Ee,v({},c,{ref:s})),"children"in t?/*#__PURE__*/e.createElement(we,null,t.children):void 0)}const ye=s.label(he||(he=me`
|
|
130
175
|
display: inline-grid;
|
|
131
176
|
grid-template-columns: auto 1fr;
|
|
132
177
|
gap: ${0};
|
|
@@ -138,9 +183,9 @@ import e,{useContext as t,useCallback as r,useState as n,useMemo as a,useRef as
|
|
|
138
183
|
${0} {
|
|
139
184
|
cursor: default;
|
|
140
185
|
}
|
|
141
|
-
`),({theme:e})=>
|
|
186
|
+
`),({theme:e})=>p(e.spacing[4]),C(e=>e.disabled),u),we=s.div(ge||(ge=me`
|
|
142
187
|
${0}
|
|
143
|
-
`),
|
|
188
|
+
`),C(e=>e.typography(14))),Ee=s.input.attrs({type:"checkbox"})(be||(be=me`
|
|
144
189
|
&[type='checkbox'] {
|
|
145
190
|
appearance: none;
|
|
146
191
|
display: inline-flex;
|
|
@@ -173,13 +218,13 @@ import e,{useContext as t,useCallback as r,useState as n,useMemo as a,useRef as
|
|
|
173
218
|
}
|
|
174
219
|
}
|
|
175
220
|
}
|
|
176
|
-
`),
|
|
221
|
+
`),C(e=>[e.borderRadius(16),e.height.px(16),e.bg.text4.hover.press,e.outline.default.focus]),C(e=>[e.bg.text5.hover.press,e.borderRadius("oval")]),C(e=>e.bg.brand.hover.press));let $e,ke,Ce,Re,Pe=e=>e;const Se=["style","className","label","required","requiredText","subLabel"],ze=e.forwardRef(function(t,r){let{style:n,className:a,label:o,required:i=!1,requiredText:l,subLabel:s}=t,c=x(t,Se);/*#__PURE__*/return e.createElement(qe,{style:n,className:a},/*#__PURE__*/e.createElement(Ne,v({ref:r},c),o),i&&/*#__PURE__*/e.createElement(Oe,null,l),/*#__PURE__*/e.createElement(Te,null,/*#__PURE__*/e.createElement("span",null,s)))}),Le=d(s),Ne=s.label($e||($e=Pe`
|
|
177
222
|
${0}
|
|
178
|
-
`),
|
|
223
|
+
`),Le(e=>[e.typography(14).bold,e.font.text1])),Oe=s.span(ke||(ke=Pe`
|
|
179
224
|
${0}
|
|
180
|
-
`),
|
|
225
|
+
`),Le(e=>[e.typography(14),e.font.text3])),Te=s.div(Ce||(Ce=Pe`
|
|
181
226
|
${0}
|
|
182
|
-
`),
|
|
227
|
+
`),Le(e=>[e.typography(14),e.font.text3.hover.press,e.outline.default.focus])),qe=s.div(Re||(Re=Pe`
|
|
183
228
|
display: inline-flex;
|
|
184
229
|
align-items: center;
|
|
185
230
|
|
|
@@ -190,30 +235,51 @@ import e,{useContext as t,useCallback as r,useState as n,useMemo as a,useRef as
|
|
|
190
235
|
> ${0} {
|
|
191
236
|
${0}
|
|
192
237
|
}
|
|
193
|
-
`),
|
|
238
|
+
`),Oe,Le(e=>e.margin.left(4)),Te,Le(e=>e.margin.left("auto")));let De,Me,He,je,Fe,Ge,Ie,Xe,Ae,Be,Ye,Je,Ke,Qe,Ue=e=>e;const Ve=["onChange"],We=["onChange"],Ze=d(s);function _e(...e){return t=>{for(const r of e)"function"==typeof r?r(t):null!==r&&(r.current=t)}}function et(e){return Array.from(e).length}const tt=e.forwardRef(function(t,r){/*#__PURE__*/return e.createElement(void 0!==t.multiline&&t.multiline?nt:rt,v({ref:r},t))}),rt=e.forwardRef(function(t,n){var a;let{onChange:s}=t,c=x(t,Ve);const{className:d,showLabel:u=!1,showCount:p=!1,label:f,requiredText:h,subLabel:g,disabled:y=!1,required:w,invalid:E=!1,assistiveText:$,maxLength:k,prefix:C="",suffix:R=""}=c,{visuallyHiddenProps:P}=m(),S=o(null),z=o(null),L=o(null),[N,O]=i(et(null!=(a=c.value)?a:"")),[T,q]=i(0),[D,M]=i(0),H=void 0===c.value,j=r(e=>{const t=et(e);void 0!==k&&t>k||(H&&O(t),null==s||s(e))},[k,H,s]);l(()=>{var e;O(et(null!=(e=c.value)?e:""))},[c.value]);const{inputProps:F,labelProps:G,descriptionProps:I,errorMessageProps:X}=b(v({inputElementType:"input",isDisabled:y,isRequired:w,validationState:E?"invalid":"valid",description:!E&&$,errorMessage:E&&$,onChange:j},c),S);return l(()=>{const e=new ResizeObserver(e=>{q(e[0].contentRect.width)}),t=new ResizeObserver(e=>{M(e[0].contentRect.width)});return null!==z.current&&e.observe(z.current),null!==L.current&&t.observe(L.current),()=>{t.disconnect(),e.disconnect()}},[]),/*#__PURE__*/e.createElement(at,{className:d,isDisabled:y},/*#__PURE__*/e.createElement(ot,v({label:f,requiredText:h,required:w,subLabel:g},G,u?{}:P)),/*#__PURE__*/e.createElement(it,null,/*#__PURE__*/e.createElement(lt,{ref:z},/*#__PURE__*/e.createElement(ct,null,C)),/*#__PURE__*/e.createElement(dt,v({ref:_e(n,S),invalid:E,extraLeftPadding:T,extraRightPadding:D},F)),/*#__PURE__*/e.createElement(st,{ref:L},/*#__PURE__*/e.createElement(ct,null,R),p&&k&&/*#__PURE__*/e.createElement(ft,null,N,"/",k))),null!=$&&0!==$.length&&/*#__PURE__*/e.createElement(gt,v({invalid:E},E?X:I),$))}),nt=e.forwardRef(function(t,n){var a;let{onChange:s}=t,c=x(t,We);const{className:d,showCount:u=!1,showLabel:p=!1,label:f,requiredText:h,subLabel:g,disabled:y=!1,required:w,invalid:E=!1,assistiveText:$,maxLength:k,autoHeight:C=!1,rows:R=4}=c,{visuallyHiddenProps:P}=m(),S=o(null),z=o(null),[L,N]=i(et(null!=(a=c.value)?a:"")),[O,T]=i(R),q=r(e=>{var t,r;const n=null!=(t=null==(r=`${e.value}\n`.match(/\n/g))?void 0:r.length)?t:1;R<=n&&T(n)},[R]),D=void 0===c.value,M=r(e=>{const t=et(e);void 0!==k&&t>k||(D&&N(t),C&&null!==S.current&&q(S.current),null==s||s(e))},[C,k,D,s,q]);l(()=>{var e;N(et(null!=(e=c.value)?e:""))},[c.value]);const{inputProps:H,labelProps:j,descriptionProps:F,errorMessageProps:G}=b(v({inputElementType:"textarea",isDisabled:y,isRequired:w,validationState:E?"invalid":"valid",description:!E&&$,errorMessage:E&&$,onChange:M},c),z);return l(()=>{C&&null!==S.current&&q(S.current)},[C,q]),/*#__PURE__*/e.createElement(at,{className:d,isDisabled:y},/*#__PURE__*/e.createElement(ot,v({label:f,requiredText:h,required:w,subLabel:g},j,p?P:{})),/*#__PURE__*/e.createElement(ut,{rows:O},/*#__PURE__*/e.createElement(pt,v({ref:_e(S,n,z),invalid:E,rows:O},H)),u&&/*#__PURE__*/e.createElement(ht,null,L)),null!=$&&0!==$.length&&/*#__PURE__*/e.createElement(gt,v({invalid:E},E?G:F),$))}),at=s.div(De||(De=Ue`
|
|
194
239
|
display: flex;
|
|
195
240
|
flex-direction: column;
|
|
196
241
|
|
|
197
242
|
${0}
|
|
198
|
-
`),e=>e.isDisabled&&{opacity:e.theme.elementEffect.disabled.opacity}),
|
|
243
|
+
`),e=>e.isDisabled&&{opacity:e.theme.elementEffect.disabled.opacity}),ot=s(ze)(Me||(Me=Ue`
|
|
199
244
|
${0}
|
|
200
|
-
`),
|
|
245
|
+
`),Ze(e=>e.margin.bottom(8))),it=s.div(He||(He=Ue`
|
|
201
246
|
height: 40px;
|
|
202
247
|
display: grid;
|
|
203
248
|
position: relative;
|
|
204
|
-
`)),
|
|
249
|
+
`)),lt=s.span(je||(je=Ue`
|
|
250
|
+
position: absolute;
|
|
251
|
+
top: 50%;
|
|
252
|
+
left: 8px;
|
|
253
|
+
transform: translateY(-50%);
|
|
254
|
+
`)),st=s.span(Fe||(Fe=Ue`
|
|
255
|
+
position: absolute;
|
|
256
|
+
top: 50%;
|
|
257
|
+
right: 8px;
|
|
258
|
+
transform: translateY(-50%);
|
|
259
|
+
|
|
260
|
+
display: flex;
|
|
261
|
+
gap: 8px;
|
|
262
|
+
`)),ct=s.span(Ge||(Ge=Ue`
|
|
263
|
+
user-select: none;
|
|
264
|
+
|
|
265
|
+
${0}
|
|
266
|
+
`),Ze(e=>[e.typography(14).preserveHalfLeading,e.font.text2])),dt=s.input(Ie||(Ie=Ue`
|
|
205
267
|
border: none;
|
|
206
268
|
box-sizing: border-box;
|
|
207
269
|
outline: none;
|
|
270
|
+
font-family: inherit;
|
|
208
271
|
|
|
209
272
|
/* Prevent zooming for iOS Safari */
|
|
210
273
|
transform-origin: top left;
|
|
211
274
|
transform: scale(0.875);
|
|
212
275
|
width: calc(100% / 0.875);
|
|
213
|
-
height: calc(
|
|
276
|
+
height: calc(100% / 0.875);
|
|
214
277
|
font-size: calc(14px / 0.875);
|
|
215
278
|
line-height: calc(22px / 0.875);
|
|
216
|
-
padding: calc(9px / 0.875)
|
|
279
|
+
padding-top: calc(9px / 0.875);
|
|
280
|
+
padding-bottom: calc(9px / 0.875);
|
|
281
|
+
padding-left: calc((8px + ${0}px) / 0.875);
|
|
282
|
+
padding-right: calc((8px + ${0}px) / 0.875);
|
|
217
283
|
border-radius: calc(4px / 0.875);
|
|
218
284
|
|
|
219
285
|
/* Display box-shadow for iOS Safari */
|
|
@@ -224,18 +290,19 @@ import e,{useContext as t,useCallback as r,useState as n,useMemo as a,useRef as
|
|
|
224
290
|
&::placeholder {
|
|
225
291
|
${0}
|
|
226
292
|
}
|
|
227
|
-
`),e=>
|
|
293
|
+
`),e=>e.extraLeftPadding,e=>e.extraRightPadding,e=>Ze(t=>[t.bg.surface3.hover,t.outline.default.focus,e.invalid&&t.outline.assertive,t.font.text2]),Ze(e=>e.font.text3)),ut=s.div(Xe||(Xe=Ue`
|
|
228
294
|
display: grid;
|
|
229
295
|
position: relative;
|
|
230
296
|
|
|
231
297
|
${0};
|
|
232
|
-
`),({rows:e})=>
|
|
298
|
+
`),({rows:e})=>c(Ae||(Ae=Ue`
|
|
233
299
|
max-height: calc(22px * ${0} + 18px);
|
|
234
|
-
`),e)),
|
|
300
|
+
`),e)),pt=s.textarea(Be||(Be=Ue`
|
|
235
301
|
border: none;
|
|
236
302
|
box-sizing: border-box;
|
|
237
303
|
outline: none;
|
|
238
304
|
resize: none;
|
|
305
|
+
font-family: inherit;
|
|
239
306
|
|
|
240
307
|
/* Prevent zooming for iOS Safari */
|
|
241
308
|
transform-origin: top left;
|
|
@@ -264,22 +331,17 @@ import e,{useContext as t,useCallback as r,useState as n,useMemo as a,useRef as
|
|
|
264
331
|
/* Hide scrollbar for IE, Edge and Firefox */
|
|
265
332
|
-ms-overflow-style: none; /* IE and Edge */
|
|
266
333
|
scrollbar-width: none; /* Firefox */
|
|
267
|
-
`),({rows:e})=>
|
|
334
|
+
`),({rows:e})=>c(Ye||(Ye=Ue`
|
|
268
335
|
height: calc(22px / 0.875 * ${0} + 18px / 0.875);
|
|
269
|
-
`),e),e=>
|
|
270
|
-
position: absolute;
|
|
271
|
-
top: 50%;
|
|
272
|
-
right: 8px;
|
|
273
|
-
transform: translateY(-50%);
|
|
274
|
-
|
|
336
|
+
`),e),e=>Ze(t=>[t.bg.surface3.hover,t.outline.default.focus,e.invalid&&t.outline.assertive,t.font.text2]),Ze(e=>e.font.text3)),ft=s.span(Je||(Je=Ue`
|
|
275
337
|
${0}
|
|
276
|
-
`),
|
|
338
|
+
`),Ze(e=>[e.typography(14).preserveHalfLeading,e.font.text3])),ht=s.span(Ke||(Ke=Ue`
|
|
277
339
|
position: absolute;
|
|
278
340
|
bottom: 9px;
|
|
279
341
|
right: 8px;
|
|
280
342
|
|
|
281
343
|
${0}
|
|
282
|
-
`),
|
|
344
|
+
`),Ze(e=>[e.typography(14).preserveHalfLeading,e.font.text3])),gt=s.p(Qe||(Qe=Ue`
|
|
283
345
|
${0}
|
|
284
|
-
`),e=>
|
|
346
|
+
`),e=>Ze(t=>[t.typography(14),t.margin.top(8),t.margin.bottom(0),t.font[e.invalid?"assertive":"text1"]]));export{H as Button,N as Clickable,$ as ComponentAbstraction,I as IconButton,Q as Radio,ee as RadioGroup,se as Select,fe as SelectGroup,xe as Switch,tt as TextField,k as useComponentAbstraction};
|
|
285
347
|
//# sourceMappingURL=index.modern.js.map
|