@chayns-components/core 5.5.51 → 5.5.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/components/dropdown-body-wrapper/delayed-dropdown-content/DelayedDropdownContent.js +1 -1
- package/lib/cjs/components/dropdown-body-wrapper/delayed-dropdown-content/DelayedDropdownContent.js.map +1 -1
- package/lib/cjs/components/filter/Filter.js +1 -1
- package/lib/cjs/components/filter/Filter.js.map +1 -1
- package/lib/cjs/components/list/list-item/ListItem.js +3 -1
- package/lib/cjs/components/list/list-item/ListItem.js.map +1 -1
- package/lib/cjs/components/list/list-item/ListItem.test.js +137 -0
- package/lib/cjs/components/list/list-item/ListItem.test.js.map +1 -0
- package/lib/cjs/components/list/list-item/list-item-head/ListItemHead.js +2 -1
- package/lib/cjs/components/list/list-item/list-item-head/ListItemHead.js.map +1 -1
- package/lib/cjs/components/search-box/search-box-body/SearchBoxBody.js +1 -1
- package/lib/cjs/components/search-box/search-box-body/SearchBoxBody.js.map +1 -1
- package/lib/cjs/hooks/element.js +1 -1
- package/lib/cjs/hooks/element.js.map +1 -1
- package/lib/esm/components/dropdown-body-wrapper/delayed-dropdown-content/DelayedDropdownContent.js +1 -1
- package/lib/esm/components/dropdown-body-wrapper/delayed-dropdown-content/DelayedDropdownContent.js.map +1 -1
- package/lib/esm/components/filter/Filter.js +1 -1
- package/lib/esm/components/filter/Filter.js.map +1 -1
- package/lib/esm/components/list/list-item/ListItem.js +3 -1
- package/lib/esm/components/list/list-item/ListItem.js.map +1 -1
- package/lib/esm/components/list/list-item/ListItem.test.js +133 -0
- package/lib/esm/components/list/list-item/ListItem.test.js.map +1 -0
- package/lib/esm/components/list/list-item/list-item-head/ListItemHead.js +2 -1
- package/lib/esm/components/list/list-item/list-item-head/ListItemHead.js.map +1 -1
- package/lib/esm/components/search-box/search-box-body/SearchBoxBody.js +1 -1
- package/lib/esm/components/search-box/search-box-body/SearchBoxBody.js.map +1 -1
- package/lib/esm/hooks/element.js +1 -1
- package/lib/esm/hooks/element.js.map +1 -1
- package/lib/types/components/list/list-item/ListItem.d.ts +17 -0
- package/lib/types/components/list/list-item/list-item-head/ListItemHead.d.ts +1 -0
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element.js","names":["React","Children","cloneElement","isValidElement","useEffect","useRef","useState","isSameRect","a","b","width","height","x","y","useElementSize","ref","shouldUseChildElement","shouldUseParentElement","size","setSize","target","current","parentElement","firstElementChild","undefined","frameId","updateSize","nextSize","window","cancelAnimationFrame","requestAnimationFrame","currentSize","getBoundingClientRect","observer","ResizeObserver","entry","contentRect","observe","disconnect","cloneWithTabIndex","node","element","type","Fragment","children","map","props","displayName","createElement","tabIndex","getClonedElement","content","preventEvents","onClick","e","stopPropagation","onMouseDown","onMouseUp","onKeyDown","onKeyUp","onFocus","onBlur","useMeasuredClone","shouldPreventTextWrapping","clonedElement","measure","offsetWidth","offsetHeight","measuredElement","style","position","opacity","pointerEvents","userSelect","zIndex","visibility","inert","useIsMeasuredClone","isClone","setIsClone","el","hasAttribute","useIsInsideDialog","isInsideDialog","setIsInsideDialog","closest"],"sources":["../../../src/hooks/element.tsx"],"sourcesContent":["import React, {\n Children,\n cloneElement,\n HTMLAttributes,\n isValidElement,\n MutableRefObject,\n ReactElement,\n ReactNode,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\ninterface UseElementSizeOptions {\n shouldUseChildElement?: boolean;\n shouldUseParentElement?: boolean;\n}\n\nconst isSameRect = (a?: DOMRectReadOnly, b?: DOMRectReadOnly) => {\n if (!a || !b) return false;\n\n return a.width === b.width && a.height === b.height && a.x === b.x && a.y === b.y;\n};\n\nexport const useElementSize = (\n ref: MutableRefObject<HTMLDivElement | HTMLLabelElement | null>,\n { shouldUseChildElement = false, shouldUseParentElement = false }: UseElementSizeOptions = {},\n): DOMRectReadOnly | undefined => {\n const [size, setSize] = useState<DOMRectReadOnly>();\n\n useEffect(() => {\n let target: HTMLElement | null = ref.current;\n\n if (shouldUseParentElement) {\n target = ref.current?.parentElement ?? null;\n }\n\n if (shouldUseChildElement) {\n target = ref.current?.firstElementChild as HTMLElement | null;\n }\n\n if (!target) return undefined;\n\n let frameId: number | undefined;\n\n const updateSize = (nextSize: DOMRectReadOnly) => {\n if (frameId) {\n window.cancelAnimationFrame(frameId);\n }\n\n frameId = window.requestAnimationFrame(() => {\n setSize((currentSize) =>\n isSameRect(currentSize, nextSize) ? currentSize : nextSize,\n );\n });\n };\n\n updateSize(target.getBoundingClientRect());\n\n const observer = new ResizeObserver(([entry]) => {\n if (!entry || entry.target !== target) return;\n\n updateSize(entry.contentRect);\n });\n\n observer.observe(target);\n\n return () => {\n if (frameId) {\n window.cancelAnimationFrame(frameId);\n }\n\n observer.disconnect();\n };\n }, [ref, shouldUseChildElement, shouldUseParentElement]);\n\n return size;\n};\n\nconst cloneWithTabIndex = (node: ReactNode): ReactNode => {\n if (!isValidElement(node)) return node;\n\n const element = node as ReactElement;\n\n if (element.type === React.Fragment) {\n const children = Children.map(element.props.children, cloneWithTabIndex);\n\n return cloneElement(element, {\n ...element.props,\n children,\n });\n }\n\n const children = element.props.children\n ? Children.map(element.props.children, cloneWithTabIndex)\n : element.props.children;\n\n if ((element.type as any).displayName === 'Button') {\n return (\n // eslint-disable-next-line react/button-has-type\n <button tabIndex={-1}>{children}</button>\n );\n }\n\n return cloneElement(element, {\n ...element.props,\n tabIndex: -1,\n children,\n });\n};\n\nconst getClonedElement = (content: ReactNode) => {\n const preventEvents: Partial<HTMLAttributes<never>> = {\n onClick: (e) => e.stopPropagation(),\n onMouseDown: (e) => e.stopPropagation(),\n onMouseUp: (e) => e.stopPropagation(),\n onKeyDown: (e) => e.stopPropagation(),\n onKeyUp: (e) => e.stopPropagation(),\n onFocus: (e) => e.stopPropagation(),\n onBlur: (e) => e.stopPropagation(),\n };\n\n if (typeof content === 'string') {\n return (\n <span tabIndex={-1} data-measured-clone>\n {content}\n </span>\n );\n }\n\n if (isValidElement(content)) {\n return cloneWithTabIndex(\n cloneElement(content, {\n ...preventEvents,\n 'data-measured-clone': true,\n }),\n );\n }\n\n return content;\n};\n\ninterface UseMeasuredCloneOptions {\n content: ReactNode;\n shouldPreventTextWrapping?: boolean;\n}\n\nexport const useMeasuredClone = ({\n content,\n shouldPreventTextWrapping = true,\n}: UseMeasuredCloneOptions) => {\n const ref = useRef<HTMLDivElement>(null);\n\n const [size, setSize] = useState({ width: 0, height: 0 });\n\n const clonedElement = getClonedElement(content);\n\n useEffect(() => {\n const measure = () => {\n if (!ref.current) return;\n\n const { offsetWidth: width, offsetHeight: height } = ref.current;\n\n setSize({ width: width + (shouldPreventTextWrapping ? 10 : 0), height });\n };\n\n measure();\n\n const observer = new ResizeObserver(measure);\n\n if (ref.current) observer.observe(ref.current);\n\n return () => observer.disconnect();\n }, [shouldPreventTextWrapping]);\n\n const measuredElement = (\n <div\n data-measured-clone=\"true\"\n ref={ref}\n style={{\n position: 'fixed',\n opacity: 0,\n pointerEvents: 'none',\n userSelect: 'none',\n zIndex: -1,\n height: 'auto',\n width: 'auto',\n visibility: 'hidden',\n }}\n inert=\"true\"\n tabIndex={-1}\n >\n {clonedElement}\n </div>\n );\n\n return {\n measuredElement,\n width: size.width,\n height: size.height,\n };\n};\n\nexport const useIsMeasuredClone = <T extends HTMLElement>() => {\n const ref = useRef<T | null>(null);\n\n const [isClone, setIsClone] = useState(false);\n\n useEffect(() => {\n if (!ref.current) return;\n\n let el: HTMLElement | null = ref.current;\n\n while (el) {\n if (el.hasAttribute('data-measured-clone')) {\n setIsClone(true);\n\n return;\n }\n\n el = el.parentElement;\n }\n\n setIsClone(false);\n }, []);\n\n return [isClone, ref] as const;\n};\n\nexport const useIsInsideDialog = <T extends HTMLElement>(ref: MutableRefObject<T | null>) => {\n const [isInsideDialog, setIsInsideDialog] = useState(false);\n\n useEffect(() => {\n if (!ref.current) {\n return;\n }\n\n setIsInsideDialog(ref.current.closest('.dialog-inner') !== null);\n }, [ref]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element.js","names":["React","Children","cloneElement","isValidElement","useEffect","useRef","useState","isSameRect","a","b","width","height","x","y","useElementSize","ref","shouldUseChildElement","shouldUseParentElement","size","setSize","target","current","parentElement","firstElementChild","undefined","frameId","updateSize","nextSize","window","cancelAnimationFrame","requestAnimationFrame","currentSize","getBoundingClientRect","observer","ResizeObserver","entry","contentRect","observe","disconnect","cloneWithTabIndex","node","element","type","Fragment","children","map","props","displayName","createElement","tabIndex","getClonedElement","content","preventEvents","onClick","e","stopPropagation","onMouseDown","onMouseUp","onKeyDown","onKeyUp","onFocus","onBlur","useMeasuredClone","shouldPreventTextWrapping","clonedElement","measure","offsetWidth","offsetHeight","measuredElement","style","position","opacity","pointerEvents","userSelect","zIndex","visibility","inert","useIsMeasuredClone","isClone","setIsClone","el","hasAttribute","useIsInsideDialog","isInsideDialog","setIsInsideDialog","closest"],"sources":["../../../src/hooks/element.tsx"],"sourcesContent":["import React, {\n Children,\n cloneElement,\n HTMLAttributes,\n isValidElement,\n MutableRefObject,\n ReactElement,\n ReactNode,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\ninterface UseElementSizeOptions {\n shouldUseChildElement?: boolean;\n shouldUseParentElement?: boolean;\n}\n\nconst isSameRect = (a?: DOMRectReadOnly, b?: DOMRectReadOnly) => {\n if (!a || !b) return false;\n\n return a.width === b.width && a.height === b.height && a.x === b.x && a.y === b.y;\n};\n\nexport const useElementSize = (\n ref: MutableRefObject<HTMLDivElement | HTMLLabelElement | null>,\n { shouldUseChildElement = false, shouldUseParentElement = false }: UseElementSizeOptions = {},\n): DOMRectReadOnly | undefined => {\n const [size, setSize] = useState<DOMRectReadOnly>();\n\n useEffect(() => {\n let target: HTMLElement | null = ref.current;\n\n if (shouldUseParentElement) {\n target = ref.current?.parentElement ?? null;\n }\n\n if (shouldUseChildElement) {\n target = ref.current?.firstElementChild as HTMLElement | null;\n }\n\n if (!target) return undefined;\n\n let frameId: number | undefined;\n\n const updateSize = (nextSize: DOMRectReadOnly) => {\n if (frameId) {\n window.cancelAnimationFrame(frameId);\n }\n\n frameId = window.requestAnimationFrame(() => {\n setSize((currentSize) =>\n isSameRect(currentSize, nextSize) ? currentSize : nextSize,\n );\n });\n };\n\n updateSize(target.getBoundingClientRect());\n\n const observer = new ResizeObserver(([entry]) => {\n if (!entry || entry.target !== target) return;\n\n updateSize(entry.contentRect);\n });\n\n observer.observe(target);\n\n return () => {\n if (frameId) {\n window.cancelAnimationFrame(frameId);\n }\n\n observer.disconnect();\n };\n }, [ref, shouldUseChildElement, shouldUseParentElement]);\n\n return size;\n};\n\nconst cloneWithTabIndex = (node: ReactNode): ReactNode => {\n if (!isValidElement(node)) return node;\n\n const element = node as ReactElement;\n\n if (element.type === React.Fragment) {\n const children = Children.map(element.props.children, cloneWithTabIndex);\n\n return cloneElement(element, {\n ...element.props,\n children,\n });\n }\n\n const children = element.props.children\n ? Children.map(element.props.children, cloneWithTabIndex)\n : element.props.children;\n\n if ((element.type as any).displayName === 'Button') {\n return (\n // eslint-disable-next-line react/button-has-type\n <button tabIndex={-1}>{children}</button>\n );\n }\n\n return cloneElement(element, {\n ...element.props,\n tabIndex: -1,\n children,\n });\n};\n\nconst getClonedElement = (content: ReactNode) => {\n const preventEvents: Partial<HTMLAttributes<never>> = {\n onClick: (e) => e.stopPropagation(),\n onMouseDown: (e) => e.stopPropagation(),\n onMouseUp: (e) => e.stopPropagation(),\n onKeyDown: (e) => e.stopPropagation(),\n onKeyUp: (e) => e.stopPropagation(),\n onFocus: (e) => e.stopPropagation(),\n onBlur: (e) => e.stopPropagation(),\n };\n\n if (typeof content === 'string') {\n return (\n <span tabIndex={-1} data-measured-clone>\n {content}\n </span>\n );\n }\n\n if (isValidElement(content)) {\n return cloneWithTabIndex(\n cloneElement(content, {\n ...preventEvents,\n 'data-measured-clone': true,\n }),\n );\n }\n\n return content;\n};\n\ninterface UseMeasuredCloneOptions {\n content: ReactNode;\n shouldPreventTextWrapping?: boolean;\n}\n\nexport const useMeasuredClone = ({\n content,\n shouldPreventTextWrapping = true,\n}: UseMeasuredCloneOptions) => {\n const ref = useRef<HTMLDivElement>(null);\n\n const [size, setSize] = useState({ width: 0, height: 0 });\n\n const clonedElement = getClonedElement(content);\n\n useEffect(() => {\n const measure = () => {\n if (!ref.current) return;\n\n const { offsetWidth: width, offsetHeight: height } = ref.current;\n\n setSize({ width: width + (shouldPreventTextWrapping ? 10 : 0), height });\n };\n\n measure();\n\n const observer = new ResizeObserver(measure);\n\n if (ref.current) observer.observe(ref.current);\n\n return () => observer.disconnect();\n }, [shouldPreventTextWrapping]);\n\n const measuredElement = (\n <div\n data-measured-clone=\"true\"\n ref={ref}\n style={{\n position: 'fixed',\n opacity: 0,\n pointerEvents: 'none',\n userSelect: 'none',\n zIndex: -1,\n height: 'auto',\n width: 'auto',\n visibility: 'hidden',\n }}\n inert={true}\n tabIndex={-1}\n >\n {clonedElement}\n </div>\n );\n\n return {\n measuredElement,\n width: size.width,\n height: size.height,\n };\n};\n\nexport const useIsMeasuredClone = <T extends HTMLElement>() => {\n const ref = useRef<T | null>(null);\n\n const [isClone, setIsClone] = useState(false);\n\n useEffect(() => {\n if (!ref.current) return;\n\n let el: HTMLElement | null = ref.current;\n\n while (el) {\n if (el.hasAttribute('data-measured-clone')) {\n setIsClone(true);\n\n return;\n }\n\n el = el.parentElement;\n }\n\n setIsClone(false);\n }, []);\n\n return [isClone, ref] as const;\n};\n\nexport const useIsInsideDialog = <T extends HTMLElement>(ref: MutableRefObject<T | null>) => {\n const [isInsideDialog, setIsInsideDialog] = useState(false);\n\n useEffect(() => {\n if (!ref.current) {\n return;\n }\n\n setIsInsideDialog(ref.current.closest('.dialog-inner') !== null);\n }, [ref]);\n\n return isInsideDialog;\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IACRC,QAAQ,EACRC,YAAY,EAEZC,cAAc,EAIdC,SAAS,EACTC,MAAM,EACNC,QAAQ,QACL,OAAO;AAOd,MAAMC,UAAU,GAAGA,CAACC,CAAmB,EAAEC,CAAmB,KA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AAI,CAACP;EACjB,CAAC;AACL,CAAC;AAED,OAAO,MAAMkE,kBAAkB,GAAGA,CAAA,KAA6B;EAC3D,MAAM9D,GAAG,GAAGV,MAAM,CAAW,IAAI,CAAC;EAElC,MAAM,CAACyE,OAAO,EAAEC,UAAU,CAAC,GAAGzE,QAAQ,CAAC,KAAK,CAAC;EAE7CF,SAAS,CAAC,MAAM;IACZ,IAAI,CAACW,GAAG,CAACM,OAAO,EAAE;IAElB,IAAI2D,EAAsB,GAAGjE,GAAG,CAACM,OAAO;IAExC,OAAO2D,EAAE,EAAE;MACP,IAAIA,EAAE,CAACC,YAAY,CAAC,qBAAqB,CAAC,EAAE;QACxCF,UAAU,CAAC,IAAI,CAAC;QAEhB;MACJ;MAEAC,EAAE,GAAGA,EAAE,CAAC1D,aAAa;IACzB;IAEAyD,UAAU,CAAC,KAAK,CAAC;EACrB,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO,CAACD,OAAO,EAAE/D,GAAG,CAAC;AACzB,CAAC;AAED,OAAO,MAAMmE,iBAAiB,GAA2BnE,GAA+B,IAAK;EACzF,MAAM,CAACoE,cAAc,EAAEC,iBAAiB,CAAC,GAAG9E,QAAQ,CAAC,KAAK,CAAC;EAE3DF,SAAS,CAAC,MAAM;IACZ,IAAI,CAACW,GAAG,CAACM,OAAO,EAAE;MACd;IACJ;IAEA+D,iBAAiB,CAACrE,GAAG,CAACM,OAAO,CAACgE,OAAO,CAAC,eAAe,CAAC,KAAK,IAAI,CAAC;EACpE,CAAC,EAAE,CAACtE,GAAG,CAAC,CAAC;EAET,OAAOoE,cAAc;AACzB,CAAC","ignoreList":[]}
|
|
@@ -119,10 +119,27 @@ export type ListItemProps = {
|
|
|
119
119
|
* Whether the image should be opened on click.
|
|
120
120
|
*/
|
|
121
121
|
shouldOpenImageOnClick?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Whether the framer-motion layout projection (`layout="position"`) should be
|
|
124
|
+
* enabled. This animates the `ListItem` smoothly into its new position when
|
|
125
|
+
* sibling items are reordered, expanded or resized.
|
|
126
|
+
*
|
|
127
|
+
* This is opt-in and disabled by default, because framer-motions layout
|
|
128
|
+
* projection is viewport-global: every layout change anywhere in the document
|
|
129
|
+
* (window resize, height animation, ...) forces a re-measurement of **all**
|
|
130
|
+
* layout-projection nodes via `getBoundingClientRect`. In lists with many
|
|
131
|
+
* `ListItem`s this scales linearly and causes noticeable layout thrash. The
|
|
132
|
+
* enter/exit height/opacity animation is unaffected and stays enabled.
|
|
133
|
+
*/
|
|
134
|
+
shouldAnimateLayout?: boolean;
|
|
122
135
|
/**
|
|
123
136
|
* Whether the layout animation should be prevented. This is useful when the
|
|
124
137
|
* `ListItem` is used in a list with a lot of items and the layout animation
|
|
125
138
|
* is not desired.
|
|
139
|
+
*
|
|
140
|
+
* @deprecated The layout projection is now disabled by default. Use
|
|
141
|
+
* `shouldAnimateLayout` to opt into it instead. When set to `true`, this
|
|
142
|
+
* prop keeps forcing the layout projection off.
|
|
126
143
|
*/
|
|
127
144
|
shouldPreventLayoutAnimation?: boolean;
|
|
128
145
|
/**
|
|
@@ -26,6 +26,7 @@ type ListItemHeadProps = {
|
|
|
26
26
|
shouldForceHover?: boolean;
|
|
27
27
|
setShouldEnableTooltip: (value: boolean) => void;
|
|
28
28
|
shouldDisableAnimation?: boolean;
|
|
29
|
+
shouldAnimateLayout?: boolean;
|
|
29
30
|
cornerElement?: ReactNode;
|
|
30
31
|
onTitleWidthChange: (titleWidth: number, titleMaxWidth: number) => void;
|
|
31
32
|
onImageError?: (event: SyntheticEvent<HTMLImageElement, Event>, index: number) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chayns-components/core",
|
|
3
|
-
"version": "5.5.
|
|
3
|
+
"version": "5.5.53",
|
|
4
4
|
"description": "A set of beautiful React components for developing your own applications with chayns.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"browserslist": [
|
|
@@ -93,5 +93,5 @@
|
|
|
93
93
|
"publishConfig": {
|
|
94
94
|
"access": "public"
|
|
95
95
|
},
|
|
96
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "c4c4ef585202346a5c6aa850c442843d851c4dd6"
|
|
97
97
|
}
|