@traefik-labs/faency 13.1.1 → 13.2.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.
Files changed (99) hide show
  1. package/dist/components/Checkbox/Checkbox.cjs +15 -2
  2. package/dist/components/Checkbox/Checkbox.cjs.map +1 -1
  3. package/dist/components/Checkbox/Checkbox.js +15 -2
  4. package/dist/components/Checkbox/Checkbox.js.map +1 -1
  5. package/dist/components/Checkbox/Checkbox.themes.cjs +4 -2
  6. package/dist/components/Checkbox/Checkbox.themes.cjs.map +1 -1
  7. package/dist/components/Checkbox/Checkbox.themes.js +4 -2
  8. package/dist/components/Checkbox/Checkbox.themes.js.map +1 -1
  9. package/dist/components/DateTimePickerInput/DateTimePickerInput.cjs +1 -1
  10. package/dist/components/DateTimePickerInput/DateTimePickerInput.cjs.map +1 -1
  11. package/dist/components/DateTimePickerInput/DateTimePickerInput.js +1 -1
  12. package/dist/components/DateTimePickerInput/DateTimePickerInput.js.map +1 -1
  13. package/dist/components/Field/Field.cjs +91 -0
  14. package/dist/components/Field/Field.cjs.map +1 -0
  15. package/dist/components/Field/Field.js +89 -0
  16. package/dist/components/Field/Field.js.map +1 -0
  17. package/dist/components/Field/Field.vanilla.cjs +95 -0
  18. package/dist/components/Field/Field.vanilla.cjs.map +1 -0
  19. package/dist/components/Field/Field.vanilla.css.cjs +6 -0
  20. package/dist/components/Field/Field.vanilla.css.cjs.map +1 -0
  21. package/dist/components/Field/Field.vanilla.css.js +6 -0
  22. package/dist/components/Field/Field.vanilla.css.js.map +1 -0
  23. package/dist/components/Field/Field.vanilla.js +93 -0
  24. package/dist/components/Field/Field.vanilla.js.map +1 -0
  25. package/dist/components/Field/FieldContext.cjs +136 -0
  26. package/dist/components/Field/FieldContext.cjs.map +1 -0
  27. package/dist/components/Field/FieldContext.js +130 -0
  28. package/dist/components/Field/FieldContext.js.map +1 -0
  29. package/dist/components/Input/Input.cjs +31 -6
  30. package/dist/components/Input/Input.cjs.map +1 -1
  31. package/dist/components/Input/Input.js +31 -6
  32. package/dist/components/Input/Input.js.map +1 -1
  33. package/dist/components/Input/Input.vanilla.cjs +17 -4
  34. package/dist/components/Input/Input.vanilla.cjs.map +1 -1
  35. package/dist/components/Input/Input.vanilla.css.cjs.map +1 -1
  36. package/dist/components/Input/Input.vanilla.css.js.map +1 -1
  37. package/dist/components/Input/Input.vanilla.js +17 -4
  38. package/dist/components/Input/Input.vanilla.js.map +1 -1
  39. package/dist/components/Radio/Radio.cjs +21 -1
  40. package/dist/components/Radio/Radio.cjs.map +1 -1
  41. package/dist/components/Radio/Radio.js +21 -1
  42. package/dist/components/Radio/Radio.js.map +1 -1
  43. package/dist/components/Radio/Radio.themes.cjs +4 -2
  44. package/dist/components/Radio/Radio.themes.cjs.map +1 -1
  45. package/dist/components/Radio/Radio.themes.js +4 -2
  46. package/dist/components/Radio/Radio.themes.js.map +1 -1
  47. package/dist/components/Select/Select.cjs +33 -4
  48. package/dist/components/Select/Select.cjs.map +1 -1
  49. package/dist/components/Select/Select.js +33 -4
  50. package/dist/components/Select/Select.js.map +1 -1
  51. package/dist/components/Switch/Switch.cjs +19 -5
  52. package/dist/components/Switch/Switch.cjs.map +1 -1
  53. package/dist/components/Switch/Switch.js +19 -5
  54. package/dist/components/Switch/Switch.js.map +1 -1
  55. package/dist/components/Switch/Switch.themes.cjs +4 -2
  56. package/dist/components/Switch/Switch.themes.cjs.map +1 -1
  57. package/dist/components/Switch/Switch.themes.js +4 -2
  58. package/dist/components/Switch/Switch.themes.js.map +1 -1
  59. package/dist/components/Text/Text.themes.cjs +2 -2
  60. package/dist/components/Text/Text.themes.cjs.map +1 -1
  61. package/dist/components/Text/Text.themes.js +2 -2
  62. package/dist/components/Text/Text.themes.js.map +1 -1
  63. package/dist/components/Text/Text.vanilla.cjs +36 -0
  64. package/dist/components/Text/Text.vanilla.cjs.map +1 -0
  65. package/dist/components/Text/Text.vanilla.css.cjs +55 -0
  66. package/dist/components/Text/Text.vanilla.css.cjs.map +1 -0
  67. package/dist/components/Text/Text.vanilla.css.js +56 -0
  68. package/dist/components/Text/Text.vanilla.css.js.map +1 -0
  69. package/dist/components/Text/Text.vanilla.js +36 -0
  70. package/dist/components/Text/Text.vanilla.js.map +1 -0
  71. package/dist/components/TextField/TextField.cjs +73 -77
  72. package/dist/components/TextField/TextField.cjs.map +1 -1
  73. package/dist/components/TextField/TextField.js +73 -77
  74. package/dist/components/TextField/TextField.js.map +1 -1
  75. package/dist/components/TextField/TextField.vanilla.cjs +70 -86
  76. package/dist/components/TextField/TextField.vanilla.cjs.map +1 -1
  77. package/dist/components/TextField/TextField.vanilla.css.cjs +10 -0
  78. package/dist/components/TextField/TextField.vanilla.css.cjs.map +1 -0
  79. package/dist/components/TextField/TextField.vanilla.css.js +8 -0
  80. package/dist/components/TextField/TextField.vanilla.css.js.map +1 -0
  81. package/dist/components/TextField/TextField.vanilla.js +71 -87
  82. package/dist/components/TextField/TextField.vanilla.js.map +1 -1
  83. package/dist/components/Textarea/Textarea.cjs +51 -41
  84. package/dist/components/Textarea/Textarea.cjs.map +1 -1
  85. package/dist/components/Textarea/Textarea.js +51 -41
  86. package/dist/components/Textarea/Textarea.js.map +1 -1
  87. package/dist/components/Textarea/Textarea.vanilla.cjs +49 -49
  88. package/dist/components/Textarea/Textarea.vanilla.cjs.map +1 -1
  89. package/dist/components/Textarea/Textarea.vanilla.css.cjs.map +1 -1
  90. package/dist/components/Textarea/Textarea.vanilla.css.js.map +1 -1
  91. package/dist/components/Textarea/Textarea.vanilla.js +49 -49
  92. package/dist/components/Textarea/Textarea.vanilla.js.map +1 -1
  93. package/dist/faency.css +170 -14
  94. package/dist/index.cjs +7 -1
  95. package/dist/index.d.ts +375 -0
  96. package/dist/index.js +5 -2
  97. package/dist/styles/themes.css.cjs.map +1 -1
  98. package/dist/styles/themes.css.js.map +1 -1
  99. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Radio.themes.cjs","names":["tinycolor"],"sources":["../../../components/Radio/Radio.themes.ts"],"sourcesContent":["import { Property } from '@stitches/react/types/css';\nimport tinycolor from 'tinycolor2';\n\nimport { ColorInfo } from '../../utils/getPrimaryColorInfo';\nexport namespace Theme {\n type Colors = {\n radioBorder: Property.Color;\n radioHoverBg: Property.Color;\n radioHoverBorder: Property.Color;\n radioFocusBorder: Property.Color;\n radioDisabledBg: Property.Color;\n radioDisabledBorder: Property.Color;\n radioIndicatorDisabledBg: Property.Color;\n };\n\n type Factory = (primaryColor: ColorInfo) => Colors;\n\n export const getLight: Factory = (primaryColor) => ({\n radioIndicator: '$primary',\n radioBorder: '$grayBlue9',\n radioHoverBg: 'transparent',\n radioHoverBorder: '$primary',\n radioFocusBorder: '$primary',\n radioDisabledBg: '$deepBlue3',\n radioDisabledBorder: '$deepBlue5',\n radioIndicatorDisabledBg: tinycolor(primaryColor.value).setAlpha(0.6).toHslString(),\n });\n\n export const getDark: Factory = (primaryColor) => ({\n radioIndicator: '$primary',\n radioBorder: '$grayBlue9',\n radioHoverBg: '$deepBlue3',\n radioHoverBorder: '$primary',\n radioFocusBorder: '$primary',\n radioDisabledBg: '$deepBlue3',\n radioDisabledBorder: '$deepBlue4',\n radioIndicatorDisabledBg: tinycolor(primaryColor.value).setAlpha(0.6).toHslString(),\n });\n}\n"],"mappings":";;;;AAIO,IAAU;CAAV,SAAA,QAAA;CAaQ,OAAA,YAAqB,kBAAkB;EAClD,gBAAgB;EAChB,aAAa;EACb,cAAc;EACd,kBAAkB;EAClB,kBAAkB;EAClB,iBAAiB;EACjB,qBAAqB;EACrB,2BAAA,GAA0BA,WAAAA,QAAAA,CAAU,aAAa,KAAK,CAAC,CAAC,SAAS,EAAG,CAAC,CAAC,YAAY;CACpF;CAEa,OAAA,WAAoB,kBAAkB;EACjD,gBAAgB;EAChB,aAAa;EACb,cAAc;EACd,kBAAkB;EAClB,kBAAkB;EAClB,iBAAiB;EACjB,qBAAqB;EACrB,2BAAA,GAA0BA,WAAAA,QAAAA,CAAU,aAAa,KAAK,CAAC,CAAC,SAAS,EAAG,CAAC,CAAC,YAAY;CACpF;AACD,EAAA,CAAA,UAAA,QAAA,CAAA,EAAD"}
1
+ {"version":3,"file":"Radio.themes.cjs","names":["tinycolor"],"sources":["../../../components/Radio/Radio.themes.ts"],"sourcesContent":["import { Property } from '@stitches/react/types/css';\nimport tinycolor from 'tinycolor2';\n\nimport { ColorInfo } from '../../utils/getPrimaryColorInfo';\nexport namespace Theme {\n type Colors = {\n radioBorder: Property.Color;\n radioHoverBg: Property.Color;\n radioHoverBorder: Property.Color;\n radioFocusBorder: Property.Color;\n radioDisabledBg: Property.Color;\n radioDisabledBorder: Property.Color;\n radioIndicatorDisabledBg: Property.Color;\n radioInvalidBorder: Property.Color;\n };\n\n type Factory = (primaryColor: ColorInfo) => Colors;\n\n export const getLight: Factory = (primaryColor) => ({\n radioIndicator: '$primary',\n radioBorder: '$grayBlue9',\n radioHoverBg: 'transparent',\n radioHoverBorder: '$primary',\n radioFocusBorder: '$primary',\n radioDisabledBg: '$deepBlue3',\n radioDisabledBorder: '$deepBlue5',\n radioIndicatorDisabledBg: tinycolor(primaryColor.value).setAlpha(0.6).toHslString(),\n radioInvalidBorder: '$red9',\n });\n\n export const getDark: Factory = (primaryColor) => ({\n radioIndicator: '$primary',\n radioBorder: '$grayBlue9',\n radioHoverBg: '$deepBlue3',\n radioHoverBorder: '$primary',\n radioFocusBorder: '$primary',\n radioDisabledBg: '$deepBlue3',\n radioDisabledBorder: '$deepBlue4',\n radioIndicatorDisabledBg: tinycolor(primaryColor.value).setAlpha(0.6).toHslString(),\n radioInvalidBorder: '$red9',\n });\n}\n"],"mappings":";;;;AAIO,IAAU;CAAV,SAAA,QAAA;CAcQ,OAAA,YAAqB,kBAAkB;EAClD,gBAAgB;EAChB,aAAa;EACb,cAAc;EACd,kBAAkB;EAClB,kBAAkB;EAClB,iBAAiB;EACjB,qBAAqB;EACrB,2BAAA,GAA0BA,WAAAA,QAAAA,CAAU,aAAa,KAAK,CAAC,CAAC,SAAS,EAAG,CAAC,CAAC,YAAY;EAClF,oBAAoB;CACtB;CAEa,OAAA,WAAoB,kBAAkB;EACjD,gBAAgB;EAChB,aAAa;EACb,cAAc;EACd,kBAAkB;EAClB,kBAAkB;EAClB,iBAAiB;EACjB,qBAAqB;EACrB,2BAAA,GAA0BA,WAAAA,QAAAA,CAAU,aAAa,KAAK,CAAC,CAAC,SAAS,EAAG,CAAC,CAAC,YAAY;EAClF,oBAAoB;CACtB;AACD,EAAA,CAAA,UAAA,QAAA,CAAA,EAAD"}
@@ -10,7 +10,8 @@ var Theme;
10
10
  radioFocusBorder: "$primary",
11
11
  radioDisabledBg: "$deepBlue3",
12
12
  radioDisabledBorder: "$deepBlue5",
13
- radioIndicatorDisabledBg: tinycolor(primaryColor.value).setAlpha(.6).toHslString()
13
+ radioIndicatorDisabledBg: tinycolor(primaryColor.value).setAlpha(.6).toHslString(),
14
+ radioInvalidBorder: "$red9"
14
15
  });
15
16
  _Theme.getDark = (primaryColor) => ({
16
17
  radioIndicator: "$primary",
@@ -20,7 +21,8 @@ var Theme;
20
21
  radioFocusBorder: "$primary",
21
22
  radioDisabledBg: "$deepBlue3",
22
23
  radioDisabledBorder: "$deepBlue4",
23
- radioIndicatorDisabledBg: tinycolor(primaryColor.value).setAlpha(.6).toHslString()
24
+ radioIndicatorDisabledBg: tinycolor(primaryColor.value).setAlpha(.6).toHslString(),
25
+ radioInvalidBorder: "$red9"
24
26
  });
25
27
  })(Theme || (Theme = {}));
26
28
  export { Theme };
