@luscii-healthtech/web-ui 8.0.1 → 8.0.3

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.
@@ -4,34 +4,52 @@ export declare enum CheckboxState {
4
4
  UNCHECKED = "unchecked"
5
5
  }
6
6
  export interface CheckboxListProps {
7
+ /**
8
+ * An array of items to render as checkboxes. Each item can be a single item or a group. When the
9
+ * title isn't specified, the group will render as a non-collapsible list. This is the way to
10
+ * render a regular list of checkboxes.
11
+ *
12
+ * @example
13
+ * Single list of checkboxes without visual grouping.
14
+ *
15
+ * ```tsx
16
+ * const groups = [{
17
+ * items: [
18
+ * {
19
+ * id: "1",
20
+ * label: "Item 1",
21
+ * },
22
+ * {
23
+ * id: "2",
24
+ * label: "Item 2",
25
+ * },
26
+ * ],
27
+ * }]
28
+ * ```
29
+ */
7
30
  groups: CheckboxGroup[];
8
31
  onChange: (event: CheckboxChangeEvent) => void;
32
+ /**
33
+ * Renders dividers between each item, including groups and inside of groups.
34
+ */
9
35
  hasDividers?: boolean;
10
36
  className?: string;
11
37
  }
12
38
  type WithCollapsible = {
13
39
  /**
14
- * When `false`, will prevent the checkbox list from being collapsed (also disabling clicking to expand/collapse)
40
+ * When `false` will prevent the checkbox list from being collapsed (also disabling clicking to expand/collapse)
15
41
  * in the component and it will be displayed expanded by default.
16
42
  * @default true
17
43
  */
18
44
  collapsible?: boolean;
19
45
  };
20
- export type CheckboxGroupProps = {
21
- title?: string;
22
- items: CheckboxListItem[];
46
+ export type CheckboxGroupProps = CheckboxGroup & {
23
47
  onChange: (event: CheckboxChangeEvent) => void;
24
48
  hasDividers?: boolean;
25
49
  className?: string;
26
- isCollapsed?: boolean;
27
50
  } & WithCollapsible;
28
- export interface CheckboxGroupItemProps {
29
- id: string;
30
- label: string;
31
- isChecked?: boolean;
32
- isDisabled?: boolean;
51
+ export interface CheckboxGroupItemProps extends CheckboxListItem {
33
52
  onChange: (event: CheckboxChangeEvent) => void;
34
- className?: string;
35
53
  }
36
54
  export interface CheckboxListItem {
37
55
  id: string;
@@ -41,8 +59,17 @@ export interface CheckboxListItem {
41
59
  className?: string;
42
60
  }
43
61
  export type CheckboxGroup = {
62
+ /**
63
+ * When the title isn't specified, the group will render as a non-collapsible list.
64
+ */
44
65
  title?: string;
66
+ /**
67
+ * The checkbox items to be shown inside of this group.
68
+ */
45
69
  items: CheckboxListItem[];
70
+ /**
71
+ * Whether the group is initially collapsed or not.
72
+ */
46
73
  isCollapsed?: boolean;
47
74
  } & WithCollapsible;
48
75
  export interface CheckboxChangeEvent {
@@ -212,35 +212,33 @@ const allowedGroupHoverColors = {
212
212
  white: "ui-group-hover:ui-text-white"
213
213
  };
214
214
  const Text = (props) => {
215
- var _a, _b, _c;
216
- const { children } = props, rest = __rest(props, ["children"]);
217
- const Component = props.inline ? "span" : "p";
218
- const resolvedVariant = (_a = props.type) !== null && _a !== void 0 ? _a : props.variant;
219
- const selectedHoverColor = props.hoverColor && !props.hoverInGroup && allowedHoverColors[props.hoverColor];
220
- const selectedGroupHoverColor = props.hoverColor && props.hoverInGroup && allowedGroupHoverColors[props.hoverColor];
215
+ var _a;
216
+ const { children, text, type, variant, inline, color, hoverColor, hoverInGroup, className, containsDangerousHtml, truncate, clampLines } = props, rest = __rest(props, ["children", "text", "type", "variant", "inline", "color", "hoverColor", "hoverInGroup", "className", "containsDangerousHtml", "truncate", "clampLines"]);
217
+ const Component = inline ? "span" : "p";
218
+ const resolvedVariant = type !== null && type !== void 0 ? type : variant;
219
+ const selectedHoverColor = hoverColor && !hoverInGroup && allowedHoverColors[hoverColor];
220
+ const selectedGroupHoverColor = hoverColor && hoverInGroup && allowedGroupHoverColors[hoverColor];
221
221
  const containerProps = {
222
- title: props.title,
223
- "data-test-id": props["data-test-id"],
224
222
  className: classNames__default.default(
225
223
  // apply different style classes
226
224
  // for now we stick with ui-font-size 16px on the body
227
225
  // so I am adjusting our styles accordingly (one step down)
228
226
  allowedTextStyles[resolvedVariant !== null && resolvedVariant !== void 0 ? resolvedVariant : "base"],
229
- allowedColors[(_b = props.color) !== null && _b !== void 0 ? _b : "base"],
227
+ allowedColors[color !== null && color !== void 0 ? color : "base"],
230
228
  selectedHoverColor,
231
229
  selectedGroupHoverColor,
232
230
  {
233
- "ui-inline": props.inline,
231
+ "ui-inline": inline,
234
232
  // FIXME: this class doesn't do anything without a ui-max-width
235
- "ui-truncate": props.truncate,
236
- "ui-text-two-lines-max": props.clampLines,
237
- "in-html-link": props.containsDangerousHtml
233
+ "ui-truncate": truncate,
234
+ "ui-text-two-lines-max": clampLines,
235
+ "in-html-link": containsDangerousHtml
238
236
  },
239
- //can be used to overwrite other classes like the color
240
- props.className
237
+ // can be used to overwrite other classes like the color
238
+ className
241
239
  )
242
240
  };
243
- return props.containsDangerousHtml ? React__namespace.default.createElement(Component, Object.assign({}, rest, containerProps, { dangerouslySetInnerHTML: { __html: (_c = children !== null && children !== void 0 ? children : props.text) !== null && _c !== void 0 ? _c : "" } })) : React__namespace.default.createElement(Component, Object.assign({}, rest, containerProps), children !== null && children !== void 0 ? children : props.text);
241
+ return containsDangerousHtml ? React__namespace.default.createElement(Component, Object.assign({}, rest, containerProps, { dangerouslySetInnerHTML: { __html: (_a = children !== null && children !== void 0 ? children : text) !== null && _a !== void 0 ? _a : "" } })) : React__namespace.default.createElement(Component, Object.assign({}, rest, containerProps), children !== null && children !== void 0 ? children : text);
244
242
  };
245
243
  Text.defaultProps = {
246
244
  variant: "base",