@traefik-labs/faency 13.3.0 → 13.5.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/Alert/Alert.cjs.map +1 -1
- package/dist/components/Alert/Alert.js.map +1 -1
- package/dist/components/AriaTable/AriaTable.cjs +15 -5
- package/dist/components/AriaTable/AriaTable.cjs.map +1 -1
- package/dist/components/AriaTable/AriaTable.js +16 -6
- package/dist/components/AriaTable/AriaTable.js.map +1 -1
- package/dist/components/Badge/Badge.vanilla.css.cjs.map +1 -1
- package/dist/components/Badge/Badge.vanilla.css.js.map +1 -1
- package/dist/components/Card/Card.cjs.map +1 -1
- package/dist/components/Card/Card.js.map +1 -1
- package/dist/components/CodeBlock/CodeBlock.cjs +2 -2
- package/dist/components/CodeBlock/CodeBlock.js +2 -2
- package/dist/components/CodeBlock/CodeBlock.vanilla.cjs +3 -3
- package/dist/components/CodeBlock/CodeBlock.vanilla.js +3 -3
- package/dist/components/Combobox/Combobox.vanilla.cjs +170 -0
- package/dist/components/Combobox/Combobox.vanilla.cjs.map +1 -0
- package/dist/components/Combobox/Combobox.vanilla.css.cjs +33 -0
- package/dist/components/Combobox/Combobox.vanilla.css.cjs.map +1 -0
- package/dist/components/Combobox/Combobox.vanilla.css.js +29 -0
- package/dist/components/Combobox/Combobox.vanilla.css.js.map +1 -0
- package/dist/components/Combobox/Combobox.vanilla.js +167 -0
- package/dist/components/Combobox/Combobox.vanilla.js.map +1 -0
- package/dist/components/DateTimePicker/DateTimePicker.cjs +1 -1
- package/dist/components/DateTimePicker/DateTimePicker.js +1 -1
- package/dist/components/Dialog/Dialog.cjs +1 -1
- package/dist/components/Dialog/Dialog.js +1 -1
- package/dist/components/Field/Field.cjs +80 -33
- package/dist/components/Field/Field.cjs.map +1 -1
- package/dist/components/Field/Field.js +80 -33
- package/dist/components/Field/Field.js.map +1 -1
- package/dist/components/Field/Field.vanilla.cjs +62 -32
- package/dist/components/Field/Field.vanilla.cjs.map +1 -1
- package/dist/components/Field/Field.vanilla.css.cjs +6 -0
- package/dist/components/Field/Field.vanilla.css.cjs.map +1 -1
- package/dist/components/Field/Field.vanilla.css.js +4 -1
- package/dist/components/Field/Field.vanilla.css.js.map +1 -1
- package/dist/components/Field/Field.vanilla.js +63 -33
- package/dist/components/Field/Field.vanilla.js.map +1 -1
- package/dist/components/Field/FieldContext.cjs +48 -10
- package/dist/components/Field/FieldContext.cjs.map +1 -1
- package/dist/components/Field/FieldContext.js +48 -10
- package/dist/components/Field/FieldContext.js.map +1 -1
- package/dist/components/List/List.cjs +1 -1
- package/dist/components/List/List.js +1 -1
- package/dist/components/Meter/Meter.vanilla.cjs +74 -0
- package/dist/components/Meter/Meter.vanilla.cjs.map +1 -0
- package/dist/components/Meter/Meter.vanilla.css.cjs +26 -0
- package/dist/components/Meter/Meter.vanilla.css.cjs.map +1 -0
- package/dist/components/Meter/Meter.vanilla.css.js +21 -0
- package/dist/components/Meter/Meter.vanilla.css.js.map +1 -0
- package/dist/components/Meter/Meter.vanilla.js +72 -0
- package/dist/components/Meter/Meter.vanilla.js.map +1 -0
- package/dist/components/NavigationTree/NavigationTreeItem.cjs +2 -2
- package/dist/components/NavigationTree/NavigationTreeItem.js +2 -2
- package/dist/components/RowLink/RowLink.cjs +35 -12
- package/dist/components/RowLink/RowLink.cjs.map +1 -1
- package/dist/components/RowLink/RowLink.js +34 -12
- package/dist/components/RowLink/RowLink.js.map +1 -1
- package/dist/components/SegmentedControl/SegmentedControl.vanilla.cjs +57 -0
- package/dist/components/SegmentedControl/SegmentedControl.vanilla.cjs.map +1 -0
- package/dist/components/SegmentedControl/SegmentedControl.vanilla.css.cjs +35 -0
- package/dist/components/SegmentedControl/SegmentedControl.vanilla.css.cjs.map +1 -0
- package/dist/components/SegmentedControl/SegmentedControl.vanilla.css.js +34 -0
- package/dist/components/SegmentedControl/SegmentedControl.vanilla.css.js.map +1 -0
- package/dist/components/SegmentedControl/SegmentedControl.vanilla.js +53 -0
- package/dist/components/SegmentedControl/SegmentedControl.vanilla.js.map +1 -0
- package/dist/components/Select/Select.cjs +1 -1
- package/dist/components/Select/Select.js +1 -1
- package/dist/components/Spinner/Spinner.vanilla.cjs +50 -0
- package/dist/components/Spinner/Spinner.vanilla.cjs.map +1 -0
- package/dist/components/Spinner/Spinner.vanilla.css.cjs +21 -0
- package/dist/components/Spinner/Spinner.vanilla.css.cjs.map +1 -0
- package/dist/components/Spinner/Spinner.vanilla.css.js +19 -0
- package/dist/components/Spinner/Spinner.vanilla.css.js.map +1 -0
- package/dist/components/Spinner/Spinner.vanilla.js +48 -0
- package/dist/components/Spinner/Spinner.vanilla.js.map +1 -0
- package/dist/components/SplitLayout/SplitLayout.vanilla.cjs +214 -0
- package/dist/components/SplitLayout/SplitLayout.vanilla.cjs.map +1 -0
- package/dist/components/SplitLayout/SplitLayout.vanilla.css.cjs +14 -0
- package/dist/components/SplitLayout/SplitLayout.vanilla.css.cjs.map +1 -0
- package/dist/components/SplitLayout/SplitLayout.vanilla.css.js +10 -0
- package/dist/components/SplitLayout/SplitLayout.vanilla.css.js.map +1 -0
- package/dist/components/SplitLayout/SplitLayout.vanilla.js +210 -0
- package/dist/components/SplitLayout/SplitLayout.vanilla.js.map +1 -0
- package/dist/components/Table/Table.cjs +13 -4
- package/dist/components/Table/Table.cjs.map +1 -1
- package/dist/components/Table/Table.js +13 -4
- package/dist/components/Table/Table.js.map +1 -1
- package/dist/components/TextField/TextField.cjs +1 -1
- package/dist/components/TextField/TextField.js +1 -1
- package/dist/components/TextField/TextField.vanilla.cjs +1 -1
- package/dist/components/TextField/TextField.vanilla.js +1 -1
- package/dist/components/Textarea/Textarea.cjs +2 -2
- package/dist/components/Textarea/Textarea.js +2 -2
- package/dist/components/Textarea/Textarea.vanilla.cjs +2 -2
- package/dist/components/Textarea/Textarea.vanilla.js +2 -2
- package/dist/components/Toast/Toast.vanilla.cjs +96 -0
- package/dist/components/Toast/Toast.vanilla.cjs.map +1 -0
- package/dist/components/Toast/Toast.vanilla.css.cjs +44 -0
- package/dist/components/Toast/Toast.vanilla.css.cjs.map +1 -0
- package/dist/components/Toast/Toast.vanilla.css.js +37 -0
- package/dist/components/Toast/Toast.vanilla.css.js.map +1 -0
- package/dist/components/Toast/Toast.vanilla.js +90 -0
- package/dist/components/Toast/Toast.vanilla.js.map +1 -0
- package/dist/components/Toast/ToastProvider.vanilla.cjs +98 -0
- package/dist/components/Toast/ToastProvider.vanilla.cjs.map +1 -0
- package/dist/components/Toast/ToastProvider.vanilla.js +94 -0
- package/dist/components/Toast/ToastProvider.vanilla.js.map +1 -0
- package/dist/faency.css +3315 -2335
- package/dist/index.cjs +55 -32
- package/dist/index.d.ts +809 -14
- package/dist/index.js +41 -33
- package/dist/styles/cssProps.cjs +3 -10
- package/dist/styles/cssProps.cjs.map +1 -1
- package/dist/styles/cssProps.js +3 -10
- package/dist/styles/cssProps.js.map +1 -1
- package/dist/styles/resolveColor.cjs +18 -0
- package/dist/styles/resolveColor.cjs.map +1 -0
- package/dist/styles/resolveColor.js +18 -0
- package/dist/styles/resolveColor.js.map +1 -0
- package/dist/styles/themes.css.cjs.map +1 -1
- package/dist/styles/themes.css.js.map +1 -1
- package/dist/styles/tokens.css.cjs +484 -0
- package/dist/styles/tokens.css.cjs.map +1 -0
- package/dist/styles/tokens.css.js +484 -0
- package/dist/styles/tokens.css.js.map +1 -0
- package/dist/utils/warnOnce.cjs +13 -0
- package/dist/utils/warnOnce.cjs.map +1 -0
- package/dist/utils/warnOnce.js +13 -0
- package/dist/utils/warnOnce.js.map +1 -0
- package/package.json +12 -25
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { processCSSProp } from "../../styles/cssProps.js";
|
|
2
2
|
import { useVanillaExtractTheme } from "../../styles/themeContext.js";
|
|
3
3
|
import { BoxVanilla } from "../Box/Box.vanilla.js";
|
|
4
|
-
import { TextVanilla } from "../Text/Text.vanilla.js";
|
|
5
4
|
import { LabelVanilla } from "../Label/Label.vanilla.js";
|
|
6
|
-
import {
|
|
5
|
+
import { TextVanilla } from "../Text/Text.vanilla.js";
|
|
7
6
|
import { VisuallyHidden } from "../VisuallyHidden/VisuallyHidden.js";
|
|
8
|
-
import { endLabelRow } from "./Field.vanilla.css.js";
|
|
7
|
+
import { endLabelRow, startControl, startLabel, startRow } from "./Field.vanilla.css.js";
|
|
8
|
+
import { FieldContext, useAnnouncedError, useFieldRoot } from "./FieldContext.js";
|
|
9
9
|
import React from "react";
|
|
10
10
|
import { assignInlineVars } from "@vanilla-extract/dynamic";
|
|
11
11
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -13,78 +13,108 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
13
13
|
var MESSAGE_CSS = {
|
|
14
14
|
display: "block",
|
|
15
15
|
m: 0,
|
|
16
|
-
mt: "$1"
|
|
16
|
+
mt: "$1",
|
|
17
|
+
lineHeight: 1.4
|
|
18
|
+
};
|
|
19
|
+
var COMPACT_LABEL_CSS = { lineHeight: 1.4 };
|
|
20
|
+
var HINT_ABOVE_CONTROL_CSS = {
|
|
21
|
+
...MESSAGE_CSS,
|
|
22
|
+
mb: "$2"
|
|
17
23
|
};
|
|
18
24
|
/**
|
|
19
|
-
* Gives a label, a description and an error to the one form control inside it.
|
|
20
|
-
*
|
|
25
|
+
* Gives a label, a hint, a description and an error to the one form control inside it.
|
|
26
|
+
* For more than one control, use `group`.
|
|
21
27
|
*/
|
|
22
|
-
var FieldVanilla = ({ label, description, error, announceError, labelPosition = "top", children, css, ...props }) => {
|
|
23
|
-
const { context, labelFor, labelVariant, hasLabel, hasDescription, hasError, onFocus, onBlur } = useFieldRoot({
|
|
28
|
+
var FieldVanilla = ({ label, hint, description, error, announceError, labelPosition = "top", children, css, ...props }) => {
|
|
29
|
+
const { context, ids, groupProps, messageSize, labelFor, labelVariant, hasLabel, hasHint, hasDescription, hasError, onFocus, onBlur } = useFieldRoot({
|
|
24
30
|
label,
|
|
31
|
+
hint,
|
|
25
32
|
description,
|
|
26
33
|
error,
|
|
27
34
|
...props
|
|
28
35
|
});
|
|
29
|
-
const announcedError = useAnnouncedError(Boolean(announceError), hasError ?
|
|
36
|
+
const announcedError = useAnnouncedError(Boolean(announceError), hasError ? ids.errorId : void 0, ids.labelId);
|
|
30
37
|
const { colors } = useVanillaExtractTheme();
|
|
31
38
|
const { style: rootStyle, vars: rootVars } = processCSSProp(css, colors);
|
|
32
39
|
const labelNode = React.useMemo(() => {
|
|
33
|
-
if (!hasLabel || !
|
|
40
|
+
if (!hasLabel || !ids.labelId) return null;
|
|
34
41
|
if (typeof label === "function") return label({
|
|
35
42
|
variant: labelVariant,
|
|
36
43
|
htmlFor: labelFor,
|
|
37
|
-
id:
|
|
44
|
+
id: ids.labelId
|
|
38
45
|
});
|
|
39
46
|
return /* @__PURE__ */ jsx(LabelVanilla, {
|
|
40
47
|
variant: labelVariant,
|
|
41
48
|
htmlFor: labelFor,
|
|
42
|
-
id:
|
|
49
|
+
id: ids.labelId,
|
|
50
|
+
css: hasHint || labelPosition === "start" ? COMPACT_LABEL_CSS : void 0,
|
|
43
51
|
children: label
|
|
44
52
|
});
|
|
45
53
|
}, [
|
|
46
54
|
hasLabel,
|
|
55
|
+
hasHint,
|
|
47
56
|
label,
|
|
57
|
+
labelPosition,
|
|
48
58
|
labelVariant,
|
|
49
59
|
labelFor,
|
|
50
|
-
|
|
60
|
+
ids.labelId
|
|
51
61
|
]);
|
|
52
|
-
const
|
|
62
|
+
const hintNode = hasHint && /* @__PURE__ */ jsx(TextVanilla, {
|
|
53
63
|
as: "p",
|
|
54
|
-
id:
|
|
55
|
-
size:
|
|
64
|
+
id: ids.hintId,
|
|
65
|
+
size: messageSize,
|
|
66
|
+
variant: "subtle",
|
|
67
|
+
css: labelPosition === "top" ? HINT_ABOVE_CONTROL_CSS : MESSAGE_CSS,
|
|
68
|
+
children: hint
|
|
69
|
+
});
|
|
70
|
+
const messages = /* @__PURE__ */ jsxs(Fragment, { children: [hasDescription && /* @__PURE__ */ jsx(TextVanilla, {
|
|
71
|
+
as: "p",
|
|
72
|
+
id: ids.descriptionId,
|
|
73
|
+
size: messageSize,
|
|
74
|
+
variant: "subtle",
|
|
75
|
+
css: MESSAGE_CSS,
|
|
76
|
+
children: description
|
|
77
|
+
}), hasError && /* @__PURE__ */ jsx(TextVanilla, {
|
|
78
|
+
as: "p",
|
|
79
|
+
id: ids.errorId,
|
|
80
|
+
size: messageSize,
|
|
56
81
|
variant: "invalid",
|
|
57
82
|
css: MESSAGE_CSS,
|
|
58
83
|
children: error
|
|
59
|
-
});
|
|
84
|
+
})] });
|
|
60
85
|
return /* @__PURE__ */ jsx(FieldContext.Provider, {
|
|
61
86
|
value: context,
|
|
62
87
|
children: /* @__PURE__ */ jsxs("div", {
|
|
88
|
+
className: labelPosition === "start" ? startRow : void 0,
|
|
63
89
|
style: {
|
|
64
90
|
...rootStyle,
|
|
65
91
|
...assignInlineVars(rootVars)
|
|
66
92
|
},
|
|
67
93
|
onFocus,
|
|
68
94
|
onBlur,
|
|
69
|
-
|
|
70
|
-
|
|
95
|
+
...groupProps,
|
|
96
|
+
children: [labelPosition === "start" ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(BoxVanilla, {
|
|
97
|
+
className: startLabel,
|
|
98
|
+
children: [labelNode, hintNode]
|
|
99
|
+
}), /* @__PURE__ */ jsxs(BoxVanilla, {
|
|
100
|
+
className: startControl,
|
|
101
|
+
children: [children, messages]
|
|
102
|
+
})] }) : labelPosition === "end" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
103
|
+
/* @__PURE__ */ jsxs(BoxVanilla, {
|
|
71
104
|
className: endLabelRow,
|
|
72
105
|
children: [children, labelNode]
|
|
73
|
-
}) : /* @__PURE__ */ jsxs(Fragment, { children: [labelNode, children] }),
|
|
74
|
-
hasDescription && /* @__PURE__ */ jsx(TextVanilla, {
|
|
75
|
-
as: "p",
|
|
76
|
-
id: context.descriptionId,
|
|
77
|
-
size: "0",
|
|
78
|
-
variant: "subtle",
|
|
79
|
-
css: MESSAGE_CSS,
|
|
80
|
-
children: description
|
|
81
106
|
}),
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
107
|
+
hintNode,
|
|
108
|
+
messages
|
|
109
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
110
|
+
labelNode,
|
|
111
|
+
hintNode,
|
|
112
|
+
children,
|
|
113
|
+
messages
|
|
114
|
+
] }), announceError && /* @__PURE__ */ jsx(VisuallyHidden, {
|
|
115
|
+
"aria-live": "polite",
|
|
116
|
+
children: announcedError
|
|
117
|
+
})]
|
|
88
118
|
})
|
|
89
119
|
});
|
|
90
120
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Field.vanilla.js","names":["_Fragment"],"sources":["../../../components/Field/Field.vanilla.tsx"],"sourcesContent":["import { assignInlineVars } from '@vanilla-extract/dynamic';\nimport React from 'react';\n\nimport { CSSProps, processCSSProp } from '../../styles/cssProps';\nimport { useVanillaExtractTheme } from '../../styles/themeContext';\nimport { BoxVanilla } from '../Box';\nimport { LabelVanilla } from '../Label';\nimport { TextVanilla } from '../Text';\nimport { VisuallyHidden } from '../VisuallyHidden';\nimport { endLabelRow } from './Field.vanilla.css';\nimport { FieldBaseProps, FieldContext, useAnnouncedError, useFieldRoot } from './FieldContext';\n\nexport type FieldVanillaProps = FieldBaseProps & { css?: CSSProps['css'] };\n\nconst MESSAGE_CSS = { display: 'block', m: 0, mt: '$1' };\n\n/**\n * Gives a label, a description and an error to the one form control inside it.\n *
|
|
1
|
+
{"version":3,"file":"Field.vanilla.js","names":["_Fragment"],"sources":["../../../components/Field/Field.vanilla.tsx"],"sourcesContent":["import { assignInlineVars } from '@vanilla-extract/dynamic';\nimport React from 'react';\n\nimport { CSSProps, processCSSProp } from '../../styles/cssProps';\nimport { useVanillaExtractTheme } from '../../styles/themeContext';\nimport { BoxVanilla } from '../Box';\nimport { LabelVanilla } from '../Label';\nimport { TextVanilla } from '../Text';\nimport { VisuallyHidden } from '../VisuallyHidden';\nimport { endLabelRow, startControl, startLabel, startRow } from './Field.vanilla.css';\nimport { FieldBaseProps, FieldContext, useAnnouncedError, useFieldRoot } from './FieldContext';\n\nexport type FieldVanillaProps = FieldBaseProps & { css?: CSSProps['css'] };\n\nconst MESSAGE_CSS = { display: 'block', m: 0, mt: '$1', lineHeight: 1.4 };\n// The tall line of a label makes room for a control right under it. Before a hint or beside a control, it is a gap.\nconst COMPACT_LABEL_CSS = { lineHeight: 1.4 };\nconst HINT_ABOVE_CONTROL_CSS = { ...MESSAGE_CSS, mb: '$2' };\n\n/**\n * Gives a label, a hint, a description and an error to the one form control inside it.\n * For more than one control, use `group`.\n */\nexport const FieldVanilla = ({\n label,\n hint,\n description,\n error,\n announceError,\n labelPosition = 'top',\n children,\n css,\n ...props\n}: FieldVanillaProps) => {\n const {\n context,\n ids,\n groupProps,\n messageSize,\n labelFor,\n labelVariant,\n hasLabel,\n hasHint,\n hasDescription,\n hasError,\n onFocus,\n onBlur,\n } = useFieldRoot({ label, hint, description, error, ...props });\n const announcedError = useAnnouncedError(\n Boolean(announceError),\n hasError ? ids.errorId : undefined,\n ids.labelId,\n );\n const { colors } = useVanillaExtractTheme();\n const { style: rootStyle, vars: rootVars } = processCSSProp(css, colors);\n\n const labelNode = React.useMemo(() => {\n if (!hasLabel || !ids.labelId) {\n return null;\n }\n if (typeof label === 'function') {\n return label({ variant: labelVariant, htmlFor: labelFor, id: ids.labelId });\n }\n return (\n <LabelVanilla\n variant={labelVariant}\n htmlFor={labelFor}\n id={ids.labelId}\n css={hasHint || labelPosition === 'start' ? COMPACT_LABEL_CSS : undefined}\n >\n {label}\n </LabelVanilla>\n );\n }, [hasLabel, hasHint, label, labelPosition, labelVariant, labelFor, ids.labelId]);\n\n const hintNode = hasHint && (\n <TextVanilla\n as=\"p\"\n id={ids.hintId}\n size={messageSize}\n variant=\"subtle\"\n css={labelPosition === 'top' ? HINT_ABOVE_CONTROL_CSS : MESSAGE_CSS}\n >\n {hint}\n </TextVanilla>\n );\n\n const messages = (\n <>\n {hasDescription && (\n <TextVanilla\n as=\"p\"\n id={ids.descriptionId}\n size={messageSize}\n variant=\"subtle\"\n css={MESSAGE_CSS}\n >\n {description}\n </TextVanilla>\n )}\n {hasError && (\n <TextVanilla as=\"p\" id={ids.errorId} size={messageSize} variant=\"invalid\" css={MESSAGE_CSS}>\n {error}\n </TextVanilla>\n )}\n </>\n );\n\n return (\n <FieldContext.Provider value={context}>\n <div\n className={labelPosition === 'start' ? startRow : undefined}\n style={{ ...rootStyle, ...assignInlineVars(rootVars) }}\n onFocus={onFocus}\n onBlur={onBlur}\n {...groupProps}\n >\n {labelPosition === 'start' ? (\n <>\n <BoxVanilla className={startLabel}>\n {labelNode}\n {hintNode}\n </BoxVanilla>\n <BoxVanilla className={startControl}>\n {children}\n {messages}\n </BoxVanilla>\n </>\n ) : labelPosition === 'end' ? (\n <>\n <BoxVanilla className={endLabelRow}>\n {children}\n {labelNode}\n </BoxVanilla>\n {hintNode}\n {messages}\n </>\n ) : (\n <>\n {labelNode}\n {hintNode}\n {children}\n {messages}\n </>\n )}\n {announceError && <VisuallyHidden aria-live=\"polite\">{announcedError}</VisuallyHidden>}\n </div>\n </FieldContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;;;;;AAcA,IAAM,cAAc;CAAE,SAAS;CAAS,GAAG;CAAG,IAAI;CAAM,YAAY;AAAI;AAExE,IAAM,oBAAoB,EAAE,YAAY,IAAI;AAC5C,IAAM,yBAAyB;CAAE,GAAG;CAAa,IAAI;AAAK;;;;;AAM1D,IAAa,gBAAgB,EAC3B,OACA,MACA,aACA,OACA,eACA,gBAAgB,OAChB,UACA,KACA,GAAG,YACoB;CACvB,MAAM,EACJ,SACA,KACA,YACA,aACA,UACA,cACA,UACA,SACA,gBACA,UACA,SACA,WACE,aAAa;EAAE;EAAO;EAAM;EAAa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AkB,UACjB,qBAAAA,UAAA,EAAA,UAAA,CACE,qBAAC,YAAD;IAAY,WAAW;IAAvB,UAAA,CACG,WACA,QACS;GACZ,CAAA,GAAA,qBAAC,YAAD;IAAY,WAAW;IAAvB,UAAA,CACG,UACA,QACS;GACZ,CAAA,CAAA,EAAA,CAAA,IACA,kBAAkB,QACpB,qBAAAA,UAAA,EAAA,UAAA;IACE,qBAAC,YAAD;KAAY,WAAW;KAAvB,UAAA,CACG,UACA,SACS;;IACX;IACA;GACD,EAAA,CAAA,IAEF,qBAAAA,UAAA,EAAA,UAAA;IACG;IACA;IACA;IACA;GACD,EAAA,CAAA,GAEH,iBAAiB,oBAAC,gBAAD;IAAgB,aAAU;IAAU,UAAA;GAA+B,CAAA,CAClF;;CACgB,CAAA;AAE3B"}
|
|
@@ -1,33 +1,45 @@
|
|
|
1
1
|
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_warnOnce = require("../../utils/warnOnce.cjs");
|
|
2
3
|
let react = require("react");
|
|
3
4
|
react = require_runtime.__toESM(react, 1);
|
|
4
5
|
// components/Field/FieldContext.ts
|
|
5
6
|
var FieldContext = react.default.createContext(null);
|
|
6
7
|
var useFieldContext = () => react.default.useContext(FieldContext);
|
|
7
8
|
var hasContent = (node) => node !== void 0 && node !== null && node !== false && node !== "";
|
|
8
|
-
var
|
|
9
|
+
var noop = () => {};
|
|
10
|
+
var MULTIPLE_CONTROLS_WARNING = "Field: more than one control is in this Field, and its label points to one of them only. Use group, or one Field per control.";
|
|
11
|
+
var useFieldRoot = ({ id, label, hint, description, error, invalid, disabled, messageSize, group = false }) => {
|
|
9
12
|
const outerContext = useFieldContext();
|
|
10
13
|
const generatedId = react.default.useId();
|
|
11
14
|
const hasLabel = typeof label === "function" || hasContent(label);
|
|
15
|
+
const hasHint = hasContent(hint);
|
|
16
|
+
const resolvedMessageSize = messageSize ?? outerContext?.messageSize ?? "0";
|
|
12
17
|
const hasDescription = hasContent(description);
|
|
13
18
|
const hasError = hasContent(error);
|
|
14
19
|
const isInvalid = Boolean(invalid) || hasError;
|
|
20
|
+
const isDisabled = Boolean(disabled) || Boolean(outerContext?.disabled);
|
|
15
21
|
const [control, setControl] = react.default.useState(null);
|
|
16
|
-
const
|
|
22
|
+
const controlsRef = react.default.useRef(/* @__PURE__ */ new Map());
|
|
23
|
+
const registerControl = react.default.useCallback((key, state) => {
|
|
24
|
+
const controls = controlsRef.current;
|
|
25
|
+
if (state) controls.set(key, state);
|
|
26
|
+
else controls.delete(key);
|
|
27
|
+
if (controls.size > 1) require_warnOnce.warnOnce(MULTIPLE_CONTROLS_WARNING);
|
|
28
|
+
const next = controls.values().next().value ?? null;
|
|
17
29
|
setControl((prev) => prev?.id === next?.id && prev?.disabled === next?.disabled && prev?.invalid === next?.invalid && prev?.labelable === next?.labelable ? prev : next);
|
|
18
30
|
}, []);
|
|
19
31
|
const controlId = control?.id ?? id ?? (hasLabel ? `${generatedId}-control` : void 0);
|
|
20
|
-
const labelFor = control
|
|
32
|
+
const labelFor = group ? void 0 : control ? control.labelable === false ? void 0 : controlId : id;
|
|
21
33
|
const [hasFocus, setHasFocus] = react.default.useState(false);
|
|
22
34
|
const onFocus = react.default.useCallback(() => setHasFocus(true), []);
|
|
23
35
|
const onBlur = react.default.useCallback(() => setHasFocus(false), []);
|
|
24
36
|
const labelVariant = react.default.useMemo(() => {
|
|
25
|
-
if (
|
|
37
|
+
if (isDisabled || control?.disabled) return "subtle";
|
|
26
38
|
if (isInvalid || control?.invalid) return "invalid";
|
|
27
39
|
if (hasFocus) return "contrast";
|
|
28
40
|
return "default";
|
|
29
41
|
}, [
|
|
30
|
-
|
|
42
|
+
isDisabled,
|
|
31
43
|
isInvalid,
|
|
32
44
|
hasFocus,
|
|
33
45
|
control?.disabled,
|
|
@@ -38,8 +50,10 @@ var useFieldRoot = ({ id, label, description, error, invalid, disabled }) => {
|
|
|
38
50
|
labelId: hasLabel ? `${generatedId}-label` : void 0,
|
|
39
51
|
descriptionId: hasDescription ? `${generatedId}-description` : void 0,
|
|
40
52
|
errorId: hasError ? `${generatedId}-error` : void 0,
|
|
53
|
+
hintId: hasHint ? `${generatedId}-hint` : void 0,
|
|
54
|
+
messageSize: resolvedMessageSize,
|
|
41
55
|
invalid: isInvalid,
|
|
42
|
-
disabled:
|
|
56
|
+
disabled: isDisabled,
|
|
43
57
|
registerControl
|
|
44
58
|
}), [
|
|
45
59
|
controlId,
|
|
@@ -47,15 +61,36 @@ var useFieldRoot = ({ id, label, description, error, invalid, disabled }) => {
|
|
|
47
61
|
hasLabel,
|
|
48
62
|
hasDescription,
|
|
49
63
|
hasError,
|
|
64
|
+
hasHint,
|
|
65
|
+
resolvedMessageSize,
|
|
50
66
|
isInvalid,
|
|
51
|
-
|
|
67
|
+
isDisabled,
|
|
52
68
|
registerControl
|
|
53
69
|
]);
|
|
70
|
+
const groupContext = react.default.useMemo(() => ({
|
|
71
|
+
messageSize: resolvedMessageSize,
|
|
72
|
+
invalid: false,
|
|
73
|
+
disabled: isDisabled,
|
|
74
|
+
registerControl: noop
|
|
75
|
+
}), [resolvedMessageSize, isDisabled]);
|
|
76
|
+
const groupProps = group ? {
|
|
77
|
+
role: "group",
|
|
78
|
+
"aria-labelledby": ownContext.labelId,
|
|
79
|
+
"aria-describedby": [
|
|
80
|
+
ownContext.errorId,
|
|
81
|
+
ownContext.descriptionId,
|
|
82
|
+
ownContext.hintId
|
|
83
|
+
].filter(Boolean).join(" ") || void 0
|
|
84
|
+
} : {};
|
|
54
85
|
return {
|
|
55
|
-
context: outerContext && !hasLabel && !hasDescription && !hasError ? outerContext : ownContext,
|
|
86
|
+
context: group ? groupContext : outerContext && !hasLabel && !hasHint && !hasDescription && !hasError ? outerContext : ownContext,
|
|
87
|
+
ids: ownContext,
|
|
88
|
+
groupProps,
|
|
89
|
+
messageSize: resolvedMessageSize,
|
|
56
90
|
labelFor,
|
|
57
91
|
labelVariant,
|
|
58
92
|
hasLabel,
|
|
93
|
+
hasHint,
|
|
59
94
|
hasDescription,
|
|
60
95
|
hasError,
|
|
61
96
|
onFocus,
|
|
@@ -69,20 +104,22 @@ var useFieldRoot = ({ id, label, description, error, invalid, disabled }) => {
|
|
|
69
104
|
*/
|
|
70
105
|
var useFieldControl = ({ id, invalid, disabled, "aria-describedby": describedBy, "aria-invalid": ariaInvalid, labelable = true }) => {
|
|
71
106
|
const field = useFieldContext();
|
|
107
|
+
const registrationId = react.default.useId();
|
|
72
108
|
const ownInvalid = Boolean(invalid || ariaInvalid === true || ariaInvalid === "true");
|
|
73
109
|
const isInvalid = ownInvalid || Boolean(field?.invalid);
|
|
74
110
|
const registerControl = field?.registerControl;
|
|
75
111
|
react.default.useEffect(() => {
|
|
76
112
|
if (!registerControl) return;
|
|
77
|
-
registerControl({
|
|
113
|
+
registerControl(registrationId, {
|
|
78
114
|
id,
|
|
79
115
|
disabled: Boolean(disabled),
|
|
80
116
|
invalid: ownInvalid,
|
|
81
117
|
labelable
|
|
82
118
|
});
|
|
83
|
-
return () => registerControl(null);
|
|
119
|
+
return () => registerControl(registrationId, null);
|
|
84
120
|
}, [
|
|
85
121
|
registerControl,
|
|
122
|
+
registrationId,
|
|
86
123
|
id,
|
|
87
124
|
disabled,
|
|
88
125
|
ownInvalid,
|
|
@@ -91,6 +128,7 @@ var useFieldControl = ({ id, invalid, disabled, "aria-describedby": describedBy,
|
|
|
91
128
|
const describedByIds = [
|
|
92
129
|
field?.errorId,
|
|
93
130
|
field?.descriptionId,
|
|
131
|
+
field?.hintId,
|
|
94
132
|
describedBy
|
|
95
133
|
].filter(Boolean).join(" ") || void 0;
|
|
96
134
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldContext.cjs","names":["React"],"sources":["../../../components/Field/FieldContext.ts"],"sourcesContent":["import React from 'react';\n\ntype FieldControlState = { id?: string; disabled: boolean; invalid: boolean; labelable: boolean };\n\nexport type FieldContextValue = {\n controlId?: string;\n labelId?: string;\n descriptionId?: string;\n errorId?: string;\n invalid: boolean;\n disabled: boolean;\n registerControl: (state: FieldControlState | null) => void;\n};\n\nexport const FieldContext = React.createContext<FieldContextValue | null>(null);\n\nexport const useFieldContext = () => React.useContext(FieldContext);\n\nexport type FieldControlOptions = {\n id?: string;\n invalid?: boolean;\n disabled?: boolean;\n 'aria-describedby'?: string;\n 'aria-invalid'?: React.AriaAttributes['aria-invalid'];\n /** Set to false when the control is not a labelable element, such as a radio group. */\n labelable?: boolean;\n};\n\nexport type FieldLabelVariant = 'invalid' | 'subtle' | 'contrast' | 'default';\n\nexport type FieldLabelProps = {\n variant: FieldLabelVariant;\n htmlFor?: string;\n id: string;\n};\n\nexport type FieldBaseProps = {\n id?: string;\n label?: React.ReactNode | ((props: FieldLabelProps) => React.ReactNode);\n description?: React.ReactNode;\n error?: React.ReactNode;\n invalid?: boolean;\n disabled?: boolean;\n announceError?: boolean;\n labelPosition?: 'top' | 'end';\n children?: React.ReactNode;\n};\n\nconst hasContent = (node: React.ReactNode) =>\n node !== undefined && node !== null && node !== false && node !== '';\n\nexport const useFieldRoot = ({\n id,\n label,\n description,\n error,\n invalid,\n disabled,\n}: FieldBaseProps) => {\n const outerContext = useFieldContext();\n const generatedId = React.useId();\n const hasLabel = typeof label === 'function' || hasContent(label);\n const hasDescription = hasContent(description);\n const hasError = hasContent(error);\n const isInvalid = Boolean(invalid) || hasError;\n\n const [control, setControl] = React.useState<FieldControlState | null>(null);\n const registerControl = React.useCallback((next: FieldControlState | null) => {\n setControl((prev) =>\n prev?.id === next?.id &&\n prev?.disabled === next?.disabled &&\n prev?.invalid === next?.invalid &&\n prev?.labelable === next?.labelable\n ? prev\n : next,\n );\n }, []);\n const controlId = control?.id ?? id ?? (hasLabel ? `${generatedId}-control` : undefined);\n const labelFor = control?.labelable === false ? undefined : controlId;\n\n const [hasFocus, setHasFocus] = React.useState(false);\n const onFocus = React.useCallback(() => setHasFocus(true), []);\n const onBlur = React.useCallback(() => setHasFocus(false), []);\n\n const labelVariant: FieldLabelVariant = React.useMemo(() => {\n if (disabled || control?.disabled) {\n return 'subtle';\n }\n if (isInvalid || control?.invalid) {\n return 'invalid';\n }\n if (hasFocus) {\n return 'contrast';\n }\n return 'default';\n }, [disabled, isInvalid, hasFocus, control?.disabled, control?.invalid]);\n\n const ownContext: FieldContextValue = React.useMemo(\n () => ({\n controlId,\n labelId: hasLabel ? `${generatedId}-label` : undefined,\n descriptionId: hasDescription ? `${generatedId}-description` : undefined,\n errorId: hasError ? `${generatedId}-error` : undefined,\n invalid: isInvalid,\n disabled: Boolean(disabled),\n registerControl,\n }),\n [\n controlId,\n generatedId,\n hasLabel,\n hasDescription,\n hasError,\n isInvalid,\n disabled,\n registerControl,\n ],\n );\n\n // A Field with no label, description or error inside another Field keeps the outer one.\n const context =\n outerContext && !hasLabel && !hasDescription && !hasError ? outerContext : ownContext;\n\n return { context, labelFor, labelVariant, hasLabel, hasDescription, hasError, onFocus, onBlur };\n};\n\n/**\n * Gives a form control the id, `aria-describedby`, `aria-invalid` and `disabled` of the `Field` around it,\n * and gives its own id, `disabled` and invalid state to that `Field`.\n * Outside a `Field`, it only sets `aria-invalid` from `invalid`.\n */\nexport const useFieldControl = ({\n id,\n invalid,\n disabled,\n 'aria-describedby': describedBy,\n 'aria-invalid': ariaInvalid,\n labelable = true,\n}: FieldControlOptions) => {\n const field = useFieldContext();\n const ownInvalid = Boolean(invalid || ariaInvalid === true || ariaInvalid === 'true');\n const isInvalid = ownInvalid || Boolean(field?.invalid);\n const registerControl = field?.registerControl;\n\n React.useEffect(() => {\n if (!registerControl) {\n return undefined;\n }\n registerControl({ id, disabled: Boolean(disabled), invalid: ownInvalid, labelable });\n return () => registerControl(null);\n }, [registerControl, id, disabled, ownInvalid, labelable]);\n const describedByIds =\n [field?.errorId, field?.descriptionId, describedBy].filter(Boolean).join(' ') || undefined;\n\n return {\n id: id ?? field?.controlId,\n labelId: field?.labelId,\n invalid: isInvalid,\n disabled: disabled || field?.disabled || undefined,\n 'aria-describedby': describedByIds,\n 'aria-invalid': isInvalid ? true : ariaInvalid,\n };\n};\n\nconst ANNOUNCE_DELAY = 1000;\n\n/**\n * Returns the text of the error, after the text of the label when there is one, once it has not\n * changed for a short time, so that a screen reader reads it after the echo of the typed text.\n */\nexport const useAnnouncedError = (enabled: boolean, errorId?: string, labelId?: string) => {\n const [announcedError, setAnnouncedError] = React.useState<string | null>(null);\n const lastTextRef = React.useRef<string | null | undefined>(undefined);\n const timeoutRef = React.useRef<ReturnType<typeof setTimeout>>();\n\n // Compares the rendered text, so that a new JSX error with the same text does not restart the delay.\n React.useEffect(() => {\n const text =\n (enabled && errorId && document.getElementById(errorId)?.textContent?.trim()) || null;\n if (text === lastTextRef.current) {\n return;\n }\n lastTextRef.current = text;\n clearTimeout(timeoutRef.current);\n timeoutRef.current = setTimeout(\n () => {\n const fieldName = labelId\n ? document.getElementById(labelId)?.textContent?.trim()\n : undefined;\n setAnnouncedError(text !== null && fieldName ? `${fieldName}: ${text}` : text);\n },\n text === null ? 0 : ANNOUNCE_DELAY,\n );\n });\n\n React.useEffect(\n () => () => {\n clearTimeout(timeoutRef.current);\n lastTextRef.current = undefined;\n },\n [],\n );\n\n return announcedError;\n};\n"],"mappings":";;;;AAcA,IAAa,eAAeA,MAAAA,QAAM,cAAwC,IAAI;AAE9E,IAAa,wBAAwBA,MAAAA,QAAM,WAAW,YAAY;AAgClE,IAAM,cAAc,SAClB,SAAS,KAAA,KAAa,SAAS,QAAQ,SAAS,SAAS,SAAS;AAEpE,IAAa,gBAAgB,EAC3B,IACA,OACA,aACA,OACA,SACA,eACoB;CACpB,MAAM,eAAe,gBAAgB;CACrC,MAAM,cAAcA,MAAAA,QAAM,MAAM;CAChC,MAAM,WAAW,OAAO,UAAU,cAAc,WAAW,KAAK;CAChE,MAAM,iBAAiB,WAAW,WAAW;CAC7C,MAAM,WAAW,WAAW,KAAK;CACjC,MAAM,YAAY,QAAQ,OAAO,KAAK;CAEtC,MAAM,CAAC,SAAS,cAAcA,MAAAA,QAAM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AAO,IAAI,cACtB;CACF,CAAC;CAED,MAAA,QAAM,sBACQ;EACV,aAAa,WAAW,OAAO;EAC/B,YAAY,UAAU,KAAA;CACxB,GACA,CAAC,CACH;CAEA,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"FieldContext.cjs","names":["React"],"sources":["../../../components/Field/FieldContext.ts"],"sourcesContent":["import React from 'react';\n\nimport { warnOnce } from '../../utils/warnOnce';\n\ntype MessageSize = '0' | '1' | '2' | '3';\n\ntype FieldControlState = { id?: string; disabled: boolean; invalid: boolean; labelable: boolean };\n\nexport type FieldContextValue = {\n controlId?: string;\n labelId?: string;\n descriptionId?: string;\n errorId?: string;\n hintId?: string;\n messageSize: MessageSize;\n invalid: boolean;\n disabled: boolean;\n registerControl: (key: string, state: FieldControlState | null) => void;\n};\n\nexport const FieldContext = React.createContext<FieldContextValue | null>(null);\n\nexport const useFieldContext = () => React.useContext(FieldContext);\n\nexport type FieldControlOptions = {\n id?: string;\n invalid?: boolean;\n disabled?: boolean;\n 'aria-describedby'?: string;\n 'aria-invalid'?: React.AriaAttributes['aria-invalid'];\n /** Set to false when the control is not a labelable element, such as a radio group. */\n labelable?: boolean;\n};\n\nexport type FieldLabelVariant = 'invalid' | 'subtle' | 'contrast' | 'default';\n\nexport type FieldLabelProps = {\n variant: FieldLabelVariant;\n htmlFor?: string;\n id: string;\n};\n\nexport type FieldBaseProps = {\n id?: string;\n label?: React.ReactNode | ((props: FieldLabelProps) => React.ReactNode);\n /** Text under the label, for what the field is for. */\n hint?: React.ReactNode;\n description?: React.ReactNode;\n error?: React.ReactNode;\n invalid?: boolean;\n disabled?: boolean;\n announceError?: boolean;\n /** `start` puts the label and the hint in a column before the control, and wraps under it when space is short. */\n labelPosition?: 'top' | 'start' | 'end';\n /** The text size of the hint, the description and the error. A Field inside another Field takes its size. */\n messageSize?: MessageSize;\n /**\n * For a field of more than one control: the field becomes a group named by the label and described by\n * the hint, the description and the error. Give each control its own name, and its own error with an inner Field.\n */\n group?: boolean;\n children?: React.ReactNode;\n};\n\nconst hasContent = (node: React.ReactNode) =>\n node !== undefined && node !== null && node !== false && node !== '';\n\nconst noop = () => {};\n\nconst MULTIPLE_CONTROLS_WARNING =\n 'Field: more than one control is in this Field, and its label points to one of them only. Use group, or one Field per control.';\n\nexport const useFieldRoot = ({\n id,\n label,\n hint,\n description,\n error,\n invalid,\n disabled,\n messageSize,\n group = false,\n}: FieldBaseProps) => {\n const outerContext = useFieldContext();\n const generatedId = React.useId();\n const hasLabel = typeof label === 'function' || hasContent(label);\n const hasHint = hasContent(hint);\n const resolvedMessageSize = messageSize ?? outerContext?.messageSize ?? '0';\n const hasDescription = hasContent(description);\n const hasError = hasContent(error);\n const isInvalid = Boolean(invalid) || hasError;\n const isDisabled = Boolean(disabled) || Boolean(outerContext?.disabled);\n\n const [control, setControl] = React.useState<FieldControlState | null>(null);\n const controlsRef = React.useRef(new Map<string, FieldControlState>());\n const registerControl = React.useCallback((key: string, state: FieldControlState | null) => {\n const controls = controlsRef.current;\n if (state) {\n controls.set(key, state);\n } else {\n controls.delete(key);\n }\n if (controls.size > 1) {\n warnOnce(MULTIPLE_CONTROLS_WARNING);\n }\n const next = controls.values().next().value ?? null;\n setControl((prev) =>\n prev?.id === next?.id &&\n prev?.disabled === next?.disabled &&\n prev?.invalid === next?.invalid &&\n prev?.labelable === next?.labelable\n ? prev\n : next,\n );\n }, []);\n const controlId = control?.id ?? id ?? (hasLabel ? `${generatedId}-control` : undefined);\n // The label points to a control only once one is there, so it never points to a missing id.\n const labelFor = group\n ? undefined\n : control\n ? control.labelable === false\n ? undefined\n : controlId\n : id;\n\n const [hasFocus, setHasFocus] = React.useState(false);\n const onFocus = React.useCallback(() => setHasFocus(true), []);\n const onBlur = React.useCallback(() => setHasFocus(false), []);\n\n const labelVariant: FieldLabelVariant = React.useMemo(() => {\n if (isDisabled || control?.disabled) {\n return 'subtle';\n }\n if (isInvalid || control?.invalid) {\n return 'invalid';\n }\n if (hasFocus) {\n return 'contrast';\n }\n return 'default';\n }, [isDisabled, isInvalid, hasFocus, control?.disabled, control?.invalid]);\n\n const ownContext: FieldContextValue = React.useMemo(\n () => ({\n controlId,\n labelId: hasLabel ? `${generatedId}-label` : undefined,\n descriptionId: hasDescription ? `${generatedId}-description` : undefined,\n errorId: hasError ? `${generatedId}-error` : undefined,\n hintId: hasHint ? `${generatedId}-hint` : undefined,\n messageSize: resolvedMessageSize,\n invalid: isInvalid,\n disabled: isDisabled,\n registerControl,\n }),\n [\n controlId,\n generatedId,\n hasLabel,\n hasDescription,\n hasError,\n hasHint,\n resolvedMessageSize,\n isInvalid,\n isDisabled,\n registerControl,\n ],\n );\n\n // The controls of a group get only its disabled state: the group itself carries the name and the messages.\n const groupContext: FieldContextValue = React.useMemo(\n () => ({\n messageSize: resolvedMessageSize,\n invalid: false,\n disabled: isDisabled,\n registerControl: noop,\n }),\n [resolvedMessageSize, isDisabled],\n );\n\n const groupProps = group\n ? {\n role: 'group',\n 'aria-labelledby': ownContext.labelId,\n 'aria-describedby':\n [ownContext.errorId, ownContext.descriptionId, ownContext.hintId]\n .filter(Boolean)\n .join(' ') || undefined,\n }\n : {};\n\n // A Field with no label, hint, description or error inside another Field keeps the outer one.\n const context = group\n ? groupContext\n : outerContext && !hasLabel && !hasHint && !hasDescription && !hasError\n ? outerContext\n : ownContext;\n\n return {\n context,\n ids: ownContext,\n groupProps,\n messageSize: resolvedMessageSize,\n labelFor,\n labelVariant,\n hasLabel,\n hasHint,\n hasDescription,\n hasError,\n onFocus,\n onBlur,\n };\n};\n\n/**\n * Gives a form control the id, `aria-describedby`, `aria-invalid` and `disabled` of the `Field` around it,\n * and gives its own id, `disabled` and invalid state to that `Field`.\n * Outside a `Field`, it only sets `aria-invalid` from `invalid`.\n */\nexport const useFieldControl = ({\n id,\n invalid,\n disabled,\n 'aria-describedby': describedBy,\n 'aria-invalid': ariaInvalid,\n labelable = true,\n}: FieldControlOptions) => {\n const field = useFieldContext();\n const registrationId = React.useId();\n const ownInvalid = Boolean(invalid || ariaInvalid === true || ariaInvalid === 'true');\n const isInvalid = ownInvalid || Boolean(field?.invalid);\n const registerControl = field?.registerControl;\n\n React.useEffect(() => {\n if (!registerControl) {\n return undefined;\n }\n registerControl(registrationId, {\n id,\n disabled: Boolean(disabled),\n invalid: ownInvalid,\n labelable,\n });\n return () => registerControl(registrationId, null);\n }, [registerControl, registrationId, id, disabled, ownInvalid, labelable]);\n const describedByIds =\n [field?.errorId, field?.descriptionId, field?.hintId, describedBy].filter(Boolean).join(' ') ||\n undefined;\n\n return {\n id: id ?? field?.controlId,\n labelId: field?.labelId,\n invalid: isInvalid,\n disabled: disabled || field?.disabled || undefined,\n 'aria-describedby': describedByIds,\n 'aria-invalid': isInvalid ? true : ariaInvalid,\n };\n};\n\nconst ANNOUNCE_DELAY = 1000;\n\n/**\n * Returns the text of the error, after the text of the label when there is one, once it has not\n * changed for a short time, so that a screen reader reads it after the echo of the typed text.\n */\nexport const useAnnouncedError = (enabled: boolean, errorId?: string, labelId?: string) => {\n const [announcedError, setAnnouncedError] = React.useState<string | null>(null);\n const lastTextRef = React.useRef<string | null | undefined>(undefined);\n const timeoutRef = React.useRef<ReturnType<typeof setTimeout>>();\n\n // Compares the rendered text, so that a new JSX error with the same text does not restart the delay.\n React.useEffect(() => {\n const text =\n (enabled && errorId && document.getElementById(errorId)?.textContent?.trim()) || null;\n if (text === lastTextRef.current) {\n return;\n }\n lastTextRef.current = text;\n clearTimeout(timeoutRef.current);\n timeoutRef.current = setTimeout(\n () => {\n const fieldName = labelId\n ? document.getElementById(labelId)?.textContent?.trim()\n : undefined;\n setAnnouncedError(text !== null && fieldName ? `${fieldName}: ${text}` : text);\n },\n text === null ? 0 : ANNOUNCE_DELAY,\n );\n });\n\n React.useEffect(\n () => () => {\n clearTimeout(timeoutRef.current);\n lastTextRef.current = undefined;\n },\n [],\n );\n\n return announcedError;\n};\n"],"mappings":";;;;;AAoBA,IAAa,eAAeA,MAAAA,QAAM,cAAwC,IAAI;AA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,UAAU,iBACb;GACJ,MAAM,YAAY,UACd,SAAS,eAAe,OAAO,CAAC,EAAE,aAAa,KAAK,IACpD,KAAA;GACJ,kBAAkB,SAAS,QAAQ,YAAY,GAAG,UAAU,IAAI,SAAS,IAAI;EAC/E,GACA,SAAS,OAAO,IAAI,cACtB;CACF,CAAC;CAED,MAAA,QAAM,sBACQ;EACV,aAAa,WAAW,OAAO;EAC/B,YAAY,UAAU,KAAA;CACxB,GACA,CAAC,CACH;CAEA,OAAO;AACT"}
|
|
@@ -1,31 +1,43 @@
|
|
|
1
|
+
import { warnOnce } from "../../utils/warnOnce.js";
|
|
1
2
|
import React from "react";
|
|
2
3
|
// components/Field/FieldContext.ts
|
|
3
4
|
var FieldContext = React.createContext(null);
|
|
4
5
|
var useFieldContext = () => React.useContext(FieldContext);
|
|
5
6
|
var hasContent = (node) => node !== void 0 && node !== null && node !== false && node !== "";
|
|
6
|
-
var
|
|
7
|
+
var noop = () => {};
|
|
8
|
+
var MULTIPLE_CONTROLS_WARNING = "Field: more than one control is in this Field, and its label points to one of them only. Use group, or one Field per control.";
|
|
9
|
+
var useFieldRoot = ({ id, label, hint, description, error, invalid, disabled, messageSize, group = false }) => {
|
|
7
10
|
const outerContext = useFieldContext();
|
|
8
11
|
const generatedId = React.useId();
|
|
9
12
|
const hasLabel = typeof label === "function" || hasContent(label);
|
|
13
|
+
const hasHint = hasContent(hint);
|
|
14
|
+
const resolvedMessageSize = messageSize ?? outerContext?.messageSize ?? "0";
|
|
10
15
|
const hasDescription = hasContent(description);
|
|
11
16
|
const hasError = hasContent(error);
|
|
12
17
|
const isInvalid = Boolean(invalid) || hasError;
|
|
18
|
+
const isDisabled = Boolean(disabled) || Boolean(outerContext?.disabled);
|
|
13
19
|
const [control, setControl] = React.useState(null);
|
|
14
|
-
const
|
|
20
|
+
const controlsRef = React.useRef(/* @__PURE__ */ new Map());
|
|
21
|
+
const registerControl = React.useCallback((key, state) => {
|
|
22
|
+
const controls = controlsRef.current;
|
|
23
|
+
if (state) controls.set(key, state);
|
|
24
|
+
else controls.delete(key);
|
|
25
|
+
if (controls.size > 1) warnOnce(MULTIPLE_CONTROLS_WARNING);
|
|
26
|
+
const next = controls.values().next().value ?? null;
|
|
15
27
|
setControl((prev) => prev?.id === next?.id && prev?.disabled === next?.disabled && prev?.invalid === next?.invalid && prev?.labelable === next?.labelable ? prev : next);
|
|
16
28
|
}, []);
|
|
17
29
|
const controlId = control?.id ?? id ?? (hasLabel ? `${generatedId}-control` : void 0);
|
|
18
|
-
const labelFor = control
|
|
30
|
+
const labelFor = group ? void 0 : control ? control.labelable === false ? void 0 : controlId : id;
|
|
19
31
|
const [hasFocus, setHasFocus] = React.useState(false);
|
|
20
32
|
const onFocus = React.useCallback(() => setHasFocus(true), []);
|
|
21
33
|
const onBlur = React.useCallback(() => setHasFocus(false), []);
|
|
22
34
|
const labelVariant = React.useMemo(() => {
|
|
23
|
-
if (
|
|
35
|
+
if (isDisabled || control?.disabled) return "subtle";
|
|
24
36
|
if (isInvalid || control?.invalid) return "invalid";
|
|
25
37
|
if (hasFocus) return "contrast";
|
|
26
38
|
return "default";
|
|
27
39
|
}, [
|
|
28
|
-
|
|
40
|
+
isDisabled,
|
|
29
41
|
isInvalid,
|
|
30
42
|
hasFocus,
|
|
31
43
|
control?.disabled,
|
|
@@ -36,8 +48,10 @@ var useFieldRoot = ({ id, label, description, error, invalid, disabled }) => {
|
|
|
36
48
|
labelId: hasLabel ? `${generatedId}-label` : void 0,
|
|
37
49
|
descriptionId: hasDescription ? `${generatedId}-description` : void 0,
|
|
38
50
|
errorId: hasError ? `${generatedId}-error` : void 0,
|
|
51
|
+
hintId: hasHint ? `${generatedId}-hint` : void 0,
|
|
52
|
+
messageSize: resolvedMessageSize,
|
|
39
53
|
invalid: isInvalid,
|
|
40
|
-
disabled:
|
|
54
|
+
disabled: isDisabled,
|
|
41
55
|
registerControl
|
|
42
56
|
}), [
|
|
43
57
|
controlId,
|
|
@@ -45,15 +59,36 @@ var useFieldRoot = ({ id, label, description, error, invalid, disabled }) => {
|
|
|
45
59
|
hasLabel,
|
|
46
60
|
hasDescription,
|
|
47
61
|
hasError,
|
|
62
|
+
hasHint,
|
|
63
|
+
resolvedMessageSize,
|
|
48
64
|
isInvalid,
|
|
49
|
-
|
|
65
|
+
isDisabled,
|
|
50
66
|
registerControl
|
|
51
67
|
]);
|
|
68
|
+
const groupContext = React.useMemo(() => ({
|
|
69
|
+
messageSize: resolvedMessageSize,
|
|
70
|
+
invalid: false,
|
|
71
|
+
disabled: isDisabled,
|
|
72
|
+
registerControl: noop
|
|
73
|
+
}), [resolvedMessageSize, isDisabled]);
|
|
74
|
+
const groupProps = group ? {
|
|
75
|
+
role: "group",
|
|
76
|
+
"aria-labelledby": ownContext.labelId,
|
|
77
|
+
"aria-describedby": [
|
|
78
|
+
ownContext.errorId,
|
|
79
|
+
ownContext.descriptionId,
|
|
80
|
+
ownContext.hintId
|
|
81
|
+
].filter(Boolean).join(" ") || void 0
|
|
82
|
+
} : {};
|
|
52
83
|
return {
|
|
53
|
-
context: outerContext && !hasLabel && !hasDescription && !hasError ? outerContext : ownContext,
|
|
84
|
+
context: group ? groupContext : outerContext && !hasLabel && !hasHint && !hasDescription && !hasError ? outerContext : ownContext,
|
|
85
|
+
ids: ownContext,
|
|
86
|
+
groupProps,
|
|
87
|
+
messageSize: resolvedMessageSize,
|
|
54
88
|
labelFor,
|
|
55
89
|
labelVariant,
|
|
56
90
|
hasLabel,
|
|
91
|
+
hasHint,
|
|
57
92
|
hasDescription,
|
|
58
93
|
hasError,
|
|
59
94
|
onFocus,
|
|
@@ -67,20 +102,22 @@ var useFieldRoot = ({ id, label, description, error, invalid, disabled }) => {
|
|
|
67
102
|
*/
|
|
68
103
|
var useFieldControl = ({ id, invalid, disabled, "aria-describedby": describedBy, "aria-invalid": ariaInvalid, labelable = true }) => {
|
|
69
104
|
const field = useFieldContext();
|
|
105
|
+
const registrationId = React.useId();
|
|
70
106
|
const ownInvalid = Boolean(invalid || ariaInvalid === true || ariaInvalid === "true");
|
|
71
107
|
const isInvalid = ownInvalid || Boolean(field?.invalid);
|
|
72
108
|
const registerControl = field?.registerControl;
|
|
73
109
|
React.useEffect(() => {
|
|
74
110
|
if (!registerControl) return;
|
|
75
|
-
registerControl({
|
|
111
|
+
registerControl(registrationId, {
|
|
76
112
|
id,
|
|
77
113
|
disabled: Boolean(disabled),
|
|
78
114
|
invalid: ownInvalid,
|
|
79
115
|
labelable
|
|
80
116
|
});
|
|
81
|
-
return () => registerControl(null);
|
|
117
|
+
return () => registerControl(registrationId, null);
|
|
82
118
|
}, [
|
|
83
119
|
registerControl,
|
|
120
|
+
registrationId,
|
|
84
121
|
id,
|
|
85
122
|
disabled,
|
|
86
123
|
ownInvalid,
|
|
@@ -89,6 +126,7 @@ var useFieldControl = ({ id, invalid, disabled, "aria-describedby": describedBy,
|
|
|
89
126
|
const describedByIds = [
|
|
90
127
|
field?.errorId,
|
|
91
128
|
field?.descriptionId,
|
|
129
|
+
field?.hintId,
|
|
92
130
|
describedBy
|
|
93
131
|
].filter(Boolean).join(" ") || void 0;
|
|
94
132
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldContext.js","names":[],"sources":["../../../components/Field/FieldContext.ts"],"sourcesContent":["import React from 'react';\n\ntype FieldControlState = { id?: string; disabled: boolean; invalid: boolean; labelable: boolean };\n\nexport type FieldContextValue = {\n controlId?: string;\n labelId?: string;\n descriptionId?: string;\n errorId?: string;\n invalid: boolean;\n disabled: boolean;\n registerControl: (state: FieldControlState | null) => void;\n};\n\nexport const FieldContext = React.createContext<FieldContextValue | null>(null);\n\nexport const useFieldContext = () => React.useContext(FieldContext);\n\nexport type FieldControlOptions = {\n id?: string;\n invalid?: boolean;\n disabled?: boolean;\n 'aria-describedby'?: string;\n 'aria-invalid'?: React.AriaAttributes['aria-invalid'];\n /** Set to false when the control is not a labelable element, such as a radio group. */\n labelable?: boolean;\n};\n\nexport type FieldLabelVariant = 'invalid' | 'subtle' | 'contrast' | 'default';\n\nexport type FieldLabelProps = {\n variant: FieldLabelVariant;\n htmlFor?: string;\n id: string;\n};\n\nexport type FieldBaseProps = {\n id?: string;\n label?: React.ReactNode | ((props: FieldLabelProps) => React.ReactNode);\n description?: React.ReactNode;\n error?: React.ReactNode;\n invalid?: boolean;\n disabled?: boolean;\n announceError?: boolean;\n labelPosition?: 'top' | 'end';\n children?: React.ReactNode;\n};\n\nconst hasContent = (node: React.ReactNode) =>\n node !== undefined && node !== null && node !== false && node !== '';\n\nexport const useFieldRoot = ({\n id,\n label,\n description,\n error,\n invalid,\n disabled,\n}: FieldBaseProps) => {\n const outerContext = useFieldContext();\n const generatedId = React.useId();\n const hasLabel = typeof label === 'function' || hasContent(label);\n const hasDescription = hasContent(description);\n const hasError = hasContent(error);\n const isInvalid = Boolean(invalid) || hasError;\n\n const [control, setControl] = React.useState<FieldControlState | null>(null);\n const registerControl = React.useCallback((next: FieldControlState | null) => {\n setControl((prev) =>\n prev?.id === next?.id &&\n prev?.disabled === next?.disabled &&\n prev?.invalid === next?.invalid &&\n prev?.labelable === next?.labelable\n ? prev\n : next,\n );\n }, []);\n const controlId = control?.id ?? id ?? (hasLabel ? `${generatedId}-control` : undefined);\n const labelFor = control?.labelable === false ? undefined : controlId;\n\n const [hasFocus, setHasFocus] = React.useState(false);\n const onFocus = React.useCallback(() => setHasFocus(true), []);\n const onBlur = React.useCallback(() => setHasFocus(false), []);\n\n const labelVariant: FieldLabelVariant = React.useMemo(() => {\n if (disabled || control?.disabled) {\n return 'subtle';\n }\n if (isInvalid || control?.invalid) {\n return 'invalid';\n }\n if (hasFocus) {\n return 'contrast';\n }\n return 'default';\n }, [disabled, isInvalid, hasFocus, control?.disabled, control?.invalid]);\n\n const ownContext: FieldContextValue = React.useMemo(\n () => ({\n controlId,\n labelId: hasLabel ? `${generatedId}-label` : undefined,\n descriptionId: hasDescription ? `${generatedId}-description` : undefined,\n errorId: hasError ? `${generatedId}-error` : undefined,\n invalid: isInvalid,\n disabled: Boolean(disabled),\n registerControl,\n }),\n [\n controlId,\n generatedId,\n hasLabel,\n hasDescription,\n hasError,\n isInvalid,\n disabled,\n registerControl,\n ],\n );\n\n // A Field with no label, description or error inside another Field keeps the outer one.\n const context =\n outerContext && !hasLabel && !hasDescription && !hasError ? outerContext : ownContext;\n\n return { context, labelFor, labelVariant, hasLabel, hasDescription, hasError, onFocus, onBlur };\n};\n\n/**\n * Gives a form control the id, `aria-describedby`, `aria-invalid` and `disabled` of the `Field` around it,\n * and gives its own id, `disabled` and invalid state to that `Field`.\n * Outside a `Field`, it only sets `aria-invalid` from `invalid`.\n */\nexport const useFieldControl = ({\n id,\n invalid,\n disabled,\n 'aria-describedby': describedBy,\n 'aria-invalid': ariaInvalid,\n labelable = true,\n}: FieldControlOptions) => {\n const field = useFieldContext();\n const ownInvalid = Boolean(invalid || ariaInvalid === true || ariaInvalid === 'true');\n const isInvalid = ownInvalid || Boolean(field?.invalid);\n const registerControl = field?.registerControl;\n\n React.useEffect(() => {\n if (!registerControl) {\n return undefined;\n }\n registerControl({ id, disabled: Boolean(disabled), invalid: ownInvalid, labelable });\n return () => registerControl(null);\n }, [registerControl, id, disabled, ownInvalid, labelable]);\n const describedByIds =\n [field?.errorId, field?.descriptionId, describedBy].filter(Boolean).join(' ') || undefined;\n\n return {\n id: id ?? field?.controlId,\n labelId: field?.labelId,\n invalid: isInvalid,\n disabled: disabled || field?.disabled || undefined,\n 'aria-describedby': describedByIds,\n 'aria-invalid': isInvalid ? true : ariaInvalid,\n };\n};\n\nconst ANNOUNCE_DELAY = 1000;\n\n/**\n * Returns the text of the error, after the text of the label when there is one, once it has not\n * changed for a short time, so that a screen reader reads it after the echo of the typed text.\n */\nexport const useAnnouncedError = (enabled: boolean, errorId?: string, labelId?: string) => {\n const [announcedError, setAnnouncedError] = React.useState<string | null>(null);\n const lastTextRef = React.useRef<string | null | undefined>(undefined);\n const timeoutRef = React.useRef<ReturnType<typeof setTimeout>>();\n\n // Compares the rendered text, so that a new JSX error with the same text does not restart the delay.\n React.useEffect(() => {\n const text =\n (enabled && errorId && document.getElementById(errorId)?.textContent?.trim()) || null;\n if (text === lastTextRef.current) {\n return;\n }\n lastTextRef.current = text;\n clearTimeout(timeoutRef.current);\n timeoutRef.current = setTimeout(\n () => {\n const fieldName = labelId\n ? document.getElementById(labelId)?.textContent?.trim()\n : undefined;\n setAnnouncedError(text !== null && fieldName ? `${fieldName}: ${text}` : text);\n },\n text === null ? 0 : ANNOUNCE_DELAY,\n );\n });\n\n React.useEffect(\n () => () => {\n clearTimeout(timeoutRef.current);\n lastTextRef.current = undefined;\n },\n [],\n );\n\n return announcedError;\n};\n"],"mappings":";;AAcA,IAAa,eAAe,MAAM,cAAwC,IAAI;AAE9E,IAAa,wBAAwB,MAAM,WAAW,YAAY;AAgClE,IAAM,cAAc,SAClB,SAAS,KAAA,KAAa,SAAS,QAAQ,SAAS,SAAS,SAAS;AAEpE,IAAa,gBAAgB,EAC3B,IACA,OACA,aACA,OACA,SACA,eACoB;CACpB,MAAM,eAAe,gBAAgB;CACrC,MAAM,cAAc,MAAM,MAAM;CAChC,MAAM,WAAW,OAAO,UAAU,cAAc,WAAW,KAAK;CAChE,MAAM,iBAAiB,WAAW,WAAW;CAC7C,MAAM,WAAW,WAAW,KAAK;CACjC,MAAM,YAAY,QAAQ,OAAO,KAAK;CAEtC,MAAM,CAAC,SAAS,cAAc,MAAM,SAAmC,IAAI;CAC3E,MAAM,kBAAkB,MAAM,aAAa,SAAmC;EAC5E,YAAY,SACV,MAAM,OAAO,MAAM,MACnB,MAAM,aAAa,MAAM,YACzB,MAAM,YAAY,MAAM,WACxB,MAAM,cAAc,MAAM,YACtB,OACA,IACN;CACF,GAAG,CAAC,CAAC;CACL,MAAM,YAAY,SAAS,MAAM,OAAO,WAAW,GAAG,YAAY,YAAY,KAAA;CAC9E,MAAM,WAAW,SAAS,cAAc,QAAQ,KAAA,IAAY;CAE5D,MAAM,CAAC,UAAU,eAAe,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AAO;EAAS,OAAO;EAAe;CAAW,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,KAAK,KAAA;CAEnF,OAAO;EACL,IAAI,MAAM,OAAO;EACjB,SAAS,OAAO;EAChB,SAAS;EACT,UAAU,YAAY,OAAO,YAAY,KAAA;EACzC,oBAAoB;EACpB,gBAAgB,YAAY,OAAO;CACrC;AACF;AAEA,IAAM,iBAAiB;;;;;AAMvB,IAAa,qBAAqB,SAAkB,SAAkB,YAAqB;CACzF,MAAM,CAAC,gBAAgB,qBAAqB,MAAM,SAAwB,IAAI;CAC9E,MAAM,cAAc,MAAM,OAAkC,KAAA,CAAS;CACrE,MAAM,aAAa,MAAM,OAAsC;CAG/D,MAAM,gBAAgB;EACpB,MAAM,OACH,WAAW,WAAW,SAAS,eAAe,OAAO,CAAC,EAAE,aAAa,KAAK,KAAM;EACnF,IAAI,SAAS,YAAY,SACvB;EAEF,YAAY,UAAU;EACtB,aAAa,WAAW,OAAO;EAC/B,WAAW,UAAU,iBACb;GACJ,MAAM,YAAY,UACd,SAAS,eAAe,OAAO,CAAC,EAAE,aAAa,KAAK,IACpD,KAAA;GACJ,kBAAkB,SAAS,QAAQ,YAAY,GAAG,UAAU,IAAI,SAAS,IAAI;EAC/E,GACA,SAAS,OAAO,IAAI,cACtB;CACF,CAAC;CAED,MAAM,sBACQ;EACV,aAAa,WAAW,OAAO;EAC/B,YAAY,UAAU,KAAA;CACxB,GACA,CAAC,CACH;CAEA,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"FieldContext.js","names":[],"sources":["../../../components/Field/FieldContext.ts"],"sourcesContent":["import React from 'react';\n\nimport { warnOnce } from '../../utils/warnOnce';\n\ntype MessageSize = '0' | '1' | '2' | '3';\n\ntype FieldControlState = { id?: string; disabled: boolean; invalid: boolean; labelable: boolean };\n\nexport type FieldContextValue = {\n controlId?: string;\n labelId?: string;\n descriptionId?: string;\n errorId?: string;\n hintId?: string;\n messageSize: MessageSize;\n invalid: boolean;\n disabled: boolean;\n registerControl: (key: string, state: FieldControlState | null) => void;\n};\n\nexport const FieldContext = React.createContext<FieldContextValue | null>(null);\n\nexport const useFieldContext = () => React.useContext(FieldContext);\n\nexport type FieldControlOptions = {\n id?: string;\n invalid?: boolean;\n disabled?: boolean;\n 'aria-describedby'?: string;\n 'aria-invalid'?: React.AriaAttributes['aria-invalid'];\n /** Set to false when the control is not a labelable element, such as a radio group. */\n labelable?: boolean;\n};\n\nexport type FieldLabelVariant = 'invalid' | 'subtle' | 'contrast' | 'default';\n\nexport type FieldLabelProps = {\n variant: FieldLabelVariant;\n htmlFor?: string;\n id: string;\n};\n\nexport type FieldBaseProps = {\n id?: string;\n label?: React.ReactNode | ((props: FieldLabelProps) => React.ReactNode);\n /** Text under the label, for what the field is for. */\n hint?: React.ReactNode;\n description?: React.ReactNode;\n error?: React.ReactNode;\n invalid?: boolean;\n disabled?: boolean;\n announceError?: boolean;\n /** `start` puts the label and the hint in a column before the control, and wraps under it when space is short. */\n labelPosition?: 'top' | 'start' | 'end';\n /** The text size of the hint, the description and the error. A Field inside another Field takes its size. */\n messageSize?: MessageSize;\n /**\n * For a field of more than one control: the field becomes a group named by the label and described by\n * the hint, the description and the error. Give each control its own name, and its own error with an inner Field.\n */\n group?: boolean;\n children?: React.ReactNode;\n};\n\nconst hasContent = (node: React.ReactNode) =>\n node !== undefined && node !== null && node !== false && node !== '';\n\nconst noop = () => {};\n\nconst MULTIPLE_CONTROLS_WARNING =\n 'Field: more than one control is in this Field, and its label points to one of them only. Use group, or one Field per control.';\n\nexport const useFieldRoot = ({\n id,\n label,\n hint,\n description,\n error,\n invalid,\n disabled,\n messageSize,\n group = false,\n}: FieldBaseProps) => {\n const outerContext = useFieldContext();\n const generatedId = React.useId();\n const hasLabel = typeof label === 'function' || hasContent(label);\n const hasHint = hasContent(hint);\n const resolvedMessageSize = messageSize ?? outerContext?.messageSize ?? '0';\n const hasDescription = hasContent(description);\n const hasError = hasContent(error);\n const isInvalid = Boolean(invalid) || hasError;\n const isDisabled = Boolean(disabled) || Boolean(outerContext?.disabled);\n\n const [control, setControl] = React.useState<FieldControlState | null>(null);\n const controlsRef = React.useRef(new Map<string, FieldControlState>());\n const registerControl = React.useCallback((key: string, state: FieldControlState | null) => {\n const controls = controlsRef.current;\n if (state) {\n controls.set(key, state);\n } else {\n controls.delete(key);\n }\n if (controls.size > 1) {\n warnOnce(MULTIPLE_CONTROLS_WARNING);\n }\n const next = controls.values().next().value ?? null;\n setControl((prev) =>\n prev?.id === next?.id &&\n prev?.disabled === next?.disabled &&\n prev?.invalid === next?.invalid &&\n prev?.labelable === next?.labelable\n ? prev\n : next,\n );\n }, []);\n const controlId = control?.id ?? id ?? (hasLabel ? `${generatedId}-control` : undefined);\n // The label points to a control only once one is there, so it never points to a missing id.\n const labelFor = group\n ? undefined\n : control\n ? control.labelable === false\n ? undefined\n : controlId\n : id;\n\n const [hasFocus, setHasFocus] = React.useState(false);\n const onFocus = React.useCallback(() => setHasFocus(true), []);\n const onBlur = React.useCallback(() => setHasFocus(false), []);\n\n const labelVariant: FieldLabelVariant = React.useMemo(() => {\n if (isDisabled || control?.disabled) {\n return 'subtle';\n }\n if (isInvalid || control?.invalid) {\n return 'invalid';\n }\n if (hasFocus) {\n return 'contrast';\n }\n return 'default';\n }, [isDisabled, isInvalid, hasFocus, control?.disabled, control?.invalid]);\n\n const ownContext: FieldContextValue = React.useMemo(\n () => ({\n controlId,\n labelId: hasLabel ? `${generatedId}-label` : undefined,\n descriptionId: hasDescription ? `${generatedId}-description` : undefined,\n errorId: hasError ? `${generatedId}-error` : undefined,\n hintId: hasHint ? `${generatedId}-hint` : undefined,\n messageSize: resolvedMessageSize,\n invalid: isInvalid,\n disabled: isDisabled,\n registerControl,\n }),\n [\n controlId,\n generatedId,\n hasLabel,\n hasDescription,\n hasError,\n hasHint,\n resolvedMessageSize,\n isInvalid,\n isDisabled,\n registerControl,\n ],\n );\n\n // The controls of a group get only its disabled state: the group itself carries the name and the messages.\n const groupContext: FieldContextValue = React.useMemo(\n () => ({\n messageSize: resolvedMessageSize,\n invalid: false,\n disabled: isDisabled,\n registerControl: noop,\n }),\n [resolvedMessageSize, isDisabled],\n );\n\n const groupProps = group\n ? {\n role: 'group',\n 'aria-labelledby': ownContext.labelId,\n 'aria-describedby':\n [ownContext.errorId, ownContext.descriptionId, ownContext.hintId]\n .filter(Boolean)\n .join(' ') || undefined,\n }\n : {};\n\n // A Field with no label, hint, description or error inside another Field keeps the outer one.\n const context = group\n ? groupContext\n : outerContext && !hasLabel && !hasHint && !hasDescription && !hasError\n ? outerContext\n : ownContext;\n\n return {\n context,\n ids: ownContext,\n groupProps,\n messageSize: resolvedMessageSize,\n labelFor,\n labelVariant,\n hasLabel,\n hasHint,\n hasDescription,\n hasError,\n onFocus,\n onBlur,\n };\n};\n\n/**\n * Gives a form control the id, `aria-describedby`, `aria-invalid` and `disabled` of the `Field` around it,\n * and gives its own id, `disabled` and invalid state to that `Field`.\n * Outside a `Field`, it only sets `aria-invalid` from `invalid`.\n */\nexport const useFieldControl = ({\n id,\n invalid,\n disabled,\n 'aria-describedby': describedBy,\n 'aria-invalid': ariaInvalid,\n labelable = true,\n}: FieldControlOptions) => {\n const field = useFieldContext();\n const registrationId = React.useId();\n const ownInvalid = Boolean(invalid || ariaInvalid === true || ariaInvalid === 'true');\n const isInvalid = ownInvalid || Boolean(field?.invalid);\n const registerControl = field?.registerControl;\n\n React.useEffect(() => {\n if (!registerControl) {\n return undefined;\n }\n registerControl(registrationId, {\n id,\n disabled: Boolean(disabled),\n invalid: ownInvalid,\n labelable,\n });\n return () => registerControl(registrationId, null);\n }, [registerControl, registrationId, id, disabled, ownInvalid, labelable]);\n const describedByIds =\n [field?.errorId, field?.descriptionId, field?.hintId, describedBy].filter(Boolean).join(' ') ||\n undefined;\n\n return {\n id: id ?? field?.controlId,\n labelId: field?.labelId,\n invalid: isInvalid,\n disabled: disabled || field?.disabled || undefined,\n 'aria-describedby': describedByIds,\n 'aria-invalid': isInvalid ? true : ariaInvalid,\n };\n};\n\nconst ANNOUNCE_DELAY = 1000;\n\n/**\n * Returns the text of the error, after the text of the label when there is one, once it has not\n * changed for a short time, so that a screen reader reads it after the echo of the typed text.\n */\nexport const useAnnouncedError = (enabled: boolean, errorId?: string, labelId?: string) => {\n const [announcedError, setAnnouncedError] = React.useState<string | null>(null);\n const lastTextRef = React.useRef<string | null | undefined>(undefined);\n const timeoutRef = React.useRef<ReturnType<typeof setTimeout>>();\n\n // Compares the rendered text, so that a new JSX error with the same text does not restart the delay.\n React.useEffect(() => {\n const text =\n (enabled && errorId && document.getElementById(errorId)?.textContent?.trim()) || null;\n if (text === lastTextRef.current) {\n return;\n }\n lastTextRef.current = text;\n clearTimeout(timeoutRef.current);\n timeoutRef.current = setTimeout(\n () => {\n const fieldName = labelId\n ? document.getElementById(labelId)?.textContent?.trim()\n : undefined;\n setAnnouncedError(text !== null && fieldName ? `${fieldName}: ${text}` : text);\n },\n text === null ? 0 : ANNOUNCE_DELAY,\n );\n });\n\n React.useEffect(\n () => () => {\n clearTimeout(timeoutRef.current);\n lastTextRef.current = undefined;\n },\n [],\n );\n\n return announcedError;\n};\n"],"mappings":";;;AAoBA,IAAa,eAAe,MAAM,cAAwC,IAAI;AAE9E,IAAa,wBAAwB,MAAM,WAAW,YAAY;AA0ClE,IAAM,cAAc,SAClB,SAAS,KAAA,KAAa,SAAS,QAAQ,SAAS,SAAS,SAAS;AAEpE,IAAM,aAAa,CAAC;AAEpB,IAAM,4BACJ;AAEF,IAAa,gBAAgB,EAC3B,IACA,OACA,MACA,aACA,OACA,SACA,UACA,aACA,QAAQ,YACY;CACpB,MAAM,eAAe,gBAAgB;CACrC,MAAM,cAAc,MAAM,MAAM;CAChC,MAAM,WAAW,OAAO,UAAU,cAAc,WAAW,KAAK;CAChE,MAAM,UAAU,WAAW,IAAI;CAC/B,MAAM,sBAAsB,eAAe,cAAc,eAAe;CACxE,MAAM,iBAAiB,WAAW,WAAW;CAC7C,MAAM,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AAS,OAAO;EAAe,OAAO;EAAQ;CAAW,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,KAC3F,KAAA;CAEF,OAAO;EACL,IAAI,MAAM,OAAO;EACjB,SAAS,OAAO;EAChB,SAAS;EACT,UAAU,YAAY,OAAO,YAAY,KAAA;EACzC,oBAAoB;EACpB,gBAAgB,YAAY,OAAO;CACrC;AACF;AAEA,IAAM,iBAAiB;;;;;AAMvB,IAAa,qBAAqB,SAAkB,SAAkB,YAAqB;CACzF,MAAM,CAAC,gBAAgB,qBAAqB,MAAM,SAAwB,IAAI;CAC9E,MAAM,cAAc,MAAM,OAAkC,KAAA,CAAS;CACrE,MAAM,aAAa,MAAM,OAAsC;CAG/D,MAAM,gBAAgB;EACpB,MAAM,OACH,WAAW,WAAW,SAAS,eAAe,OAAO,CAAC,EAAE,aAAa,KAAK,KAAM;EACnF,IAAI,SAAS,YAAY,SACvB;EAEF,YAAY,UAAU;EACtB,aAAa,WAAW,OAAO;EAC/B,WAAW,UAAU,iBACb;GACJ,MAAM,YAAY,UACd,SAAS,eAAe,OAAO,CAAC,EAAE,aAAa,KAAK,IACpD,KAAA;GACJ,kBAAkB,SAAS,QAAQ,YAAY,GAAG,UAAU,IAAI,SAAS,IAAI;EAC/E,GACA,SAAS,OAAO,IAAI,cACtB;CACF,CAAC;CAED,MAAM,sBACQ;EACV,aAAa,WAAW,OAAO;EAC/B,YAAY,UAAU,KAAA;CACxB,GACA,CAAC,CACH;CAEA,OAAO;AACT"}
|
|
@@ -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 require_Button = require("../Button/Button.cjs");
|
|
3
4
|
const require_Elevation = require("../Elevation/Elevation.cjs");
|
|
4
5
|
const require_Flex = require("../Flex/Flex.cjs");
|
|
5
|
-
const require_Button = require("../Button/Button.cjs");
|
|
6
6
|
let react = require("react");
|
|
7
7
|
react = require_runtime.__toESM(react, 1);
|
|
8
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { styled } from "../../stitches.config.js";
|
|
2
|
+
import { BUTTON_BASE_STYLES } from "../Button/Button.js";
|
|
2
3
|
import { elevationVariants } from "../Elevation/Elevation.js";
|
|
3
4
|
import { Flex } from "../Flex/Flex.js";
|
|
4
|
-
import { BUTTON_BASE_STYLES } from "../Button/Button.js";
|
|
5
5
|
import React, { createContext, useContext, useMemo } from "react";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
// components/List/List.tsx
|