@luscii-healthtech/web-ui 35.5.0 → 35.6.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.
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ type Props = {
3
+ errorText?: React.ReactNode;
4
+ errorTextId?: string;
5
+ helperText?: React.ReactNode;
6
+ helperTextId?: string;
7
+ };
8
+ export declare const HelperAndErrorText: (props: Props) => React.JSX.Element;
9
+ export {};
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+ import { Text } from "../components/Text/Text";
3
+ type Props = React.ComponentProps<typeof Text>;
4
+ export declare const LabelText: (props: Props) => React.JSX.Element;
5
+ export {};
@@ -0,0 +1,67 @@
1
+ import React from "react";
2
+ type Props = React.ComponentPropsWithRef<"input"> & {
3
+ /**
4
+ * The visual label next to the radio indicator.
5
+ */
6
+ children?: React.ReactNode;
7
+ /**
8
+ * Additional classes to apply to the radio input HTML element.
9
+ */
10
+ inputClassName?: string;
11
+ /**
12
+ * Making `name` required, since it's essential to make the radios
13
+ * work together in a group. Normally you would put the value of
14
+ * the selection here.
15
+ *
16
+ * @example "notification-method"
17
+ *
18
+ * ```tsx
19
+ * <StyledRadioGroup>
20
+ * <StyledRadio name="notification-method" id="email" value="email" />
21
+ * <StyledRadio name="notification-method" id="sms" value="sms" />
22
+ * </StyledRadioGroup>
23
+ * ```
24
+ */
25
+ name: string;
26
+ /**
27
+ * Making `id` required, since it's important for accessibility.
28
+ */
29
+ id: string;
30
+ /**
31
+ * The visual label next to the radio indicator.
32
+ * Alternative to `children` for when it's easier to just pass
33
+ * a string as a prop. Will be rendered inside a `<Text>` component.
34
+ */
35
+ label?: React.ReactNode;
36
+ /**
37
+ * Any additional information to show underneath the label.
38
+ */
39
+ helperText?: React.ReactNode;
40
+ /**
41
+ * An error message that should be shown when there's something wrong
42
+ * with the user's input.
43
+ */
44
+ errorText?: React.ReactNode;
45
+ };
46
+ /**
47
+ * @example
48
+ * ```tsx
49
+ * <StyledRadioGroup>
50
+ * <StyledRadio
51
+ * name="login-method"
52
+ * id="email"
53
+ * value="email"
54
+ * label="Email"
55
+ * />
56
+ * <StyledRadio
57
+ * name="login-method"
58
+ * id="sms"
59
+ * value="sms"
60
+ * label="SMS"
61
+ * helperText="We will use your phone number only for login purposes."
62
+ * />
63
+ * </StyledRadioGroup>
64
+ * ```
65
+ */
66
+ export declare const LabeledRadio: React.FC<Props>;
67
+ export {};
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ import { HelperAndErrorText } from "../../_internal/HelperAndErrorText";
3
+ type Props = React.ComponentProps<typeof HelperAndErrorText> & {
4
+ children?: React.ReactNode;
5
+ title?: string;
6
+ className?: string;
7
+ };
8
+ export declare const LabeledRadioGroup: React.FC<Props>;
9
+ export {};
@@ -1,5 +1,4 @@
1
1
  import React from "react";