@@ -1 +1 @@
1
- {"version":3,"file":"Radio.themes.js","names":[],"sources":["../../../components/Radio/Radio.themes.ts"],"sourcesContent":["import { Property } from '@stitches/react/types/css';\nimport tinycolor from 'tinycolor2';\n\nimport { ColorInfo } from '../../utils/getPrimaryColorInfo';\nexport namespace Theme {\n type Colors = {\n radioBorder: Property.Color;\n radioHoverBg: Property.Color;\n radioHoverBorder: Property.Color;\n radioFocusBorder: Property.Color;\n radioDisabledBg: Property.Color;\n radioDisabledBorder: Property.Color;\n radioIndicatorDisabledBg: Property.Color;\n };\n\n type Factory = (primaryColor: ColorInfo) => Colors;\n\n export const getLight: Factory = (primaryColor) => ({\n radioIndicator: '$primary',\n radioBorder: '$grayBlue9',\n radioHoverBg: 'transparent',\n radioHoverBorder: '$primary',\n radioFocusBorder: '$primary',\n radioDisabledBg: '$deepBlue3',\n radioDisabledBorder: '$deepBlue5',\n radioIndicatorDisabledBg: tinycolor(primaryColor.value).setAlpha(0.6).toHslString(),\n });\n\n export const getDark: Factory = (primaryColor) => ({\n radioIndicator: '$primary',\n radioBorder: '$grayBlue9',\n radioHoverBg: '$deepBlue3',\n radioHoverBorder: '$primary',\n radioFocusBorder: '$primary',\n radioDisabledBg: '$deepBlue3',\n radioDisabledBorder: '$deepBlue4',\n radioIndicatorDisabledBg: tinycolor(primaryColor.value).setAlpha(0.6).toHslString(),\n });\n}\n"],"mappings":";;AAIO,IAAU;CAAV,SAAA,QAAA;CAaQ,OAAA,YAAqB,kBAAkB;EAClD,gBAAgB;EAChB,aAAa;EACb,cAAc;EACd,kBAAkB;EAClB,kBAAkB;EAClB,iBAAiB;EACjB,qBAAqB;EACrB,0BAA0B,UAAU,aAAa,KAAK,CAAC,CAAC,SAAS,EAAG,CAAC,CAAC,YAAY;CACpF;CAEa,OAAA,WAAoB,kBAAkB;EACjD,gBAAgB;EAChB,aAAa;EACb,cAAc;EACd,kBAAkB;EAClB,kBAAkB;EAClB,iBAAiB;EACjB,qBAAqB;EACrB,0BAA0B,UAAU,aAAa,KAAK,CAAC,CAAC,SAAS,EAAG,CAAC,CAAC,YAAY;CACpF;AACD,EAAA,CAAA,UAAA,QAAA,CAAA,EAAD"}
1
+ {"version":3,"file":"Radio.themes.js","names":[],"sources":["../../../components/Radio/Radio.themes.ts"],"sourcesContent":["import { Property } from '@stitches/react/types/css';\nimport tinycolor from 'tinycolor2';\n\nimport { ColorInfo } from '../../utils/getPrimaryColorInfo';\nexport namespace Theme {\n type Colors = {\n radioBorder: Property.Color;\n radioHoverBg: Property.Color;\n radioHoverBorder: Property.Color;\n radioFocusBorder: Property.Color;\n radioDisabledBg: Property.Color;\n radioDisabledBorder: Property.Color;\n radioIndicatorDisabledBg: Property.Color;\n radioInvalidBorder: Property.Color;\n };\n\n type Factory = (primaryColor: ColorInfo) => Colors;\n\n export const getLight: Factory = (primaryColor) => ({\n radioIndicator: '$primary',\n radioBorder: '$grayBlue9',\n radioHoverBg: 'transparent',\n radioHoverBorder: '$primary',\n radioFocusBorder: '$primary',\n radioDisabledBg: '$deepBlue3',\n radioDisabledBorder: '$deepBlue5',\n radioIndicatorDisabledBg: tinycolor(primaryColor.value).setAlpha(0.6).toHslString(),\n radioInvalidBorder: '$red9',\n });\n\n export const getDark: Factory = (primaryColor) => ({\n radioIndicator: '$primary',\n radioBorder: '$grayBlue9',\n radioHoverBg: '$deepBlue3',\n radioHoverBorder: '$primary',\n radioFocusBorder: '$primary',\n radioDisabledBg: '$deepBlue3',\n radioDisabledBorder: '$deepBlue4',\n radioIndicatorDisabledBg: tinycolor(primaryColor.value).setAlpha(0.6).toHslString(),\n radioInvalidBorder: '$red9',\n });\n}\n"],"mappings":";;AAIO,IAAU;CAAV,SAAA,QAAA;CAcQ,OAAA,YAAqB,kBAAkB;EAClD,gBAAgB;EAChB,aAAa;EACb,cAAc;EACd,kBAAkB;EAClB,kBAAkB;EAClB,iBAAiB;EACjB,qBAAqB;EACrB,0BAA0B,UAAU,aAAa,KAAK,CAAC,CAAC,SAAS,EAAG,CAAC,CAAC,YAAY;EAClF,oBAAoB;CACtB;CAEa,OAAA,WAAoB,kBAAkB;EACjD,gBAAgB;EAChB,aAAa;EACb,cAAc;EACd,kBAAkB;EAClB,kBAAkB;EAClB,iBAAiB;EACjB,qBAAqB;EACrB,0BAA0B,UAAU,aAAa,KAAK,CAAC,CAAC,SAAS,EAAG,CAAC,CAAC,YAAY;EAClF,oBAAoB;CACtB;AACD,EAAA,CAAA,UAAA,QAAA,CAAA,EAAD"}
@@ -1,6 +1,8 @@
1
1
  const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
2
2
  const require_stitches_config = require("../../stitches.config.cjs");
3
3
  const require_Elevation = require("../Elevation/Elevation.cjs");
4
+ const require_colorSchemeContext = require("../colorSchemeContext.cjs");
5
+ const require_FieldContext = require("../Field/FieldContext.cjs");
4
6
  let _radix_ui_react_icons = require("@radix-ui/react-icons");
5
7
  let react = require("react");
6
8
  react = require_runtime.__toESM(react, 1);
@@ -75,6 +77,15 @@ var SelectWrapper = require_stitches_config.styled("div", {
75
77
  fontWeight: "$regular",
76
78
  height: "$5",
77
79
  flexShrink: 0,
80
+ [`& ${StyledSelect}:-webkit-autofill, & ${StyledSelect}:autofill`]: {
81
+ boxShadow: "inset 0 0 0 1px $colors$selectBorder, inset 0 0 0 100px $colors$selectBg",
82
+ WebkitTextFillColor: "$colors$hiContrast"
83
+ },
84
+ [`& ${StyledSelect}:-webkit-autofill:has(option[value=""]:checked)`]: {
85
+ colorScheme: "light !important",
86
+ WebkitTextFillColor: "black"
87
+ },
88
+ [`& ${StyledSelect}:-webkit-autofill:focus-visible, & ${StyledSelect}:autofill:focus-visible`]: { boxShadow: `inset 0 0 0 2px $colors$selectFocusBorder, inset 0 0 0 100px $colors$selectBg, ${FOCUS_SHADOW}` },
78
89
  "&::before": {
79
90
  boxSizing: "border-box",
80
91
  content: "\"\"",
@@ -166,24 +177,42 @@ var SelectWrapper = require_stitches_config.styled("div", {
166
177
  } },
167
178
  state: { invalid: {
168
179
  boxShadow: "inset 0 0 0 1px $colors$selectInvalidBorder",
180
+ [`& ${StyledSelect}:-webkit-autofill, & ${StyledSelect}:autofill`]: { boxShadow: "inset 0 0 0 1px $colors$selectInvalidBorder, inset 0 0 0 100px $colors$selectBg" },
169
181
  "&:focus-visible": { boxShadow: `inset 0 0 0 2px $colors$selectInvalidBorder, ${FOCUS_SHADOW}` }
170
182
  } }
171
183
  },
172
184
  defaultVariants: { size: "medium" }
173
185
  });
