@yamada-ui/react
Version:
React UI components of the Yamada, by the Yamada, for the Yamada built with React and Emotion
1 lines • 4.82 kB
Source Map (JSON)
{"version":3,"file":"resizable.cjs","names":["createSlotComponent","resizableStyle","useResizable","useValue","ResizableContext","styled","PanelGroup","Panel","useResizableItem","useResizableTrigger","PanelResizeHandle"],"sources":["../../../../src/components/resizable/resizable.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ForwardedRef, ReactElement } from \"react\"\nimport type {\n HTMLStyledProps,\n HTMLStyledPropsWithoutAs,\n ThemeProps,\n} from \"../../core\"\nimport type { ResizableStyle } from \"./resizable.style\"\nimport type {\n UseResizableItemProps,\n UseResizableProps,\n UseResizableTriggerProps,\n} from \"./use-resizable\"\nimport { useMemo } from \"react\"\nimport { Panel, PanelGroup, PanelResizeHandle } from \"react-resizable-panels\"\nimport { createSlotComponent, styled } from \"../../core\"\nimport { useValue } from \"../../hooks/use-value\"\nimport { resizableStyle } from \"./resizable.style\"\nimport {\n ResizableContext,\n useResizable,\n useResizableItem,\n useResizableTrigger,\n} from \"./use-resizable\"\n\n/**\n * `Resizable` is accessible resizable panel groups and layouts with keyboard support.\n *\n * @see https://yamada-ui.com/docs/components/resizable\n */\nexport interface ResizableRootProps\n extends HTMLStyledProps,\n ThemeProps<ResizableStyle>,\n Omit<UseResizableProps, \"orientation\"> {\n /**\n * Ref for resizable root element.\n */\n rootRef?: ForwardedRef<HTMLDivElement>\n}\n\nconst {\n PropsContext: ResizablePropsContext,\n usePropsContext: useResizablePropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<ResizableRootProps, ResizableStyle>(\n \"resizable\",\n resizableStyle,\n)\n\nexport { ResizablePropsContext, useResizablePropsContext }\n\nexport const ResizableRoot = withProvider<\n \"div\",\n ResizableRootProps,\n \"orientation\"\n>(\n ({ children, orientation: orientationProp, rootRef, ...rest }) => {\n const computedOrientation = useValue(orientationProp)\n const { controlRef, disabled, orientation, getGroupProps, getRootProps } =\n useResizable({ orientation: computedOrientation, ...rest })\n\n const context = useMemo(\n () => ({ controlRef, disabled, orientation }),\n [disabled, orientation, controlRef],\n )\n\n return (\n <ResizableContext value={context}>\n <styled.div {...getRootProps({ ref: rootRef })}>\n <PanelGroup {...getGroupProps()}>{children}</PanelGroup>\n </styled.div>\n </ResizableContext>\n )\n },\n \"root\",\n { transferProps: [\"orientation\"] },\n)()\n\nconst StyledPanel = styled(Panel, { forwardProps: [\"order\"] })\n\nexport interface ResizableItemProps\n extends Omit<HTMLStyledPropsWithoutAs, \"order\">,\n UseResizableItemProps {}\n\nexport const ResizableItem = withContext<\"div\", ResizableItemProps>((props) => {\n const { getItemProps } = useResizableItem(props)\n\n return <StyledPanel {...getItemProps()} />\n}, \"item\")()\n\nexport interface ResizableTriggerProps\n extends HTMLStyledPropsWithoutAs,\n UseResizableTriggerProps {\n /**\n * The resizable trigger icon to use.\n */\n icon?: ReactElement\n /**\n * Props for resizable trigger icon component.\n */\n iconProps?: HTMLStyledProps\n}\n\nexport const ResizableTrigger = withContext<\"div\", ResizableTriggerProps>(\n ({ children, icon, iconProps, ...rest }) => {\n const { getIconProps, getTriggerProps } = useResizableTrigger(rest)\n\n return (\n <styled.div as={PanelResizeHandle} {...getTriggerProps()}>\n {icon ? (\n <ResizableIcon {...getIconProps(iconProps)}>{icon}</ResizableIcon>\n ) : null}\n\n {children}\n </styled.div>\n )\n },\n \"trigger\",\n)()\n\ninterface ResizableIconProps extends HTMLStyledProps {}\n\nconst ResizableIcon = withContext<\"div\", ResizableIconProps>(\"div\", \"icon\")()\n"],"mappings":";;;;;;;;;;;;;;;;;AAyCA,MAAM,EACJ,cAAc,uBACd,iBAAiB,0BACjB,aACA,iBACEA,6CACF,aACAC,uCACD;AAID,MAAa,gBAAgB,cAK1B,EAAE,UAAU,aAAa,iBAAiB,QAAS,GAAG,WAAW;CAEhE,MAAM,EAAE,YAAY,UAAU,aAAa,eAAe,iBACxDC,mCAAa;EAAE,aAFWC,uCAAS,gBAAgB;EAEF,GAAG;EAAM,CAAC;AAO7D,QACE,2CAACC;EAAiB,iCALX;GAAE;GAAY;GAAU;GAAa,GAC5C;GAAC;GAAU;GAAa;GAAW,CACpC;YAIG,2CAACC,uBAAO;GAAI,GAAI,aAAa,EAAE,KAAK,SAAS,CAAC;aAC5C,2CAACC;IAAW,GAAI,eAAe;IAAG;KAAsB;IAC7C;GACI;GAGvB,QACA,EAAE,eAAe,CAAC,cAAc,EAAE,CACnC,EAAE;AAEH,MAAM,cAAcD,uBAAOE,8BAAO,EAAE,cAAc,CAAC,QAAQ,EAAE,CAAC;AAM9D,MAAa,gBAAgB,aAAwC,UAAU;CAC7E,MAAM,EAAE,iBAAiBC,uCAAiB,MAAM;AAEhD,QAAO,2CAAC,eAAY,GAAI,cAAc,GAAI;GACzC,OAAO,EAAE;AAeZ,MAAa,mBAAmB,aAC7B,EAAE,UAAU,MAAM,UAAW,GAAG,WAAW;CAC1C,MAAM,EAAE,cAAc,oBAAoBC,0CAAoB,KAAK;AAEnE,QACE,4CAACJ,uBAAO;EAAI,IAAIK;EAAmB,GAAI,iBAAiB;aACrD,OACC,2CAAC;GAAc,GAAI,aAAa,UAAU;aAAG;IAAqB,GAChE,MAEH;GACU;GAGjB,UACD,EAAE;AAIH,MAAM,gBAAgB,YAAuC,OAAO,OAAO,EAAE"}