2
- import "./RadioV2.css";
3
2
  export interface RadioProps extends React.InputHTMLAttributes<HTMLInputElement> {
4
3
  name: string;
5
4
  value: string | number;
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+ import "./RadioV2.css";
3
+ type Props = React.ComponentPropsWithRef<"input">;
4
+ export declare const StyledRadio: React.FC<Props>;
5
+ export {};
@@ -10,7 +10,7 @@ import "./Text.css";
10
10
  export declare const allowedTextStyles: {
11
11
  readonly sm: `${string} ui-font-medium`;
12
12
  readonly "sm-strong": `${string} ui-font-semibold ui-antialiased`;
13
- readonly base: string;
13
+ readonly base: `${string} ui-font-normal`;
14
14
  readonly medium: `${string} ui-font-medium ui-antialiased`;
15
15
  readonly strong: `${string} ui-font-semibold ui-antialiased`;
16
16
  readonly lg: "";
package/dist/index.d.ts CHANGED
@@ -36,6 +36,9 @@ export { InfoField } from "./components/InfoField/InfoField";
36
36
  export { default as Input } from "./components/Input/Input";
37
37
  export { FlyOutMenu } from "./components/FlyOutMenu/FlyOutMenu";
38
38
  export { StyledInput } from "./components/Input/StyledInput";
39
+ export { StyledRadio } from "./components/Radio/StyledRadio";
40
+ export { LabeledRadio } from "./components/Radio/LabeledRadio";
41
+ export { LabeledRadioGroup } from "./components/Radio/LabeledRadioGroup";
39
42
  export { default as Line } from "./components/Line/Line";
40
43
  export { Table, type TableProps } from "./components/Table/Table";
41
44
  export { prepareClientSidePagination } from "./components/Table/Table.utils";
@@ -984,7 +984,7 @@ const responsiveTextSizeVariants = {
984
984
  const allowedTextStyles = {
985
985
  sm: `${responsiveTextSizeVariants.sm} ui-font-medium`,
986
986
  "sm-strong": `${responsiveTextSizeVariants.sm} ui-font-semibold ui-antialiased`,
987
- base: responsiveTextSizeVariants.base,
987
+ base: `${responsiveTextSizeVariants.base} ui-font-normal`,
988
988
  medium: `${responsiveTextSizeVariants.base} ui-font-medium ui-antialiased`,
989
989
  strong: `${responsiveTextSizeVariants.base} ui-font-semibold ui-antialiased`,
990
990
  lg: "",
@@ -2773,44 +2773,46 @@ NotificationBanner.defaultProps = {
2773
2773
  onButtonClick: void 0
2774
2774
  };
2775
2775
 
2776
- var css_248z$a = ".ui-radio-form-field-label input[type=\"radio\"]:checked + .ui-radio-circle {\n\n --tw-bg-opacity: 1;\n\n background-color: rgb(30 64 175 / var(--tw-bg-opacity))\n}\n\n.ui-radio-form-field-label[data-has-error=\"true\"] .ui-radio-circle {\n\n --tw-border-opacity: 1;\n\n border-color: rgb(197 48 48 / var(--tw-border-opacity));\n\n outline-color: #FFF1F1\n}\n\n.ui-radio-form-field-label\n input[type=\"radio\"]:checked\n + .ui-radio-circle\n .ui-radio-inner-circle {\n\n --tw-bg-opacity: 1;\n\n background-color: rgb(255 255 255 / var(--tw-bg-opacity))\n}\n";
2776
+ const HelperAndErrorText = (props) => {
2777
+ const showHelperText = Boolean(props.helperText) && !props.errorText;
2778
+ return React__namespace.default.createElement(
2779
+ Box,
2780
+ null,
2781
+ props.errorText && React__namespace.default.createElement(Text, { variant: "sm", color: "red", id: props.errorTextId }, props.errorText),
2782
+ showHelperText && React__namespace.default.createElement(Text, { variant: "sm", color: "slate-500", id: props.helperTextId }, props.helperText)
2783
+ );
2784
+ };
2785
+
2786
+ var css_248z$a = ".ui-radio-form-field-label input[type=\"radio\"]:checked + .ui-radio-circle {\n --tw-bg-opacity: 1;\n background-color: rgb(30 64 175 / var(--tw-bg-opacity));\n --tw-border-opacity: 1;\n border-color: rgb(30 64 175 / var(--tw-border-opacity));\n}\n.ui-radio-form-field-label input[type=\"radio\"]:disabled + .ui-radio-circle {\n opacity: 0.5;\n}\n\n.ui-radio-form-field-label[data-has-error=\"true\"] .ui-radio-circle {\n --tw-border-opacity: 1;\n border-color: rgb(197 48 48 / var(--tw-border-opacity));\n outline-color: #FFF1F1;\n}\n\n.ui-radio-form-field-label\n input[type=\"radio\"]:checked\n + .ui-radio-circle\n .ui-radio-inner-circle {\n --tw-bg-opacity: 1;\n background-color: rgb(255 255 255 / var(--tw-bg-opacity));\n}\n";
2777
2787
  styleInject(css_248z$a);
2778
2788
 
2789
+ const StyledRadio = React__namespace.default.forwardRef((props, ref) => {
2790
+ const { className } = props, attributes = __rest(props, ["className"]);
2791
+ return React__namespace.default.createElement(
2792
+ React__namespace.default.Fragment,
2793
+ null,
2794
+ React__namespace.default.createElement("input", Object.assign({ type: "radio" }, attributes, { className: classNames__default.default("ui-hidden", className), ref })),
2795
+ React__namespace.default.createElement(
2796
+ "span",
2797
+ { "aria-hidden": true, className: classNames__default.default("ui-radio-circle ui-flex ui-h-4 ui-w-4 ui-flex-col ui-items-center ui-justify-center ui-rounded-xl ui-border ui-border-slate-300", "ui-transition-colors ui-duration-300 ui-ease-in-out") },
2798
+ React__namespace.default.createElement("span", { className: "ui-radio-inner-circle ui-block ui-h-1.5 ui-w-1.5 ui-rounded-xl ui-transition-colors ui-duration-300 ui-ease-in-out" })
2799
+ )
2800
+ );
2801
+ });
2802
+
2779
2803
  function RadioInner(_a) {
2780
2804
  var { text, info, isError, innerRef, className, name } = _a, otherProps = __rest(_a, ["text", "info", "isError", "innerRef", "className", "name"]);
2781
2805
  const { value, disabled } = otherProps;
2782
2806
  const nameHtmlFor = `${name}-field-${value}`;
2783
2807
  return React__namespace.default.createElement(
2784
- "label",
2785
- { className: "ui-radio-form-field-label ui-flex ui-flex-row ui-leading-tight", htmlFor: nameHtmlFor, "data-has-error": isError, "data-test-id": nameHtmlFor },
2786
- React__namespace.default.createElement(
2787
- "div",
2788
- { className: "ui-flex ui-flex-row ui-items-center ui-self-start" },
2789
- React__namespace.default.createElement("input", Object.assign({}, otherProps, {
2790
- name,
2791
- // To consider: the tailwind forms plugin adds specific styles for form inputs,
2792
- // including radio buttons. Is it worth changing to that?
2793
- className: classNames__default.default("ui-hidden", className),
2794
- ref: innerRef,
2795
- type: "radio",
2796
- id: nameHtmlFor,
2797
- disabled
2798
- })),
2799
- React__namespace.default.createElement(
2800
- "span",
2801
- { className: classNames__default.default("ui-radio-circle ui-flex ui-h-4 ui-w-4 ui-flex-col ui-items-center ui-justify-center ui-rounded-xl ui-border ui-border-slate-300 ui-transition-colors ui-duration-300 ui-ease-in-out") },
2802
- React__namespace.default.createElement("span", { className: "ui-radio-inner-circle ui-block ui-h-1.5 ui-w-1.5 ui-rounded-xl ui-transition-colors ui-duration-300 ui-ease-in-out" })
2803
- )
2804
- ),
2808
+ Stack,
2809
+ { as: "label", axis: "x", gap: "xs", className: "ui-radio-form-field-label ui-flex ui-flex-row ui-leading-none", htmlFor: nameHtmlFor, "data-has-error": isError, "data-test-id": nameHtmlFor },
2810
+ React__namespace.default.createElement(StyledRadio, Object.assign({}, otherProps, { name, id: nameHtmlFor, ref: innerRef })),
2805
2811
  React__namespace.default.createElement(
2806
2812
  "div",
2807
2813
  null,
2808
- text && React__namespace.default.createElement(
2809
- "div",
2810
- { className: "ui-ml-2 ui-flex ui-items-center" },
2811
- React__namespace.default.createElement(Text, { inline: true, text, type: "base", color: disabled ? "slate-500" : void 0 })
2812
- ),
2813
- info && React__namespace.default.createElement(Text, { className: "ui-ml-2 ui-leading-4", text: info, type: "sm", color: disabled ? "slate-500" : void 0 })
2814
+ text && React__namespace.default.createElement(Text, { inline: true, variant: "base", color: disabled ? "slate-500" : void 0 }, text),
2815
+ React__namespace.default.createElement(HelperAndErrorText, { helperText: info })
2814
2816
  )
2815
2817
  );
2816
2818
  }
@@ -3508,6 +3510,60 @@ const FlyOutMenu = {
3508
3510
  SwitchItem: FlyOutMenuSwitchItem
3509
3511
  };
3510
3512
 
3513
+ const LabelText = (props) => {
3514
+ return React__namespace.default.createElement(Text, Object.assign({}, props));
3515
+ };
3516
+
3517
+ const LabeledRadio = React__namespace.default.forwardRef((props, ref) => {
3518
+ const { children, label, helperText, errorText, className, inputClassName } = props, attributes = __rest(props, ["children", "label", "helperText", "errorText", "className", "inputClassName"]);
3519
+ const { id, disabled } = attributes;
3520
+ return React__namespace.default.createElement(
3521
+ Stack,
3522
+ { as: "label", axis: "x", gap: "xs", htmlFor: id, className: classNames__default.default("ui-radio-form-field-label", className) },
3523
+ React__namespace.default.createElement(
3524
+ "div",
3525
+ { className: "ui-relative ui-flex ui-flex-row ui-items-center ui-self-start" },
3526
+ React__namespace.default.createElement(Text, { "aria-hidden": true, className: "ui-w-4 ui-opacity-0" }, "CENTER"),
3527
+ React__namespace.default.createElement(
3528
+ "div",
3529
+ { className: "ui-absolute" },
3530
+ React__namespace.default.createElement(StyledRadio, Object.assign({ "aria-describedby": `${id}-helper-text ${id}-error-text` }, attributes, { ref, className: inputClassName }))
3531
+ )
3532
+ ),
3533
+ React__namespace.default.createElement(
3534
+ "div",
3535
+ null,
3536
+ React__namespace.default.createElement(RadioLabel, { label, disabled }, children),
3537
+ React__namespace.default.createElement(HelperAndErrorText, { helperText, helperTextId: `${id}-helper-text`, errorText, errorTextId: `${id}-error-text` })
3538
+ )
3539
+ );
3540
+ });
3541
+ function RadioLabel(props) {
3542
+ const { children, label, disabled } = props;
3543
+ if (!label && !children) {
3544
+ return null;
3545
+ }
3546
+ if (children) {
3547
+ return children;
3548
+ }
3549
+ return React__namespace.default.createElement(LabelText, { color: disabled ? "slate-500" : void 0 }, label);
3550
+ }
3551
+
3552
+ const LabeledRadioGroup = (props) => {
3553
+ const { children, title, className, errorText, errorTextId, helperText, helperTextId } = props;
3554
+ return React__namespace.default.createElement(
3555
+ Stack,
3556
+ { as: "fieldset", className: classNames__default.default(className), gap: "xxxxs" },
3557
+ title && React__namespace.default.createElement(
3558
+ "legend",
3559
+ { className: "ui-contents" },
3560
+ React__namespace.default.createElement(Text, null, title)
3561
+ ),
3562
+ React__namespace.default.createElement(Stack, { gap: "xxs" }, children),
3563
+ React__namespace.default.createElement(HelperAndErrorText, { errorText, errorTextId, helperText, helperTextId })
3564
+ );
3565
+ };
3566
+
3511
3567
  const Line = ({ left, right, className }) => /* @__PURE__ */ React__namespace.default.createElement(
3512
3568
  "div",
3513
3569
  {
@@ -6731,6 +6787,8 @@ exports.ImageIcon = ImageIcon;
6731
6787
  exports.InfoField = InfoField;
6732
6788
  exports.InfoIcon = InfoIcon;
6733
6789
  exports.Input = Input;
6790
+ exports.LabeledRadio = LabeledRadio;
6791
+ exports.LabeledRadioGroup = LabeledRadioGroup;
6734
6792
  exports.LeftArrowIcon = LeftArrowIcon;
6735
6793
  exports.LifebuoyIcon = LifebuoyIcon;
6736
6794
  exports.LightBulbIcon = LightBulbIcon;
@@ -6805,6 +6863,7 @@ exports.Steps = Steps;
6805
6863
  exports.StopwatchIcon = StopwatchIcon;
6806
6864
  exports.StyledInput = StyledInput;
6807
6865
  exports.StyledOrderedList = StyledOrderedList;
6866
+ exports.StyledRadio = StyledRadio;
6808
6867
  exports.StyledUnorderedList = StyledUnorderedList;
6809
6868
  exports.Switch = Switch;
6810
6869
  exports.Switcher = Switcher;