@charcoal-ui/react 6.0.0-rc.9 → 6.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/dist/_lib/compat.d.ts.map +1 -1
- package/dist/_lib/createDivComponent.cjs +0 -1
- package/dist/_lib/createDivComponent.cjs.map +1 -1
- package/dist/_lib/createDivComponent.d.ts +1 -1
- package/dist/_lib/createDivComponent.js.map +1 -1
- package/dist/_lib/index.cjs.map +1 -1
- package/dist/_lib/index.js.map +1 -1
- package/dist/_lib/useClassNames.cjs +0 -1
- package/dist/_lib/useClassNames.cjs.map +1 -1
- package/dist/_lib/useClassNames.js.map +1 -1
- package/dist/_lib/useForwardedRef.cjs +1 -1
- package/dist/_lib/useForwardedRef.cjs.map +1 -1
- package/dist/_lib/useForwardedRef.js.map +1 -1
- package/dist/_lib/useIsomorphicLayoutEffect.cjs +0 -1
- package/dist/_lib/useIsomorphicLayoutEffect.cjs.map +1 -1
- package/dist/_lib/useIsomorphicLayoutEffect.d.ts +2 -2
- package/dist/_lib/useIsomorphicLayoutEffect.d.ts.map +1 -1
- package/dist/_lib/useIsomorphicLayoutEffect.js.map +1 -1
- package/dist/components/Button/index.d.ts +1 -1
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index2.cjs +1 -1
- package/dist/components/Button/index2.cjs.map +1 -1
- package/dist/components/Button/index2.js.map +1 -1
- package/dist/components/Carousel/CarouselItem.cjs +0 -1
- package/dist/components/Carousel/CarouselItem.cjs.map +1 -1
- package/dist/components/Carousel/CarouselItem.d.ts.map +1 -1
- package/dist/components/Carousel/CarouselItem.js.map +1 -1
- package/dist/components/Carousel/carouselStore.cjs.map +1 -1
- package/dist/components/Carousel/carouselStore.js.map +1 -1
- package/dist/components/Carousel/index.d.ts +1 -1
- package/dist/components/Carousel/index.d.ts.map +1 -1
- package/dist/components/Carousel/index2.cjs +0 -1
- package/dist/components/Carousel/index2.cjs.map +1 -1
- package/dist/components/Carousel/index2.js.map +1 -1
- package/dist/components/Carousel/intersectionObserver.cjs.map +1 -1
- package/dist/components/Carousel/intersectionObserver.js.map +1 -1
- package/dist/components/Carousel/resizeObserver.cjs.map +1 -1
- package/dist/components/Carousel/resizeObserver.js.map +1 -1
- package/dist/components/Carousel/store.cjs.map +1 -1
- package/dist/components/Carousel/store.js.map +1 -1
- package/dist/components/Carousel/useCarouselScroller.cjs +0 -1
- package/dist/components/Carousel/useCarouselScroller.cjs.map +1 -1
- package/dist/components/Carousel/useCarouselScroller.js.map +1 -1
- package/dist/components/Checkbox/CheckboxInput/index.d.ts.map +1 -1
- package/dist/components/Checkbox/CheckboxInput/index2.cjs +0 -1
- package/dist/components/Checkbox/CheckboxInput/index2.cjs.map +1 -1
- package/dist/components/Checkbox/CheckboxInput/index2.js.map +1 -1
- package/dist/components/Checkbox/CheckboxWithLabel.cjs +1 -1
- package/dist/components/Checkbox/CheckboxWithLabel.cjs.map +1 -1
- package/dist/components/Checkbox/CheckboxWithLabel.d.ts +2 -2
- package/dist/components/Checkbox/CheckboxWithLabel.d.ts.map +1 -1
- package/dist/components/Checkbox/CheckboxWithLabel.js.map +1 -1
- package/dist/components/Checkbox/index.d.ts.map +1 -1
- package/dist/components/Checkbox/index2.cjs +0 -1
- package/dist/components/Checkbox/index2.cjs.map +1 -1
- package/dist/components/Checkbox/index2.js.map +1 -1
- package/dist/components/Clickable/index.d.ts +1 -1
- package/dist/components/Clickable/index.d.ts.map +1 -1
- package/dist/components/Clickable/index2.cjs +1 -1
- package/dist/components/Clickable/index2.cjs.map +1 -1
- package/dist/components/Clickable/index2.js.map +1 -1
- package/dist/components/DropdownSelector/DropdownMenuItem/index2.cjs +0 -1
- package/dist/components/DropdownSelector/DropdownMenuItem/index2.cjs.map +1 -1
- package/dist/components/DropdownSelector/DropdownMenuItem/index2.js.map +1 -1
- package/dist/components/DropdownSelector/DropdownPopover.cjs +0 -1
- package/dist/components/DropdownSelector/DropdownPopover.cjs.map +1 -1
- package/dist/components/DropdownSelector/DropdownPopover.js.map +1 -1
- package/dist/components/DropdownSelector/ListItem/index.d.ts +1 -1
- package/dist/components/DropdownSelector/ListItem/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/ListItem/index2.cjs +0 -1
- package/dist/components/DropdownSelector/ListItem/index2.cjs.map +1 -1
- package/dist/components/DropdownSelector/ListItem/index2.js.map +1 -1
- package/dist/components/DropdownSelector/MenuItem/index.cjs +29 -2
- package/dist/components/DropdownSelector/MenuItem/index.cjs.map +1 -1
- package/dist/components/DropdownSelector/MenuItem/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/MenuItem/index.js +30 -2
- package/dist/components/DropdownSelector/MenuItem/index.js.map +1 -1
- package/dist/components/DropdownSelector/MenuItem/internals/handleFocusByKeyBoard.cjs.map +1 -1
- package/dist/components/DropdownSelector/MenuItem/internals/handleFocusByKeyBoard.js.map +1 -1
- package/dist/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.cjs +0 -1
- package/dist/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.cjs.map +1 -1
- package/dist/components/DropdownSelector/MenuItem/internals/useMenuItemHandleKeyDown.js.map +1 -1
- package/dist/components/DropdownSelector/MenuItemGroup/index2.cjs +0 -1
- package/dist/components/DropdownSelector/MenuItemGroup/index2.cjs.map +1 -1
- package/dist/components/DropdownSelector/MenuItemGroup/index2.js.map +1 -1
- package/dist/components/DropdownSelector/MenuList/MenuListContext.cjs +0 -1
- package/dist/components/DropdownSelector/MenuList/MenuListContext.cjs.map +1 -1
- package/dist/components/DropdownSelector/MenuList/MenuListContext.js.map +1 -1
- package/dist/components/DropdownSelector/MenuList/index2.cjs +0 -1
- package/dist/components/DropdownSelector/MenuList/index2.cjs.map +1 -1
- package/dist/components/DropdownSelector/MenuList/index2.js.map +1 -1
- package/dist/components/DropdownSelector/MenuList/internals/getValuesRecursive.cjs +1 -1
- package/dist/components/DropdownSelector/MenuList/internals/getValuesRecursive.cjs.map +1 -1
- package/dist/components/DropdownSelector/MenuList/internals/getValuesRecursive.js.map +1 -1
- package/dist/components/DropdownSelector/Popover/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/Popover/index2.cjs +18 -1
- package/dist/components/DropdownSelector/Popover/index2.cjs.map +1 -1
- package/dist/components/DropdownSelector/Popover/index2.js +19 -1
- package/dist/components/DropdownSelector/Popover/index2.js.map +1 -1
- package/dist/components/DropdownSelector/Popover/usePreventScroll.cjs +0 -1
- package/dist/components/DropdownSelector/Popover/usePreventScroll.cjs.map +1 -1
- package/dist/components/DropdownSelector/Popover/usePreventScroll.js.map +1 -1
- package/dist/components/DropdownSelector/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/index2.cjs +27 -10
- package/dist/components/DropdownSelector/index2.cjs.map +1 -1
- package/dist/components/DropdownSelector/index2.js +26 -9
- package/dist/components/DropdownSelector/index2.js.map +1 -1
- package/dist/components/DropdownSelector/utils/findPreviewRecursive.cjs +1 -1
- package/dist/components/DropdownSelector/utils/findPreviewRecursive.cjs.map +1 -1
- package/dist/components/DropdownSelector/utils/findPreviewRecursive.js.map +1 -1
- package/dist/components/FieldLabel/index.d.ts.map +1 -1
- package/dist/components/FieldLabel/index2.cjs +1 -1
- package/dist/components/FieldLabel/index2.cjs.map +1 -1
- package/dist/components/FieldLabel/index2.js.map +1 -1
- package/dist/components/HintText/index2.cjs +0 -1
- package/dist/components/HintText/index2.cjs.map +1 -1
- package/dist/components/HintText/index2.js.map +1 -1
- package/dist/components/Icon/index.cjs +1 -1
- package/dist/components/Icon/index.cjs.map +1 -1
- package/dist/components/Icon/index.d.ts.map +1 -1
- package/dist/components/Icon/index.js.map +1 -1
- package/dist/components/IconButton/index.d.ts +1 -1
- package/dist/components/IconButton/index.d.ts.map +1 -1
- package/dist/components/IconButton/index2.cjs +1 -1
- package/dist/components/IconButton/index2.cjs.map +1 -1
- package/dist/components/IconButton/index2.js.map +1 -1
- package/dist/components/LoadingSpinner/index.d.ts.map +1 -1
- package/dist/components/LoadingSpinner/index2.cjs +0 -1
- package/dist/components/LoadingSpinner/index2.cjs.map +1 -1
- package/dist/components/LoadingSpinner/index2.js.map +1 -1
- package/dist/components/Modal/Dialog/index2.cjs +1 -1
- package/dist/components/Modal/Dialog/index2.cjs.map +1 -1
- package/dist/components/Modal/Dialog/index2.js.map +1 -1
- package/dist/components/Modal/ModalBackgroundContext.cjs +1 -1
- package/dist/components/Modal/ModalBackgroundContext.cjs.map +1 -1
- package/dist/components/Modal/ModalBackgroundContext.js.map +1 -1
- package/dist/components/Modal/ModalPlumbing.d.ts +3 -3
- package/dist/components/Modal/ModalPlumbing2.cjs +0 -1
- package/dist/components/Modal/ModalPlumbing2.cjs.map +1 -1
- package/dist/components/Modal/ModalPlumbing2.js.map +1 -1
- package/dist/components/Modal/index.d.ts.map +1 -1
- package/dist/components/Modal/index2.cjs +1 -1
- package/dist/components/Modal/index2.cjs.map +1 -1
- package/dist/components/Modal/index2.js.map +1 -1
- package/dist/components/Modal/useCustomModalOverlay.cjs +1 -1
- package/dist/components/Modal/useCustomModalOverlay.cjs.map +1 -1
- package/dist/components/Modal/useCustomModalOverlay.js.map +1 -1
- package/dist/components/Modal/useTransitionPresence.cjs +1 -3
- package/dist/components/Modal/useTransitionPresence.cjs.map +1 -1
- package/dist/components/Modal/useTransitionPresence.js +1 -2
- package/dist/components/Modal/useTransitionPresence.js.map +1 -1
- package/dist/components/MultiSelect/context.cjs +0 -1
- package/dist/components/MultiSelect/context.cjs.map +1 -1
- package/dist/components/MultiSelect/context.js.map +1 -1
- package/dist/components/MultiSelect/index.d.ts +1 -1
- package/dist/components/MultiSelect/index.d.ts.map +1 -1
- package/dist/components/MultiSelect/index2.cjs +2 -2
- package/dist/components/MultiSelect/index2.cjs.map +1 -1
- package/dist/components/MultiSelect/index2.js.map +1 -1
- package/dist/components/Pagination/PaginationContext.cjs +0 -1
- package/dist/components/Pagination/PaginationContext.cjs.map +1 -1
- package/dist/components/Pagination/PaginationContext.js.map +1 -1
- package/dist/components/Pagination/helper.cjs.map +1 -1
- package/dist/components/Pagination/helper.js.map +1 -1
- package/dist/components/Pagination/index2.cjs +26 -135
- package/dist/components/Pagination/index2.cjs.map +1 -1
- package/dist/components/Pagination/index2.js +86 -182
- package/dist/components/Pagination/index2.js.map +1 -1
- package/dist/components/Radio/RadioGroup/index2.cjs +1 -1
- package/dist/components/Radio/RadioGroup/index2.cjs.map +1 -1
- package/dist/components/Radio/RadioGroup/index2.js.map +1 -1
- package/dist/components/Radio/RadioGroupContext.cjs.map +1 -1
- package/dist/components/Radio/RadioGroupContext.js.map +1 -1
- package/dist/components/Radio/RadioInput/index.d.ts.map +1 -1
- package/dist/components/Radio/RadioInput/index2.cjs +0 -1
- package/dist/components/Radio/RadioInput/index2.cjs.map +1 -1
- package/dist/components/Radio/RadioInput/index2.js.map +1 -1
- package/dist/components/Radio/index.d.ts.map +1 -1
- package/dist/components/Radio/index2.cjs +2 -2
- package/dist/components/Radio/index2.cjs.map +1 -1
- package/dist/components/Radio/index2.js.map +1 -1
- package/dist/components/SegmentedControl/RadioGroupContext.cjs +1 -1
- package/dist/components/SegmentedControl/RadioGroupContext.cjs.map +1 -1
- package/dist/components/SegmentedControl/RadioGroupContext.js.map +1 -1
- package/dist/components/SegmentedControl/index.d.ts.map +1 -1
- package/dist/components/SegmentedControl/index2.cjs +1 -1
- package/dist/components/SegmentedControl/index2.cjs.map +1 -1
- package/dist/components/SegmentedControl/index2.js.map +1 -1
- package/dist/components/Switch/SwitchInput/index.d.ts.map +1 -1
- package/dist/components/Switch/SwitchInput/index2.cjs +0 -1
- package/dist/components/Switch/SwitchInput/index2.cjs.map +1 -1
- package/dist/components/Switch/SwitchInput/index2.js.map +1 -1
- package/dist/components/Switch/SwitchWithLabel.cjs +1 -1
- package/dist/components/Switch/SwitchWithLabel.cjs.map +1 -1
- package/dist/components/Switch/SwitchWithLabel.d.ts +2 -2
- package/dist/components/Switch/SwitchWithLabel.d.ts.map +1 -1
- package/dist/components/Switch/SwitchWithLabel.js.map +1 -1
- package/dist/components/Switch/index.d.ts +1 -1
- package/dist/components/Switch/index.d.ts.map +1 -1
- package/dist/components/Switch/index2.cjs +0 -1
- package/dist/components/Switch/index2.cjs.map +1 -1
- package/dist/components/Switch/index2.js.map +1 -1
- package/dist/components/TagItem/index.d.ts +1 -1
- package/dist/components/TagItem/index.d.ts.map +1 -1
- package/dist/components/TagItem/index2.cjs +1 -1
- package/dist/components/TagItem/index2.cjs.map +1 -1
- package/dist/components/TagItem/index2.js.map +1 -1
- package/dist/components/TextArea/index.d.ts.map +1 -1
- package/dist/components/TextArea/index2.cjs +0 -1
- package/dist/components/TextArea/index2.cjs.map +1 -1
- package/dist/components/TextArea/index2.js.map +1 -1
- package/dist/components/TextEllipsis/helper.cjs +2 -1
- package/dist/components/TextEllipsis/helper.cjs.map +1 -1
- package/dist/components/TextEllipsis/helper.d.ts.map +1 -1
- package/dist/components/TextEllipsis/helper.js +1 -1
- package/dist/components/TextEllipsis/helper.js.map +1 -1
- package/dist/components/TextEllipsis/index2.cjs +14 -98
- package/dist/components/TextEllipsis/index2.cjs.map +1 -1
- package/dist/components/TextEllipsis/index2.js +14 -93
- package/dist/components/TextEllipsis/index2.js.map +1 -1
- package/dist/components/TextField/AssistiveText/index.d.ts +1 -1
- package/dist/components/TextField/AssistiveText/index2.cjs.map +1 -1
- package/dist/components/TextField/AssistiveText/index2.js.map +1 -1
- package/dist/components/TextField/index.d.ts +1 -1
- package/dist/components/TextField/index.d.ts.map +1 -1
- package/dist/components/TextField/index2.cjs +1 -1
- package/dist/components/TextField/index2.cjs.map +1 -1
- package/dist/components/TextField/index2.js.map +1 -1
- package/dist/components/TextField/useFocusWithClick.cjs +0 -1
- package/dist/components/TextField/useFocusWithClick.cjs.map +1 -1
- package/dist/components/TextField/useFocusWithClick.js.map +1 -1
- package/dist/core/CharcoalProvider.cjs +1 -1
- package/dist/core/CharcoalProvider.cjs.map +1 -1
- package/dist/core/CharcoalProvider.js.map +1 -1
- package/dist/core/SSRProvider.cjs +1 -1
- package/dist/core/SSRProvider.cjs.map +1 -1
- package/dist/core/SSRProvider.js +1 -1
- package/dist/core/SSRProvider.js.map +1 -1
- package/dist/core/SetThemeScript.cjs +0 -1
- package/dist/core/SetThemeScript.cjs.map +1 -1
- package/dist/core/SetThemeScript.js.map +1 -1
- package/dist/core/themeHelper.cjs +0 -1
- package/dist/core/themeHelper.cjs.map +1 -1
- package/dist/core/themeHelper.d.ts +2 -2
- package/dist/core/themeHelper.d.ts.map +1 -1
- package/dist/core/themeHelper.js.map +1 -1
- package/dist/index.cjs +22 -23
- package/dist/index.css +1000 -1000
- package/dist/layered.css +1000 -1000
- package/dist/layered.css.map +1 -1
- package/package.json +10 -10
- package/src/_lib/compat.ts +1 -7
- package/src/components/Carousel/index.browser.test.tsx +1 -1
- package/src/components/Carousel/intersectionObserver.test.ts +12 -12
- package/src/components/Carousel/resizeObserver.test.ts +1 -1
- package/src/components/DropdownSelector/MenuItem/index.tsx +40 -2
- package/src/components/DropdownSelector/Popover/index.tsx +20 -1
- package/src/components/DropdownSelector/index.browser.test.tsx +94 -0
- package/src/components/DropdownSelector/index.test.tsx +57 -2
- package/src/components/DropdownSelector/index.tsx +37 -12
- package/src/components/FieldLabel/index.tsx +1 -2
- package/src/components/Icon/index.tsx +2 -1
- package/src/components/Modal/__snapshots__/index.css.snap +1 -0
- package/src/components/TextEllipsis/TextEllipsis.story.tsx +1 -1
- package/src/css.d.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compat.d.ts","sourceRoot":"","sources":["../../src/_lib/compat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B;;;;;;GAMG;AACH,MAAM,WAAW,2BAA2B,CAAC,CAAC,GAAG,OAAO;IACtD,QAAQ,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAA;IAChD,QAAQ,CAAC,OAAO,CAAC,EAAE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AK,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAA;IAC5D,QAAQ,CAAC,mBAAmB,CAAC,EAAE,KAAK,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAA;IAC/D,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAA;IAC9C,QAAQ,CAAC,aAAa,CAAC,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAA;IAClD,QAAQ,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAA;IAC5C,QAAQ,CAAC,cAAc,CAAC,EACtB,MAAM,GAAG,IAAI,GAAG,KAAK,GAAG,WAAW,GAAG,OAAO,GAAG,YAAY,GAAG,SAAS,CAAA;CAC3E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createDivComponent.cjs","names":[
|
|
1
|
+
{"version":3,"file":"createDivComponent.cjs","names":[],"sources":["../../src/_lib/createDivComponent.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport { useClassNames } from './useClassNames'\n\nexport function createDivComponent(mainClassName: string) {\n return forwardRef<HTMLDivElement, React.ComponentPropsWithRef<'div'>>(\n function DivComponent({ className, ...props }, ref) {\n const classNames = useClassNames(mainClassName, className)\n return <div className={classNames} ref={ref} {...props} />\n },\n )\n}\n"],"mappings":";;;;;;AAGA,SAAgB,mBAAmB,eAAuB;CACxD,6BACE,SAAS,aAAa,EAAE,WAAW,GAAG,SAAS,KAAK;EAElD,OAAO,2CAAC,OAAD;GAAK,WADO,oCAAc,eAAe,SACzB;GAAiB;GAAK,GAAI;EAAM;CACzD,CACF;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare function createDivComponent(mainClassName: string): import("react").ForwardRefExoticComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
2
|
-
ref?: ((instance: HTMLDivElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) |
|
|
2
|
+
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | null | undefined;
|
|
3
3
|
}, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
4
4
|
//# sourceMappingURL=createDivComponent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createDivComponent.js","names":[
|
|
1
|
+
{"version":3,"file":"createDivComponent.js","names":[],"sources":["../../src/_lib/createDivComponent.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport { useClassNames } from './useClassNames'\n\nexport function createDivComponent(mainClassName: string) {\n return forwardRef<HTMLDivElement, React.ComponentPropsWithRef<'div'>>(\n function DivComponent({ className, ...props }, ref) {\n const classNames = useClassNames(mainClassName, className)\n return <div className={classNames} ref={ref} {...props} />\n },\n )\n}\n"],"mappings":";;;;;;AAGA,SAAgB,mBAAmB,eAAuB;CACxD,OAAO,WACL,SAAS,aAAa,EAAE,WAAW,GAAG,SAAS,KAAK;EAElD,OAAO,oBAAC,OAAD;GAAK,WADO,cAAc,eAAe,SACzB;GAAiB;GAAK,GAAI;EAAM;CACzD,CACF;AACF"}
|
package/dist/_lib/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":[
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../../src/_lib/index.ts"],"sourcesContent":["/**\n * 今後ポートされる予定の汎用的な関数群\n */\n\n/**\n * Function used to assert a given code path is unreachable\n */\nexport function unreachable(): never\n/**\n * Function used to assert a given code path is unreachable.\n * Very useful for ensuring switches are exhaustive:\n *\n * ```ts\n * switch (a.type) {\n * case Types.A:\n * case Types.B:\n * break\n * default:\n * unreachable(a) // will cause a build error if there was\n * // a Types.C that was not checked\n * }\n * ```\n *\n * @param value Value to be asserted as unreachable\n */\n// NOTE: Uses separate overloads, _not_ `value?: never`, to not allow `undefined` to be passed\n\nexport function unreachable(value: never): never\nexport function unreachable(value?: never): never {\n throw new Error(\n arguments.length === 0\n ? 'unreachable'\n : `unreachable (${JSON.stringify(value)})`,\n )\n}\n\n/**\n * 複数のrefをマージする。\n *\n * forwardRefで受け取ったrefと、コンポーネント内で定義したrefを同じ要素につけたいケースなどで使う\n */\nexport function mergeRefs<T>(...refs: React.Ref<T>[]): React.RefCallback<T> {\n return (value) => {\n for (const ref of refs) {\n if (typeof ref === 'function') {\n ref(value)\n } else if (ref !== null) {\n // TODO: use RefObject\n // https://react.dev/blog/2024/04/25/react-19-upgrade-guide#:~:text=%3D%201%3B-,MutableRef,-is%20now%20deprecated\n ;(ref as React.MutableRefObject<T | null>).current = value\n }\n }\n }\n}\n\nexport function countCodePointsInString(string: string) {\n // [...string] とするとproduction buildで動かなくなる\n // cf. https://twitter.com/f_subal/status/1497214727511891972\n return Array.from(string).length\n}\n"],"mappings":";;;;;;;;AAyCA,SAAgB,UAAa,GAAG,MAA4C;CAC1E,QAAQ,UAAU;EAChB,KAAK,MAAM,OAAO,MAChB,IAAI,OAAO,QAAQ,YACjB,IAAI,KAAK;OACJ,IAAI,QAAQ,MAGhB,AAAC,IAAyC,UAAU;CAG3D;AACF;AAEA,SAAgB,wBAAwB,QAAgB;CAGtD,OAAO,MAAM,KAAK,MAAM,CAAC,CAAC;AAC5B"}
|
package/dist/_lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/_lib/index.ts"],"sourcesContent":["/**\n * 今後ポートされる予定の汎用的な関数群\n */\n\n/**\n * Function used to assert a given code path is unreachable\n */\nexport function unreachable(): never\n/**\n * Function used to assert a given code path is unreachable.\n * Very useful for ensuring switches are exhaustive:\n *\n * ```ts\n * switch (a.type) {\n * case Types.A:\n * case Types.B:\n * break\n * default:\n * unreachable(a) // will cause a build error if there was\n * // a Types.C that was not checked\n * }\n * ```\n *\n * @param value Value to be asserted as unreachable\n */\n// NOTE: Uses separate overloads, _not_ `value?: never`, to not allow `undefined` to be passed\n\nexport function unreachable(value: never): never\nexport function unreachable(value?: never): never {\n throw new Error(\n arguments.length === 0\n ? 'unreachable'\n : `unreachable (${JSON.stringify(value)})`,\n )\n}\n\n/**\n * 複数のrefをマージする。\n *\n * forwardRefで受け取ったrefと、コンポーネント内で定義したrefを同じ要素につけたいケースなどで使う\n */\nexport function mergeRefs<T>(...refs: React.Ref<T>[]): React.RefCallback<T> {\n return (value) => {\n for (const ref of refs) {\n if (typeof ref === 'function') {\n ref(value)\n } else if (ref !== null) {\n // TODO: use RefObject\n // https://react.dev/blog/2024/04/25/react-19-upgrade-guide#:~:text=%3D%201%3B-,MutableRef,-is%20now%20deprecated\n ;(ref as React.MutableRefObject<T | null>).current = value\n }\n }\n }\n}\n\nexport function countCodePointsInString(string: string) {\n // [...string] とするとproduction buildで動かなくなる\n // cf. https://twitter.com/f_subal/status/1497214727511891972\n return Array.from(string).length\n}\n"],"mappings":";;;;;;;AAyCA,SAAgB,UAAa,GAAG,MAA4C;CAC1E,QAAQ,UAAU;EAChB,KAAK,MAAM,OAAO,MAChB,IAAI,OAAO,QAAQ,YACjB,IAAI,KAAK;OACJ,IAAI,QAAQ,MAGhB,AAAC,IAAyC,UAAU;CAG3D;AACF;AAEA,SAAgB,wBAAwB,QAAgB;CAGtD,OAAO,MAAM,KAAK,MAAM,CAAC,CAAC;AAC5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useClassNames.cjs","names":[
|
|
1
|
+
{"version":3,"file":"useClassNames.cjs","names":[],"sources":["../../src/_lib/useClassNames.ts"],"sourcesContent":["import { useMemo } from 'react'\n\n/**\n * Join some class names if propsClassName is defined.\n */\nexport function useClassNames(...classNames: (string | undefined)[]) {\n return useMemo(() => classNames.filter((v) => v).join(' '), [classNames])\n}\n"],"mappings":";;;;;;;AAKA,SAAgB,cAAc,GAAG,YAAoC;CACnE,gCAAqB,WAAW,QAAQ,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,GAAG,CAAC,UAAU,CAAC;AAC1E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useClassNames.js","names":[
|
|
1
|
+
{"version":3,"file":"useClassNames.js","names":[],"sources":["../../src/_lib/useClassNames.ts"],"sourcesContent":["import { useMemo } from 'react'\n\n/**\n * Join some class names if propsClassName is defined.\n */\nexport function useClassNames(...classNames: (string | undefined)[]) {\n return useMemo(() => classNames.filter((v) => v).join(' '), [classNames])\n}\n"],"mappings":";;;;;;;AAKA,SAAgB,cAAc,GAAG,YAAoC;CACnE,OAAO,cAAc,WAAW,QAAQ,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,GAAG,CAAC,UAAU,CAAC;AAC1E"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
3
|
let react = require("react");
|
|
4
|
-
react = require_runtime.__toESM(react);
|
|
4
|
+
react = require_runtime.__toESM(react, 1);
|
|
5
5
|
|
|
6
6
|
//#region src/_lib/useForwardedRef.tsx
|
|
7
7
|
function useForwardedRef(ref) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useForwardedRef.cjs","names":[
|
|
1
|
+
{"version":3,"file":"useForwardedRef.cjs","names":[],"sources":["../../src/_lib/useForwardedRef.tsx"],"sourcesContent":["import * as React from 'react'\n\nexport function useForwardedRef<T>(ref: React.ForwardedRef<T>) {\n const innerRef = React.useRef<T>(null)\n\n React.useEffect(() => {\n if (!ref) return\n if (typeof ref === 'function') {\n ref(innerRef.current)\n } else {\n // eslint-disable-next-line react-compiler/react-compiler\n ref.current = innerRef.current\n }\n })\n\n return innerRef\n}\n"],"mappings":";;;;;;AAEA,SAAgB,gBAAmB,KAA4B;CAC7D,MAAM,WAAW,MAAM,OAAU,IAAI;CAErC,MAAM,gBAAgB;EACpB,IAAI,CAAC,KAAK;EACV,IAAI,OAAO,QAAQ,YACjB,IAAI,SAAS,OAAO;OAGpB,IAAI,UAAU,SAAS;CAE3B,CAAC;CAED,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useForwardedRef.js","names":[
|
|
1
|
+
{"version":3,"file":"useForwardedRef.js","names":[],"sources":["../../src/_lib/useForwardedRef.tsx"],"sourcesContent":["import * as React from 'react'\n\nexport function useForwardedRef<T>(ref: React.ForwardedRef<T>) {\n const innerRef = React.useRef<T>(null)\n\n React.useEffect(() => {\n if (!ref) return\n if (typeof ref === 'function') {\n ref(innerRef.current)\n } else {\n // eslint-disable-next-line react-compiler/react-compiler\n ref.current = innerRef.current\n }\n })\n\n return innerRef\n}\n"],"mappings":";;;;AAEA,SAAgB,gBAAmB,KAA4B;CAC7D,MAAM,WAAW,QAAM,OAAU,IAAI;CAErC,QAAM,gBAAgB;EACpB,IAAI,CAAC,KAAK;EACV,IAAI,OAAO,QAAQ,YACjB,IAAI,SAAS,OAAO;OAGpB,IAAI,UAAU,SAAS;CAE3B,CAAC;CAED,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIsomorphicLayoutEffect.cjs","names":[
|
|
1
|
+
{"version":3,"file":"useIsomorphicLayoutEffect.cjs","names":[],"sources":["../../src/_lib/useIsomorphicLayoutEffect.ts"],"sourcesContent":["import { useEffect, useLayoutEffect } from 'react'\n\n/**\n * SSR では useLayoutEffect が警告を出すため、サーバーでは useEffect にフォールバックする\n */\nexport const useIsomorphicLayoutEffect =\n typeof window !== 'undefined' ? useLayoutEffect : useEffect\n"],"mappings":";;;;;;;AAKA,MAAa,4BACX,OAAO,WAAW,cAAc,wBAAkB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useLayoutEffect } from 'react';
|
|
2
2
|
/**
|
|
3
3
|
* SSR では useLayoutEffect が警告を出すため、サーバーでは useEffect にフォールバックする
|
|
4
4
|
*/
|
|
5
|
-
export declare const useIsomorphicLayoutEffect: typeof
|
|
5
|
+
export declare const useIsomorphicLayoutEffect: typeof useLayoutEffect;
|
|
6
6
|
//# sourceMappingURL=useIsomorphicLayoutEffect.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIsomorphicLayoutEffect.d.ts","sourceRoot":"","sources":["../../src/_lib/useIsomorphicLayoutEffect.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"useIsomorphicLayoutEffect.d.ts","sourceRoot":"","sources":["../../src/_lib/useIsomorphicLayoutEffect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,eAAe,EAAE,MAAM,OAAO,CAAA;AAElD;;GAEG;AACH,eAAO,MAAM,yBAAyB,wBACuB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIsomorphicLayoutEffect.js","names":[
|
|
1
|
+
{"version":3,"file":"useIsomorphicLayoutEffect.js","names":[],"sources":["../../src/_lib/useIsomorphicLayoutEffect.ts"],"sourcesContent":["import { useEffect, useLayoutEffect } from 'react'\n\n/**\n * SSR では useLayoutEffect が警告を出すため、サーバーでは useEffect にフォールバックする\n */\nexport const useIsomorphicLayoutEffect =\n typeof window !== 'undefined' ? useLayoutEffect : useEffect\n"],"mappings":";;;;;;;AAKA,MAAa,4BACX,OAAO,WAAW,cAAc,kBAAkB"}
|
|
@@ -14,7 +14,7 @@ export type ButtonProps<T extends React.ElementType = 'button'> = {
|
|
|
14
14
|
*/
|
|
15
15
|
component?: T;
|
|
16
16
|
} & Omit<React.ComponentPropsWithRef<T>, 'children'>;
|
|
17
|
-
declare const Button: <T extends React.ElementType =
|
|
17
|
+
declare const Button: <T extends React.ElementType = 'button'>(p: 'button' extends T ? ButtonProps<'button'> : ButtonProps<T> & {
|
|
18
18
|
component: T;
|
|
19
19
|
}) => JSX.Element;
|
|
20
20
|
export default Button;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Button/index.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,OAAO,KAAK,EAAE,EAEZ,SAAS,EAGT,KAAK,GAAG,EACT,MAAM,OAAO,CAAA;AAId,KAAK,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,YAAY,CAAA;AAE1E,KAAK,IAAI,GAAG,GAAG,GAAG,GAAG,CAAA;AAErB,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,QAAQ,IAAI;IAChE,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;OAGG;IACH,SAAS,CAAC,EAAE,CAAC,CAAA;CACd,GAAG,IAAI,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAA;AAEpD,QAAA,MAAM,MAAM,EAyBN,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,QAAQ,EAC3C,CAAC,EAAE,QAAQ,SAAS,CAAC,GACjB,WAAW,CAAC,QAAQ,CAAC,GACrB,WAAW,CAAC,CAAC,CAAC,GAAG;IACf,SAAS,EAAE,CAAC,CAAA;CACb,KACF,GAAG,CAAC,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Button/index.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,OAAO,KAAK,EAAE,EAEZ,SAAS,EAGT,KAAK,GAAG,EACT,MAAM,OAAO,CAAA;AAId,KAAK,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,YAAY,CAAA;AAE1E,KAAK,IAAI,GAAG,GAAG,GAAG,GAAG,CAAA;AAErB,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,QAAQ,IAAI;IAChE,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;OAGG;IACH,SAAS,CAAC,EAAE,CAAC,CAAA;CACd,GAAG,IAAI,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAA;AAEpD,QAAA,MAAM,MAAM,EAyBN,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,QAAQ,EAC3C,CAAC,EAAE,QAAQ,SAAS,CAAC,GACjB,WAAW,CAAC,QAAQ,CAAC,GACrB,WAAW,CAAC,CAAC,CAAC,GAAG;IACf,SAAS,EAAE,CAAC,CAAA;CACb,KACF,GAAG,CAAC,OAAO,CAAA;eACD,MAAM"}
|
|
@@ -3,7 +3,7 @@ const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
|
3
3
|
require('./index.cjs');
|
|
4
4
|
const require_useClassNames = require('../../_lib/useClassNames.cjs');
|
|
5
5
|
let react = require("react");
|
|
6
|
-
react = require_runtime.__toESM(react);
|
|
6
|
+
react = require_runtime.__toESM(react, 1);
|
|
7
7
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
8
|
|
|
9
9
|
//#region src/components/Button/index.tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index2.cjs","names":[
|
|
1
|
+
{"version":3,"file":"index2.cjs","names":[],"sources":["../../../src/components/Button/index.tsx"],"sourcesContent":["import './index.css'\n\nimport React, {\n ForwardedRef,\n ReactNode,\n forwardRef,\n useMemo,\n type JSX,\n} from 'react'\n\nimport { useClassNames } from '../../_lib/useClassNames'\n\ntype Variant = 'Primary' | 'Default' | 'Overlay' | 'Danger' | 'Navigation'\n\ntype Size = 'S' | 'M'\n\nexport type ButtonProps<T extends React.ElementType = 'button'> = {\n children?: ReactNode\n variant?: Variant\n size?: Size\n fullWidth?: boolean\n isActive?: boolean\n /**\n * The component used for root element.\n * @type T extends React.ElementType = 'button'\n */\n component?: T\n} & Omit<React.ComponentPropsWithRef<T>, 'children'>\n\nconst Button = forwardRef(function Button<T extends React.ElementType>(\n {\n variant,\n fullWidth,\n size,\n className,\n component,\n isActive,\n ...props\n }: ButtonProps<T>,\n ref: ForwardedRef<HTMLButtonElement>,\n) {\n const Component = useMemo(() => component ?? 'button', [component])\n const classNames = useClassNames('charcoal-button', className)\n return (\n <Component\n {...props}\n className={classNames}\n data-variant={variant}\n data-size={size}\n data-full-width={fullWidth}\n data-active={isActive}\n ref={ref}\n />\n )\n}) as <T extends React.ElementType = 'button'>(\n p: 'button' extends T\n ? ButtonProps<'button'>\n : ButtonProps<T> & {\n component: T // required\n },\n) => JSX.Element\nexport default Button\n"],"mappings":";;;;;;;;;AA6BA,MAAM,+BAAoB,SAAS,OACjC,EACE,SACA,WACA,MACA,WACA,WACA,UACA,GAAG,SAEL,KACA;CACA,MAAM,qCAA0B,aAAa,UAAU,CAAC,SAAS,CAAC;CAClE,MAAM,aAAa,oCAAc,mBAAmB,SAAS;CAC7D,OACE,2CAAC,WAAD;EACE,GAAI;EACJ,WAAW;EACX,gBAAc;EACd,aAAW;EACX,mBAAiB;EACjB,eAAa;EACR;CAAI;AAGf,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index2.js","names":[
|
|
1
|
+
{"version":3,"file":"index2.js","names":[],"sources":["../../../src/components/Button/index.tsx"],"sourcesContent":["import './index.css'\n\nimport React, {\n ForwardedRef,\n ReactNode,\n forwardRef,\n useMemo,\n type JSX,\n} from 'react'\n\nimport { useClassNames } from '../../_lib/useClassNames'\n\ntype Variant = 'Primary' | 'Default' | 'Overlay' | 'Danger' | 'Navigation'\n\ntype Size = 'S' | 'M'\n\nexport type ButtonProps<T extends React.ElementType = 'button'> = {\n children?: ReactNode\n variant?: Variant\n size?: Size\n fullWidth?: boolean\n isActive?: boolean\n /**\n * The component used for root element.\n * @type T extends React.ElementType = 'button'\n */\n component?: T\n} & Omit<React.ComponentPropsWithRef<T>, 'children'>\n\nconst Button = forwardRef(function Button<T extends React.ElementType>(\n {\n variant,\n fullWidth,\n size,\n className,\n component,\n isActive,\n ...props\n }: ButtonProps<T>,\n ref: ForwardedRef<HTMLButtonElement>,\n) {\n const Component = useMemo(() => component ?? 'button', [component])\n const classNames = useClassNames('charcoal-button', className)\n return (\n <Component\n {...props}\n className={classNames}\n data-variant={variant}\n data-size={size}\n data-full-width={fullWidth}\n data-active={isActive}\n ref={ref}\n />\n )\n}) as <T extends React.ElementType = 'button'>(\n p: 'button' extends T\n ? ButtonProps<'button'>\n : ButtonProps<T> & {\n component: T // required\n },\n) => JSX.Element\nexport default Button\n"],"mappings":";;;;;;;AA6BA,MAAM,SAAS,WAAW,SAAS,OACjC,EACE,SACA,WACA,MACA,WACA,WACA,UACA,GAAG,SAEL,KACA;CACA,MAAM,YAAY,cAAc,aAAa,UAAU,CAAC,SAAS,CAAC;CAClE,MAAM,aAAa,cAAc,mBAAmB,SAAS;CAC7D,OACE,oBAAC,WAAD;EACE,GAAI;EACJ,WAAW;EACX,gBAAc;EACd,aAAW;EACX,mBAAiB;EACjB,eAAa;EACR;CAAI;AAGf,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CarouselItem.cjs","names":[
|
|
1
|
+
{"version":3,"file":"CarouselItem.cjs","names":[],"sources":["../../../src/components/Carousel/CarouselItem.tsx"],"sourcesContent":["import { useEffect, useRef, type ReactNode } from 'react'\nimport type { CarouselStore } from './carouselStore'\nimport { observeCenter } from './intersectionObserver'\nimport { observeResize } from './resizeObserver'\n\nexport type CarouselItemProps = Readonly<{\n index: number\n store: CarouselStore\n onResize: () => void\n children: ReactNode\n}>\n\nexport const CarouselItem = ({\n index,\n store,\n onResize,\n children,\n}: CarouselItemProps) => {\n const ref = useRef<HTMLDivElement>(null)\n\n // activeIndex: 自分が中央に来たら store に報告する(root は親=scroller から導出)。\n useEffect(() => {\n const el = ref.current\n if (!el) return\n return observeCenter(el, () => store.dispatch({ type: 'setActive', index }))\n }, [index, store])\n\n // scrollToItem: 自分宛ての命令でだけ自己スクロールする(再レンダーしない)。\n useEffect(() => {\n let lastNonce = store.getSnapshot().scroll?.nonce ?? 0\n return store.subscribe(() => {\n const scroll = store.getSnapshot().scroll\n if (!scroll || scroll.index !== index || scroll.nonce === lastNonce)\n return\n lastNonce = scroll.nonce\n ref.current?.scrollIntoView({\n behavior: 'smooth',\n inline: 'center',\n block: 'nearest',\n })\n })\n }, [index, store])\n\n // 遅延コンテンツ: 自分のサイズ変化を onResize で通知する。\n useEffect(() => {\n const el = ref.current\n if (!el) return\n return observeResize(el, onResize)\n }, [onResize])\n\n return (\n <div ref={ref} className=\"charcoal-carousel__item\">\n {children}\n </div>\n )\n}\n"],"mappings":";;;;;;;AAYA,MAAa,gBAAgB,EAC3B,OACA,OACA,UACA,eACuB;CACvB,MAAM,wBAA6B,IAAI;CAGvC,2BAAgB;EACd,MAAM,KAAK,IAAI;EACf,IAAI,CAAC,IAAI;EACT,OAAO,2CAAc,UAAU,MAAM,SAAS;GAAE,MAAM;GAAa;EAAM,CAAC,CAAC;CAC7E,GAAG,CAAC,OAAO,KAAK,CAAC;CAGjB,2BAAgB;EACd,IAAI,YAAY,MAAM,YAAY,CAAC,CAAC,QAAQ,SAAS;EACrD,OAAO,MAAM,gBAAgB;GAC3B,MAAM,SAAS,MAAM,YAAY,CAAC,CAAC;GACnC,IAAI,CAAC,UAAU,OAAO,UAAU,SAAS,OAAO,UAAU,WACxD;GACF,YAAY,OAAO;GACnB,IAAI,SAAS,eAAe;IAC1B,UAAU;IACV,QAAQ;IACR,OAAO;GACT,CAAC;EACH,CAAC;CACH,GAAG,CAAC,OAAO,KAAK,CAAC;CAGjB,2BAAgB;EACd,MAAM,KAAK,IAAI;EACf,IAAI,CAAC,IAAI;EACT,OAAO,qCAAc,IAAI,QAAQ;CACnC,GAAG,CAAC,QAAQ,CAAC;CAEb,OACE,2CAAC,OAAD;EAAU;EAAK,WAAU;EACtB;CACE;AAET"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CarouselItem.d.ts","sourceRoot":"","sources":["../../../src/components/Carousel/CarouselItem.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAIpD,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IACvC,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,aAAa,CAAA;IACpB,QAAQ,EAAE,MAAM,IAAI,CAAA;IACpB,QAAQ,EAAE,SAAS,CAAA;CACpB,CAAC,CAAA;AAEF,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"CarouselItem.d.ts","sourceRoot":"","sources":["../../../src/components/Carousel/CarouselItem.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAIpD,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IACvC,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,aAAa,CAAA;IACpB,QAAQ,EAAE,MAAM,IAAI,CAAA;IACpB,QAAQ,EAAE,SAAS,CAAA;CACpB,CAAC,CAAA;AAEF,eAAO,MAAM,YAAY,0CAKtB,iBAAiB,4CAsCnB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CarouselItem.js","names":[
|
|
1
|
+
{"version":3,"file":"CarouselItem.js","names":[],"sources":["../../../src/components/Carousel/CarouselItem.tsx"],"sourcesContent":["import { useEffect, useRef, type ReactNode } from 'react'\nimport type { CarouselStore } from './carouselStore'\nimport { observeCenter } from './intersectionObserver'\nimport { observeResize } from './resizeObserver'\n\nexport type CarouselItemProps = Readonly<{\n index: number\n store: CarouselStore\n onResize: () => void\n children: ReactNode\n}>\n\nexport const CarouselItem = ({\n index,\n store,\n onResize,\n children,\n}: CarouselItemProps) => {\n const ref = useRef<HTMLDivElement>(null)\n\n // activeIndex: 自分が中央に来たら store に報告する(root は親=scroller から導出)。\n useEffect(() => {\n const el = ref.current\n if (!el) return\n return observeCenter(el, () => store.dispatch({ type: 'setActive', index }))\n }, [index, store])\n\n // scrollToItem: 自分宛ての命令でだけ自己スクロールする(再レンダーしない)。\n useEffect(() => {\n let lastNonce = store.getSnapshot().scroll?.nonce ?? 0\n return store.subscribe(() => {\n const scroll = store.getSnapshot().scroll\n if (!scroll || scroll.index !== index || scroll.nonce === lastNonce)\n return\n lastNonce = scroll.nonce\n ref.current?.scrollIntoView({\n behavior: 'smooth',\n inline: 'center',\n block: 'nearest',\n })\n })\n }, [index, store])\n\n // 遅延コンテンツ: 自分のサイズ変化を onResize で通知する。\n useEffect(() => {\n const el = ref.current\n if (!el) return\n return observeResize(el, onResize)\n }, [onResize])\n\n return (\n <div ref={ref} className=\"charcoal-carousel__item\">\n {children}\n </div>\n )\n}\n"],"mappings":";;;;;;;AAYA,MAAa,gBAAgB,EAC3B,OACA,OACA,UACA,eACuB;CACvB,MAAM,MAAM,OAAuB,IAAI;CAGvC,gBAAgB;EACd,MAAM,KAAK,IAAI;EACf,IAAI,CAAC,IAAI;EACT,OAAO,cAAc,UAAU,MAAM,SAAS;GAAE,MAAM;GAAa;EAAM,CAAC,CAAC;CAC7E,GAAG,CAAC,OAAO,KAAK,CAAC;CAGjB,gBAAgB;EACd,IAAI,YAAY,MAAM,YAAY,CAAC,CAAC,QAAQ,SAAS;EACrD,OAAO,MAAM,gBAAgB;GAC3B,MAAM,SAAS,MAAM,YAAY,CAAC,CAAC;GACnC,IAAI,CAAC,UAAU,OAAO,UAAU,SAAS,OAAO,UAAU,WACxD;GACF,YAAY,OAAO;GACnB,IAAI,SAAS,eAAe;IAC1B,UAAU;IACV,QAAQ;IACR,OAAO;GACT,CAAC;EACH,CAAC;CACH,GAAG,CAAC,OAAO,KAAK,CAAC;CAGjB,gBAAgB;EACd,MAAM,KAAK,IAAI;EACf,IAAI,CAAC,IAAI;EACT,OAAO,cAAc,IAAI,QAAQ;CACnC,GAAG,CAAC,QAAQ,CAAC;CAEb,OACE,oBAAC,OAAD;EAAU;EAAK,WAAU;EACtB;CACE;AAET"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"carouselStore.cjs","names":[
|
|
1
|
+
{"version":3,"file":"carouselStore.cjs","names":[],"sources":["../../../src/components/Carousel/carouselStore.ts"],"sourcesContent":["import { createStore, type Store } from './store'\n\nexport type CarouselState = Readonly<{\n activeIndex: number\n canPrev: boolean\n canNext: boolean\n scroll: { index: number; nonce: number } | null\n}>\n\nexport type CarouselAction =\n | { type: 'setActive'; index: number }\n | { type: 'setScrollState'; canPrev: boolean; canNext: boolean }\n | { type: 'requestScroll'; index: number }\n\nexport type CarouselStore = Store<CarouselState, CarouselAction>\n\nexport const INITIAL_CAROUSEL_STATE: CarouselState = {\n activeIndex: 0,\n canPrev: false,\n canNext: false,\n scroll: null,\n}\n\nconst reducer = (\n state: CarouselState,\n action: CarouselAction,\n): CarouselState => {\n switch (action.type) {\n case 'setActive':\n return state.activeIndex === action.index\n ? state\n : { ...state, activeIndex: action.index }\n case 'setScrollState':\n return state.canPrev === action.canPrev &&\n state.canNext === action.canNext\n ? state\n : { ...state, canPrev: action.canPrev, canNext: action.canNext }\n case 'requestScroll':\n return {\n ...state,\n scroll: { index: action.index, nonce: (state.scroll?.nonce ?? 0) + 1 },\n }\n }\n}\n\nexport function createCarouselStore(): CarouselStore {\n return createStore(reducer, INITIAL_CAROUSEL_STATE)\n}\n"],"mappings":";;;;AAgBA,MAAa,yBAAwC;CACnD,aAAa;CACb,SAAS;CACT,SAAS;CACT,QAAQ;AACV;AAEA,MAAM,WACJ,OACA,WACkB;CAClB,QAAQ,OAAO,MAAf;EACE,KAAK,aACH,OAAO,MAAM,gBAAgB,OAAO,QAChC,QACA;GAAE,GAAG;GAAO,aAAa,OAAO;EAAM;EAC5C,KAAK,kBACH,OAAO,MAAM,YAAY,OAAO,WAC9B,MAAM,YAAY,OAAO,UACvB,QACA;GAAE,GAAG;GAAO,SAAS,OAAO;GAAS,SAAS,OAAO;EAAQ;EACnE,KAAK,iBACH,OAAO;GACL,GAAG;GACH,QAAQ;IAAE,OAAO,OAAO;IAAO,QAAQ,MAAM,QAAQ,SAAS,KAAK;GAAE;EACvE;CACJ;AACF;AAEA,SAAgB,sBAAqC;CACnD,OAAO,0BAAY,SAAS,sBAAsB;AACpD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"carouselStore.js","names":[
|
|
1
|
+
{"version":3,"file":"carouselStore.js","names":[],"sources":["../../../src/components/Carousel/carouselStore.ts"],"sourcesContent":["import { createStore, type Store } from './store'\n\nexport type CarouselState = Readonly<{\n activeIndex: number\n canPrev: boolean\n canNext: boolean\n scroll: { index: number; nonce: number } | null\n}>\n\nexport type CarouselAction =\n | { type: 'setActive'; index: number }\n | { type: 'setScrollState'; canPrev: boolean; canNext: boolean }\n | { type: 'requestScroll'; index: number }\n\nexport type CarouselStore = Store<CarouselState, CarouselAction>\n\nexport const INITIAL_CAROUSEL_STATE: CarouselState = {\n activeIndex: 0,\n canPrev: false,\n canNext: false,\n scroll: null,\n}\n\nconst reducer = (\n state: CarouselState,\n action: CarouselAction,\n): CarouselState => {\n switch (action.type) {\n case 'setActive':\n return state.activeIndex === action.index\n ? state\n : { ...state, activeIndex: action.index }\n case 'setScrollState':\n return state.canPrev === action.canPrev &&\n state.canNext === action.canNext\n ? state\n : { ...state, canPrev: action.canPrev, canNext: action.canNext }\n case 'requestScroll':\n return {\n ...state,\n scroll: { index: action.index, nonce: (state.scroll?.nonce ?? 0) + 1 },\n }\n }\n}\n\nexport function createCarouselStore(): CarouselStore {\n return createStore(reducer, INITIAL_CAROUSEL_STATE)\n}\n"],"mappings":";;;;AAgBA,MAAa,yBAAwC;CACnD,aAAa;CACb,SAAS;CACT,SAAS;CACT,QAAQ;AACV;AAEA,MAAM,WACJ,OACA,WACkB;CAClB,QAAQ,OAAO,MAAf;EACE,KAAK,aACH,OAAO,MAAM,gBAAgB,OAAO,QAChC,QACA;GAAE,GAAG;GAAO,aAAa,OAAO;EAAM;EAC5C,KAAK,kBACH,OAAO,MAAM,YAAY,OAAO,WAC9B,MAAM,YAAY,OAAO,UACvB,QACA;GAAE,GAAG;GAAO,SAAS,OAAO;GAAS,SAAS,OAAO;EAAQ;EACnE,KAAK,iBACH,OAAO;GACL,GAAG;GACH,QAAQ;IAAE,OAAO,OAAO;IAAO,QAAQ,MAAM,QAAQ,SAAS,KAAK;GAAE;EACvE;CACJ;AACF;AAEA,SAAgB,sBAAqC;CACnD,OAAO,YAAY,SAAS,sBAAsB;AACpD"}
|
|
@@ -42,7 +42,7 @@ declare const _default: import("react").MemoExoticComponent<import("react").Forw
|
|
|
42
42
|
fullWidth?: boolean;
|
|
43
43
|
navigationButtons?: boolean;
|
|
44
44
|
indicator?: boolean;
|
|
45
|
-
size?:
|
|
45
|
+
size?: 'S' | 'M';
|
|
46
46
|
scrollStep?: ScrollStep;
|
|
47
47
|
scrollSnap?: ScrollSnap;
|
|
48
48
|
onScroll?: (left: number) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Carousel/index.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,OAAO,EAYL,KAAK,SAAS,EACf,MAAM,OAAO,CAAA;AAcd,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAA;AAErD,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,WAAW,GAAG,WAAW,CAAA;AAE/D,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,OAAO,CAAA;AAEhD,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,IAAI,CAAC,EAAE,cAAc,CAAA;IACrB,KAAK,CAAC,EAAE,eAAe,CAAA;CACxB,CAAC,CAAA;AAEF,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IACvC,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,GAAG,MAAM,CAAA;CAC3B,CAAC,CAAA;AAEF,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,iBAAiB,KAAK,MAAM,CAAC,CAAA;AAGtE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,WAAW,EAAE,MAAM,IAAI,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC;IACnC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,IAAI,CAAC,EAAE,GAAG,GAAG,GAAG,CAAA;IAEhB,UAAU,CAAC,EAAE,UAAU,CA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AAO;gBACT,OAAO;wBACC,OAAO;gBACf,OAAO;WACZ,GAAG,GAAG,GAAG;iBAEH,UAAU;iBAGV,UAAU;eAEZ,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI;eACtB,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI;0BACZ,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI;oBAClC;QAAE,KAAK,CAAC,EAAE,WAAW,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE;UAElD,MAAM,GAAG,MAAM;cAEX,SAAS"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index2.cjs","names":["Children","forwardRef","isValidElement","memo","useCallback","useImperativeHandle","useMemo","useRef","useState","useSyncExternalStore","CSSProperties","ReactNode","mergeProps","useFocusRing","useKeyboard","useClassNames","IconButton","CarouselItem","CarouselSlide","createCarouselStore","INITIAL_CAROUSEL_STATE","CarouselState","useCarouselScroller","getServerSnapshot","ScrollAlign","ScrollSnapType","ScrollSnapAlign","ScrollSnap","Readonly","type","align","ScrollStepContext","clientWidth","scrollWidth","scrollLeft","direction","ScrollStep","ctx","CarouselHandlerRef","resetScroll","CarouselProps","className","hasGradient","fullWidth","navigationButtons","indicator","size","scrollStep","scrollSnap","onScroll","left","onResize","width","onScrollStateChange","canScroll","defaultScroll","offset","gap","children","Direction","DEFAULT_SCROLL_STEP","NAV_ICON","prev","next","const","NavigationButtonProps","CarouselNavigationButton","handleClick","IndicatorItemProps","index","isActive","onSelect","CarouselIndicatorItem","undefined","Carousel","Render","props","ref","showNavigationButtons","showIndicator","snapType","snapAlign","slides","toArray","slideKeys","map","slide","i","key","scrollerRef","HTMLDivElement","store","scrollByStep","onItemResize","length","activeIndex","canPrev","canNext","subscribe","getSnapshot","scrollToItem","dispatch","keyboardProps","onKeyDown","e","preventDefault","continuePropagation","focusProps","scrollerFocusProps","isFocusVisible","scrollerFocusVisible","rootFocusProps","rootFocusVisible","within","gapStyle","_","displayName"],"sources":["../../../src/components/Carousel/index.tsx"],"sourcesContent":["import './index.css'\n\nimport {\n Children,\n forwardRef,\n isValidElement,\n memo,\n useCallback,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n type CSSProperties,\n type ReactNode,\n} from 'react'\nimport { mergeProps, useFocusRing, useKeyboard } from 'react-aria'\nimport { useClassNames } from '../../_lib/useClassNames'\nimport IconButton from '../IconButton'\nimport { CarouselItem as CarouselSlide } from './CarouselItem'\nimport {\n createCarouselStore,\n INITIAL_CAROUSEL_STATE,\n type CarouselState,\n} from './carouselStore'\nimport { useCarouselScroller } from './useCarouselScroller'\n\nconst getServerSnapshot = (): CarouselState => INITIAL_CAROUSEL_STATE\n\nexport type ScrollAlign = 'left' | 'center' | 'right'\n\nexport type ScrollSnapType = 'none' | 'proximity' | 'mandatory'\n\nexport type ScrollSnapAlign = 'center' | 'start'\n\nexport type ScrollSnap = Readonly<{\n type?: ScrollSnapType\n align?: ScrollSnapAlign\n}>\n\nexport type ScrollStepContext = Readonly<{\n clientWidth: number\n scrollWidth: number\n scrollLeft: number\n direction: 'prev' | 'next'\n}>\n\nexport type ScrollStep = number | ((ctx: ScrollStepContext) => number)\n\n// 命令的 API。ref 経由で初期位置へのリセットを公開する(react-sandbox 互換)。\nexport type CarouselHandlerRef = {\n resetScroll: () => void\n}\n\nexport type CarouselProps = Readonly<{\n className?: string\n hasGradient?: boolean\n fullWidth?: boolean\n navigationButtons?: boolean\n indicator?: boolean\n size?: 'S' | 'M'\n // 進む量。number は clientWidth に対する比率、function は進む px を直接返す。\n scrollStep?: ScrollStep\n // スクロールスナップ。未指定時は size 基準(M=none / S=mandatory)、align=center。\n // M の none は sandbox 同等に 0.75×表示幅ちょうど進む(スナップで着地を吸着しない)。\n scrollSnap?: ScrollSnap\n // react-sandbox 互換のコールバック。\n onScroll?: (left: number) => void\n onResize?: (width: number) => void\n onScrollStateChange?: (canScroll: boolean) => void\n defaultScroll?: { align?: ScrollAlign; offset?: number }\n // スライド間隔。number は px、string は CSS 値をそのまま使う。未指定は間隔なし。\n gap?: number | string\n // 1 直接子要素 = 1 スライド(react-sandbox 互換)。\n children: ReactNode\n}>\n\ntype Direction = 'prev' | 'next'\n\nconst DEFAULT_SCROLL_STEP = 0.75\n\nconst NAV_ICON = {\n prev: '24/Prev',\n next: '24/Next',\n} as const\n\ntype NavigationButtonProps = Readonly<{\n direction: Direction\n canScroll: boolean\n onScroll: (direction: Direction) => void\n}>\n\nconst CarouselNavigationButton = ({\n direction,\n canScroll,\n onScroll,\n}: NavigationButtonProps) => {\n const handleClick = useCallback(() => {\n onScroll(direction)\n }, [onScroll, direction])\n return (\n <IconButton\n variant=\"Overlay\"\n size=\"S\"\n icon={NAV_ICON[direction]}\n aria-label={direction === 'prev' ? 'Previous' : 'Next'}\n disabled={!canScroll}\n onClick={handleClick}\n className=\"charcoal-carousel__navigation__item\"\n data-direction={direction}\n data-hidden={!canScroll}\n />\n )\n}\n\ntype IndicatorItemProps = Readonly<{\n index: number\n isActive: boolean\n onSelect: (index: number) => void\n}>\n\nconst CarouselIndicatorItem = ({\n index,\n isActive,\n onSelect,\n}: IndicatorItemProps) => {\n const handleClick = useCallback(() => {\n onSelect(index)\n }, [onSelect, index])\n return (\n <button\n className=\"charcoal-carousel__indicator__item\"\n data-active={isActive}\n aria-current={isActive || undefined}\n aria-label={`Go to slide ${index + 1}`}\n onClick={handleClick}\n />\n )\n}\n\nconst Carousel = forwardRef<CarouselHandlerRef, CarouselProps>(function Render(\n {\n size = 'M',\n navigationButtons,\n indicator,\n hasGradient = false,\n fullWidth = false,\n scrollStep = DEFAULT_SCROLL_STEP,\n scrollSnap,\n onScroll,\n onResize,\n onScrollStateChange,\n defaultScroll: { align = 'left', offset = 0 } = {},\n gap,\n children,\n ...props\n }: CarouselProps,\n ref,\n) {\n const className = useClassNames('charcoal-carousel', props.className)\n const showNavigationButtons = navigationButtons ?? size === 'M'\n const showIndicator = indicator ?? size === 'S'\n const snapType = scrollSnap?.type ?? (size === 'S' ? 'mandatory' : 'none')\n const snapAlign = scrollSnap?.align ?? 'center'\n\n // 直接子要素 1 つを 1 スライドとして数える。key は子要素の key を引き継ぐ\n // (toArray が付与する接頭辞付き key。無ければ index)。\n const slides = Children.toArray(children)\n const slideKeys = slides.map((slide, i) =>\n isValidElement(slide) && slide.key != null ? slide.key : i,\n )\n\n const scrollerRef = useRef<HTMLDivElement>(null)\n const [store] = useState(createCarouselStore)\n\n const { scrollByStep, onItemResize, resetScroll } = useCarouselScroller(\n scrollerRef,\n store,\n slides.length,\n { align, offset, scrollStep, onScroll, onResize, onScrollStateChange },\n )\n\n useImperativeHandle(ref, () => ({ resetScroll }), [resetScroll])\n\n const { activeIndex, canPrev, canNext } = useSyncExternalStore(\n store.subscribe,\n store.getSnapshot,\n getServerSnapshot,\n )\n\n const scrollToItem = useCallback(\n (index: number) => store.dispatch({ type: 'requestScroll', index }),\n [store],\n )\n\n // ←/→ でスクロール。コンテナにフォーカスがある時のみ。\n const { keyboardProps } = useKeyboard({\n onKeyDown: (e) => {\n if (e.key === 'ArrowRight') {\n e.preventDefault()\n scrollByStep('next')\n } else if (e.key === 'ArrowLeft') {\n e.preventDefault()\n scrollByStep('prev')\n } else {\n e.continuePropagation()\n }\n },\n })\n\n const {\n focusProps: scrollerFocusProps,\n isFocusVisible: scrollerFocusVisible,\n } = useFocusRing()\n\n // ナビゲーションボタン表示用。クリックで残留したフォーカス(pointer 由来)では\n // 表示し続けないよう、キーボード由来のフォーカスのみを検知する。\n const { focusProps: rootFocusProps, isFocusVisible: rootFocusVisible } =\n useFocusRing({ within: true })\n\n // gap 宣言自体は index.css 側に置き、ここでは CSS 変数の値だけを注入する。\n const gapStyle = useMemo(\n () =>\n ({\n ...(gap != null && {\n '--charcoal-carousel-gap': typeof gap === 'number' ? `${gap}px` : gap,\n }),\n }) satisfies CSSProperties,\n [gap],\n )\n\n return (\n <div\n {...rootFocusProps}\n className={className}\n style={gapStyle}\n data-size={size}\n data-has-gradient={hasGradient}\n data-full-width={fullWidth}\n data-indicator={showIndicator}\n data-scroll-snap-type={snapType}\n data-scroll-snap-align={snapAlign}\n data-can-prev={canPrev}\n data-can-next={canNext}\n data-focus-visible-within={rootFocusVisible || undefined}\n role=\"region\"\n aria-roledescription=\"carousel\"\n aria-label=\"Carousel\"\n >\n {/* フォーカスリングは viewport に描く(理由は index.css の同セレクタ参照) */}\n <div\n className=\"charcoal-carousel__viewport\"\n data-focus-visible={scrollerFocusVisible || undefined}\n >\n <div\n {...mergeProps(scrollerFocusProps, keyboardProps)}\n ref={scrollerRef}\n className=\"charcoal-carousel__scroller\"\n tabIndex={0}\n >\n {slides.map((slide, i) => (\n <CarouselSlide\n key={slideKeys[i]}\n index={i}\n store={store}\n onResize={onItemResize}\n >\n {slide}\n </CarouselSlide>\n ))}\n </div>\n\n <div\n className=\"charcoal-carousel__navigation\"\n data-visible={showNavigationButtons}\n aria-hidden={!showNavigationButtons}\n >\n <CarouselNavigationButton\n direction=\"prev\"\n canScroll={canPrev}\n onScroll={scrollByStep}\n />\n <CarouselNavigationButton\n direction=\"next\"\n canScroll={canNext}\n onScroll={scrollByStep}\n />\n </div>\n </div>\n\n <div\n className=\"charcoal-carousel__indicator\"\n data-visible={showIndicator}\n aria-hidden={!showIndicator}\n >\n {slides.map((_, i) => (\n <CarouselIndicatorItem\n key={slideKeys[i]}\n index={i}\n isActive={i === activeIndex}\n onSelect={scrollToItem}\n />\n ))}\n </div>\n </div>\n )\n})\n\nCarousel.displayName = 'Carousel'\n\nexport default memo(Carousel)\n"],"mappings":";;;;;;;;;;;;;AA2BA,MAAMuB,0BAAyCH;AAoD/C,MAAMwC,sBAAsB;AAE5B,MAAMC,WAAW;CACfC,MAAM;CACNC,MAAM;CACP;AAQD,MAAMG,4BAA4B,EAChC/B,WACAmB,WACAL,eAC2B;CAC3B,MAAMkB,2CAAgC;EACpClB,SAASd,UAAU;IAClB,CAACc,UAAUd,UAAU,CAAC;CACzB,OACE,2CAAC,uBAAD;EACE,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AC,OAAD;IACE,WAAU;IACV,gBAAcT;IACd,eAAa,CAACA;cAHhB,CAKE,2CAAC,0BAAD;KACE,WAAU;KACV,WAAWkB;KACX,UAAUJ;KAAa,GAEzB,2CAAC,0BAAD;KACE,WAAU;KACV,WAAWK;KACX,UAAUL;KAAa,EAEtB;MACF;MAEL,2CAAC,OAAD;GACE,WAAU;GACV,gBAAcb;GACd,eAAa,CAACA;aAEbG,OAAOG,KAAK8B,GAAG5B,MACd,2CAAC,uBAAD;IAEE,OAAOA;IACP,UAAUA,MAAMQ;IAChB,UAAUK;IAEb,EALQhB,UAAUG,GAKlB,CAAC;GACC,EACD;;EAER;AAEFb,SAAS0C,cAAc;AAEvB,uCAAoB1C,SAAS"}
|
|
1
|
+
{"version":3,"file":"index2.cjs","names":[],"sources":["../../../src/components/Carousel/index.tsx"],"sourcesContent":["import './index.css'\n\nimport {\n Children,\n forwardRef,\n isValidElement,\n memo,\n useCallback,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n type CSSProperties,\n type ReactNode,\n} from 'react'\nimport { mergeProps, useFocusRing, useKeyboard } from 'react-aria'\nimport { useClassNames } from '../../_lib/useClassNames'\nimport IconButton from '../IconButton'\nimport { CarouselItem as CarouselSlide } from './CarouselItem'\nimport {\n createCarouselStore,\n INITIAL_CAROUSEL_STATE,\n type CarouselState,\n} from './carouselStore'\nimport { useCarouselScroller } from './useCarouselScroller'\n\nconst getServerSnapshot = (): CarouselState => INITIAL_CAROUSEL_STATE\n\nexport type ScrollAlign = 'left' | 'center' | 'right'\n\nexport type ScrollSnapType = 'none' | 'proximity' | 'mandatory'\n\nexport type ScrollSnapAlign = 'center' | 'start'\n\nexport type ScrollSnap = Readonly<{\n type?: ScrollSnapType\n align?: ScrollSnapAlign\n}>\n\nexport type ScrollStepContext = Readonly<{\n clientWidth: number\n scrollWidth: number\n scrollLeft: number\n direction: 'prev' | 'next'\n}>\n\nexport type ScrollStep = number | ((ctx: ScrollStepContext) => number)\n\n// 命令的 API。ref 経由で初期位置へのリセットを公開する(react-sandbox 互換)。\nexport type CarouselHandlerRef = {\n resetScroll: () => void\n}\n\nexport type CarouselProps = Readonly<{\n className?: string\n hasGradient?: boolean\n fullWidth?: boolean\n navigationButtons?: boolean\n indicator?: boolean\n size?: 'S' | 'M'\n // 進む量。number は clientWidth に対する比率、function は進む px を直接返す。\n scrollStep?: ScrollStep\n // スクロールスナップ。未指定時は size 基準(M=none / S=mandatory)、align=center。\n // M の none は sandbox 同等に 0.75×表示幅ちょうど進む(スナップで着地を吸着しない)。\n scrollSnap?: ScrollSnap\n // react-sandbox 互換のコールバック。\n onScroll?: (left: number) => void\n onResize?: (width: number) => void\n onScrollStateChange?: (canScroll: boolean) => void\n defaultScroll?: { align?: ScrollAlign; offset?: number }\n // スライド間隔。number は px、string は CSS 値をそのまま使う。未指定は間隔なし。\n gap?: number | string\n // 1 直接子要素 = 1 スライド(react-sandbox 互換)。\n children: ReactNode\n}>\n\ntype Direction = 'prev' | 'next'\n\nconst DEFAULT_SCROLL_STEP = 0.75\n\nconst NAV_ICON = {\n prev: '24/Prev',\n next: '24/Next',\n} as const\n\ntype NavigationButtonProps = Readonly<{\n direction: Direction\n canScroll: boolean\n onScroll: (direction: Direction) => void\n}>\n\nconst CarouselNavigationButton = ({\n direction,\n canScroll,\n onScroll,\n}: NavigationButtonProps) => {\n const handleClick = useCallback(() => {\n onScroll(direction)\n }, [onScroll, direction])\n return (\n <IconButton\n variant=\"Overlay\"\n size=\"S\"\n icon={NAV_ICON[direction]}\n aria-label={direction === 'prev' ? 'Previous' : 'Next'}\n disabled={!canScroll}\n onClick={handleClick}\n className=\"charcoal-carousel__navigation__item\"\n data-direction={direction}\n data-hidden={!canScroll}\n />\n )\n}\n\ntype IndicatorItemProps = Readonly<{\n index: number\n isActive: boolean\n onSelect: (index: number) => void\n}>\n\nconst CarouselIndicatorItem = ({\n index,\n isActive,\n onSelect,\n}: IndicatorItemProps) => {\n const handleClick = useCallback(() => {\n onSelect(index)\n }, [onSelect, index])\n return (\n <button\n className=\"charcoal-carousel__indicator__item\"\n data-active={isActive}\n aria-current={isActive || undefined}\n aria-label={`Go to slide ${index + 1}`}\n onClick={handleClick}\n />\n )\n}\n\nconst Carousel = forwardRef<CarouselHandlerRef, CarouselProps>(function Render(\n {\n size = 'M',\n navigationButtons,\n indicator,\n hasGradient = false,\n fullWidth = false,\n scrollStep = DEFAULT_SCROLL_STEP,\n scrollSnap,\n onScroll,\n onResize,\n onScrollStateChange,\n defaultScroll: { align = 'left', offset = 0 } = {},\n gap,\n children,\n ...props\n }: CarouselProps,\n ref,\n) {\n const className = useClassNames('charcoal-carousel', props.className)\n const showNavigationButtons = navigationButtons ?? size === 'M'\n const showIndicator = indicator ?? size === 'S'\n const snapType = scrollSnap?.type ?? (size === 'S' ? 'mandatory' : 'none')\n const snapAlign = scrollSnap?.align ?? 'center'\n\n // 直接子要素 1 つを 1 スライドとして数える。key は子要素の key を引き継ぐ\n // (toArray が付与する接頭辞付き key。無ければ index)。\n const slides = Children.toArray(children)\n const slideKeys = slides.map((slide, i) =>\n isValidElement(slide) && slide.key != null ? slide.key : i,\n )\n\n const scrollerRef = useRef<HTMLDivElement>(null)\n const [store] = useState(createCarouselStore)\n\n const { scrollByStep, onItemResize, resetScroll } = useCarouselScroller(\n scrollerRef,\n store,\n slides.length,\n { align, offset, scrollStep, onScroll, onResize, onScrollStateChange },\n )\n\n useImperativeHandle(ref, () => ({ resetScroll }), [resetScroll])\n\n const { activeIndex, canPrev, canNext } = useSyncExternalStore(\n store.subscribe,\n store.getSnapshot,\n getServerSnapshot,\n )\n\n const scrollToItem = useCallback(\n (index: number) => store.dispatch({ type: 'requestScroll', index }),\n [store],\n )\n\n // ←/→ でスクロール。コンテナにフォーカスがある時のみ。\n const { keyboardProps } = useKeyboard({\n onKeyDown: (e) => {\n if (e.key === 'ArrowRight') {\n e.preventDefault()\n scrollByStep('next')\n } else if (e.key === 'ArrowLeft') {\n e.preventDefault()\n scrollByStep('prev')\n } else {\n e.continuePropagation()\n }\n },\n })\n\n const {\n focusProps: scrollerFocusProps,\n isFocusVisible: scrollerFocusVisible,\n } = useFocusRing()\n\n // ナビゲーションボタン表示用。クリックで残留したフォーカス(pointer 由来)では\n // 表示し続けないよう、キーボード由来のフォーカスのみを検知する。\n const { focusProps: rootFocusProps, isFocusVisible: rootFocusVisible } =\n useFocusRing({ within: true })\n\n // gap 宣言自体は index.css 側に置き、ここでは CSS 変数の値だけを注入する。\n const gapStyle = useMemo(\n () =>\n ({\n ...(gap != null && {\n '--charcoal-carousel-gap': typeof gap === 'number' ? `${gap}px` : gap,\n }),\n }) satisfies CSSProperties,\n [gap],\n )\n\n return (\n <div\n {...rootFocusProps}\n className={className}\n style={gapStyle}\n data-size={size}\n data-has-gradient={hasGradient}\n data-full-width={fullWidth}\n data-indicator={showIndicator}\n data-scroll-snap-type={snapType}\n data-scroll-snap-align={snapAlign}\n data-can-prev={canPrev}\n data-can-next={canNext}\n data-focus-visible-within={rootFocusVisible || undefined}\n role=\"region\"\n aria-roledescription=\"carousel\"\n aria-label=\"Carousel\"\n >\n {/* フォーカスリングは viewport に描く(理由は index.css の同セレクタ参照) */}\n <div\n className=\"charcoal-carousel__viewport\"\n data-focus-visible={scrollerFocusVisible || undefined}\n >\n <div\n {...mergeProps(scrollerFocusProps, keyboardProps)}\n ref={scrollerRef}\n className=\"charcoal-carousel__scroller\"\n tabIndex={0}\n >\n {slides.map((slide, i) => (\n <CarouselSlide\n key={slideKeys[i]}\n index={i}\n store={store}\n onResize={onItemResize}\n >\n {slide}\n </CarouselSlide>\n ))}\n </div>\n\n <div\n className=\"charcoal-carousel__navigation\"\n data-visible={showNavigationButtons}\n aria-hidden={!showNavigationButtons}\n >\n <CarouselNavigationButton\n direction=\"prev\"\n canScroll={canPrev}\n onScroll={scrollByStep}\n />\n <CarouselNavigationButton\n direction=\"next\"\n canScroll={canNext}\n onScroll={scrollByStep}\n />\n </div>\n </div>\n\n <div\n className=\"charcoal-carousel__indicator\"\n data-visible={showIndicator}\n aria-hidden={!showIndicator}\n >\n {slides.map((_, i) => (\n <CarouselIndicatorItem\n key={slideKeys[i]}\n index={i}\n isActive={i === activeIndex}\n onSelect={scrollToItem}\n />\n ))}\n </div>\n </div>\n )\n})\n\nCarousel.displayName = 'Carousel'\n\nexport default memo(Carousel)\n"],"mappings":";;;;;;;;;;;;AA2BA,MAAM,0BAAyC;AAoD/C,MAAM,sBAAsB;AAE5B,MAAM,WAAW;CACf,MAAM;CACN,MAAM;AACR;AAQA,MAAM,4BAA4B,EAChC,WACA,WACA,eAC2B;CAC3B,MAAM,2CAAgC;EACpC,SAAS,SAAS;CACpB,GAAG,CAAC,UAAU,SAAS,CAAC;CACxB,OACE,2CAAC,uBAAD;EACE,SAAQ;EACR,MAAK;EACL,MAAM,SAAS;EACf,cAAY,cAAc,SAAS,aAAa;EAChD,UAAU,CAAC;EACX,SAAS;EACT,WAAU;EACV,kBAAgB;EAChB,eAAa,CAAC;CAAU;AAG9B;AAQA,MAAM,yBAAyB,EAC7B,OACA,UACA,eACwB;CACxB,MAAM,2CAAgC;EACpC,SAAS,KAAK;CAChB,GAAG,CAAC,UAAU,KAAK,CAAC;CACpB,OACE,2CAAC,UAAD;EACE,WAAU;EACV,eAAa;EACb,gBAAc,YAAY;EAC1B,cAAY,eAAe,QAAQ;EACnC,SAAS;CAAY;AAG3B;AAEA,MAAM,iCAAyD,SAAS,OACtE,EACE,OAAO,KACP,mBACA,WACA,cAAc,OACd,YAAY,OACZ,aAAa,qBACb,YACA,UACA,UACA,qBACA,eAAe,EAAE,QAAQ,QAAQ,SAAS,MAAM,CAAC,GACjD,KACA,UACA,GAAG,SAEL,KACA;CACA,MAAM,YAAY,oCAAc,qBAAqB,MAAM,SAAS;CACpE,MAAM,wBAAwB,qBAAqB,SAAS;CAC5D,MAAM,gBAAgB,aAAa,SAAS;CAC5C,MAAM,WAAW,YAAY,SAAS,SAAS,MAAM,cAAc;CACnE,MAAM,YAAY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AW;YAfb,CAkBE,4CAAC,OAAD;GACE,WAAU;GACV,sBAAoB,wBAAwB;aAF9C,CAIE,2CAAC,OAAD;IACE,8BAAe,oBAAoB,aAAa;IAChD,KAAK;IACL,WAAU;IACV,UAAU;cAET,OAAO,KAAK,OAAO,MAClB,2CAAC,mCAAD;KAEE,OAAO;KACA;KACP,UAAU;eAET;IACY,GANR,UAAU,EAMF,CAChB;GACE,IAEL,4CAAC,OAAD;IACE,WAAU;IACV,gBAAc;IACd,eAAa,CAAC;cAHhB,CAKE,2CAAC,0BAAD;KACE,WAAU;KACV,WAAW;KACX,UAAU;IAAa,IAEzB,2CAAC,0BAAD;KACE,WAAU;KACV,WAAW;KACX,UAAU;IAAa,EAEtB;KACF;MAEL,2CAAC,OAAD;GACE,WAAU;GACV,gBAAc;GACd,eAAa,CAAC;aAEb,OAAO,KAAK,GAAG,MACd,2CAAC,uBAAD;IAEE,OAAO;IACP,UAAU,MAAM;IAChB,UAAU;GAAa,GAHlB,UAAU,EAGQ,CAE1B;EACE,EACF;;AAET,CAAC;AAED,SAAS,cAAc;AAEvB,uCAAoB,QAAQ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index2.js","names":["Children","forwardRef","isValidElement","memo","useCallback","useImperativeHandle","useMemo","useRef","useState","useSyncExternalStore","CSSProperties","ReactNode","mergeProps","useFocusRing","useKeyboard","useClassNames","IconButton","CarouselItem","CarouselSlide","createCarouselStore","INITIAL_CAROUSEL_STATE","CarouselState","useCarouselScroller","getServerSnapshot","ScrollAlign","ScrollSnapType","ScrollSnapAlign","ScrollSnap","Readonly","type","align","ScrollStepContext","clientWidth","scrollWidth","scrollLeft","direction","ScrollStep","ctx","CarouselHandlerRef","resetScroll","CarouselProps","className","hasGradient","fullWidth","navigationButtons","indicator","size","scrollStep","scrollSnap","onScroll","left","onResize","width","onScrollStateChange","canScroll","defaultScroll","offset","gap","children","Direction","DEFAULT_SCROLL_STEP","NAV_ICON","prev","next","const","NavigationButtonProps","CarouselNavigationButton","handleClick","IndicatorItemProps","index","isActive","onSelect","CarouselIndicatorItem","undefined","Carousel","Render","props","ref","showNavigationButtons","showIndicator","snapType","snapAlign","slides","toArray","slideKeys","map","slide","i","key","scrollerRef","HTMLDivElement","store","scrollByStep","onItemResize","length","activeIndex","canPrev","canNext","subscribe","getSnapshot","scrollToItem","dispatch","keyboardProps","onKeyDown","e","preventDefault","continuePropagation","focusProps","scrollerFocusProps","isFocusVisible","scrollerFocusVisible","rootFocusProps","rootFocusVisible","within","gapStyle","_","displayName"],"sources":["../../../src/components/Carousel/index.tsx"],"sourcesContent":["import './index.css'\n\nimport {\n Children,\n forwardRef,\n isValidElement,\n memo,\n useCallback,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n type CSSProperties,\n type ReactNode,\n} from 'react'\nimport { mergeProps, useFocusRing, useKeyboard } from 'react-aria'\nimport { useClassNames } from '../../_lib/useClassNames'\nimport IconButton from '../IconButton'\nimport { CarouselItem as CarouselSlide } from './CarouselItem'\nimport {\n createCarouselStore,\n INITIAL_CAROUSEL_STATE,\n type CarouselState,\n} from './carouselStore'\nimport { useCarouselScroller } from './useCarouselScroller'\n\nconst getServerSnapshot = (): CarouselState => INITIAL_CAROUSEL_STATE\n\nexport type ScrollAlign = 'left' | 'center' | 'right'\n\nexport type ScrollSnapType = 'none' | 'proximity' | 'mandatory'\n\nexport type ScrollSnapAlign = 'center' | 'start'\n\nexport type ScrollSnap = Readonly<{\n type?: ScrollSnapType\n align?: ScrollSnapAlign\n}>\n\nexport type ScrollStepContext = Readonly<{\n clientWidth: number\n scrollWidth: number\n scrollLeft: number\n direction: 'prev' | 'next'\n}>\n\nexport type ScrollStep = number | ((ctx: ScrollStepContext) => number)\n\n// 命令的 API。ref 経由で初期位置へのリセットを公開する(react-sandbox 互換)。\nexport type CarouselHandlerRef = {\n resetScroll: () => void\n}\n\nexport type CarouselProps = Readonly<{\n className?: string\n hasGradient?: boolean\n fullWidth?: boolean\n navigationButtons?: boolean\n indicator?: boolean\n size?: 'S' | 'M'\n // 進む量。number は clientWidth に対する比率、function は進む px を直接返す。\n scrollStep?: ScrollStep\n // スクロールスナップ。未指定時は size 基準(M=none / S=mandatory)、align=center。\n // M の none は sandbox 同等に 0.75×表示幅ちょうど進む(スナップで着地を吸着しない)。\n scrollSnap?: ScrollSnap\n // react-sandbox 互換のコールバック。\n onScroll?: (left: number) => void\n onResize?: (width: number) => void\n onScrollStateChange?: (canScroll: boolean) => void\n defaultScroll?: { align?: ScrollAlign; offset?: number }\n // スライド間隔。number は px、string は CSS 値をそのまま使う。未指定は間隔なし。\n gap?: number | string\n // 1 直接子要素 = 1 スライド(react-sandbox 互換)。\n children: ReactNode\n}>\n\ntype Direction = 'prev' | 'next'\n\nconst DEFAULT_SCROLL_STEP = 0.75\n\nconst NAV_ICON = {\n prev: '24/Prev',\n next: '24/Next',\n} as const\n\ntype NavigationButtonProps = Readonly<{\n direction: Direction\n canScroll: boolean\n onScroll: (direction: Direction) => void\n}>\n\nconst CarouselNavigationButton = ({\n direction,\n canScroll,\n onScroll,\n}: NavigationButtonProps) => {\n const handleClick = useCallback(() => {\n onScroll(direction)\n }, [onScroll, direction])\n return (\n <IconButton\n variant=\"Overlay\"\n size=\"S\"\n icon={NAV_ICON[direction]}\n aria-label={direction === 'prev' ? 'Previous' : 'Next'}\n disabled={!canScroll}\n onClick={handleClick}\n className=\"charcoal-carousel__navigation__item\"\n data-direction={direction}\n data-hidden={!canScroll}\n />\n )\n}\n\ntype IndicatorItemProps = Readonly<{\n index: number\n isActive: boolean\n onSelect: (index: number) => void\n}>\n\nconst CarouselIndicatorItem = ({\n index,\n isActive,\n onSelect,\n}: IndicatorItemProps) => {\n const handleClick = useCallback(() => {\n onSelect(index)\n }, [onSelect, index])\n return (\n <button\n className=\"charcoal-carousel__indicator__item\"\n data-active={isActive}\n aria-current={isActive || undefined}\n aria-label={`Go to slide ${index + 1}`}\n onClick={handleClick}\n />\n )\n}\n\nconst Carousel = forwardRef<CarouselHandlerRef, CarouselProps>(function Render(\n {\n size = 'M',\n navigationButtons,\n indicator,\n hasGradient = false,\n fullWidth = false,\n scrollStep = DEFAULT_SCROLL_STEP,\n scrollSnap,\n onScroll,\n onResize,\n onScrollStateChange,\n defaultScroll: { align = 'left', offset = 0 } = {},\n gap,\n children,\n ...props\n }: CarouselProps,\n ref,\n) {\n const className = useClassNames('charcoal-carousel', props.className)\n const showNavigationButtons = navigationButtons ?? size === 'M'\n const showIndicator = indicator ?? size === 'S'\n const snapType = scrollSnap?.type ?? (size === 'S' ? 'mandatory' : 'none')\n const snapAlign = scrollSnap?.align ?? 'center'\n\n // 直接子要素 1 つを 1 スライドとして数える。key は子要素の key を引き継ぐ\n // (toArray が付与する接頭辞付き key。無ければ index)。\n const slides = Children.toArray(children)\n const slideKeys = slides.map((slide, i) =>\n isValidElement(slide) && slide.key != null ? slide.key : i,\n )\n\n const scrollerRef = useRef<HTMLDivElement>(null)\n const [store] = useState(createCarouselStore)\n\n const { scrollByStep, onItemResize, resetScroll } = useCarouselScroller(\n scrollerRef,\n store,\n slides.length,\n { align, offset, scrollStep, onScroll, onResize, onScrollStateChange },\n )\n\n useImperativeHandle(ref, () => ({ resetScroll }), [resetScroll])\n\n const { activeIndex, canPrev, canNext } = useSyncExternalStore(\n store.subscribe,\n store.getSnapshot,\n getServerSnapshot,\n )\n\n const scrollToItem = useCallback(\n (index: number) => store.dispatch({ type: 'requestScroll', index }),\n [store],\n )\n\n // ←/→ でスクロール。コンテナにフォーカスがある時のみ。\n const { keyboardProps } = useKeyboard({\n onKeyDown: (e) => {\n if (e.key === 'ArrowRight') {\n e.preventDefault()\n scrollByStep('next')\n } else if (e.key === 'ArrowLeft') {\n e.preventDefault()\n scrollByStep('prev')\n } else {\n e.continuePropagation()\n }\n },\n })\n\n const {\n focusProps: scrollerFocusProps,\n isFocusVisible: scrollerFocusVisible,\n } = useFocusRing()\n\n // ナビゲーションボタン表示用。クリックで残留したフォーカス(pointer 由来)では\n // 表示し続けないよう、キーボード由来のフォーカスのみを検知する。\n const { focusProps: rootFocusProps, isFocusVisible: rootFocusVisible } =\n useFocusRing({ within: true })\n\n // gap 宣言自体は index.css 側に置き、ここでは CSS 変数の値だけを注入する。\n const gapStyle = useMemo(\n () =>\n ({\n ...(gap != null && {\n '--charcoal-carousel-gap': typeof gap === 'number' ? `${gap}px` : gap,\n }),\n }) satisfies CSSProperties,\n [gap],\n )\n\n return (\n <div\n {...rootFocusProps}\n className={className}\n style={gapStyle}\n data-size={size}\n data-has-gradient={hasGradient}\n data-full-width={fullWidth}\n data-indicator={showIndicator}\n data-scroll-snap-type={snapType}\n data-scroll-snap-align={snapAlign}\n data-can-prev={canPrev}\n data-can-next={canNext}\n data-focus-visible-within={rootFocusVisible || undefined}\n role=\"region\"\n aria-roledescription=\"carousel\"\n aria-label=\"Carousel\"\n >\n {/* フォーカスリングは viewport に描く(理由は index.css の同セレクタ参照) */}\n <div\n className=\"charcoal-carousel__viewport\"\n data-focus-visible={scrollerFocusVisible || undefined}\n >\n <div\n {...mergeProps(scrollerFocusProps, keyboardProps)}\n ref={scrollerRef}\n className=\"charcoal-carousel__scroller\"\n tabIndex={0}\n >\n {slides.map((slide, i) => (\n <CarouselSlide\n key={slideKeys[i]}\n index={i}\n store={store}\n onResize={onItemResize}\n >\n {slide}\n </CarouselSlide>\n ))}\n </div>\n\n <div\n className=\"charcoal-carousel__navigation\"\n data-visible={showNavigationButtons}\n aria-hidden={!showNavigationButtons}\n >\n <CarouselNavigationButton\n direction=\"prev\"\n canScroll={canPrev}\n onScroll={scrollByStep}\n />\n <CarouselNavigationButton\n direction=\"next\"\n canScroll={canNext}\n onScroll={scrollByStep}\n />\n </div>\n </div>\n\n <div\n className=\"charcoal-carousel__indicator\"\n data-visible={showIndicator}\n aria-hidden={!showIndicator}\n >\n {slides.map((_, i) => (\n <CarouselIndicatorItem\n key={slideKeys[i]}\n index={i}\n isActive={i === activeIndex}\n onSelect={scrollToItem}\n />\n ))}\n </div>\n </div>\n )\n})\n\nCarousel.displayName = 'Carousel'\n\nexport default memo(Carousel)\n"],"mappings":";;;;;;;;;;;;AA2BA,MAAMuB,0BAAyCH;AAoD/C,MAAMwC,sBAAsB;AAE5B,MAAMC,WAAW;CACfC,MAAM;CACNC,MAAM;CACP;AAQD,MAAMG,4BAA4B,EAChC/B,WACAmB,WACAL,eAC2B;CAC3B,MAAMkB,cAAc/D,kBAAkB;EACpC6C,SAASd,UAAU;IAClB,CAACc,UAAUd,UAAU,CAAC;CACzB,OACE,oBAAC,YAAD;EACE,SAAQ;EACR,MAAK;EACL,MAAM0B,SAAS1B;EACf,cAAYA,cAAc,SAAS,aAAa;EAChD,UAAU,CAACmB;EACX,SAASa;EACT,WAAU;EACV,kBAAgBhC;EAChB,eAAa,CAACmB;EACd;;AAUN,MAAMkB,yBAAyB,EAC7BH,OACAC,UACAC,eACwB;CACxB,MAAMJ,cAAc/D,kBAAkB;EACpCmE,SAASF,MAAM;IACd,CAACE,UAAUF,MAAM,CAAC;CACrB,OACE,oBAAC,UAAD;EACE,WAAU;EACV,eAAaC;EACb,gBAAcA,YAAYG;EAC1B,cAAY,eAAeJ,QAAQ;EACnC,SAASF;EACT;;AAIN,MAAMO,WAAWzE,WAA8C,SAAS0E,OACtE,EACE7B,OAAO,KACPF,mBACAC,WACAH,cAAc,OACdC,YAAY,OACZI,aAAaa,qBACbZ,YACAC,UACAE,UACAE,qBACAE,eAAe,EAAEzB,QAAQ,QAAQ0B,SAAS,MAAM,EAAE,EAClDC,KACAC,UACA,GAAGkB,SAELC,KACA;CACA,MAAMpC,YAAY1B,cAAc,qBAAqB6D,MAAMnC,UAAU;CACrE,MAAMqC,wBAAwBlC,qBAAqBE,SAAS;CAC5D,MAAMiC,gBAAgBlC,aAAaC,SAAS;CAC5C,MAAMkC,WAAWhC,YAAYnB,SAASiB,SAAS,MAAM,cAAc;CACnE,MAAMmC,YAAYjC,YAAYlB,SAAS;CAIvC,MAAMoD,SAASlF,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;EACnB,mBAAiBC;EACjB,kBAAgBoC;EAChB,yBAAuBC;EACvB,0BAAwBC;EACxB,iBAAee;EACf,iBAAeC;EACf,6BAA2Be,oBAAoBvC;EAC/C,MAAK;EACL,wBAAqB;EACrB,cAAW;YAfb,CAkBE,qBAAC,OAAD;GACE,WAAU;GACV,sBAAoBqC,wBAAwBrC;aAF9C,CAIE,oBAAC,OAAD;IACE,GAAI7D,WAAWgG,oBAAoBN,cAAc;IACjD,KAAKb;IACL,WAAU;IACV,UAAU;cAETP,OAAOG,KAAKC,OAAOC,MAClB,oBAAC,cAAD;KAEE,OAAOA;KACAI;KACP,UAAUE;eAETP;KAEJ,EAPQF,UAAUG,GAOlB,CAAC;IACC,GAEL,qBAAC,OAAD;IACE,WAAU;IACV,gBAAcT;IACd,eAAa,CAACA;cAHhB,CAKE,oBAAC,0BAAD;KACE,WAAU;KACV,WAAWkB;KACX,UAAUJ;KAAa,GAEzB,oBAAC,0BAAD;KACE,WAAU;KACV,WAAWK;KACX,UAAUL;KAAa,EAEtB;MACF;MAEL,oBAAC,OAAD;GACE,WAAU;GACV,gBAAcb;GACd,eAAa,CAACA;aAEbG,OAAOG,KAAK8B,GAAG5B,MACd,oBAAC,uBAAD;IAEE,OAAOA;IACP,UAAUA,MAAMQ;IAChB,UAAUK;IAEb,EALQhB,UAAUG,GAKlB,CAAC;GACC,EACD;;EAER;AAEFb,SAAS0C,cAAc;AAEvB,uBAAejH,KAAKuE,SAAS"}
|
|
1
|
+
{"version":3,"file":"index2.js","names":[],"sources":["../../../src/components/Carousel/index.tsx"],"sourcesContent":["import './index.css'\n\nimport {\n Children,\n forwardRef,\n isValidElement,\n memo,\n useCallback,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n type CSSProperties,\n type ReactNode,\n} from 'react'\nimport { mergeProps, useFocusRing, useKeyboard } from 'react-aria'\nimport { useClassNames } from '../../_lib/useClassNames'\nimport IconButton from '../IconButton'\nimport { CarouselItem as CarouselSlide } from './CarouselItem'\nimport {\n createCarouselStore,\n INITIAL_CAROUSEL_STATE,\n type CarouselState,\n} from './carouselStore'\nimport { useCarouselScroller } from './useCarouselScroller'\n\nconst getServerSnapshot = (): CarouselState => INITIAL_CAROUSEL_STATE\n\nexport type ScrollAlign = 'left' | 'center' | 'right'\n\nexport type ScrollSnapType = 'none' | 'proximity' | 'mandatory'\n\nexport type ScrollSnapAlign = 'center' | 'start'\n\nexport type ScrollSnap = Readonly<{\n type?: ScrollSnapType\n align?: ScrollSnapAlign\n}>\n\nexport type ScrollStepContext = Readonly<{\n clientWidth: number\n scrollWidth: number\n scrollLeft: number\n direction: 'prev' | 'next'\n}>\n\nexport type ScrollStep = number | ((ctx: ScrollStepContext) => number)\n\n// 命令的 API。ref 経由で初期位置へのリセットを公開する(react-sandbox 互換)。\nexport type CarouselHandlerRef = {\n resetScroll: () => void\n}\n\nexport type CarouselProps = Readonly<{\n className?: string\n hasGradient?: boolean\n fullWidth?: boolean\n navigationButtons?: boolean\n indicator?: boolean\n size?: 'S' | 'M'\n // 進む量。number は clientWidth に対する比率、function は進む px を直接返す。\n scrollStep?: ScrollStep\n // スクロールスナップ。未指定時は size 基準(M=none / S=mandatory)、align=center。\n // M の none は sandbox 同等に 0.75×表示幅ちょうど進む(スナップで着地を吸着しない)。\n scrollSnap?: ScrollSnap\n // react-sandbox 互換のコールバック。\n onScroll?: (left: number) => void\n onResize?: (width: number) => void\n onScrollStateChange?: (canScroll: boolean) => void\n defaultScroll?: { align?: ScrollAlign; offset?: number }\n // スライド間隔。number は px、string は CSS 値をそのまま使う。未指定は間隔なし。\n gap?: number | string\n // 1 直接子要素 = 1 スライド(react-sandbox 互換)。\n children: ReactNode\n}>\n\ntype Direction = 'prev' | 'next'\n\nconst DEFAULT_SCROLL_STEP = 0.75\n\nconst NAV_ICON = {\n prev: '24/Prev',\n next: '24/Next',\n} as const\n\ntype NavigationButtonProps = Readonly<{\n direction: Direction\n canScroll: boolean\n onScroll: (direction: Direction) => void\n}>\n\nconst CarouselNavigationButton = ({\n direction,\n canScroll,\n onScroll,\n}: NavigationButtonProps) => {\n const handleClick = useCallback(() => {\n onScroll(direction)\n }, [onScroll, direction])\n return (\n <IconButton\n variant=\"Overlay\"\n size=\"S\"\n icon={NAV_ICON[direction]}\n aria-label={direction === 'prev' ? 'Previous' : 'Next'}\n disabled={!canScroll}\n onClick={handleClick}\n className=\"charcoal-carousel__navigation__item\"\n data-direction={direction}\n data-hidden={!canScroll}\n />\n )\n}\n\ntype IndicatorItemProps = Readonly<{\n index: number\n isActive: boolean\n onSelect: (index: number) => void\n}>\n\nconst CarouselIndicatorItem = ({\n index,\n isActive,\n onSelect,\n}: IndicatorItemProps) => {\n const handleClick = useCallback(() => {\n onSelect(index)\n }, [onSelect, index])\n return (\n <button\n className=\"charcoal-carousel__indicator__item\"\n data-active={isActive}\n aria-current={isActive || undefined}\n aria-label={`Go to slide ${index + 1}`}\n onClick={handleClick}\n />\n )\n}\n\nconst Carousel = forwardRef<CarouselHandlerRef, CarouselProps>(function Render(\n {\n size = 'M',\n navigationButtons,\n indicator,\n hasGradient = false,\n fullWidth = false,\n scrollStep = DEFAULT_SCROLL_STEP,\n scrollSnap,\n onScroll,\n onResize,\n onScrollStateChange,\n defaultScroll: { align = 'left', offset = 0 } = {},\n gap,\n children,\n ...props\n }: CarouselProps,\n ref,\n) {\n const className = useClassNames('charcoal-carousel', props.className)\n const showNavigationButtons = navigationButtons ?? size === 'M'\n const showIndicator = indicator ?? size === 'S'\n const snapType = scrollSnap?.type ?? (size === 'S' ? 'mandatory' : 'none')\n const snapAlign = scrollSnap?.align ?? 'center'\n\n // 直接子要素 1 つを 1 スライドとして数える。key は子要素の key を引き継ぐ\n // (toArray が付与する接頭辞付き key。無ければ index)。\n const slides = Children.toArray(children)\n const slideKeys = slides.map((slide, i) =>\n isValidElement(slide) && slide.key != null ? slide.key : i,\n )\n\n const scrollerRef = useRef<HTMLDivElement>(null)\n const [store] = useState(createCarouselStore)\n\n const { scrollByStep, onItemResize, resetScroll } = useCarouselScroller(\n scrollerRef,\n store,\n slides.length,\n { align, offset, scrollStep, onScroll, onResize, onScrollStateChange },\n )\n\n useImperativeHandle(ref, () => ({ resetScroll }), [resetScroll])\n\n const { activeIndex, canPrev, canNext } = useSyncExternalStore(\n store.subscribe,\n store.getSnapshot,\n getServerSnapshot,\n )\n\n const scrollToItem = useCallback(\n (index: number) => store.dispatch({ type: 'requestScroll', index }),\n [store],\n )\n\n // ←/→ でスクロール。コンテナにフォーカスがある時のみ。\n const { keyboardProps } = useKeyboard({\n onKeyDown: (e) => {\n if (e.key === 'ArrowRight') {\n e.preventDefault()\n scrollByStep('next')\n } else if (e.key === 'ArrowLeft') {\n e.preventDefault()\n scrollByStep('prev')\n } else {\n e.continuePropagation()\n }\n },\n })\n\n const {\n focusProps: scrollerFocusProps,\n isFocusVisible: scrollerFocusVisible,\n } = useFocusRing()\n\n // ナビゲーションボタン表示用。クリックで残留したフォーカス(pointer 由来)では\n // 表示し続けないよう、キーボード由来のフォーカスのみを検知する。\n const { focusProps: rootFocusProps, isFocusVisible: rootFocusVisible } =\n useFocusRing({ within: true })\n\n // gap 宣言自体は index.css 側に置き、ここでは CSS 変数の値だけを注入する。\n const gapStyle = useMemo(\n () =>\n ({\n ...(gap != null && {\n '--charcoal-carousel-gap': typeof gap === 'number' ? `${gap}px` : gap,\n }),\n }) satisfies CSSProperties,\n [gap],\n )\n\n return (\n <div\n {...rootFocusProps}\n className={className}\n style={gapStyle}\n data-size={size}\n data-has-gradient={hasGradient}\n data-full-width={fullWidth}\n data-indicator={showIndicator}\n data-scroll-snap-type={snapType}\n data-scroll-snap-align={snapAlign}\n data-can-prev={canPrev}\n data-can-next={canNext}\n data-focus-visible-within={rootFocusVisible || undefined}\n role=\"region\"\n aria-roledescription=\"carousel\"\n aria-label=\"Carousel\"\n >\n {/* フォーカスリングは viewport に描く(理由は index.css の同セレクタ参照) */}\n <div\n className=\"charcoal-carousel__viewport\"\n data-focus-visible={scrollerFocusVisible || undefined}\n >\n <div\n {...mergeProps(scrollerFocusProps, keyboardProps)}\n ref={scrollerRef}\n className=\"charcoal-carousel__scroller\"\n tabIndex={0}\n >\n {slides.map((slide, i) => (\n <CarouselSlide\n key={slideKeys[i]}\n index={i}\n store={store}\n onResize={onItemResize}\n >\n {slide}\n </CarouselSlide>\n ))}\n </div>\n\n <div\n className=\"charcoal-carousel__navigation\"\n data-visible={showNavigationButtons}\n aria-hidden={!showNavigationButtons}\n >\n <CarouselNavigationButton\n direction=\"prev\"\n canScroll={canPrev}\n onScroll={scrollByStep}\n />\n <CarouselNavigationButton\n direction=\"next\"\n canScroll={canNext}\n onScroll={scrollByStep}\n />\n </div>\n </div>\n\n <div\n className=\"charcoal-carousel__indicator\"\n data-visible={showIndicator}\n aria-hidden={!showIndicator}\n >\n {slides.map((_, i) => (\n <CarouselIndicatorItem\n key={slideKeys[i]}\n index={i}\n isActive={i === activeIndex}\n onSelect={scrollToItem}\n />\n ))}\n </div>\n </div>\n )\n})\n\nCarousel.displayName = 'Carousel'\n\nexport default memo(Carousel)\n"],"mappings":";;;;;;;;;;;;AA2BA,MAAM,0BAAyC;AAoD/C,MAAM,sBAAsB;AAE5B,MAAM,WAAW;CACf,MAAM;CACN,MAAM;AACR;AAQA,MAAM,4BAA4B,EAChC,WACA,WACA,eAC2B;CAC3B,MAAM,cAAc,kBAAkB;EACpC,SAAS,SAAS;CACpB,GAAG,CAAC,UAAU,SAAS,CAAC;CACxB,OACE,oBAAC,YAAD;EACE,SAAQ;EACR,MAAK;EACL,MAAM,SAAS;EACf,cAAY,cAAc,SAAS,aAAa;EAChD,UAAU,CAAC;EACX,SAAS;EACT,WAAU;EACV,kBAAgB;EAChB,eAAa,CAAC;CAAU;AAG9B;AAQA,MAAM,yBAAyB,EAC7B,OACA,UACA,eACwB;CACxB,MAAM,cAAc,kBAAkB;EACpC,SAAS,KAAK;CAChB,GAAG,CAAC,UAAU,KAAK,CAAC;CACpB,OACE,oBAAC,U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-1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intersectionObserver.cjs","names":[
|
|
1
|
+
{"version":3,"file":"intersectionObserver.cjs","names":[],"sources":["../../../src/components/Carousel/intersectionObserver.ts"],"sourcesContent":["// 中央検出(左右 50% を除外)。root は item の親(scroller)から導出する。\nconst CENTER_ROOT_MARGIN = '0px -50% 0px -50%'\n\ntype CenterEntry = {\n observer: IntersectionObserver\n callbacks: Map<Element, () => void>\n}\n\n// root(= el.parentElement)ごとに observer を1つ共有する。\nconst byRoot = new Map<Element, CenterEntry>()\n\n/**\n * `el` がその親(= scroller)の中央ラインに重なったら `onEnter` を呼ぶ。同一 root の\n * IntersectionObserver を共有する singleton。返り値で監視解除(最後の1つで disconnect)。\n * SSR / 非対応環境では no-op。\n */\nexport function observeCenter(\n el: HTMLElement,\n onEnter: () => void,\n): () => void {\n // window で SSR を弾く。polyfill が global に IntersectionObserver を生やしていても\n // サーバー上では observe しない。\n if (\n typeof window === 'undefined' ||\n typeof IntersectionObserver === 'undefined'\n )\n return () => undefined\n const root = el.parentElement\n if (!root) return () => undefined\n\n let entry = byRoot.get(root)\n if (!entry) {\n const callbacks = new Map<Element, () => void>()\n const observer = new IntersectionObserver(\n (entries) => {\n for (const e of entries) {\n if (e.isIntersecting) callbacks.get(e.target)?.()\n }\n },\n { root, rootMargin: CENTER_ROOT_MARGIN, threshold: 0 },\n )\n entry = { observer, callbacks }\n byRoot.set(root, entry)\n }\n entry.callbacks.set(el, onEnter)\n entry.observer.observe(el)\n\n return () => {\n const e = byRoot.get(root)\n if (!e) return\n e.callbacks.delete(el)\n e.observer.unobserve(el)\n if (e.callbacks.size === 0) {\n e.observer.disconnect()\n byRoot.delete(root)\n }\n }\n}\n"],"mappings":";;;AACA,MAAM,qBAAqB;AAQ3B,MAAM,yBAAS,IAAI,IAA0B;;;;;;AAO7C,SAAgB,cACd,IACA,SACY;CAGZ,IACE,OAAO,WAAW,eAClB,OAAO,yBAAyB,aAEhC,aAAa;CACf,MAAM,OAAO,GAAG;CAChB,IAAI,CAAC,MAAM,aAAa;CAExB,IAAI,QAAQ,OAAO,IAAI,IAAI;CAC3B,IAAI,CAAC,OAAO;EACV,MAAM,4BAAY,IAAI,IAAyB;EAS/C,QAAQ;GAAE,cARW,sBAClB,YAAY;IACX,KAAK,MAAM,KAAK,SACd,IAAI,EAAE,gBAAgB,UAAU,IAAI,EAAE,MAAM,CAAC,GAAG;GAEpD,GACA;IAAE;IAAM,YAAY;IAAoB,WAAW;GAAE,CAE7C;GAAU;EAAU;EAC9B,OAAO,IAAI,MAAM,KAAK;CACxB;CACA,MAAM,UAAU,IAAI,IAAI,OAAO;CAC/B,MAAM,SAAS,QAAQ,EAAE;CAEzB,aAAa;EACX,MAAM,IAAI,OAAO,IAAI,IAAI;EACzB,IAAI,CAAC,GAAG;EACR,EAAE,UAAU,OAAO,EAAE;EACrB,EAAE,SAAS,UAAU,EAAE;EACvB,IAAI,EAAE,UAAU,SAAS,GAAG;GAC1B,EAAE,SAAS,WAAW;GACtB,OAAO,OAAO,IAAI;EACpB;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intersectionObserver.js","names":[
|
|
1
|
+
{"version":3,"file":"intersectionObserver.js","names":[],"sources":["../../../src/components/Carousel/intersectionObserver.ts"],"sourcesContent":["// 中央検出(左右 50% を除外)。root は item の親(scroller)から導出する。\nconst CENTER_ROOT_MARGIN = '0px -50% 0px -50%'\n\ntype CenterEntry = {\n observer: IntersectionObserver\n callbacks: Map<Element, () => void>\n}\n\n// root(= el.parentElement)ごとに observer を1つ共有する。\nconst byRoot = new Map<Element, CenterEntry>()\n\n/**\n * `el` がその親(= scroller)の中央ラインに重なったら `onEnter` を呼ぶ。同一 root の\n * IntersectionObserver を共有する singleton。返り値で監視解除(最後の1つで disconnect)。\n * SSR / 非対応環境では no-op。\n */\nexport function observeCenter(\n el: HTMLElement,\n onEnter: () => void,\n): () => void {\n // window で SSR を弾く。polyfill が global に IntersectionObserver を生やしていても\n // サーバー上では observe しない。\n if (\n typeof window === 'undefined' ||\n typeof IntersectionObserver === 'undefined'\n )\n return () => undefined\n const root = el.parentElement\n if (!root) return () => undefined\n\n let entry = byRoot.get(root)\n if (!entry) {\n const callbacks = new Map<Element, () => void>()\n const observer = new IntersectionObserver(\n (entries) => {\n for (const e of entries) {\n if (e.isIntersecting) callbacks.get(e.target)?.()\n }\n },\n { root, rootMargin: CENTER_ROOT_MARGIN, threshold: 0 },\n )\n entry = { observer, callbacks }\n byRoot.set(root, entry)\n }\n entry.callbacks.set(el, onEnter)\n entry.observer.observe(el)\n\n return () => {\n const e = byRoot.get(root)\n if (!e) return\n e.callbacks.delete(el)\n e.observer.unobserve(el)\n if (e.callbacks.size === 0) {\n e.observer.disconnect()\n byRoot.delete(root)\n }\n }\n}\n"],"mappings":";;AACA,MAAM,qBAAqB;AAQ3B,MAAM,yBAAS,IAAI,IAA0B;;;;;;AAO7C,SAAgB,cACd,IACA,SACY;CAGZ,IACE,OAAO,WAAW,eAClB,OAAO,yBAAyB,aAEhC,aAAa;CACf,MAAM,OAAO,GAAG;CAChB,IAAI,CAAC,MAAM,aAAa;CAExB,IAAI,QAAQ,OAAO,IAAI,IAAI;CAC3B,IAAI,CAAC,OAAO;EACV,MAAM,4BAAY,IAAI,IAAyB;EAS/C,QAAQ;GAAE,cARW,sBAClB,YAAY;IACX,KAAK,MAAM,KAAK,SACd,IAAI,EAAE,gBAAgB,UAAU,IAAI,EAAE,MAAM,CAAC,GAAG;GAEpD,GACA;IAAE;IAAM,YAAY;IAAoB,WAAW;GAAE,CAE7C;GAAU;EAAU;EAC9B,OAAO,IAAI,MAAM,KAAK;CACxB;CACA,MAAM,UAAU,IAAI,IAAI,OAAO;CAC/B,MAAM,SAAS,QAAQ,EAAE;CAEzB,aAAa;EACX,MAAM,IAAI,OAAO,IAAI,IAAI;EACzB,IAAI,CAAC,GAAG;EACR,EAAE,UAAU,OAAO,EAAE;EACrB,EAAE,SAAS,UAAU,EAAE;EACvB,IAAI,EAAE,UAAU,SAAS,GAAG;GAC1B,EAAE,SAAS,WAAW;GACtB,OAAO,OAAO,IAAI;EACpB;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resizeObserver.cjs","names":[
|
|
1
|
+
{"version":3,"file":"resizeObserver.cjs","names":[],"sources":["../../../src/components/Carousel/resizeObserver.ts"],"sourcesContent":["// 全 el で単一の ResizeObserver を共有する singleton。\nlet observer: ResizeObserver | null = null\nconst callbacks = new Map<Element, () => void>()\n\nfunction getObserver(): ResizeObserver | null {\n // window で SSR を弾く。polyfill が global に ResizeObserver を生やしていても\n // サーバー上では observe しない。\n if (typeof window === 'undefined' || typeof ResizeObserver === 'undefined')\n return null\n if (!observer) {\n observer = new ResizeObserver((entries) => {\n for (const e of entries) callbacks.get(e.target)?.()\n })\n }\n return observer\n}\n\n/**\n * `el` のサイズ変化で `cb` を呼ぶ。全要素で単一の ResizeObserver を共有する singleton。\n * 返り値で監視解除(最後の1つで disconnect)。SSR / 非対応環境では no-op。\n */\nexport function observeResize(el: Element, cb: () => void): () => void {\n const obs = getObserver()\n if (!obs) return () => undefined\n callbacks.set(el, cb)\n obs.observe(el)\n return () => {\n callbacks.delete(el)\n obs.unobserve(el)\n if (callbacks.size === 0) {\n obs.disconnect()\n observer = null\n }\n }\n}\n"],"mappings":";;;AACA,IAAI,WAAkC;AACtC,MAAM,4BAAY,IAAI,IAAyB;AAE/C,SAAS,cAAqC;CAG5C,IAAI,OAAO,WAAW,eAAe,OAAO,mBAAmB,aAC7D,OAAO;CACT,IAAI,CAAC,UACH,WAAW,IAAI,gBAAgB,YAAY;EACzC,KAAK,MAAM,KAAK,SAAS,UAAU,IAAI,EAAE,MAAM,CAAC,GAAG;CACrD,CAAC;CAEH,OAAO;AACT;;;;;AAMA,SAAgB,cAAc,IAAa,IAA4B;CACrE,MAAM,MAAM,YAAY;CACxB,IAAI,CAAC,KAAK,aAAa;CACvB,UAAU,IAAI,IAAI,EAAE;CACpB,IAAI,QAAQ,EAAE;CACd,aAAa;EACX,UAAU,OAAO,EAAE;EACnB,IAAI,UAAU,EAAE;EAChB,IAAI,UAAU,SAAS,GAAG;GACxB,IAAI,WAAW;GACf,WAAW;EACb;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resizeObserver.js","names":[
|
|
1
|
+
{"version":3,"file":"resizeObserver.js","names":[],"sources":["../../../src/components/Carousel/resizeObserver.ts"],"sourcesContent":["// 全 el で単一の ResizeObserver を共有する singleton。\nlet observer: ResizeObserver | null = null\nconst callbacks = new Map<Element, () => void>()\n\nfunction getObserver(): ResizeObserver | null {\n // window で SSR を弾く。polyfill が global に ResizeObserver を生やしていても\n // サーバー上では observe しない。\n if (typeof window === 'undefined' || typeof ResizeObserver === 'undefined')\n return null\n if (!observer) {\n observer = new ResizeObserver((entries) => {\n for (const e of entries) callbacks.get(e.target)?.()\n })\n }\n return observer\n}\n\n/**\n * `el` のサイズ変化で `cb` を呼ぶ。全要素で単一の ResizeObserver を共有する singleton。\n * 返り値で監視解除(最後の1つで disconnect)。SSR / 非対応環境では no-op。\n */\nexport function observeResize(el: Element, cb: () => void): () => void {\n const obs = getObserver()\n if (!obs) return () => undefined\n callbacks.set(el, cb)\n obs.observe(el)\n return () => {\n callbacks.delete(el)\n obs.unobserve(el)\n if (callbacks.size === 0) {\n obs.disconnect()\n observer = null\n }\n }\n}\n"],"mappings":";;AACA,IAAI,WAAkC;AACtC,MAAM,4BAAY,IAAI,IAAyB;AAE/C,SAAS,cAAqC;CAG5C,IAAI,OAAO,WAAW,eAAe,OAAO,mBAAmB,aAC7D,OAAO;CACT,IAAI,CAAC,UACH,WAAW,IAAI,gBAAgB,YAAY;EACzC,KAAK,MAAM,KAAK,SAAS,UAAU,IAAI,EAAE,MAAM,CAAC,GAAG;CACrD,CAAC;CAEH,OAAO;AACT;;;;;AAMA,SAAgB,cAAc,IAAa,IAA4B;CACrE,MAAM,MAAM,YAAY;CACxB,IAAI,CAAC,KAAK,aAAa;CACvB,UAAU,IAAI,IAAI,EAAE;CACpB,IAAI,QAAQ,EAAE;CACd,aAAa;EACX,UAAU,OAAO,EAAE;EACnB,IAAI,UAAU,EAAE;EAChB,IAAI,UAAU,SAAS,GAAG;GACxB,IAAI,WAAW;GACf,WAAW;EACb;CACF;AACF"}
|