@traefik-labs/faency 13.1.0 → 13.1.1
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/Badge/Badge.cjs +1 -5
- package/dist/components/Badge/Badge.cjs.map +1 -1
- package/dist/components/Badge/Badge.js +2 -6
- package/dist/components/Badge/Badge.js.map +1 -1
- package/dist/components/Button/Button.cjs +1 -2
- package/dist/components/Button/Button.cjs.map +1 -1
- package/dist/components/Button/Button.js +2 -3
- package/dist/components/Button/Button.js.map +1 -1
- package/dist/components/CodeBlock/CodeBlock.cjs +2 -1
- package/dist/components/CodeBlock/CodeBlock.cjs.map +1 -1
- package/dist/components/CodeBlock/CodeBlock.js +3 -2
- package/dist/components/CodeBlock/CodeBlock.js.map +1 -1
- package/dist/components/CodeBlock/CodeBlock.vanilla.cjs +2 -1
- package/dist/components/CodeBlock/CodeBlock.vanilla.cjs.map +1 -1
- package/dist/components/CodeBlock/CodeBlock.vanilla.js +3 -2
- package/dist/components/CodeBlock/CodeBlock.vanilla.js.map +1 -1
- package/dist/components/TextField/TextField.cjs +2 -2
- package/dist/components/TextField/TextField.cjs.map +1 -1
- package/dist/components/TextField/TextField.js +2 -2
- package/dist/components/TextField/TextField.js.map +1 -1
- package/dist/components/TextField/TextField.vanilla.cjs +2 -2
- package/dist/components/TextField/TextField.vanilla.cjs.map +1 -1
- package/dist/components/TextField/TextField.vanilla.js +2 -2
- package/dist/components/TextField/TextField.vanilla.js.map +1 -1
- package/dist/styles/themeContext.cjs +2 -1
- package/dist/styles/themeContext.cjs.map +1 -1
- package/dist/styles/themeContext.js +3 -2
- package/dist/styles/themeContext.js.map +1 -1
- package/dist/utils/useIsomorphicLayoutEffect.cjs +6 -0
- package/dist/utils/useIsomorphicLayoutEffect.cjs.map +1 -0
- package/dist/utils/useIsomorphicLayoutEffect.js +6 -0
- package/dist/utils/useIsomorphicLayoutEffect.js.map +1 -0
- package/package.json +15 -15
|
@@ -97,11 +97,7 @@ var StyledButtonBadge = require_stitches_config.styled("button", BADGE_BASE_STYL
|
|
|
97
97
|
});
|
|
98
98
|
var StyledButtonBadgeSlot = require_stitches_config.styled(_radix_ui_react_slot.Slot, StyledButtonBadge);
|
|
99
99
|
var Badge = react.default.forwardRef(({ interactive, asChild, ...props }, forwardedRef) => {
|
|
100
|
-
|
|
101
|
-
if (interactive) return asChild ? StyledButtonBadgeSlot : StyledButtonBadge;
|
|
102
|
-
return asChild ? StyledSpanBadgeSlot : StyledSpanBadge;
|
|
103
|
-
}, [asChild]);
|
|
104
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Component, {
|
|
100
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(interactive ? asChild ? StyledButtonBadgeSlot : StyledButtonBadge : asChild ? StyledSpanBadgeSlot : StyledSpanBadge, {
|
|
105
101
|
...props,
|
|
106
102
|
ref: forwardedRef
|
|
107
103
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Badge.cjs","names":["COLORS","styled","Slot","React"
|
|
1
|
+
{"version":3,"file":"Badge.cjs","names":["COLORS","styled","Slot","React"],"sources":["../../../components/Badge/Badge.tsx"],"sourcesContent":["import { Slot } from '@radix-ui/react-slot';\nimport React, { ComponentProps } from 'react';\n\nimport { styled, VariantProps } from '../../stitches.config';\nimport { COLORS } from './Badge.vanilla';\n\ntype COLOR_VALUES = (typeof COLORS)[number];\n\nconst getColorBadgeStyles = (color: COLOR_VALUES) => ({\n bc: `$${color}6`,\n color: `$${color}10`,\n border: `1px solid $${color}10`,\n});\n\ntype ColorVariants = Record<COLOR_VALUES, { bc: string; color: string }>;\nconst colorVariants: ColorVariants = COLORS.reduce(\n (variants, color) => ({\n ...variants,\n [color]: getColorBadgeStyles(color),\n }),\n {} as ColorVariants,\n);\n\nconst interactiveColorVariants: ColorVariants = COLORS.reduce(\n (variants, color) => ({\n ...variants,\n [color]: {\n ...getColorBadgeStyles(color),\n },\n }),\n {} as ColorVariants,\n);\n\nconst alphaColorCompoundVariants = COLORS.map((color) => ({\n alphaBg: true,\n variant: color,\n css: { bc: `$${color}A6` },\n}));\n\nconst BADGE_BASE_STYLES = {\n // Reset\n alignItems: 'center',\n appearance: 'none',\n border: 'none',\n boxSizing: 'border-box',\n display: 'inline-flex',\n flexShrink: 0,\n fontFamily: '$rubik',\n fontWeight: '$medium',\n justifyContent: 'center',\n lineHeight: '1',\n verticalAlign: 'middle',\n outline: 'none',\n padding: '0',\n textDecoration: 'none',\n userSelect: 'none',\n WebkitTapHighlightColor: 'rgba(0,0,0,0)',\n borderRadius: '$pill',\n whiteSpace: 'nowrap',\n fontVariantNumeric: 'tabular-nums',\n position: 'relative',\n\n '&:disabled': {\n backgroundColor: '$slate3',\n pointerEvents: 'none',\n color: '$slate8',\n },\n variants: {\n size: {\n small: {\n height: '$4',\n px: '$2',\n fontSize: '$2',\n },\n large: {\n height: '$5',\n px: '$3',\n fontSize: '$3',\n },\n },\n variant: colorVariants,\n alphaBg: {\n true: {},\n },\n borderless: {\n true: {\n border: 'none',\n },\n },\n },\n compoundVariants: alphaColorCompoundVariants,\n defaultVariants: {\n size: 'small',\n variant: 'gray',\n borderless: false,\n },\n};\n\nconst StyledSpanBadge = styled('span', BADGE_BASE_STYLES);\nconst StyledSpanBadgeSlot = styled(Slot, StyledSpanBadge);\n\nconst StyledButtonBadge = styled('button', BADGE_BASE_STYLES, {\n '&::before': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n inset: 0,\n borderRadius: 'inherit',\n },\n '&:focus-visible': {\n outline: '2px solid $primary',\n },\n '&:hover': {\n cursor: 'pointer',\n '&::before': {\n backgroundColor: '$badgeInteractiveBackgroundHover',\n },\n },\n '&:active': {\n '&::before': {\n backgroundColor: '$badgeInteractiveBackgroundActive',\n },\n },\n\n variants: {\n variant: interactiveColorVariants,\n borderless: {\n true: {\n border: 'none',\n },\n },\n },\n});\nconst StyledButtonBadgeSlot = styled(Slot, StyledButtonBadge);\n\ntype BadgeProps = ComponentProps<typeof StyledButtonBadge> &\n VariantProps<typeof StyledButtonBadge> & {\n asChild?: boolean;\n interactive?: boolean;\n };\n\nexport const Badge = React.forwardRef<React.ElementRef<typeof StyledButtonBadge>, BadgeProps>(\n ({ interactive, asChild, ...props }, forwardedRef) => {\n const Component = interactive\n ? asChild\n ? StyledButtonBadgeSlot\n : StyledButtonBadge\n : asChild\n ? StyledSpanBadgeSlot\n : StyledSpanBadge;\n\n return <Component {...props} ref={forwardedRef} />;\n },\n);\n"],"mappings":";;;;;;;;AAQA,IAAM,uBAAuB,WAAyB;CACpD,IAAI,IAAI,MAAM;CACd,OAAO,IAAI,MAAM;CACjB,QAAQ,cAAc,MAAM;AAC9B;AAGA,IAAM,gBAA+BA,sBAAAA,OAAO,QACzC,UAAU,WAAW;CACpB,GAAG;EACF,QAAQ,oBAAoB,KAAK;AACpC,IACA,CAAC,CACH;AAEA,IAAM,2BAA0CA,sBAAAA,OAAO,QACpD,UAAU,WAAW;CACpB,GAAG;EACF,QAAQ,EACP,GAAG,oBAAoB,KAAK,EAC9B;AACF,IACA,CAAC,CACH;AAEA,IAAM,6BAA6BA,sBAAAA,OAAO,KAAK,WAAW;CACxD,SAAS;CACT,SAAS;CACT,KAAK,EAAE,IAAI,IAAI,MAAM,IAAI;AAC3B,EAAE;AAEF,IAAM,oBAAoB;CAExB,YAAY;CACZ,YAAY;CACZ,QAAQ;CACR,WAAW;CACX,SAAS;CACT,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,gBAAgB;CAChB,YAAY;CACZ,eAAe;CACf,SAAS;CACT,SAAS;CACT,gBAAgB;CAChB,YAAY;CACZ,yBAAyB;CACzB,cAAc;CACd,YAAY;CACZ,oBAAoB;CACpB,UAAU;CAEV,cAAc;EACZ,iBAAiB;EACjB,eAAe;EACf,OAAO;CACT;CACA,UAAU;EACR,MAAM;GACJ,OAAO;IACL,QAAQ;IACR,IAAI;IACJ,UAAU;GACZ;GACA,OAAO;IACL,QAAQ;IACR,IAAI;IACJ,UAAU;GACZ;EACF;EACA,SAAS;EACT,SAAS,EACP,MAAM,CAAC,EACT;EACA,YAAY,EACV,MAAM,EACJ,QAAQ,OACV,EACF;CACF;CACA,kBAAkB;CAClB,iBAAiB;EACf,MAAM;EACN,SAAS;EACT,YAAY;CACd;AACF;AAEA,IAAM,kBAAkBC,wBAAAA,OAAO,QAAQ,iBAAiB;AACxD,IAAM,sBAAsBA,wBAAAA,OAAOC,qBAAAA,MAAM,eAAe;AAExD,IAAM,oBAAoBD,wBAAAA,OAAO,UAAU,mBAAmB;CAC5D,aAAa;EACX,WAAW;EACX,SAAS;EACT,UAAU;EACV,OAAO;EACP,cAAc;CAChB;CACA,mBAAmB,EACjB,SAAS,qBACX;CACA,WAAW;EACT,QAAQ;EACR,aAAa,EACX,iBAAiB,mCACnB;CACF;CACA,YAAY,EACV,aAAa,EACX,iBAAiB,oCACnB,EACF;CAEA,UAAU;EACR,SAAS;EACT,YAAY,EACV,MAAM,EACJ,QAAQ,OACV,EACF;CACF;AACF,CAAC;AACD,IAAM,wBAAwBA,wBAAAA,OAAOC,qBAAAA,MAAM,iBAAiB;AAQ5D,IAAa,QAAQC,MAAAA,QAAM,YACxB,EAAE,aAAa,SAAS,GAAG,SAAS,iBAAiB;CASpD,OAAO,iBAAA,GAAA,kBAAA,IAAA,CARW,cACd,UACE,wBACA,oBACF,UACE,sBACA,iBAEC;EAAW,GAAI;EAAO,KAAK;CAAe,CAAA;AACnD,CACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { styled } from "../../stitches.config.js";
|
|
2
2
|
import { COLORS } from "./Badge.vanilla.js";
|
|
3
|
-
import React
|
|
3
|
+
import React from "react";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
import { Slot } from "@radix-ui/react-slot";
|
|
6
6
|
// components/Badge/Badge.tsx
|
|
@@ -95,11 +95,7 @@ var StyledButtonBadge = styled("button", BADGE_BASE_STYLES, {
|
|
|
95
95
|
});
|
|
96
96
|
var StyledButtonBadgeSlot = styled(Slot, StyledButtonBadge);
|
|
97
97
|
var Badge = React.forwardRef(({ interactive, asChild, ...props }, forwardedRef) => {
|
|
98
|
-
|
|
99
|
-
if (interactive) return asChild ? StyledButtonBadgeSlot : StyledButtonBadge;
|
|
100
|
-
return asChild ? StyledSpanBadgeSlot : StyledSpanBadge;
|
|
101
|
-
}, [asChild]);
|
|
102
|
-
return /* @__PURE__ */ jsx(Component, {
|
|
98
|
+
return /* @__PURE__ */ jsx(interactive ? asChild ? StyledButtonBadgeSlot : StyledButtonBadge : asChild ? StyledSpanBadgeSlot : StyledSpanBadge, {
|
|
103
99
|
...props,
|
|
104
100
|
ref: forwardedRef
|
|
105
101
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Badge.js","names":[],"sources":["../../../components/Badge/Badge.tsx"],"sourcesContent":["import { Slot } from '@radix-ui/react-slot';\nimport React, { ComponentProps
|
|
1
|
+
{"version":3,"file":"Badge.js","names":[],"sources":["../../../components/Badge/Badge.tsx"],"sourcesContent":["import { Slot } from '@radix-ui/react-slot';\nimport React, { ComponentProps } from 'react';\n\nimport { styled, VariantProps } from '../../stitches.config';\nimport { COLORS } from './Badge.vanilla';\n\ntype COLOR_VALUES = (typeof COLORS)[number];\n\nconst getColorBadgeStyles = (color: COLOR_VALUES) => ({\n bc: `$${color}6`,\n color: `$${color}10`,\n border: `1px solid $${color}10`,\n});\n\ntype ColorVariants = Record<COLOR_VALUES, { bc: string; color: string }>;\nconst colorVariants: ColorVariants = COLORS.reduce(\n (variants, color) => ({\n ...variants,\n [color]: getColorBadgeStyles(color),\n }),\n {} as ColorVariants,\n);\n\nconst interactiveColorVariants: ColorVariants = COLORS.reduce(\n (variants, color) => ({\n ...variants,\n [color]: {\n ...getColorBadgeStyles(color),\n },\n }),\n {} as ColorVariants,\n);\n\nconst alphaColorCompoundVariants = COLORS.map((color) => ({\n alphaBg: true,\n variant: color,\n css: { bc: `$${color}A6` },\n}));\n\nconst BADGE_BASE_STYLES = {\n // Reset\n alignItems: 'center',\n appearance: 'none',\n border: 'none',\n boxSizing: 'border-box',\n display: 'inline-flex',\n flexShrink: 0,\n fontFamily: '$rubik',\n fontWeight: '$medium',\n justifyContent: 'center',\n lineHeight: '1',\n verticalAlign: 'middle',\n outline: 'none',\n padding: '0',\n textDecoration: 'none',\n userSelect: 'none',\n WebkitTapHighlightColor: 'rgba(0,0,0,0)',\n borderRadius: '$pill',\n whiteSpace: 'nowrap',\n fontVariantNumeric: 'tabular-nums',\n position: 'relative',\n\n '&:disabled': {\n backgroundColor: '$slate3',\n pointerEvents: 'none',\n color: '$slate8',\n },\n variants: {\n size: {\n small: {\n height: '$4',\n px: '$2',\n fontSize: '$2',\n },\n large: {\n height: '$5',\n px: '$3',\n fontSize: '$3',\n },\n },\n variant: colorVariants,\n alphaBg: {\n true: {},\n },\n borderless: {\n true: {\n border: 'none',\n },\n },\n },\n compoundVariants: alphaColorCompoundVariants,\n defaultVariants: {\n size: 'small',\n variant: 'gray',\n borderless: false,\n },\n};\n\nconst StyledSpanBadge = styled('span', BADGE_BASE_STYLES);\nconst StyledSpanBadgeSlot = styled(Slot, StyledSpanBadge);\n\nconst StyledButtonBadge = styled('button', BADGE_BASE_STYLES, {\n '&::before': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n inset: 0,\n borderRadius: 'inherit',\n },\n '&:focus-visible': {\n outline: '2px solid $primary',\n },\n '&:hover': {\n cursor: 'pointer',\n '&::before': {\n backgroundColor: '$badgeInteractiveBackgroundHover',\n },\n },\n '&:active': {\n '&::before': {\n backgroundColor: '$badgeInteractiveBackgroundActive',\n },\n },\n\n variants: {\n variant: interactiveColorVariants,\n borderless: {\n true: {\n border: 'none',\n },\n },\n },\n});\nconst StyledButtonBadgeSlot = styled(Slot, StyledButtonBadge);\n\ntype BadgeProps = ComponentProps<typeof StyledButtonBadge> &\n VariantProps<typeof StyledButtonBadge> & {\n asChild?: boolean;\n interactive?: boolean;\n };\n\nexport const Badge = React.forwardRef<React.ElementRef<typeof StyledButtonBadge>, BadgeProps>(\n ({ interactive, asChild, ...props }, forwardedRef) => {\n const Component = interactive\n ? asChild\n ? StyledButtonBadgeSlot\n : StyledButtonBadge\n : asChild\n ? StyledSpanBadgeSlot\n : StyledSpanBadge;\n\n return <Component {...props} ref={forwardedRef} />;\n },\n);\n"],"mappings":";;;;;;AAQA,IAAM,uBAAuB,WAAyB;CACpD,IAAI,IAAI,MAAM;CACd,OAAO,IAAI,MAAM;CACjB,QAAQ,cAAc,MAAM;AAC9B;AAGA,IAAM,gBAA+B,OAAO,QACzC,UAAU,WAAW;CACpB,GAAG;EACF,QAAQ,oBAAoB,KAAK;AACpC,IACA,CAAC,CACH;AAEA,IAAM,2BAA0C,OAAO,QACpD,UAAU,WAAW;CACpB,GAAG;EACF,QAAQ,EACP,GAAG,oBAAoB,KAAK,EAC9B;AACF,IACA,CAAC,CACH;AAEA,IAAM,6BAA6B,OAAO,KAAK,WAAW;CACxD,SAAS;CACT,SAAS;CACT,KAAK,EAAE,IAAI,IAAI,MAAM,IAAI;AAC3B,EAAE;AAEF,IAAM,oBAAoB;CAExB,YAAY;CACZ,YAAY;CACZ,QAAQ;CACR,WAAW;CACX,SAAS;CACT,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,gBAAgB;CAChB,YAAY;CACZ,eAAe;CACf,SAAS;CACT,SAAS;CACT,gBAAgB;CAChB,YAAY;CACZ,yBAAyB;CACzB,cAAc;CACd,YAAY;CACZ,oBAAoB;CACpB,UAAU;CAEV,cAAc;EACZ,iBAAiB;EACjB,eAAe;EACf,OAAO;CACT;CACA,UAAU;EACR,MAAM;GACJ,OAAO;IACL,QAAQ;IACR,IAAI;IACJ,UAAU;GACZ;GACA,OAAO;IACL,QAAQ;IACR,IAAI;IACJ,UAAU;GACZ;EACF;EACA,SAAS;EACT,SAAS,EACP,MAAM,CAAC,EACT;EACA,YAAY,EACV,MAAM,EACJ,QAAQ,OACV,EACF;CACF;CACA,kBAAkB;CAClB,iBAAiB;EACf,MAAM;EACN,SAAS;EACT,YAAY;CACd;AACF;AAEA,IAAM,kBAAkB,OAAO,QAAQ,iBAAiB;AACxD,IAAM,sBAAsB,OAAO,MAAM,eAAe;AAExD,IAAM,oBAAoB,OAAO,UAAU,mBAAmB;CAC5D,aAAa;EACX,WAAW;EACX,SAAS;EACT,UAAU;EACV,OAAO;EACP,cAAc;CAChB;CACA,mBAAmB,EACjB,SAAS,qBACX;CACA,WAAW;EACT,QAAQ;EACR,aAAa,EACX,iBAAiB,mCACnB;CACF;CACA,YAAY,EACV,aAAa,EACX,iBAAiB,oCACnB,EACF;CAEA,UAAU;EACR,SAAS;EACT,YAAY,EACV,MAAM,EACJ,QAAQ,OACV,EACF;CACF;AACF,CAAC;AACD,IAAM,wBAAwB,OAAO,MAAM,iBAAiB;AAQ5D,IAAa,QAAQ,MAAM,YACxB,EAAE,aAAa,SAAS,GAAG,SAAS,iBAAiB;CASpD,OAAO,oBARW,cACd,UACE,wBACA,oBACF,UACE,sBACA,iBAEC;EAAW,GAAI;EAAO,KAAK;CAAe,CAAA;AACnD,CACF"}
|
|
@@ -227,8 +227,7 @@ var StyledButton = require_stitches_config.styled("button", BUTTON_BASE_STYLES,
|
|
|
227
227
|
});
|
|
228
228
|
var StyledButtonSlot = require_stitches_config.styled(_radix_ui_react_slot.Slot, StyledButton);
|
|
229
229
|
var Button = react.default.forwardRef(({ children, asChild, ...props }, forwardedRef) => {
|
|
230
|
-
|
|
231
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Component, {
|
|
230
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(asChild ? StyledButtonSlot : StyledButton, {
|
|
232
231
|
ref: forwardedRef,
|
|
233
232
|
...props,
|
|
234
233
|
children
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.cjs","names":["keyframes","styled","Slot","React","useMemo"],"sources":["../../../components/Button/Button.tsx"],"sourcesContent":["import { Slot } from '@radix-ui/react-slot';\nimport React, { ComponentProps, useMemo } from 'react';\n\nimport { CSS, keyframes, styled, VariantProps } from '../../stitches.config';\n\nexport const BUTTON_BASE_STYLES = {\n appearance: 'none',\n userSelect: 'none',\n boxSizing: 'border-box',\n border: 'none',\n WebkitTapHighlightColor: 'rgba(0,0,0,0)',\n '&:disabled': {\n pointerEvents: 'none',\n opacity: 0.5,\n },\n};\n\nconst BG_SIZES = {\n small: '$sizes$8',\n medium: '$sizes$9',\n large: '$sizes$10',\n};\n\nconst backgroundSizeAnimation = (size: keyof typeof BG_SIZES) => ({\n $$bgSize: BG_SIZES[size],\n backgroundSize: '$$bgSize',\n backgroundImage: `linear-gradient(\n -45deg,\n transparent 33%,\n $colors$deepBlue4 33%,\n $colors$deepBlue4 66%,\n transparent 66%\n )`,\n animation: `${keyframes({\n '100%': { transform: 'translateX($$bgSize)' },\n })} 500ms linear infinite`,\n});\n\nexport const StyledButton = styled('button', BUTTON_BASE_STYLES, {\n // Reset\n all: 'unset',\n alignItems: 'center',\n overflow: 'hidden',\n\n '&::before': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n inset: 0,\n },\n '&::after': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n inset: 0,\n },\n\n // Custom reset?\n display: 'inline-flex',\n flexShrink: 0,\n justifyContent: 'center',\n lineHeight: '1',\n\n // Custom\n position: 'relative',\n height: '$5',\n px: '$2',\n fontFamily: '$rubik',\n fontSize: '$3',\n fontWeight: '$medium',\n fontVariantNumeric: 'tabular-nums',\n\n '&:focus-visible': {\n boxShadow: `inset 0 0 0 2px $colors$focusOutline`,\n '&::before': {\n backgroundColor: 'rgba(255, 255, 255, 0.15)',\n },\n '&::after': {\n opacity: 0.15,\n },\n },\n\n '@hover': {\n '&:hover': {\n cursor: 'pointer',\n '&::before': {\n backgroundColor: 'rgba(255, 255, 255, 0.15)',\n },\n '&::after': {\n opacity: 0.05,\n },\n },\n },\n\n '&:active': {\n '&::before': {\n backgroundColor: 'rgba(0, 0, 0, 0.15)',\n },\n },\n\n variants: {\n size: {\n small: {\n borderRadius: '$button',\n height: '$5',\n px: '$2',\n fontSize: '$1',\n lineHeight: '$sizes$5',\n },\n medium: {\n borderRadius: '$button',\n height: '$6',\n px: '$3',\n fontSize: '$3',\n lineHeight: '$sizes$6',\n },\n large: {\n borderRadius: '$button',\n height: '$7',\n px: '$3',\n fontSize: '$3',\n lineHeight: '$sizes$7',\n },\n },\n variant: {\n primary: {\n bc: '$buttonPrimaryBg',\n c: '$buttonPrimaryText',\n '&:focus-visible': {\n boxShadow: 'inset 0 0 0 2px $colors$buttonPrimaryFocusBorder',\n },\n '@hover': {\n '&:hover': {\n '&::after': {\n backgroundColor: '$buttonPrimaryBg',\n },\n },\n },\n },\n secondary: {\n bc: '$buttonSecondaryBg',\n c: '$buttonSecondaryText',\n boxShadow: 'inset 0 0 0 2px $colors$buttonSecondaryBorder',\n '&:active': {\n boxShadow: 'inset 0 0 0 1px $colors$buttonSecondaryBorder',\n },\n '&:focus-visible': {\n boxShadow: 'inset 0 0 0 2px $colors$buttonSecondaryFocusBorder',\n },\n '@hover': {\n '&:hover': {\n '&::after': {\n backgroundColor: '$buttonPrimaryBg',\n },\n },\n },\n },\n red: {\n backgroundColor: '$buttonRedBg',\n color: '$buttonRedText',\n '&:focus-visible': {\n boxShadow: 'inset 0 0 0 2px $colors$buttonRedFocusBg',\n },\n },\n },\n state: {\n active: {\n bc: '$deepBlue5',\n c: '$deepBlue11',\n '&:active': {\n backgroundColor: '$deepBlue5',\n },\n },\n waiting: {\n bc: '$deepBlue3',\n boxShadow: `inset 0 0 0 1px $deepBlue4`,\n c: 'transparent',\n overflow: 'hidden',\n pointerEvents: 'none',\n '&::after': {\n left: '-100%',\n width: '200%',\n ...backgroundSizeAnimation('medium'),\n },\n },\n },\n ghost: {\n true: {\n boxShadow: 'none',\n '@hover': {\n '&:hover': {\n boxShadow: 'none',\n },\n },\n },\n },\n rounded: {\n true: {\n borderRadius: '$pill',\n },\n },\n },\n compoundVariants: [\n {\n variant: 'primary',\n ghost: 'true',\n css: {\n color: '$buttonPrimaryBg',\n backgroundColor: 'transparent',\n '@hover': {\n '&:hover': {\n color: '$buttonPrimaryGhostHoverText',\n backgroundColor: 'transparent',\n },\n },\n },\n },\n {\n variant: 'primary',\n state: 'active',\n css: {\n backgroundColor: '$buttonPrimaryFocusBg',\n color: '$buttonPrimaryText',\n boxShadow: 'inset 0 0 0 2px white',\n },\n },\n {\n variant: 'secondary',\n state: 'waiting',\n css: {\n backgroundColor: '$deepBlue3',\n color: 'transparent',\n },\n },\n {\n variant: 'secondary',\n ghost: true,\n css: {\n backgroundColor: 'transparent',\n color: '$buttonSecondaryText',\n boxShadow: 'none',\n },\n },\n {\n variant: 'red',\n state: 'waiting',\n css: {\n backgroundColor: '$deepBlue3',\n color: 'transparent',\n },\n },\n {\n variant: 'red',\n state: 'active',\n css: {\n backgroundColor: '$buttonRedFocusBg',\n color: '$buttonRedText',\n boxShadow: 'inset 0 0 0 2px white',\n },\n },\n {\n variant: 'red',\n ghost: 'true',\n css: {\n color: '$buttonRedBg',\n backgroundColor: 'transparent',\n '@hover': {\n '&:hover': {\n color: '$buttonRedHoverText',\n backgroundColor: 'transparent',\n },\n },\n },\n },\n {\n size: 'small',\n state: 'waiting',\n css: {\n '&::after': backgroundSizeAnimation('small'),\n },\n },\n {\n size: 'large',\n state: 'waiting',\n css: {\n '&::after': backgroundSizeAnimation('large'),\n },\n },\n ],\n defaultVariants: {\n size: 'medium',\n variant: 'primary',\n },\n});\nconst StyledButtonSlot = styled(Slot, StyledButton);\n\nexport interface ButtonVariants extends VariantProps<typeof StyledButton> {}\nexport type ButtonProps = ComponentProps<typeof StyledButton> &\n ButtonVariants & {\n css?: CSS;\n asChild?: boolean;\n as?: string;\n };\n\nexport const Button = React.forwardRef<React.ElementRef<typeof StyledButton>, ButtonProps>(\n ({ children, asChild, ...props }, forwardedRef) => {\n const Component = useMemo(() => (asChild ? StyledButtonSlot : StyledButton), [asChild]);\n return (\n <Component ref={forwardedRef} {...props}>\n {children}\n </Component>\n );\n },\n);\n"],"mappings":";;;;;;;AAKA,IAAa,qBAAqB;CAChC,YAAY;CACZ,YAAY;CACZ,WAAW;CACX,QAAQ;CACR,yBAAyB;CACzB,cAAc;EACZ,eAAe;EACf,SAAS;CACX;AACF;AAEA,IAAM,WAAW;CACf,OAAO;CACP,QAAQ;CACR,OAAO;AACT;AAEA,IAAM,2BAA2B,UAAiC;CAChE,UAAU,SAAS;CACnB,gBAAgB;CAChB,iBAAiB;;;;;;;CAOjB,WAAW,GAAGA,wBAAAA,UAAU,EACtB,QAAQ,EAAE,WAAW,uBAAuB,EAC9C,CAAC,EAAE;AACL;AAEA,IAAa,eAAeC,wBAAAA,OAAO,UAAU,oBAAoB;CAE/D,KAAK;CACL,YAAY;CACZ,UAAU;CAEV,aAAa;EACX,WAAW;EACX,SAAS;EACT,UAAU;EACV,OAAO;CACT;CACA,YAAY;EACV,WAAW;EACX,SAAS;EACT,UAAU;EACV,OAAO;CACT;CAGA,SAAS;CACT,YAAY;CACZ,gBAAgB;CAChB,YAAY;CAGZ,UAAU;CACV,QAAQ;CACR,IAAI;CACJ,YAAY;CACZ,UAAU;CACV,YAAY;CACZ,oBAAoB;CAEpB,mBAAmB;EACjB,WAAW;EACX,aAAa,EACX,iBAAiB,4BACnB;EACA,YAAY,EACV,SAAS,IACX;CACF;CAEA,UAAU,EACR,WAAW;EACT,QAAQ;EACR,aAAa,EACX,iBAAiB,4BACnB;EACA,YAAY,EACV,SAAS,IACX;CACF,EACF;CAEA,YAAY,EACV,aAAa,EACX,iBAAiB,sBACnB,EACF;CAEA,UAAU;EACR,MAAM;GACJ,OAAO;IACL,cAAc;IACd,QAAQ;IACR,IAAI;IACJ,UAAU;IACV,YAAY;GACd;GACA,QAAQ;IACN,cAAc;IACd,QAAQ;IACR,IAAI;IACJ,UAAU;IACV,YAAY;GACd;GACA,OAAO;IACL,cAAc;IACd,QAAQ;IACR,IAAI;IACJ,UAAU;IACV,YAAY;GACd;EACF;EACA,SAAS;GACP,SAAS;IACP,IAAI;IACJ,GAAG;IACH,mBAAmB,EACjB,WAAW,mDACb;IACA,UAAU,EACR,WAAW,EACT,YAAY,EACV,iBAAiB,mBACnB,EACF,EACF;GACF;GACA,WAAW;IACT,IAAI;IACJ,GAAG;IACH,WAAW;IACX,YAAY,EACV,WAAW,gDACb;IACA,mBAAmB,EACjB,WAAW,qDACb;IACA,UAAU,EACR,WAAW,EACT,YAAY,EACV,iBAAiB,mBACnB,EACF,EACF;GACF;GACA,KAAK;IACH,iBAAiB;IACjB,OAAO;IACP,mBAAmB,EACjB,WAAW,2CACb;GACF;EACF;EACA,OAAO;GACL,QAAQ;IACN,IAAI;IACJ,GAAG;IACH,YAAY,EACV,iBAAiB,aACnB;GACF;GACA,SAAS;IACP,IAAI;IACJ,WAAW;IACX,GAAG;IACH,UAAU;IACV,eAAe;IACf,YAAY;KACV,MAAM;KACN,OAAO;KACP,GAAG,wBAAwB,QAAQ;IACrC;GACF;EACF;EACA,OAAO,EACL,MAAM;GACJ,WAAW;GACX,UAAU,EACR,WAAW,EACT,WAAW,OACb,EACF;EACF,EACF;EACA,SAAS,EACP,MAAM,EACJ,cAAc,QAChB,EACF;CACF;CACA,kBAAkB;EAChB;GACE,SAAS;GACT,OAAO;GACP,KAAK;IACH,OAAO;IACP,iBAAiB;IACjB,UAAU,EACR,WAAW;KACT,OAAO;KACP,iBAAiB;IACnB,EACF;GACF;EACF;EACA;GACE,SAAS;GACT,OAAO;GACP,KAAK;IACH,iBAAiB;IACjB,OAAO;IACP,WAAW;GACb;EACF;EACA;GACE,SAAS;GACT,OAAO;GACP,KAAK;IACH,iBAAiB;IACjB,OAAO;GACT;EACF;EACA;GACE,SAAS;GACT,OAAO;GACP,KAAK;IACH,iBAAiB;IACjB,OAAO;IACP,WAAW;GACb;EACF;EACA;GACE,SAAS;GACT,OAAO;GACP,KAAK;IACH,iBAAiB;IACjB,OAAO;GACT;EACF;EACA;GACE,SAAS;GACT,OAAO;GACP,KAAK;IACH,iBAAiB;IACjB,OAAO;IACP,WAAW;GACb;EACF;EACA;GACE,SAAS;GACT,OAAO;GACP,KAAK;IACH,OAAO;IACP,iBAAiB;IACjB,UAAU,EACR,WAAW;KACT,OAAO;KACP,iBAAiB;IACnB,EACF;GACF;EACF;EACA;GACE,MAAM;GACN,OAAO;GACP,KAAK,EACH,YAAY,wBAAwB,OAAO,EAC7C;EACF;EACA;GACE,MAAM;GACN,OAAO;GACP,KAAK,EACH,YAAY,wBAAwB,OAAO,EAC7C;EACF;CACF;CACA,iBAAiB;EACf,MAAM;EACN,SAAS;CACX;AACF,CAAC;AACD,IAAM,mBAAmBA,wBAAAA,OAAOC,qBAAAA,MAAM,YAAY;AAUlD,IAAa,SAASC,MAAAA,QAAM,YACzB,EAAE,UAAU,SAAS,GAAG,SAAS,iBAAiB;CACjD,MAAM,aAAA,GAAYC,MAAAA,QAAAA,OAAe,UAAU,mBAAmB,cAAe,CAAC,OAAO,CAAC;CACtF,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,WAAD;EAAW,KAAK;EAAc,GAAI;EAC/B;CACQ,CAAA;AAEf,CACF"}
|
|
1
|
+
{"version":3,"file":"Button.cjs","names":["keyframes","styled","Slot","React"],"sources":["../../../components/Button/Button.tsx"],"sourcesContent":["import { Slot } from '@radix-ui/react-slot';\nimport React, { ComponentProps } from 'react';\n\nimport { CSS, keyframes, styled, VariantProps } from '../../stitches.config';\n\nexport const BUTTON_BASE_STYLES = {\n appearance: 'none',\n userSelect: 'none',\n boxSizing: 'border-box',\n border: 'none',\n WebkitTapHighlightColor: 'rgba(0,0,0,0)',\n '&:disabled': {\n pointerEvents: 'none',\n opacity: 0.5,\n },\n};\n\nconst BG_SIZES = {\n small: '$sizes$8',\n medium: '$sizes$9',\n large: '$sizes$10',\n};\n\nconst backgroundSizeAnimation = (size: keyof typeof BG_SIZES) => ({\n $$bgSize: BG_SIZES[size],\n backgroundSize: '$$bgSize',\n backgroundImage: `linear-gradient(\n -45deg,\n transparent 33%,\n $colors$deepBlue4 33%,\n $colors$deepBlue4 66%,\n transparent 66%\n )`,\n animation: `${keyframes({\n '100%': { transform: 'translateX($$bgSize)' },\n })} 500ms linear infinite`,\n});\n\nexport const StyledButton = styled('button', BUTTON_BASE_STYLES, {\n // Reset\n all: 'unset',\n alignItems: 'center',\n overflow: 'hidden',\n\n '&::before': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n inset: 0,\n },\n '&::after': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n inset: 0,\n },\n\n // Custom reset?\n display: 'inline-flex',\n flexShrink: 0,\n justifyContent: 'center',\n lineHeight: '1',\n\n // Custom\n position: 'relative',\n height: '$5',\n px: '$2',\n fontFamily: '$rubik',\n fontSize: '$3',\n fontWeight: '$medium',\n fontVariantNumeric: 'tabular-nums',\n\n '&:focus-visible': {\n boxShadow: `inset 0 0 0 2px $colors$focusOutline`,\n '&::before': {\n backgroundColor: 'rgba(255, 255, 255, 0.15)',\n },\n '&::after': {\n opacity: 0.15,\n },\n },\n\n '@hover': {\n '&:hover': {\n cursor: 'pointer',\n '&::before': {\n backgroundColor: 'rgba(255, 255, 255, 0.15)',\n },\n '&::after': {\n opacity: 0.05,\n },\n },\n },\n\n '&:active': {\n '&::before': {\n backgroundColor: 'rgba(0, 0, 0, 0.15)',\n },\n },\n\n variants: {\n size: {\n small: {\n borderRadius: '$button',\n height: '$5',\n px: '$2',\n fontSize: '$1',\n lineHeight: '$sizes$5',\n },\n medium: {\n borderRadius: '$button',\n height: '$6',\n px: '$3',\n fontSize: '$3',\n lineHeight: '$sizes$6',\n },\n large: {\n borderRadius: '$button',\n height: '$7',\n px: '$3',\n fontSize: '$3',\n lineHeight: '$sizes$7',\n },\n },\n variant: {\n primary: {\n bc: '$buttonPrimaryBg',\n c: '$buttonPrimaryText',\n '&:focus-visible': {\n boxShadow: 'inset 0 0 0 2px $colors$buttonPrimaryFocusBorder',\n },\n '@hover': {\n '&:hover': {\n '&::after': {\n backgroundColor: '$buttonPrimaryBg',\n },\n },\n },\n },\n secondary: {\n bc: '$buttonSecondaryBg',\n c: '$buttonSecondaryText',\n boxShadow: 'inset 0 0 0 2px $colors$buttonSecondaryBorder',\n '&:active': {\n boxShadow: 'inset 0 0 0 1px $colors$buttonSecondaryBorder',\n },\n '&:focus-visible': {\n boxShadow: 'inset 0 0 0 2px $colors$buttonSecondaryFocusBorder',\n },\n '@hover': {\n '&:hover': {\n '&::after': {\n backgroundColor: '$buttonPrimaryBg',\n },\n },\n },\n },\n red: {\n backgroundColor: '$buttonRedBg',\n color: '$buttonRedText',\n '&:focus-visible': {\n boxShadow: 'inset 0 0 0 2px $colors$buttonRedFocusBg',\n },\n },\n },\n state: {\n active: {\n bc: '$deepBlue5',\n c: '$deepBlue11',\n '&:active': {\n backgroundColor: '$deepBlue5',\n },\n },\n waiting: {\n bc: '$deepBlue3',\n boxShadow: `inset 0 0 0 1px $deepBlue4`,\n c: 'transparent',\n overflow: 'hidden',\n pointerEvents: 'none',\n '&::after': {\n left: '-100%',\n width: '200%',\n ...backgroundSizeAnimation('medium'),\n },\n },\n },\n ghost: {\n true: {\n boxShadow: 'none',\n '@hover': {\n '&:hover': {\n boxShadow: 'none',\n },\n },\n },\n },\n rounded: {\n true: {\n borderRadius: '$pill',\n },\n },\n },\n compoundVariants: [\n {\n variant: 'primary',\n ghost: 'true',\n css: {\n color: '$buttonPrimaryBg',\n backgroundColor: 'transparent',\n '@hover': {\n '&:hover': {\n color: '$buttonPrimaryGhostHoverText',\n backgroundColor: 'transparent',\n },\n },\n },\n },\n {\n variant: 'primary',\n state: 'active',\n css: {\n backgroundColor: '$buttonPrimaryFocusBg',\n color: '$buttonPrimaryText',\n boxShadow: 'inset 0 0 0 2px white',\n },\n },\n {\n variant: 'secondary',\n state: 'waiting',\n css: {\n backgroundColor: '$deepBlue3',\n color: 'transparent',\n },\n },\n {\n variant: 'secondary',\n ghost: true,\n css: {\n backgroundColor: 'transparent',\n color: '$buttonSecondaryText',\n boxShadow: 'none',\n },\n },\n {\n variant: 'red',\n state: 'waiting',\n css: {\n backgroundColor: '$deepBlue3',\n color: 'transparent',\n },\n },\n {\n variant: 'red',\n state: 'active',\n css: {\n backgroundColor: '$buttonRedFocusBg',\n color: '$buttonRedText',\n boxShadow: 'inset 0 0 0 2px white',\n },\n },\n {\n variant: 'red',\n ghost: 'true',\n css: {\n color: '$buttonRedBg',\n backgroundColor: 'transparent',\n '@hover': {\n '&:hover': {\n color: '$buttonRedHoverText',\n backgroundColor: 'transparent',\n },\n },\n },\n },\n {\n size: 'small',\n state: 'waiting',\n css: {\n '&::after': backgroundSizeAnimation('small'),\n },\n },\n {\n size: 'large',\n state: 'waiting',\n css: {\n '&::after': backgroundSizeAnimation('large'),\n },\n },\n ],\n defaultVariants: {\n size: 'medium',\n variant: 'primary',\n },\n});\nconst StyledButtonSlot = styled(Slot, StyledButton);\n\nexport interface ButtonVariants extends VariantProps<typeof StyledButton> {}\nexport type ButtonProps = ComponentProps<typeof StyledButton> &\n ButtonVariants & {\n css?: CSS;\n asChild?: boolean;\n as?: string;\n };\n\nexport const Button = React.forwardRef<React.ElementRef<typeof StyledButton>, ButtonProps>(\n ({ children, asChild, ...props }, forwardedRef) => {\n const Component = asChild ? StyledButtonSlot : StyledButton;\n return (\n <Component ref={forwardedRef} {...props}>\n {children}\n </Component>\n );\n },\n);\n"],"mappings":";;;;;;;AAKA,IAAa,qBAAqB;CAChC,YAAY;CACZ,YAAY;CACZ,WAAW;CACX,QAAQ;CACR,yBAAyB;CACzB,cAAc;EACZ,eAAe;EACf,SAAS;CACX;AACF;AAEA,IAAM,WAAW;CACf,OAAO;CACP,QAAQ;CACR,OAAO;AACT;AAEA,IAAM,2BAA2B,UAAiC;CAChE,UAAU,SAAS;CACnB,gBAAgB;CAChB,iBAAiB;;;;;;;CAOjB,WAAW,G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,iBAAiB;IACjB,OAAO;IACP,mBAAmB,EACjB,WAAW,2CACb;GACF;EACF;EACA,OAAO;GACL,QAAQ;IACN,IAAI;IACJ,GAAG;IACH,YAAY,EACV,iBAAiB,aACnB;GACF;GACA,SAAS;IACP,IAAI;IACJ,WAAW;IACX,GAAG;IACH,UAAU;IACV,eAAe;IACf,YAAY;KACV,MAAM;KACN,OAAO;KACP,GAAG,wBAAwB,QAAQ;IACrC;GACF;EACF;EACA,OAAO,EACL,MAAM;GACJ,WAAW;GACX,UAAU,EACR,WAAW,EACT,WAAW,OACb,EACF;EACF,EACF;EACA,SAAS,EACP,MAAM,EACJ,cAAc,QAChB,EACF;CACF;CACA,kBAAkB;EAChB;GACE,SAAS;GACT,OAAO;GACP,KAAK;IACH,OAAO;IACP,iBAAiB;IACjB,UAAU,EACR,WAAW;KACT,OAAO;KACP,iBAAiB;IACnB,EACF;GACF;EACF;EACA;GACE,SAAS;GACT,OAAO;GACP,KAAK;IACH,iBAAiB;IACjB,OAAO;IACP,WAAW;GACb;EACF;EACA;GACE,SAAS;GACT,OAAO;GACP,KAAK;IACH,iBAAiB;IACjB,OAAO;GACT;EACF;EACA;GACE,SAAS;GACT,OAAO;GACP,KAAK;IACH,iBAAiB;IACjB,OAAO;IACP,WAAW;GACb;EACF;EACA;GACE,SAAS;GACT,OAAO;GACP,KAAK;IACH,iBAAiB;IACjB,OAAO;GACT;EACF;EACA;GACE,SAAS;GACT,OAAO;GACP,KAAK;IACH,iBAAiB;IACjB,OAAO;IACP,WAAW;GACb;EACF;EACA;GACE,SAAS;GACT,OAAO;GACP,KAAK;IACH,OAAO;IACP,iBAAiB;IACjB,UAAU,EACR,WAAW;KACT,OAAO;KACP,iBAAiB;IACnB,EACF;GACF;EACF;EACA;GACE,MAAM;GACN,OAAO;GACP,KAAK,EACH,YAAY,wBAAwB,OAAO,EAC7C;EACF;EACA;GACE,MAAM;GACN,OAAO;GACP,KAAK,EACH,YAAY,wBAAwB,OAAO,EAC7C;EACF;CACF;CACA,iBAAiB;EACf,MAAM;EACN,SAAS;CACX;AACF,CAAC;AACD,IAAM,mBAAmBA,wBAAAA,OAAOC,qBAAAA,MAAM,YAAY;AAUlD,IAAa,SAASC,MAAAA,QAAM,YACzB,EAAE,UAAU,SAAS,GAAG,SAAS,iBAAiB;CAEjD,OACE,iBAAA,GAAA,kBAAA,IAAA,CAFgB,UAAU,mBAAmB,cAE7C;EAAW,KAAK;EAAc,GAAI;EAC/B;CACQ,CAAA;AAEf,CACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { keyframes, styled } from "../../stitches.config.js";
|
|
2
|
-
import React
|
|
2
|
+
import React from "react";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
import { Slot } from "@radix-ui/react-slot";
|
|
5
5
|
// components/Button/Button.tsx
|
|
@@ -225,8 +225,7 @@ var StyledButton = styled("button", BUTTON_BASE_STYLES, {
|
|
|
225
225
|
});
|
|
226
226
|
var StyledButtonSlot = styled(Slot, StyledButton);
|
|
227
227
|
var Button = React.forwardRef(({ children, asChild, ...props }, forwardedRef) => {
|
|
228
|
-
|
|
229
|
-
return /* @__PURE__ */ jsx(Component, {
|
|
228
|
+
return /* @__PURE__ */ jsx(asChild ? StyledButtonSlot : StyledButton, {
|
|
230
229
|
ref: forwardedRef,
|
|
231
230
|
...props,
|
|
232
231
|
children
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","names":[],"sources":["../../../components/Button/Button.tsx"],"sourcesContent":["import { Slot } from '@radix-ui/react-slot';\nimport React, { ComponentProps, useMemo } from 'react';\n\nimport { CSS, keyframes, styled, VariantProps } from '../../stitches.config';\n\nexport const BUTTON_BASE_STYLES = {\n appearance: 'none',\n userSelect: 'none',\n boxSizing: 'border-box',\n border: 'none',\n WebkitTapHighlightColor: 'rgba(0,0,0,0)',\n '&:disabled': {\n pointerEvents: 'none',\n opacity: 0.5,\n },\n};\n\nconst BG_SIZES = {\n small: '$sizes$8',\n medium: '$sizes$9',\n large: '$sizes$10',\n};\n\nconst backgroundSizeAnimation = (size: keyof typeof BG_SIZES) => ({\n $$bgSize: BG_SIZES[size],\n backgroundSize: '$$bgSize',\n backgroundImage: `linear-gradient(\n -45deg,\n transparent 33%,\n $colors$deepBlue4 33%,\n $colors$deepBlue4 66%,\n transparent 66%\n )`,\n animation: `${keyframes({\n '100%': { transform: 'translateX($$bgSize)' },\n })} 500ms linear infinite`,\n});\n\nexport const StyledButton = styled('button', BUTTON_BASE_STYLES, {\n // Reset\n all: 'unset',\n alignItems: 'center',\n overflow: 'hidden',\n\n '&::before': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n inset: 0,\n },\n '&::after': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n inset: 0,\n },\n\n // Custom reset?\n display: 'inline-flex',\n flexShrink: 0,\n justifyContent: 'center',\n lineHeight: '1',\n\n // Custom\n position: 'relative',\n height: '$5',\n px: '$2',\n fontFamily: '$rubik',\n fontSize: '$3',\n fontWeight: '$medium',\n fontVariantNumeric: 'tabular-nums',\n\n '&:focus-visible': {\n boxShadow: `inset 0 0 0 2px $colors$focusOutline`,\n '&::before': {\n backgroundColor: 'rgba(255, 255, 255, 0.15)',\n },\n '&::after': {\n opacity: 0.15,\n },\n },\n\n '@hover': {\n '&:hover': {\n cursor: 'pointer',\n '&::before': {\n backgroundColor: 'rgba(255, 255, 255, 0.15)',\n },\n '&::after': {\n opacity: 0.05,\n },\n },\n },\n\n '&:active': {\n '&::before': {\n backgroundColor: 'rgba(0, 0, 0, 0.15)',\n },\n },\n\n variants: {\n size: {\n small: {\n borderRadius: '$button',\n height: '$5',\n px: '$2',\n fontSize: '$1',\n lineHeight: '$sizes$5',\n },\n medium: {\n borderRadius: '$button',\n height: '$6',\n px: '$3',\n fontSize: '$3',\n lineHeight: '$sizes$6',\n },\n large: {\n borderRadius: '$button',\n height: '$7',\n px: '$3',\n fontSize: '$3',\n lineHeight: '$sizes$7',\n },\n },\n variant: {\n primary: {\n bc: '$buttonPrimaryBg',\n c: '$buttonPrimaryText',\n '&:focus-visible': {\n boxShadow: 'inset 0 0 0 2px $colors$buttonPrimaryFocusBorder',\n },\n '@hover': {\n '&:hover': {\n '&::after': {\n backgroundColor: '$buttonPrimaryBg',\n },\n },\n },\n },\n secondary: {\n bc: '$buttonSecondaryBg',\n c: '$buttonSecondaryText',\n boxShadow: 'inset 0 0 0 2px $colors$buttonSecondaryBorder',\n '&:active': {\n boxShadow: 'inset 0 0 0 1px $colors$buttonSecondaryBorder',\n },\n '&:focus-visible': {\n boxShadow: 'inset 0 0 0 2px $colors$buttonSecondaryFocusBorder',\n },\n '@hover': {\n '&:hover': {\n '&::after': {\n backgroundColor: '$buttonPrimaryBg',\n },\n },\n },\n },\n red: {\n backgroundColor: '$buttonRedBg',\n color: '$buttonRedText',\n '&:focus-visible': {\n boxShadow: 'inset 0 0 0 2px $colors$buttonRedFocusBg',\n },\n },\n },\n state: {\n active: {\n bc: '$deepBlue5',\n c: '$deepBlue11',\n '&:active': {\n backgroundColor: '$deepBlue5',\n },\n },\n waiting: {\n bc: '$deepBlue3',\n boxShadow: `inset 0 0 0 1px $deepBlue4`,\n c: 'transparent',\n overflow: 'hidden',\n pointerEvents: 'none',\n '&::after': {\n left: '-100%',\n width: '200%',\n ...backgroundSizeAnimation('medium'),\n },\n },\n },\n ghost: {\n true: {\n boxShadow: 'none',\n '@hover': {\n '&:hover': {\n boxShadow: 'none',\n },\n },\n },\n },\n rounded: {\n true: {\n borderRadius: '$pill',\n },\n },\n },\n compoundVariants: [\n {\n variant: 'primary',\n ghost: 'true',\n css: {\n color: '$buttonPrimaryBg',\n backgroundColor: 'transparent',\n '@hover': {\n '&:hover': {\n color: '$buttonPrimaryGhostHoverText',\n backgroundColor: 'transparent',\n },\n },\n },\n },\n {\n variant: 'primary',\n state: 'active',\n css: {\n backgroundColor: '$buttonPrimaryFocusBg',\n color: '$buttonPrimaryText',\n boxShadow: 'inset 0 0 0 2px white',\n },\n },\n {\n variant: 'secondary',\n state: 'waiting',\n css: {\n backgroundColor: '$deepBlue3',\n color: 'transparent',\n },\n },\n {\n variant: 'secondary',\n ghost: true,\n css: {\n backgroundColor: 'transparent',\n color: '$buttonSecondaryText',\n boxShadow: 'none',\n },\n },\n {\n variant: 'red',\n state: 'waiting',\n css: {\n backgroundColor: '$deepBlue3',\n color: 'transparent',\n },\n },\n {\n variant: 'red',\n state: 'active',\n css: {\n backgroundColor: '$buttonRedFocusBg',\n color: '$buttonRedText',\n boxShadow: 'inset 0 0 0 2px white',\n },\n },\n {\n variant: 'red',\n ghost: 'true',\n css: {\n color: '$buttonRedBg',\n backgroundColor: 'transparent',\n '@hover': {\n '&:hover': {\n color: '$buttonRedHoverText',\n backgroundColor: 'transparent',\n },\n },\n },\n },\n {\n size: 'small',\n state: 'waiting',\n css: {\n '&::after': backgroundSizeAnimation('small'),\n },\n },\n {\n size: 'large',\n state: 'waiting',\n css: {\n '&::after': backgroundSizeAnimation('large'),\n },\n },\n ],\n defaultVariants: {\n size: 'medium',\n variant: 'primary',\n },\n});\nconst StyledButtonSlot = styled(Slot, StyledButton);\n\nexport interface ButtonVariants extends VariantProps<typeof StyledButton> {}\nexport type ButtonProps = ComponentProps<typeof StyledButton> &\n ButtonVariants & {\n css?: CSS;\n asChild?: boolean;\n as?: string;\n };\n\nexport const Button = React.forwardRef<React.ElementRef<typeof StyledButton>, ButtonProps>(\n ({ children, asChild, ...props }, forwardedRef) => {\n const Component = useMemo(() => (asChild ? StyledButtonSlot : StyledButton), [asChild]);\n return (\n <Component ref={forwardedRef} {...props}>\n {children}\n </Component>\n );\n },\n);\n"],"mappings":";;;;;AAKA,IAAa,qBAAqB;CAChC,YAAY;CACZ,YAAY;CACZ,WAAW;CACX,QAAQ;CACR,yBAAyB;CACzB,cAAc;EACZ,eAAe;EACf,SAAS;CACX;AACF;AAEA,IAAM,WAAW;CACf,OAAO;CACP,QAAQ;CACR,OAAO;AACT;A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AAU,EACR,WAAW,EACT,YAAY,EACV,iBAAiB,mBACnB,EACF,EACF;GACF;GACA,KAAK;IACH,iBAAiB;IACjB,OAAO;IACP,mBAAmB,EACjB,WAAW,2CACb;GACF;EACF;EACA,OAAO;GACL,QAAQ;IACN,IAAI;IACJ,GAAG;IACH,YAAY,EACV,iBAAiB,aACnB;GACF;GACA,SAAS;IACP,IAAI;IACJ,WAAW;IACX,GAAG;IACH,UAAU;IACV,eAAe;IACf,YAAY;KACV,MAAM;KACN,OAAO;KACP,GAAG,wBAAwB,QAAQ;IACrC;GACF;EACF;EACA,OAAO,EACL,MAAM;GACJ,WAAW;GACX,UAAU,EACR,WAAW,EACT,WAAW,OACb,EACF;EACF,EACF;EACA,SAAS,EACP,MAAM,EACJ,cAAc,QAChB,EACF;CACF;CACA,kBAAkB;EAChB;GACE,SAAS;GACT,OAAO;GACP,KAAK;IACH,OAAO;IACP,iBAAiB;IACjB,UAAU,EACR,WAAW;KACT,OAAO;KACP,iBAAiB;IACnB,EACF;GACF;EACF;EACA;GACE,SAAS;GACT,OAAO;GACP,KAAK;IACH,iBAAiB;IACjB,OAAO;IACP,WAAW;GACb;EACF;EACA;GACE,SAAS;GACT,OAAO;GACP,KAAK;IACH,iBAAiB;IACjB,OAAO;GACT;EACF;EACA;GACE,SAAS;GACT,OAAO;GACP,KAAK;IACH,iBAAiB;IACjB,OAAO;IACP,WAAW;GACb;EACF;EACA;GACE,SAAS;GACT,OAAO;GACP,KAAK;IACH,iBAAiB;IACjB,OAAO;GACT;EACF;EACA;GACE,SAAS;GACT,OAAO;GACP,KAAK;IACH,iBAAiB;IACjB,OAAO;IACP,WAAW;GACb;EACF;EACA;GACE,SAAS;GACT,OAAO;GACP,KAAK;IACH,OAAO;IACP,iBAAiB;IACjB,UAAU,EACR,WAAW;KACT,OAAO;KACP,iBAAiB;IACnB,EACF;GACF;EACF;EACA;GACE,MAAM;GACN,OAAO;GACP,KAAK,EACH,YAAY,wBAAwB,OAAO,EAC7C;EACF;EACA;GACE,MAAM;GACN,OAAO;GACP,KAAK,EACH,YAAY,wBAAwB,OAAO,EAC7C;EACF;CACF;CACA,iBAAiB;EACf,MAAM;EACN,SAAS;CACX;AACF,CAAC;AACD,IAAM,mBAAmB,OAAO,MAAM,YAAY;AAUlD,IAAa,SAAS,MAAM,YACzB,EAAE,UAAU,SAAS,GAAG,SAAS,iBAAiB;CACjD,MAAM,YAAY,cAAe,UAAU,mBAAmB,cAAe,CAAC,OAAO,CAAC;CACtF,OACE,oBAAC,WAAD;EAAW,KAAK;EAAc,GAAI;EAC/B;CACQ,CAAA;AAEf,CACF"}
|
|
1
|
+
{"version":3,"file":"Button.js","names":[],"sources":["../../../components/Button/Button.tsx"],"sourcesContent":["import { Slot } from '@radix-ui/react-slot';\nimport React, { ComponentProps } from 'react';\n\nimport { CSS, keyframes, styled, VariantProps } from '../../stitches.config';\n\nexport const BUTTON_BASE_STYLES = {\n appearance: 'none',\n userSelect: 'none',\n boxSizing: 'border-box',\n border: 'none',\n WebkitTapHighlightColor: 'rgba(0,0,0,0)',\n '&:disabled': {\n pointerEvents: 'none',\n opacity: 0.5,\n },\n};\n\nconst BG_SIZES = {\n small: '$sizes$8',\n medium: '$sizes$9',\n large: '$sizes$10',\n};\n\nconst backgroundSizeAnimation = (size: keyof typeof BG_SIZES) => ({\n $$bgSize: BG_SIZES[size],\n backgroundSize: '$$bgSize',\n backgroundImage: `linear-gradient(\n -45deg,\n transparent 33%,\n $colors$deepBlue4 33%,\n $colors$deepBlue4 66%,\n transparent 66%\n )`,\n animation: `${keyframes({\n '100%': { transform: 'translateX($$bgSize)' },\n })} 500ms linear infinite`,\n});\n\nexport const StyledButton = styled('button', BUTTON_BASE_STYLES, {\n // Reset\n all: 'unset',\n alignItems: 'center',\n overflow: 'hidden',\n\n '&::before': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n inset: 0,\n },\n '&::after': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n inset: 0,\n },\n\n // Custom reset?\n display: 'inline-flex',\n flexShrink: 0,\n justifyContent: 'center',\n lineHeight: '1',\n\n // Custom\n position: 'relative',\n height: '$5',\n px: '$2',\n fontFamily: '$rubik',\n fontSize: '$3',\n fontWeight: '$medium',\n fontVariantNumeric: 'tabular-nums',\n\n '&:focus-visible': {\n boxShadow: `inset 0 0 0 2px $colors$focusOutline`,\n '&::before': {\n backgroundColor: 'rgba(255, 255, 255, 0.15)',\n },\n '&::after': {\n opacity: 0.15,\n },\n },\n\n '@hover': {\n '&:hover': {\n cursor: 'pointer',\n '&::before': {\n backgroundColor: 'rgba(255, 255, 255, 0.15)',\n },\n '&::after': {\n opacity: 0.05,\n },\n },\n },\n\n '&:active': {\n '&::before': {\n backgroundColor: 'rgba(0, 0, 0, 0.15)',\n },\n },\n\n variants: {\n size: {\n small: {\n borderRadius: '$button',\n height: '$5',\n px: '$2',\n fontSize: '$1',\n lineHeight: '$sizes$5',\n },\n medium: {\n borderRadius: '$button',\n height: '$6',\n px: '$3',\n fontSize: '$3',\n lineHeight: '$sizes$6',\n },\n large: {\n borderRadius: '$button',\n height: '$7',\n px: '$3',\n fontSize: '$3',\n lineHeight: '$sizes$7',\n },\n },\n variant: {\n primary: {\n bc: '$buttonPrimaryBg',\n c: '$buttonPrimaryText',\n '&:focus-visible': {\n boxShadow: 'inset 0 0 0 2px $colors$buttonPrimaryFocusBorder',\n },\n '@hover': {\n '&:hover': {\n '&::after': {\n backgroundColor: '$buttonPrimaryBg',\n },\n },\n },\n },\n secondary: {\n bc: '$buttonSecondaryBg',\n c: '$buttonSecondaryText',\n boxShadow: 'inset 0 0 0 2px $colors$buttonSecondaryBorder',\n '&:active': {\n boxShadow: 'inset 0 0 0 1px $colors$buttonSecondaryBorder',\n },\n '&:focus-visible': {\n boxShadow: 'inset 0 0 0 2px $colors$buttonSecondaryFocusBorder',\n },\n '@hover': {\n '&:hover': {\n '&::after': {\n backgroundColor: '$buttonPrimaryBg',\n },\n },\n },\n },\n red: {\n backgroundColor: '$buttonRedBg',\n color: '$buttonRedText',\n '&:focus-visible': {\n boxShadow: 'inset 0 0 0 2px $colors$buttonRedFocusBg',\n },\n },\n },\n state: {\n active: {\n bc: '$deepBlue5',\n c: '$deepBlue11',\n '&:active': {\n backgroundColor: '$deepBlue5',\n },\n },\n waiting: {\n bc: '$deepBlue3',\n boxShadow: `inset 0 0 0 1px $deepBlue4`,\n c: 'transparent',\n overflow: 'hidden',\n pointerEvents: 'none',\n '&::after': {\n left: '-100%',\n width: '200%',\n ...backgroundSizeAnimation('medium'),\n },\n },\n },\n ghost: {\n true: {\n boxShadow: 'none',\n '@hover': {\n '&:hover': {\n boxShadow: 'none',\n },\n },\n },\n },\n rounded: {\n true: {\n borderRadius: '$pill',\n },\n },\n },\n compoundVariants: [\n {\n variant: 'primary',\n ghost: 'true',\n css: {\n color: '$buttonPrimaryBg',\n backgroundColor: 'transparent',\n '@hover': {\n '&:hover': {\n color: '$buttonPrimaryGhostHoverText',\n backgroundColor: 'transparent',\n },\n },\n },\n },\n {\n variant: 'primary',\n state: 'active',\n css: {\n backgroundColor: '$buttonPrimaryFocusBg',\n color: '$buttonPrimaryText',\n boxShadow: 'inset 0 0 0 2px white',\n },\n },\n {\n variant: 'secondary',\n state: 'waiting',\n css: {\n backgroundColor: '$deepBlue3',\n color: 'transparent',\n },\n },\n {\n variant: 'secondary',\n ghost: true,\n css: {\n backgroundColor: 'transparent',\n color: '$buttonSecondaryText',\n boxShadow: 'none',\n },\n },\n {\n variant: 'red',\n state: 'waiting',\n css: {\n backgroundColor: '$deepBlue3',\n color: 'transparent',\n },\n },\n {\n variant: 'red',\n state: 'active',\n css: {\n backgroundColor: '$buttonRedFocusBg',\n color: '$buttonRedText',\n boxShadow: 'inset 0 0 0 2px white',\n },\n },\n {\n variant: 'red',\n ghost: 'true',\n css: {\n color: '$buttonRedBg',\n backgroundColor: 'transparent',\n '@hover': {\n '&:hover': {\n color: '$buttonRedHoverText',\n backgroundColor: 'transparent',\n },\n },\n },\n },\n {\n size: 'small',\n state: 'waiting',\n css: {\n '&::after': backgroundSizeAnimation('small'),\n },\n },\n {\n size: 'large',\n state: 'waiting',\n css: {\n '&::after': backgroundSizeAnimation('large'),\n },\n },\n ],\n defaultVariants: {\n size: 'medium',\n variant: 'primary',\n },\n});\nconst StyledButtonSlot = styled(Slot, StyledButton);\n\nexport interface ButtonVariants extends VariantProps<typeof StyledButton> {}\nexport type ButtonProps = ComponentProps<typeof StyledButton> &\n ButtonVariants & {\n css?: CSS;\n asChild?: boolean;\n as?: string;\n };\n\nexport const Button = React.forwardRef<React.ElementRef<typeof StyledButton>, ButtonProps>(\n ({ children, asChild, ...props }, forwardedRef) => {\n const Component = asChild ? StyledButtonSlot : StyledButton;\n return (\n <Component ref={forwardedRef} {...props}>\n {children}\n </Component>\n );\n },\n);\n"],"mappings":";;;;;AAKA,IAAa,qBAAqB;CAChC,YAAY;CACZ,YAAY;CACZ,WAAW;CACX,QAAQ;CACR,yBAAyB;CACzB,cAAc;EACZ,eAAe;EACf,SAAS;CACX;AACF;AAEA,IAAM,WAAW;CACf,OAAO;CACP,QAAQ;CACR,OAAO;AACT;AAEA,IAAM,2BAA2B,UAAiC;CAChE,UAAU,SAAS;CACnB,gBAAgB;CAChB,iBAAiB;;;;;;;CAOjB,WAAW,GAAG,UAAU,EACtB,QAAQ,EAAE,WAAW,uBAAuB,EAC9C,CAAC,EAAE;AACL;AAEA,IAAa,eAAe,OAAO,UAAU,oBAAoB;CAE/D,KAAK;CACL,YAAY;CACZ,UAAU;CAEV,aAAa;EACX,WAAW;EACX,SAAS;EACT,UAAU;EACV,OAAO;CACT;CACA,YAAY;EACV,WAAW;EACX,SAAS;EACT,UAAU;EACV,OAAO;CACT;CAGA,SAAS;CACT,YAAY;CACZ,gBAAgB;CAChB,YAAY;CAGZ,UAAU;CACV,QAAQ;CACR,IAAI;CACJ,YAAY;CACZ,UAAU;CACV,YAAY;CACZ,oBAAoB;CAEpB,mBAAmB;EACjB,WAAW;EACX,aAAa,EACX,iBAAiB,4BACnB;EACA,YAAY,EACV,SAAS,IACX;CACF;CAEA,UAAU,EACR,WAAW;EACT,QAAQ;EACR,aAAa,EACX,iBAAiB,4BACnB;EACA,YAAY,EACV,SAAS,IACX;CACF,EACF;CAEA,YAAY,EACV,aAAa,EACX,iBAAiB,sBACnB,EACF;CAEA,UAAU;EACR,MAAM;GACJ,OAAO;IACL,cAAc;IACd,QAAQ;IACR,IAAI;IACJ,UAAU;IACV,YAAY;GACd;GACA,QAAQ;IACN,cAAc;IACd,QAAQ;IACR,IAAI;IACJ,UAAU;IACV,YAAY;GACd;GACA,OAAO;IACL,cAAc;IACd,QAAQ;IACR,IAAI;IACJ,UAAU;IACV,YAAY;GACd;EACF;EACA,SAAS;GACP,SAAS;IACP,IAAI;IACJ,GAAG;IACH,mBAAmB,EACjB,WAAW,mDACb;IACA,UAAU,EACR,WAAW,EACT,YAAY,EACV,iBAAiB,mBACnB,EACF,EACF;GACF;GACA,WAAW;IACT,IAAI;IACJ,GAAG;IACH,WAAW;IACX,YAAY,EACV,WAAW,gDACb;IACA,mBAAmB,EACjB,WAAW,qDACb;IACA,UAAU,EACR,WAAW,EACT,YAAY,EACV,iBAAiB,mBACnB,EACF,EACF;GACF;GACA,KAAK;IACH,iBAAiB;IACjB,OAAO;IACP,mBAAmB,EACjB,WAAW,2CACb;GACF;EACF;EACA,OAAO;GACL,QAAQ;IACN,IAAI;IACJ,GAAG;IACH,YAAY,EACV,iBAAiB,aACnB;GACF;GACA,SAAS;IACP,IAAI;IACJ,WAAW;IACX,GAAG;IACH,UAAU;IACV,eAAe;IACf,YAAY;KACV,MAAM;KACN,OAAO;KACP,GAAG,wBAAwB,QAAQ;IACrC;GACF;EACF;EACA,OAAO,EACL,MAAM;GACJ,WAAW;GACX,UAAU,EACR,WAAW,EACT,WAAW,OACb,EACF;EACF,EACF;EACA,SAAS,EACP,MAAM,EACJ,cAAc,QAChB,EACF;CACF;CACA,kBAAkB;EAChB;GACE,SAAS;GACT,OAAO;GACP,KAAK;IACH,OAAO;IACP,iBAAiB;IACjB,UAAU,EACR,WAAW;KACT,OAAO;KACP,iBAAiB;IACnB,EACF;GACF;EACF;EACA;GACE,SAAS;GACT,OAAO;GACP,KAAK;IACH,iBAAiB;IACjB,OAAO;IACP,WAAW;GACb;EACF;EACA;GACE,SAAS;GACT,OAAO;GACP,KAAK;IACH,iBAAiB;IACjB,OAAO;GACT;EACF;EACA;GACE,SAAS;GACT,OAAO;GACP,KAAK;IACH,iBAAiB;IACjB,OAAO;IACP,WAAW;GACb;EACF;EACA;GACE,SAAS;GACT,OAAO;GACP,KAAK;IACH,iBAAiB;IACjB,OAAO;GACT;EACF;EACA;GACE,SAAS;GACT,OAAO;GACP,KAAK;IACH,iBAAiB;IACjB,OAAO;IACP,WAAW;GACb;EACF;EACA;GACE,SAAS;GACT,OAAO;GACP,KAAK;IACH,OAAO;IACP,iBAAiB;IACjB,UAAU,EACR,WAAW;KACT,OAAO;KACP,iBAAiB;IACnB,EACF;GACF;EACF;EACA;GACE,MAAM;GACN,OAAO;GACP,KAAK,EACH,YAAY,wBAAwB,OAAO,EAC7C;EACF;EACA;GACE,MAAM;GACN,OAAO;GACP,KAAK,EACH,YAAY,wBAAwB,OAAO,EAC7C;EACF;CACF;CACA,iBAAiB;EACf,MAAM;EACN,SAAS;CACX;AACF,CAAC;AACD,IAAM,mBAAmB,OAAO,MAAM,YAAY;AAUlD,IAAa,SAAS,MAAM,YACzB,EAAE,UAAU,SAAS,GAAG,SAAS,iBAAiB;CAEjD,OACE,oBAFgB,UAAU,mBAAmB,cAE7C;EAAW,KAAK;EAAc,GAAI;EAC/B;CACQ,CAAA;AAEf,CACF"}
|
|
@@ -2,6 +2,7 @@ const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
|
2
2
|
const require_AccessibleIcon = require("../AccessibleIcon/AccessibleIcon.cjs");
|
|
3
3
|
const require_stitches_config = require("../../stitches.config.cjs");
|
|
4
4
|
const require_Box = require("../Box/Box.cjs");
|
|
5
|
+
const require_useIsomorphicLayoutEffect = require("../../utils/useIsomorphicLayoutEffect.cjs");
|
|
5
6
|
const require_Button = require("../Button/Button.cjs");
|
|
6
7
|
const require_colorSchemeContext = require("../colorSchemeContext.cjs");
|
|
7
8
|
require("./prism-extend.cjs");
|
|
@@ -57,7 +58,7 @@ var CodeBlock = (0, react.forwardRef)(({ lang = "text", code, copyable = false,
|
|
|
57
58
|
if (typeof ref === "function") ref(node);
|
|
58
59
|
else if (ref) ref.current = node;
|
|
59
60
|
}, [ref]);
|
|
60
|
-
|
|
61
|
+
require_useIsomorphicLayoutEffect.useIsomorphicLayoutEffect(() => {
|
|
61
62
|
if (!copyable) return;
|
|
62
63
|
const pre = preRef.current;
|
|
63
64
|
const wrapper = buttonWrapperRef.current;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlock.cjs","names":["styled","forwardRef","useColorScheme","themes","useState","useRef","useCallback","Button","AccessibleIcon","CheckIcon","CopyIcon","Highlight","Prism","Box"],"sources":["../../../components/CodeBlock/CodeBlock.tsx"],"sourcesContent":["import { CheckIcon, CopyIcon } from '@radix-ui/react-icons';\nimport { Highlight, Language, themes } from 'prism-react-renderer';\nimport React, {\n ComponentProps,\n forwardRef,\n useCallback,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { CSS, styled } from '../../stitches.config';\nimport { AccessibleIcon } from '../AccessibleIcon';\nimport { Box } from '../Box';\nimport { Button } from '../Button';\nimport { useColorScheme } from '../colorSchemeContext';\nimport type {\n CodeBlockCopyButtonAlign,\n CodeBlockCopyErrorHandler,\n CodeBlockLanguage,\n} from './index';\nimport { Prism } from './prism-extend';\n\nconst Pre = styled('pre', {\n m: 0,\n borderRadius: '$2',\n overflow: 'auto',\n border: '1px solid $colors$deepBlue3',\n fontSize: '$2',\n lineHeight: 1.6,\n\n variants: {\n noBorder: {\n true: { border: 'none' },\n },\n },\n});\n\nconst CopyButtonWrapper = styled('div', {\n position: 'absolute',\n zIndex: 1,\n variants: {\n position: {\n top: { top: '$2', right: '$3' },\n topLeft: { top: '$2', left: '$3' },\n bottomRight: { bottom: '$2', right: '$3' },\n bottomLeft: { bottom: '$2', left: '$3' },\n },\n },\n\n defaultVariants: {\n position: 'top',\n },\n});\n\nexport type CodeBlockProps = {\n lang?: CodeBlockLanguage;\n code: string;\n copyable?: boolean;\n copyText?: string;\n copiedText?: string;\n copyButtonAlign?: CodeBlockCopyButtonAlign;\n onCopy?: () => void;\n onCopyError?: CodeBlockCopyErrorHandler;\n noBorder?: boolean;\n wrapText?: boolean;\n colorScheme?: 'light' | 'dark';\n maxHeight?: number | string;\n css?: CSS;\n} & Omit<ComponentProps<typeof Pre>, 'css'>;\n\nexport const CodeBlock = forwardRef<HTMLPreElement, CodeBlockProps>(\n (\n {\n lang = 'text',\n code,\n copyable = false,\n copyText,\n copiedText,\n copyButtonAlign = 'top right',\n onCopy,\n onCopyError,\n noBorder,\n wrapText = false,\n colorScheme,\n maxHeight = 424,\n css,\n style,\n className,\n ...props\n },\n ref,\n ) => {\n const systemScheme = useColorScheme();\n const resolvedScheme = colorScheme ?? systemScheme;\n const prismTheme = resolvedScheme === 'dark' ? themes.nightOwl : themes.nightOwlLight;\n\n const isBottom = copyButtonAlign.includes('bottom');\n const isLeft = copyButtonAlign.includes('left');\n const buttonPosition = isBottom\n ? isLeft\n ? 'bottomLeft'\n : 'bottomRight'\n : isLeft\n ? 'topLeft'\n : 'top';\n\n const [copied, setCopied] = useState(false);\n\n const preRef = useRef<HTMLPreElement | null>(\n null,\n ) as React.MutableRefObject<HTMLPreElement | null>;\n const buttonWrapperRef = useRef<HTMLDivElement>(null);\n\n const setPreRef = useCallback(\n (node: HTMLPreElement | null) => {\n preRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) (ref as React.MutableRefObject<HTMLPreElement | null>).current = node;\n },\n [ref],\n );\n\n useLayoutEffect(() => {\n if (!copyable) return;\n const pre = preRef.current;\n const wrapper = buttonWrapperRef.current;\n if (!pre || !wrapper) return;\n\n const isBottomAlign = isBottom;\n const borderH = noBorder ? 0 : 2;\n\n const update = () => {\n if (!isLeft) {\n const vScrollbar = Math.max(0, pre.offsetWidth - pre.clientWidth - borderH);\n wrapper.style.right = `${16 + vScrollbar}px`;\n }\n if (isBottomAlign) {\n const hScrollbar = Math.max(0, pre.offsetHeight - pre.clientHeight - borderH);\n wrapper.style.bottom = `${8 + hScrollbar}px`;\n }\n };\n\n update();\n const observer = new ResizeObserver(update);\n observer.observe(pre);\n return () => observer.disconnect();\n }, [copyable, isBottom, isLeft, noBorder]);\n\n const handleCopy = async () => {\n try {\n try {\n await navigator.clipboard.writeText(code);\n } catch (error) {\n // clipboard write failed (e.g. permission denied) — leave UI unchanged unless a fallback handled it\n if ((await onCopyError?.(error, code)) !== true) return;\n }\n setCopied(true);\n onCopy?.();\n setTimeout(() => setCopied(false), 1500);\n } catch {\n // onCopyError or onCopy threw — leave UI unchanged\n }\n };\n\n const copyButton = copyable ? (\n <Button\n variant=\"secondary\"\n ghost\n size=\"small\"\n type=\"button\"\n onClick={handleCopy}\n css={{\n color: '$hiContrast',\n gap: '$1',\n backgroundColor: '$codeBlockCopyButtonBg',\n height: '32px',\n }}\n >\n <AccessibleIcon label={copied ? 'Copied' : 'Copy'}>\n {copied ? <CheckIcon /> : <CopyIcon />}\n </AccessibleIcon>\n {copied ? copiedText : copyText}\n </Button>\n ) : null;\n\n return (\n <Highlight\n theme={prismTheme}\n code={code}\n language={(Prism.languages[lang] != null ? lang : 'text') as Language}\n >\n {({\n className: highlightClass,\n style: highlightStyle,\n tokens,\n getLineProps,\n getTokenProps,\n }) => (\n <Box css={{ position: 'relative', ...css }}>\n <Pre\n ref={setPreRef}\n className={[highlightClass, className].filter(Boolean).join(' ')}\n style={{ maxHeight, ...highlightStyle, backgroundColor: 'inherit', ...style }}\n noBorder={noBorder}\n {...props}\n >\n <Box\n css={{\n p: '$4',\n ...(copyable && isLeft && isBottom ? { pb: '$7' } : {}),\n ...(copyable && isLeft && !isBottom ? { pt: '$7' } : {}),\n }}\n >\n {tokens.map((line, i) => (\n <div\n key={i}\n {...getLineProps({ line })}\n style={\n wrapText ? { whiteSpace: 'pre-wrap', wordBreak: 'break-all' } : undefined\n }\n >\n {line.map((token, key) => (\n <span key={key} {...getTokenProps({ token })} />\n ))}\n </div>\n ))}\n </Box>\n </Pre>\n {copyButton && (\n <CopyButtonWrapper ref={buttonWrapperRef} position={buttonPosition}>\n {copyButton}\n </CopyButtonWrapper>\n )}\n </Box>\n )}\n </Highlight>\n );\n },\n);\n\nCodeBlock.displayName = 'CodeBlock';\n"],"mappings":";;;;;;;;;;;;;AAuBA,IAAM,MAAMA,wBAAAA,OAAO,OAAO;CACxB,GAAG;CACH,cAAc;CACd,UAAU;CACV,QAAQ;CACR,UAAU;CACV,YAAY;CAEZ,UAAU,EACR,UAAU,EACR,MAAM,EAAE,QAAQ,OAAO,EACzB,EACF;AACF,CAAC;AAED,IAAM,oBAAoBA,wBAAAA,OAAO,OAAO;CACtC,UAAU;CACV,QAAQ;CACR,UAAU,EACR,UAAU;EACR,KAAK;GAAE,KAAK;GAAM,OAAO;EAAK;EAC9B,SAAS;GAAE,KAAK;GAAM,MAAM;EAAK;EACjC,aAAa;GAAE,QAAQ;GAAM,OAAO;EAAK;EACzC,YAAY;GAAE,QAAQ;GAAM,MAAM;EAAK;CACzC,EACF;CAEA,iBAAiB,EACf,UAAU,MACZ;AACF,CAAC;AAkBD,IAAa,aAAA,GAAYC,MAAAA,WAAAA,EAErB,EACE,OAAO,QACP,MACA,WAAW,OACX,UACA,YACA,kBAAkB,aAClB,QACA,aACA,UACA,WAAW,OACX,aACA,YAAY,KACZ,KACA,OACA,WACA,GAAG,SAEL,QACG;CACH,MAAM,eAAeC,2BAAAA,eAAe;CAEpC,MAAM,cADiB,eAAe,kBACA,SAASC,qBAAAA,OAAO,WAAWA,qBAAAA,OAAO;CAExE,MAAM,WAAW,gBAAgB,S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AI,YAAY,UAAU,CAAC,WAAW,EAAE,IAAI,KAAK,IAAI,CAAC;KACxD;KAEC,UAAA,OAAO,KAAK,MAAM,MACjB,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;MAEE,GAAI,aAAa,EAAE,KAAK,CAAC;MACzB,OACE,WAAW;OAAE,YAAY;OAAY,WAAW;MAAY,IAAI,KAAA;MAGjE,UAAA,KAAK,KAAK,OAAO,QAChB,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD,EAAgB,GAAI,cAAc,EAAE,MAAM,CAAC,EAAI,GAApC,GAAoC,CAChD;KACE,GATE,CASF,CACN;IACE,CAAA;GACF,CAAA,GACJ,cACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,mBAAD;IAAmB,KAAK;IAAkB,UAAU;IACjD,UAAA;GACgB,CAAA,CAElB;;CAEE,CAAA;AAEf,CACF;AAEA,UAAU,cAAc"}
|
|
1
|
+
{"version":3,"file":"CodeBlock.cjs","names":["styled","forwardRef","useColorScheme","themes","useState","useRef","useCallback","Button","AccessibleIcon","CheckIcon","CopyIcon","Highlight","Prism","Box"],"sources":["../../../components/CodeBlock/CodeBlock.tsx"],"sourcesContent":["import { CheckIcon, CopyIcon } from '@radix-ui/react-icons';\nimport { Highlight, Language, themes } from 'prism-react-renderer';\nimport React, { ComponentProps, forwardRef, useCallback, useRef, useState } from 'react';\n\nimport { CSS, styled } from '../../stitches.config';\nimport { useIsomorphicLayoutEffect } from '../../utils/useIsomorphicLayoutEffect';\nimport { AccessibleIcon } from '../AccessibleIcon';\nimport { Box } from '../Box';\nimport { Button } from '../Button';\nimport { useColorScheme } from '../colorSchemeContext';\nimport type {\n CodeBlockCopyButtonAlign,\n CodeBlockCopyErrorHandler,\n CodeBlockLanguage,\n} from './index';\nimport { Prism } from './prism-extend';\n\nconst Pre = styled('pre', {\n m: 0,\n borderRadius: '$2',\n overflow: 'auto',\n border: '1px solid $colors$deepBlue3',\n fontSize: '$2',\n lineHeight: 1.6,\n\n variants: {\n noBorder: {\n true: { border: 'none' },\n },\n },\n});\n\nconst CopyButtonWrapper = styled('div', {\n position: 'absolute',\n zIndex: 1,\n variants: {\n position: {\n top: { top: '$2', right: '$3' },\n topLeft: { top: '$2', left: '$3' },\n bottomRight: { bottom: '$2', right: '$3' },\n bottomLeft: { bottom: '$2', left: '$3' },\n },\n },\n\n defaultVariants: {\n position: 'top',\n },\n});\n\nexport type CodeBlockProps = {\n lang?: CodeBlockLanguage;\n code: string;\n copyable?: boolean;\n copyText?: string;\n copiedText?: string;\n copyButtonAlign?: CodeBlockCopyButtonAlign;\n onCopy?: () => void;\n onCopyError?: CodeBlockCopyErrorHandler;\n noBorder?: boolean;\n wrapText?: boolean;\n colorScheme?: 'light' | 'dark';\n maxHeight?: number | string;\n css?: CSS;\n} & Omit<ComponentProps<typeof Pre>, 'css'>;\n\nexport const CodeBlock = forwardRef<HTMLPreElement, CodeBlockProps>(\n (\n {\n lang = 'text',\n code,\n copyable = false,\n copyText,\n copiedText,\n copyButtonAlign = 'top right',\n onCopy,\n onCopyError,\n noBorder,\n wrapText = false,\n colorScheme,\n maxHeight = 424,\n css,\n style,\n className,\n ...props\n },\n ref,\n ) => {\n const systemScheme = useColorScheme();\n const resolvedScheme = colorScheme ?? systemScheme;\n const prismTheme = resolvedScheme === 'dark' ? themes.nightOwl : themes.nightOwlLight;\n\n const isBottom = copyButtonAlign.includes('bottom');\n const isLeft = copyButtonAlign.includes('left');\n const buttonPosition = isBottom\n ? isLeft\n ? 'bottomLeft'\n : 'bottomRight'\n : isLeft\n ? 'topLeft'\n : 'top';\n\n const [copied, setCopied] = useState(false);\n\n const preRef = useRef<HTMLPreElement | null>(\n null,\n ) as React.MutableRefObject<HTMLPreElement | null>;\n const buttonWrapperRef = useRef<HTMLDivElement>(null);\n\n const setPreRef = useCallback(\n (node: HTMLPreElement | null) => {\n preRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) (ref as React.MutableRefObject<HTMLPreElement | null>).current = node;\n },\n [ref],\n );\n\n useIsomorphicLayoutEffect(() => {\n if (!copyable) return;\n const pre = preRef.current;\n const wrapper = buttonWrapperRef.current;\n if (!pre || !wrapper) return;\n\n const isBottomAlign = isBottom;\n const borderH = noBorder ? 0 : 2;\n\n const update = () => {\n if (!isLeft) {\n const vScrollbar = Math.max(0, pre.offsetWidth - pre.clientWidth - borderH);\n wrapper.style.right = `${16 + vScrollbar}px`;\n }\n if (isBottomAlign) {\n const hScrollbar = Math.max(0, pre.offsetHeight - pre.clientHeight - borderH);\n wrapper.style.bottom = `${8 + hScrollbar}px`;\n }\n };\n\n update();\n const observer = new ResizeObserver(update);\n observer.observe(pre);\n return () => observer.disconnect();\n }, [copyable, isBottom, isLeft, noBorder]);\n\n const handleCopy = async () => {\n try {\n try {\n await navigator.clipboard.writeText(code);\n } catch (error) {\n // clipboard write failed (e.g. permission denied) — leave UI unchanged unless a fallback handled it\n if ((await onCopyError?.(error, code)) !== true) return;\n }\n setCopied(true);\n onCopy?.();\n setTimeout(() => setCopied(false), 1500);\n } catch {\n // onCopyError or onCopy threw — leave UI unchanged\n }\n };\n\n const copyButton = copyable ? (\n <Button\n variant=\"secondary\"\n ghost\n size=\"small\"\n type=\"button\"\n onClick={handleCopy}\n css={{\n color: '$hiContrast',\n gap: '$1',\n backgroundColor: '$codeBlockCopyButtonBg',\n height: '32px',\n }}\n >\n <AccessibleIcon label={copied ? 'Copied' : 'Copy'}>\n {copied ? <CheckIcon /> : <CopyIcon />}\n </AccessibleIcon>\n {copied ? copiedText : copyText}\n </Button>\n ) : null;\n\n return (\n <Highlight\n theme={prismTheme}\n code={code}\n language={(Prism.languages[lang] != null ? lang : 'text') as Language}\n >\n {({\n className: highlightClass,\n style: highlightStyle,\n tokens,\n getLineProps,\n getTokenProps,\n }) => (\n <Box css={{ position: 'relative', ...css }}>\n <Pre\n ref={setPreRef}\n className={[highlightClass, className].filter(Boolean).join(' ')}\n style={{ maxHeight, ...highlightStyle, backgroundColor: 'inherit', ...style }}\n noBorder={noBorder}\n {...props}\n >\n <Box\n css={{\n p: '$4',\n ...(copyable && isLeft && isBottom ? { pb: '$7' } : {}),\n ...(copyable && isLeft && !isBottom ? { pt: '$7' } : {}),\n }}\n >\n {tokens.map((line, i) => (\n <div\n key={i}\n {...getLineProps({ line })}\n style={\n wrapText ? { whiteSpace: 'pre-wrap', wordBreak: 'break-all' } : undefined\n }\n >\n {line.map((token, key) => (\n <span key={key} {...getTokenProps({ token })} />\n ))}\n </div>\n ))}\n </Box>\n </Pre>\n {copyButton && (\n <CopyButtonWrapper ref={buttonWrapperRef} position={buttonPosition}>\n {copyButton}\n </CopyButtonWrapper>\n )}\n </Box>\n )}\n </Highlight>\n );\n },\n);\n\nCodeBlock.displayName = 'CodeBlock';\n"],"mappings":";;;;;;;;;;;;;;AAiBA,IAAM,MAAMA,wBAAAA,OAAO,OAAO;CACxB,GAAG;CACH,cAAc;CACd,UAAU;CACV,QAAQ;CACR,UAAU;CACV,YAAY;CAEZ,UAAU,EACR,UAAU,EACR,MAAM,EAAE,QAAQ,OAAO,EACzB,EACF;AACF,CAAC;AAED,IAAM,oBAAoBA,wBAAAA,OAAO,OAAO;CACtC,UAAU;CACV,QAAQ;CACR,UAAU,EACR,UAAU;EACR,KAAK;GAAE,KAAK;GAAM,OAAO;EAAK;EAC9B,SAAS;GAAE,KAAK;GAAM,MAAM;EAAK;EACjC,aAAa;GAAE,QAAQ;GAAM,OAAO;EAAK;EACzC,YAAY;GAAE,QAAQ;GAAM,MAAM;EAAK;CACzC,EACF;CAEA,iBAAiB,EACf,UAAU,MACZ;AACF,CAAC;AAkBD,IAAa,aAAA,GAAYC,MAAAA,WAAAA,EAErB,EACE,OAAO,QACP,MACA,WAAW,OACX,UACA,YACA,kBAAkB,aAClB,QACA,aACA,UACA,WAAW,OACX,aACA,YAAY,KACZ,KACA,OACA,WACA,GAAG,SAEL,QACG;CACH,MAAM,eAAeC,2BAAAA,eAAe;CAEpC,MAAM,cADiB,eAAe,kBACA,SA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,UAAU,WAAW,EAAE,IAAI,KAAK,IAAI,CAAC;MACrD,GAAI,YAAY,UAAU,CAAC,WAAW,EAAE,IAAI,KAAK,IAAI,CAAC;KACxD;KAEC,UAAA,OAAO,KAAK,MAAM,MACjB,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;MAEE,GAAI,aAAa,EAAE,KAAK,CAAC;MACzB,OACE,WAAW;OAAE,YAAY;OAAY,WAAW;MAAY,IAAI,KAAA;MAGjE,UAAA,KAAK,KAAK,OAAO,QAChB,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD,EAAgB,GAAI,cAAc,EAAE,MAAM,CAAC,EAAI,GAApC,GAAoC,CAChD;KACE,GATE,CASF,CACN;IACE,CAAA;GACF,CAAA,GACJ,cACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,mBAAD;IAAmB,KAAK;IAAkB,UAAU;IACjD,UAAA;GACgB,CAAA,CAElB;;CAEE,CAAA;AAEf,CACF;AAEA,UAAU,cAAc"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { AccessibleIcon } from "../AccessibleIcon/AccessibleIcon.js";
|
|
2
2
|
import { styled } from "../../stitches.config.js";
|
|
3
3
|
import { Box } from "../Box/Box.js";
|
|
4
|
+
import { useIsomorphicLayoutEffect } from "../../utils/useIsomorphicLayoutEffect.js";
|
|
4
5
|
import { Button } from "../Button/Button.js";
|
|
5
6
|
import { useColorScheme } from "../colorSchemeContext.js";
|
|
6
7
|
import { Prism } from "./prism-extend.js";
|
|
7
8
|
import { CheckIcon, CopyIcon } from "@radix-ui/react-icons";
|
|
8
|
-
import { forwardRef, useCallback,
|
|
9
|
+
import { forwardRef, useCallback, useRef, useState } from "react";
|
|
9
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
11
|
import { Highlight, themes } from "prism-react-renderer";
|
|
11
12
|
// components/CodeBlock/CodeBlock.tsx
|
|
@@ -55,7 +56,7 @@ var CodeBlock = forwardRef(({ lang = "text", code, copyable = false, copyText, c
|
|
|
55
56
|
if (typeof ref === "function") ref(node);
|
|
56
57
|
else if (ref) ref.current = node;
|
|
57
58
|
}, [ref]);
|
|
58
|
-
|
|
59
|
+
useIsomorphicLayoutEffect(() => {
|
|
59
60
|
if (!copyable) return;
|
|
60
61
|
const pre = preRef.current;
|
|
61
62
|
const wrapper = buttonWrapperRef.current;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlock.js","names":[],"sources":["../../../components/CodeBlock/CodeBlock.tsx"],"sourcesContent":["import { CheckIcon, CopyIcon } from '@radix-ui/react-icons';\nimport { Highlight, Language, themes } from 'prism-react-renderer';\nimport React, {
|
|
1
|
+
{"version":3,"file":"CodeBlock.js","names":[],"sources":["../../../components/CodeBlock/CodeBlock.tsx"],"sourcesContent":["import { CheckIcon, CopyIcon } from '@radix-ui/react-icons';\nimport { Highlight, Language, themes } from 'prism-react-renderer';\nimport React, { ComponentProps, forwardRef, useCallback, useRef, useState } from 'react';\n\nimport { CSS, styled } from '../../stitches.config';\nimport { useIsomorphicLayoutEffect } from '../../utils/useIsomorphicLayoutEffect';\nimport { AccessibleIcon } from '../AccessibleIcon';\nimport { Box } from '../Box';\nimport { Button } from '../Button';\nimport { useColorScheme } from '../colorSchemeContext';\nimport type {\n CodeBlockCopyButtonAlign,\n CodeBlockCopyErrorHandler,\n CodeBlockLanguage,\n} from './index';\nimport { Prism } from './prism-extend';\n\nconst Pre = styled('pre', {\n m: 0,\n borderRadius: '$2',\n overflow: 'auto',\n border: '1px solid $colors$deepBlue3',\n fontSize: '$2',\n lineHeight: 1.6,\n\n variants: {\n noBorder: {\n true: { border: 'none' },\n },\n },\n});\n\nconst CopyButtonWrapper = styled('div', {\n position: 'absolute',\n zIndex: 1,\n variants: {\n position: {\n top: { top: '$2', right: '$3' },\n topLeft: { top: '$2', left: '$3' },\n bottomRight: { bottom: '$2', right: '$3' },\n bottomLeft: { bottom: '$2', left: '$3' },\n },\n },\n\n defaultVariants: {\n position: 'top',\n },\n});\n\nexport type CodeBlockProps = {\n lang?: CodeBlockLanguage;\n code: string;\n copyable?: boolean;\n copyText?: string;\n copiedText?: string;\n copyButtonAlign?: CodeBlockCopyButtonAlign;\n onCopy?: () => void;\n onCopyError?: CodeBlockCopyErrorHandler;\n noBorder?: boolean;\n wrapText?: boolean;\n colorScheme?: 'light' | 'dark';\n maxHeight?: number | string;\n css?: CSS;\n} & Omit<ComponentProps<typeof Pre>, 'css'>;\n\nexport const CodeBlock = forwardRef<HTMLPreElement, CodeBlockProps>(\n (\n {\n lang = 'text',\n code,\n copyable = false,\n copyText,\n copiedText,\n copyButtonAlign = 'top right',\n onCopy,\n onCopyError,\n noBorder,\n wrapText = false,\n colorScheme,\n maxHeight = 424,\n css,\n style,\n className,\n ...props\n },\n ref,\n ) => {\n const systemScheme = useColorScheme();\n const resolvedScheme = colorScheme ?? systemScheme;\n const prismTheme = resolvedScheme === 'dark' ? themes.nightOwl : themes.nightOwlLight;\n\n const isBottom = copyButtonAlign.includes('bottom');\n const isLeft = copyButtonAlign.includes('left');\n const buttonPosition = isBottom\n ? isLeft\n ? 'bottomLeft'\n : 'bottomRight'\n : isLeft\n ? 'topLeft'\n : 'top';\n\n const [copied, setCopied] = useState(false);\n\n const preRef = useRef<HTMLPreElement | null>(\n null,\n ) as React.MutableRefObject<HTMLPreElement | null>;\n const buttonWrapperRef = useRef<HTMLDivElement>(null);\n\n const setPreRef = useCallback(\n (node: HTMLPreElement | null) => {\n preRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) (ref as React.MutableRefObject<HTMLPreElement | null>).current = node;\n },\n [ref],\n );\n\n useIsomorphicLayoutEffect(() => {\n if (!copyable) return;\n const pre = preRef.current;\n const wrapper = buttonWrapperRef.current;\n if (!pre || !wrapper) return;\n\n const isBottomAlign = isBottom;\n const borderH = noBorder ? 0 : 2;\n\n const update = () => {\n if (!isLeft) {\n const vScrollbar = Math.max(0, pre.offsetWidth - pre.clientWidth - borderH);\n wrapper.style.right = `${16 + vScrollbar}px`;\n }\n if (isBottomAlign) {\n const hScrollbar = Math.max(0, pre.offsetHeight - pre.clientHeight - borderH);\n wrapper.style.bottom = `${8 + hScrollbar}px`;\n }\n };\n\n update();\n const observer = new ResizeObserver(update);\n observer.observe(pre);\n return () => observer.disconnect();\n }, [copyable, isBottom, isLeft, noBorder]);\n\n const handleCopy = async () => {\n try {\n try {\n await navigator.clipboard.writeText(code);\n } catch (error) {\n // clipboard write failed (e.g. permission denied) — leave UI unchanged unless a fallback handled it\n if ((await onCopyError?.(error, code)) !== true) return;\n }\n setCopied(true);\n onCopy?.();\n setTimeout(() => setCopied(false), 1500);\n } catch {\n // onCopyError or onCopy threw — leave UI unchanged\n }\n };\n\n const copyButton = copyable ? (\n <Button\n variant=\"secondary\"\n ghost\n size=\"small\"\n type=\"button\"\n onClick={handleCopy}\n css={{\n color: '$hiContrast',\n gap: '$1',\n backgroundColor: '$codeBlockCopyButtonBg',\n height: '32px',\n }}\n >\n <AccessibleIcon label={copied ? 'Copied' : 'Copy'}>\n {copied ? <CheckIcon /> : <CopyIcon />}\n </AccessibleIcon>\n {copied ? copiedText : copyText}\n </Button>\n ) : null;\n\n return (\n <Highlight\n theme={prismTheme}\n code={code}\n language={(Prism.languages[lang] != null ? lang : 'text') as Language}\n >\n {({\n className: highlightClass,\n style: highlightStyle,\n tokens,\n getLineProps,\n getTokenProps,\n }) => (\n <Box css={{ position: 'relative', ...css }}>\n <Pre\n ref={setPreRef}\n className={[highlightClass, className].filter(Boolean).join(' ')}\n style={{ maxHeight, ...highlightStyle, backgroundColor: 'inherit', ...style }}\n noBorder={noBorder}\n {...props}\n >\n <Box\n css={{\n p: '$4',\n ...(copyable && isLeft && isBottom ? { pb: '$7' } : {}),\n ...(copyable && isLeft && !isBottom ? { pt: '$7' } : {}),\n }}\n >\n {tokens.map((line, i) => (\n <div\n key={i}\n {...getLineProps({ line })}\n style={\n wrapText ? { whiteSpace: 'pre-wrap', wordBreak: 'break-all' } : undefined\n }\n >\n {line.map((token, key) => (\n <span key={key} {...getTokenProps({ token })} />\n ))}\n </div>\n ))}\n </Box>\n </Pre>\n {copyButton && (\n <CopyButtonWrapper ref={buttonWrapperRef} position={buttonPosition}>\n {copyButton}\n </CopyButtonWrapper>\n )}\n </Box>\n )}\n </Highlight>\n );\n },\n);\n\nCodeBlock.displayName = 'CodeBlock';\n"],"mappings":";;;;;;;;;;;;AAiBA,IAAM,MAAM,OAAO,OAAO;CACxB,GAAG;CACH,cAAc;CACd,UAAU;CACV,QAAQ;CACR,UAAU;CACV,YAAY;CAEZ,UAAU,EACR,UAAU,EACR,MAAM,EAAE,QAAQ,OAAO,EACzB,EACF;AACF,CAAC;AAED,IAAM,oBAAoB,OAAO,OAAO;CACtC,UAAU;CACV,QAAQ;CACR,UAAU,EACR,UAAU;EACR,KAAK;GAAE,KAAK;GAAM,OAAO;EAAK;EAC9B,SAAS;GAAE,KAAK;GAAM,MAAM;EAAK;EACjC,aAAa;GAAE,QAAQ;GAAM,OAAO;EAAK;EACzC,YAAY;GAAE,QAAQ;GAAM,MAAM;EAAK;CACzC,EACF;CAEA,iBAAiB,EACf,UAAU,MACZ;AACF,CAAC;AAkBD,IAAa,YAAY,YAErB,EACE,OAAO,QACP,MACA,WAAW,OACX,UACA,YACA,kBAAkB,aAClB,QACA,aACA,UACA,WAAW,OACX,aACA,YAAY,KACZ,KACA,OACA,WACA,GAAG,SAEL,QACG;CACH,MAAM,eAAe,eAAe;CAEpC,MAAM,cADiB,eAAe,kBACA,SAAS,OAAO,WAAW,OAAO;CAExE,MAAM,WAAW,gBAAgB,SAAS,QAAQ;CAClD,MAAM,SAAS,gBAAgB,SAAS,MAAM;CAC9C,MAAM,iBAAiB,WACnB,SACE,eACA,gBACF,SACE,YACA;CAEN,MAAM,CAAC,QAAQ,aAAa,SAAS,KAAK;CAE1C,MAAM,SAAS,OACb,IACF;CACA,MAAM,mBAAmB,OAAuB,IAAI;CAEpD,MAAM,YAAY,aACf,SAAgC;EAC/B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,CAAY,CAAA,IAAI,oBAAC,UAAD,CAAW,CAAA;EACvB,CAAA,GACf,SAAS,aAAa,QACjB;CACN,CAAA,IAAA;CAEJ,OACE,oBAAC,WAAD;EACE,OAAO;EACD;EACN,UAAW,MAAM,UAAU,SAAS,OAAO,OAAO;EAEhD,WAAA,EACA,WAAW,gBACX,OAAO,gBACP,QACA,cACA,oBAEA,qBAAC,KAAD;GAAK,KAAK;IAAE,UAAU;IAAY,GAAG;GAAI;GAAzC,UAAA,CACE,oBAAC,KAAD;IACE,KAAK;IACL,WAAW,CAAC,gBAAgB,SAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;IAC/D,OAAO;KAAE;KAAW,GAAG;KAAgB,iBAAiB;KAAW,GAAG;IAAM;IAClE;IACV,GAAI;IAEJ,UAAA,oBAAC,KAAD;KACE,KAAK;MACH,GAAG;MACH,GAAI,YAAY,UAAU,WAAW,EAAE,IAAI,KAAK,IAAI,CAAC;MACrD,GAAI,YAAY,UAAU,CAAC,WAAW,EAAE,IAAI,KAAK,IAAI,CAAC;KACxD;KAEC,UAAA,OAAO,KAAK,MAAM,MACjB,oBAAC,OAAD;MAEE,GAAI,aAAa,EAAE,KAAK,CAAC;MACzB,OACE,WAAW;OAAE,YAAY;OAAY,WAAW;MAAY,IAAI,KAAA;MAGjE,UAAA,KAAK,KAAK,OAAO,QAChB,oBAAC,QAAD,EAAgB,GAAI,cAAc,EAAE,MAAM,CAAC,EAAI,GAApC,GAAoC,CAChD;KACE,GATE,CASF,CACN;IACE,CAAA;GACF,CAAA,GACJ,cACC,oBAAC,mBAAD;IAAmB,KAAK;IAAkB,UAAU;IACjD,UAAA;GACgB,CAAA,CAElB;;CAEE,CAAA;AAEf,CACF;AAEA,UAAU,cAAc"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
2
|
const require_AccessibleIcon = require("../AccessibleIcon/AccessibleIcon.cjs");
|
|
3
3
|
const require_cssProps = require("../../styles/cssProps.cjs");
|
|
4
|
+
const require_useIsomorphicLayoutEffect = require("../../utils/useIsomorphicLayoutEffect.cjs");
|
|
4
5
|
const require_themeContext = require("../../styles/themeContext.cjs");
|
|
5
6
|
const require_Button_vanilla = require("../Button/Button.vanilla.cjs");
|
|
6
7
|
require("./prism-extend.cjs");
|
|
@@ -31,7 +32,7 @@ var CodeBlockVanilla = (0, react.forwardRef)(({ lang = "text", code, copyable =
|
|
|
31
32
|
if (typeof ref === "function") ref(node);
|
|
32
33
|
else if (ref) ref.current = node;
|
|
33
34
|
}, [ref]);
|
|
34
|
-
|
|
35
|
+
require_useIsomorphicLayoutEffect.useIsomorphicLayoutEffect(() => {
|
|
35
36
|
if (!copyable) return;
|
|
36
37
|
const pre = preRef.current;
|
|
37
38
|
const wrapper = buttonWrapperRef.current;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlock.vanilla.cjs","names":["forwardRef","useVanillaExtractTheme","themes","processCSSProp","assignInlineVars","useState","useRef","useCallback","copyButtonWrapperBottomLeft","copyButtonWrapperBottomRight","copyButtonWrapperTopLeft","copyButtonWrapperTop","ButtonVanilla","AccessibleIcon","CheckIcon","CopyIcon","Highlight","Prism","pre","preNoBorder","codeContent","codeContentBottomPadding","codeContentTopPadding"],"sources":["../../../components/CodeBlock/CodeBlock.vanilla.tsx"],"sourcesContent":["import { CheckIcon, CopyIcon } from '@radix-ui/react-icons';\nimport { assignInlineVars } from '@vanilla-extract/dynamic';\nimport { Highlight, Language, themes } from 'prism-react-renderer';\nimport React, {\n forwardRef,\n HTMLAttributes,\n useCallback,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { CSSProps, processCSSProp } from '../../styles/cssProps';\nimport { useVanillaExtractTheme } from '../../styles/themeContext';\nimport { AccessibleIcon } from '../AccessibleIcon';\nimport { ButtonVanilla } from '../Button';\nimport {\n codeContent,\n codeContentBottomPadding,\n codeContentTopPadding,\n copyButtonWrapperBottomLeft,\n copyButtonWrapperBottomRight,\n copyButtonWrapperTop,\n copyButtonWrapperTopLeft,\n pre,\n preNoBorder,\n} from './CodeBlock.vanilla.css';\nimport type {\n CodeBlockCopyButtonAlign,\n CodeBlockCopyErrorHandler,\n CodeBlockLanguage,\n} from './index';\nimport { Prism } from './prism-extend';\n\nexport interface CodeBlockVanillaProps\n extends Omit<HTMLAttributes<HTMLPreElement>, 'css'>, CSSProps {\n lang?: CodeBlockLanguage;\n code: string;\n copyable?: boolean;\n copyText?: string;\n copiedText?: string;\n copyButtonAlign?: CodeBlockCopyButtonAlign;\n onCopy?: () => void;\n onCopyError?: CodeBlockCopyErrorHandler;\n noBorder?: boolean;\n wrapText?: boolean;\n colorScheme?: 'light' | 'dark';\n maxHeight?: number | string;\n}\n\nexport const CodeBlockVanilla = forwardRef<HTMLPreElement, CodeBlockVanillaProps>(\n (\n {\n lang = 'text',\n code,\n copyable = false,\n copyText,\n copiedText,\n copyButtonAlign = 'top right',\n onCopy,\n onCopyError,\n noBorder,\n wrapText = false,\n colorScheme,\n maxHeight = 424,\n css,\n style,\n className,\n ...props\n },\n ref,\n ) => {\n const { colors, resolvedTheme } = useVanillaExtractTheme();\n const effectiveScheme = colorScheme ?? resolvedTheme;\n const prismTheme = effectiveScheme === 'dark' ? themes.nightOwl : themes.nightOwlLight;\n\n const isBottom = copyButtonAlign.includes('bottom');\n const isLeft = copyButtonAlign.includes('left');\n\n const { style: cssStyles, vars } = processCSSProp(css, colors);\n const containerStyles = {\n position: 'relative' as const,\n ...cssStyles,\n ...assignInlineVars(vars),\n };\n\n const [copied, setCopied] = useState(false);\n\n const preRef = useRef<HTMLPreElement | null>(\n null,\n ) as React.MutableRefObject<HTMLPreElement | null>;\n const buttonWrapperRef = useRef<HTMLDivElement>(null);\n\n const setPreRef = useCallback(\n (node: HTMLPreElement | null) => {\n preRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) (ref as React.MutableRefObject<HTMLPreElement | null>).current = node;\n },\n [ref],\n );\n\n useLayoutEffect(() => {\n if (!copyable) return;\n const pre = preRef.current;\n const wrapper = buttonWrapperRef.current;\n if (!pre || !wrapper) return;\n\n const borderH = noBorder ? 0 : 2;\n\n const update = () => {\n if (!isLeft) {\n const vScrollbar = Math.max(0, pre.offsetWidth - pre.clientWidth - borderH);\n wrapper.style.right = `${16 + vScrollbar}px`;\n }\n if (isBottom) {\n const hScrollbar = Math.max(0, pre.offsetHeight - pre.clientHeight - borderH);\n wrapper.style.bottom = `${8 + hScrollbar}px`;\n }\n };\n\n update();\n const observer = new ResizeObserver(update);\n observer.observe(pre);\n return () => observer.disconnect();\n }, [copyable, isBottom, isLeft, noBorder]);\n\n const handleCopy = async () => {\n try {\n try {\n await navigator.clipboard.writeText(code);\n } catch (error) {\n // clipboard write failed (e.g. permission denied) — leave UI unchanged unless a fallback handled it\n if ((await onCopyError?.(error, code)) !== true) return;\n }\n setCopied(true);\n onCopy?.();\n setTimeout(() => setCopied(false), 1500);\n } catch {\n // onCopyError or onCopy threw — leave UI unchanged\n }\n };\n\n const buttonPositionClass = isBottom\n ? isLeft\n ? copyButtonWrapperBottomLeft\n : copyButtonWrapperBottomRight\n : isLeft\n ? copyButtonWrapperTopLeft\n : copyButtonWrapperTop;\n\n const copyButton = copyable ? (\n <ButtonVanilla\n variant=\"secondary\"\n ghost\n size=\"small\"\n type=\"button\"\n onClick={handleCopy}\n css={{\n color: '$hiContrast',\n gap: '$1',\n backgroundColor: '$codeBlockCopyButtonBg',\n height: '32px',\n }}\n >\n <AccessibleIcon label={copied ? 'Copied' : 'Copy'}>\n {copied ? <CheckIcon /> : <CopyIcon />}\n </AccessibleIcon>\n {copied ? copiedText : copyText}\n </ButtonVanilla>\n ) : null;\n\n return (\n <Highlight\n theme={prismTheme}\n code={code}\n language={(Prism.languages[lang] != null ? lang : 'text') as Language}\n >\n {({\n className: highlightClass,\n style: highlightStyle,\n tokens,\n getLineProps,\n getTokenProps,\n }) => (\n <div style={containerStyles}>\n <pre\n ref={setPreRef}\n className={[pre, noBorder ? preNoBorder : '', highlightClass, className]\n .filter(Boolean)\n .join(' ')}\n style={{\n maxHeight,\n ...highlightStyle,\n backgroundColor: 'inherit',\n ...style,\n }}\n {...props}\n >\n <div\n className={[\n codeContent,\n copyable && isLeft && isBottom ? codeContentBottomPadding : '',\n copyable && isLeft && !isBottom ? codeContentTopPadding : '',\n ]\n .filter(Boolean)\n .join(' ')}\n >\n {tokens.map((line, i) => (\n <div\n key={i}\n {...getLineProps({ line })}\n style={\n wrapText ? { whiteSpace: 'pre-wrap', wordBreak: 'break-all' } : undefined\n }\n >\n {line.map((token, key) => (\n <span key={key} {...getTokenProps({ token })} />\n ))}\n </div>\n ))}\n </div>\n </pre>\n {copyButton && (\n <div ref={buttonWrapperRef} className={buttonPositionClass}>\n {copyButton}\n </div>\n )}\n </div>\n )}\n </Highlight>\n );\n },\n);\n\nCodeBlockVanilla.displayName = 'CodeBlockVanilla';\n"],"mappings":";;;;;;;;;;;;;;AAkDA,IAAa,oBAAA,GAAmBA,MAAAA,WAAAA,EAE5B,EACE,OAAO,QACP,MACA,WAAW,OACX,UACA,YACA,kBAAkB,aAClB,QACA,aACA,UACA,WAAW,OACX,aACA,YAAY,KACZ,KACA,OACA,WACA,GAAG,SAEL,QACG;CACH,MAAM,EAAE,QAAQ,kBAAkBC,qBAAAA,uBAAuB;CAEzD,MAAM,cADkB,eAAe,mBACA,SAASC,qBAAAA,OAAO,WAAWA,qBAAAA,OAAO;CAEzE,MAAM,WAAW,gBAAgB,SAAS,QAAQ;CAClD,MAAM,SAAS,gBAAgB,SAAS,MAAM;CAE9C,MAAM,EAAE,OAAO,WAAW,SAASC,iBAAAA,eAAe,KAAK,MAAM;CAC7D,MAAM,kBAAkB;EACtB,UAAU;EACV,GAAG;EACH,IAAA,GAAGC,yBAAAA,iBAAAA,CAAiB,IAAI;CAC1B;CAEA,MAAM,CAAC,QAAQ,cAAA,GAAaC,MAAAA,SAAAA,CAAS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,MACjB,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;MAEE,GAAI,aAAa,EAAE,KAAK,CAAC;MACzB,OACE,WAAW;OAAE,YAAY;OAAY,WAAW;MAAY,IAAI,KAAA;MAGjE,UAAA,KAAK,KAAK,OAAO,QAChB,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD,EAAgB,GAAI,cAAc,EAAE,MAAM,CAAC,EAAI,GAApC,GAAoC,CAChD;KACE,GATE,CASF,CACN;IACE,CAAA;GACF,CAAA,GACJ,cACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;IAAK,KAAK;IAAkB,WAAW;IACpC,UAAA;GACE,CAAA,CAEJ;;CAEE,CAAA;AAEf,CACF;AAEA,iBAAiB,cAAc"}
|
|
1
|
+
{"version":3,"file":"CodeBlock.vanilla.cjs","names":["forwardRef","useVanillaExtractTheme","themes","processCSSProp","assignInlineVars","useState","useRef","useCallback","copyButtonWrapperBottomLeft","copyButtonWrapperBottomRight","copyButtonWrapperTopLeft","copyButtonWrapperTop","ButtonVanilla","AccessibleIcon","CheckIcon","CopyIcon","Highlight","Prism","pre","preNoBorder","codeContent","codeContentBottomPadding","codeContentTopPadding"],"sources":["../../../components/CodeBlock/CodeBlock.vanilla.tsx"],"sourcesContent":["import { CheckIcon, CopyIcon } from '@radix-ui/react-icons';\nimport { assignInlineVars } from '@vanilla-extract/dynamic';\nimport { Highlight, Language, themes } from 'prism-react-renderer';\nimport React, { forwardRef, HTMLAttributes, useCallback, useRef, useState } from 'react';\n\nimport { CSSProps, processCSSProp } from '../../styles/cssProps';\nimport { useVanillaExtractTheme } from '../../styles/themeContext';\nimport { useIsomorphicLayoutEffect } from '../../utils/useIsomorphicLayoutEffect';\nimport { AccessibleIcon } from '../AccessibleIcon';\nimport { ButtonVanilla } from '../Button';\nimport {\n codeContent,\n codeContentBottomPadding,\n codeContentTopPadding,\n copyButtonWrapperBottomLeft,\n copyButtonWrapperBottomRight,\n copyButtonWrapperTop,\n copyButtonWrapperTopLeft,\n pre,\n preNoBorder,\n} from './CodeBlock.vanilla.css';\nimport type {\n CodeBlockCopyButtonAlign,\n CodeBlockCopyErrorHandler,\n CodeBlockLanguage,\n} from './index';\nimport { Prism } from './prism-extend';\n\nexport interface CodeBlockVanillaProps\n extends Omit<HTMLAttributes<HTMLPreElement>, 'css'>, CSSProps {\n lang?: CodeBlockLanguage;\n code: string;\n copyable?: boolean;\n copyText?: string;\n copiedText?: string;\n copyButtonAlign?: CodeBlockCopyButtonAlign;\n onCopy?: () => void;\n onCopyError?: CodeBlockCopyErrorHandler;\n noBorder?: boolean;\n wrapText?: boolean;\n colorScheme?: 'light' | 'dark';\n maxHeight?: number | string;\n}\n\nexport const CodeBlockVanilla = forwardRef<HTMLPreElement, CodeBlockVanillaProps>(\n (\n {\n lang = 'text',\n code,\n copyable = false,\n copyText,\n copiedText,\n copyButtonAlign = 'top right',\n onCopy,\n onCopyError,\n noBorder,\n wrapText = false,\n colorScheme,\n maxHeight = 424,\n css,\n style,\n className,\n ...props\n },\n ref,\n ) => {\n const { colors, resolvedTheme } = useVanillaExtractTheme();\n const effectiveScheme = colorScheme ?? resolvedTheme;\n const prismTheme = effectiveScheme === 'dark' ? themes.nightOwl : themes.nightOwlLight;\n\n const isBottom = copyButtonAlign.includes('bottom');\n const isLeft = copyButtonAlign.includes('left');\n\n const { style: cssStyles, vars } = processCSSProp(css, colors);\n const containerStyles = {\n position: 'relative' as const,\n ...cssStyles,\n ...assignInlineVars(vars),\n };\n\n const [copied, setCopied] = useState(false);\n\n const preRef = useRef<HTMLPreElement | null>(\n null,\n ) as React.MutableRefObject<HTMLPreElement | null>;\n const buttonWrapperRef = useRef<HTMLDivElement>(null);\n\n const setPreRef = useCallback(\n (node: HTMLPreElement | null) => {\n preRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) (ref as React.MutableRefObject<HTMLPreElement | null>).current = node;\n },\n [ref],\n );\n\n useIsomorphicLayoutEffect(() => {\n if (!copyable) return;\n const pre = preRef.current;\n const wrapper = buttonWrapperRef.current;\n if (!pre || !wrapper) return;\n\n const borderH = noBorder ? 0 : 2;\n\n const update = () => {\n if (!isLeft) {\n const vScrollbar = Math.max(0, pre.offsetWidth - pre.clientWidth - borderH);\n wrapper.style.right = `${16 + vScrollbar}px`;\n }\n if (isBottom) {\n const hScrollbar = Math.max(0, pre.offsetHeight - pre.clientHeight - borderH);\n wrapper.style.bottom = `${8 + hScrollbar}px`;\n }\n };\n\n update();\n const observer = new ResizeObserver(update);\n observer.observe(pre);\n return () => observer.disconnect();\n }, [copyable, isBottom, isLeft, noBorder]);\n\n const handleCopy = async () => {\n try {\n try {\n await navigator.clipboard.writeText(code);\n } catch (error) {\n // clipboard write failed (e.g. permission denied) — leave UI unchanged unless a fallback handled it\n if ((await onCopyError?.(error, code)) !== true) return;\n }\n setCopied(true);\n onCopy?.();\n setTimeout(() => setCopied(false), 1500);\n } catch {\n // onCopyError or onCopy threw — leave UI unchanged\n }\n };\n\n const buttonPositionClass = isBottom\n ? isLeft\n ? copyButtonWrapperBottomLeft\n : copyButtonWrapperBottomRight\n : isLeft\n ? copyButtonWrapperTopLeft\n : copyButtonWrapperTop;\n\n const copyButton = copyable ? (\n <ButtonVanilla\n variant=\"secondary\"\n ghost\n size=\"small\"\n type=\"button\"\n onClick={handleCopy}\n css={{\n color: '$hiContrast',\n gap: '$1',\n backgroundColor: '$codeBlockCopyButtonBg',\n height: '32px',\n }}\n >\n <AccessibleIcon label={copied ? 'Copied' : 'Copy'}>\n {copied ? <CheckIcon /> : <CopyIcon />}\n </AccessibleIcon>\n {copied ? copiedText : copyText}\n </ButtonVanilla>\n ) : null;\n\n return (\n <Highlight\n theme={prismTheme}\n code={code}\n language={(Prism.languages[lang] != null ? lang : 'text') as Language}\n >\n {({\n className: highlightClass,\n style: highlightStyle,\n tokens,\n getLineProps,\n getTokenProps,\n }) => (\n <div style={containerStyles}>\n <pre\n ref={setPreRef}\n className={[pre, noBorder ? preNoBorder : '', highlightClass, className]\n .filter(Boolean)\n .join(' ')}\n style={{\n maxHeight,\n ...highlightStyle,\n backgroundColor: 'inherit',\n ...style,\n }}\n {...props}\n >\n <div\n className={[\n codeContent,\n copyable && isLeft && isBottom ? codeContentBottomPadding : '',\n copyable && isLeft && !isBottom ? codeContentTopPadding : '',\n ]\n .filter(Boolean)\n .join(' ')}\n >\n {tokens.map((line, i) => (\n <div\n key={i}\n {...getLineProps({ line })}\n style={\n wrapText ? { whiteSpace: 'pre-wrap', wordBreak: 'break-all' } : undefined\n }\n >\n {line.map((token, key) => (\n <span key={key} {...getTokenProps({ token })} />\n ))}\n </div>\n ))}\n </div>\n </pre>\n {copyButton && (\n <div ref={buttonWrapperRef} className={buttonPositionClass}>\n {copyButton}\n </div>\n )}\n </div>\n )}\n </Highlight>\n );\n },\n);\n\nCodeBlockVanilla.displayName = 'CodeBlockVanilla';\n"],"mappings":";;;;;;;;;;;;;;;AA4CA,IAAa,oBAAA,GAAmBA,MAAAA,WAAAA,EAE5B,EACE,OAAO,QACP,MACA,WAAW,OACX,UACA,YACA,kBAAkB,aAClB,QACA,aACA,UACA,WAAW,OACX,aACA,YAAY,KACZ,KACA,OACA,WACA,GAAG,SAEL,QACG;CACH,MAAM,EAAE,QAAQ,kBAAkBC,qBAAAA,uBAAuB;CAEzD,MAAM,cADkB,eAAe,mBACA,SAASC,qBAAAA,OAAO,WAAWA,qBAAAA,OAAO;CAEzE,MAAM,WAAW,gBAAgB,SAAS,QAAQ;CAClD,MAAM,SAAS,gBAAgB,SAAS,MAAM;CAE9C,MAAM,EAAE,OAAO,WAAW,SAASC,iBAAAA,eAAe,KAAK,MAAM;CAC7D,MAAM,kBAAkB;EACtB,UAAU;EACV,GAAG;EACH,IAAA,GAAGC,yBAAAA,iBAAAA,CAAiB,IAAI;CAC1B;CAEA,MAAM,CAAC,QAAQ,cAAA,GAAaC,MAAAA,SAAAA,CAAS,KAAK;CAE1C,MAAM,UAAA,GAASC,MAAAA,OAAAA,CACb,IACF;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AK,CAAC;MACzB,OACE,WAAW;OAAE,YAAY;OAAY,WAAW;MAAY,IAAI,KAAA;MAGjE,UAAA,KAAK,KAAK,OAAO,QAChB,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD,EAAgB,GAAI,cAAc,EAAE,MAAM,CAAC,EAAI,GAApC,GAAoC,CAChD;KACE,GATE,CASF,CACN;IACE,CAAA;GACF,CAAA,GACJ,cACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;IAAK,KAAK;IAAkB,WAAW;IACpC,UAAA;GACE,CAAA,CAEJ;;CAEE,CAAA;AAEf,CACF;AAEA,iBAAiB,cAAc"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { AccessibleIcon } from "../AccessibleIcon/AccessibleIcon.js";
|
|
2
2
|
import { processCSSProp } from "../../styles/cssProps.js";
|
|
3
|
+
import { useIsomorphicLayoutEffect } from "../../utils/useIsomorphicLayoutEffect.js";
|
|
3
4
|
import { useVanillaExtractTheme } from "../../styles/themeContext.js";
|
|
4
5
|
import { ButtonVanilla } from "../Button/Button.vanilla.js";
|
|
5
6
|
import { Prism } from "./prism-extend.js";
|
|
6
7
|
import { codeContent, codeContentBottomPadding, codeContentTopPadding, copyButtonWrapperBottomLeft, copyButtonWrapperBottomRight, copyButtonWrapperTop, copyButtonWrapperTopLeft, pre, preNoBorder } from "./CodeBlock.vanilla.css.js";
|
|
7
8
|
import { CheckIcon, CopyIcon } from "@radix-ui/react-icons";
|
|
8
|
-
import { forwardRef, useCallback,
|
|
9
|
+
import { forwardRef, useCallback, useRef, useState } from "react";
|
|
9
10
|
import { assignInlineVars } from "@vanilla-extract/dynamic";
|
|
10
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
12
|
import { Highlight, themes } from "prism-react-renderer";
|
|
@@ -29,7 +30,7 @@ var CodeBlockVanilla = forwardRef(({ lang = "text", code, copyable = false, copy
|
|
|
29
30
|
if (typeof ref === "function") ref(node);
|
|
30
31
|
else if (ref) ref.current = node;
|
|
31
32
|
}, [ref]);
|
|
32
|
-
|
|
33
|
+
useIsomorphicLayoutEffect(() => {
|
|
33
34
|
if (!copyable) return;
|
|
34
35
|
const pre = preRef.current;
|
|
35
36
|
const wrapper = buttonWrapperRef.current;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlock.vanilla.js","names":[],"sources":["../../../components/CodeBlock/CodeBlock.vanilla.tsx"],"sourcesContent":["import { CheckIcon, CopyIcon } from '@radix-ui/react-icons';\nimport { assignInlineVars } from '@vanilla-extract/dynamic';\nimport { Highlight, Language, themes } from 'prism-react-renderer';\nimport React, {
|
|
1
|
+
{"version":3,"file":"CodeBlock.vanilla.js","names":[],"sources":["../../../components/CodeBlock/CodeBlock.vanilla.tsx"],"sourcesContent":["import { CheckIcon, CopyIcon } from '@radix-ui/react-icons';\nimport { assignInlineVars } from '@vanilla-extract/dynamic';\nimport { Highlight, Language, themes } from 'prism-react-renderer';\nimport React, { forwardRef, HTMLAttributes, useCallback, useRef, useState } from 'react';\n\nimport { CSSProps, processCSSProp } from '../../styles/cssProps';\nimport { useVanillaExtractTheme } from '../../styles/themeContext';\nimport { useIsomorphicLayoutEffect } from '../../utils/useIsomorphicLayoutEffect';\nimport { AccessibleIcon } from '../AccessibleIcon';\nimport { ButtonVanilla } from '../Button';\nimport {\n codeContent,\n codeContentBottomPadding,\n codeContentTopPadding,\n copyButtonWrapperBottomLeft,\n copyButtonWrapperBottomRight,\n copyButtonWrapperTop,\n copyButtonWrapperTopLeft,\n pre,\n preNoBorder,\n} from './CodeBlock.vanilla.css';\nimport type {\n CodeBlockCopyButtonAlign,\n CodeBlockCopyErrorHandler,\n CodeBlockLanguage,\n} from './index';\nimport { Prism } from './prism-extend';\n\nexport interface CodeBlockVanillaProps\n extends Omit<HTMLAttributes<HTMLPreElement>, 'css'>, CSSProps {\n lang?: CodeBlockLanguage;\n code: string;\n copyable?: boolean;\n copyText?: string;\n copiedText?: string;\n copyButtonAlign?: CodeBlockCopyButtonAlign;\n onCopy?: () => void;\n onCopyError?: CodeBlockCopyErrorHandler;\n noBorder?: boolean;\n wrapText?: boolean;\n colorScheme?: 'light' | 'dark';\n maxHeight?: number | string;\n}\n\nexport const CodeBlockVanilla = forwardRef<HTMLPreElement, CodeBlockVanillaProps>(\n (\n {\n lang = 'text',\n code,\n copyable = false,\n copyText,\n copiedText,\n copyButtonAlign = 'top right',\n onCopy,\n onCopyError,\n noBorder,\n wrapText = false,\n colorScheme,\n maxHeight = 424,\n css,\n style,\n className,\n ...props\n },\n ref,\n ) => {\n const { colors, resolvedTheme } = useVanillaExtractTheme();\n const effectiveScheme = colorScheme ?? resolvedTheme;\n const prismTheme = effectiveScheme === 'dark' ? themes.nightOwl : themes.nightOwlLight;\n\n const isBottom = copyButtonAlign.includes('bottom');\n const isLeft = copyButtonAlign.includes('left');\n\n const { style: cssStyles, vars } = processCSSProp(css, colors);\n const containerStyles = {\n position: 'relative' as const,\n ...cssStyles,\n ...assignInlineVars(vars),\n };\n\n const [copied, setCopied] = useState(false);\n\n const preRef = useRef<HTMLPreElement | null>(\n null,\n ) as React.MutableRefObject<HTMLPreElement | null>;\n const buttonWrapperRef = useRef<HTMLDivElement>(null);\n\n const setPreRef = useCallback(\n (node: HTMLPreElement | null) => {\n preRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) (ref as React.MutableRefObject<HTMLPreElement | null>).current = node;\n },\n [ref],\n );\n\n useIsomorphicLayoutEffect(() => {\n if (!copyable) return;\n const pre = preRef.current;\n const wrapper = buttonWrapperRef.current;\n if (!pre || !wrapper) return;\n\n const borderH = noBorder ? 0 : 2;\n\n const update = () => {\n if (!isLeft) {\n const vScrollbar = Math.max(0, pre.offsetWidth - pre.clientWidth - borderH);\n wrapper.style.right = `${16 + vScrollbar}px`;\n }\n if (isBottom) {\n const hScrollbar = Math.max(0, pre.offsetHeight - pre.clientHeight - borderH);\n wrapper.style.bottom = `${8 + hScrollbar}px`;\n }\n };\n\n update();\n const observer = new ResizeObserver(update);\n observer.observe(pre);\n return () => observer.disconnect();\n }, [copyable, isBottom, isLeft, noBorder]);\n\n const handleCopy = async () => {\n try {\n try {\n await navigator.clipboard.writeText(code);\n } catch (error) {\n // clipboard write failed (e.g. permission denied) — leave UI unchanged unless a fallback handled it\n if ((await onCopyError?.(error, code)) !== true) return;\n }\n setCopied(true);\n onCopy?.();\n setTimeout(() => setCopied(false), 1500);\n } catch {\n // onCopyError or onCopy threw — leave UI unchanged\n }\n };\n\n const buttonPositionClass = isBottom\n ? isLeft\n ? copyButtonWrapperBottomLeft\n : copyButtonWrapperBottomRight\n : isLeft\n ? copyButtonWrapperTopLeft\n : copyButtonWrapperTop;\n\n const copyButton = copyable ? (\n <ButtonVanilla\n variant=\"secondary\"\n ghost\n size=\"small\"\n type=\"button\"\n onClick={handleCopy}\n css={{\n color: '$hiContrast',\n gap: '$1',\n backgroundColor: '$codeBlockCopyButtonBg',\n height: '32px',\n }}\n >\n <AccessibleIcon label={copied ? 'Copied' : 'Copy'}>\n {copied ? <CheckIcon /> : <CopyIcon />}\n </AccessibleIcon>\n {copied ? copiedText : copyText}\n </ButtonVanilla>\n ) : null;\n\n return (\n <Highlight\n theme={prismTheme}\n code={code}\n language={(Prism.languages[lang] != null ? lang : 'text') as Language}\n >\n {({\n className: highlightClass,\n style: highlightStyle,\n tokens,\n getLineProps,\n getTokenProps,\n }) => (\n <div style={containerStyles}>\n <pre\n ref={setPreRef}\n className={[pre, noBorder ? preNoBorder : '', highlightClass, className]\n .filter(Boolean)\n .join(' ')}\n style={{\n maxHeight,\n ...highlightStyle,\n backgroundColor: 'inherit',\n ...style,\n }}\n {...props}\n >\n <div\n className={[\n codeContent,\n copyable && isLeft && isBottom ? codeContentBottomPadding : '',\n copyable && isLeft && !isBottom ? codeContentTopPadding : '',\n ]\n .filter(Boolean)\n .join(' ')}\n >\n {tokens.map((line, i) => (\n <div\n key={i}\n {...getLineProps({ line })}\n style={\n wrapText ? { whiteSpace: 'pre-wrap', wordBreak: 'break-all' } : undefined\n }\n >\n {line.map((token, key) => (\n <span key={key} {...getTokenProps({ token })} />\n ))}\n </div>\n ))}\n </div>\n </pre>\n {copyButton && (\n <div ref={buttonWrapperRef} className={buttonPositionClass}>\n {copyButton}\n </div>\n )}\n </div>\n )}\n </Highlight>\n );\n },\n);\n\nCodeBlockVanilla.displayName = 'CodeBlockVanilla';\n"],"mappings":";;;;;;;;;;;;;AA4CA,IAAa,mBAAmB,YAE5B,EACE,OAAO,QACP,MACA,WAAW,OACX,UACA,YACA,kBAAkB,aAClB,QACA,aACA,UACA,WAAW,OACX,aACA,YAAY,KACZ,KACA,OACA,WACA,GAAG,SAEL,QACG;CACH,MAAM,EAAE,QAAQ,kBAAkB,uBAAuB;CAEzD,MAAM,cADkB,eAAe,mBACA,SAAS,OAAO,WAAW,OAAO;CAEzE,MAAM,WAAW,gBAAgB,SAAS,QAAQ;CAClD,MAAM,SAAS,gBAAgB,SAAS,MAAM;CAE9C,MAAM,EAAE,OAAO,WAAW,SAAS,eAAe,KAAK,MAAM;CAC7D,MAAM,kBAAkB;EACtB,UAAU;EACV,GAAG;EACH,GAAG,iBAAiB,IAAI;CAC1B;CAEA,MAAM,CAAC,QAAQ,aAAa,SAAS,KAAK;CAE1C,MAAM,SAAS,OACb,IACF;CACA,MAAM,mBAAmB,OAAuB,IAAI;CAEpD,MAAM,YAAY,aACf,SAAgC;EAC/B,OAAO,UAAU;EACjB,IAAI,OAAO,QAAQ,YAAY,IAAI,IAAI;OAClC,IAAI,KAAK,IAAuD,UAAU;CACjF,GACA,CAAC,GAAG,CACN;CAEA,gCAAgC;EAC9B,IAAI,CAAC,UAAU;EACf,MAAM,MAAM,OAAO;EACnB,MAAM,UAAU,iBAAiB;EACjC,IAAI,CAAC,OAAO,CAAC,SAAS;EAEtB,MAAM,UAAU,WAAW,IAAI;EAE/B,MAAM,eAAe;GACnB,IAAI,CAAC,QAAQ;IACX,MAAM,aAAa,KAAK,IAAI,GAAG,IAAI,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K,WAAW,cAAc;KAAI;KAAgB;IAAS,CAAC,CACrE,OAAO,OAAO,CAAC,CACf,KAAK,GAAG;IACX,OAAO;KACL;KACA,GAAG;KACH,iBAAiB;KACjB,GAAG;IACL;IACA,GAAI;IAEJ,UAAA,oBAAC,OAAD;KACE,WAAW;MACT;MACA,YAAY,UAAU,WAAW,2BAA2B;MAC5D,YAAY,UAAU,CAAC,WAAW,wBAAwB;KAC5D,CAAC,CACE,OAAO,OAAO,CAAC,CACf,KAAK,GAAG;KAEV,UAAA,OAAO,KAAK,MAAM,MACjB,oBAAC,OAAD;MAEE,GAAI,aAAa,EAAE,KAAK,CAAC;MACzB,OACE,WAAW;OAAE,YAAY;OAAY,WAAW;MAAY,IAAI,KAAA;MAGjE,UAAA,KAAK,KAAK,OAAO,QAChB,oBAAC,QAAD,EAAgB,GAAI,cAAc,EAAE,MAAM,CAAC,EAAI,GAApC,GAAoC,CAChD;KACE,GATE,CASF,CACN;IACE,CAAA;GACF,CAAA,GACJ,cACC,oBAAC,OAAD;IAAK,KAAK;IAAkB,WAAW;IACpC,UAAA;GACE,CAAA,CAEJ;;CAEE,CAAA;AAEf,CACF;AAEA,iBAAiB,cAAc"}
|
|
@@ -83,8 +83,8 @@ var TextField = react.default.forwardRef(({ state, clearable, label: LabelOrComp
|
|
|
83
83
|
const togglePasswordVisibility = react.default.useCallback(() => {
|
|
84
84
|
setInnerType((prevInnerType) => prevInnerType === "password" ? void 0 : "password");
|
|
85
85
|
}, [setInnerType]);
|
|
86
|
-
const EndAdornmentWrapper =
|
|
87
|
-
const PasswordVisibilityToggleIcon =
|
|
86
|
+
const EndAdornmentWrapper = hasAdornmentGroup ? AdornmentGroup : react.default.Fragment;
|
|
87
|
+
const PasswordVisibilityToggleIcon = isPasswordVisible ? StyledEyeClosedIcon : StyledEyeOpenIcon;
|
|
88
88
|
const passwordAction = react.default.useMemo(() => isPasswordVisible ? "Hide password" : "Show password", [isPasswordVisible]);
|
|
89
89
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_Box.Box, {
|
|
90
90
|
css,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextField.cjs","names":["styled","ExclamationTriangleIcon","EyeOpenIcon","EyeClosedIcon","CrossCircledIcon","React","Label","Box","Input","Tooltip"],"sources":["../../../components/TextField/TextField.tsx"],"sourcesContent":["import {\n CrossCircledIcon,\n ExclamationTriangleIcon,\n EyeClosedIcon,\n EyeOpenIcon,\n} from '@radix-ui/react-icons';\nimport React from 'react';\n\nimport { styled } from '../../stitches.config';\nimport { Box } from '../Box';\nimport { Input, InputHandle, InputProps, InputVariants } from '../Input';\nimport { Label } from '../Label';\nimport { Tooltip } from '../Tooltip';\n\n// TYPES\nexport interface TextFieldLabelProps {\n variant: 'invalid' | 'subtle' | 'contrast' | 'default';\n htmlFor?: string;\n}\nexport type TextFieldProps = InputProps & {\n type?: string;\n clearable?: boolean;\n label?: string | ((props: TextFieldLabelProps) => JSX.Element);\n};\n\nexport type TextFieldVariants = InputVariants;\n\n// COMPONENTS\nconst AdornmentGroup = styled('div', {\n display: 'flex',\n flexDirection: 'row',\n alignItems: 'center',\n});\n\nconst StyledExclamationTriangleIcon = styled(ExclamationTriangleIcon, {\n '& + *': {\n marginLeft: '$1',\n },\n});\n\nconst StyledEyeOpenIcon = styled(EyeOpenIcon, {\n '@hover': {\n '&:hover': {\n cursor: 'pointer',\n },\n },\n});\n\nconst StyledEyeClosedIcon = styled(EyeClosedIcon, {\n '@hover': {\n '&:hover': {\n cursor: 'pointer',\n },\n },\n});\n\nconst StyledCrossCircledIcon = styled(CrossCircledIcon, {\n '@hover': {\n '&:hover': {\n cursor: 'pointer',\n },\n },\n});\n\nexport const TextField = React.forwardRef<React.ElementRef<typeof Input>, TextFieldProps>(\n (\n {\n state,\n clearable,\n label: LabelOrComponent,\n id,\n type,\n disabled,\n readOnly,\n onBlur,\n onFocus,\n css,\n ...props\n },\n forwardedRef
|
|
1
|
+
{"version":3,"file":"TextField.cjs","names":["styled","ExclamationTriangleIcon","EyeOpenIcon","EyeClosedIcon","CrossCircledIcon","React","Label","Box","Input","Tooltip"],"sources":["../../../components/TextField/TextField.tsx"],"sourcesContent":["import {\n CrossCircledIcon,\n ExclamationTriangleIcon,\n EyeClosedIcon,\n EyeOpenIcon,\n} from '@radix-ui/react-icons';\nimport React from 'react';\n\nimport { styled } from '../../stitches.config';\nimport { Box } from '../Box';\nimport { Input, InputHandle, InputProps, InputVariants } from '../Input';\nimport { Label } from '../Label';\nimport { Tooltip } from '../Tooltip';\n\n// TYPES\nexport interface TextFieldLabelProps {\n variant: 'invalid' | 'subtle' | 'contrast' | 'default';\n htmlFor?: string;\n}\nexport type TextFieldProps = InputProps & {\n type?: string;\n clearable?: boolean;\n label?: string | ((props: TextFieldLabelProps) => JSX.Element);\n};\n\nexport type TextFieldVariants = InputVariants;\n\n// COMPONENTS\nconst AdornmentGroup = styled('div', {\n display: 'flex',\n flexDirection: 'row',\n alignItems: 'center',\n});\n\nconst StyledExclamationTriangleIcon = styled(ExclamationTriangleIcon, {\n '& + *': {\n marginLeft: '$1',\n },\n});\n\nconst StyledEyeOpenIcon = styled(EyeOpenIcon, {\n '@hover': {\n '&:hover': {\n cursor: 'pointer',\n },\n },\n});\n\nconst StyledEyeClosedIcon = styled(EyeClosedIcon, {\n '@hover': {\n '&:hover': {\n cursor: 'pointer',\n },\n },\n});\n\nconst StyledCrossCircledIcon = styled(CrossCircledIcon, {\n '@hover': {\n '&:hover': {\n cursor: 'pointer',\n },\n },\n});\n\nexport const TextField = React.forwardRef<React.ElementRef<typeof Input>, TextFieldProps>(\n (\n {\n state,\n clearable,\n label: LabelOrComponent,\n id,\n type,\n disabled,\n readOnly,\n onBlur,\n onFocus,\n css,\n ...props\n },\n forwardedRef,\n ) => {\n const inputRef = React.useRef<InputHandle | null>(null);\n React.useImperativeHandle(forwardedRef, () => inputRef.current as InputHandle);\n\n const [inputHasFocus, setInputHasFocus] = React.useState(false);\n const [innerType, setInnerType] = React.useState(type);\n const isPasswordVisible = React.useMemo(() => innerType !== 'password', [innerType]);\n\n const invalid = React.useMemo(() => state === 'invalid', [state]);\n\n const labelVariant = React.useMemo(() => {\n if (disabled) {\n return 'subtle';\n }\n if (invalid) {\n return 'invalid';\n }\n if (inputHasFocus) {\n return 'contrast';\n }\n return 'default';\n }, [invalid, disabled, inputHasFocus]);\n\n const LabelNode = React.useMemo(() => {\n if (LabelOrComponent === undefined || LabelOrComponent === null) {\n return null;\n }\n if (typeof LabelOrComponent === 'string') {\n return (\n <Label variant={labelVariant} htmlFor={id}>\n {LabelOrComponent}\n </Label>\n );\n }\n return <LabelOrComponent variant={labelVariant} htmlFor={id} />;\n }, [LabelOrComponent, labelVariant, id]);\n\n const isPasswordType = React.useMemo(() => type === 'password', [type]);\n\n const typeOrInnerType = React.useMemo(\n () => (isPasswordType ? innerType : type),\n [isPasswordType, type, innerType],\n );\n\n const hasInnerAdornment = React.useMemo(\n () => clearable || isPasswordType || invalid,\n [clearable, isPasswordType, invalid],\n );\n\n const hasAdornmentGroup = React.useMemo(\n () => (clearable && invalid) || (clearable && isPasswordType) || (invalid && isPasswordType),\n [clearable, invalid, isPasswordType],\n );\n\n const clearDisabled = React.useMemo(() => readOnly || disabled, [readOnly, disabled]);\n\n const handleClear = React.useCallback(() => {\n const { current } = inputRef;\n if (current) {\n current.clear();\n }\n }, [inputRef]);\n\n const handleFocus = React.useCallback(\n (e: React.FocusEvent<HTMLInputElement>) => {\n if (onFocus) {\n onFocus(e);\n }\n setInputHasFocus(true);\n },\n [onFocus, setInputHasFocus],\n );\n\n const handleBlur = React.useCallback(\n (e: React.FocusEvent<HTMLInputElement>) => {\n if (onBlur) {\n onBlur(e);\n }\n setInputHasFocus(false);\n },\n [onBlur, setInputHasFocus],\n );\n\n const togglePasswordVisibility = React.useCallback(() => {\n setInnerType((prevInnerType) => (prevInnerType === 'password' ? undefined : 'password'));\n }, [setInnerType]);\n\n const EndAdornmentWrapper = hasAdornmentGroup ? AdornmentGroup : React.Fragment;\n\n const PasswordVisibilityToggleIcon = isPasswordVisible\n ? StyledEyeClosedIcon\n : StyledEyeOpenIcon;\n\n const passwordAction = React.useMemo(\n () => (isPasswordVisible ? 'Hide password' : 'Show password'),\n [isPasswordVisible],\n );\n\n return (\n <Box css={css}>\n {LabelNode}\n <Input\n id={id}\n ref={inputRef}\n endAdornment={\n hasInnerAdornment && (\n <EndAdornmentWrapper>\n {invalid && <StyledExclamationTriangleIcon role=\"alert\" aria-label=\"Invalid\" />}\n {isPasswordType && (\n <Tooltip content={passwordAction}>\n <PasswordVisibilityToggleIcon\n aria-label={passwordAction}\n onClick={togglePasswordVisibility}\n />\n </Tooltip>\n )}\n {clearable && !clearDisabled && (\n <Tooltip content=\"Clear\">\n <StyledCrossCircledIcon aria-label=\"Clear\" onClick={handleClear} />\n </Tooltip>\n )}\n </EndAdornmentWrapper>\n )\n }\n state={state}\n type={typeOrInnerType}\n disabled={disabled}\n readOnly={readOnly}\n onFocus={handleFocus}\n onBlur={handleBlur}\n {...props}\n />\n </Box>\n );\n },\n);\n"],"mappings":";;;;;;;;;;;AA4BA,IAAM,iBAAiBA,wBAAAA,OAAO,OAAO;CACnC,SAAS;CACT,eAAe;CACf,YAAY;AACd,CAAC;AAED,IAAM,gCAAgCA,wBAAAA,OAAOC,sBAAAA,yBAAyB,EACpE,SAAS,EACP,YAAY,KACd,EACF,CAAC;AAED,IAAM,oBAAoBD,wBAAAA,OAAOE,sBAAAA,aAAa,EAC5C,UAAU,EACR,WAAW,EACT,QAAQ,UACV,EACF,EACF,CAAC;AAED,IAAM,sBAAsBF,wBAAAA,OAAOG,sBAAAA,eAAe,EAChD,UAAU,EACR,WAAW,EACT,QAAQ,UACV,EACF,EACF,CAAC;AAED,IAAM,yBAAyBH,wBAAAA,OAAOI,sBAAAA,kBAAkB,EACtD,UAAU,EACR,WAAW,EACT,QAAQ,UACV,EACF,EACF,CAAC;AAED,IAAa,YAAYC,MAAAA,QAAM,YAE3B,EACE,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AChB,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,8BAAD;MACE,cAAY;MACZ,SAAS;KACV,CAAA;IACM,CAAA;IAEV,aAAa,CAAC,iBACb,iBAAA,GAAA,kBAAA,IAAA,CAACA,gBAAAA,SAAD;KAAS,SAAQ;KACf,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,wBAAD;MAAwB,cAAW;MAAQ,SAAS;KAAc,CAAA;IAC3D,CAAA;GAEQ,EAAA,CAAA;GAGlB;GACP,MAAM;GACI;GACA;GACV,SAAS;GACT,QAAQ;GACR,GAAI;EACL,CAAA,CACE;;AAET,CACF"}
|
|
@@ -81,8 +81,8 @@ var TextField = React.forwardRef(({ state, clearable, label: LabelOrComponent, i
|
|
|
81
81
|
const togglePasswordVisibility = React.useCallback(() => {
|
|
82
82
|
setInnerType((prevInnerType) => prevInnerType === "password" ? void 0 : "password");
|
|
83
83
|
}, [setInnerType]);
|
|
84
|
-
const EndAdornmentWrapper =
|
|
85
|
-
const PasswordVisibilityToggleIcon =
|
|
84
|
+
const EndAdornmentWrapper = hasAdornmentGroup ? AdornmentGroup : React.Fragment;
|
|
85
|
+
const PasswordVisibilityToggleIcon = isPasswordVisible ? StyledEyeClosedIcon : StyledEyeOpenIcon;
|
|
86
86
|
const passwordAction = React.useMemo(() => isPasswordVisible ? "Hide password" : "Show password", [isPasswordVisible]);
|
|
87
87
|
return /* @__PURE__ */ jsxs(Box, {
|
|
88
88
|
css,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextField.js","names":[],"sources":["../../../components/TextField/TextField.tsx"],"sourcesContent":["import {\n CrossCircledIcon,\n ExclamationTriangleIcon,\n EyeClosedIcon,\n EyeOpenIcon,\n} from '@radix-ui/react-icons';\nimport React from 'react';\n\nimport { styled } from '../../stitches.config';\nimport { Box } from '../Box';\nimport { Input, InputHandle, InputProps, InputVariants } from '../Input';\nimport { Label } from '../Label';\nimport { Tooltip } from '../Tooltip';\n\n// TYPES\nexport interface TextFieldLabelProps {\n variant: 'invalid' | 'subtle' | 'contrast' | 'default';\n htmlFor?: string;\n}\nexport type TextFieldProps = InputProps & {\n type?: string;\n clearable?: boolean;\n label?: string | ((props: TextFieldLabelProps) => JSX.Element);\n};\n\nexport type TextFieldVariants = InputVariants;\n\n// COMPONENTS\nconst AdornmentGroup = styled('div', {\n display: 'flex',\n flexDirection: 'row',\n alignItems: 'center',\n});\n\nconst StyledExclamationTriangleIcon = styled(ExclamationTriangleIcon, {\n '& + *': {\n marginLeft: '$1',\n },\n});\n\nconst StyledEyeOpenIcon = styled(EyeOpenIcon, {\n '@hover': {\n '&:hover': {\n cursor: 'pointer',\n },\n },\n});\n\nconst StyledEyeClosedIcon = styled(EyeClosedIcon, {\n '@hover': {\n '&:hover': {\n cursor: 'pointer',\n },\n },\n});\n\nconst StyledCrossCircledIcon = styled(CrossCircledIcon, {\n '@hover': {\n '&:hover': {\n cursor: 'pointer',\n },\n },\n});\n\nexport const TextField = React.forwardRef<React.ElementRef<typeof Input>, TextFieldProps>(\n (\n {\n state,\n clearable,\n label: LabelOrComponent,\n id,\n type,\n disabled,\n readOnly,\n onBlur,\n onFocus,\n css,\n ...props\n },\n forwardedRef
|
|
1
|
+
{"version":3,"file":"TextField.js","names":[],"sources":["../../../components/TextField/TextField.tsx"],"sourcesContent":["import {\n CrossCircledIcon,\n ExclamationTriangleIcon,\n EyeClosedIcon,\n EyeOpenIcon,\n} from '@radix-ui/react-icons';\nimport React from 'react';\n\nimport { styled } from '../../stitches.config';\nimport { Box } from '../Box';\nimport { Input, InputHandle, InputProps, InputVariants } from '../Input';\nimport { Label } from '../Label';\nimport { Tooltip } from '../Tooltip';\n\n// TYPES\nexport interface TextFieldLabelProps {\n variant: 'invalid' | 'subtle' | 'contrast' | 'default';\n htmlFor?: string;\n}\nexport type TextFieldProps = InputProps & {\n type?: string;\n clearable?: boolean;\n label?: string | ((props: TextFieldLabelProps) => JSX.Element);\n};\n\nexport type TextFieldVariants = InputVariants;\n\n// COMPONENTS\nconst AdornmentGroup = styled('div', {\n display: 'flex',\n flexDirection: 'row',\n alignItems: 'center',\n});\n\nconst StyledExclamationTriangleIcon = styled(ExclamationTriangleIcon, {\n '& + *': {\n marginLeft: '$1',\n },\n});\n\nconst StyledEyeOpenIcon = styled(EyeOpenIcon, {\n '@hover': {\n '&:hover': {\n cursor: 'pointer',\n },\n },\n});\n\nconst StyledEyeClosedIcon = styled(EyeClosedIcon, {\n '@hover': {\n '&:hover': {\n cursor: 'pointer',\n },\n },\n});\n\nconst StyledCrossCircledIcon = styled(CrossCircledIcon, {\n '@hover': {\n '&:hover': {\n cursor: 'pointer',\n },\n },\n});\n\nexport const TextField = React.forwardRef<React.ElementRef<typeof Input>, TextFieldProps>(\n (\n {\n state,\n clearable,\n label: LabelOrComponent,\n id,\n type,\n disabled,\n readOnly,\n onBlur,\n onFocus,\n css,\n ...props\n },\n forwardedRef,\n ) => {\n const inputRef = React.useRef<InputHandle | null>(null);\n React.useImperativeHandle(forwardedRef, () => inputRef.current as InputHandle);\n\n const [inputHasFocus, setInputHasFocus] = React.useState(false);\n const [innerType, setInnerType] = React.useState(type);\n const isPasswordVisible = React.useMemo(() => innerType !== 'password', [innerType]);\n\n const invalid = React.useMemo(() => state === 'invalid', [state]);\n\n const labelVariant = React.useMemo(() => {\n if (disabled) {\n return 'subtle';\n }\n if (invalid) {\n return 'invalid';\n }\n if (inputHasFocus) {\n return 'contrast';\n }\n return 'default';\n }, [invalid, disabled, inputHasFocus]);\n\n const LabelNode = React.useMemo(() => {\n if (LabelOrComponent === undefined || LabelOrComponent === null) {\n return null;\n }\n if (typeof LabelOrComponent === 'string') {\n return (\n <Label variant={labelVariant} htmlFor={id}>\n {LabelOrComponent}\n </Label>\n );\n }\n return <LabelOrComponent variant={labelVariant} htmlFor={id} />;\n }, [LabelOrComponent, labelVariant, id]);\n\n const isPasswordType = React.useMemo(() => type === 'password', [type]);\n\n const typeOrInnerType = React.useMemo(\n () => (isPasswordType ? innerType : type),\n [isPasswordType, type, innerType],\n );\n\n const hasInnerAdornment = React.useMemo(\n () => clearable || isPasswordType || invalid,\n [clearable, isPasswordType, invalid],\n );\n\n const hasAdornmentGroup = React.useMemo(\n () => (clearable && invalid) || (clearable && isPasswordType) || (invalid && isPasswordType),\n [clearable, invalid, isPasswordType],\n );\n\n const clearDisabled = React.useMemo(() => readOnly || disabled, [readOnly, disabled]);\n\n const handleClear = React.useCallback(() => {\n const { current } = inputRef;\n if (current) {\n current.clear();\n }\n }, [inputRef]);\n\n const handleFocus = React.useCallback(\n (e: React.FocusEvent<HTMLInputElement>) => {\n if (onFocus) {\n onFocus(e);\n }\n setInputHasFocus(true);\n },\n [onFocus, setInputHasFocus],\n );\n\n const handleBlur = React.useCallback(\n (e: React.FocusEvent<HTMLInputElement>) => {\n if (onBlur) {\n onBlur(e);\n }\n setInputHasFocus(false);\n },\n [onBlur, setInputHasFocus],\n );\n\n const togglePasswordVisibility = React.useCallback(() => {\n setInnerType((prevInnerType) => (prevInnerType === 'password' ? undefined : 'password'));\n }, [setInnerType]);\n\n const EndAdornmentWrapper = hasAdornmentGroup ? AdornmentGroup : React.Fragment;\n\n const PasswordVisibilityToggleIcon = isPasswordVisible\n ? StyledEyeClosedIcon\n : StyledEyeOpenIcon;\n\n const passwordAction = React.useMemo(\n () => (isPasswordVisible ? 'Hide password' : 'Show password'),\n [isPasswordVisible],\n );\n\n return (\n <Box css={css}>\n {LabelNode}\n <Input\n id={id}\n ref={inputRef}\n endAdornment={\n hasInnerAdornment && (\n <EndAdornmentWrapper>\n {invalid && <StyledExclamationTriangleIcon role=\"alert\" aria-label=\"Invalid\" />}\n {isPasswordType && (\n <Tooltip content={passwordAction}>\n <PasswordVisibilityToggleIcon\n aria-label={passwordAction}\n onClick={togglePasswordVisibility}\n />\n </Tooltip>\n )}\n {clearable && !clearDisabled && (\n <Tooltip content=\"Clear\">\n <StyledCrossCircledIcon aria-label=\"Clear\" onClick={handleClear} />\n </Tooltip>\n )}\n </EndAdornmentWrapper>\n )\n }\n state={state}\n type={typeOrInnerType}\n disabled={disabled}\n readOnly={readOnly}\n onFocus={handleFocus}\n onBlur={handleBlur}\n {...props}\n />\n </Box>\n );\n },\n);\n"],"mappings":";;;;;;;;;AA4BA,IAAM,iBAAiB,OAAO,OAAO;CACnC,SAAS;CACT,eAAe;CACf,YAAY;AACd,CAAC;AAED,IAAM,gCAAgC,OAAO,yBAAyB,EACpE,SAAS,EACP,YAAY,KACd,EACF,CAAC;AAED,IAAM,oBAAoB,OAAO,aAAa,EAC5C,UAAU,EACR,WAAW,EACT,QAAQ,UACV,EACF,EACF,CAAC;AAED,IAAM,sBAAsB,OAAO,eAAe,EAChD,UAAU,EACR,WAAW,EACT,QAAQ,UACV,EACF,EACF,CAAC;AAED,IAAM,yBAAyB,OAAO,kBAAkB,EACtD,UAAU,EACR,WAAW,EACT,QAAQ,UACV,EACF,EACF,CAAC;AAED,IAAa,YAAY,MAAM,YAE3B,EACE,OACA,WACA,OAAO,kBACP,IACA,MACA,UACA,UACA,QACA,SACA,KACA,GAAG,SAEL,iBACG;CACH,MAAM,WAAW,MAAM,OAA2B,IAAI;CACtD,MAAM,oBAAoB,oBAAoB,SAAS,OAAsB;CAE7E,MAAM,CAAC,eAAe,oBAAoB,MAAM,SAAS,KAAK;CAC9D,MAAM,CAAC,WAAW,gBAAgB,MAAM,SAAS,IAAI;CACrD,MAAM,oBAAoB,MAAM,cAAc,cAAc,YAAY,CAAC,SAAS,CAAC;CAEnF,MAAM,UAAU,MAAM,cAAc,UAAU,WAAW,CAAC,KAAK,CAAC;CAEhE,MAAM,eAAe,MAAM,cAAc;EACvC,IAAI,UACF,OAAO;EAET,IAAI,SACF,OAAO;EAET,IAAI,eACF,OAAO;EAET,OAAO;CACT,GAAG;EAAC;EAAS;EAAU;CAAa,CAAC;CAErC,MAAM,YAAY,MAAM,cAAc;EACpC,IAAI,qBAAqB,KAAA,KAAa,qBAAqB,MACzD,OAAO;EAET,IAAI,OAAO,qB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iB,CACpB;CAEA,OACE,qBAAC,KAAD;EAAU;EAAV,UAAA,CACG,WACD,oBAAC,OAAD;GACM;GACJ,KAAK;GACL,cACE,qBACE,qBAAC,qBAAD,EAAA,UAAA;IACG,WAAW,oBAAC,+BAAD;KAA+B,MAAK;KAAQ,cAAW;IAAW,CAAA;IAC7E,kBACC,oBAAC,SAAD;KAAS,SAAS;KAChB,UAAA,oBAAC,8BAAD;MACE,cAAY;MACZ,SAAS;KACV,CAAA;IACM,CAAA;IAEV,aAAa,CAAC,iBACb,oBAAC,SAAD;KAAS,SAAQ;KACf,UAAA,oBAAC,wBAAD;MAAwB,cAAW;MAAQ,SAAS;KAAc,CAAA;IAC3D,CAAA;GAEQ,EAAA,CAAA;GAGlB;GACP,MAAM;GACI;GACA;GACV,SAAS;GACT,QAAQ;GACR,GAAI;EACL,CAAA,CACE;;AAET,CACF"}
|
|
@@ -83,8 +83,8 @@ var TextFieldVanilla = react.default.forwardRef(({ state, clearable, label: Labe
|
|
|
83
83
|
const togglePasswordVisibility = react.default.useCallback(() => {
|
|
84
84
|
setInnerType((prevInnerType) => prevInnerType === "password" ? void 0 : "password");
|
|
85
85
|
}, [setInnerType]);
|
|
86
|
-
const EndAdornmentWrapper =
|
|
87
|
-
const PasswordVisibilityToggleIcon =
|
|
86
|
+
const EndAdornmentWrapper = hasAdornmentGroup ? AdornmentGroup : react.default.Fragment;
|
|
87
|
+
const PasswordVisibilityToggleIcon = isPasswordVisible ? StyledEyeClosedIcon : StyledEyeOpenIcon;
|
|
88
88
|
const passwordAction = react.default.useMemo(() => isPasswordVisible ? "Hide password" : "Show password", [isPasswordVisible]);
|
|
89
89
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_Box_vanilla.BoxVanilla, {
|
|
90
90
|
css,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextField.vanilla.cjs","names":["styled","ExclamationTriangleIcon","EyeOpenIcon","EyeClosedIcon","CrossCircledIcon","React","LabelVanilla","BoxVanilla","InputVanilla","Tooltip"],"sources":["../../../components/TextField/TextField.vanilla.tsx"],"sourcesContent":["import {\n CrossCircledIcon,\n ExclamationTriangleIcon,\n EyeClosedIcon,\n EyeOpenIcon,\n} from '@radix-ui/react-icons';\nimport React from 'react';\n\nimport { styled } from '../../stitches.config';\nimport { BoxVanilla } from '../Box';\nimport { InputVanilla, InputVanillaHandle, InputVanillaProps } from '../Input';\nimport { LabelVanilla } from '../Label';\nimport { Tooltip } from '../Tooltip';\n\n// TYPES\nexport interface TextFieldLabelProps {\n variant: 'invalid' | 'subtle' | 'contrast' | 'default';\n htmlFor?: string;\n}\n\nexport type TextFieldVanillaProps = InputVanillaProps & {\n type?: string;\n clearable?: boolean;\n label?: string | ((props: TextFieldLabelProps) => JSX.Element);\n};\n\n// COMPONENTS\nconst AdornmentGroup = styled('div', {\n display: 'flex',\n flexDirection: 'row',\n alignItems: 'center',\n});\n\nconst StyledExclamationTriangleIcon = styled(ExclamationTriangleIcon, {\n '& + *': {\n marginLeft: '$1',\n },\n});\n\nconst StyledEyeOpenIcon = styled(EyeOpenIcon, {\n '@hover': {\n '&:hover': {\n cursor: 'pointer',\n },\n },\n});\n\nconst StyledEyeClosedIcon = styled(EyeClosedIcon, {\n '@hover': {\n '&:hover': {\n cursor: 'pointer',\n },\n },\n});\n\nconst StyledCrossCircledIcon = styled(CrossCircledIcon, {\n '@hover': {\n '&:hover': {\n cursor: 'pointer',\n },\n },\n});\n\nexport const TextFieldVanilla = React.forwardRef<\n React.ElementRef<typeof InputVanilla>,\n TextFieldVanillaProps\n>(\n (\n {\n state,\n clearable,\n label: LabelOrComponent,\n id,\n type,\n disabled,\n readOnly,\n onBlur,\n onFocus,\n css,\n ...props\n },\n forwardedRef,\n ) => {\n const inputRef = React.useRef<InputVanillaHandle | null>(null);\n React.useImperativeHandle(forwardedRef, () => inputRef.current as InputVanillaHandle);\n\n const [inputHasFocus, setInputHasFocus] = React.useState(false);\n const [innerType, setInnerType] = React.useState(type);\n const isPasswordVisible = React.useMemo(() => innerType !== 'password', [innerType]);\n\n const invalid = React.useMemo(() => state === 'invalid', [state]);\n\n const labelVariant = React.useMemo(() => {\n if (disabled) {\n return 'subtle';\n }\n if (invalid) {\n return 'invalid';\n }\n if (inputHasFocus) {\n return 'contrast';\n }\n return 'default';\n }, [invalid, disabled, inputHasFocus]);\n\n const LabelNode = React.useMemo(() => {\n if (LabelOrComponent === undefined || LabelOrComponent === null) {\n return null;\n }\n if (typeof LabelOrComponent === 'string') {\n return (\n <LabelVanilla variant={labelVariant} htmlFor={id}>\n {LabelOrComponent}\n </LabelVanilla>\n );\n }\n return <LabelOrComponent variant={labelVariant} htmlFor={id} />;\n }, [LabelOrComponent, labelVariant, id]);\n\n const isPasswordType = React.useMemo(() => type === 'password', [type]);\n\n const typeOrInnerType = React.useMemo(\n () => (isPasswordType ? innerType : type),\n [isPasswordType, type, innerType],\n );\n\n const hasInnerAdornment = React.useMemo(\n () => clearable || isPasswordType || invalid,\n [clearable, isPasswordType, invalid],\n );\n\n const hasAdornmentGroup = React.useMemo(\n () => (clearable && invalid) || (clearable && isPasswordType) || (invalid && isPasswordType),\n [clearable, invalid, isPasswordType],\n );\n\n const clearDisabled = React.useMemo(() => readOnly || disabled, [readOnly, disabled]);\n\n const handleClear = React.useCallback(() => {\n const { current } = inputRef;\n if (current) {\n current.clear();\n }\n }, [inputRef]);\n\n const handleFocus = React.useCallback(\n (e: React.FocusEvent<HTMLInputElement>) => {\n if (onFocus) {\n onFocus(e);\n }\n setInputHasFocus(true);\n },\n [onFocus, setInputHasFocus],\n );\n\n const handleBlur = React.useCallback(\n (e: React.FocusEvent<HTMLInputElement>) => {\n if (onBlur) {\n onBlur(e);\n }\n setInputHasFocus(false);\n },\n [onBlur, setInputHasFocus],\n );\n\n const togglePasswordVisibility = React.useCallback(() => {\n setInnerType((prevInnerType) => (prevInnerType === 'password' ? undefined : 'password'));\n }, [setInnerType]);\n\n const EndAdornmentWrapper =
|
|
1
|
+
{"version":3,"file":"TextField.vanilla.cjs","names":["styled","ExclamationTriangleIcon","EyeOpenIcon","EyeClosedIcon","CrossCircledIcon","React","LabelVanilla","BoxVanilla","InputVanilla","Tooltip"],"sources":["../../../components/TextField/TextField.vanilla.tsx"],"sourcesContent":["import {\n CrossCircledIcon,\n ExclamationTriangleIcon,\n EyeClosedIcon,\n EyeOpenIcon,\n} from '@radix-ui/react-icons';\nimport React from 'react';\n\nimport { styled } from '../../stitches.config';\nimport { BoxVanilla } from '../Box';\nimport { InputVanilla, InputVanillaHandle, InputVanillaProps } from '../Input';\nimport { LabelVanilla } from '../Label';\nimport { Tooltip } from '../Tooltip';\n\n// TYPES\nexport interface TextFieldLabelProps {\n variant: 'invalid' | 'subtle' | 'contrast' | 'default';\n htmlFor?: string;\n}\n\nexport type TextFieldVanillaProps = InputVanillaProps & {\n type?: string;\n clearable?: boolean;\n label?: string | ((props: TextFieldLabelProps) => JSX.Element);\n};\n\n// COMPONENTS\nconst AdornmentGroup = styled('div', {\n display: 'flex',\n flexDirection: 'row',\n alignItems: 'center',\n});\n\nconst StyledExclamationTriangleIcon = styled(ExclamationTriangleIcon, {\n '& + *': {\n marginLeft: '$1',\n },\n});\n\nconst StyledEyeOpenIcon = styled(EyeOpenIcon, {\n '@hover': {\n '&:hover': {\n cursor: 'pointer',\n },\n },\n});\n\nconst StyledEyeClosedIcon = styled(EyeClosedIcon, {\n '@hover': {\n '&:hover': {\n cursor: 'pointer',\n },\n },\n});\n\nconst StyledCrossCircledIcon = styled(CrossCircledIcon, {\n '@hover': {\n '&:hover': {\n cursor: 'pointer',\n },\n },\n});\n\nexport const TextFieldVanilla = React.forwardRef<\n React.ElementRef<typeof InputVanilla>,\n TextFieldVanillaProps\n>(\n (\n {\n state,\n clearable,\n label: LabelOrComponent,\n id,\n type,\n disabled,\n readOnly,\n onBlur,\n onFocus,\n css,\n ...props\n },\n forwardedRef,\n ) => {\n const inputRef = React.useRef<InputVanillaHandle | null>(null);\n React.useImperativeHandle(forwardedRef, () => inputRef.current as InputVanillaHandle);\n\n const [inputHasFocus, setInputHasFocus] = React.useState(false);\n const [innerType, setInnerType] = React.useState(type);\n const isPasswordVisible = React.useMemo(() => innerType !== 'password', [innerType]);\n\n const invalid = React.useMemo(() => state === 'invalid', [state]);\n\n const labelVariant = React.useMemo(() => {\n if (disabled) {\n return 'subtle';\n }\n if (invalid) {\n return 'invalid';\n }\n if (inputHasFocus) {\n return 'contrast';\n }\n return 'default';\n }, [invalid, disabled, inputHasFocus]);\n\n const LabelNode = React.useMemo(() => {\n if (LabelOrComponent === undefined || LabelOrComponent === null) {\n return null;\n }\n if (typeof LabelOrComponent === 'string') {\n return (\n <LabelVanilla variant={labelVariant} htmlFor={id}>\n {LabelOrComponent}\n </LabelVanilla>\n );\n }\n return <LabelOrComponent variant={labelVariant} htmlFor={id} />;\n }, [LabelOrComponent, labelVariant, id]);\n\n const isPasswordType = React.useMemo(() => type === 'password', [type]);\n\n const typeOrInnerType = React.useMemo(\n () => (isPasswordType ? innerType : type),\n [isPasswordType, type, innerType],\n );\n\n const hasInnerAdornment = React.useMemo(\n () => clearable || isPasswordType || invalid,\n [clearable, isPasswordType, invalid],\n );\n\n const hasAdornmentGroup = React.useMemo(\n () => (clearable && invalid) || (clearable && isPasswordType) || (invalid && isPasswordType),\n [clearable, invalid, isPasswordType],\n );\n\n const clearDisabled = React.useMemo(() => readOnly || disabled, [readOnly, disabled]);\n\n const handleClear = React.useCallback(() => {\n const { current } = inputRef;\n if (current) {\n current.clear();\n }\n }, [inputRef]);\n\n const handleFocus = React.useCallback(\n (e: React.FocusEvent<HTMLInputElement>) => {\n if (onFocus) {\n onFocus(e);\n }\n setInputHasFocus(true);\n },\n [onFocus, setInputHasFocus],\n );\n\n const handleBlur = React.useCallback(\n (e: React.FocusEvent<HTMLInputElement>) => {\n if (onBlur) {\n onBlur(e);\n }\n setInputHasFocus(false);\n },\n [onBlur, setInputHasFocus],\n );\n\n const togglePasswordVisibility = React.useCallback(() => {\n setInnerType((prevInnerType) => (prevInnerType === 'password' ? undefined : 'password'));\n }, [setInnerType]);\n\n const EndAdornmentWrapper = hasAdornmentGroup ? AdornmentGroup : React.Fragment;\n\n const PasswordVisibilityToggleIcon = isPasswordVisible\n ? StyledEyeClosedIcon\n : StyledEyeOpenIcon;\n\n const passwordAction = React.useMemo(\n () => (isPasswordVisible ? 'Hide password' : 'Show password'),\n [isPasswordVisible],\n );\n\n return (\n <BoxVanilla css={css}>\n {LabelNode}\n <InputVanilla\n id={id}\n ref={inputRef}\n endAdornment={\n hasInnerAdornment && (\n <EndAdornmentWrapper>\n {invalid && <StyledExclamationTriangleIcon role=\"alert\" aria-label=\"Invalid\" />}\n {isPasswordType && (\n <Tooltip content={passwordAction}>\n <PasswordVisibilityToggleIcon\n aria-label={passwordAction}\n onClick={togglePasswordVisibility}\n />\n </Tooltip>\n )}\n {clearable && !clearDisabled && (\n <Tooltip content=\"Clear\">\n <StyledCrossCircledIcon aria-label=\"Clear\" onClick={handleClear} />\n </Tooltip>\n )}\n </EndAdornmentWrapper>\n )\n }\n state={state}\n type={typeOrInnerType}\n disabled={disabled}\n readOnly={readOnly}\n onFocus={handleFocus}\n onBlur={handleBlur}\n {...props}\n />\n </BoxVanilla>\n );\n },\n);\n\nTextFieldVanilla.displayName = 'TextFieldVanilla';\n"],"mappings":";;;;;;;;;;;AA2BA,IAAM,iBAAiBA,wBAAAA,OAAO,OAAO;CACnC,SAAS;CACT,eAAe;CACf,YAAY;AACd,CAAC;AAED,IAAM,gCAAgCA,wBAAAA,OAAOC,sBAAAA,yBAAyB,EACpE,SAAS,EACP,YAAY,KACd,EACF,CAAC;AAED,IAAM,oBAAoBD,wBAAAA,OAAOE,sBAAAA,aAAa,EAC5C,UAAU,EACR,WAAW,EACT,QAAQ,UACV,EACF,EACF,CAAC;AAED,IAAM,sBAAsBF,wBAAAA,OAAOG,sBAAAA,eAAe,EAChD,UAAU,EACR,WAAW,EACT,QAAQ,UACV,EACF,EACF,CAAC;AAED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G,WAAW,iBAAA,GAAA,kBAAA,IAAA,CAAC,+BAAD;KAA+B,MAAK;KAAQ,cAAW;IAAW,CAAA;IAC7E,kBACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,gBAAAA,SAAD;KAAS,SAAS;KAChB,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,8BAAD;MACE,cAAY;MACZ,SAAS;KACV,CAAA;IACM,CAAA;IAEV,aAAa,CAAC,iBACb,iBAAA,GAAA,kBAAA,IAAA,CAACA,gBAAAA,SAAD;KAAS,SAAQ;KACf,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,wBAAD;MAAwB,cAAW;MAAQ,SAAS;KAAc,CAAA;IAC3D,CAAA;GAEQ,EAAA,CAAA;GAGlB;GACP,MAAM;GACI;GACA;GACV,SAAS;GACT,QAAQ;GACR,GAAI;EACL,CAAA,CACS;;AAEhB,CACF;AAEA,iBAAiB,cAAc"}
|
|
@@ -81,8 +81,8 @@ var TextFieldVanilla = React.forwardRef(({ state, clearable, label: LabelOrCompo
|
|
|
81
81
|
const togglePasswordVisibility = React.useCallback(() => {
|
|
82
82
|
setInnerType((prevInnerType) => prevInnerType === "password" ? void 0 : "password");
|
|
83
83
|
}, [setInnerType]);
|
|
84
|
-
const EndAdornmentWrapper =
|
|
85
|
-
const PasswordVisibilityToggleIcon =
|
|
84
|
+
const EndAdornmentWrapper = hasAdornmentGroup ? AdornmentGroup : React.Fragment;
|
|
85
|
+
const PasswordVisibilityToggleIcon = isPasswordVisible ? StyledEyeClosedIcon : StyledEyeOpenIcon;
|
|
86
86
|
const passwordAction = React.useMemo(() => isPasswordVisible ? "Hide password" : "Show password", [isPasswordVisible]);
|
|
87
87
|
return /* @__PURE__ */ jsxs(BoxVanilla, {
|
|
88
88
|
css,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextField.vanilla.js","names":[],"sources":["../../../components/TextField/TextField.vanilla.tsx"],"sourcesContent":["import {\n CrossCircledIcon,\n ExclamationTriangleIcon,\n EyeClosedIcon,\n EyeOpenIcon,\n} from '@radix-ui/react-icons';\nimport React from 'react';\n\nimport { styled } from '../../stitches.config';\nimport { BoxVanilla } from '../Box';\nimport { InputVanilla, InputVanillaHandle, InputVanillaProps } from '../Input';\nimport { LabelVanilla } from '../Label';\nimport { Tooltip } from '../Tooltip';\n\n// TYPES\nexport interface TextFieldLabelProps {\n variant: 'invalid' | 'subtle' | 'contrast' | 'default';\n htmlFor?: string;\n}\n\nexport type TextFieldVanillaProps = InputVanillaProps & {\n type?: string;\n clearable?: boolean;\n label?: string | ((props: TextFieldLabelProps) => JSX.Element);\n};\n\n// COMPONENTS\nconst AdornmentGroup = styled('div', {\n display: 'flex',\n flexDirection: 'row',\n alignItems: 'center',\n});\n\nconst StyledExclamationTriangleIcon = styled(ExclamationTriangleIcon, {\n '& + *': {\n marginLeft: '$1',\n },\n});\n\nconst StyledEyeOpenIcon = styled(EyeOpenIcon, {\n '@hover': {\n '&:hover': {\n cursor: 'pointer',\n },\n },\n});\n\nconst StyledEyeClosedIcon = styled(EyeClosedIcon, {\n '@hover': {\n '&:hover': {\n cursor: 'pointer',\n },\n },\n});\n\nconst StyledCrossCircledIcon = styled(CrossCircledIcon, {\n '@hover': {\n '&:hover': {\n cursor: 'pointer',\n },\n },\n});\n\nexport const TextFieldVanilla = React.forwardRef<\n React.ElementRef<typeof InputVanilla>,\n TextFieldVanillaProps\n>(\n (\n {\n state,\n clearable,\n label: LabelOrComponent,\n id,\n type,\n disabled,\n readOnly,\n onBlur,\n onFocus,\n css,\n ...props\n },\n forwardedRef,\n ) => {\n const inputRef = React.useRef<InputVanillaHandle | null>(null);\n React.useImperativeHandle(forwardedRef, () => inputRef.current as InputVanillaHandle);\n\n const [inputHasFocus, setInputHasFocus] = React.useState(false);\n const [innerType, setInnerType] = React.useState(type);\n const isPasswordVisible = React.useMemo(() => innerType !== 'password', [innerType]);\n\n const invalid = React.useMemo(() => state === 'invalid', [state]);\n\n const labelVariant = React.useMemo(() => {\n if (disabled) {\n return 'subtle';\n }\n if (invalid) {\n return 'invalid';\n }\n if (inputHasFocus) {\n return 'contrast';\n }\n return 'default';\n }, [invalid, disabled, inputHasFocus]);\n\n const LabelNode = React.useMemo(() => {\n if (LabelOrComponent === undefined || LabelOrComponent === null) {\n return null;\n }\n if (typeof LabelOrComponent === 'string') {\n return (\n <LabelVanilla variant={labelVariant} htmlFor={id}>\n {LabelOrComponent}\n </LabelVanilla>\n );\n }\n return <LabelOrComponent variant={labelVariant} htmlFor={id} />;\n }, [LabelOrComponent, labelVariant, id]);\n\n const isPasswordType = React.useMemo(() => type === 'password', [type]);\n\n const typeOrInnerType = React.useMemo(\n () => (isPasswordType ? innerType : type),\n [isPasswordType, type, innerType],\n );\n\n const hasInnerAdornment = React.useMemo(\n () => clearable || isPasswordType || invalid,\n [clearable, isPasswordType, invalid],\n );\n\n const hasAdornmentGroup = React.useMemo(\n () => (clearable && invalid) || (clearable && isPasswordType) || (invalid && isPasswordType),\n [clearable, invalid, isPasswordType],\n );\n\n const clearDisabled = React.useMemo(() => readOnly || disabled, [readOnly, disabled]);\n\n const handleClear = React.useCallback(() => {\n const { current } = inputRef;\n if (current) {\n current.clear();\n }\n }, [inputRef]);\n\n const handleFocus = React.useCallback(\n (e: React.FocusEvent<HTMLInputElement>) => {\n if (onFocus) {\n onFocus(e);\n }\n setInputHasFocus(true);\n },\n [onFocus, setInputHasFocus],\n );\n\n const handleBlur = React.useCallback(\n (e: React.FocusEvent<HTMLInputElement>) => {\n if (onBlur) {\n onBlur(e);\n }\n setInputHasFocus(false);\n },\n [onBlur, setInputHasFocus],\n );\n\n const togglePasswordVisibility = React.useCallback(() => {\n setInnerType((prevInnerType) => (prevInnerType === 'password' ? undefined : 'password'));\n }, [setInnerType]);\n\n const EndAdornmentWrapper =
|
|
1
|
+
{"version":3,"file":"TextField.vanilla.js","names":[],"sources":["../../../components/TextField/TextField.vanilla.tsx"],"sourcesContent":["import {\n CrossCircledIcon,\n ExclamationTriangleIcon,\n EyeClosedIcon,\n EyeOpenIcon,\n} from '@radix-ui/react-icons';\nimport React from 'react';\n\nimport { styled } from '../../stitches.config';\nimport { BoxVanilla } from '../Box';\nimport { InputVanilla, InputVanillaHandle, InputVanillaProps } from '../Input';\nimport { LabelVanilla } from '../Label';\nimport { Tooltip } from '../Tooltip';\n\n// TYPES\nexport interface TextFieldLabelProps {\n variant: 'invalid' | 'subtle' | 'contrast' | 'default';\n htmlFor?: string;\n}\n\nexport type TextFieldVanillaProps = InputVanillaProps & {\n type?: string;\n clearable?: boolean;\n label?: string | ((props: TextFieldLabelProps) => JSX.Element);\n};\n\n// COMPONENTS\nconst AdornmentGroup = styled('div', {\n display: 'flex',\n flexDirection: 'row',\n alignItems: 'center',\n});\n\nconst StyledExclamationTriangleIcon = styled(ExclamationTriangleIcon, {\n '& + *': {\n marginLeft: '$1',\n },\n});\n\nconst StyledEyeOpenIcon = styled(EyeOpenIcon, {\n '@hover': {\n '&:hover': {\n cursor: 'pointer',\n },\n },\n});\n\nconst StyledEyeClosedIcon = styled(EyeClosedIcon, {\n '@hover': {\n '&:hover': {\n cursor: 'pointer',\n },\n },\n});\n\nconst StyledCrossCircledIcon = styled(CrossCircledIcon, {\n '@hover': {\n '&:hover': {\n cursor: 'pointer',\n },\n },\n});\n\nexport const TextFieldVanilla = React.forwardRef<\n React.ElementRef<typeof InputVanilla>,\n TextFieldVanillaProps\n>(\n (\n {\n state,\n clearable,\n label: LabelOrComponent,\n id,\n type,\n disabled,\n readOnly,\n onBlur,\n onFocus,\n css,\n ...props\n },\n forwardedRef,\n ) => {\n const inputRef = React.useRef<InputVanillaHandle | null>(null);\n React.useImperativeHandle(forwardedRef, () => inputRef.current as InputVanillaHandle);\n\n const [inputHasFocus, setInputHasFocus] = React.useState(false);\n const [innerType, setInnerType] = React.useState(type);\n const isPasswordVisible = React.useMemo(() => innerType !== 'password', [innerType]);\n\n const invalid = React.useMemo(() => state === 'invalid', [state]);\n\n const labelVariant = React.useMemo(() => {\n if (disabled) {\n return 'subtle';\n }\n if (invalid) {\n return 'invalid';\n }\n if (inputHasFocus) {\n return 'contrast';\n }\n return 'default';\n }, [invalid, disabled, inputHasFocus]);\n\n const LabelNode = React.useMemo(() => {\n if (LabelOrComponent === undefined || LabelOrComponent === null) {\n return null;\n }\n if (typeof LabelOrComponent === 'string') {\n return (\n <LabelVanilla variant={labelVariant} htmlFor={id}>\n {LabelOrComponent}\n </LabelVanilla>\n );\n }\n return <LabelOrComponent variant={labelVariant} htmlFor={id} />;\n }, [LabelOrComponent, labelVariant, id]);\n\n const isPasswordType = React.useMemo(() => type === 'password', [type]);\n\n const typeOrInnerType = React.useMemo(\n () => (isPasswordType ? innerType : type),\n [isPasswordType, type, innerType],\n );\n\n const hasInnerAdornment = React.useMemo(\n () => clearable || isPasswordType || invalid,\n [clearable, isPasswordType, invalid],\n );\n\n const hasAdornmentGroup = React.useMemo(\n () => (clearable && invalid) || (clearable && isPasswordType) || (invalid && isPasswordType),\n [clearable, invalid, isPasswordType],\n );\n\n const clearDisabled = React.useMemo(() => readOnly || disabled, [readOnly, disabled]);\n\n const handleClear = React.useCallback(() => {\n const { current } = inputRef;\n if (current) {\n current.clear();\n }\n }, [inputRef]);\n\n const handleFocus = React.useCallback(\n (e: React.FocusEvent<HTMLInputElement>) => {\n if (onFocus) {\n onFocus(e);\n }\n setInputHasFocus(true);\n },\n [onFocus, setInputHasFocus],\n );\n\n const handleBlur = React.useCallback(\n (e: React.FocusEvent<HTMLInputElement>) => {\n if (onBlur) {\n onBlur(e);\n }\n setInputHasFocus(false);\n },\n [onBlur, setInputHasFocus],\n );\n\n const togglePasswordVisibility = React.useCallback(() => {\n setInnerType((prevInnerType) => (prevInnerType === 'password' ? undefined : 'password'));\n }, [setInnerType]);\n\n const EndAdornmentWrapper = hasAdornmentGroup ? AdornmentGroup : React.Fragment;\n\n const PasswordVisibilityToggleIcon = isPasswordVisible\n ? StyledEyeClosedIcon\n : StyledEyeOpenIcon;\n\n const passwordAction = React.useMemo(\n () => (isPasswordVisible ? 'Hide password' : 'Show password'),\n [isPasswordVisible],\n );\n\n return (\n <BoxVanilla css={css}>\n {LabelNode}\n <InputVanilla\n id={id}\n ref={inputRef}\n endAdornment={\n hasInnerAdornment && (\n <EndAdornmentWrapper>\n {invalid && <StyledExclamationTriangleIcon role=\"alert\" aria-label=\"Invalid\" />}\n {isPasswordType && (\n <Tooltip content={passwordAction}>\n <PasswordVisibilityToggleIcon\n aria-label={passwordAction}\n onClick={togglePasswordVisibility}\n />\n </Tooltip>\n )}\n {clearable && !clearDisabled && (\n <Tooltip content=\"Clear\">\n <StyledCrossCircledIcon aria-label=\"Clear\" onClick={handleClear} />\n </Tooltip>\n )}\n </EndAdornmentWrapper>\n )\n }\n state={state}\n type={typeOrInnerType}\n disabled={disabled}\n readOnly={readOnly}\n onFocus={handleFocus}\n onBlur={handleBlur}\n {...props}\n />\n </BoxVanilla>\n );\n },\n);\n\nTextFieldVanilla.displayName = 'TextFieldVanilla';\n"],"mappings":";;;;;;;;;AA2BA,IAAM,iBAAiB,OAAO,OAAO;CACnC,SAAS;CACT,eAAe;CACf,YAAY;AACd,CAAC;AAED,IAAM,gCAAgC,OAAO,yBAAyB,EACpE,SAAS,EACP,YAAY,KACd,EACF,CAAC;AAED,IAAM,oBAAoB,OAAO,aAAa,EAC5C,UAAU,EACR,WAAW,EACT,QAAQ,UACV,EACF,EACF,CAAC;AAED,IAAM,sBAAsB,OAAO,eAAe,EAChD,UAAU,EACR,WAAW,EACT,QAAQ,UACV,EACF,EACF,CAAC;AAED,IAAM,yBAAyB,OAAO,kBAAkB,EACtD,UAAU,EACR,WAAW,EACT,QAAQ,UACV,EACF,EACF,CAAC;AAED,IAAa,mBAAmB,MAAM,YAKlC,EACE,OACA,WACA,OAAO,kBACP,IACA,MACA,UACA,UACA,QACA,SACA,KACA,GAAG,SAEL,iBACG;CACH,MAAM,WAAW,MAAM,OAAkC,IAAI;CAC7D,MAAM,oBAAoB,oBAAoB,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ACvB,MAA0C;EACzC,IAAI,SACF,QAAQ,CAAC;EAEX,iBAAiB,IAAI;CACvB,GACA,CAAC,SAAS,gBAAgB,CAC5B;CAEA,MAAM,aAAa,MAAM,aACtB,MAA0C;EACzC,IAAI,QACF,OAAO,CAAC;EAEV,iBAAiB,KAAK;CACxB,GACA,CAAC,QAAQ,gBAAgB,CAC3B;CAEA,MAAM,2BAA2B,MAAM,kBAAkB;EACvD,cAAc,kBAAmB,kBAAkB,aAAa,KAAA,IAAY,UAAW;CACzF,GAAG,CAAC,YAAY,CAAC;CAEjB,MAAM,sBAAsB,oBAAoB,iBAAiB,MAAM;CAEvE,MAAM,+BAA+B,oBACjC,sBACA;CAEJ,MAAM,iBAAiB,MAAM,cACpB,oBAAoB,kBAAkB,iBAC7C,CAAC,iBAAiB,CACpB;CAEA,OACE,qBAAC,YAAD;EAAiB;EAAjB,UAAA,CACG,WACD,oBAAC,cAAD;GACM;GACJ,KAAK;GACL,cACE,qBACE,qBAAC,qBAAD,EAAA,UAAA;IACG,WAAW,oBAAC,+BAAD;KAA+B,MAAK;KAAQ,cAAW;IAAW,CAAA;IAC7E,kBACC,oBAAC,SAAD;KAAS,SAAS;KAChB,UAAA,oBAAC,8BAAD;MACE,cAAY;MACZ,SAAS;KACV,CAAA;IACM,CAAA;IAEV,aAAa,CAAC,iBACb,oBAAC,SAAD;KAAS,SAAQ;KACf,UAAA,oBAAC,wBAAD;MAAwB,cAAW;MAAQ,SAAS;KAAc,CAAA;IAC3D,CAAA;GAEQ,EAAA,CAAA;GAGlB;GACP,MAAM;GACI;GACA;GACV,SAAS;GACT,QAAQ;GACR,GAAI;EACL,CAAA,CACS;;AAEhB,CACF;AAEA,iBAAiB,cAAc"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
2
|
const require_index = require("../colors/index.cjs");
|
|
3
|
+
const require_useIsomorphicLayoutEffect = require("../utils/useIsomorphicLayoutEffect.cjs");
|
|
3
4
|
const require_themes_css = require("./themes.css.cjs");
|
|
4
5
|
let react = require("react");
|
|
5
6
|
react = require_runtime.__toESM(react, 1);
|
|
@@ -81,7 +82,7 @@ function VanillaExtractThemeProvider({ children, defaultTheme = "system", primar
|
|
|
81
82
|
...baseColors,
|
|
82
83
|
...semanticColors
|
|
83
84
|
};
|
|
84
|
-
|
|
85
|
+
require_useIsomorphicLayoutEffect.useIsomorphicLayoutEffect(() => {
|
|
85
86
|
const themeClass = require_themes_css.themes[resolvedTheme][appliedPrimaryColor];
|
|
86
87
|
Object.values(require_themes_css.themes.light).forEach((cls) => document.body.classList.remove(cls));
|
|
87
88
|
Object.values(require_themes_css.themes.dark).forEach((cls) => document.body.classList.remove(cls));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"themeContext.cjs","names":["createContext","useState","darkColors","lightColors","themes","useContext"],"sources":["../../styles/themeContext.tsx"],"sourcesContent":["import React, { createContext, useContext, useEffect,
|
|
1
|
+
{"version":3,"file":"themeContext.cjs","names":["createContext","useState","darkColors","lightColors","themes","useContext"],"sources":["../../styles/themeContext.tsx"],"sourcesContent":["import React, { createContext, useContext, useEffect, useState } from 'react';\n\nimport { darkColors, lightColors } from '../colors';\nimport { useIsomorphicLayoutEffect } from '../utils/useIsomorphicLayoutEffect';\nimport { PrimaryColor, themes } from './themes.css';\n\nexport type ThemeMode = 'light' | 'dark' | 'system';\nexport type { PrimaryColor };\n\ninterface ThemeContextValue {\n mode: ThemeMode;\n resolvedTheme: 'light' | 'dark';\n primaryColor: PrimaryColor;\n colors: typeof lightColors | typeof darkColors;\n setMode: (mode: ThemeMode) => void;\n setPrimaryColor: (color: PrimaryColor) => void;\n}\n\nconst ThemeContext = createContext<ThemeContextValue | undefined>(undefined);\n\ninterface VanillaExtractThemeProviderProps {\n children: React.ReactNode;\n defaultTheme?: ThemeMode;\n primaryColor?: PrimaryColor;\n forcedTheme?: 'light' | 'dark';\n}\n\nexport function VanillaExtractThemeProvider({\n children,\n defaultTheme = 'system',\n primaryColor = 'blue',\n forcedTheme,\n}: VanillaExtractThemeProviderProps) {\n const [mode, setMode] = useState<ThemeMode>(defaultTheme);\n const [appliedPrimaryColor, setPrimaryColor] = useState<PrimaryColor>(primaryColor);\n const [systemTheme, setSystemTheme] = useState<'light' | 'dark'>(() => {\n if (forcedTheme) {\n return forcedTheme;\n }\n if (typeof window !== 'undefined') {\n return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';\n }\n return 'light';\n });\n\n useEffect(() => {\n setPrimaryColor(primaryColor);\n }, [primaryColor]);\n\n useEffect(() => {\n if (forcedTheme) {\n setSystemTheme(forcedTheme);\n return;\n }\n\n const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');\n setSystemTheme(mediaQuery.matches ? 'dark' : 'light');\n\n const handler = (e: MediaQueryListEvent) => {\n setSystemTheme(e.matches ? 'dark' : 'light');\n };\n\n mediaQuery.addEventListener('change', handler);\n return () => mediaQuery.removeEventListener('change', handler);\n }, [forcedTheme]);\n\n const resolvedTheme: 'light' | 'dark' = forcedTheme || (mode === 'system' ? systemTheme : mode);\n\n const baseColors = resolvedTheme === 'dark' ? darkColors : lightColors;\n\n const semanticColors =\n resolvedTheme === 'dark'\n ? {\n primary: darkColors[`${appliedPrimaryColor}9`],\n contentBg: darkColors['00dp'],\n hiContrast: 'white',\n loContrast: darkColors.deepBlue2,\n focusOutline: 'hsl(216, 100%, 64%)',\n divider: 'hsl(209, 29%, 19%)',\n background: '#0a0a0a',\n foreground: '#ffffff',\n muted: '#1a1a1a',\n mutedForeground: '#b4b4b4',\n card: '#1a1a1a',\n cardForeground: '#ffffff',\n popover: '#1a1a1a',\n popoverForeground: '#ffffff',\n border: '#3a3a3a',\n input: '#3a3a3a',\n accent: '#3b82f6',\n accentForeground: '#ffffff',\n destructive: '#dc2626',\n destructiveForeground: '#ffffff',\n ring: '#60a5fa',\n }\n : {\n primary: lightColors[`${appliedPrimaryColor}9`],\n contentBg: lightColors['00dp'],\n hiContrast: lightColors.deepBlue11,\n loContrast: 'white',\n focusOutline: 'hsl(216, 100%, 64%)',\n divider: 'hsl(207, 10%, 82%)',\n background: '#fcfcfc',\n foreground: '#1a1a1a',\n muted: '#f4f4f4',\n mutedForeground: '#646464',\n card: '#ffffff',\n cardForeground: '#1a1a1a',\n popover: '#ffffff',\n popoverForeground: '#1a1a1a',\n border: '#e3e3e3',\n input: '#e3e3e3',\n accent: '#60a5fa',\n accentForeground: '#ffffff',\n destructive: '#dc2626',\n destructiveForeground: '#ffffff',\n ring: '#3b82f6',\n };\n\n const colors = {\n ...baseColors,\n ...semanticColors,\n };\n\n // Apply the theme class synchronously before paint\n useIsomorphicLayoutEffect(() => {\n const themeClass = themes[resolvedTheme][appliedPrimaryColor];\n\n Object.values(themes.light).forEach((cls) => document.body.classList.remove(cls));\n Object.values(themes.dark).forEach((cls) => document.body.classList.remove(cls));\n\n document.body.classList.add(themeClass);\n\n return () => {\n document.body.classList.remove(themeClass);\n };\n }, [resolvedTheme, appliedPrimaryColor]);\n\n const contextValue: ThemeContextValue = {\n mode,\n resolvedTheme,\n primaryColor: appliedPrimaryColor,\n colors,\n setMode,\n setPrimaryColor,\n };\n\n return <ThemeContext.Provider value={contextValue}>{children}</ThemeContext.Provider>;\n}\n\nexport function useVanillaExtractTheme() {\n const context = useContext(ThemeContext);\n if (context === undefined) {\n throw new Error('useVanillaExtractTheme must be used within a VanillaExtractThemeProvider');\n }\n return context;\n}\n"],"mappings":";;;;;;;;AAkBA,IAAM,gBAAA,GAAeA,MAAAA,cAAAA,CAA6C,KAAA,CAAS;AAS3E,SAAgB,4BAA4B,EAC1C,UACA,eAAe,UACf,eAAe,QACf,eACmC;CACnC,MAAM,CAAC,MAAM,YAAA,GAAWC,MAAAA,SAAAA,CAAoB,YAAY;CACxD,MAAM,CAAC,qBAAqB,oBAAA,GAAmBA,MAAAA,SAAAA,CAAuB,YAAY;CAClF,MAAM,CAAC,aAAa,mBAAA,GAAkBA,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B,SAAS;EACT,mBAAmB;EACnB,QAAQ;EACR,OAAO;EACP,QAAQ;EACR,kBAAkB;EAClB,aAAa;EACb,uBAAuB;EACvB,MAAM;CACR;CAEN,MAAM,SAAS;EACb,GAAG;EACH,GAAG;CACL;CAGA,kCAAA,gCAAgC;EAC9B,MAAM,aAAaC,mBAAAA,OAAO,cAAc,CAAC;EAEzC,OAAO,OAAOA,mBAAAA,OAAO,KAAK,CAAC,CAAC,SAAS,QAAQ,SAAS,KAAK,UAAU,OAAO,GAAG,CAAC;EAChF,OAAO,OAAOA,mBAAAA,OAAO,IAAI,CAAC,CAAC,SAAS,QAAQ,SAAS,KAAK,UAAU,OAAO,GAAG,CAAC;EAE/E,SAAS,KAAK,UAAU,IAAI,UAAU;EAEtC,aAAa;GACX,SAAS,KAAK,UAAU,OAAO,UAAU;EAC3C;CACF,GAAG,CAAC,eAAe,mBAAmB,CAAC;CAEvC,MAAM,eAAkC;EACtC;EACA;EACA,cAAc;EACd;EACA;EACA;CACF;CAEA,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAAC,aAAa,UAAd;EAAuB,OAAO;EAAe;CAAgC,CAAA;AACtF;AAEA,SAAgB,yBAAyB;CACvC,MAAM,WAAA,GAAUC,MAAAA,WAAAA,CAAW,YAAY;CACvC,IAAI,YAAY,KAAA,GACd,MAAM,IAAI,MAAM,0EAA0E;CAE5F,OAAO;AACT"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { darkColors, lightColors } from "../colors/index.js";
|
|
2
|
+
import { useIsomorphicLayoutEffect } from "../utils/useIsomorphicLayoutEffect.js";
|
|
2
3
|
import { themes } from "./themes.css.js";
|
|
3
|
-
import { createContext, useContext, useEffect,
|
|
4
|
+
import { createContext, useContext, useEffect, useState } from "react";
|
|
4
5
|
import { jsx } from "react/jsx-runtime";
|
|
5
6
|
// styles/themeContext.tsx
|
|
6
7
|
var ThemeContext = createContext(void 0);
|
|
@@ -79,7 +80,7 @@ function VanillaExtractThemeProvider({ children, defaultTheme = "system", primar
|
|
|
79
80
|
...baseColors,
|
|
80
81
|
...semanticColors
|
|
81
82
|
};
|
|
82
|
-
|
|
83
|
+
useIsomorphicLayoutEffect(() => {
|
|
83
84
|
const themeClass = themes[resolvedTheme][appliedPrimaryColor];
|
|
84
85
|
Object.values(themes.light).forEach((cls) => document.body.classList.remove(cls));
|
|
85
86
|
Object.values(themes.dark).forEach((cls) => document.body.classList.remove(cls));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"themeContext.js","names":[],"sources":["../../styles/themeContext.tsx"],"sourcesContent":["import React, { createContext, useContext, useEffect,
|
|
1
|
+
{"version":3,"file":"themeContext.js","names":[],"sources":["../../styles/themeContext.tsx"],"sourcesContent":["import React, { createContext, useContext, useEffect, useState } from 'react';\n\nimport { darkColors, lightColors } from '../colors';\nimport { useIsomorphicLayoutEffect } from '../utils/useIsomorphicLayoutEffect';\nimport { PrimaryColor, themes } from './themes.css';\n\nexport type ThemeMode = 'light' | 'dark' | 'system';\nexport type { PrimaryColor };\n\ninterface ThemeContextValue {\n mode: ThemeMode;\n resolvedTheme: 'light' | 'dark';\n primaryColor: PrimaryColor;\n colors: typeof lightColors | typeof darkColors;\n setMode: (mode: ThemeMode) => void;\n setPrimaryColor: (color: PrimaryColor) => void;\n}\n\nconst ThemeContext = createContext<ThemeContextValue | undefined>(undefined);\n\ninterface VanillaExtractThemeProviderProps {\n children: React.ReactNode;\n defaultTheme?: ThemeMode;\n primaryColor?: PrimaryColor;\n forcedTheme?: 'light' | 'dark';\n}\n\nexport function VanillaExtractThemeProvider({\n children,\n defaultTheme = 'system',\n primaryColor = 'blue',\n forcedTheme,\n}: VanillaExtractThemeProviderProps) {\n const [mode, setMode] = useState<ThemeMode>(defaultTheme);\n const [appliedPrimaryColor, setPrimaryColor] = useState<PrimaryColor>(primaryColor);\n const [systemTheme, setSystemTheme] = useState<'light' | 'dark'>(() => {\n if (forcedTheme) {\n return forcedTheme;\n }\n if (typeof window !== 'undefined') {\n return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';\n }\n return 'light';\n });\n\n useEffect(() => {\n setPrimaryColor(primaryColor);\n }, [primaryColor]);\n\n useEffect(() => {\n if (forcedTheme) {\n setSystemTheme(forcedTheme);\n return;\n }\n\n const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');\n setSystemTheme(mediaQuery.matches ? 'dark' : 'light');\n\n const handler = (e: MediaQueryListEvent) => {\n setSystemTheme(e.matches ? 'dark' : 'light');\n };\n\n mediaQuery.addEventListener('change', handler);\n return () => mediaQuery.removeEventListener('change', handler);\n }, [forcedTheme]);\n\n const resolvedTheme: 'light' | 'dark' = forcedTheme || (mode === 'system' ? systemTheme : mode);\n\n const baseColors = resolvedTheme === 'dark' ? darkColors : lightColors;\n\n const semanticColors =\n resolvedTheme === 'dark'\n ? {\n primary: darkColors[`${appliedPrimaryColor}9`],\n contentBg: darkColors['00dp'],\n hiContrast: 'white',\n loContrast: darkColors.deepBlue2,\n focusOutline: 'hsl(216, 100%, 64%)',\n divider: 'hsl(209, 29%, 19%)',\n background: '#0a0a0a',\n foreground: '#ffffff',\n muted: '#1a1a1a',\n mutedForeground: '#b4b4b4',\n card: '#1a1a1a',\n cardForeground: '#ffffff',\n popover: '#1a1a1a',\n popoverForeground: '#ffffff',\n border: '#3a3a3a',\n input: '#3a3a3a',\n accent: '#3b82f6',\n accentForeground: '#ffffff',\n destructive: '#dc2626',\n destructiveForeground: '#ffffff',\n ring: '#60a5fa',\n }\n : {\n primary: lightColors[`${appliedPrimaryColor}9`],\n contentBg: lightColors['00dp'],\n hiContrast: lightColors.deepBlue11,\n loContrast: 'white',\n focusOutline: 'hsl(216, 100%, 64%)',\n divider: 'hsl(207, 10%, 82%)',\n background: '#fcfcfc',\n foreground: '#1a1a1a',\n muted: '#f4f4f4',\n mutedForeground: '#646464',\n card: '#ffffff',\n cardForeground: '#1a1a1a',\n popover: '#ffffff',\n popoverForeground: '#1a1a1a',\n border: '#e3e3e3',\n input: '#e3e3e3',\n accent: '#60a5fa',\n accentForeground: '#ffffff',\n destructive: '#dc2626',\n destructiveForeground: '#ffffff',\n ring: '#3b82f6',\n };\n\n const colors = {\n ...baseColors,\n ...semanticColors,\n };\n\n // Apply the theme class synchronously before paint\n useIsomorphicLayoutEffect(() => {\n const themeClass = themes[resolvedTheme][appliedPrimaryColor];\n\n Object.values(themes.light).forEach((cls) => document.body.classList.remove(cls));\n Object.values(themes.dark).forEach((cls) => document.body.classList.remove(cls));\n\n document.body.classList.add(themeClass);\n\n return () => {\n document.body.classList.remove(themeClass);\n };\n }, [resolvedTheme, appliedPrimaryColor]);\n\n const contextValue: ThemeContextValue = {\n mode,\n resolvedTheme,\n primaryColor: appliedPrimaryColor,\n colors,\n setMode,\n setPrimaryColor,\n };\n\n return <ThemeContext.Provider value={contextValue}>{children}</ThemeContext.Provider>;\n}\n\nexport function useVanillaExtractTheme() {\n const context = useContext(ThemeContext);\n if (context === undefined) {\n throw new Error('useVanillaExtractTheme must be used within a VanillaExtractThemeProvider');\n }\n return context;\n}\n"],"mappings":";;;;;;AAkBA,IAAM,eAAe,cAA6C,KAAA,CAAS;AAS3E,SAAgB,4BAA4B,EAC1C,UACA,eAAe,UACf,eAAe,QACf,eACmC;CACnC,MAAM,CAAC,MAAM,WAAW,SAAoB,YAAY;CACxD,MAAM,CAAC,qBAAqB,mBAAmB,SAAuB,YAAY;CAClF,MAAM,CAAC,aAAa,kBAAkB,eAAiC;EACrE,IAAI,aACF,OAAO;EAET,IAAI,OAAO,WAAW,aACpB,OAAO,OAAO,WAAW,8BAA8B,CAAC,CAAC,UAAU,SAAS;EAE9E,OAAO;CACT,CAAC;CAED,gBAAgB;EACd,gBAAgB,YAAY;CAC9B,GAAG,CAAC,YAAY,CAAC;CAEjB,gBAAgB;EACd,IAAI,aAAa;GACf,eAAe,WAAW;GAC1B;EACF;EAEA,MAAM,aAAa,OAAO,WAAW,8BAA8B;EACnE,eAAe,WAAW,UAAU,SAA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SAAS,KAAK,UAAU,OAAO,UAAU;EAC3C;CACF,GAAG,CAAC,eAAe,mBAAmB,CAAC;CAEvC,MAAM,eAAkC;EACtC;EACA;EACA,cAAc;EACd;EACA;EACA;CACF;CAEA,OAAO,oBAAC,aAAa,UAAd;EAAuB,OAAO;EAAe;CAAgC,CAAA;AACtF;AAEA,SAAgB,yBAAyB;CACvC,MAAM,UAAU,WAAW,YAAY;CACvC,IAAI,YAAY,KAAA,GACd,MAAM,IAAI,MAAM,0EAA0E;CAE5F,OAAO;AACT"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
let react = require("react");
|
|
2
|
+
// utils/useIsomorphicLayoutEffect.ts
|
|
3
|
+
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? react.useLayoutEffect : react.useEffect;
|
|
4
|
+
exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect;
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=useIsomorphicLayoutEffect.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIsomorphicLayoutEffect.cjs","names":["useLayoutEffect","useEffect"],"sources":["../../utils/useIsomorphicLayoutEffect.ts"],"sourcesContent":["import { useEffect, useLayoutEffect } from 'react';\n\n// React 18 warns when useLayoutEffect runs during server rendering, where it does nothing anyway.\nexport const useIsomorphicLayoutEffect =\n typeof window !== 'undefined' ? useLayoutEffect : useEffect;\n"],"mappings":";;AAGA,IAAa,4BACX,OAAO,WAAW,cAAcA,MAAAA,kBAAkBC,MAAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { useEffect, useLayoutEffect } from "react";
|
|
2
|
+
// utils/useIsomorphicLayoutEffect.ts
|
|
3
|
+
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect;
|
|
4
|
+
export { useIsomorphicLayoutEffect };
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=useIsomorphicLayoutEffect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIsomorphicLayoutEffect.js","names":[],"sources":["../../utils/useIsomorphicLayoutEffect.ts"],"sourcesContent":["import { useEffect, useLayoutEffect } from 'react';\n\n// React 18 warns when useLayoutEffect runs during server rendering, where it does nothing anyway.\nexport const useIsomorphicLayoutEffect =\n typeof window !== 'undefined' ? useLayoutEffect : useEffect;\n"],"mappings":";;AAGA,IAAa,4BACX,OAAO,WAAW,cAAc,kBAAkB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@traefik-labs/faency",
|
|
3
3
|
"description": "Traefik Labs design system",
|
|
4
|
-
"version": "13.1.
|
|
4
|
+
"version": "13.1.1",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"traefiklabs",
|
|
@@ -95,16 +95,16 @@
|
|
|
95
95
|
"@babel/preset-env": "7.29.7",
|
|
96
96
|
"@babel/preset-react": "7.29.7",
|
|
97
97
|
"@babel/preset-typescript": "7.29.7",
|
|
98
|
-
"@eslint-react/eslint-plugin": "
|
|
98
|
+
"@eslint-react/eslint-plugin": "5.28.8",
|
|
99
99
|
"@eslint/js": "10.0.1",
|
|
100
100
|
"@semantic-release/commit-analyzer": "13.0.1",
|
|
101
101
|
"@semantic-release/github": "12.0.10",
|
|
102
102
|
"@semantic-release/npm": "13.2.0",
|
|
103
103
|
"@semantic-release/release-notes-generator": "14.1.1",
|
|
104
|
-
"@storybook/addon-docs": "10.6.
|
|
105
|
-
"@storybook/addon-links": "10.6.
|
|
106
|
-
"@storybook/builder-vite": "10.6.
|
|
107
|
-
"@storybook/react-vite": "10.6.
|
|
104
|
+
"@storybook/addon-docs": "10.6.5",
|
|
105
|
+
"@storybook/addon-links": "10.6.5",
|
|
106
|
+
"@storybook/builder-vite": "10.6.5",
|
|
107
|
+
"@storybook/react-vite": "10.6.5",
|
|
108
108
|
"@testing-library/dom": "10.4.2",
|
|
109
109
|
"@testing-library/jest-dom": "7.0.1",
|
|
110
110
|
"@testing-library/react": "16.3.3",
|
|
@@ -122,13 +122,13 @@
|
|
|
122
122
|
"babel-jest": "30.5.2",
|
|
123
123
|
"conventional-changelog-conventionalcommits": "9.3.1",
|
|
124
124
|
"cross-env": "10.1.0",
|
|
125
|
-
"eslint": "10.
|
|
125
|
+
"eslint": "10.14.0",
|
|
126
126
|
"eslint-config-prettier": "10.1.8",
|
|
127
127
|
"eslint-plugin-jsx-a11y": "6.10.2",
|
|
128
128
|
"eslint-plugin-prettier": "5.5.7",
|
|
129
129
|
"eslint-plugin-simple-import-sort": "14.0.0",
|
|
130
|
-
"eslint-plugin-storybook": "10.6.
|
|
131
|
-
"globals": "17.
|
|
130
|
+
"eslint-plugin-storybook": "10.6.5",
|
|
131
|
+
"globals": "17.14.0",
|
|
132
132
|
"husky": "9.1.7",
|
|
133
133
|
"jest": "30.5.2",
|
|
134
134
|
"jest-axe": "11.0.0",
|
|
@@ -139,18 +139,18 @@
|
|
|
139
139
|
"react": "18.3.1",
|
|
140
140
|
"react-dom": "18.3.1",
|
|
141
141
|
"semantic-release": "25.0.9",
|
|
142
|
-
"storybook": "10.6.
|
|
142
|
+
"storybook": "10.6.5",
|
|
143
143
|
"typescript": "5.8.3",
|
|
144
|
-
"typescript-eslint": "8.72.
|
|
144
|
+
"typescript-eslint": "8.72.1",
|
|
145
145
|
"vite": "8.3.5",
|
|
146
146
|
"vite-plugin-dts": "4.5.4"
|
|
147
147
|
},
|
|
148
148
|
"resolutions": {
|
|
149
|
-
"@typescript-eslint/tsconfig-utils": "8.72.
|
|
150
|
-
"@typescript-eslint/types": "8.72.
|
|
149
|
+
"@typescript-eslint/tsconfig-utils": "8.72.1",
|
|
150
|
+
"@typescript-eslint/types": "8.72.1",
|
|
151
151
|
"bundle-name": "4.1.1",
|
|
152
|
-
"magic-string@^1.1.0": "1.4.
|
|
153
|
-
"postcss": "8.5.
|
|
152
|
+
"magic-string@^1.1.0": "1.4.5",
|
|
153
|
+
"postcss": "8.5.32"
|
|
154
154
|
},
|
|
155
155
|
"publishConfig": {
|
|
156
156
|
"access": "public",
|