@traefik-labs/faency 13.7.1 → 13.7.2
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/README.md +1 -2
- package/dist/components/AriaTable/AriaTable.cjs +48 -22
- package/dist/components/AriaTable/AriaTable.cjs.map +1 -1
- package/dist/components/AriaTable/AriaTable.js +49 -23
- package/dist/components/AriaTable/AriaTable.js.map +1 -1
- package/dist/components/AriaTable/AriaTable.vanilla.cjs +8 -4
- package/dist/components/AriaTable/AriaTable.vanilla.cjs.map +1 -1
- package/dist/components/AriaTable/AriaTable.vanilla.js +8 -4
- package/dist/components/AriaTable/AriaTable.vanilla.js.map +1 -1
- package/dist/components/Avatar/Avatar.vanilla.cjs +5 -2
- package/dist/components/Avatar/Avatar.vanilla.cjs.map +1 -1
- package/dist/components/Avatar/Avatar.vanilla.js +5 -2
- package/dist/components/Avatar/Avatar.vanilla.js.map +1 -1
- package/dist/components/Badge/Badge.vanilla.cjs +2 -10
- package/dist/components/Badge/Badge.vanilla.cjs.map +1 -1
- package/dist/components/Badge/Badge.vanilla.js +2 -10
- package/dist/components/Badge/Badge.vanilla.js.map +1 -1
- package/dist/components/Blockquote/Blockquote.vanilla.cjs +5 -11
- package/dist/components/Blockquote/Blockquote.vanilla.cjs.map +1 -1
- package/dist/components/Blockquote/Blockquote.vanilla.js +5 -11
- package/dist/components/Blockquote/Blockquote.vanilla.js.map +1 -1
- package/dist/components/Box/Box.vanilla.cjs +2 -10
- package/dist/components/Box/Box.vanilla.cjs.map +1 -1
- package/dist/components/Box/Box.vanilla.js +2 -10
- package/dist/components/Box/Box.vanilla.js.map +1 -1
- package/dist/components/Bubble/Bubble.vanilla.cjs +2 -10
- package/dist/components/Bubble/Bubble.vanilla.cjs.map +1 -1
- package/dist/components/Bubble/Bubble.vanilla.js +2 -10
- package/dist/components/Bubble/Bubble.vanilla.js.map +1 -1
- package/dist/components/Button/Button.vanilla.cjs +2 -10
- package/dist/components/Button/Button.vanilla.cjs.map +1 -1
- package/dist/components/Button/Button.vanilla.js +2 -10
- package/dist/components/Button/Button.vanilla.js.map +1 -1
- package/dist/components/ButtonSwitch/ButtonSwitch.vanilla.cjs +3 -17
- package/dist/components/ButtonSwitch/ButtonSwitch.vanilla.cjs.map +1 -1
- package/dist/components/ButtonSwitch/ButtonSwitch.vanilla.js +3 -17
- package/dist/components/ButtonSwitch/ButtonSwitch.vanilla.js.map +1 -1
- package/dist/components/Card/Card.vanilla.cjs +6 -11
- package/dist/components/Card/Card.vanilla.cjs.map +1 -1
- package/dist/components/Card/Card.vanilla.js +6 -11
- package/dist/components/Card/Card.vanilla.js.map +1 -1
- package/dist/components/CodeBlock/CodeBlock.vanilla.cjs +3 -6
- package/dist/components/CodeBlock/CodeBlock.vanilla.cjs.map +1 -1
- package/dist/components/CodeBlock/CodeBlock.vanilla.js +3 -6
- package/dist/components/CodeBlock/CodeBlock.vanilla.js.map +1 -1
- package/dist/components/Combobox/Combobox.vanilla.cjs +3 -10
- package/dist/components/Combobox/Combobox.vanilla.cjs.map +1 -1
- package/dist/components/Combobox/Combobox.vanilla.js +3 -10
- package/dist/components/Combobox/Combobox.vanilla.js.map +1 -1
- package/dist/components/Container/Container.vanilla.cjs +5 -11
- package/dist/components/Container/Container.vanilla.cjs.map +1 -1
- package/dist/components/Container/Container.vanilla.js +5 -11
- package/dist/components/Container/Container.vanilla.js.map +1 -1
- package/dist/components/Elevation/Elevation.vanilla.cjs +5 -11
- package/dist/components/Elevation/Elevation.vanilla.cjs.map +1 -1
- package/dist/components/Elevation/Elevation.vanilla.js +5 -11
- package/dist/components/Elevation/Elevation.vanilla.js.map +1 -1
- package/dist/components/Field/Field.vanilla.cjs +3 -9
- package/dist/components/Field/Field.vanilla.cjs.map +1 -1
- package/dist/components/Field/Field.vanilla.js +3 -9
- package/dist/components/Field/Field.vanilla.js.map +1 -1
- package/dist/components/Flex/Flex.vanilla.cjs +5 -11
- package/dist/components/Flex/Flex.vanilla.cjs.map +1 -1
- package/dist/components/Flex/Flex.vanilla.js +5 -11
- package/dist/components/Flex/Flex.vanilla.js.map +1 -1
- package/dist/components/Grid/Grid.vanilla.cjs +7 -11
- package/dist/components/Grid/Grid.vanilla.cjs.map +1 -1
- package/dist/components/Grid/Grid.vanilla.js +7 -11
- package/dist/components/Grid/Grid.vanilla.js.map +1 -1
- package/dist/components/Heading/Heading.vanilla.cjs +35 -0
- package/dist/components/Heading/Heading.vanilla.cjs.map +1 -0
- package/dist/components/Heading/Heading.vanilla.css.cjs +85 -0
- package/dist/components/Heading/Heading.vanilla.css.cjs.map +1 -0
- package/dist/components/Heading/Heading.vanilla.css.js +74 -0
- package/dist/components/Heading/Heading.vanilla.css.js.map +1 -0
- package/dist/components/Heading/Heading.vanilla.js +30 -0
- package/dist/components/Heading/Heading.vanilla.js.map +1 -0
- package/dist/components/IconButton/IconButton.vanilla.cjs +5 -11
- package/dist/components/IconButton/IconButton.vanilla.cjs.map +1 -1
- package/dist/components/IconButton/IconButton.vanilla.js +5 -11
- package/dist/components/IconButton/IconButton.vanilla.js.map +1 -1
- package/dist/components/Image/Image.vanilla.cjs +2 -10
- package/dist/components/Image/Image.vanilla.cjs.map +1 -1
- package/dist/components/Image/Image.vanilla.js +2 -10
- package/dist/components/Image/Image.vanilla.js.map +1 -1
- package/dist/components/Input/Input.vanilla.cjs +2 -10
- package/dist/components/Input/Input.vanilla.cjs.map +1 -1
- package/dist/components/Input/Input.vanilla.js +2 -10
- package/dist/components/Input/Input.vanilla.js.map +1 -1
- package/dist/components/Label/Label.vanilla.cjs +5 -11
- package/dist/components/Label/Label.vanilla.cjs.map +1 -1
- package/dist/components/Label/Label.vanilla.js +5 -11
- package/dist/components/Label/Label.vanilla.js.map +1 -1
- package/dist/components/List/List.vanilla.cjs +10 -18
- package/dist/components/List/List.vanilla.cjs.map +1 -1
- package/dist/components/List/List.vanilla.js +7 -15
- package/dist/components/List/List.vanilla.js.map +1 -1
- package/dist/components/Meter/Meter.vanilla.cjs +3 -8
- package/dist/components/Meter/Meter.vanilla.cjs.map +1 -1
- package/dist/components/Meter/Meter.vanilla.js +3 -8
- package/dist/components/Meter/Meter.vanilla.js.map +1 -1
- package/dist/components/Panel/Panel.vanilla.cjs +2 -10
- package/dist/components/Panel/Panel.vanilla.cjs.map +1 -1
- package/dist/components/Panel/Panel.vanilla.js +2 -10
- package/dist/components/Panel/Panel.vanilla.js.map +1 -1
- package/dist/components/Paragraph/Paragraph.vanilla.cjs +5 -11
- package/dist/components/Paragraph/Paragraph.vanilla.cjs.map +1 -1
- package/dist/components/Paragraph/Paragraph.vanilla.js +5 -11
- package/dist/components/Paragraph/Paragraph.vanilla.js.map +1 -1
- package/dist/components/RowLink/RowLink.vanilla.cjs.map +1 -1
- package/dist/components/RowLink/RowLink.vanilla.js.map +1 -1
- package/dist/components/SegmentedControl/SegmentedControl.vanilla.cjs +3 -14
- package/dist/components/SegmentedControl/SegmentedControl.vanilla.cjs.map +1 -1
- package/dist/components/SegmentedControl/SegmentedControl.vanilla.js +3 -14
- package/dist/components/SegmentedControl/SegmentedControl.vanilla.js.map +1 -1
- package/dist/components/Skeleton/Skeleton.vanilla.cjs +2 -10
- package/dist/components/Skeleton/Skeleton.vanilla.cjs.map +1 -1
- package/dist/components/Skeleton/Skeleton.vanilla.js +2 -10
- package/dist/components/Skeleton/Skeleton.vanilla.js.map +1 -1
- package/dist/components/Spinner/Spinner.vanilla.cjs +3 -6
- package/dist/components/Spinner/Spinner.vanilla.cjs.map +1 -1
- package/dist/components/Spinner/Spinner.vanilla.js +3 -6
- package/dist/components/Spinner/Spinner.vanilla.js.map +1 -1
- package/dist/components/SplitLayout/SplitLayout.vanilla.cjs +3 -10
- package/dist/components/SplitLayout/SplitLayout.vanilla.cjs.map +1 -1
- package/dist/components/SplitLayout/SplitLayout.vanilla.js +3 -10
- package/dist/components/SplitLayout/SplitLayout.vanilla.js.map +1 -1
- package/dist/components/Table/Table.vanilla.cjs +8 -4
- package/dist/components/Table/Table.vanilla.cjs.map +1 -1
- package/dist/components/Table/Table.vanilla.js +8 -4
- package/dist/components/Table/Table.vanilla.js.map +1 -1
- package/dist/components/Text/Text.vanilla.cjs +5 -11
- package/dist/components/Text/Text.vanilla.cjs.map +1 -1
- package/dist/components/Text/Text.vanilla.js +5 -11
- package/dist/components/Text/Text.vanilla.js.map +1 -1
- package/dist/components/TextField/TextField.vanilla.cjs.map +1 -1
- package/dist/components/TextField/TextField.vanilla.js.map +1 -1
- package/dist/components/Textarea/Textarea.vanilla.cjs +2 -10
- package/dist/components/Textarea/Textarea.vanilla.cjs.map +1 -1
- package/dist/components/Textarea/Textarea.vanilla.js +2 -10
- package/dist/components/Textarea/Textarea.vanilla.js.map +1 -1
- package/dist/components/Toast/Toast.vanilla.cjs +4 -15
- package/dist/components/Toast/Toast.vanilla.cjs.map +1 -1
- package/dist/components/Toast/Toast.vanilla.js +4 -15
- package/dist/components/Toast/Toast.vanilla.js.map +1 -1
- package/dist/faency.css +118 -2
- package/dist/index.cjs +9 -0
- package/dist/index.d.cts +36800 -0
- package/dist/index.d.ts +248 -94
- package/dist/index.js +3 -1
- package/dist/styles/recipeVariants.cjs +15 -0
- package/dist/styles/recipeVariants.cjs.map +1 -0
- package/dist/styles/recipeVariants.js +15 -0
- package/dist/styles/recipeVariants.js.map +1 -0
- package/dist/styles/themeContext.cjs.map +1 -1
- package/dist/styles/themeContext.js.map +1 -1
- package/package.json +17 -7
|
@@ -1,23 +1,15 @@
|
|
|
1
1
|
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
-
const require_cssProps = require("../../styles/cssProps.cjs");
|
|
3
2
|
const require_cx = require("../../styles/cx.cjs");
|
|
4
|
-
const
|
|
3
|
+
const require_useInlineStyle = require("../../styles/useInlineStyle.cjs");
|
|
5
4
|
const require_ButtonSwitch_vanilla_css = require("./ButtonSwitch.vanilla.css.cjs");
|
|
6
5
|
let react = require("react");
|
|
7
|
-
let _vanilla_extract_dynamic = require("@vanilla-extract/dynamic");
|
|
8
6
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
7
|
let _radix_ui_react_toggle_group = require("@radix-ui/react-toggle-group");
|
|
10
8
|
_radix_ui_react_toggle_group = require_runtime.__toESM(_radix_ui_react_toggle_group, 1);
|
|
11
9
|
// components/ButtonSwitch/ButtonSwitch.vanilla.tsx
|
|
12
10
|
var ButtonSwitchContainerVanillaImpl = (0, react.forwardRef)(({ as, className, css, style, children, ...props }, ref) => {
|
|
13
11
|
const Component = as || "div";
|
|
14
|
-
const
|
|
15
|
-
const { style: cssStyles, vars } = require_cssProps.processCSSProp(css, colors);
|
|
16
|
-
const mergedStyles = {
|
|
17
|
-
...cssStyles,
|
|
18
|
-
...style,
|
|
19
|
-
...(0, _vanilla_extract_dynamic.assignInlineVars)(vars)
|
|
20
|
-
};
|
|
12
|
+
const mergedStyles = require_useInlineStyle.useInlineStyle(css, style);
|
|
21
13
|
if (as) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Component, {
|
|
22
14
|
ref,
|
|
23
15
|
className: require_cx.cx(require_ButtonSwitch_vanilla_css.buttonSwitchContainer, className),
|
|
@@ -38,13 +30,7 @@ ButtonSwitchContainerVanillaImpl.displayName = "ButtonSwitchContainerVanilla";
|
|
|
38
30
|
var ButtonSwitchContainerVanilla = ButtonSwitchContainerVanillaImpl;
|
|
39
31
|
var ButtonSwitchItemVanillaImpl = (0, react.forwardRef)(({ as, className, css, style, children, ...props }, ref) => {
|
|
40
32
|
const Component = as || "button";
|
|
41
|
-
const
|
|
42
|
-
const { style: cssStyles, vars } = require_cssProps.processCSSProp(css, colors);
|
|
43
|
-
const mergedStyles = {
|
|
44
|
-
...cssStyles,
|
|
45
|
-
...style,
|
|
46
|
-
...(0, _vanilla_extract_dynamic.assignInlineVars)(vars)
|
|
47
|
-
};
|
|
33
|
+
const mergedStyles = require_useInlineStyle.useInlineStyle(css, style);
|
|
48
34
|
if (as) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Component, {
|
|
49
35
|
ref,
|
|
50
36
|
className: require_cx.cx(require_ButtonSwitch_vanilla_css.buttonSwitchItem, className),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonSwitch.vanilla.cjs","names":["forwardRef","
|
|
1
|
+
{"version":3,"file":"ButtonSwitch.vanilla.cjs","names":["forwardRef","useInlineStyle","cx","buttonSwitchContainer","ToggleGroupPrimitive","buttonSwitchItem"],"sources":["../../../components/ButtonSwitch/ButtonSwitch.vanilla.tsx"],"sourcesContent":["import * as ToggleGroupPrimitive from '@radix-ui/react-toggle-group';\nimport { ElementType, forwardRef } from 'react';\n\nimport { CSSProps } from '@/styles/cssProps';\nimport { cx } from '@/styles/cx';\nimport {\n PolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef,\n} from '@/styles/polymorphic';\nimport { useInlineStyle } from '@/styles/useInlineStyle';\n\nimport { buttonSwitchContainer, buttonSwitchItem } from './ButtonSwitch.vanilla.css';\n\n// Container Component\ninterface ButtonSwitchContainerOwnProps extends CSSProps {\n type?: 'single' | 'multiple';\n value?: string | string[];\n defaultValue?: string | string[];\n onValueChange?: (value: any) => void;\n disabled?: boolean;\n rovingFocus?: boolean;\n loop?: boolean;\n orientation?: 'horizontal' | 'vertical';\n dir?: 'ltr' | 'rtl';\n}\n\nexport type ButtonSwitchContainerVanillaProps<C extends ElementType = 'div'> =\n PolymorphicComponentProps<C, ButtonSwitchContainerOwnProps>;\n\ntype ButtonSwitchContainerVanillaComponent = PolymorphicComponent<\n 'div',\n ButtonSwitchContainerVanillaProps<ElementType>\n>;\n\nconst ButtonSwitchContainerVanillaImpl = forwardRef(\n <C extends ElementType = 'div'>(\n { as, className, css, style, children, ...props }: ButtonSwitchContainerVanillaProps<C>,\n ref?: PolymorphicRef<C>,\n ) => {\n const Component = (as || 'div') as any;\n const mergedStyles = useInlineStyle(css, style);\n\n if (as) {\n return (\n <Component\n ref={ref}\n className={cx(buttonSwitchContainer, className)}\n style={mergedStyles}\n role=\"group\"\n {...props}\n >\n {children}\n </Component>\n );\n }\n\n return (\n <ToggleGroupPrimitive.Root\n ref={ref as any}\n className={cx(buttonSwitchContainer, className)}\n style={mergedStyles}\n {...(props as any)}\n >\n {children}\n </ToggleGroupPrimitive.Root>\n );\n },\n);\n\nButtonSwitchContainerVanillaImpl.displayName = 'ButtonSwitchContainerVanilla';\n\nexport const ButtonSwitchContainerVanilla =\n ButtonSwitchContainerVanillaImpl as ButtonSwitchContainerVanillaComponent;\n\n// Item Component\ninterface ButtonSwitchItemOwnProps extends CSSProps {\n value: string;\n disabled?: boolean;\n}\n\nexport type ButtonSwitchItemVanillaProps<C extends ElementType = 'button'> =\n PolymorphicComponentProps<C, ButtonSwitchItemOwnProps>;\n\ntype ButtonSwitchItemVanillaComponent = PolymorphicComponent<\n 'button',\n ButtonSwitchItemVanillaProps<ElementType>\n>;\n\nconst ButtonSwitchItemVanillaImpl = forwardRef(\n <C extends ElementType = 'button'>(\n { as, className, css, style, children, ...props }: ButtonSwitchItemVanillaProps<C>,\n ref?: PolymorphicRef<C>,\n ) => {\n const Component = (as || 'button') as any;\n const mergedStyles = useInlineStyle(css, style);\n\n if (as) {\n return (\n <Component\n ref={ref}\n className={cx(buttonSwitchItem, className)}\n style={mergedStyles}\n role=\"radio\"\n {...props}\n >\n {children}\n </Component>\n );\n }\n\n return (\n <ToggleGroupPrimitive.Item\n ref={ref as any}\n className={cx(buttonSwitchItem, className)}\n style={mergedStyles}\n {...(props as any)}\n >\n {children}\n </ToggleGroupPrimitive.Item>\n );\n },\n);\n\nButtonSwitchItemVanillaImpl.displayName = 'ButtonSwitchItemVanilla';\n\nexport const ButtonSwitchItemVanilla =\n ButtonSwitchItemVanillaImpl as ButtonSwitchItemVanillaComponent;\n"],"mappings":";;;;;;;;;AAmCA,IAAM,oCAAA,GAAmCA,MAAAA,WAAAA,EAErC,EAAE,IAAI,WAAW,KAAK,OAAO,UAAU,GAAG,SAC1C,QACG;CACH,MAAM,YAAa,MAAM;CACzB,MAAM,eAAeC,uBAAAA,eAAe,KAAK,KAAK;CAE9C,IAAI,IACF,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,WAAD;EACO;EACL,WAAWC,WAAAA,GAAGC,iCAAAA,uBAAuB,SAAS;EAC9C,OAAO;EACP,MAAK;EACL,GAAI;EAEH;CACQ,CAAA;CAIf,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,6BAAqB,MAAtB;EACO;EACL,WAAWF,WAAAA,GAAGC,iCAAAA,uBAAuB,SAAS;EAC9C,OAAO;EACP,GAAK;EAEJ;CACwB,CAAA;AAE/B,CACF;AAEA,iCAAiC,cAAc;AAE/C,IAAa,+BACX;AAgBF,IAAM,+BAAA,GAA8BH,MAAAA,WAAAA,EAEhC,EAAE,IAAI,WAAW,KAAK,OAAO,UAAU,GAAG,SAC1C,QACG;CACH,MAAM,YAAa,MAAM;CACzB,MAAM,eAAeC,uBAAAA,eAAe,KAAK,KAAK;CAE9C,IAAI,IACF,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,WAAD;EACO;EACL,WAAWC,WAAAA,GAAGG,iCAAAA,kBAAkB,SAAS;EACzC,OAAO;EACP,MAAK;EACL,GAAI;EAEH;CACQ,CAAA;CAIf,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACD,6BAAqB,MAAtB;EACO;EACL,WAAWF,WAAAA,GAAGG,iCAAAA,kBAAkB,SAAS;EACzC,OAAO;EACP,GAAK;EAEJ;CACwB,CAAA;AAE/B,CACF;AAEA,4BAA4B,cAAc;AAE1C,IAAa,0BACX"}
|
|
@@ -1,21 +1,13 @@
|
|
|
1
|
-
import { processCSSProp } from "../../styles/cssProps.js";
|
|
2
1
|
import { cx } from "../../styles/cx.js";
|
|
3
|
-
import {
|
|
2
|
+
import { useInlineStyle } from "../../styles/useInlineStyle.js";
|
|
4
3
|
import { buttonSwitchContainer, buttonSwitchItem } from "./ButtonSwitch.vanilla.css.js";
|
|
5
4
|
import { forwardRef } from "react";
|
|
6
|
-
import { assignInlineVars } from "@vanilla-extract/dynamic";
|
|
7
5
|
import { jsx } from "react/jsx-runtime";
|
|
8
6
|
import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group";
|
|
9
7
|
// components/ButtonSwitch/ButtonSwitch.vanilla.tsx
|
|
10
8
|
var ButtonSwitchContainerVanillaImpl = forwardRef(({ as, className, css, style, children, ...props }, ref) => {
|
|
11
9
|
const Component = as || "div";
|
|
12
|
-
const
|
|
13
|
-
const { style: cssStyles, vars } = processCSSProp(css, colors);
|
|
14
|
-
const mergedStyles = {
|
|
15
|
-
...cssStyles,
|
|
16
|
-
...style,
|
|
17
|
-
...assignInlineVars(vars)
|
|
18
|
-
};
|
|
10
|
+
const mergedStyles = useInlineStyle(css, style);
|
|
19
11
|
if (as) return /* @__PURE__ */ jsx(Component, {
|
|
20
12
|
ref,
|
|
21
13
|
className: cx(buttonSwitchContainer, className),
|
|
@@ -36,13 +28,7 @@ ButtonSwitchContainerVanillaImpl.displayName = "ButtonSwitchContainerVanilla";
|
|
|
36
28
|
var ButtonSwitchContainerVanilla = ButtonSwitchContainerVanillaImpl;
|
|
37
29
|
var ButtonSwitchItemVanillaImpl = forwardRef(({ as, className, css, style, children, ...props }, ref) => {
|
|
38
30
|
const Component = as || "button";
|
|
39
|
-
const
|
|
40
|
-
const { style: cssStyles, vars } = processCSSProp(css, colors);
|
|
41
|
-
const mergedStyles = {
|
|
42
|
-
...cssStyles,
|
|
43
|
-
...style,
|
|
44
|
-
...assignInlineVars(vars)
|
|
45
|
-
};
|
|
31
|
+
const mergedStyles = useInlineStyle(css, style);
|
|
46
32
|
if (as) return /* @__PURE__ */ jsx(Component, {
|
|
47
33
|
ref,
|
|
48
34
|
className: cx(buttonSwitchItem, className),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonSwitch.vanilla.js","names":[],"sources":["../../../components/ButtonSwitch/ButtonSwitch.vanilla.tsx"],"sourcesContent":["import * as ToggleGroupPrimitive from '@radix-ui/react-toggle-group';\nimport {
|
|
1
|
+
{"version":3,"file":"ButtonSwitch.vanilla.js","names":[],"sources":["../../../components/ButtonSwitch/ButtonSwitch.vanilla.tsx"],"sourcesContent":["import * as ToggleGroupPrimitive from '@radix-ui/react-toggle-group';\nimport { ElementType, forwardRef } from 'react';\n\nimport { CSSProps } from '@/styles/cssProps';\nimport { cx } from '@/styles/cx';\nimport {\n PolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef,\n} from '@/styles/polymorphic';\nimport { useInlineStyle } from '@/styles/useInlineStyle';\n\nimport { buttonSwitchContainer, buttonSwitchItem } from './ButtonSwitch.vanilla.css';\n\n// Container Component\ninterface ButtonSwitchContainerOwnProps extends CSSProps {\n type?: 'single' | 'multiple';\n value?: string | string[];\n defaultValue?: string | string[];\n onValueChange?: (value: any) => void;\n disabled?: boolean;\n rovingFocus?: boolean;\n loop?: boolean;\n orientation?: 'horizontal' | 'vertical';\n dir?: 'ltr' | 'rtl';\n}\n\nexport type ButtonSwitchContainerVanillaProps<C extends ElementType = 'div'> =\n PolymorphicComponentProps<C, ButtonSwitchContainerOwnProps>;\n\ntype ButtonSwitchContainerVanillaComponent = PolymorphicComponent<\n 'div',\n ButtonSwitchContainerVanillaProps<ElementType>\n>;\n\nconst ButtonSwitchContainerVanillaImpl = forwardRef(\n <C extends ElementType = 'div'>(\n { as, className, css, style, children, ...props }: ButtonSwitchContainerVanillaProps<C>,\n ref?: PolymorphicRef<C>,\n ) => {\n const Component = (as || 'div') as any;\n const mergedStyles = useInlineStyle(css, style);\n\n if (as) {\n return (\n <Component\n ref={ref}\n className={cx(buttonSwitchContainer, className)}\n style={mergedStyles}\n role=\"group\"\n {...props}\n >\n {children}\n </Component>\n );\n }\n\n return (\n <ToggleGroupPrimitive.Root\n ref={ref as any}\n className={cx(buttonSwitchContainer, className)}\n style={mergedStyles}\n {...(props as any)}\n >\n {children}\n </ToggleGroupPrimitive.Root>\n );\n },\n);\n\nButtonSwitchContainerVanillaImpl.displayName = 'ButtonSwitchContainerVanilla';\n\nexport const ButtonSwitchContainerVanilla =\n ButtonSwitchContainerVanillaImpl as ButtonSwitchContainerVanillaComponent;\n\n// Item Component\ninterface ButtonSwitchItemOwnProps extends CSSProps {\n value: string;\n disabled?: boolean;\n}\n\nexport type ButtonSwitchItemVanillaProps<C extends ElementType = 'button'> =\n PolymorphicComponentProps<C, ButtonSwitchItemOwnProps>;\n\ntype ButtonSwitchItemVanillaComponent = PolymorphicComponent<\n 'button',\n ButtonSwitchItemVanillaProps<ElementType>\n>;\n\nconst ButtonSwitchItemVanillaImpl = forwardRef(\n <C extends ElementType = 'button'>(\n { as, className, css, style, children, ...props }: ButtonSwitchItemVanillaProps<C>,\n ref?: PolymorphicRef<C>,\n ) => {\n const Component = (as || 'button') as any;\n const mergedStyles = useInlineStyle(css, style);\n\n if (as) {\n return (\n <Component\n ref={ref}\n className={cx(buttonSwitchItem, className)}\n style={mergedStyles}\n role=\"radio\"\n {...props}\n >\n {children}\n </Component>\n );\n }\n\n return (\n <ToggleGroupPrimitive.Item\n ref={ref as any}\n className={cx(buttonSwitchItem, className)}\n style={mergedStyles}\n {...(props as any)}\n >\n {children}\n </ToggleGroupPrimitive.Item>\n );\n },\n);\n\nButtonSwitchItemVanillaImpl.displayName = 'ButtonSwitchItemVanilla';\n\nexport const ButtonSwitchItemVanilla =\n ButtonSwitchItemVanillaImpl as ButtonSwitchItemVanillaComponent;\n"],"mappings":";;;;;;;AAmCA,IAAM,mCAAmC,YAErC,EAAE,IAAI,WAAW,KAAK,OAAO,UAAU,GAAG,SAC1C,QACG;CACH,MAAM,YAAa,MAAM;CACzB,MAAM,eAAe,eAAe,KAAK,KAAK;CAE9C,IAAI,IACF,OACE,oBAAC,WAAD;EACO;EACL,WAAW,GAAG,uBAAuB,SAAS;EAC9C,OAAO;EACP,MAAK;EACL,GAAI;EAEH;CACQ,CAAA;CAIf,OACE,oBAAC,qBAAqB,MAAtB;EACO;EACL,WAAW,GAAG,uBAAuB,SAAS;EAC9C,OAAO;EACP,GAAK;EAEJ;CACwB,CAAA;AAE/B,CACF;AAEA,iCAAiC,cAAc;AAE/C,IAAa,+BACX;AAgBF,IAAM,8BAA8B,YAEhC,EAAE,IAAI,WAAW,KAAK,OAAO,UAAU,GAAG,SAC1C,QACG;CACH,MAAM,YAAa,MAAM;CACzB,MAAM,eAAe,eAAe,KAAK,KAAK;CAE9C,IAAI,IACF,OACE,oBAAC,WAAD;EACO;EACL,WAAW,GAAG,kBAAkB,SAAS;EACzC,OAAO;EACP,MAAK;EACL,GAAI;EAEH;CACQ,CAAA;CAIf,OACE,oBAAC,qBAAqB,MAAtB;EACO;EACL,WAAW,GAAG,kBAAkB,SAAS;EACzC,OAAO;EACP,GAAK;EAEJ;CACwB,CAAA;AAE/B,CACF;AAEA,4BAA4B,cAAc;AAE1C,IAAa,0BACX"}
|
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
const require_cssProps = require("../../styles/cssProps.cjs");
|
|
2
1
|
const require_cx = require("../../styles/cx.cjs");
|
|
3
|
-
const
|
|
2
|
+
const require_recipeVariants = require("../../styles/recipeVariants.cjs");
|
|
3
|
+
const require_useInlineStyle = require("../../styles/useInlineStyle.cjs");
|
|
4
4
|
const require_Card_vanilla_css = require("./Card.vanilla.css.cjs");
|
|
5
5
|
let react = require("react");
|
|
6
|
-
let _vanilla_extract_dynamic = require("@vanilla-extract/dynamic");
|
|
7
6
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
7
|
// components/Card/Card.vanilla.tsx
|
|
8
|
+
var cardClass = require_recipeVariants.withVariantKeys(require_Card_vanilla_css.cardRecipe);
|
|
9
|
+
var interactiveCardClass = require_recipeVariants.withVariantKeys(require_Card_vanilla_css.interactiveCardRecipe);
|
|
9
10
|
var CardVanillaComponentImpl = (0, react.forwardRef)(({ as, className, css, style, elevation, variant, active, interactive, ...props }, ref) => {
|
|
10
11
|
const Component = as || (interactive ? "button" : "div");
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const mergedStyles = {
|
|
14
|
-
...cssStyles,
|
|
15
|
-
...style,
|
|
16
|
-
...(0, _vanilla_extract_dynamic.assignInlineVars)(vars)
|
|
17
|
-
};
|
|
18
|
-
const recipeClass = (interactive ? require_Card_vanilla_css.interactiveCardRecipe : require_Card_vanilla_css.cardRecipe)({
|
|
12
|
+
const mergedStyles = require_useInlineStyle.useInlineStyle(css, style);
|
|
13
|
+
const recipeClass = (interactive ? interactiveCardClass : cardClass)({
|
|
19
14
|
elevation,
|
|
20
15
|
variant,
|
|
21
16
|
active
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Card.vanilla.cjs","names":["
|
|
1
|
+
{"version":3,"file":"Card.vanilla.cjs","names":["withVariantKeys","cardRecipe","interactiveCardRecipe","forwardRef","useInlineStyle","cx"],"sources":["../../../components/Card/Card.vanilla.tsx"],"sourcesContent":["import { ElementType, forwardRef } from 'react';\n\nimport { CSSProps } from '@/styles/cssProps';\nimport { cx } from '@/styles/cx';\nimport {\n PolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef,\n} from '@/styles/polymorphic';\nimport { RecipeVariantProps, withVariantKeys } from '@/styles/recipeVariants';\nimport { useInlineStyle } from '@/styles/useInlineStyle';\n\nimport { cardRecipe, interactiveCardRecipe } from './Card.vanilla.css';\n\nconst cardClass = withVariantKeys(cardRecipe);\nconst interactiveCardClass = withVariantKeys(interactiveCardRecipe);\n\ntype CardRecipeVariants = RecipeVariantProps<typeof cardRecipe>;\n\ninterface CardOwnProps extends CSSProps {\n elevation?: CardRecipeVariants['elevation'];\n variant?: CardRecipeVariants['variant'];\n active?: CardRecipeVariants['active'];\n interactive?: boolean;\n}\n\nexport type CardVanillaProps<C extends ElementType = 'div'> = PolymorphicComponentProps<\n C,\n CardOwnProps\n>;\n\ntype CardVanillaComponent = PolymorphicComponent<'div', CardVanillaProps<ElementType>>;\n\nconst CardVanillaComponentImpl = forwardRef(\n <C extends ElementType = 'div'>(\n {\n as,\n className,\n css,\n style,\n elevation,\n variant,\n active,\n interactive,\n ...props\n }: CardVanillaProps<C>,\n ref?: PolymorphicRef<C>,\n ) => {\n const Component = as || (interactive ? 'button' : 'div');\n const mergedStyles = useInlineStyle(css, style);\n\n const recipe = interactive ? interactiveCardClass : cardClass;\n const recipeClass = recipe({ elevation, variant, active });\n\n const additionalProps = interactive && !as ? { tabIndex: 0 } : {};\n\n return (\n <Component\n ref={ref}\n className={cx(recipeClass, className)}\n style={mergedStyles}\n {...additionalProps}\n {...props}\n />\n );\n },\n);\n\nCardVanillaComponentImpl.displayName = 'CardVanilla';\n\nexport const CardVanilla = CardVanillaComponentImpl as CardVanillaComponent;\n"],"mappings":";;;;;;;AAcA,IAAM,YAAYA,uBAAAA,gBAAgBC,yBAAAA,UAAU;AAC5C,IAAM,uBAAuBD,uBAAAA,gBAAgBE,yBAAAA,qBAAqB;AAkBlE,IAAM,4BAAA,GAA2BC,MAAAA,WAAAA,EAE7B,EACE,IACA,WACA,KACA,OACA,WACA,SACA,QACA,aACA,GAAG,SAEL,QACG;CACH,MAAM,YAAY,OAAO,cAAc,WAAW;CAClD,MAAM,eAAeC,uBAAAA,eAAe,KAAK,KAAK;CAG9C,MAAM,eADS,cAAc,uBAAuB,UAAA,CACzB;EAAE;EAAW;EAAS;CAAO,CAAC;CAEzD,MAAM,kBAAkB,eAAe,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,CAAC;CAEhE,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,WAAD;EACO;EACL,WAAWC,WAAAA,GAAG,aAAa,SAAS;EACpC,OAAO;EACP,GAAI;EACJ,GAAI;CACL,CAAA;AAEL,CACF;AAEA,yBAAyB,cAAc;AAEvC,IAAa,cAAc"}
|
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
import { processCSSProp } from "../../styles/cssProps.js";
|
|
2
1
|
import { cx } from "../../styles/cx.js";
|
|
3
|
-
import {
|
|
2
|
+
import { withVariantKeys } from "../../styles/recipeVariants.js";
|
|
3
|
+
import { useInlineStyle } from "../../styles/useInlineStyle.js";
|
|
4
4
|
import { cardRecipe, interactiveCardRecipe } from "./Card.vanilla.css.js";
|
|
5
5
|
import { forwardRef } from "react";
|
|
6
|
-
import { assignInlineVars } from "@vanilla-extract/dynamic";
|
|
7
6
|
import { jsx } from "react/jsx-runtime";
|
|
8
7
|
// components/Card/Card.vanilla.tsx
|
|
8
|
+
var cardClass = withVariantKeys(cardRecipe);
|
|
9
|
+
var interactiveCardClass = withVariantKeys(interactiveCardRecipe);
|
|
9
10
|
var CardVanillaComponentImpl = forwardRef(({ as, className, css, style, elevation, variant, active, interactive, ...props }, ref) => {
|
|
10
11
|
const Component = as || (interactive ? "button" : "div");
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const mergedStyles = {
|
|
14
|
-
...cssStyles,
|
|
15
|
-
...style,
|
|
16
|
-
...assignInlineVars(vars)
|
|
17
|
-
};
|
|
18
|
-
const recipeClass = (interactive ? interactiveCardRecipe : cardRecipe)({
|
|
12
|
+
const mergedStyles = useInlineStyle(css, style);
|
|
13
|
+
const recipeClass = (interactive ? interactiveCardClass : cardClass)({
|
|
19
14
|
elevation,
|
|
20
15
|
variant,
|
|
21
16
|
active
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Card.vanilla.js","names":[],"sources":["../../../components/Card/Card.vanilla.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"Card.vanilla.js","names":[],"sources":["../../../components/Card/Card.vanilla.tsx"],"sourcesContent":["import { ElementType, forwardRef } from 'react';\n\nimport { CSSProps } from '@/styles/cssProps';\nimport { cx } from '@/styles/cx';\nimport {\n PolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef,\n} from '@/styles/polymorphic';\nimport { RecipeVariantProps, withVariantKeys } from '@/styles/recipeVariants';\nimport { useInlineStyle } from '@/styles/useInlineStyle';\n\nimport { cardRecipe, interactiveCardRecipe } from './Card.vanilla.css';\n\nconst cardClass = withVariantKeys(cardRecipe);\nconst interactiveCardClass = withVariantKeys(interactiveCardRecipe);\n\ntype CardRecipeVariants = RecipeVariantProps<typeof cardRecipe>;\n\ninterface CardOwnProps extends CSSProps {\n elevation?: CardRecipeVariants['elevation'];\n variant?: CardRecipeVariants['variant'];\n active?: CardRecipeVariants['active'];\n interactive?: boolean;\n}\n\nexport type CardVanillaProps<C extends ElementType = 'div'> = PolymorphicComponentProps<\n C,\n CardOwnProps\n>;\n\ntype CardVanillaComponent = PolymorphicComponent<'div', CardVanillaProps<ElementType>>;\n\nconst CardVanillaComponentImpl = forwardRef(\n <C extends ElementType = 'div'>(\n {\n as,\n className,\n css,\n style,\n elevation,\n variant,\n active,\n interactive,\n ...props\n }: CardVanillaProps<C>,\n ref?: PolymorphicRef<C>,\n ) => {\n const Component = as || (interactive ? 'button' : 'div');\n const mergedStyles = useInlineStyle(css, style);\n\n const recipe = interactive ? interactiveCardClass : cardClass;\n const recipeClass = recipe({ elevation, variant, active });\n\n const additionalProps = interactive && !as ? { tabIndex: 0 } : {};\n\n return (\n <Component\n ref={ref}\n className={cx(recipeClass, className)}\n style={mergedStyles}\n {...additionalProps}\n {...props}\n />\n );\n },\n);\n\nCardVanillaComponentImpl.displayName = 'CardVanilla';\n\nexport const CardVanilla = CardVanillaComponentImpl as CardVanillaComponent;\n"],"mappings":";;;;;;;AAcA,IAAM,YAAY,gBAAgB,UAAU;AAC5C,IAAM,uBAAuB,gBAAgB,qBAAqB;AAkBlE,IAAM,2BAA2B,YAE7B,EACE,IACA,WACA,KACA,OACA,WACA,SACA,QACA,aACA,GAAG,SAEL,QACG;CACH,MAAM,YAAY,OAAO,cAAc,WAAW;CAClD,MAAM,eAAe,eAAe,KAAK,KAAK;CAG9C,MAAM,eADS,cAAc,uBAAuB,UAAA,CACzB;EAAE;EAAW;EAAS;CAAO,CAAC;CAEzD,MAAM,kBAAkB,eAAe,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,CAAC;CAEhE,OACE,oBAAC,WAAD;EACO;EACL,WAAW,GAAG,aAAa,SAAS;EACpC,OAAO;EACP,GAAI;EACJ,GAAI;CACL,CAAA;AAEL,CACF;AAEA,yBAAyB,cAAc;AAEvC,IAAa,cAAc"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
-
const require_cssProps = require("../../styles/cssProps.cjs");
|
|
3
2
|
const require_cx = require("../../styles/cx.cjs");
|
|
4
3
|
const require_themeContext = require("../../styles/themeContext.cjs");
|
|
4
|
+
const require_useInlineStyle = require("../../styles/useInlineStyle.cjs");
|
|
5
5
|
const require_useIsomorphicLayoutEffect = require("../../utils/useIsomorphicLayoutEffect.cjs");
|
|
6
6
|
const require_AccessibleIcon = require("../AccessibleIcon/AccessibleIcon.cjs");
|
|
7
7
|
const require_Button_vanilla = require("../Button/Button.vanilla.cjs");
|
|
@@ -10,20 +10,17 @@ require("./prism-extend.cjs");
|
|
|
10
10
|
let _radix_ui_react_icons = require("@radix-ui/react-icons");
|
|
11
11
|
let react = require("react");
|
|
12
12
|
react = require_runtime.__toESM(react, 1);
|
|
13
|
-
let _vanilla_extract_dynamic = require("@vanilla-extract/dynamic");
|
|
14
13
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
15
14
|
let prism_react_renderer = require("prism-react-renderer");
|
|
16
15
|
// components/CodeBlock/CodeBlock.vanilla.tsx
|
|
17
16
|
var CodeBlockVanilla = (0, react.forwardRef)(({ lang = "text", code, copyable = false, copyText, copiedText, copyButtonAlign = "top right", onCopy, onCopyError, noBorder, wrapText = false, colorScheme, maxHeight = 424, css, style, className, ...props }, ref) => {
|
|
18
|
-
const {
|
|
17
|
+
const { resolvedTheme } = require_themeContext.useVanillaExtractTheme();
|
|
19
18
|
const prismTheme = (colorScheme ?? resolvedTheme) === "dark" ? prism_react_renderer.themes.nightOwl : prism_react_renderer.themes.nightOwlLight;
|
|
20
19
|
const isBottom = copyButtonAlign.includes("bottom");
|
|
21
20
|
const isLeft = copyButtonAlign.includes("left");
|
|
22
|
-
const { style: cssStyles, vars } = require_cssProps.processCSSProp(css, colors);
|
|
23
21
|
const containerStyles = {
|
|
24
22
|
position: "relative",
|
|
25
|
-
...
|
|
26
|
-
...(0, _vanilla_extract_dynamic.assignInlineVars)(vars)
|
|
23
|
+
...require_useInlineStyle.useInlineStyle(css)
|
|
27
24
|
};
|
|
28
25
|
const [copied, setCopied] = (0, react.useState)(false);
|
|
29
26
|
const preRef = (0, react.useRef)(null);
|
|
@@ -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","cx","pre","codeContent"],"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 { cx } from '../../styles/cx';\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={cx(pre, noBorder && preNoBorder, highlightClass, className)}\n style={{\n maxHeight,\n ...highlightStyle,\n backgroundColor: 'inherit',\n ...style,\n }}\n {...props}\n >\n <div\n className={cx(\n codeContent,\n copyable && isLeft && isBottom && codeContentBottomPadding,\n copyable && isLeft && !isBottom && codeContentTopPadding,\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 </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":";;;;;;;;;;;;;;;;AA6CA,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;CACA,MAAM,oBAAA,GAAmBA,MAAAA,OAAAA,CAAuB,IAAI;CAEpD,MAAM,aAAA,GAAYC,MAAAA,YAAAA,EACf,SAAgC;EAC/B,OAAO,UAAU;EACjB,IAAI,OAAO,QAAQ,YAAY,IAAI,IAAI;OAClC,IAAI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AK;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","useInlineStyle","useState","useRef","useCallback","copyButtonWrapperBottomLeft","copyButtonWrapperBottomRight","copyButtonWrapperTopLeft","copyButtonWrapperTop","ButtonVanilla","AccessibleIcon","CheckIcon","CopyIcon","Highlight","Prism","cx","pre","codeContent"],"sources":["../../../components/CodeBlock/CodeBlock.vanilla.tsx"],"sourcesContent":["import { CheckIcon, CopyIcon } from '@radix-ui/react-icons';\nimport { Highlight, Language, themes } from 'prism-react-renderer';\nimport React, { forwardRef, HTMLAttributes, useCallback, useRef, useState } from 'react';\n\nimport { CSSProps } from '@/styles/cssProps';\nimport { cx } from '@/styles/cx';\nimport { useVanillaExtractTheme } from '@/styles/themeContext';\nimport { useInlineStyle } from '@/styles/useInlineStyle';\nimport { useIsomorphicLayoutEffect } from '@/utils/useIsomorphicLayoutEffect';\n\nimport { AccessibleIcon } from '@/components/AccessibleIcon';\nimport { ButtonVanilla } from '@/components/Button';\n\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 { 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 inlineStyle = useInlineStyle(css);\n const containerStyles = { position: 'relative' as const, ...inlineStyle };\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={cx(pre, noBorder && preNoBorder, highlightClass, className)}\n style={{\n maxHeight,\n ...highlightStyle,\n backgroundColor: 'inherit',\n ...style,\n }}\n {...props}\n >\n <div\n className={cx(\n codeContent,\n copyable && isLeft && isBottom && codeContentBottomPadding,\n copyable && isLeft && !isBottom && codeContentTopPadding,\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 </div>\n </pre>\n {copyButton && (\n <div ref={buttonWrapperRef} className={buttonPositionClass}>\n {copyButton}\n </div>\n )}\n </div>\n )}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AO,gBACP,QACA,cACA,oBAEA,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAD;GAAK,OAAO;GAAZ,UAAA,CACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;IACE,KAAK;IACL,WAAWC,WAAAA,GAAGC,8BAAAA,KAAK,YAAA,aAAyB,gBAAgB,SAAS;IACrE,OAAO;KACL;KACA,GAAG;KACH,iBAAiB;KACjB,GAAG;IACL;IACA,GAAI;IAEJ,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;KACE,WAAWD,WAAAA,GACTE,8BAAAA,aACA,YAAY,UAAU,YAAA,aACtB,YAAY,UAAU,CAAC,YAAA,WACzB;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,OAAD;IAAK,KAAK;IAAkB,WAAW;IACpC,UAAA;GACE,CAAA,CAEJ;;CAEE,CAAA;AAEf,CACF;AAEA,iBAAiB,cAAc"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { processCSSProp } from "../../styles/cssProps.js";
|
|
2
1
|
import { cx } from "../../styles/cx.js";
|
|
3
2
|
import { useVanillaExtractTheme } from "../../styles/themeContext.js";
|
|
3
|
+
import { useInlineStyle } from "../../styles/useInlineStyle.js";
|
|
4
4
|
import { useIsomorphicLayoutEffect } from "../../utils/useIsomorphicLayoutEffect.js";
|
|
5
5
|
import { AccessibleIcon } from "../AccessibleIcon/AccessibleIcon.js";
|
|
6
6
|
import { ButtonVanilla } from "../Button/Button.vanilla.js";
|
|
@@ -8,20 +8,17 @@ import { codeContent, copyButtonWrapperBottomLeft, copyButtonWrapperBottomRight,
|
|
|
8
8
|
import { Prism } from "./prism-extend.js";
|
|
9
9
|
import { CheckIcon, CopyIcon } from "@radix-ui/react-icons";
|
|
10
10
|
import { forwardRef, useCallback, useRef, useState } from "react";
|
|
11
|
-
import { assignInlineVars } from "@vanilla-extract/dynamic";
|
|
12
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
12
|
import { Highlight, themes } from "prism-react-renderer";
|
|
14
13
|
// components/CodeBlock/CodeBlock.vanilla.tsx
|
|
15
14
|
var CodeBlockVanilla = forwardRef(({ lang = "text", code, copyable = false, copyText, copiedText, copyButtonAlign = "top right", onCopy, onCopyError, noBorder, wrapText = false, colorScheme, maxHeight = 424, css, style, className, ...props }, ref) => {
|
|
16
|
-
const {
|
|
15
|
+
const { resolvedTheme } = useVanillaExtractTheme();
|
|
17
16
|
const prismTheme = (colorScheme ?? resolvedTheme) === "dark" ? themes.nightOwl : themes.nightOwlLight;
|
|
18
17
|
const isBottom = copyButtonAlign.includes("bottom");
|
|
19
18
|
const isLeft = copyButtonAlign.includes("left");
|
|
20
|
-
const { style: cssStyles, vars } = processCSSProp(css, colors);
|
|
21
19
|
const containerStyles = {
|
|
22
20
|
position: "relative",
|
|
23
|
-
...
|
|
24
|
-
...assignInlineVars(vars)
|
|
21
|
+
...useInlineStyle(css)
|
|
25
22
|
};
|
|
26
23
|
const [copied, setCopied] = useState(false);
|
|
27
24
|
const preRef = useRef(null);
|
|
@@ -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 {
|
|
1
|
+
{"version":3,"file":"CodeBlock.vanilla.js","names":[],"sources":["../../../components/CodeBlock/CodeBlock.vanilla.tsx"],"sourcesContent":["import { CheckIcon, CopyIcon } from '@radix-ui/react-icons';\nimport { Highlight, Language, themes } from 'prism-react-renderer';\nimport React, { forwardRef, HTMLAttributes, useCallback, useRef, useState } from 'react';\n\nimport { CSSProps } from '@/styles/cssProps';\nimport { cx } from '@/styles/cx';\nimport { useVanillaExtractTheme } from '@/styles/themeContext';\nimport { useInlineStyle } from '@/styles/useInlineStyle';\nimport { useIsomorphicLayoutEffect } from '@/utils/useIsomorphicLayoutEffect';\n\nimport { AccessibleIcon } from '@/components/AccessibleIcon';\nimport { ButtonVanilla } from '@/components/Button';\n\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 { 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 inlineStyle = useInlineStyle(css);\n const containerStyles = { position: 'relative' as const, ...inlineStyle };\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={cx(pre, noBorder && preNoBorder, highlightClass, className)}\n style={{\n maxHeight,\n ...highlightStyle,\n backgroundColor: 'inherit',\n ...style,\n }}\n {...props}\n >\n <div\n className={cx(\n codeContent,\n copyable && isLeft && isBottom && codeContentBottomPadding,\n copyable && isLeft && !isBottom && codeContentTopPadding,\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 </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":";;;;;;;;;;;;;AA+CA,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,kBAAkB,uBAAuB;CAEjD,MAAM,cADkB,eAAe,mBACA,SAAS,OAAO,WAAW,OAAO;CAEzE,MAAM,WA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EA,iBAAiB,cAAc"}
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
-
const require_cssProps = require("../../styles/cssProps.cjs");
|
|
3
2
|
const require_cx = require("../../styles/cx.cjs");
|
|
4
|
-
const
|
|
3
|
+
const require_useInlineStyle = require("../../styles/useInlineStyle.cjs");
|
|
5
4
|
const require_Input_vanilla = require("../Input/Input.vanilla.cjs");
|
|
6
5
|
const require_Combobox_vanilla_css = require("./Combobox.vanilla.css.cjs");
|
|
7
6
|
let react = require("react");
|
|
8
7
|
react = require_runtime.__toESM(react, 1);
|
|
9
|
-
let _vanilla_extract_dynamic = require("@vanilla-extract/dynamic");
|
|
10
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
11
9
|
let _radix_ui_react_popover = require("@radix-ui/react-popover");
|
|
12
10
|
_radix_ui_react_popover = require_runtime.__toESM(_radix_ui_react_popover, 1);
|
|
13
11
|
// components/Combobox/Combobox.vanilla.tsx
|
|
14
12
|
var defaultFilter = (suggestion, query) => suggestion.toLowerCase().includes(query.toLowerCase());
|
|
15
13
|
var ComboboxVanilla = (0, react.forwardRef)(({ value: valueProp, defaultValue = "", onValueChange, suggestions, emptyText, filter = defaultFilter, openOnFocus = true, id: idProp, size, disabled, readOnly, className, style, css, onFocus, onBlur, onKeyDown, ...props }, ref) => {
|
|
16
|
-
const
|
|
17
|
-
const { style: cssStyles, vars } = require_cssProps.processCSSProp(css, colors);
|
|
14
|
+
const inlineStyle = require_useInlineStyle.useInlineStyle(css, style);
|
|
18
15
|
const autoId = (0, react.useId)();
|
|
19
16
|
const id = idProp ?? autoId;
|
|
20
17
|
const listId = `${id}-listbox`;
|
|
@@ -86,11 +83,7 @@ var ComboboxVanilla = (0, react.forwardRef)(({ value: valueProp, defaultValue =
|
|
|
86
83
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
87
84
|
ref: anchorRef,
|
|
88
85
|
className: require_cx.cx(require_Combobox_vanilla_css.comboboxAnchor, className),
|
|
89
|
-
style:
|
|
90
|
-
...cssStyles,
|
|
91
|
-
...style,
|
|
92
|
-
...(0, _vanilla_extract_dynamic.assignInlineVars)(vars)
|
|
93
|
-
},
|
|
86
|
+
style: inlineStyle,
|
|
94
87
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Input_vanilla.InputVanilla, {
|
|
95
88
|
ref,
|
|
96
89
|
id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Combobox.vanilla.cjs","names":["forwardRef","useVanillaExtractTheme","processCSSProp","useId","useRef","useState","PopoverPrimitive","cx","comboboxAnchor","assignInlineVars","InputVanilla","comboboxContent","comboboxListbox","comboboxOptionRecipe","comboboxEmptyRecipe"],"sources":["../../../components/Combobox/Combobox.vanilla.tsx"],"sourcesContent":["import * as PopoverPrimitive from '@radix-ui/react-popover';\nimport { assignInlineVars } from '@vanilla-extract/dynamic';\nimport React, { forwardRef, useEffect, useId, useRef, useState } from 'react';\n\nimport { CSSProps, processCSSProp } from '../../styles/cssProps';\nimport { cx } from '../../styles/cx';\nimport { useVanillaExtractTheme } from '../../styles/themeContext';\nimport { InputVanilla, InputVanillaHandle, InputVanillaProps } from '../Input/Input.vanilla';\nimport {\n comboboxAnchor,\n comboboxContent,\n comboboxEmptyRecipe,\n comboboxListbox,\n comboboxOptionRecipe,\n} from './Combobox.vanilla.css';\n\nconst defaultFilter = (suggestion: string, query: string) =>\n suggestion.toLowerCase().includes(query.toLowerCase());\n\nexport interface ComboboxVanillaProps\n extends\n Omit<InputVanillaProps, 'value' | 'defaultValue' | 'onChange' | 'type' | 'role' | 'css'>,\n CSSProps {\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n suggestions: string[];\n emptyText?: React.ReactNode;\n filter?: (suggestion: string, query: string) => boolean;\n openOnFocus?: boolean;\n}\n\nexport const ComboboxVanilla = forwardRef<InputVanillaHandle, ComboboxVanillaProps>(\n (\n {\n value: valueProp,\n defaultValue = '',\n onValueChange,\n suggestions,\n emptyText,\n filter = defaultFilter,\n openOnFocus = true,\n id: idProp,\n size,\n disabled,\n readOnly,\n className,\n style,\n css,\n onFocus,\n onBlur,\n onKeyDown,\n ...props\n },\n ref,\n ) => {\n const { colors } = useVanillaExtractTheme();\n const { style: cssStyles, vars } = processCSSProp(css, colors);\n\n const autoId = useId();\n const id = idProp ?? autoId;\n const listId = `${id}-listbox`;\n const optionId = (index: number) => `${id}-option-${index}`;\n\n const anchorRef = useRef<HTMLDivElement>(null);\n const [innerValue, setInnerValue] = useState(defaultValue);\n const value = valueProp ?? innerValue;\n const [open, setOpen] = useState(false);\n const [query, setQuery] = useState('');\n const [highlighted, setHighlighted] = useState(-1);\n\n const shown = query ? suggestions.filter((s) => filter(s, query)) : suggestions;\n const showEmpty = emptyText != null && suggestions.length === 0;\n const popupOpen = open && (shown.length > 0 || showEmpty);\n const listOpen = popupOpen && shown.length > 0;\n const active = listOpen && highlighted < shown.length ? highlighted : -1;\n\n useEffect(() => {\n if (active >= 0) {\n document.getElementById(`${id}-option-${active}`)?.scrollIntoView?.({ block: 'nearest' });\n }\n }, [active, id]);\n\n const setValue = (next: string) => {\n if (valueProp === undefined) setInnerValue(next);\n onValueChange?.(next);\n };\n\n const close = () => {\n setOpen(false);\n setQuery('');\n setHighlighted(-1);\n };\n\n const choose = (suggestion: string) => {\n setValue(suggestion);\n close();\n };\n\n const interactive = !disabled && !readOnly;\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n onKeyDown?.(e);\n if (e.defaultPrevented || !interactive) return;\n\n const last = shown.length - 1;\n switch (e.key) {\n case 'ArrowDown':\n e.preventDefault();\n if (!open) {\n setOpen(true);\n setHighlighted(e.altKey ? -1 : 0);\n } else if (!e.altKey) {\n setHighlighted(active >= last ? 0 : active + 1);\n }\n break;\n case 'ArrowUp':\n e.preventDefault();\n if (!open) {\n setOpen(true);\n setHighlighted(last);\n } else {\n setHighlighted(active <= 0 ? last : active - 1);\n }\n break;\n case 'Enter':\n if (active >= 0) {\n e.preventDefault();\n choose(shown[active]);\n }\n break;\n case 'Escape':\n if (popupOpen) {\n e.preventDefault();\n close();\n }\n break;\n default:\n break;\n }\n };\n\n return (\n <PopoverPrimitive.Root open={popupOpen} onOpenChange={(next) => !next && close()}>\n <PopoverPrimitive.Anchor asChild>\n <div\n ref={anchorRef}\n className={cx(comboboxAnchor, className)}\n style={{ ...cssStyles, ...style, ...assignInlineVars(vars) }}\n >\n <InputVanilla\n ref={ref}\n id={id}\n role=\"combobox\"\n aria-autocomplete=\"list\"\n aria-expanded={listOpen}\n aria-controls={listOpen ? listId : undefined}\n aria-activedescendant={active >= 0 ? optionId(active) : undefined}\n autoComplete=\"off\"\n size={size}\n disabled={disabled}\n readOnly={readOnly}\n value={value}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n setValue(e.target.value);\n setQuery(e.target.value);\n setOpen(true);\n setHighlighted(-1);\n }}\n onFocus={(e: React.FocusEvent<HTMLInputElement>) => {\n onFocus?.(e);\n if (openOnFocus && interactive) {\n setOpen(true);\n setQuery('');\n setHighlighted(-1);\n }\n }}\n onBlur={(e: React.FocusEvent<HTMLInputElement>) => {\n onBlur?.(e);\n close();\n }}\n onKeyDown={handleKeyDown}\n {...props}\n />\n </div>\n </PopoverPrimitive.Anchor>\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n role={undefined}\n id={undefined}\n className={comboboxContent}\n side=\"bottom\"\n align=\"start\"\n sideOffset={4}\n collisionPadding={8}\n onOpenAutoFocus={(e) => e.preventDefault()}\n onCloseAutoFocus={(e) => e.preventDefault()}\n onInteractOutside={(e) => {\n if (anchorRef.current?.contains(e.target as Node)) e.preventDefault();\n }}\n // Keeps the focus in the input, so a click on an option does not blur it.\n onMouseDown={(e) => e.preventDefault()}\n >\n {listOpen ? (\n <ul\n id={listId}\n role=\"listbox\"\n aria-label={\n props['aria-labelledby'] ? undefined : (props['aria-label'] ?? 'Suggestions')\n }\n aria-labelledby={props['aria-labelledby']}\n className={comboboxListbox}\n >\n {shown.map((suggestion, index) => (\n <li\n key={optionId(index)}\n id={optionId(index)}\n role=\"option\"\n aria-selected={index === active}\n data-highlighted={index === active ? '' : undefined}\n className={comboboxOptionRecipe({ size })}\n onMouseMove={() => index !== active && setHighlighted(index)}\n onClick={() => choose(suggestion)}\n >\n {suggestion}\n </li>\n ))}\n </ul>\n ) : (\n <div role=\"status\" className={comboboxEmptyRecipe({ size })}>\n {emptyText}\n </div>\n )}\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n </PopoverPrimitive.Root>\n );\n },\n);\n\nComboboxVanilla.displayName = 'ComboboxVanilla';\n"],"mappings":";;;;;;;;;;;;;AAgBA,IAAM,iBAAiB,YAAoB,UACzC,WAAW,YAAY,CAAC,CAAC,SAAS,MAAM,YAAY,CAAC;AAevD,IAAa,mBAAA,GAAkBA,MAAAA,WAAAA,EAE3B,EACE,OAAO,WACP,eAAe,IACf,eACA,aACA,WACA,SAAS,eACT,cAAc,MACd,IAAI,QACJ,MACA,UACA,UACA,WACA,OACA,KACA,SACA,QACA,WACA,GAAG,SAEL,QACG;CACH,MAAM,EAAE,WAAWC,qBAAAA,uBAAuB;CAC1C,MAAM,EAAE,OAAO,WAAW,SAASC,iBAAAA,eAAe,KAAK,MAAM;CAE7D,MAAM,UAAA,GAASC,MAAAA,MAAAA,CAAM;CACrB,MAAM,KAAK,UAAU;CACrB,MAAM,SAAS,GAAG,GAAG;CACrB,MAAM,YAAY,UAAkB,GAAG,GAAG,UAAU;CAEpD,MAAM,aAAA,GAAYC,MAAAA,OAAAA,CAAuB,IAAI;CAC7C,MAAM,CAAC,YAAY,kBAAA,GAAiBC,MAAAA,SAAAA,CAAS,YAAY;CACzD,MAAM,QAAQ,aAAa;CAC3B,MAAM,CAAC,MAAM,YAAA,GAAWA,MAAAA,SAAAA,CAAS,KAAK;CACtC,MAAM,CAAC,OAAO,aAAA,GAAYA,M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AAA,IAAA,CAACA,wBAAiB,SAAlB;GACE,MAAM,KAAA;GACN,IAAI,KAAA;GACJ,WAAWK,6BAAAA;GACX,MAAK;GACL,OAAM;GACN,YAAY;GACZ,kBAAkB;GAClB,kBAAkB,MAAM,EAAE,eAAe;GACzC,mBAAmB,MAAM,EAAE,eAAe;GAC1C,oBAAoB,MAAM;IACxB,IAAI,UAAU,SAAS,SAAS,EAAE,MAAc,GAAG,EAAE,eAAe;GACtE;GAEA,cAAc,MAAM,EAAE,eAAe;GAEpC,UAAA,WACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,MAAD;IACE,IAAI;IACJ,MAAK;IACL,cACE,MAAM,qBAAqB,KAAA,IAAa,MAAM,iBAAiB;IAEjE,mBAAiB,MAAM;IACvB,WAAWC,6BAAAA;IAEV,UAAA,MAAM,KAAK,YAAY,UACtB,iBAAA,GAAA,kBAAA,IAAA,CAAC,MAAD;KAEE,IAAI,SAAS,KAAK;KAClB,MAAK;KACL,iBAAe,UAAU;KACzB,oBAAkB,UAAU,SAAS,KAAK,KAAA;KAC1C,WAAWC,6BAAAA,qBAAqB,EAAE,KAAK,CAAC;KACxC,mBAAmB,UAAU,UAAU,eAAe,KAAK;KAC3D,eAAe,OAAO,UAAU;KAE/B,UAAA;IACC,GAVG,SAAS,KAAK,CAUjB,CACL;GACC,CAAA,IAEJ,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;IAAK,MAAK;IAAS,WAAWC,6BAAAA,oBAAoB,EAAE,KAAK,CAAC;IACvD,UAAA;GACE,CAAA;EAEiB,CAAA,EACH,CAAA,CACJ;;AAE3B,CACF;AAEA,gBAAgB,cAAc"}
|
|
1
|
+
{"version":3,"file":"Combobox.vanilla.cjs","names":["forwardRef","useInlineStyle","useId","useRef","useState","PopoverPrimitive","cx","comboboxAnchor","InputVanilla","comboboxContent","comboboxListbox","comboboxOptionRecipe","comboboxEmptyRecipe"],"sources":["../../../components/Combobox/Combobox.vanilla.tsx"],"sourcesContent":["import * as PopoverPrimitive from '@radix-ui/react-popover';\nimport React, { forwardRef, useEffect, useId, useRef, useState } from 'react';\n\nimport { CSSProps } from '@/styles/cssProps';\nimport { cx } from '@/styles/cx';\nimport { useInlineStyle } from '@/styles/useInlineStyle';\n\nimport { InputVanilla, InputVanillaHandle, InputVanillaProps } from '@/components/Input/Input.vanilla';\n\nimport {\n comboboxAnchor,\n comboboxContent,\n comboboxEmptyRecipe,\n comboboxListbox,\n comboboxOptionRecipe,\n} from './Combobox.vanilla.css';\n\nconst defaultFilter = (suggestion: string, query: string) =>\n suggestion.toLowerCase().includes(query.toLowerCase());\n\nexport interface ComboboxVanillaProps\n extends\n Omit<InputVanillaProps, 'value' | 'defaultValue' | 'onChange' | 'type' | 'role' | 'css'>,\n CSSProps {\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n suggestions: string[];\n emptyText?: React.ReactNode;\n filter?: (suggestion: string, query: string) => boolean;\n openOnFocus?: boolean;\n}\n\nexport const ComboboxVanilla = forwardRef<InputVanillaHandle, ComboboxVanillaProps>(\n (\n {\n value: valueProp,\n defaultValue = '',\n onValueChange,\n suggestions,\n emptyText,\n filter = defaultFilter,\n openOnFocus = true,\n id: idProp,\n size,\n disabled,\n readOnly,\n className,\n style,\n css,\n onFocus,\n onBlur,\n onKeyDown,\n ...props\n },\n ref,\n ) => {\n const inlineStyle = useInlineStyle(css, style);\n\n const autoId = useId();\n const id = idProp ?? autoId;\n const listId = `${id}-listbox`;\n const optionId = (index: number) => `${id}-option-${index}`;\n\n const anchorRef = useRef<HTMLDivElement>(null);\n const [innerValue, setInnerValue] = useState(defaultValue);\n const value = valueProp ?? innerValue;\n const [open, setOpen] = useState(false);\n const [query, setQuery] = useState('');\n const [highlighted, setHighlighted] = useState(-1);\n\n const shown = query ? suggestions.filter((s) => filter(s, query)) : suggestions;\n const showEmpty = emptyText != null && suggestions.length === 0;\n const popupOpen = open && (shown.length > 0 || showEmpty);\n const listOpen = popupOpen && shown.length > 0;\n const active = listOpen && highlighted < shown.length ? highlighted : -1;\n\n useEffect(() => {\n if (active >= 0) {\n document.getElementById(`${id}-option-${active}`)?.scrollIntoView?.({ block: 'nearest' });\n }\n }, [active, id]);\n\n const setValue = (next: string) => {\n if (valueProp === undefined) setInnerValue(next);\n onValueChange?.(next);\n };\n\n const close = () => {\n setOpen(false);\n setQuery('');\n setHighlighted(-1);\n };\n\n const choose = (suggestion: string) => {\n setValue(suggestion);\n close();\n };\n\n const interactive = !disabled && !readOnly;\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n onKeyDown?.(e);\n if (e.defaultPrevented || !interactive) return;\n\n const last = shown.length - 1;\n switch (e.key) {\n case 'ArrowDown':\n e.preventDefault();\n if (!open) {\n setOpen(true);\n setHighlighted(e.altKey ? -1 : 0);\n } else if (!e.altKey) {\n setHighlighted(active >= last ? 0 : active + 1);\n }\n break;\n case 'ArrowUp':\n e.preventDefault();\n if (!open) {\n setOpen(true);\n setHighlighted(last);\n } else {\n setHighlighted(active <= 0 ? last : active - 1);\n }\n break;\n case 'Enter':\n if (active >= 0) {\n e.preventDefault();\n choose(shown[active]);\n }\n break;\n case 'Escape':\n if (popupOpen) {\n e.preventDefault();\n close();\n }\n break;\n default:\n break;\n }\n };\n\n return (\n <PopoverPrimitive.Root open={popupOpen} onOpenChange={(next) => !next && close()}>\n <PopoverPrimitive.Anchor asChild>\n <div ref={anchorRef} className={cx(comboboxAnchor, className)} style={inlineStyle}>\n <InputVanilla\n ref={ref}\n id={id}\n role=\"combobox\"\n aria-autocomplete=\"list\"\n aria-expanded={listOpen}\n aria-controls={listOpen ? listId : undefined}\n aria-activedescendant={active >= 0 ? optionId(active) : undefined}\n autoComplete=\"off\"\n size={size}\n disabled={disabled}\n readOnly={readOnly}\n value={value}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n setValue(e.target.value);\n setQuery(e.target.value);\n setOpen(true);\n setHighlighted(-1);\n }}\n onFocus={(e: React.FocusEvent<HTMLInputElement>) => {\n onFocus?.(e);\n if (openOnFocus && interactive) {\n setOpen(true);\n setQuery('');\n setHighlighted(-1);\n }\n }}\n onBlur={(e: React.FocusEvent<HTMLInputElement>) => {\n onBlur?.(e);\n close();\n }}\n onKeyDown={handleKeyDown}\n {...props}\n />\n </div>\n </PopoverPrimitive.Anchor>\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n role={undefined}\n id={undefined}\n className={comboboxContent}\n side=\"bottom\"\n align=\"start\"\n sideOffset={4}\n collisionPadding={8}\n onOpenAutoFocus={(e) => e.preventDefault()}\n onCloseAutoFocus={(e) => e.preventDefault()}\n onInteractOutside={(e) => {\n if (anchorRef.current?.contains(e.target as Node)) e.preventDefault();\n }}\n // Keeps the focus in the input, so a click on an option does not blur it.\n onMouseDown={(e) => e.preventDefault()}\n >\n {listOpen ? (\n <ul\n id={listId}\n role=\"listbox\"\n aria-label={\n props['aria-labelledby'] ? undefined : (props['aria-label'] ?? 'Suggestions')\n }\n aria-labelledby={props['aria-labelledby']}\n className={comboboxListbox}\n >\n {shown.map((suggestion, index) => (\n <li\n key={optionId(index)}\n id={optionId(index)}\n role=\"option\"\n aria-selected={index === active}\n data-highlighted={index === active ? '' : undefined}\n className={comboboxOptionRecipe({ size })}\n onMouseMove={() => index !== active && setHighlighted(index)}\n onClick={() => choose(suggestion)}\n >\n {suggestion}\n </li>\n ))}\n </ul>\n ) : (\n <div role=\"status\" className={comboboxEmptyRecipe({ size })}>\n {emptyText}\n </div>\n )}\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n </PopoverPrimitive.Root>\n );\n },\n);\n\nComboboxVanilla.displayName = 'ComboboxVanilla';\n"],"mappings":";;;;;;;;;;;AAiBA,IAAM,iBAAiB,YAAoB,UACzC,WAAW,YAAY,CAAC,CAAC,SAAS,MAAM,YAAY,CAAC;AAevD,IAAa,mBAAA,GAAkBA,MAAAA,WAAAA,EAE3B,EACE,OAAO,WACP,eAAe,IACf,eACA,aACA,WACA,SAA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;IACC,GAVG,SAAS,KAAK,CAUjB,CACL;GACC,CAAA,IAEJ,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;IAAK,MAAK;IAAS,WAAWC,6BAAAA,oBAAoB,EAAE,KAAK,CAAC;IACvD,UAAA;GACE,CAAA;EAEiB,CAAA,EACH,CAAA,CACJ;;AAE3B,CACF;AAEA,gBAAgB,cAAc"}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import { processCSSProp } from "../../styles/cssProps.js";
|
|
2
1
|
import { cx } from "../../styles/cx.js";
|
|
3
|
-
import {
|
|
2
|
+
import { useInlineStyle } from "../../styles/useInlineStyle.js";
|
|
4
3
|
import { InputVanilla } from "../Input/Input.vanilla.js";
|
|
5
4
|
import { comboboxAnchor, comboboxContent, comboboxEmptyRecipe, comboboxListbox, comboboxOptionRecipe } from "./Combobox.vanilla.css.js";
|
|
6
5
|
import { forwardRef, useEffect, useId, useRef, useState } from "react";
|
|
7
|
-
import { assignInlineVars } from "@vanilla-extract/dynamic";
|
|
8
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
7
|
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
10
8
|
// components/Combobox/Combobox.vanilla.tsx
|
|
11
9
|
var defaultFilter = (suggestion, query) => suggestion.toLowerCase().includes(query.toLowerCase());
|
|
12
10
|
var ComboboxVanilla = forwardRef(({ value: valueProp, defaultValue = "", onValueChange, suggestions, emptyText, filter = defaultFilter, openOnFocus = true, id: idProp, size, disabled, readOnly, className, style, css, onFocus, onBlur, onKeyDown, ...props }, ref) => {
|
|
13
|
-
const
|
|
14
|
-
const { style: cssStyles, vars } = processCSSProp(css, colors);
|
|
11
|
+
const inlineStyle = useInlineStyle(css, style);
|
|
15
12
|
const autoId = useId();
|
|
16
13
|
const id = idProp ?? autoId;
|
|
17
14
|
const listId = `${id}-listbox`;
|
|
@@ -83,11 +80,7 @@ var ComboboxVanilla = forwardRef(({ value: valueProp, defaultValue = "", onValue
|
|
|
83
80
|
children: /* @__PURE__ */ jsx("div", {
|
|
84
81
|
ref: anchorRef,
|
|
85
82
|
className: cx(comboboxAnchor, className),
|
|
86
|
-
style:
|
|
87
|
-
...cssStyles,
|
|
88
|
-
...style,
|
|
89
|
-
...assignInlineVars(vars)
|
|
90
|
-
},
|
|
83
|
+
style: inlineStyle,
|
|
91
84
|
children: /* @__PURE__ */ jsx(InputVanilla, {
|
|
92
85
|
ref,
|
|
93
86
|
id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Combobox.vanilla.js","names":[],"sources":["../../../components/Combobox/Combobox.vanilla.tsx"],"sourcesContent":["import * as PopoverPrimitive from '@radix-ui/react-popover';\nimport { assignInlineVars } from '@vanilla-extract/dynamic';\nimport React, { forwardRef, useEffect, useId, useRef, useState } from 'react';\n\nimport { CSSProps, processCSSProp } from '../../styles/cssProps';\nimport { cx } from '../../styles/cx';\nimport { useVanillaExtractTheme } from '../../styles/themeContext';\nimport { InputVanilla, InputVanillaHandle, InputVanillaProps } from '../Input/Input.vanilla';\nimport {\n comboboxAnchor,\n comboboxContent,\n comboboxEmptyRecipe,\n comboboxListbox,\n comboboxOptionRecipe,\n} from './Combobox.vanilla.css';\n\nconst defaultFilter = (suggestion: string, query: string) =>\n suggestion.toLowerCase().includes(query.toLowerCase());\n\nexport interface ComboboxVanillaProps\n extends\n Omit<InputVanillaProps, 'value' | 'defaultValue' | 'onChange' | 'type' | 'role' | 'css'>,\n CSSProps {\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n suggestions: string[];\n emptyText?: React.ReactNode;\n filter?: (suggestion: string, query: string) => boolean;\n openOnFocus?: boolean;\n}\n\nexport const ComboboxVanilla = forwardRef<InputVanillaHandle, ComboboxVanillaProps>(\n (\n {\n value: valueProp,\n defaultValue = '',\n onValueChange,\n suggestions,\n emptyText,\n filter = defaultFilter,\n openOnFocus = true,\n id: idProp,\n size,\n disabled,\n readOnly,\n className,\n style,\n css,\n onFocus,\n onBlur,\n onKeyDown,\n ...props\n },\n ref,\n ) => {\n const { colors } = useVanillaExtractTheme();\n const { style: cssStyles, vars } = processCSSProp(css, colors);\n\n const autoId = useId();\n const id = idProp ?? autoId;\n const listId = `${id}-listbox`;\n const optionId = (index: number) => `${id}-option-${index}`;\n\n const anchorRef = useRef<HTMLDivElement>(null);\n const [innerValue, setInnerValue] = useState(defaultValue);\n const value = valueProp ?? innerValue;\n const [open, setOpen] = useState(false);\n const [query, setQuery] = useState('');\n const [highlighted, setHighlighted] = useState(-1);\n\n const shown = query ? suggestions.filter((s) => filter(s, query)) : suggestions;\n const showEmpty = emptyText != null && suggestions.length === 0;\n const popupOpen = open && (shown.length > 0 || showEmpty);\n const listOpen = popupOpen && shown.length > 0;\n const active = listOpen && highlighted < shown.length ? highlighted : -1;\n\n useEffect(() => {\n if (active >= 0) {\n document.getElementById(`${id}-option-${active}`)?.scrollIntoView?.({ block: 'nearest' });\n }\n }, [active, id]);\n\n const setValue = (next: string) => {\n if (valueProp === undefined) setInnerValue(next);\n onValueChange?.(next);\n };\n\n const close = () => {\n setOpen(false);\n setQuery('');\n setHighlighted(-1);\n };\n\n const choose = (suggestion: string) => {\n setValue(suggestion);\n close();\n };\n\n const interactive = !disabled && !readOnly;\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n onKeyDown?.(e);\n if (e.defaultPrevented || !interactive) return;\n\n const last = shown.length - 1;\n switch (e.key) {\n case 'ArrowDown':\n e.preventDefault();\n if (!open) {\n setOpen(true);\n setHighlighted(e.altKey ? -1 : 0);\n } else if (!e.altKey) {\n setHighlighted(active >= last ? 0 : active + 1);\n }\n break;\n case 'ArrowUp':\n e.preventDefault();\n if (!open) {\n setOpen(true);\n setHighlighted(last);\n } else {\n setHighlighted(active <= 0 ? last : active - 1);\n }\n break;\n case 'Enter':\n if (active >= 0) {\n e.preventDefault();\n choose(shown[active]);\n }\n break;\n case 'Escape':\n if (popupOpen) {\n e.preventDefault();\n close();\n }\n break;\n default:\n break;\n }\n };\n\n return (\n <PopoverPrimitive.Root open={popupOpen} onOpenChange={(next) => !next && close()}>\n <PopoverPrimitive.Anchor asChild>\n <div\n ref={anchorRef}\n className={cx(comboboxAnchor, className)}\n style={{ ...cssStyles, ...style, ...assignInlineVars(vars) }}\n >\n <InputVanilla\n ref={ref}\n id={id}\n role=\"combobox\"\n aria-autocomplete=\"list\"\n aria-expanded={listOpen}\n aria-controls={listOpen ? listId : undefined}\n aria-activedescendant={active >= 0 ? optionId(active) : undefined}\n autoComplete=\"off\"\n size={size}\n disabled={disabled}\n readOnly={readOnly}\n value={value}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n setValue(e.target.value);\n setQuery(e.target.value);\n setOpen(true);\n setHighlighted(-1);\n }}\n onFocus={(e: React.FocusEvent<HTMLInputElement>) => {\n onFocus?.(e);\n if (openOnFocus && interactive) {\n setOpen(true);\n setQuery('');\n setHighlighted(-1);\n }\n }}\n onBlur={(e: React.FocusEvent<HTMLInputElement>) => {\n onBlur?.(e);\n close();\n }}\n onKeyDown={handleKeyDown}\n {...props}\n />\n </div>\n </PopoverPrimitive.Anchor>\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n role={undefined}\n id={undefined}\n className={comboboxContent}\n side=\"bottom\"\n align=\"start\"\n sideOffset={4}\n collisionPadding={8}\n onOpenAutoFocus={(e) => e.preventDefault()}\n onCloseAutoFocus={(e) => e.preventDefault()}\n onInteractOutside={(e) => {\n if (anchorRef.current?.contains(e.target as Node)) e.preventDefault();\n }}\n // Keeps the focus in the input, so a click on an option does not blur it.\n onMouseDown={(e) => e.preventDefault()}\n >\n {listOpen ? (\n <ul\n id={listId}\n role=\"listbox\"\n aria-label={\n props['aria-labelledby'] ? undefined : (props['aria-label'] ?? 'Suggestions')\n }\n aria-labelledby={props['aria-labelledby']}\n className={comboboxListbox}\n >\n {shown.map((suggestion, index) => (\n <li\n key={optionId(index)}\n id={optionId(index)}\n role=\"option\"\n aria-selected={index === active}\n data-highlighted={index === active ? '' : undefined}\n className={comboboxOptionRecipe({ size })}\n onMouseMove={() => index !== active && setHighlighted(index)}\n onClick={() => choose(suggestion)}\n >\n {suggestion}\n </li>\n ))}\n </ul>\n ) : (\n <div role=\"status\" className={comboboxEmptyRecipe({ size })}>\n {emptyText}\n </div>\n )}\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n </PopoverPrimitive.Root>\n );\n },\n);\n\nComboboxVanilla.displayName = 'ComboboxVanilla';\n"],"mappings":";;;;;;;;;;AAgBA,IAAM,iBAAiB,YAAoB,UACzC,WAAW,YAAY,CAAC,CAAC,SAAS,MAAM,YAAY,CAAC;AAevD,IAAa,kBAAkB,YAE3B,EACE,OAAO,WACP,eAAe,IACf,eACA,aACA,WACA,SAAS,eACT,cAAc,MACd,IAAI,QACJ,MACA,UACA,UACA,WACA,OACA,KACA,SACA,QACA,WACA,GAAG,SAEL,QACG;CACH,MAAM,EAAE,WAAW,uBAAuB;CAC1C,MAAM,EAAE,OAAO,WAAW,SAAS,eAAe,KAAK,MAAM;CAE7D,MAAM,SAAS,MAAM;CACrB,MAAM,KAAK,UAAU;CACrB,MAAM,SAAS,GAAG,GAAG;CACrB,MAAM,YAAY,UAAkB,GAAG,GAAG,UAAU;CAEpD,MAAM,YAAY,OAAuB,IAAI;CAC7C,MAAM,CAAC,YAAY,iBAAiB,SAAS,YAAY;CACzD,MAAM,QAAQ,aAAa;CAC3B,MAAM,CAAC,MAAM,WAAW,SAAS,KAAK;CACtC,MAAM,CAAC,OAAO,YAAY,SAAS,EAAE;CACrC,MAAM,CAAC,aAAa,kBAAkB,SAAS,EAAE;CAEjD,MAAM,QAAQ,QAAQ,YAAY,QAAQ,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI;CACpE,MAAM,YAAY,aAAa,QAAQ,YAAY,WAAW;CAC9D,MAAM,YAAY,SAAS,MAAM,SAAS,KAAK;CAC/C,MAAM,WAAW,aAAa,MAAM,SAAS;CAC7C,MAAM,SAAS,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iBAAe,UAAU;KACzB,oBAAkB,UAAU,SAAS,KAAK,KAAA;KAC1C,WAAW,qBAAqB,EAAE,KAAK,CAAC;KACxC,mBAAmB,UAAU,UAAU,eAAe,KAAK;KAC3D,eAAe,OAAO,UAAU;KAE/B,UAAA;IACC,GAVG,SAAS,KAAK,CAUjB,CACL;GACC,CAAA,IAEJ,oBAAC,OAAD;IAAK,MAAK;IAAS,WAAW,oBAAoB,EAAE,KAAK,CAAC;IACvD,UAAA;GACE,CAAA;EAEiB,CAAA,EACH,CAAA,CACJ;;AAE3B,CACF;AAEA,gBAAgB,cAAc"}
|
|
1
|
+
{"version":3,"file":"Combobox.vanilla.js","names":[],"sources":["../../../components/Combobox/Combobox.vanilla.tsx"],"sourcesContent":["import * as PopoverPrimitive from '@radix-ui/react-popover';\nimport React, { forwardRef, useEffect, useId, useRef, useState } from 'react';\n\nimport { CSSProps } from '@/styles/cssProps';\nimport { cx } from '@/styles/cx';\nimport { useInlineStyle } from '@/styles/useInlineStyle';\n\nimport { InputVanilla, InputVanillaHandle, InputVanillaProps } from '@/components/Input/Input.vanilla';\n\nimport {\n comboboxAnchor,\n comboboxContent,\n comboboxEmptyRecipe,\n comboboxListbox,\n comboboxOptionRecipe,\n} from './Combobox.vanilla.css';\n\nconst defaultFilter = (suggestion: string, query: string) =>\n suggestion.toLowerCase().includes(query.toLowerCase());\n\nexport interface ComboboxVanillaProps\n extends\n Omit<InputVanillaProps, 'value' | 'defaultValue' | 'onChange' | 'type' | 'role' | 'css'>,\n CSSProps {\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n suggestions: string[];\n emptyText?: React.ReactNode;\n filter?: (suggestion: string, query: string) => boolean;\n openOnFocus?: boolean;\n}\n\nexport const ComboboxVanilla = forwardRef<InputVanillaHandle, ComboboxVanillaProps>(\n (\n {\n value: valueProp,\n defaultValue = '',\n onValueChange,\n suggestions,\n emptyText,\n filter = defaultFilter,\n openOnFocus = true,\n id: idProp,\n size,\n disabled,\n readOnly,\n className,\n style,\n css,\n onFocus,\n onBlur,\n onKeyDown,\n ...props\n },\n ref,\n ) => {\n const inlineStyle = useInlineStyle(css, style);\n\n const autoId = useId();\n const id = idProp ?? autoId;\n const listId = `${id}-listbox`;\n const optionId = (index: number) => `${id}-option-${index}`;\n\n const anchorRef = useRef<HTMLDivElement>(null);\n const [innerValue, setInnerValue] = useState(defaultValue);\n const value = valueProp ?? innerValue;\n const [open, setOpen] = useState(false);\n const [query, setQuery] = useState('');\n const [highlighted, setHighlighted] = useState(-1);\n\n const shown = query ? suggestions.filter((s) => filter(s, query)) : suggestions;\n const showEmpty = emptyText != null && suggestions.length === 0;\n const popupOpen = open && (shown.length > 0 || showEmpty);\n const listOpen = popupOpen && shown.length > 0;\n const active = listOpen && highlighted < shown.length ? highlighted : -1;\n\n useEffect(() => {\n if (active >= 0) {\n document.getElementById(`${id}-option-${active}`)?.scrollIntoView?.({ block: 'nearest' });\n }\n }, [active, id]);\n\n const setValue = (next: string) => {\n if (valueProp === undefined) setInnerValue(next);\n onValueChange?.(next);\n };\n\n const close = () => {\n setOpen(false);\n setQuery('');\n setHighlighted(-1);\n };\n\n const choose = (suggestion: string) => {\n setValue(suggestion);\n close();\n };\n\n const interactive = !disabled && !readOnly;\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n onKeyDown?.(e);\n if (e.defaultPrevented || !interactive) return;\n\n const last = shown.length - 1;\n switch (e.key) {\n case 'ArrowDown':\n e.preventDefault();\n if (!open) {\n setOpen(true);\n setHighlighted(e.altKey ? -1 : 0);\n } else if (!e.altKey) {\n setHighlighted(active >= last ? 0 : active + 1);\n }\n break;\n case 'ArrowUp':\n e.preventDefault();\n if (!open) {\n setOpen(true);\n setHighlighted(last);\n } else {\n setHighlighted(active <= 0 ? last : active - 1);\n }\n break;\n case 'Enter':\n if (active >= 0) {\n e.preventDefault();\n choose(shown[active]);\n }\n break;\n case 'Escape':\n if (popupOpen) {\n e.preventDefault();\n close();\n }\n break;\n default:\n break;\n }\n };\n\n return (\n <PopoverPrimitive.Root open={popupOpen} onOpenChange={(next) => !next && close()}>\n <PopoverPrimitive.Anchor asChild>\n <div ref={anchorRef} className={cx(comboboxAnchor, className)} style={inlineStyle}>\n <InputVanilla\n ref={ref}\n id={id}\n role=\"combobox\"\n aria-autocomplete=\"list\"\n aria-expanded={listOpen}\n aria-controls={listOpen ? listId : undefined}\n aria-activedescendant={active >= 0 ? optionId(active) : undefined}\n autoComplete=\"off\"\n size={size}\n disabled={disabled}\n readOnly={readOnly}\n value={value}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n setValue(e.target.value);\n setQuery(e.target.value);\n setOpen(true);\n setHighlighted(-1);\n }}\n onFocus={(e: React.FocusEvent<HTMLInputElement>) => {\n onFocus?.(e);\n if (openOnFocus && interactive) {\n setOpen(true);\n setQuery('');\n setHighlighted(-1);\n }\n }}\n onBlur={(e: React.FocusEvent<HTMLInputElement>) => {\n onBlur?.(e);\n close();\n }}\n onKeyDown={handleKeyDown}\n {...props}\n />\n </div>\n </PopoverPrimitive.Anchor>\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n role={undefined}\n id={undefined}\n className={comboboxContent}\n side=\"bottom\"\n align=\"start\"\n sideOffset={4}\n collisionPadding={8}\n onOpenAutoFocus={(e) => e.preventDefault()}\n onCloseAutoFocus={(e) => e.preventDefault()}\n onInteractOutside={(e) => {\n if (anchorRef.current?.contains(e.target as Node)) e.preventDefault();\n }}\n // Keeps the focus in the input, so a click on an option does not blur it.\n onMouseDown={(e) => e.preventDefault()}\n >\n {listOpen ? (\n <ul\n id={listId}\n role=\"listbox\"\n aria-label={\n props['aria-labelledby'] ? undefined : (props['aria-label'] ?? 'Suggestions')\n }\n aria-labelledby={props['aria-labelledby']}\n className={comboboxListbox}\n >\n {shown.map((suggestion, index) => (\n <li\n key={optionId(index)}\n id={optionId(index)}\n role=\"option\"\n aria-selected={index === active}\n data-highlighted={index === active ? '' : undefined}\n className={comboboxOptionRecipe({ size })}\n onMouseMove={() => index !== active && setHighlighted(index)}\n onClick={() => choose(suggestion)}\n >\n {suggestion}\n </li>\n ))}\n </ul>\n ) : (\n <div role=\"status\" className={comboboxEmptyRecipe({ size })}>\n {emptyText}\n </div>\n )}\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n </PopoverPrimitive.Root>\n );\n },\n);\n\nComboboxVanilla.displayName = 'ComboboxVanilla';\n"],"mappings":";;;;;;;;AAiBA,IAAM,iBAAiB,YAAoB,UACzC,WAAW,YAAY,CAAC,CAAC,SAAS,MAAM,YAAY,CAAC;AAevD,IAAa,kBAAkB,YAE3B,EACE,OAAO,WACP,eAAe,IACf,eACA,aACA,WACA,SAAS,eACT,cAAc,MACd,IAAI,QACJ,MACA,UACA,UACA,WACA,OACA,KACA,SACA,QACA,WACA,GAAG,SAEL,QACG;CACH,MAAM,cAAc,eAAe,KAAK,KAAK;CAE7C,MAAM,SAAS,MAAM;CACrB,MAAM,KAAK,UAAU;CACrB,MAAM,SAAS,GAAG,GAAG;CACrB,MAAM,YAAY,UAAkB,GAAG,GAAG,UAAU;CAEpD,MAAM,YAAY,OAAuB,IAAI;CAC7C,MAAM,CAAC,YAAY,iBAAiB,SAAS,YAAY;CACzD,MAAM,QAAQ,aAAa;CAC3B,MAAM,CAAC,MAAM,WAAW,SAAS,KAAK;CACtC,MAAM,CAAC,OAAO,YAAY,SAAS,EAAE;CACrC,MAAM,CAAC,aAAa,kBAAkB,SAAS,EAAE;CAEjD,MAAM,QAAQ,QAAQ,YAAY,QAAQ,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI;CACpE,MAAM,YAAY,aAAa,QAAQ,YAAY,WAAW;CAC9D,MAAM,YAAY,SAAS,MAAM,SAAS,KAAK;CAC/C,MAAM,WAAW,aAAa,MAAM,SAAS;CAC7C,MAAM,SAAS,YAAY,cAAc,MAAM,SAAS,cAAc;CAEtE,gBAAgB;EACd,IAAI,UAAU,GACZ,SAAS,eAAe,GAAG,GA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