@bitrise/bitkit-v2 0.3.342 → 0.3.344
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/BitkitCollapsible/BitkitCollapsible.js +33 -3
- package/dist/components/BitkitCollapsible/BitkitCollapsible.js.map +1 -1
- package/dist/theme/slot-recipes/Ribbon.recipe.d.ts +1 -1
- package/dist/theme/slot-recipes/Ribbon.recipe.js +1 -1
- package/dist/theme/slot-recipes/Ribbon.recipe.js.map +1 -1
- package/dist/theme/slot-recipes/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,14 +1,41 @@
|
|
|
1
1
|
import IconChevronDown from "../../icons/IconChevronDown.js";
|
|
2
2
|
import IconChevronUp from "../../icons/IconChevronUp.js";
|
|
3
3
|
import BitkitLabel from "../BitkitLabel/BitkitLabel.js";
|
|
4
|
+
import { Box } from "@chakra-ui/react/box";
|
|
4
5
|
import { useSlotRecipe } from "@chakra-ui/react/styled-system";
|
|
5
|
-
import { forwardRef } from "react";
|
|
6
|
+
import { forwardRef, useRef, useState } from "react";
|
|
6
7
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { useSafeLayoutEffect } from "@chakra-ui/react/hooks";
|
|
7
9
|
import { Collapsible } from "@chakra-ui/react/collapsible";
|
|
8
10
|
//#region lib/components/BitkitCollapsible/BitkitCollapsible.tsx
|
|
11
|
+
var useIsContentOverflowing = (collapsedHeight) => {
|
|
12
|
+
const contentRef = useRef(null);
|
|
13
|
+
const [isOverflowing, setIsOverflowing] = useState(true);
|
|
14
|
+
useSafeLayoutEffect(() => {
|
|
15
|
+
const contentEl = contentRef.current;
|
|
16
|
+
const measureScope = contentEl?.parentElement;
|
|
17
|
+
if (!contentEl || !measureScope) return;
|
|
18
|
+
const probe = document.createElement("div");
|
|
19
|
+
probe.style.cssText = `position: absolute; visibility: hidden; pointer-events: none; height: ${collapsedHeight};`;
|
|
20
|
+
measureScope.appendChild(probe);
|
|
21
|
+
const collapsedHeightPx = probe.getBoundingClientRect().height;
|
|
22
|
+
measureScope.removeChild(probe);
|
|
23
|
+
const checkOverflow = () => setIsOverflowing(contentEl.scrollHeight > collapsedHeightPx);
|
|
24
|
+
checkOverflow();
|
|
25
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
26
|
+
const resizeObserver = new ResizeObserver(checkOverflow);
|
|
27
|
+
resizeObserver.observe(contentEl);
|
|
28
|
+
return () => resizeObserver.disconnect();
|
|
29
|
+
}, [collapsedHeight]);
|
|
30
|
+
return {
|
|
31
|
+
contentRef,
|
|
32
|
+
isOverflowing
|
|
33
|
+
};
|
|
34
|
+
};
|
|
9
35
|
var BitkitCollapsible = forwardRef((props, ref) => {
|
|
10
36
|
const { children, closedLabel = "Show less", collapsedHeight = "48px", defaultOpen, label, labelProps, onOpenChange, open, openLabel = "Show more", ...rest } = props;
|
|
11
37
|
const styles = useSlotRecipe({ key: "collapsible" })();
|
|
38
|
+
const { contentRef, isOverflowing } = useIsContentOverflowing(collapsedHeight);
|
|
12
39
|
const handleOpenChange = onOpenChange ? (details) => onOpenChange(details.open) : void 0;
|
|
13
40
|
return /* @__PURE__ */ jsxs(Collapsible.Root, {
|
|
14
41
|
ref,
|
|
@@ -25,9 +52,12 @@ var BitkitCollapsible = forwardRef((props, ref) => {
|
|
|
25
52
|
}),
|
|
26
53
|
/* @__PURE__ */ jsx(Collapsible.Content, {
|
|
27
54
|
css: styles.content,
|
|
28
|
-
children
|
|
55
|
+
children: /* @__PURE__ */ jsx(Box, {
|
|
56
|
+
ref: contentRef,
|
|
57
|
+
children
|
|
58
|
+
})
|
|
29
59
|
}),
|
|
30
|
-
/* @__PURE__ */ jsx(Collapsible.Trigger, {
|
|
60
|
+
isOverflowing && /* @__PURE__ */ jsx(Collapsible.Trigger, {
|
|
31
61
|
css: styles.trigger,
|
|
32
62
|
children: /* @__PURE__ */ jsx(Collapsible.Context, { children: (api) => /* @__PURE__ */ jsxs(Fragment$1, { children: [api.open ? closedLabel : openLabel, api.open ? /* @__PURE__ */ jsx(IconChevronUp, { size: "16" }) : /* @__PURE__ */ jsx(IconChevronDown, { size: "16" })] }) })
|
|
33
63
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BitkitCollapsible.js","names":[],"sources":["../../../lib/components/BitkitCollapsible/BitkitCollapsible.tsx"],"sourcesContent":["import { Collapsible, type CollapsibleRootProps } from '@chakra-ui/react/collapsible';\nimport { useSlotRecipe } from '@chakra-ui/react/styled-system';\nimport { forwardRef, type ReactNode } from 'react';\n\n// TODO: Investigate using AssetSelectChevron instead of IconChevronDown/IconChevronUp\nimport { IconChevronDown, IconChevronUp } from '../../icons';\nimport BitkitLabel, { type BitkitLabelProps } from '../BitkitLabel/BitkitLabel';\n\ntype UncontrolledProps = {\n defaultOpen?: boolean;\n open?: never;\n onOpenChange?: never;\n};\n\ntype ControlledProps = {\n defaultOpen?: never;\n onOpenChange: (open: boolean) => void;\n open: boolean;\n};\n\nexport type BitkitCollapsibleProps = Omit<\n CollapsibleRootProps,\n 'collapsedHeight' | 'defaultOpen' | 'onOpenChange' | 'open'\n> & {\n children: ReactNode;\n closedLabel?: string;\n collapsedHeight?: string;\n label?: string;\n labelProps?: Omit<BitkitLabelProps, 'children'>;\n openLabel?: string;\n} & (UncontrolledProps | ControlledProps);\n\nconst BitkitCollapsible = forwardRef<HTMLDivElement, BitkitCollapsibleProps>((props, ref) => {\n const {\n children,\n closedLabel = 'Show less',\n collapsedHeight = '48px',\n defaultOpen,\n label,\n labelProps,\n onOpenChange,\n open,\n openLabel = 'Show more',\n ...rest\n } = props;\n\n const recipe = useSlotRecipe({ key: 'collapsible' });\n const styles = recipe();\n\n const handleOpenChange = onOpenChange ? (details: { open: boolean }) => onOpenChange(details.open) : undefined;\n\n return (\n <Collapsible.Root\n ref={ref}\n collapsedHeight={collapsedHeight}\n css={styles.root}\n defaultOpen={defaultOpen}\n onOpenChange={handleOpenChange}\n open={open}\n {...rest}\n >\n {label && <BitkitLabel {...labelProps}>{label}</BitkitLabel>}\n <Collapsible.Content css={styles.content}>{children}</Collapsible.Content>\n <Collapsible.Trigger css={styles.trigger}>\n
|
|
1
|
+
{"version":3,"file":"BitkitCollapsible.js","names":[],"sources":["../../../lib/components/BitkitCollapsible/BitkitCollapsible.tsx"],"sourcesContent":["import { Box } from '@chakra-ui/react/box';\nimport { Collapsible, type CollapsibleRootProps } from '@chakra-ui/react/collapsible';\nimport { useSafeLayoutEffect } from '@chakra-ui/react/hooks';\nimport { useSlotRecipe } from '@chakra-ui/react/styled-system';\nimport { forwardRef, type ReactNode, useRef, useState } from 'react';\n\n// TODO: Investigate using AssetSelectChevron instead of IconChevronDown/IconChevronUp\nimport { IconChevronDown, IconChevronUp } from '../../icons';\nimport BitkitLabel, { type BitkitLabelProps } from '../BitkitLabel/BitkitLabel';\n\ntype UncontrolledProps = {\n defaultOpen?: boolean;\n open?: never;\n onOpenChange?: never;\n};\n\ntype ControlledProps = {\n defaultOpen?: never;\n onOpenChange: (open: boolean) => void;\n open: boolean;\n};\n\nexport type BitkitCollapsibleProps = Omit<\n CollapsibleRootProps,\n 'collapsedHeight' | 'defaultOpen' | 'onOpenChange' | 'open'\n> & {\n children: ReactNode;\n closedLabel?: string;\n collapsedHeight?: string;\n label?: string;\n labelProps?: Omit<BitkitLabelProps, 'children'>;\n openLabel?: string;\n} & (UncontrolledProps | ControlledProps);\n\n// contentRef sits on an unclamped wrapper *inside* Collapsible.Content, not on Content itself: when\n// closed, Content's own box is pinned to collapsedHeight (max-height + overflow), so a ResizeObserver\n// on Content can't see content that grows without changing Content's own (clamped) box - e.g. an image\n// or async child rendering more after mount. scrollHeight still reports the wrapper's true height\n// either way, clamped or not, so the read doesn't change - only where we watch for changes does.\n// collapsedHeight is the only effect dependency: the wrapper being unclamped means the observer itself\n// sees every content-driven size change, so re-running the whole effect just because `children`'s\n// identity changed (which it does on every parent render, once children stop being a plain string)\n// would only add a redundant probe/layout/observer teardown-and-rebuild on top of what the observer\n// already covers.\nconst useIsContentOverflowing = (collapsedHeight: string) => {\n const contentRef = useRef<HTMLDivElement>(null);\n const [isOverflowing, setIsOverflowing] = useState(true);\n\n useSafeLayoutEffect(() => {\n const contentEl = contentRef.current;\n const measureScope = contentEl?.parentElement;\n if (!contentEl || !measureScope) {\n return undefined;\n }\n\n // Appended as a sibling of contentEl (not document.body) so it inherits the same font-size and\n // CSS custom properties contentEl actually sees, resolving em/var(...) heights correctly - not\n // just px/rem, which don't depend on where in the tree they're resolved.\n const probe = document.createElement('div');\n probe.style.cssText = `position: absolute; visibility: hidden; pointer-events: none; height: ${collapsedHeight};`;\n measureScope.appendChild(probe);\n const collapsedHeightPx = probe.getBoundingClientRect().height;\n measureScope.removeChild(probe);\n\n const checkOverflow = () => setIsOverflowing(contentEl.scrollHeight > collapsedHeightPx);\n checkOverflow();\n\n if (typeof ResizeObserver === 'undefined') {\n return undefined;\n }\n\n const resizeObserver = new ResizeObserver(checkOverflow);\n resizeObserver.observe(contentEl);\n return () => resizeObserver.disconnect();\n }, [collapsedHeight]);\n\n return { contentRef, isOverflowing };\n};\n\nconst BitkitCollapsible = forwardRef<HTMLDivElement, BitkitCollapsibleProps>((props, ref) => {\n const {\n children,\n closedLabel = 'Show less',\n collapsedHeight = '48px',\n defaultOpen,\n label,\n labelProps,\n onOpenChange,\n open,\n openLabel = 'Show more',\n ...rest\n } = props;\n\n const recipe = useSlotRecipe({ key: 'collapsible' });\n const styles = recipe();\n\n const { contentRef, isOverflowing } = useIsContentOverflowing(collapsedHeight);\n\n const handleOpenChange = onOpenChange ? (details: { open: boolean }) => onOpenChange(details.open) : undefined;\n\n return (\n <Collapsible.Root\n ref={ref}\n collapsedHeight={collapsedHeight}\n css={styles.root}\n defaultOpen={defaultOpen}\n onOpenChange={handleOpenChange}\n open={open}\n {...rest}\n >\n {label && <BitkitLabel {...labelProps}>{label}</BitkitLabel>}\n <Collapsible.Content css={styles.content}>\n <Box ref={contentRef}>{children}</Box>\n </Collapsible.Content>\n {isOverflowing && (\n <Collapsible.Trigger css={styles.trigger}>\n <Collapsible.Context>\n {(api) => (\n <>\n {api.open ? closedLabel : openLabel}\n {api.open ? <IconChevronUp size=\"16\" /> : <IconChevronDown size=\"16\" />}\n </>\n )}\n </Collapsible.Context>\n </Collapsible.Trigger>\n )}\n </Collapsible.Root>\n );\n});\n\nBitkitCollapsible.displayName = 'BitkitCollapsible';\n\nexport default BitkitCollapsible;\n"],"mappings":";;;;;;;;;;AA4CA,IAAM,2BAA2B,oBAA4B;CAC3D,MAAM,aAAa,OAAuB,IAAI;CAC9C,MAAM,CAAC,eAAe,oBAAoB,SAAS,IAAI;CAEvD,0BAA0B;EACxB,MAAM,YAAY,WAAW;EAC7B,MAAM,eAAe,WAAW;EAChC,IAAI,CAAC,aAAa,CAAC,cACjB;EAMF,MAAM,QAAQ,SAAS,cAAc,KAAK;EAC1C,MAAM,MAAM,UAAU,yEAAyE,gBAAgB;EAC/G,aAAa,YAAY,KAAK;EAC9B,MAAM,oBAAoB,MAAM,sBAAsB,CAAC,CAAC;EACxD,aAAa,YAAY,KAAK;EAE9B,MAAM,sBAAsB,iBAAiB,UAAU,eAAe,iBAAiB;EACvF,cAAc;EAEd,IAAI,OAAO,mBAAmB,aAC5B;EAGF,MAAM,iBAAiB,IAAI,eAAe,aAAa;EACvD,eAAe,QAAQ,SAAS;EAChC,aAAa,eAAe,WAAW;CACzC,GAAG,CAAC,eAAe,CAAC;CAEpB,OAAO;EAAE;EAAY;CAAc;AACrC;AAEA,IAAM,oBAAoB,YAAoD,OAAO,QAAQ;CAC3F,MAAM,EACJ,UACA,cAAc,aACd,kBAAkB,QAClB,aACA,OACA,YACA,cACA,MACA,YAAY,aACZ,GAAG,SACD;CAGJ,MAAM,SADS,cAAc,EAAE,KAAK,cAAc,CACnC,CAAA,CAAO;CAEtB,MAAM,EAAE,YAAY,kBAAkB,wBAAwB,eAAe;CAE7E,MAAM,mBAAmB,gBAAgB,YAA+B,aAAa,QAAQ,IAAI,IAAI,KAAA;CAErG,OACE,qBAAC,YAAY,MAAb;EACO;EACY;EACjB,KAAK,OAAO;EACC;EACb,cAAc;EACR;EACN,GAAI;EAPN,UAAA;GASG,SAAS,oBAAC,aAAD;IAAa,GAAI;IAAa,UAAA;GAAmB,CAAA;GAC3D,oBAAC,YAAY,SAAb;IAAqB,KAAK,OAAO;IAC/B,UAAA,oBAAC,KAAD;KAAK,KAAK;KAAa;IAAc,CAAA;GAClB,CAAA;GACpB,iBACC,oBAAC,YAAY,SAAb;IAAqB,KAAK,OAAO;IAC/B,UAAA,oBAAC,YAAY,SAAb,EAAA,WACI,QACA,qBAAA,YAAA,EAAA,UAAA,CACG,IAAI,OAAO,cAAc,WACzB,IAAI,OAAO,oBAAC,eAAD,EAAe,MAAK,KAAM,CAAA,IAAI,oBAAC,iBAAD,EAAiB,MAAK,KAAM,CAAA,CACtE,EAAA,CAAA,EAEe,CAAA;GACF,CAAA;EAEP;;AAEtB,CAAC;AAED,kBAAkB,cAAc"}
|
|
@@ -16,7 +16,7 @@ declare const ribbonSlotRecipe: import('@chakra-ui/react').SlotRecipeDefinition<
|
|
|
16
16
|
};
|
|
17
17
|
yellow: {
|
|
18
18
|
root: {
|
|
19
|
-
background: "color/yellow/
|
|
19
|
+
background: "color/yellow/minimal";
|
|
20
20
|
borderColor: "color/yellow/muted";
|
|
21
21
|
color: "color/yellow/strong";
|
|
22
22
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Ribbon.recipe.js","names":[],"sources":["../../../lib/theme/slot-recipes/Ribbon.recipe.ts"],"sourcesContent":["import { defineSlotRecipe } from '@chakra-ui/react/styled-system';\n\nconst ribbonSlotRecipe = defineSlotRecipe({\n className: 'ribbon',\n slots: ['root', 'content', 'textBlock'],\n base: {\n root: {\n alignItems: 'center',\n borderBlockStyle: 'solid',\n borderBlockWidth: '1',\n display: 'flex',\n paddingBlock: '12',\n paddingInline: '24',\n width: 'full',\n },\n content: {\n alignItems: 'center',\n display: 'flex',\n flex: '1 0 0',\n gap: '16',\n justifyContent: 'center',\n minHeight: '32',\n minWidth: 0,\n },\n textBlock: {\n alignItems: 'baseline',\n display: 'flex',\n gap: '4',\n minWidth: 0,\n textStyle: 'body/md/regular',\n },\n },\n variants: {\n colorVariant: {\n blue: { root: { background: 'color/blue/subtle', borderColor: 'color/blue/muted', color: 'color/blue/strong' } },\n green: {\n root: { background: 'color/green/subtle', borderColor: 'color/green/muted', color: 'color/green/strong' },\n },\n yellow: {\n root: { background: 'color/yellow/
|
|
1
|
+
{"version":3,"file":"Ribbon.recipe.js","names":[],"sources":["../../../lib/theme/slot-recipes/Ribbon.recipe.ts"],"sourcesContent":["import { defineSlotRecipe } from '@chakra-ui/react/styled-system';\n\nconst ribbonSlotRecipe = defineSlotRecipe({\n className: 'ribbon',\n slots: ['root', 'content', 'textBlock'],\n base: {\n root: {\n alignItems: 'center',\n borderBlockStyle: 'solid',\n borderBlockWidth: '1',\n display: 'flex',\n paddingBlock: '12',\n paddingInline: '24',\n width: 'full',\n },\n content: {\n alignItems: 'center',\n display: 'flex',\n flex: '1 0 0',\n gap: '16',\n justifyContent: 'center',\n minHeight: '32',\n minWidth: 0,\n },\n textBlock: {\n alignItems: 'baseline',\n display: 'flex',\n gap: '4',\n minWidth: 0,\n textStyle: 'body/md/regular',\n },\n },\n variants: {\n colorVariant: {\n blue: { root: { background: 'color/blue/subtle', borderColor: 'color/blue/muted', color: 'color/blue/strong' } },\n green: {\n root: { background: 'color/green/subtle', borderColor: 'color/green/muted', color: 'color/green/strong' },\n },\n yellow: {\n root: { background: 'color/yellow/minimal', borderColor: 'color/yellow/muted', color: 'color/yellow/strong' },\n },\n red: { root: { background: 'color/red/subtle', borderColor: 'color/red/muted', color: 'color/red/strong' } },\n purple: {\n root: { background: 'color/purple/subtle', borderColor: 'color/purple/muted', color: 'color/purple/strong' },\n },\n },\n },\n defaultVariants: {\n colorVariant: 'blue',\n },\n});\n\nexport default ribbonSlotRecipe;\n"],"mappings":";;AAEA,IAAM,mBAAmB,iBAAiB;CACxC,WAAW;CACX,OAAO;EAAC;EAAQ;EAAW;CAAW;CACtC,MAAM;EACJ,MAAM;GACJ,YAAY;GACZ,kBAAkB;GAClB,kBAAkB;GAClB,SAAS;GACT,cAAc;GACd,eAAe;GACf,OAAO;EACT;EACA,SAAS;GACP,YAAY;GACZ,SAAS;GACT,MAAM;GACN,KAAK;GACL,gBAAgB;GAChB,WAAW;GACX,UAAU;EACZ;EACA,WAAW;GACT,YAAY;GACZ,SAAS;GACT,KAAK;GACL,UAAU;GACV,WAAW;EACb;CACF;CACA,UAAU,EACR,cAAc;EACZ,MAAM,EAAE,MAAM;GAAE,YAAY;GAAqB,aAAa;GAAoB,OAAO;EAAoB,EAAE;EAC/G,OAAO,EACL,MAAM;GAAE,YAAY;GAAsB,aAAa;GAAqB,OAAO;EAAqB,EAC1G;EACA,QAAQ,EACN,MAAM;GAAE,YAAY;GAAwB,aAAa;GAAsB,OAAO;EAAsB,EAC9G;EACA,KAAK,EAAE,MAAM;GAAE,YAAY;GAAoB,aAAa;GAAmB,OAAO;EAAmB,EAAE;EAC3G,QAAQ,EACN,MAAM;GAAE,YAAY;GAAuB,aAAa;GAAsB,OAAO;EAAsB,EAC7G;CACF,EACF;CACA,iBAAiB,EACf,cAAc,OAChB;AACF,CAAC"}
|