smarthr-ui 97.0.0 → 98.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.
- package/lib/components/AppHeader/components/common/AppLauncherFeatures.cjs +1 -1
- package/lib/components/AppHeader/components/common/AppLauncherFeatures.js +1 -1
- package/lib/components/AppHeader/components/common/AppLauncherSortDropdown.cjs +1 -1
- package/lib/components/AppHeader/components/common/AppLauncherSortDropdown.js +1 -1
- package/lib/components/AppHeader/components/desktop/AppLauncher.cjs +5 -5
- package/lib/components/AppHeader/components/desktop/AppLauncher.cjs.map +1 -1
- package/lib/components/AppHeader/components/desktop/AppLauncher.js +5 -5
- package/lib/components/AppHeader/components/desktop/AppLauncher.js.map +1 -1
- package/lib/components/AppHeader/components/desktop/DesktopHeader.cjs +1 -1
- package/lib/components/AppHeader/components/desktop/DesktopHeader.js +1 -1
- package/lib/components/AppHeader/components/desktop/ReleaseNotesDropdown.cjs +1 -1
- package/lib/components/AppHeader/components/desktop/ReleaseNotesDropdown.js +1 -1
- package/lib/components/AppHeader/components/desktop/UserInfo.cjs +1 -1
- package/lib/components/AppHeader/components/desktop/UserInfo.js +1 -1
- package/lib/components/AppHeader/components/mobile/AppLauncher.cjs +1 -1
- package/lib/components/AppHeader/components/mobile/AppLauncher.js +1 -1
- package/lib/components/AppHeader/components/mobile/AppLauncherFilterDropdown.cjs +1 -1
- package/lib/components/AppHeader/components/mobile/AppLauncherFilterDropdown.js +1 -1
- package/lib/components/AppHeader/components/mobile/Help.cjs +1 -1
- package/lib/components/AppHeader/components/mobile/Help.js +1 -1
- package/lib/components/AppHeader/components/mobile/LanguageSelector.cjs +1 -1
- package/lib/components/AppHeader/components/mobile/LanguageSelector.js +1 -1
- package/lib/components/AppHeader/components/mobile/Menu.cjs +1 -1
- package/lib/components/AppHeader/components/mobile/Menu.js +1 -1
- package/lib/components/AppHeader/components/mobile/MenuAccordion.cjs +1 -1
- package/lib/components/AppHeader/components/mobile/MenuAccordion.js +1 -1
- package/lib/components/AppHeader/components/mobile/MenuDialog.cjs +2 -2
- package/lib/components/AppHeader/components/mobile/MenuDialog.js +2 -2
- package/lib/components/AppHeader/components/mobile/MenuSubHeading.cjs +1 -1
- package/lib/components/AppHeader/components/mobile/MenuSubHeading.js +1 -1
- package/lib/components/AppHeader/components/mobile/ReleaseNote.cjs +1 -1
- package/lib/components/AppHeader/components/mobile/ReleaseNote.js +1 -1
- package/lib/components/AppHeader/components/mobile/UserInfo.cjs +2 -2
- package/lib/components/AppHeader/components/mobile/UserInfo.js +2 -2
- package/lib/components/Browser/Browser.cjs +11 -7
- package/lib/components/Browser/Browser.cjs.map +1 -1
- package/lib/components/Browser/Browser.js +12 -8
- package/lib/components/Browser/Browser.js.map +1 -1
- package/lib/components/Calendar/Calendar.cjs +1 -1
- package/lib/components/Calendar/Calendar.js +1 -1
- package/lib/components/Calendar/CalendarTable.cjs +1 -1
- package/lib/components/Calendar/CalendarTable.js +1 -1
- package/lib/components/Calendar/YearPicker.cjs +1 -1
- package/lib/components/Calendar/YearPicker.js +1 -1
- package/lib/components/Combobox/ItemButton.cjs +27 -26
- package/lib/components/Combobox/ItemButton.cjs.map +1 -1
- package/lib/components/Combobox/ItemButton.js +28 -27
- package/lib/components/Combobox/ItemButton.js.map +1 -1
- package/lib/components/Combobox/MultiCombobox/MultiCombobox.cjs +122 -134
- package/lib/components/Combobox/MultiCombobox/MultiCombobox.cjs.map +1 -1
- package/lib/components/Combobox/MultiCombobox/MultiCombobox.js +123 -135
- package/lib/components/Combobox/MultiCombobox/MultiCombobox.js.map +1 -1
- package/lib/components/Combobox/MultiCombobox/MultiSelectedItem.cjs +1 -1
- package/lib/components/Combobox/MultiCombobox/MultiSelectedItem.js +1 -1
- package/lib/components/Combobox/SingleCombobox/SingleCombobox.cjs +79 -46
- package/lib/components/Combobox/SingleCombobox/SingleCombobox.cjs.map +1 -1
- package/lib/components/Combobox/SingleCombobox/SingleCombobox.js +81 -48
- package/lib/components/Combobox/SingleCombobox/SingleCombobox.js.map +1 -1
- package/lib/components/Combobox/useListbox.cjs +1 -1
- package/lib/components/Combobox/useListbox.js +1 -1
- package/lib/components/Combobox/useOptions.cjs +3 -1
- package/lib/components/Combobox/useOptions.cjs.map +1 -1
- package/lib/components/Combobox/useOptions.js +4 -2
- package/lib/components/Combobox/useOptions.js.map +1 -1
- package/lib/components/Dialog/ControlledActionDialog/ActionDialogContentInner.cjs +3 -3
- package/lib/components/Dialog/ControlledActionDialog/ActionDialogContentInner.cjs.map +1 -1
- package/lib/components/Dialog/ControlledActionDialog/ActionDialogContentInner.js +3 -3
- package/lib/components/Dialog/ControlledActionDialog/ActionDialogContentInner.js.map +1 -1
- package/lib/components/Dialog/ControlledFormDialog/FormDialogContentInner.cjs +3 -3
- package/lib/components/Dialog/ControlledFormDialog/FormDialogContentInner.cjs.map +1 -1
- package/lib/components/Dialog/ControlledFormDialog/FormDialogContentInner.js +3 -3
- package/lib/components/Dialog/ControlledFormDialog/FormDialogContentInner.js.map +1 -1
- package/lib/components/Dialog/ControlledMessageDialog/MessageDialogContentInner.cjs +1 -1
- package/lib/components/Dialog/ControlledMessageDialog/MessageDialogContentInner.js +1 -1
- package/lib/components/Dialog/ControlledStepFormDialog/ControlledStepFormDialog.cjs +1 -1
- package/lib/components/Dialog/ControlledStepFormDialog/ControlledStepFormDialog.js +1 -1
- package/lib/components/Dialog/ControlledStepFormDialog/StepFormDialogContentInner.cjs +2 -2
- package/lib/components/Dialog/ControlledStepFormDialog/StepFormDialogContentInner.cjs.map +1 -1
- package/lib/components/Dialog/ControlledStepFormDialog/StepFormDialogContentInner.js +2 -2
- package/lib/components/Dialog/ControlledStepFormDialog/StepFormDialogContentInner.js.map +1 -1
- package/lib/components/Dialog/DialogContentResponseStatusMessage.cjs +3 -8
- package/lib/components/Dialog/DialogContentResponseStatusMessage.cjs.map +1 -1
- package/lib/components/Dialog/DialogContentResponseStatusMessage.d.ts +1 -1
- package/lib/components/Dialog/DialogContentResponseStatusMessage.js +3 -8
- package/lib/components/Dialog/DialogContentResponseStatusMessage.js.map +1 -1
- package/lib/components/Dialog/FocusTrap.cjs +4 -1
- package/lib/components/Dialog/FocusTrap.cjs.map +1 -1
- package/lib/components/Dialog/FocusTrap.js +4 -1
- package/lib/components/Dialog/FocusTrap.js.map +1 -1
- package/lib/components/Dialog/ModelessDialog/ModelessDialog.cjs +1 -1
- package/lib/components/Dialog/ModelessDialog/ModelessDialog.js +1 -1
- package/lib/components/Dialog/RemoteDialogTrigger/RemoteDialogTrigger.cjs +9 -3
- package/lib/components/Dialog/RemoteDialogTrigger/RemoteDialogTrigger.cjs.map +1 -1
- package/lib/components/Dialog/RemoteDialogTrigger/RemoteDialogTrigger.js +9 -3
- package/lib/components/Dialog/RemoteDialogTrigger/RemoteDialogTrigger.js.map +1 -1
- package/lib/components/Disclosure/DisclosureTrigger.cjs +8 -4
- package/lib/components/Disclosure/DisclosureTrigger.cjs.map +1 -1
- package/lib/components/Disclosure/DisclosureTrigger.js +8 -4
- package/lib/components/Disclosure/DisclosureTrigger.js.map +1 -1
- package/lib/components/DropZone/DropZone.cjs +1 -1
- package/lib/components/DropZone/DropZone.js +1 -1
- package/lib/components/Dropdown/Dropdown.cjs +36 -34
- package/lib/components/Dropdown/Dropdown.cjs.map +1 -1
- package/lib/components/Dropdown/Dropdown.js +37 -35
- package/lib/components/Dropdown/Dropdown.js.map +1 -1
- package/lib/components/Dropdown/DropdownMenuButton/DropdownMenuButton.cjs +1 -1
- package/lib/components/Dropdown/DropdownMenuButton/DropdownMenuButton.js +1 -1
- package/lib/components/Dropdown/FilterDropdown/FilterDropdown.cjs +3 -5
- package/lib/components/Dropdown/FilterDropdown/FilterDropdown.cjs.map +1 -1
- package/lib/components/Dropdown/FilterDropdown/FilterDropdown.d.ts +1 -1
- package/lib/components/Dropdown/FilterDropdown/FilterDropdown.js +3 -5
- package/lib/components/Dropdown/FilterDropdown/FilterDropdown.js.map +1 -1
- package/lib/components/Dropdown/SortDropdown/useSortDropdown.cjs +1 -1
- package/lib/components/Dropdown/SortDropdown/useSortDropdown.js +1 -1
- package/lib/components/ErrorScreen/AuthErrorScreen.cjs +1 -1
- package/lib/components/ErrorScreen/AuthErrorScreen.js +1 -1
- package/lib/components/ErrorScreen/ForbiddenErrorScreen.cjs +1 -1
- package/lib/components/ErrorScreen/ForbiddenErrorScreen.js +1 -1
- package/lib/components/ErrorScreen/NotFoundErrorScreen.cjs +1 -1
- package/lib/components/ErrorScreen/NotFoundErrorScreen.js +1 -1
- package/lib/components/ErrorScreen/UnauthorizedErrorScreen.cjs +1 -1
- package/lib/components/ErrorScreen/UnauthorizedErrorScreen.js +1 -1
- package/lib/components/FileViewer/FileViewer.cjs +35 -2
- package/lib/components/FileViewer/FileViewer.cjs.map +1 -1
- package/lib/components/FileViewer/FileViewer.js +37 -4
- package/lib/components/FileViewer/FileViewer.js.map +1 -1
- package/lib/components/FileViewer/PDFViewer.cjs +59 -2
- package/lib/components/FileViewer/PDFViewer.cjs.map +1 -1
- package/lib/components/FileViewer/PDFViewer.d.ts +6 -1
- package/lib/components/FileViewer/PDFViewer.js +60 -3
- package/lib/components/FileViewer/PDFViewer.js.map +1 -1
- package/lib/components/FileViewer/SearchController.cjs +105 -0
- package/lib/components/FileViewer/SearchController.cjs.map +1 -0
- package/lib/components/FileViewer/SearchController.d.ts +7 -0
- package/lib/components/FileViewer/SearchController.js +103 -0
- package/lib/components/FileViewer/SearchController.js.map +1 -0
- package/lib/components/FileViewer/buildCustomTextRenderer.cjs +55 -0
- package/lib/components/FileViewer/buildCustomTextRenderer.cjs.map +1 -0
- package/lib/components/FileViewer/buildCustomTextRenderer.d.ts +9 -0
- package/lib/components/FileViewer/buildCustomTextRenderer.js +50 -0
- package/lib/components/FileViewer/buildCustomTextRenderer.js.map +1 -0
- package/lib/components/FileViewer/types.d.ts +7 -0
- package/lib/components/FileViewer/usePDFSearch.cjs +148 -0
- package/lib/components/FileViewer/usePDFSearch.cjs.map +1 -0
- package/lib/components/FileViewer/usePDFSearch.d.ts +19 -0
- package/lib/components/FileViewer/usePDFSearch.js +143 -0
- package/lib/components/FileViewer/usePDFSearch.js.map +1 -0
- package/lib/components/FormControl/FormControl.cjs +2 -22
- package/lib/components/FormControl/FormControl.cjs.map +1 -1
- package/lib/components/FormControl/FormControl.js +2 -22
- package/lib/components/FormControl/FormControl.js.map +1 -1
- package/lib/components/Header/AppLauncher/AppLauncher.cjs +1 -1
- package/lib/components/Header/AppLauncher/AppLauncher.js +1 -1
- package/lib/components/Header/LanguageSwitcher/LanguageSwitcher.cjs +1 -1
- package/lib/components/Header/LanguageSwitcher/LanguageSwitcher.js +1 -1
- package/lib/components/Icon/FaIcon.js +1 -1
- package/lib/components/Icon/OpenInNewTabIcon.cjs +1 -1
- package/lib/components/Icon/OpenInNewTabIcon.js +1 -1
- package/lib/components/InformationPanel/InformationPanel.cjs +1 -1
- package/lib/components/InformationPanel/InformationPanel.js +1 -1
- package/lib/components/Input/SearchInput/SearchInputIcon.cjs +1 -1
- package/lib/components/Input/SearchInput/SearchInputIcon.js +1 -1
- package/lib/components/InputFile/InputFileMultiplyAppendable.cjs +1 -1
- package/lib/components/InputFile/InputFileMultiplyAppendable.js +1 -1
- package/lib/components/InputFile/InputFileNative.cjs +1 -1
- package/lib/components/InputFile/InputFileNative.js +1 -1
- package/lib/components/Layout/Cluster/Cluster.cjs +0 -1
- package/lib/components/Layout/Cluster/Cluster.cjs.map +1 -1
- package/lib/components/Layout/Cluster/Cluster.js +0 -1
- package/lib/components/Layout/Cluster/Cluster.js.map +1 -1
- package/lib/components/Layout/Container/Container.cjs +1 -5
- package/lib/components/Layout/Container/Container.cjs.map +1 -1
- package/lib/components/Layout/Container/Container.js +1 -5
- package/lib/components/Layout/Container/Container.js.map +1 -1
- package/lib/components/Layout/Stack/Stack.cjs +22 -22
- package/lib/components/Layout/Stack/Stack.cjs.map +1 -1
- package/lib/components/Layout/Stack/Stack.js +22 -22
- package/lib/components/Layout/Stack/Stack.js.map +1 -1
- package/lib/components/Loader/LoaderSpinner.cjs +1 -1
- package/lib/components/Loader/LoaderSpinner.js +1 -1
- package/lib/components/Pagination/Pagination.cjs +1 -1
- package/lib/components/Pagination/Pagination.js +1 -1
- package/lib/components/Pagination/PaginationItemButton.cjs +1 -1
- package/lib/components/Pagination/PaginationItemButton.js +1 -1
- package/lib/components/SideNav/SideNav.cjs +3 -22
- package/lib/components/SideNav/SideNav.cjs.map +1 -1
- package/lib/components/SideNav/SideNav.d.ts +2 -9
- package/lib/components/SideNav/SideNav.js +4 -23
- package/lib/components/SideNav/SideNav.js.map +1 -1
- package/lib/components/SideNav/SideNavContext.cjs +11 -0
- package/lib/components/SideNav/SideNavContext.cjs.map +1 -0
- package/lib/components/SideNav/SideNavContext.d.ts +7 -0
- package/lib/components/SideNav/SideNavContext.js +8 -0
- package/lib/components/SideNav/SideNavContext.js.map +1 -0
- package/lib/components/SideNav/SideNavItemButton.cjs +12 -7
- package/lib/components/SideNav/SideNavItemButton.cjs.map +1 -1
- package/lib/components/SideNav/SideNavItemButton.d.ts +5 -11
- package/lib/components/SideNav/SideNavItemButton.js +12 -7
- package/lib/components/SideNav/SideNavItemButton.js.map +1 -1
- package/lib/components/Table/Th.cjs +2 -2
- package/lib/components/Table/Th.cjs.map +1 -1
- package/lib/components/Table/Th.d.ts +0 -2
- package/lib/components/Table/Th.js +2 -2
- package/lib/components/Table/Th.js.map +1 -1
- package/lib/components/Table/ThCheckbox.cjs +1 -1
- package/lib/components/Table/ThCheckbox.js +1 -1
- package/lib/components/Table/ThSortButton.cjs +5 -6
- package/lib/components/Table/ThSortButton.cjs.map +1 -1
- package/lib/components/Table/ThSortButton.d.ts +1 -6
- package/lib/components/Table/ThSortButton.js +5 -6
- package/lib/components/Table/ThSortButton.js.map +1 -1
- package/lib/components/WarekiPicker/WarekiPicker.cjs +1 -1
- package/lib/components/WarekiPicker/WarekiPicker.js +1 -1
- package/lib/hooks/useLatest.cjs +33 -0
- package/lib/hooks/useLatest.cjs.map +1 -0
- package/lib/hooks/useLatest.d.ts +19 -0
- package/lib/hooks/useLatest.js +31 -0
- package/lib/hooks/useLatest.js.map +1 -0
- package/lib/index.cjs +1 -6
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.js +1 -4
- package/lib/index.js.map +1 -1
- package/lib/intl/Localizer.cjs +5 -1
- package/lib/intl/Localizer.cjs.map +1 -1
- package/lib/intl/Localizer.d.ts +1 -1
- package/lib/intl/Localizer.js +5 -1
- package/lib/intl/Localizer.js.map +1 -1
- package/lib/intl/locales/en_us.json.cjs +3 -0
- package/lib/intl/locales/en_us.json.cjs.map +1 -1
- package/lib/intl/locales/en_us.json.js +3 -0
- package/lib/intl/locales/en_us.json.js.map +1 -1
- package/lib/intl/locales/id_id.json.cjs +3 -0
- package/lib/intl/locales/id_id.json.cjs.map +1 -1
- package/lib/intl/locales/id_id.json.js +3 -0
- package/lib/intl/locales/id_id.json.js.map +1 -1
- package/lib/intl/locales/index.d.ts +27 -0
- package/lib/intl/locales/ja.cjs +3 -0
- package/lib/intl/locales/ja.cjs.map +1 -1
- package/lib/intl/locales/ja.d.ts +3 -0
- package/lib/intl/locales/ja.js +3 -0
- package/lib/intl/locales/ja.js.map +1 -1
- package/lib/intl/locales/ja.json.cjs +3 -0
- package/lib/intl/locales/ja.json.cjs.map +1 -1
- package/lib/intl/locales/ja.json.js +3 -0
- package/lib/intl/locales/ja.json.js.map +1 -1
- package/lib/intl/locales/ja_easy.json.cjs +3 -0
- package/lib/intl/locales/ja_easy.json.cjs.map +1 -1
- package/lib/intl/locales/ja_easy.json.js +3 -0
- package/lib/intl/locales/ja_easy.json.js.map +1 -1
- package/lib/intl/locales/ko_kr.json.cjs +3 -0
- package/lib/intl/locales/ko_kr.json.cjs.map +1 -1
- package/lib/intl/locales/ko_kr.json.js +3 -0
- package/lib/intl/locales/ko_kr.json.js.map +1 -1
- package/lib/intl/locales/pt_br.json.cjs +3 -0
- package/lib/intl/locales/pt_br.json.cjs.map +1 -1
- package/lib/intl/locales/pt_br.json.js +3 -0
- package/lib/intl/locales/pt_br.json.js.map +1 -1
- package/lib/intl/locales/vi_vn.json.cjs +3 -0
- package/lib/intl/locales/vi_vn.json.cjs.map +1 -1
- package/lib/intl/locales/vi_vn.json.js +3 -0
- package/lib/intl/locales/vi_vn.json.js.map +1 -1
- package/lib/intl/locales/zh_hans_cn.json.cjs +3 -0
- package/lib/intl/locales/zh_hans_cn.json.cjs.map +1 -1
- package/lib/intl/locales/zh_hans_cn.json.js +3 -0
- package/lib/intl/locales/zh_hans_cn.json.js.map +1 -1
- package/lib/intl/locales/zh_hant_tw.json.cjs +3 -0
- package/lib/intl/locales/zh_hant_tw.json.cjs.map +1 -1
- package/lib/intl/locales/zh_hant_tw.json.js +3 -0
- package/lib/intl/locales/zh_hant_tw.json.js.map +1 -1
- package/metadata.json +1 -1
- package/package.json +1 -1
- package/smarthr-ui.css +35 -98
- package/lib/hooks/useDecorators.cjs +0 -18
- package/lib/hooks/useDecorators.cjs.map +0 -1
- package/lib/hooks/useDecorators.d.ts +0 -6
- package/lib/hooks/useDecorators.js +0 -16
- package/lib/hooks/useDecorators.js.map +0 -1
- package/lib/hooks/useDevice/DeviceProvider.cjs +0 -37
- package/lib/hooks/useDevice/DeviceProvider.cjs.map +0 -1
- package/lib/hooks/useDevice/DeviceProvider.d.ts +0 -4
- package/lib/hooks/useDevice/DeviceProvider.js +0 -35
- package/lib/hooks/useDevice/DeviceProvider.js.map +0 -1
- package/lib/hooks/useDevice/index.cjs +0 -10
- package/lib/hooks/useDevice/index.cjs.map +0 -1
- package/lib/hooks/useDevice/index.d.ts +0 -2
- package/lib/hooks/useDevice/index.js +0 -3
- package/lib/hooks/useDevice/index.js.map +0 -1
- package/lib/hooks/useDevice/useDevice.cjs +0 -11
- package/lib/hooks/useDevice/useDevice.cjs.map +0 -1
- package/lib/hooks/useDevice/useDevice.d.ts +0 -4
- package/lib/hooks/useDevice/useDevice.js +0 -8
- package/lib/hooks/useDevice/useDevice.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Browser.cjs","sources":["../../../src/components/Browser/Browser.tsx"],"sourcesContent":["import {\n type ChangeEvent,\n type ComponentProps,\n type FC,\n type KeyboardEventHandler,\n useCallback,\n useMemo,\n} from 'react'\nimport { tv } from 'tailwind-variants'\n\nimport { BrowserColumn } from './BrowserColumn'\nimport { ItemNode, type ItemNodeLike, RootNode } from './models'\nimport { getElementIdFromNode } from './utils'\n\nconst classNameGenerator = tv({\n slots: {\n wrapper: ['smarthr-ui-Browser', 'shr-flex'],\n column: ['shr-min-w-[13em] shr-list-none', '[&_+_&]:shr-border-l-shorthand'],\n },\n variants: {\n maxColumn: {\n 1: {\n column: 'shr-max-w-[theme(width.1/3)]',\n },\n 2: {},\n 3: {},\n },\n },\n compoundVariants: [\n {\n maxColumn: [2, 3],\n className: {\n column: 'last:shr-grow',\n },\n },\n ],\n})\n\ntype AbstractProps = {\n /** 表示する item の配列 */\n items: ItemNodeLike[]\n /** 選択中の item の値 */\n value?: string\n /** 選択された際に呼び出されるコールバック。第一引数に item の value を取る。 */\n onSelectItem?: (value: string) => void\n}\ntype Props = AbstractProps & Omit<ComponentProps<'div'>, keyof AbstractProps>\n\nexport const Browser: FC<Props> = ({ value, items, onSelectItem, className, ...rest }) => {\n const rootNode = useMemo(() => RootNode.from({ children: items }), [items])\n const columns = useMemo(() => rootNode.toViewData(value), [rootNode, value])\n\n const classNames = useMemo(() => {\n const { wrapper, column } = classNameGenerator({ className })\n return {\n wrapper: wrapper(),\n column: column({\n maxColumn: columns.length as 1 | 2 | 3,\n }),\n }\n }, [className, columns.length])\n\n const selectedPath = useMemo(() => {\n if (!value) return []\n const node = rootNode.findByValue(value)\n if (!node) return []\n return [...node.getAncestors().map((n) => n.value), node.value]\n }, [rootNode, value])\n\n const
|
|
1
|
+
{"version":3,"file":"Browser.cjs","sources":["../../../src/components/Browser/Browser.tsx"],"sourcesContent":["import {\n type ChangeEvent,\n type ComponentProps,\n type FC,\n type KeyboardEventHandler,\n useCallback,\n useMemo,\n useRef,\n} from 'react'\nimport { tv } from 'tailwind-variants'\n\nimport { BrowserColumn } from './BrowserColumn'\nimport { ItemNode, type ItemNodeLike, RootNode } from './models'\nimport { getElementIdFromNode } from './utils'\n\nconst classNameGenerator = tv({\n slots: {\n wrapper: ['smarthr-ui-Browser', 'shr-flex'],\n column: ['shr-min-w-[13em] shr-list-none', '[&_+_&]:shr-border-l-shorthand'],\n },\n variants: {\n maxColumn: {\n 1: {\n column: 'shr-max-w-[theme(width.1/3)]',\n },\n 2: {},\n 3: {},\n },\n },\n compoundVariants: [\n {\n maxColumn: [2, 3],\n className: {\n column: 'last:shr-grow',\n },\n },\n ],\n})\n\ntype AbstractProps = {\n /** 表示する item の配列 */\n items: ItemNodeLike[]\n /** 選択中の item の値 */\n value?: string\n /** 選択された際に呼び出されるコールバック。第一引数に item の value を取る。 */\n onSelectItem?: (value: string) => void\n}\ntype Props = AbstractProps & Omit<ComponentProps<'div'>, keyof AbstractProps>\n\nexport const Browser: FC<Props> = ({ value, items, onSelectItem, className, ...rest }) => {\n const rootNode = useMemo(() => RootNode.from({ children: items }), [items])\n const columns = useMemo(() => rootNode.toViewData(value), [rootNode, value])\n\n const classNames = useMemo(() => {\n const { wrapper, column } = classNameGenerator({ className })\n return {\n wrapper: wrapper(),\n column: column({\n maxColumn: columns.length as 1 | 2 | 3,\n }),\n }\n }, [className, columns.length])\n\n const selectedPath = useMemo(() => {\n if (!value) return []\n const node = rootNode.findByValue(value)\n if (!node) return []\n return [...node.getAncestors().map((n) => n.value), node.value]\n }, [rootNode, value])\n\n const unstableRef = useRef({ onSelectItem, value, rootNode })\n unstableRef.current = { onSelectItem, value, rootNode }\n\n // FIXME: focusメソッドのfocusVisibleが主要ブラウザでサポートされたら使うようにしたい(現状ではマウスクリックでもfocusのoutlineが出てしまう)\n // https://developer.mozilla.org/ja/docs/Web/API/HTMLElement/focus\n const onDelegateKeyDown: KeyboardEventHandler = useCallback((e) => {\n const selectedNode = unstableRef.current.value\n ? unstableRef.current.rootNode.findByValue(unstableRef.current.value)\n : undefined\n\n if (!selectedNode) {\n return\n }\n\n let target: ItemNode | undefined = undefined\n\n switch (e.key) {\n case 'ArrowUp': {\n target = selectedNode.getPrev() ?? selectedNode.parent?.getLastChild()\n\n break\n }\n case 'ArrowDown': {\n target = selectedNode.getNext() ?? selectedNode.parent?.getFirstChild()\n\n break\n }\n case 'ArrowLeft': {\n const node = selectedNode.parent\n\n if (node instanceof ItemNode) {\n target = node\n }\n\n break\n }\n case 'ArrowRight':\n case 'Enter':\n case ' ': {\n target = selectedNode.getFirstChild()\n\n break\n }\n }\n\n if (target) {\n e.preventDefault()\n unstableRef.current.onSelectItem?.(target.value)\n document.getElementById(getElementIdFromNode(target.value))?.focus()\n }\n }, [])\n\n const onChangeInput = useCallback((e: ChangeEvent<HTMLInputElement>) => {\n unstableRef.current.onSelectItem?.(e.currentTarget.value)\n }, [])\n\n return (\n // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions\n <div {...rest} role=\"application\" onKeyDown={onDelegateKeyDown} className={classNames.wrapper}>\n {columns.map((colItems, index) => (\n <BrowserColumn\n key={index}\n items={colItems}\n index={index}\n value={selectedPath[index]}\n onChangeInput={onSelectItem ? onChangeInput : undefined}\n className={classNames.column}\n />\n ))}\n </div>\n )\n}\n"],"names":["tv","useMemo","RootNode","useRef","useCallback","ItemNode","getElementIdFromNode","_jsx","BrowserColumn"],"mappings":";;;;;;;;;;AAeA,MAAM,kBAAkB,GAAGA,QAAE,CAAC;AAC5B,IAAA,KAAK,EAAE;AACL,QAAA,OAAO,EAAE,CAAC,oBAAoB,EAAE,UAAU,CAAC;AAC3C,QAAA,MAAM,EAAE,CAAC,gCAAgC,EAAE,gCAAgC,CAAC;AAC7E,KAAA;AACD,IAAA,QAAQ,EAAE;AACR,QAAA,SAAS,EAAE;AACT,YAAA,CAAC,EAAE;AACD,gBAAA,MAAM,EAAE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AE;gBAErC;YACF;;QAGF,IAAI,MAAM,EAAE;YACV,CAAC,CAAC,cAAc,EAAE;YAClB,WAAW,CAAC,OAAO,CAAC,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC;AAChD,YAAA,QAAQ,CAAC,cAAc,CAACC,6CAAoB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE;QACtE;IACF,CAAC,EAAE,EAAE,CAAC;AAEN,IAAA,MAAM,aAAa,GAAGF,iBAAW,CAAC,CAAC,CAAgC,KAAI;AACrE,QAAA,WAAW,CAAC,OAAO,CAAC,YAAY,GAAG,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC;IAC3D,CAAC,EAAE,EAAE,CAAC;IAEN;;AAEE,IAAAG,cAAA,CAAA,KAAA,EAAA,EAAA,GAAS,IAAI,EAAE,IAAI,EAAC,aAAa,EAAC,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,UAAU,CAAC,OAAO,EAAA,QAAA,EAC1F,OAAO,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,KAAK,MAC3BA,cAAA,CAACC,8CAAa,EAAA,EAEZ,KAAK,EAAE,QAAQ,EACf,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,YAAY,CAAC,KAAK,CAAC,EAC1B,aAAa,EAAE,YAAY,GAAG,aAAa,GAAG,SAAS,EACvD,SAAS,EAAE,UAAU,CAAC,MAAM,EAAA,EALvB,KAAK,CAMV,CACH,CAAC,EAAA,CACE;AAEV;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { useMemo, useCallback } from 'react';
|
|
2
|
+
import { useMemo, useRef, useCallback } 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
4
|
import { BrowserColumn } from './BrowserColumn.js';
|
|
5
5
|
import { ItemNode } from './models/ItemNode.js';
|
|
@@ -49,10 +49,14 @@ const Browser = ({ value, items, onSelectItem, className, ...rest }) => {
|
|
|
49
49
|
return [];
|
|
50
50
|
return [...node.getAncestors().map((n) => n.value), node.value];
|
|
51
51
|
}, [rootNode, value]);
|
|
52
|
-
const
|
|
52
|
+
const unstableRef = useRef({ onSelectItem, value, rootNode });
|
|
53
|
+
unstableRef.current = { onSelectItem, value, rootNode };
|
|
53
54
|
// FIXME: focusメソッドのfocusVisibleが主要ブラウザでサポートされたら使うようにしたい(現状ではマウスクリックでもfocusのoutlineが出てしまう)
|
|
54
55
|
// https://developer.mozilla.org/ja/docs/Web/API/HTMLElement/focus
|
|
55
56
|
const onDelegateKeyDown = useCallback((e) => {
|
|
57
|
+
const selectedNode = unstableRef.current.value
|
|
58
|
+
? unstableRef.current.rootNode.findByValue(unstableRef.current.value)
|
|
59
|
+
: undefined;
|
|
56
60
|
if (!selectedNode) {
|
|
57
61
|
return;
|
|
58
62
|
}
|
|
@@ -82,16 +86,16 @@ const Browser = ({ value, items, onSelectItem, className, ...rest }) => {
|
|
|
82
86
|
}
|
|
83
87
|
if (target) {
|
|
84
88
|
e.preventDefault();
|
|
85
|
-
onSelectItem?.(target.value);
|
|
89
|
+
unstableRef.current.onSelectItem?.(target.value);
|
|
86
90
|
document.getElementById(getElementIdFromNode(target.value))?.focus();
|
|
87
91
|
}
|
|
88
|
-
}, [
|
|
89
|
-
const onChangeInput =
|
|
90
|
-
|
|
91
|
-
|
|
92
|
+
}, []);
|
|
93
|
+
const onChangeInput = useCallback((e) => {
|
|
94
|
+
unstableRef.current.onSelectItem?.(e.currentTarget.value);
|
|
95
|
+
}, []);
|
|
92
96
|
return (
|
|
93
97
|
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
|
|
94
|
-
jsx("div", { ...rest, role: "application", onKeyDown: onDelegateKeyDown, className: classNames.wrapper, children: columns.map((colItems, index) => (jsx(BrowserColumn, { items: colItems, index: index, value: selectedPath[index], onChangeInput: onChangeInput, className: classNames.column }, index))) }));
|
|
98
|
+
jsx("div", { ...rest, role: "application", onKeyDown: onDelegateKeyDown, className: classNames.wrapper, children: columns.map((colItems, index) => (jsx(BrowserColumn, { items: colItems, index: index, value: selectedPath[index], onChangeInput: onSelectItem ? onChangeInput : undefined, className: classNames.column }, index))) }));
|
|
95
99
|
};
|
|
96
100
|
|
|
97
101
|
export { Browser };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Browser.js","sources":["../../../src/components/Browser/Browser.tsx"],"sourcesContent":["import {\n type ChangeEvent,\n type ComponentProps,\n type FC,\n type KeyboardEventHandler,\n useCallback,\n useMemo,\n} from 'react'\nimport { tv } from 'tailwind-variants'\n\nimport { BrowserColumn } from './BrowserColumn'\nimport { ItemNode, type ItemNodeLike, RootNode } from './models'\nimport { getElementIdFromNode } from './utils'\n\nconst classNameGenerator = tv({\n slots: {\n wrapper: ['smarthr-ui-Browser', 'shr-flex'],\n column: ['shr-min-w-[13em] shr-list-none', '[&_+_&]:shr-border-l-shorthand'],\n },\n variants: {\n maxColumn: {\n 1: {\n column: 'shr-max-w-[theme(width.1/3)]',\n },\n 2: {},\n 3: {},\n },\n },\n compoundVariants: [\n {\n maxColumn: [2, 3],\n className: {\n column: 'last:shr-grow',\n },\n },\n ],\n})\n\ntype AbstractProps = {\n /** 表示する item の配列 */\n items: ItemNodeLike[]\n /** 選択中の item の値 */\n value?: string\n /** 選択された際に呼び出されるコールバック。第一引数に item の value を取る。 */\n onSelectItem?: (value: string) => void\n}\ntype Props = AbstractProps & Omit<ComponentProps<'div'>, keyof AbstractProps>\n\nexport const Browser: FC<Props> = ({ value, items, onSelectItem, className, ...rest }) => {\n const rootNode = useMemo(() => RootNode.from({ children: items }), [items])\n const columns = useMemo(() => rootNode.toViewData(value), [rootNode, value])\n\n const classNames = useMemo(() => {\n const { wrapper, column } = classNameGenerator({ className })\n return {\n wrapper: wrapper(),\n column: column({\n maxColumn: columns.length as 1 | 2 | 3,\n }),\n }\n }, [className, columns.length])\n\n const selectedPath = useMemo(() => {\n if (!value) return []\n const node = rootNode.findByValue(value)\n if (!node) return []\n return [...node.getAncestors().map((n) => n.value), node.value]\n }, [rootNode, value])\n\n const
|
|
1
|
+
{"version":3,"file":"Browser.js","sources":["../../../src/components/Browser/Browser.tsx"],"sourcesContent":["import {\n type ChangeEvent,\n type ComponentProps,\n type FC,\n type KeyboardEventHandler,\n useCallback,\n useMemo,\n useRef,\n} from 'react'\nimport { tv } from 'tailwind-variants'\n\nimport { BrowserColumn } from './BrowserColumn'\nimport { ItemNode, type ItemNodeLike, RootNode } from './models'\nimport { getElementIdFromNode } from './utils'\n\nconst classNameGenerator = tv({\n slots: {\n wrapper: ['smarthr-ui-Browser', 'shr-flex'],\n column: ['shr-min-w-[13em] shr-list-none', '[&_+_&]:shr-border-l-shorthand'],\n },\n variants: {\n maxColumn: {\n 1: {\n column: 'shr-max-w-[theme(width.1/3)]',\n },\n 2: {},\n 3: {},\n },\n },\n compoundVariants: [\n {\n maxColumn: [2, 3],\n className: {\n column: 'last:shr-grow',\n },\n },\n ],\n})\n\ntype AbstractProps = {\n /** 表示する item の配列 */\n items: ItemNodeLike[]\n /** 選択中の item の値 */\n value?: string\n /** 選択された際に呼び出されるコールバック。第一引数に item の value を取る。 */\n onSelectItem?: (value: string) => void\n}\ntype Props = AbstractProps & Omit<ComponentProps<'div'>, keyof AbstractProps>\n\nexport const Browser: FC<Props> = ({ value, items, onSelectItem, className, ...rest }) => {\n const rootNode = useMemo(() => RootNode.from({ children: items }), [items])\n const columns = useMemo(() => rootNode.toViewData(value), [rootNode, value])\n\n const classNames = useMemo(() => {\n const { wrapper, column } = classNameGenerator({ className })\n return {\n wrapper: wrapper(),\n column: column({\n maxColumn: columns.length as 1 | 2 | 3,\n }),\n }\n }, [className, columns.length])\n\n const selectedPath = useMemo(() => {\n if (!value) return []\n const node = rootNode.findByValue(value)\n if (!node) return []\n return [...node.getAncestors().map((n) => n.value), node.value]\n }, [rootNode, value])\n\n const unstableRef = useRef({ onSelectItem, value, rootNode })\n unstableRef.current = { onSelectItem, value, rootNode }\n\n // FIXME: focusメソッドのfocusVisibleが主要ブラウザでサポートされたら使うようにしたい(現状ではマウスクリックでもfocusのoutlineが出てしまう)\n // https://developer.mozilla.org/ja/docs/Web/API/HTMLElement/focus\n const onDelegateKeyDown: KeyboardEventHandler = useCallback((e) => {\n const selectedNode = unstableRef.current.value\n ? unstableRef.current.rootNode.findByValue(unstableRef.current.value)\n : undefined\n\n if (!selectedNode) {\n return\n }\n\n let target: ItemNode | undefined = undefined\n\n switch (e.key) {\n case 'ArrowUp': {\n target = selectedNode.getPrev() ?? selectedNode.parent?.getLastChild()\n\n break\n }\n case 'ArrowDown': {\n target = selectedNode.getNext() ?? selectedNode.parent?.getFirstChild()\n\n break\n }\n case 'ArrowLeft': {\n const node = selectedNode.parent\n\n if (node instanceof ItemNode) {\n target = node\n }\n\n break\n }\n case 'ArrowRight':\n case 'Enter':\n case ' ': {\n target = selectedNode.getFirstChild()\n\n break\n }\n }\n\n if (target) {\n e.preventDefault()\n unstableRef.current.onSelectItem?.(target.value)\n document.getElementById(getElementIdFromNode(target.value))?.focus()\n }\n }, [])\n\n const onChangeInput = useCallback((e: ChangeEvent<HTMLInputElement>) => {\n unstableRef.current.onSelectItem?.(e.currentTarget.value)\n }, [])\n\n return (\n // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions\n <div {...rest} role=\"application\" onKeyDown={onDelegateKeyDown} className={classNames.wrapper}>\n {columns.map((colItems, index) => (\n <BrowserColumn\n key={index}\n items={colItems}\n index={index}\n value={selectedPath[index]}\n onChangeInput={onSelectItem ? onChangeInput : undefined}\n className={classNames.column}\n />\n ))}\n </div>\n )\n}\n"],"names":["tv","_jsx"],"mappings":";;;;;;;;AAeA,MAAM,kBAAkB,GAAGA,EAAE,CAAC;AAC5B,IAAA,KAAK,EAAE;AAC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ss@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');
|
|
8
8
|
require('../../intl/IntlProvider.cjs');
|
|
9
9
|
var intl_useIntl = require('../../intl/useIntl.cjs');
|
|
10
|
-
require('
|
|
10
|
+
require('../../intl/Localizer.cjs');
|
|
11
11
|
require('../../intl/TimeFormatter.cjs');
|
|
12
12
|
var components_Button_Button = require('../Button/Button.cjs');
|
|
13
13
|
require('../Button/AnchorButton.cjs');
|
|
@@ -5,7 +5,7 @@ import { forwardRef, useMemo, useState, useId, useEffect, useCallback, memo } fr
|
|
|
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 '../../intl/IntlProvider.js';
|
|
7
7
|
import { useIntl } from '../../intl/useIntl.js';
|
|
8
|
-
import '
|
|
8
|
+
import '../../intl/Localizer.js';
|
|
9
9
|
import '../../intl/TimeFormatter.js';
|
|
10
10
|
import { Button } from '../Button/Button.js';
|
|
11
11
|
import '../Button/AnchorButton.js';
|
|
@@ -6,7 +6,7 @@ var React = require('react');
|
|
|
6
6
|
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');
|
|
7
7
|
require('../../intl/IntlProvider.cjs');
|
|
8
8
|
var intl_useIntl = require('../../intl/useIntl.cjs');
|
|
9
|
-
require('
|
|
9
|
+
require('../../intl/Localizer.cjs');
|
|
10
10
|
require('../../intl/TimeFormatter.cjs');
|
|
11
11
|
require('../Button/Button.cjs');
|
|
12
12
|
require('../Button/AnchorButton.cjs');
|
|
@@ -4,7 +4,7 @@ import { memo, useMemo, useCallback } from 'react';
|
|
|
4
4
|
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';
|
|
5
5
|
import '../../intl/IntlProvider.js';
|
|
6
6
|
import { useIntl } from '../../intl/useIntl.js';
|
|
7
|
-
import '
|
|
7
|
+
import '../../intl/Localizer.js';
|
|
8
8
|
import '../../intl/TimeFormatter.js';
|
|
9
9
|
import '../Button/Button.js';
|
|
10
10
|
import '../Button/AnchorButton.js';
|
|
@@ -5,7 +5,7 @@ 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('../../intl/IntlProvider.cjs');
|
|
7
7
|
var intl_useIntl = require('../../intl/useIntl.cjs');
|
|
8
|
-
require('
|
|
8
|
+
require('../../intl/Localizer.cjs');
|
|
9
9
|
require('../../_virtual/dayjs.min.cjs');
|
|
10
10
|
require('../../intl/TimeFormatter.cjs');
|
|
11
11
|
require('../Button/Button.cjs');
|
|
@@ -3,7 +3,7 @@ import { memo, useMemo, useRef, useEffect } 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
4
|
import '../../intl/IntlProvider.js';
|
|
5
5
|
import { useIntl } from '../../intl/useIntl.js';
|
|
6
|
-
import '
|
|
6
|
+
import '../../intl/Localizer.js';
|
|
7
7
|
import '../../_virtual/dayjs.min.js';
|
|
8
8
|
import '../../intl/TimeFormatter.js';
|
|
9
9
|
import '../Button/Button.js';
|
|
@@ -29,43 +29,44 @@ const classNameGenerator = index.tv({
|
|
|
29
29
|
},
|
|
30
30
|
});
|
|
31
31
|
const ItemButton = ({ option, onAdd, onSelect, onMouseOver, activeRef }) => {
|
|
32
|
+
const unstableRef = React.useRef({ onAdd, onSelect, onMouseOver, option });
|
|
33
|
+
unstableRef.current = { onAdd, onSelect, onMouseOver, option };
|
|
32
34
|
const handleMouseOver = React.useCallback(() => {
|
|
33
|
-
onMouseOver(option);
|
|
34
|
-
}, [
|
|
35
|
-
const
|
|
36
|
-
option
|
|
37
|
-
|
|
35
|
+
unstableRef.current.onMouseOver(unstableRef.current.option);
|
|
36
|
+
}, []);
|
|
37
|
+
const handleAddClick = React.useCallback(() => {
|
|
38
|
+
unstableRef.current.onAdd?.(unstableRef.current.option);
|
|
39
|
+
}, []);
|
|
40
|
+
const handleSelectClick = React.useCallback(() => {
|
|
41
|
+
unstableRef.current.onSelect(unstableRef.current.option);
|
|
42
|
+
}, []);
|
|
43
|
+
const commonAttrs = {
|
|
44
|
+
id: option.id,
|
|
45
|
+
label: option.item.label,
|
|
38
46
|
activeRef,
|
|
47
|
+
onMouseOver: handleMouseOver,
|
|
39
48
|
};
|
|
40
|
-
return option.isNew ? (jsxRuntime.jsx(AddButton, { ...
|
|
49
|
+
return option.isNew ? (jsxRuntime.jsx(AddButton, { ...commonAttrs, onClick: handleAddClick })) : (jsxRuntime.jsx(SelectButton, { ...commonAttrs, disabled: option.item.disabled, selected: option.selected, onClick: handleSelectClick }));
|
|
41
50
|
};
|
|
42
51
|
const typedMemo = React.memo;
|
|
43
52
|
const Memoized = typedMemo(ItemButton);
|
|
44
|
-
const AddButton = ({
|
|
45
|
-
const className =
|
|
53
|
+
const AddButton = React.memo(({ id, label, activeRef, onClick, onMouseOver }) => {
|
|
54
|
+
const className = classNameGenerator({
|
|
46
55
|
new: true,
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
? () => {
|
|
50
|
-
onAdd(option);
|
|
51
|
-
}
|
|
52
|
-
: undefined, [option, onAdd]);
|
|
53
|
-
return (jsxRuntime.jsx("button", { ref: activeRef, type: "button", role: "option", "aria-selected": false, id: option.id, "data-active": !!activeRef, onClick: onClick,
|
|
56
|
+
});
|
|
57
|
+
return (jsxRuntime.jsx("button", { ref: activeRef, type: "button", role: "option", "aria-selected": false, id: id, "data-active": !!activeRef, onClick: onClick,
|
|
54
58
|
// eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
|
|
55
|
-
onMouseOver: onMouseOver, className: className, children: jsxRuntime.jsx(MemoizedNewIconWithText, { label:
|
|
56
|
-
};
|
|
59
|
+
onMouseOver: onMouseOver, className: className, children: jsxRuntime.jsx(MemoizedNewIconWithText, { label: label }) }));
|
|
60
|
+
});
|
|
57
61
|
const MemoizedNewIconWithText = React.memo(({ label }) => (jsxRuntime.jsx(components_Text_Text.Text, { color: "TEXT_LINK", icon: jsxRuntime.jsx(components_Icon_FaIcon.FaCirclePlusIcon, { color: "TEXT_LINK" }), children: jsxRuntime.jsx(intl_Localizer.Localizer, { id: "smarthr-ui/Combobox/addItemButtonLabel", defaultText: "\u300C{name}\u300D\u3092\u8FFD\u52A0", values: { name: label } }) })));
|
|
58
|
-
const SelectButton = ({
|
|
59
|
-
const className =
|
|
62
|
+
const SelectButton = React.memo(({ id, label, disabled, selected, activeRef, onClick, onMouseOver }) => {
|
|
63
|
+
const className = classNameGenerator({
|
|
60
64
|
new: false,
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
onSelect(option);
|
|
64
|
-
}, [onSelect, option]);
|
|
65
|
-
return (jsxRuntime.jsx("button", { ref: activeRef, type: "button", role: "option", id: option.id, disabled: option.item.disabled, "aria-selected": option.selected, "data-active": !!activeRef, onClick: handleSelect,
|
|
65
|
+
});
|
|
66
|
+
return (jsxRuntime.jsx("button", { ref: activeRef, type: "button", role: "option", id: id, disabled: disabled, "aria-selected": selected, "data-active": !!activeRef, onClick: onClick,
|
|
66
67
|
// eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
|
|
67
|
-
onMouseOver: onMouseOver, className: className, children:
|
|
68
|
-
};
|
|
68
|
+
onMouseOver: onMouseOver, className: className, children: label }));
|
|
69
|
+
});
|
|
69
70
|
|
|
70
71
|
exports.ItemButton = Memoized;
|
|
71
72
|
//# sourceMappingURL=ItemButton.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ItemButton.cjs","sources":["../../../src/components/Combobox/ItemButton.tsx"],"sourcesContent":["import { type ReactNode, type RefObject, memo, useCallback,
|
|
1
|
+
{"version":3,"file":"ItemButton.cjs","sources":["../../../src/components/Combobox/ItemButton.tsx"],"sourcesContent":["import { type ReactNode, type RefObject, memo, useCallback, useRef } from 'react'\nimport { tv } from 'tailwind-variants'\n\nimport { Localizer } from '../../intl'\nimport { FaCirclePlusIcon } from '../Icon'\nimport { Text } from '../Text'\n\nimport type { ComboboxOption } from './types'\n\ntype Props<T> = {\n option: ComboboxOption<T>\n onAdd?: (option: ComboboxOption<T>) => void\n onSelect: (option: ComboboxOption<T>) => void\n onMouseOver: (option: ComboboxOption<T>) => void\n activeRef: RefObject<HTMLButtonElement> | undefined\n}\n\nconst classNameGenerator = tv({\n base: [\n 'shr-block shr-min-w-full shr-cursor-pointer shr-border-none shr-px-1 shr-py-0.5 shr-text-left shr-text-base shr-leading-tight',\n 'aria-selected:shr-text-white',\n 'disabled:shr-cursor-not-allowed disabled:shr-text-disabled',\n 'data-[active=true]:shr-bg-white-darken data-[active=true]:aria-selected:shr-bg-main-darken',\n 'data-[active=false]:shr-bg-white data-[active=false]:aria-selected:shr-bg-main',\n ],\n variants: {\n new: {\n true: 'smarthr-ui-Combobox-addButton shr-flex shr-items-center',\n false: 'smarthr-ui-Combobox-selectButton',\n },\n },\n})\n\nconst ItemButton = <T,>({ option, onAdd, onSelect, onMouseOver, activeRef }: Props<T>) => {\n const unstableRef = useRef({ onAdd, onSelect, onMouseOver, option })\n unstableRef.current = { onAdd, onSelect, onMouseOver, option }\n\n const handleMouseOver = useCallback(() => {\n unstableRef.current.onMouseOver(unstableRef.current.option)\n }, [])\n\n const handleAddClick = useCallback(() => {\n unstableRef.current.onAdd?.(unstableRef.current.option)\n }, [])\n\n const handleSelectClick = useCallback(() => {\n unstableRef.current.onSelect(unstableRef.current.option)\n }, [])\n\n const commonAttrs = {\n id: option.id,\n label: option.item.label,\n activeRef,\n onMouseOver: handleMouseOver,\n }\n\n return option.isNew ? (\n <AddButton {...commonAttrs} onClick={handleAddClick} />\n ) : (\n <SelectButton\n {...commonAttrs}\n disabled={option.item.disabled}\n selected={option.selected}\n onClick={handleSelectClick}\n />\n )\n}\nconst typedMemo: <T>(c: T) => T = memo\nconst Memoized = typedMemo(ItemButton)\nexport { Memoized as ItemButton }\n\nconst AddButton = memo<{\n id: string\n label: ReactNode\n activeRef: RefObject<HTMLButtonElement> | undefined\n onClick?: () => void\n onMouseOver: () => void\n}>(({ id, label, activeRef, onClick, onMouseOver }) => {\n const className = classNameGenerator({\n new: true,\n })\n\n return (\n <button\n ref={activeRef}\n type=\"button\"\n role=\"option\"\n aria-selected={false}\n id={id}\n data-active={!!activeRef}\n onClick={onClick}\n // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events\n onMouseOver={onMouseOver}\n className={className}\n >\n <MemoizedNewIconWithText label={label} />\n </button>\n )\n})\n\nconst MemoizedNewIconWithText = memo<{ label: ReactNode }>(({ label }) => (\n <Text color=\"TEXT_LINK\" icon={<FaCirclePlusIcon color=\"TEXT_LINK\" />}>\n <Localizer\n id=\"smarthr-ui/Combobox/addItemButtonLabel\"\n defaultText=\"「{name}」を追加\"\n values={{ name: label }}\n />\n </Text>\n))\n\nconst SelectButton = memo<{\n id: string\n label: ReactNode\n disabled?: boolean\n selected: boolean\n activeRef: RefObject<HTMLButtonElement> | undefined\n onClick: () => void\n onMouseOver: () => void\n}>(({ id, label, disabled, selected, activeRef, onClick, onMouseOver }) => {\n const className = classNameGenerator({\n new: false,\n })\n\n return (\n <button\n ref={activeRef}\n type=\"button\"\n role=\"option\"\n id={id}\n disabled={disabled}\n aria-selected={selected}\n data-active={!!activeRef}\n onClick={onClick}\n // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events\n onMouseOver={onMouseOver}\n className={className}\n >\n {label}\n </button>\n )\n})\n"],"names":["tv","useRef","useCallback","_jsx","memo","Text","FaCirclePlusIcon","Localizer"],"mappings":";;;;;;;;;;;;;;;AAiBA,MAAM,kBAAkB,GAAGA,QAAE,CAAC;AAC5B,IAAA,IAAI,EAAE;QACJ,+HAA+H;QAC/H,8BAA8B;QAC9B,4DAA4D;QAC5D,4FAA4F;QAC5F,gFAAgF;AACjF,KAAA;AACD,IAAA,QAAQ,EAAE;AACR,QAAA,GAAG,EAAE;AACH,YAAA,IAAI,EAAE,yDAAyD;AAC/D,YAAA,KAAK,EAAE,kCAAkC;AAC1C,SAAA;AACF,KAAA;AACF,CAAA,CAAC;AAEF,MAAM,UAAU,GAAG,CAAK,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAY,KAAI;AACvF,IAAA,MAAM,WAAW,GAAGC,YAAM,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;AACpE,IAAA,WAAW,CAAC,OAAO,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE;AAE9D,IAAA,MAAM,eAAe,GAAGC,iBAAW,CAAC,MAAK;QACvC,WAAW,CAAC,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC;IAC7D,CAAC,EAAE,EAAE,CAAC;AAEN,IAAA,MAAM,cAAc,GAAGA,iBAAW,CAAC,MAAK;AACtC,QAAA,WAAW,CAAC,OAAO,CAAC,KAAK,GAAG,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC;IACzD,CAAC,EAAE,EAAE,CAAC;AAEN,IAAA,MAAM,iBAAiB,GAAGA,iBAAW,CAAC,MAAK;QACzC,WAAW,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,C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AAK,EAAE,MACnED,cAAA,CAACE,yBAAI,EAAA,EAAC,KAAK,EAAC,WAAW,EAAC,IAAI,EAAEF,cAAA,CAACG,uCAAgB,EAAA,EAAC,KAAK,EAAC,WAAW,EAAA,CAAG,EAAA,QAAA,EAClEH,cAAA,CAACI,wBAAS,EAAA,EACR,EAAE,EAAC,wCAAwC,EAC3C,WAAW,EAAC,sCAAa,EACzB,MAAM,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,EAAA,CACvB,EAAA,CACG,CACR,CAAC;AAEF,MAAM,YAAY,GAAGH,UAAI,CAQtB,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,KAAI;IACxE,MAAM,SAAS,GAAG,kBAAkB,CAAC;AACnC,QAAA,GAAG,EAAE,KAAK;AACX,KAAA,CAAC;AAEF,IAAA,QACED,cAAA,CAAA,QAAA,EAAA,EACE,GAAG,EAAE,SAAS,EACd,IAAI,EAAC,QAAQ,EACb,IAAI,EAAC,QAAQ,EACb,EAAE,EAAE,EAAE,EACN,QAAQ,EAAE,QAAQ,EAAA,eAAA,EACH,QAAQ,EAAA,aAAA,EACV,CAAC,CAAC,SAAS,EACxB,OAAO,EAAE,OAAO;;QAEhB,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,EAAA,QAAA,EAEnB,KAAK,EAAA,CACC;AAEb,CAAC,CAAC;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { memo,
|
|
2
|
+
import { memo, useRef, useCallback } 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
4
|
import '../../intl/IntlProvider.js';
|
|
5
5
|
import 'react-intl';
|
|
@@ -27,43 +27,44 @@ const classNameGenerator = ce({
|
|
|
27
27
|
},
|
|
28
28
|
});
|
|
29
29
|
const ItemButton = ({ option, onAdd, onSelect, onMouseOver, activeRef }) => {
|
|
30
|
+
const unstableRef = useRef({ onAdd, onSelect, onMouseOver, option });
|
|
31
|
+
unstableRef.current = { onAdd, onSelect, onMouseOver, option };
|
|
30
32
|
const handleMouseOver = useCallback(() => {
|
|
31
|
-
onMouseOver(option);
|
|
32
|
-
}, [
|
|
33
|
-
const
|
|
34
|
-
option
|
|
35
|
-
|
|
33
|
+
unstableRef.current.onMouseOver(unstableRef.current.option);
|
|
34
|
+
}, []);
|
|
35
|
+
const handleAddClick = useCallback(() => {
|
|
36
|
+
unstableRef.current.onAdd?.(unstableRef.current.option);
|
|
37
|
+
}, []);
|
|
38
|
+
const handleSelectClick = useCallback(() => {
|
|
39
|
+
unstableRef.current.onSelect(unstableRef.current.option);
|
|
40
|
+
}, []);
|
|
41
|
+
const commonAttrs = {
|
|
42
|
+
id: option.id,
|
|
43
|
+
label: option.item.label,
|
|
36
44
|
activeRef,
|
|
45
|
+
onMouseOver: handleMouseOver,
|
|
37
46
|
};
|
|
38
|
-
return option.isNew ? (jsx(AddButton, { ...
|
|
47
|
+
return option.isNew ? (jsx(AddButton, { ...commonAttrs, onClick: handleAddClick })) : (jsx(SelectButton, { ...commonAttrs, disabled: option.item.disabled, selected: option.selected, onClick: handleSelectClick }));
|
|
39
48
|
};
|
|
40
49
|
const typedMemo = memo;
|
|
41
50
|
const Memoized = typedMemo(ItemButton);
|
|
42
|
-
const AddButton = ({
|
|
43
|
-
const className =
|
|
51
|
+
const AddButton = memo(({ id, label, activeRef, onClick, onMouseOver }) => {
|
|
52
|
+
const className = classNameGenerator({
|
|
44
53
|
new: true,
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
? () => {
|
|
48
|
-
onAdd(option);
|
|
49
|
-
}
|
|
50
|
-
: undefined, [option, onAdd]);
|
|
51
|
-
return (jsx("button", { ref: activeRef, type: "button", role: "option", "aria-selected": false, id: option.id, "data-active": !!activeRef, onClick: onClick,
|
|
54
|
+
});
|
|
55
|
+
return (jsx("button", { ref: activeRef, type: "button", role: "option", "aria-selected": false, id: id, "data-active": !!activeRef, onClick: onClick,
|
|
52
56
|
// eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
|
|
53
|
-
onMouseOver: onMouseOver, className: className, children: jsx(MemoizedNewIconWithText, { label:
|
|
54
|
-
};
|
|
57
|
+
onMouseOver: onMouseOver, className: className, children: jsx(MemoizedNewIconWithText, { label: label }) }));
|
|
58
|
+
});
|
|
55
59
|
const MemoizedNewIconWithText = memo(({ label }) => (jsx(Text, { color: "TEXT_LINK", icon: jsx(FaCirclePlusIcon, { color: "TEXT_LINK" }), children: jsx(Localizer, { id: "smarthr-ui/Combobox/addItemButtonLabel", defaultText: "\u300C{name}\u300D\u3092\u8FFD\u52A0", values: { name: label } }) })));
|
|
56
|
-
const SelectButton = ({
|
|
57
|
-
const className =
|
|
60
|
+
const SelectButton = memo(({ id, label, disabled, selected, activeRef, onClick, onMouseOver }) => {
|
|
61
|
+
const className = classNameGenerator({
|
|
58
62
|
new: false,
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
onSelect(option);
|
|
62
|
-
}, [onSelect, option]);
|
|
63
|
-
return (jsx("button", { ref: activeRef, type: "button", role: "option", id: option.id, disabled: option.item.disabled, "aria-selected": option.selected, "data-active": !!activeRef, onClick: handleSelect,
|
|
63
|
+
});
|
|
64
|
+
return (jsx("button", { ref: activeRef, type: "button", role: "option", id: id, disabled: disabled, "aria-selected": selected, "data-active": !!activeRef, onClick: onClick,
|
|
64
65
|
// eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
|
|
65
|
-
onMouseOver: onMouseOver, className: className, children:
|
|
66
|
-
};
|
|
66
|
+
onMouseOver: onMouseOver, className: className, children: label }));
|
|
67
|
+
});
|
|
67
68
|
|
|
68
69
|
export { Memoized as ItemButton };
|
|
69
70
|
//# sourceMappingURL=ItemButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ItemButton.js","sources":["../../../src/components/Combobox/ItemButton.tsx"],"sourcesContent":["import { type ReactNode, type RefObject, memo, useCallback,
|
|
1
|
+
{"version":3,"file":"ItemButton.js","sources":["../../../src/components/Combobox/ItemButton.tsx"],"sourcesContent":["import { type ReactNode, type RefObject, memo, useCallback, useRef } from 'react'\nimport { tv } from 'tailwind-variants'\n\nimport { Localizer } from '../../intl'\nimport { FaCirclePlusIcon } from '../Icon'\nimport { Text } from '../Text'\n\nimport type { ComboboxOption } from './types'\n\ntype Props<T> = {\n option: ComboboxOption<T>\n onAdd?: (option: ComboboxOption<T>) => void\n onSelect: (option: ComboboxOption<T>) => void\n onMouseOver: (option: ComboboxOption<T>) => void\n activeRef: RefObject<HTMLButtonElement> | undefined\n}\n\nconst classNameGenerator = tv({\n base: [\n 'shr-block shr-min-w-full shr-cursor-pointer shr-border-none shr-px-1 shr-py-0.5 shr-text-left shr-text-base shr-leading-tight',\n 'aria-selected:shr-text-white',\n 'disabled:shr-cursor-not-allowed disabled:shr-text-disabled',\n 'data-[active=true]:shr-bg-white-darken data-[active=true]:aria-selected:shr-bg-main-darken',\n 'data-[active=false]:shr-bg-white data-[active=false]:aria-selected:shr-bg-main',\n ],\n variants: {\n new: {\n true: 'smarthr-ui-Combobox-addButton shr-flex shr-items-center',\n false: 'smarthr-ui-Combobox-selectButton',\n },\n },\n})\n\nconst ItemButton = <T,>({ option, onAdd, onSelect, onMouseOver, activeRef }: Props<T>) => {\n const unstableRef = useRef({ onAdd, onSelect, onMouseOver, option })\n unstableRef.current = { onAdd, onSelect, onMouseOver, option }\n\n const handleMouseOver = useCallback(() => {\n unstableRef.current.onMouseOver(unstableRef.current.option)\n }, [])\n\n const handleAddClick = useCallback(() => {\n unstableRef.current.onAdd?.(unstableRef.current.option)\n }, [])\n\n const handleSelectClick = useCallback(() => {\n unstableRef.current.onSelect(unstableRef.current.option)\n }, [])\n\n const commonAttrs = {\n id: option.id,\n label: option.item.label,\n activeRef,\n onMouseOver: handleMouseOver,\n }\n\n return option.isNew ? (\n <AddButton {...commonAttrs} onClick={handleAddClick} />\n ) : (\n <SelectButton\n {...commonAttrs}\n disabled={option.item.disabled}\n selected={option.selected}\n onClick={handleSelectClick}\n />\n )\n}\nconst typedMemo: <T>(c: T) => T = memo\nconst Memoized = typedMemo(ItemButton)\nexport { Memoized as ItemButton }\n\nconst AddButton = memo<{\n id: string\n label: ReactNode\n activeRef: RefObject<HTMLButtonElement> | undefined\n onClick?: () => void\n onMouseOver: () => void\n}>(({ id, label, activeRef, onClick, onMouseOver }) => {\n const className = classNameGenerator({\n new: true,\n })\n\n return (\n <button\n ref={activeRef}\n type=\"button\"\n role=\"option\"\n aria-selected={false}\n id={id}\n data-active={!!activeRef}\n onClick={onClick}\n // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events\n onMouseOver={onMouseOver}\n className={className}\n >\n <MemoizedNewIconWithText label={label} />\n </button>\n )\n})\n\nconst MemoizedNewIconWithText = memo<{ label: ReactNode }>(({ label }) => (\n <Text color=\"TEXT_LINK\" icon={<FaCirclePlusIcon color=\"TEXT_LINK\" />}>\n <Localizer\n id=\"smarthr-ui/Combobox/addItemButtonLabel\"\n defaultText=\"「{name}」を追加\"\n values={{ name: label }}\n />\n </Text>\n))\n\nconst SelectButton = memo<{\n id: string\n label: ReactNode\n disabled?: boolean\n selected: boolean\n activeRef: RefObject<HTMLButtonElement> | undefined\n onClick: () => void\n onMouseOver: () => void\n}>(({ id, label, disabled, selected, activeRef, onClick, onMouseOver }) => {\n const className = classNameGenerator({\n new: false,\n })\n\n return (\n <button\n ref={activeRef}\n type=\"button\"\n role=\"option\"\n id={id}\n disabled={disabled}\n aria-selected={selected}\n data-active={!!activeRef}\n onClick={onClick}\n // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events\n onMouseOver={onMouseOver}\n className={className}\n >\n {label}\n </button>\n )\n})\n"],"names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