smarthr-ui 97.0.0 → 98.0.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/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 +96 -46
- package/lib/components/Combobox/SingleCombobox/SingleCombobox.cjs.map +1 -1
- package/lib/components/Combobox/SingleCombobox/SingleCombobox.js +98 -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/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/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/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/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/metadata.json +1 -1
- package/package.json +1 -1
- package/smarthr-ui.css +0 -94
- 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,8BAA8B;AACvC,aAAA;AACD,YAAA,CAAC,EAAE,EAAE;AACL,YAAA,CAAC,EAAE,EAAE;AACN,SAAA;AACF,KAAA;AACD,IAAA,gBAAgB,EAAE;AAChB,QAAA;AACE,YAAA,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;AACjB,YAAA,SAAS,EAAE;AACT,gBAAA,MAAM,EAAE,eAAe;AACxB,aAAA;AACF,SAAA;AACF,KAAA;AACF,CAAA,CAAC;AAYK,MAAM,OAAO,GAAc,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,KAAI;IACvF,MAAM,QAAQ,GAAGC,aAAO,CAAC,MAAMC,2CAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;IAC3E,MAAM,OAAO,GAAGD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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;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,8BAA8B;AACvC,aAAA;AACD,YAAA,CAAC,EAAE,EAAE;AACL,YAAA,CAAC,EAAE,EAAE;AACN,SAAA;AACF,KAAA;AACD,IAAA,gBAAgB,EAAE;AAChB,QAAA;AACE,YAAA,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;AACjB,YAAA,SAAS,EAAE;AACT,gBAAA,MAAM,EAAE,eAAe;AACxB,aAAA;AACF,SAAA;AACF,KAAA;AACF,CAAA,CAAC;AAYK,MAAM,OAAO,GAAc,CAAC,EAAE,KAAK,EAAE,KAAK,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AAC,YAAY,GAAG,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC;IAC3D,CAAC,EAAE,EAAE,CAAC;IAEN;;AAEE,IAAAC,GAAA,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,GAAA,CAAC,aAAa,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;;;;"}
|
|
@@ -7,7 +7,7 @@ var React = require('react');
|
|
|
7
7
|
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');
|
|
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';
|
|
@@ -9,7 +9,7 @@ var hooks_useOuterClick = require('../../../hooks/useOuterClick.cjs');
|
|
|
9
9
|
var hooks_useTheme = require('../../../hooks/useTheme.cjs');
|
|
10
10
|
require('../../../intl/IntlProvider.cjs');
|
|
11
11
|
var intl_useIntl = require('../../../intl/useIntl.cjs');
|
|
12
|
-
require('
|
|
12
|
+
require('../../../intl/Localizer.cjs');
|
|
13
13
|
require('../../../_virtual/dayjs.min.cjs');
|
|
14
14
|
require('../../../intl/TimeFormatter.cjs');
|
|
15
15
|
var libs_util = require('../../../libs/util.cjs');
|
|
@@ -98,6 +98,38 @@ const ActualMultiCombobox = ({ items, selectedItems, name, disabled = false, req
|
|
|
98
98
|
const [uncontrolledInputValue, setUncontrolledInputValue] = React.useState('');
|
|
99
99
|
const inputValue = isInputControlled ? controlledInputValue : uncontrolledInputValue;
|
|
100
100
|
const [isComposing, setIsComposing] = React.useState(false);
|
|
101
|
+
const unstableRef = React.useRef({
|
|
102
|
+
onChange,
|
|
103
|
+
onChangeInput,
|
|
104
|
+
onAdd,
|
|
105
|
+
onSelect,
|
|
106
|
+
onDelete,
|
|
107
|
+
onChangeSelected,
|
|
108
|
+
onFocus,
|
|
109
|
+
onBlur,
|
|
110
|
+
onKeyPress,
|
|
111
|
+
isItemSelected,
|
|
112
|
+
selectedItems,
|
|
113
|
+
isFocused,
|
|
114
|
+
highlighted,
|
|
115
|
+
isComposing,
|
|
116
|
+
});
|
|
117
|
+
unstableRef.current = {
|
|
118
|
+
onChange,
|
|
119
|
+
onChangeInput,
|
|
120
|
+
onAdd,
|
|
121
|
+
onSelect,
|
|
122
|
+
onDelete,
|
|
123
|
+
onChangeSelected,
|
|
124
|
+
onFocus,
|
|
125
|
+
onBlur,
|
|
126
|
+
onKeyPress,
|
|
127
|
+
isItemSelected,
|
|
128
|
+
selectedItems,
|
|
129
|
+
isFocused,
|
|
130
|
+
highlighted,
|
|
131
|
+
isComposing,
|
|
132
|
+
};
|
|
101
133
|
const { options } = components_Combobox_useOptions.useMultiOptions({
|
|
102
134
|
items,
|
|
103
135
|
selected: selectedItems,
|
|
@@ -106,41 +138,38 @@ const ActualMultiCombobox = ({ items, selectedItems, name, disabled = false, req
|
|
|
106
138
|
isItemSelected,
|
|
107
139
|
});
|
|
108
140
|
const setInputValueIfUncontrolled = isInputControlled ? NOOP : setUncontrolledInputValue;
|
|
109
|
-
const actualOnDelete = React.
|
|
141
|
+
const actualOnDelete = React.useCallback((item) => {
|
|
110
142
|
const handlers = [];
|
|
111
|
-
if (onDelete) {
|
|
112
|
-
handlers.push((
|
|
113
|
-
}
|
|
114
|
-
if (onChangeSelected) {
|
|
115
|
-
handlers.push((item) => onChangeSelected(selectedItems.filter((selected) => !components_Combobox_helper.areItemsEqual(selected, item))));
|
|
143
|
+
if (unstableRef.current.onDelete) {
|
|
144
|
+
handlers.push((deletingItem) => unstableRef.current.onDelete(deletingItem));
|
|
116
145
|
}
|
|
117
|
-
if (
|
|
118
|
-
|
|
146
|
+
if (unstableRef.current.onChangeSelected) {
|
|
147
|
+
handlers.push((deletingItem) => unstableRef.current.onChangeSelected(unstableRef.current.selectedItems.filter((selected) => !components_Combobox_helper.areItemsEqual(selected, deletingItem))));
|
|
119
148
|
}
|
|
120
|
-
|
|
149
|
+
if (handlers.length > 0) {
|
|
121
150
|
// HINT: Dropdown系コンポーネント内でComboboxを使うと、選択肢がportalで表現されている関係上Dropdownが閉じてしまう
|
|
122
151
|
// requestAnimationFrameを追加、処理を遅延させることで正常に閉じる/閉じないの判定を行えるようにする
|
|
123
152
|
requestAnimationFrame(() => {
|
|
124
153
|
handlers.forEach((h) => h(item));
|
|
125
154
|
});
|
|
126
|
-
}
|
|
127
|
-
}, [
|
|
155
|
+
}
|
|
156
|
+
}, []);
|
|
128
157
|
const actualOnSelect = React.useCallback((selected) => {
|
|
129
158
|
// HINT: Dropdown系コンポーネント内でComboboxを使うと、選択肢がportalで表現されている関係上Dropdownが閉じてしまう
|
|
130
159
|
// requestAnimationFrameを追加、処理を遅延させることで正常に閉じる/閉じないの判定を行えるようにする
|
|
131
160
|
requestAnimationFrame(() => {
|
|
132
|
-
const matchedSelectedItem = selectedItems.find((item) => components_Combobox_helper.areItemsEqual(item, selected));
|
|
161
|
+
const matchedSelectedItem = unstableRef.current.selectedItems.find((item) => components_Combobox_helper.areItemsEqual(item, selected));
|
|
133
162
|
if (matchedSelectedItem === undefined) {
|
|
134
|
-
onSelect?.(selected);
|
|
135
|
-
onChangeSelected?.(selectedItems.concat(selected));
|
|
163
|
+
unstableRef.current.onSelect?.(selected);
|
|
164
|
+
unstableRef.current.onChangeSelected?.(unstableRef.current.selectedItems.concat(selected));
|
|
136
165
|
// 制御コンポーネントの場合に親側でinputValueを更新できるように、選択時にonChangeInputを空文字で発火する
|
|
137
|
-
onChangeInput?.(EMPTY_INPUT_CHANGE_EVENT);
|
|
166
|
+
unstableRef.current.onChangeInput?.(EMPTY_INPUT_CHANGE_EVENT);
|
|
138
167
|
}
|
|
139
168
|
else if (matchedSelectedItem.deletable !== false) {
|
|
140
169
|
actualOnDelete(selected);
|
|
141
170
|
}
|
|
142
171
|
});
|
|
143
|
-
}, [
|
|
172
|
+
}, [actualOnDelete]);
|
|
144
173
|
const { renderListBox, activeOption, onKeyDownListBox, listBoxId, listBoxRef } = components_Combobox_useListbox.useListbox({
|
|
145
174
|
options,
|
|
146
175
|
dropdownHelpMessage,
|
|
@@ -154,133 +183,96 @@ const ActualMultiCombobox = ({ items, selectedItems, name, disabled = false, req
|
|
|
154
183
|
});
|
|
155
184
|
const { deletionButtonRefs, inputRef, focusPrevDeletionButton, focusNextDeletionButton, resetDeletionButtonFocus, } = components_Combobox_useFocusControl.useFocusControl(selectedItems.length);
|
|
156
185
|
React.useImperativeHandle(ref, () => inputRef.current);
|
|
157
|
-
const focus = React.
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
baseAction();
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
return baseAction;
|
|
168
|
-
}, [onFocus]);
|
|
169
|
-
const blur = React.useMemo(() => {
|
|
170
|
-
if (!isFocused) {
|
|
171
|
-
return NOOP;
|
|
172
|
-
}
|
|
173
|
-
const baseAction = () => {
|
|
186
|
+
const focus = React.useCallback(() => {
|
|
187
|
+
unstableRef.current.onFocus?.();
|
|
188
|
+
setIsFocused(true);
|
|
189
|
+
}, []);
|
|
190
|
+
const blur = React.useCallback(() => {
|
|
191
|
+
if (unstableRef.current.isFocused) {
|
|
192
|
+
unstableRef.current.onBlur?.();
|
|
174
193
|
setIsFocused(false);
|
|
175
194
|
resetDeletionButtonFocus();
|
|
176
|
-
};
|
|
177
|
-
if (onBlur) {
|
|
178
|
-
return () => {
|
|
179
|
-
onBlur();
|
|
180
|
-
baseAction();
|
|
181
|
-
};
|
|
182
195
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
const outerClickRef = React.useMemo(() => [outerRef, listBoxRef], [outerRef, listBoxRef]);
|
|
196
|
+
}, [resetDeletionButtonFocus]);
|
|
197
|
+
const outerClickRef = React.useMemo(() => [outerRef, listBoxRef], [listBoxRef]);
|
|
186
198
|
hooks_useOuterClick.useOuterClick(outerClickRef, blur);
|
|
187
|
-
const highlightedRef = React.useRef(highlighted);
|
|
188
|
-
React.useEffect(() => {
|
|
189
|
-
highlightedRef.current = highlighted;
|
|
190
|
-
}, [highlighted]);
|
|
191
199
|
React.useEffect(() => {
|
|
192
|
-
if (
|
|
200
|
+
if (unstableRef.current.highlighted) {
|
|
193
201
|
setHighlighted(false);
|
|
194
202
|
inputRef.current?.select();
|
|
195
203
|
}
|
|
196
204
|
else {
|
|
197
205
|
setInputValueIfUncontrolled('');
|
|
198
206
|
}
|
|
199
|
-
}, [selectedItems,
|
|
207
|
+
}, [selectedItems, setInputValueIfUncontrolled, inputRef]);
|
|
200
208
|
React.useEffect(() => {
|
|
201
209
|
if (isFocused) {
|
|
202
210
|
inputRef.current?.focus();
|
|
203
211
|
}
|
|
204
|
-
}, [
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
}
|
|
217
|
-
blur();
|
|
218
|
-
}
|
|
219
|
-
else if (ARROW_LEFT_KEY_REGEX.test(e.key)) {
|
|
220
|
-
e.stopPropagation();
|
|
221
|
-
focusPrevDeletionButton();
|
|
222
|
-
}
|
|
223
|
-
else if (ARROW_RIGHT_KEY_REGEX.test(e.key)) {
|
|
224
|
-
e.stopPropagation();
|
|
225
|
-
focusNextDeletionButton();
|
|
226
|
-
}
|
|
227
|
-
else if (e.key === 'Backspace' &&
|
|
228
|
-
!inputValue &&
|
|
229
|
-
selectedItems.length > 0 &&
|
|
230
|
-
selectedItems[selectedItems.length - 1].deletable !== false) {
|
|
231
|
-
e.preventDefault();
|
|
232
|
-
e.stopPropagation();
|
|
233
|
-
const lastItem = selectedItems[selectedItems.length - 1];
|
|
234
|
-
actualOnDelete(lastItem);
|
|
235
|
-
setHighlighted(true);
|
|
236
|
-
setInputValueIfUncontrolled(index$1(lastItem.label));
|
|
237
|
-
}
|
|
238
|
-
else {
|
|
239
|
-
e.stopPropagation();
|
|
212
|
+
}, [isFocused, setInputValueIfUncontrolled, selectedItems, inputRef]);
|
|
213
|
+
const isInputEmpty = !inputValue;
|
|
214
|
+
const onDelegateKeyDown = (e) => {
|
|
215
|
+
if (unstableRef.current.isComposing)
|
|
216
|
+
return;
|
|
217
|
+
if (ESCAPE_KEY_REGEX.test(e.key)) {
|
|
218
|
+
e.stopPropagation();
|
|
219
|
+
blur();
|
|
220
|
+
}
|
|
221
|
+
else if (e.key === 'Tab') {
|
|
222
|
+
if (unstableRef.current.isFocused) {
|
|
223
|
+
// フォーカスがコンポーネントを抜けるように先に input をフォーカスしておく
|
|
240
224
|
inputRef.current?.focus();
|
|
241
|
-
resetDeletionButtonFocus();
|
|
242
225
|
}
|
|
243
|
-
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
226
|
+
blur();
|
|
227
|
+
}
|
|
228
|
+
else if (ARROW_LEFT_KEY_REGEX.test(e.key)) {
|
|
229
|
+
e.stopPropagation();
|
|
230
|
+
focusPrevDeletionButton();
|
|
231
|
+
}
|
|
232
|
+
else if (ARROW_RIGHT_KEY_REGEX.test(e.key)) {
|
|
233
|
+
e.stopPropagation();
|
|
234
|
+
focusNextDeletionButton();
|
|
235
|
+
}
|
|
236
|
+
else if (e.key === 'Backspace' &&
|
|
237
|
+
isInputEmpty &&
|
|
238
|
+
unstableRef.current.selectedItems.length > 0 &&
|
|
239
|
+
unstableRef.current.selectedItems[unstableRef.current.selectedItems.length - 1].deletable !==
|
|
240
|
+
false) {
|
|
241
|
+
e.preventDefault();
|
|
242
|
+
e.stopPropagation();
|
|
243
|
+
const lastItem = unstableRef.current.selectedItems[unstableRef.current.selectedItems.length - 1];
|
|
244
|
+
actualOnDelete(lastItem);
|
|
245
|
+
setHighlighted(true);
|
|
246
|
+
setInputValueIfUncontrolled(index$1(lastItem.label));
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
e.stopPropagation();
|
|
250
|
+
inputRef.current?.focus();
|
|
251
|
+
resetDeletionButtonFocus();
|
|
252
|
+
}
|
|
253
|
+
onKeyDownListBox(e);
|
|
254
|
+
};
|
|
255
|
+
const onDelegateClick = React.useCallback((e) => {
|
|
256
|
+
if (!disabled && !unstableRef.current.isFocused) {
|
|
261
257
|
if (!e.target.closest('.smarthr-ui-MultiCombobox-deleteButton')) {
|
|
262
258
|
focus();
|
|
263
259
|
}
|
|
264
|
-
}, [isFocused, disabled, focus]);
|
|
265
|
-
const actualOnChangeInput = React.useMemo(() => {
|
|
266
|
-
const handlers = [onChange, onChangeInput].filter((h) => !!h);
|
|
267
|
-
const onSetValue = (e) => {
|
|
268
|
-
setInputValueIfUncontrolled(e.currentTarget.value);
|
|
269
|
-
};
|
|
270
|
-
if (handlers.length === 0) {
|
|
271
|
-
return onSetValue;
|
|
272
260
|
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
261
|
+
}, [disabled, focus]);
|
|
262
|
+
const actualOnChangeInput = React.useCallback((e) => {
|
|
263
|
+
const handlers = [unstableRef.current.onChange, unstableRef.current.onChangeInput].filter((h) => !!h);
|
|
264
|
+
handlers.forEach((h) => h(e));
|
|
265
|
+
setInputValueIfUncontrolled(e.currentTarget.value);
|
|
266
|
+
}, [setInputValueIfUncontrolled]);
|
|
267
|
+
const onFocusInput = React.useCallback(() => {
|
|
268
|
+
if (unstableRef.current.isFocused) {
|
|
269
|
+
resetDeletionButtonFocus();
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
281
272
|
resetDeletionButtonFocus();
|
|
282
273
|
focus();
|
|
283
|
-
}
|
|
274
|
+
}
|
|
275
|
+
}, [resetDeletionButtonFocus, focus]);
|
|
284
276
|
const onCompositionStartInput = React.useCallback(() => setIsComposing(true), []);
|
|
285
277
|
const onCompositionEndInput = React.useCallback(() => setIsComposing(false), []);
|
|
286
278
|
const onKeyDownInput = React.useCallback((e) => {
|
|
@@ -292,12 +284,10 @@ const ActualMultiCombobox = ({ items, selectedItems, name, disabled = false, req
|
|
|
292
284
|
// HINT: form内にcomboboxを設置 & 検索inputにfocusした状態で
|
|
293
285
|
// アイテムをキーボードで選択し、Enterを押すとinput上でEnterを押したことになるため、
|
|
294
286
|
// submitイベントが発生し、formが送信される場合がある
|
|
295
|
-
const onDelegateKeyPress = React.
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
}
|
|
300
|
-
: preventDefaultWithPressEnter, [onKeyPress]);
|
|
287
|
+
const onDelegateKeyPress = React.useCallback((e) => {
|
|
288
|
+
preventDefaultWithPressEnter(e);
|
|
289
|
+
unstableRef.current.onKeyPress?.(e);
|
|
290
|
+
}, []);
|
|
301
291
|
const selectedListId = React.useId();
|
|
302
292
|
const wrapperStyle = React.useMemo(() => ({
|
|
303
293
|
...style,
|
|
@@ -327,13 +317,11 @@ const ActualMultiCombobox = ({ items, selectedItems, name, disabled = false, req
|
|
|
327
317
|
const MultiCombobox = libs_util.genericsForwardRef(ActualMultiCombobox);
|
|
328
318
|
const MemoizedCaretDown = React.memo(({ className, iconStyle, disabled, isFocused }) => {
|
|
329
319
|
const theme = hooks_useTheme.useTheme();
|
|
330
|
-
const caretIconColor =
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
return theme.textColor.grey;
|
|
336
|
-
}, [disabled, isFocused, theme.textColor]);
|
|
320
|
+
const caretIconColor = isFocused
|
|
321
|
+
? theme.textColor.black
|
|
322
|
+
: disabled
|
|
323
|
+
? theme.textColor.disabled
|
|
324
|
+
: theme.textColor.grey;
|
|
337
325
|
return (jsxRuntime.jsx("div", { className: className, children: jsxRuntime.jsx(components_Icon_FaIcon.FaCaretDownIcon, { color: caretIconColor, className: iconStyle }) }));
|
|
338
326
|
});
|
|
339
327
|
|