@traefik-labs/faency 13.7.2 → 13.8.0
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/Select/Select.vanilla.cjs +136 -0
- package/dist/components/Select/Select.vanilla.cjs.map +1 -0
- package/dist/components/Select/Select.vanilla.css.cjs +69 -0
- package/dist/components/Select/Select.vanilla.css.cjs.map +1 -0
- package/dist/components/Select/Select.vanilla.css.js +58 -0
- package/dist/components/Select/Select.vanilla.css.js.map +1 -0
- package/dist/components/Select/Select.vanilla.js +129 -0
- package/dist/components/Select/Select.vanilla.js.map +1 -0
- package/dist/components/Switch/Switch.vanilla.cjs +70 -0
- package/dist/components/Switch/Switch.vanilla.cjs.map +1 -0
- package/dist/components/Switch/Switch.vanilla.css.cjs +17 -0
- package/dist/components/Switch/Switch.vanilla.css.cjs.map +1 -0
- package/dist/components/Switch/Switch.vanilla.css.js +17 -0
- package/dist/components/Switch/Switch.vanilla.css.js.map +1 -0
- package/dist/components/Switch/Switch.vanilla.js +68 -0
- package/dist/components/Switch/Switch.vanilla.js.map +1 -0
- package/dist/faency.css +2995 -2530
- package/dist/index.cjs +8 -0
- package/dist/index.d.cts +168 -0
- package/dist/index.d.ts +168 -0
- package/dist/index.js +3 -1
- package/dist/styles/tokens.css.cjs +146 -133
- package/dist/styles/tokens.css.js +146 -133
- package/package.json +2 -1
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_cx = require("../../styles/cx.cjs");
|
|
3
|
+
const require_useInlineStyle = require("../../styles/useInlineStyle.cjs");
|
|
4
|
+
const require_FieldContext = require("../Field/FieldContext.cjs");
|
|
5
|
+
const require_Select_vanilla_css = require("./Select.vanilla.css.cjs");
|
|
6
|
+
let _radix_ui_react_icons = require("@radix-ui/react-icons");
|
|
7
|
+
let react = require("react");
|
|
8
|
+
react = require_runtime.__toESM(react, 1);
|
|
9
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
|
+
let _radix_ui_react_select = require("@radix-ui/react-select");
|
|
11
|
+
_radix_ui_react_select = require_runtime.__toESM(_radix_ui_react_select, 1);
|
|
12
|
+
// components/Select/Select.vanilla.tsx
|
|
13
|
+
var SelectSizeContext = react.default.createContext("medium");
|
|
14
|
+
var SelectVanilla = react.default.forwardRef(({ value, defaultValue, onValueChange, open, defaultOpen, onOpenChange, name, form, required, autoComplete, disabled, dir, placeholder, size = "medium", variant, state, id, css, className, style, children, onBlur, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, ...props }, forwardedRef) => {
|
|
15
|
+
const contentRef = react.default.useRef(null);
|
|
16
|
+
const control = require_FieldContext.useFieldControl({
|
|
17
|
+
id,
|
|
18
|
+
disabled,
|
|
19
|
+
invalid: state === "invalid",
|
|
20
|
+
"aria-describedby": ariaDescribedBy,
|
|
21
|
+
"aria-invalid": ariaInvalid
|
|
22
|
+
});
|
|
23
|
+
const inlineStyle = require_useInlineStyle.useInlineStyle(css, style);
|
|
24
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectSizeContext.Provider, {
|
|
25
|
+
value: size,
|
|
26
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_radix_ui_react_select.Root, {
|
|
27
|
+
value,
|
|
28
|
+
defaultValue,
|
|
29
|
+
onValueChange,
|
|
30
|
+
open,
|
|
31
|
+
defaultOpen,
|
|
32
|
+
onOpenChange,
|
|
33
|
+
name,
|
|
34
|
+
form,
|
|
35
|
+
required,
|
|
36
|
+
autoComplete,
|
|
37
|
+
disabled: control.disabled,
|
|
38
|
+
dir,
|
|
39
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_radix_ui_react_select.Trigger, {
|
|
40
|
+
ref: forwardedRef,
|
|
41
|
+
id: control.id,
|
|
42
|
+
"aria-describedby": control["aria-describedby"],
|
|
43
|
+
"aria-invalid": control["aria-invalid"],
|
|
44
|
+
className: require_cx.cx(require_Select_vanilla_css.selectTriggerRecipe({
|
|
45
|
+
size,
|
|
46
|
+
variant,
|
|
47
|
+
state: control.invalid ? "invalid" : state
|
|
48
|
+
}), className),
|
|
49
|
+
style: inlineStyle,
|
|
50
|
+
onBlur: (event) => {
|
|
51
|
+
if (!contentRef.current?.contains(event.relatedTarget)) onBlur?.(event);
|
|
52
|
+
},
|
|
53
|
+
...props,
|
|
54
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
55
|
+
className: require_Select_vanilla_css.selectValue,
|
|
56
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_select.Value, { placeholder })
|
|
57
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_select.Icon, {
|
|
58
|
+
className: require_Select_vanilla_css.selectIcon,
|
|
59
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_icons.CaretSortIcon, {})
|
|
60
|
+
})]
|
|
61
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_select.Portal, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_radix_ui_react_select.Content, {
|
|
62
|
+
ref: contentRef,
|
|
63
|
+
className: require_Select_vanilla_css.selectContent,
|
|
64
|
+
position: "popper",
|
|
65
|
+
sideOffset: 4,
|
|
66
|
+
collisionPadding: 8,
|
|
67
|
+
children: [
|
|
68
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_select.ScrollUpButton, {
|
|
69
|
+
className: require_Select_vanilla_css.selectScrollButton,
|
|
70
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_icons.ChevronUpIcon, {})
|
|
71
|
+
}),
|
|
72
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_select.Viewport, {
|
|
73
|
+
className: require_Select_vanilla_css.selectViewport,
|
|
74
|
+
children
|
|
75
|
+
}),
|
|
76
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_select.ScrollDownButton, {
|
|
77
|
+
className: require_Select_vanilla_css.selectScrollButton,
|
|
78
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_icons.ChevronDownIcon, {})
|
|
79
|
+
})
|
|
80
|
+
]
|
|
81
|
+
}) })]
|
|
82
|
+
})
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
SelectVanilla.displayName = "SelectVanilla";
|
|
86
|
+
var SelectItemVanilla = react.default.forwardRef(({ description, children, css, className, style, ...props }, forwardedRef) => {
|
|
87
|
+
const size = react.default.useContext(SelectSizeContext);
|
|
88
|
+
const inlineStyle = require_useInlineStyle.useInlineStyle(css, style);
|
|
89
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_radix_ui_react_select.Item, {
|
|
90
|
+
ref: forwardedRef,
|
|
91
|
+
className: require_cx.cx(require_Select_vanilla_css.selectItemRecipe({ size }), className),
|
|
92
|
+
style: inlineStyle,
|
|
93
|
+
...props,
|
|
94
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
95
|
+
className: require_Select_vanilla_css.selectItemContent,
|
|
96
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_select.ItemText, { children }), description != null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
97
|
+
className: require_Select_vanilla_css.selectItemDescriptionRecipe({ size }),
|
|
98
|
+
children: description
|
|
99
|
+
})]
|
|
100
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
101
|
+
className: require_Select_vanilla_css.selectItemIndicator,
|
|
102
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_select.ItemIndicator, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_icons.CheckIcon, {}) })
|
|
103
|
+
})]
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
SelectItemVanilla.displayName = "SelectItemVanilla";
|
|
107
|
+
var SelectGroupVanilla = react.default.forwardRef(({ css, style, ...props }, forwardedRef) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_select.Group, {
|
|
108
|
+
ref: forwardedRef,
|
|
109
|
+
style: require_useInlineStyle.useInlineStyle(css, style),
|
|
110
|
+
...props
|
|
111
|
+
}));
|
|
112
|
+
SelectGroupVanilla.displayName = "SelectGroupVanilla";
|
|
113
|
+
var SelectLabelVanilla = react.default.forwardRef(({ css, className, style, ...props }, forwardedRef) => {
|
|
114
|
+
const size = react.default.useContext(SelectSizeContext);
|
|
115
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_select.Label, {
|
|
116
|
+
ref: forwardedRef,
|
|
117
|
+
className: require_cx.cx(require_Select_vanilla_css.selectLabelRecipe({ size }), className),
|
|
118
|
+
style: require_useInlineStyle.useInlineStyle(css, style),
|
|
119
|
+
...props
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
SelectLabelVanilla.displayName = "SelectLabelVanilla";
|
|
123
|
+
var SelectSeparatorVanilla = react.default.forwardRef(({ css, className, style, ...props }, forwardedRef) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_select.Separator, {
|
|
124
|
+
ref: forwardedRef,
|
|
125
|
+
className: require_cx.cx(require_Select_vanilla_css.selectSeparator, className),
|
|
126
|
+
style: require_useInlineStyle.useInlineStyle(css, style),
|
|
127
|
+
...props
|
|
128
|
+
}));
|
|
129
|
+
SelectSeparatorVanilla.displayName = "SelectSeparatorVanilla";
|
|
130
|
+
exports.SelectGroupVanilla = SelectGroupVanilla;
|
|
131
|
+
exports.SelectItemVanilla = SelectItemVanilla;
|
|
132
|
+
exports.SelectLabelVanilla = SelectLabelVanilla;
|
|
133
|
+
exports.SelectSeparatorVanilla = SelectSeparatorVanilla;
|
|
134
|
+
exports.SelectVanilla = SelectVanilla;
|
|
135
|
+
|
|
136
|
+
//# sourceMappingURL=Select.vanilla.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Select.vanilla.cjs","names":["React","useFieldControl","useInlineStyle","SelectPrimitive","cx","selectTriggerRecipe","selectValue","selectIcon","CaretSortIcon","selectContent","selectScrollButton","ChevronUpIcon","selectViewport","ChevronDownIcon","selectItemRecipe","selectItemContent","selectItemDescriptionRecipe","selectItemIndicator","CheckIcon","selectLabelRecipe","selectSeparator"],"sources":["../../../components/Select/Select.vanilla.tsx"],"sourcesContent":["import { CaretSortIcon, CheckIcon, ChevronDownIcon, ChevronUpIcon } from '@radix-ui/react-icons';\nimport * as SelectPrimitive from '@radix-ui/react-select';\nimport React from 'react';\n\nimport { CSSProps } from '@/styles/cssProps';\nimport { cx } from '@/styles/cx';\nimport type { RecipeVariantProps } from '@/styles/recipeVariants';\nimport { useInlineStyle } from '@/styles/useInlineStyle';\n\nimport { useFieldControl } from '@/components/Field/FieldContext';\n\nimport {\n selectContent,\n selectIcon,\n selectItemContent,\n selectItemDescriptionRecipe,\n selectItemIndicator,\n selectItemRecipe,\n selectLabelRecipe,\n selectScrollButton,\n selectSeparator,\n selectTriggerRecipe,\n selectValue,\n selectViewport,\n} from './Select.vanilla.css';\n\ntype SelectTriggerVariants = RecipeVariantProps<typeof selectTriggerRecipe>;\ntype SelectSize = NonNullable<SelectTriggerVariants['size']>;\n\nconst SelectSizeContext = React.createContext<SelectSize>('medium');\n\ntype SelectRootProps = Omit<\n SelectPrimitive.SelectProps,\n 'children' | 'autoComplete' | 'onValueChange'\n>;\n\nexport type SelectVanillaProps = Omit<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n keyof SelectRootProps | 'children' | 'type' | 'onChange'\n> &\n SelectRootProps &\n CSSProps & {\n onValueChange?: (value: string) => void;\n placeholder?: React.ReactNode;\n autoComplete?: string;\n size?: SelectTriggerVariants['size'];\n variant?: SelectTriggerVariants['variant'];\n state?: SelectTriggerVariants['state'];\n children?: React.ReactNode;\n };\n\nexport const SelectVanilla = React.forwardRef<HTMLButtonElement, SelectVanillaProps>(\n (\n {\n value,\n defaultValue,\n onValueChange,\n open,\n defaultOpen,\n onOpenChange,\n name,\n form,\n required,\n autoComplete,\n disabled,\n dir,\n placeholder,\n size = 'medium',\n variant,\n state,\n id,\n css,\n className,\n style,\n children,\n onBlur,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n ...props\n },\n forwardedRef,\n ) => {\n const contentRef = React.useRef<HTMLDivElement>(null);\n const control = useFieldControl({\n id,\n disabled,\n invalid: state === 'invalid',\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n });\n const inlineStyle = useInlineStyle(css, style);\n\n return (\n <SelectSizeContext.Provider value={size}>\n <SelectPrimitive.Root\n value={value}\n defaultValue={defaultValue}\n onValueChange={onValueChange}\n open={open}\n defaultOpen={defaultOpen}\n onOpenChange={onOpenChange}\n name={name}\n form={form}\n required={required}\n autoComplete={autoComplete}\n disabled={control.disabled}\n dir={dir}\n >\n <SelectPrimitive.Trigger\n ref={forwardedRef}\n id={control.id}\n aria-describedby={control['aria-describedby']}\n aria-invalid={control['aria-invalid']}\n className={cx(\n selectTriggerRecipe({\n size,\n variant,\n state: control.invalid ? 'invalid' : state,\n }),\n className,\n )}\n style={inlineStyle}\n onBlur={(event) => {\n // Focus moving into the open list is not leaving the field.\n if (!contentRef.current?.contains(event.relatedTarget)) onBlur?.(event);\n }}\n {...props}\n >\n {/* Radix drops the className of Value. */}\n <span className={selectValue}>\n <SelectPrimitive.Value placeholder={placeholder} />\n </span>\n <SelectPrimitive.Icon className={selectIcon}>\n <CaretSortIcon />\n </SelectPrimitive.Icon>\n </SelectPrimitive.Trigger>\n <SelectPrimitive.Portal>\n <SelectPrimitive.Content\n ref={contentRef}\n className={selectContent}\n position=\"popper\"\n sideOffset={4}\n collisionPadding={8}\n >\n <SelectPrimitive.ScrollUpButton className={selectScrollButton}>\n <ChevronUpIcon />\n </SelectPrimitive.ScrollUpButton>\n <SelectPrimitive.Viewport className={selectViewport}>\n {children}\n </SelectPrimitive.Viewport>\n <SelectPrimitive.ScrollDownButton className={selectScrollButton}>\n <ChevronDownIcon />\n </SelectPrimitive.ScrollDownButton>\n </SelectPrimitive.Content>\n </SelectPrimitive.Portal>\n </SelectPrimitive.Root>\n </SelectSizeContext.Provider>\n );\n },\n);\n\nSelectVanilla.displayName = 'SelectVanilla';\n\nexport type SelectItemVanillaProps = Omit<SelectPrimitive.SelectItemProps, 'asChild'> &\n CSSProps & {\n /** A second line under the item, shown in the list only. */\n description?: React.ReactNode;\n };\n\nexport const SelectItemVanilla = React.forwardRef<HTMLDivElement, SelectItemVanillaProps>(\n ({ description, children, css, className, style, ...props }, forwardedRef) => {\n const size = React.useContext(SelectSizeContext);\n const inlineStyle = useInlineStyle(css, style);\n\n return (\n <SelectPrimitive.Item\n ref={forwardedRef}\n className={cx(selectItemRecipe({ size }), className)}\n style={inlineStyle}\n {...props}\n >\n <span className={selectItemContent}>\n <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n {description != null && (\n <span className={selectItemDescriptionRecipe({ size })}>{description}</span>\n )}\n </span>\n <span className={selectItemIndicator}>\n <SelectPrimitive.ItemIndicator>\n <CheckIcon />\n </SelectPrimitive.ItemIndicator>\n </span>\n </SelectPrimitive.Item>\n );\n },\n);\n\nSelectItemVanilla.displayName = 'SelectItemVanilla';\n\nexport type SelectGroupVanillaProps = Omit<SelectPrimitive.SelectGroupProps, 'asChild'> & CSSProps;\n\nexport const SelectGroupVanilla = React.forwardRef<HTMLDivElement, SelectGroupVanillaProps>(\n ({ css, style, ...props }, forwardedRef) => (\n <SelectPrimitive.Group ref={forwardedRef} style={useInlineStyle(css, style)} {...props} />\n ),\n);\n\nSelectGroupVanilla.displayName = 'SelectGroupVanilla';\n\nexport type SelectLabelVanillaProps = Omit<SelectPrimitive.SelectLabelProps, 'asChild'> & CSSProps;\n\nexport const SelectLabelVanilla = React.forwardRef<HTMLDivElement, SelectLabelVanillaProps>(\n ({ css, className, style, ...props }, forwardedRef) => {\n const size = React.useContext(SelectSizeContext);\n\n return (\n <SelectPrimitive.Label\n ref={forwardedRef}\n className={cx(selectLabelRecipe({ size }), className)}\n style={useInlineStyle(css, style)}\n {...props}\n />\n );\n },\n);\n\nSelectLabelVanilla.displayName = 'SelectLabelVanilla';\n\nexport type SelectSeparatorVanillaProps = Omit<SelectPrimitive.SelectSeparatorProps, 'asChild'> &\n CSSProps;\n\nexport const SelectSeparatorVanilla = React.forwardRef<HTMLDivElement, SelectSeparatorVanillaProps>(\n ({ css, className, style, ...props }, forwardedRef) => (\n <SelectPrimitive.Separator\n ref={forwardedRef}\n className={cx(selectSeparator, className)}\n style={useInlineStyle(css, style)}\n {...props}\n />\n ),\n);\n\nSelectSeparatorVanilla.displayName = 'SelectSeparatorVanilla';\n"],"mappings":";;;;;;;;;;;;AA6BA,IAAM,oBAAoBA,MAAAA,QAAM,cAA0B,QAAQ;AAsBlE,IAAa,gBAAgBA,MAAAA,QAAM,YAE/B,EACE,OACA,cACA,eACA,MACA,aACA,cACA,MACA,MACA,UACA,cACA,UACA,KACA,aACA,OAAO,UACP,SACA,OACA,IACA,KACA,WACA,OACA,UACA,QACA,oBAAoB,iBACpB,gBAAgB,aAChB,GAAG,SAEL,iBACG;CACH,MAAM,aAAaA,MAAAA,QAAM,OAAuB,IAAI;CACpD,MAAM,UAAUC,qBAAAA,gBAAgB;EAC9B;EACA;EACA,SAAS,UAAU;EACnB,oBAAoB;EACpB,gBAAgB;CAClB,CAAC;CACD,MAAM,cAAcC,uBAAAA,eAAe,KAAK,KAAK;CAE7C,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,kBAAkB,UAAnB;EAA4B,OAAO;EACjC,UAAA,iBAAA,GAAA,kBAAA,KAAA,CAACC,uBAAgB,MAAjB;GACS;GACO;GACC;GACT;GACO;GACC;GACR;GACA;GACI;GACI;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uBAAgB,OAAjB;CAAuB,KAAK;CAAc,OAAOD,uBAAAA,eAAe,KAAK,KAAK;CAAG,GAAI;AAAQ,CAAA,CAE7F;AAEA,mBAAmB,cAAc;AAIjC,IAAa,qBAAqBF,MAAAA,QAAM,YACrC,EAAE,KAAK,WAAW,OAAO,GAAG,SAAS,iBAAiB;CACrD,MAAM,OAAOA,MAAAA,QAAM,WAAW,iBAAiB;CAE/C,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACG,uBAAgB,OAAjB;EACE,KAAK;EACL,WAAWC,WAAAA,GAAGe,2BAAAA,kBAAkB,EAAE,KAAK,CAAC,GAAG,SAAS;EACpD,OAAOjB,uBAAAA,eAAe,KAAK,KAAK;EAChC,GAAI;CACL,CAAA;AAEL,CACF;AAEA,mBAAmB,cAAc;AAKjC,IAAa,yBAAyBF,MAAAA,QAAM,YACzC,EAAE,KAAK,WAAW,OAAO,GAAG,SAAS,iBACpC,iBAAA,GAAA,kBAAA,IAAA,CAACG,uBAAgB,WAAjB;CACE,KAAK;CACL,WAAWC,WAAAA,GAAGgB,2BAAAA,iBAAiB,SAAS;CACxC,OAAOlB,uBAAAA,eAAe,KAAK,KAAK;CAChC,GAAI;AACL,CAAA,CAEL;AAEA,uBAAuB,cAAc"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
;/* empty css */
|
|
2
|
+
let _vanilla_extract_recipes_createRuntimeFn = require("@vanilla-extract/recipes/createRuntimeFn");
|
|
3
|
+
// components/Select/Select.vanilla.css.ts
|
|
4
|
+
var selectTriggerRecipe = (0, _vanilla_extract_recipes_createRuntimeFn.createRuntimeFn)({
|
|
5
|
+
defaultClassName: "_12b0twh0",
|
|
6
|
+
variantClassNames: {
|
|
7
|
+
size: {
|
|
8
|
+
small: "_12b0twh1",
|
|
9
|
+
medium: "_12b0twh2",
|
|
10
|
+
large: "_12b0twh3"
|
|
11
|
+
},
|
|
12
|
+
variant: { ghost: "_12b0twh4" },
|
|
13
|
+
state: { invalid: "_12b0twh5" }
|
|
14
|
+
},
|
|
15
|
+
defaultVariants: { size: "medium" },
|
|
16
|
+
compoundVariants: []
|
|
17
|
+
});
|
|
18
|
+
var selectValue = "_12b0twh6";
|
|
19
|
+
var selectIcon = "_12b0twh7";
|
|
20
|
+
var selectContent = "_12b0twh8";
|
|
21
|
+
var selectViewport = "_12b0twh9";
|
|
22
|
+
var selectScrollButton = "_12b0twha";
|
|
23
|
+
var selectItemRecipe = (0, _vanilla_extract_recipes_createRuntimeFn.createRuntimeFn)({
|
|
24
|
+
defaultClassName: "_12b0twhb",
|
|
25
|
+
variantClassNames: { size: {
|
|
26
|
+
small: "_12b0twhc",
|
|
27
|
+
medium: "_12b0twhd",
|
|
28
|
+
large: "_12b0twhe"
|
|
29
|
+
} },
|
|
30
|
+
defaultVariants: { size: "medium" },
|
|
31
|
+
compoundVariants: []
|
|
32
|
+
});
|
|
33
|
+
var selectItemContent = "_12b0twhf";
|
|
34
|
+
var selectItemDescriptionRecipe = (0, _vanilla_extract_recipes_createRuntimeFn.createRuntimeFn)({
|
|
35
|
+
defaultClassName: "_12b0twhg",
|
|
36
|
+
variantClassNames: { size: {
|
|
37
|
+
small: "_12b0twhh",
|
|
38
|
+
medium: "_12b0twhi",
|
|
39
|
+
large: "_12b0twhj"
|
|
40
|
+
} },
|
|
41
|
+
defaultVariants: { size: "medium" },
|
|
42
|
+
compoundVariants: []
|
|
43
|
+
});
|
|
44
|
+
var selectItemIndicator = "_12b0twhk";
|
|
45
|
+
var selectLabelRecipe = (0, _vanilla_extract_recipes_createRuntimeFn.createRuntimeFn)({
|
|
46
|
+
defaultClassName: "_12b0twhl",
|
|
47
|
+
variantClassNames: { size: {
|
|
48
|
+
small: "_12b0twhm",
|
|
49
|
+
medium: "_12b0twhn",
|
|
50
|
+
large: "_12b0twho"
|
|
51
|
+
} },
|
|
52
|
+
defaultVariants: { size: "medium" },
|
|
53
|
+
compoundVariants: []
|
|
54
|
+
});
|
|
55
|
+
var selectSeparator = "_12b0twhp";
|
|
56
|
+
exports.selectContent = selectContent;
|
|
57
|
+
exports.selectIcon = selectIcon;
|
|
58
|
+
exports.selectItemContent = selectItemContent;
|
|
59
|
+
exports.selectItemDescriptionRecipe = selectItemDescriptionRecipe;
|
|
60
|
+
exports.selectItemIndicator = selectItemIndicator;
|
|
61
|
+
exports.selectItemRecipe = selectItemRecipe;
|
|
62
|
+
exports.selectLabelRecipe = selectLabelRecipe;
|
|
63
|
+
exports.selectScrollButton = selectScrollButton;
|
|
64
|
+
exports.selectSeparator = selectSeparator;
|
|
65
|
+
exports.selectTriggerRecipe = selectTriggerRecipe;
|
|
66
|
+
exports.selectValue = selectValue;
|
|
67
|
+
exports.selectViewport = selectViewport;
|
|
68
|
+
|
|
69
|
+
//# sourceMappingURL=Select.vanilla.css.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Select.vanilla.css.cjs","names":[],"sources":[],"mappings":""}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/* empty css */
|
|
2
|
+
import { createRuntimeFn } from "@vanilla-extract/recipes/createRuntimeFn";
|
|
3
|
+
// components/Select/Select.vanilla.css.ts
|
|
4
|
+
var selectTriggerRecipe = createRuntimeFn({
|
|
5
|
+
defaultClassName: "_12b0twh0",
|
|
6
|
+
variantClassNames: {
|
|
7
|
+
size: {
|
|
8
|
+
small: "_12b0twh1",
|
|
9
|
+
medium: "_12b0twh2",
|
|
10
|
+
large: "_12b0twh3"
|
|
11
|
+
},
|
|
12
|
+
variant: { ghost: "_12b0twh4" },
|
|
13
|
+
state: { invalid: "_12b0twh5" }
|
|
14
|
+
},
|
|
15
|
+
defaultVariants: { size: "medium" },
|
|
16
|
+
compoundVariants: []
|
|
17
|
+
});
|
|
18
|
+
var selectValue = "_12b0twh6";
|
|
19
|
+
var selectIcon = "_12b0twh7";
|
|
20
|
+
var selectContent = "_12b0twh8";
|
|
21
|
+
var selectViewport = "_12b0twh9";
|
|
22
|
+
var selectScrollButton = "_12b0twha";
|
|
23
|
+
var selectItemRecipe = createRuntimeFn({
|
|
24
|
+
defaultClassName: "_12b0twhb",
|
|
25
|
+
variantClassNames: { size: {
|
|
26
|
+
small: "_12b0twhc",
|
|
27
|
+
medium: "_12b0twhd",
|
|
28
|
+
large: "_12b0twhe"
|
|
29
|
+
} },
|
|
30
|
+
defaultVariants: { size: "medium" },
|
|
31
|
+
compoundVariants: []
|
|
32
|
+
});
|
|
33
|
+
var selectItemContent = "_12b0twhf";
|
|
34
|
+
var selectItemDescriptionRecipe = createRuntimeFn({
|
|
35
|
+
defaultClassName: "_12b0twhg",
|
|
36
|
+
variantClassNames: { size: {
|
|
37
|
+
small: "_12b0twhh",
|
|
38
|
+
medium: "_12b0twhi",
|
|
39
|
+
large: "_12b0twhj"
|
|
40
|
+
} },
|
|
41
|
+
defaultVariants: { size: "medium" },
|
|
42
|
+
compoundVariants: []
|
|
43
|
+
});
|
|
44
|
+
var selectItemIndicator = "_12b0twhk";
|
|
45
|
+
var selectLabelRecipe = createRuntimeFn({
|
|
46
|
+
defaultClassName: "_12b0twhl",
|
|
47
|
+
variantClassNames: { size: {
|
|
48
|
+
small: "_12b0twhm",
|
|
49
|
+
medium: "_12b0twhn",
|
|
50
|
+
large: "_12b0twho"
|
|
51
|
+
} },
|
|
52
|
+
defaultVariants: { size: "medium" },
|
|
53
|
+
compoundVariants: []
|
|
54
|
+
});
|
|
55
|
+
var selectSeparator = "_12b0twhp";
|
|
56
|
+
export { selectContent, selectIcon, selectItemContent, selectItemDescriptionRecipe, selectItemIndicator, selectItemRecipe, selectLabelRecipe, selectScrollButton, selectSeparator, selectTriggerRecipe, selectValue, selectViewport };
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=Select.vanilla.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Select.vanilla.css.js","names":[],"sources":[],"mappings":""}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { cx } from "../../styles/cx.js";
|
|
2
|
+
import { useInlineStyle } from "../../styles/useInlineStyle.js";
|
|
3
|
+
import { useFieldControl } from "../Field/FieldContext.js";
|
|
4
|
+
import { selectContent, selectIcon, selectItemContent, selectItemDescriptionRecipe, selectItemIndicator, selectItemRecipe, selectLabelRecipe, selectScrollButton, selectSeparator, selectTriggerRecipe, selectValue, selectViewport } from "./Select.vanilla.css.js";
|
|
5
|
+
import { CaretSortIcon, CheckIcon, ChevronDownIcon, ChevronUpIcon } from "@radix-ui/react-icons";
|
|
6
|
+
import React from "react";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import * as SelectPrimitive from "@radix-ui/react-select";
|
|
9
|
+
// components/Select/Select.vanilla.tsx
|
|
10
|
+
var SelectSizeContext = React.createContext("medium");
|
|
11
|
+
var SelectVanilla = React.forwardRef(({ value, defaultValue, onValueChange, open, defaultOpen, onOpenChange, name, form, required, autoComplete, disabled, dir, placeholder, size = "medium", variant, state, id, css, className, style, children, onBlur, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, ...props }, forwardedRef) => {
|
|
12
|
+
const contentRef = React.useRef(null);
|
|
13
|
+
const control = useFieldControl({
|
|
14
|
+
id,
|
|
15
|
+
disabled,
|
|
16
|
+
invalid: state === "invalid",
|
|
17
|
+
"aria-describedby": ariaDescribedBy,
|
|
18
|
+
"aria-invalid": ariaInvalid
|
|
19
|
+
});
|
|
20
|
+
const inlineStyle = useInlineStyle(css, style);
|
|
21
|
+
return /* @__PURE__ */ jsx(SelectSizeContext.Provider, {
|
|
22
|
+
value: size,
|
|
23
|
+
children: /* @__PURE__ */ jsxs(SelectPrimitive.Root, {
|
|
24
|
+
value,
|
|
25
|
+
defaultValue,
|
|
26
|
+
onValueChange,
|
|
27
|
+
open,
|
|
28
|
+
defaultOpen,
|
|
29
|
+
onOpenChange,
|
|
30
|
+
name,
|
|
31
|
+
form,
|
|
32
|
+
required,
|
|
33
|
+
autoComplete,
|
|
34
|
+
disabled: control.disabled,
|
|
35
|
+
dir,
|
|
36
|
+
children: [/* @__PURE__ */ jsxs(SelectPrimitive.Trigger, {
|
|
37
|
+
ref: forwardedRef,
|
|
38
|
+
id: control.id,
|
|
39
|
+
"aria-describedby": control["aria-describedby"],
|
|
40
|
+
"aria-invalid": control["aria-invalid"],
|
|
41
|
+
className: cx(selectTriggerRecipe({
|
|
42
|
+
size,
|
|
43
|
+
variant,
|
|
44
|
+
state: control.invalid ? "invalid" : state
|
|
45
|
+
}), className),
|
|
46
|
+
style: inlineStyle,
|
|
47
|
+
onBlur: (event) => {
|
|
48
|
+
if (!contentRef.current?.contains(event.relatedTarget)) onBlur?.(event);
|
|
49
|
+
},
|
|
50
|
+
...props,
|
|
51
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
52
|
+
className: selectValue,
|
|
53
|
+
children: /* @__PURE__ */ jsx(SelectPrimitive.Value, { placeholder })
|
|
54
|
+
}), /* @__PURE__ */ jsx(SelectPrimitive.Icon, {
|
|
55
|
+
className: selectIcon,
|
|
56
|
+
children: /* @__PURE__ */ jsx(CaretSortIcon, {})
|
|
57
|
+
})]
|
|
58
|
+
}), /* @__PURE__ */ jsx(SelectPrimitive.Portal, { children: /* @__PURE__ */ jsxs(SelectPrimitive.Content, {
|
|
59
|
+
ref: contentRef,
|
|
60
|
+
className: selectContent,
|
|
61
|
+
position: "popper",
|
|
62
|
+
sideOffset: 4,
|
|
63
|
+
collisionPadding: 8,
|
|
64
|
+
children: [
|
|
65
|
+
/* @__PURE__ */ jsx(SelectPrimitive.ScrollUpButton, {
|
|
66
|
+
className: selectScrollButton,
|
|
67
|
+
children: /* @__PURE__ */ jsx(ChevronUpIcon, {})
|
|
68
|
+
}),
|
|
69
|
+
/* @__PURE__ */ jsx(SelectPrimitive.Viewport, {
|
|
70
|
+
className: selectViewport,
|
|
71
|
+
children
|
|
72
|
+
}),
|
|
73
|
+
/* @__PURE__ */ jsx(SelectPrimitive.ScrollDownButton, {
|
|
74
|
+
className: selectScrollButton,
|
|
75
|
+
children: /* @__PURE__ */ jsx(ChevronDownIcon, {})
|
|
76
|
+
})
|
|
77
|
+
]
|
|
78
|
+
}) })]
|
|
79
|
+
})
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
SelectVanilla.displayName = "SelectVanilla";
|
|
83
|
+
var SelectItemVanilla = React.forwardRef(({ description, children, css, className, style, ...props }, forwardedRef) => {
|
|
84
|
+
const size = React.useContext(SelectSizeContext);
|
|
85
|
+
const inlineStyle = useInlineStyle(css, style);
|
|
86
|
+
return /* @__PURE__ */ jsxs(SelectPrimitive.Item, {
|
|
87
|
+
ref: forwardedRef,
|
|
88
|
+
className: cx(selectItemRecipe({ size }), className),
|
|
89
|
+
style: inlineStyle,
|
|
90
|
+
...props,
|
|
91
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
92
|
+
className: selectItemContent,
|
|
93
|
+
children: [/* @__PURE__ */ jsx(SelectPrimitive.ItemText, { children }), description != null && /* @__PURE__ */ jsx("span", {
|
|
94
|
+
className: selectItemDescriptionRecipe({ size }),
|
|
95
|
+
children: description
|
|
96
|
+
})]
|
|
97
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
98
|
+
className: selectItemIndicator,
|
|
99
|
+
children: /* @__PURE__ */ jsx(SelectPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx(CheckIcon, {}) })
|
|
100
|
+
})]
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
SelectItemVanilla.displayName = "SelectItemVanilla";
|
|
104
|
+
var SelectGroupVanilla = React.forwardRef(({ css, style, ...props }, forwardedRef) => /* @__PURE__ */ jsx(SelectPrimitive.Group, {
|
|
105
|
+
ref: forwardedRef,
|
|
106
|
+
style: useInlineStyle(css, style),
|
|
107
|
+
...props
|
|
108
|
+
}));
|
|
109
|
+
SelectGroupVanilla.displayName = "SelectGroupVanilla";
|
|
110
|
+
var SelectLabelVanilla = React.forwardRef(({ css, className, style, ...props }, forwardedRef) => {
|
|
111
|
+
const size = React.useContext(SelectSizeContext);
|
|
112
|
+
return /* @__PURE__ */ jsx(SelectPrimitive.Label, {
|
|
113
|
+
ref: forwardedRef,
|
|
114
|
+
className: cx(selectLabelRecipe({ size }), className),
|
|
115
|
+
style: useInlineStyle(css, style),
|
|
116
|
+
...props
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
SelectLabelVanilla.displayName = "SelectLabelVanilla";
|
|
120
|
+
var SelectSeparatorVanilla = React.forwardRef(({ css, className, style, ...props }, forwardedRef) => /* @__PURE__ */ jsx(SelectPrimitive.Separator, {
|
|
121
|
+
ref: forwardedRef,
|
|
122
|
+
className: cx(selectSeparator, className),
|
|
123
|
+
style: useInlineStyle(css, style),
|
|
124
|
+
...props
|
|
125
|
+
}));
|
|
126
|
+
SelectSeparatorVanilla.displayName = "SelectSeparatorVanilla";
|
|
127
|
+
export { SelectGroupVanilla, SelectItemVanilla, SelectLabelVanilla, SelectSeparatorVanilla, SelectVanilla };
|
|
128
|
+
|
|
129
|
+
//# sourceMappingURL=Select.vanilla.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Select.vanilla.js","names":[],"sources":["../../../components/Select/Select.vanilla.tsx"],"sourcesContent":["import { CaretSortIcon, CheckIcon, ChevronDownIcon, ChevronUpIcon } from '@radix-ui/react-icons';\nimport * as SelectPrimitive from '@radix-ui/react-select';\nimport React from 'react';\n\nimport { CSSProps } from '@/styles/cssProps';\nimport { cx } from '@/styles/cx';\nimport type { RecipeVariantProps } from '@/styles/recipeVariants';\nimport { useInlineStyle } from '@/styles/useInlineStyle';\n\nimport { useFieldControl } from '@/components/Field/FieldContext';\n\nimport {\n selectContent,\n selectIcon,\n selectItemContent,\n selectItemDescriptionRecipe,\n selectItemIndicator,\n selectItemRecipe,\n selectLabelRecipe,\n selectScrollButton,\n selectSeparator,\n selectTriggerRecipe,\n selectValue,\n selectViewport,\n} from './Select.vanilla.css';\n\ntype SelectTriggerVariants = RecipeVariantProps<typeof selectTriggerRecipe>;\ntype SelectSize = NonNullable<SelectTriggerVariants['size']>;\n\nconst SelectSizeContext = React.createContext<SelectSize>('medium');\n\ntype SelectRootProps = Omit<\n SelectPrimitive.SelectProps,\n 'children' | 'autoComplete' | 'onValueChange'\n>;\n\nexport type SelectVanillaProps = Omit<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n keyof SelectRootProps | 'children' | 'type' | 'onChange'\n> &\n SelectRootProps &\n CSSProps & {\n onValueChange?: (value: string) => void;\n placeholder?: React.ReactNode;\n autoComplete?: string;\n size?: SelectTriggerVariants['size'];\n variant?: SelectTriggerVariants['variant'];\n state?: SelectTriggerVariants['state'];\n children?: React.ReactNode;\n };\n\nexport const SelectVanilla = React.forwardRef<HTMLButtonElement, SelectVanillaProps>(\n (\n {\n value,\n defaultValue,\n onValueChange,\n open,\n defaultOpen,\n onOpenChange,\n name,\n form,\n required,\n autoComplete,\n disabled,\n dir,\n placeholder,\n size = 'medium',\n variant,\n state,\n id,\n css,\n className,\n style,\n children,\n onBlur,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n ...props\n },\n forwardedRef,\n ) => {\n const contentRef = React.useRef<HTMLDivElement>(null);\n const control = useFieldControl({\n id,\n disabled,\n invalid: state === 'invalid',\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n });\n const inlineStyle = useInlineStyle(css, style);\n\n return (\n <SelectSizeContext.Provider value={size}>\n <SelectPrimitive.Root\n value={value}\n defaultValue={defaultValue}\n onValueChange={onValueChange}\n open={open}\n defaultOpen={defaultOpen}\n onOpenChange={onOpenChange}\n name={name}\n form={form}\n required={required}\n autoComplete={autoComplete}\n disabled={control.disabled}\n dir={dir}\n >\n <SelectPrimitive.Trigger\n ref={forwardedRef}\n id={control.id}\n aria-describedby={control['aria-describedby']}\n aria-invalid={control['aria-invalid']}\n className={cx(\n selectTriggerRecipe({\n size,\n variant,\n state: control.invalid ? 'invalid' : state,\n }),\n className,\n )}\n style={inlineStyle}\n onBlur={(event) => {\n // Focus moving into the open list is not leaving the field.\n if (!contentRef.current?.contains(event.relatedTarget)) onBlur?.(event);\n }}\n {...props}\n >\n {/* Radix drops the className of Value. */}\n <span className={selectValue}>\n <SelectPrimitive.Value placeholder={placeholder} />\n </span>\n <SelectPrimitive.Icon className={selectIcon}>\n <CaretSortIcon />\n </SelectPrimitive.Icon>\n </SelectPrimitive.Trigger>\n <SelectPrimitive.Portal>\n <SelectPrimitive.Content\n ref={contentRef}\n className={selectContent}\n position=\"popper\"\n sideOffset={4}\n collisionPadding={8}\n >\n <SelectPrimitive.ScrollUpButton className={selectScrollButton}>\n <ChevronUpIcon />\n </SelectPrimitive.ScrollUpButton>\n <SelectPrimitive.Viewport className={selectViewport}>\n {children}\n </SelectPrimitive.Viewport>\n <SelectPrimitive.ScrollDownButton className={selectScrollButton}>\n <ChevronDownIcon />\n </SelectPrimitive.ScrollDownButton>\n </SelectPrimitive.Content>\n </SelectPrimitive.Portal>\n </SelectPrimitive.Root>\n </SelectSizeContext.Provider>\n );\n },\n);\n\nSelectVanilla.displayName = 'SelectVanilla';\n\nexport type SelectItemVanillaProps = Omit<SelectPrimitive.SelectItemProps, 'asChild'> &\n CSSProps & {\n /** A second line under the item, shown in the list only. */\n description?: React.ReactNode;\n };\n\nexport const SelectItemVanilla = React.forwardRef<HTMLDivElement, SelectItemVanillaProps>(\n ({ description, children, css, className, style, ...props }, forwardedRef) => {\n const size = React.useContext(SelectSizeContext);\n const inlineStyle = useInlineStyle(css, style);\n\n return (\n <SelectPrimitive.Item\n ref={forwardedRef}\n className={cx(selectItemRecipe({ size }), className)}\n style={inlineStyle}\n {...props}\n >\n <span className={selectItemContent}>\n <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n {description != null && (\n <span className={selectItemDescriptionRecipe({ size })}>{description}</span>\n )}\n </span>\n <span className={selectItemIndicator}>\n <SelectPrimitive.ItemIndicator>\n <CheckIcon />\n </SelectPrimitive.ItemIndicator>\n </span>\n </SelectPrimitive.Item>\n );\n },\n);\n\nSelectItemVanilla.displayName = 'SelectItemVanilla';\n\nexport type SelectGroupVanillaProps = Omit<SelectPrimitive.SelectGroupProps, 'asChild'> & CSSProps;\n\nexport const SelectGroupVanilla = React.forwardRef<HTMLDivElement, SelectGroupVanillaProps>(\n ({ css, style, ...props }, forwardedRef) => (\n <SelectPrimitive.Group ref={forwardedRef} style={useInlineStyle(css, style)} {...props} />\n ),\n);\n\nSelectGroupVanilla.displayName = 'SelectGroupVanilla';\n\nexport type SelectLabelVanillaProps = Omit<SelectPrimitive.SelectLabelProps, 'asChild'> & CSSProps;\n\nexport const SelectLabelVanilla = React.forwardRef<HTMLDivElement, SelectLabelVanillaProps>(\n ({ css, className, style, ...props }, forwardedRef) => {\n const size = React.useContext(SelectSizeContext);\n\n return (\n <SelectPrimitive.Label\n ref={forwardedRef}\n className={cx(selectLabelRecipe({ size }), className)}\n style={useInlineStyle(css, style)}\n {...props}\n />\n );\n },\n);\n\nSelectLabelVanilla.displayName = 'SelectLabelVanilla';\n\nexport type SelectSeparatorVanillaProps = Omit<SelectPrimitive.SelectSeparatorProps, 'asChild'> &\n CSSProps;\n\nexport const SelectSeparatorVanilla = React.forwardRef<HTMLDivElement, SelectSeparatorVanillaProps>(\n ({ css, className, style, ...props }, forwardedRef) => (\n <SelectPrimitive.Separator\n ref={forwardedRef}\n className={cx(selectSeparator, className)}\n style={useInlineStyle(css, style)}\n {...props}\n />\n ),\n);\n\nSelectSeparatorVanilla.displayName = 'SelectSeparatorVanilla';\n"],"mappings":";;;;;;;;;AA6BA,IAAM,oBAAoB,MAAM,cAA0B,QAAQ;AAsBlE,IAAa,gBAAgB,MAAM,YAE/B,EACE,OACA,cACA,eACA,MACA,aACA,cACA,MACA,MACA,UACA,cACA,UACA,KACA,aACA,OAAO,UACP,SACA,OACA,IACA,KACA,WACA,OACA,UACA,QACA,oBAAoB,iBACpB,gBAAgB,aAChB,GAAG,SAEL,iBACG;CACH,MAAM,aAAa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KjC,IAAa,yBAAyB,MAAM,YACzC,EAAE,KAAK,WAAW,OAAO,GAAG,SAAS,iBACpC,oBAAC,gBAAgB,WAAjB;CACE,KAAK;CACL,WAAW,GAAG,iBAAiB,SAAS;CACxC,OAAO,eAAe,KAAK,KAAK;CAChC,GAAI;AACL,CAAA,CAEL;AAEA,uBAAuB,cAAc"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_cx = require("../../styles/cx.cjs");
|
|
3
|
+
const require_recipeVariants = require("../../styles/recipeVariants.cjs");
|
|
4
|
+
const require_useInlineStyle = require("../../styles/useInlineStyle.cjs");
|
|
5
|
+
const require_FieldContext = require("../Field/FieldContext.cjs");
|
|
6
|
+
const require_Switch_vanilla_css = require("./Switch.vanilla.css.cjs");
|
|
7
|
+
let react = require("react");
|
|
8
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
|
+
let _radix_ui_react_switch = require("@radix-ui/react-switch");
|
|
10
|
+
_radix_ui_react_switch = require_runtime.__toESM(_radix_ui_react_switch, 1);
|
|
11
|
+
// components/Switch/Switch.vanilla.tsx
|
|
12
|
+
var switchClass = require_recipeVariants.withVariantKeys(require_Switch_vanilla_css.switchRecipe);
|
|
13
|
+
var SwitchVanillaComponentImpl = (0, react.forwardRef)(({ as, className, css, style, size, id, checked, defaultChecked, onCheckedChange, disabled, required, name, value, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, "aria-labelledby": ariaLabelledBy, ...props }, ref) => {
|
|
14
|
+
const mergedStyles = require_useInlineStyle.useInlineStyle(css, style);
|
|
15
|
+
const recipeClass = switchClass({ size });
|
|
16
|
+
const control = require_FieldContext.useFieldControl({
|
|
17
|
+
id,
|
|
18
|
+
disabled,
|
|
19
|
+
"aria-describedby": ariaDescribedBy,
|
|
20
|
+
"aria-invalid": ariaInvalid,
|
|
21
|
+
labelable: !as
|
|
22
|
+
});
|
|
23
|
+
if (as) {
|
|
24
|
+
const Component = as;
|
|
25
|
+
const state = checked ?? defaultChecked ? "checked" : "unchecked";
|
|
26
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Component, {
|
|
27
|
+
...props,
|
|
28
|
+
ref,
|
|
29
|
+
id: control.id,
|
|
30
|
+
role: "switch",
|
|
31
|
+
"aria-checked": state === "checked",
|
|
32
|
+
"aria-readonly": true,
|
|
33
|
+
"aria-disabled": control.disabled,
|
|
34
|
+
"aria-labelledby": ariaLabelledBy ?? control.labelId,
|
|
35
|
+
"aria-describedby": control["aria-describedby"],
|
|
36
|
+
"aria-invalid": control["aria-invalid"],
|
|
37
|
+
"data-state": state,
|
|
38
|
+
"data-disabled": control.disabled ? "" : void 0,
|
|
39
|
+
className: require_cx.cx(recipeClass, className),
|
|
40
|
+
style: mergedStyles,
|
|
41
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
42
|
+
"data-state": state,
|
|
43
|
+
className: require_Switch_vanilla_css.switchThumb
|
|
44
|
+
})
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_switch.Root, {
|
|
48
|
+
...props,
|
|
49
|
+
ref,
|
|
50
|
+
id: control.id,
|
|
51
|
+
checked,
|
|
52
|
+
defaultChecked,
|
|
53
|
+
onCheckedChange,
|
|
54
|
+
disabled: control.disabled,
|
|
55
|
+
required,
|
|
56
|
+
name,
|
|
57
|
+
value,
|
|
58
|
+
"aria-labelledby": ariaLabelledBy,
|
|
59
|
+
"aria-describedby": control["aria-describedby"],
|
|
60
|
+
"aria-invalid": control["aria-invalid"],
|
|
61
|
+
className: require_cx.cx(recipeClass, className),
|
|
62
|
+
style: mergedStyles,
|
|
63
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_switch.Thumb, { className: require_Switch_vanilla_css.switchThumb })
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
SwitchVanillaComponentImpl.displayName = "SwitchVanilla";
|
|
67
|
+
var SwitchVanilla = SwitchVanillaComponentImpl;
|
|
68
|
+
exports.SwitchVanilla = SwitchVanilla;
|
|
69
|
+
|
|
70
|
+
//# sourceMappingURL=Switch.vanilla.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Switch.vanilla.cjs","names":["withVariantKeys","switchRecipe","forwardRef","useInlineStyle","useFieldControl","cx","switchThumb","SwitchPrimitive"],"sources":["../../../components/Switch/Switch.vanilla.tsx"],"sourcesContent":["import * as SwitchPrimitive from '@radix-ui/react-switch';\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 { RecipeVariantProps, withVariantKeys } from '@/styles/recipeVariants';\nimport { useInlineStyle } from '@/styles/useInlineStyle';\n\nimport { useFieldControl } from '@/components/Field/FieldContext';\n\nimport { switchRecipe, switchThumb } from './Switch.vanilla.css';\n\nconst switchClass = withVariantKeys(switchRecipe);\n\ntype SwitchRecipeVariants = RecipeVariantProps<typeof switchRecipe>;\n\ninterface SwitchVanillaOwnProps extends SwitchRecipeVariants, CSSProps {\n checked?: boolean;\n defaultChecked?: boolean;\n onCheckedChange?: (checked: boolean) => void;\n disabled?: boolean;\n required?: boolean;\n name?: string;\n value?: string;\n}\n\nexport type SwitchVanillaProps<C extends ElementType = 'button'> = PolymorphicComponentProps<\n C,\n SwitchVanillaOwnProps\n>;\n\ntype SwitchVanillaComponent = PolymorphicComponent<'button', SwitchVanillaProps<ElementType>>;\n\nconst SwitchVanillaComponentImpl = forwardRef(\n <C extends ElementType = 'button'>(\n {\n as,\n className,\n css,\n style,\n size,\n id,\n checked,\n defaultChecked,\n onCheckedChange,\n disabled,\n required,\n name,\n value,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-labelledby': ariaLabelledBy,\n ...props\n }: SwitchVanillaProps<C>,\n ref?: PolymorphicRef<C>,\n ) => {\n const mergedStyles = useInlineStyle(css, style);\n const recipeClass = switchClass({ size });\n\n const control = useFieldControl({\n id,\n disabled,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n labelable: !as,\n });\n\n // With `as`, the switch is a read-only indicator of `checked`, not a control.\n if (as) {\n const Component = as as ElementType;\n const state = (checked ?? defaultChecked) ? 'checked' : 'unchecked';\n\n return (\n <Component\n {...props}\n ref={ref}\n id={control.id}\n role=\"switch\"\n aria-checked={state === 'checked'}\n aria-readonly\n aria-disabled={control.disabled}\n aria-labelledby={ariaLabelledBy ?? control.labelId}\n aria-describedby={control['aria-describedby']}\n aria-invalid={control['aria-invalid']}\n data-state={state}\n data-disabled={control.disabled ? '' : undefined}\n className={cx(recipeClass, className)}\n style={mergedStyles}\n >\n <span data-state={state} className={switchThumb} />\n </Component>\n );\n }\n\n return (\n <SwitchPrimitive.Root\n {...props}\n ref={ref}\n id={control.id}\n checked={checked}\n defaultChecked={defaultChecked}\n onCheckedChange={onCheckedChange}\n disabled={control.disabled}\n required={required}\n name={name}\n value={value}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={control['aria-describedby']}\n aria-invalid={control['aria-invalid']}\n className={cx(recipeClass, className)}\n style={mergedStyles}\n >\n <SwitchPrimitive.Thumb className={switchThumb} />\n </SwitchPrimitive.Root>\n );\n },\n);\n\nSwitchVanillaComponentImpl.displayName = 'SwitchVanilla';\n\nexport const SwitchVanilla = SwitchVanillaComponentImpl as SwitchVanillaComponent;\n"],"mappings":";;;;;;;;;;;AAiBA,IAAM,cAAcA,uBAAAA,gBAAgBC,2BAAAA,YAAY;AAqBhD,IAAM,8BAAA,GAA6BC,MAAAA,WAAAA,EAE/B,EACE,IACA,WACA,KACA,OACA,MACA,IACA,SACA,gBACA,iBACA,UACA,UACA,MACA,OACA,oBAAoB,iBACpB,gBAA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3
|
+
// components/Switch/Switch.vanilla.css.ts
|
|
4
|
+
var switchRecipe = (0, require("@vanilla-extract/recipes/createRuntimeFn").createRuntimeFn)({
|
|
5
|
+
defaultClassName: "_43j34p3",
|
|
6
|
+
variantClassNames: { size: {
|
|
7
|
+
"1": "_43j34p4",
|
|
8
|
+
"2": "_43j34p5"
|
|
9
|
+
} },
|
|
10
|
+
defaultVariants: { size: "1" },
|
|
11
|
+
compoundVariants: []
|
|
12
|
+
});
|
|
13
|
+
var switchThumb = "_43j34p6";
|
|
14
|
+
exports.switchRecipe = switchRecipe;
|
|
15
|
+
exports.switchThumb = switchThumb;
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=Switch.vanilla.css.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Switch.vanilla.css.cjs","names":[],"sources":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/* empty css */
|
|
2
|
+
/* empty css */
|
|
3
|
+
import { createRuntimeFn } from "@vanilla-extract/recipes/createRuntimeFn";
|
|
4
|
+
// components/Switch/Switch.vanilla.css.ts
|
|
5
|
+
var switchRecipe = createRuntimeFn({
|
|
6
|
+
defaultClassName: "_43j34p3",
|
|
7
|
+
variantClassNames: { size: {
|
|
8
|
+
"1": "_43j34p4",
|
|
9
|
+
"2": "_43j34p5"
|
|
10
|
+
} },
|
|
11
|
+
defaultVariants: { size: "1" },
|
|
12
|
+
compoundVariants: []
|
|
13
|
+
});
|
|
14
|
+
var switchThumb = "_43j34p6";
|
|
15
|
+
export { switchRecipe, switchThumb };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=Switch.vanilla.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Switch.vanilla.css.js","names":[],"sources":[],"mappings":""}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { cx } from "../../styles/cx.js";
|
|
2
|
+
import { withVariantKeys } from "../../styles/recipeVariants.js";
|
|
3
|
+
import { useInlineStyle } from "../../styles/useInlineStyle.js";
|
|
4
|
+
import { useFieldControl } from "../Field/FieldContext.js";
|
|
5
|
+
import { switchRecipe, switchThumb } from "./Switch.vanilla.css.js";
|
|
6
|
+
import { forwardRef } from "react";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
import * as SwitchPrimitive from "@radix-ui/react-switch";
|
|
9
|
+
// components/Switch/Switch.vanilla.tsx
|
|
10
|
+
var switchClass = withVariantKeys(switchRecipe);
|
|
11
|
+
var SwitchVanillaComponentImpl = forwardRef(({ as, className, css, style, size, id, checked, defaultChecked, onCheckedChange, disabled, required, name, value, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, "aria-labelledby": ariaLabelledBy, ...props }, ref) => {
|
|
12
|
+
const mergedStyles = useInlineStyle(css, style);
|
|
13
|
+
const recipeClass = switchClass({ size });
|
|
14
|
+
const control = useFieldControl({
|
|
15
|
+
id,
|
|
16
|
+
disabled,
|
|
17
|
+
"aria-describedby": ariaDescribedBy,
|
|
18
|
+
"aria-invalid": ariaInvalid,
|
|
19
|
+
labelable: !as
|
|
20
|
+
});
|
|
21
|
+
if (as) {
|
|
22
|
+
const Component = as;
|
|
23
|
+
const state = checked ?? defaultChecked ? "checked" : "unchecked";
|
|
24
|
+
return /* @__PURE__ */ jsx(Component, {
|
|
25
|
+
...props,
|
|
26
|
+
ref,
|
|
27
|
+
id: control.id,
|
|
28
|
+
role: "switch",
|
|
29
|
+
"aria-checked": state === "checked",
|
|
30
|
+
"aria-readonly": true,
|
|
31
|
+
"aria-disabled": control.disabled,
|
|
32
|
+
"aria-labelledby": ariaLabelledBy ?? control.labelId,
|
|
33
|
+
"aria-describedby": control["aria-describedby"],
|
|
34
|
+
"aria-invalid": control["aria-invalid"],
|
|
35
|
+
"data-state": state,
|
|
36
|
+
"data-disabled": control.disabled ? "" : void 0,
|
|
37
|
+
className: cx(recipeClass, className),
|
|
38
|
+
style: mergedStyles,
|
|
39
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
40
|
+
"data-state": state,
|
|
41
|
+
className: switchThumb
|
|
42
|
+
})
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return /* @__PURE__ */ jsx(SwitchPrimitive.Root, {
|
|
46
|
+
...props,
|
|
47
|
+
ref,
|
|
48
|
+
id: control.id,
|
|
49
|
+
checked,
|
|
50
|
+
defaultChecked,
|
|
51
|
+
onCheckedChange,
|
|
52
|
+
disabled: control.disabled,
|
|
53
|
+
required,
|
|
54
|
+
name,
|
|
55
|
+
value,
|
|
56
|
+
"aria-labelledby": ariaLabelledBy,
|
|
57
|
+
"aria-describedby": control["aria-describedby"],
|
|
58
|
+
"aria-invalid": control["aria-invalid"],
|
|
59
|
+
className: cx(recipeClass, className),
|
|
60
|
+
style: mergedStyles,
|
|
61
|
+
children: /* @__PURE__ */ jsx(SwitchPrimitive.Thumb, { className: switchThumb })
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
SwitchVanillaComponentImpl.displayName = "SwitchVanilla";
|
|
65
|
+
var SwitchVanilla = SwitchVanillaComponentImpl;
|
|
66
|
+
export { SwitchVanilla };
|
|
67
|
+
|
|
68
|
+
//# sourceMappingURL=Switch.vanilla.js.map
|