@microbit/ui 0.1.0-alpha.17 → 0.1.0-alpha.18

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.
@@ -1,68 +0,0 @@
1
- /**
2
- * (c) 2026, Micro:bit Educational Foundation and contributors
3
- *
4
- * SPDX-License-Identifier: MIT
5
- */
6
- import { ReactNode } from "react";
7
- import { FieldError, Text as RACText } from "react-aria-components";
8
- import { css, cx } from "styled-system/css";
9
- import { field } from "styled-system/recipes";
10
- import { SystemStyleObject } from "styled-system/types";
11
-
12
- /**
13
- * The label/helper/error chrome every labelled form field shares — Chakra's
14
- * FormControl parts, generalised out of TextField so Select, ComboBox,
15
- * NumberField, RadioGroup and CheckboxGroup carry the same props
16
- * (data-microbit-org's forms attach helper and error text to all of these).
17
- */
18
- export interface FieldSupportProps {
19
- /** Help text below the field (Chakra's FormHelperText). */
20
- helperText?: ReactNode;
21
- /** Shown below the field when invalid (Chakra's FormErrorMessage). */
22
- errorMessage?: ReactNode;
23
- /** Per-instance style overrides for the helper text. */
24
- helperTextCss?: SystemStyleObject;
25
- }
26
-
27
- /**
28
- * Helper text and error message for a react-aria field container. Render
29
- * inside any RAC component with field validation context (TextField, Select,
30
- * ComboBox, NumberField, RadioGroup, CheckboxGroup) — react-aria wires the
31
- * description to the input's aria-describedby, and the error renders only
32
- * while the field is invalid. Also exported for app-side composites built on
33
- * RAC containers.
34
- */
35
- export const FieldSupport = ({
36
- helperText,
37
- errorMessage,
38
- helperTextCss,
39
- }: FieldSupportProps) => {
40
- const slots = field();
41
- return (
42
- <>
43
- {helperText != null && (
44
- <RACText
45
- slot="description"
46
- className={cx(
47
- slots.helperText,
48
- helperTextCss ? css(helperTextCss) : undefined,
49
- )}
50
- >
51
- {helperText}
52
- </RACText>
53
- )}
54
- <FieldError className={slots.errorMessage}>{errorMessage}</FieldError>
55
- </>
56
- );
57
- };
58
-
59
- /**
60
- * The required-field asterisk (Chakra's FormLabel indicator). Render inside
61
- * the field's label when `isRequired`; aria-hidden because react-aria already
62
- * announces requiredness from the input itself.
63
- */
64
- export const FieldRequiredIndicator = () => (
65
- <span aria-hidden className={field().requiredIndicator}>
66
- *
67
- </span>
68
- );
@@ -1,58 +0,0 @@
1
- /**
2
- * (c) 2026, Micro:bit Educational Foundation and contributors
3
- *
4
- * SPDX-License-Identifier: MIT
5
- */
6
- import { defineSlotRecipe } from "@pandacss/dev";
7
-
8
- /**
9
- * Field slot recipe — Chakra's FormControl parts (FormLabel/FormHelperText/
10
- * FormErrorMessage, light mode). Consumed by the shared-ui TextField, which
11
- * maps the slots onto react-aria-components' TextField/Label/Text/FieldError;
12
- * the input itself is styled by the `input` recipe (Input.recipe.ts).
13
- *
14
- * Registered in the base preset (base-preset.ts). No variants, so it
15
- * needs no `staticCss` entry.
16
- */
17
- export const field = defineSlotRecipe({
18
- className: "field",
19
- slots: ["root", "label", "requiredIndicator", "helperText", "errorMessage"],
20
- base: {
21
- root: {
22
- display: "flex",
23
- flexDirection: "column",
24
- alignItems: "stretch",
25
- width: "100%",
26
- },
27
- label: {
28
- display: "block",
29
- fontSize: "md",
30
- fontWeight: "medium",
31
- marginEnd: "3",
32
- mb: "2",
33
- "&[data-disabled]": { opacity: 0.4 },
34
- },
35
- requiredIndicator: {
36
- marginStart: "1",
37
- color: "danger.500",
38
- },
39
- helperText: {
40
- // RAC's Text renders a span, and RadioGroup/CheckboxGroup roots are not
41
- // flex containers to blockify it, where an inline box would drop the
42
- // margin below (gotcha #44).
43
- display: "block",
44
- mt: "2",
45
- fontSize: "sm",
46
- lineHeight: "normal",
47
- color: "gray.600",
48
- },
49
- errorMessage: {
50
- display: "flex",
51
- alignItems: "center",
52
- mt: "2",
53
- fontSize: "sm",
54
- lineHeight: "normal",
55
- color: "danger.500",
56
- },
57
- },
58
- });