@traefik-labs/faency 13.1.1 → 13.3.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/Accordion/Accordion.cjs +24 -18
- package/dist/components/Accordion/Accordion.cjs.map +1 -1
- package/dist/components/Accordion/Accordion.js +24 -18
- package/dist/components/Accordion/Accordion.js.map +1 -1
- package/dist/components/AriaTable/AriaTable.cjs +47 -9
- package/dist/components/AriaTable/AriaTable.cjs.map +1 -1
- package/dist/components/AriaTable/AriaTable.js +48 -10
- package/dist/components/AriaTable/AriaTable.js.map +1 -1
- package/dist/components/Checkbox/Checkbox.cjs +15 -2
- package/dist/components/Checkbox/Checkbox.cjs.map +1 -1
- package/dist/components/Checkbox/Checkbox.js +15 -2
- package/dist/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/components/Checkbox/Checkbox.themes.cjs +4 -2
- package/dist/components/Checkbox/Checkbox.themes.cjs.map +1 -1
- package/dist/components/Checkbox/Checkbox.themes.js +4 -2
- package/dist/components/Checkbox/Checkbox.themes.js.map +1 -1
- package/dist/components/DateTimePickerInput/DateTimePickerInput.cjs +1 -1
- package/dist/components/DateTimePickerInput/DateTimePickerInput.cjs.map +1 -1
- package/dist/components/DateTimePickerInput/DateTimePickerInput.js +1 -1
- package/dist/components/DateTimePickerInput/DateTimePickerInput.js.map +1 -1
- package/dist/components/Dialog/Dialog.cjs +4 -3
- package/dist/components/Dialog/Dialog.cjs.map +1 -1
- package/dist/components/Dialog/Dialog.js +4 -3
- package/dist/components/Dialog/Dialog.js.map +1 -1
- package/dist/components/Field/Field.cjs +91 -0
- package/dist/components/Field/Field.cjs.map +1 -0
- package/dist/components/Field/Field.js +89 -0
- package/dist/components/Field/Field.js.map +1 -0
- package/dist/components/Field/Field.vanilla.cjs +95 -0
- package/dist/components/Field/Field.vanilla.cjs.map +1 -0
- package/dist/components/Field/Field.vanilla.css.cjs +6 -0
- package/dist/components/Field/Field.vanilla.css.cjs.map +1 -0
- package/dist/components/Field/Field.vanilla.css.js +6 -0
- package/dist/components/Field/Field.vanilla.css.js.map +1 -0
- package/dist/components/Field/Field.vanilla.js +93 -0
- package/dist/components/Field/Field.vanilla.js.map +1 -0
- package/dist/components/Field/FieldContext.cjs +136 -0
- package/dist/components/Field/FieldContext.cjs.map +1 -0
- package/dist/components/Field/FieldContext.js +130 -0
- package/dist/components/Field/FieldContext.js.map +1 -0
- package/dist/components/Input/Input.cjs +31 -6
- package/dist/components/Input/Input.cjs.map +1 -1
- package/dist/components/Input/Input.js +31 -6
- package/dist/components/Input/Input.js.map +1 -1
- package/dist/components/Input/Input.vanilla.cjs +17 -4
- package/dist/components/Input/Input.vanilla.cjs.map +1 -1
- package/dist/components/Input/Input.vanilla.css.cjs.map +1 -1
- package/dist/components/Input/Input.vanilla.css.js.map +1 -1
- package/dist/components/Input/Input.vanilla.js +17 -4
- package/dist/components/Input/Input.vanilla.js.map +1 -1
- package/dist/components/Navigation/Navigation.cjs +4 -1
- package/dist/components/Navigation/Navigation.cjs.map +1 -1
- package/dist/components/Navigation/Navigation.js +4 -1
- package/dist/components/Navigation/Navigation.js.map +1 -1
- package/dist/components/Radio/Radio.cjs +21 -1
- package/dist/components/Radio/Radio.cjs.map +1 -1
- package/dist/components/Radio/Radio.js +21 -1
- package/dist/components/Radio/Radio.js.map +1 -1
- package/dist/components/Radio/Radio.themes.cjs +4 -2
- package/dist/components/Radio/Radio.themes.cjs.map +1 -1
- package/dist/components/Radio/Radio.themes.js +4 -2
- package/dist/components/Radio/Radio.themes.js.map +1 -1
- package/dist/components/RadioAccordion/RadioAccordion.cjs +10 -6
- package/dist/components/RadioAccordion/RadioAccordion.cjs.map +1 -1
- package/dist/components/RadioAccordion/RadioAccordion.js +10 -6
- package/dist/components/RadioAccordion/RadioAccordion.js.map +1 -1
- package/dist/components/RowLink/RowLink.cjs +95 -0
- package/dist/components/RowLink/RowLink.cjs.map +1 -0
- package/dist/components/RowLink/RowLink.js +90 -0
- package/dist/components/RowLink/RowLink.js.map +1 -0
- package/dist/components/Select/Select.cjs +33 -4
- package/dist/components/Select/Select.cjs.map +1 -1
- package/dist/components/Select/Select.js +33 -4
- package/dist/components/Select/Select.js.map +1 -1
- package/dist/components/SidePanel/SidePanel.cjs +3 -3
- package/dist/components/SidePanel/SidePanel.cjs.map +1 -1
- package/dist/components/SidePanel/SidePanel.js +3 -3
- package/dist/components/SidePanel/SidePanel.js.map +1 -1
- package/dist/components/Skeleton/Skeleton.cjs +4 -0
- package/dist/components/Skeleton/Skeleton.cjs.map +1 -1
- package/dist/components/Skeleton/Skeleton.js +4 -0
- package/dist/components/Skeleton/Skeleton.js.map +1 -1
- package/dist/components/Skeleton/Skeleton.vanilla.css.cjs.map +1 -1
- package/dist/components/Skeleton/Skeleton.vanilla.css.js.map +1 -1
- package/dist/components/Switch/Switch.cjs +19 -5
- package/dist/components/Switch/Switch.cjs.map +1 -1
- package/dist/components/Switch/Switch.js +19 -5
- package/dist/components/Switch/Switch.js.map +1 -1
- package/dist/components/Switch/Switch.themes.cjs +4 -2
- package/dist/components/Switch/Switch.themes.cjs.map +1 -1
- package/dist/components/Switch/Switch.themes.js +4 -2
- package/dist/components/Switch/Switch.themes.js.map +1 -1
- package/dist/components/Table/ExpandButton.cjs +18 -0
- package/dist/components/Table/ExpandButton.cjs.map +1 -0
- package/dist/components/Table/ExpandButton.js +19 -0
- package/dist/components/Table/ExpandButton.js.map +1 -0
- package/dist/components/Table/Table.cjs +39 -13
- package/dist/components/Table/Table.cjs.map +1 -1
- package/dist/components/Table/Table.js +40 -14
- package/dist/components/Table/Table.js.map +1 -1
- package/dist/components/Text/Text.themes.cjs +2 -2
- package/dist/components/Text/Text.themes.cjs.map +1 -1
- package/dist/components/Text/Text.themes.js +2 -2
- package/dist/components/Text/Text.themes.js.map +1 -1
- package/dist/components/Text/Text.vanilla.cjs +36 -0
- package/dist/components/Text/Text.vanilla.cjs.map +1 -0
- package/dist/components/Text/Text.vanilla.css.cjs +55 -0
- package/dist/components/Text/Text.vanilla.css.cjs.map +1 -0
- package/dist/components/Text/Text.vanilla.css.js +56 -0
- package/dist/components/Text/Text.vanilla.css.js.map +1 -0
- package/dist/components/Text/Text.vanilla.js +36 -0
- package/dist/components/Text/Text.vanilla.js.map +1 -0
- package/dist/components/TextField/TextField.cjs +73 -77
- package/dist/components/TextField/TextField.cjs.map +1 -1
- package/dist/components/TextField/TextField.js +73 -77
- package/dist/components/TextField/TextField.js.map +1 -1
- package/dist/components/TextField/TextField.vanilla.cjs +70 -86
- package/dist/components/TextField/TextField.vanilla.cjs.map +1 -1
- package/dist/components/TextField/TextField.vanilla.css.cjs +10 -0
- package/dist/components/TextField/TextField.vanilla.css.cjs.map +1 -0
- package/dist/components/TextField/TextField.vanilla.css.js +8 -0
- package/dist/components/TextField/TextField.vanilla.css.js.map +1 -0
- package/dist/components/TextField/TextField.vanilla.js +71 -87
- package/dist/components/TextField/TextField.vanilla.js.map +1 -1
- package/dist/components/Textarea/Textarea.cjs +51 -41
- package/dist/components/Textarea/Textarea.cjs.map +1 -1
- package/dist/components/Textarea/Textarea.js +51 -41
- package/dist/components/Textarea/Textarea.js.map +1 -1
- package/dist/components/Textarea/Textarea.vanilla.cjs +49 -49
- package/dist/components/Textarea/Textarea.vanilla.cjs.map +1 -1
- package/dist/components/Textarea/Textarea.vanilla.css.cjs.map +1 -1
- package/dist/components/Textarea/Textarea.vanilla.css.js.map +1 -1
- package/dist/components/Textarea/Textarea.vanilla.js +49 -49
- package/dist/components/Textarea/Textarea.vanilla.js.map +1 -1
- package/dist/faency.css +176 -14
- package/dist/index.cjs +11 -1
- package/dist/index.d.ts +777 -3
- package/dist/index.js +6 -2
- package/dist/styles/themes.css.cjs.map +1 -1
- package/dist/styles/themes.css.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
;/* empty css */
|
|
2
|
+
;/* empty css */
|
|
3
|
+
;/* empty css */
|
|
4
|
+
// components/Text/Text.vanilla.css.ts
|
|
5
|
+
var textRecipe = (0, require("@vanilla-extract/recipes/createRuntimeFn").createRuntimeFn)({
|
|
6
|
+
defaultClassName: "mlb3ql1 mlb3ql0",
|
|
7
|
+
variantClassNames: {
|
|
8
|
+
size: {
|
|
9
|
+
"0": "mlb3ql2",
|
|
10
|
+
"1": "mlb3ql3",
|
|
11
|
+
"2": "mlb3ql4",
|
|
12
|
+
"3": "mlb3ql5",
|
|
13
|
+
"4": "mlb3ql6",
|
|
14
|
+
"5": "mlb3ql7",
|
|
15
|
+
"6": "mlb3ql8",
|
|
16
|
+
"7": "mlb3ql9",
|
|
17
|
+
"8": "mlb3qla",
|
|
18
|
+
"9": "mlb3qlb",
|
|
19
|
+
"10": "mlb3qlc",
|
|
20
|
+
"11": "mlb3qld",
|
|
21
|
+
"12": "mlb3qle",
|
|
22
|
+
inherit: "mlb3qlf"
|
|
23
|
+
},
|
|
24
|
+
weight: {
|
|
25
|
+
light: "mlb3qlg",
|
|
26
|
+
regular: "mlb3qlh",
|
|
27
|
+
medium: "mlb3qli",
|
|
28
|
+
semiBold: "mlb3qlj",
|
|
29
|
+
bold: "mlb3qlk"
|
|
30
|
+
},
|
|
31
|
+
variant: {
|
|
32
|
+
red: "mlb3qll",
|
|
33
|
+
subtle: "mlb3qlm",
|
|
34
|
+
"default": "mlb3qln",
|
|
35
|
+
contrast: "mlb3qlo",
|
|
36
|
+
inherit: "mlb3qlp",
|
|
37
|
+
invalid: "mlb3qlq"
|
|
38
|
+
},
|
|
39
|
+
gradient: { true: "mlb3qlr" },
|
|
40
|
+
transform: {
|
|
41
|
+
uppercase: "mlb3qls",
|
|
42
|
+
capitalize: "mlb3qlt",
|
|
43
|
+
capitalizeWords: "mlb3qlu"
|
|
44
|
+
},
|
|
45
|
+
noWrap: { true: "mlb3qlv" }
|
|
46
|
+
},
|
|
47
|
+
defaultVariants: {
|
|
48
|
+
size: "3",
|
|
49
|
+
variant: "default"
|
|
50
|
+
},
|
|
51
|
+
compoundVariants: []
|
|
52
|
+
});
|
|
53
|
+
exports.textRecipe = textRecipe;
|
|
54
|
+
|
|
55
|
+
//# sourceMappingURL=Text.vanilla.css.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Text.vanilla.css.cjs","names":["_7a468"],"sources":["../../../components/Text/Text.vanilla.css.ts"],"sourcesContent":["import { style } from '@vanilla-extract/css';\nimport { recipe } from '@vanilla-extract/recipes';\n\nimport { tokens } from '../../styles';\nimport {\n colorVariants,\n gradientVariants,\n noWrapVariants,\n sizeVariants,\n transformVariants,\n weightVariants,\n} from '../../styles/textVariants.css';\n\nconst text = style({\n lineHeight: '1',\n margin: '0',\n fontFamily: tokens.fonts.rubik,\n fontVariantNumeric: 'tabular-nums',\n display: 'inline-block',\n});\n\nexport const textRecipe = recipe({\n base: text,\n\n variants: {\n size: sizeVariants,\n weight: weightVariants,\n variant: colorVariants,\n gradient: gradientVariants,\n transform: transformVariants,\n noWrap: noWrapVariants,\n },\n\n defaultVariants: {\n size: '3',\n variant: 'default',\n },\n});\n"],"mappings":""}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/* empty css */
|
|
2
|
+
/* empty css */
|
|
3
|
+
/* empty css */
|
|
4
|
+
import { createRuntimeFn } from "@vanilla-extract/recipes/createRuntimeFn";
|
|
5
|
+
// components/Text/Text.vanilla.css.ts
|
|
6
|
+
var textRecipe = createRuntimeFn({
|
|
7
|
+
defaultClassName: "mlb3ql1 mlb3ql0",
|
|
8
|
+
variantClassNames: {
|
|
9
|
+
size: {
|
|
10
|
+
"0": "mlb3ql2",
|
|
11
|
+
"1": "mlb3ql3",
|
|
12
|
+
"2": "mlb3ql4",
|
|
13
|
+
"3": "mlb3ql5",
|
|
14
|
+
"4": "mlb3ql6",
|
|
15
|
+
"5": "mlb3ql7",
|
|
16
|
+
"6": "mlb3ql8",
|
|
17
|
+
"7": "mlb3ql9",
|
|
18
|
+
"8": "mlb3qla",
|
|
19
|
+
"9": "mlb3qlb",
|
|
20
|
+
"10": "mlb3qlc",
|
|
21
|
+
"11": "mlb3qld",
|
|
22
|
+
"12": "mlb3qle",
|
|
23
|
+
inherit: "mlb3qlf"
|
|
24
|
+
},
|
|
25
|
+
weight: {
|
|
26
|
+
light: "mlb3qlg",
|
|
27
|
+
regular: "mlb3qlh",
|
|
28
|
+
medium: "mlb3qli",
|
|
29
|
+
semiBold: "mlb3qlj",
|
|
30
|
+
bold: "mlb3qlk"
|
|
31
|
+
},
|
|
32
|
+
variant: {
|
|
33
|
+
red: "mlb3qll",
|
|
34
|
+
subtle: "mlb3qlm",
|
|
35
|
+
"default": "mlb3qln",
|
|
36
|
+
contrast: "mlb3qlo",
|
|
37
|
+
inherit: "mlb3qlp",
|
|
38
|
+
invalid: "mlb3qlq"
|
|
39
|
+
},
|
|
40
|
+
gradient: { true: "mlb3qlr" },
|
|
41
|
+
transform: {
|
|
42
|
+
uppercase: "mlb3qls",
|
|
43
|
+
capitalize: "mlb3qlt",
|
|
44
|
+
capitalizeWords: "mlb3qlu"
|
|
45
|
+
},
|
|
46
|
+
noWrap: { true: "mlb3qlv" }
|
|
47
|
+
},
|
|
48
|
+
defaultVariants: {
|
|
49
|
+
size: "3",
|
|
50
|
+
variant: "default"
|
|
51
|
+
},
|
|
52
|
+
compoundVariants: []
|
|
53
|
+
});
|
|
54
|
+
export { textRecipe };
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=Text.vanilla.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Text.vanilla.css.js","names":["_7a468"],"sources":["../../../components/Text/Text.vanilla.css.ts"],"sourcesContent":["import { style } from '@vanilla-extract/css';\nimport { recipe } from '@vanilla-extract/recipes';\n\nimport { tokens } from '../../styles';\nimport {\n colorVariants,\n gradientVariants,\n noWrapVariants,\n sizeVariants,\n transformVariants,\n weightVariants,\n} from '../../styles/textVariants.css';\n\nconst text = style({\n lineHeight: '1',\n margin: '0',\n fontFamily: tokens.fonts.rubik,\n fontVariantNumeric: 'tabular-nums',\n display: 'inline-block',\n});\n\nexport const textRecipe = recipe({\n base: text,\n\n variants: {\n size: sizeVariants,\n weight: weightVariants,\n variant: colorVariants,\n gradient: gradientVariants,\n transform: transformVariants,\n noWrap: noWrapVariants,\n },\n\n defaultVariants: {\n size: '3',\n variant: 'default',\n },\n});\n"],"mappings":""}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { processCSSProp } from "../../styles/cssProps.js";
|
|
2
|
+
import { useVanillaExtractTheme } from "../../styles/themeContext.js";
|
|
3
|
+
import { textRecipe } from "./Text.vanilla.css.js";
|
|
4
|
+
import { forwardRef } from "react";
|
|
5
|
+
import { assignInlineVars } from "@vanilla-extract/dynamic";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
// components/Text/Text.vanilla.tsx
|
|
8
|
+
var TextVanillaComponentImpl = forwardRef(({ as, className, css, style, size, weight, variant, gradient, transform, noWrap, ...props }, ref) => {
|
|
9
|
+
const Component = as || "span";
|
|
10
|
+
const { colors } = useVanillaExtractTheme();
|
|
11
|
+
const { style: cssStyles, vars } = processCSSProp(css, colors);
|
|
12
|
+
const mergedStyles = {
|
|
13
|
+
...cssStyles,
|
|
14
|
+
...style,
|
|
15
|
+
...assignInlineVars(vars)
|
|
16
|
+
};
|
|
17
|
+
const recipeClass = textRecipe({
|
|
18
|
+
size,
|
|
19
|
+
weight,
|
|
20
|
+
variant,
|
|
21
|
+
gradient,
|
|
22
|
+
transform,
|
|
23
|
+
noWrap
|
|
24
|
+
});
|
|
25
|
+
return /* @__PURE__ */ 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
|
+
export { TextVanilla };
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=Text.vanilla.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Text.vanilla.js","names":[],"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,2BAA2B,YAE7B,EACE,IACA,WACA,KACA,OACA,MACA,QACA,SACA,UACA,WACA,QACA,GAAG,SAEL,QACG;CACH,MAAM,YAAY,MAAM;CAExB,MAAM,EAAE,WAAW,uBAAuB;CAE1C,MAAM,EAAE,OAAO,WAAW,SAAS,eAAe,KAAK,MAAM;CAE7D,MAAM,eAAe;EACnB,GAAG;EACH,GAAG;EACH,GAAG,iBAAiB,IAAI;CAC1B;CAEA,MAAM,cAAc,WAAW;EAAE;EAAM;EAAQ;EAAS;EAAU;EAAW;CAAO,CAAC;CAErF,OACE,oBAAC,WAAD;EACO;EACL,WAAW,GAAG,YAAY,GAAG,aAAa,KAAK,KAAK;EACpD,OAAO;EACP,GAAI;CACL,CAAA;AAEL,CACF;AAEA,yBAAyB,cAAc;AAEvC,IAAa,cAAc"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
2
|
const require_stitches_config = require("../../stitches.config.cjs");
|
|
3
|
-
const
|
|
4
|
-
const require_Label = require("../Label/Label.cjs");
|
|
3
|
+
const require_FieldContext = require("../Field/FieldContext.cjs");
|
|
5
4
|
const require_Input = require("../Input/Input.cjs");
|
|
5
|
+
const require_Field = require("../Field/Field.cjs");
|
|
6
6
|
const require_Tooltip = require("../Tooltip/Tooltip.cjs");
|
|
7
7
|
let _radix_ui_react_icons = require("@radix-ui/react-icons");
|
|
8
8
|
let react = require("react");
|
|
@@ -15,42 +15,35 @@ var AdornmentGroup = require_stitches_config.styled("div", {
|
|
|
15
15
|
alignItems: "center"
|
|
16
16
|
});
|
|
17
17
|
var StyledExclamationTriangleIcon = require_stitches_config.styled(_radix_ui_react_icons.ExclamationTriangleIcon, { "& + *": { marginLeft: "$1" } });
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
var AdornmentButton = require_stitches_config.styled("button", {
|
|
19
|
+
appearance: "none",
|
|
20
|
+
background: "none",
|
|
21
|
+
border: "none",
|
|
22
|
+
padding: 0,
|
|
23
|
+
font: "inherit",
|
|
24
|
+
display: "inline-flex",
|
|
25
|
+
alignItems: "center",
|
|
26
|
+
justifyContent: "center",
|
|
27
|
+
borderRadius: "$1",
|
|
28
|
+
color: "inherit",
|
|
29
|
+
"@hover": { "&:hover": { cursor: "pointer" } },
|
|
30
|
+
"&:focus-visible": {
|
|
31
|
+
outline: "2px solid $inputFocusBorder",
|
|
32
|
+
outlineOffset: "1px"
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
var TextField = react.default.forwardRef(({ state, clearable, label: LabelOrComponent, description, error, announceError, id, type, disabled, readOnly, css, ...props }, forwardedRef) => {
|
|
22
36
|
const inputRef = react.default.useRef(null);
|
|
23
37
|
react.default.useImperativeHandle(forwardedRef, () => inputRef.current);
|
|
24
|
-
const
|
|
38
|
+
const outerField = require_FieldContext.useFieldContext();
|
|
25
39
|
const [innerType, setInnerType] = react.default.useState(type);
|
|
26
40
|
const isPasswordVisible = react.default.useMemo(() => innerType !== "password", [innerType]);
|
|
27
|
-
const invalid =
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}, [
|
|
34
|
-
invalid,
|
|
35
|
-
disabled,
|
|
36
|
-
inputHasFocus
|
|
37
|
-
]);
|
|
38
|
-
const LabelNode = react.default.useMemo(() => {
|
|
39
|
-
if (LabelOrComponent === void 0 || LabelOrComponent === null) return null;
|
|
40
|
-
if (typeof LabelOrComponent === "string") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Label.Label, {
|
|
41
|
-
variant: labelVariant,
|
|
42
|
-
htmlFor: id,
|
|
43
|
-
children: LabelOrComponent
|
|
44
|
-
});
|
|
45
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LabelOrComponent, {
|
|
46
|
-
variant: labelVariant,
|
|
47
|
-
htmlFor: id
|
|
48
|
-
});
|
|
49
|
-
}, [
|
|
50
|
-
LabelOrComponent,
|
|
51
|
-
labelVariant,
|
|
52
|
-
id
|
|
53
|
-
]);
|
|
41
|
+
const invalid = state === "invalid" || Boolean(error) || Boolean(outerField?.invalid);
|
|
42
|
+
const renderLabel = react.default.useMemo(() => {
|
|
43
|
+
if (LabelOrComponent === void 0 || LabelOrComponent === null) return;
|
|
44
|
+
if (typeof LabelOrComponent === "string") return LabelOrComponent;
|
|
45
|
+
return (labelProps) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LabelOrComponent, { ...labelProps });
|
|
46
|
+
}, [LabelOrComponent]);
|
|
54
47
|
const isPasswordType = react.default.useMemo(() => type === "password", [type]);
|
|
55
48
|
const typeOrInnerType = react.default.useMemo(() => isPasswordType ? innerType : type, [
|
|
56
49
|
isPasswordType,
|
|
@@ -67,58 +60,61 @@ var TextField = react.default.forwardRef(({ state, clearable, label: LabelOrComp
|
|
|
67
60
|
invalid,
|
|
68
61
|
isPasswordType
|
|
69
62
|
]);
|
|
70
|
-
const clearDisabled =
|
|
63
|
+
const clearDisabled = readOnly || disabled || Boolean(outerField?.disabled);
|
|
71
64
|
const handleClear = react.default.useCallback(() => {
|
|
72
65
|
const { current } = inputRef;
|
|
73
|
-
if (current)
|
|
66
|
+
if (current) {
|
|
67
|
+
(Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value")?.set)?.call(current, "");
|
|
68
|
+
current.dispatchEvent(new Event("input", { bubbles: true }));
|
|
69
|
+
current.focus();
|
|
70
|
+
}
|
|
74
71
|
}, [inputRef]);
|
|
75
|
-
const handleFocus = react.default.useCallback((e) => {
|
|
76
|
-
if (onFocus) onFocus(e);
|
|
77
|
-
setInputHasFocus(true);
|
|
78
|
-
}, [onFocus, setInputHasFocus]);
|
|
79
|
-
const handleBlur = react.default.useCallback((e) => {
|
|
80
|
-
if (onBlur) onBlur(e);
|
|
81
|
-
setInputHasFocus(false);
|
|
82
|
-
}, [onBlur, setInputHasFocus]);
|
|
83
72
|
const togglePasswordVisibility = react.default.useCallback(() => {
|
|
84
73
|
setInnerType((prevInnerType) => prevInnerType === "password" ? void 0 : "password");
|
|
85
74
|
}, [setInnerType]);
|
|
86
75
|
const EndAdornmentWrapper = hasAdornmentGroup ? AdornmentGroup : react.default.Fragment;
|
|
87
|
-
const PasswordVisibilityToggleIcon = isPasswordVisible ?
|
|
76
|
+
const PasswordVisibilityToggleIcon = isPasswordVisible ? _radix_ui_react_icons.EyeClosedIcon : _radix_ui_react_icons.EyeOpenIcon;
|
|
88
77
|
const passwordAction = react.default.useMemo(() => isPasswordVisible ? "Hide password" : "Show password", [isPasswordVisible]);
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PasswordVisibilityToggleIcon, {
|
|
102
|
-
"aria-label": passwordAction,
|
|
103
|
-
onClick: togglePasswordVisibility
|
|
104
|
-
})
|
|
105
|
-
}),
|
|
106
|
-
clearable && !clearDisabled && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Tooltip.Tooltip, {
|
|
107
|
-
content: "Clear",
|
|
108
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledCrossCircledIcon, {
|
|
109
|
-
"aria-label": "Clear",
|
|
110
|
-
onClick: handleClear
|
|
111
|
-
})
|
|
78
|
+
const input = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Input.Input, {
|
|
79
|
+
id,
|
|
80
|
+
ref: inputRef,
|
|
81
|
+
endAdornment: hasInnerAdornment && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(EndAdornmentWrapper, { children: [
|
|
82
|
+
invalid && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyledExclamationTriangleIcon, { "aria-hidden": true }),
|
|
83
|
+
isPasswordType && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Tooltip.Tooltip, {
|
|
84
|
+
content: passwordAction,
|
|
85
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AdornmentButton, {
|
|
86
|
+
type: "button",
|
|
87
|
+
"aria-label": passwordAction,
|
|
88
|
+
onClick: togglePasswordVisibility,
|
|
89
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PasswordVisibilityToggleIcon, { "aria-hidden": true })
|
|
112
90
|
})
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
91
|
+
}),
|
|
92
|
+
clearable && !clearDisabled && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Tooltip.Tooltip, {
|
|
93
|
+
content: "Clear",
|
|
94
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AdornmentButton, {
|
|
95
|
+
type: "button",
|
|
96
|
+
"aria-label": "Clear",
|
|
97
|
+
onClick: handleClear,
|
|
98
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_radix_ui_react_icons.CrossCircledIcon, { "aria-hidden": true })
|
|
99
|
+
})
|
|
100
|
+
})
|
|
101
|
+
] }),
|
|
102
|
+
state,
|
|
103
|
+
type: typeOrInnerType,
|
|
104
|
+
disabled,
|
|
105
|
+
readOnly,
|
|
106
|
+
...props
|
|
107
|
+
});
|
|
108
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Field.Field, {
|
|
109
|
+
id,
|
|
110
|
+
label: renderLabel,
|
|
111
|
+
description,
|
|
112
|
+
error,
|
|
113
|
+
announceError,
|
|
114
|
+
invalid: state === "invalid",
|
|
115
|
+
disabled,
|
|
116
|
+
css,
|
|
117
|
+
children: input
|
|
122
118
|
});
|
|
123
119
|
});
|
|
124
120
|
exports.TextField = TextField;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextField.cjs","names":["styled","ExclamationTriangleIcon","
|
|
1
|
+
{"version":3,"file":"TextField.cjs","names":["styled","ExclamationTriangleIcon","React","useFieldContext","EyeClosedIcon","EyeOpenIcon","Input","Tooltip","CrossCircledIcon","Field"],"sources":["../../../components/TextField/TextField.tsx"],"sourcesContent":["import {\n CrossCircledIcon,\n ExclamationTriangleIcon,\n EyeClosedIcon,\n EyeOpenIcon,\n} from '@radix-ui/react-icons';\nimport React from 'react';\n\nimport { styled } from '../../stitches.config';\nimport { Field } from '../Field/Field';\nimport { FieldLabelProps, useFieldContext } from '../Field/FieldContext';\nimport { Input, InputHandle, InputProps, InputVariants } from '../Input';\nimport { Tooltip } from '../Tooltip';\n\n// TYPES\nexport interface TextFieldLabelProps {\n variant: 'invalid' | 'subtle' | 'contrast' | 'default';\n htmlFor?: string;\n id?: string;\n}\nexport type TextFieldProps = InputProps & {\n type?: string;\n clearable?: boolean;\n label?: string | ((props: TextFieldLabelProps) => JSX.Element);\n description?: React.ReactNode;\n error?: React.ReactNode;\n announceError?: boolean;\n};\n\nexport type TextFieldVariants = InputVariants;\n\n// COMPONENTS\nconst AdornmentGroup = styled('div', {\n display: 'flex',\n flexDirection: 'row',\n alignItems: 'center',\n});\n\nconst StyledExclamationTriangleIcon = styled(ExclamationTriangleIcon, {\n '& + *': {\n marginLeft: '$1',\n },\n});\n\nconst AdornmentButton = styled('button', {\n appearance: 'none',\n background: 'none',\n border: 'none',\n padding: 0,\n font: 'inherit',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n borderRadius: '$1',\n color: 'inherit',\n '@hover': {\n '&:hover': {\n cursor: 'pointer',\n },\n },\n '&:focus-visible': {\n outline: '2px solid $inputFocusBorder',\n outlineOffset: '1px',\n },\n});\n\nexport const TextField = React.forwardRef<React.ElementRef<typeof Input>, TextFieldProps>(\n (\n {\n state,\n clearable,\n label: LabelOrComponent,\n description,\n error,\n announceError,\n id,\n type,\n disabled,\n readOnly,\n css,\n ...props\n },\n forwardedRef,\n ) => {\n const inputRef = React.useRef<InputHandle | null>(null);\n React.useImperativeHandle(forwardedRef, () => inputRef.current as InputHandle);\n\n const outerField = useFieldContext();\n const [innerType, setInnerType] = React.useState(type);\n const isPasswordVisible = React.useMemo(() => innerType !== 'password', [innerType]);\n\n const invalid = state === 'invalid' || Boolean(error) || Boolean(outerField?.invalid);\n\n const renderLabel = React.useMemo(() => {\n if (LabelOrComponent === undefined || LabelOrComponent === null) {\n return undefined;\n }\n if (typeof LabelOrComponent === 'string') {\n return LabelOrComponent;\n }\n return (labelProps: FieldLabelProps) => <LabelOrComponent {...labelProps} />;\n }, [LabelOrComponent]);\n\n const isPasswordType = React.useMemo(() => type === 'password', [type]);\n\n const typeOrInnerType = React.useMemo(\n () => (isPasswordType ? innerType : type),\n [isPasswordType, type, innerType],\n );\n\n const hasInnerAdornment = React.useMemo(\n () => clearable || isPasswordType || invalid,\n [clearable, isPasswordType, invalid],\n );\n\n const hasAdornmentGroup = React.useMemo(\n () => (clearable && invalid) || (clearable && isPasswordType) || (invalid && isPasswordType),\n [clearable, invalid, isPasswordType],\n );\n\n const clearDisabled = readOnly || disabled || Boolean(outerField?.disabled);\n\n const handleClear = React.useCallback(() => {\n const { current } = inputRef;\n if (current) {\n const setValue = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set;\n setValue?.call(current, '');\n current.dispatchEvent(new Event('input', { bubbles: true }));\n current.focus();\n }\n }, [inputRef]);\n\n const togglePasswordVisibility = React.useCallback(() => {\n setInnerType((prevInnerType) => (prevInnerType === 'password' ? undefined : 'password'));\n }, [setInnerType]);\n\n const EndAdornmentWrapper = hasAdornmentGroup ? AdornmentGroup : React.Fragment;\n\n const PasswordVisibilityToggleIcon = isPasswordVisible ? EyeClosedIcon : EyeOpenIcon;\n\n const passwordAction = React.useMemo(\n () => (isPasswordVisible ? 'Hide password' : 'Show password'),\n [isPasswordVisible],\n );\n\n const input = (\n <Input\n id={id}\n ref={inputRef}\n endAdornment={\n hasInnerAdornment && (\n <EndAdornmentWrapper>\n {invalid && <StyledExclamationTriangleIcon aria-hidden />}\n {isPasswordType && (\n <Tooltip content={passwordAction}>\n <AdornmentButton\n type=\"button\"\n aria-label={passwordAction}\n onClick={togglePasswordVisibility}\n >\n <PasswordVisibilityToggleIcon aria-hidden />\n </AdornmentButton>\n </Tooltip>\n )}\n {clearable && !clearDisabled && (\n <Tooltip content=\"Clear\">\n <AdornmentButton type=\"button\" aria-label=\"Clear\" onClick={handleClear}>\n <CrossCircledIcon aria-hidden />\n </AdornmentButton>\n </Tooltip>\n )}\n </EndAdornmentWrapper>\n )\n }\n state={state}\n type={typeOrInnerType}\n disabled={disabled}\n readOnly={readOnly}\n {...props}\n />\n );\n\n return (\n <Field\n id={id}\n label={renderLabel}\n description={description}\n error={error}\n announceError={announceError}\n invalid={state === 'invalid'}\n disabled={disabled}\n css={css}\n >\n {input}\n </Field>\n );\n },\n);\n"],"mappings":"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"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { styled } from "../../stitches.config.js";
|
|
2
|
-
import {
|
|
3
|
-
import { Label } from "../Label/Label.js";
|
|
2
|
+
import { useFieldContext } from "../Field/FieldContext.js";
|
|
4
3
|
import { Input } from "../Input/Input.js";
|
|
4
|
+
import { Field } from "../Field/Field.js";
|
|
5
5
|
import { Tooltip } from "../Tooltip/Tooltip.js";
|
|
6
6
|
import { CrossCircledIcon, ExclamationTriangleIcon, EyeClosedIcon, EyeOpenIcon } from "@radix-ui/react-icons";
|
|
7
7
|
import React from "react";
|
|
@@ -13,42 +13,35 @@ var AdornmentGroup = styled("div", {
|
|
|
13
13
|
alignItems: "center"
|
|
14
14
|
});
|
|
15
15
|
var StyledExclamationTriangleIcon = styled(ExclamationTriangleIcon, { "& + *": { marginLeft: "$1" } });
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
var AdornmentButton = styled("button", {
|
|
17
|
+
appearance: "none",
|
|
18
|
+
background: "none",
|
|
19
|
+
border: "none",
|
|
20
|
+
padding: 0,
|
|
21
|
+
font: "inherit",
|
|
22
|
+
display: "inline-flex",
|
|
23
|
+
alignItems: "center",
|
|
24
|
+
justifyContent: "center",
|
|
25
|
+
borderRadius: "$1",
|
|
26
|
+
color: "inherit",
|
|
27
|
+
"@hover": { "&:hover": { cursor: "pointer" } },
|
|
28
|
+
"&:focus-visible": {
|
|
29
|
+
outline: "2px solid $inputFocusBorder",
|
|
30
|
+
outlineOffset: "1px"
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
var TextField = React.forwardRef(({ state, clearable, label: LabelOrComponent, description, error, announceError, id, type, disabled, readOnly, css, ...props }, forwardedRef) => {
|
|
20
34
|
const inputRef = React.useRef(null);
|
|
21
35
|
React.useImperativeHandle(forwardedRef, () => inputRef.current);
|
|
22
|
-
const
|
|
36
|
+
const outerField = useFieldContext();
|
|
23
37
|
const [innerType, setInnerType] = React.useState(type);
|
|
24
38
|
const isPasswordVisible = React.useMemo(() => innerType !== "password", [innerType]);
|
|
25
|
-
const invalid =
|
|
26
|
-
const
|
|
27
|
-
if (
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}, [
|
|
32
|
-
invalid,
|
|
33
|
-
disabled,
|
|
34
|
-
inputHasFocus
|
|
35
|
-
]);
|
|
36
|
-
const LabelNode = React.useMemo(() => {
|
|
37
|
-
if (LabelOrComponent === void 0 || LabelOrComponent === null) return null;
|
|
38
|
-
if (typeof LabelOrComponent === "string") return /* @__PURE__ */ jsx(Label, {
|
|
39
|
-
variant: labelVariant,
|
|
40
|
-
htmlFor: id,
|
|
41
|
-
children: LabelOrComponent
|
|
42
|
-
});
|
|
43
|
-
return /* @__PURE__ */ jsx(LabelOrComponent, {
|
|
44
|
-
variant: labelVariant,
|
|
45
|
-
htmlFor: id
|
|
46
|
-
});
|
|
47
|
-
}, [
|
|
48
|
-
LabelOrComponent,
|
|
49
|
-
labelVariant,
|
|
50
|
-
id
|
|
51
|
-
]);
|
|
39
|
+
const invalid = state === "invalid" || Boolean(error) || Boolean(outerField?.invalid);
|
|
40
|
+
const renderLabel = React.useMemo(() => {
|
|
41
|
+
if (LabelOrComponent === void 0 || LabelOrComponent === null) return;
|
|
42
|
+
if (typeof LabelOrComponent === "string") return LabelOrComponent;
|
|
43
|
+
return (labelProps) => /* @__PURE__ */ jsx(LabelOrComponent, { ...labelProps });
|
|
44
|
+
}, [LabelOrComponent]);
|
|
52
45
|
const isPasswordType = React.useMemo(() => type === "password", [type]);
|
|
53
46
|
const typeOrInnerType = React.useMemo(() => isPasswordType ? innerType : type, [
|
|
54
47
|
isPasswordType,
|
|
@@ -65,58 +58,61 @@ var TextField = React.forwardRef(({ state, clearable, label: LabelOrComponent, i
|
|
|
65
58
|
invalid,
|
|
66
59
|
isPasswordType
|
|
67
60
|
]);
|
|
68
|
-
const clearDisabled =
|
|
61
|
+
const clearDisabled = readOnly || disabled || Boolean(outerField?.disabled);
|
|
69
62
|
const handleClear = React.useCallback(() => {
|
|
70
63
|
const { current } = inputRef;
|
|
71
|
-
if (current)
|
|
64
|
+
if (current) {
|
|
65
|
+
(Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value")?.set)?.call(current, "");
|
|
66
|
+
current.dispatchEvent(new Event("input", { bubbles: true }));
|
|
67
|
+
current.focus();
|
|
68
|
+
}
|
|
72
69
|
}, [inputRef]);
|
|
73
|
-
const handleFocus = React.useCallback((e) => {
|
|
74
|
-
if (onFocus) onFocus(e);
|
|
75
|
-
setInputHasFocus(true);
|
|
76
|
-
}, [onFocus, setInputHasFocus]);
|
|
77
|
-
const handleBlur = React.useCallback((e) => {
|
|
78
|
-
if (onBlur) onBlur(e);
|
|
79
|
-
setInputHasFocus(false);
|
|
80
|
-
}, [onBlur, setInputHasFocus]);
|
|
81
70
|
const togglePasswordVisibility = React.useCallback(() => {
|
|
82
71
|
setInnerType((prevInnerType) => prevInnerType === "password" ? void 0 : "password");
|
|
83
72
|
}, [setInnerType]);
|
|
84
73
|
const EndAdornmentWrapper = hasAdornmentGroup ? AdornmentGroup : React.Fragment;
|
|
85
|
-
const PasswordVisibilityToggleIcon = isPasswordVisible ?
|
|
74
|
+
const PasswordVisibilityToggleIcon = isPasswordVisible ? EyeClosedIcon : EyeOpenIcon;
|
|
86
75
|
const passwordAction = React.useMemo(() => isPasswordVisible ? "Hide password" : "Show password", [isPasswordVisible]);
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
children: /* @__PURE__ */ jsx(PasswordVisibilityToggleIcon, {
|
|
100
|
-
"aria-label": passwordAction,
|
|
101
|
-
onClick: togglePasswordVisibility
|
|
102
|
-
})
|
|
103
|
-
}),
|
|
104
|
-
clearable && !clearDisabled && /* @__PURE__ */ jsx(Tooltip, {
|
|
105
|
-
content: "Clear",
|
|
106
|
-
children: /* @__PURE__ */ jsx(StyledCrossCircledIcon, {
|
|
107
|
-
"aria-label": "Clear",
|
|
108
|
-
onClick: handleClear
|
|
109
|
-
})
|
|
76
|
+
const input = /* @__PURE__ */ jsx(Input, {
|
|
77
|
+
id,
|
|
78
|
+
ref: inputRef,
|
|
79
|
+
endAdornment: hasInnerAdornment && /* @__PURE__ */ jsxs(EndAdornmentWrapper, { children: [
|
|
80
|
+
invalid && /* @__PURE__ */ jsx(StyledExclamationTriangleIcon, { "aria-hidden": true }),
|
|
81
|
+
isPasswordType && /* @__PURE__ */ jsx(Tooltip, {
|
|
82
|
+
content: passwordAction,
|
|
83
|
+
children: /* @__PURE__ */ jsx(AdornmentButton, {
|
|
84
|
+
type: "button",
|
|
85
|
+
"aria-label": passwordAction,
|
|
86
|
+
onClick: togglePasswordVisibility,
|
|
87
|
+
children: /* @__PURE__ */ jsx(PasswordVisibilityToggleIcon, { "aria-hidden": true })
|
|
110
88
|
})
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
89
|
+
}),
|
|
90
|
+
clearable && !clearDisabled && /* @__PURE__ */ jsx(Tooltip, {
|
|
91
|
+
content: "Clear",
|
|
92
|
+
children: /* @__PURE__ */ jsx(AdornmentButton, {
|
|
93
|
+
type: "button",
|
|
94
|
+
"aria-label": "Clear",
|
|
95
|
+
onClick: handleClear,
|
|
96
|
+
children: /* @__PURE__ */ jsx(CrossCircledIcon, { "aria-hidden": true })
|
|
97
|
+
})
|
|
98
|
+
})
|
|
99
|
+
] }),
|
|
100
|
+
state,
|
|
101
|
+
type: typeOrInnerType,
|
|
102
|
+
disabled,
|
|
103
|
+
readOnly,
|
|
104
|
+
...props
|
|
105
|
+
});
|
|
106
|
+
return /* @__PURE__ */ jsx(Field, {
|
|
107
|
+
id,
|
|
108
|
+
label: renderLabel,
|
|
109
|
+
description,
|
|
110
|
+
error,
|
|
111
|
+
announceError,
|
|
112
|
+
invalid: state === "invalid",
|
|
113
|
+
disabled,
|
|
114
|
+
css,
|
|
115
|
+
children: input
|
|
120
116
|
});
|
|
121
117
|
});
|
|
122
118
|
export { TextField };
|