@loadsmart/loadsmart-ui 5.14.3 → 5.15.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/components/Drawer/Drawer.d.ts +3 -2
- package/dist/components/Drawer/Drawer.stories.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Drawer/Drawer.stories.tsx +3 -3
- package/src/components/Drawer/Drawer.test.tsx +24 -2
- package/src/components/Drawer/Drawer.tsx +29 -5
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
1
|
import type { PropsWithChildren } from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
3
|
export interface DrawerProps {
|
|
4
4
|
children?: ReactNode;
|
|
5
5
|
className?: string;
|
|
6
6
|
open: boolean;
|
|
7
7
|
onClose?: () => void;
|
|
8
|
+
onClickOutside?: () => void;
|
|
8
9
|
}
|
|
9
10
|
export interface DrawerHeaderProps {
|
|
10
11
|
className?: string;
|
|
@@ -18,7 +19,7 @@ export interface DrawerFooterProps {
|
|
|
18
19
|
className?: string;
|
|
19
20
|
}
|
|
20
21
|
declare function DrawerFooter({ children, className, ...others }: PropsWithChildren<DrawerFooterProps>): JSX.Element;
|
|
21
|
-
declare function Drawer({ className, children, open, onClose, ...others }: DrawerProps): JSX.Element;
|
|
22
|
+
declare function Drawer({ className, children, open, onClose, onClickOutside, ...others }: DrawerProps): JSX.Element;
|
|
22
23
|
declare namespace Drawer {
|
|
23
24
|
var Header: typeof DrawerHeader;
|
|
24
25
|
var Body: typeof DrawerBody;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Meta, Story } from '@storybook/react/types-6-0';
|
|
2
2
|
import type { DrawerProps } from './Drawer';
|
|
3
3
|
declare const _default: Meta<import("@storybook/react/types-6-0").Args>;
|
|
4
4
|
export default _default;
|
package/dist/index.js
CHANGED
|
@@ -2288,7 +2288,7 @@
|
|
|
2288
2288
|
border-top-color: ${r.getToken("color-neutral-light")};
|
|
2289
2289
|
border-top-width: 1px;
|
|
2290
2290
|
border-top-style: solid;
|
|
2291
|
-
`;function uc(n){var{className:r,children:o,open:a,onClose:l}=n,
|
|
2291
|
+
`;function uc(n){var{className:r,children:o,open:a,onClose:l,onClickOutside:i}=n,c=e.__rest(n,["className","children","open","onClose","onClickOutside"]);const[s,u]=t.useState(!a),g=t.useRef(null);return t.useEffect((()=>{a&&u(!1)}),[a]),t.useEffect((()=>{const e=g.current;if(e&&i){const t=t=>{e.isSameNode(t.target)&&i()};return e.addEventListener("mouseup",t),()=>e.removeEventListener("mouseup",t)}}),[i]),p.default.createPortal(d.default.createElement(ac,{open:!s,ref:g},d.default.createElement(ic,Object.assign({},c,{className:r,open:a,onTransitionEnd:function(){a||u(!0)},role:"dialog","aria-modal":"true","aria-label":"drawer"}),Boolean(l)&&d.default.createElement(lc,{onClick:l,"aria-label":"close"}),o)),document.body)}function gc(e){const{useSelectable:n}=Wr(),[r,o]=t.useState([]),a=function(e){const t={multiple:!0,selected:[],onChange(){},adapters:{generic:{getKey:e=>e.value}}};return e&&!0!==e?Object.assign(Object.assign({},t),e):t}(e),{selected:l,toggle:i,select:c,unselect:s,clear:d}=n(Object.assign(Object.assign({},a),{onChange:e=>a.onChange(e?[...e.values()]:[])})),u=l.size===r.length,g=t.useCallback((e=>{var t;const{adapters:n}=a,r=null==n?void 0:n[e._type||"generic"];return null!==(t=null==r?void 0:r.getKey(e))&&void 0!==t?t:""}),[a]),p=t.useCallback((e=>{if(!e)return;const t=g(e);o((n=>n.some((e=>g(e)===t))?n:[...n,e]))}),[g]);return{allRowsAreSelected:u,config:a,selected:l,toggle:i,toggleAll:function(){u?r.forEach((e=>{const t=g(e);t&&s(t)})):r.forEach((e=>c(e)))},clear:d,register:p}}uc.Header=function(t){var{children:n,className:r}=t,o=e.__rest(t,["children","className"]);return d.default.createElement(cc,Object.assign({},o,{className:r}),n)},uc.Body=function(t){var{children:n,className:r}=t,o=e.__rest(t,["children","className"]);return d.default.createElement(sc,Object.assign({},o,{className:r}),n)},uc.Footer=function(t){var{children:n,className:r}=t,o=e.__rest(t,["children","className"]);return d.default.createElement(dc,Object.assign({},o,{className:r}),n)};const pc=t.createContext({selected:void 0,config:{},allRowsAreSelected:!1,toggle(){},toggleAll(){},clear(){},register(){}});function hc({children:e,selection:t}){const n=gc(t);return d.default.createElement(pc.Provider,{value:n},e)}function fc(){return t.useContext(pc)}function mc(e,t,n){const{adapters:r}=n,o=null==r?void 0:r[e._type||"generic"],a=null==o?void 0:o.getKey(e);return!!a&&t.has(a)}const bc=g.default(Jt)`
|
|
2292
2292
|
display: inline-flex;
|
|
2293
2293
|
flex-flow: row nowrap;
|
|
2294
2294
|
align-items: center;
|