@tosui/react 0.1.4 → 0.1.5
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/Alert/Alert.d.ts.map +1 -1
- package/dist/components/Alert/Alert.js.map +1 -1
- package/dist/components/Badge/Badge.d.ts.map +1 -1
- package/dist/components/Badge/Badge.js.map +1 -1
- package/dist/components/Box/Box.d.ts +2 -7
- package/dist/components/Box/Box.d.ts.map +1 -1
- package/dist/components/Box/Box.js +1 -1
- package/dist/components/Box/Box.js.map +1 -1
- package/dist/components/Box/borders/borders.d.ts +11 -13
- package/dist/components/Box/borders/borders.d.ts.map +1 -1
- package/dist/components/Box/borders/borders.js +29 -62
- package/dist/components/Box/borders/borders.js.map +1 -1
- package/dist/components/Box/borders/borders.module.css +936 -40
- package/dist/components/Box/borders/borders.module.css.js +600 -40
- package/dist/components/Box/borders/borders.module.css.js.map +1 -1
- package/dist/components/Box/colors/colors.d.ts +6 -8
- package/dist/components/Box/colors/colors.d.ts.map +1 -1
- package/dist/components/Box/colors/colors.js +20 -30
- package/dist/components/Box/colors/colors.js.map +1 -1
- package/dist/components/Box/colors/colors.module.css +2537 -108
- package/dist/components/Box/colors/colors.module.css.js +1620 -108
- package/dist/components/Box/colors/colors.module.css.js.map +1 -1
- package/dist/components/Box/display/display.d.ts +2 -8
- package/dist/components/Box/display/display.d.ts.map +1 -1
- package/dist/components/Box/display/display.js +10 -33
- package/dist/components/Box/display/display.js.map +1 -1
- package/dist/components/Box/flexbox/flexbox.d.ts +12 -14
- package/dist/components/Box/flexbox/flexbox.d.ts.map +1 -1
- package/dist/components/Box/flexbox/flexbox.js +39 -102
- package/dist/components/Box/flexbox/flexbox.js.map +1 -1
- package/dist/components/Box/flexbox/flexbox.module.css +1210 -56
- package/dist/components/Box/flexbox/flexbox.module.css.js +727 -55
- package/dist/components/Box/flexbox/flexbox.module.css.js.map +1 -1
- package/dist/components/Box/grid/grid.d.ts.map +1 -1
- package/dist/components/Box/grid/grid.js +22 -33
- package/dist/components/Box/grid/grid.js.map +1 -1
- package/dist/components/Box/grid/grid.module.css +36 -36
- package/dist/components/Box/grid/grid.module.css.js +14 -34
- package/dist/components/Box/grid/grid.module.css.js.map +1 -1
- package/dist/components/Box/inset/inset.d.ts.map +1 -1
- package/dist/components/Box/inset/inset.js +8 -52
- package/dist/components/Box/inset/inset.js.map +1 -1
- package/dist/components/Box/inset/inset.module.css +120 -120
- package/dist/components/Box/inset/inset.module.css.js +21 -161
- package/dist/components/Box/inset/inset.module.css.js.map +1 -1
- package/dist/components/Box/interactions/interactions.d.ts +6 -8
- package/dist/components/Box/interactions/interactions.d.ts.map +1 -1
- package/dist/components/Box/interactions/interactions.js +20 -30
- package/dist/components/Box/interactions/interactions.js.map +1 -1
- package/dist/components/Box/interactions/interactions.module.css +891 -38
- package/dist/components/Box/interactions/interactions.module.css.js +570 -38
- package/dist/components/Box/interactions/interactions.module.css.js.map +1 -1
- package/dist/components/Box/margin/margin.d.ts.map +1 -1
- package/dist/components/Box/margin/margin.js +8 -52
- package/dist/components/Box/margin/margin.js.map +1 -1
- package/dist/components/Box/margin/margin.module.css +120 -120
- package/dist/components/Box/margin/margin.module.css.js +21 -161
- package/dist/components/Box/margin/margin.module.css.js.map +1 -1
- package/dist/components/Box/opacity/opacity.d.ts +2 -8
- package/dist/components/Box/opacity/opacity.d.ts.map +1 -1
- package/dist/components/Box/opacity/opacity.js +10 -33
- package/dist/components/Box/opacity/opacity.js.map +1 -1
- package/dist/components/Box/overflow/overflow.d.ts +2 -8
- package/dist/components/Box/overflow/overflow.d.ts.map +1 -1
- package/dist/components/Box/overflow/overflow.js +24 -29
- package/dist/components/Box/overflow/overflow.js.map +1 -1
- package/dist/components/Box/padding/padding.d.ts.map +1 -1
- package/dist/components/Box/padding/padding.js +8 -52
- package/dist/components/Box/padding/padding.js.map +1 -1
- package/dist/components/Box/padding/padding.module.css +120 -120
- package/dist/components/Box/padding/padding.module.css.js +21 -161
- package/dist/components/Box/padding/padding.module.css.js.map +1 -1
- package/dist/components/Box/position/position.d.ts +2 -8
- package/dist/components/Box/position/position.d.ts.map +1 -1
- package/dist/components/Box/position/position.js +10 -33
- package/dist/components/Box/position/position.js.map +1 -1
- package/dist/components/Box/roundness/roundness.d.ts +12 -14
- package/dist/components/Box/roundness/roundness.d.ts.map +1 -1
- package/dist/components/Box/roundness/roundness.js +26 -62
- package/dist/components/Box/roundness/roundness.js.map +1 -1
- package/dist/components/Box/roundness/roundness.module.css +937 -40
- package/dist/components/Box/roundness/roundness.module.css.js +600 -40
- package/dist/components/Box/roundness/roundness.module.css.js.map +1 -1
- package/dist/components/Box/shadows/shadows.d.ts +2 -8
- package/dist/components/Box/shadows/shadows.d.ts.map +1 -1
- package/dist/components/Box/shadows/shadows.js +10 -33
- package/dist/components/Box/shadows/shadows.js.map +1 -1
- package/dist/components/Box/shared/index.d.ts +1 -0
- package/dist/components/Box/shared/index.d.ts.map +1 -1
- package/dist/components/Box/shared/responsive.d.ts +36 -0
- package/dist/components/Box/shared/responsive.d.ts.map +1 -0
- package/dist/components/Box/shared/responsive.js +65 -0
- package/dist/components/Box/shared/responsive.js.map +1 -0
- package/dist/components/Box/shared/types.d.ts +6 -0
- package/dist/components/Box/shared/types.d.ts.map +1 -1
- package/dist/components/Box/sizing/sizing.d.ts.map +1 -1
- package/dist/components/Box/sizing/sizing.js +5 -37
- package/dist/components/Box/sizing/sizing.js.map +1 -1
- package/dist/components/Box/sizing/sizing.module.css +175 -183
- package/dist/components/Box/sizing/sizing.module.css.js +31 -241
- package/dist/components/Box/sizing/sizing.module.css.js.map +1 -1
- package/dist/components/Box/text/text.d.ts +6 -8
- package/dist/components/Box/text/text.d.ts.map +1 -1
- package/dist/components/Box/text/text.js +24 -30
- package/dist/components/Box/text/text.js.map +1 -1
- package/dist/components/Box/text/text.module.css +562 -24
- package/dist/components/Box/text/text.module.css.js +360 -24
- package/dist/components/Box/text/text.module.css.js.map +1 -1
- package/dist/components/Box/typography/typography.d.ts +7 -9
- package/dist/components/Box/typography/typography.d.ts.map +1 -1
- package/dist/components/Box/typography/typography.js +33 -19
- package/dist/components/Box/typography/typography.js.map +1 -1
- package/dist/components/Box/typography/typography.module.css +890 -19
- package/dist/components/Box/typography/typography.module.css.js +570 -19
- package/dist/components/Box/typography/typography.module.css.js.map +1 -1
- package/dist/components/Box/zIndex/zIndex.d.ts +2 -8
- package/dist/components/Box/zIndex/zIndex.d.ts.map +1 -1
- package/dist/components/Box/zIndex/zIndex.js +10 -33
- package/dist/components/Box/zIndex/zIndex.js.map +1 -1
- package/dist/components/Flex/Flex.d.ts +5 -6
- package/dist/components/Flex/Flex.d.ts.map +1 -1
- package/dist/components/Flex/Flex.js +0 -1
- package/dist/components/Flex/Flex.js.map +1 -1
- package/dist/components/Grid/Grid.d.ts +3 -3
- package/dist/components/Grid/Grid.d.ts.map +1 -1
- package/dist/components/Grid/Grid.js.map +1 -1
- package/dist/components/IconButton/IconButton.d.ts.map +1 -1
- package/dist/components/IconButton/IconButton.js.map +1 -1
- package/dist/components/Menu/Menu.d.ts.map +1 -1
- package/dist/components/Menu/Menu.js +5 -5
- package/dist/components/Menu/Menu.js.map +1 -1
- package/dist/components/Popover/Popover.d.ts.map +1 -1
- package/dist/components/Popover/Popover.js +9 -9
- package/dist/components/Popover/Popover.js.map +1 -1
- package/dist/components/Progress/Progress.d.ts.map +1 -1
- package/dist/components/Progress/Progress.js.map +1 -1
- package/dist/components/Stack/Stack.d.ts +2 -1
- package/dist/components/Stack/Stack.d.ts.map +1 -1
- package/dist/components/Stack/Stack.js.map +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/components/Tooltip/Tooltip.js +5 -5
- package/dist/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/index.css +9778 -2147
- package/dist/styles/styles.css +7 -0
- package/package.json +1 -1
|
@@ -1,40 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getEnumResponsiveStyles } from "../shared/responsive.js";
|
|
2
2
|
import styles from "./zIndex.module.css.js";
|
|
3
3
|
import clsx from "clsx";
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return stateClassSuffix ? styles[`${value}${stateClassSuffix}`] : styles[value];
|
|
8
|
-
}
|
|
9
|
-
return stateClassSuffix ? styles[`${value}_${responsiveKey}${stateClassSuffix}`] : styles[`${value}_${responsiveKey}`];
|
|
10
|
-
}
|
|
11
|
-
function getZIndexStylesForValue(value, state) {
|
|
12
|
-
const result = { className: "", style: {} };
|
|
13
|
-
if (value === void 0) return result;
|
|
14
|
-
if (typeof value === "string") {
|
|
15
|
-
const className = getZIndexClass(value, "base", state);
|
|
16
|
-
if (className) {
|
|
17
|
-
result.className = className;
|
|
18
|
-
}
|
|
19
|
-
return result;
|
|
20
|
-
}
|
|
21
|
-
for (const responsiveKey of RESPONSIVE_KEYS) {
|
|
22
|
-
const zIndexValue = value[responsiveKey];
|
|
23
|
-
if (zIndexValue === void 0) continue;
|
|
24
|
-
const className = getZIndexClass(zIndexValue, responsiveKey, state);
|
|
25
|
-
if (className) {
|
|
26
|
-
result.className = clsx(result.className, className);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return result;
|
|
4
|
+
function getZIndexStylesForState(props, state) {
|
|
5
|
+
if (!props) return { className: "", style: {} };
|
|
6
|
+
return getEnumResponsiveStyles(styles, "", props.zIndex, state);
|
|
30
7
|
}
|
|
31
8
|
function getZIndexStyles(props) {
|
|
32
|
-
const {
|
|
33
|
-
const baseStyles =
|
|
34
|
-
const hoverStyles =
|
|
35
|
-
const focusStyles =
|
|
36
|
-
const activeStyles =
|
|
37
|
-
const disabledStyles =
|
|
9
|
+
const { _hover, _focus, _active, _disabled, ...baseProps } = props;
|
|
10
|
+
const baseStyles = getZIndexStylesForState(baseProps, "base");
|
|
11
|
+
const hoverStyles = getZIndexStylesForState(_hover, "hover");
|
|
12
|
+
const focusStyles = getZIndexStylesForState(_focus, "focus");
|
|
13
|
+
const activeStyles = getZIndexStylesForState(_active, "active");
|
|
14
|
+
const disabledStyles = getZIndexStylesForState(_disabled, "disabled");
|
|
38
15
|
return {
|
|
39
16
|
className: clsx(
|
|
40
17
|
baseStyles.className,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zIndex.js","sources":["../../../../src/components/Box/zIndex/zIndex.ts"],"sourcesContent":["import type { ResponsiveValue } from \"@/utils/breakpoints\";\nimport {\n
|
|
1
|
+
{"version":3,"file":"zIndex.js","sources":["../../../../src/components/Box/zIndex/zIndex.ts"],"sourcesContent":["import type { ResponsiveValue } from \"@/utils/breakpoints\";\nimport {\n type StateKey,\n type StateProps,\n type StyleResult,\n getEnumResponsiveStyles,\n} from \"../shared\";\nimport styles from \"./zIndex.module.css\";\nimport clsx from \"clsx\";\n\nexport type ZIndexValue = \"base\" | \"behind\" | \"dropdown\" | \"sticky\" | \"modal\" | \"toast\" | \"tooltip\";\n\nexport type ZIndexProps = {\n zIndex?: ResponsiveValue<ZIndexValue>;\n};\n\nfunction getZIndexStylesForState(\n props: ZIndexProps | undefined,\n state: StateKey\n): StyleResult {\n if (!props) return { className: \"\", style: {} };\n\n return getEnumResponsiveStyles(styles, \"\", props.zIndex, state);\n}\n\nexport function getZIndexStyles(\n props: ZIndexProps & StateProps<ZIndexProps>\n): StyleResult {\n const { _hover, _focus, _active, _disabled, ...baseProps } = props;\n\n const baseStyles = getZIndexStylesForState(baseProps, \"base\");\n const hoverStyles = getZIndexStylesForState(_hover, \"hover\");\n const focusStyles = getZIndexStylesForState(_focus, \"focus\");\n const activeStyles = getZIndexStylesForState(_active, \"active\");\n const disabledStyles = getZIndexStylesForState(_disabled, \"disabled\");\n\n return {\n className: clsx(\n baseStyles.className,\n hoverStyles.className,\n focusStyles.className,\n activeStyles.className,\n disabledStyles.className\n ),\n style: {},\n };\n}\n"],"names":[],"mappings":";;;AAgBA,SAAS,wBACP,OACA,OACa;AACb,MAAI,CAAC,MAAO,QAAO,EAAE,WAAW,IAAI,OAAO,GAAC;AAE5C,SAAO,wBAAwB,QAAQ,IAAI,MAAM,QAAQ,KAAK;AAChE;AAEO,SAAS,gBACd,OACa;AACb,QAAM,EAAE,QAAQ,QAAQ,SAAS,WAAW,GAAG,cAAc;AAE7D,QAAM,aAAa,wBAAwB,WAAW,MAAM;AAC5D,QAAM,cAAc,wBAAwB,QAAQ,OAAO;AAC3D,QAAM,cAAc,wBAAwB,QAAQ,OAAO;AAC3D,QAAM,eAAe,wBAAwB,SAAS,QAAQ;AAC9D,QAAM,iBAAiB,wBAAwB,WAAW,UAAU;AAEpE,SAAO;AAAA,IACL,WAAW;AAAA,MACT,WAAW;AAAA,MACX,YAAY;AAAA,MACZ,YAAY;AAAA,MACZ,aAAa;AAAA,MACb,eAAe;AAAA,IAAA;AAAA,IAEjB,OAAO,CAAA;AAAA,EAAC;AAEZ;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ElementType } from 'react';
|
|
2
2
|
import { Polymorphic } from '../../types/Polymorphic';
|
|
3
3
|
import { BoxOwnProps } from '../Box/Box';
|
|
4
|
+
import { ResponsiveValue } from '../../utils/breakpoints';
|
|
4
5
|
import { FlexDirectionValue, JustifyContentValue, AlignItemsValue, AlignSelfValue, FlexWrapValue, SpacingValue } from '../Box/flexbox/flexbox';
|
|
5
6
|
export type FlexOwnProps = Omit<BoxOwnProps, "display" | "flexDirection" | "justifyContent" | "alignItems" | "alignSelf" | "flexWrap" | "gap" | "gapRow" | "gapColumn" | "flexBasis" | "flexGrow" | "flexShrink"> & {
|
|
6
7
|
/** Flex direction: row (default), column, row-reverse, column-reverse */
|
|
@@ -11,14 +12,12 @@ export type FlexOwnProps = Omit<BoxOwnProps, "display" | "flexDirection" | "just
|
|
|
11
12
|
justify?: JustifyContentValue;
|
|
12
13
|
/** Align items along the cross axis */
|
|
13
14
|
align?: AlignItemsValue;
|
|
14
|
-
/** Align content when there are multiple lines */
|
|
15
|
-
alignContent?: JustifyContentValue;
|
|
16
15
|
/** Gap between children (0-32 spacing multiplier or string) */
|
|
17
|
-
gap?: SpacingValue
|
|
16
|
+
gap?: ResponsiveValue<SpacingValue>;
|
|
18
17
|
/** Row gap between children (0-32 spacing multiplier or string) */
|
|
19
|
-
gapRow?: SpacingValue
|
|
18
|
+
gapRow?: ResponsiveValue<SpacingValue>;
|
|
20
19
|
/** Column gap between children (0-32 spacing multiplier or string) */
|
|
21
|
-
gapColumn?: SpacingValue
|
|
20
|
+
gapColumn?: ResponsiveValue<SpacingValue>;
|
|
22
21
|
/** Flex basis of the container */
|
|
23
22
|
basis?: string;
|
|
24
23
|
/** Flex grow of the container */
|
|
@@ -42,5 +41,5 @@ export type FlexProps<T extends ElementType = "div"> = Polymorphic<T, FlexOwnPro
|
|
|
42
41
|
* - gap, gapRow, gapColumn
|
|
43
42
|
* - basis, grow, shrink -> flexBasis, flexGrow, flexShrink
|
|
44
43
|
*/
|
|
45
|
-
export declare function Flex<T extends ElementType = "div">({ as, direction, wrap, justify, align,
|
|
44
|
+
export declare function Flex<T extends ElementType = "div">({ as, direction, wrap, justify, align, gap, gapRow, gapColumn, basis, grow, shrink, alignSelf, children, ...rest }: FlexProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
46
45
|
//# sourceMappingURL=Flex.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Flex.d.ts","sourceRoot":"","sources":["../../../src/components/Flex/Flex.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAO,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,aAAa,EACb,YAAY,EACb,MAAM,kCAAkC,CAAC;AAM1C,MAAM,MAAM,YAAY,GAAG,IAAI,CAC7B,W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C,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;IACpC,mEAAmE;IACnE,MAAM,CAAC,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;IACvC,sEAAsE;IACtE,SAAS,CAAC,EAAE,eAAe,CAAC,YAAY,CAAC,CAAC;IAC1C,kCAAkC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iCAAiC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mCAAmC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8CAA8C;IAC9C,SAAS,CAAC,EAAE,cAAc,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,WAAW,GAAG,KAAK,IAAI,WAAW,CAChE,CAAC,EACD,YAAY,CACb,CAAC;AAMF;;;;;;;;;;;;GAYG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,WAAW,GAAG,KAAK,EAAE,EAClD,EAAE,EACF,SAAS,EACT,IAAI,EACJ,OAAO,EACP,KAAK,EAEL,GAAG,EACH,MAAM,EACN,SAAS,EACT,KAAK,EACL,IAAI,EACJ,MAAM,EACN,SAAS,EACT,QAAQ,EACR,GAAG,IAAI,EACR,EAAE,SAAS,CAAC,CAAC,CAAC,2CAsBd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Flex.js","sources":["../../../src/components/Flex/Flex.tsx"],"sourcesContent":["import { type ElementType } from \"react\";\nimport { type Polymorphic } from \"@/types/Polymorphic\";\nimport { Box, type BoxOwnProps } from \"@/components/Box/Box\";\nimport type {\n FlexDirectionValue,\n JustifyContentValue,\n AlignItemsValue,\n AlignSelfValue,\n FlexWrapValue,\n SpacingValue,\n} from \"@/components/Box/flexbox/flexbox\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport type FlexOwnProps = Omit<\n BoxOwnProps,\n | \"display\"\n | \"flexDirection\"\n | \"justifyContent\"\n | \"alignItems\"\n | \"alignSelf\"\n | \"flexWrap\"\n | \"gap\"\n | \"gapRow\"\n | \"gapColumn\"\n | \"flexBasis\"\n | \"flexGrow\"\n | \"flexShrink\"\n> & {\n /** Flex direction: row (default), column, row-reverse, column-reverse */\n direction?: FlexDirectionValue;\n /** Flex wrapping: nowrap (default), wrap, wrap-reverse */\n wrap?: FlexWrapValue;\n /** Justify content along the main axis */\n justify?: JustifyContentValue;\n /** Align items along the cross axis */\n align?: AlignItemsValue;\n
|
|
1
|
+
{"version":3,"file":"Flex.js","sources":["../../../src/components/Flex/Flex.tsx"],"sourcesContent":["import { type ElementType } from \"react\";\nimport { type Polymorphic } from \"@/types/Polymorphic\";\nimport { Box, type BoxOwnProps } from \"@/components/Box/Box\";\nimport type { ResponsiveValue } from \"@/utils/breakpoints\";\nimport type {\n FlexDirectionValue,\n JustifyContentValue,\n AlignItemsValue,\n AlignSelfValue,\n FlexWrapValue,\n SpacingValue,\n} from \"@/components/Box/flexbox/flexbox\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport type FlexOwnProps = Omit<\n BoxOwnProps,\n | \"display\"\n | \"flexDirection\"\n | \"justifyContent\"\n | \"alignItems\"\n | \"alignSelf\"\n | \"flexWrap\"\n | \"gap\"\n | \"gapRow\"\n | \"gapColumn\"\n | \"flexBasis\"\n | \"flexGrow\"\n | \"flexShrink\"\n> & {\n /** Flex direction: row (default), column, row-reverse, column-reverse */\n direction?: FlexDirectionValue;\n /** Flex wrapping: nowrap (default), wrap, wrap-reverse */\n wrap?: FlexWrapValue;\n /** Justify content along the main axis */\n justify?: JustifyContentValue;\n /** Align items along the cross axis */\n align?: AlignItemsValue;\n\n /** Gap between children (0-32 spacing multiplier or string) */\n gap?: ResponsiveValue<SpacingValue>;\n /** Row gap between children (0-32 spacing multiplier or string) */\n gapRow?: ResponsiveValue<SpacingValue>;\n /** Column gap between children (0-32 spacing multiplier or string) */\n gapColumn?: ResponsiveValue<SpacingValue>;\n /** Flex basis of the container */\n basis?: string;\n /** Flex grow of the container */\n grow?: number;\n /** Flex shrink of the container */\n shrink?: number;\n /** Align self within parent flex container */\n alignSelf?: AlignSelfValue;\n};\n\nexport type FlexProps<T extends ElementType = \"div\"> = Polymorphic<\n T,\n FlexOwnProps\n>;\n\n// ============================================================================\n// Component\n// ============================================================================\n\n/**\n * Flex - Explicit flexbox layout component\n *\n * A polymorphic flex container with shorthand props:\n * - Default element: <div>\n * - Always renders with display=\"flex\"\n * - direction -> flexDirection (default: row)\n * - wrap -> flexWrap\n * - justify -> justifyContent\n * - align -> alignItems\n * - gap, gapRow, gapColumn\n * - basis, grow, shrink -> flexBasis, flexGrow, flexShrink\n */\nexport function Flex<T extends ElementType = \"div\">({\n as,\n direction,\n wrap,\n justify,\n align,\n\n gap,\n gapRow,\n gapColumn,\n basis,\n grow,\n shrink,\n alignSelf,\n children,\n ...rest\n}: FlexProps<T>) {\n return (\n // @ts-expect-error - Polymorphic component type forwarding\n <Box\n as={as || \"div\"}\n display=\"flex\"\n flexDirection={direction}\n flexWrap={wrap}\n justifyContent={justify}\n alignItems={align}\n gap={gap}\n gapRow={gapRow}\n gapColumn={gapColumn}\n flexBasis={basis}\n flexGrow={grow}\n flexShrink={shrink}\n alignSelf={alignSelf}\n {...rest}\n >\n {children}\n </Box>\n );\n}\n"],"names":[],"mappings":";;;AA+EO,SAAS,KAAoC;AAAA,EAClD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAiB;AACf;AAAA;AAAA,IAEE;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,IAAI,MAAM;AAAA,QACV,SAAQ;AAAA,QACR,eAAe;AAAA,QACf,UAAU;AAAA,QACV,gBAAgB;AAAA,QAChB,YAAY;AAAA,QACZ;AAAA,QACA;AAAA,QACA;AAAA,QACA,WAAW;AAAA,QACX,UAAU;AAAA,QACV,YAAY;AAAA,QACZ;AAAA,QACC,GAAG;AAAA,QAEH;AAAA,MAAA;AAAA,IAAA;AAAA;AAGP;"}
|
|
@@ -9,11 +9,11 @@ export type GridOwnProps = Omit<BoxOwnProps, "display" | "gridTemplateColumns" |
|
|
|
9
9
|
/** Grid template rows — CSS value or responsive object */
|
|
10
10
|
rows?: ResponsiveValue<string>;
|
|
11
11
|
/** Gap between grid items (0-32 spacing multiplier or string) */
|
|
12
|
-
gap?: SpacingValue
|
|
12
|
+
gap?: ResponsiveValue<SpacingValue>;
|
|
13
13
|
/** Row gap between grid items (0-32 spacing multiplier or string) */
|
|
14
|
-
gapRow?: SpacingValue
|
|
14
|
+
gapRow?: ResponsiveValue<SpacingValue>;
|
|
15
15
|
/** Column gap between grid items (0-32 spacing multiplier or string) */
|
|
16
|
-
gapColumn?: SpacingValue
|
|
16
|
+
gapColumn?: ResponsiveValue<SpacingValue>;
|
|
17
17
|
/** Justify items along the inline (row) axis */
|
|
18
18
|
justify?: JustifyContentValue;
|
|
19
19
|
/** Align items along the block (column) axis */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Grid.d.ts","sourceRoot":"","sources":["../../../src/components/Grid/Grid.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAO,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EACV,mBAAmB,EACnB,eAAe,EACf,YAAY,EACb,MAAM,kCAAkC,CAAC;AAM1C,MAAM,MAAM,YAAY,GAAG,IAAI,CAC7B,WAAW,EACT,SAAS,GACT,qBAAqB,GACrB,kBAAkB,GAClB,KAAK,GACL,QAAQ,GACR,WAAW,GACX,gBAAgB,GAChB,YAAY,CACf,GAAG;IACF,6DA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B,CAAC;IACrC,yCAAyC;IACzC,YAAY,CAAC,EAAE,mBAAmB,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,WAAW,GAAG,KAAK,IAAI,WAAW,CAChE,CAAC,EACD,YAAY,CACb,CAAC;AAMF;;;;;;;;;;;;GAYG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,WAAW,GAAG,KAAK,EAAE,EAClD,EAAE,EACF,OAAO,EACP,IAAI,EACJ,GAAG,EACH,MAAM,EACN,SAAS,EACT,OAAO,EACP,KAAK,EACL,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,GAAG,IAAI,EACR,EAAE,SAAS,CAAC,CAAC,CAAC,2CAkBd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Grid.js","sources":["../../../src/components/Grid/Grid.tsx"],"sourcesContent":["import { type ElementType } from \"react\";\nimport { type Polymorphic } from \"@/types/Polymorphic\";\nimport type { ResponsiveValue } from \"@/utils/breakpoints\";\nimport { Box, type BoxOwnProps } from \"@/components/Box/Box\";\nimport type {\n JustifyContentValue,\n AlignItemsValue,\n SpacingValue,\n} from \"@/components/Box/flexbox/flexbox\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport type GridOwnProps = Omit<\n BoxOwnProps,\n | \"display\"\n | \"gridTemplateColumns\"\n | \"gridTemplateRows\"\n | \"gap\"\n | \"gapRow\"\n | \"gapColumn\"\n | \"justifyContent\"\n | \"alignItems\"\n> & {\n /** Grid template columns — CSS value or responsive object */\n columns?: ResponsiveValue<string>;\n /** Grid template rows — CSS value or responsive object */\n rows?: ResponsiveValue<string>;\n /** Gap between grid items (0-32 spacing multiplier or string) */\n gap?: SpacingValue
|
|
1
|
+
{"version":3,"file":"Grid.js","sources":["../../../src/components/Grid/Grid.tsx"],"sourcesContent":["import { type ElementType } from \"react\";\nimport { type Polymorphic } from \"@/types/Polymorphic\";\nimport type { ResponsiveValue } from \"@/utils/breakpoints\";\nimport { Box, type BoxOwnProps } from \"@/components/Box/Box\";\nimport type {\n JustifyContentValue,\n AlignItemsValue,\n SpacingValue,\n} from \"@/components/Box/flexbox/flexbox\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport type GridOwnProps = Omit<\n BoxOwnProps,\n | \"display\"\n | \"gridTemplateColumns\"\n | \"gridTemplateRows\"\n | \"gap\"\n | \"gapRow\"\n | \"gapColumn\"\n | \"justifyContent\"\n | \"alignItems\"\n> & {\n /** Grid template columns — CSS value or responsive object */\n columns?: ResponsiveValue<string>;\n /** Grid template rows — CSS value or responsive object */\n rows?: ResponsiveValue<string>;\n /** Gap between grid items (0-32 spacing multiplier or string) */\n gap?: ResponsiveValue<SpacingValue>;\n /** Row gap between grid items (0-32 spacing multiplier or string) */\n gapRow?: ResponsiveValue<SpacingValue>;\n /** Column gap between grid items (0-32 spacing multiplier or string) */\n gapColumn?: ResponsiveValue<SpacingValue>;\n /** Justify items along the inline (row) axis */\n justify?: JustifyContentValue;\n /** Align items along the block (column) axis */\n align?: AlignItemsValue;\n /** Justify content (distribute rows) */\n justifyContent?: JustifyContentValue;\n /** Align content (distribute columns) */\n alignContent?: JustifyContentValue;\n};\n\nexport type GridProps<T extends ElementType = \"div\"> = Polymorphic<\n T,\n GridOwnProps\n>;\n\n// ============================================================================\n// Component\n// ============================================================================\n\n/**\n * Grid - Explicit CSS Grid layout component\n *\n * A polymorphic grid container with shorthand props:\n * - Default element: <div>\n * - Always renders with display=\"grid\"\n * - columns -> gridTemplateColumns\n * - rows -> gridTemplateRows\n * - gap, gapRow, gapColumn\n * - justify -> justifyItems (alignment within cells)\n * - align -> alignItems (alignment within cells)\n * - justifyContent, alignContent (distribution of grid tracks)\n */\nexport function Grid<T extends ElementType = \"div\">({\n as,\n columns,\n rows,\n gap,\n gapRow,\n gapColumn,\n justify,\n align,\n justifyContent,\n alignContent,\n children,\n ...rest\n}: GridProps<T>) {\n return (\n // @ts-expect-error - Polymorphic component type forwarding\n <Box\n as={as || \"div\"}\n display=\"grid\"\n gridTemplateColumns={columns}\n gridTemplateRows={rows}\n gap={gap}\n gapRow={gapRow}\n gapColumn={gapColumn}\n justifyContent={justify ?? justifyContent}\n alignItems={align ?? alignContent}\n {...rest}\n >\n {children}\n </Box>\n );\n}\n"],"names":[],"mappings":";;;AAmEO,SAAS,KAAoC;AAAA,EAClD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAiB;AACf;AAAA;AAAA,IAEE;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,IAAI,MAAM;AAAA,QACV,SAAQ;AAAA,QACR,qBAAqB;AAAA,QACrB,kBAAkB;AAAA,QAClB;AAAA,QACA;AAAA,QACA;AAAA,QACA,gBAAgB,WAAW;AAAA,QAC3B,YAAY,SAAS;AAAA,QACpB,GAAG;AAAA,QAEH;AAAA,MAAA;AAAA,IAAA;AAAA;AAGP;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconButton.d.ts","sourceRoot":"","sources":["../../../src/components/IconButton/IconButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAkC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"IconButton.d.ts","sourceRoot":"","sources":["../../../src/components/IconButton/IconButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAkC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAWvE,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,SAAS,GAAG,OAAO,CAAC;AAC9D,MAAM,MAAM,cAAc,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAChD,MAAM,MAAM,qBAAqB,GAC7B,SAAS,GACT,QAAQ,GACR,SAAS,GACT,SAAS,GACT,OAAO,GACP,MAAM,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG;IAC5B,0BAA0B;IAC1B,IAAI,EAAE,SAAS,CAAC;IAChB,qDAAqD;IACrD,YAAY,EAAE,MAAM,CAAC;IACrB,qBAAqB;IACrB,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B,yBAAyB;IACzB,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,mBAAmB;IACnB,WAAW,CAAC,EAAE,qBAAqB,CAAC;IACpC,qCAAqC;IACrC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,sCAAsC;IACtC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,4BAA4B;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oBAAoB;IACpB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC;AAkEF;;;;;;;;;GASG;AACH,eAAO,MAAM,UAAU,+GAgEtB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconButton.js","sources":["../../../src/components/IconButton/IconButton.tsx"],"sourcesContent":["import { forwardRef, type CSSProperties, type ReactNode } from \"react\";\nimport clsx from \"clsx\";\nimport { Box } from \"@/components/Box/Box\";\nimport { Spinner } from \"@/components/Spinner/Spinner\";\nimport styles from \"./iconbutton.module.css\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport type IconButtonVariant = \"solid\" | \"outline\" | \"ghost\";\nexport type IconButtonSize = \"sm\" | \"md\" | \"lg\";\nexport type IconButtonColorScheme =\n | \"primary\"\n | \"accent\"\n | \"success\"\n | \"warning\"\n | \"error\"\n | \"info\";\n\nexport type IconButtonProps = {\n /** The icon to display */\n icon: ReactNode;\n /** Accessible label (required for screen readers) */\n \"aria-label\": string;\n /** Visual variant */\n variant?: IconButtonVariant;\n /** Size of the button */\n size?: IconButtonSize;\n /** Color scheme */\n colorScheme?: IconButtonColorScheme;\n /** Whether the button is disabled */\n disabled?: boolean;\n /** Whether to show loading spinner */\n loading?: boolean;\n /** Additional class name */\n className?: string;\n /** Click handler */\n onClick?: () => void;\n};\n\n// ============================================================================\n// Size configurations\n// ============================================================================\n\nconst sizeConfig = {\n sm: { dimension: \"28px\", iconSize: \"14px\", fontSize: \"sm\" },\n md: { dimension: \"36px\", iconSize: \"18px\", fontSize: \"md\" },\n lg: { dimension: \"44px\", iconSize: \"22px\", fontSize: \"lg\" },\n} as const;\n\n// ============================================================================\n// Color configurations\n// ============================================================================\n\ntype ColorConfig = {\n bg: string;\n color: string;\n borderColor: string | undefined;\n hoverBg: string;\n};\n\nfunction getColorConfig(\n variant: IconButtonVariant,\n colorScheme: IconButtonColorScheme\n): ColorConfig {\n switch (variant) {\n case \"solid\":\n return {\n bg: `${colorScheme}-default`,\n color: \"foreground-inverted\",\n borderColor: undefined,\n hoverBg: `var(--t-color-${colorScheme}-emphasis)`,\n };\n case \"outline\":\n return {\n bg: \"transparent\",\n color: colorScheme,\n borderColor: colorScheme,\n hoverBg: `var(--t-color-${colorScheme}-subtle)`,\n };\n case \"ghost\":\n return {\n bg: \"transparent\",\n color: colorScheme,\n borderColor: undefined,\n hoverBg: `var(--t-color-${colorScheme}-subtle)`,\n };\n }\n}\n\n// ============================================================================\n// Variant border configurations\n// ============================================================================\n\nconst variantBorderConfig = {\n solid: \"none\",\n outline: \"thin\",\n ghost: \"none\",\n} as const;\n\n// ============================================================================\n// Component\n// ============================================================================\n\n/**\n * IconButton - Icon-only button component\n *\n * A compact button for icons that provides:\n * - Square sizing for icon-only use\n * - All Button variants (solid, outline, ghost)\n * - All color schemes\n * - Loading state with spinner\n * - Required aria-label for accessibility\n */\nexport const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(\n function IconButton(\n {\n icon,\n \"aria-label\": ariaLabel,\n variant = \"solid\",\n size = \"md\",\n colorScheme = \"primary\",\n disabled = false,\n loading = false,\n className,\n onClick,\n ...rest\n },\n ref\n ) {\n const isDisabled = disabled || loading;\n const colorConfig = getColorConfig(variant, colorScheme);\n const sizeProps = sizeConfig[size];\n\n return (\n <Box\n as=\"button\"\n ref={ref}\n // Layout\n display=\"inline-flex\"\n alignItems=\"center\"\n justifyContent=\"center\"\n // Size (square)\n w={sizeProps.dimension}\n h={sizeProps.dimension}\n fontSize={sizeProps.fontSize}\n rounded=\"md\"\n // Colors (type assertions for computed values)\n bg={colorConfig.bg as
|
|
1
|
+
{"version":3,"file":"IconButton.js","sources":["../../../src/components/IconButton/IconButton.tsx"],"sourcesContent":["import { forwardRef, type CSSProperties, type ReactNode } from \"react\";\nimport type { BackgroundColorValue, BorderColorValue, ColorValue } from \"@/components/Box/colors/colors\";\nimport clsx from \"clsx\";\nimport { Box } from \"@/components/Box/Box\";\nimport { Spinner } from \"@/components/Spinner/Spinner\";\nimport styles from \"./iconbutton.module.css\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport type IconButtonVariant = \"solid\" | \"outline\" | \"ghost\";\nexport type IconButtonSize = \"sm\" | \"md\" | \"lg\";\nexport type IconButtonColorScheme =\n | \"primary\"\n | \"accent\"\n | \"success\"\n | \"warning\"\n | \"error\"\n | \"info\";\n\nexport type IconButtonProps = {\n /** The icon to display */\n icon: ReactNode;\n /** Accessible label (required for screen readers) */\n \"aria-label\": string;\n /** Visual variant */\n variant?: IconButtonVariant;\n /** Size of the button */\n size?: IconButtonSize;\n /** Color scheme */\n colorScheme?: IconButtonColorScheme;\n /** Whether the button is disabled */\n disabled?: boolean;\n /** Whether to show loading spinner */\n loading?: boolean;\n /** Additional class name */\n className?: string;\n /** Click handler */\n onClick?: () => void;\n};\n\n// ============================================================================\n// Size configurations\n// ============================================================================\n\nconst sizeConfig = {\n sm: { dimension: \"28px\", iconSize: \"14px\", fontSize: \"sm\" },\n md: { dimension: \"36px\", iconSize: \"18px\", fontSize: \"md\" },\n lg: { dimension: \"44px\", iconSize: \"22px\", fontSize: \"lg\" },\n} as const;\n\n// ============================================================================\n// Color configurations\n// ============================================================================\n\ntype ColorConfig = {\n bg: string;\n color: string;\n borderColor: string | undefined;\n hoverBg: string;\n};\n\nfunction getColorConfig(\n variant: IconButtonVariant,\n colorScheme: IconButtonColorScheme\n): ColorConfig {\n switch (variant) {\n case \"solid\":\n return {\n bg: `${colorScheme}-default`,\n color: \"foreground-inverted\",\n borderColor: undefined,\n hoverBg: `var(--t-color-${colorScheme}-emphasis)`,\n };\n case \"outline\":\n return {\n bg: \"transparent\",\n color: colorScheme,\n borderColor: colorScheme,\n hoverBg: `var(--t-color-${colorScheme}-subtle)`,\n };\n case \"ghost\":\n return {\n bg: \"transparent\",\n color: colorScheme,\n borderColor: undefined,\n hoverBg: `var(--t-color-${colorScheme}-subtle)`,\n };\n }\n}\n\n// ============================================================================\n// Variant border configurations\n// ============================================================================\n\nconst variantBorderConfig = {\n solid: \"none\",\n outline: \"thin\",\n ghost: \"none\",\n} as const;\n\n// ============================================================================\n// Component\n// ============================================================================\n\n/**\n * IconButton - Icon-only button component\n *\n * A compact button for icons that provides:\n * - Square sizing for icon-only use\n * - All Button variants (solid, outline, ghost)\n * - All color schemes\n * - Loading state with spinner\n * - Required aria-label for accessibility\n */\nexport const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(\n function IconButton(\n {\n icon,\n \"aria-label\": ariaLabel,\n variant = \"solid\",\n size = \"md\",\n colorScheme = \"primary\",\n disabled = false,\n loading = false,\n className,\n onClick,\n ...rest\n },\n ref\n ) {\n const isDisabled = disabled || loading;\n const colorConfig = getColorConfig(variant, colorScheme);\n const sizeProps = sizeConfig[size];\n\n return (\n <Box\n as=\"button\"\n ref={ref}\n // Layout\n display=\"inline-flex\"\n alignItems=\"center\"\n justifyContent=\"center\"\n // Size (square)\n w={sizeProps.dimension}\n h={sizeProps.dimension}\n fontSize={sizeProps.fontSize}\n rounded=\"md\"\n // Colors (type assertions for computed values)\n bg={colorConfig.bg as BackgroundColorValue}\n color={colorConfig.color as ColorValue}\n border={variantBorderConfig[variant]}\n borderColor={colorConfig.borderColor as BorderColorValue | undefined}\n // Interaction states\n cursor={isDisabled ? \"not-allowed\" : \"pointer\"}\n pointerEvents={isDisabled ? \"none\" : undefined}\n opacity={isDisabled ? \"faint\" : undefined}\n // CSS module styles\n className={clsx(styles.iconButton, styles[variant], className)}\n // Hover color via CSS variable\n style={{ \"--iconbutton-hover-bg\": colorConfig.hoverBg } as CSSProperties}\n // Accessibility\n aria-label={ariaLabel}\n disabled={isDisabled}\n aria-disabled={isDisabled}\n aria-busy={loading}\n onClick={onClick}\n {...rest}\n >\n {loading ? (\n <Spinner size=\"sm\" aria-hidden=\"true\" />\n ) : (\n <Box as=\"span\" display=\"inline-flex\" alignItems=\"center\" aria-hidden=\"true\">\n {icon}\n </Box>\n )}\n </Box>\n );\n }\n);\n"],"names":["IconButton"],"mappings":";;;;;;AA8CA,MAAM,aAAa;AAAA,EACjB,IAAI,EAAE,WAAW,QAAQ,UAAU,QAAQ,UAAU,KAAA;AAAA,EACrD,IAAI,EAAE,WAAW,QAAQ,UAAU,QAAQ,UAAU,KAAA;AAAA,EACrD,IAAI,EAAE,WAAW,QAAQ,UAAU,QAAQ,UAAU,KAAA;AACvD;AAaA,SAAS,eACP,SACA,aACa;AACb,UAAQ,SAAA;AAAA,IACN,KAAK;AACH,aAAO;AAAA,QACL,IAAI,GAAG,WAAW;AAAA,QAClB,OAAO;AAAA,QACP,aAAa;AAAA,QACb,SAAS,iBAAiB,WAAW;AAAA,MAAA;AAAA,IAEzC,KAAK;AACH,aAAO;AAAA,QACL,IAAI;AAAA,QACJ,OAAO;AAAA,QACP,aAAa;AAAA,QACb,SAAS,iBAAiB,WAAW;AAAA,MAAA;AAAA,IAEzC,KAAK;AACH,aAAO;AAAA,QACL,IAAI;AAAA,QACJ,OAAO;AAAA,QACP,aAAa;AAAA,QACb,SAAS,iBAAiB,WAAW;AAAA,MAAA;AAAA,EACvC;AAEN;AAMA,MAAM,sBAAsB;AAAA,EAC1B,OAAO;AAAA,EACP,SAAS;AAAA,EACT,OAAO;AACT;AAgBO,MAAM,aAAa;AAAA,EACxB,SAASA,YACP;AAAA,IACE;AAAA,IACA,cAAc;AAAA,IACd,UAAU;AAAA,IACV,OAAO;AAAA,IACP,cAAc;AAAA,IACd,WAAW;AAAA,IACX,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,GAEL,KACA;AACA,UAAM,aAAa,YAAY;AAC/B,UAAM,cAAc,eAAe,SAAS,WAAW;AACvD,UAAM,YAAY,WAAW,IAAI;AAEjC,WACE;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,IAAG;AAAA,QACH;AAAA,QAEA,SAAQ;AAAA,QACR,YAAW;AAAA,QACX,gBAAe;AAAA,QAEf,GAAG,UAAU;AAAA,QACb,GAAG,UAAU;AAAA,QACb,UAAU,UAAU;AAAA,QACpB,SAAQ;AAAA,QAER,IAAI,YAAY;AAAA,QAChB,OAAO,YAAY;AAAA,QACnB,QAAQ,oBAAoB,OAAO;AAAA,QACnC,aAAa,YAAY;AAAA,QAEzB,QAAQ,aAAa,gBAAgB;AAAA,QACrC,eAAe,aAAa,SAAS;AAAA,QACrC,SAAS,aAAa,UAAU;AAAA,QAEhC,WAAW,KAAK,OAAO,YAAY,OAAO,OAAO,GAAG,SAAS;AAAA,QAE7D,OAAO,EAAE,yBAAyB,YAAY,QAAA;AAAA,QAE9C,cAAY;AAAA,QACZ,UAAU;AAAA,QACV,iBAAe;AAAA,QACf,aAAW;AAAA,QACX;AAAA,QACC,GAAG;AAAA,QAEH,oBACC,oBAAC,SAAA,EAAQ,MAAK,MAAK,eAAY,QAAO,IAEtC,oBAAC,KAAA,EAAI,IAAG,QAAO,SAAQ,eAAc,YAAW,UAAS,eAAY,QAClE,UAAA,KAAA,CACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Menu.d.ts","sourceRoot":"","sources":["../../../src/components/Menu/Menu.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"Menu.d.ts","sourceRoot":"","sources":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AAG,IAAI,EAAE,EAAE,eAAe,2CAe3E;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,aAAa,kDAyB9D;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,EACvB,OAAO,EACP,QAAgB,EAChB,SAAS,EACT,QAAQ,GACT,EAAE,aAAa,2CAgCf"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import { createContext, useState, useRef, useEffect, useContext } from "react";
|
|
3
|
+
import { createContext, useState, useRef, useCallback, useEffect, useContext } from "react";
|
|
4
4
|
import clsx from "clsx";
|
|
5
5
|
import { Box } from "../Box/Box.js";
|
|
6
6
|
import { Button } from "../Button/Button.js";
|
|
@@ -22,7 +22,7 @@ function Menu({
|
|
|
22
22
|
const isControlled = controlledIsOpen !== void 0;
|
|
23
23
|
const isOpen = isControlled ? controlledIsOpen : internalIsOpen;
|
|
24
24
|
const buttonRef = useRef(null);
|
|
25
|
-
const setOpen = (open) => {
|
|
25
|
+
const setOpen = useCallback((open) => {
|
|
26
26
|
if (!isControlled) {
|
|
27
27
|
setInternalIsOpen(open);
|
|
28
28
|
}
|
|
@@ -31,7 +31,7 @@ function Menu({
|
|
|
31
31
|
} else {
|
|
32
32
|
onClose?.();
|
|
33
33
|
}
|
|
34
|
-
};
|
|
34
|
+
}, [isControlled, onOpen, onClose]);
|
|
35
35
|
useEffect(() => {
|
|
36
36
|
if (!isOpen) return;
|
|
37
37
|
const handleClick = (e) => {
|
|
@@ -40,7 +40,7 @@ function Menu({
|
|
|
40
40
|
};
|
|
41
41
|
document.addEventListener("click", handleClick);
|
|
42
42
|
return () => document.removeEventListener("click", handleClick);
|
|
43
|
-
}, [isOpen]);
|
|
43
|
+
}, [isOpen, setOpen]);
|
|
44
44
|
useEffect(() => {
|
|
45
45
|
if (!isOpen) return;
|
|
46
46
|
const handleKeyDown = (e) => {
|
|
@@ -48,7 +48,7 @@ function Menu({
|
|
|
48
48
|
};
|
|
49
49
|
document.addEventListener("keydown", handleKeyDown);
|
|
50
50
|
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
51
|
-
}, [isOpen]);
|
|
51
|
+
}, [isOpen, setOpen]);
|
|
52
52
|
return /* @__PURE__ */ jsx(MenuContext.Provider, { value: { isOpen, setIsOpen: setOpen, buttonRef }, children: /* @__PURE__ */ jsx(
|
|
53
53
|
Box,
|
|
54
54
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Menu.js","sources":["../../../src/components/Menu/Menu.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ReactNode,\n createContext,\n useContext,\n useState,\n useRef,\n useEffect,\n} from \"react\";\nimport clsx from \"clsx\";\nimport { Box } from \"@/components/Box/Box\";\nimport { Button, type ButtonProps } from \"@/components/Button\";\nimport styles from \"./menu.module.css\";\n\n// ============================================================================\n// Context\n// ============================================================================\n\ntype MenuContextValue = {\n isOpen: boolean;\n setIsOpen: (open: boolean) => void;\n buttonRef: React.RefObject<HTMLButtonElement | null>;\n};\n\nconst MenuContext = createContext<MenuContextValue | null>(null);\n\nfunction useMenuContext() {\n const context = useContext(MenuContext);\n if (!context) throw new Error(\"Menu components must be used within Menu\");\n return context;\n}\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport type MenuProps = {\n /** Controlled open state */\n isOpen?: boolean;\n /** Callback when menu opens */\n onOpen?: () => void;\n /** Callback when menu closes */\n onClose?: () => void;\n /** Additional class name */\n className?: string;\n /** Menu components */\n children?: ReactNode;\n};\n\nexport type MenuButtonProps = Omit<ButtonProps<\"button\">, \"as\"> & {\n /** Button content */\n children?: ReactNode;\n};\n\nexport type MenuListProps = {\n /** Additional class name */\n className?: string;\n /** Menu items */\n children?: ReactNode;\n};\n\nexport type MenuItemProps = {\n /** Click handler */\n onClick?: () => void;\n /** Disabled state */\n disabled?: boolean;\n /** Additional class name */\n className?: string;\n /** Item content */\n children?: ReactNode;\n};\n\n// ============================================================================\n// Components\n// ============================================================================\n\n/**\n * Menu - Dropdown menu container\n *\n * Provides context for MenuButton, MenuList, and MenuItem.\n * Handles open/close state and click-outside behavior.\n * Supports controlled mode via isOpen/onOpen/onClose.\n */\nexport function Menu({\n isOpen: controlledIsOpen,\n onOpen,\n onClose,\n className,\n children,\n}: MenuProps) {\n const [internalIsOpen, setInternalIsOpen] = useState(false);\n const isControlled = controlledIsOpen !== undefined;\n const isOpen = isControlled ? controlledIsOpen : internalIsOpen;\n\n const buttonRef = useRef<HTMLButtonElement | null>(null);\n\n const setOpen = (open: boolean) => {\n if (!isControlled) {\n setInternalIsOpen(open);\n }\n if (open) {\n onOpen?.();\n } else {\n onClose?.();\n }\n };\n\n // Close on outside click\n useEffect(() => {\n if (!isOpen) return;\n\n const handleClick = (e: MouseEvent) => {\n if (buttonRef.current?.contains(e.target as Node)) return;\n setOpen(false);\n };\n\n document.addEventListener(\"click\", handleClick);\n return () => document.removeEventListener(\"click\", handleClick);\n }, [isOpen]);\n\n // Close on Escape\n useEffect(() => {\n if (!isOpen) return;\n\n const handleKeyDown = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") setOpen(false);\n };\n\n document.addEventListener(\"keydown\", handleKeyDown);\n return () => document.removeEventListener(\"keydown\", handleKeyDown);\n }, [isOpen]);\n\n return (\n <MenuContext.Provider value={{ isOpen, setIsOpen: setOpen, buttonRef }}>\n <Box\n position=\"relative\"\n display=\"inline-block\"\n className={clsx(styles.menu, className)}\n >\n {children}\n </Box>\n </MenuContext.Provider>\n );\n}\n\n/**\n * MenuButton - Trigger button for the menu\n *\n * Renders as a Button component with dropdown indicators.\n */\nexport function MenuButton({ children, className, ...rest }: MenuButtonProps) {\n const { isOpen, setIsOpen, buttonRef } = useMenuContext();\n\n return (\n <Button\n ref={buttonRef}\n aria-haspopup=\"menu\"\n aria-expanded={isOpen}\n onClick={() => setIsOpen(!isOpen)}\n className={className}\n {...rest}\n >\n {children}\n </Button>\n );\n}\n\n/**\n * MenuList - Dropdown container for menu items\n *\n * Only renders when menu is open.\n */\nexport function MenuList({ className, children }: MenuListProps) {\n const { isOpen } = useMenuContext();\n\n if (!isOpen) return null;\n\n return (\n <Box\n role=\"menu\"\n position=\"absolute\"\n top=\"100%\"\n left={0}\n mt={1}\n py={1}\n minW=\"160px\"\n bg=\"surface\"\n border=\"thin\"\n borderColor=\"border\"\n rounded=\"md\"\n shadow=\"md\"\n zIndex=\"dropdown\"\n className={clsx(styles.menuList, className)}\n >\n {children}\n </Box>\n );\n}\n\n/**\n * MenuItem - Individual menu item\n *\n * Closes the menu when clicked (unless disabled).\n */\nexport function MenuItem({\n onClick,\n disabled = false,\n className,\n children,\n}: MenuItemProps) {\n const { setIsOpen } = useMenuContext();\n\n const handleClick = () => {\n if (disabled) return;\n onClick?.();\n setIsOpen(false);\n };\n\n return (\n <Box\n as=\"button\"\n type=\"button\"\n role=\"menuitem\"\n onClick={handleClick}\n disabled={disabled}\n display=\"flex\"\n alignItems=\"center\"\n w=\"100%\"\n py={2}\n px={3}\n fontSize=\"sm\"\n color={disabled ? \"foreground-muted\" : \"foreground\"}\n bg=\"transparent\"\n border=\"none\"\n cursor={disabled ? \"not-allowed\" : \"pointer\"}\n textAlign=\"left\"\n className={clsx(styles.menuItem, disabled && styles.disabled, className)}\n >\n {children}\n </Box>\n );\n}\n"],"names":[],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"Menu.js","sources":["../../../src/components/Menu/Menu.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ReactNode,\n createContext,\n useContext,\n useState,\n useRef,\n useEffect,\n useCallback,\n} from \"react\";\nimport clsx from \"clsx\";\nimport { Box } from \"@/components/Box/Box\";\nimport { Button, type ButtonProps } from \"@/components/Button\";\nimport styles from \"./menu.module.css\";\n\n// ============================================================================\n// Context\n// ============================================================================\n\ntype MenuContextValue = {\n isOpen: boolean;\n setIsOpen: (open: boolean) => void;\n buttonRef: React.RefObject<HTMLButtonElement | null>;\n};\n\nconst MenuContext = createContext<MenuContextValue | null>(null);\n\nfunction useMenuContext() {\n const context = useContext(MenuContext);\n if (!context) throw new Error(\"Menu components must be used within Menu\");\n return context;\n}\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport type MenuProps = {\n /** Controlled open state */\n isOpen?: boolean;\n /** Callback when menu opens */\n onOpen?: () => void;\n /** Callback when menu closes */\n onClose?: () => void;\n /** Additional class name */\n className?: string;\n /** Menu components */\n children?: ReactNode;\n};\n\nexport type MenuButtonProps = Omit<ButtonProps<\"button\">, \"as\"> & {\n /** Button content */\n children?: ReactNode;\n};\n\nexport type MenuListProps = {\n /** Additional class name */\n className?: string;\n /** Menu items */\n children?: ReactNode;\n};\n\nexport type MenuItemProps = {\n /** Click handler */\n onClick?: () => void;\n /** Disabled state */\n disabled?: boolean;\n /** Additional class name */\n className?: string;\n /** Item content */\n children?: ReactNode;\n};\n\n// ============================================================================\n// Components\n// ============================================================================\n\n/**\n * Menu - Dropdown menu container\n *\n * Provides context for MenuButton, MenuList, and MenuItem.\n * Handles open/close state and click-outside behavior.\n * Supports controlled mode via isOpen/onOpen/onClose.\n */\nexport function Menu({\n isOpen: controlledIsOpen,\n onOpen,\n onClose,\n className,\n children,\n}: MenuProps) {\n const [internalIsOpen, setInternalIsOpen] = useState(false);\n const isControlled = controlledIsOpen !== undefined;\n const isOpen = isControlled ? controlledIsOpen : internalIsOpen;\n\n const buttonRef = useRef<HTMLButtonElement | null>(null);\n\n const setOpen = useCallback((open: boolean) => {\n if (!isControlled) {\n setInternalIsOpen(open);\n }\n if (open) {\n onOpen?.();\n } else {\n onClose?.();\n }\n }, [isControlled, onOpen, onClose]);\n\n // Close on outside click\n useEffect(() => {\n if (!isOpen) return;\n\n const handleClick = (e: MouseEvent) => {\n if (buttonRef.current?.contains(e.target as Node)) return;\n setOpen(false);\n };\n\n document.addEventListener(\"click\", handleClick);\n return () => document.removeEventListener(\"click\", handleClick);\n }, [isOpen, setOpen]);\n\n // Close on Escape\n useEffect(() => {\n if (!isOpen) return;\n\n const handleKeyDown = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") setOpen(false);\n };\n\n document.addEventListener(\"keydown\", handleKeyDown);\n return () => document.removeEventListener(\"keydown\", handleKeyDown);\n }, [isOpen, setOpen]);\n\n return (\n <MenuContext.Provider value={{ isOpen, setIsOpen: setOpen, buttonRef }}>\n <Box\n position=\"relative\"\n display=\"inline-block\"\n className={clsx(styles.menu, className)}\n >\n {children}\n </Box>\n </MenuContext.Provider>\n );\n}\n\n/**\n * MenuButton - Trigger button for the menu\n *\n * Renders as a Button component with dropdown indicators.\n */\nexport function MenuButton({ children, className, ...rest }: MenuButtonProps) {\n const { isOpen, setIsOpen, buttonRef } = useMenuContext();\n\n return (\n <Button\n ref={buttonRef}\n aria-haspopup=\"menu\"\n aria-expanded={isOpen}\n onClick={() => setIsOpen(!isOpen)}\n className={className}\n {...rest}\n >\n {children}\n </Button>\n );\n}\n\n/**\n * MenuList - Dropdown container for menu items\n *\n * Only renders when menu is open.\n */\nexport function MenuList({ className, children }: MenuListProps) {\n const { isOpen } = useMenuContext();\n\n if (!isOpen) return null;\n\n return (\n <Box\n role=\"menu\"\n position=\"absolute\"\n top=\"100%\"\n left={0}\n mt={1}\n py={1}\n minW=\"160px\"\n bg=\"surface\"\n border=\"thin\"\n borderColor=\"border\"\n rounded=\"md\"\n shadow=\"md\"\n zIndex=\"dropdown\"\n className={clsx(styles.menuList, className)}\n >\n {children}\n </Box>\n );\n}\n\n/**\n * MenuItem - Individual menu item\n *\n * Closes the menu when clicked (unless disabled).\n */\nexport function MenuItem({\n onClick,\n disabled = false,\n className,\n children,\n}: MenuItemProps) {\n const { setIsOpen } = useMenuContext();\n\n const handleClick = () => {\n if (disabled) return;\n onClick?.();\n setIsOpen(false);\n };\n\n return (\n <Box\n as=\"button\"\n type=\"button\"\n role=\"menuitem\"\n onClick={handleClick}\n disabled={disabled}\n display=\"flex\"\n alignItems=\"center\"\n w=\"100%\"\n py={2}\n px={3}\n fontSize=\"sm\"\n color={disabled ? \"foreground-muted\" : \"foreground\"}\n bg=\"transparent\"\n border=\"none\"\n cursor={disabled ? \"not-allowed\" : \"pointer\"}\n textAlign=\"left\"\n className={clsx(styles.menuItem, disabled && styles.disabled, className)}\n >\n {children}\n </Box>\n );\n}\n"],"names":[],"mappings":";;;;;;;AA0BA,MAAM,cAAc,cAAuC,IAAI;AAE/D,SAAS,iBAAiB;AACxB,QAAM,UAAU,WAAW,WAAW;AACtC,MAAI,CAAC,QAAS,OAAM,IAAI,MAAM,0CAA0C;AACxE,SAAO;AACT;AAqDO,SAAS,KAAK;AAAA,EACnB,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAc;AACZ,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAAS,KAAK;AAC1D,QAAM,eAAe,qBAAqB;AAC1C,QAAM,SAAS,eAAe,mBAAmB;AAEjD,QAAM,YAAY,OAAiC,IAAI;AAEvD,QAAM,UAAU,YAAY,CAAC,SAAkB;AAC7C,QAAI,CAAC,cAAc;AACjB,wBAAkB,IAAI;AAAA,IACxB;AACA,QAAI,MAAM;AACR,eAAA;AAAA,IACF,OAAO;AACL,gBAAA;AAAA,IACF;AAAA,EACF,GAAG,CAAC,cAAc,QAAQ,OAAO,CAAC;AAGlC,YAAU,MAAM;AACd,QAAI,CAAC,OAAQ;AAEb,UAAM,cAAc,CAAC,MAAkB;AACrC,UAAI,UAAU,SAAS,SAAS,EAAE,MAAc,EAAG;AACnD,cAAQ,KAAK;AAAA,IACf;AAEA,aAAS,iBAAiB,SAAS,WAAW;AAC9C,WAAO,MAAM,SAAS,oBAAoB,SAAS,WAAW;AAAA,EAChE,GAAG,CAAC,QAAQ,OAAO,CAAC;AAGpB,YAAU,MAAM;AACd,QAAI,CAAC,OAAQ;AAEb,UAAM,gBAAgB,CAAC,MAAqB;AAC1C,UAAI,EAAE,QAAQ,SAAU,SAAQ,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A,IAAc,eAAA;AAEtB,QAAM,cAAc,MAAM;AACxB,QAAI,SAAU;AACd,cAAA;AACA,cAAU,KAAK;AAAA,EACjB;AAEA,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,IAAG;AAAA,MACH,MAAK;AAAA,MACL,MAAK;AAAA,MACL,SAAS;AAAA,MACT;AAAA,MACA,SAAQ;AAAA,MACR,YAAW;AAAA,MACX,GAAE;AAAA,MACF,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,UAAS;AAAA,MACT,OAAO,WAAW,qBAAqB;AAAA,MACvC,IAAG;AAAA,MACH,QAAO;AAAA,MACP,QAAQ,WAAW,gBAAgB;AAAA,MACnC,WAAU;AAAA,MACV,WAAW,KAAK,OAAO,UAAU,YAAY,OAAO,UAAU,SAAS;AAAA,MAEtE;AAAA,IAAA;AAAA,EAAA;AAGP;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Popover.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/Popover.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"Popover.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/Popover.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAA6D,MAAM,OAAO,CAAC;AAUlG,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;AAEnE,MAAM,MAAM,YAAY,GAAG;IACzB,sBAAsB;IACtB,OAAO,EAAE,SAAS,CAAC;IACnB,2BAA2B;IAC3B,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,6BAA6B;IAC7B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,4BAA4B;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,kCAAkC;IAClC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,mCAAmC;IACnC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,4BAA4B;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sBAAsB;IACtB,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,4BAA4B;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qBAAqB;IACrB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,4BAA4B;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mBAAmB;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,CAAC;AAMF;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CAAC,EACtB,OAAO,EACP,SAAoB,EACpB,WAAkB,EAClB,MAAM,EAAE,gBAAgB,EACxB,MAAM,EACN,OAAO,EACP,SAAS,EACT,QAAQ,GACT,EAAE,YAAY,2CA6Hd;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,kBAAkB,2CAaxE;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,gBAAgB,2CAMpE"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
3
|
-
import { useState, useRef, useEffect } from "react";
|
|
3
|
+
import { useState, useRef, useCallback, useLayoutEffect, useEffect } from "react";
|
|
4
4
|
import { createPortal } from "react-dom";
|
|
5
5
|
import clsx from "clsx";
|
|
6
6
|
import { Box } from "../Box/Box.js";
|
|
@@ -21,7 +21,7 @@ function Popover({
|
|
|
21
21
|
const [position, setPosition] = useState({ top: 0, left: 0 });
|
|
22
22
|
const triggerRef = useRef(null);
|
|
23
23
|
const popoverRef = useRef(null);
|
|
24
|
-
const setOpen = (open) => {
|
|
24
|
+
const setOpen = useCallback((open) => {
|
|
25
25
|
if (!isControlled) {
|
|
26
26
|
setInternalIsOpen(open);
|
|
27
27
|
}
|
|
@@ -30,8 +30,8 @@ function Popover({
|
|
|
30
30
|
} else {
|
|
31
31
|
onClose?.();
|
|
32
32
|
}
|
|
33
|
-
};
|
|
34
|
-
const updatePosition = () => {
|
|
33
|
+
}, [isControlled, onOpen, onClose]);
|
|
34
|
+
const updatePosition = useCallback(() => {
|
|
35
35
|
if (!triggerRef.current || !popoverRef.current) return;
|
|
36
36
|
const triggerRect = triggerRef.current.getBoundingClientRect();
|
|
37
37
|
const popoverRect = popoverRef.current.getBoundingClientRect();
|
|
@@ -57,10 +57,10 @@ function Popover({
|
|
|
57
57
|
break;
|
|
58
58
|
}
|
|
59
59
|
setPosition({ top: top + window.scrollY, left: left + window.scrollX });
|
|
60
|
-
};
|
|
61
|
-
|
|
60
|
+
}, [placement]);
|
|
61
|
+
useLayoutEffect(() => {
|
|
62
62
|
if (isOpen) updatePosition();
|
|
63
|
-
}, [isOpen,
|
|
63
|
+
}, [isOpen, updatePosition]);
|
|
64
64
|
useEffect(() => {
|
|
65
65
|
if (!isOpen || !closeOnBlur) return;
|
|
66
66
|
const handleClick = (e) => {
|
|
@@ -70,7 +70,7 @@ function Popover({
|
|
|
70
70
|
};
|
|
71
71
|
document.addEventListener("click", handleClick);
|
|
72
72
|
return () => document.removeEventListener("click", handleClick);
|
|
73
|
-
}, [isOpen, closeOnBlur]);
|
|
73
|
+
}, [isOpen, closeOnBlur, setOpen]);
|
|
74
74
|
useEffect(() => {
|
|
75
75
|
if (!isOpen) return;
|
|
76
76
|
const handleKeyDown = (e) => {
|
|
@@ -78,7 +78,7 @@ function Popover({
|
|
|
78
78
|
};
|
|
79
79
|
document.addEventListener("keydown", handleKeyDown);
|
|
80
80
|
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
81
|
-
}, [isOpen]);
|
|
81
|
+
}, [isOpen, setOpen]);
|
|
82
82
|
const handleTriggerClick = () => {
|
|
83
83
|
setOpen(!isOpen);
|
|
84
84
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Popover.js","sources":["../../../src/components/Popover/Popover.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, useState, useRef, useEffect } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport clsx from \"clsx\";\nimport { Box } from \"@/components/Box/Box\";\nimport styles from \"./popover.module.css\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport type PopoverPlacement = \"top\" | \"bottom\" | \"left\" | \"right\";\n\nexport type PopoverProps = {\n /** Popover content */\n content: ReactNode;\n /** Placement of popover */\n placement?: PopoverPlacement;\n /** Close on outside click */\n closeOnBlur?: boolean;\n /** Controlled open state */\n isOpen?: boolean;\n /** Callback when popover opens */\n onOpen?: () => void;\n /** Callback when popover closes */\n onClose?: () => void;\n /** Additional class name */\n className?: string;\n /** Trigger element */\n children: ReactNode;\n};\n\nexport type PopoverHeaderProps = {\n /** Additional class name */\n className?: string;\n /** Header content */\n children?: ReactNode;\n};\n\nexport type PopoverBodyProps = {\n /** Additional class name */\n className?: string;\n /** Body content */\n children?: ReactNode;\n};\n\n// ============================================================================\n// Components\n// ============================================================================\n\n/**\n * Popover - Click-triggered overlay with positioning\n *\n * A popover component that:\n * - Toggles on click\n * - Positions relative to trigger\n * - Closes on outside click and Escape\n * - Supports controlled mode via isOpen/onOpen/onClose\n * - Renders via portal\n */\nexport function Popover({\n content,\n placement = \"bottom\",\n closeOnBlur = true,\n isOpen: controlledIsOpen,\n onOpen,\n onClose,\n className,\n children,\n}: PopoverProps) {\n const [internalIsOpen, setInternalIsOpen] = useState(false);\n const isControlled = controlledIsOpen !== undefined;\n const isOpen = isControlled ? controlledIsOpen : internalIsOpen;\n\n const [position, setPosition] = useState({ top: 0, left: 0 });\n const triggerRef = useRef<HTMLElement>(null);\n const popoverRef = useRef<HTMLDivElement>(null);\n\n const setOpen = (open: boolean) => {\n if (!isControlled) {\n setInternalIsOpen(open);\n }\n if (open) {\n onOpen?.();\n } else {\n onClose?.();\n }\n };\n\n const updatePosition = () => {\n if (!triggerRef.current || !popoverRef.current) return;\n\n const triggerRect = triggerRef.current.getBoundingClientRect();\n const popoverRect = popoverRef.current.getBoundingClientRect();\n const gap = 8;\n\n let top = 0;\n let left = 0;\n\n switch (placement) {\n case \"top\":\n top = triggerRect.top - popoverRect.height - gap;\n left = triggerRect.left + (triggerRect.width - popoverRect.width) / 2;\n break;\n case \"bottom\":\n top = triggerRect.bottom + gap;\n left = triggerRect.left + (triggerRect.width - popoverRect.width) / 2;\n break;\n case \"left\":\n top = triggerRect.top + (triggerRect.height - popoverRect.height) / 2;\n left = triggerRect.left - popoverRect.width - gap;\n break;\n case \"right\":\n top = triggerRect.top + (triggerRect.height - popoverRect.height) / 2;\n left = triggerRect.right + gap;\n break;\n }\n\n setPosition({ top: top + window.scrollY, left: left + window.scrollX });\n };\n\n
|
|
1
|
+
{"version":3,"file":"Popover.js","sources":["../../../src/components/Popover/Popover.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, useState, useRef, useEffect, useCallback, useLayoutEffect } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport clsx from \"clsx\";\nimport { Box } from \"@/components/Box/Box\";\nimport styles from \"./popover.module.css\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport type PopoverPlacement = \"top\" | \"bottom\" | \"left\" | \"right\";\n\nexport type PopoverProps = {\n /** Popover content */\n content: ReactNode;\n /** Placement of popover */\n placement?: PopoverPlacement;\n /** Close on outside click */\n closeOnBlur?: boolean;\n /** Controlled open state */\n isOpen?: boolean;\n /** Callback when popover opens */\n onOpen?: () => void;\n /** Callback when popover closes */\n onClose?: () => void;\n /** Additional class name */\n className?: string;\n /** Trigger element */\n children: ReactNode;\n};\n\nexport type PopoverHeaderProps = {\n /** Additional class name */\n className?: string;\n /** Header content */\n children?: ReactNode;\n};\n\nexport type PopoverBodyProps = {\n /** Additional class name */\n className?: string;\n /** Body content */\n children?: ReactNode;\n};\n\n// ============================================================================\n// Components\n// ============================================================================\n\n/**\n * Popover - Click-triggered overlay with positioning\n *\n * A popover component that:\n * - Toggles on click\n * - Positions relative to trigger\n * - Closes on outside click and Escape\n * - Supports controlled mode via isOpen/onOpen/onClose\n * - Renders via portal\n */\nexport function Popover({\n content,\n placement = \"bottom\",\n closeOnBlur = true,\n isOpen: controlledIsOpen,\n onOpen,\n onClose,\n className,\n children,\n}: PopoverProps) {\n const [internalIsOpen, setInternalIsOpen] = useState(false);\n const isControlled = controlledIsOpen !== undefined;\n const isOpen = isControlled ? controlledIsOpen : internalIsOpen;\n\n const [position, setPosition] = useState({ top: 0, left: 0 });\n const triggerRef = useRef<HTMLElement>(null);\n const popoverRef = useRef<HTMLDivElement>(null);\n\n const setOpen = useCallback((open: boolean) => {\n if (!isControlled) {\n setInternalIsOpen(open);\n }\n if (open) {\n onOpen?.();\n } else {\n onClose?.();\n }\n }, [isControlled, onOpen, onClose]);\n\n const updatePosition = useCallback(() => {\n if (!triggerRef.current || !popoverRef.current) return;\n\n const triggerRect = triggerRef.current.getBoundingClientRect();\n const popoverRect = popoverRef.current.getBoundingClientRect();\n const gap = 8;\n\n let top = 0;\n let left = 0;\n\n switch (placement) {\n case \"top\":\n top = triggerRect.top - popoverRect.height - gap;\n left = triggerRect.left + (triggerRect.width - popoverRect.width) / 2;\n break;\n case \"bottom\":\n top = triggerRect.bottom + gap;\n left = triggerRect.left + (triggerRect.width - popoverRect.width) / 2;\n break;\n case \"left\":\n top = triggerRect.top + (triggerRect.height - popoverRect.height) / 2;\n left = triggerRect.left - popoverRect.width - gap;\n break;\n case \"right\":\n top = triggerRect.top + (triggerRect.height - popoverRect.height) / 2;\n left = triggerRect.right + gap;\n break;\n }\n\n setPosition({ top: top + window.scrollY, left: left + window.scrollX });\n }, [placement]);\n\n useLayoutEffect(() => {\n // eslint-disable-next-line react-hooks/set-state-in-effect -- useLayoutEffect for DOM measurement before paint\n if (isOpen) updatePosition();\n }, [isOpen, updatePosition]);\n\n // Close on outside click\n useEffect(() => {\n if (!isOpen || !closeOnBlur) return;\n\n const handleClick = (e: MouseEvent) => {\n if (\n triggerRef.current?.contains(e.target as Node) ||\n popoverRef.current?.contains(e.target as Node)\n )\n return;\n setOpen(false);\n };\n\n document.addEventListener(\"click\", handleClick);\n return () => document.removeEventListener(\"click\", handleClick);\n }, [isOpen, closeOnBlur, setOpen]);\n\n // Close on Escape\n useEffect(() => {\n if (!isOpen) return;\n\n const handleKeyDown = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") setOpen(false);\n };\n\n document.addEventListener(\"keydown\", handleKeyDown);\n return () => document.removeEventListener(\"keydown\", handleKeyDown);\n }, [isOpen, setOpen]);\n\n const handleTriggerClick = () => {\n setOpen(!isOpen);\n };\n\n return (\n <>\n <Box\n as=\"span\"\n ref={triggerRef}\n display=\"inline-block\"\n onClick={handleTriggerClick}\n aria-expanded={isOpen}\n aria-haspopup=\"dialog\"\n cursor=\"pointer\"\n >\n {children}\n </Box>\n {isOpen &&\n createPortal(\n <Box\n ref={popoverRef}\n position=\"absolute\"\n bg=\"surface\"\n border=\"thin\"\n borderColor=\"border\"\n rounded=\"md\"\n shadow=\"lg\"\n zIndex=\"dropdown\"\n minW=\"200px\"\n className={clsx(styles.popover, className)}\n style={{ top: position.top, left: position.left }}\n role=\"dialog\"\n >\n {content}\n </Box>,\n document.body\n )}\n </>\n );\n}\n\n/**\n * PopoverHeader - Header section for popover\n */\nexport function PopoverHeader({ className, children }: PopoverHeaderProps) {\n return (\n <Box\n px={4}\n py={3}\n borderBottom=\"thin\"\n borderColor=\"border\"\n fontWeight=\"medium\"\n className={clsx(styles.header, className)}\n >\n {children}\n </Box>\n );\n}\n\n/**\n * PopoverBody - Body section for popover\n */\nexport function PopoverBody({ className, children }: PopoverBodyProps) {\n return (\n <Box px={4} py={3} className={clsx(styles.body, className)}>\n {children}\n </Box>\n );\n}\n"],"names":[],"mappings":";;;;;;;AA6DO,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AA,UACZ,SAAQ;AAAA,UACR,QAAO;AAAA,UACP,QAAO;AAAA,UACP,MAAK;AAAA,UACL,WAAW,KAAK,OAAO,SAAS,SAAS;AAAA,UACzC,OAAO,EAAE,KAAK,SAAS,KAAK,MAAM,SAAS,KAAA;AAAA,UAC3C,MAAK;AAAA,UAEJ,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,MAEH,SAAS;AAAA,IAAA;AAAA,EACX,GACJ;AAEJ;AAKO,SAAS,cAAc,EAAE,WAAW,YAAgC;AACzE,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,cAAa;AAAA,MACb,aAAY;AAAA,MACZ,YAAW;AAAA,MACX,WAAW,KAAK,OAAO,QAAQ,SAAS;AAAA,MAEvC;AAAA,IAAA;AAAA,EAAA;AAGP;AAKO,SAAS,YAAY,EAAE,WAAW,YAA8B;AACrE,SACE,oBAAC,KAAA,EAAI,IAAI,GAAG,IAAI,GAAG,WAAW,KAAK,OAAO,MAAM,SAAS,GACtD,SAAA,CACH;AAEJ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Progress.d.ts","sourceRoot":"","sources":["../../../src/components/Progress/Progress.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Progress.d.ts","sourceRoot":"","sources":["../../../src/components/Progress/Progress.tsx"],"names":[],"mappings":"AAUA,MAAM,MAAM,mBAAmB,GAC3B,SAAS,GACT,QAAQ,GACR,SAAS,GACT,SAAS,GACT,OAAO,GACP,MAAM,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE9C,MAAM,MAAM,aAAa,GAAG;IAC1B,6BAA6B;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kCAAkC;IAClC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,mBAAmB;IACnB,WAAW,CAAC,EAAE,mBAAmB,CAAC;IAClC,WAAW;IACX,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,0DAA0D;IAC1D,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,4BAA4B;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAgBF;;;;;;;;;;;GAWG;AACH,wBAAgB,QAAQ,CAAC,EACvB,KAAS,EACT,GAAS,EACT,WAAuB,EACvB,IAAW,EACX,eAAuB,EACvB,SAAS,GACV,EAAE,aAAa,2CAkCf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Progress.js","sources":["../../../src/components/Progress/Progress.tsx"],"sourcesContent":["import { type CSSProperties } from \"react\";\nimport clsx from \"clsx\";\nimport { Box } from \"@/components/Box/Box\";\nimport styles from \"./progress.module.css\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport type ProgressColorScheme =\n | \"primary\"\n | \"accent\"\n | \"success\"\n | \"warning\"\n | \"error\"\n | \"info\";\n\nexport type ProgressSize = \"sm\" | \"md\" | \"lg\";\n\nexport type ProgressProps = {\n /** Progress value (0-100) */\n value?: number;\n /** Maximum value (default 100) */\n max?: number;\n /** Color scheme */\n colorScheme?: ProgressColorScheme;\n /** Size */\n size?: ProgressSize;\n /** Indeterminate mode (loading without known progress) */\n isIndeterminate?: boolean;\n /** Additional class name */\n className?: string;\n};\n\n// ============================================================================\n// Size configurations\n// ============================================================================\n\nconst sizeConfig = {\n sm: \"4px\",\n md: \"8px\",\n lg: \"12px\",\n} as const;\n\n// ============================================================================\n// Component\n// ============================================================================\n\n/**\n * Progress - Progress bar indicator\n *\n * A visual indicator of completion progress:\n * - Value-based: shows percentage complete\n * - Indeterminate: animated loading state\n *\n * Features:\n * - 6 color schemes\n * - 3 sizes (sm, md, lg)\n * - Accessible with role=\"progressbar\" and ARIA attributes\n */\nexport function Progress({\n value = 0,\n max = 100,\n colorScheme = \"primary\",\n size = \"md\",\n isIndeterminate = false,\n className,\n}: ProgressProps) {\n const percentage = Math.min(100, Math.max(0, (value / max) * 100));\n const height = sizeConfig[size];\n\n return (\n <Box\n role=\"progressbar\"\n aria-valuenow={isIndeterminate ? undefined : value}\n aria-valuemin={0}\n aria-valuemax={max}\n position=\"relative\"\n overflow=\"hidden\"\n rounded=\"full\"\n bg=\"surface\"\n className={clsx(styles.track, className)}\n style={{ \"--progress-height\": height } as CSSProperties}\n >\n <Box\n position=\"absolute\"\n inset={0}\n rounded=\"full\"\n bg={`${colorScheme}-default` as
|
|
1
|
+
{"version":3,"file":"Progress.js","sources":["../../../src/components/Progress/Progress.tsx"],"sourcesContent":["import { type CSSProperties } from \"react\";\nimport type { BackgroundColorValue } from \"@/components/Box/colors/colors\";\nimport clsx from \"clsx\";\nimport { Box } from \"@/components/Box/Box\";\nimport styles from \"./progress.module.css\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport type ProgressColorScheme =\n | \"primary\"\n | \"accent\"\n | \"success\"\n | \"warning\"\n | \"error\"\n | \"info\";\n\nexport type ProgressSize = \"sm\" | \"md\" | \"lg\";\n\nexport type ProgressProps = {\n /** Progress value (0-100) */\n value?: number;\n /** Maximum value (default 100) */\n max?: number;\n /** Color scheme */\n colorScheme?: ProgressColorScheme;\n /** Size */\n size?: ProgressSize;\n /** Indeterminate mode (loading without known progress) */\n isIndeterminate?: boolean;\n /** Additional class name */\n className?: string;\n};\n\n// ============================================================================\n// Size configurations\n// ============================================================================\n\nconst sizeConfig = {\n sm: \"4px\",\n md: \"8px\",\n lg: \"12px\",\n} as const;\n\n// ============================================================================\n// Component\n// ============================================================================\n\n/**\n * Progress - Progress bar indicator\n *\n * A visual indicator of completion progress:\n * - Value-based: shows percentage complete\n * - Indeterminate: animated loading state\n *\n * Features:\n * - 6 color schemes\n * - 3 sizes (sm, md, lg)\n * - Accessible with role=\"progressbar\" and ARIA attributes\n */\nexport function Progress({\n value = 0,\n max = 100,\n colorScheme = \"primary\",\n size = \"md\",\n isIndeterminate = false,\n className,\n}: ProgressProps) {\n const percentage = Math.min(100, Math.max(0, (value / max) * 100));\n const height = sizeConfig[size];\n\n return (\n <Box\n role=\"progressbar\"\n aria-valuenow={isIndeterminate ? undefined : value}\n aria-valuemin={0}\n aria-valuemax={max}\n position=\"relative\"\n overflow=\"hidden\"\n rounded=\"full\"\n bg=\"surface\"\n className={clsx(styles.track, className)}\n style={{ \"--progress-height\": height } as CSSProperties}\n >\n <Box\n position=\"absolute\"\n inset={0}\n rounded=\"full\"\n bg={`${colorScheme}-default` as BackgroundColorValue}\n className={clsx(\n styles.fill,\n isIndeterminate && styles.indeterminate\n )}\n style={\n isIndeterminate\n ? undefined\n : ({ \"--progress-width\": `${percentage}%` } as CSSProperties)\n }\n />\n </Box>\n );\n}\n"],"names":[],"mappings":";;;;;AAuCA,MAAM,aAAa;AAAA,EACjB,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AAkBO,SAAS,SAAS;AAAA,EACvB,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,cAAc;AAAA,EACd,OAAO;AAAA,EACP,kBAAkB;AAAA,EAClB;AACF,GAAkB;AAChB,QAAM,aAAa,KAAK,IAAI,KAAK,KAAK,IAAI,GAAI,QAAQ,MAAO,GAAG,CAAC;AACjE,QAAM,SAAS,WAAW,IAAI;AAE9B,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,MAAK;AAAA,MACL,iBAAe,kBAAkB,SAAY;AAAA,MAC7C,iBAAe;AAAA,MACf,iBAAe;AAAA,MACf,UAAS;AAAA,MACT,UAAS;AAAA,MACT,SAAQ;AAAA,MACR,IAAG;AAAA,MACH,WAAW,KAAK,OAAO,OAAO,SAAS;AAAA,MACvC,OAAO,EAAE,qBAAqB,OAAA;AAAA,MAE9B,UAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,UAAS;AAAA,UACT,OAAO;AAAA,UACP,SAAQ;AAAA,UACR,IAAI,GAAG,WAAW;AAAA,UAClB,WAAW;AAAA,YACT,OAAO;AAAA,YACP,mBAAmB,OAAO;AAAA,UAAA;AAAA,UAE5B,OACE,kBACI,SACC,EAAE,oBAAoB,GAAG,UAAU,IAAA;AAAA,QAAI;AAAA,MAAA;AAAA,IAEhD;AAAA,EAAA;AAGN;"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { ElementType } from 'react';
|
|
2
2
|
import { Polymorphic } from '../../types/Polymorphic';
|
|
3
3
|
import { BoxOwnProps } from '../Box/Box';
|
|
4
|
+
import { ResponsiveValue } from '../../utils/breakpoints';
|
|
4
5
|
import { FlexDirectionValue, JustifyContentValue, AlignItemsValue, SpacingValue } from '../Box/flexbox/flexbox';
|
|
5
6
|
export type StackOwnProps = Omit<BoxOwnProps, "display" | "flexDirection" | "justifyContent" | "alignItems" | "flexWrap" | "gap"> & {
|
|
6
7
|
/** Stack direction: row, column, row-reverse, column-reverse */
|
|
7
8
|
direction?: FlexDirectionValue;
|
|
8
9
|
/** Gap between children (0-32 spacing multiplier) */
|
|
9
|
-
gap?: SpacingValue
|
|
10
|
+
gap?: ResponsiveValue<SpacingValue>;
|
|
10
11
|
/** Align items along the cross axis */
|
|
11
12
|
align?: AlignItemsValue;
|
|
12
13
|
/** Justify content along the main axis */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Stack.d.ts","sourceRoot":"","sources":["../../../src/components/Stack/Stack.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAO,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,YAAY,EACb,MAAM,kCAAkC,CAAC;AAM1C,MAAM,MAAM,aAAa,GAAG,IAAI,CAC9B,WAAW,EACX,SAAS,GAAG,eAAe,GAAG,gBAAgB,GAAG,YAAY,GAAG,UAAU,GAAG,K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,GAAG,IAAI,EACR,EAAE,UAAU,CAAC,CAAC,CAAC,2CAgBf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Stack.js","sources":["../../../src/components/Stack/Stack.tsx"],"sourcesContent":["import { type ElementType } from \"react\";\nimport { type Polymorphic } from \"@/types/Polymorphic\";\nimport { Box, type BoxOwnProps } from \"@/components/Box/Box\";\nimport type {\n FlexDirectionValue,\n JustifyContentValue,\n AlignItemsValue,\n SpacingValue,\n} from \"@/components/Box/flexbox/flexbox\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport type StackOwnProps = Omit<\n BoxOwnProps,\n \"display\" | \"flexDirection\" | \"justifyContent\" | \"alignItems\" | \"flexWrap\" | \"gap\"\n> & {\n /** Stack direction: row, column, row-reverse, column-reverse */\n direction?: FlexDirectionValue;\n /** Gap between children (0-32 spacing multiplier) */\n gap?: SpacingValue
|
|
1
|
+
{"version":3,"file":"Stack.js","sources":["../../../src/components/Stack/Stack.tsx"],"sourcesContent":["import { type ElementType } from \"react\";\nimport { type Polymorphic } from \"@/types/Polymorphic\";\nimport { Box, type BoxOwnProps } from \"@/components/Box/Box\";\nimport type { ResponsiveValue } from \"@/utils/breakpoints\";\nimport type {\n FlexDirectionValue,\n JustifyContentValue,\n AlignItemsValue,\n SpacingValue,\n} from \"@/components/Box/flexbox/flexbox\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport type StackOwnProps = Omit<\n BoxOwnProps,\n \"display\" | \"flexDirection\" | \"justifyContent\" | \"alignItems\" | \"flexWrap\" | \"gap\"\n> & {\n /** Stack direction: row, column, row-reverse, column-reverse */\n direction?: FlexDirectionValue;\n /** Gap between children (0-32 spacing multiplier) */\n gap?: ResponsiveValue<SpacingValue>;\n /** Align items along the cross axis */\n align?: AlignItemsValue;\n /** Justify content along the main axis */\n justify?: JustifyContentValue;\n /** Enable flex wrapping */\n wrap?: boolean;\n};\n\nexport type StackProps<T extends ElementType = \"div\"> = Polymorphic<\n T,\n StackOwnProps\n>;\n\n// ============================================================================\n// Component\n// ============================================================================\n\n/**\n * Stack - Flex-based layout component\n *\n * A polymorphic flex container that provides:\n * - Default element: <div>\n * - Direction: column (default), row, row-reverse, column-reverse\n * - Gap: spacing multiplier (0-32)\n * - Align: cross-axis alignment\n * - Justify: main-axis alignment\n * - Wrap: enable flex wrapping\n */\nexport function Stack<T extends ElementType = \"div\">({\n as,\n direction = \"column\",\n gap,\n align,\n justify,\n wrap,\n children,\n ...rest\n}: StackProps<T>) {\n return (\n // @ts-expect-error - Polymorphic component type forwarding\n <Box\n as={as || \"div\"}\n display=\"flex\"\n flexDirection={direction}\n gap={gap}\n alignItems={align}\n justifyContent={justify}\n flexWrap={wrap ? \"wrap\" : undefined}\n {...rest}\n >\n {children}\n </Box>\n );\n}\n"],"names":[],"mappings":";;;AAmDO,SAAS,MAAqC;AAAA,EACnD;AAAA,EACA,YAAY;AAAA,EACZ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAkB;AAChB;AAAA;AAAA,IAEE;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,IAAI,MAAM;AAAA,QACV,SAAQ;AAAA,QACR,eAAe;AAAA,QACf;AAAA,QACA,YAAY;AAAA,QACZ,gBAAgB;AAAA,QAChB,UAAU,OAAO,SAAS;AAAA,QACzB,GAAG;AAAA,QAEH;AAAA,MAAA;AAAA,IAAA;AAAA;AAGP;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../../src/components/Tooltip/Tooltip.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../../src/components/Tooltip/Tooltip.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAA6D,MAAM,OAAO,CAAC;AAUlG,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;AAEnE,MAAM,MAAM,YAAY,GAAG;IACzB,sBAAsB;IACtB,KAAK,EAAE,SAAS,CAAC;IACjB,2BAA2B;IAC3B,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,gCAAgC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+BAA+B;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kCAAkC;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,4BAA4B;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,kCAAkC;IAClC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,mCAAmC;IACnC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,4BAA4B;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sBAAsB;IACtB,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC;AAMF;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CAAC,EACtB,KAAK,EACL,SAAiB,EACjB,SAAa,EACb,UAAc,EACd,QAAgB,EAChB,MAAM,EAAE,gBAAgB,EACxB,MAAM,EACN,OAAO,EACP,SAAS,EACT,QAAQ,GACT,EAAE,YAAY,2CA8Hd"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
3
|
-
import { useState, useRef, useEffect } from "react";
|
|
3
|
+
import { useState, useRef, useCallback, useLayoutEffect, useEffect } from "react";
|
|
4
4
|
import { createPortal } from "react-dom";
|
|
5
5
|
import clsx from "clsx";
|
|
6
6
|
import { Box } from "../Box/Box.js";
|
|
@@ -25,7 +25,7 @@ function Tooltip({
|
|
|
25
25
|
const tooltipRef = useRef(null);
|
|
26
26
|
const openTimeoutRef = useRef(null);
|
|
27
27
|
const closeTimeoutRef = useRef(null);
|
|
28
|
-
const updatePosition = () => {
|
|
28
|
+
const updatePosition = useCallback(() => {
|
|
29
29
|
if (!triggerRef.current || !tooltipRef.current) return;
|
|
30
30
|
const triggerRect = triggerRef.current.getBoundingClientRect();
|
|
31
31
|
const tooltipRect = tooltipRef.current.getBoundingClientRect();
|
|
@@ -51,10 +51,10 @@ function Tooltip({
|
|
|
51
51
|
break;
|
|
52
52
|
}
|
|
53
53
|
setPosition({ top: top + window.scrollY, left: left + window.scrollX });
|
|
54
|
-
};
|
|
55
|
-
|
|
54
|
+
}, [placement]);
|
|
55
|
+
useLayoutEffect(() => {
|
|
56
56
|
if (isOpen) updatePosition();
|
|
57
|
-
}, [isOpen,
|
|
57
|
+
}, [isOpen, updatePosition]);
|
|
58
58
|
const setOpen = (open) => {
|
|
59
59
|
if (!isControlled) {
|
|
60
60
|
setInternalIsOpen(open);
|