smarthr-ui 79.0.0 → 79.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,7 +12,8 @@ const classNameGenerator = ce({
12
12
  const AnchorButton = forwardRef(({ size = 'default', prefix, suffix, wide = false, variant = 'secondary', inactiveReason, target, rel, elementAs, className, children, ...props }, ref) => {
13
13
  const actualClassName = useMemo(() => classNameGenerator({ className }), [className]);
14
14
  const actualSuffix = useMemo(() => {
15
- if (target === '_blank' && !prefix && !suffix) {
15
+ // target="_blank" だが OpenInNewTabIcon を表示したくない場合 suffix に null を指定すれば表示しないようにしている
16
+ if (target === '_blank' && !prefix && suffix === undefined) {
16
17
  return jsx(OpenInNewTabIcon, {});
17
18
  }
18
19
  return suffix;
@@ -1 +1 @@
1
- {"version":3,"file":"AnchorButton.js","sources":["../../../src/components/Button/AnchorButton.tsx"],"sourcesContent":["'use client'\n\nimport {\n type ComponentPropsWithoutRef,\n type ElementType,\n type FC,\n type PropsWithoutRef,\n type ReactElement,\n type Ref,\n forwardRef,\n useMemo,\n} from 'react'\nimport { tv } from 'tailwind-variants'\n\nimport { OpenInNewTabIcon } from '../OpenInNewTabIcon'\n\nimport { ButtonWrapper } from './ButtonWrapper'\nimport { DisabledReason } from './DisabledReason'\n\nimport type { BaseProps } from './types'\nimport type { ElementRef, ElementRefProps } from '../../types'\n\ntype ElementProps<T extends ElementType> = Omit<\n ComponentPropsWithoutRef<T>,\n keyof Props<T> & ElementRefProps<T>\n>\n\ntype Props<T extends ElementType> = Omit<BaseProps, 'variant' | 'disabledReason'> & {\n /** next/linkなどのカスタムコンポーネントを指定します。指定がない場合はデフォルトで `a` タグが使用されます。 */\n elementAs?: T\n // tertiaryはAnchorButtonでは使用不可\n variant?: Exclude<BaseProps['variant'], 'tertiary'>\n inactiveReason?: BaseProps['disabledReason']\n}\n\nconst classNameGenerator = tv({\n base: 'smarthr-ui-AnchorButton',\n})\n\nconst AnchorButton = forwardRef(\n <T extends ElementType = 'a'>(\n {\n size = 'default',\n prefix,\n suffix,\n wide = false,\n variant = 'secondary',\n inactiveReason,\n target,\n rel,\n elementAs,\n className,\n children,\n ...props\n }: PropsWithoutRef<Props<T>> & ElementProps<T>,\n ref: Ref<ElementRef<T>>,\n ): ReactElement => {\n const actualClassName = useMemo(() => classNameGenerator({ className }), [className])\n\n const actualSuffix = useMemo(() => {\n if (target === '_blank' && !prefix && !suffix) {\n return <OpenInNewTabIcon />\n }\n\n return suffix\n }, [prefix, suffix, target])\n\n const button = (\n <ButtonWrapper\n {...props}\n size={size}\n wide={wide}\n variant={variant}\n className={actualClassName}\n target={target}\n rel={rel === undefined && target === '_blank' ? 'noopener noreferrer' : rel}\n isAnchor\n anchorRef={ref}\n elementAs={elementAs}\n prefix={prefix}\n suffix={actualSuffix}\n >\n {children}\n </ButtonWrapper>\n )\n\n if (!props.href && inactiveReason) {\n return <DisabledReason button={button} disabledReason={inactiveReason} />\n }\n\n return button\n },\n)\n\n// 型キャストなしで ForwardRefExoticComponent に合わせた型をエクスポートするための処理\ntype AnchorButtonType = <T extends ElementType = 'a'>(\n props: Props<T> & ElementProps<T> & ElementRefProps<T>,\n) => ReturnType<FC>\n\nconst ForwardedAnchorButton = AnchorButton as unknown as AnchorButtonType & {\n displayName: string\n}\n\n// BottomFixedArea での判定に用いるために displayName を明示的に設定する\nForwardedAnchorButton.displayName = 'AnchorButton'\n\nexport { ForwardedAnchorButton as AnchorButton }\n"],"names":[],"mappings":";;;;;;;;AAmCA;AACE;AACD;AAED;AAkBI;AAEA;;;;AAKE;;AAGF;AAmBA;;;AAIA;AACF;AAQF;AAIA;AACA;;"}
1
+ {"version":3,"file":"AnchorButton.js","sources":["../../../src/components/Button/AnchorButton.tsx"],"sourcesContent":["'use client'\n\nimport {\n type ComponentPropsWithoutRef,\n type ElementType,\n type FC,\n type PropsWithoutRef,\n type ReactElement,\n type Ref,\n forwardRef,\n useMemo,\n} from 'react'\nimport { tv } from 'tailwind-variants'\n\nimport { OpenInNewTabIcon } from '../OpenInNewTabIcon'\n\nimport { ButtonWrapper } from './ButtonWrapper'\nimport { DisabledReason } from './DisabledReason'\n\nimport type { BaseProps } from './types'\nimport type { ElementRef, ElementRefProps } from '../../types'\n\ntype ElementProps<T extends ElementType> = Omit<\n ComponentPropsWithoutRef<T>,\n keyof Props<T> & ElementRefProps<T>\n>\n\ntype Props<T extends ElementType> = Omit<BaseProps, 'variant' | 'disabledReason'> & {\n /** next/linkなどのカスタムコンポーネントを指定します。指定がない場合はデフォルトで `a` タグが使用されます。 */\n elementAs?: T\n // tertiaryはAnchorButtonでは使用不可\n variant?: Exclude<BaseProps['variant'], 'tertiary'>\n inactiveReason?: BaseProps['disabledReason']\n}\n\nconst classNameGenerator = tv({\n base: 'smarthr-ui-AnchorButton',\n})\n\nconst AnchorButton = forwardRef(\n <T extends ElementType = 'a'>(\n {\n size = 'default',\n prefix,\n suffix,\n wide = false,\n variant = 'secondary',\n inactiveReason,\n target,\n rel,\n elementAs,\n className,\n children,\n ...props\n }: PropsWithoutRef<Props<T>> & ElementProps<T>,\n ref: Ref<ElementRef<T>>,\n ): ReactElement => {\n const actualClassName = useMemo(() => classNameGenerator({ className }), [className])\n\n const actualSuffix = useMemo(() => {\n // target=\"_blank\" だが OpenInNewTabIcon を表示したくない場合 suffix に null を指定すれば表示しないようにしている\n if (target === '_blank' && !prefix && suffix === undefined) {\n return <OpenInNewTabIcon />\n }\n\n return suffix\n }, [prefix, suffix, target])\n\n const button = (\n <ButtonWrapper\n {...props}\n size={size}\n wide={wide}\n variant={variant}\n className={actualClassName}\n target={target}\n rel={rel === undefined && target === '_blank' ? 'noopener noreferrer' : rel}\n isAnchor\n anchorRef={ref}\n elementAs={elementAs}\n prefix={prefix}\n suffix={actualSuffix}\n >\n {children}\n </ButtonWrapper>\n )\n\n if (!props.href && inactiveReason) {\n return <DisabledReason button={button} disabledReason={inactiveReason} />\n }\n\n return button\n },\n)\n\n// 型キャストなしで ForwardRefExoticComponent に合わせた型をエクスポートするための処理\ntype AnchorButtonType = <T extends ElementType = 'a'>(\n props: Props<T> & ElementProps<T> & ElementRefProps<T>,\n) => ReturnType<FC>\n\nconst ForwardedAnchorButton = AnchorButton as unknown as AnchorButtonType & {\n displayName: string\n}\n\n// BottomFixedArea での判定に用いるために displayName を明示的に設定する\nForwardedAnchorButton.displayName = 'AnchorButton'\n\nexport { ForwardedAnchorButton as AnchorButton }\n"],"names":[],"mappings":";;;;;;;;AAmCA;AACE;AACD;AAED;AAkBI;AAEA;;;;;AAME;;AAGF;AAmBA;;;AAIA;AACF;AAQF;AAIA;AACA;;"}
@@ -257,7 +257,7 @@ declare const classNameGenerator: import("tailwind-variants").TVReturnType<{
257
257
  type StyleVariants = VariantProps<typeof classNameGenerator>;
258
258
  type Props = PropsWithChildren<Omit<StyleVariants, 'type'> & Required<Pick<StyleVariants, 'type'>> & {
259
259
  /** コンポーネント右の領域 */
260
- subActionArea: ReactNode;
260
+ subActionArea?: ReactNode;
261
261
  /** 閉じるボタン押下時に発火させる関数 */
262
262
  onClose?: () => void;
263
263
  /** role 属性 */
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationBar.js","sources":["../../../src/components/NotificationBar/NotificationBar.tsx"],"sourcesContent":["import {\n type ComponentProps,\n type ComponentPropsWithoutRef,\n type FC,\n Fragment,\n type PropsWithChildren,\n type ReactNode,\n memo,\n useMemo,\n} from 'react'\nimport { type VariantProps, tv } from 'tailwind-variants'\n\nimport { Localizer } from '../../intl'\nimport { Base } from '../Base'\nimport { Button } from '../Button'\nimport {\n FaCircleCheckIcon,\n FaCircleExclamationIcon,\n FaCircleInfoIcon,\n FaRotateIcon,\n FaTriangleExclamationIcon,\n FaXmarkIcon,\n WarningIcon,\n} from '../Icon'\nimport { Cluster } from '../Layout'\nimport { Text } from '../Text'\n\nconst classNameGenerator = tv({\n slots: {\n wrapper:\n 'smarthr-ui-NotificationBar shr-flex shr-items-baseline shr-justify-between shr-gap-0.5 shr-p-0.75',\n inner: 'shr-flex-grow',\n messageArea: [\n 'smarthr-ui-NotificationBar-messageArea',\n 'shr-flex shr-grow',\n '[&_.smarthr-ui-Icon-withText]:shr-leading-tight',\n ],\n icon: '',\n actionArea: 'smarthr-ui-NotificationBar-actionArea -shr-my-0.5 shr-shrink-0',\n closeButton:\n 'smarthr-ui-NotificationBar-closeButton -shr-mb-0.5 -shr-mr-0.5 -shr-mt-0.5 shr-flex-shrink-0 shr-text-black',\n },\n variants: {\n /** 下地 */\n base: {\n none: {},\n base: {\n wrapper: 'shr-py-1 shr-pe-1 shr-ps-1.5',\n },\n },\n /** メッセージの種類 */\n type: {\n info: {\n icon: 'shr-text-grey',\n },\n success: {},\n warning: {\n icon: 'shr-text-black',\n },\n error: {},\n sync: {\n icon: 'shr-text-main',\n },\n },\n /** 強調するかどうか */\n bold: {\n true: '',\n false: '',\n },\n /** スライドインするかどうか */\n animate: {\n true: {\n wrapper: 'shr-animate-[notification-bar-slide-in_0.2s_ease-out]',\n },\n },\n },\n compoundVariants: [\n {\n type: ['info', 'success', 'warning', 'error', 'sync'],\n bold: false,\n className: {\n wrapper: 'shr-bg-white shr-text-black',\n },\n },\n {\n type: 'success',\n bold: false,\n className: {\n icon: 'shr-text-main',\n },\n },\n {\n type: 'error',\n bold: false,\n className: {\n icon: 'shr-text-danger',\n },\n },\n {\n type: ['info', 'sync'],\n bold: true,\n className: {\n wrapper: 'shr-bg-white',\n },\n },\n {\n type: 'success',\n bold: true,\n className: {\n wrapper: 'shr-bg-main shr-text-white',\n icon: 'shr-text-white',\n closeButton:\n 'shr-text-white hover:[&]:shr-bg-main-darken focus-visible:[&]:shr-bg-main-darken',\n },\n },\n {\n type: 'warning',\n bold: true,\n className: {\n wrapper: 'shr-bg-warning-yellow shr-text-black',\n closeButton:\n 'shr-text-black hover:[&]:shr-bg-warning-yellow-darken focus-visible:[&]:shr-bg-warning-yellow-darken',\n },\n },\n {\n type: 'error',\n bold: true,\n className: {\n wrapper: 'shr-bg-danger shr-text-white',\n icon: 'shr-text-white',\n closeButton:\n 'shr-text-white hover:[&]:shr-bg-danger-darken focus-visible:[&]:shr-bg-danger-darken',\n },\n },\n ],\n})\n\ntype StyleVariants = VariantProps<typeof classNameGenerator>\ntype Props = PropsWithChildren<\n Omit<StyleVariants, 'type'> &\n Required<Pick<StyleVariants, 'type'>> & {\n /** コンポーネント右の領域 */\n subActionArea: ReactNode\n /** 閉じるボタン押下時に発火させる関数 */\n onClose?: () => void\n /** role 属性 */\n role?: 'alert' | 'status'\n }\n>\ntype ElementProps = Omit<ComponentPropsWithoutRef<'div'>, keyof Props>\ntype BaseProps = Pick<ComponentProps<typeof Base>, 'layer'>\ntype ActualProps = Props & ElementProps & BaseProps\n\nconst ABSTRACT_ICON_MAPPER = {\n info: FaCircleInfoIcon,\n success: FaCircleCheckIcon,\n error: FaCircleExclamationIcon,\n sync: FaRotateIcon,\n}\nconst ICON_MAPPER = {\n normal: {\n ...ABSTRACT_ICON_MAPPER,\n warning: WarningIcon,\n },\n bold: {\n ...ABSTRACT_ICON_MAPPER,\n warning: FaTriangleExclamationIcon,\n },\n} as const\n\nconst ROLE_STATUS_TYPE_REGEX = /^(info|sync)$/\n\nexport const NotificationBar: FC<ActualProps> = ({\n type,\n bold,\n animate,\n subActionArea,\n onClose,\n children,\n role,\n base,\n layer,\n className,\n ...props\n}) => {\n const actualRole = useMemo(() => {\n if (role) {\n return role\n }\n\n return ROLE_STATUS_TYPE_REGEX.test(type) ? 'status' : 'alert'\n }, [role, type])\n const { WrapBase, baseProps } = useMemo(\n () =>\n base === 'base'\n ? {\n WrapBase: Base,\n baseProps: {\n layer,\n overflow: 'hidden' as ComponentProps<typeof Base>['overflow'],\n },\n }\n : {\n WrapBase: Fragment,\n baseProps: {},\n },\n [base, layer],\n )\n const classNames = useMemo(() => {\n const { wrapper, inner, messageArea, icon, actionArea, closeButton } = classNameGenerator({\n type,\n bold: !!bold,\n base: base || 'none',\n })\n\n return {\n wrapper: wrapper({ animate, className }),\n inner: inner(),\n messageArea: messageArea(),\n icon: icon(),\n actionArea: actionArea(),\n closeButton: closeButton(),\n }\n }, [animate, base, bold, type, className])\n\n return (\n <WrapBase {...baseProps}>\n <div {...props} className={classNames.wrapper} role={actualRole}>\n <Cluster gap={1} align=\"center\" justify=\"flex-end\" className={classNames.inner}>\n <MessageArea bold={bold} type={type} classNames={classNames}>\n {children}\n </MessageArea>\n {subActionArea && (\n <Cluster align=\"center\" justify=\"flex-end\" className={classNames.actionArea}>\n {subActionArea}\n </Cluster>\n )}\n </Cluster>\n <CloseButton onClose={onClose} className={classNames.closeButton} />\n </div>\n </WrapBase>\n )\n}\n\nconst MessageArea = memo<\n Pick<ActualProps, 'children' | 'bold' | 'type'> & {\n classNames: { messageArea: string; icon: string }\n }\n>(({ children, bold, type, classNames }) => {\n const Icon = ICON_MAPPER[bold ? 'bold' : 'normal'][type]\n\n return (\n <Text\n prefixIcon={<Icon iconGap={0.5} className={classNames.icon} />}\n className={classNames.messageArea}\n as=\"div\"\n >\n {children}\n </Text>\n )\n})\n\nconst CloseButton = memo<Pick<ActualProps, 'onClose'> & { className: string }>(\n ({ onClose, className }) =>\n onClose && (\n <Button variant=\"text\" size=\"s\" onClick={onClose} className={className}>\n <FaXmarkIcon\n alt={\n <Localizer id=\"smarthr-ui/NotificationBar/closeButtonIconAlt\" defaultText=\"閉じる\" />\n }\n />\n </Button>\n ),\n)\n"],"names":["tv","_jsx","_jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAM,kBAAkB,GAAGA,EAAE,CAAC;AAC5B,IAAA,KAAK,EAAE;AACL,QAAA,OAAO,EACL,mGAAmG;AACrG,QAAA,KAAK,EAAE,eAAe;AACtB,QAAA,WAAW,EAAE;YACX,wCAAwC;YACxC,mBAAmB;YACnB,iDAAiD;AAClD,SAAA;AACD,QAAA,IAAI,EAAE,EAAE;AACR,QAAA,UAAU,EAAE,gEAAgE;AAC5E,QAAA,WAAW,EACT,6GAA6G;AAChH,KA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EAAC,KAAK,EAAA,QAAA,EAEP,QAAQ,EAAA,CACJ;AAEX,CAAC,CAAC;AAEF,MAAM,WAAW,GAAG,IAAI,CACtB,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,KACrB,OAAO,KACLA,GAAA,CAAC,MAAM,EAAA,EAAC,OAAO,EAAC,MAAM,EAAC,IAAI,EAAC,GAAG,EAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAA,QAAA,EACpEA,GAAA,CAAC,WAAW,EAAA,EACV,GAAG,EACDA,GAAA,CAAC,SAAS,IAAC,EAAE,EAAC,+CAA+C,EAAC,WAAW,EAAC,oBAAK,EAAA,CAAG,EAAA,CAEpF,EAAA,CACK,CACV,CACJ;;;;"}
1
+ {"version":3,"file":"NotificationBar.js","sources":["../../../src/components/NotificationBar/NotificationBar.tsx"],"sourcesContent":["import {\n type ComponentProps,\n type ComponentPropsWithoutRef,\n type FC,\n Fragment,\n type PropsWithChildren,\n type ReactNode,\n memo,\n useMemo,\n} from 'react'\nimport { type VariantProps, tv } from 'tailwind-variants'\n\nimport { Localizer } from '../../intl'\nimport { Base } from '../Base'\nimport { Button } from '../Button'\nimport {\n FaCircleCheckIcon,\n FaCircleExclamationIcon,\n FaCircleInfoIcon,\n FaRotateIcon,\n FaTriangleExclamationIcon,\n FaXmarkIcon,\n WarningIcon,\n} from '../Icon'\nimport { Cluster } from '../Layout'\nimport { Text } from '../Text'\n\nconst classNameGenerator = tv({\n slots: {\n wrapper:\n 'smarthr-ui-NotificationBar shr-flex shr-items-baseline shr-justify-between shr-gap-0.5 shr-p-0.75',\n inner: 'shr-flex-grow',\n messageArea: [\n 'smarthr-ui-NotificationBar-messageArea',\n 'shr-flex shr-grow',\n '[&_.smarthr-ui-Icon-withText]:shr-leading-tight',\n ],\n icon: '',\n actionArea: 'smarthr-ui-NotificationBar-actionArea -shr-my-0.5 shr-shrink-0',\n closeButton:\n 'smarthr-ui-NotificationBar-closeButton -shr-mb-0.5 -shr-mr-0.5 -shr-mt-0.5 shr-flex-shrink-0 shr-text-black',\n },\n variants: {\n /** 下地 */\n base: {\n none: {},\n base: {\n wrapper: 'shr-py-1 shr-pe-1 shr-ps-1.5',\n },\n },\n /** メッセージの種類 */\n type: {\n info: {\n icon: 'shr-text-grey',\n },\n success: {},\n warning: {\n icon: 'shr-text-black',\n },\n error: {},\n sync: {\n icon: 'shr-text-main',\n },\n },\n /** 強調するかどうか */\n bold: {\n true: '',\n false: '',\n },\n /** スライドインするかどうか */\n animate: {\n true: {\n wrapper: 'shr-animate-[notification-bar-slide-in_0.2s_ease-out]',\n },\n },\n },\n compoundVariants: [\n {\n type: ['info', 'success', 'warning', 'error', 'sync'],\n bold: false,\n className: {\n wrapper: 'shr-bg-white shr-text-black',\n },\n },\n {\n type: 'success',\n bold: false,\n className: {\n icon: 'shr-text-main',\n },\n },\n {\n type: 'error',\n bold: false,\n className: {\n icon: 'shr-text-danger',\n },\n },\n {\n type: ['info', 'sync'],\n bold: true,\n className: {\n wrapper: 'shr-bg-white',\n },\n },\n {\n type: 'success',\n bold: true,\n className: {\n wrapper: 'shr-bg-main shr-text-white',\n icon: 'shr-text-white',\n closeButton:\n 'shr-text-white hover:[&]:shr-bg-main-darken focus-visible:[&]:shr-bg-main-darken',\n },\n },\n {\n type: 'warning',\n bold: true,\n className: {\n wrapper: 'shr-bg-warning-yellow shr-text-black',\n closeButton:\n 'shr-text-black hover:[&]:shr-bg-warning-yellow-darken focus-visible:[&]:shr-bg-warning-yellow-darken',\n },\n },\n {\n type: 'error',\n bold: true,\n className: {\n wrapper: 'shr-bg-danger shr-text-white',\n icon: 'shr-text-white',\n closeButton:\n 'shr-text-white hover:[&]:shr-bg-danger-darken focus-visible:[&]:shr-bg-danger-darken',\n },\n },\n ],\n})\n\ntype StyleVariants = VariantProps<typeof classNameGenerator>\ntype Props = PropsWithChildren<\n Omit<StyleVariants, 'type'> &\n Required<Pick<StyleVariants, 'type'>> & {\n /** コンポーネント右の領域 */\n subActionArea?: ReactNode\n /** 閉じるボタン押下時に発火させる関数 */\n onClose?: () => void\n /** role 属性 */\n role?: 'alert' | 'status'\n }\n>\ntype ElementProps = Omit<ComponentPropsWithoutRef<'div'>, keyof Props>\ntype BaseProps = Pick<ComponentProps<typeof Base>, 'layer'>\ntype ActualProps = Props & ElementProps & BaseProps\n\nconst ABSTRACT_ICON_MAPPER = {\n info: FaCircleInfoIcon,\n success: FaCircleCheckIcon,\n error: FaCircleExclamationIcon,\n sync: FaRotateIcon,\n}\nconst ICON_MAPPER = {\n normal: {\n ...ABSTRACT_ICON_MAPPER,\n warning: WarningIcon,\n },\n bold: {\n ...ABSTRACT_ICON_MAPPER,\n warning: FaTriangleExclamationIcon,\n },\n} as const\n\nconst ROLE_STATUS_TYPE_REGEX = /^(info|sync)$/\n\nexport const NotificationBar: FC<ActualProps> = ({\n type,\n bold,\n animate,\n subActionArea,\n onClose,\n children,\n role,\n base,\n layer,\n className,\n ...props\n}) => {\n const actualRole = useMemo(() => {\n if (role) {\n return role\n }\n\n return ROLE_STATUS_TYPE_REGEX.test(type) ? 'status' : 'alert'\n }, [role, type])\n const { WrapBase, baseProps } = useMemo(\n () =>\n base === 'base'\n ? {\n WrapBase: Base,\n baseProps: {\n layer,\n overflow: 'hidden' as ComponentProps<typeof Base>['overflow'],\n },\n }\n : {\n WrapBase: Fragment,\n baseProps: {},\n },\n [base, layer],\n )\n const classNames = useMemo(() => {\n const { wrapper, inner, messageArea, icon, actionArea, closeButton } = classNameGenerator({\n type,\n bold: !!bold,\n base: base || 'none',\n })\n\n return {\n wrapper: wrapper({ animate, className }),\n inner: inner(),\n messageArea: messageArea(),\n icon: icon(),\n actionArea: actionArea(),\n closeButton: closeButton(),\n }\n }, [animate, base, bold, type, className])\n\n return (\n <WrapBase {...baseProps}>\n <div {...props} className={classNames.wrapper} role={actualRole}>\n <Cluster gap={1} align=\"center\" justify=\"flex-end\" className={classNames.inner}>\n <MessageArea bold={bold} type={type} classNames={classNames}>\n {children}\n </MessageArea>\n {subActionArea && (\n <Cluster align=\"center\" justify=\"flex-end\" className={classNames.actionArea}>\n {subActionArea}\n </Cluster>\n )}\n </Cluster>\n <CloseButton onClose={onClose} className={classNames.closeButton} />\n </div>\n </WrapBase>\n )\n}\n\nconst MessageArea = memo<\n Pick<ActualProps, 'children' | 'bold' | 'type'> & {\n classNames: { messageArea: string; icon: string }\n }\n>(({ children, bold, type, classNames }) => {\n const Icon = ICON_MAPPER[bold ? 'bold' : 'normal'][type]\n\n return (\n <Text\n prefixIcon={<Icon iconGap={0.5} className={classNames.icon} />}\n className={classNames.messageArea}\n as=\"div\"\n >\n {children}\n </Text>\n )\n})\n\nconst CloseButton = memo<Pick<ActualProps, 'onClose'> & { className: string }>(\n ({ onClose, className }) =>\n onClose && (\n <Button variant=\"text\" size=\"s\" onClick={onClose} className={className}>\n <FaXmarkIcon\n alt={\n <Localizer id=\"smarthr-ui/NotificationBar/closeButtonIconAlt\" defaultText=\"閉じる\" />\n }\n />\n </Button>\n ),\n)\n"],"names":["tv","_jsx","_jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAM,kBAAkB,GAAGA,EAAE,CAAC;AAC5B,IAAA,KAAK,EAAE;AACL,QAAA,OAAO,EACL,mGAAmG;AACrG,QAAA,KAAK,EAAE,eAAe;AACtB,QAAA,WAAW,EAAE;YACX,wCAAwC;YACxC,mBAAmB;YACnB,iDAAiD;AAClD,SAAA;AACD,QAAA,IAAI,EAAE,EAAE;AACR,QAAA,UAAU,EAAE,gEAAgE;AAC5E,QAAA,WAAW,EACT,6GAA6G;AAChH,KAAA;AACD,IAAA,QAAQ,EAAE;;AAER,QAAA,IAAI,EAAE;AACJ,YAAA,IAAI,EAAE,EAAE;AACR,YAAA,IAAI,EAAE;AACJ,gBAAA,OAAO,EAAE,8BAA8B;AACxC,aAAA;AACF,SAAA;;AAED,QAAA,IAAI,EAAE;AACJ,YAAA,IAAI,EAAE;AACJ,gBAAA,IAAI,EAAE,eAAe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O,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAA,QAAA,EACpEA,GAAA,CAAC,WAAW,EAAA,EACV,GAAG,EACDA,GAAA,CAAC,SAAS,IAAC,EAAE,EAAC,+CAA+C,EAAC,WAAW,EAAC,oBAAK,EAAA,CAAG,EAAA,CAEpF,EAAA,CACK,CACV,CACJ;;;;"}
@@ -34,7 +34,8 @@ const suffixWrapperClassName = suffixWrapper();
34
34
  const ActualTextLink = forwardRef(({ elementAs, href, target, rel, onClick, children, prefix, suffix, className, size, ...others }, ref) => {
35
35
  const Anchor = elementAs || 'a';
36
36
  const actualSuffix = useMemo(() => {
37
- if (target === '_blank' && !prefix && !suffix) {
37
+ // target="_blank" だが OpenInNewTabIcon を表示したくない場合 suffix に null を指定すれば表示しないようにしている
38
+ if (target === '_blank' && !prefix && suffix === undefined) {
38
39
  return jsx(OpenInNewTabIcon, {});
39
40
  }
40
41
  return suffix;
@@ -1 +1 @@
1
- {"version":3,"file":"TextLink.js","sources":["../../../src/components/TextLink/TextLink.tsx"],"sourcesContent":["import {\n type ComponentPropsWithoutRef,\n type ElementType,\n type FC,\n type MouseEvent,\n type PropsWithoutRef,\n type ReactNode,\n type Ref,\n forwardRef,\n memo,\n useMemo,\n} from 'react'\nimport { type VariantProps, tv } from 'tailwind-variants'\n\nimport { OpenInNewTabIcon } from '../OpenInNewTabIcon'\n\nimport type { ElementRef, ElementRefProps } from '../../types'\n\ntype ElementProps<T extends ElementType> = Omit<\n ComponentPropsWithoutRef<T>,\n (keyof Props<T> & ElementRefProps<T>) | 'color'\n>\n\ntype Props<T extends ElementType> = VariantProps<typeof classNameGenerator> & {\n /** リンクをクリックした時に発火するコールバック関数 */\n onClick?: (e: MouseEvent) => void\n /** テキストの前に表示するアイコン */\n prefix?: ReactNode\n /** テキストの後ろに表示するアイコン */\n suffix?: ReactNode\n /** TextLinkを利用しつつnext/linkなどと併用する場合に指定する */\n elementAs?: T\n}\n\ntype TextLinkComponent = <T extends ElementType = 'a'>(\n props: Props<T> & ElementProps<T> & ElementRefProps<T>,\n) => ReturnType<FC>\n\nconst classNameGenerator = tv({\n slots: {\n anchor: [\n 'shr-text-link shr-no-underline shr-shadow-underline',\n 'forced-colors:shr-underline',\n '[&:not([href])]:shr-shadow-none [&:not([href])]:forced-colors:shr-no-underline',\n '[.smarthr-ui-Th_&]:shr-text-link-darken',\n ],\n prefixWrapper: 'shr-me-0.25 shr-align-middle',\n suffixWrapper: 'shr-ms-0.25 shr-align-middle',\n },\n variants: {\n size: {\n XS: {\n anchor: 'shr-text-xs',\n },\n S: {\n anchor: 'shr-text-sm',\n },\n M: {\n anchor: 'shr-text-base',\n },\n },\n },\n})\nconst { anchor, prefixWrapper, suffixWrapper } = classNameGenerator()\nconst prefixWrapperClassName = prefixWrapper()\nconst suffixWrapperClassName = suffixWrapper()\n\nconst ActualTextLink: TextLinkComponent = forwardRef(\n <T extends ElementType = 'a'>(\n {\n elementAs,\n href,\n target,\n rel,\n onClick,\n children,\n prefix,\n suffix,\n className,\n size,\n ...others\n }: PropsWithoutRef<Props<T>> & ElementProps<T>,\n ref: Ref<ElementRef<T>>,\n ) => {\n const Anchor = elementAs || 'a'\n const actualSuffix = useMemo(() => {\n if (target === '_blank' && !prefix && !suffix) {\n return <OpenInNewTabIcon />\n }\n\n return suffix\n }, [prefix, suffix, target])\n const actualHref = useMemo(() => {\n if (href) {\n return href\n }\n\n if (onClick) {\n return ''\n }\n\n return undefined\n }, [href, onClick])\n const actualRel = useMemo(\n () => (rel === undefined && target === '_blank' ? 'noopener noreferrer' : rel),\n [rel, target],\n )\n const anchorClassName = useMemo(() => anchor({ size, className }), [size, className])\n\n const actualOnClick = useMemo(() => {\n if (!onClick) {\n return undefined\n }\n\n if (href) {\n return onClick\n }\n\n return (e: MouseEvent) => {\n e.preventDefault()\n onClick(e)\n }\n }, [onClick, href])\n\n return (\n <Anchor\n {...others}\n ref={ref}\n href={actualHref}\n target={target}\n rel={actualRel}\n onClick={actualOnClick}\n className={anchorClassName}\n >\n {prefix && <span className={prefixWrapperClassName}>{prefix}</span>}\n {children}\n {actualSuffix && <span className={suffixWrapperClassName}>{actualSuffix}</span>}\n </Anchor>\n )\n },\n)\n\nexport const TextLink = memo(ActualTextLink) as typeof ActualTextLink\n"],"names":["tv","_jsx","_jsxs"],"mappings":";;;;;AAsCA,MAAM,kBAAkB,GAAGA,EAAE,CAAC;AAC5B,IAAA,KAAK,EAAE;AACL,QAAA,MAAM,EAAE;YACN,qDAAqD;YACrD,6BAA6B;YAC7B,gFAAgF;YAChF,yCAAyC;AAC1C,SAAA;AACD,QAAA,aAAa,EAAE,8BAA8B;AAC7C,QAAA,aAAa,EAAE,8BAA8B;AAC9C,KAAA;AACD,IAAA,QAAQ,EAAE;AACR,QAAA,IAAI,EAAE;AACJ,YAAA,EAAE,EAAE;AACF,gBAAA,MAAM,EAAE,aAAa;AACtB,aAAA;AACD,YAAA,CAAC,EAAE;AACD,gBAAA,MAAM,EAAE,aAAa;AACtB,aAAA;AACD,YAAA,CAAC,EAAE;AACD,gBAAA,MAAM,EAAE,eAAe;AACxB,aAAA;AACF,SAAA;AACF,KAAA;AACF,CAAA,CAAC;AACF,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,GAAG,kBAAkB,EAAE;AACrE,MAAM,sBAAsB,GAAG,aAAa,EAAE;AAC9C,MAAM,sBAAsB,GAAG,aAAa,EAAE;AAE9C,MAAM,cAAc,GAAsB,UAAU,CAClD,CACE,EACE,SAAS,EACT,IAAI,EACJ,MAAM,EACN,GAAG,EACH,OAAO,EACP,QAAQ,EACR,MAAM,EACN,MAAM,EACN,SAAS,EACT,IAAI,EACJ,GAAG,MAAM,EACmC,EAC9C,GAAuB,KACrB;AACF,IAAA,MAAM,MAAM,GAAG,SAAS,IAAI,GAAG;AAC/B,IAAA,MAAM,YAAY,GAAG,OAAO,CAAC,MAAK;QAChC,IAAI,MAAM,KAAK,QAAQ,IAAI,CAAC,MAAM,IAAI,CAAC,MAA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,CAEzB,MAAM,IAAID,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAE,sBAAsB,EAAA,QAAA,EAAG,MAAM,EAAA,CAAQ,EAClE,QAAQ,EACR,YAAY,IAAIA,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAE,sBAAsB,EAAA,QAAA,EAAG,YAAY,EAAA,CAAQ,CAAA,EAAA,CACxE;AAEb,CAAC,CACF;MAEY,QAAQ,GAAG,IAAI,CAAC,cAAc;;;;"}
1
+ {"version":3,"file":"TextLink.js","sources":["../../../src/components/TextLink/TextLink.tsx"],"sourcesContent":["import {\n type ComponentPropsWithoutRef,\n type ElementType,\n type FC,\n type MouseEvent,\n type PropsWithoutRef,\n type ReactNode,\n type Ref,\n forwardRef,\n memo,\n useMemo,\n} from 'react'\nimport { type VariantProps, tv } from 'tailwind-variants'\n\nimport { OpenInNewTabIcon } from '../OpenInNewTabIcon'\n\nimport type { ElementRef, ElementRefProps } from '../../types'\n\ntype ElementProps<T extends ElementType> = Omit<\n ComponentPropsWithoutRef<T>,\n (keyof Props<T> & ElementRefProps<T>) | 'color'\n>\n\ntype Props<T extends ElementType> = VariantProps<typeof classNameGenerator> & {\n /** リンクをクリックした時に発火するコールバック関数 */\n onClick?: (e: MouseEvent) => void\n /** テキストの前に表示するアイコン */\n prefix?: ReactNode\n /** テキストの後ろに表示するアイコン */\n suffix?: ReactNode\n /** TextLinkを利用しつつnext/linkなどと併用する場合に指定する */\n elementAs?: T\n}\n\ntype TextLinkComponent = <T extends ElementType = 'a'>(\n props: Props<T> & ElementProps<T> & ElementRefProps<T>,\n) => ReturnType<FC>\n\nconst classNameGenerator = tv({\n slots: {\n anchor: [\n 'shr-text-link shr-no-underline shr-shadow-underline',\n 'forced-colors:shr-underline',\n '[&:not([href])]:shr-shadow-none [&:not([href])]:forced-colors:shr-no-underline',\n '[.smarthr-ui-Th_&]:shr-text-link-darken',\n ],\n prefixWrapper: 'shr-me-0.25 shr-align-middle',\n suffixWrapper: 'shr-ms-0.25 shr-align-middle',\n },\n variants: {\n size: {\n XS: {\n anchor: 'shr-text-xs',\n },\n S: {\n anchor: 'shr-text-sm',\n },\n M: {\n anchor: 'shr-text-base',\n },\n },\n },\n})\nconst { anchor, prefixWrapper, suffixWrapper } = classNameGenerator()\nconst prefixWrapperClassName = prefixWrapper()\nconst suffixWrapperClassName = suffixWrapper()\n\nconst ActualTextLink: TextLinkComponent = forwardRef(\n <T extends ElementType = 'a'>(\n {\n elementAs,\n href,\n target,\n rel,\n onClick,\n children,\n prefix,\n suffix,\n className,\n size,\n ...others\n }: PropsWithoutRef<Props<T>> & ElementProps<T>,\n ref: Ref<ElementRef<T>>,\n ) => {\n const Anchor = elementAs || 'a'\n const actualSuffix = useMemo(() => {\n // target=\"_blank\" だが OpenInNewTabIcon を表示したくない場合 suffix に null を指定すれば表示しないようにしている\n if (target === '_blank' && !prefix && suffix === undefined) {\n return <OpenInNewTabIcon />\n }\n\n return suffix\n }, [prefix, suffix, target])\n const actualHref = useMemo(() => {\n if (href) {\n return href\n }\n\n if (onClick) {\n return ''\n }\n\n return undefined\n }, [href, onClick])\n const actualRel = useMemo(\n () => (rel === undefined && target === '_blank' ? 'noopener noreferrer' : rel),\n [rel, target],\n )\n const anchorClassName = useMemo(() => anchor({ size, className }), [size, className])\n\n const actualOnClick = useMemo(() => {\n if (!onClick) {\n return undefined\n }\n\n if (href) {\n return onClick\n }\n\n return (e: MouseEvent) => {\n e.preventDefault()\n onClick(e)\n }\n }, [onClick, href])\n\n return (\n <Anchor\n {...others}\n ref={ref}\n href={actualHref}\n target={target}\n rel={actualRel}\n onClick={actualOnClick}\n className={anchorClassName}\n >\n {prefix && <span className={prefixWrapperClassName}>{prefix}</span>}\n {children}\n {actualSuffix && <span className={suffixWrapperClassName}>{actualSuffix}</span>}\n </Anchor>\n )\n },\n)\n\nexport const TextLink = memo(ActualTextLink) as typeof ActualTextLink\n"],"names":["tv","_jsx","_jsxs"],"mappings":";;;;;AAsCA,MAAM,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G,YAAY,EAAA,CAAQ,CAAA,EAAA,CACxE;AAEb,CAAC,CACF;MAEY,QAAQ,GAAG,IAAI,CAAC,cAAc;;;;"}
@@ -14,7 +14,8 @@ const classNameGenerator = (0, tailwind_variants_1.tv)({
14
14
  const AnchorButton = (0, react_1.forwardRef)(({ size = 'default', prefix, suffix, wide = false, variant = 'secondary', inactiveReason, target, rel, elementAs, className, children, ...props }, ref) => {
15
15
  const actualClassName = (0, react_1.useMemo)(() => classNameGenerator({ className }), [className]);
16
16
  const actualSuffix = (0, react_1.useMemo)(() => {
17
- if (target === '_blank' && !prefix && !suffix) {
17
+ // target="_blank" だが OpenInNewTabIcon を表示したくない場合 suffix に null を指定すれば表示しないようにしている
18
+ if (target === '_blank' && !prefix && suffix === undefined) {
18
19
  return (0, jsx_runtime_1.jsx)(OpenInNewTabIcon_1.OpenInNewTabIcon, {});
19
20
  }
20
21
  return suffix;
@@ -1 +1 @@
1
- {"version":3,"file":"AnchorButton.js","sourceRoot":"","sources":["../../../src/components/Button/AnchorButton.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAA;;;;AAEZ,iCASc;AACd,yDAAsC;AAEtC,0DAAsD;AAEtD,mDAA+C;AAC/C,qDAAiD;AAkBjD,MAAM,kBAAkB,GAAG,IAAA,sBAAE,EAAC;IAC5B,IAAI,EAAE,yBAAyB;CAChC,CAAC,CAAA;AAEF,MAAM,YAAY,GAAG,IAAA,kBAAU,EAC7B,CACE,EACE,IAAI,GAAG,SAAS,EAChB,MAAM,EACN,MAAM,EACN,IAAI,GAAG,KAAK,EACZ,OAAO,GAAG,WAAW,EACrB,cAAc,EACd,MAAM,EACN,GAAG,EACH,SAAS,EACT,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACoC,EAC9C,GAAuB,EACT,EAAE;IAChB,MAAM,eAAe,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,kBAAkB,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAA;IAErF,MAAM,YAAY,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE;QAChC,IAAI,MAAM,KAAK,QAAQ,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC;YAC9C,OAAO,uBAAC,mCAAgB,KAAG,CAAA;QAC7B,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IAE5B,MAAM,MAAM,GAAG,CACb,uBAAC,6BAAa,OACR,KAAK,EACT,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,eAAe,EAC1B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,GAAG,KAAK,SAAS,IAAI,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,GAAG,EAC3E,QAAQ,QACR,SAAS,EAAE,GAAG,EACd,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,YAAY,YAEnB,QAAQ,GACK,CACjB,CAAA;IAED,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,cAAc,EAAE,CAAC;QAClC,OAAO,uBAAC,+BAAc,IAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,GAAI,CAAA;IAC3E,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CACF,CAAA;AAOD,MAAM,qBAAqB,GAAG,YAE7B,CAAA;AAKiC,6CAAY;AAH9C,oDAAoD;AACpD,qBAAqB,CAAC,WAAW,GAAG,cAAc,CAAA","sourcesContent":["'use client'\n\nimport {\n type ComponentPropsWithoutRef,\n type ElementType,\n type FC,\n type PropsWithoutRef,\n type ReactElement,\n type Ref,\n forwardRef,\n useMemo,\n} from 'react'\nimport { tv } from 'tailwind-variants'\n\nimport { OpenInNewTabIcon } from '../OpenInNewTabIcon'\n\nimport { ButtonWrapper } from './ButtonWrapper'\nimport { DisabledReason } from './DisabledReason'\n\nimport type { BaseProps } from './types'\nimport type { ElementRef, ElementRefProps } from '../../types'\n\ntype ElementProps<T extends ElementType> = Omit<\n ComponentPropsWithoutRef<T>,\n keyof Props<T> & ElementRefProps<T>\n>\n\ntype Props<T extends ElementType> = Omit<BaseProps, 'variant' | 'disabledReason'> & {\n /** next/linkなどのカスタムコンポーネントを指定します。指定がない場合はデフォルトで `a` タグが使用されます。 */\n elementAs?: T\n // tertiaryはAnchorButtonでは使用不可\n variant?: Exclude<BaseProps['variant'], 'tertiary'>\n inactiveReason?: BaseProps['disabledReason']\n}\n\nconst classNameGenerator = tv({\n base: 'smarthr-ui-AnchorButton',\n})\n\nconst AnchorButton = forwardRef(\n <T extends ElementType = 'a'>(\n {\n size = 'default',\n prefix,\n suffix,\n wide = false,\n variant = 'secondary',\n inactiveReason,\n target,\n rel,\n elementAs,\n className,\n children,\n ...props\n }: PropsWithoutRef<Props<T>> & ElementProps<T>,\n ref: Ref<ElementRef<T>>,\n ): ReactElement => {\n const actualClassName = useMemo(() => classNameGenerator({ className }), [className])\n\n const actualSuffix = useMemo(() => {\n if (target === '_blank' && !prefix && !suffix) {\n return <OpenInNewTabIcon />\n }\n\n return suffix\n }, [prefix, suffix, target])\n\n const button = (\n <ButtonWrapper\n {...props}\n size={size}\n wide={wide}\n variant={variant}\n className={actualClassName}\n target={target}\n rel={rel === undefined && target === '_blank' ? 'noopener noreferrer' : rel}\n isAnchor\n anchorRef={ref}\n elementAs={elementAs}\n prefix={prefix}\n suffix={actualSuffix}\n >\n {children}\n </ButtonWrapper>\n )\n\n if (!props.href && inactiveReason) {\n return <DisabledReason button={button} disabledReason={inactiveReason} />\n }\n\n return button\n },\n)\n\n// 型キャストなしで ForwardRefExoticComponent に合わせた型をエクスポートするための処理\ntype AnchorButtonType = <T extends ElementType = 'a'>(\n props: Props<T> & ElementProps<T> & ElementRefProps<T>,\n) => ReturnType<FC>\n\nconst ForwardedAnchorButton = AnchorButton as unknown as AnchorButtonType & {\n displayName: string\n}\n\n// BottomFixedArea での判定に用いるために displayName を明示的に設定する\nForwardedAnchorButton.displayName = 'AnchorButton'\n\nexport { ForwardedAnchorButton as AnchorButton }\n"]}
1
+ {"version":3,"file":"AnchorButton.js","sourceRoot":"","sources":["../../../src/components/Button/AnchorButton.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAA;;;;AAEZ,iCASc;AACd,yDAAsC;AAEtC,0DAAsD;AAEtD,mDAA+C;AAC/C,qDAAiD;AAkBjD,MAAM,kBAAkB,GAAG,IAAA,sBAAE,EAAC;IAC5B,IAAI,EAAE,yBAAyB;CAChC,CAAC,CAAA;AAEF,MAAM,YAAY,GAAG,IAAA,kBAAU,EAC7B,CACE,EACE,IAAI,GAAG,SAAS,EAChB,MAAM,EACN,MAAM,EACN,IAAI,GAAG,KAAK,EACZ,OAAO,GAAG,WAAW,EACrB,cAAc,EACd,MAAM,EACN,GAAG,EACH,SAAS,EACT,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACoC,EAC9C,GAAuB,EACT,EAAE;IAChB,MAAM,eAAe,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,kBAAkB,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAA;IAErF,MAAM,YAAY,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE;QAChC,kFAAkF;QAClF,IAAI,MAAM,KAAK,QAAQ,IAAI,CAAC,MAAM,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YAC3D,OAAO,uBAAC,mCAAgB,KAAG,CAAA;QAC7B,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IAE5B,MAAM,MAAM,GAAG,CACb,uBAAC,6BAAa,OACR,KAAK,EACT,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,eAAe,EAC1B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,GAAG,KAAK,SAAS,IAAI,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,GAAG,EAC3E,QAAQ,QACR,SAAS,EAAE,GAAG,EACd,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,YAAY,YAEnB,QAAQ,GACK,CACjB,CAAA;IAED,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,cAAc,EAAE,CAAC;QAClC,OAAO,uBAAC,+BAAc,IAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,GAAI,CAAA;IAC3E,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CACF,CAAA;AAOD,MAAM,qBAAqB,GAAG,YAE7B,CAAA;AAKiC,6CAAY;AAH9C,oDAAoD;AACpD,qBAAqB,CAAC,WAAW,GAAG,cAAc,CAAA","sourcesContent":["'use client'\n\nimport {\n type ComponentPropsWithoutRef,\n type ElementType,\n type FC,\n type PropsWithoutRef,\n type ReactElement,\n type Ref,\n forwardRef,\n useMemo,\n} from 'react'\nimport { tv } from 'tailwind-variants'\n\nimport { OpenInNewTabIcon } from '../OpenInNewTabIcon'\n\nimport { ButtonWrapper } from './ButtonWrapper'\nimport { DisabledReason } from './DisabledReason'\n\nimport type { BaseProps } from './types'\nimport type { ElementRef, ElementRefProps } from '../../types'\n\ntype ElementProps<T extends ElementType> = Omit<\n ComponentPropsWithoutRef<T>,\n keyof Props<T> & ElementRefProps<T>\n>\n\ntype Props<T extends ElementType> = Omit<BaseProps, 'variant' | 'disabledReason'> & {\n /** next/linkなどのカスタムコンポーネントを指定します。指定がない場合はデフォルトで `a` タグが使用されます。 */\n elementAs?: T\n // tertiaryはAnchorButtonでは使用不可\n variant?: Exclude<BaseProps['variant'], 'tertiary'>\n inactiveReason?: BaseProps['disabledReason']\n}\n\nconst classNameGenerator = tv({\n base: 'smarthr-ui-AnchorButton',\n})\n\nconst AnchorButton = forwardRef(\n <T extends ElementType = 'a'>(\n {\n size = 'default',\n prefix,\n suffix,\n wide = false,\n variant = 'secondary',\n inactiveReason,\n target,\n rel,\n elementAs,\n className,\n children,\n ...props\n }: PropsWithoutRef<Props<T>> & ElementProps<T>,\n ref: Ref<ElementRef<T>>,\n ): ReactElement => {\n const actualClassName = useMemo(() => classNameGenerator({ className }), [className])\n\n const actualSuffix = useMemo(() => {\n // target=\"_blank\" だが OpenInNewTabIcon を表示したくない場合 suffix に null を指定すれば表示しないようにしている\n if (target === '_blank' && !prefix && suffix === undefined) {\n return <OpenInNewTabIcon />\n }\n\n return suffix\n }, [prefix, suffix, target])\n\n const button = (\n <ButtonWrapper\n {...props}\n size={size}\n wide={wide}\n variant={variant}\n className={actualClassName}\n target={target}\n rel={rel === undefined && target === '_blank' ? 'noopener noreferrer' : rel}\n isAnchor\n anchorRef={ref}\n elementAs={elementAs}\n prefix={prefix}\n suffix={actualSuffix}\n >\n {children}\n </ButtonWrapper>\n )\n\n if (!props.href && inactiveReason) {\n return <DisabledReason button={button} disabledReason={inactiveReason} />\n }\n\n return button\n },\n)\n\n// 型キャストなしで ForwardRefExoticComponent に合わせた型をエクスポートするための処理\ntype AnchorButtonType = <T extends ElementType = 'a'>(\n props: Props<T> & ElementProps<T> & ElementRefProps<T>,\n) => ReturnType<FC>\n\nconst ForwardedAnchorButton = AnchorButton as unknown as AnchorButtonType & {\n displayName: string\n}\n\n// BottomFixedArea での判定に用いるために displayName を明示的に設定する\nForwardedAnchorButton.displayName = 'AnchorButton'\n\nexport { ForwardedAnchorButton as AnchorButton }\n"]}
@@ -257,7 +257,7 @@ declare const classNameGenerator: import("tailwind-variants").TVReturnType<{
257
257
  type StyleVariants = VariantProps<typeof classNameGenerator>;
258
258
  type Props = PropsWithChildren<Omit<StyleVariants, 'type'> & Required<Pick<StyleVariants, 'type'>> & {
259
259
  /** コンポーネント右の領域 */
260
- subActionArea: ReactNode;
260
+ subActionArea?: ReactNode;
261
261
  /** 閉じるボタン押下時に発火させる関数 */
262
262
  onClose?: () => void;
263
263
  /** role 属性 */
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationBar.js","sourceRoot":"","sources":["../../../src/components/NotificationBar/NotificationBar.tsx"],"names":[],"mappings":";;;;AAAA,iCASc;AACd,yDAAyD;AAEzD,qCAAsC;AACtC,kCAA8B;AAC9B,sCAAkC;AAClC,kCAQgB;AAChB,sCAAmC;AACnC,kCAA8B;AAE9B,MAAM,kBAAkB,GAAG,IAAA,sBAAE,EAAC;IAC5B,KAAK,EAAE;QACL,OAAO,EACL,mGAAmG;QACrG,KAAK,EAAE,eAAe;QACtB,WAAW,EAAE;YACX,wCAAwC;YACxC,mBAAmB;YACnB,iDAAiD;SAClD;QACD,IAAI,EAAE,EAAE;QACR,UAAU,EAAE,gEAAgE;QAC5E,WAAW,EACT,6GAA6G;KAChH;IACD,QAAQ,EAAE;QACR,SAAS;QACT,IAAI,EAAE;YACJ,IAAI,EAAE,EAAE;YACR,IAAI,EAAE;gBACJ,OAAO,EAAE,8BAA8B;aACxC;SACF;QACD,eAAe;QACf,IAAI,EAAE;YACJ,IAAI,EAAE;gBACJ,IAAI,EAAE,eAAe;aACtB;YACD,OAAO,EAAE,EAAE;YACX,OAAO,EAAE;gBACP,IAAI,EAAE,gBAAgB;aACvB;YACD,KAAK,EAAE,EAAE;YACT,IAAI,EAAE;gBACJ,IAAI,EAAE,eAAe;aACtB;SACF;QACD,eAAe;QACf,IAAI,EAAE;YACJ,IAAI,EAAE,EAAE;YACR,KAAK,EAAE,EAAE;SACV;QACD,mBAAmB;QACnB,OAAO,EAAE;YACP,IAAI,EAAE;gBACJ,OAAO,EAAE,uDAAuD;aACjE;SACF;KACF;IACD,gBAAgB,EAAE;QAChB;YACE,IAAI,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC;YACrD,IAAI,E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ACjC,EAAE,EAAC,KAAK,YAEP,QAAQ,GACJ,CACR,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,MAAM,WAAW,GAAG,IAAA,YAAI,EACtB,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,CACzB,OAAO,IAAI,CACT,uBAAC,eAAM,IAAC,OAAO,EAAC,MAAM,EAAC,IAAI,EAAC,GAAG,EAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,YACpE,uBAAC,kBAAW,IACV,GAAG,EACD,uBAAC,gBAAS,IAAC,EAAE,EAAC,+CAA+C,EAAC,WAAW,EAAC,oBAAK,GAAG,GAEpF,GACK,CACV,CACJ,CAAA","sourcesContent":["import {\n type ComponentProps,\n type ComponentPropsWithoutRef,\n type FC,\n Fragment,\n type PropsWithChildren,\n type ReactNode,\n memo,\n useMemo,\n} from 'react'\nimport { type VariantProps, tv } from 'tailwind-variants'\n\nimport { Localizer } from '../../intl'\nimport { Base } from '../Base'\nimport { Button } from '../Button'\nimport {\n FaCircleCheckIcon,\n FaCircleExclamationIcon,\n FaCircleInfoIcon,\n FaRotateIcon,\n FaTriangleExclamationIcon,\n FaXmarkIcon,\n WarningIcon,\n} from '../Icon'\nimport { Cluster } from '../Layout'\nimport { Text } from '../Text'\n\nconst classNameGenerator = tv({\n slots: {\n wrapper:\n 'smarthr-ui-NotificationBar shr-flex shr-items-baseline shr-justify-between shr-gap-0.5 shr-p-0.75',\n inner: 'shr-flex-grow',\n messageArea: [\n 'smarthr-ui-NotificationBar-messageArea',\n 'shr-flex shr-grow',\n '[&_.smarthr-ui-Icon-withText]:shr-leading-tight',\n ],\n icon: '',\n actionArea: 'smarthr-ui-NotificationBar-actionArea -shr-my-0.5 shr-shrink-0',\n closeButton:\n 'smarthr-ui-NotificationBar-closeButton -shr-mb-0.5 -shr-mr-0.5 -shr-mt-0.5 shr-flex-shrink-0 shr-text-black',\n },\n variants: {\n /** 下地 */\n base: {\n none: {},\n base: {\n wrapper: 'shr-py-1 shr-pe-1 shr-ps-1.5',\n },\n },\n /** メッセージの種類 */\n type: {\n info: {\n icon: 'shr-text-grey',\n },\n success: {},\n warning: {\n icon: 'shr-text-black',\n },\n error: {},\n sync: {\n icon: 'shr-text-main',\n },\n },\n /** 強調するかどうか */\n bold: {\n true: '',\n false: '',\n },\n /** スライドインするかどうか */\n animate: {\n true: {\n wrapper: 'shr-animate-[notification-bar-slide-in_0.2s_ease-out]',\n },\n },\n },\n compoundVariants: [\n {\n type: ['info', 'success', 'warning', 'error', 'sync'],\n bold: false,\n className: {\n wrapper: 'shr-bg-white shr-text-black',\n },\n },\n {\n type: 'success',\n bold: false,\n className: {\n icon: 'shr-text-main',\n },\n },\n {\n type: 'error',\n bold: false,\n className: {\n icon: 'shr-text-danger',\n },\n },\n {\n type: ['info', 'sync'],\n bold: true,\n className: {\n wrapper: 'shr-bg-white',\n },\n },\n {\n type: 'success',\n bold: true,\n className: {\n wrapper: 'shr-bg-main shr-text-white',\n icon: 'shr-text-white',\n closeButton:\n 'shr-text-white hover:[&]:shr-bg-main-darken focus-visible:[&]:shr-bg-main-darken',\n },\n },\n {\n type: 'warning',\n bold: true,\n className: {\n wrapper: 'shr-bg-warning-yellow shr-text-black',\n closeButton:\n 'shr-text-black hover:[&]:shr-bg-warning-yellow-darken focus-visible:[&]:shr-bg-warning-yellow-darken',\n },\n },\n {\n type: 'error',\n bold: true,\n className: {\n wrapper: 'shr-bg-danger shr-text-white',\n icon: 'shr-text-white',\n closeButton:\n 'shr-text-white hover:[&]:shr-bg-danger-darken focus-visible:[&]:shr-bg-danger-darken',\n },\n },\n ],\n})\n\ntype StyleVariants = VariantProps<typeof classNameGenerator>\ntype Props = PropsWithChildren<\n Omit<StyleVariants, 'type'> &\n Required<Pick<StyleVariants, 'type'>> & {\n /** コンポーネント右の領域 */\n subActionArea: ReactNode\n /** 閉じるボタン押下時に発火させる関数 */\n onClose?: () => void\n /** role 属性 */\n role?: 'alert' | 'status'\n }\n>\ntype ElementProps = Omit<ComponentPropsWithoutRef<'div'>, keyof Props>\ntype BaseProps = Pick<ComponentProps<typeof Base>, 'layer'>\ntype ActualProps = Props & ElementProps & BaseProps\n\nconst ABSTRACT_ICON_MAPPER = {\n info: FaCircleInfoIcon,\n success: FaCircleCheckIcon,\n error: FaCircleExclamationIcon,\n sync: FaRotateIcon,\n}\nconst ICON_MAPPER = {\n normal: {\n ...ABSTRACT_ICON_MAPPER,\n warning: WarningIcon,\n },\n bold: {\n ...ABSTRACT_ICON_MAPPER,\n warning: FaTriangleExclamationIcon,\n },\n} as const\n\nconst ROLE_STATUS_TYPE_REGEX = /^(info|sync)$/\n\nexport const NotificationBar: FC<ActualProps> = ({\n type,\n bold,\n animate,\n subActionArea,\n onClose,\n children,\n role,\n base,\n layer,\n className,\n ...props\n}) => {\n const actualRole = useMemo(() => {\n if (role) {\n return role\n }\n\n return ROLE_STATUS_TYPE_REGEX.test(type) ? 'status' : 'alert'\n }, [role, type])\n const { WrapBase, baseProps } = useMemo(\n () =>\n base === 'base'\n ? {\n WrapBase: Base,\n baseProps: {\n layer,\n overflow: 'hidden' as ComponentProps<typeof Base>['overflow'],\n },\n }\n : {\n WrapBase: Fragment,\n baseProps: {},\n },\n [base, layer],\n )\n const classNames = useMemo(() => {\n const { wrapper, inner, messageArea, icon, actionArea, closeButton } = classNameGenerator({\n type,\n bold: !!bold,\n base: base || 'none',\n })\n\n return {\n wrapper: wrapper({ animate, className }),\n inner: inner(),\n messageArea: messageArea(),\n icon: icon(),\n actionArea: actionArea(),\n closeButton: closeButton(),\n }\n }, [animate, base, bold, type, className])\n\n return (\n <WrapBase {...baseProps}>\n <div {...props} className={classNames.wrapper} role={actualRole}>\n <Cluster gap={1} align=\"center\" justify=\"flex-end\" className={classNames.inner}>\n <MessageArea bold={bold} type={type} classNames={classNames}>\n {children}\n </MessageArea>\n {subActionArea && (\n <Cluster align=\"center\" justify=\"flex-end\" className={classNames.actionArea}>\n {subActionArea}\n </Cluster>\n )}\n </Cluster>\n <CloseButton onClose={onClose} className={classNames.closeButton} />\n </div>\n </WrapBase>\n )\n}\n\nconst MessageArea = memo<\n Pick<ActualProps, 'children' | 'bold' | 'type'> & {\n classNames: { messageArea: string; icon: string }\n }\n>(({ children, bold, type, classNames }) => {\n const Icon = ICON_MAPPER[bold ? 'bold' : 'normal'][type]\n\n return (\n <Text\n prefixIcon={<Icon iconGap={0.5} className={classNames.icon} />}\n className={classNames.messageArea}\n as=\"div\"\n >\n {children}\n </Text>\n )\n})\n\nconst CloseButton = memo<Pick<ActualProps, 'onClose'> & { className: string }>(\n ({ onClose, className }) =>\n onClose && (\n <Button variant=\"text\" size=\"s\" onClick={onClose} className={className}>\n <FaXmarkIcon\n alt={\n <Localizer id=\"smarthr-ui/NotificationBar/closeButtonIconAlt\" defaultText=\"閉じる\" />\n }\n />\n </Button>\n ),\n)\n"]}
1
+ {"version":3,"file":"NotificationBar.js","sourceRoot":"","sources":["../../../src/components/NotificationBar/NotificationBar.tsx"],"names":[],"mappings":";;;;AAAA,iCASc;AACd,yDAAyD;AAEzD,qCAAsC;AACtC,kCAA8B;AAC9B,sCAAkC;AAClC,kCAQgB;AAChB,sCAAmC;AACnC,kCAA8B;AAE9B,MAAM,kBAAkB,GAAG,IAAA,sBAAE,EAAC;IAC5B,KAAK,EAAE;QACL,OAAO,EACL,mGAAmG;QACrG,KAAK,EAAE,eAAe;QACtB,WAAW,EAAE;YACX,wCAAwC;YACxC,mBAAmB;YACnB,iDAAiD;SAClD;QACD,IAAI,EAAE,EAAE;QACR,UAAU,EAAE,gEAAgE;QAC5E,WAAW,EACT,6GAA6G;KAChH;IACD,QAAQ,EAAE;QACR,SAAS;QACT,IAAI,EAAE;YACJ,IAAI,EAAE,EAAE;YACR,IAAI,EAAE;gBACJ,OAAO,EAAE,8BAA8B;aACxC;SACF;QACD,eAAe;QACf,IAAI,EAAE;YACJ,IAAI,EAAE;gBACJ,IAAI,EAAE,eAAe;aACtB;YACD,OAAO,EAAE,EAAE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A,eAAe,mBAsE3B;AAED,MAAM,WAAW,GAAG,IAAA,YAAI,EAItB,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE;IACzC,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAA;IAExD,OAAO,CACL,uBAAC,WAAI,IACH,UAAU,EAAE,uBAAC,IAAI,IAAC,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,UAAU,CAAC,IAAI,GAAI,EAC9D,SAAS,EAAE,UAAU,CAAC,WAAW,EACjC,EAAE,EAAC,KAAK,YAEP,QAAQ,GACJ,CACR,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,MAAM,WAAW,GAAG,IAAA,YAAI,EACtB,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,CACzB,OAAO,IAAI,CACT,uBAAC,eAAM,IAAC,OAAO,EAAC,MAAM,EAAC,IAAI,EAAC,GAAG,EAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,YACpE,uBAAC,kBAAW,IACV,GAAG,EACD,uBAAC,gBAAS,IAAC,EAAE,EAAC,+CAA+C,EAAC,WAAW,EAAC,oBAAK,GAAG,GAEpF,GACK,CACV,CACJ,CAAA","sourcesContent":["import {\n type ComponentProps,\n type ComponentPropsWithoutRef,\n type FC,\n Fragment,\n type PropsWithChildren,\n type ReactNode,\n memo,\n useMemo,\n} from 'react'\nimport { type VariantProps, tv } from 'tailwind-variants'\n\nimport { Localizer } from '../../intl'\nimport { Base } from '../Base'\nimport { Button } from '../Button'\nimport {\n FaCircleCheckIcon,\n FaCircleExclamationIcon,\n FaCircleInfoIcon,\n FaRotateIcon,\n FaTriangleExclamationIcon,\n FaXmarkIcon,\n WarningIcon,\n} from '../Icon'\nimport { Cluster } from '../Layout'\nimport { Text } from '../Text'\n\nconst classNameGenerator = tv({\n slots: {\n wrapper:\n 'smarthr-ui-NotificationBar shr-flex shr-items-baseline shr-justify-between shr-gap-0.5 shr-p-0.75',\n inner: 'shr-flex-grow',\n messageArea: [\n 'smarthr-ui-NotificationBar-messageArea',\n 'shr-flex shr-grow',\n '[&_.smarthr-ui-Icon-withText]:shr-leading-tight',\n ],\n icon: '',\n actionArea: 'smarthr-ui-NotificationBar-actionArea -shr-my-0.5 shr-shrink-0',\n closeButton:\n 'smarthr-ui-NotificationBar-closeButton -shr-mb-0.5 -shr-mr-0.5 -shr-mt-0.5 shr-flex-shrink-0 shr-text-black',\n },\n variants: {\n /** 下地 */\n base: {\n none: {},\n base: {\n wrapper: 'shr-py-1 shr-pe-1 shr-ps-1.5',\n },\n },\n /** メッセージの種類 */\n type: {\n info: {\n icon: 'shr-text-grey',\n },\n success: {},\n warning: {\n icon: 'shr-text-black',\n },\n error: {},\n sync: {\n icon: 'shr-text-main',\n },\n },\n /** 強調するかどうか */\n bold: {\n true: '',\n false: '',\n },\n /** スライドインするかどうか */\n animate: {\n true: {\n wrapper: 'shr-animate-[notification-bar-slide-in_0.2s_ease-out]',\n },\n },\n },\n compoundVariants: [\n {\n type: ['info', 'success', 'warning', 'error', 'sync'],\n bold: false,\n className: {\n wrapper: 'shr-bg-white shr-text-black',\n },\n },\n {\n type: 'success',\n bold: false,\n className: {\n icon: 'shr-text-main',\n },\n },\n {\n type: 'error',\n bold: false,\n className: {\n icon: 'shr-text-danger',\n },\n },\n {\n type: ['info', 'sync'],\n bold: true,\n className: {\n wrapper: 'shr-bg-white',\n },\n },\n {\n type: 'success',\n bold: true,\n className: {\n wrapper: 'shr-bg-main shr-text-white',\n icon: 'shr-text-white',\n closeButton:\n 'shr-text-white hover:[&]:shr-bg-main-darken focus-visible:[&]:shr-bg-main-darken',\n },\n },\n {\n type: 'warning',\n bold: true,\n className: {\n wrapper: 'shr-bg-warning-yellow shr-text-black',\n closeButton:\n 'shr-text-black hover:[&]:shr-bg-warning-yellow-darken focus-visible:[&]:shr-bg-warning-yellow-darken',\n },\n },\n {\n type: 'error',\n bold: true,\n className: {\n wrapper: 'shr-bg-danger shr-text-white',\n icon: 'shr-text-white',\n closeButton:\n 'shr-text-white hover:[&]:shr-bg-danger-darken focus-visible:[&]:shr-bg-danger-darken',\n },\n },\n ],\n})\n\ntype StyleVariants = VariantProps<typeof classNameGenerator>\ntype Props = PropsWithChildren<\n Omit<StyleVariants, 'type'> &\n Required<Pick<StyleVariants, 'type'>> & {\n /** コンポーネント右の領域 */\n subActionArea?: ReactNode\n /** 閉じるボタン押下時に発火させる関数 */\n onClose?: () => void\n /** role 属性 */\n role?: 'alert' | 'status'\n }\n>\ntype ElementProps = Omit<ComponentPropsWithoutRef<'div'>, keyof Props>\ntype BaseProps = Pick<ComponentProps<typeof Base>, 'layer'>\ntype ActualProps = Props & ElementProps & BaseProps\n\nconst ABSTRACT_ICON_MAPPER = {\n info: FaCircleInfoIcon,\n success: FaCircleCheckIcon,\n error: FaCircleExclamationIcon,\n sync: FaRotateIcon,\n}\nconst ICON_MAPPER = {\n normal: {\n ...ABSTRACT_ICON_MAPPER,\n warning: WarningIcon,\n },\n bold: {\n ...ABSTRACT_ICON_MAPPER,\n warning: FaTriangleExclamationIcon,\n },\n} as const\n\nconst ROLE_STATUS_TYPE_REGEX = /^(info|sync)$/\n\nexport const NotificationBar: FC<ActualProps> = ({\n type,\n bold,\n animate,\n subActionArea,\n onClose,\n children,\n role,\n base,\n layer,\n className,\n ...props\n}) => {\n const actualRole = useMemo(() => {\n if (role) {\n return role\n }\n\n return ROLE_STATUS_TYPE_REGEX.test(type) ? 'status' : 'alert'\n }, [role, type])\n const { WrapBase, baseProps } = useMemo(\n () =>\n base === 'base'\n ? {\n WrapBase: Base,\n baseProps: {\n layer,\n overflow: 'hidden' as ComponentProps<typeof Base>['overflow'],\n },\n }\n : {\n WrapBase: Fragment,\n baseProps: {},\n },\n [base, layer],\n )\n const classNames = useMemo(() => {\n const { wrapper, inner, messageArea, icon, actionArea, closeButton } = classNameGenerator({\n type,\n bold: !!bold,\n base: base || 'none',\n })\n\n return {\n wrapper: wrapper({ animate, className }),\n inner: inner(),\n messageArea: messageArea(),\n icon: icon(),\n actionArea: actionArea(),\n closeButton: closeButton(),\n }\n }, [animate, base, bold, type, className])\n\n return (\n <WrapBase {...baseProps}>\n <div {...props} className={classNames.wrapper} role={actualRole}>\n <Cluster gap={1} align=\"center\" justify=\"flex-end\" className={classNames.inner}>\n <MessageArea bold={bold} type={type} classNames={classNames}>\n {children}\n </MessageArea>\n {subActionArea && (\n <Cluster align=\"center\" justify=\"flex-end\" className={classNames.actionArea}>\n {subActionArea}\n </Cluster>\n )}\n </Cluster>\n <CloseButton onClose={onClose} className={classNames.closeButton} />\n </div>\n </WrapBase>\n )\n}\n\nconst MessageArea = memo<\n Pick<ActualProps, 'children' | 'bold' | 'type'> & {\n classNames: { messageArea: string; icon: string }\n }\n>(({ children, bold, type, classNames }) => {\n const Icon = ICON_MAPPER[bold ? 'bold' : 'normal'][type]\n\n return (\n <Text\n prefixIcon={<Icon iconGap={0.5} className={classNames.icon} />}\n className={classNames.messageArea}\n as=\"div\"\n >\n {children}\n </Text>\n )\n})\n\nconst CloseButton = memo<Pick<ActualProps, 'onClose'> & { className: string }>(\n ({ onClose, className }) =>\n onClose && (\n <Button variant=\"text\" size=\"s\" onClick={onClose} className={className}>\n <FaXmarkIcon\n alt={\n <Localizer id=\"smarthr-ui/NotificationBar/closeButtonIconAlt\" defaultText=\"閉じる\" />\n }\n />\n </Button>\n ),\n)\n"]}
@@ -36,7 +36,8 @@ const suffixWrapperClassName = suffixWrapper();
36
36
  const ActualTextLink = (0, react_1.forwardRef)(({ elementAs, href, target, rel, onClick, children, prefix, suffix, className, size, ...others }, ref) => {
37
37
  const Anchor = elementAs || 'a';
38
38
  const actualSuffix = (0, react_1.useMemo)(() => {
39
- if (target === '_blank' && !prefix && !suffix) {
39
+ // target="_blank" だが OpenInNewTabIcon を表示したくない場合 suffix に null を指定すれば表示しないようにしている
40
+ if (target === '_blank' && !prefix && suffix === undefined) {
40
41
  return (0, jsx_runtime_1.jsx)(OpenInNewTabIcon_1.OpenInNewTabIcon, {});
41
42
  }
42
43
  return suffix;
@@ -1 +1 @@
1
- {"version":3,"file":"TextLink.js","sourceRoot":"","sources":["../../../src/components/TextLink/TextLink.tsx"],"names":[],"mappings":";;;;AAAA,iCAWc;AACd,yDAAyD;AAEzD,0DAAsD;AAwBtD,MAAM,kBAAkB,GAAG,IAAA,sBAAE,EAAC;IAC5B,KAAK,EAAE;QACL,MAAM,EAAE;YACN,qDAAqD;YACrD,6BAA6B;YAC7B,gFAAgF;YAChF,yCAAyC;SAC1C;QACD,aAAa,EAAE,8BAA8B;QAC7C,aAAa,EAAE,8BAA8B;KAC9C;IACD,QAAQ,EAAE;QACR,IAAI,EAAE;YACJ,EAAE,EAAE;gBACF,MAAM,EAAE,aAAa;aACtB;YACD,CAAC,EAAE;gBACD,MAAM,EAAE,aAAa;aACtB;YACD,CAAC,EAAE;gBACD,MAAM,EAAE,eAAe;aACxB;SACF;KACF;CACF,CAAC,CAAA;AACF,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,GAAG,kBAAkB,EAAE,CAAA;AACrE,MAAM,sBAAsB,GAAG,aAAa,EAAE,CAAA;AAC9C,MAAM,sBAAsB,GAAG,aAAa,EAAE,CAAA;AAE9C,MAAM,cAAc,GAAsB,IAAA,kBAAU,EAClD,CACE,EACE,SAAS,EACT,IAAI,EACJ,MAAM,EACN,GAAG,EACH,OAAO,EACP,QAAQ,EACR,MAAM,EACN,MAAM,EACN,SAAS,EACT,IAAI,EACJ,GAAG,MAAM,EACmC,EAC9C,GAAuB,EACvB,EAAE;IACF,MAAM,MAAM,GAAG,SAAS,IAAI,GAAG,CAAA;IAC/B,MAAM,YAAY,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE;QAChC,IAAI,MAAM,KAAK,QAAQ,IAAI,CAAC,MAAM,IAAI,CAAC,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E,GAAG,EACR,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,SAAS,EACd,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,eAAe,aAEzB,MAAM,IAAI,iCAAM,SAAS,EAAE,sBAAsB,YAAG,MAAM,GAAQ,EAClE,QAAQ,EACR,YAAY,IAAI,iCAAM,SAAS,EAAE,sBAAsB,YAAG,YAAY,GAAQ,IACxE,CACV,CAAA;AACH,CAAC,CACF,CAAA;AAEY,QAAA,QAAQ,GAAG,IAAA,YAAI,EAAC,cAAc,CAA0B,CAAA","sourcesContent":["import {\n type ComponentPropsWithoutRef,\n type ElementType,\n type FC,\n type MouseEvent,\n type PropsWithoutRef,\n type ReactNode,\n type Ref,\n forwardRef,\n memo,\n useMemo,\n} from 'react'\nimport { type VariantProps, tv } from 'tailwind-variants'\n\nimport { OpenInNewTabIcon } from '../OpenInNewTabIcon'\n\nimport type { ElementRef, ElementRefProps } from '../../types'\n\ntype ElementProps<T extends ElementType> = Omit<\n ComponentPropsWithoutRef<T>,\n (keyof Props<T> & ElementRefProps<T>) | 'color'\n>\n\ntype Props<T extends ElementType> = VariantProps<typeof classNameGenerator> & {\n /** リンクをクリックした時に発火するコールバック関数 */\n onClick?: (e: MouseEvent) => void\n /** テキストの前に表示するアイコン */\n prefix?: ReactNode\n /** テキストの後ろに表示するアイコン */\n suffix?: ReactNode\n /** TextLinkを利用しつつnext/linkなどと併用する場合に指定する */\n elementAs?: T\n}\n\ntype TextLinkComponent = <T extends ElementType = 'a'>(\n props: Props<T> & ElementProps<T> & ElementRefProps<T>,\n) => ReturnType<FC>\n\nconst classNameGenerator = tv({\n slots: {\n anchor: [\n 'shr-text-link shr-no-underline shr-shadow-underline',\n 'forced-colors:shr-underline',\n '[&:not([href])]:shr-shadow-none [&:not([href])]:forced-colors:shr-no-underline',\n '[.smarthr-ui-Th_&]:shr-text-link-darken',\n ],\n prefixWrapper: 'shr-me-0.25 shr-align-middle',\n suffixWrapper: 'shr-ms-0.25 shr-align-middle',\n },\n variants: {\n size: {\n XS: {\n anchor: 'shr-text-xs',\n },\n S: {\n anchor: 'shr-text-sm',\n },\n M: {\n anchor: 'shr-text-base',\n },\n },\n },\n})\nconst { anchor, prefixWrapper, suffixWrapper } = classNameGenerator()\nconst prefixWrapperClassName = prefixWrapper()\nconst suffixWrapperClassName = suffixWrapper()\n\nconst ActualTextLink: TextLinkComponent = forwardRef(\n <T extends ElementType = 'a'>(\n {\n elementAs,\n href,\n target,\n rel,\n onClick,\n children,\n prefix,\n suffix,\n className,\n size,\n ...others\n }: PropsWithoutRef<Props<T>> & ElementProps<T>,\n ref: Ref<ElementRef<T>>,\n ) => {\n const Anchor = elementAs || 'a'\n const actualSuffix = useMemo(() => {\n if (target === '_blank' && !prefix && !suffix) {\n return <OpenInNewTabIcon />\n }\n\n return suffix\n }, [prefix, suffix, target])\n const actualHref = useMemo(() => {\n if (href) {\n return href\n }\n\n if (onClick) {\n return ''\n }\n\n return undefined\n }, [href, onClick])\n const actualRel = useMemo(\n () => (rel === undefined && target === '_blank' ? 'noopener noreferrer' : rel),\n [rel, target],\n )\n const anchorClassName = useMemo(() => anchor({ size, className }), [size, className])\n\n const actualOnClick = useMemo(() => {\n if (!onClick) {\n return undefined\n }\n\n if (href) {\n return onClick\n }\n\n return (e: MouseEvent) => {\n e.preventDefault()\n onClick(e)\n }\n }, [onClick, href])\n\n return (\n <Anchor\n {...others}\n ref={ref}\n href={actualHref}\n target={target}\n rel={actualRel}\n onClick={actualOnClick}\n className={anchorClassName}\n >\n {prefix && <span className={prefixWrapperClassName}>{prefix}</span>}\n {children}\n {actualSuffix && <span className={suffixWrapperClassName}>{actualSuffix}</span>}\n </Anchor>\n )\n },\n)\n\nexport const TextLink = memo(ActualTextLink) as typeof ActualTextLink\n"]}
1
+ {"version":3,"file":"TextLink.js","sourceRoot":"","sources":["../../../src/components/TextLink/TextLink.tsx"],"names":[],"mappings":";;;;AAAA,iCAWc;AACd,yDAAy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AAE,sBAAsB,YAAG,YAAY,GAAQ,IACxE,CACV,CAAA;AACH,CAAC,CACF,CAAA;AAEY,QAAA,QAAQ,GAAG,IAAA,YAAI,EAAC,cAAc,CAA0B,CAAA","sourcesContent":["import {\n type ComponentPropsWithoutRef,\n type ElementType,\n type FC,\n type MouseEvent,\n type PropsWithoutRef,\n type ReactNode,\n type Ref,\n forwardRef,\n memo,\n useMemo,\n} from 'react'\nimport { type VariantProps, tv } from 'tailwind-variants'\n\nimport { OpenInNewTabIcon } from '../OpenInNewTabIcon'\n\nimport type { ElementRef, ElementRefProps } from '../../types'\n\ntype ElementProps<T extends ElementType> = Omit<\n ComponentPropsWithoutRef<T>,\n (keyof Props<T> & ElementRefProps<T>) | 'color'\n>\n\ntype Props<T extends ElementType> = VariantProps<typeof classNameGenerator> & {\n /** リンクをクリックした時に発火するコールバック関数 */\n onClick?: (e: MouseEvent) => void\n /** テキストの前に表示するアイコン */\n prefix?: ReactNode\n /** テキストの後ろに表示するアイコン */\n suffix?: ReactNode\n /** TextLinkを利用しつつnext/linkなどと併用する場合に指定する */\n elementAs?: T\n}\n\ntype TextLinkComponent = <T extends ElementType = 'a'>(\n props: Props<T> & ElementProps<T> & ElementRefProps<T>,\n) => ReturnType<FC>\n\nconst classNameGenerator = tv({\n slots: {\n anchor: [\n 'shr-text-link shr-no-underline shr-shadow-underline',\n 'forced-colors:shr-underline',\n '[&:not([href])]:shr-shadow-none [&:not([href])]:forced-colors:shr-no-underline',\n '[.smarthr-ui-Th_&]:shr-text-link-darken',\n ],\n prefixWrapper: 'shr-me-0.25 shr-align-middle',\n suffixWrapper: 'shr-ms-0.25 shr-align-middle',\n },\n variants: {\n size: {\n XS: {\n anchor: 'shr-text-xs',\n },\n S: {\n anchor: 'shr-text-sm',\n },\n M: {\n anchor: 'shr-text-base',\n },\n },\n },\n})\nconst { anchor, prefixWrapper, suffixWrapper } = classNameGenerator()\nconst prefixWrapperClassName = prefixWrapper()\nconst suffixWrapperClassName = suffixWrapper()\n\nconst ActualTextLink: TextLinkComponent = forwardRef(\n <T extends ElementType = 'a'>(\n {\n elementAs,\n href,\n target,\n rel,\n onClick,\n children,\n prefix,\n suffix,\n className,\n size,\n ...others\n }: PropsWithoutRef<Props<T>> & ElementProps<T>,\n ref: Ref<ElementRef<T>>,\n ) => {\n const Anchor = elementAs || 'a'\n const actualSuffix = useMemo(() => {\n // target=\"_blank\" だが OpenInNewTabIcon を表示したくない場合 suffix に null を指定すれば表示しないようにしている\n if (target === '_blank' && !prefix && suffix === undefined) {\n return <OpenInNewTabIcon />\n }\n\n return suffix\n }, [prefix, suffix, target])\n const actualHref = useMemo(() => {\n if (href) {\n return href\n }\n\n if (onClick) {\n return ''\n }\n\n return undefined\n }, [href, onClick])\n const actualRel = useMemo(\n () => (rel === undefined && target === '_blank' ? 'noopener noreferrer' : rel),\n [rel, target],\n )\n const anchorClassName = useMemo(() => anchor({ size, className }), [size, className])\n\n const actualOnClick = useMemo(() => {\n if (!onClick) {\n return undefined\n }\n\n if (href) {\n return onClick\n }\n\n return (e: MouseEvent) => {\n e.preventDefault()\n onClick(e)\n }\n }, [onClick, href])\n\n return (\n <Anchor\n {...others}\n ref={ref}\n href={actualHref}\n target={target}\n rel={actualRel}\n onClick={actualOnClick}\n className={anchorClassName}\n >\n {prefix && <span className={prefixWrapperClassName}>{prefix}</span>}\n {children}\n {actualSuffix && <span className={suffixWrapperClassName}>{actualSuffix}</span>}\n </Anchor>\n )\n },\n)\n\nexport const TextLink = memo(ActualTextLink) as typeof ActualTextLink\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "smarthr-ui",
3
3
  "description": "SmartHR ui components built with React.",
4
- "version": "79.0.0",
4
+ "version": "79.1.0",
5
5
  "author": "SmartHR-UI Team",
6
6
  "dependencies": {
7
7
  "@smarthr/wareki": "^1.3.0",