174
- var Select = react.default.forwardRef(({ css, size, state, variant, cursor, ...props }, forwardedRef) => {
186
+ var Select = react.default.forwardRef(({ css, size, state, variant, cursor, id, disabled, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, style, ...props }, forwardedRef) => {
187
+ const colorScheme = require_colorSchemeContext.useColorScheme();
188
+ const control = require_FieldContext.useFieldControl({
189
+ id,
190
+ disabled,
191
+ invalid: state === "invalid",
192
+ "aria-describedby": ariaDescribedBy,
193
+ "aria-invalid": ariaInvalid
194
+ });
175
195
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(SelectWrapper, {
176
196
  css,
177
197
  size,
178
- state,
198
+ state: control.invalid ? "invalid" : state,
179
199
  variant,
180
- disabled: props.disabled,
200
+ disabled: control.disabled,
181
201
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledSelect, {
182
202
  ref: forwardedRef,
203
+ id: control.id,
204
+ disabled: control.disabled,
205
+ "aria-describedby": control["aria-describedby"],
206
+ "aria-invalid": control["aria-invalid"],
207
+ style: {
208
+ colorScheme,
209
+ ...style
210
+ },
183
211
  ...props
184
212
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledCaretSortIcon, {
185
213
  size,
186
- cursor
214
+ cursor,
215
+ "aria-hidden": true
187
216
  })]
188
217
  });
189
218
  });
@@ -1 +1 @@
1
- {"version":3,"file":"Select.cjs","names":["elevationVariants","styled","CaretSortIcon","React"],"sources":["../../../components/Select/Select.tsx"],"sourcesContent":["import { CaretSortIcon } from '@radix-ui/react-icons';\nimport React from 'react';\n\nimport { CSS, styled, VariantProps } from '../../stitches.config';\nimport { elevationVariants } from '../Elevation';\n\n// CONSTANTS\nconst FOCUS_SHADOW = elevationVariants[1].boxShadow; // apply elevation $1 when focus\nconst CARET_WIDTH = '15px';\n\nconst StyledCaretSortIcon = styled(CaretSortIcon, {\n position: 'absolute',\n pointerEvents: 'none',\n display: 'inline',\n\n variants: {\n // Use margins instead of top/left to avoid setting \"position: relative\" on parent,\n // which would make stacking context tricky with Select used in a control group.\n size: {\n small: {\n marginTop: 5,\n marginLeft: -16,\n },\n medium: {\n marginTop: 9,\n marginLeft: -16,\n },\n large: {\n marginTop: 13,\n marginLeft: -16,\n },\n },\n cursor: {\n default: {\n cursor: 'default',\n '&:focus': {\n cursor: 'text',\n },\n },\n text: {\n cursor: 'text',\n },\n },\n },\n defaultVariants: {\n size: 'medium',\n },\n});\n\nconst StyledSelect = styled('select', {\n appearance: 'none',\n backgroundColor: 'transparent',\n border: 'none',\n borderRadius: 'inherit',\n color: 'inherit',\n font: 'inherit',\n outline: 'none',\n width: '100%',\n height: '100%',\n pl: '$1',\n pr: '$3',\n lineHeight: '25px',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n\n '& option': {\n color: 'black',\n bc: 'white',\n },\n\n '&:focus-visible': {\n boxShadow: `inset 0 0 0 2px $colors$selectFocusBorder, ${FOCUS_SHADOW}`,\n },\n\n '&:disabled': {\n pointerEvents: 'none',\n color: '$selectDisabledText',\n },\n});\n\nconst SelectWrapper = styled('div', {\n position: 'relative',\n backgroundColor: '$selectBg',\n borderRadius: '$2',\n boxShadow: 'inset 0 0 0 1px $colors$selectBorder',\n color: '$selectText',\n fontFamily: '$rubik',\n fontSize: '$1',\n fontVariantNumeric: 'tabular-nums',\n fontWeight: '$regular',\n height: '$5',\n flexShrink: 0,\n\n '&::before': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n inset: 0,\n pointerEvents: 'none',\n borderRadius: 'inherit',\n },\n '&::after': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n inset: 0,\n pointerEvents: 'none',\n borderRadius: 'inherit',\n },\n\n '&:focus-visible': {\n '&::before': {\n backgroundColor: '$selectFocusBg',\n },\n '&::after': {\n backgroundColor: '$primary',\n opacity: 0.15,\n },\n },\n\n '@hover': {\n '&:hover': {\n '&::before': {\n backgroundColor: '$selectHoverBg',\n },\n '&::after': {\n backgroundColor: '$primary',\n opacity: 0.05,\n },\n },\n },\n\n variants: {\n disabled: {\n true: {\n opacity: 0.7,\n color: '$selectDisabledText',\n '@hover': {\n '&:hover': {\n '&::before': {\n display: 'none',\n },\n '&::after': {\n display: 'none',\n },\n },\n },\n },\n },\n size: {\n small: {\n borderRadius: '$2',\n height: '$5',\n fontSize: '$1',\n lineHeight: '$sizes$5',\n '&:-webkit-autofill::first-line': {\n fontSize: '$1',\n },\n [`& ${StyledSelect}`]: {\n pl: '$2',\n pr: `calc($2 + ${CARET_WIDTH})`,\n },\n [`& ${StyledCaretSortIcon}`]: {\n right: 'calc($2 / 2)',\n },\n },\n medium: {\n borderRadius: '$3',\n height: '$6',\n fontSize: '$3',\n lineHeight: '$sizes$6',\n '&:-webkit-autofill::first-line': {\n fontSize: '$3',\n },\n [`& ${StyledSelect}`]: {\n pl: '$3',\n pr: `calc($3 + ${CARET_WIDTH})`,\n },\n [`& ${StyledCaretSortIcon}`]: {\n right: 'calc($3 / 2)',\n },\n },\n large: {\n borderRadius: '$3',\n height: '$7',\n fontSize: '$3',\n lineHeight: '$sizes$7',\n '&:-webkit-autofill::first-line': {\n fontSize: '$3',\n },\n [`& ${StyledSelect}`]: {\n pl: '$3',\n pr: `calc($3 + ${CARET_WIDTH})`,\n },\n [`& ${StyledCaretSortIcon}`]: {\n right: 'calc($3 / 2)',\n },\n },\n },\n variant: {\n ghost: {\n boxShadow: 'none',\n backgroundColor: 'transparent',\n '@hover': {\n '&:hover': {\n boxShadow: 'inset 0 0 0 1px $colors$slateA7',\n backgroundColor: '$selectHoverBg',\n },\n },\n '&:focus-within': {\n backgroundColor: '$loContrast',\n boxShadow:\n 'inset 0px 0px 0px 1px $colors$selectFocusBorder, 0px 0px 0px 1px $colors$selectFocusBorder',\n },\n },\n },\n state: {\n invalid: {\n boxShadow: 'inset 0 0 0 1px $colors$selectInvalidBorder',\n '&:focus-visible': {\n boxShadow: `inset 0 0 0 2px $colors$selectInvalidBorder, ${FOCUS_SHADOW}`,\n },\n },\n },\n },\n defaultVariants: {\n size: 'medium',\n },\n});\n\nexport type SelectVariants = VariantProps<typeof StyledSelect> &\n VariantProps<typeof SelectWrapper> &\n VariantProps<typeof StyledCaretSortIcon>;\n\nexport type SelectProps = Omit<React.ComponentProps<typeof StyledSelect>, 'size'> &\n SelectVariants & { css?: CSS };\n\nexport const Select = React.forwardRef<React.ElementRef<typeof StyledSelect>, SelectProps>(\n ({ css, size, state, variant, cursor, ...props }, forwardedRef) => {\n return (\n <SelectWrapper\n css={css}\n size={size}\n state={state}\n variant={variant}\n disabled={props.disabled}\n >\n <StyledSelect ref={forwardedRef} {...props} />\n <StyledCaretSortIcon size={size} cursor={cursor} />\n </SelectWrapper>\n );\n }\n);\n\nSelect.toString = () => `.${SelectWrapper.className}`;\n"],"mappings":";;;;;;;;AAOA,IAAM,eAAeA,kBAAAA,kBAAkB,EAAE,CAAC;AAC1C,IAAM,cAAc;AAEpB,IAAM,sBAAsBC,wBAAAA,OAAOC,sBAAAA,eAAe;CAChD,UAAU;CACV,eAAe;CACf,SAAS;CAET,UAAU;EAGR,MAAM;GACJ,OAAO;IACL,WAAW;IACX,YAAY;GACd;GACA,QAAQ;IACN,WAAW;IACX,YAAY;GACd;GACA,OAAO;IACL,WAAW;IACX,YAAY;GACd;EACF;EACA,QAAQ;GACN,SAAS;IACP,QAAQ;IACR,WAAW,EACT,QAAQ,OACV;GACF;GACA,MAAM,EACJ,QAAQ,OACV;EACF;CACF;CACA,iBAAiB,EACf,MAAM,SACR;AACF,CAAC;AAED,IAAM,eAAeD,wBAAAA,OAAO,UAAU;CACpC,YAAY;CACZ,iBAAiB;CACjB,QAAQ;CACR,cAAc;CACd,OAAO;CACP,MAAM;CACN,SAAS;CACT,OAAO;CACP,QAAQ;CACR,IAAI;CACJ,IAAI;CACJ,YAAY;CACZ,UAAU;CACV,cAAc;CACd,YAAY;CAEZ,YAAY;EACV,OAAO;EACP,IAAI;CACN;CAEA,mBAAmB,EACjB,WA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AU,KACZ;KACC,KAAK,iBAAiB;KACrB,IAAI;KACJ,IAAI,aAAa,YAAY;IAC/B;KACC,KAAK,wBAAwB,EAC5B,OAAO,eACT;GACF;EACF;EACA,SAAS,EACP,OAAO;GACL,WAAW;GACX,iBAAiB;GACjB,UAAU,EACR,WAAW;IACT,WAAW;IACX,iBAAiB;GACnB,EACF;GACA,kBAAkB;IAChB,iBAAiB;IACjB,WACE;GACJ;EACF,EACF;EACA,OAAO,EACL,SAAS;GACP,WAAW;GACX,mBAAmB,EACjB,WAAW,gDAAgD,eAC7D;EACF,EACF;CACF;CACA,iBAAiB,EACf,MAAM,SACR;AACF,CAAC;AASD,IAAa,SAASE,MAAAA,QAAM,YACzB,EAAE,KAAK,MAAM,OAAO,SAAS,QAAQ,GAAG,SAAS,iBAAiB;CACjE,OACE,iBAAA,GAAA,kBAAA,KAAA,CAAC,eAAD;EACO;EACC;EACC;EACE;EACT,UAAU,MAAM;EALlB,UAAA,CAOE,iBAAA,GAAA,kBAAA,IAAA,CAAC,cAAD;GAAc,KAAK;GAAc,GAAI;EAAQ,CAAA,GAC7C,iBAAA,GAAA,kBAAA,IAAA,CAAC,qBAAD;GAA2B;GAAc;EAAS,CAAA,CACrC;;AAEnB,CACF;AAEA,OAAO,iBAAiB,IAAI,cAAc"}
1
+ {"version":3,"file":"Select.cjs","names":["elevationVariants","styled","CaretSortIcon","React","useColorScheme","useFieldControl"],"sources":["../../../components/Select/Select.tsx"],"sourcesContent":["import { CaretSortIcon } from '@radix-ui/react-icons';\nimport React from 'react';\n\nimport { CSS, styled, VariantProps } from '../../stitches.config';\nimport { useColorScheme } from '../colorSchemeContext';\nimport { elevationVariants } from '../Elevation';\nimport { useFieldControl } from '../Field/FieldContext';\n\n// CONSTANTS\nconst FOCUS_SHADOW = elevationVariants[1].boxShadow; // apply elevation $1 when focus\nconst CARET_WIDTH = '15px';\n\nconst StyledCaretSortIcon = styled(CaretSortIcon, {\n position: 'absolute',\n pointerEvents: 'none',\n display: 'inline',\n\n variants: {\n // Use margins instead of top/left to avoid setting \"position: relative\" on parent,\n // which would make stacking context tricky with Select used in a control group.\n size: {\n small: {\n marginTop: 5,\n marginLeft: -16,\n },\n medium: {\n marginTop: 9,\n marginLeft: -16,\n },\n large: {\n marginTop: 13,\n marginLeft: -16,\n },\n },\n cursor: {\n default: {\n cursor: 'default',\n '&:focus': {\n cursor: 'text',\n },\n },\n text: {\n cursor: 'text',\n },\n },\n },\n defaultVariants: {\n size: 'medium',\n },\n});\n\nconst StyledSelect = styled('select', {\n appearance: 'none',\n backgroundColor: 'transparent',\n border: 'none',\n borderRadius: 'inherit',\n color: 'inherit',\n font: 'inherit',\n outline: 'none',\n width: '100%',\n height: '100%',\n pl: '$1',\n pr: '$3',\n lineHeight: '25px',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n\n '& option': {\n color: 'black',\n bc: 'white',\n },\n\n '&:focus-visible': {\n boxShadow: `inset 0 0 0 2px $colors$selectFocusBorder, ${FOCUS_SHADOW}`,\n },\n\n '&:disabled': {\n pointerEvents: 'none',\n color: '$selectDisabledText',\n },\n});\n\nconst SelectWrapper = styled('div', {\n position: 'relative',\n backgroundColor: '$selectBg',\n borderRadius: '$2',\n boxShadow: 'inset 0 0 0 1px $colors$selectBorder',\n color: '$selectText',\n fontFamily: '$rubik',\n fontSize: '$1',\n fontVariantNumeric: 'tabular-nums',\n fontWeight: '$regular',\n height: '$5',\n flexShrink: 0,\n\n [`& ${StyledSelect}:-webkit-autofill, & ${StyledSelect}:autofill`]: {\n boxShadow: 'inset 0 0 0 1px $colors$selectBorder, inset 0 0 0 100px $colors$selectBg',\n WebkitTextFillColor: '$colors$hiContrast',\n },\n\n [`& ${StyledSelect}:-webkit-autofill:has(option[value=\"\"]:checked)`]: {\n colorScheme: 'light !important',\n WebkitTextFillColor: 'black',\n },\n\n [`& ${StyledSelect}:-webkit-autofill:focus-visible, & ${StyledSelect}:autofill:focus-visible`]: {\n boxShadow: `inset 0 0 0 2px $colors$selectFocusBorder, inset 0 0 0 100px $colors$selectBg, ${FOCUS_SHADOW}`,\n },\n\n '&::before': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n inset: 0,\n pointerEvents: 'none',\n borderRadius: 'inherit',\n },\n '&::after': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n inset: 0,\n pointerEvents: 'none',\n borderRadius: 'inherit',\n },\n\n '&:focus-visible': {\n '&::before': {\n backgroundColor: '$selectFocusBg',\n },\n '&::after': {\n backgroundColor: '$primary',\n opacity: 0.15,\n },\n },\n\n '@hover': {\n '&:hover': {\n '&::before': {\n backgroundColor: '$selectHoverBg',\n },\n '&::after': {\n backgroundColor: '$primary',\n opacity: 0.05,\n },\n },\n },\n\n variants: {\n disabled: {\n true: {\n opacity: 0.7,\n color: '$selectDisabledText',\n '@hover': {\n '&:hover': {\n '&::before': {\n display: 'none',\n },\n '&::after': {\n display: 'none',\n },\n },\n },\n },\n },\n size: {\n small: {\n borderRadius: '$2',\n height: '$5',\n fontSize: '$1',\n lineHeight: '$sizes$5',\n '&:-webkit-autofill::first-line': {\n fontSize: '$1',\n },\n [`& ${StyledSelect}`]: {\n pl: '$2',\n pr: `calc($2 + ${CARET_WIDTH})`,\n },\n [`& ${StyledCaretSortIcon}`]: {\n right: 'calc($2 / 2)',\n },\n },\n medium: {\n borderRadius: '$3',\n height: '$6',\n fontSize: '$3',\n lineHeight: '$sizes$6',\n '&:-webkit-autofill::first-line': {\n fontSize: '$3',\n },\n [`& ${StyledSelect}`]: {\n pl: '$3',\n pr: `calc($3 + ${CARET_WIDTH})`,\n },\n [`& ${StyledCaretSortIcon}`]: {\n right: 'calc($3 / 2)',\n },\n },\n large: {\n borderRadius: '$3',\n height: '$7',\n fontSize: '$3',\n lineHeight: '$sizes$7',\n '&:-webkit-autofill::first-line': {\n fontSize: '$3',\n },\n [`& ${StyledSelect}`]: {\n pl: '$3',\n pr: `calc($3 + ${CARET_WIDTH})`,\n },\n [`& ${StyledCaretSortIcon}`]: {\n right: 'calc($3 / 2)',\n },\n },\n },\n variant: {\n ghost: {\n boxShadow: 'none',\n backgroundColor: 'transparent',\n '@hover': {\n '&:hover': {\n boxShadow: 'inset 0 0 0 1px $colors$slateA7',\n backgroundColor: '$selectHoverBg',\n },\n },\n '&:focus-within': {\n backgroundColor: '$loContrast',\n boxShadow:\n 'inset 0px 0px 0px 1px $colors$selectFocusBorder, 0px 0px 0px 1px $colors$selectFocusBorder',\n },\n },\n },\n state: {\n invalid: {\n boxShadow: 'inset 0 0 0 1px $colors$selectInvalidBorder',\n [`& ${StyledSelect}:-webkit-autofill, & ${StyledSelect}:autofill`]: {\n boxShadow:\n 'inset 0 0 0 1px $colors$selectInvalidBorder, inset 0 0 0 100px $colors$selectBg',\n },\n '&:focus-visible': {\n boxShadow: `inset 0 0 0 2px $colors$selectInvalidBorder, ${FOCUS_SHADOW}`,\n },\n },\n },\n },\n defaultVariants: {\n size: 'medium',\n },\n});\n\nexport type SelectVariants = VariantProps<typeof StyledSelect> &\n VariantProps<typeof SelectWrapper> &\n VariantProps<typeof StyledCaretSortIcon>;\n\nexport type SelectProps = Omit<React.ComponentProps<typeof StyledSelect>, 'size'> &\n SelectVariants & { css?: CSS };\n\nexport const Select = React.forwardRef<React.ElementRef<typeof StyledSelect>, SelectProps>(\n (\n {\n css,\n size,\n state,\n variant,\n cursor,\n id,\n disabled,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n style,\n ...props\n },\n forwardedRef,\n ) => {\n const colorScheme = useColorScheme();\n const control = useFieldControl({\n id,\n disabled,\n invalid: state === 'invalid',\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n });\n\n return (\n <SelectWrapper\n css={css}\n size={size}\n state={control.invalid ? 'invalid' : state}\n variant={variant}\n disabled={control.disabled}\n >\n <StyledSelect\n ref={forwardedRef}\n id={control.id}\n disabled={control.disabled}\n aria-describedby={control['aria-describedby']}\n aria-invalid={control['aria-invalid']}\n style={{ colorScheme, ...style }}\n {...props}\n />\n <StyledCaretSortIcon size={size} cursor={cursor} aria-hidden />\n </SelectWrapper>\n );\n },\n);\n\nSelect.toString = () => `.${SelectWrapper.className}`;\n"],"mappings":";;;;;;;;;;AASA,IAAM,eAAeA,kBAAAA,kBAAkB,EAAE,CAAC;AAC1C,IAAM,cAAc;AAEpB,IAAM,sBAAsBC,wBAAAA,OAAOC,sBAAAA,eAAe;CAChD,UAAU;CACV,eAAe;CACf,SAAS;CAET,UAAU;EAGR,MAAM;GACJ,OAAO;IACL,WAAW;IACX,YAAY;GACd;GACA,QAAQ;IACN,WAAW;IACX,YAAY;GACd;GACA,OAAO;IACL,WAAW;IACX,YAAY;GACd;EACF;EACA,QAAQ;GACN,SAAS;IACP,QAAQ;IACR,WAAW,EACT,QAAQ,OACV;GACF;GACA,MAAM,EACJ,QAAQ,OACV;EACF;CACF;CACA,iBAAiB,EACf,MAAM,SACR;AACF,CAAC;AAED,IAAM,eAAeD,wBAAAA,OAAO,UAAU;CACpC,YAAY;CACZ,iBAAiB;CACjB,QAAQ;CACR,cAAc;CACd,OAAO;CACP,MAAM;CACN,SAAS;CACT,OAAO;CACP,QAAQ;CACR,IAAI;CACJ,IAAI;CACJ,YAAY;CACZ,UAAU;CACV,cAAc;CACd,YAAY;CAEZ,YAAY;EACV,OAAO;EACP,IAAI;CACN;CAEA,mBAAmB,EACjB,WAAW,8CAA8C,eAC3D;CAEA,cAAc;EACZ,eAAe;EACf,OAAO;CACT;AACF,CAAC;AAED,IAAM,gBAAgBA,wBAAAA,OAAO,OAAO;CAClC,UAAU;CACV,iBAAiB;CACjB,cAAc;CACd,WAAW;CACX,OAAO;CACP,YAAY;CACZ,UAAU;CACV,oBAAoB;CACpB,YAAY;CACZ,QAAQ;CACR,YAAY;EAEX,KAAK,aAAa,uBAAuB,aAAa,aAAa;EAClE,WAAW;EACX,qBAAqB;CACvB;EAEC,KAAK,aAAa,mDAAmD;EACp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WAAW;GACX,iBAAiB;GACjB,UAAU,EACR,WAAW;IACT,WAAW;IACX,iBAAiB;GACnB,EACF;GACA,kBAAkB;IAChB,iBAAiB;IACjB,WACE;GACJ;EACF,EACF;EACA,OAAO,EACL,SAAS;GACP,WAAW;IACV,KAAK,aAAa,uBAAuB,aAAa,aAAa,EAClE,WACE,kFACJ;GACA,mBAAmB,EACjB,WAAW,gDAAgD,eAC7D;EACF,EACF;CACF;CACA,iBAAiB,EACf,MAAM,SACR;AACF,CAAC;AASD,IAAa,SAASE,MAAAA,QAAM,YAExB,EACE,KACA,MACA,OACA,SACA,QACA,IACA,UACA,oBAAoB,iBACpB,gBAAgB,aAChB,OACA,GAAG,SAEL,iBACG;CACH,MAAM,cAAcC,2BAAAA,eAAe;CACnC,MAAM,UAAUC,qBAAAA,gBAAgB;EAC9B;EACA;EACA,SAAS,UAAU;EACnB,oBAAoB;EACpB,gBAAgB;CAClB,CAAC;CAED,OACE,iBAAA,GAAA,kBAAA,KAAA,CAAC,eAAD;EACO;EACC;EACN,OAAO,QAAQ,UAAU,YAAY;EAC5B;EACT,UAAU,QAAQ;EALpB,UAAA,CAOE,iBAAA,GAAA,kBAAA,IAAA,CAAC,cAAD;GACE,KAAK;GACL,IAAI,QAAQ;GACZ,UAAU,QAAQ;GAClB,oBAAkB,QAAQ;GAC1B,gBAAc,QAAQ;GACtB,OAAO;IAAE;IAAa,GAAG;GAAM;GAC/B,GAAI;EACL,CAAA,GACD,iBAAA,GAAA,kBAAA,IAAA,CAAC,qBAAD;GAA2B;GAAc;GAAQ,eAAA;EAAa,CAAA,CACjD;;AAEnB,CACF;AAEA,OAAO,iBAAiB,IAAI,cAAc"}
@@ -1,5 +1,7 @@
1
1
  import { styled } from "../../stitches.config.js";
2
2
  import { elevationVariants } from "../Elevation/Elevation.js";
3
+ import { useColorScheme } from "../colorSchemeContext.js";
4
+ import { useFieldControl } from "../Field/FieldContext.js";
3
5
  import { CaretSortIcon } from "@radix-ui/react-icons";
4
6
  import React from "react";
5
7
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -73,6 +75,15 @@ var SelectWrapper = styled("div", {
73
75
  fontWeight: "$regular",
74
76
  height: "$5",
75
77
  flexShrink: 0,
78
+ [`& ${StyledSelect}:-webkit-autofill, & ${StyledSelect}:autofill`]: {
79
+ boxShadow: "inset 0 0 0 1px $colors$selectBorder, inset 0 0 0 100px $colors$selectBg",
80
+ WebkitTextFillColor: "$colors$hiContrast"
81
+ },
82
+ [`& ${StyledSelect}:-webkit-autofill:has(option[value=""]:checked)`]: {
83
+ colorScheme: "light !important",
84
+ WebkitTextFillColor: "black"
85
+ },
86
+ [`& ${StyledSelect}:-webkit-autofill:focus-visible, & ${StyledSelect}:autofill:focus-visible`]: { boxShadow: `inset 0 0 0 2px $colors$selectFocusBorder, inset 0 0 0 100px $colors$selectBg, ${FOCUS_SHADOW}` },
76
87
  "&::before": {
77
88
  boxSizing: "border-box",
78
89
  content: "\"\"",
@@ -164,24 +175,42 @@ var SelectWrapper = styled("div", {
164
175
  } },
165
176
  state: { invalid: {
166
177
  boxShadow: "inset 0 0 0 1px $colors$selectInvalidBorder",
178
+ [`& ${StyledSelect}:-webkit-autofill, & ${StyledSelect}:autofill`]: { boxShadow: "inset 0 0 0 1px $colors$selectInvalidBorder, inset 0 0 0 100px $colors$selectBg" },
167
179
  "&:focus-visible": { boxShadow: `inset 0 0 0 2px $colors$selectInvalidBorder, ${FOCUS_SHADOW}` }
168
180
  } }
169
181
  },
170
182
  defaultVariants: { size: "medium" }
171
183
  });
172
- var Select = React.forwardRef(({ css, size, state, variant, cursor, ...props }, forwardedRef) => {
184
+ var Select = React.forwardRef(({ css, size, state, variant, cursor, id, disabled, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, style, ...props }, forwardedRef) => {
185
+ const colorScheme = useColorScheme();
186
+ const control = useFieldControl({
187
+ id,
188
+ disabled,
189
+ invalid: state === "invalid",
190
+ "aria-describedby": ariaDescribedBy,
191
+ "aria-invalid": ariaInvalid
192
+ });
173
193
  return /* @__PURE__ */ jsxs(SelectWrapper, {
174
194
  css,
175
195
  size,
176
- state,
196
+ state: control.invalid ? "invalid" : state,
177
197
  variant,
178
- disabled: props.disabled,
198
+ disabled: control.disabled,
179
199
  children: [/* @__PURE__ */ jsx(StyledSelect, {
180
200
  ref: forwardedRef,
201
+ id: control.id,
202
+ disabled: control.disabled,
203
+ "aria-describedby": control["aria-describedby"],
204
+ "aria-invalid": control["aria-invalid"],
205
+ style: {
206
+ colorScheme,
207
+ ...style
208
+ },
181
209
  ...props
182
210
  }), /* @__PURE__ */ jsx(StyledCaretSortIcon, {
183
211
  size,
184
- cursor
212
+ cursor,
213
+ "aria-hidden": true
185
214
  })]
186
215
  });
187
216
  });
@@ -1 +1 @@
1
- {"version":3,"file":"Select.js","names":[],"sources":["../../../components/Select/Select.tsx"],"sourcesContent":["import { CaretSortIcon } from '@radix-ui/react-icons';\nimport React from 'react';\n\nimport { CSS, styled, VariantProps } from '../../stitches.config';\nimport { elevationVariants } from '../Elevation';\n\n// CONSTANTS\nconst FOCUS_SHADOW = elevationVariants[1].boxShadow; // apply elevation $1 when focus\nconst CARET_WIDTH = '15px';\n\nconst StyledCaretSortIcon = styled(CaretSortIcon, {\n position: 'absolute',\n pointerEvents: 'none',\n display: 'inline',\n\n variants: {\n // Use margins instead of top/left to avoid setting \"position: relative\" on parent,\n // which would make stacking context tricky with Select used in a control group.\n size: {\n small: {\n marginTop: 5,\n marginLeft: -16,\n },\n medium: {\n marginTop: 9,\n marginLeft: -16,\n },\n large: {\n marginTop: 13,\n marginLeft: -16,\n },\n },\n cursor: {\n default: {\n cursor: 'default',\n '&:focus': {\n cursor: 'text',\n },\n },\n text: {\n cursor: 'text',\n },\n },\n },\n defaultVariants: {\n size: 'medium',\n },\n});\n\nconst StyledSelect = styled('select', {\n appearance: 'none',\n backgroundColor: 'transparent',\n border: 'none',\n borderRadius: 'inherit',\n color: 'inherit',\n font: 'inherit',\n outline: 'none',\n width: '100%',\n height: '100%',\n pl: '$1',\n pr: '$3',\n lineHeight: '25px',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n\n '& option': {\n color: 'black',\n bc: 'white',\n },\n\n '&:focus-visible': {\n boxShadow: `inset 0 0 0 2px $colors$selectFocusBorder, ${FOCUS_SHADOW}`,\n },\n\n '&:disabled': {\n pointerEvents: 'none',\n color: '$selectDisabledText',\n },\n});\n\nconst SelectWrapper = styled('div', {\n position: 'relative',\n backgroundColor: '$selectBg',\n borderRadius: '$2',\n boxShadow: 'inset 0 0 0 1px $colors$selectBorder',\n color: '$selectText',\n fontFamily: '$rubik',\n fontSize: '$1',\n fontVariantNumeric: 'tabular-nums',\n fontWeight: '$regular',\n height: '$5',\n flexShrink: 0,\n\n '&::before': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n inset: 0,\n pointerEvents: 'none',\n borderRadius: 'inherit',\n },\n '&::after': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n inset: 0,\n pointerEvents: 'none',\n borderRadius: 'inherit',\n },\n\n '&:focus-visible': {\n '&::before': {\n backgroundColor: '$selectFocusBg',\n },\n '&::after': {\n backgroundColor: '$primary',\n opacity: 0.15,\n },\n },\n\n '@hover': {\n '&:hover': {\n '&::before': {\n backgroundColor: '$selectHoverBg',\n },\n '&::after': {\n backgroundColor: '$primary',\n opacity: 0.05,\n },\n },\n },\n\n variants: {\n disabled: {\n true: {\n opacity: 0.7,\n color: '$selectDisabledText',\n '@hover': {\n '&:hover': {\n '&::before': {\n display: 'none',\n },\n '&::after': {\n display: 'none',\n },\n },\n },\n },\n },\n size: {\n small: {\n borderRadius: '$2',\n height: '$5',\n fontSize: '$1',\n lineHeight: '$sizes$5',\n '&:-webkit-autofill::first-line': {\n fontSize: '$1',\n },\n [`& ${StyledSelect}`]: {\n pl: '$2',\n pr: `calc($2 + ${CARET_WIDTH})`,\n },\n [`& ${StyledCaretSortIcon}`]: {\n right: 'calc($2 / 2)',\n },\n },\n medium: {\n borderRadius: '$3',\n height: '$6',\n fontSize: '$3',\n lineHeight: '$sizes$6',\n '&:-webkit-autofill::first-line': {\n fontSize: '$3',\n },\n [`& ${StyledSelect}`]: {\n pl: '$3',\n pr: `calc($3 + ${CARET_WIDTH})`,\n },\n [`& ${StyledCaretSortIcon}`]: {\n right: 'calc($3 / 2)',\n },\n },\n large: {\n borderRadius: '$3',\n height: '$7',\n fontSize: '$3',\n lineHeight: '$sizes$7',\n '&:-webkit-autofill::first-line': {\n fontSize: '$3',\n },\n [`& ${StyledSelect}`]: {\n pl: '$3',\n pr: `calc($3 + ${CARET_WIDTH})`,\n },\n [`& ${StyledCaretSortIcon}`]: {\n right: 'calc($3 / 2)',\n },\n },\n },\n variant: {\n ghost: {\n boxShadow: 'none',\n backgroundColor: 'transparent',\n '@hover': {\n '&:hover': {\n boxShadow: 'inset 0 0 0 1px $colors$slateA7',\n backgroundColor: '$selectHoverBg',\n },\n },\n '&:focus-within': {\n backgroundColor: '$loContrast',\n boxShadow:\n 'inset 0px 0px 0px 1px $colors$selectFocusBorder, 0px 0px 0px 1px $colors$selectFocusBorder',\n },\n },\n },\n state: {\n invalid: {\n boxShadow: 'inset 0 0 0 1px $colors$selectInvalidBorder',\n '&:focus-visible': {\n boxShadow: `inset 0 0 0 2px $colors$selectInvalidBorder, ${FOCUS_SHADOW}`,\n },\n },\n },\n },\n defaultVariants: {\n size: 'medium',\n },\n});\n\nexport type SelectVariants = VariantProps<typeof StyledSelect> &\n VariantProps<typeof SelectWrapper> &\n VariantProps<typeof StyledCaretSortIcon>;\n\nexport type SelectProps = Omit<React.ComponentProps<typeof StyledSelect>, 'size'> &\n SelectVariants & { css?: CSS };\n\nexport const Select = React.forwardRef<React.ElementRef<typeof StyledSelect>, SelectProps>(\n ({ css, size, state, variant, cursor, ...props }, forwardedRef) => {\n return (\n <SelectWrapper\n css={css}\n size={size}\n state={state}\n variant={variant}\n disabled={props.disabled}\n >\n <StyledSelect ref={forwardedRef} {...props} />\n <StyledCaretSortIcon size={size} cursor={cursor} />\n </SelectWrapper>\n );\n }\n);\n\nSelect.toString = () => `.${SelectWrapper.className}`;\n"],"mappings":";;;;;;AAOA,IAAM,eAAe,kBAAkB,EAAE,CAAC;AAC1C,IAAM,cAAc;AAEpB,IAAM,sBAAsB,OAAO,eAAe;CAChD,UAAU;CACV,eAAe;CACf,SAAS;CAET,UAAU;EAGR,MAAM;GACJ,OAAO;IACL,WAAW;IACX,YAAY;GACd;GACA,QAAQ;IACN,WAAW;IACX,YAAY;GACd;GACA,OAAO;IACL,WAAW;IACX,YAAY;GACd;EACF;EACA,QAAQ;GACN,SAAS;IACP,QAAQ;IACR,WAAW,EACT,QAAQ,OACV;GACF;GACA,MAAM,EACJ,QAAQ,OACV;EACF;CACF;CACA,iBAAiB,EACf,MAAM,SACR;AACF,CAAC;AAED,IAAM,eAAe,OAAO,UAAU;CACpC,YAAY;CACZ,iBAAiB;CACjB,QAAQ;CACR,cAAc;CACd,OAAO;CACP,MAAM;CACN,SAAS;CACT,OAAO;CACP,QAAQ;CACR,IAAI;CACJ,IAAI;CACJ,YAAY;CACZ,UAAU;CACV,cAAc;CACd,YAAY;CAEZ,YAAY;EACV,OAAO;EACP,IAAI;CACN;CAEA,mBAAmB,EACjB,WAAW,8CAA8C,eAC3D;CAEA,cAAc;EACZ,eAAe;EACf,OAAO;CACT;AACF,CAAC;AAED,IAAM,gBAAgB,OAAO,OAAO;CAClC,UAAU;CACV,iBAAiB;CACjB,cAAc;CACd,WAAW;CACX,OAAO;CACP,YAAY;CACZ,UAAU;CACV,oBAAoB;CACpB,YAAY;CACZ,QAAQ;CACR,YAAY;CAEZ,aAAa;EACX,WAAW;EACX,SAAS;EACT,UAAU;EACV,OAAO;EACP,eAAe;EACf,cAAc;CAChB;CACA,YAAY;EACV,WAAW;EACX,SAAS;EACT,UAAU;EACV,OAAO;EACP,eAAe;EACf,cAAc;CAChB;CAEA,mBAAmB;EACjB,aAAa,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AAE,KAAK,MAAM,OAAO,SAAS,QAAQ,GAAG,SAAS,iBAAiB;CACjE,OACE,qBAAC,eAAD;EACO;EACC;EACC;EACE;EACT,UAAU,MAAM;EALlB,UAAA,CAOE,oBAAC,cAAD;GAAc,KAAK;GAAc,GAAI;EAAQ,CAAA,GAC7C,oBAAC,qBAAD;GAA2B;GAAc;EAAS,CAAA,CACrC;;AAEnB,CACF;AAEA,OAAO,iBAAiB,IAAI,cAAc"}
1
+ {"version":3,"file":"Select.js","names":[],"sources":["../../../components/Select/Select.tsx"],"sourcesContent":["import { CaretSortIcon } from '@radix-ui/react-icons';\nimport React from 'react';\n\nimport { CSS, styled, VariantProps } from '../../stitches.config';\nimport { useColorScheme } from '../colorSchemeContext';\nimport { elevationVariants } from '../Elevation';\nimport { useFieldControl } from '../Field/FieldContext';\n\n// CONSTANTS\nconst FOCUS_SHADOW = elevationVariants[1].boxShadow; // apply elevation $1 when focus\nconst CARET_WIDTH = '15px';\n\nconst StyledCaretSortIcon = styled(CaretSortIcon, {\n position: 'absolute',\n pointerEvents: 'none',\n display: 'inline',\n\n variants: {\n // Use margins instead of top/left to avoid setting \"position: relative\" on parent,\n // which would make stacking context tricky with Select used in a control group.\n size: {\n small: {\n marginTop: 5,\n marginLeft: -16,\n },\n medium: {\n marginTop: 9,\n marginLeft: -16,\n },\n large: {\n marginTop: 13,\n marginLeft: -16,\n },\n },\n cursor: {\n default: {\n cursor: 'default',\n '&:focus': {\n cursor: 'text',\n },\n },\n text: {\n cursor: 'text',\n },\n },\n },\n defaultVariants: {\n size: 'medium',\n },\n});\n\nconst StyledSelect = styled('select', {\n appearance: 'none',\n backgroundColor: 'transparent',\n border: 'none',\n borderRadius: 'inherit',\n color: 'inherit',\n font: 'inherit',\n outline: 'none',\n width: '100%',\n height: '100%',\n pl: '$1',\n pr: '$3',\n lineHeight: '25px',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n\n '& option': {\n color: 'black',\n bc: 'white',\n },\n\n '&:focus-visible': {\n boxShadow: `inset 0 0 0 2px $colors$selectFocusBorder, ${FOCUS_SHADOW}`,\n },\n\n '&:disabled': {\n pointerEvents: 'none',\n color: '$selectDisabledText',\n },\n});\n\nconst SelectWrapper = styled('div', {\n position: 'relative',\n backgroundColor: '$selectBg',\n borderRadius: '$2',\n boxShadow: 'inset 0 0 0 1px $colors$selectBorder',\n color: '$selectText',\n fontFamily: '$rubik',\n fontSize: '$1',\n fontVariantNumeric: 'tabular-nums',\n fontWeight: '$regular',\n height: '$5',\n flexShrink: 0,\n\n [`& ${StyledSelect}:-webkit-autofill, & ${StyledSelect}:autofill`]: {\n boxShadow: 'inset 0 0 0 1px $colors$selectBorder, inset 0 0 0 100px $colors$selectBg',\n WebkitTextFillColor: '$colors$hiContrast',\n },\n\n [`& ${StyledSelect}:-webkit-autofill:has(option[value=\"\"]:checked)`]: {\n colorScheme: 'light !important',\n WebkitTextFillColor: 'black',\n },\n\n [`& ${StyledSelect}:-webkit-autofill:focus-visible, & ${StyledSelect}:autofill:focus-visible`]: {\n boxShadow: `inset 0 0 0 2px $colors$selectFocusBorder, inset 0 0 0 100px $colors$selectBg, ${FOCUS_SHADOW}`,\n },\n\n '&::before': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n inset: 0,\n pointerEvents: 'none',\n borderRadius: 'inherit',\n },\n '&::after': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n inset: 0,\n pointerEvents: 'none',\n borderRadius: 'inherit',\n },\n\n '&:focus-visible': {\n '&::before': {\n backgroundColor: '$selectFocusBg',\n },\n '&::after': {\n backgroundColor: '$primary',\n opacity: 0.15,\n },\n },\n\n '@hover': {\n '&:hover': {\n '&::before': {\n backgroundColor: '$selectHoverBg',\n },\n '&::after': {\n backgroundColor: '$primary',\n opacity: 0.05,\n },\n },\n },\n\n variants: {\n disabled: {\n true: {\n opacity: 0.7,\n color: '$selectDisabledText',\n '@hover': {\n '&:hover': {\n '&::before': {\n display: 'none',\n },\n '&::after': {\n display: 'none',\n },\n },\n },\n },\n },\n size: {\n small: {\n borderRadius: '$2',\n height: '$5',\n fontSize: '$1',\n lineHeight: '$sizes$5',\n '&:-webkit-autofill::first-line': {\n fontSize: '$1',\n },\n [`& ${StyledSelect}`]: {\n pl: '$2',\n pr: `calc($2 + ${CARET_WIDTH})`,\n },\n [`& ${StyledCaretSortIcon}`]: {\n right: 'calc($2 / 2)',\n },\n },\n medium: {\n borderRadius: '$3',\n height: '$6',\n fontSize: '$3',\n lineHeight: '$sizes$6',\n '&:-webkit-autofill::first-line': {\n fontSize: '$3',\n },\n [`& ${StyledSelect}`]: {\n pl: '$3',\n pr: `calc($3 + ${CARET_WIDTH})`,\n },\n [`& ${StyledCaretSortIcon}`]: {\n right: 'calc($3 / 2)',\n },\n },\n large: {\n borderRadius: '$3',\n height: '$7',\n fontSize: '$3',\n lineHeight: '$sizes$7',\n '&:-webkit-autofill::first-line': {\n fontSize: '$3',\n },\n [`& ${StyledSelect}`]: {\n pl: '$3',\n pr: `calc($3 + ${CARET_WIDTH})`,\n },\n [`& ${StyledCaretSortIcon}`]: {\n right: 'calc($3 / 2)',\n },\n },\n },\n variant: {\n ghost: {\n boxShadow: 'none',\n backgroundColor: 'transparent',\n '@hover': {\n '&:hover': {\n boxShadow: 'inset 0 0 0 1px $colors$slateA7',\n backgroundColor: '$selectHoverBg',\n },\n },\n '&:focus-within': {\n backgroundColor: '$loContrast',\n boxShadow:\n 'inset 0px 0px 0px 1px $colors$selectFocusBorder, 0px 0px 0px 1px $colors$selectFocusBorder',\n },\n },\n },\n state: {\n invalid: {\n boxShadow: 'inset 0 0 0 1px $colors$selectInvalidBorder',\n [`& ${StyledSelect}:-webkit-autofill, & ${StyledSelect}:autofill`]: {\n boxShadow:\n 'inset 0 0 0 1px $colors$selectInvalidBorder, inset 0 0 0 100px $colors$selectBg',\n },\n '&:focus-visible': {\n boxShadow: `inset 0 0 0 2px $colors$selectInvalidBorder, ${FOCUS_SHADOW}`,\n },\n },\n },\n },\n defaultVariants: {\n size: 'medium',\n },\n});\n\nexport type SelectVariants = VariantProps<typeof StyledSelect> &\n VariantProps<typeof SelectWrapper> &\n VariantProps<typeof StyledCaretSortIcon>;\n\nexport type SelectProps = Omit<React.ComponentProps<typeof StyledSelect>, 'size'> &\n SelectVariants & { css?: CSS };\n\nexport const Select = React.forwardRef<React.ElementRef<typeof StyledSelect>, SelectProps>(\n (\n {\n css,\n size,\n state,\n variant,\n cursor,\n id,\n disabled,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n style,\n ...props\n },\n forwardedRef,\n ) => {\n const colorScheme = useColorScheme();\n const control = useFieldControl({\n id,\n disabled,\n invalid: state === 'invalid',\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n });\n\n return (\n <SelectWrapper\n css={css}\n size={size}\n state={control.invalid ? 'invalid' : state}\n variant={variant}\n disabled={control.disabled}\n >\n <StyledSelect\n ref={forwardedRef}\n id={control.id}\n disabled={control.disabled}\n aria-describedby={control['aria-describedby']}\n aria-invalid={control['aria-invalid']}\n style={{ colorScheme, ...style }}\n {...props}\n />\n <StyledCaretSortIcon size={size} cursor={cursor} aria-hidden />\n </SelectWrapper>\n );\n },\n);\n\nSelect.toString = () => `.${SelectWrapper.className}`;\n"],"mappings":";;;;;;;;AASA,IAAM,eAAe,kBAAkB,EAAE,CAAC;AAC1C,IAAM,cAAc;AAEpB,IAAM,sBAAsB,OAAO,eAAe;CAChD,UAAU;CACV,eAAe;CACf,SAAS;CAET,UAAU;EAGR,MAAM;GACJ,OAAO;IACL,WAAW;IACX,YAAY;GACd;GACA,QAAQ;IACN,WAAW;IACX,YAAY;GACd;GACA,OAAO;IACL,WAAW;IACX,YAAY;GACd;EACF;EACA,QAAQ;GACN,SAAS;IACP,QAAQ;IACR,WAAW,EACT,QAAQ,OACV;GACF;GACA,MAAM,EACJ,QAAQ,OACV;EACF;CACF;CACA,iBAAiB,EACf,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AY;EAC5B;EACT,UAAU,QAAQ;EALpB,UAAA,CAOE,oBAAC,cAAD;GACE,KAAK;GACL,IAAI,QAAQ;GACZ,UAAU,QAAQ;GAClB,oBAAkB,QAAQ;GAC1B,gBAAc,QAAQ;GACtB,OAAO;IAAE;IAAa,GAAG;GAAM;GAC/B,GAAI;EACL,CAAA,GACD,oBAAC,qBAAD;GAA2B;GAAc;GAAQ,eAAA;EAAa,CAAA,CACjD;;AAEnB,CACF;AAEA,OAAO,iBAAiB,IAAI,cAAc"}
@@ -1,6 +1,7 @@
1
1
  const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
2
2
  const require_stitches_config = require("../../stitches.config.cjs");
3
3
  const require_Elevation = require("../Elevation/Elevation.cjs");
4
+ const require_FieldContext = require("../Field/FieldContext.cjs");
4
5
  let react = require("react");
5
6
  react = require_runtime.__toESM(react, 1);
6
7
  let react_jsx_runtime = require("react/jsx-runtime");
@@ -54,6 +55,7 @@ var StyledSwitch = require_stitches_config.styled(_radix_ui_react_switch.Root, {
54
55
  opacity: .38
55
56
  },
56
57
  "&[data-state=\"checked\"]": { backgroundColor: "$switchActiveBackground" },
58
+ "&[aria-invalid=\"true\"]:not(:focus)": { boxShadow: "inset 0 0 0 1px $colors$switchInvalidBorder" },
57
59
  variants: { size: {
58
60
  "1": {
59
61
  width: ROOT_WIDTH,
@@ -73,11 +75,23 @@ var StyledSwitch = require_stitches_config.styled(_radix_ui_react_switch.Root, {
73
75
  } },
74
76
  defaultVariants: { size: "1" }
75
77
  });
76
- var Switch = react.default.forwardRef((props, forwardedRef) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledSwitch, {
77
- ...props,
78
- ref: forwardedRef,
79
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledThumb, {})
80
- }));
78
+ var Switch = react.default.forwardRef(({ id, disabled, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, ...props }, forwardedRef) => {
79
+ const control = require_FieldContext.useFieldControl({
80
+ id,
81
+ disabled,
82
+ "aria-describedby": ariaDescribedBy,
83
+ "aria-invalid": ariaInvalid
84
+ });
85
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledSwitch, {
86
+ ...props,
87
+ id: control.id,
88
+ disabled: control.disabled,
89
+ "aria-describedby": control["aria-describedby"],
90
+ "aria-invalid": control["aria-invalid"],
91
+ ref: forwardedRef,
92
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledThumb, {})
93
+ });
94
+ });
81
95
  exports.Switch = Switch;
82
96
 
83
97
  //# sourceMappingURL=Switch.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Switch.cjs","names":["styled","SwitchPrimitive","elevationVariants","React"],"sources":["../../../components/Switch/Switch.tsx"],"sourcesContent":["import * as SwitchPrimitive from '@radix-ui/react-switch';\nimport React from 'react';\n\nimport { CSS, styled, VariantProps } from '../../stitches.config';\nimport { elevationVariants } from '../Elevation';\n\n// CONSTANTS\nconst THUMB_DIAMETER = 14; // @FIXME: shouldn't this size be part of theme ?\nconst LARGE_RATIO = 1.5;\nconst THUMB_GAP = 2; // Gap between thumb and background\nconst ROOT_WIDTH = 32;\nconst ROOT_HEIGHT = 18;\n\n// COMPONENTS\nconst StyledThumb = styled(SwitchPrimitive.Thumb, {\n position: 'absolute',\n left: 0,\n width: THUMB_DIAMETER,\n height: THUMB_DIAMETER,\n backgroundColor: '$switchThumb',\n borderRadius: '$round',\n boxShadow: 'rgba(0, 0, 0, 0.3) 0px 0px 1px, rgba(0, 0, 0, 0.2) 0px 1px 2px;',\n transition: 'transform 100ms cubic-bezier(0.22, 1, 0.36, 1)',\n transform: `translateX(${THUMB_GAP}px)`,\n willChange: 'transform',\n\n '&[data-state=\"checked\"]': {\n transform: `translateX(${ROOT_WIDTH - THUMB_GAP - THUMB_DIAMETER}px)`,\n },\n});\n\nconst StyledSwitch = styled(SwitchPrimitive.Root, {\n all: 'unset',\n boxSizing: 'border-box',\n userSelect: 'none',\n '&::before': {\n boxSizing: 'border-box',\n },\n '&::after': {\n boxSizing: 'border-box',\n },\n\n // Reset\n alignItems: 'center',\n display: 'inline-flex',\n justifyContent: 'center',\n lineHeight: '1',\n margin: '0',\n outline: 'none',\n WebkitTapHighlightColor: 'rgba(0,0,0,0)',\n\n backgroundColor: '$switchBackground',\n borderRadius: '$pill',\n position: 'relative',\n '@hover': {\n '&:hover': {\n cursor: 'pointer',\n [`& ${StyledThumb}`]: {\n ...elevationVariants[1],\n },\n },\n },\n '&:focus': {\n outline: '2px solid $switchFocusBorder',\n [`& ${StyledThumb}`]: {\n ...elevationVariants[2],\n },\n },\n '&:disabled': {\n pointerEvents: 'none',\n opacity: 0.38,\n },\n '&[data-state=\"checked\"]': {\n backgroundColor: '$switchActiveBackground',\n },\n\n variants: {\n size: {\n '1': {\n width: ROOT_WIDTH,\n height: ROOT_HEIGHT,\n m: '$2',\n },\n '2': {\n width: ROOT_WIDTH * LARGE_RATIO,\n height: ROOT_HEIGHT * LARGE_RATIO,\n [`& ${StyledThumb}`]: {\n width: THUMB_DIAMETER * LARGE_RATIO,\n height: THUMB_DIAMETER * LARGE_RATIO,\n transform: `translateX(${LARGE_RATIO * THUMB_GAP})`,\n\n '&[data-state=\"checked\"]': {\n transform: `translateX(${LARGE_RATIO * (ROOT_WIDTH - THUMB_GAP - THUMB_DIAMETER)}px)`,\n },\n },\n },\n },\n },\n defaultVariants: {\n size: '1',\n },\n});\n\nexport type SwitchVariants = VariantProps<typeof StyledSwitch>;\ntype SwitchPrimitiveProps = Omit<React.ComponentProps<typeof SwitchPrimitive.Root>, 'as'>;\nexport type SwitchProps = SwitchPrimitiveProps & SwitchVariants & { css?: CSS };\n\nexport const Switch = React.forwardRef<React.ElementRef<typeof StyledSwitch>, SwitchProps>(\n (props, forwardedRef) => (\n <StyledSwitch {...props} ref={forwardedRef}>\n <StyledThumb />\n </StyledSwitch>\n )\n);\n"],"mappings":";;;;;;;;;AAOA,IAAM,iBAAiB;AACvB,IAAM,cAAc;AAC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B,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,aAAD,CAAc,CAAA;AACF,CAAA,CAElB"}
1
+ {"version":3,"file":"Switch.cjs","names":["styled","SwitchPrimitive","elevationVariants","React","useFieldControl"],"sources":["../../../components/Switch/Switch.tsx"],"sourcesContent":["import * as SwitchPrimitive from '@radix-ui/react-switch';\nimport React from 'react';\n\nimport { CSS, styled, VariantProps } from '../../stitches.config';\nimport { elevationVariants } from '../Elevation';\nimport { useFieldControl } from '../Field/FieldContext';\n\n// CONSTANTS\nconst THUMB_DIAMETER = 14; // @FIXME: shouldn't this size be part of theme ?\nconst LARGE_RATIO = 1.5;\nconst THUMB_GAP = 2; // Gap between thumb and background\nconst ROOT_WIDTH = 32;\nconst ROOT_HEIGHT = 18;\n\n// COMPONENTS\nconst StyledThumb = styled(SwitchPrimitive.Thumb, {\n position: 'absolute',\n left: 0,\n width: THUMB_DIAMETER,\n height: THUMB_DIAMETER,\n backgroundColor: '$switchThumb',\n borderRadius: '$round',\n boxShadow: 'rgba(0, 0, 0, 0.3) 0px 0px 1px, rgba(0, 0, 0, 0.2) 0px 1px 2px;',\n transition: 'transform 100ms cubic-bezier(0.22, 1, 0.36, 1)',\n transform: `translateX(${THUMB_GAP}px)`,\n willChange: 'transform',\n\n '&[data-state=\"checked\"]': {\n transform: `translateX(${ROOT_WIDTH - THUMB_GAP - THUMB_DIAMETER}px)`,\n },\n});\n\nconst StyledSwitch = styled(SwitchPrimitive.Root, {\n all: 'unset',\n boxSizing: 'border-box',\n userSelect: 'none',\n '&::before': {\n boxSizing: 'border-box',\n },\n '&::after': {\n boxSizing: 'border-box',\n },\n\n // Reset\n alignItems: 'center',\n display: 'inline-flex',\n justifyContent: 'center',\n lineHeight: '1',\n margin: '0',\n outline: 'none',\n WebkitTapHighlightColor: 'rgba(0,0,0,0)',\n\n backgroundColor: '$switchBackground',\n borderRadius: '$pill',\n position: 'relative',\n '@hover': {\n '&:hover': {\n cursor: 'pointer',\n [`& ${StyledThumb}`]: {\n ...elevationVariants[1],\n },\n },\n },\n '&:focus': {\n outline: '2px solid $switchFocusBorder',\n [`& ${StyledThumb}`]: {\n ...elevationVariants[2],\n },\n },\n '&:disabled': {\n pointerEvents: 'none',\n opacity: 0.38,\n },\n '&[data-state=\"checked\"]': {\n backgroundColor: '$switchActiveBackground',\n },\n\n '&[aria-invalid=\"true\"]:not(:focus)': {\n boxShadow: 'inset 0 0 0 1px $colors$switchInvalidBorder',\n },\n\n variants: {\n size: {\n '1': {\n width: ROOT_WIDTH,\n height: ROOT_HEIGHT,\n m: '$2',\n },\n '2': {\n width: ROOT_WIDTH * LARGE_RATIO,\n height: ROOT_HEIGHT * LARGE_RATIO,\n [`& ${StyledThumb}`]: {\n width: THUMB_DIAMETER * LARGE_RATIO,\n height: THUMB_DIAMETER * LARGE_RATIO,\n transform: `translateX(${LARGE_RATIO * THUMB_GAP})`,\n\n '&[data-state=\"checked\"]': {\n transform: `translateX(${LARGE_RATIO * (ROOT_WIDTH - THUMB_GAP - THUMB_DIAMETER)}px)`,\n },\n },\n },\n },\n },\n defaultVariants: {\n size: '1',\n },\n});\n\nexport type SwitchVariants = VariantProps<typeof StyledSwitch>;\ntype SwitchPrimitiveProps = Omit<React.ComponentProps<typeof SwitchPrimitive.Root>, 'as'>;\nexport type SwitchProps = SwitchPrimitiveProps & SwitchVariants & { css?: CSS };\n\nexport const Switch = React.forwardRef<React.ElementRef<typeof StyledSwitch>, SwitchProps>(\n (\n { id, disabled, 'aria-describedby': ariaDescribedBy, 'aria-invalid': ariaInvalid, ...props },\n forwardedRef,\n ) => {\n const control = useFieldControl({\n id,\n disabled,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n });\n\n return (\n <StyledSwitch\n {...props}\n id={control.id}\n disabled={control.disabled}\n aria-describedby={control['aria-describedby']}\n aria-invalid={control['aria-invalid']}\n ref={forwardedRef}\n >\n <StyledThumb />\n </StyledSwitch>\n );\n },\n);\n"],"mappings":";;;;;;;;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E,IAAI,UAAU,oBAAoB,iBAAiB,gBAAgB,aAAa,GAAG,SACrF,iBACG;CACH,MAAM,UAAUC,qBAAAA,gBAAgB;EAC9B;EACA;EACA,oBAAoB;EACpB,gBAAgB;CAClB,CAAC;CAED,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,cAAD;EACE,GAAI;EACJ,IAAI,QAAQ;EACZ,UAAU,QAAQ;EAClB,oBAAkB,QAAQ;EAC1B,gBAAc,QAAQ;EACtB,KAAK;EAEL,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,aAAD,CAAc,CAAA;CACF,CAAA;AAElB,CACF"}
@@ -1,5 +1,6 @@
1
1
  import { styled } from "../../stitches.config.js";
2
2
  import { elevationVariants } from "../Elevation/Elevation.js";
3
+ import { useFieldControl } from "../Field/FieldContext.js";
3
4
  import React from "react";
4
5
  import { jsx } from "react/jsx-runtime";
5
6
  import * as SwitchPrimitive from "@radix-ui/react-switch";
@@ -51,6 +52,7 @@ var StyledSwitch = styled(SwitchPrimitive.Root, {
51
52
  opacity: .38
52
53
  },
53
54
  "&[data-state=\"checked\"]": { backgroundColor: "$switchActiveBackground" },
55
+ "&[aria-invalid=\"true\"]:not(:focus)": { boxShadow: "inset 0 0 0 1px $colors$switchInvalidBorder" },
54
56
  variants: { size: {
55
57
  "1": {
56
58
  width: ROOT_WIDTH,
@@ -70,11 +72,23 @@ var StyledSwitch = styled(SwitchPrimitive.Root, {
70
72
  } },
71
73
  defaultVariants: { size: "1" }
72
74
  });
73
- var Switch = React.forwardRef((props, forwardedRef) => /* @__PURE__ */ jsx(StyledSwitch, {
74
- ...props,
75
- ref: forwardedRef,
76
- children: /* @__PURE__ */ jsx(StyledThumb, {})
77
- }));
75
+ var Switch = React.forwardRef(({ id, disabled, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, ...props }, forwardedRef) => {
76
+ const control = useFieldControl({
77
+ id,
78
+ disabled,
79
+ "aria-describedby": ariaDescribedBy,
80
+ "aria-invalid": ariaInvalid
81
+ });
82
+ return /* @__PURE__ */ jsx(StyledSwitch, {
83
+ ...props,
84
+ id: control.id,
85
+ disabled: control.disabled,
86
+ "aria-describedby": control["aria-describedby"],
87
+ "aria-invalid": control["aria-invalid"],
88
+ ref: forwardedRef,
89
+ children: /* @__PURE__ */ jsx(StyledThumb, {})
90
+ });
91
+ });
78
92
  export { Switch };
79
93
 
80
94
  //# sourceMappingURL=Switch.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Switch.js","names":[],"sources":["../../../components/Switch/Switch.tsx"],"sourcesContent":["import * as SwitchPrimitive from '@radix-ui/react-switch';\nimport React from 'react';\n\nimport { CSS, styled, VariantProps } from '../../stitches.config';\nimport { elevationVariants } from '../Elevation';\n\n// CONSTANTS\nconst THUMB_DIAMETER = 14; // @FIXME: shouldn't this size be part of theme ?\nconst LARGE_RATIO = 1.5;\nconst THUMB_GAP = 2; // Gap between thumb and background\nconst ROOT_WIDTH = 32;\nconst ROOT_HEIGHT = 18;\n\n// COMPONENTS\nconst StyledThumb = styled(SwitchPrimitive.Thumb, {\n position: 'absolute',\n left: 0,\n width: THUMB_DIAMETER,\n height: THUMB_DIAMETER,\n backgroundColor: '$switchThumb',\n borderRadius: '$round',\n boxShadow: 'rgba(0, 0, 0, 0.3) 0px 0px 1px, rgba(0, 0, 0, 0.2) 0px 1px 2px;',\n transition: 'transform 100ms cubic-bezier(0.22, 1, 0.36, 1)',\n transform: `translateX(${THUMB_GAP}px)`,\n willChange: 'transform',\n\n '&[data-state=\"checked\"]': {\n transform: `translateX(${ROOT_WIDTH - THUMB_GAP - THUMB_DIAMETER}px)`,\n },\n});\n\nconst StyledSwitch = styled(SwitchPrimitive.Root, {\n all: 'unset',\n boxSizing: 'border-box',\n userSelect: 'none',\n '&::before': {\n boxSizing: 'border-box',\n },\n '&::after': {\n boxSizing: 'border-box',\n },\n\n // Reset\n alignItems: 'center',\n display: 'inline-flex',\n justifyContent: 'center',\n lineHeight: '1',\n margin: '0',\n outline: 'none',\n WebkitTapHighlightColor: 'rgba(0,0,0,0)',\n\n backgroundColor: '$switchBackground',\n borderRadius: '$pill',\n position: 'relative',\n '@hover': {\n '&:hover': {\n cursor: 'pointer',\n [`& ${StyledThumb}`]: {\n ...elevationVariants[1],\n },\n },\n },\n '&:focus': {\n outline: '2px solid $switchFocusBorder',\n [`& ${StyledThumb}`]: {\n ...elevationVariants[2],\n },\n },\n '&:disabled': {\n pointerEvents: 'none',\n opacity: 0.38,\n },\n '&[data-state=\"checked\"]': {\n backgroundColor: '$switchActiveBackground',\n },\n\n variants: {\n size: {\n '1': {\n width: ROOT_WIDTH,\n height: ROOT_HEIGHT,\n m: '$2',\n },\n '2': {\n width: ROOT_WIDTH * LARGE_RATIO,\n height: ROOT_HEIGHT * LARGE_RATIO,\n [`& ${StyledThumb}`]: {\n width: THUMB_DIAMETER * LARGE_RATIO,\n height: THUMB_DIAMETER * LARGE_RATIO,\n transform: `translateX(${LARGE_RATIO * THUMB_GAP})`,\n\n '&[data-state=\"checked\"]': {\n transform: `translateX(${LARGE_RATIO * (ROOT_WIDTH - THUMB_GAP - THUMB_DIAMETER)}px)`,\n },\n },\n },\n },\n },\n defaultVariants: {\n size: '1',\n },\n});\n\nexport type SwitchVariants = VariantProps<typeof StyledSwitch>;\ntype SwitchPrimitiveProps = Omit<React.ComponentProps<typeof SwitchPrimitive.Root>, 'as'>;\nexport type SwitchProps = SwitchPrimitiveProps & SwitchVariants & { css?: CSS };\n\nexport const Switch = React.forwardRef<React.ElementRef<typeof StyledSwitch>, SwitchProps>(\n (props, forwardedRef) => (\n <StyledSwitch {...props} ref={forwardedRef}>\n <StyledThumb />\n </StyledSwitch>\n )\n);\n"],"mappings":";;;;;;AAOA,IAAM,iBAAiB;AACvB,IAAM,cAAc;AACpB,IAAM,YAAY;AAClB,IAAM,aAAa;AACnB,IAAM,cAAc;AAGpB,IAAM,cAAc,OAAO,gBAAgB,OAAO;CAChD,UAAU;CACV,MAAM;CACN,OAAO;CACP,QAAQ;CACR,iBAAiB;CACjB,cAAc;CACd,WAAW;CACX,YAAY;CACZ,WAAW,cAAc,UAAU;CACnC,YAAY;CAEZ,6BAA2B,EACzB,WAAW,mBACb;AACF,CAAC;AAED,IAAM,eAAe,OAAO,gBAAgB,MAAM;CAChD,KAAK;CACL,WAAW;CACX,YAAY;CACZ,aAAa,EACX,WAAW,aACb;CACA,YAAY,EACV,WAAW,aACb;CAGA,YAAY;CACZ,SAAS;CACT,gBAAgB;CAChB,YAAY;CACZ,QAAQ;CACR,SAAS;CACT,yBAAyB;CAEzB,iBAAiB;CACjB,cAAc;CACd,UAAU;CACV,UAAU,EACR,WAAW;EACT,QAAQ;GACP,KAAK,gBAAgB,EACpB,GAAG,kBAAkB,GACvB;CACF,EACF;CACA,WAAW;EACT,SAAS;GACR,KAAK,gBAAgB,EACpB,GAAG,kBAAkB,GACvB;CACF;CACA,cAAc;EACZ,eAAe;EACf,SAAS;CACX;CACA,6BAA2B,EACzB,iBAAiB,0BACnB;CAEA,UAAU,EACR,MAAM;EACJ,KAAK;GACH,OAAO;GACP,QAAQ;GACR,GAAG;EACL;EACA,KAAK;GACH,OAAO,aAAa;GACpB,QAAQ,cAAc;IACrB,KAAK,gBAAgB;IACpB,OAAO,iBAAiB;IACxB,QAAQ,iBAAiB;IACzB,WAAW,cAAc,cAAc,UAAU;IAEjD,6BAA2B,EACzB,WAAW,cAAc,cAAe,GAAyC,KACnF;GACF;EACF;CACF,EACF;CACA,iBAAiB,EACf,MAAM,IACR;AACF,CAAC;AAMD,IAAa,SAAS,MAAM,YACzB,OAAO,iBACN,oBAAC,cAAD;CAAc,GAAI;CAAO,KAAK;CAC5B,UAAA,oBAAC,aAAD,CAAc,CAAA;AACF,CAAA,CAElB"}
1
+ {"version":3,"file":"Switch.js","names":[],"sources":["../../../components/Switch/Switch.tsx"],"sourcesContent":["import * as SwitchPrimitive from '@radix-ui/react-switch';\nimport React from 'react';\n\nimport { CSS, styled, VariantProps } from '../../stitches.config';\nimport { elevationVariants } from '../Elevation';\nimport { useFieldControl } from '../Field/FieldContext';\n\n// CONSTANTS\nconst THUMB_DIAMETER = 14; // @FIXME: shouldn't this size be part of theme ?\nconst LARGE_RATIO = 1.5;\nconst THUMB_GAP = 2; // Gap between thumb and background\nconst ROOT_WIDTH = 32;\nconst ROOT_HEIGHT = 18;\n\n// COMPONENTS\nconst StyledThumb = styled(SwitchPrimitive.Thumb, {\n position: 'absolute',\n left: 0,\n width: THUMB_DIAMETER,\n height: THUMB_DIAMETER,\n backgroundColor: '$switchThumb',\n borderRadius: '$round',\n boxShadow: 'rgba(0, 0, 0, 0.3) 0px 0px 1px, rgba(0, 0, 0, 0.2) 0px 1px 2px;',\n transition: 'transform 100ms cubic-bezier(0.22, 1, 0.36, 1)',\n transform: `translateX(${THUMB_GAP}px)`,\n willChange: 'transform',\n\n '&[data-state=\"checked\"]': {\n transform: `translateX(${ROOT_WIDTH - THUMB_GAP - THUMB_DIAMETER}px)`,\n },\n});\n\nconst StyledSwitch = styled(SwitchPrimitive.Root, {\n all: 'unset',\n boxSizing: 'border-box',\n userSelect: 'none',\n '&::before': {\n boxSizing: 'border-box',\n },\n '&::after': {\n boxSizing: 'border-box',\n },\n\n // Reset\n alignItems: 'center',\n display: 'inline-flex',\n justifyContent: 'center',\n lineHeight: '1',\n margin: '0',\n outline: 'none',\n WebkitTapHighlightColor: 'rgba(0,0,0,0)',\n\n backgroundColor: '$switchBackground',\n borderRadius: '$pill',\n position: 'relative',\n '@hover': {\n '&:hover': {\n cursor: 'pointer',\n [`& ${StyledThumb}`]: {\n ...elevationVariants[1],\n },\n },\n },\n '&:focus': {\n outline: '2px solid $switchFocusBorder',\n [`& ${StyledThumb}`]: {\n ...elevationVariants[2],\n },\n },\n '&:disabled': {\n pointerEvents: 'none',\n opacity: 0.38,\n },\n '&[data-state=\"checked\"]': {\n backgroundColor: '$switchActiveBackground',\n },\n\n '&[aria-invalid=\"true\"]:not(:focus)': {\n boxShadow: 'inset 0 0 0 1px $colors$switchInvalidBorder',\n },\n\n variants: {\n size: {\n '1': {\n width: ROOT_WIDTH,\n height: ROOT_HEIGHT,\n m: '$2',\n },\n '2': {\n width: ROOT_WIDTH * LARGE_RATIO,\n height: ROOT_HEIGHT * LARGE_RATIO,\n [`& ${StyledThumb}`]: {\n width: THUMB_DIAMETER * LARGE_RATIO,\n height: THUMB_DIAMETER * LARGE_RATIO,\n transform: `translateX(${LARGE_RATIO * THUMB_GAP})`,\n\n '&[data-state=\"checked\"]': {\n transform: `translateX(${LARGE_RATIO * (ROOT_WIDTH - THUMB_GAP - THUMB_DIAMETER)}px)`,\n },\n },\n },\n },\n },\n defaultVariants: {\n size: '1',\n },\n});\n\nexport type SwitchVariants = VariantProps<typeof StyledSwitch>;\ntype SwitchPrimitiveProps = Omit<React.ComponentProps<typeof SwitchPrimitive.Root>, 'as'>;\nexport type SwitchProps = SwitchPrimitiveProps & SwitchVariants & { css?: CSS };\n\nexport const Switch = React.forwardRef<React.ElementRef<typeof StyledSwitch>, SwitchProps>(\n (\n { id, disabled, 'aria-describedby': ariaDescribedBy, 'aria-invalid': ariaInvalid, ...props },\n forwardedRef,\n ) => {\n const control = useFieldControl({\n id,\n disabled,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n });\n\n return (\n <StyledSwitch\n {...props}\n id={control.id}\n disabled={control.disabled}\n aria-describedby={control['aria-describedby']}\n aria-invalid={control['aria-invalid']}\n ref={forwardedRef}\n >\n <StyledThumb />\n </StyledSwitch>\n );\n },\n);\n"],"mappings":";;;;;;;AAQA,IAAM,iBAAiB;AACvB,IAAM,cAAc;AACpB,IAAM,YAAY;AAClB,IAAM,aAAa;AACnB,IAAM,cAAc;AAGpB,IAAM,cAAc,OAAO,gBAAgB,OAAO;CAChD,UAAU;CACV,MAAM;CACN,OAAO;CACP,QAAQ;CACR,iBAAiB;CACjB,cAAc;CACd,WAAW;CACX,YAAY;CACZ,WAAW,cAAc,UAAU;CACnC,YAAY;CAEZ,6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B,CACF"}
@@ -8,13 +8,15 @@ var Theme;
8
8
  switchBackground: (0, tinycolor2.default)("black").setAlpha(.2).toHslString(),
9
9
  switchActiveBackground: "$primary",
10
10
  switchFocusBorder: primaryColor.helpers.pickScale(8),
11
- switchThumb: (0, tinycolor2.default)("white").setAlpha(.87).toHslString()
11
+ switchThumb: (0, tinycolor2.default)("white").setAlpha(.87).toHslString(),
12
+ switchInvalidBorder: "$red9"
12
13
  });
13
14
  _Theme.getDark = (primaryColor) => ({
14
15
  switchBackground: (0, tinycolor2.default)("white").setAlpha(.2).toHslString(),
15
16
  switchActiveBackground: "$primary",
16
17
  switchFocusBorder: primaryColor.helpers.pickScale(11),
17
- switchThumb: (0, tinycolor2.default)("black").setAlpha(.87).toHslString()
18
+ switchThumb: (0, tinycolor2.default)("black").setAlpha(.87).toHslString(),
19
+ switchInvalidBorder: "$red9"
18
20
  });
19
21
  })(Theme || (Theme = {}));
