@mittwald/flow-react-components 1.5.0-next.2 → 1.5.0-next.21
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/AGENTS.md +14 -9
- package/USAGE.md +2 -0
- package/dist/assets/component-index.json +1 -1
- package/dist/assets/doc-properties.json +1 -1
- package/dist/css/all-layered.css +1 -1
- package/dist/css/all.css +1 -1
- package/dist/js/packages/components/src/components/Accordion/Accordion.module.mjs.map +1 -1
- package/dist/js/packages/components/src/components/ActionGroup/ActionGroup.mjs.map +1 -1
- package/dist/js/packages/components/src/components/ActionGroup/ActionGroup.module.mjs.map +1 -1
- package/dist/js/packages/components/src/components/Autocomplete/Autocomplete.mjs +14 -7
- package/dist/js/packages/components/src/components/Autocomplete/Autocomplete.mjs.map +1 -1
- package/dist/js/packages/components/src/components/Button/Button.mjs +5 -17
- package/dist/js/packages/components/src/components/Button/Button.mjs.map +1 -1
- package/dist/js/packages/components/src/components/Button/Button.module.mjs.map +1 -1
- package/dist/js/packages/components/src/components/CartesianChart/components/YAxis/YAxis.mjs +5 -1
- package/dist/js/packages/components/src/components/CartesianChart/components/YAxis/YAxis.mjs.map +1 -1
- package/dist/js/packages/components/src/components/Checkbox/Checkbox.mjs +3 -3
- package/dist/js/packages/components/src/components/Checkbox/Checkbox.mjs.map +1 -1
- package/dist/js/packages/components/src/components/CheckboxButton/CheckboxButton.mjs +3 -3
- package/dist/js/packages/components/src/components/CheckboxButton/CheckboxButton.mjs.map +1 -1
- package/dist/js/packages/components/src/components/CheckboxGroup/CheckboxGroup.mjs +3 -3
- package/dist/js/packages/components/src/components/CheckboxGroup/CheckboxGroup.mjs.map +1 -1
- package/dist/js/packages/components/src/components/CodeEditor/CodeEditor.mjs +24 -10
- package/dist/js/packages/components/src/components/CodeEditor/CodeEditor.mjs.map +1 -1
- package/dist/js/packages/components/src/components/ComboBox/ComboBox.mjs +3 -3
- package/dist/js/packages/components/src/components/ComboBox/ComboBox.mjs.map +1 -1
- package/dist/js/packages/components/src/components/ContextMenu/ContextMenu.mjs +5 -1
- package/dist/js/packages/components/src/components/ContextMenu/ContextMenu.mjs.map +1 -1
- package/dist/js/packages/components/src/components/DatePicker/DatePicker.mjs +6 -5
- package/dist/js/packages/components/src/components/DatePicker/DatePicker.mjs.map +1 -1
- package/dist/js/packages/components/src/components/DateRangePicker/DateRangePicker.mjs +4 -3
- package/dist/js/packages/components/src/components/DateRangePicker/DateRangePicker.mjs.map +1 -1
- package/dist/js/packages/components/src/components/FieldError/FieldError.mjs +40 -31
- package/dist/js/packages/components/src/components/FieldError/FieldError.mjs.map +1 -1
- package/dist/js/packages/components/src/components/FileDropZone/FileDropZone.mjs +8 -6
- package/dist/js/packages/components/src/components/FileDropZone/FileDropZone.mjs.map +1 -1
- package/dist/js/packages/components/src/components/FileField/FileField.mjs +3 -3
- package/dist/js/packages/components/src/components/FileField/FileField.mjs.map +1 -1
- package/dist/js/packages/components/src/components/Flex/Flex.mjs +5 -5
- package/dist/js/packages/components/src/components/Flex/Flex.mjs.map +1 -1
- package/dist/js/packages/components/src/components/Link/Link.mjs.map +1 -1
- package/dist/js/packages/components/src/components/List/components/ListItemView/ListItemView.module.mjs.map +1 -1
- package/dist/js/packages/components/src/components/NumberField/NumberField.mjs +3 -2
- package/dist/js/packages/components/src/components/NumberField/NumberField.mjs.map +1 -1
- package/dist/js/packages/components/src/components/PasswordCreationField/PasswordCreationField.mjs +42 -19
- package/dist/js/packages/components/src/components/PasswordCreationField/PasswordCreationField.mjs.map +1 -1
- package/dist/js/packages/components/src/components/PasswordCreationField/components/ComplexityIndicator/ComplexityIndicator.mjs +2 -2
- package/dist/js/packages/components/src/components/PasswordCreationField/components/ComplexityIndicator/ComplexityIndicator.mjs.map +1 -1
- package/dist/js/packages/components/src/components/PasswordCreationField/lib/usePolicyValidationResult.mjs +12 -0
- package/dist/js/packages/components/src/components/PasswordCreationField/lib/usePolicyValidationResult.mjs.map +1 -1
- package/dist/js/packages/components/src/components/RadioGroup/RadioGroup.mjs +3 -2
- package/dist/js/packages/components/src/components/RadioGroup/RadioGroup.mjs.map +1 -1
- package/dist/js/packages/components/src/components/Rating/Rating.mjs +3 -2
- package/dist/js/packages/components/src/components/Rating/Rating.mjs.map +1 -1
- package/dist/js/packages/components/src/components/SearchField/SearchField.mjs +3 -3
- package/dist/js/packages/components/src/components/SearchField/SearchField.mjs.map +1 -1
- package/dist/js/packages/components/src/components/SegmentedControl/SegmentedControl.mjs +3 -2
- package/dist/js/packages/components/src/components/SegmentedControl/SegmentedControl.mjs.map +1 -1
- package/dist/js/packages/components/src/components/Select/Select.mjs +3 -3
- package/dist/js/packages/components/src/components/Select/Select.mjs.map +1 -1
- package/dist/js/packages/components/src/components/Slider/Slider.mjs +8 -8
- package/dist/js/packages/components/src/components/Slider/Slider.mjs.map +1 -1
- package/dist/js/packages/components/src/components/Slider/Slider.module.mjs.map +1 -1
- package/dist/js/packages/components/src/components/Switch/Switch.mjs +3 -2
- package/dist/js/packages/components/src/components/Switch/Switch.mjs.map +1 -1
- package/dist/js/packages/components/src/components/TextArea/TextArea.mjs +3 -3
- package/dist/js/packages/components/src/components/TextArea/TextArea.mjs.map +1 -1
- package/dist/js/packages/components/src/components/TextField/TextField.mjs +3 -3
- package/dist/js/packages/components/src/components/TextField/TextField.mjs.map +1 -1
- package/dist/js/packages/components/src/components/TimeField/TimeField.mjs +5 -3
- package/dist/js/packages/components/src/components/TimeField/TimeField.mjs.map +1 -1
- package/dist/js/packages/components/src/integrations/react-hook-form/components/FormRootError/FormRootError.mjs +6 -3
- package/dist/js/packages/components/src/integrations/react-hook-form/components/FormRootError/FormRootError.mjs.map +1 -1
- package/dist/js/packages/components/src/lib/hooks/fieldErrorRenderedContext.mjs +16 -0
- package/dist/js/packages/components/src/lib/hooks/fieldErrorRenderedContext.mjs.map +1 -0
- package/dist/js/packages/components/src/lib/hooks/useFieldComponent.mjs +8 -7
- package/dist/js/packages/components/src/lib/hooks/useFieldComponent.mjs.map +1 -1
- package/dist/js/packages/components/src/lib/hooks/useFieldError.mjs +34 -21
- package/dist/js/packages/components/src/lib/hooks/useFieldError.mjs.map +1 -1
- package/dist/types/components/ActionGroup/ActionGroup.d.ts +3 -2
- package/dist/types/components/Button/Button.d.ts +7 -1
- package/dist/types/components/CartesianChart/components/YAxis/YAxis.d.ts +7 -0
- package/dist/types/components/FileField/FileField.d.ts +1 -1
- package/dist/types/components/Flex/Flex.d.ts +4 -0
- package/dist/types/components/Link/Link.d.ts +5 -1
- package/dist/types/components/PasswordCreationField/components/ComplexityIndicator/ComplexityIndicator.d.ts +5 -0
- package/dist/types/integrations/react-hook-form/components/FormRootError/FormRootError.d.ts +12 -2
- package/dist/types/lib/hooks/fieldErrorRenderedContext.d.ts +1 -0
- package/dist/types/lib/hooks/useFieldComponent.d.ts +15 -4
- package/dist/types/lib/hooks/useFieldError.d.ts +7 -1
- package/package.json +10 -9
|
@@ -11,16 +11,15 @@ import { useFieldComponent } from "../../lib/hooks/useFieldComponent.mjs";
|
|
|
11
11
|
import Slider_module_default from "./Slider.module.mjs";
|
|
12
12
|
import __locale_default from "../../../../../_virtual/_19.locale.mjs";
|
|
13
13
|
import clsx from "clsx";
|
|
14
|
-
import "react";
|
|
15
|
-
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
16
15
|
import { useObjectRef } from "@react-aria/utils";
|
|
17
16
|
import * as Aria from "react-aria-components";
|
|
18
17
|
//#region src/components/Slider/Slider.tsx
|
|
19
18
|
/** @flr-generate all */
|
|
20
19
|
var Slider = flowComponent("Slider", (props) => {
|
|
21
|
-
const { className, children, name, isDisabled, defaultValue, showInitialMarker, isReadOnly, ref, step, sliderOnly, ...rest } = props;
|
|
20
|
+
const { className, children, name, isDisabled, defaultValue, showInitialMarker, isReadOnly, ref, step, sliderOnly, "aria-describedby": ignoredAriaDescribedBy, ...rest } = props;
|
|
22
21
|
const rootClassName = clsx(Slider_module_default.slider, isDisabled && Slider_module_default.disabled, className);
|
|
23
|
-
const { FieldErrorView, FieldErrorCaptureContext, fieldPropsContext,
|
|
22
|
+
const { FieldErrorView, FieldErrorCaptureContext, fieldPropsContext, wrapperProps, controlProps } = useFieldComponent(props, "Slider");
|
|
24
23
|
const stringFormatter = useLocalizedStringFormatter(__locale_default, "Slider");
|
|
25
24
|
const objectRef = useObjectRef(ref);
|
|
26
25
|
const propsContext = {
|
|
@@ -35,7 +34,7 @@ var Slider = flowComponent("Slider", (props) => {
|
|
|
35
34
|
}
|
|
36
35
|
};
|
|
37
36
|
return /* @__PURE__ */ jsx("div", {
|
|
38
|
-
|
|
37
|
+
className: wrapperProps.className,
|
|
39
38
|
children: /* @__PURE__ */ jsx(Aria.Slider, {
|
|
40
39
|
...rest,
|
|
41
40
|
className: rootClassName,
|
|
@@ -72,7 +71,7 @@ var Slider = flowComponent("Slider", (props) => {
|
|
|
72
71
|
size: "s"
|
|
73
72
|
} },
|
|
74
73
|
children: [
|
|
75
|
-
!sliderOnly && /* @__PURE__ */ jsxs(Fragment
|
|
74
|
+
!sliderOnly && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Button, {
|
|
76
75
|
onPress: () => state.decrementThumb(0, step),
|
|
77
76
|
"aria-label": stringFormatter.format("decrement"),
|
|
78
77
|
className: Slider_module_default.decrement,
|
|
@@ -85,14 +84,15 @@ var Slider = flowComponent("Slider", (props) => {
|
|
|
85
84
|
})] }),
|
|
86
85
|
/* @__PURE__ */ jsx("div", {
|
|
87
86
|
className: Slider_module_default.fill,
|
|
88
|
-
style: {
|
|
87
|
+
style: { "--slider--value": state.getThumbPercent(0) }
|
|
89
88
|
}),
|
|
90
89
|
showInitialMarker && defaultValue && typeof defaultValue === "number" && /* @__PURE__ */ jsx("div", {
|
|
91
90
|
className: Slider_module_default.initialMarker,
|
|
92
|
-
style: {
|
|
91
|
+
style: { "--slider--initial-value": state.getValuePercent(defaultValue) }
|
|
93
92
|
}),
|
|
94
93
|
/* @__PURE__ */ jsx(Aria.SliderThumb, {
|
|
95
94
|
inputRef: objectRef,
|
|
95
|
+
"aria-describedby": controlProps["aria-describedby"],
|
|
96
96
|
name,
|
|
97
97
|
className: Slider_module_default.handle,
|
|
98
98
|
isDisabled: isReadOnly
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Slider.mjs","names":[],"sources":["../../../../../../../src/components/Slider/Slider.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"Slider.mjs","names":[],"sources":["../../../../../../../src/components/Slider/Slider.tsx"],"sourcesContent":["import type { PropsWithChildren } from \"react\";\nimport type { FlowComponentProps } from \"@/lib/componentFactory/flowComponent\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\nimport * as Aria from \"react-aria-components\";\nimport clsx from \"clsx\";\nimport styles from \"./Slider.module.scss\";\nimport type { PropsContext } from \"@/lib/propsContext\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport { Button } from \"@/components/Button\";\nimport { IconMinus, IconPlus } from \"@/components/Icon/components/icons\";\nimport locales from \"./locales/*.locale.json\";\nimport { useLocalizedStringFormatter } from \"@/components/TranslationProvider/useLocalizedStringFormatter\";\nimport { useObjectRef } from \"@react-aria/utils\";\nimport { useFieldComponent } from \"@/lib/hooks/useFieldComponent\";\nimport { UiComponentTunnelExit } from \"@/components/UiComponentTunnel/UiComponentTunnelExit\";\n\nexport interface SliderProps\n extends\n FlowComponentProps<HTMLInputElement>,\n PropsWithChildren<Aria.SliderProps>,\n Pick<Aria.SliderThumbProps, \"name\"> {\n /** Whether the marker for the initial value should be visible */\n showInitialMarker?: boolean;\n /** Whether the component is read only. */\n isReadOnly?: boolean;\n /** Whether the component is invalid. */\n isInvalid?: boolean;\n /** Hide Buttons, Label and Value */\n sliderOnly?: boolean;\n}\n\n/** @flr-generate all */\nexport const Slider = flowComponent(\"Slider\", (props) => {\n const {\n className,\n children,\n name,\n isDisabled,\n defaultValue,\n showInitialMarker,\n isReadOnly,\n ref,\n step,\n sliderOnly,\n // Reaches the thumb through `controlProps` – react-aria would add it a\n // second time from the slider.\n \"aria-describedby\": ignoredAriaDescribedBy,\n ...rest\n } = props;\n\n const rootClassName = clsx(\n styles.slider,\n isDisabled && styles.disabled,\n className,\n );\n\n const {\n FieldErrorView,\n FieldErrorCaptureContext,\n fieldPropsContext,\n wrapperProps,\n controlProps,\n } = useFieldComponent(props, \"Slider\");\n\n const stringFormatter = useLocalizedStringFormatter(locales, \"Slider\");\n\n const objectRef = useObjectRef(ref);\n\n const propsContext: PropsContext = {\n ...fieldPropsContext,\n Label: {\n tunnel: {\n id: \"label\",\n component: \"Slider\",\n },\n ...fieldPropsContext.Label,\n className: styles.label,\n },\n };\n\n return (\n <div className={wrapperProps.className}>\n <Aria.Slider\n {...rest}\n className={rootClassName}\n isDisabled={isDisabled}\n defaultValue={defaultValue}\n step={step}\n >\n <PropsContextProvider props={propsContext}>\n <FieldErrorCaptureContext>{children}</FieldErrorCaptureContext>\n\n {!sliderOnly && (\n <div className={styles.text}>\n <Aria.SliderOutput className={styles.value} />{\" \"}\n <UiComponentTunnelExit id=\"label\" component=\"Slider\" />\n </div>\n )}\n\n <Aria.SliderTrack className={styles.track}>\n {({ state }) => (\n <PropsContextProvider\n props={{\n Button: {\n isPending: false,\n isFailed: false,\n isSucceeded: false,\n isReadOnly: isReadOnly,\n excludeFromTabOrder: true,\n isDisabled,\n variant: \"plain\",\n color: \"secondary\",\n size: \"s\",\n },\n }}\n >\n {!sliderOnly && (\n <>\n <Button\n onPress={() => state.decrementThumb(0, step)}\n aria-label={stringFormatter.format(\"decrement\")}\n className={styles.decrement}\n >\n <IconMinus />\n </Button>\n <Button\n onPress={() => state.incrementThumb(0, step)}\n aria-label={stringFormatter.format(\"increment\")}\n className={styles.increment}\n >\n <IconPlus />\n </Button>\n </>\n )}\n\n <div\n className={styles.fill}\n style={{\n \"--slider--value\": state.getThumbPercent(0),\n }}\n />\n\n {showInitialMarker &&\n defaultValue &&\n typeof defaultValue === \"number\" && (\n <div\n className={styles.initialMarker}\n style={{\n \"--slider--initial-value\":\n state.getValuePercent(defaultValue),\n }}\n />\n )}\n <Aria.SliderThumb\n inputRef={objectRef}\n aria-describedby={controlProps[\"aria-describedby\"]}\n name={name}\n className={styles.handle}\n isDisabled={isReadOnly}\n />\n </PropsContextProvider>\n )}\n </Aria.SliderTrack>\n <FieldErrorView />\n </PropsContextProvider>\n </Aria.Slider>\n </div>\n );\n});\n\nexport default Slider;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAgCA,IAAa,SAAS,cAAc,WAAW,UAAU;CACvD,MAAM,EACJ,WACA,UACA,MACA,YACA,cACA,mBACA,YACA,KACA,MACA,YAGA,oBAAoB,wBACpB,GAAG,SACD;CAEJ,MAAM,gBAAgB,KACpB,sBAAO,QACP,cAAc,sBAAO,UACrB,SACF;CAEA,MAAM,EACJ,gBACA,0BACA,mBACA,cACA,iBACE,kBAAkB,OAAO,QAAQ;CAErC,MAAM,kBAAkB,4BAA4B,kBAAS,QAAQ;CAErE,MAAM,YAAY,aAAa,GAAG;CAElC,MAAM,eAA6B;EACjC,GAAG;EACH,OAAO;GACL,QAAQ;IACN,IAAI;IACJ,WAAW;GACb;GACA,GAAG,kBAAkB;GACrB,WAAW,sBAAO;EACpB;CACF;CAEA,OACE,oBAAC,OAAD;EAAK,WAAW,aAAa;EAC3B,UAAA,oBAAC,KAAK,QAAN;GACE,GAAI;GACJ,WAAW;GACC;GACE;GACR;GAEN,UAAA,qBAAC,sBAAD;IAAsB,OAAO;IAA7B,UAAA;KACE,oBAAC,0BAAD,EAA2B,SAAmC,CAAA;KAE7D,CAAC,cACA,qBAAC,OAAD;MAAK,WAAW,sBAAO;MAAvB,UAAA;OACE,oBAAC,KAAK,cAAN,EAAmB,WAAW,sBAAO,MAAQ,CAAA;OAAE;OAC/C,oBAAC,uBAAD;QAAuB,IAAG;QAAQ,WAAU;OAAU,CAAA;MACnD;;KAGP,oBAAC,KAAK,aAAN;MAAkB,WAAW,sBAAO;MAChC,WAAA,EAAE,YACF,qBAAC,sBAAD;OACE,OAAO,EACL,QAAQ;QACN,WAAW;QACX,UAAU;QACV,aAAa;QACD;QACZ,qBAAqB;QACrB;QACA,SAAS;QACT,OAAO;QACP,MAAM;OACR,EACF;OAbF,UAAA;QAeG,CAAC,cACA,qBAAA,UAAA,EAAA,UAAA,CACE,oBAAC,QAAD;SACE,eAAe,MAAM,eAAe,GAAG,IAAI;SAC3C,cAAY,gBAAgB,OAAO,WAAW;SAC9C,WAAW,sBAAO;SAElB,UAAA,oBAAC,WAAD,CAAY,CAAA;QACN,CAAA,GACR,oBAAC,QAAD;SACE,eAAe,MAAM,eAAe,GAAG,IAAI;SAC3C,cAAY,gBAAgB,OAAO,WAAW;SAC9C,WAAW,sBAAO;SAElB,UAAA,oBAAC,UAAD,CAAW,CAAA;QACL,CAAA,CACR,EAAA,CAAA;QAGJ,oBAAC,OAAD;SACE,WAAW,sBAAO;SAClB,OAAO,EACL,mBAAmB,MAAM,gBAAgB,CAAC,EAC5C;QACD,CAAA;QAEA,qBACC,gBACA,OAAO,iBAAiB,YACtB,oBAAC,OAAD;SACE,WAAW,sBAAO;SAClB,OAAO,EACL,2BACE,MAAM,gBAAgB,YAAY,EACtC;QACD,CAAA;QAEL,oBAAC,KAAK,aAAN;SACE,UAAU;SACV,oBAAkB,aAAa;SACzB;SACN,WAAW,sBAAO;SAClB,YAAY;QACb,CAAA;OACmB;;KAER,CAAA;KAClB,oBAAC,gBAAD,CAAiB,CAAA;IACG;;EACX,CAAA;CACV,CAAA;AAET,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Slider.module.mjs","names":[],"sources":["../../../../../../../src/components/Slider/Slider.module.scss"],"sourcesContent":["@use \"@/styles/mixins/focus\";\n\n.slider {\n display: flex;\n flex-direction: column;\n width: 100%;\n row-gap: var(--slider--spacing-y);\n\n --button-size: calc(\n var(--button--line-height-s) + var(--button--padding-s-y) * 2\n );\n\n .text {\n text-align: center;\n align-items: end;\n padding-inline: calc(var(--button-size) + var(--slider--spacing-x));\n padding-top: calc(var(--slider--spacing-y) / 2);\n\n .value {\n font-size: var(--font-size-text--s);\n font-weight: var(--slider--value-font-weight);\n }\n\n .label {\n margin: 0;\n display: inline-flex;\n column-gap: var(--label--spacing);\n }\n }\n\n .track {\n grid-area: track;\n position: relative;\n height: var(--slider--track-height);\n background-color: var(--slider--track-color--default);\n width: 100%;\n border-radius: var(--slider--corner-radius);\n border: var(--slider--track-border-width) var(--slider--track-border-style)\n var(--slider--track-border-color--default);\n }\n\n .fill {\n position: absolute;\n height: var(--slider--track-height);\n background-color: var(--slider--color--default);\n top: calc(50% - var(--slider--track-height) / 2);\n border-radius: var(--slider--corner-radius);\n }\n\n .initialMarker {\n position: absolute;\n height: var(--slider--initial-marker-height);\n width: var(--slider--initial-marker-border-width);\n background-color: var(--slider--color--default);\n top: calc(50% - var(--slider--initial-marker-height) / 2);\n border-radius: var(--slider--corner-radius);\n }\n\n .handle {\n width: var(--slider--handle-size);\n height: var(--slider--handle-size);\n border-radius: var(--slider--handle-corner-radius);\n background-color: var(--slider--handle-fill-color);\n border: var(--slider--handle-border-width) var(--slider--track-border-style)\n var(--slider--color--default);\n forced-color-adjust: none;\n top: 50%;\n transition-property: background-color;\n transition-duration: var(--transition--duration--default);\n\n &[data-dragging],\n &[data-focus-visible] {\n background-color: var(--slider--color--default);\n }\n\n &[data-focus-visible] {\n @include focus.focus;\n\n & {\n outline-offset: var(--size-px--xs);\n }\n }\n }\n\n .increment,\n .decrement {\n position: absolute;\n top: calc((var(--slider--spacing-y) + var(--button-size)) * -1);\n }\n\n .increment {\n inset-inline-end: 0;\n }\n\n .decrement {\n inset-inline-start: 0;\n }\n\n &.disabled {\n .track {\n background-color: var(--slider--track-color--disabled);\n border-color: var(--slider--track-border-color--disabled);\n }\n\n .fill {\n background-color: var(--slider--color--disabled);\n }\n\n .handle {\n border-color: var(--slider--color--disabled);\n }\n\n .text {\n color: var(--text--color--disabled);\n }\n }\n}\n\n/*\n.slider {\n\n\n\n\n\n\n\n\n\n}\n*/\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"Slider.module.mjs","names":[],"sources":["../../../../../../../src/components/Slider/Slider.module.scss"],"sourcesContent":["@use \"@/styles/mixins/focus\";\n\n.slider {\n display: flex;\n flex-direction: column;\n width: 100%;\n row-gap: var(--slider--spacing-y);\n\n --button-size: calc(\n var(--button--line-height-s) + var(--button--padding-s-y) * 2\n );\n\n .text {\n text-align: center;\n align-items: end;\n padding-inline: calc(var(--button-size) + var(--slider--spacing-x));\n padding-top: calc(var(--slider--spacing-y) / 2);\n\n .value {\n font-size: var(--font-size-text--s);\n font-weight: var(--slider--value-font-weight);\n }\n\n .label {\n margin: 0;\n display: inline-flex;\n column-gap: var(--label--spacing);\n }\n }\n\n .track {\n grid-area: track;\n position: relative;\n height: var(--slider--track-height);\n background-color: var(--slider--track-color--default);\n width: 100%;\n border-radius: var(--slider--corner-radius);\n border: var(--slider--track-border-width) var(--slider--track-border-style)\n var(--slider--track-border-color--default);\n }\n\n .fill {\n position: absolute;\n width: calc(var(--slider--value) * 100%);\n height: var(--slider--track-height);\n background-color: var(--slider--color--default);\n top: calc(50% - var(--slider--track-height) / 2);\n border-radius: var(--slider--corner-radius);\n }\n\n .initialMarker {\n position: absolute;\n inset-inline-start: calc(var(--slider--initial-value) * 100% - 2px);\n height: var(--slider--initial-marker-height);\n width: var(--slider--initial-marker-border-width);\n background-color: var(--slider--color--default);\n top: calc(50% - var(--slider--initial-marker-height) / 2);\n border-radius: var(--slider--corner-radius);\n }\n\n .handle {\n width: var(--slider--handle-size);\n height: var(--slider--handle-size);\n border-radius: var(--slider--handle-corner-radius);\n background-color: var(--slider--handle-fill-color);\n border: var(--slider--handle-border-width) var(--slider--track-border-style)\n var(--slider--color--default);\n forced-color-adjust: none;\n top: 50%;\n transition-property: background-color;\n transition-duration: var(--transition--duration--default);\n\n &[data-dragging],\n &[data-focus-visible] {\n background-color: var(--slider--color--default);\n }\n\n &[data-focus-visible] {\n @include focus.focus;\n\n & {\n outline-offset: var(--size-px--xs);\n }\n }\n }\n\n .increment,\n .decrement {\n position: absolute;\n top: calc((var(--slider--spacing-y) + var(--button-size)) * -1);\n }\n\n .increment {\n inset-inline-end: 0;\n }\n\n .decrement {\n inset-inline-start: 0;\n }\n\n &.disabled {\n .track {\n background-color: var(--slider--track-color--disabled);\n border-color: var(--slider--track-border-color--disabled);\n }\n\n .fill {\n background-color: var(--slider--color--disabled);\n }\n\n .handle {\n border-color: var(--slider--color--disabled);\n }\n\n .text {\n color: var(--text--color--disabled);\n }\n }\n}\n\n/*\n.slider {\n\n\n\n\n\n\n\n\n\n}\n*/\n"],"mappings":""}
|
|
@@ -18,7 +18,7 @@ var Switch = flowComponent("Switch", (props) => {
|
|
|
18
18
|
const { children, className, labelPosition = "trailing", ref, ...rest } = props;
|
|
19
19
|
const rootClassName = clsx(Switch_module_default.switch, labelPosition !== "trailing" && Switch_module_default[`label-${labelPosition}`], className);
|
|
20
20
|
const objectRef = useObjectRef(ref);
|
|
21
|
-
const { FieldErrorView, FieldErrorCaptureContext, fieldPropsContext,
|
|
21
|
+
const { FieldErrorView, FieldErrorCaptureContext, fieldPropsContext, wrapperProps, controlProps } = useFieldComponent(props, "Switch");
|
|
22
22
|
const propsContext = {
|
|
23
23
|
...fieldPropsContext,
|
|
24
24
|
Label: {
|
|
@@ -28,9 +28,10 @@ var Switch = flowComponent("Switch", (props) => {
|
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
30
|
return /* @__PURE__ */ jsxs("div", {
|
|
31
|
-
|
|
31
|
+
className: wrapperProps.className,
|
|
32
32
|
children: [/* @__PURE__ */ jsx(FieldErrorCaptureContext, { children: /* @__PURE__ */ jsx(Aria.Switch, {
|
|
33
33
|
...rest,
|
|
34
|
+
"aria-describedby": controlProps["aria-describedby"],
|
|
34
35
|
className: rootClassName,
|
|
35
36
|
inputRef: objectRef,
|
|
36
37
|
children: ({ isSelected }) => /* @__PURE__ */ jsxs(PropsContextProvider, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Switch.mjs","names":[],"sources":["../../../../../../../src/components/Switch/Switch.tsx"],"sourcesContent":["import { type PropsWithChildren } from \"react\";\nimport * as Aria from \"react-aria-components\";\nimport styles from \"./Switch.module.scss\";\nimport clsx from \"clsx\";\nimport { IconCheck, IconClose } from \"@/components/Icon/components/icons\";\nimport type { FlowComponentProps } from \"@/lib/componentFactory/flowComponent\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\nimport { useFieldComponent } from \"@/lib/hooks/useFieldComponent\";\nimport { type PropsContext, PropsContextProvider } from \"@/lib/propsContext\";\nimport labelStyles from \"@/components/Label/Label.module.scss\";\nimport { useObjectRef } from \"react-aria\";\n\nexport interface SwitchProps\n extends\n PropsWithChildren<Omit<Aria.SwitchProps, \"children\" | \"inputRef\">>,\n FlowComponentProps<HTMLInputElement> {\n /**\n * Whether the label should appear before or after the switch. @default\n * \"trailing\"\n */\n labelPosition?: \"leading\" | \"trailing\";\n}\n\n/** @flr-generate all */\nexport const Switch = flowComponent(\"Switch\", (props) => {\n const {\n children,\n className,\n labelPosition = \"trailing\",\n ref,\n ...rest\n } = props;\n\n const rootClassName = clsx(\n styles.switch,\n labelPosition !== \"trailing\" && styles[`label-${labelPosition}`],\n className,\n );\n\n const objectRef = useObjectRef(ref);\n\n const {\n FieldErrorView,\n FieldErrorCaptureContext,\n fieldPropsContext,\n
|
|
1
|
+
{"version":3,"file":"Switch.mjs","names":[],"sources":["../../../../../../../src/components/Switch/Switch.tsx"],"sourcesContent":["import { type PropsWithChildren } from \"react\";\nimport * as Aria from \"react-aria-components\";\nimport styles from \"./Switch.module.scss\";\nimport clsx from \"clsx\";\nimport { IconCheck, IconClose } from \"@/components/Icon/components/icons\";\nimport type { FlowComponentProps } from \"@/lib/componentFactory/flowComponent\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\nimport { useFieldComponent } from \"@/lib/hooks/useFieldComponent\";\nimport { type PropsContext, PropsContextProvider } from \"@/lib/propsContext\";\nimport labelStyles from \"@/components/Label/Label.module.scss\";\nimport { useObjectRef } from \"react-aria\";\n\nexport interface SwitchProps\n extends\n PropsWithChildren<Omit<Aria.SwitchProps, \"children\" | \"inputRef\">>,\n FlowComponentProps<HTMLInputElement> {\n /**\n * Whether the label should appear before or after the switch. @default\n * \"trailing\"\n */\n labelPosition?: \"leading\" | \"trailing\";\n}\n\n/** @flr-generate all */\nexport const Switch = flowComponent(\"Switch\", (props) => {\n const {\n children,\n className,\n labelPosition = \"trailing\",\n ref,\n ...rest\n } = props;\n\n const rootClassName = clsx(\n styles.switch,\n labelPosition !== \"trailing\" && styles[`label-${labelPosition}`],\n className,\n );\n\n const objectRef = useObjectRef(ref);\n\n const {\n FieldErrorView,\n FieldErrorCaptureContext,\n fieldPropsContext,\n wrapperProps,\n controlProps,\n } = useFieldComponent(props, \"Switch\");\n\n const propsContext: PropsContext = {\n ...fieldPropsContext,\n Label: {\n ...fieldPropsContext.Label,\n optional: false,\n className: styles.label,\n },\n };\n\n return (\n <div className={wrapperProps.className}>\n <FieldErrorCaptureContext>\n <Aria.Switch\n {...rest}\n aria-describedby={controlProps[\"aria-describedby\"]}\n className={rootClassName}\n inputRef={objectRef}\n >\n {({ isSelected }) => (\n <PropsContextProvider props={propsContext}>\n <div className={styles.track}>\n <div className={styles.handle}>\n {isSelected ? <IconCheck size=\"s\" /> : <IconClose size=\"s\" />}\n </div>\n </div>\n <div className={labelStyles.label}>{children}</div>\n </PropsContextProvider>\n )}\n </Aria.Switch>\n </FieldErrorCaptureContext>\n <FieldErrorView />\n </div>\n );\n});\n\nexport default Switch;\n"],"mappings":";;;;;;;;;;;;;;;;AAwBA,IAAa,SAAS,cAAc,WAAW,UAAU;CACvD,MAAM,EACJ,UACA,WACA,gBAAgB,YAChB,KACA,GAAG,SACD;CAEJ,MAAM,gBAAgB,KACpB,sBAAO,QACP,kBAAkB,cAAc,sBAAO,SAAS,kBAChD,SACF;CAEA,MAAM,YAAY,aAAa,GAAG;CAElC,MAAM,EACJ,gBACA,0BACA,mBACA,cACA,iBACE,kBAAkB,OAAO,QAAQ;CAErC,MAAM,eAA6B;EACjC,GAAG;EACH,OAAO;GACL,GAAG,kBAAkB;GACrB,UAAU;GACV,WAAW,sBAAO;EACpB;CACF;CAEA,OACE,qBAAC,OAAD;EAAK,WAAW,aAAa;EAA7B,UAAA,CACE,oBAAC,0BAAD,EAAA,UACE,oBAAC,KAAK,QAAN;GACE,GAAI;GACJ,oBAAkB,aAAa;GAC/B,WAAW;GACX,UAAU;GAER,WAAA,EAAE,iBACF,qBAAC,sBAAD;IAAsB,OAAO;IAA7B,UAAA,CACE,oBAAC,OAAD;KAAK,WAAW,sBAAO;KACrB,UAAA,oBAAC,OAAD;MAAK,WAAW,sBAAO;MACpB,UAAA,aAAa,oBAAC,WAAD,EAAW,MAAK,IAAK,CAAA,IAAI,oBAAC,WAAD,EAAW,MAAK,IAAK,CAAA;KACzD,CAAA;IACF,CAAA,GACL,oBAAC,OAAD;KAAK,WAAW,qBAAY;KAAQ;IAAc,CAAA,CAC9B;;EAEb,CAAA,EACW,CAAA,GAC1B,oBAAC,gBAAD,CAAiB,CAAA,CACd;;AAET,CAAC"}
|
|
@@ -21,11 +21,11 @@ var TextArea = flowComponent("TextArea", (props) => {
|
|
|
21
21
|
const { children, placeholder, rows = 5, autoResizeMaxRows = rows, ref, allowVerticalResize, allowHorizontalResize, showCharacterCount, className, onChange, isReadOnly, value, ...rest } = useControlledHostValueProps(props, "");
|
|
22
22
|
if (allowHorizontalResize !== void 0) warnDeprecation("The 'allowHorizontalResize' prop is deprecated and will be removed in a future release. Use 'allowResize' instead.");
|
|
23
23
|
if (allowVerticalResize !== void 0) warnDeprecation("The 'allowVerticalResize' prop is deprecated and will be removed in a future release. Use 'allowResize' instead.");
|
|
24
|
-
const { FieldErrorView, FieldErrorCaptureContext, fieldPropsContext,
|
|
24
|
+
const { FieldErrorView, FieldErrorCaptureContext, fieldPropsContext, wrapperProps, controlProps } = useFieldComponent(props, "TextArea");
|
|
25
25
|
let { allowResize } = props;
|
|
26
26
|
if (allowVerticalResize) allowResize = "vertical";
|
|
27
27
|
else if (allowHorizontalResize) allowResize = "horizontal";
|
|
28
|
-
const rootClassName = clsx(
|
|
28
|
+
const rootClassName = clsx(wrapperProps.className, className);
|
|
29
29
|
const inputClassName = clsx(TextArea_module_default.input, typeof allowResize === "boolean" && allowResize ? TextArea_module_default.resize : null, allowResize === "horizontal" ? TextArea_module_default.horizontalResize : allowResize === "vertical" ? TextArea_module_default.verticalResize : null);
|
|
30
30
|
const handleChange = (v) => {
|
|
31
31
|
if (isReadOnly) return;
|
|
@@ -78,7 +78,7 @@ var TextArea = flowComponent("TextArea", (props) => {
|
|
|
78
78
|
]);
|
|
79
79
|
return /* @__PURE__ */ jsx(Aria.TextField, {
|
|
80
80
|
...rest,
|
|
81
|
-
...
|
|
81
|
+
...controlProps,
|
|
82
82
|
value,
|
|
83
83
|
className: rootClassName,
|
|
84
84
|
onChange: handleChange,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextArea.mjs","names":[],"sources":["../../../../../../../src/components/TextArea/TextArea.tsx"],"sourcesContent":["import * as Aria from \"react-aria-components\";\nimport styles from \"./TextArea.module.scss\";\nimport type { FlowComponentProps } from \"@/lib/componentFactory/flowComponent\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\nimport { useObjectRef } from \"@react-aria/utils\";\nimport { useFieldComponent } from \"@/lib/hooks/useFieldComponent\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport clsx from \"clsx\";\nimport {\n type PropsWithChildren,\n useEffect,\n useLayoutEffect,\n useState,\n} from \"react\";\nimport { useControlledHostValueProps } from \"@/lib/remote/useControlledHostValueProps\";\nimport { useLocalizedStringFormatter } from \"@/components/TranslationProvider/useLocalizedStringFormatter\";\nimport locales from \"./locales/*.locale.json\";\nimport { FieldDescription } from \"@/components/FieldDescription\";\nimport { useWarnDeprecation } from \"@/components/DeprecationWarningProvider\";\n\nexport interface TextAreaProps\n extends\n PropsWithChildren<Omit<Aria.TextFieldProps, \"children\">>,\n Pick<Aria.TextAreaProps, \"placeholder\" | \"rows\" | \"aria-hidden\">,\n FlowComponentProps<HTMLTextAreaElement> {\n /** Whether a character count should be displayed inside the field description. */\n showCharacterCount?: boolean;\n /**\n * Whether the text area should grow if its content gets longer than its\n * initial height.\n */\n autoResizeMaxRows?: number;\n /** Allows the user to manually resize the textArea horizontally. */\n allowResize?: boolean | \"horizontal\" | \"vertical\";\n /** @deprecated Use `allowResize` instead. */\n allowHorizontalResize?: boolean;\n /** @deprecated Use `allowResize` instead. */\n allowVerticalResize?: boolean;\n}\n\n/** @flr-generate all */\nexport const TextArea = flowComponent(\"TextArea\", (props) => {\n const warnDeprecation = useWarnDeprecation();\n const {\n children,\n placeholder,\n rows = 5,\n autoResizeMaxRows = rows,\n ref,\n allowVerticalResize,\n allowHorizontalResize,\n showCharacterCount,\n className,\n onChange,\n isReadOnly,\n value,\n ...rest\n } = useControlledHostValueProps(props, \"\");\n\n if (allowHorizontalResize !== undefined) {\n warnDeprecation(\n \"The 'allowHorizontalResize' prop is deprecated and will be removed in a future release. Use 'allowResize' instead.\",\n );\n }\n if (allowVerticalResize !== undefined) {\n warnDeprecation(\n \"The 'allowVerticalResize' prop is deprecated and will be removed in a future release. Use 'allowResize' instead.\",\n );\n }\n\n const {\n FieldErrorView,\n FieldErrorCaptureContext,\n fieldPropsContext,\n
|
|
1
|
+
{"version":3,"file":"TextArea.mjs","names":[],"sources":["../../../../../../../src/components/TextArea/TextArea.tsx"],"sourcesContent":["import * as Aria from \"react-aria-components\";\nimport styles from \"./TextArea.module.scss\";\nimport type { FlowComponentProps } from \"@/lib/componentFactory/flowComponent\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\nimport { useObjectRef } from \"@react-aria/utils\";\nimport { useFieldComponent } from \"@/lib/hooks/useFieldComponent\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport clsx from \"clsx\";\nimport {\n type PropsWithChildren,\n useEffect,\n useLayoutEffect,\n useState,\n} from \"react\";\nimport { useControlledHostValueProps } from \"@/lib/remote/useControlledHostValueProps\";\nimport { useLocalizedStringFormatter } from \"@/components/TranslationProvider/useLocalizedStringFormatter\";\nimport locales from \"./locales/*.locale.json\";\nimport { FieldDescription } from \"@/components/FieldDescription\";\nimport { useWarnDeprecation } from \"@/components/DeprecationWarningProvider\";\n\nexport interface TextAreaProps\n extends\n PropsWithChildren<Omit<Aria.TextFieldProps, \"children\">>,\n Pick<Aria.TextAreaProps, \"placeholder\" | \"rows\" | \"aria-hidden\">,\n FlowComponentProps<HTMLTextAreaElement> {\n /** Whether a character count should be displayed inside the field description. */\n showCharacterCount?: boolean;\n /**\n * Whether the text area should grow if its content gets longer than its\n * initial height.\n */\n autoResizeMaxRows?: number;\n /** Allows the user to manually resize the textArea horizontally. */\n allowResize?: boolean | \"horizontal\" | \"vertical\";\n /** @deprecated Use `allowResize` instead. */\n allowHorizontalResize?: boolean;\n /** @deprecated Use `allowResize` instead. */\n allowVerticalResize?: boolean;\n}\n\n/** @flr-generate all */\nexport const TextArea = flowComponent(\"TextArea\", (props) => {\n const warnDeprecation = useWarnDeprecation();\n const {\n children,\n placeholder,\n rows = 5,\n autoResizeMaxRows = rows,\n ref,\n allowVerticalResize,\n allowHorizontalResize,\n showCharacterCount,\n className,\n onChange,\n isReadOnly,\n value,\n ...rest\n } = useControlledHostValueProps(props, \"\");\n\n if (allowHorizontalResize !== undefined) {\n warnDeprecation(\n \"The 'allowHorizontalResize' prop is deprecated and will be removed in a future release. Use 'allowResize' instead.\",\n );\n }\n if (allowVerticalResize !== undefined) {\n warnDeprecation(\n \"The 'allowVerticalResize' prop is deprecated and will be removed in a future release. Use 'allowResize' instead.\",\n );\n }\n\n const {\n FieldErrorView,\n FieldErrorCaptureContext,\n fieldPropsContext,\n wrapperProps,\n controlProps,\n } = useFieldComponent(props, \"TextArea\");\n\n let { allowResize } = props;\n if (allowVerticalResize) {\n allowResize = \"vertical\";\n } else if (allowHorizontalResize) {\n allowResize = \"horizontal\";\n }\n\n const rootClassName = clsx(wrapperProps.className, className);\n\n const inputClassName = clsx(\n styles.input,\n typeof allowResize === \"boolean\" && allowResize ? styles.resize : null,\n allowResize === \"horizontal\"\n ? styles.horizontalResize\n : allowResize === \"vertical\"\n ? styles.verticalResize\n : null,\n );\n\n const handleChange = (v: string) => {\n if (isReadOnly) {\n return;\n }\n\n if (onChange) {\n onChange(v);\n }\n };\n\n const translation = useLocalizedStringFormatter(locales, \"TextArea\");\n\n // Derived, so that a value the field never saw typed is counted as well.\n const charactersCountDescription = translation.format(\"characters\", {\n count: value.length,\n maxCount: props.maxLength ?? 0,\n });\n\n const localRef = useObjectRef(ref);\n\n const [resized, setResized] = useState(false);\n\n const autoResizable = rows !== autoResizeMaxRows;\n\n const verticallyResizable =\n allowResize && (!autoResizable || (autoResizable && resized));\n\n useEffect(() => {\n const textarea = localRef.current;\n if (!textarea) return;\n\n const startHeight = textarea.offsetHeight;\n let tracking = false;\n\n const handleMouseDown = () => {\n tracking = true;\n };\n\n const handleMouseMove = () => {\n if (!tracking || resized) return;\n\n const currentHeight = textarea.offsetHeight;\n\n if (currentHeight !== startHeight) {\n setResized(true);\n tracking = false;\n }\n };\n\n const handleMouseUp = () => {\n tracking = false;\n };\n\n window.addEventListener(\"mousedown\", handleMouseDown);\n window.addEventListener(\"mousemove\", handleMouseMove);\n window.addEventListener(\"mouseup\", handleMouseUp);\n\n return () => {\n window.removeEventListener(\"mousedown\", handleMouseDown);\n window.removeEventListener(\"mousemove\", handleMouseMove);\n window.removeEventListener(\"mouseup\", handleMouseUp);\n };\n }, [resized]);\n\n /*\n * The height depends on the rendered content, so it cannot be a style. It is\n * synced to the value instead of to the `change` event, because a value the\n * field never saw typed — an initial value, or a draft loaded into a\n * controlled field — has to resize it just the same.\n */\n useLayoutEffect(() => {\n const textArea = localRef.current;\n if (!textArea || !autoResizable || verticallyResizable) {\n return;\n }\n // https://stackoverflow.com/a/60795884\n textArea.style.height = \"0px\";\n // + 2 to add border height\n textArea.style.height = `${textArea.scrollHeight + 2}px`;\n }, [value, autoResizable, verticallyResizable]);\n\n return (\n <Aria.TextField\n {...rest}\n {...controlProps}\n value={value}\n className={rootClassName}\n onChange={handleChange}\n >\n <PropsContextProvider props={fieldPropsContext}>\n <FieldErrorCaptureContext>{children}</FieldErrorCaptureContext>\n <Aria.TextArea\n rows={rows}\n {...(isReadOnly ? { \"data-readonly\": true } : {})}\n aria-readonly={isReadOnly}\n aria-hidden={props[\"aria-hidden\"]}\n placeholder={placeholder}\n className={inputClassName}\n ref={localRef}\n style={{\n \"--text-area--rows\": rows,\n \"--text-area--max-rows\": verticallyResizable\n ? undefined\n : autoResizeMaxRows,\n }}\n />\n {showCharacterCount && (\n <FieldDescription>{charactersCountDescription}</FieldDescription>\n )}\n <FieldErrorView />\n </PropsContextProvider>\n </Aria.TextField>\n );\n});\n\nexport default TextArea;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAyCA,IAAa,WAAW,cAAc,aAAa,UAAU;CAC3D,MAAM,kBAAkB,mBAAmB;CAC3C,MAAM,EACJ,UACA,aACA,OAAO,GACP,oBAAoB,MACpB,KACA,qBACA,uBACA,oBACA,WACA,UACA,YACA,OACA,GAAG,SACD,4BAA4B,OAAO,EAAE;CAEzC,IAAI,0BAA0B,KAAA,GAC5B,gBACE,oHACF;CAEF,IAAI,wBAAwB,KAAA,GAC1B,gBACE,kHACF;CAGF,MAAM,EACJ,gBACA,0BACA,mBACA,cACA,iBACE,kBAAkB,OAAO,UAAU;CAEvC,IAAI,EAAE,gBAAgB;CACtB,IAAI,qBACF,cAAc;MACT,IAAI,uBACT,cAAc;CAGhB,MAAM,gBAAgB,KAAK,aAAa,WAAW,SAAS;CAE5D,MAAM,iBAAiB,KACrB,wBAAO,OACP,OAAO,gBAAgB,aAAa,cAAc,wBAAO,SAAS,MAClE,gBAAgB,eACZ,wBAAO,mBACP,gBAAgB,aACd,wBAAO,iBACP,IACR;CAEA,MAAM,gBAAgB,MAAc;EAClC,IAAI,YACF;EAGF,IAAI,UACF,SAAS,CAAC;CAEd;CAKA,MAAM,6BAHc,4BAA4B,kBAAS,UAGtB,CAAA,CAAY,OAAO,cAAc;EAClE,OAAO,MAAM;EACb,UAAU,MAAM,aAAa;CAC/B,CAAC;CAED,MAAM,WAAW,aAAa,GAAG;CAEjC,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAE5C,MAAM,gBAAgB,SAAS;CAE/B,MAAM,sBACJ,gBAAgB,CAAC,iBAAkB,iBAAiB;CAEtD,gBAAgB;EACd,MAAM,WAAW,SAAS;EAC1B,IAAI,CAAC,UAAU;EAEf,MAAM,cAAc,SAAS;EAC7B,IAAI,WAAW;EAEf,MAAM,wBAAwB;GAC5B,WAAW;EACb;EAEA,MAAM,wBAAwB;GAC5B,IAAI,CAAC,YAAY,SAAS;GAI1B,IAFsB,SAAS,iBAET,aAAa;IACjC,WAAW,IAAI;IACf,WAAW;GACb;EACF;EAEA,MAAM,sBAAsB;GAC1B,WAAW;EACb;EAEA,OAAO,iBAAiB,aAAa,eAAe;EACpD,OAAO,iBAAiB,aAAa,eAAe;EACpD,OAAO,iBAAiB,WAAW,aAAa;EAEhD,aAAa;GACX,OAAO,oBAAoB,aAAa,eAAe;GACvD,OAAO,oBAAoB,aAAa,eAAe;GACvD,OAAO,oBAAoB,WAAW,aAAa;EACrD;CACF,GAAG,CAAC,OAAO,CAAC;CAQZ,sBAAsB;EACpB,MAAM,WAAW,SAAS;EAC1B,IAAI,CAAC,YAAY,CAAC,iBAAiB,qBACjC;EAGF,SAAS,MAAM,SAAS;EAExB,SAAS,MAAM,SAAS,GAAG,SAAS,eAAe,EAAE;CACvD,GAAG;EAAC;EAAO;EAAe;CAAmB,CAAC;CAE9C,OACE,oBAAC,KAAK,WAAN;EACE,GAAI;EACJ,GAAI;EACG;EACP,WAAW;EACX,UAAU;EAEV,UAAA,qBAAC,sBAAD;GAAsB,OAAO;GAA7B,UAAA;IACE,oBAAC,0BAAD,EAA2B,SAAmC,CAAA;IAC9D,oBAAC,KAAK,UAAN;KACQ;KACN,GAAK,aAAa,EAAE,iBAAiB,KAAK,IAAI,CAAC;KAC/C,iBAAe;KACf,eAAa,MAAM;KACN;KACb,WAAW;KACX,KAAK;KACL,OAAO;MACL,qBAAqB;MACrB,yBAAyB,sBACrB,KAAA,IACA;KACN;IACD,CAAA;IACA,sBACC,oBAAC,kBAAD,EAAA,UAAmB,2BAA6C,CAAA;IAElE,oBAAC,gBAAD,CAAiB,CAAA;GACG;;CACR,CAAA;AAEpB,CAAC"}
|
|
@@ -22,8 +22,8 @@ var TextField = flowComponent("TextField", (props) => {
|
|
|
22
22
|
const { className, showCharacterCount, form, placeholder, ref, type: typeFromProps, children, onChange, ...rest } = useControlledHostValueProps(props, "");
|
|
23
23
|
const [charactersCount, setCharactersCount] = useState(props.defaultValue?.length ?? props.value?.length ?? 0);
|
|
24
24
|
const [type, setType] = useState(typeFromProps);
|
|
25
|
-
const { FieldErrorView, FieldErrorCaptureContext, fieldPropsContext,
|
|
26
|
-
const rootClassName = clsx(
|
|
25
|
+
const { FieldErrorView, FieldErrorCaptureContext, fieldPropsContext, wrapperProps, controlProps } = useFieldComponent(props, "TextField");
|
|
26
|
+
const rootClassName = clsx(wrapperProps.className, className);
|
|
27
27
|
const propsContext = {
|
|
28
28
|
Button: {
|
|
29
29
|
className: TextField_module_default.button,
|
|
@@ -54,7 +54,7 @@ var TextField = flowComponent("TextField", (props) => {
|
|
|
54
54
|
});
|
|
55
55
|
return /* @__PURE__ */ jsx(Aria.TextField, {
|
|
56
56
|
...rest,
|
|
57
|
-
...
|
|
57
|
+
...controlProps,
|
|
58
58
|
className: rootClassName,
|
|
59
59
|
onChange: handleChange,
|
|
60
60
|
type,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextField.mjs","names":[],"sources":["../../../../../../../src/components/TextField/TextField.tsx"],"sourcesContent":["import {\n flowComponent,\n type FlowComponentProps,\n} from \"@/lib/componentFactory/flowComponent\";\nimport * as Aria from \"react-aria-components\";\nimport { type PropsWithChildren, useState } from \"react\";\nimport { useControlledHostValueProps } from \"@/lib/remote/useControlledHostValueProps\";\nimport { type PropsContext, PropsContextProvider } from \"@/lib/propsContext\";\nimport { useFieldComponent } from \"@/lib/hooks/useFieldComponent\";\nimport styles from \"./TextField.module.scss\";\nimport { FieldDescription } from \"@/components/FieldDescription\";\nimport locales from \"./locales/*.locale.json\";\nimport { Button } from \"@/components/Button\";\nimport { IconHide, IconShow } from \"@/components/Icon/components/icons\";\nimport clsx from \"clsx\";\nimport { useLocalizedStringFormatter } from \"@/components/TranslationProvider\";\nimport { UiComponentTunnelExit } from \"@/components/UiComponentTunnel/UiComponentTunnelExit\";\n\nexport interface TextFieldProps\n extends\n PropsWithChildren<Omit<Aria.TextFieldProps, \"children\">>,\n Pick<Aria.InputProps, \"placeholder\">,\n FlowComponentProps<HTMLInputElement> {\n /** Whether a character count should be displayed inside the field description. */\n showCharacterCount?: boolean;\n}\n\n/** @flr-generate all */\nexport const TextField = flowComponent(\"TextField\", (props) => {\n const {\n className,\n showCharacterCount,\n form,\n placeholder,\n ref,\n type: typeFromProps,\n children,\n onChange,\n ...rest\n } = useControlledHostValueProps(props, \"\");\n\n const [charactersCount, setCharactersCount] = useState(\n props.defaultValue?.length ?? props.value?.length ?? 0,\n );\n\n const [type, setType] = useState(typeFromProps);\n\n const {\n FieldErrorView,\n FieldErrorCaptureContext,\n fieldPropsContext,\n
|
|
1
|
+
{"version":3,"file":"TextField.mjs","names":[],"sources":["../../../../../../../src/components/TextField/TextField.tsx"],"sourcesContent":["import {\n flowComponent,\n type FlowComponentProps,\n} from \"@/lib/componentFactory/flowComponent\";\nimport * as Aria from \"react-aria-components\";\nimport { type PropsWithChildren, useState } from \"react\";\nimport { useControlledHostValueProps } from \"@/lib/remote/useControlledHostValueProps\";\nimport { type PropsContext, PropsContextProvider } from \"@/lib/propsContext\";\nimport { useFieldComponent } from \"@/lib/hooks/useFieldComponent\";\nimport styles from \"./TextField.module.scss\";\nimport { FieldDescription } from \"@/components/FieldDescription\";\nimport locales from \"./locales/*.locale.json\";\nimport { Button } from \"@/components/Button\";\nimport { IconHide, IconShow } from \"@/components/Icon/components/icons\";\nimport clsx from \"clsx\";\nimport { useLocalizedStringFormatter } from \"@/components/TranslationProvider\";\nimport { UiComponentTunnelExit } from \"@/components/UiComponentTunnel/UiComponentTunnelExit\";\n\nexport interface TextFieldProps\n extends\n PropsWithChildren<Omit<Aria.TextFieldProps, \"children\">>,\n Pick<Aria.InputProps, \"placeholder\">,\n FlowComponentProps<HTMLInputElement> {\n /** Whether a character count should be displayed inside the field description. */\n showCharacterCount?: boolean;\n}\n\n/** @flr-generate all */\nexport const TextField = flowComponent(\"TextField\", (props) => {\n const {\n className,\n showCharacterCount,\n form,\n placeholder,\n ref,\n type: typeFromProps,\n children,\n onChange,\n ...rest\n } = useControlledHostValueProps(props, \"\");\n\n const [charactersCount, setCharactersCount] = useState(\n props.defaultValue?.length ?? props.value?.length ?? 0,\n );\n\n const [type, setType] = useState(typeFromProps);\n\n const {\n FieldErrorView,\n FieldErrorCaptureContext,\n fieldPropsContext,\n wrapperProps,\n controlProps,\n } = useFieldComponent(props, \"TextField\");\n\n const rootClassName = clsx(wrapperProps.className, className);\n\n const propsContext: PropsContext = {\n Button: {\n className: styles.button,\n variant: \"plain\",\n color: \"secondary\",\n tunnel: {\n id: \"button\",\n component: \"TextField\",\n },\n },\n CopyButton: {\n className: styles.button,\n tunnel: {\n id: \"button\",\n component: \"TextField\",\n },\n },\n ...fieldPropsContext,\n };\n\n const handleChange = (v: string) => {\n if (showCharacterCount) {\n setCharactersCount(v.length);\n }\n if (onChange) {\n onChange(v);\n }\n };\n\n const translation = useLocalizedStringFormatter(locales, \"TextField\");\n\n const charactersCountDescription = translation.format(\"characters\", {\n count: charactersCount,\n maxCount: props.maxLength ?? 0,\n });\n\n return (\n <Aria.TextField\n {...rest}\n {...controlProps}\n className={rootClassName}\n onChange={handleChange}\n type={type}\n >\n <PropsContextProvider props={propsContext}>\n <FieldErrorCaptureContext>\n {children}\n <div className={styles.inputContainer}>\n <Aria.Input\n form={form}\n placeholder={placeholder}\n className={styles.input}\n ref={ref}\n />\n <UiComponentTunnelExit id=\"button\" component=\"TextField\" />\n {typeFromProps === \"password\" && (\n <Button\n color=\"secondary\"\n variant=\"plain\"\n className={styles.button}\n onPress={() =>\n setType(type === \"password\" ? \"text\" : \"password\")\n }\n aria-label={translation.format(\n `password.${type === \"password\" ? \"show\" : \"hide\"}`,\n )}\n >\n {type === \"password\" ? <IconShow /> : <IconHide />}\n </Button>\n )}\n </div>\n {showCharacterCount && (\n <FieldDescription>{charactersCountDescription}</FieldDescription>\n )}\n </FieldErrorCaptureContext>\n <FieldErrorView />\n </PropsContextProvider>\n </Aria.TextField>\n );\n});\n\nexport default TextField;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA4BA,IAAa,YAAY,cAAc,cAAc,UAAU;CAC7D,MAAM,EACJ,WACA,oBACA,MACA,aACA,KACA,MAAM,eACN,UACA,UACA,GAAG,SACD,4BAA4B,OAAO,EAAE;CAEzC,MAAM,CAAC,iBAAiB,sBAAsB,SAC5C,MAAM,cAAc,UAAU,MAAM,OAAO,UAAU,CACvD;CAEA,MAAM,CAAC,MAAM,WAAW,SAAS,aAAa;CAE9C,MAAM,EACJ,gBACA,0BACA,mBACA,cACA,iBACE,kBAAkB,OAAO,WAAW;CAExC,MAAM,gBAAgB,KAAK,aAAa,WAAW,SAAS;CAE5D,MAAM,eAA6B;EACjC,QAAQ;GACN,WAAW,yBAAO;GAClB,SAAS;GACT,OAAO;GACP,QAAQ;IACN,IAAI;IACJ,WAAW;GACb;EACF;EACA,YAAY;GACV,WAAW,yBAAO;GAClB,QAAQ;IACN,IAAI;IACJ,WAAW;GACb;EACF;EACA,GAAG;CACL;CAEA,MAAM,gBAAgB,MAAc;EAClC,IAAI,oBACF,mBAAmB,EAAE,MAAM;EAE7B,IAAI,UACF,SAAS,CAAC;CAEd;CAEA,MAAM,cAAc,4BAA4B,kBAAS,WAAW;CAEpE,MAAM,6BAA6B,YAAY,OAAO,cAAc;EAClE,OAAO;EACP,UAAU,MAAM,aAAa;CAC/B,CAAC;CAED,OACE,oBAAC,KAAK,WAAN;EACE,GAAI;EACJ,GAAI;EACJ,WAAW;EACX,UAAU;EACJ;EAEN,UAAA,qBAAC,sBAAD;GAAsB,OAAO;GAA7B,UAAA,CACE,qBAAC,0BAAD,EAAA,UAAA;IACG;IACD,qBAAC,OAAD;KAAK,WAAW,yBAAO;KAAvB,UAAA;MACE,oBAAC,KAAK,OAAN;OACQ;OACO;OACb,WAAW,yBAAO;OACb;MACN,CAAA;MACD,oBAAC,uBAAD;OAAuB,IAAG;OAAS,WAAU;MAAa,CAAA;MACzD,kBAAkB,cACjB,oBAAC,QAAD;OACE,OAAM;OACN,SAAQ;OACR,WAAW,yBAAO;OAClB,eACE,QAAQ,SAAS,aAAa,SAAS,UAAU;OAEnD,cAAY,YAAY,OACtB,YAAY,SAAS,aAAa,SAAS,QAC7C;OAEC,UAAA,SAAS,aAAa,oBAAC,UAAD,CAAW,CAAA,IAAI,oBAAC,UAAD,CAAW,CAAA;MAC3C,CAAA;KAEP;;IACJ,sBACC,oBAAC,kBAAD,EAAA,UAAmB,2BAA6C,CAAA;GAE1C,EAAA,CAAA,GAC1B,oBAAC,gBAAD,CAAiB,CAAA,CACG;;CACR,CAAA;AAEpB,CAAC"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { PropsContextProvider } from "../../lib/propsContext/components/PropsContextProvider.mjs";
|
|
4
4
|
import { flowComponent } from "../../lib/componentFactory/flowComponent.mjs";
|
|
5
5
|
import { useFieldComponent } from "../../lib/hooks/useFieldComponent.mjs";
|
|
6
|
+
import { useControlledHostValueProps } from "../../lib/remote/useControlledHostValueProps.mjs";
|
|
6
7
|
import { DateInput } from "../DateInput/DateInput.mjs";
|
|
7
8
|
import TimeField_module_default from "./TimeField.module.mjs";
|
|
8
9
|
import "react";
|
|
@@ -11,12 +12,13 @@ import * as Aria from "react-aria-components";
|
|
|
11
12
|
//#region src/components/TimeField/TimeField.tsx
|
|
12
13
|
/** @flr-generate all */
|
|
13
14
|
var TimeField = flowComponent("TimeField", (props) => {
|
|
14
|
-
const { children, ref, ...rest } = props;
|
|
15
|
-
const { FieldErrorView, FieldErrorCaptureContext, fieldPropsContext,
|
|
15
|
+
const { children, ref, ...rest } = useControlledHostValueProps(props, null);
|
|
16
|
+
const { FieldErrorView, FieldErrorCaptureContext, fieldPropsContext, wrapperProps, controlProps } = useFieldComponent(props, "TimeField");
|
|
16
17
|
return /* @__PURE__ */ jsxs(Aria.TimeField, {
|
|
17
18
|
hourCycle: 24,
|
|
18
19
|
...rest,
|
|
19
|
-
...
|
|
20
|
+
...wrapperProps,
|
|
21
|
+
...controlProps,
|
|
20
22
|
children: [/* @__PURE__ */ jsxs(FieldErrorCaptureContext, { children: [/* @__PURE__ */ jsx(DateInput, {
|
|
21
23
|
className: TimeField_module_default.dateInput,
|
|
22
24
|
ref
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimeField.mjs","names":[],"sources":["../../../../../../../src/components/TimeField/TimeField.tsx"],"sourcesContent":["import { type PropsWithChildren } from \"react\";\nimport * as Aria from \"react-aria-components\";\nimport {\n flowComponent,\n type FlowComponentProps,\n} from \"@/lib/componentFactory/flowComponent\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport styles from \"./TimeField.module.scss\";\nimport { useFieldComponent } from \"@/lib/hooks/useFieldComponent\";\nimport DateInput from \"@/components/DateInput\";\n\nexport interface TimeFieldProps<T extends Aria.TimeValue = Aria.TimeValue>\n extends\n PropsWithChildren<Omit<Aria.TimeFieldProps<T>, \"children\">>,\n FlowComponentProps<HTMLSpanElement> {}\n\n/** @flr-generate all */\nexport const TimeField = flowComponent(\"TimeField\", (props) => {\n const { children, ref, ...rest } = props;\n\n const {\n FieldErrorView,\n FieldErrorCaptureContext,\n fieldPropsContext,\n
|
|
1
|
+
{"version":3,"file":"TimeField.mjs","names":[],"sources":["../../../../../../../src/components/TimeField/TimeField.tsx"],"sourcesContent":["import { type PropsWithChildren } from \"react\";\nimport * as Aria from \"react-aria-components\";\nimport {\n flowComponent,\n type FlowComponentProps,\n} from \"@/lib/componentFactory/flowComponent\";\nimport { PropsContextProvider } from \"@/lib/propsContext\";\nimport styles from \"./TimeField.module.scss\";\nimport { useFieldComponent } from \"@/lib/hooks/useFieldComponent\";\nimport DateInput from \"@/components/DateInput\";\nimport { useControlledHostValueProps } from \"@/lib/remote/useControlledHostValueProps\";\n\nexport interface TimeFieldProps<T extends Aria.TimeValue = Aria.TimeValue>\n extends\n PropsWithChildren<Omit<Aria.TimeFieldProps<T>, \"children\">>,\n FlowComponentProps<HTMLSpanElement> {}\n\n/** @flr-generate all */\nexport const TimeField = flowComponent(\"TimeField\", (props) => {\n // `null` is what react-aria's time field state uses for \"no time\"\n const { children, ref, ...rest } = useControlledHostValueProps(props, null);\n\n const {\n FieldErrorView,\n FieldErrorCaptureContext,\n fieldPropsContext,\n wrapperProps,\n controlProps,\n } = useFieldComponent(props, \"TimeField\");\n\n return (\n <Aria.TimeField\n hourCycle={24}\n {...rest}\n {...wrapperProps}\n {...controlProps}\n >\n <FieldErrorCaptureContext>\n <DateInput className={styles.dateInput} ref={ref} />\n <PropsContextProvider props={fieldPropsContext}>\n {children}\n </PropsContextProvider>\n </FieldErrorCaptureContext>\n <FieldErrorView />\n </Aria.TimeField>\n );\n});\n\nexport default TimeField;\n"],"mappings":";;;;;;;;;;;;;AAkBA,IAAa,YAAY,cAAc,cAAc,UAAU;CAE7D,MAAM,EAAE,UAAU,KAAK,GAAG,SAAS,4BAA4B,OAAO,IAAI;CAE1E,MAAM,EACJ,gBACA,0BACA,mBACA,cACA,iBACE,kBAAkB,OAAO,WAAW;CAExC,OACE,qBAAC,KAAK,WAAN;EACE,WAAW;EACX,GAAI;EACJ,GAAI;EACJ,GAAI;EAJN,UAAA,CAME,qBAAC,0BAAD,EAAA,UAAA,CACE,oBAAC,WAAD;GAAW,WAAW,yBAAO;GAAgB;EAAM,CAAA,GACnD,oBAAC,sBAAD;GAAsB,OAAO;GAC1B;EACmB,CAAA,CACE,EAAA,CAAA,GAC1B,oBAAC,gBAAD,CAAiB,CAAA,CACH;;AAEpB,CAAC"}
|
|
@@ -3,17 +3,20 @@
|
|
|
3
3
|
import { useFormContext } from "../FormContextProvider/FormContextProvider.mjs";
|
|
4
4
|
import FieldErrorView from "../../../../views/FieldErrorView.mjs";
|
|
5
5
|
import { useMountedFormRootErrorComponent } from "./useMountedFormRootErrorComponent.mjs";
|
|
6
|
-
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
7
7
|
//#region src/integrations/react-hook-form/components/FormRootError/FormRootError.tsx
|
|
8
8
|
/** @flowStatus new */
|
|
9
|
-
var FormRootError = () => {
|
|
9
|
+
var FormRootError = (props) => {
|
|
10
|
+
const { children } = props;
|
|
10
11
|
const form = useFormContext().form;
|
|
11
12
|
useMountedFormRootErrorComponent();
|
|
12
13
|
const error = form.formState.errors.root;
|
|
13
|
-
return /* @__PURE__ */ jsx(FieldErrorView, {
|
|
14
|
+
if (children === void 0) return /* @__PURE__ */ jsx(FieldErrorView, {
|
|
14
15
|
renderAlert: true,
|
|
15
16
|
children: error?.message
|
|
16
17
|
});
|
|
18
|
+
if (!error) return null;
|
|
19
|
+
return /* @__PURE__ */ jsx(Fragment, { children: typeof children === "function" ? children(error) : children });
|
|
17
20
|
};
|
|
18
21
|
//#endregion
|
|
19
22
|
export { FormRootError, FormRootError as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormRootError.mjs","names":[],"sources":["../../../../../../../../../src/integrations/react-hook-form/components/FormRootError/FormRootError.tsx"],"sourcesContent":["import type { FC } from \"react\";\nimport { useFormContext } from \"../FormContextProvider\";\nimport FieldErrorView from \"@/views/FieldErrorView\";\nimport { useMountedFormRootErrorComponent } from \"./useMountedFormRootErrorComponent\";\n\n/** @flowStatus new */\nexport const FormRootError: FC = () => {\n const form = useFormContext().form;\n useMountedFormRootErrorComponent();\n const error = form.formState.errors.root;\n return <FieldErrorView renderAlert>{error?.message}</FieldErrorView>;\n};\n\nexport default FormRootError;\n"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"FormRootError.mjs","names":[],"sources":["../../../../../../../../../src/integrations/react-hook-form/components/FormRootError/FormRootError.tsx"],"sourcesContent":["import type { FC, ReactNode } from \"react\";\nimport type { FieldErrors } from \"react-hook-form\";\nimport { useFormContext } from \"../FormContextProvider\";\nimport FieldErrorView from \"@/views/FieldErrorView\";\nimport { useMountedFormRootErrorComponent } from \"./useMountedFormRootErrorComponent\";\n\nexport type FormRootErrorValue = NonNullable<FieldErrors[\"root\"]>;\n\nexport interface FormRootErrorProps {\n /**\n * Custom content shown instead of the default alert. Rendered only while a\n * root error is set. A function receives the root error, e.g. to pick the\n * content by its `type`.\n */\n children?: ReactNode | ((error: FormRootErrorValue) => ReactNode);\n}\n\n/** @flowStatus new */\nexport const FormRootError: FC<FormRootErrorProps> = (props) => {\n const { children } = props;\n const form = useFormContext().form;\n useMountedFormRootErrorComponent();\n const error = form.formState.errors.root;\n\n if (children === undefined) {\n return <FieldErrorView renderAlert>{error?.message}</FieldErrorView>;\n }\n\n if (!error) {\n return null;\n }\n\n return <>{typeof children === \"function\" ? children(error) : children}</>;\n};\n\nexport default FormRootError;\n"],"mappings":";;;;;;;;AAkBA,IAAa,iBAAyC,UAAU;CAC9D,MAAM,EAAE,aAAa;CACrB,MAAM,OAAO,eAAe,CAAC,CAAC;CAC9B,iCAAiC;CACjC,MAAM,QAAQ,KAAK,UAAU,OAAO;CAEpC,IAAI,aAAa,KAAA,GACf,OAAO,oBAAC,gBAAD;EAAgB,aAAA;EAAa,UAAA,OAAO;CAAwB,CAAA;CAGrE,IAAI,CAAC,OACH,OAAO;CAGT,OAAO,oBAAA,UAAA,EAAA,UAAG,OAAO,aAAa,aAAa,SAAS,KAAK,IAAI,SAAW,CAAA;AAC1E"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
/* */
|
|
3
|
+
import { createContext } from "react";
|
|
4
|
+
//#region src/lib/hooks/fieldErrorRenderedContext.ts
|
|
5
|
+
/**
|
|
6
|
+
* Lets a rendered `FieldError` tell its field which id it has, so the field
|
|
7
|
+
* references the error only while it exists. `undefined` reports that it is
|
|
8
|
+
* gone.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
var FieldErrorRenderedContext = createContext(void 0);
|
|
13
|
+
//#endregion
|
|
14
|
+
export { FieldErrorRenderedContext };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=fieldErrorRenderedContext.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fieldErrorRenderedContext.mjs","names":[],"sources":["../../../../../../../src/lib/hooks/fieldErrorRenderedContext.ts"],"sourcesContent":["import { createContext } from \"react\";\n\n/**\n * Lets a rendered `FieldError` tell its field which id it has, so the field\n * references the error only while it exists. `undefined` reports that it is\n * gone.\n *\n * @internal\n */\nexport const FieldErrorRenderedContext = createContext<\n ((fieldErrorId: string | undefined) => void) | undefined\n>(undefined);\n"],"mappings":";;;;;;;;;;;AASA,IAAa,4BAA4B,cAEvC,KAAA,CAAS"}
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
/* */
|
|
3
3
|
import FormField_module_default from "../../components/FormField/FormField.module.mjs";
|
|
4
4
|
import { useFieldError } from "./useFieldError.mjs";
|
|
5
|
-
import
|
|
5
|
+
import "clsx";
|
|
6
6
|
import { useId } from "react";
|
|
7
7
|
//#region src/lib/hooks/useFieldComponent.tsx
|
|
8
|
+
/** Joins id references, dropping empty ones. @internal */
|
|
9
|
+
var joinIds = (...ids) => ids.filter(Boolean).join(" ") || void 0;
|
|
8
10
|
var useFieldComponent = (props, component) => {
|
|
9
11
|
const fieldErrorId = useId();
|
|
10
|
-
const { FieldErrorView, FieldErrorCaptureContext } = useFieldError({
|
|
12
|
+
const { FieldErrorView, FieldErrorCaptureContext, renderedFieldErrorId } = useFieldError({
|
|
11
13
|
fieldErrorId,
|
|
12
14
|
component
|
|
13
15
|
});
|
|
@@ -22,13 +24,12 @@ var useFieldComponent = (props, component) => {
|
|
|
22
24
|
},
|
|
23
25
|
FieldDescription: { className: FormField_module_default.fieldDescription }
|
|
24
26
|
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
27
|
+
wrapperProps: { className: FormField_module_default.formField },
|
|
28
|
+
controlProps: { "aria-describedby": joinIds(renderedFieldErrorId, props["aria-describedby"]) },
|
|
29
|
+
renderedFieldErrorId
|
|
29
30
|
};
|
|
30
31
|
};
|
|
31
32
|
//#endregion
|
|
32
|
-
export { useFieldComponent };
|
|
33
|
+
export { joinIds, useFieldComponent };
|
|
33
34
|
|
|
34
35
|
//# sourceMappingURL=useFieldComponent.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFieldComponent.mjs","names":[],"sources":["../../../../../../../src/lib/hooks/useFieldComponent.tsx"],"sourcesContent":["import { type FC, type PropsWithChildren, useId } from \"react\";\nimport { type PropsContext } from \"@/lib/propsContext\";\nimport formFieldStyles from \"@/components/FormField/FormField.module.scss\";\nimport { useFieldError } from \"@/lib/hooks/useFieldError\";\nimport
|
|
1
|
+
{"version":3,"file":"useFieldComponent.mjs","names":[],"sources":["../../../../../../../src/lib/hooks/useFieldComponent.tsx"],"sourcesContent":["import { type FC, type PropsWithChildren, useId } from \"react\";\nimport { type PropsContext } from \"@/lib/propsContext\";\nimport formFieldStyles from \"@/components/FormField/FormField.module.scss\";\nimport { useFieldError } from \"@/lib/hooks/useFieldError\";\nimport { type ClassValue } from \"clsx\";\nimport type { FlowComponentName } from \"@/components/propTypes\";\n\ninterface FieldComponentProps {\n className?: ClassValue;\n isRequired?: boolean;\n isDisabled?: boolean;\n \"aria-describedby\"?: string;\n}\n\nexport interface UseFieldComponent {\n FieldErrorCaptureContext: FC<PropsWithChildren>;\n FieldErrorView: FC;\n fieldPropsContext: PropsContext;\n /** For the field's outer element. */\n wrapperProps: {\n className: string;\n };\n /**\n * For what assistive technology lands on — the input, or the group of a\n * grouped control. Where the react-aria root forwards `aria-describedby` to\n * its input itself, spread it on the root together with `wrapperProps`.\n * Spread it after `rest`: it already contains the consumer's\n * `aria-describedby`, which `rest` would otherwise put back alone.\n */\n controlProps: {\n \"aria-describedby\"?: string;\n };\n /** The id of the error while one is rendered, without the consumer's ids. */\n renderedFieldErrorId?: string;\n}\n\n/** Joins id references, dropping empty ones. @internal */\nexport const joinIds = (...ids: (string | false | null | undefined)[]) =>\n ids.filter(Boolean).join(\" \") || undefined;\n\nexport const useFieldComponent = (\n props: FieldComponentProps,\n component: FlowComponentName,\n): UseFieldComponent => {\n const fieldErrorId = useId();\n const { FieldErrorView, FieldErrorCaptureContext, renderedFieldErrorId } =\n useFieldError({\n fieldErrorId,\n component,\n });\n\n // setting up the props context for all components that\n // are part of a form control\n const fieldPropsContext: PropsContext = {\n Label: {\n className: formFieldStyles.label,\n optional: !props.isRequired,\n isDisabled: !!props.isDisabled,\n },\n FieldDescription: {\n className: formFieldStyles.fieldDescription,\n },\n };\n\n return {\n FieldErrorView,\n FieldErrorCaptureContext,\n fieldPropsContext,\n wrapperProps: {\n className: formFieldStyles.formField,\n },\n controlProps: {\n // Reference the error only while it is rendered – an id that points to\n // nothing fails HTML validators and a11y checks.\n \"aria-describedby\": joinIds(\n renderedFieldErrorId,\n props[\"aria-describedby\"],\n ),\n },\n renderedFieldErrorId,\n } as const;\n};\n"],"mappings":";;;;;;;;AAqCA,IAAa,WAAW,GAAG,QACzB,IAAI,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,KAAK,KAAA;AAEnC,IAAa,qBACX,OACA,cACsB;CACtB,MAAM,eAAe,MAAM;CAC3B,MAAM,EAAE,gBAAgB,0BAA0B,yBAChD,cAAc;EACZ;EACA;CACF,CAAC;CAeH,OAAO;EACL;EACA;EACA,mBAAA;GAbA,OAAO;IACL,WAAW,yBAAgB;IAC3B,UAAU,CAAC,MAAM;IACjB,YAAY,CAAC,CAAC,MAAM;GACtB;GACA,kBAAkB,EAChB,WAAW,yBAAgB,iBAC7B;EAMA;EACA,cAAc,EACZ,WAAW,yBAAgB,UAC7B;EACA,cAAc,EAGZ,oBAAoB,QAClB,sBACA,MAAM,mBACR,EACF;EACA;CACF;AACF"}
|
|
@@ -5,7 +5,8 @@ import { PropsContextProvider } from "../propsContext/components/PropsContextPro
|
|
|
5
5
|
import { ClearPropsContext } from "../propsContext/components/ClearPropsContext.mjs";
|
|
6
6
|
import { UiComponentTunnelExit } from "../../components/UiComponentTunnel/UiComponentTunnelExit.mjs";
|
|
7
7
|
import FormField_module_default from "../../components/FormField/FormField.module.mjs";
|
|
8
|
-
import
|
|
8
|
+
import { FieldErrorRenderedContext } from "./fieldErrorRenderedContext.mjs";
|
|
9
|
+
import React, { useMemo, useState } from "react";
|
|
9
10
|
import { jsx } from "react/jsx-runtime";
|
|
10
11
|
//#region src/lib/hooks/useFieldError.tsx
|
|
11
12
|
var useFieldError = (options) => {
|
|
@@ -19,27 +20,39 @@ var useFieldError = (options) => {
|
|
|
19
20
|
},
|
|
20
21
|
className: FormField_module_default.fieldError
|
|
21
22
|
} };
|
|
22
|
-
const
|
|
23
|
-
return /* @__PURE__ */ jsx(PropsContextProvider, {
|
|
24
|
-
props: fieldErrorCapturePropsContext,
|
|
25
|
-
dependencies: [tunnelId],
|
|
26
|
-
children: props.children
|
|
27
|
-
});
|
|
28
|
-
}, [tunnelId]);
|
|
29
|
-
const FieldErrorView = () => {
|
|
30
|
-
if (currentTunnelId) return null;
|
|
31
|
-
return /* @__PURE__ */ jsx(UiComponentTunnelExit, {
|
|
32
|
-
id: tunnelId,
|
|
33
|
-
component: options.component,
|
|
34
|
-
children: (children) => {
|
|
35
|
-
const childrenArray = React.Children.toArray(children);
|
|
36
|
-
return /* @__PURE__ */ jsx(ClearPropsContext, { children: childrenArray[0] });
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
};
|
|
23
|
+
const [renderedFieldErrorId, setRenderedFieldErrorId] = useState();
|
|
40
24
|
return {
|
|
41
|
-
FieldErrorCaptureContext
|
|
42
|
-
|
|
25
|
+
FieldErrorCaptureContext: useMemo(() => (props) => {
|
|
26
|
+
return /* @__PURE__ */ jsx(PropsContextProvider, {
|
|
27
|
+
props: fieldErrorCapturePropsContext,
|
|
28
|
+
dependencies: [tunnelId],
|
|
29
|
+
children: props.children
|
|
30
|
+
});
|
|
31
|
+
}, [tunnelId]),
|
|
32
|
+
FieldErrorView: useMemo(() => () => {
|
|
33
|
+
if (currentTunnelId) return null;
|
|
34
|
+
return /* @__PURE__ */ jsx(FieldErrorRenderedContext, {
|
|
35
|
+
value: setRenderedFieldErrorId,
|
|
36
|
+
children: /* @__PURE__ */ jsx(UiComponentTunnelExit, {
|
|
37
|
+
id: tunnelId,
|
|
38
|
+
component: options.component,
|
|
39
|
+
children: (children) => {
|
|
40
|
+
const childrenArray = React.Children.toArray(children);
|
|
41
|
+
return /* @__PURE__ */ jsx(ClearPropsContext, { children: childrenArray[0] });
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
});
|
|
45
|
+
}, [
|
|
46
|
+
currentTunnelId,
|
|
47
|
+
tunnelId,
|
|
48
|
+
options.component
|
|
49
|
+
]),
|
|
50
|
+
/**
|
|
51
|
+
* The id of the error while one is rendered for this field. A nested field
|
|
52
|
+
* (a `Checkbox` inside a `CheckboxButton`) renders its error at the outer
|
|
53
|
+
* one, so only the outer field ever gets an id here.
|
|
54
|
+
*/
|
|
55
|
+
renderedFieldErrorId
|
|
43
56
|
};
|
|
44
57
|
};
|
|
45
58
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFieldError.mjs","names":[],"sources":["../../../../../../../src/lib/hooks/useFieldError.tsx"],"sourcesContent":["import React, {
|
|
1
|
+
{"version":3,"file":"useFieldError.mjs","names":[],"sources":["../../../../../../../src/lib/hooks/useFieldError.tsx"],"sourcesContent":["import React, {\n type FC,\n type PropsWithChildren,\n useMemo,\n useState,\n} from \"react\";\nimport { type PropsContext, PropsContextProvider } from \"@/lib/propsContext\";\nimport formFieldStyles from \"@/components/FormField/FormField.module.scss\";\nimport ClearPropsContext from \"@/lib/propsContext/components/ClearPropsContext\";\nimport { useProps } from \"@/lib/hooks/useProps\";\nimport { UiComponentTunnelExit } from \"@/components/UiComponentTunnel/UiComponentTunnelExit\";\nimport type { FlowComponentName } from \"@/components/propTypes\";\nimport { FieldErrorRenderedContext } from \"@/lib/hooks/fieldErrorRenderedContext\";\n\nexport interface UseFieldErrorOptions {\n fieldErrorId: string;\n tunnelId?: string;\n component: FlowComponentName;\n}\n\nexport const useFieldError = (options: UseFieldErrorOptions) => {\n const fieldErrorProps = useProps(\"FieldError\", {});\n const currentTunnelId = fieldErrorProps.tunnel?.id;\n const tunnelId =\n options.tunnelId ?? currentTunnelId ?? `${options.fieldErrorId}.fieldError`;\n\n const fieldErrorCapturePropsContext: PropsContext = {\n FieldError: {\n id: options.fieldErrorId,\n tunnel: { id: tunnelId, component: options.component },\n className: formFieldStyles.fieldError,\n },\n };\n\n const [renderedFieldErrorId, setRenderedFieldErrorId] = useState<string>();\n\n const FieldErrorCaptureContext: FC<PropsWithChildren> = useMemo(\n () => (props) => {\n return (\n <PropsContextProvider\n props={fieldErrorCapturePropsContext}\n dependencies={[tunnelId]}\n >\n {props.children}\n </PropsContextProvider>\n );\n },\n [tunnelId],\n );\n\n // Keep the component identity stable: a new one per render makes React\n // remount the error on every render of the field (each keystroke).\n const FieldErrorView: FC = useMemo(\n () => () => {\n if (currentTunnelId) {\n return null;\n }\n\n return (\n <FieldErrorRenderedContext value={setRenderedFieldErrorId}>\n <UiComponentTunnelExit id={tunnelId} component={options.component}>\n {(children) => {\n const childrenArray = React.Children.toArray(children);\n return <ClearPropsContext>{childrenArray[0]}</ClearPropsContext>;\n }}\n </UiComponentTunnelExit>\n </FieldErrorRenderedContext>\n );\n },\n [currentTunnelId, tunnelId, options.component],\n );\n\n return {\n FieldErrorCaptureContext,\n FieldErrorView,\n /**\n * The id of the error while one is rendered for this field. A nested field\n * (a `Checkbox` inside a `CheckboxButton`) renders its error at the outer\n * one, so only the outer field ever gets an id here.\n */\n renderedFieldErrorId,\n } as const;\n};\n"],"mappings":";;;;;;;;;;;AAoBA,IAAa,iBAAiB,YAAkC;CAE9D,MAAM,kBADkB,SAAS,cAAc,CAAC,CACxB,CAAA,CAAgB,QAAQ;CAChD,MAAM,WACJ,QAAQ,YAAY,mBAAmB,GAAG,QAAQ,aAAa;CAEjE,MAAM,gCAA8C,EAClD,YAAY;EACV,IAAI,QAAQ;EACZ,QAAQ;GAAE,IAAI;GAAU,WAAW,QAAQ;EAAU;EACrD,WAAW,yBAAgB;CAC7B,EACF;CAEA,MAAM,CAAC,sBAAsB,2BAA2B,SAAiB;CAsCzE,OAAO;EACL,0BArCsD,eAC/C,UAAU;GACf,OACE,oBAAC,sBAAD;IACE,OAAO;IACP,cAAc,CAAC,QAAQ;IAEtB,UAAA,MAAM;GACa,CAAA;EAE1B,GACA,CAAC,QAAQ,CA0BT;EACA,gBAtByB,oBACb;GACV,IAAI,iBACF,OAAO;GAGT,OACE,oBAAC,2BAAD;IAA2B,OAAO;IAChC,UAAA,oBAAC,uBAAD;KAAuB,IAAI;KAAU,WAAW,QAAQ;KACpD,WAAA,aAAa;MACb,MAAM,gBAAgB,MAAM,SAAS,QAAQ,QAAQ;MACrD,OAAO,oBAAC,mBAAD,EAAA,UAAoB,cAAc,GAAsB,CAAA;KACjE;IACqB,CAAA;GACE,CAAA;EAE/B,GACA;GAAC;GAAiB;GAAU,QAAQ;EAAS,CAK7C;;;;;;EAMA;CACF;AACF"}
|
|
@@ -8,8 +8,9 @@ export interface ActionGroupProps extends PropsWithChildren, FlowComponentProps<
|
|
|
8
8
|
/** The size of the buttons and links inside the action group. @default "m" */
|
|
9
9
|
size?: ButtonProps["size"];
|
|
10
10
|
/**
|
|
11
|
-
* When set, the buttons are not sorted
|
|
12
|
-
* order.
|
|
11
|
+
* When set, the buttons are not sorted into the slots `primary`, `secondary`
|
|
12
|
+
* and `abort` but stay in source order. Use it when the actions have no such
|
|
13
|
+
* hierarchy, e.g. a row of equal actions or icon buttons. @default false
|
|
13
14
|
*/
|
|
14
15
|
preserveOrder?: boolean;
|
|
15
16
|
}
|
|
@@ -3,7 +3,13 @@ import { FlowComponentProps } from '../../lib/componentFactory/flowComponent';
|
|
|
3
3
|
import { AlphaColor } from '../../lib/types/props';
|
|
4
4
|
import * as Aria from "react-aria-components";
|
|
5
5
|
export interface ButtonProps extends PropsWithChildren<Aria.ButtonProps>, FlowComponentProps<HTMLButtonElement> {
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Slot for button placement in action groups: `primary` (at the end),
|
|
8
|
+
* `secondary` (before the primary action) or `abort` (at the start). Without
|
|
9
|
+
* a slot, an action group places the colors primary, success and danger in
|
|
10
|
+
* `primary` and every other color in `abort`. A secondary-colored button that
|
|
11
|
+
* does not abort therefore needs `slot="secondary"`.
|
|
12
|
+
*/
|
|
7
13
|
slot?: string;
|
|
8
14
|
/**
|
|
9
15
|
* The color of the button.
|
|
@@ -4,6 +4,13 @@ import * as Recharts from "recharts";
|
|
|
4
4
|
export type YAxisProps<TData extends ChartDataValue = ChartDataValue, TDataKey extends DataKey<TData> = DataKey<TData>, TDataMatch = DataKeyValue<TData, TDataKey>> = Pick<Recharts.YAxisProps, "className" | "orientation" | "allowDecimals" | "interval" | "minTickGap" | "scale" | "type" | "domain" | "hide" | "unit"> & {
|
|
5
5
|
dataKey?: TDataKey;
|
|
6
6
|
tickFormatter?: (value: TDataMatch, index: number) => string;
|
|
7
|
+
/**
|
|
8
|
+
* The width of the axis in pixels. `"auto"` sizes the axis to its widest tick
|
|
9
|
+
* label. Defaults to `"auto"` for a category axis (e.g. with `layout` set to
|
|
10
|
+
* `"vertical"`) and to `60` otherwise. Pin a number to align the plot areas
|
|
11
|
+
* of synchronized charts.
|
|
12
|
+
*/
|
|
13
|
+
width?: number | "auto";
|
|
7
14
|
};
|
|
8
15
|
/**
|
|
9
16
|
* `tickFormatter` is deliberately not part of the remote surface. A function
|
|
@@ -2,7 +2,7 @@ import { PropsWithChildren } from 'react';
|
|
|
2
2
|
import { FileInputOnChangeHandler } from './components/FileInput';
|
|
3
3
|
import { FlowComponentProps } from '../../lib/componentFactory/flowComponent';
|
|
4
4
|
import type * as Aria from "react-aria-components";
|
|
5
|
-
export interface FileFieldProps extends PropsWithChildren, FlowComponentProps<HTMLInputElement>, Pick<Aria.InputProps, "accept" | "multiple" | "name">, Pick<Aria.TextFieldProps, "isRequired" | "isInvalid" | "validationBehavior" | "isDisabled"> {
|
|
5
|
+
export interface FileFieldProps extends PropsWithChildren, FlowComponentProps<HTMLInputElement>, Pick<Aria.InputProps, "accept" | "multiple" | "name" | "aria-describedby">, Pick<Aria.TextFieldProps, "isRequired" | "isInvalid" | "validationBehavior" | "isDisabled"> {
|
|
6
6
|
/** Handler that is called when the file input changes. */
|
|
7
7
|
onChange?: FileInputOnChangeHandler;
|
|
8
8
|
/** Whether the component is read only. */
|
|
@@ -19,6 +19,10 @@ export interface FlexProps extends PropsWithChildren, PropsWithClassName, PropsW
|
|
|
19
19
|
wrap?: CSSProperties["flexWrap"];
|
|
20
20
|
/** The padding of the element. */
|
|
21
21
|
padding?: "xs" | "s" | "m" | "l" | "xl";
|
|
22
|
+
/** The padding top and bottom of the element. Takes precedence over `padding`. */
|
|
23
|
+
paddingBlock?: "xs" | "s" | "m" | "l" | "xl";
|
|
24
|
+
/** The padding left and right of the element. Takes precedence over `padding`. */
|
|
25
|
+
paddingInline?: "xs" | "s" | "m" | "l" | "xl";
|
|
22
26
|
/** The padding top of the element. */
|
|
23
27
|
paddingTop?: "xs" | "s" | "m" | "l" | "xl";
|
|
24
28
|
/** The padding bottom of the element. */
|