smarthr-ui 96.1.0 → 96.1.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/lib/components/AppHeader/components/common/CommonButton.cjs +3 -2
- package/lib/components/AppHeader/components/common/CommonButton.cjs.map +1 -1
- package/lib/components/AppHeader/components/common/CommonButton.js +3 -2
- package/lib/components/AppHeader/components/common/CommonButton.js.map +1 -1
- package/lib/components/Base/Base.cjs +7 -1
- package/lib/components/Base/Base.cjs.map +1 -1
- package/lib/components/Base/Base.js +7 -1
- package/lib/components/Base/Base.js.map +1 -1
- package/lib/components/Base/BaseColumn/BaseColumn.cjs +7 -1
- package/lib/components/Base/BaseColumn/BaseColumn.cjs.map +1 -1
- package/lib/components/Base/BaseColumn/BaseColumn.js +7 -1
- package/lib/components/Base/BaseColumn/BaseColumn.js.map +1 -1
- package/lib/components/BottomFixedArea/BottomFixedArea.cjs +1 -3
- package/lib/components/BottomFixedArea/BottomFixedArea.cjs.map +1 -1
- package/lib/components/BottomFixedArea/BottomFixedArea.js +2 -4
- package/lib/components/BottomFixedArea/BottomFixedArea.js.map +1 -1
- package/lib/components/Button/AnchorButton.cjs +2 -7
- package/lib/components/Button/AnchorButton.cjs.map +1 -1
- package/lib/components/Button/AnchorButton.js +2 -7
- package/lib/components/Button/AnchorButton.js.map +1 -1
- package/lib/components/Button/useButtonWrapper.cjs +24 -6
- package/lib/components/Button/useButtonWrapper.cjs.map +1 -1
- package/lib/components/Button/useButtonWrapper.js +24 -6
- package/lib/components/Button/useButtonWrapper.js.map +1 -1
- package/lib/components/Combobox/MultiCombobox/MultiSelectedItem.cjs +8 -4
- package/lib/components/Combobox/MultiCombobox/MultiSelectedItem.cjs.map +1 -1
- package/lib/components/Combobox/MultiCombobox/MultiSelectedItem.js +8 -4
- package/lib/components/Combobox/MultiCombobox/MultiSelectedItem.js.map +1 -1
- package/lib/components/Dialog/DialogBody.cjs +7 -1
- package/lib/components/Dialog/DialogBody.cjs.map +1 -1
- package/lib/components/Dialog/DialogBody.js +7 -1
- package/lib/components/Dialog/DialogBody.js.map +1 -1
- package/lib/components/Dialog/DialogContentInner.cjs +7 -1
- package/lib/components/Dialog/DialogContentInner.cjs.map +1 -1
- package/lib/components/Dialog/DialogContentInner.js +7 -1
- package/lib/components/Dialog/DialogContentInner.js.map +1 -1
- package/lib/components/Dialog/DialogOverlap.cjs +22 -5
- package/lib/components/Dialog/DialogOverlap.cjs.map +1 -1
- package/lib/components/Dialog/DialogOverlap.js +23 -6
- package/lib/components/Dialog/DialogOverlap.js.map +1 -1
- package/lib/components/Dialog/ModelessDialog/ModelessDialog.cjs +7 -1
- package/lib/components/Dialog/ModelessDialog/ModelessDialog.cjs.map +1 -1
- package/lib/components/Dialog/ModelessDialog/ModelessDialog.js +7 -1
- package/lib/components/Dialog/ModelessDialog/ModelessDialog.js.map +1 -1
- package/lib/components/Dialog/RemoteDialogTrigger/RemoteDialogTrigger.cjs +51 -11
- package/lib/components/Dialog/RemoteDialogTrigger/RemoteDialogTrigger.cjs.map +1 -1
- package/lib/components/Dialog/RemoteDialogTrigger/RemoteDialogTrigger.d.ts +3 -4
- package/lib/components/Dialog/RemoteDialogTrigger/RemoteDialogTrigger.js +52 -12
- package/lib/components/Dialog/RemoteDialogTrigger/RemoteDialogTrigger.js.map +1 -1
- package/lib/components/Dropdown/Dropdown.cjs +3 -3
- package/lib/components/Dropdown/Dropdown.cjs.map +1 -1
- package/lib/components/Dropdown/Dropdown.d.ts +1 -1
- package/lib/components/Dropdown/Dropdown.js +3 -3
- package/lib/components/Dropdown/Dropdown.js.map +1 -1
- package/lib/components/Dropdown/DropdownMenuButton/DropdownMenuButton.cjs +20 -10
- package/lib/components/Dropdown/DropdownMenuButton/DropdownMenuButton.cjs.map +1 -1
- package/lib/components/Dropdown/DropdownMenuButton/DropdownMenuButton.js +21 -11
- package/lib/components/Dropdown/DropdownMenuButton/DropdownMenuButton.js.map +1 -1
- package/lib/components/Dropdown/DropdownTrigger.cjs +33 -16
- package/lib/components/Dropdown/DropdownTrigger.cjs.map +1 -1
- package/lib/components/Dropdown/DropdownTrigger.js +33 -16
- package/lib/components/Dropdown/DropdownTrigger.js.map +1 -1
- package/lib/components/Header/Header.cjs +3 -3
- package/lib/components/Header/Header.cjs.map +1 -1
- package/lib/components/Header/Header.js +3 -3
- package/lib/components/Header/Header.js.map +1 -1
- package/lib/components/Icon/generateIcon.cjs +9 -1
- package/lib/components/Icon/generateIcon.cjs.map +1 -1
- package/lib/components/Icon/generateIcon.js +9 -1
- package/lib/components/Icon/generateIcon.js.map +1 -1
- package/lib/components/Layout/Cluster/Cluster.cjs +4 -0
- package/lib/components/Layout/Cluster/Cluster.cjs.map +1 -1
- package/lib/components/Layout/Cluster/Cluster.d.ts +1 -1
- package/lib/components/Layout/Cluster/Cluster.js +4 -0
- package/lib/components/Layout/Cluster/Cluster.js.map +1 -1
- package/lib/components/Layout/Container/Container.cjs +2 -2
- package/lib/components/Layout/Container/Container.js +2 -2
- package/lib/components/Scroller/Scroller.cjs +12 -19
- package/lib/components/Scroller/Scroller.cjs.map +1 -1
- package/lib/components/Scroller/Scroller.js +13 -20
- package/lib/components/Scroller/Scroller.js.map +1 -1
- package/lib/components/Table/TableReel.cjs +1 -1
- package/lib/components/Table/TableReel.cjs.map +1 -1
- package/lib/components/Table/TableReel.js +1 -1
- package/lib/components/Table/TableReel.js.map +1 -1
- package/lib/components/Table/TableScrollContext.cjs +4 -4
- package/lib/components/Table/TableScrollContext.js +4 -4
- package/lib/components/Table/useReelCells.cjs +13 -7
- package/lib/components/Table/useReelCells.cjs.map +1 -1
- package/lib/components/Table/useReelCells.d.ts +1 -3
- package/lib/components/Table/useReelCells.js +13 -7
- package/lib/components/Table/useReelCells.js.map +1 -1
- package/lib/components/Text/Text.cjs +3 -1
- package/lib/components/Text/Text.cjs.map +1 -1
- package/lib/components/Text/Text.js +3 -1
- package/lib/components/Text/Text.js.map +1 -1
- package/lib/components/TextLink/TextLink.cjs +14 -28
- package/lib/components/TextLink/TextLink.cjs.map +1 -1
- package/lib/components/TextLink/TextLink.js +15 -29
- package/lib/components/TextLink/TextLink.js.map +1 -1
- package/lib/components/TextLink/UpwardLink/UpwardLink.cjs +2 -2
- package/lib/components/TextLink/UpwardLink/UpwardLink.js +2 -2
- package/lib/components/Textarea/Textarea.cjs +7 -6
- package/lib/components/Textarea/Textarea.cjs.map +1 -1
- package/lib/components/Textarea/Textarea.js +7 -6
- package/lib/components/Textarea/Textarea.js.map +1 -1
- package/lib/components/Tooltip/Tooltip.cjs +12 -21
- package/lib/components/Tooltip/Tooltip.cjs.map +1 -1
- package/lib/components/Tooltip/Tooltip.js +14 -23
- package/lib/components/Tooltip/Tooltip.js.map +1 -1
- package/lib/components/Tooltip/TooltipPortal.cjs +2 -2
- package/lib/components/Tooltip/TooltipPortal.cjs.map +1 -1
- package/lib/components/Tooltip/TooltipPortal.d.ts +1 -0
- package/lib/components/Tooltip/TooltipPortal.js +2 -2
- package/lib/components/Tooltip/TooltipPortal.js.map +1 -1
- package/lib/components/Tooltip/tooltipHelper.cjs +2 -2
- package/lib/components/Tooltip/tooltipHelper.cjs.map +1 -1
- package/lib/components/Tooltip/tooltipHelper.js +2 -2
- package/lib/components/Tooltip/tooltipHelper.js.map +1 -1
- package/lib/components/WarekiPicker/WarekiPicker.cjs +2 -3
- package/lib/components/WarekiPicker/WarekiPicker.cjs.map +1 -1
- package/lib/components/WarekiPicker/WarekiPicker.js +2 -3
- package/lib/components/WarekiPicker/WarekiPicker.js.map +1 -1
- package/lib/configureTwMerge.cjs +2 -2
- package/lib/configureTwMerge.js +2 -2
- package/lib/hooks/useDevice/DeviceProvider.cjs +2 -2
- package/lib/hooks/useDevice/DeviceProvider.js +2 -2
- package/lib/hooks/useEnvironment/EnvironmentProvider.cjs +2 -2
- package/lib/hooks/useEnvironment/EnvironmentProvider.js +2 -2
- package/lib/hooks/useOuterClick.cjs +5 -2
- package/lib/hooks/useOuterClick.cjs.map +1 -1
- package/lib/hooks/useOuterClick.js +6 -3
- package/lib/hooks/useOuterClick.js.map +1 -1
- package/lib/hooks/usePortal.cjs +1 -1
- package/lib/hooks/usePortal.cjs.map +1 -1
- package/lib/hooks/usePortal.js +1 -1
- package/lib/hooks/usePortal.js.map +1 -1
- package/lib/hooks/useSV/useSV.cjs +2 -2
- package/lib/hooks/useSV/useSV.js +2 -2
- package/lib/hooks/useTheme.cjs +3 -0
- package/lib/hooks/useTheme.cjs.map +1 -1
- package/lib/hooks/useTheme.js +3 -0
- package/lib/hooks/useTheme.js.map +1 -1
- package/lib/index.cjs +14 -8
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.ts +1 -10
- package/lib/index.js +10 -4
- package/lib/index.js.map +1 -1
- package/lib/intl/locales/index.cjs +1 -0
- package/lib/intl/locales/index.cjs.map +1 -1
- package/lib/intl/locales/index.js +1 -0
- package/lib/intl/locales/index.js.map +1 -1
- package/lib/libs/ua.cjs +1 -2
- package/lib/libs/ua.cjs.map +1 -1
- package/lib/libs/ua.js +1 -2
- package/lib/libs/ua.js.map +1 -1
- package/lib/smarthr-ui-preset.cjs +4 -4
- package/lib/smarthr-ui-preset.js +4 -4
- package/lib/tailwind/color.cjs +9 -0
- package/lib/tailwind/color.cjs.map +1 -1
- package/lib/tailwind/color.d.ts +1 -1
- package/lib/tailwind/color.js +9 -0
- package/lib/tailwind/color.js.map +1 -1
- package/lib/tailwind/fontSize.cjs +10 -0
- package/lib/tailwind/fontSize.cjs.map +1 -1
- package/lib/tailwind/fontSize.d.ts +1 -1
- package/lib/tailwind/fontSize.js +10 -0
- package/lib/tailwind/fontSize.js.map +1 -1
- package/lib/tailwind/index.cjs +10 -2
- package/lib/tailwind/index.cjs.map +1 -1
- package/lib/tailwind/index.js +9 -1
- package/lib/tailwind/index.js.map +1 -1
- package/lib/tailwind/textColor.cjs +9 -0
- package/lib/tailwind/textColor.cjs.map +1 -1
- package/lib/tailwind/textColor.d.ts +1 -1
- package/lib/tailwind/textColor.js +9 -0
- package/lib/tailwind/textColor.js.map +1 -1
- package/lib/themes/createWidth.cjs +1 -3
- package/lib/themes/createWidth.cjs.map +1 -1
- package/lib/themes/createWidth.d.ts +3 -1
- package/lib/themes/createWidth.js +1 -3
- package/lib/themes/createWidth.js.map +1 -1
- package/lib/themes/index.cjs +14 -0
- package/lib/themes/index.cjs.map +1 -1
- package/lib/themes/index.d.ts +7 -1
- package/lib/themes/index.js +9 -1
- package/lib/themes/index.js.map +1 -1
- package/metadata.json +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropdownMenuButton.cjs","sources":["../../../../src/components/Dropdown/DropdownMenuButton/DropdownMenuButton.tsx"],"sourcesContent":["'use client'\n\nimport {\n Children,\n type ComponentProps,\n type ComponentPropsWithRef,\n type ComponentType,\n type FC,\n Fragment,\n type ReactElement,\n type ReactNode,\n isValidElement,\n memo,\n useContext,\n useEffect,\n useMemo,\n useRef,\n} from 'react'\nimport innerText from 'react-innertext'\nimport { tv } from 'tailwind-variants'\n\nimport { useObjectAttributes } from '../../../hooks/useObjectAttributes'\nimport { useIntl } from '../../../intl'\nimport { type AnchorButton, Button, type AbstractProps as ButtonProps } from '../../Button'\nimport { FaCaretDownIcon, FaEllipsisIcon } from '../../Icon'\nimport { Dropdown, DropdownContext } from '../Dropdown'\nimport { DropdownCloser } from '../DropdownCloser'\nimport { DropdownContent } from '../DropdownContent'\nimport { DropdownTrigger } from '../DropdownTrigger'\n\nimport { DropdownMenuGroup } from './DropdownMenuGroup'\nimport useKeyboardNavigation from './useKeyboardNavigation'\n\nimport type { RemoteDialogTrigger } from '../../Dialog'\n\ntype Actions = ActionItem | ActionItem[]\n\n// これでコンポーネントを絞れるわけではないが Button[variant=text] を使ってほしいんだよ! という気持ち\ntype ActionItem =\n | ReactElement<ComponentProps<typeof Button>>\n | ReactElement<ComponentProps<typeof AnchorButton>>\n | ReactElement<ComponentProps<typeof RemoteDialogTrigger>>\n | ReactNode\n\ntype ObjectTriggerType = {\n /** 引き金となるボタンラベル */\n children: ReactNode\n /** 引き金となるボタンの大きさ */\n size?: ButtonProps['size']\n /** 引き金となるボタンをアイコンのみとするかどうか */\n onlyIcon?:\n | boolean\n | {\n /** 引き金となるアイコンを差し替えたい場合(onlyIcon=true の場合のみ有効) */\n component?: ComponentType<ComponentProps<typeof FaCaretDownIcon>>\n }\n}\ntype AbstractProps = {\n /** 引き金となるボタン */\n trigger: ReactNode | ObjectTriggerType\n /** 操作群 */\n children: Actions\n /** ドロップダウンメニューが開かれた際のイベント */\n onOpen?: () => void\n /** ドロップダウンメニューが閉じられた際のイベント */\n onClose?: () => void\n}\ntype ElementProps = Omit<ComponentPropsWithRef<'button'>, keyof AbstractProps>\ntype Props = AbstractProps & ElementProps\n\nconst triggerObjectConverter = (trigger: ReactNode) => ({\n children: trigger,\n})\n\nconst classNameGenerator = tv({\n slots: {\n triggerWrapper: 'smarthr-ui-DropdownMenuButton',\n triggerButton:\n 'smarthr-ui-DropdownMenuButton-trigger [&[aria-expanded=\"true\"]_.smarthr-ui-Icon:last-child]:shr-rotate-180',\n actionList: [\n 'smarthr-ui-DropdownMenuButton-panel',\n 'shr-list-none shr-py-0.5',\n [\n /* unset した Button の右 padding 分 */\n '[&_.smarthr-ui-Button-disabledWrapper]:shr-pe-1',\n '[&_.smarthr-ui-Button-disabledWrapper]:shr-gap-x-0.5',\n '[&_.smarthr-ui-Button-disabledWrapper_>_.smarthr-ui-Button]:shr-w-[unset] [&_.smarthr-ui-Button-disabledWrapper_>_.smarthr-ui-Button]:shr-bg-transparent [&_.smarthr-ui-Button-disabledWrapper_>_.smarthr-ui-Button]:shr-pe-[unset]',\n ],\n ],\n actionListItemButton: [\n // HINT: 実際にレンダリングされた要素のclassに対して追加されるため、優先度を上げる必要がある\n '[&&]:shr-w-full [&&]:shr-justify-start [&&]:shr-rounded-none [&&]:shr-border-none [&&]:shr-py-0.5 [&&]:shr-font-normal',\n '[&&]:focus-visible:shr-focus-indicator',\n ],\n },\n})\n\nconst { triggerWrapper, triggerButton, actionList, actionListItemButton } = classNameGenerator()\n\nexport const DropdownMenuButton: FC<Props> = ({\n trigger,\n children,\n onOpen,\n onClose,\n className,\n ...rest\n}) => {\n const {\n children: triggerChildren,\n size: triggerSize,\n onlyIcon: onlyIconTrigger,\n } = useObjectAttributes<ReactNode | ObjectTriggerType, ObjectTriggerType>(\n trigger,\n triggerObjectConverter,\n )\n\n const containerRef = useRef<HTMLUListElement>(null)\n\n useKeyboardNavigation(containerRef)\n\n const classNames = useMemo(\n () => ({\n triggerWrapper: triggerWrapper({ className }),\n triggerButton: triggerButton(),\n actionList: actionList(),\n }),\n [className],\n )\n\n return (\n <Dropdown onOpen={onOpen} onClose={onClose}>\n <MemoizedTriggerButton\n {...rest}\n onlyIconTrigger={onlyIconTrigger}\n triggerSize={triggerSize}\n classNames={classNames}\n >\n {triggerChildren}\n </MemoizedTriggerButton>\n <DropdownContent controllable={true}>\n <menu ref={containerRef} role=\"menu\" className={classNames.actionList}>\n {renderButtonList(children)}\n </menu>\n </DropdownContent>\n </Dropdown>\n )\n}\n\nconst MemoizedTriggerButton = memo<\n ElementProps & {\n onlyIconTrigger: ObjectTriggerType['onlyIcon']\n triggerSize: ObjectTriggerType['size']\n children: ObjectTriggerType['children']\n classNames: {\n triggerWrapper: string\n triggerButton: string\n }\n }\n>(({ onlyIconTrigger, triggerSize, children, classNames, ...rest }) => {\n const { localize } = useIntl()\n\n const { active } = useContext(DropdownContext)\n\n
|
|
1
|
+
{"version":3,"file":"DropdownMenuButton.cjs","sources":["../../../../src/components/Dropdown/DropdownMenuButton/DropdownMenuButton.tsx"],"sourcesContent":["'use client'\n\nimport {\n Children,\n type ComponentProps,\n type ComponentPropsWithRef,\n type ComponentType,\n type FC,\n Fragment,\n type ReactElement,\n type ReactNode,\n isValidElement,\n memo,\n useContext,\n useEffect,\n useMemo,\n useRef,\n} from 'react'\nimport innerText from 'react-innertext'\nimport { tv } from 'tailwind-variants'\n\nimport { useObjectAttributes } from '../../../hooks/useObjectAttributes'\nimport { useIntl } from '../../../intl'\nimport { type AnchorButton, Button, type AbstractProps as ButtonProps } from '../../Button'\nimport { FaCaretDownIcon, FaEllipsisIcon } from '../../Icon'\nimport { Dropdown, DropdownContext } from '../Dropdown'\nimport { DropdownCloser } from '../DropdownCloser'\nimport { DropdownContent } from '../DropdownContent'\nimport { DropdownTrigger } from '../DropdownTrigger'\n\nimport { DropdownMenuGroup } from './DropdownMenuGroup'\nimport useKeyboardNavigation from './useKeyboardNavigation'\n\nimport type { RemoteDialogTrigger } from '../../Dialog'\n\ntype Actions = ActionItem | ActionItem[]\n\n// これでコンポーネントを絞れるわけではないが Button[variant=text] を使ってほしいんだよ! という気持ち\ntype ActionItem =\n | ReactElement<ComponentProps<typeof Button>>\n | ReactElement<ComponentProps<typeof AnchorButton>>\n | ReactElement<ComponentProps<typeof RemoteDialogTrigger>>\n | ReactNode\n\ntype ObjectTriggerType = {\n /** 引き金となるボタンラベル */\n children: ReactNode\n /** 引き金となるボタンの大きさ */\n size?: ButtonProps['size']\n /** 引き金となるボタンをアイコンのみとするかどうか */\n onlyIcon?:\n | boolean\n | {\n /** 引き金となるアイコンを差し替えたい場合(onlyIcon=true の場合のみ有効) */\n component?: ComponentType<ComponentProps<typeof FaCaretDownIcon>>\n }\n}\ntype AbstractProps = {\n /** 引き金となるボタン */\n trigger: ReactNode | ObjectTriggerType\n /** 操作群 */\n children: Actions\n /** ドロップダウンメニューが開かれた際のイベント */\n onOpen?: () => void\n /** ドロップダウンメニューが閉じられた際のイベント */\n onClose?: () => void\n}\ntype ElementProps = Omit<ComponentPropsWithRef<'button'>, keyof AbstractProps>\ntype Props = AbstractProps & ElementProps\n\nconst triggerObjectConverter = (trigger: ReactNode) => ({\n children: trigger,\n})\n\nconst classNameGenerator = tv({\n slots: {\n triggerWrapper: 'smarthr-ui-DropdownMenuButton',\n triggerButton:\n 'smarthr-ui-DropdownMenuButton-trigger [&[aria-expanded=\"true\"]_.smarthr-ui-Icon:last-child]:shr-rotate-180',\n actionList: [\n 'smarthr-ui-DropdownMenuButton-panel',\n 'shr-list-none shr-py-0.5',\n [\n /* unset した Button の右 padding 分 */\n '[&_.smarthr-ui-Button-disabledWrapper]:shr-pe-1',\n '[&_.smarthr-ui-Button-disabledWrapper]:shr-gap-x-0.5',\n '[&_.smarthr-ui-Button-disabledWrapper_>_.smarthr-ui-Button]:shr-w-[unset] [&_.smarthr-ui-Button-disabledWrapper_>_.smarthr-ui-Button]:shr-bg-transparent [&_.smarthr-ui-Button-disabledWrapper_>_.smarthr-ui-Button]:shr-pe-[unset]',\n ],\n ],\n actionListItemButton: [\n // HINT: 実際にレンダリングされた要素のclassに対して追加されるため、優先度を上げる必要がある\n '[&&]:shr-w-full [&&]:shr-justify-start [&&]:shr-rounded-none [&&]:shr-border-none [&&]:shr-py-0.5 [&&]:shr-font-normal',\n '[&&]:focus-visible:shr-focus-indicator',\n ],\n },\n})\n\nconst { triggerWrapper, triggerButton, actionList, actionListItemButton } = classNameGenerator()\n\nexport const DropdownMenuButton: FC<Props> = ({\n trigger,\n children,\n onOpen,\n onClose,\n className,\n ...rest\n}) => {\n const {\n children: triggerChildren,\n size: triggerSize,\n onlyIcon: onlyIconTrigger,\n } = useObjectAttributes<ReactNode | ObjectTriggerType, ObjectTriggerType>(\n trigger,\n triggerObjectConverter,\n )\n\n const containerRef = useRef<HTMLUListElement>(null)\n\n useKeyboardNavigation(containerRef)\n\n const classNames = useMemo(\n () => ({\n triggerWrapper: triggerWrapper({ className }),\n triggerButton: triggerButton(),\n actionList: actionList(),\n }),\n [className],\n )\n\n return (\n <Dropdown onOpen={onOpen} onClose={onClose}>\n <MemoizedTriggerButton\n {...rest}\n onlyIconTrigger={onlyIconTrigger}\n triggerSize={triggerSize}\n classNames={classNames}\n >\n {triggerChildren}\n </MemoizedTriggerButton>\n <DropdownContent controllable={true}>\n <menu ref={containerRef} role=\"menu\" className={classNames.actionList}>\n {renderButtonList(children)}\n </menu>\n </DropdownContent>\n </Dropdown>\n )\n}\n\nconst MemoizedTriggerButton = memo<\n ElementProps & {\n onlyIconTrigger: ObjectTriggerType['onlyIcon']\n triggerSize: ObjectTriggerType['size']\n children: ObjectTriggerType['children']\n classNames: {\n triggerWrapper: string\n triggerButton: string\n }\n }\n>(({ onlyIconTrigger, triggerSize, children, classNames, ...rest }) => {\n const { localize } = useIntl()\n\n const { active } = useContext(DropdownContext)\n\n return (\n <DropdownTrigger\n className={classNames.triggerWrapper}\n tooltip={{ show: !!onlyIconTrigger, message: children }}\n >\n <Button\n {...rest}\n suffix={\n !onlyIconTrigger && (\n <FaCaretDownIcon\n alt={\n active\n ? localize({\n id: 'smarthr-ui/DropdownMenuButton/triggerActive',\n defaultText: '候補を閉じる',\n })\n : localize({\n id: 'smarthr-ui/DropdownMenuButton/triggerInactive',\n defaultText: '候補を開く',\n })\n }\n />\n )\n }\n size={triggerSize}\n className={classNames.triggerButton}\n >\n <TriggerLabelText onlyIconTrigger={onlyIconTrigger}>{children}</TriggerLabelText>\n </Button>\n </DropdownTrigger>\n )\n})\n\nconst TriggerLabelText = memo<{\n onlyIconTrigger: ObjectTriggerType['onlyIcon']\n children: ObjectTriggerType['children']\n}>(({ children, onlyIconTrigger }) => {\n if (!onlyIconTrigger) {\n return children\n }\n\n const Icon = (typeof onlyIconTrigger === 'object' && onlyIconTrigger.component) || FaEllipsisIcon\n\n return <Icon alt={typeof children === 'string' ? children : innerText(children)} />\n})\n\nexport const renderButtonList = (children: Actions) =>\n Children.map(children, (item): ReactNode => {\n if (!item || !isValidElement(item)) {\n return null\n }\n\n switch (item.type) {\n case Fragment:\n return renderButtonList(item.props.children)\n case DropdownMenuGroup:\n return item\n }\n\n return <ButtonListItem>{item}</ButtonListItem>\n })\n\nconst ButtonListItem: FC<{ children: ReactElement }> = ({ children }) => {\n const ref = useRef<HTMLLIElement>(null)\n\n useEffect(() => {\n const listItem = ref.current\n if (!listItem) {\n return\n }\n\n const setupButton = () => {\n const button = listItem.querySelector('button,a')\n\n if (button) {\n button.setAttribute('role', 'menuitem')\n button.setAttribute(\n 'class',\n actionListItemButton({ className: button.getAttribute('class') }),\n )\n }\n }\n\n setupButton()\n\n const observer = new MutationObserver(setupButton)\n observer.observe(listItem, {\n childList: true,\n subtree: true,\n })\n\n return () => {\n observer.disconnect()\n }\n }, [])\n\n return (\n <li role=\"presentation\" ref={ref}>\n <DropdownCloser>{children}</DropdownCloser>\n </li>\n )\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAsEA;AACE;AACD;AAED;AACE;AACE;AACA;AAEA;;;AAGE;;;;;AAKC;AACF;AACD;;;;AAIC;AACF;AACF;AAED;;;AAmBE;;AAIA;AAEI;;;AAGD;AAIH;AAiBF;AAEA;AAWE;;AAIA;;AAaoB;AACA;;;AAGA;AACA;;AAatB;AAEA;;AAKI;;AAGF;;AAGF;AAEO;;AAGD;;AAGF;AACE;;AAEA;AACE;;AAGJ;AACF;AAEF;AACE;;AAGE;;;;;;;AASI;AACA;;AAKJ;AAEA;AAEA;AACA;AACE;AACA;AACD;AAED;;AAEA;;AAGF;AAKF;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
-
import { memo, useContext,
|
|
3
|
+
import { memo, useContext, useRef, useMemo, Children, isValidElement, Fragment, useEffect } from 'react';
|
|
4
4
|
import innerText from '../../../_virtual/index3.js';
|
|
5
5
|
import { tv as ce } from './../../../vendor/.pnpm/tailwind-variants@0.3.1_tailwindcss@3.4.19_ts-node@10.9.2_@swc_core@1.15.17_@types_node@20.19.35_typescript@5.9.3__/vendor/tailwind-variants/dist/index.js';
|
|
6
6
|
import { useObjectAttributes } from '../../../hooks/useObjectAttributes.js';
|
|
@@ -61,9 +61,7 @@ const DropdownMenuButton = ({ trigger, children, onOpen, onClose, className, ...
|
|
|
61
61
|
const MemoizedTriggerButton = memo(({ onlyIconTrigger, triggerSize, children, classNames, ...rest }) => {
|
|
62
62
|
const { localize } = useIntl();
|
|
63
63
|
const { active } = useContext(DropdownContext);
|
|
64
|
-
|
|
65
|
-
const tooltip = useMemo(() => ({ show: showTooltip, message: children }), [children, showTooltip]);
|
|
66
|
-
return (jsx(DropdownTrigger, { className: classNames.triggerWrapper, tooltip: tooltip, children: jsx(Button, { ...rest, suffix: !onlyIconTrigger && (jsx(FaCaretDownIcon, { alt: active
|
|
64
|
+
return (jsx(DropdownTrigger, { className: classNames.triggerWrapper, tooltip: { show: !!onlyIconTrigger, message: children }, children: jsx(Button, { ...rest, suffix: !onlyIconTrigger && (jsx(FaCaretDownIcon, { alt: active
|
|
67
65
|
? localize({
|
|
68
66
|
id: 'smarthr-ui/DropdownMenuButton/triggerActive',
|
|
69
67
|
defaultText: '候補を閉じる',
|
|
@@ -95,15 +93,27 @@ const renderButtonList = (children) => Children.map(children, (item) => {
|
|
|
95
93
|
const ButtonListItem = ({ children }) => {
|
|
96
94
|
const ref = useRef(null);
|
|
97
95
|
useEffect(() => {
|
|
98
|
-
|
|
96
|
+
const listItem = ref.current;
|
|
97
|
+
if (!listItem) {
|
|
99
98
|
return;
|
|
100
99
|
}
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
button
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
100
|
+
const setupButton = () => {
|
|
101
|
+
const button = listItem.querySelector('button,a');
|
|
102
|
+
if (button) {
|
|
103
|
+
button.setAttribute('role', 'menuitem');
|
|
104
|
+
button.setAttribute('class', actionListItemButton({ className: button.getAttribute('class') }));
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
setupButton();
|
|
108
|
+
const observer = new MutationObserver(setupButton);
|
|
109
|
+
observer.observe(listItem, {
|
|
110
|
+
childList: true,
|
|
111
|
+
subtree: true,
|
|
112
|
+
});
|
|
113
|
+
return () => {
|
|
114
|
+
observer.disconnect();
|
|
115
|
+
};
|
|
116
|
+
}, []);
|
|
107
117
|
return (jsx("li", { role: "presentation", ref: ref, children: jsx(DropdownCloser, { children: children }) }));
|
|
108
118
|
};
|
|
109
119
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropdownMenuButton.js","sources":["../../../../src/components/Dropdown/DropdownMenuButton/DropdownMenuButton.tsx"],"sourcesContent":["'use client'\n\nimport {\n Children,\n type ComponentProps,\n type ComponentPropsWithRef,\n type ComponentType,\n type FC,\n Fragment,\n type ReactElement,\n type ReactNode,\n isValidElement,\n memo,\n useContext,\n useEffect,\n useMemo,\n useRef,\n} from 'react'\nimport innerText from 'react-innertext'\nimport { tv } from 'tailwind-variants'\n\nimport { useObjectAttributes } from '../../../hooks/useObjectAttributes'\nimport { useIntl } from '../../../intl'\nimport { type AnchorButton, Button, type AbstractProps as ButtonProps } from '../../Button'\nimport { FaCaretDownIcon, FaEllipsisIcon } from '../../Icon'\nimport { Dropdown, DropdownContext } from '../Dropdown'\nimport { DropdownCloser } from '../DropdownCloser'\nimport { DropdownContent } from '../DropdownContent'\nimport { DropdownTrigger } from '../DropdownTrigger'\n\nimport { DropdownMenuGroup } from './DropdownMenuGroup'\nimport useKeyboardNavigation from './useKeyboardNavigation'\n\nimport type { RemoteDialogTrigger } from '../../Dialog'\n\ntype Actions = ActionItem | ActionItem[]\n\n// これでコンポーネントを絞れるわけではないが Button[variant=text] を使ってほしいんだよ! という気持ち\ntype ActionItem =\n | ReactElement<ComponentProps<typeof Button>>\n | ReactElement<ComponentProps<typeof AnchorButton>>\n | ReactElement<ComponentProps<typeof RemoteDialogTrigger>>\n | ReactNode\n\ntype ObjectTriggerType = {\n /** 引き金となるボタンラベル */\n children: ReactNode\n /** 引き金となるボタンの大きさ */\n size?: ButtonProps['size']\n /** 引き金となるボタンをアイコンのみとするかどうか */\n onlyIcon?:\n | boolean\n | {\n /** 引き金となるアイコンを差し替えたい場合(onlyIcon=true の場合のみ有効) */\n component?: ComponentType<ComponentProps<typeof FaCaretDownIcon>>\n }\n}\ntype AbstractProps = {\n /** 引き金となるボタン */\n trigger: ReactNode | ObjectTriggerType\n /** 操作群 */\n children: Actions\n /** ドロップダウンメニューが開かれた際のイベント */\n onOpen?: () => void\n /** ドロップダウンメニューが閉じられた際のイベント */\n onClose?: () => void\n}\ntype ElementProps = Omit<ComponentPropsWithRef<'button'>, keyof AbstractProps>\ntype Props = AbstractProps & ElementProps\n\nconst triggerObjectConverter = (trigger: ReactNode) => ({\n children: trigger,\n})\n\nconst classNameGenerator = tv({\n slots: {\n triggerWrapper: 'smarthr-ui-DropdownMenuButton',\n triggerButton:\n 'smarthr-ui-DropdownMenuButton-trigger [&[aria-expanded=\"true\"]_.smarthr-ui-Icon:last-child]:shr-rotate-180',\n actionList: [\n 'smarthr-ui-DropdownMenuButton-panel',\n 'shr-list-none shr-py-0.5',\n [\n /* unset した Button の右 padding 分 */\n '[&_.smarthr-ui-Button-disabledWrapper]:shr-pe-1',\n '[&_.smarthr-ui-Button-disabledWrapper]:shr-gap-x-0.5',\n '[&_.smarthr-ui-Button-disabledWrapper_>_.smarthr-ui-Button]:shr-w-[unset] [&_.smarthr-ui-Button-disabledWrapper_>_.smarthr-ui-Button]:shr-bg-transparent [&_.smarthr-ui-Button-disabledWrapper_>_.smarthr-ui-Button]:shr-pe-[unset]',\n ],\n ],\n actionListItemButton: [\n // HINT: 実際にレンダリングされた要素のclassに対して追加されるため、優先度を上げる必要がある\n '[&&]:shr-w-full [&&]:shr-justify-start [&&]:shr-rounded-none [&&]:shr-border-none [&&]:shr-py-0.5 [&&]:shr-font-normal',\n '[&&]:focus-visible:shr-focus-indicator',\n ],\n },\n})\n\nconst { triggerWrapper, triggerButton, actionList, actionListItemButton } = classNameGenerator()\n\nexport const DropdownMenuButton: FC<Props> = ({\n trigger,\n children,\n onOpen,\n onClose,\n className,\n ...rest\n}) => {\n const {\n children: triggerChildren,\n size: triggerSize,\n onlyIcon: onlyIconTrigger,\n } = useObjectAttributes<ReactNode | ObjectTriggerType, ObjectTriggerType>(\n trigger,\n triggerObjectConverter,\n )\n\n const containerRef = useRef<HTMLUListElement>(null)\n\n useKeyboardNavigation(containerRef)\n\n const classNames = useMemo(\n () => ({\n triggerWrapper: triggerWrapper({ className }),\n triggerButton: triggerButton(),\n actionList: actionList(),\n }),\n [className],\n )\n\n return (\n <Dropdown onOpen={onOpen} onClose={onClose}>\n <MemoizedTriggerButton\n {...rest}\n onlyIconTrigger={onlyIconTrigger}\n triggerSize={triggerSize}\n classNames={classNames}\n >\n {triggerChildren}\n </MemoizedTriggerButton>\n <DropdownContent controllable={true}>\n <menu ref={containerRef} role=\"menu\" className={classNames.actionList}>\n {renderButtonList(children)}\n </menu>\n </DropdownContent>\n </Dropdown>\n )\n}\n\nconst MemoizedTriggerButton = memo<\n ElementProps & {\n onlyIconTrigger: ObjectTriggerType['onlyIcon']\n triggerSize: ObjectTriggerType['size']\n children: ObjectTriggerType['children']\n classNames: {\n triggerWrapper: string\n triggerButton: string\n }\n }\n>(({ onlyIconTrigger, triggerSize, children, classNames, ...rest }) => {\n const { localize } = useIntl()\n\n const { active } = useContext(DropdownContext)\n\n
|
|
1
|
+
{"version":3,"file":"DropdownMenuButton.js","sources":["../../../../src/components/Dropdown/DropdownMenuButton/DropdownMenuButton.tsx"],"sourcesContent":["'use client'\n\nimport {\n Children,\n type ComponentProps,\n type ComponentPropsWithRef,\n type ComponentType,\n type FC,\n Fragment,\n type ReactElement,\n type ReactNode,\n isValidElement,\n memo,\n useContext,\n useEffect,\n useMemo,\n useRef,\n} from 'react'\nimport innerText from 'react-innertext'\nimport { tv } from 'tailwind-variants'\n\nimport { useObjectAttributes } from '../../../hooks/useObjectAttributes'\nimport { useIntl } from '../../../intl'\nimport { type AnchorButton, Button, type AbstractProps as ButtonProps } from '../../Button'\nimport { FaCaretDownIcon, FaEllipsisIcon } from '../../Icon'\nimport { Dropdown, DropdownContext } from '../Dropdown'\nimport { DropdownCloser } from '../DropdownCloser'\nimport { DropdownContent } from '../DropdownContent'\nimport { DropdownTrigger } from '../DropdownTrigger'\n\nimport { DropdownMenuGroup } from './DropdownMenuGroup'\nimport useKeyboardNavigation from './useKeyboardNavigation'\n\nimport type { RemoteDialogTrigger } from '../../Dialog'\n\ntype Actions = ActionItem | ActionItem[]\n\n// これでコンポーネントを絞れるわけではないが Button[variant=text] を使ってほしいんだよ! という気持ち\ntype ActionItem =\n | ReactElement<ComponentProps<typeof Button>>\n | ReactElement<ComponentProps<typeof AnchorButton>>\n | ReactElement<ComponentProps<typeof RemoteDialogTrigger>>\n | ReactNode\n\ntype ObjectTriggerType = {\n /** 引き金となるボタンラベル */\n children: ReactNode\n /** 引き金となるボタンの大きさ */\n size?: ButtonProps['size']\n /** 引き金となるボタンをアイコンのみとするかどうか */\n onlyIcon?:\n | boolean\n | {\n /** 引き金となるアイコンを差し替えたい場合(onlyIcon=true の場合のみ有効) */\n component?: ComponentType<ComponentProps<typeof FaCaretDownIcon>>\n }\n}\ntype AbstractProps = {\n /** 引き金となるボタン */\n trigger: ReactNode | ObjectTriggerType\n /** 操作群 */\n children: Actions\n /** ドロップダウンメニューが開かれた際のイベント */\n onOpen?: () => void\n /** ドロップダウンメニューが閉じられた際のイベント */\n onClose?: () => void\n}\ntype ElementProps = Omit<ComponentPropsWithRef<'button'>, keyof AbstractProps>\ntype Props = AbstractProps & ElementProps\n\nconst triggerObjectConverter = (trigger: ReactNode) => ({\n children: trigger,\n})\n\nconst classNameGenerator = tv({\n slots: {\n triggerWrapper: 'smarthr-ui-DropdownMenuButton',\n triggerButton:\n 'smarthr-ui-DropdownMenuButton-trigger [&[aria-expanded=\"true\"]_.smarthr-ui-Icon:last-child]:shr-rotate-180',\n actionList: [\n 'smarthr-ui-DropdownMenuButton-panel',\n 'shr-list-none shr-py-0.5',\n [\n /* unset した Button の右 padding 分 */\n '[&_.smarthr-ui-Button-disabledWrapper]:shr-pe-1',\n '[&_.smarthr-ui-Button-disabledWrapper]:shr-gap-x-0.5',\n '[&_.smarthr-ui-Button-disabledWrapper_>_.smarthr-ui-Button]:shr-w-[unset] [&_.smarthr-ui-Button-disabledWrapper_>_.smarthr-ui-Button]:shr-bg-transparent [&_.smarthr-ui-Button-disabledWrapper_>_.smarthr-ui-Button]:shr-pe-[unset]',\n ],\n ],\n actionListItemButton: [\n // HINT: 実際にレンダリングされた要素のclassに対して追加されるため、優先度を上げる必要がある\n '[&&]:shr-w-full [&&]:shr-justify-start [&&]:shr-rounded-none [&&]:shr-border-none [&&]:shr-py-0.5 [&&]:shr-font-normal',\n '[&&]:focus-visible:shr-focus-indicator',\n ],\n },\n})\n\nconst { triggerWrapper, triggerButton, actionList, actionListItemButton } = classNameGenerator()\n\nexport const DropdownMenuButton: FC<Props> = ({\n trigger,\n children,\n onOpen,\n onClose,\n className,\n ...rest\n}) => {\n const {\n children: triggerChildren,\n size: triggerSize,\n onlyIcon: onlyIconTrigger,\n } = useObjectAttributes<ReactNode | ObjectTriggerType, ObjectTriggerType>(\n trigger,\n triggerObjectConverter,\n )\n\n const containerRef = useRef<HTMLUListElement>(null)\n\n useKeyboardNavigation(containerRef)\n\n const classNames = useMemo(\n () => ({\n triggerWrapper: triggerWrapper({ className }),\n triggerButton: triggerButton(),\n actionList: actionList(),\n }),\n [className],\n )\n\n return (\n <Dropdown onOpen={onOpen} onClose={onClose}>\n <MemoizedTriggerButton\n {...rest}\n onlyIconTrigger={onlyIconTrigger}\n triggerSize={triggerSize}\n classNames={classNames}\n >\n {triggerChildren}\n </MemoizedTriggerButton>\n <DropdownContent controllable={true}>\n <menu ref={containerRef} role=\"menu\" className={classNames.actionList}>\n {renderButtonList(children)}\n </menu>\n </DropdownContent>\n </Dropdown>\n )\n}\n\nconst MemoizedTriggerButton = memo<\n ElementProps & {\n onlyIconTrigger: ObjectTriggerType['onlyIcon']\n triggerSize: ObjectTriggerType['size']\n children: ObjectTriggerType['children']\n classNames: {\n triggerWrapper: string\n triggerButton: string\n }\n }\n>(({ onlyIconTrigger, triggerSize, children, classNames, ...rest }) => {\n const { localize } = useIntl()\n\n const { active } = useContext(DropdownContext)\n\n return (\n <DropdownTrigger\n className={classNames.triggerWrapper}\n tooltip={{ show: !!onlyIconTrigger, message: children }}\n >\n <Button\n {...rest}\n suffix={\n !onlyIconTrigger && (\n <FaCaretDownIcon\n alt={\n active\n ? localize({\n id: 'smarthr-ui/DropdownMenuButton/triggerActive',\n defaultText: '候補を閉じる',\n })\n : localize({\n id: 'smarthr-ui/DropdownMenuButton/triggerInactive',\n defaultText: '候補を開く',\n })\n }\n />\n )\n }\n size={triggerSize}\n className={classNames.triggerButton}\n >\n <TriggerLabelText onlyIconTrigger={onlyIconTrigger}>{children}</TriggerLabelText>\n </Button>\n </DropdownTrigger>\n )\n})\n\nconst TriggerLabelText = memo<{\n onlyIconTrigger: ObjectTriggerType['onlyIcon']\n children: ObjectTriggerType['children']\n}>(({ children, onlyIconTrigger }) => {\n if (!onlyIconTrigger) {\n return children\n }\n\n const Icon = (typeof onlyIconTrigger === 'object' && onlyIconTrigger.component) || FaEllipsisIcon\n\n return <Icon alt={typeof children === 'string' ? children : innerText(children)} />\n})\n\nexport const renderButtonList = (children: Actions) =>\n Children.map(children, (item): ReactNode => {\n if (!item || !isValidElement(item)) {\n return null\n }\n\n switch (item.type) {\n case Fragment:\n return renderButtonList(item.props.children)\n case DropdownMenuGroup:\n return item\n }\n\n return <ButtonListItem>{item}</ButtonListItem>\n })\n\nconst ButtonListItem: FC<{ children: ReactElement }> = ({ children }) => {\n const ref = useRef<HTMLLIElement>(null)\n\n useEffect(() => {\n const listItem = ref.current\n if (!listItem) {\n return\n }\n\n const setupButton = () => {\n const button = listItem.querySelector('button,a')\n\n if (button) {\n button.setAttribute('role', 'menuitem')\n button.setAttribute(\n 'class',\n actionListItemButton({ className: button.getAttribute('class') }),\n )\n }\n }\n\n setupButton()\n\n const observer = new MutationObserver(setupButton)\n observer.observe(listItem, {\n childList: true,\n subtree: true,\n })\n\n return () => {\n observer.disconnect()\n }\n }, [])\n\n return (\n <li role=\"presentation\" ref={ref}>\n <DropdownCloser>{children}</DropdownCloser>\n </li>\n )\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAsEA;AACE;AACD;AAED;AACE;AACE;AACA;AAEA;;;AAGE;;;;;AAKC;AACF;AACD;;;;AAIC;AACF;AACF;AAED;;;AAmBE;;AAIA;AAEI;;;AAGD;AAIH;AAiBF;AAEA;AAWE;;AAIA;;AAaoB;AACA;;;AAGA;AACA;;AAatB;AAEA;;AAKI;;AAGF;;AAGF;AAEO;;AAGD;;AAGF;AACE;;AAEA;AACE;;AAGJ;AACF;AAEF;AACE;;AAGE;;;;;;;AASI;AACA;;AAKJ;AAEA;AAEA;AACA;AACE;AACA;AACD;AAED;;AAEA;;AAGF;AAKF;;"}
|
|
@@ -20,7 +20,7 @@ const classNameGenerator = index.tv({
|
|
|
20
20
|
base: 'smarthr-ui-Dropdown shr-inline-block',
|
|
21
21
|
});
|
|
22
22
|
const DropdownTrigger = ({ children, className, tooltip }) => {
|
|
23
|
-
const { active,
|
|
23
|
+
const { active, memoizedOnClickTrigger, contentId, triggerElementRef } = React.useContext(components_Dropdown_Dropdown.DropdownContext);
|
|
24
24
|
const actualClassName = React.useMemo(() => classNameGenerator({ className }), [className]);
|
|
25
25
|
React.useEffect(() => {
|
|
26
26
|
if (!triggerElementRef.current) {
|
|
@@ -34,27 +34,44 @@ const DropdownTrigger = ({ children, className, tooltip }) => {
|
|
|
34
34
|
});
|
|
35
35
|
}, [active, triggerElementRef, contentId]);
|
|
36
36
|
React.useEffect(() => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
const button = triggerElementRef.current.querySelector('button');
|
|
41
|
-
// 引き金となる要素が disabled な場合、処理を差し込む必要がないため、そのまま出力する
|
|
42
|
-
if (!button || button.disabled || button.getAttribute('aria-disabled') === 'true') {
|
|
37
|
+
const triggerElement = triggerElementRef.current;
|
|
38
|
+
if (!triggerElement) {
|
|
43
39
|
return;
|
|
44
40
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
let currentCleanup;
|
|
42
|
+
const setupButton = () => {
|
|
43
|
+
// 既存のクリーンアップを実行
|
|
44
|
+
currentCleanup?.();
|
|
45
|
+
currentCleanup = undefined;
|
|
46
|
+
const button = triggerElement.querySelector('button');
|
|
47
|
+
// 引き金となる要素が disabled な場合、処理を差し込む必要がないため、そのまま出力する
|
|
48
|
+
if (!button || button.disabled || button.getAttribute('aria-disabled') === 'true') {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
// HINT: Trigger要素自体にonClickが設定されている場合、先にDropdownを開いた状態で処理を行いたい
|
|
52
|
+
// そのためcaptureで開く処理を実行する
|
|
53
|
+
const callback = (e) => {
|
|
54
|
+
memoizedOnClickTrigger(e.currentTarget.getBoundingClientRect());
|
|
55
|
+
};
|
|
56
|
+
button.addEventListener('click', callback, CAPTURE_OPTION);
|
|
57
|
+
currentCleanup = () => {
|
|
58
|
+
button.removeEventListener('click', callback, CAPTURE_OPTION);
|
|
59
|
+
};
|
|
49
60
|
};
|
|
50
|
-
|
|
61
|
+
setupButton();
|
|
62
|
+
const observer = new MutationObserver(setupButton);
|
|
63
|
+
observer.observe(triggerElement, {
|
|
64
|
+
childList: true,
|
|
65
|
+
subtree: true,
|
|
66
|
+
});
|
|
51
67
|
return () => {
|
|
52
|
-
|
|
68
|
+
currentCleanup?.();
|
|
69
|
+
observer.disconnect();
|
|
53
70
|
};
|
|
54
|
-
}, [
|
|
55
|
-
return (jsxRuntime.jsx("div", { ref: triggerElementRef, className: actualClassName, children: jsxRuntime.jsx(ConditionalWrapper, { shouldWrapContent: tooltip?.show, wrapper: ({ children: currentChildren }) => (
|
|
71
|
+
}, [memoizedOnClickTrigger, triggerElementRef]);
|
|
72
|
+
return (jsxRuntime.jsx("div", { ref: triggerElementRef, className: actualClassName, children: jsxRuntime.jsx(ConditionalWrapper, { shouldWrapContent: tooltip?.show, wrapper: ({ children: currentChildren }) => tooltip?.message ? (
|
|
56
73
|
// eslint-disable-next-line smarthr/a11y-scroller-has-tabindex
|
|
57
|
-
jsxRuntime.jsx(components_Tooltip_Tooltip.Tooltip, { message: tooltip?.message, triggerType: "icon", tabIndex: -1, children: currentChildren })), children: children }) }));
|
|
74
|
+
jsxRuntime.jsx(components_Tooltip_Tooltip.Tooltip, { message: tooltip?.message, triggerType: "icon", tabIndex: -1, children: currentChildren })) : (currentChildren), children: children }) }));
|
|
58
75
|
};
|
|
59
76
|
|
|
60
77
|
exports.DropdownTrigger = DropdownTrigger;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropdownTrigger.cjs","sources":["../../../src/components/Dropdown/DropdownTrigger.tsx"],"sourcesContent":["'use client'\n\nimport {\n type ComponentProps,\n type FC,\n type PropsWithChildren,\n type ReactNode,\n useContext,\n useEffect,\n useMemo,\n} from 'react'\nimport { tv } from 'tailwind-variants'\n\nimport { tabbable } from '../../libs/tabbable'\nimport { Tooltip } from '../Tooltip'\n\nimport { DropdownContext } from './Dropdown'\n\ntype ConditionalWrapperProps = {\n shouldWrapContent?: boolean\n wrapper: FC<PropsWithChildren>\n}\n\nconst CAPTURE_OPTION = {\n capture: true,\n}\n\n/**\n * 条件付きでラッパをレンダリングする\n */\nconst ConditionalWrapper: FC<PropsWithChildren<ConditionalWrapperProps>> = ({\n shouldWrapContent,\n wrapper,\n children,\n}) => (shouldWrapContent ? wrapper({ children }) : children)\n\ntype Props = PropsWithChildren<ComponentProps<'div'>> & {\n tooltip?: { message: ReactNode; show?: boolean }\n}\n\nconst classNameGenerator = tv({\n base: 'smarthr-ui-Dropdown shr-inline-block',\n})\n\nexport const DropdownTrigger: FC<Props> = ({ children, className, tooltip }) => {\n const { active,
|
|
1
|
+
{"version":3,"file":"DropdownTrigger.cjs","sources":["../../../src/components/Dropdown/DropdownTrigger.tsx"],"sourcesContent":["'use client'\n\nimport {\n type ComponentProps,\n type FC,\n type PropsWithChildren,\n type ReactNode,\n useContext,\n useEffect,\n useMemo,\n} from 'react'\nimport { tv } from 'tailwind-variants'\n\nimport { tabbable } from '../../libs/tabbable'\nimport { Tooltip } from '../Tooltip'\n\nimport { DropdownContext } from './Dropdown'\n\ntype ConditionalWrapperProps = {\n shouldWrapContent?: boolean\n wrapper: FC<PropsWithChildren>\n}\n\nconst CAPTURE_OPTION = {\n capture: true,\n}\n\n/**\n * 条件付きでラッパをレンダリングする\n */\nconst ConditionalWrapper: FC<PropsWithChildren<ConditionalWrapperProps>> = ({\n shouldWrapContent,\n wrapper,\n children,\n}) => (shouldWrapContent ? wrapper({ children }) : children)\n\ntype Props = PropsWithChildren<ComponentProps<'div'>> & {\n tooltip?: { message: ReactNode; show?: boolean }\n}\n\nconst classNameGenerator = tv({\n base: 'smarthr-ui-Dropdown shr-inline-block',\n})\n\nexport const DropdownTrigger: FC<Props> = ({ children, className, tooltip }) => {\n const { active, memoizedOnClickTrigger, contentId, triggerElementRef } =\n useContext(DropdownContext)\n const actualClassName = useMemo(() => classNameGenerator({ className }), [className])\n\n useEffect(() => {\n if (!triggerElementRef.current) {\n return\n }\n\n // apply ARIA to all focusable elements in trigger\n const triggers = tabbable(triggerElementRef.current, { shouldIgnoreVisibility: true })\n\n triggers.forEach((trigger) => {\n trigger.setAttribute('aria-expanded', active.toString())\n trigger.setAttribute('aria-controls', contentId)\n })\n }, [active, triggerElementRef, contentId])\n\n useEffect(() => {\n const triggerElement = triggerElementRef.current\n if (!triggerElement) {\n return\n }\n\n let currentCleanup: (() => void) | undefined\n\n const setupButton = () => {\n // 既存のクリーンアップを実行\n currentCleanup?.()\n currentCleanup = undefined\n\n const button = triggerElement.querySelector<HTMLButtonElement>('button')\n\n // 引き金となる要素が disabled な場合、処理を差し込む必要がないため、そのまま出力する\n if (!button || button.disabled || button.getAttribute('aria-disabled') === 'true') {\n return\n }\n\n // HINT: Trigger要素自体にonClickが設定されている場合、先にDropdownを開いた状態で処理を行いたい\n // そのためcaptureで開く処理を実行する\n const callback = (e: MouseEvent) => {\n memoizedOnClickTrigger((e.currentTarget! as HTMLButtonElement).getBoundingClientRect())\n }\n\n button.addEventListener('click', callback, CAPTURE_OPTION)\n\n currentCleanup = () => {\n button.removeEventListener('click', callback, CAPTURE_OPTION)\n }\n }\n\n setupButton()\n\n const observer = new MutationObserver(setupButton)\n\n observer.observe(triggerElement, {\n childList: true,\n subtree: true,\n })\n\n return () => {\n currentCleanup?.()\n observer.disconnect()\n }\n }, [memoizedOnClickTrigger, triggerElementRef])\n\n return (\n <div ref={triggerElementRef} className={actualClassName}>\n {/* eslint-disable-next-line smarthr/a11y-scroller-has-tabindex */}\n <ConditionalWrapper\n shouldWrapContent={tooltip?.show}\n wrapper={({ children: currentChildren }) =>\n tooltip?.message ? (\n // eslint-disable-next-line smarthr/a11y-scroller-has-tabindex\n <Tooltip message={tooltip?.message} triggerType=\"icon\" tabIndex={-1}>\n {currentChildren}\n </Tooltip>\n ) : (\n currentChildren\n )\n }\n >\n {children}\n </ConditionalWrapper>\n </div>\n )\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAuBA;AACE;;AAGF;;AAEG;AACH;AAUA;AACE;AACD;AAEM;AACL;AAEA;;AAGE;;;;AAKA;AAEA;;AAEE;AACF;;;AAIA;;;;AAKA;;;;;;;AAUE;;;;;AAMA;;AAEA;;;;AAMA;AACF;AAEA;AAEA;AAEA;AACE;AACA;AACD;AAED;;;AAGA;AACF;AAEA;;AAQU;AAYZ;;"}
|
|
@@ -18,7 +18,7 @@ const classNameGenerator = ce({
|
|
|
18
18
|
base: 'smarthr-ui-Dropdown shr-inline-block',
|
|
19
19
|
});
|
|
20
20
|
const DropdownTrigger = ({ children, className, tooltip }) => {
|
|
21
|
-
const { active,
|
|
21
|
+
const { active, memoizedOnClickTrigger, contentId, triggerElementRef } = useContext(DropdownContext);
|
|
22
22
|
const actualClassName = useMemo(() => classNameGenerator({ className }), [className]);
|
|
23
23
|
useEffect(() => {
|
|
24
24
|
if (!triggerElementRef.current) {
|
|
@@ -32,27 +32,44 @@ const DropdownTrigger = ({ children, className, tooltip }) => {
|
|
|
32
32
|
});
|
|
33
33
|
}, [active, triggerElementRef, contentId]);
|
|
34
34
|
useEffect(() => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
const button = triggerElementRef.current.querySelector('button');
|
|
39
|
-
// 引き金となる要素が disabled な場合、処理を差し込む必要がないため、そのまま出力する
|
|
40
|
-
if (!button || button.disabled || button.getAttribute('aria-disabled') === 'true') {
|
|
35
|
+
const triggerElement = triggerElementRef.current;
|
|
36
|
+
if (!triggerElement) {
|
|
41
37
|
return;
|
|
42
38
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
let currentCleanup;
|
|
40
|
+
const setupButton = () => {
|
|
41
|
+
// 既存のクリーンアップを実行
|
|
42
|
+
currentCleanup?.();
|
|
43
|
+
currentCleanup = undefined;
|
|
44
|
+
const button = triggerElement.querySelector('button');
|
|
45
|
+
// 引き金となる要素が disabled な場合、処理を差し込む必要がないため、そのまま出力する
|
|
46
|
+
if (!button || button.disabled || button.getAttribute('aria-disabled') === 'true') {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
// HINT: Trigger要素自体にonClickが設定されている場合、先にDropdownを開いた状態で処理を行いたい
|
|
50
|
+
// そのためcaptureで開く処理を実行する
|
|
51
|
+
const callback = (e) => {
|
|
52
|
+
memoizedOnClickTrigger(e.currentTarget.getBoundingClientRect());
|
|
53
|
+
};
|
|
54
|
+
button.addEventListener('click', callback, CAPTURE_OPTION);
|
|
55
|
+
currentCleanup = () => {
|
|
56
|
+
button.removeEventListener('click', callback, CAPTURE_OPTION);
|
|
57
|
+
};
|
|
47
58
|
};
|
|
48
|
-
|
|
59
|
+
setupButton();
|
|
60
|
+
const observer = new MutationObserver(setupButton);
|
|
61
|
+
observer.observe(triggerElement, {
|
|
62
|
+
childList: true,
|
|
63
|
+
subtree: true,
|
|
64
|
+
});
|
|
49
65
|
return () => {
|
|
50
|
-
|
|
66
|
+
currentCleanup?.();
|
|
67
|
+
observer.disconnect();
|
|
51
68
|
};
|
|
52
|
-
}, [
|
|
53
|
-
return (jsx("div", { ref: triggerElementRef, className: actualClassName, children: jsx(ConditionalWrapper, { shouldWrapContent: tooltip?.show, wrapper: ({ children: currentChildren }) => (
|
|
69
|
+
}, [memoizedOnClickTrigger, triggerElementRef]);
|
|
70
|
+
return (jsx("div", { ref: triggerElementRef, className: actualClassName, children: jsx(ConditionalWrapper, { shouldWrapContent: tooltip?.show, wrapper: ({ children: currentChildren }) => tooltip?.message ? (
|
|
54
71
|
// eslint-disable-next-line smarthr/a11y-scroller-has-tabindex
|
|
55
|
-
jsx(Tooltip, { message: tooltip?.message, triggerType: "icon", tabIndex: -1, children: currentChildren })), children: children }) }));
|
|
72
|
+
jsx(Tooltip, { message: tooltip?.message, triggerType: "icon", tabIndex: -1, children: currentChildren })) : (currentChildren), children: children }) }));
|
|
56
73
|
};
|
|
57
74
|
|
|
58
75
|
export { DropdownTrigger };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropdownTrigger.js","sources":["../../../src/components/Dropdown/DropdownTrigger.tsx"],"sourcesContent":["'use client'\n\nimport {\n type ComponentProps,\n type FC,\n type PropsWithChildren,\n type ReactNode,\n useContext,\n useEffect,\n useMemo,\n} from 'react'\nimport { tv } from 'tailwind-variants'\n\nimport { tabbable } from '../../libs/tabbable'\nimport { Tooltip } from '../Tooltip'\n\nimport { DropdownContext } from './Dropdown'\n\ntype ConditionalWrapperProps = {\n shouldWrapContent?: boolean\n wrapper: FC<PropsWithChildren>\n}\n\nconst CAPTURE_OPTION = {\n capture: true,\n}\n\n/**\n * 条件付きでラッパをレンダリングする\n */\nconst ConditionalWrapper: FC<PropsWithChildren<ConditionalWrapperProps>> = ({\n shouldWrapContent,\n wrapper,\n children,\n}) => (shouldWrapContent ? wrapper({ children }) : children)\n\ntype Props = PropsWithChildren<ComponentProps<'div'>> & {\n tooltip?: { message: ReactNode; show?: boolean }\n}\n\nconst classNameGenerator = tv({\n base: 'smarthr-ui-Dropdown shr-inline-block',\n})\n\nexport const DropdownTrigger: FC<Props> = ({ children, className, tooltip }) => {\n const { active,
|
|
1
|
+
{"version":3,"file":"DropdownTrigger.js","sources":["../../../src/components/Dropdown/DropdownTrigger.tsx"],"sourcesContent":["'use client'\n\nimport {\n type ComponentProps,\n type FC,\n type PropsWithChildren,\n type ReactNode,\n useContext,\n useEffect,\n useMemo,\n} from 'react'\nimport { tv } from 'tailwind-variants'\n\nimport { tabbable } from '../../libs/tabbable'\nimport { Tooltip } from '../Tooltip'\n\nimport { DropdownContext } from './Dropdown'\n\ntype ConditionalWrapperProps = {\n shouldWrapContent?: boolean\n wrapper: FC<PropsWithChildren>\n}\n\nconst CAPTURE_OPTION = {\n capture: true,\n}\n\n/**\n * 条件付きでラッパをレンダリングする\n */\nconst ConditionalWrapper: FC<PropsWithChildren<ConditionalWrapperProps>> = ({\n shouldWrapContent,\n wrapper,\n children,\n}) => (shouldWrapContent ? wrapper({ children }) : children)\n\ntype Props = PropsWithChildren<ComponentProps<'div'>> & {\n tooltip?: { message: ReactNode; show?: boolean }\n}\n\nconst classNameGenerator = tv({\n base: 'smarthr-ui-Dropdown shr-inline-block',\n})\n\nexport const DropdownTrigger: FC<Props> = ({ children, className, tooltip }) => {\n const { active, memoizedOnClickTrigger, contentId, triggerElementRef } =\n useContext(DropdownContext)\n const actualClassName = useMemo(() => classNameGenerator({ className }), [className])\n\n useEffect(() => {\n if (!triggerElementRef.current) {\n return\n }\n\n // apply ARIA to all focusable elements in trigger\n const triggers = tabbable(triggerElementRef.current, { shouldIgnoreVisibility: true })\n\n triggers.forEach((trigger) => {\n trigger.setAttribute('aria-expanded', active.toString())\n trigger.setAttribute('aria-controls', contentId)\n })\n }, [active, triggerElementRef, contentId])\n\n useEffect(() => {\n const triggerElement = triggerElementRef.current\n if (!triggerElement) {\n return\n }\n\n let currentCleanup: (() => void) | undefined\n\n const setupButton = () => {\n // 既存のクリーンアップを実行\n currentCleanup?.()\n currentCleanup = undefined\n\n const button = triggerElement.querySelector<HTMLButtonElement>('button')\n\n // 引き金となる要素が disabled な場合、処理を差し込む必要がないため、そのまま出力する\n if (!button || button.disabled || button.getAttribute('aria-disabled') === 'true') {\n return\n }\n\n // HINT: Trigger要素自体にonClickが設定されている場合、先にDropdownを開いた状態で処理を行いたい\n // そのためcaptureで開く処理を実行する\n const callback = (e: MouseEvent) => {\n memoizedOnClickTrigger((e.currentTarget! as HTMLButtonElement).getBoundingClientRect())\n }\n\n button.addEventListener('click', callback, CAPTURE_OPTION)\n\n currentCleanup = () => {\n button.removeEventListener('click', callback, CAPTURE_OPTION)\n }\n }\n\n setupButton()\n\n const observer = new MutationObserver(setupButton)\n\n observer.observe(triggerElement, {\n childList: true,\n subtree: true,\n })\n\n return () => {\n currentCleanup?.()\n observer.disconnect()\n }\n }, [memoizedOnClickTrigger, triggerElementRef])\n\n return (\n <div ref={triggerElementRef} className={actualClassName}>\n {/* eslint-disable-next-line smarthr/a11y-scroller-has-tabindex */}\n <ConditionalWrapper\n shouldWrapContent={tooltip?.show}\n wrapper={({ children: currentChildren }) =>\n tooltip?.message ? (\n // eslint-disable-next-line smarthr/a11y-scroller-has-tabindex\n <Tooltip message={tooltip?.message} triggerType=\"icon\" tabIndex={-1}>\n {currentChildren}\n </Tooltip>\n ) : (\n currentChildren\n )\n }\n >\n {children}\n </ConditionalWrapper>\n </div>\n )\n}\n"],"names":[],"mappings":";;;;;;;;;AAuBA;AACE;;AAGF;;AAEG;AACH;AAUA;AACE;AACD;AAEM;AACL;AAEA;;AAGE;;;;AAKA;AAEA;;AAEE;AACF;;;AAIA;;;;AAKA;;;;;;;AAUE;;;;;AAMA;;AAEA;;;;AAMA;AACF;AAEA;AAEA;AAEA;AACE;AACA;AACD;AAED;;;AAGA;AACF;AAEA;;AAQU;AAYZ;;"}
|
|
@@ -46,7 +46,7 @@ const classNameGenerator = index.tv({
|
|
|
46
46
|
});
|
|
47
47
|
const COMMON_GAP = { column: 0.25, row: 0 };
|
|
48
48
|
const CHILDREN_GAP = { column: 0.5, row: 0.25 };
|
|
49
|
-
const Header = ({ enableNew, logo, logoHref, featureName, apps, tenants, currentTenantId, onTenantSelect, children, className, }) => {
|
|
49
|
+
const Header = ({ enableNew, logo, logoHref, featureName, apps, tenants, currentTenantId, onTenantSelect, children, className, ...rest }) => {
|
|
50
50
|
const classNames = React.useMemo(() => {
|
|
51
51
|
const { wrapper, logoLink, tenantInfo: tenantInfoStyle, tenantNameText, actions, } = classNameGenerator({ enableNew });
|
|
52
52
|
return {
|
|
@@ -57,9 +57,9 @@ const Header = ({ enableNew, logo, logoHref, featureName, apps, tenants, current
|
|
|
57
57
|
actions: actions(),
|
|
58
58
|
};
|
|
59
59
|
}, [enableNew, className]);
|
|
60
|
-
return (jsxRuntime.jsxs(components_Layout_Cluster_Cluster.Cluster, { as: "header", justify: "space-between", gap: COMMON_GAP, className: classNames.wrapper, children: [jsxRuntime.jsxs(components_Layout_Cluster_Cluster.Cluster, { align: "center", gap: COMMON_GAP, children: [jsxRuntime.jsx(
|
|
60
|
+
return (jsxRuntime.jsxs(components_Layout_Cluster_Cluster.Cluster, { ...rest, as: "header", justify: "space-between", gap: COMMON_GAP, className: classNames.wrapper, children: [jsxRuntime.jsxs(components_Layout_Cluster_Cluster.Cluster, { align: "center", gap: COMMON_GAP, children: [jsxRuntime.jsx(LogoLink, { href: logoHref, enableNew: enableNew, className: classNames.logoLink, children: logo }), enableNew ? (jsxRuntime.jsx(MemoizedAppLauncher, { featureName: featureName, apps: apps, enableNew: enableNew })) : (jsxRuntime.jsx(TenantSwitcher, { currentTenantId: currentTenantId, tenants: tenants, classNames: classNames, onTenantSelect: onTenantSelect }))] }), jsxRuntime.jsx(components_Layout_Cluster_Cluster.Cluster, { align: "center", justify: "flex-end", gap: CHILDREN_GAP, className: classNames.actions, children: children })] }));
|
|
61
61
|
};
|
|
62
|
-
const
|
|
62
|
+
const LogoLink = React.memo(({ children, href, enableNew, className }) => (jsxRuntime.jsx("a", { href: href || '/', className: className, children: children || jsxRuntime.jsx(components_SmartHRLogo_SmartHRLogo.SmartHRLogo, { fill: enableNew ? 'brand' : undefined, className: "shr-p-0.75" }) })));
|
|
63
63
|
const MemoizedAppLauncher = React.memo(({ featureName, apps = [], enableNew }) => featureName && jsxRuntime.jsx(components_Header_AppLauncher_AppLauncher.AppLauncher, { apps: apps, enableNew: enableNew, triggerLabel: featureName }));
|
|
64
64
|
const TenantSwitcher = React.memo(({ currentTenantId, tenants, classNames, onTenantSelect }) => {
|
|
65
65
|
const currentTenantName = React.useMemo(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Header.cjs","sources":["../../../src/components/Header/Header.tsx"],"sourcesContent":["import {\n type ComponentProps,\n type FC,\n type MouseEvent,\n type PropsWithChildren,\n type ReactElement,\n type ReactNode,\n memo,\n useMemo,\n} from 'react'\nimport { type VariantProps, tv } from 'tailwind-variants'\n\nimport { Button } from '../Button'\nimport { Cluster } from '../Layout'\nimport { SmartHRLogo } from '../SmartHRLogo'\nimport { Text } from '../Text'\n\nimport { AppLauncher } from './AppLauncher'\nimport { HeaderDropdownMenuButton } from './HeaderDropdownMenuButton'\n\nconst classNameGenerator = tv({\n slots: {\n wrapper: ['smarthr-ui-Header', 'shr-bg-brand shr-px-1.25', 'max-md:shr-px-0.75'],\n logoLink: [\n 'smarthr-ui-Header-logoLink',\n /* ロゴが持つ padding 分だけ調整 */\n '-shr-ms-0.75',\n 'focus-visible:shr-focus-indicator',\n ],\n tenantInfo: ['smarthr-ui-Header-tenantInfo', 'shr-ms-auto'],\n tenantNameText: 'shr-px-0.25',\n actions: ['smarthr-ui-Header-actions', 'shr-ms-auto'],\n },\n variants: {\n enableNew: {\n true: {\n wrapper: [\n 'shr-border-0 shr-border-b shr-border-t-6 shr-border-solid shr-border-b-default shr-border-t-brand shr-bg-white shr-px-1.5',\n ],\n logoLink: '',\n tenantInfo: '',\n tenantNameText: '',\n actions: 'shr-py-0.5',\n },\n },\n },\n})\n\ntype Tenant = PropsWithChildren<{\n id: string\n name: ReactNode\n}>\n\ntype AbstractProps = PropsWithChildren<{\n /** ロゴ */\n logo?: ReactElement\n /** ロゴリンク */\n logoHref?: string\n /** 機能名(enableNew と合わせて使います) */\n featureName?: ReactNode\n /** 機能群(enableNew と合わせて使います) */\n apps?: ComponentProps<typeof AppLauncher>['apps']\n /** テナント一覧 */\n tenants?: Tenant[]\n /** 現在のテナント ID */\n currentTenantId?: string\n /** テナントが選択された時に発火するコールバック関数 */\n onTenantSelect?: (id: string) => void\n /** @deprecated internal-ui から利用するので使わないでください。 */\n enableNew?: boolean\n}> &\n VariantProps<typeof classNameGenerator>\ntype Props = AbstractProps & Omit<ComponentProps<'header'>, keyof AbstractProps>\n\nconst COMMON_GAP = { column: 0.25, row: 0 } as const\nconst CHILDREN_GAP = { column: 0.5, row: 0.25 } as const\n\nexport const Header: FC<Props> = ({\n enableNew,\n logo,\n logoHref,\n featureName,\n apps,\n tenants,\n currentTenantId,\n onTenantSelect,\n children,\n className,\n}) => {\n const classNames = useMemo(() => {\n const {\n wrapper,\n logoLink,\n tenantInfo: tenantInfoStyle,\n tenantNameText,\n actions,\n } = classNameGenerator({ enableNew })\n\n return {\n wrapper: wrapper({ className }),\n logoLink: logoLink(),\n tenantInfo: tenantInfoStyle(),\n tenantNameText: tenantNameText(),\n actions: actions(),\n }\n }, [enableNew, className])\n\n return (\n <Cluster
|
|
1
|
+
{"version":3,"file":"Header.cjs","sources":["../../../src/components/Header/Header.tsx"],"sourcesContent":["import {\n type ComponentProps,\n type FC,\n type MouseEvent,\n type PropsWithChildren,\n type ReactElement,\n type ReactNode,\n memo,\n useMemo,\n} from 'react'\nimport { type VariantProps, tv } from 'tailwind-variants'\n\nimport { Button } from '../Button'\nimport { Cluster } from '../Layout'\nimport { SmartHRLogo } from '../SmartHRLogo'\nimport { Text } from '../Text'\n\nimport { AppLauncher } from './AppLauncher'\nimport { HeaderDropdownMenuButton } from './HeaderDropdownMenuButton'\n\nconst classNameGenerator = tv({\n slots: {\n wrapper: ['smarthr-ui-Header', 'shr-bg-brand shr-px-1.25', 'max-md:shr-px-0.75'],\n logoLink: [\n 'smarthr-ui-Header-logoLink',\n /* ロゴが持つ padding 分だけ調整 */\n '-shr-ms-0.75',\n 'focus-visible:shr-focus-indicator',\n ],\n tenantInfo: ['smarthr-ui-Header-tenantInfo', 'shr-ms-auto'],\n tenantNameText: 'shr-px-0.25',\n actions: ['smarthr-ui-Header-actions', 'shr-ms-auto'],\n },\n variants: {\n enableNew: {\n true: {\n wrapper: [\n 'shr-border-0 shr-border-b shr-border-t-6 shr-border-solid shr-border-b-default shr-border-t-brand shr-bg-white shr-px-1.5',\n ],\n logoLink: '',\n tenantInfo: '',\n tenantNameText: '',\n actions: 'shr-py-0.5',\n },\n },\n },\n})\n\ntype Tenant = PropsWithChildren<{\n id: string\n name: ReactNode\n}>\n\ntype AbstractProps = PropsWithChildren<{\n /** ロゴ */\n logo?: ReactElement\n /** ロゴリンク */\n logoHref?: string\n /** 機能名(enableNew と合わせて使います) */\n featureName?: ReactNode\n /** 機能群(enableNew と合わせて使います) */\n apps?: ComponentProps<typeof AppLauncher>['apps']\n /** テナント一覧 */\n tenants?: Tenant[]\n /** 現在のテナント ID */\n currentTenantId?: string\n /** テナントが選択された時に発火するコールバック関数 */\n onTenantSelect?: (id: string) => void\n /** @deprecated internal-ui から利用するので使わないでください。 */\n enableNew?: boolean\n}> &\n VariantProps<typeof classNameGenerator>\ntype Props = AbstractProps & Omit<ComponentProps<'header'>, keyof AbstractProps>\n\nconst COMMON_GAP = { column: 0.25, row: 0 } as const\nconst CHILDREN_GAP = { column: 0.5, row: 0.25 } as const\n\nexport const Header: FC<Props> = ({\n enableNew,\n logo,\n logoHref,\n featureName,\n apps,\n tenants,\n currentTenantId,\n onTenantSelect,\n children,\n className,\n ...rest\n}) => {\n const classNames = useMemo(() => {\n const {\n wrapper,\n logoLink,\n tenantInfo: tenantInfoStyle,\n tenantNameText,\n actions,\n } = classNameGenerator({ enableNew })\n\n return {\n wrapper: wrapper({ className }),\n logoLink: logoLink(),\n tenantInfo: tenantInfoStyle(),\n tenantNameText: tenantNameText(),\n actions: actions(),\n }\n }, [enableNew, className])\n\n return (\n <Cluster\n {...rest}\n as=\"header\"\n justify=\"space-between\"\n gap={COMMON_GAP}\n className={classNames.wrapper}\n >\n <Cluster align=\"center\" gap={COMMON_GAP}>\n <LogoLink href={logoHref} enableNew={enableNew} className={classNames.logoLink}>\n {logo}\n </LogoLink>\n {enableNew ? (\n <MemoizedAppLauncher featureName={featureName} apps={apps} enableNew={enableNew} />\n ) : (\n <TenantSwitcher\n currentTenantId={currentTenantId}\n tenants={tenants}\n classNames={classNames}\n onTenantSelect={onTenantSelect}\n />\n )}\n </Cluster>\n <Cluster align=\"center\" justify=\"flex-end\" gap={CHILDREN_GAP} className={classNames.actions}>\n {children}\n </Cluster>\n </Cluster>\n )\n}\n\nconst LogoLink = memo<\n Pick<Props, 'enableNew'> & { children: Props['logo']; href: Props['logoHref']; className: string }\n>(({ children, href, enableNew, className }) => (\n <a href={href || '/'} className={className}>\n {children || <SmartHRLogo fill={enableNew ? 'brand' : undefined} className=\"shr-p-0.75\" />}\n </a>\n))\n\nconst MemoizedAppLauncher = memo<Pick<Props, 'featureName' | 'apps' | 'enableNew'>>(\n ({ featureName, apps = [], enableNew }) =>\n featureName && <AppLauncher apps={apps} enableNew={enableNew} triggerLabel={featureName} />,\n)\n\nconst TenantSwitcher = memo<\n Pick<Props, 'currentTenantId' | 'tenants' | 'onTenantSelect'> & {\n classNames: { tenantInfo: string; tenantNameText: string }\n }\n>(({ currentTenantId, tenants, classNames, onTenantSelect }) => {\n const currentTenantName = useMemo(() => {\n if (tenants && tenants.length >= 1) {\n const current = tenants.find(({ id }) => id === currentTenantId)\n\n return current ? current.name : tenants[0].name\n }\n\n return undefined\n }, [currentTenantId, tenants])\n\n return (\n currentTenantName && (\n <div className={classNames.tenantInfo}>\n {tenants && tenants.length > 1 ? (\n <MultiTenantDropdownMenuButton\n trigger={currentTenantName}\n tenants={tenants}\n onTenantSelect={onTenantSelect}\n />\n ) : (\n <Text color=\"TEXT_WHITE\" className={classNames.tenantNameText}>\n {currentTenantName}\n </Text>\n )}\n </div>\n )\n )\n})\n\nconst MultiTenantDropdownMenuButton = memo<\n Pick<Required<Props>, 'tenants'> & Pick<Props, 'onTenantSelect'> & { trigger: ReactNode }\n>(({ trigger, tenants, onTenantSelect }) => {\n const onClick = useMemo(\n () =>\n onTenantSelect\n ? (e: MouseEvent<HTMLButtonElement>) => {\n onTenantSelect(e.currentTarget.value)\n }\n : undefined,\n [onTenantSelect],\n )\n\n return (\n <HeaderDropdownMenuButton trigger={trigger}>\n {tenants.map(({ id, name }) => (\n <Button key={id} value={id} onClick={onClick}>\n {name}\n </Button>\n ))}\n </HeaderDropdownMenuButton>\n )\n})\n"],"names":["tv","useMemo","_jsxs","Cluster","_jsx","memo","SmartHRLogo","AppLauncher","Text","HeaderDropdownMenuButton","Button"],"mappings":";;;;;;;;;;;;;;;;;;;AAoBA,MAAM,kBAAkB,GAAGA,QAAE,CAAC;AAC5B,IAAA,KAAK,EAAE;AACL,QAAA,OAAO,EAAE,CAAC,mBAAmB,EAAE,0BAA0B,EAAE,oBAAoB,CAAC;AAChF,QAAA,QAAQ,EAAE;YACR,4BAA4B;;YAE5B,cAAc;YACd,mCAAmC;AACpC,SAAA;AACD,QAAA,UAAU,EAAE,CAAC,8BAA8B,EAAE,aAAa,CAAC;AAC3D,QAAA,cAAc,EAAE,aAAa;AAC7B,QAAA,OAAO,EAAE,CAAC,2BAA2B,EAAE,aAAa,CAAC;AACtD,KAAA;AACD,IAAA,QAAQ,EAAE;AACR,QAAA,SAAS,EAAE;AACT,YAAA,IAAI,EAAE;AACJ,gBAAA,OAAO,EAAE;oBACP,2HAA2H;AAC5H,iBAAA;AACD,gBAAA,QAAQ,EAAE,EAAE;AACZ,gB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C,OAAO,EAAE,OAAO,EAAA,QAAA,EACvC,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,MACxBL,eAACM,+BAAM,EAAA,EAAU,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAA,QAAA,EACzC,IAAI,IADM,EAAE,CAEN,CACV,CAAC,EAAA,CACuB;AAE/B,CAAC,CAAC;;;;"}
|
|
@@ -44,7 +44,7 @@ const classNameGenerator = ce({
|
|
|
44
44
|
});
|
|
45
45
|
const COMMON_GAP = { column: 0.25, row: 0 };
|
|
46
46
|
const CHILDREN_GAP = { column: 0.5, row: 0.25 };
|
|
47
|
-
const Header = ({ enableNew, logo, logoHref, featureName, apps, tenants, currentTenantId, onTenantSelect, children, className, }) => {
|
|
47
|
+
const Header = ({ enableNew, logo, logoHref, featureName, apps, tenants, currentTenantId, onTenantSelect, children, className, ...rest }) => {
|
|
48
48
|
const classNames = useMemo(() => {
|
|
49
49
|
const { wrapper, logoLink, tenantInfo: tenantInfoStyle, tenantNameText, actions, } = classNameGenerator({ enableNew });
|
|
50
50
|
return {
|
|
@@ -55,9 +55,9 @@ const Header = ({ enableNew, logo, logoHref, featureName, apps, tenants, current
|
|
|
55
55
|
actions: actions(),
|
|
56
56
|
};
|
|
57
57
|
}, [enableNew, className]);
|
|
58
|
-
return (jsxs(Cluster, { as: "header", justify: "space-between", gap: COMMON_GAP, className: classNames.wrapper, children: [jsxs(Cluster, { align: "center", gap: COMMON_GAP, children: [jsx(
|
|
58
|
+
return (jsxs(Cluster, { ...rest, as: "header", justify: "space-between", gap: COMMON_GAP, className: classNames.wrapper, children: [jsxs(Cluster, { align: "center", gap: COMMON_GAP, children: [jsx(LogoLink, { href: logoHref, enableNew: enableNew, className: classNames.logoLink, children: logo }), enableNew ? (jsx(MemoizedAppLauncher, { featureName: featureName, apps: apps, enableNew: enableNew })) : (jsx(TenantSwitcher, { currentTenantId: currentTenantId, tenants: tenants, classNames: classNames, onTenantSelect: onTenantSelect }))] }), jsx(Cluster, { align: "center", justify: "flex-end", gap: CHILDREN_GAP, className: classNames.actions, children: children })] }));
|
|
59
59
|
};
|
|
60
|
-
const
|
|
60
|
+
const LogoLink = memo(({ children, href, enableNew, className }) => (jsx("a", { href: href || '/', className: className, children: children || jsx(SmartHRLogo, { fill: enableNew ? 'brand' : undefined, className: "shr-p-0.75" }) })));
|
|
61
61
|
const MemoizedAppLauncher = memo(({ featureName, apps = [], enableNew }) => featureName && jsx(AppLauncher, { apps: apps, enableNew: enableNew, triggerLabel: featureName }));
|
|
62
62
|
const TenantSwitcher = memo(({ currentTenantId, tenants, classNames, onTenantSelect }) => {
|
|
63
63
|
const currentTenantName = useMemo(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Header.js","sources":["../../../src/components/Header/Header.tsx"],"sourcesContent":["import {\n type ComponentProps,\n type FC,\n type MouseEvent,\n type PropsWithChildren,\n type ReactElement,\n type ReactNode,\n memo,\n useMemo,\n} from 'react'\nimport { type VariantProps, tv } from 'tailwind-variants'\n\nimport { Button } from '../Button'\nimport { Cluster } from '../Layout'\nimport { SmartHRLogo } from '../SmartHRLogo'\nimport { Text } from '../Text'\n\nimport { AppLauncher } from './AppLauncher'\nimport { HeaderDropdownMenuButton } from './HeaderDropdownMenuButton'\n\nconst classNameGenerator = tv({\n slots: {\n wrapper: ['smarthr-ui-Header', 'shr-bg-brand shr-px-1.25', 'max-md:shr-px-0.75'],\n logoLink: [\n 'smarthr-ui-Header-logoLink',\n /* ロゴが持つ padding 分だけ調整 */\n '-shr-ms-0.75',\n 'focus-visible:shr-focus-indicator',\n ],\n tenantInfo: ['smarthr-ui-Header-tenantInfo', 'shr-ms-auto'],\n tenantNameText: 'shr-px-0.25',\n actions: ['smarthr-ui-Header-actions', 'shr-ms-auto'],\n },\n variants: {\n enableNew: {\n true: {\n wrapper: [\n 'shr-border-0 shr-border-b shr-border-t-6 shr-border-solid shr-border-b-default shr-border-t-brand shr-bg-white shr-px-1.5',\n ],\n logoLink: '',\n tenantInfo: '',\n tenantNameText: '',\n actions: 'shr-py-0.5',\n },\n },\n },\n})\n\ntype Tenant = PropsWithChildren<{\n id: string\n name: ReactNode\n}>\n\ntype AbstractProps = PropsWithChildren<{\n /** ロゴ */\n logo?: ReactElement\n /** ロゴリンク */\n logoHref?: string\n /** 機能名(enableNew と合わせて使います) */\n featureName?: ReactNode\n /** 機能群(enableNew と合わせて使います) */\n apps?: ComponentProps<typeof AppLauncher>['apps']\n /** テナント一覧 */\n tenants?: Tenant[]\n /** 現在のテナント ID */\n currentTenantId?: string\n /** テナントが選択された時に発火するコールバック関数 */\n onTenantSelect?: (id: string) => void\n /** @deprecated internal-ui から利用するので使わないでください。 */\n enableNew?: boolean\n}> &\n VariantProps<typeof classNameGenerator>\ntype Props = AbstractProps & Omit<ComponentProps<'header'>, keyof AbstractProps>\n\nconst COMMON_GAP = { column: 0.25, row: 0 } as const\nconst CHILDREN_GAP = { column: 0.5, row: 0.25 } as const\n\nexport const Header: FC<Props> = ({\n enableNew,\n logo,\n logoHref,\n featureName,\n apps,\n tenants,\n currentTenantId,\n onTenantSelect,\n children,\n className,\n}) => {\n const classNames = useMemo(() => {\n const {\n wrapper,\n logoLink,\n tenantInfo: tenantInfoStyle,\n tenantNameText,\n actions,\n } = classNameGenerator({ enableNew })\n\n return {\n wrapper: wrapper({ className }),\n logoLink: logoLink(),\n tenantInfo: tenantInfoStyle(),\n tenantNameText: tenantNameText(),\n actions: actions(),\n }\n }, [enableNew, className])\n\n return (\n <Cluster
|
|
1
|
+
{"version":3,"file":"Header.js","sources":["../../../src/components/Header/Header.tsx"],"sourcesContent":["import {\n type ComponentProps,\n type FC,\n type MouseEvent,\n type PropsWithChildren,\n type ReactElement,\n type ReactNode,\n memo,\n useMemo,\n} from 'react'\nimport { type VariantProps, tv } from 'tailwind-variants'\n\nimport { Button } from '../Button'\nimport { Cluster } from '../Layout'\nimport { SmartHRLogo } from '../SmartHRLogo'\nimport { Text } from '../Text'\n\nimport { AppLauncher } from './AppLauncher'\nimport { HeaderDropdownMenuButton } from './HeaderDropdownMenuButton'\n\nconst classNameGenerator = tv({\n slots: {\n wrapper: ['smarthr-ui-Header', 'shr-bg-brand shr-px-1.25', 'max-md:shr-px-0.75'],\n logoLink: [\n 'smarthr-ui-Header-logoLink',\n /* ロゴが持つ padding 分だけ調整 */\n '-shr-ms-0.75',\n 'focus-visible:shr-focus-indicator',\n ],\n tenantInfo: ['smarthr-ui-Header-tenantInfo', 'shr-ms-auto'],\n tenantNameText: 'shr-px-0.25',\n actions: ['smarthr-ui-Header-actions', 'shr-ms-auto'],\n },\n variants: {\n enableNew: {\n true: {\n wrapper: [\n 'shr-border-0 shr-border-b shr-border-t-6 shr-border-solid shr-border-b-default shr-border-t-brand shr-bg-white shr-px-1.5',\n ],\n logoLink: '',\n tenantInfo: '',\n tenantNameText: '',\n actions: 'shr-py-0.5',\n },\n },\n },\n})\n\ntype Tenant = PropsWithChildren<{\n id: string\n name: ReactNode\n}>\n\ntype AbstractProps = PropsWithChildren<{\n /** ロゴ */\n logo?: ReactElement\n /** ロゴリンク */\n logoHref?: string\n /** 機能名(enableNew と合わせて使います) */\n featureName?: ReactNode\n /** 機能群(enableNew と合わせて使います) */\n apps?: ComponentProps<typeof AppLauncher>['apps']\n /** テナント一覧 */\n tenants?: Tenant[]\n /** 現在のテナント ID */\n currentTenantId?: string\n /** テナントが選択された時に発火するコールバック関数 */\n onTenantSelect?: (id: string) => void\n /** @deprecated internal-ui から利用するので使わないでください。 */\n enableNew?: boolean\n}> &\n VariantProps<typeof classNameGenerator>\ntype Props = AbstractProps & Omit<ComponentProps<'header'>, keyof AbstractProps>\n\nconst COMMON_GAP = { column: 0.25, row: 0 } as const\nconst CHILDREN_GAP = { column: 0.5, row: 0.25 } as const\n\nexport const Header: FC<Props> = ({\n enableNew,\n logo,\n logoHref,\n featureName,\n apps,\n tenants,\n currentTenantId,\n onTenantSelect,\n children,\n className,\n ...rest\n}) => {\n const classNames = useMemo(() => {\n const {\n wrapper,\n logoLink,\n tenantInfo: tenantInfoStyle,\n tenantNameText,\n actions,\n } = classNameGenerator({ enableNew })\n\n return {\n wrapper: wrapper({ className }),\n logoLink: logoLink(),\n tenantInfo: tenantInfoStyle(),\n tenantNameText: tenantNameText(),\n actions: actions(),\n }\n }, [enableNew, className])\n\n return (\n <Cluster\n {...rest}\n as=\"header\"\n justify=\"space-between\"\n gap={COMMON_GAP}\n className={classNames.wrapper}\n >\n <Cluster align=\"center\" gap={COMMON_GAP}>\n <LogoLink href={logoHref} enableNew={enableNew} className={classNames.logoLink}>\n {logo}\n </LogoLink>\n {enableNew ? (\n <MemoizedAppLauncher featureName={featureName} apps={apps} enableNew={enableNew} />\n ) : (\n <TenantSwitcher\n currentTenantId={currentTenantId}\n tenants={tenants}\n classNames={classNames}\n onTenantSelect={onTenantSelect}\n />\n )}\n </Cluster>\n <Cluster align=\"center\" justify=\"flex-end\" gap={CHILDREN_GAP} className={classNames.actions}>\n {children}\n </Cluster>\n </Cluster>\n )\n}\n\nconst LogoLink = memo<\n Pick<Props, 'enableNew'> & { children: Props['logo']; href: Props['logoHref']; className: string }\n>(({ children, href, enableNew, className }) => (\n <a href={href || '/'} className={className}>\n {children || <SmartHRLogo fill={enableNew ? 'brand' : undefined} className=\"shr-p-0.75\" />}\n </a>\n))\n\nconst MemoizedAppLauncher = memo<Pick<Props, 'featureName' | 'apps' | 'enableNew'>>(\n ({ featureName, apps = [], enableNew }) =>\n featureName && <AppLauncher apps={apps} enableNew={enableNew} triggerLabel={featureName} />,\n)\n\nconst TenantSwitcher = memo<\n Pick<Props, 'currentTenantId' | 'tenants' | 'onTenantSelect'> & {\n classNames: { tenantInfo: string; tenantNameText: string }\n }\n>(({ currentTenantId, tenants, classNames, onTenantSelect }) => {\n const currentTenantName = useMemo(() => {\n if (tenants && tenants.length >= 1) {\n const current = tenants.find(({ id }) => id === currentTenantId)\n\n return current ? current.name : tenants[0].name\n }\n\n return undefined\n }, [currentTenantId, tenants])\n\n return (\n currentTenantName && (\n <div className={classNames.tenantInfo}>\n {tenants && tenants.length > 1 ? (\n <MultiTenantDropdownMenuButton\n trigger={currentTenantName}\n tenants={tenants}\n onTenantSelect={onTenantSelect}\n />\n ) : (\n <Text color=\"TEXT_WHITE\" className={classNames.tenantNameText}>\n {currentTenantName}\n </Text>\n )}\n </div>\n )\n )\n})\n\nconst MultiTenantDropdownMenuButton = memo<\n Pick<Required<Props>, 'tenants'> & Pick<Props, 'onTenantSelect'> & { trigger: ReactNode }\n>(({ trigger, tenants, onTenantSelect }) => {\n const onClick = useMemo(\n () =>\n onTenantSelect\n ? (e: MouseEvent<HTMLButtonElement>) => {\n onTenantSelect(e.currentTarget.value)\n }\n : undefined,\n [onTenantSelect],\n )\n\n return (\n <HeaderDropdownMenuButton trigger={trigger}>\n {tenants.map(({ id, name }) => (\n <Button key={id} value={id} onClick={onClick}>\n {name}\n </Button>\n ))}\n </HeaderDropdownMenuButton>\n )\n})\n"],"names":["tv","_jsxs","_jsx"],"mappings":";;;;;;;;;;;;;;;;;AAoBA,MAAM,kBAAkB,GAAGA,EAAE,CAAC;AAC5B,IAAA,KAAK,EAAE;AACL,QAAA,OAAO,EAAE,CAAC,mBAAmB,EAAE,0BAA0B,EAAE,oBAAoB,CAAC;AAChF,QAAA,QAAQ,EAAE;YACR,4BAA4B;;YAE5B,cAAc;YACd,mCAAmC;AACpC,SAAA;AACD,QAAA,UAAU,EAAE,CAAC,8BAA8B,EAAE,aAAa,CAAC;AAC3D,QAAA,cAAc,EAAE,aAAa;AAC7B,QAAA,OAAO,EAAE,CAAC,2BAA2B,EAAE,aAAa,CAAC;AACtD,KAAA;AACD,IAAA,QAAQ,EAAE;AACR,QAAA,SAAS,EAAE;AACT,YAAA,IAAI,EAAE;AACJ,gBAAA,OAAO,EAAE;oBACP,2HAA2H;AAC5H,iBAAA;AACD,gBAAA,QAAQ,EAAE,EAAE;AACZ,gBAAA,UAAU,EAAE,EAAE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OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,MACxBA,IAAC,MAAM,EAAA,EAAU,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAA,QAAA,EACzC,IAAI,IADM,EAAE,CAEN,CACV,CAAC,EAAA,CACuB;AAE/B,CAAC,CAAC;;;;"}
|
|
@@ -3,9 +3,17 @@
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var index = require('./../../vendor/.pnpm/tailwind-variants@0.3.1_tailwindcss@3.4.19_ts-node@10.9.2_@swc_core@1.15.17_@types_node@20.19.35_typescript@5.9.3__/vendor/tailwind-variants/dist/index.cjs');
|
|
6
|
-
|
|
6
|
+
require('../../themes/createSpacing.cjs');
|
|
7
7
|
var themes_createFontSize = require('../../themes/createFontSize.cjs');
|
|
8
8
|
var themes_createColor = require('../../themes/createColor.cjs');
|
|
9
|
+
var themes_createTextColor = require('../../themes/createTextColor.cjs');
|
|
10
|
+
require('styled-components');
|
|
11
|
+
require('../../_virtual/index.cjs');
|
|
12
|
+
require('../../_virtual/index2.cjs');
|
|
13
|
+
require('../../themes/createShadow/defaultShadow.cjs');
|
|
14
|
+
require('../../themes/createWidth.cjs');
|
|
15
|
+
require('../../themes/createBackgroundColor.cjs');
|
|
16
|
+
require('../../themes/createBorder.cjs');
|
|
9
17
|
var components_VisuallyHiddenText_VisuallyHiddenText = require('../VisuallyHiddenText/VisuallyHiddenText.cjs');
|
|
10
18
|
|
|
11
19
|
const colorSet = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateIcon.cjs","sources":["../../../src/components/Icon/generateIcon.tsx"],"sourcesContent":["import { type ComponentProps, type ReactNode, memo, useMemo } from 'react'\nimport { tv } from 'tailwind-variants'\n\nimport { color as defaultColorPalette, fontSize, textColor } from '../../tailwind'\nimport { VisuallyHiddenText } from '../VisuallyHiddenText'\n\nimport type { FontSizes } from '../../themes'\nimport type { IconType } from 'react-icons'\n\n/**\n * literal union type に補完を効かせるためのハック\n * https://github.com/microsoft/TypeScript/issues/29729\n */\ntype LiteralUnion<T extends U, U = string> = T | (U & Record<never, never>)\n\nexport const colorSet = {\n TEXT_BLACK: 'black',\n TEXT_WHITE: 'white',\n TEXT_GREY: 'grey',\n TEXT_DISABLED: 'disabled',\n TEXT_LINK: 'link',\n MAIN: 'main',\n DANGER: 'danger',\n WARNING: 'warning-yellow',\n BRAND: 'brand',\n} as const\n\nconst existsColor = (color: string): color is keyof typeof colorSet => color in colorSet\n\ntype IconProps = {\n /**\n * アイコンの色\n * @type string | 'TEXT_BLACK' | 'TEXT_GREY' | 'TEXT_DISABLED' | 'TEXT_LINK' | 'MAIN' | 'DANGER' | 'WARNING' | 'BRAND'\n */\n color?: LiteralUnion<keyof typeof colorSet>\n /**\n * アイコンの大きさ(フォントサイズの抽象値)\n * @deprecated 親要素やデフォルトフォントサイズが継承されるため固定値の指定は非推奨\n */\n size?: FontSizes\n}\n\ntype AbstractProps = {\n /**アイコンの説明テキスト*/\n alt?: ReactNode\n}\nexport type Props = AbstractProps &\n Omit<IconProps & Omit<ComponentProps<'svg'>, keyof IconProps>, keyof AbstractProps>\n\n// HINT: smarthr-ui-Icon-extendedはアイコン+α(例えば複数のアイコンをまとめて一つにしているなど)を表すclass\n// altなどもVisuallyHiddenTextで表現している関係上、squareの計算などの際に複数要素として判断されると認知と違う結果になるため使用しています\n\nconst classNameGenerator = tv({\n slots: {\n icon: 'smarthr-ui-Icon group-[]/iconWrapper:shr-shrink-0 group-[]/iconWrapper:shr-translate-y-[0.125em] forced-colors:shr-fill-[CanvasText]',\n wrapperWithAlt: 'smarthr-ui-Icon-extended smarthr-ui-Icon-withAlt shr-relative shr-leading-[0]',\n },\n})\n\nexport const generateIcon = (SvgIcon: IconType) => {\n const Icon = memo<Props>(\n ({\n color,\n className,\n role = 'img',\n alt,\n 'aria-hidden': ariaHidden,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby,\n focusable = false,\n size,\n ...rest\n }) => {\n const actualAriaHidden = useMemo(() => {\n if (ariaHidden !== undefined) {\n return ariaHidden\n }\n\n if (alt !== undefined || (ariaLabel === undefined && ariaLabelledby === undefined)) {\n return true\n }\n\n return undefined\n }, [ariaHidden, alt, ariaLabel, ariaLabelledby])\n\n const classNames = useMemo(() => {\n const { icon, wrapperWithAlt } = classNameGenerator()\n\n return {\n icon: icon({ className }),\n wrapperWithAlt: wrapperWithAlt(),\n }\n }, [className])\n\n const replacedColor = useMemo(() => {\n if (color && existsColor(color)) {\n const colorName = colorSet[color]\n\n if (colorName in textColor) {\n return textColor[colorName as keyof typeof textColor]\n }\n\n return defaultColorPalette[colorName as keyof typeof defaultColorPalette] as string\n }\n\n return color\n }, [color])\n\n const iconSize = size ? fontSize[size] : '1em' // 指定がない場合は親要素のフォントサイズを継承する\n const svgIcon = (\n <SvgIcon\n {...rest}\n stroke=\"currentColor\"\n fill=\"currentColor\"\n strokeWidth=\"0\"\n // size は react-icons のアイコンの大きさ、width / height は自前で SVG からアイコンを作る場合の大きさ指定\n size={iconSize}\n width={iconSize}\n height={iconSize}\n color={replacedColor}\n className={classNames.icon}\n role={role}\n aria-hidden={actualAriaHidden}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n focusable={focusable}\n />\n )\n\n if (alt) {\n return (\n // HINT: VisuallyHiddenTextが存在すると、アイコンなのに2つの要素がある状態になってしまい\n // styleなどを記述する際、意図しない状態になる場合がある\n // 回避するため、spanでラップし、開発者のメンタルモデルに合わせる\n <span className={classNames.wrapperWithAlt}>\n <VisuallyHiddenText>{alt}</VisuallyHiddenText>\n {svgIcon}\n </span>\n )\n }\n\n return svgIcon\n },\n )\n\n Icon.displayName = SvgIcon.name\n\n return Icon\n}\n"],"names":["tv","memo","useMemo","textColor","defaultColorPalette","fontSize","_jsx","_jsxs","VisuallyHiddenText"],"mappings":"
|
|
1
|
+
{"version":3,"file":"generateIcon.cjs","sources":["../../../src/components/Icon/generateIcon.tsx"],"sourcesContent":["import { type ComponentProps, type ReactNode, memo, useMemo } from 'react'\nimport { tv } from 'tailwind-variants'\n\nimport { color as defaultColorPalette, fontSize, textColor } from '../../tailwind'\nimport { VisuallyHiddenText } from '../VisuallyHiddenText'\n\nimport type { FontSizes } from '../../themes'\nimport type { IconType } from 'react-icons'\n\n/**\n * literal union type に補完を効かせるためのハック\n * https://github.com/microsoft/TypeScript/issues/29729\n */\ntype LiteralUnion<T extends U, U = string> = T | (U & Record<never, never>)\n\nexport const colorSet = {\n TEXT_BLACK: 'black',\n TEXT_WHITE: 'white',\n TEXT_GREY: 'grey',\n TEXT_DISABLED: 'disabled',\n TEXT_LINK: 'link',\n MAIN: 'main',\n DANGER: 'danger',\n WARNING: 'warning-yellow',\n BRAND: 'brand',\n} as const\n\nconst existsColor = (color: string): color is keyof typeof colorSet => color in colorSet\n\ntype IconProps = {\n /**\n * アイコンの色\n * @type string | 'TEXT_BLACK' | 'TEXT_GREY' | 'TEXT_DISABLED' | 'TEXT_LINK' | 'MAIN' | 'DANGER' | 'WARNING' | 'BRAND'\n */\n color?: LiteralUnion<keyof typeof colorSet>\n /**\n * アイコンの大きさ(フォントサイズの抽象値)\n * @deprecated 親要素やデフォルトフォントサイズが継承されるため固定値の指定は非推奨\n */\n size?: FontSizes\n}\n\ntype AbstractProps = {\n /**アイコンの説明テキスト*/\n alt?: ReactNode\n}\nexport type Props = AbstractProps &\n Omit<IconProps & Omit<ComponentProps<'svg'>, keyof IconProps>, keyof AbstractProps>\n\n// HINT: smarthr-ui-Icon-extendedはアイコン+α(例えば複数のアイコンをまとめて一つにしているなど)を表すclass\n// altなどもVisuallyHiddenTextで表現している関係上、squareの計算などの際に複数要素として判断されると認知と違う結果になるため使用しています\n\nconst classNameGenerator = tv({\n slots: {\n icon: 'smarthr-ui-Icon group-[]/iconWrapper:shr-shrink-0 group-[]/iconWrapper:shr-translate-y-[0.125em] forced-colors:shr-fill-[CanvasText]',\n wrapperWithAlt: 'smarthr-ui-Icon-extended smarthr-ui-Icon-withAlt shr-relative shr-leading-[0]',\n },\n})\n\nexport const generateIcon = (SvgIcon: IconType) => {\n const Icon = memo<Props>(\n ({\n color,\n className,\n role = 'img',\n alt,\n 'aria-hidden': ariaHidden,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby,\n focusable = false,\n size,\n ...rest\n }) => {\n const actualAriaHidden = useMemo(() => {\n if (ariaHidden !== undefined) {\n return ariaHidden\n }\n\n if (alt !== undefined || (ariaLabel === undefined && ariaLabelledby === undefined)) {\n return true\n }\n\n return undefined\n }, [ariaHidden, alt, ariaLabel, ariaLabelledby])\n\n const classNames = useMemo(() => {\n const { icon, wrapperWithAlt } = classNameGenerator()\n\n return {\n icon: icon({ className }),\n wrapperWithAlt: wrapperWithAlt(),\n }\n }, [className])\n\n const replacedColor = useMemo(() => {\n if (color && existsColor(color)) {\n const colorName = colorSet[color]\n\n if (colorName in textColor) {\n return textColor[colorName as keyof typeof textColor]\n }\n\n return defaultColorPalette[colorName as keyof typeof defaultColorPalette] as string\n }\n\n return color\n }, [color])\n\n const iconSize = size ? fontSize[size] : '1em' // 指定がない場合は親要素のフォントサイズを継承する\n const svgIcon = (\n <SvgIcon\n {...rest}\n stroke=\"currentColor\"\n fill=\"currentColor\"\n strokeWidth=\"0\"\n // size は react-icons のアイコンの大きさ、width / height は自前で SVG からアイコンを作る場合の大きさ指定\n size={iconSize}\n width={iconSize}\n height={iconSize}\n color={replacedColor}\n className={classNames.icon}\n role={role}\n aria-hidden={actualAriaHidden}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n focusable={focusable}\n />\n )\n\n if (alt) {\n return (\n // HINT: VisuallyHiddenTextが存在すると、アイコンなのに2つの要素がある状態になってしまい\n // styleなどを記述する際、意図しない状態になる場合がある\n // 回避するため、spanでラップし、開発者のメンタルモデルに合わせる\n <span className={classNames.wrapperWithAlt}>\n <VisuallyHiddenText>{alt}</VisuallyHiddenText>\n {svgIcon}\n </span>\n )\n }\n\n return svgIcon\n },\n )\n\n Icon.displayName = SvgIcon.name\n\n return Icon\n}\n"],"names":["tv","memo","useMemo","textColor","defaultColorPalette","fontSize","_jsx","_jsxs","VisuallyHiddenText"],"mappings":";;;;;;;;;;;;;;;;;;AAeO,MAAM,QAAQ,GAAG;AACtB,IAAA,UAAU,EAAE,OAAO;AACnB,IAAA,UAAU,EAAE,OAAO;AACnB,IAAA,SAAS,EAAE,MAAM;AACjB,IAAA,aAAa,EAAE,UAAU;AACzB,IAAA,SAAS,EAAE,MAAM;AACjB,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,MAAM,EAAE,QAAQ;AAChB,IAAA,OAAO,EAAE,gBAAgB;AACzB,IAAA,KAAK,EAAE,OAAO;;AAGhB,MAAM,WAAW,GAAG,CAAC,KAAa,KAAqC,KAAK,IAAI,QAAQ;AAsBxF;AACA;AAEA,MAAM,kBAAkB,GAAGA,QAAE,CAAC;AAC5B,IAAA,KAAK,EAAE;AACL,QAAA,IAAI,EAAE,sIAAsI;AAC5I,QAAA,cAAc,EAAE,+EAA+E;AAChG,KAAA;AACF,CAAA,CAAC;AAEK,MAAM,YAAY,GAAG,CAAC,OAAiB,KAAI;AAChD,IAAA,MAAM,IAAI,GAAGC,UAAI,CACf,CAAC,EACC,KAAK,EACL,SAAS,EACT,IAAI,GAAG,KAAK,EACZ,GAAG,EACH,aAAa,EAAE,UAAU,EACzB,YAAY,EAAE,SAAS,EACvB,iBAAiB,EAAE,cAAc,EACjC,SAAS,GAAG,KAAK,EACjB,IAAI,EACJ,GAAG,IAAI,EACR,KAAI;AACH,QAAA,MAAM,gBAAgB,GAAGC,aAAO,CAAC,MAAK;AACpC,YAAA,IAAI,UAAU,KAAK,SAAS,EAAE;AAC5B,gBAAA,OAAO,UAAU;YACnB;AAEA,YAAA,IAAI,GAAG,KAAK,SAAS,KAAK,SAAS,KAAK,SAAS,IAAI,cAAc,KAAK,SAAS,CAAC,EAAE;A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SAAS,EAAA,iBAAA,EACJ,cAAc,EAC/B,SAAS,EAAE,SAAS,EAAA,CACpB,CACH;QAED,IAAI,GAAG,EAAE;YACP;;;;AAIE,YAAAC,eAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAE,UAAU,CAAC,cAAc,EAAA,QAAA,EAAA,CACxCD,cAAA,CAACE,mEAAkB,EAAA,EAAA,QAAA,EAAE,GAAG,EAAA,CAAsB,EAC7C,OAAO,CAAA,EAAA,CACH;QAEX;AAEA,QAAA,OAAO,OAAO;AAChB,IAAA,CAAC,CACF;AAED,IAAA,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,IAAI;AAE/B,IAAA,OAAO,IAAI;AACb;;;;;"}
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import { memo, useMemo } from 'react';
|
|
3
3
|
import { tv as ce } from './../../vendor/.pnpm/tailwind-variants@0.3.1_tailwindcss@3.4.19_ts-node@10.9.2_@swc_core@1.15.17_@types_node@20.19.35_typescript@5.9.3__/vendor/tailwind-variants/dist/index.js';
|
|
4
|
-
import
|
|
4
|
+
import '../../themes/createSpacing.js';
|
|
5
5
|
import { defaultFontSize } from '../../themes/createFontSize.js';
|
|
6
6
|
import { defaultColor } from '../../themes/createColor.js';
|
|
7
|
+
import { defaultTextColor } from '../../themes/createTextColor.js';
|
|
8
|
+
import 'styled-components';
|
|
9
|
+
import '../../_virtual/index.js';
|
|
10
|
+
import '../../_virtual/index2.js';
|
|
11
|
+
import '../../themes/createShadow/defaultShadow.js';
|
|
12
|
+
import '../../themes/createWidth.js';
|
|
13
|
+
import '../../themes/createBackgroundColor.js';
|
|
14
|
+
import '../../themes/createBorder.js';
|
|
7
15
|
import { VisuallyHiddenText } from '../VisuallyHiddenText/VisuallyHiddenText.js';
|
|
8
16
|
|
|
9
17
|
const colorSet = {
|