20
22
  Object.defineProperty(exports, "Theme", {
@@ -1 +1 @@
1
- {"version":3,"file":"Switch.themes.cjs","names":["tinycolor"],"sources":["../../../components/Switch/Switch.themes.ts"],"sourcesContent":["import { Property } from '@stitches/react/types/css';\nimport tinycolor from 'tinycolor2';\n\nimport { ColorInfo } from '../../utils/getPrimaryColorInfo';\n\nexport namespace Theme {\n type Colors = {\n switchBackground: Property.Color;\n switchActiveBackground: Property.Color;\n switchFocusBorder: Property.Color;\n switchThumb: Property.Color;\n };\n\n type Factory = (primaryColor: ColorInfo) => Colors;\n\n export const getLight: Factory = (primaryColor) => ({\n switchBackground: tinycolor('black').setAlpha(0.2).toHslString(),\n switchActiveBackground: '$primary',\n switchFocusBorder: primaryColor.helpers.pickScale(8),\n switchThumb: tinycolor('white').setAlpha(0.87).toHslString(),\n });\n\n export const getDark: Factory = (primaryColor) => ({\n switchBackground: tinycolor('white').setAlpha(0.2).toHslString(),\n switchActiveBackground: '$primary',\n switchFocusBorder: primaryColor.helpers.pickScale(11),\n switchThumb: tinycolor('black').setAlpha(0.87).toHslString(),\n });\n}\n"],"mappings":";;;;AAKO,IAAU;CAAV,SAAA,QAAA;CAUQ,OAAA,YAAqB,kBAAkB;EAClD,mBAAA,GAAkBA,WAAAA,QAAAA,CAAU,OAAO,CAAC,CAAC,SAAS,EAAG,CAAC,CAAC,YAAY;EAC/D,wBAAwB;EACxB,mBAAmB,aAAa,QAAQ,UAAU,CAAC;EACnD,cAAA,GAAaA,WAAAA,QAAAA,CAAU,OAAO,CAAC,CAAC,SAAS,GAAI,CAAC,CAAC,YAAY;CAC7D;CAEa,OAAA,WAAoB,kBAAkB;EACjD,mBAAA,GAAkBA,WAAAA,QAAAA,CAAU,OAAO,CAAC,CAAC,SAAS,EAAG,CAAC,CAAC,YAAY;EAC/D,wBAAwB;EACxB,mBAAmB,aAAa,QAAQ,UAAU,EAAE;EACpD,cAAA,GAAaA,WAAAA,QAAAA,CAAU,OAAO,CAAC,CAAC,SAAS,GAAI,CAAC,CAAC,YAAY;CAC7D;AACD,EAAA,CAAA,UAAA,QAAA,CAAA,EAAD"}
1
+ {"version":3,"file":"Switch.themes.cjs","names":["tinycolor"],"sources":["../../../components/Switch/Switch.themes.ts"],"sourcesContent":["import { Property } from '@stitches/react/types/css';\nimport tinycolor from 'tinycolor2';\n\nimport { ColorInfo } from '../../utils/getPrimaryColorInfo';\n\nexport namespace Theme {\n type Colors = {\n switchBackground: Property.Color;\n switchActiveBackground: Property.Color;\n switchFocusBorder: Property.Color;\n switchThumb: Property.Color;\n switchInvalidBorder: Property.Color;\n };\n\n type Factory = (primaryColor: ColorInfo) => Colors;\n\n export const getLight: Factory = (primaryColor) => ({\n switchBackground: tinycolor('black').setAlpha(0.2).toHslString(),\n switchActiveBackground: '$primary',\n switchFocusBorder: primaryColor.helpers.pickScale(8),\n switchThumb: tinycolor('white').setAlpha(0.87).toHslString(),\n switchInvalidBorder: '$red9',\n });\n\n export const getDark: Factory = (primaryColor) => ({\n switchBackground: tinycolor('white').setAlpha(0.2).toHslString(),\n switchActiveBackground: '$primary',\n switchFocusBorder: primaryColor.helpers.pickScale(11),\n switchThumb: tinycolor('black').setAlpha(0.87).toHslString(),\n switchInvalidBorder: '$red9',\n });\n}\n"],"mappings":";;;;AAKO,IAAU;CAAV,SAAA,QAAA;CAWQ,OAAA,YAAqB,kBAAkB;EAClD,mBAAA,GAAkBA,WAAAA,QAAAA,CAAU,OAAO,CAAC,CAAC,SAAS,EAAG,CAAC,CAAC,YAAY;EAC/D,wBAAwB;EACxB,mBAAmB,aAAa,QAAQ,UAAU,CAAC;EACnD,cAAA,GAAaA,WAAAA,QAAAA,CAAU,OAAO,CAAC,CAAC,SAAS,GAAI,CAAC,CAAC,YAAY;EAC3D,qBAAqB;CACvB;CAEa,OAAA,WAAoB,kBAAkB;EACjD,mBAAA,GAAkBA,WAAAA,QAAAA,CAAU,OAAO,CAAC,CAAC,SAAS,EAAG,CAAC,CAAC,YAAY;EAC/D,wBAAwB;EACxB,mBAAmB,aAAa,QAAQ,UAAU,EAAE;EACpD,cAAA,GAAaA,WAAAA,QAAAA,CAAU,OAAO,CAAC,CAAC,SAAS,GAAI,CAAC,CAAC,YAAY;EAC3D,qBAAqB;CACvB;AACD,EAAA,CAAA,UAAA,QAAA,CAAA,EAAD"}
@@ -6,13 +6,15 @@ var Theme;
6
6
  switchBackground: tinycolor("black").setAlpha(.2).toHslString(),
7
7
  switchActiveBackground: "$primary",
8
8
  switchFocusBorder: primaryColor.helpers.pickScale(8),
9
- switchThumb: tinycolor("white").setAlpha(.87).toHslString()
9
+ switchThumb: tinycolor("white").setAlpha(.87).toHslString(),
10
+ switchInvalidBorder: "$red9"
10
11
  });
11
12
  _Theme.getDark = (primaryColor) => ({
12
13
  switchBackground: tinycolor("white").setAlpha(.2).toHslString(),
13
14
  switchActiveBackground: "$primary",
14
15
  switchFocusBorder: primaryColor.helpers.pickScale(11),
15
- switchThumb: tinycolor("black").setAlpha(.87).toHslString()
16
+ switchThumb: tinycolor("black").setAlpha(.87).toHslString(),
17
+ switchInvalidBorder: "$red9"
16
18
  });
17
19
  })(Theme || (Theme = {}));
18
20
  export { Theme };
@@ -1 +1 @@
1
- {"version":3,"file":"Switch.themes.js","names":[],"sources":["../../../components/Switch/Switch.themes.ts"],"sourcesContent":["import { Property } from '@stitches/react/types/css';\nimport tinycolor from 'tinycolor2';\n\nimport { ColorInfo } from '../../utils/getPrimaryColorInfo';\n\nexport namespace Theme {\n type Colors = {\n switchBackground: Property.Color;\n switchActiveBackground: Property.Color;\n switchFocusBorder: Property.Color;\n switchThumb: Property.Color;\n };\n\n type Factory = (primaryColor: ColorInfo) => Colors;\n\n export const getLight: Factory = (primaryColor) => ({\n switchBackground: tinycolor('black').setAlpha(0.2).toHslString(),\n switchActiveBackground: '$primary',\n switchFocusBorder: primaryColor.helpers.pickScale(8),\n switchThumb: tinycolor('white').setAlpha(0.87).toHslString(),\n });\n\n export const getDark: Factory = (primaryColor) => ({\n switchBackground: tinycolor('white').setAlpha(0.2).toHslString(),\n switchActiveBackground: '$primary',\n switchFocusBorder: primaryColor.helpers.pickScale(11),\n switchThumb: tinycolor('black').setAlpha(0.87).toHslString(),\n });\n}\n"],"mappings":";;AAKO,IAAU;CAAV,SAAA,QAAA;CAUQ,OAAA,YAAqB,kBAAkB;EAClD,kBAAkB,UAAU,OAAO,CAAC,CAAC,SAAS,EAAG,CAAC,CAAC,YAAY;EAC/D,wBAAwB;EACxB,mBAAmB,aAAa,QAAQ,UAAU,CAAC;EACnD,aAAa,UAAU,OAAO,CAAC,CAAC,SAAS,GAAI,CAAC,CAAC,YAAY;CAC7D;CAEa,OAAA,WAAoB,kBAAkB;EACjD,kBAAkB,UAAU,OAAO,CAAC,CAAC,SAAS,EAAG,CAAC,CAAC,YAAY;EAC/D,wBAAwB;EACxB,mBAAmB,aAAa,QAAQ,UAAU,EAAE;EACpD,aAAa,UAAU,OAAO,CAAC,CAAC,SAAS,GAAI,CAAC,CAAC,YAAY;CAC7D;AACD,EAAA,CAAA,UAAA,QAAA,CAAA,EAAD"}
1
+ {"version":3,"file":"Switch.themes.js","names":[],"sources":["../../../components/Switch/Switch.themes.ts"],"sourcesContent":["import { Property } from '@stitches/react/types/css';\nimport tinycolor from 'tinycolor2';\n\nimport { ColorInfo } from '../../utils/getPrimaryColorInfo';\n\nexport namespace Theme {\n type Colors = {\n switchBackground: Property.Color;\n switchActiveBackground: Property.Color;\n switchFocusBorder: Property.Color;\n switchThumb: Property.Color;\n switchInvalidBorder: Property.Color;\n };\n\n type Factory = (primaryColor: ColorInfo) => Colors;\n\n export const getLight: Factory = (primaryColor) => ({\n switchBackground: tinycolor('black').setAlpha(0.2).toHslString(),\n switchActiveBackground: '$primary',\n switchFocusBorder: primaryColor.helpers.pickScale(8),\n switchThumb: tinycolor('white').setAlpha(0.87).toHslString(),\n switchInvalidBorder: '$red9',\n });\n\n export const getDark: Factory = (primaryColor) => ({\n switchBackground: tinycolor('white').setAlpha(0.2).toHslString(),\n switchActiveBackground: '$primary',\n switchFocusBorder: primaryColor.helpers.pickScale(11),\n switchThumb: tinycolor('black').setAlpha(0.87).toHslString(),\n switchInvalidBorder: '$red9',\n });\n}\n"],"mappings":";;AAKO,IAAU;CAAV,SAAA,QAAA;CAWQ,OAAA,YAAqB,kBAAkB;EAClD,kBAAkB,UAAU,OAAO,CAAC,CAAC,SAAS,EAAG,CAAC,CAAC,YAAY;EAC/D,wBAAwB;EACxB,mBAAmB,aAAa,QAAQ,UAAU,CAAC;EACnD,aAAa,UAAU,OAAO,CAAC,CAAC,SAAS,GAAI,CAAC,CAAC,YAAY;EAC3D,qBAAqB;CACvB;CAEa,OAAA,WAAoB,kBAAkB;EACjD,kBAAkB,UAAU,OAAO,CAAC,CAAC,SAAS,EAAG,CAAC,CAAC,YAAY;EAC/D,wBAAwB;EACxB,mBAAmB,aAAa,QAAQ,UAAU,EAAE;EACpD,aAAa,UAAU,OAAO,CAAC,CAAC,SAAS,GAAI,CAAC,CAAC,YAAY;EAC3D,qBAAqB;CACvB;AACD,EAAA,CAAA,UAAA,QAAA,CAAA,EAAD"}
@@ -8,14 +8,14 @@ var Theme;
8
8
  textSubtle: (0, tinycolor2.default)("black").setAlpha(.51).toHslString(),
9
9
  textDefault: (0, tinycolor2.default)("black").setAlpha(.74).toHslString(),
10
10
  textContrast: "black",
11
- textInvalid: "$red9",
11
+ textInvalid: "$red11",
12
12
  textRed: "$red10"
13
13
  });
14
14
  _Theme.getDark = () => ({
15
15
  textSubtle: (0, tinycolor2.default)("white").setAlpha(.51).toHslString(),
16
16
  textDefault: (0, tinycolor2.default)("white").setAlpha(.74).toHslString(),
17
17
  textContrast: "white",
18
- textInvalid: "$red9",
18
+ textInvalid: "$red11",
19
19
  textRed: "$red10"
20
20
  });
21
21
  })(Theme || (Theme = {}));
@@ -1 +1 @@
1
- {"version":3,"file":"Text.themes.cjs","names":["tinycolor"],"sources":["../../../components/Text/Text.themes.ts"],"sourcesContent":["import { Property } from '@stitches/react/types/css';\nimport tinycolor from 'tinycolor2';\n\nimport { ColorInfo } from '../../utils/getPrimaryColorInfo';\n\nexport namespace Theme {\n type Colors = {\n textSubtle: Property.Color;\n textDefault: Property.Color;\n textContrast: Property.Color;\n textInvalid: Property.Color;\n textRed: Property.Color;\n };\n\n type Factory = (primaryColor: ColorInfo) => Colors;\n\n export const getLight: Factory = () => ({\n textSubtle: tinycolor('black').setAlpha(0.51).toHslString(),\n textDefault: tinycolor('black').setAlpha(0.74).toHslString(),\n textContrast: 'black',\n textInvalid: '$red9',\n textRed: '$red10',\n });\n\n export const getDark: Factory = () => ({\n textSubtle: tinycolor('white').setAlpha(0.51).toHslString(),\n textDefault: tinycolor('white').setAlpha(0.74).toHslString(),\n textContrast: 'white',\n textInvalid: '$red9',\n textRed: '$red10',\n });\n}\n"],"mappings":";;;;AAKO,IAAU;CAAV,SAAA,QAAA;CAWQ,OAAA,kBAA2B;EACtC,aAAA,GAAYA,WAAAA,QAAAA,CAAU,OAAO,CAAC,CAAC,SAAS,GAAI,CAAC,CAAC,YAAY;EAC1D,cAAA,GAAaA,WAAAA,QAAAA,CAAU,OAAO,CAAC,CAAC,SAAS,GAAI,CAAC,CAAC,YAAY;EAC3D,cAAc;EACd,aAAa;EACb,SAAS;CACX;CAEa,OAAA,iBAA0B;EACrC,aAAA,GAAYA,WAAAA,QAAAA,CAAU,OAAO,CAAC,CAAC,SAAS,GAAI,CAAC,CAAC,YAAY;EAC1D,cAAA,GAAaA,WAAAA,QAAAA,CAAU,OAAO,CAAC,CAAC,SAAS,GAAI,CAAC,CAAC,YAAY;EAC3D,cAAc;EACd,aAAa;EACb,SAAS;CACX;AACD,EAAA,CAAA,UAAA,QAAA,CAAA,EAAD"}
1
+ {"version":3,"file":"Text.themes.cjs","names":["tinycolor"],"sources":["../../../components/Text/Text.themes.ts"],"sourcesContent":["import { Property } from '@stitches/react/types/css';\nimport tinycolor from 'tinycolor2';\n\nimport { ColorInfo } from '../../utils/getPrimaryColorInfo';\n\nexport namespace Theme {\n type Colors = {\n textSubtle: Property.Color;\n textDefault: Property.Color;\n textContrast: Property.Color;\n textInvalid: Property.Color;\n textRed: Property.Color;\n };\n\n type Factory = (primaryColor: ColorInfo) => Colors;\n\n export const getLight: Factory = () => ({\n textSubtle: tinycolor('black').setAlpha(0.51).toHslString(),\n textDefault: tinycolor('black').setAlpha(0.74).toHslString(),\n textContrast: 'black',\n textInvalid: '$red11',\n textRed: '$red10',\n });\n\n export const getDark: Factory = () => ({\n textSubtle: tinycolor('white').setAlpha(0.51).toHslString(),\n textDefault: tinycolor('white').setAlpha(0.74).toHslString(),\n textContrast: 'white',\n textInvalid: '$red11',\n textRed: '$red10',\n });\n}\n"],"mappings":";;;;AAKO,IAAU;CAAV,SAAA,QAAA;CAWQ,OAAA,kBAA2B;EACtC,aAAA,GAAYA,WAAAA,QAAAA,CAAU,OAAO,CAAC,CAAC,SAAS,GAAI,CAAC,CAAC,YAAY;EAC1D,cAAA,GAAaA,WAAAA,QAAAA,CAAU,OAAO,CAAC,CAAC,SAAS,GAAI,CAAC,CAAC,YAAY;EAC3D,cAAc;EACd,aAAa;EACb,SAAS;CACX;CAEa,OAAA,iBAA0B;EACrC,aAAA,GAAYA,WAAAA,QAAAA,CAAU,OAAO,CAAC,CAAC,SAAS,GAAI,CAAC,CAAC,YAAY;EAC1D,cAAA,GAAaA,WAAAA,QAAAA,CAAU,OAAO,CAAC,CAAC,SAAS,GAAI,CAAC,CAAC,YAAY;EAC3D,cAAc;EACd,aAAa;EACb,SAAS;CACX;AACD,EAAA,CAAA,UAAA,QAAA,CAAA,EAAD"}
@@ -6,14 +6,14 @@ var Theme;
6
6
  textSubtle: tinycolor("black").setAlpha(.51).toHslString(),
7
7
  textDefault: tinycolor("black").setAlpha(.74).toHslString(),
8
8
  textContrast: "black",
9
- textInvalid: "$red9",
9
+ textInvalid: "$red11",
10
10
  textRed: "$red10"
11
11
  });
12
12
  _Theme.getDark = () => ({
13
13
  textSubtle: tinycolor("white").setAlpha(.51).toHslString(),
14
14
  textDefault: tinycolor("white").setAlpha(.74).toHslString(),
15
15
  textContrast: "white",
16
- textInvalid: "$red9",
16
+ textInvalid: "$red11",
17
17
  textRed: "$red10"
18
18
  });
19
19
  })(Theme || (Theme = {}));
@@ -1 +1 @@
1
- {"version":3,"file":"Text.themes.js","names":[],"sources":["../../../components/Text/Text.themes.ts"],"sourcesContent":["import { Property } from '@stitches/react/types/css';\nimport tinycolor from 'tinycolor2';\n\nimport { ColorInfo } from '../../utils/getPrimaryColorInfo';\n\nexport namespace Theme {\n type Colors = {\n textSubtle: Property.Color;\n textDefault: Property.Color;\n textContrast: Property.Color;\n textInvalid: Property.Color;\n textRed: Property.Color;\n };\n\n type Factory = (primaryColor: ColorInfo) => Colors;\n\n export const getLight: Factory = () => ({\n textSubtle: tinycolor('black').setAlpha(0.51).toHslString(),\n textDefault: tinycolor('black').setAlpha(0.74).toHslString(),\n textContrast: 'black',\n textInvalid: '$red9',\n textRed: '$red10',\n });\n\n export const getDark: Factory = () => ({\n textSubtle: tinycolor('white').setAlpha(0.51).toHslString(),\n textDefault: tinycolor('white').setAlpha(0.74).toHslString(),\n textContrast: 'white',\n textInvalid: '$red9',\n textRed: '$red10',\n });\n}\n"],"mappings":";;AAKO,IAAU;CAAV,SAAA,QAAA;CAWQ,OAAA,kBAA2B;EACtC,YAAY,UAAU,OAAO,CAAC,CAAC,SAAS,GAAI,CAAC,CAAC,YAAY;EAC1D,aAAa,UAAU,OAAO,CAAC,CAAC,SAAS,GAAI,CAAC,CAAC,YAAY;EAC3D,cAAc;EACd,aAAa;EACb,SAAS;CACX;CAEa,OAAA,iBAA0B;EACrC,YAAY,UAAU,OAAO,CAAC,CAAC,SAAS,GAAI,CAAC,CAAC,YAAY;EAC1D,aAAa,UAAU,OAAO,CAAC,CAAC,SAAS,GAAI,CAAC,CAAC,YAAY;EAC3D,cAAc;EACd,aAAa;EACb,SAAS;CACX;AACD,EAAA,CAAA,UAAA,QAAA,CAAA,EAAD"}
1
+ {"version":3,"file":"Text.themes.js","names":[],"sources":["../../../components/Text/Text.themes.ts"],"sourcesContent":["import { Property } from '@stitches/react/types/css';\nimport tinycolor from 'tinycolor2';\n\nimport { ColorInfo } from '../../utils/getPrimaryColorInfo';\n\nexport namespace Theme {\n type Colors = {\n textSubtle: Property.Color;\n textDefault: Property.Color;\n textContrast: Property.Color;\n textInvalid: Property.Color;\n textRed: Property.Color;\n };\n\n type Factory = (primaryColor: ColorInfo) => Colors;\n\n export const getLight: Factory = () => ({\n textSubtle: tinycolor('black').setAlpha(0.51).toHslString(),\n textDefault: tinycolor('black').setAlpha(0.74).toHslString(),\n textContrast: 'black',\n textInvalid: '$red11',\n textRed: '$red10',\n });\n\n export const getDark: Factory = () => ({\n textSubtle: tinycolor('white').setAlpha(0.51).toHslString(),\n textDefault: tinycolor('white').setAlpha(0.74).toHslString(),\n textContrast: 'white',\n textInvalid: '$red11',\n textRed: '$red10',\n });\n}\n"],"mappings":";;AAKO,IAAU;CAAV,SAAA,QAAA;CAWQ,OAAA,kBAA2B;EACtC,YAAY,UAAU,OAAO,CAAC,CAAC,SAAS,GAAI,CAAC,CAAC,YAAY;EAC1D,aAAa,UAAU,OAAO,CAAC,CAAC,SAAS,GAAI,CAAC,CAAC,YAAY;EAC3D,cAAc;EACd,aAAa;EACb,SAAS;CACX;CAEa,OAAA,iBAA0B;EACrC,YAAY,UAAU,OAAO,CAAC,CAAC,SAAS,GAAI,CAAC,CAAC,YAAY;EAC1D,aAAa,UAAU,OAAO,CAAC,CAAC,SAAS,GAAI,CAAC,CAAC,YAAY;EAC3D,cAAc;EACd,aAAa;EACb,SAAS;CACX;AACD,EAAA,CAAA,UAAA,QAAA,CAAA,EAAD"}
@@ -0,0 +1,36 @@
1
+ const require_cssProps = require("../../styles/cssProps.cjs");
2
+ const require_themeContext = require("../../styles/themeContext.cjs");
3
+ const require_Text_vanilla_css = require("./Text.vanilla.css.cjs");
4
+ let react = require("react");
5
+ let _vanilla_extract_dynamic = require("@vanilla-extract/dynamic");
6
+ let react_jsx_runtime = require("react/jsx-runtime");
7
+ // components/Text/Text.vanilla.tsx
8
+ var TextVanillaComponentImpl = (0, react.forwardRef)(({ as, className, css, style, size, weight, variant, gradient, transform, noWrap, ...props }, ref) => {
9
+ const Component = as || "span";
10
+ const { colors } = require_themeContext.useVanillaExtractTheme();
11
+ const { style: cssStyles, vars } = require_cssProps.processCSSProp(css, colors);
12
+ const mergedStyles = {
13
+ ...cssStyles,
14
+ ...style,
15
+ ...(0, _vanilla_extract_dynamic.assignInlineVars)(vars)
16
+ };
17
+ const recipeClass = require_Text_vanilla_css.textRecipe({
18
+ size,
19
+ weight,
20
+ variant,
21
+ gradient,
22
+ transform,
23
+ noWrap
24
+ });
25
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Component, {
26
+ ref,
27
+ className: `${recipeClass} ${className || ""}`.trim(),
28
+ style: mergedStyles,
29
+ ...props
30
+ });
31
+ });
32
+ TextVanillaComponentImpl.displayName = "TextVanilla";
33
+ var TextVanilla = TextVanillaComponentImpl;
34
+ exports.TextVanilla = TextVanilla;
35
+
36
+ //# sourceMappingURL=Text.vanilla.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Text.vanilla.cjs","names":["forwardRef","useVanillaExtractTheme","processCSSProp","assignInlineVars","textRecipe"],"sources":["../../../components/Text/Text.vanilla.tsx"],"sourcesContent":["import { assignInlineVars } from '@vanilla-extract/dynamic';\nimport { RecipeVariants } from '@vanilla-extract/recipes';\nimport { ElementType, forwardRef } from 'react';\n\nimport { CSSProps, processCSSProp } from '../../styles/cssProps';\nimport {\n PolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef,\n} from '../../styles/polymorphic';\nimport { useVanillaExtractTheme } from '../../styles/themeContext';\nimport { textRecipe } from './Text.vanilla.css';\n\ntype TextRecipeVariants = RecipeVariants<typeof textRecipe>;\n\ninterface TextOwnProps extends Omit<TextRecipeVariants, never>, CSSProps {}\n\nexport type TextVanillaProps<C extends ElementType = 'span'> = PolymorphicComponentProps<\n C,\n TextOwnProps\n>;\n\ntype TextComponent = PolymorphicComponent<'span', TextVanillaProps<ElementType>>;\n\nconst TextVanillaComponentImpl = forwardRef(\n <C extends ElementType = 'span'>(\n {\n as,\n className,\n css,\n style,\n size,\n weight,\n variant,\n gradient,\n transform,\n noWrap,\n ...props\n }: TextVanillaProps<C>,\n ref?: PolymorphicRef<C>,\n ) => {\n const Component = as || 'span';\n\n const { colors } = useVanillaExtractTheme();\n\n const { style: cssStyles, vars } = processCSSProp(css, colors);\n\n const mergedStyles = {\n ...cssStyles,\n ...style,\n ...assignInlineVars(vars),\n };\n\n const recipeClass = textRecipe({ size, weight, variant, gradient, transform, noWrap });\n\n return (\n <Component\n ref={ref}\n className={`${recipeClass} ${className || ''}`.trim()}\n style={mergedStyles}\n {...props}\n />\n );\n },\n);\n\nTextVanillaComponentImpl.displayName = 'TextVanilla';\n\nexport const TextVanilla = TextVanillaComponentImpl as TextComponent;\n"],"mappings":";;;;;;;AAwBA,IAAM,4BAAA,GAA2BA,MAAAA,WAAAA,EAE7B,EACE,IACA,WACA,KACA,OACA,MACA,QACA,SACA,UACA,WACA,QACA,GAAG,SAEL,QACG;CACH,MAAM,YAAY,MAAM;CAExB,MAAM,EAAE,WAAWC,qBAAAA,uBAAuB;CAE1C,MAAM,EAAE,OAAO,WAAW,SAASC,iBAAAA,eAAe,KAAK,MAAM;CAE7D,MAAM,eAAe;EACnB,GAAG;EACH,GAAG;EACH,IAAA,GAAGC,yBAAAA,iBAAAA,CAAiB,IAAI;CAC1B;CAEA,MAAM,cAAcC,yBAAAA,WAAW;EAAE;EAAM;EAAQ;EAAS;EAAU;EAAW;CAAO,CAAC;CAErF,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,WAAD;EACO;EACL,WAAW,GAAG,YAAY,GAAG,aAAa,KAAK,KAAK;EACpD,OAAO;EACP,GAAI;CACL,CAAA;AAEL,CACF;AAEA,yBAAyB,cAAc;AAEvC,IAAa,cAAc"}